Skip to content

Commit

Permalink
Fix query params based omni api calls (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson authored Apr 9, 2024
1 parent 6002877 commit 8f673ab
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 41 deletions.
8 changes: 7 additions & 1 deletion packages/omniapi-generator/src/generateResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ function generateOperationArray(method: StaticOperation) {
const requestType = method.requestBody?.body.requestType;
const bodyInfo = getReqBodyInfo(requestType);
const respInfo = getResponseInfo(method.response);
const paramInfo = getParamInfo(method.parameters);
paramInfo.QUERY.length;

const flag = (bodyInfo.componentType != null ? 1 : 0)
+ (paramInfo.QUERY.length > 0 ? 2 : 0)
+ (paramInfo.HEADER.length > 0 ? 4 : 0);

let count = 0;
const constParts = [
HTTP_VERB_MAP[method.httpMethod],
`"${method.path.replace(/{.*?}/g, () => `{${count++}}`)}"`,
bodyInfo.componentType != null ? 1 : "",
flag > 0 ? flag : "",
bodyInfo.mimeType,
respInfo.mimeType,
];
Expand Down
2 changes: 1 addition & 1 deletion packages/omniapi/src/public/Datasets_Branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const _listBranches: $OmniMethod<
datasetRid: $C.DatasetRid,
$queryParams?: { pageSize?: $C.PageSize; pageToken?: $C.PageToken },
) => Promise<$C.ListBranchesResponse>
> = [0, "/v1/datasets/{0}/branches"];
> = [0, "/v1/datasets/{0}/branches", 2];

/**
* Lists the Branches of a Dataset.
Expand Down
8 changes: 4 additions & 4 deletions packages/omniapi/src/public/Datasets_Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const _readTable: $OmniMethod<
rowLimit?: number;
},
) => Promise<unknown>
> = [0, "/v1/datasets/{0}/readTable", , , "*/*"];
> = [0, "/v1/datasets/{0}/readTable", 2, , "*/*"];

/**
* Gets the content of a dataset as a table in the specified format.
Expand Down Expand Up @@ -110,7 +110,7 @@ const _getSchema: $OmniMethod<
preview?: $C.PreviewMode;
},
) => Promise<any | undefined>
> = [0, "/v1/datasets/{0}/schema"];
> = [0, "/v1/datasets/{0}/schema", 2];

/**
* Retrieves the Schema for a Dataset and Branch, if it exists.
Expand Down Expand Up @@ -139,7 +139,7 @@ const _putSchema: $OmniMethod<
$body: any,
$queryParams?: { branchId?: $C.BranchId; preview?: $C.PreviewMode },
) => Promise<void>
> = [2, "/v1/datasets/{0}/schema", 1];
> = [2, "/v1/datasets/{0}/schema", 3];

/**
* Puts a Schema on an existing Dataset and Branch.
Expand Down Expand Up @@ -167,7 +167,7 @@ const _deleteSchema: $OmniMethod<
preview?: $C.PreviewMode;
},
) => Promise<void>
> = [3, "/v1/datasets/{0}/schema"];
> = [3, "/v1/datasets/{0}/schema", 2];

/**
* Deletes the Schema from a Dataset and Branch.
Expand Down
10 changes: 5 additions & 5 deletions packages/omniapi/src/public/Datasets_File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const _listFiles: $OmniMethod<
pageToken?: $C.PageToken;
},
) => Promise<$C.ListFilesResponse>
> = [0, "/v1/datasets/{0}/files"];
> = [0, "/v1/datasets/{0}/files", 2];

/**
* Lists Files contained in a Dataset. By default files are listed on the latest view of the default
Expand Down Expand Up @@ -92,7 +92,7 @@ const _uploadFile: $OmniMethod<
transactionRid?: $C.TransactionRid;
},
) => Promise<$C.File>
> = [1, "/v1/datasets/{0}/files:upload", , "*/*"];
> = [1, "/v1/datasets/{0}/files:upload", 2, "*/*"];

/**
* Uploads a File to an existing Dataset.
Expand Down Expand Up @@ -145,7 +145,7 @@ const _getFileMetadata: $OmniMethod<
endTransactionRid?: $C.TransactionRid;
},
) => Promise<$C.File>
> = [0, "/v1/datasets/{0}/files/{1}"];
> = [0, "/v1/datasets/{0}/files/{1}", 2];

/**
* Gets metadata about a File contained in a Dataset. By default this retrieves the file's metadata from the latest
Expand Down Expand Up @@ -201,7 +201,7 @@ const _deleteFile: $OmniMethod<
transactionRid?: $C.TransactionRid;
},
) => Promise<void>
> = [3, "/v1/datasets/{0}/files/{1}"];
> = [3, "/v1/datasets/{0}/files/{1}", 2];

/**
* Deletes a File from a Dataset. By default the file is deleted in a new transaction on the default
Expand Down Expand Up @@ -249,7 +249,7 @@ const _getFileContent: $OmniMethod<
endTransactionRid?: $C.TransactionRid;
},
) => Promise<unknown>
> = [0, "/v1/datasets/{0}/files/{1}/content", , , "*/*"];
> = [0, "/v1/datasets/{0}/files/{1}/content", 2, , "*/*"];

/**
* Gets the content of a File contained in a Dataset. By default this retrieves the file's content from the latest
Expand Down
2 changes: 1 addition & 1 deletion packages/omniapi/src/public/Datasets_Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const _createTransaction: $OmniMethod<
$body: $C.CreateTransactionRequest,
$queryParams?: { branchId?: $C.BranchId },
) => Promise<$C.Transaction>
> = [1, "/v1/datasets/{0}/transactions", 1];
> = [1, "/v1/datasets/{0}/transactions", 3];

/**
* Creates a Transaction on a Branch of a Dataset.
Expand Down
2 changes: 1 addition & 1 deletion packages/omniapi/src/public/Models_LanguageModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const _listLanguageModels: $OmniMethod<
($queryParams?: {
source?: $C.LanguageModelSource;
}) => Promise<$C.ListLanguageModelsResponse>
> = [0, "/v1/models/languageModels"];
> = [0, "/v1/models/languageModels", 2];

/**
* Lists the language models available. Can be filtered by source.
Expand Down
6 changes: 3 additions & 3 deletions packages/omniapi/src/public/OntologiesV2_Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const _applyActionV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.SyncApplyActionResponseV2>
> = [1, "/v2/ontologies/{0}/actions/{1}/apply", 1];
> = [1, "/v2/ontologies/{0}/actions/{1}/apply", 3];

/**
* Applies an action using the given parameters.
Expand Down Expand Up @@ -72,7 +72,7 @@ const _applyActionBatchV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.BatchApplyActionResponseV2>
> = [1, "/v2/ontologies/{0}/actions/{1}/applyBatch", 1];
> = [1, "/v2/ontologies/{0}/actions/{1}/applyBatch", 3];

/**
* Applies multiple actions (of the same Action Type) using the given parameters.
Expand Down Expand Up @@ -112,7 +112,7 @@ const _applyActionAsyncV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.AsyncApplyActionResponseV2>
> = [1, "/v2/ontologies/{0}/actions/{1}/applyAsync", 1];
> = [1, "/v2/ontologies/{0}/actions/{1}/applyAsync", 3];

/**
* Applies an action using the given parameters.
Expand Down
2 changes: 1 addition & 1 deletion packages/omniapi/src/public/OntologiesV2_ActionTypeV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const _listActionTypesV2: $OmniMethod<
ontology: $C.OntologyIdentifier,
$queryParams?: { pageSize?: $C.PageSize; pageToken?: $C.PageToken },
) => Promise<$C.ListActionTypesResponseV2>
> = [0, "/v2/ontologies/{0}/actionTypes"];
> = [0, "/v2/ontologies/{0}/actionTypes", 2];

/**
* Lists the action types for the given Ontology.
Expand Down
4 changes: 2 additions & 2 deletions packages/omniapi/src/public/OntologiesV2_ObjectTypeV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const _listObjectTypesV2: $OmniMethod<
ontology: $C.OntologyIdentifier,
$queryParams?: { pageSize?: $C.PageSize; pageToken?: $C.PageToken },
) => Promise<$C.ListObjectTypesV2Response>
> = [0, "/v2/ontologies/{0}/objectTypes"];
> = [0, "/v2/ontologies/{0}/objectTypes", 2];

/**
* Lists the object types for the given Ontology.
Expand Down Expand Up @@ -79,7 +79,7 @@ const _listOutgoingLinkTypesV2: $OmniMethod<
objectType: $C.ObjectTypeApiName,
$queryParams?: { pageSize?: $C.PageSize; pageToken?: $C.PageToken },
) => Promise<$C.ListOutgoingLinkTypesResponseV2>
> = [0, "/v2/ontologies/{0}/objectTypes/{1}/outgoingLinkTypes"];
> = [0, "/v2/ontologies/{0}/objectTypes/{1}/outgoingLinkTypes", 2];

/**
* List the outgoing links for an object type.
Expand Down
4 changes: 2 additions & 2 deletions packages/omniapi/src/public/OntologiesV2_OntologyObjectSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const _loadObjectSetV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.LoadObjectSetResponseV2>
> = [1, "/v2/ontologies/{0}/objectSets/loadObjects", 1];
> = [1, "/v2/ontologies/{0}/objectSets/loadObjects", 3];

/**
* Load the ontology objects present in the `ObjectSet` from the provided object set definition.
Expand Down Expand Up @@ -91,7 +91,7 @@ const _aggregateObjectSetV2: $OmniMethod<
preview?: $C.PreviewMode;
},
) => Promise<$C.AggregateObjectsResponseV2>
> = [1, "/v2/ontologies/{0}/objectSets/aggregate", 1];
> = [1, "/v2/ontologies/{0}/objectSets/aggregate", 3];

/**
* Aggregates the ontology objects present in the `ObjectSet` from the provided object set definition.
Expand Down
36 changes: 18 additions & 18 deletions packages/omniapi/src/public/OntologiesV2_OntologyObjectV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const _listObjectsV2: $OmniMethod<
excludeRid?: boolean;
},
) => Promise<$C.ListObjectsResponseV2>
> = [0, "/v2/ontologies/{0}/objects/{1}"];
> = [0, "/v2/ontologies/{0}/objects/{1}", 2];

/**
* Lists the objects for the given Ontology and object type.
Expand Down Expand Up @@ -89,7 +89,7 @@ const _getObjectV2: $OmniMethod<
excludeRid?: boolean;
},
) => Promise<$C.OntologyObjectV2>
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}"];
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}", 2];

/**
* Gets a specific object with the given primary key.
Expand Down Expand Up @@ -126,7 +126,7 @@ const _countObjects: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.CountObjectsResponseV2>
> = [1, "/v2/ontologies/{0}/objects/{1}/count"];
> = [1, "/v2/ontologies/{0}/objects/{1}/count", 2];

/**
* Returns a count of the objects of the given object type.
Expand Down Expand Up @@ -161,7 +161,7 @@ const _searchObjectsV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.SearchObjectsResponseV2>
> = [1, "/v2/ontologies/{0}/objects/{1}/search", 1];
> = [1, "/v2/ontologies/{0}/objects/{1}/search", 3];

/**
* Search for objects in the specified ontology and object type. The request body is used
Expand Down Expand Up @@ -216,7 +216,7 @@ const _aggregateObjectsV2: $OmniMethod<
preview?: $C.PreviewMode;
},
) => Promise<$C.AggregateObjectsResponseV2>
> = [1, "/v2/ontologies/{0}/objects/{1}/aggregate", 1];
> = [1, "/v2/ontologies/{0}/objects/{1}/aggregate", 3];

/**
* Perform functions on object fields in the specified ontology and object type.
Expand Down Expand Up @@ -251,7 +251,7 @@ const _listInterfaceTypes: $OmniMethod<
preview?: $C.PreviewMode;
},
) => Promise<$C.ListInterfaceTypesResponse>
> = [0, "/v2/ontologies/{0}/interfaceTypes"];
> = [0, "/v2/ontologies/{0}/interfaceTypes", 2];

/**
* :::callout{theme=warning title=Warning}
Expand Down Expand Up @@ -290,7 +290,7 @@ const _getInterfaceType: $OmniMethod<
interfaceType: $C.InterfaceTypeApiName,
$queryParams?: { preview?: $C.PreviewMode },
) => Promise<$C.InterfaceType>
> = [0, "/v2/ontologies/{0}/interfaceTypes/{1}"];
> = [0, "/v2/ontologies/{0}/interfaceTypes/{1}", 2];

/**
* :::callout{theme=warning title=Warning}
Expand Down Expand Up @@ -324,7 +324,7 @@ const _searchObjectsForInterface: $OmniMethod<
$body: $C.SearchObjectsForInterfaceRequest,
$queryParams?: { preview?: $C.PreviewMode },
) => Promise<$C.SearchObjectsResponseV2>
> = [1, "/v2/ontologies/{0}/interfaces/{1}/search", 1];
> = [1, "/v2/ontologies/{0}/interfaces/{1}/search", 3];

/**
* :::callout{theme=warning title=Warning}
Expand Down Expand Up @@ -379,7 +379,7 @@ const _aggregateObjectsForInterface: $OmniMethod<
$body: $C.AggregateObjectsRequestV2,
$queryParams?: { preview?: $C.PreviewMode },
) => Promise<$C.AggregateObjectsResponseV2>
> = [1, "/v2/ontologies/{0}/interfaces/{1}/aggregate", 1];
> = [1, "/v2/ontologies/{0}/interfaces/{1}/aggregate", 3];

/**
* :::callout{theme=warning title=Warning}
Expand Down Expand Up @@ -423,7 +423,7 @@ const _listLinkedObjectsV2: $OmniMethod<
excludeRid?: boolean;
},
) => Promise<$C.ListLinkedObjectsResponseV2>
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/links/{3}"];
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/links/{3}", 2];

/**
* Lists the linked objects for a specific object and the given link type.
Expand Down Expand Up @@ -481,7 +481,7 @@ const _getLinkedObjectV2: $OmniMethod<
excludeRid?: boolean;
},
) => Promise<$C.OntologyObjectV2>
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/links/{3}/{4}"];
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/links/{3}/{4}", 2];

/**
* Get a specific linked object that originates from another object.
Expand Down Expand Up @@ -524,7 +524,7 @@ const _getAttachmentsV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.AttachmentMetadataResponse>
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}"];
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}", 2];

/**
* Get the metadata of attachments parented to the given object.
Expand Down Expand Up @@ -564,7 +564,7 @@ const _getAttachmentByRidV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.AttachmentV2>
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/{4}"];
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/{4}", 2];

/**
* Get the metadata of a particular attachment in an attachment list.
Expand Down Expand Up @@ -607,7 +607,7 @@ const _getAttachmentContentV2: $OmniMethod<
> = [
0,
"/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/content",
,
2,
,
"*/*",
];
Expand Down Expand Up @@ -653,7 +653,7 @@ const _getAttachmentContentByRidV2: $OmniMethod<
> = [
0,
"/v2/ontologies/{0}/objects/{1}/{2}/attachments/{3}/{4}/content",
,
2,
,
"*/*",
];
Expand Down Expand Up @@ -698,7 +698,7 @@ const _getFirstPoint: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.TimeSeriesPoint | undefined>
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/firstPoint"];
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/firstPoint", 2];

/**
* Get the first point of a time series property.
Expand Down Expand Up @@ -737,7 +737,7 @@ const _getLastPoint: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.TimeSeriesPoint | undefined>
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/lastPoint"];
> = [0, "/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/lastPoint", 2];

/**
* Get the last point of a time series property.
Expand Down Expand Up @@ -780,7 +780,7 @@ const _streamPoints: $OmniMethod<
> = [
1,
"/v2/ontologies/{0}/objects/{1}/{2}/timeseries/{3}/streamPoints",
1,
3,
,
"*/*",
];
Expand Down
4 changes: 2 additions & 2 deletions packages/omniapi/src/public/OntologiesV2_QueryType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const _listQueryTypesV2: $OmniMethod<
ontology: $C.OntologyIdentifier,
$queryParams?: { pageSize?: $C.PageSize; pageToken?: $C.PageToken },
) => Promise<$C.ListQueryTypesResponseV2>
> = [0, "/v2/ontologies/{0}/queryTypes"];
> = [0, "/v2/ontologies/{0}/queryTypes", 2];

/**
* Lists the query types for the given Ontology.
Expand Down Expand Up @@ -82,7 +82,7 @@ const _executeQueryV2: $OmniMethod<
packageName?: $C.SdkPackageName;
},
) => Promise<$C.ExecuteQueryResponse>
> = [1, "/v2/ontologies/{0}/queries/{1}/execute", 1];
> = [1, "/v2/ontologies/{0}/queries/{1}/execute", 3];

/**
* Executes a Query using the given parameters.
Expand Down

0 comments on commit 8f673ab

Please sign in to comment.