@bpmnkit/core 1.9.0 → 1.10.1

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 (110) hide show
  1. package/agent-cards/bpmn.md +3 -3
  2. package/builder-reference.md +11 -9
  3. package/dist/bpmn/auto-layout.js +82 -26
  4. package/dist/bpmn/bpmn-builder.d.ts +84 -7
  5. package/dist/bpmn/bpmn-builder.js +313 -78
  6. package/dist/bpmn/bpmn-model.d.ts +2 -0
  7. package/dist/bpmn/bpmn-parser.js +68 -76
  8. package/dist/bpmn/bpmn-serializer.js +60 -19
  9. package/dist/bpmn/bpmnlint.js +4 -69
  10. package/dist/bpmn/builder-rules.d.ts +20 -0
  11. package/dist/bpmn/builder-rules.js +120 -0
  12. package/dist/bpmn/camunda-compat-data.d.ts +10 -148
  13. package/dist/bpmn/camunda-compat-data.js +16 -407
  14. package/dist/bpmn/camunda-compat-feel.d.ts +3 -0
  15. package/dist/bpmn/camunda-compat-feel.js +1 -1
  16. package/dist/bpmn/camunda-compat.js +7 -6
  17. package/dist/bpmn/camunda7/export.js +4 -1
  18. package/dist/bpmn/camunda7/juel.js +2 -1
  19. package/dist/bpmn/camunda7/migrate.d.ts +23 -0
  20. package/dist/bpmn/camunda7/migrate.js +75 -3
  21. package/dist/bpmn/compact-stream.js +2 -1
  22. package/dist/bpmn/compact.d.ts +80 -4
  23. package/dist/bpmn/compact.js +220 -38
  24. package/dist/bpmn/feel-condition.d.ts +9 -0
  25. package/dist/bpmn/feel-condition.js +19 -0
  26. package/dist/bpmn/full-operations.js +31 -4
  27. package/dist/bpmn/index.d.ts +13 -3
  28. package/dist/bpmn/index.js +16 -15
  29. package/dist/bpmn/operations.d.ts +4 -4
  30. package/dist/bpmn/operations.js +14 -2
  31. package/dist/bpmn/optimize/bpmnlint-rules.js +7 -40
  32. package/dist/bpmn/optimize/index.js +15 -1
  33. package/dist/bpmn/optimize/tasks.js +12 -3
  34. package/dist/bpmn/process-delta.d.ts +18 -0
  35. package/dist/bpmn/process-delta.js +20 -2
  36. package/dist/bpmn/process-text-writer.js +27 -1
  37. package/dist/bpmn/process-text.d.ts +9 -3
  38. package/dist/bpmn/process-text.js +122 -16
  39. package/dist/bpmn/stable-ids.d.ts +2 -0
  40. package/dist/bpmn/stable-ids.js +8 -0
  41. package/dist/bpmn/zeebe-extensions.js +2 -1
  42. package/dist/bpmn/zeebe-placement.js +6 -129
  43. package/dist/bpmn/zeebe-validate/context.d.ts +132 -0
  44. package/dist/bpmn/zeebe-validate/context.js +241 -0
  45. package/dist/bpmn/zeebe-validate/gate.d.ts +87 -0
  46. package/dist/bpmn/zeebe-validate/gate.js +492 -0
  47. package/dist/bpmn/zeebe-validate/index.d.ts +37 -0
  48. package/dist/bpmn/zeebe-validate/index.js +106 -0
  49. package/dist/bpmn/zeebe-validate/rules/events.d.ts +4 -0
  50. package/dist/bpmn/zeebe-validate/rules/events.js +580 -0
  51. package/dist/bpmn/zeebe-validate/rules/extensions.d.ts +4 -0
  52. package/dist/bpmn/zeebe-validate/rules/extensions.js +411 -0
  53. package/dist/bpmn/zeebe-validate/rules/gateways.d.ts +3 -0
  54. package/dist/bpmn/zeebe-validate/rules/gateways.js +296 -0
  55. package/dist/bpmn/zeebe-validate/rules/references.d.ts +3 -0
  56. package/dist/bpmn/zeebe-validate/rules/references.js +495 -0
  57. package/dist/bpmn/zeebe-validate/rules/structure.d.ts +3 -0
  58. package/dist/bpmn/zeebe-validate/rules/structure.js +629 -0
  59. package/dist/bpmn/zeebe-validate/rules/tasks.d.ts +4 -0
  60. package/dist/bpmn/zeebe-validate/rules/tasks.js +446 -0
  61. package/dist/bpmn/zeebe-validate/xml.d.ts +15 -0
  62. package/dist/bpmn/zeebe-validate/xml.js +1062 -0
  63. package/dist/bpmn/zeebe-validate/xsd.d.ts +19 -0
  64. package/dist/bpmn/zeebe-validate/xsd.js +350 -0
  65. package/dist/connectors/aliases.js +1 -0
  66. package/dist/connectors/apply-element.d.ts +5 -2
  67. package/dist/connectors/apply-element.js +6 -0
  68. package/dist/connectors/apply-many.d.ts +9 -2
  69. package/dist/connectors/apply-many.js +17 -2
  70. package/dist/connectors/apply.d.ts +4 -2
  71. package/dist/connectors/deployability.d.ts +27 -0
  72. package/dist/connectors/deployability.js +41 -0
  73. package/dist/connectors/index.d.ts +1 -0
  74. package/dist/connectors/lines.d.ts +10 -0
  75. package/dist/connectors/lines.js +13 -4
  76. package/dist/connectors/templates/generated.js +10101 -3188
  77. package/dist/dmn/dmn-model.d.ts +24 -4
  78. package/dist/dmn/dmn-parser.js +37 -3
  79. package/dist/dmn/dmn-serializer.js +48 -47
  80. package/dist/dmn/lint.js +4 -11
  81. package/dist/errors.d.ts +30 -1
  82. package/dist/errors.js +31 -0
  83. package/dist/form/form-model.d.ts +11 -0
  84. package/dist/form/form-parser.d.ts +1 -0
  85. package/dist/form/form-parser.js +48 -12
  86. package/dist/form/form-serializer.js +40 -17
  87. package/dist/form/lint.js +6 -40
  88. package/dist/generated/bpmn-elements.d.ts +5 -0
  89. package/dist/generated/bpmn-elements.js +151 -0
  90. package/dist/generated/camunda-compat-data.d.ts +148 -0
  91. package/dist/generated/camunda-compat-data.js +371 -0
  92. package/dist/generated/dmn-elements.d.ts +12 -0
  93. package/dist/generated/dmn-elements.js +45 -0
  94. package/dist/generated/form-elements.d.ts +5 -0
  95. package/dist/generated/form-elements.js +45 -0
  96. package/dist/generated/lint-rules.d.ts +17 -0
  97. package/dist/generated/lint-rules.js +116 -0
  98. package/dist/generated/zeebe-elements.d.ts +10 -0
  99. package/dist/generated/zeebe-elements.js +168 -0
  100. package/dist/generated/zeebe-rules.d.ts +25 -0
  101. package/dist/generated/zeebe-rules.js +202 -0
  102. package/dist/index.d.ts +10 -4
  103. package/dist/index.js +4 -1
  104. package/dist/layout/annotations.js +21 -1
  105. package/dist/layout/orthogonal.js +9 -3
  106. package/dist/plan/compile.d.ts +26 -1
  107. package/dist/plan/compile.js +48 -6
  108. package/dist/plan/merge.d.ts +2 -1
  109. package/dist/plan/merge.js +13 -5
  110. package/package.json +2 -2
@@ -39,6 +39,7 @@ gw >(Label: default) y branch taken when no condition holds
39
39
  Kinds: start end task user service rule (DMN decision) send receive script manual call xor and or eventgw catch (wait for message or timer) throw boundary adhoc (an AI agent that chooses among tools)
40
40
  Events take a trigger: start:message end:error catch:timer boundary:error (timer message signal error escalation terminate conditional compensate cancel)
41
41
  Attributes after |: on=<task id> (required on boundary), nonint (non-interrupting), job=<job type>, each=<list variable> (once per item), after=<ISO duration> (timer), result=<variable>, feel=<FEEL expression> (last)
42
+ Names after |: msg=<message name> key=<FEEL> (key required where a message is waited for: catch, boundary, receive), signal=<name>, error=<code>, escalation=<code>, at=<ISO date-time> and every=<R/PT1H> (timers), called=<process id> (call)
42
43
  Also after |: form=<form id> (start, user), in.<name>=<FEEL> and out.<name>=<FEEL> map variables in and out of a step (value runs to the next word=; write comparisons with spaces: a = 1)
43
44
  Ad-hoc: agent[adhoc Name] is a container with flows like any node; tool[service Name | inside=agent] has no flows of its own; note <id>: text annotates a node
44
45
  doc <id>: text the element's documentation; for a tool inside an ad-hoc agent it is the description the agent chooses the tool by
@@ -210,10 +211,21 @@ function handles(element) {
210
211
  return false;
211
212
  return HANDLING.test(element.name ?? "") || HANDLING.test(element.id.replace(/[_.-]+/g, " "));
212
213
  }
214
+ /**
215
+ * The type a kind word names, or `undefined`. Own keys only: `KINDS["constructor"]`
216
+ * would find `Object.prototype`'s member and make a node whose type is a function.
217
+ */
218
+ export function kindOf(word) {
219
+ if (Object.hasOwn(KINDS, word))
220
+ return KINDS[word];
221
+ if (Object.hasOwn(ALIASES, word))
222
+ return ALIASES[word];
223
+ return undefined;
224
+ }
213
225
  /** The type a bare id suggests, for a node written without a kind or never declared. */
214
226
  function typeFromId(id) {
215
227
  // `pick > and`, `and > dispatch`: the kind written as if it were an id.
216
- const kind = KINDS[id.toLowerCase()] ?? ALIASES[id.toLowerCase()];
228
+ const kind = kindOf(id.toLowerCase());
217
229
  if (kind !== undefined && GATEWAYS.has(kind))
218
230
  return kind;
219
231
  if (/^start/i.test(id))
@@ -273,7 +285,7 @@ export function tokenizePath(text) {
273
285
  let spec;
274
286
  // `… > xor Notify sales? >(Yes: …)`: a kind and a name without brackets, after an
275
287
  // arrow. At the start of a line it is more likely prose ("end of the answer").
276
- const bare = refs.length > 0 && KINDS[id] !== undefined
288
+ const bare = refs.length > 0 && Object.hasOwn(KINDS, id)
277
289
  ? /^ +([^[\]()>|]+?)(?=\s*(?:-{0,2}>|$))/.exec(text.slice(i))
278
290
  : null;
279
291
  if (bare?.[1]) {
@@ -572,7 +584,7 @@ class Reader {
572
584
  // `and[kind and]` or `ord[id=ord kind=start]` annotate the node already
573
585
  // there, and `validate[xor …] > …` restarts from it.
574
586
  const word = spec.split(/[\s|]/, 1)[0]?.toLowerCase().split(":")[0] ?? "";
575
- const kind = KINDS[word] ?? ALIASES[word];
587
+ const kind = kindOf(word);
576
588
  // A boundary is always new: it cannot be a revision of the task it sits on.
577
589
  // `send[…] > send[post Slack message to #support]`: a name of several words
578
590
  // after an arrow is a second node, whatever its kind word
@@ -604,7 +616,7 @@ class Reader {
604
616
  }
605
617
  const bar = spec.indexOf("|");
606
618
  // `boundary:timer on=poll`: an attribute written before the bar is one still
607
- const loose = /\s+((?:on|job|each|after|result)=\S+|nonint)(?=\s|$)/g;
619
+ const loose = /\s+((?:on|job|each|after|at|every|result|msg|key|signal|error|escalation|called)=\S+|nonint)(?=\s|$)/g;
608
620
  const beforeBar = bar < 0 ? spec : spec.slice(0, bar);
609
621
  const head = beforeBar.replace(loose, "").trim();
610
622
  const attrs = [...beforeBar.matchAll(loose)].map((m) => m[1]).join(" ") +
@@ -613,7 +625,7 @@ class Reader {
613
625
  const kindWord = space < 0 ? head : head.slice(0, space);
614
626
  const name = space < 0 ? undefined : head.slice(space + 1).trim() || undefined;
615
627
  const [kind = "", trigger] = kindWord.toLowerCase().split(":");
616
- let type = KINDS[kind] ?? ALIASES[kind];
628
+ let type = kindOf(kind);
617
629
  let label = name;
618
630
  if (type === undefined) {
619
631
  // Most often the kind was left out (`start[Order placed]`): the whole
@@ -656,6 +668,14 @@ class Reader {
656
668
  element.eventType = trigger;
657
669
  }
658
670
  }
671
+ // `paid[catch Paid | msg=payment-received]`: an attribute naming what the event
672
+ // waits for or throws is its trigger, when the kind word did not say one
673
+ if (EVENTS.has(element.type) && element.eventType === undefined) {
674
+ const named = /(?:^|[\s,|])(msg|signal|error|escalation|at|every)=\S/.exec(attrs)?.[1];
675
+ const trigger = named === undefined ? undefined : NAMED_TRIGGERS.get(named);
676
+ if (trigger !== undefined && !(trigger === "timer" && element.type === "endEvent"))
677
+ element.eventType = trigger;
678
+ }
659
679
  if (label)
660
680
  element.name = label;
661
681
  // A catch or boundary event waits for something, and cannot deploy without
@@ -704,8 +724,45 @@ class Reader {
704
724
  node.on = hostOf.get(value) ?? value;
705
725
  else if (key === "inside" && value)
706
726
  node.inside = hostOf.get(value) ?? value;
727
+ // `c[call Run child | job=child]`: what a call activity runs is a process, not a job
728
+ else if (key === "job" && value && element.type === "callActivity")
729
+ element.calledProcess = value;
707
730
  else if (key === "job" && value)
708
731
  element.jobType = value;
732
+ else if (key === "called" && value && element.type === "callActivity")
733
+ element.calledProcess = value;
734
+ else if (key === "key" &&
735
+ value &&
736
+ (EVENTS.has(element.type) || element.type === "receiveTask"))
737
+ element.correlationKey = value.startsWith("=") ? value : `=${value}`;
738
+ else if (key === "msg" && value && element.type === "receiveTask")
739
+ element.messageName = value;
740
+ else if (key !== undefined && value && NAMED_TRIGGERS.has(key) && EVENTS.has(element.type)) {
741
+ const trigger = NAMED_TRIGGERS.get(key);
742
+ if (element.eventType !== trigger) {
743
+ this.problems.push({
744
+ line: n,
745
+ message: `${key}= takes a ${trigger} event; ignored on "${id}"`,
746
+ });
747
+ }
748
+ else if (key === "msg")
749
+ element.messageName = value;
750
+ else if (key === "signal")
751
+ element.signalName = value;
752
+ else if (key === "error")
753
+ element.errorCode = value;
754
+ else if (key === "escalation")
755
+ element.escalationCode = value;
756
+ else if (key === "at")
757
+ element.timerDate = value;
758
+ else if (cycle(value) !== undefined)
759
+ element.timerCycle = cycle(value);
760
+ else
761
+ this.problems.push({
762
+ line: n,
763
+ message: `every=${value} on "${id}" is not a repeating interval (R/PT1H); ignored`,
764
+ });
765
+ }
709
766
  else if (key === "nonint" && value === undefined)
710
767
  element.interrupting = false;
711
768
  else if (key === "form" &&
@@ -760,7 +817,17 @@ class Reader {
760
817
  // `calc[task Count open issues | feel=…]`: a step that evaluates FEEL is a script task
761
818
  if (element.type === "task")
762
819
  element.type = "scriptTask";
763
- if (element.type === "scriptTask") {
820
+ if (EVENTS.has(element.type) && element.eventType === "conditional") {
821
+ // `ready[catch:conditional | feel=stock > 0]`: the condition it waits for
822
+ element.condition = feel;
823
+ if (parseExpression(feel.slice(1)).errors.length > 0) {
824
+ this.problems.push({
825
+ line: n,
826
+ message: `feel= on "${id}" is not FEEL; kept for the reader to correct`,
827
+ });
828
+ }
829
+ }
830
+ else if (element.type === "scriptTask") {
764
831
  element.script = feel;
765
832
  element.resultVariable ??= id;
766
833
  if (parseExpression(feel.slice(1)).errors.length > 0) {
@@ -851,6 +918,25 @@ const UNITS = { s: "S", m: "M", h: "H", d: "D", w: "W" };
851
918
  * An ISO 8601 duration from what models write: `PT5M` as it is, `5m`, `5 min`,
852
919
  * `5 minutes`, `2 hours` or `1 day`, also inside a name ("Wait 5 minutes").
853
920
  */
921
+ /** The trigger an attribute names (`msg=` a message): {@link parseProcessText} reads it as the event's. */
922
+ const NAMED_TRIGGERS = new Map([
923
+ ["msg", "message"],
924
+ ["signal", "signal"],
925
+ ["error", "error"],
926
+ ["escalation", "escalation"],
927
+ ["at", "timer"],
928
+ ["every", "timer"],
929
+ ]);
930
+ /**
931
+ * A timer cycle from `every=`: an ISO 8601 repeating interval (`R/PT1H`, `R3/PT10M`)
932
+ * as written, or a duration (`PT1H`, `1h`, `2 days`) repeated forever.
933
+ */
934
+ export function cycle(text) {
935
+ if (/^R\d*\/P\S+$/i.test(text))
936
+ return text.toUpperCase();
937
+ const each = duration(text);
938
+ return each === undefined ? undefined : `R/${each}`;
939
+ }
854
940
  export function duration(text) {
855
941
  // `p1d` is P1D: models write ISO durations in lower case too
856
942
  const iso = /\bP(?:\d+[YMWD])*(?:T(?:\d+[HMS])+)?\b/i.exec(text)?.[0]?.toUpperCase();
@@ -920,6 +1006,8 @@ function assemble(reader, final) {
920
1006
  for (const [id, node] of reader.nodes) {
921
1007
  nodes.set(id, { ...node, element: { ...node.element } });
922
1008
  }
1009
+ // Copies: a stream assembles every frame from the same reader, which must stay as read
1010
+ const edgesRead = reader.edges.map((edge) => ({ ...edge }));
923
1011
  const taken = new Set(nodes.keys());
924
1012
  const typeOf = (id) => nodes.get(id)?.element.type;
925
1013
  const nameOf = (id) => nodes.get(id)?.element.name ?? nameFromId(id);
@@ -932,7 +1020,7 @@ function assemble(reader, final) {
932
1020
  // from its id instead — while streaming it may yet be declared. An id only an
933
1021
  // `on=` names is not added: nothing would lead to it.
934
1022
  if (final) {
935
- for (const edge of reader.edges) {
1023
+ for (const edge of edgesRead) {
936
1024
  for (const id of [edge.from, edge.to]) {
937
1025
  if (nodes.has(id))
938
1026
  continue;
@@ -986,7 +1074,7 @@ function assemble(reader, final) {
986
1074
  : undefined;
987
1075
  if (why !== undefined) {
988
1076
  // A node nothing leads to is dropped later as unconnected; say so rather than "stays"
989
- const drawn = reader.edges.some((edge) => edge.from === id || edge.to === id);
1077
+ const drawn = edgesRead.some((edge) => edge.from === id || edge.to === id);
990
1078
  problems.push({
991
1079
  line: node.line,
992
1080
  message: `inside=${parentId} on "${id}": ${why}; "${id}" ${drawn ? "stays at the top level" : "has no flows, so it is left out"}`,
@@ -1001,7 +1089,7 @@ function assemble(reader, final) {
1001
1089
  // Flows would make the task run in the main path, which an ad-hoc tool does not
1002
1090
  const flowing = [];
1003
1091
  const outside = [];
1004
- for (const edge of reader.edges) {
1092
+ for (const edge of edgesRead) {
1005
1093
  if (insideIds.has(edge.from) || insideIds.has(edge.to))
1006
1094
  flowing.push(edge);
1007
1095
  else
@@ -1022,11 +1110,11 @@ function assemble(reader, final) {
1022
1110
  if (node.element.type !== "boundaryEvent")
1023
1111
  continue;
1024
1112
  // `send > wait[boundary:timer …]` without on=: the one task drawn into it is its host
1025
- const drawn = node.on === undefined ? reader.edges.filter((edge) => edge.to === id) : [];
1113
+ const drawn = node.on === undefined ? edgesRead.filter((edge) => edge.to === id) : [];
1026
1114
  const from = drawn.length === 1 ? nodes.get(drawn[0]?.from ?? "") : undefined;
1027
1115
  if (from && drawn[0] && !EVENTS.has(from.element.type) && !GATEWAYS.has(from.element.type)) {
1028
1116
  node.on = from.element.id;
1029
- reader.edges.splice(reader.edges.indexOf(drawn[0]), 1);
1117
+ edgesRead.splice(edgesRead.indexOf(drawn[0]), 1);
1030
1118
  fixes.push(`put boundary "${id}" on "${from.element.id}", the task drawn into it`);
1031
1119
  }
1032
1120
  const host = node.on === undefined ? undefined : nodes.get(node.on);
@@ -1059,7 +1147,7 @@ function assemble(reader, final) {
1059
1147
  // `poll > late[… | on=poll]`: the arrow from its own task only says where it sits
1060
1148
  if (target.on === edge.from)
1061
1149
  return [];
1062
- const next = reader.edges.filter((out) => out.from === edge.to);
1150
+ const next = edgesRead.filter((out) => out.from === edge.to);
1063
1151
  if (next.length === 0)
1064
1152
  return [edge];
1065
1153
  if (final) {
@@ -1711,9 +1799,26 @@ function assemble(reader, final) {
1711
1799
  }
1712
1800
  }
1713
1801
  for (const node of [...nodes.values(), ...childNodes]) {
1714
- if (JOB_TASKS.has(node.element.type) && node.element.jobType === undefined) {
1715
- node.element.jobType = node.element.id;
1716
- }
1802
+ const el = node.element;
1803
+ if (JOB_TASKS.has(el.type) && el.jobType === undefined) {
1804
+ el.jobType = el.id;
1805
+ }
1806
+ // What an element sends, throws, waits for or calls needs a name to deploy; the id
1807
+ // stands in, as it does for a job type. A correlation key has no such stand-in.
1808
+ const throws = el.type === "intermediateThrowEvent" || el.type === "endEvent";
1809
+ if (el.type === "callActivity")
1810
+ el.calledProcess ??= el.id;
1811
+ if (el.eventType === "message" || el.type === "receiveTask")
1812
+ el.messageName ??= el.id;
1813
+ if (el.eventType === "message" && throws)
1814
+ el.jobType ??= el.id;
1815
+ if (el.eventType === "signal")
1816
+ el.signalName ??= el.id;
1817
+ // A caught error or escalation without a code catches every one
1818
+ if (el.eventType === "error" && throws)
1819
+ el.errorCode ??= el.id;
1820
+ if (el.eventType === "escalation" && throws)
1821
+ el.escalationCode ??= el.id;
1717
1822
  // A DMN task needs a decision to deploy; the id stands in, as it does for a job type.
1718
1823
  if (node.element.type === "businessRuleTask" &&
1719
1824
  node.element.jobType === undefined &&
@@ -1895,7 +2000,8 @@ export function createProcessTextStream() {
1895
2000
  }
1896
2001
  if (!changed || reader.nodes.size === 0)
1897
2002
  return null;
1898
- return expand(assemble(reader, false).diagram);
2003
+ // A frame is a preview of text still arriving, never deployed: no gate.
2004
+ return expand(assemble(reader, false).diagram, { validate: false });
1899
2005
  },
1900
2006
  end() {
1901
2007
  if (pending !== "")
@@ -3,6 +3,8 @@ import type { BpmnFlowElement, BpmnSequenceFlow } from "./bpmn-model.js";
3
3
  export declare function setFlowDiscriminatorSource(flow: BpmnSequenceFlow, branchId: string): void;
4
4
  /** Marks `flow.id` as caller-chosen: `assignStableFlowIds` keeps it and reserves it. */
5
5
  export declare function markExplicitFlowId(flow: BpmnSequenceFlow): void;
6
+ /** Gives `to`, a copy of `flow`, the builder-side facts recorded for `flow`. */
7
+ export declare function copyFlowTags(flow: BpmnSequenceFlow, to: BpmnSequenceFlow): void;
6
8
  /**
7
9
  * Throws when a caller-chosen flow id is also the id of another element or
8
10
  * flow anywhere in the process, nested sub-processes included.
@@ -58,6 +58,14 @@ export function setFlowDiscriminatorSource(flow, branchId) {
58
58
  export function markExplicitFlowId(flow) {
59
59
  explicitIds.add(flow);
60
60
  }
61
+ /** Gives `to`, a copy of `flow`, the builder-side facts recorded for `flow`. */
62
+ export function copyFlowTags(flow, to) {
63
+ const branchId = branchIds.get(flow);
64
+ if (branchId !== undefined)
65
+ branchIds.set(to, branchId);
66
+ if (explicitIds.has(flow))
67
+ explicitIds.add(to);
68
+ }
61
69
  function isIdScope(element) {
62
70
  return "flowElements" in element && "sequenceFlows" in element;
63
71
  }
@@ -1,3 +1,4 @@
1
+ import { toFeelCondition } from "./feel-condition.js";
1
2
  import { ZEEBE_PLACEMENT } from "./zeebe-placement.js";
2
3
  function listenersToXml(container, child, listeners) {
3
4
  return {
@@ -293,7 +294,7 @@ export function ensureZeebeExtension(owner, extension) {
293
294
  export function makeConditionalDefinition(condition, variableEvents) {
294
295
  return {
295
296
  type: "conditional",
296
- condition,
297
+ condition: toFeelCondition(condition),
297
298
  conditionAttributes: { "xsi:type": "bpmn:tFormalExpression" },
298
299
  ...(variableEvents && variableEvents.length > 0
299
300
  ? {
@@ -1,7 +1,8 @@
1
- // Generated by scripts/generate-zeebe-placement.ts — do not edit.
2
- // Source: descriptors/zeebe.json (zeebe-bpmn-moddle, MIT) resolved against
3
- // descriptors/bpmn.json (bpmn-moddle, MIT). Regenerate with:
4
- // pnpm --filter @bpmnkit/core generate:placement
1
+ import { ZEEBE_ALLOWED_IN } from "../generated/zeebe-elements.js";
2
+ // The data lives in spec/elements/zeebe.json (`allowedIn`), which
3
+ // scripts/generate-zeebe-placement.ts fills from the vendored descriptors
4
+ // (zeebe-bpmn-moddle, MIT, resolved against bpmn-moddle, MIT). Regenerate with:
5
+ // pnpm --filter @bpmnkit/core generate:placement && pnpm spec:gen
5
6
  /**
6
7
  * Where each Zeebe extension element may be placed, keyed by element name.
7
8
  *
@@ -12,129 +13,5 @@
12
13
  * An extension absent from this table is one the descriptor says nothing about;
13
14
  * see `isZeebePlacementAllowed` for what that means.
14
15
  */
15
- export const ZEEBE_PLACEMENT = {
16
- "zeebe:adHoc": ["bpmn:adHocSubProcess"],
17
- "zeebe:agentDefinition": ["bpmn:adHocSubProcess", "bpmn:serviceTask"],
18
- "zeebe:assignmentDefinition": ["bpmn:userTask"],
19
- "zeebe:calledDecision": ["bpmn:businessRuleTask"],
20
- "zeebe:calledElement": ["bpmn:callActivity"],
21
- "zeebe:conditionalFilter": ["bpmn:conditionalEventDefinition"],
22
- "zeebe:executionListener": ["zeebe:executionListeners"],
23
- "zeebe:executionListeners": [
24
- "bpmn:adHocSubProcess",
25
- "bpmn:boundaryEvent",
26
- "bpmn:businessRuleTask",
27
- "bpmn:callActivity",
28
- "bpmn:endEvent",
29
- "bpmn:eventBasedGateway",
30
- "bpmn:exclusiveGateway",
31
- "bpmn:implicitThrowEvent",
32
- "bpmn:inclusiveGateway",
33
- "bpmn:intermediateCatchEvent",
34
- "bpmn:intermediateThrowEvent",
35
- "bpmn:manualTask",
36
- "bpmn:parallelGateway",
37
- "bpmn:process",
38
- "bpmn:receiveTask",
39
- "bpmn:scriptTask",
40
- "bpmn:sendTask",
41
- "bpmn:serviceTask",
42
- "bpmn:startEvent",
43
- "bpmn:subProcess",
44
- "bpmn:task",
45
- "bpmn:transaction",
46
- "bpmn:userTask",
47
- ],
48
- "zeebe:formDefinition": ["bpmn:startEvent", "bpmn:userTask"],
49
- "zeebe:input": [
50
- "bpmn:adHocSubProcess",
51
- "bpmn:businessRuleTask",
52
- "bpmn:callActivity",
53
- "bpmn:endEvent",
54
- "bpmn:intermediateThrowEvent",
55
- "bpmn:scriptTask",
56
- "bpmn:sendTask",
57
- "bpmn:serviceTask",
58
- "bpmn:subProcess",
59
- "bpmn:transaction",
60
- "bpmn:userTask",
61
- ],
62
- "zeebe:ioMapping": [
63
- "bpmn:adHocSubProcess",
64
- "bpmn:boundaryEvent",
65
- "bpmn:businessRuleTask",
66
- "bpmn:callActivity",
67
- "bpmn:endEvent",
68
- "bpmn:implicitThrowEvent",
69
- "bpmn:intermediateCatchEvent",
70
- "bpmn:intermediateThrowEvent",
71
- "bpmn:receiveTask",
72
- "bpmn:scriptTask",
73
- "bpmn:sendTask",
74
- "bpmn:serviceTask",
75
- "bpmn:startEvent",
76
- "bpmn:subProcess",
77
- "bpmn:transaction",
78
- "bpmn:userTask",
79
- ],
80
- "zeebe:jobPriorityDefinition": [
81
- "bpmn:adHocSubProcess",
82
- "bpmn:businessRuleTask",
83
- "bpmn:endEvent",
84
- "bpmn:intermediateThrowEvent",
85
- "bpmn:process",
86
- "bpmn:scriptTask",
87
- "bpmn:sendTask",
88
- "bpmn:serviceTask",
89
- ],
90
- "zeebe:linkedResource": ["bpmn:serviceTask"],
91
- "zeebe:linkedResources": ["bpmn:serviceTask"],
92
- "zeebe:loopCharacteristics": ["bpmn:multiInstanceLoopCharacteristics"],
93
- "zeebe:output": [
94
- "bpmn:adHocSubProcess",
95
- "bpmn:boundaryEvent",
96
- "bpmn:businessRuleTask",
97
- "bpmn:callActivity",
98
- "bpmn:endEvent",
99
- "bpmn:implicitThrowEvent",
100
- "bpmn:intermediateCatchEvent",
101
- "bpmn:intermediateThrowEvent",
102
- "bpmn:receiveTask",
103
- "bpmn:scriptTask",
104
- "bpmn:sendTask",
105
- "bpmn:serviceTask",
106
- "bpmn:startEvent",
107
- "bpmn:subProcess",
108
- "bpmn:transaction",
109
- "bpmn:userTask",
110
- ],
111
- "zeebe:priorityDefinition": ["bpmn:userTask"],
112
- "zeebe:script": ["bpmn:scriptTask"],
113
- "zeebe:taskDefinition": [
114
- "bpmn:adHocSubProcess",
115
- "bpmn:businessRuleTask",
116
- "bpmn:endEvent",
117
- "bpmn:intermediateThrowEvent",
118
- "bpmn:scriptTask",
119
- "bpmn:sendTask",
120
- "bpmn:serviceTask",
121
- ],
122
- "zeebe:taskHeaders": [
123
- "bpmn:adHocSubProcess",
124
- "bpmn:businessRuleTask",
125
- "bpmn:endEvent",
126
- "bpmn:intermediateThrowEvent",
127
- "bpmn:scriptTask",
128
- "bpmn:sendTask",
129
- "bpmn:serviceTask",
130
- "bpmn:userTask",
131
- "zeebe:executionListener",
132
- ],
133
- "zeebe:taskListener": ["zeebe:taskListeners"],
134
- "zeebe:taskListeners": ["bpmn:userTask"],
135
- "zeebe:taskSchedule": ["bpmn:userTask"],
136
- "zeebe:userTask": ["bpmn:userTask"],
137
- "zeebe:userTaskForm": ["bpmn:process"],
138
- "zeebe:versionTag": ["bpmn:process"],
139
- };
16
+ export const ZEEBE_PLACEMENT = ZEEBE_ALLOWED_IN;
140
17
  //# sourceMappingURL=zeebe-placement.js.map
@@ -0,0 +1,132 @@
1
+ import { type ZeebeRuleName } from "../../generated/zeebe-rules.js";
2
+ import type { XmlElement } from "../../types/xml-element.js";
3
+ import type { BpmnDefinitions, BpmnError, BpmnEscalation, BpmnFlowElement, BpmnMessage, BpmnSequenceFlow, BpmnSignal } from "../bpmn-model.js";
4
+ import type { OptimizationFinding } from "../optimize/types.js";
5
+ export declare const ZEEBE_NS = "http://camunda.org/schema/zeebe/1.0";
6
+ /**
7
+ * The other resources of the same deployment, for the rules that look past one
8
+ * file (`bindingType="deployment"` targets, duplicate process ids). Each answers
9
+ * for resources other than the BPMN being validated.
10
+ */
11
+ export interface ZeebeResolver {
12
+ hasProcess?(id: string): boolean;
13
+ hasDecision?(id: string): boolean;
14
+ hasForm?(id: string): boolean;
15
+ hasResource?(id: string): boolean;
16
+ }
17
+ /** Zeebe's configured length limits (`EngineConfiguration`, 32768 by default). */
18
+ export interface ZeebeLimits {
19
+ maxIdLength: number;
20
+ maxNameLength: number;
21
+ maxWorkerTypeLength: number;
22
+ }
23
+ export declare const DEFAULT_ZEEBE_LIMITS: ZeebeLimits;
24
+ export interface ValidateDeployableOptions {
25
+ /** The Camunda 8 version to validate for, e.g. `"8.6"`. Defaults to the newest supported. */
26
+ camundaVersion?: string;
27
+ /** Other resources of the deployment; without it the context rules are skipped. */
28
+ resolver?: ZeebeResolver;
29
+ limits?: Partial<ZeebeLimits>;
30
+ }
31
+ /** What a scope is: the process itself or a container whose children Zeebe validates as a scope. */
32
+ export type ScopeKind = "process" | "subProcess" | "eventSubProcess" | "adHocSubProcess" | "transaction";
33
+ export interface Scope {
34
+ kind: ScopeKind;
35
+ /** The process id, or the container's id. */
36
+ id: string;
37
+ processId: string;
38
+ /** The container element; absent for a process. */
39
+ container?: BpmnFlowElement;
40
+ parent?: Scope;
41
+ flowElements: BpmnFlowElement[];
42
+ sequenceFlows: BpmnSequenceFlow[];
43
+ }
44
+ export interface NodeEntry {
45
+ node: BpmnFlowElement;
46
+ scope: Scope;
47
+ }
48
+ export interface FlowEntry {
49
+ flow: BpmnSequenceFlow;
50
+ scope: Scope;
51
+ }
52
+ /** One check: reads the context and reports through `ctx.report`. */
53
+ export type ZeebeCheck = (ctx: ZeebeContext) => void;
54
+ /**
55
+ * Everything a check needs, built once per validation: the scopes (recursive),
56
+ * every flow node and sequence flow with its scope, the root elements by id,
57
+ * and the document order findings are sorted by.
58
+ */
59
+ export declare class ZeebeContext {
60
+ readonly defs: BpmnDefinitions;
61
+ /** The `major.minor` being validated for. */
62
+ readonly version: string;
63
+ readonly limits: ZeebeLimits;
64
+ readonly resolver: ZeebeResolver | undefined;
65
+ readonly scopes: Scope[];
66
+ readonly nodes: NodeEntry[];
67
+ readonly flows: FlowEntry[];
68
+ private readonly nodeIndex;
69
+ private readonly flowIndex;
70
+ private readonly order;
71
+ private readonly findings;
72
+ constructor(defs: BpmnDefinitions, options?: ValidateDeployableOptions);
73
+ private mark;
74
+ private walk;
75
+ /** Whether the rule applies to the version being validated. */
76
+ applies(rule: ZeebeRuleName): boolean;
77
+ node(id: string | undefined): NodeEntry | undefined;
78
+ flow(id: string | undefined): FlowEntry | undefined;
79
+ /** Sequence flows whose `targetRef` is the node, as Zeebe's model computes them. */
80
+ incoming(nodeId: string): FlowEntry[];
81
+ /** Sequence flows whose `sourceRef` is the node. */
82
+ outgoing(nodeId: string): FlowEntry[];
83
+ /** Boundary events attached to the activity. */
84
+ boundaries(activityId: string): NodeEntry[];
85
+ message(id: string | undefined): BpmnMessage | undefined;
86
+ error(id: string | undefined): BpmnError | undefined;
87
+ signal(id: string | undefined): BpmnSignal | undefined;
88
+ escalation(id: string | undefined): BpmnEscalation | undefined;
89
+ /** Whether an element name such as `zeebe:taskDefinition` is in the Zeebe namespace. */
90
+ isZeebe(name: string, local: string): boolean;
91
+ /** The `zeebe:<local>` children of an element's `extensionElements`. */
92
+ zeebe(el: {
93
+ extensionElements?: XmlElement[];
94
+ } | undefined, local: string): XmlElement[];
95
+ /** The `zeebe:<local>` children of an XML element. */
96
+ zeebeChildren(el: XmlElement | undefined, local: string): XmlElement[];
97
+ /**
98
+ * Reports a rule violation. Dropped when the rule does not apply to the
99
+ * version, so a check never tests the version itself.
100
+ */
101
+ report(rule: ZeebeRuleName, elementId: string, message: string, suggestion: string, processId?: string): void;
102
+ /** The process an element belongs to; root elements answer the first process. */
103
+ processOf(elementId: string): string;
104
+ /** The findings, deduplicated and sorted by rule, then document order, then message. */
105
+ finish(): OptimizationFinding[];
106
+ }
107
+ /**
108
+ * A reference with its QName prefix removed: Zeebe resolves `messageRef="bpmn:m"`
109
+ * to `m`. Ids are NCNames, so they never contain a colon themselves.
110
+ */
111
+ export declare function localRef(ref: string): string;
112
+ /**
113
+ * Whether a Zeebe expression attribute is an expression rather than a static value:
114
+ * Zeebe's `FeelExpressionLanguage` matches the whole text against `=(.+)`, so a
115
+ * leading space or a lone `=` makes it static.
116
+ */
117
+ export declare function isExpression(text: string): boolean;
118
+ /**
119
+ * The FEEL parse error of an expression attribute, or `undefined` when it parses
120
+ * or is a static value. Only the part after `=` is FEEL.
121
+ */
122
+ export declare function feelError(text: string): string | undefined;
123
+ /**
124
+ * Zeebe's message for a FEEL parse failure, up to the parser's own detail, which
125
+ * differs between feel-scala and @bpmnkit/feel.
126
+ */
127
+ export declare function feelFailure(text: string): string;
128
+ /** Zeebe's message for a static value where an expression is required. */
129
+ export declare function staticValueMessage(text: string): string;
130
+ /** An attribute value, or `undefined` when absent or blank (Zeebe's "present and not empty"). */
131
+ export declare function nonEmpty(value: string | undefined): string | undefined;
132
+ //# sourceMappingURL=context.d.ts.map