@temporalio/common 0.15.0 → 0.17.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.
- package/lib/activity-options.d.ts +9 -5
- package/lib/activity-options.js +10 -2
- package/lib/activity-options.js.map +1 -1
- package/lib/converter/data-converter.d.ts +9 -2
- package/lib/converter/data-converter.js +14 -2
- package/lib/converter/data-converter.js.map +1 -1
- package/lib/converter/helpers.d.ts +1 -0
- package/lib/converter/helpers.js +33 -0
- package/lib/converter/helpers.js.map +1 -0
- package/lib/converter/payload-converter.d.ts +34 -2
- package/lib/converter/payload-converter.js +137 -1
- package/lib/converter/payload-converter.js.map +1 -1
- package/lib/converter/types.d.ts +2 -1
- package/lib/converter/types.js +2 -1
- package/lib/converter/types.js.map +1 -1
- package/lib/errors.d.ts +4 -0
- package/lib/errors.js +13 -1
- package/lib/errors.js.map +1 -1
- package/lib/failure.d.ts +20 -7
- package/lib/failure.js +32 -9
- package/lib/failure.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +1 -1
- package/lib/interfaces.d.ts +4 -38
- package/lib/retry-policy.d.ts +43 -0
- package/lib/retry-policy.js +36 -0
- package/lib/retry-policy.js.map +1 -0
- package/lib/time.d.ts +2 -1
- package/lib/time.js +7 -1
- package/lib/time.js.map +1 -1
- package/lib/type-helpers.d.ts +5 -0
- package/lib/type-helpers.js +18 -0
- package/lib/type-helpers.js.map +1 -1
- package/lib/utils.d.ts +4 -0
- package/lib/utils.js +11 -0
- package/lib/utils.js.map +1 -0
- package/lib/workflow-options.d.ts +16 -21
- package/lib/workflow-options.js +13 -3
- package/lib/workflow-options.js.map +1 -1
- package/package.json +8 -4
- package/src/activity-options.ts +14 -5
- package/src/converter/data-converter.ts +29 -6
- package/src/converter/helpers.ts +38 -0
- package/src/converter/payload-converter.ts +155 -4
- package/src/converter/types.ts +3 -1
- package/src/errors.ts +18 -0
- package/src/failure.ts +34 -10
- package/src/index.ts +3 -0
- package/src/interceptors.ts +1 -1
- package/src/interfaces.ts +4 -40
- package/src/retry-policy.ts +73 -0
- package/src/time.ts +6 -1
- package/src/type-helpers.ts +23 -0
- package/src/utils.ts +6 -0
- package/src/workflow-options.ts +29 -34
- package/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +0 -8
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { coresdk } from '@temporalio/proto/lib/coresdk';
|
|
2
|
-
import {
|
|
3
|
-
export declare
|
|
1
|
+
import type { coresdk } from '@temporalio/proto/lib/coresdk';
|
|
2
|
+
import { RetryPolicy } from './retry-policy';
|
|
3
|
+
export declare enum ActivityCancellationType {
|
|
4
|
+
TRY_CANCEL = 0,
|
|
5
|
+
WAIT_CANCELLATION_COMPLETED = 1,
|
|
6
|
+
ABANDON = 2
|
|
7
|
+
}
|
|
4
8
|
/**
|
|
5
9
|
* Options for remote activity invocation - will be processed from a task queue.
|
|
6
10
|
* @see https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/activity/ActivityOptions.Builder.html
|
|
@@ -31,9 +35,9 @@ export interface ActivityOptions {
|
|
|
31
35
|
*/
|
|
32
36
|
heartbeatTimeout?: string | number;
|
|
33
37
|
/**
|
|
34
|
-
*
|
|
38
|
+
* RetryPolicy that define how activity is retried in case of failure. If this is not set, then the server-defined default activity retry policy will be used. To ensure zero retries, set maximum attempts to 1.
|
|
35
39
|
*/
|
|
36
|
-
retry?:
|
|
40
|
+
retry?: RetryPolicy;
|
|
37
41
|
/**
|
|
38
42
|
* Maximum time of a single Activity execution attempt.
|
|
39
43
|
Note that the Temporal Server doesn't detect Worker process failures directly. It relies on this timeout to detect that an Activity that didn't complete on time. So this timeout should be as short as the longest possible execution of the Activity body. Potentially long running Activities must specify {@link heartbeatTimeout} and call {@link activity.Context.heartbeat} periodically for timely failure detection.
|
package/lib/activity-options.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActivityCancellationType = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const type_helpers_1 = require("./type-helpers");
|
|
5
|
+
// Avoid importing the proto implementation to reduce workflow bundle size
|
|
6
|
+
// Copied from coresdk.workflow_commands.ActivityCancellationType
|
|
7
|
+
var ActivityCancellationType;
|
|
8
|
+
(function (ActivityCancellationType) {
|
|
9
|
+
ActivityCancellationType[ActivityCancellationType["TRY_CANCEL"] = 0] = "TRY_CANCEL";
|
|
10
|
+
ActivityCancellationType[ActivityCancellationType["WAIT_CANCELLATION_COMPLETED"] = 1] = "WAIT_CANCELLATION_COMPLETED";
|
|
11
|
+
ActivityCancellationType[ActivityCancellationType["ABANDON"] = 2] = "ABANDON";
|
|
12
|
+
})(ActivityCancellationType = exports.ActivityCancellationType || (exports.ActivityCancellationType = {}));
|
|
13
|
+
(0, type_helpers_1.checkExtends)();
|
|
6
14
|
//# sourceMappingURL=activity-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-options.js","sourceRoot":"","sources":["../src/activity-options.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"activity-options.js","sourceRoot":"","sources":["../src/activity-options.ts"],"names":[],"mappings":";;;AAEA,iDAA8C;AAE9C,0EAA0E;AAC1E,iEAAiE;AACjE,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,mFAAc,CAAA;IACd,qHAA+B,CAAA;IAC/B,6EAAW,CAAA;AACb,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AAED,IAAA,2BAAY,GAAgF,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { PayloadConverter } from './payload-converter';
|
|
|
4
4
|
* Used by the framework to serialize/deserialize method parameters that need to be sent over the
|
|
5
5
|
* wire.
|
|
6
6
|
*
|
|
7
|
-
* Implement this in order to customize worker data serialization or use the default data converter which supports `Uint8Array
|
|
7
|
+
* Implement this in order to customize worker data serialization or use the default data converter which supports `Uint8Array`, Protobuf, and JSON serializables.
|
|
8
8
|
*/
|
|
9
9
|
export interface DataConverter {
|
|
10
10
|
toPayload<T>(value: T): Promise<Payload>;
|
|
@@ -53,6 +53,7 @@ export interface DataConverter {
|
|
|
53
53
|
*/
|
|
54
54
|
fromPayloadsSync<T>(index: number, content?: Payload[] | null): T;
|
|
55
55
|
}
|
|
56
|
+
export declare const isValidDataConverter: (dataConverter: unknown) => dataConverter is DataConverter;
|
|
56
57
|
export declare class CompositeDataConverter implements DataConverter {
|
|
57
58
|
readonly converters: PayloadConverter[];
|
|
58
59
|
readonly converterByEncoding: Map<string, PayloadConverter>;
|
|
@@ -70,4 +71,10 @@ export declare function arrayFromPayloads(converter: DataConverter, content?: Pa
|
|
|
70
71
|
export declare function mapToPayloads<K extends string>(converter: DataConverter, source: Record<K, any>): Promise<Record<K, Payload>>;
|
|
71
72
|
export declare function arrayFromPayloadsSync(converter: DataConverter, content?: Payload[] | null): unknown[];
|
|
72
73
|
export declare function mapToPayloadsSync<K extends string>(converter: DataConverter, source: Record<K, any>): Record<K, Payload>;
|
|
73
|
-
export
|
|
74
|
+
export interface DefaultDataConverterOptions {
|
|
75
|
+
root?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
export declare class DefaultDataConverter extends CompositeDataConverter {
|
|
78
|
+
constructor({ root }?: DefaultDataConverterOptions);
|
|
79
|
+
}
|
|
80
|
+
export declare const defaultDataConverter: DefaultDataConverter;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultDataConverter = exports.mapToPayloadsSync = exports.arrayFromPayloadsSync = exports.mapToPayloads = exports.arrayFromPayloads = exports.CompositeDataConverter = void 0;
|
|
3
|
+
exports.defaultDataConverter = exports.DefaultDataConverter = exports.mapToPayloadsSync = exports.arrayFromPayloadsSync = exports.mapToPayloads = exports.arrayFromPayloads = exports.CompositeDataConverter = exports.isValidDataConverter = void 0;
|
|
4
4
|
const errors_1 = require("../errors");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
const payload_converter_1 = require("./payload-converter");
|
|
7
|
+
const isValidDataConverter = (dataConverter) => typeof dataConverter === 'object' &&
|
|
8
|
+
dataConverter !== null &&
|
|
9
|
+
['toPayload', 'toPayloads', 'fromPayload', 'fromPayloads'].every((method) => typeof dataConverter[method] === 'function');
|
|
10
|
+
exports.isValidDataConverter = isValidDataConverter;
|
|
7
11
|
class CompositeDataConverter {
|
|
8
12
|
constructor(...converters) {
|
|
9
13
|
this.converterByEncoding = new Map();
|
|
@@ -100,5 +104,13 @@ function mapToPayloadsSync(converter, source) {
|
|
|
100
104
|
return Object.fromEntries(Object.entries(source).map(([k, v]) => [k, converter.toPayloadSync(v)]));
|
|
101
105
|
}
|
|
102
106
|
exports.mapToPayloadsSync = mapToPayloadsSync;
|
|
103
|
-
|
|
107
|
+
class DefaultDataConverter extends CompositeDataConverter {
|
|
108
|
+
constructor({ root } = {}) {
|
|
109
|
+
// Match the order used in other SDKs
|
|
110
|
+
// Go SDK: https://github.com/temporalio/sdk-go/blob/5e5645f0c550dcf717c095ae32c76a7087d2e985/converter/default_data_converter.go#L28
|
|
111
|
+
super(new payload_converter_1.UndefinedPayloadConverter(), new payload_converter_1.BinaryPayloadConverter(), new payload_converter_1.ProtobufJsonPayloadConverter(root), new payload_converter_1.ProtobufBinaryPayloadConverter(root), new payload_converter_1.JsonPayloadConverter());
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.DefaultDataConverter = DefaultDataConverter;
|
|
115
|
+
exports.defaultDataConverter = new DefaultDataConverter();
|
|
104
116
|
//# sourceMappingURL=data-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-converter.js","sourceRoot":"","sources":["../../src/converter/data-converter.ts"],"names":[],"mappings":";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AAC,EACxC,IAAI,wCAAoB,EAAE,CAC3B,CAAC;IACJ,CAAC;CACF;AAZD,oDAYC;AAEY,QAAA,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function patchProtobufRoot<T extends Record<string, unknown>>(root: T, name?: string): T;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patchProtobufRoot = void 0;
|
|
4
|
+
const type_helpers_1 = require("../type-helpers");
|
|
5
|
+
function patchProtobufRoot(root, name) {
|
|
6
|
+
const newRoot = new root.constructor(isNamespace(root) ? name : {});
|
|
7
|
+
for (const key in root) {
|
|
8
|
+
newRoot[key] = root[key];
|
|
9
|
+
}
|
|
10
|
+
if ((0, type_helpers_1.isRecord)(root.nested)) {
|
|
11
|
+
for (const typeOrNamespace in root.nested) {
|
|
12
|
+
const value = root.nested[typeOrNamespace];
|
|
13
|
+
if (typeOrNamespace in root && !(isType(root[typeOrNamespace]) || isNamespace(root[typeOrNamespace]))) {
|
|
14
|
+
console.log(`patchRoot warning: overriding property '${typeOrNamespace}' that is used by protobufjs with the '${typeOrNamespace}' protobuf namespace. This may result in protobufjs not working property.`);
|
|
15
|
+
}
|
|
16
|
+
if (isNamespace(value)) {
|
|
17
|
+
newRoot[typeOrNamespace] = patchProtobufRoot(value, typeOrNamespace);
|
|
18
|
+
}
|
|
19
|
+
else if (isType(value)) {
|
|
20
|
+
newRoot[typeOrNamespace] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return newRoot;
|
|
25
|
+
}
|
|
26
|
+
exports.patchProtobufRoot = patchProtobufRoot;
|
|
27
|
+
function isType(value) {
|
|
28
|
+
return (0, type_helpers_1.isRecord)(value) && value.constructor.name === 'Type';
|
|
29
|
+
}
|
|
30
|
+
function isNamespace(value) {
|
|
31
|
+
return (0, type_helpers_1.isRecord)(value) && value.constructor.name === 'Namespace';
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/converter/helpers.ts"],"names":[],"mappings":";;;AAAA,kDAA2C;AAE3C,SAAgB,iBAAiB,CAAoC,IAAO,EAAE,IAAa;IACzF,MAAM,OAAO,GAAG,IAAK,IAAI,CAAC,WAAmB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;KAC1B;IAED,IAAI,IAAA,uBAAQ,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACzB,KAAK,MAAM,eAAe,IAAI,IAAI,CAAC,MAAM,EAAE;YACzC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YAC3C,IAAI,eAAe,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;gBACrG,OAAO,CAAC,GAAG,CACT,2CAA2C,eAAe,0CAA0C,eAAe,2EAA2E,CAC/L,CAAC;aACH;YAED,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;gBACtB,OAAO,CAAC,eAAe,CAAC,GAAG,iBAAiB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;aACtE;iBAAM,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;gBACxB,OAAO,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC;aAClC;SACF;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAxBD,8CAwBC;AAKD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,IAAA,uBAAQ,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC;AAC9D,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,IAAA,uBAAQ,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,WAAW,CAAC;AACnE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Payload } from './types';
|
|
2
|
+
import type { Root, Type } from 'protobufjs';
|
|
2
3
|
/**
|
|
3
4
|
* Used by the framework to serialize/deserialize method parameters that need to be sent over the
|
|
4
5
|
* wire.
|
|
@@ -12,7 +13,7 @@ export interface PayloadConverter {
|
|
|
12
13
|
* Implements conversion of value to payload
|
|
13
14
|
*
|
|
14
15
|
* @param value JS value to convert.
|
|
15
|
-
* @return converted value
|
|
16
|
+
* @return converted value or `undefined` if unable to convert.
|
|
16
17
|
* @throws DataConverterException if conversion of the value passed as parameter failed for any
|
|
17
18
|
* reason.
|
|
18
19
|
*/
|
|
@@ -33,7 +34,7 @@ export interface PayloadConverter {
|
|
|
33
34
|
* Implements conversion of value to payload
|
|
34
35
|
*
|
|
35
36
|
* @param value JS value to convert.
|
|
36
|
-
* @return converted value
|
|
37
|
+
* @return converted value or `undefined` if unable to convert.
|
|
37
38
|
* @throws DataConverterException if conversion of the value passed as parameter failed for any
|
|
38
39
|
* reason.
|
|
39
40
|
*/
|
|
@@ -82,3 +83,34 @@ export declare class BinaryPayloadConverter extends AsyncFacadePayloadConverter
|
|
|
82
83
|
toDataSync(value: unknown): Payload | undefined;
|
|
83
84
|
fromDataSync<T>(content: Payload): T;
|
|
84
85
|
}
|
|
86
|
+
declare abstract class ProtobufPayloadConverter extends AsyncFacadePayloadConverter {
|
|
87
|
+
protected readonly root: Root | undefined;
|
|
88
|
+
constructor(root?: unknown);
|
|
89
|
+
protected validatePayload(content: Payload): {
|
|
90
|
+
messageType: Type;
|
|
91
|
+
data: Uint8Array;
|
|
92
|
+
};
|
|
93
|
+
protected constructPayload({ messageTypeName, message }: {
|
|
94
|
+
messageTypeName: string;
|
|
95
|
+
message: Uint8Array;
|
|
96
|
+
}): Payload;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Converts between protobufjs Message instances and serialized Protobuf Payload
|
|
100
|
+
*/
|
|
101
|
+
export declare class ProtobufBinaryPayloadConverter extends ProtobufPayloadConverter {
|
|
102
|
+
encodingType: "binary/protobuf";
|
|
103
|
+
constructor(root?: unknown);
|
|
104
|
+
toDataSync(value: unknown): Payload | undefined;
|
|
105
|
+
fromDataSync<T>(content: Payload): T;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Converts between protobufjs Message instances and serialized JSON Payload
|
|
109
|
+
*/
|
|
110
|
+
export declare class ProtobufJsonPayloadConverter extends ProtobufPayloadConverter {
|
|
111
|
+
encodingType: "json/protobuf";
|
|
112
|
+
constructor(root?: unknown);
|
|
113
|
+
toDataSync(value: unknown): Payload | undefined;
|
|
114
|
+
fromDataSync<T>(content: Payload): T;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
@@ -1,8 +1,30 @@
|
|
|
1
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
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BinaryPayloadConverter = exports.JsonPayloadConverter = exports.UndefinedPayloadConverter = exports.AsyncFacadePayloadConverter = void 0;
|
|
22
|
+
exports.ProtobufJsonPayloadConverter = exports.ProtobufBinaryPayloadConverter = exports.BinaryPayloadConverter = exports.JsonPayloadConverter = exports.UndefinedPayloadConverter = exports.AsyncFacadePayloadConverter = void 0;
|
|
4
23
|
const errors_1 = require("../errors");
|
|
5
24
|
const types_1 = require("./types");
|
|
25
|
+
const type_helpers_1 = require("../type-helpers");
|
|
26
|
+
const errors_2 = require("../errors");
|
|
27
|
+
const protoJsonSerializer = __importStar(require("proto3-json-serializer"));
|
|
6
28
|
class AsyncFacadePayloadConverter {
|
|
7
29
|
async toData(value) {
|
|
8
30
|
return this.toDataSync(value);
|
|
@@ -86,4 +108,118 @@ class BinaryPayloadConverter extends AsyncFacadePayloadConverter {
|
|
|
86
108
|
}
|
|
87
109
|
}
|
|
88
110
|
exports.BinaryPayloadConverter = BinaryPayloadConverter;
|
|
111
|
+
class ProtobufPayloadConverter extends AsyncFacadePayloadConverter {
|
|
112
|
+
// Don't use type Root here because root.d.ts doesn't export Root, so users would have to type assert
|
|
113
|
+
constructor(root) {
|
|
114
|
+
super();
|
|
115
|
+
if (root) {
|
|
116
|
+
if (!isRoot(root)) {
|
|
117
|
+
throw new TypeError('root must be an instance of a protobufjs Root');
|
|
118
|
+
}
|
|
119
|
+
this.root = root;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
validatePayload(content) {
|
|
123
|
+
if (content.data === undefined || content.data === null) {
|
|
124
|
+
throw new errors_1.ValueError('Got payload with no data');
|
|
125
|
+
}
|
|
126
|
+
if (!content.metadata || !(types_1.METADATA_MESSAGE_TYPE_KEY in content.metadata)) {
|
|
127
|
+
throw new errors_1.ValueError(`Got protobuf payload without metadata.${types_1.METADATA_MESSAGE_TYPE_KEY}`);
|
|
128
|
+
}
|
|
129
|
+
if (!this.root) {
|
|
130
|
+
throw new errors_1.DataConverterError('Unable to deserialize protobuf message without `root` being provided');
|
|
131
|
+
}
|
|
132
|
+
const messageTypeName = (0, types_1.str)(content.metadata[types_1.METADATA_MESSAGE_TYPE_KEY]);
|
|
133
|
+
let messageType;
|
|
134
|
+
try {
|
|
135
|
+
messageType = this.root.lookupType(messageTypeName);
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
if ((0, errors_2.errorMessage)(e)?.includes('no such type')) {
|
|
139
|
+
throw new errors_1.DataConverterError(`Got a \`${messageTypeName}\` protobuf message but cannot find corresponding message class in \`root\``);
|
|
140
|
+
}
|
|
141
|
+
throw e;
|
|
142
|
+
}
|
|
143
|
+
return { messageType, data: content.data };
|
|
144
|
+
}
|
|
145
|
+
constructPayload({ messageTypeName, message }) {
|
|
146
|
+
return {
|
|
147
|
+
metadata: {
|
|
148
|
+
[types_1.METADATA_ENCODING_KEY]: (0, types_1.u8)(this.encodingType),
|
|
149
|
+
[types_1.METADATA_MESSAGE_TYPE_KEY]: (0, types_1.u8)(messageTypeName),
|
|
150
|
+
},
|
|
151
|
+
data: message,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Converts between protobufjs Message instances and serialized Protobuf Payload
|
|
157
|
+
*/
|
|
158
|
+
class ProtobufBinaryPayloadConverter extends ProtobufPayloadConverter {
|
|
159
|
+
constructor(root) {
|
|
160
|
+
super(root);
|
|
161
|
+
this.encodingType = types_1.encodingTypes.METADATA_ENCODING_PROTOBUF;
|
|
162
|
+
}
|
|
163
|
+
toDataSync(value) {
|
|
164
|
+
if (!isProtobufMessage(value)) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
return this.constructPayload({
|
|
168
|
+
messageTypeName: getNamespacedTypeName(value.$type),
|
|
169
|
+
message: value.$type.encode(value).finish(),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
fromDataSync(content) {
|
|
173
|
+
const { messageType, data } = this.validatePayload(content);
|
|
174
|
+
return messageType.decode(data);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.ProtobufBinaryPayloadConverter = ProtobufBinaryPayloadConverter;
|
|
178
|
+
/**
|
|
179
|
+
* Converts between protobufjs Message instances and serialized JSON Payload
|
|
180
|
+
*/
|
|
181
|
+
class ProtobufJsonPayloadConverter extends ProtobufPayloadConverter {
|
|
182
|
+
constructor(root) {
|
|
183
|
+
super(root);
|
|
184
|
+
this.encodingType = types_1.encodingTypes.METADATA_ENCODING_PROTOBUF_JSON;
|
|
185
|
+
}
|
|
186
|
+
toDataSync(value) {
|
|
187
|
+
if (!isProtobufMessage(value)) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
const jsonValue = protoJsonSerializer.toProto3JSON(value);
|
|
191
|
+
return this.constructPayload({
|
|
192
|
+
messageTypeName: getNamespacedTypeName(value.$type),
|
|
193
|
+
message: (0, types_1.u8)(JSON.stringify(jsonValue)),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
fromDataSync(content) {
|
|
197
|
+
const { messageType, data } = this.validatePayload(content);
|
|
198
|
+
return protoJsonSerializer.fromProto3JSON(messageType, JSON.parse((0, types_1.str)(data)));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.ProtobufJsonPayloadConverter = ProtobufJsonPayloadConverter;
|
|
202
|
+
function isProtobufType(type) {
|
|
203
|
+
return ((0, type_helpers_1.isRecord)(type) &&
|
|
204
|
+
type.constructor.name === 'Type' &&
|
|
205
|
+
(0, type_helpers_1.hasOwnProperties)(type, ['parent', 'name', 'create', 'encode', 'decode']) &&
|
|
206
|
+
typeof type.name === 'string' &&
|
|
207
|
+
typeof type.create === 'function' &&
|
|
208
|
+
typeof type.encode === 'function' &&
|
|
209
|
+
typeof type.decode === 'function');
|
|
210
|
+
}
|
|
211
|
+
function isProtobufMessage(value) {
|
|
212
|
+
return (0, type_helpers_1.isRecord)(value) && (0, type_helpers_1.hasOwnProperty)(value, '$type') && isProtobufType(value.$type);
|
|
213
|
+
}
|
|
214
|
+
function getNamespacedTypeName(node) {
|
|
215
|
+
if (node.parent && !isRoot(node.parent)) {
|
|
216
|
+
return getNamespacedTypeName(node.parent) + '.' + node.name;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return node.name;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function isRoot(root) {
|
|
223
|
+
return (0, type_helpers_1.isRecord)(root) && root.constructor.name === 'Root';
|
|
224
|
+
}
|
|
89
225
|
//# sourceMappingURL=payload-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload-converter.js","sourceRoot":"","sources":["../../src/converter/payload-converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payload-converter.js","sourceRoot":"","sources":["../../src/converter/payload-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,sCAA2D;AAC3D,mCAQiB;AACjB,kDAA6E;AAC7E,sCAAyC;AACzC,4EAA8D;AA4D9D,MAAsB,2BAA2B;IAKxC,KAAK,CAAC,MAAM,CAAC,KAAc;QAChC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAI,OAAgB;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACF;AAZD,kEAYC;AAED;;GAEG;AACH,MAAa,yBAA0B,SAAQ,2BAA2B;IAA1E;;QACS,iBAAY,GAAG,qBAAa,CAA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,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,IAAA,uBAAQ,EAAC,KAAK,CAAC,IAAI,IAAA,6BAAc,EAAC,KAAK,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,qBAAqB,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,OAAO,IAAA,uBAAQ,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC;AAC5D,CAAC"}
|
package/lib/converter/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as iface from '@temporalio/proto/lib/coresdk';
|
|
1
|
+
import type * as iface from '@temporalio/proto/lib/coresdk';
|
|
2
2
|
export declare type Payload = iface.coresdk.common.IPayload;
|
|
3
3
|
/**
|
|
4
4
|
* Transform an *ascii* string into a Uint8Array
|
|
@@ -20,3 +20,4 @@ export declare const encodingKeys: {
|
|
|
20
20
|
readonly METADATA_ENCODING_PROTOBUF_JSON: Uint8Array;
|
|
21
21
|
readonly METADATA_ENCODING_PROTOBUF: Uint8Array;
|
|
22
22
|
};
|
|
23
|
+
export declare const METADATA_MESSAGE_TYPE_KEY = "messageType";
|
package/lib/converter/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodingKeys = exports.encodingTypes = exports.METADATA_ENCODING_KEY = exports.str = exports.u8 = void 0;
|
|
3
|
+
exports.METADATA_MESSAGE_TYPE_KEY = exports.encodingKeys = exports.encodingTypes = exports.METADATA_ENCODING_KEY = exports.str = exports.u8 = void 0;
|
|
4
4
|
const encoding_1 = require("../encoding");
|
|
5
5
|
/**
|
|
6
6
|
* Transform an *ascii* string into a Uint8Array
|
|
@@ -28,4 +28,5 @@ exports.encodingKeys = {
|
|
|
28
28
|
METADATA_ENCODING_PROTOBUF_JSON: u8(exports.encodingTypes.METADATA_ENCODING_PROTOBUF_JSON),
|
|
29
29
|
METADATA_ENCODING_PROTOBUF: u8(exports.encodingTypes.METADATA_ENCODING_PROTOBUF),
|
|
30
30
|
};
|
|
31
|
+
exports.METADATA_MESSAGE_TYPE_KEY = 'messageType';
|
|
31
32
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/converter/types.ts"],"names":[],"mappings":";;;AACA,0CAAuD;AAIvD;;GAEG;AACH,SAAgB,EAAE,CAAC,CAAS;IAC1B,OAAO,IAAI,sBAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAFD,gBAEC;AAED,SAAgB,GAAG,CAAC,CAAa;IAC/B,OAAO,IAAI,sBAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAFD,kBAEC;AAEY,QAAA,qBAAqB,GAAG,UAAU,CAAC;AACnC,QAAA,aAAa,GAAG;IAC3B,sBAAsB,EAAE,aAAa;IACrC,qBAAqB,EAAE,cAAc;IACrC,sBAAsB,EAAE,YAAY;IACpC,+BAA+B,EAAE,eAAe;IAChD,0BAA0B,EAAE,iBAAiB;CACrC,CAAC;AAEE,QAAA,YAAY,GAAG;IAC1B,sBAAsB,EAAE,EAAE,CAAC,qBAAa,CAAC,sBAAsB,CAAC;IAChE,qBAAqB,EAAE,EAAE,CAAC,qBAAa,CAAC,qBAAqB,CAAC;IAC9D,sBAAsB,EAAE,EAAE,CAAC,qBAAa,CAAC,sBAAsB,CAAC;IAChE,+BAA+B,EAAE,EAAE,CAAC,qBAAa,CAAC,+BAA+B,CAAC;IAClF,0BAA0B,EAAE,EAAE,CAAC,qBAAa,CAAC,0BAA0B,CAAC;CAChE,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/converter/types.ts"],"names":[],"mappings":";;;AACA,0CAAuD;AAIvD;;GAEG;AACH,SAAgB,EAAE,CAAC,CAAS;IAC1B,OAAO,IAAI,sBAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAFD,gBAEC;AAED,SAAgB,GAAG,CAAC,CAAa;IAC/B,OAAO,IAAI,sBAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAFD,kBAEC;AAEY,QAAA,qBAAqB,GAAG,UAAU,CAAC;AACnC,QAAA,aAAa,GAAG;IAC3B,sBAAsB,EAAE,aAAa;IACrC,qBAAqB,EAAE,cAAc;IACrC,sBAAsB,EAAE,YAAY;IACpC,+BAA+B,EAAE,eAAe;IAChD,0BAA0B,EAAE,iBAAiB;CACrC,CAAC;AAEE,QAAA,YAAY,GAAG;IAC1B,sBAAsB,EAAE,EAAE,CAAC,qBAAa,CAAC,sBAAsB,CAAC;IAChE,qBAAqB,EAAE,EAAE,CAAC,qBAAa,CAAC,qBAAqB,CAAC;IAC9D,sBAAsB,EAAE,EAAE,CAAC,qBAAa,CAAC,sBAAsB,CAAC;IAChE,+BAA+B,EAAE,EAAE,CAAC,qBAAa,CAAC,+BAA+B,CAAC;IAClF,0BAA0B,EAAE,EAAE,CAAC,qBAAa,CAAC,0BAA0B,CAAC;CAChE,CAAC;AAEE,QAAA,yBAAyB,GAAG,aAAa,CAAC"}
|
package/lib/errors.d.ts
CHANGED
|
@@ -14,3 +14,7 @@ export declare class IllegalStateError extends Error {
|
|
|
14
14
|
* Get error message from an Error or string or return undefined
|
|
15
15
|
*/
|
|
16
16
|
export declare function errorMessage(err: unknown): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get error code from an Error or return undefined
|
|
19
|
+
*/
|
|
20
|
+
export declare function errorCode(error: unknown): string | undefined;
|
package/lib/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorMessage = exports.IllegalStateError = exports.DataConverterError = exports.ValueError = void 0;
|
|
3
|
+
exports.errorCode = exports.errorMessage = exports.IllegalStateError = exports.DataConverterError = exports.ValueError = void 0;
|
|
4
4
|
class ValueError extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
@@ -38,4 +38,16 @@ function errorMessage(err) {
|
|
|
38
38
|
return undefined;
|
|
39
39
|
}
|
|
40
40
|
exports.errorMessage = errorMessage;
|
|
41
|
+
/**
|
|
42
|
+
* Get error code from an Error or return undefined
|
|
43
|
+
*/
|
|
44
|
+
function errorCode(error) {
|
|
45
|
+
if (typeof error === 'object' &&
|
|
46
|
+
error.code !== undefined &&
|
|
47
|
+
typeof error.code === 'string') {
|
|
48
|
+
return error.code;
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
exports.errorCode = errorCode;
|
|
41
53
|
//# sourceMappingURL=errors.js.map
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;IAA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ANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import { temporal } from '@temporalio/proto/lib/coresdk';
|
|
1
|
+
import type { temporal } from '@temporalio/proto/lib/coresdk';
|
|
2
2
|
import { DataConverter } from './converter/data-converter';
|
|
3
3
|
export declare const FAILURE_SOURCE = "TypeScriptSDK";
|
|
4
4
|
export declare type ProtoFailure = temporal.api.failure.v1.IFailure;
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export declare enum TimeoutType {
|
|
6
|
+
TIMEOUT_TYPE_UNSPECIFIED = 0,
|
|
7
|
+
TIMEOUT_TYPE_START_TO_CLOSE = 1,
|
|
8
|
+
TIMEOUT_TYPE_SCHEDULE_TO_START = 2,
|
|
9
|
+
TIMEOUT_TYPE_SCHEDULE_TO_CLOSE = 3,
|
|
10
|
+
TIMEOUT_TYPE_HEARTBEAT = 4
|
|
11
|
+
}
|
|
12
|
+
export declare enum RetryState {
|
|
13
|
+
RETRY_STATE_UNSPECIFIED = 0,
|
|
14
|
+
RETRY_STATE_IN_PROGRESS = 1,
|
|
15
|
+
RETRY_STATE_NON_RETRYABLE_FAILURE = 2,
|
|
16
|
+
RETRY_STATE_TIMEOUT = 3,
|
|
17
|
+
RETRY_STATE_MAXIMUM_ATTEMPTS_REACHED = 4,
|
|
18
|
+
RETRY_STATE_RETRY_POLICY_NOT_SET = 5,
|
|
19
|
+
RETRY_STATE_INTERNAL_SERVER_ERROR = 6,
|
|
20
|
+
RETRY_STATE_CANCEL_REQUESTED = 7
|
|
21
|
+
}
|
|
9
22
|
export declare type WorkflowExecution = temporal.api.common.v1.IWorkflowExecution;
|
|
10
23
|
/**
|
|
11
24
|
* Represents failures that can cross Workflow and Activity boundaries.
|
|
@@ -75,7 +88,7 @@ export declare class ApplicationFailure extends TemporalFailure {
|
|
|
75
88
|
* @param details optional details about the failure. They are serialized using the same approach
|
|
76
89
|
* as arguments and results.
|
|
77
90
|
*/
|
|
78
|
-
static retryable(message: string | undefined, type
|
|
91
|
+
static retryable(message: string | undefined, type?: string, ...details: unknown[]): ApplicationFailure;
|
|
79
92
|
/**
|
|
80
93
|
* New ApplicationFailure with {@link nonRetryable} flag set to true.
|
|
81
94
|
*
|
|
@@ -87,7 +100,7 @@ export declare class ApplicationFailure extends TemporalFailure {
|
|
|
87
100
|
* @param details optional details about the failure. They are serialized using the same approach
|
|
88
101
|
* as arguments and results.
|
|
89
102
|
*/
|
|
90
|
-
static nonRetryable(message: string | undefined, type
|
|
103
|
+
static nonRetryable(message: string | undefined, type?: string, ...details: unknown[]): ApplicationFailure;
|
|
91
104
|
}
|
|
92
105
|
/**
|
|
93
106
|
* Used as the cause for when a Workflow or Activity has been cancelled
|
package/lib/failure.js
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rootCause = exports.failureToError = exports.failureToErrorInner = exports.optionalFailureToOptionalError = exports.ensureTemporalFailure = exports.errorToFailure = exports.cutoffStackTrace = exports.optionalErrorToOptionalFailure = exports.ChildWorkflowFailure = exports.ActivityFailure = exports.TimeoutFailure = exports.TerminatedFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ServerFailure = exports.TemporalFailure = exports.RetryState = exports.TimeoutType = exports.FAILURE_SOURCE = void 0;
|
|
4
|
-
const coresdk_1 = require("@temporalio/proto/lib/coresdk");
|
|
5
4
|
const data_converter_1 = require("./converter/data-converter");
|
|
5
|
+
const type_helpers_1 = require("./type-helpers");
|
|
6
6
|
exports.FAILURE_SOURCE = 'TypeScriptSDK';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// Avoid importing the proto implementation to reduce workflow bundle size
|
|
8
|
+
// Copied from temporal.api.enums.v1.TimeoutType
|
|
9
|
+
var TimeoutType;
|
|
10
|
+
(function (TimeoutType) {
|
|
11
|
+
TimeoutType[TimeoutType["TIMEOUT_TYPE_UNSPECIFIED"] = 0] = "TIMEOUT_TYPE_UNSPECIFIED";
|
|
12
|
+
TimeoutType[TimeoutType["TIMEOUT_TYPE_START_TO_CLOSE"] = 1] = "TIMEOUT_TYPE_START_TO_CLOSE";
|
|
13
|
+
TimeoutType[TimeoutType["TIMEOUT_TYPE_SCHEDULE_TO_START"] = 2] = "TIMEOUT_TYPE_SCHEDULE_TO_START";
|
|
14
|
+
TimeoutType[TimeoutType["TIMEOUT_TYPE_SCHEDULE_TO_CLOSE"] = 3] = "TIMEOUT_TYPE_SCHEDULE_TO_CLOSE";
|
|
15
|
+
TimeoutType[TimeoutType["TIMEOUT_TYPE_HEARTBEAT"] = 4] = "TIMEOUT_TYPE_HEARTBEAT";
|
|
16
|
+
})(TimeoutType = exports.TimeoutType || (exports.TimeoutType = {}));
|
|
17
|
+
(0, type_helpers_1.checkExtends)();
|
|
18
|
+
// Avoid importing the proto implementation to reduce workflow bundle size
|
|
19
|
+
// Copied from temporal.api.enums.v1.RetryState
|
|
20
|
+
var RetryState;
|
|
21
|
+
(function (RetryState) {
|
|
22
|
+
RetryState[RetryState["RETRY_STATE_UNSPECIFIED"] = 0] = "RETRY_STATE_UNSPECIFIED";
|
|
23
|
+
RetryState[RetryState["RETRY_STATE_IN_PROGRESS"] = 1] = "RETRY_STATE_IN_PROGRESS";
|
|
24
|
+
RetryState[RetryState["RETRY_STATE_NON_RETRYABLE_FAILURE"] = 2] = "RETRY_STATE_NON_RETRYABLE_FAILURE";
|
|
25
|
+
RetryState[RetryState["RETRY_STATE_TIMEOUT"] = 3] = "RETRY_STATE_TIMEOUT";
|
|
26
|
+
RetryState[RetryState["RETRY_STATE_MAXIMUM_ATTEMPTS_REACHED"] = 4] = "RETRY_STATE_MAXIMUM_ATTEMPTS_REACHED";
|
|
27
|
+
RetryState[RetryState["RETRY_STATE_RETRY_POLICY_NOT_SET"] = 5] = "RETRY_STATE_RETRY_POLICY_NOT_SET";
|
|
28
|
+
RetryState[RetryState["RETRY_STATE_INTERNAL_SERVER_ERROR"] = 6] = "RETRY_STATE_INTERNAL_SERVER_ERROR";
|
|
29
|
+
RetryState[RetryState["RETRY_STATE_CANCEL_REQUESTED"] = 7] = "RETRY_STATE_CANCEL_REQUESTED";
|
|
30
|
+
})(RetryState = exports.RetryState || (exports.RetryState = {}));
|
|
31
|
+
(0, type_helpers_1.checkExtends)();
|
|
9
32
|
/**
|
|
10
33
|
* Represents failures that can cross Workflow and Activity boundaries.
|
|
11
34
|
*
|
|
@@ -77,7 +100,7 @@ class ApplicationFailure extends TemporalFailure {
|
|
|
77
100
|
* as arguments and results.
|
|
78
101
|
*/
|
|
79
102
|
static retryable(message, type, ...details) {
|
|
80
|
-
return new this(message, type, false, details);
|
|
103
|
+
return new this(message, type ?? 'Error', false, details);
|
|
81
104
|
}
|
|
82
105
|
/**
|
|
83
106
|
* New ApplicationFailure with {@link nonRetryable} flag set to true.
|
|
@@ -91,7 +114,7 @@ class ApplicationFailure extends TemporalFailure {
|
|
|
91
114
|
* as arguments and results.
|
|
92
115
|
*/
|
|
93
116
|
static nonRetryable(message, type, ...details) {
|
|
94
|
-
return new this(message, type, true, details);
|
|
117
|
+
return new this(message, type ?? 'Error', true, details);
|
|
95
118
|
}
|
|
96
119
|
}
|
|
97
120
|
exports.ApplicationFailure = ApplicationFailure;
|
|
@@ -172,7 +195,7 @@ exports.optionalErrorToOptionalFailure = optionalErrorToOptionalFailure;
|
|
|
172
195
|
*/
|
|
173
196
|
const CUTTOFF_STACK_PATTERNS = [
|
|
174
197
|
/** Activity execution */
|
|
175
|
-
/\s+at Activity\.execute \(
|
|
198
|
+
/\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,
|
|
176
199
|
/** Workflow activation */
|
|
177
200
|
/\s+at Activator\.\S+NextHandler \(webpack-internal:\/\/\/.*\/internals\.[jt]s:\d+:\d+\)/,
|
|
178
201
|
];
|
|
@@ -327,7 +350,7 @@ async function failureToErrorInner(failure, dataConverter) {
|
|
|
327
350
|
return new ServerFailure(failure.message ?? undefined, Boolean(failure.serverFailureInfo.nonRetryable), await optionalFailureToOptionalError(failure.cause, dataConverter));
|
|
328
351
|
}
|
|
329
352
|
if (failure.timeoutFailureInfo) {
|
|
330
|
-
return new TimeoutFailure(failure.message ?? undefined, await dataConverter.fromPayloads(0, failure.timeoutFailureInfo.lastHeartbeatDetails?.payloads), failure.timeoutFailureInfo.timeoutType ??
|
|
353
|
+
return new TimeoutFailure(failure.message ?? undefined, await dataConverter.fromPayloads(0, failure.timeoutFailureInfo.lastHeartbeatDetails?.payloads), failure.timeoutFailureInfo.timeoutType ?? TimeoutType.TIMEOUT_TYPE_UNSPECIFIED);
|
|
331
354
|
}
|
|
332
355
|
if (failure.terminatedFailureInfo) {
|
|
333
356
|
return new TerminatedFailure(failure.message ?? undefined, await optionalFailureToOptionalError(failure.cause, dataConverter));
|
|
@@ -343,13 +366,13 @@ async function failureToErrorInner(failure, dataConverter) {
|
|
|
343
366
|
if (!(workflowType?.name && workflowExecution)) {
|
|
344
367
|
throw new TypeError('Missing attributes on childWorkflowExecutionFailureInfo');
|
|
345
368
|
}
|
|
346
|
-
return new ChildWorkflowFailure(namespace ?? undefined, workflowExecution, workflowType.name, retryState ??
|
|
369
|
+
return new ChildWorkflowFailure(namespace ?? undefined, workflowExecution, workflowType.name, retryState ?? RetryState.RETRY_STATE_UNSPECIFIED, await optionalFailureToOptionalError(failure.cause, dataConverter));
|
|
347
370
|
}
|
|
348
371
|
if (failure.activityFailureInfo) {
|
|
349
372
|
if (!failure.activityFailureInfo.activityType?.name) {
|
|
350
373
|
throw new TypeError('Missing activityType?.name on activityFailureInfo');
|
|
351
374
|
}
|
|
352
|
-
return new ActivityFailure(failure.activityFailureInfo.activityType.name, failure.activityFailureInfo.activityId ?? undefined, failure.activityFailureInfo.retryState ??
|
|
375
|
+
return new ActivityFailure(failure.activityFailureInfo.activityType.name, failure.activityFailureInfo.activityId ?? undefined, failure.activityFailureInfo.retryState ?? RetryState.RETRY_STATE_UNSPECIFIED, failure.activityFailureInfo.identity ?? undefined, await optionalFailureToOptionalError(failure.cause, dataConverter));
|
|
353
376
|
}
|
|
354
377
|
return new TemporalFailure(failure.message ?? undefined, await optionalFailureToOptionalError(failure.cause, dataConverter));
|
|
355
378
|
}
|