@temporalio/client 1.8.5 → 1.9.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ import 'abort-controller/polyfill';
1
3
  import { DataConverter, LoadedDataConverter } from '@temporalio/common';
2
4
  import { ConnectionLike, Metadata } from './types';
3
5
  export interface BaseClientOptions {
@@ -41,6 +43,15 @@ export declare class BaseClient {
41
43
  * Set the deadline for any service requests executed in `fn`'s scope.
42
44
  */
43
45
  withDeadline<R>(deadline: number | Date, fn: () => Promise<R>): Promise<R>;
46
+ /**
47
+ * Set an {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} that, when aborted,
48
+ * cancels any ongoing service requests executed in `fn`'s scope.
49
+ *
50
+ * @returns value returned from `fn`
51
+ *
52
+ * @see {@link Connection.withAbortSignal}
53
+ */
54
+ withAbortSignal<R>(abortSignal: AbortSignal, fn: () => Promise<R>): Promise<R>;
44
55
  /**
45
56
  * Set metadata for any service requests executed in `fn`'s scope.
46
57
  *
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BaseClient = exports.defaultBaseClientOptions = void 0;
7
+ // Keep this around until we drop support for Node 14.
8
+ require("abort-controller/polyfill"); // eslint-disable-line import/no-unassigned-import
7
9
  const node_os_1 = __importDefault(require("node:os"));
8
10
  const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
9
11
  const connection_1 = require("./connection");
@@ -27,6 +29,17 @@ class BaseClient {
27
29
  async withDeadline(deadline, fn) {
28
30
  return await this.connection.withDeadline(deadline, fn);
29
31
  }
32
+ /**
33
+ * Set an {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} that, when aborted,
34
+ * cancels any ongoing service requests executed in `fn`'s scope.
35
+ *
36
+ * @returns value returned from `fn`
37
+ *
38
+ * @see {@link Connection.withAbortSignal}
39
+ */
40
+ async withAbortSignal(abortSignal, fn) {
41
+ return await this.connection.withAbortSignal(abortSignal, fn);
42
+ }
30
43
  /**
31
44
  * Set metadata for any service requests executed in `fn`'s scope.
32
45
  *
@@ -1 +1 @@
1
- {"version":3,"file":"base-client.js","sourceRoot":"","sources":["../src/base-client.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AAEzB,wFAAwG;AACxG,6CAA0C;AAyC1C,SAAgB,wBAAwB;IACtC,OAAO;QACL,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,IAAI,iBAAE,CAAC,QAAQ,EAAE,EAAE;QAC3C,SAAS,EAAE,SAAS;KACrB,CAAC;AACJ,CAAC;AAND,4DAMC;AAED,MAAa,UAAU;IAIrB,YAAsB,OAA2B;QAC/C,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,uBAAU,CAAC,IAAI,EAAE,CAAC;QAC3D,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,EAAE,CAAC;QACnD,IAAI,CAAC,mBAAmB,GAAG,IAAA,6CAAqB,EAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAA,yCAAiB,EAAC,aAAa,CAAC,CAAC;IACrH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,YAAY,CAAI,QAAuB,EAAE,EAAoB;QACxE,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,YAAY,CAAI,QAAkB,EAAE,EAAoB;QACnE,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,IAAc,aAAa;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IA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IAAc,aAAa;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;CACF;AA3CD,gCA2CC"}
@@ -1,4 +1,6 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import 'abort-controller/polyfill';
2
4
  import { AsyncLocalStorage } from 'node:async_hooks';
3
5
  import * as grpc from '@grpc/grpc-js';
4
6
  import type { RPCImpl } from 'protobufjs';
@@ -17,19 +19,44 @@ export interface ConnectionOptions {
17
19
  */
18
20
  address?: string;
19
21
  /**
20
- * TLS configuration.
21
- * Pass a falsy value to use a non-encrypted connection or `true` or `{}` to
22
- * connect with TLS without any customization.
22
+ * TLS configuration. Pass a falsy value to use a non-encrypted connection,
23
+ * or `true` or `{}` to connect with TLS without any customization.
24
+ *
25
+ * For advanced scenario, a prebuilt {@link grpc.ChannelCredentials} object
26
+ * may instead be specified using the {@link credentials} property.
23
27
  *
24
28
  * Either {@link credentials} or this may be specified for configuring TLS
29
+ *
30
+ * @default TLS is disabled
25
31
  */
26
32
  tls?: TLSConfig | boolean | null;
27
33
  /**
28
- * Channel credentials, create using the factory methods defined {@link https://grpc.github.io/grpc/node/grpc.credentials.html | here}
34
+ * gRPC channel credentials.
35
+ *
36
+ * `ChannelCredentials` are things like SSL credentials that can be used to secure a connection.
37
+ * There may be only one `ChannelCredentials`. They can be created using some of the factory
38
+ * methods defined {@link https://grpc.github.io/grpc/node/grpc.credentials.html | here}
39
+ *
40
+ * Specifying a prebuilt `ChannelCredentials` should only be required for advanced use cases.
41
+ * For simple TLS use cases, using the {@link tls} property is recommended. To register
42
+ * `CallCredentials` (eg. metadata-based authentication), use the {@link callCredentials} property.
29
43
  *
30
44
  * Either {@link tls} or this may be specified for configuring TLS
31
45
  */
32
46
  credentials?: grpc.ChannelCredentials;
47
+ /**
48
+ * gRPC call credentials.
49
+ *
50
+ * `CallCredentials` generaly modify metadata; they can be attached to a connection to affect all method
51
+ * calls made using that connection. They can be created using some of the factory methods defined
52
+ * {@link https://grpc.github.io/grpc/node/grpc.credentials.html | here}
53
+ *
54
+ * If `callCredentials` are specified, they will be composed with channel credentials
55
+ * (either the one created implicitely by using the {@link tls} option, or the one specified
56
+ * explicitly through {@link credentials}). Notice that gRPC doesn't allow registering
57
+ * `callCredentials` on insecure connections.
58
+ */
59
+ callCredentials?: grpc.CallCredentials[];
33
60
  /**
34
61
  * GRPC Channel arguments
35
62
  *
@@ -74,7 +101,7 @@ export interface ConnectionOptions {
74
101
  */
75
102
  connectTimeout?: Duration;
76
103
  }
77
- export type ConnectionOptionsWithDefaults = Required<Omit<ConnectionOptions, 'tls' | 'connectTimeout'>> & {
104
+ export type ConnectionOptionsWithDefaults = Required<Omit<ConnectionOptions, 'tls' | 'connectTimeout' | 'callCredentials'>> & {
78
105
  connectTimeoutMs: number;
79
106
  };
80
107
  export declare const LOCAL_TARGET = "127.0.0.1:7233";
@@ -129,6 +156,12 @@ export declare class Connection {
129
156
  /**
130
157
  * Raw gRPC access to Temporal Server's
131
158
  * {@link https://github.com/temporalio/api/blob/master/temporal/api/operatorservice/v1/service.proto | Operator service}
159
+ *
160
+ * The Operator Service API defines how Temporal SDKs and other clients interact with the Temporal
161
+ * server to perform administrative functions like registering a search attribute or a namespace.
162
+ *
163
+ * This Service API is NOT compatible with Temporal Cloud. Attempt to use it against a Temporal
164
+ * Cloud namespace will result in gRPC `unauthorized` error.
132
165
  */
133
166
  readonly operatorService: OperatorService;
134
167
  readonly healthService: HealthService;
@@ -165,6 +198,22 @@ export declare class Connection {
165
198
  * @returns value returned from `fn`
166
199
  */
167
200
  withDeadline<ReturnType>(deadline: number | Date, fn: () => Promise<ReturnType>): Promise<ReturnType>;
201
+ /**
202
+ * Set an {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} that, when aborted,
203
+ * cancels any ongoing requests executed in `fn`'s scope.
204
+ *
205
+ * @returns value returned from `fn`
206
+ *
207
+ * @example
208
+ *
209
+ * ```ts
210
+ * const ctrl = new AbortController();
211
+ * setTimeout(() => ctrl.abort(), 10_000);
212
+ * // 👇 throws if incomplete by the timeout.
213
+ * await conn.withAbortSignal(ctrl.signal, () => client.workflow.execute(myWorkflow, options));
214
+ * ```
215
+ */
216
+ withAbortSignal<ReturnType>(abortSignal: AbortSignal, fn: () => Promise<ReturnType>): Promise<ReturnType>;
168
217
  /**
169
218
  * Set metadata for any service requests executed in `fn`'s scope.
170
219
  *
@@ -175,11 +224,11 @@ export declare class Connection {
175
224
  *
176
225
  * @example
177
226
  *
178
- *```ts
179
- *const workflowHandle = await conn.withMetadata({ apiKey: 'secret' }, () =>
180
- * conn.withMetadata({ otherKey: 'set' }, () => client.start(options)))
181
- *);
182
- *```
227
+ * ```ts
228
+ * const workflowHandle = await conn.withMetadata({ apiKey: 'secret' }, () =>
229
+ * conn.withMetadata({ otherKey: 'set' }, () => client.start(options)))
230
+ * );
231
+ * ```
183
232
  */
184
233
  withMetadata<ReturnType>(metadata: Metadata, fn: () => Promise<ReturnType>): Promise<ReturnType>;
185
234
  /**
package/lib/connection.js CHANGED
@@ -27,6 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Connection = exports.LOCAL_TARGET = void 0;
30
+ // Keep this around until we drop support for Node 14.
31
+ require("abort-controller/polyfill"); // eslint-disable-line import/no-unassigned-import
30
32
  const node_async_hooks_1 = require("node:async_hooks");
31
33
  const grpc = __importStar(require("@grpc/grpc-js"));
32
34
  const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
@@ -59,7 +61,7 @@ function addDefaults(options) {
59
61
  * - Add default port to address if port not specified
60
62
  */
61
63
  function normalizeGRPCConfig(options) {
62
- const { tls: tlsFromConfig, credentials, ...rest } = options || {};
64
+ const { tls: tlsFromConfig, credentials, callCredentials, ...rest } = options || {};
63
65
  if (rest.address) {
64
66
  // eslint-disable-next-line prefer-const
65
67
  let [host, port] = rest.address.split(':', 2);
@@ -73,7 +75,7 @@ function normalizeGRPCConfig(options) {
73
75
  }
74
76
  return {
75
77
  ...rest,
76
- credentials: grpc.credentials.createSsl(tls.serverRootCACertificate, tls.clientCertPair?.key, tls.clientCertPair?.crt),
78
+ credentials: grpc.credentials.combineChannelCredentials(grpc.credentials.createSsl(tls.serverRootCACertificate, tls.clientCertPair?.key, tls.clientCertPair?.crt), ...(callCredentials ?? [])),
77
79
  channelArgs: {
78
80
  ...rest.channelArgs,
79
81
  ...(tls.serverNameOverride
@@ -86,7 +88,10 @@ function normalizeGRPCConfig(options) {
86
88
  };
87
89
  }
88
90
  else {
89
- return rest;
91
+ return {
92
+ ...rest,
93
+ credentials: grpc.credentials.combineChannelCredentials(credentials ?? grpc.credentials.createInsecure(), ...(callCredentials ?? [])),
94
+ };
90
95
  }
91
96
  }
92
97
  /**
@@ -199,7 +204,7 @@ class Connection {
199
204
  static generateRPCImplementation({ serviceName, client, callContextStorage, interceptors, staticMetadata, }) {
200
205
  return (method, requestData, callback) => {
201
206
  const metadataContainer = new grpc.Metadata();
202
- const { metadata, deadline } = callContextStorage.getStore() ?? {};
207
+ const { metadata, deadline, abortSignal } = callContextStorage.getStore() ?? {};
203
208
  for (const [k, v] of Object.entries(staticMetadata)) {
204
209
  metadataContainer.set(k, v);
205
210
  }
@@ -208,7 +213,11 @@ class Connection {
208
213
  metadataContainer.set(k, v);
209
214
  }
210
215
  }
211
- return client.makeUnaryRequest(`/${serviceName}/${method.name}`, (arg) => arg, (arg) => arg, requestData, metadataContainer, { interceptors, deadline }, callback);
216
+ const call = client.makeUnaryRequest(`/${serviceName}/${method.name}`, (arg) => arg, (arg) => arg, requestData, metadataContainer, { interceptors, deadline }, callback);
217
+ if (abortSignal != null) {
218
+ abortSignal.addEventListener('abort', () => call.cancel());
219
+ }
220
+ return call;
212
221
  };
213
222
  }
214
223
  /**
@@ -218,7 +227,26 @@ class Connection {
218
227
  */
219
228
  async withDeadline(deadline, fn) {
220
229
  const cc = this.callContextStorage.getStore();
221
- return await this.callContextStorage.run({ deadline, metadata: cc?.metadata }, fn);
230
+ return await this.callContextStorage.run({ ...cc, deadline }, fn);
231
+ }
232
+ /**
233
+ * Set an {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} that, when aborted,
234
+ * cancels any ongoing requests executed in `fn`'s scope.
235
+ *
236
+ * @returns value returned from `fn`
237
+ *
238
+ * @example
239
+ *
240
+ * ```ts
241
+ * const ctrl = new AbortController();
242
+ * setTimeout(() => ctrl.abort(), 10_000);
243
+ * // 👇 throws if incomplete by the timeout.
244
+ * await conn.withAbortSignal(ctrl.signal, () => client.workflow.execute(myWorkflow, options));
245
+ * ```
246
+ */
247
+ async withAbortSignal(abortSignal, fn) {
248
+ const cc = this.callContextStorage.getStore();
249
+ return await this.callContextStorage.run({ ...cc, abortSignal }, fn);
222
250
  }
223
251
  /**
224
252
  * Set metadata for any service requests executed in `fn`'s scope.
@@ -230,16 +258,15 @@ class Connection {
230
258
  *
231
259
  * @example
232
260
  *
233
- *```ts
234
- *const workflowHandle = await conn.withMetadata({ apiKey: 'secret' }, () =>
235
- * conn.withMetadata({ otherKey: 'set' }, () => client.start(options)))
236
- *);
237
- *```
261
+ * ```ts
262
+ * const workflowHandle = await conn.withMetadata({ apiKey: 'secret' }, () =>
263
+ * conn.withMetadata({ otherKey: 'set' }, () => client.start(options)))
264
+ * );
265
+ * ```
238
266
  */
239
267
  async withMetadata(metadata, fn) {
240
268
  const cc = this.callContextStorage.getStore();
241
- metadata = { ...cc?.metadata, ...metadata };
242
- return await this.callContextStorage.run({ metadata, deadline: cc?.deadline }, fn);
269
+ return await this.callContextStorage.run({ ...cc, metadata: { ...cc?.metadata, ...metadata } }, fn);
243
270
  }
244
271
  /**
245
272
  * Wait for successful connection to the server.
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAqD;AACrD,oD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ACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,+GAA+G;IAC/G;;;;OAIG;IACI,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;;AAtQH,gCAuQC;AAtQC;;GAEG;AACoB,iBAAM,GAAG,IAAI,CAAC,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC"}
package/lib/errors.d.ts CHANGED
@@ -23,6 +23,14 @@ export declare class WorkflowFailedError extends Error {
23
23
  readonly retryState: RetryState;
24
24
  constructor(message: string, cause: TemporalFailure | undefined, retryState: RetryState);
25
25
  }
26
+ /**
27
+ * Thrown by the client while waiting on Workflow Update result if Update
28
+ * completes with failure.
29
+ */
30
+ export declare class WorkflowUpdateFailedError extends Error {
31
+ readonly cause: TemporalFailure | undefined;
32
+ constructor(message: string, cause: TemporalFailure | undefined);
33
+ }
26
34
  /**
27
35
  * Thrown the by client while waiting on Workflow execution result if Workflow
28
36
  * continues as new.
package/lib/errors.js CHANGED
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.isServerErrorResponse = exports.isGrpcServiceError = exports.WorkflowContinuedAsNewError = exports.WorkflowFailedError = exports.ServiceError = void 0;
9
+ exports.isServerErrorResponse = exports.isGrpcServiceError = exports.WorkflowContinuedAsNewError = exports.WorkflowUpdateFailedError = exports.WorkflowFailedError = exports.ServiceError = void 0;
10
10
  const type_helpers_1 = require("@temporalio/common/lib/type-helpers");
11
11
  /**
12
12
  * Generic Error class for errors coming from the service
@@ -41,6 +41,20 @@ WorkflowFailedError = __decorate([
41
41
  (0, type_helpers_1.SymbolBasedInstanceOfError)('WorkflowFailedError')
42
42
  ], WorkflowFailedError);
43
43
  exports.WorkflowFailedError = WorkflowFailedError;
44
+ /**
45
+ * Thrown by the client while waiting on Workflow Update result if Update
46
+ * completes with failure.
47
+ */
48
+ let WorkflowUpdateFailedError = class WorkflowUpdateFailedError extends Error {
49
+ constructor(message, cause) {
50
+ super(message);
51
+ this.cause = cause;
52
+ }
53
+ };
54
+ WorkflowUpdateFailedError = __decorate([
55
+ (0, type_helpers_1.SymbolBasedInstanceOfError)('WorkflowUpdateFailedError')
56
+ ], WorkflowUpdateFailedError);
57
+ exports.WorkflowUpdateFailedError = WorkflowUpdateFailedError;
44
58
  /**
45
59
  * Thrown the by client while waiting on Workflow execution result if Workflow
46
60
  * continues as new.
package/lib/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;;;;AAEA,sEAAoG;AAEpG;;GAEG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,KAAK;IAGrC,YAAY,OAAe,EAAE,IAAuB;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC;IAC3B,CAAC;CACF,CAAA;AAPY,YAAY;IADxB,IAAA,yCAA0B,EAAC,cAAc,CAAC;GAC9B,YAAY,CAOxB;AAPY,oCAAY;AASzB;;;;;;;;GAQG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,KAAK;IAC5C,YACE,OAAe,EACC,KAAkC,EAClC,UAAsB;QAEtC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,UAAK,GAAL,KAAK,CAA6B;QAClC,eAAU,GAAV,UAAU,CAAY;IAGxC,CAAC;CACF,CAAA;AARY,mBAAmB;IAD/B,IAAA,yCAA0B,EAAC,qBAAqB,CAAC;GACrC,mBAAmB,CAQ/B;AARY,kDAAmB;AAUhC;;;;;GAKG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,KAAK;IACpD,YAAmB,OAAe,EAA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/B,MAAM,yBAA0B,SAAQ,KAAK;IAClD,YAAmB,OAAe,EAAkB,KAAkC;QACpF,KAAK,CAAC,OAAO,CAAC,CAAC;QADmC,UAAK,GAAL,KAAK,CAA6B;IAEtF,CAAC;CACF,CAAA;AAJY,yBAAyB;IADrC,IAAA,yCAA0B,EAAC,2BAA2B,CAAC;GAC3C,yBAAyB,CAIrC;AAJY,8DAAyB;AAMtC;;;;;GAKG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,KAAK;IACpD,YAAmB,OAAe,EAAkB,iBAAyB;QAC3E,KAAK,CAAC,OAAO,CAAC,CAAC;QADmC,sBAAiB,GAAjB,iBAAiB,CAAQ;IAE7E,CAAC;CACF,CAAA;AAJY,2BAA2B;IADvC,IAAA,yCAA0B,EAAC,sCAAsC,CAAC;GACtD,2BAA2B,CAIvC;AAJY,kEAA2B;AAMxC,SAAgB,kBAAkB,CAAC,GAAY;IAC7C,OAAO,CACL,IAAA,sBAAO,EAAC,GAAG,CAAC;QACZ,OAAQ,GAAwB,EAAE,OAAO,KAAK,QAAQ;QACtD,IAAA,uBAAQ,EAAE,GAAwB,CAAC,QAAQ,CAAC,CAC7C,CAAC;AACJ,CAAC;AAND,gDAMC;AAED;;GAEG;AACU,QAAA,qBAAqB,GAAG,kBAAkB,CAAC"}
@@ -7,8 +7,8 @@ import { Headers, Next } from '@temporalio/common';
7
7
  import { temporal } from '@temporalio/proto';
8
8
  import { CompiledScheduleOptions } from './schedule-types';
9
9
  import { DescribeWorkflowExecutionResponse, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution } from './types';
10
- import { CompiledWorkflowOptions } from './workflow-options';
11
- export { Next, Headers };
10
+ import { CompiledWorkflowOptions, WorkflowUpdateOptions } from './workflow-options';
11
+ export { Headers, Next };
12
12
  /** Input for WorkflowClientInterceptor.start */
13
13
  export interface WorkflowStartInput {
14
14
  /** Name of Workflow to start */
@@ -16,6 +16,21 @@ export interface WorkflowStartInput {
16
16
  readonly headers: Headers;
17
17
  readonly options: CompiledWorkflowOptions;
18
18
  }
19
+ /** Input for WorkflowClientInterceptor.update */
20
+ export interface WorkflowStartUpdateInput {
21
+ readonly updateName: string;
22
+ readonly args: unknown[];
23
+ readonly workflowExecution: WorkflowExecution;
24
+ readonly firstExecutionRunId?: string;
25
+ readonly headers: Headers;
26
+ readonly options: WorkflowUpdateOptions;
27
+ }
28
+ /** Output for WorkflowClientInterceptor.startUpdate */
29
+ export interface WorkflowStartUpdateOutput {
30
+ readonly updateId: string;
31
+ readonly workflowRunId: string;
32
+ readonly outcome?: temporal.api.update.v1.IOutcome;
33
+ }
19
34
  /** Input for WorkflowClientInterceptor.signal */
20
35
  export interface WorkflowSignalInput {
21
36
  readonly signalName: string;
@@ -66,6 +81,12 @@ export interface WorkflowClientInterceptor {
66
81
  * {@link signalWithStart} most likely needs to be implemented too
67
82
  */
68
83
  start?: (input: WorkflowStartInput, next: Next<this, 'start'>) => Promise<string>;
84
+ /**
85
+ * Intercept a service call to updateWorkflowExecution
86
+ *
87
+ * @experimental Update is an experimental feature.
88
+ */
89
+ startUpdate?: (input: WorkflowStartUpdateInput, next: Next<this, 'startUpdate'>) => Promise<WorkflowStartUpdateOutput>;
69
90
  /**
70
91
  * Intercept a service call to signalWorkflowExecution
71
92
  *
package/lib/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import type * as grpc from '@grpc/grpc-js';
2
3
  import type { SearchAttributes } from '@temporalio/common';
3
4
  import * as proto from '@temporalio/proto';
@@ -62,6 +63,7 @@ export interface CallContext {
62
63
  * Metadata to set on gRPC requests
63
64
  */
64
65
  metadata?: Metadata;
66
+ abortSignal?: AbortSignal;
65
67
  }
66
68
  /**
67
69
  * Connection interface used by high level SDK clients.
@@ -83,4 +85,11 @@ export interface ConnectionLike {
83
85
  * @returns returned value of `fn`
84
86
  */
85
87
  withMetadata<R>(metadata: Metadata, fn: () => Promise<R>): Promise<R>;
88
+ /**
89
+ * Set an {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} that, when aborted,
90
+ * cancels any ongoing requests executed in `fn`'s scope.
91
+ *
92
+ * @returns value returned from `fn`
93
+ */
94
+ withAbortSignal<R>(abortSignal: AbortSignal, fn: () => Promise<R>): Promise<R>;
86
95
  }
@@ -1,10 +1,10 @@
1
1
  import { status as grpcStatus } from '@grpc/grpc-js';
2
- import { BaseWorkflowHandle, HistoryAndWorkflowId, QueryDefinition, WithWorkflowArgs, Workflow, WorkflowResultType } from '@temporalio/common';
2
+ import { BaseWorkflowHandle, HistoryAndWorkflowId, QueryDefinition, UpdateDefinition, WithWorkflowArgs, Workflow, WorkflowResultType } from '@temporalio/common';
3
3
  import { History } from '@temporalio/common/lib/proto-utils';
4
4
  import { temporal } from '@temporalio/proto';
5
- import { WorkflowCancelInput, WorkflowClientInterceptor, WorkflowClientInterceptors, WorkflowDescribeInput, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput } from './interceptors';
5
+ import { WorkflowCancelInput, WorkflowClientInterceptor, WorkflowClientInterceptors, WorkflowDescribeInput, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput, WorkflowStartUpdateInput, WorkflowStartUpdateOutput } from './interceptors';
6
6
  import { DescribeWorkflowExecutionResponse, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution, WorkflowExecutionDescription, WorkflowExecutionInfo, WorkflowService } from './types';
7
- import { WorkflowOptions, WorkflowSignalWithStartOptions, WorkflowStartOptions } from './workflow-options';
7
+ import { WorkflowOptions, WorkflowSignalWithStartOptions, WorkflowStartOptions, WorkflowUpdateOptions } from './workflow-options';
8
8
  import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client';
9
9
  /**
10
10
  * A client side handle to a single Workflow instance.
@@ -12,8 +12,9 @@ import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client
12
12
  *
13
13
  * Given the following Workflow definition:
14
14
  * ```ts
15
- * export const incrementSignal = defineSignal('increment');
15
+ * export const incrementSignal = defineSignal<[number]>('increment');
16
16
  * export const getValueQuery = defineQuery<number>('getValue');
17
+ * export const incrementAndGetValueUpdate = defineUpdate<number, [number]>('incrementAndGetValue');
17
18
  * export async function counterWorkflow(initialValue: number): Promise<void>;
18
19
  * ```
19
20
  *
@@ -27,12 +28,63 @@ import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client
27
28
  * taskQueue: 'tutorial',
28
29
  * });
29
30
  * await handle.signal(incrementSignal, 2);
30
- * await handle.query(getValueQuery); // 4
31
+ * const queryResult = await handle.query(getValueQuery); // 4
32
+ * const firstUpdateResult = await handle.executeUpdate(incrementAndGetValueUpdate, { args: [2] }); // 6
33
+ * const secondUpdateHandle = await handle.startUpdate(incrementAndGetValueUpdate, { args: [2] });
34
+ * const secondUpdateResult = await secondUpdateHandle.result(); // 8
31
35
  * await handle.cancel();
32
- * await handle.result(); // throws WorkflowExecutionCancelledError
36
+ * await handle.result(); // throws a WorkflowFailedError with `cause` set to a CancelledFailure.
33
37
  * ```
34
38
  */
35
39
  export interface WorkflowHandle<T extends Workflow = Workflow> extends BaseWorkflowHandle<T> {
40
+ /**
41
+ * Start an Update and wait for the result.
42
+ *
43
+ * @experimental Update is an experimental feature.
44
+ *
45
+ * @throws {@link WorkflowUpdateFailedError} if Update validation fails or if ApplicationFailure is thrown in the Update handler.
46
+ *
47
+ * @param def an Update definition as returned from {@link defineUpdate}
48
+ * @param options Update arguments
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const updateResult = await handle.executeUpdate(incrementAndGetValueUpdate, { args: [2] });
53
+ * ```
54
+ */
55
+ executeUpdate<Ret, Args extends [any, ...any[]], Name extends string = string>(def: UpdateDefinition<Ret, Args, Name> | string, options: WorkflowUpdateOptions & {
56
+ args: Args;
57
+ }): Promise<Ret>;
58
+ executeUpdate<Ret, Args extends [], Name extends string = string>(def: UpdateDefinition<Ret, Args, Name> | string, options?: WorkflowUpdateOptions & {
59
+ args?: Args;
60
+ }): Promise<Ret>;
61
+ /**
62
+ * Start an Update and receive a handle to the Update.
63
+ * The Update validator (if present) is run before the handle is returned.
64
+ *
65
+ * @experimental Update is an experimental feature.
66
+ *
67
+ * @throws {@link WorkflowUpdateFailedError} if Update validation fails.
68
+ *
69
+ * @param def an Update definition as returned from {@link defineUpdate}
70
+ * @param options Update arguments
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const updateHandle = await handle.startUpdate(incrementAndGetValueUpdate, { args: [2] });
75
+ * const updateResult = await updateHandle.result();
76
+ * ```
77
+ */
78
+ startUpdate<Ret, Args extends [any, ...any[]], Name extends string = string>(def: UpdateDefinition<Ret, Args, Name> | string, options: WorkflowUpdateOptions & {
79
+ args: Args;
80
+ }): Promise<WorkflowUpdateHandle<Ret>>;
81
+ startUpdate<Ret, Args extends [], Name extends string = string>(def: UpdateDefinition<Ret, Args, Name> | string, options?: WorkflowUpdateOptions & {
82
+ args?: Args;
83
+ }): Promise<WorkflowUpdateHandle<Ret>>;
84
+ /**
85
+ * Get a handle to an Update.
86
+ */
87
+ getUpdateHandle<Ret>(updateId: string, workflowId: string, options?: GetWorkflowUpdateHandleOptions): WorkflowUpdateHandle<Ret>;
36
88
  /**
37
89
  * Query a running or completed Workflow.
38
90
  *
@@ -128,6 +180,9 @@ export interface WorkflowResultOptions {
128
180
  */
129
181
  followRuns?: boolean;
130
182
  }
183
+ /**
184
+ * Options for {@link WorkflowClient.getHandle}
185
+ */
131
186
  export interface GetWorkflowHandleOptions extends WorkflowResultOptions {
132
187
  /**
133
188
  * ID of the first execution in the Workflow execution chain.
@@ -163,6 +218,37 @@ export interface AsyncWorkflowListIterable extends AsyncIterable<WorkflowExecuti
163
218
  */
164
219
  intoHistories: (intoHistoriesOptions?: IntoHistoriesOptions) => AsyncIterable<HistoryAndWorkflowId>;
165
220
  }
221
+ /**
222
+ * A client-side handle to an Update.
223
+ */
224
+ export interface WorkflowUpdateHandle<Ret> {
225
+ /**
226
+ * The ID of this Update request.
227
+ */
228
+ updateId: string;
229
+ /**
230
+ * The ID of the Workflow being targeted by this Update request.
231
+ */
232
+ workflowId: string;
233
+ /**
234
+ * The ID of the Run of the Workflow being targeted by this Update request.
235
+ */
236
+ workflowRunId?: string;
237
+ /**
238
+ * Return the result of the Update.
239
+ * @throws {@link WorkflowUpdateFailedError} if ApplicationFailure is thrown in the Update handler.
240
+ */
241
+ result(): Promise<Ret>;
242
+ }
243
+ /**
244
+ * Options for {@link WorkflowHandle.getUpdateHandle}
245
+ */
246
+ export interface GetWorkflowUpdateHandleOptions {
247
+ /**
248
+ * The ID of the Run of the Workflow targeted by the Update.
249
+ */
250
+ workflowRunId?: string;
251
+ }
166
252
  /**
167
253
  * Options for {@link WorkflowClient.list}
168
254
  */
@@ -262,6 +348,18 @@ export declare class WorkflowClient extends BaseClient {
262
348
  * Used as the final function of the query interceptor chain
263
349
  */
264
350
  protected _queryWorkflowHandler(input: WorkflowQueryInput): Promise<unknown>;
351
+ /**
352
+ * Start the Update.
353
+ *
354
+ * Used as the final function of the interceptor chain during startUpdate and executeUpdate.
355
+ */
356
+ protected _startUpdateHandler(waitForStage: temporal.api.enums.v1.UpdateWorkflowExecutionLifecycleStage, input: WorkflowStartUpdateInput): Promise<WorkflowStartUpdateOutput>;
357
+ protected createWorkflowUpdateHandle<Ret>(updateId: string, workflowId: string, options?: GetWorkflowUpdateHandleOptions, outcome?: temporal.api.update.v1.IOutcome): WorkflowUpdateHandle<Ret>;
358
+ /**
359
+ * Poll Update until a response with an outcome is received; return that outcome.
360
+ * This is used directly; no interceptor is available.
361
+ */
362
+ protected _pollForUpdateOutcome(updateId: string, workflowExecution: temporal.api.common.v1.IWorkflowExecution): Promise<temporal.api.update.v1.IOutcome>;
265
363
  /**
266
364
  * Uses given input to make a signalWorkflowExecution call to the service
267
365
  *