@bpmnkit/core 1.15.0 → 1.17.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 (60) hide show
  1. package/builder-reference.md +2 -1
  2. package/dist/bpmn/auto-layout.d.ts +0 -8
  3. package/dist/bpmn/auto-layout.js +605 -98
  4. package/dist/bpmn/bpmn-builder.d.ts +120 -14
  5. package/dist/bpmn/bpmn-builder.js +411 -152
  6. package/dist/bpmn/bpmn-model.d.ts +15 -0
  7. package/dist/bpmn/bpmn-parser.js +32 -6
  8. package/dist/bpmn/bpmn-serializer.js +9 -2
  9. package/dist/bpmn/compact-stream.d.ts +7 -0
  10. package/dist/bpmn/compact-stream.js +7 -0
  11. package/dist/bpmn/compact.d.ts +124 -9
  12. package/dist/bpmn/compact.js +295 -27
  13. package/dist/bpmn/full-operations.d.ts +19 -0
  14. package/dist/bpmn/full-operations.js +191 -7
  15. package/dist/bpmn/make-room.js +114 -0
  16. package/dist/bpmn/place-new-shapes.js +4 -2
  17. package/dist/bpmn/preserving-writer.d.ts +1 -1
  18. package/dist/bpmn/preserving-writer.js +1 -1
  19. package/dist/bpmn/process-delta.d.ts +32 -1
  20. package/dist/bpmn/process-delta.js +62 -1
  21. package/dist/bpmn/process-text-writer.d.ts +18 -7
  22. package/dist/bpmn/process-text-writer.js +105 -22
  23. package/dist/bpmn/process-text.d.ts +27 -1
  24. package/dist/bpmn/process-text.js +350 -2
  25. package/dist/bpmn/swimlanes.d.ts +178 -0
  26. package/dist/bpmn/swimlanes.js +774 -0
  27. package/dist/index.d.ts +5 -4
  28. package/dist/index.js +3 -2
  29. package/dist/layout/collaboration/crossings.d.ts +13 -0
  30. package/dist/layout/collaboration/crossings.js +37 -0
  31. package/dist/layout/collaboration/docked-labels.d.ts +21 -0
  32. package/dist/layout/collaboration/docked-labels.js +65 -0
  33. package/dist/layout/collaboration/message-tracks.d.ts +20 -0
  34. package/dist/layout/collaboration/message-tracks.js +78 -0
  35. package/dist/layout/collaboration/stack-crossings.d.ts +38 -0
  36. package/dist/layout/collaboration/stack-crossings.js +155 -0
  37. package/dist/layout/grid/edge-labels.js +21 -10
  38. package/dist/layout/layered/coords.d.ts +13 -0
  39. package/dist/layout/layered/coords.js +211 -0
  40. package/dist/layout/layered/index.d.ts +21 -0
  41. package/dist/layout/layered/index.js +288 -0
  42. package/dist/layout/layered/layers.d.ts +60 -0
  43. package/dist/layout/layered/layers.js +374 -0
  44. package/dist/layout/layered/route.d.ts +66 -0
  45. package/dist/layout/layered/route.js +369 -0
  46. package/dist/layout/layout-engine.d.ts +6 -2
  47. package/dist/layout/layout-engine.js +4 -2
  48. package/dist/layout/semantic/bands.js +8 -2
  49. package/dist/layout/semantic/graph.d.ts +33 -1
  50. package/dist/layout/semantic/graph.js +200 -4
  51. package/dist/layout/semantic/index.d.ts +8 -2
  52. package/dist/layout/semantic/index.js +114 -14
  53. package/dist/layout/semantic/lanes.d.ts +40 -0
  54. package/dist/layout/semantic/lanes.js +198 -0
  55. package/dist/layout/semantic/place.d.ts +46 -2
  56. package/dist/layout/semantic/place.js +248 -30
  57. package/dist/layout/semantic/route.js +35 -2
  58. package/dist/layout/types.d.ts +0 -8
  59. package/dist/xml/xml-patch.d.ts +1 -1
  60. package/package.json +2 -2
@@ -2,11 +2,6 @@ import type { GridHint, LayoutHints } from "../layout/types.js";
2
2
  import type { BpmnAssociation, BpmnDefinitions, BpmnError, BpmnEscalation, BpmnFlowElement, BpmnLaneSet, BpmnMessage, BpmnSequenceFlow, BpmnSignal, BpmnTextAnnotation } from "./bpmn-model.js";
3
3
  import type { RestConnectorConfig } from "./rest-connector.js";
4
4
  import { type ZeebeLinkedResource, type ZeebeListener } from "./zeebe-extensions.js";
5
- /** Options for {@link ProcessBuilder.inLane}. */
6
- export interface LaneOptions {
7
- /** Label shown on the lane; defaults to its id. */
8
- name?: string;
9
- }
10
5
  /** Options shared by all element methods. */
11
6
  export interface ElementOptions {
12
7
  name?: string;
@@ -555,6 +550,22 @@ export interface AnnotateOptions {
555
550
  */
556
551
  side?: "above" | "below" | "left" | "right";
557
552
  }
553
+ /** Options for {@link ProcessBuilder.inLane}. */
554
+ export interface LaneOptions {
555
+ /** Label shown on the lane; defaults to its id. */
556
+ name?: string;
557
+ }
558
+ /** Options for `ProcessBuilder.lane()`. */
559
+ export interface DeclaredLaneOptions extends LaneOptions {
560
+ /**
561
+ * Ids of the top-level flow nodes in this lane, written verbatim and in this
562
+ * order. Only a leaf lane (one no other lane names as `parent`) holds nodes;
563
+ * a boundary event follows its host and need not be listed.
564
+ */
565
+ flowNodes?: string[];
566
+ /** Id of the lane this one is a child lane of. */
567
+ parent?: string;
568
+ }
558
569
  /**
559
570
  * Lane bookkeeping shared by a process builder and its gateway branches (never by
560
571
  * sub-process contents: nodes inside a sub-process are not lane members).
@@ -877,6 +888,10 @@ export declare class ProcessBuilder {
877
888
  private _pendingSpliceFlowId;
878
889
  /** Flows the caller deliberately spliced, exempt from the rewiring guard. */
879
890
  private readonly _splicedFlowIds;
891
+ /** `lane()` calls, in call order. */
892
+ private readonly _lanes;
893
+ /** Set by `participant()`: the pool this process is drawn in. */
894
+ private _participant?;
880
895
  private readonly lanes;
881
896
  constructor(processId: string);
882
897
  private roots;
@@ -946,7 +961,11 @@ export declare class ProcessBuilder {
946
961
  }): this;
947
962
  /** Set the display name for this process. */
948
963
  name(name: string): this;
949
- /** Set whether this process is executable. */
964
+ /**
965
+ * Set whether this process is executable. Pass `false` for a partner pool the
966
+ * engine must not deploy: Flowable reads an absent `isExecutable` as
967
+ * executable, so a partner process has to say so explicitly.
968
+ */
950
969
  executable(value: boolean): this;
951
970
  /** Set the process version tag. */
952
971
  versionTag(tag: string): this;
@@ -1131,6 +1150,70 @@ export declare class ProcessBuilder {
1131
1150
  textAnnotation(text: string): this;
1132
1151
  /** Attach a text annotation to any flow element by explicit ID. */
1133
1152
  annotate(elementId: string, text: string, options?: AnnotateOptions): this;
1153
+ /**
1154
+ * Declares a swimlane, or a child lane of `options.parent`.
1155
+ *
1156
+ * Once any lane is declared, a fresh build puts every top-level flow node in
1157
+ * exactly one leaf lane and refuses otherwise, listing every problem at once
1158
+ * (`Invalid lanes:` …): an unknown or sub-process ref, a node listed twice,
1159
+ * flow nodes on a lane with child lanes, an undeclared or looping parent, a
1160
+ * lane id already in use, an unassigned node. Boundary events follow their
1161
+ * host, and an inferred join gateway the lane of its first predecessor.
1162
+ * Parent lanes list the union of their descendants' refs. Lanes imply a
1163
+ * pool: without {@link participant} the build adds `Participant_<processId>`,
1164
+ * named after the process.
1165
+ *
1166
+ * Continuing a document ({@link ProcessBuilder.from}) instead names one of its
1167
+ * existing leaf lanes: the listed nodes move there, `name` renames it, and a
1168
+ * new lane or a `parent` is refused. Nodes added in continue mode join the lane
1169
+ * of their predecessor (see `laneForNewNode`) without any `lane()` call.
1170
+ *
1171
+ * @param id - The lane's element id, used verbatim.
1172
+ * @example
1173
+ * ```typescript
1174
+ * Bpmn.createProcess("order")
1175
+ * .startEvent("start").userTask("review").serviceTask("ship", { taskType: "ship" }).endEvent("end")
1176
+ * .lane("Lane_sales", { name: "Sales", flowNodes: ["start", "review"] })
1177
+ * .lane("Lane_ops", { name: "Operations", flowNodes: ["ship", "end"] })
1178
+ * ```
1179
+ */
1180
+ lane(id: string, options?: DeclaredLaneOptions): this;
1181
+ /**
1182
+ * Names the pool this process is drawn in: the build writes a collaboration
1183
+ * with one participant `id` referencing this process, named `options.name`,
1184
+ * else the process name, else the process id. Without this call a process
1185
+ * gets a pool only when it has lanes.
1186
+ *
1187
+ * Continuing a document, `id` must be the process's existing pool, which
1188
+ * `name` renames; adding or replacing a pool there is refused.
1189
+ *
1190
+ * @param id - The participant's element id, used verbatim.
1191
+ */
1192
+ participant(id: string, options?: Omit<ParticipantOptions, "processId">): this;
1193
+ /**
1194
+ * Lanes and pool of a fresh build: `process` with its lane set, and the
1195
+ * collaboration `participant()` asked for. Both are returned untouched when
1196
+ * neither `lane()` nor `participant()` was called.
1197
+ *
1198
+ * @throws Error listing every lane and pool problem at once.
1199
+ */
1200
+ private freshSwimlanes;
1201
+ /**
1202
+ * Continue mode: new nodes join the lane `laneForNewNode` picks, then each
1203
+ * `lane()` call moves its nodes into, and renames, an existing leaf lane.
1204
+ * Existing refs are kept as they are, even ones a fresh build would refuse:
1205
+ * the document is the caller's.
1206
+ *
1207
+ * @throws Error listing every `lane()` call that cannot be applied.
1208
+ */
1209
+ private continueLanes;
1210
+ /**
1211
+ * Continue mode: `participant()` renames the pool that already references this
1212
+ * process.
1213
+ *
1214
+ * @throws Error when the process has no pool, or one with another id.
1215
+ */
1216
+ private continuePool;
1134
1217
  /**
1135
1218
  * Build the complete BPMN definitions model.
1136
1219
  *
@@ -1171,9 +1254,11 @@ export declare class ProcessBuilder {
1171
1254
  * Writes this process's contents back into the document it came from.
1172
1255
  *
1173
1256
  * Everything not listed here is kept by identity — other processes, the
1174
- * collaboration, diagram interchange, root elements, the process's own lanes,
1175
- * documentation, extensions and unmodelled content. That is the whole point of
1176
- * continuing rather than regenerating.
1257
+ * collaboration, diagram interchange, root elements, the process's existing
1258
+ * lane refs, documentation, extensions and unmodelled content. That is the
1259
+ * whole point of continuing rather than regenerating. The lanes change only
1260
+ * where nodes were added (each joins its predecessor's lane) or moved with
1261
+ * `lane()`; the pool only where `participant()` renames it.
1177
1262
  *
1178
1263
  * Diagram interchange is *not* regenerated: existing shapes keep their
1179
1264
  * positions, and elements added here have none until `placeNewShapes()` draws
@@ -1206,6 +1291,10 @@ export declare class ProcessBuilder {
1206
1291
  inLane(id: string, options?: LaneOptions): this;
1207
1292
  private addFlowElement;
1208
1293
  }
1294
+ /**
1295
+ * Builder for a complete BPMN definitions document containing one or more processes.
1296
+ * Use `Bpmn.createDiagram(id?)` to obtain an instance.
1297
+ */
1209
1298
  export declare class DiagramBuilder {
1210
1299
  private readonly _id;
1211
1300
  private readonly _processes;
@@ -1213,11 +1302,29 @@ export declare class DiagramBuilder {
1213
1302
  private readonly _messages;
1214
1303
  private readonly _participants;
1215
1304
  private readonly _messageFlows;
1305
+ /** Pools the processes brought along: `participant()` on the process, or the one lanes imply. */
1306
+ private readonly _processPools;
1307
+ private readonly _layoutHints;
1308
+ private _autoLayout;
1216
1309
  private _collaborationId;
1217
1310
  private _executionPlatformVersion;
1218
1311
  constructor(id: string);
1219
1312
  /** Set the Camunda execution platform version stamped into the BPMN definitions. Defaults to `"8.10.0"`. */
1220
1313
  executionPlatformVersion(version: string): this;
1314
+ /**
1315
+ * Adds a process built by `callback`.
1316
+ *
1317
+ * The process keeps its lanes, and its pool: the one `participant()` named on
1318
+ * the process builder, or the one its lanes imply. A `participant()` on this
1319
+ * diagram that references the same process replaces that pool.
1320
+ *
1321
+ * A process with no flow elements and no lanes, whose builder never called
1322
+ * `executable()`, is written `isExecutable: false`: it can only be the
1323
+ * process of a black-box partner pool, and Flowable would otherwise deploy
1324
+ * it, since it reads an absent attribute as executable. Every other process
1325
+ * keeps the builder's default, `true`; call `.executable(false)` on a partner
1326
+ * that has content.
1327
+ */
1221
1328
  process(id: string, callback: (b: ProcessBuilder) => void): this;
1222
1329
  /** Renames the collaboration element. Defaults to `"Collaboration_1"`. */
1223
1330
  collaborationId(id: string): this;
@@ -1254,12 +1361,11 @@ export declare class DiagramBuilder {
1254
1361
  */
1255
1362
  messageFlow(id: string, options: MessageFlowOptions): this;
1256
1363
  /**
1257
- * Reports every way the declared collaboration would not survive contact with
1258
- * a modeler, so `build()` can refuse rather than emit a file that opens broken.
1364
+ * Enable auto-layout: `build()` lays out the whole diagram (pools, lanes,
1365
+ * message flows and every process) and writes its diagram interchange, using
1366
+ * the layout hints each process builder recorded.
1259
1367
  */
1260
- private collaborationProblems;
1261
- /** Maps every participant id and every flow node id to its owning participant. */
1262
- private participantIndex;
1368
+ withAutoLayout(): this;
1263
1369
  /**
1264
1370
  * Build the document. Gated like {@link ProcessBuilder.build}: see
1265
1371
  * {@link BuildGateOptions}.