@temporalio/workflow 1.17.1 → 1.17.3
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/package.json +16 -5
- package/src/current-random.ts +5 -0
- package/src/flags.ts +1 -1
- package/src/global-overrides.ts +3 -2
- package/src/index.ts +4 -2
- package/src/interceptor-composition.ts +31 -0
- package/src/interfaces.ts +5 -4
- package/src/internals.ts +213 -55
- package/src/logs.ts +1 -1
- package/src/metrics.ts +1 -1
- package/src/nexus.ts +8 -3
- package/src/random-helpers.ts +21 -0
- package/src/random-stream-seed.ts +18 -0
- package/src/random-streams.ts +132 -0
- package/src/worker-interface.ts +3 -1
- package/src/workflow.ts +99 -54
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/workflow",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.3",
|
|
4
4
|
"description": "Temporal.io SDK Workflow sub-package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"temporal",
|
|
@@ -20,12 +20,18 @@
|
|
|
20
20
|
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
|
|
21
21
|
"main": "lib/index.js",
|
|
22
22
|
"types": "lib/index.d.ts",
|
|
23
|
+
"ava": {
|
|
24
|
+
"timeout": "60s",
|
|
25
|
+
"concurrency": 1,
|
|
26
|
+
"workerThreads": false
|
|
27
|
+
},
|
|
23
28
|
"dependencies": {
|
|
24
29
|
"nexus-rpc": "^0.0.2",
|
|
25
|
-
"@temporalio/
|
|
26
|
-
"@temporalio/
|
|
30
|
+
"@temporalio/common": "1.17.3",
|
|
31
|
+
"@temporalio/proto": "1.17.3"
|
|
27
32
|
},
|
|
28
33
|
"devDependencies": {
|
|
34
|
+
"ava": "^5.3.1",
|
|
29
35
|
"source-map": "^0.7.4"
|
|
30
36
|
},
|
|
31
37
|
"publishConfig": {
|
|
@@ -36,7 +42,12 @@
|
|
|
36
42
|
},
|
|
37
43
|
"files": [
|
|
38
44
|
"src",
|
|
39
|
-
"lib"
|
|
45
|
+
"lib",
|
|
46
|
+
"!src/__tests__",
|
|
47
|
+
"!lib/__tests__"
|
|
40
48
|
],
|
|
41
|
-
"scripts": {
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc --build",
|
|
51
|
+
"test": "ava ./lib/__tests__/test-*.js"
|
|
52
|
+
}
|
|
42
53
|
}
|
package/src/flags.ts
CHANGED
|
@@ -114,7 +114,7 @@ type AltConditionFn = (ctx: { info: WorkflowInfo; sdkVersion?: string }) => bool
|
|
|
114
114
|
|
|
115
115
|
function buildIdSdkVersionMatches(version: RegExp): AltConditionFn {
|
|
116
116
|
const regex = new RegExp(`^@temporalio/worker@(${version.source})[+]`);
|
|
117
|
-
return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId);
|
|
117
|
+
return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
type SemVer = {
|
package/src/global-overrides.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { msToTs } from '@temporalio/common/lib/time';
|
|
7
7
|
import { CancellationScope } from './cancellation-scope';
|
|
8
|
+
import { currentRandom } from './current-random';
|
|
8
9
|
import { DeterminismViolationError } from './errors';
|
|
9
10
|
import { getActivator } from './global-attributes';
|
|
10
11
|
import { SdkFlags } from './flags';
|
|
@@ -103,6 +104,6 @@ export function overrideGlobals(): void {
|
|
|
103
104
|
}
|
|
104
105
|
};
|
|
105
106
|
|
|
106
|
-
//
|
|
107
|
-
Math.random =
|
|
107
|
+
// currentRandom() dispatches to a scoped stream when WorkflowRandomStream.with(...) is active.
|
|
108
|
+
Math.random = currentRandom;
|
|
108
109
|
}
|
package/src/index.ts
CHANGED
|
@@ -93,8 +93,8 @@ export {
|
|
|
93
93
|
PayloadConverter,
|
|
94
94
|
RetryPolicy,
|
|
95
95
|
rootCause,
|
|
96
|
-
SearchAttributes,
|
|
97
|
-
SearchAttributeValue,
|
|
96
|
+
SearchAttributes,
|
|
97
|
+
SearchAttributeValue,
|
|
98
98
|
ServerFailure,
|
|
99
99
|
TemporalFailure,
|
|
100
100
|
TerminatedFailure,
|
|
@@ -136,6 +136,8 @@ export {
|
|
|
136
136
|
WorkflowInfo,
|
|
137
137
|
} from './interfaces';
|
|
138
138
|
export { proxySinks, Sink, SinkCall, SinkFunction, Sinks } from './sinks';
|
|
139
|
+
export type { WorkflowRandomStream } from './random-streams';
|
|
140
|
+
export { getRandomStream, workflowRandom } from './random-streams';
|
|
139
141
|
export { log } from './logs';
|
|
140
142
|
export { Trigger } from './trigger';
|
|
141
143
|
export * from './workflow';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { composeInterceptorsWith, type Next } from '@temporalio/common/lib/interceptors';
|
|
2
|
+
import { getActivator } from './global-attributes';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Compose workflow interceptors while making every `next(...)` continuation re-enter
|
|
6
|
+
* the workflow-random scope that was current when that continuation was created.
|
|
7
|
+
*
|
|
8
|
+
* This is intentionally a thin wrapper over the shared interceptor composition helper
|
|
9
|
+
* in `packages/common`. The shared helper owns the actual chain-construction algorithm,
|
|
10
|
+
* ordering, and `next(...)` wiring so workflow code cannot silently drift away from the
|
|
11
|
+
* semantics used by the rest of the SDK.
|
|
12
|
+
*
|
|
13
|
+
* The workflow-specific behavior lives entirely in the `wrapNext` hook we pass into that
|
|
14
|
+
* shared helper. Each `next(...)` continuation handed to a workflow interceptor is wrapped
|
|
15
|
+
* with `Activator.bindCurrentRandom(...)`, which captures the currently active workflow
|
|
16
|
+
* random scope, including the absence of any scoped override. When the interceptor later
|
|
17
|
+
* calls `next(...)`, the wrapper restores that captured scope before entering the rest of
|
|
18
|
+
* the interceptor chain or the base workflow/runtime handler.
|
|
19
|
+
*
|
|
20
|
+
* That is the behavior we need for `WorkflowRandomStream.with(...)`: a temporary
|
|
21
|
+
* plugin/interceptor scope should apply to the plugin's own code, but it must not
|
|
22
|
+
* leak through `next(...)` into downstream workflow code unless that downstream code
|
|
23
|
+
* explicitly establishes its own scope.
|
|
24
|
+
*/
|
|
25
|
+
export function composeInterceptors<I, M extends keyof I>(interceptors: I[], method: M, next: Next<I, M>): Next<I, M> {
|
|
26
|
+
const activator = getActivator();
|
|
27
|
+
return composeInterceptorsWith(interceptors, method, next, ((wrappedNext) =>
|
|
28
|
+
activator.bindCurrentRandom(wrappedNext as any)) as <F extends (...args: any[]) => any>(
|
|
29
|
+
next: F
|
|
30
|
+
) => F) as unknown as Next<I, M>;
|
|
31
|
+
}
|
package/src/interfaces.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface WorkflowInfo {
|
|
|
47
47
|
* This value may change during the lifetime of an Execution.
|
|
48
48
|
* @deprecated Use {@link typedSearchAttributes} instead.
|
|
49
49
|
*/
|
|
50
|
-
readonly searchAttributes: SearchAttributes;
|
|
50
|
+
readonly searchAttributes: SearchAttributes;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Indexed information attached to the Workflow Execution, exposed through an interface.
|
|
@@ -337,7 +337,7 @@ export interface ContinueAsNewOptions {
|
|
|
337
337
|
* Searchable attributes to attach to next Workflow run
|
|
338
338
|
* @deprecated Use {@link typedSearchAttributes} instead.
|
|
339
339
|
*/
|
|
340
|
-
searchAttributes?: SearchAttributes;
|
|
340
|
+
searchAttributes?: SearchAttributes;
|
|
341
341
|
/**
|
|
342
342
|
* Specifies additional indexed information to attach to the Workflow Execution. More info:
|
|
343
343
|
* https://docs.temporal.io/docs/typescript/search-attributes
|
|
@@ -357,7 +357,7 @@ export interface ContinueAsNewOptions {
|
|
|
357
357
|
*
|
|
358
358
|
* @deprecated Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
|
|
359
359
|
*/
|
|
360
|
-
versioningIntent?: VersioningIntent;
|
|
360
|
+
versioningIntent?: VersioningIntent;
|
|
361
361
|
/**
|
|
362
362
|
* Defines the versioning behavior to be used by the first task of a new workflow run in a continue-as-new chain.
|
|
363
363
|
*
|
|
@@ -567,7 +567,7 @@ export interface ChildWorkflowOptions extends Omit<CommonWorkflowOptions, 'workf
|
|
|
567
567
|
*
|
|
568
568
|
* @deprecated Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
|
|
569
569
|
*/
|
|
570
|
-
versioningIntent?: VersioningIntent;
|
|
570
|
+
versioningIntent?: VersioningIntent;
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
export type RequiredChildWorkflowOptions = Required<Pick<ChildWorkflowOptions, 'workflowId' | 'cancellationType'>> & {
|
|
@@ -646,6 +646,7 @@ export interface WorkflowCreateOptions {
|
|
|
646
646
|
randomnessSeed: number[];
|
|
647
647
|
now: number;
|
|
648
648
|
showStackTraceSources: boolean;
|
|
649
|
+
failureExceptionTypeNames?: string[];
|
|
649
650
|
}
|
|
650
651
|
|
|
651
652
|
export interface WorkflowCreateOptionsInternal extends WorkflowCreateOptions {
|