Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow pagination to be passed in through smartapi yaml #90

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading