Namespace: workflow
This library provides tools required for authoring workflows.
Usage
See the tutorial for writing your first workflow.
Timers
The recommended way of scheduling timers is by using the sleep function. 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.
import { sleep } from '@temporalio/workflow';
export async function sleeper(ms = 100): Promise<void> {
await sleep(ms);
console.log('slept');
}
Activities
To schedule Activities, use proxyActivities to obtain an Activity function and call.
import { proxyActivities } from '@temporalio/workflow';
import type * as activities from './activities';
const { sendEmail } = proxyActivities<typeof activities>({
startToCloseTimeout: '1 minute',
});
export async function sampleWorkflow(): Promise<string> {
await sendEmail("to@example.com","Hello, Temporal!");
}
Updates, Signals and Queries
Use setHandler to set handlers for Updates, Signals, and Queries.
Update and Signal handlers can be either async or non-async functions. Update handlers may return a value, but signal
handlers may not (return void or Promise<void>). You may use Activities, Timers, child Workflows, etc in Update
and Signal handlers, but this should be done cautiously: for example, note that if you await async operations such as
these in an Update or Signal handler, then you are responsible for ensuring that the workflow does not complete first.
Query handlers may not be async functions, and may not mutate any variables or use Activities, Timers, child Workflows, etc.
Implementation
export const incrementSignal = wf.defineSignal<[number]>('increment');
export const getValueQuery = wf.defineQuery<number>('getValue');
export const incrementAndGetValueUpdate = wf.defineUpdate<number, [number]>('incrementAndGetValue');
export async function counterWorkflow(initialValue: number): Promise<void> {
let count = initialValue;
wf.setHandler(incrementSignal, (arg: number) => {
count += arg;
});
wf.setHandler(getValueQuery, () => count);
wf.setHandler(incrementAndGetValueUpdate, (arg: number): number => {
count += arg;
return count;
});
await wf.condition(() => false);
}
More
Classes
- CancellationScope
- ContinueAsNew
- DeterminismViolationError
- LocalActivityDoBackoff
- Trigger
- WorkflowError
Interfaces
- ActivateInput
- ActivityInput
- CancellationScopeOptions
- ChildWorkflowHandle
- ChildWorkflowOptions
- ConcludeActivationInput
- ContinueAsNewInput
- ContinueAsNewOptions
- DisposeInput
- EnhancedStackTrace
- ExternalWorkflowHandle
- LocalActivityInput
- LoggerSinks
- NexusOperationHandle
- NexusServiceClient
- NexusServiceClientOptions
- ParentWorkflowInfo
- QueryInput
- RootWorkflowInfo
- SignalInput
- SignalWorkflowInput
- SinkCall
- StackTrace
- StackTraceFileLocation
- StackTraceFileSlice
- StackTraceSDKInfo
- StartChildWorkflowExecutionInput
- StartNexusOperationInput
- StartNexusOperationOptions
- StartNexusOperationOutput
- TimerInput
- TimerOptions
- UnsafeRandomSource
- UnsafeWorkflowInfo
- UpdateInput
- WorkflowExecuteInput
- WorkflowInboundCallsInterceptor
- WorkflowInfo
- WorkflowInterceptors
- WorkflowInternalsInterceptor
- WorkflowOutboundCallsInterceptor
- WorkflowRandomStream
References
ActivityCancellationType
Re-exports ActivityCancellationType
ActivityFailure
Re-exports ActivityFailure
ActivityFunction
Re-exports ActivityFunction
ActivityInterface
Re-exports ActivityInterface
ActivityOptions
Re-exports ActivityOptions
ApplicationFailure
Re-exports ApplicationFailure
BaseWorkflowHandle
Re-exports BaseWorkflowHandle
BaseWorkflowOptions
Re-exports BaseWorkflowOptions
CancelledFailure
Re-exports CancelledFailure
ChildWorkflowFailure
Re-exports ChildWorkflowFailure
CommonWorkflowOptions
Re-exports CommonWorkflowOptions
CompleteAsyncError
Re-exports CompleteAsyncError
ExternalStorageNotConfiguredError
Re-exports ExternalStorageNotConfiguredError
Headers
Re-exports Headers
IllegalStateError
Re-exports IllegalStateError
NamespaceNotFoundError
Re-exports NamespaceNotFoundError
Next
Re-exports Next
Payload
Re-exports Payload
PayloadConverter
Re-exports PayloadConverter
PayloadConverterError
Re-exports PayloadConverterError
QueryDefinition
Re-exports QueryDefinition
RetryPolicy
Re-exports RetryPolicy
SearchAttributeValue
Re-exports SearchAttributeValue
SearchAttributes
Re-exports SearchAttributes
ServerFailure
Re-exports ServerFailure
SignalDefinition
Re-exports SignalDefinition
TemporalFailure
Re-exports TemporalFailure
TerminatedFailure
Re-exports TerminatedFailure
TimeoutFailure
Re-exports TimeoutFailure
UntypedActivities
Re-exports UntypedActivities
ValueError
Re-exports ValueError
WithWorkflowArgs
Re-exports WithWorkflowArgs
Workflow
Re-exports Workflow
WorkflowDurationOptions
Re-exports WorkflowDurationOptions
WorkflowIdConflictPolicy
Re-exports WorkflowIdConflictPolicy
WorkflowIdReusePolicy
Re-exports WorkflowIdReusePolicy
WorkflowNotFoundError
Re-exports WorkflowNotFoundError
WorkflowQueryType
Re-exports WorkflowQueryType
WorkflowResultType
Re-exports WorkflowResultType
WorkflowReturnType
Re-exports WorkflowReturnType
WorkflowSignalType
Re-exports WorkflowSignalType
decodeWorkflowIdConflictPolicy
Re-exports decodeWorkflowIdConflictPolicy
decodeWorkflowIdReusePolicy
Re-exports decodeWorkflowIdReusePolicy
defaultPayloadConverter
Re-exports defaultPayloadConverter
encodeWorkflowIdConflictPolicy
Re-exports encodeWorkflowIdConflictPolicy
encodeWorkflowIdReusePolicy
Re-exports encodeWorkflowIdReusePolicy
extractWorkflowType
Re-exports extractWorkflowType
rootCause
Re-exports rootCause
Type Aliases
ActivityFunctionWithOptions
Ƭ ActivityFunctionWithOptions<T>: T & { executeWithOptions: (options: ActivityOptions, args: Parameters<T>) => Promise<Awaited<ReturnType<T>>> }
Type parameters
| Name | Type |
|---|---|
T | extends ActivityFunction |
ActivityInterfaceFor
Ƭ ActivityInterfaceFor<T>: { [K in keyof T]: T[K] extends ActivityFunction ? ActivityFunctionWithOptions<T[K]> : typeof NotAnActivityMethod }
Type helper that takes a type T and transforms attributes that are not ActivityFunction to
NotAnActivityMethod.
Example
Used by proxyActivities to get this compile-time error:
interface MyActivities {
valid(input: number): Promise<number>;
invalid(input: number): number;
}
const act = proxyActivities<MyActivities>({ startToCloseTimeout: '5m' });
await act.valid(true);
await act.invalid();
// ^ TS complains with:
// (property) invalidDefinition: typeof NotAnActivityMethod
// This expression is not callable.
// Type 'Symbol' has no call signatures.(2349)
Type parameters
| Name |
|---|
T |
ChildWorkflowCancellationType
Ƭ ChildWorkflowCancellationType: typeof ChildWorkflowCancellationType[keyof typeof ChildWorkflowCancellationType]
ConcludeActivationOutput
Ƭ ConcludeActivationOutput: ConcludeActivationInput
Output for WorkflowInternalsInterceptor.concludeActivation
ContinueAsNewInputOptions
Ƭ ContinueAsNewInputOptions: ContinueAsNewOptions & Required<Pick<ContinueAsNewOptions, "workflowType">>
Input for WorkflowOutboundCallsInterceptor.continueAsNew.
GetLogAttributesInput
Ƭ GetLogAttributesInput: Record<string, unknown>
Input for WorkflowOutboundCallsInterceptor.getLogAttributes.
GetMetricTagsInput
Ƭ GetMetricTagsInput: MetricTags
Input for WorkflowOutboundCallsInterceptor.getMetricTags.
LocalActivityFunctionWithOptions
Ƭ LocalActivityFunctionWithOptions<T>: T & { executeWithOptions: (options: LocalActivityOptions, args: Parameters<T>) => Promise<Awaited<ReturnType<T>>> }
Type parameters
| Name | Type |
|---|---|
T | extends ActivityFunction |
LocalActivityInterfaceFor
Ƭ LocalActivityInterfaceFor<T>: { [K in keyof T]: T[K] extends ActivityFunction ? LocalActivityFunctionWithOptions<T[K]> : typeof NotAnActivityMethod }
The local activity counterpart to ActivityInterfaceFor
Type parameters
| Name |
|---|
T |
NexusOperationCancellationType
Ƭ NexusOperationCancellationType: typeof NexusOperationCancellationType[keyof typeof NexusOperationCancellationType]
ParentClosePolicy
Ƭ ParentClosePolicy: typeof ParentClosePolicy[keyof typeof ParentClosePolicy]
Sink
Ƭ Sink: Record<string, SinkFunction>
A mapping of name to function, defines a single sink (e.g. logger)
SinkFunction
Ƭ SinkFunction: (...args: any[]) => void
Any function signature can be used for Sink functions as long as the return type is void.
When calling a Sink function, arguments are copied from the Workflow isolate to the Node.js environment using postMessage.
This constrains the argument types to primitives (excluding Symbols).
Type declaration
▸ (...args): void
Parameters
| Name | Type |
|---|---|
...args | any[] |
Returns
void
Sinks
Ƭ Sinks: Record<string, Sink>
Workflow Sink are a mapping of name to Sink
WorkflowInterceptorsFactory
Ƭ WorkflowInterceptorsFactory: () => WorkflowInterceptors
A function that instantiates WorkflowInterceptors.
Workflow interceptor modules should export an interceptors function of this type.
Example
export function interceptors(): WorkflowInterceptors {
return {
inbound: [], // Populate with list of inbound interceptor implementations
outbound: [], // Populate with list of outbound interceptor implementations
internals: [], // Populate with list of internals interceptor implementations
};
}
Type declaration
▸ (): WorkflowInterceptors
Returns
Variables
AsyncLocalStorage
• Const AsyncLocalStorage: <T>() => ALS<T>
Type declaration
• <T>(): ALS<T>
Type parameters
| Name |
|---|
T |
Returns
ALS<T>
ChildWorkflowCancellationType
• Const ChildWorkflowCancellationType: Object
Determines:
- whether cancellation requests should be propagated from the Parent Workflow to the Child, and
- whether and when should the Child's cancellation be reported back to the Parent Workflow
(i.e. at which moment should the executeChild's or ChildWorkflowHandle.result's
promise fail with a
ChildWorkflowFailure, withcauseset to aCancelledFailure).
Note that this setting only applies to cancellation originating from an external request for the
Parent Workflow itself, or from internal cancellation of the CancellationScope in which the
Child Workflow call was made. Eventual Cancellation of a Child Workflow on completion of the
Parent Workflow is controlled by the ParentClosePolicy setting.
Default
ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED
Type declaration
| Name | Type | Description |
|---|---|---|
ABANDON | "ABANDON" | Do not propagate cancellation requests to the Child, and immediately report cancellation to the caller. |
TRY_CANCEL | "TRY_CANCEL" | Propagate cancellation request from the Parent Workflow to the Child, yet immediately report cancellation to the caller, i.e. without waiting for the server to confirm the cancellation request. Note that this cancellation type provides no guarantee, from the Parent-side, that the cancellation request will actually be atomically added to the Child workflow's history. In particular, the Child may complete (either successfully or uncessfully) before the cancellation is delivered, resulting in a situation where the Parent workflow thinks its child was cancelled, but the child actually completed successfully. To guarantee that the Child will eventually be notified of the cancellation request, use WAIT_CANCELLATION_REQUESTED. |
WAIT_CANCELLATION_COMPLETED | "WAIT_CANCELLATION_COMPLETED" | Propagate cancellation request from the Parent Workflow to the Child, then wait for completion of the Child Workflow. The Child may respect cancellation, in which case the Parent's executeChild or ChildWorkflowHandle.result promise will fail with a ChildWorkflowFailure, with cause set to a CancelledFailure. On the other hand, the Child may ignore the cancellation request, in which case the corresponding promise will either resolve with a result (if Child completed successfully) or reject with a different cause (if Child completed uncessfully). Default ts |
WAIT_CANCELLATION_REQUESTED | "WAIT_CANCELLATION_REQUESTED" | Propagate cancellation request from the Parent Workflow to the Child, then wait for the server to confirm that the Child Workflow cancellation request was recorded in its history. This cancellation type guarantees that the Child will eventually be notified of the cancellation request (that is, unless the Child terminates inbetween due to unexpected causes). |
NexusOperationCancellationType
• Const NexusOperationCancellationType: Object
Determines:
- whether cancellation requests should be propagated from the Workflow to the Nexus Operation
- whether and when should the Operation's cancellation be reported back to the Workflow
(i.e. at which moment should the operation's result promise fail with a
NexusOperationFailure, withcauseset to aCancelledFailure).
Note that this setting only applies to cancellation originating from an external request for the
Workflow itself, or from internal cancellation of the CancellationScope in which the
Operation call was made.
Nexus support in Temporal SDK is experimental.
Type declaration
| Name | Type | Description |
|---|---|---|
ABANDON | "ABANDON" | Do not propagate cancellation requests to the Nexus Operation, and immediately report cancellation to the caller. |
TRY_CANCEL | "TRY_CANCEL" | Initiate a cancellation request for the Nexus operation and immediately report cancellation to the caller. Note that it doesn't guarantee that cancellation is delivered to the operation if calling workflow exits before the delivery is done. If you want to ensure that cancellation is delivered to the operation, use WAIT_CANCELLATION_REQUESTED. Propagate cancellation request from the Workflow to the Operation, yet immediately report cancellation to the caller, i.e. without waiting for the server to confirm the cancellation request. Note that this cancellation type provides no guarantee, from the Workflow-side, that the cancellation request will be delivered to the Operation Handler. In particular, either the Operation or the Workflow may complete (either successfully or uncessfully) before the cancellation request is delivered, resulting in a situation where the Operation completed successfully, but the Workflow thinks it was cancelled. To guarantee that the Operation will eventually be notified of the cancellation request, use WAIT_CANCELLATION_REQUESTED. |
WAIT_CANCELLATION_COMPLETED | "WAIT_CANCELLATION_COMPLETED" | Propagate cancellation request from the Workflow to the Operation, then wait for completion of the Operation. |
WAIT_CANCELLATION_REQUESTED | "WAIT_CANCELLATION_REQUESTED" | Propagate cancellation request from the Workflow to the Operation, then wait for the server to confirm that the Operation cancellation request was delivered to the Operation Handler. |
NotAnActivityMethod
• Const NotAnActivityMethod: unique symbol
Symbol used in the return type of proxy methods to mark that an attribute on the source type is not a method.
See
ParentClosePolicy
• Const ParentClosePolicy: Object
How a Child Workflow reacts to the Parent Workflow reaching a Closed state.
See
Type declaration
| Name | Type | Description |
|---|---|---|
ABANDON | "ABANDON" | When the Parent is Closed, nothing is done to the Child. |
PARENT_CLOSE_POLICY_ABANDON | "ABANDON" | When the Parent is Closed, nothing is done to the Child. Deprecated Use ParentClosePolicy.ABANDON instead. |
PARENT_CLOSE_POLICY_REQUEST_CANCEL | "REQUEST_CANCEL" | When the Parent is Closed, the Child is Cancelled. Deprecated Use ParentClosePolicy.REQUEST_CANCEL instead. |
PARENT_CLOSE_POLICY_TERMINATE | "TERMINATE" | When the Parent is Closed, the Child is Terminated. Deprecated Use ParentClosePolicy.TERMINATE instead. |
PARENT_CLOSE_POLICY_UNSPECIFIED | undefined | If a ParentClosePolicy is set to this, or is not set at all, the server default value will be used. Deprecated Either leave property undefined, or set an explicit policy instead. |
REQUEST_CANCEL | "REQUEST_CANCEL" | When the Parent is Closed, the Child is Cancelled. |
TERMINATE | "TERMINATE" | When the Parent is Closed, the Child is Terminated. Default ts |
enhancedStackTraceQuery
• Const enhancedStackTraceQuery: QueryDefinition<EnhancedStackTrace, [], string>
log
• Const log: WorkflowLogger
Default workflow logger.
This logger is replay-aware and will omit log messages on workflow replay. Messages emitted by this logger are funnelled through a sink that forwards them to the logger registered on Runtime.logger.
Attributes from the current Workflow Execution context are automatically included as metadata on every log
entries. An extra sdkComponent metadata attribute is also added, with value workflow; this can be used for
fine-grained filtering of log entries further downstream.
To customize log attributes, register a WorkflowOutboundCallsInterceptor that intercepts the
getLogAttributes() method.
Notice that since sinks are used to power this logger, any log attributes must be transferable via the postMessage API.
NOTE: Specifying a custom logger through defaultSink or by manually registering a sink named
defaultWorkerLogger has been deprecated. Please use Runtime.logger instead.
metricMeter
• Const metricMeter: MetricMeter
A MetricMeter that can be used to emit metrics from within a Workflow.
The Metric API is an experimental feature and may be subject to change.
stackTraceQuery
• Const stackTraceQuery: QueryDefinition<string, [], string>
workflowMetadataQuery
• Const workflowMetadataQuery: QueryDefinition<IWorkflowMetadata, [], string>
workflowRandom
• Const workflowRandom: WorkflowRandomStream
The default deterministic random stream for the current workflow execution.
This exposes the same underlying sequence used by workflow-level Math.random()
when no named override is active. It can be useful for plugin/interceptor code
that wants an explicit handle to the main workflow random stream, including from
inside a temporary named scope established by another WorkflowRandomStream.
This API may be removed or changed in the future.
Functions
addDefaultWorkflowOptions
▸ addDefaultWorkflowOptions<T>(opts): ChildWorkflowOptionsWithDefaults
Adds default values of workflowId and cancellationType to given workflow options.
Type parameters
| Name | Type |
|---|---|
T | extends Workflow |
Parameters
| Name | Type |
|---|---|
opts | WithWorkflowArgs<T, ChildWorkflowOptions> |
Returns
ChildWorkflowOptionsWithDefaults
allHandlersFinished
▸ allHandlersFinished(): boolean
Whether update and signal handlers have finished executing.
Consider waiting on this condition before workflow return or continue-as-new, to prevent interruption of in-progress handlers by workflow exit:
await workflow.condition(workflow.allHandlersFinished)
Returns
boolean
true if there are no in-progress update or signal handler executions.
condition
▸ condition(fn, timeout, options): Promise<boolean>
Returns a Promise that resolves when fn evaluates to true or timeout expires, providing
options to configure the timer (i.e. provide metadata)
Parameters
| Name | Type | Description |
|---|---|---|
fn | () => boolean | - |
timeout | Duration | number of milliseconds or ms-formatted string |
options | TimerOptions | - |
Returns
Promise<boolean>
a boolean indicating whether the condition was true before the timeout expires
TimerOptions is a new addition and subject to change
▸ condition(fn, timeout): Promise<boolean>
Returns a Promise that resolves when fn evaluates to true or timeout expires.
Parameters
| Name | Type | Description |
|---|---|---|
fn | () => boolean | - |
timeout | Duration | number of milliseconds or ms-formatted string |
Returns
Promise<boolean>
a boolean indicating whether the condition was true before the timeout expires
▸ condition(fn): Promise<void>
Returns a Promise that resolves when fn evaluates to true.
Parameters
| Name | Type |
|---|---|
fn | () => boolean |
Returns
Promise<void>
continueAsNew
▸ continueAsNew<F>(...args): Promise<never>
Continues-As-New the current Workflow Execution with default options.
Shorthand for makeContinueAsNewFunc<F>()(...args). (See: makeContinueAsNewFunc.)
Type parameters
| Name | Type |
|---|---|
F | extends Workflow |
Parameters
| Name | Type |
|---|---|
...args | Parameters<F> |
Returns
Promise<never>
Example
import { continueAsNew } from '@temporalio/workflow';
import { SearchAttributeType } from '@temporalio/common';
export async function myWorkflow(n: number): Promise<void> {
// ... Workflow logic
await continueAsNew<typeof myWorkflow>(n + 1);
}
createNexusServiceClient
▸ createNexusServiceClient<T>(options): NexusServiceClient<T>
Create a Nexus client for invoking Nexus Operations from a Workflow.
Nexus support in Temporal SDK is experimental.
Type parameters
| Name | Type |
|---|---|
T | extends ServiceDefinition<OperationMap> |
Parameters
| Name | Type |
|---|---|
options | NexusServiceClientOptions<T> |
Returns
currentUpdateInfo
▸ currentUpdateInfo(): UpdateInfo | undefined
Get information about the current update if any.
Returns
UpdateInfo | undefined
Info for the current update handler the code calling this is executing within if any.
defineQuery
▸ defineQuery<Ret, Args, Name>(name): QueryDefinition<Ret, Args, Name>
Define a query method for a Workflow.
A definition is used to register a handler in the Workflow via setHandler and to query a Workflow using a WorkflowHandle. A definition can be reused in multiple Workflows.
Type parameters
| Name | Type |
|---|---|
Ret | Ret |
Args | extends any[] = [] |
Name | extends string = string |
Parameters
| Name | Type |
|---|---|
name | Name |
Returns
QueryDefinition<Ret, Args, Name>
defineSignal
▸ defineSignal<Args, Name>(name): SignalDefinition<Args, Name>
Define a signal method for a Workflow.
A definition is used to register a handler in the Workflow via setHandler and to signal a Workflow using a WorkflowHandle, ChildWorkflowHandle or ExternalWorkflowHandle. A definition can be reused in multiple Workflows.
Type parameters
| Name | Type |
|---|---|
Args | extends any[] = [] |
Name | extends string = string |
Parameters
| Name | Type |
|---|---|
name | Name |
Returns
SignalDefinition<Args, Name>
defineUpdate
▸ defineUpdate<Ret, Args, Name>(name): UpdateDefinition<Ret, Args, Name>
Define an update method for a Workflow.
A definition is used to register a handler in the Workflow via setHandler and to update a Workflow using a WorkflowHandle, ChildWorkflowHandle or ExternalWorkflowHandle. A definition can be reused in multiple Workflows.
Type parameters
| Name | Type |
|---|---|
Ret | Ret |
Args | extends any[] = [] |
Name | extends string = string |
Parameters
| Name | Type |
|---|---|
name | Name |
Returns
UpdateDefinition<Ret, Args, Name>
deprecatePatch
▸ deprecatePatch(patchId): void
Indicate that a patch is being phased out.
See docs page for info.
Workflows with this call may be deployed alongside workflows with a patched call, but they must not be deployed while any workers still exist running old code without a patched call, or any runs with histories produced by such workers exist. If either kind of worker encounters a history produced by the other, their behavior is undefined.
Once all live workflow runs have been produced by workers with this call, you can deploy workers which are free of either kind of patch call for this ID. Workers with and without this call may coexist, as long as they are both running the "new" code.
Parameters
| Name | Type | Description |
|---|---|---|
patchId | string | An identifier that should be unique to this patch. It is OK to use multiple calls with the same ID, which means all such calls will always return the same value. |
Returns
void
executeChild
▸ executeChild<T>(workflowType, options): Promise<WorkflowResultType<T>>
Start a child Workflow execution and await its completion.
- By default, a child will be scheduled on the same task queue as its parent.
- This operation is cancellable using CancellationScopes.
Type parameters
| Name | Type |
|---|---|
T | extends Workflow |
Parameters
| Name | Type |
|---|---|
workflowType | string |
options | WithWorkflowArgs<T, ChildWorkflowOptions> |
Returns
Promise<WorkflowResultType<T>>
The result of the child Workflow.
▸ executeChild<T>(workflowFunc, options): Promise<WorkflowResultType<T>>
Start a child Workflow execution and await its completion.
- By default, a child will be scheduled on the same task queue as its parent.
- Deduces the Workflow type and signature from provided Workflow function.
- This operation is cancellable using CancellationScopes.
Type parameters
| Name | Type |
|---|---|
T | extends Workflow |
Parameters
| Name | Type |
|---|---|
workflowFunc | T |
options | WithWorkflowArgs<T, ChildWorkflowOptions> |
Returns
Promise<WorkflowResultType<T>>
The result of the child Workflow.
▸ executeChild<T>(workflowType): Promise<WorkflowResultType<T>>
Start a child Workflow execution and await its completion.
Override for Workflows that accept no arguments.
- The child will be scheduled on the same task queue as its parent.
- This operation is cancellable using CancellationScopes.
Type parameters
| Name | Type |
|---|---|
T | extends () => WorkflowReturnType |
Parameters
| Name | Type |
|---|---|
workflowType | string |
Returns
Promise<WorkflowResultType<T>>
The result of the child Workflow.
▸ executeChild<T>(workflowFunc): Promise<WorkflowResultType<T>>
Start a child Workflow execution and await its completion.
Override for Workflows that accept no arguments.
- The child will be scheduled on the same task queue as its parent.
- Deduces the Workflow type and signature from provided Workflow function.
- This operation is cancellable using CancellationScopes.
Type parameters
| Name | Type |
|---|---|
T | extends () => WorkflowReturnType |
Parameters
| Name | Type |
|---|---|
workflowFunc | T |
Returns
Promise<WorkflowResultType<T>>
The result of the child Workflow.
getCurrentDetails
▸ getCurrentDetails(): string
Returns
string
getExternalWorkflowHandle
▸ getExternalWorkflowHandle(workflowId, runId?): ExternalWorkflowHandle
Returns a client-side handle that can be used to signal and cancel an existing Workflow execution. It takes a Workflow ID and optional run ID.
Parameters
| Name | Type |
|---|---|
workflowId | string |
runId? | string |
Returns
getRandomStream
▸ getRandomStream(name): WorkflowRandomStream
Get a named deterministic random stream for the current workflow execution.
Named streams are derived from the workflow seed and a stable stream name,
without consuming the workflow's default Math.random() stream. Repeated
calls with the same name within a workflow execution refer to the same
logical stream state, including across activations.
This is the preferred entry point for workflow plugins and interceptors that
need their own deterministic entropy. Use stable package- or module-style
names so the stream identity remains replay-safe, then keep the returned
WorkflowRandomStream around and call its methods directly.
This API may be removed or changed in the future.
Parameters
| Name | Type |
|---|---|
name | string |