@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/src/type-helpers.ts
CHANGED
|
@@ -4,6 +4,11 @@ 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
|
+
{
|
|
10
|
+
[K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
|
|
11
|
+
}[Keys];
|
|
7
12
|
|
|
8
13
|
/** Verify that an type _Copy extends _Orig */
|
|
9
14
|
export function checkExtends<_Orig, _Copy extends _Orig>(): void {
|
|
@@ -61,3 +66,10 @@ export function errorCode(error: unknown): string | undefined {
|
|
|
61
66
|
|
|
62
67
|
return undefined;
|
|
63
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Asserts that some type is the never type
|
|
72
|
+
*/
|
|
73
|
+
export function assertNever(msg: string, x: never): never {
|
|
74
|
+
throw new TypeError(msg + ': ' + x);
|
|
75
|
+
}
|
|
@@ -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';
|
package/src/workflow-options.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { temporal, google } from '@temporalio/proto';
|
|
2
2
|
import { SearchAttributes, Workflow } from './interfaces';
|
|
3
3
|
import { RetryPolicy } from './retry-policy';
|
|
4
|
-
import { msOptionalToTs } from './time';
|
|
4
|
+
import { Duration, msOptionalToTs } from './time';
|
|
5
5
|
import { checkExtends, Replace } from './type-helpers';
|
|
6
6
|
|
|
7
7
|
// Avoid importing the proto implementation to reduce workflow bundle size
|
|
@@ -113,7 +113,7 @@ export interface WorkflowDurationOptions {
|
|
|
113
113
|
*
|
|
114
114
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
115
115
|
*/
|
|
116
|
-
workflowRunTimeout?:
|
|
116
|
+
workflowRunTimeout?: Duration;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
*
|
|
@@ -123,14 +123,14 @@ export interface WorkflowDurationOptions {
|
|
|
123
123
|
*
|
|
124
124
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
125
125
|
*/
|
|
126
|
-
workflowExecutionTimeout?:
|
|
126
|
+
workflowExecutionTimeout?: Duration;
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Maximum execution time of a single workflow task. Default is 10 seconds.
|
|
130
130
|
*
|
|
131
131
|
* @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
|
|
132
132
|
*/
|
|
133
|
-
workflowTaskTimeout?:
|
|
133
|
+
workflowTaskTimeout?: Duration;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions;
|
|
@@ -154,3 +154,14 @@ export function compileWorkflowOptions<T extends CommonWorkflowOptions>(options:
|
|
|
154
154
|
workflowTaskTimeout: msOptionalToTs(workflowTaskTimeout),
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
+
|
|
158
|
+
export function extractWorkflowType<T extends Workflow>(workflowTypeOrFunc: string | T): string {
|
|
159
|
+
if (typeof workflowTypeOrFunc === 'string') return workflowTypeOrFunc as string;
|
|
160
|
+
if (typeof workflowTypeOrFunc === 'function') {
|
|
161
|
+
if (workflowTypeOrFunc?.name) return workflowTypeOrFunc.name;
|
|
162
|
+
throw new TypeError('Invalid workflow type: the workflow function is anonymous');
|
|
163
|
+
}
|
|
164
|
+
throw new TypeError(
|
|
165
|
+
`Invalid workflow type: expected either a string or a function, got '${typeof workflowTypeOrFunc}'`
|
|
166
|
+
);
|
|
167
|
+
}
|