@temporalio/common 1.11.7 → 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 (89) hide show
  1. package/lib/activity-options.d.ts +6 -1
  2. package/lib/activity-options.js.map +1 -1
  3. package/lib/converter/failure-converter.d.ts +3 -3
  4. package/lib/converter/failure-converter.js +3 -1
  5. package/lib/converter/failure-converter.js.map +1 -1
  6. package/lib/converter/payload-converter.d.ts +2 -15
  7. package/lib/converter/payload-converter.js +6 -69
  8. package/lib/converter/payload-converter.js.map +1 -1
  9. package/lib/converter/payload-search-attributes.d.ts +26 -0
  10. package/lib/converter/payload-search-attributes.js +171 -0
  11. package/lib/converter/payload-search-attributes.js.map +1 -0
  12. package/lib/converter/protobuf-payload-converters.js +3 -2
  13. package/lib/converter/protobuf-payload-converters.js.map +1 -1
  14. package/lib/errors.d.ts +2 -1
  15. package/lib/errors.js +6 -1
  16. package/lib/errors.js.map +1 -1
  17. package/lib/failure.d.ts +20 -1
  18. package/lib/failure.js +47 -5
  19. package/lib/failure.js.map +1 -1
  20. package/lib/index.d.ts +7 -0
  21. package/lib/index.js +9 -0
  22. package/lib/index.js.map +1 -1
  23. package/lib/interfaces.d.ts +0 -7
  24. package/lib/interfaces.js.map +1 -1
  25. package/lib/internal-non-workflow/codec-helpers.d.ts +2 -2
  26. package/lib/internal-non-workflow/codec-types.d.ts +1 -1
  27. package/lib/internal-non-workflow/index.d.ts +0 -1
  28. package/lib/internal-non-workflow/index.js +0 -1
  29. package/lib/internal-non-workflow/index.js.map +1 -1
  30. package/lib/internal-workflow/index.d.ts +1 -0
  31. package/lib/internal-workflow/index.js +1 -0
  32. package/lib/internal-workflow/index.js.map +1 -1
  33. package/lib/internal-workflow/objects-helpers.d.ts +15 -0
  34. package/lib/internal-workflow/objects-helpers.js +29 -0
  35. package/lib/internal-workflow/objects-helpers.js.map +1 -0
  36. package/lib/logger.d.ts +32 -0
  37. package/lib/logger.js +91 -1
  38. package/lib/logger.js.map +1 -1
  39. package/lib/metrics.d.ts +181 -0
  40. package/lib/metrics.js +240 -0
  41. package/lib/metrics.js.map +1 -0
  42. package/lib/priority.d.ts +36 -0
  43. package/lib/priority.js +27 -0
  44. package/lib/priority.js.map +1 -0
  45. package/lib/search-attributes.d.ts +77 -0
  46. package/lib/search-attributes.js +233 -0
  47. package/lib/search-attributes.js.map +1 -0
  48. package/lib/type-helpers.d.ts +5 -1
  49. package/lib/type-helpers.js +0 -22
  50. package/lib/type-helpers.js.map +1 -1
  51. package/lib/versioning-intent-enum.d.ts +1 -1
  52. package/lib/versioning-intent-enum.js +1 -1
  53. package/lib/versioning-intent.d.ts +1 -1
  54. package/lib/worker-deployments.d.ts +47 -0
  55. package/lib/worker-deployments.js +32 -0
  56. package/lib/worker-deployments.js.map +1 -0
  57. package/lib/workflow-definition-options.d.ts +18 -0
  58. package/lib/workflow-definition-options.js +3 -0
  59. package/lib/workflow-definition-options.js.map +1 -0
  60. package/lib/workflow-options.d.ts +22 -2
  61. package/lib/workflow-options.js.map +1 -1
  62. package/package.json +6 -3
  63. package/src/activity-options.ts +7 -1
  64. package/src/converter/failure-converter.ts +9 -4
  65. package/src/converter/payload-converter.ts +7 -71
  66. package/src/converter/payload-search-attributes.ts +220 -0
  67. package/src/errors.ts +2 -1
  68. package/src/failure.ts +38 -3
  69. package/src/index.ts +13 -0
  70. package/src/interfaces.ts +0 -8
  71. package/src/internal-non-workflow/codec-helpers.ts +2 -2
  72. package/src/internal-non-workflow/codec-types.ts +10 -8
  73. package/src/internal-non-workflow/index.ts +0 -1
  74. package/src/internal-workflow/index.ts +1 -0
  75. package/src/internal-workflow/objects-helpers.ts +37 -0
  76. package/src/logger.ts +108 -0
  77. package/src/metrics.ts +443 -0
  78. package/src/priority.ts +54 -0
  79. package/src/search-attributes.ts +292 -0
  80. package/src/type-helpers.ts +11 -23
  81. package/src/versioning-intent-enum.ts +1 -1
  82. package/src/versioning-intent.ts +1 -1
  83. package/src/worker-deployments.ts +70 -0
  84. package/src/workflow-definition-options.ts +20 -0
  85. package/src/workflow-options.ts +27 -3
  86. package/lib/internal-non-workflow/utils.d.ts +0 -4
  87. package/lib/internal-non-workflow/utils.js +0 -10
  88. package/lib/internal-non-workflow/utils.js.map +0 -1
  89. package/src/internal-non-workflow/utils.ts +0 -6
@@ -0,0 +1,292 @@
1
+ import type { temporal } from '@temporalio/proto';
2
+ import { makeProtoEnumConverters } from './internal-workflow';
3
+
4
+ /** @deprecated: Use {@link TypedSearchAttributes} instead */
5
+ export type SearchAttributeValueOrReadonly = SearchAttributeValue | Readonly<SearchAttributeValue> | undefined; // eslint-disable-line deprecation/deprecation
6
+ /** @deprecated: Use {@link TypedSearchAttributes} instead */
7
+ export type SearchAttributes = Record<string, SearchAttributeValueOrReadonly>; // eslint-disable-line deprecation/deprecation
8
+ /** @deprecated: Use {@link TypedSearchAttributes} instead */
9
+ export type SearchAttributeValue = string[] | number[] | boolean[] | Date[]; // eslint-disable-line deprecation/deprecation
10
+
11
+ export const SearchAttributeType = {
12
+ TEXT: 'TEXT',
13
+ KEYWORD: 'KEYWORD',
14
+ INT: 'INT',
15
+ DOUBLE: 'DOUBLE',
16
+ BOOL: 'BOOL',
17
+ DATETIME: 'DATETIME',
18
+ KEYWORD_LIST: 'KEYWORD_LIST',
19
+ } as const;
20
+
21
+ export type SearchAttributeType = (typeof SearchAttributeType)[keyof typeof SearchAttributeType];
22
+
23
+ // Note: encodeSearchAttributeIndexedValueType exported for use in tests to register search attributes
24
+ // ts-prune-ignore-next
25
+ export const [encodeSearchAttributeIndexedValueType, _] = makeProtoEnumConverters<
26
+ temporal.api.enums.v1.IndexedValueType,
27
+ typeof temporal.api.enums.v1.IndexedValueType,
28
+ keyof typeof temporal.api.enums.v1.IndexedValueType,
29
+ typeof SearchAttributeType,
30
+ 'INDEXED_VALUE_TYPE_'
31
+ >(
32
+ {
33
+ [SearchAttributeType.TEXT]: 1,
34
+ [SearchAttributeType.KEYWORD]: 2,
35
+ [SearchAttributeType.INT]: 3,
36
+ [SearchAttributeType.DOUBLE]: 4,
37
+ [SearchAttributeType.BOOL]: 5,
38
+ [SearchAttributeType.DATETIME]: 6,
39
+ [SearchAttributeType.KEYWORD_LIST]: 7,
40
+ UNSPECIFIED: 0,
41
+ } as const,
42
+ 'INDEXED_VALUE_TYPE_'
43
+ );
44
+
45
+ interface IndexedValueTypeMapping {
46
+ TEXT: string;
47
+ KEYWORD: string;
48
+ INT: number;
49
+ DOUBLE: number;
50
+ BOOL: boolean;
51
+ DATETIME: Date;
52
+ KEYWORD_LIST: string[];
53
+ }
54
+
55
+ export function isValidValueForType<T extends SearchAttributeType>(
56
+ type: T,
57
+ value: unknown
58
+ ): value is IndexedValueTypeMapping[T] {
59
+ switch (type) {
60
+ case SearchAttributeType.TEXT:
61
+ case SearchAttributeType.KEYWORD:
62
+ return typeof value === 'string';
63
+ case SearchAttributeType.INT:
64
+ return Number.isInteger(value);
65
+ case SearchAttributeType.DOUBLE:
66
+ return typeof value === 'number';
67
+ case SearchAttributeType.BOOL:
68
+ return typeof value === 'boolean';
69
+ case SearchAttributeType.DATETIME:
70
+ return value instanceof Date;
71
+ case SearchAttributeType.KEYWORD_LIST:
72
+ return Array.isArray(value) && value.every((item) => typeof item === 'string');
73
+ default:
74
+ return false;
75
+ }
76
+ }
77
+
78
+ export interface SearchAttributeKey<T extends SearchAttributeType> {
79
+ name: string;
80
+ type: T;
81
+ }
82
+
83
+ export function defineSearchAttributeKey<T extends SearchAttributeType>(name: string, type: T): SearchAttributeKey<T> {
84
+ return { name, type };
85
+ }
86
+
87
+ class BaseSearchAttributeValue<T extends SearchAttributeType, V = IndexedValueTypeMapping[T]> {
88
+ private readonly _type: T;
89
+ private readonly _value: V;
90
+
91
+ constructor(type: T, value: V) {
92
+ this._type = type;
93
+ this._value = value;
94
+ }
95
+
96
+ get type(): T {
97
+ return this._type;
98
+ }
99
+
100
+ get value(): V {
101
+ return this._value;
102
+ }
103
+ }
104
+
105
+ // Internal type for class private data.
106
+ // Exported for use in payload conversion.
107
+ export class TypedSearchAttributeValue<T extends SearchAttributeType> extends BaseSearchAttributeValue<T> {}
108
+ // ts-prune-ignore-next
109
+ export class TypedSearchAttributeUpdateValue<T extends SearchAttributeType> extends BaseSearchAttributeValue<
110
+ T,
111
+ IndexedValueTypeMapping[T] | null
112
+ > {}
113
+
114
+ export type SearchAttributePair = {
115
+ [T in SearchAttributeType]: { key: SearchAttributeKey<T>; value: IndexedValueTypeMapping[T] };
116
+ }[SearchAttributeType];
117
+
118
+ export type SearchAttributeUpdatePair = {
119
+ [T in SearchAttributeType]: { key: SearchAttributeKey<T>; value: IndexedValueTypeMapping[T] | null };
120
+ }[SearchAttributeType];
121
+
122
+ export class TypedSearchAttributes {
123
+ private searchAttributes: Record<string, TypedSearchAttributeValue<SearchAttributeType>> = {};
124
+
125
+ constructor(initialAttributes?: SearchAttributePair[]) {
126
+ if (initialAttributes === undefined) return;
127
+ for (const pair of initialAttributes) {
128
+ if (pair.key.name in this.searchAttributes) {
129
+ throw new Error(`Duplicate search attribute key: ${pair.key.name}`);
130
+ }
131
+ this.searchAttributes[pair.key.name] = new TypedSearchAttributeValue(pair.key.type, pair.value);
132
+ }
133
+ }
134
+
135
+ get<T extends SearchAttributeType>(key: SearchAttributeKey<T>): IndexedValueTypeMapping[T] | undefined {
136
+ const attr = this.searchAttributes[key.name];
137
+ // Key not found or type mismatch.
138
+ if (attr === undefined || !isValidValueForType(key.type, attr.value)) {
139
+ return undefined;
140
+ }
141
+ return attr.value;
142
+ }
143
+
144
+ /** Returns a deep copy of the given TypedSearchAttributes instance */
145
+ copy(): TypedSearchAttributes {
146
+ const state: Record<string, TypedSearchAttributeValue<SearchAttributeType>> = {};
147
+
148
+ for (const [key, attr] of Object.entries(this.searchAttributes)) {
149
+ // Create a new instance with the same properties
150
+ let value = attr.value;
151
+ // For non-primitive types, create a deep copy
152
+ if (attr.value instanceof Date) {
153
+ value = new Date(attr.value);
154
+ } else if (Array.isArray(attr.value)) {
155
+ value = [...attr.value];
156
+ }
157
+ state[key] = new TypedSearchAttributeValue(attr.type, value);
158
+ }
159
+
160
+ // Create return value with manually assigned state.
161
+ const res = new TypedSearchAttributes();
162
+ res.searchAttributes = state;
163
+ return res;
164
+ }
165
+
166
+ /**
167
+ * @hidden
168
+ * Return JSON representation of this class as SearchAttributePair[]
169
+ * Default toJSON method is not used because it's JSON representation includes private state.
170
+ */
171
+ toJSON(): SearchAttributePair[] {
172
+ return this.getAll();
173
+ }
174
+
175
+ /** Returns a copy of the current TypedSearchAttributes instance with the updated attributes. */
176
+ updateCopy(updates: SearchAttributeUpdatePair[]): TypedSearchAttributes {
177
+ // Create a deep copy of the current instance.
178
+ const res = this.copy();
179
+ // Apply updates.
180
+ res.update(updates);
181
+ return res;
182
+ }
183
+
184
+ // Performs direct mutation on the current instance.
185
+ private update(updates: SearchAttributeUpdatePair[]) {
186
+ // Apply updates.
187
+ for (const pair of updates) {
188
+ // Delete attribute.
189
+ if (pair.value === null) {
190
+ // Delete only if the update matches a key and type.
191
+ const attrVal = this.searchAttributes[pair.key.name];
192
+ if (attrVal && attrVal.type === pair.key.type) {
193
+ delete this.searchAttributes[pair.key.name];
194
+ }
195
+ continue;
196
+ }
197
+ // Add or update attribute.
198
+ this.searchAttributes[pair.key.name] = new TypedSearchAttributeValue(pair.key.type, pair.value);
199
+ }
200
+ }
201
+
202
+ getAll(): SearchAttributePair[] {
203
+ const res: SearchAttributePair[] = [];
204
+ for (const [key, attr] of Object.entries(this.searchAttributes)) {
205
+ const attrKey = { name: key, type: attr.type };
206
+ // Sanity check, should always be legal.
207
+ if (isValidValueForType(attrKey.type, attr.value)) {
208
+ res.push({ key: attrKey, value: attr.value } as SearchAttributePair);
209
+ }
210
+ }
211
+ return res;
212
+ }
213
+
214
+ static getKeyFromUntyped(
215
+ key: string,
216
+ value: SearchAttributeValueOrReadonly // eslint-disable-line deprecation/deprecation
217
+ ): SearchAttributeKey<SearchAttributeType> | undefined {
218
+ if (value == null) {
219
+ return;
220
+ }
221
+
222
+ // Unpack single-element arrays.
223
+ const val = value.length === 1 ? value[0] : value;
224
+ switch (typeof val) {
225
+ case 'string':
226
+ // Check if val is an ISO string, if so, return a DATETIME key.
227
+ if (!isNaN(Date.parse(val)) && Date.parse(val) === new Date(val).getTime()) {
228
+ return { name: key, type: SearchAttributeType.DATETIME };
229
+ }
230
+ return { name: key, type: SearchAttributeType.TEXT };
231
+ case 'number':
232
+ return {
233
+ name: key,
234
+ type: Number.isInteger(val) ? SearchAttributeType.INT : SearchAttributeType.DOUBLE,
235
+ };
236
+ case 'boolean':
237
+ return { name: key, type: SearchAttributeType.BOOL };
238
+ case 'object':
239
+ if (val instanceof Date) {
240
+ return { name: key, type: SearchAttributeType.DATETIME };
241
+ }
242
+ if (Array.isArray(val) && val.every((item) => typeof item === 'string')) {
243
+ return { name: key, type: SearchAttributeType.KEYWORD_LIST };
244
+ }
245
+ return;
246
+ default:
247
+ return;
248
+ }
249
+ }
250
+
251
+ static toMetadataType(type: SearchAttributeType): string {
252
+ switch (type) {
253
+ case SearchAttributeType.TEXT:
254
+ return 'Text';
255
+ case SearchAttributeType.KEYWORD:
256
+ return 'Keyword';
257
+ case SearchAttributeType.INT:
258
+ return 'Int';
259
+ case SearchAttributeType.DOUBLE:
260
+ return 'Double';
261
+ case SearchAttributeType.BOOL:
262
+ return 'Bool';
263
+ case SearchAttributeType.DATETIME:
264
+ return 'Datetime';
265
+ case SearchAttributeType.KEYWORD_LIST:
266
+ return 'KeywordList';
267
+ default:
268
+ throw new Error(`Unknown search attribute type: ${type}`);
269
+ }
270
+ }
271
+
272
+ static toSearchAttributeType(type: string): SearchAttributeType | undefined {
273
+ switch (type) {
274
+ case 'Text':
275
+ return SearchAttributeType.TEXT;
276
+ case 'Keyword':
277
+ return SearchAttributeType.KEYWORD;
278
+ case 'Int':
279
+ return SearchAttributeType.INT;
280
+ case 'Double':
281
+ return SearchAttributeType.DOUBLE;
282
+ case 'Bool':
283
+ return SearchAttributeType.BOOL;
284
+ case 'Datetime':
285
+ return SearchAttributeType.DATETIME;
286
+ case 'KeywordList':
287
+ return SearchAttributeType.KEYWORD_LIST;
288
+ default:
289
+ return;
290
+ }
291
+ }
292
+ }
@@ -1,9 +1,20 @@
1
+ export type NonNullableObject<T> = { [P in keyof T]-?: NonNullable<T[P]> };
2
+
1
3
  /** Shorthand alias */
2
4
  export type AnyFunc = (...args: any[]) => any;
5
+
3
6
  /** A tuple without its last element */
4
7
  export type OmitLast<T> = T extends [...infer REST, any] ? REST : never;
8
+
5
9
  /** F with all arguments but the last */
6
10
  export type OmitLastParam<F extends AnyFunc> = (...args: OmitLast<Parameters<F>>) => ReturnType<F>;
11
+
12
+ export type OmitFirst<T> = T extends [any, ...infer REST] ? REST : never;
13
+
14
+ export type OmitFirstParam<T> = T extends (...args: any[]) => any
15
+ ? (...args: OmitFirst<Parameters<T>>) => ReturnType<T>
16
+ : never;
17
+
7
18
  /** Require that T has at least one of the provided properties defined */
8
19
  export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &
9
20
  {
@@ -218,26 +229,3 @@ export function SymbolBasedInstanceOfError<E extends Error>(markerName: string):
218
229
  });
219
230
  };
220
231
  }
221
-
222
- // Thanks MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
223
- export function deepFreeze<T>(object: T): T {
224
- // Retrieve the property names defined on object
225
- const propNames = Object.getOwnPropertyNames(object);
226
-
227
- // Freeze properties before freezing self
228
- for (const name of propNames) {
229
- const value = (object as any)[name];
230
-
231
- if (value && typeof value === 'object') {
232
- try {
233
- deepFreeze(value);
234
- } catch (_err) {
235
- // This is okay, there are some typed arrays that cannot be frozen (encodingKeys)
236
- }
237
- } else if (typeof value === 'function') {
238
- Object.freeze(value);
239
- }
240
- }
241
-
242
- return Object.freeze(object);
243
- }
@@ -7,7 +7,7 @@ import { assertNever, checkExtends } from './type-helpers';
7
7
  /**
8
8
  * Protobuf enum representation of {@link VersioningIntentString}.
9
9
  *
10
- * @experimental
10
+ * @experimental The Worker Versioning API is still being designed. Major changes are expected.
11
11
  */
12
12
  export enum VersioningIntent {
13
13
  UNSPECIFIED = 0,
@@ -11,6 +11,6 @@
11
11
  * current worker. The default behavior for starting Workflows is `DEFAULT`. The default behavior for Workflows starting
12
12
  * Activities, starting Child Workflows, or Continuing As New is `COMPATIBLE`.
13
13
  *
14
- * @experimental
14
+ * @experimental The Worker Versioning API is still being designed. Major changes are expected.
15
15
  */
16
16
  export type VersioningIntent = 'COMPATIBLE' | 'DEFAULT';
@@ -0,0 +1,70 @@
1
+ import type { temporal } from '@temporalio/proto';
2
+ import { makeProtoEnumConverters } from './internal-workflow';
3
+
4
+ /**
5
+ * Represents the version of a specific worker deployment.
6
+ *
7
+ * @experimental Deployment based versioning is experimental and may change in the future.
8
+ */
9
+ export interface WorkerDeploymentVersion {
10
+ readonly buildId: string;
11
+ readonly deploymentName: string;
12
+ }
13
+
14
+ /**
15
+ * @returns The canonical representation of a deployment version, which is a string in the format
16
+ * `deploymentName.buildId`.
17
+ */
18
+ export function toCanonicalString(version: WorkerDeploymentVersion): string {
19
+ return `${version.deploymentName}.${version.buildId}`;
20
+ }
21
+
22
+ /**
23
+ * Specifies when a workflow might move from a worker of one Build Id to another.
24
+ *
25
+ * * 'PINNED' - The workflow will be pinned to the current Build ID unless manually moved.
26
+ * * 'AUTO_UPGRADE' - The workflow will automatically move to the latest version (default Build ID
27
+ * of the task queue) when the next task is dispatched.
28
+ *
29
+ * @experimental Deployment based versioning is experimental and may change in the future.
30
+ */
31
+ export const VersioningBehavior = {
32
+ PINNED: 'PINNED',
33
+ AUTO_UPGRADE: 'AUTO_UPGRADE',
34
+ } as const;
35
+ export type VersioningBehavior = (typeof VersioningBehavior)[keyof typeof VersioningBehavior];
36
+
37
+ export const [encodeVersioningBehavior, decodeVersioningBehavior] = makeProtoEnumConverters<
38
+ temporal.api.enums.v1.VersioningBehavior,
39
+ typeof temporal.api.enums.v1.VersioningBehavior,
40
+ keyof typeof temporal.api.enums.v1.VersioningBehavior,
41
+ typeof VersioningBehavior,
42
+ 'VERSIONING_BEHAVIOR_'
43
+ >(
44
+ {
45
+ [VersioningBehavior.PINNED]: 1,
46
+ [VersioningBehavior.AUTO_UPGRADE]: 2,
47
+ UNSPECIFIED: 0,
48
+ } as const,
49
+ 'VERSIONING_BEHAVIOR_'
50
+ );
51
+
52
+ /**
53
+ * Represents versioning overrides. For example, when starting workflows.
54
+ */
55
+ export type VersioningOverride = PinnedVersioningOverride | 'AUTO_UPGRADE';
56
+
57
+ /**
58
+ * Workflow will be pinned to a specific deployment version.
59
+ */
60
+ export interface PinnedVersioningOverride {
61
+ /**
62
+ * The worker deployment version to pin the workflow to.
63
+ */
64
+ pinnedTo: WorkerDeploymentVersion;
65
+ }
66
+
67
+ /**
68
+ * The workflow will auto-upgrade to the current deployment version on the next workflow task.
69
+ */
70
+ export type AutoUpgradeVersioningOverride = 'AUTO_UPGRADE';
@@ -0,0 +1,20 @@
1
+ import { VersioningBehavior } from './worker-deployments';
2
+
3
+ /**
4
+ * Options that can be used when defining a workflow via {@link setWorkflowOptions}.
5
+ */
6
+ export interface WorkflowDefinitionOptions {
7
+ versioningBehavior?: VersioningBehavior;
8
+ }
9
+
10
+ type AsyncFunction<Args extends any[], ReturnType> = (...args: Args) => Promise<ReturnType>;
11
+ export type WorkflowDefinitionOptionsOrGetter = WorkflowDefinitionOptions | (() => WorkflowDefinitionOptions);
12
+
13
+ /**
14
+ * @internal
15
+ * @hidden
16
+ * A workflow function that has been defined with options from {@link WorkflowDefinitionOptions}.
17
+ */
18
+ export interface WorkflowFunctionWithOptions<Args extends any[], ReturnType> extends AsyncFunction<Args, ReturnType> {
19
+ workflowDefinitionOptions: WorkflowDefinitionOptionsOrGetter;
20
+ }
@@ -1,8 +1,11 @@
1
1
  import type { temporal } from '@temporalio/proto';
2
- import { SearchAttributes, Workflow } from './interfaces';
2
+ import { Workflow } from './interfaces';
3
3
  import { RetryPolicy } from './retry-policy';
4
4
  import { Duration } from './time';
5
5
  import { makeProtoEnumConverters } from './internal-workflow';
6
+ import { SearchAttributePair, SearchAttributes, TypedSearchAttributes } from './search-attributes';
7
+ import { Priority } from './priority';
8
+ import { WorkflowFunctionWithOptions } from './workflow-definition-options';
6
9
 
7
10
  /**
8
11
  * Defines what happens when trying to start a Workflow with the same ID as a *Closed* Workflow.
@@ -173,8 +176,27 @@ export interface BaseWorkflowOptions {
173
176
  * https://docs.temporal.io/docs/typescript/search-attributes
174
177
  *
175
178
  * Values are always converted using {@link JsonPayloadConverter}, even when a custom data converter is provided.
179
+ *
180
+ * @deprecated Use {@link typedSearchAttributes} instead.
181
+ */
182
+ searchAttributes?: SearchAttributes; // eslint-disable-line deprecation/deprecation
183
+
184
+ /**
185
+ * Specifies additional indexed information to attach to the Workflow Execution. More info:
186
+ * https://docs.temporal.io/docs/typescript/search-attributes
187
+ *
188
+ * Values are always converted using {@link JsonPayloadConverter}, even when a custom data converter is provided.
189
+ * Note that search attributes are not encoded, as such, do not include any sensitive information.
190
+ *
191
+ * If both {@link searchAttributes} and {@link typedSearchAttributes} are provided, conflicting keys will be overwritten
192
+ * by {@link typedSearchAttributes}.
193
+ */
194
+ typedSearchAttributes?: SearchAttributePair[] | TypedSearchAttributes;
195
+
196
+ /**
197
+ * Priority of a workflow
176
198
  */
177
- searchAttributes?: SearchAttributes;
199
+ priority?: Priority;
178
200
  }
179
201
 
180
202
  export type WithWorkflowArgs<W extends Workflow, T> = T &
@@ -222,7 +244,9 @@ export interface WorkflowDurationOptions {
222
244
 
223
245
  export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions;
224
246
 
225
- export function extractWorkflowType<T extends Workflow>(workflowTypeOrFunc: string | T): string {
247
+ export function extractWorkflowType<T extends Workflow>(
248
+ workflowTypeOrFunc: string | T | WorkflowFunctionWithOptions<any[], any>
249
+ ): string {
226
250
  if (typeof workflowTypeOrFunc === 'string') return workflowTypeOrFunc as string;
227
251
  if (typeof workflowTypeOrFunc === 'function') {
228
252
  if (workflowTypeOrFunc?.name) return workflowTypeOrFunc.name;
@@ -1,4 +0,0 @@
1
- /**
2
- * Helper to prevent undefined and null values overriding defaults when merging maps
3
- */
4
- export declare function filterNullAndUndefined<T extends Record<string, any>>(obj: T): T;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterNullAndUndefined = filterNullAndUndefined;
4
- /**
5
- * Helper to prevent undefined and null values overriding defaults when merging maps
6
- */
7
- function filterNullAndUndefined(obj) {
8
- return Object.fromEntries(Object.entries(obj).filter(([_k, v]) => v != null));
9
- }
10
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal-non-workflow/utils.ts"],"names":[],"mappings":";;AAGA,wDAEC;AALD;;GAEG;AACH,SAAgB,sBAAsB,CAAgC,GAAM;IAC1E,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAQ,CAAC;AACvF,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Helper to prevent undefined and null values overriding defaults when merging maps
3
- */
4
- export function filterNullAndUndefined<T extends Record<string, any>>(obj: T): T {
5
- return Object.fromEntries(Object.entries(obj).filter(([_k, v]) => v != null)) as any;
6
- }