Socket
Socket
Sign inDemoInstall

@temporalio/client

Package Overview
Dependencies
Maintainers
4
Versions
80
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 0.15.0 to 0.16.0

31

lib/workflow-client.d.ts
import { temporal } from '@temporalio/proto';
import { WorkflowClientInterceptors } from './interceptors';
import { DataConverter, Workflow, BaseWorkflowHandle, QueryDefinition, WorkflowResultType, WithWorkflowArgs, WorkflowReturnType } from '@temporalio/common';
import { DataConverter, Workflow, BaseWorkflowHandle, QueryDefinition, WorkflowResultType, WithWorkflowArgs } from '@temporalio/common';
import { WorkflowOptions, WorkflowSignalWithStartOptions } from './workflow-options';

@@ -103,9 +103,2 @@ import { WorkflowCancelInput, WorkflowClientCallsInterceptor, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput } from './interceptors';

queryRejectCondition?: temporal.api.enums.v1.QueryRejectCondition;
/**
* Apply default options for starting new Workflows.
*
* These defaults are **shallowly** merged with options provided to methods that start Workflows
* e.g. {@link WorkflowClient.start}.
*/
workflowDefaults?: Partial<WorkflowOptions>;
}

@@ -131,3 +124,3 @@ export declare type WorkflowClientOptionsWithDefaults = Required<WorkflowClientOptions>;

*/
export declare type WorkflowStartOptions<T extends Workflow> = WithWorkflowArgs<T, Partial<WorkflowOptions>>;
export declare type WorkflowStartOptions<T extends Workflow> = WithWorkflowArgs<T, WorkflowOptions>;
/**

@@ -145,3 +138,3 @@ * Client for starting Workflow executions and creating Workflow handles

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

@@ -157,12 +150,4 @@ * Sends a signal to a running Workflow or starts a new one if not already running and immediately signals it.

*
* **Override for Workflows that accept no arguments**.
*
* @returns a WorkflowHandle to the started Workflow
*/
start<T extends () => WorkflowReturnType>(workflowTypeOrFunc: string | T): Promise<WorkflowHandleWithRunId<T>>;
/**
* Start a new Workflow execution.
*
* @returns a WorkflowHandle to the started Workflow
*/
start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WorkflowStartOptions<T>): Promise<WorkflowHandleWithRunId<T>>;

@@ -183,10 +168,2 @@ /**

/**
* Starts a new Workflow execution and awaits its completion.
*
* **Override for Workflows that accept no arguments**.
*
* @returns the result of the Workflow execution
*/
execute<T extends () => WorkflowReturnType>(workflowTypeOrFunc: string | T): Promise<WorkflowResultType<T>>;
/**
* Gets the result of a Workflow execution.

@@ -240,3 +217,3 @@ *

*/
getHandle<T extends Workflow>(workflowId: string, runId?: string): WorkflowHandle<T>;
getHandle<T extends Workflow>(workflowId: string, runId?: string, options?: WorkflowResultOptions): WorkflowHandle<T>;
}

@@ -243,0 +220,0 @@ export declare class QueryRejectedError extends Error {

44

lib/workflow-client.js

@@ -22,3 +22,2 @@ "use strict";

queryRejectCondition: proto_1.temporal.api.enums.v1.QueryRejectCondition.QUERY_REJECT_CONDITION_UNSPECIFIED,
workflowDefaults: {},
};

@@ -31,3 +30,10 @@ }

}
if (!opts.workflowId) {
throw new TypeError('Missing WorkflowOptions.workflowId');
}
}
function ensureArgs(opts) {
const { args, ...rest } = opts;
return { args: args ?? [], ...rest };
}
/**

@@ -49,3 +55,3 @@ * Client for starting Workflow executions and creating Workflow handles

assertRequiredWorkflowOptions(options);
const compiledOptions = (0, workflow_options_1.compileWorkflowOptions)((0, workflow_options_1.addDefaults)(options));
const compiledOptions = (0, workflow_options_1.compileWorkflowOptions)(ensureArgs(options));
const start = (0, common_1.composeInterceptors)(interceptors, 'start', this._startWorkflowHandler.bind(this));

@@ -68,3 +74,3 @@ return start({

assertRequiredWorkflowOptions(rest);
const compiledOptions = (0, workflow_options_1.compileWorkflowOptions)((0, workflow_options_1.addDefaults)(rest));
const compiledOptions = (0, workflow_options_1.compileWorkflowOptions)(ensureArgs(rest));
const signalWithStart = (0, common_1.composeInterceptors)(interceptors, 'signalWithStart', this._signalWithStartWorkflowHandler.bind(this));

@@ -79,6 +85,10 @@ return signalWithStart({

}
async start(workflowTypeOrFunc, maybeOptions) {
/**
* Start a new Workflow execution.
*
* @returns a WorkflowHandle to the started Workflow
*/
async start(workflowTypeOrFunc, options) {
const { workflowId } = options;
// Cast is needed because it's impossible to deduce the type in this situation
const options = { ...this.options.workflowDefaults, ...maybeOptions };
const workflowId = options.workflowId ?? (0, uuid_1.v4)();
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));

@@ -99,6 +109,5 @@ const runId = await this._start(workflowTypeOrFunc, { ...options, workflowId }, interceptors);

async signalWithStart(workflowTypeOrFunc, options) {
options = { ...this.options.workflowDefaults, ...options };
const workflowId = options.workflowId ?? (0, uuid_1.v4)();
const { workflowId } = options;
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
const runId = await this._signalWithStart(workflowTypeOrFunc, { ...options, workflowId }, interceptors);
const runId = await this._signalWithStart(workflowTypeOrFunc, options, interceptors);
const handle = this._createWorkflowHandle(workflowId, runId, interceptors, {

@@ -110,8 +119,11 @@ followRuns: options.followRuns ?? true,

}
async execute(workflowTypeOrFunc, maybeOptions) {
// Cast is needed because it's impossible to deduce the type in this situation
const options = { ...this.options.workflowDefaults, ...maybeOptions };
const workflowId = options.workflowId ?? (0, uuid_1.v4)();
/**
* Starts a new Workflow execution and awaits its completion.
*
* @returns the result of the Workflow execution
*/
async execute(workflowTypeOrFunc, options) {
const { workflowId } = options;
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId }));
await this._start(workflowTypeOrFunc, { ...options, workflowId }, interceptors);
await this._start(workflowTypeOrFunc, options, interceptors);
return await this.result(workflowId, undefined, {

@@ -409,6 +421,6 @@ followRuns: options.followRuns ?? true,

*/
getHandle(workflowId, runId) {
getHandle(workflowId, runId, options) {
const interceptors = (this.options.interceptors.calls ?? []).map((ctor) => ctor({ workflowId, runId }));
return this._createWorkflowHandle(workflowId, runId, interceptors, {
followRuns: this.options.workflowDefaults.followRuns ?? true,
followRuns: options?.followRuns ?? true,
});

@@ -415,0 +427,0 @@ }

@@ -1,5 +0,16 @@

import { WithWorkflowArgs, WorkflowOptions as CommonWorkflowOptions, WorkflowOptionsWithDefaults as CommonWorkflowOptionsWithDefaults, SignalDefinition, Workflow } from '@temporalio/common';
export { CompiledWorkflowOptions, compileWorkflowOptions } from '@temporalio/common';
import { WithCompiledWorkflowDurationOptions, CommonWorkflowOptions, SignalDefinition } from '@temporalio/common';
export { WithCompiledWorkflowDurationOptions, compileWorkflowOptions } from '@temporalio/common';
export interface CompiledWorkflowOptions extends WithCompiledWorkflowDurationOptions<WorkflowOptions> {
args: unknown[];
}
export interface WorkflowOptions extends CommonWorkflowOptions {
/**
* Workflow id to use when starting.
*
* Assign a meaningful business id.
* This ID can be used to ensure starting Workflows is idempotent.
* Workflow IDs are unique, see also {@link WorkflowOptions.workflowIdReusePolicy}
*/
workflowId: string;
/**
* Task queue to use for Workflow tasks. It should match a task queue specified when creating a

@@ -9,5 +20,13 @@ * `Worker` that hosts the Workflow code.

taskQueue: string;
/**
* If set to true, instructs the client to follow the chain of execution before returning a Workflow's result.
*
* Workflow execution is chained if the Workflow has a cron schedule or continues-as-new or configured to retry
* after failure or timeout.
*
* @default true
*/
followRuns?: boolean;
}
export interface WorkflowSignalWithStartOptions<SA extends any[] = []> extends Partial<WorkflowOptions> {
export interface WorkflowSignalWithStartOptions<SA extends any[] = []> extends WorkflowOptions {
/**

@@ -22,16 +41,1 @@ * SignalDefinition or name of signal

}
export interface WorkflowOptionsWithDefaults<T extends Workflow> extends CommonWorkflowOptionsWithDefaults<T> {
/**
* If set to true, instructs the client to follow the chain of execution before returning a Workflow's result.
*
* Workflow execution is chained if the Workflow has a cron schedule or continues-as-new or configured to retry
* after failure or timeout.
*
* @default true
*/
followRuns: boolean;
}
/**
* Adds default values to `workflowId` and `workflowIdReusePolicy` to given workflow options.
*/
export declare function addDefaults<T extends Workflow>(opts: WithWorkflowArgs<T, WorkflowOptions>): WorkflowOptionsWithDefaults<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addDefaults = exports.compileWorkflowOptions = void 0;
const uuid_1 = require("uuid");
exports.compileWorkflowOptions = void 0;
var common_1 = require("@temporalio/common");
Object.defineProperty(exports, "compileWorkflowOptions", { enumerable: true, get: function () { return common_1.compileWorkflowOptions; } });
/**
* Adds default values to `workflowId` and `workflowIdReusePolicy` to given workflow options.
*/
function addDefaults(opts) {
const { workflowId, args, ...rest } = opts;
return {
followRuns: true,
args: args ?? [],
workflowId: workflowId ?? (0, uuid_1.v4)(),
...rest,
};
}
exports.addDefaults = addDefaults;
// export interface WorkflowOptionsWithDefaults<T extends Workflow> extends CommonWorkflowOptionsWithDefaults<T> {
// /**
// * If set to true, instructs the client to follow the chain of execution before returning a Workflow's result.
// *
// * Workflow execution is chained if the Workflow has a cron schedule or continues-as-new or configured to retry
// * after failure or timeout.
// *
// * @default true
// */
// followRuns: boolean;
// }
//
// /**
// * Adds default values to `workflowId` and `workflowIdReusePolicy` to given workflow options.
// */
// export function addDefaults<T extends Workflow>(
// opts: WithWorkflowArgs<T, WorkflowOptions>
// ): WorkflowOptionsWithDefaults<T> {
// const { workflowId, args, ...rest } = opts;
// return {
// followRuns: true,
// args: args ?? [],
// workflowId: workflowId ?? uuid4(),
// ...rest,
// };
// }
//# sourceMappingURL=workflow-options.js.map
{
"name": "@temporalio/client",
"version": "0.15.0",
"version": "0.16.0",
"description": "Temporal.io SDK Client sub-package",

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

"@grpc/grpc-js": "^1.3.7",
"@temporalio/common": "^0.15.0",
"@temporalio/proto": "^0.15.0",
"@temporalio/common": "^0.16.0",
"@temporalio/proto": "^0.16.0",
"ms": "^2.1.3",

@@ -34,3 +34,3 @@ "protobufjs": "^6.11.2",

},
"gitHead": "81960030b31d52200129d6ea9ebfaa12771dcc45"
"gitHead": "42638434f033db2b55c43c2a9a7751d883ba17ec"
}

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