From bf2dd06085a5320b7abaf259a0100000f02570e6 Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Mon, 8 Jan 2024 16:48:34 +1000 Subject: [PATCH] Add sorting options for meta queries. --- src/client.ts | 14 ++++++++++++-- src/interfaces.ts | 2 +- src/types.ts | 5 +++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index e02d1d4..ea4ebd3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -133,8 +133,18 @@ export class QuantClient { * @returns Promise * The repsonse object. */ - meta: async (): Promise => { - return await this._project.get('global-meta') + meta: async (filters?: types.MetaFilters): Promise => { + const qs: { sort_direction?: string, sort_field?: string } = {} + + if (filters?.sort_direction != null) { + qs.sort_direction = filters.sort_direction + } + + if (filters?.sort_field != null) { + qs.sort_field = filters.sort_field + } + + return await this._project.get('global-meta', qs) }, /** diff --git a/src/interfaces.ts b/src/interfaces.ts index a156c12..ff8dc74 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -15,7 +15,7 @@ export interface Client { export interface ProjectApi { ping: () => Promise - meta: () => Promise + meta: (filter?: types.MetaFilters) => Promise markup: (payload: types.MarkupPayload) => Promise file: (payload: types.FilePayload) => Promise publish: (payload: types.PublishPayload) => Promise diff --git a/src/types.ts b/src/types.ts index dd04652..82fe5e9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -69,3 +69,8 @@ export interface WafLog { method: string user_agent: string } + +export interface MetaFilters { + sort_field: string + sort_direction: string +}