Skip to content

Commit

Permalink
Add filters to invocations API (#138)
Browse files Browse the repository at this point in the history
Signed-off-by: Nik Nasr <[email protected]>
  • Loading branch information
nikrooz authored Jan 2, 2025
1 parent d8542b6 commit 1e85c6d
Show file tree
Hide file tree
Showing 10 changed files with 574 additions and 24 deletions.
16 changes: 13 additions & 3 deletions libs/data-access/admin-api/src/lib/api/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import {
SupportedMethods,
} from './client';
import { useAdminBaseUrl } from '../AdminBaseUrlProvider';
import type { DeploymentId, Revision, ServiceName, Deployment } from './type';
import type {
DeploymentId,
Revision,
ServiceName,
Deployment,
FilterItem,
} from './type';

type HookQueryOptions<
Path extends keyof paths,
Expand Down Expand Up @@ -232,11 +238,15 @@ export function useServiceOpenApi(
}

export function useListInvocations(
options?: HookQueryOptions<'/query/invocations', 'get'>
filters?: FilterItem[],
options?: HookQueryOptions<'/query/invocations', 'post'>
) {
const baseUrl = useAdminBaseUrl();
const queryOptions = adminApi('query', '/query/invocations', 'get', {
const queryOptions = adminApi('query', '/query/invocations', 'post', {
baseUrl,
body: {
filters,
},
});

const results = useQuery({
Expand Down
56 changes: 52 additions & 4 deletions libs/data-access/admin-api/src/lib/api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ export interface paths {
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/**
* List invocations
* @description List invocations
*/
get: operations['list_invocations'];
put?: never;
post?: never;
post: operations['list_invocations'];
delete?: never;
options?: never;
head?: never;
Expand Down Expand Up @@ -830,6 +830,50 @@ export interface components {
*/
services: components['schemas']['ServiceMetadata'][];
};
ListInvocationsRequestBody: {
filters?: components['schemas']['FilterItem'][];
};
FilterItem: components['schemas']['FilterBaseItem'] &
(
| components['schemas']['FilterNumberItem']
| components['schemas']['FilterStringItem']
| components['schemas']['FilterDateItem']
| components['schemas']['FilterStringListItem']
);
FilterBaseItem: {
/** @enum {string} */
type: 'STRING' | 'NUMBER' | 'DATE' | 'STRING_LIST';
field: string;
};
FilterNumberItem: {
/** @enum {string} */
type: 'NUMBER';
/** @enum {string} */
operation: 'EQUALS' | 'NOT_EQUALS' | 'GREATER_THAN' | 'LESS_THAN';
value?: number;
};
FilterStringItem: {
/** @enum {string} */
type: 'STRING';
/** @enum {string} */
operation: 'EQUALS' | 'NOT_EQUALS' | 'CONTAINS';
value?: string;
};
FilterStringListItem: {
/** @enum {string} */
type: 'STRING_LIST';
/** @enum {string} */
operation: 'IN' | 'NOT_IN';
value: string[];
};
FilterDateItem: {
/** @enum {string} */
type: 'DATE';
/** @enum {string} */
operation: 'BEFORE' | 'AFTER';
/** Format: date-time */
value: string;
};
StateInterfaceResponse: {
keys?: {
name: string;
Expand Down Expand Up @@ -2376,7 +2420,11 @@ export interface operations {
path?: never;
cookie?: never;
};
requestBody?: never;
requestBody: {
content: {
'application/json': components['schemas']['ListInvocationsRequestBody'];
};
};
responses: {
200: {
headers: {
Expand Down
131 changes: 130 additions & 1 deletion libs/data-access/admin-api/src/lib/api/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -1491,11 +1491,21 @@
}
},
"/query/invocations": {
"get": {
"post": {
"tags": ["query-invocations"],
"summary": "List invocations",
"description": "List invocations",
"operationId": "list_invocations",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListInvocationsRequestBody"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "",
Expand Down Expand Up @@ -2725,6 +2735,125 @@
}
]
},
"ListInvocationsRequestBody": {
"type": "object",
"properties": {
"filters": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FilterItem"
}
}
}
},
"FilterItem": {
"allOf": [
{
"$ref": "#/components/schemas/FilterBaseItem"
},
{
"oneOf": [
{
"$ref": "#/components/schemas/FilterNumberItem"
},
{
"$ref": "#/components/schemas/FilterStringItem"
},
{
"$ref": "#/components/schemas/FilterDateItem"
},
{
"$ref": "#/components/schemas/FilterStringListItem"
}
]
}
]
},
"FilterBaseItem": {
"type": "object",
"required": ["type", "field"],
"properties": {
"type": {
"type": "string",
"enum": ["STRING", "NUMBER", "DATE", "STRING_LIST"]
},
"field": {
"type": "string"
}
}
},
"FilterNumberItem": {
"type": "object",
"required": ["type", "operation"],
"properties": {
"type": {
"type": "string",
"enum": ["NUMBER"]
},
"operation": {
"type": "string",
"enum": ["EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN"]
},
"value": {
"type": "number"
}
}
},
"FilterStringItem": {
"type": "object",
"required": ["type", "operation"],
"properties": {
"type": {
"type": "string",
"enum": ["STRING"]
},
"operation": {
"type": "string",
"enum": ["EQUALS", "NOT_EQUALS", "CONTAINS"]
},
"value": {
"type": "string"
}
}
},
"FilterStringListItem": {
"type": "object",
"required": ["type", "operation", "value"],
"properties": {
"type": {
"type": "string",
"enum": ["STRING_LIST"]
},
"operation": {
"type": "string",
"enum": ["IN", "NOT_IN"]
},
"value": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"FilterDateItem": {
"type": "object",
"required": ["type", "operation", "value"],
"properties": {
"type": {
"type": "string",
"enum": ["DATE"]
},
"operation": {
"type": "string",
"enum": ["BEFORE", "AFTER"]
},
"value": {
"type": "string",
"format": "date-time"
}
}
},
"StateInterfaceResponse": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit 1e85c6d

Please sign in to comment.