Skip to content

Commit 411edef

Browse files
committed
chore: templates
1 parent ddb77b5 commit 411edef

File tree

1 file changed

+8
-37
lines changed

1 file changed

+8
-37
lines changed

templates/javascript/clients/algoliasearch/builds/definition.mustache

+8-37
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type Algoliasearch = SearchClient & {
3232
// Bridge helpers to expose along with the search endpoints at the root of the API client
3333

3434
/**
35-
* Helper: Similar to the `saveObjects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `taskID` and `region` must've been passed to the client instantiation method.
35+
* Helper: Similar to the `saveObjects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `region` must've been passed to the client instantiation method.
3636
*
3737
* @summary Save objects to an Algolia index by leveraging the Transformation pipeline setup in the Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/).
3838
* @param saveObjects - The `saveObjects` object.
@@ -42,13 +42,10 @@ export type Algoliasearch = SearchClient & {
4242
* @param saveObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
4343
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
4444
*/
45-
saveObjectsWithTransformation: (
46-
{ indexName, objects, waitForTasks, batchSize }: SaveObjectsOptions,
47-
requestOptions?: RequestOptions,
48-
) => Promise<WatchResponse>;
45+
saveObjectsWithTransformation: (options: SaveObjectsOptions & TransformationOptions, requestOptions?: RequestOptions) => Promise<WatchResponse>;
4946

5047
/**
51-
* Helper: Similar to the `partialUpdateObjects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `taskID` and `region` must've been passed to the client instantiation method.
48+
* Helper: Similar to the `partialUpdateObjects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `region` must've been passed to the client instantiation method.
5249
*
5350
* @summary Save objects to an Algolia index by leveraging the Transformation pipeline setup in the Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/).
5451
* @param partialUpdateObjects - The `partialUpdateObjects` object.
@@ -59,18 +56,12 @@ export type Algoliasearch = SearchClient & {
5956
* @param partialUpdateObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
6057
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
6158
*/
62-
partialUpdateObjectsWithTransformation: (
63-
{ indexName, objects, createIfNotExists, waitForTasks, batchSize }: PartialUpdateObjectsOptions,
64-
requestOptions?: RequestOptions,
65-
) => Promise<WatchResponse>;
59+
partialUpdateObjectsWithTransformation: (options: PartialUpdateObjectsOptions & TransformationOptions, requestOptions?: RequestOptions) => Promise<WatchResponse>;
6660
};
6761

6862
export type TransformationOptions = {
6963
// When provided, a second transporter will be created in order to leverage the `*WithTransformation` methods exposed by the Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/).
7064
transformation?: {
71-
// The taskID returned by the Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) setup.
72-
taskID: string;
73-
7465
// The region of your Algolia application ID, used to target the correct hosts of the transformation service.
7566
region: IngestionRegion;
7667
};
@@ -94,40 +85,27 @@ export function algoliasearch(
9485
let ingestionTransporter: IngestionClient | undefined;
9586

9687
if (options?.transformation) {
97-
if (!options.transformation.taskID) {
98-
throw new Error('`taskID` must be provided when leveraging the transformation pipeline');
99-
}
100-
10188
if (!options.transformation.region) {
10289
throw new Error('`region` must be provided when leveraging the transformation pipeline');
10390
}
10491

10592
ingestionTransporter = ingestionClient(appId, apiKey, options.transformation.region, options);
106-
107-
ingestionTransporter.addAlgoliaAgent("Ingestion via Algoliasearch");
10893
}
10994

11095
return {
11196
...client,
11297
11398
async saveObjectsWithTransformation({ objects, waitForTasks }, requestOptions): Promise<WatchResponse> {
11499
if (!ingestionTransporter) {
115-
throw new Error(
116-
'`transformation.taskID` and `transformation.region` must be provided at client instantiation before calling this method.',
117-
);
118-
}
119-
120-
if (!options?.transformation?.taskID) {
121-
throw new Error('`taskID` must be provided when leveraging the transformation pipeline');
100+
throw new Error('`transformation.region` must be provided at client instantiation before calling this method.');
122101
}
123102

124103
if (!options?.transformation?.region) {
125104
throw new Error('`region` must be provided when leveraging the transformation pipeline');
126105
}
127106

128-
return ingestionTransporter?.pushTask(
107+
return ingestionTransporter?.push(
129108
{
130-
taskID: options?.transformation?.taskID,
131109
watch: waitForTasks,
132110
pushTaskPayload: {
133111
action: 'addObject',
@@ -143,22 +121,15 @@ export function algoliasearch(
143121
requestOptions,
144122
): Promise<WatchResponse> {
145123
if (!ingestionTransporter) {
146-
throw new Error(
147-
'`transformation.taskID` and `transformation.region` must be provided at client instantiation before calling this method.',
148-
);
149-
}
150-
151-
if (!options?.transformation?.taskID) {
152-
throw new Error('`taskID` must be provided when leveraging the transformation pipeline');
124+
throw new Error('`transformation.region` must be provided at client instantiation before calling this method.');
153125
}
154126

155127
if (!options?.transformation?.region) {
156128
throw new Error('`region` must be provided when leveraging the transformation pipeline');
157129
}
158130

159-
return ingestionTransporter?.pushTask(
131+
return ingestionTransporter?.push(
160132
{
161-
taskID: options?.transformation?.taskID,
162133
watch: waitForTasks,
163134
pushTaskPayload: {
164135
action: createIfNotExists ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate',

0 commit comments

Comments
 (0)