@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.
- package/README.md +5 -11
- package/lib/converter/data-converter.d.ts +34 -62
- package/lib/converter/data-converter.js +0 -101
- package/lib/converter/data-converter.js.map +1 -1
- package/lib/{encoding.d.ts → converter/encoding.d.ts} +0 -0
- package/lib/{encoding.js → converter/encoding.js} +0 -0
- package/lib/converter/encoding.js.map +1 -0
- package/lib/converter/patch-protobuf-root.d.ts +8 -0
- package/lib/converter/patch-protobuf-root.js +43 -0
- package/lib/converter/patch-protobuf-root.js.map +1 -0
- package/lib/converter/payload-codec.d.ts +27 -0
- package/lib/converter/payload-codec.js +11 -0
- package/lib/converter/payload-codec.js.map +1 -0
- package/lib/converter/payload-converter.d.ts +63 -62
- package/lib/converter/payload-converter.js +113 -68
- package/lib/converter/payload-converter.js.map +1 -1
- package/lib/converter/payload-converters.d.ts +31 -0
- package/lib/converter/payload-converters.js +85 -0
- package/lib/converter/payload-converters.js.map +1 -0
- package/lib/converter/protobuf-payload-converters.d.ts +53 -0
- package/lib/converter/protobuf-payload-converters.js +159 -0
- package/lib/converter/protobuf-payload-converters.js.map +1 -0
- package/lib/converter/types.d.ts +2 -0
- package/lib/converter/types.js +3 -2
- package/lib/converter/types.js.map +1 -1
- package/lib/failure.d.ts +6 -6
- package/lib/failure.js +37 -35
- package/lib/failure.js.map +1 -1
- package/lib/index.d.ts +9 -11
- package/lib/index.js +12 -16
- package/lib/index.js.map +1 -1
- package/lib/protobufs.d.ts +13 -0
- package/lib/protobufs.js +31 -0
- package/lib/protobufs.js.map +1 -0
- package/package.json +11 -8
- package/src/converter/data-converter.ts +35 -176
- package/src/{encoding.ts → converter/encoding.ts} +0 -0
- package/src/converter/patch-protobuf-root.ts +49 -0
- package/src/converter/payload-codec.ts +30 -0
- package/src/converter/payload-converter.ts +122 -102
- package/src/converter/payload-converters.ts +89 -0
- package/src/converter/protobuf-payload-converters.ts +192 -0
- package/src/converter/types.ts +4 -1
- package/src/failure.ts +44 -43
- package/src/index.ts +9 -11
- package/src/protobufs.ts +15 -0
- package/tsconfig.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/activity-options.d.ts +0 -81
- package/lib/activity-options.js +0 -14
- package/lib/activity-options.js.map +0 -1
- package/lib/encoding.js.map +0 -1
- package/lib/errors.d.ts +0 -16
- package/lib/errors.js +0 -41
- package/lib/errors.js.map +0 -1
- package/lib/interceptors.d.ts +0 -18
- package/lib/interceptors.js +0 -24
- package/lib/interceptors.js.map +0 -1
- package/lib/interfaces.d.ts +0 -31
- package/lib/interfaces.js +0 -3
- package/lib/interfaces.js.map +0 -1
- package/lib/otel.d.ts +0 -26
- package/lib/otel.js +0 -82
- package/lib/otel.js.map +0 -1
- package/lib/retry-policy.d.ts +0 -43
- package/lib/retry-policy.js +0 -36
- package/lib/retry-policy.js.map +0 -1
- package/lib/time.d.ts +0 -16
- package/lib/time.js +0 -73
- package/lib/time.js.map +0 -1
- package/lib/tls-config.d.ts +0 -32
- package/lib/tls-config.js +0 -11
- package/lib/tls-config.js.map +0 -1
- package/lib/type-helpers.d.ts +0 -8
- package/lib/type-helpers.js +0 -9
- package/lib/type-helpers.js.map +0 -1
- package/lib/utils.d.ts +0 -4
- package/lib/utils.js +0 -11
- package/lib/utils.js.map +0 -1
- package/lib/workflow-handle.d.ts +0 -27
- package/lib/workflow-handle.js +0 -3
- package/lib/workflow-handle.js.map +0 -1
- package/lib/workflow-options.d.ts +0 -91
- package/lib/workflow-options.js +0 -26
- package/lib/workflow-options.js.map +0 -1
- package/src/activity-options.ts +0 -97
- package/src/errors.ts +0 -27
- package/src/interceptors.ts +0 -32
- package/src/interfaces.ts +0 -37
- package/src/otel.ts +0 -61
- package/src/retry-policy.ts +0 -73
- package/src/time.ts +0 -72
- package/src/tls-config.ts +0 -35
- package/src/type-helpers.ts +0 -11
- package/src/utils.ts +0 -6
- package/src/workflow-handle.ts +0 -30
- package/src/workflow-options.ts +0 -127
package/README.md
CHANGED
|
@@ -2,16 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@temporalio/common)
|
|
4
4
|
|
|
5
|
-
Part of
|
|
5
|
+
Part of [Temporal](https://temporal.io)'s TypeScript SDK (see [docs](https://docs.temporal.io/docs/typescript/introduction/) and [samples](https://github.com/temporalio/samples-typescript)).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Common library for code that's used across the Client, Worker, and/or Workflow:
|
|
8
8
|
|
|
9
|
-
- https://
|
|
10
|
-
- https://
|
|
11
|
-
- https://typescript.temporal.io/api/namespaces/
|
|
12
|
-
- https://typescript.temporal.io/api/namespaces/workflow
|
|
13
|
-
|
|
14
|
-
More docs:
|
|
15
|
-
|
|
16
|
-
- See code samples [here](https://github.com/temporalio/samples-typescript)
|
|
17
|
-
- See full introduction on the [docs site](https://docs.temporal.io/docs/typescript/introduction)
|
|
9
|
+
- [DataConverter docs](https://docs.temporal.io/docs/typescript/data-converters)
|
|
10
|
+
- [Failure docs](https://docs.temporal.io/docs/typescript/handling-failure)
|
|
11
|
+
- [API reference](https://typescript.temporal.io/api/namespaces/common)
|
|
@@ -1,73 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PayloadCodec } from './payload-codec';
|
|
2
2
|
import { PayloadConverter } from './payload-converter';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* When your data (arguments and return values) is sent over the wire and stored by Temporal Server, it is encoded in
|
|
5
|
+
* binary in a {@link Payload} Protobuf message.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* The default `DataConverter` supports `Uint8Array`, and JSON serializables (so if
|
|
8
|
+
* [`JSON.stringify(yourArgOrRetval)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)
|
|
9
|
+
* works, the default data converter will work). Protobufs are supported via [this
|
|
10
|
+
* API](https://docs.temporal.io/docs/typescript/data-converters#protobufs).
|
|
11
|
+
*
|
|
12
|
+
* Use a custom `DataConverter` to control the contents of your {@link Payload}s. Common reasons for using a custom
|
|
13
|
+
* `DataConverter` are:
|
|
14
|
+
* - Converting values that are not supported by the default `DataConverter` (for example, `JSON.stringify()` doesn't
|
|
15
|
+
* handle `BigInt`s, so if you want to return `{ total: 1000n }` from a Workflow, Signal, or Activity, you need your
|
|
16
|
+
* own `DataConverter`).
|
|
17
|
+
* - Encrypting values that may contain private information that you don't want stored in plaintext in Temporal Server's
|
|
18
|
+
* database.
|
|
19
|
+
* - Compressing values to reduce disk or network usage.
|
|
20
|
+
*
|
|
21
|
+
* To use your custom `DataConverter`, provide it to the {@link WorkflowClient}, {@link Worker}, and
|
|
22
|
+
* {@link bundleWorkflowCode} (if you use it):
|
|
23
|
+
* - `new WorkflowClient({ ..., dataConverter })`
|
|
24
|
+
* - `Worker.create({ ..., dataConverter })`
|
|
25
|
+
* - `bundleWorkflowCode({ ..., payloadConverterPath })`
|
|
8
26
|
*/
|
|
9
27
|
export interface DataConverter {
|
|
10
|
-
toPayload<T>(value: T): Promise<Payload>;
|
|
11
|
-
fromPayload<T>(payload: Payload): Promise<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Implements conversion of a list of values.
|
|
14
|
-
*
|
|
15
|
-
* @param values JS values to convert to Payloads.
|
|
16
|
-
* @return converted value
|
|
17
|
-
* @throws DataConverterError if conversion of the value passed as parameter failed for any
|
|
18
|
-
* reason.
|
|
19
|
-
*/
|
|
20
|
-
toPayloads(...values: unknown[]): Promise<Payload[] | undefined>;
|
|
21
|
-
/**
|
|
22
|
-
* Implements conversion of an array of values of different types. Useful for deserializing
|
|
23
|
-
* arguments of function invocations.
|
|
24
|
-
*
|
|
25
|
-
* @param index index of the value in the payloads
|
|
26
|
-
* @param content serialized value to convert to JS values.
|
|
27
|
-
* @return converted JS value
|
|
28
|
-
* @throws DataConverterError if conversion of the data passed as parameter failed for any
|
|
29
|
-
* reason.
|
|
30
|
-
*/
|
|
31
|
-
fromPayloads<T>(index: number, content?: Payload[] | null): Promise<T>;
|
|
32
28
|
/**
|
|
33
|
-
*
|
|
29
|
+
* Path of a file that has a `payloadConverter` named export.
|
|
30
|
+
* `payloadConverter` should be an instance of a class that implements {@link PayloadConverter}.
|
|
31
|
+
* If no path is provided, {@link defaultPayloadConverter} is used.
|
|
34
32
|
*/
|
|
35
|
-
|
|
33
|
+
payloadConverterPath?: string;
|
|
36
34
|
/**
|
|
37
|
-
*
|
|
35
|
+
* A {@link PayloadCodec} instance. The default codec is a no-op.
|
|
38
36
|
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Sync conversion of all arguments, used in the Workflow runtime
|
|
42
|
-
*
|
|
43
|
-
* Implements conversion of a list of values.
|
|
44
|
-
*
|
|
45
|
-
* @param values JS values to convert to Payloads.
|
|
46
|
-
* @return converted value
|
|
47
|
-
* @throws DataConverterError if conversion of the value passed as parameter failed for any
|
|
48
|
-
* reason.
|
|
49
|
-
*/
|
|
50
|
-
toPayloadsSync(...values: unknown[]): Payload[] | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Sync version of {@link fromPayloads}
|
|
53
|
-
*/
|
|
54
|
-
fromPayloadsSync<T>(index: number, content?: Payload[] | null): T;
|
|
37
|
+
payloadCodec?: PayloadCodec;
|
|
55
38
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
fromPayload<T>(payload: Payload): Promise<T>;
|
|
63
|
-
fromPayloadSync<T>(payload: Payload): T;
|
|
64
|
-
toPayloads(...values: unknown[]): Promise<Payload[] | undefined>;
|
|
65
|
-
toPayloadsSync(...values: unknown[]): Payload[] | undefined;
|
|
66
|
-
fromPayloads<T>(index: number, payloads?: Payload[] | null): Promise<T>;
|
|
67
|
-
fromPayloadsSync<T>(index: number, payloads?: Payload[] | null): T;
|
|
39
|
+
/**
|
|
40
|
+
* A {@link DataConverter} that has been loaded via {@link loadDataConverter}.
|
|
41
|
+
*/
|
|
42
|
+
export interface LoadedDataConverter {
|
|
43
|
+
payloadConverter: PayloadConverter;
|
|
44
|
+
payloadCodec: PayloadCodec;
|
|
68
45
|
}
|
|
69
|
-
export declare function arrayFromPayloads(converter: DataConverter, content?: Payload[] | null): Promise<unknown[]>;
|
|
70
|
-
export declare function mapToPayloads<K extends string>(converter: DataConverter, source: Record<K, any>): Promise<Record<K, Payload>>;
|
|
71
|
-
export declare function arrayFromPayloadsSync(converter: DataConverter, content?: Payload[] | null): unknown[];
|
|
72
|
-
export declare function mapToPayloadsSync<K extends string>(converter: DataConverter, source: Record<K, any>): Record<K, Payload>;
|
|
73
|
-
export declare const defaultDataConverter: CompositeDataConverter;
|
|
@@ -1,104 +1,3 @@
|
|
|
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;
|
|
4
|
-
const errors_1 = require("../errors");
|
|
5
|
-
const types_1 = require("./types");
|
|
6
|
-
const payload_converter_1 = require("./payload-converter");
|
|
7
|
-
class CompositeDataConverter {
|
|
8
|
-
constructor(...converters) {
|
|
9
|
-
this.converterByEncoding = new Map();
|
|
10
|
-
this.converters = converters;
|
|
11
|
-
for (const converter of converters) {
|
|
12
|
-
this.converterByEncoding.set(converter.encodingType, converter);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async toPayload(value) {
|
|
16
|
-
for (const converter of this.converters) {
|
|
17
|
-
const result = await converter.toData(value);
|
|
18
|
-
if (result !== undefined)
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
throw new errors_1.ValueError(`Cannot serialize ${value}`);
|
|
22
|
-
}
|
|
23
|
-
toPayloadSync(value) {
|
|
24
|
-
for (const converter of this.converters) {
|
|
25
|
-
const result = converter.toDataSync(value);
|
|
26
|
-
if (result !== undefined)
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
throw new errors_1.ValueError(`Cannot serialize ${value}`);
|
|
30
|
-
}
|
|
31
|
-
async fromPayload(payload) {
|
|
32
|
-
if (payload.metadata === undefined || payload.metadata === null) {
|
|
33
|
-
throw new errors_1.ValueError('Missing payload metadata');
|
|
34
|
-
}
|
|
35
|
-
const encoding = (0, types_1.str)(payload.metadata[types_1.METADATA_ENCODING_KEY]);
|
|
36
|
-
const converter = this.converterByEncoding.get(encoding);
|
|
37
|
-
if (converter === undefined) {
|
|
38
|
-
throw new errors_1.ValueError(`Unknown encoding: ${encoding}`);
|
|
39
|
-
}
|
|
40
|
-
return await converter.fromData(payload);
|
|
41
|
-
}
|
|
42
|
-
fromPayloadSync(payload) {
|
|
43
|
-
if (payload.metadata === undefined || payload.metadata === null) {
|
|
44
|
-
throw new errors_1.ValueError('Missing payload metadata');
|
|
45
|
-
}
|
|
46
|
-
const encoding = (0, types_1.str)(payload.metadata[types_1.METADATA_ENCODING_KEY]);
|
|
47
|
-
const converter = this.converterByEncoding.get(encoding);
|
|
48
|
-
if (converter === undefined) {
|
|
49
|
-
throw new errors_1.ValueError(`Unknown encoding: ${encoding}`);
|
|
50
|
-
}
|
|
51
|
-
return converter.fromDataSync(payload);
|
|
52
|
-
}
|
|
53
|
-
async toPayloads(...values) {
|
|
54
|
-
if (values.length === 0) {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
return await Promise.all(values.map((value) => this.toPayload(value)));
|
|
58
|
-
}
|
|
59
|
-
toPayloadsSync(...values) {
|
|
60
|
-
if (values.length === 0) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
return values.map((value) => this.toPayloadSync(value));
|
|
64
|
-
}
|
|
65
|
-
async fromPayloads(index, payloads) {
|
|
66
|
-
// To make adding arguments a backwards compatible change
|
|
67
|
-
if (payloads === undefined || payloads === null || index >= payloads.length) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
return await this.fromPayload(payloads[index]);
|
|
71
|
-
}
|
|
72
|
-
fromPayloadsSync(index, payloads) {
|
|
73
|
-
// To make adding arguments a backwards compatible change
|
|
74
|
-
if (payloads === undefined || payloads === null || index >= payloads.length) {
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
return this.fromPayloadSync(payloads[index]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.CompositeDataConverter = CompositeDataConverter;
|
|
81
|
-
async function arrayFromPayloads(converter, content) {
|
|
82
|
-
if (!content) {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
return await Promise.all(content.map((payload) => converter.fromPayload(payload)));
|
|
86
|
-
}
|
|
87
|
-
exports.arrayFromPayloads = arrayFromPayloads;
|
|
88
|
-
async function mapToPayloads(converter, source) {
|
|
89
|
-
return Object.fromEntries(await Promise.all(Object.entries(source).map(async ([k, v]) => [k, await converter.toPayload(v)])));
|
|
90
|
-
}
|
|
91
|
-
exports.mapToPayloads = mapToPayloads;
|
|
92
|
-
function arrayFromPayloadsSync(converter, content) {
|
|
93
|
-
if (!content) {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
return content.map((payload) => converter.fromPayloadSync(payload));
|
|
97
|
-
}
|
|
98
|
-
exports.arrayFromPayloadsSync = arrayFromPayloadsSync;
|
|
99
|
-
function mapToPayloadsSync(converter, source) {
|
|
100
|
-
return Object.fromEntries(Object.entries(source).map(([k, v]) => [k, converter.toPayloadSync(v)]));
|
|
101
|
-
}
|
|
102
|
-
exports.mapToPayloadsSync = mapToPayloadsSync;
|
|
103
|
-
exports.defaultDataConverter = new CompositeDataConverter(new payload_converter_1.UndefinedPayloadConverter(), new payload_converter_1.BinaryPayloadConverter(), new payload_converter_1.JsonPayloadConverter());
|
|
104
3
|
//# sourceMappingURL=data-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-converter.js","sourceRoot":"","sources":["../../src/converter/data-converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-converter.js","sourceRoot":"","sources":["../../src/converter/data-converter.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/converter/encoding.ts"],"names":[],"mappings":";AAAA,mJAAmJ;AACnJ,8BAA8B;;;AAE9B,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AACzC,MAAM,aAAa,GAAG,6DAA6D,CAAC;AACpF,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;AAEzC,MAAa,WAAW;IACtB,MAAM,CAAC,kBAAgE;QACrE,MAAM,QAAQ,GAAG,kBAAkB,YAAY,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAEpH,IAAI,eAAe,GAAG,EAAE,EACtB,MAAM,GAAG,EAAE,EACX,KAAK,GAAG,CAAC,EACT,OAAO,GAAG,CAAC,EACX,GAAG,GAAG,CAAC,EACP,SAAS,GAAG,CAAC,EACb,OAAO,GAAG,CAAC,EACX,GAAG,GAAG,CAAC,EACP,GAAG,GAAG,CAAC,EACP,GAAG,GAAG,CAAC,CAAC,CAAC;QACX,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM,UAAU,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAClC,2GAA2G;QAC3G,OAAO,KAAK,GAAG,GAAG,GAAI;YACpB,OAAO,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACvD,OAAO,GAAG,GAAG,OAAO,EAAE,KAAK,GA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AW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,CAAC;CACF;AAhHD,kCAgHC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a version of `root` with non-nested namespaces to match the generated types.
|
|
3
|
+
* For more information, see:
|
|
4
|
+
* https://github.com/temporalio/sdk-typescript/blob/main/docs/protobuf-libraries.md#current-solution
|
|
5
|
+
* @param root Generated by `pbjs -t json-module -w commonjs -o json-module.js *.proto`
|
|
6
|
+
* @returns A new patched `root`
|
|
7
|
+
*/
|
|
8
|
+
export declare function patchProtobufRoot<T extends Record<string, unknown>>(root: T): T;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patchProtobufRoot = void 0;
|
|
4
|
+
const internal_workflow_common_1 = require("@temporalio/internal-workflow-common");
|
|
5
|
+
/**
|
|
6
|
+
* Create a version of `root` with non-nested namespaces to match the generated types.
|
|
7
|
+
* For more information, see:
|
|
8
|
+
* https://github.com/temporalio/sdk-typescript/blob/main/docs/protobuf-libraries.md#current-solution
|
|
9
|
+
* @param root Generated by `pbjs -t json-module -w commonjs -o json-module.js *.proto`
|
|
10
|
+
* @returns A new patched `root`
|
|
11
|
+
*/
|
|
12
|
+
function patchProtobufRoot(root) {
|
|
13
|
+
return _patchProtobufRoot(root);
|
|
14
|
+
}
|
|
15
|
+
exports.patchProtobufRoot = patchProtobufRoot;
|
|
16
|
+
function _patchProtobufRoot(root, name) {
|
|
17
|
+
const newRoot = new root.constructor(isNamespace(root) ? name : {});
|
|
18
|
+
for (const key in root) {
|
|
19
|
+
newRoot[key] = root[key];
|
|
20
|
+
}
|
|
21
|
+
if ((0, internal_workflow_common_1.isRecord)(root.nested)) {
|
|
22
|
+
for (const typeOrNamespace in root.nested) {
|
|
23
|
+
const value = root.nested[typeOrNamespace];
|
|
24
|
+
if (typeOrNamespace in root && !(isType(root[typeOrNamespace]) || isNamespace(root[typeOrNamespace]))) {
|
|
25
|
+
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.`);
|
|
26
|
+
}
|
|
27
|
+
if (isNamespace(value)) {
|
|
28
|
+
newRoot[typeOrNamespace] = _patchProtobufRoot(value, typeOrNamespace);
|
|
29
|
+
}
|
|
30
|
+
else if (isType(value)) {
|
|
31
|
+
newRoot[typeOrNamespace] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return newRoot;
|
|
36
|
+
}
|
|
37
|
+
function isType(value) {
|
|
38
|
+
return (0, internal_workflow_common_1.isRecord)(value) && value.constructor.name === 'Type';
|
|
39
|
+
}
|
|
40
|
+
function isNamespace(value) {
|
|
41
|
+
return (0, internal_workflow_common_1.isRecord)(value) && value.constructor.name === 'Namespace';
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=patch-protobuf-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-protobuf-root.js","sourceRoot":"","sources":["../../src/converter/patch-protobuf-root.ts"],"names":[],"mappings":";;;AAAA,mFAAgE;AAEhE;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAoC,IAAO;IAC1E,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAFD,8CAEC;AAED,SAAS,kBAAkB,CAAoC,IAAO,EAAE,IAAa;IACnF,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,mCAAQ,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,kBAAkB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;aACvE;iBAAM,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;gBACxB,OAAO,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC;aAClC;SACF;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAKD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,IAAA,mCAAQ,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,CAAC;AAC9D,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,IAAA,mCAAQ,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,WAAW,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Payload } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* `PayloadCodec` is an optional step that happens between the wire and the {@link PayloadConverter}:
|
|
4
|
+
*
|
|
5
|
+
* Temporal Server <--> Wire <--> `PayloadCodec` <--> `PayloadConverter` <--> User code
|
|
6
|
+
*
|
|
7
|
+
* Implement this to transform an array of {@link Payload}s to/from the format sent over the wire and stored by Temporal Server.
|
|
8
|
+
* Common transformations are encryption and compression.
|
|
9
|
+
*/
|
|
10
|
+
export interface PayloadCodec {
|
|
11
|
+
/**
|
|
12
|
+
* Encode an array of {@link Payload}s for sending over the wire.
|
|
13
|
+
* @param payloads May have length 0.
|
|
14
|
+
*/
|
|
15
|
+
encode(payloads: Payload[]): Promise<Payload[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Decode an array of {@link Payload}s received from the wire.
|
|
18
|
+
*/
|
|
19
|
+
decode(payloads: Payload[]): Promise<Payload[]>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* No-op implementation of {@link PayloadCodec}.
|
|
23
|
+
*/
|
|
24
|
+
export declare const defaultPayloadCodec: {
|
|
25
|
+
encode: (payloads: Payload[]) => Promise<Payload[]>;
|
|
26
|
+
decode: (payloads: Payload[]) => Promise<Payload[]>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultPayloadCodec = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* No-op implementation of {@link PayloadCodec}.
|
|
6
|
+
*/
|
|
7
|
+
exports.defaultPayloadCodec = {
|
|
8
|
+
encode: async (payloads) => payloads,
|
|
9
|
+
decode: async (payloads) => payloads,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=payload-codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload-codec.js","sourceRoot":"","sources":["../../src/converter/payload-codec.ts"],"names":[],"mappings":";;;AAuBA;;GAEG;AACU,QAAA,mBAAmB,GAAG;IACjC,MAAM,EAAE,KAAK,EAAE,QAAmB,EAAsB,EAAE,CAAC,QAAQ;IACnE,MAAM,EAAE,KAAK,EAAE,QAAmB,EAAsB,EAAE,CAAC,QAAQ;CACpE,CAAC"}
|
|
@@ -1,84 +1,85 @@
|
|
|
1
|
+
import { PayloadConverterWithEncoding } from './payload-converters';
|
|
1
2
|
import { Payload } from './types';
|
|
2
3
|
/**
|
|
3
|
-
* Used by the framework to serialize/deserialize
|
|
4
|
-
* wire.
|
|
4
|
+
* Used by the framework to serialize/deserialize parameters and return values.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* This is called inside the [Workflow isolate](https://docs.temporal.io/docs/typescript/determinism).
|
|
7
|
+
* To write async code or use Node APIs (or use packages that use Node APIs), use a {@link PayloadCodec}.
|
|
7
8
|
*/
|
|
8
9
|
export interface PayloadConverter {
|
|
9
|
-
encodingType: string;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param value JS value to convert.
|
|
15
|
-
* @return converted value
|
|
16
|
-
* @throws DataConverterException if conversion of the value passed as parameter failed for any
|
|
17
|
-
* reason.
|
|
11
|
+
* Converts a value to a {@link Payload}.
|
|
12
|
+
* @param value The value to convert. Example values include the Workflow args sent by the client and the values returned by a Workflow or Activity.
|
|
18
13
|
*/
|
|
19
|
-
|
|
14
|
+
toPayload<T>(value: T): Payload | undefined;
|
|
20
15
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @param content Serialized value to convert to a JS value.
|
|
24
|
-
* @return converted JS value
|
|
25
|
-
* @throws DataConverterException if conversion of the data passed as parameter failed for any
|
|
26
|
-
* reason.
|
|
16
|
+
* Converts a {@link Payload} back to a value.
|
|
27
17
|
*/
|
|
28
|
-
|
|
18
|
+
fromPayload<T>(payload: Payload): T;
|
|
19
|
+
}
|
|
20
|
+
export declare class CompositePayloadConverter implements PayloadConverter {
|
|
21
|
+
readonly converters: PayloadConverterWithEncoding[];
|
|
22
|
+
readonly converterByEncoding: Map<string, PayloadConverterWithEncoding>;
|
|
23
|
+
constructor(...converters: PayloadConverterWithEncoding[]);
|
|
29
24
|
/**
|
|
30
|
-
*
|
|
31
|
-
* the
|
|
25
|
+
* Tries to run `.toPayload(value)` on each converter in the order provided at construction.
|
|
26
|
+
* Returns the first successful result, or `undefined` if there is no converter that can handle the value.
|
|
32
27
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param value JS value to convert.
|
|
36
|
-
* @return converted value
|
|
37
|
-
* @throws DataConverterException if conversion of the value passed as parameter failed for any
|
|
38
|
-
* reason.
|
|
28
|
+
* @throws UnsupportedJsonTypeError
|
|
39
29
|
*/
|
|
40
|
-
|
|
30
|
+
toPayload<T>(value: T): Payload | undefined;
|
|
41
31
|
/**
|
|
42
|
-
*
|
|
43
|
-
* the async version limits the functionality of the runtime.
|
|
44
|
-
*
|
|
45
|
-
* Implements conversion of payload to value.
|
|
46
|
-
*
|
|
47
|
-
* @param content Serialized value to convert to a JS value.
|
|
48
|
-
* @return converted JS value
|
|
49
|
-
* @throws DataConverterException if conversion of the data passed as parameter failed for any
|
|
50
|
-
* reason.
|
|
32
|
+
* Run {@link PayloadConverterWithEncoding.fromPayload} based on the {@link encodingTypes | encoding type} of the {@link Payload}.
|
|
51
33
|
*/
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
export declare abstract class AsyncFacadePayloadConverter implements PayloadConverter {
|
|
55
|
-
abstract encodingType: string;
|
|
56
|
-
abstract toDataSync(value: unknown): Payload | undefined;
|
|
57
|
-
abstract fromDataSync<T>(content: Payload): T;
|
|
58
|
-
toData(value: unknown): Promise<Payload | undefined>;
|
|
59
|
-
fromData<T>(content: Payload): Promise<T>;
|
|
34
|
+
fromPayload<T>(payload: Payload): T;
|
|
60
35
|
}
|
|
61
36
|
/**
|
|
62
|
-
*
|
|
37
|
+
* Tries to convert `value` to a {@link Payload}. Throws if conversion fails.
|
|
38
|
+
*
|
|
39
|
+
* @throws {@link PayloadConverterError}
|
|
63
40
|
*/
|
|
64
|
-
export declare
|
|
65
|
-
encodingType: "binary/null";
|
|
66
|
-
toDataSync(value: unknown): Payload | undefined;
|
|
67
|
-
fromDataSync<T>(_content: Payload): T;
|
|
68
|
-
}
|
|
41
|
+
export declare function toPayload(converter: PayloadConverter, value: unknown): Payload;
|
|
69
42
|
/**
|
|
70
|
-
*
|
|
43
|
+
* Implements conversion of a list of values.
|
|
44
|
+
*
|
|
45
|
+
* @param converter
|
|
46
|
+
* @param values JS values to convert to Payloads
|
|
47
|
+
* @return converted values
|
|
48
|
+
* @throws PayloadConverterError if conversion of the value passed as parameter failed for any
|
|
49
|
+
* reason.
|
|
71
50
|
*/
|
|
72
|
-
export declare
|
|
73
|
-
encodingType: "json/plain";
|
|
74
|
-
toDataSync(value: unknown): Payload | undefined;
|
|
75
|
-
fromDataSync<T>(content: Payload): T;
|
|
76
|
-
}
|
|
51
|
+
export declare function toPayloads(converter: PayloadConverter, ...values: unknown[]): Payload[] | undefined;
|
|
77
52
|
/**
|
|
78
|
-
*
|
|
53
|
+
* Run {@link PayloadConverter.toPayload} on each value in the map.
|
|
54
|
+
*
|
|
55
|
+
* @throws {@link PayloadConverterError} if conversion of any value in the map fails
|
|
56
|
+
*/
|
|
57
|
+
export declare function mapToPayloads<K extends string>(converter: PayloadConverter, map: Record<K, any>): Record<K, Payload>;
|
|
58
|
+
/**
|
|
59
|
+
* Implements conversion of an array of values of different types. Useful for deserializing
|
|
60
|
+
* arguments of function invocations.
|
|
61
|
+
*
|
|
62
|
+
* @param converter
|
|
63
|
+
* @param index index of the value in the payloads
|
|
64
|
+
* @param payloads serialized value to convert to JS values.
|
|
65
|
+
* @return converted JS value
|
|
66
|
+
* @throws {@link PayloadConverterError} if conversion of the data passed as parameter failed for any
|
|
67
|
+
* reason.
|
|
68
|
+
*/
|
|
69
|
+
export declare function fromPayloadsAtIndex<T>(converter: PayloadConverter, index: number, payloads?: Payload[] | null): T;
|
|
70
|
+
/**
|
|
71
|
+
* Run {@link PayloadConverter.fromPayload} on each value in the array.
|
|
79
72
|
*/
|
|
80
|
-
export declare
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
fromDataSync<T>(content: Payload): T;
|
|
73
|
+
export declare function arrayFromPayloads(converter: PayloadConverter, payloads?: Payload[] | null): unknown[];
|
|
74
|
+
export declare class DefaultPayloadConverter extends CompositePayloadConverter {
|
|
75
|
+
constructor();
|
|
84
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The default {@link PayloadConverter} used by the SDK.
|
|
79
|
+
* Supports `Uint8Array` and JSON serializables (so if [`JSON.stringify(yourArgOrRetval)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description) works, the default payload converter will work).
|
|
80
|
+
*
|
|
81
|
+
* To also support Protobufs, create a custom payload converter with {@link DefaultPayloadConverter}:
|
|
82
|
+
*
|
|
83
|
+
* `const myConverter = new DefaultPayloadConverter({ protobufRoot })`
|
|
84
|
+
*/
|
|
85
|
+
export declare const defaultPayloadConverter: DefaultPayloadConverter;
|