Skip to content

Commit

Permalink
allow pagination to be passed in through smartapi yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
rjawesome committed May 23, 2024
1 parent 43c47bc commit 38ccf8d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/parser/query_operation.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
}
9 changes: 9 additions & 0 deletions src/parser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -125,6 +131,7 @@ export interface XBTEKGSOperationObject {
batchSize?: number;
knowledge_level?: string;
agent_type?: string;
pagination?: PaginationData;
}

export interface SmartAPISpec {
Expand Down Expand Up @@ -184,6 +191,8 @@ export interface QueryOperationInterface {
inputSeparator: string;
useTemplating?: boolean;
templateInputs?: any;
paginated?: boolean;
paginationData?: PaginationData;
}

export interface SmartAPIKGOperationObject {
Expand Down

0 comments on commit 38ccf8d

Please sign in to comment.