@temporalio/workflow 1.17.4 → 1.18.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/current-random.d.ts +1 -0
- package/lib/current-random.js +8 -0
- package/lib/current-random.js.map +1 -0
- package/lib/flags.js +1 -1
- package/lib/flags.js.map +1 -1
- package/lib/global-overrides.js +3 -2
- package/lib/global-overrides.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/interceptor-composition.d.ts +23 -0
- package/lib/interceptor-composition.js +31 -0
- package/lib/interceptor-composition.js.map +1 -0
- package/lib/interfaces.d.ts +1 -0
- package/lib/internals.d.ts +55 -12
- package/lib/internals.js +178 -52
- package/lib/internals.js.map +1 -1
- package/lib/logs.js +2 -2
- package/lib/logs.js.map +1 -1
- package/lib/metrics.js +2 -2
- package/lib/metrics.js.map +1 -1
- package/lib/nexus.js +9 -4
- package/lib/nexus.js.map +1 -1
- package/lib/random-helpers.d.ts +2 -0
- package/lib/random-helpers.js +22 -0
- package/lib/random-helpers.js.map +1 -0
- package/lib/random-stream-seed.d.ts +1 -0
- package/lib/random-stream-seed.js +19 -0
- package/lib/random-stream-seed.js.map +1 -0
- package/lib/random-streams.d.ts +78 -0
- package/lib/random-streams.js +72 -0
- package/lib/random-streams.js.map +1 -0
- package/lib/worker-interface.js +6 -4
- package/lib/worker-interface.js.map +1 -1
- package/lib/workflow.d.ts +11 -5
- package/lib/workflow.js +88 -55
- package/lib/workflow.js.map +1 -1
- package/package.json +3 -3
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function currentRandom(): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentRandom = currentRandom;
|
|
4
|
+
const global_attributes_1 = require("./global-attributes");
|
|
5
|
+
function currentRandom() {
|
|
6
|
+
return (0, global_attributes_1.assertInWorkflowContext)('Workflow random APIs may only be used from workflow context.').currentRandom();
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=current-random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-random.js","sourceRoot":"","sources":["../src/current-random.ts"],"names":[],"mappings":";;AAEA,sCAEC;AAJD,2DAA8D;AAE9D,SAAgB,aAAa;IAC3B,OAAO,IAAA,2CAAuB,EAAC,8DAA8D,CAAC,CAAC,aAAa,EAAE,CAAC;AACjH,CAAC"}
|
package/lib/flags.js
CHANGED
|
@@ -88,7 +88,7 @@ function assertValidFlag(id) {
|
|
|
88
88
|
}
|
|
89
89
|
function buildIdSdkVersionMatches(version) {
|
|
90
90
|
const regex = new RegExp(`^@temporalio/worker@(${version.source})[+]`);
|
|
91
|
-
return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId);
|
|
91
|
+
return ({ info }) => info.currentBuildId != null && regex.test(info.currentBuildId);
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Creates an `AltConditionFn` that checks if the SDK version is equal to or after the provided version.
|
package/lib/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":";;;AAgGA,0CAEC;AA1FD,MAAM,aAAa,GAAyB,IAAI,GAAG,EAAE,CAAC;AAEzC,QAAA,QAAQ,GAAG;IACtB;;;;;;;;;;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AO,CAAC,CAAC,CAAC;IACjC,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/lib/global-overrides.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.overrideGlobals = overrideGlobals;
|
|
|
8
8
|
*/
|
|
9
9
|
const time_1 = require("@temporalio/common/lib/time");
|
|
10
10
|
const cancellation_scope_1 = require("./cancellation-scope");
|
|
11
|
+
const current_random_1 = require("./current-random");
|
|
11
12
|
const errors_1 = require("./errors");
|
|
12
13
|
const global_attributes_1 = require("./global-attributes");
|
|
13
14
|
const flags_1 = require("./flags");
|
|
@@ -90,7 +91,7 @@ function overrideGlobals() {
|
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
|
-
//
|
|
94
|
-
Math.random =
|
|
94
|
+
// currentRandom() dispatches to a scoped stream when WorkflowRandomStream.with(...) is active.
|
|
95
|
+
Math.random = current_random_1.currentRandom;
|
|
95
96
|
}
|
|
96
97
|
//# sourceMappingURL=global-overrides.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-overrides.js","sourceRoot":"","sources":["../src/global-overrides.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"global-overrides.js","sourceRoot":"","sources":["../src/global-overrides.ts"],"names":[],"mappings":";;AAiBA,0CA2FC;AA5GD;;;;GAIG;AACH,sDAAqD;AACrD,6DAAyD;AACzD,qDAAiD;AACjD,qCAAqD;AACrD,2DAAmD;AACnD,mCAAmC;AACnC,yCAAmC;AACnC,mDAAiD;AAEjD,MAAM,MAAM,GAAG,UAAiB,CAAC;AACjC,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;AAErC,SAAgB,eAAe;IAC7B,0GAA0G;IAC1G,+EAA+E;IAC/E,MAAM,CAAC,OAAO,GAAG;QACf,MAAM,IAAI,kCAAyB,CAAC,wEAAwE,CAAC,CAAC;IAChH,CAAC,CAAC;IACF,MAAM,CAAC,oBAAoB,GAAG;QAC5B,MAAM,IAAI,kC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yBAAyB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACzC,UAAU,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,gEAAgE;YAC5F,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC3C,SAAS,CAAC,WAAW,CAAC;gBACpB,WAAW,EAAE;oBACX,GAAG,EAAE,MAAM;iBACZ;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;IAEF,+FAA+F;IAC/F,IAAI,CAAC,MAAM,GAAG,8BAAa,CAAC;AAC9B,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -81,9 +81,7 @@ export async function sampleWorkflow(): Promise<string> {
|
|
|
81
81
|
*
|
|
82
82
|
* @module
|
|
83
83
|
*/
|
|
84
|
-
export { ActivityCancellationType, ActivityFailure, ActivityOptions, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, defaultPayloadConverter, PayloadConverter, RetryPolicy, rootCause, SearchAttributes,
|
|
85
|
-
SearchAttributeValue, // eslint-disable-line @typescript-eslint/no-deprecated
|
|
86
|
-
ServerFailure, TemporalFailure, TerminatedFailure, TimeoutFailure, } from '@temporalio/common';
|
|
84
|
+
export { ActivityCancellationType, ActivityFailure, ActivityOptions, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, defaultPayloadConverter, PayloadConverter, RetryPolicy, rootCause, SearchAttributes, SearchAttributeValue, ServerFailure, TemporalFailure, TerminatedFailure, TimeoutFailure, } from '@temporalio/common';
|
|
87
85
|
export * from '@temporalio/common/lib/errors';
|
|
88
86
|
export { ActivityFunction, ActivityInterface, // eslint-disable-line @typescript-eslint/no-deprecated
|
|
89
87
|
Payload, QueryDefinition, SignalDefinition, UntypedActivities, Workflow, WorkflowQueryType, WorkflowResultType, WorkflowReturnType, WorkflowSignalType, } from '@temporalio/common/lib/interfaces';
|
|
@@ -94,6 +92,8 @@ export * from './errors';
|
|
|
94
92
|
export * from './interceptors';
|
|
95
93
|
export { ChildWorkflowCancellationType, ChildWorkflowOptions, ContinueAsNew, ContinueAsNewOptions, EnhancedStackTrace, StackTraceFileLocation, StackTraceFileSlice, ParentClosePolicy, ParentWorkflowInfo, RootWorkflowInfo, StackTraceSDKInfo, StackTrace, UnsafeWorkflowInfo, WorkflowInfo, } from './interfaces';
|
|
96
94
|
export { proxySinks, Sink, SinkCall, SinkFunction, Sinks } from './sinks';
|
|
95
|
+
export type { WorkflowRandomStream } from './random-streams';
|
|
96
|
+
export { getRandomStream, workflowRandom } from './random-streams';
|
|
97
97
|
export { log } from './logs';
|
|
98
98
|
export { Trigger } from './trigger';
|
|
99
99
|
export * from './workflow';
|
package/lib/index.js
CHANGED
|
@@ -97,7 +97,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
97
97
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
98
98
|
};
|
|
99
99
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100
|
-
exports.NexusOperationCancellationType = exports.createNexusServiceClient = exports.metricMeter = exports.Trigger = exports.log = exports.proxySinks = exports.ParentClosePolicy = exports.ContinueAsNew = exports.ChildWorkflowCancellationType = exports.CancellationScope = exports.AsyncLocalStorage = exports.TimeoutFailure = exports.TerminatedFailure = exports.TemporalFailure = exports.ServerFailure = exports.rootCause = exports.defaultPayloadConverter = exports.ChildWorkflowFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ActivityFailure = exports.ActivityCancellationType = void 0;
|
|
100
|
+
exports.NexusOperationCancellationType = exports.createNexusServiceClient = exports.metricMeter = exports.Trigger = exports.log = exports.workflowRandom = exports.getRandomStream = exports.proxySinks = exports.ParentClosePolicy = exports.ContinueAsNew = exports.ChildWorkflowCancellationType = exports.CancellationScope = exports.AsyncLocalStorage = exports.TimeoutFailure = exports.TerminatedFailure = exports.TemporalFailure = exports.ServerFailure = exports.rootCause = exports.defaultPayloadConverter = exports.ChildWorkflowFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ActivityFailure = exports.ActivityCancellationType = void 0;
|
|
101
101
|
var common_1 = require("@temporalio/common");
|
|
102
102
|
Object.defineProperty(exports, "ActivityCancellationType", { enumerable: true, get: function () { return common_1.ActivityCancellationType; } });
|
|
103
103
|
Object.defineProperty(exports, "ActivityFailure", { enumerable: true, get: function () { return common_1.ActivityFailure; } });
|
|
@@ -124,6 +124,9 @@ Object.defineProperty(exports, "ContinueAsNew", { enumerable: true, get: functio
|
|
|
124
124
|
Object.defineProperty(exports, "ParentClosePolicy", { enumerable: true, get: function () { return interfaces_1.ParentClosePolicy; } });
|
|
125
125
|
var sinks_1 = require("./sinks");
|
|
126
126
|
Object.defineProperty(exports, "proxySinks", { enumerable: true, get: function () { return sinks_1.proxySinks; } });
|
|
127
|
+
var random_streams_1 = require("./random-streams");
|
|
128
|
+
Object.defineProperty(exports, "getRandomStream", { enumerable: true, get: function () { return random_streams_1.getRandomStream; } });
|
|
129
|
+
Object.defineProperty(exports, "workflowRandom", { enumerable: true, get: function () { return random_streams_1.workflowRandom; } });
|
|
127
130
|
var logs_1 = require("./logs");
|
|
128
131
|
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logs_1.log; } });
|
|
129
132
|
var trigger_1 = require("./trigger");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;;;;;;;;;;;;;;;;;AAEH,6CAiB4B;AAhB1B,kHAAA,wBAAwB,OAAA;AACxB,yGAAA,eAAe,OAAA;AAEf,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AACh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E;AAAjE,mGAAA,UAAU,OAAA;AAEnB,mDAAmE;AAA1D,iHAAA,eAAe,OAAA;AAAE,gHAAA,cAAc,OAAA;AACxC,+BAA6B;AAApB,2FAAA,GAAG,OAAA;AACZ,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,6CAA2B;AAE3B,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,iCAMiB;AALf,iHAAA,wBAAwB,OAAA;AAIxB,uHAAA,8BAA8B,OAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Next } from '@temporalio/common/lib/interceptors';
|
|
2
|
+
/**
|
|
3
|
+
* Compose workflow interceptors while making every `next(...)` continuation re-enter
|
|
4
|
+
* the workflow-random scope that was current when that continuation was created.
|
|
5
|
+
*
|
|
6
|
+
* This is intentionally a thin wrapper over the shared interceptor composition helper
|
|
7
|
+
* in `packages/common`. The shared helper owns the actual chain-construction algorithm,
|
|
8
|
+
* ordering, and `next(...)` wiring so workflow code cannot silently drift away from the
|
|
9
|
+
* semantics used by the rest of the SDK.
|
|
10
|
+
*
|
|
11
|
+
* The workflow-specific behavior lives entirely in the `wrapNext` hook we pass into that
|
|
12
|
+
* shared helper. Each `next(...)` continuation handed to a workflow interceptor is wrapped
|
|
13
|
+
* with `Activator.bindCurrentRandom(...)`, which captures the currently active workflow
|
|
14
|
+
* random scope, including the absence of any scoped override. When the interceptor later
|
|
15
|
+
* calls `next(...)`, the wrapper restores that captured scope before entering the rest of
|
|
16
|
+
* the interceptor chain or the base workflow/runtime handler.
|
|
17
|
+
*
|
|
18
|
+
* That is the behavior we need for `WorkflowRandomStream.with(...)`: a temporary
|
|
19
|
+
* plugin/interceptor scope should apply to the plugin's own code, but it must not
|
|
20
|
+
* leak through `next(...)` into downstream workflow code unless that downstream code
|
|
21
|
+
* explicitly establishes its own scope.
|
|
22
|
+
*/
|
|
23
|
+
export declare function composeInterceptors<I, M extends keyof I>(interceptors: I[], method: M, next: Next<I, M>): Next<I, M>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.composeInterceptors = composeInterceptors;
|
|
4
|
+
const interceptors_1 = require("@temporalio/common/lib/interceptors");
|
|
5
|
+
const global_attributes_1 = require("./global-attributes");
|
|
6
|
+
/**
|
|
7
|
+
* Compose workflow interceptors while making every `next(...)` continuation re-enter
|
|
8
|
+
* the workflow-random scope that was current when that continuation was created.
|
|
9
|
+
*
|
|
10
|
+
* This is intentionally a thin wrapper over the shared interceptor composition helper
|
|
11
|
+
* in `packages/common`. The shared helper owns the actual chain-construction algorithm,
|
|
12
|
+
* ordering, and `next(...)` wiring so workflow code cannot silently drift away from the
|
|
13
|
+
* semantics used by the rest of the SDK.
|
|
14
|
+
*
|
|
15
|
+
* The workflow-specific behavior lives entirely in the `wrapNext` hook we pass into that
|
|
16
|
+
* shared helper. Each `next(...)` continuation handed to a workflow interceptor is wrapped
|
|
17
|
+
* with `Activator.bindCurrentRandom(...)`, which captures the currently active workflow
|
|
18
|
+
* random scope, including the absence of any scoped override. When the interceptor later
|
|
19
|
+
* calls `next(...)`, the wrapper restores that captured scope before entering the rest of
|
|
20
|
+
* the interceptor chain or the base workflow/runtime handler.
|
|
21
|
+
*
|
|
22
|
+
* That is the behavior we need for `WorkflowRandomStream.with(...)`: a temporary
|
|
23
|
+
* plugin/interceptor scope should apply to the plugin's own code, but it must not
|
|
24
|
+
* leak through `next(...)` into downstream workflow code unless that downstream code
|
|
25
|
+
* explicitly establishes its own scope.
|
|
26
|
+
*/
|
|
27
|
+
function composeInterceptors(interceptors, method, next) {
|
|
28
|
+
const activator = (0, global_attributes_1.getActivator)();
|
|
29
|
+
return (0, interceptors_1.composeInterceptorsWith)(interceptors, method, next, ((wrappedNext) => activator.bindCurrentRandom(wrappedNext)));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=interceptor-composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptor-composition.js","sourceRoot":"","sources":["../src/interceptor-composition.ts"],"names":[],"mappings":";;AAwBA,kDAMC;AA9BD,sEAAyF;AACzF,2DAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,mBAAmB,CAAuB,YAAiB,EAAE,MAAS,EAAE,IAAgB;IACtG,MAAM,SAAS,GAAG,IAAA,gCAAY,GAAE,CAAC;IACjC,OAAO,IAAA,sCAAuB,EAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAC1E,SAAS,CAAC,iBAAiB,CAAC,WAAkB,CAAC,CAE3C,CAA0B,CAAC;AACnC,CAAC"}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -522,6 +522,7 @@ export interface WorkflowCreateOptions {
|
|
|
522
522
|
randomnessSeed: number[];
|
|
523
523
|
now: number;
|
|
524
524
|
showStackTraceSources: boolean;
|
|
525
|
+
failureExceptionTypeNames?: string[];
|
|
525
526
|
}
|
|
526
527
|
export interface WorkflowCreateOptionsInternal extends WorkflowCreateOptions {
|
|
527
528
|
sourceMap: RawSourceMap;
|
package/lib/internals.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { AsyncLocalStorage as ALS } from 'node:async_hooks';
|
|
1
2
|
import type { RawSourceMap } from 'source-map';
|
|
2
|
-
import type { FailureConverter, PayloadConverter, Workflow, WorkflowQueryAnnotatedType, WorkflowSignalAnnotatedType, WorkflowUpdateAnnotatedType,
|
|
3
|
+
import type { ActivitySerializationContext, FailureConverter, PayloadConverter, ProtoFailure, Workflow, WorkflowFunctionWithOptions, WorkflowQueryAnnotatedType, WorkflowSignalAnnotatedType, WorkflowUpdateAnnotatedType, WorkflowUpdateType, WorkflowUpdateValidatorType, VersioningBehavior, WorkflowDefinitionOptions, WorkflowSerializationContext } from '@temporalio/common';
|
|
3
4
|
import { HandlerUnfinishedPolicy } from '@temporalio/common';
|
|
4
5
|
import type { coresdk } from '@temporalio/proto';
|
|
5
6
|
import type { RNG } from './alea';
|
|
@@ -19,9 +20,10 @@ export interface PromiseStackStore {
|
|
|
19
20
|
childToParent: Map<Promise<unknown>, Set<Promise<unknown>>>;
|
|
20
21
|
promiseToStack: Map<Promise<unknown>, Stack>;
|
|
21
22
|
}
|
|
22
|
-
export interface Completion<Success> {
|
|
23
|
+
export interface Completion<Success, Context = never> {
|
|
23
24
|
resolve(val: Success): void;
|
|
24
25
|
reject(reason: Error): void;
|
|
26
|
+
context?: Context;
|
|
25
27
|
}
|
|
26
28
|
export interface Condition {
|
|
27
29
|
fn(): boolean;
|
|
@@ -42,6 +44,9 @@ interface MessageHandlerExecution {
|
|
|
42
44
|
unfinishedPolicy: HandlerUnfinishedPolicy;
|
|
43
45
|
id?: string;
|
|
44
46
|
}
|
|
47
|
+
interface ScopedWorkflowRandomSource {
|
|
48
|
+
random(): number;
|
|
49
|
+
}
|
|
45
50
|
/**
|
|
46
51
|
* Keeps all of the Workflow runtime state like pending completions for activities and timers.
|
|
47
52
|
*
|
|
@@ -69,14 +74,14 @@ export declare class Activator implements ActivationHandler {
|
|
|
69
74
|
* Map of task sequence to a Completion
|
|
70
75
|
*/
|
|
71
76
|
readonly completions: {
|
|
72
|
-
timer: Map<number, Completion<void>>;
|
|
73
|
-
activity: Map<number, Completion<unknown>>;
|
|
74
|
-
nexusOperationStart: Map<number, Completion<StartNexusOperationOutput>>;
|
|
75
|
-
nexusOperationComplete: Map<number, Completion<unknown>>;
|
|
76
|
-
childWorkflowStart: Map<number, Completion<string>>;
|
|
77
|
-
childWorkflowComplete: Map<number, Completion<unknown>>;
|
|
78
|
-
signalWorkflow: Map<number, Completion<void>>;
|
|
79
|
-
cancelWorkflow: Map<number, Completion<void>>;
|
|
77
|
+
timer: Map<number, Completion<void, never>>;
|
|
78
|
+
activity: Map<number, Completion<unknown, ActivitySerializationContext>>;
|
|
79
|
+
nexusOperationStart: Map<number, Completion<StartNexusOperationOutput, never>>;
|
|
80
|
+
nexusOperationComplete: Map<number, Completion<unknown, never>>;
|
|
81
|
+
childWorkflowStart: Map<number, Completion<string, WorkflowSerializationContext>>;
|
|
82
|
+
childWorkflowComplete: Map<number, Completion<unknown, WorkflowSerializationContext>>;
|
|
83
|
+
signalWorkflow: Map<number, Completion<void, WorkflowSerializationContext>>;
|
|
84
|
+
cancelWorkflow: Map<number, Completion<void, WorkflowSerializationContext>>;
|
|
80
85
|
};
|
|
81
86
|
/**
|
|
82
87
|
* Holds buffered Update calls until a handler is registered
|
|
@@ -152,6 +157,20 @@ export declare class Activator implements ActivationHandler {
|
|
|
152
157
|
* the first captured error is preserved).
|
|
153
158
|
*/
|
|
154
159
|
workflowTaskError: unknown;
|
|
160
|
+
/**
|
|
161
|
+
* Error type _names_ (from {@link WorkerOptions.workflowFailureErrorTypes}) that
|
|
162
|
+
* should cause Workflow Execution failure rather than WFT failure.
|
|
163
|
+
*
|
|
164
|
+
* Set at workflow creation time from the worker options.
|
|
165
|
+
*/
|
|
166
|
+
failureExceptionTypeNames: string[];
|
|
167
|
+
/**
|
|
168
|
+
* Error _types_ (from {@link WorkflowDefinitionOptions.failureExceptionTypes})
|
|
169
|
+
* that should cause Workflow Execution failure rather than WFT failure.
|
|
170
|
+
*
|
|
171
|
+
* Set in `worker-interface.ts` after the workflow definition options are read.
|
|
172
|
+
*/
|
|
173
|
+
workflowDefinitionFailureExceptionTypes: Array<new (...args: any[]) => Error> | undefined;
|
|
155
174
|
/**
|
|
156
175
|
* Set to true when running synchronous code (e.g. while processing activation jobs and when calling
|
|
157
176
|
* `tryUnblockConditions()`). While this flag is set, it is safe to let errors bubble up.
|
|
@@ -214,9 +233,20 @@ export declare class Activator implements ActivationHandler {
|
|
|
214
233
|
*/
|
|
215
234
|
info: WorkflowInfo;
|
|
216
235
|
/**
|
|
217
|
-
*
|
|
236
|
+
* The main deterministic RNG for this workflow execution.
|
|
237
|
+
*
|
|
238
|
+
* Scoped overrides used by `WorkflowRandomStream.with(...)` are layered on top of this RNG.
|
|
218
239
|
*/
|
|
219
240
|
random: RNG;
|
|
241
|
+
/**
|
|
242
|
+
* The current seed material for this workflow execution's deterministic RNGs.
|
|
243
|
+
*/
|
|
244
|
+
randomnessSeed: number[];
|
|
245
|
+
/**
|
|
246
|
+
* Additional deterministic RNG streams keyed by stable stream name.
|
|
247
|
+
*/
|
|
248
|
+
readonly namedRandomStreams: Map<string, RNG>;
|
|
249
|
+
protected currentRandomStorage?: ALS<ScopedWorkflowRandomSource | undefined>;
|
|
220
250
|
payloadConverter: PayloadConverter;
|
|
221
251
|
failureConverter: FailureConverter;
|
|
222
252
|
/**
|
|
@@ -245,7 +275,13 @@ export declare class Activator implements ActivationHandler {
|
|
|
245
275
|
workflowDefinitionOptionsGetter?: () => WorkflowDefinitionOptions;
|
|
246
276
|
readonly workflowSandboxDestructors: (() => void)[];
|
|
247
277
|
protected readonly stackTracesEnabled: boolean;
|
|
248
|
-
constructor({ info, now, showStackTraceSources, sourceMap, getTimeOfDay, randomnessSeed, registeredActivityNames, stackTracesEnabled, }: WorkflowCreateOptionsInternal);
|
|
278
|
+
constructor({ info, now, showStackTraceSources, sourceMap, getTimeOfDay, randomnessSeed, registeredActivityNames, stackTracesEnabled, failureExceptionTypeNames, }: WorkflowCreateOptionsInternal);
|
|
279
|
+
protected setRandomnessSeed(randomnessSeed: number[]): void;
|
|
280
|
+
getNamedRandom(name: string): RNG;
|
|
281
|
+
protected withRandomSource<T>(randomSource: ScopedWorkflowRandomSource | undefined, fn: () => T): T;
|
|
282
|
+
withCurrentRandom<T>(randomSource: ScopedWorkflowRandomSource, fn: () => T): T;
|
|
283
|
+
bindCurrentRandom<T extends (...args: any[]) => any>(fn: T): T;
|
|
284
|
+
currentRandom(): number;
|
|
249
285
|
/**
|
|
250
286
|
* May be invoked from outside the VM.
|
|
251
287
|
*/
|
|
@@ -310,6 +346,12 @@ export declare class Activator implements ActivationHandler {
|
|
|
310
346
|
* Used to handle any failure emitted by the Workflow.
|
|
311
347
|
*/
|
|
312
348
|
handleWorkflowFailure(error: unknown): void;
|
|
349
|
+
/**
|
|
350
|
+
* Returns true if the given error matches any of the configured failure exception types
|
|
351
|
+
* (from {@link WorkerOptions.workflowFailureErrorTypes} or
|
|
352
|
+
* {@link WorkflowDefinitionOptions.failureExceptionTypes}).
|
|
353
|
+
*/
|
|
354
|
+
private isConfiguredFailureException;
|
|
313
355
|
recordWorkflowTaskError(error: unknown): void;
|
|
314
356
|
/**
|
|
315
357
|
* If a Workflow Task error was captured, and we are running in synchronous mode,
|
|
@@ -328,5 +370,6 @@ export declare class Activator implements ActivationHandler {
|
|
|
328
370
|
private completeWorkflow;
|
|
329
371
|
errorToFailure(err: unknown): ProtoFailure;
|
|
330
372
|
failureToError(failure: ProtoFailure): Error;
|
|
373
|
+
private workflowSerializationContext;
|
|
331
374
|
}
|
|
332
375
|
export {};
|