@workflow/core 5.0.0-beta.55 → 5.0.0-beta.57
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 +7 -0
- package/dist/create-hook.d.ts +38 -1
- package/dist/create-hook.d.ts.map +1 -1
- package/dist/create-hook.js +1 -1
- package/dist/global.d.ts +2 -0
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js +1 -1
- package/dist/runtime/constants.d.ts +13 -3
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +54 -4
- package/dist/runtime/deployment-guard.d.ts.map +1 -1
- package/dist/runtime/deployment-guard.js +9 -5
- package/dist/runtime/helpers.d.ts +23 -0
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +23 -2
- package/dist/runtime/hook-wake.d.ts +122 -0
- package/dist/runtime/hook-wake.d.ts.map +1 -0
- package/dist/runtime/hook-wake.js +225 -0
- package/dist/runtime/lifecycle-hooks.d.ts +25 -22
- package/dist/runtime/lifecycle-hooks.d.ts.map +1 -1
- package/dist/runtime/lifecycle-hooks.js +74 -38
- package/dist/runtime/open-hook-wait-state.d.ts +55 -0
- package/dist/runtime/open-hook-wait-state.d.ts.map +1 -0
- package/dist/runtime/open-hook-wait-state.js +93 -0
- package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -1
- package/dist/runtime/quickjs-entrypoint.js +89 -16
- package/dist/runtime/quickjs-runtime.d.ts +2 -0
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +103 -4
- package/dist/runtime/quickjs-serde.d.ts.map +1 -1
- package/dist/runtime/quickjs-serde.js +63 -1
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +466 -314
- package/dist/runtime/run-spec-version.d.ts +16 -0
- package/dist/runtime/run-spec-version.d.ts.map +1 -0
- package/dist/runtime/run-spec-version.js +19 -0
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +5 -3
- package/dist/runtime/runs.d.ts.map +1 -1
- package/dist/runtime/runs.js +15 -6
- package/dist/runtime/start.d.ts +59 -1
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +271 -44
- package/dist/runtime/step-executor.d.ts.map +1 -1
- package/dist/runtime/step-executor.js +16 -10
- package/dist/runtime/step-latency.d.ts +3 -2
- package/dist/runtime/step-latency.d.ts.map +1 -1
- package/dist/runtime/step-latency.js +1 -1
- package/dist/runtime/suspension-handler.d.ts +42 -13
- package/dist/runtime/suspension-handler.d.ts.map +1 -1
- package/dist/runtime/suspension-handler.js +244 -146
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +228 -73
- package/dist/serialization/reducers/common-vm.d.ts.map +1 -1
- package/dist/serialization/reducers/common-vm.js +40 -1
- package/dist/serialization/reducers/common.d.ts.map +1 -1
- package/dist/serialization/reducers/common.js +27 -2
- package/dist/serialization/types.d.ts +8 -0
- package/dist/serialization/types.d.ts.map +1 -1
- package/dist/serialization/types.js +1 -1
- package/dist/serialization.d.ts +15 -2
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +5 -4
- package/dist/telemetry/semantic-conventions.d.ts +29 -0
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
- package/dist/telemetry/semantic-conventions.js +20 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/workflow/hook.d.ts.map +1 -1
- package/dist/workflow/hook.js +76 -4
- package/docs/api-reference/create-hook.mdx +77 -0
- package/docs/api-reference/create-webhook.mdx +1 -1
- package/docs/api-reference/define-hook.mdx +2 -0
- package/docs/foundations/errors-and-retries.mdx +3 -1
- package/docs/foundations/hooks.mdx +34 -0
- package/docs/foundations/idempotency.mdx +44 -21
- package/docs/foundations/starting-workflows.mdx +2 -0
- package/docs/how-it-works/event-sourcing.mdx +7 -1
- package/package.json +5 -5
package/dist/runtime/start.d.ts
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
import type { RunRetention, World } from '@workflow/world';
|
|
2
|
+
import { type HealthCheckResult } from './helpers.js';
|
|
2
3
|
import { Run } from './run.js';
|
|
4
|
+
/**
|
|
5
|
+
* Where a run's stamped spec version came from, recorded on the `start()`
|
|
6
|
+
* span so "why is this run on spec N?" is answerable without reading code.
|
|
7
|
+
*/
|
|
8
|
+
export type SpecVersionSource = 'same-deployment' | 'explicit' | 'probe' | 'probe-unversioned' | 'probe-malformed' | 'probe-miss' | 'no-probe-channel';
|
|
9
|
+
/**
|
|
10
|
+
* The spec version to stamp on a run that another deployment will execute.
|
|
11
|
+
*
|
|
12
|
+
* A run's spec version is a promise about the runtime that reads and writes
|
|
13
|
+
* its event log, and for a cross-deployment start that is the target, not
|
|
14
|
+
* this caller. The capability probe runs inside the target and reports the
|
|
15
|
+
* version the target itself mints (which already honours the target's own
|
|
16
|
+
* `WORKFLOW_SEALED_LOG` switch), so that is the answer, capped at what this
|
|
17
|
+
* caller's World mints: the caller writes `run_created` and the arguments,
|
|
18
|
+
* and must never stamp a version it could not have written itself.
|
|
19
|
+
*
|
|
20
|
+
* When the target does not report a usable version:
|
|
21
|
+
*
|
|
22
|
+
* - a plain-text reply predates the versioned JSON health response, which
|
|
23
|
+
* arrived with spec 3 (CBOR queue transport), so it is stamped as
|
|
24
|
+
* event-sourced: such a target cannot read a CBOR `runInput`.
|
|
25
|
+
* - a JSON reply without a usable `specVersion` still proves the target is
|
|
26
|
+
* at spec 3 or later, so it is stamped with CBOR queue transport rather
|
|
27
|
+
* than losing it (and resilient start with it) to a malformed field.
|
|
28
|
+
* - a probe that times out, or no probe channel at all, is a guess.
|
|
29
|
+
* `SPEC_VERSION_SUPPORTS_SLOT_IDENTITY` is the lowest version a v5 runtime
|
|
30
|
+
* can execute on the Vercel World (it requires slot event ids), so it is
|
|
31
|
+
* the only floor that keeps same-major targets working. It is NOT safe for
|
|
32
|
+
* an older-major target such as `stable` (spec 3): that target rejects the
|
|
33
|
+
* run when it picks it up. No single floor serves both, which is why the
|
|
34
|
+
* probe budget is generous; the miss is logged and recorded on the span.
|
|
35
|
+
*
|
|
36
|
+
* Once executors attest their version on `run_started` and the backend
|
|
37
|
+
* raises a run to it (vercel/workflow#4366, vercel/workflow-server#1044), a
|
|
38
|
+
* v5 target heals an under-stamped run, and this miss floor may drop, but
|
|
39
|
+
* only once the raise is enabled on the whole server fleet AND every v5
|
|
40
|
+
* target a caller can reach attests its version (a published beta that does
|
|
41
|
+
* not would be stamped below slot identity and fail). Even then a floor
|
|
42
|
+
* below `SPEC_VERSION_SUPPORTS_ATTRIBUTES` would refuse `attributes` on every
|
|
43
|
+
* miss. Tracked in vercel/workflow#4401.
|
|
44
|
+
*
|
|
45
|
+
* Exported for tests.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveCrossDeploymentSpecVersion(probe: Pick<HealthCheckResult, 'healthy' | 'specVersion' | 'format'> | undefined, callerSpecVersion: number): {
|
|
48
|
+
specVersion: number;
|
|
49
|
+
source: SpecVersionSource;
|
|
50
|
+
};
|
|
3
51
|
/**
|
|
4
52
|
* Reset the `deploymentId: 'latest'` no-op warn-once guard. Test-only,
|
|
5
53
|
* exported so unit tests can exercise the warn path across `start()` calls.
|
|
@@ -7,6 +55,12 @@ import { Run } from './run.js';
|
|
|
7
55
|
* @internal
|
|
8
56
|
*/
|
|
9
57
|
export declare function _resetLatestNoOpWarnForTests(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Reset the cross-deployment probe-miss warn-once guard. Test-only.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export declare function _resetProbeMissWarnForTests(): void;
|
|
10
64
|
export interface StartOptionsBase {
|
|
11
65
|
/**
|
|
12
66
|
* The world to use for the workflow run creation,
|
|
@@ -14,7 +68,11 @@ export interface StartOptionsBase {
|
|
|
14
68
|
*/
|
|
15
69
|
world?: World;
|
|
16
70
|
/**
|
|
17
|
-
* The spec version to use for the workflow run. Defaults to the
|
|
71
|
+
* The spec version to use for the workflow run. Defaults to the spec
|
|
72
|
+
* version of the deployment that will execute the run: the configured
|
|
73
|
+
* World's for a same-deployment start, and for a cross-deployment start
|
|
74
|
+
* (`deploymentId` naming another deployment) the version the target
|
|
75
|
+
* reports on its capability probe, capped at the configured World's.
|
|
18
76
|
*/
|
|
19
77
|
specVersion?: number;
|
|
20
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EAEZ,KAAK,EACN,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EAEZ,KAAK,EACN,MAAM,iBAAiB,CAAC;AAqCzB,OAAO,EAEL,KAAK,iBAAiB,EAEvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAuD/B;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,iBAAiB,GACjB,UAAU,GACV,OAAO,GACP,mBAAmB,GACnB,iBAAiB,GACjB,YAAY,GACZ,kBAAkB,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EACD,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC,GAC7D,SAAS,EACb,iBAAiB,EAAE,MAAM,GACxB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAqBpD;AAuCD;;;;;GAKG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAYD;;;;GAIG;AACH,wB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