@temporalio/workflow 0.22.0 → 1.0.0-rc.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/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [![NPM](https://img.shields.io/npm/v/@temporalio/workflow?style=for-the-badge)](https://www.npmjs.com/package/@temporalio/workflow)
4
4
 
5
- Part of [Temporal](https://temporal.io)'s [TypeScript SDK](https://docs.temporal.io/docs/typescript/introduction/).
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/docs/typescript/workflows)
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;AAGzE,iEAAiE;AACjE,qFAAqF;AACxE,QAAA,iBAAiB,GAAyB,UAAkB,CAAC,iBAAiB,IAAI;CAAQ,CAAC;AAExG,8EAA8E;AAC9E,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAuBtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAa,iBAAiB;IA4B5B,YAAY,OAAkC;QAP9C,6CAAmB,KAAK,EAAC;QAQvB,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YAC/C,8EAA8E;YAC9E,6DAA6D;YAC7D,aAAa;YACb,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE,EAAE;gBACpB,uBAAA,IAAI,sCAAoB,IAAI,MAAA,CAAC;gBAC7B,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,6BAA6B;QAC7B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,OAAO,EAAE,MAAM,KAAK,SAAS,EAAE;YACjC,I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AkHC;;AAED;;GAEG;AACU,QAAA,OAAO,GAAG,IAAI,yBAAiB,EAAqB,CAAC;AAElE,MAAa,qBAAsB,SAAQ,iBAAiB;IAC1D,MAAM;QACJ,IAAI,CAAC,MAAM,CAAC,IAAI,yBAAgB,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC1D,CAAC;CACF;AAJD,sDAIC;AAED,qCAAqC;AACxB,QAAA,UAAU,GAAG,IAAI,qBAAqB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAE9F,+FAA+F;AAC/F,IAAI,KAAK,GAAG,CAAC,CAAkB,EAAiB,EAAE;IAChD,MAAM,IAAI,0BAAiB,CAAC,4CAA4C,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,SAAgB,2BAA2B,CAAC,EAAgB;IAC1D,KAAK,GAAG,EAAE,CAAC;AACb,CAAC;AAFD,kEAEC"}
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
- const common_1 = require("@temporalio/common");
5
- var common_2 = require("@temporalio/common");
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
- return (err instanceof common_1.CancelledFailure ||
32
- ((err instanceof common_1.ActivityFailure || err instanceof common_1.ChildWorkflowFailure) && isCancellation(err.cause)));
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,+CAA6F;AAC7F,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;;GAEG;AACH,SAAgB,cAAc,CAAC,GAAY;IACzC,OAAO,CACL,GAAG,YAAY,yBAAgB;QAC/B,CAAC,CAAC,GAAG,YAAY,wBAAe,IAAI,GAAG,YAAY,6BAAoB,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CACvG,CAAC;AACJ,CAAC;AALD,wCAKC"}
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 [tutorial](https://docs.temporal.io/docs/typescript/hello-world#workflows) for writing your first workflow.
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
- * We've replaced `setTimeout` and `clearTimeout` with deterministic versions so these are also usable but have a limitation that they don't play well with [cancellation scopes](https://docs.temporal.io/docs/typescript/workflow-scopes-and-cancellation).
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
- * Signal handlers can return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
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
- * Query handlers must **not** mutate any variables or generate any commands (like Activities or Timers), they run synchronously and thus **must** return a `Promise`.
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 also provide a deterministic {@link uuid4} function for convenience.
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/docs/typescript/workflow-scopes-and-cancellation)
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/docs/typescript/sinks)
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, ActivityOptions, IllegalStateError, RetryPolicy, ValueError, } from '@temporalio/internal-workflow-common';
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 [tutorial](https://docs.temporal.io/docs/typescript/hello-world#workflows) for writing your first workflow.
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
- * We've replaced `setTimeout` and `clearTimeout` with deterministic versions so these are also usable but have a limitation that they don't play well with [cancellation scopes](https://docs.temporal.io/docs/typescript/workflow-scopes-and-cancellation).
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
- * Signal handlers can return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
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
- * Query handlers must **not** mutate any variables or generate any commands (like Activities or Timers), they run synchronously and thus **must** return a `Promise`.
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 also provide a deterministic {@link uuid4} function for convenience.
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/docs/typescript/workflow-scopes-and-cancellation)
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/docs/typescript/sinks)
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.ValueError = exports.IllegalStateError = exports.ActivityCancellationType = exports.TimeoutFailure = exports.TerminatedFailure = exports.TemporalFailure = exports.ServerFailure = exports.rootCause = exports.defaultPayloadConverter = exports.ChildWorkflowFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ActivityFailure = void 0;
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
- Object.defineProperty(exports, "IllegalStateError", { enumerable: true, get: function () { return internal_workflow_common_1.IllegalStateError; } });
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;;;;;;;;;;;;;;;;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,iFAQ8C;AAP5C,oIAAA,wBAAwB,OAAA;AAIxB,6HAAA,iBAAiB,OAAA;AAEjB,sHAAA,UAAU,OAAA;AAEZ,sFAAoE;AACpE,4FAA0E;AAC1E,2DAAkH;AAAzG,uHAAA,iBAAiB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAA4B,gHAAA,UAAU,OAAA;AACnF,2CAAyB;AACzB,iDAA+B;AAC/B,2CAOsB;AANpB,2HAAA,6BAA6B,OAAA;AAE7B,2GAAA,aAAa,OAAA;AAEb,+GAAA,iBAAiB,OAAA;AAInB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,6CAA2B"}
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"}
@@ -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'>): Promise<void>;
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
  *
@@ -1,7 +1,8 @@
1
- import { CommonWorkflowOptions } from '@temporalio/internal-workflow-common';
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 execution information
5
+ * Workflow Execution information
5
6
  */
6
7
  export interface WorkflowInfo {
7
8
  /**
@@ -14,21 +15,87 @@ export interface WorkflowInfo {
14
15
  */
15
16
  runId: string;
16
17
  /**
17
- * Filename containing the Workflow code
18
+ * Workflow function's name
18
19
  */
19
20
  workflowType: string;
20
21
  /**
21
- * Namespace this Workflow is scheduled in
22
+ * Indexed information attached to the Workflow Execution
22
23
  */
23
- namespace: string;
24
+ searchAttributes: SearchAttributes;
25
+ /**
26
+ * Non-indexed information attached to the Workflow Execution
27
+ */
28
+ memo?: Record<string, unknown>;
29
+ /**
30
+ * Parent Workflow info (present if this is a Child Workflow)
31
+ */
32
+ parent?: ParentWorkflowInfo;
33
+ /**
34
+ * Result from the previous Run (present if this is a Cron Workflow or was Continued As New).
35
+ *
36
+ * An array of values, since other SDKs may return multiple values from a Workflow.
37
+ */
38
+ lastResult?: unknown;
24
39
  /**
25
- * Task queue this Workflow is scheduled in
40
+ * Failure from the previous Run (present when this Run is a retry, or the last Run of a Cron Workflow failed)
41
+ */
42
+ lastFailure?: TemporalFailure;
43
+ /**
44
+ * Task queue this Workflow is executing on
26
45
  */
27
46
  taskQueue: string;
28
47
  /**
29
- * Whether a Workflow is replaying history or processing new events
48
+ * Namespace this Workflow is executing in
49
+ */
50
+ namespace: string;
51
+ /**
52
+ * Run Id of the first Run in this Execution Chain
53
+ */
54
+ firstExecutionRunId: string;
55
+ /**
56
+ * The last Run Id in this Execution Chain
57
+ */
58
+ continuedFromExecutionRunId?: string;
59
+ /**
60
+ * Time at which the Workflow Run started
61
+ */
62
+ /**
63
+ * Milliseconds after which the Workflow Execution is automatically terminated by Temporal Server. Set via {@link WorkflowOptions.workflowExecutionTimeout}.
64
+ */
65
+ executionTimeoutMs?: number;
66
+ /**
67
+ * Time at which the Workflow Execution expires
68
+ */
69
+ executionExpirationTime?: Date;
70
+ /**
71
+ * Milliseconds after which the Workflow Run is automatically terminated by Temporal Server. Set via {@link WorkflowOptions.workflowRunTimeout}.
72
+ */
73
+ runTimeoutMs?: number;
74
+ /**
75
+ * Maximum execution time of a Workflow Task in milliseconds. Set via {@link WorkflowOptions.workflowTaskTimeout}.
76
+ */
77
+ taskTimeoutMs: number;
78
+ /**
79
+ * Retry Policy for this Execution. Set via {@link WorkflowOptions.retry}.
80
+ */
81
+ retryPolicy?: RetryPolicy;
82
+ /**
83
+ * Starts at 1 and increments for every retry if there is a `retryPolicy`
30
84
  */
31
- isReplaying: boolean;
85
+ attempt: number;
86
+ /**
87
+ * Cron Schedule for this Execution. Set via {@link WorkflowOptions.cronSchedule}.
88
+ */
89
+ cronSchedule?: string;
90
+ /**
91
+ * Milliseconds between Cron Runs
92
+ */
93
+ cronScheduleToScheduleInterval?: number;
94
+ }
95
+ export interface ParentWorkflowInfo {
96
+ workflowId: string;
97
+ runId: string;
98
+ namespace: string;
32
99
  }
33
100
  /**
34
101
  * Not an actual error, used by the Workflow runtime to abort execution when {@link continueAsNew} is called
@@ -67,18 +134,62 @@ export interface ContinueAsNewOptions {
67
134
  /**
68
135
  * Searchable attributes to attach to next Workflow run
69
136
  */
70
- searchAttributes?: Record<string, any>;
137
+ searchAttributes?: SearchAttributes;
71
138
  }
139
+ /**
140
+ * Specifies:
141
+ * - whether cancellation requests are sent to the Child
142
+ * - whether and when a {@link CanceledFailure} is thrown from {@link executeChild} or
143
+ * {@link ChildWorkflowHandle.result}
144
+ *
145
+ * @default {@link ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED}
146
+ */
72
147
  export declare enum ChildWorkflowCancellationType {
148
+ /**
149
+ * Don't send a cancellation request to the Child.
150
+ */
73
151
  ABANDON = 0,
152
+ /**
153
+ * Send a cancellation request to the Child. Immediately throw the error.
154
+ */
74
155
  TRY_CANCEL = 1,
156
+ /**
157
+ * Send a cancellation request to the Child. The Child may respect cancellation, in which case an error will be thrown
158
+ * when cancellation has completed, and {@link isCancellation}(error) will be true. On the other hand, the Child may
159
+ * ignore the cancellation request, in which case an error might be thrown with a different cause, or the Child may
160
+ * complete successfully.
161
+ *
162
+ * @default
163
+ */
75
164
  WAIT_CANCELLATION_COMPLETED = 2,
165
+ /**
166
+ * Send a cancellation request to the Child. Throw the error once the Server receives the Child cancellation request.
167
+ */
76
168
  WAIT_CANCELLATION_REQUESTED = 3
77
169
  }
170
+ /**
171
+ * How a Child Workflow reacts to the Parent Workflow reaching a Closed state.
172
+ *
173
+ * @see {@link https://docs.temporal.io/concepts/what-is-a-parent-close-policy/ | Parent Close Policy}
174
+ */
78
175
  export declare enum ParentClosePolicy {
176
+ /**
177
+ * If a `ParentClosePolicy` is set to this, or is not set at all, the server default value will be used.
178
+ */
79
179
  PARENT_CLOSE_POLICY_UNSPECIFIED = 0,
180
+ /**
181
+ * When the Parent is Closed, the Child is Terminated.
182
+ *
183
+ * @default
184
+ */
80
185
  PARENT_CLOSE_POLICY_TERMINATE = 1,
186
+ /**
187
+ * When the Parent is Closed, nothing is done to the Child.
188
+ */
81
189
  PARENT_CLOSE_POLICY_ABANDON = 2,
190
+ /**
191
+ * When the Parent is Closed, the Child is Cancelled.
192
+ */
82
193
  PARENT_CLOSE_POLICY_REQUEST_CANCEL = 3
83
194
  }
84
195
  export interface ChildWorkflowOptions extends CommonWorkflowOptions {
@@ -94,13 +205,18 @@ export interface ChildWorkflowOptions extends CommonWorkflowOptions {
94
205
  */
95
206
  taskQueue?: string;
96
207
  /**
97
- * In case of a child workflow cancellation it fails with a CanceledFailure.
98
- * The type defines at which point the exception is thrown.
99
- * @default ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED
208
+ * Specifies:
209
+ * - whether cancellation requests are sent to the Child
210
+ * - whether and when an error is thrown from {@link executeChild} or
211
+ * {@link ChildWorkflowHandle.result}
212
+ *
213
+ * @default {@link ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED}
100
214
  */
101
215
  cancellationType?: ChildWorkflowCancellationType;
102
216
  /**
103
- * Specifies how this workflow reacts to the death of the parent workflow.
217
+ * Specifies how the Child reacts to the Parent Workflow reaching a Closed state.
218
+ *
219
+ * @default {@link ParentClosePolicy.PARENT_CLOSE_POLICY_TERMINATE}
104
220
  */
105
221
  parentClosePolicy?: ParentClosePolicy;
106
222
  }
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)();
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAAA,mFAA2F;AAsC3F;;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;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AtBW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAsB5B;AAED,IAAA,uCAAY,GAA+D,CAAC"}
@@ -5,6 +5,13 @@ 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 signal name to handler
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);
@@ -138,6 +145,14 @@ export declare class State {
138
145
  * Information about the current Workflow
139
146
  */
140
147
  info?: WorkflowInfo;
148
+ /**
149
+ * Whether a Workflow is replaying history or processing new events
150
+ */
151
+ isReplaying?: boolean;
152
+ /**
153
+ * ID of last WorkflowTaskStarted event
154
+ */
155
+ historyLength?: number;
141
156
  /**
142
157
  * A deterministic RNG, used by the isolate's overridden Math.random
143
158
  */