@temporalio/common 1.1.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/activity-options.d.ts +138 -0
- package/lib/activity-options.js +15 -0
- package/lib/activity-options.js.map +1 -0
- package/lib/converter/data-converter.d.ts +20 -1
- package/lib/converter/data-converter.js +14 -3
- package/lib/converter/data-converter.js.map +1 -1
- package/lib/converter/failure-converter.d.ts +75 -0
- package/lib/converter/failure-converter.js +239 -0
- package/lib/converter/failure-converter.js.map +1 -0
- package/lib/converter/payload-codec.d.ts +1 -1
- package/lib/converter/payload-converter.d.ts +85 -1
- package/lib/converter/payload-converter.js +210 -1
- package/lib/converter/payload-converter.js.map +1 -1
- package/lib/converter/protobuf-payload-converters.d.ts +3 -3
- package/lib/converter/protobuf-payload-converters.js +20 -19
- package/lib/converter/protobuf-payload-converters.js.map +1 -1
- package/lib/converter/types.d.ts +0 -6
- package/lib/converter/types.js +7 -18
- package/lib/converter/types.js.map +1 -1
- package/lib/deprecated-time.d.ts +52 -0
- package/lib/deprecated-time.js +106 -0
- package/lib/deprecated-time.js.map +1 -0
- package/lib/{converter/encoding.d.ts → encoding.d.ts} +8 -0
- package/lib/{converter/encoding.js → encoding.js} +15 -1
- package/lib/encoding.js.map +1 -0
- package/lib/errors.d.ts +47 -0
- package/lib/errors.js +68 -0
- package/lib/errors.js.map +1 -0
- package/lib/failure.d.ts +0 -27
- package/lib/failure.js +9 -203
- package/lib/failure.js.map +1 -1
- package/lib/index.d.ts +25 -8
- package/lib/index.js +43 -7
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +18 -0
- package/lib/interceptors.js +24 -0
- package/lib/interceptors.js.map +1 -0
- package/lib/interfaces.d.ts +52 -0
- package/lib/interfaces.js +3 -0
- package/lib/interfaces.js.map +1 -0
- package/lib/internal-non-workflow/codec-helpers.d.ts +82 -0
- package/lib/internal-non-workflow/codec-helpers.js +295 -0
- package/lib/internal-non-workflow/codec-helpers.js.map +1 -0
- package/lib/internal-non-workflow/codec-types.d.ts +22 -0
- package/lib/internal-non-workflow/codec-types.js +3 -0
- package/lib/internal-non-workflow/codec-types.js.map +1 -0
- package/lib/internal-non-workflow/data-converter-helpers.d.ts +11 -0
- package/lib/internal-non-workflow/data-converter-helpers.js +66 -0
- package/lib/internal-non-workflow/data-converter-helpers.js.map +1 -0
- package/lib/internal-non-workflow/index.d.ts +10 -0
- package/lib/internal-non-workflow/index.js +27 -0
- package/lib/internal-non-workflow/index.js.map +1 -0
- package/lib/internal-non-workflow/tls-config.d.ts +32 -0
- package/lib/internal-non-workflow/tls-config.js +11 -0
- package/lib/internal-non-workflow/tls-config.js.map +1 -0
- package/lib/internal-non-workflow/utils.d.ts +4 -0
- package/lib/internal-non-workflow/utils.js +11 -0
- package/lib/internal-non-workflow/utils.js.map +1 -0
- package/lib/otel.d.ts +1 -1
- package/lib/otel.js +2 -2
- package/lib/otel.js.map +1 -1
- package/lib/retry-policy.d.ts +48 -0
- package/lib/retry-policy.js +62 -0
- package/lib/retry-policy.js.map +1 -0
- package/lib/time.d.ts +18 -0
- package/lib/time.js +79 -0
- package/lib/time.js.map +1 -0
- package/lib/type-helpers.d.ts +21 -0
- package/lib/type-helpers.js +46 -0
- package/lib/type-helpers.js.map +1 -0
- package/lib/workflow-handle.d.ts +27 -0
- package/lib/workflow-handle.js +3 -0
- package/lib/workflow-handle.js.map +1 -0
- package/lib/workflow-options.d.ts +118 -0
- package/lib/workflow-options.js +53 -0
- package/lib/workflow-options.js.map +1 -0
- package/package.json +5 -4
- package/src/activity-options.ts +159 -0
- package/src/converter/data-converter.ts +24 -3
- package/src/converter/failure-converter.ts +355 -0
- package/src/converter/payload-codec.ts +1 -1
- package/src/converter/payload-converter.ts +246 -1
- package/src/converter/protobuf-payload-converters.ts +14 -25
- package/src/converter/types.ts +6 -19
- package/src/deprecated-time.ts +80 -0
- package/src/{converter/encoding.ts → encoding.ts} +14 -0
- package/src/errors.ts +55 -0
- package/src/failure.ts +3 -251
- package/src/index.ts +34 -8
- package/src/interceptors.ts +32 -0
- package/src/interfaces.ts +64 -0
- package/src/internal-non-workflow/codec-helpers.ts +348 -0
- package/src/internal-non-workflow/codec-types.ts +34 -0
- package/src/internal-non-workflow/data-converter-helpers.ts +81 -0
- package/src/internal-non-workflow/index.ts +10 -0
- package/src/internal-non-workflow/tls-config.ts +35 -0
- package/src/internal-non-workflow/utils.ts +6 -0
- package/src/otel.ts +2 -2
- package/src/retry-policy.ts +101 -0
- package/src/time.ts +79 -0
- package/src/type-helpers.ts +64 -0
- package/src/workflow-handle.ts +30 -0
- package/src/workflow-options.ts +156 -0
- package/lib/converter/encoding.js.map +0 -1
- package/lib/converter/json-payload-converter.d.ts +0 -10
- package/lib/converter/json-payload-converter.js +0 -39
- package/lib/converter/json-payload-converter.js.map +0 -1
- package/lib/converter/payload-converters.d.ts +0 -67
- package/lib/converter/payload-converters.js +0 -124
- package/lib/converter/payload-converters.js.map +0 -1
- package/lib/converter/search-attribute-payload-converter.d.ts +0 -12
- package/lib/converter/search-attribute-payload-converter.js +0 -64
- package/lib/converter/search-attribute-payload-converter.js.map +0 -1
- package/src/converter/json-payload-converter.ts +0 -37
- package/src/converter/payload-converters.ts +0 -148
- package/src/converter/search-attribute-payload-converter.ts +0 -71
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { temporal } from '@temporalio/proto';
|
|
2
|
+
export declare type Payload = temporal.api.common.v1.IPayload;
|
|
3
|
+
/** Type that can be returned from a Workflow `execute` function */
|
|
4
|
+
export declare type WorkflowReturnType = Promise<any>;
|
|
5
|
+
export declare type WorkflowSignalType = (...args: any[]) => Promise<void> | void;
|
|
6
|
+
export declare type WorkflowQueryType = (...args: any[]) => any;
|
|
7
|
+
/**
|
|
8
|
+
* Broad Workflow function definition, specific Workflows will typically use a narrower type definition, e.g:
|
|
9
|
+
* ```ts
|
|
10
|
+
* export async function myWorkflow(arg1: number, arg2: string): Promise<string>;
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare type Workflow = (...args: any[]) => WorkflowReturnType;
|
|
14
|
+
/**
|
|
15
|
+
* An interface representing a Workflow signal definition, as returned from {@link defineSignal}
|
|
16
|
+
*
|
|
17
|
+
* @remarks `_Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
|
|
18
|
+
*/
|
|
19
|
+
export interface SignalDefinition<_Args extends any[] = []> {
|
|
20
|
+
type: 'signal';
|
|
21
|
+
name: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An interface representing a Workflow query definition as returned from {@link defineQuery}
|
|
25
|
+
*
|
|
26
|
+
* @remarks `_Args` and `_Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
|
|
27
|
+
*/
|
|
28
|
+
export interface QueryDefinition<_Ret, _Args extends any[] = []> {
|
|
29
|
+
type: 'query';
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
/** Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type `W` */
|
|
33
|
+
export declare type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promise<infer R> ? R : never;
|
|
34
|
+
/**
|
|
35
|
+
* If another SDK creates a Search Attribute that's not an array, we wrap it in an array.
|
|
36
|
+
*
|
|
37
|
+
* Dates are serialized as ISO strings.
|
|
38
|
+
*/
|
|
39
|
+
export declare type SearchAttributes = Record<string, SearchAttributeValue | undefined>;
|
|
40
|
+
export declare type SearchAttributeValue = string[] | number[] | boolean[] | Date[];
|
|
41
|
+
export interface ActivityFunction<P extends any[] = any[], R = any> {
|
|
42
|
+
(...args: P): Promise<R>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Mapping of Activity name to function
|
|
46
|
+
* @deprecated not required anymore, for untyped activities use {@link UntypedActivities}
|
|
47
|
+
*/
|
|
48
|
+
export declare type ActivityInterface = Record<string, ActivityFunction>;
|
|
49
|
+
/**
|
|
50
|
+
* Mapping of Activity name to function
|
|
51
|
+
*/
|
|
52
|
+
export declare type UntypedActivities = Record<string, ActivityFunction>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Payload } from '../interfaces';
|
|
2
|
+
import { PayloadCodec } from '../converter/payload-codec';
|
|
3
|
+
import { ProtoFailure, TemporalFailure } from '../failure';
|
|
4
|
+
import { LoadedDataConverter } from '../converter/data-converter';
|
|
5
|
+
import { DecodedPayload, DecodedProtoFailure, EncodedPayload, EncodedProtoFailure } from './codec-types';
|
|
6
|
+
/**
|
|
7
|
+
* Decode through each codec, starting with the last codec.
|
|
8
|
+
*/
|
|
9
|
+
export declare function decode(codecs: PayloadCodec[], payloads: Payload[]): Promise<DecodedPayload[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Encode through each codec, starting with the first codec.
|
|
12
|
+
*/
|
|
13
|
+
export declare function encode(codecs: PayloadCodec[], payloads: Payload[]): Promise<EncodedPayload[]>;
|
|
14
|
+
/** Run {@link PayloadCodec.encode} on `payloads` */
|
|
15
|
+
export declare function encodeOptional(codecs: PayloadCodec[], payloads: Payload[] | null | undefined): Promise<EncodedPayload[] | null | undefined>;
|
|
16
|
+
/** Run {@link PayloadCodec.decode} on `payloads` */
|
|
17
|
+
export declare function decodeOptional(codecs: PayloadCodec[], payloads: Payload[] | null | undefined): Promise<DecodedPayload[] | null | undefined>;
|
|
18
|
+
/** Run {@link PayloadCodec.encode} on a single Payload */
|
|
19
|
+
export declare function encodeOptionalSingle(codecs: PayloadCodec[], payload: Payload | null | undefined): Promise<EncodedPayload | null | undefined>;
|
|
20
|
+
/** Run {@link PayloadCodec.decode} on a single Payload */
|
|
21
|
+
export declare function decodeOptionalSingle(codecs: PayloadCodec[], payload: Payload | null | undefined): Promise<DecodedPayload | null | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Run {@link PayloadConverter.toPayload} on value, and then encode it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function encodeToPayload(converter: LoadedDataConverter, value: unknown): Promise<Payload>;
|
|
26
|
+
/**
|
|
27
|
+
* Decode `payloads` and then return {@link arrayFromPayloads}`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function decodeArrayFromPayloads(converter: LoadedDataConverter, payloads?: Payload[] | null): Promise<unknown[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Decode `payloads` and then return {@link fromPayloadsAtIndex}.
|
|
32
|
+
*/
|
|
33
|
+
export declare function decodeFromPayloadsAtIndex<T>(converter: LoadedDataConverter, index: number, payloads?: Payload[] | null): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Run {@link decodeFailure} and then return {@link failureToError}.
|
|
36
|
+
*/
|
|
37
|
+
export declare function decodeOptionalFailureToOptionalError(converter: LoadedDataConverter, failure: ProtoFailure | undefined | null): Promise<TemporalFailure | undefined>;
|
|
38
|
+
export declare function decodeOptionalMap(codecs: PayloadCodec[], payloads: Record<string, Payload> | null | undefined): Promise<Record<string, DecodedPayload> | null | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Run {@link PayloadConverter.toPayload} on values, and then encode them.
|
|
41
|
+
*/
|
|
42
|
+
export declare function encodeToPayloads(converter: LoadedDataConverter, ...values: unknown[]): Promise<Payload[] | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Run {@link PayloadCodec.decode} and then {@link PayloadConverter.fromPayload} on values in `map`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function decodeMapFromPayloads<K extends string>(converter: LoadedDataConverter, map: Record<K, Payload> | null | undefined): Promise<Record<K, unknown> | undefined>;
|
|
47
|
+
/** Run {@link PayloadCodec.encode} on all values in `map` */
|
|
48
|
+
export declare function encodeMap<K extends string>(codecs: PayloadCodec[], map: Record<K, Payload> | null | undefined): Promise<Record<K, EncodedPayload> | null | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Run {@link PayloadConverter.toPayload} and then {@link PayloadCodec.encode} on values in `map`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function encodeMapToPayloads<K extends string>(converter: LoadedDataConverter, map: Record<K, unknown>): Promise<Record<K, Payload>>;
|
|
53
|
+
/**
|
|
54
|
+
* Run {@link errorToFailure} on `error`, and then {@link encodeFailure}.
|
|
55
|
+
*/
|
|
56
|
+
export declare function encodeErrorToFailure(dataConverter: LoadedDataConverter, error: unknown): Promise<ProtoFailure>;
|
|
57
|
+
/**
|
|
58
|
+
* Return a new {@link ProtoFailure} with `codec.encode()` run on all the {@link Payload}s.
|
|
59
|
+
*/
|
|
60
|
+
export declare function encodeFailure(codecs: PayloadCodec[], failure: ProtoFailure): Promise<EncodedProtoFailure>;
|
|
61
|
+
/**
|
|
62
|
+
* Return a new {@link ProtoFailure} with `codec.decode()` run on all the {@link Payload}s.
|
|
63
|
+
*/
|
|
64
|
+
export declare function decodeFailure(codecs: PayloadCodec[], failure: ProtoFailure): Promise<DecodedProtoFailure>;
|
|
65
|
+
/**
|
|
66
|
+
* Return a new {@link ProtoFailure} with `codec.encode()` run on all the {@link Payload}s.
|
|
67
|
+
*/
|
|
68
|
+
export declare function encodeOptionalFailure(codecs: PayloadCodec[], failure: ProtoFailure | null | undefined): Promise<EncodedProtoFailure | null | undefined>;
|
|
69
|
+
/**
|
|
70
|
+
* Return a new {@link ProtoFailure} with `codec.encode()` run on all the {@link Payload}s.
|
|
71
|
+
*/
|
|
72
|
+
export declare function decodeOptionalFailure(codecs: PayloadCodec[], failure: ProtoFailure | null | undefined): Promise<DecodedProtoFailure | null | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Mark all values in the map as encoded.
|
|
75
|
+
* Use this for headers, which we don't encode.
|
|
76
|
+
*/
|
|
77
|
+
export declare function noopEncodeMap<K extends string>(map: Record<K, Payload> | null | undefined): Record<K, EncodedPayload> | null | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Mark all values in the map as decoded.
|
|
80
|
+
* Use this for headers, which we don't encode.
|
|
81
|
+
*/
|
|
82
|
+
export declare function noopDecodeMap<K extends string>(map: Record<K, Payload> | null | undefined): Record<K, DecodedPayload> | null | undefined;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noopDecodeMap = exports.noopEncodeMap = exports.decodeOptionalFailure = exports.encodeOptionalFailure = exports.decodeFailure = exports.encodeFailure = exports.encodeErrorToFailure = exports.encodeMapToPayloads = exports.encodeMap = exports.decodeMapFromPayloads = exports.encodeToPayloads = exports.decodeOptionalMap = exports.decodeOptionalFailureToOptionalError = exports.decodeFromPayloadsAtIndex = exports.decodeArrayFromPayloads = exports.encodeToPayload = exports.decodeOptionalSingle = exports.encodeOptionalSingle = exports.decodeOptional = exports.encodeOptional = exports.encode = exports.decode = void 0;
|
|
4
|
+
const payload_converter_1 = require("../converter/payload-converter");
|
|
5
|
+
const errors_1 = require("../errors");
|
|
6
|
+
/**
|
|
7
|
+
* Decode through each codec, starting with the last codec.
|
|
8
|
+
*/
|
|
9
|
+
async function decode(codecs, payloads) {
|
|
10
|
+
for (let i = codecs.length - 1; i >= 0; i--) {
|
|
11
|
+
payloads = await codecs[i].decode(payloads);
|
|
12
|
+
}
|
|
13
|
+
return payloads;
|
|
14
|
+
}
|
|
15
|
+
exports.decode = decode;
|
|
16
|
+
/**
|
|
17
|
+
* Encode through each codec, starting with the first codec.
|
|
18
|
+
*/
|
|
19
|
+
async function encode(codecs, payloads) {
|
|
20
|
+
for (let i = 0; i < codecs.length; i++) {
|
|
21
|
+
payloads = await codecs[i].encode(payloads);
|
|
22
|
+
}
|
|
23
|
+
return payloads;
|
|
24
|
+
}
|
|
25
|
+
exports.encode = encode;
|
|
26
|
+
/** Run {@link PayloadCodec.encode} on `payloads` */
|
|
27
|
+
async function encodeOptional(codecs, payloads) {
|
|
28
|
+
if (payloads == null)
|
|
29
|
+
return payloads;
|
|
30
|
+
return await encode(codecs, payloads);
|
|
31
|
+
}
|
|
32
|
+
exports.encodeOptional = encodeOptional;
|
|
33
|
+
/** Run {@link PayloadCodec.decode} on `payloads` */
|
|
34
|
+
async function decodeOptional(codecs, payloads) {
|
|
35
|
+
if (payloads == null)
|
|
36
|
+
return payloads;
|
|
37
|
+
return await decode(codecs, payloads);
|
|
38
|
+
}
|
|
39
|
+
exports.decodeOptional = decodeOptional;
|
|
40
|
+
async function encodeSingle(codecs, payload) {
|
|
41
|
+
const encodedPayloads = await encode(codecs, [payload]);
|
|
42
|
+
return encodedPayloads[0];
|
|
43
|
+
}
|
|
44
|
+
async function decodeSingle(codecs, payload) {
|
|
45
|
+
const [decodedPayload] = await decode(codecs, [payload]);
|
|
46
|
+
return decodedPayload;
|
|
47
|
+
}
|
|
48
|
+
/** Run {@link PayloadCodec.encode} on a single Payload */
|
|
49
|
+
async function encodeOptionalSingle(codecs, payload) {
|
|
50
|
+
if (payload == null)
|
|
51
|
+
return payload;
|
|
52
|
+
return await encodeSingle(codecs, payload);
|
|
53
|
+
}
|
|
54
|
+
exports.encodeOptionalSingle = encodeOptionalSingle;
|
|
55
|
+
/** Run {@link PayloadCodec.decode} on a single Payload */
|
|
56
|
+
async function decodeOptionalSingle(codecs, payload) {
|
|
57
|
+
if (payload == null)
|
|
58
|
+
return payload;
|
|
59
|
+
return await decodeSingle(codecs, payload);
|
|
60
|
+
}
|
|
61
|
+
exports.decodeOptionalSingle = decodeOptionalSingle;
|
|
62
|
+
/**
|
|
63
|
+
* Run {@link PayloadConverter.toPayload} on value, and then encode it.
|
|
64
|
+
*/
|
|
65
|
+
async function encodeToPayload(converter, value) {
|
|
66
|
+
const { payloadConverter, payloadCodecs } = converter;
|
|
67
|
+
return await encodeSingle(payloadCodecs, payloadConverter.toPayload(value));
|
|
68
|
+
}
|
|
69
|
+
exports.encodeToPayload = encodeToPayload;
|
|
70
|
+
/**
|
|
71
|
+
* Decode `payloads` and then return {@link arrayFromPayloads}`.
|
|
72
|
+
*/
|
|
73
|
+
async function decodeArrayFromPayloads(converter, payloads) {
|
|
74
|
+
const { payloadConverter, payloadCodecs } = converter;
|
|
75
|
+
return (0, payload_converter_1.arrayFromPayloads)(payloadConverter, await decodeOptional(payloadCodecs, payloads));
|
|
76
|
+
}
|
|
77
|
+
exports.decodeArrayFromPayloads = decodeArrayFromPayloads;
|
|
78
|
+
/**
|
|
79
|
+
* Decode `payloads` and then return {@link fromPayloadsAtIndex}.
|
|
80
|
+
*/
|
|
81
|
+
async function decodeFromPayloadsAtIndex(converter, index, payloads) {
|
|
82
|
+
const { payloadConverter, payloadCodecs } = converter;
|
|
83
|
+
return await (0, payload_converter_1.fromPayloadsAtIndex)(payloadConverter, index, await decodeOptional(payloadCodecs, payloads));
|
|
84
|
+
}
|
|
85
|
+
exports.decodeFromPayloadsAtIndex = decodeFromPayloadsAtIndex;
|
|
86
|
+
/**
|
|
87
|
+
* Run {@link decodeFailure} and then return {@link failureToError}.
|
|
88
|
+
*/
|
|
89
|
+
async function decodeOptionalFailureToOptionalError(converter, failure) {
|
|
90
|
+
const { failureConverter, payloadCodecs } = converter;
|
|
91
|
+
return failure ? failureConverter.failureToError(await decodeFailure(payloadCodecs, failure)) : undefined;
|
|
92
|
+
}
|
|
93
|
+
exports.decodeOptionalFailureToOptionalError = decodeOptionalFailureToOptionalError;
|
|
94
|
+
async function decodeOptionalMap(codecs, payloads) {
|
|
95
|
+
if (payloads == null)
|
|
96
|
+
return payloads;
|
|
97
|
+
return Object.fromEntries(await Promise.all(Object.entries(payloads).map(async ([k, v]) => [k, await decode(codecs, [v])])));
|
|
98
|
+
}
|
|
99
|
+
exports.decodeOptionalMap = decodeOptionalMap;
|
|
100
|
+
/**
|
|
101
|
+
* Run {@link PayloadConverter.toPayload} on values, and then encode them.
|
|
102
|
+
*/
|
|
103
|
+
async function encodeToPayloads(converter, ...values) {
|
|
104
|
+
const { payloadConverter, payloadCodecs } = converter;
|
|
105
|
+
if (values.length === 0) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
const payloads = (0, payload_converter_1.toPayloads)(payloadConverter, ...values);
|
|
109
|
+
return payloads ? await encode(payloadCodecs, payloads) : undefined;
|
|
110
|
+
}
|
|
111
|
+
exports.encodeToPayloads = encodeToPayloads;
|
|
112
|
+
/**
|
|
113
|
+
* Run {@link PayloadCodec.decode} and then {@link PayloadConverter.fromPayload} on values in `map`.
|
|
114
|
+
*/
|
|
115
|
+
async function decodeMapFromPayloads(converter, map) {
|
|
116
|
+
if (!map)
|
|
117
|
+
return undefined;
|
|
118
|
+
const { payloadConverter, payloadCodecs } = converter;
|
|
119
|
+
return Object.fromEntries(await Promise.all(Object.entries(map).map(async ([k, payload]) => {
|
|
120
|
+
const [decodedPayload] = await decode(payloadCodecs, [payload]);
|
|
121
|
+
const value = payloadConverter.fromPayload(decodedPayload);
|
|
122
|
+
return [k, value];
|
|
123
|
+
})));
|
|
124
|
+
}
|
|
125
|
+
exports.decodeMapFromPayloads = decodeMapFromPayloads;
|
|
126
|
+
/** Run {@link PayloadCodec.encode} on all values in `map` */
|
|
127
|
+
async function encodeMap(codecs, map) {
|
|
128
|
+
if (map === null)
|
|
129
|
+
return null;
|
|
130
|
+
if (map === undefined)
|
|
131
|
+
return undefined;
|
|
132
|
+
return Object.fromEntries(await Promise.all(Object.entries(map).map(async ([k, payload]) => {
|
|
133
|
+
return [k, await encodeSingle(codecs, payload)];
|
|
134
|
+
})));
|
|
135
|
+
}
|
|
136
|
+
exports.encodeMap = encodeMap;
|
|
137
|
+
/**
|
|
138
|
+
* Run {@link PayloadConverter.toPayload} and then {@link PayloadCodec.encode} on values in `map`.
|
|
139
|
+
*/
|
|
140
|
+
async function encodeMapToPayloads(converter, map) {
|
|
141
|
+
const { payloadConverter, payloadCodecs } = converter;
|
|
142
|
+
return Object.fromEntries(await Promise.all(Object.entries(map).map(async ([k, v]) => {
|
|
143
|
+
const payload = payloadConverter.toPayload(v);
|
|
144
|
+
if (payload === undefined)
|
|
145
|
+
throw new errors_1.PayloadConverterError(`Failed to encode entry: ${k}: ${v}`);
|
|
146
|
+
const [encodedPayload] = await encode(payloadCodecs, [payload]);
|
|
147
|
+
return [k, encodedPayload];
|
|
148
|
+
})));
|
|
149
|
+
}
|
|
150
|
+
exports.encodeMapToPayloads = encodeMapToPayloads;
|
|
151
|
+
/**
|
|
152
|
+
* Run {@link errorToFailure} on `error`, and then {@link encodeFailure}.
|
|
153
|
+
*/
|
|
154
|
+
async function encodeErrorToFailure(dataConverter, error) {
|
|
155
|
+
const { failureConverter, payloadCodecs } = dataConverter;
|
|
156
|
+
return await encodeFailure(payloadCodecs, failureConverter.errorToFailure(error));
|
|
157
|
+
}
|
|
158
|
+
exports.encodeErrorToFailure = encodeErrorToFailure;
|
|
159
|
+
/**
|
|
160
|
+
* Return a new {@link ProtoFailure} with `codec.encode()` run on all the {@link Payload}s.
|
|
161
|
+
*/
|
|
162
|
+
async function encodeFailure(codecs, failure) {
|
|
163
|
+
return {
|
|
164
|
+
...failure,
|
|
165
|
+
encodedAttributes: failure.encodedAttributes ? (await encode(codecs, [failure.encodedAttributes]))[0] : undefined,
|
|
166
|
+
cause: failure.cause ? await encodeFailure(codecs, failure.cause) : null,
|
|
167
|
+
applicationFailureInfo: failure.applicationFailureInfo
|
|
168
|
+
? {
|
|
169
|
+
...failure.applicationFailureInfo,
|
|
170
|
+
details: failure.applicationFailureInfo.details
|
|
171
|
+
? {
|
|
172
|
+
payloads: await encode(codecs, failure.applicationFailureInfo.details.payloads ?? []),
|
|
173
|
+
}
|
|
174
|
+
: undefined,
|
|
175
|
+
}
|
|
176
|
+
: undefined,
|
|
177
|
+
timeoutFailureInfo: failure.timeoutFailureInfo
|
|
178
|
+
? {
|
|
179
|
+
...failure.timeoutFailureInfo,
|
|
180
|
+
lastHeartbeatDetails: failure.timeoutFailureInfo.lastHeartbeatDetails
|
|
181
|
+
? {
|
|
182
|
+
payloads: await encode(codecs, failure.timeoutFailureInfo.lastHeartbeatDetails.payloads ?? []),
|
|
183
|
+
}
|
|
184
|
+
: undefined,
|
|
185
|
+
}
|
|
186
|
+
: undefined,
|
|
187
|
+
canceledFailureInfo: failure.canceledFailureInfo
|
|
188
|
+
? {
|
|
189
|
+
...failure.canceledFailureInfo,
|
|
190
|
+
details: failure.canceledFailureInfo.details
|
|
191
|
+
? {
|
|
192
|
+
payloads: await encode(codecs, failure.canceledFailureInfo.details.payloads ?? []),
|
|
193
|
+
}
|
|
194
|
+
: undefined,
|
|
195
|
+
}
|
|
196
|
+
: undefined,
|
|
197
|
+
resetWorkflowFailureInfo: failure.resetWorkflowFailureInfo
|
|
198
|
+
? {
|
|
199
|
+
...failure.resetWorkflowFailureInfo,
|
|
200
|
+
lastHeartbeatDetails: failure.resetWorkflowFailureInfo.lastHeartbeatDetails
|
|
201
|
+
? {
|
|
202
|
+
payloads: await encode(codecs, failure.resetWorkflowFailureInfo.lastHeartbeatDetails.payloads ?? []),
|
|
203
|
+
}
|
|
204
|
+
: undefined,
|
|
205
|
+
}
|
|
206
|
+
: undefined,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
exports.encodeFailure = encodeFailure;
|
|
210
|
+
/**
|
|
211
|
+
* Return a new {@link ProtoFailure} with `codec.decode()` run on all the {@link Payload}s.
|
|
212
|
+
*/
|
|
213
|
+
async function decodeFailure(codecs, failure) {
|
|
214
|
+
return {
|
|
215
|
+
...failure,
|
|
216
|
+
encodedAttributes: failure.encodedAttributes ? (await decode(codecs, [failure.encodedAttributes]))[0] : undefined,
|
|
217
|
+
cause: failure.cause ? await decodeFailure(codecs, failure.cause) : null,
|
|
218
|
+
applicationFailureInfo: failure.applicationFailureInfo
|
|
219
|
+
? {
|
|
220
|
+
...failure.applicationFailureInfo,
|
|
221
|
+
details: failure.applicationFailureInfo.details
|
|
222
|
+
? {
|
|
223
|
+
payloads: await decode(codecs, failure.applicationFailureInfo.details.payloads ?? []),
|
|
224
|
+
}
|
|
225
|
+
: undefined,
|
|
226
|
+
}
|
|
227
|
+
: undefined,
|
|
228
|
+
timeoutFailureInfo: failure.timeoutFailureInfo
|
|
229
|
+
? {
|
|
230
|
+
...failure.timeoutFailureInfo,
|
|
231
|
+
lastHeartbeatDetails: failure.timeoutFailureInfo.lastHeartbeatDetails
|
|
232
|
+
? {
|
|
233
|
+
payloads: await decode(codecs, failure.timeoutFailureInfo.lastHeartbeatDetails.payloads ?? []),
|
|
234
|
+
}
|
|
235
|
+
: undefined,
|
|
236
|
+
}
|
|
237
|
+
: undefined,
|
|
238
|
+
canceledFailureInfo: failure.canceledFailureInfo
|
|
239
|
+
? {
|
|
240
|
+
...failure.canceledFailureInfo,
|
|
241
|
+
details: failure.canceledFailureInfo.details
|
|
242
|
+
? {
|
|
243
|
+
payloads: await decode(codecs, failure.canceledFailureInfo.details.payloads ?? []),
|
|
244
|
+
}
|
|
245
|
+
: undefined,
|
|
246
|
+
}
|
|
247
|
+
: undefined,
|
|
248
|
+
resetWorkflowFailureInfo: failure.resetWorkflowFailureInfo
|
|
249
|
+
? {
|
|
250
|
+
...failure.resetWorkflowFailureInfo,
|
|
251
|
+
lastHeartbeatDetails: failure.resetWorkflowFailureInfo.lastHeartbeatDetails
|
|
252
|
+
? {
|
|
253
|
+
payloads: await decode(codecs, failure.resetWorkflowFailureInfo.lastHeartbeatDetails.payloads ?? []),
|
|
254
|
+
}
|
|
255
|
+
: undefined,
|
|
256
|
+
}
|
|
257
|
+
: undefined,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
exports.decodeFailure = decodeFailure;
|
|
261
|
+
/**
|
|
262
|
+
* Return a new {@link ProtoFailure} with `codec.encode()` run on all the {@link Payload}s.
|
|
263
|
+
*/
|
|
264
|
+
async function encodeOptionalFailure(codecs, failure) {
|
|
265
|
+
if (failure == null)
|
|
266
|
+
return failure;
|
|
267
|
+
return await encodeFailure(codecs, failure);
|
|
268
|
+
}
|
|
269
|
+
exports.encodeOptionalFailure = encodeOptionalFailure;
|
|
270
|
+
/**
|
|
271
|
+
* Return a new {@link ProtoFailure} with `codec.encode()` run on all the {@link Payload}s.
|
|
272
|
+
*/
|
|
273
|
+
async function decodeOptionalFailure(codecs, failure) {
|
|
274
|
+
if (failure == null)
|
|
275
|
+
return failure;
|
|
276
|
+
return await decodeFailure(codecs, failure);
|
|
277
|
+
}
|
|
278
|
+
exports.decodeOptionalFailure = decodeOptionalFailure;
|
|
279
|
+
/**
|
|
280
|
+
* Mark all values in the map as encoded.
|
|
281
|
+
* Use this for headers, which we don't encode.
|
|
282
|
+
*/
|
|
283
|
+
function noopEncodeMap(map) {
|
|
284
|
+
return map;
|
|
285
|
+
}
|
|
286
|
+
exports.noopEncodeMap = noopEncodeMap;
|
|
287
|
+
/**
|
|
288
|
+
* Mark all values in the map as decoded.
|
|
289
|
+
* Use this for headers, which we don't encode.
|
|
290
|
+
*/
|
|
291
|
+
function noopDecodeMap(map) {
|
|
292
|
+
return map;
|
|
293
|
+
}
|
|
294
|
+
exports.noopDecodeMap = noopDecodeMap;
|
|
295
|
+
//# sourceMappingURL=codec-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-helpers.js","sourceRoot":"","sources":["../../src/internal-non-workflow/codec-helpers.ts"],"names":[],"mappings":";;;AACA,sEAAoG;AACpG,sCAAkD;AAMlD;;GAEG;AACI,KAAK,UAAU,MAAM,CAAC,MAAsB,EAAE,QAAmB;IACtE,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3C,QAAQ,GAAG,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAC7C;IACD,OAAO,QAA4B,CAAC;AACtC,CAAC;AALD,wBAKC;AAED;;GAEG;AACI,KAAK,UAAU,MAAM,CAAC,MAAsB,EAAE,QAAmB;IACtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,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,CAAC;gBACE,GAAG,OAAO,CAAC,wBAAwB;gBACnC,oBAAoB,EAAE,OAAO,CAAC,wBAAwB,CAAC,oBAAoB;oBACzE,CAAC,CAAC;wBACE,QAAQ,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,QAAQ,IAAI,EAAE,CAAC;qBACrG;oBACH,CAAC,CAAC,SAAS;aACd;YACH,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC;AA9CD,sCA8CC;AAED;;GAEG;AACI,KAAK,UAAU,qBAAqB,CACzC,MAAsB,EACtB,OAAwC;IAExC,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,OAAO,CAAC;IACpC,OAAO,MAAM,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAND,sDAMC;AAED;;GAEG;AACI,KAAK,UAAU,qBAAqB,CACzC,MAAsB,EACtB,OAAwC;IAExC,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,OAAO,CAAC;IACpC,OAAO,MAAM,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAND,sDAMC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAC3B,GAA0C;IAE1C,OAAO,GAAmD,CAAC;AAC7D,CAAC;AAJD,sCAIC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAC3B,GAA0C;IAE1C,OAAO,GAAmD,CAAC;AAC7D,CAAC;AAJD,sCAIC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Payload } from '../interfaces';
|
|
2
|
+
import type { ProtoFailure } from '../failure';
|
|
3
|
+
export interface EncodedPayload extends Payload {
|
|
4
|
+
encoded: true;
|
|
5
|
+
}
|
|
6
|
+
export interface DecodedPayload extends Payload {
|
|
7
|
+
decoded: true;
|
|
8
|
+
}
|
|
9
|
+
/** Replace `Payload`s with `EncodedPayload`s */
|
|
10
|
+
export declare type Encoded<T> = ReplaceNested<T, Payload, EncodedPayload>;
|
|
11
|
+
/** Replace `Payload`s with `DecodedPayload`s */
|
|
12
|
+
export declare type Decoded<T> = ReplaceNested<T, Payload, DecodedPayload>;
|
|
13
|
+
export declare type EncodedProtoFailure = Encoded<ProtoFailure>;
|
|
14
|
+
export declare type DecodedProtoFailure = Decoded<ProtoFailure>;
|
|
15
|
+
/** An object T with any nested values of type ToReplace replaced with ReplaceWith */
|
|
16
|
+
export declare type ReplaceNested<T, ToReplace, ReplaceWith> = T extends (...args: any[]) => any ? T : [keyof T] extends [never] ? T : T extends {
|
|
17
|
+
[k: string]: ToReplace;
|
|
18
|
+
} ? {
|
|
19
|
+
[P in keyof T]: ReplaceNested<T[P], ToReplace, ReplaceWith>;
|
|
20
|
+
} : T extends ToReplace ? ReplaceWith | Exclude<T, ToReplace> : {
|
|
21
|
+
[P in keyof T]: ReplaceNested<T[P], ToReplace, ReplaceWith>;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types.js","sourceRoot":"","sources":["../../src/internal-non-workflow/codec-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataConverter, LoadedDataConverter } from '../converter/data-converter';
|
|
2
|
+
/**
|
|
3
|
+
* If {@link DataConverter.payloadConverterPath} is specified, `require()` it and validate that the module has a `payloadConverter` named export.
|
|
4
|
+
* If not, use {@link defaultPayloadConverter}.
|
|
5
|
+
* If {@link DataConverter.payloadCodecs} is unspecified, use an empty array.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadDataConverter(dataConverter?: DataConverter): LoadedDataConverter;
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if the converter is already "loaded"
|
|
10
|
+
*/
|
|
11
|
+
export declare function isLoadedDataConverter(dataConverter?: DataConverter | LoadedDataConverter): dataConverter is LoadedDataConverter;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLoadedDataConverter = exports.loadDataConverter = void 0;
|
|
4
|
+
const data_converter_1 = require("../converter/data-converter");
|
|
5
|
+
const payload_converter_1 = require("../converter/payload-converter");
|
|
6
|
+
const type_helpers_1 = require("../type-helpers");
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
const isValidPayloadConverter = (converter) => typeof converter === 'object' &&
|
|
9
|
+
converter !== null &&
|
|
10
|
+
['toPayload', 'fromPayload'].every((method) => typeof converter[method] === 'function');
|
|
11
|
+
const isValidFailureConverter = (converter) => typeof converter === 'object' &&
|
|
12
|
+
converter !== null &&
|
|
13
|
+
['errorToFailure', 'failureToError'].every((method) => typeof converter[method] === 'function');
|
|
14
|
+
function requireConverter(path, type, validator) {
|
|
15
|
+
let module;
|
|
16
|
+
try {
|
|
17
|
+
module = require(path); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if ((0, type_helpers_1.errorCode)(error) === 'MODULE_NOT_FOUND') {
|
|
21
|
+
throw new errors_1.ValueError(`Could not find a file at the specified ${type}Path: '${path}'.`);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
if ((0, type_helpers_1.isRecord)(module) && (0, type_helpers_1.hasOwnProperty)(module, type)) {
|
|
26
|
+
const converter = module[type];
|
|
27
|
+
if (validator(converter)) {
|
|
28
|
+
return converter;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new errors_1.ValueError(`payloadConverter export at ${path} must be an object with toPayload and fromPayload methods`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new errors_1.ValueError(`Module ${path} does not have a \`payloadConverter\` named export`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* If {@link DataConverter.payloadConverterPath} is specified, `require()` it and validate that the module has a `payloadConverter` named export.
|
|
40
|
+
* If not, use {@link defaultPayloadConverter}.
|
|
41
|
+
* If {@link DataConverter.payloadCodecs} is unspecified, use an empty array.
|
|
42
|
+
*/
|
|
43
|
+
function loadDataConverter(dataConverter) {
|
|
44
|
+
let payloadConverter = payload_converter_1.defaultPayloadConverter;
|
|
45
|
+
if (dataConverter?.payloadConverterPath) {
|
|
46
|
+
payloadConverter = requireConverter(dataConverter.payloadConverterPath, 'payloadConverter', isValidPayloadConverter);
|
|
47
|
+
}
|
|
48
|
+
let failureConverter = data_converter_1.defaultFailureConverter;
|
|
49
|
+
if (dataConverter?.failureConverterPath) {
|
|
50
|
+
failureConverter = requireConverter(dataConverter.failureConverterPath, 'failureConverter', isValidFailureConverter);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
payloadConverter,
|
|
54
|
+
failureConverter,
|
|
55
|
+
payloadCodecs: dataConverter?.payloadCodecs ?? [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.loadDataConverter = loadDataConverter;
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if the converter is already "loaded"
|
|
61
|
+
*/
|
|
62
|
+
function isLoadedDataConverter(dataConverter) {
|
|
63
|
+
return (0, type_helpers_1.isRecord)(dataConverter) && (0, type_helpers_1.hasOwnProperty)(dataConverter, 'payloadConverter');
|
|
64
|
+
}
|
|
65
|
+
exports.isLoadedDataConverter = isLoadedDataConverter;
|
|
66
|
+
//# sourceMappingURL=data-converter-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-converter-helpers.js","sourceRoot":"","sources":["../../src/internal-non-workflow/data-converter-helpers.ts"],"names":[],"mappings":";;;AACA,gEAA0G;AAE1G,sEAAyE;AACzE,kDAAsE;AACtE,sCAAuC;AAEvC,MAAM,uBAAuB,GAAG,CAAC,SAAkB,EAAiC,EAAE,CACpF,OAAO,SAAS,KAAK,QAAQ;IAC7B,SAAS,KAAK,IAAI;IAClB,CAAC,WAAW,EAAE,aAAa,CAAC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BAAoB,EAAE;QACvC,gBAAgB,GAAG,gBAAgB,CACjC,aAAa,CAAC,oBAAoB,EAClC,kBAAkB,EAClB,uBAAuB,CACxB,CAAC;KACH;IACD,IAAI,gBAAgB,GAAqB,wCAAuB,CAAC;IACjE,IAAI,aAAa,EAAE,oBAAoB,EAAE;QACvC,gBAAgB,GAAG,gBAAgB,CACjC,aAAa,CAAC,oBAAoB,EAClC,kBAAkB,EAClB,uBAAuB,CACxB,CAAC;KACH;IACD,OAAO;QACL,gBAAgB;QAChB,gBAAgB;QAChB,aAAa,EAAE,aAAa,EAAE,aAAa,IAAI,EAAE;KAClD,CAAC;AACJ,CAAC;AAtBD,8CAsBC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACnC,aAAmD;IAEnD,OAAO,IAAA,uBAAQ,EAAC,aAAa,CAAC,IAAI,IAAA,6BAAc,EAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AACtF,CAAC;AAJD,sDAIC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal SDK library: users should usually use other packages instead. Not included in Workflow bundle.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
export * from './codec-helpers';
|
|
7
|
+
export * from './codec-types';
|
|
8
|
+
export * from './data-converter-helpers';
|
|
9
|
+
export * from './tls-config';
|
|
10
|
+
export * from './utils';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* Internal SDK library: users should usually use other packages instead. Not included in Workflow bundle.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./codec-helpers"), exports);
|
|
23
|
+
__exportStar(require("./codec-types"), exports);
|
|
24
|
+
__exportStar(require("./data-converter-helpers"), exports);
|
|
25
|
+
__exportStar(require("./tls-config"), exports);
|
|
26
|
+
__exportStar(require("./utils"), exports);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal-non-workflow/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,kDAAgC;AAChC,gDAA8B;AAC9B,2DAAyC;AACzC,+CAA6B;AAC7B,0CAAwB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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;
|