@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
@@ -1 +1 @@
1
- {"version":3,"file":"proxy-config.js","sourceRoot":"","sources":["../../src/internal-non-workflow/proxy-config.ts"],"names":[],"mappings":";;;AAAA,qDAAqE;AAgCrE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,4BAA4B,CAAC,MAAc;IACzD,MAAM,KAAK,GAAG,IAAA,mCAAkB,EAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,SAAS,CACjB,mGAAmG,MAAM,GAAG,CAC7G,CAAC;IACJ,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACxD,IAAI,MAAM,KAAK,MAAM;QACnB,MAAM,IAAI,SAAS,CAAC,sEAAsE,MAAM,GAAG,CAAC,CAAC;IACvG,IAAI,IAAI,KAAK,SAAS;QACpB,MAAM,IAAI,SAAS,CAAC,kEAAkE,MAAM,GAAG,CAAC,CAAC;IACnG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC;AAZD,oEAYC"}
1
+ {"version":3,"file":"proxy-config.js","sourceRoot":"","sources":["../../src/internal-non-workflow/proxy-config.ts"],"names":[],"mappings":";;AA+CA,oEAYC;AA3DD,qDAAqE;AAgCrE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,4BAA4B,CAAC,MAAc;IACzD,MAAM,KAAK,GAAG,IAAA,mCAAkB,EAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,SAAS,CACjB,mGAAmG,MAAM,GAAG,CAC7G,CAAC;IACJ,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACxD,IAAI,MAAM,KAAK,MAAM;QACnB,MAAM,IAAI,SAAS,CAAC,sEAAsE,MAAM,GAAG,CAAC,CAAC;IACvG,IAAI,IAAI,KAAK,SAAS;QACpB,MAAM,IAAI,SAAS,CAAC,kEAAkE,MAAM,GAAG,CAAC,CAAC;IACnG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /** TLS configuration options. */
3
2
  export interface TLSConfig {
4
3
  /**
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeTlsConfig = void 0;
3
+ exports.normalizeTlsConfig = normalizeTlsConfig;
4
4
  /**
5
5
  * Normalize {@link TLSConfigOption} by turning false and null to undefined and true to and empty object
6
6
  */
7
7
  function normalizeTlsConfig(tls) {
8
8
  return typeof tls === 'object' ? (tls === null ? undefined : tls) : tls ? {} : undefined;
9
9
  }
10
- exports.normalizeTlsConfig = normalizeTlsConfig;
11
10
  //# sourceMappingURL=tls-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tls-config.js","sourceRoot":"","sources":["../../src/internal-non-workflow/tls-config.ts"],"names":[],"mappings":";;;AA+BA;;GAEG;AACH,SAAgB,kBAAkB,CAAC,GAAoB;IACrD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3F,CAAC;AAFD,gDAEC"}
1
+ {"version":3,"file":"tls-config.js","sourceRoot":"","sources":["../../src/internal-non-workflow/tls-config.ts"],"names":[],"mappings":";;AAkCA,gDAEC;AALD;;GAEG;AACH,SAAgB,kBAAkB,CAAC,GAAoB;IACrD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3F,CAAC"}
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterNullAndUndefined = void 0;
3
+ exports.filterNullAndUndefined = filterNullAndUndefined;
4
4
  /**
5
5
  * Helper to prevent undefined and null values overriding defaults when merging maps
6
6
  */
7
7
  function filterNullAndUndefined(obj) {
8
8
  return Object.fromEntries(Object.entries(obj).filter(([_k, v]) => v != null));
9
9
  }
10
- exports.filterNullAndUndefined = filterNullAndUndefined;
11
10
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal-non-workflow/utils.ts"],"names":[],"mappings":";;;AAAA;;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;AAFD,wDAEC"}
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"}
@@ -0,0 +1,170 @@
1
+ import { Exact, RemovePrefix, UnionToIntersection } from '../type-helpers';
2
+ /**
3
+ * Create encoding and decoding functions to convert between the numeric `enum` types produced by our
4
+ * Protobuf compiler and "const object of strings" enum values that we expose in our public APIs.
5
+ *
6
+ * ### Usage
7
+ *
8
+ * Newly introduced enums should follow the following pattern:
9
+ *
10
+ * ```ts
11
+ * type ParentClosePolicy = (typeof ParentClosePolicy)[keyof typeof ParentClosePolicy];
12
+ * const ParentClosePolicy = {
13
+ * TERMINATE: 'TERMINATE',
14
+ * ABANDON: 'ABANDON',
15
+ * REQUEST_CANCEL: 'REQUEST_CANCEL',
16
+ * } as const;
17
+ *
18
+ * const [encodeParentClosePolicy, decodeParentClosePolicy] = //
19
+ * makeProtoEnumConverters<
20
+ * coresdk.child_workflow.ParentClosePolicy,
21
+ * typeof coresdk.child_workflow.ParentClosePolicy,
22
+ * keyof typeof coresdk.child_workflow.ParentClosePolicy,
23
+ * typeof ParentClosePolicy,
24
+ * 'PARENT_CLOSE_POLICY_' // This may be an empty string if the proto enum doesn't add a repeated prefix on values
25
+ * >(
26
+ * {
27
+ * [ParentClosePolicy.TERMINATE]: 1, // These numbers must match the ones in the proto enum
28
+ * [ParentClosePolicy.ABANDON]: 2,
29
+ * [ParentClosePolicy.REQUEST_CANCEL]: 3,
30
+ *
31
+ * UNSPECIFIED: 0,
32
+ * } as const,
33
+ * 'PARENT_CLOSE_POLICY_'
34
+ * );
35
+ * ```
36
+ *
37
+ * `makeProtoEnumConverters` supports other usage patterns, but they are only meant for
38
+ * backward compatibility with former enum definitions and should not be used for new enums.
39
+ *
40
+ * ### Context
41
+ *
42
+ * Temporal's Protobuf APIs define several `enum` types; our Protobuf compiler transforms these to
43
+ * traditional (i.e. non-const) [TypeScript numeric `enum`s](https://www.typescriptlang.org/docs/handbook/enums.html#numeric-enums).
44
+ *
45
+ * For various reasons, this is far from ideal:
46
+ *
47
+ * - Due to the dual nature of non-const TypeScript `enum`s (they are both a type and a value),
48
+ * it is not possible to refer to an enum value from code without a "real" import of the enum type
49
+ * (i.e. can't simply do `import type ...`). In Workflow code, such an import would result in
50
+ * loading our entire Protobuf definitions into the workflow sandbox, adding several megabytes to
51
+ * the per-workflow memory footprint, which is unacceptable; to avoid that, we need to maintain
52
+ * a mirror copy of each enum types used by in-workflow APIs, and export these from either
53
+ * `@temporalio/common` or `@temporalio/workflow`.
54
+ * - It is not desirable for users to need an explicit dependency on `@temporalio/proto` just to
55
+ * get access to these enum types; we therefore made it a common practice to reexport these enums
56
+ * from our public facing packages. However, experience demontrated that these reexports effectively
57
+ * resulted in poor and inconsistent documentation coverage compared to mirrored enums types.
58
+ * - Our Protobuf enum types tend to follow a verbose and redundant naming convention, which feels
59
+ * unatural and excessive according to most TypeScript style guides; e.g. instead of
60
+ * `workflowIdReusePolicy: WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE`,
61
+ * a TypeScript developer would generally expect to be able to write something similar to
62
+ * `workflowIdReusePolicy: 'REJECT_DUPLICATE'`.
63
+ * - Because of the way Protobuf works, many of our enum types contain an `UNSPECIFIED` value, which
64
+ * is used to explicitly identify a value that is unset. In TypeScript code, the `undefined` value
65
+ * already serves that purpose, and is definitely more idiomatic to TS developers, whereas these
66
+ * `UNSPECIFIED` values create noise and confusion in our APIs.
67
+ * - TypeScript editors generally do a very bad job at providing autocompletion that implies reaching
68
+ * for values of a TypeScript enum type, forcing developers to explicitly type in at least part
69
+ * of the name of the enum type before they can get autocompletion for its values. On the other
70
+ * hand, all TS editors immediately provide autocompletion for string union types.
71
+ * - The [TypeScript's official documentation](https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
72
+ * itself suggests that, in modern TypeScript, the use of `as const` objects may generally suffice
73
+ * and may be advantageous over the use of `enum` types.
74
+ *
75
+ * A const object of strings, combined with a union type of possible string values, provides a much
76
+ * more idiomatic syntax and a better DX for TypeScript developers. This however requires a way to
77
+ * convert back and forth between the `enum` values produced by the Protobuf compiler and the
78
+ * equivalent string values.
79
+ *
80
+ * This helper dynamically creates these conversion functions for a given Protobuf enum type,
81
+ * strongly building upon specific conventions that we have adopted in our Protobuf definitions.
82
+ *
83
+ * ### Validations
84
+ *
85
+ * The complex type signature of this helper is there to prevent most potential incoherencies
86
+ * that could result from having to manually synchronize the const object of strings enum and the
87
+ * conversion table with the proto enum, while not requiring a regular import on the Protobuf enum
88
+ * itself (so it can be used safely for enums meant to be used from workflow code).
89
+ *
90
+ * In particular, failing any of the following invariants will result in build time errors:
91
+ *
92
+ * - For every key of the form `PREFIX_KEY: number` in the proto enum, excluding the `UNSPECIFIED` key:
93
+ * - There MUST be a corresponding `KEY: 'KEY'` entry in the const object of strings enum;
94
+ * - There MAY be a corresponding `PREFIX_KEY: 'KEY'` in the const object of strings enum
95
+ * (this is meant to preserve backward compatibility with the former syntax; such aliases should
96
+ * not be added for new enums and enum entries introduced going forward);
97
+ * - There MUST be a corresponding `KEY: number` in the mapping table.
98
+ * - If the proto enum contains a `PREFIX_UNSPECIFIED` entry, then:
99
+ * - There MAY be a corresponding `PREFIX_UNSPECIFIED: undefined` and/or `UNSPECIFIED: undefined`
100
+ * entries in the const object of strings enum — this is meant to preserve backward compatibility
101
+ * with the former syntax; this alias should not be added for new enums introduced going forward;
102
+ * - There MUST be an `UNSPECIFIED: 0` in the mapping table.
103
+ * - The const object of strings enum MUST NOT contain any other keys than the ones mandated or
104
+ * optionally allowed be the preceeding rules.
105
+ * - The mapping table MUST NOT contain any other keys than the ones mandated above.
106
+ *
107
+ * These rules notably ensure that whenever a new value is added to an existing Proto enum, the code
108
+ * will fail to compile until the corresponding entry is added on the const object of strings enum
109
+ * and the mapping table.
110
+ *
111
+ * @internal
112
+ */
113
+ export declare function makeProtoEnumConverters<ProtoEnumValue extends number, ProtoEnum extends {
114
+ [k in ProtoEnumKey]: ProtoEnumValue;
115
+ }, ProtoEnumKey extends `${Prefix}${string}`, StringEnumTypeActual extends Exact<StringEnumType, StringEnumTypeActual>, Prefix extends string, Unspecified = ProtoEnumKey extends `${Prefix}UNSPECIFIED` ? 'UNSPECIFIED' : never, ShortStringEnumKey extends RemovePrefix<Prefix, ProtoEnumKey> = Exclude<RemovePrefix<Prefix, ProtoEnumKey>, Unspecified>, StringEnumType extends ProtoConstObjectOfStringsEnum<ShortStringEnumKey, Prefix, Unspecified> = ProtoConstObjectOfStringsEnum<ShortStringEnumKey, Prefix, Unspecified>, MapTable extends ProtoEnumToConstObjectOfStringMapTable<StringEnumType, ProtoEnumValue, ProtoEnum, ProtoEnumKey, Prefix, Unspecified, ShortStringEnumKey> = ProtoEnumToConstObjectOfStringMapTable<StringEnumType, ProtoEnumValue, ProtoEnum, ProtoEnumKey, Prefix, Unspecified, ShortStringEnumKey>>(mapTable: MapTable, prefix: Prefix): [
116
+ (input: ShortStringEnumKey | `${Prefix}${ShortStringEnumKey}` | ProtoEnumValue | null | undefined) => ProtoEnumValue | undefined,
117
+ (input: ProtoEnumValue | null | undefined) => ShortStringEnumKey | undefined
118
+ ];
119
+ /**
120
+ * Given the exploded parameters of a proto enum (i.e. short keys, prefix, and short key of the
121
+ * unspecified value), make a type that _exactly_ corresponds to the const object of strings enum,
122
+ * e.g. the type that the developer is expected to write.
123
+ *
124
+ * For example, for coresdk.child_workflow.ParentClosePolicy, this evaluates to:
125
+ *
126
+ * {
127
+ * TERMINATE: "TERMINATE";
128
+ * ABANDON: "ABANDON";
129
+ * REQUEST_CANCEL: "REQUEST_CANCEL";
130
+ *
131
+ * PARENT_CLOSE_POLICY_TERMINATE?: "TERMINATE";
132
+ * PARENT_CLOSE_POLICY_ABANDON?: "ABANDON";
133
+ * PARENT_CLOSE_POLICY_REQUEST_CANCEL?: "REQUEST_CANCEL";
134
+ *
135
+ * PARENT_CLOSE_POLICY_UNSPECIFIED?: undefined;
136
+ * }
137
+ */
138
+ type ProtoConstObjectOfStringsEnum<ShortStringEnumKey extends string, Prefix extends string, Unspecified> = UnionToIntersection<{
139
+ readonly [k in ShortStringEnumKey]: k;
140
+ } | {
141
+ [k in ShortStringEnumKey]: Prefix extends '' ? object : {
142
+ readonly [kk in `${Prefix}${k}`]?: k;
143
+ };
144
+ }[ShortStringEnumKey] | (Unspecified extends string ? {
145
+ [k in `${Prefix}${Unspecified}`]?: undefined;
146
+ } : object) | (Unspecified extends string ? {
147
+ [k in `${Unspecified}`]?: undefined;
148
+ } : object)>;
149
+ /**
150
+ * Given the exploded parameters of a proto enum (i.e. short keys, prefix, and short key of the
151
+ * unspecified value), make a type that _exactly_ corresponds to the mapping table that the user is
152
+ * expected to provide.
153
+ *
154
+ * For example, for coresdk.child_workflow.ParentClosePolicy, this evaluates to:
155
+ *
156
+ * {
157
+ * UNSPECIFIED: 0,
158
+ * TERMINATE: 1,
159
+ * ABANDON: 2,
160
+ * REQUEST_CANCEL: 3,
161
+ * }
162
+ */
163
+ type ProtoEnumToConstObjectOfStringMapTable<_StringEnum extends ProtoConstObjectOfStringsEnum<ShortStringEnumKey, Prefix, Unspecified>, ProtoEnumValue extends number, ProtoEnum extends {
164
+ [k in ProtoEnumKey]: ProtoEnumValue;
165
+ }, ProtoEnumKey extends `${Prefix}${string}`, Prefix extends string, Unspecified, ShortStringEnumKey extends RemovePrefix<Prefix, ProtoEnumKey>> = UnionToIntersection<{
166
+ [k in ProtoEnumKey]: {
167
+ [kk in RemovePrefix<Prefix, k>]: ProtoEnum[k] extends number ? ProtoEnum[k] : never;
168
+ };
169
+ }[ProtoEnumKey]>;
170
+ export {};
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeProtoEnumConverters = makeProtoEnumConverters;
4
+ const errors_1 = require("../errors");
5
+ /**
6
+ * Create encoding and decoding functions to convert between the numeric `enum` types produced by our
7
+ * Protobuf compiler and "const object of strings" enum values that we expose in our public APIs.
8
+ *
9
+ * ### Usage
10
+ *
11
+ * Newly introduced enums should follow the following pattern:
12
+ *
13
+ * ```ts
14
+ * type ParentClosePolicy = (typeof ParentClosePolicy)[keyof typeof ParentClosePolicy];
15
+ * const ParentClosePolicy = {
16
+ * TERMINATE: 'TERMINATE',
17
+ * ABANDON: 'ABANDON',
18
+ * REQUEST_CANCEL: 'REQUEST_CANCEL',
19
+ * } as const;
20
+ *
21
+ * const [encodeParentClosePolicy, decodeParentClosePolicy] = //
22
+ * makeProtoEnumConverters<
23
+ * coresdk.child_workflow.ParentClosePolicy,
24
+ * typeof coresdk.child_workflow.ParentClosePolicy,
25
+ * keyof typeof coresdk.child_workflow.ParentClosePolicy,
26
+ * typeof ParentClosePolicy,
27
+ * 'PARENT_CLOSE_POLICY_' // This may be an empty string if the proto enum doesn't add a repeated prefix on values
28
+ * >(
29
+ * {
30
+ * [ParentClosePolicy.TERMINATE]: 1, // These numbers must match the ones in the proto enum
31
+ * [ParentClosePolicy.ABANDON]: 2,
32
+ * [ParentClosePolicy.REQUEST_CANCEL]: 3,
33
+ *
34
+ * UNSPECIFIED: 0,
35
+ * } as const,
36
+ * 'PARENT_CLOSE_POLICY_'
37
+ * );
38
+ * ```
39
+ *
40
+ * `makeProtoEnumConverters` supports other usage patterns, but they are only meant for
41
+ * backward compatibility with former enum definitions and should not be used for new enums.
42
+ *
43
+ * ### Context
44
+ *
45
+ * Temporal's Protobuf APIs define several `enum` types; our Protobuf compiler transforms these to
46
+ * traditional (i.e. non-const) [TypeScript numeric `enum`s](https://www.typescriptlang.org/docs/handbook/enums.html#numeric-enums).
47
+ *
48
+ * For various reasons, this is far from ideal:
49
+ *
50
+ * - Due to the dual nature of non-const TypeScript `enum`s (they are both a type and a value),
51
+ * it is not possible to refer to an enum value from code without a "real" import of the enum type
52
+ * (i.e. can't simply do `import type ...`). In Workflow code, such an import would result in
53
+ * loading our entire Protobuf definitions into the workflow sandbox, adding several megabytes to
54
+ * the per-workflow memory footprint, which is unacceptable; to avoid that, we need to maintain
55
+ * a mirror copy of each enum types used by in-workflow APIs, and export these from either
56
+ * `@temporalio/common` or `@temporalio/workflow`.
57
+ * - It is not desirable for users to need an explicit dependency on `@temporalio/proto` just to
58
+ * get access to these enum types; we therefore made it a common practice to reexport these enums
59
+ * from our public facing packages. However, experience demontrated that these reexports effectively
60
+ * resulted in poor and inconsistent documentation coverage compared to mirrored enums types.
61
+ * - Our Protobuf enum types tend to follow a verbose and redundant naming convention, which feels
62
+ * unatural and excessive according to most TypeScript style guides; e.g. instead of
63
+ * `workflowIdReusePolicy: WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE`,
64
+ * a TypeScript developer would generally expect to be able to write something similar to
65
+ * `workflowIdReusePolicy: 'REJECT_DUPLICATE'`.
66
+ * - Because of the way Protobuf works, many of our enum types contain an `UNSPECIFIED` value, which
67
+ * is used to explicitly identify a value that is unset. In TypeScript code, the `undefined` value
68
+ * already serves that purpose, and is definitely more idiomatic to TS developers, whereas these
69
+ * `UNSPECIFIED` values create noise and confusion in our APIs.
70
+ * - TypeScript editors generally do a very bad job at providing autocompletion that implies reaching
71
+ * for values of a TypeScript enum type, forcing developers to explicitly type in at least part
72
+ * of the name of the enum type before they can get autocompletion for its values. On the other
73
+ * hand, all TS editors immediately provide autocompletion for string union types.
74
+ * - The [TypeScript's official documentation](https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
75
+ * itself suggests that, in modern TypeScript, the use of `as const` objects may generally suffice
76
+ * and may be advantageous over the use of `enum` types.
77
+ *
78
+ * A const object of strings, combined with a union type of possible string values, provides a much
79
+ * more idiomatic syntax and a better DX for TypeScript developers. This however requires a way to
80
+ * convert back and forth between the `enum` values produced by the Protobuf compiler and the
81
+ * equivalent string values.
82
+ *
83
+ * This helper dynamically creates these conversion functions for a given Protobuf enum type,
84
+ * strongly building upon specific conventions that we have adopted in our Protobuf definitions.
85
+ *
86
+ * ### Validations
87
+ *
88
+ * The complex type signature of this helper is there to prevent most potential incoherencies
89
+ * that could result from having to manually synchronize the const object of strings enum and the
90
+ * conversion table with the proto enum, while not requiring a regular import on the Protobuf enum
91
+ * itself (so it can be used safely for enums meant to be used from workflow code).
92
+ *
93
+ * In particular, failing any of the following invariants will result in build time errors:
94
+ *
95
+ * - For every key of the form `PREFIX_KEY: number` in the proto enum, excluding the `UNSPECIFIED` key:
96
+ * - There MUST be a corresponding `KEY: 'KEY'` entry in the const object of strings enum;
97
+ * - There MAY be a corresponding `PREFIX_KEY: 'KEY'` in the const object of strings enum
98
+ * (this is meant to preserve backward compatibility with the former syntax; such aliases should
99
+ * not be added for new enums and enum entries introduced going forward);
100
+ * - There MUST be a corresponding `KEY: number` in the mapping table.
101
+ * - If the proto enum contains a `PREFIX_UNSPECIFIED` entry, then:
102
+ * - There MAY be a corresponding `PREFIX_UNSPECIFIED: undefined` and/or `UNSPECIFIED: undefined`
103
+ * entries in the const object of strings enum — this is meant to preserve backward compatibility
104
+ * with the former syntax; this alias should not be added for new enums introduced going forward;
105
+ * - There MUST be an `UNSPECIFIED: 0` in the mapping table.
106
+ * - The const object of strings enum MUST NOT contain any other keys than the ones mandated or
107
+ * optionally allowed be the preceeding rules.
108
+ * - The mapping table MUST NOT contain any other keys than the ones mandated above.
109
+ *
110
+ * These rules notably ensure that whenever a new value is added to an existing Proto enum, the code
111
+ * will fail to compile until the corresponding entry is added on the const object of strings enum
112
+ * and the mapping table.
113
+ *
114
+ * @internal
115
+ */
116
+ function makeProtoEnumConverters(mapTable, prefix) {
117
+ const reverseTable = Object.fromEntries(Object.entries(mapTable).map(([k, v]) => [v, k]));
118
+ const hasUnspecified = mapTable['UNSPECIFIED'] === 0 || mapTable[`${prefix}UNSPECIFIED`] === 0;
119
+ function isShortStringEnumKeys(x) {
120
+ return typeof x === 'string' && x in mapTable;
121
+ }
122
+ function isNumericEnumValue(x) {
123
+ return typeof x === 'number' && x in reverseTable;
124
+ }
125
+ function encode(input) {
126
+ if (input == null) {
127
+ return undefined;
128
+ }
129
+ else if (typeof input === 'string') {
130
+ let shorten = input;
131
+ if (shorten.startsWith(prefix)) {
132
+ shorten = shorten.slice(prefix.length);
133
+ }
134
+ if (isShortStringEnumKeys(shorten)) {
135
+ return mapTable[shorten];
136
+ }
137
+ throw new errors_1.ValueError(`Invalid enum value: '${input}'`);
138
+ }
139
+ else if (typeof input === 'number') {
140
+ return input;
141
+ }
142
+ else {
143
+ throw new errors_1.ValueError(`Invalid enum value: '${input}' of type ${typeof input}`);
144
+ }
145
+ }
146
+ function decode(input) {
147
+ if (input == null) {
148
+ return undefined;
149
+ }
150
+ else if (typeof input === 'number') {
151
+ if (hasUnspecified && input === 0) {
152
+ return undefined;
153
+ }
154
+ if (isNumericEnumValue(input)) {
155
+ return reverseTable[input];
156
+ }
157
+ // We got a proto enum value that we don't yet know about (i.e. it didn't exist when this code
158
+ // was compiled). This is certainly a possibility, but given how our APIs evolve, this is is
159
+ // unlikely to be a terribly bad thing by itself (we avoid adding new enum values in places
160
+ // that would break backward compatibility with existing deployed code). Therefore, throwing
161
+ // on "unexpected" values is likely to end up causing more problems than it might avoid,
162
+ // especially given that the decoded value may actually never get read anwyay.
163
+ //
164
+ // Therefore, we instead cheat on type constraints and return a string of the form "unknown_23".
165
+ // That somewhat mirrors the behavior we'd get with the pure numerical approach.
166
+ return `unknown_${input}`;
167
+ }
168
+ throw new errors_1.ValueError(`Invalid proto enum value: '${input}' of type ${typeof input}`);
169
+ }
170
+ return [encode, decode];
171
+ }
172
+ //# sourceMappingURL=enums-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums-helpers.js","sourceRoot":"","sources":["../../src/internal-workflow/enums-helpers.ts"],"names":[],"mappings":";;AAkHA,0DA0GC;AA5ND,sCAAuC;AAGvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GG;AACH,SAAgB,uBAAuB,CAoCrC,QAAkB,EAClB,MAAc;IAOd,MAAM,YAAY,GAA+C,MAAM,CAAC,WAAW,CACjF,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CACjD,CAAC;IACF,MAAM,cAAc,GAAI,QAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,IAAK,QAAgB,CAAC,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,CAAC;IAEjH,SAAS,qBAAqB,CAAC,CAAU;QACvC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,IAAI,QAAQ,CAAC;IAChD,CAAC;IAED,SAAS,kBAAkB,CAAC,CAAU;QACpC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,IAAI,YAAY,CAAC;IACpD,CAAC;IAED,S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wB,CAAC;QAClD,CAAC;QAED,MAAM,IAAI,mBAAU,CAAC,8BAA8B,KAAK,aAAa,OAAO,KAAK,EAAE,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AACnC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './enums-helpers';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums-helpers"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal-workflow/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC"}
@@ -23,7 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.JSONToPayload = exports.payloadToJSON = exports.historyToJSON = exports.historyFromJSON = void 0;
26
+ exports.historyFromJSON = historyFromJSON;
27
+ exports.historyToJSON = historyToJSON;
28
+ exports.payloadToJSON = payloadToJSON;
29
+ exports.JSONToPayload = JSONToPayload;
27
30
  const proto3_json_serializer_1 = require("proto3-json-serializer");
28
31
  const proto = __importStar(require("@temporalio/proto"));
29
32
  const patch_protobuf_root_1 = require("@temporalio/proto/lib/patch-protobuf-root");
@@ -105,7 +108,6 @@ function historyFromJSON(history) {
105
108
  }
106
109
  return loaded;
107
110
  }
108
- exports.historyFromJSON = historyFromJSON;
109
111
  /**
110
112
  * Convert an History object, e.g. as returned by `WorkflowClient.list().withHistory()`, to a JSON
111
113
  * string that adheres to the same norm as JSON history files produced by other Temporal tools.
@@ -129,14 +131,12 @@ function historyToJSON(history) {
129
131
  const protoJson = (0, proto3_json_serializer_1.toProto3JSON)(proto.temporal.api.history.v1.History.fromObject(history));
130
132
  return JSON.stringify(fixBuffers(protoJson), null, 2);
131
133
  }
132
- exports.historyToJSON = historyToJSON;
133
134
  /**
134
135
  * Convert from protobuf payload to JSON
135
136
  */
136
137
  function payloadToJSON(payload) {
137
138
  return (0, proto3_json_serializer_1.toProto3JSON)(patched.temporal.api.common.v1.Payload.create(payload));
138
139
  }
139
- exports.payloadToJSON = payloadToJSON;
140
140
  /**
141
141
  * Convert from JSON to protobuf payload
142
142
  */
@@ -147,5 +147,4 @@ function JSONToPayload(json) {
147
147
  }
148
148
  return loaded;
149
149
  }
150
- exports.JSONToPayload = JSONToPayload;
151
150
  //# sourceMappingURL=proto-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"proto-utils.js","sourceRoot":"","sources":["../src/proto-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAsE;AACtE,yDAA2C;AAC3C,mFAA8E;AAmB9E,yFAAyF;AACzF,MAAM,OAAO,GAAG,IAAA,uCAAiB,EAAC,KAAK,CAAQ,CAAC;AAChD,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,iCAAiC,CAAC,CAAC;AAC1E,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,gCAAgC,CAAC,CAAC;AAEzE;;GAEG;AACH,SAAgB,eAAe,CAAC,OAAgB;IAC9C,SAAS,wBAAwB,CAAC,CAAS;QACzC,OAAO,CA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uCAAc,EAAC,WAAW,EAAE,IAAW,CAAC,CAAC;IACxD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAAa,CAAC;AACvB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decompileRetryPolicy = exports.compileRetryPolicy = void 0;
3
+ exports.compileRetryPolicy = compileRetryPolicy;
4
+ exports.decompileRetryPolicy = decompileRetryPolicy;
4
5
  const errors_1 = require("./errors");
5
6
  const time_1 = require("./time");
6
7
  /**
@@ -42,7 +43,6 @@ function compileRetryPolicy(retryPolicy) {
42
43
  nonRetryableErrorTypes: retryPolicy.nonRetryableErrorTypes,
43
44
  };
44
45
  }
45
- exports.compileRetryPolicy = compileRetryPolicy;
46
46
  /**
47
47
  * Turn a proto compatible RetryPolicy into a TS RetryPolicy
48
48
  */
@@ -58,5 +58,4 @@ function decompileRetryPolicy(retryPolicy) {
58
58
  nonRetryableErrorTypes: retryPolicy.nonRetryableErrorTypes ?? undefined,
59
59
  };
60
60
  }
61
- exports.decompileRetryPolicy = decompileRetryPolicy;
62
61
  //# sourceMappingURL=retry-policy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry-policy.js","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":";;;AACA,qCAAsC;AACtC,iCAA0G;AA2C1G;;GAEG;AACH,SAAgB,kBAAkB,CAAC,WAAwB;IACzD,IAAI,WAAW,CAAC,kBAAkB,IAAI,IAAI,IAAI,WAAW,CAAC,kBAAkB,IAAI,CAAC,EAAE,CAAC;QAClF,MAAM,IAAI,mBAAU,CAAC,uDAAuD,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,WAAW,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;QACxC,IAAI,WAAW,CAAC,eAAe,KAAK,MAAM,CAAC,iBAAiB,EA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ib/time.js CHANGED
@@ -3,7 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.optionalDateToTs = exports.optionalTsToDate = exports.requiredTsToDate = exports.tsToDate = exports.msToNumber = exports.msOptionalToNumber = exports.msOptionalToTs = exports.msToTs = exports.msNumberToTs = exports.tsToMs = exports.requiredTsToMs = exports.optionalTsToMs = void 0;
6
+ exports.optionalTsToMs = optionalTsToMs;
7
+ exports.requiredTsToMs = requiredTsToMs;
8
+ exports.tsToMs = tsToMs;
9
+ exports.msNumberToTs = msNumberToTs;
10
+ exports.msToTs = msToTs;
11
+ exports.msOptionalToTs = msOptionalToTs;
12
+ exports.msOptionalToNumber = msOptionalToNumber;
13
+ exports.msToNumber = msToNumber;
14
+ exports.tsToDate = tsToDate;
15
+ exports.requiredTsToDate = requiredTsToDate;
16
+ exports.optionalTsToDate = optionalTsToDate;
17
+ exports.optionalDateToTs = optionalDateToTs;
7
18
  const long_1 = __importDefault(require("long")); // eslint-disable-line import/no-named-as-default
8
19
  const ms_1 = __importDefault(require("ms"));
9
20
  const errors_1 = require("./errors");
@@ -17,7 +28,6 @@ function optionalTsToMs(ts) {
17
28
  }
18
29
  return tsToMs(ts);
19
30
  }
20
- exports.optionalTsToMs = optionalTsToMs;
21
31
  /**
22
32
  * Lossy conversion function from Timestamp to number due to possible overflow.
23
33
  * If ts is null or undefined, throws a TypeError, with error message including the name of the field.
@@ -28,7 +38,6 @@ function requiredTsToMs(ts, fieldName) {
28
38
  }
29
39
  return tsToMs(ts);
30
40
  }
31
- exports.requiredTsToMs = requiredTsToMs;
32
41
  /**
33
42
  * Lossy conversion function from Timestamp to number due to possible overflow
34
43
  */
@@ -42,7 +51,6 @@ function tsToMs(ts) {
42
51
  .add(Math.floor((nanos || 0) / 1000000))
43
52
  .toNumber();
44
53
  }
45
- exports.tsToMs = tsToMs;
46
54
  function msNumberToTs(millis) {
47
55
  const seconds = Math.floor(millis / 1000);
48
56
  const nanos = (millis % 1000) * 1000000;
@@ -51,28 +59,23 @@ function msNumberToTs(millis) {
51
59
  }
52
60
  return { seconds: long_1.default.fromNumber(seconds), nanos };
53
61
  }
54
- exports.msNumberToTs = msNumberToTs;
55
62
  function msToTs(str) {
56
63
  return msNumberToTs(msToNumber(str));
57
64
  }
58
- exports.msToTs = msToTs;
59
65
  function msOptionalToTs(str) {
60
66
  return str ? msToTs(str) : undefined;
61
67
  }
62
- exports.msOptionalToTs = msOptionalToTs;
63
68
  function msOptionalToNumber(val) {
64
69
  if (val === undefined)
65
70
  return undefined;
66
71
  return msToNumber(val);
67
72
  }
68
- exports.msOptionalToNumber = msOptionalToNumber;
69
73
  function msToNumber(val) {
70
74
  if (typeof val === 'number') {
71
75
  return val;
72
76
  }
73
77
  return msWithValidation(val);
74
78
  }
75
- exports.msToNumber = msToNumber;
76
79
  function msWithValidation(str) {
77
80
  const millis = (0, ms_1.default)(str);
78
81
  if (millis == null || isNaN(millis)) {
@@ -83,19 +86,16 @@ function msWithValidation(str) {
83
86
  function tsToDate(ts) {
84
87
  return new Date(tsToMs(ts));
85
88
  }
86
- exports.tsToDate = tsToDate;
87
89
  // ts-prune-ignore-next
88
90
  function requiredTsToDate(ts, fieldName) {
89
91
  return new Date(requiredTsToMs(ts, fieldName));
90
92
  }
91
- exports.requiredTsToDate = requiredTsToDate;
92
93
  function optionalTsToDate(ts) {
93
94
  if (ts === undefined || ts === null) {
94
95
  return undefined;
95
96
  }
96
97
  return new Date(tsToMs(ts));
97
98
  }
98
- exports.optionalTsToDate = optionalTsToDate;
99
99
  // ts-prune-ignore-next (imported via schedule-helpers.ts)
100
100
  function optionalDateToTs(date) {
101
101
  if (date === undefined || date === null) {
@@ -103,5 +103,4 @@ function optionalDateToTs(date) {
103
103
  }
104
104
  return msToTs(date.getTime());
105
105
  }
106
- exports.optionalDateToTs = optionalDateToTs;
107
106
  //# sourceMappingUR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