@temporalio/client 1.11.4 → 1.11.6

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.
package/src/helpers.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ServiceError as GrpcServiceError } from '@grpc/grpc-js';
1
+ import { ServiceError as GrpcServiceError, status as grpcStatus } from '@grpc/grpc-js';
2
2
  import {
3
3
  LoadedDataConverter,
4
4
  mapFromPayloads,
@@ -10,7 +10,12 @@ import { Replace } from '@temporalio/common/lib/type-helpers';
10
10
  import { optionalTsToDate, requiredTsToDate } from '@temporalio/common/lib/time';
11
11
  import { decodeMapFromPayloads } from '@temporalio/common/lib/internal-non-workflow/codec-helpers';
12
12
  import { temporal, google } from '@temporalio/proto';
13
- import { RawWorkflowExecutionInfo, WorkflowExecutionInfo, WorkflowExecutionStatusName } from './types';
13
+ import {
14
+ CountWorkflowExecution,
15
+ RawWorkflowExecutionInfo,
16
+ WorkflowExecutionInfo,
17
+ WorkflowExecutionStatusName,
18
+ } from './types';
14
19
 
15
20
  function workflowStatusCodeToName(code: temporal.api.enums.v1.WorkflowExecutionStatus): WorkflowExecutionStatusName {
16
21
  return workflowStatusCodeToNameInternal(code) ?? 'UNKNOWN';
@@ -81,7 +86,24 @@ export async function executionInfoFromRaw<T>(
81
86
  };
82
87
  }
83
88
 
89
+ export function decodeCountWorkflowExecutionsResponse(
90
+ raw: temporal.api.workflowservice.v1.ICountWorkflowExecutionsResponse
91
+ ): CountWorkflowExecution {
92
+ return {
93
+ // Note: lossy conversion of Long to number
94
+ count: raw.count!.toNumber(),
95
+ groups: raw.groups!.map((group) => {
96
+ return {
97
+ // Note: lossy conversion of Long to number
98
+ count: group.count!.toNumber(),
99
+ groupValues: group.groupValues!.map((value) => searchAttributePayloadConverter.fromPayload(value)),
100
+ };
101
+ }),
102
+ };
103
+ }
104
+
84
105
  type ErrorDetailsName = `temporal.api.errordetails.v1.${keyof typeof temporal.api.errordetails.v1}`;
106
+ type FailureName = `temporal.api.failure.v1.${keyof typeof temporal.api.failure.v1}`;
85
107
 
86
108
  /**
87
109
  * If the error type can be determined based on embedded grpc error details,
@@ -102,6 +124,28 @@ export function rethrowKnownErrorTypes(err: GrpcServiceError): void {
102
124
  const { namespace } = temporal.api.errordetails.v1.NamespaceNotFoundFailure.decode(entry.value);
103
125
  throw new NamespaceNotFoundError(namespace);
104
126
  }
127
+ case 'temporal.api.errordetails.v1.MultiOperationExecutionFailure': {
128
+ // MultiOperationExecutionFailure contains error statuses for multiple
129
+ // operations. A MultiOperationExecutionAborted error status means that
130
+ // the corresponding operation was aborted due to an error in one of the
131
+ // other operations. We rethrow the first operation error that is not
132
+ // MultiOperationExecutionAborted.
133
+ const { statuses } = temporal.api.errordetails.v1.MultiOperationExecutionFailure.decode(entry.value);
134
+ for (const status of statuses) {
135
+ const detail = status.details?.[0];
136
+ const statusType = detail?.type_url?.replace(/^type.googleapis.com\//, '') as FailureName | undefined;
137
+ if (
138
+ statusType === 'temporal.api.failure.v1.MultiOperationExecutionAborted' ||
139
+ status.code === grpcStatus.OK
140
+ ) {
141
+ continue;
142
+ }
143
+ err.message = status.message ?? err.message;
144
+ err.code = status.code || err.code;
145
+ err.details = detail?.value?.toString() || err.details;
146
+ throw err;
147
+ }
148
+ }
105
149
  }
106
150
  }
107
151
  }
@@ -42,6 +42,32 @@ export interface WorkflowStartUpdateOutput {
42
42
  readonly outcome?: temporal.api.update.v1.IOutcome;
43
43
  }
44
44
 
45
+ /**
46
+ * Input for WorkflowClientInterceptor.startUpdateWithStart
47
+ *
48
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
49
+ */
50
+ export interface WorkflowStartUpdateWithStartInput {
51
+ readonly workflowType: string;
52
+ readonly workflowStartOptions: CompiledWorkflowOptions;
53
+ readonly workflowStartHeaders: Headers;
54
+ readonly updateName: string;
55
+ readonly updateArgs: unknown[];
56
+ readonly updateOptions: WorkflowUpdateOptions;
57
+ readonly updateHeaders: Headers;
58
+ }
59
+
60
+ /**
61
+ * Output for WorkflowClientInterceptor.startUpdateWithStart
62
+ *
63
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
64
+ */
65
+ export interface WorkflowStartUpdateWithStartOutput {
66
+ readonly workflowExecution: WorkflowExecution;
67
+ readonly updateId: string;
68
+ readonly updateOutcome?: temporal.api.update.v1.IOutcome;
69
+ }
70
+
45
71
  /** Input for WorkflowClientInterceptor.signal */
46
72
  export interface WorkflowSignalInput {
47
73
  readonly signalName: string;
@@ -100,13 +126,20 @@ export interface WorkflowClientInterceptor {
100
126
  start?: (input: WorkflowStartInput, next: Next<this, 'start'>) => Promise<string /* runId */>;
101
127
  /**
102
128
  * Intercept a service call to updateWorkflowExecution
103
- *
104
- * @experimental Update is an experimental feature.
105
129
  */
106
130
  startUpdate?: (
107
131
  input: WorkflowStartUpdateInput,
108
132
  next: Next<this, 'startUpdate'>
109
133
  ) => Promise<WorkflowStartUpdateOutput>;
134
+ /**
135
+ * Intercept a service call to startUpdateWithStart
136
+ *
137
+ * @experimental Update-with-Start is an experimental feature and may be subject to change.
138
+ */
139
+ startUpdateWithStart?: (
140
+ input: WorkflowStartUpdateWithStartInput,
141
+ next: Next<this, 'startUpdateWithStart'>
142
+ ) => Promise<WorkflowStartUpdateWithStartOutput>;
110
143
  /**
111
144
  * Intercept a service call to signalWorkflowExecution
112
145
  *
package/src/types.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 { makeProtoEnumConverters } from '@temporalio/common/lib/internal-workflow';
4
4
  import * as proto from '@temporalio/proto';
5
5
  import { Replace } from '@temporalio/common/lib/type-helpers';
@@ -52,6 +52,14 @@ export interface WorkflowExecutionInfo {
52
52
  raw: RawWorkflowExecutionInfo;
53
53
  }
54
54
 
55
+ export interface CountWorkflowExecution {
56
+ count: number;
57
+ groups: {
58
+ count: number;
59
+ groupValues: SearchAttributeValue[];
60
+ }[];
61
+ }
62
+
55
63
  export type WorkflowExecutionDescription = Replace<
56
64
  WorkflowExecutionInfo,
57
65
  {