@jylups/flowable-simple-view 0.0.0-stage → 0.1.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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +112 -2
- package/dist/bpmn.d.ts +6 -0
- package/dist/bpmn.js +4 -0
- package/dist/bpmn.js.map +1 -0
- package/dist/cmmn.d.ts +6 -0
- package/dist/cmmn.js +4 -0
- package/dist/cmmn.js.map +1 -0
- package/dist/core/layout.d.ts +48 -0
- package/dist/core/layout.js +164 -0
- package/dist/core/layout.js.map +1 -0
- package/dist/core/outline.d.ts +76 -0
- package/dist/core/outline.js +432 -0
- package/dist/core/outline.js.map +1 -0
- package/dist/core.d.ts +8 -0
- package/dist/core.js +7 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/render/case.d.ts +9 -0
- package/dist/render/case.js +73 -0
- package/dist/render/case.js.map +1 -0
- package/dist/render/common.d.ts +47 -0
- package/dist/render/common.js +109 -0
- package/dist/render/common.js.map +1 -0
- package/dist/render/process.d.ts +17 -0
- package/dist/render/process.js +88 -0
- package/dist/render/process.js.map +1 -0
- package/dist/simple-view.css +347 -0
- package/package.json +84 -4
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain-language outlines of Flowable models: who works each task, which
|
|
3
|
+
* screen it shows, what starts it and where the flow branches, read from the
|
|
4
|
+
* BPMN or CMMN XML.
|
|
5
|
+
*/
|
|
6
|
+
const FLOWABLE = 'http://flowable.org/bpmn';
|
|
7
|
+
const FLOWABLE_CMMN = 'http://flowable.org/cmmn';
|
|
8
|
+
/** The element's local name, without its prefix. */
|
|
9
|
+
function localName(element) {
|
|
10
|
+
return element.localName;
|
|
11
|
+
}
|
|
12
|
+
function childElements(element, ...names) {
|
|
13
|
+
return Array.from(element.children).filter((child) => !names.length || names.includes(localName(child)));
|
|
14
|
+
}
|
|
15
|
+
function parse(xml) {
|
|
16
|
+
const document = new DOMParser().parseFromString(xml, 'application/xml');
|
|
17
|
+
if (document.getElementsByTagName('parsererror').length) {
|
|
18
|
+
throw new Error('The model is not well-formed XML');
|
|
19
|
+
}
|
|
20
|
+
return document;
|
|
21
|
+
}
|
|
22
|
+
/** "orderReviewer" → "Order reviewer". */
|
|
23
|
+
export function humanize(identifier) {
|
|
24
|
+
const words = identifier
|
|
25
|
+
.replace(/[_-]+/g, ' ')
|
|
26
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
27
|
+
.trim()
|
|
28
|
+
.toLowerCase();
|
|
29
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
30
|
+
}
|
|
31
|
+
/** A name with its run-time values shown as [variable]: "Approve ${orderId}" → "Approve [orderId]". */
|
|
32
|
+
export function plainName(text) {
|
|
33
|
+
return (text || '')
|
|
34
|
+
.replace(/\$\{\s*([A-Za-z_][\w.]*)\s*\}/g, '[$1]')
|
|
35
|
+
.replace(/\$\{[^}]*\}/g, '[…]')
|
|
36
|
+
.replace(/\s+/g, ' ')
|
|
37
|
+
.trim();
|
|
38
|
+
}
|
|
39
|
+
/** An expression in plain words, shortened: ${vars:equals(decision, "REJECTED")} → decision is REJECTED. */
|
|
40
|
+
export function plainCondition(expression) {
|
|
41
|
+
let text = (expression || '')
|
|
42
|
+
.trim()
|
|
43
|
+
.replace(/^\$\{([\s\S]*)\}$/, '$1')
|
|
44
|
+
.trim();
|
|
45
|
+
text = text
|
|
46
|
+
.replace(/vars:(?:equals|eq)\(\s*'?(\w+)'?\s*,\s*["']([^"']*)["']\s*\)/g, '$1 is $2')
|
|
47
|
+
.replace(/vars:(?:notEquals|ne)\(\s*'?(\w+)'?\s*,\s*["']([^"']*)["']\s*\)/g, '$1 is not $2')
|
|
48
|
+
.replace(/!\s*vars:exists\(\s*'?(\w+)'?\s*\)/g, '$1 is not set')
|
|
49
|
+
.replace(/vars:exists\(\s*'?(\w+)'?\s*\)/g, '$1 is set')
|
|
50
|
+
.replace(/vars:isNotEmpty\(\s*'?(\w+)'?\s*\)/g, '$1 is not empty')
|
|
51
|
+
.replace(/vars:isEmpty\(\s*'?(\w+)'?\s*\)/g, '$1 is empty')
|
|
52
|
+
.replace(/\s*&&\s*/g, ' and ')
|
|
53
|
+
.replace(/\s*\|\|\s*/g, ' or ')
|
|
54
|
+
.replace(/\s*==\s*/g, ' is ')
|
|
55
|
+
.replace(/\s*!=\s*/g, ' is not ')
|
|
56
|
+
.replace(/ is not (?:''|"")/g, ' is not empty')
|
|
57
|
+
.replace(/ is (?:''|"")/g, ' is empty')
|
|
58
|
+
.replace(/ is not null\b/g, ' is set')
|
|
59
|
+
.replace(/ is null\b/g, ' is not set')
|
|
60
|
+
.replace(/\s+/g, ' ');
|
|
61
|
+
// the same check twice says it once: "x is not set or x is not set" → "x is not set"
|
|
62
|
+
text = [...new Set(text.split(' or ').map((part) => [...new Set(part.split(' and '))].join(' and ')))].join(' or ');
|
|
63
|
+
return text.length > 80 ? text.slice(0, 79) + '…' : text;
|
|
64
|
+
}
|
|
65
|
+
/** Who works a task, from its candidate groups and users and its assignee. */
|
|
66
|
+
export function personaOf(element, namespace) {
|
|
67
|
+
const parts = [];
|
|
68
|
+
const groups = element.getAttributeNS(namespace, 'candidateGroups');
|
|
69
|
+
const users = element.getAttributeNS(namespace, 'candidateUsers');
|
|
70
|
+
const assignee = element.getAttributeNS(namespace, 'assignee');
|
|
71
|
+
if (groups) {
|
|
72
|
+
parts.push(groups
|
|
73
|
+
.split(',')
|
|
74
|
+
.map((group) => plainName(group.trim()))
|
|
75
|
+
.join(' or '));
|
|
76
|
+
}
|
|
77
|
+
if (users) {
|
|
78
|
+
parts.push('Users ' +
|
|
79
|
+
users
|
|
80
|
+
.split(',')
|
|
81
|
+
.map((user) => plainName(user.trim()))
|
|
82
|
+
.join(', '));
|
|
83
|
+
}
|
|
84
|
+
if (assignee) {
|
|
85
|
+
parts.push(assigneeInWords(assignee));
|
|
86
|
+
}
|
|
87
|
+
return parts.length ? parts.join(' · ') : undefined;
|
|
88
|
+
}
|
|
89
|
+
function assigneeInWords(assignee) {
|
|
90
|
+
const variable = assignee.match(/^\$\{\s*([A-Za-z_]\w*)\s*\}$/);
|
|
91
|
+
if (variable) {
|
|
92
|
+
return variable[1] === 'initiator' ? 'The one who started it' : humanize(variable[1]);
|
|
93
|
+
}
|
|
94
|
+
if (/currentWorkflowUser|getCurrentUserId|authenticatedUserId/.test(assignee)) {
|
|
95
|
+
return 'The current user';
|
|
96
|
+
}
|
|
97
|
+
if (!assignee.includes('${')) {
|
|
98
|
+
return assignee;
|
|
99
|
+
}
|
|
100
|
+
return 'Assigned by a rule';
|
|
101
|
+
}
|
|
102
|
+
/** The form or page a task shows: a key starting with / is a page. */
|
|
103
|
+
export function screenOf(formKey) {
|
|
104
|
+
if (!formKey) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
if (formKey.includes('${')) {
|
|
108
|
+
return 'Form chosen at run time';
|
|
109
|
+
}
|
|
110
|
+
return formKey.startsWith('/') ? `Page ${formKey}` : `Form ${formKey}`;
|
|
111
|
+
}
|
|
112
|
+
// ---------------------------------------------------------------- processes
|
|
113
|
+
const TASK_KINDS = {
|
|
114
|
+
userTask: 'Task',
|
|
115
|
+
manualTask: 'Manual task',
|
|
116
|
+
task: 'Task',
|
|
117
|
+
serviceTask: 'Automatic step',
|
|
118
|
+
scriptTask: 'Script',
|
|
119
|
+
businessRuleTask: 'Decision',
|
|
120
|
+
sendTask: 'Sends a message',
|
|
121
|
+
receiveTask: 'Waits for a message',
|
|
122
|
+
callActivity: 'Runs process',
|
|
123
|
+
subProcess: 'Subprocess',
|
|
124
|
+
transaction: 'Subprocess'
|
|
125
|
+
};
|
|
126
|
+
const GATEWAY_KINDS = {
|
|
127
|
+
exclusiveGateway: 'One way',
|
|
128
|
+
inclusiveGateway: 'One or more ways',
|
|
129
|
+
parallelGateway: 'All ways',
|
|
130
|
+
eventBasedGateway: 'First event',
|
|
131
|
+
complexGateway: 'Rule'
|
|
132
|
+
};
|
|
133
|
+
const EVENT_KINDS = ['startEvent', 'endEvent', 'intermediateCatchEvent', 'intermediateThrowEvent', 'boundaryEvent'];
|
|
134
|
+
/** "timerEventDefinition" → "Timer". */
|
|
135
|
+
function eventTrigger(event) {
|
|
136
|
+
const definition = childElements(event).find((child) => localName(child).endsWith('EventDefinition'));
|
|
137
|
+
return definition ? humanize(localName(definition).replace('EventDefinition', '')) : undefined;
|
|
138
|
+
}
|
|
139
|
+
function eventLabel(event) {
|
|
140
|
+
const name = plainName(event.getAttribute('name'));
|
|
141
|
+
const trigger = eventTrigger(event);
|
|
142
|
+
const kind = localName(event);
|
|
143
|
+
if (name) {
|
|
144
|
+
return name;
|
|
145
|
+
}
|
|
146
|
+
if (kind === 'startEvent') {
|
|
147
|
+
return trigger ? `${trigger} starts it` : 'Start';
|
|
148
|
+
}
|
|
149
|
+
if (kind === 'endEvent') {
|
|
150
|
+
return trigger ? `End (${trigger.toLowerCase()})` : 'End';
|
|
151
|
+
}
|
|
152
|
+
return trigger || 'Event';
|
|
153
|
+
}
|
|
154
|
+
/** The outline of a BPMN process model: its flow, and each event subprocess on its own. */
|
|
155
|
+
export function processOutline(xml) {
|
|
156
|
+
const document = parse(xml);
|
|
157
|
+
const processes = Array.from(document.getElementsByTagNameNS('*', 'process'));
|
|
158
|
+
if (!processes.length) {
|
|
159
|
+
throw new Error('The model has no BPMN process');
|
|
160
|
+
}
|
|
161
|
+
const lanes = new Map();
|
|
162
|
+
Array.from(document.getElementsByTagNameNS('*', 'lane')).forEach((lane) => {
|
|
163
|
+
Array.from(lane.getElementsByTagNameNS('*', 'flowNodeRef')).forEach((ref) => lanes.set((ref.textContent || '').trim(), plainName(lane.getAttribute('name'))));
|
|
164
|
+
});
|
|
165
|
+
const sections = [];
|
|
166
|
+
const main = processes.find((process) => process.getAttribute('isExecutable') !== 'false') || processes[0];
|
|
167
|
+
processes.forEach((process) => {
|
|
168
|
+
const section = { title: processes.length > 1 ? plainName(process.getAttribute('name')) || undefined : undefined, nodes: [], edges: [] };
|
|
169
|
+
const eventSubprocesses = [];
|
|
170
|
+
collectFlow(process, section, lanes, eventSubprocesses, '');
|
|
171
|
+
sections.push(collapsePassThrough(section));
|
|
172
|
+
eventSubprocesses.forEach((subprocess) => {
|
|
173
|
+
const start = childElements(subprocess, 'startEvent')[0];
|
|
174
|
+
const when = start ? eventLabel(start) : 'an event';
|
|
175
|
+
const subSection = { title: `${plainName(subprocess.getAttribute('name')) || 'Event subprocess'} (starts on: ${when})`, nodes: [], edges: [] };
|
|
176
|
+
collectFlow(subprocess, subSection, lanes, [], '');
|
|
177
|
+
sections.push(collapsePassThrough(subSection));
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
return { name: plainName(main.getAttribute('name')) || main.getAttribute('id') || 'Process', sections };
|
|
181
|
+
}
|
|
182
|
+
/** Pass-through nodes: the start and end of an embedded subprocess, replaced by the arrows through them. */
|
|
183
|
+
const PASS_THROUGH = 'passThrough';
|
|
184
|
+
function collectFlow(container, section, lanes, eventSubprocesses, within) {
|
|
185
|
+
const embedded = [];
|
|
186
|
+
childElements(container).forEach((element) => {
|
|
187
|
+
const kind = localName(element);
|
|
188
|
+
const id = element.getAttribute('id') || '';
|
|
189
|
+
if (kind === 'subProcess' && element.getAttribute('triggeredByEvent') === 'true') {
|
|
190
|
+
eventSubprocesses.push(element);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (kind === 'subProcess' || kind === 'transaction') {
|
|
194
|
+
embedded.push(element);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (TASK_KINDS[kind]) {
|
|
198
|
+
const lane = lanes.get(id);
|
|
199
|
+
const persona = personaOf(element, FLOWABLE);
|
|
200
|
+
const called = element.getAttribute('calledElement');
|
|
201
|
+
section.nodes.push({
|
|
202
|
+
id,
|
|
203
|
+
kind,
|
|
204
|
+
kindLabel: TASK_KINDS[kind],
|
|
205
|
+
shape: 'task',
|
|
206
|
+
name: plainName(element.getAttribute('name')) || id,
|
|
207
|
+
persona: lane || persona,
|
|
208
|
+
personaDetail: lane && persona && persona !== lane ? persona : undefined,
|
|
209
|
+
screen: screenOf(element.getAttributeNS(FLOWABLE, 'formKey')),
|
|
210
|
+
detail: [called ? `Runs process ${called}` : '', within ? `In ${within}` : ''].filter(Boolean).join(' · ') || undefined
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else if (GATEWAY_KINDS[kind]) {
|
|
214
|
+
section.nodes.push({ id, kind, kindLabel: GATEWAY_KINDS[kind], shape: 'gateway', name: plainName(element.getAttribute('name')) });
|
|
215
|
+
}
|
|
216
|
+
else if (EVENT_KINDS.includes(kind)) {
|
|
217
|
+
section.nodes.push({ id, kind, kindLabel: kind === 'boundaryEvent' ? 'If' : 'Event', shape: 'event', name: eventLabel(element) });
|
|
218
|
+
if (kind === 'boundaryEvent') {
|
|
219
|
+
const host = element.getAttribute('attachedToRef') || '';
|
|
220
|
+
const trigger = (eventTrigger(element) || 'event').toLowerCase();
|
|
221
|
+
section.edges.push({ id: `${id}-attached`, from: host, to: id, label: element.getAttribute('cancelActivity') === 'false' ? `${trigger}, meanwhile` : trigger });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else if (kind === 'sequenceFlow') {
|
|
225
|
+
section.edges.push({ id, from: element.getAttribute('sourceRef') || '', to: element.getAttribute('targetRef') || '', label: flowLabel(element, container) });
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
// an embedded subprocess shows its steps in the flow: arrows into it go to its start, arrows out of it leave from its end
|
|
229
|
+
embedded.forEach((subprocess) => {
|
|
230
|
+
const id = subprocess.getAttribute('id') || '';
|
|
231
|
+
const name = plainName(subprocess.getAttribute('name')) || id;
|
|
232
|
+
const before = section.nodes.length;
|
|
233
|
+
collectFlow(subprocess, section, lanes, eventSubprocesses, name);
|
|
234
|
+
const inner = section.nodes.slice(before);
|
|
235
|
+
const starts = inner.filter((node) => node.kind === 'startEvent');
|
|
236
|
+
const ends = inner.filter((node) => node.kind === 'endEvent');
|
|
237
|
+
starts.concat(ends).forEach((node) => (node.kind = PASS_THROUGH));
|
|
238
|
+
section.nodes.push({ id, kind: PASS_THROUGH, kindLabel: '', shape: 'event', name });
|
|
239
|
+
starts.forEach((start) => section.edges.push({ id: `${id}-in-${start.id}`, from: id, to: start.id }));
|
|
240
|
+
ends.forEach((end) => section.edges.push({ id: `${id}-out-${end.id}`, from: end.id, to: `${id}#out` }));
|
|
241
|
+
section.nodes.push({ id: `${id}#out`, kind: PASS_THROUGH, kindLabel: '', shape: 'event', name });
|
|
242
|
+
section.edges.filter((edge) => edge.from === id && !edge.id.startsWith(`${id}-in-`)).forEach((edge) => (edge.from = `${id}#out`));
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function flowLabel(flow, container) {
|
|
246
|
+
const name = plainName(flow.getAttribute('name'));
|
|
247
|
+
if (name) {
|
|
248
|
+
return name;
|
|
249
|
+
}
|
|
250
|
+
const id = flow.getAttribute('id');
|
|
251
|
+
const source = childElements(container).find((element) => element.getAttribute('id') === flow.getAttribute('sourceRef'));
|
|
252
|
+
if (source && source.getAttribute('default') === id) {
|
|
253
|
+
return 'Otherwise';
|
|
254
|
+
}
|
|
255
|
+
const condition = childElements(flow, 'conditionExpression')[0];
|
|
256
|
+
return condition ? plainCondition(condition.textContent) : undefined;
|
|
257
|
+
}
|
|
258
|
+
/** Replaces each pass-through node by arrows from its sources straight to its targets. */
|
|
259
|
+
function collapsePassThrough(section) {
|
|
260
|
+
let nodes = section.nodes;
|
|
261
|
+
let edges = section.edges;
|
|
262
|
+
nodes
|
|
263
|
+
.filter((node) => node.kind === PASS_THROUGH)
|
|
264
|
+
.forEach((node) => {
|
|
265
|
+
const incoming = edges.filter((edge) => edge.to === node.id);
|
|
266
|
+
const outgoing = edges.filter((edge) => edge.from === node.id);
|
|
267
|
+
const rest = edges.filter((edge) => edge.to !== node.id && edge.from !== node.id);
|
|
268
|
+
const through = incoming.flatMap((into) => outgoing.map((out) => ({ id: `${into.id}>${out.id}`, from: into.from, to: out.to, label: into.label || out.label })));
|
|
269
|
+
edges = rest.concat(through);
|
|
270
|
+
nodes = nodes.filter((other) => other !== node);
|
|
271
|
+
});
|
|
272
|
+
const ids = new Set(nodes.map((node) => node.id));
|
|
273
|
+
return { title: section.title, nodes, edges: edges.filter((edge) => ids.has(edge.from) && ids.has(edge.to)) };
|
|
274
|
+
}
|
|
275
|
+
// ---------------------------------------------------------------- case plans
|
|
276
|
+
const ITEM_KINDS = {
|
|
277
|
+
humanTask: 'Task',
|
|
278
|
+
task: 'Task',
|
|
279
|
+
processTask: 'Runs process',
|
|
280
|
+
caseTask: 'Runs case',
|
|
281
|
+
decisionTask: 'Decision',
|
|
282
|
+
serviceTask: 'Automatic step',
|
|
283
|
+
milestone: 'Milestone',
|
|
284
|
+
stage: 'Stage',
|
|
285
|
+
planFragment: 'Group',
|
|
286
|
+
timerEventListener: 'Timer',
|
|
287
|
+
userEventListener: 'User action',
|
|
288
|
+
genericEventListener: 'Event',
|
|
289
|
+
signalEventListener: 'Signal',
|
|
290
|
+
variableEventListener: 'Variable change',
|
|
291
|
+
eventListener: 'Event'
|
|
292
|
+
};
|
|
293
|
+
const EVENT_LISTENERS = ['timerEventListener', 'userEventListener', 'genericEventListener', 'signalEventListener', 'variableEventListener', 'eventListener'];
|
|
294
|
+
/** "complete" → "completes", in the voice of the source's kind. */
|
|
295
|
+
function eventInWords(event, sourceKind) {
|
|
296
|
+
if (event === 'occur') {
|
|
297
|
+
return sourceKind === 'milestone' ? 'is reached' : 'happens';
|
|
298
|
+
}
|
|
299
|
+
const words = {
|
|
300
|
+
complete: 'completes',
|
|
301
|
+
start: 'starts',
|
|
302
|
+
exit: 'exits',
|
|
303
|
+
terminate: 'is ended',
|
|
304
|
+
create: 'is created',
|
|
305
|
+
enable: 'becomes available',
|
|
306
|
+
disable: 'is disabled',
|
|
307
|
+
manualStart: 'is started by a user',
|
|
308
|
+
fault: 'fails',
|
|
309
|
+
suspend: 'is suspended',
|
|
310
|
+
resume: 'resumes',
|
|
311
|
+
reactivate: 'is reactivated',
|
|
312
|
+
parentSuspend: 'has its stage suspended',
|
|
313
|
+
parentResume: 'has its stage resumed'
|
|
314
|
+
};
|
|
315
|
+
return words[event] || event;
|
|
316
|
+
}
|
|
317
|
+
/** The outline of a CMMN case plan: its stages, and in each the items in the order their sentries start them. */
|
|
318
|
+
export function caseOutline(xml) {
|
|
319
|
+
const document = parse(xml);
|
|
320
|
+
const plan = document.getElementsByTagNameNS('*', 'casePlanModel')[0];
|
|
321
|
+
if (!plan) {
|
|
322
|
+
throw new Error('The model has no CMMN case plan');
|
|
323
|
+
}
|
|
324
|
+
const definitions = new Map();
|
|
325
|
+
Array.from(document.getElementsByTagNameNS('*', '*')).forEach((element) => {
|
|
326
|
+
if (ITEM_KINDS[localName(element)] && element.getAttribute('id')) {
|
|
327
|
+
definitions.set(element.getAttribute('id'), element);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
// every plan item, for the names and kinds the sentries refer to
|
|
331
|
+
const planItems = new Map();
|
|
332
|
+
Array.from(document.getElementsByTagNameNS('*', 'planItem')).forEach((planItem) => {
|
|
333
|
+
const definition = definitions.get(planItem.getAttribute('definitionRef') || '');
|
|
334
|
+
planItems.set(planItem.getAttribute('id') || '', {
|
|
335
|
+
name: plainName(planItem.getAttribute('name')) || plainName(definition?.getAttribute('name')) || planItem.getAttribute('id') || '',
|
|
336
|
+
kind: definition ? localName(definition) : ''
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
const name = plainName(plan.getAttribute('name')) || 'Case plan';
|
|
340
|
+
const root = { id: plan.getAttribute('id') || 'casePlanModel', kind: 'stage', kindLabel: 'Case', name, startsWhen: ['When the case starts'], repeats: false, manual: false, required: false };
|
|
341
|
+
fillStage(root, plan, definitions, planItems, true);
|
|
342
|
+
return { name, plan: root };
|
|
343
|
+
}
|
|
344
|
+
function fillStage(stage, element, definitions, planItems, isPlan) {
|
|
345
|
+
const sentries = new Map(childElements(element, 'sentry').map((sentry) => [sentry.getAttribute('id') || '', sentry]));
|
|
346
|
+
const items = [];
|
|
347
|
+
const sources = new Map();
|
|
348
|
+
childElements(element, 'planItem').forEach((planItem) => {
|
|
349
|
+
const definition = definitions.get(planItem.getAttribute('definitionRef') || '');
|
|
350
|
+
if (!definition) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const kind = localName(definition);
|
|
354
|
+
const control = [childElements(planItem, 'itemControl')[0], childElements(definition, 'defaultControl')[0]].filter(Boolean);
|
|
355
|
+
const hasRule = (rule) => control.some((item) => childElements(item, rule).length > 0);
|
|
356
|
+
const entry = childElements(planItem, 'entryCriterion')
|
|
357
|
+
.map((criterion) => sentries.get(criterion.getAttribute('sentryRef') || ''))
|
|
358
|
+
.filter(Boolean);
|
|
359
|
+
const processRef = definition.getAttribute('processRef') || childElements(definition, 'processRefExpression')[0]?.textContent?.trim();
|
|
360
|
+
const caseRef = definition.getAttribute('caseRef') || childElements(definition, 'caseRefExpression')[0]?.textContent?.trim();
|
|
361
|
+
const decisionRef = definition.getAttribute('decisionRef') || childElements(definition, 'decisionRefExpression')[0]?.textContent?.trim();
|
|
362
|
+
const item = {
|
|
363
|
+
id: planItem.getAttribute('id') || '',
|
|
364
|
+
kind,
|
|
365
|
+
kindLabel: ITEM_KINDS[kind] || humanize(kind),
|
|
366
|
+
name: planItems.get(planItem.getAttribute('id') || '')?.name || kind,
|
|
367
|
+
persona: kind === 'humanTask' ? personaOf(definition, FLOWABLE_CMMN) : undefined,
|
|
368
|
+
screen: kind === 'humanTask' ? screenOf(definition.getAttributeNS(FLOWABLE_CMMN, 'formKey')) : undefined,
|
|
369
|
+
detail: processRef ? `Runs process ${processRef}` : caseRef ? `Runs case ${caseRef}` : decisionRef ? `Decision ${decisionRef}` : undefined,
|
|
370
|
+
startsWhen: entry.length ? entry.map((sentry) => sentryInWords(sentry, planItems)) : [EVENT_LISTENERS.includes(kind) ? 'When it happens' : isPlan ? 'When the case starts' : 'When its stage starts'],
|
|
371
|
+
repeats: hasRule('repetitionRule'),
|
|
372
|
+
manual: hasRule('manualActivationRule'),
|
|
373
|
+
required: hasRule('requiredRule')
|
|
374
|
+
};
|
|
375
|
+
sources.set(item, entry.flatMap((sentry) => childElements(sentry, 'planItemOnPart').map((part) => part.getAttribute('sourceRef') || '')));
|
|
376
|
+
if (kind === 'stage') {
|
|
377
|
+
fillStage(item, definition, definitions, planItems, false);
|
|
378
|
+
}
|
|
379
|
+
items.push(item);
|
|
380
|
+
});
|
|
381
|
+
stage.events = items.filter((item) => EVENT_LISTENERS.includes(item.kind));
|
|
382
|
+
stage.rows = rowsBySentries(items.filter((item) => !EVENT_LISTENERS.includes(item.kind)), sources);
|
|
383
|
+
}
|
|
384
|
+
function sentryInWords(sentry, planItems) {
|
|
385
|
+
const parts = childElements(sentry).flatMap((part) => {
|
|
386
|
+
if (localName(part) === 'planItemOnPart') {
|
|
387
|
+
const source = planItems.get(part.getAttribute('sourceRef') || '');
|
|
388
|
+
const event = (childElements(part, 'standardEvent')[0]?.textContent || 'complete').trim();
|
|
389
|
+
return [`after ${source?.name || part.getAttribute('sourceRef')} ${eventInWords(event, source?.kind || '')}`];
|
|
390
|
+
}
|
|
391
|
+
if (localName(part) === 'caseFileItemOnPart') {
|
|
392
|
+
return [`when ${part.getAttribute('sourceRef')} changes`];
|
|
393
|
+
}
|
|
394
|
+
if (localName(part) === 'ifPart') {
|
|
395
|
+
return [`if ${plainCondition(childElements(part, 'condition')[0]?.textContent)}`];
|
|
396
|
+
}
|
|
397
|
+
return [];
|
|
398
|
+
});
|
|
399
|
+
const text = parts.join(' and ') || 'when its condition is met';
|
|
400
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The items of a stage in rows: an item goes in the row after the latest of
|
|
404
|
+
* the items in this stage that start it; the rest keep the model's order.
|
|
405
|
+
*/
|
|
406
|
+
function rowsBySentries(items, sources) {
|
|
407
|
+
const byId = new Map(items.map((item) => [item.id, item]));
|
|
408
|
+
const rowOf = new Map();
|
|
409
|
+
const visiting = new Set();
|
|
410
|
+
const row = (item) => {
|
|
411
|
+
if (rowOf.has(item)) {
|
|
412
|
+
return rowOf.get(item);
|
|
413
|
+
}
|
|
414
|
+
if (visiting.has(item)) {
|
|
415
|
+
return 0;
|
|
416
|
+
}
|
|
417
|
+
visiting.add(item);
|
|
418
|
+
const before = (sources.get(item) || []).map((id) => byId.get(id)).filter((source) => !!source && source !== item);
|
|
419
|
+
const value = before.length ? Math.max(...before.map((source) => row(source) + 1)) : 0;
|
|
420
|
+
visiting.delete(item);
|
|
421
|
+
rowOf.set(item, value);
|
|
422
|
+
return value;
|
|
423
|
+
};
|
|
424
|
+
const rows = [];
|
|
425
|
+
items.forEach((item) => {
|
|
426
|
+
const index = row(item);
|
|
427
|
+
(rows[index] = rows[index] || []).push(item);
|
|
428
|
+
});
|
|
429
|
+
// in a row, the boxes come before the stages (a stage takes the whole width)
|
|
430
|
+
return rows.filter(Boolean).map((items) => [...items.filter((item) => item.kind !== 'stage'), ...items.filter((item) => item.kind === 'stage')]);
|
|
431
|
+
}
|
|
432
|
+
//# sourceMappingURL=outline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outline.js","sourceRoot":"","sources":["../../src/core/outline.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAC5C,MAAM,aAAa,GAAG,0BAA0B,CAAC;AAkEjD,oDAAoD;AACpD,SAAS,SAAS,CAAC,OAAgB;IAC/B,OAAO,OAAO,CAAC,SAAS,CAAC;AAC7B,CAAC;AAED,SAAS,aAAa,CAAC,OAAgB,EAAE,GAAG,KAAe;IACvD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ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AC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AACrJ,CAAC","sourcesContent":["/**\n * Plain-language outlines of Flowable models: who works each task, which\n * screen it shows, what starts it and where the flow branches, read from the\n * BPMN or CMMN XML.\n */\n\nconst FLOWABLE = 'http://flowable.org/bpmn';\nconst FLOWABLE_CMMN = 'http://flowable.org/cmmn';\n\n/** A box of an outline: a task, step, event or stage. */\nexport interface OutlineBox {\n id: string;\n /** The element type, for example userTask or humanTask. */\n kind: string;\n /** The kind in plain words, for example Task, Automatic step or Runs process. */\n kindLabel: string;\n /** The name, with run-time values shown as [variable]. */\n name: string;\n /** Who works it, in plain words. */\n persona?: string;\n /** More about who works it, when the persona comes from a lane. */\n personaDetail?: string;\n /** The form or page it shows. */\n screen?: string;\n /** Another line, for example the process it runs. */\n detail?: string;\n}\n\n/** A node of a process flow. */\nexport interface FlowNode extends OutlineBox {\n shape: 'task' | 'gateway' | 'event';\n}\n\n/** An arrow of a process flow, with the branch in plain words. */\nexport interface FlowEdge {\n id: string;\n from: string;\n to: string;\n label?: string;\n}\n\n/** A connected part of a process: the main flow, or an event subprocess. */\nexport interface FlowSection {\n title?: string;\n nodes: FlowNode[];\n edges: FlowEdge[];\n}\n\nexport interface ProcessOutline {\n name: string;\n sections: FlowSection[];\n}\n\n/** A plan item of a case plan. */\nexport interface CaseItem extends OutlineBox {\n /** What starts it, one line per entry criterion. */\n startsWhen: string[];\n repeats: boolean;\n /** A user starts it (manual activation). */\n manual: boolean;\n required: boolean;\n /** The items of a stage, in rows: each row starts after items of earlier rows. */\n rows?: CaseItem[][];\n /** The event listeners of a stage. */\n events?: CaseItem[];\n}\n\nexport interface CaseOutline {\n name: string;\n /** The case plan itself, as a stage. */\n plan: CaseItem;\n}\n\n/** The element's local name, without its prefix. */\nfunction localName(element: Element): string {\n return element.localName;\n}\n\nfunction childElements(element: Element, ...names: string[]): Element[] {\n return Array.from(element.children).filter((child) => !names.length || names.includes(localName(child)));\n}\n\nfunction parse(xml: string): Document {\n const document = new DOMParser().parseFromString(xml, 'application/xml');\n\n if (document.getElementsByTagName('parsererror').length) {\n throw new Error('The model is not well-formed XML');\n }\n\n return document;\n}\n\n/** \"orderReviewer\" → \"Order reviewer\". */\nexport function humanize(identifier: string): string {\n const words = identifier\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim()\n .toLowerCase();\n\n return words.charAt(0).toUpperCase() + words.slice(1);\n}\n\n/** A name with its run-time values shown as [variable]: \"Approve ${orderId}\" → \"Approve [orderId]\". */\nexport function plainName(text: string | null | undefined): string {\n return (text || '')\n .replace(/\\$\\{\\s*([A-Za-z_][\\w.]*)\\s*\\}/g, '[$1]')\n .replace(/\\$\\{[^}]*\\}/g, '[…]')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** An expression in plain words, shortened: ${vars:equals(decision, \"REJECTED\")} → decision is REJECTED. */\nexport function plainCondition(expression: string | null | undefined): string {\n let text = (expression || '')\n .trim()\n .replace(/^\\$\\{([\\s\\S]*)\\}$/, '$1')\n .trim();\n\n text = text\n .replace(/vars:(?:equals|eq)\\(\\s*'?(\\w+)'?\\s*,\\s*[\"']([^\"']*)[\"']\\s*\\)/g, '$1 is $2')\n .replace(/vars:(?:notEquals|ne)\\(\\s*'?(\\w+)'?\\s*,\\s*[\"']([^\"']*)[\"']\\s*\\)/g, '$1 is not $2')\n .replace(/!\\s*vars:exists\\(\\s*'?(\\w+)'?\\s*\\)/g, '$1 is not set')\n .replace(/vars:exists\\(\\s*'?(\\w+)'?\\s*\\)/g, '$1 is set')\n .replace(/vars:isNotEmpty\\(\\s*'?(\\w+)'?\\s*\\)/g, '$1 is not empty')\n .replace(/vars:isEmpty\\(\\s*'?(\\w+)'?\\s*\\)/g, '$1 is empty')\n .replace(/\\s*&&\\s*/g, ' and ')\n .replace(/\\s*\\|\\|\\s*/g, ' or ')\n .replace(/\\s*==\\s*/g, ' is ')\n .replace(/\\s*!=\\s*/g, ' is not ')\n .replace(/ is not (?:''|\"\")/g, ' is not empty')\n .replace(/ is (?:''|\"\")/g, ' is empty')\n .replace(/ is not null\\b/g, ' is set')\n .replace(/ is null\\b/g, ' is not set')\n .replace(/\\s+/g, ' ');\n\n // the same check twice says it once: \"x is not set or x is not set\" → \"x is not set\"\n text = [...new Set(text.split(' or ').map((part) => [...new Set(part.split(' and '))].join(' and ')))].join(' or ');\n\n return text.length > 80 ? text.slice(0, 79) + '…' : text;\n}\n\n/** Who works a task, from its candidate groups and users and its assignee. */\nexport function personaOf(element: Element, namespace: string): string | undefined {\n const parts: string[] = [];\n const groups = element.getAttributeNS(namespace, 'candidateGroups');\n const users = element.getAttributeNS(namespace, 'candidateUsers');\n const assignee = element.getAttributeNS(namespace, 'assignee');\n\n if (groups) {\n parts.push(\n groups\n .split(',')\n .map((group) => plainName(group.trim()))\n .join(' or ')\n );\n }\n\n if (users) {\n parts.push(\n 'Users ' +\n users\n .split(',')\n .map((user) => plainName(user.trim()))\n .join(', ')\n );\n }\n\n if (assignee) {\n parts.push(assigneeInWords(assignee));\n }\n\n return parts.length ? parts.join(' · ') : undefined;\n}\n\nfunction assigneeInWords(assignee: string): string {\n const variable = assignee.match(/^\\$\\{\\s*([A-Za-z_]\\w*)\\s*\\}$/);\n\n if (variable) {\n return variable[1] === 'initiator' ? 'The one who started it' : humanize(variable[1]);\n }\n\n if (/currentWorkflowUser|getCurrentUserId|authenticatedUserId/.test(assignee)) {\n return 'The current user';\n }\n\n if (!assignee.includes('${')) {\n return assignee;\n }\n\n return 'Assigned by a rule';\n}\n\n/** The form or page a task shows: a key starting with / is a page. */\nexport function screenOf(formKey: string | null | undefined): string | undefined {\n if (!formKey) {\n return undefined;\n }\n\n if (formKey.includes('${')) {\n return 'Form chosen at run time';\n }\n\n return formKey.startsWith('/') ? `Page ${formKey}` : `Form ${formKey}`;\n}\n\n// ---------------------------------------------------------------- processes\n\nconst TASK_KINDS: Record<string, string> = {\n userTask: 'Task',\n manualTask: 'Manual task',\n task: 'Task',\n serviceTask: 'Automatic step',\n scriptTask: 'Script',\n businessRuleTask: 'Decision',\n sendTask: 'Sends a message',\n receiveTask: 'Waits for a message',\n callActivity: 'Runs process',\n subProcess: 'Subprocess',\n transaction: 'Subprocess'\n};\n\nconst GATEWAY_KINDS: Record<string, string> = {\n exclusiveGateway: 'One way',\n inclusiveGateway: 'One or more ways',\n parallelGateway: 'All ways',\n eventBasedGateway: 'First event',\n complexGateway: 'Rule'\n};\n\nconst EVENT_KINDS = ['startEvent', 'endEvent', 'intermediateCatchEvent', 'intermediateThrowEvent', 'boundaryEvent'];\n\n/** \"timerEventDefinition\" → \"Timer\". */\nfunction eventTrigger(event: Element): string | undefined {\n const definition = childElements(event).find((child) => localName(child).endsWith('EventDefinition'));\n\n return definition ? humanize(localName(definition).replace('EventDefinition', '')) : undefined;\n}\n\nfunction eventLabel(event: Element): string {\n const name = plainName(event.getAttribute('name'));\n const trigger = eventTrigger(event);\n const kind = localName(event);\n\n if (name) {\n return name;\n }\n\n if (kind === 'startEvent') {\n return trigger ? `${trigger} starts it` : 'Start';\n }\n\n if (kind === 'endEvent') {\n return trigger ? `End (${trigger.toLowerCase()})` : 'End';\n }\n\n return trigger || 'Event';\n}\n\n/** The outline of a BPMN process model: its flow, and each event subprocess on its own. */\nexport function processOutline(xml: string): ProcessOutline {\n const document = parse(xml);\n const processes = Array.from(document.getElementsByTagNameNS('*', 'process'));\n\n if (!processes.length) {\n throw new Error('The model has no BPMN process');\n }\n\n const lanes = new Map<string, string>();\n\n Array.from(document.getElementsByTagNameNS('*', 'lane')).forEach((lane) => {\n Array.from(lane.getElementsByTagNameNS('*', 'flowNodeRef')).forEach((ref) => lanes.set((ref.textContent || '').trim(), plainName(lane.getAttribute('name'))));\n });\n\n const sections: FlowSection[] = [];\n const main = processes.find((process) => process.getAttribute('isExecutable') !== 'false') || processes[0];\n\n processes.forEach((process) => {\n const section: FlowSection = { title: processes.length > 1 ? plainName(process.getAttribute('name')) || undefined : undefined, nodes: [], edges: [] };\n const eventSubprocesses: Element[] = [];\n\n collectFlow(process, section, lanes, eventSubprocesses, '');\n sections.push(collapsePassThrough(section));\n\n eventSubprocesses.forEach((subprocess) => {\n const start = childElements(subprocess, 'startEvent')[0];\n const when = start ? eventLabel(start) : 'an event';\n const subSection: FlowSection = { title: `${plainName(subprocess.getAttribute('name')) || 'Event subprocess'} (starts on: ${when})`, nodes: [], edges: [] };\n\n collectFlow(subprocess, subSection, lanes, [], '');\n sections.push(collapsePassThrough(subSection));\n });\n });\n\n return { name: plainName(main.getAttribute('name')) || main.getAttribute('id') || 'Process', sections };\n}\n\n/** Pass-through nodes: the start and end of an embedded subprocess, replaced by the arrows through them. */\nconst PASS_THROUGH = 'passThrough';\n\nfunction collectFlow(container: Element, section: FlowSection, lanes: Map<string, string>, eventSubprocesses: Element[], within: string): void {\n const embedded: Element[] = [];\n\n childElements(container).forEach((element) => {\n const kind = localName(element);\n const id = element.getAttribute('id') || '';\n\n if (kind === 'subProcess' && element.getAttribute('triggeredByEvent') === 'true') {\n eventSubprocesses.push(element);\n return;\n }\n\n if (kind === 'subProcess' || kind === 'transaction') {\n embedded.push(element);\n return;\n }\n\n if (TASK_KINDS[kind]) {\n const lane = lanes.get(id);\n const persona = personaOf(element, FLOWABLE);\n const called = element.getAttribute('calledElement');\n\n section.nodes.push({\n id,\n kind,\n kindLabel: TASK_KINDS[kind],\n shape: 'task',\n name: plainName(element.getAttribute('name')) || id,\n persona: lane || persona,\n personaDetail: lane && persona && persona !== lane ? persona : undefined,\n screen: screenOf(element.getAttributeNS(FLOWABLE, 'formKey')),\n detail: [called ? `Runs process ${called}` : '', within ? `In ${within}` : ''].filter(Boolean).join(' · ') || undefined\n });\n } else if (GATEWAY_KINDS[kind]) {\n section.nodes.push({ id, kind, kindLabel: GATEWAY_KINDS[kind], shape: 'gateway', name: plainName(element.getAttribute('name')) });\n } else if (EVENT_KINDS.includes(kind)) {\n section.nodes.push({ id, kind, kindLabel: kind === 'boundaryEvent' ? 'If' : 'Event', shape: 'event', name: eventLabel(element) });\n\n if (kind === 'boundaryEvent') {\n const host = element.getAttribute('attachedToRef') || '';\n const trigger = (eventTrigger(element) || 'event').toLowerCase();\n\n section.edges.push({ id: `${id}-attached`, from: host, to: id, label: element.getAttribute('cancelActivity') === 'false' ? `${trigger}, meanwhile` : trigger });\n }\n } else if (kind === 'sequenceFlow') {\n section.edges.push({ id, from: element.getAttribute('sourceRef') || '', to: element.getAttribute('targetRef') || '', label: flowLabel(element, container) });\n }\n });\n\n // an embedded subprocess shows its steps in the flow: arrows into it go to its start, arrows out of it leave from its end\n embedded.forEach((subprocess) => {\n const id = subprocess.getAttribute('id') || '';\n const name = plainName(subprocess.getAttribute('name')) || id;\n const before = section.nodes.length;\n\n collectFlow(subprocess, section, lanes, eventSubprocesses, name);\n\n const inner = section.nodes.slice(before);\n const starts = inner.filter((node) => node.kind === 'startEvent');\n const ends = inner.filter((node) => node.kind === 'endEvent');\n\n starts.concat(ends).forEach((node) => (node.kind = PASS_THROUGH));\n section.nodes.push({ id, kind: PASS_THROUGH, kindLabel: '', shape: 'event', name });\n starts.forEach((start) => section.edges.push({ id: `${id}-in-${start.id}`, from: id, to: start.id }));\n ends.forEach((end) => section.edges.push({ id: `${id}-out-${end.id}`, from: end.id, to: `${id}#out` }));\n section.nodes.push({ id: `${id}#out`, kind: PASS_THROUGH, kindLabel: '', shape: 'event', name });\n section.edges.filter((edge) => edge.from === id && !edge.id.startsWith(`${id}-in-`)).forEach((edge) => (edge.from = `${id}#out`));\n });\n}\n\nfunction flowLabel(flow: Element, container: Element): string | undefined {\n const name = plainName(flow.getAttribute('name'));\n\n if (name) {\n return name;\n }\n\n const id = flow.getAttribute('id');\n const source = childElements(container).find((element) => element.getAttribute('id') === flow.getAttribute('sourceRef'));\n\n if (source && source.getAttribute('default') === id) {\n return 'Otherwise';\n }\n\n const condition = childElements(flow, 'conditionExpression')[0];\n\n return condition ? plainCondition(condition.textContent) : undefined;\n}\n\n/** Replaces each pass-through node by arrows from its sources straight to its targets. */\nfunction collapsePassThrough(section: FlowSection): FlowSection {\n let nodes = section.nodes;\n let edges = section.edges;\n\n nodes\n .filter((node) => node.kind === PASS_THROUGH)\n .forEach((node) => {\n const incoming = edges.filter((edge) => edge.to === node.id);\n const outgoing = edges.filter((edge) => edge.from === node.id);\n const rest = edges.filter((edge) => edge.to !== node.id && edge.from !== node.id);\n const through = incoming.flatMap((into) => outgoing.map((out) => ({ id: `${into.id}>${out.id}`, from: into.from, to: out.to, label: into.label || out.label })));\n\n edges = rest.concat(through);\n nodes = nodes.filter((other) => other !== node);\n });\n\n const ids = new Set(nodes.map((node) => node.id));\n\n return { title: section.title, nodes, edges: edges.filter((edge) => ids.has(edge.from) && ids.has(edge.to)) };\n}\n\n// ---------------------------------------------------------------- case plans\n\nconst ITEM_KINDS: Record<string, string> = {\n humanTask: 'Task',\n task: 'Task',\n processTask: 'Runs process',\n caseTask: 'Runs case',\n decisionTask: 'Decision',\n serviceTask: 'Automatic step',\n milestone: 'Milestone',\n stage: 'Stage',\n planFragment: 'Group',\n timerEventListener: 'Timer',\n userEventListener: 'User action',\n genericEventListener: 'Event',\n signalEventListener: 'Signal',\n variableEventListener: 'Variable change',\n eventListener: 'Event'\n};\n\nconst EVENT_LISTENERS = ['timerEventListener', 'userEventListener', 'genericEventListener', 'signalEventListener', 'variableEventListener', 'eventListener'];\n\n/** \"complete\" → \"completes\", in the voice of the source's kind. */\nfunction eventInWords(event: string, sourceKind: string): string {\n if (event === 'occur') {\n return sourceKind === 'milestone' ? 'is reached' : 'happens';\n }\n\n const words: Record<string, string> = {\n complete: 'completes',\n start: 'starts',\n exit: 'exits',\n terminate: 'is ended',\n create: 'is created',\n enable: 'becomes available',\n disable: 'is disabled',\n manualStart: 'is started by a user',\n fault: 'fails',\n suspend: 'is suspended',\n resume: 'resumes',\n reactivate: 'is reactivated',\n parentSuspend: 'has its stage suspended',\n parentResume: 'has its stage resumed'\n };\n\n return words[event] || event;\n}\n\n/** The outline of a CMMN case plan: its stages, and in each the items in the order their sentries start them. */\nexport function caseOutline(xml: string): CaseOutline {\n const document = parse(xml);\n const plan = document.getElementsByTagNameNS('*', 'casePlanModel')[0];\n\n if (!plan) {\n throw new Error('The model has no CMMN case plan');\n }\n\n const definitions = new Map<string, Element>();\n\n Array.from(document.getElementsByTagNameNS('*', '*')).forEach((element) => {\n if (ITEM_KINDS[localName(element)] && element.getAttribute('id')) {\n definitions.set(element.getAttribute('id')!, element);\n }\n });\n\n // every plan item, for the names and kinds the sentries refer to\n const planItems = new Map<string, { name: string; kind: string }>();\n\n Array.from(document.getElementsByTagNameNS('*', 'planItem')).forEach((planItem) => {\n const definition = definitions.get(planItem.getAttribute('definitionRef') || '');\n\n planItems.set(planItem.getAttribute('id') || '', {\n name: plainName(planItem.getAttribute('name')) || plainName(definition?.getAttribute('name')) || planItem.getAttribute('id') || '',\n kind: definition ? localName(definition) : ''\n });\n });\n\n const name = plainName(plan.getAttribute('name')) || 'Case plan';\n const root: CaseItem = { id: plan.getAttribute('id') || 'casePlanModel', kind: 'stage', kindLabel: 'Case', name, startsWhen: ['When the case starts'], repeats: false, manual: false, required: false };\n\n fillStage(root, plan, definitions, planItems, true);\n\n return { name, plan: root };\n}\n\nfunction fillStage(stage: CaseItem, element: Element, definitions: Map<string, Element>, planItems: Map<string, { name: string; kind: string }>, isPlan: boolean): void {\n const sentries = new Map(childElements(element, 'sentry').map((sentry) => [sentry.getAttribute('id') || '', sentry]));\n const items: CaseItem[] = [];\n const sources = new Map<CaseItem, string[]>();\n\n childElements(element, 'planItem').forEach((planItem) => {\n const definition = definitions.get(planItem.getAttribute('definitionRef') || '');\n\n if (!definition) {\n return;\n }\n\n const kind = localName(definition);\n const control = [childElements(planItem, 'itemControl')[0], childElements(definition, 'defaultControl')[0]].filter(Boolean) as Element[];\n const hasRule = (rule: string) => control.some((item) => childElements(item, rule).length > 0);\n const entry = childElements(planItem, 'entryCriterion')\n .map((criterion) => sentries.get(criterion.getAttribute('sentryRef') || ''))\n .filter(Boolean) as Element[];\n const processRef = definition.getAttribute('processRef') || childElements(definition, 'processRefExpression')[0]?.textContent?.trim();\n const caseRef = definition.getAttribute('caseRef') || childElements(definition, 'caseRefExpression')[0]?.textContent?.trim();\n const decisionRef = definition.getAttribute('decisionRef') || childElements(definition, 'decisionRefExpression')[0]?.textContent?.trim();\n\n const item: CaseItem = {\n id: planItem.getAttribute('id') || '',\n kind,\n kindLabel: ITEM_KINDS[kind] || humanize(kind),\n name: planItems.get(planItem.getAttribute('id') || '')?.name || kind,\n persona: kind === 'humanTask' ? personaOf(definition, FLOWABLE_CMMN) : undefined,\n screen: kind === 'humanTask' ? screenOf(definition.getAttributeNS(FLOWABLE_CMMN, 'formKey')) : undefined,\n detail: processRef ? `Runs process ${processRef}` : caseRef ? `Runs case ${caseRef}` : decisionRef ? `Decision ${decisionRef}` : undefined,\n startsWhen: entry.length ? entry.map((sentry) => sentryInWords(sentry, planItems)) : [EVENT_LISTENERS.includes(kind) ? 'When it happens' : isPlan ? 'When the case starts' : 'When its stage starts'],\n repeats: hasRule('repetitionRule'),\n manual: hasRule('manualActivationRule'),\n required: hasRule('requiredRule')\n };\n\n sources.set(\n item,\n entry.flatMap((sentry) => childElements(sentry, 'planItemOnPart').map((part) => part.getAttribute('sourceRef') || ''))\n );\n\n if (kind === 'stage') {\n fillStage(item, definition, definitions, planItems, false);\n }\n\n items.push(item);\n });\n\n stage.events = items.filter((item) => EVENT_LISTENERS.includes(item.kind));\n stage.rows = rowsBySentries(\n items.filter((item) => !EVENT_LISTENERS.includes(item.kind)),\n sources\n );\n}\n\nfunction sentryInWords(sentry: Element, planItems: Map<string, { name: string; kind: string }>): string {\n const parts = childElements(sentry).flatMap((part) => {\n if (localName(part) === 'planItemOnPart') {\n const source = planItems.get(part.getAttribute('sourceRef') || '');\n const event = (childElements(part, 'standardEvent')[0]?.textContent || 'complete').trim();\n\n return [`after ${source?.name || part.getAttribute('sourceRef')} ${eventInWords(event, source?.kind || '')}`];\n }\n\n if (localName(part) === 'caseFileItemOnPart') {\n return [`when ${part.getAttribute('sourceRef')} changes`];\n }\n\n if (localName(part) === 'ifPart') {\n return [`if ${plainCondition(childElements(part, 'condition')[0]?.textContent)}`];\n }\n\n return [];\n });\n const text = parts.join(' and ') || 'when its condition is met';\n\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n/**\n * The items of a stage in rows: an item goes in the row after the latest of\n * the items in this stage that start it; the rest keep the model's order.\n */\nfunction rowsBySentries(items: CaseItem[], sources: Map<CaseItem, string[]>): CaseItem[][] {\n const byId = new Map(items.map((item) => [item.id, item]));\n const rowOf = new Map<CaseItem, number>();\n const visiting = new Set<CaseItem>();\n\n const row = (item: CaseItem): number => {\n if (rowOf.has(item)) {\n return rowOf.get(item)!;\n }\n\n if (visiting.has(item)) {\n return 0;\n }\n\n visiting.add(item);\n const before = (sources.get(item) || []).map((id) => byId.get(id)).filter((source): source is CaseItem => !!source && source !== item);\n const value = before.length ? Math.max(...before.map((source) => row(source) + 1)) : 0;\n visiting.delete(item);\n rowOf.set(item, value);\n\n return value;\n };\n\n const rows: CaseItem[][] = [];\n\n items.forEach((item) => {\n const index = row(item);\n\n (rows[index] = rows[index] || []).push(item);\n });\n\n // in a row, the boxes come before the stages (a stage takes the whole width)\n return rows.filter(Boolean).map((items) => [...items.filter((item) => item.kind !== 'stage'), ...items.filter((item) => item.kind === 'stage')]);\n}\n"]}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts both views share: the plain-words helpers, the flow layout and
|
|
3
|
+
* the outline types.
|
|
4
|
+
*/
|
|
5
|
+
export { humanize, plainName, plainCondition, personaOf, screenOf } from './core/outline.js';
|
|
6
|
+
export type { OutlineBox, FlowNode, FlowEdge, FlowSection, ProcessOutline, CaseItem, CaseOutline } from './core/outline.js';
|
|
7
|
+
export { layoutFlow } from './core/layout.js';
|
|
8
|
+
export type { LayoutNodeInput, LayoutEdgeInput, PlacedNode, PlacedEdge, FlowLayout, FlowLayoutOptions } from './core/layout.js';
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts both views share: the plain-words helpers, the flow layout and
|
|
3
|
+
* the outline types.
|
|
4
|
+
*/
|
|
5
|
+
export { humanize, plainName, plainCondition, personaOf, screenOf } from './core/outline.js';
|
|
6
|
+
export { layoutFlow } from './core/layout.js';
|
|
7
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * The parts both views share: the plain-words helpers, the flow layout and\n * the outline types.\n */\n\nexport { humanize, plainName, plainCondition, personaOf, screenOf } from './core/outline.js';\nexport type { OutlineBox, FlowNode, FlowEdge, FlowSection, ProcessOutline, CaseItem, CaseOutline } from './core/outline.js';\nexport { layoutFlow } from './core/layout.js';\nexport type { LayoutNodeInput, LayoutEdgeInput, PlacedNode, PlacedEdge, FlowLayout, FlowLayoutOptions } from './core/layout.js';\n"]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jylups/flowable-simple-view: a plain-language box view of Flowable BPMN
|
|
3
|
+
* processes and CMMN case plans. Everything from the bpmn, cmmn and core
|
|
4
|
+
* entry points.
|
|
5
|
+
*/
|
|
6
|
+
export * from './core.js';
|
|
7
|
+
export * from './bpmn.js';
|
|
8
|
+
export * from './cmmn.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC","sourcesContent":["/**\n * @jylups/flowable-simple-view: a plain-language box view of Flowable BPMN\n * processes and CMMN case plans. Everything from the bpmn, cmmn and core\n * entry points.\n */\n\nexport * from './core.js';\nexport * from './bpmn.js';\nexport * from './cmmn.js';\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SimpleView, SimpleViewOptions } from './common.js';
|
|
2
|
+
export type CaseViewOptions = SimpleViewOptions;
|
|
3
|
+
/**
|
|
4
|
+
* Draws the Simple view of a CMMN case plan into an element: its stages as
|
|
5
|
+
* groups of plain boxes, in each the items in the order their sentries start
|
|
6
|
+
* them, each with what starts it in plain words, who works it and which
|
|
7
|
+
* screen it shows.
|
|
8
|
+
*/
|
|
9
|
+
export declare function renderCaseOutline(container: HTMLElement, xml: string, options?: CaseViewOptions): SimpleView;
|