@temporalio/common 1.6.0 → 1.7.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/errors.d.ts +2 -1
- package/lib/errors.js +2 -1
- package/lib/errors.js.map +1 -1
- package/lib/interfaces.d.ts +27 -7
- package/lib/workflow-handle.d.ts +1 -1
- package/lib/workflow-options.d.ts +2 -2
- package/package.json +8 -3
- package/src/errors.ts +3 -1
- package/src/interfaces.ts +26 -9
- package/src/workflow-handle.ts +4 -1
- package/src/workflow-options.ts +2 -2
package/lib/errors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TemporalFailure } from './failure';
|
|
1
2
|
/**
|
|
2
3
|
* Thrown from code that receives a value that is unexpected or that it's unable to handle.
|
|
3
4
|
*/
|
|
@@ -26,7 +27,7 @@ export declare class IllegalStateError extends Error {
|
|
|
26
27
|
* - There is closed Workflow in the `Completed` state with the same Workflow Id and the {@link WorkflowOptions.workflowIdReusePolicy}
|
|
27
28
|
* is `WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY`
|
|
28
29
|
*/
|
|
29
|
-
export declare class WorkflowExecutionAlreadyStartedError extends
|
|
30
|
+
export declare class WorkflowExecutionAlreadyStartedError extends TemporalFailure {
|
|
30
31
|
readonly workflowId: string;
|
|
31
32
|
readonly workflowType: string;
|
|
32
33
|
readonly name: string;
|
package/lib/errors.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkflowNotFoundError = exports.WorkflowExecutionAlreadyStartedError = exports.IllegalStateError = exports.PayloadConverterError = exports.ValueError = void 0;
|
|
4
|
+
const failure_1 = require("./failure");
|
|
4
5
|
/**
|
|
5
6
|
* Thrown from code that receives a value that is unexpected or that it's unable to handle.
|
|
6
7
|
*/
|
|
@@ -40,7 +41,7 @@ exports.IllegalStateError = IllegalStateError;
|
|
|
40
41
|
* - There is closed Workflow in the `Completed` state with the same Workflow Id and the {@link WorkflowOptions.workflowIdReusePolicy}
|
|
41
42
|
* is `WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY`
|
|
42
43
|
*/
|
|
43
|
-
class WorkflowExecutionAlreadyStartedError extends
|
|
44
|
+
class WorkflowExecutionAlreadyStartedError extends failure_1.TemporalFailure {
|
|
44
45
|
constructor(message, workflowId, workflowType) {
|
|
45
46
|
super(message);
|
|
46
47
|
this.workflowId = workflowId;
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,UAAW,SAAQ,KAAK;IAGnC,YAAY,OAA2B,EAAkB,KAAe;QACtE,KAAK,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC;QAD2B,UAAK,GAAL,KAAK,CAAU;QAFxD,SAAI,GAAW,YAAY,CAAC;IAI5C,CAAC;CACF;AAND,gCAMC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,UAAU;IAArD;;QACkB,SAAI,GAAW,uBAAuB,CAAC;IACzD,CAAC;CAAA;AAFD,sDAEC;AAED;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAA5C;;QACkB,SAAI,GAAW,mBAAmB,CAAC;IACrD,CAAC;CAAA;AAFD,8CAEC;AAED;;;;;;;GAOG;AACH,MAAa,oCAAqC,SAAQ,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,uCAA4C;AAE5C;;GAEG;AACH,MAAa,UAAW,SAAQ,KAAK;IAGnC,YAAY,OAA2B,EAAkB,KAAe;QACtE,KAAK,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC;QAD2B,UAAK,GAAL,KAAK,CAAU;QAFxD,SAAI,GAAW,YAAY,CAAC;IAI5C,CAAC;CACF;AAND,gCAMC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,UAAU;IAArD;;QACkB,SAAI,GAAW,uBAAuB,CAAC;IACzD,CAAC;CAAA;AAFD,sDAEC;AAED;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAA5C;;QACkB,SAAI,GAAW,mBAAmB,CAAC;IACrD,CAAC;CAAA;AAFD,8CAEC;AAED;;;;;;;GAOG;AACH,MAAa,oCAAqC,SAAQ,yBAAe;IAGvE,YAAY,OAAe,EAAkB,UAAkB,EAAkB,YAAoB;QACnG,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,eAAU,GAAV,UAAU,CAAQ;QAAkB,iBAAY,GAAZ,YAAY,CAAQ;QAFrF,SAAI,GAAW,sCAAsC,CAAC;IAItE,CAAC;CACF;AAND,oFAMC;AAED;;;;;;GAMG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IAG9C,YAAY,OAAe,EAAkB,UAAkB,EAAkB,KAAyB;QACxG,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,eAAU,GAAV,UAAU,CAAQ;QAAkB,UAAK,GAAL,KAAK,CAAoB;QAF1F,SAAI,GAAW,uBAAuB,CAAC;IAIvD,CAAC;CACF;AAND,sDAMC"}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -11,23 +11,42 @@ export declare type WorkflowQueryType = (...args: any[]) => any;
|
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
13
|
export declare type Workflow = (...args: any[]) => WorkflowReturnType;
|
|
14
|
+
declare const argsBrand: unique symbol;
|
|
14
15
|
/**
|
|
15
16
|
* An interface representing a Workflow signal definition, as returned from {@link defineSignal}
|
|
16
17
|
*
|
|
17
|
-
* @remarks `
|
|
18
|
+
* @remarks `Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
|
|
19
|
+
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the signal name.
|
|
18
20
|
*/
|
|
19
|
-
export interface SignalDefinition<
|
|
21
|
+
export interface SignalDefinition<Args extends any[] = [], Name extends string = string> {
|
|
20
22
|
type: 'signal';
|
|
21
|
-
name:
|
|
23
|
+
name: Name;
|
|
24
|
+
/**
|
|
25
|
+
* Virtual type brand to maintain a distinction between {@link SignalDefinition} types with different args.
|
|
26
|
+
* This field is not present at run-time.
|
|
27
|
+
*/
|
|
28
|
+
[argsBrand]: Args;
|
|
22
29
|
}
|
|
30
|
+
declare const retBrand: unique symbol;
|
|
23
31
|
/**
|
|
24
32
|
* An interface representing a Workflow query definition as returned from {@link defineQuery}
|
|
25
33
|
*
|
|
26
|
-
* @remarks `
|
|
34
|
+
* @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
|
|
35
|
+
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the query name.
|
|
27
36
|
*/
|
|
28
|
-
export interface QueryDefinition<
|
|
37
|
+
export interface QueryDefinition<Ret, Args extends any[] = [], Name extends string = string> {
|
|
29
38
|
type: 'query';
|
|
30
|
-
name:
|
|
39
|
+
name: Name;
|
|
40
|
+
/**
|
|
41
|
+
* Virtual type brand to maintain a distinction between {@link QueryDefinition} types with different args.
|
|
42
|
+
* This field is not present at run-time.
|
|
43
|
+
*/
|
|
44
|
+
[argsBrand]: Args;
|
|
45
|
+
/**
|
|
46
|
+
* Virtual type brand to maintain a distinction between {@link QueryDefinition} types with different return types.
|
|
47
|
+
* This field is not present at run-time.
|
|
48
|
+
*/
|
|
49
|
+
[retBrand]: Ret;
|
|
31
50
|
}
|
|
32
51
|
/** Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type `W` */
|
|
33
52
|
export declare type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promise<infer R> ? R : never;
|
|
@@ -36,7 +55,7 @@ export declare type WorkflowResultType<W extends Workflow> = ReturnType<W> exten
|
|
|
36
55
|
*
|
|
37
56
|
* Dates are serialized as ISO strings.
|
|
38
57
|
*/
|
|
39
|
-
export declare type SearchAttributes = Record<string, SearchAttributeValue | undefined>;
|
|
58
|
+
export declare type SearchAttributes = Record<string, SearchAttributeValue | Readonly<SearchAttributeValue> | undefined>;
|
|
40
59
|
export declare type SearchAttributeValue = string[] | number[] | boolean[] | Date[];
|
|
41
60
|
export interface ActivityFunction<P extends any[] = any[], R = any> {
|
|
42
61
|
(...args: P): Promise<R>;
|
|
@@ -57,3 +76,4 @@ export interface HistoryAndWorkflowId {
|
|
|
57
76
|
workflowId: string;
|
|
58
77
|
history: temporal.api.history.v1.History | unknown | undefined;
|
|
59
78
|
}
|
|
79
|
+
export {};
|
package/lib/workflow-handle.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface BaseWorkflowHandle<T extends Workflow> {
|
|
|
19
19
|
* await handle.signal(incrementSignal, 3);
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
signal<Args extends any[] = []>(def: SignalDefinition<Args> | string, ...args: Args): Promise<void>;
|
|
22
|
+
signal<Args extends any[] = [], Name extends string = string>(def: SignalDefinition<Args, Name> | string, ...args: Args): Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* The workflowId of the current Workflow
|
|
25
25
|
*/
|
|
@@ -77,12 +77,12 @@ export declare type WithWorkflowArgs<W extends Workflow, T> = T & (Parameters<W>
|
|
|
77
77
|
/**
|
|
78
78
|
* Arguments to pass to the Workflow
|
|
79
79
|
*/
|
|
80
|
-
args: Parameters<W
|
|
80
|
+
args: Parameters<W> | Readonly<Parameters<W>>;
|
|
81
81
|
} : {
|
|
82
82
|
/**
|
|
83
83
|
* Arguments to pass to the Workflow
|
|
84
84
|
*/
|
|
85
|
-
args?: Parameters<W
|
|
85
|
+
args?: Parameters<W> | Readonly<Parameters<W>>;
|
|
86
86
|
});
|
|
87
87
|
export interface WorkflowDurationOptions {
|
|
88
88
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
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",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@opentelemetry/api": "^1.3.0",
|
|
16
|
-
"@temporalio/proto": "1.
|
|
16
|
+
"@temporalio/proto": "1.7.1",
|
|
17
17
|
"long": "^5.2.0",
|
|
18
18
|
"ms": "^2.1.3",
|
|
19
19
|
"proto3-json-serializer": "^1.0.3",
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"bugs": {
|
|
23
23
|
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
24
24
|
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/temporalio/sdk-typescript.git",
|
|
28
|
+
"directory": "packages/common"
|
|
29
|
+
},
|
|
25
30
|
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/packages/common",
|
|
26
31
|
"publishConfig": {
|
|
27
32
|
"access": "public"
|
|
@@ -30,5 +35,5 @@
|
|
|
30
35
|
"src",
|
|
31
36
|
"lib"
|
|
32
37
|
],
|
|
33
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "368aa83c631555fc31cff25f4af8817d069878d8"
|
|
34
39
|
}
|
package/src/errors.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TemporalFailure } from './failure';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Thrown from code that receives a value that is unexpected or that it's unable to handle.
|
|
3
5
|
*/
|
|
@@ -31,7 +33,7 @@ export class IllegalStateError extends Error {
|
|
|
31
33
|
* - There is closed Workflow in the `Completed` state with the same Workflow Id and the {@link WorkflowOptions.workflowIdReusePolicy}
|
|
32
34
|
* is `WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY`
|
|
33
35
|
*/
|
|
34
|
-
export class WorkflowExecutionAlreadyStartedError extends
|
|
36
|
+
export class WorkflowExecutionAlreadyStartedError extends TemporalFailure {
|
|
35
37
|
public readonly name: string = 'WorkflowExecutionAlreadyStartedError';
|
|
36
38
|
|
|
37
39
|
constructor(message: string, public readonly workflowId: string, public readonly workflowType: string) {
|
package/src/interfaces.ts
CHANGED
|
@@ -15,26 +15,43 @@ export type WorkflowQueryType = (...args: any[]) => any;
|
|
|
15
15
|
*/
|
|
16
16
|
export type Workflow = (...args: any[]) => WorkflowReturnType;
|
|
17
17
|
|
|
18
|
+
declare const argsBrand: unique symbol;
|
|
18
19
|
/**
|
|
19
20
|
* An interface representing a Workflow signal definition, as returned from {@link defineSignal}
|
|
20
21
|
*
|
|
21
|
-
* @remarks `
|
|
22
|
+
* @remarks `Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
|
|
23
|
+
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the signal name.
|
|
22
24
|
*/
|
|
23
|
-
|
|
24
|
-
export interface SignalDefinition<_Args extends any[] = []> {
|
|
25
|
+
export interface SignalDefinition<Args extends any[] = [], Name extends string = string> {
|
|
25
26
|
type: 'signal';
|
|
26
|
-
name:
|
|
27
|
+
name: Name;
|
|
28
|
+
/**
|
|
29
|
+
* Virtual type brand to maintain a distinction between {@link SignalDefinition} types with different args.
|
|
30
|
+
* This field is not present at run-time.
|
|
31
|
+
*/
|
|
32
|
+
[argsBrand]: Args;
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
declare const retBrand: unique symbol;
|
|
29
36
|
/**
|
|
30
37
|
* An interface representing a Workflow query definition as returned from {@link defineQuery}
|
|
31
38
|
*
|
|
32
|
-
* @remarks `
|
|
39
|
+
* @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
|
|
40
|
+
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the query name.
|
|
33
41
|
*/
|
|
34
|
-
|
|
35
|
-
export interface QueryDefinition<_Ret, _Args extends any[] = []> {
|
|
42
|
+
export interface QueryDefinition<Ret, Args extends any[] = [], Name extends string = string> {
|
|
36
43
|
type: 'query';
|
|
37
|
-
name:
|
|
44
|
+
name: Name;
|
|
45
|
+
/**
|
|
46
|
+
* Virtual type brand to maintain a distinction between {@link QueryDefinition} types with different args.
|
|
47
|
+
* This field is not present at run-time.
|
|
48
|
+
*/
|
|
49
|
+
[argsBrand]: Args;
|
|
50
|
+
/**
|
|
51
|
+
* Virtual type brand to maintain a distinction between {@link QueryDefinition} types with different return types.
|
|
52
|
+
* This field is not present at run-time.
|
|
53
|
+
*/
|
|
54
|
+
[retBrand]: Ret;
|
|
38
55
|
}
|
|
39
56
|
|
|
40
57
|
/** Get the "unwrapped" return type (without Promise) of the execute handler from Workflow type `W` */
|
|
@@ -45,7 +62,7 @@ export type WorkflowResultType<W extends Workflow> = ReturnType<W> extends Promi
|
|
|
45
62
|
*
|
|
46
63
|
* Dates are serialized as ISO strings.
|
|
47
64
|
*/
|
|
48
|
-
export type SearchAttributes = Record<string, SearchAttributeValue | undefined>;
|
|
65
|
+
export type SearchAttributes = Record<string, SearchAttributeValue | Readonly<SearchAttributeValue> | undefined>;
|
|
49
66
|
export type SearchAttributeValue = string[] | number[] | boolean[] | Date[];
|
|
50
67
|
|
|
51
68
|
export interface ActivityFunction<P extends any[] = any[], R = any> {
|
package/src/workflow-handle.ts
CHANGED
|
@@ -21,7 +21,10 @@ export interface BaseWorkflowHandle<T extends Workflow> {
|
|
|
21
21
|
* await handle.signal(incrementSignal, 3);
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
signal<Args extends any[] = []
|
|
24
|
+
signal<Args extends any[] = [], Name extends string = string>(
|
|
25
|
+
def: SignalDefinition<Args, Name> | string,
|
|
26
|
+
...args: Args
|
|
27
|
+
): Promise<void>;
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* The workflowId of the current Workflow
|
package/src/workflow-options.ts
CHANGED
|
@@ -96,13 +96,13 @@ export type WithWorkflowArgs<W extends Workflow, T> = T &
|
|
|
96
96
|
/**
|
|
97
97
|
* Arguments to pass to the Workflow
|
|
98
98
|
*/
|
|
99
|
-
args: Parameters<W
|
|
99
|
+
args: Parameters<W> | Readonly<Parameters<W>>;
|
|
100
100
|
}
|
|
101
101
|
: {
|
|
102
102
|
/**
|
|
103
103
|
* Arguments to pass to the Workflow
|
|
104
104
|
*/
|
|
105
|
-
args?: Parameters<W
|
|
105
|
+
args?: Parameters<W> | Readonly<Parameters<W>>;
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
export interface WorkflowDurationOptions {
|