@temporalio/workflow 0.21.0 → 1.0.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/README.md +2 -2
- package/lib/cancellation-scope.js +6 -2
- package/lib/cancellation-scope.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +18 -18
- package/lib/interfaces.d.ts +77 -10
- package/lib/interfaces.js.map +1 -1
- package/lib/internals.d.ts +18 -3
- package/lib/internals.js +49 -14
- package/lib/internals.js.map +1 -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 +5 -4
- package/lib/trigger.js +10 -7
- package/lib/trigger.js.map +1 -1
- package/lib/worker-interface.d.ts +6 -3
- package/lib/worker-interface.js +21 -24
- package/lib/worker-interface.js.map +1 -1
- package/lib/workflow-handle.d.ts +5 -2
- package/lib/workflow.d.ts +70 -11
- package/lib/workflow.js +184 -76
- package/lib/workflow.js.map +1 -1
- package/package.json +5 -4
package/lib/trigger.js
CHANGED
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Trigger = void 0;
|
|
4
4
|
const cancellation_scope_1 = require("./cancellation-scope");
|
|
5
|
+
const stack_helpers_1 = require("./stack-helpers");
|
|
5
6
|
/**
|
|
6
7
|
* A `PromiseLike` helper which exposes its `resolve` and `reject` methods.
|
|
7
8
|
*
|
|
8
|
-
* Trigger is CancellationScope
|
|
9
|
+
* Trigger is CancellationScope-aware: it is linked to the current scope on
|
|
9
10
|
* construction and throws when that scope is cancelled.
|
|
10
11
|
*
|
|
11
|
-
* Useful for e.g. waiting for unblocking a Workflow from a
|
|
12
|
+
* Useful for e.g. waiting for unblocking a Workflow from a Signal.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
|
-
* <!--SNIPSTART typescript-
|
|
15
|
+
* <!--SNIPSTART typescript-trigger-workflow-->
|
|
15
16
|
* <!--SNIPEND-->
|
|
16
17
|
*/
|
|
17
18
|
class Trigger {
|
|
18
19
|
constructor() {
|
|
19
|
-
|
|
20
|
+
this.promise = new Promise((resolve, reject) => {
|
|
20
21
|
const scope = cancellation_scope_1.CancellationScope.current();
|
|
21
22
|
if (scope.consideredCancelled || scope.cancellable) {
|
|
22
|
-
scope.cancelRequested.catch(reject);
|
|
23
|
+
(0, stack_helpers_1.untrackPromise)(scope.cancelRequested.catch(reject));
|
|
23
24
|
}
|
|
24
25
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
25
26
|
// @ts-ignore
|
|
@@ -29,8 +30,10 @@ class Trigger {
|
|
|
29
30
|
this.reject = reject;
|
|
30
31
|
});
|
|
31
32
|
// Avoid unhandled rejections
|
|
32
|
-
promise.catch(() => undefined);
|
|
33
|
-
|
|
33
|
+
(0, stack_helpers_1.untrackPromise)(this.promise.catch(() => undefined));
|
|
34
|
+
}
|
|
35
|
+
then(onfulfilled, onrejected) {
|
|
36
|
+
return this.promise.then(onfulfilled, onrejected);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
exports.Trigger = Trigger;
|
package/lib/trigger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.js","sourceRoot":"","sources":["../src/trigger.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;
|
|
1
|
+
{"version":3,"file":"trigger.js","sourceRoot":"","sources":["../src/trigger.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AACzD,mDAAiD;AAEjD;;;;;;;;;;;GAWG;AACH,MAAa,OAAO;IAUlB;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAChD,MAAM,KAAK,GAAG,sCAAiB,CAAC,OAAO,EAAE,CAAC;YAC1C,IAAI,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,WAAW,EAAE;gBAClD,IAAA,8BAAc,EAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;aACrD;YACD,6DAA6D;YAC7D,aAAa;YACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,6DAA6D;YAC7D,aAAa;YACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,6BAA6B;QAC7B,IAAA,8BAAc,EAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CACF,WAAiF,EACjF,UAAmF;QAEnF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;CACF;AAjCD,0BAiCC"}
|
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { ProtoFailure } from '@temporalio/common';
|
|
7
|
-
import type { coresdk } from '@temporalio/proto
|
|
7
|
+
import type { coresdk } from '@temporalio/proto';
|
|
8
8
|
import { WorkflowInfo } from './interfaces';
|
|
9
9
|
import { InterceptorsImportFunc, WorkflowsImportFunc } from './internals';
|
|
10
10
|
import { SinkCall } from './sinks';
|
|
11
|
+
export { PromiseStackStore } from './internals';
|
|
11
12
|
export interface WorkflowCreateOptions {
|
|
12
13
|
info: WorkflowInfo;
|
|
13
14
|
randomnessSeed: number[];
|
|
14
15
|
now: number;
|
|
15
16
|
patches: string[];
|
|
17
|
+
isReplaying: boolean;
|
|
18
|
+
historyLength: number;
|
|
16
19
|
}
|
|
17
20
|
export interface ImportFunctions {
|
|
18
21
|
importWorkflows: WorkflowsImportFunc;
|
|
@@ -25,12 +28,12 @@ export declare function overrideGlobals(): void;
|
|
|
25
28
|
*
|
|
26
29
|
* Sets required internal state and instantiates the workflow and interceptors.
|
|
27
30
|
*/
|
|
28
|
-
export declare function initRuntime({ info, randomnessSeed, now, patches }: WorkflowCreateOptions): Promise<void>;
|
|
31
|
+
export declare function initRuntime({ info, randomnessSeed, now, patches, isReplaying, historyLength, }: WorkflowCreateOptions): Promise<void>;
|
|
29
32
|
/**
|
|
30
33
|
* Run a chunk of activation jobs
|
|
31
34
|
* @returns a boolean indicating whether job was processed or ignored
|
|
32
35
|
*/
|
|
33
|
-
export declare function activate(activation: coresdk.workflow_activation.WorkflowActivation, batchIndex: number):
|
|
36
|
+
export declare function activate(activation: coresdk.workflow_activation.WorkflowActivation, batchIndex: number): void;
|
|
34
37
|
/**
|
|
35
38
|
* Conclude a single activation.
|
|
36
39
|
* Should be called after processing all activation jobs and queued microtasks.
|
package/lib/worker-interface.js
CHANGED
|
@@ -100,19 +100,21 @@ exports.overrideGlobals = overrideGlobals;
|
|
|
100
100
|
*
|
|
101
101
|
* Sets required internal state and instantiates the workflow and interceptors.
|
|
102
102
|
*/
|
|
103
|
-
async function initRuntime({ info, randomnessSeed, now, patches }) {
|
|
103
|
+
async function initRuntime({ info, randomnessSeed, now, patches, isReplaying, historyLength, }) {
|
|
104
|
+
const global = globalThis;
|
|
104
105
|
// Set the runId globally on the context so it can be retrieved in the case
|
|
105
106
|
// of an unhandled promise rejection.
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
global.__TEMPORAL__.runId = info.runId;
|
|
108
|
+
// Set the promiseStackStore so promises can be tracked
|
|
109
|
+
global.__TEMPORAL__.promiseStackStore = {
|
|
110
|
+
promiseToStack: new Map(),
|
|
111
|
+
childToParent: new Map(),
|
|
111
112
|
};
|
|
112
113
|
internals_1.state.info = info;
|
|
113
114
|
internals_1.state.now = now;
|
|
114
115
|
internals_1.state.random = (0, alea_1.alea)(randomnessSeed);
|
|
115
|
-
|
|
116
|
+
internals_1.state.historyLength = historyLength;
|
|
117
|
+
if (isReplaying) {
|
|
116
118
|
for (const patch of patches) {
|
|
117
119
|
internals_1.state.knownPresentPatches.add(patch);
|
|
118
120
|
}
|
|
@@ -142,19 +144,10 @@ async function initRuntime({ info, randomnessSeed, now, patches }) {
|
|
|
142
144
|
internals_1.state.interceptors.internals.push(...(interceptors.internals ?? []));
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (typeof workflow !== 'function') {
|
|
150
|
-
throw new TypeError(`'${info.workflowType}' is not a function`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
const failure = common_1.ApplicationFailure.nonRetryable((0, internal_workflow_common_1.errorMessage)(err), 'ReferenceError');
|
|
155
|
-
failure.stack = failure.stack?.split('\n')[0];
|
|
156
|
-
(0, internals_1.handleWorkflowFailure)(failure);
|
|
157
|
-
return;
|
|
147
|
+
const mod = await importWorkflows();
|
|
148
|
+
const workflow = mod[info.workflowType];
|
|
149
|
+
if (typeof workflow !== 'function') {
|
|
150
|
+
throw new TypeError(`'${info.workflowType}' is not a function`);
|
|
158
151
|
}
|
|
159
152
|
internals_1.state.workflow = workflow;
|
|
160
153
|
}
|
|
@@ -163,8 +156,8 @@ exports.initRuntime = initRuntime;
|
|
|
163
156
|
* Run a chunk of activation jobs
|
|
164
157
|
* @returns a boolean indicating whether job was processed or ignored
|
|
165
158
|
*/
|
|
166
|
-
|
|
167
|
-
const intercept = (0, internal_workflow_common_1.composeInterceptors)(internals_1.state.interceptors.internals, 'activate',
|
|
159
|
+
function activate(activation, batchIndex) {
|
|
160
|
+
const intercept = (0, internal_workflow_common_1.composeInterceptors)(internals_1.state.interceptors.internals, 'activate', ({ activation, batchIndex }) => {
|
|
168
161
|
if (batchIndex === 0) {
|
|
169
162
|
if (internals_1.state.info === undefined) {
|
|
170
163
|
throw new internal_workflow_common_1.IllegalStateError('Workflow has not been initialized');
|
|
@@ -176,7 +169,11 @@ async function activate(activation, batchIndex) {
|
|
|
176
169
|
// timestamp will not be updated for activation that contain only queries
|
|
177
170
|
internals_1.state.now = (0, internal_workflow_common_1.tsToMs)(activation.timestamp);
|
|
178
171
|
}
|
|
179
|
-
|
|
172
|
+
if (activation.historyLength == null) {
|
|
173
|
+
throw new TypeError('Got activation with no historyLength');
|
|
174
|
+
}
|
|
175
|
+
internals_1.state.isReplaying = activation.isReplaying ?? false;
|
|
176
|
+
internals_1.state.historyLength = activation.historyLength;
|
|
180
177
|
}
|
|
181
178
|
// Cast from the interface to the class which has the `variant` attribute.
|
|
182
179
|
// This is safe because we know that activation is a proto class.
|
|
@@ -199,7 +196,7 @@ async function activate(activation, batchIndex) {
|
|
|
199
196
|
tryUnblockConditions();
|
|
200
197
|
}
|
|
201
198
|
});
|
|
202
|
-
|
|
199
|
+
intercept({
|
|
203
200
|
activation,
|
|
204
201
|
batchIndex,
|
|
205
202
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-interface.js","sourceRoot":"","sources":["../src/worker-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,+
|
|
1
|
+
{"version":3,"file":"worker-interface.js","sourceRoot":"","sources":["../src/worker-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,+CAAqF;AACrF,mFAA8G;AAE9G,iCAA8B;AAC9B,6DAA+C;AAC/C,qCAAqD;AAGrD,2CAAiF;AAmBjF,SAAgB,cAAc,CAAC,EAAE,eAAe,EAAE,kBAAkB,EAAmB;IACrF,iBAAK,CAAC,eAAe,GAAG,eAAe,CAAC;IACxC,iBAAK,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAChD,CAAC;AAHD,wCAGC;AAED,SAAgB,eAAe;IAC7B,MAAM,MAAM,GAAG,UAAiB,CAAC;IACjC,0GAA0G;IAC1G,uEAAuE;IACvE,+EAA+E;IAC/E,MAAM,CAAC,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,EAAE,EAAE,QAAQ,EAAE;KACzB,CAAC;AACJ,CAAC;AATD,gDASC;AAED,SAAgB,oBAAoB;IAClC,OAAO,iBAAK,CAAC,oBAAoB,EAAE,CAAC;AACtC,CAAC;AAFD,oDAEC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB;IAClC,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,SAAS;QACP,MAAM,aAAa,GAAG,YAAY,CAAC;QACnC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,iBAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,EAAE;YAC3D,IAAI,IAAI,CAAC,EAAE,EAAE,EAAE;gBACb,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,YAAY,EAAE,CAAC;gBACf,qDAAqD;gBACrD,iBAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aACrC;SACF;QACD,IAAI,aAAa,KAAK,YAAY,EAAE;YAClC,MAAM;SACP;KACF;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAjBD,oDAiBC;AAEM,KAAK,UAAU,OAAO;IAC3B,MAAM,OAAO,GAAG,IAAA,8CAAmB,EAAC,iBAAK,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE;QACtF,4BAAO,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC;AALD,0BAKC;AAED,SAAgB,cAAc,CAAC,GAAY;IACzC,OAAO,IAAA,uBAAe,EAAC,GAAG,EAAE,iBAAK,CAAC,gBAAgB,CAAC,CAAC;AACtD,CAAC;AAFD,wCAEC"}
|
package/lib/workflow-handle.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BaseWorkflowHandle, SignalDefinition, Workflow } from '@temporalio/internal-workflow-common';
|
|
2
2
|
/**
|
|
3
|
-
* Handle representing an external Workflow
|
|
3
|
+
* Handle representing an external Workflow Execution.
|
|
4
|
+
*
|
|
5
|
+
* This handle only has methods `cancel` and `signal`. To call other methods, like `query` and `result`, use
|
|
6
|
+
* {@link WorkflowClient.getHandle} inside an Activity.
|
|
4
7
|
*/
|
|
5
8
|
export interface ExternalWorkflowHandle {
|
|
6
9
|
/**
|
|
@@ -51,5 +54,5 @@ export interface ChildWorkflowHandle<T extends Workflow> extends BaseWorkflowHan
|
|
|
51
54
|
/**
|
|
52
55
|
* The runId of the initial run of the bound Workflow
|
|
53
56
|
*/
|
|
54
|
-
readonly
|
|
57
|
+
readonly firstExecutionRunId: string;
|
|
55
58
|
}
|
package/lib/workflow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActivityFunction, ActivityInterface, ActivityOptions, LocalActivityOptions, QueryDefinition, SignalDefinition, WithWorkflowArgs, Workflow, WorkflowResultType, WorkflowReturnType } from '@temporalio/internal-workflow-common';
|
|
1
|
+
import { ActivityFunction, ActivityInterface, ActivityOptions, LocalActivityOptions, QueryDefinition, SearchAttributes, SignalDefinition, WithWorkflowArgs, Workflow, WorkflowResultType, WorkflowReturnType } from '@temporalio/internal-workflow-common';
|
|
2
2
|
import { ChildWorkflowOptions, ChildWorkflowOptionsWithDefaults, ContinueAsNewOptions, WorkflowInfo } from './interfaces';
|
|
3
3
|
import { Sinks } from './sinks';
|
|
4
4
|
import { ChildWorkflowHandle, ExternalWorkflowHandle } from './workflow-handle';
|
|
@@ -11,8 +11,8 @@ export declare function addDefaultWorkflowOptions<T extends Workflow>(opts: With
|
|
|
11
11
|
*
|
|
12
12
|
* Schedules a timer on the Temporal service.
|
|
13
13
|
*
|
|
14
|
-
* @param ms sleep duration - {@link https://www.npmjs.com/package/ms | ms} formatted string or number of milliseconds.
|
|
15
|
-
*
|
|
14
|
+
* @param ms sleep duration - {@link https://www.npmjs.com/package/ms | ms} formatted string or number of milliseconds.
|
|
15
|
+
* If given a negative number or 0, value will be set to 1.
|
|
16
16
|
*/
|
|
17
17
|
export declare function sleep(ms: number | string): Promise<void>;
|
|
18
18
|
export interface ActivityInfo {
|
|
@@ -20,10 +20,6 @@ export interface ActivityInfo {
|
|
|
20
20
|
type: string;
|
|
21
21
|
}
|
|
22
22
|
export declare type InternalActivityFunction<P extends any[], R> = ActivityFunction<P, R> & ActivityInfo;
|
|
23
|
-
/**
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
26
|
-
export declare function validateActivityOptions(options: ActivityOptions): void;
|
|
27
23
|
/**
|
|
28
24
|
* Schedule an activity and run outbound interceptors
|
|
29
25
|
* @hidden
|
|
@@ -187,6 +183,10 @@ export declare function executeChild<T extends () => WorkflowReturnType>(workflo
|
|
|
187
183
|
* Get information about the current Workflow
|
|
188
184
|
*/
|
|
189
185
|
export declare function workflowInfo(): WorkflowInfo;
|
|
186
|
+
/**
|
|
187
|
+
* Returns whether or not code is executing in workflow context
|
|
188
|
+
*/
|
|
189
|
+
export declare function inWorkflowContext(): boolean;
|
|
190
190
|
/**
|
|
191
191
|
* Get a reference to Sinks for exporting data out of the Workflow.
|
|
192
192
|
*
|
|
@@ -257,7 +257,7 @@ export declare function uuid4(): string;
|
|
|
257
257
|
/**
|
|
258
258
|
* Patch or upgrade workflow code by checking or stating that this workflow has a certain patch.
|
|
259
259
|
*
|
|
260
|
-
* See [docs page](https://docs.temporal.io/
|
|
260
|
+
* See [docs page](https://docs.temporal.io/typescript/versioning) for info.
|
|
261
261
|
*
|
|
262
262
|
* If the workflow is replaying an existing history, then this function returns true if that
|
|
263
263
|
* history was produced by a worker which also had a `patched` call with the same `patchId`.
|
|
@@ -275,7 +275,7 @@ export declare function patched(patchId: string): boolean;
|
|
|
275
275
|
/**
|
|
276
276
|
* Indicate that a patch is being phased out.
|
|
277
277
|
*
|
|
278
|
-
* See [docs page](https://docs.temporal.io/
|
|
278
|
+
* See [docs page](https://docs.temporal.io/typescript/versioning) for info.
|
|
279
279
|
*
|
|
280
280
|
* Workflows with this call may be deployed alongside workflows with a {@link patched} call, but
|
|
281
281
|
* they must *not* be deployed while any workers still exist running old code without a
|
|
@@ -326,6 +326,65 @@ export declare type Handler<Ret, Args extends any[], T extends SignalDefinition<
|
|
|
326
326
|
* If this function is called multiple times for a given signal or query name the last handler will overwrite any previous calls.
|
|
327
327
|
*
|
|
328
328
|
* @param def a {@link SignalDefinition} or {@link QueryDefinition} as returned by {@link defineSignal} or {@link defineQuery} respectively.
|
|
329
|
-
* @param handler
|
|
329
|
+
* @param handler a compatible handler function for the given definition or `undefined` to unset the handler.
|
|
330
|
+
*/
|
|
331
|
+
export declare function setHandler<Ret, Args extends any[], T extends SignalDefinition<Args> | QueryDefinition<Ret, Args>>(def: T, handler: Handler<Ret, Args, T> | undefined): void;
|
|
332
|
+
/**
|
|
333
|
+
* Updates this Workflow's Search Attributes by merging the provided `searchAttributes` with the existing Search
|
|
334
|
+
* Attributes, `workflowInfo().searchAttributes`.
|
|
335
|
+
*
|
|
336
|
+
* For example, this Workflow code:
|
|
337
|
+
*
|
|
338
|
+
* ```ts
|
|
339
|
+
* upsertSearchAttributes({
|
|
340
|
+
* CustomIntField: [1, 2, 3],
|
|
341
|
+
* CustomBoolField: [true]
|
|
342
|
+
* });
|
|
343
|
+
* upsertSearchAttributes({
|
|
344
|
+
* CustomIntField: [42],
|
|
345
|
+
* CustomKeywordField: ['durable code', 'is great']
|
|
346
|
+
* });
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
* would result in the Workflow having these Search Attributes:
|
|
350
|
+
*
|
|
351
|
+
* ```ts
|
|
352
|
+
* {
|
|
353
|
+
* CustomIntField: [42],
|
|
354
|
+
* CustomBoolField: [true],
|
|
355
|
+
* CustomKeywordField: ['durable code', 'is great']
|
|
356
|
+
* }
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @param searchAttributes The Record to merge. Use a value of `[]` to clear a Search Attribute.
|
|
360
|
+
*/
|
|
361
|
+
export declare function upsertSearchAttributes(searchAttributes: SearchAttributes): void;
|
|
362
|
+
/**
|
|
363
|
+
* Unsafe information about the currently executing Workflow Task.
|
|
364
|
+
*
|
|
365
|
+
* Never rely on this information in Workflow logic as it will cause non-deterministic behavior.
|
|
366
|
+
*/
|
|
367
|
+
export interface UnsafeTaskInfo {
|
|
368
|
+
isReplaying: boolean;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Information about the currently executing Workflow Task.
|
|
372
|
+
*
|
|
373
|
+
* Meant for advanced usage.
|
|
374
|
+
*/
|
|
375
|
+
export interface TaskInfo {
|
|
376
|
+
/**
|
|
377
|
+
* Length of Workflow history up until the current Workflow Task.
|
|
378
|
+
*
|
|
379
|
+
* You may safely use this information to decide when to {@link continueAsNew}.
|
|
380
|
+
*/
|
|
381
|
+
historyLength: number;
|
|
382
|
+
unsafe: UnsafeTaskInfo;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Get information about the currently executing Workflow Task.
|
|
386
|
+
*
|
|
387
|
+
* See {@link TaskInfo}
|
|
330
388
|
*/
|
|
331
|
-
export declare function
|
|
389
|
+
export declare function taskInfo(): TaskInfo;
|
|
390
|
+
export declare const stackTraceQuery: QueryDefinition<string, []>;
|