@blokjs/runner 0.4.0 → 0.6.0
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/Blok.js +32 -3
- package/dist/Blok.js.map +1 -1
- package/dist/Configuration.d.ts +41 -5
- package/dist/Configuration.js +215 -92
- package/dist/Configuration.js.map +1 -1
- package/dist/ForEachNode.d.ts +59 -0
- package/dist/ForEachNode.js +522 -0
- package/dist/ForEachNode.js.map +1 -0
- package/dist/LoopMaxIterationsError.d.ts +11 -0
- package/dist/LoopMaxIterationsError.js +18 -0
- package/dist/LoopMaxIterationsError.js.map +1 -0
- package/dist/LoopNode.d.ts +36 -0
- package/dist/LoopNode.js +182 -0
- package/dist/LoopNode.js.map +1 -0
- package/dist/Runner.d.ts +11 -1
- package/dist/Runner.js +9 -2
- package/dist/Runner.js.map +1 -1
- package/dist/RunnerSteps.js +419 -112
- package/dist/RunnerSteps.js.map +1 -1
- package/dist/RuntimeAdapterNode.d.ts +2 -1
- package/dist/RuntimeAdapterNode.js +2 -2
- package/dist/RuntimeAdapterNode.js.map +1 -1
- package/dist/RuntimeRegistry.d.ts +23 -2
- package/dist/RuntimeRegistry.js +31 -2
- package/dist/RuntimeRegistry.js.map +1 -1
- package/dist/SubworkflowNode.d.ts +106 -0
- package/dist/SubworkflowNode.js +261 -3
- package/dist/SubworkflowNode.js.map +1 -1
- package/dist/SwitchNode.d.ts +37 -0
- package/dist/SwitchNode.js +153 -0
- package/dist/SwitchNode.js.map +1 -0
- package/dist/TriggerBase.d.ts +50 -0
- package/dist/TriggerBase.js +262 -4
- package/dist/TriggerBase.js.map +1 -1
- package/dist/TryCatchNode.d.ts +32 -0
- package/dist/TryCatchNode.js +207 -0
- package/dist/TryCatchNode.js.map +1 -0
- package/dist/adapters/grpc/GrpcCodec.js +2 -2
- package/dist/adapters/grpc/GrpcRuntimeAdapter.d.ts +6 -4
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js +6 -4
- package/dist/adapters/grpc/GrpcRuntimeAdapter.js.map +1 -1
- package/dist/adapters/grpc/types.d.ts +7 -5
- package/dist/adapters/grpc/types.js.map +1 -1
- package/dist/adapters/transport.d.ts +12 -41
- package/dist/adapters/transport.js +21 -70
- package/dist/adapters/transport.js.map +1 -1
- package/dist/cache/NodeResultCache.js +7 -0
- package/dist/cache/NodeResultCache.js.map +1 -1
- package/dist/concurrency/NatsKvConcurrencyBackend.js +18 -5
- package/dist/concurrency/NatsKvConcurrencyBackend.js.map +1 -1
- package/dist/concurrency/RedisConcurrencyBackend.d.ts +64 -0
- package/dist/concurrency/RedisConcurrencyBackend.js +374 -0
- package/dist/concurrency/RedisConcurrencyBackend.js.map +1 -0
- package/dist/concurrency/createConcurrencyBackend.d.ts +1 -0
- package/dist/concurrency/createConcurrencyBackend.js +5 -1
- package/dist/concurrency/createConcurrencyBackend.js.map +1 -1
- package/dist/defineNode.d.ts +8 -0
- package/dist/defineNode.js +25 -5
- package/dist/defineNode.js.map +1 -1
- package/dist/graphql/GraphQLSchemaGenerator.js +1 -1
- package/dist/graphql/GraphQLSchemaGenerator.js.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/marketplace/RuntimeCatalog.d.ts +6 -0
- package/dist/marketplace/RuntimeCatalog.js.map +1 -1
- package/dist/marketplace/RuntimeDiscovery.d.ts +2 -2
- package/dist/marketplace/RuntimeDiscovery.js +18 -6
- package/dist/marketplace/RuntimeDiscovery.js.map +1 -1
- package/dist/monitoring/ConcurrencyMetrics.d.ts +26 -0
- package/dist/monitoring/ConcurrencyMetrics.js +36 -4
- package/dist/monitoring/ConcurrencyMetrics.js.map +1 -1
- package/dist/monitoring/ForEachWaitMetrics.d.ts +22 -0
- package/dist/monitoring/ForEachWaitMetrics.js +36 -0
- package/dist/monitoring/ForEachWaitMetrics.js.map +1 -0
- package/dist/openapi/OpenAPIGenerator.js +7 -2
- package/dist/openapi/OpenAPIGenerator.js.map +1 -1
- package/dist/runtime/PrimitiveStack.d.ts +64 -0
- package/dist/runtime/PrimitiveStack.js +92 -0
- package/dist/runtime/PrimitiveStack.js.map +1 -0
- package/dist/scheduling/DebounceBackend.d.ts +108 -0
- package/dist/scheduling/DebounceBackend.js +23 -0
- package/dist/scheduling/DebounceBackend.js.map +1 -0
- package/dist/scheduling/DebounceCoordinator.d.ts +65 -12
- package/dist/scheduling/DebounceCoordinator.js +234 -13
- package/dist/scheduling/DebounceCoordinator.js.map +1 -1
- package/dist/scheduling/DeferredRunScheduler.d.ts +28 -0
- package/dist/scheduling/DeferredRunScheduler.js +105 -3
- package/dist/scheduling/DeferredRunScheduler.js.map +1 -1
- package/dist/scheduling/NatsKvDebounceBackend.d.ts +53 -0
- package/dist/scheduling/NatsKvDebounceBackend.js +334 -0
- package/dist/scheduling/NatsKvDebounceBackend.js.map +1 -0
- package/dist/scheduling/RedisDebounceBackend.d.ts +49 -0
- package/dist/scheduling/RedisDebounceBackend.js +356 -0
- package/dist/scheduling/RedisDebounceBackend.js.map +1 -0
- package/dist/scheduling/createDebounceBackend.d.ts +25 -0
- package/dist/scheduling/createDebounceBackend.js +39 -0
- package/dist/scheduling/createDebounceBackend.js.map +1 -0
- package/dist/security/AuditLogger.js +1 -1
- package/dist/security/AuditLogger.js.map +1 -1
- package/dist/security/AuthMiddleware.d.ts +19 -20
- package/dist/security/AuthMiddleware.js +35 -20
- package/dist/security/AuthMiddleware.js.map +1 -1
- package/dist/security/OAuthProvider.js +2 -2
- package/dist/security/OAuthProvider.js.map +1 -1
- package/dist/security/SecretManager.js +14 -13
- package/dist/security/SecretManager.js.map +1 -1
- package/dist/security/index.d.ts +3 -1
- package/dist/security/index.js +3 -1
- package/dist/security/index.js.map +1 -1
- package/dist/testing/TestHarness.d.ts +27 -12
- package/dist/testing/TestHarness.js +19 -3
- package/dist/testing/TestHarness.js.map +1 -1
- package/dist/testing/WorkflowTestRunner.js +0 -7
- package/dist/testing/WorkflowTestRunner.js.map +1 -1
- package/dist/tracing/InMemoryRunStore.d.ts +14 -1
- package/dist/tracing/InMemoryRunStore.js +95 -6
- package/dist/tracing/InMemoryRunStore.js.map +1 -1
- package/dist/tracing/PostgresRunStore.d.ts +28 -2
- package/dist/tracing/PostgresRunStore.js +276 -3
- package/dist/tracing/PostgresRunStore.js.map +1 -1
- package/dist/tracing/RoutingDiagnostics.d.ts +55 -0
- package/dist/tracing/RoutingDiagnostics.js +50 -0
- package/dist/tracing/RoutingDiagnostics.js.map +1 -0
- package/dist/tracing/RunStore.d.ts +82 -1
- package/dist/tracing/RunTracker.d.ts +7 -1
- package/dist/tracing/RunTracker.js +23 -0
- package/dist/tracing/RunTracker.js.map +1 -1
- package/dist/tracing/SqliteRunStore.d.ts +57 -2
- package/dist/tracing/SqliteRunStore.js +408 -48
- package/dist/tracing/SqliteRunStore.js.map +1 -1
- package/dist/tracing/TraceRouter.js +380 -18
- package/dist/tracing/TraceRouter.js.map +1 -1
- package/dist/tracing/createStore.js +14 -3
- package/dist/tracing/createStore.js.map +1 -1
- package/dist/tracing/metadataFilter.d.ts +63 -0
- package/dist/tracing/metadataFilter.js +224 -0
- package/dist/tracing/metadataFilter.js.map +1 -0
- package/dist/tracing/types.d.ts +331 -7
- package/dist/utils/envAllowlist.d.ts +35 -0
- package/dist/utils/envAllowlist.js +113 -0
- package/dist/utils/envAllowlist.js.map +1 -0
- package/dist/version/RuntimeVersionValidator.d.ts +38 -0
- package/dist/version/RuntimeVersionValidator.js +121 -0
- package/dist/version/RuntimeVersionValidator.js.map +1 -0
- package/dist/visualization/WorkflowVisualizer.js +4 -4
- package/dist/visualization/WorkflowVisualizer.js.map +1 -1
- package/dist/workflow/PersistenceHelper.d.ts +18 -10
- package/dist/workflow/PersistenceHelper.js +35 -9
- package/dist/workflow/PersistenceHelper.js.map +1 -1
- package/dist/workflow/WorkflowNormalizer.d.ts +19 -1
- package/dist/workflow/WorkflowNormalizer.js +469 -19
- package/dist/workflow/WorkflowNormalizer.js.map +1 -1
- package/dist/workflow/WorkflowRegistry.d.ts +122 -0
- package/dist/workflow/WorkflowRegistry.js +121 -0
- package/dist/workflow/WorkflowRegistry.js.map +1 -1
- package/dist/workflow/sampleBody.d.ts +54 -0
- package/dist/workflow/sampleBody.js +320 -0
- package/dist/workflow/sampleBody.js.map +1 -0
- package/package.json +3 -8
- package/dist/adapters/HttpRuntimeAdapter.d.ts +0 -79
- package/dist/adapters/HttpRuntimeAdapter.js +0 -233
- package/dist/adapters/HttpRuntimeAdapter.js.map +0 -1
package/dist/SubworkflowNode.js
CHANGED
|
@@ -19,6 +19,25 @@ function getMaxDepth() {
|
|
|
19
19
|
}
|
|
20
20
|
return 10;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* G2 — resolve the deployment's self base URL for HTTP self-call
|
|
24
|
+
* dispatch. Reads `BLOK_SELF_BASE_URL` when set (recommended in
|
|
25
|
+
* containerized deployments where `localhost` is just the pod);
|
|
26
|
+
* otherwise defaults to `http://localhost:${PORT || 4000}` which
|
|
27
|
+
* works out-of-box for the dev orchestrator. Always trims a trailing
|
|
28
|
+
* slash so callers can `${base}${path}` without doubling.
|
|
29
|
+
*
|
|
30
|
+
* Exported for tests; production callers go through
|
|
31
|
+
* `SubworkflowNode.dispatchHttpSelf`.
|
|
32
|
+
*/
|
|
33
|
+
export function getSelfBaseUrl() {
|
|
34
|
+
const fromEnv = process.env.BLOK_SELF_BASE_URL;
|
|
35
|
+
if (typeof fromEnv === "string" && fromEnv.length > 0) {
|
|
36
|
+
return fromEnv.endsWith("/") ? fromEnv.slice(0, -1) : fromEnv;
|
|
37
|
+
}
|
|
38
|
+
const port = process.env.PORT && process.env.PORT.length > 0 ? process.env.PORT : "4000";
|
|
39
|
+
return `http://localhost:${port}`;
|
|
40
|
+
}
|
|
22
41
|
/**
|
|
23
42
|
* Internal ctx field that carries the current sub-workflow depth.
|
|
24
43
|
* Incremented by `SubworkflowNode.run` before invoking the child;
|
|
@@ -51,6 +70,51 @@ const SUBWORKFLOW_DEPTH_KEY = "_subworkflowDepth";
|
|
|
51
70
|
* cycle / deep-nesting blast radius. Throws a clear error past the cap.
|
|
52
71
|
*/
|
|
53
72
|
export class SubworkflowNode extends RunnerNode {
|
|
73
|
+
/**
|
|
74
|
+
* v0.7 — optional namespace prefix prepended to the resolved
|
|
75
|
+
* polymorphic name. Used by the Webhook trigger:
|
|
76
|
+
* `namespace: "stripe"` + `subworkflow: "js/ctx.req.body.type"`
|
|
77
|
+
* resolving to `"invoice.paid"` looks up `"stripe.invoice.paid"`.
|
|
78
|
+
* Static names are unaffected.
|
|
79
|
+
*/
|
|
80
|
+
namespace;
|
|
81
|
+
/**
|
|
82
|
+
* G3 (v0.5) — exact-match allow-list for the workflow name dispatched
|
|
83
|
+
* by this step. When set, the **final** resolved name (after any
|
|
84
|
+
* polymorphic `js/...` evaluation AND the `namespace` prefix) must be
|
|
85
|
+
* in this array; otherwise the dispatch is rejected at run time with
|
|
86
|
+
* a structured error. Strongly recommended when `subworkflow` is an
|
|
87
|
+
* expression so a malicious or buggy ctx value can't escalate the
|
|
88
|
+
* workflow surface accessible to a request.
|
|
89
|
+
*
|
|
90
|
+
* `undefined` preserves pre-G3 behaviour (no constraint). Authors
|
|
91
|
+
* with literal `subworkflow:` strings have no reason to set this —
|
|
92
|
+
* the registry lookup already gates dispatch on the literal name.
|
|
93
|
+
*/
|
|
94
|
+
allowList;
|
|
95
|
+
/**
|
|
96
|
+
* G2 (v0.6) — dispatch strategy.
|
|
97
|
+
*
|
|
98
|
+
* - `"in-process"` (default): the child workflow runs in the SAME
|
|
99
|
+
* Node process — synchronous when `wait: true`, `setImmediate`-
|
|
100
|
+
* based when `wait: false`. Cheapest, no extra hops; the historic
|
|
101
|
+
* behaviour.
|
|
102
|
+
* - `"http-self"`: the child is dispatched as a fresh HTTP request
|
|
103
|
+
* to the deployment's own base URL (resolved from
|
|
104
|
+
* `BLOK_SELF_BASE_URL`, defaulting to `http://localhost:${PORT}`).
|
|
105
|
+
* Use when each child run should land on a different process in
|
|
106
|
+
* a horizontally-scaled deployment, or to fully isolate child
|
|
107
|
+
* execution from the parent's call stack. The child MUST have an
|
|
108
|
+
* HTTP trigger — a runtime error is thrown otherwise. Lineage
|
|
109
|
+
* (parentRunId / parentNodeRunId / depth) is preserved across the
|
|
110
|
+
* HTTP hop via `X-Blok-Parent-Run-Id` / `X-Blok-Parent-Node-Run-Id`
|
|
111
|
+
* / `X-Blok-Subworkflow-Depth` headers that the receiving
|
|
112
|
+
* HttpTrigger reads + threads into `tracker.startRun(...)`.
|
|
113
|
+
*
|
|
114
|
+
* Both modes integrate with `wait` and `idempotencyKey` identically
|
|
115
|
+
* (the cache lookup happens BEFORE `SubworkflowNode.run`).
|
|
116
|
+
*/
|
|
117
|
+
dispatch;
|
|
54
118
|
/**
|
|
55
119
|
* Runner-wide options (carries the `nodes` registry that the child
|
|
56
120
|
* Configuration needs for `module` step resolution). Set by
|
|
@@ -64,13 +128,42 @@ export class SubworkflowNode extends RunnerNode {
|
|
|
64
128
|
if (depth > maxDepth) {
|
|
65
129
|
throw new Error(`[blok] Sub-workflow recursion limit exceeded (depth ${depth} > ${maxDepth}). Likely a cycle: workflow "${ctx.workflow_name}" called sub-workflow "${this.subworkflow}" too deep. Bump via BLOK_MAX_SUBWORKFLOW_DEPTH if intentional.`);
|
|
66
130
|
}
|
|
67
|
-
// === 2.
|
|
131
|
+
// === 2. Resolve the child workflow name (polymorphic v0.7) ===
|
|
132
|
+
// Static names ("send-receipt-email") are looked up directly.
|
|
133
|
+
// Mapper-expression names ("js/ctx.req.body.type", "$.req.body.type")
|
|
134
|
+
// are evaluated against the live ctx — the cleanest way to dispatch
|
|
135
|
+
// many handlers from one webhook / event router workflow without a
|
|
136
|
+
// big switch statement. Resolved names go through the same registry
|
|
137
|
+
// lookup as static names.
|
|
138
|
+
const resolvedName = await this.resolveSubworkflowName(ctx);
|
|
68
139
|
const registry = WorkflowRegistry.getInstance();
|
|
69
|
-
const entry = registry.get(
|
|
140
|
+
const entry = registry.get(resolvedName);
|
|
70
141
|
if (!entry) {
|
|
71
142
|
const known = registry.list().map((w) => w.name);
|
|
72
143
|
const knownStr = known.length > 0 ? known.join(", ") : "(none registered yet)";
|
|
73
|
-
throw new Error(`[blok] Sub-workflow "${
|
|
144
|
+
throw new Error(`[blok] Sub-workflow "${resolvedName}" not found in WorkflowRegistry. Available: ${knownStr}. Workflows are registered automatically by the HTTP trigger at boot — make sure the child workflow file is in the scanned directory and has \`name: "${resolvedName}"\`.`);
|
|
145
|
+
}
|
|
146
|
+
// === 2.5. Registry-level authorization ===
|
|
147
|
+
// Default-allow when no hook is installed (preserves pre-v0.4.1
|
|
148
|
+
// behavior). Operators install a hook via
|
|
149
|
+
// WorkflowRegistry.getInstance().setAuthorizeFn(...) for
|
|
150
|
+
// multi-tenant access control. Throws on denial; the parent
|
|
151
|
+
// step's retry loop (if any) will retry — author should pin
|
|
152
|
+
// `retry: undefined` on sub-workflow steps where denial is
|
|
153
|
+
// permanent.
|
|
154
|
+
const allowed = await registry.authorize(ctx.workflow_name ?? "<unknown>", resolvedName, ctx);
|
|
155
|
+
if (!allowed) {
|
|
156
|
+
throw new Error(`[blok] Sub-workflow access denied: workflow "${ctx.workflow_name}" is not authorized to invoke "${resolvedName}". This denial came from the registry-level authorize hook (WorkflowRegistry.setAuthorizeFn). Adjust the hook to allow this composition, or remove the gate.`);
|
|
157
|
+
}
|
|
158
|
+
// === 2.6. G2 — HTTP self-call dispatch ===
|
|
159
|
+
// When `dispatch: "http-self"`, skip the in-process Configuration
|
|
160
|
+
// + Runner materialization entirely. The child workflow runs on
|
|
161
|
+
// the OTHER side of an HTTP request that goes through the
|
|
162
|
+
// deployment's own base URL, hitting whichever process picks it
|
|
163
|
+
// up. The receiving HttpTrigger registers the child run record;
|
|
164
|
+
// this side just makes the HTTP call.
|
|
165
|
+
if (this.dispatch === "http-self") {
|
|
166
|
+
return this.dispatchHttpSelf(ctx, entry, resolvedName, depth);
|
|
74
167
|
}
|
|
75
168
|
// === 3. Materialize child Configuration + Runner ===
|
|
76
169
|
// `preloaded` = entry.workflow skips the disk re-read; the
|
|
@@ -174,6 +267,171 @@ export class SubworkflowNode extends RunnerNode {
|
|
|
174
267
|
* doesn't exist yet). Caller polls `GET /__blok/runs/<runId>` for
|
|
175
268
|
* the actual outcome.
|
|
176
269
|
*/
|
|
270
|
+
/**
|
|
271
|
+
* v0.7 PR 4 — resolve a (possibly polymorphic) sub-workflow name to
|
|
272
|
+
* the actual workflow name in the registry.
|
|
273
|
+
*
|
|
274
|
+
* - Static names ("send-receipt-email") pass through unchanged.
|
|
275
|
+
* - `js/...` expressions are evaluated against the live ctx —
|
|
276
|
+
* `subworkflow: "js/ctx.req.body.type"` becomes `"invoice.paid"`
|
|
277
|
+
* on a request with that body.
|
|
278
|
+
* - `$.<path>` / `${...}` strings go through the same Mapper code
|
|
279
|
+
* path as step inputs (the TS DSL compiles `$` to `"js/ctx..."`
|
|
280
|
+
* by the time the workflow hits Configuration; this branch
|
|
281
|
+
* handles authors who hand-wrote `$` in JSON).
|
|
282
|
+
* - When `this.namespace` is set (from the parent workflow's
|
|
283
|
+
* `trigger.webhook.namespace`), the resolved name is prefixed
|
|
284
|
+
* as `"<namespace>.<resolvedName>"` — only when polymorphic
|
|
285
|
+
* resolution fired AND the resolved name isn't already prefixed.
|
|
286
|
+
*
|
|
287
|
+
* Throws if the expression evaluates to anything other than a
|
|
288
|
+
* non-empty string — operators should see a clear "polymorphic
|
|
289
|
+
* subworkflow name resolved to <T>" error rather than a confusing
|
|
290
|
+
* "workflow not found" downstream.
|
|
291
|
+
*/
|
|
292
|
+
async resolveSubworkflowName(ctx) {
|
|
293
|
+
const raw = this.subworkflow;
|
|
294
|
+
const isExpression = typeof raw === "string" && (raw.startsWith("js/") || raw.startsWith("$.") || raw.startsWith("${"));
|
|
295
|
+
let resolvedName;
|
|
296
|
+
if (!isExpression) {
|
|
297
|
+
resolvedName = raw;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
// Lazy import keeps the static dep graph between runner and
|
|
301
|
+
// shared minimal — most steps don't dispatch sub-workflows.
|
|
302
|
+
const { mapper } = await import("@blokjs/shared");
|
|
303
|
+
// Normalise `$.<path>` → `js/ctx.<path>` so Mapper.replaceString
|
|
304
|
+
// evaluates it. Authors who wrote `js/...` go straight through.
|
|
305
|
+
let expr = raw;
|
|
306
|
+
if (expr.startsWith("$.")) {
|
|
307
|
+
expr = `js/ctx.${expr.slice(2)}`;
|
|
308
|
+
}
|
|
309
|
+
else if (expr.startsWith("$")) {
|
|
310
|
+
expr = `js/${expr.slice(1)}`;
|
|
311
|
+
}
|
|
312
|
+
const resolved = mapper.replaceString(expr, ctx, {});
|
|
313
|
+
if (typeof resolved !== "string" || resolved.length === 0) {
|
|
314
|
+
throw new Error(`[blok] Polymorphic sub-workflow name "${raw}" resolved to ${JSON.stringify(resolved)} (expected a non-empty string). Check the expression and the runtime value of ctx.`);
|
|
315
|
+
}
|
|
316
|
+
resolvedName = resolved;
|
|
317
|
+
}
|
|
318
|
+
// Namespace prefix — applies to polymorphic resolutions when set on
|
|
319
|
+
// the parent workflow's trigger (today: webhook namespace). Static
|
|
320
|
+
// names skip prefixing so they stay routable by their literal name.
|
|
321
|
+
if (isExpression && this.namespace && this.namespace.length > 0 && !resolvedName.startsWith(`${this.namespace}.`)) {
|
|
322
|
+
resolvedName = `${this.namespace}.${resolvedName}`;
|
|
323
|
+
}
|
|
324
|
+
// G3 allow-list enforcement. Checked after namespace prefixing so
|
|
325
|
+
// the value an author writes in the list matches the registry name
|
|
326
|
+
// they intend to permit. Polymorphic dispatch without an allow-list
|
|
327
|
+
// is still allowed (matches pre-G3 behaviour); the schema's
|
|
328
|
+
// describe() recommends pairing them in production.
|
|
329
|
+
if (this.allowList && this.allowList.length > 0 && !this.allowList.includes(resolvedName)) {
|
|
330
|
+
throw new Error(`[blok] Sub-workflow dispatch blocked: resolved name "${resolvedName}" is not in the step's \`allowList\` [${this.allowList.map((n) => `"${n}"`).join(", ")}]. Add it to the list if the dispatch is intended, or audit the workflow whose ctx produced this name.`);
|
|
331
|
+
}
|
|
332
|
+
return resolvedName;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* G2 (v0.6) — HTTP self-call dispatch.
|
|
336
|
+
*
|
|
337
|
+
* Replaces the in-process child Configuration / Runner / Context
|
|
338
|
+
* with an HTTP request to the deployment's own base URL. The
|
|
339
|
+
* receiving HttpTrigger materializes the child as if it were a
|
|
340
|
+
* fresh request — registers its own run record, runs the workflow,
|
|
341
|
+
* returns the response.
|
|
342
|
+
*
|
|
343
|
+
* - `wait: true` (default) — `fetch` is awaited. The HTTP response
|
|
344
|
+
* body becomes this step's `model.data`. A non-2xx response is
|
|
345
|
+
* treated as failure (mirrors the in-process error propagation).
|
|
346
|
+
* - `wait: false` — `fetch` is fired-and-forgotten. The promise's
|
|
347
|
+
* rejection is caught + logged. Parent step's output is
|
|
348
|
+
* `{runId: null, workflowName, scheduledAt}` — the child's runId
|
|
349
|
+
* isn't known on this side until the receiver actually creates
|
|
350
|
+
* the run record. Studio's Sub-runs strip surfaces the child
|
|
351
|
+
* once it lands.
|
|
352
|
+
*
|
|
353
|
+
* Lineage (parentRunId / parentNodeRunId / depth) crosses the HTTP
|
|
354
|
+
* boundary via headers that the receiving HttpTrigger reads + threads
|
|
355
|
+
* into `tracker.startRun(...)`. Same end-result as the in-process
|
|
356
|
+
* path: child's `WorkflowRun` carries the parent ids so Studio renders
|
|
357
|
+
* the breadcrumbs.
|
|
358
|
+
*/
|
|
359
|
+
async dispatchHttpSelf(parentCtx, entry, resolvedName, depth) {
|
|
360
|
+
// === 1. Validate the child has an HTTP trigger ===
|
|
361
|
+
const childWorkflow = entry.workflow;
|
|
362
|
+
const httpTrigger = childWorkflow?.trigger?.http;
|
|
363
|
+
if (!httpTrigger || typeof httpTrigger.path !== "string" || httpTrigger.path.length === 0) {
|
|
364
|
+
throw new Error(`[blok] Sub-workflow dispatch failed: \`dispatch: "http-self"\` requires the child workflow "${resolvedName}" to have an HTTP trigger with an explicit \`trigger.http.path\`. Switch the step to \`dispatch: "in-process"\` (or omit the field) for non-HTTP children, or add an HTTP trigger to the child.`);
|
|
365
|
+
}
|
|
366
|
+
const method = (httpTrigger.method ?? "POST").toUpperCase();
|
|
367
|
+
const path = httpTrigger.path.startsWith("/") ? httpTrigger.path : `/${httpTrigger.path}`;
|
|
368
|
+
// === 2. Resolve the deployment's self base URL ===
|
|
369
|
+
const baseUrl = getSelfBaseUrl();
|
|
370
|
+
const url = `${baseUrl}${path}`;
|
|
371
|
+
// === 3. Build lineage headers ===
|
|
372
|
+
const parentRunId = parentCtx._traceRunId;
|
|
373
|
+
const parentNodeRunId = parentCtx._traceNodeId;
|
|
374
|
+
const headers = {
|
|
375
|
+
"content-type": "application/json",
|
|
376
|
+
// Receiving HttpTrigger reads these in `runWorkflowExecution`
|
|
377
|
+
// and threads them into `tracker.startRun({parentRunId, ...})`.
|
|
378
|
+
// Same shape as the existing `X-Blok-Replay-Of` plumbing.
|
|
379
|
+
"X-Blok-Subworkflow-Depth": String(depth),
|
|
380
|
+
};
|
|
381
|
+
if (parentRunId)
|
|
382
|
+
headers["X-Blok-Parent-Run-Id"] = parentRunId;
|
|
383
|
+
if (parentNodeRunId)
|
|
384
|
+
headers["X-Blok-Parent-Node-Run-Id"] = parentNodeRunId;
|
|
385
|
+
// === 4. Parent step's resolved inputs become the request body ===
|
|
386
|
+
const parentNodeConfig = parentCtx.config?.[this.name];
|
|
387
|
+
const parentInputs = parentNodeConfig?.inputs ?? {};
|
|
388
|
+
const body = JSON.stringify(parentInputs);
|
|
389
|
+
// === 5. Fire-and-forget (wait: false) ===
|
|
390
|
+
if (this.wait === false) {
|
|
391
|
+
const scheduledAt = Date.now();
|
|
392
|
+
fetch(url, { method, headers, body }).catch((err) => {
|
|
393
|
+
console.error(`[blok][subworkflow] http-self dispatch to ${url} failed (wait:false):`, err instanceof Error ? err.stack || err.message : err);
|
|
394
|
+
});
|
|
395
|
+
const dispatchData = {
|
|
396
|
+
runId: null, // unknown on this side — receiving trigger creates the record
|
|
397
|
+
workflowName: entry.name,
|
|
398
|
+
scheduledAt,
|
|
399
|
+
dispatch: "http-self",
|
|
400
|
+
url,
|
|
401
|
+
};
|
|
402
|
+
const result = { success: true, data: dispatchData };
|
|
403
|
+
applyStepOutput(parentCtx, this, result);
|
|
404
|
+
return {
|
|
405
|
+
success: true,
|
|
406
|
+
data: dispatchData,
|
|
407
|
+
error: null,
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
// === 6. Synchronous (wait: true) ===
|
|
411
|
+
let response;
|
|
412
|
+
try {
|
|
413
|
+
response = await fetch(url, { method, headers, body });
|
|
414
|
+
}
|
|
415
|
+
catch (err) {
|
|
416
|
+
// Network-level failure: connection refused, DNS, etc.
|
|
417
|
+
throw new Error(`[blok] Sub-workflow http-self dispatch to ${url} failed: ${err instanceof Error ? err.message : String(err)}. The deployment's self base URL is "${baseUrl}" (set via BLOK_SELF_BASE_URL or defaulted from PORT). Make sure the trigger is listening + the URL is reachable from THIS process.`);
|
|
418
|
+
}
|
|
419
|
+
const responseText = await response.text();
|
|
420
|
+
let responseBody;
|
|
421
|
+
try {
|
|
422
|
+
responseBody = responseText.length > 0 ? JSON.parse(responseText) : undefined;
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
responseBody = responseText;
|
|
426
|
+
}
|
|
427
|
+
if (!response.ok) {
|
|
428
|
+
throw new Error(`[blok] Sub-workflow http-self dispatch returned ${response.status} ${response.statusText} from ${url}. Body: ${typeof responseBody === "string" ? responseBody.slice(0, 500) : JSON.stringify(responseBody).slice(0, 500)}`);
|
|
429
|
+
}
|
|
430
|
+
const resp = { success: true, data: responseBody, error: null };
|
|
431
|
+
const result = { success: true, data: responseBody };
|
|
432
|
+
applyStepOutput(parentCtx, this, result);
|
|
433
|
+
return resp;
|
|
434
|
+
}
|
|
177
435
|
dispatchAsync(parentCtx, childRunner, childCtx, childRunId, childWorkflowName) {
|
|
178
436
|
const scheduledAt = Date.now();
|
|
179
437
|
const tracker = RunTracker.getInstance();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubworkflowNode.js","sourceRoot":"","sources":["../src/SubworkflowNode.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;;;;GAKG;AACH,SAAS,WAAW;IACnB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACnD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;YAAE,OAAO,MAAM,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAwB9C;;;;OAIG;IACI,aAAa,CAAiB;IAErC,KAAK,CAAC,GAAG,CAAC,GAAY;QACrB,6BAA6B;QAC7B,MAAM,KAAK,GAAG,CAAG,GAA+B,CAAC,qBAAqB,CAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC7F,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QA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AAC,SAAyD,CAAC;oBACxF,IAAI,YAAY,EAAE,eAAe,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACnF,YAAY,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;oBACtC,CAAC;gBACF,CAAC;YACF,CAAC,CAAC,EAAE,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,4DAA4D;QAC5D,gEAAgE;QAChE,mCAAmC;QACnC,MAAM,YAAY,GAA4B;YAC7C,KAAK,EAAE,UAAU,IAAI,IAAI;YACzB,YAAY,EAAE,iBAAiB;YAC/B,WAAW;SACX,CAAC;QACF,MAAM,MAAM,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QACrD,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QACzC,OAAO;YACN,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,IAAI;SACX,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SwitchNode — v0.5 primitive. N-way branch keyed on a value. First
|
|
3
|
+
* matching case wins; an optional `default` block runs when no case
|
|
4
|
+
* matches.
|
|
5
|
+
*
|
|
6
|
+
* The runtime config is read from `ctx.config[this.name]`:
|
|
7
|
+
* {
|
|
8
|
+
* on: unknown, // resolved by mapper
|
|
9
|
+
* cases: [{ when, steps: NodeBase[] }], // pre-resolved by Configuration
|
|
10
|
+
* default?: NodeBase[], // pre-resolved
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* Match semantics:
|
|
14
|
+
* - `when` is a literal scalar (string/number/boolean) → match if `on === when`.
|
|
15
|
+
* - `when` is an array → match if `array.includes(on)` (group related cases).
|
|
16
|
+
*
|
|
17
|
+
* Mutations to state inside the matched case's sub-pipeline DO carry
|
|
18
|
+
* forward to subsequent top-level steps — switch is a passthrough flow,
|
|
19
|
+
* NOT an isolation boundary like forEach. The matched case's last step
|
|
20
|
+
* output becomes the switch step's `response.data`.
|
|
21
|
+
*
|
|
22
|
+
* If no case matches and there's no default, the step is a no-op
|
|
23
|
+
* (success, data: null).
|
|
24
|
+
*
|
|
25
|
+
* v0.6 Phase 4 — switch + wait support. The cursor schema
|
|
26
|
+
* (`SwitchIterationContext`) records `caseIndex` (or -1 for `default`)
|
|
27
|
+
* plus `innerStepIndex` within that arm. On re-entry after a wait,
|
|
28
|
+
* SwitchNode reads its cursor from the rehydrated map (keyed by its
|
|
29
|
+
* own NodeRun id), walks back into the matched arm at the right step,
|
|
30
|
+
* and ignores the `on` value entirely — we already committed to a
|
|
31
|
+
* specific arm in the first pass.
|
|
32
|
+
*/
|
|
33
|
+
import type { Context, ResponseContext } from "@blokjs/shared";
|
|
34
|
+
import RunnerNode from "./RunnerNode";
|
|
35
|
+
export declare class SwitchNode extends RunnerNode {
|
|
36
|
+
run(ctx: Context): Promise<ResponseContext>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SwitchNode — v0.5 primitive. N-way branch keyed on a value. First
|
|
3
|
+
* matching case wins; an optional `default` block runs when no case
|
|
4
|
+
* matches.
|
|
5
|
+
*
|
|
6
|
+
* The runtime config is read from `ctx.config[this.name]`:
|
|
7
|
+
* {
|
|
8
|
+
* on: unknown, // resolved by mapper
|
|
9
|
+
* cases: [{ when, steps: NodeBase[] }], // pre-resolved by Configuration
|
|
10
|
+
* default?: NodeBase[], // pre-resolved
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* Match semantics:
|
|
14
|
+
* - `when` is a literal scalar (string/number/boolean) → match if `on === when`.
|
|
15
|
+
* - `when` is an array → match if `array.includes(on)` (group related cases).
|
|
16
|
+
*
|
|
17
|
+
* Mutations to state inside the matched case's sub-pipeline DO carry
|
|
18
|
+
* forward to subsequent top-level steps — switch is a passthrough flow,
|
|
19
|
+
* NOT an isolation boundary like forEach. The matched case's last step
|
|
20
|
+
* output becomes the switch step's `response.data`.
|
|
21
|
+
*
|
|
22
|
+
* If no case matches and there's no default, the step is a no-op
|
|
23
|
+
* (success, data: null).
|
|
24
|
+
*
|
|
25
|
+
* v0.6 Phase 4 — switch + wait support. The cursor schema
|
|
26
|
+
* (`SwitchIterationContext`) records `caseIndex` (or -1 for `default`)
|
|
27
|
+
* plus `innerStepIndex` within that arm. On re-entry after a wait,
|
|
28
|
+
* SwitchNode reads its cursor from the rehydrated map (keyed by its
|
|
29
|
+
* own NodeRun id), walks back into the matched arm at the right step,
|
|
30
|
+
* and ignores the `on` value entirely — we already committed to a
|
|
31
|
+
* specific arm in the first pass.
|
|
32
|
+
*/
|
|
33
|
+
import RunnerNode from "./RunnerNode";
|
|
34
|
+
import { consumeRehydratedCursor, popPrimitiveFrame, pushPrimitiveFrame, readRehydratedCursor, } from "./runtime/PrimitiveStack";
|
|
35
|
+
import { applyStepOutput } from "./workflow/PersistenceHelper";
|
|
36
|
+
/** Sentinel `caseIndex` value meaning "the `default` arm matched". */
|
|
37
|
+
const DEFAULT_ARM = -1;
|
|
38
|
+
function caseMatches(when, on) {
|
|
39
|
+
if (Array.isArray(when)) {
|
|
40
|
+
return when.some((w) => w === on);
|
|
41
|
+
}
|
|
42
|
+
return when === on;
|
|
43
|
+
}
|
|
44
|
+
export class SwitchNode extends RunnerNode {
|
|
45
|
+
async run(ctx) {
|
|
46
|
+
this.contentType = "application/json";
|
|
47
|
+
const response = { success: true, data: null, error: null };
|
|
48
|
+
const opts = (ctx.config?.[this.name] ?? {});
|
|
49
|
+
const on = opts.on;
|
|
50
|
+
const cases = Array.isArray(opts.cases) ? opts.cases : [];
|
|
51
|
+
const defaultSteps = Array.isArray(opts.default) ? opts.default : undefined;
|
|
52
|
+
// v0.6 Phase 4 — resume cursor lookup. On re-entry from a wait
|
|
53
|
+
// fired inside a switch case, the persisted NodeRun's
|
|
54
|
+
// iteration_context carries the matched arm + inner step index.
|
|
55
|
+
const ctxAny = ctx;
|
|
56
|
+
const myNodeRunId = ctxAny._traceNodeId;
|
|
57
|
+
// Phase 4 — lookup by step NAME (stable across re-entries).
|
|
58
|
+
const resumeRaw = readRehydratedCursor(ctx, this.name);
|
|
59
|
+
const resume = resumeRaw && resumeRaw.mode === "switch" ? resumeRaw : undefined;
|
|
60
|
+
if (resume) {
|
|
61
|
+
consumeRehydratedCursor(ctx, this.name);
|
|
62
|
+
}
|
|
63
|
+
// Case selection. On resume, skip re-evaluating the `when`
|
|
64
|
+
// expressions — we've already committed to a specific arm and
|
|
65
|
+
// `on` could have changed mid-flight (different ctx state after
|
|
66
|
+
// pre-wait mutations). Walk straight back into the cached arm.
|
|
67
|
+
let selected;
|
|
68
|
+
let selectedCaseIndex = DEFAULT_ARM;
|
|
69
|
+
if (resume !== undefined) {
|
|
70
|
+
if (resume.caseIndex === DEFAULT_ARM) {
|
|
71
|
+
selected = defaultSteps;
|
|
72
|
+
}
|
|
73
|
+
else if (resume.caseIndex >= 0 && resume.caseIndex < cases.length) {
|
|
74
|
+
selected = cases[resume.caseIndex].steps;
|
|
75
|
+
selectedCaseIndex = resume.caseIndex;
|
|
76
|
+
}
|
|
77
|
+
// Cursor pointed at an arm that no longer exists (case removed
|
|
78
|
+
// between deploys, etc.). Fall through to fresh first-match
|
|
79
|
+
// behaviour — better than crashing the resume.
|
|
80
|
+
}
|
|
81
|
+
if (selected === undefined && resume === undefined) {
|
|
82
|
+
for (let idx = 0; idx < cases.length; idx++) {
|
|
83
|
+
if (caseMatches(cases[idx].when, on)) {
|
|
84
|
+
selected = cases[idx].steps;
|
|
85
|
+
selectedCaseIndex = idx;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (selected === undefined) {
|
|
90
|
+
selected = defaultSteps;
|
|
91
|
+
if (selected !== undefined)
|
|
92
|
+
selectedCaseIndex = DEFAULT_ARM;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (selected === undefined || selected.length === 0) {
|
|
96
|
+
// No matching case + no default → no-op success. State
|
|
97
|
+
// entry is `null` so downstream `$.state[<id>]` reads return
|
|
98
|
+
// null (not undefined) — keeps the persistence model uniform.
|
|
99
|
+
applyStepOutput(ctx, this, { data: null });
|
|
100
|
+
// Preserve the previous step's ctx.response so the NEXT
|
|
101
|
+
// top-level step doesn't dereference null when RunnerSteps
|
|
102
|
+
// assigns `ctx.response.contentType`.
|
|
103
|
+
response.data = ctx.response;
|
|
104
|
+
return response;
|
|
105
|
+
}
|
|
106
|
+
// v0.6 Phase 4 — push a primitive frame so a nested wait fired
|
|
107
|
+
// inside this case's sub-pipeline persists the cursor on
|
|
108
|
+
// THIS switch's NodeRun. `innerStepIndex` is updated at each
|
|
109
|
+
// step boundary inside the case body by RunnerSteps; we just
|
|
110
|
+
// keep `caseIndex` pinned for the duration of this run.
|
|
111
|
+
const initialCursor = {
|
|
112
|
+
mode: "switch",
|
|
113
|
+
caseIndex: selectedCaseIndex,
|
|
114
|
+
innerStepIndex: resume?.innerStepIndex ?? 0,
|
|
115
|
+
completedResults: [],
|
|
116
|
+
};
|
|
117
|
+
const frame = myNodeRunId
|
|
118
|
+
? { nodeRunId: myNodeRunId, cursor: initialCursor }
|
|
119
|
+
: undefined;
|
|
120
|
+
if (frame)
|
|
121
|
+
pushPrimitiveFrame(ctx, frame);
|
|
122
|
+
try {
|
|
123
|
+
// Lazy import — same circular-dep guard ForEach/Loop use.
|
|
124
|
+
const { default: Runner } = await import("./Runner");
|
|
125
|
+
const runner = new Runner(selected);
|
|
126
|
+
// On resume, pass the inner-step resume index — INCLUDING
|
|
127
|
+
// the index-0 case where the wait is the very first step
|
|
128
|
+
// of the matched arm. The deep runSteps' wait re-entry
|
|
129
|
+
// detection uses `innerResumeIndex !== undefined` as the
|
|
130
|
+
// "this primitive resumed here" signal (Phase 4 fix).
|
|
131
|
+
if (resume) {
|
|
132
|
+
ctxAny._blokInnerResumeIndex = resume.innerStepIndex;
|
|
133
|
+
}
|
|
134
|
+
// `deep: true` so the inner runSteps doesn't inherit the
|
|
135
|
+
// outer run's `lastCompletedStepIndex` cursor (PR 4 wait/
|
|
136
|
+
// resume logic).
|
|
137
|
+
await runner.run(ctx, { deep: true, stepName: this.name });
|
|
138
|
+
// Switch is a passthrough — the matched case ran on the
|
|
139
|
+
// parent ctx, so state mutations are already visible to
|
|
140
|
+
// downstream steps. The switch step's own data is the last
|
|
141
|
+
// inner step's response.
|
|
142
|
+
const data = ctx.response;
|
|
143
|
+
response.data = data;
|
|
144
|
+
applyStepOutput(ctx, this, { data });
|
|
145
|
+
return response;
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
if (frame)
|
|
149
|
+
popPrimitiveFrame(ctx);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=SwitchNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchNode.js","sourceRoot":"","sources":["../src/SwitchNode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAEN,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAa/D,sEAAsE;AACtE,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC;AAEvB,SAAS,WAAW,CAAC,IAAa,EAAE,EAAW;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,OAAO,UAAW,SAAQ,U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AC,GAAG,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YACrC,OAAO,QAAQ,CAAC;QACjB,CAAC;gBAAS,CAAC;YACV,IAAI,KAAK;gBAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;IACF,CAAC;CACD"}
|
package/dist/TriggerBase.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { PrometheusMetricsBridge } from "./monitoring/PrometheusMetricsBridge";
|
|
|
11
11
|
import { RateLimiter } from "./monitoring/RateLimiter";
|
|
12
12
|
import type { RateLimitConfig, RateLimitResult } from "./monitoring/RateLimiter";
|
|
13
13
|
import { TriggerMetricsCollector } from "./monitoring/TriggerMetricsCollector";
|
|
14
|
+
import type GlobalOptions from "./types/GlobalOptions";
|
|
14
15
|
import type TriggerResponse from "./types/TriggerResponse";
|
|
15
16
|
/**
|
|
16
17
|
* Tier 2 quick-wins follow-up · structural logger interface used by
|
|
@@ -71,6 +72,55 @@ export default abstract class TriggerBase extends Trigger {
|
|
|
71
72
|
* the class name doesn't naturally produce the right tag.
|
|
72
73
|
*/
|
|
73
74
|
protected getTriggerType(): string;
|
|
75
|
+
/**
|
|
76
|
+
* v0.6 — apply the merged middleware chain (process-global → workflow-level
|
|
77
|
+
* → trigger-level) to `ctx` before the main workflow body runs.
|
|
78
|
+
*
|
|
79
|
+
* Trigger-level names are read from
|
|
80
|
+
* `this.configuration.trigger[<this.getTriggerType()>].middleware`, so
|
|
81
|
+
* HttpTrigger reads `trigger.http.middleware`, WorkerTrigger reads
|
|
82
|
+
* `trigger.worker.middleware`, CronTrigger reads `trigger.cron.middleware`.
|
|
83
|
+
*
|
|
84
|
+
* Pre-v0.6 the merge code lived inline in `HttpTrigger.run` and worker
|
|
85
|
+
* + cron triggers silently skipped middleware. Centralising it on
|
|
86
|
+
* TriggerBase gives all three trigger families uniform semantics.
|
|
87
|
+
*
|
|
88
|
+
* Resolution order outer→inner:
|
|
89
|
+
* process-global → workflow-level → trigger-level → main workflow body.
|
|
90
|
+
*
|
|
91
|
+
* State mutations from earlier middleware (e.g. `ctx.state.identity`
|
|
92
|
+
* from auth-check) carry forward to later middleware and the main
|
|
93
|
+
* workflow because they share the same ctx. Middleware authors
|
|
94
|
+
* short-circuit via `@blokjs/throw` — the throw propagates to the
|
|
95
|
+
* caller's outer catch, and the main workflow does NOT run.
|
|
96
|
+
*/
|
|
97
|
+
protected applyMiddlewareChain(ctx: Context, nodeMap: GlobalOptions): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* v0.6 — dispatch a chain of middleware workflows on the same parent
|
|
100
|
+
* ctx. Each entry in `names` is the `name:` of a workflow registered
|
|
101
|
+
* with `middleware: true`. For each:
|
|
102
|
+
*
|
|
103
|
+
* - Materialise a fresh `Configuration` for the middleware (resolves
|
|
104
|
+
* its inner steps + nodes against `nodeMap` so `@blokjs/throw`
|
|
105
|
+
* etc. resolve from `@blokjs/helpers`).
|
|
106
|
+
* - Save the parent ctx.config; swap in the middleware's resolved
|
|
107
|
+
* `mwConfig.nodes` so the blueprint mapper finds the middleware's
|
|
108
|
+
* step inputs.
|
|
109
|
+
* - Run via `new Runner(...).run(ctx, { deep: true })` — `deep: true`
|
|
110
|
+
* prevents the inner runSteps from inheriting the outer run's
|
|
111
|
+
* `lastCompletedStepIndex` cursor (PR 4 wait/resume hazard).
|
|
112
|
+
* - Restore parent ctx.config in `finally`.
|
|
113
|
+
*
|
|
114
|
+
* Missing middleware (name not registered) is a configuration error
|
|
115
|
+
* — throws a clear message naming the unknown middleware. Authors
|
|
116
|
+
* typically use `@blokjs/throw` inside middleware with a `code:` to
|
|
117
|
+
* produce structured HTTP responses (e.g. 401) — those throws
|
|
118
|
+
* propagate to the outer catch in the calling trigger.
|
|
119
|
+
*
|
|
120
|
+
* Pre-v0.6 this lived as a private method on `HttpTrigger`. Lifted
|
|
121
|
+
* here so worker + cron triggers can reuse it without duplication.
|
|
122
|
+
*/
|
|
123
|
+
protected runMiddlewareChain(ctx: Context, names: readonly string[], nodeMap: GlobalOptions): Promise<void>;
|
|
74
124
|
/** Flag — set true after `installCrashHandlers` has run once in this process. */
|
|
75
125
|
private static crashHandlersInstalled;
|
|
76
126
|
/**
|