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