Skip to content

Commit

Permalink
regen code to fix variables type, add accountId param (#56)
Browse files Browse the repository at this point in the history
- pin generator at v6.0.1
- update package version to 5.0.0
- regen code
- update wrappers
  • Loading branch information
jkaho authored Jul 20, 2022
1 parent 16650ab commit 14cd244
Show file tree
Hide file tree
Showing 108 changed files with 674 additions and 258 deletions.
2 changes: 1 addition & 1 deletion generate/Dockerfile.generate
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM openapitools/openapi-generator-cli@sha256:bc3f07ee4032923c7158b1a4a59aadd1861c6b4227c58d8ded5ee2b6c075bf72
FROM openapitools/openapi-generator-cli@sha256:c49d9c99124fe2ad94ccef54cc6d3362592e7ca29006a8cf01337ab10d1c01f4
2 changes: 1 addition & 1 deletion generate/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ -z "$TEMPLATES_PATH" ]; then
die "TEMPLATES_PATH must be set, e.g. /path/to/sajari/sdk-node/generate/templates"
fi

VERSION=4.6.2
VERSION=5.0.0

docker-entrypoint.sh generate \
-i /openapi.json \
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sajari/sdk-node",
"version": "4.6.2",
"version": "5.0.0",
"repository": "[email protected]:github.com/sajari/sdk-node.git",
"author": "Search.io",
"license": "MIT",
Expand Down
9 changes: 6 additions & 3 deletions src/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ export class CollectionsClient extends Client {
}

async listCollections({
accountId,
pageSize,
pageToken,
}: {
accountId?: string;
pageSize?: number;
pageToken?: string;
}) {
try {
const res = await this.client.listCollections(pageSize, pageToken);
const res = await this.client.listCollections(accountId, pageSize, pageToken);
return res.body;
} catch (e) {
throw handleError(e);
Expand All @@ -72,7 +74,8 @@ export class CollectionsClient extends Client {
}

async updateCollection(
id: string,
collectionId: string,
accountId?: string,
...options: Array<
(c: Collection, updateMask: Record<string, boolean>) => void
>
Expand All @@ -89,7 +92,7 @@ export class CollectionsClient extends Client {
const um = Object.keys(updateMask).map((field) => field);

try {
const res = await this.client.updateCollection(id, um.join(","), c);
const res = await this.client.updateCollection(collectionId, c, accountId, um.join(","));
// OpenAPI readonly fields become optional TS fields, but we know the API
// will return it, so use ! to fix the types. This is done so upstream
// users don't have to do this.
Expand Down
2 changes: 1 addition & 1 deletion src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class EventsClient extends Client {

async sendEvent(accountId: string, args: SendEventRequest) {
try {
const res = await this.client.sendEvent(args, {
const res = await this.client.sendEvent(accountId, args, {
headers: {
"Account-Id": accountId,
},
Expand Down
5 changes: 5 additions & 0 deletions src/generated/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ model/batchUpdateRecordsResponseError.ts
model/batchUpdateRecordsResponseRecord.ts
model/batchUpsertRecordsRequest.ts
model/batchUpsertRecordsRequestPipeline.ts
model/batchUpsertRecordsRequestVariablesValue.ts
model/batchUpsertRecordsResponse.ts
model/batchUpsertRecordsResponseError.ts
model/batchUpsertRecordsResponseKey.ts
model/batchUpsertRecordsResponseVariables.ts
model/collection.ts
model/collectionType.ts
model/createSchemaFieldRequest.ts
model/deleteRecordRequest.ts
model/event.ts
model/experimentRequest.ts
model/experimentRequestPipeline.ts
model/experimentResponse.ts
model/generatePipelinesRequest.ts
model/generatePipelinesResponse.ts
model/getCollectionRequestView.ts
model/getDefaultPipelineResponse.ts
model/getDefaultVersionRequestView.ts
model/getPipelineRequestView.ts
model/getRecordRequest.ts
model/listCollectionsRequestView.ts
model/listCollectionsResponse.ts
model/listPipelinesRequestView.ts
model/listPipelinesResponse.ts
Expand Down
2 changes: 1 addition & 1 deletion src/generated/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
6.1.0-SNAPSHOT
71 changes: 59 additions & 12 deletions src/generated/api/collectionsApi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Search.io API
* Search.io offers a search and discovery service with Neuralsearch®, the world\'s first instant AI search technology. Businesses of all sizes use Search.io to build site search and discovery solutions that maximize e-commerce revenue, optimize on-site customer experience, and scale their online presence.
* Search.io offers a search and discovery service with Neuralsearch®, the world\'s first instant AI search technology. Businesses of all sizes use Search.io to build site search and discovery solutions that maximize e-commerce revenue, optimize on-site customer experience, and scale their online presence. # Authentication <!-- ReDoc-Inject: <SecurityDefinitions> --> # Rate limiting The Search.io API employs a number of safeguards against bursts of incoming traffic to help maximize its stability. Users who send many requests in quick succession may see error responses that show up as HTTP status code `429`. For the [UpsertRecord](/docs/api#operation/UpsertRecord) call, Search.io allows up to 175 write operations per second. Treat these limits as maximums and don\'t generate unnecessary load. See [Handling limiting gracefully](/docs/api/#section/Rate-limiting/Handling-limiting-gracefully) for advice on handling `429`s. We may reduce limits to prevent abuse. ## Common causes and mitigations Rate limiting can occur under a variety of conditions, but it\'s most common in these scenarios: - Running a large volume of closely-spaced requests. Often this is part of a user\'s long-running reindex job. When engaging in these activities, you should try to control the request rate (see [Handling limiting gracefully](/docs/api/#section/Rate-limiting/Handling-limiting-gracefully)). - Running batch operations in parallel. Often [BatchUpsertRecords](/docs/api#operation/BatchUpsertRecords) is used as part of a user\'s long-running reindex job. A batch of records of size `N` passed to [BatchUpsertRecords](/docs/api#operation/BatchUpsertRecords) is counted as `N` [UpsertRecord](/docs/api#operation/UpsertRecord) calls for the purposes of rate limiting, as opposed to a single call. Treat batch API calls as a convenience rather than a way to get more write throughput. ## Handling limiting gracefully A basic technique for integrations to gracefully handle limiting is to watch for `429` HTTP status codes and build in a retry mechanism. The retry mechanism should follow an exponential backoff schedule to reduce request volume when necessary. We also recommend building some randomness into the backoff schedule to avoid a [thundering herd effect](https://en.wikipedia.org/wiki/Thundering_herd_problem).
*
* The version of the OpenAPI document: v4
* The version of the OpenAPI document: 4.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -122,10 +122,12 @@ export class CollectionsApi {
* @summary Create collection
* @param collectionId The ID to use for the collection. This must start with an alphanumeric character followed by one or more alphanumeric or &#x60;-&#x60; characters. Strictly speaking, it must match the regular expression: &#x60;^[A-Za-z][A-Za-z0-9\\-]*$&#x60;.
* @param collection Details of the collection to create.
* @param accountId The account that owns the collection, e.g. &#x60;1618535966441231024&#x60;.
*/
public async createCollection(
collectionId: string,
collection: Collection,
accountId?: string,
options: { headers: { [name: string]: string } } = { headers: {} }
): Promise<{ response: http.IncomingMessage; body: Collection }> {
const localVarPath = this.basePath + "/v4/collections";
Expand Down Expand Up @@ -164,6 +166,10 @@ export class CollectionsApi {
);
}

localVarHeaderParams["Account-Id"] = ObjectSerializer.serialize(
accountId,
"string"
);
(<any>Object).assign(localVarHeaderParams, options.headers);

let localVarUseFormData = false;
Expand Down Expand Up @@ -232,9 +238,11 @@ export class CollectionsApi {
* Delete a collection and all of its associated data. > Note: This operation cannot be reversed.
* @summary Delete collection
* @param collectionId The collection to delete, e.g. &#x60;my-collection&#x60;.
* @param accountId The account that owns the collection, e.g. &#x60;1618535966441231024&#x60;.
*/
public async deleteCollection(
collectionId: string,
accountId?: string,
options: { headers: { [name: string]: string } } = { headers: {} }
): Promise<{ response: http.IncomingMessage; body: any }> {
const localVarPath =
Expand Down Expand Up @@ -264,6 +272,10 @@ export class CollectionsApi {
);
}

localVarHeaderParams["Account-Id"] = ObjectSerializer.serialize(
accountId,
"string"
);
(<any>Object).assign(localVarHeaderParams, options.headers);

let localVarUseFormData = false;
Expand Down Expand Up @@ -441,9 +453,13 @@ export class CollectionsApi {
* Retrieve the details of a collection.
* @summary Get collection
* @param collectionId The collection to retrieve, e.g. &#x60;my-collection&#x60;.
* @param accountId The account that owns the collection, e.g. &#x60;1618535966441231024&#x60;.
* @param view The amount of information to include in the retrieved pipeline. - BASIC: Include basic information including display name and domains. This is the default value (for both [ListCollections](/docs/api#operation/ListCollections) and [GetCollection](/docs/api#operation/GetCollection)). - FULL: Include the information from &#x60;BASIC&#x60;, plus full collection details like disk usage.
*/
public async getCollection(
collectionId: string,
accountId?: string,
view?: "VIEW_UNSPECIFIED" | "BASIC" | "FULL",
options: { headers: { [name: string]: string } } = { headers: {} }
): Promise<{ response: http.IncomingMessage; body: Collection }> {
const localVarPath =
Expand Down Expand Up @@ -473,6 +489,17 @@ export class CollectionsApi {
);
}

if (view !== undefined) {
localVarQueryParameters["view"] = ObjectSerializer.serialize(
view,
"'VIEW_UNSPECIFIED' | 'BASIC' | 'FULL'"
);
}

localVarHeaderParams["Account-Id"] = ObjectSerializer.serialize(
accountId,
"string"
);
(<any>Object).assign(localVarHeaderParams, options.headers);

let localVarUseFormData = false;
Expand Down Expand Up @@ -539,12 +566,16 @@ export class CollectionsApi {
/**
* Retrieve a list of collections in an account.
* @summary List collections
* @param accountId The account that owns this set of collections, e.g. &#x60;1618535966441231024&#x60;.
* @param pageSize The maximum number of collections to return. The service may return fewer than this value. If unspecified, at most 50 collections are returned. The maximum value is 100; values above 100 are coerced to 100.
* @param pageToken A page token, received from a previous [ListCollections](/docs/api#operation/ListCollections) call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to [ListCollections](/docs/api#operation/ListCollections) must match the call that provided the page token.
* @param view The amount of information to include in each retrieved collection. - BASIC: Include basic information including display name and domains. This is the default value (for both [ListCollections](/docs/api#operation/ListCollections) and [GetCollection](/docs/api#operation/GetCollection)). - FULL: Include the information from &#x60;BASIC&#x60;, plus full collection details like disk usage.
*/
public async listCollections(
accountId?: string,
pageSize?: number,
pageToken?: string,
view?: "VIEW_UNSPECIFIED" | "BASIC" | "FULL",
options: { headers: { [name: string]: string } } = { headers: {} }
): Promise<{
response: http.IncomingMessage;
Expand Down Expand Up @@ -579,6 +610,17 @@ export class CollectionsApi {
);
}

if (view !== undefined) {
localVarQueryParameters["view"] = ObjectSerializer.serialize(
view,
"'VIEW_UNSPECIFIED' | 'BASIC' | 'FULL'"
);
}

localVarHeaderParams["Account-Id"] = ObjectSerializer.serialize(
accountId,
"string"
);
(<any>Object).assign(localVarHeaderParams, options.headers);

let localVarUseFormData = false;
Expand Down Expand Up @@ -651,10 +693,12 @@ export class CollectionsApi {
* @summary Query collection
* @param collectionId The collection to query, e.g. &#x60;my-collection&#x60;.
* @param queryCollectionRequest
* @param accountId The account that owns the collection, e.g. &#x60;1618535966441231024&#x60;. Unlike other API calls, the &#x60;QueryCollection&#x60; call can be called from a browser. When called from a browser, the &#x60;Account-Id&#x60; header must be set to your account ID.
*/
public async queryCollection(
collectionId: string,
queryCollectionRequest: QueryCollectionRequest,
accountId?: string,
options: { headers: { [name: string]: string } } = { headers: {} }
): Promise<{
response: http.IncomingMessage;
Expand Down Expand Up @@ -697,6 +741,10 @@ export class CollectionsApi {
);
}

localVarHeaderParams["Account-Id"] = ObjectSerializer.serialize(
accountId,
"string"
);
(<any>Object).assign(localVarHeaderParams, options.headers);

let localVarUseFormData = false;
Expand Down Expand Up @@ -891,7 +939,7 @@ export class CollectionsApi {
});
}
/**
* Track an analytics event when a user interacts with an object returned by a [QueryCollection](/docs/api/#operation/QueryCollection) request. An analytics event can be tracked for the following objects: - Results - Promotion banners - Redirects Note: You must pass an `Account-Id` header.
* Track an analytics event when a user interacts with an object returned by a [QueryCollection](/docs/api/#operation/QueryCollection) request. An analytics event can be tracked for the following objects: - Results - Promotion banners - Redirects When tracking redirect events, set `type` to `redirect`. - **Note:** You must pass an `Account-Id` header. - **Note:** One of `result_id`, `banner_id` or `redirect_id` are required.
* @summary Track event
* @param accountId The account that owns the collection, e.g. &#x60;1618535966441231024&#x60;.
* @param collectionId The collection to track the event against, e.g. &#x60;my-collection&#x60;.
Expand Down Expand Up @@ -1016,13 +1064,15 @@ export class CollectionsApi {
* Update the details of a collection.
* @summary Update collection
* @param collectionId The collection to update, e.g. &#x60;my-collection&#x60;.
* @param updateMask The list of fields to be updated, separated by a comma, e.g. &#x60;field1,field2&#x60;. Each field should be in snake case, e.g. &#x60;display_name&#x60;. For each field that you want to update, provide a corresponding value in the collection object containing the new value.
* @param collection The details of the collection to update.
* @param accountId The account that owns the collection, e.g. &#x60;1618535966441231024&#x60;.
* @param updateMask The list of fields to update, separated by a comma, e.g. &#x60;authorized_query_domains,display_name&#x60;. Each field should be in snake case. For each field that you want to update, provide a corresponding value in the collection object containing the new value.
*/
public async updateCollection(
collectionId: string,
updateMask: string,
collection: Collection,
accountId?: string,
updateMask?: string,
options: { headers: { [name: string]: string } } = { headers: {} }
): Promise<{ response: http.IncomingMessage; body: Collection }> {
const localVarPath =
Expand Down Expand Up @@ -1052,13 +1102,6 @@ export class CollectionsApi {
);
}

// verify required parameter 'updateMask' is not null or undefined
if (updateMask === null || updateMask === undefined) {
throw new Error(
"Required parameter updateMask was null or undefined when calling updateCollection."
);
}

// verify required parameter 'collection' is not null or undefined
if (collection === null || collection === undefined) {
throw new Error(
Expand All @@ -1073,6 +1116,10 @@ export class CollectionsApi {
);
}

localVarHeaderParams["Account-Id"] = ObjectSerializer.serialize(
accountId,
"string"
);
(<any>Object).assign(localVarHeaderParams, options.headers);

let localVarUseFormData = false;
Expand Down
Loading

0 comments on commit 14cd244

Please sign in to comment.