@peter.prib/renderengine 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +215 -213
  2. package/REFERENCE.md +99 -7
  3. package/dist/renderengine-workspace.umd.js +13168 -11966
  4. package/dist/renderengine.umd.js +7439 -6472
  5. package/examples/data-model.html +324 -0
  6. package/package.json +70 -68
  7. package/src/charting/CheckboxTreeSelector.js +373 -304
  8. package/src/charting/DiagramEditor.js +3372 -3330
  9. package/src/charting/DiagramTypeRegistry.js +365 -326
  10. package/src/charting/Palette.js +119 -119
  11. package/src/charting/TemplateCatalog.js +61 -59
  12. package/src/charting/archimate/ArchimateCanvasEditor.js +825 -815
  13. package/src/charting/archimate/ArchimateElementTemplate.js +208 -195
  14. package/src/charting/datamodel/DataModel.js +299 -0
  15. package/src/charting/datamodel/DataModelContext.js +108 -0
  16. package/src/charting/datamodel/DataModelPerspective.js +84 -0
  17. package/src/charting/datamodel/LevelMapping.js +38 -0
  18. package/src/charting/datamodel/LevelSchema.js +41 -0
  19. package/src/charting/datamodel/index.js +5 -0
  20. package/src/charting/diagrams/DataModelDiagram.js +160 -86
  21. package/src/charting/diagrams/DataModelRelationshipStrategy.js +86 -38
  22. package/src/charting/diagrams/nesting.js +31 -0
  23. package/src/charting/modelTree/ModelTree.js +202 -164
  24. package/src/charting/modelTree/ModelTreePanel.js +36 -3
  25. package/src/charting/modelTree/TreeViewMode.js +131 -110
  26. package/src/charting/modelTree/modes/FlatTreeMode.js +32 -46
  27. package/src/charting/modelTree/modes/LayerGroupedTreeMode.js +47 -62
  28. package/src/charting/modelTree/modes/TypeGroupedTreeMode.js +46 -60
  29. package/src/datamodel.js +132 -122
  30. package/src/diagramCatalog.js +35 -30
  31. package/src/index.js +6 -1
  32. package/src/workspace/index.js +1 -0
  33. package/src/workspace/parts/ArchimateCanvasPart.js +5 -2
  34. package/src/workspace/parts/ChartPart.js +6 -1
  35. package/src/workspace/parts/DataModelPart.js +234 -0
@@ -1,326 +1,365 @@
1
- /**
2
- * DiagramTypeRegistry — palette categories: which shapes each kind of diagram offers.
3
- *
4
- * Each category is pure data: `{ name, group, description, templates }`, where a
5
- * template entry is `{ id, name, factory(id, x, y) }`. `group` drives the
6
- * grouped category picker. The 'generic' key is the fallback for unknown types.
7
- */
8
- import {
9
- RectangleTemplate, RoundedRectangleTemplate, StadiumTemplate, PredefinedProcessTemplate,
10
- ClassTemplate, ComponentTemplate, SwimlaneTemplate, CircleTemplate, FinalStateTemplate,
11
- EllipseTemplate, DiamondTemplate, TriangleTemplate, PentagonTemplate, HexagonTemplate,
12
- OctagonTemplate, StarTemplate, ParallelogramTemplate, TrapezoidTemplate, ManualInputTemplate,
13
- CylinderTemplate, DocumentTemplate, NoteTemplate, CloudTemplate, ActorTemplate,
14
- PackageTemplate, BoxTemplate, DataStoreTemplate, LifelineTemplate,
15
- } from './templates/index.js';
16
-
17
- const C = {
18
- blue: '#dbeafe', green: '#dcfce7', yellow: '#fef9c3', red: '#fee2e2', purple: '#ede9fe',
19
- orange: '#ffedd5', teal: '#ccfbf1', grey: '#f1f5f9', white: '#ffffff', dark: '#334155',
20
- };
21
-
22
- /** Palette entry whose instances are `TemplateClass` created with `options` and named `name`. */
23
- function shape(id, name, TemplateClass, options = {}) {
24
- return { id, name, factory: (instanceId, x, y) => new TemplateClass(instanceId, name, { ...options, x, y }) };
25
- }
26
-
27
- const note = shape('note', 'Note', NoteTemplate);
28
-
29
- export const DIAGRAM_TYPES = {
30
- 'generic': {
31
- name: 'Basic Shapes',
32
- group: 'General',
33
- description: 'General-purpose geometric shapes',
34
- templates: [
35
- shape('rectangle', 'Rectangle', RectangleTemplate, { fillColor: C.blue }),
36
- shape('rounded-rectangle', 'Rounded', RoundedRectangleTemplate, { fillColor: C.blue }),
37
- shape('circle', 'Circle', CircleTemplate, { fillColor: C.red }),
38
- shape('ellipse', 'Ellipse', EllipseTemplate, { fillColor: C.purple }),
39
- shape('diamond', 'Diamond', DiamondTemplate, { fillColor: C.yellow }),
40
- shape('triangle', 'Triangle', TriangleTemplate, { fillColor: C.green }),
41
- shape('pentagon', 'Pentagon', PentagonTemplate, { fillColor: C.teal }),
42
- shape('hexagon', 'Hexagon', HexagonTemplate, { fillColor: C.orange }),
43
- shape('octagon', 'Octagon', OctagonTemplate, { fillColor: C.red }),
44
- shape('star', 'Star', StarTemplate, { fillColor: C.yellow }),
45
- shape('parallelogram', 'Parallelogram', ParallelogramTemplate, { fillColor: C.green }),
46
- shape('trapezoid', 'Trapezoid', TrapezoidTemplate, { fillColor: C.purple }),
47
- shape('cylinder', 'Cylinder', CylinderTemplate, { fillColor: C.grey }),
48
- shape('document', 'Document', DocumentTemplate, { fillColor: C.white }),
49
- shape('cloud', 'Cloud', CloudTemplate, { fillColor: C.blue }),
50
- note,
51
- ],
52
- },
53
-
54
- 'flowchart': {
55
- name: 'Flowchart',
56
- group: 'Process',
57
- description: 'Steps, decisions and data in a process or algorithm',
58
- templates: [
59
- shape('terminator', 'Start / End', StadiumTemplate, { fillColor: C.green }),
60
- shape('process', 'Process', RectangleTemplate, { fillColor: C.blue }),
61
- shape('decision', 'Decision', DiamondTemplate, { fillColor: C.yellow }),
62
- shape('data', 'Data (I/O)', ParallelogramTemplate, { fillColor: C.purple }),
63
- shape('predefined-process', 'Subroutine', PredefinedProcessTemplate, { fillColor: C.blue }),
64
- shape('document', 'Document', DocumentTemplate, { fillColor: C.white }),
65
- shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
66
- shape('manual-input', 'Manual Input', ManualInputTemplate, { fillColor: C.orange }),
67
- shape('manual-operation', 'Manual Op', TrapezoidTemplate, { fillColor: C.orange }),
68
- shape('preparation', 'Preparation', HexagonTemplate, { fillColor: C.teal }),
69
- shape('connector', 'Connector', CircleTemplate, { width: 30, height: 30, fillColor: C.white }),
70
- note,
71
- ],
72
- },
73
-
74
- 'bpmn': {
75
- name: 'BPMN Process',
76
- group: 'Process',
77
- description: 'Business process: events, tasks, gateways and lanes',
78
- templates: [
79
- shape('start-event', 'Start Event', CircleTemplate, { width: 40, height: 40, fillColor: C.green }),
80
- shape('end-event', 'End Event', CircleTemplate, { width: 40, height: 40, fillColor: C.red, strokeWidth: 4 }),
81
- shape('task', 'Task', RoundedRectangleTemplate, { fillColor: C.blue }),
82
- shape('subprocess', 'Sub-Process', PredefinedProcessTemplate, { fillColor: C.blue }),
83
- shape('gateway', 'Gateway', DiamondTemplate, { width: 50, height: 50, fillColor: C.yellow }),
84
- shape('data-object', 'Data Object', NoteTemplate, { width: 50, height: 64, fillColor: C.white }),
85
- shape('data-store', 'Data Store', CylinderTemplate, { width: 60, height: 60, fillColor: C.grey }),
86
- shape('lane', 'Lane', SwimlaneTemplate, { zIndex: -1 }),
87
- note,
88
- ],
89
- },
90
-
91
- 'swimlane-diagram': {
92
- name: 'Swimlane',
93
- group: 'Process',
94
- description: 'Flow steps divided into lanes by actor or department',
95
- templates: [
96
- shape('lane', 'Lane', SwimlaneTemplate, { zIndex: -1 }),
97
- shape('start', 'Start / End', StadiumTemplate, { fillColor: C.green }),
98
- shape('task', 'Task', RoundedRectangleTemplate, { width: 110, height: 50, fillColor: C.blue }),
99
- shape('decision', 'Decision', DiamondTemplate, { width: 80, height: 80, fillColor: C.yellow }),
100
- shape('document', 'Document', DocumentTemplate, { fillColor: C.white }),
101
- note,
102
- ],
103
- },
104
-
105
- 'class-diagram': {
106
- name: 'Class',
107
- group: 'UML',
108
- description: 'Classes, interfaces and their relationships',
109
- templates: [
110
- shape('class', 'Class', ClassTemplate, { fillColor: C.white }),
111
- shape('abstract-class', 'Abstract Class', ClassTemplate, { fillColor: C.grey }),
112
- shape('interface', '«interface»', ClassTemplate, { height: 80, fillColor: C.green }),
113
- shape('enumeration', '«enumeration»', ClassTemplate, { height: 90, fillColor: C.yellow }),
114
- shape('package', 'Package', PackageTemplate, { fillColor: C.grey, zIndex: -1 }),
115
- note,
116
- ],
117
- },
118
-
119
- 'sequence-diagram': {
120
- name: 'Sequence',
121
- group: 'UML',
122
- description: 'Messages exchanged between participants over time',
123
- templates: [
124
- shape('actor', 'Actor', ActorTemplate),
125
- shape('lifeline', 'Participant', LifelineTemplate, { fillColor: C.blue }),
126
- shape('activation', 'Activation', RectangleTemplate, { width: 14, height: 80, fillColor: C.white }),
127
- shape('fragment', 'Fragment', SwimlaneTemplate, { width: 300, height: 140, fillColor: C.white, fillOpacity: 0.3, zIndex: -1 }),
128
- note,
129
- ],
130
- },
131
-
132
- 'activity-diagram': {
133
- name: 'Activity',
134
- group: 'UML',
135
- description: 'Actions, control flow, forks and joins',
136
- templates: [
137
- shape('initial', 'Initial', CircleTemplate, { width: 28, height: 28, fillColor: C.dark }),
138
- shape('action', 'Action', RoundedRectangleTemplate, { fillColor: C.blue }),
139
- shape('decision', 'Decision / Merge', DiamondTemplate, { width: 44, height: 44, fillColor: C.yellow }),
140
- shape('fork-join', 'Fork / Join', RectangleTemplate, { width: 120, height: 8, fillColor: C.dark }),
141
- shape('object', 'Object', RectangleTemplate, { fillColor: C.white }),
142
- shape('final', 'Final', FinalStateTemplate),
143
- shape('partition', 'Partition', SwimlaneTemplate, { zIndex: -1 }),
144
- note,
145
- ],
146
- },
147
-
148
- 'state-machine': {
149
- name: 'State Machine',
150
- group: 'UML',
151
- description: 'States and the transitions between them',
152
- templates: [
153
- shape('initial', 'Initial', CircleTemplate, { width: 28, height: 28, fillColor: C.dark }),
154
- shape('state', 'State', RoundedRectangleTemplate, { fillColor: C.blue }),
155
- shape('composite-state', 'Composite State', RoundedRectangleTemplate, { width: 260, height: 160, fillColor: C.grey, zIndex: -1 }),
156
- shape('choice', 'Choice', DiamondTemplate, { width: 40, height: 40, fillColor: C.yellow }),
157
- shape('final', 'Final', FinalStateTemplate),
158
- note,
159
- ],
160
- },
161
-
162
- 'use-case-diagram': {
163
- name: 'Use Case',
164
- group: 'UML',
165
- description: 'Actors and the system functions they use',
166
- templates: [
167
- shape('actor', 'Actor', ActorTemplate),
168
- shape('use-case', 'Use Case', EllipseTemplate, { width: 140, height: 60, fillColor: C.blue }),
169
- shape('system', 'System Boundary', RectangleTemplate, { width: 300, height: 360, fillColor: C.white, zIndex: -1 }),
170
- note,
171
- ],
172
- },
173
-
174
- 'component-diagram': {
175
- name: 'Component',
176
- group: 'UML',
177
- description: 'Software components and the interfaces that wire them',
178
- templates: [
179
- shape('component', 'Component', ComponentTemplate, { fillColor: C.blue }),
180
- shape('interface', 'Interface', CircleTemplate, { width: 24, height: 24, fillColor: C.white }),
181
- shape('package', 'Package', PackageTemplate, { fillColor: C.grey, zIndex: -1 }),
182
- shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
183
- note,
184
- ],
185
- },
186
-
187
- 'deployment-diagram': {
188
- name: 'Deployment',
189
- group: 'UML',
190
- description: 'Hardware nodes and the artifacts deployed to them',
191
- templates: [
192
- shape('node', 'Node', BoxTemplate, { fillColor: C.grey }),
193
- shape('device', '«device»', BoxTemplate, { fillColor: C.blue }),
194
- shape('execution-environment', '«exec env»', BoxTemplate, { fillColor: C.green }),
195
- shape('artifact', '«artifact»', NoteTemplate, { fillColor: C.white }),
196
- shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
197
- note,
198
- ],
199
- },
200
-
201
- 'er-diagram': {
202
- name: 'Entity-Relationship',
203
- group: 'Data',
204
- description: 'Entities, attributes and relationships (Chen notation)',
205
- templates: [
206
- shape('entity', 'Entity', RectangleTemplate, { width: 140, height: 60, fillColor: C.blue }),
207
- shape('relationship', 'Relationship', DiamondTemplate, { width: 120, height: 70, fillColor: C.yellow }),
208
- shape('attribute', 'Attribute', EllipseTemplate, { width: 110, height: 50, fillColor: C.green }),
209
- shape('table', 'Table', ClassTemplate, { fillColor: C.white }),
210
- note,
211
- ],
212
- },
213
-
214
- 'data-flow-diagram': {
215
- name: 'Data Flow',
216
- group: 'Data',
217
- description: 'How data moves between processes, stores and external entities',
218
- templates: [
219
- shape('process', 'Process', CircleTemplate, { width: 100, height: 100, fillColor: C.blue }),
220
- shape('external-entity', 'External Entity', RectangleTemplate, { fillColor: C.grey }),
221
- shape('data-store', 'Data Store', DataStoreTemplate, { fillColor: C.yellow }),
222
- note,
223
- ],
224
- },
225
-
226
- 'network-diagram': {
227
- name: 'Network',
228
- group: 'Infrastructure',
229
- description: 'Servers, clients and the connections between them',
230
- templates: [
231
- shape('server', 'Server', BoxTemplate, { width: 100, height: 110, fillColor: C.grey }),
232
- shape('client', 'Client', RectangleTemplate, { width: 100, height: 70, fillColor: C.blue }),
233
- shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
234
- shape('cloud', 'Cloud', CloudTemplate, { fillColor: C.blue }),
235
- shape('router', 'Router', CircleTemplate, { width: 60, height: 60, fillColor: C.green }),
236
- shape('firewall', 'Firewall', RectangleTemplate, { width: 40, height: 100, fillColor: C.red }),
237
- shape('load-balancer', 'Load Balancer', HexagonTemplate, { fillColor: C.orange }),
238
- shape('zone', 'Zone', SwimlaneTemplate, { fillColor: C.grey, fillOpacity: 0.5, zIndex: -1 }),
239
- note,
240
- ],
241
- },
242
-
243
- 'organizational-chart': {
244
- name: 'Org Chart',
245
- group: 'Business',
246
- description: 'Reporting lines and departments',
247
- templates: [
248
- shape('executive', 'Executive', RoundedRectangleTemplate, { width: 140, height: 60, fillColor: C.purple }),
249
- shape('manager', 'Manager', RoundedRectangleTemplate, { width: 130, height: 56, fillColor: C.blue }),
250
- shape('staff', 'Staff', RoundedRectangleTemplate, { width: 120, height: 50, fillColor: C.white }),
251
- shape('vacancy', 'Vacancy', RoundedRectangleTemplate, { width: 120, height: 50, fillColor: C.grey }),
252
- shape('department', 'Department', SwimlaneTemplate, { width: 320, height: 200, zIndex: -1 }),
253
- note,
254
- ],
255
- },
256
-
257
- 'mind-map': {
258
- name: 'Mind Map',
259
- group: 'Ideas',
260
- description: 'Topics radiating from a central idea',
261
- templates: [
262
- shape('central-topic', 'Central Topic', EllipseTemplate, { width: 170, height: 80, fillColor: C.orange, strokeWidth: 3 }),
263
- shape('main-topic', 'Main Topic', StadiumTemplate, { width: 130, height: 44, fillColor: C.blue }),
264
- shape('subtopic', 'Subtopic', RoundedRectangleTemplate, { width: 110, height: 34, fillColor: C.white }),
265
- shape('idea', 'Idea', CloudTemplate, { width: 120, height: 72, fillColor: C.yellow }),
266
- note,
267
- ],
268
- },
269
-
270
- 'concept-map': {
271
- name: 'Concept Map',
272
- group: 'Ideas',
273
- description: 'Concepts joined by labelled relationships',
274
- templates: [
275
- shape('concept', 'Concept', RoundedRectangleTemplate, { fillColor: C.blue }),
276
- shape('key-concept', 'Key Concept', EllipseTemplate, { width: 140, height: 70, fillColor: C.orange }),
277
- shape('linking-phrase', 'Linking Phrase', RectangleTemplate, { width: 100, height: 30, fillColor: C.white, strokeWidth: 1 }),
278
- note,
279
- ],
280
- },
281
-
282
- 'decision-tree': {
283
- name: 'Decision Tree',
284
- group: 'Ideas',
285
- description: 'Decisions, chance events and outcomes',
286
- templates: [
287
- shape('decision', 'Decision', RectangleTemplate, { width: 60, height: 60, fillColor: C.blue }),
288
- shape('chance', 'Chance', CircleTemplate, { width: 60, height: 60, fillColor: C.yellow }),
289
- shape('outcome', 'Outcome', TriangleTemplate, { width: 60, height: 54, fillColor: C.green }),
290
- shape('label', 'Label', RectangleTemplate, { width: 110, height: 30, fillColor: C.white, strokeWidth: 1 }),
291
- note,
292
- ],
293
- },
294
-
295
- 'venn-diagram': {
296
- name: 'Venn',
297
- group: 'Ideas',
298
- description: 'Overlapping sets',
299
- templates: [
300
- shape('set-a', 'Set A', CircleTemplate, { width: 180, height: 180, fillColor: '#60a5fa', fillOpacity: 0.35 }),
301
- shape('set-b', 'Set B', CircleTemplate, { width: 180, height: 180, fillColor: '#f87171', fillOpacity: 0.35 }),
302
- shape('set-c', 'Set C', CircleTemplate, { width: 180, height: 180, fillColor: '#4ade80', fillOpacity: 0.35 }),
303
- shape('universe', 'Universe', RectangleTemplate, { width: 420, height: 320, fillColor: C.white, zIndex: -1 }),
304
- note,
305
- ],
306
- },
307
- };
308
-
309
- /** Template entries for a category, falling back to 'generic' for unknown keys. */
310
- export function getTemplatesForDiagramType(diagramType) {
311
- return (DIAGRAM_TYPES[diagramType] ?? DIAGRAM_TYPES.generic).templates;
312
- }
313
-
314
- export function getAllDiagramTypes() {
315
- return Object.keys(DIAGRAM_TYPES);
316
- }
317
-
318
- /** Categories grouped for a picker, in registry order: [{ group, types: [{ key, name, description }] }]. */
319
- export function getDiagramTypesByGroup(types = DIAGRAM_TYPES) {
320
- const groups = new Map();
321
- for (const [key, { name, group = 'Other', description }] of Object.entries(types)) {
322
- if (!groups.has(group)) groups.set(group, []);
323
- groups.get(group).push({ key, name, description });
324
- }
325
- return [...groups].map(([group, entries]) => ({ group, types: entries }));
326
- }
1
+ /**
2
+ * DiagramTypeRegistry — palette categories: which shapes each kind of diagram offers.
3
+ *
4
+ * Each category is pure data: `{ name, group, description, templates }`, where a
5
+ * template entry is `{ id, name, factory(id, x, y), description? }` (what the
6
+ * palette says of it on hover). `group` drives the
7
+ * grouped category picker. The 'generic' key is the fallback for unknown types.
8
+ */
9
+ import {
10
+ RectangleTemplate, RoundedRectangleTemplate, StadiumTemplate, PredefinedProcessTemplate,
11
+ ClassTemplate, ComponentTemplate, SwimlaneTemplate, CircleTemplate, FinalStateTemplate,
12
+ EllipseTemplate, DiamondTemplate, TriangleTemplate, PentagonTemplate, HexagonTemplate,
13
+ OctagonTemplate, StarTemplate, ParallelogramTemplate, TrapezoidTemplate, ManualInputTemplate,
14
+ CylinderTemplate, DocumentTemplate, NoteTemplate, CloudTemplate, ActorTemplate,
15
+ PackageTemplate, BoxTemplate, DataStoreTemplate, LifelineTemplate,
16
+ } from './templates/index.js';
17
+
18
+ const C = {
19
+ blue: '#dbeafe', green: '#dcfce7', yellow: '#fef9c3', red: '#fee2e2', purple: '#ede9fe',
20
+ orange: '#ffedd5', teal: '#ccfbf1', grey: '#f1f5f9', white: '#ffffff', dark: '#334155',
21
+ };
22
+
23
+ /** Palette entry whose instances are `TemplateClass` created with `options` and named `name`; `description` says what it is. */
24
+ function shape(id, name, TemplateClass, options = {}, description = undefined) {
25
+ return {
26
+ id, name, factory: (instanceId, x, y) => new TemplateClass(instanceId, name, { ...options, x, y }),
27
+ ...(description && { description }),
28
+ };
29
+ }
30
+
31
+ const note = shape('note', 'Note', NoteTemplate);
32
+
33
+ export const DIAGRAM_TYPES = {
34
+ 'generic': {
35
+ name: 'Basic Shapes',
36
+ group: 'General',
37
+ description: 'General-purpose geometric shapes',
38
+ templates: [
39
+ shape('rectangle', 'Rectangle', RectangleTemplate, { fillColor: C.blue }),
40
+ shape('rounded-rectangle', 'Rounded', RoundedRectangleTemplate, { fillColor: C.blue }),
41
+ shape('circle', 'Circle', CircleTemplate, { fillColor: C.red }),
42
+ shape('ellipse', 'Ellipse', EllipseTemplate, { fillColor: C.purple }),
43
+ shape('diamond', 'Diamond', DiamondTemplate, { fillColor: C.yellow }),
44
+ shape('triangle', 'Triangle', TriangleTemplate, { fillColor: C.green }),
45
+ shape('pentagon', 'Pentagon', PentagonTemplate, { fillColor: C.teal }),
46
+ shape('hexagon', 'Hexagon', HexagonTemplate, { fillColor: C.orange }),
47
+ shape('octagon', 'Octagon', OctagonTemplate, { fillColor: C.red }),
48
+ shape('star', 'Star', StarTemplate, { fillColor: C.yellow }),
49
+ shape('parallelogram', 'Parallelogram', ParallelogramTemplate, { fillColor: C.green }),
50
+ shape('trapezoid', 'Trapezoid', TrapezoidTemplate, { fillColor: C.purple }),
51
+ shape('cylinder', 'Cylinder', CylinderTemplate, { fillColor: C.grey }),
52
+ shape('document', 'Document', DocumentTemplate, { fillColor: C.white }),
53
+ shape('cloud', 'Cloud', CloudTemplate, { fillColor: C.blue }),
54
+ note,
55
+ ],
56
+ },
57
+
58
+ 'flowchart': {
59
+ name: 'Flowchart',
60
+ group: 'Process',
61
+ description: 'Steps, decisions and data in a process or algorithm',
62
+ templates: [
63
+ shape('terminator', 'Start / End', StadiumTemplate, { fillColor: C.green }),
64
+ shape('process', 'Process', RectangleTemplate, { fillColor: C.blue }),
65
+ shape('decision', 'Decision', DiamondTemplate, { fillColor: C.yellow }),
66
+ shape('data', 'Data (I/O)', ParallelogramTemplate, { fillColor: C.purple }),
67
+ shape('predefined-process', 'Subroutine', PredefinedProcessTemplate, { fillColor: C.blue }),
68
+ shape('document', 'Document', DocumentTemplate, { fillColor: C.white }),
69
+ shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
70
+ shape('manual-input', 'Manual Input', ManualInputTemplate, { fillColor: C.orange }),
71
+ shape('manual-operation', 'Manual Op', TrapezoidTemplate, { fillColor: C.orange }),
72
+ shape('preparation', 'Preparation', HexagonTemplate, { fillColor: C.teal }),
73
+ shape('connector', 'Connector', CircleTemplate, { width: 30, height: 30, fillColor: C.white }),
74
+ note,
75
+ ],
76
+ },
77
+
78
+ 'bpmn': {
79
+ name: 'BPMN Process',
80
+ group: 'Process',
81
+ description: 'Business process: events, tasks, gateways and lanes',
82
+ templates: [
83
+ shape('start-event', 'Start Event', CircleTemplate, { width: 40, height: 40, fillColor: C.green }),
84
+ shape('end-event', 'End Event', CircleTemplate, { width: 40, height: 40, fillColor: C.red, strokeWidth: 4 }),
85
+ shape('task', 'Task', RoundedRectangleTemplate, { fillColor: C.blue }),
86
+ shape('subprocess', 'Sub-Process', PredefinedProcessTemplate, { fillColor: C.blue }),
87
+ shape('gateway', 'Gateway', DiamondTemplate, { width: 50, height: 50, fillColor: C.yellow }),
88
+ shape('data-object', 'Data Object', NoteTemplate, { width: 50, height: 64, fillColor: C.white }),
89
+ shape('data-store', 'Data Store', CylinderTemplate, { width: 60, height: 60, fillColor: C.grey }),
90
+ shape('lane', 'Lane', SwimlaneTemplate, { zIndex: -1 }),
91
+ note,
92
+ ],
93
+ },
94
+
95
+ 'swimlane-diagram': {
96
+ name: 'Swimlane',
97
+ group: 'Process',
98
+ description: 'Flow steps divided into lanes by actor or department',
99
+ templates: [
100
+ shape('lane', 'Lane', SwimlaneTemplate, { zIndex: -1 }),
101
+ shape('start', 'Start / End', StadiumTemplate, { fillColor: C.green }),
102
+ shape('task', 'Task', RoundedRectangleTemplate, { width: 110, height: 50, fillColor: C.blue }),
103
+ shape('decision', 'Decision', DiamondTemplate, { width: 80, height: 80, fillColor: C.yellow }),
104
+ shape('document', 'Document', DocumentTemplate, { fillColor: C.white }),
105
+ note,
106
+ ],
107
+ },
108
+
109
+ 'class-diagram': {
110
+ name: 'Class',
111
+ group: 'UML',
112
+ description: 'Classes, interfaces and their relationships',
113
+ templates: [
114
+ shape('class', 'Class', ClassTemplate, { fillColor: C.white }),
115
+ shape('abstract-class', 'Abstract Class', ClassTemplate, { fillColor: C.grey }),
116
+ shape('interface', '«interface»', ClassTemplate, { height: 80, fillColor: C.green }),
117
+ shape('enumeration', '«enumeration»', ClassTemplate, { height: 90, fillColor: C.yellow }),
118
+ shape('package', 'Package', PackageTemplate, { fillColor: C.grey, zIndex: -1 }),
119
+ note,
120
+ ],
121
+ },
122
+
123
+ 'sequence-diagram': {
124
+ name: 'Sequence',
125
+ group: 'UML',
126
+ description: 'Messages exchanged between participants over time',
127
+ templates: [
128
+ shape('actor', 'Actor', ActorTemplate),
129
+ shape('lifeline', 'Participant', LifelineTemplate, { fillColor: C.blue }),
130
+ shape('activation', 'Activation', RectangleTemplate, { width: 14, height: 80, fillColor: C.white }),
131
+ shape('fragment', 'Fragment', SwimlaneTemplate, { width: 300, height: 140, fillColor: C.white, fillOpacity: 0.3, zIndex: -1 }),
132
+ note,
133
+ ],
134
+ },
135
+
136
+ 'activity-diagram': {
137
+ name: 'Activity',
138
+ group: 'UML',
139
+ description: 'Actions, control flow, forks and joins',
140
+ templates: [
141
+ shape('initial', 'Initial', CircleTemplate, { width: 28, height: 28, fillColor: C.dark }),
142
+ shape('action', 'Action', RoundedRectangleTemplate, { fillColor: C.blue }),
143
+ shape('decision', 'Decision / Merge', DiamondTemplate, { width: 44, height: 44, fillColor: C.yellow }),
144
+ shape('fork-join', 'Fork / Join', RectangleTemplate, { width: 120, height: 8, fillColor: C.dark }),
145
+ shape('object', 'Object', RectangleTemplate, { fillColor: C.white }),
146
+ shape('final', 'Final', FinalStateTemplate),
147
+ shape('partition', 'Partition', SwimlaneTemplate, { zIndex: -1 }),
148
+ note,
149
+ ],
150
+ },
151
+
152
+ 'state-machine': {
153
+ name: 'State Machine',
154
+ group: 'UML',
155
+ description: 'States and the transitions between them',
156
+ templates: [
157
+ shape('initial', 'Initial', CircleTemplate, { width: 28, height: 28, fillColor: C.dark }),
158
+ shape('state', 'State', RoundedRectangleTemplate, { fillColor: C.blue }),
159
+ shape('composite-state', 'Composite State', RoundedRectangleTemplate, { width: 260, height: 160, fillColor: C.grey, zIndex: -1 }),
160
+ shape('choice', 'Choice', DiamondTemplate, { width: 40, height: 40, fillColor: C.yellow }),
161
+ shape('final', 'Final', FinalStateTemplate),
162
+ note,
163
+ ],
164
+ },
165
+
166
+ 'use-case-diagram': {
167
+ name: 'Use Case',
168
+ group: 'UML',
169
+ description: 'Actors and the system functions they use',
170
+ templates: [
171
+ shape('actor', 'Actor', ActorTemplate),
172
+ shape('use-case', 'Use Case', EllipseTemplate, { width: 140, height: 60, fillColor: C.blue }),
173
+ shape('system', 'System Boundary', RectangleTemplate, { width: 300, height: 360, fillColor: C.white, zIndex: -1 }),
174
+ note,
175
+ ],
176
+ },
177
+
178
+ 'component-diagram': {
179
+ name: 'Component',
180
+ group: 'UML',
181
+ description: 'Software components and the interfaces that wire them',
182
+ templates: [
183
+ shape('component', 'Component', ComponentTemplate, { fillColor: C.blue }),
184
+ shape('interface', 'Interface', CircleTemplate, { width: 24, height: 24, fillColor: C.white }),
185
+ shape('package', 'Package', PackageTemplate, { fillColor: C.grey, zIndex: -1 }),
186
+ shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
187
+ note,
188
+ ],
189
+ },
190
+
191
+ 'deployment-diagram': {
192
+ name: 'Deployment',
193
+ group: 'UML',
194
+ description: 'Hardware nodes and the artifacts deployed to them',
195
+ templates: [
196
+ shape('node', 'Node', BoxTemplate, { fillColor: C.grey }),
197
+ shape('device', '«device»', BoxTemplate, { fillColor: C.blue }),
198
+ shape('execution-environment', '«exec env»', BoxTemplate, { fillColor: C.green }),
199
+ shape('artifact', '«artifact»', NoteTemplate, { fillColor: C.white }),
200
+ shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
201
+ note,
202
+ ],
203
+ },
204
+
205
+ 'er-diagram': {
206
+ name: 'Entity-Relationship',
207
+ group: 'Data',
208
+ description: 'Entities, attributes and relationships (Chen notation)',
209
+ templates: [
210
+ shape('entity', 'Entity', RectangleTemplate, { width: 140, height: 60, fillColor: C.blue }),
211
+ shape('relationship', 'Relationship', DiamondTemplate, { width: 120, height: 70, fillColor: C.yellow }),
212
+ shape('attribute', 'Attribute', EllipseTemplate, { width: 110, height: 50, fillColor: C.green }),
213
+ shape('table', 'Table', ClassTemplate, { fillColor: C.white }),
214
+ note,
215
+ ],
216
+ },
217
+
218
+ 'enterprise-ontology': {
219
+ name: 'Enterprise Ontology',
220
+ group: 'Data',
221
+ description: 'The universal concepts enterprise data models are built from (after IBM IFW\'s data concepts): parties in roles enter arrangements for products and resources; events change them, ledgers record their value; business direction steers them; classification, place, time, measure and rule describe them',
222
+ templates: [
223
+ shape('party', 'Party', ActorTemplate, {},
224
+ 'A person or legal actor that can act or hold rights: person, organisation, government body. Every business process involves actors.'),
225
+ shape('role', 'Role', StadiumTemplate, { width: 120, height: 44, fillColor: C.purple },
226
+ 'The part a party (or resource) plays in a context: customer, supplier, employee, owner, custodian. A party has many roles, and they change over time.'),
227
+ shape('arrangement', 'Arrangement', DocumentTemplate, { width: 130, height: 70, fillColor: C.yellow },
228
+ 'A formalised relationship between parties, or parties and resources: contract, agreement, subscription, membership, policy, lease. Business interactions are structured by agreements.'),
229
+ shape('product', 'Product', PackageTemplate, { width: 120, height: 70, fillColor: C.green },
230
+ 'What the business offers and sells, under terms: a plan, a policy, a loan, a service bundle. Not the things it holds (resources), but the offer made of them.'),
231
+ shape('resource', 'Resource', BoxTemplate, { width: 110, height: 80, fillColor: C.blue },
232
+ 'A physical or digital thing of value or use: product, asset, document, file, device. Businesses manage things.'),
233
+ shape('event', 'Event', EllipseTemplate, { width: 120, height: 60, fillColor: C.green },
234
+ 'A change of state the business cares about: order placed, payment made, shipment dispatched, sensor reading. Events drive processes, workflows and ledgers.'),
235
+ shape('ledger', 'Account / Ledger', CylinderTemplate, { width: 100, height: 80, fillColor: C.grey },
236
+ 'A record of value, obligations or state over time: financial account, inventory ledger, entitlement balance, audit log. It records the quantitative impact of events.'),
237
+ shape('classification', 'Classification', PentagonTemplate, { width: 110, height: 80, fillColor: C.teal },
238
+ 'A scheme for categorising parties, resources, events and arrangements: product category, risk rating, asset class, industry code, status.'),
239
+ shape('place', 'Place', HexagonTemplate, { width: 110, height: 70, fillColor: C.orange },
240
+ 'Where things happen or exist, physical or logical: building, room, coordinate, cloud region, network zone.'),
241
+ shape('time', 'Time', CircleTemplate, { width: 70, height: 70, fillColor: C.white },
242
+ 'A point or interval in time: effective date, validity period, contract term, timestamp, posting date.'),
243
+ shape('measure', 'Measure', RectangleTemplate, { width: 110, height: 40, fillColor: C.white },
244
+ 'A quantity with its unit: weight, price, balance, temperature, risk score, count. The basis of metrics, KPIs and ledgers.'),
245
+ shape('direction', 'Business Direction', StarTemplate, { width: 100, height: 90, fillColor: C.yellow },
246
+ 'Where the business means to go: goal, objective, strategy, plan, policy, and the targets that measure them. It shapes products, arrangements and rules.'),
247
+ shape('rule', 'Rule', DiamondTemplate, { width: 100, height: 70, fillColor: C.red },
248
+ 'A condition that governs arrangements, events or resources: business rule, policy, validation, regulatory requirement, eligibility.'),
249
+ note,
250
+ ],
251
+ },
252
+
253
+ 'data-flow-diagram': {
254
+ name: 'Data Flow',
255
+ group: 'Data',
256
+ description: 'How data moves between processes, stores and external entities',
257
+ templates: [
258
+ shape('process', 'Process', CircleTemplate, { width: 100, height: 100, fillColor: C.blue }),
259
+ shape('external-entity', 'External Entity', RectangleTemplate, { fillColor: C.grey }),
260
+ shape('data-store', 'Data Store', DataStoreTemplate, { fillColor: C.yellow }),
261
+ note,
262
+ ],
263
+ },
264
+
265
+ 'network-diagram': {
266
+ name: 'Network',
267
+ group: 'Infrastructure',
268
+ description: 'Servers, clients and the connections between them',
269
+ templates: [
270
+ shape('server', 'Server', BoxTemplate, { width: 100, height: 110, fillColor: C.grey }),
271
+ shape('client', 'Client', RectangleTemplate, { width: 100, height: 70, fillColor: C.blue }),
272
+ shape('database', 'Database', CylinderTemplate, { fillColor: C.grey }),
273
+ shape('cloud', 'Cloud', CloudTemplate, { fillColor: C.blue }),
274
+ shape('router', 'Router', CircleTemplate, { width: 60, height: 60, fillColor: C.green }),
275
+ shape('firewall', 'Firewall', RectangleTemplate, { width: 40, height: 100, fillColor: C.red }),
276
+ shape('load-balancer', 'Load Balancer', HexagonTemplate, { fillColor: C.orange }),
277
+ shape('zone', 'Zone', SwimlaneTemplate, { fillColor: C.grey, fillOpacity: 0.5, zIndex: -1 }),
278
+ note,
279
+ ],
280
+ },
281
+
282
+ 'organizational-chart': {
283
+ name: 'Org Chart',
284
+ group: 'Business',
285
+ description: 'Reporting lines and departments',
286
+ templates: [
287
+ shape('executive', 'Executive', RoundedRectangleTemplate, { width: 140, height: 60, fillColor: C.purple }),
288
+ shape('manager', 'Manager', RoundedRectangleTemplate, { width: 130, height: 56, fillColor: C.blue }),
289
+ shape('staff', 'Staff', RoundedRectangleTemplate, { width: 120, height: 50, fillColor: C.white }),
290
+ shape('vacancy', 'Vacancy', RoundedRectangleTemplate, { width: 120, height: 50, fillColor: C.grey }),
291
+ shape('department', 'Department', SwimlaneTemplate, { width: 320, height: 200, zIndex: -1 }),
292
+ note,
293
+ ],
294
+ },
295
+
296
+ 'mind-map': {
297
+ name: 'Mind Map',
298
+ group: 'Ideas',
299
+ description: 'Topics radiating from a central idea',
300
+ templates: [
301
+ shape('central-topic', 'Central Topic', EllipseTemplate, { width: 170, height: 80, fillColor: C.orange, strokeWidth: 3 }),
302
+ shape('main-topic', 'Main Topic', StadiumTemplate, { width: 130, height: 44, fillColor: C.blue }),
303
+ shape('subtopic', 'Subtopic', RoundedRectangleTemplate, { width: 110, height: 34, fillColor: C.white }),
304
+ shape('idea', 'Idea', CloudTemplate, { width: 120, height: 72, fillColor: C.yellow }),
305
+ note,
306
+ ],
307
+ },
308
+
309
+ 'concept-map': {
310
+ name: 'Concept Map',
311
+ group: 'Ideas',
312
+ description: 'Concepts joined by labelled relationships',
313
+ templates: [
314
+ shape('concept', 'Concept', RoundedRectangleTemplate, { fillColor: C.blue }),
315
+ shape('key-concept', 'Key Concept', EllipseTemplate, { width: 140, height: 70, fillColor: C.orange }),
316
+ shape('linking-phrase', 'Linking Phrase', RectangleTemplate, { width: 100, height: 30, fillColor: C.white, strokeWidth: 1 }),
317
+ note,
318
+ ],
319
+ },
320
+
321
+ 'decision-tree': {
322
+ name: 'Decision Tree',
323
+ group: 'Ideas',
324
+ description: 'Decisions, chance events and outcomes',
325
+ templates: [
326
+ shape('decision', 'Decision', RectangleTemplate, { width: 60, height: 60, fillColor: C.blue }),
327
+ shape('chance', 'Chance', CircleTemplate, { width: 60, height: 60, fillColor: C.yellow }),
328
+ shape('outcome', 'Outcome', TriangleTemplate, { width: 60, height: 54, fillColor: C.green }),
329
+ shape('label', 'Label', RectangleTemplate, { width: 110, height: 30, fillColor: C.white, strokeWidth: 1 }),
330
+ note,
331
+ ],
332
+ },
333
+
334
+ 'venn-diagram': {
335
+ name: 'Venn',
336
+ group: 'Ideas',
337
+ description: 'Overlapping sets',
338
+ templates: [
339
+ shape('set-a', 'Set A', CircleTemplate, { width: 180, height: 180, fillColor: '#60a5fa', fillOpacity: 0.35 }),
340
+ shape('set-b', 'Set B', CircleTemplate, { width: 180, height: 180, fillColor: '#f87171', fillOpacity: 0.35 }),
341
+ shape('set-c', 'Set C', CircleTemplate, { width: 180, height: 180, fillColor: '#4ade80', fillOpacity: 0.35 }),
342
+ shape('universe', 'Universe', RectangleTemplate, { width: 420, height: 320, fillColor: C.white, zIndex: -1 }),
343
+ note,
344
+ ],
345
+ },
346
+ };
347
+
348
+ /** Template entries for a category, falling back to 'generic' for unknown keys. */
349
+ export function getTemplatesForDiagramType(diagramType) {
350
+ return (DIAGRAM_TYPES[diagramType] ?? DIAGRAM_TYPES.generic).templates;
351
+ }
352
+
353
+ export function getAllDiagramTypes() {
354
+ return Object.keys(DIAGRAM_TYPES);
355
+ }
356
+
357
+ /** Categories grouped for a picker, in registry order: [{ group, types: [{ key, name, description }] }]. */
358
+ export function getDiagramTypesByGroup(types = DIAGRAM_TYPES) {
359
+ const groups = new Map();
360
+ for (const [key, { name, group = 'Other', description }] of Object.entries(types)) {
361
+ if (!groups.has(group)) groups.set(group, []);
362
+ groups.get(group).push({ key, name, description });
363
+ }
364
+ return [...groups].map(([group, entries]) => ({ group, types: entries }));
365
+ }