@hotmeshio/hotmesh 0.0.12 → 0.0.14

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.
Files changed (82) hide show
  1. package/README.md +2 -2
  2. package/build/modules/errors.d.ts +22 -1
  3. package/build/modules/errors.js +28 -1
  4. package/build/modules/utils.d.ts +2 -1
  5. package/build/modules/utils.js +5 -1
  6. package/build/package.json +7 -2
  7. package/build/services/activities/activity.d.ts +2 -0
  8. package/build/services/activities/activity.js +16 -10
  9. package/build/services/activities/await.d.ts +2 -6
  10. package/build/services/activities/await.js +12 -75
  11. package/build/services/activities/cycle.js +2 -2
  12. package/build/services/activities/index.d.ts +2 -2
  13. package/build/services/activities/index.js +2 -2
  14. package/build/services/activities/signal.d.ts +16 -0
  15. package/build/services/activities/signal.js +94 -0
  16. package/build/services/activities/trigger.js +4 -3
  17. package/build/services/activities/worker.d.ts +2 -1
  18. package/build/services/activities/worker.js +11 -6
  19. package/build/services/compiler/deployer.js +3 -1
  20. package/build/services/durable/client.d.ts +3 -2
  21. package/build/services/durable/client.js +39 -21
  22. package/build/services/durable/factory.d.ts +22 -18
  23. package/build/services/durable/factory.js +722 -50
  24. package/build/services/durable/handle.d.ts +1 -0
  25. package/build/services/durable/handle.js +5 -1
  26. package/build/services/durable/worker.d.ts +3 -8
  27. package/build/services/durable/worker.js +75 -73
  28. package/build/services/durable/workflow.d.ts +5 -0
  29. package/build/services/durable/workflow.js +93 -24
  30. package/build/services/engine/index.d.ts +6 -6
  31. package/build/services/engine/index.js +25 -15
  32. package/build/services/hotmesh/index.d.ts +2 -1
  33. package/build/services/hotmesh/index.js +3 -1
  34. package/build/services/mapper/index.js +1 -1
  35. package/build/services/pipe/functions/array.d.ts +1 -0
  36. package/build/services/pipe/functions/array.js +3 -0
  37. package/build/services/reporter/index.js +9 -2
  38. package/build/services/signaler/store.js +8 -3
  39. package/build/services/signaler/stream.js +3 -3
  40. package/build/services/store/clients/ioredis.js +15 -15
  41. package/build/services/store/clients/redis.js +18 -18
  42. package/build/services/store/index.d.ts +1 -1
  43. package/build/services/store/index.js +11 -3
  44. package/build/services/task/index.js +3 -3
  45. package/build/types/activity.d.ts +15 -6
  46. package/build/types/durable.d.ts +15 -2
  47. package/build/types/index.d.ts +2 -2
  48. package/build/types/stats.d.ts +1 -0
  49. package/modules/errors.ts +35 -0
  50. package/modules/utils.ts +5 -1
  51. package/package.json +7 -2
  52. package/services/activities/activity.ts +19 -9
  53. package/services/activities/await.ts +14 -90
  54. package/services/activities/cycle.ts +2 -2
  55. package/services/activities/index.ts +2 -2
  56. package/services/activities/signal.ts +124 -0
  57. package/services/activities/trigger.ts +4 -3
  58. package/services/activities/worker.ts +13 -13
  59. package/services/compiler/deployer.ts +3 -1
  60. package/services/durable/client.ts +48 -23
  61. package/services/durable/factory.ts +723 -49
  62. package/services/durable/handle.ts +6 -1
  63. package/services/durable/worker.ts +92 -79
  64. package/services/durable/workflow.ts +95 -25
  65. package/services/engine/index.ts +33 -24
  66. package/services/hotmesh/index.ts +7 -4
  67. package/services/mapper/index.ts +1 -1
  68. package/services/pipe/functions/array.ts +4 -0
  69. package/services/reporter/index.ts +10 -2
  70. package/services/signaler/store.ts +8 -3
  71. package/services/signaler/stream.ts +3 -3
  72. package/services/store/clients/ioredis.ts +15 -15
  73. package/services/store/clients/redis.ts +18 -18
  74. package/services/store/index.ts +12 -3
  75. package/services/task/index.ts +3 -3
  76. package/types/activity.ts +16 -7
  77. package/types/durable.ts +18 -1
  78. package/types/index.ts +2 -1
  79. package/types/stats.ts +1 -0
  80. package/build/services/activities/emit.d.ts +0 -9
  81. package/build/services/activities/emit.js +0 -13
  82. package/services/activities/emit.ts +0 -25
@@ -1,30 +1,20 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkflowYAML = exports.getActivityYAML = void 0;
4
2
  /**
5
- * 1) `maxSystemRetries` | can be 0 to 3 and represents milliseconds;
6
- * if there is an error, the workflow will retry up to `maxSystemRetries` times
7
- * delaying by 10, 100, and 1000ms; this is a system level retry
8
- * and is not configurable. It exists to handle intermittent network
9
- * errors. (NOTE: each retry spawns a new transition stream)
10
- *
11
- * 2) `backoffExponent` | can be any number and represents `seconds` when applied;
12
- * retries will happen indefinitely and adhere to the
13
- * exponential backoff algorithm by multiplying by `backoffExponent`.
14
- * For example, if `backoffExponent` is 10, the workflow will retry
15
- * in 10s, 100s, 1000s, 10000s, etc.
16
- *
17
- * EXAMPLE | Using `maxSystemRetries = 3` and `backoffExponent = 10`, errant
18
- * workflows will be retried on the following schedule (8 times in 27 hours):
19
- * => 10ms, 100ms, 1000ms, 10s, 100s, 1_000s, 10_000s, 100_000s
3
+ * NOTE: Using `maxSystemRetries = 3` and `backoffCoefficient = 10`, errant
4
+ * workflows will be retried on the following schedule (8 times in 27 hours):
5
+ * => 10ms, 100ms, 1000ms, 10s, 100s, 1_000s, 10_000s, 100_000s
20
6
  */
21
- const getWorkflowYAML = (topic, version = '1', maxSystemRetries = 2, backoffExponent = 10) => {
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.WFS_HOOK_ID = exports.WFSC_PUBLISHES_TOPIC = exports.WFSC_SUBSCRIBES_TOPIC = exports.WFS_PUBLISHES_TOPIC = exports.WFS_SUBSCRIBES_TOPIC = exports.DEFAULT_COEFFICIENT = exports.SLEEP_HOOK_ID = exports.ACTIVITY_HOOK_ID = exports.HOOK_ID = exports.PUBLISHES_TOPIC = exports.SUBSCRIBES_TOPIC = exports.SLEEP_PUBLISHES_TOPIC = exports.SLEEP_SUBSCRIBES_TOPIC = exports.ACTIVITY_PUBLISHES_TOPIC = exports.ACTIVITY_SUBSCRIBES_TOPIC = exports.APP_ID = exports.APP_VERSION = exports.getWorkflowYAML = void 0;
9
+ //todo: getChildWorkflowYAML (includes key, so flow will cleanup)
10
+ //todo: if an activity throws an error, it should self-clean its index
11
+ const getWorkflowYAML = (app, version) => {
22
12
  return `app:
23
- id: ${topic}
13
+ id: ${app}
24
14
  version: '${version}'
25
15
  graphs:
26
- - subscribes: ${topic}
27
- publishes: ${topic}
16
+ - subscribes: ${app}.execute
17
+ publishes: ${app}.executed
28
18
  expire: 120
29
19
  input:
30
20
  schema:
@@ -34,18 +24,27 @@ const getWorkflowYAML = (topic, version = '1', maxSystemRetries = 2, backoffExpo
34
24
  type: string
35
25
  arguments:
36
26
  type: array
27
+ workflowTopic:
28
+ type: string
29
+ backoffCoefficient:
30
+ type: number
37
31
  output:
38
32
  schema:
39
33
  type: object
40
34
  properties:
41
35
  response:
42
36
  type: any
37
+ done:
38
+ type: boolean
43
39
 
44
40
  activities:
45
41
  t1:
46
42
  type: trigger
47
43
  stats:
48
44
  id: '{$self.input.data.workflowId}'
45
+ job:
46
+ maps:
47
+ done: false
49
48
 
50
49
  a1:
51
50
  type: activity
@@ -57,13 +56,13 @@ const getWorkflowYAML = (topic, version = '1', maxSystemRetries = 2, backoffExpo
57
56
  duration:
58
57
  type: number
59
58
  maps:
60
- duration: ${backoffExponent}
59
+ duration: '{t1.output.data.backoffCoefficient}'
61
60
 
62
61
  w1:
63
62
  type: worker
64
- topic: ${topic}
63
+ topic: '{t1.output.data.workflowTopic}'
65
64
  retry:
66
- '599': [${maxSystemRetries}]
65
+ '599': [2]
67
66
  input:
68
67
  schema:
69
68
  type: object
@@ -81,16 +80,152 @@ const getWorkflowYAML = (topic, version = '1', maxSystemRetries = 2, backoffExpo
81
80
  properties:
82
81
  response:
83
82
  type: any
83
+ 594:
84
+ schema:
85
+ type: object
86
+ properties:
87
+ index:
88
+ type: number
89
+ description: the index of the first signal in the array
90
+ signals:
91
+ type: array
92
+ description: remaining signal ids
93
+ items:
94
+ type: object
95
+ properties:
96
+ signal:
97
+ type: string
98
+ index:
99
+ type: number
100
+ maps:
101
+ index: '{$self.output.data.index}'
102
+ signals: '{$self.output.data.signals}'
103
+ 595:
104
+ schema:
105
+ type: object
106
+ properties:
107
+ duration:
108
+ type: number
109
+ description: sleep duration in seconds
110
+ index:
111
+ type: number
112
+ description: the current index
113
+ maps:
114
+ duration: '{$self.output.data.duration}'
115
+ index: '{$self.output.data.index}'
84
116
  job:
85
117
  maps:
86
118
  response: '{$self.output.data.response}'
119
+ done: '{$self.output.data.done}'
87
120
 
88
- a599:
121
+ a594:
122
+ title: Wait for signals
123
+ type: await
124
+ topic: ${app}.wfsc.execute
125
+ input:
126
+ schema:
127
+ type: object
128
+ properties:
129
+ index:
130
+ type: number
131
+ signals:
132
+ type: array
133
+ description: signal ids
134
+ items:
135
+ type: object
136
+ properties:
137
+ signal:
138
+ type: string
139
+ index:
140
+ type: number
141
+ parentWorkflowId:
142
+ type: string
143
+ cycleWorkflowId:
144
+ type: string
145
+ baseWorkflowId:
146
+ type: string
147
+ description: index will be appended later
148
+ maps:
149
+ signals: '{w1.output.data.signals}'
150
+ parentWorkflowId:
151
+ '@pipe':
152
+ - ['{$job.metadata.jid}', '-w']
153
+ - ['{@string.concat}']
154
+ cycleWorkflowId:
155
+ '@pipe':
156
+ - ['{$job.metadata.jid}', '-$wfc-', '{w1.output.data.index}']
157
+ - ['{@string.concat}']
158
+ baseWorkflowId:
159
+ '@pipe':
160
+ - ['{$job.metadata.jid}', '-$wfs-']
161
+ - ['{@string.concat}']
162
+ output:
163
+ schema:
164
+ type: object
165
+ properties:
166
+ done:
167
+ type: boolean
168
+ maps:
169
+ done: '{w1.output.data.done}'
170
+
171
+ c594:
172
+ title: Goto Activity a1
173
+ type: cycle
174
+ ancestor: a1
175
+ input:
176
+ maps:
177
+ duration: '{a1.output.data.duration}'
178
+
179
+ a595:
89
180
  title: Sleep before trying again
181
+ type: await
182
+ topic: ${app}.sleep.execute
183
+ input:
184
+ schema:
185
+ type: object
186
+ properties:
187
+ duration:
188
+ type: number
189
+ index:
190
+ type: number
191
+ workflowId:
192
+ type: string
193
+ parentWorkflowId:
194
+ type: string
195
+ maps:
196
+ duration: '{w1.output.data.duration}'
197
+ index: '{w1.output.data.index}'
198
+ parentWorkflowId:
199
+ '@pipe':
200
+ - ['{$job.metadata.jid}', '-s']
201
+ - ['{@string.concat}']
202
+ workflowId:
203
+ '@pipe':
204
+ - ['{$job.metadata.jid}', '-$sleep-', '{w1.output.data.index}']
205
+ - ['{@string.concat}']
206
+ output:
207
+ schema:
208
+ type: object
209
+ properties:
210
+ done:
211
+ type: boolean
212
+ maps:
213
+ done: '{w1.output.data.done}'
214
+
215
+ c595:
216
+ title: Goto Activity a1
217
+ type: cycle
218
+ ancestor: a1
219
+ input:
220
+ maps:
221
+ duration: '{a1.output.data.duration}'
222
+
223
+ a599:
224
+ title: Sleep exponentially longer before retrying
90
225
  type: activity
91
- sleep: "{a1.output.data.duration}"
226
+ sleep: '{a1.output.data.duration}'
92
227
 
93
- c1:
228
+ c599:
94
229
  title: Goto Activity a1
95
230
  type: cycle
96
231
  ancestor: a1
@@ -98,39 +233,174 @@ const getWorkflowYAML = (topic, version = '1', maxSystemRetries = 2, backoffExpo
98
233
  maps:
99
234
  duration:
100
235
  '@pipe':
101
- - ['{a1.output.data.duration}', ${backoffExponent}]
236
+ - ['{a1.output.data.duration}', '{t1.output.data.backoffCoefficient}']
102
237
  - ['{@math.multiply}']
103
238
 
239
+ s1:
240
+ title: Awaken activity flows so they end and self-clean
241
+ type: signal
242
+ subtype: all
243
+ key_name: parentWorkflowId
244
+ key_value:
245
+ '@pipe':
246
+ - ['{$job.metadata.jid}', '-a']
247
+ - ['{@string.concat}']
248
+ topic: ${app}.activity.awaken
249
+ resolver:
250
+ schema:
251
+ type: object
252
+ properties:
253
+ data:
254
+ type: object
255
+ properties:
256
+ parentWorkflowId:
257
+ type: string
258
+ scrub:
259
+ type: boolean
260
+ maps:
261
+ data:
262
+ parentWorkflowId:
263
+ '@pipe':
264
+ - ['{$job.metadata.jid}', '-a']
265
+ - ['{@string.concat}']
266
+
267
+ scrub: true
268
+ signal:
269
+ schema:
270
+ type: object
271
+ properties:
272
+ done:
273
+ type: boolean
274
+ maps:
275
+ done: true
276
+
277
+ s2:
278
+ title: Awaken sleep flows so they end and self-clean
279
+ type: signal
280
+ subtype: all
281
+ key_name: parentWorkflowId
282
+ key_value:
283
+ '@pipe':
284
+ - ['{$job.metadata.jid}', '-s']
285
+ - ['{@string.concat}']
286
+ topic: ${app}.sleep.awaken
287
+ resolver:
288
+ schema:
289
+ type: object
290
+ properties:
291
+ data:
292
+ type: object
293
+ properties:
294
+ parentWorkflowId:
295
+ type: string
296
+ scrub:
297
+ type: boolean
298
+ maps:
299
+ data:
300
+ parentWorkflowId:
301
+ '@pipe':
302
+ - ['{$job.metadata.jid}', '-s']
303
+ - ['{@string.concat}']
304
+ scrub: true
305
+ signal:
306
+ schema:
307
+ type: object
308
+ properties:
309
+ done:
310
+ type: boolean
311
+ maps:
312
+ done: true
313
+
314
+ s3:
315
+ title: Awaken WFS flows so they end and self-clean
316
+ type: signal
317
+ subtype: all
318
+ key_name: parentWorkflowId
319
+ key_value:
320
+ '@pipe':
321
+ - ['{$job.metadata.jid}', '-w']
322
+ - ['{@string.concat}']
323
+ topic: ${app}.wfs.awaken
324
+ resolver:
325
+ schema:
326
+ type: object
327
+ properties:
328
+ data:
329
+ type: object
330
+ properties:
331
+ parentWorkflowId:
332
+ type: string
333
+ scrub:
334
+ type: boolean
335
+ maps:
336
+ data:
337
+ parentWorkflowId:
338
+ '@pipe':
339
+ - ['{$job.metadata.jid}', '-w']
340
+ - ['{@string.concat}']
341
+ scrub: true
342
+ signal:
343
+ schema:
344
+ type: object
345
+ properties:
346
+ done:
347
+ type: boolean
348
+ maps:
349
+ done: true
350
+
104
351
  transitions:
105
352
  t1:
106
353
  - to: a1
107
354
  a1:
108
355
  - to: w1
109
356
  w1:
357
+ - to: a594
358
+ conditions:
359
+ code: 594
360
+ - to: a595
361
+ conditions:
362
+ code: 595
110
363
  - to: a599
111
364
  conditions:
112
365
  code: 599
366
+ - to: s1
367
+ conditions:
368
+ code: [200, 598, 597, 596]
369
+ - to: s2
370
+ conditions:
371
+ code: [200, 598, 597, 596]
372
+ - to: s3
373
+ conditions:
374
+ code: [200, 598, 597, 596]
375
+ a594:
376
+ - to: c594
377
+ conditions:
378
+ code: 202
379
+
380
+ a595:
381
+ - to: c595
382
+ conditions:
383
+ code: 202
113
384
  a599:
114
- - to: c1
115
- `;
116
- };
117
- exports.getWorkflowYAML = getWorkflowYAML;
118
- const getActivityYAML = (topic, version = '1') => {
119
- return `app:
120
- id: ${topic}
121
- version: '${version}'
122
- graphs:
123
- - subscribes: ${topic}
385
+ - to: c599
386
+
387
+ - subscribes: ${app}.activity.execute
388
+ publishes: ${app}.activity.executed
389
+
390
+ expire: 120
391
+
124
392
  input:
125
393
  schema:
126
394
  type: object
127
395
  properties:
396
+ parentWorkflowId:
397
+ type: string
128
398
  workflowId:
129
399
  type: string
130
400
  workflowTopic:
131
401
  type: string
132
402
  activityName:
133
- type: array
403
+ type: string
134
404
  arguments:
135
405
  type: array
136
406
  output:
@@ -139,32 +409,44 @@ const getActivityYAML = (topic, version = '1') => {
139
409
  properties:
140
410
  response:
141
411
  type: any
412
+ done:
413
+ type: boolean
142
414
 
143
415
  activities:
144
- t1:
416
+ t1a:
145
417
  type: trigger
146
418
  stats:
147
419
  id: '{$self.input.data.workflowId}'
148
- a1:
420
+ key: '{$self.input.data.parentWorkflowId}'
421
+ granularity: infinity
422
+ measures:
423
+ - measure: index
424
+ target: '{$self.input.data.parentWorkflowId}'
425
+
426
+ w1a:
149
427
  type: worker
150
- topic: ${topic}
428
+ topic: '{t1a.output.data.workflowTopic}'
429
+ emit: true
151
430
  input:
152
431
  schema:
153
432
  type: object
154
433
  properties:
434
+ parentWorkflowId:
435
+ type: string
155
436
  workflowId:
156
437
  type: string
157
438
  workflowTopic:
158
439
  type: string
159
440
  activityName:
160
- type: array
441
+ type: string
161
442
  arguments:
162
443
  type: array
163
444
  maps:
164
- workflowId: '{t1.output.data.workflowId}'
165
- workflowTopic: '{t1.output.data.workflowTopic}'
166
- activityName: '{t1.output.data.activityName}'
167
- arguments: '{t1.output.data.arguments}'
445
+ parentWorkflowId: '{t1a.output.data.parentWorkflowId}'
446
+ workflowId: '{t1a.output.data.workflowId}'
447
+ workflowTopic: '{t1a.output.data.workflowTopic}'
448
+ activityName: '{t1a.output.data.activityName}'
449
+ arguments: '{t1a.output.data.arguments}'
168
450
  output:
169
451
  schema:
170
452
  type: object
@@ -174,8 +456,398 @@ const getActivityYAML = (topic, version = '1') => {
174
456
  job:
175
457
  maps:
176
458
  response: '{$self.output.data.response}'
459
+ done: true
460
+
461
+ s1a:
462
+ type: activity
463
+ title: Wait for cleanup signal
464
+ hook:
465
+ type: object
466
+ properties:
467
+ done:
468
+ type: boolean
469
+ job:
470
+ maps:
471
+ workflowId: '{t1a.output.data.workflowId}'
472
+
177
473
  transitions:
178
- t1:
179
- - to: a1`;
474
+ t1a:
475
+ - to: w1a
476
+ w1a:
477
+ - to: s1a
478
+
479
+ hooks:
480
+ ${app}.activity.awaken:
481
+ - to: s1a
482
+ conditions:
483
+ match:
484
+ - expected: '{t1a.output.data.workflowId}'
485
+ actual: '{$self.hook.data.id}'
486
+
487
+ - subscribes: ${app}.sleep.execute
488
+ publishes: ${app}.sleep.executed
489
+
490
+ expire: 120
491
+
492
+ input:
493
+ schema:
494
+ type: object
495
+ properties:
496
+ parentWorkflowId:
497
+ type: string
498
+ workflowId:
499
+ type: string
500
+ duration:
501
+ type: number
502
+ description: in seconds
503
+ index:
504
+ type: number
505
+ output:
506
+ schema:
507
+ type: object
508
+ properties:
509
+ done:
510
+ type: boolean
511
+ duration:
512
+ type: number
513
+ index:
514
+ type: number
515
+
516
+ activities:
517
+ t1s:
518
+ type: trigger
519
+ stats:
520
+ id: '{$self.input.data.workflowId}'
521
+ key: '{$self.input.data.parentWorkflowId}'
522
+ granularity: infinity
523
+ measures:
524
+ - measure: index
525
+ target: '{$self.input.data.parentWorkflowId}'
526
+
527
+ a1s:
528
+ type: activity
529
+ title: Sleep for a duration
530
+ sleep: '{t1s.output.data.duration}'
531
+ emit: true
532
+
533
+ a2s:
534
+ type: activity
535
+ title: Wait for cleanup signal
536
+ hook:
537
+ type: object
538
+ properties:
539
+ done:
540
+ type: boolean
541
+ job:
542
+ maps:
543
+ done: true
544
+ duration: '{t1s.output.data.duration}'
545
+ index: '{t1s.output.data.index}'
546
+ workflowId: '{t1s.output.data.workflowId}'
547
+
548
+ transitions:
549
+ t1s:
550
+ - to: a1s
551
+ a1s:
552
+ - to: a2s
553
+
554
+ hooks:
555
+ ${app}.sleep.awaken:
556
+ - to: a2s
557
+ conditions:
558
+ match:
559
+ - expected: '{t1s.output.data.workflowId}'
560
+ actual: '{$self.hook.data.id}'
561
+
562
+ - subscribes: ${app}.wfsc.execute
563
+ publishes: ${app}.wfsc.executed
564
+
565
+ expire: 120
566
+
567
+ input:
568
+ schema:
569
+ type: object
570
+ properties:
571
+ index:
572
+ type: number
573
+ signals:
574
+ type: array
575
+ description: signal ids
576
+ items:
577
+ type: object
578
+ properties:
579
+ signal:
580
+ type: string
581
+ index:
582
+ type: number
583
+ parentWorkflowId:
584
+ type: string
585
+ cycleWorkflowId:
586
+ type: string
587
+ baseWorkflowId:
588
+ type: string
589
+ description: index will be appended later
590
+ output:
591
+ schema:
592
+ type: object
593
+ properties:
594
+ done:
595
+ type: boolean
596
+
597
+ activities:
598
+ t1wc:
599
+ title: Cycler workflow that creates signal workflows
600
+ type: trigger
601
+ stats:
602
+ id: '{$self.input.data.cycleWorkflowId}'
603
+
604
+ a1wc:
605
+ title: Split signal data
606
+ type: activity
607
+ cycle: true
608
+ output:
609
+ schema:
610
+ type: object
611
+ properties:
612
+ targetLength:
613
+ type: number
614
+ targetSignal:
615
+ type: object
616
+ properties:
617
+ signal:
618
+ type: string
619
+ index:
620
+ type: number
621
+ signals:
622
+ type: array
623
+ items:
624
+ type: object
625
+ properties:
626
+ signal:
627
+ type: string
628
+ index:
629
+ type: number
630
+ maps:
631
+ targetLength:
632
+ '@pipe':
633
+ - ['{t1wc.output.data.signals}']
634
+ - ['{@array.length}']
635
+ targetSignal:
636
+ '@pipe':
637
+ - ['{t1wc.output.data.signals}', 0]
638
+ - ['{@array.get}']
639
+ signals:
640
+ '@pipe':
641
+ - ['{t1wc.output.data.signals}', 1]
642
+ - ['{@array.slice}']
643
+ a2wc:
644
+ type: activity
645
+ output:
646
+ schema:
647
+ type: object
648
+ properties:
649
+ targetLength:
650
+ type: number
651
+ maps:
652
+ targetLength: '{a1wc.output.data.targetLength}'
653
+
654
+ c1wc:
655
+ title: Goto Activity a1wc
656
+ type: cycle
657
+ ancestor: a1wc
658
+ input:
659
+ maps:
660
+ targetLength:
661
+ '@pipe':
662
+ - ['{a1wc.output.data.signals}']
663
+ - ['{@array.length}']
664
+ targetSignal:
665
+ '@pipe':
666
+ - ['{a1wc.output.data.signals}', 0]
667
+ - ['{@array.get}']
668
+ signals:
669
+ '@pipe':
670
+ - ['{a1wc.output.data.signals}', 1]
671
+ - ['{@array.slice}']
672
+
673
+ a3wc:
674
+ title: Call WFS workflow
675
+ type: await
676
+ topic: ${app}.wfs.execute
677
+ emit: true
678
+ input:
679
+ schema:
680
+ type: object
681
+ properties:
682
+ parentWorkflowId:
683
+ type: string
684
+ description: used to forge the cleanup key
685
+ signalId:
686
+ type: string
687
+ description: used to forge the custom hookid
688
+ workflowId:
689
+ type: string
690
+ description: the baseId + index
691
+ maps:
692
+ parentWorkflowId: '{t1wc.output.data.parentWorkflowId}'
693
+ signalId: '{a1wc.output.data.targetSignal.signal}'
694
+ workflowId:
695
+ '@pipe':
696
+ - ['{t1wc.output.data.baseWorkflowId}', '{a1wc.output.data.targetSignal.index}']
697
+ - ['{@string.concat}']
698
+ output:
699
+ schema:
700
+ type: object
701
+ properties:
702
+ done:
703
+ type: boolean
704
+ maps:
705
+ done: '{w1.output.data.done}'
706
+
707
+ transitions:
708
+ t1wc:
709
+ - to: a1wc
710
+ a1wc:
711
+ - to: a2wc
712
+ a2wc:
713
+ - to: c1wc
714
+ conditions:
715
+ match:
716
+ - expected: true
717
+ actual:
718
+ '@pipe':
719
+ - ['{a1wc.output.data.targetLength}', 0]
720
+ - ['{@conditional.greater_than}']
721
+ - to: a3wc
722
+ conditions:
723
+ match:
724
+ - expected: true
725
+ actual:
726
+ '@pipe':
727
+ - ['{a1wc.output.data.targetLength}', 0]
728
+ - ['{@conditional.greater_than}']
729
+
730
+ - subscribes: ${app}.wfs.execute
731
+ publishes: ${app}.wfs.executed
732
+
733
+ expire: 120
734
+
735
+ input:
736
+ schema:
737
+ type: object
738
+ properties:
739
+ parentWorkflowId:
740
+ type: string
741
+ description: used to forge the cleanup key
742
+ workflowId:
743
+ type: string
744
+ description: used to forge the cleanup hookid
745
+ signalId:
746
+ type: string
747
+ description: used to forge the custom hookid
748
+ output:
749
+ schema:
750
+ type: object
751
+ properties:
752
+ done:
753
+ type: boolean
754
+ workflowId:
755
+ type: string
756
+ signalData:
757
+ type: object
758
+
759
+ activities:
760
+ t1ww:
761
+ type: trigger
762
+ stats:
763
+ id: '{$self.input.data.workflowId}'
764
+ key: '{$self.input.data.parentWorkflowId}'
765
+ granularity: infinity
766
+ measures:
767
+ - measure: index
768
+ target: '{$self.input.data.parentWorkflowId}'
769
+
770
+ a1ww:
771
+ type: activity
772
+ title: Wait for custom signal
773
+ emit: true
774
+ hook:
775
+ type: object
776
+ properties:
777
+ signalData:
778
+ type: object
779
+ job:
780
+ maps:
781
+ signalData: '{$self.hook.data}'
782
+ workflowId: '{t1ww.output.data.workflowId}'
783
+ signalId: '{t1ww.output.data.signalId}'
784
+
785
+ a2ww:
786
+ type: activity
787
+ title: Wait for cleanup signal
788
+ hook:
789
+ type: object
790
+ properties:
791
+ done:
792
+ type: boolean
793
+ job:
794
+ maps:
795
+ done: true
796
+ workflowId: '{t1ww.output.data.workflowId}'
797
+
798
+ transitions:
799
+ t1ww:
800
+ - to: a1ww
801
+ - to: a2ww
802
+
803
+ hooks:
804
+ ${app}.wfs.signal:
805
+ - to: a1ww
806
+ conditions:
807
+ match:
808
+ - expected: '{t1ww.output.data.signalId}'
809
+ actual: '{$self.hook.data.id}'
810
+ ${app}.wfs.awaken:
811
+ - to: a2ww
812
+ conditions:
813
+ match:
814
+ - expected: '{t1ww.output.data.workflowId}'
815
+ actual: '{$self.hook.data.id}'
816
+
817
+ `;
180
818
  };
181
- exports.getActivityYAML = getActivityYAML;
819
+ exports.getWorkflowYAML = getWorkflowYAML;
820
+ const APP_VERSION = '1';
821
+ exports.APP_VERSION = APP_VERSION;
822
+ const APP_ID = 'durable';
823
+ exports.APP_ID = APP_ID;
824
+ const ACTIVITY_SUBSCRIBES_TOPIC = 'durable.activity.execute';
825
+ exports.ACTIVITY_SUBSCRIBES_TOPIC = ACTIVITY_SUBSCRIBES_TOPIC;
826
+ const ACTIVITY_PUBLISHES_TOPIC = 'durable.activity.executed';
827
+ exports.ACTIVITY_PUBLISHES_TOPIC = ACTIVITY_PUBLISHES_TOPIC;
828
+ const SLEEP_SUBSCRIBES_TOPIC = 'durable.sleep.execute';
829
+ exports.SLEEP_SUBSCRIBES_TOPIC = SLEEP_SUBSCRIBES_TOPIC;
830
+ const SLEEP_PUBLISHES_TOPIC = 'durable.sleep.executed';
831
+ exports.SLEEP_PUBLISHES_TOPIC = SLEEP_PUBLISHES_TOPIC;
832
+ const WFS_SUBSCRIBES_TOPIC = 'durable.wfs.execute';
833
+ exports.WFS_SUBSCRIBES_TOPIC = WFS_SUBSCRIBES_TOPIC;
834
+ const WFS_PUBLISHES_TOPIC = 'durable.wfs.executed';
835
+ exports.WFS_PUBLISHES_TOPIC = WFS_PUBLISHES_TOPIC;
836
+ const WFSC_SUBSCRIBES_TOPIC = 'durable.wfsc.execute';
837
+ exports.WFSC_SUBSCRIBES_TOPIC = WFSC_SUBSCRIBES_TOPIC;
838
+ const WFSC_PUBLISHES_TOPIC = 'durable.wfsc.executed';
839
+ exports.WFSC_PUBLISHES_TOPIC = WFSC_PUBLISHES_TOPIC;
840
+ const SUBSCRIBES_TOPIC = 'durable.execute';
841
+ exports.SUBSCRIBES_TOPIC = SUBSCRIBES_TOPIC;
842
+ const PUBLISHES_TOPIC = 'durable.executed';
843
+ exports.PUBLISHES_TOPIC = PUBLISHES_TOPIC;
844
+ const HOOK_ID = 'durable.awaken';
845
+ exports.HOOK_ID = HOOK_ID;
846
+ const ACTIVITY_HOOK_ID = 'durable.activity.awaken';
847
+ exports.ACTIVITY_HOOK_ID = ACTIVITY_HOOK_ID;
848
+ const SLEEP_HOOK_ID = 'durable.sleep.awaken';
849
+ exports.SLEEP_HOOK_ID = SLEEP_HOOK_ID;
850
+ const WFS_HOOK_ID = 'durable.wfs.awaken';
851
+ exports.WFS_HOOK_ID = WFS_HOOK_ID;
852
+ const DEFAULT_COEFFICIENT = 10;
853
+ exports.DEFAULT_COEFFICIENT = DEFAULT_COEFFICIENT;