@algolia/ingestion 1.25.0 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  // src/ingestionClient.ts
2
2
  import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
3
- var apiClientVersion = "1.25.0";
3
+ var apiClientVersion = "1.26.0";
4
4
  var REGIONS = ["eu", "us"];
5
5
  function getDefaultHosts(region) {
6
6
  const url = "data.{region}.algolia.com".replace("{region}", region);
@@ -262,12 +262,15 @@ function createIngestionClient({
262
262
  if (!transformationCreate) {
263
263
  throw new Error("Parameter `transformationCreate` is required when calling `createTransformation`.");
264
264
  }
265
- if (!transformationCreate.code) {
266
- throw new Error("Parameter `transformationCreate.code` is required when calling `createTransformation`.");
267
- }
268
265
  if (!transformationCreate.name) {
269
266
  throw new Error("Parameter `transformationCreate.name` is required when calling `createTransformation`.");
270
267
  }
268
+ if (!transformationCreate.type) {
269
+ throw new Error("Parameter `transformationCreate.type` is required when calling `createTransformation`.");
270
+ }
271
+ if (!transformationCreate.input) {
272
+ throw new Error("Parameter `transformationCreate.input` is required when calling `createTransformation`.");
273
+ }
271
274
  const requestPath = "/1/transformations";
272
275
  const headers = {};
273
276
  const queryParameters = {};
@@ -1290,7 +1293,56 @@ function createIngestionClient({
1290
1293
  return transporter.request(request, requestOptions);
1291
1294
  },
1292
1295
  /**
1293
- * Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the observability endpoints.
1296
+ * Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records. This method is similar to `pushTask`, but requires an `indexName` instead of a `taskID`. If zero or many tasks are found, an error will be returned.
1297
+ *
1298
+ * Required API Key ACLs:
1299
+ * - addObject
1300
+ * - deleteIndex
1301
+ * - editSettings
1302
+ * @param push - The push object.
1303
+ * @param push.indexName - Name of the index on which to perform the operation.
1304
+ * @param push.pushTaskPayload - The pushTaskPayload object.
1305
+ * @param push.watch - When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
1306
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1307
+ */
1308
+ push({ indexName, pushTaskPayload, watch }, requestOptions) {
1309
+ if (!indexName) {
1310
+ throw new Error("Parameter `indexName` is required when calling `push`.");
1311
+ }
1312
+ if (!pushTaskPayload) {
1313
+ throw new Error("Parameter `pushTaskPayload` is required when calling `push`.");
1314
+ }
1315
+ if (!pushTaskPayload.action) {
1316
+ throw new Error("Parameter `pushTaskPayload.action` is required when calling `push`.");
1317
+ }
1318
+ if (!pushTaskPayload.records) {
1319
+ throw new Error("Parameter `pushTaskPayload.records` is required when calling `push`.");
1320
+ }
1321
+ const requestPath = "/1/push/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1322
+ const headers = {};
1323
+ const queryParameters = {};
1324
+ if (watch !== void 0) {
1325
+ queryParameters["watch"] = watch.toString();
1326
+ }
1327
+ const request = {
1328
+ method: "POST",
1329
+ path: requestPath,
1330
+ queryParameters,
1331
+ headers,
1332
+ data: pushTaskPayload
1333
+ };
1334
+ requestOptions = {
1335
+ timeouts: {
1336
+ connect: 18e4,
1337
+ read: 18e4,
1338
+ write: 18e4,
1339
+ ...requestOptions?.timeouts
1340
+ }
1341
+ };
1342
+ return transporter.request(request, requestOptions);
1343
+ },
1344
+ /**
1345
+ * Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records. This method is similar to `push`, but requires a `taskID` instead of a `indexName`, which is useful when many `destinations` target the same `indexName`.
1294
1346
  *
1295
1347
  * Required API Key ACLs:
1296
1348
  * - addObject
@@ -1298,7 +1350,7 @@ function createIngestionClient({
1298
1350
  * - editSettings
1299
1351
  * @param pushTask - The pushTask object.
1300
1352
  * @param pushTask.taskID - Unique identifier of a task.
1301
- * @param pushTask.pushTaskPayload - Request body of a Search API `batch` request that will be pushed in the Connectors pipeline.
1353
+ * @param pushTask.pushTaskPayload - The pushTaskPayload object.
1302
1354
  * @param pushTask.watch - When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
1303
1355
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1304
1356
  */
@@ -1333,7 +1385,7 @@ function createIngestionClient({
1333
1385
  connect: 18e4,
1334
1386
  read: 18e4,
1335
1387
  write: 18e4,
1336
- ...requestOptions == null ? void 0 : requestOptions.timeouts
1388
+ ...requestOptions?.timeouts
1337
1389
  }
1338
1390
  };
1339
1391
  return transporter.request(request, requestOptions);
@@ -1629,7 +1681,7 @@ function createIngestionClient({
1629
1681
  connect: 18e4,
1630
1682
  read: 18e4,
1631
1683
  write: 18e4,
1632
- ...requestOptions == null ? void 0 : requestOptions.timeouts
1684
+ ...requestOptions?.timeouts
1633
1685
  }
1634
1686
  };
1635
1687
  return transporter.request(request, requestOptions);
@@ -1875,12 +1927,15 @@ function createIngestionClient({
1875
1927
  if (!transformationCreate) {
1876
1928
  throw new Error("Parameter `transformationCreate` is required when calling `updateTransformation`.");
1877
1929
  }
1878
- if (!transformationCreate.code) {
1879
- throw new Error("Parameter `transformationCreate.code` is required when calling `updateTransformation`.");
1880
- }
1881
1930
  if (!transformationCreate.name) {
1882
1931
  throw new Error("Parameter `transformationCreate.name` is required when calling `updateTransformation`.");
1883
1932
  }
1933
+ if (!transformationCreate.type) {
1934
+ throw new Error("Parameter `transformationCreate.type` is required when calling `updateTransformation`.");
1935
+ }
1936
+ if (!transformationCreate.input) {
1937
+ throw new Error("Parameter `transformationCreate.input` is required when calling `updateTransformation`.");
1938
+ }
1884
1939
  const requestPath = "/1/transformations/{transformationID}".replace(
1885
1940
  "{transformationID}",
1886
1941
  encodeURIComponent(transformationID)
@@ -1922,7 +1977,7 @@ function createIngestionClient({
1922
1977
  connect: 18e4,
1923
1978
  read: 18e4,
1924
1979
  write: 18e4,
1925
- ...requestOptions == null ? void 0 : requestOptions.timeouts
1980
+ ...requestOptions?.timeouts
1926
1981
  }
1927
1982
  };
1928
1983
  return transporter.request(request, requestOptions);
@@ -1961,7 +2016,7 @@ function createIngestionClient({
1961
2016
  connect: 18e4,
1962
2017
  read: 18e4,
1963
2018
  write: 18e4,
1964
- ...requestOptions == null ? void 0 : requestOptions.timeouts
2019
+ ...requestOptions?.timeouts
1965
2020
  }
1966
2021
  };
1967
2022
  return transporter.request(request, requestOptions);