workflow 4.0.1-beta.5 → 4.0.1-beta.6
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/dist/stdlib.d.ts +1 -22
- package/dist/stdlib.d.ts.map +1 -1
- package/dist/stdlib.js +1 -31
- package/dist/stdlib.js.map +1 -1
- package/package.json +6 -6
package/dist/stdlib.d.ts
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This is the "standard library" of steps that we make available to all workflow users.
|
|
3
|
-
* The can be imported like so: `import {
|
|
3
|
+
* The can be imported like so: `import { fetch } from 'workflow'`. and used in workflow.
|
|
4
4
|
* The need to be exported directly in this package and cannot live in `core` to prevent
|
|
5
5
|
* circular dependencies post-compilation.
|
|
6
6
|
*/
|
|
7
|
-
import { type StringValue } from 'ms';
|
|
8
|
-
/**
|
|
9
|
-
* Sleep within a workflow for a given duration.
|
|
10
|
-
*
|
|
11
|
-
* @param duration - The duration to sleep for, this is a string in the format
|
|
12
|
-
* of `"1000ms"`, `"1s"`, `"1m"`, `"1h"`, or `"1d"`.
|
|
13
|
-
* @overload
|
|
14
|
-
* @returns A promise that resolves when the sleep is complete.
|
|
15
|
-
*/
|
|
16
|
-
export declare function sleep(duration: StringValue): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Sleep within a workflow until a specific date.
|
|
19
|
-
*
|
|
20
|
-
* @param date - The date to sleep until, this must be a future date.
|
|
21
|
-
* @overload
|
|
22
|
-
* @returns A promise that resolves when the sleep is complete.
|
|
23
|
-
*/
|
|
24
|
-
export declare function sleep(date: Date): Promise<void>;
|
|
25
|
-
export declare namespace sleep {
|
|
26
|
-
var maxRetries: number;
|
|
27
|
-
}
|
|
28
7
|
/**
|
|
29
8
|
* A hoisted `fetch()` function that is executed as a "step" function,
|
|
30
9
|
* for use within workflow functions.
|
package/dist/stdlib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdlib.d.ts","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"stdlib.d.ts","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,qBAGvE"}
|
package/dist/stdlib.js
CHANGED
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This is the "standard library" of steps that we make available to all workflow users.
|
|
3
|
-
* The can be imported like so: `import {
|
|
3
|
+
* The can be imported like so: `import { fetch } from 'workflow'`. and used in workflow.
|
|
4
4
|
* The need to be exported directly in this package and cannot live in `core` to prevent
|
|
5
5
|
* circular dependencies post-compilation.
|
|
6
6
|
*/
|
|
7
|
-
import { RetryableError } from '@workflow/errors';
|
|
8
|
-
import ms from 'ms';
|
|
9
|
-
import { getStepMetadata } from './index.js';
|
|
10
|
-
// vqs has a max message visibility lifespan, the workflow sleep function
|
|
11
|
-
// will retry repeatedly until the user requested duration is reached.
|
|
12
|
-
// (Eventually make this configurable based on the queue backend adapter)
|
|
13
|
-
const MAX_SLEEP_DURATION_SECONDS = ms('23h') / 1000;
|
|
14
|
-
export async function sleep(param) {
|
|
15
|
-
'use step';
|
|
16
|
-
const { stepStartedAt } = getStepMetadata();
|
|
17
|
-
const durationMs = typeof param === 'string'
|
|
18
|
-
? ms(param)
|
|
19
|
-
: param.getTime() - Number(stepStartedAt);
|
|
20
|
-
if (typeof durationMs !== 'number' || durationMs < 0) {
|
|
21
|
-
const message = param instanceof Date
|
|
22
|
-
? `Invalid sleep date: "${param}". Expected a future date.`
|
|
23
|
-
: `Invalid sleep duration: "${param}". Expected a valid duration string like "1s", "1m", "1h", etc.`;
|
|
24
|
-
throw new Error(message);
|
|
25
|
-
}
|
|
26
|
-
const endAt = +stepStartedAt + durationMs;
|
|
27
|
-
const now = Date.now();
|
|
28
|
-
if (now < endAt) {
|
|
29
|
-
const remainingSeconds = (endAt - now) / 1000;
|
|
30
|
-
const retryAfter = Math.min(remainingSeconds, MAX_SLEEP_DURATION_SECONDS);
|
|
31
|
-
throw new RetryableError(`Sleeping for ${ms(retryAfter * 1000, { long: true })}`, {
|
|
32
|
-
retryAfter,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
sleep.maxRetries = Infinity;
|
|
37
7
|
/**
|
|
38
8
|
* A hoisted `fetch()` function that is executed as a "step" function,
|
|
39
9
|
* for use within workflow functions.
|
package/dist/stdlib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdlib.js","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"stdlib.js","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,GAAG,IAAyC;IACtE,UAAU,CAAC;IACX,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workflow",
|
|
3
|
-
"version": "4.0.1-beta.
|
|
3
|
+
"version": "4.0.1-beta.6",
|
|
4
4
|
"description": "Workflow DevKit - Build durable, resilient, and observable workflows",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"ms": "2.1.3",
|
|
42
|
-
"@workflow/cli": "4.0.1-beta.
|
|
43
|
-
"@workflow/core": "4.0.1-beta.
|
|
44
|
-
"@workflow/errors": "4.0.1-beta.
|
|
42
|
+
"@workflow/cli": "4.0.1-beta.6",
|
|
43
|
+
"@workflow/core": "4.0.1-beta.5",
|
|
44
|
+
"@workflow/errors": "4.0.1-beta.2",
|
|
45
45
|
"@workflow/typescript-plugin": "4.0.1-beta.3",
|
|
46
|
-
"@workflow/next": "4.0.1-beta.
|
|
47
|
-
"@workflow/nitro": "4.0.1-beta.
|
|
46
|
+
"@workflow/next": "4.0.1-beta.6",
|
|
47
|
+
"@workflow/nitro": "4.0.1-beta.6"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/ms": "^2.1.0",
|