@temporalio/workflow 1.10.2 → 1.11.0
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/flags.d.ts +18 -0
- package/lib/flags.js +19 -1
- package/lib/flags.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interfaces.d.ts +35 -13
- package/lib/interfaces.js.map +1 -1
- package/lib/internals.d.ts +58 -20
- package/lib/internals.js +151 -83
- package/lib/internals.js.map +1 -1
- package/lib/update-scope.d.ts +43 -0
- package/lib/update-scope.js +41 -0
- package/lib/update-scope.js.map +1 -0
- package/lib/worker-interface.d.ts +1 -8
- package/lib/worker-interface.js +13 -58
- package/lib/worker-interface.js.map +1 -1
- package/lib/workflow.d.ts +67 -8
- package/lib/workflow.js +108 -13
- package/lib/workflow.js.map +1 -1
- package/package.json +4 -4
- package/src/flags.ts +20 -1
- package/src/index.ts +3 -3
- package/src/interfaces.ts +41 -14
- package/src/internals.ts +192 -88
- package/src/update-scope.ts +67 -0
- package/src/worker-interface.ts +15 -64
- package/src/workflow.ts +118 -13
package/src/flags.ts
CHANGED
|
@@ -16,7 +16,26 @@ export const SdkFlags = {
|
|
|
16
16
|
*
|
|
17
17
|
* @since Introduced in 1.10.2/1.11.0.
|
|
18
18
|
*/
|
|
19
|
-
NonCancellableScopesAreShieldedFromPropagation: defineFlag(1,
|
|
19
|
+
NonCancellableScopesAreShieldedFromPropagation: defineFlag(1, true),
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Prior to 1.11.0, when processing a Workflow activation, the SDK would execute `notifyHasPatch`
|
|
23
|
+
* and `signalWorkflow` jobs in distinct phases, before other types of jobs. The primary reason
|
|
24
|
+
* behind that multi-phase algorithm was to avoid the possibility that a Workflow execution might
|
|
25
|
+
* complete before all incoming signals have been dispatched (at least to the point that the
|
|
26
|
+
* _synchronous_ part of the handler function has been executed).
|
|
27
|
+
*
|
|
28
|
+
* This flag replaces that multi-phase algorithm with a simpler one where jobs are simply sorted as
|
|
29
|
+
* `(signals and updates) -> others`, but without processing them as distinct batches (i.e. without
|
|
30
|
+
* leaving/reentering the VM context between each group, which automatically triggers the execution
|
|
31
|
+
* of all outstanding microtasks). That single-phase approach resolves a number of quirks of the
|
|
32
|
+
* former algorithm, and yet still satisfies to the original requirement of ensuring that every
|
|
33
|
+
* `signalWorkflow` jobs - and now `doUpdate` jobs as well - have been given a proper chance to
|
|
34
|
+
* execute before the Workflow main function might completes.
|
|
35
|
+
*
|
|
36
|
+
* @since Introduced in 1.11.0. This change is not rollback-safe.
|
|
37
|
+
*/
|
|
38
|
+
ProcessWorkflowActivationJobsAsSingleBatch: defineFlag(2, true),
|
|
20
39
|
} as const;
|
|
21
40
|
|
|
22
41
|
function defineFlag(id: number, def: boolean): SdkFlag {
|
package/src/index.ts
CHANGED
|
@@ -92,11 +92,11 @@ export {
|
|
|
92
92
|
ContinueAsNew,
|
|
93
93
|
ContinueAsNewOptions,
|
|
94
94
|
EnhancedStackTrace,
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
StackTraceFileLocation,
|
|
96
|
+
StackTraceFileSlice,
|
|
97
97
|
ParentClosePolicy,
|
|
98
98
|
ParentWorkflowInfo,
|
|
99
|
-
|
|
99
|
+
StackTraceSDKInfo,
|
|
100
100
|
StackTrace,
|
|
101
101
|
UnsafeWorkflowInfo,
|
|
102
102
|
WorkflowInfo,
|
package/src/interfaces.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
RetryPolicy,
|
|
4
4
|
TemporalFailure,
|
|
5
5
|
CommonWorkflowOptions,
|
|
6
|
+
HandlerUnfinishedPolicy,
|
|
6
7
|
SearchAttributes,
|
|
7
8
|
SignalDefinition,
|
|
8
9
|
UpdateDefinition,
|
|
@@ -190,6 +191,23 @@ export interface UnsafeWorkflowInfo {
|
|
|
190
191
|
readonly isReplaying: boolean;
|
|
191
192
|
}
|
|
192
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Information about a workflow update.
|
|
196
|
+
*
|
|
197
|
+
* @experimental
|
|
198
|
+
*/
|
|
199
|
+
export interface UpdateInfo {
|
|
200
|
+
/**
|
|
201
|
+
* A workflow-unique identifier for this update.
|
|
202
|
+
*/
|
|
203
|
+
readonly id: string;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The update type name.
|
|
207
|
+
*/
|
|
208
|
+
readonly name: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
193
211
|
export interface ParentWorkflowInfo {
|
|
194
212
|
workflowId: string;
|
|
195
213
|
runId: string;
|
|
@@ -365,7 +383,7 @@ export type RequiredChildWorkflowOptions = Required<Pick<ChildWorkflowOptions, '
|
|
|
365
383
|
|
|
366
384
|
export type ChildWorkflowOptionsWithDefaults = ChildWorkflowOptions & RequiredChildWorkflowOptions;
|
|
367
385
|
|
|
368
|
-
export interface
|
|
386
|
+
export interface StackTraceSDKInfo {
|
|
369
387
|
name: string;
|
|
370
388
|
version: string;
|
|
371
389
|
}
|
|
@@ -373,26 +391,26 @@ export interface SDKInfo {
|
|
|
373
391
|
/**
|
|
374
392
|
* Represents a slice of a file starting at lineOffset
|
|
375
393
|
*/
|
|
376
|
-
export interface
|
|
394
|
+
export interface StackTraceFileSlice {
|
|
377
395
|
/**
|
|
378
|
-
*
|
|
396
|
+
* Only used possible to trim the file without breaking syntax highlighting.
|
|
379
397
|
*/
|
|
380
|
-
|
|
398
|
+
line_offset: number;
|
|
381
399
|
/**
|
|
382
|
-
*
|
|
400
|
+
* slice of a file with `\n` (newline) line terminator.
|
|
383
401
|
*/
|
|
384
|
-
|
|
402
|
+
content: string;
|
|
385
403
|
}
|
|
386
404
|
|
|
387
405
|
/**
|
|
388
406
|
* A pointer to a location in a file
|
|
389
407
|
*/
|
|
390
|
-
export interface
|
|
408
|
+
export interface StackTraceFileLocation {
|
|
391
409
|
/**
|
|
392
410
|
* Path to source file (absolute or relative).
|
|
393
411
|
* When using a relative path, make sure all paths are relative to the same root.
|
|
394
412
|
*/
|
|
395
|
-
|
|
413
|
+
file_path?: string;
|
|
396
414
|
/**
|
|
397
415
|
* If possible, SDK should send this, required for displaying the code location.
|
|
398
416
|
*/
|
|
@@ -405,24 +423,28 @@ export interface FileLocation {
|
|
|
405
423
|
* Function name this line belongs to (if applicable).
|
|
406
424
|
* Used for falling back to stack trace view.
|
|
407
425
|
*/
|
|
408
|
-
|
|
426
|
+
function_name?: string;
|
|
427
|
+
/**
|
|
428
|
+
* Flag to mark this as internal SDK code and hide by default in the UI.
|
|
429
|
+
*/
|
|
430
|
+
internal_code: boolean;
|
|
409
431
|
}
|
|
410
432
|
|
|
411
433
|
export interface StackTrace {
|
|
412
|
-
locations:
|
|
434
|
+
locations: StackTraceFileLocation[];
|
|
413
435
|
}
|
|
414
436
|
|
|
415
437
|
/**
|
|
416
438
|
* Used as the result for the enhanced stack trace query
|
|
417
439
|
*/
|
|
418
440
|
export interface EnhancedStackTrace {
|
|
419
|
-
sdk:
|
|
441
|
+
sdk: StackTraceSDKInfo;
|
|
420
442
|
/**
|
|
421
443
|
* Mapping of file path to file contents.
|
|
422
444
|
* SDK may choose to send no, some or all sources.
|
|
423
445
|
* Sources might be trimmed, and some time only the file(s) of the top element of the trace will be sent.
|
|
424
446
|
*/
|
|
425
|
-
sources: Record<string,
|
|
447
|
+
sources: Record<string, StackTraceFileSlice[]>;
|
|
426
448
|
stacks: StackTrace[];
|
|
427
449
|
}
|
|
428
450
|
|
|
@@ -431,6 +453,7 @@ export interface WorkflowCreateOptions {
|
|
|
431
453
|
randomnessSeed: number[];
|
|
432
454
|
now: number;
|
|
433
455
|
patches: string[];
|
|
456
|
+
sdkFlags: number[];
|
|
434
457
|
showStackTraceSources: boolean;
|
|
435
458
|
}
|
|
436
459
|
|
|
@@ -473,12 +496,16 @@ export type QueryHandlerOptions = { description?: string };
|
|
|
473
496
|
/**
|
|
474
497
|
* A description of a signal handler.
|
|
475
498
|
*/
|
|
476
|
-
export type SignalHandlerOptions = { description?: string };
|
|
499
|
+
export type SignalHandlerOptions = { description?: string; unfinishedPolicy?: HandlerUnfinishedPolicy };
|
|
477
500
|
|
|
478
501
|
/**
|
|
479
502
|
* A validator and description of an update handler.
|
|
480
503
|
*/
|
|
481
|
-
export type UpdateHandlerOptions<Args extends any[]> = {
|
|
504
|
+
export type UpdateHandlerOptions<Args extends any[]> = {
|
|
505
|
+
validator?: UpdateValidator<Args>;
|
|
506
|
+
description?: string;
|
|
507
|
+
unfinishedPolicy?: HandlerUnfinishedPolicy;
|
|
508
|
+
};
|
|
482
509
|
|
|
483
510
|
export interface ActivationCompletion {
|
|
484
511
|
commands: coresdk.workflow_commands.IWorkflowCommand[];
|