@temporalio/common 0.17.2 → 0.19.0-rc.1

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 (97) hide show
  1. package/README.md +5 -11
  2. package/lib/converter/data-converter.d.ts +34 -62
  3. package/lib/converter/data-converter.js +0 -101
  4. package/lib/converter/data-converter.js.map +1 -1
  5. package/lib/{encoding.d.ts → converter/encoding.d.ts} +0 -0
  6. package/lib/{encoding.js → converter/encoding.js} +0 -0
  7. package/lib/converter/encoding.js.map +1 -0
  8. package/lib/converter/patch-protobuf-root.d.ts +8 -0
  9. package/lib/converter/patch-protobuf-root.js +43 -0
  10. package/lib/converter/patch-protobuf-root.js.map +1 -0
  11. package/lib/converter/payload-codec.d.ts +27 -0
  12. package/lib/converter/payload-codec.js +11 -0
  13. package/lib/converter/payload-codec.js.map +1 -0
  14. package/lib/converter/payload-converter.d.ts +63 -62
  15. package/lib/converter/payload-converter.js +113 -68
  16. package/lib/converter/payload-converter.js.map +1 -1
  17. package/lib/converter/payload-converters.d.ts +31 -0
  18. package/lib/converter/payload-converters.js +85 -0
  19. package/lib/converter/payload-converters.js.map +1 -0
  20. package/lib/converter/protobuf-payload-converters.d.ts +53 -0
  21. package/lib/converter/protobuf-payload-converters.js +159 -0
  22. package/lib/converter/protobuf-payload-converters.js.map +1 -0
  23. package/lib/converter/types.d.ts +2 -0
  24. package/lib/converter/types.js +3 -2
  25. package/lib/converter/types.js.map +1 -1
  26. package/lib/failure.d.ts +6 -6
  27. package/lib/failure.js +37 -35
  28. package/lib/failure.js.map +1 -1
  29. package/lib/index.d.ts +9 -11
  30. package/lib/index.js +12 -16
  31. package/lib/index.js.map +1 -1
  32. package/lib/protobufs.d.ts +13 -0
  33. package/lib/protobufs.js +31 -0
  34. package/lib/protobufs.js.map +1 -0
  35. package/package.json +11 -8
  36. package/src/converter/data-converter.ts +35 -176
  37. package/src/{encoding.ts → converter/encoding.ts} +0 -0
  38. package/src/converter/patch-protobuf-root.ts +49 -0
  39. package/src/converter/payload-codec.ts +30 -0
  40. package/src/converter/payload-converter.ts +122 -102
  41. package/src/converter/payload-converters.ts +89 -0
  42. package/src/converter/protobuf-payload-converters.ts +192 -0
  43. package/src/converter/types.ts +4 -1
  44. package/src/failure.ts +44 -43
  45. package/src/index.ts +9 -11
  46. package/src/protobufs.ts +15 -0
  47. package/tsconfig.json +2 -2
  48. package/tsconfig.tsbuildinfo +1 -1
  49. package/lib/activity-options.d.ts +0 -81
  50. package/lib/activity-options.js +0 -14
  51. package/lib/activity-options.js.map +0 -1
  52. package/lib/encoding.js.map +0 -1
  53. package/lib/errors.d.ts +0 -16
  54. package/lib/errors.js +0 -41
  55. package/lib/errors.js.map +0 -1
  56. package/lib/interceptors.d.ts +0 -18
  57. package/lib/interceptors.js +0 -24
  58. package/lib/interceptors.js.map +0 -1
  59. package/lib/interfaces.d.ts +0 -31
  60. package/lib/interfaces.js +0 -3
  61. package/lib/interfaces.js.map +0 -1
  62. package/lib/otel.d.ts +0 -26
  63. package/lib/otel.js +0 -82
  64. package/lib/otel.js.map +0 -1
  65. package/lib/retry-policy.d.ts +0 -43
  66. package/lib/retry-policy.js +0 -36
  67. package/lib/retry-policy.js.map +0 -1
  68. package/lib/time.d.ts +0 -16
  69. package/lib/time.js +0 -73
  70. package/lib/time.js.map +0 -1
  71. package/lib/tls-config.d.ts +0 -32
  72. package/lib/tls-config.js +0 -11
  73. package/lib/tls-config.js.map +0 -1
  74. package/lib/type-helpers.d.ts +0 -8
  75. package/lib/type-helpers.js +0 -9
  76. package/lib/type-helpers.js.map +0 -1
  77. package/lib/utils.d.ts +0 -4
  78. package/lib/utils.js +0 -11
  79. package/lib/utils.js.map +0 -1
  80. package/lib/workflow-handle.d.ts +0 -27
  81. package/lib/workflow-handle.js +0 -3
  82. package/lib/workflow-handle.js.map +0 -1
  83. package/lib/workflow-options.d.ts +0 -91
  84. package/lib/workflow-options.js +0 -26
  85. package/lib/workflow-options.js.map +0 -1
  86. package/src/activity-options.ts +0 -97
  87. package/src/errors.ts +0 -27
  88. package/src/interceptors.ts +0 -32
  89. package/src/interfaces.ts +0 -37
  90. package/src/otel.ts +0 -61
  91. package/src/retry-policy.ts +0 -73
  92. package/src/time.ts +0 -72
  93. package/src/tls-config.ts +0 -35
  94. package/src/type-helpers.ts +0 -11
  95. package/src/utils.ts +0 -6
  96. package/src/workflow-handle.ts +0 -30
  97. package/src/workflow-options.ts +0 -127
package/lib/errors.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.errorMessage = exports.IllegalStateError = exports.DataConverterError = exports.ValueError = void 0;
4
- class ValueError extends Error {
5
- constructor() {
6
- super(...arguments);
7
- this.name = 'ValueError';
8
- }
9
- }
10
- exports.ValueError = ValueError;
11
- class DataConverterError extends Error {
12
- constructor() {
13
- super(...arguments);
14
- this.name = 'DataConverterError';
15
- }
16
- }
17
- exports.DataConverterError = DataConverterError;
18
- /**
19
- * Used in different parts of the project to signal that something unexpected has happened
20
- */
21
- class IllegalStateError extends Error {
22
- constructor() {
23
- super(...arguments);
24
- this.name = 'IllegalStateError';
25
- }
26
- }
27
- exports.IllegalStateError = IllegalStateError;
28
- /**
29
- * Get error message from an Error or string or return undefined
30
- */
31
- function errorMessage(err) {
32
- if (typeof err === 'string') {
33
- return err;
34
- }
35
- if (err instanceof Error) {
36
- return err.message;
37
- }
38
- return undefined;
39
- }
40
- exports.errorMessage = errorMessage;
41
- //# sourceMappingURL=errors.js.map
package/lib/errors.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAW,SAAQ,KAAK;IAArC;;QACkB,SAAI,GAAW,YAAY,CAAC;IAC9C,CAAC;CAAA;AAFD,gCAEC;AAED,MAAa,kBAAmB,SAAQ,KAAK;IAA7C;;QACkB,SAAI,GAAW,oBAAoB,CAAC;IACtD,CAAC;CAAA;AAFD,gDAEC;AAED;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAA5C;;QACkB,SAAI,GAAW,mBAAmB,CAAC;IACrD,CAAC;CAAA;AAFD,8CAEC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,GAAG,YAAY,KAAK,EAAE;QACxB,OAAO,GAAG,CAAC,OAAO,CAAC;KACpB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AARD,oCAQC"}
@@ -1,18 +0,0 @@
1
- import type { coresdk } from '@temporalio/proto/lib/coresdk';
2
- import { AnyFunc, OmitLastParam } from './type-helpers';
3
- /**
4
- * Type of the next function for a given interceptor function
5
- *
6
- * Called from an interceptor to continue the interception chain
7
- */
8
- export declare type Next<IF, FN extends keyof IF> = Required<IF>[FN] extends AnyFunc ? OmitLastParam<Required<IF>[FN]> : never;
9
- /** Headers are just a mapping of header name to Payload */
10
- export declare type Headers = Record<string, coresdk.common.IPayload>;
11
- /**
12
- * Composes all interceptor methods into a single function
13
- *
14
- * @param interceptors a list of interceptors
15
- * @param method the name of the interceptor method to compose
16
- * @param next the original function to be executed at the end of the interception chain
17
- */
18
- export declare function composeInterceptors<I, M extends keyof I>(interceptors: I[], method: M, next: Next<I, M>): Next<I, M>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeInterceptors = void 0;
4
- /**
5
- * Composes all interceptor methods into a single function
6
- *
7
- * @param interceptors a list of interceptors
8
- * @param method the name of the interceptor method to compose
9
- * @param next the original function to be executed at the end of the interception chain
10
- */
11
- function composeInterceptors(interceptors, method, next) {
12
- for (let i = interceptors.length - 1; i >= 0; --i) {
13
- const interceptor = interceptors[i];
14
- if (interceptor[method] !== undefined) {
15
- const prev = next;
16
- // We loose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
17
- // the same type as Next<I, M>
18
- next = ((input) => interceptor[method](input, prev));
19
- }
20
- }
21
- return next;
22
- }
23
- exports.composeInterceptors = composeInterceptors;
24
- //# sourceMappingURL=interceptors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interceptors.js","sourceRoot":"","sources":["../src/interceptors.ts"],"names":[],"mappings":";;;AAaA;;;;;;GAMG;AACH,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,31 +0,0 @@
1
- /** Type that can be returned from a Workflow `execute` function */
2
- export declare type WorkflowReturnType = Promise<any>;
3
- export declare type WorkflowSignalType = (...args: any[]) => Promise<void> | void;
4
- export declare type WorkflowQueryType = (...args: any[]) => any;
5
- /**
6
- * Broad Workflow function definition, specific Workflows will typically use a narrower type definition, e.g:
7
- * ```ts
8
- * export async function myWorkflow(arg1: number, arg2: string): Promise<string>;
9
- * ```
10
- */
11
- export declare type Workflow = (...args: any[]) => WorkflowReturnType;
12
- /**
13
- * An interface representing a Workflow signal definition, as returned from {@link defineSignal}
14
- *
15
- * @remarks `_Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
16
- */
17
- export interface SignalDefinition<_Args extends any[] = []> {
18
- type: 'signal';
19
- name: string;
20
- }
21
- /**
22
- * An interface representing a Workflow query definition as returned from {@link defineQuery}
23
- *
24
- * @remarks `_Args` and `_Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
25
- */
26
- export interface QueryDefinition<_Ret, _Args extends any[] = []> {
27
- type: 'query';
28
- name: string;
29
- }
30
- /** Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type `W` */
31
- export declare type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promise<infer R> ? R : never;
package/lib/interfaces.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
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,82 +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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- 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;
23
- const otel = __importStar(require("@opentelemetry/api"));
24
- const data_converter_1 = require("./converter/data-converter");
25
- /** Default trace header for opentelemetry interceptors */
26
- exports.TRACE_HEADER = '_tracer-data';
27
- /** As in workflow run id */
28
- exports.RUN_ID_ATTR_KEY = 'run_id';
29
- /** For a workflow or activity task */
30
- exports.TASK_TOKEN_ATTR_KEY = 'task_token';
31
- /** Number of jobs in a workflow activation */
32
- exports.NUM_JOBS_ATTR_KEY = 'num_jobs';
33
- /**
34
- * If found, return an otel Context deserialized from the provided headers
35
- */
36
- async function extractContextFromHeaders(headers) {
37
- const encodedSpanContext = headers[exports.TRACE_HEADER];
38
- if (encodedSpanContext === undefined) {
39
- return undefined;
40
- }
41
- const textMap = await data_converter_1.defaultDataConverter.fromPayload(encodedSpanContext);
42
- return otel.propagation.extract(otel.context.active(), textMap, otel.defaultTextMapGetter);
43
- }
44
- exports.extractContextFromHeaders = extractContextFromHeaders;
45
- /**
46
- * If found, return an otel SpanContext deserialized from the provided headers
47
- */
48
- async function extractSpanContextFromHeaders(headers) {
49
- const context = await extractContextFromHeaders(headers);
50
- if (context === undefined) {
51
- return undefined;
52
- }
53
- return otel.trace.getSpanContext(context);
54
- }
55
- exports.extractSpanContextFromHeaders = extractSpanContextFromHeaders;
56
- /**
57
- * Given headers, return new headers with the current otel context inserted
58
- */
59
- async function headersWithContext(headers) {
60
- const carrier = {};
61
- otel.propagation.inject(otel.context.active(), carrier, otel.defaultTextMapSetter);
62
- return { ...headers, [exports.TRACE_HEADER]: await data_converter_1.defaultDataConverter.toPayload(carrier) };
63
- }
64
- exports.headersWithContext = headersWithContext;
65
- /**
66
- * Link a span to an maybe-existing span context
67
- */
68
- function linkSpans(fromSpan, toContext) {
69
- if (toContext !== undefined) {
70
- // TODO: I have to go around typescript because otel api 😢
71
- // See https://github.com/open-telemetry/opentelemetry-js-api/issues/124
72
- const links = fromSpan.links;
73
- if (links === undefined) {
74
- fromSpan.links = [{ context: toContext }];
75
- }
76
- else {
77
- links.push({ context: toContext });
78
- }
79
- }
80
- }
81
- exports.linkSpans = linkSpans;
82
- //# 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;AAC3C,+DAAkE;AAGlE,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;;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,MAAM,qCAAoB,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACnG,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,MAAM,qCAAoB,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;AACvF,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"}
@@ -1,43 +0,0 @@
1
- import type { temporal } from '@temporalio/proto';
2
- /**
3
- * Options for retrying Workflows and Activities
4
- */
5
- export interface RetryPolicy {
6
- /**
7
- * Coefficient used to calculate the next retry interval.
8
- * The next retry interval is previous interval multiplied by this coefficient.
9
- * @minimum 1
10
- * @default 2
11
- */
12
- backoffCoefficient?: number;
13
- /**
14
- * Interval of the first retry.
15
- * If coefficient is 1 then it is used for all retries
16
- * @format {@link https://www.npmjs.com/package/ms | ms} formatted string or number of milliseconds
17
- * @default 1 second
18
- */
19
- initialInterval?: string | number;
20
- /**
21
- * Maximum number of attempts. When exceeded the retries stop even if not expired yet.
22
- * @minimum 1
23
- * @default Infinity
24
- */
25
- maximumAttempts?: number;
26
- /**
27
- * Maximum interval between retries.
28
- * Exponential backoff leads to interval increase.
29
- * This value is the cap of the increase.
30
- *
31
- * @default 100x of {@link initialInterval}
32
- * @format {@link https://www.npmjs.com/package/ms | ms} formatted string or number of milliseconds
33
- */
34
- maximumInterval?: string | number;
35
- /**
36
- * List of application failures types to not retry.
37
- */
38
- nonRetryableErrorTypes?: string[];
39
- }
40
- /**
41
- * Turns a TS RetryPolicy into a proto compatible RetryPolicy
42
- */
43
- export declare function compileRetryPolicy(retryPolicy: RetryPolicy): temporal.api.common.v1.IRetryPolicy;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileRetryPolicy = void 0;
4
- const _1 = require(".");
5
- const time_1 = require("./time");
6
- /**
7
- * Turns a TS RetryPolicy into a proto compatible RetryPolicy
8
- */
9
- function compileRetryPolicy(retryPolicy) {
10
- if (retryPolicy.backoffCoefficient != null && retryPolicy.backoffCoefficient <= 0) {
11
- throw new _1.ValueError('RetryPolicy.backoffCoefficient must be greater than 0');
12
- }
13
- if (retryPolicy.maximumAttempts != null && retryPolicy.maximumAttempts <= 0) {
14
- throw new _1.ValueError('RetryPolicy.maximumAttempts must be greater than 0');
15
- }
16
- const maximumInterval = (0, time_1.msOptionalToNumber)(retryPolicy.maximumInterval);
17
- const initialInterval = (0, time_1.msToNumber)(retryPolicy.initialInterval ?? 1000);
18
- if (maximumInterval === 0) {
19
- throw new _1.ValueError('RetryPolicy.maximumInterval cannot be 0');
20
- }
21
- if (initialInterval === 0) {
22
- throw new _1.ValueError('RetryPolicy.initialInterval cannot be 0');
23
- }
24
- if (maximumInterval != null && maximumInterval < initialInterval) {
25
- throw new _1.ValueError('RetryPolicy.maximumInterval cannot be less than its initialInterval');
26
- }
27
- return {
28
- maximumAttempts: retryPolicy.maximumAttempts,
29
- initialInterval: (0, time_1.msToTs)(initialInterval),
30
- maximumInterval: (0, time_1.msOptionalToTs)(maximumInterval),
31
- backoffCoefficient: retryPolicy.backoffCoefficient,
32
- nonRetryableErrorTypes: retryPolicy.nonRetryableErrorTypes,
33
- };
34
- }
35
- exports.compileRetryPolicy = compileRetryPolicy;
36
- //# sourceMappingURL=retry-policy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry-policy.js","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":";;;AACA,wBAA+B;AAC/B,iCAAgF;AA0ChF;;GAEG;AACH,SAAgB,kBAAkB,CAAC,WAAwB;IACzD,IAAI,WAAW,CAAC,kBAAkB,IAAI,IAAI,IAAI,WAAW,CAAC,kBAAkB,IAAI,CAAC,EAAE;QACjF,MAAM,IAAI,aAAU,CAAC,uDAAuD,CAAC,CAAC;KAC/E;IACD,IAAI,WAAW,CAAC,eAAe,IAAI,IAAI,IAAI,WAAW,CAAC,eAAe,IAAI,CAAC,EAAE;QAC3E,MAAM,IAAI,aAAU,CAAC,oDAAoD,CAAC,CAAC;KAC5E;IACD,MAAM,eAAe,GAAG,IAAA,yBAAkB,EAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,IAAA,iBAAU,EAAC,WAAW,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC;IACxE,IAAI,eAAe,KAAK,CAAC,EAAE;QACzB,MAAM,IAAI,aAAU,CAAC,yCAAyC,CAAC,CAAC;KACjE;IACD,IAAI,eAAe,KAAK,CAAC,EAAE;QACzB,MAAM,IAAI,aAAU,CAAC,yCAAyC,CAAC,CAAC;KACjE;IACD,IAAI,eAAe,IAAI,IAAI,IAAI,eAAe,GAAG,eAAe,EAAE;QAChE,MAAM,IAAI,aAAU,CAAC,qEAAqE,CAAC,CAAC;KAC7F;IACD,OAAO;QACL,eAAe,EAAE,WAAW,CAAC,eAAe;QAC5C,eAAe,EAAE,IAAA,aAAM,EAAC,eAAe,CAAC;QACxC,eAAe,EAAE,IAAA,qBAAc,EAAC,eAAe,CAAC;QAChD,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;QAClD,sBAAsB,EAAE,WAAW,CAAC,sBAAsB;KAC3D,CAAC;AACJ,CAAC;AAzBD,gDAyBC"}
package/lib/time.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type * as iface from '@temporalio/proto/lib/coresdk';
2
- export declare type Timestamp = iface.google.protobuf.ITimestamp;
3
- /**
4
- * Lossy conversion function from Timestamp to number due to possible overflow.
5
- * If ts is null or undefined returns undefined.
6
- */
7
- export declare function optionalTsToMs(ts: Timestamp | null | undefined): number | undefined;
8
- /**
9
- * Lossy conversion function from Timestamp to number due to possible overflow
10
- */
11
- export declare function tsToMs(ts: Timestamp | null | undefined): number;
12
- export declare function msNumberToTs(millis: number): Timestamp;
13
- export declare function msToTs(str: string | number): Timestamp;
14
- export declare function msOptionalToTs(str: string | number | undefined): Timestamp | undefined;
15
- export declare function msOptionalToNumber(val: string | number | undefined): number | undefined;
16
- export declare function msToNumber(val: string | number): number;
package/lib/time.js DELETED
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.msToNumber = exports.msOptionalToNumber = exports.msOptionalToTs = exports.msToTs = exports.msNumberToTs = exports.tsToMs = exports.optionalTsToMs = void 0;
7
- const long_1 = __importDefault(require("long"));
8
- const ms_1 = __importDefault(require("ms"));
9
- const errors_1 = require("./errors");
10
- /**
11
- * Lossy conversion function from Timestamp to number due to possible overflow.
12
- * If ts is null or undefined returns undefined.
13
- */
14
- function optionalTsToMs(ts) {
15
- if (ts === undefined || ts === null) {
16
- return undefined;
17
- }
18
- return tsToMs(ts);
19
- }
20
- exports.optionalTsToMs = optionalTsToMs;
21
- /**
22
- * Lossy conversion function from Timestamp to number due to possible overflow
23
- */
24
- function tsToMs(ts) {
25
- if (ts === undefined || ts === null) {
26
- throw new Error(`Expected timestamp, got ${ts}`);
27
- }
28
- const { seconds, nanos } = ts;
29
- return (seconds || long_1.default.UZERO)
30
- .mul(1000)
31
- .add(Math.floor((nanos || 0) / 1000000))
32
- .toNumber();
33
- }
34
- exports.tsToMs = tsToMs;
35
- function msNumberToTs(millis) {
36
- const seconds = Math.floor(millis / 1000);
37
- const nanos = (millis % 1000) * 1000000;
38
- if (Number.isNaN(seconds) || Number.isNaN(nanos)) {
39
- throw new errors_1.ValueError(`Invalid millis ${millis}`);
40
- }
41
- return { seconds: long_1.default.fromNumber(seconds), nanos };
42
- }
43
- exports.msNumberToTs = msNumberToTs;
44
- function msToTs(str) {
45
- if (typeof str === 'number') {
46
- return msNumberToTs(str);
47
- }
48
- return msNumberToTs((0, ms_1.default)(str));
49
- }
50
- exports.msToTs = msToTs;
51
- function msOptionalToTs(str) {
52
- if (str === undefined)
53
- return undefined;
54
- if (typeof str === 'number') {
55
- return msNumberToTs(str);
56
- }
57
- return msNumberToTs((0, ms_1.default)(str));
58
- }
59
- exports.msOptionalToTs = msOptionalToTs;
60
- function msOptionalToNumber(val) {
61
- if (val === undefined)
62
- return undefined;
63
- return msToNumber(val);
64
- }
65
- exports.msOptionalToNumber = msOptionalToNumber;
66
- function msToNumber(val) {
67
- if (typeof val === 'number') {
68
- return val;
69
- }
70
- return (0, ms_1.default)(val);
71
- }
72
- exports.msToNumber = msToNumber;
73
- //# sourceMappingURL=time.js.map
package/lib/time.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,qCAAsC;AAStC;;;GAGG;AACH,SAAgB,cAAc,CAAC,EAAgC;IAC7D,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC;AALD,wCAKC;AAED;;GAEG;AACH,SAAgB,MAAM,CAAC,EAAgC;IACrD,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;KAClD;IACD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAC9B,OAAO,CAAC,OAAO,IAAI,cAAI,CAAC,KAAK,CAAC;SAC3B,GAAG,CAAC,IAAI,CAAC;SACT,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;SACvC,QAAQ,EAAE,CAAC;AAChB,CAAC;AATD,wBASC;AAED,SAAgB,YAAY,CAAC,MAAc;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;IACxC,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QAChD,MAAM,IAAI,mBAAU,CAAC,kBAAkB,MAAM,EAAE,CAAC,CAAC;KAClD;IACD,OAAO,EAAE,OAAO,EAAE,cAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;AACtD,CAAC;AAPD,oCAOC;AAED,SAAgB,MAAM,CAAC,GAAoB;IACzC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;KAC1B;IACD,OAAO,YAAY,CAAC,IAAA,YAAE,EAAC,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC;AALD,wBAKC;AAED,SAAgB,cAAc,CAAC,GAAgC;IAC7D,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;KAC1B;IACD,OAAO,YAAY,CAAC,IAAA,YAAE,EAAC,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC;AAND,wCAMC;AAED,SAAgB,kBAAkB,CAAC,GAAgC;IACjE,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAHD,gDAGC;AAED,SAAgB,UAAU,CAAC,GAAoB;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAA,YAAE,EAAC,GAAG,CAAC,CAAC;AACjB,CAAC;AALD,gCAKC"}
@@ -1,32 +0,0 @@
1
- /// <reference types="node" />
2
- /** TLS configuration options. */
3
- export interface TLSConfig {
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.
8
- */
9
- serverNameOverride?: string;
10
- /**
11
- * Root CA certificate used by the server. If not set, and the server's
12
- * cert is issued by someone the operating system trusts, verification will still work (ex: Cloud offering).
13
- */
14
- serverRootCACertificate?: Buffer;
15
- /** Sets the client certificate and key for connecting with mTLS */
16
- clientCertPair?: {
17
- /** The certificate for this client */
18
- crt: Buffer;
19
- /** The private key for this client */
20
- key: Buffer;
21
- };
22
- }
23
- /**
24
- * TLS configuration.
25
- * Pass a falsy value to use a non-encrypted connection or `true` or `{}` to
26
- * connect with TLS without any customization.
27
- */
28
- export declare type TLSConfigOption = TLSConfig | boolean | null;
29
- /**
30
- * Normalize {@link TLSConfigOption} by turning false and null to undefined and true to and empty object
31
- */
32
- export declare function normalizeTlsConfig(tls?: TLSConfigOption): TLSConfig | undefined;
package/lib/tls-config.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeTlsConfig = void 0;
4
- /**
5
- * Normalize {@link TLSConfigOption} by turning false and null to undefined and true to and empty object
6
- */
7
- function normalizeTlsConfig(tls) {
8
- return typeof tls === 'object' ? (tls === null ? undefined : tls) : tls ? {} : undefined;
9
- }
10
- exports.normalizeTlsConfig = normalizeTlsConfig;
11
- //# sourceMappingURL=tls-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tls-config.js","sourceRoot":"","sources":["../src/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,8 +0,0 @@
1
- /** Shorthand alias */
2
- export declare type AnyFunc = (...args: any[]) => any;
3
- /** A tuple without its last element */
4
- export declare type OmitLast<T> = T extends [...infer REST, any] ? REST : never;
5
- /** F with all arguments but the last */
6
- export declare type OmitLastParam<F extends AnyFunc> = (...args: OmitLast<Parameters<F>>) => ReturnType<F>;
7
- /** Verify that an type _Copy extends _Orig */
8
- export declare function checkExtends<_Orig, _Copy extends _Orig>(): void;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkExtends = void 0;
4
- /** Verify that an type _Copy extends _Orig */
5
- function checkExtends() {
6
- // noop, just type check
7
- }
8
- exports.checkExtends = checkExtends;
9
- //# sourceMappingURL=type-helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-helpers.js","sourceRoot":"","sources":["../src/type-helpers.ts"],"names":[],"mappings":";;;AAOA,8CAA8C;AAC9C,SAAgB,YAAY;IAC1B,wBAAwB;AAC1B,CAAC;AAFD,oCAEC"}
package/lib/utils.d.ts DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * Helper to prevent undefined and null values overriding defaults when merging maps
3
- */
4
- export declare function filterNullAndUndefined<T extends Record<string, any>>(obj: T): T;
package/lib/utils.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterNullAndUndefined = void 0;
4
- /**
5
- * Helper to prevent undefined and null values overriding defaults when merging maps
6
- */
7
- function filterNullAndUndefined(obj) {
8
- return Object.fromEntries(Object.entries(obj).filter(([_k, v]) => v != null));
9
- }
10
- exports.filterNullAndUndefined = filterNullAndUndefined;
11
- //# sourceMappingURL=utils.js.map
package/lib/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/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,27 +0,0 @@
1
- import { Workflow, WorkflowResultType, SignalDefinition } from './interfaces';
2
- /**
3
- * Base WorkflowHandle interface, extended in workflow and client libs.
4
- *
5
- * Transforms a workflow interface `T` into a client interface.
6
- */
7
- export interface BaseWorkflowHandle<T extends Workflow> {
8
- /**
9
- * Promise that resolves when Workflow execution completes
10
- */
11
- result(): Promise<WorkflowResultType<T>>;
12
- /**
13
- * Signal a running Workflow.
14
- *
15
- * @param def a signal definition as returned from {@link defineSignal}
16
- *
17
- * @example
18
- * ```ts
19
- * await handle.signal(incrementSignal, 3);
20
- * ```
21
- */
22
- signal<Args extends any[] = []>(def: SignalDefinition<Args> | string, ...args: Args): Promise<void>;
23
- /**
24
- * The workflowId of the current Workflow
25
- */
26
- readonly workflowId: string;
27
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=workflow-handle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-handle.js","sourceRoot":"","sources":["../src/workflow-handle.ts"],"names":[],"mappings":""}