@temporalio/client 1.11.5 → 1.11.7

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.
@@ -37,8 +37,8 @@ export declare class BaseClient {
37
37
  /**
38
38
  * The underlying {@link Connection | connection} used by this client.
39
39
  *
40
- * Clients are cheap to create, but connections are expensive. Where that make sense,
41
- * a single connection may and should be reused by multiple `Client`.
40
+ * Clients are cheap to create, but connections are expensive. Where it makes sense,
41
+ * a single connection may and should be reused by multiple `Client`s.
42
42
  */
43
43
  readonly connection: ConnectionLike;
44
44
  private readonly loadedDataConverter;
package/lib/helpers.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { ServiceError as GrpcServiceError } from '@grpc/grpc-js';
2
2
  import { LoadedDataConverter } from '@temporalio/common';
3
3
  import { Replace } from '@temporalio/common/lib/type-helpers';
4
- import { RawWorkflowExecutionInfo, WorkflowExecutionInfo } from './types';
4
+ import { temporal } from '@temporalio/proto';
5
+ import { CountWorkflowExecution, RawWorkflowExecutionInfo, WorkflowExecutionInfo } from './types';
5
6
  export declare function executionInfoFromRaw<T>(raw: RawWorkflowExecutionInfo, dataConverter: LoadedDataConverter, rawDataToEmbed: T): Promise<Replace<WorkflowExecutionInfo, {
6
7
  raw: T;
7
8
  }>>;
9
+ export declare function decodeCountWorkflowExecutionsResponse(raw: temporal.api.workflowservice.v1.ICountWorkflowExecutionsResponse): CountWorkflowExecution;
8
10
  /**
9
11
  * If the error type can be determined based on embedded grpc error details,
10
12
  * then rethrow the appropriate TypeScript error. Otherwise do nothing.
package/lib/helpers.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executionInfoFromRaw = executionInfoFromRaw;
4
+ exports.decodeCountWorkflowExecutionsResponse = decodeCountWorkflowExecutionsResponse;
4
5
  exports.rethrowKnownErrorTypes = rethrowKnownErrorTypes;
6
+ const grpc_js_1 = require("@grpc/grpc-js");
5
7
  const common_1 = require("@temporalio/common");
6
8
  const time_1 = require("@temporalio/common/lib/time");
7
9
  const codec_helpers_1 = require("@temporalio/common/lib/internal-non-workflow/codec-helpers");
@@ -63,6 +65,19 @@ async function executionInfoFromRaw(raw, dataConverter, rawDataToEmbed) {
63
65
  raw: rawDataToEmbed,
64
66
  };
65
67
  }
68
+ function decodeCountWorkflowExecutionsResponse(raw) {
69
+ return {
70
+ // Note: lossy conversion of Long to number
71
+ count: raw.count.toNumber(),
72
+ groups: raw.groups.map((group) => {
73
+ return {
74
+ // Note: lossy conversion of Long to number
75
+ count: group.count.toNumber(),
76
+ groupValues: group.groupValues.map((value) => common_1.searchAttributePayloadConverter.fromPayload(value)),
77
+ };
78
+ }),
79
+ };
80
+ }
66
81
  /**
67
82
  * If the error type can be determined based on embedded grpc error details,
68
83
  * then rethrow the appropriate TypeScript error. Otherwise do nothing.
@@ -82,6 +97,26 @@ function rethrowKnownErrorTypes(err) {
82
97
  const { namespace } = proto_1.temporal.api.errordetails.v1.NamespaceNotFoundFailure.decode(entry.value);
83
98
  throw new common_1.NamespaceNotFoundError(namespace);
84
99
  }
100
+ case 'temporal.api.errordetails.v1.MultiOperationExecutionFailure': {
101
+ // MultiOperationExecutionFailure contains error statuses for multiple
102
+ // operations. A MultiOperationExecutionAborted error status means that
103
+ // the corresponding operation was aborted due to an error in one of the
104
+ // other operations. We rethrow the first operation error that is not
105
+ // MultiOperationExecutionAborted.
106
+ const { statuses } = proto_1.temporal.api.errordetails.v1.MultiOperationExecutionFailure.decode(entry.value);
107
+ for (const status of statuses) {
108
+ const detail = status.details?.[0];
109
+ const statusType = detail?.type_url?.replace(/^type.googleapis.com\//, '');
110
+ if (statusType === 'temporal.api.failure.v1.MultiOperationExecutionAborted' ||
111
+ status.code === grpc_js_1.status.OK) {
112
+ continue;
113
+ }
114
+ err.message = status.message ?? err.message;
115
+ err.code = status.code || err.code;
116
+ err.details = detail?.value?.toString() || err.details;
117
+ throw err;
118
+ }
119
+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C,CAAC,OAAO,CAAC;AACxD,CAAC"}
@@ -31,6 +31,30 @@ export interface WorkflowStartUpdateOutput {
31
31
  readonly workflowRunId: string;
32
32
  readonly outcome?: temporal.api.update.v1.IOutcome;
33
33
  }
34
+ /**
35
+ * Input for WorkflowClientInterceptor.startUpdateWithStart
36
+ *
37
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
38
+ */
39
+ export interface WorkflowStartUpdateWithStartInput {
40
+ readonly workflowType: string;
41
+ readonly workflowStartOptions: CompiledWorkflowOptions;
42
+ readonly workflowStartHeaders: Headers;
43
+ readonly updateName: string;
44
+ readonly updateArgs: unknown[];
45
+ readonly updateOptions: WorkflowUpdateOptions;
46
+ readonly updateHeaders: Headers;
47
+ }
48
+ /**
49
+ * Output for WorkflowClientInterceptor.startUpdateWithStart
50
+ *
51
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
52
+ */
53
+ export interface WorkflowStartUpdateWithStartOutput {
54
+ readonly workflowExecution: WorkflowExecution;
55
+ readonly updateId: string;
56
+ readonly updateOutcome?: temporal.api.update.v1.IOutcome;
57
+ }
34
58
  /** Input for WorkflowClientInterceptor.signal */
35
59
  export interface WorkflowSignalInput {
36
60
  readonly signalName: string;
@@ -83,10 +107,14 @@ export interface WorkflowClientInterceptor {
83
107
  start?: (input: WorkflowStartInput, next: Next<this, 'start'>) => Promise<string>;
84
108
  /**
85
109
  * Intercept a service call to updateWorkflowExecution
86
- *
87
- * @experimental Update is an experimental feature.
88
110
  */
89
111
  startUpdate?: (input: WorkflowStartUpdateInput, next: Next<this, 'startUpdate'>) => Promise<WorkflowStartUpdateOutput>;
112
+ /**
113
+ * Intercept a service call to startUpdateWithStart
114
+ *
115
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
116
+ */
117
+ startUpdateWithStart?: (input: WorkflowStartUpdateWithStartInput, next: Next<this, 'startUpdateWithStart'>) => Promise<WorkflowStartUpdateWithStartOutput>;
90
118
  /**
91
119
  * Intercept a service call to signalWorkflowExecution
92
120
  *
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type * as grpc from '@grpc/grpc-js';
2
- import type { SearchAttributes } from '@temporalio/common';
2
+ import type { SearchAttributes, SearchAttributeValue } from '@temporalio/common';
3
3
  import * as proto from '@temporalio/proto';
4
4
  import { Replace } from '@temporalio/common/lib/type-helpers';
5
5
  export interface WorkflowExecution {
@@ -37,6 +37,13 @@ export interface WorkflowExecutionInfo {
37
37
  parentExecution?: Required<proto.temporal.api.common.v1.IWorkflowExecution>;
38
38
  raw: RawWorkflowExecutionInfo;
39
39
  }
40
+ export interface CountWorkflowExecution {
41
+ count: number;
42
+ groups: {
43
+ count: number;
44
+ groupValues: SearchAttributeValue[];
45
+ }[];
46
+ }
40
47
  export type WorkflowExecutionDescription = Replace<WorkflowExecutionInfo, {
41
48
  raw: DescribeWorkflowExecutionResponse;
42
49
  }>;
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gFAAmF;AACnF,yDAA2C;AA2D5B,uBAAe,GAAK,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,iBAAC;AAE1D,uBAAe,GAAK,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,iBAAC;AAElD,qBAAa,GAAK,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,QAAC;AAyEjD,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,qBAAqB,EAAE,uBAAuB;IAE9C,4CAA4C;IAC5C,2BAA2B,EAAE,MAAM,EAAE,8CAA8C;IAEnF,gDAAgD;IAChD,+BAA+B,EAAE,UAAU,EAAE,8CAA8C;IAE3F,6DAA6D;IAC7D,4CAA4C,EAAE,uBAAuB,EAAE,8CAA8C;IAErH,2C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;IAC/C,WAAW,EAAE,CAAC;CACN,EACV,yBAAyB,CAC1B,EAda,kCAA0B,UAAE,kCAA0B,SAclE"}
@@ -1,9 +1,9 @@
1
1
  import { status as grpcStatus } from '@grpc/grpc-js';
2
- import { BaseWorkflowHandle, HistoryAndWorkflowId, QueryDefinition, UpdateDefinition, WithWorkflowArgs, Workflow, WorkflowResultType } from '@temporalio/common';
2
+ import { BaseWorkflowHandle, HistoryAndWorkflowId, QueryDefinition, UpdateDefinition, WithWorkflowArgs, Workflow, WorkflowResultType, WorkflowIdConflictPolicy } 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, WorkflowStartUpdateInput, WorkflowStartUpdateOutput } from './interceptors';
6
- import { DescribeWorkflowExecutionResponse, QueryRejectCondition, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution, WorkflowExecutionDescription, WorkflowExecutionInfo, WorkflowService } from './types';
5
+ import { WorkflowCancelInput, WorkflowClientInterceptor, WorkflowClientInterceptors, WorkflowDescribeInput, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput, WorkflowStartUpdateInput, WorkflowStartUpdateOutput, WorkflowStartUpdateWithStartInput, WorkflowStartUpdateWithStartOutput } from './interceptors';
6
+ import { CountWorkflowExecution, DescribeWorkflowExecutionResponse, QueryRejectCondition, RequestCancelWorkflowExecutionResponse, StartWorkflowExecutionRequest, TerminateWorkflowExecutionResponse, WorkflowExecution, WorkflowExecutionDescription, WorkflowExecutionInfo, WorkflowService } from './types';
7
7
  import { WorkflowOptions, WorkflowSignalWithStartOptions, WorkflowStartOptions, WorkflowUpdateOptions } from './workflow-options';
8
8
  import { BaseClient, BaseClientOptions, LoadedWithDefaults } from './base-client';
9
9
  import { WorkflowUpdateStage } from './workflow-update-stage';
@@ -41,8 +41,6 @@ export interface WorkflowHandle<T extends Workflow = Workflow> extends BaseWorkf
41
41
  /**
42
42
  * Start an Update and wait for the result.
43
43
  *
44
- * @experimental Update is an experimental feature.
45
- *
46
44
  * @throws {@link WorkflowUpdateFailedError} if Update validation fails or if ApplicationFailure is thrown in the Update handler.
47
45
  * @throws {@link WorkflowUpdateRPCTimeoutOrCancelledError} if this Update call timed out or was cancelled. This doesn't
48
46
  * mean the update itself was timed out or cancelled.
@@ -64,8 +62,6 @@ export interface WorkflowHandle<T extends Workflow = Workflow> extends BaseWorkf
64
62
  * Start an Update and receive a handle to the Update. The Update validator (if present) is run
65
63
  * before the handle is returned.
66
64
  *
67
- * @experimental Update is an experimental feature.
68
- *
69
65
  * @throws {@link WorkflowUpdateFailedError} if Update validation fails.
70
66
  * @throws {@link WorkflowUpdateRPCTimeoutOrCancelledError} if this Update call timed out or was cancelled. This doesn't
71
67
  * mean the update itself was timed out or cancelled.
@@ -306,6 +302,29 @@ export interface IntoHistoriesOptions {
306
302
  */
307
303
  bufferLimit?: number;
308
304
  }
305
+ declare const withStartWorkflowOperationResolve: unique symbol;
306
+ declare const withStartWorkflowOperationReject: unique symbol;
307
+ declare const withStartWorkflowOperationUsed: unique symbol;
308
+ /**
309
+ * Define how to start a workflow when using {@link WorkflowClient.startUpdateWithStart} and
310
+ * {@link WorkflowClient.executeUpdateWithStart}. `workflowIdConflictPolicy` is required in the options.
311
+ *
312
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
313
+ */
314
+ export declare class WithStartWorkflowOperation<T extends Workflow> {
315
+ workflowTypeOrFunc: string | T;
316
+ options: WorkflowStartOptions<T> & {
317
+ workflowIdConflictPolicy: WorkflowIdConflictPolicy;
318
+ };
319
+ private [withStartWorkflowOperationUsed];
320
+ private [withStartWorkflowOperationResolve];
321
+ private [withStartWorkflowOperationReject];
322
+ private workflowHandlePromise;
323
+ constructor(workflowTypeOrFunc: string | T, options: WorkflowStartOptions<T> & {
324
+ workflowIdConflictPolicy: WorkflowIdConflictPolicy;
325
+ });
326
+ workflowHandle(): Promise<WorkflowHandle<T>>;
327
+ }
309
328
  /**
310
329
  * Client for starting Workflow executions and creating Workflow handles.
311
330
  *
@@ -322,58 +341,119 @@ export declare class WorkflowClient extends BaseClient {
322
341
  * object.
323
342
  */
324
343
  get workflowService(): WorkflowService;
344
+ protected _start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowOptions>, interceptors: WorkflowClientInterceptor[]): Promise<string>;
345
+ protected _signalWithStart<T extends Workflow, SA extends any[]>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowSignalWithStartOptions<SA>>, interceptors: WorkflowClientInterceptor[]): Promise<string>;
325
346
  /**
326
347
  * Start a new Workflow execution.
327
348
  *
328
- * @returns the execution's `runId`.
349
+ * @returns a {@link WorkflowHandle} to the started Workflow
329
350
  */
330
- protected _start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowOptions>, interceptors: WorkflowClientInterceptor[]): Promise<string>;
351
+ start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WorkflowStartOptions<T>): Promise<WorkflowHandleWithFirstExecutionRunId<T>>;
331
352
  /**
332
- * Sends a signal to a running Workflow or starts a new one if not already running and immediately signals it.
333
- * Useful when you're unsure of the Workflow's run state.
353
+ * Start a new Workflow Execution and immediately send a Signal to that Workflow.
334
354
  *
335
- * @returns the runId of the Workflow
355
+ * The behavior of Signal-with-Start in the case where there is already a running Workflow with
356
+ * the given Workflow ID depends on the {@link WorkflowIDConflictPolicy}. That is, if the policy
357
+ * is `USE_EXISTING`, then the Signal is issued against the already existing Workflow Execution;
358
+ * however, if the policy is `FAIL`, then an error is thrown. If no policy is specified,
359
+ * Signal-with-Start defaults to `USE_EXISTING`.
360
+ *
361
+ * @returns a {@link WorkflowHandle} to the started Workflow
336
362
  */
337
- protected _signalWithStart<T extends Workflow, SA extends any[]>(workflowTypeOrFunc: string | T, options: WithWorkflowArgs<T, WorkflowSignalWithStartOptions<SA>>, interceptors: WorkflowClientInterceptor[]): Promise<string>;
363
+ signalWithStart<WorkflowFn extends Workflow, SignalArgs extends any[] = []>(workflowTypeOrFunc: string | WorkflowFn, options: WithWorkflowArgs<WorkflowFn, WorkflowSignalWithStartOptions<SignalArgs>>): Promise<WorkflowHandleWithSignaledRunId<WorkflowFn>>;
338
364
  /**
339
- * Start a new Workflow execution.
365
+ * Start a new Workflow Execution and immediately send an Update to that Workflow,
366
+ * then await and return the Update's result.
367
+ *
368
+ * The `updateOptions` object must contain a {@link WithStartWorkflowOperation}, which defines
369
+ * the options for the Workflow execution to start (e.g. the Workflow's type, task queue, input
370
+ * arguments, etc.)
340
371
  *
341
- * @returns a WorkflowHandle to the started Workflow
372
+ * The behavior of Update-with-Start in the case where there is already a running Workflow with
373
+ * the given Workflow ID depends on the specified {@link WorkflowIDConflictPolicy}. That is, if
374
+ * the policy is `USE_EXISTING`, then the Update is issued against the already existing Workflow
375
+ * Execution; however, if the policy is `FAIL`, then an error is thrown. Caller MUST specify
376
+ * the desired WorkflowIDConflictPolicy.
377
+ *
378
+ * This call will block until the Update has completed. The Workflow handle can be retrieved by
379
+ * awaiting on {@link WithStartWorkflowOperation.workflowHandle}, whether or not the Update
380
+ * succeeds.
381
+ *
382
+ * @returns the Update result
383
+ *
384
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
342
385
  */
343
- start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WorkflowStartOptions<T>): Promise<WorkflowHandleWithFirstExecutionRunId<T>>;
386
+ executeUpdateWithStart<T extends Workflow, Ret, Args extends any[]>(updateDef: UpdateDefinition<Ret, Args> | string, updateOptions: WorkflowUpdateOptions & {
387
+ args?: Args;
388
+ startWorkflowOperation: WithStartWorkflowOperation<T>;
389
+ }): Promise<Ret>;
344
390
  /**
345
- * Sends a Signal to a running Workflow or starts a new one if not already running and immediately Signals it.
346
- * Useful when you're unsure whether the Workflow has been started.
391
+ * Start a new Workflow Execution and immediately send an Update to that Workflow,
392
+ * then return a {@link WorkflowUpdateHandle} for that Update.
347
393
  *
348
- * @returns a {@link WorkflowHandle} to the started Workflow
394
+ * The `updateOptions` object must contain a {@link WithStartWorkflowOperation}, which defines
395
+ * the options for the Workflow execution to start (e.g. the Workflow's type, task queue, input
396
+ * arguments, etc.)
397
+ *
398
+ * The behavior of Update-with-Start in the case where there is already a running Workflow with
399
+ * the given Workflow ID depends on the specified {@link WorkflowIDConflictPolicy}. That is, if
400
+ * the policy is `USE_EXISTING`, then the Update is issued against the already existing Workflow
401
+ * Execution; however, if the policy is `FAIL`, then an error is thrown. Caller MUST specify
402
+ * the desired WorkflowIDConflictPolicy.
403
+ *
404
+ * This call will block until the Update has reached the specified {@link WorkflowUpdateStage}.
405
+ * Note that this means that the call will not return successfully until the Update has
406
+ * been delivered to a Worker. The Workflow handle can be retrieved by awaiting on
407
+ * {@link WithStartWorkflowOperation.workflowHandle}, whether or not the Update succeeds.
408
+ *
409
+ * @returns a {@link WorkflowUpdateHandle} to the started Update
410
+ *
411
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
349
412
  */
350
- signalWithStart<WorkflowFn extends Workflow, SignalArgs extends any[] = []>(workflowTypeOrFunc: string | WorkflowFn, options: WithWorkflowArgs<WorkflowFn, WorkflowSignalWithStartOptions<SignalArgs>>): Promise<WorkflowHandleWithSignaledRunId<WorkflowFn>>;
413
+ startUpdateWithStart<T extends Workflow, Ret, Args extends any[]>(updateDef: UpdateDefinition<Ret, Args> | string, updateOptions: WorkflowUpdateOptions & {
414
+ args?: Args;
415
+ waitForStage: 'ACCEPTED';
416
+ startWorkflowOperation: WithStartWorkflowOperation<T>;
417
+ }): Promise<WorkflowUpdateHandle<Ret>>;
418
+ protected _startUpdateWithStart<T extends Workflow, Ret, Args extends any[]>(updateDef: UpdateDefinition<Ret, Args> | string, updateWithStartOptions: WorkflowUpdateOptions & {
419
+ args?: Args;
420
+ waitForStage: WorkflowUpdateStage;
421
+ startWorkflowOperation: WithStartWorkflowOperation<T>;
422
+ }): Promise<WorkflowUpdateHandle<Ret>>;
351
423
  /**
352
- * Starts a new Workflow execution and awaits its completion.
424
+ * Start a new Workflow execution, then await for its completion and return that Workflow's result.
353
425
  *
354
426
  * @returns the result of the Workflow execution
355
427
  */
356
428
  execute<T extends Workflow>(workflowTypeOrFunc: string | T, options: WorkflowStartOptions<T>): Promise<WorkflowResultType<T>>;
357
429
  /**
358
- * Gets the result of a Workflow execution.
430
+ * Get the result of a Workflow execution.
359
431
  *
360
- * Follows the chain of execution in case Workflow continues as new, or has a cron schedule or retry policy.
432
+ * Follow the chain of execution in case Workflow continues as new, or has a cron schedule or retry policy.
361
433
  */
362
434
  result<T extends Workflow>(workflowId: string, runId?: string, opts?: WorkflowResultOptions): Promise<WorkflowResultType<T>>;
363
435
  protected rethrowUpdateGrpcError(err: unknown, fallbackMessage: string, workflowExecution?: WorkflowExecution): never;
364
436
  protected rethrowGrpcError(err: unknown, fallbackMessage: string, workflowExecution?: WorkflowExecution): never;
365
437
  /**
366
- * Uses given input to make a queryWorkflow call to the service
438
+ * Use given input to make a queryWorkflow call to the service
367
439
  *
368
440
  * Used as the final function of the query interceptor chain
369
441
  */
370
442
  protected _queryWorkflowHandler(input: WorkflowQueryInput): Promise<unknown>;
443
+ protected _createUpdateWorkflowRequest(lifecycleStage: temporal.api.enums.v1.UpdateWorkflowExecutionLifecycleStage, input: WorkflowStartUpdateInput): Promise<temporal.api.workflowservice.v1.IUpdateWorkflowExecutionRequest>;
371
444
  /**
372
445
  * Start the Update.
373
446
  *
374
447
  * Used as the final function of the interceptor chain during startUpdate and executeUpdate.
375
448
  */
376
449
  protected _startUpdateHandler(waitForStage: WorkflowUpdateStage, input: WorkflowStartUpdateInput): Promise<WorkflowStartUpdateOutput>;
450
+ /**
451
+ * Send the Update-With-Start MultiOperation request.
452
+ *
453
+ * Used as the final function of the interceptor chain during
454
+ * startUpdateWithStart and executeUpdateWithStart.
455
+ */
456
+ protected _updateWithStartHandler(waitForStage: WorkflowUpdateStage, onStart: (startResponse: temporal.api.workflowservice.v1.IStartWorkflowExecutionResponse) => void, onStartError: (err: any) => void, input: WorkflowStartUpdateWithStartInput): Promise<WorkflowStartUpdateWithStartOutput>;
377
457
  protected createWorkflowUpdateHandle<Ret>(updateId: string, workflowId: string, workflowRunId?: string, outcome?: temporal.api.update.v1.IOutcome): WorkflowUpdateHandle<Ret>;
378
458
  /**
379
459
  * Poll Update until a response with an outcome is received; return that outcome.
@@ -381,25 +461,26 @@ export declare class WorkflowClient extends BaseClient {
381
461
  */
382
462
  protected _pollForUpdateOutcome(updateId: string, workflowExecution: temporal.api.common.v1.IWorkflowExecution): Promise<temporal.api.update.v1.IOutcome>;
383
463
  /**
384
- * Uses given input to make a signalWorkflowExecution call to the service
464
+ * Use given input to make a signalWorkflowExecution call to the service
385
465
  *
386
466
  * Used as the final function of the signal interceptor chain
387
467
  */
388
468
  protected _signalWorkflowHandler(input: WorkflowSignalInput): Promise<void>;
389
469
  /**
390
- * Uses given input to make a signalWithStartWorkflowExecution call to the service
470
+ * Use given input to make a signalWithStartWorkflowExecution call to the service
391
471
  *
392
472
  * Used as the final function of the signalWithStart interceptor chain
393
473
  */
394
474
  protected _signalWithStartWorkflowHandler(input: WorkflowSignalWithStartInput): Promise<string>;
395
475
  /**
396
- * Uses given input to make startWorkflowExecution call to the service
476
+ * Use given input to make startWorkflowExecution call to the service
397
477
  *
398
478
  * Used as the final function of the start interceptor chain
399
479
  */
400
480
  protected _startWorkflowHandler(input: WorkflowStartInput): Promise<string>;
481
+ protected createStartWorkflowRequest(input: WorkflowStartInput): Promise<StartWorkflowExecutionRequest>;
401
482
  /**
402
- * Uses given input to make terminateWorkflowExecution call to the service
483
+ * Use given input to make terminateWorkflowExecution call to the service
403
484
  *
404
485
  * Used as the final function of the terminate interceptor chain
405
486
  */
@@ -441,14 +522,24 @@ export declare class WorkflowClient extends BaseClient {
441
522
  getHandle<T extends Workflow>(workflowId: string, runId?: string, options?: GetWorkflowHandleOptions): WorkflowHandle<T>;
442
523
  protected _list(options?: ListOptions): AsyncIterable<WorkflowExecutionInfo>;
443
524
  /**
444
- * List workflows by given `query`.
525
+ * Return a list of Workflow Executions matching the given `query`.
445
526
  *
446
- * ⚠️ To use advanced query functionality, as of the 1.18 server release, you must use Elasticsearch based visibility.
527
+ * Note that the list of Workflow Executions returned is approximate and eventually consistent.
447
528
  *
448
529
  * More info on the concept of "visibility" and the query syntax on the Temporal documentation site:
449
530
  * https://docs.temporal.io/visibility
450
531
  */
451
532
  list(options?: ListOptions): AsyncWorkflowListIterable;
533
+ /**
534
+ * Return the number of Workflow Executions matching the given `query`. If no `query` is provided, then return the
535
+ * total number of Workflow Executions for this namespace.
536
+ *
537
+ * Note that the number of Workflow Executions returned is approximate and eventually consistent.
538
+ *
539
+ * More info on the concept of "visibility" and the query syntax on the Temporal documentation site:
540
+ * https://docs.temporal.io/visibility
541
+ */
542
+ count(query?: string): Promise<CountWorkflowExecution>;
452
543
  protected getOrMakeInterceptors(workflowId: string, runId?: string): WorkflowClientInterceptor[];
453
544
  }
454
545
  export declare class QueryRejectedError extends Error {