@mnci/az-durable 0.1.2 → 0.1.4
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/eslint-plugin.cjs.js +218 -219
- package/dist/index.cjs.js +160 -997
- package/dist/testing.cjs.js +130 -153
- package/package.json +3 -2
package/dist/index.cjs.js
CHANGED
|
@@ -32,7 +32,9 @@ var df__namespace = /*#__PURE__*/_interopNamespaceDefault(df);
|
|
|
32
32
|
* until replay, by which point the history already refers to the wrong thing.
|
|
33
33
|
*
|
|
34
34
|
* Failing loudly at startup is strictly better, so registration throws.
|
|
35
|
-
*/
|
|
35
|
+
*/
|
|
36
|
+
/** Every name registered so far, and where. Module-level, matching the SDK's own global scope. */
|
|
37
|
+
const registered = new Map();
|
|
36
38
|
/**
|
|
37
39
|
* Records a name, throwing if it was already taken.
|
|
38
40
|
*
|
|
@@ -46,12 +48,13 @@ var df__namespace = /*#__PURE__*/_interopNamespaceDefault(df);
|
|
|
46
48
|
* @returns Nothing.
|
|
47
49
|
* @throws Error when `name` has already been registered.
|
|
48
50
|
* @typeParam None - this function has no generic type parameters.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
51
|
+
*/
|
|
52
|
+
function claimName(kind, name) {
|
|
53
|
+
const previous = registered.get(name);
|
|
54
|
+
if (previous !== undefined) {
|
|
55
|
+
throw new Error(`Duplicate ${kind} name '${name}'. Names are global to the Function App and are ` + 'baked into orchestration history, so two registrations silently misbind.\n' + ` first registered at: ${previous}\n` + ` registered again at: ${callSite()}`);
|
|
56
|
+
}
|
|
57
|
+
registered.set(name, callSite());
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
60
|
* The caller's source location, as best the stack can tell.
|
|
@@ -65,116 +68,18 @@ var df__namespace = /*#__PURE__*/_interopNamespaceDefault(df);
|
|
|
65
68
|
* @returns A `file:line:col` string, or `<unknown location>`.
|
|
66
69
|
* @throws Never - falls back to a placeholder.
|
|
67
70
|
* @typeParam None - this function has no generic type parameters.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
*/
|
|
72
|
+
function callSite() {
|
|
73
|
+
const stack = new Error('locate').stack;
|
|
74
|
+
if (stack === undefined) {
|
|
75
|
+
return '<unknown location>';
|
|
76
|
+
}
|
|
77
|
+
// [0] is the Error line, [1] is callSite, [2] is claimName, [3] is
|
|
78
|
+
// defineActivity/defineOrchestration, [4] is the consumer — the one we want.
|
|
79
|
+
const frame = stack.split('\n', 5)[4];
|
|
80
|
+
return frame === undefined ? '<unknown location>' : frame.trim().replace(/^at\s+/, '');
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
function _ts_generator$5(thisArg, body) {
|
|
80
|
-
var f, y, t, _ = {
|
|
81
|
-
label: 0,
|
|
82
|
-
sent: function() {
|
|
83
|
-
if (t[0] & 1) throw t[1];
|
|
84
|
-
return t[1];
|
|
85
|
-
},
|
|
86
|
-
trys: [],
|
|
87
|
-
ops: []
|
|
88
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
89
|
-
return d(g, "next", {
|
|
90
|
-
value: verb(0)
|
|
91
|
-
}), d(g, "throw", {
|
|
92
|
-
value: verb(1)
|
|
93
|
-
}), d(g, "return", {
|
|
94
|
-
value: verb(2)
|
|
95
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
96
|
-
value: function() {
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
}), g;
|
|
100
|
-
function verb(n) {
|
|
101
|
-
return function(v) {
|
|
102
|
-
return step([
|
|
103
|
-
n,
|
|
104
|
-
v
|
|
105
|
-
]);
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function step(op) {
|
|
109
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
110
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
111
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
112
|
-
if (y = 0, t) op = [
|
|
113
|
-
op[0] & 2,
|
|
114
|
-
t.value
|
|
115
|
-
];
|
|
116
|
-
switch(op[0]){
|
|
117
|
-
case 0:
|
|
118
|
-
case 1:
|
|
119
|
-
t = op;
|
|
120
|
-
break;
|
|
121
|
-
case 4:
|
|
122
|
-
_.label++;
|
|
123
|
-
return {
|
|
124
|
-
value: op[1],
|
|
125
|
-
done: false
|
|
126
|
-
};
|
|
127
|
-
case 5:
|
|
128
|
-
_.label++;
|
|
129
|
-
y = op[1];
|
|
130
|
-
op = [
|
|
131
|
-
0
|
|
132
|
-
];
|
|
133
|
-
continue;
|
|
134
|
-
case 7:
|
|
135
|
-
op = _.ops.pop();
|
|
136
|
-
_.trys.pop();
|
|
137
|
-
continue;
|
|
138
|
-
default:
|
|
139
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
140
|
-
_ = 0;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
144
|
-
_.label = op[1];
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
148
|
-
_.label = t[1];
|
|
149
|
-
t = op;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
if (t && _.label < t[2]) {
|
|
153
|
-
_.label = t[2];
|
|
154
|
-
_.ops.push(op);
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
if (t[2]) _.ops.pop();
|
|
158
|
-
_.trys.pop();
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
op = body.call(thisArg, _);
|
|
162
|
-
} catch (e) {
|
|
163
|
-
op = [
|
|
164
|
-
6,
|
|
165
|
-
e
|
|
166
|
-
];
|
|
167
|
-
y = 0;
|
|
168
|
-
} finally{
|
|
169
|
-
f = t = 0;
|
|
170
|
-
}
|
|
171
|
-
if (op[0] & 5) throw op[1];
|
|
172
|
-
return {
|
|
173
|
-
value: op[0] ? op[1] : void 0,
|
|
174
|
-
done: true
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
83
|
/**
|
|
179
84
|
* Registers an activity and remembers its input and output types.
|
|
180
85
|
*
|
|
@@ -199,15 +104,16 @@ function _ts_generator$5(thisArg, body) {
|
|
|
199
104
|
* @throws Error when `name` is already registered.
|
|
200
105
|
* @typeParam TInput - The JSON-serialisable input.
|
|
201
106
|
* @typeParam TOutput - The handler's return type, awaited.
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
107
|
+
*/
|
|
108
|
+
function defineActivity(name, handler) {
|
|
109
|
+
claimName('activity', name);
|
|
110
|
+
const registered = df__namespace.app.activity(name, {
|
|
111
|
+
handler: handler
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
name,
|
|
115
|
+
registered
|
|
116
|
+
};
|
|
211
117
|
}
|
|
212
118
|
/**
|
|
213
119
|
* Schedules an activity without yielding it, for fan-out.
|
|
@@ -243,11 +149,12 @@ function _ts_generator$5(thisArg, body) {
|
|
|
243
149
|
* @throws Never - scheduling is synchronous and cannot fail here.
|
|
244
150
|
* @typeParam TInput - The activity's input type.
|
|
245
151
|
* @typeParam TOutput - The activity's output type.
|
|
246
|
-
*/
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
152
|
+
*/
|
|
153
|
+
function activityTask(context, activity, input, retry) {
|
|
154
|
+
const task = retry === undefined ? context.df.callActivity(activity.name, input) : context.df.callActivityWithRetry(activity.name, retry, input);
|
|
155
|
+
return {
|
|
156
|
+
task
|
|
157
|
+
};
|
|
251
158
|
}
|
|
252
159
|
/**
|
|
253
160
|
* Calls an activity and returns its typed result.
|
|
@@ -273,147 +180,15 @@ function _ts_generator$5(thisArg, body) {
|
|
|
273
180
|
* @throws Whatever the activity threw, once the driver resumes with a failure.
|
|
274
181
|
* @typeParam TInput - The activity's input type.
|
|
275
182
|
* @typeParam TOutput - The activity's output type.
|
|
276
|
-
*/
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
activityTask(context, activity, input, retry).task
|
|
284
|
-
];
|
|
285
|
-
case 1:
|
|
286
|
-
result = _state.sent();
|
|
287
|
-
// The one cast in the package. The SDK resumes the generator with the
|
|
288
|
-
// activity's result typed `any`; `TOutput` is the claim `defineActivity`
|
|
289
|
-
// captured from the handler's real signature.
|
|
290
|
-
return [
|
|
291
|
-
2,
|
|
292
|
-
result
|
|
293
|
-
];
|
|
294
|
-
}
|
|
295
|
-
});
|
|
183
|
+
*/
|
|
184
|
+
function* callActivity(context, activity, input, retry) {
|
|
185
|
+
const result = yield activityTask(context, activity, input, retry).task;
|
|
186
|
+
// The one cast in the package. The SDK resumes the generator with the
|
|
187
|
+
// activity's result typed `any`; `TOutput` is the claim `defineActivity`
|
|
188
|
+
// captured from the handler's real signature.
|
|
189
|
+
return result;
|
|
296
190
|
}
|
|
297
191
|
|
|
298
|
-
function _ts_generator$4(thisArg, body) {
|
|
299
|
-
var f, y, t, _ = {
|
|
300
|
-
label: 0,
|
|
301
|
-
sent: function() {
|
|
302
|
-
if (t[0] & 1) throw t[1];
|
|
303
|
-
return t[1];
|
|
304
|
-
},
|
|
305
|
-
trys: [],
|
|
306
|
-
ops: []
|
|
307
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
308
|
-
return d(g, "next", {
|
|
309
|
-
value: verb(0)
|
|
310
|
-
}), d(g, "throw", {
|
|
311
|
-
value: verb(1)
|
|
312
|
-
}), d(g, "return", {
|
|
313
|
-
value: verb(2)
|
|
314
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
315
|
-
value: function() {
|
|
316
|
-
return this;
|
|
317
|
-
}
|
|
318
|
-
}), g;
|
|
319
|
-
function verb(n) {
|
|
320
|
-
return function(v) {
|
|
321
|
-
return step([
|
|
322
|
-
n,
|
|
323
|
-
v
|
|
324
|
-
]);
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
function step(op) {
|
|
328
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
329
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
330
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
331
|
-
if (y = 0, t) op = [
|
|
332
|
-
op[0] & 2,
|
|
333
|
-
t.value
|
|
334
|
-
];
|
|
335
|
-
switch(op[0]){
|
|
336
|
-
case 0:
|
|
337
|
-
case 1:
|
|
338
|
-
t = op;
|
|
339
|
-
break;
|
|
340
|
-
case 4:
|
|
341
|
-
_.label++;
|
|
342
|
-
return {
|
|
343
|
-
value: op[1],
|
|
344
|
-
done: false
|
|
345
|
-
};
|
|
346
|
-
case 5:
|
|
347
|
-
_.label++;
|
|
348
|
-
y = op[1];
|
|
349
|
-
op = [
|
|
350
|
-
0
|
|
351
|
-
];
|
|
352
|
-
continue;
|
|
353
|
-
case 7:
|
|
354
|
-
op = _.ops.pop();
|
|
355
|
-
_.trys.pop();
|
|
356
|
-
continue;
|
|
357
|
-
default:
|
|
358
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
359
|
-
_ = 0;
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
362
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
363
|
-
_.label = op[1];
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
367
|
-
_.label = t[1];
|
|
368
|
-
t = op;
|
|
369
|
-
break;
|
|
370
|
-
}
|
|
371
|
-
if (t && _.label < t[2]) {
|
|
372
|
-
_.label = t[2];
|
|
373
|
-
_.ops.push(op);
|
|
374
|
-
break;
|
|
375
|
-
}
|
|
376
|
-
if (t[2]) _.ops.pop();
|
|
377
|
-
_.trys.pop();
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
op = body.call(thisArg, _);
|
|
381
|
-
} catch (e) {
|
|
382
|
-
op = [
|
|
383
|
-
6,
|
|
384
|
-
e
|
|
385
|
-
];
|
|
386
|
-
y = 0;
|
|
387
|
-
} finally{
|
|
388
|
-
f = t = 0;
|
|
389
|
-
}
|
|
390
|
-
if (op[0] & 5) throw op[1];
|
|
391
|
-
return {
|
|
392
|
-
value: op[0] ? op[1] : void 0,
|
|
393
|
-
done: true
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
function _ts_values$1(o) {
|
|
398
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
399
|
-
if (m) {
|
|
400
|
-
return m.call(o);
|
|
401
|
-
}
|
|
402
|
-
if (o && typeof o.length === "number") {
|
|
403
|
-
return {
|
|
404
|
-
next: function() {
|
|
405
|
-
if (o && i >= o.length) {
|
|
406
|
-
o = void 0;
|
|
407
|
-
}
|
|
408
|
-
return {
|
|
409
|
-
value: o && o[i++],
|
|
410
|
-
done: !o
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
416
|
-
}
|
|
417
192
|
/**
|
|
418
193
|
* Registers an orchestration, handing the handler its deserialised input.
|
|
419
194
|
*
|
|
@@ -430,43 +205,26 @@ function _ts_values$1(o) {
|
|
|
430
205
|
* @throws Error when `name` is already registered.
|
|
431
206
|
* @typeParam TInput - The JSON-serialisable input.
|
|
432
207
|
* @typeParam TOutput - The value the orchestration returns.
|
|
433
|
-
*/
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
_ts_values$1(handler(context, input, bind(context)))
|
|
454
|
-
];
|
|
455
|
-
case 1:
|
|
456
|
-
return [
|
|
457
|
-
2,
|
|
458
|
-
_state.sent()
|
|
459
|
-
];
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
});
|
|
463
|
-
return {
|
|
464
|
-
name: name,
|
|
465
|
-
registered: registered,
|
|
466
|
-
handler: function handler1(context, input) {
|
|
467
|
-
return handler(context, input, bind(context));
|
|
468
|
-
}
|
|
469
|
-
};
|
|
208
|
+
*/
|
|
209
|
+
function defineOrchestration(name, handler, options) {
|
|
210
|
+
claimName('orchestration', name);
|
|
211
|
+
const parse = options?.parse;
|
|
212
|
+
const bind = context => ({
|
|
213
|
+
name,
|
|
214
|
+
continueAsNew: next => {
|
|
215
|
+
context.df.continueAsNew(next);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
const registered = df__namespace.app.orchestration(name, function* (context) {
|
|
219
|
+
const raw = context.df.getInput();
|
|
220
|
+
const input = parse === undefined ? raw : parse(raw);
|
|
221
|
+
return yield* handler(context, input, bind(context));
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
name,
|
|
225
|
+
registered,
|
|
226
|
+
handler: (context, input) => handler(context, input, bind(context))
|
|
227
|
+
};
|
|
470
228
|
}
|
|
471
229
|
/**
|
|
472
230
|
* Calls a sub-orchestration and returns its typed result.
|
|
@@ -482,23 +240,10 @@ function _ts_values$1(o) {
|
|
|
482
240
|
* @throws Whatever the sub-orchestration threw, once the driver resumes with a failure.
|
|
483
241
|
* @typeParam TInput - The sub-orchestration's input type.
|
|
484
242
|
* @typeParam TOutput - The sub-orchestration's output type.
|
|
485
|
-
*/
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
case 0:
|
|
490
|
-
return [
|
|
491
|
-
4,
|
|
492
|
-
subOrchestrationTask(context, orchestration, input, options).task
|
|
493
|
-
];
|
|
494
|
-
case 1:
|
|
495
|
-
result = _state.sent();
|
|
496
|
-
return [
|
|
497
|
-
2,
|
|
498
|
-
result
|
|
499
|
-
];
|
|
500
|
-
}
|
|
501
|
-
});
|
|
243
|
+
*/
|
|
244
|
+
function* callSubOrchestration(context, orchestration, input, options) {
|
|
245
|
+
const result = yield subOrchestrationTask(context, orchestration, input, options).task;
|
|
246
|
+
return result;
|
|
502
247
|
}
|
|
503
248
|
/**
|
|
504
249
|
* Schedules a sub-orchestration without yielding it.
|
|
@@ -517,165 +262,15 @@ function _ts_values$1(o) {
|
|
|
517
262
|
* @throws Never - scheduling only.
|
|
518
263
|
* @typeParam TInput - The sub-orchestration's input type.
|
|
519
264
|
* @typeParam TOutput - The sub-orchestration's output type.
|
|
520
|
-
*/
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
265
|
+
*/
|
|
266
|
+
function subOrchestrationTask(context, orchestration, input, options) {
|
|
267
|
+
const retry = options?.retry;
|
|
268
|
+
const task = retry === undefined ? context.df.callSubOrchestrator(orchestration.name, input, options?.instanceId) : context.df.callSubOrchestratorWithRetry(orchestration.name, retry, input, options?.instanceId);
|
|
269
|
+
return {
|
|
270
|
+
task
|
|
271
|
+
};
|
|
526
272
|
}
|
|
527
273
|
|
|
528
|
-
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
529
|
-
try {
|
|
530
|
-
var info = gen[key](arg);
|
|
531
|
-
var value = info.value;
|
|
532
|
-
} catch (error) {
|
|
533
|
-
reject(error);
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
if (info.done) resolve(value);
|
|
537
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
538
|
-
}
|
|
539
|
-
function _async_to_generator$1(fn) {
|
|
540
|
-
return function() {
|
|
541
|
-
var self = this, args = arguments;
|
|
542
|
-
return new Promise(function(resolve, reject) {
|
|
543
|
-
var gen = fn.apply(self, args);
|
|
544
|
-
function _next(value) {
|
|
545
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
546
|
-
}
|
|
547
|
-
function _throw(err) {
|
|
548
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
549
|
-
}
|
|
550
|
-
_next(undefined);
|
|
551
|
-
});
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
function _define_property(obj, key, value) {
|
|
555
|
-
if (key in obj) {
|
|
556
|
-
Object.defineProperty(obj, key, {
|
|
557
|
-
value: value,
|
|
558
|
-
enumerable: true,
|
|
559
|
-
configurable: true,
|
|
560
|
-
writable: true
|
|
561
|
-
});
|
|
562
|
-
} else obj[key] = value;
|
|
563
|
-
return obj;
|
|
564
|
-
}
|
|
565
|
-
function _object_spread(target) {
|
|
566
|
-
for(var i = 1; i < arguments.length; i++){
|
|
567
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
568
|
-
var ownKeys = Object.keys(source);
|
|
569
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
570
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
571
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
572
|
-
}));
|
|
573
|
-
}
|
|
574
|
-
ownKeys.forEach(function(key) {
|
|
575
|
-
_define_property(target, key, source[key]);
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
return target;
|
|
579
|
-
}
|
|
580
|
-
function _ts_generator$3(thisArg, body) {
|
|
581
|
-
var f, y, t, _ = {
|
|
582
|
-
label: 0,
|
|
583
|
-
sent: function() {
|
|
584
|
-
if (t[0] & 1) throw t[1];
|
|
585
|
-
return t[1];
|
|
586
|
-
},
|
|
587
|
-
trys: [],
|
|
588
|
-
ops: []
|
|
589
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
590
|
-
return d(g, "next", {
|
|
591
|
-
value: verb(0)
|
|
592
|
-
}), d(g, "throw", {
|
|
593
|
-
value: verb(1)
|
|
594
|
-
}), d(g, "return", {
|
|
595
|
-
value: verb(2)
|
|
596
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
597
|
-
value: function() {
|
|
598
|
-
return this;
|
|
599
|
-
}
|
|
600
|
-
}), g;
|
|
601
|
-
function verb(n) {
|
|
602
|
-
return function(v) {
|
|
603
|
-
return step([
|
|
604
|
-
n,
|
|
605
|
-
v
|
|
606
|
-
]);
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
function step(op) {
|
|
610
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
611
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
612
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
613
|
-
if (y = 0, t) op = [
|
|
614
|
-
op[0] & 2,
|
|
615
|
-
t.value
|
|
616
|
-
];
|
|
617
|
-
switch(op[0]){
|
|
618
|
-
case 0:
|
|
619
|
-
case 1:
|
|
620
|
-
t = op;
|
|
621
|
-
break;
|
|
622
|
-
case 4:
|
|
623
|
-
_.label++;
|
|
624
|
-
return {
|
|
625
|
-
value: op[1],
|
|
626
|
-
done: false
|
|
627
|
-
};
|
|
628
|
-
case 5:
|
|
629
|
-
_.label++;
|
|
630
|
-
y = op[1];
|
|
631
|
-
op = [
|
|
632
|
-
0
|
|
633
|
-
];
|
|
634
|
-
continue;
|
|
635
|
-
case 7:
|
|
636
|
-
op = _.ops.pop();
|
|
637
|
-
_.trys.pop();
|
|
638
|
-
continue;
|
|
639
|
-
default:
|
|
640
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
641
|
-
_ = 0;
|
|
642
|
-
continue;
|
|
643
|
-
}
|
|
644
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
645
|
-
_.label = op[1];
|
|
646
|
-
break;
|
|
647
|
-
}
|
|
648
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
649
|
-
_.label = t[1];
|
|
650
|
-
t = op;
|
|
651
|
-
break;
|
|
652
|
-
}
|
|
653
|
-
if (t && _.label < t[2]) {
|
|
654
|
-
_.label = t[2];
|
|
655
|
-
_.ops.push(op);
|
|
656
|
-
break;
|
|
657
|
-
}
|
|
658
|
-
if (t[2]) _.ops.pop();
|
|
659
|
-
_.trys.pop();
|
|
660
|
-
continue;
|
|
661
|
-
}
|
|
662
|
-
op = body.call(thisArg, _);
|
|
663
|
-
} catch (e) {
|
|
664
|
-
op = [
|
|
665
|
-
6,
|
|
666
|
-
e
|
|
667
|
-
];
|
|
668
|
-
y = 0;
|
|
669
|
-
} finally{
|
|
670
|
-
f = t = 0;
|
|
671
|
-
}
|
|
672
|
-
if (op[0] & 5) throw op[1];
|
|
673
|
-
return {
|
|
674
|
-
value: op[0] ? op[1] : void 0,
|
|
675
|
-
done: true
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
274
|
/**
|
|
680
275
|
* Starts an orchestration with an input checked against its declared type.
|
|
681
276
|
*
|
|
@@ -692,29 +287,15 @@ function _ts_generator$3(thisArg, body) {
|
|
|
692
287
|
* @throws Propagates whatever the client throws.
|
|
693
288
|
* @typeParam TInput - The orchestration's input type.
|
|
694
289
|
* @typeParam TOutput - The orchestration's output type, unused at runtime.
|
|
695
|
-
*/
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
client.startNew(orchestration.name, _object_spread({
|
|
705
|
-
input: input
|
|
706
|
-
}, instanceId !== undefined && {
|
|
707
|
-
instanceId: instanceId
|
|
708
|
-
}))
|
|
709
|
-
];
|
|
710
|
-
case 1:
|
|
711
|
-
return [
|
|
712
|
-
2,
|
|
713
|
-
_state.sent()
|
|
714
|
-
];
|
|
715
|
-
}
|
|
716
|
-
});
|
|
717
|
-
})();
|
|
290
|
+
*/
|
|
291
|
+
async function startOrchestration(client, orchestration, input, options) {
|
|
292
|
+
const instanceId = options?.instanceId;
|
|
293
|
+
return await client.startNew(orchestration.name, {
|
|
294
|
+
input,
|
|
295
|
+
...(instanceId !== undefined && {
|
|
296
|
+
instanceId
|
|
297
|
+
})
|
|
298
|
+
});
|
|
718
299
|
}
|
|
719
300
|
|
|
720
301
|
/**
|
|
@@ -733,119 +314,21 @@ function _ts_generator$3(thisArg, body) {
|
|
|
733
314
|
* @returns An SDK `RetryOptions` instance.
|
|
734
315
|
* @throws Whatever the SDK constructor throws for an invalid interval.
|
|
735
316
|
* @typeParam None - this function has no generic type parameters.
|
|
736
|
-
*/
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
317
|
+
*/
|
|
318
|
+
function retryPolicy(policy) {
|
|
319
|
+
const options = new df.RetryOptions(policy.firstRetryIntervalInMilliseconds, policy.maxNumberOfAttempts);
|
|
320
|
+
if (policy.backoffCoefficient !== undefined) {
|
|
321
|
+
options.backoffCoefficient = policy.backoffCoefficient;
|
|
322
|
+
}
|
|
323
|
+
if (policy.maxRetryIntervalInMilliseconds !== undefined) {
|
|
324
|
+
options.maxRetryIntervalInMilliseconds = policy.maxRetryIntervalInMilliseconds;
|
|
325
|
+
}
|
|
326
|
+
if (policy.retryTimeoutInMilliseconds !== undefined) {
|
|
327
|
+
options.retryTimeoutInMilliseconds = policy.retryTimeoutInMilliseconds;
|
|
328
|
+
}
|
|
329
|
+
return options;
|
|
748
330
|
}
|
|
749
331
|
|
|
750
|
-
function _ts_generator$2(thisArg, body) {
|
|
751
|
-
var f, y, t, _ = {
|
|
752
|
-
label: 0,
|
|
753
|
-
sent: function() {
|
|
754
|
-
if (t[0] & 1) throw t[1];
|
|
755
|
-
return t[1];
|
|
756
|
-
},
|
|
757
|
-
trys: [],
|
|
758
|
-
ops: []
|
|
759
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
760
|
-
return d(g, "next", {
|
|
761
|
-
value: verb(0)
|
|
762
|
-
}), d(g, "throw", {
|
|
763
|
-
value: verb(1)
|
|
764
|
-
}), d(g, "return", {
|
|
765
|
-
value: verb(2)
|
|
766
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
767
|
-
value: function() {
|
|
768
|
-
return this;
|
|
769
|
-
}
|
|
770
|
-
}), g;
|
|
771
|
-
function verb(n) {
|
|
772
|
-
return function(v) {
|
|
773
|
-
return step([
|
|
774
|
-
n,
|
|
775
|
-
v
|
|
776
|
-
]);
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
function step(op) {
|
|
780
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
781
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
782
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
783
|
-
if (y = 0, t) op = [
|
|
784
|
-
op[0] & 2,
|
|
785
|
-
t.value
|
|
786
|
-
];
|
|
787
|
-
switch(op[0]){
|
|
788
|
-
case 0:
|
|
789
|
-
case 1:
|
|
790
|
-
t = op;
|
|
791
|
-
break;
|
|
792
|
-
case 4:
|
|
793
|
-
_.label++;
|
|
794
|
-
return {
|
|
795
|
-
value: op[1],
|
|
796
|
-
done: false
|
|
797
|
-
};
|
|
798
|
-
case 5:
|
|
799
|
-
_.label++;
|
|
800
|
-
y = op[1];
|
|
801
|
-
op = [
|
|
802
|
-
0
|
|
803
|
-
];
|
|
804
|
-
continue;
|
|
805
|
-
case 7:
|
|
806
|
-
op = _.ops.pop();
|
|
807
|
-
_.trys.pop();
|
|
808
|
-
continue;
|
|
809
|
-
default:
|
|
810
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
811
|
-
_ = 0;
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
815
|
-
_.label = op[1];
|
|
816
|
-
break;
|
|
817
|
-
}
|
|
818
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
819
|
-
_.label = t[1];
|
|
820
|
-
t = op;
|
|
821
|
-
break;
|
|
822
|
-
}
|
|
823
|
-
if (t && _.label < t[2]) {
|
|
824
|
-
_.label = t[2];
|
|
825
|
-
_.ops.push(op);
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
if (t[2]) _.ops.pop();
|
|
829
|
-
_.trys.pop();
|
|
830
|
-
continue;
|
|
831
|
-
}
|
|
832
|
-
op = body.call(thisArg, _);
|
|
833
|
-
} catch (e) {
|
|
834
|
-
op = [
|
|
835
|
-
6,
|
|
836
|
-
e
|
|
837
|
-
];
|
|
838
|
-
y = 0;
|
|
839
|
-
} finally{
|
|
840
|
-
f = t = 0;
|
|
841
|
-
}
|
|
842
|
-
if (op[0] & 5) throw op[1];
|
|
843
|
-
return {
|
|
844
|
-
value: op[0] ? op[1] : void 0,
|
|
845
|
-
done: true
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
332
|
/**
|
|
850
333
|
* Waits for every task, preserving tuple positions.
|
|
851
334
|
*
|
|
@@ -859,25 +342,10 @@ function _ts_generator$2(thisArg, body) {
|
|
|
859
342
|
* @returns A generator whose return value is the outputs, in input order.
|
|
860
343
|
* @throws `AggregatedError` when any task failed, matching the SDK.
|
|
861
344
|
* @typeParam T - The tuple of tasks.
|
|
862
|
-
*/
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
case 0:
|
|
867
|
-
return [
|
|
868
|
-
4,
|
|
869
|
-
context.df.Task.all(tasks.map(function(t) {
|
|
870
|
-
return t.task;
|
|
871
|
-
}))
|
|
872
|
-
];
|
|
873
|
-
case 1:
|
|
874
|
-
results = _state.sent();
|
|
875
|
-
return [
|
|
876
|
-
2,
|
|
877
|
-
results
|
|
878
|
-
];
|
|
879
|
-
}
|
|
880
|
-
});
|
|
345
|
+
*/
|
|
346
|
+
function* all(context, tasks) {
|
|
347
|
+
const results = yield context.df.Task.all(tasks.map(t => t.task));
|
|
348
|
+
return results;
|
|
881
349
|
}
|
|
882
350
|
/**
|
|
883
351
|
* Waits for the first task to complete and returns **which one won**.
|
|
@@ -901,34 +369,17 @@ function _ts_generator$2(thisArg, body) {
|
|
|
901
369
|
* @returns A generator whose return value is the winning task.
|
|
902
370
|
* @throws Error when the SDK returns a task that was not one of the inputs.
|
|
903
371
|
* @typeParam T - The tuple of tasks.
|
|
904
|
-
*/
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
case 1:
|
|
916
|
-
won = _state.sent();
|
|
917
|
-
winner = tasks.find(function(t) {
|
|
918
|
-
return t.task === won;
|
|
919
|
-
});
|
|
920
|
-
if (winner === undefined) {
|
|
921
|
-
// Not defensive padding: if this ever fires, the SDK returned something
|
|
922
|
-
// other than one of the tasks handed to it, and silently returning the
|
|
923
|
-
// wrong element would misroute the branch the caller takes next.
|
|
924
|
-
throw new Error('Task.any returned a task that was not one of the inputs.');
|
|
925
|
-
}
|
|
926
|
-
return [
|
|
927
|
-
2,
|
|
928
|
-
winner
|
|
929
|
-
];
|
|
930
|
-
}
|
|
931
|
-
});
|
|
372
|
+
*/
|
|
373
|
+
function* any(context, tasks) {
|
|
374
|
+
const won = yield context.df.Task.any(tasks.map(t => t.task));
|
|
375
|
+
const winner = tasks.find(t => t.task === won);
|
|
376
|
+
if (winner === undefined) {
|
|
377
|
+
// Not defensive padding: if this ever fires, the SDK returned something
|
|
378
|
+
// other than one of the tasks handed to it, and silently returning the
|
|
379
|
+
// wrong element would misroute the branch the caller takes next.
|
|
380
|
+
throw new Error('Task.any returned a task that was not one of the inputs.');
|
|
381
|
+
}
|
|
382
|
+
return winner;
|
|
932
383
|
}
|
|
933
384
|
/**
|
|
934
385
|
* Reads a completed task's result, typed.
|
|
@@ -942,135 +393,11 @@ function _ts_generator$2(thisArg, body) {
|
|
|
942
393
|
* @returns Its result, typed as the task's output.
|
|
943
394
|
* @throws Never - reads a property.
|
|
944
395
|
* @typeParam TOutput - The task's output type.
|
|
945
|
-
*/
|
|
946
|
-
|
|
396
|
+
*/
|
|
397
|
+
function resultOf(task) {
|
|
398
|
+
return task.task.result;
|
|
947
399
|
}
|
|
948
400
|
|
|
949
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
950
|
-
try {
|
|
951
|
-
var info = gen[key](arg);
|
|
952
|
-
var value = info.value;
|
|
953
|
-
} catch (error) {
|
|
954
|
-
reject(error);
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
if (info.done) resolve(value);
|
|
958
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
959
|
-
}
|
|
960
|
-
function _async_to_generator(fn) {
|
|
961
|
-
return function() {
|
|
962
|
-
var self = this, args = arguments;
|
|
963
|
-
return new Promise(function(resolve, reject) {
|
|
964
|
-
var gen = fn.apply(self, args);
|
|
965
|
-
function _next(value) {
|
|
966
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
967
|
-
}
|
|
968
|
-
function _throw(err) {
|
|
969
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
970
|
-
}
|
|
971
|
-
_next(undefined);
|
|
972
|
-
});
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
function _ts_generator$1(thisArg, body) {
|
|
976
|
-
var f, y, t, _ = {
|
|
977
|
-
label: 0,
|
|
978
|
-
sent: function() {
|
|
979
|
-
if (t[0] & 1) throw t[1];
|
|
980
|
-
return t[1];
|
|
981
|
-
},
|
|
982
|
-
trys: [],
|
|
983
|
-
ops: []
|
|
984
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
985
|
-
return d(g, "next", {
|
|
986
|
-
value: verb(0)
|
|
987
|
-
}), d(g, "throw", {
|
|
988
|
-
value: verb(1)
|
|
989
|
-
}), d(g, "return", {
|
|
990
|
-
value: verb(2)
|
|
991
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
992
|
-
value: function() {
|
|
993
|
-
return this;
|
|
994
|
-
}
|
|
995
|
-
}), g;
|
|
996
|
-
function verb(n) {
|
|
997
|
-
return function(v) {
|
|
998
|
-
return step([
|
|
999
|
-
n,
|
|
1000
|
-
v
|
|
1001
|
-
]);
|
|
1002
|
-
};
|
|
1003
|
-
}
|
|
1004
|
-
function step(op) {
|
|
1005
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1006
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1007
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1008
|
-
if (y = 0, t) op = [
|
|
1009
|
-
op[0] & 2,
|
|
1010
|
-
t.value
|
|
1011
|
-
];
|
|
1012
|
-
switch(op[0]){
|
|
1013
|
-
case 0:
|
|
1014
|
-
case 1:
|
|
1015
|
-
t = op;
|
|
1016
|
-
break;
|
|
1017
|
-
case 4:
|
|
1018
|
-
_.label++;
|
|
1019
|
-
return {
|
|
1020
|
-
value: op[1],
|
|
1021
|
-
done: false
|
|
1022
|
-
};
|
|
1023
|
-
case 5:
|
|
1024
|
-
_.label++;
|
|
1025
|
-
y = op[1];
|
|
1026
|
-
op = [
|
|
1027
|
-
0
|
|
1028
|
-
];
|
|
1029
|
-
continue;
|
|
1030
|
-
case 7:
|
|
1031
|
-
op = _.ops.pop();
|
|
1032
|
-
_.trys.pop();
|
|
1033
|
-
continue;
|
|
1034
|
-
default:
|
|
1035
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1036
|
-
_ = 0;
|
|
1037
|
-
continue;
|
|
1038
|
-
}
|
|
1039
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1040
|
-
_.label = op[1];
|
|
1041
|
-
break;
|
|
1042
|
-
}
|
|
1043
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1044
|
-
_.label = t[1];
|
|
1045
|
-
t = op;
|
|
1046
|
-
break;
|
|
1047
|
-
}
|
|
1048
|
-
if (t && _.label < t[2]) {
|
|
1049
|
-
_.label = t[2];
|
|
1050
|
-
_.ops.push(op);
|
|
1051
|
-
break;
|
|
1052
|
-
}
|
|
1053
|
-
if (t[2]) _.ops.pop();
|
|
1054
|
-
_.trys.pop();
|
|
1055
|
-
continue;
|
|
1056
|
-
}
|
|
1057
|
-
op = body.call(thisArg, _);
|
|
1058
|
-
} catch (e) {
|
|
1059
|
-
op = [
|
|
1060
|
-
6,
|
|
1061
|
-
e
|
|
1062
|
-
];
|
|
1063
|
-
y = 0;
|
|
1064
|
-
} finally{
|
|
1065
|
-
f = t = 0;
|
|
1066
|
-
}
|
|
1067
|
-
if (op[0] & 5) throw op[1];
|
|
1068
|
-
return {
|
|
1069
|
-
value: op[0] ? op[1] : void 0,
|
|
1070
|
-
done: true
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
401
|
/**
|
|
1075
402
|
* Declares an external event and its payload type.
|
|
1076
403
|
*
|
|
@@ -1083,10 +410,11 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1083
410
|
* @returns The event reference.
|
|
1084
411
|
* @throws Never - constructs an object.
|
|
1085
412
|
* @typeParam TPayload - The payload type.
|
|
1086
|
-
*/
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
413
|
+
*/
|
|
414
|
+
function defineEvent(name) {
|
|
415
|
+
return {
|
|
416
|
+
name
|
|
417
|
+
};
|
|
1090
418
|
}
|
|
1091
419
|
/**
|
|
1092
420
|
* Waits for an external event and returns its typed payload.
|
|
@@ -1099,23 +427,10 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1099
427
|
* @returns A generator whose return value is the event payload.
|
|
1100
428
|
* @throws Never - resolves when the event arrives.
|
|
1101
429
|
* @typeParam TPayload - The payload type.
|
|
1102
|
-
*/
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
case 0:
|
|
1107
|
-
return [
|
|
1108
|
-
4,
|
|
1109
|
-
eventTask(context, event).task
|
|
1110
|
-
];
|
|
1111
|
-
case 1:
|
|
1112
|
-
payload = _state.sent();
|
|
1113
|
-
return [
|
|
1114
|
-
2,
|
|
1115
|
-
payload
|
|
1116
|
-
];
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
430
|
+
*/
|
|
431
|
+
function* waitForEvent(context, event) {
|
|
432
|
+
const payload = yield eventTask(context, event).task;
|
|
433
|
+
return payload;
|
|
1119
434
|
}
|
|
1120
435
|
/**
|
|
1121
436
|
* Schedules a wait for an external event, without yielding it.
|
|
@@ -1133,10 +448,11 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1133
448
|
* @returns A task carrying the event's payload type.
|
|
1134
449
|
* @throws Never - scheduling only.
|
|
1135
450
|
* @typeParam TPayload - The payload type.
|
|
1136
|
-
*/
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
451
|
+
*/
|
|
452
|
+
function eventTask(context, event) {
|
|
453
|
+
return {
|
|
454
|
+
task: context.df.waitForExternalEvent(event.name)
|
|
455
|
+
};
|
|
1140
456
|
}
|
|
1141
457
|
/**
|
|
1142
458
|
* Raises an external event to a waiting instance, with a checked payload.
|
|
@@ -1153,144 +469,11 @@ function _ts_generator$1(thisArg, body) {
|
|
|
1153
469
|
* @returns A promise resolving when the event is enqueued.
|
|
1154
470
|
* @throws Propagates whatever the client throws.
|
|
1155
471
|
* @typeParam TPayload - The payload type.
|
|
1156
|
-
*/
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
switch(_state.label){
|
|
1160
|
-
case 0:
|
|
1161
|
-
return [
|
|
1162
|
-
4,
|
|
1163
|
-
client.raiseEvent(instanceId, event.name, payload)
|
|
1164
|
-
];
|
|
1165
|
-
case 1:
|
|
1166
|
-
_state.sent();
|
|
1167
|
-
return [
|
|
1168
|
-
2
|
|
1169
|
-
];
|
|
1170
|
-
}
|
|
1171
|
-
});
|
|
1172
|
-
})();
|
|
472
|
+
*/
|
|
473
|
+
async function raiseEvent(client, instanceId, event, payload) {
|
|
474
|
+
await client.raiseEvent(instanceId, event.name, payload);
|
|
1173
475
|
}
|
|
1174
476
|
|
|
1175
|
-
function _ts_generator(thisArg, body) {
|
|
1176
|
-
var f, y, t, _ = {
|
|
1177
|
-
label: 0,
|
|
1178
|
-
sent: function() {
|
|
1179
|
-
if (t[0] & 1) throw t[1];
|
|
1180
|
-
return t[1];
|
|
1181
|
-
},
|
|
1182
|
-
trys: [],
|
|
1183
|
-
ops: []
|
|
1184
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1185
|
-
return d(g, "next", {
|
|
1186
|
-
value: verb(0)
|
|
1187
|
-
}), d(g, "throw", {
|
|
1188
|
-
value: verb(1)
|
|
1189
|
-
}), d(g, "return", {
|
|
1190
|
-
value: verb(2)
|
|
1191
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1192
|
-
value: function() {
|
|
1193
|
-
return this;
|
|
1194
|
-
}
|
|
1195
|
-
}), g;
|
|
1196
|
-
function verb(n) {
|
|
1197
|
-
return function(v) {
|
|
1198
|
-
return step([
|
|
1199
|
-
n,
|
|
1200
|
-
v
|
|
1201
|
-
]);
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
function step(op) {
|
|
1205
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1206
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1207
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1208
|
-
if (y = 0, t) op = [
|
|
1209
|
-
op[0] & 2,
|
|
1210
|
-
t.value
|
|
1211
|
-
];
|
|
1212
|
-
switch(op[0]){
|
|
1213
|
-
case 0:
|
|
1214
|
-
case 1:
|
|
1215
|
-
t = op;
|
|
1216
|
-
break;
|
|
1217
|
-
case 4:
|
|
1218
|
-
_.label++;
|
|
1219
|
-
return {
|
|
1220
|
-
value: op[1],
|
|
1221
|
-
done: false
|
|
1222
|
-
};
|
|
1223
|
-
case 5:
|
|
1224
|
-
_.label++;
|
|
1225
|
-
y = op[1];
|
|
1226
|
-
op = [
|
|
1227
|
-
0
|
|
1228
|
-
];
|
|
1229
|
-
continue;
|
|
1230
|
-
case 7:
|
|
1231
|
-
op = _.ops.pop();
|
|
1232
|
-
_.trys.pop();
|
|
1233
|
-
continue;
|
|
1234
|
-
default:
|
|
1235
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1236
|
-
_ = 0;
|
|
1237
|
-
continue;
|
|
1238
|
-
}
|
|
1239
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1240
|
-
_.label = op[1];
|
|
1241
|
-
break;
|
|
1242
|
-
}
|
|
1243
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1244
|
-
_.label = t[1];
|
|
1245
|
-
t = op;
|
|
1246
|
-
break;
|
|
1247
|
-
}
|
|
1248
|
-
if (t && _.label < t[2]) {
|
|
1249
|
-
_.label = t[2];
|
|
1250
|
-
_.ops.push(op);
|
|
1251
|
-
break;
|
|
1252
|
-
}
|
|
1253
|
-
if (t[2]) _.ops.pop();
|
|
1254
|
-
_.trys.pop();
|
|
1255
|
-
continue;
|
|
1256
|
-
}
|
|
1257
|
-
op = body.call(thisArg, _);
|
|
1258
|
-
} catch (e) {
|
|
1259
|
-
op = [
|
|
1260
|
-
6,
|
|
1261
|
-
e
|
|
1262
|
-
];
|
|
1263
|
-
y = 0;
|
|
1264
|
-
} finally{
|
|
1265
|
-
f = t = 0;
|
|
1266
|
-
}
|
|
1267
|
-
if (op[0] & 5) throw op[1];
|
|
1268
|
-
return {
|
|
1269
|
-
value: op[0] ? op[1] : void 0,
|
|
1270
|
-
done: true
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
function _ts_values(o) {
|
|
1275
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
1276
|
-
if (m) {
|
|
1277
|
-
return m.call(o);
|
|
1278
|
-
}
|
|
1279
|
-
if (o && typeof o.length === "number") {
|
|
1280
|
-
return {
|
|
1281
|
-
next: function() {
|
|
1282
|
-
if (o && i >= o.length) {
|
|
1283
|
-
o = void 0;
|
|
1284
|
-
}
|
|
1285
|
-
return {
|
|
1286
|
-
value: o && o[i++],
|
|
1287
|
-
done: !o
|
|
1288
|
-
};
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1291
|
-
}
|
|
1292
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
1293
|
-
}
|
|
1294
477
|
/**
|
|
1295
478
|
* The current time, safely for replay.
|
|
1296
479
|
*
|
|
@@ -1304,8 +487,9 @@ function _ts_values(o) {
|
|
|
1304
487
|
* @returns The replay-safe current time.
|
|
1305
488
|
* @throws Never - reads a property.
|
|
1306
489
|
* @typeParam None - this function has no generic type parameters.
|
|
1307
|
-
*/
|
|
1308
|
-
|
|
490
|
+
*/
|
|
491
|
+
function now(context) {
|
|
492
|
+
return context.df.currentUtcDateTime;
|
|
1309
493
|
}
|
|
1310
494
|
/**
|
|
1311
495
|
* Sleeps until an absolute time.
|
|
@@ -1318,21 +502,9 @@ function _ts_values(o) {
|
|
|
1318
502
|
* @returns A generator that completes when the timer fires.
|
|
1319
503
|
* @throws Never - the timer either fires or the instance ends.
|
|
1320
504
|
* @typeParam None - this function has no generic type parameters.
|
|
1321
|
-
*/
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
case 0:
|
|
1325
|
-
return [
|
|
1326
|
-
4,
|
|
1327
|
-
context.df.createTimer(when)
|
|
1328
|
-
];
|
|
1329
|
-
case 1:
|
|
1330
|
-
_state.sent();
|
|
1331
|
-
return [
|
|
1332
|
-
2
|
|
1333
|
-
];
|
|
1334
|
-
}
|
|
1335
|
-
});
|
|
505
|
+
*/
|
|
506
|
+
function* sleepUntil(context, when) {
|
|
507
|
+
yield context.df.createTimer(when);
|
|
1336
508
|
}
|
|
1337
509
|
/**
|
|
1338
510
|
* Sleeps for a duration.
|
|
@@ -1350,21 +522,9 @@ function _ts_values(o) {
|
|
|
1350
522
|
* @returns A generator that completes when the timer fires.
|
|
1351
523
|
* @throws Never - the timer either fires or the instance ends.
|
|
1352
524
|
* @typeParam None - this function has no generic type parameters.
|
|
1353
|
-
*/
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
case 0:
|
|
1357
|
-
return [
|
|
1358
|
-
5,
|
|
1359
|
-
_ts_values(sleepUntil(context, new Date(now(context).getTime() + ms)))
|
|
1360
|
-
];
|
|
1361
|
-
case 1:
|
|
1362
|
-
_state.sent();
|
|
1363
|
-
return [
|
|
1364
|
-
2
|
|
1365
|
-
];
|
|
1366
|
-
}
|
|
1367
|
-
});
|
|
525
|
+
*/
|
|
526
|
+
function* sleepFor(context, ms) {
|
|
527
|
+
yield* sleepUntil(context, new Date(now(context).getTime() + ms));
|
|
1368
528
|
}
|
|
1369
529
|
/**
|
|
1370
530
|
* Schedules a durable timer for an absolute instant, without yielding it.
|
|
@@ -1380,17 +540,16 @@ function _ts_values(o) {
|
|
|
1380
540
|
* @returns A cancellable timer task.
|
|
1381
541
|
* @throws Never - scheduling only.
|
|
1382
542
|
* @typeParam None - this function has no generic type parameters.
|
|
1383
|
-
*/
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
};
|
|
543
|
+
*/
|
|
544
|
+
function timerTaskUntil(context, when) {
|
|
545
|
+
const task = context.df.createTimer(when);
|
|
546
|
+
return {
|
|
547
|
+
task,
|
|
548
|
+
cancel: () => {
|
|
549
|
+
task.cancel();
|
|
550
|
+
},
|
|
551
|
+
isCompleted: () => task.isCompleted
|
|
552
|
+
};
|
|
1394
553
|
}
|
|
1395
554
|
/**
|
|
1396
555
|
* Schedules a durable timer a fixed duration ahead, without yielding it.
|
|
@@ -1404,8 +563,9 @@ function _ts_values(o) {
|
|
|
1404
563
|
* @returns A cancellable timer task.
|
|
1405
564
|
* @throws Never - scheduling only.
|
|
1406
565
|
* @typeParam None - this function has no generic type parameters.
|
|
1407
|
-
*/
|
|
1408
|
-
|
|
566
|
+
*/
|
|
567
|
+
function timerTask(context, ms) {
|
|
568
|
+
return timerTaskUntil(context, new Date(now(context).getTime() + ms));
|
|
1409
569
|
}
|
|
1410
570
|
|
|
1411
571
|
/**
|
|
@@ -1420,8 +580,9 @@ function _ts_values(o) {
|
|
|
1420
580
|
* @returns The same object, with its literal types preserved.
|
|
1421
581
|
* @throws Never - returns its argument.
|
|
1422
582
|
* @typeParam T - The status map's literal type.
|
|
1423
|
-
*/
|
|
1424
|
-
|
|
583
|
+
*/
|
|
584
|
+
function defineStatuses(statuses) {
|
|
585
|
+
return statuses;
|
|
1425
586
|
}
|
|
1426
587
|
/**
|
|
1427
588
|
* Sets the orchestration's custom status from a declared set.
|
|
@@ -1437,8 +598,9 @@ function _ts_values(o) {
|
|
|
1437
598
|
* @returns Nothing.
|
|
1438
599
|
* @throws Never - delegates to the SDK.
|
|
1439
600
|
* @typeParam T - The status map's literal type.
|
|
1440
|
-
*/
|
|
1441
|
-
|
|
601
|
+
*/
|
|
602
|
+
function setStatus(context, statuses, key) {
|
|
603
|
+
context.df.setCustomStatus(statuses[key]);
|
|
1442
604
|
}
|
|
1443
605
|
|
|
1444
606
|
exports.activityTask = activityTask;
|
|
@@ -1463,3 +625,4 @@ exports.subOrchestrationTask = subOrchestrationTask;
|
|
|
1463
625
|
exports.timerTask = timerTask;
|
|
1464
626
|
exports.timerTaskUntil = timerTaskUntil;
|
|
1465
627
|
exports.waitForEvent = waitForEvent;
|
|
628
|
+
//# sourceMappingURL=index.cjs.js.map
|