@nanobpm/workflow 0.8.2 → 0.10.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.
Files changed (65) hide show
  1. package/README.md +73 -2
  2. package/dist/declarative.d.ts +178 -10
  3. package/dist/declarative.js +216 -356
  4. package/dist/nodes/branch.d.ts +11 -0
  5. package/dist/nodes/branch.js +40 -0
  6. package/dist/nodes/break.d.ts +8 -0
  7. package/dist/nodes/break.js +19 -0
  8. package/dist/nodes/continue.d.ts +8 -0
  9. package/dist/nodes/continue.js +18 -0
  10. package/dist/nodes/forEach.d.ts +24 -0
  11. package/dist/nodes/forEach.js +109 -0
  12. package/dist/nodes/index.d.ts +12 -0
  13. package/dist/nodes/index.js +19 -0
  14. package/dist/nodes/loop.d.ts +9 -0
  15. package/dist/nodes/loop.js +25 -0
  16. package/dist/nodes/parallel.d.ts +9 -0
  17. package/dist/nodes/parallel.js +40 -0
  18. package/dist/nodes/race.d.ts +54 -0
  19. package/dist/nodes/race.js +134 -0
  20. package/dist/nodes/registry.d.ts +33 -0
  21. package/dist/nodes/registry.js +71 -0
  22. package/dist/nodes/run.d.ts +10 -0
  23. package/dist/nodes/run.js +21 -0
  24. package/dist/nodes/signal.d.ts +11 -0
  25. package/dist/nodes/signal.js +26 -0
  26. package/dist/nodes/switch.d.ts +11 -0
  27. package/dist/nodes/switch.js +51 -0
  28. package/dist/nodes/task.d.ts +47 -0
  29. package/dist/nodes/task.js +97 -0
  30. package/dist/nodes/timer.d.ts +9 -0
  31. package/dist/nodes/timer.js +34 -0
  32. package/dist/test-support/diff.d.ts +8 -0
  33. package/dist/test-support/diff.js +70 -0
  34. package/dist/test-support/index.d.ts +8 -0
  35. package/dist/test-support/index.js +49 -0
  36. package/dist/test-support/normalize.d.ts +19 -0
  37. package/dist/test-support/normalize.js +245 -0
  38. package/dist/test-support/parity.d.ts +28 -0
  39. package/dist/test-support/parity.js +61 -0
  40. package/dist/test-support/xml.d.ts +17 -0
  41. package/dist/test-support/xml.js +135 -0
  42. package/dist/types.d.ts +20 -56
  43. package/package.json +12 -4
  44. package/src/declarative.ts +339 -360
  45. package/src/nodes/README.md +123 -0
  46. package/src/nodes/branch.ts +48 -0
  47. package/src/nodes/break.ts +25 -0
  48. package/src/nodes/continue.ts +24 -0
  49. package/src/nodes/forEach.ts +142 -0
  50. package/src/nodes/index.ts +20 -0
  51. package/src/nodes/loop.ts +34 -0
  52. package/src/nodes/parallel.ts +48 -0
  53. package/src/nodes/race.ts +185 -0
  54. package/src/nodes/registry.ts +105 -0
  55. package/src/nodes/run.ts +29 -0
  56. package/src/nodes/signal.ts +35 -0
  57. package/src/nodes/switch.ts +56 -0
  58. package/src/nodes/task.ts +150 -0
  59. package/src/nodes/timer.ts +42 -0
  60. package/src/test-support/diff.ts +69 -0
  61. package/src/test-support/index.ts +53 -0
  62. package/src/test-support/normalize.ts +274 -0
  63. package/src/test-support/parity.ts +85 -0
  64. package/src/test-support/xml.ts +140 -0
  65. package/src/types.ts +20 -30
@@ -0,0 +1,10 @@
1
+ declare module "../types.js" {
2
+ interface FlowNodeRegistry {
3
+ run: {
4
+ kind: "run";
5
+ name: string;
6
+ envelopes?: NodeEnvelopes;
7
+ };
8
+ }
9
+ }
10
+ export {};
@@ -0,0 +1,21 @@
1
+ // Built-in flow-node kind: `run` — a durable service task served by a worker
2
+ // THIS program hosts (its handler runs in the in-process `Worker`). Contributed
3
+ // entirely from this module through the extension seam (epic #314, S0/#315):
4
+ // its `FlowNode` variant, its `w.run(...)` builder method, and its walk/emit
5
+ // handlers — with NO edit to the shared union or a central dispatch switch.
6
+ import { registerNodeKind } from "./registry.js";
7
+ registerNodeKind("run", {
8
+ build: (api) => (name, handler) => {
9
+ api.claim(name);
10
+ if (typeof handler !== "function")
11
+ throw new Error(`run("${name}") needs a handler function`);
12
+ api.handlers[name] = handler;
13
+ api.out.push({ kind: "run", name, envelopes: api.contractEnvelopes(name) });
14
+ return api.self();
15
+ },
16
+ emit: (node, incoming, _loop, api) => {
17
+ api.addServiceTask(node);
18
+ api.connect(incoming, node.name);
19
+ return [api.newEdge(node.name)];
20
+ },
21
+ });
@@ -0,0 +1,11 @@
1
+ import type { Envelope } from "../envelope.js";
2
+ declare module "../types.js" {
3
+ interface FlowNodeRegistry {
4
+ signal: {
5
+ kind: "signal";
6
+ name: string;
7
+ correlationKey: string;
8
+ payload?: Envelope;
9
+ };
10
+ }
11
+ }
@@ -0,0 +1,26 @@
1
+ // Built-in flow-node kind: `signal` — a durable wait for an external/human event
2
+ // correlated on a process variable (a BPMN message intermediate catch event).
3
+ // Contributed from this module through the extension seam (epic #314, S0/#315).
4
+ import { assertIdent } from "../xml.js";
5
+ import { registerNodeKind } from "./registry.js";
6
+ registerNodeKind("signal", {
7
+ build: (api) => (name, opts) => {
8
+ api.claim(name);
9
+ if (!opts || typeof opts.correlationKey !== "string" || opts.correlationKey.trim() === "") {
10
+ throw new Error(`signal("${name}") needs { correlationKey }`);
11
+ }
12
+ // Trim before validating/storing, in parity with the race() signal arm: a
13
+ // value like " prKey " is usable after trimming, so it must not fail the
14
+ // NCName check on stray whitespace. Name the node in the assertIdent context.
15
+ const correlationKey = opts.correlationKey.trim();
16
+ assertIdent(`signal("${name}") correlationKey`, correlationKey);
17
+ api.out.push({ kind: "signal", name, correlationKey, payload: api.contracts[name]?.in });
18
+ return api.self();
19
+ },
20
+ emit: (node, incoming, _loop, api) => {
21
+ api.addCatchEvent(node);
22
+ api.connect(incoming, node.name);
23
+ api.recordEnvelope(node.payload);
24
+ return [api.newEdge(node.name)];
25
+ },
26
+ });
@@ -0,0 +1,11 @@
1
+ declare module "../types.js" {
2
+ interface FlowNodeRegistry {
3
+ switch: {
4
+ kind: "switch";
5
+ subject: string;
6
+ cases: SwitchCase[];
7
+ default?: FlowNode[];
8
+ };
9
+ }
10
+ }
11
+ export {};
@@ -0,0 +1,51 @@
1
+ // Built-in flow-node kind: `switch` — a multi-way exclusive choice (a BPMN
2
+ // exclusive gateway); each case routes when `subject` equals the case value, with
3
+ // an optional unconditional `default`. Contributed through the extension seam.
4
+ import { feelEquals } from "../declarative.js";
5
+ import { registerNodeKind } from "./registry.js";
6
+ registerNodeKind("switch", {
7
+ build: (api) => (subject, cases) => {
8
+ if (typeof subject !== "string" || subject.trim() === "") {
9
+ throw new Error(`switch() needs a non-empty subject expression`);
10
+ }
11
+ if (cases === null || typeof cases !== "object") {
12
+ throw new Error(`switch("${subject}") needs a cases object { value: (b) => {…} }`);
13
+ }
14
+ const caseNodes = [];
15
+ for (const [value, fn] of Object.entries(cases)) {
16
+ if (value === "default")
17
+ continue;
18
+ if (typeof fn !== "function")
19
+ throw new Error(`switch("${subject}") cases must be blocks (b) => {…}`);
20
+ caseNodes.push({ value, body: api.child(fn, false) });
21
+ }
22
+ if (caseNodes.length === 0)
23
+ throw new Error(`switch("${subject}") needs at least one case`);
24
+ if (cases.default !== undefined && typeof cases.default !== "function") {
25
+ throw new Error(`switch("${subject}") default must be a block (b) => {…}`);
26
+ }
27
+ const def = cases.default ? api.child(cases.default, false) : undefined;
28
+ api.out.push({ kind: "switch", subject, cases: caseNodes, default: def });
29
+ return api.self();
30
+ },
31
+ walk: (node, recurse) => {
32
+ for (const c of node.cases)
33
+ recurse(c.body);
34
+ if (node.default)
35
+ recurse(node.default);
36
+ },
37
+ emit: (node, incoming, loop, api) => {
38
+ const id = `Gw_${api.nextGw()}`;
39
+ const gw = api.addGateway(id, node.subject);
40
+ api.connect(incoming, id);
41
+ const out = [];
42
+ for (const c of node.cases) {
43
+ const e = api.newEdge(id, { condition: feelEquals(node.subject, c.value), name: c.value });
44
+ out.push(...api.emitList(c.body, [e], loop));
45
+ }
46
+ const de = api.newEdge(id, { name: "default" });
47
+ gw.defaultFlow = de.id;
48
+ out.push(...api.emitList(node.default ?? [], [de], loop));
49
+ return out;
50
+ },
51
+ });
@@ -0,0 +1,47 @@
1
+ /** Binds an LLM prompt resource to an agent service task. Emits, alongside the
2
+ * task's `zeebe:taskDefinition` capability token, a
3
+ * `<zeebe:linkedResources><zeebe:linkedResource resourceId=… bindingType=…
4
+ * resourceType="GenericScript" linkName="prompt"/></zeebe:linkedResources>`
5
+ * extension — the shape the nano-workforce agent tasks use to attach a prompt
6
+ * script to the worker that services the job. */
7
+ export interface PromptBinding {
8
+ /** The `GenericScript` resource id bound as the prompt (the linkedResource
9
+ * `resourceId`, e.g. `"retro.md"`). Required and non-empty. */
10
+ resourceId: string;
11
+ /** The linkedResource `bindingType` — how the engine resolves the resource
12
+ * version at deploy time. Defaults to `"latest"`. */
13
+ bindingType?: string;
14
+ /** Optional prompt addendum: a FEEL expression (or literal) fed to the worker
15
+ * through a `<zeebe:ioMapping><zeebe:input source=… target="appendPrompt"/>`
16
+ * input, the convention the agent tasks use to append runtime context to the
17
+ * bound prompt. Omitted → no `ioMapping` is emitted. */
18
+ append?: string;
19
+ }
20
+ declare module "../types.js" {
21
+ interface FlowNodeRegistry {
22
+ task: {
23
+ kind: "task";
24
+ name: string;
25
+ envelopes?: NodeEnvelopes;
26
+ jobType?: string;
27
+ /** The agent prompt binding, when the task is an LLM-agent service task. */
28
+ prompt?: PromptBinding;
29
+ };
30
+ }
31
+ }
32
+ declare module "../declarative.js" {
33
+ interface FlowBuilder<C extends object> {
34
+ /**
35
+ * An AGENT external service task: as `task`, but additionally binds an LLM
36
+ * `prompt` resource to the worker via a `zeebe:linkedResource`
37
+ * (`resourceType="GenericScript" linkName="prompt"`). Pair it with a
38
+ * `{ jobType }` capability token (e.g. `senior:retro`) so an agent pool
39
+ * services it. `prompt.append` (optional) feeds a FEEL expression to the
40
+ * worker through a `zeebe:ioMapping` `appendPrompt` input.
41
+ */
42
+ task<K extends string>(name: K, opts: {
43
+ jobType?: string;
44
+ prompt: PromptBinding;
45
+ }): FlowBuilder<C>;
46
+ }
47
+ }
@@ -0,0 +1,97 @@
1
+ // Built-in flow-node kind: `task` — a durable service task served by a worker
2
+ // OUTSIDE this program (no locally-hosted handler). Its job type defaults to the
3
+ // derived `${flowId}:${name}` unless overridden with `{ jobType }`. Contributed
4
+ // from this module through the extension seam (epic #314, S0/#315).
5
+ //
6
+ // This module also owns the AGENT PROMPT BINDING (epic #314, S4/#319): an
7
+ // optional `{ prompt }` option binds an LLM prompt resource to the worker via a
8
+ // `<zeebe:linkedResource … resourceType="GenericScript" linkName="prompt">`,
9
+ // mirroring the nano-workforce agent service tasks. The extension is contributed
10
+ // entirely from this module — the `task` node's own registered emit handler and
11
+ // its option type — WITHOUT re-opening the shared `FlowNode` union, the central
12
+ // `walkNodes`/`emitNode` dispatch, or the generated barrel.
13
+ import { assertJobType, escapeXml } from "../xml.js";
14
+ import { registerNodeKind } from "./registry.js";
15
+ /** Normalize + validate a prompt binding at authoring time, applying the
16
+ * `bindingType` default. Emitted string fields are trimmed before storing (in
17
+ * parity with how `timer` normalizes `{ after }`/`{ at }`), so a value like
18
+ * `resourceId: " retro.md "` passes validation AND is emitted without stray
19
+ * surrounding whitespace. Returns a fully-resolved binding stored on the node. */
20
+ function resolvePrompt(name, prompt) {
21
+ if (typeof prompt !== "object" || prompt === null) {
22
+ throw new Error(`task("${name}") prompt must be an object with a non-empty resourceId`);
23
+ }
24
+ const resourceId = prompt.resourceId;
25
+ if (typeof resourceId !== "string" || resourceId.trim() === "") {
26
+ throw new Error(`task("${name}") prompt.resourceId must be a non-empty string`);
27
+ }
28
+ // Only an ABSENT bindingType defaults to "latest"; `??` would also swallow an
29
+ // explicit `null`, masking an authoring mistake. Distinguish `undefined` (use
30
+ // the default) from any other non-string (reject), in parity with how `append`
31
+ // below treats `!== undefined` as "provided, so validate strictly".
32
+ const bindingType = prompt.bindingType === undefined ? "latest" : prompt.bindingType;
33
+ if (typeof bindingType !== "string" || bindingType.trim() === "") {
34
+ throw new Error(`task("${name}") prompt.bindingType must be a non-empty string`);
35
+ }
36
+ const resolved = { resourceId: resourceId.trim(), bindingType: bindingType.trim() };
37
+ if (prompt.append !== undefined) {
38
+ if (typeof prompt.append !== "string" || prompt.append.trim() === "") {
39
+ throw new Error(`task("${name}") prompt.append must be a non-empty string when provided`);
40
+ }
41
+ resolved.append = prompt.append.trim();
42
+ }
43
+ return resolved;
44
+ }
45
+ /** Build the prompt-specific `<bpmn:extensionElements>` delta appended to the
46
+ * shared service-task emission: the `zeebe:linkedResources` prompt binding and
47
+ * (optionally) a `zeebe:ioMapping` `appendPrompt` input. The task shell
48
+ * (taskDefinition + envelope properties) is rendered by the built-in
49
+ * `EmitApi.addServiceTask`, so this variant only contributes its delta and the
50
+ * envelope serialization can never drift from the plain service task. */
51
+ function promptExtensions(prompt) {
52
+ const { resourceId, bindingType, append } = prompt;
53
+ const linked = ` <zeebe:linkedResources>\n` +
54
+ ` <zeebe:linkedResource resourceId="${escapeXml(resourceId)}" ` +
55
+ `bindingType="${escapeXml(bindingType ?? "latest")}" resourceType="GenericScript" linkName="prompt" />\n` +
56
+ ` </zeebe:linkedResources>\n`;
57
+ const io = append !== undefined
58
+ ? ` <zeebe:ioMapping>\n` +
59
+ ` <zeebe:input source="${escapeXml(append)}" target="appendPrompt" />\n` +
60
+ ` </zeebe:ioMapping>\n`
61
+ : "";
62
+ return linked + io;
63
+ }
64
+ registerNodeKind("task", {
65
+ build: (api) => (name, opts) => {
66
+ api.claim(name);
67
+ const override = opts?.jobType;
68
+ if (override !== undefined)
69
+ assertJobType("task jobType", override);
70
+ const prompt = opts?.prompt !== undefined ? resolvePrompt(name, opts.prompt) : undefined;
71
+ api.out.push({
72
+ kind: "task",
73
+ name,
74
+ envelopes: api.contractEnvelopes(name),
75
+ jobType: override,
76
+ prompt,
77
+ });
78
+ return api.self();
79
+ },
80
+ emit: (node, incoming, _loop, api) => {
81
+ // No prompt → the standard service-task emission is preserved unchanged (no
82
+ // `linkedResources` are emitted).
83
+ if (node.prompt === undefined) {
84
+ api.addServiceTask(node);
85
+ api.connect(incoming, node.name);
86
+ return [api.newEdge(node.name)];
87
+ }
88
+ // Prompt binding present → the shared `addServiceTask` renders the task
89
+ // shell (taskDefinition + envelope properties, recording envelopes); we only
90
+ // supply the `zeebe:linkedResource` (and optional `appendPrompt` ioMapping)
91
+ // delta, so the envelope/taskDefinition serialization has a single source.
92
+ const prompt = node.prompt;
93
+ api.addServiceTask(node, { extraExt: promptExtensions(prompt) });
94
+ api.connect(incoming, node.name);
95
+ return [api.newEdge(node.name)];
96
+ },
97
+ });
@@ -0,0 +1,9 @@
1
+ declare module "../types.js" {
2
+ interface FlowNodeRegistry {
3
+ timer: {
4
+ kind: "timer";
5
+ name: string;
6
+ } & TimerAt;
7
+ }
8
+ }
9
+ export {};
@@ -0,0 +1,34 @@
1
+ // Built-in flow-node kind: `timer` — a durable wait for a point in time (a BPMN
2
+ // timer intermediate catch event): exactly one of `{ after }` (a delay) or
3
+ // `{ at }` (an instant). Contributed through the extension seam (epic #314).
4
+ import { assertTimerDate, assertTimerDuration } from "../xml.js";
5
+ import { registerNodeKind } from "./registry.js";
6
+ registerNodeKind("timer", {
7
+ build: (api) => (name, opts) => {
8
+ api.claim(name);
9
+ if (!opts || typeof opts !== "object") {
10
+ throw new Error(`timer("${name}") needs exactly one of { after } (a delay) or { at } (an instant)`);
11
+ }
12
+ const hasAfter = "after" in opts && typeof opts.after === "string";
13
+ const hasAt = "at" in opts && typeof opts.at === "string";
14
+ if (hasAfter === hasAt) {
15
+ throw new Error(`timer("${name}") needs exactly one of { after } (a delay) or { at } (an instant)`);
16
+ }
17
+ if ("after" in opts) {
18
+ const after = opts.after.trim();
19
+ assertTimerDuration(`timer("${name}") after`, after);
20
+ api.out.push({ kind: "timer", name, after });
21
+ }
22
+ else {
23
+ const at = opts.at.trim();
24
+ assertTimerDate(`timer("${name}") at`, at);
25
+ api.out.push({ kind: "timer", name, at });
26
+ }
27
+ return api.self();
28
+ },
29
+ emit: (node, incoming, _loop, api) => {
30
+ api.addTimerCatchEvent(node);
31
+ api.connect(incoming, node.name);
32
+ return [api.newEdge(node.name)];
33
+ },
34
+ });
@@ -0,0 +1,8 @@
1
+ import type { CanonicalModel } from "./normalize.js";
2
+ /** True when two canonical models are structurally equal (all three multisets
3
+ * match). */
4
+ export declare function modelsEqual(expected: CanonicalModel, actual: CanonicalModel): boolean;
5
+ /** Render a legible red/green structural diff, or `""` when the two models are
6
+ * structurally equal. `-`/red is the `expected` (golden) side, `+`/green the
7
+ * `actual` (derived) side. */
8
+ export declare function diffModels(expected: CanonicalModel, actual: CanonicalModel): string;
@@ -0,0 +1,70 @@
1
+ // A legible red/green structural diff between two canonical models. Each of the
2
+ // three sections (flow nodes, sequence flows, message subscriptions) is compared
3
+ // as a MULTISET: a line present more times on one side than the other is
4
+ // reported, `-` (red) for "expected / golden only" and `+` (green) for "derived
5
+ // only". Equal models produce an empty diff.
6
+ const useColor = () => {
7
+ if (process.env.NO_COLOR)
8
+ return false;
9
+ if (process.env.FORCE_COLOR)
10
+ return true;
11
+ return Boolean(process.stdout?.isTTY);
12
+ };
13
+ const RED = "\x1b[31m";
14
+ const GREEN = "\x1b[32m";
15
+ const DIM = "\x1b[2m";
16
+ const RESET = "\x1b[0m";
17
+ function paint(code, s) {
18
+ return useColor() ? `${code}${s}${RESET}` : s;
19
+ }
20
+ /** Multiset difference: for each distinct line, the count on `expected` minus the
21
+ * count on `actual`. Positive → missing from `actual` (removed); negative →
22
+ * extra in `actual` (added). */
23
+ function multisetDiff(expected, actual) {
24
+ const counts = new Map();
25
+ for (const line of expected)
26
+ counts.set(line, (counts.get(line) ?? 0) + 1);
27
+ for (const line of actual)
28
+ counts.set(line, (counts.get(line) ?? 0) - 1);
29
+ const removed = [];
30
+ const added = [];
31
+ for (const [line, n] of counts) {
32
+ for (let k = 0; k < n; k++)
33
+ removed.push(line);
34
+ for (let k = 0; k < -n; k++)
35
+ added.push(line);
36
+ }
37
+ return { removed: removed.sort(), added: added.sort() };
38
+ }
39
+ function section(title, expected, actual) {
40
+ const { removed, added } = multisetDiff(expected, actual);
41
+ if (removed.length === 0 && added.length === 0)
42
+ return [];
43
+ const out = [paint(DIM, ` ${title}:`)];
44
+ for (const line of removed)
45
+ out.push(paint(RED, ` - ${line}`));
46
+ for (const line of added)
47
+ out.push(paint(GREEN, ` + ${line}`));
48
+ return out;
49
+ }
50
+ /** True when two canonical models are structurally equal (all three multisets
51
+ * match). */
52
+ export function modelsEqual(expected, actual) {
53
+ return diffModels(expected, actual) === "";
54
+ }
55
+ /** Render a legible red/green structural diff, or `""` when the two models are
56
+ * structurally equal. `-`/red is the `expected` (golden) side, `+`/green the
57
+ * `actual` (derived) side. */
58
+ export function diffModels(expected, actual) {
59
+ const lines = [
60
+ ...section("flow nodes", expected.nodes, actual.nodes),
61
+ ...section("sequence flows", expected.flows, actual.flows),
62
+ ...section("message subscriptions", expected.messages, actual.messages),
63
+ ];
64
+ if (lines.length === 0)
65
+ return "";
66
+ return [
67
+ paint(DIM, "structural mismatch (-expected/golden, +actual/derived):"),
68
+ ...lines,
69
+ ].join("\n");
70
+ }
@@ -0,0 +1,8 @@
1
+ export { normalize } from "./normalize.js";
2
+ export type { CanonicalModel } from "./normalize.js";
3
+ export { assertDerivationParity, deploySmoke } from "./parity.js";
4
+ export type { DerivedInput, DeploySmokeOptions, DeploySmokeResult } from "./parity.js";
5
+ export { diffModels, modelsEqual } from "./diff.js";
6
+ export { parseXml, localName } from "./xml.js";
7
+ export type { XmlElement } from "./xml.js";
8
+ export { isFlowBuilder, assemblyFailureMessage } from "../declarative.js";
@@ -0,0 +1,49 @@
1
+ // @nanobpm/workflow/test-support — the DERIVATION-PARITY HARNESS (the oracle).
2
+ //
3
+ // This is the reusable test-support surface S1–S6 (epic #314) import to assert
4
+ // their derived flows against the hand-authored golden `.bpmn` models vendored in
5
+ // `packages/workflow/test/fixtures/nwf/`. It ships as the package subpath export
6
+ // `@nanobpm/workflow/test-support`:
7
+ //
8
+ // import {
9
+ // normalize,
10
+ // assertDerivationParity,
11
+ // deploySmoke,
12
+ // } from "@nanobpm/workflow/test-support";
13
+ //
14
+ // PUBLIC SURFACE
15
+ // ─────────────────────────────────────────────────────────────────────────────
16
+ //
17
+ // normalize(bpmnXml: string): CanonicalModel
18
+ // Strip DI (`bpmndi:BPMNDiagram` layout) and canonicalize element ids, child
19
+ // ordering, and sequence-flow ids so only SEMANTIC structure remains. Returns
20
+ // a `CanonicalModel` — three sorted multisets: `nodes` (flow nodes with their
21
+ // type + definition + edge-degree signature), `flows` (sequence, attach, and
22
+ // containment edges by endpoint), and `messages` (each subscribed message's
23
+ // full definition — name plus `zeebe:subscription correlationKey` and
24
+ // `zeebe:properties` envelope, so correlationKey/envelope differences count).
25
+ // Two models mean the same thing iff their `CanonicalModel`s are equal.
26
+ //
27
+ // assertDerivationParity(derived, goldenBpmnPath): void
28
+ // `derived` is a `DeclarativeFlow` (its BPMN is derived for you) or derived
29
+ // BPMN XML. Normalizes both it and the golden at `goldenBpmnPath` and asserts
30
+ // structural equality over flow nodes, sequence flows, message subscriptions,
31
+ // and timer/boundary definitions — throwing a legible red/green structural
32
+ // diff on mismatch.
33
+ //
34
+ // deploySmoke(derivedModel, opts?): Promise<DeploySmokeResult>
35
+ // Deploy the derived model to the wasm/live engine and assert acceptance.
36
+ // Supply `{ client }`, `{ baseUrl }`, or set `WORKFLOW_GATEWAY_URL`; with no
37
+ // engine reachable it resolves `{ skipped: true }` (never throws) so unit-only
38
+ // CI stays green, and throws only when a reachable engine REJECTS the model.
39
+ //
40
+ // LOWER-LEVEL HELPERS (for custom assertions):
41
+ // modelsEqual(a, b): boolean — structural equality predicate.
42
+ // diffModels(expected, actual): string — the red/green diff ("" when equal).
43
+ // parseXml / localName — the dependency-free XML reader.
44
+ export { normalize } from "./normalize.js";
45
+ export { assertDerivationParity, deploySmoke } from "./parity.js";
46
+ export { diffModels, modelsEqual } from "./diff.js";
47
+ export { parseXml, localName } from "./xml.js";
48
+ // The internal builder invariant guard, exposed for the fail-fast guard test.
49
+ export { isFlowBuilder, assemblyFailureMessage } from "../declarative.js";
@@ -0,0 +1,19 @@
1
+ /** The id-agnostic, order-agnostic semantic structure of a BPMN model. Two
2
+ * models are structurally equal iff their three multisets are equal. */
3
+ export interface CanonicalModel {
4
+ /** Semantic descriptor of every flow node (task/gateway/event/subProcess),
5
+ * sorted. Each carries its type, definition, and edge-degree signature. */
6
+ nodes: string[];
7
+ /** Every sequence flow as `«fromNode» =[tag]=> «toNode»`, plus structural
8
+ * attach (boundary→host) and containment (subProcess→child) edges, sorted. */
9
+ flows: string[];
10
+ /** The full semantic identity of every message a catch event subscribes to,
11
+ * sorted (deduped): the serialized `<bpmn:message>` definition — its name plus
12
+ * the `zeebe:subscription correlationKey` and any `zeebe:properties` envelope —
13
+ * so a differing correlation key or envelope is a structural difference. */
14
+ messages: string[];
15
+ }
16
+ /** Normalize a BPMN XML document to its canonical semantic model. Strips DI and
17
+ * canonicalizes ids, child ordering, and sequence-flow ids so only semantic
18
+ * structure remains. */
19
+ export declare function normalize(bpmnXml: string): CanonicalModel;