Skip to main content

Namespace: common

Common library for both isolated Workflow and normal non-Workflow code

Classes#

Interfaces#

Type aliases#

ActivityInterface#

Ƭ ActivityInterface: Record<string, ActivityFunction<any[], any>>

Mapping of Activity name to function


CompiledWorkflowOptions#

Ƭ CompiledWorkflowOptions: BaseWorkflowOptions & RequiredWorkflowOptions & { workflowExecutionTimeout?: google.protobuf.IDuration ; workflowRunTimeout?: google.protobuf.IDuration ; workflowTaskTimeout?: google.protobuf.IDuration }


Headers#

Ƭ Headers: Record<string, IPayload>

Headers are just a mapping of header name to Payload


Next#

Ƭ Next<IF, FN>: Required<IF>[FN] extends AnyFunc ? OmitLastParam<Required<IF>[FN]> : never

Type of the next function for a given interceptor function

Called from an interceptor to continue the interception chain

Type parameters#

NameType
IFIF
FNextends keyof IF

ProtoFailure#

Ƭ ProtoFailure: temporal.api.failure.v1.IFailure


RequiredWorkflowOptions#

Ƭ RequiredWorkflowOptions: Required<Pick<BaseWorkflowOptions, "workflowId" | "taskQueue">>


RetryPolicy#

Ƭ RetryPolicy: IRetryPolicy


RetryState#

Ƭ RetryState: temporal.api.enums.v1.RetryState


TLSConfigOption#

Ƭ TLSConfigOption: TLSConfig | boolean | null

TLS configuration. Pass a falsy value to use a non-encrypted connection or true or {} to connect with TLS without any customization.


TimeoutType#

Ƭ TimeoutType: temporal.api.enums.v1.TimeoutType


Timestamp#

Ƭ Timestamp: iface.google.protobuf.ITimestamp


Workflow#

Ƭ Workflow: (...args: any[]) => WorkflowReturnType

Type declaration#

▸ (...args): WorkflowReturnType

Broad Workflow function definition, specific Workflows will typically use a narrower type definition, e.g:

export async function myWorkflow(arg1: number, arg2: string): Promise<string>;
Parameters#
NameType
...argsany[]
Returns#

WorkflowReturnType


WorkflowExecution#

Ƭ WorkflowExecution: temporal.api.common.v1.IWorkflowExecution


WorkflowIdReusePolicy#

Ƭ WorkflowIdReusePolicy: WorkflowIdReusePolicy


WorkflowOptions#

Ƭ WorkflowOptions: BaseWorkflowOptions & WorkflowDurationOptions


WorkflowOptionsWithDefaults#

Ƭ WorkflowOptionsWithDefaults: WorkflowOptions & RequiredWorkflowOptions


WorkflowQueryType#

Ƭ WorkflowQueryType: (...args: any[]) => any

Type declaration#

▸ (...args): any

Parameters#
NameType
...argsany[]
Returns#

any


WorkflowResultType#

Ƭ WorkflowResultType<W>: ReturnType<W> extends Promise<infer R> ? R : never

Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type W

Type parameters#

NameType
Wextends Workflow

WorkflowReturnType#

Ƭ WorkflowReturnType: Promise<any>

Type that can be returned from a Workflow execute function


WorkflowSignalType#

Ƭ WorkflowSignalType: (...args: any[]) => Promise<void> | void

Type declaration#

▸ (...args): Promise<void> | void

Parameters#
NameType
...argsany[]
Returns#

Promise<void> | void

Variables#

ActivityCancellationType#

Const ActivityCancellationType: typeof ActivityCancellationType


FAILURE_SOURCE#

Const FAILURE_SOURCE: "TypeScriptSDK"


RetryState#

RetryState: typeof RetryState


TimeoutType#

TimeoutType: typeof TimeoutType


WorkflowIdReusePolicy#

WorkflowIdReusePolicy: typeof WorkflowIdReusePolicy


defaultDataConverter#

Const defaultDataConverter: CompositeDataConverter

Functions#

arrayFromPayloads#

arrayFromPayloads(converter, content?): Promise<unknown[]>

Parameters#

NameType
converterDataConverter
content?Payload[] | null

Returns#

Promise<unknown[]>


arrayFromPayloadsSync#

arrayFromPayloadsSync(converter, content?): unknown[]

Parameters#

NameType
converterDataConverter
content?Payload[] | null

Returns#

unknown[]


compileWorkflowOptions#

compileWorkflowOptions(__namedParameters): CompiledWorkflowOptions

Parameters#

NameType
__namedParametersWorkflowOptionsWithDefaults

Returns#

CompiledWorkflowOptions


composeInterceptors#

composeInterceptors<I, M>(interceptors, method, next): Next<I, M>

Composes all interceptor methods into a single function

Type parameters#

NameType
II
Mextends string | number | symbol

Parameters#

NameTypeDescription
interceptorsI[]a list of interceptors
methodMthe name of the interceptor method to compose
nextNext<I, M>the original function to be executed at the end of the interception chain

Returns#

Next<I, M>


cutoffStackTrace#

cutoffStackTrace(stack?): string

Cuts out the framework part of a stack trace, leaving only user code entries

Parameters#

NameType
stack?string

Returns#

string


ensureTemporalFailure#

ensureTemporalFailure(err): TemporalFailure

If err is an Error it is turned into an ApplicationFailure.

If err was already a TemporalFailure, returns the original error.

Otherwise returns an ApplicationFailure with String(err) as the message.

Parameters#

NameType
errunknown

Returns#

TemporalFailure


errorMessage#

errorMessage(err): string | undefined

Get error message from an Error or string or return undefined

Parameters#

NameType
errunknown

Returns#

string | undefined


errorToFailure#

errorToFailure(err, dataConverter): Promise<ProtoFailure>

Converts a caught error to a Failure proto message

Parameters#

NameType
errunknown
dataConverterDataConverter

Returns#

Promise<ProtoFailure>


failureToError#

failureToError(failure, dataConverter): Promise<TemporalFailure>

Converts a Failure proto message to a JS Error object.

Parameters#

NameType
failureProtoFailure
dataConverterDataConverter

Returns#

Promise<TemporalFailure>


failureToErrorInner#

failureToErrorInner(failure, dataConverter): Promise<TemporalFailure>

Converts a Failure proto message to a JS Error object.

Does not set common properties, that is done in failureToError.

Parameters#

NameType
failureProtoFailure
dataConverterDataConverter

Returns#

Promise<TemporalFailure>


mapToPayloads#

mapToPayloads<K>(converter, source): Promise<Record<K, Payload>>

Type parameters#

NameType
Kextends string

Parameters#

NameType
converterDataConverter
sourceRecord<K, any>

Returns#

Promise<Record<K, Payload>>


mapToPayloadsSync#

mapToPayloadsSync<K>(converter, source): Record<K, Payload>

Type parameters#

NameType
Kextends string

Parameters#

NameType
converterDataConverter
sourceRecord<K, any>

Returns#

Record<K, Payload>


msNumberToTs#

msNumberToTs(millis): Timestamp

Parameters#

NameType
millisnumber

Returns#

Timestamp


msOptionalToTs#

msOptionalToTs(str): Timestamp | undefined

Parameters#

NameType
strstring | number | undefined

Returns#

Timestamp | undefined


msToNumber#

msToNumber(val): number

Parameters#

NameType
valstring | number

Returns#

number


msToTs#

msToTs(str): Timestamp

Parameters#

NameType
strstring | number

Returns#

Timestamp


normalizeTlsConfig#

normalizeTlsConfig(tls?): TLSConfig | undefined

Normalize TLSConfigOption by turning false and null to undefined and true to and empty object

Parameters#

NameType
tls?TLSConfigOption

Returns#

TLSConfig | undefined


optionalErrorToOptionalFailure#

optionalErrorToOptionalFailure(err, dataConverter): Promise<ProtoFailure | undefined>

Converts an error to a Failure proto message if defined or returns undefined

Parameters#

NameType
errunknown
dataConverterDataConverter

Returns#

Promise<ProtoFailure | undefined>


optionalFailureToOptionalError#

optionalFailureToOptionalError(failure, dataConverter): Promise<TemporalFailure | undefined>

Converts a Failure proto message to a JS Error object if defined or returns undefined.

Parameters#

NameType
failureProtoFailure | undefined | null
dataConverterDataConverter

Returns#

Promise<TemporalFailure | undefined>


optionalTsToMs#

optionalTsToMs(ts): number | undefined

Lossy conversion function from Timestamp to number due to possible overflow. If ts is null or undefined returns undefined.

Parameters#

NameType
tsTimestamp | null | undefined

Returns#

number | undefined


rootCause#

rootCause(err): string | undefined

Get the root cause (string) of given error err.

In case err is a TemporalFailure, recurse the cause chain and return the root's message. Otherwise, return err.message.

Parameters#

NameType
errunknown

Returns#

string | undefined


tsToMs#

tsToMs(ts): number

Lossy conversion function from Timestamp to number due to possible overflow

Parameters#

NameType
tsTimestamp | null | undefined

Returns#

number