@temporalio/workflow 1.8.5 → 1.9.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/errors.d.ts +8 -0
- package/lib/errors.js +14 -1
- package/lib/errors.js.map +1 -1
- package/lib/global-attributes.d.ts +4 -0
- package/lib/global-attributes.js +21 -1
- package/lib/global-attributes.js.map +1 -1
- package/lib/index.d.ts +19 -8
- package/lib/index.js +15 -8
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +15 -0
- package/lib/interfaces.d.ts +40 -32
- package/lib/interfaces.js.map +1 -1
- package/lib/internals.d.ts +24 -13
- package/lib/internals.js +145 -41
- package/lib/internals.js.map +1 -1
- package/lib/logs.d.ts +50 -0
- package/lib/logs.js +84 -0
- package/lib/logs.js.map +1 -0
- package/lib/sinks.d.ts +29 -10
- package/lib/sinks.js +57 -0
- package/lib/sinks.js.map +1 -1
- package/lib/worker-interface.d.ts +2 -2
- package/lib/worker-interface.js +33 -22
- package/lib/worker-interface.js.map +1 -1
- package/lib/workflow.d.ts +23 -54
- package/lib/workflow.js +156 -141
- package/lib/workflow.js.map +1 -1
- package/package.json +4 -4
- package/src/errors.ts +11 -0
- package/src/global-attributes.ts +21 -0
- package/src/index.ts +24 -8
- package/src/interceptors.ts +18 -0
- package/src/interfaces.ts +44 -32
- package/src/internals.ts +175 -37
- package/src/logs.ts +118 -0
- package/src/sinks.ts +60 -9
- package/src/worker-interface.ts +28 -16
- package/src/workflow.ts +150 -128
package/lib/errors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { coresdk } from '@temporalio/proto';
|
|
1
2
|
/**
|
|
2
3
|
* Base class for all workflow errors
|
|
3
4
|
*/
|
|
@@ -8,6 +9,13 @@ export declare class WorkflowError extends Error {
|
|
|
8
9
|
*/
|
|
9
10
|
export declare class DeterminismViolationError extends WorkflowError {
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* A class that acts as a marker for this special result type
|
|
14
|
+
*/
|
|
15
|
+
export declare class LocalActivityDoBackoff extends Error {
|
|
16
|
+
readonly backoff: coresdk.activity_result.IDoBackoff;
|
|
17
|
+
constructor(backoff: coresdk.activity_result.IDoBackoff);
|
|
18
|
+
}
|
|
11
19
|
/**
|
|
12
20
|
* Returns whether provided `err` is caused by cancellation
|
|
13
21
|
*/
|
package/lib/errors.js
CHANGED
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.isCancellation = exports.DeterminismViolationError = exports.WorkflowError = void 0;
|
|
9
|
+
exports.isCancellation = exports.LocalActivityDoBackoff = exports.DeterminismViolationError = exports.WorkflowError = void 0;
|
|
10
10
|
const common_1 = require("@temporalio/common");
|
|
11
11
|
const type_helpers_1 = require("@temporalio/common/lib/type-helpers");
|
|
12
12
|
/**
|
|
@@ -27,6 +27,19 @@ DeterminismViolationError = __decorate([
|
|
|
27
27
|
(0, type_helpers_1.SymbolBasedInstanceOfError)('DeterminismViolationError')
|
|
28
28
|
], DeterminismViolationError);
|
|
29
29
|
exports.DeterminismViolationError = DeterminismViolationError;
|
|
30
|
+
/**
|
|
31
|
+
* A class that acts as a marker for this special result type
|
|
32
|
+
*/
|
|
33
|
+
let LocalActivityDoBackoff = class LocalActivityDoBackoff extends Error {
|
|
34
|
+
constructor(backoff) {
|
|
35
|
+
super();
|
|
36
|
+
this.backoff = backoff;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
LocalActivityDoBackoff = __decorate([
|
|
40
|
+
(0, type_helpers_1.SymbolBasedInstanceOfError)('LocalActivityDoBackoff')
|
|
41
|
+
], LocalActivityDoBackoff);
|
|
42
|
+
exports.LocalActivityDoBackoff = LocalActivityDoBackoff;
|
|
30
43
|
/**
|
|
31
44
|
* Returns whether provided `err` is caused by cancellation
|
|
32
45
|
*/
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA6F;AAC7F,sEAAiF;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAA6F;AAC7F,sEAAiF;AAGjF;;GAEG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,KAAK;CAAG,CAAA;AAA9B,aAAa;IADzB,IAAA,yCAA0B,EAAC,eAAe,CAAC;GAC/B,aAAa,CAAiB;AAA9B,sCAAa;AAE1B;;GAEG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,aAAa;CAAG,CAAA;AAAlD,yBAAyB;IADrC,IAAA,yCAA0B,EAAC,2BAA2B,CAAC;GAC3C,yBAAyB,CAAyB;AAAlD,8DAAyB;AAEtC;;GAEG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,KAAK;IAC/C,YAA4B,OAA2C;QACrE,KAAK,EAAE,CAAC;QADkB,YAAO,GAAP,OAAO,CAAoC;IAEvE,CAAC;CACF,CAAA;AAJY,sBAAsB;IADlC,IAAA,yCAA0B,EAAC,wBAAwB,CAAC;GACxC,sBAAsB,CAIlC;AAJY,wDAAsB;AAMnC;;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,GAAG,CAAC,KAAK,YAAY,yBAAgB,CAAC,CACnH,CAAC;AACJ,CAAC;AALD,wCAKC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { type Activator } from './internals';
|
|
1
2
|
export declare function maybeGetActivatorUntyped(): unknown;
|
|
2
3
|
export declare function setActivatorUntyped(activator: unknown): void;
|
|
4
|
+
export declare function maybeGetActivator(): Activator | undefined;
|
|
5
|
+
export declare function assertInWorkflowContext(message: string): Activator;
|
|
6
|
+
export declare function getActivator(): Activator;
|
package/lib/global-attributes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setActivatorUntyped = exports.maybeGetActivatorUntyped = void 0;
|
|
3
|
+
exports.getActivator = exports.assertInWorkflowContext = exports.maybeGetActivator = exports.setActivatorUntyped = exports.maybeGetActivatorUntyped = void 0;
|
|
4
|
+
const common_1 = require("@temporalio/common");
|
|
4
5
|
function maybeGetActivatorUntyped() {
|
|
5
6
|
return globalThis.__TEMPORAL_ACTIVATOR__;
|
|
6
7
|
}
|
|
@@ -9,4 +10,23 @@ function setActivatorUntyped(activator) {
|
|
|
9
10
|
globalThis.__TEMPORAL_ACTIVATOR__ = activator;
|
|
10
11
|
}
|
|
11
12
|
exports.setActivatorUntyped = setActivatorUntyped;
|
|
13
|
+
function maybeGetActivator() {
|
|
14
|
+
return maybeGetActivatorUntyped();
|
|
15
|
+
}
|
|
16
|
+
exports.maybeGetActivator = maybeGetActivator;
|
|
17
|
+
function assertInWorkflowContext(message) {
|
|
18
|
+
const activator = maybeGetActivator();
|
|
19
|
+
if (activator == null)
|
|
20
|
+
throw new common_1.IllegalStateError(message);
|
|
21
|
+
return activator;
|
|
22
|
+
}
|
|
23
|
+
exports.assertInWorkflowContext = assertInWorkflowContext;
|
|
24
|
+
function getActivator() {
|
|
25
|
+
const activator = maybeGetActivator();
|
|
26
|
+
if (activator === undefined) {
|
|
27
|
+
throw new common_1.IllegalStateError('Workflow uninitialized');
|
|
28
|
+
}
|
|
29
|
+
return activator;
|
|
30
|
+
}
|
|
31
|
+
exports.getActivator = getActivator;
|
|
12
32
|
//# sourceMappingURL=global-attributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-attributes.js","sourceRoot":"","sources":["../src/global-attributes.ts"],"names":[],"mappings":";;;AAAA,SAAgB,wBAAwB;IACtC,OAAQ,UAAkB,CAAC,sBAAsB,CAAC;AACpD,CAAC;AAFD,4DAEC;AAED,SAAgB,mBAAmB,CAAC,SAAkB;IACnD,UAAkB,CAAC,sBAAsB,GAAG,SAAS,CAAC;AACzD,CAAC;AAFD,kDAEC"}
|
|
1
|
+
{"version":3,"file":"global-attributes.js","sourceRoot":"","sources":["../src/global-attributes.ts"],"names":[],"mappings":";;;AAAA,+CAAuD;AAGvD,SAAgB,wBAAwB;IACtC,OAAQ,UAAkB,CAAC,sBAAsB,CAAC;AACpD,CAAC;AAFD,4DAEC;AAED,SAAgB,mBAAmB,CAAC,SAAkB;IACnD,UAAkB,CAAC,sBAAsB,GAAG,SAAS,CAAC;AACzD,CAAC;AAFD,kDAEC;AAED,SAAgB,iBAAiB;IAC/B,OAAO,wBAAwB,EAA2B,CAAC;AAC7D,CAAC;AAFD,8CAEC;AAED,SAAgB,uBAAuB,CAAC,OAAe;IACrD,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAC;IACtC,IAAI,SAAS,IAAI,IAAI;QAAE,MAAM,IAAI,0BAAiB,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,SAAS,CAAC;AACnB,CAAC;AAJD,0DAIC;AAED,SAAgB,YAAY;IAC1B,MAAM,SAAS,GAAG,iBAAiB,EAAE,CAAC;IACtC,IAAI,SAAS,KAAK,SAAS,EAAE;QAC3B,MAAM,IAAI,0BAAiB,CAAC,wBAAwB,CAAC,CAAC;KACvD;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAND,oCAMC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -20,18 +20,21 @@
|
|
|
20
20
|
* <!--SNIPSTART typescript-schedule-activity-workflow-->
|
|
21
21
|
* <!--SNIPEND-->
|
|
22
22
|
*
|
|
23
|
-
* ### Signals and Queries
|
|
23
|
+
* ### Updates, Signals and Queries
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
* return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
|
|
25
|
+
* Use {@link setHandler} to set handlers for Updates, Signals, and Queries.
|
|
27
26
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* Update and Signal handlers can be either async or non-async functions. Update handlers may return a value, but signal
|
|
28
|
+
* handlers may not (return `void` or `Promise<void>`). You may use Activities, Timers, child Workflows, etc in Update
|
|
29
|
+
* and Signal handlers, but this should be done cautiously: for example, note that if you await async operations such as
|
|
30
|
+
* these in an Update or Signal handler, then you are responsible for ensuring that the workflow does not complete first.
|
|
31
|
+
*
|
|
32
|
+
* Query handlers may **not** be async functions, and may **not** mutate any variables or use Activities, Timers,
|
|
33
|
+
* child Workflows, etc.
|
|
31
34
|
*
|
|
32
35
|
* #### Implementation
|
|
33
36
|
*
|
|
34
|
-
* <!--SNIPSTART typescript-workflow-signal-
|
|
37
|
+
* <!--SNIPSTART typescript-workflow-update-signal-query-example-->
|
|
35
38
|
* <!--SNIPEND-->
|
|
36
39
|
*
|
|
37
40
|
* ### More
|
|
@@ -55,7 +58,15 @@ export { AsyncLocalStorage, CancellationScope, CancellationScopeOptions } from '
|
|
|
55
58
|
export * from './errors';
|
|
56
59
|
export * from './interceptors';
|
|
57
60
|
export { ChildWorkflowCancellationType, ChildWorkflowOptions, ContinueAsNew, ContinueAsNewOptions, EnhancedStackTrace, FileLocation, FileSlice, ParentClosePolicy, ParentWorkflowInfo, SDKInfo, StackTrace, UnsafeWorkflowInfo, WorkflowInfo, } from './interfaces';
|
|
58
|
-
export {
|
|
61
|
+
export { proxySinks, Sink, SinkCall, SinkFunction, Sinks } from './sinks';
|
|
62
|
+
export { log } from './logs';
|
|
59
63
|
export { Trigger } from './trigger';
|
|
60
64
|
export * from './workflow';
|
|
61
65
|
export { ChildWorkflowHandle, ExternalWorkflowHandle } from './workflow-handle';
|
|
66
|
+
export {
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Do not use LoggerSinks directly. To log from Workflow code, use the `log` object
|
|
69
|
+
* exported by the `@temporalio/workflow` package. To capture log messages emitted
|
|
70
|
+
* by Workflow code, set the {@link Runtime.logger} property.
|
|
71
|
+
*/
|
|
72
|
+
LoggerSinksDeprecated as LoggerSinks, } from './logs';
|
package/lib/index.js
CHANGED
|
@@ -21,18 +21,21 @@
|
|
|
21
21
|
* <!--SNIPSTART typescript-schedule-activity-workflow-->
|
|
22
22
|
* <!--SNIPEND-->
|
|
23
23
|
*
|
|
24
|
-
* ### Signals and Queries
|
|
24
|
+
* ### Updates, Signals and Queries
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
* return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
|
|
26
|
+
* Use {@link setHandler} to set handlers for Updates, Signals, and Queries.
|
|
28
27
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* Update and Signal handlers can be either async or non-async functions. Update handlers may return a value, but signal
|
|
29
|
+
* handlers may not (return `void` or `Promise<void>`). You may use Activities, Timers, child Workflows, etc in Update
|
|
30
|
+
* and Signal handlers, but this should be done cautiously: for example, note that if you await async operations such as
|
|
31
|
+
* these in an Update or Signal handler, then you are responsible for ensuring that the workflow does not complete first.
|
|
32
|
+
*
|
|
33
|
+
* Query handlers may **not** be async functions, and may **not** mutate any variables or use Activities, Timers,
|
|
34
|
+
* child Workflows, etc.
|
|
32
35
|
*
|
|
33
36
|
* #### Implementation
|
|
34
37
|
*
|
|
35
|
-
* <!--SNIPSTART typescript-workflow-signal-
|
|
38
|
+
* <!--SNIPSTART typescript-workflow-update-signal-query-example-->
|
|
36
39
|
* <!--SNIPEND-->
|
|
37
40
|
*
|
|
38
41
|
* ### More
|
|
@@ -61,7 +64,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
61
64
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
62
65
|
};
|
|
63
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
-
exports.Trigger = 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;
|
|
67
|
+
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;
|
|
65
68
|
var common_1 = require("@temporalio/common");
|
|
66
69
|
Object.defineProperty(exports, "ActivityCancellationType", { enumerable: true, get: function () { return common_1.ActivityCancellationType; } });
|
|
67
70
|
Object.defineProperty(exports, "ActivityFailure", { enumerable: true, get: function () { return common_1.ActivityFailure; } });
|
|
@@ -86,6 +89,10 @@ var interfaces_1 = require("./interfaces");
|
|
|
86
89
|
Object.defineProperty(exports, "ChildWorkflowCancellationType", { enumerable: true, get: function () { return interfaces_1.ChildWorkflowCancellationType; } });
|
|
87
90
|
Object.defineProperty(exports, "ContinueAsNew", { enumerable: true, get: function () { return interfaces_1.ContinueAsNew; } });
|
|
88
91
|
Object.defineProperty(exports, "ParentClosePolicy", { enumerable: true, get: function () { return interfaces_1.ParentClosePolicy; } });
|
|
92
|
+
var sinks_1 = require("./sinks");
|
|
93
|
+
Object.defineProperty(exports, "proxySinks", { enumerable: true, get: function () { return sinks_1.proxySinks; } });
|
|
94
|
+
var logs_1 = require("./logs");
|
|
95
|
+
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logs_1.log; } });
|
|
89
96
|
var trigger_1 = require("./trigger");
|
|
90
97
|
Object.defineProperty(exports, "Trigger", { enumerable: true, get: function () { return trigger_1.Trigger; } });
|
|
91
98
|
__exportStar(require("./workflow"), exports);
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;;;;;;;;;;;;;;;;;AAEH,6CAe4B;AAd1B,kHAAA,wBAAwB,OAAA;AACxB,yGAAA,eAAe,OAAA;AAEf,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,8GAAA,oBAAoB,OAAA;AACpB,iHAAA,uBAAuB,OAAA;AAGvB,mGAAA,SAAS,OAAA;AACT,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AAEhB,gEAA8C;AAgB9C,yEAAuD;AACvD,0EAAwD;AACxD,2DAAsG;AAA7F,uHAAA,iBAAiB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAC7C,2CAAyB;AACzB,iDAA+B;AAC/B,2CAcsB;AAbpB,2HAAA,6BAA6B,OAAA;AAE7B,2GAAA,aAAa,OAAA;AAKb,+GAAA,iBAAiB,OAAA;AAOnB,iCAA0E;AAAjE,mGAAA,UAAU,OAAA;AACnB,+BAA6B;AAApB,2FAAA,GAAG,OAAA;AACZ,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,6CAA2B"}
|
package/lib/interceptors.d.ts
CHANGED
|
@@ -14,6 +14,14 @@ export interface WorkflowExecuteInput {
|
|
|
14
14
|
readonly args: unknown[];
|
|
15
15
|
readonly headers: Headers;
|
|
16
16
|
}
|
|
17
|
+
/** Input for WorkflowInboundCallsInterceptor.handleUpdate and
|
|
18
|
+
* WorkflowInboundCallsInterceptor.validateUpdate */
|
|
19
|
+
export interface UpdateInput {
|
|
20
|
+
readonly updateId: string;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly args: unknown[];
|
|
23
|
+
readonly headers: Headers;
|
|
24
|
+
}
|
|
17
25
|
/** Input for WorkflowInboundCallsInterceptor.handleSignal */
|
|
18
26
|
export interface SignalInput {
|
|
19
27
|
readonly signalName: string;
|
|
@@ -37,6 +45,13 @@ export interface WorkflowInboundCallsInterceptor {
|
|
|
37
45
|
* @return result of the Workflow execution
|
|
38
46
|
*/
|
|
39
47
|
execute?: (input: WorkflowExecuteInput, next: Next<this, 'execute'>) => Promise<unknown>;
|
|
48
|
+
/** Called when Update handler is called
|
|
49
|
+
*
|
|
50
|
+
* @return result of the Update
|
|
51
|
+
*/
|
|
52
|
+
handleUpdate?: (input: UpdateInput, next: Next<this, 'handleUpdate'>) => Promise<unknown>;
|
|
53
|
+
/** Called when update validator called */
|
|
54
|
+
validateUpdate?: (input: UpdateInput, next: Next<this, 'validateUpdate'>) => void;
|
|
40
55
|
/** Called when signal is delivered to a Workflow execution */
|
|
41
56
|
handleSignal?: (input: SignalInput, next: Next<this, 'handleSignal'>) => Promise<void>;
|
|
42
57
|
/**
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RawSourceMap } from 'source-map';
|
|
2
|
-
import { RetryPolicy, TemporalFailure, CommonWorkflowOptions, SearchAttributes, SignalDefinition, QueryDefinition, Duration, VersioningIntent } from '@temporalio/common';
|
|
2
|
+
import { RetryPolicy, TemporalFailure, CommonWorkflowOptions, SearchAttributes, SignalDefinition, UpdateDefinition, QueryDefinition, Duration, VersioningIntent } from '@temporalio/common';
|
|
3
3
|
import type { coresdk } from '@temporalio/proto';
|
|
4
4
|
/**
|
|
5
5
|
* Workflow Execution information
|
|
@@ -9,39 +9,39 @@ export interface WorkflowInfo {
|
|
|
9
9
|
* ID of the Workflow, this can be set by the client during Workflow creation.
|
|
10
10
|
* A single Workflow may run multiple times e.g. when scheduled with cron.
|
|
11
11
|
*/
|
|
12
|
-
workflowId: string;
|
|
12
|
+
readonly workflowId: string;
|
|
13
13
|
/**
|
|
14
14
|
* ID of a single Workflow run
|
|
15
15
|
*/
|
|
16
|
-
runId: string;
|
|
16
|
+
readonly runId: string;
|
|
17
17
|
/**
|
|
18
18
|
* Workflow function's name
|
|
19
19
|
*/
|
|
20
|
-
workflowType: string;
|
|
20
|
+
readonly workflowType: string;
|
|
21
21
|
/**
|
|
22
22
|
* Indexed information attached to the Workflow Execution
|
|
23
23
|
*
|
|
24
24
|
* This value may change during the lifetime of an Execution.
|
|
25
25
|
*/
|
|
26
|
-
searchAttributes: SearchAttributes;
|
|
26
|
+
readonly searchAttributes: SearchAttributes;
|
|
27
27
|
/**
|
|
28
28
|
* Non-indexed information attached to the Workflow Execution
|
|
29
29
|
*/
|
|
30
|
-
memo?: Record<string, unknown>;
|
|
30
|
+
readonly memo?: Record<string, unknown>;
|
|
31
31
|
/**
|
|
32
32
|
* Parent Workflow info (present if this is a Child Workflow)
|
|
33
33
|
*/
|
|
34
|
-
parent?: ParentWorkflowInfo;
|
|
34
|
+
readonly parent?: ParentWorkflowInfo;
|
|
35
35
|
/**
|
|
36
36
|
* Result from the previous Run (present if this is a Cron Workflow or was Continued As New).
|
|
37
37
|
*
|
|
38
38
|
* An array of values, since other SDKs may return multiple values from a Workflow.
|
|
39
39
|
*/
|
|
40
|
-
lastResult?: unknown;
|
|
40
|
+
readonly lastResult?: unknown;
|
|
41
41
|
/**
|
|
42
42
|
* Failure from the previous Run (present when this Run is a retry, or the last Run of a Cron Workflow failed)
|
|
43
43
|
*/
|
|
44
|
-
lastFailure?: TemporalFailure;
|
|
44
|
+
readonly lastFailure?: TemporalFailure;
|
|
45
45
|
/**
|
|
46
46
|
* Length of Workflow history up until the current Workflow Task.
|
|
47
47
|
*
|
|
@@ -49,7 +49,7 @@ export interface WorkflowInfo {
|
|
|
49
49
|
*
|
|
50
50
|
* You may safely use this information to decide when to {@link continueAsNew}.
|
|
51
51
|
*/
|
|
52
|
-
historyLength: number;
|
|
52
|
+
readonly historyLength: number;
|
|
53
53
|
/**
|
|
54
54
|
* Size of Workflow history in bytes until the current Workflow Task.
|
|
55
55
|
*
|
|
@@ -59,7 +59,7 @@ export interface WorkflowInfo {
|
|
|
59
59
|
*
|
|
60
60
|
* You may safely use this information to decide when to {@link continueAsNew}.
|
|
61
61
|
*/
|
|
62
|
-
historySize: number;
|
|
62
|
+
readonly historySize: number;
|
|
63
63
|
/**
|
|
64
64
|
* A hint provided by the current WorkflowTaskStarted event recommending whether to
|
|
65
65
|
* {@link continueAsNew}.
|
|
@@ -68,64 +68,64 @@ export interface WorkflowInfo {
|
|
|
68
68
|
*
|
|
69
69
|
* Supported only on Temporal Server 1.20+, always `false` on older servers.
|
|
70
70
|
*/
|
|
71
|
-
continueAsNewSuggested: boolean;
|
|
71
|
+
readonly continueAsNewSuggested: boolean;
|
|
72
72
|
/**
|
|
73
73
|
* Task queue this Workflow is executing on
|
|
74
74
|
*/
|
|
75
|
-
taskQueue: string;
|
|
75
|
+
readonly taskQueue: string;
|
|
76
76
|
/**
|
|
77
77
|
* Namespace this Workflow is executing in
|
|
78
78
|
*/
|
|
79
|
-
namespace: string;
|
|
79
|
+
readonly namespace: string;
|
|
80
80
|
/**
|
|
81
81
|
* Run Id of the first Run in this Execution Chain
|
|
82
82
|
*/
|
|
83
|
-
firstExecutionRunId: string;
|
|
83
|
+
readonly firstExecutionRunId: string;
|
|
84
84
|
/**
|
|
85
85
|
* The last Run Id in this Execution Chain
|
|
86
86
|
*/
|
|
87
|
-
continuedFromExecutionRunId?: string;
|
|
87
|
+
readonly continuedFromExecutionRunId?: string;
|
|
88
88
|
/**
|
|
89
89
|
* Time at which this [Workflow Execution Chain](https://docs.temporal.io/workflows#workflow-execution-chain) was started
|
|
90
90
|
*/
|
|
91
|
-
startTime: Date;
|
|
91
|
+
readonly startTime: Date;
|
|
92
92
|
/**
|
|
93
93
|
* Time at which the current Workflow Run started
|
|
94
94
|
*/
|
|
95
|
-
runStartTime: Date;
|
|
95
|
+
readonly runStartTime: Date;
|
|
96
96
|
/**
|
|
97
97
|
* Milliseconds after which the Workflow Execution is automatically terminated by Temporal Server. Set via {@link WorkflowOptions.workflowExecutionTimeout}.
|
|
98
98
|
*/
|
|
99
|
-
executionTimeoutMs?: number;
|
|
99
|
+
readonly executionTimeoutMs?: number;
|
|
100
100
|
/**
|
|
101
101
|
* Time at which the Workflow Execution expires
|
|
102
102
|
*/
|
|
103
|
-
executionExpirationTime?: Date;
|
|
103
|
+
readonly executionExpirationTime?: Date;
|
|
104
104
|
/**
|
|
105
105
|
* Milliseconds after which the Workflow Run is automatically terminated by Temporal Server. Set via {@link WorkflowOptions.workflowRunTimeout}.
|
|
106
106
|
*/
|
|
107
|
-
runTimeoutMs?: number;
|
|
107
|
+
readonly runTimeoutMs?: number;
|
|
108
108
|
/**
|
|
109
109
|
* Maximum execution time of a Workflow Task in milliseconds. Set via {@link WorkflowOptions.workflowTaskTimeout}.
|
|
110
110
|
*/
|
|
111
|
-
taskTimeoutMs: number;
|
|
111
|
+
readonly taskTimeoutMs: number;
|
|
112
112
|
/**
|
|
113
113
|
* Retry Policy for this Execution. Set via {@link WorkflowOptions.retry}.
|
|
114
114
|
*/
|
|
115
|
-
retryPolicy?: RetryPolicy;
|
|
115
|
+
readonly retryPolicy?: RetryPolicy;
|
|
116
116
|
/**
|
|
117
117
|
* Starts at 1 and increments for every retry if there is a `retryPolicy`
|
|
118
118
|
*/
|
|
119
|
-
attempt: number;
|
|
119
|
+
readonly attempt: number;
|
|
120
120
|
/**
|
|
121
121
|
* Cron Schedule for this Execution. Set via {@link WorkflowOptions.cronSchedule}.
|
|
122
122
|
*/
|
|
123
|
-
cronSchedule?: string;
|
|
123
|
+
readonly cronSchedule?: string;
|
|
124
124
|
/**
|
|
125
125
|
* Milliseconds between Cron Runs
|
|
126
126
|
*/
|
|
127
|
-
cronScheduleToScheduleInterval?: number;
|
|
128
|
-
unsafe: UnsafeWorkflowInfo;
|
|
127
|
+
readonly cronScheduleToScheduleInterval?: number;
|
|
128
|
+
readonly unsafe: UnsafeWorkflowInfo;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Unsafe information about the current Workflow Execution.
|
|
@@ -139,8 +139,8 @@ export interface UnsafeWorkflowInfo {
|
|
|
139
139
|
* The safe version of time is `new Date()` and `Date.now()`, which are set on the first invocation of a Workflow
|
|
140
140
|
* Task and stay constant for the duration of the Task and during replay.
|
|
141
141
|
*/
|
|
142
|
-
now()
|
|
143
|
-
isReplaying: boolean;
|
|
142
|
+
readonly now: () => number;
|
|
143
|
+
readonly isReplaying: boolean;
|
|
144
144
|
}
|
|
145
145
|
export interface ParentWorkflowInfo {
|
|
146
146
|
workflowId: string;
|
|
@@ -188,6 +188,8 @@ export interface ContinueAsNewOptions {
|
|
|
188
188
|
* When using the Worker Versioning feature, specifies whether this Workflow should
|
|
189
189
|
* Continue-as-New onto a worker with a compatible Build Id or not. See {@link VersioningIntent}.
|
|
190
190
|
*
|
|
191
|
+
* @default 'COMPATIBLE'
|
|
192
|
+
*
|
|
191
193
|
* @experimental
|
|
192
194
|
*/
|
|
193
195
|
versioningIntent?: VersioningIntent;
|
|
@@ -279,6 +281,8 @@ export interface ChildWorkflowOptions extends CommonWorkflowOptions {
|
|
|
279
281
|
* When using the Worker Versioning feature, specifies whether this Child Workflow should run on
|
|
280
282
|
* a worker with a compatible Build Id or not. See {@link VersioningIntent}.
|
|
281
283
|
*
|
|
284
|
+
* @default 'COMPATIBLE'
|
|
285
|
+
*
|
|
282
286
|
* @experimental
|
|
283
287
|
*/
|
|
284
288
|
versioningIntent?: VersioningIntent;
|
|
@@ -356,10 +360,14 @@ export interface WorkflowCreateOptionsInternal extends WorkflowCreateOptions {
|
|
|
356
360
|
getTimeOfDay(): bigint;
|
|
357
361
|
}
|
|
358
362
|
/**
|
|
359
|
-
* A handler function capable of accepting the arguments for a given SignalDefinition or QueryDefinition.
|
|
363
|
+
* A handler function capable of accepting the arguments for a given UpdateDefinition, SignalDefinition or QueryDefinition.
|
|
360
364
|
*/
|
|
361
|
-
export type Handler<Ret, Args extends any[], T extends SignalDefinition<Args> | QueryDefinition<Ret, Args>> = T extends SignalDefinition<infer A> ? (...args: A) => void | Promise<void> : T extends QueryDefinition<infer R, infer A> ? (...args: A) => R : never;
|
|
365
|
+
export type Handler<Ret, Args extends any[], T extends UpdateDefinition<Ret, Args> | SignalDefinition<Args> | QueryDefinition<Ret, Args>> = T extends UpdateDefinition<infer R, infer A> ? (...args: A) => R | Promise<R> : T extends SignalDefinition<infer A> ? (...args: A) => void | Promise<void> : T extends QueryDefinition<infer R, infer A> ? (...args: A) => R : never;
|
|
362
366
|
/**
|
|
363
|
-
* A handler function accepting
|
|
367
|
+
* A handler function accepting signal calls for non-registered signal names.
|
|
364
368
|
*/
|
|
365
369
|
export type DefaultSignalHandler = (signalName: string, ...args: unknown[]) => void | Promise<void>;
|
|
370
|
+
/**
|
|
371
|
+
* A validation function capable of accepting the arguments for a given UpdateDefinition.
|
|
372
|
+
*/
|
|
373
|
+
export type UpdateValidator<Args extends any[]> = (...args: Args) => void;
|
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":";;;;;;;;;AAYA,sEAA+F;AAkL/F;;GAEG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,KAAK;IACtC,YAA4B,OAAkE;QAC5F,KAAK,CAAC,2BAA2B,CAAC,CAAC;QADT,YAAO,GAAP,OAAO,CAA2D;IAE9F,CAAC;CACF,CAAA;AAJY,aAAa;IADzB,IAAA,yCAA0B,EAAC,eAAe,CAAC;GAC/B,aAAa,CAIzB;AAJY,sCAAa;AA+C1B;;;;;;;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,2BAAY,GAAuF,CAAC;AACpG,IAAA,2BAAY,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,2BAAY,GAA+D,CAAC;AAC5E,IAAA,2BAAY,GAA+D,CAAC"}
|
package/lib/internals.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { RawSourceMap } from 'source-map';
|
|
2
|
-
import { FailureConverter, PayloadConverter, Workflow, WorkflowQueryType, WorkflowSignalType, ProtoFailure } from '@temporalio/common';
|
|
2
|
+
import { FailureConverter, PayloadConverter, Workflow, WorkflowQueryType, WorkflowSignalType, WorkflowUpdateType, ProtoFailure, WorkflowUpdateValidatorType } from '@temporalio/common';
|
|
3
3
|
import type { coresdk } from '@temporalio/proto';
|
|
4
4
|
import { RNG } from './alea';
|
|
5
5
|
import { RootCancellationScope } from './cancellation-scope';
|
|
6
|
-
import { QueryInput, SignalInput, WorkflowExecuteInput, WorkflowInterceptors } from './interceptors';
|
|
6
|
+
import { QueryInput, SignalInput, UpdateInput, WorkflowExecuteInput, WorkflowInterceptors } from './interceptors';
|
|
7
7
|
import { DefaultSignalHandler, FileLocation, WorkflowInfo, WorkflowCreateOptionsInternal } from './interfaces';
|
|
8
|
-
import { SinkCall } from './sinks';
|
|
8
|
+
import { type SinkCall } from './sinks';
|
|
9
9
|
export interface Stack {
|
|
10
10
|
formatted: string;
|
|
11
11
|
structured: FileLocation[];
|
|
@@ -25,13 +25,6 @@ export interface Condition {
|
|
|
25
25
|
fn(): boolean;
|
|
26
26
|
resolve(): void;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* A class that acts as a marker for this special result type
|
|
30
|
-
*/
|
|
31
|
-
export declare class LocalActivityDoBackoff extends Error {
|
|
32
|
-
readonly backoff: coresdk.activity_result.IDoBackoff;
|
|
33
|
-
constructor(backoff: coresdk.activity_result.IDoBackoff);
|
|
34
|
-
}
|
|
35
28
|
export type ActivationHandlerFunction<K extends keyof coresdk.workflow_activation.IWorkflowActivationJob> = (activation: NonNullable<coresdk.workflow_activation.IWorkflowActivationJob[K]>) => void;
|
|
36
29
|
/**
|
|
37
30
|
* Verifies all activation job handling methods are implemented
|
|
@@ -60,6 +53,10 @@ export declare class Activator implements ActivationHandler {
|
|
|
60
53
|
signalWorkflow: Map<number, Completion>;
|
|
61
54
|
cancelWorkflow: Map<number, Completion>;
|
|
62
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Holds buffered Update calls until a handler is registered
|
|
58
|
+
*/
|
|
59
|
+
readonly bufferedUpdates: coresdk.workflow_activation.IDoUpdate[];
|
|
63
60
|
/**
|
|
64
61
|
* Holds buffered signal calls until a handler is registered
|
|
65
62
|
*/
|
|
@@ -72,6 +69,13 @@ export declare class Activator implements ActivationHandler {
|
|
|
72
69
|
* which delays query handler registration.
|
|
73
70
|
*/
|
|
74
71
|
protected readonly bufferedQueries: coresdk.workflow_activation.IQueryWorkflow[];
|
|
72
|
+
/**
|
|
73
|
+
* Mapping of update name to handler and validator
|
|
74
|
+
*/
|
|
75
|
+
readonly updateHandlers: Map<string, {
|
|
76
|
+
handler: WorkflowUpdateType;
|
|
77
|
+
validator?: WorkflowUpdateValidatorType | undefined;
|
|
78
|
+
}>;
|
|
75
79
|
/**
|
|
76
80
|
* Mapping of signal name to handler
|
|
77
81
|
*/
|
|
@@ -147,7 +151,7 @@ export declare class Activator implements ActivationHandler {
|
|
|
147
151
|
/**
|
|
148
152
|
* Information about the current Workflow
|
|
149
153
|
*/
|
|
150
|
-
|
|
154
|
+
info: WorkflowInfo;
|
|
151
155
|
/**
|
|
152
156
|
* A deterministic RNG, used by the isolate's overridden Math.random
|
|
153
157
|
*/
|
|
@@ -172,6 +176,7 @@ export declare class Activator implements ActivationHandler {
|
|
|
172
176
|
readonly getTimeOfDay: () => bigint;
|
|
173
177
|
readonly registeredActivityNames: Set<string>;
|
|
174
178
|
constructor({ info, now, showStackTraceSources, sourceMap, getTimeOfDay, randomnessSeed, patches, registeredActivityNames, }: WorkflowCreateOptionsInternal);
|
|
179
|
+
mutateWorkflowInfo(fn: (info: WorkflowInfo) => WorkflowInfo): void;
|
|
175
180
|
protected getStackTraces(): Stack[];
|
|
176
181
|
getAndResetSinkCalls(): SinkCall[];
|
|
177
182
|
/**
|
|
@@ -190,6 +195,11 @@ export declare class Activator implements ActivationHandler {
|
|
|
190
195
|
resolveChildWorkflowExecution(activation: coresdk.workflow_activation.IResolveChildWorkflowExecution): void;
|
|
191
196
|
protected queryWorkflowNextHandler({ queryName, args }: QueryInput): Promise<unknown>;
|
|
192
197
|
queryWorkflow(activation: coresdk.workflow_activation.IQueryWorkflow): void;
|
|
198
|
+
doUpdate(activation: coresdk.workflow_activation.IDoUpdate): void;
|
|
199
|
+
protected updateNextHandler({ name, args }: UpdateInput): Promise<unknown>;
|
|
200
|
+
protected validateUpdateNextHandler({ name, args }: UpdateInput): void;
|
|
201
|
+
dispatchBufferedUpdates(): void;
|
|
202
|
+
rejectBufferedUpdates(): void;
|
|
193
203
|
signalWorkflowNextHandler({ signalName, args }: SignalInput): Promise<void>;
|
|
194
204
|
signalWorkflow(activation: coresdk.workflow_activation.ISignalWorkflow): void;
|
|
195
205
|
dispatchBufferedSignals(): void;
|
|
@@ -205,6 +215,9 @@ export declare class Activator implements ActivationHandler {
|
|
|
205
215
|
handleWorkflowFailure(error: unknown): Promise<void>;
|
|
206
216
|
private completeQuery;
|
|
207
217
|
private failQuery;
|
|
218
|
+
private acceptUpdate;
|
|
219
|
+
private completeUpdate;
|
|
220
|
+
private rejectUpdate;
|
|
208
221
|
/** Consume a completion if it exists in Workflow state */
|
|
209
222
|
private maybeConsumeCompletion;
|
|
210
223
|
/** Consume a completion if it exists in Workflow state, throws if it doesn't */
|
|
@@ -213,5 +226,3 @@ export declare class Activator implements ActivationHandler {
|
|
|
213
226
|
errorToFailure(err: unknown): ProtoFailure;
|
|
214
227
|
failureToError(failure: ProtoFailure): Error;
|
|
215
228
|
}
|
|
216
|
-
export declare function maybeGetActivator(): Activator | undefined;
|
|
217
|
-
export declare function getActivator(): Activator;
|