Socket
Socket
Sign inDemoInstall

@temporalio/client

Package Overview
Dependencies
Maintainers
7
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@temporalio/client - npm Package Compare versions

Comparing version 1.4.4 to 1.5.0

lib/base-client.d.ts

37

lib/async-completion-client.d.ts

@@ -1,4 +0,3 @@

import { DataConverter, LoadedDataConverter } from '@temporalio/common';
import { Replace } from '@temporalio/common/lib/type-helpers';
import { ConnectionLike, WorkflowService } from './types';
import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client';
import { WorkflowService } from './types';
/**

@@ -28,28 +27,4 @@ * Thrown by {@link AsyncCompletionClient} when trying to complete or heartbeat an Activity that does not exist in the

*/
export interface AsyncCompletionClientOptions {
/**
* {@link DataConverter} or {@link LoadedDataConverter} to use for serializing and deserializing payloads
*/
dataConverter?: DataConverter | LoadedDataConverter;
/**
* Identity to report to the server
*
* @default `${process.pid}@${os.hostname()}`
*/
identity?: string;
connection?: ConnectionLike;
/**
* Server namespace
*
* @default default
*/
namespace?: string;
}
export declare type AsyncCompletionClientOptionsWithDefaults = Replace<Required<AsyncCompletionClientOptions>, {
connection?: ConnectionLike;
}>;
export declare type LoadedAsyncCompletionClientOptions = AsyncCompletionClientOptionsWithDefaults & {
loadedDataConverter: LoadedDataConverter;
};
export declare function defaultAsyncCompletionClientOptions(): AsyncCompletionClientOptionsWithDefaults;
export declare type AsyncCompletionClientOptions = BaseClientOptions;
export declare type LoadedAsyncCompletionClientOptions = LoadedWithDefaults<AsyncCompletionClientOptions>;
/**

@@ -73,5 +48,4 @@ * A mostly unique Activity identifier including its scheduling workflow's ID

*/
export declare class AsyncCompletionClient {
export declare class AsyncCompletionClient extends BaseClient {
readonly options: LoadedAsyncCompletionClientOptions;
readonly connection: ConnectionLike;
constructor(options?: AsyncCompletionClientOptions);

@@ -85,3 +59,2 @@ /**

get workflowService(): WorkflowService;
protected get dataConverter(): LoadedDataConverter;
/**

@@ -88,0 +61,0 @@ * Transforms grpc errors into well defined TS errors.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncCompletionClient = exports.defaultAsyncCompletionClientOptions = exports.ActivityCancelledError = exports.ActivityCompletionError = exports.ActivityNotFoundError = void 0;
exports.AsyncCompletionClient = exports.ActivityCancelledError = exports.ActivityCompletionError = exports.ActivityNotFoundError = void 0;
const constants_1 = require("@grpc/grpc-js/build/src/constants");
const common_1 = require("@temporalio/common");
const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
const os_1 = __importDefault(require("os"));
const connection_1 = require("./connection");
const base_client_1 = require("./base-client");
const errors_1 = require("./errors");

@@ -47,9 +43,4 @@ /**

function defaultAsyncCompletionClientOptions() {
return {
dataConverter: {},
identity: `${process.pid}@${os_1.default.hostname()}`,
namespace: 'default',
};
return (0, base_client_1.defaultBaseClientOptions)();
}
exports.defaultAsyncCompletionClientOptions = defaultAsyncCompletionClientOptions;
/**

@@ -61,11 +52,9 @@ * A client for asynchronous completion and heartbeating of Activities.

*/
class AsyncCompletionClient {
class AsyncCompletionClient extends base_client_1.BaseClient {
constructor(options) {
this.connection = options?.connection ?? connection_1.Connection.lazy();
const dataConverter = options?.dataConverter;
const loadedDataConverter = (0, internal_non_workflow_1.isLoadedDataConverter)(dataConverter) ? dataConverter : (0, internal_non_workflow_1.loadDataConverter)(dataConverter);
super(options);
this.options = {
...defaultAsyncCompletionClientOptions(),
...(0, internal_non_workflow_1.filterNullAndUndefined)(options ?? {}),
loadedDataConverter,
loadedDataConverter: this.dataConverter,
};

@@ -82,5 +71,2 @@ }

}
get dataConverter() {
return this.options.loadedDataConverter;
}
/**

@@ -87,0 +73,0 @@ * Transforms grpc errors into well defined TS errors.

@@ -1,14 +0,10 @@

import { DataConverter, LoadedDataConverter } from '@temporalio/common';
import { Replace } from '@temporalio/common/lib/type-helpers';
import { temporal } from '@temporalio/proto';
import { AsyncCompletionClient } from './async-completion-client';
import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client';
import { ClientInterceptors } from './interceptors';
import { ConnectionLike, Metadata, WorkflowService } from './types';
import { ScheduleClient } from './schedule-client';
import { WorkflowService } from './types';
import { WorkflowClient } from './workflow-client';
export interface ClientOptions {
export interface ClientOptions extends BaseClientOptions {
/**
* {@link DataConverter} to use for serializing and deserializing payloads
*/
dataConverter?: DataConverter;
/**
* Used to override and extend default Connection functionality

@@ -19,22 +15,2 @@ *

interceptors?: ClientInterceptors;
/**
* Identity to report to the server
*
* @default `${process.pid}@${os.hostname()}`
*/
identity?: string;
/**
* Connection to use to communicate with the server.
*
* By default `WorkflowClient` connects to localhost.
*
* Connections are expensive to construct and should be reused.
*/
connection?: ConnectionLike;
/**
* Server namespace
*
* @default default
*/
namespace?: string;
workflow?: {

@@ -49,17 +25,7 @@ /**

}
export declare type ClientOptionsWithDefaults = Replace<Required<ClientOptions>, {
connection?: ConnectionLike;
}>;
export declare type LoadedClientOptions = ClientOptionsWithDefaults & {
loadedDataConverter: LoadedDataConverter;
};
export declare function defaultClientOptions(): ClientOptionsWithDefaults;
export declare type LoadedClientOptions = LoadedWithDefaults<ClientOptions>;
/**
* High level SDK client.
*/
export declare class Client {
/**
* Underlying gRPC connection to the Temporal service
*/
readonly connection: ConnectionLike;
export declare class Client extends BaseClient {
readonly options: LoadedClientOptions;

@@ -74,2 +40,8 @@ /**

readonly activity: AsyncCompletionClient;
/**
* Schedule sub-client - use to start and interact with Schedules
*
* @experimental
*/
readonly schedule: ScheduleClient;
constructor(options?: ClientOptions);

@@ -83,14 +55,2 @@ /**

get workflowService(): WorkflowService;
/**
* Set the deadline for any service requests executed in `fn`'s scope.
*/
withDeadline<R>(deadline: number | Date, fn: () => Promise<R>): Promise<R>;
/**
* Set metadata for any service requests executed in `fn`'s scope.
*
* @returns returned value of `fn`
*
* @see {@link Connection.withMetadata}
*/
withMetadata<R>(metadata: Metadata, fn: () => Promise<R>): Promise<R>;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Client = exports.defaultClientOptions = void 0;
exports.Client = void 0;
const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
const proto_1 = require("@temporalio/proto");
const os_1 = __importDefault(require("os"));
const async_completion_client_1 = require("./async-completion-client");
const connection_1 = require("./connection");
const base_client_1 = require("./base-client");
const schedule_client_1 = require("./schedule-client");
const workflow_client_1 = require("./workflow-client");
function defaultClientOptions() {
return {
dataConverter: {},
identity: `${process.pid}@${os_1.default.hostname()}`,
interceptors: {},
namespace: 'default',
workflow: {
queryRejectCondition: proto_1.temporal.api.enums.v1.QueryRejectCondition.QUERY_REJECT_CONDITION_UNSPECIFIED,
},
};
}
exports.defaultClientOptions = defaultClientOptions;
/**
* High level SDK client.
*/
class Client {
class Client extends base_client_1.BaseClient {
constructor(options) {
this.connection = options?.connection ?? connection_1.Connection.lazy();
this.options = {
...defaultClientOptions(),
...(0, internal_non_workflow_1.filterNullAndUndefined)(options ?? {}),
loadedDataConverter: (0, internal_non_workflow_1.loadDataConverter)(options?.dataConverter),
};
const { workflow, loadedDataConverter, interceptors, ...base } = this.options;
super(options);
const { interceptors, workflow, ...commonOptions } = options ?? {};
this.workflow = new workflow_client_1.WorkflowClient({
...base,
...workflow,
...commonOptions,
...(workflow ?? {}),
connection: this.connection,
dataConverter: loadedDataConverter,
interceptors: interceptors.workflow,
dataConverter: this.dataConverter,
interceptors: interceptors?.workflow,
});
this.activity = new async_completion_client_1.AsyncCompletionClient({
...base,
...commonOptions,
connection: this.connection,
dataConverter: loadedDataConverter,
dataConverter: this.dataConverter,
});
this.schedule = new schedule_client_1.ScheduleClient({
...commonOptions,
connection: this.connection,
dataConverter: this.dataConverter,
interceptors: interceptors?.schedule,
});
this.options = {
...(0, base_client_1.defaultBaseClientOptions)(),
...(0, internal_non_workflow_1.filterNullAndUndefined)(commonOptions),
loadedDataConverter: this.dataConverter,
interceptors: {
workflow: this.workflow.options.interceptors,
schedule: this.schedule.options.interceptors,
},
workflow: {
queryRejectCondition: this.workflow.options.queryRejectCondition,
},
};
}

@@ -59,20 +56,4 @@ /**

}
/**
* Set the deadline for any service requests executed in `fn`'s scope.
*/
async withDeadline(deadline, fn) {
return await this.connection.withDeadline(deadline, fn);
}
/**
* Set metadata for any service requests executed in `fn`'s scope.
*
* @returns returned value of `fn`
*
* @see {@link Connection.withMetadata}
*/
async withMetadata(metadata, fn) {
return await this.connection.withMetadata(metadata, fn);
}
}
exports.Client = Client;
//# sourceMappingURL=client.js.map
/// <reference types="node" />
import { AsyncLocalStorage } from 'async_hooks';
import * as grpc from '@grpc/grpc-js';
import type { RPCImpl } from 'protobufjs';
import { TLSConfig } from '@temporalio/common/lib/internal-non-workflow';
import { AsyncLocalStorage } from 'async_hooks';
import type { RPCImpl } from 'protobufjs';
import { CallContext, HealthService, Metadata, OperatorService, WorkflowService } from './types';

@@ -49,10 +49,10 @@ /**

/**
* Grpc interceptors which will be applied to every RPC call performed by this connection. By default, an interceptor
* will be included which automatically retries retryable errors. If you do not wish to perform automatic retries, set
* this to an empty list (or a list with your own interceptors). If you want to add your own interceptors while
* keeping the default retry behavior, add this to your list of interceptors:
* `makeGrpcRetryInterceptor(defaultGrpcRetryOptions())`. See:
* {@link https://grpc.github.io/grpc/node/module-src_client_interceptors.html | gRPC interceptors} which will be
* applied to every RPC call performed by this connection. By default, an interceptor will be included which
* automatically retries retryable errors. If you do not wish to perform automatic retries, set this to an empty list
* (or a list with your own interceptors). If you want to add your own interceptors while keeping the default retry
* behavior, add this to your list of interceptors: `makeGrpcRetryInterceptor(defaultGrpcRetryOptions())`. See:
*
* - @link makeGrpcRetryInterceptor
* - @link defaultGrpcRetryOptions
* - {@link makeGrpcRetryInterceptor}
* - {@link defaultGrpcRetryOptions}
*/

@@ -59,0 +59,0 @@ interceptors?: grpc.Interceptor[];

@@ -30,5 +30,6 @@ "use strict";

exports.Connection = exports.LOCAL_TARGET = void 0;
const async_hooks_1 = require("async_hooks");
const grpc = __importStar(require("@grpc/grpc-js"));
const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
const async_hooks_1 = require("async_hooks");
const time_1 = require("@temporalio/common/lib/time");
const errors_1 = require("./errors");

@@ -40,3 +41,3 @@ const grpc_retry_1 = require("./grpc-retry");

function addDefaults(options) {
const { channelArgs, interceptors, ...rest } = options;
const { channelArgs, interceptors, connectTimeout, ...rest } = options;
return {

@@ -53,3 +54,3 @@ address: exports.LOCAL_TARGET,

metadata: {},
connectTimeoutMs: 10000,
connectTimeoutMs: (0, time_1.msOptionalToNumber)(connectTimeout) ?? 10000,
...(0, internal_non_workflow_1.filterNullAndUndefined)(rest),

@@ -56,0 +57,0 @@ };

import { ServerErrorResponse } from '@grpc/grpc-js';
import { RetryState, TemporalFailure } from '@temporalio/common';
export { WorkflowExecutionAlreadyStartedError } from '@temporalio/common';
/**

@@ -5,0 +4,0 @@ * Generic Error class for errors coming from the service

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isServerErrorResponse = exports.WorkflowContinuedAsNewError = exports.WorkflowFailedError = exports.ServiceError = exports.WorkflowExecutionAlreadyStartedError = void 0;
var common_1 = require("@temporalio/common");
Object.defineProperty(exports, "WorkflowExecutionAlreadyStartedError", { enumerable: true, get: function () { return common_1.WorkflowExecutionAlreadyStartedError; } });
exports.isServerErrorResponse = exports.WorkflowContinuedAsNewError = exports.WorkflowFailedError = exports.ServiceError = void 0;
/**

@@ -7,0 +5,0 @@ * Generic Error class for errors coming from the service

@@ -25,1 +25,3 @@ /**

export * from './workflow-options';
export * from './schedule-types';
export * from './schedule-client';

@@ -52,2 +52,4 @@ "use strict";

__exportStar(require("./workflow-options"), exports);
__exportStar(require("./schedule-types"), exports);
__exportStar(require("./schedule-client"), exports);
//# sourceMappingURL=index.js.map

@@ -8,6 +8,7 @@ /**

import { temporal } from '@temporalio/proto';
import { CompiledScheduleOptions } from './schedule-types';
import { DescribeWorkflowExecutionResponse, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution } from './types';
import { CompiledWorkflowOptions } from './workflow-options';
export { Next, Headers };
/** Input for WorkflowClientCallsInterceptor.start */
/** Input for WorkflowClientInterceptor.start */
export interface WorkflowStartInput {

@@ -19,3 +20,3 @@ /** Name of Workflow to start */

}
/** Input for WorkflowClientCallsInterceptor.signal */
/** Input for WorkflowClientInterceptor.signal */
export interface WorkflowSignalInput {

@@ -27,3 +28,3 @@ readonly signalName: string;

}
/** Input for WorkflowClientCallsInterceptor.signalWithStart */
/** Input for WorkflowClientInterceptor.signalWithStart */
export interface WorkflowSignalWithStartInput {

@@ -36,3 +37,3 @@ readonly workflowType: string;

}
/** Input for WorkflowClientCallsInterceptor.query */
/** Input for WorkflowClientInterceptor.query */
export interface WorkflowQueryInput {

@@ -45,3 +46,3 @@ readonly queryType: string;

}
/** Input for WorkflowClientCallsInterceptor.terminate */
/** Input for WorkflowClientInterceptor.terminate */
export interface WorkflowTerminateInput {

@@ -53,3 +54,3 @@ readonly workflowExecution: WorkflowExecution;

}
/** Input for WorkflowClientCallsInterceptor.cancel */
/** Input for WorkflowClientInterceptor.cancel */
export interface WorkflowCancelInput {

@@ -59,3 +60,3 @@ readonly workflowExecution: WorkflowExecution;

}
/** Input for WorkflowClientCallsInterceptor.describe */
/** Input for WorkflowClientInterceptor.describe */
export interface WorkflowDescribeInput {

@@ -67,3 +68,3 @@ readonly workflowExecution: WorkflowExecution;

*/
export interface WorkflowClientCallsInterceptor {
export interface WorkflowClientInterceptor {
/**

@@ -104,2 +105,5 @@ * Intercept a service call to startWorkflowExecution

}
/** @deprecated: Use WorkflowClientInterceptor instead */
export declare type WorkflowClientCallsInterceptor = WorkflowClientInterceptor;
/** @deprecated */
export interface WorkflowClientCallsInterceptorFactoryInput {

@@ -111,2 +115,4 @@ workflowId: string;

* A function that takes {@link CompiledWorkflowOptions} and returns an interceptor
*
* @deprecated: Please define interceptors directly, without factory
*/

@@ -118,13 +124,43 @@ export interface WorkflowClientCallsInterceptorFactory {

* A mapping of interceptor type of a list of factory functions
*
* @deprecated: Please define interceptors directly, without factory
*/
export interface WorkflowClientInterceptors {
/** @deprecated */
calls?: WorkflowClientCallsInterceptorFactory[];
}
/**
* Implement any of these methods to intercept ScheduleClient outbound calls
*
* @experimental
*/
export interface ScheduleClientInterceptor {
/**
* Intercept a service call to CreateSchedule
*/
create?: (input: CreateScheduleInput, next: Next<this, 'create'>) => Promise<CreateScheduleOutput>;
}
/**
* Input for {@link ScheduleClientInterceptor.create}
*
* @experimental
*/
export interface CreateScheduleInput {
readonly headers: Headers;
readonly options: CompiledScheduleOptions;
}
export declare type CreateScheduleOutput = {
readonly conflictToken: Uint8Array;
};
/**
* Interceptors for any high-level SDK client.
*
* NOTE: Currently only for {@link WorkflowClient}. More will be added later as needed.
* NOTE: Currently only for {@link WorkflowClient} and {@link ScheduleClient}. More will be added later as needed.
*/
export interface ClientInterceptors {
workflow?: WorkflowClientInterceptors;
workflow?: WorkflowClientInterceptors | WorkflowClientInterceptor[];
/**
* @experimental
*/
schedule?: ScheduleClientInterceptor[];
}

@@ -0,4 +1,5 @@

import type * as grpc from '@grpc/grpc-js';
import type { SearchAttributes } from '@temporalio/common';
import * as proto from '@temporalio/proto';
import type * as grpc from '@grpc/grpc-js';
import { Replace } from '@temporalio/common/lib/type-helpers';
export interface WorkflowExecution {

@@ -11,6 +12,7 @@ workflowId: string;

export declare type DescribeWorkflowExecutionResponse = proto.temporal.api.workflowservice.v1.IDescribeWorkflowExecutionResponse;
export declare type RawWorkflowExecutionInfo = proto.temporal.api.workflow.v1.IWorkflowExecutionInfo;
export declare type TerminateWorkflowExecutionResponse = proto.temporal.api.workflowservice.v1.ITerminateWorkflowExecutionResponse;
export declare type RequestCancelWorkflowExecutionResponse = proto.temporal.api.workflowservice.v1.IRequestCancelWorkflowExecutionResponse;
export declare type WorkflowExecutionStatusName = 'UNSPECIFIED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'TERMINATED' | 'CONTINUED_AS_NEW' | 'TIMED_OUT' | 'UNKNOWN';
export interface WorkflowExecutionDescription {
export interface WorkflowExecutionInfo {
type: string;

@@ -31,4 +33,7 @@ workflowId: string;

parentExecution?: Required<proto.temporal.api.common.v1.IWorkflowExecution>;
raw: RawWorkflowExecutionInfo;
}
export declare type WorkflowExecutionDescription = Replace<WorkflowExecutionInfo, {
raw: DescribeWorkflowExecutionResponse;
}
}>;
export declare type WorkflowService = proto.temporal.api.workflowservice.v1.WorkflowService;

@@ -35,0 +40,0 @@ export declare const WorkflowService: typeof proto.temporal.api.workflowservice.v1.WorkflowService;

import { status as grpcStatus } from '@grpc/grpc-js';
import { DataConverter, LoadedDataConverter } from '@temporalio/common';
import { BaseWorkflowHandle, QueryDefinition, WithWorkflowArgs, Workflow, WorkflowResultType } from '@temporalio/common';
import { Replace } from '@temporalio/common/lib/type-helpers';
import { BaseWorkflowHandle, HistoryAndWorkflowId, QueryDefinition, WithWorkflowArgs, Workflow, WorkflowResultType } from '@temporalio/common';
import { History } from '@temporalio/common/lib/proto-utils';
import { temporal } from '@temporalio/proto';
import { WorkflowCancelInput, WorkflowClientCallsInterceptor, WorkflowClientInterceptors, WorkflowDescribeInput, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput } from './interceptors';
import { ConnectionLike, DescribeWorkflowExecutionResponse, Metadata, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution, WorkflowExecutionDescription, WorkflowService } from './types';
import { WorkflowOptions, WorkflowSignalWithStartOptions } from './workflow-options';
import { WorkflowCancelInput, WorkflowClientInterceptor, WorkflowClientInterceptors, WorkflowDescribeInput, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput } from './interceptors';
import { DescribeWorkflowExecutionResponse, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution, WorkflowExecutionDescription, WorkflowExecutionInfo, WorkflowService } from './types';
import { WorkflowOptions, WorkflowSignalWithStartOptions, WorkflowStartOptions } from './workflow-options';
import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client';
/**

@@ -71,2 +71,6 @@ * A client side handle to a single Workflow instance.

/**
* Return a workflow execution's history
*/
fetchHistory(): Promise<History>;
/**
* Readonly accessor to the underlying WorkflowClient

@@ -99,8 +103,4 @@ */

}
export interface WorkflowClientOptions {
export interface WorkflowClientOptions extends BaseClientOptions {
/**
* {@link DataConverter} or {@link LoadedDataConverter} to use for serializing and deserializing payloads
*/
dataConverter?: DataConverter | LoadedDataConverter;
/**
* Used to override and extend default Connection functionality

@@ -110,24 +110,4 @@ *

*/
interceptors?: WorkflowClientInterceptors;
interceptors?: WorkflowClientInterceptors | WorkflowClientInterceptor[];
/**
* Identity to report to the server
*
* @default `${process.pid}@${os.hostname()}`
*/
identity?: string;
/**
* Connection to use to communicate with the server.
*
* By default `WorkflowClient` connects to localhost.
*
* Connections are expensive to construct and should be reused.
*/
connection?: ConnectionLike;
/**
* Server namespace
*
* @default default
*/
namespace?: string;
/**
* Should a query be rejected by closed and failed workflows

@@ -139,9 +119,3 @@ *

}
export declare type WorkflowClientOptionsWithDefaults = Replace<Required<WorkflowClientOptions>, {
connection?: ConnectionLike;
}>;
export declare type LoadedWorkflowClientOptions = WorkflowClientOptionsWithDefaults & {
loadedDataConverter: LoadedDataConverter;
};
export declare function defaultWorkflowClientOptions(): WorkflowClientOptionsWithDefaults;
export declare type LoadedWorkflowClientOptions = LoadedWithDefaults<WorkflowClientOptions>;
/**

@@ -174,3 +148,3 @@ * Options for getting a result of a Workflow execution.

runId?: string;
interceptors: WorkflowClientCallsInterceptor[];
interceptors: WorkflowClientInterceptor[];
/**

@@ -186,6 +160,52 @@ * A runId to use for getting the workflow's result.

/**
* Options for starting a Workflow
* An iterable list of WorkflowExecution, as returned by {@link WorkflowClient.list}.
*/
export declare type WorkflowStartOptions<T extends Workflow = Workflow> = WithWorkflowArgs<T, WorkflowOptions>;
interface AsyncWorkflowListIterable extends AsyncIterable<WorkflowExecutionInfo> {
/**
* Return an iterable of histories corresponding to this iterable's WorkflowExecutions.
* Workflow histories will be fetched concurrently.
*
* Useful in batch replaying
*/
intoHistories: (intoHistoriesOptions?: IntoHistoriesOptions) => AsyncIterable<HistoryAndWorkflowId>;
}
/**
* Options for {@link WorkflowClient.list}
*/
export interface ListOptions {
/**
* Maximum number of results to fetch per page.
*
* @default depends on server config, typically 1000
*/
pageSize?: number;
/**
* Query string for matching and ordering the results
*/
query?: string;
}
/**
* Options for {@link WorkflowClient.list().intoHistories()}
*/
export interface IntoHistoriesOptions {
/**
* Maximum number of workflow histories to download concurrently.
*
* @default 5
*/
concurrency?: number;
/**
* Maximum number of workflow histories to buffer ahead, ready for consumption.
*
* It is recommended to set `bufferLimit` to a rasonnably low number if it is expected that the
* iterable may be stopped before reaching completion (for example, when implementing a fail fast
* bach replay test).
*
* Ignored unless `concurrency > 1`. No limit applies if set to `undefined`.
*
* @default unlimited
*/
bufferLimit?: number;
}
/**
* Client for starting Workflow executions and creating Workflow handles.

@@ -196,5 +216,4 @@ *

*/
export declare class WorkflowClient {
export declare class WorkflowClient extends BaseClient {
readonly options: LoadedWorkflowClientOptions;
readonly connection: ConnectionLike;
constructor(options?: WorkflowClientOptions);

@@ -208,16 +227,3 @@ /**

get workflowService(): WorkflowService;
protected get dataConverter(): LoadedDataConverter;
/**
* Set the deadline for any service requests executed in `fn`'s scope.
*/
withDeadline<R>(deadline: number | Date, fn: () => Promise<R>): Promise<R>;
/**
* Set metadata for any service requests executed in `fn`'s scope.
*
* @returns returned value of `fn`
*
* @see {@link Connection.withMetadata}
*/
withMetadata<R>(metadata: Metadata, fn: () => Promise<R>): Promise<R>;
/**
* Start a new Workflow execution.

@@ -227,3 +233,3 @@ *

*/
protected _start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowOptions>, interceptors: WorkflowClientCallsInterceptor[]): Promise<string>;
protected _start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowOptions>, interceptors: WorkflowClientInterceptor[]): Promise<string>;
/**

@@ -235,3 +241,3 @@ * Sends a signal to a running Workflow or starts a new one if not already running and immediately signals it.

*/
protected _signalWithStart<T extends Workflow, SA extends any[]>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowSignalWithStartOptions<SA>>, interceptors: WorkflowClientCallsInterceptor[]): Promise<string>;
protected _signalWithStart<T extends Workflow, SA extends any[]>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowSignalWithStartOptions<SA>>, interceptors: WorkflowClientInterceptor[]): Promise<string>;
/**

@@ -328,2 +334,13 @@ * Start a new Workflow execution.

getHandle<T extends Workflow>(workflowId: string, runId?: string, options?: GetWorkflowHandleOptions): WorkflowHandle<T>;
protected _list(options?: ListOptions): AsyncIterable<WorkflowExecutionInfo>;
/**
* List workflows by given `query`.
*
* ⚠️ To use advanced query functionality, as of the 1.18 server release, you must use Elasticsearch based visibility.
*
* More info on the concept of "visibility" and the query syntax on the Temporal documentation site:
* https://docs.temporal.io/visibility
*/
list(options?: ListOptions): AsyncWorkflowListIterable;
protected getOrMakeInterceptors(workflowId: string, runId?: string): WorkflowClientInterceptor[];
}

@@ -330,0 +347,0 @@ export declare class QueryRejectedError extends Error {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryNotRegisteredError = exports.QueryRejectedError = exports.WorkflowClient = exports.defaultWorkflowClientOptions = void 0;
exports.QueryNotRegisteredError = exports.QueryRejectedError = exports.WorkflowClient = void 0;
const grpc_js_1 = require("@grpc/grpc-js");
const uuid_1 = require("uuid");
const common_1 = require("@temporalio/common");
const interceptors_1 = require("@temporalio/common/lib/interceptors");
const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
const common_2 = require("@temporalio/common");
const time_1 = require("@temporalio/common/lib/time");
const interceptors_1 = require("@temporalio/common/lib/interceptors");
const proto_1 = require("@temporalio/proto");
const os_1 = __importDefault(require("os"));
const uuid_1 = require("uuid");
const connection_1 = require("./connection");
const errors_1 = require("./errors");
const workflow_options_1 = require("./workflow-options");
const helpers_1 = require("./helpers");
const base_client_1 = require("./base-client");
const iterators_utils_1 = require("./iterators-utils");
function defaultWorkflowClientOptions() {
return {
dataConverter: {},
// The equivalent in Java is ManagementFactory.getRuntimeMXBean().getName()
identity: `${process.pid}@${os_1.default.hostname()}`,
interceptors: {},
namespace: 'default',
...(0, base_client_1.defaultBaseClientOptions)(),
interceptors: [],
queryRejectCondition: proto_1.temporal.api.enums.v1.QueryRejectCondition.QUERY_REJECT_CONDITION_UNSPECIFIED,
};
}
exports.defaultWorkflowClientOptions = defaultWorkflowClientOptions;
function assertRequiredWorkflowOptions(opts) {

@@ -48,11 +40,9 @@ if (!opts.taskQueue) {

*/
class WorkflowClient {
class WorkflowClient extends base_client_1.BaseClient {
constructor(options) {
this.connection = options?.connection ?? connection_1.Connection.lazy();
const dataConverter = options?.dataConverter;
const loadedDataConverter = (0, internal_non_workflow_1.isLoadedDataConverter)(dataConverter) ? dataConverter : (0, internal_non_workflow_1.loadDataConverter)(dataConverter);
super(options);
this.options = {
...defaultWorkflowClientOptions(),
...(0, internal_non_workflow_1.filterNullAndUndefined)(options ?? {}),
loadedDataConverter,
loadedDataConverter: this.dataConverter,
};

@@ -69,22 +59,3 @@ }

}
get dataConverter() {
return this.options.loadedDataConverter;
}
/**
* Set the deadline for any service requests executed in `fn`'s scope.
*/
async withDeadline(deadline, fn) {
return await this.connection.withDeadline(deadline, fn);
}
/**
* Set metadata for any service requests executed in `fn`'s scope.
*
* @returns returned value of `fn`
*
* @see {@link Connection.withMetadata}
*/
async withMetadata(metadata, fn) {
return await this.connection.withMetadata(metadata, fn);
}
/**
* Start a new Workflow execution.

@@ -132,4 +103,3 @@ *

const { workflowId } = options;
// Cast is needed because it's impossible to deduce the type in this situation
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
const interceptors = this.getOrMakeInterceptors(workflowId);
const runId = await this._start(workflowTypeOrFunc, { ...options, workflowId }, interceptors);

@@ -157,3 +127,3 @@ // runId is not used in handles created with `start*` calls because these

const { workflowId } = options;
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
const interceptors = this.getOrMakeInterceptors(workflowId);
const runId = await this._signalWithStart(workflowTypeOrFunc, options, interceptors);

@@ -180,3 +150,3 @@ // runId is not used in handles created with `start*` calls because these

const { workflowId } = options;
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
const interceptors = this.getOrMakeInterceptors(workflowId);
await this._start(workflowTypeOrFunc, options, interceptors);

@@ -278,3 +248,3 @@ return await this.result(workflowId, undefined, {

if (err.code === grpc_js_1.status.NOT_FOUND) {
throw new common_2.WorkflowNotFoundError(err.details ?? 'Workflow not found', workflowExecution.workflowId, workflowExecution.runId);
throw new common_1.WorkflowNotFoundError(err.details ?? 'Workflow not found', workflowExecution.workflowId, workflowExecution.runId);
}

@@ -370,3 +340,3 @@ throw new errors_1.ServiceError(fallbackMessage, { cause: err });

workflowTaskTimeout: options.workflowTaskTimeout,
retryPolicy: options.retry ? (0, common_2.compileRetryPolicy)(options.retry) : undefined,
retryPolicy: options.retry ? (0, common_1.compileRetryPolicy)(options.retry) : undefined,
memo: options.memo ? { fields: await (0, internal_non_workflow_1.encodeMapToPayloads)(this.dataConverter, options.memo) } : undefined,

@@ -410,3 +380,3 @@ searchAttributes: options.searchAttributes

workflowTaskTimeout: opts.workflowTaskTimeout,
retryPolicy: opts.retry ? (0, common_2.compileRetryPolicy)(opts.retry) : undefined,
retryPolicy: opts.retry ? (0, common_1.compileRetryPolicy)(opts.retry) : undefined,
memo: opts.memo ? { fields: await (0, internal_non_workflow_1.encodeMapToPayloads)(this.dataConverter, opts.memo) } : undefined,

@@ -427,3 +397,3 @@ searchAttributes: opts.searchAttributes

if (err.code === grpc_js_1.status.ALREADY_EXISTS) {
throw new errors_1.WorkflowExecutionAlreadyStartedError('Workflow execution already started', opts.workflowId, workflowType);
throw new common_1.WorkflowExecutionAlreadyStartedError('Workflow execution already started', opts.workflowId, workflowType);
}

@@ -522,29 +492,22 @@ this.rethrowGrpcError(err, { workflowId: opts.workflowId }, 'Failed to start Workflow');

});
return {
/* eslint-disable @typescript-eslint/no-non-null-assertion */
type: raw.workflowExecutionInfo.type.name,
workflowId: raw.workflowExecutionInfo.execution.workflowId,
runId: raw.workflowExecutionInfo.execution.runId,
taskQueue: raw.workflowExecutionInfo.taskQueue,
status: {
code: raw.workflowExecutionInfo.status,
name: workflowStatusCodeToName(raw.workflowExecutionInfo.status),
},
// Safe to convert to number, max history length is 50k, which is much less than Number.MAX_SAFE_INTEGER
historyLength: raw.workflowExecutionInfo.historyLength.toNumber(),
startTime: (0, time_1.tsToDate)(raw.workflowExecutionInfo.startTime),
executionTime: (0, time_1.optionalTsToDate)(raw.workflowExecutionInfo.executionTime),
closeTime: (0, time_1.optionalTsToDate)(raw.workflowExecutionInfo.closeTime),
memo: await (0, internal_non_workflow_1.decodeMapFromPayloads)(this.client.dataConverter, raw.workflowExecutionInfo.memo?.fields),
searchAttributes: Object.fromEntries(Object.entries((0, common_1.mapFromPayloads)(common_1.searchAttributePayloadConverter, raw.workflowExecutionInfo.searchAttributes?.indexedFields ?? {})).filter(([_, v]) => v && v.length > 0) // Filter out empty arrays returned by pre 1.18 servers
),
parentExecution: raw.workflowExecutionInfo?.parentExecution
? {
workflowId: raw.workflowExecutionInfo.parentExecution.workflowId,
runId: raw.workflowExecutionInfo.parentExecution.runId,
}
: undefined,
raw,
};
const info = await (0, helpers_1.executionInfoFromRaw)(raw.workflowExecutionInfo ?? {}, this.client.dataConverter);
info.raw = raw;
return info;
},
async fetchHistory() {
let nextPageToken = undefined;
const events = Array();
for (;;) {
const response = await this.client.workflowService.getWorkflowExecutionHistory({
nextPageToken,
namespace: this.client.options.namespace,
execution: { workflowId, runId },
});
events.push(...(response.history?.events ?? []));
nextPageToken = response.nextPageToken;
if (nextPageToken == null || nextPageToken.length === 0)
break;
}
return proto_1.temporal.api.history.v1.History.create({ events });
},
async signal(def, ...args) {

@@ -592,3 +555,3 @@ const next = this.client._signalWorkflowHandler.bind(this.client);

getHandle(workflowId, runId, options) {
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId, runId }));
const interceptors = this.getOrMakeInterceptors(workflowId, runId);
return this._createWorkflowHandle({

@@ -603,2 +566,51 @@ workflowId,

}
async *_list(options) {
let nextPageToken = Buffer.alloc(0);
for (;;) {
const response = await this.workflowService.listWorkflowExecutions({
namespace: this.options.namespace,
query: options?.query,
nextPageToken,
pageSize: options?.pageSize,
});
// Not decoding memo payloads concurrently even though we could have to keep the lazy nature of this iterator.
// Decoding is done for `memo` fields which tend to be small.
// We might decide to change that based on user feedback.
for (const raw of response.executions) {
yield await (0, helpers_1.executionInfoFromRaw)(raw, this.dataConverter);
}
nextPageToken = response.nextPageToken;
if (nextPageToken == null || nextPageToken.length === 0)
break;
}
}
/**
* List workflows by given `query`.
*
* ⚠️ To use advanced query functionality, as of the 1.18 server release, you must use Elasticsearch based visibility.
*
* More info on the concept of "visibility" and the query syntax on the Temporal documentation site:
* https://docs.temporal.io/visibility
*/
list(options) {
return {
[Symbol.asyncIterator]: () => this._list(options)[Symbol.asyncIterator](),
intoHistories: (intoHistoriesOptions) => {
return (0, iterators_utils_1.mapAsyncIterable)(this._list(options), async ({ workflowId, runId }) => ({
workflowId,
history: await this.getHandle(workflowId, runId)
.fetchHistory()
.catch((_) => undefined),
}), { concurrency: intoHistoriesOptions?.concurrency ?? 5 });
},
};
}
getOrMakeInterceptors(workflowId, runId) {
if (typeof this.options.interceptors === 'object' && 'calls' in this.options.interceptors) {
// eslint-disable-next-line deprecation/deprecation
const factories = this.options.interceptors.calls ?? [];
return factories.map((ctor) => ctor({ workflowId, runId }));
}
return Array.isArray(this.options.interceptors) ? this.options.interceptors : [];
}
}

@@ -622,28 +634,2 @@ exports.WorkflowClient = WorkflowClient;

exports.QueryNotRegisteredError = QueryNotRegisteredError;
function workflowStatusCodeToName(code) {
return workflowStatusCodeToNameInternal(code) ?? 'UNKNOWN';
}
/**
* Intentionally leave out `default` branch to get compilation errors when new values are added
*/
function workflowStatusCodeToNameInternal(code) {
switch (code) {
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_UNSPECIFIED:
return 'UNSPECIFIED';
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_RUNNING:
return 'RUNNING';
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_FAILED:
return 'FAILED';
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_TIMED_OUT:
return 'TIMED_OUT';
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_CANCELED:
return 'CANCELLED';
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_TERMINATED:
return 'TERMINATED';
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_COMPLETED:
return 'COMPLETED';
case proto_1.temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_CONTINUED_AS_NEW:
return 'CONTINUED_AS_NEW';
}
}
//# sourceMappingURL=workflow-client.js.map

@@ -1,2 +0,2 @@

import { CommonWorkflowOptions, SignalDefinition, WithCompiledWorkflowOptions } from '@temporalio/common';
import { CommonWorkflowOptions, SignalDefinition, WithCompiledWorkflowOptions, WithWorkflowArgs, Workflow } from '@temporalio/common';
export * from '@temporalio/common/lib/workflow-options';

@@ -51,1 +51,5 @@ export interface CompiledWorkflowOptions extends WithCompiledWorkflowOptions<WorkflowOptions> {

}
/**
* Options for starting a Workflow
*/
export declare type WorkflowStartOptions<T extends Workflow = Workflow> = WithWorkflowArgs<T, WorkflowOptions>;
{
"name": "@temporalio/client",
"version": "1.4.4",
"version": "1.5.0",
"description": "Temporal.io SDK Client sub-package",

@@ -17,8 +17,10 @@ "main": "lib/index.js",

"@grpc/grpc-js": "^1.6.7",
"@temporalio/common": "~1.4.4",
"@temporalio/proto": "~1.4.4",
"ms": "^2.1.3",
"@temporalio/common": "~1.5.0",
"@temporalio/proto": "~1.5.0",
"abort-controller": "^3.0.0",
"long": "^5.2.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/long": "^5.0.0",
"protobufjs": "^7.0.0"

@@ -37,3 +39,3 @@ },

],
"gitHead": "7ae3fba6332000b35d521411404c11e32052f282"
"gitHead": "b46426d8b9b342c052d53520b50dbb991b8d5e03"
}
import { Status } from '@grpc/grpc-js/build/src/constants';
import { DataConverter, ensureTemporalFailure, LoadedDataConverter } from '@temporalio/common';
import { ensureTemporalFailure } from '@temporalio/common';
import {

@@ -7,10 +7,12 @@ encodeErrorToFailure,

filterNullAndUndefined,
isLoadedDataConverter,
loadDataConverter,
} from '@temporalio/common/lib/internal-non-workflow';
import { Replace } from '@temporalio/common/lib/type-helpers';
import os from 'os';
import { Connection } from './connection';
import {
BaseClient,
BaseClientOptions,
defaultBaseClientOptions,
LoadedWithDefaults,
WithDefaults,
} from './base-client';
import { isServerErrorResponse } from './errors';
import { ConnectionLike, WorkflowService } from './types';
import { WorkflowService } from './types';

@@ -44,44 +46,10 @@ /**

*/
export interface AsyncCompletionClientOptions {
/**
* {@link DataConverter} or {@link LoadedDataConverter} to use for serializing and deserializing payloads
*/
dataConverter?: DataConverter | LoadedDataConverter;
export type AsyncCompletionClientOptions = BaseClientOptions;
/**
* Identity to report to the server
*
* @default `${process.pid}@${os.hostname()}`
*/
identity?: string;
export type LoadedAsyncCompletionClientOptions = LoadedWithDefaults<AsyncCompletionClientOptions>;
connection?: ConnectionLike;
/**
* Server namespace
*
* @default default
*/
namespace?: string;
function defaultAsyncCompletionClientOptions(): WithDefaults<AsyncCompletionClientOptions> {
return defaultBaseClientOptions();
}
export type AsyncCompletionClientOptionsWithDefaults = Replace<
Required<AsyncCompletionClientOptions>,
{
connection?: ConnectionLike;
}
>;
export type LoadedAsyncCompletionClientOptions = AsyncCompletionClientOptionsWithDefaults & {
loadedDataConverter: LoadedDataConverter;
};
export function defaultAsyncCompletionClientOptions(): AsyncCompletionClientOptionsWithDefaults {
return {
dataConverter: {},
identity: `${process.pid}@${os.hostname()}`,
namespace: 'default',
};
}
/**

@@ -106,14 +74,11 @@ * A mostly unique Activity identifier including its scheduling workflow's ID

*/
export class AsyncCompletionClient {
export class AsyncCompletionClient extends BaseClient {
public readonly options: LoadedAsyncCompletionClientOptions;
public readonly connection: ConnectionLike;
constructor(options?: AsyncCompletionClientOptions) {
this.connection = options?.connection ?? Connection.lazy();
const dataConverter = options?.dataConverter;
const loadedDataConverter = isLoadedDataConverter(dataConverter) ? dataConverter : loadDataConverter(dataConverter);
super(options);
this.options = {
...defaultAsyncCompletionClientOptions(),
...filterNullAndUndefined(options ?? {}),
loadedDataConverter,
loadedDataConverter: this.dataConverter,
};

@@ -132,6 +97,2 @@ }

protected get dataConverter(): LoadedDataConverter {
return this.options.loadedDataConverter;
}
/**

@@ -138,0 +99,0 @@ * Transforms grpc errors into well defined TS errors.

@@ -1,19 +0,12 @@

import { DataConverter, LoadedDataConverter } from '@temporalio/common';
import { filterNullAndUndefined, loadDataConverter } from '@temporalio/common/lib/internal-non-workflow';
import { Replace } from '@temporalio/common/lib/type-helpers';
import { filterNullAndUndefined } from '@temporalio/common/lib/internal-non-workflow';
import { temporal } from '@temporalio/proto';
import os from 'os';
import { AsyncCompletionClient } from './async-completion-client';
import { Connection } from './connection';
import { BaseClient, BaseClientOptions, defaultBaseClientOptions, LoadedWithDefaults } from './base-client';
import { ClientInterceptors } from './interceptors';
import { ConnectionLike, Metadata, WorkflowService } from './types';
import { ScheduleClient } from './schedule-client';
import { WorkflowService } from './types';
import { WorkflowClient } from './workflow-client';
export interface ClientOptions {
export interface ClientOptions extends BaseClientOptions {
/**
* {@link DataConverter} to use for serializing and deserializing payloads
*/
dataConverter?: DataConverter;
/**
* Used to override and extend default Connection functionality

@@ -25,25 +18,2 @@ *

/**
* Identity to report to the server
*
* @default `${process.pid}@${os.hostname()}`
*/
identity?: string;
/**
* Connection to use to communicate with the server.
*
* By default `WorkflowClient` connects to localhost.
*
* Connections are expensive to construct and should be reused.
*/
connection?: ConnectionLike;
/**
* Server namespace
*
* @default default
*/
namespace?: string;
workflow?: {

@@ -59,33 +29,8 @@ /**

export type ClientOptionsWithDefaults = Replace<
Required<ClientOptions>,
{
connection?: ConnectionLike;
}
>;
export type LoadedClientOptions = LoadedWithDefaults<ClientOptions>;
export type LoadedClientOptions = ClientOptionsWithDefaults & {
loadedDataConverter: LoadedDataConverter;
};
export function defaultClientOptions(): ClientOptionsWithDefaults {
return {
dataConverter: {},
identity: `${process.pid}@${os.hostname()}`,
interceptors: {},
namespace: 'default',
workflow: {
queryRejectCondition: temporal.api.enums.v1.QueryRejectCondition.QUERY_REJECT_CONDITION_UNSPECIFIED,
},
};
}
/**
* High level SDK client.
*/
export class Client {
/**
* Underlying gRPC connection to the Temporal service
*/
public readonly connection: ConnectionLike;
export class Client extends BaseClient {
public readonly options: LoadedClientOptions;

@@ -100,26 +45,47 @@ /**

public readonly activity: AsyncCompletionClient;
/**
* Schedule sub-client - use to start and interact with Schedules
*
* @experimental
*/
public readonly schedule: ScheduleClient;
constructor(options?: ClientOptions) {
this.connection = options?.connection ?? Connection.lazy();
this.options = {
...defaultClientOptions(),
...filterNullAndUndefined(options ?? {}),
loadedDataConverter: loadDataConverter(options?.dataConverter),
};
super(options);
const { workflow, loadedDataConverter, interceptors, ...base } = this.options;
const { interceptors, workflow, ...commonOptions } = options ?? {};
this.workflow = new WorkflowClient({
...base,
...workflow,
...commonOptions,
...(workflow ?? {}),
connection: this.connection,
dataConverter: loadedDataConverter,
interceptors: interceptors.workflow,
dataConverter: this.dataConverter,
interceptors: interceptors?.workflow,
});
this.activity = new AsyncCompletionClient({
...base,
...commonOptions,
connection: this.connection,
dataConverter: loadedDataConverter,
dataConverter: this.dataConverter,
});
this.schedule = new ScheduleClient({
...commonOptions,
connection: this.connection,
dataConverter: this.dataConverter,
interceptors: interceptors?.schedule,
});
this.options = {
...defaultBaseClientOptions(),
...filterNullAndUndefined(commonOptions),
loadedDataConverter: this.dataConverter,
interceptors: {
workflow: this.workflow.options.interceptors,
schedule: this.schedule.options.interceptors,
},
workflow: {
queryRejectCondition: this.workflow.options.queryRejectCondition,
},
};
}

@@ -136,20 +102,2 @@

}
/**
* Set the deadline for any service requests executed in `fn`'s scope.
*/
async withDeadline<R>(deadline: number | Date, fn: () => Promise<R>): Promise<R> {
return await this.connection.withDeadline(deadline, fn);
}
/**
* Set metadata for any service requests executed in `fn`'s scope.
*
* @returns returned value of `fn`
*
* @see {@link Connection.withMetadata}
*/
async withMetadata<R>(metadata: Metadata, fn: () => Promise<R>): Promise<R> {
return await this.connection.withMetadata(metadata, fn);
}
}

@@ -0,5 +1,6 @@

import { AsyncLocalStorage } from 'async_hooks';
import * as grpc from '@grpc/grpc-js';
import type { RPCImpl } from 'protobufjs';
import { filterNullAndUndefined, normalizeTlsConfig, TLSConfig } from '@temporalio/common/lib/internal-non-workflow';
import { AsyncLocalStorage } from 'async_hooks';
import type { RPCImpl } from 'protobufjs';
import { msOptionalToNumber } from '@temporalio/common/lib/time';
import { isServerErrorResponse, ServiceError } from './errors';

@@ -56,10 +57,10 @@ import { defaultGrpcRetryOptions, makeGrpcRetryInterceptor } from './grpc-retry';

/**
* Grpc interceptors which will be applied to every RPC call performed by this connection. By default, an interceptor
* will be included which automatically retries retryable errors. If you do not wish to perform automatic retries, set
* this to an empty list (or a list with your own interceptors). If you want to add your own interceptors while
* keeping the default retry behavior, add this to your list of interceptors:
* `makeGrpcRetryInterceptor(defaultGrpcRetryOptions())`. See:
* {@link https://grpc.github.io/grpc/node/module-src_client_interceptors.html | gRPC interceptors} which will be
* applied to every RPC call performed by this connection. By default, an interceptor will be included which
* automatically retries retryable errors. If you do not wish to perform automatic retries, set this to an empty list
* (or a list with your own interceptors). If you want to add your own interceptors while keeping the default retry
* behavior, add this to your list of interceptors: `makeGrpcRetryInterceptor(defaultGrpcRetryOptions())`. See:
*
* - @link makeGrpcRetryInterceptor
* - @link defaultGrpcRetryOptions
* - {@link makeGrpcRetryInterceptor}
* - {@link defaultGrpcRetryOptions}
*/

@@ -94,3 +95,3 @@ interceptors?: grpc.Interceptor[];

function addDefaults(options: ConnectionOptions): ConnectionOptionsWithDefaults {
const { channelArgs, interceptors, ...rest } = options;
const { channelArgs, interceptors, connectTimeout, ...rest } = options;
return {

@@ -107,3 +108,3 @@ address: LOCAL_TARGET,

metadata: {},
connectTimeoutMs: 10_000,
connectTimeoutMs: msOptionalToNumber(connectTimeout) ?? 10_000,
...filterNullAndUndefined(rest),

@@ -110,0 +111,0 @@ };

import { ServerErrorResponse } from '@grpc/grpc-js';
import { RetryState, TemporalFailure } from '@temporalio/common';
export { WorkflowExecutionAlreadyStartedError } from '@temporalio/common';

@@ -5,0 +4,0 @@ /**

@@ -39,1 +39,3 @@ /**

export * from './workflow-options';
export * from './schedule-types';
export * from './schedule-client';

@@ -9,2 +9,3 @@ /**

import { temporal } from '@temporalio/proto';
import { CompiledScheduleOptions } from './schedule-types';
import {

@@ -20,3 +21,3 @@ DescribeWorkflowExecutionResponse,

/** Input for WorkflowClientCallsInterceptor.start */
/** Input for WorkflowClientInterceptor.start */
export interface WorkflowStartInput {

@@ -29,3 +30,3 @@ /** Name of Workflow to start */

/** Input for WorkflowClientCallsInterceptor.signal */
/** Input for WorkflowClientInterceptor.signal */
export interface WorkflowSignalInput {

@@ -38,3 +39,3 @@ readonly signalName: string;

/** Input for WorkflowClientCallsInterceptor.signalWithStart */
/** Input for WorkflowClientInterceptor.signalWithStart */
export interface WorkflowSignalWithStartInput {

@@ -48,3 +49,3 @@ readonly workflowType: string;

/** Input for WorkflowClientCallsInterceptor.query */
/** Input for WorkflowClientInterceptor.query */
export interface WorkflowQueryInput {

@@ -58,3 +59,3 @@ readonly queryType: string;

/** Input for WorkflowClientCallsInterceptor.terminate */
/** Input for WorkflowClientInterceptor.terminate */
export interface WorkflowTerminateInput {

@@ -67,3 +68,3 @@ readonly workflowExecution: WorkflowExecution;

/** Input for WorkflowClientCallsInterceptor.cancel */
/** Input for WorkflowClientInterceptor.cancel */
export interface WorkflowCancelInput {

@@ -74,3 +75,3 @@ readonly workflowExecution: WorkflowExecution;

/** Input for WorkflowClientCallsInterceptor.describe */
/** Input for WorkflowClientInterceptor.describe */
export interface WorkflowDescribeInput {

@@ -83,3 +84,3 @@ readonly workflowExecution: WorkflowExecution;

*/
export interface WorkflowClientCallsInterceptor {
export interface WorkflowClientInterceptor {
/**

@@ -124,2 +125,6 @@ * Intercept a service call to startWorkflowExecution

/** @deprecated: Use WorkflowClientInterceptor instead */
export type WorkflowClientCallsInterceptor = WorkflowClientInterceptor;
/** @deprecated */
export interface WorkflowClientCallsInterceptorFactoryInput {

@@ -132,4 +137,7 @@ workflowId: string;

* A function that takes {@link CompiledWorkflowOptions} and returns an interceptor
*
* @deprecated: Please define interceptors directly, without factory
*/
export interface WorkflowClientCallsInterceptorFactory {
// eslint-disable-next-line deprecation/deprecation
(input: WorkflowClientCallsInterceptorFactoryInput): WorkflowClientCallsInterceptor;

@@ -140,4 +148,8 @@ }

* A mapping of interceptor type of a list of factory functions
*
* @deprecated: Please define interceptors directly, without factory
*/
export interface WorkflowClientInterceptors {
/** @deprecated */
// eslint-disable-next-line deprecation/deprecation
calls?: WorkflowClientCallsInterceptorFactory[];

@@ -147,8 +159,40 @@ }

/**
* Implement any of these methods to intercept ScheduleClient outbound calls
*
* @experimental
*/
export interface ScheduleClientInterceptor {
/**
* Intercept a service call to CreateSchedule
*/
create?: (input: CreateScheduleInput, next: Next<this, 'create'>) => Promise<CreateScheduleOutput>;
}
/**
* Input for {@link ScheduleClientInterceptor.create}
*
* @experimental
*/
export interface CreateScheduleInput {
readonly headers: Headers;
readonly options: CompiledScheduleOptions;
}
export type CreateScheduleOutput = {
readonly conflictToken: Uint8Array;
};
/**
* Interceptors for any high-level SDK client.
*
* NOTE: Currently only for {@link WorkflowClient}. More will be added later as needed.
* NOTE: Currently only for {@link WorkflowClient} and {@link ScheduleClient}. More will be added later as needed.
*/
export interface ClientInterceptors {
workflow?: WorkflowClientInterceptors;
// eslint-disable-next-line deprecation/deprecation
workflow?: WorkflowClientInterceptors | WorkflowClientInterceptor[];
/**
* @experimental
*/
schedule?: ScheduleClientInterceptor[];
}

@@ -0,4 +1,5 @@

import type * as grpc from '@grpc/grpc-js';
import type { SearchAttributes } from '@temporalio/common';
import * as proto from '@temporalio/proto';
import type * as grpc from '@grpc/grpc-js';
import { Replace } from '@temporalio/common/lib/type-helpers';

@@ -14,2 +15,3 @@ export interface WorkflowExecution {

proto.temporal.api.workflowservice.v1.IDescribeWorkflowExecutionResponse;
export type RawWorkflowExecutionInfo = proto.temporal.api.workflow.v1.IWorkflowExecutionInfo;
export type TerminateWorkflowExecutionResponse =

@@ -31,3 +33,3 @@ proto.temporal.api.workflowservice.v1.ITerminateWorkflowExecutionResponse;

export interface WorkflowExecutionDescription {
export interface WorkflowExecutionInfo {
type: string;

@@ -45,5 +47,12 @@ workflowId: string;

parentExecution?: Required<proto.temporal.api.common.v1.IWorkflowExecution>;
raw: DescribeWorkflowExecutionResponse;
raw: RawWorkflowExecutionInfo;
}
export type WorkflowExecutionDescription = Replace<
WorkflowExecutionInfo,
{
raw: DescribeWorkflowExecutionResponse;
}
>;
export type WorkflowService = proto.temporal.api.workflowservice.v1.WorkflowService;

@@ -50,0 +59,0 @@ export const { WorkflowService } = proto.temporal.api.workflowservice.v1;

import { status as grpcStatus } from '@grpc/grpc-js';
import { v4 as uuid4 } from 'uuid';
import {
BaseWorkflowHandle,
CancelledFailure,
DataConverter,
LoadedDataConverter,
mapFromPayloads,
compileRetryPolicy,
mapToPayloads,
HistoryAndWorkflowId,
QueryDefinition,
RetryState,
searchAttributePayloadConverter,
SignalDefinition,
TerminatedFailure,
TimeoutFailure,
TimeoutType,
WithWorkflowArgs,
Workflow,
WorkflowExecutionAlreadyStartedError,
WorkflowNotFoundError,
WorkflowResultType,
} from '@temporalio/common';
import { composeInterceptors } from '@temporalio/common/lib/interceptors';
import { History } from '@temporalio/common/lib/proto-utils';
import {
decodeArrayFromPayloads,
decodeFromPayloadsAtIndex,
decodeMapFromPayloads,
decodeOptionalFailureToOptionalError,

@@ -22,33 +31,8 @@ encodeMapToPayloads,

filterNullAndUndefined,
isLoadedDataConverter,
loadDataConverter,
} from '@temporalio/common/lib/internal-non-workflow';
import {
BaseWorkflowHandle,
compileRetryPolicy,
QueryDefinition,
SearchAttributes,
SignalDefinition,
WithWorkflowArgs,
Workflow,
WorkflowNotFoundError,
WorkflowResultType,
} from '@temporalio/common';
import { optionalTsToDate, tsToDate } from '@temporalio/common/lib/time';
import { composeInterceptors } from '@temporalio/common/lib/interceptors';
import { Replace } from '@temporalio/common/lib/type-helpers';
import { temporal } from '@temporalio/proto';
import os from 'os';
import { v4 as uuid4 } from 'uuid';
import { Connection } from './connection';
import { isServerErrorResponse, ServiceError, WorkflowContinuedAsNewError, WorkflowFailedError } from './errors';
import {
isServerErrorResponse,
ServiceError,
WorkflowContinuedAsNewError,
WorkflowExecutionAlreadyStartedError,
WorkflowFailedError,
} from './errors';
import {
WorkflowCancelInput,
WorkflowClientCallsInterceptor,
WorkflowClientInterceptor,
WorkflowClientInterceptors,

@@ -63,6 +47,4 @@ WorkflowDescribeInput,

import {
ConnectionLike,
DescribeWorkflowExecutionResponse,
GetWorkflowExecutionHistoryRequest,
Metadata,
RequestCancelWorkflowExecutionResponse,

@@ -73,6 +55,20 @@ StartWorkflowExecutionRequest,

WorkflowExecutionDescription,
WorkflowExecutionStatusName,
WorkflowExecutionInfo,
WorkflowService,
} from './types';
import { compileWorkflowOptions, WorkflowOptions, WorkflowSignalWithStartOptions } from './workflow-options';
import {
compileWorkflowOptions,
WorkflowOptions,
WorkflowSignalWithStartOptions,
WorkflowStartOptions,
} from './workflow-options';
import { executionInfoFromRaw } from './helpers';
import {
BaseClient,
BaseClientOptions,
defaultBaseClientOptions,
LoadedWithDefaults,
WithDefaults,
} from './base-client';
import { mapAsyncIterable } from './iterators-utils';

@@ -145,2 +141,7 @@ /**

/**
* Return a workflow execution's history
*/
fetchHistory(): Promise<History>;
/**
* Readonly accessor to the underlying WorkflowClient

@@ -176,9 +177,4 @@ */

export interface WorkflowClientOptions {
export interface WorkflowClientOptions extends BaseClientOptions {
/**
* {@link DataConverter} or {@link LoadedDataConverter} to use for serializing and deserializing payloads
*/
dataConverter?: DataConverter | LoadedDataConverter;
/**
* Used to override and extend default Connection functionality

@@ -188,28 +184,6 @@ *

*/
interceptors?: WorkflowClientInterceptors;
// eslint-disable-next-line deprecation/deprecation
interceptors?: WorkflowClientInterceptors | WorkflowClientInterceptor[];
/**
* Identity to report to the server
*
* @default `${process.pid}@${os.hostname()}`
*/
identity?: string;
/**
* Connection to use to communicate with the server.
*
* By default `WorkflowClient` connects to localhost.
*
* Connections are expensive to construct and should be reused.
*/
connection?: ConnectionLike;
/**
* Server namespace
*
* @default default
*/
namespace?: string;
/**
* Should a query be rejected by closed and failed workflows

@@ -222,19 +196,8 @@ *

export type WorkflowClientOptionsWithDefaults = Replace<
Required<WorkflowClientOptions>,
{
connection?: ConnectionLike;
}
>;
export type LoadedWorkflowClientOptions = WorkflowClientOptionsWithDefaults & {
loadedDataConverter: LoadedDataConverter;
};
export type LoadedWorkflowClientOptions = LoadedWithDefaults<WorkflowClientOptions>;
export function defaultWorkflowClientOptions(): WorkflowClientOptionsWithDefaults {
function defaultWorkflowClientOptions(): WithDefaults<WorkflowClientOptions> {
return {
dataConverter: {},
// The equivalent in Java is ManagementFactory.getRuntimeMXBean().getName()
identity: `${process.pid}@${os.hostname()}`,
interceptors: {},
namespace: 'default',
...defaultBaseClientOptions(),
interceptors: [],
queryRejectCondition: temporal.api.enums.v1.QueryRejectCondition.QUERY_REJECT_CONDITION_UNSPECIFIED,

@@ -289,3 +252,3 @@ };

runId?: string;
interceptors: WorkflowClientCallsInterceptor[];
interceptors: WorkflowClientInterceptor[];
/**

@@ -302,7 +265,56 @@ * A runId to use for getting the workflow's result.

/**
* Options for starting a Workflow
* An iterable list of WorkflowExecution, as returned by {@link WorkflowClient.list}.
*/
export type WorkflowStartOptions<T extends Workflow = Workflow> = WithWorkflowArgs<T, WorkflowOptions>;
interface AsyncWorkflowListIterable extends AsyncIterable<WorkflowExecutionInfo> {
/**
* Return an iterable of histories corresponding to this iterable's WorkflowExecutions.
* Workflow histories will be fetched concurrently.
*
* Useful in batch replaying
*/
intoHistories: (intoHistoriesOptions?: IntoHistoriesOptions) => AsyncIterable<HistoryAndWorkflowId>;
}
/**
* Options for {@link WorkflowClient.list}
*/
export interface ListOptions {
/**
* Maximum number of results to fetch per page.
*
* @default depends on server config, typically 1000
*/
pageSize?: number;
/**
* Query string for matching and ordering the results
*/
query?: string;
}
/**
* Options for {@link WorkflowClient.list().intoHistories()}
*/
export interface IntoHistoriesOptions {
/**
* Maximum number of workflow histories to download concurrently.
*
* @default 5
*/
concurrency?: number;
/**
* Maximum number of workflow histories to buffer ahead, ready for consumption.
*
* It is recommended to set `bufferLimit` to a rasonnably low number if it is expected that the
* iterable may be stopped before reaching completion (for example, when implementing a fail fast
* bach replay test).
*
* Ignored unless `concurrency > 1`. No limit applies if set to `undefined`.
*
* @default unlimited
*/
bufferLimit?: number;
}
/**
* Client for starting Workflow executions and creating Workflow handles.

@@ -313,14 +325,11 @@ *

*/
export class WorkflowClient {
export class WorkflowClient extends BaseClient {
public readonly options: LoadedWorkflowClientOptions;
public readonly connection: ConnectionLike;
constructor(options?: WorkflowClientOptions) {
this.connection = options?.connection ?? Connection.lazy();
const dataConverter = options?.dataConverter;
const loadedDataConverter = isLoadedDataConverter(dataConverter) ? dataConverter : loadDataConverter(dataConverter);
super(options);
this.options = {
...defaultWorkflowClientOptions(),
...filterNullAndUndefined(options ?? {}),
loadedDataConverter,
loadedDataConverter: this.dataConverter,
};

@@ -339,25 +348,3 @@ }

protected get dataConverter(): LoadedDataConverter {
return this.options.loadedDataConverter;
}
/**
* Set the deadline for any service requests executed in `fn`'s scope.
*/
async withDeadline<R>(deadline: number | Date, fn: () => Promise<R>): Promise<R> {
return await this.connection.withDeadline(deadline, fn);
}
/**
* Set metadata for any service requests executed in `fn`'s scope.
*
* @returns returned value of `fn`
*
* @see {@link Connection.withMetadata}
*/
async withMetadata<R>(metadata: Metadata, fn: () => Promise<R>): Promise<R> {
return await this.connection.withMetadata(metadata, fn);
}
/**
* Start a new Workflow execution.

@@ -370,3 +357,3 @@ *

options: WithWorkflowArgs<T, WorkflowOptions>,
interceptors: WorkflowClientCallsInterceptor[]
interceptors: WorkflowClientInterceptor[]
): Promise<string> {

@@ -395,3 +382,3 @@ const workflowType = typeof workflowTypeOrFunc === 'string' ? workflowTypeOrFunc : workflowTypeOrFunc.name;

options: WithWorkflowArgs<T, WorkflowSignalWithStartOptions<SA>>,
interceptors: WorkflowClientCallsInterceptor[]
interceptors: WorkflowClientInterceptor[]
): Promise<string> {

@@ -428,4 +415,3 @@ const workflowType = typeof workflowTypeOrFunc === 'string' ? workflowTypeOrFunc : workflowTypeOrFunc.name;

const { workflowId } = options;
// Cast is needed because it's impossible to deduce the type in this situation
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
const interceptors = this.getOrMakeInterceptors(workflowId);
const runId = await this._start(workflowTypeOrFunc, { ...options, workflowId }, interceptors);

@@ -457,3 +443,3 @@ // runId is not used in handles created with `start*` calls because these

const { workflowId } = options;
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
const interceptors = this.getOrMakeInterceptors(workflowId);
const runId = await this._signalWithStart(workflowTypeOrFunc, options, interceptors);

@@ -484,3 +470,3 @@ // runId is not used in handles created with `start*` calls because these

const { workflowId } = options;
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
const interceptors = this.getOrMakeInterceptors(workflowId);
await this._start(workflowTypeOrFunc, options, interceptors);

@@ -874,35 +860,22 @@ return await this.result(workflowId, undefined, {

});
return {
/* eslint-disable @typescript-eslint/no-non-null-assertion */
type: raw.workflowExecutionInfo!.type!.name!,
workflowId: raw.workflowExecutionInfo!.execution!.workflowId!,
runId: raw.workflowExecutionInfo!.execution!.runId!,
taskQueue: raw.workflowExecutionInfo!.taskQueue!,
status: {
code: raw.workflowExecutionInfo!.status!,
name: workflowStatusCodeToName(raw.workflowExecutionInfo!.status!),
},
// Safe to convert to number, max history length is 50k, which is much less than Number.MAX_SAFE_INTEGER
historyLength: raw.workflowExecutionInfo!.historyLength!.toNumber(),
startTime: tsToDate(raw.workflowExecutionInfo!.startTime!),
executionTime: optionalTsToDate(raw.workflowExecutionInfo!.executionTime),
closeTime: optionalTsToDate(raw.workflowExecutionInfo!.closeTime),
memo: await decodeMapFromPayloads(this.client.dataConverter, raw.workflowExecutionInfo!.memo?.fields),
searchAttributes: Object.fromEntries(
Object.entries(
mapFromPayloads(
searchAttributePayloadConverter,
raw.workflowExecutionInfo!.searchAttributes?.indexedFields ?? {}
) as SearchAttributes
).filter(([_, v]) => v && v.length > 0) // Filter out empty arrays returned by pre 1.18 servers
),
parentExecution: raw.workflowExecutionInfo?.parentExecution
? {
workflowId: raw.workflowExecutionInfo.parentExecution.workflowId!,
runId: raw.workflowExecutionInfo.parentExecution.runId!,
}
: undefined,
raw,
};
const info = await executionInfoFromRaw(raw.workflowExecutionInfo ?? {}, this.client.dataConverter);
(info as unknown as WorkflowExecutionDescription).raw = raw;
return info;
},
async fetchHistory() {
let nextPageToken: Uint8Array | undefined = undefined;
const events = Array<temporal.api.history.v1.IHistoryEvent>();
for (;;) {
const response: temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryResponse =
await this.client.workflowService.getWorkflowExecutionHistory({
nextPageToken,
namespace: this.client.options.namespace,
execution: { workflowId, runId },
});
events.push(...(response.history?.events ?? []));
nextPageToken = response.nextPageToken;
if (nextPageToken == null || nextPageToken.length === 0) break;
}
return temporal.api.history.v1.History.create({ events });
},
async signal<Args extends any[]>(def: SignalDefinition<Args> | string, ...args: Args): Promise<void> {

@@ -955,3 +928,3 @@ const next = this.client._signalWorkflowHandler.bind(this.client);

): WorkflowHandle<T> {
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId, runId }));
const interceptors = this.getOrMakeInterceptors(workflowId, runId);

@@ -967,2 +940,57 @@ return this._createWorkflowHandle({

}
protected async *_list(options?: ListOptions): AsyncIterable<WorkflowExecutionInfo> {
let nextPageToken: Uint8Array = Buffer.alloc(0);
for (;;) {
const response = await this.workflowService.listWorkflowExecutions({
namespace: this.options.namespace,
query: options?.query,
nextPageToken,
pageSize: options?.pageSize,
});
// Not decoding memo payloads concurrently even though we could have to keep the lazy nature of this iterator.
// Decoding is done for `memo` fields which tend to be small.
// We might decide to change that based on user feedback.
for (const raw of response.executions) {
yield await executionInfoFromRaw(raw, this.dataConverter);
}
nextPageToken = response.nextPageToken;
if (nextPageToken == null || nextPageToken.length === 0) break;
}
}
/**
* List workflows by given `query`.
*
* ⚠️ To use advanced query functionality, as of the 1.18 server release, you must use Elasticsearch based visibility.
*
* More info on the concept of "visibility" and the query syntax on the Temporal documentation site:
* https://docs.temporal.io/visibility
*/
public list(options?: ListOptions): AsyncWorkflowListIterable {
return {
[Symbol.asyncIterator]: () => this._list(options)[Symbol.asyncIterator](),
intoHistories: (intoHistoriesOptions?: IntoHistoriesOptions) => {
return mapAsyncIterable(
this._list(options),
async ({ workflowId, runId }) => ({
workflowId,
history: await this.getHandle(workflowId, runId)
.fetchHistory()
.catch((_) => undefined),
}),
{ concurrency: intoHistoriesOptions?.concurrency ?? 5 }
);
},
};
}
protected getOrMakeInterceptors(workflowId: string, runId?: string): WorkflowClientInterceptor[] {
if (typeof this.options.interceptors === 'object' && 'calls' in this.options.interceptors) {
// eslint-disable-next-line deprecation/deprecation
const factories = (this.options.interceptors as WorkflowClientInterceptors).calls ?? [];
return factories.map((ctor) => ctor({ workflowId, runId }));
}
return Array.isArray(this.options.interceptors) ? (this.options.interceptors as WorkflowClientInterceptor[]) : [];
}
}

@@ -983,31 +1011,1 @@

}
function workflowStatusCodeToName(code: temporal.api.enums.v1.WorkflowExecutionStatus): WorkflowExecutionStatusName {
return workflowStatusCodeToNameInternal(code) ?? 'UNKNOWN';
}
/**
* Intentionally leave out `default` branch to get compilation errors when new values are added
*/
function workflowStatusCodeToNameInternal(
code: temporal.api.enums.v1.WorkflowExecutionStatus
): WorkflowExecutionStatusName {
switch (code) {
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_UNSPECIFIED:
return 'UNSPECIFIED';
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_RUNNING:
return 'RUNNING';
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_FAILED:
return 'FAILED';
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_TIMED_OUT:
return 'TIMED_OUT';
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_CANCELED:
return 'CANCELLED';
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_TERMINATED:
return 'TERMINATED';
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_COMPLETED:
return 'COMPLETED';
case temporal.api.enums.v1.WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_CONTINUED_AS_NEW:
return 'CONTINUED_AS_NEW';
}
}

@@ -1,2 +0,8 @@

import { CommonWorkflowOptions, SignalDefinition, WithCompiledWorkflowOptions } from '@temporalio/common';
import {
CommonWorkflowOptions,
SignalDefinition,
WithCompiledWorkflowOptions,
WithWorkflowArgs,
Workflow,
} from '@temporalio/common';

@@ -63,1 +69,6 @@ export * from '@temporalio/common/lib/workflow-options';

}
/**
* Options for starting a Workflow
*/
export type WorkflowStartOptions<T extends Workflow = Workflow> = WithWorkflowArgs<T, WorkflowOptions>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc