@formicoidea/labre-framework-bpmn 0.32.0 → 0.34.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.
- package/dist/actions.d.ts +202 -6
- package/dist/actions.js +427 -43
- package/dist/background.d.ts +2 -0
- package/dist/background.js +158 -0
- package/dist/commands-manifest.d.ts +18 -0
- package/dist/commands-manifest.js +226 -0
- package/dist/commands.js +496 -5
- package/dist/consts.d.ts +195 -4
- package/dist/consts.js +230 -4
- package/dist/element-renderer.d.ts +10 -4
- package/dist/element-renderer.js +14 -55
- package/dist/element-view.d.ts +119 -8
- package/dist/element-view.js +274 -30
- package/dist/export.d.ts +277 -0
- package/dist/export.js +1802 -0
- package/dist/facts.d.ts +48 -0
- package/dist/facts.js +127 -0
- package/dist/import.d.ts +69 -0
- package/dist/import.js +1476 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +47 -0
- package/dist/interchange.d.ts +109 -0
- package/dist/interchange.js +191 -0
- package/dist/morph.d.ts +61 -0
- package/dist/morph.js +118 -0
- package/dist/node/node-renderer.d.ts +0 -9
- package/dist/node/node-renderer.js +294 -17
- package/dist/pool-hit.d.ts +98 -0
- package/dist/pool-hit.js +130 -0
- package/dist/presets.d.ts +168 -0
- package/dist/presets.js +327 -0
- package/dist/profiles.d.ts +2 -0
- package/dist/profiles.js +189 -0
- package/dist/roles.d.ts +96 -0
- package/dist/roles.js +410 -0
- package/dist/rules.d.ts +199 -0
- package/dist/rules.js +1539 -0
- package/dist/templates/index.js +116 -9
- package/dist/toolbar/bpmn-senior-button.js +8 -2
- package/dist/toolbar/config.d.ts +28 -2
- package/dist/toolbar/config.js +93 -4
- package/dist/toolbar/icons.d.ts +67 -0
- package/dist/toolbar/icons.js +141 -0
- package/dist/toolbar/senior-tool.js +1 -0
- package/dist/translations.d.ts +3 -1
- package/dist/translations.js +38 -3
- package/dist/view.d.ts +6 -2
- package/dist/view.js +68 -5
- package/package.json +6 -2
package/dist/export.d.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { BpmnNodeElementModel, BpmnNodeKind, BpmnPoolElementModel, ConnectorElementModel } from '@formicoidea/labre-core/model';
|
|
2
|
+
/**
|
|
3
|
+
* The board, as a BPMN 2.0 interchange document (clause 15) — semantic model
|
|
4
|
+
* plus BPMN DI, in one `definitions` element.
|
|
5
|
+
*
|
|
6
|
+
* ## Pure by construction
|
|
7
|
+
*
|
|
8
|
+
* Element models in, string out. No `BlockStdScope`, no surface, no DOM, no
|
|
9
|
+
* clock and no randomness — the same discipline `facts.ts` holds itself to, and
|
|
10
|
+
* for the same three reasons: a host can call it, a test can call it with plain
|
|
11
|
+
* stubs, and the same board always serializes to the same bytes. The command
|
|
12
|
+
* that downloads the file is the only thing that knows what a canvas is.
|
|
13
|
+
*
|
|
14
|
+
* ## What it says, and what it refuses to say
|
|
15
|
+
*
|
|
16
|
+
* The export speaks the author's STATEMENTS and nothing else. A connector
|
|
17
|
+
* carrying no BPMN role relates nothing — `docs/adr/0010` is explicit that the
|
|
18
|
+
* role is the statement — so it is not a sequence flow that happens to be
|
|
19
|
+
* untyped, it is not a flow at all, and it is absent. A plain rectangle drawn
|
|
20
|
+
* beside a pool is likewise not an unnamed task. The alternative — guessing —
|
|
21
|
+
* would put words in an architect's mouth in a file they are about to hand to
|
|
22
|
+
* an execution engine.
|
|
23
|
+
*
|
|
24
|
+
* ## Conformance target
|
|
25
|
+
*
|
|
26
|
+
* The **Descriptive** sub-class of BPMN 2.0 (spec Table 2.1), which is exactly
|
|
27
|
+
* the vocabulary the pack draws: the seventeen artefacts map onto the
|
|
28
|
+
* seventeen-odd element names that table lists, and nothing here needs the
|
|
29
|
+
* executable half of the metamodel. Clause 15.1 explicitly licenses a partial
|
|
30
|
+
* model — implementers "disregard missing attributes marked required" — which
|
|
31
|
+
* is what lets a picture drawn for humans round-trip through bpmn.io without
|
|
32
|
+
* inventing an `ioSpecification` nobody asked for.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* The four namespaces an interchange file is written in, with the prefixes the
|
|
36
|
+
* spec's own schema uses (`bpmndi`, `di`, `dc`; §12.2.4 and Annex B).
|
|
37
|
+
*
|
|
38
|
+
* Prefixes are arbitrary and URIs are not — bpmn.io writes the same two DD
|
|
39
|
+
* namespaces as `omgdi` / `omgdc` — so the URIs are what is pinned by the tests
|
|
40
|
+
* and the prefixes merely have to be consistent with themselves. The MODEL
|
|
41
|
+
* namespace is given the explicit `bpmn` prefix rather than made the default,
|
|
42
|
+
* because a reader of the file should never have to work out which of two
|
|
43
|
+
* unprefixed vocabularies an element belongs to.
|
|
44
|
+
*
|
|
45
|
+
* The stale `.../BPMNDI/1.0.0` that appears in the spec's own clause 15.3.1
|
|
46
|
+
* example is a documented erratum and is NOT what the normative schema says.
|
|
47
|
+
*/
|
|
48
|
+
export declare const BPMN_NS: {
|
|
49
|
+
readonly model: "http://www.omg.org/spec/BPMN/20100524/MODEL";
|
|
50
|
+
readonly bpmndi: "http://www.omg.org/spec/BPMN/20100524/DI";
|
|
51
|
+
readonly di: "http://www.omg.org/spec/DD/20100524/DI";
|
|
52
|
+
readonly dc: "http://www.omg.org/spec/DD/20100524/DC";
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The four declarations this library writes, as they appear on `definitions` —
|
|
56
|
+
* the PAIR, prefix and URI together, and the pair is the point.
|
|
57
|
+
*
|
|
58
|
+
* A reader carries a file's namespace declarations because a carried fragment
|
|
59
|
+
* is stored with the prefixes the file spelled it in, and a `camunda:property`
|
|
60
|
+
* or a `bpmn2:boundaryEvent` means nothing under a declaration nobody wrote.
|
|
61
|
+
* What it must NOT carry is a declaration this writer is going to make anyway,
|
|
62
|
+
* or the payload gains four permanent entries, every Labre file reports four
|
|
63
|
+
* things carried, and the "a file we wrote comes back with an empty middle
|
|
64
|
+
* column" property — the no-slow-leak property — stops being true.
|
|
65
|
+
*
|
|
66
|
+
* Keyed by the attribute NAME rather than by the URI, because the prefix is
|
|
67
|
+
* exactly what differs: bpmn.io writes the model namespace as `bpmn2:` and this
|
|
68
|
+
* library writes it as `bpmn:`, and a fragment carrying `bpmn2:` is unreadable
|
|
69
|
+
* unless `xmlns:bpmn2` comes back with it. Same URI, different prefix,
|
|
70
|
+
* different fate — which a set of URIs cannot express.
|
|
71
|
+
*/
|
|
72
|
+
export declare const BPMN_OWN_DECLARATIONS: Readonly<Record<string, string>>;
|
|
73
|
+
/**
|
|
74
|
+
* The interchange format's id — the key under which foreign matter from a
|
|
75
|
+
* `.bpmn` rides on an element (`interchange.bpmn`, ADR 0012 D2), and the middle
|
|
76
|
+
* term of both capability ids.
|
|
77
|
+
*
|
|
78
|
+
* Declared here, in the module both directions already depend on, so that the
|
|
79
|
+
* writer, the reader and the registry entry cannot disagree about which key
|
|
80
|
+
* they are talking about.
|
|
81
|
+
*/
|
|
82
|
+
export declare const BPMN_FORMAT_ID = "bpmn";
|
|
83
|
+
/**
|
|
84
|
+
* Which slot of `process` an artefact serializes into.
|
|
85
|
+
*
|
|
86
|
+
* Not decoration: the spec's `tProcess` sequence is `laneSet* → flowElement* →
|
|
87
|
+
* artifact*` in that order, and a `textAnnotation` written before a `task` is a
|
|
88
|
+
* document a validating parser rejects. It also decides what a LANE may point
|
|
89
|
+
* at — `flowNodeRef` is an IDREF to a flow NODE, and a data reference is a flow
|
|
90
|
+
* element that is not one, so a data object sitting in a lane is simply not
|
|
91
|
+
* referenced by it.
|
|
92
|
+
*/
|
|
93
|
+
type BpmnXmlSlot = 'flowNode' | 'data' | 'artifact';
|
|
94
|
+
export interface BpmnXmlMapping {
|
|
95
|
+
/** The semantic element name, in the MODEL namespace. */
|
|
96
|
+
element: string;
|
|
97
|
+
slot: BpmnXmlSlot;
|
|
98
|
+
/** The child that says what TRIGGERS the event, for the four variants. */
|
|
99
|
+
eventDefinition?: 'messageEventDefinition' | 'timerEventDefinition' | 'terminateEventDefinition';
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The whole notation, kind by kind — the table this module is really about.
|
|
103
|
+
*
|
|
104
|
+
* `Record<BpmnNodeKind, …>` and therefore COMPILE-TOTAL: a kind added to the
|
|
105
|
+
* pack without a BPMN element name to serialize it as fails the build here,
|
|
106
|
+
* which is the only place that failure is cheap. A kind that reached a
|
|
107
|
+
* document and had no mapping would be an artefact the author drew, saved, and
|
|
108
|
+
* then silently lost on export.
|
|
109
|
+
*
|
|
110
|
+
* Three of the seventeen do not map one-for-one and the reasons are the spec's:
|
|
111
|
+
*
|
|
112
|
+
* - the four TRIGGERED events are `startEvent` / `endEvent` carrying an event
|
|
113
|
+
* definition child, never elements of their own — "message start event" is a
|
|
114
|
+
* start event with a `messageEventDefinition` in it (§10.4.2);
|
|
115
|
+
* - a data object serializes as `dataObjectReference`, because DI attaches to
|
|
116
|
+
* the REFERENCE and not to the `dataObject` it points at (§10.4.1, and the
|
|
117
|
+
* spec's own rule that "Data Object Reference cannot specify item
|
|
118
|
+
* definitions, and Data Objects cannot specify states"). The `dataObject`
|
|
119
|
+
* itself is emitted alongside it;
|
|
120
|
+
* - a `group` carries no `name` at all. Its visible label is the `value` of the
|
|
121
|
+
* `categoryValue` it points at, which is a ROOT element of the document — the
|
|
122
|
+
* one place in this file where drawing a box round three tasks costs two
|
|
123
|
+
* extra elements somewhere else entirely (§10.4, Table 8.30).
|
|
124
|
+
*/
|
|
125
|
+
export declare const BPMN_XML_OF_KIND: Record<BpmnNodeKind, BpmnXmlMapping>;
|
|
126
|
+
/**
|
|
127
|
+
* Character DATA — the three characters that would otherwise start markup.
|
|
128
|
+
*
|
|
129
|
+
* A newline, a tab and a carriage return are left exactly as they are, which is
|
|
130
|
+
* what makes `<bpmn:text>` carry a multi-line annotation faithfully: inside an
|
|
131
|
+
* element, whitespace is content.
|
|
132
|
+
*/
|
|
133
|
+
export declare function escapeText(value: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* An attribute VALUE, which needs strictly more than character data does.
|
|
136
|
+
*
|
|
137
|
+
* The quotes are the obvious half. The other half is the one that loses data
|
|
138
|
+
* silently: XML 1.0 §3.3.3 makes every conformant parser replace a literal
|
|
139
|
+
* `#xA`, `#xD` or `#x9` in an attribute value with a SPACE before anyone sees
|
|
140
|
+
* it — attribute-value normalization, and it is not optional. Only a character
|
|
141
|
+
* reference survives it.
|
|
142
|
+
*
|
|
143
|
+
* That matters here because a multi-line label is ordinary on this canvas (it
|
|
144
|
+
* is how a task fits in its box) and `name` is where nearly all of them go:
|
|
145
|
+
* every flow node, the participant, the lane, the flows, and
|
|
146
|
+
* `categoryValue/@value`. Written raw, a two-line task name comes back as one
|
|
147
|
+
* line, with no warning and no way for the author to tell. Written as ` `
|
|
148
|
+
* it comes back as it went in.
|
|
149
|
+
*/
|
|
150
|
+
export declare function escapeAttr(value: string): string;
|
|
151
|
+
/**
|
|
152
|
+
* A surface id, as an XML NCName.
|
|
153
|
+
*
|
|
154
|
+
* `id` is `xsd:ID` throughout BPMN, which means NCName and means
|
|
155
|
+
* DOCUMENT-unique — a `BPMNShape` may not carry the id of the `task` it
|
|
156
|
+
* describes. Surface ids are nanoid-shaped: they routinely open on a digit and
|
|
157
|
+
* may carry a `-`, both of which a validating parser refuses on an `xsd:ID`.
|
|
158
|
+
*
|
|
159
|
+
* So: every disallowed character becomes `_`, and an id that does not open on a
|
|
160
|
+
* letter or `_` is prefixed with one. The transformation is lossy on purpose —
|
|
161
|
+
* two distinct surface ids can collapse onto the same NCName — which is what
|
|
162
|
+
* {@link IdMinter} is for.
|
|
163
|
+
*/
|
|
164
|
+
export declare function toNcName(raw: string): string;
|
|
165
|
+
/** Whether a string is already an NCName, and can therefore be given back. */
|
|
166
|
+
export declare function isNcName(value: string): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* `.bpmn`'s scope vocabulary — where a carried fragment came off, and therefore
|
|
169
|
+
* where this writer has to put it back (ADR 0012, D2 as amended in #157).
|
|
170
|
+
*
|
|
171
|
+
* Declared HERE, in the module both directions already depend on, for the same
|
|
172
|
+
* reason {@link BPMN_FORMAT_ID} is: the reader files a fragment under a scope
|
|
173
|
+
* and the writer looks it up under one, and a table written twice is a table
|
|
174
|
+
* that drifts. `import.ts` re-exports it.
|
|
175
|
+
*
|
|
176
|
+
* One Labre element stands for several source elements: a pool is a
|
|
177
|
+
* `participant` AND its `process`, plus a `laneSet`, every `lane`, the
|
|
178
|
+
* `BPMNShape` that draws it, and — on the first pool of a document — the
|
|
179
|
+
* `collaboration` and `definitions` themselves. Everything they carry lands in
|
|
180
|
+
* ONE payload, so what came off which is recorded, or two lanes with the same
|
|
181
|
+
* foreign attribute leave one value in a persisted field and a report that says
|
|
182
|
+
* two.
|
|
183
|
+
*
|
|
184
|
+
* A scope is either a source element's **id, verbatim** — every carried flow
|
|
185
|
+
* node, every lane, every carried root element — or one of the `@` keys below,
|
|
186
|
+
* for the parts of the document that have no id worth naming or whose identity
|
|
187
|
+
* is their relation to this element. `@` is not an XML NameStartChar, so no id
|
|
188
|
+
* in a conformant file can ever collide with one.
|
|
189
|
+
*
|
|
190
|
+
* The rule for a fragment is always the same: **the scope is the element it was
|
|
191
|
+
* a child of**. For an attribute it is the element that carried the attribute;
|
|
192
|
+
* for a `di` fragment, what that fragment draws.
|
|
193
|
+
*/
|
|
194
|
+
export declare const BPMN_SCOPE: {
|
|
195
|
+
/** The element this payload rides on: the participant, the flow node, the flow. */
|
|
196
|
+
readonly self: "@self";
|
|
197
|
+
/** Its `BPMNShape` or `BPMNEdge`. */
|
|
198
|
+
readonly shape: "@shape";
|
|
199
|
+
/** The `process` behind a participant — the pool's other half. */
|
|
200
|
+
readonly process: "@process";
|
|
201
|
+
/** The pool's `laneSet`. */
|
|
202
|
+
readonly laneSet: "@laneSet";
|
|
203
|
+
/** The `collaboration`, whose residue rides on the first pool (D6). */
|
|
204
|
+
readonly collaboration: "@collaboration";
|
|
205
|
+
/** `definitions` itself: its foreign attributes, its declarations, its roots. */
|
|
206
|
+
readonly definitions: "@definitions";
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* The board to serialize — everything on the surface, split by what it is.
|
|
210
|
+
*
|
|
211
|
+
* The whole board and not a selection: a BPMN document is a process, and half a
|
|
212
|
+
* process is not a smaller process. The pool whose toolbar launched the export
|
|
213
|
+
* decides the FILENAME and nothing else.
|
|
214
|
+
*/
|
|
215
|
+
export interface BpmnExportBoard {
|
|
216
|
+
/** In document order — which is the tie-break `bpmnPoolOf` breaks on. */
|
|
217
|
+
pools: readonly BpmnPoolElementModel[];
|
|
218
|
+
nodes: readonly BpmnNodeElementModel[];
|
|
219
|
+
connectors: readonly ConnectorElementModel[];
|
|
220
|
+
}
|
|
221
|
+
export interface BpmnExportOptions {
|
|
222
|
+
/** Names the `collaboration` / lone `process` and the `BPMNDiagram`. */
|
|
223
|
+
name?: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The document, plus what writing it could not say.
|
|
227
|
+
*
|
|
228
|
+
* Three things the board can hold have no honest place in a `.bpmn` file, and
|
|
229
|
+
* until now each of them was documented in a code comment and silent to the
|
|
230
|
+
* person who clicked Export. A warning is one line, in the user's words, and it
|
|
231
|
+
* names the fix rather than the mechanism. Nothing here is an error: the file
|
|
232
|
+
* is valid and the export succeeded — these are the sentences the format
|
|
233
|
+
* refused to carry.
|
|
234
|
+
*/
|
|
235
|
+
export interface BpmnExportOutcome {
|
|
236
|
+
text: string;
|
|
237
|
+
/** Empty when the board came out whole, which is the usual case. */
|
|
238
|
+
warnings: string[];
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Serialize a board as a BPMN 2.0 XML interchange document.
|
|
242
|
+
*
|
|
243
|
+
* ## The shape of the document, and what decides it
|
|
244
|
+
*
|
|
245
|
+
* One `definitions`, always. Then:
|
|
246
|
+
*
|
|
247
|
+
* - **at least one pool** — a `collaboration` holding one `participant` per
|
|
248
|
+
* pool, one `process` per pool, and the message flows (which are the
|
|
249
|
+
* collaboration's, never a process's). Things drawn OUTSIDE every pool split
|
|
250
|
+
* in two: ARTIFACTS (annotation, group, and the associations that tie them to
|
|
251
|
+
* anything) become children of the collaboration itself, where
|
|
252
|
+
* `tCollaboration` allows them and where bpmn-js draws them; FLOW OBJECTS get
|
|
253
|
+
* ONE extra participant-less process, and only if there are any. See
|
|
254
|
+
* {@link COLLABORATION} for what the live recette found out about the
|
|
255
|
+
* difference, and the note on the orphan process for what it still cannot fix;
|
|
256
|
+
* - **no pool at all** — a single `process` and no collaboration, which is what
|
|
257
|
+
* a process drawn without swimlanes IS. The `BPMNPlane` then points at that
|
|
258
|
+
* process; with a collaboration it must point at the collaboration, or most
|
|
259
|
+
* tools draw the flow and none of the pools (spec §12.3.2).
|
|
260
|
+
*
|
|
261
|
+
* Attribution is {@link bpmnPoolOf} and {@link bpmnLaneOf} — the CENTRE against
|
|
262
|
+
* the pool's PLOT, containment only, no nearest-pool fallback. Deliberately the
|
|
263
|
+
* same arithmetic the audit and the validation rules read, so a task the audit
|
|
264
|
+
* reports in "Back office" is in the `lane` named "Back office" here.
|
|
265
|
+
*/
|
|
266
|
+
export declare function exportBpmnXml(board: BpmnExportBoard, options?: BpmnExportOptions): string;
|
|
267
|
+
/**
|
|
268
|
+
* The same serialization, with the loss channel attached — see
|
|
269
|
+
* {@link BpmnExportOutcome}.
|
|
270
|
+
*
|
|
271
|
+
* {@link exportBpmnXml} is the thin wrapper over it, kept because a caller that
|
|
272
|
+
* only wants the bytes should not have to reach past a report to get them, and
|
|
273
|
+
* because #149's forty-six tests and the live integration spec pin that
|
|
274
|
+
* signature. The interchange capability calls THIS one.
|
|
275
|
+
*/
|
|
276
|
+
export declare function exportBpmnXmlWithWarnings(board: BpmnExportBoard, options?: BpmnExportOptions): BpmnExportOutcome;
|
|
277
|
+
export {};
|