@temporalio/common 1.7.4 → 1.8.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/activity-options.d.ts +18 -10
- package/lib/activity-options.js.map +1 -1
- package/lib/converter/failure-converter.d.ts +5 -3
- package/lib/converter/failure-converter.js +10 -10
- package/lib/converter/failure-converter.js.map +1 -1
- package/lib/converter/payload-converter.js +5 -3
- package/lib/converter/payload-converter.js.map +1 -1
- package/lib/converter/protobuf-payload-converters.js +3 -1
- package/lib/converter/protobuf-payload-converters.js.map +1 -1
- package/lib/deprecated-time.d.ts +5 -5
- package/lib/deprecated-time.js.map +1 -1
- package/lib/errors.d.ts +18 -0
- package/lib/errors.js +26 -1
- package/lib/errors.js.map +1 -1
- package/lib/failure.d.ts +73 -0
- package/lib/failure.js +100 -3
- package/lib/failure.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts +13 -0
- package/lib/logger.js +3 -0
- package/lib/logger.js.map +1 -0
- package/lib/retry-policy.d.ts +3 -2
- package/lib/retry-policy.js.map +1 -1
- package/lib/time.d.ts +10 -4
- package/lib/time.js +9 -5
- package/lib/time.js.map +1 -1
- package/lib/type-helpers.d.ts +8 -0
- package/lib/type-helpers.js +8 -1
- package/lib/type-helpers.js.map +1 -1
- package/lib/versioning-intent.d.ts +18 -0
- package/lib/versioning-intent.js +3 -0
- package/lib/versioning-intent.js.map +1 -0
- package/lib/workflow-options.d.ts +5 -3
- package/lib/workflow-options.js +12 -1
- package/lib/workflow-options.js.map +1 -1
- package/package.json +4 -4
- package/src/activity-options.ts +19 -10
- package/src/converter/failure-converter.ts +15 -13
- package/src/converter/payload-converter.ts +9 -4
- package/src/converter/protobuf-payload-converters.ts +3 -1
- package/src/deprecated-time.ts +5 -5
- package/src/errors.ts +28 -0
- package/src/failure.ts +115 -3
- package/src/index.ts +3 -1
- package/src/logger.ts +15 -0
- package/src/retry-policy.ts +3 -3
- package/src/time.ts +22 -10
- package/src/type-helpers.ts +12 -0
- package/src/versioning-intent.ts +18 -0
- package/src/workflow-options.ts +15 -4
package/lib/failure.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.rootCause = exports.ensureTemporalFailure = exports.ensureApplicationFailure = exports.ChildWorkflowFailure = exports.ActivityFailure = exports.TimeoutFailure = exports.TerminatedFailure = exports.CancelledFailure = exports.ApplicationFailure = exports.ServerFailure = exports.TemporalFailure = exports.RetryState = exports.TimeoutType = exports.FAILURE_SOURCE = void 0;
|
|
4
5
|
const type_helpers_1 = require("./type-helpers");
|
|
@@ -30,6 +31,7 @@ var RetryState;
|
|
|
30
31
|
})(RetryState = exports.RetryState || (exports.RetryState = {}));
|
|
31
32
|
(0, type_helpers_1.checkExtends)();
|
|
32
33
|
(0, type_helpers_1.checkExtends)();
|
|
34
|
+
const isTemporalFailure = Symbol.for('__temporal_isTemporalFailure');
|
|
33
35
|
/**
|
|
34
36
|
* Represents failures that can cross Workflow and Activity boundaries.
|
|
35
37
|
*
|
|
@@ -42,18 +44,42 @@ class TemporalFailure extends Error {
|
|
|
42
44
|
super(message ?? undefined);
|
|
43
45
|
this.cause = cause;
|
|
44
46
|
this.name = 'TemporalFailure';
|
|
47
|
+
/**
|
|
48
|
+
* Marker to determine whether an error is an instance of TemporalFailure.
|
|
49
|
+
*/
|
|
50
|
+
this[_a] = true;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
54
|
+
*/
|
|
55
|
+
static is(error) {
|
|
56
|
+
return error instanceof TemporalFailure || error?.[isTemporalFailure] === true;
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
59
|
exports.TemporalFailure = TemporalFailure;
|
|
60
|
+
_a = isTemporalFailure;
|
|
61
|
+
const isServerFailure = Symbol.for('__temporal_isServerFailure');
|
|
48
62
|
/** Exceptions originated at the Temporal service. */
|
|
49
63
|
class ServerFailure extends TemporalFailure {
|
|
50
64
|
constructor(message, nonRetryable, cause) {
|
|
51
65
|
super(message, cause);
|
|
52
66
|
this.nonRetryable = nonRetryable;
|
|
53
67
|
this.name = 'ServerFailure';
|
|
68
|
+
/**
|
|
69
|
+
* Marker to determine whether an error is an instance of ServerFailure.
|
|
70
|
+
*/
|
|
71
|
+
this[_b] = true;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
75
|
+
*/
|
|
76
|
+
static is(error) {
|
|
77
|
+
return error instanceof ServerFailure || error?.[isServerFailure] === true;
|
|
54
78
|
}
|
|
55
79
|
}
|
|
56
80
|
exports.ServerFailure = ServerFailure;
|
|
81
|
+
_b = isServerFailure;
|
|
82
|
+
const isApplicationFailure = Symbol.for('__temporal_isApplicationFailure');
|
|
57
83
|
/**
|
|
58
84
|
* `ApplicationFailure`s are used to communicate application-specific failures in Workflows and Activities.
|
|
59
85
|
*
|
|
@@ -86,6 +112,16 @@ class ApplicationFailure extends TemporalFailure {
|
|
|
86
112
|
this.nonRetryable = nonRetryable;
|
|
87
113
|
this.details = details;
|
|
88
114
|
this.name = 'ApplicationFailure';
|
|
115
|
+
/**
|
|
116
|
+
* Marker to determine whether an error is an instance of ApplicationFailure.
|
|
117
|
+
*/
|
|
118
|
+
this[_c] = true;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
122
|
+
*/
|
|
123
|
+
static is(error) {
|
|
124
|
+
return error instanceof ApplicationFailure || error?.[isApplicationFailure] === true;
|
|
89
125
|
}
|
|
90
126
|
/**
|
|
91
127
|
* Create a new `ApplicationFailure` from an Error object.
|
|
@@ -133,6 +169,8 @@ class ApplicationFailure extends TemporalFailure {
|
|
|
133
169
|
}
|
|
134
170
|
}
|
|
135
171
|
exports.ApplicationFailure = ApplicationFailure;
|
|
172
|
+
_c = isApplicationFailure;
|
|
173
|
+
const isCancelledFailure = Symbol.for('__temporal_isCancelledFailure');
|
|
136
174
|
/**
|
|
137
175
|
* This error is thrown when Cancellation has been requested. To allow Cancellation to happen, let it propagate. To
|
|
138
176
|
* ignore Cancellation, catch it and continue executing. Note that Cancellation can only be requested a single time, so
|
|
@@ -145,9 +183,21 @@ class CancelledFailure extends TemporalFailure {
|
|
|
145
183
|
super(message, cause);
|
|
146
184
|
this.details = details;
|
|
147
185
|
this.name = 'CancelledFailure';
|
|
186
|
+
/**
|
|
187
|
+
* Marker to determine whether an error is an instance of CancelledFailure.
|
|
188
|
+
*/
|
|
189
|
+
this[_d] = true;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
193
|
+
*/
|
|
194
|
+
static is(error) {
|
|
195
|
+
return error instanceof CancelledFailure || error?.[isCancelledFailure] === true;
|
|
148
196
|
}
|
|
149
197
|
}
|
|
150
198
|
exports.CancelledFailure = CancelledFailure;
|
|
199
|
+
_d = isCancelledFailure;
|
|
200
|
+
const isTerminatedFailure = Symbol.for('__temporal_isTerminatedFailure');
|
|
151
201
|
/**
|
|
152
202
|
* Used as the `cause` when a Workflow has been terminated
|
|
153
203
|
*/
|
|
@@ -155,9 +205,21 @@ class TerminatedFailure extends TemporalFailure {
|
|
|
155
205
|
constructor(message, cause) {
|
|
156
206
|
super(message, cause);
|
|
157
207
|
this.name = 'TerminatedFailure';
|
|
208
|
+
/**
|
|
209
|
+
* Marker to determine whether an error is an instance of TerminatedFailure.
|
|
210
|
+
*/
|
|
211
|
+
this[_e] = true;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
215
|
+
*/
|
|
216
|
+
static is(error) {
|
|
217
|
+
return error instanceof TerminatedFailure || error?.[isTerminatedFailure] === true;
|
|
158
218
|
}
|
|
159
219
|
}
|
|
160
220
|
exports.TerminatedFailure = TerminatedFailure;
|
|
221
|
+
_e = isTerminatedFailure;
|
|
222
|
+
const isTimeoutFailure = Symbol.for('__temporal_isTimeoutFailure');
|
|
161
223
|
/**
|
|
162
224
|
* Used to represent timeouts of Activities and Workflows
|
|
163
225
|
*/
|
|
@@ -167,9 +229,21 @@ class TimeoutFailure extends TemporalFailure {
|
|
|
167
229
|
this.lastHeartbeatDetails = lastHeartbeatDetails;
|
|
168
230
|
this.timeoutType = timeoutType;
|
|
169
231
|
this.name = 'TimeoutFailure';
|
|
232
|
+
/**
|
|
233
|
+
* Marker to determine whether an error is an instance of TimeoutFailure.
|
|
234
|
+
*/
|
|
235
|
+
this[_f] = true;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
239
|
+
*/
|
|
240
|
+
static is(error) {
|
|
241
|
+
return error instanceof TimeoutFailure || error?.[isTimeoutFailure] === true;
|
|
170
242
|
}
|
|
171
243
|
}
|
|
172
244
|
exports.TimeoutFailure = TimeoutFailure;
|
|
245
|
+
_f = isTimeoutFailure;
|
|
246
|
+
const isActivityFailure = Symbol.for('__temporal_isActivityFailure');
|
|
173
247
|
/**
|
|
174
248
|
* Contains information about an Activity failure. Always contains the original reason for the failure as its `cause`.
|
|
175
249
|
* For example, if an Activity timed out, the cause will be a {@link TimeoutFailure}.
|
|
@@ -184,9 +258,21 @@ class ActivityFailure extends TemporalFailure {
|
|
|
184
258
|
this.retryState = retryState;
|
|
185
259
|
this.identity = identity;
|
|
186
260
|
this.name = 'ActivityFailure';
|
|
261
|
+
/**
|
|
262
|
+
* Marker to determine whether an error is an instance of ActivityFailure.
|
|
263
|
+
*/
|
|
264
|
+
this[_g] = true;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
268
|
+
*/
|
|
269
|
+
static is(error) {
|
|
270
|
+
return error instanceof ActivityFailure || error?.[isActivityFailure] === true;
|
|
187
271
|
}
|
|
188
272
|
}
|
|
189
273
|
exports.ActivityFailure = ActivityFailure;
|
|
274
|
+
_g = isActivityFailure;
|
|
275
|
+
const isChildWorkflowFailure = Symbol.for('__temporal_isChildWorkflowFailure');
|
|
190
276
|
/**
|
|
191
277
|
* Contains information about a Child Workflow failure. Always contains the reason for the failure as its {@link cause}.
|
|
192
278
|
* For example, if the Child was Terminated, the `cause` is a {@link TerminatedFailure}.
|
|
@@ -201,9 +287,20 @@ class ChildWorkflowFailure extends TemporalFailure {
|
|
|
201
287
|
this.workflowType = workflowType;
|
|
202
288
|
this.retryState = retryState;
|
|
203
289
|
this.name = 'ChildWorkflowFailure';
|
|
290
|
+
/**
|
|
291
|
+
* Marker to determine whether an error is an instance of ChildWorkflowFailure.
|
|
292
|
+
*/
|
|
293
|
+
this[_h] = true;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Instanceof check that works when multiple versions of @temporalio/common are installed.
|
|
297
|
+
*/
|
|
298
|
+
static is(error) {
|
|
299
|
+
return error instanceof ChildWorkflowFailure || error?.[isChildWorkflowFailure] === true;
|
|
204
300
|
}
|
|
205
301
|
}
|
|
206
302
|
exports.ChildWorkflowFailure = ChildWorkflowFailure;
|
|
303
|
+
_h = isChildWorkflowFailure;
|
|
207
304
|
/**
|
|
208
305
|
* If `error` is already an `ApplicationFailure`, returns `error`.
|
|
209
306
|
*
|
|
@@ -214,7 +311,7 @@ exports.ChildWorkflowFailure = ChildWorkflowFailure;
|
|
|
214
311
|
* - `stack`: `error.stack` or `''`
|
|
215
312
|
*/
|
|
216
313
|
function ensureApplicationFailure(error) {
|
|
217
|
-
if (error
|
|
314
|
+
if (ApplicationFailure.is(error)) {
|
|
218
315
|
return error;
|
|
219
316
|
}
|
|
220
317
|
const message = ((0, type_helpers_1.isRecord)(error) && String(error.message)) || String(error);
|
|
@@ -232,7 +329,7 @@ exports.ensureApplicationFailure = ensureApplicationFailure;
|
|
|
232
329
|
* Otherwise returns an `ApplicationFailure` with `String(err)` as the message.
|
|
233
330
|
*/
|
|
234
331
|
function ensureTemporalFailure(err) {
|
|
235
|
-
if (err
|
|
332
|
+
if (TemporalFailure.is(err)) {
|
|
236
333
|
return err;
|
|
237
334
|
}
|
|
238
335
|
return ensureApplicationFailure(err);
|
|
@@ -245,7 +342,7 @@ exports.ensureTemporalFailure = ensureTemporalFailure;
|
|
|
245
342
|
* Otherwise, return `error.message`.
|
|
246
343
|
*/
|
|
247
344
|
function rootCause(error) {
|
|
248
|
-
if (error
|
|
345
|
+
if (TemporalFailure.is(error)) {
|
|
249
346
|
return error.cause ? rootCause(error.cause) : error.message;
|
|
250
347
|
}
|
|
251
348
|
if (error instanceof Error) {
|
package/lib/failure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.js","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"failure.js","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":";;;;AACA,iDAAwD;AAE3C,QAAA,cAAc,GAAG,eAAe,CAAC;AAG9C,0EAA0E;AAC1E,gDAAgD;AAChD,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,qFAA4B,CAAA;IAC5B,2FAA+B,CAAA;IAC/B,iGAAkC,CAAA;IAClC,iGAAkC,CAAA;IAClC,iFAA0B,CAAA;AAC5B,CAAC,EANW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAMtB;AAED,IAAA,2BAAY,GAAkD,CAAC;AAC/D,IAAA,2BAAY,GAAkD,CAAC;AAE/D,0EAA0E;AAC1E,+CAA+C;AAC/C,IAAY,UASX;AATD,WAAY,UAAU;IACpB,iFAA2B,CAAA;IAC3B,iFAA2B,CAAA;IAC3B,qGAAqC,CAAA;IACrC,yEAAuB,CAAA;IACvB,2GAAwC,CAAA;IACxC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O,CAAC,KAAK,GAAG,CAAC,IAAA,uBAAQ,EAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/D,OAAO,OAAO,CAAC;AACjB,CAAC;AAVD,4DAUC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,GAAY;IAChD,IAAI,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AALD,sDAKC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,IAAI,eAAe,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;QAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;KAC7D;IACD,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,KAAK,CAAC,OAAO,CAAC;KACtB;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC;KACd;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,8BAWC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -14,10 +14,12 @@ export * from './errors';
|
|
|
14
14
|
export * from './failure';
|
|
15
15
|
export { Headers, Next } from './interceptors';
|
|
16
16
|
export * from './interfaces';
|
|
17
|
+
export * from './logger';
|
|
17
18
|
export * from './retry-policy';
|
|
18
|
-
export { Timestamp } from './time';
|
|
19
|
+
export { type Timestamp, Duration, StringValue } from './time';
|
|
19
20
|
export * from './workflow-handle';
|
|
20
21
|
export * from './workflow-options';
|
|
22
|
+
export * from './versioning-intent';
|
|
21
23
|
/**
|
|
22
24
|
* Encode a UTF-8 string into a Uint8Array
|
|
23
25
|
*
|
package/lib/index.js
CHANGED
|
@@ -44,9 +44,11 @@ __exportStar(require("./deprecated-time"), exports);
|
|
|
44
44
|
__exportStar(require("./errors"), exports);
|
|
45
45
|
__exportStar(require("./failure"), exports);
|
|
46
46
|
__exportStar(require("./interfaces"), exports);
|
|
47
|
+
__exportStar(require("./logger"), exports);
|
|
47
48
|
__exportStar(require("./retry-policy"), exports);
|
|
48
49
|
__exportStar(require("./workflow-handle"), exports);
|
|
49
50
|
__exportStar(require("./workflow-options"), exports);
|
|
51
|
+
__exportStar(require("./versioning-intent"), exports);
|
|
50
52
|
/**
|
|
51
53
|
* Encode a UTF-8 string into a Uint8Array
|
|
52
54
|
*
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qDAAuC;AACvC,wDAA0C;AAE1C,qDAAmC;AACnC,6DAA2C;AAC3C,gEAA8C;AAC9C,4DAA0C;AAC1C,gEAA8C;AAC9C,oDAAkC;AAClC,oDAAkC;AAClC,2CAAyB;AACzB,4CAA0B;AAE1B,+CAA6B;AAC7B,iDAA+B;AAE/B,oDAAkC;AAClC,qDAAmC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qDAAuC;AACvC,wDAA0C;AAE1C,qDAAmC;AACnC,6DAA2C;AAC3C,gEAA8C;AAC9C,4DAA0C;AAC1C,gEAA8C;AAC9C,oDAAkC;AAClC,oDAAkC;AAClC,2CAAyB;AACzB,4CAA0B;AAE1B,+CAA6B;AAC7B,2CAAyB;AACzB,iDAA+B;AAE/B,oDAAkC;AAClC,qDAAmC;AACnC,sDAAoC;AAEpC;;;;;GAKG;AACH,SAAgB,EAAE,CAAC,CAAS;IAC1B,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAFD,gBAEC;AAED;;;;;GAKG;AACH,SAAgB,GAAG,CAAC,GAAe;IACjC,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAFD,kBAEC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAFD,oCAEC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAFD,8BAEC"}
|
package/lib/logger.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type LogLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
2
|
+
export type LogMetadata = Record<string | symbol, any>;
|
|
3
|
+
/**
|
|
4
|
+
* Implement this interface in order to customize worker logging
|
|
5
|
+
*/
|
|
6
|
+
export interface Logger {
|
|
7
|
+
log(level: LogLevel, message: string, meta?: LogMetadata): any;
|
|
8
|
+
trace(message: string, meta?: LogMetadata): any;
|
|
9
|
+
debug(message: string, meta?: LogMetadata): any;
|
|
10
|
+
info(message: string, meta?: LogMetadata): any;
|
|
11
|
+
warn(message: string, meta?: LogMetadata): any;
|
|
12
|
+
error(message: string, meta?: LogMetadata): any;
|
|
13
|
+
}
|
package/lib/logger.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":""}
|
package/lib/retry-policy.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { temporal } from '@temporalio/proto';
|
|
2
|
+
import { Duration } from './time';
|
|
2
3
|
/**
|
|
3
4
|
* Options for retrying Workflows and Activities
|
|
4
5
|
*/
|
|
@@ -16,7 +17,7 @@ export interface RetryPolicy {
|
|
|
16
17
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
17
18
|
* @default 1 second
|
|
18
19
|
*/
|
|
19
|
-
initialInterval?:
|
|
20
|
+
initialInterval?: Duration;
|
|
20
21
|
/**
|
|
21
22
|
* Maximum number of attempts. When exceeded, retries stop (even if {@link ActivityOptions.scheduleToCloseTimeout}
|
|
22
23
|
* hasn't been reached).
|
|
@@ -32,7 +33,7 @@ export interface RetryPolicy {
|
|
|
32
33
|
* @default 100x of {@link initialInterval}
|
|
33
34
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
34
35
|
*/
|
|
35
|
-
maximumInterval?:
|
|
36
|
+
maximumInterval?: Duration;
|
|
36
37
|
/**
|
|
37
38
|
* List of application failures types to not retry.
|
|
38
39
|
*/
|
package/lib/retry-policy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-policy.js","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":";;;AACA,qCAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"retry-policy.js","sourceRoot":"","sources":["../src/retry-policy.ts"],"names":[],"mappings":";;;AACA,qCAAsC;AACtC,iCAA0G;AA2C1G;;GAEG;AACH,SAAgB,kBAAkB,CAAC,WAAwB;IACzD,IAAI,WAAW,CAAC,kBAAkB,IAAI,IAAI,IAAI,WAAW,CAAC,kBAAkB,IAAI,CAAC,EAAE;QACjF,MAAM,IAAI,mBAAU,CAAC,uDAAuD,CAAC,CAAC;KAC/E;IACD,IAAI,WAAW,CAAC,eAAe,IAAI,IAAI,EAAE;QACvC,IAAI,WAAW,CAAC,eAAe,KAAK,MAAM,CAAC,iBAAiB,EAAE;YAC5D,uCAAuC;YACvC,MAAM,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,WAAW,CAAC;YACvD,WAAW,GAAG,OAAO,CAAC;SACvB;aAAM,IA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AAe,CAAC;QAC5D,eAAe,EAAE,IAAA,qBAAc,EAAC,WAAW,CAAC,eAAe,CAAC;QAC5D,sBAAsB,EAAE,WAAW,CAAC,sBAAsB,IAAI,SAAS;KACxE,CAAC;AACJ,CAAC;AAdD,oDAcC"}
|
package/lib/time.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { StringValue } from 'ms';
|
|
1
2
|
import type { google } from '@temporalio/proto';
|
|
2
3
|
export type Timestamp = google.protobuf.ITimestamp;
|
|
4
|
+
/**
|
|
5
|
+
* A duration, expressed either as a number of milliseconds, or as a {@link https://www.npmjs.com/package/ms | ms-formatted string}.
|
|
6
|
+
*/
|
|
7
|
+
export type Duration = StringValue | number;
|
|
8
|
+
export type { StringValue } from 'ms';
|
|
3
9
|
/**
|
|
4
10
|
* Lossy conversion function from Timestamp to number due to possible overflow.
|
|
5
11
|
* If ts is null or undefined returns undefined.
|
|
@@ -10,10 +16,10 @@ export declare function optionalTsToMs(ts: Timestamp | null | undefined): number
|
|
|
10
16
|
*/
|
|
11
17
|
export declare function tsToMs(ts: Timestamp | null | undefined): number;
|
|
12
18
|
export declare function msNumberToTs(millis: number): Timestamp;
|
|
13
|
-
export declare function msToTs(str:
|
|
14
|
-
export declare function msOptionalToTs(str:
|
|
15
|
-
export declare function msOptionalToNumber(val:
|
|
16
|
-
export declare function msToNumber(val:
|
|
19
|
+
export declare function msToTs(str: Duration): Timestamp;
|
|
20
|
+
export declare function msOptionalToTs(str: Duration | undefined): Timestamp | undefined;
|
|
21
|
+
export declare function msOptionalToNumber(val: Duration | undefined): number | undefined;
|
|
22
|
+
export declare function msToNumber(val: Duration): number;
|
|
17
23
|
export declare function tsToDate(ts: Timestamp): Date;
|
|
18
24
|
export declare function optionalTsToDate(ts: Timestamp | null | undefined): Date | undefined;
|
|
19
25
|
export declare function optionalDateToTs(date: Date | null | undefined): Timestamp | undefined;
|
package/lib/time.js
CHANGED
|
@@ -43,10 +43,7 @@ function msNumberToTs(millis) {
|
|
|
43
43
|
}
|
|
44
44
|
exports.msNumberToTs = msNumberToTs;
|
|
45
45
|
function msToTs(str) {
|
|
46
|
-
|
|
47
|
-
return msNumberToTs(str);
|
|
48
|
-
}
|
|
49
|
-
return msNumberToTs((0, ms_1.default)(str));
|
|
46
|
+
return msNumberToTs(msToNumber(str));
|
|
50
47
|
}
|
|
51
48
|
exports.msToTs = msToTs;
|
|
52
49
|
function msOptionalToTs(str) {
|
|
@@ -63,9 +60,16 @@ function msToNumber(val) {
|
|
|
63
60
|
if (typeof val === 'number') {
|
|
64
61
|
return val;
|
|
65
62
|
}
|
|
66
|
-
return (
|
|
63
|
+
return msWithValidation(val);
|
|
67
64
|
}
|
|
68
65
|
exports.msToNumber = msToNumber;
|
|
66
|
+
function msWithValidation(str) {
|
|
67
|
+
const millis = (0, ms_1.default)(str);
|
|
68
|
+
if (millis == null || isNaN(millis)) {
|
|
69
|
+
throw new TypeError(`Invalid duration string: '${str}'`);
|
|
70
|
+
}
|
|
71
|
+
return millis;
|
|
72
|
+
}
|
|
69
73
|
function tsToDate(ts) {
|
|
70
74
|
return new Date(tsToMs(ts));
|
|
71
75
|
}
|
package/lib/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAsD;AACtD,gDAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAsD;AACtD,gDAAwB;AACxB,4CAAqC;AAErC,qCAAsC;AAgBtC;;;GAGG;AACH,SAAgB,cAAc,CAAC,EAAgC;IAC7D,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC;AALD,wCAKC;AAED;;GAEG;AACH,SAAgB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,OAAO,SAAS,CAAC;IACxC,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAHD,gDAGC;AAED,SAAgB,UAAU,CAAC,GAAa;IACtC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AALD,gCAKC;AAED,SAAS,gBAAgB,CAAC,GAAgB;IACxC,MAAM,MAAM,GAAG,IAAA,YAAE,EAAC,GAAG,CAAC,CAAC;IACvB,IAAI,MAAM,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;QACnC,MAAM,IAAI,SAAS,CAAC,6BAA6B,GAAG,GAAG,CAAC,CAAC;KAC1D;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,QAAQ,CAAC,EAAa;IACpC,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC;AAFD,4BAEC;AAED,SAAgB,gBAAgB,CAAC,EAAgC;IAC/D,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC;AALD,4CAKC;AAED,0DAA0D;AAC1D,SAAgB,gBAAgB,CAAC,IAA6B;IAC5D,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE;QACvC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAChC,CAAC;AALD,4CAKC"}
|
package/lib/type-helpers.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export type AnyFunc = (...args: any[]) => any;
|
|
|
4
4
|
export type OmitLast<T> = T extends [...infer REST, any] ? REST : never;
|
|
5
5
|
/** F with all arguments but the last */
|
|
6
6
|
export type OmitLastParam<F extends AnyFunc> = (...args: OmitLast<Parameters<F>>) => ReturnType<F>;
|
|
7
|
+
/** Require that T has at least one of the provided properties defined */
|
|
8
|
+
export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
|
|
9
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
10
|
+
}[Keys];
|
|
7
11
|
/** Verify that an type _Copy extends _Orig */
|
|
8
12
|
export declare function checkExtends<_Orig, _Copy extends _Orig>(): void;
|
|
9
13
|
export type Replace<Base, New> = Omit<Base, keyof New> & New;
|
|
@@ -18,3 +22,7 @@ export declare function errorMessage(error: unknown): string | undefined;
|
|
|
18
22
|
* Get `error.code` (or `undefined` if not present)
|
|
19
23
|
*/
|
|
20
24
|
export declare function errorCode(error: unknown): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Asserts that some type is the never type
|
|
27
|
+
*/
|
|
28
|
+
export declare function assertNever(msg: string, x: never): never;
|
package/lib/type-helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorCode = exports.errorMessage = exports.hasOwnProperties = exports.hasOwnProperty = exports.isRecord = exports.checkExtends = void 0;
|
|
3
|
+
exports.assertNever = exports.errorCode = exports.errorMessage = exports.hasOwnProperties = exports.hasOwnProperty = exports.isRecord = exports.checkExtends = void 0;
|
|
4
4
|
/** Verify that an type _Copy extends _Orig */
|
|
5
5
|
function checkExtends() {
|
|
6
6
|
// noop, just type check
|
|
@@ -44,4 +44,11 @@ function errorCode(error) {
|
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
46
|
exports.errorCode = errorCode;
|
|
47
|
+
/**
|
|
48
|
+
* Asserts that some type is the never type
|
|
49
|
+
*/
|
|
50
|
+
function assertNever(msg, x) {
|
|
51
|
+
throw new TypeError(msg + ': ' + x);
|
|
52
|
+
}
|
|
53
|
+
exports.assertNever = assertNever;
|
|
47
54
|
//# sourceMappingURL=type-helpers.js.map
|
package/lib/type-helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-helpers.js","sourceRoot":"","sources":["../src/type-helpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"type-helpers.js","sourceRoot":"","sources":["../src/type-helpers.ts"],"names":[],"mappings":";;;AAYA,8CAA8C;AAC9C,SAAgB,YAAY;IAC1B,wBAAwB;AAC1B,CAAC;AAFD,oCAEC;AAID,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAFD,4BAEC;AAED,uBAAuB;AACvB,SAAgB,cAAc,CAC5B,MAAS,EACT,IAAO;IAEP,OAAO,IAAI,IAAI,MAAM,CAAC;AACxB,CAAC;AALD,wCAKC;AAED,SAAgB,gBAAgB,CAC9B,MAAS,EACT,KAAU;IAEV,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC;AAC/C,CAAC;AALD,4CAKC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAc;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC;KACd;IACD,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,KAAK,CAAC,OAAO,CAAC;KACtB;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AARD,oCAQC;AAKD;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,IACE,OAAO,KAAK,KAAK,QAAQ;QACxB,KAAuB,CAAC,IAAI,KAAK,SAAS;QAC3C,OAAQ,KAAuB,CAAC,IAAI,KAAK,QAAQ,EACjD;QACA,OAAQ,KAAuB,CAAC,IAAI,CAAC;KACtC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAVD,8BAUC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,GAAW,EAAE,CAAQ;IAC/C,MAAM,IAAI,SAAS,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC;AAFD,kCAEC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indicates whether the user intends certain commands to be run on a compatible worker Build Id
|
|
3
|
+
* version or not.
|
|
4
|
+
*
|
|
5
|
+
* `COMPATIBLE` indicates that the command should run on a worker with compatible version if
|
|
6
|
+
* possible. It may not be possible if the target task queue does not also have knowledge of the
|
|
7
|
+
* current worker's Build Id.
|
|
8
|
+
*
|
|
9
|
+
* `DEFAULT` indicates that the command should run on the target task queue's current
|
|
10
|
+
* overall-default Build Id.
|
|
11
|
+
*
|
|
12
|
+
* Where this type is accepted optionally, an unset value indicates that the SDK should choose the
|
|
13
|
+
* most sensible default behavior for the type of command, accounting for whether the command will
|
|
14
|
+
* be run on the same task queue as the current worker.
|
|
15
|
+
*
|
|
16
|
+
* @experimental
|
|
17
|
+
*/
|
|
18
|
+
export type VersioningIntent = 'COMPATIBLE' | 'DEFAULT';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versioning-intent.js","sourceRoot":"","sources":["../src/versioning-intent.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { google } from '@temporalio/proto';
|
|
2
2
|
import { SearchAttributes, Workflow } from './interfaces';
|
|
3
3
|
import { RetryPolicy } from './retry-policy';
|
|
4
|
+
import { Duration } from './time';
|
|
4
5
|
import { Replace } from './type-helpers';
|
|
5
6
|
/**
|
|
6
7
|
* Concept: {@link https://docs.temporal.io/concepts/what-is-a-workflow-id-reuse-policy/ | Workflow Id Reuse Policy}
|
|
@@ -92,7 +93,7 @@ export interface WorkflowDurationOptions {
|
|
|
92
93
|
*
|
|
93
94
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
94
95
|
*/
|
|
95
|
-
workflowRunTimeout?:
|
|
96
|
+
workflowRunTimeout?: Duration;
|
|
96
97
|
/**
|
|
97
98
|
*
|
|
98
99
|
* The time after which workflow execution (which includes run retries and continue as new) is
|
|
@@ -101,13 +102,13 @@ export interface WorkflowDurationOptions {
|
|
|
101
102
|
*
|
|
102
103
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
103
104
|
*/
|
|
104
|
-
workflowExecutionTimeout?:
|
|
105
|
+
workflowExecutionTimeout?: Duration;
|
|
105
106
|
/**
|
|
106
107
|
* Maximum execution time of a single workflow task. Default is 10 seconds.
|
|
107
108
|
*
|
|
108
109
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
109
110
|
*/
|
|
110
|
-
workflowTaskTimeout?:
|
|
111
|
+
workflowTaskTimeout?: Duration;
|
|
111
112
|
}
|
|
112
113
|
export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions;
|
|
113
114
|
export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<T, {
|
|
@@ -116,3 +117,4 @@ export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Repla
|
|
|
116
117
|
workflowTaskTimeout?: google.protobuf.IDuration;
|
|
117
118
|
}>;
|
|
118
119
|
export declare function compileWorkflowOptions<T extends CommonWorkflowOptions>(options: T): WithCompiledWorkflowOptions<T>;
|
|
120
|
+
export declare function extractWorkflowType<T extends Workflow>(workflowTypeOrFunc: string | T): string;
|
package/lib/workflow-options.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compileWorkflowOptions = exports.WorkflowIdReusePolicy = void 0;
|
|
3
|
+
exports.extractWorkflowType = exports.compileWorkflowOptions = exports.WorkflowIdReusePolicy = void 0;
|
|
4
4
|
const time_1 = require("./time");
|
|
5
5
|
const type_helpers_1 = require("./type-helpers");
|
|
6
6
|
// Avoid importing the proto implementation to reduce workflow bundle size
|
|
@@ -50,4 +50,15 @@ function compileWorkflowOptions(options) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
exports.compileWorkflowOptions = compileWorkflowOptions;
|
|
53
|
+
function extractWorkflowType(workflowTypeOrFunc) {
|
|
54
|
+
if (typeof workflowTypeOrFunc === 'string')
|
|
55
|
+
return workflowTypeOrFunc;
|
|
56
|
+
if (typeof workflowTypeOrFunc === 'function') {
|
|
57
|
+
if (workflowTypeOrFunc?.name)
|
|
58
|
+
return workflowTypeOrFunc.name;
|
|
59
|
+
throw new TypeError('Invalid workflow type: the workflow function is anonymous');
|
|
60
|
+
}
|
|
61
|
+
throw new TypeError(`Invalid workflow type: expected either a string or a function, got '${typeof workflowTypeOrFunc}'`);
|
|
62
|
+
}
|
|
63
|
+
exports.extractWorkflowType = extractWorkflowType;
|
|
53
64
|
//# sourceMappingURL=workflow-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-options.js","sourceRoot":"","sources":["../src/workflow-options.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"workflow-options.js","sourceRoot":"","sources":["../src/workflow-options.ts"],"names":[],"mappings":";;;AAGA,iCAAkD;AAClD,iDAAuD;AAEvD,0EAA0E;AAC1E,0DAA0D;AAC1D;;;;;;GAMG;AACH,IAAY,qBA4BX;AA5BD,WAAY,qBAAqB;IAC/B;;;;OAIG;IACH,iIAAwC,CAAA;IAExC;;;OAGG;IACH,yIAA4C,CAAA;IAE5C;;OAEG;IACH,iKAAwD,CAAA;IAExD;;OAEG;IACH,2IAA6C,CAAA;IAE7C;;OAEG;IACH,mJAAiD,CAAA;AACnD,CAAC,EA5BW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QA4BhC;AAED,IAAA,2BAAY,GAAsE,CAAC;AACnF,IAAA,2BAAY,GAAsE,CAAC;AAoGnF,SAAgB,sBAAsB,CAAkC,OAAU;IAChF,MAAM,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE/F,OAAO;QACL,GAAG,IAAI;QACP,wBAAwB,EAAE,IAAA,qBAAc,EAAC,wBAAwB,CAAC;QAClE,kBAAkB,EAAE,IAAA,qBAAc,EAAC,kBAAkB,CAAC;QACtD,mBAAmB,EAAE,IAAA,qBAAc,EAAC,mBAAmB,CAAC;KACzD,CAAC;AACJ,CAAC;AATD,wDASC;AAED,SAAgB,mBAAmB,CAAqB,kBAA8B;IACpF,IAAI,OAAO,kBAAkB,KAAK,QAAQ;QAAE,OAAO,kBAA4B,CAAC;IAChF,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE;QAC5C,IAAI,kBAAkB,EAAE,IAAI;YAAE,OAAO,kBAAkB,CAAC,IAAI,CAAC;QAC7D,MAAM,IAAI,SAAS,CAAC,2DAA2D,CAAC,CAAC;KAClF;IACD,MAAM,IAAI,SAAS,CACjB,uEAAuE,OAAO,kBAAkB,GAAG,CACpG,CAAC;AACJ,CAAC;AATD,kDASC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.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,9 +13,9 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@opentelemetry/api": "^1.4.1",
|
|
16
|
-
"@temporalio/proto": "1.
|
|
16
|
+
"@temporalio/proto": "1.8.1",
|
|
17
17
|
"long": "^5.2.0",
|
|
18
|
-
"ms": "^
|
|
18
|
+
"ms": "^3.0.0-canary.1",
|
|
19
19
|
"proto3-json-serializer": "^1.0.3",
|
|
20
20
|
"protobufjs": "^7.0.0"
|
|
21
21
|
},
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"src",
|
|
36
36
|
"lib"
|
|
37
37
|
],
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "97808111bbec478260e915726bb9730a489f8fa4"
|
|
39
39
|
}
|