You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@temporalio/client

Package Overview
Dependencies
6
Maintainers
4
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.1 to 0.7.0

58

lib/workflow-client.d.ts
import { temporal } from '@temporalio/proto';
import { WorkflowClientInterceptors } from './interceptors';
import { DataConverter, Workflow, WorkflowSignalType, WorkflowQueryType, BaseWorkflowStub } from '@temporalio/common';
import { EnsurePromise } from '@temporalio/common/lib/type-helpers';
import { DataConverter, Workflow, WorkflowSignalType, WorkflowQueryType, BaseWorkflowHandle, WorkflowSignalHandlers, WorkflowResultType, WorkflowQueryHandlers } from '@temporalio/common';
import { WorkflowOptions } from './workflow-options';

@@ -14,4 +13,4 @@ import { WorkflowCancelInput, WorkflowClientCallsInterceptor, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput } from './interceptors';

* ```ts
* export interface Counter {
* main(initialValue?: number): number;
* export type Counter = () => {
* execute(initialValue?: number): number;
* signals: {

@@ -31,8 +30,8 @@ * increment(amount?: number): void;

* // `lib/workflows/counter.js` after building the typescript project
* const workflow = connection.stub<Counter>('counter', { taskQueue: 'tutorial' });
* // start workflow main function with initialValue of 2 and await its completion
* const workflow = connection.createWorkflowHandle<Counter>('counter', { taskQueue: 'tutorial' });
* // start workflow `execute` function with initialValue of 2 and await its completion
* await workflow.execute(2);
* ```
*/
export interface WorkflowStub<T extends Workflow> extends BaseWorkflowStub<T> {
export interface WorkflowHandle<T extends Workflow> extends BaseWorkflowHandle<T> {
/**

@@ -46,4 +45,4 @@ * A mapping of the different queries defined by Workflow interface `T` to callable functions.

*/
query: T extends Record<'queries', Record<string, WorkflowQueryType>> ? {
[P in keyof T['queries']]: (...args: Parameters<T['queries'][P]>) => Promise<ReturnType<T['queries'][P]>>;
query: WorkflowQueryHandlers<T> extends Record<string, WorkflowQueryType> ? {
[P in keyof WorkflowQueryHandlers<T>]: (...args: Parameters<WorkflowQueryHandlers<T>[P]>) => Promise<ReturnType<WorkflowQueryHandlers<T>[P]>>;
} : undefined;

@@ -54,3 +53,3 @@ /**

*/
signalWithStart: T extends Record<'signals', Record<string, WorkflowSignalType>> ? <S extends keyof T['signals']>(signalName: S, signalArgs: Parameters<T['signals'][S]>, workflowArgs: Parameters<T['main']>) => Promise<string> : never;
signalWithStart: WorkflowSignalHandlers<T> extends Record<string, WorkflowSignalType> ? <S extends keyof WorkflowSignalHandlers<T>>(signalName: S, signalArgs: Parameters<WorkflowSignalHandlers<T>[S]>, workflowArgs: Parameters<T>) => Promise<string> : never;
/**

@@ -106,3 +105,3 @@ * Terminate a running Workflow

/**
* Client for starting Workflow executions and creating Workflow stubs
* Client for starting Workflow executions and creating Workflow handles
*/

@@ -114,13 +113,13 @@ export declare class WorkflowClient {

/**
* Starts a new Workflow execution
* Start a new Workflow execution. Resolves with the execution `runId`.
*/
start<T extends Workflow>(opts: WorkflowOptions, name: string, ...args: Parameters<T['main']>): Promise<string>;
start<T extends Workflow>(opts: WorkflowOptions, name: string, ...args: Parameters<T>): Promise<string>;
/**
* Starts a new Workflow execution and awaits its completion
*/
execute<T extends Workflow>(opts: WorkflowOptions, name: string, ...args: Parameters<T['main']>): EnsurePromise<ReturnType<T['main']>>;
execute<T extends Workflow>(opts: WorkflowOptions, name: string, ...args: Parameters<T>): WorkflowResultType<T>;
/**
* Gets the result of a Workflow execution
*/
result<T extends Workflow>(workflowId: string, runId?: string): EnsurePromise<ReturnType<T['main']>>;
result<T extends Workflow>(workflowId: string, runId?: string): ReturnType<T['execute']>;
/**

@@ -163,28 +162,31 @@ * Uses given input to make a queryWorkflow call to the service

/**
* Create a {@link WorkflowStub} for a new Workflow execution
* Create a {@link WorkflowHandle} for starting a new Workflow execution
*
* @param name workflow type name (the filename in the Node.js SDK)
* @param name workflow type name (the exported function name in the Node.js SDK)
* @param options used to start the Workflow
*/
stub<T extends Workflow>(name: string, options: WorkflowOptions): WorkflowStub<T>;
createWorkflowHandle<T extends Workflow>(name: string, options: WorkflowOptions): WorkflowHandle<T>;
/**
* Create a {@link WorkflowStub} for an existing Workflow execution
* Create a {@link WorkflowHandle} for starting a new Workflow execution
*
* @param func an exported function
* @param options used to start the Workflow
*/
stub<T extends Workflow>(workflowId: string): WorkflowStub<T>;
createWorkflowHandle<T extends Workflow>(func: T, options: WorkflowOptions): WorkflowHandle<T>;
/**
* Create a {@link WorkflowStub} for an existing Workflow run
* Create a {@link WorkflowHandle} for an existing Workflow execution
*/
stub<T extends Workflow>(workflowId: string, runId: string): WorkflowStub<T>;
createWorkflowHandle<T extends Workflow>(workflowId: string, runId?: string): WorkflowHandle<T>;
/**
* Create a new workflow stub for new or existing Workflow execution
* Create a new workflow handle for new or existing Workflow execution
*/
protected createWorkflowStub<T extends Workflow>(workflowId: string, runId: string | undefined, interceptors: WorkflowClientCallsInterceptor[], start: WorkflowStub<T>['start'], signalWithStart: WorkflowStub<T>['signalWithStart']): WorkflowStub<T>;
protected _createWorkflowHandle<T extends Workflow>(workflowId: string, runId: string | undefined, interceptors: WorkflowClientCallsInterceptor[], start: WorkflowHandle<T>['start'], signalWithStart: WorkflowHandle<T>['signalWithStart']): WorkflowHandle<T>;
/**
* Creates a Workflow stub for existing Workflow using `workflowId` and optional `runId`
* Creates a Workflow handle for existing Workflow using `workflowId` and optional `runId`
*/
protected connectToExistingWorkflow<T extends Workflow>(workflowId: string, runId?: string): WorkflowStub<T>;
protected connectToExistingWorkflow<T extends Workflow>(workflowId: string, runId?: string): WorkflowHandle<T>;
/**
* Creates a Workflow stub for new Workflow execution
* Creates a Workflow handle for new Workflow execution
*/
protected createNewWorkflow<T extends Workflow>(name: string, options: WorkflowOptions): WorkflowStub<T>;
protected createNewWorkflow<T extends Workflow>(name: string, options: WorkflowOptions): WorkflowHandle<T>;
}

@@ -191,0 +193,0 @@ export declare class QueryRejectedError extends Error {

@@ -45,3 +45,3 @@ "use strict";

/**
* Client for starting Workflow executions and creating Workflow stubs
* Client for starting Workflow executions and creating Workflow handles
*/

@@ -54,3 +54,3 @@ class WorkflowClient {

/**
* Starts a new Workflow execution
* Start a new Workflow execution. Resolves with the execution `runId`.
*/

@@ -63,3 +63,3 @@ async start(opts, name, ...args) {

options: compiledOptions,
headers: new Map(),
headers: {},
args,

@@ -214,3 +214,3 @@ name,

cronSchedule: options.cronSchedule,
header: { fields: Object.fromEntries(headers.entries()) },
header: { fields: headers },
});

@@ -250,3 +250,3 @@ return runId;

cronSchedule: opts.cronSchedule,
header: { fields: Object.fromEntries(headers.entries()) },
header: { fields: headers },
};

@@ -282,5 +282,10 @@ const res = await this.service.startWorkflowExecution(req);

}
stub(nameOrWorkflowId, optionsOrRunId) {
createWorkflowHandle(nameOrWorkflowIdOrFunc, optionsOrRunId) {
const nameOrWorkflowId = typeof nameOrWorkflowIdOrFunc === 'string'
? nameOrWorkflowIdOrFunc
: typeof nameOrWorkflowIdOrFunc === 'function'
? nameOrWorkflowIdOrFunc.name
: undefined;
if (typeof nameOrWorkflowId !== 'string') {
throw new TypeError(`Invalid argument: ${nameOrWorkflowId}, expected a string with the Workflow filename or Workflow ID`);
throw new TypeError(`Invalid argument: ${nameOrWorkflowIdOrFunc}, expected a Workflow function or a string with the Workflow name or Workflow ID`);
}

@@ -306,5 +311,5 @@ if (optionsOrRunId === undefined) {

/**
* Create a new workflow stub for new or existing Workflow execution
* Create a new workflow handle for new or existing Workflow execution
*/
createWorkflowStub(workflowId, runId, interceptors, start, signalWithStart) {
_createWorkflowHandle(workflowId, runId, interceptors, start, signalWithStart) {
const namespace = this.options.namespace;

@@ -315,3 +320,3 @@ const workflow = {

execute(...args) {
// Typescript doesn't know how to unpack EnsurePromise, cast to any
// TODO: fix the type here
return this.start(...args).then(() => this.result());

@@ -389,3 +394,3 @@ },

/**
* Creates a Workflow stub for existing Workflow using `workflowId` and optional `runId`
* Creates a Workflow handle for existing Workflow using `workflowId` and optional `runId`
*/

@@ -397,3 +402,3 @@ connectToExistingWorkflow(workflowId, runId) {

};
return this.createWorkflowStub(workflowId, runId, interceptors, startCallback,
return this._createWorkflowHandle(workflowId, runId, interceptors, startCallback,
// Requires cast because workflow signals are optional which complicate the type

@@ -403,3 +408,3 @@ startCallback);

/**
* Creates a Workflow stub for new Workflow execution
* Creates a Workflow handle for new Workflow execution
*/

@@ -413,3 +418,3 @@ createNewWorkflow(name, options) {

options: compiledOptions,
headers: new Map(),
headers: {},
args,

@@ -423,3 +428,3 @@ name,

options: compiledOptions,
headers: new Map(),
headers: {},
workflowArgs,

@@ -431,3 +436,3 @@ workflowName: name,

};
return this.createWorkflowStub(compiledOptions.workflowId, undefined, interceptors, start,
return this._createWorkflowHandle(compiledOptions.workflowId, undefined, interceptors, start,
// Requires cast because workflow signals are optional which complicate the type

@@ -434,0 +439,0 @@ signalWithStart);

{
"name": "@temporalio/client",
"version": "0.6.1",
"version": "0.7.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.2.0",
"@temporalio/proto": "^0.3.1",
"@temporalio/common": "^0.3.0",
"@temporalio/proto": "^0.3.2",
"ms": "^2.1.3",

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

},
"gitHead": "254e9f5793afc11cb5fb64a9829b1c55190092f0"
"gitHead": "23da8507a90049774cc6ddd28a8ec3dfc37d345f"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc