@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.
@@ -8,8 +8,14 @@ import {
8
8
  import { createXhrRequester } from "@algolia/requester-browser-xhr";
9
9
 
10
10
  // src/ingestionClient.ts
11
- import { createAuth, createIterablePromise, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
12
- var apiClientVersion = "1.52.1";
11
+ import {
12
+ createAuth,
13
+ createIterablePromise,
14
+ createTransporter,
15
+ getAlgoliaAgent,
16
+ validateRequired
17
+ } from "@algolia/client-common";
18
+ var apiClientVersion = "1.54.0";
13
19
  var REGIONS = ["eu", "us"];
14
20
  function getDefaultHosts(region) {
15
21
  const url = "data.{region}.algolia.com".replace("{region}", region);
@@ -106,6 +112,7 @@ function createIngestionClient({
106
112
  * @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.
107
113
  * @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.
108
114
  * @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).
115
+ * @param chunkedPush.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
109
116
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getEvent` method and merged with the transporter requestOptions.
110
117
  */
111
118
  async chunkedPush({
@@ -114,7 +121,8 @@ function createIngestionClient({
114
121
  action = "addObject",
115
122
  waitForTasks,
116
123
  batchSize = 1e3,
117
- referenceIndexName
124
+ referenceIndexName,
125
+ maxRetries = 100
118
126
  }, requestOptions) {
119
127
  let records = [];
120
128
  let offset = 0;
@@ -150,8 +158,8 @@ function createIngestionClient({
150
158
  validate: (response) => response !== void 0,
151
159
  aggregator: () => retryCount += 1,
152
160
  error: {
153
- validate: () => retryCount >= 50,
154
- message: () => `The maximum number of retries exceeded. (${retryCount}/${50})`
161
+ validate: () => retryCount >= maxRetries,
162
+ 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.`
155
163
  },
156
164
  timeout: () => Math.min(retryCount * 1500, 5e3)
157
165
  });
@@ -172,18 +180,10 @@ function createIngestionClient({
172
180
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
173
181
  */
174
182
  createAuthentication(authenticationCreate, requestOptions) {
175
- if (!authenticationCreate) {
176
- throw new Error("Parameter `authenticationCreate` is required when calling `createAuthentication`.");
177
- }
178
- if (!authenticationCreate.type) {
179
- throw new Error("Parameter `authenticationCreate.type` is required when calling `createAuthentication`.");
180
- }
181
- if (!authenticationCreate.name) {
182
- throw new Error("Parameter `authenticationCreate.name` is required when calling `createAuthentication`.");
183
- }
184
- if (!authenticationCreate.input) {
185
- throw new Error("Parameter `authenticationCreate.input` is required when calling `createAuthentication`.");
186
- }
183
+ validateRequired("authenticationCreate", "createAuthentication", authenticationCreate);
184
+ validateRequired("authenticationCreate.type", "createAuthentication", authenticationCreate.type);
185
+ validateRequired("authenticationCreate.name", "createAuthentication", authenticationCreate.name);
186
+ validateRequired("authenticationCreate.input", "createAuthentication", authenticationCreate.input);
187
187
  const requestPath = "/1/authentications";
188
188
  const headers = {};
189
189
  const queryParameters = {};
@@ -207,18 +207,10 @@ function createIngestionClient({
207
207
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
208
208
  */
209
209
  createDestination(destinationCreate, requestOptions) {
210
- if (!destinationCreate) {
211
- throw new Error("Parameter `destinationCreate` is required when calling `createDestination`.");
212
- }
213
- if (!destinationCreate.type) {
214
- throw new Error("Parameter `destinationCreate.type` is required when calling `createDestination`.");
215
- }
216
- if (!destinationCreate.name) {
217
- throw new Error("Parameter `destinationCreate.name` is required when calling `createDestination`.");
218
- }
219
- if (!destinationCreate.input) {
220
- throw new Error("Parameter `destinationCreate.input` is required when calling `createDestination`.");
221
- }
210
+ validateRequired("destinationCreate", "createDestination", destinationCreate);
211
+ validateRequired("destinationCreate.type", "createDestination", destinationCreate.type);
212
+ validateRequired("destinationCreate.name", "createDestination", destinationCreate.name);
213
+ validateRequired("destinationCreate.input", "createDestination", destinationCreate.input);
222
214
  const requestPath = "/1/destinations";
223
215
  const headers = {};
224
216
  const queryParameters = {};
@@ -242,15 +234,9 @@ function createIngestionClient({
242
234
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
243
235
  */
244
236
  createSource(sourceCreate, requestOptions) {
245
- if (!sourceCreate) {
246
- throw new Error("Parameter `sourceCreate` is required when calling `createSource`.");
247
- }
248
- if (!sourceCreate.type) {
249
- throw new Error("Parameter `sourceCreate.type` is required when calling `createSource`.");
250
- }
251
- if (!sourceCreate.name) {
252
- throw new Error("Parameter `sourceCreate.name` is required when calling `createSource`.");
253
- }
237
+ validateRequired("sourceCreate", "createSource", sourceCreate);
238
+ validateRequired("sourceCreate.type", "createSource", sourceCreate.type);
239
+ validateRequired("sourceCreate.name", "createSource", sourceCreate.name);
254
240
  const requestPath = "/1/sources";
255
241
  const headers = {};
256
242
  const queryParameters = {};
@@ -274,18 +260,10 @@ function createIngestionClient({
274
260
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
275
261
  */
276
262
  createTask(taskCreate, requestOptions) {
277
- if (!taskCreate) {
278
- throw new Error("Parameter `taskCreate` is required when calling `createTask`.");
279
- }
280
- if (!taskCreate.sourceID) {
281
- throw new Error("Parameter `taskCreate.sourceID` is required when calling `createTask`.");
282
- }
283
- if (!taskCreate.destinationID) {
284
- throw new Error("Parameter `taskCreate.destinationID` is required when calling `createTask`.");
285
- }
286
- if (!taskCreate.action) {
287
- throw new Error("Parameter `taskCreate.action` is required when calling `createTask`.");
288
- }
263
+ validateRequired("taskCreate", "createTask", taskCreate);
264
+ validateRequired("taskCreate.sourceID", "createTask", taskCreate.sourceID);
265
+ validateRequired("taskCreate.destinationID", "createTask", taskCreate.destinationID);
266
+ validateRequired("taskCreate.action", "createTask", taskCreate.action);
289
267
  const requestPath = "/2/tasks";
290
268
  const headers = {};
291
269
  const queryParameters = {};
@@ -311,21 +289,11 @@ function createIngestionClient({
311
289
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
312
290
  */
313
291
  createTaskV1(taskCreate, requestOptions) {
314
- if (!taskCreate) {
315
- throw new Error("Parameter `taskCreate` is required when calling `createTaskV1`.");
316
- }
317
- if (!taskCreate.sourceID) {
318
- throw new Error("Parameter `taskCreate.sourceID` is required when calling `createTaskV1`.");
319
- }
320
- if (!taskCreate.destinationID) {
321
- throw new Error("Parameter `taskCreate.destinationID` is required when calling `createTaskV1`.");
322
- }
323
- if (!taskCreate.trigger) {
324
- throw new Error("Parameter `taskCreate.trigger` is required when calling `createTaskV1`.");
325
- }
326
- if (!taskCreate.action) {
327
- throw new Error("Parameter `taskCreate.action` is required when calling `createTaskV1`.");
328
- }
292
+ validateRequired("taskCreate", "createTaskV1", taskCreate);
293
+ validateRequired("taskCreate.sourceID", "createTaskV1", taskCreate.sourceID);
294
+ validateRequired("taskCreate.destinationID", "createTaskV1", taskCreate.destinationID);
295
+ validateRequired("taskCreate.trigger", "createTaskV1", taskCreate.trigger);
296
+ validateRequired("taskCreate.action", "createTaskV1", taskCreate.action);
329
297
  const requestPath = "/1/tasks";
330
298
  const headers = {};
331
299
  const queryParameters = {};
@@ -349,12 +317,8 @@ function createIngestionClient({
349
317
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
350
318
  */
351
319
  createTransformation(transformationCreate, requestOptions) {
352
- if (!transformationCreate) {
353
- throw new Error("Parameter `transformationCreate` is required when calling `createTransformation`.");
354
- }
355
- if (!transformationCreate.name) {
356
- throw new Error("Parameter `transformationCreate.name` is required when calling `createTransformation`.");
357
- }
320
+ validateRequired("transformationCreate", "createTransformation", transformationCreate);
321
+ validateRequired("transformationCreate.name", "createTransformation", transformationCreate.name);
358
322
  const requestPath = "/1/transformations";
359
323
  const headers = {};
360
324
  const queryParameters = {};
@@ -375,9 +339,7 @@ function createIngestionClient({
375
339
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
376
340
  */
377
341
  customDelete({ path, parameters }, requestOptions) {
378
- if (!path) {
379
- throw new Error("Parameter `path` is required when calling `customDelete`.");
380
- }
342
+ validateRequired("path", "customDelete", path);
381
343
  const requestPath = "/{path}".replace("{path}", path);
382
344
  const headers = {};
383
345
  const queryParameters = parameters ? parameters : {};
@@ -397,9 +359,7 @@ function createIngestionClient({
397
359
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
398
360
  */
399
361
  customGet({ path, parameters }, requestOptions) {
400
- if (!path) {
401
- throw new Error("Parameter `path` is required when calling `customGet`.");
402
- }
362
+ validateRequired("path", "customGet", path);
403
363
  const requestPath = "/{path}".replace("{path}", path);
404
364
  const headers = {};
405
365
  const queryParameters = parameters ? parameters : {};
@@ -420,9 +380,7 @@ function createIngestionClient({
420
380
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
421
381
  */
422
382
  customPost({ path, parameters, body }, requestOptions) {
423
- if (!path) {
424
- throw new Error("Parameter `path` is required when calling `customPost`.");
425
- }
383
+ validateRequired("path", "customPost", path);
426
384
  const requestPath = "/{path}".replace("{path}", path);
427
385
  const headers = {};
428
386
  const queryParameters = parameters ? parameters : {};
@@ -444,9 +402,7 @@ function createIngestionClient({
444
402
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
445
403
  */
446
404
  customPut({ path, parameters, body }, requestOptions) {
447
- if (!path) {
448
- throw new Error("Parameter `path` is required when calling `customPut`.");
449
- }
405
+ validateRequired("path", "customPut", path);
450
406
  const requestPath = "/{path}".replace("{path}", path);
451
407
  const headers = {};
452
408
  const queryParameters = parameters ? parameters : {};
@@ -471,9 +427,7 @@ function createIngestionClient({
471
427
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
472
428
  */
473
429
  deleteAuthentication({ authenticationID }, requestOptions) {
474
- if (!authenticationID) {
475
- throw new Error("Parameter `authenticationID` is required when calling `deleteAuthentication`.");
476
- }
430
+ validateRequired("authenticationID", "deleteAuthentication", authenticationID);
477
431
  const requestPath = "/1/authentications/{authenticationID}".replace(
478
432
  "{authenticationID}",
479
433
  encodeURIComponent(authenticationID)
@@ -500,9 +454,7 @@ function createIngestionClient({
500
454
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
501
455
  */
502
456
  deleteDestination({ destinationID }, requestOptions) {
503
- if (!destinationID) {
504
- throw new Error("Parameter `destinationID` is required when calling `deleteDestination`.");
505
- }
457
+ validateRequired("destinationID", "deleteDestination", destinationID);
506
458
  const requestPath = "/1/destinations/{destinationID}".replace(
507
459
  "{destinationID}",
508
460
  encodeURIComponent(destinationID)
@@ -529,9 +481,7 @@ function createIngestionClient({
529
481
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
530
482
  */
531
483
  deleteSource({ sourceID }, requestOptions) {
532
- if (!sourceID) {
533
- throw new Error("Parameter `sourceID` is required when calling `deleteSource`.");
534
- }
484
+ validateRequired("sourceID", "deleteSource", sourceID);
535
485
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
536
486
  const headers = {};
537
487
  const queryParameters = {};
@@ -555,9 +505,7 @@ function createIngestionClient({
555
505
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
556
506
  */
557
507
  deleteTask({ taskID }, requestOptions) {
558
- if (!taskID) {
559
- throw new Error("Parameter `taskID` is required when calling `deleteTask`.");
560
- }
508
+ validateRequired("taskID", "deleteTask", taskID);
561
509
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
562
510
  const headers = {};
563
511
  const queryParameters = {};
@@ -583,9 +531,7 @@ function createIngestionClient({
583
531
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
584
532
  */
585
533
  deleteTaskV1({ taskID }, requestOptions) {
586
- if (!taskID) {
587
- throw new Error("Parameter `taskID` is required when calling `deleteTaskV1`.");
588
- }
534
+ validateRequired("taskID", "deleteTaskV1", taskID);
589
535
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
590
536
  const headers = {};
591
537
  const queryParameters = {};
@@ -609,9 +555,7 @@ function createIngestionClient({
609
555
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
610
556
  */
611
557
  deleteTransformation({ transformationID }, requestOptions) {
612
- if (!transformationID) {
613
- throw new Error("Parameter `transformationID` is required when calling `deleteTransformation`.");
614
- }
558
+ validateRequired("transformationID", "deleteTransformation", transformationID);
615
559
  const requestPath = "/1/transformations/{transformationID}".replace(
616
560
  "{transformationID}",
617
561
  encodeURIComponent(transformationID)
@@ -638,9 +582,7 @@ function createIngestionClient({
638
582
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
639
583
  */
640
584
  disableTask({ taskID }, requestOptions) {
641
- if (!taskID) {
642
- throw new Error("Parameter `taskID` is required when calling `disableTask`.");
643
- }
585
+ validateRequired("taskID", "disableTask", taskID);
644
586
  const requestPath = "/2/tasks/{taskID}/disable".replace("{taskID}", encodeURIComponent(taskID));
645
587
  const headers = {};
646
588
  const queryParameters = {};
@@ -666,9 +608,7 @@ function createIngestionClient({
666
608
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
667
609
  */
668
610
  disableTaskV1({ taskID }, requestOptions) {
669
- if (!taskID) {
670
- throw new Error("Parameter `taskID` is required when calling `disableTaskV1`.");
671
- }
611
+ validateRequired("taskID", "disableTaskV1", taskID);
672
612
  const requestPath = "/1/tasks/{taskID}/disable".replace("{taskID}", encodeURIComponent(taskID));
673
613
  const headers = {};
674
614
  const queryParameters = {};
@@ -692,9 +632,7 @@ function createIngestionClient({
692
632
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
693
633
  */
694
634
  enableTask({ taskID }, requestOptions) {
695
- if (!taskID) {
696
- throw new Error("Parameter `taskID` is required when calling `enableTask`.");
697
- }
635
+ validateRequired("taskID", "enableTask", taskID);
698
636
  const requestPath = "/2/tasks/{taskID}/enable".replace("{taskID}", encodeURIComponent(taskID));
699
637
  const headers = {};
700
638
  const queryParameters = {};
@@ -720,9 +658,7 @@ function createIngestionClient({
720
658
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
721
659
  */
722
660
  enableTaskV1({ taskID }, requestOptions) {
723
- if (!taskID) {
724
- throw new Error("Parameter `taskID` is required when calling `enableTaskV1`.");
725
- }
661
+ validateRequired("taskID", "enableTaskV1", taskID);
726
662
  const requestPath = "/1/tasks/{taskID}/enable".replace("{taskID}", encodeURIComponent(taskID));
727
663
  const headers = {};
728
664
  const queryParameters = {};
@@ -746,9 +682,7 @@ function createIngestionClient({
746
682
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
747
683
  */
748
684
  getAuthentication({ authenticationID }, requestOptions) {
749
- if (!authenticationID) {
750
- throw new Error("Parameter `authenticationID` is required when calling `getAuthentication`.");
751
- }
685
+ validateRequired("authenticationID", "getAuthentication", authenticationID);
752
686
  const requestPath = "/1/authentications/{authenticationID}".replace(
753
687
  "{authenticationID}",
754
688
  encodeURIComponent(authenticationID)
@@ -775,9 +709,7 @@ function createIngestionClient({
775
709
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
776
710
  */
777
711
  getDestination({ destinationID }, requestOptions) {
778
- if (!destinationID) {
779
- throw new Error("Parameter `destinationID` is required when calling `getDestination`.");
780
- }
712
+ validateRequired("destinationID", "getDestination", destinationID);
781
713
  const requestPath = "/1/destinations/{destinationID}".replace(
782
714
  "{destinationID}",
783
715
  encodeURIComponent(destinationID)
@@ -805,12 +737,8 @@ function createIngestionClient({
805
737
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
806
738
  */
807
739
  getEvent({ runID, eventID }, requestOptions) {
808
- if (!runID) {
809
- throw new Error("Parameter `runID` is required when calling `getEvent`.");
810
- }
811
- if (!eventID) {
812
- throw new Error("Parameter `eventID` is required when calling `getEvent`.");
813
- }
740
+ validateRequired("runID", "getEvent", runID);
741
+ validateRequired("eventID", "getEvent", eventID);
814
742
  const requestPath = "/1/runs/{runID}/events/{eventID}".replace("{runID}", encodeURIComponent(runID)).replace("{eventID}", encodeURIComponent(eventID));
815
743
  const headers = {};
816
744
  const queryParameters = {};
@@ -834,9 +762,7 @@ function createIngestionClient({
834
762
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
835
763
  */
836
764
  getRun({ runID }, requestOptions) {
837
- if (!runID) {
838
- throw new Error("Parameter `runID` is required when calling `getRun`.");
839
- }
765
+ validateRequired("runID", "getRun", runID);
840
766
  const requestPath = "/1/runs/{runID}".replace("{runID}", encodeURIComponent(runID));
841
767
  const headers = {};
842
768
  const queryParameters = {};
@@ -860,9 +786,7 @@ function createIngestionClient({
860
786
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
861
787
  */
862
788
  getSource({ sourceID }, requestOptions) {
863
- if (!sourceID) {
864
- throw new Error("Parameter `sourceID` is required when calling `getSource`.");
865
- }
789
+ validateRequired("sourceID", "getSource", sourceID);
866
790
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
867
791
  const headers = {};
868
792
  const queryParameters = {};
@@ -886,9 +810,7 @@ function createIngestionClient({
886
810
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
887
811
  */
888
812
  getTask({ taskID }, requestOptions) {
889
- if (!taskID) {
890
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
891
- }
813
+ validateRequired("taskID", "getTask", taskID);
892
814
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
893
815
  const headers = {};
894
816
  const queryParameters = {};
@@ -914,9 +836,7 @@ function createIngestionClient({
914
836
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
915
837
  */
916
838
  getTaskV1({ taskID }, requestOptions) {
917
- if (!taskID) {
918
- throw new Error("Parameter `taskID` is required when calling `getTaskV1`.");
919
- }
839
+ validateRequired("taskID", "getTaskV1", taskID);
920
840
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
921
841
  const headers = {};
922
842
  const queryParameters = {};
@@ -940,9 +860,7 @@ function createIngestionClient({
940
860
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
941
861
  */
942
862
  getTransformation({ transformationID }, requestOptions) {
943
- if (!transformationID) {
944
- throw new Error("Parameter `transformationID` is required when calling `getTransformation`.");
945
- }
863
+ validateRequired("transformationID", "getTransformation", transformationID);
946
864
  const requestPath = "/1/transformations/{transformationID}".replace(
947
865
  "{transformationID}",
948
866
  encodeURIComponent(transformationID)
@@ -1073,9 +991,7 @@ function createIngestionClient({
1073
991
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1074
992
  */
1075
993
  listEvents({ runID, itemsPerPage, page, status, type, sort, order, startDate, endDate }, requestOptions) {
1076
- if (!runID) {
1077
- throw new Error("Parameter `runID` is required when calling `listEvents`.");
1078
- }
994
+ validateRequired("runID", "listEvents", runID);
1079
995
  const requestPath = "/1/runs/{runID}/events".replace("{runID}", encodeURIComponent(runID));
1080
996
  const headers = {};
1081
997
  const queryParameters = {};
@@ -1410,18 +1326,10 @@ function createIngestionClient({
1410
1326
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1411
1327
  */
1412
1328
  push({ indexName, pushTaskPayload, watch, referenceIndexName }, requestOptions) {
1413
- if (!indexName) {
1414
- throw new Error("Parameter `indexName` is required when calling `push`.");
1415
- }
1416
- if (!pushTaskPayload) {
1417
- throw new Error("Parameter `pushTaskPayload` is required when calling `push`.");
1418
- }
1419
- if (!pushTaskPayload.action) {
1420
- throw new Error("Parameter `pushTaskPayload.action` is required when calling `push`.");
1421
- }
1422
- if (!pushTaskPayload.records) {
1423
- throw new Error("Parameter `pushTaskPayload.records` is required when calling `push`.");
1424
- }
1329
+ validateRequired("indexName", "push", indexName);
1330
+ validateRequired("pushTaskPayload", "push", pushTaskPayload);
1331
+ validateRequired("pushTaskPayload.action", "push", pushTaskPayload.action);
1332
+ validateRequired("pushTaskPayload.records", "push", pushTaskPayload.records);
1425
1333
  const requestPath = "/1/push/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1426
1334
  const headers = {};
1427
1335
  const queryParameters = {};
@@ -1462,18 +1370,10 @@ function createIngestionClient({
1462
1370
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1463
1371
  */
1464
1372
  pushTask({ taskID, pushTaskPayload, watch }, requestOptions) {
1465
- if (!taskID) {
1466
- throw new Error("Parameter `taskID` is required when calling `pushTask`.");
1467
- }
1468
- if (!pushTaskPayload) {
1469
- throw new Error("Parameter `pushTaskPayload` is required when calling `pushTask`.");
1470
- }
1471
- if (!pushTaskPayload.action) {
1472
- throw new Error("Parameter `pushTaskPayload.action` is required when calling `pushTask`.");
1473
- }
1474
- if (!pushTaskPayload.records) {
1475
- throw new Error("Parameter `pushTaskPayload.records` is required when calling `pushTask`.");
1476
- }
1373
+ validateRequired("taskID", "pushTask", taskID);
1374
+ validateRequired("pushTaskPayload", "pushTask", pushTaskPayload);
1375
+ validateRequired("pushTaskPayload.action", "pushTask", pushTaskPayload.action);
1376
+ validateRequired("pushTaskPayload.records", "pushTask", pushTaskPayload.records);
1477
1377
  const requestPath = "/2/tasks/{taskID}/push".replace("{taskID}", encodeURIComponent(taskID));
1478
1378
  const headers = {};
1479
1379
  const queryParameters = {};
@@ -1510,18 +1410,10 @@ function createIngestionClient({
1510
1410
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1511
1411
  */
1512
1412
  replaceTask({ taskID, taskReplace }, requestOptions) {
1513
- if (!taskID) {
1514
- throw new Error("Parameter `taskID` is required when calling `replaceTask`.");
1515
- }
1516
- if (!taskReplace) {
1517
- throw new Error("Parameter `taskReplace` is required when calling `replaceTask`.");
1518
- }
1519
- if (!taskReplace.destinationID) {
1520
- throw new Error("Parameter `taskReplace.destinationID` is required when calling `replaceTask`.");
1521
- }
1522
- if (!taskReplace.action) {
1523
- throw new Error("Parameter `taskReplace.action` is required when calling `replaceTask`.");
1524
- }
1413
+ validateRequired("taskID", "replaceTask", taskID);
1414
+ validateRequired("taskReplace", "replaceTask", taskReplace);
1415
+ validateRequired("taskReplace.destinationID", "replaceTask", taskReplace.destinationID);
1416
+ validateRequired("taskReplace.action", "replaceTask", taskReplace.action);
1525
1417
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1526
1418
  const headers = {};
1527
1419
  const queryParameters = {};
@@ -1547,9 +1439,7 @@ function createIngestionClient({
1547
1439
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1548
1440
  */
1549
1441
  runSource({ sourceID, runSourcePayload }, requestOptions) {
1550
- if (!sourceID) {
1551
- throw new Error("Parameter `sourceID` is required when calling `runSource`.");
1552
- }
1442
+ validateRequired("sourceID", "runSource", sourceID);
1553
1443
  const requestPath = "/1/sources/{sourceID}/run".replace("{sourceID}", encodeURIComponent(sourceID));
1554
1444
  const headers = {};
1555
1445
  const queryParameters = {};
@@ -1575,9 +1465,7 @@ function createIngestionClient({
1575
1465
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1576
1466
  */
1577
1467
  runTask({ taskID, runTaskPayload }, requestOptions) {
1578
- if (!taskID) {
1579
- throw new Error("Parameter `taskID` is required when calling `runTask`.");
1580
- }
1468
+ validateRequired("taskID", "runTask", taskID);
1581
1469
  const requestPath = "/2/tasks/{taskID}/run".replace("{taskID}", encodeURIComponent(taskID));
1582
1470
  const headers = {};
1583
1471
  const queryParameters = {};
@@ -1605,9 +1493,7 @@ function createIngestionClient({
1605
1493
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1606
1494
  */
1607
1495
  runTaskV1({ taskID, runTaskPayload }, requestOptions) {
1608
- if (!taskID) {
1609
- throw new Error("Parameter `taskID` is required when calling `runTaskV1`.");
1610
- }
1496
+ validateRequired("taskID", "runTaskV1", taskID);
1611
1497
  const requestPath = "/1/tasks/{taskID}/run".replace("{taskID}", encodeURIComponent(taskID));
1612
1498
  const headers = {};
1613
1499
  const queryParameters = {};
@@ -1631,14 +1517,12 @@ function createIngestionClient({
1631
1517
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1632
1518
  */
1633
1519
  searchAuthentications(authenticationSearch, requestOptions) {
1634
- if (!authenticationSearch) {
1635
- throw new Error("Parameter `authenticationSearch` is required when calling `searchAuthentications`.");
1636
- }
1637
- if (!authenticationSearch.authenticationIDs) {
1638
- throw new Error(
1639
- "Parameter `authenticationSearch.authenticationIDs` is required when calling `searchAuthentications`."
1640
- );
1641
- }
1520
+ validateRequired("authenticationSearch", "searchAuthentications", authenticationSearch);
1521
+ validateRequired(
1522
+ "authenticationSearch.authenticationIDs",
1523
+ "searchAuthentications",
1524
+ authenticationSearch.authenticationIDs
1525
+ );
1642
1526
  const requestPath = "/1/authentications/search";
1643
1527
  const headers = {};
1644
1528
  const queryParameters = {};
@@ -1662,12 +1546,8 @@ function createIngestionClient({
1662
1546
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1663
1547
  */
1664
1548
  searchDestinations(destinationSearch, requestOptions) {
1665
- if (!destinationSearch) {
1666
- throw new Error("Parameter `destinationSearch` is required when calling `searchDestinations`.");
1667
- }
1668
- if (!destinationSearch.destinationIDs) {
1669
- throw new Error("Parameter `destinationSearch.destinationIDs` is required when calling `searchDestinations`.");
1670
- }
1549
+ validateRequired("destinationSearch", "searchDestinations", destinationSearch);
1550
+ validateRequired("destinationSearch.destinationIDs", "searchDestinations", destinationSearch.destinationIDs);
1671
1551
  const requestPath = "/1/destinations/search";
1672
1552
  const headers = {};
1673
1553
  const queryParameters = {};
@@ -1691,12 +1571,8 @@ function createIngestionClient({
1691
1571
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1692
1572
  */
1693
1573
  searchSources(sourceSearch, requestOptions) {
1694
- if (!sourceSearch) {
1695
- throw new Error("Parameter `sourceSearch` is required when calling `searchSources`.");
1696
- }
1697
- if (!sourceSearch.sourceIDs) {
1698
- throw new Error("Parameter `sourceSearch.sourceIDs` is required when calling `searchSources`.");
1699
- }
1574
+ validateRequired("sourceSearch", "searchSources", sourceSearch);
1575
+ validateRequired("sourceSearch.sourceIDs", "searchSources", sourceSearch.sourceIDs);
1700
1576
  const requestPath = "/1/sources/search";
1701
1577
  const headers = {};
1702
1578
  const queryParameters = {};
@@ -1720,12 +1596,8 @@ function createIngestionClient({
1720
1596
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1721
1597
  */
1722
1598
  searchTasks(taskSearch, requestOptions) {
1723
- if (!taskSearch) {
1724
- throw new Error("Parameter `taskSearch` is required when calling `searchTasks`.");
1725
- }
1726
- if (!taskSearch.taskIDs) {
1727
- throw new Error("Parameter `taskSearch.taskIDs` is required when calling `searchTasks`.");
1728
- }
1599
+ validateRequired("taskSearch", "searchTasks", taskSearch);
1600
+ validateRequired("taskSearch.taskIDs", "searchTasks", taskSearch.taskIDs);
1729
1601
  const requestPath = "/2/tasks/search";
1730
1602
  const headers = {};
1731
1603
  const queryParameters = {};
@@ -1751,12 +1623,8 @@ function createIngestionClient({
1751
1623
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1752
1624
  */
1753
1625
  searchTasksV1(taskSearch, requestOptions) {
1754
- if (!taskSearch) {
1755
- throw new Error("Parameter `taskSearch` is required when calling `searchTasksV1`.");
1756
- }
1757
- if (!taskSearch.taskIDs) {
1758
- throw new Error("Parameter `taskSearch.taskIDs` is required when calling `searchTasksV1`.");
1759
- }
1626
+ validateRequired("taskSearch", "searchTasksV1", taskSearch);
1627
+ validateRequired("taskSearch.taskIDs", "searchTasksV1", taskSearch.taskIDs);
1760
1628
  const requestPath = "/1/tasks/search";
1761
1629
  const headers = {};
1762
1630
  const queryParameters = {};
@@ -1780,14 +1648,12 @@ function createIngestionClient({
1780
1648
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1781
1649
  */
1782
1650
  searchTransformations(transformationSearch, requestOptions) {
1783
- if (!transformationSearch) {
1784
- throw new Error("Parameter `transformationSearch` is required when calling `searchTransformations`.");
1785
- }
1786
- if (!transformationSearch.transformationIDs) {
1787
- throw new Error(
1788
- "Parameter `transformationSearch.transformationIDs` is required when calling `searchTransformations`."
1789
- );
1790
- }
1651
+ validateRequired("transformationSearch", "searchTransformations", transformationSearch);
1652
+ validateRequired(
1653
+ "transformationSearch.transformationIDs",
1654
+ "searchTransformations",
1655
+ transformationSearch.transformationIDs
1656
+ );
1791
1657
  const requestPath = "/1/transformations/search";
1792
1658
  const headers = {};
1793
1659
  const queryParameters = {};
@@ -1812,9 +1678,7 @@ function createIngestionClient({
1812
1678
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1813
1679
  */
1814
1680
  triggerDockerSourceDiscover({ sourceID }, requestOptions) {
1815
- if (!sourceID) {
1816
- throw new Error("Parameter `sourceID` is required when calling `triggerDockerSourceDiscover`.");
1817
- }
1681
+ validateRequired("sourceID", "triggerDockerSourceDiscover", sourceID);
1818
1682
  const requestPath = "/1/sources/{sourceID}/discover".replace("{sourceID}", encodeURIComponent(sourceID));
1819
1683
  const headers = {};
1820
1684
  const queryParameters = {};
@@ -1845,12 +1709,8 @@ function createIngestionClient({
1845
1709
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1846
1710
  */
1847
1711
  tryTransformation(transformationTry, requestOptions) {
1848
- if (!transformationTry) {
1849
- throw new Error("Parameter `transformationTry` is required when calling `tryTransformation`.");
1850
- }
1851
- if (!transformationTry.sampleRecord) {
1852
- throw new Error("Parameter `transformationTry.sampleRecord` is required when calling `tryTransformation`.");
1853
- }
1712
+ validateRequired("transformationTry", "tryTransformation", transformationTry);
1713
+ validateRequired("transformationTry.sampleRecord", "tryTransformation", transformationTry.sampleRecord);
1854
1714
  const requestPath = "/1/transformations/try";
1855
1715
  const headers = {};
1856
1716
  const queryParameters = {};
@@ -1876,17 +1736,13 @@ function createIngestionClient({
1876
1736
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1877
1737
  */
1878
1738
  tryTransformationBeforeUpdate({ transformationID, transformationTry }, requestOptions) {
1879
- if (!transformationID) {
1880
- throw new Error("Parameter `transformationID` is required when calling `tryTransformationBeforeUpdate`.");
1881
- }
1882
- if (!transformationTry) {
1883
- throw new Error("Parameter `transformationTry` is required when calling `tryTransformationBeforeUpdate`.");
1884
- }
1885
- if (!transformationTry.sampleRecord) {
1886
- throw new Error(
1887
- "Parameter `transformationTry.sampleRecord` is required when calling `tryTransformationBeforeUpdate`."
1888
- );
1889
- }
1739
+ validateRequired("transformationID", "tryTransformationBeforeUpdate", transformationID);
1740
+ validateRequired("transformationTry", "tryTransformationBeforeUpdate", transformationTry);
1741
+ validateRequired(
1742
+ "transformationTry.sampleRecord",
1743
+ "tryTransformationBeforeUpdate",
1744
+ transformationTry.sampleRecord
1745
+ );
1890
1746
  const requestPath = "/1/transformations/{transformationID}/try".replace(
1891
1747
  "{transformationID}",
1892
1748
  encodeURIComponent(transformationID)
@@ -1915,12 +1771,8 @@ function createIngestionClient({
1915
1771
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1916
1772
  */
1917
1773
  updateAuthentication({ authenticationID, authenticationUpdate }, requestOptions) {
1918
- if (!authenticationID) {
1919
- throw new Error("Parameter `authenticationID` is required when calling `updateAuthentication`.");
1920
- }
1921
- if (!authenticationUpdate) {
1922
- throw new Error("Parameter `authenticationUpdate` is required when calling `updateAuthentication`.");
1923
- }
1774
+ validateRequired("authenticationID", "updateAuthentication", authenticationID);
1775
+ validateRequired("authenticationUpdate", "updateAuthentication", authenticationUpdate);
1924
1776
  const requestPath = "/1/authentications/{authenticationID}".replace(
1925
1777
  "{authenticationID}",
1926
1778
  encodeURIComponent(authenticationID)
@@ -1949,12 +1801,8 @@ function createIngestionClient({
1949
1801
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1950
1802
  */
1951
1803
  updateDestination({ destinationID, destinationUpdate }, requestOptions) {
1952
- if (!destinationID) {
1953
- throw new Error("Parameter `destinationID` is required when calling `updateDestination`.");
1954
- }
1955
- if (!destinationUpdate) {
1956
- throw new Error("Parameter `destinationUpdate` is required when calling `updateDestination`.");
1957
- }
1804
+ validateRequired("destinationID", "updateDestination", destinationID);
1805
+ validateRequired("destinationUpdate", "updateDestination", destinationUpdate);
1958
1806
  const requestPath = "/1/destinations/{destinationID}".replace(
1959
1807
  "{destinationID}",
1960
1808
  encodeURIComponent(destinationID)
@@ -1983,12 +1831,8 @@ function createIngestionClient({
1983
1831
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1984
1832
  */
1985
1833
  updateSource({ sourceID, sourceUpdate }, requestOptions) {
1986
- if (!sourceID) {
1987
- throw new Error("Parameter `sourceID` is required when calling `updateSource`.");
1988
- }
1989
- if (!sourceUpdate) {
1990
- throw new Error("Parameter `sourceUpdate` is required when calling `updateSource`.");
1991
- }
1834
+ validateRequired("sourceID", "updateSource", sourceID);
1835
+ validateRequired("sourceUpdate", "updateSource", sourceUpdate);
1992
1836
  const requestPath = "/1/sources/{sourceID}".replace("{sourceID}", encodeURIComponent(sourceID));
1993
1837
  const headers = {};
1994
1838
  const queryParameters = {};
@@ -2014,12 +1858,8 @@ function createIngestionClient({
2014
1858
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2015
1859
  */
2016
1860
  updateTask({ taskID, taskUpdate }, requestOptions) {
2017
- if (!taskID) {
2018
- throw new Error("Parameter `taskID` is required when calling `updateTask`.");
2019
- }
2020
- if (!taskUpdate) {
2021
- throw new Error("Parameter `taskUpdate` is required when calling `updateTask`.");
2022
- }
1861
+ validateRequired("taskID", "updateTask", taskID);
1862
+ validateRequired("taskUpdate", "updateTask", taskUpdate);
2023
1863
  const requestPath = "/2/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
2024
1864
  const headers = {};
2025
1865
  const queryParameters = {};
@@ -2047,12 +1887,8 @@ function createIngestionClient({
2047
1887
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2048
1888
  */
2049
1889
  updateTaskV1({ taskID, taskUpdate }, requestOptions) {
2050
- if (!taskID) {
2051
- throw new Error("Parameter `taskID` is required when calling `updateTaskV1`.");
2052
- }
2053
- if (!taskUpdate) {
2054
- throw new Error("Parameter `taskUpdate` is required when calling `updateTaskV1`.");
2055
- }
1890
+ validateRequired("taskID", "updateTaskV1", taskID);
1891
+ validateRequired("taskUpdate", "updateTaskV1", taskUpdate);
2056
1892
  const requestPath = "/1/tasks/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
2057
1893
  const headers = {};
2058
1894
  const queryParameters = {};
@@ -2078,15 +1914,9 @@ function createIngestionClient({
2078
1914
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2079
1915
  */
2080
1916
  updateTransformation({ transformationID, transformationCreate }, requestOptions) {
2081
- if (!transformationID) {
2082
- throw new Error("Parameter `transformationID` is required when calling `updateTransformation`.");
2083
- }
2084
- if (!transformationCreate) {
2085
- throw new Error("Parameter `transformationCreate` is required when calling `updateTransformation`.");
2086
- }
2087
- if (!transformationCreate.name) {
2088
- throw new Error("Parameter `transformationCreate.name` is required when calling `updateTransformation`.");
2089
- }
1917
+ validateRequired("transformationID", "updateTransformation", transformationID);
1918
+ validateRequired("transformationCreate", "updateTransformation", transformationCreate);
1919
+ validateRequired("transformationCreate.name", "updateTransformation", transformationCreate.name);
2090
1920
  const requestPath = "/1/transformations/{transformationID}".replace(
2091
1921
  "{transformationID}",
2092
1922
  encodeURIComponent(transformationID)
@@ -2146,12 +1976,8 @@ function createIngestionClient({
2146
1976
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2147
1977
  */
2148
1978
  validateSourceBeforeUpdate({ sourceID, sourceUpdate }, requestOptions) {
2149
- if (!sourceID) {
2150
- throw new Error("Parameter `sourceID` is required when calling `validateSourceBeforeUpdate`.");
2151
- }
2152
- if (!sourceUpdate) {
2153
- throw new Error("Parameter `sourceUpdate` is required when calling `validateSourceBeforeUpdate`.");
2154
- }
1979
+ validateRequired("sourceID", "validateSourceBeforeUpdate", sourceID);
1980
+ validateRequired("sourceUpdate", "validateSourceBeforeUpdate", sourceUpdate);
2155
1981
  const requestPath = "/1/sources/{sourceID}/validate".replace("{sourceID}", encodeURIComponent(sourceID));
2156
1982
  const headers = {};
2157
1983
  const queryParameters = {};