@mastra/temporal 0.5.0 → 0.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +209 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +210 -83
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/run.d.ts +52 -3
- package/dist/run.d.ts.map +1 -1
- package/dist/temporal-workflow-runtime.mjs +265 -47
- package/dist/transforms/activities.d.ts.map +1 -1
- package/dist/transforms/temporal-workflow-runtime.d.mts +23 -109
- package/dist/transforms/temporal-workflow-runtime.d.mts.map +1 -1
- package/dist/worker.cjs +78 -7
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +79 -8
- package/dist/worker.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,8 +1,62 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ApplicationFailure,
|
|
3
|
+
TemporalFailure,
|
|
4
|
+
condition,
|
|
5
|
+
defineQuery,
|
|
6
|
+
defineSignal,
|
|
7
|
+
executeChild,
|
|
8
|
+
isCancellation,
|
|
9
|
+
proxyActivities,
|
|
10
|
+
log,
|
|
11
|
+
setHandler,
|
|
12
|
+
sleep,
|
|
13
|
+
} from '@temporalio/workflow';
|
|
14
|
+
|
|
15
|
+
const resumeSignal = defineSignal('mastra.resume');
|
|
16
|
+
const statusQuery = defineQuery('mastra.status');
|
|
17
|
+
|
|
18
|
+
// The step error an Activity or child Workflow put in its failure details. Failures without them
|
|
19
|
+
// (timeouts, Activities from an older Worker) give the innermost cause's type and message.
|
|
20
|
+
function readStepFailure(error) {
|
|
21
|
+
let current = error;
|
|
22
|
+
while (current) {
|
|
23
|
+
const details = current.details?.[0];
|
|
24
|
+
|
|
25
|
+
if (details?.error) {
|
|
26
|
+
return { error: details.error, ...(details.tripwire && { tripwire: details.tripwire }) };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!current.cause) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
current = current.cause;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { error: { name: current?.type ?? current?.name ?? 'Error', message: current?.message ?? String(error) } };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Records a step as failed, in the core StepResult shape, before its failure ends the run.
|
|
40
|
+
function recordFailure(stepResults, id, payload, startedAt, error) {
|
|
41
|
+
stepResults[id] = {
|
|
42
|
+
__temporalStepResult: true,
|
|
43
|
+
status: 'failed',
|
|
44
|
+
payload,
|
|
45
|
+
...readStepFailure(error),
|
|
46
|
+
startedAt,
|
|
47
|
+
endedAt: Date.now(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
2
50
|
|
|
3
51
|
export class TemporalExecutionEngine {
|
|
4
52
|
startToCloseTimeout;
|
|
5
53
|
activityHandle;
|
|
54
|
+
resumePayloads = new Map();
|
|
55
|
+
suspendedSteps = new Set();
|
|
56
|
+
resumeLabels = new Map();
|
|
57
|
+
currentResult;
|
|
58
|
+
initData;
|
|
59
|
+
initialState;
|
|
6
60
|
|
|
7
61
|
constructor(params) {
|
|
8
62
|
this.startToCloseTimeout = params?.options?.startToCloseTimeout ?? '1 minute';
|
|
@@ -10,65 +64,187 @@ export class TemporalExecutionEngine {
|
|
|
10
64
|
startToCloseTimeout: this.startToCloseTimeout,
|
|
11
65
|
...(params?.options?.retry !== undefined && { retry: params.options.retry }),
|
|
12
66
|
});
|
|
67
|
+
setHandler(resumeSignal, payload => {
|
|
68
|
+
const id = this.resumeTarget(payload);
|
|
69
|
+
if (id !== undefined && !this.resumePayloads.has(id)) {
|
|
70
|
+
this.resumePayloads.set(id, payload);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
setHandler(statusQuery, () => this.currentResult);
|
|
13
74
|
}
|
|
14
75
|
|
|
15
76
|
async execute(params) {
|
|
16
77
|
this.initData = params.input;
|
|
78
|
+
this.initialState = params.initialState;
|
|
17
79
|
this.executionContext = {
|
|
18
80
|
...(params.requestContext !== undefined && { requestContext: params.requestContext }),
|
|
19
81
|
...(params.runId !== undefined && { runId: params.runId }),
|
|
20
82
|
...(params.resourceId !== undefined && { resourceId: params.resourceId }),
|
|
21
|
-
validateInputs: params.validateInputs,
|
|
83
|
+
...(params.validateInputs !== undefined && { validateInputs: params.validateInputs }),
|
|
22
84
|
workflowId: params.workflowId,
|
|
23
85
|
};
|
|
24
|
-
// Step times let start() build Mastra step records. Only recorded on request so runs that
|
|
25
|
-
// never read them (startAsync, runs started before the field existed) keep their result size.
|
|
26
|
-
this.stepMeta = params.recordStepMeta ? {} : undefined;
|
|
27
86
|
let result = params.input;
|
|
28
87
|
const stepResults = {};
|
|
88
|
+
this.currentResult = {
|
|
89
|
+
status: 'running',
|
|
90
|
+
input: params.input,
|
|
91
|
+
state: params.initialState,
|
|
92
|
+
steps: stepResults,
|
|
93
|
+
};
|
|
29
94
|
|
|
30
|
-
|
|
31
|
-
|
|
95
|
+
try {
|
|
96
|
+
for (const entry of params.graph.steps) {
|
|
97
|
+
result = await this.executeEntry(entry, result, stepResults);
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
// An error that isn't a Temporal failure comes from Workflow code. It fails only the Workflow
|
|
101
|
+
// Task, which Temporal retries, so a fixed Worker can still finish the run.
|
|
102
|
+
if (isCancellation(error) || !(error instanceof TemporalFailure)) {
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// The run still fails in Temporal. The details let start() return step records and the
|
|
107
|
+
// step's own error, which a thrown ActivityFailure would lose.
|
|
108
|
+
const failure = readStepFailure(error);
|
|
109
|
+
throw ApplicationFailure.create({
|
|
110
|
+
message: failure.error.message,
|
|
111
|
+
type: failure.error.name,
|
|
112
|
+
cause: error,
|
|
113
|
+
details: [{ ...failure, steps: stepResults }],
|
|
114
|
+
});
|
|
32
115
|
}
|
|
33
116
|
|
|
34
|
-
|
|
117
|
+
this.currentResult = {
|
|
35
118
|
status: 'success',
|
|
36
119
|
input: params.input,
|
|
37
120
|
result,
|
|
38
121
|
state: params.initialState,
|
|
39
122
|
steps: stepResults,
|
|
40
|
-
...(this.stepMeta && { stepMeta: this.stepMeta }),
|
|
41
123
|
};
|
|
124
|
+
return this.currentResult;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
resumeTarget(payload) {
|
|
128
|
+
if (payload?.step !== undefined) {
|
|
129
|
+
return this.suspendedSteps.has(payload.step) ? payload.step : undefined;
|
|
130
|
+
}
|
|
131
|
+
if (payload?.label !== undefined) {
|
|
132
|
+
const labeledStep = this.resumeLabels.get(payload.label);
|
|
133
|
+
return labeledStep !== undefined && this.suspendedSteps.has(labeledStep) ? labeledStep : undefined;
|
|
134
|
+
}
|
|
135
|
+
return this.suspendedSteps.size === 1 ? [...this.suspendedSteps][0] : undefined;
|
|
42
136
|
}
|
|
43
137
|
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
async timed(stepResults, id, run) {
|
|
138
|
+
// Record steps in the core StepResult shape ({ status, payload, output, startedAt, endedAt }).
|
|
139
|
+
async recordStep(stepResults, id, payload, run, group) {
|
|
47
140
|
const startedAt = Date.now();
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
141
|
+
const attempt = async resumeData => {
|
|
142
|
+
try {
|
|
143
|
+
return await run(resumeData);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
recordFailure(stepResults, id, payload, startedAt, error);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
let output = await attempt();
|
|
150
|
+
let suspendPayload;
|
|
151
|
+
let resumeData;
|
|
152
|
+
|
|
153
|
+
while (output?.__temporalSuspension === true) {
|
|
154
|
+
suspendPayload = output.suspendPayload;
|
|
155
|
+
stepResults[id] = {
|
|
156
|
+
__temporalStepResult: true,
|
|
157
|
+
status: 'suspended',
|
|
158
|
+
payload,
|
|
159
|
+
suspendPayload,
|
|
160
|
+
suspendedAt: Date.now(),
|
|
161
|
+
};
|
|
162
|
+
for (const [label, target] of Object.entries(output.resumeLabels ?? {})) {
|
|
163
|
+
if (target?.stepId === id) {
|
|
164
|
+
this.resumeLabels.set(label, id);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
this.currentResult = {
|
|
168
|
+
status: 'suspended',
|
|
169
|
+
input: this.initData,
|
|
170
|
+
state: this.initialState,
|
|
171
|
+
steps: stepResults,
|
|
172
|
+
suspended: [[id]],
|
|
173
|
+
suspendPayload: { [id]: suspendPayload },
|
|
174
|
+
resumeLabels: Object.fromEntries([...this.resumeLabels].map(([label, stepId]) => [label, { stepId }])),
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
this.suspendedSteps.add(id);
|
|
178
|
+
try {
|
|
179
|
+
await condition(() => this.resumePayloads.has(id) || group?.failed === true);
|
|
180
|
+
// A failed sibling branch ends the run, so the step stays suspended in the records.
|
|
181
|
+
if (!this.resumePayloads.has(id)) {
|
|
182
|
+
return output;
|
|
183
|
+
}
|
|
184
|
+
resumeData = this.resumePayloads.get(id)?.resumeData;
|
|
185
|
+
this.resumePayloads.delete(id);
|
|
186
|
+
} finally {
|
|
187
|
+
this.suspendedSteps.delete(id);
|
|
188
|
+
for (const [label, stepId] of this.resumeLabels.entries()) {
|
|
189
|
+
if (stepId === id) {
|
|
190
|
+
this.resumeLabels.delete(label);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
this.currentResult = {
|
|
195
|
+
status: 'running',
|
|
196
|
+
input: this.initData,
|
|
197
|
+
state: this.initialState,
|
|
198
|
+
steps: stepResults,
|
|
199
|
+
};
|
|
200
|
+
output = await attempt(resumeData);
|
|
52
201
|
}
|
|
53
|
-
|
|
202
|
+
|
|
203
|
+
stepResults[id] = {
|
|
204
|
+
__temporalStepResult: true,
|
|
205
|
+
status: 'success',
|
|
206
|
+
payload,
|
|
207
|
+
output,
|
|
208
|
+
...(suspendPayload !== undefined && { suspendPayload }),
|
|
209
|
+
...(resumeData !== undefined && { resumeData }),
|
|
210
|
+
startedAt,
|
|
211
|
+
endedAt: Date.now(),
|
|
212
|
+
};
|
|
213
|
+
this.currentResult = {
|
|
214
|
+
status: 'running',
|
|
215
|
+
input: this.initData,
|
|
216
|
+
state: this.initialState,
|
|
217
|
+
steps: stepResults,
|
|
218
|
+
};
|
|
219
|
+
return output;
|
|
54
220
|
}
|
|
55
221
|
|
|
56
222
|
activityParams(inputData, extra = {}) {
|
|
57
223
|
return { inputData, ...extra, ...this.executionContext };
|
|
58
224
|
}
|
|
59
225
|
|
|
60
|
-
async executeEntry(entry, inputData, stepResults) {
|
|
226
|
+
async executeEntry(entry, inputData, stepResults, group) {
|
|
61
227
|
switch (entry.type) {
|
|
62
228
|
case 'step': {
|
|
63
229
|
log.info('step', { stepId: entry.step.id });
|
|
64
|
-
return this.
|
|
65
|
-
|
|
230
|
+
return this.recordStep(
|
|
231
|
+
stepResults,
|
|
232
|
+
entry.step.id,
|
|
233
|
+
inputData,
|
|
234
|
+
resumeData =>
|
|
235
|
+
this.activityHandle[entry.step.id](
|
|
236
|
+
this.activityParams(inputData, {
|
|
237
|
+
initData: this.initData,
|
|
238
|
+
...(resumeData !== undefined && { resumeData }),
|
|
239
|
+
}),
|
|
240
|
+
),
|
|
241
|
+
group,
|
|
66
242
|
);
|
|
67
243
|
}
|
|
68
244
|
|
|
69
245
|
case 'childWorkflow': {
|
|
70
246
|
log.info('childWorkflow', { workflowType: entry.workflowType });
|
|
71
|
-
return this.
|
|
247
|
+
return this.recordStep(stepResults, entry.id ?? entry.workflowType, inputData, async () => {
|
|
72
248
|
const childResult = await executeChild(entry.workflowType, {
|
|
73
249
|
args: [{ inputData, ...this.executionContext }],
|
|
74
250
|
});
|
|
@@ -78,7 +254,7 @@ export class TemporalExecutionEngine {
|
|
|
78
254
|
|
|
79
255
|
case 'mapping': {
|
|
80
256
|
log.info('mapping', { mappingId: entry.id });
|
|
81
|
-
return this.
|
|
257
|
+
return this.recordStep(stepResults, entry.id, inputData, () =>
|
|
82
258
|
this.activityHandle[entry.id](this.activityParams(inputData, { initData: this.initData })),
|
|
83
259
|
);
|
|
84
260
|
}
|
|
@@ -105,16 +281,37 @@ export class TemporalExecutionEngine {
|
|
|
105
281
|
}
|
|
106
282
|
|
|
107
283
|
case 'parallel': {
|
|
108
|
-
// The next step keeps reading a nested workflow under its Temporal type name, as before.
|
|
109
|
-
// Only the step records use the Mastra id.
|
|
110
284
|
const entryId = parallelEntry =>
|
|
111
285
|
parallelEntry.type === 'childWorkflow' ? parallelEntry.workflowType : parallelEntry.step.id;
|
|
112
286
|
log.info('parallel', { steps: entry.steps.map(entryId) });
|
|
113
|
-
|
|
287
|
+
// Waits for every branch, as a local run does, so a failed run keeps the others' records.
|
|
288
|
+
// A failed branch also ends the wait of a suspended one, which would otherwise keep the run
|
|
289
|
+
// open until a resume. The flag is per group so a later parallel starts clean.
|
|
290
|
+
const group = { failed: false };
|
|
291
|
+
const settled = await Promise.allSettled(
|
|
292
|
+
entry.steps.map(step =>
|
|
293
|
+
this.executeEntry(step, inputData, stepResults, group).catch(error => {
|
|
294
|
+
group.failed = true;
|
|
295
|
+
throw error;
|
|
296
|
+
}),
|
|
297
|
+
),
|
|
298
|
+
);
|
|
299
|
+
const failures = settled.filter(outcome => outcome.status === 'rejected');
|
|
300
|
+
// Same order as in execute(), whatever the branch order: a cancelled run ends Canceled, and
|
|
301
|
+
// an error from Workflow code wins so Temporal retries the Workflow Task.
|
|
302
|
+
const rejected =
|
|
303
|
+
failures.find(outcome => isCancellation(outcome.reason)) ??
|
|
304
|
+
failures.find(outcome => !(outcome.reason instanceof TemporalFailure)) ??
|
|
305
|
+
failures[0];
|
|
306
|
+
|
|
307
|
+
if (rejected) {
|
|
308
|
+
throw rejected.reason;
|
|
309
|
+
}
|
|
310
|
+
|
|
114
311
|
const out = {};
|
|
115
312
|
|
|
116
313
|
entry.steps.forEach((step, i) => {
|
|
117
|
-
out[entryId(step)] =
|
|
314
|
+
out[entryId(step)] = settled[i].value;
|
|
118
315
|
});
|
|
119
316
|
|
|
120
317
|
return out;
|
|
@@ -134,8 +331,13 @@ export class TemporalExecutionEngine {
|
|
|
134
331
|
for (let i = 0; i < entry.steps.length; i++) {
|
|
135
332
|
if (condResults[i]) {
|
|
136
333
|
const stepId = entry.steps[i].step.id;
|
|
137
|
-
out[stepId] = await this.
|
|
138
|
-
this.activityHandle[stepId](
|
|
334
|
+
out[stepId] = await this.recordStep(stepResults, stepId, inputData, resumeData =>
|
|
335
|
+
this.activityHandle[stepId](
|
|
336
|
+
this.activityParams(inputData, {
|
|
337
|
+
initData: this.initData,
|
|
338
|
+
...(resumeData !== undefined && { resumeData }),
|
|
339
|
+
}),
|
|
340
|
+
),
|
|
139
341
|
);
|
|
140
342
|
}
|
|
141
343
|
}
|
|
@@ -148,9 +350,14 @@ export class TemporalExecutionEngine {
|
|
|
148
350
|
let current = inputData;
|
|
149
351
|
|
|
150
352
|
while (true) {
|
|
151
|
-
const
|
|
152
|
-
current = await this.
|
|
153
|
-
this.activityHandle[entry.step.id](
|
|
353
|
+
const payload = current;
|
|
354
|
+
current = await this.recordStep(stepResults, entry.step.id, payload, resumeData =>
|
|
355
|
+
this.activityHandle[entry.step.id](
|
|
356
|
+
this.activityParams(payload, {
|
|
357
|
+
initData: this.initData,
|
|
358
|
+
...(resumeData !== undefined && { resumeData }),
|
|
359
|
+
}),
|
|
360
|
+
),
|
|
154
361
|
);
|
|
155
362
|
const shouldContinue = Boolean(
|
|
156
363
|
await this.activityHandle[entry.serializedCondition.id](this.activityParams(current)),
|
|
@@ -173,24 +380,36 @@ export class TemporalExecutionEngine {
|
|
|
173
380
|
: (entry.opts.concurrency ?? 1);
|
|
174
381
|
const concurrency = Number.isFinite(configured) ? Math.max(1, Math.floor(configured)) : 1;
|
|
175
382
|
log.info('foreach', { step: entry.step.id, concurrency });
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
results[i] = await this.activityHandle[entry.step.id](
|
|
186
|
-
this.activityParams(items[i], { initData: this.initData }),
|
|
187
|
-
);
|
|
383
|
+
const startedAt = Date.now();
|
|
384
|
+
const results = new Array(items.length);
|
|
385
|
+
let index = 0;
|
|
386
|
+
const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
387
|
+
while (true) {
|
|
388
|
+
const i = index++;
|
|
389
|
+
if (i >= items.length) {
|
|
390
|
+
break;
|
|
188
391
|
}
|
|
189
|
-
|
|
392
|
+
results[i] = await this.activityHandle[entry.step.id](
|
|
393
|
+
this.activityParams(items[i], { initData: this.initData }),
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
});
|
|
190
397
|
|
|
398
|
+
try {
|
|
191
399
|
await Promise.all(workers);
|
|
192
|
-
|
|
193
|
-
|
|
400
|
+
} catch (error) {
|
|
401
|
+
recordFailure(stepResults, entry.step.id, inputData, startedAt, error);
|
|
402
|
+
throw error;
|
|
403
|
+
}
|
|
404
|
+
stepResults[entry.step.id] = {
|
|
405
|
+
__temporalStepResult: true,
|
|
406
|
+
status: 'success',
|
|
407
|
+
payload: inputData,
|
|
408
|
+
output: results,
|
|
409
|
+
startedAt,
|
|
410
|
+
endedAt: Date.now(),
|
|
411
|
+
};
|
|
412
|
+
return results;
|
|
194
413
|
}
|
|
195
414
|
|
|
196
415
|
default:
|
|
@@ -220,7 +439,6 @@ export function createWorkflow(workflowId, options) {
|
|
|
220
439
|
},
|
|
221
440
|
input: startArgs?.inputData,
|
|
222
441
|
initialState: startArgs?.initialState,
|
|
223
|
-
recordStepMeta: startArgs?.recordStepMeta,
|
|
224
442
|
});
|
|
225
443
|
};
|
|
226
444
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmE/G;
|
|
1
|
+
{"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmE/G;AAkUD,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mCAAmC,CAAC,CAoZ9C"}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
export declare class TemporalExecutionEngine {
|
|
2
|
-
initData: any;
|
|
3
2
|
executionContext: {
|
|
4
3
|
requestContext?: any;
|
|
5
4
|
runId?: any;
|
|
6
5
|
resourceId?: any;
|
|
7
|
-
validateInputs
|
|
6
|
+
validateInputs?: any;
|
|
8
7
|
workflowId: any;
|
|
9
8
|
} | undefined;
|
|
10
|
-
stepMeta: {} | undefined;
|
|
11
9
|
startToCloseTimeout: any;
|
|
12
10
|
activityHandle: import("@temporalio/workflow").ActivityInterfaceFor<import("@temporalio/workflow").UntypedActivities>;
|
|
11
|
+
resumePayloads: Map<any, any>;
|
|
12
|
+
suspendedSteps: Set<any>;
|
|
13
|
+
resumeLabels: Map<any, any>;
|
|
14
|
+
currentResult: any;
|
|
15
|
+
initData: any;
|
|
16
|
+
initialState: any;
|
|
13
17
|
constructor(params: any);
|
|
14
|
-
execute(params: any): Promise<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
result: any;
|
|
18
|
-
state: any;
|
|
19
|
-
steps: {};
|
|
20
|
-
stepMeta?: {} | undefined;
|
|
21
|
-
}>;
|
|
22
|
-
timed(stepResults: any, id: any, run: any): Promise<any>;
|
|
18
|
+
execute(params: any): Promise<any>;
|
|
19
|
+
resumeTarget(payload: any): any;
|
|
20
|
+
recordStep(stepResults: any, id: any, payload: any, run: any, group: any): Promise<any>;
|
|
23
21
|
activityParams(inputData: any, extra?: {}): {
|
|
24
22
|
requestContext?: any;
|
|
25
23
|
runId?: any;
|
|
@@ -28,103 +26,19 @@ export declare class TemporalExecutionEngine {
|
|
|
28
26
|
workflowId?: any;
|
|
29
27
|
inputData: any;
|
|
30
28
|
};
|
|
31
|
-
executeEntry(entry: any, inputData: any, stepResults: any): Promise<any>;
|
|
29
|
+
executeEntry(entry: any, inputData: any, stepResults: any, group: any): Promise<any>;
|
|
32
30
|
}
|
|
33
|
-
export declare function createWorkflow(workflowId: any, options: any): ((startArgs: any) => Promise<{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
state: any;
|
|
46
|
-
steps: {};
|
|
47
|
-
stepMeta?: {} | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
thenWorkflow(workflowType: any, id: any): (startArgs: any) => Promise<{
|
|
50
|
-
status: string;
|
|
51
|
-
input: any;
|
|
52
|
-
result: any;
|
|
53
|
-
state: any;
|
|
54
|
-
steps: {};
|
|
55
|
-
stepMeta?: {} | undefined;
|
|
56
|
-
}>;
|
|
57
|
-
map(mappingId: any): (startArgs: any) => Promise<{
|
|
58
|
-
status: string;
|
|
59
|
-
input: any;
|
|
60
|
-
result: any;
|
|
61
|
-
state: any;
|
|
62
|
-
steps: {};
|
|
63
|
-
stepMeta?: {} | undefined;
|
|
64
|
-
}>;
|
|
65
|
-
sleep(durationOrFnId: any): (startArgs: any) => Promise<{
|
|
66
|
-
status: string;
|
|
67
|
-
input: any;
|
|
68
|
-
result: any;
|
|
69
|
-
state: any;
|
|
70
|
-
steps: {};
|
|
71
|
-
stepMeta?: {} | undefined;
|
|
72
|
-
}>;
|
|
73
|
-
sleepUntil(dateOrFnId: any): (startArgs: any) => Promise<{
|
|
74
|
-
status: string;
|
|
75
|
-
input: any;
|
|
76
|
-
result: any;
|
|
77
|
-
state: any;
|
|
78
|
-
steps: {};
|
|
79
|
-
stepMeta?: {} | undefined;
|
|
80
|
-
}>;
|
|
81
|
-
parallel(entries: any): (startArgs: any) => Promise<{
|
|
82
|
-
status: string;
|
|
83
|
-
input: any;
|
|
84
|
-
result: any;
|
|
85
|
-
state: any;
|
|
86
|
-
steps: {};
|
|
87
|
-
stepMeta?: {} | undefined;
|
|
88
|
-
}>;
|
|
89
|
-
branch(pairs: any): (startArgs: any) => Promise<{
|
|
90
|
-
status: string;
|
|
91
|
-
input: any;
|
|
92
|
-
result: any;
|
|
93
|
-
state: any;
|
|
94
|
-
steps: {};
|
|
95
|
-
stepMeta?: {} | undefined;
|
|
96
|
-
}>;
|
|
97
|
-
dowhile(stepId: any, condId: any): (startArgs: any) => Promise<{
|
|
98
|
-
status: string;
|
|
99
|
-
input: any;
|
|
100
|
-
result: any;
|
|
101
|
-
state: any;
|
|
102
|
-
steps: {};
|
|
103
|
-
stepMeta?: {} | undefined;
|
|
104
|
-
}>;
|
|
105
|
-
dountil(stepId: any, condId: any): (startArgs: any) => Promise<{
|
|
106
|
-
status: string;
|
|
107
|
-
input: any;
|
|
108
|
-
result: any;
|
|
109
|
-
state: any;
|
|
110
|
-
steps: {};
|
|
111
|
-
stepMeta?: {} | undefined;
|
|
112
|
-
}>;
|
|
113
|
-
foreach(stepId: any, opts: any): (startArgs: any) => Promise<{
|
|
114
|
-
status: string;
|
|
115
|
-
input: any;
|
|
116
|
-
result: any;
|
|
117
|
-
state: any;
|
|
118
|
-
steps: {};
|
|
119
|
-
stepMeta?: {} | undefined;
|
|
120
|
-
}>;
|
|
121
|
-
commit(): (startArgs: any) => Promise<{
|
|
122
|
-
status: string;
|
|
123
|
-
input: any;
|
|
124
|
-
result: any;
|
|
125
|
-
state: any;
|
|
126
|
-
steps: {};
|
|
127
|
-
stepMeta?: {} | undefined;
|
|
128
|
-
}>;
|
|
31
|
+
export declare function createWorkflow(workflowId: any, options: any): ((startArgs: any) => Promise<any>) & {
|
|
32
|
+
then(stepId: any): (startArgs: any) => Promise<any>;
|
|
33
|
+
thenWorkflow(workflowType: any, id: any): (startArgs: any) => Promise<any>;
|
|
34
|
+
map(mappingId: any): (startArgs: any) => Promise<any>;
|
|
35
|
+
sleep(durationOrFnId: any): (startArgs: any) => Promise<any>;
|
|
36
|
+
sleepUntil(dateOrFnId: any): (startArgs: any) => Promise<any>;
|
|
37
|
+
parallel(entries: any): (startArgs: any) => Promise<any>;
|
|
38
|
+
branch(pairs: any): (startArgs: any) => Promise<any>;
|
|
39
|
+
dowhile(stepId: any, condId: any): (startArgs: any) => Promise<any>;
|
|
40
|
+
dountil(stepId: any, condId: any): (startArgs: any) => Promise<any>;
|
|
41
|
+
foreach(stepId: any, opts: any): (startArgs: any) => Promise<any>;
|
|
42
|
+
commit(): (startArgs: any) => Promise<any>;
|
|
129
43
|
};
|
|
130
44
|
//# sourceMappingURL=temporal-workflow-runtime.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAkDA,qBAAa,uBAAuB;IA4B3B,gBAAgB;;;;;;;IA3BvB,mBAAmB,MAAC;IACpB,cAAc,wGAAC;IACf,cAAc,gBAAa;IAC3B,cAAc,WAAa;IAC3B,YAAY,gBAAa;IACzB,aAAa,MAAC;IACd,QAAQ,MAAC;IACT,YAAY,MAAC;IAEb,YAAY,MAAM,KAAA,EAajB;IAEK,OAAO,CAAC,MAAM,KAAA,gBAiDnB;IAED,YAAY,CAAC,OAAO,KAAA,OASnB;IAGK,UAAU,CAAC,WAAW,KAAA,EAAE,EAAE,KAAA,EAAE,OAAO,KAAA,EAAE,GAAG,KAAA,EAAE,KAAK,KAAA,gBAiFpD;IAED,cAAc,CAAC,SAAS,KAAA,EAAE,KAAK,KAAK;;;;;;;MAEnC;IAEK,YAAY,CAAC,KAAK,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,EAAE,KAAK,KAAA,gBAgMtD;CACF;AAED,wBAAgB,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA;;;;;;;;;;;;EAuJjD"}
|