@temporalio/client 1.2.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/async-completion-client.d.ts +17 -5
- package/lib/async-completion-client.js +28 -11
- package/lib/async-completion-client.js.map +1 -1
- package/lib/client.d.ts +92 -0
- package/lib/client.js +77 -0
- package/lib/client.js.map +1 -0
- package/lib/connection.d.ts +12 -4
- package/lib/connection.js +13 -4
- package/lib/connection.js.map +1 -1
- package/lib/grpc-retry.d.ts +51 -8
- package/lib/grpc-retry.js +73 -46
- package/lib/grpc-retry.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/interceptors.d.ts +10 -2
- package/lib/types.d.ts +16 -15
- package/lib/types.js +28 -4
- package/lib/types.js.map +1 -1
- package/lib/workflow-client.d.ts +26 -10
- package/lib/workflow-client.js +51 -45
- package/lib/workflow-client.js.map +1 -1
- package/lib/workflow-options.d.ts +16 -5
- package/lib/workflow-options.js +1 -27
- package/lib/workflow-options.js.map +1 -1
- package/package.json +7 -9
- package/src/async-completion-client.ts +30 -8
- package/src/client.ts +151 -0
- package/src/connection.ts +21 -3
- package/src/grpc-retry.ts +129 -56
- package/src/index.ts +6 -5
- package/src/interceptors.ts +11 -2
- package/src/types.ts +19 -15
- package/src/workflow-client.ts +65 -49
- package/src/workflow-options.ts +21 -35
package/lib/grpc-retry.js
CHANGED
|
@@ -23,17 +23,43 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.makeGrpcRetryInterceptor = exports.
|
|
26
|
+
exports.makeGrpcRetryInterceptor = exports.isRetryableError = exports.defaultGrpcRetryOptions = void 0;
|
|
27
27
|
const grpc_js_1 = require("@grpc/grpc-js");
|
|
28
28
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Add defaults as documented in {@link BackoffOptions}
|
|
31
|
+
*/
|
|
32
|
+
function withDefaultBackoffOptions({ maxAttempts, factor, maxJitter, initialIntervalMs, }) {
|
|
33
|
+
return {
|
|
34
|
+
maxAttempts: maxAttempts ?? 10,
|
|
35
|
+
factor: factor ?? 2,
|
|
36
|
+
maxJitter: maxJitter ?? 0.1,
|
|
37
|
+
initialIntervalMs: initialIntervalMs ?? defaultInitialIntervalMs,
|
|
38
|
+
maxIntervalMs() {
|
|
39
|
+
return 10000;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generates the default retry behavior based on given backoff options
|
|
45
|
+
*
|
|
46
|
+
* @experimental
|
|
47
|
+
*/
|
|
48
|
+
function defaultGrpcRetryOptions(options = {}) {
|
|
49
|
+
const { maxAttempts, factor, maxJitter, initialIntervalMs, maxIntervalMs } = withDefaultBackoffOptions(options);
|
|
30
50
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
delayFunction(attempt, status) {
|
|
52
|
+
return Math.min(maxIntervalMs(status), factor ** attempt * initialIntervalMs(status)) * jitter(maxJitter);
|
|
53
|
+
},
|
|
54
|
+
retryableDecider(attempt, status) {
|
|
55
|
+
return attempt < maxAttempts && isRetryableError(status);
|
|
56
|
+
},
|
|
34
57
|
};
|
|
35
58
|
}
|
|
36
59
|
exports.defaultGrpcRetryOptions = defaultGrpcRetryOptions;
|
|
60
|
+
/**
|
|
61
|
+
* Set of retryable gRPC status codes
|
|
62
|
+
*/
|
|
37
63
|
const retryableCodes = new Set([
|
|
38
64
|
grpc.status.UNKNOWN,
|
|
39
65
|
grpc.status.RESOURCE_EXHAUSTED,
|
|
@@ -46,71 +72,72 @@ function isRetryableError(status) {
|
|
|
46
72
|
return retryableCodes.has(status.code);
|
|
47
73
|
}
|
|
48
74
|
exports.isRetryableError = isRetryableError;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Calculates random amount of jitter between 0 and `max`
|
|
77
|
+
*/
|
|
78
|
+
function jitter(max) {
|
|
79
|
+
return 1 - max + Math.random() * max * 2;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Default implementation - backs off more on RESOURCE_EXHAUSTED errors
|
|
83
|
+
*/
|
|
84
|
+
function defaultInitialIntervalMs({ code }) {
|
|
85
|
+
// Backoff more on RESOURCE_EXHAUSTED
|
|
86
|
+
if (code === grpc.status.RESOURCE_EXHAUSTED) {
|
|
87
|
+
return 1000;
|
|
88
|
+
}
|
|
89
|
+
return 20;
|
|
52
90
|
}
|
|
53
|
-
exports.backOffAmount = backOffAmount;
|
|
54
91
|
/**
|
|
55
92
|
* Returns a GRPC interceptor that will perform automatic retries for some types of failed calls
|
|
56
93
|
*
|
|
57
94
|
* @param retryOptions Options for the retry interceptor
|
|
95
|
+
*
|
|
96
|
+
* @experimental
|
|
58
97
|
*/
|
|
59
98
|
function makeGrpcRetryInterceptor(retryOptions) {
|
|
60
99
|
return (options, nextCall) => {
|
|
61
|
-
let savedMetadata;
|
|
62
100
|
let savedSendMessage;
|
|
63
101
|
let savedReceiveMessage;
|
|
64
102
|
let savedMessageNext;
|
|
65
103
|
const requester = new grpc_js_1.RequesterBuilder()
|
|
66
104
|
.withStart(function (metadata, _listener, next) {
|
|
67
|
-
|
|
68
|
-
|
|
105
|
+
// First attempt
|
|
106
|
+
let attempt = 1;
|
|
107
|
+
const listener = new grpc_js_1.ListenerBuilder()
|
|
69
108
|
.withOnReceiveMessage((message, next) => {
|
|
70
109
|
savedReceiveMessage = message;
|
|
71
110
|
savedMessageNext = next;
|
|
72
111
|
})
|
|
73
112
|
.withOnReceiveStatus((status, next) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
onReceiveMessage: (message) => {
|
|
113
|
+
const retry = () => {
|
|
114
|
+
attempt++;
|
|
115
|
+
const call = nextCall(options);
|
|
116
|
+
call.start(metadata, {
|
|
117
|
+
onReceiveMessage(message) {
|
|
80
118
|
savedReceiveMessage = message;
|
|
81
119
|
},
|
|
82
|
-
onReceiveStatus
|
|
83
|
-
if (retryOptions.retryableDecider(status)) {
|
|
84
|
-
if (retries <= retryOptions.maxRetries) {
|
|
85
|
-
setTimeout(() => retry(message, metadata), retryOptions.delayFunction(retries));
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
savedMessageNext(savedReceiveMessage);
|
|
89
|
-
next(status);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
savedMessageNext(savedReceiveMessage);
|
|
94
|
-
// TODO: For reasons that are completely unclear to me, if you pass a handcrafted
|
|
95
|
-
// status object here, node will magically just exit at the end of this line.
|
|
96
|
-
// No warning, no nothing. Here be dragons.
|
|
97
|
-
next(status);
|
|
98
|
-
}
|
|
99
|
-
},
|
|
120
|
+
onReceiveStatus,
|
|
100
121
|
});
|
|
101
|
-
|
|
102
|
-
|
|
122
|
+
call.sendMessage(savedSendMessage);
|
|
123
|
+
call.halfClose();
|
|
124
|
+
};
|
|
125
|
+
const onReceiveStatus = (status) => {
|
|
126
|
+
if (retryOptions.retryableDecider(attempt, status)) {
|
|
127
|
+
setTimeout(retry, retryOptions.delayFunction(attempt, status));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
savedMessageNext(savedReceiveMessage);
|
|
131
|
+
// TODO: For reasons that are completely unclear to me, if you pass a handcrafted
|
|
132
|
+
// status object here, node will magically just exit at the end of this line.
|
|
133
|
+
// No warning, no nothing. Here be dragons.
|
|
134
|
+
next(status);
|
|
135
|
+
}
|
|
103
136
|
};
|
|
104
|
-
|
|
105
|
-
setTimeout(() => retry(savedSendMessage, savedMetadata), backOffAmount(retries));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
savedMessageNext(savedReceiveMessage);
|
|
109
|
-
next(status);
|
|
110
|
-
}
|
|
137
|
+
onReceiveStatus(status);
|
|
111
138
|
})
|
|
112
139
|
.build();
|
|
113
|
-
next(metadata,
|
|
140
|
+
next(metadata, listener);
|
|
114
141
|
})
|
|
115
142
|
.withSendMessage((message, next) => {
|
|
116
143
|
savedSendMessage = message;
|
package/lib/grpc-retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-retry.js","sourceRoot":"","sources":["../src/grpc-retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"grpc-retry.js","sourceRoot":"","sources":["../src/grpc-retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+G;AAC/G,oDAAsC;AA0DtC;;GAEG;AACH,SAAS,yBAAyB,CAAC,EACjC,WAAW,EACX,MAAM,EACN,SAAS,EACT,iBAAiB,GACO;IACxB,OAAO;QACL,WAAW,EAAE,WAAW,IAAI,EAAE;QAC9B,MAAM,EAAE,MAAM,IAAI,CAAC;QACnB,SAAS,EAAE,SAAS,IAAI,GAAG;QAC3B,iBAAiB,EAAE,iBAAiB,IAAI,wBAAwB;QAChE,aAAa;YACX,OAAO,KAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CAAC,UAAmC,EAAE;IAC3E,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAChH,OAAO;QACL,aAAa,CAAC,OAAO,EAAE,MAAM;YAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,OAAO,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;QAC5G,CAAC;QACD,gBAA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GAAG,OAAO,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,CAAC;QAChB,CAAC,CAAC;aACD,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,0BAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC;AAtDD,4DAsDC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* <!--SNIPEND-->
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
export { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, DataConverter, defaultPayloadConverter, ProtoFailure, ServerFailure, TemporalFailure, TerminatedFailure, TimeoutFailure, } from '@temporalio/common';
|
|
12
|
-
export { TLSConfig } from '@temporalio/internal-non-workflow
|
|
13
|
-
export
|
|
14
|
-
export * from '@temporalio/
|
|
15
|
-
export * from '@temporalio/
|
|
16
|
-
export * from '@temporalio/internal-workflow-common/lib/workflow-handle';
|
|
11
|
+
export { ActivityFailure, ApplicationFailure, CancelledFailure, ChildWorkflowFailure, DataConverter, defaultPayloadConverter, ProtoFailure, RetryPolicy, ServerFailure, TemporalFailure, TerminatedFailure, TimeoutFailure, } from '@temporalio/common';
|
|
12
|
+
export { TLSConfig } from '@temporalio/common/lib/internal-non-workflow';
|
|
13
|
+
export * from '@temporalio/common/lib/errors';
|
|
14
|
+
export * from '@temporalio/common/lib/interfaces';
|
|
15
|
+
export * from '@temporalio/common/lib/workflow-handle';
|
|
17
16
|
export * from './async-completion-client';
|
|
17
|
+
export * from './client';
|
|
18
18
|
export { Connection, ConnectionOptions, ConnectionOptionsWithDefaults, LOCAL_TARGET } from './connection';
|
|
19
19
|
export * from './errors';
|
|
20
20
|
export * from './grpc-retry';
|
package/lib/index.js
CHANGED
|
@@ -35,10 +35,11 @@ Object.defineProperty(exports, "ServerFailure", { enumerable: true, get: functio
|
|
|
35
35
|
Object.defineProperty(exports, "TemporalFailure", { enumerable: true, get: function () { return common_1.TemporalFailure; } });
|
|
36
36
|
Object.defineProperty(exports, "TerminatedFailure", { enumerable: true, get: function () { return common_1.TerminatedFailure; } });
|
|
37
37
|
Object.defineProperty(exports, "TimeoutFailure", { enumerable: true, get: function () { return common_1.TimeoutFailure; } });
|
|
38
|
-
__exportStar(require("@temporalio/
|
|
39
|
-
__exportStar(require("@temporalio/
|
|
40
|
-
__exportStar(require("@temporalio/
|
|
38
|
+
__exportStar(require("@temporalio/common/lib/errors"), exports);
|
|
39
|
+
__exportStar(require("@temporalio/common/lib/interfaces"), exports);
|
|
40
|
+
__exportStar(require("@temporalio/common/lib/workflow-handle"), exports);
|
|
41
41
|
__exportStar(require("./async-completion-client"), exports);
|
|
42
|
+
__exportStar(require("./client"), exports);
|
|
42
43
|
var connection_1 = require("./connection");
|
|
43
44
|
Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_1.Connection; } });
|
|
44
45
|
Object.defineProperty(exports, "LOCAL_TARGET", { enumerable: true, get: function () { return connection_1.LOCAL_TARGET; } });
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;AAEH,6CAa4B;AAZ1B,yGAAA,eAAe,OAAA;AACf,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,8GAAA,oBAAoB,OAAA;AAEpB,iHAAA,uBAAuB,OAAA;AAGvB,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA;AAGhB,gEAA8C;AAC9C,oEAAkD;AAClD,yEAAuD;AACvD,4DAA0C;AAC1C,2CAAyB;AACzB,2CAA0G;AAAjG,wGAAA,UAAU,OAAA;AAAoD,0GAAA,YAAY,OAAA;AACnF,2CAAyB;AACzB,+CAA6B;AAC7B,iDAA+B;AAC/B,0CAAwB;AACxB,oDAAkC;AAClC,qDAAmC"}
|
package/lib/interceptors.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { Headers, Next } from '@temporalio/
|
|
6
|
+
import { Headers, Next } from '@temporalio/common';
|
|
7
7
|
import { temporal } from '@temporalio/proto';
|
|
8
8
|
import { DescribeWorkflowExecutionResponse, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution } from './types';
|
|
9
9
|
import { CompiledWorkflowOptions } from './workflow-options';
|
|
@@ -93,7 +93,7 @@ export interface WorkflowClientCallsInterceptor {
|
|
|
93
93
|
*/
|
|
94
94
|
describe?: (input: WorkflowDescribeInput, next: Next<this, 'describe'>) => Promise<DescribeWorkflowExecutionResponse>;
|
|
95
95
|
}
|
|
96
|
-
interface WorkflowClientCallsInterceptorFactoryInput {
|
|
96
|
+
export interface WorkflowClientCallsInterceptorFactoryInput {
|
|
97
97
|
workflowId: string;
|
|
98
98
|
runId?: string;
|
|
99
99
|
}
|
|
@@ -109,3 +109,11 @@ export interface WorkflowClientCallsInterceptorFactory {
|
|
|
109
109
|
export interface WorkflowClientInterceptors {
|
|
110
110
|
calls?: WorkflowClientCallsInterceptorFactory[];
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Interceptors for any high-level SDK client.
|
|
114
|
+
*
|
|
115
|
+
* NOTE: Currently only for {@link WorkflowClient}. More will be added later as needed.
|
|
116
|
+
*/
|
|
117
|
+
export interface ClientInterceptors {
|
|
118
|
+
workflow?: WorkflowClientInterceptors;
|
|
119
|
+
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type { SearchAttributes } from '@temporalio/
|
|
2
|
-
import
|
|
1
|
+
import type { SearchAttributes } from '@temporalio/common';
|
|
2
|
+
import * as proto from '@temporalio/proto';
|
|
3
3
|
import type * as grpc from '@grpc/grpc-js';
|
|
4
|
-
import Long from 'long';
|
|
5
4
|
export interface WorkflowExecution {
|
|
6
5
|
workflowId: string;
|
|
7
6
|
runId?: string;
|
|
8
7
|
}
|
|
9
|
-
export declare type StartWorkflowExecutionRequest = temporal.api.workflowservice.v1.IStartWorkflowExecutionRequest;
|
|
10
|
-
export declare type GetWorkflowExecutionHistoryRequest = temporal.api.workflowservice.v1.IGetWorkflowExecutionHistoryRequest;
|
|
11
|
-
export declare type DescribeWorkflowExecutionResponse = temporal.api.workflowservice.v1.IDescribeWorkflowExecutionResponse;
|
|
12
|
-
export declare type TerminateWorkflowExecutionResponse = temporal.api.workflowservice.v1.ITerminateWorkflowExecutionResponse;
|
|
13
|
-
export declare type RequestCancelWorkflowExecutionResponse = temporal.api.workflowservice.v1.IRequestCancelWorkflowExecutionResponse;
|
|
8
|
+
export declare type StartWorkflowExecutionRequest = proto.temporal.api.workflowservice.v1.IStartWorkflowExecutionRequest;
|
|
9
|
+
export declare type GetWorkflowExecutionHistoryRequest = proto.temporal.api.workflowservice.v1.IGetWorkflowExecutionHistoryRequest;
|
|
10
|
+
export declare type DescribeWorkflowExecutionResponse = proto.temporal.api.workflowservice.v1.IDescribeWorkflowExecutionResponse;
|
|
11
|
+
export declare type TerminateWorkflowExecutionResponse = proto.temporal.api.workflowservice.v1.ITerminateWorkflowExecutionResponse;
|
|
12
|
+
export declare type RequestCancelWorkflowExecutionResponse = proto.temporal.api.workflowservice.v1.IRequestCancelWorkflowExecutionResponse;
|
|
14
13
|
export declare type WorkflowExecutionStatusName = 'UNSPECIFIED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'TERMINATED' | 'CONTINUED_AS_NEW' | 'TIMED_OUT' | 'UNKNOWN';
|
|
15
14
|
export interface WorkflowExecutionDescription {
|
|
16
15
|
type: string;
|
|
@@ -18,22 +17,24 @@ export interface WorkflowExecutionDescription {
|
|
|
18
17
|
runId: string;
|
|
19
18
|
taskQueue: string;
|
|
20
19
|
status: {
|
|
21
|
-
code: temporal.api.enums.v1.WorkflowExecutionStatus;
|
|
20
|
+
code: proto.temporal.api.enums.v1.WorkflowExecutionStatus;
|
|
22
21
|
name: WorkflowExecutionStatusName;
|
|
23
22
|
};
|
|
24
|
-
historyLength:
|
|
23
|
+
historyLength: number;
|
|
25
24
|
startTime: Date;
|
|
26
25
|
executionTime?: Date;
|
|
27
26
|
closeTime?: Date;
|
|
28
27
|
memo?: Record<string, unknown>;
|
|
29
28
|
searchAttributes: SearchAttributes;
|
|
30
|
-
parentExecution?: Required<temporal.api.common.v1.IWorkflowExecution>;
|
|
29
|
+
parentExecution?: Required<proto.temporal.api.common.v1.IWorkflowExecution>;
|
|
31
30
|
raw: DescribeWorkflowExecutionResponse;
|
|
32
31
|
}
|
|
33
|
-
export declare type WorkflowService = temporal.api.workflowservice.v1.WorkflowService;
|
|
34
|
-
export declare const WorkflowService: typeof temporal.api.workflowservice.v1.WorkflowService;
|
|
35
|
-
export declare type OperatorService = temporal.api.operatorservice.v1.OperatorService;
|
|
36
|
-
export declare const OperatorService: typeof temporal.api.operatorservice.v1.OperatorService;
|
|
32
|
+
export declare type WorkflowService = proto.temporal.api.workflowservice.v1.WorkflowService;
|
|
33
|
+
export declare const WorkflowService: typeof proto.temporal.api.workflowservice.v1.WorkflowService;
|
|
34
|
+
export declare type OperatorService = proto.temporal.api.operatorservice.v1.OperatorService;
|
|
35
|
+
export declare const OperatorService: typeof proto.temporal.api.operatorservice.v1.OperatorService;
|
|
36
|
+
export declare type HealthService = proto.grpc.health.v1.Health;
|
|
37
|
+
export declare const HealthService: typeof proto.grpc.health.v1.Health;
|
|
37
38
|
/**
|
|
38
39
|
* Mapping of string to valid gRPC metadata value
|
|
39
40
|
*/
|
package/lib/types.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OperatorService = exports.WorkflowService = void 0;
|
|
4
|
-
const
|
|
5
|
-
exports.WorkflowService =
|
|
6
|
-
exports.OperatorService =
|
|
26
|
+
exports.HealthService = exports.OperatorService = exports.WorkflowService = void 0;
|
|
27
|
+
const proto = __importStar(require("@temporalio/proto"));
|
|
28
|
+
exports.WorkflowService = proto.temporal.api.workflowservice.v1.WorkflowService;
|
|
29
|
+
exports.OperatorService = proto.temporal.api.operatorservice.v1.OperatorService;
|
|
30
|
+
exports.HealthService = proto.grpc.health.v1.Health;
|
|
7
31
|
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AA6C5B,uBAAe,GAAK,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,iBAAC;AAE1D,uBAAe,GAAK,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,iBAAC;AAElD,qBAAa,GAAK,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,QAAC"}
|
package/lib/workflow-client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { status as grpcStatus } from '@grpc/grpc-js';
|
|
2
2
|
import { DataConverter, LoadedDataConverter } from '@temporalio/common';
|
|
3
|
-
import { BaseWorkflowHandle, QueryDefinition,
|
|
3
|
+
import { BaseWorkflowHandle, QueryDefinition, WithWorkflowArgs, Workflow, WorkflowResultType } from '@temporalio/common';
|
|
4
|
+
import { Replace } from '@temporalio/common/lib/type-helpers';
|
|
4
5
|
import { temporal } from '@temporalio/proto';
|
|
5
6
|
import { WorkflowCancelInput, WorkflowClientCallsInterceptor, WorkflowClientInterceptors, WorkflowDescribeInput, WorkflowQueryInput, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowTerminateInput } from './interceptors';
|
|
6
7
|
import { ConnectionLike, DescribeWorkflowExecutionResponse, Metadata, RequestCancelWorkflowExecutionResponse, TerminateWorkflowExecutionResponse, WorkflowExecution, WorkflowExecutionDescription, WorkflowService } from './types';
|
|
@@ -49,7 +50,17 @@ export interface WorkflowHandle<T extends Workflow = Workflow> extends BaseWorkf
|
|
|
49
50
|
*/
|
|
50
51
|
terminate(reason?: string): Promise<TerminateWorkflowExecutionResponse>;
|
|
51
52
|
/**
|
|
52
|
-
* Cancel a running Workflow
|
|
53
|
+
* Cancel a running Workflow.
|
|
54
|
+
*
|
|
55
|
+
* When a Workflow is cancelled, the root scope throws {@link CancelledFailure} with `message: 'Workflow canceled'`.
|
|
56
|
+
* That means that all cancellable scopes will throw `CancelledFailure`.
|
|
57
|
+
*
|
|
58
|
+
* Cancellation may be propagated to Activities depending on {@link ActivityOptions#cancellationType}, after which
|
|
59
|
+
* Activity calls may throw an {@link ActivityFailure}, and `isCancellation(error)` will be true (see {@link isCancellation}).
|
|
60
|
+
*
|
|
61
|
+
* Cancellation may be propagated to Child Workflows depending on {@link ChildWorkflowOptions#cancellationType}, after
|
|
62
|
+
* which calls to {@link executeChild} and {@link ChildWorkflowHandle#result} will throw, and `isCancellation(error)`
|
|
63
|
+
* will be true (see {@link isCancellation}).
|
|
53
64
|
*/
|
|
54
65
|
cancel(): Promise<RequestCancelWorkflowExecutionResponse>;
|
|
55
66
|
/**
|
|
@@ -86,9 +97,9 @@ export interface WorkflowHandleWithSignaledRunId<T extends Workflow = Workflow>
|
|
|
86
97
|
}
|
|
87
98
|
export interface WorkflowClientOptions {
|
|
88
99
|
/**
|
|
89
|
-
* {@link DataConverter} to use for serializing and deserializing payloads
|
|
100
|
+
* {@link DataConverter} or {@link LoadedDataConverter} to use for serializing and deserializing payloads
|
|
90
101
|
*/
|
|
91
|
-
dataConverter?: DataConverter;
|
|
102
|
+
dataConverter?: DataConverter | LoadedDataConverter;
|
|
92
103
|
/**
|
|
93
104
|
* Used to override and extend default Connection functionality
|
|
94
105
|
*
|
|
@@ -171,7 +182,10 @@ interface WorkflowHandleOptions extends GetWorkflowHandleOptions {
|
|
|
171
182
|
*/
|
|
172
183
|
export declare type WorkflowStartOptions<T extends Workflow = Workflow> = WithWorkflowArgs<T, WorkflowOptions>;
|
|
173
184
|
/**
|
|
174
|
-
* Client for starting Workflow executions and creating Workflow handles
|
|
185
|
+
* Client for starting Workflow executions and creating Workflow handles.
|
|
186
|
+
*
|
|
187
|
+
* Typically this client should not be instantiated directly, instead create the high level {@link Client} and use
|
|
188
|
+
* {@link Client.workflow} to interact with Workflows.
|
|
175
189
|
*/
|
|
176
190
|
export declare class WorkflowClient {
|
|
177
191
|
readonly options: LoadedWorkflowClientOptions;
|
|
@@ -180,9 +194,11 @@ export declare class WorkflowClient {
|
|
|
180
194
|
/**
|
|
181
195
|
* Raw gRPC access to the Temporal service.
|
|
182
196
|
*
|
|
183
|
-
* **NOTE**: The namespace provided in {@link options} is **not** automatically set on requests made
|
|
197
|
+
* **NOTE**: The namespace provided in {@link options} is **not** automatically set on requests made via this service
|
|
198
|
+
* object.
|
|
184
199
|
*/
|
|
185
200
|
get workflowService(): WorkflowService;
|
|
201
|
+
protected get dataConverter(): LoadedDataConverter;
|
|
186
202
|
/**
|
|
187
203
|
* Set the deadline for any service requests executed in `fn`'s scope.
|
|
188
204
|
*/
|
|
@@ -215,12 +231,12 @@ export declare class WorkflowClient {
|
|
|
215
231
|
*/
|
|
216
232
|
start<T extends Workflow>(workflowTypeOrFunc: string | T, options: WorkflowStartOptions<T>): Promise<WorkflowHandleWithFirstExecutionRunId<T>>;
|
|
217
233
|
/**
|
|
218
|
-
* Sends a
|
|
219
|
-
* Useful when you're unsure
|
|
234
|
+
* Sends a Signal to a running Workflow or starts a new one if not already running and immediately Signals it.
|
|
235
|
+
* Useful when you're unsure whether the Workflow has been started.
|
|
220
236
|
*
|
|
221
|
-
* @returns a WorkflowHandle to the started Workflow
|
|
237
|
+
* @returns a {@link WorkflowHandle} to the started Workflow
|
|
222
238
|
*/
|
|
223
|
-
signalWithStart<
|
|
239
|
+
signalWithStart<WorkflowFn extends Workflow, SignalArgs extends any[] = []>(workflowTypeOrFunc: string | WorkflowFn, options: WithWorkflowArgs<WorkflowFn, WorkflowSignalWithStartOptions<SignalArgs>>): Promise<WorkflowHandleWithSignaledRunId<WorkflowFn>>;
|
|
224
240
|
/**
|
|
225
241
|
* Starts a new Workflow execution and awaits its completion.
|
|
226
242
|
*
|