@temporalio/workflow 0.23.0 → 1.0.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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/lib/cancellation-scope.js +6 -2
- package/lib/cancellation-scope.js.map +1 -1
- package/lib/errors.js +9 -5
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +18 -12
- package/lib/index.js +16 -13
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +3 -1
- package/lib/interfaces.d.ts +147 -12
- package/lib/interfaces.js +44 -0
- package/lib/interfaces.js.map +1 -1
- package/lib/internals.d.ts +11 -4
- package/lib/internals.js +47 -15
- package/lib/internals.js.map +1 -1
- package/lib/sinks.d.ts +2 -1
- package/lib/stack-helpers.d.ts +4 -0
- package/lib/stack-helpers.js +15 -0
- package/lib/stack-helpers.js.map +1 -0
- package/lib/trigger.d.ts +2 -1
- package/lib/trigger.js +7 -4
- package/lib/trigger.js.map +1 -1
- package/lib/worker-interface.d.ts +2 -1
- package/lib/worker-interface.js +16 -12
- package/lib/worker-interface.js.map +1 -1
- package/lib/workflow-handle.d.ts +1 -1
- package/lib/workflow.d.ts +115 -43
- package/lib/workflow.js +151 -74
- package/lib/workflow.js.map +1 -1
- package/package.json +10 -8
- package/src/alea.ts +88 -0
- package/src/cancellation-scope.ts +205 -0
- package/src/errors.ts +30 -0
- package/src/index.ts +91 -0
- package/src/interceptors.ts +239 -0
- package/src/interfaces.ts +294 -0
- package/src/internals.ts +611 -0
- package/src/sinks.ts +41 -0
- package/src/stack-helpers.ts +11 -0
- package/src/trigger.ts +49 -0
- package/src/worker-interface.ts +273 -0
- package/src/workflow-handle.ts +63 -0
- package/src/workflow.ts +1247 -0
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Temporal TypeScript SDK
|
|
|
2
2
|
|
|
3
3
|
MIT License
|
|
4
4
|
|
|
5
|
-
Copyright (c) 2021 Temporal Technologies
|
|
5
|
+
Copyright (c) 2021 Temporal Technologies Inc. All Rights Reserved
|
|
6
6
|
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
8
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@temporalio/workflow)
|
|
4
4
|
|
|
5
|
-
Part of [Temporal](https://temporal.io)'s [TypeScript SDK](https://docs.temporal.io/
|
|
5
|
+
Part of [Temporal](https://temporal.io)'s [TypeScript SDK](https://docs.temporal.io/typescript/introduction/).
|
|
6
6
|
|
|
7
|
-
- [Workflow docs](https://docs.temporal.io/
|
|
7
|
+
- [Workflow docs](https://docs.temporal.io/typescript/workflows)
|
|
8
8
|
- [API reference](https://typescript.temporal.io/api/namespaces/workflow)
|
|
9
9
|
- [Sample projects](https://github.com/temporalio/samples-typescript)
|
|
@@ -14,6 +14,7 @@ var _CancellationScope_cancelRequested;
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.registerSleepImplementation = exports.ROOT_SCOPE = exports.RootCancellationScope = exports.storage = exports.CancellationScope = exports.AsyncLocalStorage = void 0;
|
|
16
16
|
const common_1 = require("@temporalio/common");
|
|
17
|
+
const stack_helpers_1 = require("./stack-helpers");
|
|
17
18
|
// AsyncLocalStorage is injected via vm module into global scope.
|
|
18
19
|
// In case Workflow code is imported in Node.js context, replace with an empty class.
|
|
19
20
|
exports.AsyncLocalStorage = globalThis.AsyncLocalStorage ?? class {
|
|
@@ -69,8 +70,9 @@ class CancellationScope {
|
|
|
69
70
|
reject(err);
|
|
70
71
|
};
|
|
71
72
|
});
|
|
73
|
+
(0, stack_helpers_1.untrackPromise)(this.cancelRequested);
|
|
72
74
|
// Avoid unhandled rejections
|
|
73
|
-
this.cancelRequested.catch(() => undefined);
|
|
75
|
+
(0, stack_helpers_1.untrackPromise)(this.cancelRequested.catch(() => undefined));
|
|
74
76
|
if (options?.parent !== NO_PARENT) {
|
|
75
77
|
this.parent = options?.parent || CancellationScope.current();
|
|
76
78
|
__classPrivateFieldSet(this, _CancellationScope_cancelRequested, __classPrivateFieldGet(this.parent, _CancellationScope_cancelRequested, "f"), "f");
|
|
@@ -100,7 +102,9 @@ class CancellationScope {
|
|
|
100
102
|
*/
|
|
101
103
|
async runInContext(fn) {
|
|
102
104
|
if (this.timeout) {
|
|
103
|
-
sleep(this.timeout).then(() => this.cancel())
|
|
105
|
+
(0, stack_helpers_1.untrackPromise)(sleep(this.timeout).then(() => this.cancel(), () => {
|
|
106
|
+
// scope was already cancelled, ignore
|
|
107
|
+
}));
|
|
104
108
|
}
|
|
105
109
|
return await fn();
|
|
106
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancellation-scope.js","sourceRoot":"","sources":["../src/cancellation-scope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAyE;
|
|
1
|
+
{"version":3,"file":"cancellation-scope.js","sourceRoot":"","sources":["../src/cancellation-scope.ts"],"names":[],"mappings":"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"}
|
package/lib/errors.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isCancellation = exports.DeterminismViolationError = exports.WorkflowError = exports.WorkflowExecutionAlreadyStartedError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "WorkflowExecutionAlreadyStartedError", { enumerable: true, get: function () { return common_2.WorkflowExecutionAlreadyStartedError; } });
|
|
4
|
+
var common_1 = require("@temporalio/common");
|
|
5
|
+
Object.defineProperty(exports, "WorkflowExecutionAlreadyStartedError", { enumerable: true, get: function () { return common_1.WorkflowExecutionAlreadyStartedError; } });
|
|
7
6
|
/**
|
|
8
7
|
* Base class for all workflow errors
|
|
9
8
|
*/
|
|
@@ -24,12 +23,17 @@ class DeterminismViolationError extends WorkflowError {
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
exports.DeterminismViolationError = DeterminismViolationError;
|
|
26
|
+
function looksLikeError(err) {
|
|
27
|
+
return typeof err === 'object' && err != null && Object.prototype.hasOwnProperty.call(err, 'name');
|
|
28
|
+
}
|
|
27
29
|
/**
|
|
28
30
|
* Returns whether provided `err` is caused by cancellation
|
|
29
31
|
*/
|
|
30
32
|
function isCancellation(err) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
if (!looksLikeError(err))
|
|
34
|
+
return false;
|
|
35
|
+
return (err.name === 'CancelledFailure' ||
|
|
36
|
+
((err.name === 'ActivityFailure' || err.name === 'ChildWorkflowFailure') && isCancellation(err.cause)));
|
|
33
37
|
}
|
|
34
38
|
exports.isCancellation = isCancellation;
|
|
35
39
|
//# sourceMappingURL=errors.js.map
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,6CAA0E;AAAjE,8HAAA,oCAAoC,OAAA;AAE7C;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IAAxC;;QACkB,SAAI,GAAW,eAAe,CAAC;IACjD,CAAC;CAAA;AAFD,sCAEC;AAED;;GAEG;AACH,MAAa,yBAA0B,SAAQ,aAAa;IAA5D;;QACkB,SAAI,GAAW,2BAA2B,CAAC;IAC7D,CAAC;CAAA;AAFD,8DAEC;AAED,SAAS,cAAc,CAAC,GAAY;IAClC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACrG,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,GAAY;IACzC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,OAAO,CACL,GAAG,CAAC,IAAI,KAAK,kBAAkB;QAC/B,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,iBAAiB,IAAI,GAAG,CAAC,IAAI,KAAK,sBAAsB,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CACvG,CAAC;AACJ,CAAC;AAND,wCAMC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* This library provides tools required for authoring workflows.
|
|
3
3
|
*
|
|
4
4
|
* ## Usage
|
|
5
|
-
* See the
|
|
5
|
+
* See the {@link https://docs.temporal.io/typescript/hello-world#workflows | tutorial} for writing your first workflow.
|
|
6
6
|
*
|
|
7
7
|
* ### Timers
|
|
8
8
|
*
|
|
9
|
-
* The recommended way of scheduling timers is by using the {@link sleep} function.
|
|
10
|
-
*
|
|
9
|
+
* The recommended way of scheduling timers is by using the {@link sleep} function. We've replaced `setTimeout` and
|
|
10
|
+
* `clearTimeout` with deterministic versions so these are also usable but have a limitation that they don't play well
|
|
11
|
+
* with {@link https://docs.temporal.io/typescript/workflow-scopes-and-cancellation | cancellation scopes}.
|
|
11
12
|
*
|
|
12
13
|
* <!--SNIPSTART typescript-sleep-workflow-->
|
|
13
14
|
* <!--SNIPEND-->
|
|
@@ -21,11 +22,12 @@
|
|
|
21
22
|
*
|
|
22
23
|
* ### Signals and Queries
|
|
23
24
|
*
|
|
24
|
-
* To add signal handlers to a Workflow, add a signals property to the exported `workflow` object.
|
|
25
|
-
*
|
|
25
|
+
* To add signal handlers to a Workflow, add a signals property to the exported `workflow` object. Signal handlers can
|
|
26
|
+
* return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
|
|
26
27
|
*
|
|
27
|
-
* To add query handlers to a Workflow, add a queries property to the exported `workflow` object.
|
|
28
|
-
*
|
|
28
|
+
* To add query handlers to a Workflow, add a queries property to the exported `workflow` object. Query handlers must
|
|
29
|
+
* **not** mutate any variables or generate any commands (like Activities or Timers), they run synchronously and thus
|
|
30
|
+
* **must** return a `Promise`.
|
|
29
31
|
*
|
|
30
32
|
* #### Implementation
|
|
31
33
|
*
|
|
@@ -33,25 +35,29 @@
|
|
|
33
35
|
* <!--SNIPEND-->
|
|
34
36
|
*
|
|
35
37
|
* ### Deterministic built-ins
|
|
36
|
-
* It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We
|
|
38
|
+
* It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We
|
|
39
|
+
* also provide a deterministic {@link uuid4} function for convenience.
|
|
37
40
|
*
|
|
38
|
-
* ### [Cancellation and scopes](https://docs.temporal.io/
|
|
41
|
+
* ### [Cancellation and scopes](https://docs.temporal.io/typescript/workflow-scopes-and-cancellation)
|
|
39
42
|
* - {@link CancellationScope}
|
|
40
43
|
* - {@link Trigger}
|
|
41
44
|
*
|
|
42
|
-
* ### [Sinks](https://docs.temporal.io/
|
|
45
|
+
* ### [Sinks](https://docs.temporal.io/typescript/sinks)
|
|
43
46
|
* - {@link Sinks}
|
|
44
47
|
*
|
|
45
48
|
* @module
|
|
46
49
|
*/
|
|
47
50
|
export { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, defaultPayloadConverter, PayloadConverter, rootCause, ServerFailure, TemporalFailure, TerminatedFailure, TimeoutFailure, } from '@temporalio/common';
|
|
48
|
-
export { ActivityCancellationType, ActivityFunction, ActivityInterface,
|
|
51
|
+
export { ActivityCancellationType, ActivityFunction, ActivityInterface, // eslint-disable-line deprecation/deprecation
|
|
52
|
+
ActivityOptions, RetryPolicy, UntypedActivities, } from '@temporalio/internal-workflow-common';
|
|
53
|
+
export * from '@temporalio/internal-workflow-common/lib/errors';
|
|
49
54
|
export * from '@temporalio/internal-workflow-common/lib/interfaces';
|
|
55
|
+
export * from '@temporalio/internal-workflow-common/lib/workflow-handle';
|
|
50
56
|
export * from '@temporalio/internal-workflow-common/lib/workflow-options';
|
|
51
57
|
export { AsyncLocalStorage, CancellationScope, CancellationScopeOptions, ROOT_SCOPE } from './cancellation-scope';
|
|
52
58
|
export * from './errors';
|
|
53
59
|
export * from './interceptors';
|
|
54
|
-
export { ChildWorkflowCancellationType, ChildWorkflowOptions, ContinueAsNew, ContinueAsNewOptions, ParentClosePolicy, WorkflowInfo, } from './interfaces';
|
|
60
|
+
export { ChildWorkflowCancellationType, ChildWorkflowOptions, ContinueAsNew, ContinueAsNewOptions, ParentClosePolicy, ParentWorkflowInfo, WorkflowInfo, } from './interfaces';
|
|
55
61
|
export { Sink, SinkCall, SinkFunction, Sinks } from './sinks';
|
|
56
62
|
export { Trigger } from './trigger';
|
|
57
63
|
export * from './workflow';
|
package/lib/index.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* This library provides tools required for authoring workflows.
|
|
4
4
|
*
|
|
5
5
|
* ## Usage
|
|
6
|
-
* See the
|
|
6
|
+
* See the {@link https://docs.temporal.io/typescript/hello-world#workflows | tutorial} for writing your first workflow.
|
|
7
7
|
*
|
|
8
8
|
* ### Timers
|
|
9
9
|
*
|
|
10
|
-
* The recommended way of scheduling timers is by using the {@link sleep} function.
|
|
11
|
-
*
|
|
10
|
+
* The recommended way of scheduling timers is by using the {@link sleep} function. We've replaced `setTimeout` and
|
|
11
|
+
* `clearTimeout` with deterministic versions so these are also usable but have a limitation that they don't play well
|
|
12
|
+
* with {@link https://docs.temporal.io/typescript/workflow-scopes-and-cancellation | cancellation scopes}.
|
|
12
13
|
*
|
|
13
14
|
* <!--SNIPSTART typescript-sleep-workflow-->
|
|
14
15
|
* <!--SNIPEND-->
|
|
@@ -22,11 +23,12 @@
|
|
|
22
23
|
*
|
|
23
24
|
* ### Signals and Queries
|
|
24
25
|
*
|
|
25
|
-
* To add signal handlers to a Workflow, add a signals property to the exported `workflow` object.
|
|
26
|
-
*
|
|
26
|
+
* To add signal handlers to a Workflow, add a signals property to the exported `workflow` object. Signal handlers can
|
|
27
|
+
* return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
|
|
27
28
|
*
|
|
28
|
-
* To add query handlers to a Workflow, add a queries property to the exported `workflow` object.
|
|
29
|
-
*
|
|
29
|
+
* To add query handlers to a Workflow, add a queries property to the exported `workflow` object. Query handlers must
|
|
30
|
+
* **not** mutate any variables or generate any commands (like Activities or Timers), they run synchronously and thus
|
|
31
|
+
* **must** return a `Promise`.
|
|
30
32
|
*
|
|
31
33
|
* #### Implementation
|
|
32
34
|
*
|
|
@@ -34,13 +36,14 @@
|
|
|
34
36
|
* <!--SNIPEND-->
|
|
35
37
|
*
|
|
36
38
|
* ### Deterministic built-ins
|
|
37
|
-
* It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We
|
|
39
|
+
* It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We
|
|
40
|
+
* also provide a deterministic {@link uuid4} function for convenience.
|
|
38
41
|
*
|
|
39
|
-
* ### [Cancellation and scopes](https://docs.temporal.io/
|
|
42
|
+
* ### [Cancellation and scopes](https://docs.temporal.io/typescript/workflow-scopes-and-cancellation)
|
|
40
43
|
* - {@link CancellationScope}
|
|
41
44
|
* - {@link Trigger}
|
|
42
45
|
*
|
|
43
|
-
* ### [Sinks](https://docs.temporal.io/
|
|
46
|
+
* ### [Sinks](https://docs.temporal.io/typescript/sinks)
|
|
44
47
|
* - {@link Sinks}
|
|
45
48
|
*
|
|
46
49
|
* @module
|
|
@@ -60,7 +63,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
60
63
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
61
64
|
};
|
|
62
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
-
exports.Trigger = exports.ParentClosePolicy = exports.ContinueAsNew = exports.ChildWorkflowCancellationType = exports.ROOT_SCOPE = exports.CancellationScope = exports.AsyncLocalStorage = exports.
|
|
66
|
+
exports.Trigger = exports.ParentClosePolicy = exports.ContinueAsNew = exports.ChildWorkflowCancellationType = exports.ROOT_SCOPE = exports.CancellationScope = exports.AsyncLocalStorage = exports.ActivityCancellationType = exports.TimeoutFailure = exports.TerminatedFailure = exports.TemporalFailure = exports.ServerFailure = exports.rootCause = exports.defaultPayloadConverter = exports.ChildWorkflowFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ActivityFailure = void 0;
|
|
64
67
|
var common_1 = require("@temporalio/common");
|
|
65
68
|
Object.defineProperty(exports, "ActivityFailure", { enumerable: true, get: function () { return common_1.ActivityFailure; } });
|
|
66
69
|
Object.defineProperty(exports, "ApplicationFailure", { enumerable: true, get: function () { return common_1.ApplicationFailure; } });
|
|
@@ -74,9 +77,9 @@ Object.defineProperty(exports, "TerminatedFailure", { enumerable: true, get: fun
|
|
|
74
77
|
Object.defineProperty(exports, "TimeoutFailure", { enumerable: true, get: function () { return common_1.TimeoutFailure; } });
|
|
75
78
|
var internal_workflow_common_1 = require("@temporalio/internal-workflow-common");
|
|
76
79
|
Object.defineProperty(exports, "ActivityCancellationType", { enumerable: true, get: function () { return internal_workflow_common_1.ActivityCancellationType; } });
|
|
77
|
-
|
|
78
|
-
Object.defineProperty(exports, "ValueError", { enumerable: true, get: function () { return internal_workflow_common_1.ValueError; } });
|
|
80
|
+
__exportStar(require("@temporalio/internal-workflow-common/lib/errors"), exports);
|
|
79
81
|
__exportStar(require("@temporalio/internal-workflow-common/lib/interfaces"), exports);
|
|
82
|
+
__exportStar(require("@temporalio/internal-workflow-common/lib/workflow-handle"), exports);
|
|
80
83
|
__exportStar(require("@temporalio/internal-workflow-common/lib/workflow-options"), exports);
|
|
81
84
|
var cancellation_scope_1 = require("./cancellation-scope");
|
|
82
85
|
Object.defineProperty(exports, "AsyncLocalStorage", { enumerable: true, get: function () { return cancellation_scope_1.AsyncLocalStorage; } });
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;;;;;;;;;;;;;;;;;AAEH,6CAY4B;AAX1B,yGAAA,eAAe,OAAA;AACf,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,8GAAA,oBAAoB,OAAA;AACpB,iHAAA,uBAAuB,OAAA;AAEvB,mGAAA,SAAS,OAAA;AACT,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AAEhB,iFAO8C;AAN5C,oIAAA,wBAAwB,OAAA;AAO1B,kFAAgE;AAChE,sFAAoE;AACpE,2FAAyE;AACzE,4FAA0E;AAC1E,2DAAkH;AAAzG,uHAAA,iBAAiB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAA4B,gHAAA,UAAU,OAAA;AACnF,2CAAyB;AACzB,iDAA+B;AAC/B,2CAQsB;AAPpB,2HAAA,6BAA6B,OAAA;AAE7B,2GAAA,aAAa,OAAA;AAEb,+GAAA,iBAAiB,OAAA;AAKnB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,6CAA2B"}
|
package/lib/interceptors.d.ts
CHANGED
|
@@ -155,12 +155,14 @@ export interface DisposeInput {
|
|
|
155
155
|
* Interceptor for the internals of the Workflow runtime.
|
|
156
156
|
*
|
|
157
157
|
* Use to manipulate or trace Workflow activations.
|
|
158
|
+
*
|
|
159
|
+
* @experimental
|
|
158
160
|
*/
|
|
159
161
|
export interface WorkflowInternalsInterceptor {
|
|
160
162
|
/**
|
|
161
163
|
* Called when the Workflow runtime runs a WorkflowActivationJob.
|
|
162
164
|
*/
|
|
163
|
-
activate?(input: ActivateInput, next: Next<this, 'activate'>):
|
|
165
|
+
activate?(input: ActivateInput, next: Next<this, 'activate'>): void;
|
|
164
166
|
/**
|
|
165
167
|
* Called after all `WorkflowActivationJob`s have been processed for an activation.
|
|
166
168
|
*
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RetryPolicy, TemporalFailure } from '@temporalio/common';
|
|
2
|
+
import { CommonWorkflowOptions, SearchAttributes } from '@temporalio/internal-workflow-common';
|
|
2
3
|
import type { coresdk } from '@temporalio/proto';
|
|
3
4
|
/**
|
|
4
|
-
* Workflow
|
|
5
|
+
* Workflow Execution information
|
|
5
6
|
*/
|
|
6
7
|
export interface WorkflowInfo {
|
|
7
8
|
/**
|
|
@@ -14,22 +15,107 @@ export interface WorkflowInfo {
|
|
|
14
15
|
*/
|
|
15
16
|
runId: string;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Workflow function's name
|
|
18
19
|
*/
|
|
19
20
|
workflowType: string;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Indexed information attached to the Workflow Execution
|
|
23
|
+
*
|
|
24
|
+
* This value may change during the lifetime of an Execution.
|
|
22
25
|
*/
|
|
23
|
-
|
|
26
|
+
searchAttributes: SearchAttributes;
|
|
27
|
+
/**
|
|
28
|
+
* Non-indexed information attached to the Workflow Execution
|
|
29
|
+
*/
|
|
30
|
+
memo?: Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Parent Workflow info (present if this is a Child Workflow)
|
|
33
|
+
*/
|
|
34
|
+
parent?: ParentWorkflowInfo;
|
|
35
|
+
/**
|
|
36
|
+
* Result from the previous Run (present if this is a Cron Workflow or was Continued As New).
|
|
37
|
+
*
|
|
38
|
+
* An array of values, since other SDKs may return multiple values from a Workflow.
|
|
39
|
+
*/
|
|
40
|
+
lastResult?: unknown;
|
|
41
|
+
/**
|
|
42
|
+
* Failure from the previous Run (present when this Run is a retry, or the last Run of a Cron Workflow failed)
|
|
43
|
+
*/
|
|
44
|
+
lastFailure?: TemporalFailure;
|
|
45
|
+
/**
|
|
46
|
+
* Length of Workflow history up until the current Workflow Task.
|
|
47
|
+
*
|
|
48
|
+
* This value changes during the lifetime of an Execution.
|
|
49
|
+
*
|
|
50
|
+
* You may safely use this information to decide when to {@link continueAsNew}.
|
|
51
|
+
*/
|
|
52
|
+
historyLength: number;
|
|
24
53
|
/**
|
|
25
|
-
* Task queue this Workflow is
|
|
54
|
+
* Task queue this Workflow is executing on
|
|
26
55
|
*/
|
|
27
56
|
taskQueue: string;
|
|
28
57
|
/**
|
|
29
|
-
*
|
|
58
|
+
* Namespace this Workflow is executing in
|
|
59
|
+
*/
|
|
60
|
+
namespace: string;
|
|
61
|
+
/**
|
|
62
|
+
* Run Id of the first Run in this Execution Chain
|
|
63
|
+
*/
|
|
64
|
+
firstExecutionRunId: string;
|
|
65
|
+
/**
|
|
66
|
+
* The last Run Id in this Execution Chain
|
|
30
67
|
*/
|
|
68
|
+
continuedFromExecutionRunId?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Time at which the Workflow Run started
|
|
71
|
+
*/
|
|
72
|
+
/**
|
|
73
|
+
* Milliseconds after which the Workflow Execution is automatically terminated by Temporal Server. Set via {@link WorkflowOptions.workflowExecutionTimeout}.
|
|
74
|
+
*/
|
|
75
|
+
executionTimeoutMs?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Time at which the Workflow Execution expires
|
|
78
|
+
*/
|
|
79
|
+
executionExpirationTime?: Date;
|
|
80
|
+
/**
|
|
81
|
+
* Milliseconds after which the Workflow Run is automatically terminated by Temporal Server. Set via {@link WorkflowOptions.workflowRunTimeout}.
|
|
82
|
+
*/
|
|
83
|
+
runTimeoutMs?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Maximum execution time of a Workflow Task in milliseconds. Set via {@link WorkflowOptions.workflowTaskTimeout}.
|
|
86
|
+
*/
|
|
87
|
+
taskTimeoutMs: number;
|
|
88
|
+
/**
|
|
89
|
+
* Retry Policy for this Execution. Set via {@link WorkflowOptions.retry}.
|
|
90
|
+
*/
|
|
91
|
+
retryPolicy?: RetryPolicy;
|
|
92
|
+
/**
|
|
93
|
+
* Starts at 1 and increments for every retry if there is a `retryPolicy`
|
|
94
|
+
*/
|
|
95
|
+
attempt: number;
|
|
96
|
+
/**
|
|
97
|
+
* Cron Schedule for this Execution. Set via {@link WorkflowOptions.cronSchedule}.
|
|
98
|
+
*/
|
|
99
|
+
cronSchedule?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Milliseconds between Cron Runs
|
|
102
|
+
*/
|
|
103
|
+
cronScheduleToScheduleInterval?: number;
|
|
104
|
+
unsafe: UnsafeWorkflowInfo;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Unsafe information about the current Workflow Execution.
|
|
108
|
+
*
|
|
109
|
+
* Never rely on this information in Workflow logic as it will cause non-deterministic behavior.
|
|
110
|
+
*/
|
|
111
|
+
export interface UnsafeWorkflowInfo {
|
|
31
112
|
isReplaying: boolean;
|
|
32
113
|
}
|
|
114
|
+
export interface ParentWorkflowInfo {
|
|
115
|
+
workflowId: string;
|
|
116
|
+
runId: string;
|
|
117
|
+
namespace: string;
|
|
118
|
+
}
|
|
33
119
|
/**
|
|
34
120
|
* Not an actual error, used by the Workflow runtime to abort execution when {@link continueAsNew} is called
|
|
35
121
|
*/
|
|
@@ -67,18 +153,62 @@ export interface ContinueAsNewOptions {
|
|
|
67
153
|
/**
|
|
68
154
|
* Searchable attributes to attach to next Workflow run
|
|
69
155
|
*/
|
|
70
|
-
searchAttributes?:
|
|
156
|
+
searchAttributes?: SearchAttributes;
|
|
71
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Specifies:
|
|
160
|
+
* - whether cancellation requests are sent to the Child
|
|
161
|
+
* - whether and when a {@link CanceledFailure} is thrown from {@link executeChild} or
|
|
162
|
+
* {@link ChildWorkflowHandle.result}
|
|
163
|
+
*
|
|
164
|
+
* @default {@link ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED}
|
|
165
|
+
*/
|
|
72
166
|
export declare enum ChildWorkflowCancellationType {
|
|
167
|
+
/**
|
|
168
|
+
* Don't send a cancellation request to the Child.
|
|
169
|
+
*/
|
|
73
170
|
ABANDON = 0,
|
|
171
|
+
/**
|
|
172
|
+
* Send a cancellation request to the Child. Immediately throw the error.
|
|
173
|
+
*/
|
|
74
174
|
TRY_CANCEL = 1,
|
|
175
|
+
/**
|
|
176
|
+
* Send a cancellation request to the Child. The Child may respect cancellation, in which case an error will be thrown
|
|
177
|
+
* when cancellation has completed, and {@link isCancellation}(error) will be true. On the other hand, the Child may
|
|
178
|
+
* ignore the cancellation request, in which case an error might be thrown with a different cause, or the Child may
|
|
179
|
+
* complete successfully.
|
|
180
|
+
*
|
|
181
|
+
* @default
|
|
182
|
+
*/
|
|
75
183
|
WAIT_CANCELLATION_COMPLETED = 2,
|
|
184
|
+
/**
|
|
185
|
+
* Send a cancellation request to the Child. Throw the error once the Server receives the Child cancellation request.
|
|
186
|
+
*/
|
|
76
187
|
WAIT_CANCELLATION_REQUESTED = 3
|
|
77
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* How a Child Workflow reacts to the Parent Workflow reaching a Closed state.
|
|
191
|
+
*
|
|
192
|
+
* @see {@link https://docs.temporal.io/concepts/what-is-a-parent-close-policy/ | Parent Close Policy}
|
|
193
|
+
*/
|
|
78
194
|
export declare enum ParentClosePolicy {
|
|
195
|
+
/**
|
|
196
|
+
* If a `ParentClosePolicy` is set to this, or is not set at all, the server default value will be used.
|
|
197
|
+
*/
|
|
79
198
|
PARENT_CLOSE_POLICY_UNSPECIFIED = 0,
|
|
199
|
+
/**
|
|
200
|
+
* When the Parent is Closed, the Child is Terminated.
|
|
201
|
+
*
|
|
202
|
+
* @default
|
|
203
|
+
*/
|
|
80
204
|
PARENT_CLOSE_POLICY_TERMINATE = 1,
|
|
205
|
+
/**
|
|
206
|
+
* When the Parent is Closed, nothing is done to the Child.
|
|
207
|
+
*/
|
|
81
208
|
PARENT_CLOSE_POLICY_ABANDON = 2,
|
|
209
|
+
/**
|
|
210
|
+
* When the Parent is Closed, the Child is Cancelled.
|
|
211
|
+
*/
|
|
82
212
|
PARENT_CLOSE_POLICY_REQUEST_CANCEL = 3
|
|
83
213
|
}
|
|
84
214
|
export interface ChildWorkflowOptions extends CommonWorkflowOptions {
|
|
@@ -94,13 +224,18 @@ export interface ChildWorkflowOptions extends CommonWorkflowOptions {
|
|
|
94
224
|
*/
|
|
95
225
|
taskQueue?: string;
|
|
96
226
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @
|
|
227
|
+
* Specifies:
|
|
228
|
+
* - whether cancellation requests are sent to the Child
|
|
229
|
+
* - whether and when an error is thrown from {@link executeChild} or
|
|
230
|
+
* {@link ChildWorkflowHandle.result}
|
|
231
|
+
*
|
|
232
|
+
* @default {@link ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED}
|
|
100
233
|
*/
|
|
101
234
|
cancellationType?: ChildWorkflowCancellationType;
|
|
102
235
|
/**
|
|
103
|
-
* Specifies how
|
|
236
|
+
* Specifies how the Child reacts to the Parent Workflow reaching a Closed state.
|
|
237
|
+
*
|
|
238
|
+
* @default {@link ParentClosePolicy.PARENT_CLOSE_POLICY_TERMINATE}
|
|
104
239
|
*/
|
|
105
240
|
parentClosePolicy?: ParentClosePolicy;
|
|
106
241
|
}
|
package/lib/interfaces.js
CHANGED
|
@@ -13,19 +13,63 @@ class ContinueAsNew extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.ContinueAsNew = ContinueAsNew;
|
|
16
|
+
/**
|
|
17
|
+
* Specifies:
|
|
18
|
+
* - whether cancellation requests are sent to the Child
|
|
19
|
+
* - whether and when a {@link CanceledFailure} is thrown from {@link executeChild} or
|
|
20
|
+
* {@link ChildWorkflowHandle.result}
|
|
21
|
+
*
|
|
22
|
+
* @default {@link ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED}
|
|
23
|
+
*/
|
|
16
24
|
var ChildWorkflowCancellationType;
|
|
17
25
|
(function (ChildWorkflowCancellationType) {
|
|
26
|
+
/**
|
|
27
|
+
* Don't send a cancellation request to the Child.
|
|
28
|
+
*/
|
|
18
29
|
ChildWorkflowCancellationType[ChildWorkflowCancellationType["ABANDON"] = 0] = "ABANDON";
|
|
30
|
+
/**
|
|
31
|
+
* Send a cancellation request to the Child. Immediately throw the error.
|
|
32
|
+
*/
|
|
19
33
|
ChildWorkflowCancellationType[ChildWorkflowCancellationType["TRY_CANCEL"] = 1] = "TRY_CANCEL";
|
|
34
|
+
/**
|
|
35
|
+
* Send a cancellation request to the Child. The Child may respect cancellation, in which case an error will be thrown
|
|
36
|
+
* when cancellation has completed, and {@link isCancellation}(error) will be true. On the other hand, the Child may
|
|
37
|
+
* ignore the cancellation request, in which case an error might be thrown with a different cause, or the Child may
|
|
38
|
+
* complete successfully.
|
|
39
|
+
*
|
|
40
|
+
* @default
|
|
41
|
+
*/
|
|
20
42
|
ChildWorkflowCancellationType[ChildWorkflowCancellationType["WAIT_CANCELLATION_COMPLETED"] = 2] = "WAIT_CANCELLATION_COMPLETED";
|
|
43
|
+
/**
|
|
44
|
+
* Send a cancellation request to the Child. Throw the error once the Server receives the Child cancellation request.
|
|
45
|
+
*/
|
|
21
46
|
ChildWorkflowCancellationType[ChildWorkflowCancellationType["WAIT_CANCELLATION_REQUESTED"] = 3] = "WAIT_CANCELLATION_REQUESTED";
|
|
22
47
|
})(ChildWorkflowCancellationType = exports.ChildWorkflowCancellationType || (exports.ChildWorkflowCancellationType = {}));
|
|
23
48
|
(0, internal_workflow_common_1.checkExtends)();
|
|
49
|
+
/**
|
|
50
|
+
* How a Child Workflow reacts to the Parent Workflow reaching a Closed state.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://docs.temporal.io/concepts/what-is-a-parent-close-policy/ | Parent Close Policy}
|
|
53
|
+
*/
|
|
24
54
|
var ParentClosePolicy;
|
|
25
55
|
(function (ParentClosePolicy) {
|
|
56
|
+
/**
|
|
57
|
+
* If a `ParentClosePolicy` is set to this, or is not set at all, the server default value will be used.
|
|
58
|
+
*/
|
|
26
59
|
ParentClosePolicy[ParentClosePolicy["PARENT_CLOSE_POLICY_UNSPECIFIED"] = 0] = "PARENT_CLOSE_POLICY_UNSPECIFIED";
|
|
60
|
+
/**
|
|
61
|
+
* When the Parent is Closed, the Child is Terminated.
|
|
62
|
+
*
|
|
63
|
+
* @default
|
|
64
|
+
*/
|
|
27
65
|
ParentClosePolicy[ParentClosePolicy["PARENT_CLOSE_POLICY_TERMINATE"] = 1] = "PARENT_CLOSE_POLICY_TERMINATE";
|
|
66
|
+
/**
|
|
67
|
+
* When the Parent is Closed, nothing is done to the Child.
|
|
68
|
+
*/
|
|
28
69
|
ParentClosePolicy[ParentClosePolicy["PARENT_CLOSE_POLICY_ABANDON"] = 2] = "PARENT_CLOSE_POLICY_ABANDON";
|
|
70
|
+
/**
|
|
71
|
+
* When the Parent is Closed, the Child is Cancelled.
|
|
72
|
+
*/
|
|
29
73
|
ParentClosePolicy[ParentClosePolicy["PARENT_CLOSE_POLICY_REQUEST_CANCEL"] = 3] = "PARENT_CLOSE_POLICY_REQUEST_CANCEL";
|
|
30
74
|
})(ParentClosePolicy = exports.ParentClosePolicy || (exports.ParentClosePolicy = {}));
|
|
31
75
|
(0, internal_workflow_common_1.checkExtends)();
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AACA,mFAA6G;AAiJ7G;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IAGtC,YAA4B,OAAkE;QAC5F,KAAK,CAAC,2BAA2B,CAAC,CAAC;QADT,YAAO,GAAP,OAAO,CAA2D;QAF9E,SAAI,GAAG,eAAe,CAAC;IAIvC,CAAC;CACF;AAND,sCAMC;AAkCD;;;;;;;GAOG;AACH,IAAY,6BAyBX;AAzBD,WAAY,6BAA6B;IACvC;;OAEG;IACH,uFAAW,CAAA;IAEX;;OAEG;IACH,6FAAc,CAAA;IAEd;;;;;;;OAOG;IACH,+HAA+B,CAAA;IAE/B;;OAEG;IACH,+HAA+B,CAAA;AACjC,CAAC,EAzBW,6BAA6B,GAA7B,qCAA6B,KAA7B,qCAA6B,QAyBxC;AAED,IAAA,uCAAY,GAAuF,CAAC;AAEpG;;;;GAIG;AACH,IAAY,iBAsBX;AAtBD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,+GAAmC,CAAA;IAEnC;;;;OAIG;IACH,2GAAiC,CAAA;IAEjC;;OAEG;IACH,uGAA+B,CAAA;IAE/B;;OAEG;IACH,qHAAsC,CAAA;AACxC,CAAC,EAtBW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAsB5B;AAED,IAAA,uCAAY,GAA+D,CAAC"}
|
package/lib/internals.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PayloadConverter } from '@temporalio/common';
|
|
2
2
|
import { Workflow, WorkflowQueryType, WorkflowSignalType } from '@temporalio/internal-workflow-common';
|
|
3
3
|
import type { coresdk } from '@temporalio/proto';
|
|
4
4
|
import { RNG } from './alea';
|
|
5
5
|
import { QueryInput, SignalInput, WorkflowExecuteInput, WorkflowInterceptors, WorkflowInterceptorsFactory } from './interceptors';
|
|
6
6
|
import { WorkflowInfo } from './interfaces';
|
|
7
7
|
import { SinkCall } from './sinks';
|
|
8
|
+
/**
|
|
9
|
+
* Global store to track promise stacks for stack trace query
|
|
10
|
+
*/
|
|
11
|
+
export interface PromiseStackStore {
|
|
12
|
+
childToParent: Map<Promise<unknown>, Set<Promise<unknown>>>;
|
|
13
|
+
promiseToStack: Map<Promise<unknown>, string>;
|
|
14
|
+
}
|
|
8
15
|
export declare type ResolveFunction<T = any> = (val: T) => any;
|
|
9
16
|
export declare type RejectFunction<E = any> = (val: E) => any;
|
|
10
17
|
export interface Completion {
|
|
@@ -89,7 +96,7 @@ export declare class State {
|
|
|
89
96
|
*/
|
|
90
97
|
readonly signalHandlers: Map<string, WorkflowSignalType>;
|
|
91
98
|
/**
|
|
92
|
-
* Mapping of
|
|
99
|
+
* Mapping of query name to handler
|
|
93
100
|
*/
|
|
94
101
|
readonly queryHandlers: Map<string, WorkflowQueryType>;
|
|
95
102
|
/**
|
|
@@ -100,7 +107,6 @@ export declare class State {
|
|
|
100
107
|
* Buffer that stores all generated commands, reset after each activation
|
|
101
108
|
*/
|
|
102
109
|
commands: coresdk.workflow_commands.IWorkflowCommand[];
|
|
103
|
-
/**
|
|
104
110
|
/**
|
|
105
111
|
* Stores all {@link condition}s that haven't been unblocked yet
|
|
106
112
|
*/
|
|
@@ -127,6 +133,7 @@ export declare class State {
|
|
|
127
133
|
signalWorkflow: number;
|
|
128
134
|
cancelWorkflow: number;
|
|
129
135
|
condition: number;
|
|
136
|
+
stack: number;
|
|
130
137
|
};
|
|
131
138
|
get now(): number;
|
|
132
139
|
set now(value: number);
|
|
@@ -154,7 +161,7 @@ export declare class State {
|
|
|
154
161
|
* Injected on isolate context startup
|
|
155
162
|
*/
|
|
156
163
|
importInterceptors?: InterceptorsImportFunc;
|
|
157
|
-
payloadConverter:
|
|
164
|
+
payloadConverter: PayloadConverter;
|
|
158
165
|
/**
|
|
159
166
|
* Patches we know the status of for this workflow, as in {@link patched}
|
|
160
167
|
*/
|