@temporalio/client 1.11.8 → 1.12.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.
Files changed (51) hide show
  1. package/lib/async-completion-client.js +3 -1
  2. package/lib/async-completion-client.js.map +1 -1
  3. package/lib/base-client.js +8 -0
  4. package/lib/base-client.js.map +1 -1
  5. package/lib/build-id-types.d.ts +8 -8
  6. package/lib/client.d.ts +1 -1
  7. package/lib/client.js +21 -2
  8. package/lib/client.js.map +1 -1
  9. package/lib/connection.d.ts +1 -1
  10. package/lib/connection.js +35 -6
  11. package/lib/connection.js.map +1 -1
  12. package/lib/errors.d.ts +5 -5
  13. package/lib/errors.js +6 -0
  14. package/lib/errors.js.map +1 -1
  15. package/lib/grpc-retry.d.ts +0 -9
  16. package/lib/grpc-retry.js +0 -4
  17. package/lib/grpc-retry.js.map +1 -1
  18. package/lib/helpers.js +11 -3
  19. package/lib/helpers.js.map +1 -1
  20. package/lib/schedule-client.js +17 -6
  21. package/lib/schedule-client.js.map +1 -1
  22. package/lib/schedule-helpers.d.ts +1 -2
  23. package/lib/schedule-helpers.js +7 -10
  24. package/lib/schedule-helpers.js.map +1 -1
  25. package/lib/schedule-types.d.ts +38 -8
  26. package/lib/schedule-types.js.map +1 -1
  27. package/lib/task-queue-client.d.ts +5 -5
  28. package/lib/task-queue-client.js +5 -5
  29. package/lib/task-queue-client.js.map +1 -1
  30. package/lib/types.d.ts +5 -1
  31. package/lib/types.js.map +1 -1
  32. package/lib/workflow-client.js +20 -10
  33. package/lib/workflow-client.js.map +1 -1
  34. package/lib/workflow-options.d.ts +9 -3
  35. package/lib/workflow-options.js +22 -1
  36. package/lib/workflow-options.js.map +1 -1
  37. package/package.json +8 -5
  38. package/src/async-completion-client.ts +2 -5
  39. package/src/build-id-types.ts +8 -8
  40. package/src/client.ts +2 -2
  41. package/src/connection.ts +2 -2
  42. package/src/errors.ts +3 -3
  43. package/src/grpc-retry.ts +0 -9
  44. package/src/helpers.ts +13 -10
  45. package/src/schedule-client.ts +24 -14
  46. package/src/schedule-helpers.ts +17 -28
  47. package/src/schedule-types.ts +45 -9
  48. package/src/task-queue-client.ts +6 -7
  49. package/src/types.ts +7 -3
  50. package/src/workflow-client.ts +20 -13
  51. package/src/workflow-options.ts +42 -4
@@ -1,5 +1,5 @@
1
1
  import { checkExtends, Replace } from '@temporalio/common/lib/type-helpers';
2
- import { Duration, SearchAttributes, Workflow } from '@temporalio/common';
2
+ import { Duration, SearchAttributes, Workflow, TypedSearchAttributes, SearchAttributePair } from '@temporalio/common';
3
3
  import { makeProtoEnumConverters } from '@temporalio/common/lib/internal-workflow';
4
4
  import type { temporal } from '@temporalio/proto';
5
5
  import { WorkflowStartOptions } from './workflow-options';
@@ -70,8 +70,21 @@ export interface ScheduleOptions<A extends ScheduleOptionsAction = ScheduleOptio
70
70
  * https://docs.temporal.io/docs/typescript/search-attributes
71
71
  *
72
72
  * Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided.
73
+ *
74
+ * @deprecated Use {@link typedSearchAttributes} instead.
73
75
  */
74
- searchAttributes?: SearchAttributes;
76
+ searchAttributes?: SearchAttributes; // eslint-disable-line deprecation/deprecation
77
+
78
+ /**
79
+ * Additional indexed information attached to the Schedule. More info:
80
+ * https://docs.temporal.io/docs/typescript/search-attributes
81
+ *
82
+ * Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided.
83
+ *
84
+ * If both {@link searchAttributes} and {@link typedSearchAttributes} are provided, conflicting keys will be overwritten
85
+ * by {@link typedSearchAttributes}.
86
+ */
87
+ typedSearchAttributes?: SearchAttributePair[] | TypedSearchAttributes;
75
88
 
76
89
  /**
77
90
  * The initial state of the schedule, right after creation or update.
@@ -129,7 +142,7 @@ export type CompiledScheduleOptions = Replace<
129
142
  * The specification of an updated Schedule, as expected by {@link ScheduleHandle.update}.
130
143
  */
131
144
  export type ScheduleUpdateOptions<A extends ScheduleOptionsAction = ScheduleOptionsAction> = Replace<
132
- Omit<ScheduleOptions, 'scheduleId' | 'memo' | 'searchAttributes'>,
145
+ Omit<ScheduleOptions, 'scheduleId' | 'memo'>,
133
146
  {
134
147
  action: A;
135
148
  state: Omit<ScheduleOptions['state'], 'triggerImmediately' | 'backfill'>;
@@ -172,12 +185,22 @@ export interface ScheduleSummary {
172
185
  memo?: Record<string, unknown>;
173
186
 
174
187
  /**
175
- * Additional indexed information attached to the Schedule.
176
- * More info: https://docs.temporal.io/docs/typescript/search-attributes
188
+ * Additional indexed information attached to the Schedule. More info:
189
+ * https://docs.temporal.io/docs/typescript/search-attributes
177
190
  *
178
191
  * Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided.
192
+ *
193
+ * @deprecated Use {@link typedSearchAttributes} instead.
179
194
  */
180
- searchAttributes?: SearchAttributes;
195
+ searchAttributes?: SearchAttributes; // eslint-disable-line deprecation/deprecation
196
+
197
+ /**
198
+ * Additional indexed information attached to the Schedule. More info:
199
+ * https://docs.temporal.io/docs/typescript/search-attributes
200
+ *
201
+ * Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided.
202
+ */
203
+ typedSearchAttributes?: TypedSearchAttributes;
181
204
 
182
205
  state: {
183
206
  /**
@@ -284,12 +307,22 @@ export type ScheduleDescription = {
284
307
  memo?: Record<string, unknown>;
285
308
 
286
309
  /**
287
- * Additional indexed information attached to the Schedule.
288
- * More info: https://docs.temporal.io/docs/typescript/search-attributes
310
+ * Additional indexed information attached to the Schedule. More info:
311
+ * https://docs.temporal.io/docs/typescript/search-attributes
312
+ *
313
+ * Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided.
314
+ *
315
+ * @deprecated Use {@link typedSearchAttributes} instead.
316
+ */
317
+ searchAttributes: SearchAttributes; // eslint-disable-line deprecation/deprecation
318
+
319
+ /**
320
+ * Additional indexed information attached to the Schedule. More info:
321
+ * https://docs.temporal.io/docs/typescript/search-attributes
289
322
  *
290
323
  * Values are always converted using {@link JsonPayloadConverter}, even when a custom Data Converter is provided.
291
324
  */
292
- searchAttributes: SearchAttributes;
325
+ typedSearchAttributes: TypedSearchAttributes;
293
326
 
294
327
  state: {
295
328
  /**
@@ -745,6 +778,7 @@ export type ScheduleOptionsStartWorkflowAction<W extends Workflow> = {
745
778
  | 'args'
746
779
  | 'memo'
747
780
  | 'searchAttributes'
781
+ | 'typedSearchAttributes'
748
782
  | 'retry'
749
783
  | 'workflowExecutionTimeout'
750
784
  | 'workflowRunTimeout'
@@ -776,10 +810,12 @@ export type ScheduleDescriptionStartWorkflowAction = ScheduleSummaryStartWorkflo
776
810
  | 'args'
777
811
  | 'memo'
778
812
  | 'searchAttributes'
813
+ | 'typedSearchAttributes'
779
814
  | 'retry'
780
815
  | 'workflowExecutionTimeout'
781
816
  | 'workflowRunTimeout'
782
817
  | 'workflowTaskTimeout'
818
+ | 'priority'
783
819
  >;
784
820
 
785
821
  // Invariant: an existing ScheduleDescriptionAction can be used as is to create or update a schedule
@@ -1,7 +1,6 @@
1
1
  import { status } from '@grpc/grpc-js';
2
- import { filterNullAndUndefined } from '@temporalio/common/lib/internal-non-workflow';
3
2
  import { assertNever, SymbolBasedInstanceOfError, RequireAtLeastOne } from '@temporalio/common/lib/type-helpers';
4
- import { makeProtoEnumConverters } from '@temporalio/common/lib/internal-workflow';
3
+ import { filterNullAndUndefined, makeProtoEnumConverters } from '@temporalio/common/lib/internal-workflow';
5
4
  import { temporal } from '@temporalio/proto';
6
5
  import { BaseClient, BaseClientOptions, defaultBaseClientOptions, LoadedWithDefaults } from './base-client';
7
6
  import { WorkflowService } from './types';
@@ -14,18 +13,18 @@ type IUpdateWorkerBuildIdCompatibilityRequest =
14
13
  type GetWorkerTaskReachabilityResponse = temporal.api.workflowservice.v1.GetWorkerTaskReachabilityResponse;
15
14
 
16
15
  /**
17
- * @experimental
16
+ * @experimental The Worker Versioning API is still being designed. Major changes are expected.
18
17
  */
19
18
  export type TaskQueueClientOptions = BaseClientOptions;
20
19
 
21
20
  /**
22
- * @experimental
21
+ * @experimental The Worker Versioning API is still being designed. Major changes are expected.
23
22
  */
24
23
  export type LoadedTaskQueueClientOptions = LoadedWithDefaults<TaskQueueClientOptions>;
25
24
 
26
25
  /**
27
26
  * A stand-in for a Build Id for unversioned Workers
28
- * @experimental
27
+ * @experimental The Worker Versioning API is still being designed. Major changes are expected.
29
28
  */
30
29
  export const UnversionedBuildId = Symbol.for('__temporal_unversionedBuildId');
31
30
  export type UnversionedBuildIdType = typeof UnversionedBuildId;
@@ -33,7 +32,7 @@ export type UnversionedBuildIdType = typeof UnversionedBuildId;
33
32
  /**
34
33
  * Client for starting Workflow executions and creating Workflow handles
35
34
  *
36
- * @experimental
35
+ * @experimental The Worker Versioning API is still being designed. Major changes are expected.
37
36
  */
38
37
  export class TaskQueueClient extends BaseClient {
39
38
  public readonly options: LoadedTaskQueueClientOptions;
@@ -285,7 +284,7 @@ export function reachabilityResponseFromProto(resp: GetWorkerTaskReachabilityRes
285
284
  * - Id passed is incorrect
286
285
  * - Build Id has been scavenged by the server.
287
286
  *
288
- * @experimental
287
+ * @experimental The Worker Versioning API is still being designed. Major changes are expected.
289
288
  */
290
289
  @SymbolBasedInstanceOfError('BuildIdNotFoundError')
291
290
  export class BuildIdNotFoundError extends Error {}
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type * as grpc from '@grpc/grpc-js';
2
- import type { SearchAttributes, SearchAttributeValue } from '@temporalio/common';
2
+ import type { TypedSearchAttributes, SearchAttributes, SearchAttributeValue, Priority } 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';
@@ -47,16 +47,20 @@ export interface WorkflowExecutionInfo {
47
47
  executionTime?: Date;
48
48
  closeTime?: Date;
49
49
  memo?: Record<string, unknown>;
50
- searchAttributes: SearchAttributes;
50
+ /** @deprecated Use {@link typedSearchAttributes} instead. */
51
+ searchAttributes: SearchAttributes; // eslint-disable-line deprecation/deprecation
52
+ typedSearchAttributes: TypedSearchAttributes;
51
53
  parentExecution?: Required<proto.temporal.api.common.v1.IWorkflowExecution>;
54
+ rootExecution?: Required<proto.temporal.api.common.v1.IWorkflowExecution>;
52
55
  raw: RawWorkflowExecutionInfo;
56
+ priority?: Priority;
53
57
  }
54
58
 
55
59
  export interface CountWorkflowExecution {
56
60
  count: number;
57
61
  groups: {
58
62
  count: number;
59
- groupValues: SearchAttributeValue[];
63
+ groupValues: SearchAttributeValue[]; // eslint-disable-line deprecation/deprecation
60
64
  }[];
61
65
  }
62
66
 
@@ -4,11 +4,9 @@ import {
4
4
  BaseWorkflowHandle,
5
5
  CancelledFailure,
6
6
  compileRetryPolicy,
7
- mapToPayloads,
8
7
  HistoryAndWorkflowId,
9
8
  QueryDefinition,
10
9
  RetryState,
11
- searchAttributePayloadConverter,
12
10
  SignalDefinition,
13
11
  UpdateDefinition,
14
12
  TerminatedFailure,
@@ -24,7 +22,9 @@ import {
24
22
  decodeRetryState,
25
23
  encodeWorkflowIdConflictPolicy,
26
24
  WorkflowIdConflictPolicy,
25
+ compilePriority,
27
26
  } from '@temporalio/common';
27
+ import { encodeUnifiedSearchAttributes } from '@temporalio/common/lib/converter/payload-search-attributes';
28
28
  import { composeInterceptors } from '@temporalio/common/lib/interceptors';
29
29
  import { History } from '@temporalio/common/lib/proto-utils';
30
30
  import { SymbolBasedInstanceOfError } from '@temporalio/common/lib/type-helpers';
@@ -34,8 +34,8 @@ import {
34
34
  decodeOptionalFailureToOptionalError,
35
35
  encodeMapToPayloads,
36
36
  encodeToPayloads,
37
- filterNullAndUndefined,
38
37
  } from '@temporalio/common/lib/internal-non-workflow';
38
+ import { filterNullAndUndefined } from '@temporalio/common/lib/internal-workflow';
39
39
  import { temporal } from '@temporalio/proto';
40
40
  import {
41
41
  ServiceError,
@@ -1218,13 +1218,16 @@ export class WorkflowClient extends BaseClient {
1218
1218
  workflowStartDelay: options.startDelay,
1219
1219
  retryPolicy: options.retry ? compileRetryPolicy(options.retry) : undefined,
1220
1220
  memo: options.memo ? { fields: await encodeMapToPayloads(this.dataConverter, options.memo) } : undefined,
1221
- searchAttributes: options.searchAttributes
1222
- ? {
1223
- indexedFields: mapToPayloads(searchAttributePayloadConverter, options.searchAttributes),
1224
- }
1225
- : undefined,
1221
+ searchAttributes:
1222
+ options.searchAttributes || options.typedSearchAttributes // eslint-disable-line deprecation/deprecation
1223
+ ? {
1224
+ indexedFields: encodeUnifiedSearchAttributes(options.searchAttributes, options.typedSearchAttributes), // eslint-disable-line deprecation/deprecation
1225
+ }
1226
+ : undefined,
1226
1227
  cronSchedule: options.cronSchedule,
1227
1228
  header: { fields: headers },
1229
+ priority: options.priority ? compilePriority(options.priority) : undefined,
1230
+ versioningOverride: options.versioningOverride ?? undefined,
1228
1231
  };
1229
1232
  try {
1230
1233
  return (await this.workflowService.signalWithStartWorkflowExecution(req)).runId;
@@ -1265,6 +1268,7 @@ export class WorkflowClient extends BaseClient {
1265
1268
  protected async createStartWorkflowRequest(input: WorkflowStartInput): Promise<StartWorkflowExecutionRequest> {
1266
1269
  const { options: opts, workflowType, headers } = input;
1267
1270
  const { identity, namespace } = this.options;
1271
+
1268
1272
  return {
1269
1273
  namespace,
1270
1274
  identity,
@@ -1284,13 +1288,16 @@ export class WorkflowClient extends BaseClient {
1284
1288
  workflowStartDelay: opts.startDelay,
1285
1289
  retryPolicy: opts.retry ? compileRetryPolicy(opts.retry) : undefined,
1286
1290
  memo: opts.memo ? { fields: await encodeMapToPayloads(this.dataConverter, opts.memo) } : undefined,
1287
- searchAttributes: opts.searchAttributes
1288
- ? {
1289
- indexedFields: mapToPayloads(searchAttributePayloadConverter, opts.searchAttributes),
1290
- }
1291
- : undefined,
1291
+ searchAttributes:
1292
+ opts.searchAttributes || opts.typedSearchAttributes // eslint-disable-line deprecation/deprecation
1293
+ ? {
1294
+ indexedFields: encodeUnifiedSearchAttributes(opts.searchAttributes, opts.typedSearchAttributes), // eslint-disable-line deprecation/deprecation
1295
+ }
1296
+ : undefined,
1292
1297
  cronSchedule: opts.cronSchedule,
1293
1298
  header: { fields: headers },
1299
+ priority: opts.priority ? compilePriority(opts.priority) : undefined,
1300
+ versioningOverride: opts.versioningOverride ?? undefined,
1294
1301
  };
1295
1302
  }
1296
1303
 
@@ -1,7 +1,14 @@
1
- import { CommonWorkflowOptions, SignalDefinition, WithWorkflowArgs, Workflow } from '@temporalio/common';
1
+ import {
2
+ CommonWorkflowOptions,
3
+ SignalDefinition,
4
+ WithWorkflowArgs,
5
+ Workflow,
6
+ VersioningOverride,
7
+ toCanonicalString,
8
+ } from '@temporalio/common';
2
9
  import { Duration, msOptionalToTs } from '@temporalio/common/lib/time';
3
10
  import { Replace } from '@temporalio/common/lib/type-helpers';
4
- import { google } from '@temporalio/proto';
11
+ import { google, temporal } from '@temporalio/proto';
5
12
 
6
13
  export * from '@temporalio/common/lib/workflow-options';
7
14
 
@@ -38,9 +45,15 @@ export interface WorkflowOptions extends CommonWorkflowOptions {
38
45
 
39
46
  /**
40
47
  * Amount of time to wait before starting the workflow.
41
- *
42
48
  */
43
49
  startDelay?: Duration;
50
+
51
+ /**
52
+ * Override the versioning behavior of the Workflow that is about to be started.
53
+ *
54
+ * @experimental Deployment based versioning is experimental and may change in the future.
55
+ */
56
+ versioningOverride?: VersioningOverride;
44
57
  }
45
58
 
46
59
  export type WithCompiledWorkflowOptions<T extends WorkflowOptions> = Replace<
@@ -50,11 +63,13 @@ export type WithCompiledWorkflowOptions<T extends WorkflowOptions> = Replace<
50
63
  workflowRunTimeout?: google.protobuf.IDuration;
51
64
  workflowTaskTimeout?: google.protobuf.IDuration;
52
65
  startDelay?: google.protobuf.IDuration;
66
+ versioningOverride?: temporal.api.workflow.v1.IVersioningOverride;
53
67
  }
54
68
  >;
55
69
 
56
70
  export function compileWorkflowOptions<T extends WorkflowOptions>(options: T): WithCompiledWorkflowOptions<T> {
57
- const { workflowExecutionTimeout, workflowRunTimeout, workflowTaskTimeout, startDelay, ...rest } = options;
71
+ const { workflowExecutionTimeout, workflowRunTimeout, workflowTaskTimeout, startDelay, versioningOverride, ...rest } =
72
+ options;
58
73
 
59
74
  return {
60
75
  ...rest,
@@ -62,6 +77,7 @@ export function compileWorkflowOptions<T extends WorkflowOptions>(options: T): W
62
77
  workflowRunTimeout: msOptionalToTs(workflowRunTimeout),
63
78
  workflowTaskTimeout: msOptionalToTs(workflowTaskTimeout),
64
79
  startDelay: msOptionalToTs(startDelay),
80
+ versioningOverride: versioningOverrideToProto(versioningOverride),
65
81
  };
66
82
  }
67
83
 
@@ -109,3 +125,25 @@ export interface WorkflowSignalWithStartOptionsWithArgs<SignalArgs extends any[]
109
125
  * Options for starting a Workflow
110
126
  */
111
127
  export type WorkflowStartOptions<T extends Workflow = Workflow> = WithWorkflowArgs<T, WorkflowOptions>;
128
+
129
+ function versioningOverrideToProto(
130
+ vo: VersioningOverride | undefined
131
+ ): temporal.api.workflow.v1.IVersioningOverride | undefined {
132
+ if (!vo) return undefined;
133
+
134
+ // TODO: Remove deprecated field assignments when versioning is non-experimental
135
+ if (vo === 'AUTO_UPGRADE') {
136
+ return {
137
+ autoUpgrade: true,
138
+ behavior: temporal.api.enums.v1.VersioningBehavior.VERSIONING_BEHAVIOR_AUTO_UPGRADE,
139
+ };
140
+ }
141
+
142
+ return {
143
+ pinned: {
144
+ version: vo.pinnedTo,
145
+ },
146
+ behavior: temporal.api.enums.v1.VersioningBehavior.VERSIONING_BEHAVIOR_PINNED,
147
+ pinnedVersion: toCanonicalString(vo.pinnedTo),
148
+ };
149
+ }