@temporalio/common 0.17.2 → 0.19.0-rc.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/README.md +5 -11
- package/lib/converter/data-converter.d.ts +34 -62
- package/lib/converter/data-converter.js +0 -101
- package/lib/converter/data-converter.js.map +1 -1
- package/lib/{encoding.d.ts → converter/encoding.d.ts} +0 -0
- package/lib/{encoding.js → converter/encoding.js} +0 -0
- package/lib/converter/encoding.js.map +1 -0
- package/lib/converter/patch-protobuf-root.d.ts +8 -0
- package/lib/converter/patch-protobuf-root.js +43 -0
- package/lib/converter/patch-protobuf-root.js.map +1 -0
- package/lib/converter/payload-codec.d.ts +27 -0
- package/lib/converter/payload-codec.js +11 -0
- package/lib/converter/payload-codec.js.map +1 -0
- package/lib/converter/payload-converter.d.ts +63 -62
- package/lib/converter/payload-converter.js +113 -68
- package/lib/converter/payload-converter.js.map +1 -1
- package/lib/converter/payload-converters.d.ts +31 -0
- package/lib/converter/payload-converters.js +85 -0
- package/lib/converter/payload-converters.js.map +1 -0
- package/lib/converter/protobuf-payload-converters.d.ts +53 -0
- package/lib/converter/protobuf-payload-converters.js +159 -0
- package/lib/converter/protobuf-payload-converters.js.map +1 -0
- package/lib/converter/types.d.ts +2 -0
- package/lib/converter/types.js +3 -2
- package/lib/converter/types.js.map +1 -1
- package/lib/failure.d.ts +6 -6
- package/lib/failure.js +37 -35
- package/lib/failure.js.map +1 -1
- package/lib/index.d.ts +9 -11
- package/lib/index.js +12 -16
- package/lib/index.js.map +1 -1
- package/lib/protobufs.d.ts +13 -0
- package/lib/protobufs.js +31 -0
- package/lib/protobufs.js.map +1 -0
- package/package.json +11 -8
- package/src/converter/data-converter.ts +35 -176
- package/src/{encoding.ts → converter/encoding.ts} +0 -0
- package/src/converter/patch-protobuf-root.ts +49 -0
- package/src/converter/payload-codec.ts +30 -0
- package/src/converter/payload-converter.ts +122 -102
- package/src/converter/payload-converters.ts +89 -0
- package/src/converter/protobuf-payload-converters.ts +192 -0
- package/src/converter/types.ts +4 -1
- package/src/failure.ts +44 -43
- package/src/index.ts +9 -11
- package/src/protobufs.ts +15 -0
- package/tsconfig.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/activity-options.d.ts +0 -81
- package/lib/activity-options.js +0 -14
- package/lib/activity-options.js.map +0 -1
- package/lib/encoding.js.map +0 -1
- package/lib/errors.d.ts +0 -16
- package/lib/errors.js +0 -41
- package/lib/errors.js.map +0 -1
- package/lib/interceptors.d.ts +0 -18
- package/lib/interceptors.js +0 -24
- package/lib/interceptors.js.map +0 -1
- package/lib/interfaces.d.ts +0 -31
- package/lib/interfaces.js +0 -3
- package/lib/interfaces.js.map +0 -1
- package/lib/otel.d.ts +0 -26
- package/lib/otel.js +0 -82
- package/lib/otel.js.map +0 -1
- package/lib/retry-policy.d.ts +0 -43
- package/lib/retry-policy.js +0 -36
- package/lib/retry-policy.js.map +0 -1
- package/lib/time.d.ts +0 -16
- package/lib/time.js +0 -73
- package/lib/time.js.map +0 -1
- package/lib/tls-config.d.ts +0 -32
- package/lib/tls-config.js +0 -11
- package/lib/tls-config.js.map +0 -1
- package/lib/type-helpers.d.ts +0 -8
- package/lib/type-helpers.js +0 -9
- package/lib/type-helpers.js.map +0 -1
- package/lib/utils.d.ts +0 -4
- package/lib/utils.js +0 -11
- package/lib/utils.js.map +0 -1
- package/lib/workflow-handle.d.ts +0 -27
- package/lib/workflow-handle.js +0 -3
- package/lib/workflow-handle.js.map +0 -1
- package/lib/workflow-options.d.ts +0 -91
- package/lib/workflow-options.js +0 -26
- package/lib/workflow-options.js.map +0 -1
- package/src/activity-options.ts +0 -97
- package/src/errors.ts +0 -27
- package/src/interceptors.ts +0 -32
- package/src/interfaces.ts +0 -37
- package/src/otel.ts +0 -61
- package/src/retry-policy.ts +0 -73
- package/src/time.ts +0 -72
- package/src/tls-config.ts +0 -35
- package/src/type-helpers.ts +0 -11
- package/src/utils.ts +0 -6
- package/src/workflow-handle.ts +0 -30
- package/src/workflow-options.ts +0 -127
package/lib/failure.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rootCause = exports.failureToError = exports.failureToErrorInner = exports.optionalFailureToOptionalError = exports.ensureTemporalFailure = exports.errorToFailure = exports.cutoffStackTrace = exports.optionalErrorToOptionalFailure = 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
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const internal_workflow_common_1 = require("@temporalio/internal-workflow-common");
|
|
5
|
+
const payload_converter_1 = require("./converter/payload-converter");
|
|
6
6
|
exports.FAILURE_SOURCE = 'TypeScriptSDK';
|
|
7
7
|
// Avoid importing the proto implementation to reduce workflow bundle size
|
|
8
8
|
// Copied from temporal.api.enums.v1.TimeoutType
|
|
@@ -14,7 +14,7 @@ var TimeoutType;
|
|
|
14
14
|
TimeoutType[TimeoutType["TIMEOUT_TYPE_SCHEDULE_TO_CLOSE"] = 3] = "TIMEOUT_TYPE_SCHEDULE_TO_CLOSE";
|
|
15
15
|
TimeoutType[TimeoutType["TIMEOUT_TYPE_HEARTBEAT"] = 4] = "TIMEOUT_TYPE_HEARTBEAT";
|
|
16
16
|
})(TimeoutType = exports.TimeoutType || (exports.TimeoutType = {}));
|
|
17
|
-
(0,
|
|
17
|
+
(0, internal_workflow_common_1.checkExtends)();
|
|
18
18
|
// Avoid importing the proto implementation to reduce workflow bundle size
|
|
19
19
|
// Copied from temporal.api.enums.v1.RetryState
|
|
20
20
|
var RetryState;
|
|
@@ -28,7 +28,7 @@ var RetryState;
|
|
|
28
28
|
RetryState[RetryState["RETRY_STATE_INTERNAL_SERVER_ERROR"] = 6] = "RETRY_STATE_INTERNAL_SERVER_ERROR";
|
|
29
29
|
RetryState[RetryState["RETRY_STATE_CANCEL_REQUESTED"] = 7] = "RETRY_STATE_CANCEL_REQUESTED";
|
|
30
30
|
})(RetryState = exports.RetryState || (exports.RetryState = {}));
|
|
31
|
-
(0,
|
|
31
|
+
(0, internal_workflow_common_1.checkExtends)();
|
|
32
32
|
/**
|
|
33
33
|
* Represents failures that can cross Workflow and Activity boundaries.
|
|
34
34
|
*
|
|
@@ -186,14 +186,14 @@ exports.ChildWorkflowFailure = ChildWorkflowFailure;
|
|
|
186
186
|
/**
|
|
187
187
|
* Converts an error to a Failure proto message if defined or returns undefined
|
|
188
188
|
*/
|
|
189
|
-
|
|
190
|
-
return err ?
|
|
189
|
+
function optionalErrorToOptionalFailure(err, payloadConverter) {
|
|
190
|
+
return err ? errorToFailure(err, payloadConverter) : undefined;
|
|
191
191
|
}
|
|
192
192
|
exports.optionalErrorToOptionalFailure = optionalErrorToOptionalFailure;
|
|
193
193
|
/**
|
|
194
194
|
* Stack traces will be cutoff when on of these patterns is matched
|
|
195
195
|
*/
|
|
196
|
-
const
|
|
196
|
+
const CUTOFF_STACK_PATTERNS = [
|
|
197
197
|
/** Activity execution */
|
|
198
198
|
/\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,
|
|
199
199
|
/** Workflow activation */
|
|
@@ -206,7 +206,7 @@ function cutoffStackTrace(stack) {
|
|
|
206
206
|
const lines = (stack ?? '').split(/\r?\n/);
|
|
207
207
|
const acc = Array();
|
|
208
208
|
lineLoop: for (const line of lines) {
|
|
209
|
-
for (const pattern of
|
|
209
|
+
for (const pattern of CUTOFF_STACK_PATTERNS) {
|
|
210
210
|
if (pattern.test(line))
|
|
211
211
|
break lineLoop;
|
|
212
212
|
}
|
|
@@ -218,14 +218,14 @@ exports.cutoffStackTrace = cutoffStackTrace;
|
|
|
218
218
|
/**
|
|
219
219
|
* Converts a caught error to a Failure proto message
|
|
220
220
|
*/
|
|
221
|
-
|
|
221
|
+
function errorToFailure(err, payloadConverter) {
|
|
222
222
|
if (err instanceof TemporalFailure) {
|
|
223
223
|
if (err.failure)
|
|
224
224
|
return err.failure;
|
|
225
225
|
const base = {
|
|
226
226
|
message: err.message,
|
|
227
227
|
stackTrace: cutoffStackTrace(err.stack),
|
|
228
|
-
cause:
|
|
228
|
+
cause: optionalErrorToOptionalFailure(err.cause, payloadConverter),
|
|
229
229
|
source: exports.FAILURE_SOURCE,
|
|
230
230
|
};
|
|
231
231
|
if (err instanceof ActivityFailure) {
|
|
@@ -253,9 +253,7 @@ async function errorToFailure(err, dataConverter) {
|
|
|
253
253
|
applicationFailureInfo: {
|
|
254
254
|
type: err.type,
|
|
255
255
|
nonRetryable: err.nonRetryable,
|
|
256
|
-
details: err.details && err.details.length
|
|
257
|
-
? { payloads: await dataConverter.toPayloads(...err.details) }
|
|
258
|
-
: undefined,
|
|
256
|
+
details: err.details && err.details.length ? { payloads: (0, payload_converter_1.toPayloads)(payloadConverter, ...err.details) } : undefined,
|
|
259
257
|
},
|
|
260
258
|
};
|
|
261
259
|
}
|
|
@@ -263,9 +261,7 @@ async function errorToFailure(err, dataConverter) {
|
|
|
263
261
|
return {
|
|
264
262
|
...base,
|
|
265
263
|
canceledFailureInfo: {
|
|
266
|
-
details: err.details && err.details.length
|
|
267
|
-
? { payloads: await dataConverter.toPayloads(...err.details) }
|
|
268
|
-
: undefined,
|
|
264
|
+
details: err.details && err.details.length ? { payloads: (0, payload_converter_1.toPayloads)(payloadConverter, ...err.details) } : undefined,
|
|
269
265
|
},
|
|
270
266
|
};
|
|
271
267
|
}
|
|
@@ -275,7 +271,7 @@ async function errorToFailure(err, dataConverter) {
|
|
|
275
271
|
timeoutFailureInfo: {
|
|
276
272
|
timeoutType: err.timeoutType,
|
|
277
273
|
lastHeartbeatDetails: err.lastHeartbeatDetails
|
|
278
|
-
? { payloads:
|
|
274
|
+
? { payloads: (0, payload_converter_1.toPayloads)(payloadConverter, err.lastHeartbeatDetails) }
|
|
279
275
|
: undefined,
|
|
280
276
|
},
|
|
281
277
|
};
|
|
@@ -298,13 +294,19 @@ async function errorToFailure(err, dataConverter) {
|
|
|
298
294
|
const base = {
|
|
299
295
|
source: exports.FAILURE_SOURCE,
|
|
300
296
|
};
|
|
301
|
-
if (err
|
|
302
|
-
return {
|
|
297
|
+
if ((0, internal_workflow_common_1.isRecord)(err) && (0, internal_workflow_common_1.hasOwnProperties)(err, ['message', 'stack'])) {
|
|
298
|
+
return {
|
|
299
|
+
...base,
|
|
300
|
+
message: String(err.message) ?? '',
|
|
301
|
+
stackTrace: cutoffStackTrace(String(err.stack)),
|
|
302
|
+
cause: optionalErrorToOptionalFailure(err.cause, payloadConverter),
|
|
303
|
+
};
|
|
303
304
|
}
|
|
305
|
+
const recommendation = ` [A non-Error value was thrown from your code. We recommend throwing Error objects so that we can provide a stack trace.]`;
|
|
304
306
|
if (typeof err === 'string') {
|
|
305
|
-
return { ...base, message: err };
|
|
307
|
+
return { ...base, message: err + recommendation };
|
|
306
308
|
}
|
|
307
|
-
return { ...base, message:
|
|
309
|
+
return { ...base, message: JSON.stringify(err) + recommendation };
|
|
308
310
|
}
|
|
309
311
|
exports.errorToFailure = errorToFailure;
|
|
310
312
|
/**
|
|
@@ -333,8 +335,8 @@ exports.ensureTemporalFailure = ensureTemporalFailure;
|
|
|
333
335
|
/**
|
|
334
336
|
* Converts a Failure proto message to a JS Error object if defined or returns undefined.
|
|
335
337
|
*/
|
|
336
|
-
|
|
337
|
-
return failure ?
|
|
338
|
+
function optionalFailureToOptionalError(failure, payloadConverter) {
|
|
339
|
+
return failure ? failureToError(failure, payloadConverter) : undefined;
|
|
338
340
|
}
|
|
339
341
|
exports.optionalFailureToOptionalError = optionalFailureToOptionalError;
|
|
340
342
|
/**
|
|
@@ -342,46 +344,46 @@ exports.optionalFailureToOptionalError = optionalFailureToOptionalError;
|
|
|
342
344
|
*
|
|
343
345
|
* Does not set common properties, that is done in {@link failureToError}.
|
|
344
346
|
*/
|
|
345
|
-
|
|
347
|
+
function failureToErrorInner(failure, payloadConverter) {
|
|
346
348
|
if (failure.applicationFailureInfo) {
|
|
347
|
-
return new ApplicationFailure(failure.message ?? undefined, failure.applicationFailureInfo.type, Boolean(failure.applicationFailureInfo.nonRetryable),
|
|
349
|
+
return new ApplicationFailure(failure.message ?? undefined, failure.applicationFailureInfo.type, Boolean(failure.applicationFailureInfo.nonRetryable), (0, payload_converter_1.arrayFromPayloads)(payloadConverter, failure.applicationFailureInfo.details?.payloads), optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
348
350
|
}
|
|
349
351
|
if (failure.serverFailureInfo) {
|
|
350
|
-
return new ServerFailure(failure.message ?? undefined, Boolean(failure.serverFailureInfo.nonRetryable),
|
|
352
|
+
return new ServerFailure(failure.message ?? undefined, Boolean(failure.serverFailureInfo.nonRetryable), optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
351
353
|
}
|
|
352
354
|
if (failure.timeoutFailureInfo) {
|
|
353
|
-
return new TimeoutFailure(failure.message ?? undefined,
|
|
355
|
+
return new TimeoutFailure(failure.message ?? undefined, (0, payload_converter_1.fromPayloadsAtIndex)(payloadConverter, 0, failure.timeoutFailureInfo.lastHeartbeatDetails?.payloads), failure.timeoutFailureInfo.timeoutType ?? TimeoutType.TIMEOUT_TYPE_UNSPECIFIED);
|
|
354
356
|
}
|
|
355
357
|
if (failure.terminatedFailureInfo) {
|
|
356
|
-
return new TerminatedFailure(failure.message ?? undefined,
|
|
358
|
+
return new TerminatedFailure(failure.message ?? undefined, optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
357
359
|
}
|
|
358
360
|
if (failure.canceledFailureInfo) {
|
|
359
|
-
return new CancelledFailure(failure.message ?? undefined,
|
|
361
|
+
return new CancelledFailure(failure.message ?? undefined, (0, payload_converter_1.arrayFromPayloads)(payloadConverter, failure.canceledFailureInfo.details?.payloads), optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
360
362
|
}
|
|
361
363
|
if (failure.resetWorkflowFailureInfo) {
|
|
362
|
-
return new ApplicationFailure(failure.message ?? undefined, 'ResetWorkflow', false,
|
|
364
|
+
return new ApplicationFailure(failure.message ?? undefined, 'ResetWorkflow', false, (0, payload_converter_1.arrayFromPayloads)(payloadConverter, failure.resetWorkflowFailureInfo.lastHeartbeatDetails?.payloads), optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
363
365
|
}
|
|
364
366
|
if (failure.childWorkflowExecutionFailureInfo) {
|
|
365
367
|
const { namespace, workflowType, workflowExecution, retryState } = failure.childWorkflowExecutionFailureInfo;
|
|
366
368
|
if (!(workflowType?.name && workflowExecution)) {
|
|
367
369
|
throw new TypeError('Missing attributes on childWorkflowExecutionFailureInfo');
|
|
368
370
|
}
|
|
369
|
-
return new ChildWorkflowFailure(namespace ?? undefined, workflowExecution, workflowType.name, retryState ?? RetryState.RETRY_STATE_UNSPECIFIED,
|
|
371
|
+
return new ChildWorkflowFailure(namespace ?? undefined, workflowExecution, workflowType.name, retryState ?? RetryState.RETRY_STATE_UNSPECIFIED, optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
370
372
|
}
|
|
371
373
|
if (failure.activityFailureInfo) {
|
|
372
374
|
if (!failure.activityFailureInfo.activityType?.name) {
|
|
373
375
|
throw new TypeError('Missing activityType?.name on activityFailureInfo');
|
|
374
376
|
}
|
|
375
|
-
return new ActivityFailure(failure.activityFailureInfo.activityType.name, failure.activityFailureInfo.activityId ?? undefined, failure.activityFailureInfo.retryState ?? RetryState.RETRY_STATE_UNSPECIFIED, failure.activityFailureInfo.identity ?? undefined,
|
|
377
|
+
return new ActivityFailure(failure.activityFailureInfo.activityType.name, failure.activityFailureInfo.activityId ?? undefined, failure.activityFailureInfo.retryState ?? RetryState.RETRY_STATE_UNSPECIFIED, failure.activityFailureInfo.identity ?? undefined, optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
376
378
|
}
|
|
377
|
-
return new TemporalFailure(failure.message ?? undefined,
|
|
379
|
+
return new TemporalFailure(failure.message ?? undefined, optionalFailureToOptionalError(failure.cause, payloadConverter));
|
|
378
380
|
}
|
|
379
381
|
exports.failureToErrorInner = failureToErrorInner;
|
|
380
382
|
/**
|
|
381
383
|
* Converts a Failure proto message to a JS Error object.
|
|
382
384
|
*/
|
|
383
|
-
|
|
384
|
-
const err =
|
|
385
|
+
function failureToError(failure, payloadConverter) {
|
|
386
|
+
const err = failureToErrorInner(failure, payloadConverter);
|
|
385
387
|
err.stack = failure.stackTrace ?? '';
|
|
386
388
|
err.failure = failure;
|
|
387
389
|
return err;
|
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":";;;AAAA,mFAAgG;AAEhG,qEAAqH;AAExG,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,uCAAY,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,mGAAoC,CAAA;IACpC,qGAAqC,CAAA;IACrC,2FAAgC,CAAA;AAClC,CAAC,EATW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QASrB;AAED,IAAA,uCAAY,GAAgD,CAAC;AAI7D;;;;;;;;;;;GAWG;A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AO,EAAE,gBAAgB,CAAC,CAAC;IAC3D,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;IACrC,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,OAAO,GAAG,CAAC;AACb,CAAC;AALD,wCAKC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,GAAY;IACpC,IAAI,GAAG,YAAY,eAAe,EAAE;QAClC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;KACvD;IACD,IAAI,GAAG,YAAY,KAAK,EAAE;QACxB,OAAO,GAAG,CAAC,OAAO,CAAC;KACpB;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,8BAWC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Common library for
|
|
2
|
+
* Common library for code that's used across the Client, Worker, and/or Workflow
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export { ActivityFunction, ActivityInterface, Headers, Next, RetryPolicy } from '@temporalio/internal-workflow-common';
|
|
7
|
+
export * from '@temporalio/internal-workflow-common/lib/errors';
|
|
8
|
+
export * from '@temporalio/internal-workflow-common/lib/interfaces';
|
|
9
|
+
export * from '@temporalio/internal-workflow-common/lib/time';
|
|
7
10
|
export * from './converter/data-converter';
|
|
8
|
-
export * from './
|
|
11
|
+
export * from './converter/payload-codec';
|
|
12
|
+
export * from './converter/payload-converter';
|
|
13
|
+
export * from './converter/payload-converters';
|
|
14
|
+
export * from './converter/types';
|
|
9
15
|
export * from './failure';
|
|
10
|
-
export * from './interceptors';
|
|
11
|
-
export * from './interfaces';
|
|
12
|
-
export * from './retry-policy';
|
|
13
|
-
export * from './time';
|
|
14
|
-
export * from './tls-config';
|
|
15
|
-
export * from './workflow-handle';
|
|
16
|
-
export * from './workflow-options';
|
|
17
|
-
export * from './utils';
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,21 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @module
|
|
17
|
-
*/
|
|
18
|
-
__exportStar(require("./activity-options"), exports);
|
|
17
|
+
__exportStar(require("@temporalio/internal-workflow-common/lib/errors"), exports);
|
|
18
|
+
__exportStar(require("@temporalio/internal-workflow-common/lib/interfaces"), exports);
|
|
19
|
+
__exportStar(require("@temporalio/internal-workflow-common/lib/time"), exports);
|
|
19
20
|
__exportStar(require("./converter/data-converter"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./converter/payload-codec"), exports);
|
|
22
|
+
__exportStar(require("./converter/payload-converter"), exports);
|
|
23
|
+
__exportStar(require("./converter/payload-converters"), exports);
|
|
24
|
+
__exportStar(require("./converter/types"), exports);
|
|
21
25
|
__exportStar(require("./failure"), exports);
|
|
22
|
-
__exportStar(require("./interceptors"), exports);
|
|
23
|
-
__exportStar(require("./interfaces"), exports);
|
|
24
|
-
__exportStar(require("./retry-policy"), exports);
|
|
25
|
-
__exportStar(require("./time"), exports);
|
|
26
|
-
__exportStar(require("./tls-config"), exports);
|
|
27
|
-
__exportStar(require("./workflow-handle"), exports);
|
|
28
|
-
__exportStar(require("./workflow-options"), exports);
|
|
29
|
-
__exportStar(require("./utils"), exports);
|
|
30
26
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAMA,kFAAgE;AAChE,sFAAoE;AACpE,gFAA8D;AAC9D,6DAA2C;AAC3C,4DAA0C;AAC1C,gEAA8C;AAC9C,iEAA+C;AAC/C,oDAAkC;AAClC,4CAA0B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for classes and utilities related to using
|
|
3
|
+
* [Protobufs](https://docs.temporal.io/docs/typescript/data-converters#protobufs) for serialization.
|
|
4
|
+
*
|
|
5
|
+
* Import from `@temporalio/common/lib/protobufs`, for example:
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* import { patchProtobufRoot } from '@temporalio/common/lib/protobufs';
|
|
9
|
+
* ```
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
export * from './converter/protobuf-payload-converters';
|
|
13
|
+
export * from './converter/patch-protobuf-root';
|
package/lib/protobufs.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Entry point for classes and utilities related to using
|
|
4
|
+
* [Protobufs](https://docs.temporal.io/docs/typescript/data-converters#protobufs) for serialization.
|
|
5
|
+
*
|
|
6
|
+
* Import from `@temporalio/common/lib/protobufs`, for example:
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* import { patchProtobufRoot } from '@temporalio/common/lib/protobufs';
|
|
10
|
+
* ```
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
// Don't export from index, so we save space in Workflow bundles of users who don't use Protobufs
|
|
29
|
+
__exportStar(require("./converter/protobuf-payload-converters"), exports);
|
|
30
|
+
__exportStar(require("./converter/patch-protobuf-root"), exports);
|
|
31
|
+
//# sourceMappingURL=protobufs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protobufs.js","sourceRoot":"","sources":["../src/protobufs.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;AAEH,iGAAiG;AACjG,0EAAwD;AACxD,kEAAgD"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/common",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.19.0-rc.1",
|
|
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",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"temporal",
|
|
9
9
|
"workflow",
|
|
10
|
-
"worker"
|
|
11
|
-
"common"
|
|
10
|
+
"worker"
|
|
12
11
|
],
|
|
13
|
-
"author": "
|
|
12
|
+
"author": "Loren Sands-Ramshaw <loren@temporal.io>",
|
|
14
13
|
"license": "MIT",
|
|
15
14
|
"dependencies": {
|
|
16
|
-
"@temporalio/
|
|
17
|
-
"
|
|
15
|
+
"@temporalio/internal-workflow-common": "^0.19.0-rc.1",
|
|
16
|
+
"proto3-json-serializer": "^0.1.6"
|
|
18
17
|
},
|
|
19
18
|
"bugs": {
|
|
20
19
|
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
@@ -23,5 +22,9 @@
|
|
|
23
22
|
"publishConfig": {
|
|
24
23
|
"access": "public"
|
|
25
24
|
},
|
|
26
|
-
"
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@temporalio/proto": "^0.19.0-rc.1",
|
|
27
|
+
"protobufjs": "^6.11.2"
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "186341ed7285e468c145121433f2c239e53934a6"
|
|
27
30
|
}
|
|
@@ -1,189 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
PayloadConverter,
|
|
5
|
-
UndefinedPayloadConverter,
|
|
6
|
-
BinaryPayloadConverter,
|
|
7
|
-
JsonPayloadConverter,
|
|
8
|
-
} from './payload-converter';
|
|
1
|
+
import { PayloadCodec } from './payload-codec';
|
|
2
|
+
import { PayloadConverter } from './payload-converter';
|
|
9
3
|
|
|
10
4
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
5
|
+
* When your data (arguments and return values) is sent over the wire and stored by Temporal Server, it is encoded in
|
|
6
|
+
* binary in a {@link Payload} Protobuf message.
|
|
13
7
|
*
|
|
14
|
-
*
|
|
8
|
+
* The default `DataConverter` supports `Uint8Array`, and JSON serializables (so if
|
|
9
|
+
* [`JSON.stringify(yourArgOrRetval)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description)
|
|
10
|
+
* works, the default data converter will work). Protobufs are supported via [this
|
|
11
|
+
* API](https://docs.temporal.io/docs/typescript/data-converters#protobufs).
|
|
12
|
+
*
|
|
13
|
+
* Use a custom `DataConverter` to control the contents of your {@link Payload}s. Common reasons for using a custom
|
|
14
|
+
* `DataConverter` are:
|
|
15
|
+
* - Converting values that are not supported by the default `DataConverter` (for example, `JSON.stringify()` doesn't
|
|
16
|
+
* handle `BigInt`s, so if you want to return `{ total: 1000n }` from a Workflow, Signal, or Activity, you need your
|
|
17
|
+
* own `DataConverter`).
|
|
18
|
+
* - Encrypting values that may contain private information that you don't want stored in plaintext in Temporal Server's
|
|
19
|
+
* database.
|
|
20
|
+
* - Compressing values to reduce disk or network usage.
|
|
21
|
+
*
|
|
22
|
+
* To use your custom `DataConverter`, provide it to the {@link WorkflowClient}, {@link Worker}, and
|
|
23
|
+
* {@link bundleWorkflowCode} (if you use it):
|
|
24
|
+
* - `new WorkflowClient({ ..., dataConverter })`
|
|
25
|
+
* - `Worker.create({ ..., dataConverter })`
|
|
26
|
+
* - `bundleWorkflowCode({ ..., payloadConverterPath })`
|
|
15
27
|
*/
|
|
16
28
|
export interface DataConverter {
|
|
17
|
-
toPayload<T>(value: T): Promise<Payload>;
|
|
18
|
-
|
|
19
|
-
fromPayload<T>(payload: Payload): Promise<T>;
|
|
20
|
-
/**
|
|
21
|
-
* Implements conversion of a list of values.
|
|
22
|
-
*
|
|
23
|
-
* @param values JS values to convert to Payloads.
|
|
24
|
-
* @return converted value
|
|
25
|
-
* @throws DataConverterError if conversion of the value passed as parameter failed for any
|
|
26
|
-
* reason.
|
|
27
|
-
*/
|
|
28
|
-
toPayloads(...values: unknown[]): Promise<Payload[] | undefined>;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Implements conversion of an array of values of different types. Useful for deserializing
|
|
32
|
-
* arguments of function invocations.
|
|
33
|
-
*
|
|
34
|
-
* @param index index of the value in the payloads
|
|
35
|
-
* @param content serialized value to convert to JS values.
|
|
36
|
-
* @return converted JS value
|
|
37
|
-
* @throws DataConverterError if conversion of the data passed as parameter failed for any
|
|
38
|
-
* reason.
|
|
39
|
-
*/
|
|
40
|
-
fromPayloads<T>(index: number, content?: Payload[] | null): Promise<T>;
|
|
41
|
-
|
|
42
29
|
/**
|
|
43
|
-
*
|
|
30
|
+
* Path of a file that has a `payloadConverter` named export.
|
|
31
|
+
* `payloadConverter` should be an instance of a class that implements {@link PayloadConverter}.
|
|
32
|
+
* If no path is provided, {@link defaultPayloadConverter} is used.
|
|
44
33
|
*/
|
|
45
|
-
|
|
34
|
+
payloadConverterPath?: string;
|
|
46
35
|
|
|
47
36
|
/**
|
|
48
|
-
*
|
|
37
|
+
* A {@link PayloadCodec} instance. The default codec is a no-op.
|
|
49
38
|
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Sync conversion of all arguments, used in the Workflow runtime
|
|
53
|
-
*
|
|
54
|
-
* Implements conversion of a list of values.
|
|
55
|
-
*
|
|
56
|
-
* @param values JS values to convert to Payloads.
|
|
57
|
-
* @return converted value
|
|
58
|
-
* @throws DataConverterError if conversion of the value passed as parameter failed for any
|
|
59
|
-
* reason.
|
|
60
|
-
*/
|
|
61
|
-
toPayloadsSync(...values: unknown[]): Payload[] | undefined;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Sync version of {@link fromPayloads}
|
|
65
|
-
*/
|
|
66
|
-
fromPayloadsSync<T>(index: number, content?: Payload[] | null): T;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export class CompositeDataConverter implements DataConverter {
|
|
70
|
-
readonly converters: PayloadConverter[];
|
|
71
|
-
readonly converterByEncoding: Map<string, PayloadConverter> = new Map();
|
|
72
|
-
|
|
73
|
-
constructor(...converters: PayloadConverter[]) {
|
|
74
|
-
this.converters = converters;
|
|
75
|
-
for (const converter of converters) {
|
|
76
|
-
this.converterByEncoding.set(converter.encodingType, converter);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public async toPayload<T>(value: T): Promise<Payload> {
|
|
81
|
-
for (const converter of this.converters) {
|
|
82
|
-
const result = await converter.toData(value);
|
|
83
|
-
if (result !== undefined) return result;
|
|
84
|
-
}
|
|
85
|
-
throw new ValueError(`Cannot serialize ${value}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public toPayloadSync<T>(value: T): Payload {
|
|
89
|
-
for (const converter of this.converters) {
|
|
90
|
-
const result = converter.toDataSync(value);
|
|
91
|
-
if (result !== undefined) return result;
|
|
92
|
-
}
|
|
93
|
-
throw new ValueError(`Cannot serialize ${value}`);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public async fromPayload<T>(payload: Payload): Promise<T> {
|
|
97
|
-
if (payload.metadata === undefined || payload.metadata === null) {
|
|
98
|
-
throw new ValueError('Missing payload metadata');
|
|
99
|
-
}
|
|
100
|
-
const encoding = str(payload.metadata[METADATA_ENCODING_KEY]);
|
|
101
|
-
const converter = this.converterByEncoding.get(encoding);
|
|
102
|
-
if (converter === undefined) {
|
|
103
|
-
throw new ValueError(`Unknown encoding: ${encoding}`);
|
|
104
|
-
}
|
|
105
|
-
return await converter.fromData(payload);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public fromPayloadSync<T>(payload: Payload): T {
|
|
109
|
-
if (payload.metadata === undefined || payload.metadata === null) {
|
|
110
|
-
throw new ValueError('Missing payload metadata');
|
|
111
|
-
}
|
|
112
|
-
const encoding = str(payload.metadata[METADATA_ENCODING_KEY]);
|
|
113
|
-
const converter = this.converterByEncoding.get(encoding);
|
|
114
|
-
if (converter === undefined) {
|
|
115
|
-
throw new ValueError(`Unknown encoding: ${encoding}`);
|
|
116
|
-
}
|
|
117
|
-
return converter.fromDataSync(payload);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public async toPayloads(...values: unknown[]): Promise<Payload[] | undefined> {
|
|
121
|
-
if (values.length === 0) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
return await Promise.all(values.map((value) => this.toPayload(value)));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public toPayloadsSync(...values: unknown[]): Payload[] | undefined {
|
|
128
|
-
if (values.length === 0) {
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
return values.map((value) => this.toPayloadSync(value));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
public async fromPayloads<T>(index: number, payloads?: Payload[] | null): Promise<T> {
|
|
135
|
-
// To make adding arguments a backwards compatible change
|
|
136
|
-
if (payloads === undefined || payloads === null || index >= payloads.length) {
|
|
137
|
-
return undefined as any;
|
|
138
|
-
}
|
|
139
|
-
return await this.fromPayload(payloads[index]);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public fromPayloadsSync<T>(index: number, payloads?: Payload[] | null): T {
|
|
143
|
-
// To make adding arguments a backwards compatible change
|
|
144
|
-
if (payloads === undefined || payloads === null || index >= payloads.length) {
|
|
145
|
-
return undefined as any;
|
|
146
|
-
}
|
|
147
|
-
return this.fromPayloadSync(payloads[index]);
|
|
148
|
-
}
|
|
39
|
+
payloadCodec?: PayloadCodec;
|
|
149
40
|
}
|
|
150
41
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
export async function mapToPayloads<K extends string>(
|
|
159
|
-
converter: DataConverter,
|
|
160
|
-
source: Record<K, any>
|
|
161
|
-
): Promise<Record<K, Payload>> {
|
|
162
|
-
return Object.fromEntries(
|
|
163
|
-
await Promise.all(
|
|
164
|
-
Object.entries(source).map(async ([k, v]): Promise<[K, Payload]> => [k as K, await converter.toPayload(v)])
|
|
165
|
-
)
|
|
166
|
-
) as Record<K, Payload>;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function arrayFromPayloadsSync(converter: DataConverter, content?: Payload[] | null): unknown[] {
|
|
170
|
-
if (!content) {
|
|
171
|
-
return [];
|
|
172
|
-
}
|
|
173
|
-
return content.map((payload: Payload) => converter.fromPayloadSync(payload));
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function mapToPayloadsSync<K extends string>(
|
|
177
|
-
converter: DataConverter,
|
|
178
|
-
source: Record<K, any>
|
|
179
|
-
): Record<K, Payload> {
|
|
180
|
-
return Object.fromEntries(
|
|
181
|
-
Object.entries(source).map(([k, v]): [K, Payload] => [k as K, converter.toPayloadSync(v)])
|
|
182
|
-
) as Record<K, Payload>;
|
|
42
|
+
/**
|
|
43
|
+
* A {@link DataConverter} that has been loaded via {@link loadDataConverter}.
|
|
44
|
+
*/
|
|
45
|
+
export interface LoadedDataConverter {
|
|
46
|
+
payloadConverter: PayloadConverter;
|
|
47
|
+
payloadCodec: PayloadCodec;
|
|
183
48
|
}
|
|
184
|
-
|
|
185
|
-
export const defaultDataConverter = new CompositeDataConverter(
|
|
186
|
-
new UndefinedPayloadConverter(),
|
|
187
|
-
new BinaryPayloadConverter(),
|
|
188
|
-
new JsonPayloadConverter()
|
|
189
|
-
);
|
|
File without changes
|