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 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 { sleep, fetch } from 'workflow'`. and used in workflow.
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.
@@ -1 +1 @@
1
- {"version":3,"file":"stdlib.d.ts","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAW,EAAE,KAAK,WAAW,EAAE,MAAM,IAAI,CAAC;AAQ1C;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;yBAAjC,KAAK;;;AAiC3B;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,qBAGvE"}
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 { sleep, fetch } from 'workflow'`. and used in workflow.
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.
@@ -1 +1 @@
1
- {"version":3,"file":"stdlib.js","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAwB,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,yEAAyE;AACzE,sEAAsE;AACtE,yEAAyE;AACzE,MAAM,0BAA0B,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;AAqBpD,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,KAAyB;IACnD,UAAU,CAAC;IACX,MAAM,EAAE,aAAa,EAAE,GAAG,eAAe,EAAE,CAAC;IAC5C,MAAM,UAAU,GACd,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACX,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAE9C,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,OAAO,GACX,KAAK,YAAY,IAAI;YACnB,CAAC,CAAC,wBAAwB,KAAK,4BAA4B;YAC3D,CAAC,CAAC,4BAA4B,KAAK,iEAAiE,CAAC;QACzG,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,aAAa,GAAG,UAAU,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;QAChB,MAAM,gBAAgB,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,0BAA0B,CAAC,CAAC;QAC1E,MAAM,IAAI,cAAc,CACtB,gBAAgB,EAAE,CAAC,UAAU,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EACvD;YACE,UAAU;SACX,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AACD,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;AAE5B;;;;;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"}
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.5",
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.5",
43
- "@workflow/core": "4.0.1-beta.4",
44
- "@workflow/errors": "4.0.1-beta.1",
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.5",
47
- "@workflow/nitro": "4.0.1-beta.5"
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",