Skip to content

Commit

Permalink
Merge pull request #90 from biothings/monarch-pagination
Browse files Browse the repository at this point in the history
allow pagination to be passed in through smartapi yaml
  • Loading branch information
tokebe authored Aug 20, 2024
2 parents 8914774 + 38ccf8d commit a328307
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;

static unfreeze(obj: any) {
const newObj = new QueryOperationObject();
Expand Down Expand Up @@ -42,6 +44,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 @@ -115,4 +119,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 a328307

Please sign in to comment.