@voyant-travel/workflows 0.107.10
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/LICENSE +201 -0
- package/NOTICE +52 -0
- package/README.md +79 -0
- package/dist/auth/index.d.ts +125 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +352 -0
- package/dist/bindings.d.ts +119 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +19 -0
- package/dist/client.d.ts +135 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +305 -0
- package/dist/conditions.d.ts +29 -0
- package/dist/conditions.d.ts.map +1 -0
- package/dist/conditions.js +5 -0
- package/dist/config.d.ts +93 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +7 -0
- package/dist/driver.d.ts +237 -0
- package/dist/driver.d.ts.map +1 -0
- package/dist/driver.js +53 -0
- package/dist/errors.d.ts +58 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +76 -0
- package/dist/events/compile.d.ts +34 -0
- package/dist/events/compile.d.ts.map +1 -0
- package/dist/events/compile.js +204 -0
- package/dist/events/index.d.ts +8 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +11 -0
- package/dist/events/input-mapper.d.ts +24 -0
- package/dist/events/input-mapper.d.ts.map +1 -0
- package/dist/events/input-mapper.js +169 -0
- package/dist/events/manifest-builder.d.ts +42 -0
- package/dist/events/manifest-builder.d.ts.map +1 -0
- package/dist/events/manifest-builder.js +313 -0
- package/dist/events/payload-hash.d.ts +46 -0
- package/dist/events/payload-hash.d.ts.map +1 -0
- package/dist/events/payload-hash.js +98 -0
- package/dist/events/predicate.d.ts +77 -0
- package/dist/events/predicate.d.ts.map +1 -0
- package/dist/events/predicate.js +347 -0
- package/dist/events/registry.d.ts +37 -0
- package/dist/events/registry.d.ts.map +1 -0
- package/dist/events/registry.js +47 -0
- package/dist/handler/index.d.ts +114 -0
- package/dist/handler/index.d.ts.map +1 -0
- package/dist/handler/index.js +267 -0
- package/dist/handler/resume.d.ts +41 -0
- package/dist/handler/resume.d.ts.map +1 -0
- package/dist/handler/resume.js +44 -0
- package/dist/http-ingest.d.ts +54 -0
- package/dist/http-ingest.d.ts.map +1 -0
- package/dist/http-ingest.js +214 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/protocol/index.d.ts +345 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +110 -0
- package/dist/rate-limit/index.d.ts +40 -0
- package/dist/rate-limit/index.d.ts.map +1 -0
- package/dist/rate-limit/index.js +139 -0
- package/dist/runtime/ctx.d.ts +111 -0
- package/dist/runtime/ctx.d.ts.map +1 -0
- package/dist/runtime/ctx.js +624 -0
- package/dist/runtime/determinism.d.ts +19 -0
- package/dist/runtime/determinism.d.ts.map +1 -0
- package/dist/runtime/determinism.js +61 -0
- package/dist/runtime/errors.d.ts +21 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +45 -0
- package/dist/runtime/executor.d.ts +166 -0
- package/dist/runtime/executor.d.ts.map +1 -0
- package/dist/runtime/executor.js +226 -0
- package/dist/runtime/journal.d.ts +56 -0
- package/dist/runtime/journal.d.ts.map +1 -0
- package/dist/runtime/journal.js +28 -0
- package/dist/testing/index.d.ts +117 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +599 -0
- package/dist/trigger.d.ts +37 -0
- package/dist/trigger.d.ts.map +1 -0
- package/dist/trigger.js +11 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/workflow.d.ts +222 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +55 -0
- package/package.json +120 -0
- package/src/auth/index.ts +398 -0
- package/src/bindings.ts +135 -0
- package/src/client.ts +498 -0
- package/src/conditions.ts +43 -0
- package/src/config.ts +114 -0
- package/src/driver.ts +277 -0
- package/src/errors.ts +109 -0
- package/src/events/compile.ts +268 -0
- package/src/events/index.ts +42 -0
- package/src/events/input-mapper.ts +201 -0
- package/src/events/manifest-builder.ts +372 -0
- package/src/events/payload-hash.ts +110 -0
- package/src/events/predicate.ts +390 -0
- package/src/events/registry.ts +86 -0
- package/src/handler/index.ts +413 -0
- package/src/handler/resume.ts +100 -0
- package/src/http-ingest.ts +299 -0
- package/src/index.ts +18 -0
- package/src/protocol/index.ts +483 -0
- package/src/rate-limit/index.ts +181 -0
- package/src/runtime/ctx.ts +876 -0
- package/src/runtime/determinism.ts +75 -0
- package/src/runtime/errors.ts +58 -0
- package/src/runtime/executor.ts +442 -0
- package/src/runtime/journal.ts +80 -0
- package/src/testing/index.ts +796 -0
- package/src/trigger.ts +63 -0
- package/src/types.ts +80 -0
- package/src/workflow.ts +328 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAIvD;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAA;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB,CAAC,KAAK,GAAG,OAAO;IAClD,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAA;IACZ,wBAAwB;IACxB,IAAI,EAAE,KAA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|
+
// A driver is the runtime-side object that backs `createApp({ workflows })`:
|
|
4
|
+
// it owns manifest registration, run triggering, event ingest, and (optionally)
|
|
5
|
+
// admin reads. Concrete drivers live in downstream packages
|
|
6
|
+
// (`@voyant-travel/workflows-orchestrator` for InMemory, `-node` for Mode 2 / Postgres,
|
|
7
|
+
// `-cloudflare` for Mode 1 / DO+KV).
|
|
8
|
+
//
|
|
9
|
+
// Drivers are constructed via *factories* — `DriverFactory` is a function the
|
|
10
|
+
// framework invokes after `createApp()` has assembled its `ModuleContainer`.
|
|
11
|
+
// This lets concrete factories accept their environment-specific options
|
|
12
|
+
// (DO namespaces, DB pool, etc.) at user-call time and receive framework
|
|
13
|
+
// deps (services, logger, …) at boot time, without a setter API.
|
|
14
|
+
//
|
|
15
|
+
// Authoritative architecture: docs/architecture/workflows-runtime-architecture.md §6.
|
|
16
|
+
// ---- Errors ----
|
|
17
|
+
/**
|
|
18
|
+
* Base class for typed driver errors. Concrete subclasses below; consumers
|
|
19
|
+
* `instanceof` to handle specific cases.
|
|
20
|
+
*/
|
|
21
|
+
export class WorkflowDriverError extends Error {
|
|
22
|
+
code;
|
|
23
|
+
cause;
|
|
24
|
+
constructor(code, message, opts) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "WorkflowDriverError";
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.cause = opts?.cause;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class ManifestNotRegisteredError extends WorkflowDriverError {
|
|
32
|
+
constructor(environment) {
|
|
33
|
+
super("manifest_not_registered", `No manifest is registered for environment "${environment}". ` +
|
|
34
|
+
`createApp() must complete its bootstrap before driver.ingestEvent(...) can fire.`);
|
|
35
|
+
this.name = "ManifestNotRegisteredError";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class EventTooLargeError extends WorkflowDriverError {
|
|
39
|
+
bytes;
|
|
40
|
+
limit;
|
|
41
|
+
constructor(bytes, limit = 256 * 1024) {
|
|
42
|
+
super("payload_too_large", `Event payload is ${bytes} bytes, exceeding the ${limit}-byte cap.`);
|
|
43
|
+
this.name = "EventTooLargeError";
|
|
44
|
+
this.bytes = bytes;
|
|
45
|
+
this.limit = limit;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class EnvironmentMismatchError extends WorkflowDriverError {
|
|
49
|
+
constructor(eventEnv, manifestEnv) {
|
|
50
|
+
super("environment_mismatch", `Event environment "${eventEnv}" does not match the registered manifest's environment "${manifestEnv}".`);
|
|
51
|
+
this.name = "EnvironmentMismatchError";
|
|
52
|
+
}
|
|
53
|
+
}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type ErrorCategory = "USER_ERROR" | "RUNTIME_ERROR";
|
|
2
|
+
export declare abstract class VoyantError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly category: ErrorCategory;
|
|
5
|
+
constructor(message: string, opts: {
|
|
6
|
+
code: string;
|
|
7
|
+
category: ErrorCategory;
|
|
8
|
+
cause?: unknown;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export declare class FatalError extends VoyantError {
|
|
12
|
+
constructor(message: string, opts?: {
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
code?: string;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export type RetryAfter = string | number | Date;
|
|
18
|
+
export declare class RetryableError extends VoyantError {
|
|
19
|
+
readonly retryAfter?: RetryAfter;
|
|
20
|
+
constructor(message: string, opts?: {
|
|
21
|
+
retryAfter?: RetryAfter;
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
code?: string;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export declare class TimeoutError extends VoyantError {
|
|
27
|
+
constructor(message: string, opts?: {
|
|
28
|
+
cause?: unknown;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export declare class HookConflictError extends VoyantError {
|
|
32
|
+
readonly tokenId: string;
|
|
33
|
+
constructor(tokenId: string, opts?: {
|
|
34
|
+
cause?: unknown;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export declare class QuotaExceededError extends VoyantError {
|
|
38
|
+
readonly meter: string;
|
|
39
|
+
readonly limit: number;
|
|
40
|
+
readonly environment: "production" | "preview" | "development";
|
|
41
|
+
constructor(opts: {
|
|
42
|
+
meter: string;
|
|
43
|
+
limit: number;
|
|
44
|
+
environment: "production" | "preview" | "development";
|
|
45
|
+
cause?: unknown;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export interface ValidationIssue {
|
|
49
|
+
path: string[];
|
|
50
|
+
message: string;
|
|
51
|
+
}
|
|
52
|
+
export declare class ValidationError extends VoyantError {
|
|
53
|
+
readonly issues: ValidationIssue[];
|
|
54
|
+
constructor(issues: ValidationIssue[], opts?: {
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,eAAe,CAAA;AAE1D,8BAAsB,WAAY,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;gBAG9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,aAAa,CAAA;QACvB,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB;CAOJ;AAED,qBAAa,UAAW,SAAQ,WAAW;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;CAOvE;AAED,MAAM,MAAM,UAAU,GAAG,MAA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A;KAAE;CAQlE"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @voyant-travel/workflows/errors
|
|
2
|
+
//
|
|
3
|
+
// Typed error classes used across the Voyant Workflows SDK.
|
|
4
|
+
// Contract defined in docs/sdk-surface.md §7.
|
|
5
|
+
export class VoyantError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
category;
|
|
8
|
+
constructor(message, opts) {
|
|
9
|
+
super(message, { cause: opts.cause });
|
|
10
|
+
this.name = new.target.name;
|
|
11
|
+
this.code = opts.code;
|
|
12
|
+
this.category = opts.category;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class FatalError extends VoyantError {
|
|
16
|
+
constructor(message, opts) {
|
|
17
|
+
super(message, {
|
|
18
|
+
code: opts?.code ?? "FATAL",
|
|
19
|
+
category: "USER_ERROR",
|
|
20
|
+
cause: opts?.cause,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class RetryableError extends VoyantError {
|
|
25
|
+
retryAfter;
|
|
26
|
+
constructor(message, opts) {
|
|
27
|
+
super(message, {
|
|
28
|
+
code: opts?.code ?? "RETRYABLE",
|
|
29
|
+
category: "USER_ERROR",
|
|
30
|
+
cause: opts?.cause,
|
|
31
|
+
});
|
|
32
|
+
this.retryAfter = opts?.retryAfter;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class TimeoutError extends VoyantError {
|
|
36
|
+
constructor(message, opts) {
|
|
37
|
+
super(message, { code: "TIMEOUT", category: "RUNTIME_ERROR", cause: opts?.cause });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class HookConflictError extends VoyantError {
|
|
41
|
+
tokenId;
|
|
42
|
+
constructor(tokenId, opts) {
|
|
43
|
+
super(`hook token already resolved: ${tokenId}`, {
|
|
44
|
+
code: "HOOK_CONFLICT",
|
|
45
|
+
category: "RUNTIME_ERROR",
|
|
46
|
+
cause: opts?.cause,
|
|
47
|
+
});
|
|
48
|
+
this.tokenId = tokenId;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export class QuotaExceededError extends VoyantError {
|
|
52
|
+
meter;
|
|
53
|
+
limit;
|
|
54
|
+
environment;
|
|
55
|
+
constructor(opts) {
|
|
56
|
+
super(`quota exceeded for ${opts.meter} (limit ${opts.limit}) in ${opts.environment}`, {
|
|
57
|
+
code: "QUOTA_EXCEEDED",
|
|
58
|
+
category: "RUNTIME_ERROR",
|
|
59
|
+
cause: opts.cause,
|
|
60
|
+
});
|
|
61
|
+
this.meter = opts.meter;
|
|
62
|
+
this.limit = opts.limit;
|
|
63
|
+
this.environment = opts.environment;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export class ValidationError extends VoyantError {
|
|
67
|
+
issues;
|
|
68
|
+
constructor(issues, opts) {
|
|
69
|
+
super(`validation failed with ${issues.length} issue${issues.length === 1 ? "" : "s"}`, {
|
|
70
|
+
code: "VALIDATION",
|
|
71
|
+
category: "USER_ERROR",
|
|
72
|
+
cause: opts?.cause,
|
|
73
|
+
});
|
|
74
|
+
this.issues = issues;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EventFilterDeclaration } from "../trigger.js";
|
|
2
|
+
import { type EventFilterRuntimeEntry } from "./registry.js";
|
|
3
|
+
export declare class EventFilterCompileError extends Error {
|
|
4
|
+
readonly errors: string[];
|
|
5
|
+
constructor(message: string, errors?: string[]);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Compile an authored declaration into a runtime entry. Throws
|
|
9
|
+
* `EventFilterCompileError` on shape errors so authoring problems fail
|
|
10
|
+
* at module-load time.
|
|
11
|
+
*/
|
|
12
|
+
export declare function compileEventFilter<T>(eventType: string, declaration: EventFilterDeclaration<T>): Promise<EventFilterRuntimeEntry>;
|
|
13
|
+
/**
|
|
14
|
+
* Compile + register in one step. The synchronous wrapper for `trigger.on()`
|
|
15
|
+
* that user code calls — validates the declaration, computes the
|
|
16
|
+
* content-derived id, registers the entry, and returns it.
|
|
17
|
+
*
|
|
18
|
+
* Returning the full {@link EventFilterRuntimeEntry} is what makes the
|
|
19
|
+
* authoring shape from the architecture doc work directly — modules can
|
|
20
|
+
* write `eventFilters: [trigger.on(...)]` without a registry round-trip:
|
|
21
|
+
* the entry already structurally satisfies `EventFilterDescriptor`
|
|
22
|
+
* (matching `id` + `eventType` fields) and carries the `manifest` payload
|
|
23
|
+
* `createApp()`'s wireWorkflowRuntime needs to register with the driver.
|
|
24
|
+
*/
|
|
25
|
+
export declare function compileAndRegister<T>(eventType: string, declaration: EventFilterDeclaration<T>): EventFilterRuntimeEntry;
|
|
26
|
+
/**
|
|
27
|
+
* Synchronous compile — uses a deterministic but non-cryptographic hash
|
|
28
|
+
* over the canonical JSON. Suitable for the registry id (we just need
|
|
29
|
+
* stable + collision-resistant-enough across realistic registration
|
|
30
|
+
* counts). The crypto-grade `sha256(...)` is used at *manifest build*
|
|
31
|
+
* time when async is fine.
|
|
32
|
+
*/
|
|
33
|
+
export declare function compileEventFilterSync<T>(eventType: string, declaration: EventFilterDeclaration<T>): EventFilterRuntimeEntry;
|
|
34
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/events/compile.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAI3D,OAAO,EAAE,KAAK,uBAAuB,EAA0B,MAAM,eAAe,CAAA;AAEpF,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAA;gBAEb,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,EAAO;CAKnD;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,uBAAuB,CAAC,CAyFlC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACrC,uBAAuB,CAOzB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACrC,uBAAuB,CAqFzB"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Compile an `EventFilterDeclaration` (authored in user code) into an
|
|
2
|
+
// `EventFilterRuntimeEntry`. Validates the predicate + mapper at
|
|
3
|
+
// registration time so authoring errors fail fast; computes the
|
|
4
|
+
// content-derived `id` / `payloadHash` so the manifest is deterministic.
|
|
5
|
+
//
|
|
6
|
+
// Called from `trigger.on(...)` in `../trigger.js`.
|
|
7
|
+
import { validateInputMapper } from "./input-mapper.js";
|
|
8
|
+
import { canonicalJson, sha256 } from "./payload-hash.js";
|
|
9
|
+
import { validatePredicate } from "./predicate.js";
|
|
10
|
+
import { getEventFilterRegistry } from "./registry.js";
|
|
11
|
+
export class EventFilterCompileError extends Error {
|
|
12
|
+
errors;
|
|
13
|
+
constructor(message, errors = []) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "EventFilterCompileError";
|
|
16
|
+
this.errors = errors;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compile an authored declaration into a runtime entry. Throws
|
|
21
|
+
* `EventFilterCompileError` on shape errors so authoring problems fail
|
|
22
|
+
* at module-load time.
|
|
23
|
+
*/
|
|
24
|
+
export async function compileEventFilter(eventType, declaration) {
|
|
25
|
+
if (typeof eventType !== "string" || eventType.length === 0) {
|
|
26
|
+
throw new EventFilterCompileError(`trigger.on(eventType, ...): eventType must be a non-empty string`);
|
|
27
|
+
}
|
|
28
|
+
if (typeof declaration !== "object" || declaration === null) {
|
|
29
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", ...): declaration must be an object`);
|
|
30
|
+
}
|
|
31
|
+
if (!declaration.target || typeof declaration.target !== "object") {
|
|
32
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", ...): "target" must be a workflow definition (got ${typeof declaration.target})`);
|
|
33
|
+
}
|
|
34
|
+
const targetWorkflowId = typeof declaration.target.id === "string"
|
|
35
|
+
? declaration.target.id
|
|
36
|
+
: "";
|
|
37
|
+
if (targetWorkflowId.length === 0) {
|
|
38
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", ...): "target.id" must be a non-empty string`);
|
|
39
|
+
}
|
|
40
|
+
// Validate `where` if supplied.
|
|
41
|
+
const where = declaration.where;
|
|
42
|
+
if (where !== undefined) {
|
|
43
|
+
const result = validatePredicate(where);
|
|
44
|
+
if (!result.ok) {
|
|
45
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", target=${targetWorkflowId}): invalid where clause`, result.errors);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Validate `input` if supplied.
|
|
49
|
+
const input = declaration.input;
|
|
50
|
+
if (input !== undefined) {
|
|
51
|
+
const result = validateInputMapper(input);
|
|
52
|
+
if (!result.ok) {
|
|
53
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", target=${targetWorkflowId}): invalid input mapper`, result.errors);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Reject the legacy `match` callback explicitly so authoring errors are obvious.
|
|
57
|
+
if (typeof declaration.match === "function") {
|
|
58
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}"): the "match" callback is no longer supported. ` +
|
|
59
|
+
`Use the structured "where" predicate instead. See architecture doc §12.`);
|
|
60
|
+
}
|
|
61
|
+
// Canonical content-derived id. Stable across re-deploys because the
|
|
62
|
+
// canonicalized JSON of the declaration is identical for byte-equivalent
|
|
63
|
+
// sources.
|
|
64
|
+
const canonicalDeclaration = {
|
|
65
|
+
eventType,
|
|
66
|
+
where: where ?? null,
|
|
67
|
+
input: input ?? null,
|
|
68
|
+
targetWorkflowId,
|
|
69
|
+
};
|
|
70
|
+
const fullHash = await sha256(canonicalDeclaration);
|
|
71
|
+
const payloadHash = fullHash;
|
|
72
|
+
// Filter id seeds from the same hash but stays human-friendly in logs.
|
|
73
|
+
const id = `ef_${fullHash.slice(0, 16)}`;
|
|
74
|
+
const manifest = {
|
|
75
|
+
id,
|
|
76
|
+
eventType,
|
|
77
|
+
payloadHash,
|
|
78
|
+
targetWorkflowId,
|
|
79
|
+
...(where !== undefined ? { where } : {}),
|
|
80
|
+
...(input !== undefined ? { input } : {}),
|
|
81
|
+
};
|
|
82
|
+
const entry = {
|
|
83
|
+
id,
|
|
84
|
+
eventType,
|
|
85
|
+
manifest,
|
|
86
|
+
declaration: declaration,
|
|
87
|
+
targetWorkflowId,
|
|
88
|
+
};
|
|
89
|
+
return entry;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Compile + register in one step. The synchronous wrapper for `trigger.on()`
|
|
93
|
+
* that user code calls — validates the declaration, computes the
|
|
94
|
+
* content-derived id, registers the entry, and returns it.
|
|
95
|
+
*
|
|
96
|
+
* Returning the full {@link EventFilterRuntimeEntry} is what makes the
|
|
97
|
+
* authoring shape from the architecture doc work directly — modules can
|
|
98
|
+
* write `eventFilters: [trigger.on(...)]` without a registry round-trip:
|
|
99
|
+
* the entry already structurally satisfies `EventFilterDescriptor`
|
|
100
|
+
* (matching `id` + `eventType` fields) and carries the `manifest` payload
|
|
101
|
+
* `createApp()`'s wireWorkflowRuntime needs to register with the driver.
|
|
102
|
+
*/
|
|
103
|
+
export function compileAndRegister(eventType, declaration) {
|
|
104
|
+
// Run validation + compile synchronously where possible. The async
|
|
105
|
+
// boundary is the SHA-256 digest from Web Crypto; we bridge via a
|
|
106
|
+
// synchronous canonical-JSON hash so trigger.on() can stay sync.
|
|
107
|
+
const entry = compileEventFilterSync(eventType, declaration);
|
|
108
|
+
getEventFilterRegistry().add(entry);
|
|
109
|
+
return entry;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Synchronous compile — uses a deterministic but non-cryptographic hash
|
|
113
|
+
* over the canonical JSON. Suitable for the registry id (we just need
|
|
114
|
+
* stable + collision-resistant-enough across realistic registration
|
|
115
|
+
* counts). The crypto-grade `sha256(...)` is used at *manifest build*
|
|
116
|
+
* time when async is fine.
|
|
117
|
+
*/
|
|
118
|
+
export function compileEventFilterSync(eventType, declaration) {
|
|
119
|
+
if (typeof eventType !== "string" || eventType.length === 0) {
|
|
120
|
+
throw new EventFilterCompileError(`trigger.on(eventType, ...): eventType must be a non-empty string`);
|
|
121
|
+
}
|
|
122
|
+
if (typeof declaration !== "object" || declaration === null) {
|
|
123
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", ...): declaration must be an object`);
|
|
124
|
+
}
|
|
125
|
+
if (!declaration.target || typeof declaration.target !== "object") {
|
|
126
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", ...): "target" must be a workflow definition (got ${typeof declaration.target})`);
|
|
127
|
+
}
|
|
128
|
+
const targetWorkflowId = typeof declaration.target.id === "string"
|
|
129
|
+
? declaration.target.id
|
|
130
|
+
: "";
|
|
131
|
+
if (targetWorkflowId.length === 0) {
|
|
132
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", ...): "target.id" must be a non-empty string`);
|
|
133
|
+
}
|
|
134
|
+
const where = declaration.where;
|
|
135
|
+
if (where !== undefined) {
|
|
136
|
+
const result = validatePredicate(where);
|
|
137
|
+
if (!result.ok) {
|
|
138
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", target=${targetWorkflowId}): invalid where clause`, result.errors);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const input = declaration.input;
|
|
142
|
+
if (input !== undefined) {
|
|
143
|
+
const result = validateInputMapper(input);
|
|
144
|
+
if (!result.ok) {
|
|
145
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}", target=${targetWorkflowId}): invalid input mapper`, result.errors);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (typeof declaration.match === "function") {
|
|
149
|
+
throw new EventFilterCompileError(`trigger.on("${eventType}"): the "match" callback is no longer supported. ` +
|
|
150
|
+
`Use the structured "where" predicate instead. See architecture doc §12.`);
|
|
151
|
+
}
|
|
152
|
+
const canonicalDeclaration = {
|
|
153
|
+
eventType,
|
|
154
|
+
where: where ?? null,
|
|
155
|
+
input: input ?? null,
|
|
156
|
+
targetWorkflowId,
|
|
157
|
+
};
|
|
158
|
+
const json = canonicalJson(canonicalDeclaration);
|
|
159
|
+
const shortId = nonCryptoHash16(json);
|
|
160
|
+
const id = `ef_${shortId}`;
|
|
161
|
+
const manifest = {
|
|
162
|
+
id,
|
|
163
|
+
eventType,
|
|
164
|
+
// payloadHash on the manifest is stable (same canonical JSON) but
|
|
165
|
+
// upgraded to the crypto-grade sha256 at manifest-build time. Until
|
|
166
|
+
// then it carries the same short hash so consumers that read it pre-
|
|
167
|
+
// build (e.g. dashboards in dev mode) still see something sensible.
|
|
168
|
+
payloadHash: shortId,
|
|
169
|
+
targetWorkflowId,
|
|
170
|
+
...(where !== undefined ? { where } : {}),
|
|
171
|
+
...(input !== undefined ? { input } : {}),
|
|
172
|
+
};
|
|
173
|
+
return {
|
|
174
|
+
id,
|
|
175
|
+
eventType,
|
|
176
|
+
manifest,
|
|
177
|
+
declaration: declaration,
|
|
178
|
+
targetWorkflowId,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Deterministic 16-hex-char hash for synchronous registration. Uses FNV-1a
|
|
183
|
+
* 64-bit folded into hex — collision-resistant enough at the cardinality of
|
|
184
|
+
* "filters per project" (low thousands at most). The cryptographic SHA-256
|
|
185
|
+
* is the source of truth for manifest-level identity; this is just enough
|
|
186
|
+
* to be a stable id for the in-process registry.
|
|
187
|
+
*/
|
|
188
|
+
function nonCryptoHash16(text) {
|
|
189
|
+
// FNV-1a 64-bit, computed as two 32-bit halves to avoid bigint overhead
|
|
190
|
+
// in tight loops. Output: 16 hex chars (concatenation of the two halves).
|
|
191
|
+
let h1 = 0xcbf29ce4;
|
|
192
|
+
let h2 = 0x84222325;
|
|
193
|
+
for (let i = 0; i < text.length; i++) {
|
|
194
|
+
const c = text.charCodeAt(i);
|
|
195
|
+
h1 = (h1 ^ c) >>> 0;
|
|
196
|
+
h2 = (h2 ^ c) >>> 0;
|
|
197
|
+
// Multiply by 0x100000001b3 split into the two halves.
|
|
198
|
+
const lo = h2 * 0x01b3;
|
|
199
|
+
const hi = h1 * 0x01b3 + Math.floor(lo / 0x100000000);
|
|
200
|
+
h2 = (lo & 0xffffffff) >>> 0;
|
|
201
|
+
h1 = hi >>> 0;
|
|
202
|
+
}
|
|
203
|
+
return h1.toString(16).padStart(8, "0") + h2.toString(16).padStart(8, "0");
|
|
204
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { compileAndRegister, compileEventFilterSync, EventFilterCompileError, } from "./compile.js";
|
|
2
|
+
export type { InputMapper } from "./input-mapper.js";
|
|
3
|
+
export { type InputMapperValidationResult, projectInput, validateInputMapper, } from "./input-mapper.js";
|
|
4
|
+
export { type BuildManifestArgs, buildManifest, } from "./manifest-builder.js";
|
|
5
|
+
export { canonicalize, canonicalJson, deriveStableEventId, sha256, shortHash, } from "./payload-hash.js";
|
|
6
|
+
export { evaluatePredicate, type PathOrLit, type PredicateEnvelope, type PredicateExpr, type PredicateValidationResult, resolvePath, validatePredicate, } from "./predicate.js";
|
|
7
|
+
export { __resetEventFilterRegistry, type EventFilterRuntimeEntry, getEventFilterRegistry, } from "./registry.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EACL,KAAK,2BAA2B,EAChC,YAAY,EACZ,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,KAAK,iBAAiB,EACtB,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,SAAS,GACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,WAAW,EACX,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,0BAA0B,EAC1B,KAAK,uBAAuB,EAC5B,sBAAsB,GACvB,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// `@voyant-travel/workflows/events` — the events runtime: structured `where`
|
|
2
|
+
// predicate + `input` mapper, event-filter registry, manifest builder.
|
|
3
|
+
//
|
|
4
|
+
// Authoritative architecture: docs/architecture/workflows-runtime-architecture.md
|
|
5
|
+
// §12 (trigger.on runtime), §13 (DSLs), §14 (manifest lifecycle).
|
|
6
|
+
export { compileAndRegister, compileEventFilterSync, EventFilterCompileError, } from "./compile.js";
|
|
7
|
+
export { projectInput, validateInputMapper, } from "./input-mapper.js";
|
|
8
|
+
export { buildManifest, } from "./manifest-builder.js";
|
|
9
|
+
export { canonicalize, canonicalJson, deriveStableEventId, sha256, shortHash, } from "./payload-hash.js";
|
|
10
|
+
export { evaluatePredicate, resolvePath, validatePredicate, } from "./predicate.js";
|
|
11
|
+
export { __resetEventFilterRegistry, getEventFilterRegistry, } from "./registry.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type PathOrLit, type PredicateEnvelope } from "./predicate.js";
|
|
2
|
+
export type InputMapper = undefined | {
|
|
3
|
+
passthrough: true;
|
|
4
|
+
} | {
|
|
5
|
+
path: string;
|
|
6
|
+
} | {
|
|
7
|
+
object: Record<string, InputMapper | PathOrLit>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Project a workflow input from an event envelope. Mirrors the predicate
|
|
11
|
+
* evaluator's no-throw contract — missing paths produce `undefined` in the
|
|
12
|
+
* output, registration-time linting catches structural errors.
|
|
13
|
+
*
|
|
14
|
+
* Throws `InputMapperError` only on unexpected shape errors (the mapper
|
|
15
|
+
* itself was constructed wrong). Drivers catch and surface this as
|
|
16
|
+
* `IngestMatch.status === "skipped"` with reason `"input_projection_error"`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function projectInput(mapper: InputMapper, envelope: PredicateEnvelope): unknown;
|
|
19
|
+
export interface InputMapperValidationResult {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
errors: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare function validateInputMapper(mapper: InputMapper): InputMapperValidationResult;
|
|
24
|
+
//# sourceMappingURL=input-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-mapper.d.ts","sourceRoot":"","sources":["../../src/events/input-mapper.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAAe,MAAM,gBAAgB,CAAA;AAIpF,MAAM,MAAM,WAAW,GACnB,SAAS,GACT;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC,CAAA;CAAE,CAAA;AAIvD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAgCtF;AAID,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,2BAA2B,CAIpF"}
|