From 38ccf8d61cfa28e768859b65e19ee08190c5fca7 Mon Sep 17 00:00:00 2001 From: Rohan Juneja Date: Thu, 23 May 2024 16:45:56 -0700 Subject: [PATCH] allow pagination to be passed in through smartapi yaml --- src/parser/query_operation.ts | 14 +++++++++++++- src/parser/types.ts | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/parser/query_operation.ts b/src/parser/query_operation.ts index 13bcd37..281e937 100644 --- a/src/parser/query_operation.ts +++ b/src/parser/query_operation.ts @@ -1,4 +1,4 @@ -import { QueryOperationInterface, XBTEKGSOperationObject, XBTEParametersObject } from "./types"; +import { PaginationData, QueryOperationInterface, XBTEKGSOperationObject, XBTEParametersObject } from "./types"; export default class QueryOperationObject implements QueryOperationInterface { private _params: XBTEParametersObject; @@ -14,6 +14,8 @@ export default class QueryOperationObject implements QueryOperationInterface { private _tags: string[]; private _pathParams: string[]; private _templateInputs: any; + private _paginated: boolean; + private _paginationData: PaginationData; set xBTEKGSOperation(newOp: XBTEKGSOperationObject) { this._params = newOp.parameters; @@ -24,6 +26,8 @@ export default class QueryOperationObject implements QueryOperationInterface { this._inputSeparator = newOp.inputSeparator; this._templateInputs = newOp.templateInputs; this._batchSize = newOp.batchSize; + this._paginated = !!newOp.pagination?.countField && !!newOp.pagination?.pageSize && !!newOp.pagination?.totalField; + this._paginationData = newOp.pagination; } get templateInputs(): any { @@ -97,4 +101,12 @@ export default class QueryOperationObject implements QueryOperationInterface { set path_params(newPathParams: string[]) { this._pathParams = newPathParams; } + + get paginated(): boolean { + return this._paginated; + } + + get paginationData(): PaginationData { + return this._paginationData; + } } diff --git a/src/parser/types.ts b/src/parser/types.ts index c8a2f3e..909e808 100644 --- a/src/parser/types.ts +++ b/src/parser/types.ts @@ -107,6 +107,12 @@ export interface XBTEKGSOperationBioEntityObject { semantic: string; } +export interface PaginationData { + countField: string; + totalField: string; + pageSize: number; +} + export interface XBTEKGSOperationObject { inputs: XBTEKGSOperationBioEntityObject[]; outputs: XBTEKGSOperationBioEntityObject[]; @@ -125,6 +131,7 @@ export interface XBTEKGSOperationObject { batchSize?: number; knowledge_level?: string; agent_type?: string; + pagination?: PaginationData; } export interface SmartAPISpec { @@ -184,6 +191,8 @@ export interface QueryOperationInterface { inputSeparator: string; useTemplating?: boolean; templateInputs?: any; + paginated?: boolean; + paginationData?: PaginationData; } export interface SmartAPIKGOperationObject {