@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.
@@ -3,8 +3,14 @@ import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/c
3
3
  import { createFetchRequester } from "@algolia/requester-fetch";
4
4
 
5
5
  // src/ingestionClient.ts
6
- import { createAuth, createIterablePromise, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
7
- var apiClientVersion = "1.52.1";
6
+ import {
7
+ createAuth,
8
+ createIterablePromise,
9
+ createTransporter,
10
+ getAlgoliaAgent,
11
+ validateRequired
12
+ } from "@algolia/client-common";
13
+ var apiClientVersion = "1.54.0";
8
14
  var REGIONS = ["eu", "us"];
9
15
  function getDefaultHosts(region) {
10
16
  const url = "data.{region}.algolia.com".replace("{region}", region);
@@ -101,6 +107,7 @@ function createIngestionClient({
101
107
  * @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.
102
108
  * @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.
103
109
  * @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).
110
+ * @param chunkedPush.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
104
111
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getEvent` method and merged with the transporter requestOptions.
105
112
  */
106
113
  async chunkedPush({
@@ -109,7 +116,8 @@ function createIngestionClient({
109
116
  action = "addObject",
110
117
  waitForTasks,
111
118
  batchSize = 1e3,
112
- referenceIndexName
119
+ referenceIndexName,
120
+ maxRetries = 100
113
121
  }, requestOptions) {
114
122
  let records = [];
115
123
  let offset = 0;
@@ -145,8 +153,8 @@ function createIngestionClient({
145
153
  validate: (response) => response !== void 0,
146
154
  aggregator: () => retryCount += 1,
147
155
  error: {
148
- validate: () => retryCount >= 50,
149
- message: () => `The maximum number of retries exceeded. (${retryCount}/${50})`
156
+ validate: () => retryCount >= maxRetries,
157
+ 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.`
150
158
  },
151
159
  timeout: () => Math.min(retryCount * 1500, 5e3)
152
160
  });
@@ -167,18 +175,10 @@ function createIngestionClient({
167
175
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
168
176
  */
169
177
  createAuthentication(authenticationCreate, requestOptions) {
170
- if (!authenticationCreate) {
171
- throw new Error("Parameter `authenticationCreate` is required when calling `createAuthentication`.");
172
- }
173
- if (!authenticationCreate.type) {
174
- throw new Error("Parameter `authenticationCreate.type` is required when calling `createAuthentication`.");
175
- }
176
- if (!authenticationCreate.name) {
177
- throw new Error("Parameter `authenticationCreate.name` is required when calling `createAuthentication`.");
178
- }
179
- if (!authenticationCreate.input) {
180
- throw new Error("Parameter `authenticationCreate.input` is required when calling `createAuthentication`.");
181
- }
178
+ validateRequired("authenticationCreate", "createAuthentication", authenticationCreate);
179
+ validateRequired("authenticationCreate.type", "createAuthentication", authenticationCreate.type);
180
+ validateRequired("authenticationCreate.name", "createAuthentication", authenticationCreate.name);
181
+ validateRequired("authenticationCreate.input", "createAuthentication", authenticationCreate.input);
182
182
  const requestPath = "/1/authentications";
183
183
  const headers = {};
184
184
  const queryParameters = {};
@@ -202,18 +202,10 @@ function createIngestionClient({
202
202
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
203
203
  */
204
204
  createDestination(destinationCreate, requestOptions) {
205
- if (!destinationCreate) {
206
- throw new Error("Parameter `destinationCreate` is required when calling `createDestination`.");
207
- }
208
- if (!destinationCreate.type) {
209
- throw new Error("Parameter `destinationCreate.type` is required when calling `createDestination`.");
210
- }
211
- if (!destinationCreate.name) {
212
- throw new Error("Parameter `destinationCreate.name` is required when calling `createDestination`.");
213
- }
214
- if (!destinationCreate.input) {
215
- throw new Error("Parameter `destinationCreate.input` is required when calling `createDestination`.");
216
- }
205
+ validateRequired("destinationCreate", "createDestination", destinationCreate);
206
+ validateRequired("destinationCreate.type", "createDestination", destinationCreate.type);
207
+ validateRequired("destinationCreate.name", "createDestination", destinationCreate.name);
208
+ validateRequired("destinationCreate.input", "createDestination", destinationCreate.input);
217
209
  const requestPath = "/1/destinations";
218
210
  const headers = {};
219
211
  const queryParameters = {};
@@ -237,15 +229,9 @@ function createIngestionClient({
237
229
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
238
230
  */
239
231
  createSource(sourceCreate, requestOptions) {
240
- if (!sourceCreate) {
241
- throw new Error("Parameter `sourceCreate` is required when calling `createSource`.");
242
- }
243
- if (!sourceCreate.type) {
244
- throw new Error("Parameter `sourceCreate.type` is required when calling `createSource`.");
245
- }
246
- if (!sourceCreate.name) {
247
- throw new Error("Parameter `sourceCreate.name` is required when calling `createSource`.");
248
- }
232
+ validateRequired("sourceCreate", "createSource", sourceCreate);
233
+ validateRequired("sourceCreate.type", "createSource", sourceCreate.type);
234
+ validateRequired("sourceCreate.name", "createSource", sourceCreate.name);
249
235
  const requestPath = "/1/sources";
250
236
  const headers = {};
251
237
  const queryParameters = {};
@@ -269,18 +255,10 @@ function createIngestionClient({
269
255
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
270
256
  */
271
257
  createTask(taskCreate, requestOptions) {
272
- if (!taskCreate) {
273
- throw new Error("Parameter `taskCreate` is required when calling `createTask`.");
274
- }
275
- if (!taskCreate.sourceID) {
276
- throw new Error("Parameter `taskCreate.sourceID` is required when calling `createTask`.");
277
- }
278
- if (!taskCreate.destinationID) {
279
- throw new Error("Parameter `taskCreate.destinationID` is required when calling `createTask`.");
280
- }
281
- if (!taskCreate.action) {
282
- throw new Error("Parameter `taskCreate.action` is required when calling `createTask`.");
283
- }
258
+ validateRequired("taskCreate", "createTask", taskCreate);
259
+ validateRequired("taskCreate.sourceID", "createTask", taskCreate.sourceID);
260
+ validateRequired("taskCreate.destinationID", "createTask", taskCreate.destinationID);
261
+ validateRequired("taskCreate.action", "createTask", taskCreate.action);
284
262
  const requestPath = "/2/tasks";
285
263
  const headers = {};
286
264
  const queryParameters = {};
@@ -306,21 +284,11 @@ function createIngestionClient({
306
284
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
307
285
  */
308
286
  createTaskV1(taskCreate, requestOptions) {
309
- if (!taskCreate) {
310
- throw new Error("Parameter `taskCreate` is required when calling `createTaskV1`.");
311
- }
312
- if (!taskCreate.sourceID) {
313
- throw new Error("Parameter `taskCreate.sourceID` is required when calling `createTaskV1`.");
314
- }
315
- if (!taskCreate.destinationID) {
316
- throw new Error("Parameter `taskCreate.destinationID` is required when calling `createTaskV1`.");
317
- }
318
- if (!taskCreate.trigger) {
319
- throw new Error("Parameter `taskCreate.trigger` is required when calling `createTaskV1`.");
320
- }
321
- if (!taskCreate.action) {
322
- throw new Error("Parameter `taskCreate.action` is required when calling `createTaskV1`.");
323
- }
287
+ validateRequired("taskCreate", "createTaskV1", taskCreate);
288
+ validateRequired("taskCreate.sourceID", "createTaskV1", taskCreate.sourceID);
289
+ validateRequired("taskCreate.destinationID", "createTaskV1", taskCreate.destinationID);
290
+ validateRequired("taskCreate.trigger", "createTaskV1", taskCreate.trigger);
291
+ validateRequired("taskCreate.action", "createTaskV1", taskCreate.action);
324
292
  const requestPath = "/1/tasks";
325
293
  const headers = {};
326
294
  const queryParameters = {};
@@ -344,12 +312,8 @@ function createIngestionClient({
344
312
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
345
313
  */
346
314
  createTransformation(transformationCreate, requestOptions) {
347
- if (!transformationCreate) {
348
- throw new Error("Parameter `transformationCreate` is required when calling `createTransformation`.");
349
- }
350
- if (!transformationCreate.name) {
351
- throw new Error("Parameter `transformationCreate.name` is required when calling `createTransformation`.");
352
- }
315
+ validateRequired("transformationCreate", "createTransformation", transformationCreate);
316
+ validateRequired("transformationCreate.name", "createTransformation", transformationCreate.name);
353
317
  const requestPath = "/1/transformations";
354
318
  const headers = {};
355
319
  const queryParameters = {};
@@ -370,9 +334,7 @@ function createIngestionClient({
370
334
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
371
335
  */
372
336
  customDelete({ path, parameters }, requestOptions) {
373
- if (!path) {
374
- throw new Error("Parameter `path` is required when calling `customDelete`.");
375
- }
337
+ validateRequired("path", "customDelete", path);
376
338
  const requestPath = "/{path}".replace("{path}", path);
377
339
  const headers = {};
378
340
  const queryParameters = parameters ? parameters : {};
@@ -392,9 +354,7 @@ function createIngestionClient({
392
354
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
393
355
  */
394
356
  customGet({ path, parameters }, requestOptions) {
395
- if (!path) {
396
- throw new Error("Parameter `path` is required when calling `customGet`.");
397
- }
357
+ validateRequired("path", "customGet", path);
398
358
  const requestPath = "/{path}".replace("{path}", path);
399
359
  const headers = {};
400
360
  const queryParameters = parameters ? parameters : {};
@@ -415,9 +375,7 @@ function createIngestionClient({
415
375
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
416
376
  */
417
377
  customPost({ path, parameters, body }, requestOptions) {
418
- if (!path) {
419
- throw new Error("Parameter `path` is required when calling `customPost`.");
420
- }
378
+ validateRequired("path", "customPost", path);
421
379
  const requestPath = "/{path}".replace("{path}", path);
422
380
  const headers = {};
423
381
  const queryParameters = parameters ? parameters : {};
@@ -439,9 +397,7 @@ function createIngestionClient({
439
397
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
440
398
  */
441
399
  customPut({ path, parameters, body }, requestOptions) {
442
- if (!path) {
443
- throw new Error("Parameter `path` is required when calling `customPut`.");
444
- }
400
+ validateRequired("path", "customPut", path);
445
401
  const requestPath = "/{path}".replace("{path}", path);
446
402
  const headers = {};
447
403
  const queryParameters = parameters ? parameters : {};
@@ -466,9 +422,7 @@ function createIngestionClient({
466
422
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
467
423
  */
468
424
  deleteAuthentication({ authenticationID }, requestOptions) {
469
- if (!authenticationID) {
470
- throw new Error("Parameter `authenticationID` is required when calling `deleteAuthentication`.");
471
- }
425
+ validateRequired("authenticationID", "deleteAuthentication", authenticationID);
472
426
  const requestPath = "/1/authentications/{authenticationID}".replace(
473
427
  "{authenticationID}",
474
428
  encodeURIComponent(authenticationID)
@@ -495,9 +449,7 @@ function createIngestionClient({
495
449
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
496
450
  */
497
451
  deleteDestination({ destinationID }, requestOptions) {
498
- if (!destinationID) {
499
- throw new Error("Parameter `destinationID` is required when calling `deleteDestination`.");
500
- }
452
+ validateRequired("destinationID", "deleteDestination", destinationID);
501
453
  const requestPath = "/1/destinations/{destinationID}".replace(
502
454
  "{destinationID}",
503
455
  encodeURIComponent(destinationID)
@@ -524,9 +476,7 @@ function createIngestionClient({
524
476
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
525
477
  */
526
478
  deleteSource({ sourceID }, requestOptions) {
527
- if (!sourceID) {
528
- throw new Error("Parameter `sourceID` is required when calling `deleteSource`.");
529
- }
479
+ validateRequired("sourceID", "deleteSource", sourceID);
530
480
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
531
481
  const headers = {};
532
482
  const queryParameters = {};
@@ -550,9 +500,7 @@ function createIngestionClient({
550
500
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
551
501
  */
552
502
  deleteTask({ taskID }, requestOptions) {
553
- if (!taskID) {
554
- throw new Error("Parameter `taskID` is required when calling `deleteTask`.");
555
- }
503
+ validateRequired("taskID", "deleteTask", taskID);
556
504
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
557
505
  const headers = {};
558
506
  const queryParameters = {};
@@ -578,9 +526,7 @@ function createIngestionClient({
578
526
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
579
527
  */
580
528
  deleteTaskV1({ taskID }, requestOptions) {
581
- if (!taskID) {
582
- throw new Error("Parameter `taskID` is required when calling `deleteTaskV1`.");
583
- }
529
+ validateRequired("taskID", "deleteTaskV1", taskID);
584
530
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
585
531
  const headers = {};
586
532
  const queryParameters = {};
@@ -604,9 +550,7 @@ function createIngestionClient({
604
550
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
605
551
  */
606
552
  deleteTransformation({ transformationID }, requestOptions) {
607
- if (!transformationID) {
608
- throw new Error("Parameter `transformationID` is required when calling `deleteTransformation`.");
609
- }
553
+ validateRequired("transformationID", "deleteTransformation", transformationID);
610
554
  const requestPath = "/1/transformations/{transformationID}".replace(
611
555
  "{transformationID}",
612
556
  encodeURIComponent(transformationID)
@@ -633,9 +577,7 @@ function createIngestionClient({
633
577
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
634
578
  */
635
579
  disableTask({ taskID }, requestOptions) {
636
- if (!taskID) {
637
- throw new Error("Parameter `taskID` is required when calling `disableTask`.");
638
- }
580
+ validateRequired("taskID", "disableTask", taskID);
639
581
  const requestPath = "/2/tasks/{taskID}/disable".replace("{taskID}", encodeURIComponent(taskID));
640
582
  const headers = {};
641
583
  const queryParameters = {};
@@ -661,9 +603,7 @@ function createIngestionClient({
661
603
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
662
604
  */
663
605
  disableTaskV1({ taskID }, requestOptions) {
664
- if (!taskID) {
665
- throw new Error("Parameter `taskID` is required when calling `disableTaskV1`.");
666
- }
606
+ validateRequired("taskID", "disableTaskV1", taskID);
667
607
  const requestPath = "/1/tasks/{taskID}/disable".replace("{taskID}", encodeURIComponent(taskID));
668
608
  const headers = {};
669
609
  const queryParameters = {};
@@ -687,9 +627,7 @@ function createIngestionClient({
687
627
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
688
628
  */
689
629
  enableTask({ taskID }, requestOptions) {
690
- if (!taskID) {
691
- throw new Error("Parameter `taskID` is required when calling `enableTask`.");
692
- }
630
+ validateRequired("taskID", "enableTask", taskID);
693
631
  const requestPath = "/2/tasks/{taskID}/enable".replace("{taskID}", encodeURIComponent(taskID));
694
632
  const headers = {};
695
633
  const queryParameters = {};
@@ -715,9 +653,7 @@ function createIngestionClient({
715
653
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
716
654
  */
717
655
  enableTaskV1({ taskID }, requestOptions) {
718
- if (!taskID) {
719
- throw new Error("Parameter `taskID` is required when calling `enableTaskV1`.");
720
- }
656
+ validateRequired("taskID", "enableTaskV1", taskID);
721
657
  const requestPath = "/1/tasks/{taskID}/enable".replace("{taskID}", encodeURIComponent(taskID));
722
658
  const headers = {};
723
659
  const queryParameters = {};
@@ -741,9 +677,7 @@ function createIngestionClient({
741
677
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
742
678
  */
743
679
  getAuthentication({ authenticationID }, requestOptions) {
744
- if (!authenticationID) {
745
- throw new Error("Parameter `authenticationID` is required when calling `getAuthentication`.");
746
- }
680
+ validateRequired("authenticationID", "getAuthentication", authenticationID);
747
681
  const requestPath = "/1/authentications/{authenticationID}".replace(
748
682
  "{authenticationID}",
749
683
  encodeURIComponent(authenticationID)
@@ -770,9 +704,7 @@ function createIngestionClient({
770
704
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
771
705
  */
772
706
  getDestination({ destinationID }, requestOptions) {
773
- if (!destinationID) {
774
- throw new Error("Parameter `destinationID` is required when calling `getDestination`.");
775
- }
707
+ validateRequired("destinationID", "getDestination", destinationID);
776
708
  const requestPath = "/1/destinations/{destinationID}".replace(
777
709
  "{destinationID}",
778
710
  encodeURIComponent(destinationID)
@@ -800,12 +732,8 @@ function createIngestionClient({
800
732
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
801
733
  */
802
734
  getEvent({ runID, eventID }, requestOptions) {
803
- if (!runID) {
804
- throw new Error("Parameter `runID` is required when calling `getEvent`.");
805
- }
806
- if (!eventID) {
807
- throw new Error("Parameter `eventID` is required when calling `getEvent`.");
808
- }
735
+ validateRequired("runID", "getEvent", runID);
736
+ validateRequired("eventID", "getEvent", eventID);
809
737
  const requestPath = "/1/runs/{runID}/events/{eventID}".replace("{runID}", encodeURIComponent(runID)).replace("{eventID}", encodeURIComponent(eventID));
810
738
  const headers = {};
811
739
  const queryParameters = {};
@@ -829,9 +757,7 @@ function createIngestionClient({
829
757
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
830
758
  */
831
759
  getRun({ runID }, requestOptions) {
832
- if (!runID) {
833
- throw new Error("Parameter `runID` is required when calling `getRun`.");
834
- }
760
+ validateRequired("runID", "getRun", runID);
835
761
  const requestPath = "/1/runs/{runID}".replace("{runID}", encodeURIComponent(runID));
836
762
  const headers = {};
837
763
  const queryParameters = {};
@@ -855,9 +781,7 @@ function createIngestionClient({
855
781
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
856
782
  */
857
783
  getSource({ sourceID }, requestOptions) {
858
- if (!sourceID) {
859
- throw new Error("Parameter `sourceID` is required when calling `getSource`.");
860
- }
784
+ validateRequired("sourceID", "getSource", sourceID);
861
785
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
862
786
  const headers = {};
863
787
  const queryParameters = {};
@@ -881,9 +805,7 @@ function createIngestionClient({
881
805
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
882
806
  */
883
807
  getTask({ taskID }, requestOptions) {
884
- if (!taskID) {
885
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
886
- }
808
+ validateRequired("taskID", "getTask", taskID);
887
809
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
888
810
  const headers = {};
889
811
  const queryParameters = {};
@@ -909,9 +831,7 @@ function createIngestionClient({
909
831
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
910
832
  */
911
833
  getTaskV1({ taskID }, requestOptions) {
912
- if (!taskID) {
913
- throw new Error("Parameter `taskID` is required when calling `getTaskV1`.");
914
- }
834
+ validateRequired("taskID", "getTaskV1", taskID);
915
835
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
916
836
  const headers = {};
917
837
  const queryParameters = {};
@@ -935,9 +855,7 @@ function createIngestionClient({
935
855
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
936
856
  */
937
857
  getTransformation({ transformationID }, requestOptions) {
938
- if (!transformationID) {
939
- throw new Error("Parameter `transformationID` is required when calling `getTransformation`.");
940
- }
858
+ validateRequired("transformationID", "getTransformation", transformationID);
941
859
  const requestPath = "/1/transformations/{transformationID}".replace(
942
860
  "{transformationID}",
943
861
  encodeURIComponent(transformationID)
@@ -1068,9 +986,7 @@ function createIngestionClient({
1068
986
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1069
987
  */
1070
988
  listEvents({ runID, itemsPerPage, page, status, type, sort, order, startDate, endDate }, requestOptions) {
1071
- if (!runID) {
1072
- throw new Error("Parameter `runID` is required when calling `listEvents`.");
1073
- }
989
+ validateRequired("runID", "listEvents", runID);
1074
990
  const requestPath = "/1/runs/{runID}/events".replace("{runID}", encodeURIComponent(runID));
1075
991
  const headers = {};
1076
992
  const queryParameters = {};
@@ -1405,18 +1321,10 @@ function createIngestionClient({
1405
1321
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1406
1322
  */
1407
1323
  push({ indexName, pushTaskPayload, watch, referenceIndexName }, requestOptions) {
1408
- if (!indexName) {
1409
- throw new Error("Parameter `indexName` is required when calling `push`.");
1410
- }
1411
- if (!pushTaskPayload) {
1412
- throw new Error("Parameter `pushTaskPayload` is required when calling `push`.");
1413
- }
1414
- if (!pushTaskPayload.action) {
1415
- throw new Error("Parameter `pushTaskPayload.action` is required when calling `push`.");
1416
- }
1417
- if (!pushTaskPayload.records) {
1418
- throw new Error("Parameter `pushTaskPayload.records` is required when calling `push`.");
1419
- }
1324
+ validateRequired("indexName", "push", indexName);
1325
+ validateRequired("pushTaskPayload", "push", pushTaskPayload);
1326
+ validateRequired("pushTaskPayload.action", "push", pushTaskPayload.action);
1327
+ validateRequired("pushTaskPayload.records", "push", pushTaskPayload.records);
1420
1328
  const requestPath = "/1/push/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1421
1329
  const headers = {};
1422
1330
  const queryParameters = {};
@@ -1457,18 +1365,10 @@ function createIngestionClient({
1457
1365
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1458
1366
  */
1459
1367
  pushTask({ taskID, pushTaskPayload, watch }, requestOptions) {
1460
- if (!taskID) {
1461
- throw new Error("Parameter `taskID` is required when calling `pushTask`.");
1462
- }
1463
- if (!pushTaskPayload) {
1464
- throw new Error("Parameter `pushTaskPayload` is required when calling `pushTask`.");
1465
- }
1466
- if (!pushTaskPayload.action) {
1467
- throw new Error("Parameter `pushTaskPayload.action` is required when calling `pushTask`.");
1468
- }
1469
- if (!pushTaskPayload.records) {
1470
- throw new Error("Parameter `pushTaskPayload.records` is required when calling `pushTask`.");
1471
- }
1368
+ validateRequired("taskID", "pushTask", taskID);
1369
+ validateRequired("pushTaskPayload", "pushTask", pushTaskPayload);
1370
+ validateRequired("pushTaskPayload.action", "pushTask", pushTaskPayload.action);
1371
+ validateRequired("pushTaskPayload.records", "pushTask", pushTaskPayload.records);
1472
1372
  const requestPath = "/2/tasks/{taskID}/push".replace("{taskID}", encodeURIComponent(taskID));
1473
1373
  const headers = {};
1474
1374
  const queryParameters = {};
@@ -1505,18 +1405,10 @@ function createIngestionClient({
1505
1405
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1506
1406
  */
1507
1407
  replaceTask({ taskID, taskReplace }, requestOptions) {
1508
- if (!taskID) {
1509
- throw new Error("Parameter `taskID` is required when calling `replaceTask`.");
1510
- }
1511
- if (!taskReplace) {
1512
- throw new Error("Parameter `taskReplace` is required when calling `replaceTask`.");
1513
- }
1514
- if (!taskReplace.destinationID) {
1515
- throw new Error("Parameter `taskReplace.destinationID` is required when calling `replaceTask`.");
1516
- }
1517
- if (!taskReplace.action) {
1518
- throw new Error("Parameter `taskReplace.action` is required when calling `replaceTask`.");
1519
- }
1408
+ validateRequired("taskID", "replaceTask", taskID);
1409
+ validateRequired("taskReplace", "replaceTask", taskReplace);
1410
+ validateRequired("taskReplace.destinationID", "replaceTask", taskReplace.destinationID);
1411
+ validateRequired("taskReplace.action", "replaceTask", taskReplace.action);
1520
1412
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1521
1413
  const headers = {};
1522
1414
  const queryParameters = {};
@@ -1542,9 +1434,7 @@ function createIngestionClient({
1542
1434
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1543
1435
  */
1544
1436
  runSource({ sourceID, runSourcePayload }, requestOptions) {
1545
- if (!sourceID) {
1546
- throw new Error("Parameter `sourceID` is required when calling `runSource`.");
1547
- }
1437
+ validateRequired("sourceID", "runSource", sourceID);
1548
1438
  const requestPath = "/1/sources/{sourceID}/run".replace("{sourceID}", encodeURIComponent(sourceID));
1549
1439
  const headers = {};
1550
1440
  const queryParameters = {};
@@ -1570,9 +1460,7 @@ function createIngestionClient({
1570
1460
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1571
1461
  */
1572
1462
  runTask({ taskID, runTaskPayload }, requestOptions) {
1573
- if (!taskID) {
1574
- throw new Error("Parameter `taskID` is required when calling `runTask`.");
1575
- }
1463
+ validateRequired("taskID", "runTask", taskID);
1576
1464
  const requestPath = "/2/tasks/{taskID}/run".replace("{taskID}", encodeURIComponent(taskID));
1577
1465
  const headers = {};
1578
1466
  const queryParameters = {};
@@ -1600,9 +1488,7 @@ function createIngestionClient({
1600
1488
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1601
1489
  */
1602
1490
  runTaskV1({ taskID, runTaskPayload }, requestOptions) {
1603
- if (!taskID) {
1604
- throw new Error("Parameter `taskID` is required when calling `runTaskV1`.");
1605
- }
1491
+ validateRequired("taskID", "runTaskV1", taskID);
1606
1492
  const requestPath = "/1/tasks/{taskID}/run".replace("{taskID}", encodeURIComponent(taskID));
1607
1493
  const headers = {};
1608
1494
  const queryParameters = {};
@@ -1626,14 +1512,12 @@ function createIngestionClient({
1626
1512
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1627
1513
  */
1628
1514
  searchAuthentications(authenticationSearch, requestOptions) {
1629
- if (!authenticationSearch) {
1630
- throw new Error("Parameter `authenticationSearch` is required when calling `searchAuthentications`.");
1631
- }
1632
- if (!authenticationSearch.authenticationIDs) {
1633
- throw new Error(
1634
- "Parameter `authenticationSearch.authenticationIDs` is required when calling `searchAuthentications`."
1635
- );
1636
- }
1515
+ validateRequired("authenticationSearch", "searchAuthentications", authenticationSearch);
1516
+ validateRequired(
1517
+ "authenticationSearch.authenticationIDs",
1518
+ "searchAuthentications",
1519
+ authenticationSearch.authenticationIDs
1520
+ );
1637
1521
  const requestPath = "/1/authentications/search";
1638
1522
  const headers = {};
1639
1523
  const queryParameters = {};
@@ -1657,12 +1541,8 @@ function createIngestionClient({
1657
1541
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1658
1542
  */
1659
1543
  searchDestinations(destinationSearch, requestOptions) {
1660
- if (!destinationSearch) {
1661
- throw new Error("Parameter `destinationSearch` is required when calling `searchDestinations`.");
1662
- }
1663
- if (!destinationSearch.destinationIDs) {
1664
- throw new Error("Parameter `destinationSearch.destinationIDs` is required when calling `searchDestinations`.");
1665
- }
1544
+ validateRequired("destinationSearch", "searchDestinations", destinationSearch);
1545
+ validateRequired("destinationSearch.destinationIDs", "searchDestinations", destinationSearch.destinationIDs);
1666
1546
  const requestPath = "/1/destinations/search";
1667
1547
  const headers = {};
1668
1548
  const queryParameters = {};
@@ -1686,12 +1566,8 @@ function createIngestionClient({
1686
1566
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1687
1567
  */
1688
1568
  searchSources(sourceSearch, requestOptions) {
1689
- if (!sourceSearch) {
1690
- throw new Error("Parameter `sourceSearch` is required when calling `searchSources`.");
1691
- }
1692
- if (!sourceSearch.sourceIDs) {
1693
- throw new Error("Parameter `sourceSearch.sourceIDs` is required when calling `searchSources`.");
1694
- }
1569
+ validateRequired("sourceSearch", "searchSources", sourceSearch);
1570
+ validateRequired("sourceSearch.sourceIDs", "searchSources", sourceSearch.sourceIDs);
1695
1571
  const requestPath = "/1/sources/search";
1696
1572
  const headers = {};
1697
1573
  const queryParameters = {};
@@ -1715,12 +1591,8 @@ function createIngestionClient({
1715
1591
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1716
1592
  */
1717
1593
  searchTasks(taskSearch, requestOptions) {
1718
- if (!taskSearch) {
1719
- throw new Error("Parameter `taskSearch` is required when calling `searchTasks`.");
1720
- }
1721
- if (!taskSearch.taskIDs) {
1722
- throw new Error("Parameter `taskSearch.taskIDs` is required when calling `searchTasks`.");
1723
- }
1594
+ validateRequired("taskSearch", "searchTasks", taskSearch);
1595
+ validateRequired("taskSearch.taskIDs", "searchTasks", taskSearch.taskIDs);
1724
1596
  const requestPath = "/2/tasks/search";
1725
1597
  const headers = {};
1726
1598
  const queryParameters = {};
@@ -1746,12 +1618,8 @@ function createIngestionClient({
1746
1618
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1747
1619
  */
1748
1620
  searchTasksV1(taskSearch, requestOptions) {
1749
- if (!taskSearch) {
1750
- throw new Error("Parameter `taskSearch` is required when calling `searchTasksV1`.");
1751
- }
1752
- if (!taskSearch.taskIDs) {
1753
- throw new Error("Parameter `taskSearch.taskIDs` is required when calling `searchTasksV1`.");
1754
- }
1621
+ validateRequired("taskSearch", "searchTasksV1", taskSearch);
1622
+ validateRequired("taskSearch.taskIDs", "searchTasksV1", taskSearch.taskIDs);
1755
1623
  const requestPath = "/1/tasks/search";
1756
1624
  const headers = {};
1757
1625
  const queryParameters = {};
@@ -1775,14 +1643,12 @@ function createIngestionClient({
1775
1643
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1776
1644
  */
1777
1645
  searchTransformations(transformationSearch, requestOptions) {
1778
- if (!transformationSearch) {
1779
- throw new Error("Parameter `transformationSearch` is required when calling `searchTransformations`.");
1780
- }
1781
- if (!transformationSearch.transformationIDs) {
1782
- throw new Error(
1783
- "Parameter `transformationSearch.transformationIDs` is required when calling `searchTransformations`."
1784
- );
1785
- }
1646
+ validateRequired("transformationSearch", "searchTransformations", transformationSearch);
1647
+ validateRequired(
1648
+ "transformationSearch.transformationIDs",
1649
+ "searchTransformations",
1650
+ transformationSearch.transformationIDs
1651
+ );
1786
1652
  const requestPath = "/1/transformations/search";
1787
1653
  const headers = {};
1788
1654
  const queryParameters = {};
@@ -1807,9 +1673,7 @@ function createIngestionClient({
1807
1673
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1808
1674
  */
1809
1675
  triggerDockerSourceDiscover({ sourceID }, requestOptions) {
1810
- if (!sourceID) {
1811
- throw new Error("Parameter `sourceID` is required when calling `triggerDockerSourceDiscover`.");
1812
- }
1676
+ validateRequired("sourceID", "triggerDockerSourceDiscover", sourceID);
1813
1677
  const requestPath = "/1/sources/{sourceID}/discover".replace("{sourceID}", encodeURIComponent(sourceID));
1814
1678
  const headers = {};
1815
1679
  const queryParameters = {};
@@ -1840,12 +1704,8 @@ function createIngestionClient({
1840
1704
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1841
1705
  */
1842
1706
  tryTransformation(transformationTry, requestOptions) {
1843
- if (!transformationTry) {
1844
- throw new Error("Parameter `transformationTry` is required when calling `tryTransformation`.");
1845
- }
1846
- if (!transformationTry.sampleRecord) {
1847
- throw new Error("Parameter `transformationTry.sampleRecord` is required when calling `tryTransformation`.");
1848
- }
1707
+ validateRequired("transformationTry", "tryTransformation", transformationTry);
1708
+ validateRequired("transformationTry.sampleRecord", "tryTransformation", transformationTry.sampleRecord);
1849
1709
  const requestPath = "/1/transformations/try";
1850
1710
  const headers = {};
1851
1711
  const queryParameters = {};
@@ -1871,17 +1731,13 @@ function createIngestionClient({
1871
1731
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1872
1732
  */
1873
1733
  tryTransformationBeforeUpdate({ transformationID, transformationTry }, requestOptions) {
1874
- if (!transformationID) {
1875
- throw new Error("Parameter `transformationID` is required when calling `tryTransformationBeforeUpdate`.");
1876
- }
1877
- if (!transformationTry) {
1878
- throw new Error("Parameter `transformationTry` is required when calling `tryTransformationBeforeUpdate`.");
1879
- }
1880
- if (!transformationTry.sampleRecord) {
1881
- throw new Error(
1882
- "Parameter `transformationTry.sampleRecord` is required when calling `tryTransformationBeforeUpdate`."
1883
- );
1884
- }
1734
+ validateRequired("transformationID", "tryTransformationBeforeUpdate", transformationID);
1735
+ validateRequired("transformationTry", "tryTransformationBeforeUpdate", transformationTry);
1736
+ validateRequired(
1737
+ "transformationTry.sampleRecord",
1738
+ "tryTransformationBeforeUpdate",
1739
+ transformationTry.sampleRecord
1740
+ );
1885
1741
  const requestPath = "/1/transformations/{transformationID}/try".replace(
1886
1742
  "{transformationID}",
1887
1743
  encodeURIComponent(transformationID)
@@ -1910,12 +1766,8 @@ function createIngestionClient({
1910
1766
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1911
1767
  */
1912
1768
  updateAuthentication({ authenticationID, authenticationUpdate }, requestOptions) {
1913
- if (!authenticationID) {
1914
- throw new Error("Parameter `authenticationID` is required when calling `updateAuthentication`.");
1915
- }
1916
- if (!authenticationUpdate) {
1917
- throw new Error("Parameter `authenticationUpdate` is required when calling `updateAuthentication`.");
1918
- }
1769
+ validateRequired("authenticationID", "updateAuthentication", authenticationID);
1770
+ validateRequired("authenticationUpdate", "updateAuthentication", authenticationUpdate);
1919
1771
  const requestPath = "/1/authentications/{authenticationID}".replace(
1920
1772
  "{authenticationID}",
1921
1773
  encodeURIComponent(authenticationID)
@@ -1944,12 +1796,8 @@ function createIngestionClient({
1944
1796
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1945
1797
  */
1946
1798
  updateDestination({ destinationID, destinationUpdate }, requestOptions) {
1947
- if (!destinationID) {
1948
- throw new Error("Parameter `destinationID` is required when calling `updateDestination`.");
1949
- }
1950
- if (!destinationUpdate) {
1951
- throw new Error("Parameter `destinationUpdate` is required when calling `updateDestination`.");
1952
- }
1799
+ validateRequired("destinationID", "updateDestination", destinationID);
1800
+ validateRequired("destinationUpdate", "updateDestination", destinationUpdate);
1953
1801
  const requestPath = "/1/destinations/{destinationID}".replace(
1954
1802
  "{destinationID}",
1955
1803
  encodeURIComponent(destinationID)
@@ -1978,12 +1826,8 @@ function createIngestionClient({
1978
1826
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1979
1827
  */
1980
1828
  updateSource({ sourceID, sourceUpdate }, requestOptions) {
1981
- if (!sourceID) {
1982
- throw new Error("Parameter `sourceID` is required when calling `updateSource`.");
1983
- }
1984
- if (!sourceUpdate) {
1985
- throw new Error("Parameter `sourceUpdate` is required when calling `updateSource`.");
1986
- }
1829
+ validateRequired("sourceID", "updateSource", sourceID);
1830
+ validateRequired("sourceUpdate", "updateSource", sourceUpdate);
1987
1831
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
1988
1832
  const headers = {};
1989
1833
  const queryParameters = {};
@@ -2009,12 +1853,8 @@ function createIngestionClient({
2009
1853
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2010
1854
  */
2011
1855
  updateTask({ taskID, taskUpdate }, requestOptions) {
2012
- if (!taskID) {
2013
- throw new Error("Parameter `taskID` is required when calling `updateTask`.");
2014
- }
2015
- if (!taskUpdate) {
2016
- throw new Error("Parameter `taskUpdate` is required when calling `updateTask`.");
2017
- }
1856
+ validateRequired("taskID", "updateTask", taskID);
1857
+ validateRequired("taskUpdate", "updateTask", taskUpdate);
2018
1858
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
2019
1859
  const headers = {};
2020
1860
  const queryParameters = {};
@@ -2042,12 +1882,8 @@ function createIngestionClient({
2042
1882
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2043
1883
  */
2044
1884
  updateTaskV1({ taskID, taskUpdate }, requestOptions) {
2045
- if (!taskID) {
2046
- throw new Error("Parameter `taskID` is required when calling `updateTaskV1`.");
2047
- }
2048
- if (!taskUpdate) {
2049
- throw new Error("Parameter `taskUpdate` is required when calling `updateTaskV1`.");
2050
- }
1885
+ validateRequired("taskID", "updateTaskV1", taskID);
1886
+ validateRequired("taskUpdate", "updateTaskV1", taskUpdate);
2051
1887
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
2052
1888
  const headers = {};
2053
1889
  const queryParameters = {};
@@ -2073,15 +1909,9 @@ function createIngestionClient({
2073
1909
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2074
1910
  */
2075
1911
  updateTransformation({ transformationID, transformationCreate }, requestOptions) {
2076
- if (!transformationID) {
2077
- throw new Error("Parameter `transformationID` is required when calling `updateTransformation`.");
2078
- }
2079
- if (!transformationCreate) {
2080
- throw new Error("Parameter `transformationCreate` is required when calling `updateTransformation`.");
2081
- }
2082
- if (!transformationCreate.name) {
2083
- throw new Error("Parameter `transformationCreate.name` is required when calling `updateTransformation`.");
2084
- }
1912
+ validateRequired("transformationID", "updateTransformation", transformationID);
1913
+ validateRequired("transformationCreate", "updateTransformation", transformationCreate);
1914
+ validateRequired("transformationCreate.name", "updateTransformation", transformationCreate.name);
2085
1915
  const requestPath = "/1/transformations/{transformationID}".replace(
2086
1916
  "{transformationID}",
2087
1917
  encodeURIComponent(transformationID)
@@ -2141,12 +1971,8 @@ function createIngestionClient({
2141
1971
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2142
1972
  */
2143
1973
  validateSourceBeforeUpdate({ sourceID, sourceUpdate }, requestOptions) {
2144
- if (!sourceID) {
2145
- throw new Error("Parameter `sourceID` is required when calling `validateSourceBeforeUpdate`.");
2146
- }
2147
- if (!sourceUpdate) {
2148
- throw new Error("Parameter `sourceUpdate` is required when calling `validateSourceBeforeUpdate`.");
2149
- }
1974
+ validateRequired("sourceID", "validateSourceBeforeUpdate", sourceID);
1975
+ validateRequired("sourceUpdate", "validateSourceBeforeUpdate", sourceUpdate);
2150
1976
  const requestPath = "/1/sources/{sourceID}/validate".replace("{sourceID}", encodeURIComponent(sourceID));
2151
1977
  const headers = {};
2152
1978
  const queryParameters = {};