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