workflow 5.0.0-beta.49 → 5.0.0-beta.50

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/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import '@workflow/core/runtime/world-init';
2
2
  export type { CancelRunOptions, Event, StopSleepOptions, StopSleepResult, WorkflowRun, } from '@workflow/core/runtime';
3
- export { getHookByToken, type ResumedHook, resumeHook, resumeWebhook, } from '@workflow/core/runtime/resume-hook';
3
+ export { getHookByToken, type Hook, type ResumedHook, resumeHook, resumeWebhook, } from '@workflow/core/runtime/resume-hook';
4
4
  export { getRun, Run, type WorkflowReadableStream, type WorkflowReadableStreamOptions, type WorkflowRunWritableStreamOptions, } from '@workflow/core/runtime/run';
5
5
  export { type StartOptions, start, } from '@workflow/core/runtime/start';
6
6
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAOA,OAAO,mCAAmC,CAAC;AAE3C,YAAY,EACV,gBAAgB,EAChB,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,KAAK,WAAW,EAChB,UAAU,EACV,aAAa,GACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,MAAM,EACN,GAAG,EACH,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,GACtC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,GACN,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAOA,OAAO,mCAAmC,CAAC;AAE3C,YAAY,EACV,gBAAgB,EAChB,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,UAAU,EACV,aAAa,GACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,MAAM,EACN,GAAG,EACH,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,GACtC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,GACN,MAAM,8BAA8B,CAAC"}
package/dist/api.js CHANGED
@@ -9,4 +9,4 @@ import '@workflow/core/runtime/world-init';
9
9
  export { getHookByToken, resumeHook, resumeWebhook, } from '@workflow/core/runtime/resume-hook';
10
10
  export { getRun, Run, } from '@workflow/core/runtime/run';
11
11
  export { start, } from '@workflow/core/runtime/start';
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxxRUFBcUU7QUFDckUseUVBQXlFO0FBQ3pFLDJFQUEyRTtBQUMzRSw0RUFBNEU7QUFDNUUsNkVBQTZFO0FBQzdFLG1CQUFtQjtBQUNuQix5RUFBeUU7QUFDekUsT0FBTyxtQ0FBbUMsQ0FBQztBQVMzQyxPQUFPLEVBQ0wsY0FBYyxFQUVkLFVBQVUsRUFDVixhQUFhLEdBQ2QsTUFBTSxvQ0FBb0MsQ0FBQztBQUM1QyxPQUFPLEVBQ0wsTUFBTSxFQUNOLEdBQUcsR0FJSixNQUFNLDRCQUE0QixDQUFDO0FBQ3BDLE9BQU8sRUFFTCxLQUFLLEdBQ04sTUFBTSw4QkFBOEIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8vIFNpZGUtZWZmZWN0IGltcG9ydDogZW5zdXJlIGB3b3JsZC50c2AgaXMgbG9hZGVkIHNvI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lwZSBTdGFydE9wdGlvbnMsXG4gIHN0YXJ0LFxufSBmcm9tICdAd29ya2Zsb3cvY29yZS9ydW50aW1lL3N0YXJ0JztcbiJdfQ==
@@ -17,6 +17,10 @@ When `experimental_minRetention` is set, this function continues to return the H
17
17
  `getHookByToken` is a runtime function that must be called from outside a workflow function.
18
18
  </Callout>
19
19
 
20
+ <Callout type="info">
21
+ `hook.metadata` is a getter that returns a Promise, so `await` it to read the value. Hydrating metadata can add extra network round trips, so that work is deferred to first access and the lookup itself stays a single read. Awaiting it on a hook with no metadata resolves `undefined` and performs no extra work, and repeat reads are free.
22
+ </Callout>
23
+
20
24
  <Callout type="info">
21
25
  Looking up a deterministic hook token is useful in hook-based idempotency flows, but it is only an advisory check. If no hook exists yet, another request can still start the same workflow before your `start()` call registers its hook. Use the lookup to avoid obvious duplicate starts, and handle the race inside the workflow by checking `await hook.getConflict()` before duplicate-sensitive work. On a conflict it resolves with the run that owns the token, so the duplicate can route the caller to the active owner. If duplicates must be rejected before a workflow body runs, keep a durable request record until native atomic start-and-hook registration exists. See [Run idempotency](/docs/foundations/idempotency#run-idempotency).
22
26
  </Callout>
@@ -48,7 +52,7 @@ Returns a `Promise<Hook>` that resolves to:
48
52
 
49
53
  <TSDoc
50
54
  definition={`
51
- import type { Hook } from "@workflow/world";
55
+ import type { Hook } from "workflow/api";
52
56
  export default Hook;`}
53
57
  showSections={["returns"]}
54
58
  />
@@ -70,7 +74,7 @@ export async function POST(request: Request) {
70
74
  const hook = await getHookByToken(token); // [!code highlight]
71
75
 
72
76
  console.log("Resuming workflow run:", hook.runId);
73
- console.log("Hook metadata:", hook.metadata);
77
+ console.log("Hook metadata:", await hook.metadata); // [!code highlight]
74
78
 
75
79
  // Then resume the hook with the payload
76
80
  await resumeHook(token, data);
@@ -97,7 +101,8 @@ export async function POST(request: Request) {
97
101
 
98
102
  try {
99
103
  const hook = await getHookByToken(token); // [!code highlight]
100
- const metadata = hook.metadata as { allowedUserId?: string } | undefined;
104
+ // `metadata` is a Promise, so awaiting it hydrates the stored value.
105
+ const metadata = (await hook.metadata) as { allowedUserId?: string } | undefined; // [!code highlight]
101
106
 
102
107
  // Validate that the hook metadata matches the user
103
108
  if (metadata?.allowedUserId !== userId) {
@@ -52,11 +52,11 @@ showSections={["parameters"]}
52
52
 
53
53
  ### Returns
54
54
 
55
- Returns a `Promise<ResumedHook>`, a `Hook` extended with an optional `resilientResume` flag. Resolving means the payload is durably recorded as `hook_received` and the workflow wake was accepted. `resilientResume` is retained for source compatibility and is no longer set by any path. The resolved hook:
55
+ Returns a `Promise<ResumedHook>`, a `Hook` (from `workflow/api`) extended with an optional `resilientResume` flag. Resolving means the payload is durably recorded as `hook_received` and the workflow wake was accepted. `resilientResume` is retained for source compatibility and is no longer set by any path. Resuming never reads the hook's metadata, so the resolved hook's `metadata` is a Promise that hydrates on first access, exactly as with [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token): `await hook.metadata` to read it. The resolved hook:
56
56
 
57
57
  <TSDoc
58
58
  definition={`
59
- import type { Hook } from "@workflow/world";
59
+ import type { Hook } from "workflow/api";
60
60
  export default Hook;`}
61
61
  showSections={["returns"]}
62
62
  />
@@ -444,9 +444,11 @@ import { getWorld } from "workflow/runtime";
444
444
 
445
445
  const world = await getWorld();
446
446
  const hook = await world.hooks.getByToken(token); // [!code highlight]
447
- console.log(hook.runId, hook.metadata); // [!code highlight]
447
+ console.log(hook.runId); // [!code highlight]
448
448
  ```
449
449
 
450
+ The World-level `Hook` carries `metadata` as the raw serialized (and, on encrypting Worlds, encrypted) value, not the object the workflow passed to `createHook()`. To read the decoded value, use [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token), whose `hook.metadata` is a Promise that hydrates it on first access.
451
+
450
452
  ### List events for audit trail
451
453
 
452
454
  ```typescript lineNumbers
package/docs/meta.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "pages": [
3
3
  "---",
4
+ "whats-new",
4
5
  "getting-started",
5
6
  "foundations",
6
7
  "how-it-works",
@@ -157,6 +157,7 @@ All three first-party Worlds now implement it: Vercel accepts up to 30 days, and
157
157
  | --- | --- |
158
158
  | `runStep` removed from `workflow/api` | Call your step function directly; the compiler routes it through the step runtime. |
159
159
  | `hook.getConflict()` resolves with a `Run` | Replace `conflict.runId` round trips through `getRun()` inside a step with the accessors on `conflict` directly. `conflict.runId` still works. |
160
+ | `hook.metadata` is a Promise on hooks returned by `getHookByToken()` and `resumeHook()` | Write `await hook.metadata` where you read it. Hydrating metadata can add network round trips, and those are now paid only by code that reads it, so the lookup itself is a single read. The `Hook` type is exported from `workflow/api`; the World-level record from `world.hooks.getByToken()` is unchanged. See [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token). |
160
161
  | `experimental_setAttributes` removed | Import `setAttributes` instead, and `SetAttributesOptions` in place of `ExperimentalSetAttributesOptions`. The deprecated aliases are gone. |
161
162
  | [`getWorld()`](/docs/api-reference/workflow-runtime/get-world), [`getWorldHandlers()`](/docs/api-reference/workflow-runtime/get-world-handlers), and [`createWorld()`](/docs/api-reference/workflow-runtime/create-world) are async | They resolve a `Promise` now, so await the call before reaching for anything on it: `const world = await getWorld();` then `await world.start?.();`. This mainly affects the `instrumentation.ts` bootstrap that starts a World with background workers, such as the [Postgres World](/worlds/postgres#starting-the-world). Under TypeScript the old shape fails the build; in plain JavaScript it does not, and `.start` reads as `undefined` on a promise, so the worker never starts and nothing is logged. Writing `await getWorld()` is also valid on 4.x, so the change can be made before upgrading. |
162
163
  | Duplicate step or workflow IDs fail the build | 4.x resolved collisions across non-exported workspace files last-write-wins. If you start encountering build failures after upgrading, rename the colliding functions. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow",
3
- "version": "5.0.0-beta.49",
3
+ "version": "5.0.0-beta.50",
4
4
  "description": "Workflow SDK - Build durable, resilient, and observable workflows",
5
5
  "main": "dist/typescript-plugin.cjs",
6
6
  "type": "module",
@@ -58,19 +58,19 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "@workflow/astro": "5.0.0-beta.49",
62
- "@workflow/cli": "5.0.0-beta.49",
63
- "@workflow/core": "5.0.0-beta.49",
61
+ "@workflow/astro": "5.0.0-beta.50",
62
+ "@workflow/cli": "5.0.0-beta.50",
63
+ "@workflow/core": "5.0.0-beta.50",
64
64
  "@workflow/errors": "5.0.0-beta.21",
65
65
  "@workflow/typescript-plugin": "5.0.0-beta.5",
66
66
  "@workflow/utils": "5.0.0-beta.10",
67
67
  "ms": "2.1.3",
68
- "@workflow/next": "5.0.0-beta.49",
69
- "@workflow/nest": "5.0.0-beta.49",
70
- "@workflow/nitro": "5.0.0-beta.49",
71
- "@workflow/nuxt": "5.0.0-beta.49",
72
- "@workflow/sveltekit": "5.0.0-beta.49",
73
- "@workflow/rollup": "5.0.0-beta.49"
68
+ "@workflow/next": "5.0.0-beta.50",
69
+ "@workflow/nest": "5.0.0-beta.50",
70
+ "@workflow/nitro": "5.0.0-beta.50",
71
+ "@workflow/nuxt": "5.0.0-beta.50",
72
+ "@workflow/sveltekit": "5.0.0-beta.50",
73
+ "@workflow/rollup": "5.0.0-beta.50"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/ms": "2.1.0",