@bpmn-nova/studio 0.3.9-preview → 0.4.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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/canvas.js +97 -25
  3. package/dist/config.js +13 -0
  4. package/dist/context-menu.js +41 -32
  5. package/dist/controller.js +45 -19
  6. package/dist/flow-tree.d.ts +4 -0
  7. package/dist/flow-tree.js +14 -0
  8. package/dist/index.d.ts +47 -2
  9. package/dist/index.js +1 -0
  10. package/dist/interactions.js +6 -1
  11. package/dist/modules/bpmn-model/index.d.ts +2 -1
  12. package/dist/modules/bpmn-model/index.js +12 -10
  13. package/dist/modules/core/gateway.js +16 -13
  14. package/dist/modules/core/index.d.ts +6 -4
  15. package/dist/modules/core/model.js +12 -7
  16. package/dist/modules/designer/index.d.ts +5 -1
  17. package/dist/modules/designer/index.js +36 -15
  18. package/dist/modules/export-svg/index.d.ts +12 -5
  19. package/dist/modules/export-svg/preview.js +34 -24
  20. package/dist/modules/export-svg/render.js +102 -50
  21. package/dist/modules/flow-tree/controller.js +364 -0
  22. package/dist/modules/flow-tree/index.d.ts +248 -0
  23. package/dist/modules/flow-tree/index.js +5 -0
  24. package/dist/modules/flow-tree/operations.js +484 -0
  25. package/dist/modules/flow-tree/sample.js +445 -0
  26. package/dist/modules/flow-tree/schema.js +588 -0
  27. package/dist/modules/flow-tree/validate.js +125 -0
  28. package/dist/modules/flow-tree-bpmn/compiler.js +547 -0
  29. package/dist/modules/flow-tree-bpmn/decompiler.js +524 -0
  30. package/dist/modules/flow-tree-bpmn/expression.js +135 -0
  31. package/dist/modules/flow-tree-bpmn/index.d.ts +53 -0
  32. package/dist/modules/flow-tree-bpmn/index.js +14 -0
  33. package/dist/modules/flow-tree-renderer/canvas.js +1003 -0
  34. package/dist/modules/flow-tree-renderer/export-svg.js +325 -0
  35. package/dist/modules/flow-tree-renderer/index.d.ts +143 -0
  36. package/dist/modules/flow-tree-renderer/index.js +3 -0
  37. package/dist/modules/flow-tree-renderer/shell.js +970 -0
  38. package/dist/modules/i18n/index.d.ts +647 -0
  39. package/dist/modules/i18n/index.js +247 -0
  40. package/dist/modules/i18n/locales/en-US.js +1222 -0
  41. package/dist/modules/i18n/locales/zh-CN.js +1204 -0
  42. package/dist/modules/icons/index.js +23 -0
  43. package/dist/modules/node-presentation/index.d.ts +3 -2
  44. package/dist/modules/node-presentation/index.js +14 -11
  45. package/dist/modules/palette/index.d.ts +6 -1
  46. package/dist/modules/palette/index.js +26 -8
  47. package/dist/modules/palette/panel.js +44 -6
  48. package/dist/modules/properties/index.d.ts +2 -1
  49. package/dist/modules/properties/index.js +2 -2
  50. package/dist/modules/properties-activiti/index.js +84 -59
  51. package/dist/modules/properties-bpmn/index.js +151 -128
  52. package/dist/modules/properties-core/index.d.ts +9 -3
  53. package/dist/modules/properties-core/index.js +16 -4
  54. package/dist/modules/properties-flow-tree/index.d.ts +56 -0
  55. package/dist/modules/properties-flow-tree/index.js +2 -0
  56. package/dist/modules/properties-flow-tree/panel.js +1136 -0
  57. package/dist/modules/properties-flow-tree/widgets.js +625 -0
  58. package/dist/modules/properties-flowable/index.js +55 -34
  59. package/dist/modules/properties-renderer/index.d.ts +5 -1
  60. package/dist/modules/properties-renderer/index.js +110 -42
  61. package/dist/modules/renderer-svg/index.d.ts +6 -2
  62. package/dist/modules/renderer-svg/index.js +113 -38
  63. package/dist/modules/runtime/index.d.ts +33 -5
  64. package/dist/modules/runtime/index.js +97 -73
  65. package/dist/modules/runtime/time.js +89 -4
  66. package/dist/modules/runtime/visits.js +6 -4
  67. package/dist/modules/theme/index.d.ts +5 -2
  68. package/dist/modules/theme/index.js +8 -4
  69. package/dist/modules/viewer/index.d.ts +28 -7
  70. package/dist/modules/viewer/index.js +223 -58
  71. package/dist/modules/viewer/runtime-content.js +26 -20
  72. package/dist/modules/viewer/runtime-trace.js +43 -25
  73. package/dist/modules/viewer/timeline.js +103 -36
  74. package/dist/shell.js +258 -75
  75. package/dist/sidebars.js +3 -1
  76. package/dist/styles.css +2371 -2
  77. package/llms-full.txt +586 -47
  78. package/llms.txt +6 -5
  79. package/package.json +7 -3
@@ -0,0 +1,364 @@
1
+ import { HistoryStack } from '../core/index.js';
2
+ import { createI18n, resolveI18n } from '../i18n/index.js';
3
+ import {
4
+ cloneFlowTree,
5
+ createDefaultFlowTreeNodeRegistry,
6
+ isRouteNode,
7
+ normalizeFlowTreeDocument,
8
+ } from './schema.js';
9
+ import {
10
+ addBranchToRoute,
11
+ canMoveFlowTreeNode,
12
+ countFlowTreeVisibleCards,
13
+ duplicateFlowTreeNode,
14
+ findFlowTreeNode,
15
+ insertRouteAt,
16
+ insertStepAt,
17
+ moveFlowTreeNode,
18
+ removeFlowTreeNode,
19
+ reorderRouteBranch,
20
+ updateFlowTreeNode,
21
+ updateFlowTreeNodeConfig,
22
+ } from './operations.js';
23
+ import { validateFlowTree } from './validate.js';
24
+ import { createEmptyFlowTree } from './sample.js';
25
+
26
+ export class FlowTreeController {
27
+ constructor(options = {}) {
28
+ const {
29
+ document: initialDocument = null,
30
+ engine = 'flowable',
31
+ historyLimit = 80,
32
+ nodeRegistry = null,
33
+ customNodes = [],
34
+ compiler = null,
35
+ i18n = null,
36
+ locale,
37
+ messages,
38
+ } = options;
39
+
40
+ this._ownsI18n = !i18n;
41
+ this.i18n = i18n ? resolveI18n(i18n) : createI18n({ locale, messages });
42
+ this.nodeRegistry = nodeRegistry || createDefaultFlowTreeNodeRegistry(customNodes);
43
+ this._compiler = compiler || null;
44
+ this._document = initialDocument
45
+ ? normalizeFlowTreeDocument(initialDocument, { i18n: this.i18n, nodeRegistry: this.nodeRegistry })
46
+ : createEmptyFlowTree(engine, { i18n: this.i18n, nodeRegistry: this.nodeRegistry });
47
+ this.history = new HistoryStack(historyLimit);
48
+ this.selection = { kind: 'node', id: this._document.starter.id };
49
+ this._collapsedBranches = new Set();
50
+ this._listeners = new Set();
51
+
52
+ this.commands = Object.freeze({
53
+ insertStep: (containerRef, index, nodeType, overrides) => this.insertStep(containerRef, index, nodeType, overrides),
54
+ insertRoute: (containerRef, index, routeType, options) => this.insertRoute(containerRef, index, routeType, options),
55
+ addBranch: (routeId, overrides) => this.addBranch(routeId, overrides),
56
+ reorderBranch: (routeId, fromIndex, toIndex) => this.reorderBranch(routeId, fromIndex, toIndex),
57
+ duplicateNode: (nodeId) => this.duplicateNode(nodeId),
58
+ removeNode: (nodeId) => this.removeNode(nodeId),
59
+ moveNode: (nodeId, targetContainerRef, targetIndex) => this.moveNode(nodeId, targetContainerRef, targetIndex),
60
+ canMoveNode: (nodeId, targetContainerRef) => this.canMoveNode(nodeId, targetContainerRef),
61
+ updateDocument: (patch) => this.updateDocument(patch),
62
+ updateNode: (nodeId, patch) => this.updateNode(nodeId, patch),
63
+ updateNodeConfig: (nodeId, configPatch) => this.updateNodeConfig(nodeId, configPatch),
64
+ setEngine: (nextEngine) => this.setEngine(nextEngine),
65
+ select: (selection) => this.select(selection),
66
+ toggleBranchCollapse: (branchId) => this.toggleBranchCollapse(branchId),
67
+ undo: () => this.undo(),
68
+ redo: () => this.redo(),
69
+ });
70
+
71
+ this._offI18n = this.i18n.subscribe((state) => {
72
+ this._emit('localeChanged', { locale: state.locale, resolvedLocale: state.resolvedLocale });
73
+ });
74
+ }
75
+
76
+ get document() { return this._document; }
77
+
78
+ setCompiler(compiler) {
79
+ this._compiler = compiler || null;
80
+ }
81
+
82
+ setLocale(locale, messages) {
83
+ this.i18n.setLocale(locale, messages);
84
+ return this.getLocale();
85
+ }
86
+
87
+ getLocale() {
88
+ return this.i18n.getState();
89
+ }
90
+
91
+ subscribe(listener) {
92
+ if (typeof listener !== 'function') return () => {};
93
+ this._listeners.add(listener);
94
+ return () => this._listeners.delete(listener);
95
+ }
96
+
97
+ _emit(type, detail = {}) {
98
+ const event = { type, ...detail, state: this.getState() };
99
+ for (const listener of this._listeners) listener(event);
100
+ }
101
+
102
+ _commit(reason, mutator) {
103
+ this.history.capture(this._document);
104
+ const result = mutator();
105
+ this._emit('documentChanged', { reason });
106
+ this._emit('historyChanged', { reason });
107
+ return result;
108
+ }
109
+
110
+ getSelectedNode() {
111
+ if (!this.selection || this.selection.kind !== 'node') return null;
112
+ return findFlowTreeNode(this._document, this.selection.id);
113
+ }
114
+
115
+ getState() {
116
+ const validationIssues = this.validate();
117
+ return {
118
+ document: cloneFlowTree(this._document),
119
+ selection: this.selection ? cloneFlowTree(this.selection) : null,
120
+ selectedNode: cloneFlowTree(this.getSelectedNode()),
121
+ collapsedBranches: [...this._collapsedBranches],
122
+ canUndo: this.history.canUndo,
123
+ canRedo: this.history.canRedo,
124
+ engine: this._document.engine,
125
+ nodeCount: countFlowTreeVisibleCards(this._document),
126
+ validationIssues,
127
+ locale: this.i18n.locale,
128
+ };
129
+ }
130
+
131
+ setDocument(nextDocument, { resetHistory = true } = {}) {
132
+ this._document = normalizeFlowTreeDocument(nextDocument, { i18n: this.i18n, nodeRegistry: this.nodeRegistry });
133
+ if (resetHistory) this.history = new HistoryStack(this.history.limit);
134
+ this._collapsedBranches.clear();
135
+ this.selection = { kind: 'node', id: this._document.starter.id };
136
+ this._emit('documentChanged', { reason: 'set-document' });
137
+ this._emit('selectionChanged', { selection: this.selection, node: this.getSelectedNode() });
138
+ this._emit('historyChanged', { reason: 'set-document' });
139
+ return cloneFlowTree(this._document);
140
+ }
141
+
142
+ select(selection) {
143
+ if (!selection || selection.kind === 'process') {
144
+ this.selection = { kind: 'process', id: this._document.id };
145
+ this._emit('selectionChanged', { selection: this.selection, node: null });
146
+ return true;
147
+ }
148
+ if (selection.kind === 'node') {
149
+ const target = findFlowTreeNode(this._document, selection.id);
150
+ if (!target) return false;
151
+ this.selection = { kind: 'node', id: target.id };
152
+ this._emit('selectionChanged', { selection: this.selection, node: target });
153
+ return true;
154
+ }
155
+ return false;
156
+ }
157
+
158
+ insertStep(containerRef, index, nodeType, overrides = {}) {
159
+ const def = this.nodeRegistry.resolve(nodeType);
160
+ if (def?.kind === 'route') return this.insertRoute(containerRef, index, nodeType, overrides);
161
+ let created = null;
162
+ this._commit('insert-step', () => {
163
+ created = insertStepAt(this._document, containerRef, index, nodeType, overrides, {
164
+ i18n: this.i18n,
165
+ nodeRegistry: this.nodeRegistry,
166
+ });
167
+ });
168
+ if (created) this.select({ kind: 'node', id: created.id });
169
+ return created;
170
+ }
171
+
172
+ insertRoute(containerRef, index, routeType, options = {}) {
173
+ let created = null;
174
+ this._commit('insert-route', () => {
175
+ created = insertRouteAt(this._document, containerRef, index, routeType, {
176
+ ...options,
177
+ i18n: this.i18n,
178
+ nodeRegistry: this.nodeRegistry,
179
+ });
180
+ });
181
+ if (created?.branches?.[0]) {
182
+ this.select({ kind: 'node', id: created.branches[0].id });
183
+ }
184
+ return created;
185
+ }
186
+
187
+ addBranch(routeId, overrides = {}) {
188
+ let created = null;
189
+ this._commit('add-branch', () => {
190
+ created = addBranchToRoute(this._document, routeId, overrides, {
191
+ i18n: this.i18n,
192
+ nodeRegistry: this.nodeRegistry,
193
+ });
194
+ });
195
+ if (created) this.select({ kind: 'node', id: created.id });
196
+ return created;
197
+ }
198
+
199
+ reorderBranch(routeId, fromIndex, toIndex) {
200
+ let moved = false;
201
+ this._commit('reorder-branch', () => {
202
+ moved = reorderRouteBranch(this._document, routeId, fromIndex, toIndex);
203
+ });
204
+ return moved;
205
+ }
206
+
207
+ duplicateNode(nodeId) {
208
+ let copy = null;
209
+ this._commit('duplicate-node', () => {
210
+ copy = duplicateFlowTreeNode(this._document, nodeId);
211
+ });
212
+ if (copy) {
213
+ const selectId = isRouteNode(copy) ? copy.branches?.[0]?.id : copy.id;
214
+ if (selectId) this.select({ kind: 'node', id: selectId });
215
+ }
216
+ return copy;
217
+ }
218
+
219
+ removeNode(nodeId) {
220
+ let removed = false;
221
+ this._commit('remove-node', () => {
222
+ removed = removeFlowTreeNode(this._document, nodeId);
223
+ });
224
+ if (!removed) return false;
225
+ if (this.selection?.kind === 'node' && !findFlowTreeNode(this._document, this.selection.id)) {
226
+ this.select({ kind: 'node', id: this._document.starter.id });
227
+ }
228
+ return true;
229
+ }
230
+
231
+ canMoveNode(nodeId, targetContainerRef) {
232
+ return canMoveFlowTreeNode(this._document, nodeId, targetContainerRef);
233
+ }
234
+
235
+ moveNode(nodeId, targetContainerRef, targetIndex) {
236
+ if (!this.canMoveNode(nodeId, targetContainerRef)) return false;
237
+ let moved = false;
238
+ this._commit('move-node', () => {
239
+ moved = moveFlowTreeNode(this._document, nodeId, targetContainerRef, targetIndex);
240
+ });
241
+ if (moved) this.select({ kind: 'node', id: nodeId });
242
+ return moved;
243
+ }
244
+
245
+ updateDocument(patch = {}) {
246
+ this._commit('update-document', () => {
247
+ if (patch.settings && typeof patch.settings === 'object') {
248
+ this._document.settings = { ...this._document.settings, ...cloneFlowTree(patch.settings) };
249
+ }
250
+ if (patch.properties && typeof patch.properties === 'object') {
251
+ this._document.properties = { ...(this._document.properties || {}), ...cloneFlowTree(patch.properties) };
252
+ }
253
+ for (const [key, value] of Object.entries(patch)) {
254
+ if (['settings', 'properties', 'starter', 'steps', 'end', 'schemaVersion'].includes(key)) continue;
255
+ this._document[key] = cloneFlowTree(value);
256
+ }
257
+ });
258
+ return true;
259
+ }
260
+
261
+ updateNode(nodeId, patch = {}) {
262
+ if (!findFlowTreeNode(this._document, nodeId)) return false;
263
+ this._commit('update-node', () => {
264
+ updateFlowTreeNode(this._document, nodeId, patch);
265
+ });
266
+ return true;
267
+ }
268
+
269
+ updateNodeConfig(nodeId, configPatch = {}) {
270
+ if (!findFlowTreeNode(this._document, nodeId)) return false;
271
+ this._commit('update-node-config', () => {
272
+ updateFlowTreeNodeConfig(this._document, nodeId, configPatch);
273
+ });
274
+ return true;
275
+ }
276
+
277
+ setEngine(engine) {
278
+ if (!['flowable', 'activiti'].includes(engine) || engine === this._document.engine) return false;
279
+ this._commit('set-engine', () => {
280
+ this._document.engine = engine;
281
+ });
282
+ return true;
283
+ }
284
+
285
+ isBranchCollapsed(branchId) {
286
+ return this._collapsedBranches.has(branchId);
287
+ }
288
+
289
+ toggleBranchCollapse(branchId) {
290
+ if (!branchId) return false;
291
+ if (this._collapsedBranches.has(branchId)) this._collapsedBranches.delete(branchId);
292
+ else this._collapsedBranches.add(branchId);
293
+ this._emit('viewChanged', { collapsedBranches: [...this._collapsedBranches] });
294
+ return this._collapsedBranches.has(branchId);
295
+ }
296
+
297
+ validate() {
298
+ return validateFlowTree(this._document, { i18n: this.i18n, nodeRegistry: this.nodeRegistry });
299
+ }
300
+
301
+ undo() {
302
+ const previous = this.history.undo(this._document);
303
+ if (!previous) return false;
304
+ this._document = previous;
305
+ if (this.selection?.kind === 'node' && !findFlowTreeNode(this._document, this.selection.id)) {
306
+ this.selection = { kind: 'node', id: this._document.starter.id };
307
+ }
308
+ this._emit('documentChanged', { reason: 'undo' });
309
+ this._emit('selectionChanged', { selection: this.selection, node: this.getSelectedNode() });
310
+ this._emit('historyChanged', { reason: 'undo' });
311
+ return true;
312
+ }
313
+
314
+ redo() {
315
+ const next = this.history.redo(this._document);
316
+ if (!next) return false;
317
+ this._document = next;
318
+ if (this.selection?.kind === 'node' && !findFlowTreeNode(this._document, this.selection.id)) {
319
+ this.selection = { kind: 'node', id: this._document.starter.id };
320
+ }
321
+ this._emit('documentChanged', { reason: 'redo' });
322
+ this._emit('selectionChanged', { selection: this.selection, node: this.getSelectedNode() });
323
+ this._emit('historyChanged', { reason: 'redo' });
324
+ return true;
325
+ }
326
+
327
+ toJSON() {
328
+ return cloneFlowTree(this._document);
329
+ }
330
+
331
+ fromJSON(json, options = {}) {
332
+ const parsed = typeof json === 'string' ? JSON.parse(json) : json;
333
+ return this.setDocument(parsed, options);
334
+ }
335
+
336
+ compileToBpmn(options = {}) {
337
+ if (!this._compiler?.compile) throw new Error('No BPMN compiler attached to FlowTreeController.');
338
+ return this._compiler.compile(this._document, { i18n: this.i18n, nodeRegistry: this.nodeRegistry, ...options });
339
+ }
340
+
341
+ exportXml(engine = this._document.engine, options = {}) {
342
+ if (!this._compiler?.exportXml) throw new Error('No BPMN XML exporter attached to FlowTreeController.');
343
+ return this._compiler.exportXml(this._document, engine, { i18n: this.i18n, nodeRegistry: this.nodeRegistry, ...options });
344
+ }
345
+
346
+ importXml(xml, engine, options = {}) {
347
+ if (!this._compiler?.importXml) throw new Error('No BPMN XML importer attached to FlowTreeController.');
348
+ const result = this._compiler.importXml(xml, engine, { i18n: this.i18n, nodeRegistry: this.nodeRegistry, ...options });
349
+ if (result?.document) {
350
+ this.setDocument(result.document, { resetHistory: options.resetHistory !== false });
351
+ }
352
+ return result;
353
+ }
354
+
355
+ destroy() {
356
+ this._offI18n?.();
357
+ this._offI18n = null;
358
+ this._listeners.clear();
359
+ }
360
+ }
361
+
362
+ export function createFlowTreeController(options = {}) {
363
+ return new FlowTreeController(options);
364
+ }
@@ -0,0 +1,248 @@
1
+ import type { I18nController, LocaleMessages, LocaleState } from '../i18n/index.js';
2
+ import type { ProcessModel } from '../core/index.js';
3
+ import type { RuntimeSnapshot } from '../runtime/index.js';
4
+
5
+ export type FlowTreeEngine = 'flowable' | 'activiti';
6
+ export type FlowTreeRouteType = 'conditionRoute' | 'parallelRoute' | 'inclusiveRoute';
7
+ export type FlowTreeBranchType = 'conditionBranch' | 'parallelBranch' | 'inclusiveBranch';
8
+ export type FlowTreeBuiltinNodeType =
9
+ | 'starter'
10
+ | 'approver'
11
+ | 'cc'
12
+ | 'handler'
13
+ | FlowTreeRouteType
14
+ | FlowTreeBranchType
15
+ | 'delay'
16
+ | 'trigger'
17
+ | 'subFlow'
18
+ | 'end';
19
+
20
+ export interface FlowTreeTargetRef {
21
+ id: string;
22
+ name: string;
23
+ }
24
+
25
+ export interface FlowTreeTargetGroup {
26
+ users: FlowTreeTargetRef[];
27
+ roles: FlowTreeTargetRef[];
28
+ departments: FlowTreeTargetRef[];
29
+ }
30
+
31
+ export type FlowTreeFormPermission = 'editable' | 'readonly' | 'hidden';
32
+
33
+ export interface FlowTreeConditionRule {
34
+ id: string;
35
+ field: string;
36
+ fieldLabel?: string;
37
+ fieldType?: 'string' | 'number' | 'date' | 'boolean' | 'select' | 'user' | 'department';
38
+ operator: string;
39
+ value?: string;
40
+ valueMax?: string;
41
+ }
42
+
43
+ export interface FlowTreeConditionGroup {
44
+ id: string;
45
+ logic: 'AND' | 'OR';
46
+ rules: FlowTreeConditionRule[];
47
+ }
48
+
49
+ export interface FlowTreeNodeBase {
50
+ id: string;
51
+ type: string;
52
+ name: string;
53
+ config?: Record<string, any>;
54
+ extensionAttributes?: Record<string, string>;
55
+ }
56
+
57
+ export interface FlowTreeBranchNode extends FlowTreeNodeBase {
58
+ type: FlowTreeBranchType;
59
+ priority: number;
60
+ isDefault?: boolean;
61
+ steps: FlowTreeStep[];
62
+ }
63
+
64
+ export interface FlowTreeRouteNode {
65
+ id: string;
66
+ type: FlowTreeRouteType;
67
+ name: string;
68
+ branches: FlowTreeBranchNode[];
69
+ }
70
+
71
+ export type FlowTreeStep = FlowTreeNodeBase | FlowTreeRouteNode;
72
+
73
+ export interface FlowTreeDocument {
74
+ schemaVersion: 1;
75
+ id: string;
76
+ name: string;
77
+ engine: FlowTreeEngine;
78
+ description?: string;
79
+ starter: FlowTreeNodeBase;
80
+ steps: FlowTreeStep[];
81
+ end: FlowTreeNodeBase;
82
+ settings: {
83
+ direction: 'vertical' | 'horizontal';
84
+ starterCompileMode: 'startAndUserTask' | 'startEvent';
85
+ ccCompileMode: 'serviceTask' | 'executionListener';
86
+ autoDeduplicateApprovers: 'none' | 'consecutive' | 'all';
87
+ allowWithdraw: boolean;
88
+ };
89
+ properties?: {
90
+ documentation?: string;
91
+ extensionAttributes?: Record<string, string>;
92
+ };
93
+ }
94
+
95
+ export interface FlowTreeValidationIssue {
96
+ id: string;
97
+ level: 'error' | 'warning';
98
+ code: string;
99
+ nodeId: string | null;
100
+ message: string;
101
+ }
102
+
103
+ export type FlowTreeContainerRef =
104
+ | { kind: 'root' }
105
+ | { kind: 'branch'; branchId: string; routeId?: string }
106
+ | { kind: 'embedded'; subFlowId: string };
107
+
108
+ export type FlowTreeSelection =
109
+ | { kind: 'process'; id: string }
110
+ | { kind: 'node'; id: string };
111
+
112
+ export interface FlowTreeCustomNodeDescriptor {
113
+ type: string;
114
+ label: string;
115
+ description?: string;
116
+ iconId?: string;
117
+ tone?: string;
118
+ group?: string;
119
+ defaultConfig?: Record<string, any> | (() => Record<string, any>);
120
+ formatSummary?: (node: FlowTreeNodeBase, context: { i18n: I18nController }) => string;
121
+ validate?: (node: FlowTreeNodeBase, context: { document: FlowTreeDocument; i18n: I18nController }) => Array<{ level?: 'error' | 'warning'; code?: string; message: string }>;
122
+ compileToBpmn?: (node: FlowTreeNodeBase, context: any) => any;
123
+ }
124
+
125
+ export class FlowTreeNodeRegistry {
126
+ constructor(descriptors?: FlowTreeCustomNodeDescriptor[]);
127
+ register(descriptor: FlowTreeCustomNodeDescriptor): () => void;
128
+ resolve(type: string): any;
129
+ has(type: string): boolean;
130
+ listInsertable(): any[];
131
+ list(): any[];
132
+ }
133
+
134
+ export interface FlowTreeControllerState {
135
+ document: FlowTreeDocument;
136
+ selection: FlowTreeSelection | null;
137
+ selectedNode: FlowTreeNodeBase | FlowTreeRouteNode | null;
138
+ collapsedBranches: string[];
139
+ canUndo: boolean;
140
+ canRedo: boolean;
141
+ engine: FlowTreeEngine;
142
+ nodeCount: number;
143
+ validationIssues: FlowTreeValidationIssue[];
144
+ locale: string;
145
+ }
146
+
147
+ export interface FlowTreeControllerOptions {
148
+ document?: Partial<FlowTreeDocument> | null;
149
+ engine?: FlowTreeEngine;
150
+ historyLimit?: number;
151
+ nodeRegistry?: FlowTreeNodeRegistry | null;
152
+ customNodes?: FlowTreeCustomNodeDescriptor[];
153
+ compiler?: {
154
+ compile?: (doc: FlowTreeDocument, options?: any) => ProcessModel;
155
+ exportXml?: (doc: FlowTreeDocument, engine?: FlowTreeEngine, options?: any) => string;
156
+ importXml?: (xml: string, engine?: FlowTreeEngine, options?: any) => { document: FlowTreeDocument | null; compatible: boolean; diagnostics: any[]; bpmnModel?: ProcessModel };
157
+ } | null;
158
+ i18n?: I18nController | null;
159
+ locale?: string;
160
+ messages?: LocaleMessages;
161
+ }
162
+
163
+ export class FlowTreeController {
164
+ readonly i18n: I18nController;
165
+ readonly nodeRegistry: FlowTreeNodeRegistry;
166
+ readonly document: FlowTreeDocument;
167
+ readonly commands: {
168
+ insertStep(containerRef: FlowTreeContainerRef, index: number, nodeType: string, overrides?: Record<string, any>): FlowTreeStep | null;
169
+ insertRoute(containerRef: FlowTreeContainerRef, index: number, routeType: FlowTreeRouteType, options?: Record<string, any>): FlowTreeRouteNode | null;
170
+ addBranch(routeId: string, overrides?: Record<string, any>): FlowTreeBranchNode | null;
171
+ reorderBranch(routeId: string, fromIndex: number, toIndex: number): boolean;
172
+ duplicateNode(nodeId: string): FlowTreeStep | FlowTreeBranchNode | null;
173
+ removeNode(nodeId: string): boolean;
174
+ moveNode(nodeId: string, targetContainerRef: FlowTreeContainerRef, targetIndex: number): boolean;
175
+ canMoveNode(nodeId: string, targetContainerRef: FlowTreeContainerRef): boolean;
176
+ updateDocument(patch: Partial<FlowTreeDocument>): boolean;
177
+ updateNode(nodeId: string, patch: Record<string, any>): boolean;
178
+ updateNodeConfig(nodeId: string, configPatch: Record<string, any>): boolean;
179
+ setEngine(engine: FlowTreeEngine): boolean;
180
+ select(selection: FlowTreeSelection | null): boolean;
181
+ toggleBranchCollapse(branchId: string): boolean;
182
+ undo(): boolean;
183
+ redo(): boolean;
184
+ };
185
+ constructor(options?: FlowTreeControllerOptions);
186
+ setCompiler(compiler: FlowTreeControllerOptions['compiler']): void;
187
+ setLocale(locale?: string | null, messages?: LocaleMessages | null): LocaleState;
188
+ getLocale(): LocaleState;
189
+ subscribe(listener: (event: { type: string; state: FlowTreeControllerState; [key: string]: any }) => void): () => void;
190
+ getSelectedNode(): FlowTreeNodeBase | FlowTreeRouteNode | null;
191
+ getState(): FlowTreeControllerState;
192
+ setDocument(nextDocument: Partial<FlowTreeDocument>, options?: { resetHistory?: boolean }): FlowTreeDocument;
193
+ select(selection: FlowTreeSelection | null): boolean;
194
+ insertStep(containerRef: FlowTreeContainerRef, index: number, nodeType: string, overrides?: Record<string, any>): FlowTreeStep | null;
195
+ insertRoute(containerRef: FlowTreeContainerRef, index: number, routeType: FlowTreeRouteType, options?: Record<string, any>): FlowTreeRouteNode | null;
196
+ addBranch(routeId: string, overrides?: Record<string, any>): FlowTreeBranchNode | null;
197
+ reorderBranch(routeId: string, fromIndex: number, toIndex: number): boolean;
198
+ duplicateNode(nodeId: string): FlowTreeStep | FlowTreeBranchNode | null;
199
+ removeNode(nodeId: string): boolean;
200
+ canMoveNode(nodeId: string, targetContainerRef: FlowTreeContainerRef): boolean;
201
+ moveNode(nodeId: string, targetContainerRef: FlowTreeContainerRef, targetIndex: number): boolean;
202
+ updateDocument(patch: Partial<FlowTreeDocument>): boolean;
203
+ updateNode(nodeId: string, patch: Record<string, any>): boolean;
204
+ updateNodeConfig(nodeId: string, configPatch: Record<string, any>): boolean;
205
+ setEngine(engine: FlowTreeEngine): boolean;
206
+ isBranchCollapsed(branchId: string): boolean;
207
+ toggleBranchCollapse(branchId: string): boolean;
208
+ validate(): FlowTreeValidationIssue[];
209
+ undo(): boolean;
210
+ redo(): boolean;
211
+ toJSON(): FlowTreeDocument;
212
+ fromJSON(json: string | Partial<FlowTreeDocument>, options?: { resetHistory?: boolean }): FlowTreeDocument;
213
+ compileToBpmn(options?: Record<string, any>): ProcessModel;
214
+ exportXml(engine?: FlowTreeEngine, options?: Record<string, any>): string;
215
+ importXml(xml: string, engine?: FlowTreeEngine, options?: Record<string, any>): { document: FlowTreeDocument | null; compatible: boolean; diagnostics: any[]; bpmnModel?: ProcessModel };
216
+ destroy(): void;
217
+ }
218
+
219
+ export const FLOW_TREE_SCHEMA_VERSION: 1;
220
+ export const FLOW_TREE_ROUTE_TYPES: readonly FlowTreeRouteType[];
221
+ export const FLOW_TREE_BRANCH_TYPES: readonly FlowTreeBranchType[];
222
+ export const CONDITION_OPERATORS: readonly any[];
223
+ export const FLOW_TREE_NODE_DEFINITIONS: Record<string, any>;
224
+
225
+ export function createDefaultFlowTreeNodeRegistry(customTypes?: FlowTreeCustomNodeDescriptor[]): FlowTreeNodeRegistry;
226
+ export function createFlowTreeController(options?: FlowTreeControllerOptions): FlowTreeController;
227
+ export function createEmptyFlowTree(engine?: FlowTreeEngine, options?: any): FlowTreeDocument;
228
+ export function createSampleFlowTree(engine?: FlowTreeEngine, options?: any): FlowTreeDocument;
229
+ export function createSampleFlowTreeRuntime(doc?: FlowTreeDocument | null, options?: any): RuntimeSnapshot;
230
+ export function createSampleFlowTreeDataProviders(options?: any): Record<string, any>;
231
+ export function createFlowTreeNode(type: string, overrides?: Record<string, any>, options?: any): FlowTreeStep;
232
+ export function createFlowTreeRoute(routeType: FlowTreeRouteType, overrides?: Record<string, any>, options?: any): FlowTreeRouteNode;
233
+ export function createFlowTreeBranch(routeType: FlowTreeRouteType, overrides?: Record<string, any>, options?: any): FlowTreeBranchNode;
234
+ export function createEmptyConditionGroup(overrides?: Partial<FlowTreeConditionGroup>): FlowTreeConditionGroup;
235
+ export function createEmptyConditionRule(overrides?: Partial<FlowTreeConditionRule>): FlowTreeConditionRule;
236
+ export function normalizeFlowTreeDocument(input: Partial<FlowTreeDocument>, options?: any): FlowTreeDocument;
237
+ export function cloneFlowTree<T>(value: T): T;
238
+ export function isRouteNode(node: any): node is FlowTreeRouteNode;
239
+ export function isBranchNode(node: any): node is FlowTreeBranchNode;
240
+ export function walkFlowTree(doc: FlowTreeDocument, visitor: (node: any, info: any) => void): void;
241
+ export function collectAllFlowTreeNodes(doc: FlowTreeDocument): any[];
242
+ export function findFlowTreeNode(doc: FlowTreeDocument, nodeId: string): any;
243
+ export function findFlowTreeNodeLocation(doc: FlowTreeDocument, nodeId: string): any;
244
+ export function countFlowTreeVisibleCards(doc: FlowTreeDocument): number;
245
+ export function countBranchSteps(branch: FlowTreeBranchNode): number;
246
+ export function formatFlowTreeNodeSummary(node: any, options?: any): string;
247
+ export function validateFlowTree(doc: FlowTreeDocument, options?: any): FlowTreeValidationIssue[];
248
+ export function resolveFlowTreeTypeLabel(type: string, options?: any): string;
@@ -0,0 +1,5 @@
1
+ export * from './schema.js';
2
+ export * from './operations.js';
3
+ export * from './validate.js';
4
+ export * from './sample.js';
5
+ export * from './controller.js';