@bpmn-nova/studio 0.4.0 → 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 (32) hide show
  1. package/README.md +1 -1
  2. package/dist/flow-tree.d.ts +4 -0
  3. package/dist/flow-tree.js +14 -0
  4. package/dist/modules/flow-tree/controller.js +364 -0
  5. package/dist/modules/flow-tree/index.d.ts +248 -0
  6. package/dist/modules/flow-tree/index.js +5 -0
  7. package/dist/modules/flow-tree/operations.js +484 -0
  8. package/dist/modules/flow-tree/sample.js +445 -0
  9. package/dist/modules/flow-tree/schema.js +588 -0
  10. package/dist/modules/flow-tree/validate.js +125 -0
  11. package/dist/modules/flow-tree-bpmn/compiler.js +547 -0
  12. package/dist/modules/flow-tree-bpmn/decompiler.js +524 -0
  13. package/dist/modules/flow-tree-bpmn/expression.js +135 -0
  14. package/dist/modules/flow-tree-bpmn/index.d.ts +53 -0
  15. package/dist/modules/flow-tree-bpmn/index.js +14 -0
  16. package/dist/modules/flow-tree-renderer/canvas.js +1003 -0
  17. package/dist/modules/flow-tree-renderer/export-svg.js +325 -0
  18. package/dist/modules/flow-tree-renderer/index.d.ts +143 -0
  19. package/dist/modules/flow-tree-renderer/index.js +3 -0
  20. package/dist/modules/flow-tree-renderer/shell.js +970 -0
  21. package/dist/modules/i18n/locales/en-US.js +399 -0
  22. package/dist/modules/i18n/locales/zh-CN.js +399 -0
  23. package/dist/modules/icons/index.js +23 -0
  24. package/dist/modules/properties-flow-tree/index.d.ts +56 -0
  25. package/dist/modules/properties-flow-tree/index.js +2 -0
  26. package/dist/modules/properties-flow-tree/panel.js +1136 -0
  27. package/dist/modules/properties-flow-tree/widgets.js +625 -0
  28. package/dist/modules/viewer/index.js +10 -2
  29. package/dist/styles.css +2368 -0
  30. package/llms-full.txt +353 -9
  31. package/llms.txt +3 -2
  32. package/package.json +6 -1
@@ -0,0 +1,588 @@
1
+ import { DEFAULT_I18N, resolveI18n } from '../i18n/index.js';
2
+
3
+ export const FLOW_TREE_SCHEMA_VERSION = 1;
4
+
5
+ export const FLOW_TREE_ROUTE_TYPES = Object.freeze(['conditionRoute', 'parallelRoute', 'inclusiveRoute']);
6
+ export const FLOW_TREE_BRANCH_TYPES = Object.freeze(['conditionBranch', 'parallelBranch', 'inclusiveBranch']);
7
+
8
+ export const ROUTE_TO_BRANCH_TYPE = Object.freeze({
9
+ conditionRoute: 'conditionBranch',
10
+ parallelRoute: 'parallelBranch',
11
+ inclusiveRoute: 'inclusiveBranch',
12
+ });
13
+
14
+ export const CONDITION_OPERATORS = Object.freeze([
15
+ { value: 'eq', unary: false, range: false, multi: false, types: ['string', 'number', 'date', 'boolean', 'select', 'user', 'department'] },
16
+ { value: 'neq', unary: false, range: false, multi: false, types: ['string', 'number', 'date', 'boolean', 'select', 'user', 'department'] },
17
+ { value: 'gt', unary: false, range: false, multi: false, types: ['number', 'date'] },
18
+ { value: 'gte', unary: false, range: false, multi: false, types: ['number', 'date'] },
19
+ { value: 'lt', unary: false, range: false, multi: false, types: ['number', 'date'] },
20
+ { value: 'lte', unary: false, range: false, multi: false, types: ['number', 'date'] },
21
+ { value: 'between', unary: false, range: true, multi: false, types: ['number', 'date'] },
22
+ { value: 'in', unary: false, range: false, multi: true, types: ['string', 'number', 'select', 'user', 'department'] },
23
+ { value: 'notIn', unary: false, range: false, multi: true, types: ['string', 'number', 'select', 'user', 'department'] },
24
+ { value: 'contains', unary: false, range: false, multi: false, types: ['string'] },
25
+ { value: 'notContains', unary: false, range: false, multi: false, types: ['string'] },
26
+ { value: 'isEmpty', unary: true, range: false, multi: false, types: ['string', 'number', 'date', 'select', 'user', 'department'] },
27
+ { value: 'isNotEmpty', unary: true, range: false, multi: false, types: ['string', 'number', 'date', 'select', 'user', 'department'] },
28
+ { value: 'belongsToDept', unary: false, range: false, multi: true, types: ['user', 'department', 'string'] },
29
+ { value: 'hasRole', unary: false, range: false, multi: true, types: ['user', 'string'] },
30
+ ]);
31
+
32
+ export const FLOW_TREE_NODE_DEFINITIONS = Object.freeze({
33
+ starter: Object.freeze({
34
+ type: 'starter',
35
+ kind: 'starter',
36
+ iconId: 'flowTree.starter',
37
+ tone: 'primary',
38
+ insertable: false,
39
+ deletable: false,
40
+ draggable: false,
41
+ }),
42
+ approver: Object.freeze({
43
+ type: 'approver',
44
+ kind: 'step',
45
+ iconId: 'flowTree.approver',
46
+ tone: 'user-task',
47
+ insertable: true,
48
+ group: 'approval',
49
+ deletable: true,
50
+ draggable: true,
51
+ }),
52
+ cc: Object.freeze({
53
+ type: 'cc',
54
+ kind: 'step',
55
+ iconId: 'flowTree.cc',
56
+ tone: 'info',
57
+ insertable: true,
58
+ group: 'approval',
59
+ deletable: true,
60
+ draggable: true,
61
+ }),
62
+ handler: Object.freeze({
63
+ type: 'handler',
64
+ kind: 'step',
65
+ iconId: 'flowTree.handler',
66
+ tone: 'message-task',
67
+ insertable: true,
68
+ group: 'approval',
69
+ deletable: true,
70
+ draggable: true,
71
+ }),
72
+ conditionRoute: Object.freeze({
73
+ type: 'conditionRoute',
74
+ kind: 'route',
75
+ branchType: 'conditionBranch',
76
+ iconId: 'flowTree.conditionRoute',
77
+ tone: 'success',
78
+ insertable: true,
79
+ group: 'routing',
80
+ deletable: true,
81
+ draggable: true,
82
+ hasDefaultBranch: true,
83
+ }),
84
+ conditionBranch: Object.freeze({
85
+ type: 'conditionBranch',
86
+ kind: 'branch',
87
+ routeType: 'conditionRoute',
88
+ iconId: 'flowTree.conditionRoute',
89
+ tone: 'success',
90
+ insertable: false,
91
+ deletable: true,
92
+ draggable: false,
93
+ }),
94
+ parallelRoute: Object.freeze({
95
+ type: 'parallelRoute',
96
+ kind: 'route',
97
+ branchType: 'parallelBranch',
98
+ iconId: 'flowTree.parallelRoute',
99
+ tone: 'script-task',
100
+ insertable: true,
101
+ group: 'routing',
102
+ deletable: true,
103
+ draggable: true,
104
+ hasDefaultBranch: false,
105
+ }),
106
+ parallelBranch: Object.freeze({
107
+ type: 'parallelBranch',
108
+ kind: 'branch',
109
+ routeType: 'parallelRoute',
110
+ iconId: 'flowTree.parallelRoute',
111
+ tone: 'script-task',
112
+ insertable: false,
113
+ deletable: true,
114
+ draggable: false,
115
+ }),
116
+ inclusiveRoute: Object.freeze({
117
+ type: 'inclusiveRoute',
118
+ kind: 'route',
119
+ branchType: 'inclusiveBranch',
120
+ iconId: 'flowTree.inclusiveRoute',
121
+ tone: 'rule-task',
122
+ insertable: true,
123
+ group: 'routing',
124
+ deletable: true,
125
+ draggable: true,
126
+ hasDefaultBranch: true,
127
+ }),
128
+ inclusiveBranch: Object.freeze({
129
+ type: 'inclusiveBranch',
130
+ kind: 'branch',
131
+ routeType: 'inclusiveRoute',
132
+ iconId: 'flowTree.inclusiveRoute',
133
+ tone: 'rule-task',
134
+ insertable: false,
135
+ deletable: true,
136
+ draggable: false,
137
+ }),
138
+ delay: Object.freeze({
139
+ type: 'delay',
140
+ kind: 'step',
141
+ iconId: 'flowTree.delay',
142
+ tone: 'warning',
143
+ insertable: true,
144
+ group: 'automation',
145
+ deletable: true,
146
+ draggable: true,
147
+ }),
148
+ trigger: Object.freeze({
149
+ type: 'trigger',
150
+ kind: 'step',
151
+ iconId: 'flowTree.trigger',
152
+ tone: 'service-task',
153
+ insertable: true,
154
+ group: 'automation',
155
+ deletable: true,
156
+ draggable: true,
157
+ }),
158
+ subFlow: Object.freeze({
159
+ type: 'subFlow',
160
+ kind: 'step',
161
+ iconId: 'flowTree.subFlow',
162
+ tone: 'manual-task',
163
+ insertable: true,
164
+ group: 'automation',
165
+ deletable: true,
166
+ draggable: true,
167
+ }),
168
+ end: Object.freeze({
169
+ type: 'end',
170
+ kind: 'end',
171
+ iconId: 'flowTree.end',
172
+ tone: 'neutral',
173
+ insertable: false,
174
+ deletable: false,
175
+ draggable: false,
176
+ }),
177
+ });
178
+
179
+ let idCounter = 0;
180
+
181
+ export function flowTreeUid(prefix = 'Node') {
182
+ idCounter += 1;
183
+ const safePrefix = String(prefix || 'Node').replace(/[^A-Za-z0-9_]/g, '_');
184
+ return `${safePrefix}_${Date.now().toString(36)}_${idCounter.toString(36)}`;
185
+ }
186
+
187
+ export function cloneFlowTree(value) {
188
+ if (value === undefined) return undefined;
189
+ return JSON.parse(JSON.stringify(value));
190
+ }
191
+
192
+ export function isRouteNode(node) {
193
+ return Boolean(node && FLOW_TREE_ROUTE_TYPES.includes(node.type));
194
+ }
195
+
196
+ export function isBranchNode(node) {
197
+ return Boolean(node && FLOW_TREE_BRANCH_TYPES.includes(node.type));
198
+ }
199
+
200
+ export function createEmptyConditionRule(overrides = {}) {
201
+ return {
202
+ id: overrides.id || flowTreeUid('Rule'),
203
+ field: '',
204
+ fieldLabel: '',
205
+ fieldType: 'string',
206
+ operator: 'eq',
207
+ value: '',
208
+ valueMax: '',
209
+ ...overrides,
210
+ };
211
+ }
212
+
213
+ export function createEmptyConditionGroup(overrides = {}) {
214
+ return {
215
+ id: overrides.id || flowTreeUid('CondGroup'),
216
+ logic: 'AND',
217
+ rules: [createEmptyConditionRule()],
218
+ ...overrides,
219
+ };
220
+ }
221
+
222
+ export function defaultTargets(overrides = {}) {
223
+ return {
224
+ users: [],
225
+ roles: [],
226
+ departments: [],
227
+ ...overrides,
228
+ };
229
+ }
230
+
231
+ export function defaultNodeConfig(type, overrides = {}) {
232
+ let base = {};
233
+ if (type === 'starter') {
234
+ base = {
235
+ starterScope: 'all',
236
+ targets: defaultTargets(),
237
+ allowResubmit: true,
238
+ formPermissions: {},
239
+ };
240
+ } else if (type === 'approver') {
241
+ base = {
242
+ assigneeType: 'users',
243
+ targets: defaultTargets(),
244
+ supervisorLevel: 1,
245
+ supervisorEndLevel: 2,
246
+ formUserField: '',
247
+ expression: '',
248
+ selfSelectMultiple: false,
249
+ approvalMode: 'or',
250
+ passPercentage: 60,
251
+ emptyStrategy: 'autoPass',
252
+ fallbackUsers: [],
253
+ sameAsInitiatorStrategy: 'default',
254
+ dedupStrategy: 'inherit',
255
+ timeout: {
256
+ enabled: false,
257
+ duration: 24,
258
+ unit: 'hour',
259
+ action: 'remind',
260
+ },
261
+ buttons: {
262
+ approve: true,
263
+ reject: true,
264
+ returnEnabled: true,
265
+ returnMode: 'previous',
266
+ returnTargetIds: [],
267
+ transfer: true,
268
+ addSign: false,
269
+ delegate: false,
270
+ commentRequiredOnReject: true,
271
+ },
272
+ formPermissions: {},
273
+ };
274
+ } else if (type === 'cc') {
275
+ base = {
276
+ assigneeType: 'users',
277
+ targets: defaultTargets(),
278
+ supervisorLevel: 1,
279
+ formUserField: '',
280
+ allowStarterSelfSelect: false,
281
+ ccTiming: 'onArrive',
282
+ delegateExpression: '${novaCcDelegate}',
283
+ formPermissions: {},
284
+ };
285
+ } else if (type === 'handler') {
286
+ base = {
287
+ assigneeType: 'users',
288
+ targets: defaultTargets(),
289
+ supervisorLevel: 1,
290
+ formUserField: '',
291
+ expression: '',
292
+ completionMode: 'or',
293
+ emptyStrategy: 'toAdmin',
294
+ fallbackUsers: [],
295
+ timeout: {
296
+ enabled: false,
297
+ duration: 24,
298
+ unit: 'hour',
299
+ action: 'remind',
300
+ },
301
+ buttons: {
302
+ complete: true,
303
+ transfer: true,
304
+ returnEnabled: false,
305
+ returnMode: 'previous',
306
+ },
307
+ formPermissions: {},
308
+ };
309
+ } else if (type === 'conditionBranch' || type === 'inclusiveBranch') {
310
+ base = {
311
+ mode: 'visual',
312
+ conditionGroups: [],
313
+ expression: '',
314
+ };
315
+ } else if (type === 'parallelBranch') {
316
+ base = {};
317
+ } else if (type === 'delay') {
318
+ base = {
319
+ delayType: 'duration',
320
+ duration: 1,
321
+ unit: 'hour',
322
+ fixedDate: '',
323
+ cronExpression: '',
324
+ };
325
+ } else if (type === 'trigger') {
326
+ base = {
327
+ triggerType: 'webhook',
328
+ method: 'POST',
329
+ url: '',
330
+ headers: [],
331
+ bodyTemplate: '{\n "processInstanceId": "${execution.processInstanceId}"\n}',
332
+ implementation: '',
333
+ resultVariable: '',
334
+ async: true,
335
+ retryCycle: 'R3/PT5M',
336
+ fields: [],
337
+ };
338
+ } else if (type === 'subFlow') {
339
+ base = {
340
+ subFlowMode: 'callActivity',
341
+ calledElement: '',
342
+ inheritBusinessKey: true,
343
+ inheritVariables: true,
344
+ inParameters: [],
345
+ outParameters: [],
346
+ steps: [],
347
+ };
348
+ } else if (type === 'end') {
349
+ base = {
350
+ documentation: '',
351
+ };
352
+ }
353
+
354
+ return deepMergePlain(base, overrides);
355
+ }
356
+
357
+ function isPlainObject(value) {
358
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
359
+ }
360
+
361
+ function deepMergePlain(base, patch) {
362
+ if (!isPlainObject(patch)) return cloneFlowTree(base);
363
+ const result = isPlainObject(base) ? cloneFlowTree(base) : {};
364
+ for (const [key, value] of Object.entries(patch)) {
365
+ if (value === undefined) continue;
366
+ if (isPlainObject(value) && isPlainObject(result[key])) {
367
+ result[key] = deepMergePlain(result[key], value);
368
+ } else {
369
+ result[key] = cloneFlowTree(value);
370
+ }
371
+ }
372
+ return result;
373
+ }
374
+
375
+ export class FlowTreeNodeRegistry {
376
+ constructor(descriptors = []) {
377
+ this._definitions = new Map();
378
+ for (const def of Object.values(FLOW_TREE_NODE_DEFINITIONS)) {
379
+ this._definitions.set(def.type, def);
380
+ }
381
+ for (const descriptor of descriptors) this.register(descriptor);
382
+ }
383
+
384
+ register(descriptor) {
385
+ if (!descriptor?.type) throw new Error('Custom FlowTree node type requires a non-empty type.');
386
+ const normalized = Object.freeze({
387
+ kind: 'step',
388
+ iconId: 'flowTree.trigger',
389
+ tone: 'primary',
390
+ insertable: true,
391
+ group: 'custom',
392
+ deletable: true,
393
+ draggable: true,
394
+ ...descriptor,
395
+ });
396
+ this._definitions.set(normalized.type, normalized);
397
+ return () => {
398
+ if (!FLOW_TREE_NODE_DEFINITIONS[normalized.type]) this._definitions.delete(normalized.type);
399
+ };
400
+ }
401
+
402
+ resolve(type) {
403
+ return this._definitions.get(type) || null;
404
+ }
405
+
406
+ has(type) {
407
+ return this._definitions.has(type);
408
+ }
409
+
410
+ listInsertable() {
411
+ return [...this._definitions.values()].filter((item) => item.insertable);
412
+ }
413
+
414
+ list() {
415
+ return [...this._definitions.values()];
416
+ }
417
+ }
418
+
419
+ export function createDefaultFlowTreeNodeRegistry(customTypes = []) {
420
+ return new FlowTreeNodeRegistry(customTypes);
421
+ }
422
+
423
+ export function resolveFlowTreeTypeLabel(type, options = null) {
424
+ const registry = options?.nodeRegistry;
425
+ const custom = registry?.resolve?.(type);
426
+ if (custom?.label && !FLOW_TREE_NODE_DEFINITIONS[type]) return custom.label;
427
+ const i18n = resolveI18n(options);
428
+ return i18n.t(`flowTree.nodeTypes.${type}`) || custom?.label || type;
429
+ }
430
+
431
+ export function createFlowTreeBranch(routeType, overrides = {}, options = null) {
432
+ const i18n = resolveI18n(options);
433
+ const branchType = ROUTE_TO_BRANCH_TYPE[routeType] || 'conditionBranch';
434
+ const isDefault = Boolean(overrides.isDefault);
435
+ const priority = Number.isInteger(overrides.priority) ? overrides.priority : 1;
436
+ let defaultName = i18n.t('flowTree.canvas.branchName', { index: priority });
437
+ if (isDefault) defaultName = i18n.t('flowTree.canvas.defaultBranchName');
438
+ else if (routeType === 'parallelRoute') defaultName = i18n.t('flowTree.canvas.parallelBranchName', { index: priority });
439
+ else if (routeType === 'inclusiveRoute') defaultName = i18n.t('flowTree.canvas.inclusiveBranchName', { index: priority });
440
+
441
+ return {
442
+ id: overrides.id || flowTreeUid(branchType === 'parallelBranch' ? 'Parallel' : 'Branch'),
443
+ type: branchType,
444
+ name: overrides.name || defaultName,
445
+ priority,
446
+ isDefault,
447
+ config: defaultNodeConfig(branchType, overrides.config || {}),
448
+ steps: Array.isArray(overrides.steps) ? cloneFlowTree(overrides.steps) : [],
449
+ };
450
+ }
451
+
452
+ export function createFlowTreeRoute(routeType = 'conditionRoute', overrides = {}, options = null) {
453
+ const def = FLOW_TREE_NODE_DEFINITIONS[routeType] || FLOW_TREE_NODE_DEFINITIONS.conditionRoute;
454
+ const hasDefault = Boolean(def.hasDefaultBranch);
455
+ const branchCount = Math.max(2, overrides.branchCount || 2);
456
+ let branches;
457
+ if (Array.isArray(overrides.branches) && overrides.branches.length >= 2) {
458
+ branches = overrides.branches.map((branch, index) => createFlowTreeBranch(routeType, {
459
+ ...branch,
460
+ priority: index + 1,
461
+ isDefault: hasDefault ? Boolean(branch.isDefault) : false,
462
+ }, options));
463
+ if (hasDefault && !branches.some((item) => item.isDefault)) {
464
+ branches[branches.length - 1].isDefault = true;
465
+ }
466
+ } else {
467
+ branches = [];
468
+ for (let i = 0; i < branchCount; i += 1) {
469
+ const isDefault = hasDefault && i === branchCount - 1;
470
+ branches.push(createFlowTreeBranch(routeType, { priority: i + 1, isDefault }, options));
471
+ }
472
+ }
473
+ return {
474
+ id: overrides.id || flowTreeUid(routeType === 'parallelRoute' ? 'ParallelRoute' : routeType === 'inclusiveRoute' ? 'InclusiveRoute' : 'ConditionRoute'),
475
+ type: def.type,
476
+ name: overrides.name || resolveFlowTreeTypeLabel(def.type, options),
477
+ branches,
478
+ };
479
+ }
480
+
481
+ export function createFlowTreeNode(type, overrides = {}, options = null) {
482
+ if (FLOW_TREE_ROUTE_TYPES.includes(type)) {
483
+ return createFlowTreeRoute(type, overrides, options);
484
+ }
485
+ const registry = options?.nodeRegistry;
486
+ const def = registry?.resolve?.(type) || FLOW_TREE_NODE_DEFINITIONS[type];
487
+ const baseConfig = typeof def?.defaultConfig === 'function'
488
+ ? def.defaultConfig()
489
+ : (def?.defaultConfig ? cloneFlowTree(def.defaultConfig) : defaultNodeConfig(type));
490
+ const prefixMap = {
491
+ starter: 'Starter',
492
+ approver: 'Approver',
493
+ cc: 'Cc',
494
+ handler: 'Handler',
495
+ delay: 'Delay',
496
+ trigger: 'Trigger',
497
+ subFlow: 'SubFlow',
498
+ end: 'End',
499
+ };
500
+ return {
501
+ id: overrides.id || flowTreeUid(prefixMap[type] || type),
502
+ type,
503
+ name: overrides.name || resolveFlowTreeTypeLabel(type, options),
504
+ config: deepMergePlain(baseConfig, overrides.config || {}),
505
+ ...(overrides.extensionAttributes ? { extensionAttributes: cloneFlowTree(overrides.extensionAttributes) } : {}),
506
+ };
507
+ }
508
+
509
+ export function normalizeBranchPriorities(route) {
510
+ if (!isRouteNode(route) || !Array.isArray(route.branches)) return;
511
+ const def = FLOW_TREE_NODE_DEFINITIONS[route.type];
512
+ if (def?.hasDefaultBranch) {
513
+ const regulars = route.branches.filter((branch) => !branch.isDefault);
514
+ const defaults = route.branches.filter((branch) => branch.isDefault);
515
+ if (defaults.length > 0) {
516
+ const defaultBranch = defaults[0];
517
+ const extras = defaults.slice(1).map((branch) => ({ ...branch, isDefault: false }));
518
+ route.branches = [...regulars, ...extras, defaultBranch];
519
+ }
520
+ }
521
+ route.branches.forEach((branch, index) => {
522
+ branch.priority = index + 1;
523
+ });
524
+ }
525
+
526
+ function normalizeStep(step, options) {
527
+ if (!step || typeof step !== 'object') return null;
528
+ if (isRouteNode(step)) {
529
+ const normalized = createFlowTreeRoute(step.type, {
530
+ id: step.id,
531
+ name: step.name,
532
+ branches: (step.branches || []).map((branch, index) => ({
533
+ ...branch,
534
+ priority: index + 1,
535
+ steps: (branch.steps || []).map((child) => normalizeStep(child, options)).filter(Boolean),
536
+ })),
537
+ }, options);
538
+ normalizeBranchPriorities(normalized);
539
+ return normalized;
540
+ }
541
+ const normalized = createFlowTreeNode(step.type || 'approver', step, options);
542
+ if (normalized.type === 'subFlow' && Array.isArray(normalized.config?.steps)) {
543
+ normalized.config.steps = normalized.config.steps.map((child) => normalizeStep(child, options)).filter(Boolean);
544
+ }
545
+ return normalized;
546
+ }
547
+
548
+ export function normalizeFlowTreeDocument(input, options = null) {
549
+ const i18n = resolveI18n(options);
550
+ const source = isPlainObject(input) ? input : {};
551
+ const engine = source.engine === 'activiti' ? 'activiti' : 'flowable';
552
+ const starter = createFlowTreeNode('starter', {
553
+ id: source.starter?.id || 'Starter_1',
554
+ name: source.starter?.name || i18n.t('flowTree.defaultStarterName'),
555
+ config: source.starter?.config || {},
556
+ }, { ...options, i18n });
557
+ const end = createFlowTreeNode('end', {
558
+ id: source.end?.id || 'End_1',
559
+ name: source.end?.name || i18n.t('flowTree.defaultEndName'),
560
+ config: source.end?.config || {},
561
+ }, { ...options, i18n });
562
+
563
+ return {
564
+ schemaVersion: FLOW_TREE_SCHEMA_VERSION,
565
+ id: String(source.id || 'Process_Approval_1').trim() || 'Process_Approval_1',
566
+ name: String(source.name || i18n.t('flowTree.defaultProcessName')),
567
+ engine,
568
+ description: String(source.description || ''),
569
+ starter,
570
+ steps: Array.isArray(source.steps) ? source.steps.map((step) => normalizeStep(step, { ...options, i18n })).filter(Boolean) : [],
571
+ end,
572
+ settings: {
573
+ direction: source.settings?.direction === 'horizontal' ? 'horizontal' : 'vertical',
574
+ starterCompileMode: source.settings?.starterCompileMode === 'startEvent' ? 'startEvent' : 'startAndUserTask',
575
+ ccCompileMode: source.settings?.ccCompileMode === 'executionListener' ? 'executionListener' : 'serviceTask',
576
+ autoDeduplicateApprovers: ['none', 'consecutive', 'all'].includes(source.settings?.autoDeduplicateApprovers)
577
+ ? source.settings.autoDeduplicateApprovers
578
+ : 'none',
579
+ allowWithdraw: source.settings?.allowWithdraw !== false,
580
+ },
581
+ properties: {
582
+ documentation: String(source.properties?.documentation || ''),
583
+ extensionAttributes: isPlainObject(source.properties?.extensionAttributes)
584
+ ? cloneFlowTree(source.properties.extensionAttributes)
585
+ : {},
586
+ },
587
+ };
588
+ }