@temporalio/workflow 1.12.3 → 1.13.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/lib/errors.js +2 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +234 -133
- package/lib/interceptors.js +1 -3
- package/lib/interceptors.js.map +1 -1
- package/lib/internals.d.ts +15 -12
- package/lib/internals.js +65 -13
- package/lib/internals.js.map +1 -1
- package/lib/nexus.d.ts +82 -0
- package/lib/nexus.js +92 -0
- package/lib/nexus.js.map +1 -0
- package/lib/workflow.d.ts +2 -4
- package/lib/workflow.js.map +1 -1
- package/package.json +5 -4
- package/src/errors.ts +3 -2
- package/src/index.ts +5 -1
- package/src/interceptors.ts +279 -144
- package/src/internals.ts +95 -27
- package/src/nexus.ts +228 -0
- package/src/workflow.ts +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/workflow",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "Temporal.io SDK Workflow sub-package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"temporal",
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"types": "lib/index.d.ts",
|
|
23
23
|
"scripts": {},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@temporalio/common": "1.
|
|
26
|
-
"@temporalio/proto": "1.
|
|
25
|
+
"@temporalio/common": "1.13.1",
|
|
26
|
+
"@temporalio/proto": "1.13.1",
|
|
27
|
+
"nexus-rpc": "^0.0.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"source-map": "^0.7.4"
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"src",
|
|
39
40
|
"lib"
|
|
40
41
|
],
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7904e19bc72dcdf9eb0275ecaa585a2ff2fec072"
|
|
42
43
|
}
|
package/src/errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActivityFailure, CancelledFailure, ChildWorkflowFailure } from '@temporalio/common';
|
|
1
|
+
import { ActivityFailure, CancelledFailure, ChildWorkflowFailure, NexusOperationFailure } from '@temporalio/common';
|
|
2
2
|
import { SymbolBasedInstanceOfError } from '@temporalio/common/lib/type-helpers';
|
|
3
3
|
import { coresdk } from '@temporalio/proto';
|
|
4
4
|
|
|
@@ -30,6 +30,7 @@ export class LocalActivityDoBackoff extends Error {
|
|
|
30
30
|
export function isCancellation(err: unknown): boolean {
|
|
31
31
|
return (
|
|
32
32
|
err instanceof CancelledFailure ||
|
|
33
|
-
((err instanceof ActivityFailure || err instanceof ChildWorkflowFailure
|
|
33
|
+
((err instanceof ActivityFailure || err instanceof ChildWorkflowFailure || err instanceof NexusOperationFailure) &&
|
|
34
|
+
err.cause instanceof CancelledFailure)
|
|
34
35
|
);
|
|
35
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -109,7 +109,11 @@ export * from './workflow';
|
|
|
109
109
|
export { ChildWorkflowHandle, ExternalWorkflowHandle } from './workflow-handle';
|
|
110
110
|
export { metricMeter } from './metrics';
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
export { createNexusClient, NexusClientOptions, NexusClient, NexusOperationHandle } from './nexus';
|
|
113
|
+
|
|
114
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
115
|
+
// Deprecated APIs
|
|
116
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
113
117
|
|
|
114
118
|
export {
|
|
115
119
|
/**
|
package/src/interceptors.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type definitions
|
|
3
|
-
*
|
|
4
|
-
* The Workflow specific interceptors are defined here.
|
|
2
|
+
* Type definitions for Workflow interceptors.
|
|
5
3
|
*
|
|
6
4
|
* @module
|
|
7
5
|
*/
|
|
8
6
|
|
|
9
7
|
import {
|
|
10
8
|
ActivityOptions,
|
|
9
|
+
Duration,
|
|
11
10
|
Headers,
|
|
12
11
|
LocalActivityOptions,
|
|
13
12
|
MetricTags,
|
|
@@ -20,14 +19,83 @@ import { ChildWorkflowOptionsWithDefaults, ContinueAsNewOptions } from './interf
|
|
|
20
19
|
|
|
21
20
|
export { Next, Headers };
|
|
22
21
|
|
|
23
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* A function that instantiates {@link WorkflowInterceptors}.
|
|
24
|
+
*
|
|
25
|
+
* Workflow interceptor modules should export an `interceptors` function of this type.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* export function interceptors(): WorkflowInterceptors {
|
|
31
|
+
* return {
|
|
32
|
+
* inbound: [], // Populate with list of inbound interceptor implementations
|
|
33
|
+
* outbound: [], // Populate with list of outbound interceptor implementations
|
|
34
|
+
* internals: [], // Populate with list of internals interceptor implementations
|
|
35
|
+
* };
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export type WorkflowInterceptorsFactory = () => WorkflowInterceptors;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A mapping from interceptor type to an optional list of interceptor implementations
|
|
43
|
+
*/
|
|
44
|
+
export interface WorkflowInterceptors {
|
|
45
|
+
inbound?: WorkflowInboundCallsInterceptor[];
|
|
46
|
+
outbound?: WorkflowOutboundCallsInterceptor[];
|
|
47
|
+
internals?: WorkflowInternalsInterceptor[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Workflow Inbound Calls Interceptors /////////////////////////////////////////////////////////////////////////////////
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Implement any of these methods to intercept Workflow inbound calls like execution, and signal and query handling.
|
|
54
|
+
*/
|
|
55
|
+
export interface WorkflowInboundCallsInterceptor {
|
|
56
|
+
/**
|
|
57
|
+
* Called when Workflow execute method is called
|
|
58
|
+
*
|
|
59
|
+
* @return result of the Workflow execution
|
|
60
|
+
*/
|
|
61
|
+
execute?: (input: WorkflowExecuteInput, next: Next<WorkflowInboundCallsInterceptor, 'execute'>) => Promise<unknown>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Called when Update handler is called
|
|
65
|
+
*
|
|
66
|
+
* @return result of the Update
|
|
67
|
+
*/
|
|
68
|
+
handleUpdate?: (input: UpdateInput, next: Next<WorkflowInboundCallsInterceptor, 'handleUpdate'>) => Promise<unknown>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Called when update validator called
|
|
72
|
+
*/
|
|
73
|
+
validateUpdate?: (input: UpdateInput, next: Next<WorkflowInboundCallsInterceptor, 'validateUpdate'>) => void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Called when signal is delivered to a Workflow execution
|
|
77
|
+
*/
|
|
78
|
+
handleSignal?: (input: SignalInput, next: Next<WorkflowInboundCallsInterceptor, 'handleSignal'>) => Promise<void>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Called when a Workflow is queried
|
|
82
|
+
*
|
|
83
|
+
* @return result of the query
|
|
84
|
+
*/
|
|
85
|
+
handleQuery?: (input: QueryInput, next: Next<WorkflowInboundCallsInterceptor, 'handleQuery'>) => Promise<unknown>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Input for {@link WorkflowInboundCallsInterceptor.execute}.
|
|
90
|
+
*/
|
|
24
91
|
export interface WorkflowExecuteInput {
|
|
25
92
|
readonly args: unknown[];
|
|
26
93
|
readonly headers: Headers;
|
|
27
94
|
}
|
|
28
95
|
|
|
29
|
-
/**
|
|
30
|
-
* WorkflowInboundCallsInterceptor.validateUpdate
|
|
96
|
+
/**
|
|
97
|
+
* Input for {@link WorkflowInboundCallsInterceptor.handleUpdate} and {@link WorkflowInboundCallsInterceptor.validateUpdate}.
|
|
98
|
+
*/
|
|
31
99
|
export interface UpdateInput {
|
|
32
100
|
readonly updateId: string;
|
|
33
101
|
readonly name: string;
|
|
@@ -35,14 +103,18 @@ export interface UpdateInput {
|
|
|
35
103
|
readonly headers: Headers;
|
|
36
104
|
}
|
|
37
105
|
|
|
38
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Input for {@link WorkflowInboundCallsInterceptor.handleSignal}.
|
|
108
|
+
*/
|
|
39
109
|
export interface SignalInput {
|
|
40
110
|
readonly signalName: string;
|
|
41
111
|
readonly args: unknown[];
|
|
42
112
|
readonly headers: Headers;
|
|
43
113
|
}
|
|
44
114
|
|
|
45
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Input for {@link WorkflowInboundCallsInterceptor.handleQuery}.
|
|
117
|
+
*/
|
|
46
118
|
export interface QueryInput {
|
|
47
119
|
readonly queryId: string;
|
|
48
120
|
readonly queryName: string;
|
|
@@ -50,38 +122,123 @@ export interface QueryInput {
|
|
|
50
122
|
readonly headers: Headers;
|
|
51
123
|
}
|
|
52
124
|
|
|
125
|
+
// Workflow Outbound Calls Interceptors /////////////////////////////////////////////////////////////////////////////////
|
|
126
|
+
|
|
53
127
|
/**
|
|
54
|
-
* Implement any of these methods to intercept Workflow
|
|
128
|
+
* Implement any of these methods to intercept Workflow code calls to the Temporal APIs, like scheduling an activity
|
|
129
|
+
* and starting a timer.
|
|
55
130
|
*/
|
|
56
|
-
export interface
|
|
131
|
+
export interface WorkflowOutboundCallsInterceptor {
|
|
57
132
|
/**
|
|
58
|
-
* Called when Workflow
|
|
133
|
+
* Called when Workflow starts a timer.
|
|
134
|
+
*/
|
|
135
|
+
startTimer?: (input: TimerInput, next: Next<WorkflowOutboundCallsInterceptor, 'startTimer'>) => Promise<void>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Called when Workflow schedules an Activity.
|
|
59
139
|
*
|
|
60
|
-
* @return result of the
|
|
140
|
+
* @return result of the activity execution
|
|
61
141
|
*/
|
|
62
|
-
|
|
142
|
+
scheduleActivity?: (
|
|
143
|
+
input: ActivityInput,
|
|
144
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'scheduleActivity'>
|
|
145
|
+
) => Promise<unknown>;
|
|
63
146
|
|
|
64
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Called when Workflow schedules a local Activity.
|
|
65
149
|
*
|
|
66
|
-
* @return result of the
|
|
150
|
+
* @return result of the activity execution
|
|
67
151
|
*/
|
|
68
|
-
|
|
152
|
+
scheduleLocalActivity?: (
|
|
153
|
+
input: LocalActivityInput,
|
|
154
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'scheduleLocalActivity'>
|
|
155
|
+
) => Promise<unknown>;
|
|
69
156
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Called when Workflow starts a Nexus Operation.
|
|
159
|
+
*
|
|
160
|
+
* @experimental Nexus support in Temporal SDK is experimental.
|
|
161
|
+
*/
|
|
162
|
+
startNexusOperation?: (
|
|
163
|
+
input: StartNexusOperationInput,
|
|
164
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'startNexusOperation'>
|
|
165
|
+
) => Promise<StartNexusOperationOutput>;
|
|
72
166
|
|
|
73
|
-
/**
|
|
74
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Called when Workflow starts a child workflow execution.
|
|
169
|
+
*
|
|
170
|
+
* The interceptor function returns 2 promises:
|
|
171
|
+
* - The first resolves with the `runId` when the child workflow has started or rejects if failed to start.
|
|
172
|
+
* - The second resolves with the workflow result when the child workflow completes or rejects on failure.
|
|
173
|
+
*/
|
|
174
|
+
startChildWorkflowExecution?: (
|
|
175
|
+
input: StartChildWorkflowExecutionInput,
|
|
176
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'startChildWorkflowExecution'>
|
|
177
|
+
) => Promise<[Promise<string>, Promise<unknown>]>;
|
|
75
178
|
|
|
76
179
|
/**
|
|
77
|
-
* Called when a
|
|
180
|
+
* Called when Workflow signals a child or external Workflow.
|
|
181
|
+
*/
|
|
182
|
+
signalWorkflow?: (
|
|
183
|
+
input: SignalWorkflowInput,
|
|
184
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'signalWorkflow'>
|
|
185
|
+
) => Promise<void>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Called when Workflow calls continueAsNew.
|
|
189
|
+
*/
|
|
190
|
+
continueAsNew?: (
|
|
191
|
+
input: ContinueAsNewInput,
|
|
192
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'continueAsNew'>
|
|
193
|
+
) => Promise<never>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Called on each invocation of the `workflow.log` methods.
|
|
78
197
|
*
|
|
79
|
-
*
|
|
198
|
+
* The attributes returned in this call are attached to every log message.
|
|
80
199
|
*/
|
|
81
|
-
|
|
200
|
+
getLogAttributes?: (
|
|
201
|
+
input: GetLogAttributesInput,
|
|
202
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'getLogAttributes'>
|
|
203
|
+
) => Record<string, unknown>;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Called once every time a metric is emitted from a Workflow metric (ie. a metric created
|
|
207
|
+
* from {@link workflow.metricMeter}).
|
|
208
|
+
*
|
|
209
|
+
* Tags returned by this hook are _prepended_ to tags defined at the metric level and tags
|
|
210
|
+
* defined on the emitter function itself.
|
|
211
|
+
*/
|
|
212
|
+
getMetricTags?: (
|
|
213
|
+
input: GetMetricTagsInput,
|
|
214
|
+
next: Next<WorkflowOutboundCallsInterceptor, 'getMetricTags'>
|
|
215
|
+
) => MetricTags;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.startTimer}
|
|
220
|
+
*/
|
|
221
|
+
export interface TimerInput {
|
|
222
|
+
readonly durationMs: number;
|
|
223
|
+
readonly seq: number;
|
|
224
|
+
readonly options?: TimerOptions;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Options for starting a timer (i.e. sleep)
|
|
229
|
+
*/
|
|
230
|
+
export interface TimerOptions {
|
|
231
|
+
/**
|
|
232
|
+
* A fixed, single line summary of the command's purpose
|
|
233
|
+
*
|
|
234
|
+
* @experimental User metadata is a new API and susceptible to change.
|
|
235
|
+
*/
|
|
236
|
+
readonly summary?: string;
|
|
82
237
|
}
|
|
83
238
|
|
|
84
|
-
/**
|
|
239
|
+
/**
|
|
240
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.scheduleActivity}.
|
|
241
|
+
*/
|
|
85
242
|
export interface ActivityInput {
|
|
86
243
|
readonly activityType: string;
|
|
87
244
|
readonly args: unknown[];
|
|
@@ -90,7 +247,9 @@ export interface ActivityInput {
|
|
|
90
247
|
readonly seq: number;
|
|
91
248
|
}
|
|
92
249
|
|
|
93
|
-
/**
|
|
250
|
+
/**
|
|
251
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.scheduleLocalActivity}.
|
|
252
|
+
*/
|
|
94
253
|
export interface LocalActivityInput {
|
|
95
254
|
readonly activityType: string;
|
|
96
255
|
readonly args: unknown[];
|
|
@@ -101,40 +260,77 @@ export interface LocalActivityInput {
|
|
|
101
260
|
readonly attempt: number;
|
|
102
261
|
}
|
|
103
262
|
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
263
|
+
/**
|
|
264
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.startNexusOperation}.
|
|
265
|
+
*
|
|
266
|
+
* @experimental Nexus support in Temporal SDK is experimental.
|
|
267
|
+
*/
|
|
268
|
+
export interface StartNexusOperationInput {
|
|
269
|
+
readonly input: unknown;
|
|
270
|
+
readonly endpoint: string;
|
|
271
|
+
readonly service: string;
|
|
272
|
+
readonly options: StartNexusOperationOptions;
|
|
273
|
+
readonly operation: string;
|
|
109
274
|
readonly seq: number;
|
|
275
|
+
readonly headers: Record<string, string>;
|
|
110
276
|
}
|
|
111
277
|
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Options for starting a Nexus Operation.
|
|
280
|
+
*
|
|
281
|
+
* @experimental Nexus support in Temporal SDK is experimental.
|
|
282
|
+
*/
|
|
283
|
+
export interface StartNexusOperationOptions {
|
|
284
|
+
/**
|
|
285
|
+
* The end to end timeout for the Nexus Operation.
|
|
286
|
+
*
|
|
287
|
+
* Optional: defaults to the maximum allowed by the Temporal server.
|
|
288
|
+
*/
|
|
289
|
+
readonly scheduleToCloseTimeout?: Duration;
|
|
118
290
|
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
291
|
+
/**
|
|
292
|
+
* A fixed, single-line summary for this Nexus Operation that may appear in the UI/CLI.
|
|
293
|
+
* This can be in single-line Temporal markdown format.
|
|
294
|
+
*
|
|
295
|
+
* @experimental User metadata is a new API and susceptible to change.
|
|
296
|
+
*/
|
|
122
297
|
readonly summary?: string;
|
|
123
298
|
}
|
|
124
299
|
|
|
125
300
|
/**
|
|
126
|
-
*
|
|
301
|
+
* Output for {@link WorkflowOutboundCallsInterceptor.startNexusOperation}.
|
|
302
|
+
*
|
|
303
|
+
* @experimental Nexus support in Temporal SDK is experimental.
|
|
127
304
|
*/
|
|
128
|
-
export
|
|
305
|
+
export interface StartNexusOperationOutput {
|
|
306
|
+
/**
|
|
307
|
+
* The token for the Nexus Operation.
|
|
308
|
+
*
|
|
309
|
+
* Undefined if the Nexus Operation completed synchronously, in which case the {@link result}
|
|
310
|
+
* will be immediately resolved.
|
|
311
|
+
*/
|
|
312
|
+
readonly token?: string;
|
|
129
313
|
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
314
|
+
/**
|
|
315
|
+
* A promise that will resolve when the Nexus Operation completes, either with the result of the
|
|
316
|
+
* Operation if it completed successfully, or a failure if the Nexus Operation failed.
|
|
317
|
+
*/
|
|
318
|
+
readonly result: Promise<unknown>;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.startChildWorkflowExecution}.
|
|
323
|
+
*/
|
|
324
|
+
export interface StartChildWorkflowExecutionInput {
|
|
325
|
+
readonly workflowType: string;
|
|
326
|
+
readonly options: ChildWorkflowOptionsWithDefaults;
|
|
133
327
|
readonly headers: Headers;
|
|
134
|
-
readonly
|
|
328
|
+
readonly seq: number;
|
|
135
329
|
}
|
|
136
330
|
|
|
137
|
-
/**
|
|
331
|
+
/**
|
|
332
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.signalWorkflow}.
|
|
333
|
+
*/
|
|
138
334
|
export interface SignalWorkflowInput {
|
|
139
335
|
readonly seq: number;
|
|
140
336
|
readonly signalName: string;
|
|
@@ -151,90 +347,31 @@ export interface SignalWorkflowInput {
|
|
|
151
347
|
};
|
|
152
348
|
}
|
|
153
349
|
|
|
154
|
-
/** Input for WorkflowOutboundCallsInterceptor.getLogAttributes */
|
|
155
|
-
export type GetLogAttributesInput = Record<string, unknown>;
|
|
156
|
-
|
|
157
|
-
/** Input for WorkflowOutboundCallsInterceptor.getMetricTags */
|
|
158
|
-
export type GetMetricTagsInput = MetricTags;
|
|
159
|
-
|
|
160
350
|
/**
|
|
161
|
-
*
|
|
351
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.continueAsNew}.
|
|
162
352
|
*/
|
|
163
|
-
export interface
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* @return result of the activity execution
|
|
168
|
-
*/
|
|
169
|
-
scheduleActivity?: (input: ActivityInput, next: Next<this, 'scheduleActivity'>) => Promise<unknown>;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Called when Workflow schedules a local Activity
|
|
173
|
-
*
|
|
174
|
-
* @return result of the activity execution
|
|
175
|
-
*/
|
|
176
|
-
scheduleLocalActivity?: (input: LocalActivityInput, next: Next<this, 'scheduleLocalActivity'>) => Promise<unknown>;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Called when Workflow starts a timer
|
|
180
|
-
*/
|
|
181
|
-
startTimer?: (input: TimerInput, next: Next<this, 'startTimer'>) => Promise<void>;
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Called when Workflow calls continueAsNew
|
|
185
|
-
*/
|
|
186
|
-
continueAsNew?: (input: ContinueAsNewInput, next: Next<this, 'continueAsNew'>) => Promise<never>;
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Called when Workflow signals a child or external Workflow
|
|
190
|
-
*/
|
|
191
|
-
signalWorkflow?: (input: SignalWorkflowInput, next: Next<this, 'signalWorkflow'>) => Promise<void>;
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Called when Workflow starts a child workflow execution, the interceptor function returns 2 promises:
|
|
195
|
-
*
|
|
196
|
-
* - The first resolves with the `runId` when the child workflow has started or rejects if failed to start.
|
|
197
|
-
* - The second resolves with the workflow result when the child workflow completes or rejects on failure.
|
|
198
|
-
*/
|
|
199
|
-
startChildWorkflowExecution?: (
|
|
200
|
-
input: StartChildWorkflowExecutionInput,
|
|
201
|
-
next: Next<this, 'startChildWorkflowExecution'>
|
|
202
|
-
) => Promise<[Promise<string>, Promise<unknown>]>;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Called on each invocation of the `workflow.log` methods.
|
|
206
|
-
*
|
|
207
|
-
* The attributes returned in this call are attached to every log message.
|
|
208
|
-
*/
|
|
209
|
-
getLogAttributes?: (input: GetLogAttributesInput, next: Next<this, 'getLogAttributes'>) => Record<string, unknown>;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Called once every time a metric is emitted from a Workflow metric (ie. a metric created
|
|
213
|
-
* from {@link workflow.metricMeter}).
|
|
214
|
-
*
|
|
215
|
-
* Tags returned by this hook are _prepended_ to tags defined at the metric level and tags
|
|
216
|
-
* defined on the emitter function itself.
|
|
217
|
-
*/
|
|
218
|
-
getMetricTags?: (input: GetMetricTagsInput, next: Next<this, 'getMetricTags'>) => MetricTags;
|
|
353
|
+
export interface ContinueAsNewInput {
|
|
354
|
+
readonly args: unknown[];
|
|
355
|
+
readonly headers: Headers;
|
|
356
|
+
readonly options: ContinueAsNewInputOptions;
|
|
219
357
|
}
|
|
220
358
|
|
|
221
|
-
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.continueAsNew}.
|
|
361
|
+
*/
|
|
362
|
+
export type ContinueAsNewInputOptions = ContinueAsNewOptions & Required<Pick<ContinueAsNewOptions, 'workflowType'>>;
|
|
225
363
|
|
|
226
|
-
/**
|
|
227
|
-
|
|
364
|
+
/**
|
|
365
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.getLogAttributes}.
|
|
366
|
+
*/
|
|
367
|
+
export type GetLogAttributesInput = Record<string, unknown>;
|
|
228
368
|
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
369
|
+
/**
|
|
370
|
+
* Input for {@link WorkflowOutboundCallsInterceptor.getMetricTags}.
|
|
371
|
+
*/
|
|
372
|
+
export type GetMetricTagsInput = MetricTags;
|
|
234
373
|
|
|
235
|
-
|
|
236
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
237
|
-
export interface DisposeInput {}
|
|
374
|
+
// Workflow Internals Interceptors /////////////////////////////////////////////////////////////////////////////////////
|
|
238
375
|
|
|
239
376
|
/**
|
|
240
377
|
* Interceptor for the internals of the Workflow runtime.
|
|
@@ -265,29 +402,27 @@ export interface WorkflowInternalsInterceptor {
|
|
|
265
402
|
}
|
|
266
403
|
|
|
267
404
|
/**
|
|
268
|
-
*
|
|
405
|
+
* Input for {@link WorkflowInternalsInterceptor.activate}
|
|
269
406
|
*/
|
|
270
|
-
export interface
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
internals?: WorkflowInternalsInterceptor[];
|
|
407
|
+
export interface ActivateInput {
|
|
408
|
+
readonly activation: coresdk.workflow_activation.IWorkflowActivation;
|
|
409
|
+
readonly batchIndex: number;
|
|
274
410
|
}
|
|
275
411
|
|
|
276
412
|
/**
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
* Workflow interceptor modules should export an `interceptors` function of this type.
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
*
|
|
283
|
-
* ```ts
|
|
284
|
-
* export function interceptors(): WorkflowInterceptors {
|
|
285
|
-
* return {
|
|
286
|
-
* inbound: [], // Populate with list of interceptor implementations
|
|
287
|
-
* outbound: [], // Populate with list of interceptor implementations
|
|
288
|
-
* internals: [], // Populate with list of interceptor implementations
|
|
289
|
-
* };
|
|
290
|
-
* }
|
|
291
|
-
* ```
|
|
413
|
+
* Input for {@link WorkflowInternalsInterceptor.dispose}
|
|
292
414
|
*/
|
|
293
|
-
|
|
415
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
416
|
+
export interface DisposeInput {}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Input for {@link WorkflowInternalsInterceptor.concludeActivation}
|
|
420
|
+
*/
|
|
421
|
+
export interface ConcludeActivationInput {
|
|
422
|
+
readonly commands: coresdk.workflow_commands.IWorkflowCommand[];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Output for {@link WorkflowInternalsInterceptor.concludeActivation}
|
|
427
|
+
*/
|
|
428
|
+
export type ConcludeActivationOutput = ConcludeActivationInput;
|