Namespace: client
Client for communicating with Temporal Server.
Most functionality is available through WorkflowClient, but you can also call gRPC methods directly using Connection.workflowService and Connection.operatorService.
Usage
import { Connection, Client } from '@temporalio/client';
import { loadClientConnectConfig } from '@temporalio/envconfig';
import { sleepForDays } from './workflows';
import { nanoid } from 'nanoid';
async function run() {
const config = loadClientConnectConfig();
const connection = await Connection.connect(config.connectionOptions);
const client = new Client({ connection });
const handle = await client.workflow.start(sleepForDays, {
taskQueue: 'sleep-for-days',
workflowId: 'workflow-' + nanoid(),
});
console.log(`Started workflow ${handle.workflowId}`);
// Wait for workflow completion (runs indefinitely until it receives a signal)
console.log(await handle.result());
}
run().catch((err) => {
console.error(err);
process.exit(1);
});
Classes
- ActivityCancelledError
- ActivityClient
- ActivityCompletionError
- ActivityExecutionAlreadyStartedError
- ActivityExecutionFailedError
- ActivityNotFoundError
- ActivityPausedError
- ActivityResetError
- AsyncCompletionClient
- BuildIdNotFoundError
- Client
- Connection
- NexusClient
- NexusOperationAlreadyStartedError
- NexusOperationFailureError
- NexusOperationNotFoundError
- QueryNotRegisteredError
- QueryRejectedError
- ScheduleAlreadyRunning
- ScheduleClient
- ScheduleNotFoundError
- ServiceError
- TaskQueueClient
- WithStartWorkflowOperation
- WorkflowClient
- WorkflowContinuedAsNewError
- WorkflowFailedError
- WorkflowUpdateFailedError
- WorkflowUpdateRPCTimeoutOrCancelledError
Interfaces
- ActivityCancelInput
- ActivityClientInterceptor
- ActivityClientOptions
- ActivityCountInput
- ActivityDescribeInput
- ActivityExecutionDescription
- ActivityExecutionInfo
- ActivityGetResultInput
- ActivityHandle
- ActivityListInput
- ActivityOptions
- ActivityStartInput
- ActivityTerminateInput
- AddNewCompatibleVersion
- AddNewIdInNewDefaultSet
- AsyncCompletionOperationOptions
- AsyncWorkflowListIterable
- Backfill
- BackoffOptions
- BaseReachabilityOptions
- BuildIdReachability
- BuildIdVersionSet
- CalendarSpec
- CalendarSpecDescription
- CallContext
- CancelNexusOperationInput
- ClientInterceptors
- ClientOptions
- ClientPlugin
- CompiledWorkflowOptions
- ConnectionLike
- ConnectionOptions
- ConnectionPlugin
- CountActivityExecutions
- CountNexusOperationsInput
- CountWorkflowExecution
- CreateScheduleInput
- DescribeNexusOperationInput
- DescribeNexusOperationOptions
- FullActivityId
- GetNexusOperationHandleOptions
- GetNexusOperationResultInput
- GetWorkflowHandleOptions
- GetWorkflowUpdateHandleOptions
- GrpcRetryOptions
- IntervalSpec
- IntervalSpecDescription
- IntoHistoriesOptions
- ListNexusOperationsInput
- ListNexusOperationsOptions
- ListOptions
- ListScheduleOptions
- MergeSets
- NexusClientInterceptor
- NexusClientOptions
- NexusOperationExecution
- NexusOperationExecutionCancellationInfo
- NexusOperationExecutionCount
- NexusOperationExecutionCountGroup
- NexusOperationHandle
- NexusServiceClient
- PromoteBuildIdWithinSet
- PromoteSetByBuildId
- Range
- ReachabilityResponse
- ScheduleClientInterceptor
- ScheduleClientOptions
- ScheduleExecutionResult
- ScheduleExecutionStartWorkflowActionResult
- ScheduleHandle
- ScheduleOptions
- ScheduleSpec
- ScheduleSummary
- ScheduleSummaryStartWorkflowAction
- StartNexusOperationInput
- StartNexusOperationOptions
- TerminateNexusOperationInput
- TypedActivityClient
- WorkerBuildIdVersionSets
- WorkflowCancelInput
- WorkflowClientCallsInterceptorFactory
- WorkflowClientCallsInterceptorFactoryInput
- WorkflowClientInterceptor
- WorkflowClientInterceptors
- WorkflowClientOptions
- WorkflowDescribeInput
- WorkflowExecution
- WorkflowExecutionInfo
- WorkflowHandle
- WorkflowHandleWithFirstExecutionRunId
- WorkflowHandleWithSignaledRunId
- WorkflowHandleWithStartDetails
- WorkflowOptions
- WorkflowQueryInput
- WorkflowResultOptions
- WorkflowSignalInput
- WorkflowSignalWithStartInput
- WorkflowSignalWithStartOptionsWithArgs
- WorkflowSignalWithStartOptionsWithoutArgs
- WorkflowStartInput
- WorkflowStartOutput
- WorkflowStartUpdateInput
- WorkflowStartUpdateOutput
- WorkflowStartUpdateWithStartInput
- WorkflowStartUpdateWithStartOutput
- WorkflowTerminateInput
- WorkflowUpdateHandle
- WorkflowUpdateOptions
References
ActivityFailure
Re-exports ActivityFailure
ActivityFunction
Re-exports ActivityFunction
ActivityInterface
Re-exports ActivityInterface
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
DataConverter
Re-exports DataConverter
HandlerUnfinishedPolicy
Re-exports HandlerUnfinishedPolicy
Headers
Re-exports Headers
HistoryAndWorkflowId
Re-exports HistoryAndWorkflowId
IllegalStateError
Re-exports IllegalStateError
NamespaceNotFoundError
Re-exports NamespaceNotFoundError
Next
Re-exports Next
Payload
Re-exports Payload
PayloadConverterError
Re-exports PayloadConverterError
ProtoFailure
Re-exports ProtoFailure
QueryDefinition
Re-exports QueryDefinition
RetryPolicy
Re-exports RetryPolicy
ServerFailure
Re-exports ServerFailure
SignalDefinition
Re-exports SignalDefinition
TLSConfig
Re-exports TLSConfig
TemporalFailure
Re-exports TemporalFailure
TerminatedFailure
Re-exports TerminatedFailure
TimeoutFailure
Re-exports TimeoutFailure
UntypedActivities
Re-exports UntypedActivities
UpdateDefinition
Re-exports UpdateDefinition
ValueError
Re-exports ValueError
WithWorkflowArgs
Re-exports WithWorkflowArgs
Workflow
Re-exports Workflow
WorkflowDurationOptions
Re-exports WorkflowDurationOptions
WorkflowExecutionAlreadyStartedError
Re-exports WorkflowExecutionAlreadyStartedError
WorkflowIdConflictPolicy
Re-exports WorkflowIdConflictPolicy
WorkflowIdReusePolicy
Re-exports WorkflowIdReusePolicy
WorkflowNotFoundError
Re-exports WorkflowNotFoundError
WorkflowQueryAnnotatedType
Re-exports WorkflowQueryAnnotatedType
WorkflowQueryType
Re-exports WorkflowQueryType
WorkflowResultType
Re-exports WorkflowResultType
WorkflowReturnType
Re-exports WorkflowReturnType
WorkflowSignalAnnotatedType
Re-exports WorkflowSignalAnnotatedType
WorkflowSignalType
Re-exports WorkflowSignalType
WorkflowUpdateAnnotatedType
Re-exports WorkflowUpdateAnnotatedType
WorkflowUpdateType
Re-exports WorkflowUpdateType
WorkflowUpdateValidatorType
Re-exports WorkflowUpdateValidatorType
decodeWorkflowIdConflictPolicy
Re-exports decodeWorkflowIdConflictPolicy
decodeWorkflowIdReusePolicy
Re-exports decodeWorkflowIdReusePolicy
defaultPayloadConverter
Re-exports defaultPayloadConverter
encodeWorkflowIdConflictPolicy
Re-exports encodeWorkflowIdConflictPolicy
encodeWorkflowIdReusePolicy
Re-exports encodeWorkflowIdReusePolicy
extractWorkflowType
Re-exports extractWorkflowType
Type Aliases
ActivityArgs
Ƭ ActivityArgs<T, N>: T[N] extends ActivityFunction<infer P, any> ? P : never
Utility type to support strong typing in TypedActivityClient. Extracts argument types of an activity.
Type parameters
| Name | Type | Description |
|---|---|---|
T | T | Activity interface |
N | extends ActivityName<T> | Activity name Standalone Activities are experimental. APIs may be subject to change. |
ActivityExecutionStatus
Ƭ ActivityExecutionStatus: typeof ActivityExecutionStatus[keyof typeof ActivityExecutionStatus]
Standalone Activities are experimental. APIs may be subject to change.
ActivityIdConflictPolicy
Ƭ ActivityIdConflictPolicy: typeof ActivityIdConflictPolicy[keyof typeof ActivityIdConflictPolicy]
Standalone Activities are experimental. APIs may be subject to change.
ActivityIdReusePolicy
Ƭ ActivityIdReusePolicy: typeof ActivityIdReusePolicy[keyof typeof ActivityIdReusePolicy]
Standalone Activities are experimental. APIs may be subject to change.
ActivityName
Ƭ ActivityName<T>: { [N in keyof T & string]: T[N] extends ActivityFunction<any, any> ? N : never }[keyof T & string]
Utility type to support strong typing in TypedActivityClient. Contains names of activities extracted from the specified activity interface.
Type parameters
| Name | Description |
|---|---|
T | Activity interface Standalone Activities are experimental. APIs may be subject to change. |
ActivityOptionsFor
Ƭ ActivityOptionsFor<T, N>: ActivityOptionsWithArgs<ActivityArgs<T, N>>
Utility type to support strong typing in TypedActivityClient. Represents ActivityOptions with strongly typed arguments matching specified Activity in specified interface.
Type parameters
| Name | Type | Description |
|---|---|---|
T | T | Activity interface |
N | extends ActivityName<T> | Activity name Standalone Activities are experimental. APIs may be subject to change. |
ActivityOptionsWithArgs
Ƭ ActivityOptionsWithArgs<Args>: Args extends [any, ...any] ? Replace<ActivityOptions, { args: Args | Readonly<Args> }> : Replace<ActivityOptions, { args?: Args | Readonly<Args> }>
Utility type to support strong typing in TypedActivityClient. Represents ActivityOptions with strongly typed arguments.
Type parameters
| Name | Type | Description |
|---|---|---|
Args | extends any[] | Types of activity arguments as an array type. Standalone Activities are experimental. APIs may be subject to change. |
ActivityResult
Ƭ ActivityResult<T, N>: T[N] extends ActivityFunction<any, infer R> ? R : never
Utility type to support strong typing in TypedActivityClient. Extracts result type of an activity.
Type parameters
| Name | Type | Description |
|---|---|---|
T | T | Activity interface |
N | extends ActivityName<T> | Activity name Standalone Activities are experimental. APIs may be subject to change. |
AsyncCompletionClientOptions
Ƭ AsyncCompletionClientOptions: BaseClientOptions
Options used to configure AsyncCompletionClient
BuildIdOperation
Ƭ BuildIdOperation: AddNewIdInNewDefaultSet | AddNewCompatibleVersion | PromoteSetByBuildId | PromoteBuildIdWithinSet | MergeSets
Operations that can be passed to TaskQueueClient.updateBuildIdCompatibility.
Deprecated
Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
CompiledScheduleAction
Ƭ CompiledScheduleAction: Replace<ScheduleDescriptionAction, { args: unknown[] ; workflowType: string }>
CompiledScheduleOptions
Ƭ CompiledScheduleOptions: Replace<ScheduleOptions, { action: CompiledScheduleAction }>
CompiledScheduleUpdateOptions
Ƭ CompiledScheduleUpdateOptions: Replace<ScheduleUpdateOptions, { action: CompiledScheduleAction }>
ConnectionOptionsWithDefaults
Ƭ ConnectionOptionsWithDefaults: Required<Omit<ConnectionOptions, "tls" | "connectTimeout" | "callCredentials" | "apiKey">> & { connectTimeoutMs: number }
CreateScheduleOutput
Ƭ CreateScheduleOutput: Object
Type declaration
| Name | Type |
|---|---|
conflictToken | Uint8Array |
DayOfWeek
Ƭ DayOfWeek: typeof DAYS_OF_WEEK[number]
DescribeWorkflowExecutionResponse
Ƭ DescribeWorkflowExecutionResponse: IDescribeWorkflowExecutionResponse
GetWorkflowExecutionHistoryRequest
Ƭ GetWorkflowExecutionHistoryRequest: IGetWorkflowExecutionHistoryRequest
HealthService
Ƭ HealthService: Health
InternalConnectionLike
Ƭ InternalConnectionLike: ConnectionLike & { [InternalConnectionLikeSymbol]?: { supportsEagerStart?: boolean } }
LoadedAsyncCompletionClientOptions
Ƭ LoadedAsyncCompletionClientOptions: LoadedWithDefaults<AsyncCompletionClientOptions>
LoadedClientOptions
Ƭ LoadedClientOptions: LoadedWithDefaults<ClientOptions>
LoadedNexusClientOptions
Ƭ LoadedNexusClientOptions: LoadedWithDefaults<NexusClientOptions>
LoadedScheduleClientOptions
Ƭ LoadedScheduleClientOptions: LoadedWithDefaults<ScheduleClientOptions>
LoadedTaskQueueClientOptions
Ƭ LoadedTaskQueueClientOptions: LoadedWithDefaults<TaskQueueClientOptions>
Deprecated
Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
LoadedWorkflowClientOptions
Ƭ LoadedWorkflowClientOptions: LoadedWithDefaults<WorkflowClientOptions>
LooseRange
Ƭ LooseRange<Unit>: Range<Unit> | { end?: Range<Unit>["end"] ; start: Range<Unit>["start"] ; step?: never } | Unit
A Range definition, with support for loose syntax.
For example:
3 ➡️ 3
{ start: 2 } ➡️ 2
{ start: 2, end: 4 } ➡️ 2, 3, 4
{ start: 2, end: 10, step: 3 } ➡️ 2, 5, 8
Type parameters
| Name |
|---|
Unit |
Metadata
Ƭ Metadata: Record<string, grpc.MetadataValue>
Mapping of string to valid gRPC metadata value
Month
Ƭ Month: typeof MONTHS[number]
NexusOperationCancellationState
Ƭ NexusOperationCancellationState: typeof NexusOperationCancellationState[keyof typeof NexusOperationCancellationState]
NexusOperationExecutionDescription
Ƭ NexusOperationExecutionDescription: Replace<NexusOperationExecution, { raw: INexusOperationExecutionInfo }> & { attempt: number ; blockedReason: string | undefined ; cancellationInfo: NexusOperationExecutionCancellationInfo | undefined ; expirationTime: Date | undefined ; identity: string ; lastAttemptCompleteTime: Date | undefined ; lastAttemptFailure: Error | undefined ; nextAttemptScheduleTime: Date | undefined ; operationToken: string | undefined ; requestId: string ; scheduleToCloseTimeout: number | undefined ; scheduleToStartTimeout: number | undefined ; startToCloseTimeout: number | undefined ; state: PendingNexusOperationState | undefined ; staticDetails: () => Promise<string | undefined> ; staticSummary: () => Promise<string | undefined> }
Detailed information about a standalone Nexus operation execution.
NexusOperationExecutionStatus
Ƭ NexusOperationExecutionStatus: typeof NexusOperationExecutionStatus[keyof typeof NexusOperationExecutionStatus]
NexusOperationIdConflictPolicy
Ƭ NexusOperationIdConflictPolicy: typeof NexusOperationIdConflictPolicy[keyof typeof NexusOperationIdConflictPolicy]
NexusOperationIdReusePolicy
Ƭ NexusOperationIdReusePolicy: typeof NexusOperationIdReusePolicy[keyof typeof NexusOperationIdReusePolicy]
OperatorService
Ƭ OperatorService: OperatorService
PendingActivityState
Ƭ PendingActivityState: typeof PendingActivityState[keyof typeof PendingActivityState]
Standalone Activities are experimental. APIs may be subject to change.
PendingNexusOperationState
Ƭ PendingNexusOperationState: typeof PendingNexusOperationState[keyof typeof PendingNexusOperationState]
QueryRejectCondition
Ƭ QueryRejectCondition: typeof QueryRejectCondition[keyof typeof QueryRejectCondition]
RawActivityExecutionInfo
Ƭ RawActivityExecutionInfo: IActivityExecutionInfo
Standalone Activities are experimental. APIs may be subject to change.
RawActivityExecutionListInfo
Ƭ RawActivityExecutionListInfo: IActivityExecutionListInfo
Standalone Activities are experimental. APIs may be subject to change.
RawNexusOperationExecutionCancellationInfo
Ƭ RawNexusOperationExecutionCancellationInfo: INexusOperationExecutionCancellationInfo
RawNexusOperationExecutionInfo
Ƭ RawNexusOperationExecutionInfo: INexusOperationExecutionInfo
RawNexusOperationExecutionListInfo
Ƭ RawNexusOperationExecutionListInfo: INexusOperationExecutionListInfo
RawWorkflowExecutionInfo
Ƭ RawWorkflowExecutionInfo: IWorkflowExecutionInfo
ReachabilityOptions
Ƭ ReachabilityOptions: RequireAtLeastOne<BaseReachabilityOptions, "buildIds" | "taskQueues">
Options for TaskQueueClient.getReachability
Deprecated
Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
ReachabilityType
Ƭ ReachabilityType: typeof ReachabilityType[keyof typeof ReachabilityType]
ReachabilityTypeResponse
Ƭ ReachabilityTypeResponse: ReachabilityType | "NOT_FETCHED"
Deprecated
Worker Versioning is now deprecated. Please use the Worker Deployment API instead: https://docs.temporal.io/worker-deployments
RequestCancelWorkflowExecutionResponse
Ƭ RequestCancelWorkflowExecutionResponse: IRequestCancelWorkflowExecutionResponse
ScheduleDescription
Ƭ ScheduleDescription: Object
A detailed description of an exisiting Schedule, as returned by ScheduleHandle.describe.