@temporalio/common 1.8.5 → 1.9.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.
@@ -89,6 +89,8 @@ export interface ActivityOptions {
89
89
  * When using the Worker Versioning feature, specifies whether this Activity should run on a
90
90
  * worker with a compatible Build Id or not. See {@link VersioningIntent}.
91
91
  *
92
+ * @default 'COMPATIBLE'
93
+ *
92
94
  * @experimental
93
95
  */
94
96
  versioningIntent?: VersioningIntent;
@@ -4,29 +4,39 @@ exports.DefaultFailureConverter = exports.cutoffStackTrace = void 0;
4
4
  const failure_1 = require("../failure");
5
5
  const type_helpers_1 = require("../type-helpers");
6
6
  const payload_converter_1 = require("./payload-converter");
7
+ function combineRegExp(...regexps) {
8
+ return new RegExp(regexps.map((x) => `(?:${x.source})`).join('|'));
9
+ }
7
10
  /**
8
11
  * Stack traces will be cutoff when on of these patterns is matched
9
12
  */
10
- const CUTOFF_STACK_PATTERNS = [
11
- /** Activity execution */
12
- /\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,
13
- /** Workflow activation */
14
- /\s+at Activator\.\S+NextHandler \(.*[\\/]workflow[\\/](?:src|lib)[\\/]internals\.[jt]s:\d+:\d+\)/,
15
- /** Workflow run anything in context */
16
- /\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/,
17
- ];
13
+ const CUTOFF_STACK_PATTERNS = combineRegExp(
14
+ /** Activity execution */
15
+ /\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,
16
+ /** Workflow activation */
17
+ /\s+at Activator\.\S+NextHandler \(.*[\\/]workflow[\\/](?:src|lib)[\\/]internals\.[jt]s:\d+:\d+\)/,
18
+ /** Workflow run anything in context */
19
+ /\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/);
20
+ /**
21
+ * Any stack trace frames that match any of those wil be dopped.
22
+ * The "null." prefix on some cases is to avoid https://github.com/nodejs/node/issues/42417
23
+ */
24
+ const DROPPED_STACK_FRAMES_PATTERNS = combineRegExp(
25
+ /** Internal functions used to recursively chain interceptors */
26
+ /\s+at (null\.)?next \(.*[\\/]common[\\/](?:src|lib)[\\/]interceptors\.[jt]s:\d+:\d+\)/,
27
+ /** Internal functions used to recursively chain interceptors */
28
+ /\s+at (null\.)?executeNextHandler \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/);
18
29
  /**
19
30
  * Cuts out the framework part of a stack trace, leaving only user code entries
20
31
  */
21
32
  function cutoffStackTrace(stack) {
22
33
  const lines = (stack ?? '').split(/\r?\n/);
23
34
  const acc = Array();
24
- lineLoop: for (const line of lines) {
25
- for (const pattern of CUTOFF_STACK_PATTERNS) {
26
- if (pattern.test(line))
27
- break lineLoop;
28
- }
29
- acc.push(line);
35
+ for (const line of lines) {
36
+ if (CUTOFF_STACK_PATTERNS.test(line))
37
+ break;
38
+ if (!DROPPED_STACK_FRAMES_PATTERNS.test(line))
39
+ acc.push(line);
30
40
  }
31
41
  return acc.join('\n');
32
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"failure-converter.js","sourceRoot":"","sources":["../../src/converter/failure-converter.ts"],"names":[],"mappings":";;;AAAA,wCAaoB;AACpB,kDAA0C;AAC1C,2DAA2G;AAE3G;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC5B,yBAAyB;IACzB,uFAAuF;IACvF,0BAA0B;IAC1B,kGAAkG;IAClG,uCAAuC;IACvC,2DAA2D;CAC5D,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,MAAM,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,KAAK,EAAU,CAAC;IAC5B,QAAQ,EAAE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;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) {
183
183
  return ((0, type_helpers_1.isRecord)(type) &&
184
- type.constructor.name === 'Type' &&
184
+ // constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
185
+ type.constructor.className === 'Type' &&
185
186
  (0, type_helpers_1.hasOwnProperties)(type, ['parent', 'name', 'create', 'encode', 'decode']) &&
186
187
  typeof type.name === 'string' &&
187
188
  typeof type.create === 'function' &&
@@ -200,7 +201,8 @@ function getNamespacedTypeName(node) {
200
201
  }
201
202
  }
202
203
  function isRoot(root) {
203
- return (0, type_helpers_1.isRecord)(root) && root.constructor.name === 'Root';
204
+ // constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
205
+ return (0, type_helpers_1.isRecord)(root) && root.constructor.className === 'Root';
204
206
  }
205
207
  class DefaultPayloadConverterWithProtobufs extends payload_converter_1.CompositePayloadConverter {
206
208
  // Match the order used in other SDKs.
@@ -1 +1 @@
1
- {"version":3,"file":"protobuf-payload-converters.js","sourceRoot":"","sources":["../../src/converter/protobuf-payload-converters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA8D;AAE9D,0CAA6C;AAC7C,sCAA8D;AAE9D,kDAA2F;AAC3F,2DAM6B;AAE7B,mCAA0F;AAE1F,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,0BAA0B,CAAC,EAAE,CAAC;AAEvF,MAAe,wBAAwB;IAOrC,qGAAqG;IACrG,YAAY,IAAc;QACxB,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACjB,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;aACtE;YAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;IACH,CAAC;IAES,eAAe,CAAC,OAAgB;QACxC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE;YACvD,MAAM,IAAI,mBAAU,C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E;QACvC,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;KAC7D;SAAM;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;KAClB;AACH,CAAC;AAED,SAAS,MAAM,CAAC,IAAa;IAC3B,OAAO,IAAA,uBAAQ,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC;AAC5D,CAAC;AASD,MAAa,oCAAqC,SAAQ,6CAAyB;IACjF,sCAAsC;IACtC,EAAE;IACF,UAAU;IACV,6HAA6H;IAC7H,YAAY,EAAE,YAAY,EAA+C;QACvE,KAAK,CACH,IAAI,6CAAyB,EAAE,EAC/B,IAAI,0CAAsB,EAAE,EAC5B,IAAI,4BAA4B,CAAC,YAAY,CAAC,EAC9C,IAAI,8BAA8B,CAAC,YAAY,CAAC,EAChD,IAAI,wCAAoB,EAAE,CAC3B,CAAC;IACJ,CAAC;CACF;AAdD,oFAcC"}
1
+ {"version":3,"file":"protobuf-payload-converters.js","sourceRoot":"","sources":["../../src/converter/protobuf-payload-converters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA8D;AAE9D,0CAA6C;AAC7C,sCAA8D;AAE9D,kDAA2F;AAC3F,2DAM6B;AAE7B,mCAA0F;AAE1F,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,0BAA0B,CAAC,EAAE,CAAC;AAEvF,MAAe,wBAAwB;IAOrC,qGAAqG;IACrG,YAAY,IAAc;QACxB,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACjB,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;aACtE;YAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;IACH,CAAC;IAES,eAAe,CAAC,OAAgB;QACxC,IAAI,OAAO,CAAC,IAAI,K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,CAAC,IAAsB;IACnD,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACvC,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;KAC7D;SAAM;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;KAClB;AACH,CAAC;AAED,SAAS,MAAM,CAAC,IAAa;IAC3B,sGAAsG;IACtG,OAAO,IAAA,uBAAQ,EAAC,IAAI,CAAC,IAAK,IAAI,CAAC,WAAmB,CAAC,SAAS,KAAK,MAAM,CAAC;AAC1E,CAAC;AASD,MAAa,oCAAqC,SAAQ,6CAAyB;IACjF,sCAAsC;IACtC,EAAE;IACF,UAAU;IACV,6HAA6H;IAC7H,YAAY,EAAE,YAAY,EAA+C;QACvE,KAAK,CACH,IAAI,6CAAyB,EAAE,EAC/B,IAAI,0CAAsB,EAAE,EAC5B,IAAI,4BAA4B,CAAC,YAAY,CAAC,EAC9C,IAAI,8BAA8B,CAAC,YAAY,CAAC,EAChD,IAAI,wCAAoB,EAAE,CAC3B,CAAC;IACJ,CAAC;CACF;AAdD,oFAcC"}
@@ -9,7 +9,10 @@ export type Next<IF, FN extends keyof IF> = Required<IF>[FN] extends AnyFunc ? O
9
9
  /** Headers are just a mapping of header name to Payload */
10
10
  export type Headers = Record<string, Payload>;
11
11
  /**
12
- * Composes all interceptor methods into a single function
12
+ * Compose all interceptor methods into a single function.
13
+ *
14
+ * Calling the composed function results in calling each of the provided interceptor, in order (from the first to
15
+ * the last), followed by the original function provided as argument to `composeInterceptors()`.
13
16
  *
14
17
  * @param interceptors a list of interceptors
15
18
  * @param method the name of the interceptor method to compose
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.composeInterceptors = void 0;
4
4
  /**
5
- * Composes all interceptor methods into a single function
5
+ * Compose all interceptor methods into a single function.
6
+ *
7
+ * Calling the composed function results in calling each of the provided interceptor, in order (from the first to
8
+ * the last), followed by the original function provided as argument to `composeInterceptors()`.
6
9
  *
7
10
  * @param interceptors a list of interceptors
8
11
  * @param method the name of the interceptor method to compose
@@ -14,7 +17,7 @@ function composeInterceptors(interceptors, method, next) {
14
17
  const interceptor = interceptors[i];
15
18
  if (interceptor[method] !== undefined) {
16
19
  const prev = next;
17
- // We loose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
20
+ // We lose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
18
21
  // the same type as Next<I, M>
19
22
  next = ((input) => interceptor[method](input, prev));
20
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../src/interceptors.ts"],"names":[],"mappings":";;;AAaA;;;;;;GAMG;AACH,uDAAuD;AACvD,SAAgB,mBAAmB,CAAuB,YAAiB,EAAE,MAAS,EAAE,IAAgB;IACtG,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;QACjD,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC;YAClB,gHAAgH;YAChH,8BAA8B;YAC9B,IAAI,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAE,WAAW,CAAC,MAAM,CAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAQ,CAAC;SAC3E;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,kDAWC"}
1
+ {"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../src/interceptors.ts"],"names":[],"mappings":";;;AAaA;;;;;;;;;GASG;AACH,uDAAuD;AACvD,SAAgB,mBAAmB,CAAuB,YAAiB,EAAE,MAAS,EAAE,IAAgB;IACtG,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE;QACjD,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC;YAClB,+GAA+G;YAC/G,8BAA8B;YAC9B,IAAI,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAE,WAAW,CAAC,MAAM,CAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAQ,CAAC;SAC3E;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,kDAWC"}
@@ -2,6 +2,8 @@ import type { temporal } from '@temporalio/proto';
2
2
  export type Payload = temporal.api.common.v1.IPayload;
3
3
  /** Type that can be returned from a Workflow `execute` function */
4
4
  export type WorkflowReturnType = Promise<any>;
5
+ export type WorkflowUpdateType = (...args: any[]) => Promise<any> | any;
6
+ export type WorkflowUpdateValidatorType = (...args: any[]) => void;
5
7
  export type WorkflowSignalType = (...args: any[]) => Promise<void> | void;
6
8
  export type WorkflowQueryType = (...args: any[]) => any;
7
9
  /**
@@ -12,10 +14,31 @@ export type WorkflowQueryType = (...args: any[]) => any;
12
14
  */
13
15
  export type Workflow = (...args: any[]) => WorkflowReturnType;
14
16
  declare const argsBrand: unique symbol;
17
+ declare const retBrand: unique symbol;
18
+ /**
19
+ * An interface representing a Workflow update definition, as returned from {@link defineUpdate}
20
+ *
21
+ * @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
22
+ * `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the update name.
23
+ */
24
+ export interface UpdateDefinition<Ret, Args extends any[] = [], Name extends string = string> {
25
+ type: 'update';
26
+ name: Name;
27
+ /**
28
+ * Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different args.
29
+ * This field is not present at run-time.
30
+ */
31
+ [argsBrand]: Args;
32
+ /**
33
+ * Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different return types.
34
+ * This field is not present at run-time.
35
+ */
36
+ [retBrand]: Ret;
37
+ }
15
38
  /**
16
39
  * An interface representing a Workflow signal definition, as returned from {@link defineSignal}
17
40
  *
18
- * @remarks `Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
41
+ * @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
19
42
  * `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the signal name.
20
43
  */
21
44
  export interface SignalDefinition<Args extends any[] = [], Name extends string = string> {
@@ -27,11 +50,10 @@ export interface SignalDefinition<Args extends any[] = [], Name extends string =
27
50
  */
28
51
  [argsBrand]: Args;
29
52
  }
30
- declare const retBrand: unique symbol;
31
53
  /**
32
54
  * An interface representing a Workflow query definition as returned from {@link defineQuery}
33
55
  *
34
- * @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
56
+ * @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and WorkflowHandle methods.
35
57
  * `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the query name.
36
58
  */
37
59
  export interface QueryDefinition<Ret, Args extends any[] = [], Name extends string = string> {
@@ -2,9 +2,11 @@
2
2
  /** TLS configuration options. */
3
3
  export interface TLSConfig {
4
4
  /**
5
- * Overrides the target name used for SSL host name checking.
6
- * If this attribute is not specified, the name used for SSL host name checking will be the host from {@link ServerOptions.url}.
7
- * This _should_ be used for testing only.
5
+ * Overrides the target name (SNI) used for TLS host name checking.
6
+ * If this attribute is not specified, the name used for TLS host name checking will be the host from {@link ServerOptions.url}.
7
+ * This can be useful when you have reverse proxy in front of temporal server, and you may want to override the SNI to
8
+ * direct traffic to the appropriate backend server based on custom routing rules. Oppositely, connections could be refused
9
+ * if the provided SNI does not match the expected host. Adding this override should be done with care.
8
10
  */
9
11
  serverNameOverride?: string;
10
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tls-config.js","sourceRoot":"","sources":["../../src/internal-non-workflow/tls-config.ts"],"names":[],"mappings":";;;AA6BA;;GAEG;AACH,SAAgB,kBAAkB,CAAC,GAAqB;IACtD,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":";;;AA+BA;;GAEG;AACH,SAAgB,kBAAkB,CAAC,GAAqB;IACtD,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"}
@@ -59,3 +59,4 @@ export type Class<E extends Error> = {
59
59
  * checking for the presence of that symbol.
60
60
  */
61
61
  export declare function SymbolBasedInstanceOfError<E extends Error>(markerName: string): (clazz: Class<E>) => void;
62
+ export declare function deepFreeze<T>(object: T): T;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SymbolBasedInstanceOfError = exports.assertNever = exports.errorCode = exports.errorMessage = exports.isAbortError = exports.isError = exports.hasOwnProperties = exports.hasOwnProperty = exports.isRecord = exports.checkExtends = void 0;
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;
4
4
  /** Verify that an type _Copy extends _Orig */
5
5
  function checkExtends() {
6
6
  // noop, just type check
@@ -112,4 +112,26 @@ function SymbolBasedInstanceOfError(markerName) {
112
112
  };
113
113
  }
114
114
  exports.SymbolBasedInstanceOfError = SymbolBasedInstanceOfError;
115
+ // Thanks MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
116
+ function deepFreeze(object) {
117
+ // Retrieve the property names defined on object
118
+ const propNames = Object.getOwnPropertyNames(object);
119
+ // Freeze properties before freezing self
120
+ for (const name of propNames) {
121
+ const value = object[name];
122
+ if (value && typeof value === 'object') {
123
+ try {
124
+ deepFreeze(value);
125
+ }
126
+ catch (err) {
127
+ // This is okay, there are some typed arrays that cannot be frozen (encodingKeys)
128
+ }
129
+ }
130
+ else if (typeof value === 'function') {
131
+ Object.freeze(value);
132
+ }
133
+ }
134
+ return Object.freeze(object);
135
+ }
136
+ exports.deepFreeze = deepFreeze;
115
137
  //# 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,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC;AAC/C,CAAC;AALD,4CAKC;AAED,SAAgB,OAAO,CAAC,KAAc;IACpC,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC;QACf,OAAO,KAAK,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KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACtC,IAAI;gBACF,UAAU,CAAC,KAAK,CAAC,CAAC;aACnB;YAAC,OAAO,GAAG,EAAE;gBACZ,iFAAiF;aAClF;SACF;aAAM,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YACtC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACtB;KACF;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC;AApBD,gCAoBC"}
@@ -1,17 +1,15 @@
1
1
  /**
2
- * Indicates whether the user intends certain commands to be run on a compatible worker Build Id
3
- * version or not.
2
+ * Indicates whether the user intends certain commands to be run on a compatible worker Build Id version or not.
4
3
  *
5
- * `COMPATIBLE` indicates that the command should run on a worker with compatible version if
6
- * possible. It may not be possible if the target task queue does not also have knowledge of the
7
- * current worker's Build Id.
4
+ * `COMPATIBLE` indicates that the command should run on a worker with compatible version if possible. It may not be
5
+ * possible if the target task queue does not also have knowledge of the current worker's Build Id.
8
6
  *
9
- * `DEFAULT` indicates that the command should run on the target task queue's current
10
- * overall-default Build Id.
7
+ * `DEFAULT` indicates that the command should run on the target task queue's current overall-default Build Id.
11
8
  *
12
- * Where this type is accepted optionally, an unset value indicates that the SDK should choose the
13
- * most sensible default behavior for the type of command, accounting for whether the command will
14
- * be run on the same task queue as the current worker.
9
+ * Where this type is accepted optionally, an unset value indicates that the SDK should choose the most sensible default
10
+ * behavior for the type of command, accounting for whether the command will be run on the same task queue as the
11
+ * current worker. The default behavior for starting Workflows is `DEFAULT`. The default behavior for Workflows starting
12
+ * Activities, starting Child Workflows, or Continuing As New is `COMPATIBLE`.
15
13
  *
16
14
  * @experimental
17
15
  */
@@ -1,8 +1,6 @@
1
- import type { google } from '@temporalio/proto';
2
1
  import { SearchAttributes, Workflow } from './interfaces';
3
2
  import { RetryPolicy } from './retry-policy';
4
3
  import { Duration } from './time';
5
- import { Replace } from './type-helpers';
6
4
  /**
7
5
  * Concept: {@link https://docs.temporal.io/concepts/what-is-a-workflow-id-reuse-policy/ | Workflow Id Reuse Policy}
8
6
  *
@@ -111,10 +109,4 @@ export interface WorkflowDurationOptions {
111
109
  workflowTaskTimeout?: Duration;
112
110
  }
113
111
  export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions;
114
- export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<T, {
115
- workflowExecutionTimeout?: google.protobuf.IDuration;
116
- workflowRunTimeout?: google.protobuf.IDuration;
117
- workflowTaskTimeout?: google.protobuf.IDuration;
118
- }>;
119
- export declare function compileWorkflowOptions<T extends CommonWorkflowOptions>(options: T): WithCompiledWorkflowOptions<T>;
120
112
  export declare function extractWorkflowType<T extends Workflow>(workflowTypeOrFunc: string | T): string;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractWorkflowType = exports.compileWorkflowOptions = exports.WorkflowIdReusePolicy = void 0;
4
- const time_1 = require("./time");
3
+ exports.extractWorkflowType = exports.WorkflowIdReusePolicy = void 0;
5
4
  const type_helpers_1 = require("./type-helpers");
6
5
  // Avoid importing the proto implementation to reduce workflow bundle size
7
6
  // Copied from temporal.api.enums.v1.WorkflowIdReusePolicy
@@ -40,16 +39,6 @@ var WorkflowIdReusePolicy;
40
39
  })(WorkflowIdReusePolicy = exports.WorkflowIdReusePolicy || (exports.WorkflowIdReusePolicy = {}));
41
40
  (0, type_helpers_1.checkExtends)();
42
41
  (0, type_helpers_1.checkExtends)();
43
- function compileWorkflowOptions(options) {
44
- const { workflowExecutionTimeout, workflowRunTimeout, workflowTaskTimeout, ...rest } = options;
45
- return {
46
- ...rest,
47
- workflowExecutionTimeout: (0, time_1.msOptionalToTs)(workflowExecutionTimeout),
48
- workflowRunTimeout: (0, time_1.msOptionalToTs)(workflowRunTimeout),
49
- workflowTaskTimeout: (0, time_1.msOptionalToTs)(workflowTaskTimeout),
50
- };
51
- }
52
- exports.compileWorkflowOptions = compileWorkflowOptions;
53
42
  function extractWorkflowType(workflowTypeOrFunc) {
54
43
  if (typeof workflowTypeOrFunc === 'string')
55
44
  return workflowTypeOrFunc;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-options.js","sourceRoot":"","sources":["../src/workflow-options.ts"],"names":[],"mappings":";;;AAGA,iCAAkD;AAClD,iDAAuD;AAEvD,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,GAArB,6BAAqB,KAArB,6BAAqB,QA4BhC;AAED,IAAA,2BAAY,GAAsE,CAAC;AACnF,IAAA,2BAAY,GAAsE,CAAC;AAoGnF,SAAgB,sBAAsB,CAAkC,OAAU;IAChF,MAAM,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE/F,OAAO;QACL,GAAG,IAAI;QACP,wBAAwB,EAAE,IAAA,qBAAc,EAAC,wBAAwB,CAAC;QAClE,kBAAkB,EAAE,IAAA,qBAAc,EAAC,kBAAkB,CAAC;QACtD,mBAAmB,EAAE,IAAA,qBAAc,EAAC,mBAAmB,CAAC;KACzD,CAAC;AACJ,CAAC;AATD,wDASC;AAED,SAAgB,mBAAmB,CAAqB,kBAA8B;IACpF,IAAI,OAAO,kBAAkB,KAAK,QAAQ;QAAE,OAAO,kBAA4B,CAAC;IAChF,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE;QAC5C,IAAI,kBAAkB,EAAE,IAAI;YAAE,OAAO,kBAAkB,CAAC,IAAI,CAAC;QAC7D,MAAM,IAAI,SAAS,CAAC,2DAA2D,CAAC,CAAC;KAClF;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":";;;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,GAArB,6BAAqB,KAArB,6BAAqB,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;QAC5C,IAAI,kBAAkB,EAAE,IAAI;YAAE,OAAO,kBAAkB,CAAC,IAAI,CAAC;QAC7D,MAAM,IAAI,SAAS,CAAC,2DAA2D,CAAC,CAAC;KAClF;IACD,MAAM,IAAI,SAAS,CACjB,uEAAuE,OAAO,kBAAkB,GAAG,CACpG,CAAC;AACJ,CAAC;AATD,kDASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/common",
3
- "version": "1.8.5",
3
+ "version": "1.9.0-rc.0",
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,8 +12,7 @@
12
12
  "author": "Temporal Technologies Inc. <sdk@temporal.io>",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@opentelemetry/api": "^1.4.1",
16
- "@temporalio/proto": "1.8.5",
15
+ "@temporalio/proto": "1.9.0-rc.0",
17
16
  "long": "^5.2.0",
18
17
  "ms": "^3.0.0-canary.1",
19
18
  "proto3-json-serializer": "^1.0.3",
@@ -35,5 +34,5 @@
35
34
  "src",
36
35
  "lib"
37
36
  ],
38
- "gitHead": "1a03096ceb2d63345c3f2c190d975c2a54c7b4a5"
37
+ "gitHead": "ca3e508e62de02b2c9bb40d0d889003cebba282d"
39
38
  }
@@ -106,6 +106,8 @@ export interface ActivityOptions {
106
106
  * When using the Worker Versioning feature, specifies whether this Activity should run on a
107
107
  * worker with a compatible Build Id or not. See {@link VersioningIntent}.
108
108
  *
109
+ * @default 'COMPATIBLE'
110
+ *
109
111
  * @experimental
110
112
  */
111
113
  versioningIntent?: VersioningIntent;
@@ -15,17 +15,32 @@ import {
15
15
  import { isError } from '../type-helpers';
16
16
  import { arrayFromPayloads, fromPayloadsAtIndex, PayloadConverter, toPayloads } from './payload-converter';
17
17
 
18
+ function combineRegExp(...regexps: RegExp[]): RegExp {
19
+ return new RegExp(regexps.map((x) => `(?:${x.source})`).join('|'));
20
+ }
21
+
18
22
  /**
19
23
  * Stack traces will be cutoff when on of these patterns is matched
20
24
  */
21
- const CUTOFF_STACK_PATTERNS = [
25
+ const CUTOFF_STACK_PATTERNS = combineRegExp(
22
26
  /** Activity execution */
23
27
  /\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,
24
28
  /** Workflow activation */
25
29
  /\s+at Activator\.\S+NextHandler \(.*[\\/]workflow[\\/](?:src|lib)[\\/]internals\.[jt]s:\d+:\d+\)/,
26
30
  /** Workflow run anything in context */
27
- /\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/,
28
- ];
31
+ /\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/
32
+ );
33
+
34
+ /**
35
+ * Any stack trace frames that match any of those wil be dopped.
36
+ * The "null." prefix on some cases is to avoid https://github.com/nodejs/node/issues/42417
37
+ */
38
+ const DROPPED_STACK_FRAMES_PATTERNS = combineRegExp(
39
+ /** Internal functions used to recursively chain interceptors */
40
+ /\s+at (null\.)?next \(.*[\\/]common[\\/](?:src|lib)[\\/]interceptors\.[jt]s:\d+:\d+\)/,
41
+ /** Internal functions used to recursively chain interceptors */
42
+ /\s+at (null\.)?executeNextHandler \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/
43
+ );
29
44
 
30
45
  /**
31
46
  * Cuts out the framework part of a stack trace, leaving only user code entries
@@ -33,11 +48,9 @@ const CUTOFF_STACK_PATTERNS = [
33
48
  export function cutoffStackTrace(stack?: string): string {
34
49
  const lines = (stack ?? '').split(/\r?\n/);
35
50
  const acc = Array<string>();
36
- lineLoop: for (const line of lines) {
37
- for (const pattern of CUTOFF_STACK_PATTERNS) {
38
- if (pattern.test(line)) break lineLoop;
39
- }
40
- acc.push(line);
51
+ for (const line of lines) {
52
+ if (CUTOFF_STACK_PATTERNS.test(line)) break;
53
+ if (!DROPPED_STACK_FRAMES_PATTERNS.test(line)) acc.push(line);
41
54
  }
42
55
  return acc.join('\n');
43
56
  }
@@ -192,7 +192,8 @@ function resetBufferInGlobal(hasChanged: boolean): void {
192
192
  function isProtobufType(type: unknown): type is Type {
193
193
  return (
194
194
  isRecord(type) &&
195
- type.constructor.name === 'Type' &&
195
+ // constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
196
+ (type.constructor as any).className === 'Type' &&
196
197
  hasOwnProperties(type, ['parent', 'name', 'create', 'encode', 'decode']) &&
197
198
  typeof type.name === 'string' &&
198
199
  typeof type.create === 'function' &&
@@ -214,7 +215,8 @@ function getNamespacedTypeName(node: Type | Namespace): string {
214
215
  }
215
216
 
216
217
  function isRoot(root: unknown): root is Root {
217
- return isRecord(root) && root.constructor.name === 'Root';
218
+ // constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
219
+ return isRecord(root) && (root.constructor as any).className === 'Root';
218
220
  }
219
221
 
220
222
  export interface DefaultPayloadConverterWithProtobufsOptions {
@@ -12,7 +12,10 @@ export type Next<IF, FN extends keyof IF> = Required<IF>[FN] extends AnyFunc ? O
12
12
  export type Headers = Record<string, Payload>;
13
13
 
14
14
  /**
15
- * Composes all interceptor methods into a single function
15
+ * Compose all interceptor methods into a single function.
16
+ *
17
+ * Calling the composed function results in calling each of the provided interceptor, in order (from the first to
18
+ * the last), followed by the original function provided as argument to `composeInterceptors()`.
16
19
  *
17
20
  * @param interceptors a list of interceptors
18
21
  * @param method the name of the interceptor method to compose
@@ -24,7 +27,7 @@ export function composeInterceptors<I, M extends keyof I>(interceptors: I[], met
24
27
  const interceptor = interceptors[i];
25
28
  if (interceptor[method] !== undefined) {
26
29
  const prev = next;
27
- // We loose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
30
+ // We lose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
28
31
  // the same type as Next<I, M>
29
32
  next = ((input: any) => (interceptor[method] as any)(input, prev)) as any;
30
33
  }
package/src/interfaces.ts CHANGED
@@ -4,6 +4,8 @@ export type Payload = temporal.api.common.v1.IPayload;
4
4
 
5
5
  /** Type that can be returned from a Workflow `execute` function */
6
6
  export type WorkflowReturnType = Promise<any>;
7
+ export type WorkflowUpdateType = (...args: any[]) => Promise<any> | any;
8
+ export type WorkflowUpdateValidatorType = (...args: any[]) => void;
7
9
  export type WorkflowSignalType = (...args: any[]) => Promise<void> | void;
8
10
  export type WorkflowQueryType = (...args: any[]) => any;
9
11
 
@@ -16,10 +18,33 @@ export type WorkflowQueryType = (...args: any[]) => any;
16
18
  export type Workflow = (...args: any[]) => WorkflowReturnType;
17
19
 
18
20
  declare const argsBrand: unique symbol;
21
+ declare const retBrand: unique symbol;
22
+
23
+ /**
24
+ * An interface representing a Workflow update definition, as returned from {@link defineUpdate}
25
+ *
26
+ * @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
27
+ * `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the update name.
28
+ */
29
+ export interface UpdateDefinition<Ret, Args extends any[] = [], Name extends string = string> {
30
+ type: 'update';
31
+ name: Name;
32
+ /**
33
+ * Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different args.
34
+ * This field is not present at run-time.
35
+ */
36
+ [argsBrand]: Args;
37
+ /**
38
+ * Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different return types.
39
+ * This field is not present at run-time.
40
+ */
41
+ [retBrand]: Ret;
42
+ }
43
+
19
44
  /**
20
45
  * An interface representing a Workflow signal definition, as returned from {@link defineSignal}
21
46
  *
22
- * @remarks `Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
47
+ * @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
23
48
  * `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the signal name.
24
49
  */
25
50
  export interface SignalDefinition<Args extends any[] = [], Name extends string = string> {
@@ -32,11 +57,10 @@ export interface SignalDefinition<Args extends any[] = [], Name extends string =
32
57
  [argsBrand]: Args;
33
58
  }
34
59
 
35
- declare const retBrand: unique symbol;
36
60
  /**
37
61
  * An interface representing a Workflow query definition as returned from {@link defineQuery}
38
62
  *
39
- * @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
63
+ * @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and WorkflowHandle methods.
40
64
  * `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the query name.
41
65
  */
42
66
  export interface QueryDefinition<Ret, Args extends any[] = [], Name extends string = string> {
@@ -1,9 +1,11 @@
1
1
  /** TLS configuration options. */
2
2
  export interface TLSConfig {
3
3
  /**
4
- * Overrides the target name used for SSL host name checking.
5
- * If this attribute is not specified, the name used for SSL host name checking will be the host from {@link ServerOptions.url}.
6
- * This _should_ be used for testing only.
4
+ * Overrides the target name (SNI) used for TLS host name checking.
5
+ * If this attribute is not specified, the name used for TLS host name checking will be the host from {@link ServerOptions.url}.
6
+ * This can be useful when you have reverse proxy in front of temporal server, and you may want to override the SNI to
7
+ * direct traffic to the appropriate backend server based on custom routing rules. Oppositely, connections could be refused
8
+ * if the provided SNI does not match the expected host. Adding this override should be done with care.
7
9
  */
8
10
  serverNameOverride?: string;
9
11
  /**
@@ -140,3 +140,26 @@ export function SymbolBasedInstanceOfError<E extends Error>(markerName: string):
140
140
  });
141
141
  };
142
142
  }
143
+
144
+ // Thanks MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
145
+ export function deepFreeze<T>(object: T): T {
146
+ // Retrieve the property names defined on object
147
+ const propNames = Object.getOwnPropertyNames(object);
148
+
149
+ // Freeze properties before freezing self
150
+ for (const name of propNames) {
151
+ const value = (object as any)[name];
152
+
153
+ if (value && typeof value === 'object') {
154
+ try {
155
+ deepFreeze(value);
156
+ } catch (err) {
157
+ // This is okay, there are some typed arrays that cannot be frozen (encodingKeys)
158
+ }
159
+ } else if (typeof value === 'function') {
160
+ Object.freeze(value);
161
+ }
162
+ }
163
+
164
+ return Object.freeze(object);
165
+ }
@@ -1,17 +1,15 @@
1
1
  /**
2
- * Indicates whether the user intends certain commands to be run on a compatible worker Build Id
3
- * version or not.
2
+ * Indicates whether the user intends certain commands to be run on a compatible worker Build Id version or not.
4
3
  *
5
- * `COMPATIBLE` indicates that the command should run on a worker with compatible version if
6
- * possible. It may not be possible if the target task queue does not also have knowledge of the
7
- * current worker's Build Id.
4
+ * `COMPATIBLE` indicates that the command should run on a worker with compatible version if possible. It may not be
5
+ * possible if the target task queue does not also have knowledge of the current worker's Build Id.
8
6
  *
9
- * `DEFAULT` indicates that the command should run on the target task queue's current
10
- * overall-default Build Id.
7
+ * `DEFAULT` indicates that the command should run on the target task queue's current overall-default Build Id.
11
8
  *
12
- * Where this type is accepted optionally, an unset value indicates that the SDK should choose the
13
- * most sensible default behavior for the type of command, accounting for whether the command will
14
- * be run on the same task queue as the current worker.
9
+ * Where this type is accepted optionally, an unset value indicates that the SDK should choose the most sensible default
10
+ * behavior for the type of command, accounting for whether the command will be run on the same task queue as the
11
+ * current worker. The default behavior for starting Workflows is `DEFAULT`. The default behavior for Workflows starting
12
+ * Activities, starting Child Workflows, or Continuing As New is `COMPATIBLE`.
15
13
  *
16
14
  * @experimental
17
15
  */
@@ -1,8 +1,8 @@
1
- import type { temporal, google } from '@temporalio/proto';
1
+ import type { temporal } from '@temporalio/proto';
2
2
  import { SearchAttributes, Workflow } from './interfaces';
3
3
  import { RetryPolicy } from './retry-policy';
4
- import { Duration, msOptionalToTs } from './time';
5
- import { checkExtends, Replace } from './type-helpers';
4
+ import { Duration } from './time';
5
+ import { checkExtends } from './type-helpers';
6
6
 
7
7
  // Avoid importing the proto implementation to reduce workflow bundle size
8
8
  // Copied from temporal.api.enums.v1.WorkflowIdReusePolicy
@@ -135,26 +135,6 @@ export interface WorkflowDurationOptions {
135
135
 
136
136
  export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions;
137
137
 
138
- export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<
139
- T,
140
- {
141
- workflowExecutionTimeout?: google.protobuf.IDuration;
142
- workflowRunTimeout?: google.protobuf.IDuration;
143
- workflowTaskTimeout?: google.protobuf.IDuration;
144
- }
145
- >;
146
-
147
- export function compileWorkflowOptions<T extends CommonWorkflowOptions>(options: T): WithCompiledWorkflowOptions<T> {
148
- const { workflowExecutionTimeout, workflowRunTimeout, workflowTaskTimeout, ...rest } = options;
149
-
150
- return {
151
- ...rest,
152
- workflowExecutionTimeout: msOptionalToTs(workflowExecutionTimeout),
153
- workflowRunTimeout: msOptionalToTs(workflowRunTimeout),
154
- workflowTaskTimeout: msOptionalToTs(workflowTaskTimeout),
155
- };
156
- }
157
-
158
138
  export function extractWorkflowType<T extends Workflow>(workflowTypeOrFunc: string | T): string {
159
139
  if (typeof workflowTypeOrFunc === 'string') return workflowTypeOrFunc as string;
160
140
  if (typeof workflowTypeOrFunc === 'function') {
package/lib/otel.d.ts DELETED
@@ -1,26 +0,0 @@
1
- import * as otel from '@opentelemetry/api';
2
- import { Headers } from './interceptors';
3
- /** Default trace header for opentelemetry interceptors */
4
- export declare const TRACE_HEADER = "_tracer-data";
5
- /** As in workflow run id */
6
- export declare const RUN_ID_ATTR_KEY = "run_id";
7
- /** For a workflow or activity task */
8
- export declare const TASK_TOKEN_ATTR_KEY = "task_token";
9
- /** Number of jobs in a workflow activation */
10
- export declare const NUM_JOBS_ATTR_KEY = "num_jobs";
11
- /**
12
- * If found, return an otel Context deserialized from the provided headers
13
- */
14
- export declare function extractContextFromHeaders(headers: Headers): Promise<otel.Context | undefined>;
15
- /**
16
- * If found, return an otel SpanContext deserialized from the provided headers
17
- */
18
- export declare function extractSpanContextFromHeaders(headers: Headers): Promise<otel.SpanContext | undefined>;
19
- /**
20
- * Given headers, return new headers with the current otel context inserted
21
- */
22
- export declare function headersWithContext(headers: Headers): Promise<Headers>;
23
- /**
24
- * Link a span to an maybe-existing span context
25
- */
26
- export declare function linkSpans(fromSpan: otel.Span, toContext?: otel.SpanContext): void;
package/lib/otel.js DELETED
@@ -1,87 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.linkSpans = exports.headersWithContext = exports.extractSpanContextFromHeaders = exports.extractContextFromHeaders = exports.NUM_JOBS_ATTR_KEY = exports.TASK_TOKEN_ATTR_KEY = exports.RUN_ID_ATTR_KEY = exports.TRACE_HEADER = void 0;
27
- const otel = __importStar(require("@opentelemetry/api"));
28
- const payload_converter_1 = require("./converter/payload-converter");
29
- /** Default trace header for opentelemetry interceptors */
30
- exports.TRACE_HEADER = '_tracer-data';
31
- /** As in workflow run id */
32
- exports.RUN_ID_ATTR_KEY = 'run_id';
33
- /** For a workflow or activity task */
34
- exports.TASK_TOKEN_ATTR_KEY = 'task_token';
35
- /** Number of jobs in a workflow activation */
36
- exports.NUM_JOBS_ATTR_KEY = 'num_jobs';
37
- const payloadConverter = payload_converter_1.defaultPayloadConverter;
38
- /**
39
- * If found, return an otel Context deserialized from the provided headers
40
- */
41
- async function extractContextFromHeaders(headers) {
42
- const encodedSpanContext = headers[exports.TRACE_HEADER];
43
- if (encodedSpanContext === undefined) {
44
- return undefined;
45
- }
46
- const textMap = payloadConverter.fromPayload(encodedSpanContext);
47
- return otel.propagation.extract(otel.context.active(), textMap, otel.defaultTextMapGetter);
48
- }
49
- exports.extractContextFromHeaders = extractContextFromHeaders;
50
- /**
51
- * If found, return an otel SpanContext deserialized from the provided headers
52
- */
53
- async function extractSpanContextFromHeaders(headers) {
54
- const context = await extractContextFromHeaders(headers);
55
- if (context === undefined) {
56
- return undefined;
57
- }
58
- return otel.trace.getSpanContext(context);
59
- }
60
- exports.extractSpanContextFromHeaders = extractSpanContextFromHeaders;
61
- /**
62
- * Given headers, return new headers with the current otel context inserted
63
- */
64
- async function headersWithContext(headers) {
65
- const carrier = {};
66
- otel.propagation.inject(otel.context.active(), carrier, otel.defaultTextMapSetter);
67
- return { ...headers, [exports.TRACE_HEADER]: payloadConverter.toPayload(carrier) };
68
- }
69
- exports.headersWithContext = headersWithContext;
70
- /**
71
- * Link a span to an maybe-existing span context
72
- */
73
- function linkSpans(fromSpan, toContext) {
74
- if (toContext !== undefined) {
75
- // TODO: I have to go around typescript because otel api 😢
76
- // See https://github.com/open-telemetry/opentelemetry-js-api/issues/124
77
- const links = fromSpan.links;
78
- if (links === undefined) {
79
- fromSpan.links = [{ context: toContext }];
80
- }
81
- else {
82
- links.push({ context: toContext });
83
- }
84
- }
85
- }
86
- exports.linkSpans = linkSpans;
87
- //# sourceMappingURL=otel.js.map
package/lib/otel.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"otel.js","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAE3C,qEAAwE;AAExE,0DAA0D;AAC7C,QAAA,YAAY,GAAG,cAAc,CAAC;AAC3C,4BAA4B;AACf,QAAA,eAAe,GAAG,QAAQ,CAAC;AACxC,sCAAsC;AACzB,QAAA,mBAAmB,GAAG,YAAY,CAAC;AAChD,8CAA8C;AACjC,QAAA,iBAAiB,GAAG,UAAU,CAAC;AAE5C,MAAM,gBAAgB,GAAG,2CAAuB,CAAC;AAEjD;;GAEG;AACI,KAAK,UAAU,yBAAyB,CAAC,OAAgB;IAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,oBAAY,CAAC,CAAC;IACjD,IAAI,kBAAkB,KAAK,SAAS,EAAE;QACpC,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,OAAO,GAA2B,gBAAgB,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACzF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAC7F,CAAC;AAPD,8DAOC;AAED;;GAEG;AACI,KAAK,UAAU,6BAA6B,CAAC,OAAgB;IAClE,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACzD,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAPD,sEAOC;AAED;;GAEG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAAgB;IACvD,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACnF,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,oBAAY,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;AAC7E,CAAC;AAJD,gDAIC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,QAAmB,EAAE,SAA4B;IACzE,IAAI,SAAS,KAAK,SAAS,EAAE;QAC3B,2DAA2D;QAC3D,yEAAyE;QACzE,MAAM,KAAK,GAAI,QAAgB,CAAC,KAAK,CAAC;QACtC,IAAI,KAAK,KAAK,SAAS,EAAE;YACtB,QAAgB,CAAC,KAAK,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;SACpD;aAAM;YACL,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;SACpC;KACF;AACH,CAAC;AAXD,8BAWC"}
package/src/otel.ts DELETED
@@ -1,63 +0,0 @@
1
- import * as otel from '@opentelemetry/api';
2
- import { Headers } from './interceptors';
3
- import { defaultPayloadConverter } from './converter/payload-converter';
4
-
5
- /** Default trace header for opentelemetry interceptors */
6
- export const TRACE_HEADER = '_tracer-data';
7
- /** As in workflow run id */
8
- export const RUN_ID_ATTR_KEY = 'run_id';
9
- /** For a workflow or activity task */
10
- export const TASK_TOKEN_ATTR_KEY = 'task_token';
11
- /** Number of jobs in a workflow activation */
12
- export const NUM_JOBS_ATTR_KEY = 'num_jobs';
13
-
14
- const payloadConverter = defaultPayloadConverter;
15
-
16
- /**
17
- * If found, return an otel Context deserialized from the provided headers
18
- */
19
- export async function extractContextFromHeaders(headers: Headers): Promise<otel.Context | undefined> {
20
- const encodedSpanContext = headers[TRACE_HEADER];
21
- if (encodedSpanContext === undefined) {
22
- return undefined;
23
- }
24
- const textMap: Record<string, string> = payloadConverter.fromPayload(encodedSpanContext);
25
- return otel.propagation.extract(otel.context.active(), textMap, otel.defaultTextMapGetter);
26
- }
27
-
28
- /**
29
- * If found, return an otel SpanContext deserialized from the provided headers
30
- */
31
- export async function extractSpanContextFromHeaders(headers: Headers): Promise<otel.SpanContext | undefined> {
32
- const context = await extractContextFromHeaders(headers);
33
- if (context === undefined) {
34
- return undefined;
35
- }
36
-
37
- return otel.trace.getSpanContext(context);
38
- }
39
-
40
- /**
41
- * Given headers, return new headers with the current otel context inserted
42
- */
43
- export async function headersWithContext(headers: Headers): Promise<Headers> {
44
- const carrier = {};
45
- otel.propagation.inject(otel.context.active(), carrier, otel.defaultTextMapSetter);
46
- return { ...headers, [TRACE_HEADER]: payloadConverter.toPayload(carrier) };
47
- }
48
-
49
- /**
50
- * Link a span to an maybe-existing span context
51
- */
52
- export function linkSpans(fromSpan: otel.Span, toContext?: otel.SpanContext): void {
53
- if (toContext !== undefined) {
54
- // TODO: I have to go around typescript because otel api 😢
55
- // See https://github.com/open-telemetry/opentelemetry-js-api/issues/124
56
- const links = (fromSpan as any).links;
57
- if (links === undefined) {
58
- (fromSpan as any).links = [{ context: toContext }];
59
- } else {
60
- links.push({ context: toContext });
61
- }
62
- }
63
- }