@temporalio/common 1.11.3 → 1.11.4

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 (65) hide show
  1. package/lib/activity-options.d.ts +8 -6
  2. package/lib/activity-options.js +13 -12
  3. package/lib/activity-options.js.map +1 -1
  4. package/lib/converter/failure-converter.js +8 -6
  5. package/lib/converter/failure-converter.js.map +1 -1
  6. package/lib/converter/payload-converter.js +7 -7
  7. package/lib/converter/payload-converter.js.map +1 -1
  8. package/lib/deprecated-time.js +9 -10
  9. package/lib/deprecated-time.js.map +1 -1
  10. package/lib/encoding.js +3 -3
  11. package/lib/encoding.js.map +1 -1
  12. package/lib/failure.d.ts +51 -23
  13. package/lib/failure.js +65 -32
  14. package/lib/failure.js.map +1 -1
  15. package/lib/index.js +4 -5
  16. package/lib/index.js.map +1 -1
  17. package/lib/interceptors.js +1 -2
  18. package/lib/interceptors.js.map +1 -1
  19. package/lib/interfaces.d.ts +5 -4
  20. package/lib/interfaces.js +4 -5
  21. package/lib/interfaces.js.map +1 -1
  22. package/lib/internal-non-workflow/codec-helpers.js +22 -23
  23. package/lib/internal-non-workflow/codec-helpers.js.map +1 -1
  24. package/lib/internal-non-workflow/data-converter-helpers.js +3 -4
  25. package/lib/internal-non-workflow/data-converter-helpers.js.map +1 -1
  26. package/lib/internal-non-workflow/parse-host-uri.js +3 -4
  27. package/lib/internal-non-workflow/parse-host-uri.js.map +1 -1
  28. package/lib/internal-non-workflow/proxy-config.js +1 -2
  29. package/lib/internal-non-workflow/proxy-config.js.map +1 -1
  30. package/lib/internal-non-workflow/tls-config.d.ts +0 -1
  31. package/lib/internal-non-workflow/tls-config.js +1 -2
  32. package/lib/internal-non-workflow/tls-config.js.map +1 -1
  33. package/lib/internal-non-workflow/utils.js +1 -2
  34. package/lib/internal-non-workflow/utils.js.map +1 -1
  35. package/lib/internal-workflow/enums-helpers.d.ts +170 -0
  36. package/lib/internal-workflow/enums-helpers.js +172 -0
  37. package/lib/internal-workflow/enums-helpers.js.map +1 -0
  38. package/lib/internal-workflow/index.d.ts +1 -0
  39. package/lib/internal-workflow/index.js +18 -0
  40. package/lib/internal-workflow/index.js.map +1 -0
  41. package/lib/proto-utils.js +4 -5
  42. package/lib/proto-utils.js.map +1 -1
  43. package/lib/retry-policy.js +2 -3
  44. package/lib/retry-policy.js.map +1 -1
  45. package/lib/time.js +12 -13
  46. package/lib/time.js.map +1 -1
  47. package/lib/type-helpers.d.ts +18 -0
  48. package/lib/type-helpers.js +12 -13
  49. package/lib/type-helpers.js.map +1 -1
  50. package/lib/versioning-intent-enum.js +2 -2
  51. package/lib/versioning-intent-enum.js.map +1 -1
  52. package/lib/workflow-options.d.ts +69 -17
  53. package/lib/workflow-options.js +64 -23
  54. package/lib/workflow-options.js.map +1 -1
  55. package/package.json +3 -3
  56. package/src/activity-options.ts +24 -13
  57. package/src/converter/failure-converter.ts +10 -6
  58. package/src/converter/payload-converter.ts +1 -1
  59. package/src/failure.ts +95 -28
  60. package/src/interfaces.ts +5 -4
  61. package/src/internal-non-workflow/data-converter-helpers.ts +1 -1
  62. package/src/internal-workflow/enums-helpers.ts +301 -0
  63. package/src/internal-workflow/index.ts +1 -0
  64. package/src/type-helpers.ts +79 -1
  65. package/src/workflow-options.ts +110 -23
@@ -11,6 +11,23 @@ export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclu
11
11
  /** Verify that an type _Copy extends _Orig */
12
12
  export declare function checkExtends<_Orig, _Copy extends _Orig>(): void;
13
13
  export type Replace<Base, New> = Omit<Base, keyof New> & New;
14
+ export type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? // The `& Union` is to allow indexing by the resulting type
15
+ Intersection & Union : never;
16
+ type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2 ? true : false;
17
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
18
+ type IsNull<T> = [T] extends [null] ? true : false;
19
+ type IsUnknown<T> = unknown extends T ? IsNull<T> extends false ? true : false : false;
20
+ type ObjectValue<T, K> = K extends keyof T ? T[K] : ToString<K> extends keyof T ? T[ToString<K>] : K extends `${infer NumberK extends number}` ? NumberK extends keyof T ? T[NumberK] : never : never;
21
+ type ToString<T> = T extends string | number ? `${T}` : never;
22
+ type KeysOfUnion<ObjectType> = ObjectType extends unknown ? keyof ObjectType : never;
23
+ type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
24
+ type ExactObject<ParameterType, InputType> = {
25
+ [Key in keyof ParameterType]: Exact<ParameterType[Key], ObjectValue<InputType, Key>>;
26
+ } & Record<Exclude<keyof InputType, KeysOfUnion<ParameterType>>, never>;
27
+ export type Exact<ParameterType, InputType> = IsEqual<ParameterType, InputType> extends true ? ParameterType : ParameterType extends Primitive ? ParameterType : IsUnknown<ParameterType> extends true ? unknown : ParameterType extends Function ? ParameterType : ParameterType extends unknown[] ? Array<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>> : ParameterType extends readonly unknown[] ? ReadonlyArray<Exact<ArrayElement<ParameterType>, ArrayElement<InputType>>> : ExactObject<ParameterType, InputType>;
28
+ export type RemovePrefix<Prefix extends string, Keys extends string> = {
29
+ [k in Keys]: k extends `${Prefix}${infer Suffix}` ? Suffix : never;
30
+ }[Keys];
14
31
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
15
32
  export declare function hasOwnProperty<X extends Record<string, unknown>, Y extends PropertyKey>(record: X, prop: Y): record is X & Record<Y, unknown>;
16
33
  export declare function hasOwnProperties<X extends Record<string, unknown>, Y extends PropertyKey>(record: X, props: Y[]): record is X & Record<Y, unknown>;
@@ -60,3 +77,4 @@ export type Class<E extends Error> = {
60
77
  */
61
78
  export declare function SymbolBasedInstanceOfError<E extends Error>(markerName: string): (clazz: Class<E>) => void;
62
79
  export declare function deepFreeze<T>(object: T): T;
80
+ export {};
@@ -1,34 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deepFreeze = exports.SymbolBasedInstanceOfError = exports.assertNever = exports.errorCode = exports.errorMessage = exports.isAbortError = exports.isError = exports.hasOwnProperties = exports.hasOwnProperty = exports.isRecord = exports.checkExtends = void 0;
3
+ exports.checkExtends = checkExtends;
4
+ exports.isRecord = isRecord;
5
+ exports.hasOwnProperty = hasOwnProperty;
6
+ exports.hasOwnProperties = hasOwnProperties;
7
+ exports.isError = isError;
8
+ exports.isAbortError = isAbortError;
9
+ exports.errorMessage = errorMessage;
10
+ exports.errorCode = errorCode;
11
+ exports.assertNever = assertNever;
12
+ exports.SymbolBasedInstanceOfError = SymbolBasedInstanceOfError;
13
+ exports.deepFreeze = deepFreeze;
4
14
  /** Verify that an type _Copy extends _Orig */
5
15
  function checkExtends() {
6
16
  // noop, just type check
7
17
  }
8
- exports.checkExtends = checkExtends;
9
18
  function isRecord(value) {
10
19
  return typeof value === 'object' && value !== null;
11
20
  }
12
- exports.isRecord = isRecord;
13
21
  function hasOwnProperty(record, prop) {
14
22
  return prop in record;
15
23
  }
16
- exports.hasOwnProperty = hasOwnProperty;
17
24
  function hasOwnProperties(record, props) {
18
25
  return props.every((prop) => prop in record);
19
26
  }
20
- exports.hasOwnProperties = hasOwnProperties;
21
27
  function isError(error) {
22
28
  return (isRecord(error) &&
23
29
  typeof error.name === 'string' &&
24
30
  typeof error.message === 'string' &&
25
31
  (error.stack == null || typeof error.stack === 'string'));
26
32
  }
27
- exports.isError = isError;
28
33
  function isAbortError(error) {
29
34
  return isError(error) && error.name === 'AbortError';
30
35
  }
31
- exports.isAbortError = isAbortError;
32
36
  /**
33
37
  * Get `error.message` (or `undefined` if not present)
34
38
  */
@@ -41,7 +45,6 @@ function errorMessage(error) {
41
45
  }
42
46
  return undefined;
43
47
  }
44
- exports.errorMessage = errorMessage;
45
48
  function isErrorWithCode(error) {
46
49
  return isRecord(error) && typeof error.code === 'string';
47
50
  }
@@ -54,14 +57,12 @@ function errorCode(error) {
54
57
  }
55
58
  return undefined;
56
59
  }
57
- exports.errorCode = errorCode;
58
60
  /**
59
61
  * Asserts that some type is the never type
60
62
  */
61
63
  function assertNever(msg, x) {
62
64
  throw new TypeError(msg + ': ' + x);
63
65
  }
64
- exports.assertNever = assertNever;
65
66
  /**
66
67
  * A decorator to be used on error classes. It adds the 'name' property AND provides a custom
67
68
  * 'instanceof' handler that works correctly across execution contexts.
@@ -111,7 +112,6 @@ function SymbolBasedInstanceOfError(markerName) {
111
112
  });
112
113
  };
113
114
  }
114
- exports.SymbolBasedInstanceOfError = SymbolBasedInstanceOfError;
115
115
  // Thanks MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
116
116
  function deepFreeze(object) {
117
117
  // Retrieve the property names defined on object
@@ -123,7 +123,7 @@ function deepFreeze(object) {
123
123
  try {
124
124
  deepFreeze(value);
125
125
  }
126
- catch (err) {
126
+ catch (_err) {
127
127
  // This is okay, there are some typed arrays that cannot be frozen (encodingKeys)
128
128
  }
129
129
  }
@@ -133,5 +133,4 @@ function deepFreeze(object) {
133
133
  }
134
134
  return Object.freeze(object);
135
135
  }
136
- exports.deepFreeze = deepFreeze;
137
136
  //# sourceMappingURL=type-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-helpers.js","sourceRoot":"","sources":["../src/type-helpers.ts"],"names":[],"mappings":";;;AAYA,8CAA8C;AAC9C,SAAgB,YAAY;IAC1B,wBAAwB;AAC1B,CAAC;AAFD,oCAEC;AAID,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAFD,4BAEC;AAED,SAAgB,cAAc,CAC5B,MAAS,EACT,IAAO;IAEP,OAAO,IAAI,IAAI,MAAM,CAAC;AACxB,CAAC;AALD,wCAKC;AAED,SAAgB,gBAAgB,CAC9B,MAAS,EACT,KAAU;IAEV,OAAO,KAAK,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AM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.versioningIntentToProto = exports.VersioningIntent = void 0;
3
+ exports.VersioningIntent = void 0;
4
+ exports.versioningIntentToProto = versioningIntentToProto;
4
5
  const type_helpers_1 = require("./type-helpers");
5
6
  // Avoid importing the proto implementation to reduce workflow bundle size
6
7
  // Copied from coresdk.common.VersioningIntent
@@ -29,5 +30,4 @@ function versioningIntentToProto(intent) {
29
30
  (0, type_helpers_1.assertNever)('Unexpected VersioningIntent', intent);
30
31
  }
31
32
  }
32
- exports.versioningIntentToProto = versioningIntentToProto;
33
33
  //# sourceMappingURL=versioning-intent-enum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"versioning-intent-enum.js","sourceRoot":"","sources":["../src/versioning-intent-enum.ts"],"names":[],"mappings":";;;AAEA,iDAA2D;AAE3D,0EAA0E;AAC1E,8CAA8C;AAC9C;;;;GAIG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qEAAe,CAAA;IACf,mEAAc,CAAA;IACd,6DAAW,CAAA;AACb,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AAED,IAAA,2BAAY,GAAqD,CAAC;AAClE,IAAA,2BAAY,GAAqD,CAAC;AAElE,SAAgB,uBAAuB,CAAC,MAA0C;IAChF,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,gBAAgB,CAAC,OAAO,CAAC;QAClC,KAAK,YAAY;YACf,OAAO,gBAAgB,CAAC,UAAU,CAAC;QACrC,KAAK,SAAS;YACZ,OAAO,gBAAgB,CAAC,WAAW,CAAC;QACtC;YACE,IAAA,0BAAW,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAXD,0DAWC"}
1
+ {"version":3,"file":"versioning-intent-enum.js","sourceRoot":"","sources":["../src/versioning-intent-enum.ts"],"names":[],"mappings":";;;AAoBA,0DAWC;AA7BD,iDAA2D;AAE3D,0EAA0E;AAC1E,8CAA8C;AAC9C;;;;GAIG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qEAAe,CAAA;IACf,mEAAc,CAAA;IACd,6DAAW,CAAA;AACb,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AAED,IAAA,2BAAY,GAAqD,CAAC;AAClE,IAAA,2BAAY,GAAqD,CAAC;AAElE,SAAgB,uBAAuB,CAAC,MAA0C;IAChF,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,gBAAgB,CAAC,OAAO,CAAC;QAClC,KAAK,YAAY;YACf,OAAO,gBAAgB,CAAC,UAAU,CAAC;QACrC,KAAK,SAAS;YACZ,OAAO,gBAAgB,CAAC,WAAW,CAAC;QACtC;YACE,IAAA,0BAAW,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
@@ -1,47 +1,99 @@
1
+ import type { temporal } from '@temporalio/proto';
1
2
  import { SearchAttributes, Workflow } from './interfaces';
2
3
  import { RetryPolicy } from './retry-policy';
3
4
  import { Duration } from './time';
4
5
  /**
6
+ * Defines what happens when trying to start a Workflow with the same ID as a *Closed* Workflow.
7
+ *
8
+ * See {@link WorkflowOptions.workflowIdConflictPolicy} for what happens when trying to start a
9
+ * Workflow with the same ID as a *Running* Workflow.
10
+ *
5
11
  * Concept: {@link https://docs.temporal.io/concepts/what-is-a-workflow-id-reuse-policy/ | Workflow Id Reuse Policy}
6
12
  *
7
- * Whether a Workflow can be started with a Workflow Id of a Closed Workflow.
13
+ * *Note: It is not possible to have two actively running Workflows with the same ID.*
8
14
  *
9
- * *Note: A Workflow can never be started with a Workflow Id of a Running Workflow.*
10
15
  */
11
- export declare enum WorkflowIdReusePolicy {
12
- /**
13
- * No need to use this.
14
- *
15
- * (If a `WorkflowIdReusePolicy` is set to this, or is not set at all, the default value will be used.)
16
- */
17
- WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED = 0,
16
+ export declare const WorkflowIdReusePolicy: {
18
17
  /**
19
18
  * The Workflow can be started if the previous Workflow is in a Closed state.
20
19
  * @default
21
20
  */
22
- WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE = 1,
21
+ readonly ALLOW_DUPLICATE: "ALLOW_DUPLICATE";
23
22
  /**
24
23
  * The Workflow can be started if the previous Workflow is in a Closed state that is not Completed.
25
24
  */
26
- WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY = 2,
25
+ readonly ALLOW_DUPLICATE_FAILED_ONLY: "ALLOW_DUPLICATE_FAILED_ONLY";
27
26
  /**
28
27
  * The Workflow cannot be started.
29
28
  */
30
- WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE = 3,
29
+ readonly REJECT_DUPLICATE: "REJECT_DUPLICATE";
30
+ /**
31
+ * Terminate the current Workflow if one is already running; otherwise allow reusing the Workflow ID.
32
+ *
33
+ * @deprecated Use {@link WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE} instead, and
34
+ * set `WorkflowOptions.workflowIdConflictPolicy` to
35
+ * {@link WorkflowIdConflictPolicy.WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTING}.
36
+ * When using this option, `WorkflowOptions.workflowIdConflictPolicy` must be left unspecified.
37
+ */
38
+ readonly TERMINATE_IF_RUNNING: "TERMINATE_IF_RUNNING";
31
39
  /**
32
- * Terminate the current workflow if one is already running.
40
+ * No need to use this. If a `WorkflowIdReusePolicy` is set to this, or is not set at all, the default value will be used.
41
+ *
42
+ * @deprecated Either leave property `undefined`, or use {@link ALLOW_DUPLICATE} instead.
33
43
  */
34
- WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING = 4
35
- }
44
+ readonly WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED: undefined;
45
+ /** @deprecated Use {@link ALLOW_DUPLICATE} instead. */
46
+ readonly WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE: "ALLOW_DUPLICATE";
47
+ /** @deprecated Use {@link ALLOW_DUPLICATE_FAILED_ONLY} instead. */
48
+ readonly WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY: "ALLOW_DUPLICATE_FAILED_ONLY";
49
+ /** @deprecated Use {@link REJECT_DUPLICATE} instead. */
50
+ readonly WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE: "REJECT_DUPLICATE";
51
+ /** @deprecated Use {@link TERMINATE_IF_RUNNING} instead. */
52
+ readonly WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING: "TERMINATE_IF_RUNNING";
53
+ };
54
+ export type WorkflowIdReusePolicy = (typeof WorkflowIdReusePolicy)[keyof typeof WorkflowIdReusePolicy];
55
+ export declare const encodeWorkflowIdReusePolicy: (input: "ALLOW_DUPLICATE" | "ALLOW_DUPLICATE_FAILED_ONLY" | "REJECT_DUPLICATE" | "TERMINATE_IF_RUNNING" | "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE" | "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY" | "WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE" | "WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING" | temporal.api.enums.v1.WorkflowIdReusePolicy | null | undefined) => temporal.api.enums.v1.WorkflowIdReusePolicy | undefined, decodeWorkflowIdReusePolicy: (input: temporal.api.enums.v1.WorkflowIdReusePolicy | null | undefined) => "ALLOW_DUPLICATE" | "ALLOW_DUPLICATE_FAILED_ONLY" | "REJECT_DUPLICATE" | "TERMINATE_IF_RUNNING" | undefined;
56
+ /**
57
+ * Defines what happens when trying to start a Workflow with the same ID as a *Running* Workflow.
58
+ *
59
+ * See {@link WorkflowOptions.workflowIdReusePolicy} for what happens when trying to start a Workflow
60
+ * with the same ID as a *Closed* Workflow.
61
+ *
62
+ * *Note: It is never possible to have two _actively running_ Workflows with the same ID.*
63
+ */
64
+ export type WorkflowIdConflictPolicy = (typeof WorkflowIdConflictPolicy)[keyof typeof WorkflowIdConflictPolicy];
65
+ export declare const WorkflowIdConflictPolicy: {
66
+ /**
67
+ * Do not start a new Workflow. Instead raise a `WorkflowExecutionAlreadyStartedError`.
68
+ */
69
+ readonly FAIL: "FAIL";
70
+ /**
71
+ * Do not start a new Workflow. Instead return a Workflow Handle for the already Running Workflow.
72
+ */
73
+ readonly USE_EXISTING: "USE_EXISTING";
74
+ /**
75
+ * Start a new Workflow, terminating the current workflow if one is already running.
76
+ */
77
+ readonly TERMINATE_EXISTING: "TERMINATE_EXISTING";
78
+ };
79
+ export declare const encodeWorkflowIdConflictPolicy: (input: "FAIL" | "USE_EXISTING" | "TERMINATE_EXISTING" | temporal.api.enums.v1.WorkflowIdConflictPolicy | "WORKFLOW_ID_CONFLICT_POLICY_FAIL" | "WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING" | "WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTING" | null | undefined) => temporal.api.enums.v1.WorkflowIdConflictPolicy | undefined, decodeWorkflowIdConflictPolicy: (input: temporal.api.enums.v1.WorkflowIdConflictPolicy | null | undefined) => "FAIL" | "USE_EXISTING" | "TERMINATE_EXISTING" | undefined;
36
80
  export interface BaseWorkflowOptions {
37
81
  /**
38
- * Whether a Workflow can be started with a Workflow Id of a Closed Workflow.
82
+ * Defines what happens when trying to start a Workflow with the same ID as a *Closed* Workflow.
39
83
  *
40
- * *Note: A Workflow can never be started with a Workflow Id of a Running Workflow.*
84
+ * *Note: It is not possible to have two actively running Workflows with the same ID.*
41
85
  *
42
86
  * @default {@link WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE}
43
87
  */
44
88
  workflowIdReusePolicy?: WorkflowIdReusePolicy;
89
+ /**
90
+ * Defines what happens when trying to start a Workflow with the same ID as a *Running* Workflow.
91
+ *
92
+ * *Note: It is not possible to have two actively running Workflows with the same ID.*
93
+ *
94
+ * @default {@link WorkflowIdConflictPolicy.WORKFLOW_ID_CONFLICT_POLICY_UNSPECIFIED}
95
+ */
96
+ workflowIdConflictPolicy?: WorkflowIdConflictPolicy;
45
97
  /**
46
98
  * Controls how a Workflow Execution is retried.
47
99
  *
@@ -1,44 +1,86 @@
1
1
  "use strict";
2
+ var _a, _b;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractWorkflowType = exports.WorkflowIdReusePolicy = void 0;
4
- const type_helpers_1 = require("./type-helpers");
5
- // Avoid importing the proto implementation to reduce workflow bundle size
6
- // Copied from temporal.api.enums.v1.WorkflowIdReusePolicy
4
+ exports.decodeWorkflowIdConflictPolicy = exports.encodeWorkflowIdConflictPolicy = exports.WorkflowIdConflictPolicy = exports.decodeWorkflowIdReusePolicy = exports.encodeWorkflowIdReusePolicy = exports.WorkflowIdReusePolicy = void 0;
5
+ exports.extractWorkflowType = extractWorkflowType;
6
+ const internal_workflow_1 = require("./internal-workflow");
7
7
  /**
8
+ * Defines what happens when trying to start a Workflow with the same ID as a *Closed* Workflow.
9
+ *
10
+ * See {@link WorkflowOptions.workflowIdConflictPolicy} for what happens when trying to start a
11
+ * Workflow with the same ID as a *Running* Workflow.
12
+ *
8
13
  * Concept: {@link https://docs.temporal.io/concepts/what-is-a-workflow-id-reuse-policy/ | Workflow Id Reuse Policy}
9
14
  *
10
- * Whether a Workflow can be started with a Workflow Id of a Closed Workflow.
15
+ * *Note: It is not possible to have two actively running Workflows with the same ID.*
11
16
  *
12
- * *Note: A Workflow can never be started with a Workflow Id of a Running Workflow.*
13
17
  */
14
- var WorkflowIdReusePolicy;
15
- (function (WorkflowIdReusePolicy) {
16
- /**
17
- * No need to use this.
18
- *
19
- * (If a `WorkflowIdReusePolicy` is set to this, or is not set at all, the default value will be used.)
20
- */
21
- WorkflowIdReusePolicy[WorkflowIdReusePolicy["WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED"] = 0] = "WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED";
18
+ exports.WorkflowIdReusePolicy = {
22
19
  /**
23
20
  * The Workflow can be started if the previous Workflow is in a Closed state.
24
21
  * @default
25
22
  */
26
- WorkflowIdReusePolicy[WorkflowIdReusePolicy["WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE"] = 1] = "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE";
23
+ ALLOW_DUPLICATE: 'ALLOW_DUPLICATE',
27
24
  /**
28
25
  * The Workflow can be started if the previous Workflow is in a Closed state that is not Completed.
29
26
  */
30
- WorkflowIdReusePolicy[WorkflowIdReusePolicy["WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY"] = 2] = "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY";
27
+ ALLOW_DUPLICATE_FAILED_ONLY: 'ALLOW_DUPLICATE_FAILED_ONLY',
31
28
  /**
32
29
  * The Workflow cannot be started.
33
30
  */
34
- WorkflowIdReusePolicy[WorkflowIdReusePolicy["WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE"] = 3] = "WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE";
31
+ REJECT_DUPLICATE: 'REJECT_DUPLICATE',
35
32
  /**
36
- * Terminate the current workflow if one is already running.
33
+ * Terminate the current Workflow if one is already running; otherwise allow reusing the Workflow ID.
34
+ *
35
+ * @deprecated Use {@link WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE} instead, and
36
+ * set `WorkflowOptions.workflowIdConflictPolicy` to
37
+ * {@link WorkflowIdConflictPolicy.WORKFLOW_ID_CONFLICT_POLICY_TERMINATE_EXISTING}.
38
+ * When using this option, `WorkflowOptions.workflowIdConflictPolicy` must be left unspecified.
37
39
  */
38
- WorkflowIdReusePolicy[WorkflowIdReusePolicy["WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING"] = 4] = "WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING";
39
- })(WorkflowIdReusePolicy || (exports.WorkflowIdReusePolicy = WorkflowIdReusePolicy = {}));
40
- (0, type_helpers_1.checkExtends)();
41
- (0, type_helpers_1.checkExtends)();
40
+ TERMINATE_IF_RUNNING: 'TERMINATE_IF_RUNNING', // eslint-disable-line deprecation/deprecation
41
+ /// Anything below this line has been deprecated
42
+ /**
43
+ * No need to use this. If a `WorkflowIdReusePolicy` is set to this, or is not set at all, the default value will be used.
44
+ *
45
+ * @deprecated Either leave property `undefined`, or use {@link ALLOW_DUPLICATE} instead.
46
+ */
47
+ WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED: undefined, // eslint-disable-line deprecation/deprecation
48
+ /** @deprecated Use {@link ALLOW_DUPLICATE} instead. */
49
+ WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE: 'ALLOW_DUPLICATE', // eslint-disable-line deprecation/deprecation
50
+ /** @deprecated Use {@link ALLOW_DUPLICATE_FAILED_ONLY} instead. */
51
+ WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY: 'ALLOW_DUPLICATE_FAILED_ONLY', // eslint-disable-line deprecation/deprecation
52
+ /** @deprecated Use {@link REJECT_DUPLICATE} instead. */
53
+ WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE: 'REJECT_DUPLICATE', // eslint-disable-line deprecation/deprecation
54
+ /** @deprecated Use {@link TERMINATE_IF_RUNNING} instead. */
55
+ WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING: 'TERMINATE_IF_RUNNING', // eslint-disable-line deprecation/deprecation
56
+ };
57
+ _a = (0, internal_workflow_1.makeProtoEnumConverters)({
58
+ [exports.WorkflowIdReusePolicy.ALLOW_DUPLICATE]: 1,
59
+ [exports.WorkflowIdReusePolicy.ALLOW_DUPLICATE_FAILED_ONLY]: 2,
60
+ [exports.WorkflowIdReusePolicy.REJECT_DUPLICATE]: 3,
61
+ [exports.WorkflowIdReusePolicy.TERMINATE_IF_RUNNING]: 4, // eslint-disable-line deprecation/deprecation
62
+ UNSPECIFIED: 0,
63
+ }, 'WORKFLOW_ID_REUSE_POLICY_'), exports.encodeWorkflowIdReusePolicy = _a[0], exports.decodeWorkflowIdReusePolicy = _a[1];
64
+ exports.WorkflowIdConflictPolicy = {
65
+ /**
66
+ * Do not start a new Workflow. Instead raise a `WorkflowExecutionAlreadyStartedError`.
67
+ */
68
+ FAIL: 'FAIL',
69
+ /**
70
+ * Do not start a new Workflow. Instead return a Workflow Handle for the already Running Workflow.
71
+ */
72
+ USE_EXISTING: 'USE_EXISTING',
73
+ /**
74
+ * Start a new Workflow, terminating the current workflow if one is already running.
75
+ */
76
+ TERMINATE_EXISTING: 'TERMINATE_EXISTING',
77
+ };
78
+ _b = (0, internal_workflow_1.makeProtoEnumConverters)({
79
+ [exports.WorkflowIdConflictPolicy.FAIL]: 1,
80
+ [exports.WorkflowIdConflictPolicy.USE_EXISTING]: 2,
81
+ [exports.WorkflowIdConflictPolicy.TERMINATE_EXISTING]: 3,
82
+ UNSPECIFIED: 0,
83
+ }, 'WORKFLOW_ID_CONFLICT_POLICY_'), exports.encodeWorkflowIdConflictPolicy = _b[0], exports.decodeWorkflowIdConflictPolicy = _b[1];
42
84
  function extractWorkflowType(workflowTypeOrFunc) {
43
85
  if (typeof workflowTypeOrFunc === 'string')
44
86
  return workflowTypeOrFunc;
@@ -49,5 +91,4 @@ function extractWorkflowType(workflowTypeOrFunc) {
49
91
  }
50
92
  throw new TypeError(`Invalid workflow type: expected either a string or a function, got '${typeof workflowTypeOrFunc}'`);
51
93
  }
52
- exports.extractWorkflowType = extractWorkflowType;
53
94
  //# sourceMappingURL=workflow-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-options.js","sourceRoot":"","sources":["../src/workflow-options.ts"],"names":[],"mappings":";;;AAIA,iDAA8C;AAE9C,0EAA0E;AAC1E,0DAA0D;AAC1D;;;;;;GAMG;AACH,IAAY,qBA4BX;AA5BD,WAAY,qBAAqB;IAC/B;;;;OAIG;IACH,iIAAwC,CAAA;IAExC;;;OAGG;IACH,yIAA4C,CAAA;IAE5C;;OAEG;IACH,iKAAwD,CAAA;IAExD;;OAEG;IACH,2IAA6C,CAAA;IAE7C;;OAEG;IACH,mJAAiD,CAAA;AACnD,CAAC,EA5BW,qBAAqB,qCAArB,qBAAqB,QA4BhC;AAED,IAAA,2BAAY,GAAsE,CAAC;AACnF,IAAA,2BAAY,GAAsE,CAAC;AA2FnF,SAAgB,mBAAmB,CAAqB,kBAA8B;IACpF,IAAI,OAAO,kBAAkB,KAAK,QAAQ;QAAE,OAAO,kBAA4B,CAAC;IAChF,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE,CAAC;QAC7C,IAAI,kBAAkB,EAAE,IAAI;YAAE,OAAO,kBAAkB,CAAC,IAAI,CAAC;QAC7D,MAAM,IAAI,SAAS,CAAC,2DAA2D,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,IAAI,SAAS,CACjB,uEAAuE,OAAO,kBAAkB,GAAG,CACpG,CAAC;AACJ,CAAC;AATD,kDASC"}
1
+ {"version":3,"file":"workflow-options.js","sourceRoot":"","sources":["../src/workflow-options.ts"],"names":[],"mappings":";;;;AAgOA,kDASC;AArOD,2DAA8D;AAE9D;;;;;;;;;;GAUG;AACU,QAAA,qBAAqB,GAAG;IACnC;;;OAGG;IACH,eAAe,EAAE,iBAAiB;IAElC;;OAEG;IACH,2BAA2B,EAAE,6BAA6B;IAE1D;;OAEG;IACH,gBAAgB,EAAE,kBAAkB;IAEpC;;;;;;;OAOG;IACH,oBAAoB,EAAE,sBAAsB,EAAE,8CAA8C;IAE5F,gDAAgD;IAEhD;;;;OAIG;IACH,oCAAoC,EAAE,SAAS,EAAE,8CAA8C;IAE/F,uDAAuD;IACvD,wCAAwC,EAAE,i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SAAS,CAAC,2DAA2D,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,IAAI,SAAS,CACjB,uEAAuE,OAAO,kBAAkB,GAAG,CACpG,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/common",
3
- "version": "1.11.3",
3
+ "version": "1.11.4",
4
4
  "description": "Common library for code that's used across the Client, Worker, and/or Workflow",
5
5
  "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "author": "Temporal Technologies Inc. <sdk@temporal.io>",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@temporalio/proto": "1.11.3",
15
+ "@temporalio/proto": "^1.11.4",
16
16
  "long": "^5.2.3",
17
17
  "ms": "^3.0.0-canary.1",
18
18
  "proto3-json-serializer": "^2.0.0"
@@ -36,5 +36,5 @@
36
36
  "src",
37
37
  "lib"
38
38
  ],
39
- "gitHead": "4c90f9d844710abf7e085662373aac226ec09017"
39
+ "gitHead": "6a7e2d527c9f7078ee78abd9d59ca0d318bb70dd"
40
40
  }
@@ -1,19 +1,30 @@
1
1
  import type { coresdk } from '@temporalio/proto';
2
2
  import { RetryPolicy } from './retry-policy';
3
- import { checkExtends } from './type-helpers';
4
3
  import { Duration } from './time';
5
4
  import { VersioningIntent } from './versioning-intent';
6
-
7
- // Avoid importing the proto implementation to reduce workflow bundle size
8
- // Copied from coresdk.workflow_commands.ActivityCancellationType
9
- export enum ActivityCancellationType {
10
- TRY_CANCEL = 0,
11
- WAIT_CANCELLATION_COMPLETED = 1,
12
- ABANDON = 2,
13
- }
14
-
15
- checkExtends<coresdk.workflow_commands.ActivityCancellationType, ActivityCancellationType>();
16
- checkExtends<ActivityCancellationType, coresdk.workflow_commands.ActivityCancellationType>();
5
+ import { makeProtoEnumConverters } from './internal-workflow';
6
+
7
+ export const ActivityCancellationType = {
8
+ TRY_CANCEL: 'TRY_CANCEL',
9
+ WAIT_CANCELLATION_COMPLETED: 'WAIT_CANCELLATION_COMPLETED',
10
+ ABANDON: 'ABANDON',
11
+ } as const;
12
+ export type ActivityCancellationType = (typeof ActivityCancellationType)[keyof typeof ActivityCancellationType];
13
+
14
+ export const [encodeActivityCancellationType, decodeActivityCancellationType] = makeProtoEnumConverters<
15
+ coresdk.workflow_commands.ActivityCancellationType,
16
+ typeof coresdk.workflow_commands.ActivityCancellationType,
17
+ keyof typeof coresdk.workflow_commands.ActivityCancellationType,
18
+ typeof ActivityCancellationType,
19
+ ''
20
+ >(
21
+ {
22
+ [ActivityCancellationType.TRY_CANCEL]: 0,
23
+ [ActivityCancellationType.WAIT_CANCELLATION_COMPLETED]: 1,
24
+ [ActivityCancellationType.ABANDON]: 2,
25
+ } as const,
26
+ ''
27
+ );
17
28
 
18
29
  /**
19
30
  * Options for remote activity invocation
@@ -174,5 +185,5 @@ export interface LocalActivityOptions {
174
185
  * heartbeat or chooses to ignore the cancellation request.
175
186
  * - `ABANDON` - Do not request cancellation of the activity and immediately report cancellation to the workflow.
176
187
  */
177
- cancellationType?: coresdk.workflow_commands.ActivityCancellationType;
188
+ cancellationType?: ActivityCancellationType;
178
189
  }
@@ -3,14 +3,16 @@ import {
3
3
  ApplicationFailure,
4
4
  CancelledFailure,
5
5
  ChildWorkflowFailure,
6
+ decodeRetryState,
7
+ decodeTimeoutType,
8
+ encodeRetryState,
9
+ encodeTimeoutType,
6
10
  FAILURE_SOURCE,
7
11
  ProtoFailure,
8
- RetryState,
9
12
  ServerFailure,
10
13
  TemporalFailure,
11
14
  TerminatedFailure,
12
15
  TimeoutFailure,
13
- TimeoutType,
14
16
  } from '../failure';
15
17
  import { isError } from '../type-helpers';
16
18
  import { msOptionalToTs } from '../time';
@@ -139,7 +141,7 @@ export class DefaultFailureConverter implements FailureConverter {
139
141
  return new TimeoutFailure(
140
142
  failure.message ?? undefined,
141
143
  fromPayloadsAtIndex(payloadConverter, 0, failure.timeoutFailureInfo.lastHeartbeatDetails?.payloads),
142
- failure.timeoutFailureInfo.timeoutType ?? TimeoutType.TIMEOUT_TYPE_UNSPECIFIED
144
+ decodeTimeoutType(failure.timeoutFailureInfo.timeoutType)
143
145
  );
144
146
  }
145
147
  if (failure.terminatedFailureInfo) {
@@ -173,7 +175,7 @@ export class DefaultFailureConverter implements FailureConverter {
173
175
  namespace ?? undefined,
174
176
  workflowExecution,
175
177
  workflowType.name,
176
- retryState ?? RetryState.RETRY_STATE_UNSPECIFIED,
178
+ decodeRetryState(retryState),
177
179
  this.optionalFailureToOptionalError(failure.cause, payloadConverter)
178
180
  );
179
181
  }
@@ -185,7 +187,7 @@ export class DefaultFailureConverter implements FailureConverter {
185
187
  failure.message ?? undefined,
186
188
  failure.activityFailureInfo.activityType.name,
187
189
  failure.activityFailureInfo.activityId ?? undefined,
188
- failure.activityFailureInfo.retryState ?? RetryState.RETRY_STATE_UNSPECIFIED,
190
+ decodeRetryState(failure.activityFailureInfo.retryState),
189
191
  failure.activityFailureInfo.identity ?? undefined,
190
192
  this.optionalFailureToOptionalError(failure.cause, payloadConverter)
191
193
  );
@@ -244,6 +246,7 @@ export class DefaultFailureConverter implements FailureConverter {
244
246
  ...base,
245
247
  activityFailureInfo: {
246
248
  ...err,
249
+ retryState: encodeRetryState(err.retryState),
247
250
  activityType: { name: err.activityType },
248
251
  },
249
252
  };
@@ -253,6 +256,7 @@ export class DefaultFailureConverter implements FailureConverter {
253
256
  ...base,
254
257
  childWorkflowExecutionFailureInfo: {
255
258
  ...err,
259
+ retryState: encodeRetryState(err.retryState),
256
260
  workflowExecution: err.execution,
257
261
  workflowType: { name: err.workflowType },
258
262
  },
@@ -287,7 +291,7 @@ export class DefaultFailureConverter implements FailureConverter {
287
291
  return {
288
292
  ...base,
289
293
  timeoutFailureInfo: {
290
- timeoutType: err.timeoutType,
294
+ timeoutType: encodeTimeoutType(err.timeoutType),
291
295
  lastHeartbeatDetails: err.lastHeartbeatDetails
292
296
  ? { payloads: toPayloads(payloadConverter, err.lastHeartbeatDetails) }
293
297
  : undefined,
@@ -232,7 +232,7 @@ export class JsonPayloadConverter implements PayloadConverterWithEncoding {
232
232
  let json;
233
233
  try {
234
234
  json = JSON.stringify(value);
235
- } catch (err) {
235
+ } catch (_err) {
236
236
  return undefined;
237
237
  }
238
238