@io-orkes/conductor-javascript 2.0.0-rc1 → 2.0.0-rc3

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.
package/dist/browser.mjs DELETED
@@ -1,3667 +0,0 @@
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
- * If the workflow is disconnected from tasks, this API can be used to clean up (in bulk)
1827
- * @param requestBody
1828
- * @returns any OK
1829
- * @throws ApiError
1830
- */
1831
- deleteTaskFromHumanTaskRecords(requestBody) {
1832
- return this.httpRequest.request({
1833
- method: "DELETE",
1834
- url: "/human/tasks/delete",
1835
- body: requestBody,
1836
- mediaType: "application/json"
1837
- });
1838
- }
1839
- /**
1840
- * If the workflow is disconnected from tasks, this API can be used to clean up
1841
- * @param taskId
1842
- * @returns any OK
1843
- * @throws ApiError
1844
- */
1845
- deleteTaskFromHumanTaskRecords1(taskId) {
1846
- return this.httpRequest.request({
1847
- method: "DELETE",
1848
- url: "/human/tasks/delete/{taskId}",
1849
- path: {
1850
- "taskId": taskId
1851
- }
1852
- });
1853
- }
1854
- /**
1855
- * Search human tasks
1856
- * @param requestBody
1857
- * @returns HumanTaskSearchResult OK
1858
- * @throws ApiError
1859
- */
1860
- search(requestBody) {
1861
- return this.httpRequest.request({
1862
- method: "POST",
1863
- url: "/human/tasks/search",
1864
- body: requestBody,
1865
- mediaType: "application/json"
1866
- });
1867
- }
1868
- /**
1869
- * Update task output, optionally complete
1870
- * @param workflowId
1871
- * @param taskRefName
1872
- * @param requestBody
1873
- * @param complete
1874
- * @param iteration Populate this value if your task is in a loop and you want to update a specific iteration. If its not in a loop OR if you want to just update the latest iteration, leave this as empty
1875
- * @returns any OK
1876
- * @throws ApiError
1877
- */
1878
- updateTaskOutputByRef(workflowId, taskRefName, requestBody, complete = false, iteration) {
1879
- return this.httpRequest.request({
1880
- method: "POST",
1881
- url: "/human/tasks/update/taskRef",
1882
- query: {
1883
- "workflowId": workflowId,
1884
- "taskRefName": taskRefName,
1885
- "complete": complete,
1886
- "iteration": iteration
1887
- },
1888
- body: requestBody,
1889
- mediaType: "application/json"
1890
- });
1891
- }
1892
- /**
1893
- * Get a task
1894
- * @param taskId
1895
- * @returns HumanTaskEntry OK
1896
- * @throws ApiError
1897
- */
1898
- getTask1(taskId) {
1899
- return this.httpRequest.request({
1900
- method: "GET",
1901
- url: "/human/tasks/{taskId}",
1902
- path: {
1903
- "taskId": taskId
1904
- }
1905
- });
1906
- }
1907
- /**
1908
- * Claim a task by authenticated Conductor user
1909
- * @param taskId
1910
- * @param overrideAssignment
1911
- * @returns any OK
1912
- * @throws ApiError
1913
- */
1914
- claimTask(taskId, overrideAssignment = false) {
1915
- return this.httpRequest.request({
1916
- method: "POST",
1917
- url: "/human/tasks/{taskId}/claim",
1918
- path: {
1919
- "taskId": taskId
1920
- },
1921
- query: {
1922
- "overrideAssignment": overrideAssignment
1923
- }
1924
- });
1925
- }
1926
- /**
1927
- * Claim a task to an external user
1928
- * @param taskId
1929
- * @param userId
1930
- * @param overrideAssignment
1931
- * @returns any OK
1932
- * @throws ApiError
1933
- */
1934
- assignAndClaim(taskId, userId, overrideAssignment = false) {
1935
- return this.httpRequest.request({
1936
- method: "POST",
1937
- url: "/human/tasks/{taskId}/externalUser/{userId}",
1938
- path: {
1939
- "taskId": taskId,
1940
- "userId": userId
1941
- },
1942
- query: {
1943
- "overrideAssignment": overrideAssignment
1944
- }
1945
- });
1946
- }
1947
- /**
1948
- * Release a task without completing it
1949
- * @param taskId
1950
- * @param requestBody
1951
- * @returns any OK
1952
- * @throws ApiError
1953
- */
1954
- reassignTask(taskId, requestBody) {
1955
- return this.httpRequest.request({
1956
- method: "POST",
1957
- url: "/human/tasks/{taskId}/reassign",
1958
- path: {
1959
- "taskId": taskId
1960
- },
1961
- body: requestBody,
1962
- mediaType: "application/json"
1963
- });
1964
- }
1965
- /**
1966
- * Release a task without completing it
1967
- * @param taskId
1968
- * @returns any OK
1969
- * @throws ApiError
1970
- */
1971
- releaseTask(taskId) {
1972
- return this.httpRequest.request({
1973
- method: "POST",
1974
- url: "/human/tasks/{taskId}/release",
1975
- path: {
1976
- "taskId": taskId
1977
- }
1978
- });
1979
- }
1980
- /**
1981
- * If a task is assigned to a user, this API can be used to skip that assignment and move to the next assignee
1982
- * @param taskId
1983
- * @param reason
1984
- * @returns any OK
1985
- * @throws ApiError
1986
- */
1987
- skipTask(taskId, reason) {
1988
- return this.httpRequest.request({
1989
- method: "POST",
1990
- url: "/human/tasks/{taskId}/skip",
1991
- path: {
1992
- "taskId": taskId
1993
- },
1994
- query: {
1995
- "reason": reason
1996
- }
1997
- });
1998
- }
1999
- /**
2000
- * Update task output, optionally complete
2001
- * @param taskId
2002
- * @param requestBody
2003
- * @param complete
2004
- * @returns any OK
2005
- * @throws ApiError
2006
- */
2007
- updateTaskOutput(taskId, requestBody, complete = false) {
2008
- return this.httpRequest.request({
2009
- method: "POST",
2010
- url: "/human/tasks/{taskId}/update",
2011
- path: {
2012
- "taskId": taskId
2013
- },
2014
- query: {
2015
- "complete": complete
2016
- },
2017
- body: requestBody,
2018
- mediaType: "application/json"
2019
- });
2020
- }
2021
- /**
2022
- * List all user form templates or get templates by name, or a template by name and version
2023
- * @param name
2024
- * @param version
2025
- * @returns HumanTaskTemplate OK
2026
- * @throws ApiError
2027
- */
2028
- getAllTemplates(name, version) {
2029
- return this.httpRequest.request({
2030
- method: "GET",
2031
- url: "/human/template",
2032
- query: {
2033
- "name": name,
2034
- "version": version
2035
- }
2036
- });
2037
- }
2038
- /**
2039
- * Save user form template
2040
- * @param requestBody
2041
- * @param newVersion
2042
- * @returns HumanTaskTemplate OK
2043
- * @throws ApiError
2044
- */
2045
- saveTemplate(requestBody, newVersion = false) {
2046
- return this.httpRequest.request({
2047
- method: "POST",
2048
- url: "/human/template",
2049
- query: {
2050
- "newVersion": newVersion
2051
- },
2052
- body: requestBody,
2053
- mediaType: "application/json"
2054
- });
2055
- }
2056
- /**
2057
- * Save user form template
2058
- * @param requestBody
2059
- * @param newVersion
2060
- * @returns HumanTaskTemplate OK
2061
- * @throws ApiError
2062
- */
2063
- saveTemplates(requestBody, newVersion = false) {
2064
- return this.httpRequest.request({
2065
- method: "POST",
2066
- url: "/human/template/bulk",
2067
- query: {
2068
- "newVersion": newVersion
2069
- },
2070
- body: requestBody,
2071
- mediaType: "application/json"
2072
- });
2073
- }
2074
- /**
2075
- * Delete all versions of user form template by name
2076
- * @param name
2077
- * @returns any OK
2078
- * @throws ApiError
2079
- */
2080
- deleteTemplateByName(name) {
2081
- return this.httpRequest.request({
2082
- method: "DELETE",
2083
- url: "/human/template/{name}",
2084
- path: {
2085
- "name": name
2086
- }
2087
- });
2088
- }
2089
- /**
2090
- * Delete a version of form template by name
2091
- * @param name
2092
- * @param version
2093
- * @returns any OK
2094
- * @throws ApiError
2095
- */
2096
- deleteTemplatesByNameAndVersion(name, version) {
2097
- return this.httpRequest.request({
2098
- method: "DELETE",
2099
- url: "/human/template/{name}/{version}",
2100
- path: {
2101
- "name": name,
2102
- "version": version
2103
- }
2104
- });
2105
- }
2106
- /**
2107
- * Get user form template by name and version
2108
- * @param name
2109
- * @param version
2110
- * @returns HumanTaskTemplate OK
2111
- * @throws ApiError
2112
- */
2113
- getTemplateByNameAndVersion(name, version) {
2114
- return this.httpRequest.request({
2115
- method: "GET",
2116
- url: "/human/template/{name}/{version}",
2117
- path: {
2118
- "name": name,
2119
- "version": version
2120
- }
2121
- });
2122
- }
2123
- };
2124
-
2125
- // src/common/open-api/services/HumanTaskResourceService.ts
2126
- var HumanTaskResourceService = class {
2127
- constructor(httpRequest) {
2128
- this.httpRequest = httpRequest;
2129
- }
2130
- /**
2131
- * Get Conductor task by id (for human tasks only)
2132
- * @param taskId
2133
- * @returns Task OK
2134
- * @throws ApiError
2135
- */
2136
- getConductorTaskById(taskId) {
2137
- return this.httpRequest.request({
2138
- method: "GET",
2139
- url: "/human/tasks/{taskId}/conductorTask",
2140
- path: {
2141
- "taskId": taskId
2142
- }
2143
- });
2144
- }
2145
- };
2146
-
2147
- // src/common/open-api/ConductorClient.ts
2148
- var defaultRequestHandler = (request2, config, options) => request2(config, options);
2149
- var ConductorClient = class {
2150
- constructor(config, requestHandler = defaultRequestHandler) {
2151
- const resolvedConfig = {
2152
- BASE: config?.serverUrl ?? "http://localhost:8080",
2153
- VERSION: config?.VERSION ?? "0",
2154
- WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
2155
- CREDENTIALS: config?.CREDENTIALS ?? "include",
2156
- TOKEN: config?.TOKEN,
2157
- USERNAME: config?.USERNAME,
2158
- PASSWORD: config?.PASSWORD,
2159
- HEADERS: config?.HEADERS,
2160
- ENCODE_PATH: config?.ENCODE_PATH
2161
- };
2162
- this.request = {
2163
- config: resolvedConfig,
2164
- request: (apiConfig) => {
2165
- return requestHandler(
2166
- request,
2167
- { ...resolvedConfig, TOKEN: this.token },
2168
- apiConfig
2169
- );
2170
- }
2171
- };
2172
- this.token = config?.TOKEN;
2173
- this.eventResource = new EventResourceService(this.request);
2174
- this.healthCheckResource = new HealthCheckResourceService(this.request);
2175
- this.metadataResource = new MetadataResourceService(this.request);
2176
- this.schedulerResource = new SchedulerResourceService(this.request);
2177
- this.taskResource = new TaskResourceService(this.request);
2178
- this.tokenResource = new TokenResourceService(this.request);
2179
- this.workflowBulkResource = new WorkflowBulkResourceService(this.request);
2180
- this.workflowResource = new WorkflowResourceService(this.request);
2181
- this.humanTask = new HumanTaskService(this.request);
2182
- this.humanTaskResource = new HumanTaskResourceService(this.request);
2183
- }
2184
- stop() {
2185
- }
2186
- };
2187
-
2188
- // src/common/open-api/core/BaseHttpRequest.ts
2189
- var BaseHttpRequest = class {
2190
- constructor(config) {
2191
- this.config = config;
2192
- }
2193
- };
2194
-
2195
- // src/task/constants.ts
2196
- var DEFAULT_POLL_INTERVAL = 100;
2197
- var DEFAULT_CONCURRENCY = 1;
2198
- var DEFAULT_WARN_AT_O = 100;
2199
- var DEFAULT_BATCH_POLLING_TIMEOUT = 100;
2200
-
2201
- // src/task/Poller.ts
2202
- var Poller = class {
2203
- constructor(pollerId, pollFunction, performWorkFunction, pollerOptions, logger) {
2204
- this.performWorkFunction = async () => {
2205
- };
2206
- this.polling = false;
2207
- this._tasksInProcess = 0;
2208
- this._counterAtO = 0;
2209
- this._pollerId = "";
2210
- this.options = {
2211
- pollInterval: DEFAULT_POLL_INTERVAL,
2212
- concurrency: DEFAULT_CONCURRENCY,
2213
- warnAtO: DEFAULT_WARN_AT_O
2214
- };
2215
- this.logger = noopLogger;
2216
- /**
2217
- * Starts polling for work
2218
- */
2219
- this.startPolling = () => {
2220
- if (this.polling) {
2221
- throw new Error("Runner is already started");
2222
- }
2223
- this._tasksInProcess = 0;
2224
- this.polling = true;
2225
- this.poll();
2226
- };
2227
- /**
2228
- * Stops Polling for work
2229
- */
2230
- this.stopPolling = async () => {
2231
- this.polling = false;
2232
- clearTimeout(this.timeoutHandler);
2233
- };
2234
- this.performWork = async (work) => {
2235
- await this.performWorkFunction(work);
2236
- this._tasksInProcess--;
2237
- };
2238
- this.poll = async () => {
2239
- while (this.isPolling) {
2240
- try {
2241
- const count = Math.max(
2242
- 0,
2243
- this.options.concurrency - this._tasksInProcess
2244
- );
2245
- if (count === 0) {
2246
- this.logger.debug(
2247
- "Max in process reached, Will skip polling for " + this._pollerId
2248
- );
2249
- this._counterAtO++;
2250
- if (this._counterAtO > (this.options.warnAtO ?? 100)) {
2251
- this.logger.info(
2252
- `Not polling anything because in process tasks is maxed as concurrency level. ${this._pollerId}`
2253
- );
2254
- }
2255
- } else {
2256
- this._counterAtO = 0;
2257
- const tasksResult = await this.pollFunction(count);
2258
- this._tasksInProcess = this._tasksInProcess + (tasksResult ?? []).length;
2259
- tasksResult.forEach(this.performWork);
2260
- }
2261
- } catch (e) {
2262
- this.logger.error(`Error polling for tasks: ${e.message}`, e);
2263
- }
2264
- await new Promise(
2265
- (r) => this.isPolling ? this.timeoutHandler = setTimeout(
2266
- () => r(true),
2267
- this.options.pollInterval
2268
- ) : r(true)
2269
- );
2270
- }
2271
- };
2272
- this._pollerId = pollerId;
2273
- this.pollFunction = pollFunction;
2274
- this.performWorkFunction = performWorkFunction;
2275
- this.options = { ...this.options, ...pollerOptions };
2276
- this.logger = logger || noopLogger;
2277
- }
2278
- get isPolling() {
2279
- return this.polling;
2280
- }
2281
- get tasksInProcess() {
2282
- return this._tasksInProcess;
2283
- }
2284
- updateOptions(options) {
2285
- const newOptions = { ...this.options, ...options };
2286
- this.options = newOptions;
2287
- }
2288
- };
2289
-
2290
- // src/task/helpers.ts
2291
- var optionEquals = (oldOptions, newOptions) => {
2292
- const newOptionEntries = Object.entries(newOptions);
2293
- const oldOptionsEntries = Object.entries(oldOptions);
2294
- return newOptionEntries.length === oldOptionsEntries.length && newOptionEntries.every(
2295
- ([key, value]) => oldOptions[key] === value
2296
- );
2297
- };
2298
-
2299
- // src/task/TaskRunner.ts
2300
- var DEFAULT_ERROR_MESSAGE = "An unknown error occurred";
2301
- var MAX_RETRIES = 3;
2302
- var noopErrorHandler = (__error) => {
2303
- };
2304
- var defaultRunnerOptions = {
2305
- workerID: "",
2306
- pollInterval: DEFAULT_POLL_INTERVAL,
2307
- domain: void 0,
2308
- concurrency: DEFAULT_CONCURRENCY,
2309
- batchPollingTimeout: DEFAULT_BATCH_POLLING_TIMEOUT
2310
- };
2311
- var TaskRunner = class {
2312
- constructor({
2313
- worker,
2314
- taskResource,
2315
- options,
2316
- logger = noopLogger,
2317
- onError: errorHandler = noopErrorHandler
2318
- }) {
2319
- /**
2320
- * Starts polling for work
2321
- */
2322
- this.startPolling = () => {
2323
- this.poller.startPolling();
2324
- this.logger.info(
2325
- `TaskWorker ${this.worker.taskDefName} initialized with concurrency of ${this.poller.options.concurrency} and poll interval of ${this.poller.options.pollInterval}`
2326
- );
2327
- };
2328
- /**
2329
- * Stops Polling for work
2330
- */
2331
- this.stopPolling = async () => {
2332
- await this.poller.stopPolling();
2333
- };
2334
- this.batchPoll = async (count) => {
2335
- const { workerID } = this.options;
2336
- const tasks = await this.taskResource.batchPoll(
2337
- this.worker.taskDefName,
2338
- workerID,
2339
- this.worker.domain ?? this.options.domain,
2340
- count,
2341
- this.options.batchPollingTimeout ?? 100
2342
- // default batch poll defined in the method
2343
- );
2344
- return tasks;
2345
- };
2346
- this.updateTaskWithRetry = async (task, taskResult) => {
2347
- const { workerID } = this.options;
2348
- let retryCount = 0;
2349
- while (retryCount < MAX_RETRIES) {
2350
- try {
2351
- await this.taskResource.updateTask1({
2352
- ...taskResult,
2353
- workerId: workerID
2354
- });
2355
- return;
2356
- } catch (error) {
2357
- this.errorHandler(error, task);
2358
- this.logger.error(
2359
- `Error updating task ${taskResult.taskId} on retry ${retryCount}`,
2360
- error
2361
- );
2362
- retryCount++;
2363
- await new Promise((r) => setTimeout(() => r(true), retryCount * 10));
2364
- }
2365
- }
2366
- this.logger.error(
2367
- `Unable to update task ${taskResult.taskId} after ${retryCount} retries`
2368
- );
2369
- };
2370
- this.executeTask = async (task) => {
2371
- try {
2372
- const result = await this.worker.execute(task);
2373
- await this.updateTaskWithRetry(task, {
2374
- ...result,
2375
- workflowInstanceId: task.workflowInstanceId,
2376
- taskId: task.taskId
2377
- });
2378
- this.logger.debug(`Task has executed successfully ${task.taskId}`);
2379
- } catch (error) {
2380
- await this.updateTaskWithRetry(task, {
2381
- workflowInstanceId: task.workflowInstanceId,
2382
- taskId: task.taskId,
2383
- reasonForIncompletion: error?.message ?? DEFAULT_ERROR_MESSAGE,
2384
- status: "FAILED",
2385
- outputData: {}
2386
- });
2387
- this.errorHandler(error, task);
2388
- this.logger.error(`Error executing ${task.taskId}`, error);
2389
- }
2390
- };
2391
- this.handleUnknownError = (unknownError) => {
2392
- let message = "";
2393
- let stack = "";
2394
- if (unknownError.stack) {
2395
- stack = unknownError.stack;
2396
- }
2397
- if (unknownError.message) {
2398
- message = unknownError.message;
2399
- }
2400
- this.logger.error(
2401
- `Error for ${this.worker.taskDefName}: error: ${message}, stack: ${stack}`
2402
- );
2403
- };
2404
- this.taskResource = taskResource;
2405
- this.logger = logger;
2406
- this.worker = worker;
2407
- this.options = { ...defaultRunnerOptions, ...options };
2408
- this.errorHandler = errorHandler;
2409
- this.poller = new Poller(
2410
- worker.taskDefName,
2411
- this.batchPoll,
2412
- this.executeTask,
2413
- {
2414
- concurrency: worker.concurrency ?? options.concurrency,
2415
- pollInterval: worker.pollInterval ?? options.pollInterval
2416
- },
2417
- this.logger
2418
- );
2419
- }
2420
- get isPolling() {
2421
- return this.poller.isPolling;
2422
- }
2423
- updateOptions(options) {
2424
- const newOptions = { ...this.options, ...options };
2425
- const isOptionsUpdated = !optionEquals(this.options, newOptions);
2426
- if (isOptionsUpdated) {
2427
- this.poller.updateOptions({
2428
- concurrency: newOptions.concurrency,
2429
- pollInterval: newOptions.pollInterval
2430
- });
2431
- this.logger.info(
2432
- `TaskWorker ${this.worker.taskDefName} configuration updated with concurrency of ${this.poller.options.concurrency} and poll interval of ${this.poller.options.pollInterval}`
2433
- );
2434
- }
2435
- this.options = newOptions;
2436
- }
2437
- get getOptions() {
2438
- return this.options;
2439
- }
2440
- };
2441
-
2442
- // src/task/TaskManager.ts
2443
- import os from "os";
2444
- var defaultManagerOptions = {
2445
- workerID: "",
2446
- pollInterval: DEFAULT_POLL_INTERVAL,
2447
- domain: void 0,
2448
- concurrency: DEFAULT_CONCURRENCY,
2449
- batchPollingTimeout: DEFAULT_BATCH_POLLING_TIMEOUT
2450
- };
2451
- function workerId(options) {
2452
- return options.workerID ?? os.hostname();
2453
- }
2454
- var TaskManager = class {
2455
- constructor(client, workers, config = {}) {
2456
- this.workerRunners = /* @__PURE__ */ new Map();
2457
- this.polling = false;
2458
- this.workerManagerWorkerOptions = (worker) => {
2459
- return {
2460
- ...this.options,
2461
- concurrency: worker.concurrency ?? this.options.concurrency,
2462
- pollInterval: worker.pollInterval ?? this.options.pollInterval,
2463
- domain: worker.domain ?? this.options.domain
2464
- };
2465
- };
2466
- this.updatePollingOptionForWorker = (workerTaskDefName, options) => {
2467
- const maybeRunner = this.workerRunners.get(workerTaskDefName);
2468
- if (maybeRunner != null) {
2469
- maybeRunner.updateOptions(options);
2470
- } else {
2471
- this.logger.info(
2472
- `No runner found for worker with taskDefName: ${workerTaskDefName}`
2473
- );
2474
- }
2475
- };
2476
- /**
2477
- * new options will get merged to existing options
2478
- * @param options new options to update polling options
2479
- */
2480
- this.updatePollingOptions = (options) => {
2481
- this.workers.forEach((worker) => {
2482
- const newOptions = {
2483
- ...this.workerManagerWorkerOptions(worker),
2484
- ...options
2485
- };
2486
- this.updatePollingOptionForWorker(worker.taskDefName, newOptions);
2487
- });
2488
- this.options.concurrency = options.concurrency ?? this.options.concurrency;
2489
- this.options.pollInterval = options.pollInterval ?? this.options.pollInterval;
2490
- };
2491
- this.sanityCheck = () => {
2492
- if (this.workers.length === 0) {
2493
- throw new Error("No workers supplied to TaskManager");
2494
- }
2495
- const workerIDs = /* @__PURE__ */ new Set();
2496
- for (const item of this.workers) {
2497
- if (workerIDs.has(item.taskDefName)) {
2498
- throw new Error(`Duplicate worker taskDefName: ${item.taskDefName}`);
2499
- }
2500
- workerIDs.add(item.taskDefName);
2501
- }
2502
- };
2503
- /**
2504
- * Start polling for tasks
2505
- */
2506
- this.startPolling = () => {
2507
- this.sanityCheck();
2508
- this.workers.forEach((worker) => {
2509
- const options = this.workerManagerWorkerOptions(worker);
2510
- const runner = new TaskRunner({
2511
- worker,
2512
- options,
2513
- taskResource: this.client.taskResource,
2514
- logger: this.logger,
2515
- onError: this.errorHandler
2516
- });
2517
- runner.startPolling();
2518
- this.workerRunners.set(worker.taskDefName, runner);
2519
- });
2520
- this.polling = true;
2521
- };
2522
- /**
2523
- * Stops polling for tasks
2524
- */
2525
- this.stopPolling = async () => {
2526
- for (const [workerTaskDefName, runner] of this.workerRunners) {
2527
- this.logger.debug(`Stopping taskDefName=${workerTaskDefName}`);
2528
- await runner.stopPolling();
2529
- this.workerRunners.delete(workerTaskDefName);
2530
- }
2531
- this.polling = false;
2532
- };
2533
- if (!workers) {
2534
- throw new Error(
2535
- "No workers supplied to TaskManager. Please pass an array of workers."
2536
- );
2537
- }
2538
- this.client = client;
2539
- this.logger = config.logger ?? new DefaultLogger();
2540
- this.errorHandler = config.onError ?? noopErrorHandler;
2541
- this.workers = workers;
2542
- const providedOptions = config.options ?? {};
2543
- this.options = {
2544
- ...defaultManagerOptions,
2545
- ...providedOptions,
2546
- workerID: workerId(providedOptions)
2547
- };
2548
- }
2549
- get isPolling() {
2550
- return this.polling;
2551
- }
2552
- };
2553
-
2554
- // src/core/types.ts
2555
- var ConductorError = class extends Error {
2556
- constructor(message, innerError) {
2557
- super(message);
2558
- this._trace = innerError;
2559
- const actualProto = new.target.prototype;
2560
- if (Object.setPrototypeOf) {
2561
- Object.setPrototypeOf(this, actualProto);
2562
- } else {
2563
- this.__proto__ = actualProto;
2564
- }
2565
- }
2566
- };
2567
-
2568
- // src/core/helpers.ts
2569
- var errorMapper = (error) => new ConductorError(error?.body?.message, error);
2570
- var tryCatchReThrow = (fn) => {
2571
- try {
2572
- return fn();
2573
- } catch (error) {
2574
- throw errorMapper(error);
2575
- }
2576
- };
2577
- function reverseFind(array, predicate) {
2578
- for (let i = array.length - 1; i >= 0; i--) {
2579
- if (predicate(array[i], i, array)) {
2580
- return array[i];
2581
- }
2582
- }
2583
- return void 0;
2584
- }
2585
-
2586
- // src/core/executor.ts
2587
- var RETRY_TIME_IN_MILLISECONDS = 1e4;
2588
- var completedTaskMatchingType = (taskType) => (task) => task.status === "COMPLETED" && task.taskType === taskType;
2589
- var WorkflowExecutor = class {
2590
- constructor(client) {
2591
- this._client = client;
2592
- }
2593
- /**
2594
- * Will persist a workflow in conductor
2595
- * @param override If true will override the existing workflow with the definition
2596
- * @param workflow Complete workflow definition
2597
- * @returns null
2598
- */
2599
- registerWorkflow(override, workflow2) {
2600
- return tryCatchReThrow(
2601
- () => this._client.metadataResource.create(workflow2, override)
2602
- );
2603
- }
2604
- /**
2605
- * Takes a StartWorkflowRequest. returns a Promise<string> with the workflowInstanceId of the running workflow
2606
- * @param workflowRequest
2607
- * @returns
2608
- */
2609
- startWorkflow(workflowRequest) {
2610
- return tryCatchReThrow(
2611
- () => this._client.workflowResource.startWorkflow(workflowRequest)
2612
- );
2613
- }
2614
- /**
2615
- * Execute a workflow synchronously. returns a Promise<WorkflowRun> with details of the running workflow
2616
- * @param workflowRequest
2617
- * @returns
2618
- */
2619
- executeWorkflow(workflowRequest, name, version, requestId, waitUntilTaskRef = "") {
2620
- return tryCatchReThrow(
2621
- () => this._client.workflowResource.executeWorkflow(
2622
- workflowRequest,
2623
- name,
2624
- version,
2625
- requestId,
2626
- waitUntilTaskRef
2627
- )
2628
- );
2629
- }
2630
- startWorkflows(workflowsRequest) {
2631
- return tryCatchReThrow(() => workflowsRequest.map(this.startWorkflow));
2632
- }
2633
- async goBackToTask(workflowInstanceId, taskFinderPredicate, rerunWorkflowRequestOverrides = {}) {
2634
- const { tasks: executedTasks = [] } = await this.getExecution(
2635
- workflowInstanceId
2636
- );
2637
- const maybePreviousTask = reverseFind(
2638
- executedTasks,
2639
- taskFinderPredicate
2640
- );
2641
- if (!maybePreviousTask) {
2642
- throw new Error("Task not found");
2643
- }
2644
- await this.reRun(workflowInstanceId, {
2645
- //taskInput: previousTask.inputData,
2646
- ...rerunWorkflowRequestOverrides,
2647
- reRunFromTaskId: maybePreviousTask.taskId
2648
- });
2649
- }
2650
- async goBackToFirstTaskMatchingType(workflowInstanceId, taskType) {
2651
- return this.goBackToTask(workflowInstanceId, completedTaskMatchingType(taskType));
2652
- }
2653
- /**
2654
- * Takes an workflowInstanceId and an includeTasks and an optional retry parameter returns the whole execution status.
2655
- * If includeTasks flag is provided. Details of tasks execution will be returned as well,
2656
- * retry specifies the amount of retrys before throwing an error.
2657
- *
2658
- * @param workflowInstanceId
2659
- * @param includeTasks
2660
- * @param retry
2661
- * @returns
2662
- */
2663
- async getWorkflow(workflowInstanceId, includeTasks, retry = 0) {
2664
- try {
2665
- const workflowStatus = await this._client.workflowResource.getExecutionStatus(
2666
- workflowInstanceId,
2667
- includeTasks
2668
- );
2669
- return workflowStatus;
2670
- } catch (error) {
2671
- if (![500, 404, 403].includes(error.status) || retry === 0) {
2672
- throw errorMapper(error);
2673
- }
2674
- }
2675
- await new Promise(
2676
- (res) => setTimeout(() => res(true), RETRY_TIME_IN_MILLISECONDS)
2677
- );
2678
- return this.getWorkflow(workflowInstanceId, includeTasks, retry - 1);
2679
- }
2680
- /**
2681
- * Returns a summary of the current workflow status.
2682
- *
2683
- * @param workflowInstanceId current running workflow
2684
- * @param includeOutput flag to include output
2685
- * @param includeVariables flag to include variable
2686
- * @returns Promise<WorkflowStatus>
2687
- */
2688
- getWorkflowStatus(workflowInstanceId, includeOutput, includeVariables) {
2689
- return tryCatchReThrow(
2690
- () => this._client.workflowResource.getWorkflowStatusSummary(
2691
- workflowInstanceId,
2692
- includeOutput,
2693
- includeVariables
2694
- )
2695
- );
2696
- }
2697
- /**
2698
- * Returns a summary of the current workflow status.
2699
- *
2700
- * @param workflowInstanceId current running workflow
2701
- * @param includeOutput flag to include output
2702
- * @param includeVariables flag to include variable
2703
- * @returns Promise<WorkflowStatus>
2704
- */
2705
- getExecution(workflowInstanceId, includeTasks = true) {
2706
- return tryCatchReThrow(
2707
- () => this._client.workflowResource.getExecutionStatus(
2708
- workflowInstanceId,
2709
- includeTasks
2710
- )
2711
- );
2712
- }
2713
- /**
2714
- * Pauses a running workflow
2715
- * @param workflowInstanceId current workflow execution
2716
- * @returns
2717
- */
2718
- pause(workflowInstanceId) {
2719
- return tryCatchReThrow(
2720
- () => this._client.workflowResource.pauseWorkflow(workflowInstanceId)
2721
- );
2722
- }
2723
- /**
2724
- * Reruns workflowInstanceId workflow. with new parameters
2725
- *
2726
- * @param workflowInstanceId current workflow execution
2727
- * @param rerunWorkflowRequest Rerun Workflow Execution Request
2728
- * @returns
2729
- */
2730
- reRun(workflowInstanceId, rerunWorkflowRequest = {}) {
2731
- return tryCatchReThrow(
2732
- () => this._client.workflowResource.rerun(
2733
- workflowInstanceId,
2734
- rerunWorkflowRequest
2735
- )
2736
- );
2737
- }
2738
- /**
2739
- * Restarts workflow with workflowInstanceId, if useLatestDefinition uses last defintion
2740
- * @param workflowInstanceId
2741
- * @param useLatestDefinitions
2742
- * @returns
2743
- */
2744
- restart(workflowInstanceId, useLatestDefinitions) {
2745
- return tryCatchReThrow(
2746
- () => this._client.workflowResource.restart1(
2747
- workflowInstanceId,
2748
- useLatestDefinitions
2749
- )
2750
- );
2751
- }
2752
- /**
2753
- * Resumes a previously paused execution
2754
- *
2755
- * @param workflowInstanceId Running workflow workflowInstanceId
2756
- * @returns
2757
- */
2758
- resume(workflowInstanceId) {
2759
- return tryCatchReThrow(
2760
- () => this._client.workflowResource.resumeWorkflow(workflowInstanceId)
2761
- );
2762
- }
2763
- /**
2764
- * Retrys workflow from last failing task
2765
- * if resumeSubworkflowTasks is true will resume tasks in spawned subworkflows
2766
- *
2767
- * @param workflowInstanceId
2768
- * @param resumeSubworkflowTasks
2769
- * @returns
2770
- */
2771
- retry(workflowInstanceId, resumeSubworkflowTasks) {
2772
- return tryCatchReThrow(
2773
- () => this._client.workflowResource.retry1(
2774
- workflowInstanceId,
2775
- resumeSubworkflowTasks
2776
- )
2777
- );
2778
- }
2779
- /**
2780
- * Searches for existing workflows given the following querys
2781
- *
2782
- * @param start
2783
- * @param size
2784
- * @param query
2785
- * @param freeText
2786
- * @param sort
2787
- * @param skipCache
2788
- * @returns
2789
- */
2790
- search(start, size, query, freeText, sort = "", skipCache = false) {
2791
- const queryId = void 0;
2792
- return tryCatchReThrow(
2793
- () => this._client.workflowResource.search1(
2794
- queryId,
2795
- start,
2796
- size,
2797
- sort,
2798
- freeText,
2799
- query,
2800
- skipCache
2801
- )
2802
- );
2803
- }
2804
- /**
2805
- * Skips a task of a running workflow.
2806
- * by providing a skipTaskRequest you can set the input and the output of the skipped tasks
2807
- * @param workflowInstanceId
2808
- * @param taskReferenceName
2809
- * @param skipTaskRequest
2810
- * @returns
2811
- */
2812
- skipTasksFromWorkflow(workflowInstanceId, taskReferenceName, skipTaskRequest) {
2813
- return tryCatchReThrow(
2814
- () => this._client.workflowResource.skipTaskFromWorkflow(
2815
- workflowInstanceId,
2816
- taskReferenceName,
2817
- skipTaskRequest
2818
- )
2819
- );
2820
- }
2821
- /**
2822
- * Takes an workflowInstanceId, and terminates a running workflow
2823
- * @param workflowInstanceId
2824
- * @param reason
2825
- * @returns
2826
- */
2827
- terminate(workflowInstanceId, reason) {
2828
- return tryCatchReThrow(
2829
- () => this._client.workflowResource.terminate1(workflowInstanceId, reason)
2830
- );
2831
- }
2832
- /**
2833
- * Takes a taskId and a workflowInstanceId. Will update the task for the corresponding taskId
2834
- * @param taskId
2835
- * @param workflowInstanceId
2836
- * @param taskStatus
2837
- * @param taskOutput
2838
- * @returns
2839
- */
2840
- updateTask(taskId, workflowInstanceId, taskStatus, outputData) {
2841
- const taskUpdates = {
2842
- status: taskStatus,
2843
- taskId,
2844
- workflowInstanceId
2845
- };
2846
- return tryCatchReThrow(
2847
- () => this._client.taskResource.updateTask1({
2848
- outputData,
2849
- ...taskUpdates
2850
- })
2851
- );
2852
- }
2853
- /**
2854
- * Updates a task by reference Name
2855
- * @param taskReferenceName
2856
- * @param workflowInstanceId
2857
- * @param status
2858
- * @param taskOutput
2859
- * @returns
2860
- */
2861
- updateTaskByRefName(taskReferenceName, workflowInstanceId, status, taskOutput) {
2862
- return tryCatchReThrow(
2863
- () => this._client.taskResource.updateTask(
2864
- workflowInstanceId,
2865
- taskReferenceName,
2866
- status,
2867
- taskOutput
2868
- )
2869
- );
2870
- }
2871
- /**
2872
- *
2873
- * @param taskId
2874
- * @returns
2875
- */
2876
- getTask(taskId) {
2877
- return tryCatchReThrow(() => this._client.taskResource.getTask(taskId));
2878
- }
2879
- };
2880
-
2881
- // src/core/human.ts
2882
- var EMPTY_SEARCH = {
2883
- size: 15,
2884
- states: [],
2885
- taskInputQuery: "",
2886
- taskOutputQuery: "",
2887
- definitionNames: [],
2888
- taskRefNames: [],
2889
- claimants: [],
2890
- assignees: [],
2891
- start: 0
2892
- };
2893
- var DEFAULT_POLL_INTERVAL2 = { pollInterval: 100, maxPollTimes: 20 };
2894
- var HumanExecutor = class {
2895
- constructor(client) {
2896
- this._client = client;
2897
- }
2898
- /**
2899
- * @deprecated use search instead
2900
- * Takes a set of filter parameters. return matches of human tasks for that set of parameters
2901
- * @param state
2902
- * @param assignee
2903
- * @param assigneeType
2904
- * @param claimedBy
2905
- * @param taskName
2906
- * @param freeText
2907
- * @param includeInputOutput
2908
- * @returns
2909
- */
2910
- async getTasksByFilter(state, assignee, assigneeType, claimedBy, taskName, taskInputQuery, taskOutputQuery) {
2911
- const [claimedUserType, claimedUser] = claimedBy?.split(":") ?? [];
2912
- if (claimedUserType && !claimedUser) {
2913
- throw new Error("claimedBy should be in the format of <userType>:<user>");
2914
- }
2915
- const response = await this.search({
2916
- states: [state],
2917
- assignees: assignee ? [{ userType: assigneeType, user: assignee }] : [],
2918
- claimants: claimedBy ? [{ userType: claimedUserType, user: claimedUser }] : [],
2919
- taskRefNames: taskName ? [taskName] : [],
2920
- taskInputQuery,
2921
- taskOutputQuery
2922
- });
2923
- return response;
2924
- }
2925
- /**
2926
- * Takes a set of filter parameters. return matches of human tasks for that set of parameters
2927
- * @param state
2928
- * @param assignee
2929
- * @param assigneeType
2930
- * @param claimedBy
2931
- * @param taskName
2932
- * @param freeText
2933
- * @param includeInputOutput
2934
- * @returns Promise<HumanTaskEntry[]>
2935
- */
2936
- async search(searchParams) {
2937
- const search = { ...EMPTY_SEARCH, ...searchParams };
2938
- const response = await tryCatchReThrow(
2939
- () => this._client.humanTask.search(search)
2940
- );
2941
- if (response.results != void 0) {
2942
- return response.results;
2943
- }
2944
- return [];
2945
- }
2946
- /**
2947
- * Takes a set of filter parameters. An polling interval options. will poll until the task returns a result
2948
- * @param state
2949
- * @param assignee
2950
- * @param assigneeType
2951
- * @param claimedBy
2952
- * @param taskName
2953
- * @param freeText
2954
- * @param includeInputOutput
2955
- * @returns Promise<HumanTaskEntry[]>
2956
- */
2957
- async pollSearch(searchParams, {
2958
- pollInterval = 100,
2959
- maxPollTimes = 20
2960
- } = DEFAULT_POLL_INTERVAL2) {
2961
- let pollCount = 0;
2962
- while (pollCount < maxPollTimes) {
2963
- const response = await this.search(searchParams);
2964
- if (response.length > 0) {
2965
- return response;
2966
- }
2967
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
2968
- pollCount++;
2969
- }
2970
- return [];
2971
- }
2972
- /**
2973
- * Returns task for a given task id
2974
- * @param taskId
2975
- * @returns
2976
- */
2977
- getTaskById(taskId) {
2978
- return tryCatchReThrow(() => this._client.humanTask.getTask1(taskId));
2979
- }
2980
- /**
2981
- * Assigns taskId to assignee. If the task is already assigned to another user, this will fail.
2982
- * @param taskId
2983
- * @param assignee
2984
- * @returns
2985
- */
2986
- async claimTaskAsExternalUser(taskId, assignee) {
2987
- return tryCatchReThrow(
2988
- () => this._client.humanTask.assignAndClaim(taskId, assignee)
2989
- );
2990
- }
2991
- /**
2992
- * Claim task as conductor user
2993
- * @param taskId
2994
- * @returns
2995
- */
2996
- async claimTaskAsConductorUser(taskId) {
2997
- return tryCatchReThrow(() => this._client.humanTask.claimTask(taskId));
2998
- }
2999
- /**
3000
- * Claim task as conductor user
3001
- * @param taskId
3002
- * @param assignee
3003
- * @returns
3004
- */
3005
- async releaseTask(taskId) {
3006
- try {
3007
- await this._client.humanTask.releaseTask(taskId);
3008
- } catch (error) {
3009
- throw errorMapper(error);
3010
- }
3011
- }
3012
- /**
3013
- * Returns a HumanTaskTemplateEntry for a given name and version
3014
- * @param templateId
3015
- * @returns
3016
- */
3017
- async getTemplateByNameVersion(name, version) {
3018
- return tryCatchReThrow(
3019
- () => this._client.humanTask.getTemplateByNameAndVersion(name, version)
3020
- );
3021
- }
3022
- /**
3023
- * @deprecated use getTemplate instead. name will be used as id here with version 1
3024
- * Returns a HumanTaskTemplateEntry for a given templateId
3025
- * @param templateId
3026
- * @returns
3027
- */
3028
- async getTemplateById(templateNameVersionOne) {
3029
- return this.getTemplateByNameVersion(templateNameVersionOne, 1);
3030
- }
3031
- /**
3032
- * Takes a taskId and a partial body. will update with given body
3033
- * @param taskId
3034
- * @param requestBody
3035
- */
3036
- async updateTaskOutput(taskId, requestBody) {
3037
- try {
3038
- await this._client.humanTask.updateTaskOutput(taskId, requestBody, false);
3039
- } catch (error) {
3040
- throw errorMapper(error);
3041
- }
3042
- }
3043
- /**
3044
- * Takes a taskId and an optional partial body. will complete the task with the given body
3045
- * @param taskId
3046
- * @param requestBody
3047
- */
3048
- async completeTask(taskId, requestBody = {}) {
3049
- try {
3050
- await this._client.humanTask.updateTaskOutput(taskId, requestBody, true);
3051
- } catch (error) {
3052
- throw errorMapper(error);
3053
- }
3054
- }
3055
- };
3056
-
3057
- // src/core/sdk/doWhile.ts
3058
- var doWhileTask = (taskRefName, terminationCondition, tasks) => ({
3059
- name: taskRefName,
3060
- taskReferenceName: taskRefName,
3061
- loopCondition: terminationCondition,
3062
- inputParameters: {},
3063
- type: "DO_WHILE" /* DO_WHILE */,
3064
- loopOver: tasks
3065
- });
3066
- var loopForCondition = (taskRefName, valueKey) => `if ( $.${taskRefName}['iteration'] < $.${valueKey} ) { true; } else { false; }`;
3067
- var newLoopTask = (taskRefName, iterations, tasks) => ({
3068
- name: taskRefName,
3069
- taskReferenceName: taskRefName,
3070
- loopCondition: loopForCondition(taskRefName, "value"),
3071
- inputParameters: {
3072
- value: iterations
3073
- },
3074
- type: "DO_WHILE" /* DO_WHILE */,
3075
- loopOver: tasks
3076
- });
3077
-
3078
- // src/core/sdk/dynamicFork.ts
3079
- var dynamicForkTask = (taskReferenceName, preForkTasks = [], dynamicTasksInput = "") => ({
3080
- name: taskReferenceName,
3081
- taskReferenceName,
3082
- inputParameters: {
3083
- dynamicTasks: preForkTasks,
3084
- dynamicTasksInput
3085
- },
3086
- type: "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */,
3087
- dynamicForkTasksParam: "dynamicTasks",
3088
- dynamicForkTasksInputParamName: "dynamicTasksInput"
3089
- });
3090
-
3091
- // src/core/sdk/event.ts
3092
- var eventTask = (taskReferenceName, eventPrefix, eventSuffix) => ({
3093
- name: taskReferenceName,
3094
- taskReferenceName,
3095
- sink: `${eventPrefix}:${eventSuffix}`,
3096
- type: "EVENT" /* EVENT */
3097
- });
3098
- var sqsEventTask = (taskReferenceName, queueName) => eventTask(taskReferenceName, "sqs", queueName);
3099
- var conductorEventTask = (taskReferenceName, eventName) => eventTask(taskReferenceName, "conductor", eventName);
3100
-
3101
- // src/core/generators/common.ts
3102
- var randomChars = (n = 7) => (Math.random() + 1).toString(36).substring(n);
3103
- var taskNameGenerator = (taskType) => `${taskType}__task_${randomChars(7)}`;
3104
- var taskReferenceNameGenerator = (taskName) => `${taskName}_ref`;
3105
- var nameTaskNameGenerator = (taskType, maybeOverrides = {}) => {
3106
- const name = maybeOverrides?.name ?? taskNameGenerator(taskType);
3107
- return {
3108
- name,
3109
- taskReferenceName: taskReferenceNameGenerator(name)
3110
- };
3111
- };
3112
- function mapArrValues(arrayTransformer, mapWithValues) {
3113
- return Object.fromEntries(
3114
- Object.entries(mapWithValues).map(([key, value]) => [
3115
- key,
3116
- arrayTransformer(value)
3117
- ])
3118
- );
3119
- }
3120
-
3121
- // src/core/generators/SimpleTask.ts
3122
- var generateSimpleTask = (overrides = {}) => ({
3123
- ...nameTaskNameGenerator("simple", overrides),
3124
- inputParameters: {},
3125
- ...overrides,
3126
- type: "SIMPLE" /* SIMPLE */
3127
- });
3128
-
3129
- // src/core/generators/DoWhileTask.ts
3130
- var generateDoWhileTask = (overrides = {}, nestedTasksMapper) => ({
3131
- ...nameTaskNameGenerator("doWhile", overrides),
3132
- inputParameters: {},
3133
- startDelay: 0,
3134
- optional: false,
3135
- asyncComplete: false,
3136
- loopCondition: "",
3137
- ...overrides,
3138
- loopOver: nestedTasksMapper(overrides?.loopOver || []),
3139
- type: "DO_WHILE" /* DO_WHILE */
3140
- });
3141
-
3142
- // src/core/generators/EventTask.ts
3143
- var generateEventTask = (overrides = {}) => ({
3144
- ...nameTaskNameGenerator("event", overrides),
3145
- sink: "sqs:sqs_queue_name",
3146
- asyncComplete: false,
3147
- ...overrides,
3148
- type: "EVENT" /* EVENT */
3149
- });
3150
-
3151
- // src/core/generators/ForkJoin.ts
3152
- var generateForkJoinTask = (overrides = {}, nestedMapper) => ({
3153
- ...nameTaskNameGenerator("forkJoin", overrides),
3154
- inputParameters: {},
3155
- ...overrides,
3156
- type: "FORK_JOIN" /* FORK_JOIN */,
3157
- forkTasks: (overrides?.forkTasks || []).map(nestedMapper)
3158
- });
3159
- var generateJoinTask = (overrides = {}) => ({
3160
- ...nameTaskNameGenerator("join", overrides),
3161
- inputParameters: {},
3162
- joinOn: [],
3163
- optional: false,
3164
- asyncComplete: false,
3165
- ...overrides,
3166
- type: "JOIN" /* JOIN */
3167
- });
3168
-
3169
- // src/core/generators/HttpTask.ts
3170
- var generateHTTPTask = (overrides = {}) => ({
3171
- ...nameTaskNameGenerator("httpTask", overrides),
3172
- inputParameters: {
3173
- http_request: {
3174
- uri: "https://jsonplaceholder.typicode.com/posts/${workflow.input.queryid}",
3175
- method: "GET"
3176
- }
3177
- },
3178
- ...overrides,
3179
- type: "HTTP" /* HTTP */
3180
- });
3181
-
3182
- // src/core/generators/InlineTask.ts
3183
- var defaultInputParams = {
3184
- value: "${workflow.input.value}",
3185
- evaluatorType: "graaljs",
3186
- expression: "true"
3187
- };
3188
- var generateEvaluationCode = (inputParametersPartial = {}) => {
3189
- const inlinePartialDefJavascript = inputParametersPartial;
3190
- const inlineExpression = inlinePartialDefJavascript?.expression;
3191
- if (inlineExpression !== void 0 && typeof inlineExpression === "function") {
3192
- const resultingFunction = inlineExpression();
3193
- const resultingFunctionAsString = resultingFunction.toString();
3194
- const toReturn = {
3195
- evaluatorType: "graaljs",
3196
- ...inputParametersPartial || { value: "true" },
3197
- expression: `(${resultingFunctionAsString})();`
3198
- };
3199
- return toReturn;
3200
- }
3201
- return {
3202
- ...defaultInputParams,
3203
- evaluatorType: "graaljs",
3204
- ...inputParametersPartial
3205
- };
3206
- };
3207
- var generateInlineTask = (override = {}) => ({
3208
- ...nameTaskNameGenerator("inline", override),
3209
- ...override,
3210
- inputParameters: generateEvaluationCode(override?.inputParameters || {}),
3211
- type: "INLINE" /* INLINE */
3212
- });
3213
-
3214
- // src/core/generators/JsonJQTransform.ts
3215
- var generateJQTransformTask = (overrides = {}) => ({
3216
- ...nameTaskNameGenerator("jqTransform", overrides),
3217
- inputParameters: {
3218
- key1: {
3219
- value1: ["a", "b"]
3220
- },
3221
- key2: {
3222
- value2: ["c", "d"]
3223
- },
3224
- queryExpression: "{ key3: (.key1.value1 + .key2.value2) }"
3225
- },
3226
- ...overrides,
3227
- type: "JSON_JQ_TRANSFORM" /* JSON_JQ_TRANSFORM */
3228
- });
3229
-
3230
- // src/core/generators/KafkaTask.ts
3231
- var generateKafkaPublishTask = (overrides = {}) => ({
3232
- ...nameTaskNameGenerator("kafka", overrides),
3233
- inputParameters: {
3234
- kafka_request: {
3235
- topic: "topic",
3236
- value: "",
3237
- bootStrapServers: "localhost:9092",
3238
- headers: {},
3239
- key: "123",
3240
- keySerializer: "org.apache.kafka.common.serialization.IntegerSerializer"
3241
- }
3242
- },
3243
- ...overrides,
3244
- type: "KAFKA_PUBLISH" /* KAFKA_PUBLISH */
3245
- });
3246
-
3247
- // src/core/generators/SubWorkflowTask.ts
3248
- var generateSubWorkflowTask = (overrides = {}) => ({
3249
- ...nameTaskNameGenerator("subWorkflow", overrides),
3250
- inputParameters: {},
3251
- subWorkflowParam: {
3252
- name: "name",
3253
- version: 1,
3254
- taskToDomain: {}
3255
- },
3256
- ...overrides,
3257
- type: "SUB_WORKFLOW" /* SUB_WORKFLOW */
3258
- });
3259
-
3260
- // src/core/generators/SetVariableTask.ts
3261
- var generateSetVariableTask = (overrides = {}) => ({
3262
- ...nameTaskNameGenerator("setVariable", overrides),
3263
- inputParameters: {},
3264
- ...overrides,
3265
- type: "SET_VARIABLE" /* SET_VARIABLE */
3266
- });
3267
-
3268
- // src/core/generators/TerminateTask.ts
3269
- var generateTerminateTask = (overrides = {}) => ({
3270
- ...nameTaskNameGenerator("terminate", overrides),
3271
- inputParameters: {
3272
- terminationStatus: "COMPLETED",
3273
- workflowOutput: {}
3274
- },
3275
- startDelay: 0,
3276
- optional: false,
3277
- ...overrides,
3278
- type: "TERMINATE" /* TERMINATE */
3279
- });
3280
-
3281
- // src/core/generators/WaitTask.ts
3282
- var generateWaitTask = (overrides = {}) => ({
3283
- ...nameTaskNameGenerator("wait", overrides),
3284
- ...overrides,
3285
- inputParameters: {},
3286
- type: "WAIT" /* WAIT */
3287
- });
3288
-
3289
- // src/core/generators/SwitchTask.ts
3290
- var fillSwitchTaskBranches = (task, mapper) => ({
3291
- decisionCases: mapArrValues(mapper, task?.decisionCases || {}),
3292
- defaultCase: mapper(task?.defaultCase || [])
3293
- });
3294
- var generateSwitchTask = (overrides = {}, nestedTasksMapper) => ({
3295
- ...nameTaskNameGenerator("switch", overrides),
3296
- inputParameters: {
3297
- switchCaseValue: ""
3298
- },
3299
- evaluatorType: "value-param",
3300
- expression: "switchCaseValue",
3301
- ...overrides,
3302
- ...fillSwitchTaskBranches(overrides, nestedTasksMapper),
3303
- type: "SWITCH" /* SWITCH */
3304
- });
3305
-
3306
- // src/core/generators/WorkflowGenerator.ts
3307
- var workflowGenerator = (overrides) => ({
3308
- name: "NewWorkflow_3nxbi",
3309
- description: "Edit or extend this sample workflow. Set the workflow name to get started",
3310
- version: 1,
3311
- tasks: [],
3312
- inputParameters: [],
3313
- outputParameters: {},
3314
- schemaVersion: 2,
3315
- restartable: true,
3316
- workflowStatusListenerEnabled: false,
3317
- ownerEmail: "james.stuart@orkes.io",
3318
- timeoutPolicy: "ALERT_ONLY",
3319
- timeoutSeconds: 0,
3320
- ...overrides
3321
- });
3322
-
3323
- // src/core/generators/ForkJoinDynamicTask.ts
3324
- var generateForkJoinDynamic = (overrides = {}) => ({
3325
- ...nameTaskNameGenerator("forkJoinDynamic", overrides),
3326
- inputParameters: {
3327
- dynamicTasks: "",
3328
- dynamicTasksInput: ""
3329
- },
3330
- dynamicForkTasksParam: "dynamicTasks",
3331
- dynamicForkTasksInputParamName: "dynamicTasksInput",
3332
- startDelay: 0,
3333
- optional: false,
3334
- asyncComplete: false,
3335
- ...overrides,
3336
- type: "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */
3337
- });
3338
-
3339
- // src/core/generators/generator.ts
3340
- var filledTaskDef = (task) => {
3341
- const taskType = task.type;
3342
- switch (taskType) {
3343
- case "SWITCH" /* SWITCH */:
3344
- return generateSwitchTask(task, taskGenMapper);
3345
- case "SIMPLE" /* SIMPLE */:
3346
- return generateSimpleTask(task);
3347
- case "DO_WHILE" /* DO_WHILE */:
3348
- return generateDoWhileTask(task, taskGenMapper);
3349
- case "EVENT" /* EVENT */:
3350
- return generateEventTask(task);
3351
- case "FORK_JOIN" /* FORK_JOIN */:
3352
- return generateForkJoinTask(task, taskGenMapper);
3353
- case "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */:
3354
- return generateForkJoinDynamic(task);
3355
- case "HTTP" /* HTTP */:
3356
- return generateHTTPTask(task);
3357
- case "INLINE" /* INLINE */:
3358
- return generateInlineTask(task);
3359
- case "JOIN" /* JOIN */:
3360
- return generateJoinTask(task);
3361
- case "JSON_JQ_TRANSFORM" /* JSON_JQ_TRANSFORM */:
3362
- return generateJQTransformTask(task);
3363
- case "KAFKA_PUBLISH" /* KAFKA_PUBLISH */:
3364
- return generateKafkaPublishTask(task);
3365
- case "SUB_WORKFLOW" /* SUB_WORKFLOW */:
3366
- return generateSubWorkflowTask(task);
3367
- case "SET_VARIABLE" /* SET_VARIABLE */:
3368
- return generateSetVariableTask(task);
3369
- case "TERMINATE" /* TERMINATE */:
3370
- return generateTerminateTask(task);
3371
- case "WAIT" /* WAIT */:
3372
- return generateWaitTask(task);
3373
- default:
3374
- return generateSimpleTask(task);
3375
- }
3376
- };
3377
- var taskGenMapper = (tasks) => tasks.reduce((acc, task, idx) => {
3378
- const filledTask = filledTaskDef(task);
3379
- const maybeNextTask = tasks.length >= idx + 1 ? tasks[idx + 1] : void 0;
3380
- return acc.concat(maybeAddJoinTask(filledTask, maybeNextTask));
3381
- }, []);
3382
- var maybeAddJoinTask = (currentTask, maybeNextTask) => {
3383
- if ((currentTask.type === "FORK_JOIN" /* FORK_JOIN */ || currentTask.type === "FORK_JOIN_DYNAMIC" /* FORK_JOIN_DYNAMIC */) && maybeNextTask != null && maybeNextTask.type !== "JOIN" /* JOIN */) {
3384
- return [currentTask, generateJoinTask({})];
3385
- }
3386
- return currentTask;
3387
- };
3388
- var generate = (overrides) => {
3389
- const maybeTasks = overrides.tasks || [];
3390
- const generatedTasks = taskGenMapper(maybeTasks);
3391
- return workflowGenerator({ ...overrides, tasks: generatedTasks });
3392
- };
3393
-
3394
- // src/core/generators/index.ts
3395
- var generateSwitchTask2 = (overrides = {}, nestedTasksMapper = taskGenMapper) => generateSwitchTask(overrides, nestedTasksMapper);
3396
- var generateDoWhileTask2 = (overrides = {}, nestedTasksMapper = taskGenMapper) => generateDoWhileTask(overrides, nestedTasksMapper);
3397
- var generateForkJoinTask2 = (overrides = {}, nestedMapper = taskGenMapper) => generateForkJoinTask(overrides, nestedMapper);
3398
-
3399
- // src/core/sdk/forkJoin.ts
3400
- var forkTask = (taskReferenceName, forkTasks) => ({
3401
- taskReferenceName,
3402
- name: taskReferenceName,
3403
- type: "FORK_JOIN" /* FORK_JOIN */,
3404
- forkTasks: [forkTasks]
3405
- });
3406
- var forkTaskJoin = (taskReferenceName, forkTasks) => [
3407
- forkTask(taskReferenceName, forkTasks),
3408
- generateJoinTask({ name: `${taskReferenceName}_join` })
3409
- ];
3410
-
3411
- // src/core/sdk/http.ts
3412
- var httpTask = (taskReferenceName, inputParameters) => ({
3413
- name: taskReferenceName,
3414
- taskReferenceName,
3415
- inputParameters: {
3416
- http_request: inputParameters
3417
- },
3418
- type: "HTTP" /* HTTP */
3419
- });
3420
-
3421
- // src/core/sdk/inline.ts
3422
- var inlineTask = (taskReferenceName, script, evaluatorType = "javascript") => ({
3423
- name: taskReferenceName,
3424
- taskReferenceName,
3425
- inputParameters: {
3426
- evaluatorType,
3427
- expression: script
3428
- },
3429
- type: "INLINE" /* INLINE */
3430
- });
3431
-
3432
- // src/core/sdk/join.ts
3433
- var joinTask = (taskReferenceName, joinOn) => ({
3434
- name: taskReferenceName,
3435
- taskReferenceName,
3436
- joinOn,
3437
- type: "JOIN" /* JOIN */
3438
- });
3439
-
3440
- // src/core/sdk/jsonJq.ts
3441
- var jsonJqTask = (taskReferenceName, script) => ({
3442
- name: taskReferenceName,
3443
- taskReferenceName,
3444
- type: "JSON_JQ_TRANSFORM" /* JSON_JQ_TRANSFORM */,
3445
- inputParameters: {
3446
- queryExpression: script
3447
- }
3448
- });
3449
-
3450
- // src/core/sdk/kafkaPublish.ts
3451
- var kafkaPublishTask = (taskReferenceName, kafka_request) => ({
3452
- taskReferenceName,
3453
- name: taskReferenceName,
3454
- type: "KAFKA_PUBLISH" /* KAFKA_PUBLISH */,
3455
- inputParameters: {
3456
- kafka_request
3457
- }
3458
- });
3459
-
3460
- // src/core/sdk/setVariable.ts
3461
- var setVariableTask = (taskReferenceName, inputParameters) => ({
3462
- name: taskReferenceName,
3463
- taskReferenceName,
3464
- type: "SET_VARIABLE" /* SET_VARIABLE */,
3465
- inputParameters
3466
- });
3467
-
3468
- // src/core/sdk/simple.ts
3469
- var simpleTask = (taskReferenceName, name, inputParameters) => ({
3470
- name,
3471
- taskReferenceName,
3472
- inputParameters,
3473
- type: "SIMPLE" /* SIMPLE */
3474
- });
3475
-
3476
- // src/core/sdk/subWorkflow.ts
3477
- var subWorkflowTask = (taskReferenceName, workflowName, version) => ({
3478
- name: taskReferenceName,
3479
- taskReferenceName,
3480
- subWorkflowParam: {
3481
- name: workflowName,
3482
- version
3483
- },
3484
- type: "SUB_WORKFLOW" /* SUB_WORKFLOW */
3485
- });
3486
-
3487
- // src/core/sdk/switch.ts
3488
- var switchTask = (taskReferenceName, expression, decisionCases = {}, defaultCase = []) => ({
3489
- name: taskReferenceName,
3490
- taskReferenceName,
3491
- decisionCases,
3492
- evaluatorType: "value-param",
3493
- inputParameters: {
3494
- switchCaseValue: expression
3495
- },
3496
- expression: "switchCaseValue",
3497
- defaultCase,
3498
- type: "SWITCH" /* SWITCH */
3499
- });
3500
-
3501
- // src/core/sdk/terminate.ts
3502
- var terminateTask = (taskReferenceName, status, terminationReason) => ({
3503
- name: taskReferenceName,
3504
- taskReferenceName,
3505
- inputParameters: {
3506
- terminationStatus: status,
3507
- terminationReason
3508
- },
3509
- type: "TERMINATE" /* TERMINATE */
3510
- });
3511
-
3512
- // src/core/sdk/wait.ts
3513
- var waitTaskDuration = (taskReferenceName, duration) => ({
3514
- name: taskReferenceName,
3515
- taskReferenceName,
3516
- inputParameters: {
3517
- duration
3518
- },
3519
- type: "WAIT" /* WAIT */
3520
- });
3521
- var waitTaskUntil = (taskReferenceName, until) => ({
3522
- name: taskReferenceName,
3523
- taskReferenceName,
3524
- inputParameters: {
3525
- until
3526
- },
3527
- type: "WAIT" /* WAIT */
3528
- });
3529
-
3530
- // src/core/sdk/workflow.ts
3531
- var workflow = (name, tasks) => ({
3532
- name,
3533
- version: 1,
3534
- tasks,
3535
- inputParameters: [],
3536
- timeoutSeconds: 0
3537
- });
3538
-
3539
- // src/orkes/BaseOrkesConductorClient.ts
3540
- var defaultRequestHandler2 = (request2, config, options) => request2(config, options);
3541
- var REFRESH_TOKEN_IN_MILLISECONDS = 30 * 60 * 1e3;
3542
- var AuthConductorClient = class extends ConductorClient {
3543
- constructor(config, requestHandler = defaultRequestHandler2) {
3544
- super(config, requestHandler);
3545
- }
3546
- /**
3547
- * Stops the interval that refreshes the token
3548
- */
3549
- stop() {
3550
- if (this.intervalId != null) {
3551
- clearInterval(this.intervalId);
3552
- }
3553
- }
3554
- };
3555
- var baseOrkesConductorClient = (fetchFn, baseRequestHandler = defaultRequestHandler2) => {
3556
- const requestTokenForKeySecret = (keyId, keySecret, tokenUrl) => fetchFn(tokenUrl, {
3557
- headers: {
3558
- "Content-Type": "application/json",
3559
- Accept: "application/json"
3560
- },
3561
- body: JSON.stringify({ keyId, keySecret }),
3562
- method: "POST"
3563
- });
3564
- return async (config, requestHandler = baseRequestHandler) => {
3565
- if (config?.keySecret != null && config?.keyId != null) {
3566
- const {
3567
- serverUrl,
3568
- keyId,
3569
- keySecret,
3570
- refreshTokenInterval = REFRESH_TOKEN_IN_MILLISECONDS
3571
- } = config;
3572
- const tokenUrl = `${serverUrl}/token`;
3573
- const res = await requestTokenForKeySecret(keyId, keySecret, tokenUrl);
3574
- const { token } = await res.json();
3575
- const conductorClientInstance = new AuthConductorClient(
3576
- { ...config, TOKEN: token },
3577
- requestHandler
3578
- );
3579
- if (token != null && refreshTokenInterval > 0) {
3580
- const intervalId = setInterval(async () => {
3581
- const res2 = await requestTokenForKeySecret(
3582
- keyId,
3583
- keySecret,
3584
- tokenUrl
3585
- );
3586
- const { token: token2 } = await res2.json();
3587
- conductorClientInstance.token = token2;
3588
- }, refreshTokenInterval);
3589
- conductorClientInstance.intervalId = intervalId;
3590
- }
3591
- return conductorClientInstance;
3592
- } else {
3593
- return new ConductorClient(config, requestHandler);
3594
- }
3595
- };
3596
- };
3597
-
3598
- // src/orkes/BrowserOrkesConductorClient.ts
3599
- var defaultRequestHandler3 = (request2, config, options) => request2(config, options);
3600
- var orkesConductorClient = baseOrkesConductorClient(
3601
- fetch,
3602
- defaultRequestHandler3
3603
- );
3604
- export {
3605
- ApiError,
3606
- BaseHttpRequest,
3607
- CancelError,
3608
- CancelablePromise,
3609
- ConductorClient,
3610
- ConductorError,
3611
- DefaultLogger,
3612
- EventResourceService,
3613
- HealthCheckResourceService,
3614
- HumanExecutor,
3615
- MetadataResourceService,
3616
- SchedulerResourceService,
3617
- TaskManager,
3618
- TaskResourceService,
3619
- TaskRunner,
3620
- TaskType,
3621
- TokenResourceService,
3622
- WorkflowBulkResourceService,
3623
- WorkflowExecutor,
3624
- WorkflowResourceService,
3625
- completedTaskMatchingType,
3626
- conductorEventTask,
3627
- doWhileTask,
3628
- dynamicForkTask,
3629
- eventTask,
3630
- forkTask,
3631
- forkTaskJoin,
3632
- generate,
3633
- generateDoWhileTask2 as generateDoWhileTask,
3634
- generateEventTask,
3635
- generateForkJoinTask2 as generateForkJoinTask,
3636
- generateHTTPTask,
3637
- generateInlineTask,
3638
- generateJQTransformTask,
3639
- generateJoinTask,
3640
- generateKafkaPublishTask,
3641
- generateSetVariableTask,
3642
- generateSimpleTask,
3643
- generateSubWorkflowTask,
3644
- generateSwitchTask2 as generateSwitchTask,
3645
- generateTerminateTask,
3646
- generateWaitTask,
3647
- httpTask,
3648
- inlineTask,
3649
- joinTask,
3650
- jsonJqTask,
3651
- kafkaPublishTask,
3652
- newLoopTask,
3653
- noopErrorHandler,
3654
- noopLogger,
3655
- orkesConductorClient,
3656
- setVariableTask,
3657
- simpleTask,
3658
- sqsEventTask,
3659
- subWorkflowTask,
3660
- switchTask,
3661
- taskGenMapper,
3662
- terminateTask,
3663
- waitTaskDuration,
3664
- waitTaskUntil,
3665
- workflow
3666
- };
3667
- //# sourceMappingURL=browser.mjs.map