@algolia/ingestion 1.52.1 → 1.54.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,12 @@
1
1
  // src/ingestionClient.ts
2
- import { createAuth, createIterablePromise, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
3
- var apiClientVersion = "1.52.1";
2
+ import {
3
+ createAuth,
4
+ createIterablePromise,
5
+ createTransporter,
6
+ getAlgoliaAgent,
7
+ validateRequired
8
+ } from "@algolia/client-common";
9
+ var apiClientVersion = "1.54.0";
4
10
  var REGIONS = ["eu", "us"];
5
11
  function getDefaultHosts(region) {
6
12
  const url = "data.{region}.algolia.com".replace("{region}", region);
@@ -97,6 +103,7 @@ function createIngestionClient({
97
103
  * @param chunkedPush.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.
98
104
  * @param chunkedPush.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
99
105
  * @param chunkedPush.referenceIndexName - This is required when targeting an index that does not have a push connector setup (e.g. a tmp index), but you wish to attach another index's transformation to it (e.g. the source index name).
106
+ * @param chunkedPush.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
100
107
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getEvent` method and merged with the transporter requestOptions.
101
108
  */
102
109
  async chunkedPush({
@@ -105,7 +112,8 @@ function createIngestionClient({
105
112
  action = "addObject",
106
113
  waitForTasks,
107
114
  batchSize = 1e3,
108
- referenceIndexName
115
+ referenceIndexName,
116
+ maxRetries = 100
109
117
  }, requestOptions) {
110
118
  let records = [];
111
119
  let offset = 0;
@@ -141,8 +149,8 @@ function createIngestionClient({
141
149
  validate: (response) => response !== void 0,
142
150
  aggregator: () => retryCount += 1,
143
151
  error: {
144
- validate: () => retryCount >= 50,
145
- message: () => `The maximum number of retries exceeded. (${retryCount}/${50})`
152
+ validate: () => retryCount >= maxRetries,
153
+ message: () => `Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`
146
154
  },
147
155
  timeout: () => Math.min(retryCount * 1500, 5e3)
148
156
  });
@@ -163,18 +171,10 @@ function createIngestionClient({
163
171
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
164
172
  */
165
173
  createAuthentication(authenticationCreate, requestOptions) {
166
- if (!authenticationCreate) {
167
- throw new Error("Parameter `authenticationCreate` is required when calling `createAuthentication`.");
168
- }
169
- if (!authenticationCreate.type) {
170
- throw new Error("Parameter `authenticationCreate.type` is required when calling `createAuthentication`.");
171
- }
172
- if (!authenticationCreate.name) {
173
- throw new Error("Parameter `authenticationCreate.name` is required when calling `createAuthentication`.");
174
- }
175
- if (!authenticationCreate.input) {
176
- throw new Error("Parameter `authenticationCreate.input` is required when calling `createAuthentication`.");
177
- }
174
+ validateRequired("authenticationCreate", "createAuthentication", authenticationCreate);
175
+ validateRequired("authenticationCreate.type", "createAuthentication", authenticationCreate.type);
176
+ validateRequired("authenticationCreate.name", "createAuthentication", authenticationCreate.name);
177
+ validateRequired("authenticationCreate.input", "createAuthentication", authenticationCreate.input);
178
178
  const requestPath = "/1/authentications";
179
179
  const headers = {};
180
180
  const queryParameters = {};
@@ -198,18 +198,10 @@ function createIngestionClient({
198
198
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
199
199
  */
200
200
  createDestination(destinationCreate, requestOptions) {
201
- if (!destinationCreate) {
202
- throw new Error("Parameter `destinationCreate` is required when calling `createDestination`.");
203
- }
204
- if (!destinationCreate.type) {
205
- throw new Error("Parameter `destinationCreate.type` is required when calling `createDestination`.");
206
- }
207
- if (!destinationCreate.name) {
208
- throw new Error("Parameter `destinationCreate.name` is required when calling `createDestination`.");
209
- }
210
- if (!destinationCreate.input) {
211
- throw new Error("Parameter `destinationCreate.input` is required when calling `createDestination`.");
212
- }
201
+ validateRequired("destinationCreate", "createDestination", destinationCreate);
202
+ validateRequired("destinationCreate.type", "createDestination", destinationCreate.type);
203
+ validateRequired("destinationCreate.name", "createDestination", destinationCreate.name);
204
+ validateRequired("destinationCreate.input", "createDestination", destinationCreate.input);
213
205
  const requestPath = "/1/destinations";
214
206
  const headers = {};
215
207
  const queryParameters = {};
@@ -233,15 +225,9 @@ function createIngestionClient({
233
225
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
234
226
  */
235
227
  createSource(sourceCreate, requestOptions) {
236
- if (!sourceCreate) {
237
- throw new Error("Parameter `sourceCreate` is required when calling `createSource`.");
238
- }
239
- if (!sourceCreate.type) {
240
- throw new Error("Parameter `sourceCreate.type` is required when calling `createSource`.");
241
- }
242
- if (!sourceCreate.name) {
243
- throw new Error("Parameter `sourceCreate.name` is required when calling `createSource`.");
244
- }
228
+ validateRequired("sourceCreate", "createSource", sourceCreate);
229
+ validateRequired("sourceCreate.type", "createSource", sourceCreate.type);
230
+ validateRequired("sourceCreate.name", "createSource", sourceCreate.name);
245
231
  const requestPath = "/1/sources";
246
232
  const headers = {};
247
233
  const queryParameters = {};
@@ -265,18 +251,10 @@ function createIngestionClient({
265
251
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
266
252
  */
267
253
  createTask(taskCreate, requestOptions) {
268
- if (!taskCreate) {
269
- throw new Error("Parameter `taskCreate` is required when calling `createTask`.");
270
- }
271
- if (!taskCreate.sourceID) {
272
- throw new Error("Parameter `taskCreate.sourceID` is required when calling `createTask`.");
273
- }
274
- if (!taskCreate.destinationID) {
275
- throw new Error("Parameter `taskCreate.destinationID` is required when calling `createTask`.");
276
- }
277
- if (!taskCreate.action) {
278
- throw new Error("Parameter `taskCreate.action` is required when calling `createTask`.");
279
- }
254
+ validateRequired("taskCreate", "createTask", taskCreate);
255
+ validateRequired("taskCreate.sourceID", "createTask", taskCreate.sourceID);
256
+ validateRequired("taskCreate.destinationID", "createTask", taskCreate.destinationID);
257
+ validateRequired("taskCreate.action", "createTask", taskCreate.action);
280
258
  const requestPath = "/2/tasks";
281
259
  const headers = {};
282
260
  const queryParameters = {};
@@ -302,21 +280,11 @@ function createIngestionClient({
302
280
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
303
281
  */
304
282
  createTaskV1(taskCreate, requestOptions) {
305
- if (!taskCreate) {
306
- throw new Error("Parameter `taskCreate` is required when calling `createTaskV1`.");
307
- }
308
- if (!taskCreate.sourceID) {
309
- throw new Error("Parameter `taskCreate.sourceID` is required when calling `createTaskV1`.");
310
- }
311
- if (!taskCreate.destinationID) {
312
- throw new Error("Parameter `taskCreate.destinationID` is required when calling `createTaskV1`.");
313
- }
314
- if (!taskCreate.trigger) {
315
- throw new Error("Parameter `taskCreate.trigger` is required when calling `createTaskV1`.");
316
- }
317
- if (!taskCreate.action) {
318
- throw new Error("Parameter `taskCreate.action` is required when calling `createTaskV1`.");
319
- }
283
+ validateRequired("taskCreate", "createTaskV1", taskCreate);
284
+ validateRequired("taskCreate.sourceID", "createTaskV1", taskCreate.sourceID);
285
+ validateRequired("taskCreate.destinationID", "createTaskV1", taskCreate.destinationID);
286
+ validateRequired("taskCreate.trigger", "createTaskV1", taskCreate.trigger);
287
+ validateRequired("taskCreate.action", "createTaskV1", taskCreate.action);
320
288
  const requestPath = "/1/tasks";
321
289
  const headers = {};
322
290
  const queryParameters = {};
@@ -340,12 +308,8 @@ function createIngestionClient({
340
308
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
341
309
  */
342
310
  createTransformation(transformationCreate, requestOptions) {
343
- if (!transformationCreate) {
344
- throw new Error("Parameter `transformationCreate` is required when calling `createTransformation`.");
345
- }
346
- if (!transformationCreate.name) {
347
- throw new Error("Parameter `transformationCreate.name` is required when calling `createTransformation`.");
348
- }
311
+ validateRequired("transformationCreate", "createTransformation", transformationCreate);
312
+ validateRequired("transformationCreate.name", "createTransformation", transformationCreate.name);
349
313
  const requestPath = "/1/transformations";
350
314
  const headers = {};
351
315
  const queryParameters = {};
@@ -366,9 +330,7 @@ function createIngestionClient({
366
330
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
367
331
  */
368
332
  customDelete({ path, parameters }, requestOptions) {
369
- if (!path) {
370
- throw new Error("Parameter `path` is required when calling `customDelete`.");
371
- }
333
+ validateRequired("path", "customDelete", path);
372
334
  const requestPath = "/{path}".replace("{path}", path);
373
335
  const headers = {};
374
336
  const queryParameters = parameters ? parameters : {};
@@ -388,9 +350,7 @@ function createIngestionClient({
388
350
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
389
351
  */
390
352
  customGet({ path, parameters }, requestOptions) {
391
- if (!path) {
392
- throw new Error("Parameter `path` is required when calling `customGet`.");
393
- }
353
+ validateRequired("path", "customGet", path);
394
354
  const requestPath = "/{path}".replace("{path}", path);
395
355
  const headers = {};
396
356
  const queryParameters = parameters ? parameters : {};
@@ -411,9 +371,7 @@ function createIngestionClient({
411
371
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
412
372
  */
413
373
  customPost({ path, parameters, body }, requestOptions) {
414
- if (!path) {
415
- throw new Error("Parameter `path` is required when calling `customPost`.");
416
- }
374
+ validateRequired("path", "customPost", path);
417
375
  const requestPath = "/{path}".replace("{path}", path);
418
376
  const headers = {};
419
377
  const queryParameters = parameters ? parameters : {};
@@ -435,9 +393,7 @@ function createIngestionClient({
435
393
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
436
394
  */
437
395
  customPut({ path, parameters, body }, requestOptions) {
438
- if (!path) {
439
- throw new Error("Parameter `path` is required when calling `customPut`.");
440
- }
396
+ validateRequired("path", "customPut", path);
441
397
  const requestPath = "/{path}".replace("{path}", path);
442
398
  const headers = {};
443
399
  const queryParameters = parameters ? parameters : {};
@@ -462,9 +418,7 @@ function createIngestionClient({
462
418
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
463
419
  */
464
420
  deleteAuthentication({ authenticationID }, requestOptions) {
465
- if (!authenticationID) {
466
- throw new Error("Parameter `authenticationID` is required when calling `deleteAuthentication`.");
467
- }
421
+ validateRequired("authenticationID", "deleteAuthentication", authenticationID);
468
422
  const requestPath = "/1/authentications/{authenticationID}".replace(
469
423
  "{authenticationID}",
470
424
  encodeURIComponent(authenticationID)
@@ -491,9 +445,7 @@ function createIngestionClient({
491
445
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
492
446
  */
493
447
  deleteDestination({ destinationID }, requestOptions) {
494
- if (!destinationID) {
495
- throw new Error("Parameter `destinationID` is required when calling `deleteDestination`.");
496
- }
448
+ validateRequired("destinationID", "deleteDestination", destinationID);
497
449
  const requestPath = "/1/destinations/{destinationID}".replace(
498
450
  "{destinationID}",
499
451
  encodeURIComponent(destinationID)
@@ -520,9 +472,7 @@ function createIngestionClient({
520
472
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
521
473
  */
522
474
  deleteSource({ sourceID }, requestOptions) {
523
- if (!sourceID) {
524
- throw new Error("Parameter `sourceID` is required when calling `deleteSource`.");
525
- }
475
+ validateRequired("sourceID", "deleteSource", sourceID);
526
476
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
527
477
  const headers = {};
528
478
  const queryParameters = {};
@@ -546,9 +496,7 @@ function createIngestionClient({
546
496
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
547
497
  */
548
498
  deleteTask({ taskID }, requestOptions) {
549
- if (!taskID) {
550
- throw new Error("Parameter `taskID` is required when calling `deleteTask`.");
551
- }
499
+ validateRequired("taskID", "deleteTask", taskID);
552
500
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
553
501
  const headers = {};
554
502
  const queryParameters = {};
@@ -574,9 +522,7 @@ function createIngestionClient({
574
522
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
575
523
  */
576
524
  deleteTaskV1({ taskID }, requestOptions) {
577
- if (!taskID) {
578
- throw new Error("Parameter `taskID` is required when calling `deleteTaskV1`.");
579
- }
525
+ validateRequired("taskID", "deleteTaskV1", taskID);
580
526
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
581
527
  const headers = {};
582
528
  const queryParameters = {};
@@ -600,9 +546,7 @@ function createIngestionClient({
600
546
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
601
547
  */
602
548
  deleteTransformation({ transformationID }, requestOptions) {
603
- if (!transformationID) {
604
- throw new Error("Parameter `transformationID` is required when calling `deleteTransformation`.");
605
- }
549
+ validateRequired("transformationID", "deleteTransformation", transformationID);
606
550
  const requestPath = "/1/transformations/{transformationID}".replace(
607
551
  "{transformationID}",
608
552
  encodeURIComponent(transformationID)
@@ -629,9 +573,7 @@ function createIngestionClient({
629
573
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
630
574
  */
631
575
  disableTask({ taskID }, requestOptions) {
632
- if (!taskID) {
633
- throw new Error("Parameter `taskID` is required when calling `disableTask`.");
634
- }
576
+ validateRequired("taskID", "disableTask", taskID);
635
577
  const requestPath = "/2/tasks/{taskID}/disable".replace("{taskID}", encodeURIComponent(taskID));
636
578
  const headers = {};
637
579
  const queryParameters = {};
@@ -657,9 +599,7 @@ function createIngestionClient({
657
599
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
658
600
  */
659
601
  disableTaskV1({ taskID }, requestOptions) {
660
- if (!taskID) {
661
- throw new Error("Parameter `taskID` is required when calling `disableTaskV1`.");
662
- }
602
+ validateRequired("taskID", "disableTaskV1", taskID);
663
603
  const requestPath = "/1/tasks/{taskID}/disable".replace("{taskID}", encodeURIComponent(taskID));
664
604
  const headers = {};
665
605
  const queryParameters = {};
@@ -683,9 +623,7 @@ function createIngestionClient({
683
623
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
684
624
  */
685
625
  enableTask({ taskID }, requestOptions) {
686
- if (!taskID) {
687
- throw new Error("Parameter `taskID` is required when calling `enableTask`.");
688
- }
626
+ validateRequired("taskID", "enableTask", taskID);
689
627
  const requestPath = "/2/tasks/{taskID}/enable".replace("{taskID}", encodeURIComponent(taskID));
690
628
  const headers = {};
691
629
  const queryParameters = {};
@@ -711,9 +649,7 @@ function createIngestionClient({
711
649
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
712
650
  */
713
651
  enableTaskV1({ taskID }, requestOptions) {
714
- if (!taskID) {
715
- throw new Error("Parameter `taskID` is required when calling `enableTaskV1`.");
716
- }
652
+ validateRequired("taskID", "enableTaskV1", taskID);
717
653
  const requestPath = "/1/tasks/{taskID}/enable".replace("{taskID}", encodeURIComponent(taskID));
718
654
  const headers = {};
719
655
  const queryParameters = {};
@@ -737,9 +673,7 @@ function createIngestionClient({
737
673
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
738
674
  */
739
675
  getAuthentication({ authenticationID }, requestOptions) {
740
- if (!authenticationID) {
741
- throw new Error("Parameter `authenticationID` is required when calling `getAuthentication`.");
742
- }
676
+ validateRequired("authenticationID", "getAuthentication", authenticationID);
743
677
  const requestPath = "/1/authentications/{authenticationID}".replace(
744
678
  "{authenticationID}",
745
679
  encodeURIComponent(authenticationID)
@@ -766,9 +700,7 @@ function createIngestionClient({
766
700
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
767
701
  */
768
702
  getDestination({ destinationID }, requestOptions) {
769
- if (!destinationID) {
770
- throw new Error("Parameter `destinationID` is required when calling `getDestination`.");
771
- }
703
+ validateRequired("destinationID", "getDestination", destinationID);
772
704
  const requestPath = "/1/destinations/{destinationID}".replace(
773
705
  "{destinationID}",
774
706
  encodeURIComponent(destinationID)
@@ -796,12 +728,8 @@ function createIngestionClient({
796
728
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
797
729
  */
798
730
  getEvent({ runID, eventID }, requestOptions) {
799
- if (!runID) {
800
- throw new Error("Parameter `runID` is required when calling `getEvent`.");
801
- }
802
- if (!eventID) {
803
- throw new Error("Parameter `eventID` is required when calling `getEvent`.");
804
- }
731
+ validateRequired("runID", "getEvent", runID);
732
+ validateRequired("eventID", "getEvent", eventID);
805
733
  const requestPath = "/1/runs/{runID}/events/{eventID}".replace("{runID}", encodeURIComponent(runID)).replace("{eventID}", encodeURIComponent(eventID));
806
734
  const headers = {};
807
735
  const queryParameters = {};
@@ -825,9 +753,7 @@ function createIngestionClient({
825
753
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
826
754
  */
827
755
  getRun({ runID }, requestOptions) {
828
- if (!runID) {
829
- throw new Error("Parameter `runID` is required when calling `getRun`.");
830
- }
756
+ validateRequired("runID", "getRun", runID);
831
757
  const requestPath = "/1/runs/{runID}".replace("{runID}", encodeURIComponent(runID));
832
758
  const headers = {};
833
759
  const queryParameters = {};
@@ -851,9 +777,7 @@ function createIngestionClient({
851
777
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
852
778
  */
853
779
  getSource({ sourceID }, requestOptions) {
854
- if (!sourceID) {
855
- throw new Error("Parameter `sourceID` is required when calling `getSource`.");
856
- }
780
+ validateRequired("sourceID", "getSource", sourceID);
857
781
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
858
782
  const headers = {};
859
783
  const queryParameters = {};
@@ -877,9 +801,7 @@ function createIngestionClient({
877
801
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
878
802
  */
879
803
  getTask({ taskID }, requestOptions) {
880
- if (!taskID) {
881
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
882
- }
804
+ validateRequired("taskID", "getTask", taskID);
883
805
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
884
806
  const headers = {};
885
807
  const queryParameters = {};
@@ -905,9 +827,7 @@ function createIngestionClient({
905
827
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
906
828
  */
907
829
  getTaskV1({ taskID }, requestOptions) {
908
- if (!taskID) {
909
- throw new Error("Parameter `taskID` is required when calling `getTaskV1`.");
910
- }
830
+ validateRequired("taskID", "getTaskV1", taskID);
911
831
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
912
832
  const headers = {};
913
833
  const queryParameters = {};
@@ -931,9 +851,7 @@ function createIngestionClient({
931
851
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
932
852
  */
933
853
  getTransformation({ transformationID }, requestOptions) {
934
- if (!transformationID) {
935
- throw new Error("Parameter `transformationID` is required when calling `getTransformation`.");
936
- }
854
+ validateRequired("transformationID", "getTransformation", transformationID);
937
855
  const requestPath = "/1/transformations/{transformationID}".replace(
938
856
  "{transformationID}",
939
857
  encodeURIComponent(transformationID)
@@ -1064,9 +982,7 @@ function createIngestionClient({
1064
982
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1065
983
  */
1066
984
  listEvents({ runID, itemsPerPage, page, status, type, sort, order, startDate, endDate }, requestOptions) {
1067
- if (!runID) {
1068
- throw new Error("Parameter `runID` is required when calling `listEvents`.");
1069
- }
985
+ validateRequired("runID", "listEvents", runID);
1070
986
  const requestPath = "/1/runs/{runID}/events".replace("{runID}", encodeURIComponent(runID));
1071
987
  const headers = {};
1072
988
  const queryParameters = {};
@@ -1401,18 +1317,10 @@ function createIngestionClient({
1401
1317
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1402
1318
  */
1403
1319
  push({ indexName, pushTaskPayload, watch, referenceIndexName }, requestOptions) {
1404
- if (!indexName) {
1405
- throw new Error("Parameter `indexName` is required when calling `push`.");
1406
- }
1407
- if (!pushTaskPayload) {
1408
- throw new Error("Parameter `pushTaskPayload` is required when calling `push`.");
1409
- }
1410
- if (!pushTaskPayload.action) {
1411
- throw new Error("Parameter `pushTaskPayload.action` is required when calling `push`.");
1412
- }
1413
- if (!pushTaskPayload.records) {
1414
- throw new Error("Parameter `pushTaskPayload.records` is required when calling `push`.");
1415
- }
1320
+ validateRequired("indexName", "push", indexName);
1321
+ validateRequired("pushTaskPayload", "push", pushTaskPayload);
1322
+ validateRequired("pushTaskPayload.action", "push", pushTaskPayload.action);
1323
+ validateRequired("pushTaskPayload.records", "push", pushTaskPayload.records);
1416
1324
  const requestPath = "/1/push/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1417
1325
  const headers = {};
1418
1326
  const queryParameters = {};
@@ -1453,18 +1361,10 @@ function createIngestionClient({
1453
1361
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1454
1362
  */
1455
1363
  pushTask({ taskID, pushTaskPayload, watch }, requestOptions) {
1456
- if (!taskID) {
1457
- throw new Error("Parameter `taskID` is required when calling `pushTask`.");
1458
- }
1459
- if (!pushTaskPayload) {
1460
- throw new Error("Parameter `pushTaskPayload` is required when calling `pushTask`.");
1461
- }
1462
- if (!pushTaskPayload.action) {
1463
- throw new Error("Parameter `pushTaskPayload.action` is required when calling `pushTask`.");
1464
- }
1465
- if (!pushTaskPayload.records) {
1466
- throw new Error("Parameter `pushTaskPayload.records` is required when calling `pushTask`.");
1467
- }
1364
+ validateRequired("taskID", "pushTask", taskID);
1365
+ validateRequired("pushTaskPayload", "pushTask", pushTaskPayload);
1366
+ validateRequired("pushTaskPayload.action", "pushTask", pushTaskPayload.action);
1367
+ validateRequired("pushTaskPayload.records", "pushTask", pushTaskPayload.records);
1468
1368
  const requestPath = "/2/tasks/{taskID}/push".replace("{taskID}", encodeURIComponent(taskID));
1469
1369
  const headers = {};
1470
1370
  const queryParameters = {};
@@ -1501,18 +1401,10 @@ function createIngestionClient({
1501
1401
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1502
1402
  */
1503
1403
  replaceTask({ taskID, taskReplace }, requestOptions) {
1504
- if (!taskID) {
1505
- throw new Error("Parameter `taskID` is required when calling `replaceTask`.");
1506
- }
1507
- if (!taskReplace) {
1508
- throw new Error("Parameter `taskReplace` is required when calling `replaceTask`.");
1509
- }
1510
- if (!taskReplace.destinationID) {
1511
- throw new Error("Parameter `taskReplace.destinationID` is required when calling `replaceTask`.");
1512
- }
1513
- if (!taskReplace.action) {
1514
- throw new Error("Parameter `taskReplace.action` is required when calling `replaceTask`.");
1515
- }
1404
+ validateRequired("taskID", "replaceTask", taskID);
1405
+ validateRequired("taskReplace", "replaceTask", taskReplace);
1406
+ validateRequired("taskReplace.destinationID", "replaceTask", taskReplace.destinationID);
1407
+ validateRequired("taskReplace.action", "replaceTask", taskReplace.action);
1516
1408
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1517
1409
  const headers = {};
1518
1410
  const queryParameters = {};
@@ -1538,9 +1430,7 @@ function createIngestionClient({
1538
1430
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1539
1431
  */
1540
1432
  runSource({ sourceID, runSourcePayload }, requestOptions) {
1541
- if (!sourceID) {
1542
- throw new Error("Parameter `sourceID` is required when calling `runSource`.");
1543
- }
1433
+ validateRequired("sourceID", "runSource", sourceID);
1544
1434
  const requestPath = "/1/sources/{sourceID}/run".replace("{sourceID}", encodeURIComponent(sourceID));
1545
1435
  const headers = {};
1546
1436
  const queryParameters = {};
@@ -1566,9 +1456,7 @@ function createIngestionClient({
1566
1456
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1567
1457
  */
1568
1458
  runTask({ taskID, runTaskPayload }, requestOptions) {
1569
- if (!taskID) {
1570
- throw new Error("Parameter `taskID` is required when calling `runTask`.");
1571
- }
1459
+ validateRequired("taskID", "runTask", taskID);
1572
1460
  const requestPath = "/2/tasks/{taskID}/run".replace("{taskID}", encodeURIComponent(taskID));
1573
1461
  const headers = {};
1574
1462
  const queryParameters = {};
@@ -1596,9 +1484,7 @@ function createIngestionClient({
1596
1484
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1597
1485
  */
1598
1486
  runTaskV1({ taskID, runTaskPayload }, requestOptions) {
1599
- if (!taskID) {
1600
- throw new Error("Parameter `taskID` is required when calling `runTaskV1`.");
1601
- }
1487
+ validateRequired("taskID", "runTaskV1", taskID);
1602
1488
  const requestPath = "/1/tasks/{taskID}/run".replace("{taskID}", encodeURIComponent(taskID));
1603
1489
  const headers = {};
1604
1490
  const queryParameters = {};
@@ -1622,14 +1508,12 @@ function createIngestionClient({
1622
1508
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1623
1509
  */
1624
1510
  searchAuthentications(authenticationSearch, requestOptions) {
1625
- if (!authenticationSearch) {
1626
- throw new Error("Parameter `authenticationSearch` is required when calling `searchAuthentications`.");
1627
- }
1628
- if (!authenticationSearch.authenticationIDs) {
1629
- throw new Error(
1630
- "Parameter `authenticationSearch.authenticationIDs` is required when calling `searchAuthentications`."
1631
- );
1632
- }
1511
+ validateRequired("authenticationSearch", "searchAuthentications", authenticationSearch);
1512
+ validateRequired(
1513
+ "authenticationSearch.authenticationIDs",
1514
+ "searchAuthentications",
1515
+ authenticationSearch.authenticationIDs
1516
+ );
1633
1517
  const requestPath = "/1/authentications/search";
1634
1518
  const headers = {};
1635
1519
  const queryParameters = {};
@@ -1653,12 +1537,8 @@ function createIngestionClient({
1653
1537
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1654
1538
  */
1655
1539
  searchDestinations(destinationSearch, requestOptions) {
1656
- if (!destinationSearch) {
1657
- throw new Error("Parameter `destinationSearch` is required when calling `searchDestinations`.");
1658
- }
1659
- if (!destinationSearch.destinationIDs) {
1660
- throw new Error("Parameter `destinationSearch.destinationIDs` is required when calling `searchDestinations`.");
1661
- }
1540
+ validateRequired("destinationSearch", "searchDestinations", destinationSearch);
1541
+ validateRequired("destinationSearch.destinationIDs", "searchDestinations", destinationSearch.destinationIDs);
1662
1542
  const requestPath = "/1/destinations/search";
1663
1543
  const headers = {};
1664
1544
  const queryParameters = {};
@@ -1682,12 +1562,8 @@ function createIngestionClient({
1682
1562
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1683
1563
  */
1684
1564
  searchSources(sourceSearch, requestOptions) {
1685
- if (!sourceSearch) {
1686
- throw new Error("Parameter `sourceSearch` is required when calling `searchSources`.");
1687
- }
1688
- if (!sourceSearch.sourceIDs) {
1689
- throw new Error("Parameter `sourceSearch.sourceIDs` is required when calling `searchSources`.");
1690
- }
1565
+ validateRequired("sourceSearch", "searchSources", sourceSearch);
1566
+ validateRequired("sourceSearch.sourceIDs", "searchSources", sourceSearch.sourceIDs);
1691
1567
  const requestPath = "/1/sources/search";
1692
1568
  const headers = {};
1693
1569
  const queryParameters = {};
@@ -1711,12 +1587,8 @@ function createIngestionClient({
1711
1587
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1712
1588
  */
1713
1589
  searchTasks(taskSearch, requestOptions) {
1714
- if (!taskSearch) {
1715
- throw new Error("Parameter `taskSearch` is required when calling `searchTasks`.");
1716
- }
1717
- if (!taskSearch.taskIDs) {
1718
- throw new Error("Parameter `taskSearch.taskIDs` is required when calling `searchTasks`.");
1719
- }
1590
+ validateRequired("taskSearch", "searchTasks", taskSearch);
1591
+ validateRequired("taskSearch.taskIDs", "searchTasks", taskSearch.taskIDs);
1720
1592
  const requestPath = "/2/tasks/search";
1721
1593
  const headers = {};
1722
1594
  const queryParameters = {};
@@ -1742,12 +1614,8 @@ function createIngestionClient({
1742
1614
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1743
1615
  */
1744
1616
  searchTasksV1(taskSearch, requestOptions) {
1745
- if (!taskSearch) {
1746
- throw new Error("Parameter `taskSearch` is required when calling `searchTasksV1`.");
1747
- }
1748
- if (!taskSearch.taskIDs) {
1749
- throw new Error("Parameter `taskSearch.taskIDs` is required when calling `searchTasksV1`.");
1750
- }
1617
+ validateRequired("taskSearch", "searchTasksV1", taskSearch);
1618
+ validateRequired("taskSearch.taskIDs", "searchTasksV1", taskSearch.taskIDs);
1751
1619
  const requestPath = "/1/tasks/search";
1752
1620
  const headers = {};
1753
1621
  const queryParameters = {};
@@ -1771,14 +1639,12 @@ function createIngestionClient({
1771
1639
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1772
1640
  */
1773
1641
  searchTransformations(transformationSearch, requestOptions) {
1774
- if (!transformationSearch) {
1775
- throw new Error("Parameter `transformationSearch` is required when calling `searchTransformations`.");
1776
- }
1777
- if (!transformationSearch.transformationIDs) {
1778
- throw new Error(
1779
- "Parameter `transformationSearch.transformationIDs` is required when calling `searchTransformations`."
1780
- );
1781
- }
1642
+ validateRequired("transformationSearch", "searchTransformations", transformationSearch);
1643
+ validateRequired(
1644
+ "transformationSearch.transformationIDs",
1645
+ "searchTransformations",
1646
+ transformationSearch.transformationIDs
1647
+ );
1782
1648
  const requestPath = "/1/transformations/search";
1783
1649
  const headers = {};
1784
1650
  const queryParameters = {};
@@ -1803,9 +1669,7 @@ function createIngestionClient({
1803
1669
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1804
1670
  */
1805
1671
  triggerDockerSourceDiscover({ sourceID }, requestOptions) {
1806
- if (!sourceID) {
1807
- throw new Error("Parameter `sourceID` is required when calling `triggerDockerSourceDiscover`.");
1808
- }
1672
+ validateRequired("sourceID", "triggerDockerSourceDiscover", sourceID);
1809
1673
  const requestPath = "/1/sources/{sourceID}/discover".replace("{sourceID}", encodeURIComponent(sourceID));
1810
1674
  const headers = {};
1811
1675
  const queryParameters = {};
@@ -1836,12 +1700,8 @@ function createIngestionClient({
1836
1700
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1837
1701
  */
1838
1702
  tryTransformation(transformationTry, requestOptions) {
1839
- if (!transformationTry) {
1840
- throw new Error("Parameter `transformationTry` is required when calling `tryTransformation`.");
1841
- }
1842
- if (!transformationTry.sampleRecord) {
1843
- throw new Error("Parameter `transformationTry.sampleRecord` is required when calling `tryTransformation`.");
1844
- }
1703
+ validateRequired("transformationTry", "tryTransformation", transformationTry);
1704
+ validateRequired("transformationTry.sampleRecord", "tryTransformation", transformationTry.sampleRecord);
1845
1705
  const requestPath = "/1/transformations/try";
1846
1706
  const headers = {};
1847
1707
  const queryParameters = {};
@@ -1867,17 +1727,13 @@ function createIngestionClient({
1867
1727
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1868
1728
  */
1869
1729
  tryTransformationBeforeUpdate({ transformationID, transformationTry }, requestOptions) {
1870
- if (!transformationID) {
1871
- throw new Error("Parameter `transformationID` is required when calling `tryTransformationBeforeUpdate`.");
1872
- }
1873
- if (!transformationTry) {
1874
- throw new Error("Parameter `transformationTry` is required when calling `tryTransformationBeforeUpdate`.");
1875
- }
1876
- if (!transformationTry.sampleRecord) {
1877
- throw new Error(
1878
- "Parameter `transformationTry.sampleRecord` is required when calling `tryTransformationBeforeUpdate`."
1879
- );
1880
- }
1730
+ validateRequired("transformationID", "tryTransformationBeforeUpdate", transformationID);
1731
+ validateRequired("transformationTry", "tryTransformationBeforeUpdate", transformationTry);
1732
+ validateRequired(
1733
+ "transformationTry.sampleRecord",
1734
+ "tryTransformationBeforeUpdate",
1735
+ transformationTry.sampleRecord
1736
+ );
1881
1737
  const requestPath = "/1/transformations/{transformationID}/try".replace(
1882
1738
  "{transformationID}",
1883
1739
  encodeURIComponent(transformationID)
@@ -1906,12 +1762,8 @@ function createIngestionClient({
1906
1762
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1907
1763
  */
1908
1764
  updateAuthentication({ authenticationID, authenticationUpdate }, requestOptions) {
1909
- if (!authenticationID) {
1910
- throw new Error("Parameter `authenticationID` is required when calling `updateAuthentication`.");
1911
- }
1912
- if (!authenticationUpdate) {
1913
- throw new Error("Parameter `authenticationUpdate` is required when calling `updateAuthentication`.");
1914
- }
1765
+ validateRequired("authenticationID", "updateAuthentication", authenticationID);
1766
+ validateRequired("authenticationUpdate", "updateAuthentication", authenticationUpdate);
1915
1767
  const requestPath = "/1/authentications/{authenticationID}".replace(
1916
1768
  "{authenticationID}",
1917
1769
  encodeURIComponent(authenticationID)
@@ -1940,12 +1792,8 @@ function createIngestionClient({
1940
1792
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1941
1793
  */
1942
1794
  updateDestination({ destinationID, destinationUpdate }, requestOptions) {
1943
- if (!destinationID) {
1944
- throw new Error("Parameter `destinationID` is required when calling `updateDestination`.");
1945
- }
1946
- if (!destinationUpdate) {
1947
- throw new Error("Parameter `destinationUpdate` is required when calling `updateDestination`.");
1948
- }
1795
+ validateRequired("destinationID", "updateDestination", destinationID);
1796
+ validateRequired("destinationUpdate", "updateDestination", destinationUpdate);
1949
1797
  const requestPath = "/1/destinations/{destinationID}".replace(
1950
1798
  "{destinationID}",
1951
1799
  encodeURIComponent(destinationID)
@@ -1974,12 +1822,8 @@ function createIngestionClient({
1974
1822
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1975
1823
  */
1976
1824
  updateSource({ sourceID, sourceUpdate }, requestOptions) {
1977
- if (!sourceID) {
1978
- throw new Error("Parameter `sourceID` is required when calling `updateSource`.");
1979
- }
1980
- if (!sourceUpdate) {
1981
- throw new Error("Parameter `sourceUpdate` is required when calling `updateSource`.");
1982
- }
1825
+ validateRequired("sourceID", "updateSource", sourceID);
1826
+ validateRequired("sourceUpdate", "updateSource", sourceUpdate);
1983
1827
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
1984
1828
  const headers = {};
1985
1829
  const queryParameters = {};
@@ -2005,12 +1849,8 @@ function createIngestionClient({
2005
1849
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2006
1850
  */
2007
1851
  updateTask({ taskID, taskUpdate }, requestOptions) {
2008
- if (!taskID) {
2009
- throw new Error("Parameter `taskID` is required when calling `updateTask`.");
2010
- }
2011
- if (!taskUpdate) {
2012
- throw new Error("Parameter `taskUpdate` is required when calling `updateTask`.");
2013
- }
1852
+ validateRequired("taskID", "updateTask", taskID);
1853
+ validateRequired("taskUpdate", "updateTask", taskUpdate);
2014
1854
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
2015
1855
  const headers = {};
2016
1856
  const queryParameters = {};
@@ -2038,12 +1878,8 @@ function createIngestionClient({
2038
1878
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2039
1879
  */
2040
1880
  updateTaskV1({ taskID, taskUpdate }, requestOptions) {
2041
- if (!taskID) {
2042
- throw new Error("Parameter `taskID` is required when calling `updateTaskV1`.");
2043
- }
2044
- if (!taskUpdate) {
2045
- throw new Error("Parameter `taskUpdate` is required when calling `updateTaskV1`.");
2046
- }
1881
+ validateRequired("taskID", "updateTaskV1", taskID);
1882
+ validateRequired("taskUpdate", "updateTaskV1", taskUpdate);
2047
1883
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
2048
1884
  const headers = {};
2049
1885
  const queryParameters = {};
@@ -2069,15 +1905,9 @@ function createIngestionClient({
2069
1905
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2070
1906
  */
2071
1907
  updateTransformation({ transformationID, transformationCreate }, requestOptions) {
2072
- if (!transformationID) {
2073
- throw new Error("Parameter `transformationID` is required when calling `updateTransformation`.");
2074
- }
2075
- if (!transformationCreate) {
2076
- throw new Error("Parameter `transformationCreate` is required when calling `updateTransformation`.");
2077
- }
2078
- if (!transformationCreate.name) {
2079
- throw new Error("Parameter `transformationCreate.name` is required when calling `updateTransformation`.");
2080
- }
1908
+ validateRequired("transformationID", "updateTransformation", transformationID);
1909
+ validateRequired("transformationCreate", "updateTransformation", transformationCreate);
1910
+ validateRequired("transformationCreate.name", "updateTransformation", transformationCreate.name);
2081
1911
  const requestPath = "/1/transformations/{transformationID}".replace(
2082
1912
  "{transformationID}",
2083
1913
  encodeURIComponent(transformationID)
@@ -2137,12 +1967,8 @@ function createIngestionClient({
2137
1967
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2138
1968
  */
2139
1969
  validateSourceBeforeUpdate({ sourceID, sourceUpdate }, requestOptions) {
2140
- if (!sourceID) {
2141
- throw new Error("Parameter `sourceID` is required when calling `validateSourceBeforeUpdate`.");
2142
- }
2143
- if (!sourceUpdate) {
2144
- throw new Error("Parameter `sourceUpdate` is required when calling `validateSourceBeforeUpdate`.");
2145
- }
1970
+ validateRequired("sourceID", "validateSourceBeforeUpdate", sourceID);
1971
+ validateRequired("sourceUpdate", "validateSourceBeforeUpdate", sourceUpdate);
2146
1972
  const requestPath = "/1/sources/{sourceID}/validate".replace("{sourceID}", encodeURIComponent(sourceID));
2147
1973
  const headers = {};
2148
1974
  const queryParameters = {};
@@ -2173,11 +1999,4 @@ export {
2173
1999
  isScheduleTrigger,
2174
2000
  isSubscriptionTrigger
2175
2001
  };
2176
- //# sourceMappingURL=ingestionClient.js.mapEGIONS,
2177
- apiClientVersion,
2178
- createIngestionClient,
2179
- isOnDemandTrigger,
2180
- isScheduleTrigger,
2181
- isSubscriptionTrigger
2182
- };
2183
2002
  //# sourceMappingURL=ingestionClient.js.map