@io-orkes/conductor-javascript 1.1.0 → 1.2.0-rc.1

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.
@@ -0,0 +1,3456 @@
1
+ // src/common/ConductorLogger.ts
2
+ var LOG_LEVELS = {
3
+ DEBUG: 10,
4
+ INFO: 30,
5
+ ERROR: 60
6
+ };
7
+ var DefaultLogger = class {
8
+ constructor(config = {}) {
9
+ this.info = (...args) => {
10
+ this.log("INFO", ...args);
11
+ };
12
+ this.debug = (...args) => {
13
+ this.log("DEBUG", ...args);
14
+ };
15
+ this.error = (...args) => {
16
+ this.log("ERROR", ...args);
17
+ };
18
+ const { level, tags = [] } = config;
19
+ this.tags = tags;
20
+ if (level && level in LOG_LEVELS) {
21
+ this.level = LOG_LEVELS[level];
22
+ } else {
23
+ this.level = LOG_LEVELS.INFO;
24
+ }
25
+ }
26
+ log(level, ...args) {
27
+ let resolvedLevel;
28
+ let name = level;
29
+ if (level in LOG_LEVELS) {
30
+ resolvedLevel = LOG_LEVELS[level];
31
+ } else {
32
+ name = "INFO";
33
+ resolvedLevel = LOG_LEVELS.INFO;
34
+ }
35
+ if (resolvedLevel >= this.level) {
36
+ console.log(name, ...this.tags, ...args);
37
+ }
38
+ }
39
+ };
40
+ var noopLogger = {
41
+ //eslint-disable-next-line
42
+ debug: (...args) => {
43
+ },
44
+ //eslint-disable-next-line
45
+ info: (...args) => {
46
+ },
47
+ //eslint-disable-next-line
48
+ error: (...args) => {
49
+ }
50
+ };
51
+
52
+ // src/common/types.ts
53
+ var TaskType = /* @__PURE__ */ ((TaskType2) => {
54
+ TaskType2["START"] = "START";
55
+ TaskType2["SIMPLE"] = "SIMPLE";
56
+ TaskType2["DYNAMIC"] = "DYNAMIC";
57
+ TaskType2["FORK_JOIN"] = "FORK_JOIN";
58
+ TaskType2["FORK_JOIN_DYNAMIC"] = "FORK_JOIN_DYNAMIC";
59
+ TaskType2["DECISION"] = "DECISION";
60
+ TaskType2["SWITCH"] = "SWITCH";
61
+ TaskType2["JOIN"] = "JOIN";
62
+ TaskType2["DO_WHILE"] = "DO_WHILE";
63
+ TaskType2["SUB_WORKFLOW"] = "SUB_WORKFLOW";
64
+ TaskType2["EVENT"] = "EVENT";
65
+ TaskType2["WAIT"] = "WAIT";
66
+ TaskType2["USER_DEFINED"] = "USER_DEFINED";
67
+ TaskType2["HTTP"] = "HTTP";
68
+ TaskType2["LAMBDA"] = "LAMBDA";
69
+ TaskType2["INLINE"] = "INLINE";
70
+ TaskType2["EXCLUSIVE_JOIN"] = "EXCLUSIVE_JOIN";
71
+ TaskType2["TERMINAL"] = "TERMINAL";
72
+ TaskType2["TERMINATE"] = "TERMINATE";
73
+ TaskType2["KAFKA_PUBLISH"] = "KAFKA_PUBLISH";
74
+ TaskType2["JSON_JQ_TRANSFORM"] = "JSON_JQ_TRANSFORM";
75
+ TaskType2["SET_VARIABLE"] = "SET_VARIABLE";
76
+ return TaskType2;
77
+ })(TaskType || {});
78
+
79
+ // src/common/open-api/services/EventResourceService.ts
80
+ var EventResourceService = class {
81
+ constructor(httpRequest) {
82
+ this.httpRequest = httpRequest;
83
+ }
84
+ /**
85
+ * Get queue config by name
86
+ * @param queueType
87
+ * @param queueName
88
+ * @returns any OK
89
+ * @throws ApiError
90
+ */
91
+ getQueueConfig(queueType, queueName) {
92
+ return this.httpRequest.request({
93
+ method: "GET",
94
+ url: "/event/queue/config/{queueType}/{queueName}",
95
+ path: {
96
+ "queueType": queueType,
97
+ "queueName": queueName
98
+ }
99
+ });
100
+ }
101
+ /**
102
+ * Create or update queue config by name
103
+ * @param queueType
104
+ * @param queueName
105
+ * @param requestBody
106
+ * @returns any OK
107
+ * @throws ApiError
108
+ */
109
+ putQueueConfig(queueType, queueName, requestBody) {
110
+ return this.httpRequest.request({
111
+ method: "PUT",
112
+ url: "/event/queue/config/{queueType}/{queueName}",
113
+ path: {
114
+ "queueType": queueType,
115
+ "queueName": queueName
116
+ },
117
+ body: requestBody,
118
+ mediaType: "application/json"
119
+ });
120
+ }
121
+ /**
122
+ * Delete queue config by name
123
+ * @param queueType
124
+ * @param queueName
125
+ * @returns any OK
126
+ * @throws ApiError
127
+ */
128
+ deleteQueueConfig(queueType, queueName) {
129
+ return this.httpRequest.request({
130
+ method: "DELETE",
131
+ url: "/event/queue/config/{queueType}/{queueName}",
132
+ path: {
133
+ "queueType": queueType,
134
+ "queueName": queueName
135
+ }
136
+ });
137
+ }
138
+ /**
139
+ * Get all the event handlers
140
+ * @returns EventHandler OK
141
+ * @throws ApiError
142
+ */
143
+ getEventHandlers() {
144
+ return this.httpRequest.request({
145
+ method: "GET",
146
+ url: "/event"
147
+ });
148
+ }
149
+ /**
150
+ * Update an existing event handler.
151
+ * @param requestBody
152
+ * @returns any OK
153
+ * @throws ApiError
154
+ */
155
+ updateEventHandler(requestBody) {
156
+ return this.httpRequest.request({
157
+ method: "PUT",
158
+ url: "/event",
159
+ body: requestBody,
160
+ mediaType: "application/json"
161
+ });
162
+ }
163
+ /**
164
+ * Add a new event handler.
165
+ * @param requestBody
166
+ * @returns any OK
167
+ * @throws ApiError
168
+ */
169
+ addEventHandler(requestBody) {
170
+ return this.httpRequest.request({
171
+ method: "POST",
172
+ url: "/event",
173
+ body: requestBody,
174
+ mediaType: "application/json"
175
+ });
176
+ }
177
+ /**
178
+ * Get all queue configs
179
+ * @returns any OK
180
+ * @throws ApiError
181
+ */
182
+ getQueueNames() {
183
+ return this.httpRequest.request({
184
+ method: "GET",
185
+ url: "/event/queue/config"
186
+ });
187
+ }
188
+ /**
189
+ * Remove an event handler
190
+ * @param name
191
+ * @returns any OK
192
+ * @throws ApiError
193
+ */
194
+ removeEventHandlerStatus(name) {
195
+ return this.httpRequest.request({
196
+ method: "DELETE",
197
+ url: "/event/{name}",
198
+ path: {
199
+ "name": name
200
+ }
201
+ });
202
+ }
203
+ /**
204
+ * Get event handlers for a given event
205
+ * @param event
206
+ * @param activeOnly
207
+ * @returns EventHandler OK
208
+ * @throws ApiError
209
+ */
210
+ getEventHandlersForEvent(event, activeOnly = true) {
211
+ return this.httpRequest.request({
212
+ method: "GET",
213
+ url: "/event/{event}",
214
+ path: {
215
+ "event": event
216
+ },
217
+ query: {
218
+ "activeOnly": activeOnly
219
+ }
220
+ });
221
+ }
222
+ };
223
+
224
+ // src/common/open-api/services/HealthCheckResourceService.ts
225
+ var HealthCheckResourceService = class {
226
+ constructor(httpRequest) {
227
+ this.httpRequest = httpRequest;
228
+ }
229
+ /**
230
+ * @returns any OK
231
+ * @throws ApiError
232
+ */
233
+ doCheck() {
234
+ return this.httpRequest.request({
235
+ method: "GET",
236
+ url: "/health"
237
+ });
238
+ }
239
+ };
240
+
241
+ // src/common/open-api/services/MetadataResourceService.ts
242
+ var MetadataResourceService = class {
243
+ constructor(httpRequest) {
244
+ this.httpRequest = httpRequest;
245
+ }
246
+ /**
247
+ * Gets the task definition
248
+ * @param tasktype
249
+ * @param metadata
250
+ * @returns TaskDef OK
251
+ * @throws ApiError
252
+ */
253
+ getTaskDef(tasktype, metadata = false) {
254
+ return this.httpRequest.request({
255
+ method: "GET",
256
+ url: "/metadata/taskdefs/{tasktype}",
257
+ path: {
258
+ "tasktype": tasktype
259
+ },
260
+ query: {
261
+ "metadata": metadata
262
+ }
263
+ });
264
+ }
265
+ /**
266
+ * Remove a task definition
267
+ * @param tasktype
268
+ * @returns any OK
269
+ * @throws ApiError
270
+ */
271
+ unregisterTaskDef(tasktype) {
272
+ return this.httpRequest.request({
273
+ method: "DELETE",
274
+ url: "/metadata/taskdefs/{tasktype}",
275
+ path: {
276
+ "tasktype": tasktype
277
+ }
278
+ });
279
+ }
280
+ /**
281
+ * Retrieves all workflow definition along with blueprint
282
+ * @param access
283
+ * @param metadata
284
+ * @param tagKey
285
+ * @param tagValue
286
+ * @returns WorkflowDef OK
287
+ * @throws ApiError
288
+ */
289
+ getAllWorkflows(access = "READ", metadata = false, tagKey, tagValue) {
290
+ return this.httpRequest.request({
291
+ method: "GET",
292
+ url: "/metadata/workflow",
293
+ query: {
294
+ "access": access,
295
+ "metadata": metadata,
296
+ "tagKey": tagKey,
297
+ "tagValue": tagValue
298
+ }
299
+ });
300
+ }
301
+ /**
302
+ * Create or update workflow definition(s)
303
+ * @param requestBody
304
+ * @param overwrite
305
+ * @returns any OK
306
+ * @throws ApiError
307
+ */
308
+ update(requestBody, overwrite = true) {
309
+ return this.httpRequest.request({
310
+ method: "PUT",
311
+ url: "/metadata/workflow",
312
+ query: {
313
+ "overwrite": overwrite
314
+ },
315
+ body: requestBody,
316
+ mediaType: "application/json"
317
+ });
318
+ }
319
+ /**
320
+ * Create a new workflow definition
321
+ * @param requestBody
322
+ * @param overwrite
323
+ * @returns any OK
324
+ * @throws ApiError
325
+ */
326
+ create(requestBody, overwrite = false) {
327
+ return this.httpRequest.request({
328
+ method: "POST",
329
+ url: "/metadata/workflow",
330
+ query: {
331
+ "overwrite": overwrite
332
+ },
333
+ body: requestBody,
334
+ mediaType: "application/json"
335
+ });
336
+ }
337
+ /**
338
+ * Gets all task definition
339
+ * @param access
340
+ * @param metadata
341
+ * @param tagKey
342
+ * @param tagValue
343
+ * @returns TaskDef OK
344
+ * @throws ApiError
345
+ */
346
+ getTaskDefs(access = "READ", metadata = false, tagKey, tagValue) {
347
+ return this.httpRequest.request({
348
+ method: "GET",
349
+ url: "/metadata/taskdefs",
350
+ query: {
351
+ "access": access,
352
+ "metadata": metadata,
353
+ "tagKey": tagKey,
354
+ "tagValue": tagValue
355
+ }
356
+ });
357
+ }
358
+ /**
359
+ * Update an existing task
360
+ * @param requestBody
361
+ * @returns any OK
362
+ * @throws ApiError
363
+ */
364
+ updateTaskDef(requestBody) {
365
+ return this.httpRequest.request({
366
+ method: "PUT",
367
+ url: "/metadata/taskdefs",
368
+ body: requestBody,
369
+ mediaType: "application/json"
370
+ });
371
+ }
372
+ /**
373
+ * Create or update task definition(s)
374
+ * @param requestBody
375
+ * @returns any OK
376
+ * @throws ApiError
377
+ */
378
+ registerTaskDef(requestBody) {
379
+ return this.httpRequest.request({
380
+ method: "POST",
381
+ url: "/metadata/taskdefs",
382
+ body: requestBody,
383
+ mediaType: "application/json"
384
+ });
385
+ }
386
+ /**
387
+ * Removes workflow definition. It does not remove workflows associated with the definition.
388
+ * @param name
389
+ * @param version
390
+ * @returns any OK
391
+ * @throws ApiError
392
+ */
393
+ unregisterWorkflowDef(name, version) {
394
+ return this.httpRequest.request({
395
+ method: "DELETE",
396
+ url: "/metadata/workflow/{name}/{version}",
397
+ path: {
398
+ "name": name,
399
+ "version": version
400
+ }
401
+ });
402
+ }
403
+ /**
404
+ * Retrieves workflow definition along with blueprint
405
+ * @param name
406
+ * @param version
407
+ * @param metadata
408
+ * @returns WorkflowDef OK
409
+ * @throws ApiError
410
+ */
411
+ get(name, version, metadata = false) {
412
+ return this.httpRequest.request({
413
+ method: "GET",
414
+ url: "/metadata/workflow/{name}",
415
+ path: {
416
+ "name": name
417
+ },
418
+ query: {
419
+ "version": version,
420
+ "metadata": metadata
421
+ }
422
+ });
423
+ }
424
+ };
425
+
426
+ // src/common/open-api/services/SchedulerResourceService.ts
427
+ var SchedulerResourceService = class {
428
+ constructor(httpRequest) {
429
+ this.httpRequest = httpRequest;
430
+ }
431
+ /**
432
+ * Get an existing workflow schedule by name
433
+ * @param name
434
+ * @returns any OK
435
+ * @throws ApiError
436
+ */
437
+ getSchedule(name) {
438
+ return this.httpRequest.request({
439
+ method: "GET",
440
+ url: "/scheduler/schedules/{name}",
441
+ path: {
442
+ "name": name
443
+ }
444
+ });
445
+ }
446
+ /**
447
+ * Deletes an existing workflow schedule by name
448
+ * @param name
449
+ * @returns any OK
450
+ * @throws ApiError
451
+ */
452
+ deleteSchedule(name) {
453
+ return this.httpRequest.request({
454
+ method: "DELETE",
455
+ url: "/scheduler/schedules/{name}",
456
+ path: {
457
+ "name": name
458
+ }
459
+ });
460
+ }
461
+ /**
462
+ * Get list of the next x (default 3, max 5) execution times for a scheduler
463
+ * @param cronExpression
464
+ * @param scheduleStartTime
465
+ * @param scheduleEndTime
466
+ * @param limit
467
+ * @returns number OK
468
+ * @throws ApiError
469
+ */
470
+ getNextFewSchedules(cronExpression, scheduleStartTime, scheduleEndTime, limit = 3) {
471
+ return this.httpRequest.request({
472
+ method: "GET",
473
+ url: "/scheduler/nextFewSchedules",
474
+ query: {
475
+ "cronExpression": cronExpression,
476
+ "scheduleStartTime": scheduleStartTime,
477
+ "scheduleEndTime": scheduleEndTime,
478
+ "limit": limit
479
+ }
480
+ });
481
+ }
482
+ /**
483
+ * Pauses an existing schedule by name
484
+ * @param name
485
+ * @returns any OK
486
+ * @throws ApiError
487
+ */
488
+ pauseSchedule(name) {
489
+ return this.httpRequest.request({
490
+ method: "GET",
491
+ url: "/scheduler/schedules/{name}/pause",
492
+ path: {
493
+ "name": name
494
+ }
495
+ });
496
+ }
497
+ /**
498
+ * Pause all scheduling in a single conductor server instance (for debugging only)
499
+ * @returns any OK
500
+ * @throws ApiError
501
+ */
502
+ pauseAllSchedules() {
503
+ return this.httpRequest.request({
504
+ method: "GET",
505
+ url: "/scheduler/admin/pause"
506
+ });
507
+ }
508
+ /**
509
+ * Resume a paused schedule by name
510
+ * @param name
511
+ * @returns any OK
512
+ * @throws ApiError
513
+ */
514
+ resumeSchedule(name) {
515
+ return this.httpRequest.request({
516
+ method: "GET",
517
+ url: "/scheduler/schedules/{name}/resume",
518
+ path: {
519
+ "name": name
520
+ }
521
+ });
522
+ }
523
+ /**
524
+ * Requeue all execution records
525
+ * @returns any OK
526
+ * @throws ApiError
527
+ */
528
+ requeueAllExecutionRecords() {
529
+ return this.httpRequest.request({
530
+ method: "GET",
531
+ url: "/scheduler/admin/requeue"
532
+ });
533
+ }
534
+ /**
535
+ * Resume all scheduling
536
+ * @returns any OK
537
+ * @throws ApiError
538
+ */
539
+ resumeAllSchedules() {
540
+ return this.httpRequest.request({
541
+ method: "GET",
542
+ url: "/scheduler/admin/resume"
543
+ });
544
+ }
545
+ /**
546
+ * Get all existing workflow schedules and optionally filter by workflow name
547
+ * @param workflowName
548
+ * @returns WorkflowSchedule OK
549
+ * @throws ApiError
550
+ */
551
+ getAllSchedules(workflowName) {
552
+ return this.httpRequest.request({
553
+ method: "GET",
554
+ url: "/scheduler/schedules",
555
+ query: {
556
+ "workflowName": workflowName
557
+ }
558
+ });
559
+ }
560
+ /**
561
+ * Create or update a schedule for a specified workflow with a corresponding start workflow request
562
+ * @param requestBody
563
+ * @returns any OK
564
+ * @throws ApiError
565
+ */
566
+ saveSchedule(requestBody) {
567
+ return this.httpRequest.request({
568
+ method: "POST",
569
+ url: "/scheduler/schedules",
570
+ body: requestBody,
571
+ mediaType: "application/json"
572
+ });
573
+ }
574
+ /**
575
+ * Test timeout - do not use in production
576
+ * @returns any OK
577
+ * @throws ApiError
578
+ */
579
+ testTimeout() {
580
+ return this.httpRequest.request({
581
+ method: "GET",
582
+ url: "/scheduler/test/timeout"
583
+ });
584
+ }
585
+ /**
586
+ * Search for workflows based on payload and other parameters
587
+ * use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC.
588
+ * @param start
589
+ * @param size
590
+ * @param sort
591
+ * @param freeText
592
+ * @param query
593
+ * @returns SearchResultWorkflowScheduleExecutionModel OK
594
+ * @throws ApiError
595
+ */
596
+ searchV21(start, size = 100, sort, freeText = "*", query) {
597
+ return this.httpRequest.request({
598
+ method: "GET",
599
+ url: "/scheduler/search/executions",
600
+ query: {
601
+ "start": start,
602
+ "size": size,
603
+ "sort": sort,
604
+ "freeText": freeText,
605
+ "query": query
606
+ }
607
+ });
608
+ }
609
+ };
610
+
611
+ // src/common/open-api/services/TaskResourceService.ts
612
+ var TaskResourceService = class {
613
+ constructor(httpRequest) {
614
+ this.httpRequest = httpRequest;
615
+ }
616
+ /**
617
+ * Poll for a task of a certain type
618
+ * @param tasktype
619
+ * @param workerid
620
+ * @param domain
621
+ * @returns Task OK
622
+ * @throws ApiError
623
+ */
624
+ poll(tasktype, workerid, domain) {
625
+ return this.httpRequest.request({
626
+ method: "GET",
627
+ url: "/tasks/poll/{tasktype}",
628
+ path: {
629
+ "tasktype": tasktype
630
+ },
631
+ query: {
632
+ "workerid": workerid,
633
+ "domain": domain
634
+ }
635
+ });
636
+ }
637
+ /**
638
+ * Get the details about each queue
639
+ * @returns number OK
640
+ * @throws ApiError
641
+ */
642
+ allVerbose() {
643
+ return this.httpRequest.request({
644
+ method: "GET",
645
+ url: "/tasks/queue/all/verbose"
646
+ });
647
+ }
648
+ /**
649
+ * Update a task By Ref Name
650
+ * @param workflowId
651
+ * @param taskRefName
652
+ * @param status
653
+ * @param requestBody
654
+ * @returns string OK
655
+ * @throws ApiError
656
+ */
657
+ updateTask(workflowId, taskRefName, status, requestBody) {
658
+ return this.httpRequest.request({
659
+ method: "POST",
660
+ url: "/tasks/{workflowId}/{taskRefName}/{status}",
661
+ path: {
662
+ "workflowId": workflowId,
663
+ "taskRefName": taskRefName,
664
+ "status": status
665
+ },
666
+ body: requestBody,
667
+ mediaType: "application/json"
668
+ });
669
+ }
670
+ /**
671
+ * Get task by Id
672
+ * @param taskId
673
+ * @returns Task OK
674
+ * @throws ApiError
675
+ */
676
+ getTask(taskId) {
677
+ return this.httpRequest.request({
678
+ method: "GET",
679
+ url: "/tasks/{taskId}",
680
+ path: {
681
+ "taskId": taskId
682
+ }
683
+ });
684
+ }
685
+ /**
686
+ * Get the details about each queue
687
+ * @returns number OK
688
+ * @throws ApiError
689
+ */
690
+ all() {
691
+ return this.httpRequest.request({
692
+ method: "GET",
693
+ url: "/tasks/queue/all"
694
+ });
695
+ }
696
+ /**
697
+ * Requeue pending tasks
698
+ * @param taskType
699
+ * @returns string OK
700
+ * @throws ApiError
701
+ */
702
+ requeuePendingTask(taskType) {
703
+ return this.httpRequest.request({
704
+ method: "POST",
705
+ url: "/tasks/queue/requeue/{taskType}",
706
+ path: {
707
+ "taskType": taskType
708
+ }
709
+ });
710
+ }
711
+ /**
712
+ * Search for tasks based in payload and other parameters
713
+ * use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
714
+ * @param start
715
+ * @param size
716
+ * @param sort
717
+ * @param freeText
718
+ * @param query
719
+ * @returns SearchResultTaskSummary OK
720
+ * @throws ApiError
721
+ */
722
+ search(start, size = 100, sort, freeText = "*", query) {
723
+ return this.httpRequest.request({
724
+ method: "GET",
725
+ url: "/tasks/search",
726
+ query: {
727
+ "start": start,
728
+ "size": size,
729
+ "sort": sort,
730
+ "freeText": freeText,
731
+ "query": query
732
+ }
733
+ });
734
+ }
735
+ /**
736
+ * Search for tasks based in payload and other parameters
737
+ * use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
738
+ * @param start
739
+ * @param size
740
+ * @param sort
741
+ * @param freeText
742
+ * @param query
743
+ * @returns SearchResultTask OK
744
+ * @throws ApiError
745
+ */
746
+ searchV22(start, size = 100, sort, freeText = "*", query) {
747
+ return this.httpRequest.request({
748
+ method: "GET",
749
+ url: "/tasks/search-v2",
750
+ query: {
751
+ "start": start,
752
+ "size": size,
753
+ "sort": sort,
754
+ "freeText": freeText,
755
+ "query": query
756
+ }
757
+ });
758
+ }
759
+ /**
760
+ * Get the last poll data for a given task type
761
+ * @param taskType
762
+ * @returns PollData OK
763
+ * @throws ApiError
764
+ */
765
+ getPollData(taskType) {
766
+ return this.httpRequest.request({
767
+ method: "GET",
768
+ url: "/tasks/queue/polldata",
769
+ query: {
770
+ "taskType": taskType
771
+ }
772
+ });
773
+ }
774
+ /**
775
+ * Get Task Execution Logs
776
+ * @param taskId
777
+ * @returns TaskExecLog OK
778
+ * @throws ApiError
779
+ */
780
+ getTaskLogs(taskId) {
781
+ return this.httpRequest.request({
782
+ method: "GET",
783
+ url: "/tasks/{taskId}/log",
784
+ path: {
785
+ "taskId": taskId
786
+ }
787
+ });
788
+ }
789
+ /**
790
+ * Log Task Execution Details
791
+ * @param taskId
792
+ * @param requestBody
793
+ * @returns any OK
794
+ * @throws ApiError
795
+ */
796
+ log(taskId, requestBody) {
797
+ return this.httpRequest.request({
798
+ method: "POST",
799
+ url: "/tasks/{taskId}/log",
800
+ path: {
801
+ "taskId": taskId
802
+ },
803
+ body: requestBody,
804
+ mediaType: "application/json"
805
+ });
806
+ }
807
+ /**
808
+ * Get the last poll data for all task types
809
+ * @returns PollData OK
810
+ * @throws ApiError
811
+ */
812
+ getAllPollData() {
813
+ return this.httpRequest.request({
814
+ method: "GET",
815
+ url: "/tasks/queue/polldata/all"
816
+ });
817
+ }
818
+ /**
819
+ * Batch poll for a task of a certain type
820
+ * @param tasktype
821
+ * @param workerid
822
+ * @param domain
823
+ * @param count
824
+ * @param timeout
825
+ * @returns Task OK
826
+ * @throws ApiError
827
+ */
828
+ batchPoll(tasktype, workerid, domain, count = 1, timeout = 100) {
829
+ return this.httpRequest.request({
830
+ method: "GET",
831
+ url: "/tasks/poll/batch/{tasktype}",
832
+ path: {
833
+ "tasktype": tasktype
834
+ },
835
+ query: {
836
+ "workerid": workerid,
837
+ "domain": domain,
838
+ "count": count,
839
+ "timeout": timeout
840
+ }
841
+ });
842
+ }
843
+ /**
844
+ * Update a task
845
+ * @param requestBody
846
+ * @returns string OK
847
+ * @throws ApiError
848
+ */
849
+ updateTask1(requestBody) {
850
+ return this.httpRequest.request({
851
+ method: "POST",
852
+ url: "/tasks",
853
+ body: requestBody,
854
+ mediaType: "application/json"
855
+ });
856
+ }
857
+ /**
858
+ * Get Task type queue sizes
859
+ * @param taskType
860
+ * @returns number OK
861
+ * @throws ApiError
862
+ */
863
+ size1(taskType) {
864
+ return this.httpRequest.request({
865
+ method: "GET",
866
+ url: "/tasks/queue/sizes",
867
+ query: {
868
+ "taskType": taskType
869
+ }
870
+ });
871
+ }
872
+ /**
873
+ * Get the external uri where the task payload is to be stored
874
+ * @param path
875
+ * @param operation
876
+ * @param payloadType
877
+ * @returns ExternalStorageLocation OK
878
+ * @throws ApiError
879
+ */
880
+ getExternalStorageLocation1(path, operation, payloadType) {
881
+ return this.httpRequest.request({
882
+ method: "GET",
883
+ url: "/tasks/externalstoragelocation",
884
+ query: {
885
+ "path": path,
886
+ "operation": operation,
887
+ "payloadType": payloadType
888
+ }
889
+ });
890
+ }
891
+ };
892
+
893
+ // src/common/open-api/services/TokenResourceService.ts
894
+ var TokenResourceService = class {
895
+ constructor(httpRequest) {
896
+ this.httpRequest = httpRequest;
897
+ }
898
+ /**
899
+ * Generate JWT with the given access key
900
+ * @param requestBody
901
+ * @returns Response OK
902
+ * @throws ApiError
903
+ */
904
+ generateToken(requestBody) {
905
+ return this.httpRequest.request({
906
+ method: "POST",
907
+ url: "/token",
908
+ body: requestBody,
909
+ mediaType: "application/json"
910
+ });
911
+ }
912
+ /**
913
+ * Get the user info from the token
914
+ * @returns any OK
915
+ * @throws ApiError
916
+ */
917
+ getUserInfo() {
918
+ return this.httpRequest.request({
919
+ method: "GET",
920
+ url: "/token/userInfo"
921
+ });
922
+ }
923
+ };
924
+
925
+ // src/common/open-api/services/WorkflowBulkResourceService.ts
926
+ var WorkflowBulkResourceService = class {
927
+ constructor(httpRequest) {
928
+ this.httpRequest = httpRequest;
929
+ }
930
+ /**
931
+ * Retry the last failed task for each workflow from the list
932
+ * @param requestBody
933
+ * @returns BulkResponse OK
934
+ * @throws ApiError
935
+ */
936
+ retry(requestBody) {
937
+ return this.httpRequest.request({
938
+ method: "POST",
939
+ url: "/workflow/bulk/retry",
940
+ body: requestBody,
941
+ mediaType: "application/json"
942
+ });
943
+ }
944
+ /**
945
+ * Restart the list of completed workflow
946
+ * @param requestBody
947
+ * @param useLatestDefinitions
948
+ * @returns BulkResponse OK
949
+ * @throws ApiError
950
+ */
951
+ restart(requestBody, useLatestDefinitions = false) {
952
+ return this.httpRequest.request({
953
+ method: "POST",
954
+ url: "/workflow/bulk/restart",
955
+ query: {
956
+ "useLatestDefinitions": useLatestDefinitions
957
+ },
958
+ body: requestBody,
959
+ mediaType: "application/json"
960
+ });
961
+ }
962
+ /**
963
+ * Terminate workflows execution
964
+ * @param requestBody
965
+ * @param reason
966
+ * @returns BulkResponse OK
967
+ * @throws ApiError
968
+ */
969
+ terminate(requestBody, reason) {
970
+ return this.httpRequest.request({
971
+ method: "POST",
972
+ url: "/workflow/bulk/terminate",
973
+ query: {
974
+ "reason": reason
975
+ },
976
+ body: requestBody,
977
+ mediaType: "application/json"
978
+ });
979
+ }
980
+ /**
981
+ * Resume the list of workflows
982
+ * @param requestBody
983
+ * @returns BulkResponse OK
984
+ * @throws ApiError
985
+ */
986
+ resumeWorkflow(requestBody) {
987
+ return this.httpRequest.request({
988
+ method: "PUT",
989
+ url: "/workflow/bulk/resume",
990
+ body: requestBody,
991
+ mediaType: "application/json"
992
+ });
993
+ }
994
+ /**
995
+ * Pause the list of workflows
996
+ * @param requestBody
997
+ * @returns BulkResponse OK
998
+ * @throws ApiError
999
+ */
1000
+ pauseWorkflow1(requestBody) {
1001
+ return this.httpRequest.request({
1002
+ method: "PUT",
1003
+ url: "/workflow/bulk/pause",
1004
+ body: requestBody,
1005
+ mediaType: "application/json"
1006
+ });
1007
+ }
1008
+ };
1009
+
1010
+ // src/common/open-api/services/WorkflowResourceService.ts
1011
+ var WorkflowResourceService = class {
1012
+ constructor(httpRequest) {
1013
+ this.httpRequest = httpRequest;
1014
+ }
1015
+ /**
1016
+ * Retrieve all the running workflows
1017
+ * @param name
1018
+ * @param version
1019
+ * @param startTime
1020
+ * @param endTime
1021
+ * @returns string OK
1022
+ * @throws ApiError
1023
+ */
1024
+ getRunningWorkflow(name, version = 1, startTime, endTime) {
1025
+ return this.httpRequest.request({
1026
+ method: "GET",
1027
+ url: "/workflow/running/{name}",
1028
+ path: {
1029
+ "name": name
1030
+ },
1031
+ query: {
1032
+ "version": version,
1033
+ "startTime": startTime,
1034
+ "endTime": endTime
1035
+ }
1036
+ });
1037
+ }
1038
+ /**
1039
+ * Execute a workflow synchronously
1040
+ * @param body
1041
+ * @param name
1042
+ * @param version
1043
+ * @param requestId
1044
+ * @param waitUntilTaskRef
1045
+ * @param callback
1046
+ * @returns workflowRun
1047
+ * @throws ApiError
1048
+ */
1049
+ executeWorkflow(body, name, version, requestId, waitUntilTaskRef) {
1050
+ return this.httpRequest.request({
1051
+ method: "POST",
1052
+ url: "/workflow/execute/{name}/{version}",
1053
+ path: {
1054
+ "name": name,
1055
+ "version": version
1056
+ },
1057
+ query: {
1058
+ "requestId": requestId,
1059
+ "waitUntilTaskRef": waitUntilTaskRef
1060
+ },
1061
+ body,
1062
+ mediaType: "application/json"
1063
+ });
1064
+ }
1065
+ /**
1066
+ * Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain
1067
+ * @param requestBody
1068
+ * @returns string OK
1069
+ * @throws ApiError
1070
+ */
1071
+ startWorkflow(requestBody) {
1072
+ return this.httpRequest.request({
1073
+ method: "POST",
1074
+ url: "/workflow",
1075
+ body: requestBody,
1076
+ mediaType: "application/json"
1077
+ });
1078
+ }
1079
+ /**
1080
+ * Starts the decision task for a workflow
1081
+ * @param workflowId
1082
+ * @returns any OK
1083
+ * @throws ApiError
1084
+ */
1085
+ decide(workflowId) {
1086
+ return this.httpRequest.request({
1087
+ method: "PUT",
1088
+ url: "/workflow/decide/{workflowId}",
1089
+ path: {
1090
+ "workflowId": workflowId
1091
+ }
1092
+ });
1093
+ }
1094
+ /**
1095
+ * Reruns the workflow from a specific task
1096
+ * @param workflowId
1097
+ * @param requestBody
1098
+ * @returns string OK
1099
+ * @throws ApiError
1100
+ */
1101
+ rerun(workflowId, requestBody) {
1102
+ return this.httpRequest.request({
1103
+ method: "POST",
1104
+ url: "/workflow/{workflowId}/rerun",
1105
+ path: {
1106
+ "workflowId": workflowId
1107
+ },
1108
+ body: requestBody,
1109
+ mediaType: "application/json"
1110
+ });
1111
+ }
1112
+ /**
1113
+ * Search for workflows based on payload and other parameters
1114
+ * use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC.
1115
+ * @param start
1116
+ * @param size
1117
+ * @param sort
1118
+ * @param freeText
1119
+ * @param query
1120
+ * @returns SearchResultWorkflow OK
1121
+ * @throws ApiError
1122
+ */
1123
+ searchV21(start, size = 100, sort, freeText = "*", query) {
1124
+ return this.httpRequest.request({
1125
+ method: "GET",
1126
+ url: "/workflow/search-v2",
1127
+ query: {
1128
+ "start": start,
1129
+ "size": size,
1130
+ "sort": sort,
1131
+ "freeText": freeText,
1132
+ "query": query
1133
+ }
1134
+ });
1135
+ }
1136
+ /**
1137
+ * Pauses the workflow
1138
+ * @param workflowId
1139
+ * @returns any OK
1140
+ * @throws ApiError
1141
+ */
1142
+ pauseWorkflow(workflowId) {
1143
+ return this.httpRequest.request({
1144
+ method: "PUT",
1145
+ url: "/workflow/{workflowId}/pause",
1146
+ path: {
1147
+ "workflowId": workflowId
1148
+ }
1149
+ });
1150
+ }
1151
+ /**
1152
+ * Skips a given task from a current running workflow
1153
+ * @param workflowId
1154
+ * @param taskReferenceName
1155
+ * @param requestBody
1156
+ * @returns any OK
1157
+ * @throws ApiError
1158
+ */
1159
+ skipTaskFromWorkflow(workflowId, taskReferenceName, requestBody) {
1160
+ return this.httpRequest.request({
1161
+ method: "PUT",
1162
+ url: "/workflow/{workflowId}/skiptask/{taskReferenceName}",
1163
+ path: {
1164
+ "workflowId": workflowId,
1165
+ "taskReferenceName": taskReferenceName
1166
+ },
1167
+ body: requestBody,
1168
+ mediaType: "application/json"
1169
+ });
1170
+ }
1171
+ /**
1172
+ * Lists workflows for the given correlation id list
1173
+ * @param name
1174
+ * @param requestBody
1175
+ * @param includeClosed
1176
+ * @param includeTasks
1177
+ * @returns Workflow OK
1178
+ * @throws ApiError
1179
+ */
1180
+ getWorkflows(name, requestBody, includeClosed = false, includeTasks = false) {
1181
+ return this.httpRequest.request({
1182
+ method: "POST",
1183
+ url: "/workflow/{name}/correlated",
1184
+ path: {
1185
+ "name": name
1186
+ },
1187
+ query: {
1188
+ "includeClosed": includeClosed,
1189
+ "includeTasks": includeTasks
1190
+ },
1191
+ body: requestBody,
1192
+ mediaType: "application/json"
1193
+ });
1194
+ }
1195
+ /**
1196
+ * Gets the workflow by workflow id
1197
+ * @param workflowId
1198
+ * @param includeOutput
1199
+ * @param includeVariables
1200
+ * @returns WorkflowStatus OK
1201
+ * @throws ApiError
1202
+ */
1203
+ getWorkflowStatusSummary(workflowId, includeOutput = false, includeVariables = false) {
1204
+ return this.httpRequest.request({
1205
+ method: "GET",
1206
+ url: "/workflow/{workflowId}/status",
1207
+ path: {
1208
+ "workflowId": workflowId
1209
+ },
1210
+ query: {
1211
+ "includeOutput": includeOutput,
1212
+ "includeVariables": includeVariables
1213
+ }
1214
+ });
1215
+ }
1216
+ /**
1217
+ * Lists workflows for the given correlation id
1218
+ * @param name
1219
+ * @param correlationId
1220
+ * @param includeClosed
1221
+ * @param includeTasks
1222
+ * @returns Workflow OK
1223
+ * @throws ApiError
1224
+ */
1225
+ getWorkflows1(name, correlationId, includeClosed = false, includeTasks = false) {
1226
+ return this.httpRequest.request({
1227
+ method: "GET",
1228
+ url: "/workflow/{name}/correlated/{correlationId}",
1229
+ path: {
1230
+ "name": name,
1231
+ "correlationId": correlationId
1232
+ },
1233
+ query: {
1234
+ "includeClosed": includeClosed,
1235
+ "includeTasks": includeTasks
1236
+ }
1237
+ });
1238
+ }
1239
+ /**
1240
+ * Retries the last failed task
1241
+ * @param workflowId
1242
+ * @param resumeSubworkflowTasks
1243
+ * @returns void
1244
+ * @throws ApiError
1245
+ */
1246
+ retry1(workflowId, resumeSubworkflowTasks = false) {
1247
+ return this.httpRequest.request({
1248
+ method: "POST",
1249
+ url: "/workflow/{workflowId}/retry",
1250
+ path: {
1251
+ "workflowId": workflowId
1252
+ },
1253
+ query: {
1254
+ "resumeSubworkflowTasks": resumeSubworkflowTasks
1255
+ }
1256
+ });
1257
+ }
1258
+ /**
1259
+ * Gets the workflow by workflow id
1260
+ * @param workflowId
1261
+ * @param includeTasks
1262
+ * @returns Workflow OK
1263
+ * @throws ApiError
1264
+ */
1265
+ getExecutionStatus(workflowId, includeTasks = true) {
1266
+ return this.httpRequest.request({
1267
+ method: "GET",
1268
+ url: "/workflow/{workflowId}",
1269
+ path: {
1270
+ "workflowId": workflowId
1271
+ },
1272
+ query: {
1273
+ "includeTasks": includeTasks
1274
+ }
1275
+ });
1276
+ }
1277
+ /**
1278
+ * Terminate workflow execution
1279
+ * @param workflowId
1280
+ * @param reason
1281
+ * @returns any OK
1282
+ * @throws ApiError
1283
+ */
1284
+ terminate1(workflowId, reason) {
1285
+ return this.httpRequest.request({
1286
+ method: "DELETE",
1287
+ url: "/workflow/{workflowId}",
1288
+ path: {
1289
+ "workflowId": workflowId
1290
+ },
1291
+ query: {
1292
+ "reason": reason
1293
+ }
1294
+ });
1295
+ }
1296
+ /**
1297
+ * Resumes the workflow
1298
+ * @param workflowId
1299
+ * @returns any OK
1300
+ * @throws ApiError
1301
+ */
1302
+ resumeWorkflow(workflowId) {
1303
+ return this.httpRequest.request({
1304
+ method: "PUT",
1305
+ url: "/workflow/{workflowId}/resume",
1306
+ path: {
1307
+ "workflowId": workflowId
1308
+ }
1309
+ });
1310
+ }
1311
+ /**
1312
+ * Removes the workflow from the system
1313
+ * @param workflowId
1314
+ * @param archiveWorkflow
1315
+ * @returns any OK
1316
+ * @throws ApiError
1317
+ */
1318
+ delete(workflowId, archiveWorkflow = true) {
1319
+ return this.httpRequest.request({
1320
+ method: "DELETE",
1321
+ url: "/workflow/{workflowId}/remove",
1322
+ path: {
1323
+ "workflowId": workflowId
1324
+ },
1325
+ query: {
1326
+ "archiveWorkflow": archiveWorkflow
1327
+ }
1328
+ });
1329
+ }
1330
+ /**
1331
+ * Search for workflows based on task parameters
1332
+ * use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
1333
+ * @param start
1334
+ * @param size
1335
+ * @param sort
1336
+ * @param freeText
1337
+ * @param query
1338
+ * @returns SearchResultWorkflowSummary OK
1339
+ * @throws ApiError
1340
+ */
1341
+ searchWorkflowsByTasks(start, size = 100, sort, freeText = "*", query) {
1342
+ return this.httpRequest.request({
1343
+ method: "GET",
1344
+ url: "/workflow/search-by-tasks",
1345
+ query: {
1346
+ "start": start,
1347
+ "size": size,
1348
+ "sort": sort,
1349
+ "freeText": freeText,
1350
+ "query": query
1351
+ }
1352
+ });
1353
+ }
1354
+ /**
1355
+ * Get the uri and path of the external storage where the workflow payload is to be stored
1356
+ * @param path
1357
+ * @param operation
1358
+ * @param payloadType
1359
+ * @returns ExternalStorageLocation OK
1360
+ * @throws ApiError
1361
+ */
1362
+ getExternalStorageLocation(path, operation, payloadType) {
1363
+ return this.httpRequest.request({
1364
+ method: "GET",
1365
+ url: "/workflow/externalstoragelocation",
1366
+ query: {
1367
+ "path": path,
1368
+ "operation": operation,
1369
+ "payloadType": payloadType
1370
+ }
1371
+ });
1372
+ }
1373
+ /**
1374
+ * Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking
1375
+ * @param name
1376
+ * @param requestBody
1377
+ * @param version
1378
+ * @param correlationId
1379
+ * @param priority
1380
+ * @returns string OK
1381
+ * @throws ApiError
1382
+ */
1383
+ startWorkflow1(name, requestBody, version, correlationId, priority) {
1384
+ return this.httpRequest.request({
1385
+ method: "POST",
1386
+ url: "/workflow/{name}",
1387
+ path: {
1388
+ "name": name
1389
+ },
1390
+ query: {
1391
+ "version": version,
1392
+ "correlationId": correlationId,
1393
+ "priority": priority
1394
+ },
1395
+ body: requestBody,
1396
+ mediaType: "application/json"
1397
+ });
1398
+ }
1399
+ /**
1400
+ * Restarts a completed workflow
1401
+ * @param workflowId
1402
+ * @param useLatestDefinitions
1403
+ * @returns void
1404
+ * @throws ApiError
1405
+ */
1406
+ restart1(workflowId, useLatestDefinitions = false) {
1407
+ return this.httpRequest.request({
1408
+ method: "POST",
1409
+ url: "/workflow/{workflowId}/restart",
1410
+ path: {
1411
+ "workflowId": workflowId
1412
+ },
1413
+ query: {
1414
+ "useLatestDefinitions": useLatestDefinitions
1415
+ }
1416
+ });
1417
+ }
1418
+ /**
1419
+ * Search for workflows based on payload and other parameters
1420
+ * use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC.
1421
+ * @param queryId
1422
+ * @param start
1423
+ * @param size
1424
+ * @param sort
1425
+ * @param freeText
1426
+ * @param query
1427
+ * @param skipCache
1428
+ * @returns ScrollableSearchResultWorkflowSummary OK
1429
+ * @throws ApiError
1430
+ */
1431
+ search1(queryId, start, size = 100, sort, freeText = "*", query, skipCache = false) {
1432
+ return this.httpRequest.request({
1433
+ method: "GET",
1434
+ url: "/workflow/search",
1435
+ query: {
1436
+ "queryId": queryId,
1437
+ "start": start,
1438
+ "size": size,
1439
+ "sort": sort,
1440
+ "freeText": freeText,
1441
+ "query": query,
1442
+ "skipCache": skipCache
1443
+ }
1444
+ });
1445
+ }
1446
+ /**
1447
+ * Search for workflows based on task parameters
1448
+ * use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
1449
+ * @param start
1450
+ * @param size
1451
+ * @param sort
1452
+ * @param freeText
1453
+ * @param query
1454
+ * @returns SearchResultWorkflow OK
1455
+ * @throws ApiError
1456
+ */
1457
+ searchWorkflowsByTasksV2(start, size = 100, sort, freeText = "*", query) {
1458
+ return this.httpRequest.request({
1459
+ method: "GET",
1460
+ url: "/workflow/search-by-tasks-v2",
1461
+ query: {
1462
+ "start": start,
1463
+ "size": size,
1464
+ "sort": sort,
1465
+ "freeText": freeText,
1466
+ "query": query
1467
+ }
1468
+ });
1469
+ }
1470
+ /**
1471
+ * Resets callback times of all non-terminal SIMPLE tasks to 0
1472
+ * @param workflowId
1473
+ * @returns void
1474
+ * @throws ApiError
1475
+ */
1476
+ resetWorkflow(workflowId) {
1477
+ return this.httpRequest.request({
1478
+ method: "POST",
1479
+ url: "/workflow/{workflowId}/resetcallbacks",
1480
+ path: {
1481
+ "workflowId": workflowId
1482
+ }
1483
+ });
1484
+ }
1485
+ };
1486
+
1487
+ // src/common/open-api/core/ApiError.ts
1488
+ var ApiError = class extends Error {
1489
+ constructor(request2, response, message) {
1490
+ super(message);
1491
+ this.name = "ApiError";
1492
+ this.url = response.url;
1493
+ this.status = response.status;
1494
+ this.statusText = response.statusText;
1495
+ this.body = response.body;
1496
+ this.request = request2;
1497
+ }
1498
+ };
1499
+
1500
+ // src/common/open-api/core/CancelablePromise.ts
1501
+ var CancelError = class extends Error {
1502
+ constructor(message) {
1503
+ super(message);
1504
+ this.name = "CancelError";
1505
+ }
1506
+ get isCancelled() {
1507
+ return true;
1508
+ }
1509
+ };
1510
+ var CancelablePromise = class {
1511
+ static {
1512
+ Symbol.toStringTag;
1513
+ }
1514
+ constructor(executor) {
1515
+ this._isResolved = false;
1516
+ this._isRejected = false;
1517
+ this._isCancelled = false;
1518
+ this._cancelHandlers = [];
1519
+ this._promise = new Promise((resolve2, reject) => {
1520
+ this._resolve = resolve2;
1521
+ this._reject = reject;
1522
+ const onResolve = (value) => {
1523
+ if (this._isResolved || this._isRejected || this._isCancelled) {
1524
+ return;
1525
+ }
1526
+ this._isResolved = true;
1527
+ this._resolve?.(value);
1528
+ };
1529
+ const onReject = (reason) => {
1530
+ if (this._isResolved || this._isRejected || this._isCancelled) {
1531
+ return;
1532
+ }
1533
+ this._isRejected = true;
1534
+ this._reject?.(reason);
1535
+ };
1536
+ const onCancel = (cancelHandler) => {
1537
+ if (this._isResolved || this._isRejected || this._isCancelled) {
1538
+ return;
1539
+ }
1540
+ this._cancelHandlers.push(cancelHandler);
1541
+ };
1542
+ Object.defineProperty(onCancel, "isResolved", {
1543
+ get: () => this._isResolved
1544
+ });
1545
+ Object.defineProperty(onCancel, "isRejected", {
1546
+ get: () => this._isRejected
1547
+ });
1548
+ Object.defineProperty(onCancel, "isCancelled", {
1549
+ get: () => this._isCancelled
1550
+ });
1551
+ return executor(onResolve, onReject, onCancel);
1552
+ });
1553
+ }
1554
+ then(onFulfilled, onRejected) {
1555
+ return this._promise.then(onFulfilled, onRejected);
1556
+ }
1557
+ catch(onRejected) {
1558
+ return this._promise.catch(onRejected);
1559
+ }
1560
+ finally(onFinally) {
1561
+ return this._promise.finally(onFinally);
1562
+ }
1563
+ cancel() {
1564
+ if (this._isResolved || this._isRejected || this._isCancelled) {
1565
+ return;
1566
+ }
1567
+ this._isCancelled = true;
1568
+ if (this._cancelHandlers.length) {
1569
+ try {
1570
+ for (const cancelHandler of this._cancelHandlers) {
1571
+ cancelHandler();
1572
+ }
1573
+ } catch (error) {
1574
+ console.warn("Cancellation threw an error", error);
1575
+ return;
1576
+ }
1577
+ }
1578
+ this._cancelHandlers.length = 0;
1579
+ this._reject?.(new CancelError("Request aborted"));
1580
+ }
1581
+ get isCancelled() {
1582
+ return this._isCancelled;
1583
+ }
1584
+ };
1585
+
1586
+ // src/common/open-api/core/request.ts
1587
+ var isDefined = (value) => {
1588
+ return value !== void 0 && value !== null;
1589
+ };
1590
+ var isString = (value) => {
1591
+ return typeof value === "string";
1592
+ };
1593
+ var isStringWithValue = (value) => {
1594
+ return isString(value) && value !== "";
1595
+ };
1596
+ var isBlob = (value) => {
1597
+ return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
1598
+ };
1599
+ var isFormData = (value) => {
1600
+ return value instanceof FormData;
1601
+ };
1602
+ var base64 = (str) => {
1603
+ try {
1604
+ return btoa(str);
1605
+ } catch (err) {
1606
+ return Buffer.from(str).toString("base64");
1607
+ }
1608
+ };
1609
+ var getQueryString = (params) => {
1610
+ const qs = [];
1611
+ const append = (key, value) => {
1612
+ qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
1613
+ };
1614
+ const process = (key, value) => {
1615
+ if (isDefined(value)) {
1616
+ if (Array.isArray(value)) {
1617
+ value.forEach((v) => {
1618
+ process(key, v);
1619
+ });
1620
+ } else if (typeof value === "object") {
1621
+ Object.entries(value).forEach(([k, v]) => {
1622
+ process(`${key}[${k}]`, v);
1623
+ });
1624
+ } else {
1625
+ append(key, value);
1626
+ }
1627
+ }
1628
+ };
1629
+ Object.entries(params).forEach(([key, value]) => {
1630
+ process(key, value);
1631
+ });
1632
+ if (qs.length > 0) {
1633
+ return `?${qs.join("&")}`;
1634
+ }
1635
+ return "";
1636
+ };
1637
+ var getUrl = (config, options) => {
1638
+ const encoder = config.ENCODE_PATH || encodeURI;
1639
+ const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
1640
+ if (options.path?.hasOwnProperty(group)) {
1641
+ return encoder(String(options.path[group]));
1642
+ }
1643
+ return substring;
1644
+ });
1645
+ const url = `${config.BASE}${path}`;
1646
+ if (options.query) {
1647
+ return `${url}${getQueryString(options.query)}`;
1648
+ }
1649
+ return url;
1650
+ };
1651
+ var getFormData = (options) => {
1652
+ if (options.formData) {
1653
+ const formData = new FormData();
1654
+ const process = (key, value) => {
1655
+ if (isString(value) || isBlob(value)) {
1656
+ formData.append(key, value);
1657
+ } else {
1658
+ formData.append(key, JSON.stringify(value));
1659
+ }
1660
+ };
1661
+ Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
1662
+ if (Array.isArray(value)) {
1663
+ value.forEach((v) => process(key, v));
1664
+ } else {
1665
+ process(key, value);
1666
+ }
1667
+ });
1668
+ return formData;
1669
+ }
1670
+ return void 0;
1671
+ };
1672
+ var resolve = async (options, resolver) => {
1673
+ if (typeof resolver === "function") {
1674
+ return resolver(options);
1675
+ }
1676
+ return resolver;
1677
+ };
1678
+ var getHeaders = async (config, options) => {
1679
+ const token = await resolve(options, config.TOKEN);
1680
+ const username = await resolve(options, config.USERNAME);
1681
+ const password = await resolve(options, config.PASSWORD);
1682
+ const additionalHeaders = await resolve(options, config.HEADERS);
1683
+ const headers = Object.entries({
1684
+ Accept: "application/json",
1685
+ ...additionalHeaders,
1686
+ ...options.headers
1687
+ }).filter(([_, value]) => isDefined(value)).reduce(
1688
+ (headers2, [key, value]) => ({
1689
+ ...headers2,
1690
+ [key]: String(value)
1691
+ }),
1692
+ {}
1693
+ );
1694
+ if (isStringWithValue(token)) {
1695
+ headers["X-AUTHORIZATION"] = token;
1696
+ }
1697
+ if (isStringWithValue(username) && isStringWithValue(password)) {
1698
+ const credentials = base64(`${username}:${password}`);
1699
+ headers["Authorization"] = `Basic ${credentials}`;
1700
+ }
1701
+ if (options.body) {
1702
+ if (options.mediaType) {
1703
+ headers["Content-Type"] = options.mediaType;
1704
+ } else if (isBlob(options.body)) {
1705
+ headers["Content-Type"] = "application/octet-stream";
1706
+ } else if (isString(options.body)) {
1707
+ headers["Content-Type"] = "text/plain";
1708
+ } else if (!isFormData(options.body)) {
1709
+ headers["Content-Type"] = "application/json";
1710
+ }
1711
+ }
1712
+ return new Headers(headers);
1713
+ };
1714
+ var getRequestBody = (options) => {
1715
+ if (options.body) {
1716
+ if (options.mediaType?.includes("/json")) {
1717
+ return JSON.stringify(options.body);
1718
+ } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
1719
+ return options.body;
1720
+ } else {
1721
+ return JSON.stringify(options.body);
1722
+ }
1723
+ }
1724
+ return void 0;
1725
+ };
1726
+ var sendRequest = async (options, url, body, formData, headers, onCancel) => {
1727
+ const controller = new AbortController();
1728
+ const request2 = {
1729
+ headers,
1730
+ method: options.method,
1731
+ body: body ?? formData,
1732
+ signal: controller.signal
1733
+ };
1734
+ onCancel(() => controller.abort());
1735
+ return await fetch(url, request2);
1736
+ };
1737
+ var getResponseHeader = (response, responseHeader) => {
1738
+ if (responseHeader) {
1739
+ const content = response.headers.get(responseHeader);
1740
+ if (isString(content)) {
1741
+ return content;
1742
+ }
1743
+ }
1744
+ return void 0;
1745
+ };
1746
+ var getResponseBody = async (response) => {
1747
+ if (response.status !== 204) {
1748
+ try {
1749
+ const contentType = response.headers.get("Content-Type");
1750
+ if (contentType) {
1751
+ const isJSON = contentType.toLowerCase().startsWith("application/json");
1752
+ if (isJSON) {
1753
+ return await response.json();
1754
+ } else {
1755
+ return await response.text();
1756
+ }
1757
+ }
1758
+ } catch (error) {
1759
+ console.error(error);
1760
+ }
1761
+ }
1762
+ return void 0;
1763
+ };
1764
+ var catchErrorCodes = (options, result) => {
1765
+ const errors = {
1766
+ 400: "Bad Request",
1767
+ 401: "Unauthorized",
1768
+ 403: "Forbidden",
1769
+ 404: "Not Found",
1770
+ 500: "Internal Server Error",
1771
+ 502: "Bad Gateway",
1772
+ 503: "Service Unavailable",
1773
+ ...options.errors
1774
+ };
1775
+ const error = errors[result.status];
1776
+ if (error) {
1777
+ throw new ApiError(options, result, error);
1778
+ }
1779
+ if (!result.ok) {
1780
+ throw new ApiError(options, result, "Generic Error");
1781
+ }
1782
+ };
1783
+ var request = (config, options) => {
1784
+ return new CancelablePromise(async (resolve2, reject, onCancel) => {
1785
+ try {
1786
+ const url = getUrl(config, options);
1787
+ const formData = getFormData(options);
1788
+ const body = getRequestBody(options);
1789
+ const headers = await getHeaders(config, options);
1790
+ if (!onCancel.isCancelled) {
1791
+ const response = await sendRequest(
1792
+ options,
1793
+ url,
1794
+ body,
1795
+ formData,
1796
+ headers,
1797
+ onCancel
1798
+ );
1799
+ const responseBody = await getResponseBody(response);
1800
+ const responseHeader = getResponseHeader(
1801
+ response,
1802
+ options.responseHeader
1803
+ );
1804
+ const result = {
1805
+ url,
1806
+ ok: response.ok,
1807
+ status: response.status,
1808
+ statusText: response.statusText,
1809
+ body: responseHeader ?? responseBody
1810
+ };
1811
+ catchErrorCodes(options, result);
1812
+ resolve2(result.body);
1813
+ }
1814
+ } catch (error) {
1815
+ reject(error);
1816
+ }
1817
+ });
1818
+ };
1819
+
1820
+ // src/common/open-api/services/HumanTaskService.ts
1821
+ var HumanTaskService = class {
1822
+ constructor(httpRequest) {
1823
+ this.httpRequest = httpRequest;
1824
+ }
1825
+ /**
1826
+ * List tasks by filters - task name, state, assignee, assignee type, claimed
1827
+ * @param state
1828
+ * @param assignee
1829
+ * @param assigneeType
1830
+ * @param claimedBy
1831
+ * @param taskName
1832
+ * @param freeText
1833
+ * @param includeInputOutput
1834
+ * @returns SearchResultHumanTaskEntry OK
1835
+ * @throws ApiError
1836
+ */
1837
+ getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, freeText, includeInputOutput = false) {
1838
+ return this.httpRequest.request({
1839
+ method: "GET",
1840
+ url: "/human/tasks",
1841
+ query: {
1842
+ "state": state,
1843
+ "assignee": assignee,
1844
+ "assigneeType": assigneeType,
1845
+ "claimedBy": claimedBy,
1846
+ "taskName": taskName,
1847
+ "freeText": freeText,
1848
+ "includeInputOutput": includeInputOutput
1849
+ }
1850
+ });
1851
+ }
1852
+ /**
1853
+ * Get task load grouped by workflow name and task ref name per user
1854
+ * @returns HumanTaskLoad OK
1855
+ * @throws ApiError
1856
+ */
1857
+ getTaskLoad() {
1858
+ return this.httpRequest.request({
1859
+ method: "GET",
1860
+ url: "/human/tasks/load"
1861
+ });
1862
+ }
1863
+ /**
1864
+ * Search human tasks
1865
+ * @param queryId
1866
+ * @param start
1867
+ * @param size
1868
+ * @param freeText
1869
+ * @param query
1870
+ * @param jsonQuery
1871
+ * @param includeInputOutput
1872
+ * @returns HTScrollableSearchResultHumanTaskEntry OK
1873
+ * @throws ApiError
1874
+ */
1875
+ search1(queryId, start, size = 100, freeText = "*", query, jsonQuery, includeInputOutput = false) {
1876
+ return this.httpRequest.request({
1877
+ method: "GET",
1878
+ url: "/human/tasks/search",
1879
+ query: {
1880
+ "queryId": queryId,
1881
+ "start": start,
1882
+ "size": size,
1883
+ "freeText": freeText,
1884
+ "query": query,
1885
+ "jsonQuery": jsonQuery,
1886
+ "includeInputOutput": includeInputOutput
1887
+ }
1888
+ });
1889
+ }
1890
+ /**
1891
+ * If the workflow is disconnected from tasks, this API can be used to clean up
1892
+ * @param taskId
1893
+ * @returns any OK
1894
+ * @throws ApiError
1895
+ */
1896
+ updateTaskOutput1(taskId) {
1897
+ return this.httpRequest.request({
1898
+ method: "DELETE",
1899
+ url: "/human/tasks/{taskId}",
1900
+ path: {
1901
+ "taskId": taskId
1902
+ }
1903
+ });
1904
+ }
1905
+ /**
1906
+ * Get a task
1907
+ * @param taskId
1908
+ * @returns HumanTaskEntry OK
1909
+ * @throws ApiError
1910
+ */
1911
+ getTask1(taskId) {
1912
+ return this.httpRequest.request({
1913
+ method: "GET",
1914
+ url: "/human/tasks/{taskId}",
1915
+ path: {
1916
+ "taskId": taskId
1917
+ }
1918
+ });
1919
+ }
1920
+ /**
1921
+ * Get human task action log entries by task id
1922
+ * @param taskId
1923
+ * @returns HumanTaskActionLogEntry OK
1924
+ * @throws ApiError
1925
+ */
1926
+ getActionLogs(taskId) {
1927
+ return this.httpRequest.request({
1928
+ method: "GET",
1929
+ url: "/human/tasks/{taskId}/actionLogs",
1930
+ path: {
1931
+ "taskId": taskId
1932
+ }
1933
+ });
1934
+ }
1935
+ /**
1936
+ * Claim a task by authenticated Conductor user
1937
+ * @param taskId
1938
+ * @returns any OK
1939
+ * @throws ApiError
1940
+ */
1941
+ claimTask(taskId) {
1942
+ return this.httpRequest.request({
1943
+ method: "POST",
1944
+ url: "/human/tasks/{taskId}/claim",
1945
+ path: {
1946
+ "taskId": taskId
1947
+ }
1948
+ });
1949
+ }
1950
+ /**
1951
+ * Claim a task to an external user
1952
+ * @param taskId
1953
+ * @param userId
1954
+ * @returns any OK
1955
+ * @throws ApiError
1956
+ */
1957
+ assignAndClaim(taskId, userId) {
1958
+ return this.httpRequest.request({
1959
+ method: "POST",
1960
+ url: "/human/tasks/{taskId}/externalUser/{userId}",
1961
+ path: {
1962
+ "taskId": taskId,
1963
+ "userId": userId
1964
+ }
1965
+ });
1966
+ }
1967
+ /**
1968
+ * Release a task without completing it
1969
+ * @param taskId
1970
+ * @param requestBody
1971
+ * @returns any OK
1972
+ * @throws ApiError
1973
+ */
1974
+ reassignTask(taskId, requestBody) {
1975
+ return this.httpRequest.request({
1976
+ method: "POST",
1977
+ url: "/human/tasks/{taskId}/reassign",
1978
+ path: {
1979
+ "taskId": taskId
1980
+ },
1981
+ body: requestBody,
1982
+ mediaType: "application/json"
1983
+ });
1984
+ }
1985
+ /**
1986
+ * Release a task without completing it
1987
+ * @param taskId
1988
+ * @returns any OK
1989
+ * @throws ApiError
1990
+ */
1991
+ releaseTask(taskId) {
1992
+ return this.httpRequest.request({
1993
+ method: "POST",
1994
+ url: "/human/tasks/{taskId}/release",
1995
+ path: {
1996
+ "taskId": taskId
1997
+ }
1998
+ });
1999
+ }
2000
+ /**
2001
+ * Get human task state log entries by task id
2002
+ * @param taskId
2003
+ * @returns HumanTaskStateLogEntry OK
2004
+ * @throws ApiError
2005
+ */
2006
+ getStateLogs(taskId) {
2007
+ return this.httpRequest.request({
2008
+ method: "GET",
2009
+ url: "/human/tasks/{taskId}/stateLogs",
2010
+ path: {
2011
+ "taskId": taskId
2012
+ }
2013
+ });
2014
+ }
2015
+ /**
2016
+ * Update task output, optionally complete
2017
+ * @param taskId
2018
+ * @param requestBody
2019
+ * @param complete
2020
+ * @returns any OK
2021
+ * @throws ApiError
2022
+ */
2023
+ updateTaskOutput(taskId, requestBody, complete = false) {
2024
+ return this.httpRequest.request({
2025
+ method: "POST",
2026
+ url: "/human/tasks/{taskId}/update",
2027
+ path: {
2028
+ "taskId": taskId
2029
+ },
2030
+ query: {
2031
+ "complete": complete
2032
+ },
2033
+ body: requestBody,
2034
+ mediaType: "application/json"
2035
+ });
2036
+ }
2037
+ /**
2038
+ * Delete human task templates by name
2039
+ * @param name
2040
+ * @returns any OK
2041
+ * @throws ApiError
2042
+ */
2043
+ deleteTemplatesByName(name) {
2044
+ return this.httpRequest.request({
2045
+ method: "DELETE",
2046
+ url: "/human/template",
2047
+ query: {
2048
+ "name": name
2049
+ }
2050
+ });
2051
+ }
2052
+ /**
2053
+ * List all human task templates or get templates by name, or a template by name and version
2054
+ * @param name
2055
+ * @param version
2056
+ * @returns HumanTaskTemplateEntry OK
2057
+ * @throws ApiError
2058
+ */
2059
+ getAllTemplates(name, version) {
2060
+ return this.httpRequest.request({
2061
+ method: "GET",
2062
+ url: "/human/template",
2063
+ query: {
2064
+ "name": name,
2065
+ "version": version
2066
+ }
2067
+ });
2068
+ }
2069
+ /**
2070
+ * Save human task template
2071
+ * @param requestBody
2072
+ * @param newVersion
2073
+ * @returns string OK
2074
+ * @throws ApiError
2075
+ */
2076
+ saveTemplate(requestBody, newVersion = false) {
2077
+ return this.httpRequest.request({
2078
+ method: "POST",
2079
+ url: "/human/template",
2080
+ query: {
2081
+ "newVersion": newVersion
2082
+ },
2083
+ body: requestBody,
2084
+ mediaType: "application/json"
2085
+ });
2086
+ }
2087
+ /**
2088
+ * Delete human task template
2089
+ * @param id
2090
+ * @returns any OK
2091
+ * @throws ApiError
2092
+ */
2093
+ deleteTemplateById(id) {
2094
+ return this.httpRequest.request({
2095
+ method: "DELETE",
2096
+ url: "/human/template/{id}",
2097
+ path: {
2098
+ "id": id
2099
+ }
2100
+ });
2101
+ }
2102
+ /**
2103
+ * Get human task template by id
2104
+ * @param id
2105
+ * @returns HumanTaskTemplateEntry OK
2106
+ * @throws ApiError
2107
+ */
2108
+ getTemplateById(id) {
2109
+ return this.httpRequest.request({
2110
+ method: "GET",
2111
+ url: "/human/template/{id}",
2112
+ path: {
2113
+ "id": id
2114
+ }
2115
+ });
2116
+ }
2117
+ };
2118
+
2119
+ // src/common/open-api/services/HumanTaskResourceService.ts
2120
+ var HumanTaskResourceService = class {
2121
+ constructor(httpRequest) {
2122
+ this.httpRequest = httpRequest;
2123
+ }
2124
+ /**
2125
+ * Get Conductor task by id (for human tasks only)
2126
+ * @param taskId
2127
+ * @returns Task OK
2128
+ * @throws ApiError
2129
+ */
2130
+ getConductorTaskById(taskId) {
2131
+ return this.httpRequest.request({
2132
+ method: "GET",
2133
+ url: "/human/tasks/{taskId}/conductorTask",
2134
+ path: {
2135
+ "taskId": taskId
2136
+ }
2137
+ });
2138
+ }
2139
+ };
2140
+
2141
+ // src/common/open-api/ConductorClient.ts
2142
+ var defaultRequestHandler = (request2, config, options) => request2(config, options);
2143
+ var ConductorClient = class {
2144
+ constructor(config, requestHandler = defaultRequestHandler) {
2145
+ const resolvedConfig = {
2146
+ BASE: config?.serverUrl ?? "http://localhost:8080",
2147
+ VERSION: config?.VERSION ?? "0",
2148
+ WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
2149
+ CREDENTIALS: config?.CREDENTIALS ?? "include",
2150
+ TOKEN: config?.TOKEN,
2151
+ USERNAME: config?.USERNAME,
2152
+ PASSWORD: config?.PASSWORD,
2153
+ HEADERS: config?.HEADERS,
2154
+ ENCODE_PATH: config?.ENCODE_PATH
2155
+ };
2156
+ this.request = {
2157
+ config: resolvedConfig,
2158
+ request: (apiConfig) => {
2159
+ return requestHandler(request, resolvedConfig, apiConfig);
2160
+ }
2161
+ };
2162
+ this.token = config?.TOKEN;
2163
+ this.eventResource = new EventResourceService(this.request);
2164
+ this.healthCheckResource = new HealthCheckResourceService(this.request);
2165
+ this.metadataResource = new MetadataResourceService(this.request);
2166
+ this.schedulerResource = new SchedulerResourceService(this.request);
2167
+ this.taskResource = new TaskResourceService(this.request);
2168
+ this.tokenResource = new TokenResourceService(this.request);
2169
+ this.workflowBulkResource = new WorkflowBulkResourceService(this.request);
2170
+ this.workflowResource = new WorkflowResourceService(this.request);
2171
+ this.humanTask = new HumanTaskService(this.request);
2172
+ this.humanTaskResource = new HumanTaskResourceService(this.request);
2173
+ }
2174
+ };
2175
+
2176
+ // src/common/open-api/core/BaseHttpRequest.ts
2177
+ var BaseHttpRequest = class {
2178
+ constructor(config) {
2179
+ this.config = config;
2180
+ }
2181
+ };
2182
+
2183
+ // src/task/Poller.ts
2184
+ var Poller = class {
2185
+ constructor(pollFunction, pollerOptions, logger) {
2186
+ this.concurrentCalls = [];
2187
+ this.pollFunction = async () => {
2188
+ };
2189
+ this.polling = false;
2190
+ this.options = {
2191
+ pollInterval: 1e3,
2192
+ concurrency: 1
2193
+ };
2194
+ this.logger = noopLogger;
2195
+ /**
2196
+ * Starts polling for work
2197
+ */
2198
+ this.startPolling = () => {
2199
+ if (this.polling) {
2200
+ throw new Error("Runner is already started");
2201
+ }
2202
+ return this.poll();
2203
+ };
2204
+ /**
2205
+ * Stops Polling for work
2206
+ */
2207
+ this.stopPolling = () => {
2208
+ this.polling = false;
2209
+ this.concurrentCalls.forEach((call) => call.stop());
2210
+ };
2211
+ this.poll = async () => {
2212
+ if (!this.polling) {
2213
+ this.polling = true;
2214
+ for (let i = 0; i < this.options.concurrency; i++) {
2215
+ this.concurrentCalls.push(this.singlePoll());
2216
+ }
2217
+ }
2218
+ };
2219
+ this.singlePoll = () => {
2220
+ let poll = this.polling;
2221
+ let timeout;
2222
+ const pollingCall = async () => {
2223
+ while (poll) {
2224
+ await this.pollFunction();
2225
+ await new Promise(
2226
+ (r) => timeout = setTimeout(() => r(true), this.options.pollInterval)
2227
+ );
2228
+ }
2229
+ };
2230
+ return {
2231
+ promise: pollingCall(),
2232
+ stop: () => {
2233
+ clearTimeout(timeout);
2234
+ poll = false;
2235
+ this.logger.debug("stopping single poll call");
2236
+ }
2237
+ };
2238
+ };
2239
+ this.pollFunction = pollFunction;
2240
+ this.options = { ...this.options, ...pollerOptions };
2241
+ this.logger = logger || noopLogger;
2242
+ }
2243
+ get isPolling() {
2244
+ return this.polling;
2245
+ }
2246
+ /**
2247
+ * adds or shuts down concurrent calls based on the concurrency setting
2248
+ * @param concurrency
2249
+ */
2250
+ updateConcurrency(concurrency) {
2251
+ if (concurrency > 0 && concurrency !== this.options.concurrency) {
2252
+ if (concurrency < this.options.concurrency) {
2253
+ const result = this.concurrentCalls.splice(
2254
+ 0,
2255
+ this.options.concurrency - concurrency
2256
+ );
2257
+ result.forEach((call) => {
2258
+ call.stop();
2259
+ this.logger.debug("stopping some spawned calls");
2260
+ });
2261
+ } else {
2262
+ for (let i = 0; i < concurrency - this.options.concurrency; i++) {
2263
+ this.concurrentCalls.push(this.singlePoll());
2264
+ this.logger.debug("spawning additional poll calls");
2265
+ }
2266
+ }
2267
+ this.options.concurrency = concurrency;
2268
+ }
2269
+ }
2270
+ updateOptions(options) {
2271
+ const newOptions = { ...this.options, ...options };
2272
+ this.updateConcurrency(newOptions.concurrency);
2273
+ this.options = newOptions;
2274
+ }
2275
+ };
2276
+
2277
+ // src/task/TaskRunner.ts
2278
+ var DEFAULT_ERROR_MESSAGE = "An unknown error occurred";
2279
+ var MAX_RETRIES = 3;
2280
+ var noopErrorHandler = (__error) => {
2281
+ };
2282
+ var TaskRunner = class {
2283
+ constructor({
2284
+ worker,
2285
+ taskResource,
2286
+ options,
2287
+ logger = noopLogger,
2288
+ onError: errorHandler = noopErrorHandler
2289
+ }) {
2290
+ /**
2291
+ * Starts polling for work
2292
+ */
2293
+ this.startPolling = () => {
2294
+ this.poller.startPolling();
2295
+ };
2296
+ /**
2297
+ * Stops Polling for work
2298
+ */
2299
+ this.stopPolling = () => {
2300
+ this.poller.stopPolling();
2301
+ };
2302
+ this.pollAndExecute = async () => {
2303
+ try {
2304
+ const { workerID } = this.options;
2305
+ const task = await this.taskResource.poll(
2306
+ this.worker.taskDefName,
2307
+ workerID,
2308
+ this.worker.domain ?? this.options.domain
2309
+ );
2310
+ if (task && task.taskId) {
2311
+ await this.executeTask(task);
2312
+ } else {
2313
+ this.logger.debug(`No tasks for ${this.worker.taskDefName}`);
2314
+ }
2315
+ } catch (unknownError) {
2316
+ this.handleUnknownError(unknownError);
2317
+ this.errorHandler(unknownError);
2318
+ }
2319
+ };
2320
+ this.updateTaskWithRetry = async (task, taskResult) => {
2321
+ let retryCount = 0;
2322
+ while (retryCount < MAX_RETRIES) {
2323
+ try {
2324
+ await this.taskResource.updateTask1(taskResult);
2325
+ return;
2326
+ } catch (error) {
2327
+ this.errorHandler(error, task);
2328
+ this.logger.error(
2329
+ `Error updating task ${taskResult.taskId} on retry ${retryCount}`,
2330
+ error
2331
+ );
2332
+ retryCount++;
2333
+ await new Promise((r) => setTimeout(() => r(true), retryCount * 10));
2334
+ }
2335
+ }
2336
+ this.logger.error(
2337
+ `Unable to update task ${taskResult.taskId} after ${retryCount} retries`
2338
+ );
2339
+ };
2340
+ this.executeTask = async (task) => {
2341
+ try {
2342
+ const result = await this.worker.execute(task);
2343
+ await this.updateTaskWithRetry(task, {
2344
+ ...result,
2345
+ workflowInstanceId: task.workflowInstanceId,
2346
+ taskId: task.taskId
2347
+ });
2348
+ this.logger.debug(`Finished polling for task ${task.taskId}`);
2349
+ } catch (error) {
2350
+ await this.updateTaskWithRetry(task, {
2351
+ workflowInstanceId: task.workflowInstanceId,
2352
+ taskId: task.taskId,
2353
+ reasonForIncompletion: error?.message ?? DEFAULT_ERROR_MESSAGE,
2354
+ status: "FAILED",
2355
+ outputData: {}
2356
+ });
2357
+ this.errorHandler(error, task);
2358
+ this.logger.error(`Error executing ${task.taskId}`, error);
2359
+ }
2360
+ };
2361
+ this.handleUnknownError = (unknownError) => {
2362
+ let message = "";
2363
+ let stack = "";
2364
+ if (unknownError.stack) {
2365
+ stack = unknownError.stack;
2366
+ }
2367
+ if (unknownError.message) {
2368
+ message = unknownError.message;
2369
+ }
2370
+ this.logger.error(
2371
+ `Error for ${this.worker.taskDefName}: error: ${message}, stack: ${stack}`
2372
+ );
2373
+ };
2374
+ this.taskResource = taskResource;
2375
+ this.logger = logger;
2376
+ this.worker = worker;
2377
+ this.options = options;
2378
+ this.errorHandler = errorHandler;
2379
+ this.poller = new Poller(
2380
+ this.pollAndExecute,
2381
+ { concurrency: options.concurrency, pollInterval: options.pollInterval },
2382
+ this.logger
2383
+ );
2384
+ }
2385
+ get isPolling() {
2386
+ return this.poller.isPolling;
2387
+ }
2388
+ updateOptions(options) {
2389
+ const newOptions = { ...this.options, ...options };
2390
+ this.poller.updateOptions({
2391
+ concurrency: newOptions.concurrency,
2392
+ pollInterval: newOptions.pollInterval
2393
+ });
2394
+ this.options = newOptions;
2395
+ }
2396
+ get getOptions() {
2397
+ return this.options;
2398
+ }
2399
+ };
2400
+
2401
+ // src/task/TaskManager.ts
2402
+ import os from "os";
2403
+ var defaultManagerOptions = {
2404
+ workerID: "",
2405
+ pollInterval: 1e3,
2406
+ domain: void 0,
2407
+ concurrency: 1
2408
+ };
2409
+ function workerId(options) {
2410
+ return options.workerID ?? os.hostname();
2411
+ }
2412
+ var TaskManager = class {
2413
+ constructor(client, workers, config = {}) {
2414
+ this.tasks = {};
2415
+ this.polling = false;
2416
+ this.workerManagerWorkerOptions = (worker) => {
2417
+ return {
2418
+ ...this.options,
2419
+ concurrency: worker.concurrency ?? this.options.concurrency,
2420
+ domain: worker.domain ?? this.options.domain
2421
+ };
2422
+ };
2423
+ /**
2424
+ * new options will get merged to existing options
2425
+ * @param options new options to update polling options
2426
+ */
2427
+ this.updatePollingOptions = (options) => {
2428
+ this.workers.forEach((worker) => {
2429
+ const newOptions = {
2430
+ ...this.workerManagerWorkerOptions(worker),
2431
+ ...options
2432
+ };
2433
+ const runners = this.tasks[worker.taskDefName];
2434
+ runners.forEach((runner) => {
2435
+ runner.updateOptions(newOptions);
2436
+ });
2437
+ });
2438
+ this.options.concurrency = options.concurrency ?? this.options.concurrency;
2439
+ this.options.pollInterval = options.pollInterval ?? this.options.pollInterval;
2440
+ };
2441
+ /**
2442
+ * Start polling for tasks
2443
+ */
2444
+ this.startPolling = () => {
2445
+ this.workers.forEach((worker) => {
2446
+ this.tasks[worker.taskDefName] = [];
2447
+ const options = this.workerManagerWorkerOptions(worker);
2448
+ this.logger.debug(
2449
+ `Starting taskDefName=${worker.taskDefName} concurrency=${options.concurrency} domain=${options.domain}`
2450
+ );
2451
+ const runner = new TaskRunner({
2452
+ worker,
2453
+ options,
2454
+ taskResource: this.client.taskResource,
2455
+ logger: this.logger,
2456
+ onError: this.errorHandler
2457
+ });
2458
+ runner.startPolling();
2459
+ this.tasks[worker.taskDefName].push(runner);
2460
+ });
2461
+ this.polling = true;
2462
+ };
2463
+ /**
2464
+ * Stops polling for tasks
2465
+ */
2466
+ this.stopPolling = () => {
2467
+ for (const taskType in this.tasks) {
2468
+ this.tasks[taskType].forEach((runner) => runner.stopPolling());
2469
+ this.tasks[taskType] = [];
2470
+ }
2471
+ this.polling = false;
2472
+ };
2473
+ if (!workers) {
2474
+ throw new Error(
2475
+ "No workers supplied to TaskManager. Please pass an array of workers."
2476
+ );
2477
+ }
2478
+ this.client = client;
2479
+ this.logger = config.logger ?? new DefaultLogger();
2480
+ this.errorHandler = config.onError ?? noopErrorHandler;
2481
+ this.workers = workers;
2482
+ const providedOptions = config.options ?? {};
2483
+ this.options = {
2484
+ ...defaultManagerOptions,
2485
+ ...providedOptions,
2486
+ workerID: workerId(providedOptions)
2487
+ };
2488
+ }
2489
+ get isPolling() {
2490
+ return this.polling;
2491
+ }
2492
+ };
2493
+
2494
+ // src/core/types.ts
2495
+ var ConductorError = class extends Error {
2496
+ constructor(message, innerError) {
2497
+ super(message);
2498
+ this._trace = innerError;
2499
+ const actualProto = new.target.prototype;
2500
+ if (Object.setPrototypeOf) {
2501
+ Object.setPrototypeOf(this, actualProto);
2502
+ } else {
2503
+ this.__proto__ = actualProto;
2504
+ }
2505
+ }
2506
+ };
2507
+
2508
+ // src/core/helpers.ts
2509
+ var errorMapper = (error) => new ConductorError(error?.body?.message, error);
2510
+ var tryCatchReThrow = (fn) => {
2511
+ try {
2512
+ return fn();
2513
+ } catch (error) {
2514
+ throw errorMapper(error);
2515
+ }
2516
+ };
2517
+
2518
+ // src/core/executor.ts
2519
+ var RETRY_TIME_IN_MILLISECONDS = 1e4;
2520
+ var WorkflowExecutor = class {
2521
+ constructor(client) {
2522
+ this._client = client;
2523
+ }
2524
+ /**
2525
+ * Will persist a workflow in conductor
2526
+ * @param override If true will override the existing workflow with the definition
2527
+ * @param workflow Complete workflow definition
2528
+ * @returns null
2529
+ */
2530
+ registerWorkflow(override, workflow2) {
2531
+ return tryCatchReThrow(
2532
+ () => this._client.metadataResource.create(workflow2, override)
2533
+ );
2534
+ }
2535
+ /**
2536
+ * Takes a StartWorkflowRequest. returns a Promise<string> with the workflowInstanceId of the running workflow
2537
+ * @param workflowRequest
2538
+ * @returns
2539
+ */
2540
+ startWorkflow(workflowRequest) {
2541
+ return tryCatchReThrow(
2542
+ () => this._client.workflowResource.startWorkflow(workflowRequest)
2543
+ );
2544
+ }
2545
+ /**
2546
+ * Execute a workflow synchronously. returns a Promise<WorkflowRun> with details of the running workflow
2547
+ * @param workflowRequest
2548
+ * @returns
2549
+ */
2550
+ executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
2551
+ return tryCatchReThrow(
2552
+ () => this._client.workflowResource.executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef)
2553
+ );
2554
+ }
2555
+ startWorkflows(workflowsRequest) {
2556
+ return tryCatchReThrow(() => workflowsRequest.map(this.startWorkflow));
2557
+ }
2558
+ /**
2559
+ * Takes an workflowInstanceId and an includeTasks and an optional retry parameter returns the whole execution status.
2560
+ * If includeTasks flag is provided. Details of tasks execution will be returned as well,
2561
+ * retry specifies the amount of retrys before throwing an error.
2562
+ *
2563
+ * @param workflowInstanceId
2564
+ * @param includeTasks
2565
+ * @param retry
2566
+ * @returns
2567
+ */
2568
+ async getWorkflow(workflowInstanceId, includeTasks, retry = 0) {
2569
+ try {
2570
+ const workflowStatus = await this._client.workflowResource.getExecutionStatus(
2571
+ workflowInstanceId,
2572
+ includeTasks
2573
+ );
2574
+ return workflowStatus;
2575
+ } catch (error) {
2576
+ if (![500, 404, 403].includes(error.status) || retry === 0) {
2577
+ throw errorMapper(error);
2578
+ }
2579
+ }
2580
+ await new Promise(
2581
+ (res) => setTimeout(() => res(true), RETRY_TIME_IN_MILLISECONDS)
2582
+ );
2583
+ return this.getWorkflow(workflowInstanceId, includeTasks, retry - 1);
2584
+ }
2585
+ /**
2586
+ * Returns a summary of the current workflow status.
2587
+ *
2588
+ * @param workflowInstanceId current running workflow
2589
+ * @param includeOutput flag to include output
2590
+ * @param includeVariables flag to include variable
2591
+ * @returns Promise<WorkflowStatus>
2592
+ */
2593
+ getWorkflowStatus(workflowInstanceId, includeOutput, includeVariables) {
2594
+ return tryCatchReThrow(
2595
+ () => this._client.workflowResource.getWorkflowStatusSummary(
2596
+ workflowInstanceId,
2597
+ includeOutput,
2598
+ includeVariables
2599
+ )
2600
+ );
2601
+ }
2602
+ /**
2603
+ * Pauses a running workflow
2604
+ * @param workflowInstanceId current workflow execution
2605
+ * @returns
2606
+ */
2607
+ pause(workflowInstanceId) {
2608
+ return tryCatchReThrow(
2609
+ () => this._client.workflowResource.pauseWorkflow(workflowInstanceId)
2610
+ );
2611
+ }
2612
+ /**
2613
+ * Reruns workflowInstanceId workflow. with new parameters
2614
+ *
2615
+ * @param workflowInstanceId current workflow execution
2616
+ * @param rerunWorkflowRequest Rerun Workflow Execution Request
2617
+ * @returns
2618
+ */
2619
+ reRun(workflowInstanceId, rerunWorkflowRequest = {}) {
2620
+ return tryCatchReThrow(
2621
+ () => this._client.workflowResource.rerun(
2622
+ workflowInstanceId,
2623
+ rerunWorkflowRequest
2624
+ )
2625
+ );
2626
+ }
2627
+ /**
2628
+ * Restarts workflow with workflowInstanceId, if useLatestDefinition uses last defintion
2629
+ * @param workflowInstanceId
2630
+ * @param useLatestDefinitions
2631
+ * @returns
2632
+ */
2633
+ restart(workflowInstanceId, useLatestDefinitions) {
2634
+ return tryCatchReThrow(
2635
+ () => this._client.workflowResource.restart1(
2636
+ workflowInstanceId,
2637
+ useLatestDefinitions
2638
+ )
2639
+ );
2640
+ }
2641
+ /**
2642
+ * Resumes a previously paused execution
2643
+ *
2644
+ * @param workflowInstanceId Running workflow workflowInstanceId
2645
+ * @returns
2646
+ */
2647
+ resume(workflowInstanceId) {
2648
+ return tryCatchReThrow(
2649
+ () => this._client.workflowResource.resumeWorkflow(workflowInstanceId)
2650
+ );
2651
+ }
2652
+ /**
2653
+ * Retrys workflow from last failing task
2654
+ * if resumeSubworkflowTasks is true will resume tasks in spawned subworkflows
2655
+ *
2656
+ * @param workflowInstanceId
2657
+ * @param resumeSubworkflowTasks
2658
+ * @returns
2659
+ */
2660
+ retry(workflowInstanceId, resumeSubworkflowTasks) {
2661
+ return tryCatchReThrow(
2662
+ () => this._client.workflowResource.retry1(
2663
+ workflowInstanceId,
2664
+ resumeSubworkflowTasks
2665
+ )
2666
+ );
2667
+ }
2668
+ /**
2669
+ * Searches for existing workflows given the following querys
2670
+ *
2671
+ * @param start
2672
+ * @param size
2673
+ * @param query
2674
+ * @param freeText
2675
+ * @param sort
2676
+ * @param skipCache
2677
+ * @returns
2678
+ */
2679
+ search(start, size, query, freeText, sort = "", skipCache = false) {
2680
+ const queryId = void 0;
2681
+ return tryCatchReThrow(
2682
+ () => this._client.workflowResource.search1(
2683
+ queryId,
2684
+ start,
2685
+ size,
2686
+ sort,
2687
+ freeText,
2688
+ query,
2689
+ skipCache
2690
+ )
2691
+ );
2692
+ }
2693
+ /**
2694
+ * Skips a task of a running workflow.
2695
+ * by providing a skipTaskRequest you can set the input and the output of the skipped tasks
2696
+ * @param workflowInstanceId
2697
+ * @param taskReferenceName
2698
+ * @param skipTaskRequest
2699
+ * @returns
2700
+ */
2701
+ skipTasksFromWorkflow(workflowInstanceId, taskReferenceName, skipTaskRequest) {
2702
+ return tryCatchReThrow(
2703
+ () => this._client.workflowResource.skipTaskFromWorkflow(
2704
+ workflowInstanceId,
2705
+ taskReferenceName,
2706
+ skipTaskRequest
2707
+ )
2708
+ );
2709
+ }
2710
+ /**
2711
+ * Takes an workflowInstanceId, and terminates a running workflow
2712
+ * @param workflowInstanceId
2713
+ * @param reason
2714
+ * @returns
2715
+ */
2716
+ terminate(workflowInstanceId, reason) {
2717
+ return tryCatchReThrow(
2718
+ () => this._client.workflowResource.terminate1(workflowInstanceId, reason)
2719
+ );
2720
+ }
2721
+ /**
2722
+ * Takes a taskId and a workflowInstanceId. Will update the task for the corresponding taskId
2723
+ * @param taskId
2724
+ * @param workflowInstanceId
2725
+ * @param taskStatus
2726
+ * @param taskOutput
2727
+ * @returns
2728
+ */
2729
+ updateTask(taskId, workflowInstanceId, taskStatus, outputData) {
2730
+ const taskUpdates = {
2731
+ status: taskStatus,
2732
+ taskId,
2733
+ workflowInstanceId
2734
+ };
2735
+ return tryCatchReThrow(
2736
+ () => this._client.taskResource.updateTask1({
2737
+ outputData,
2738
+ ...taskUpdates
2739
+ })
2740
+ );
2741
+ }
2742
+ /**
2743
+ * Updates a task by reference Name
2744
+ * @param taskReferenceName
2745
+ * @param workflowInstanceId
2746
+ * @param status
2747
+ * @param taskOutput
2748
+ * @returns
2749
+ */
2750
+ updateTaskByRefName(taskReferenceName, workflowInstanceId, status, taskOutput) {
2751
+ return tryCatchReThrow(
2752
+ () => this._client.taskResource.updateTask(
2753
+ workflowInstanceId,
2754
+ taskReferenceName,
2755
+ status,
2756
+ taskOutput
2757
+ )
2758
+ );
2759
+ }
2760
+ /**
2761
+ *
2762
+ * @param taskId
2763
+ * @returns
2764
+ */
2765
+ getTask(taskId) {
2766
+ return tryCatchReThrow(() => this._client.taskResource.getTask(taskId));
2767
+ }
2768
+ };
2769
+
2770
+ // src/core/human.ts
2771
+ var HumanExecutor = class {
2772
+ constructor(client) {
2773
+ this._client = client;
2774
+ }
2775
+ /**
2776
+ * Takes a set of filter parameters. return matches of human tasks for that set of parameters
2777
+ * @param state
2778
+ * @param assignee
2779
+ * @param assigneeType
2780
+ * @param claimedBy
2781
+ * @param taskName
2782
+ * @param freeText
2783
+ * @param includeInputOutput
2784
+ * @returns
2785
+ */
2786
+ async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, freeText, includeInputOutput = false) {
2787
+ const response = await this._client.humanTask.getTasksByFilter(
2788
+ state,
2789
+ assignee,
2790
+ assigneeType,
2791
+ claimedBy,
2792
+ taskName,
2793
+ freeText,
2794
+ includeInputOutput
2795
+ );
2796
+ if (response.results != void 0) {
2797
+ return response.results;
2798
+ }
2799
+ return [];
2800
+ }
2801
+ /**
2802
+ * Returns task for a given task id
2803
+ * @param taskId
2804
+ * @returns
2805
+ */
2806
+ getTaskById(taskId) {
2807
+ return tryCatchReThrow(() => this._client.humanTask.getTask1(taskId));
2808
+ }
2809
+ /**
2810
+ * Assigns taskId to assignee. If the task is already assigned to another user, this will fail.
2811
+ * @param taskId
2812
+ * @param assignee
2813
+ * @returns
2814
+ */
2815
+ async claimTaskAsExternalUser(taskId, assignee) {
2816
+ try {
2817
+ await this._client.humanTask.assignAndClaim(taskId, assignee);
2818
+ } catch (error) {
2819
+ throw errorMapper(error);
2820
+ }
2821
+ }
2822
+ /**
2823
+ * Claim task as conductor user
2824
+ * @param taskId
2825
+ * @returns
2826
+ */
2827
+ async claimTaskAsConductorUser(taskId) {
2828
+ try {
2829
+ await this._client.humanTask.claimTask(taskId);
2830
+ } catch (error) {
2831
+ throw errorMapper(error);
2832
+ }
2833
+ }
2834
+ /**
2835
+ * Claim task as conductor user
2836
+ * @param taskId
2837
+ * @param assignee
2838
+ * @returns
2839
+ */
2840
+ async releaseTask(taskId) {
2841
+ try {
2842
+ await this._client.humanTask.releaseTask(taskId);
2843
+ } catch (error) {
2844
+ throw errorMapper(error);
2845
+ }
2846
+ }
2847
+ /**
2848
+ * Returns a HumanTaskTemplateEntry for a given templateId
2849
+ * @param templateId
2850
+ * @returns
2851
+ */
2852
+ async getTemplateById(templateId) {
2853
+ return tryCatchReThrow(
2854
+ () => this._client.humanTask.getTemplateById(templateId)
2855
+ );
2856
+ }
2857
+ /**
2858
+ * Takes a taskId and a partial body. will update with given body
2859
+ * @param taskId
2860
+ * @param requestBody
2861
+ */
2862
+ async updateTaskOutput(taskId, requestBody) {
2863
+ try {
2864
+ await this._client.humanTask.updateTaskOutput(taskId, requestBody, false);
2865
+ } catch (error) {
2866
+ throw errorMapper(error);
2867
+ }
2868
+ }
2869
+ /**
2870
+ * Takes a taskId and an optional partial body. will complete the task with the given body
2871
+ * @param taskId
2872
+ * @param requestBody
2873
+ */
2874
+ async completeTask(taskId, requestBody = {}) {
2875
+ try {
2876
+ await this._client.humanTask.updateTaskOutput(taskId, requestBody, true);
2877
+ } catch (error) {
2878
+ throw errorMapper(error);
2879
+ }
2880
+ }
2881
+ };
2882
+
2883
+ // src/core/sdk/doWhile.ts
2884
+ var doWhileTask = (taskRefName, terminationCondition, tasks) => ({
2885
+ name: taskRefName,
2886
+ taskReferenceName: taskRefName,
2887
+ loopCondition: terminationCondition,
2888
+ inputParameters: {},
2889
+ type: "DO_WHILE" /* DO_WHILE */,
2890
+ loopOver: tasks
2891
+ });
2892
+ var loopForCondition = (taskRefName, valueKey) => `if ( $.${taskRefName}['iteration'] < $.${valueKey} ) { true; } else { false; }`;
2893
+ var newLoopTask = (taskRefName, iterations, tasks) => ({
2894
+ name: taskRefName,
2895
+ taskReferenceName: taskRefName,
2896
+ loopCondition: loopForCondition(taskRefName, "value"),
2897
+ inputParameters: {
2898
+ value: iterations
2899
+ },
2900
+ type: "DO_WHILE" /* DO_WHILE */,
2901
+ loopOver: tasks
2902
+ });
2903
+
2904
+ // src/core/sdk/dynamicFork.ts
2905
+ var dynamicForkTask = (taskReferenceName, preForkTasks = [], dynamicTasksInput = "") => ({
2906
+ name: taskReferenceName,
2907
+ taskReferenceName,
2908
+ inputParameters: {
2909
+ dynamicTasks: preForkTasks,
2910
+ dynamicTasksInput
2911
+ },
2912
+ type: "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */,
2913
+ dynamicForkTasksParam: "dynamicTasks",
2914
+ dynamicForkTasksInputParamName: "dynamicTasksInput"
2915
+ });
2916
+
2917
+ // src/core/sdk/event.ts
2918
+ var eventTask = (taskReferenceName, eventPrefix, eventSuffix) => ({
2919
+ name: taskReferenceName,
2920
+ taskReferenceName,
2921
+ sink: `${eventPrefix}:${eventSuffix}`,
2922
+ type: "EVENT" /* EVENT */
2923
+ });
2924
+ var sqsEventTask = (taskReferenceName, queueName) => eventTask(taskReferenceName, "sqs", queueName);
2925
+ var conductorEventTask = (taskReferenceName, eventName) => eventTask(taskReferenceName, "conductor", eventName);
2926
+
2927
+ // src/core/generators/common.ts
2928
+ var randomChars = (n = 7) => (Math.random() + 1).toString(36).substring(n);
2929
+ var taskNameGenerator = (taskType) => `${taskType}__task_${randomChars(7)}`;
2930
+ var taskReferenceNameGenerator = (taskName) => `${taskName}_ref`;
2931
+ var nameTaskNameGenerator = (taskType, maybeOverrides = {}) => {
2932
+ const name = maybeOverrides?.name ?? taskNameGenerator(taskType);
2933
+ return {
2934
+ name,
2935
+ taskReferenceName: taskReferenceNameGenerator(name)
2936
+ };
2937
+ };
2938
+ function mapArrValues(arrayTransformer, mapWithValues) {
2939
+ return Object.fromEntries(
2940
+ Object.entries(mapWithValues).map(([key, value]) => [
2941
+ key,
2942
+ arrayTransformer(value)
2943
+ ])
2944
+ );
2945
+ }
2946
+
2947
+ // src/core/generators/SimpleTask.ts
2948
+ var generateSimpleTask = (overrides = {}) => ({
2949
+ ...nameTaskNameGenerator("simple", overrides),
2950
+ inputParameters: {},
2951
+ ...overrides,
2952
+ type: "SIMPLE" /* SIMPLE */
2953
+ });
2954
+
2955
+ // src/core/generators/DoWhileTask.ts
2956
+ var generateDoWhileTask = (overrides = {}, nestedTasksMapper) => ({
2957
+ ...nameTaskNameGenerator("doWhile", overrides),
2958
+ inputParameters: {},
2959
+ startDelay: 0,
2960
+ optional: false,
2961
+ asyncComplete: false,
2962
+ loopCondition: "",
2963
+ ...overrides,
2964
+ loopOver: nestedTasksMapper(overrides?.loopOver || []),
2965
+ type: "DO_WHILE" /* DO_WHILE */
2966
+ });
2967
+
2968
+ // src/core/generators/EventTask.ts
2969
+ var generateEventTask = (overrides = {}) => ({
2970
+ ...nameTaskNameGenerator("event", overrides),
2971
+ sink: "sqs:sqs_queue_name",
2972
+ asyncComplete: false,
2973
+ ...overrides,
2974
+ type: "EVENT" /* EVENT */
2975
+ });
2976
+
2977
+ // src/core/generators/ForkJoin.ts
2978
+ var generateForkJoinTask = (overrides = {}, nestedMapper) => ({
2979
+ ...nameTaskNameGenerator("forkJoin", overrides),
2980
+ inputParameters: {},
2981
+ ...overrides,
2982
+ type: "FORK_JOIN" /* FORK_JOIN */,
2983
+ forkTasks: (overrides?.forkTasks || []).map(nestedMapper)
2984
+ });
2985
+ var generateJoinTask = (overrides = {}) => ({
2986
+ ...nameTaskNameGenerator("join", overrides),
2987
+ inputParameters: {},
2988
+ joinOn: [],
2989
+ optional: false,
2990
+ asyncComplete: false,
2991
+ ...overrides,
2992
+ type: "JOIN" /* JOIN */
2993
+ });
2994
+
2995
+ // src/core/generators/HttpTask.ts
2996
+ var generateHTTPTask = (overrides = {}) => ({
2997
+ ...nameTaskNameGenerator("httpTask", overrides),
2998
+ inputParameters: {
2999
+ http_request: {
3000
+ uri: "https://jsonplaceholder.typicode.com/posts/${workflow.input.queryid}",
3001
+ method: "GET"
3002
+ }
3003
+ },
3004
+ ...overrides,
3005
+ type: "HTTP" /* HTTP */
3006
+ });
3007
+
3008
+ // src/core/generators/InlineTask.ts
3009
+ var defaultInputParams = {
3010
+ value: "${workflow.input.value}",
3011
+ evaluatorType: "graaljs",
3012
+ expression: "true"
3013
+ };
3014
+ var generateEvaluationCode = (inputParametersPartial = {}) => {
3015
+ const inlinePartialDefJavascript = inputParametersPartial;
3016
+ const inlineExpression = inlinePartialDefJavascript?.expression;
3017
+ if (inlineExpression !== void 0 && typeof inlineExpression === "function") {
3018
+ const resultingFunction = inlineExpression();
3019
+ const resultingFunctionAsString = resultingFunction.toString();
3020
+ const toReturn = {
3021
+ evaluatorType: "graaljs",
3022
+ ...inputParametersPartial || { value: "true" },
3023
+ expression: `(${resultingFunctionAsString})();`
3024
+ };
3025
+ return toReturn;
3026
+ }
3027
+ return {
3028
+ ...defaultInputParams,
3029
+ evaluatorType: "graaljs",
3030
+ ...inputParametersPartial
3031
+ };
3032
+ };
3033
+ var generateInlineTask = (override = {}) => ({
3034
+ ...nameTaskNameGenerator("inline", override),
3035
+ ...override,
3036
+ inputParameters: generateEvaluationCode(override?.inputParameters || {}),
3037
+ type: "INLINE" /* INLINE */
3038
+ });
3039
+
3040
+ // src/core/generators/JsonJQTransform.ts
3041
+ var generateJQTransformTask = (overrides = {}) => ({
3042
+ ...nameTaskNameGenerator("jqTransform", overrides),
3043
+ inputParameters: {
3044
+ key1: {
3045
+ value1: ["a", "b"]
3046
+ },
3047
+ key2: {
3048
+ value2: ["c", "d"]
3049
+ },
3050
+ queryExpression: "{ key3: (.key1.value1 + .key2.value2) }"
3051
+ },
3052
+ ...overrides,
3053
+ type: "JSON_JQ_TRANSFORM" /* JSON_JQ_TRANSFORM */
3054
+ });
3055
+
3056
+ // src/core/generators/KafkaTask.ts
3057
+ var generateKafkaPublishTask = (overrides = {}) => ({
3058
+ ...nameTaskNameGenerator("kafka", overrides),
3059
+ inputParameters: {
3060
+ kafka_request: {
3061
+ topic: "topic",
3062
+ value: "",
3063
+ bootStrapServers: "localhost:9092",
3064
+ headers: {},
3065
+ key: "123",
3066
+ keySerializer: "org.apache.kafka.common.serialization.IntegerSerializer"
3067
+ }
3068
+ },
3069
+ ...overrides,
3070
+ type: "KAFKA_PUBLISH" /* KAFKA_PUBLISH */
3071
+ });
3072
+
3073
+ // src/core/generators/SubWorkflowTask.ts
3074
+ var generateSubWorkflowTask = (overrides = {}) => ({
3075
+ ...nameTaskNameGenerator("subWorkflow", overrides),
3076
+ inputParameters: {},
3077
+ subWorkflowParam: {
3078
+ name: "name",
3079
+ version: 1,
3080
+ taskToDomain: {}
3081
+ },
3082
+ ...overrides,
3083
+ type: "SUB_WORKFLOW" /* SUB_WORKFLOW */
3084
+ });
3085
+
3086
+ // src/core/generators/SetVariableTask.ts
3087
+ var generateSetVariableTask = (overrides = {}) => ({
3088
+ ...nameTaskNameGenerator("setVariable", overrides),
3089
+ inputParameters: {},
3090
+ ...overrides,
3091
+ type: "SET_VARIABLE" /* SET_VARIABLE */
3092
+ });
3093
+
3094
+ // src/core/generators/TerminateTask.ts
3095
+ var generateTerminateTask = (overrides = {}) => ({
3096
+ ...nameTaskNameGenerator("terminate", overrides),
3097
+ inputParameters: {
3098
+ terminationStatus: "COMPLETED",
3099
+ workflowOutput: {}
3100
+ },
3101
+ startDelay: 0,
3102
+ optional: false,
3103
+ ...overrides,
3104
+ type: "TERMINATE" /* TERMINATE */
3105
+ });
3106
+
3107
+ // src/core/generators/WaitTask.ts
3108
+ var generateWaitTask = (overrides = {}) => ({
3109
+ ...nameTaskNameGenerator("wait", overrides),
3110
+ ...overrides,
3111
+ inputParameters: {},
3112
+ type: "WAIT" /* WAIT */
3113
+ });
3114
+
3115
+ // src/core/generators/SwitchTask.ts
3116
+ var fillSwitchTaskBranches = (task, mapper) => ({
3117
+ decisionCases: mapArrValues(mapper, task?.decisionCases || {}),
3118
+ defaultCase: mapper(task?.defaultCase || [])
3119
+ });
3120
+ var generateSwitchTask = (overrides = {}, nestedTasksMapper) => ({
3121
+ ...nameTaskNameGenerator("switch", overrides),
3122
+ inputParameters: {
3123
+ switchCaseValue: ""
3124
+ },
3125
+ evaluatorType: "value-param",
3126
+ expression: "switchCaseValue",
3127
+ ...overrides,
3128
+ ...fillSwitchTaskBranches(overrides, nestedTasksMapper),
3129
+ type: "SWITCH" /* SWITCH */
3130
+ });
3131
+
3132
+ // src/core/generators/WorkflowGenerator.ts
3133
+ var workflowGenerator = (overrides) => ({
3134
+ name: "NewWorkflow_3nxbi",
3135
+ description: "Edit or extend this sample workflow. Set the workflow name to get started",
3136
+ version: 1,
3137
+ tasks: [],
3138
+ inputParameters: [],
3139
+ outputParameters: {},
3140
+ schemaVersion: 2,
3141
+ restartable: true,
3142
+ workflowStatusListenerEnabled: false,
3143
+ ownerEmail: "james.stuart@orkes.io",
3144
+ timeoutPolicy: "ALERT_ONLY",
3145
+ timeoutSeconds: 0,
3146
+ ...overrides
3147
+ });
3148
+
3149
+ // src/core/generators/ForkJoinDynamicTask.ts
3150
+ var generateForkJoinDynamic = (overrides = {}) => ({
3151
+ ...nameTaskNameGenerator("forkJoinDynamic", overrides),
3152
+ inputParameters: {
3153
+ dynamicTasks: "",
3154
+ dynamicTasksInput: ""
3155
+ },
3156
+ dynamicForkTasksParam: "dynamicTasks",
3157
+ dynamicForkTasksInputParamName: "dynamicTasksInput",
3158
+ startDelay: 0,
3159
+ optional: false,
3160
+ asyncComplete: false,
3161
+ ...overrides,
3162
+ type: "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */
3163
+ });
3164
+
3165
+ // src/core/generators/generator.ts
3166
+ var filledTaskDef = (task) => {
3167
+ const taskType = task.type;
3168
+ switch (taskType) {
3169
+ case "SWITCH" /* SWITCH */:
3170
+ return generateSwitchTask(task, taskGenMapper);
3171
+ case "SIMPLE" /* SIMPLE */:
3172
+ return generateSimpleTask(task);
3173
+ case "DO_WHILE" /* DO_WHILE */:
3174
+ return generateDoWhileTask(task, taskGenMapper);
3175
+ case "EVENT" /* EVENT */:
3176
+ return generateEventTask(task);
3177
+ case "FORK_JOIN" /* FORK_JOIN */:
3178
+ return generateForkJoinTask(task, taskGenMapper);
3179
+ case "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */:
3180
+ return generateForkJoinDynamic(task);
3181
+ case "HTTP" /* HTTP */:
3182
+ return generateHTTPTask(task);
3183
+ case "INLINE" /* INLINE */:
3184
+ return generateInlineTask(task);
3185
+ case "JOIN" /* JOIN */:
3186
+ return generateJoinTask(task);
3187
+ case "JSON_JQ_TRANSFORM" /* JSON_JQ_TRANSFORM */:
3188
+ return generateJQTransformTask(task);
3189
+ case "KAFKA_PUBLISH" /* KAFKA_PUBLISH */:
3190
+ return generateKafkaPublishTask(task);
3191
+ case "SUB_WORKFLOW" /* SUB_WORKFLOW */:
3192
+ return generateSubWorkflowTask(task);
3193
+ case "SET_VARIABLE" /* SET_VARIABLE */:
3194
+ return generateSetVariableTask(task);
3195
+ case "TERMINATE" /* TERMINATE */:
3196
+ return generateTerminateTask(task);
3197
+ case "WAIT" /* WAIT */:
3198
+ return generateWaitTask(task);
3199
+ default:
3200
+ return generateSimpleTask(task);
3201
+ }
3202
+ };
3203
+ var taskGenMapper = (tasks) => tasks.reduce((acc, task, idx) => {
3204
+ const filledTask = filledTaskDef(task);
3205
+ const maybeNextTask = tasks.length >= idx + 1 ? tasks[idx + 1] : void 0;
3206
+ return acc.concat(maybeAddJoinTask(filledTask, maybeNextTask));
3207
+ }, []);
3208
+ var maybeAddJoinTask = (currentTask, maybeNextTask) => {
3209
+ if ((currentTask.type === "FORK_JOIN" /* FORK_JOIN */ || currentTask.type === "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */) && maybeNextTask != null && maybeNextTask.type !== "JOIN" /* JOIN */) {
3210
+ return [currentTask, generateJoinTask({})];
3211
+ }
3212
+ return currentTask;
3213
+ };
3214
+ var generate = (overrides) => {
3215
+ const maybeTasks = overrides.tasks || [];
3216
+ const generatedTasks = taskGenMapper(maybeTasks);
3217
+ return workflowGenerator({ ...overrides, tasks: generatedTasks });
3218
+ };
3219
+
3220
+ // src/core/generators/index.ts
3221
+ var generateSwitchTask2 = (overrides = {}, nestedTasksMapper = taskGenMapper) => generateSwitchTask(overrides, nestedTasksMapper);
3222
+ var generateDoWhileTask2 = (overrides = {}, nestedTasksMapper = taskGenMapper) => generateDoWhileTask(overrides, nestedTasksMapper);
3223
+ var generateForkJoinTask2 = (overrides = {}, nestedMapper = taskGenMapper) => generateForkJoinTask(overrides, nestedMapper);
3224
+
3225
+ // src/core/sdk/forkJoin.ts
3226
+ var forkTask = (taskReferenceName, forkTasks) => ({
3227
+ taskReferenceName,
3228
+ name: taskReferenceName,
3229
+ type: "FORK_JOIN" /* FORK_JOIN */,
3230
+ forkTasks: [forkTasks]
3231
+ });
3232
+ var forkTaskJoin = (taskReferenceName, forkTasks) => [
3233
+ forkTask(taskReferenceName, forkTasks),
3234
+ generateJoinTask({ name: `${taskReferenceName}_join` })
3235
+ ];
3236
+
3237
+ // src/core/sdk/http.ts
3238
+ var httpTask = (taskReferenceName, inputParameters) => ({
3239
+ name: taskReferenceName,
3240
+ taskReferenceName,
3241
+ inputParameters: {
3242
+ http_request: inputParameters
3243
+ },
3244
+ type: "HTTP" /* HTTP */
3245
+ });
3246
+
3247
+ // src/core/sdk/inline.ts
3248
+ var inlineTask = (taskReferenceName, script, evaluatorType = "javascript") => ({
3249
+ name: taskReferenceName,
3250
+ taskReferenceName,
3251
+ inputParameters: {
3252
+ evaluatorType,
3253
+ expression: script
3254
+ },
3255
+ type: "INLINE" /* INLINE */
3256
+ });
3257
+
3258
+ // src/core/sdk/join.ts
3259
+ var joinTask = (taskReferenceName, joinOn) => ({
3260
+ name: taskReferenceName,
3261
+ taskReferenceName,
3262
+ joinOn,
3263
+ type: "JOIN" /* JOIN */
3264
+ });
3265
+
3266
+ // src/core/sdk/jsonJq.ts
3267
+ var jsonJqTask = (taskReferenceName, script) => ({
3268
+ name: taskReferenceName,
3269
+ taskReferenceName,
3270
+ type: "JSON_JQ_TRANSFORM" /* JSON_JQ_TRANSFORM */,
3271
+ inputParameters: {
3272
+ queryExpression: script
3273
+ }
3274
+ });
3275
+
3276
+ // src/core/sdk/kafkaPublish.ts
3277
+ var kafkaPublishTask = (taskReferenceName, kafka_request) => ({
3278
+ taskReferenceName,
3279
+ name: taskReferenceName,
3280
+ type: "KAFKA_PUBLISH" /* KAFKA_PUBLISH */,
3281
+ inputParameters: {
3282
+ kafka_request
3283
+ }
3284
+ });
3285
+
3286
+ // src/core/sdk/setVariable.ts
3287
+ var setVariableTask = (taskReferenceName, inputParameters) => ({
3288
+ name: taskReferenceName,
3289
+ taskReferenceName,
3290
+ type: "SET_VARIABLE" /* SET_VARIABLE */,
3291
+ inputParameters
3292
+ });
3293
+
3294
+ // src/core/sdk/simple.ts
3295
+ var simpleTask = (taskReferenceName, name, inputParameters) => ({
3296
+ name,
3297
+ taskReferenceName,
3298
+ inputParameters,
3299
+ type: "SIMPLE" /* SIMPLE */
3300
+ });
3301
+
3302
+ // src/core/sdk/subWorkflow.ts
3303
+ var subWorkflowTask = (taskReferenceName, workflowName, version) => ({
3304
+ name: taskReferenceName,
3305
+ taskReferenceName,
3306
+ subWorkflowParam: {
3307
+ name: workflowName,
3308
+ version
3309
+ },
3310
+ type: "SUB_WORKFLOW" /* SUB_WORKFLOW */
3311
+ });
3312
+
3313
+ // src/core/sdk/switch.ts
3314
+ var switchTask = (taskReferenceName, expression, decisionCases = {}, defaultCase = []) => ({
3315
+ name: taskReferenceName,
3316
+ taskReferenceName,
3317
+ decisionCases,
3318
+ evaluatorType: "value-param",
3319
+ inputParameters: {
3320
+ switchCaseValue: expression
3321
+ },
3322
+ expression: "switchCaseValue",
3323
+ defaultCase,
3324
+ type: "SWITCH" /* SWITCH */
3325
+ });
3326
+
3327
+ // src/core/sdk/terminate.ts
3328
+ var terminateTask = (taskReferenceName, status, terminationReason) => ({
3329
+ name: taskReferenceName,
3330
+ taskReferenceName,
3331
+ inputParameters: {
3332
+ terminationStatus: status,
3333
+ terminationReason
3334
+ },
3335
+ type: "TERMINATE" /* TERMINATE */
3336
+ });
3337
+
3338
+ // src/core/sdk/wait.ts
3339
+ var waitTaskDuration = (taskReferenceName, duration) => ({
3340
+ name: taskReferenceName,
3341
+ taskReferenceName,
3342
+ inputParameters: {
3343
+ duration
3344
+ },
3345
+ type: "WAIT" /* WAIT */
3346
+ });
3347
+ var waitTaskUntil = (taskReferenceName, until) => ({
3348
+ name: taskReferenceName,
3349
+ taskReferenceName,
3350
+ inputParameters: {
3351
+ until
3352
+ },
3353
+ type: "WAIT" /* WAIT */
3354
+ });
3355
+
3356
+ // src/core/sdk/workflow.ts
3357
+ var workflow = (name, tasks) => ({
3358
+ name,
3359
+ version: 1,
3360
+ tasks,
3361
+ inputParameters: [],
3362
+ timeoutSeconds: 0
3363
+ });
3364
+
3365
+ // src/orkes/BaseOrkesConductorClient.ts
3366
+ var defaultRequestHandler2 = (request2, config, options) => request2(config, options);
3367
+ var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHandler2) => {
3368
+ return async (config, requestHandler = baseRequestHandler) => {
3369
+ if (config?.keySecret != null && config?.keyId != null) {
3370
+ const { serverUrl, keyId, keySecret } = config;
3371
+ const tokenUrl = `${serverUrl}/token`;
3372
+ const res = await fetchFn(tokenUrl, {
3373
+ headers: {
3374
+ "Content-Type": "application/json",
3375
+ Accept: "application/json"
3376
+ },
3377
+ body: JSON.stringify({ keyId, keySecret }),
3378
+ method: "POST"
3379
+ });
3380
+ const { token } = await res.json();
3381
+ return new ConductorClient({ ...config, TOKEN: token }, requestHandler);
3382
+ } else {
3383
+ return new ConductorClient(config, requestHandler);
3384
+ }
3385
+ };
3386
+ };
3387
+
3388
+ // src/orkes/BrowserOrkesConductorClient.ts
3389
+ var defaultRequestHandler3 = (request2, config, options) => request2(config, options);
3390
+ var orkesConductorClient = baseOrkesConductorClient(
3391
+ fetch,
3392
+ defaultRequestHandler3
3393
+ );
3394
+ export {
3395
+ ApiError,
3396
+ BaseHttpRequest,
3397
+ CancelError,
3398
+ CancelablePromise,
3399
+ ConductorClient,
3400
+ ConductorError,
3401
+ DefaultLogger,
3402
+ EventResourceService,
3403
+ HealthCheckResourceService,
3404
+ HumanExecutor,
3405
+ MetadataResourceService,
3406
+ SchedulerResourceService,
3407
+ TaskManager,
3408
+ TaskResourceService,
3409
+ TaskRunner,
3410
+ TaskType,
3411
+ TokenResourceService,
3412
+ WorkflowBulkResourceService,
3413
+ WorkflowExecutor,
3414
+ WorkflowResourceService,
3415
+ conductorEventTask,
3416
+ doWhileTask,
3417
+ dynamicForkTask,
3418
+ eventTask,
3419
+ forkTask,
3420
+ forkTaskJoin,
3421
+ generate,
3422
+ generateDoWhileTask2 as generateDoWhileTask,
3423
+ generateEventTask,
3424
+ generateForkJoinTask2 as generateForkJoinTask,
3425
+ generateHTTPTask,
3426
+ generateInlineTask,
3427
+ generateJQTransformTask,
3428
+ generateJoinTask,
3429
+ generateKafkaPublishTask,
3430
+ generateSetVariableTask,
3431
+ generateSimpleTask,
3432
+ generateSubWorkflowTask,
3433
+ generateSwitchTask2 as generateSwitchTask,
3434
+ generateTerminateTask,
3435
+ generateWaitTask,
3436
+ httpTask,
3437
+ inlineTask,
3438
+ joinTask,
3439
+ jsonJqTask,
3440
+ kafkaPublishTask,
3441
+ newLoopTask,
3442
+ noopErrorHandler,
3443
+ noopLogger,
3444
+ orkesConductorClient,
3445
+ setVariableTask,
3446
+ simpleTask,
3447
+ sqsEventTask,
3448
+ subWorkflowTask,
3449
+ switchTask,
3450
+ taskGenMapper,
3451
+ terminateTask,
3452
+ waitTaskDuration,
3453
+ waitTaskUntil,
3454
+ workflow
3455
+ };
3456
+ //# sourceMappingURL=browser.mjs.map