@temporalio/common 1.7.1 → 1.7.3
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/converter/types.d.ts +1 -1
- package/lib/failure.d.ts +2 -2
- package/lib/interceptors.d.ts +2 -2
- package/lib/interfaces.d.ts +10 -10
- package/lib/internal-non-workflow/codec-types.d.ts +5 -5
- package/lib/internal-non-workflow/tls-config.d.ts +1 -1
- package/lib/proto-utils.d.ts +2 -2
- package/lib/proto-utils.js +23 -1
- package/lib/proto-utils.js.map +1 -1
- package/lib/time.d.ts +1 -1
- package/lib/type-helpers.d.ts +4 -4
- package/lib/workflow-options.d.ts +3 -3
- package/package.json +4 -4
- package/src/converter/types.ts +1 -1
- package/src/proto-utils.ts +25 -1
package/lib/converter/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const encodingTypes: {
|
|
|
6
6
|
readonly METADATA_ENCODING_PROTOBUF_JSON: "json/protobuf";
|
|
7
7
|
readonly METADATA_ENCODING_PROTOBUF: "binary/protobuf";
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type EncodingType = (typeof encodingTypes)[keyof typeof encodingTypes];
|
|
10
10
|
export declare const encodingKeys: {
|
|
11
11
|
readonly METADATA_ENCODING_NULL: Uint8Array;
|
|
12
12
|
readonly METADATA_ENCODING_RAW: Uint8Array;
|
package/lib/failure.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { temporal } from '@temporalio/proto';
|
|
2
2
|
export declare const FAILURE_SOURCE = "TypeScriptSDK";
|
|
3
|
-
export
|
|
3
|
+
export type ProtoFailure = temporal.api.failure.v1.IFailure;
|
|
4
4
|
export declare enum TimeoutType {
|
|
5
5
|
TIMEOUT_TYPE_UNSPECIFIED = 0,
|
|
6
6
|
TIMEOUT_TYPE_START_TO_CLOSE = 1,
|
|
@@ -18,7 +18,7 @@ export declare enum RetryState {
|
|
|
18
18
|
RETRY_STATE_INTERNAL_SERVER_ERROR = 6,
|
|
19
19
|
RETRY_STATE_CANCEL_REQUESTED = 7
|
|
20
20
|
}
|
|
21
|
-
export
|
|
21
|
+
export type WorkflowExecution = temporal.api.common.v1.IWorkflowExecution;
|
|
22
22
|
/**
|
|
23
23
|
* Represents failures that can cross Workflow and Activity boundaries.
|
|
24
24
|
*
|
package/lib/interceptors.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { Payload } from './interfaces';
|
|
|
5
5
|
*
|
|
6
6
|
* Called from an interceptor to continue the interception chain
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type Next<IF, FN extends keyof IF> = Required<IF>[FN] extends AnyFunc ? OmitLastParam<Required<IF>[FN]> : never;
|
|
9
9
|
/** Headers are just a mapping of header name to Payload */
|
|
10
|
-
export
|
|
10
|
+
export type Headers = Record<string, Payload>;
|
|
11
11
|
/**
|
|
12
12
|
* Composes all interceptor methods into a single function
|
|
13
13
|
*
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { temporal } from '@temporalio/proto';
|
|
2
|
-
export
|
|
2
|
+
export type Payload = temporal.api.common.v1.IPayload;
|
|
3
3
|
/** Type that can be returned from a Workflow `execute` function */
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
4
|
+
export type WorkflowReturnType = Promise<any>;
|
|
5
|
+
export type WorkflowSignalType = (...args: any[]) => Promise<void> | void;
|
|
6
|
+
export type WorkflowQueryType = (...args: any[]) => any;
|
|
7
7
|
/**
|
|
8
8
|
* Broad Workflow function definition, specific Workflows will typically use a narrower type definition, e.g:
|
|
9
9
|
* ```ts
|
|
10
10
|
* export async function myWorkflow(arg1: number, arg2: string): Promise<string>;
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type Workflow = (...args: any[]) => WorkflowReturnType;
|
|
14
14
|
declare const argsBrand: unique symbol;
|
|
15
15
|
/**
|
|
16
16
|
* An interface representing a Workflow signal definition, as returned from {@link defineSignal}
|
|
@@ -49,14 +49,14 @@ export interface QueryDefinition<Ret, Args extends any[] = [], Name extends stri
|
|
|
49
49
|
[retBrand]: Ret;
|
|
50
50
|
}
|
|
51
51
|
/** Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type `W` */
|
|
52
|
-
export
|
|
52
|
+
export type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promise<infer R> ? R : never;
|
|
53
53
|
/**
|
|
54
54
|
* If another SDK creates a Search Attribute that's not an array, we wrap it in an array.
|
|
55
55
|
*
|
|
56
56
|
* Dates are serialized as ISO strings.
|
|
57
57
|
*/
|
|
58
|
-
export
|
|
59
|
-
export
|
|
58
|
+
export type SearchAttributes = Record<string, SearchAttributeValue | Readonly<SearchAttributeValue> | undefined>;
|
|
59
|
+
export type SearchAttributeValue = string[] | number[] | boolean[] | Date[];
|
|
60
60
|
export interface ActivityFunction<P extends any[] = any[], R = any> {
|
|
61
61
|
(...args: P): Promise<R>;
|
|
62
62
|
}
|
|
@@ -64,11 +64,11 @@ export interface ActivityFunction<P extends any[] = any[], R = any> {
|
|
|
64
64
|
* Mapping of Activity name to function
|
|
65
65
|
* @deprecated not required anymore, for untyped activities use {@link UntypedActivities}
|
|
66
66
|
*/
|
|
67
|
-
export
|
|
67
|
+
export type ActivityInterface = Record<string, ActivityFunction>;
|
|
68
68
|
/**
|
|
69
69
|
* Mapping of Activity name to function
|
|
70
70
|
*/
|
|
71
|
-
export
|
|
71
|
+
export type UntypedActivities = Record<string, ActivityFunction>;
|
|
72
72
|
/**
|
|
73
73
|
* A workflow's history and ID. Useful for replay.
|
|
74
74
|
*/
|
|
@@ -7,13 +7,13 @@ export interface DecodedPayload extends Payload {
|
|
|
7
7
|
decoded: true;
|
|
8
8
|
}
|
|
9
9
|
/** Replace `Payload`s with `EncodedPayload`s */
|
|
10
|
-
export
|
|
10
|
+
export type Encoded<T> = ReplaceNested<T, Payload, EncodedPayload>;
|
|
11
11
|
/** Replace `Payload`s with `DecodedPayload`s */
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export type Decoded<T> = ReplaceNested<T, Payload, DecodedPayload>;
|
|
13
|
+
export type EncodedProtoFailure = Encoded<ProtoFailure>;
|
|
14
|
+
export type DecodedProtoFailure = Decoded<ProtoFailure>;
|
|
15
15
|
/** An object T with any nested values of type ToReplace replaced with ReplaceWith */
|
|
16
|
-
export
|
|
16
|
+
export type ReplaceNested<T, ToReplace, ReplaceWith> = T extends (...args: any[]) => any ? T : [keyof T] extends [never] ? T : T extends {
|
|
17
17
|
[k: string]: ToReplace;
|
|
18
18
|
} ? {
|
|
19
19
|
[P in keyof T]: ReplaceNested<T[P], ToReplace, ReplaceWith>;
|
|
@@ -25,7 +25,7 @@ export interface TLSConfig {
|
|
|
25
25
|
* Pass a falsy value to use a non-encrypted connection or `true` or `{}` to
|
|
26
26
|
* connect with TLS without any customization.
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export type TLSConfigOption = TLSConfig | boolean | null;
|
|
29
29
|
/**
|
|
30
30
|
* Normalize {@link TLSConfigOption} by turning false and null to undefined and true to and empty object
|
|
31
31
|
*/
|
package/lib/proto-utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as proto from '@temporalio/proto';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type History = proto.temporal.api.history.v1.IHistory;
|
|
3
|
+
export type Payload = proto.temporal.api.common.v1.IPayload;
|
|
4
4
|
/**
|
|
5
5
|
* Convert a proto JSON representation of History to a valid History object
|
|
6
6
|
*/
|
package/lib/proto-utils.js
CHANGED
|
@@ -36,14 +36,36 @@ function pascalCaseToConstantCase(s) {
|
|
|
36
36
|
}
|
|
37
37
|
function fixEnumValue(obj, attr, prefix) {
|
|
38
38
|
return (obj[attr] && {
|
|
39
|
-
[attr]: `${prefix}_${pascalCaseToConstantCase(obj[attr])}`,
|
|
39
|
+
[attr]: obj[attr].startsWith(prefix) ? obj[attr] : `${prefix}_${pascalCaseToConstantCase(obj[attr])}`,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
+
// fromProto3JSON doesn't allow null values on 'bytes' fields. This turns out to be a problem for payloads.
|
|
43
|
+
// Recursively descend on objects and array, and fix in-place any payload that has a null data field
|
|
44
|
+
function fixPayloads(e) {
|
|
45
|
+
function isPayload(p) {
|
|
46
|
+
return p && typeof p === 'object' && 'metadata' in p && 'data' in p;
|
|
47
|
+
}
|
|
48
|
+
if (e && typeof e === 'object') {
|
|
49
|
+
if (isPayload(e)) {
|
|
50
|
+
if (e.data === null) {
|
|
51
|
+
const { data: _data, ...rest } = e;
|
|
52
|
+
return rest;
|
|
53
|
+
}
|
|
54
|
+
return e;
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(e))
|
|
57
|
+
return e.map(fixPayloads);
|
|
58
|
+
return Object.fromEntries(Object.entries(e).map(([k, v]) => [k, fixPayloads(v)]));
|
|
59
|
+
}
|
|
60
|
+
return e;
|
|
61
|
+
}
|
|
42
62
|
function fixHistoryEvent(e) {
|
|
43
63
|
const type = Object.keys(e).find((k) => k.endsWith('EventAttributes'));
|
|
44
64
|
if (!type) {
|
|
45
65
|
throw new TypeError(`Missing attributes in history event: ${JSON.stringify(e)}`);
|
|
46
66
|
}
|
|
67
|
+
// Fix payloads with null data
|
|
68
|
+
e = fixPayloads(e);
|
|
47
69
|
return {
|
|
48
70
|
...e,
|
|
49
71
|
...fixEnumValue(e, 'eventType', 'EVENT_TYPE'),
|
package/lib/proto-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proto-utils.js","sourceRoot":"","sources":["../src/proto-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAsE;AACtE,yDAA2C;AAC3C,mFAA8E;AAK9E,yFAAyF;AACzF,MAAM,OAAO,GAAG,IAAA,uCAAiB,EAAC,KAAK,CAAQ,CAA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|
|
4
4
|
* Lossy conversion function from Timestamp to number due to possible overflow.
|
|
5
5
|
* If ts is null or undefined returns undefined.
|
package/lib/type-helpers.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** Shorthand alias */
|
|
2
|
-
export
|
|
2
|
+
export type AnyFunc = (...args: any[]) => any;
|
|
3
3
|
/** A tuple without its last element */
|
|
4
|
-
export
|
|
4
|
+
export type OmitLast<T> = T extends [...infer REST, any] ? REST : never;
|
|
5
5
|
/** F with all arguments but the last */
|
|
6
|
-
export
|
|
6
|
+
export type OmitLastParam<F extends AnyFunc> = (...args: OmitLast<Parameters<F>>) => ReturnType<F>;
|
|
7
7
|
/** Verify that an type _Copy extends _Orig */
|
|
8
8
|
export declare function checkExtends<_Orig, _Copy extends _Orig>(): void;
|
|
9
|
-
export
|
|
9
|
+
export type Replace<Base, New> = Omit<Base, keyof New> & New;
|
|
10
10
|
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
11
11
|
export declare function hasOwnProperty<X extends Record<string, unknown>, Y extends PropertyKey>(record: X, prop: Y): record is X & Record<Y, unknown>;
|
|
12
12
|
export declare function hasOwnProperties<X extends Record<string, unknown>, Y extends PropertyKey>(record: X, props: Y[]): record is X & Record<Y, unknown>;
|
|
@@ -73,7 +73,7 @@ export interface BaseWorkflowOptions {
|
|
|
73
73
|
*/
|
|
74
74
|
searchAttributes?: SearchAttributes;
|
|
75
75
|
}
|
|
76
|
-
export
|
|
76
|
+
export type WithWorkflowArgs<W extends Workflow, T> = T & (Parameters<W> extends [any, ...any[]] ? {
|
|
77
77
|
/**
|
|
78
78
|
* Arguments to pass to the Workflow
|
|
79
79
|
*/
|
|
@@ -109,8 +109,8 @@ export interface WorkflowDurationOptions {
|
|
|
109
109
|
*/
|
|
110
110
|
workflowTaskTimeout?: string | number;
|
|
111
111
|
}
|
|
112
|
-
export
|
|
113
|
-
export
|
|
112
|
+
export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions;
|
|
113
|
+
export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<T, {
|
|
114
114
|
workflowExecutionTimeout?: google.protobuf.IDuration;
|
|
115
115
|
workflowRunTimeout?: google.protobuf.IDuration;
|
|
116
116
|
workflowTaskTimeout?: google.protobuf.IDuration;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/common",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "Common library for code that's used across the Client, Worker, and/or Workflow",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@opentelemetry/api": "^1.
|
|
16
|
-
"@temporalio/proto": "1.7.
|
|
15
|
+
"@opentelemetry/api": "^1.4.1",
|
|
16
|
+
"@temporalio/proto": "1.7.3",
|
|
17
17
|
"long": "^5.2.0",
|
|
18
18
|
"ms": "^2.1.3",
|
|
19
19
|
"proto3-json-serializer": "^1.0.3",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"src",
|
|
36
36
|
"lib"
|
|
37
37
|
],
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "c78237bad40342b97a0aaec97ef01763b39a04f8"
|
|
39
39
|
}
|
package/src/converter/types.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const encodingTypes = {
|
|
|
8
8
|
METADATA_ENCODING_PROTOBUF_JSON: 'json/protobuf',
|
|
9
9
|
METADATA_ENCODING_PROTOBUF: 'binary/protobuf',
|
|
10
10
|
} as const;
|
|
11
|
-
export type EncodingType = typeof encodingTypes[keyof typeof encodingTypes];
|
|
11
|
+
export type EncodingType = (typeof encodingTypes)[keyof typeof encodingTypes];
|
|
12
12
|
|
|
13
13
|
export const encodingKeys = {
|
|
14
14
|
METADATA_ENCODING_NULL: encode(encodingTypes.METADATA_ENCODING_NULL),
|
package/src/proto-utils.ts
CHANGED
|
@@ -17,17 +17,41 @@ function pascalCaseToConstantCase(s: string) {
|
|
|
17
17
|
function fixEnumValue<O extends Record<string, any>>(obj: O, attr: keyof O, prefix: string) {
|
|
18
18
|
return (
|
|
19
19
|
obj[attr] && {
|
|
20
|
-
[attr]: `${prefix}_${pascalCaseToConstantCase(obj[attr])}`,
|
|
20
|
+
[attr]: obj[attr].startsWith(prefix) ? obj[attr] : `${prefix}_${pascalCaseToConstantCase(obj[attr])}`,
|
|
21
21
|
}
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// fromProto3JSON doesn't allow null values on 'bytes' fields. This turns out to be a problem for payloads.
|
|
26
|
+
// Recursively descend on objects and array, and fix in-place any payload that has a null data field
|
|
27
|
+
function fixPayloads<T>(e: T): T {
|
|
28
|
+
function isPayload(p: any): p is JSONPayload {
|
|
29
|
+
return p && typeof p === 'object' && 'metadata' in p && 'data' in p;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (e && typeof e === 'object') {
|
|
33
|
+
if (isPayload(e)) {
|
|
34
|
+
if (e.data === null) {
|
|
35
|
+
const { data: _data, ...rest } = e;
|
|
36
|
+
return rest as T;
|
|
37
|
+
}
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(e)) return e.map(fixPayloads) as T;
|
|
41
|
+
return Object.fromEntries(Object.entries(e as object).map(([k, v]) => [k, fixPayloads(v)])) as T;
|
|
42
|
+
}
|
|
43
|
+
return e;
|
|
44
|
+
}
|
|
45
|
+
|
|
25
46
|
function fixHistoryEvent(e: Record<string, any>) {
|
|
26
47
|
const type = Object.keys(e).find((k) => k.endsWith('EventAttributes'));
|
|
27
48
|
if (!type) {
|
|
28
49
|
throw new TypeError(`Missing attributes in history event: ${JSON.stringify(e)}`);
|
|
29
50
|
}
|
|
30
51
|
|
|
52
|
+
// Fix payloads with null data
|
|
53
|
+
e = fixPayloads(e);
|
|
54
|
+
|
|
31
55
|
return {
|
|
32
56
|
...e,
|
|
33
57
|
...fixEnumValue(e, 'eventType', 'EVENT_TYPE'),
|