eventmodeler 0.5.0 → 0.6.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 (150) hide show
  1. package/dist/index.js +6776 -2132
  2. package/package.json +11 -5
  3. package/dist/api/index.d.ts +0 -285
  4. package/dist/api/index.js +0 -323
  5. package/dist/cloud/slices/index.d.ts +0 -276
  6. package/dist/cloud/slices/index.js +0 -406
  7. package/dist/eventmodeler.js +0 -5646
  8. package/dist/formatters.d.ts +0 -17
  9. package/dist/formatters.js +0 -482
  10. package/dist/index.d.ts +0 -2
  11. package/dist/lib/auth.d.ts +0 -24
  12. package/dist/lib/auth.js +0 -331
  13. package/dist/lib/backend.d.ts +0 -43
  14. package/dist/lib/backend.js +0 -73
  15. package/dist/lib/chapter-utils.d.ts +0 -13
  16. package/dist/lib/chapter-utils.js +0 -71
  17. package/dist/lib/cloud-client.d.ts +0 -69
  18. package/dist/lib/cloud-client.js +0 -364
  19. package/dist/lib/config.d.ts +0 -30
  20. package/dist/lib/config.js +0 -95
  21. package/dist/lib/diff/merge-rules.d.ts +0 -45
  22. package/dist/lib/diff/merge-rules.js +0 -210
  23. package/dist/lib/diff/model-differ.d.ts +0 -8
  24. package/dist/lib/diff/model-differ.js +0 -568
  25. package/dist/lib/diff/three-way-merge.d.ts +0 -7
  26. package/dist/lib/diff/three-way-merge.js +0 -390
  27. package/dist/lib/diff/types.d.ts +0 -75
  28. package/dist/lib/diff/types.js +0 -1
  29. package/dist/lib/element-lookup.d.ts +0 -58
  30. package/dist/lib/element-lookup.js +0 -126
  31. package/dist/lib/file-loader.d.ts +0 -8
  32. package/dist/lib/file-loader.js +0 -108
  33. package/dist/lib/flow-utils.d.ts +0 -53
  34. package/dist/lib/flow-utils.js +0 -348
  35. package/dist/lib/format.d.ts +0 -10
  36. package/dist/lib/format.js +0 -23
  37. package/dist/lib/project-config.d.ts +0 -27
  38. package/dist/lib/project-config.js +0 -83
  39. package/dist/lib/slice-utils.d.ts +0 -59
  40. package/dist/lib/slice-utils.js +0 -140
  41. package/dist/local/slices/index.d.ts +0 -11
  42. package/dist/local/slices/index.js +0 -13
  43. package/dist/projection.d.ts +0 -3
  44. package/dist/projection.js +0 -828
  45. package/dist/slices/add-field/index.d.ts +0 -8
  46. package/dist/slices/add-field/index.js +0 -211
  47. package/dist/slices/add-scenario/index.d.ts +0 -27
  48. package/dist/slices/add-scenario/index.js +0 -307
  49. package/dist/slices/codegen-chapter-events/index.d.ts +0 -2
  50. package/dist/slices/codegen-chapter-events/index.js +0 -145
  51. package/dist/slices/codegen-slice/index.d.ts +0 -2
  52. package/dist/slices/codegen-slice/index.js +0 -448
  53. package/dist/slices/create-automation-slice/index.d.ts +0 -2
  54. package/dist/slices/create-automation-slice/index.js +0 -304
  55. package/dist/slices/create-flow/index.d.ts +0 -2
  56. package/dist/slices/create-flow/index.js +0 -183
  57. package/dist/slices/create-state-change-slice/index.d.ts +0 -2
  58. package/dist/slices/create-state-change-slice/index.js +0 -263
  59. package/dist/slices/create-state-view-slice/index.d.ts +0 -2
  60. package/dist/slices/create-state-view-slice/index.js +0 -128
  61. package/dist/slices/diff/index.d.ts +0 -11
  62. package/dist/slices/diff/index.js +0 -293
  63. package/dist/slices/export-eventmodel-to-json/index.d.ts +0 -2
  64. package/dist/slices/export-eventmodel-to-json/index.js +0 -355
  65. package/dist/slices/git/index.d.ts +0 -2
  66. package/dist/slices/git/index.js +0 -125
  67. package/dist/slices/guide/guides/codegen.d.ts +0 -5
  68. package/dist/slices/guide/guides/codegen.js +0 -339
  69. package/dist/slices/guide/guides/connect-slices.d.ts +0 -5
  70. package/dist/slices/guide/guides/connect-slices.js +0 -202
  71. package/dist/slices/guide/guides/create-slices.d.ts +0 -5
  72. package/dist/slices/guide/guides/create-slices.js +0 -303
  73. package/dist/slices/guide/guides/explore.d.ts +0 -5
  74. package/dist/slices/guide/guides/explore.js +0 -251
  75. package/dist/slices/guide/guides/information-flow.d.ts +0 -5
  76. package/dist/slices/guide/guides/information-flow.js +0 -318
  77. package/dist/slices/guide/guides/scenarios.d.ts +0 -5
  78. package/dist/slices/guide/guides/scenarios.js +0 -269
  79. package/dist/slices/guide/index.d.ts +0 -1
  80. package/dist/slices/guide/index.js +0 -40
  81. package/dist/slices/import/index.d.ts +0 -8
  82. package/dist/slices/import/index.js +0 -63
  83. package/dist/slices/init/index.d.ts +0 -5
  84. package/dist/slices/init/index.js +0 -80
  85. package/dist/slices/list-chapters/index.d.ts +0 -3
  86. package/dist/slices/list-chapters/index.js +0 -21
  87. package/dist/slices/list-commands/index.d.ts +0 -3
  88. package/dist/slices/list-commands/index.js +0 -20
  89. package/dist/slices/list-events/index.d.ts +0 -3
  90. package/dist/slices/list-events/index.js +0 -98
  91. package/dist/slices/list-processors/index.d.ts +0 -3
  92. package/dist/slices/list-processors/index.js +0 -20
  93. package/dist/slices/list-readmodels/index.d.ts +0 -3
  94. package/dist/slices/list-readmodels/index.js +0 -21
  95. package/dist/slices/list-scenarios/index.d.ts +0 -3
  96. package/dist/slices/list-scenarios/index.js +0 -35
  97. package/dist/slices/list-screens/index.d.ts +0 -3
  98. package/dist/slices/list-screens/index.js +0 -47
  99. package/dist/slices/list-slices/index.d.ts +0 -3
  100. package/dist/slices/list-slices/index.js +0 -35
  101. package/dist/slices/login/index.d.ts +0 -1
  102. package/dist/slices/login/index.js +0 -20
  103. package/dist/slices/logout/index.d.ts +0 -1
  104. package/dist/slices/logout/index.js +0 -14
  105. package/dist/slices/map-fields/index.d.ts +0 -2
  106. package/dist/slices/map-fields/index.js +0 -269
  107. package/dist/slices/mark-slice-status/index.d.ts +0 -2
  108. package/dist/slices/mark-slice-status/index.js +0 -31
  109. package/dist/slices/merge/index.d.ts +0 -19
  110. package/dist/slices/merge/index.js +0 -147
  111. package/dist/slices/open-app/index.d.ts +0 -1
  112. package/dist/slices/open-app/index.js +0 -36
  113. package/dist/slices/remove-field/index.d.ts +0 -8
  114. package/dist/slices/remove-field/index.js +0 -167
  115. package/dist/slices/remove-scenario/index.d.ts +0 -2
  116. package/dist/slices/remove-scenario/index.js +0 -77
  117. package/dist/slices/search/index.d.ts +0 -3
  118. package/dist/slices/search/index.js +0 -302
  119. package/dist/slices/show-actor/index.d.ts +0 -4
  120. package/dist/slices/show-actor/index.js +0 -115
  121. package/dist/slices/show-aggregate/index.d.ts +0 -3
  122. package/dist/slices/show-aggregate/index.js +0 -108
  123. package/dist/slices/show-aggregate-completeness/index.d.ts +0 -4
  124. package/dist/slices/show-aggregate-completeness/index.js +0 -181
  125. package/dist/slices/show-chapter/index.d.ts +0 -3
  126. package/dist/slices/show-chapter/index.js +0 -195
  127. package/dist/slices/show-command/index.d.ts +0 -3
  128. package/dist/slices/show-command/index.js +0 -133
  129. package/dist/slices/show-completeness/index.d.ts +0 -4
  130. package/dist/slices/show-completeness/index.js +0 -731
  131. package/dist/slices/show-event/index.d.ts +0 -3
  132. package/dist/slices/show-event/index.js +0 -118
  133. package/dist/slices/show-model-summary/index.d.ts +0 -3
  134. package/dist/slices/show-model-summary/index.js +0 -31
  135. package/dist/slices/show-processor/index.d.ts +0 -3
  136. package/dist/slices/show-processor/index.js +0 -111
  137. package/dist/slices/show-readmodel/index.d.ts +0 -3
  138. package/dist/slices/show-readmodel/index.js +0 -158
  139. package/dist/slices/show-scenario/index.d.ts +0 -3
  140. package/dist/slices/show-scenario/index.js +0 -196
  141. package/dist/slices/show-screen/index.d.ts +0 -3
  142. package/dist/slices/show-screen/index.js +0 -139
  143. package/dist/slices/show-slice/index.d.ts +0 -3
  144. package/dist/slices/show-slice/index.js +0 -696
  145. package/dist/slices/update-field/index.d.ts +0 -15
  146. package/dist/slices/update-field/index.js +0 -208
  147. package/dist/slices/whoami/index.d.ts +0 -2
  148. package/dist/slices/whoami/index.js +0 -44
  149. package/dist/types.d.ts +0 -195
  150. package/dist/types.js +0 -1
@@ -1,828 +0,0 @@
1
- export function createEmptyModel() {
2
- return {
3
- modelId: '',
4
- name: '',
5
- commands: new Map(),
6
- events: new Map(),
7
- readModels: new Map(),
8
- screens: new Map(),
9
- processors: new Map(),
10
- slices: new Map(),
11
- chapters: new Map(),
12
- scenarios: new Map(),
13
- flows: new Map(),
14
- aggregates: new Map(),
15
- actors: new Map(),
16
- };
17
- }
18
- export function projectEvents(rawEvents) {
19
- const model = createEmptyModel();
20
- for (const event of rawEvents) {
21
- applyEvent(model, event);
22
- }
23
- return model;
24
- }
25
- function applyEvent(model, event) {
26
- const d = event.data;
27
- switch (event.type) {
28
- // Model creation
29
- case 'EventModelCreated':
30
- model.modelId = d.modelId;
31
- model.name = d.name;
32
- break;
33
- // Command sticky events
34
- case 'CommandStickyPlaced':
35
- model.commands.set(d.commandStickyId, {
36
- id: d.commandStickyId,
37
- name: d.name,
38
- fields: [],
39
- position: d.position,
40
- width: d.width,
41
- height: d.height,
42
- });
43
- break;
44
- case 'CommandStickyMoved': {
45
- const cmd = model.commands.get(d.commandStickyId);
46
- if (cmd)
47
- cmd.position = d.position;
48
- break;
49
- }
50
- case 'CommandStickyRemoved':
51
- model.commands.delete(d.commandStickyId);
52
- break;
53
- case 'CommandRenamed': {
54
- const cmd = model.commands.get(d.commandStickyId);
55
- if (cmd)
56
- cmd.name = d.name;
57
- break;
58
- }
59
- case 'CommandFieldAdded': {
60
- const cmd = model.commands.get(d.commandStickyId);
61
- if (cmd)
62
- cmd.fields.push(d.field);
63
- break;
64
- }
65
- case 'CommandFieldRemoved': {
66
- const cmd = model.commands.get(d.commandStickyId);
67
- if (cmd)
68
- cmd.fields = cmd.fields.filter(f => f.id !== d.fieldId);
69
- break;
70
- }
71
- case 'CommandFieldAdjusted': {
72
- const cmd = model.commands.get(d.commandStickyId);
73
- if (cmd) {
74
- const idx = cmd.fields.findIndex(f => f.id === d.fieldId);
75
- if (idx !== -1) {
76
- cmd.fields[idx] = { ...d.field, id: d.fieldId };
77
- }
78
- }
79
- break;
80
- }
81
- // Event sticky events
82
- case 'EventStickyPlaced':
83
- model.events.set(d.eventStickyId, {
84
- id: d.eventStickyId,
85
- name: d.name,
86
- fields: [],
87
- position: d.position,
88
- width: d.width,
89
- height: d.height,
90
- });
91
- break;
92
- case 'EventStickyMoved': {
93
- const evt = model.events.get(d.eventStickyId);
94
- if (evt)
95
- evt.position = d.position;
96
- break;
97
- }
98
- case 'EventStickyRemoved':
99
- model.events.delete(d.eventStickyId);
100
- break;
101
- case 'EventRenamed': {
102
- const evt = model.events.get(d.eventStickyId);
103
- if (evt)
104
- evt.name = d.name;
105
- break;
106
- }
107
- case 'EventFieldAdded': {
108
- const evt = model.events.get(d.eventStickyId);
109
- if (evt) {
110
- evt.fields.push(d.field);
111
- // Sync field to all linked copies with the same canonicalId
112
- if (evt.canonicalId) {
113
- for (const otherEvt of model.events.values()) {
114
- if (otherEvt.id !== evt.id && otherEvt.canonicalId === evt.canonicalId) {
115
- otherEvt.fields.push(d.field);
116
- }
117
- }
118
- }
119
- }
120
- break;
121
- }
122
- case 'EventFieldRemoved': {
123
- const evt = model.events.get(d.eventStickyId);
124
- if (evt) {
125
- evt.fields = evt.fields.filter(f => f.id !== d.fieldId);
126
- // Sync removal to all linked copies with the same canonicalId
127
- if (evt.canonicalId) {
128
- for (const otherEvt of model.events.values()) {
129
- if (otherEvt.id !== evt.id && otherEvt.canonicalId === evt.canonicalId) {
130
- otherEvt.fields = otherEvt.fields.filter(f => f.id !== d.fieldId);
131
- }
132
- }
133
- }
134
- }
135
- break;
136
- }
137
- case 'EventFieldAdjusted': {
138
- const evt = model.events.get(d.eventStickyId);
139
- if (evt) {
140
- const idx = evt.fields.findIndex(f => f.id === d.fieldId);
141
- if (idx !== -1) {
142
- const adjustedField = { ...d.field, id: d.fieldId };
143
- evt.fields[idx] = adjustedField;
144
- // Sync adjustment to all linked copies with the same canonicalId
145
- if (evt.canonicalId) {
146
- for (const otherEvt of model.events.values()) {
147
- if (otherEvt.id !== evt.id && otherEvt.canonicalId === evt.canonicalId) {
148
- const otherIdx = otherEvt.fields.findIndex(f => f.id === d.fieldId);
149
- if (otherIdx !== -1) {
150
- otherEvt.fields[otherIdx] = adjustedField;
151
- }
152
- }
153
- }
154
- }
155
- }
156
- }
157
- break;
158
- }
159
- case 'EventStickyLinkedCopyCreated': {
160
- const source = model.events.get(d.sourceEventStickyId);
161
- model.events.set(d.eventStickyId, {
162
- id: d.eventStickyId,
163
- name: source?.name ?? '',
164
- fields: source?.fields ? [...source.fields] : [],
165
- position: d.position,
166
- width: d.width,
167
- height: d.height,
168
- canonicalId: d.canonicalId,
169
- originalNodeId: d.sourceEventStickyId,
170
- });
171
- // Also set canonical on source if not already set
172
- if (source && !source.canonicalId) {
173
- source.canonicalId = d.canonicalId;
174
- }
175
- break;
176
- }
177
- case 'EventStickyCanonicalGroupRemoved': {
178
- const canonicalId = d.canonicalId;
179
- for (const [id, evt] of model.events) {
180
- if (evt.canonicalId === canonicalId) {
181
- model.events.delete(id);
182
- }
183
- }
184
- break;
185
- }
186
- // Read model sticky events
187
- case 'ReadModelStickyPlaced':
188
- model.readModels.set(d.readModelStickyId, {
189
- id: d.readModelStickyId,
190
- name: d.name,
191
- fields: [],
192
- position: d.position,
193
- width: d.width,
194
- height: d.height,
195
- });
196
- break;
197
- case 'ReadModelStickyMoved': {
198
- const rm = model.readModels.get(d.readModelStickyId);
199
- if (rm)
200
- rm.position = d.position;
201
- break;
202
- }
203
- case 'ReadModelStickyRemoved':
204
- model.readModels.delete(d.readModelStickyId);
205
- break;
206
- case 'ReadModelRenamed': {
207
- const rm = model.readModels.get(d.readModelStickyId);
208
- if (rm)
209
- rm.name = d.name;
210
- break;
211
- }
212
- case 'ReadModelFieldAdded': {
213
- const rm = model.readModels.get(d.readModelStickyId);
214
- if (rm) {
215
- rm.fields.push(d.field);
216
- // Sync field to all linked copies with the same canonicalId
217
- if (rm.canonicalId) {
218
- for (const otherRm of model.readModels.values()) {
219
- if (otherRm.id !== rm.id && otherRm.canonicalId === rm.canonicalId) {
220
- otherRm.fields.push(d.field);
221
- }
222
- }
223
- }
224
- }
225
- break;
226
- }
227
- case 'ReadModelFieldRemoved': {
228
- const rm = model.readModels.get(d.readModelStickyId);
229
- if (rm) {
230
- rm.fields = rm.fields.filter(f => f.id !== d.fieldId);
231
- // Sync removal to all linked copies with the same canonicalId
232
- if (rm.canonicalId) {
233
- for (const otherRm of model.readModels.values()) {
234
- if (otherRm.id !== rm.id && otherRm.canonicalId === rm.canonicalId) {
235
- otherRm.fields = otherRm.fields.filter(f => f.id !== d.fieldId);
236
- }
237
- }
238
- }
239
- }
240
- break;
241
- }
242
- case 'ReadModelFieldAdjusted': {
243
- const rm = model.readModels.get(d.readModelStickyId);
244
- if (rm) {
245
- const idx = rm.fields.findIndex(f => f.id === d.fieldId);
246
- if (idx !== -1) {
247
- const adjustedField = { ...d.field, id: d.fieldId };
248
- rm.fields[idx] = adjustedField;
249
- // Sync adjustment to all linked copies with the same canonicalId
250
- if (rm.canonicalId) {
251
- for (const otherRm of model.readModels.values()) {
252
- if (otherRm.id !== rm.id && otherRm.canonicalId === rm.canonicalId) {
253
- const otherIdx = otherRm.fields.findIndex(f => f.id === d.fieldId);
254
- if (otherIdx !== -1) {
255
- otherRm.fields[otherIdx] = adjustedField;
256
- }
257
- }
258
- }
259
- }
260
- }
261
- }
262
- break;
263
- }
264
- case 'ReadModelStickyLinkedCopyCreated': {
265
- const source = model.readModels.get(d.sourceReadModelStickyId);
266
- model.readModels.set(d.readModelStickyId, {
267
- id: d.readModelStickyId,
268
- name: source?.name ?? '',
269
- fields: source?.fields ? [...source.fields] : [],
270
- position: d.position,
271
- width: d.width,
272
- height: d.height,
273
- canonicalId: d.canonicalId,
274
- originalNodeId: d.sourceReadModelStickyId,
275
- });
276
- if (source && !source.canonicalId) {
277
- source.canonicalId = d.canonicalId;
278
- }
279
- break;
280
- }
281
- case 'ReadModelStickyCanonicalGroupRemoved': {
282
- const canonicalId = d.canonicalId;
283
- for (const [id, rm] of model.readModels) {
284
- if (rm.canonicalId === canonicalId) {
285
- model.readModels.delete(id);
286
- }
287
- }
288
- break;
289
- }
290
- // Screen events
291
- case 'ScreenPlaced':
292
- model.screens.set(d.screenId, {
293
- id: d.screenId,
294
- name: d.name,
295
- fields: [],
296
- position: d.position,
297
- width: d.width,
298
- height: d.height,
299
- });
300
- break;
301
- case 'ScreenMoved': {
302
- const scr = model.screens.get(d.screenId);
303
- if (scr)
304
- scr.position = d.position;
305
- break;
306
- }
307
- case 'ScreenRemoved':
308
- model.screens.delete(d.screenId);
309
- break;
310
- case 'ScreenRenamed': {
311
- const scr = model.screens.get(d.screenId);
312
- if (scr)
313
- scr.name = d.name;
314
- break;
315
- }
316
- case 'ScreenFieldAdded': {
317
- const scr = model.screens.get(d.screenId);
318
- if (scr) {
319
- scr.fields.push(d.field);
320
- // Sync field to all linked copies with the same canonicalId
321
- if (scr.canonicalId) {
322
- for (const otherScr of model.screens.values()) {
323
- if (otherScr.id !== scr.id && otherScr.canonicalId === scr.canonicalId) {
324
- otherScr.fields.push(d.field);
325
- }
326
- }
327
- }
328
- }
329
- break;
330
- }
331
- case 'ScreenFieldRemoved': {
332
- const scr = model.screens.get(d.screenId);
333
- if (scr) {
334
- scr.fields = scr.fields.filter(f => f.id !== d.fieldId);
335
- // Sync removal to all linked copies with the same canonicalId
336
- if (scr.canonicalId) {
337
- for (const otherScr of model.screens.values()) {
338
- if (otherScr.id !== scr.id && otherScr.canonicalId === scr.canonicalId) {
339
- otherScr.fields = otherScr.fields.filter(f => f.id !== d.fieldId);
340
- }
341
- }
342
- }
343
- }
344
- break;
345
- }
346
- case 'ScreenFieldAdjusted': {
347
- const scr = model.screens.get(d.screenId);
348
- if (scr) {
349
- const idx = scr.fields.findIndex(f => f.id === d.fieldId);
350
- if (idx !== -1) {
351
- const adjustedField = { ...d.field, id: d.fieldId };
352
- scr.fields[idx] = adjustedField;
353
- // Sync adjustment to all linked copies with the same canonicalId
354
- if (scr.canonicalId) {
355
- for (const otherScr of model.screens.values()) {
356
- if (otherScr.id !== scr.id && otherScr.canonicalId === scr.canonicalId) {
357
- const otherIdx = otherScr.fields.findIndex(f => f.id === d.fieldId);
358
- if (otherIdx !== -1) {
359
- otherScr.fields[otherIdx] = adjustedField;
360
- }
361
- }
362
- }
363
- }
364
- }
365
- }
366
- break;
367
- }
368
- case 'ScreenLinkedCopyCreated': {
369
- const source = model.screens.get(d.sourceScreenId);
370
- model.screens.set(d.screenId, {
371
- id: d.screenId,
372
- name: source?.name ?? '',
373
- fields: source?.fields ? [...source.fields] : [],
374
- position: d.position,
375
- width: d.width,
376
- height: d.height,
377
- canonicalId: d.canonicalId,
378
- originalNodeId: d.sourceScreenId,
379
- });
380
- if (source && !source.canonicalId) {
381
- source.canonicalId = d.canonicalId;
382
- }
383
- break;
384
- }
385
- case 'ScreenCanonicalGroupRemoved': {
386
- const canonicalId = d.canonicalId;
387
- for (const [id, scr] of model.screens) {
388
- if (scr.canonicalId === canonicalId) {
389
- model.screens.delete(id);
390
- }
391
- }
392
- break;
393
- }
394
- // Processor events
395
- case 'ProcessorPlaced':
396
- model.processors.set(d.processorId, {
397
- id: d.processorId,
398
- name: d.name,
399
- fields: [],
400
- position: d.position,
401
- width: d.width,
402
- height: d.height,
403
- });
404
- break;
405
- case 'ProcessorMoved': {
406
- const proc = model.processors.get(d.processorId);
407
- if (proc)
408
- proc.position = d.position;
409
- break;
410
- }
411
- case 'ProcessorRemoved':
412
- model.processors.delete(d.processorId);
413
- break;
414
- case 'ProcessorRenamed': {
415
- const proc = model.processors.get(d.processorId);
416
- if (proc)
417
- proc.name = d.name;
418
- break;
419
- }
420
- case 'ProcessorFieldAdded': {
421
- const proc = model.processors.get(d.processorId);
422
- if (proc)
423
- proc.fields.push(d.field);
424
- break;
425
- }
426
- case 'ProcessorFieldRemoved': {
427
- const proc = model.processors.get(d.processorId);
428
- if (proc)
429
- proc.fields = proc.fields.filter(f => f.id !== d.fieldId);
430
- break;
431
- }
432
- case 'ProcessorFieldAdjusted': {
433
- const proc = model.processors.get(d.processorId);
434
- if (proc) {
435
- const idx = proc.fields.findIndex(f => f.id === d.fieldId);
436
- if (idx !== -1) {
437
- proc.fields[idx] = { ...d.field, id: d.fieldId };
438
- }
439
- }
440
- break;
441
- }
442
- // Slice events
443
- case 'SlicePlaced':
444
- model.slices.set(d.sliceId, {
445
- id: d.sliceId,
446
- name: d.name,
447
- status: 'created',
448
- position: d.position,
449
- size: d.size,
450
- nodeIds: [],
451
- });
452
- break;
453
- case 'SliceMoved': {
454
- const slice = model.slices.get(d.sliceId);
455
- if (slice)
456
- slice.position = d.position;
457
- break;
458
- }
459
- case 'SliceResized': {
460
- const slice = model.slices.get(d.sliceId);
461
- if (slice) {
462
- slice.position = d.position;
463
- slice.size = d.size;
464
- }
465
- break;
466
- }
467
- case 'SliceRemoved':
468
- model.slices.delete(d.sliceId);
469
- break;
470
- case 'SliceRenamed': {
471
- const slice = model.slices.get(d.sliceId);
472
- if (slice)
473
- slice.name = d.name;
474
- break;
475
- }
476
- case 'SliceMarkedAsCreated': {
477
- const slice = model.slices.get(d.sliceId);
478
- if (slice)
479
- slice.status = 'created';
480
- break;
481
- }
482
- case 'SliceMarkedAsInProgress': {
483
- const slice = model.slices.get(d.sliceId);
484
- if (slice)
485
- slice.status = 'in-progress';
486
- break;
487
- }
488
- case 'SliceMarkedAsBlocked': {
489
- const slice = model.slices.get(d.sliceId);
490
- if (slice)
491
- slice.status = 'blocked';
492
- break;
493
- }
494
- case 'SliceMarkedAsDone': {
495
- const slice = model.slices.get(d.sliceId);
496
- if (slice)
497
- slice.status = 'done';
498
- break;
499
- }
500
- case 'SlicesWidthEqualized': {
501
- const width = d.width;
502
- for (const sliceId of d.sliceIds) {
503
- const slice = model.slices.get(sliceId);
504
- if (slice)
505
- slice.size.width = width;
506
- }
507
- break;
508
- }
509
- case 'SlicesHeightEqualized': {
510
- const height = d.height;
511
- const y = d.y;
512
- for (const sliceId of d.sliceIds) {
513
- const slice = model.slices.get(sliceId);
514
- if (slice) {
515
- slice.size.height = height;
516
- slice.position.y = y;
517
- }
518
- }
519
- break;
520
- }
521
- // Aggregate events
522
- case 'AggregatePlaced':
523
- model.aggregates.set(d.aggregateId, {
524
- id: d.aggregateId,
525
- name: d.name,
526
- position: d.position,
527
- size: d.size,
528
- eventIds: [],
529
- aggregateIdFieldName: d.aggregateIdFieldName,
530
- aggregateIdFieldType: d.aggregateIdFieldType,
531
- });
532
- break;
533
- case 'AggregateMoved': {
534
- const aggregate = model.aggregates.get(d.aggregateId);
535
- if (aggregate)
536
- aggregate.position = d.position;
537
- break;
538
- }
539
- case 'AggregateResized': {
540
- const aggregate = model.aggregates.get(d.aggregateId);
541
- if (aggregate) {
542
- aggregate.position = d.position;
543
- aggregate.size = d.size;
544
- }
545
- break;
546
- }
547
- case 'AggregateRemoved':
548
- model.aggregates.delete(d.aggregateId);
549
- break;
550
- case 'AggregateRenamed': {
551
- const aggregate = model.aggregates.get(d.aggregateId);
552
- if (aggregate)
553
- aggregate.name = d.name;
554
- break;
555
- }
556
- case 'AggregateIdFieldSet': {
557
- const aggregate = model.aggregates.get(d.aggregateId);
558
- if (aggregate) {
559
- aggregate.aggregateIdFieldName = d.aggregateIdFieldName;
560
- aggregate.aggregateIdFieldType = d.aggregateIdFieldType;
561
- }
562
- break;
563
- }
564
- // Actor events
565
- case 'ActorPlaced':
566
- model.actors.set(d.actorId, {
567
- id: d.actorId,
568
- name: d.name,
569
- position: d.position,
570
- size: d.size,
571
- screenIds: [],
572
- });
573
- break;
574
- case 'ActorMoved': {
575
- const actor = model.actors.get(d.actorId);
576
- if (actor)
577
- actor.position = d.position;
578
- break;
579
- }
580
- case 'ActorResized': {
581
- const actor = model.actors.get(d.actorId);
582
- if (actor) {
583
- actor.position = d.position;
584
- actor.size = d.size;
585
- }
586
- break;
587
- }
588
- case 'ActorRemoved':
589
- model.actors.delete(d.actorId);
590
- break;
591
- case 'ActorRenamed': {
592
- const actor = model.actors.get(d.actorId);
593
- if (actor)
594
- actor.name = d.name;
595
- break;
596
- }
597
- // Chapter events
598
- case 'ChapterPlaced':
599
- model.chapters.set(d.chapterId, {
600
- id: d.chapterId,
601
- name: d.name,
602
- position: d.position,
603
- size: d.size,
604
- });
605
- break;
606
- case 'ChapterMoved': {
607
- const chapter = model.chapters.get(d.chapterId);
608
- if (chapter)
609
- chapter.position = d.position;
610
- break;
611
- }
612
- case 'ChapterResized': {
613
- const chapter = model.chapters.get(d.chapterId);
614
- if (chapter) {
615
- chapter.position = d.position;
616
- chapter.size = d.size;
617
- }
618
- break;
619
- }
620
- case 'ChapterRemoved':
621
- model.chapters.delete(d.chapterId);
622
- break;
623
- case 'ChapterRenamed': {
624
- const chapter = model.chapters.get(d.chapterId);
625
- if (chapter)
626
- chapter.name = d.name;
627
- break;
628
- }
629
- // Flow events
630
- case 'CommandToEventFlowSpecified':
631
- model.flows.set(d.flowId, {
632
- id: d.flowId,
633
- flowType: 'CommandToEvent',
634
- sourceId: d.commandStickyId,
635
- targetId: d.eventStickyId,
636
- fieldMappings: [],
637
- });
638
- break;
639
- case 'EventToReadModelFlowSpecified':
640
- model.flows.set(d.flowId, {
641
- id: d.flowId,
642
- flowType: 'EventToReadModel',
643
- sourceId: d.eventStickyId,
644
- targetId: d.readModelStickyId,
645
- fieldMappings: [],
646
- });
647
- break;
648
- case 'ReadModelToScreenFlowSpecified':
649
- model.flows.set(d.flowId, {
650
- id: d.flowId,
651
- flowType: 'ReadModelToScreen',
652
- sourceId: d.readModelStickyId,
653
- targetId: d.screenId,
654
- fieldMappings: [],
655
- });
656
- break;
657
- case 'ReadModelToProcessorFlowSpecified':
658
- model.flows.set(d.flowId, {
659
- id: d.flowId,
660
- flowType: 'ReadModelToProcessor',
661
- sourceId: d.readModelStickyId,
662
- targetId: d.processorId,
663
- fieldMappings: [],
664
- });
665
- break;
666
- case 'ScreenToCommandFlowSpecified':
667
- model.flows.set(d.flowId, {
668
- id: d.flowId,
669
- flowType: 'ScreenToCommand',
670
- sourceId: d.screenId,
671
- targetId: d.commandStickyId,
672
- fieldMappings: [],
673
- });
674
- break;
675
- case 'ProcessorToCommandFlowSpecified':
676
- model.flows.set(d.flowId, {
677
- id: d.flowId,
678
- flowType: 'ProcessorToCommand',
679
- sourceId: d.processorId,
680
- targetId: d.commandStickyId,
681
- fieldMappings: [],
682
- });
683
- break;
684
- case 'FlowRemoved':
685
- model.flows.delete(d.flowId);
686
- break;
687
- case 'FieldMappingSpecified': {
688
- const flow = model.flows.get(d.flowId);
689
- if (flow)
690
- flow.fieldMappings = d.mappings;
691
- break;
692
- }
693
- case 'FieldMappingCleared': {
694
- const flow = model.flows.get(d.flowId);
695
- if (flow)
696
- flow.fieldMappings = [];
697
- break;
698
- }
699
- // Field propagation events
700
- case 'FieldsPropagatedFromCommandToEvent':
701
- case 'FieldsPropagatedFromEventToCommand':
702
- case 'FieldsPropagatedFromEventToReadModel':
703
- case 'FieldsPropagatedFromReadModelToEvent':
704
- case 'FieldsPropagatedFromReadModelToScreen':
705
- case 'FieldsPropagatedFromScreenToReadModel':
706
- case 'FieldsPropagatedFromReadModelToProcessor':
707
- case 'FieldsPropagatedFromProcessorToReadModel':
708
- case 'FieldsPropagatedFromScreenToCommand':
709
- case 'FieldsPropagatedFromCommandToScreen':
710
- case 'FieldsPropagatedFromProcessorToCommand':
711
- case 'FieldsPropagatedFromCommandToProcessor':
712
- handleFieldPropagation(model, event);
713
- break;
714
- // Scenario events
715
- case 'ScenarioCreated':
716
- model.scenarios.set(d.scenarioId, {
717
- id: d.scenarioId,
718
- sliceId: d.sliceId,
719
- name: d.name,
720
- description: '',
721
- position: d.position,
722
- width: d.width,
723
- height: d.height,
724
- givenEvents: [],
725
- whenCommand: null,
726
- whenEvents: [],
727
- then: { type: 'events', expectedEvents: [] },
728
- });
729
- break;
730
- case 'ScenarioMoved': {
731
- const scenario = model.scenarios.get(d.scenarioId);
732
- if (scenario)
733
- scenario.position = d.position;
734
- break;
735
- }
736
- case 'ScenarioRemoved':
737
- model.scenarios.delete(d.scenarioId);
738
- break;
739
- case 'ScenarioRenamed': {
740
- const scenario = model.scenarios.get(d.scenarioId);
741
- if (scenario)
742
- scenario.name = d.name;
743
- break;
744
- }
745
- case 'ScenarioDescriptionUpdated': {
746
- const scenario = model.scenarios.get(d.scenarioId);
747
- if (scenario)
748
- scenario.description = d.description;
749
- break;
750
- }
751
- case 'ScenarioGivenEventsUpdated': {
752
- const scenario = model.scenarios.get(d.scenarioId);
753
- if (scenario)
754
- scenario.givenEvents = d.givenEvents;
755
- break;
756
- }
757
- case 'ScenarioWhenCommandUpdated': {
758
- const scenario = model.scenarios.get(d.scenarioId);
759
- if (scenario)
760
- scenario.whenCommand = d.whenCommand;
761
- break;
762
- }
763
- case 'ScenarioWhenEventsUpdated': {
764
- const scenario = model.scenarios.get(d.scenarioId);
765
- if (scenario)
766
- scenario.whenEvents = d.whenEvents;
767
- break;
768
- }
769
- case 'ScenarioThenUpdated': {
770
- const scenario = model.scenarios.get(d.scenarioId);
771
- if (scenario)
772
- scenario.then = d.then;
773
- break;
774
- }
775
- // Ignore visual-only events
776
- case 'ScreenDesignUpdated':
777
- // Screen designs are visual-only, not relevant for CLI
778
- break;
779
- }
780
- }
781
- // Merge source fields into target fields:
782
- // - If a field with the same name exists, update its subfields
783
- // - If it doesn't exist, add as new field
784
- function mergeFieldsInto(existingFields, sourceFields) {
785
- for (const field of sourceFields) {
786
- const existingIdx = existingFields.findIndex(f => f.name === field.name);
787
- if (existingIdx !== -1) {
788
- existingFields[existingIdx] = {
789
- ...existingFields[existingIdx],
790
- subfields: field.subfields,
791
- };
792
- }
793
- else {
794
- existingFields.push(field);
795
- }
796
- }
797
- }
798
- // Forward propagation: source → target on the flow
799
- const FORWARD_PROPAGATION_TYPES = new Set([
800
- 'FieldsPropagatedFromCommandToEvent',
801
- 'FieldsPropagatedFromEventToReadModel',
802
- 'FieldsPropagatedFromReadModelToScreen',
803
- 'FieldsPropagatedFromReadModelToProcessor',
804
- 'FieldsPropagatedFromScreenToCommand',
805
- 'FieldsPropagatedFromProcessorToCommand',
806
- ]);
807
- function getFieldsForNode(model, nodeId) {
808
- return model.commands.get(nodeId)?.fields
809
- ?? model.events.get(nodeId)?.fields
810
- ?? model.readModels.get(nodeId)?.fields
811
- ?? model.screens.get(nodeId)?.fields
812
- ?? model.processors.get(nodeId)?.fields
813
- ?? null;
814
- }
815
- function handleFieldPropagation(model, event) {
816
- const flowId = event.data.flowId;
817
- const flow = model.flows.get(flowId);
818
- if (!flow)
819
- return;
820
- const isForward = FORWARD_PROPAGATION_TYPES.has(event.type);
821
- const sourceId = isForward ? flow.sourceId : flow.targetId;
822
- const targetId = isForward ? flow.targetId : flow.sourceId;
823
- const sourceFields = getFieldsForNode(model, sourceId) ?? [];
824
- const targetFields = getFieldsForNode(model, targetId);
825
- if (targetFields !== null) {
826
- mergeFieldsInto(targetFields, sourceFields);
827
- }
828
- }