@bpmnkit/core 0.1.1 → 0.2.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/README.md +32 -1
- package/dist/bpmn/agentic.d.ts +121 -0
- package/dist/bpmn/agentic.js +97 -0
- package/dist/bpmn/auto-layout.d.ts +5 -5
- package/dist/bpmn/auto-layout.js +592 -36
- package/dist/bpmn/bpmn-builder.d.ts +265 -3
- package/dist/bpmn/bpmn-builder.js +603 -197
- package/dist/bpmn/bpmn-model.d.ts +114 -0
- package/dist/bpmn/bpmn-parser.js +1414 -521
- package/dist/bpmn/bpmn-serializer.js +107 -19
- package/dist/bpmn/compact.d.ts +17 -2
- package/dist/bpmn/compact.js +3 -3
- package/dist/bpmn/full-operations.d.ts +89 -0
- package/dist/bpmn/full-operations.js +478 -0
- package/dist/bpmn/index.d.ts +19 -0
- package/dist/bpmn/index.js +21 -0
- package/dist/bpmn/optimize/agentic.d.ts +10 -0
- package/dist/bpmn/optimize/agentic.js +88 -0
- package/dist/bpmn/optimize/deploy.d.ts +16 -0
- package/dist/bpmn/optimize/deploy.js +143 -0
- package/dist/bpmn/optimize/feel-syntax.d.ts +12 -0
- package/dist/bpmn/optimize/feel-syntax.js +87 -0
- package/dist/bpmn/optimize/feel.js +7 -4
- package/dist/bpmn/optimize/flow.js +22 -2
- package/dist/bpmn/optimize/index.js +20 -9
- package/dist/bpmn/optimize/patterns.js +23 -16
- package/dist/bpmn/optimize/tasks.js +30 -7
- package/dist/bpmn/optimize/types.d.ts +10 -1
- package/dist/bpmn/optimize/utils.js +2 -4
- package/dist/bpmn/optimize/variable-flow.js +58 -67
- package/dist/bpmn/semantic-hash.d.ts +93 -0
- package/dist/bpmn/semantic-hash.js +155 -0
- package/dist/bpmn/sha256.d.ts +17 -0
- package/dist/bpmn/sha256.js +95 -0
- package/dist/bpmn/zeebe-extensions.d.ts +83 -0
- package/dist/bpmn/zeebe-extensions.js +117 -0
- package/dist/bpmn/zeebe-placement.d.ts +12 -0
- package/dist/bpmn/zeebe-placement.js +140 -0
- package/dist/errors.d.ts +40 -1
- package/dist/errors.js +41 -0
- package/dist/index.d.ts +16 -5
- package/dist/index.js +9 -3
- package/dist/layout/annotations.js +36 -1
- package/dist/layout/collaboration/alignment.d.ts +26 -0
- package/dist/layout/collaboration/alignment.js +66 -0
- package/dist/layout/collaboration/ordering.d.ts +21 -0
- package/dist/layout/collaboration/ordering.js +102 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/layout-engine.d.ts +13 -3
- package/dist/layout/layout-engine.js +9 -4
- package/dist/layout/semantic/bands.d.ts +19 -0
- package/dist/layout/semantic/bands.js +324 -0
- package/dist/layout/semantic/graph.d.ts +37 -0
- package/dist/layout/semantic/graph.js +242 -0
- package/dist/layout/semantic/index.d.ts +13 -0
- package/dist/layout/semantic/index.js +181 -0
- package/dist/layout/semantic/place.d.ts +40 -0
- package/dist/layout/semantic/place.js +271 -0
- package/dist/layout/semantic/route.d.ts +14 -0
- package/dist/layout/semantic/route.js +514 -0
- package/dist/layout/types.d.ts +17 -0
- package/dist/node/index.d.ts +10 -0
- package/dist/node/index.js +9 -0
- package/dist/node/write.d.ts +81 -0
- package/dist/node/write.js +167 -0
- package/dist/plan/compile.d.ts +39 -0
- package/dist/plan/compile.js +380 -0
- package/dist/plan/extract.d.ts +31 -0
- package/dist/plan/extract.js +248 -0
- package/dist/plan/index.d.ts +6 -0
- package/dist/plan/index.js +5 -0
- package/dist/plan/merge.d.ts +13 -0
- package/dist/plan/merge.js +80 -0
- package/dist/plan/slug.d.ts +5 -0
- package/dist/plan/slug.js +22 -0
- package/dist/plan/types.d.ts +225 -0
- package/dist/plan/types.js +13 -0
- package/dist/types/id-generator.js +11 -3
- package/dist/xml/index.d.ts +3 -1
- package/dist/xml/index.js +2 -1
- package/dist/xml/xml-parser.d.ts +32 -0
- package/dist/xml/xml-parser.js +394 -143
- package/package.json +9 -2
|
@@ -131,6 +131,42 @@ function serializeExtensionElements(extensions, bp) {
|
|
|
131
131
|
return [];
|
|
132
132
|
return [el(`${bp}:extensionElements`, {}, extensions)];
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* The `documentation` and `extensionElements` children shared by every BPMN
|
|
136
|
+
* base element, in the order the schema declares them.
|
|
137
|
+
*/
|
|
138
|
+
function serializeBaseChildren(owner, bp) {
|
|
139
|
+
const children = [];
|
|
140
|
+
if (owner.documentation !== undefined) {
|
|
141
|
+
children.push(el(`${bp}:documentation`, {}, [], owner.documentation));
|
|
142
|
+
}
|
|
143
|
+
children.push(...serializeExtensionElements(owner.extensionElements ?? [], bp));
|
|
144
|
+
return children;
|
|
145
|
+
}
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
// Data associations
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
function serializeProperty(property, bp) {
|
|
150
|
+
const attrs = { ...property.unknownAttributes };
|
|
151
|
+
if (property.id !== undefined)
|
|
152
|
+
attrs.id = property.id;
|
|
153
|
+
if (property.name !== undefined)
|
|
154
|
+
attrs.name = property.name;
|
|
155
|
+
if (property.itemSubjectRef !== undefined)
|
|
156
|
+
attrs.itemSubjectRef = property.itemSubjectRef;
|
|
157
|
+
return el(`${bp}:property`, attrs, []);
|
|
158
|
+
}
|
|
159
|
+
function serializeDataAssociation(association, tag, bp) {
|
|
160
|
+
const attrs = { ...association.unknownAttributes };
|
|
161
|
+
if (association.id !== undefined)
|
|
162
|
+
attrs.id = association.id;
|
|
163
|
+
const children = association.sourceRefs.map((ref) => el(`${bp}:sourceRef`, {}, [], ref));
|
|
164
|
+
if (association.targetRef !== undefined) {
|
|
165
|
+
children.push(el(`${bp}:targetRef`, {}, [], association.targetRef));
|
|
166
|
+
}
|
|
167
|
+
children.push(...(association.unknownChildren ?? []));
|
|
168
|
+
return el(`${bp}:${tag}`, attrs, children);
|
|
169
|
+
}
|
|
134
170
|
// ---------------------------------------------------------------------------
|
|
135
171
|
// Multi-instance loop
|
|
136
172
|
// ---------------------------------------------------------------------------
|
|
@@ -140,11 +176,15 @@ function serializeLoopCharacteristics(lc, bp) {
|
|
|
140
176
|
const attrs = {};
|
|
141
177
|
if (lc.isSequential)
|
|
142
178
|
attrs.isSequential = "true";
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
179
|
+
const children = [...serializeExtensionElements(lc.extensionElements, bp)];
|
|
180
|
+
if (lc.loopCardinality) {
|
|
181
|
+
children.push(el(`${bp}:loopCardinality`, lc.loopCardinality.attributes, [], lc.loopCardinality.text));
|
|
182
|
+
}
|
|
183
|
+
if (lc.completionCondition) {
|
|
184
|
+
children.push(el(`${bp}:completionCondition`, lc.completionCondition.attributes, [], lc.completionCondition.text));
|
|
185
|
+
}
|
|
186
|
+
children.push(...(lc.unknownChildren ?? []));
|
|
187
|
+
return [el(`${bp}:multiInstanceLoopCharacteristics`, attrs, children)];
|
|
148
188
|
}
|
|
149
189
|
// ---------------------------------------------------------------------------
|
|
150
190
|
// Flow elements
|
|
@@ -169,6 +209,17 @@ function serializeFlowElement(fe, ns) {
|
|
|
169
209
|
// Incoming / outgoing
|
|
170
210
|
children.push(...flowRefs(fe.incoming, "incoming", bp));
|
|
171
211
|
children.push(...flowRefs(fe.outgoing, "outgoing", bp));
|
|
212
|
+
// Data wiring
|
|
213
|
+
for (const property of fe.properties ?? []) {
|
|
214
|
+
children.push(serializeProperty(property, bp));
|
|
215
|
+
}
|
|
216
|
+
for (const association of fe.dataInputAssociations ?? []) {
|
|
217
|
+
children.push(serializeDataAssociation(association, "dataInputAssociation", bp));
|
|
218
|
+
}
|
|
219
|
+
for (const association of fe.dataOutputAssociations ?? []) {
|
|
220
|
+
children.push(serializeDataAssociation(association, "dataOutputAssociation", bp));
|
|
221
|
+
}
|
|
222
|
+
children.push(...(fe.unknownChildren ?? []));
|
|
172
223
|
switch (fe.type) {
|
|
173
224
|
case "startEvent":
|
|
174
225
|
if (fe.isInterrupting === false)
|
|
@@ -202,8 +253,14 @@ function serializeFlowElement(fe, ns) {
|
|
|
202
253
|
children.push(...serializeLoopCharacteristics(fe.loopCharacteristics, bp));
|
|
203
254
|
break;
|
|
204
255
|
case "adHocSubProcess":
|
|
256
|
+
if (fe.cancelRemainingInstances !== undefined) {
|
|
257
|
+
attrs.cancelRemainingInstances = String(fe.cancelRemainingInstances);
|
|
258
|
+
}
|
|
205
259
|
children.push(...serializeLoopCharacteristics(fe.loopCharacteristics, bp));
|
|
206
260
|
children.push(...serializeProcessContents(fe, ns));
|
|
261
|
+
if (fe.completionCondition) {
|
|
262
|
+
children.push(el(`${bp}:completionCondition`, fe.completionCondition.attributes, [], fe.completionCondition.text));
|
|
263
|
+
}
|
|
207
264
|
break;
|
|
208
265
|
case "subProcess":
|
|
209
266
|
if (fe.triggeredByEvent !== undefined)
|
|
@@ -272,8 +329,22 @@ function serializeSequenceFlow(sf, bp) {
|
|
|
272
329
|
// ---------------------------------------------------------------------------
|
|
273
330
|
// Annotations
|
|
274
331
|
// ---------------------------------------------------------------------------
|
|
332
|
+
function serializeCategory(category, bp) {
|
|
333
|
+
const attrs = { ...category.unknownAttributes };
|
|
334
|
+
if (category.id !== undefined)
|
|
335
|
+
attrs.id = category.id;
|
|
336
|
+
if (category.name !== undefined)
|
|
337
|
+
attrs.name = category.name;
|
|
338
|
+
const children = category.categoryValues.map((value) => {
|
|
339
|
+
const valueAttrs = { id: value.id, ...value.unknownAttributes };
|
|
340
|
+
if (value.value !== undefined)
|
|
341
|
+
valueAttrs.value = value.value;
|
|
342
|
+
return el(`${bp}:categoryValue`, valueAttrs, []);
|
|
343
|
+
});
|
|
344
|
+
return el(`${bp}:category`, attrs, children);
|
|
345
|
+
}
|
|
275
346
|
function serializeTextAnnotation(ta, bp) {
|
|
276
|
-
const children =
|
|
347
|
+
const children = serializeBaseChildren(ta, bp);
|
|
277
348
|
if (ta.text !== undefined) {
|
|
278
349
|
children.push(el(`${bp}:text`, {}, [], ta.text));
|
|
279
350
|
}
|
|
@@ -288,13 +359,13 @@ function serializeAssociation(a, bp) {
|
|
|
288
359
|
};
|
|
289
360
|
if (a.associationDirection !== undefined)
|
|
290
361
|
attrs.associationDirection = a.associationDirection;
|
|
291
|
-
return el(`${bp}:association`, attrs,
|
|
362
|
+
return el(`${bp}:association`, attrs, serializeBaseChildren(a, bp));
|
|
292
363
|
}
|
|
293
364
|
function serializeGroup(g, bp) {
|
|
294
365
|
const attrs = { id: g.id, ...g.unknownAttributes };
|
|
295
366
|
if (g.categoryValueRef !== undefined)
|
|
296
367
|
attrs.categoryValueRef = g.categoryValueRef;
|
|
297
|
-
return el(`${bp}:group`, attrs,
|
|
368
|
+
return el(`${bp}:group`, attrs, serializeBaseChildren(g, bp));
|
|
298
369
|
}
|
|
299
370
|
// ---------------------------------------------------------------------------
|
|
300
371
|
// Process contents
|
|
@@ -327,16 +398,19 @@ function serializeLane(lane, bp) {
|
|
|
327
398
|
const attrs = { id: lane.id, ...lane.unknownAttributes };
|
|
328
399
|
if (lane.name !== undefined)
|
|
329
400
|
attrs.name = lane.name;
|
|
330
|
-
const children = lane
|
|
401
|
+
const children = serializeBaseChildren(lane, bp);
|
|
402
|
+
children.push(...lane.flowNodeRefs.map((ref) => el(`${bp}:flowNodeRef`, {}, [], ref)));
|
|
331
403
|
if (lane.childLaneSet) {
|
|
332
404
|
children.push(serializeLaneSet(lane.childLaneSet, bp));
|
|
333
405
|
}
|
|
334
406
|
return el(`${bp}:lane`, attrs, children);
|
|
335
407
|
}
|
|
336
408
|
function serializeLaneSet(laneSet, bp) {
|
|
337
|
-
const attrs = {};
|
|
409
|
+
const attrs = { ...laneSet.unknownAttributes };
|
|
338
410
|
if (laneSet.id)
|
|
339
411
|
attrs.id = laneSet.id;
|
|
412
|
+
if (laneSet.name !== undefined)
|
|
413
|
+
attrs.name = laneSet.name;
|
|
340
414
|
return el(`${bp}:laneSet`, attrs, laneSet.lanes.map((l) => serializeLane(l, bp)));
|
|
341
415
|
}
|
|
342
416
|
// ---------------------------------------------------------------------------
|
|
@@ -349,12 +423,12 @@ function serializeProcess(process, ns) {
|
|
|
349
423
|
attrs.name = process.name;
|
|
350
424
|
if (process.isExecutable)
|
|
351
425
|
attrs.isExecutable = "true";
|
|
352
|
-
const children =
|
|
353
|
-
children.push(...serializeExtensionElements(process.extensionElements, bp));
|
|
426
|
+
const children = serializeBaseChildren({ documentation: process.documentation, extensionElements: process.extensionElements }, bp);
|
|
354
427
|
if (process.laneSet) {
|
|
355
428
|
children.push(serializeLaneSet(process.laneSet, bp));
|
|
356
429
|
}
|
|
357
430
|
children.push(...serializeProcessContents(process, ns));
|
|
431
|
+
children.push(...(process.unknownChildren ?? []));
|
|
358
432
|
return el(`${bp}:process`, attrs, children);
|
|
359
433
|
}
|
|
360
434
|
// ---------------------------------------------------------------------------
|
|
@@ -366,7 +440,7 @@ function serializeParticipant(p, bp) {
|
|
|
366
440
|
attrs.name = p.name;
|
|
367
441
|
if (p.processRef !== undefined)
|
|
368
442
|
attrs.processRef = p.processRef;
|
|
369
|
-
return el(`${bp}:participant`, attrs,
|
|
443
|
+
return el(`${bp}:participant`, attrs, serializeBaseChildren(p, bp));
|
|
370
444
|
}
|
|
371
445
|
function serializeMessageFlow(mf, bp) {
|
|
372
446
|
const attrs = {
|
|
@@ -377,11 +451,13 @@ function serializeMessageFlow(mf, bp) {
|
|
|
377
451
|
};
|
|
378
452
|
if (mf.name !== undefined)
|
|
379
453
|
attrs.name = mf.name;
|
|
380
|
-
|
|
454
|
+
if (mf.messageRef !== undefined)
|
|
455
|
+
attrs.messageRef = mf.messageRef;
|
|
456
|
+
return el(`${bp}:messageFlow`, attrs, serializeBaseChildren(mf, bp));
|
|
381
457
|
}
|
|
382
458
|
function serializeCollaboration(c, ns) {
|
|
383
459
|
const bp = bpmnPrefix(ns);
|
|
384
|
-
const children =
|
|
460
|
+
const children = serializeBaseChildren(c, bp);
|
|
385
461
|
for (const p of c.participants) {
|
|
386
462
|
children.push(serializeParticipant(p, bp));
|
|
387
463
|
}
|
|
@@ -397,6 +473,7 @@ function serializeCollaboration(c, ns) {
|
|
|
397
473
|
for (const g of c.groups ?? []) {
|
|
398
474
|
children.push(serializeGroup(g, bp));
|
|
399
475
|
}
|
|
476
|
+
children.push(...(c.unknownChildren ?? []));
|
|
400
477
|
return el(`${bp}:collaboration`, { id: c.id, ...c.unknownAttributes }, children);
|
|
401
478
|
}
|
|
402
479
|
// ---------------------------------------------------------------------------
|
|
@@ -408,7 +485,7 @@ function serializeError(e, bp) {
|
|
|
408
485
|
attrs.name = e.name;
|
|
409
486
|
if (e.errorCode !== undefined)
|
|
410
487
|
attrs.errorCode = e.errorCode;
|
|
411
|
-
return el(`${bp}:error`, attrs,
|
|
488
|
+
return el(`${bp}:error`, { ...e.unknownAttributes, ...attrs }, serializeBaseChildren(e, bp));
|
|
412
489
|
}
|
|
413
490
|
function serializeEscalation(e, bp) {
|
|
414
491
|
const attrs = { id: e.id };
|
|
@@ -416,19 +493,19 @@ function serializeEscalation(e, bp) {
|
|
|
416
493
|
attrs.name = e.name;
|
|
417
494
|
if (e.escalationCode !== undefined)
|
|
418
495
|
attrs.escalationCode = e.escalationCode;
|
|
419
|
-
return el(`${bp}:escalation`, attrs,
|
|
496
|
+
return el(`${bp}:escalation`, { ...e.unknownAttributes, ...attrs }, serializeBaseChildren(e, bp));
|
|
420
497
|
}
|
|
421
498
|
function serializeMessage(m, bp) {
|
|
422
499
|
const attrs = { id: m.id, ...m.unknownAttributes };
|
|
423
500
|
if (m.name !== undefined)
|
|
424
501
|
attrs.name = m.name;
|
|
425
|
-
return el(`${bp}:message`, attrs,
|
|
502
|
+
return el(`${bp}:message`, attrs, serializeBaseChildren(m, bp));
|
|
426
503
|
}
|
|
427
504
|
function serializeSignal(s, bp) {
|
|
428
505
|
const attrs = { id: s.id };
|
|
429
506
|
if (s.name !== undefined)
|
|
430
507
|
attrs.name = s.name;
|
|
431
|
-
return el(`${bp}:signal`, attrs,
|
|
508
|
+
return el(`${bp}:signal`, { ...s.unknownAttributes, ...attrs }, serializeBaseChildren(s, bp));
|
|
432
509
|
}
|
|
433
510
|
// ---------------------------------------------------------------------------
|
|
434
511
|
// Diagram interchange
|
|
@@ -533,6 +610,17 @@ export function serializeBpmn(definitions) {
|
|
|
533
610
|
attrs[key] = value;
|
|
534
611
|
}
|
|
535
612
|
const children = [];
|
|
613
|
+
if (definitions.documentation !== undefined) {
|
|
614
|
+
children.push(el(`${bp}:documentation`, {}, [], definitions.documentation));
|
|
615
|
+
}
|
|
616
|
+
// Categories supply the labels groups reference
|
|
617
|
+
for (const category of definitions.categories ?? []) {
|
|
618
|
+
children.push(serializeCategory(category, bp));
|
|
619
|
+
}
|
|
620
|
+
// Unmodelled children first: `import` and `extension` precede the root
|
|
621
|
+
// elements in the schema, and the rest are root elements themselves, so they
|
|
622
|
+
// sit legally alongside the modelled ones.
|
|
623
|
+
children.push(...(definitions.unknownChildren ?? []));
|
|
536
624
|
// Root elements: errors, escalations, messages, signals first
|
|
537
625
|
for (const e of definitions.escalations) {
|
|
538
626
|
children.push(serializeEscalation(e, bp));
|
package/dist/bpmn/compact.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { XmlElement } from "../types/xml-element.js";
|
|
2
|
+
import type { BpmnDefinitions, BpmnElementType, BpmnEventDefinition, BpmnFlowElement } from "./bpmn-model.js";
|
|
2
3
|
/** A single BPMN flow node in compact form. */
|
|
3
4
|
export interface CompactElement {
|
|
4
5
|
id: string;
|
|
@@ -54,7 +55,18 @@ export interface CompactProcess {
|
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* Token-efficient representation of a {@link BpmnDefinitions} document.
|
|
57
|
-
*
|
|
58
|
+
*
|
|
59
|
+
* **A read-only view, not a model.** It carries topology, names and the common
|
|
60
|
+
* Zeebe bindings and drops everything else — collaborations, participants,
|
|
61
|
+
* message flows, lanes, data stores, artifacts, root-level messages and errors,
|
|
62
|
+
* multi-instance loop characteristics, full `zeebe:ioMapping` entries and the
|
|
63
|
+
* diagram. Use it to show a model to a language model, and
|
|
64
|
+
* {@link expand} to build a *new* model from one.
|
|
65
|
+
*
|
|
66
|
+
* Do not use it as an edit path for a file you need to keep:
|
|
67
|
+
* `expand(compactify(defs))` is not `defs`. Edit the {@link BpmnDefinitions}
|
|
68
|
+
* instead — `applyBpmnOperations` applies the same operation vocabulary to the
|
|
69
|
+
* full model without going through this projection.
|
|
58
70
|
*/
|
|
59
71
|
export interface CompactDiagram {
|
|
60
72
|
id: string;
|
|
@@ -80,6 +92,9 @@ export interface CompactDiagram {
|
|
|
80
92
|
* ```
|
|
81
93
|
*/
|
|
82
94
|
export declare function compactify(defs: BpmnDefinitions): CompactDiagram;
|
|
95
|
+
export declare function makeEventDef(eventType: string): BpmnEventDefinition | undefined;
|
|
96
|
+
export declare function makeExtensions(el: CompactElement): XmlElement[];
|
|
97
|
+
export declare function buildFlowElement(el: CompactElement, incoming: string[], outgoing: string[]): BpmnFlowElement;
|
|
83
98
|
/**
|
|
84
99
|
* Restores a {@link CompactDiagram} (produced by {@link compactify} or an AI
|
|
85
100
|
* model) back to a full {@link BpmnDefinitions} with auto-generated layout.
|
package/dist/bpmn/compact.js
CHANGED
|
@@ -112,7 +112,7 @@ export function compactify(defs) {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
// ── Expand ───────────────────────────────────────────────────────────────────
|
|
115
|
-
function makeEventDef(eventType) {
|
|
115
|
+
export function makeEventDef(eventType) {
|
|
116
116
|
switch (eventType) {
|
|
117
117
|
case "timer":
|
|
118
118
|
return { type: "timer" };
|
|
@@ -138,7 +138,7 @@ function makeEventDef(eventType) {
|
|
|
138
138
|
return undefined;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function makeExtensions(el) {
|
|
141
|
+
export function makeExtensions(el) {
|
|
142
142
|
const ext = [];
|
|
143
143
|
if (el.jobType) {
|
|
144
144
|
ext.push({ name: "zeebe:taskDefinition", attributes: { type: el.jobType }, children: [] });
|
|
@@ -226,7 +226,7 @@ function buildSubContent(children) {
|
|
|
226
226
|
groups: [],
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
-
function buildFlowElement(el, incoming, outgoing) {
|
|
229
|
+
export function buildFlowElement(el, incoming, outgoing) {
|
|
230
230
|
const base = {
|
|
231
231
|
id: el.id,
|
|
232
232
|
name: el.name,
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { BpmnDefinitions } from "./bpmn-model.js";
|
|
2
|
+
import { type CompactDiagram } from "./compact.js";
|
|
3
|
+
import type { BpmnOperation } from "./operations.js";
|
|
4
|
+
/**
|
|
5
|
+
* Applies the {@link BpmnOperation} vocabulary directly to a
|
|
6
|
+
* {@link BpmnDefinitions}.
|
|
7
|
+
*
|
|
8
|
+
* The operations were originally applied to a `CompactDiagram`, which meant
|
|
9
|
+
* every edit round-tripped the model through a projection that models about
|
|
10
|
+
* fifteen properties — so editing a task's name silently discarded the
|
|
11
|
+
* document's pools, lanes, data associations and `zeebe:ioMapping` detail.
|
|
12
|
+
* Applying the same operations here touches only what an operation names and
|
|
13
|
+
* leaves the rest of the element untouched.
|
|
14
|
+
*
|
|
15
|
+
* Unresolved ids are reported rather than ignored. The original implementation
|
|
16
|
+
* skipped any operation whose target did not exist, so a patch with a
|
|
17
|
+
* misspelled id reported success and changed nothing.
|
|
18
|
+
*/
|
|
19
|
+
/** An operation that could not be applied, and why. */
|
|
20
|
+
export interface OperationProblem {
|
|
21
|
+
/** Position in the operation list, so a caller can point at the offender. */
|
|
22
|
+
index: number;
|
|
23
|
+
/** The operation as given. */
|
|
24
|
+
operation: BpmnOperation;
|
|
25
|
+
/** What went wrong, in a form worth showing a user. */
|
|
26
|
+
reason: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ApplyBpmnOperationsResult {
|
|
29
|
+
/** The edited model. The input is never mutated. */
|
|
30
|
+
definitions: BpmnDefinitions;
|
|
31
|
+
/** How many operations took effect. */
|
|
32
|
+
applied: number;
|
|
33
|
+
/** Operations that did not, each with a reason. */
|
|
34
|
+
problems: OperationProblem[];
|
|
35
|
+
}
|
|
36
|
+
export interface ApplyBpmnOperationsOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Throw if any operation fails, leaving the model untouched. Default `true`
|
|
39
|
+
* — silence is what made the previous implementation dangerous.
|
|
40
|
+
*/
|
|
41
|
+
strict?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Thrown by {@link applyBpmnOperations} in strict mode. */
|
|
44
|
+
export declare class OperationError extends Error {
|
|
45
|
+
readonly problems: OperationProblem[];
|
|
46
|
+
constructor(problems: OperationProblem[]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Applies operations to a copy of the model.
|
|
50
|
+
*
|
|
51
|
+
* @param definitions - The model to edit. Never mutated.
|
|
52
|
+
* @param operations - Operations to apply, in order.
|
|
53
|
+
* @param options - `strict` (default `true`) throws instead of returning problems.
|
|
54
|
+
* @returns The edited model, how many operations landed, and what did not.
|
|
55
|
+
* @throws {OperationError} In strict mode, when any operation fails. Nothing is
|
|
56
|
+
* applied — the caller's model and the returned one are both untouched.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { applyBpmnOperations } from "@bpmnkit/core"
|
|
61
|
+
*
|
|
62
|
+
* const { definitions } = applyBpmnOperations(parsed, [
|
|
63
|
+
* { op: "rename", id: "Task_1", name: "Approve invoice" },
|
|
64
|
+
* ])
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function applyBpmnOperations(definitions: BpmnDefinitions, operations: readonly BpmnOperation[], options?: ApplyBpmnOperationsOptions): ApplyBpmnOperationsResult;
|
|
68
|
+
/**
|
|
69
|
+
* Applies a {@link CompactDiagram} onto an existing model as a set of changes,
|
|
70
|
+
* rather than expanding it into a replacement.
|
|
71
|
+
*
|
|
72
|
+
* `expand(compact)` builds a whole new model from about fifteen properties per
|
|
73
|
+
* element, so using it to apply an edit destroys everything the compact form
|
|
74
|
+
* does not carry. This walks the same input as a description of the intended
|
|
75
|
+
* topology and turns it into {@link BpmnOperation}s: elements that already exist
|
|
76
|
+
* are patched in place and keep their extensions, new ones are inserted, and
|
|
77
|
+
* ones the input no longer mentions are removed.
|
|
78
|
+
*
|
|
79
|
+
* Processes are only ever added, never removed — a caller sending one process of
|
|
80
|
+
* a multi-process document means "this is how that process should look", not
|
|
81
|
+
* "delete the others".
|
|
82
|
+
*
|
|
83
|
+
* @param definitions - The model to update. Never mutated.
|
|
84
|
+
* @param compact - The intended topology.
|
|
85
|
+
* @param options - `strict` (default `true`) throws instead of returning problems.
|
|
86
|
+
* @returns The updated model, plus what applied and what did not.
|
|
87
|
+
*/
|
|
88
|
+
export declare function reconcileCompact(definitions: BpmnDefinitions, compact: CompactDiagram, options?: ApplyBpmnOperationsOptions): ApplyBpmnOperationsResult;
|
|
89
|
+
//# sourceMappingURL=full-operations.d.ts.map
|