eventmodeler 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 (61) hide show
  1. package/dist/cloud/slices/index.d.ts +215 -0
  2. package/dist/cloud/slices/index.js +247 -0
  3. package/dist/index.js +984 -39
  4. package/dist/lib/auth.d.ts +24 -0
  5. package/dist/lib/auth.js +332 -0
  6. package/dist/lib/backend.d.ts +48 -0
  7. package/dist/lib/backend.js +103 -0
  8. package/dist/lib/cloud-client.d.ts +70 -0
  9. package/dist/lib/cloud-client.js +528 -0
  10. package/dist/lib/config.d.ts +27 -0
  11. package/dist/lib/config.js +80 -11
  12. package/dist/lib/diff/three-way-merge.js +4 -4
  13. package/dist/lib/file-loader.js +43 -12
  14. package/dist/lib/project-config.d.ts +30 -0
  15. package/dist/lib/project-config.js +90 -0
  16. package/dist/lib/slice-utils.d.ts +28 -0
  17. package/dist/lib/slice-utils.js +80 -0
  18. package/dist/local/slices/index.d.ts +11 -0
  19. package/dist/local/slices/index.js +13 -0
  20. package/dist/projection.js +372 -371
  21. package/dist/slices/add-field/index.js +25 -15
  22. package/dist/slices/add-scenario/index.js +34 -22
  23. package/dist/slices/create-automation-slice/index.js +93 -65
  24. package/dist/slices/create-flow/index.js +24 -18
  25. package/dist/slices/create-state-change-slice/index.js +77 -53
  26. package/dist/slices/create-state-view-slice/index.js +25 -17
  27. package/dist/slices/import/index.d.ts +8 -0
  28. package/dist/slices/import/index.js +63 -0
  29. package/dist/slices/init/index.d.ts +4 -0
  30. package/dist/slices/init/index.js +133 -0
  31. package/dist/slices/list-processors/index.d.ts +3 -0
  32. package/dist/slices/list-processors/index.js +20 -0
  33. package/dist/slices/list-readmodels/index.d.ts +3 -0
  34. package/dist/slices/list-readmodels/index.js +21 -0
  35. package/dist/slices/list-scenarios/index.d.ts +3 -0
  36. package/dist/slices/list-scenarios/index.js +35 -0
  37. package/dist/slices/list-screens/index.d.ts +3 -0
  38. package/dist/slices/list-screens/index.js +47 -0
  39. package/dist/slices/login/index.d.ts +1 -0
  40. package/dist/slices/login/index.js +24 -0
  41. package/dist/slices/logout/index.d.ts +1 -0
  42. package/dist/slices/logout/index.js +14 -0
  43. package/dist/slices/map-fields/index.js +5 -3
  44. package/dist/slices/mark-slice-status/index.js +4 -2
  45. package/dist/slices/remove-field/index.js +25 -15
  46. package/dist/slices/remove-scenario/index.js +8 -4
  47. package/dist/slices/show-aggregate/index.d.ts +3 -0
  48. package/dist/slices/show-aggregate/index.js +108 -0
  49. package/dist/slices/show-processor/index.d.ts +3 -0
  50. package/dist/slices/show-processor/index.js +111 -0
  51. package/dist/slices/show-readmodel/index.d.ts +3 -0
  52. package/dist/slices/show-readmodel/index.js +158 -0
  53. package/dist/slices/show-scenario/index.d.ts +3 -0
  54. package/dist/slices/show-scenario/index.js +196 -0
  55. package/dist/slices/show-screen/index.d.ts +3 -0
  56. package/dist/slices/show-screen/index.js +139 -0
  57. package/dist/slices/update-field/index.js +30 -20
  58. package/dist/slices/whoami/index.d.ts +2 -0
  59. package/dist/slices/whoami/index.js +35 -0
  60. package/dist/types.d.ts +1 -2
  61. package/package.json +1 -1
@@ -126,9 +126,11 @@ function addFieldToCommand(model, filePath, commandName, fieldInput) {
126
126
  const field = createFieldFromInput(fieldInput);
127
127
  appendEvent(filePath, {
128
128
  type: 'CommandFieldAdded',
129
- commandStickyId: command.id,
130
- field,
131
- timestamp: Date.now(),
129
+ data: {
130
+ commandStickyId: command.id,
131
+ field,
132
+ timestamp: Date.now(),
133
+ },
132
134
  });
133
135
  console.log(`Added field "${field.name}" to command "${command.name}"`);
134
136
  }
@@ -143,9 +145,11 @@ function addFieldToEvent(model, filePath, eventName, fieldInput) {
143
145
  const field = createFieldFromInput(fieldInput);
144
146
  appendEvent(filePath, {
145
147
  type: 'EventFieldAdded',
146
- eventStickyId: event.id,
147
- field,
148
- timestamp: Date.now(),
148
+ data: {
149
+ eventStickyId: event.id,
150
+ field,
151
+ timestamp: Date.now(),
152
+ },
149
153
  });
150
154
  console.log(`Added field "${field.name}" to event "${event.name}"`);
151
155
  }
@@ -160,9 +164,11 @@ function addFieldToReadModel(model, filePath, readModelName, fieldInput) {
160
164
  const field = createFieldFromInput(fieldInput);
161
165
  appendEvent(filePath, {
162
166
  type: 'ReadModelFieldAdded',
163
- readModelStickyId: readModel.id,
164
- field,
165
- timestamp: Date.now(),
167
+ data: {
168
+ readModelStickyId: readModel.id,
169
+ field,
170
+ timestamp: Date.now(),
171
+ },
166
172
  });
167
173
  console.log(`Added field "${field.name}" to read model "${readModel.name}"`);
168
174
  }
@@ -177,9 +183,11 @@ function addFieldToScreen(model, filePath, screenName, fieldInput) {
177
183
  const field = createFieldFromInput(fieldInput);
178
184
  appendEvent(filePath, {
179
185
  type: 'ScreenFieldAdded',
180
- screenId: screen.id,
181
- field,
182
- timestamp: Date.now(),
186
+ data: {
187
+ screenId: screen.id,
188
+ field,
189
+ timestamp: Date.now(),
190
+ },
183
191
  });
184
192
  console.log(`Added field "${field.name}" to screen "${screen.name}"`);
185
193
  }
@@ -193,9 +201,11 @@ function addFieldToProcessor(model, filePath, processorName, fieldInput) {
193
201
  const field = createFieldFromInput(fieldInput);
194
202
  appendEvent(filePath, {
195
203
  type: 'ProcessorFieldAdded',
196
- processorId: processor.id,
197
- field,
198
- timestamp: Date.now(),
204
+ data: {
205
+ processorId: processor.id,
206
+ field,
207
+ timestamp: Date.now(),
208
+ },
199
209
  });
200
210
  console.log(`Added field "${field.name}" to processor "${processor.name}"`);
201
211
  }
@@ -288,56 +288,68 @@ export function addScenario(model, filePath, sliceName, input) {
288
288
  // Append ScenarioCreated event
289
289
  appendEvent(filePath, {
290
290
  type: 'ScenarioCreated',
291
- scenarioId,
292
- sliceId: slice.id,
293
- name: scenarioInput.name,
294
- position,
295
- width: 200,
296
- height: 80,
297
- timestamp: Date.now(),
291
+ data: {
292
+ scenarioId,
293
+ sliceId: slice.id,
294
+ name: scenarioInput.name,
295
+ position,
296
+ width: 200,
297
+ height: 80,
298
+ timestamp: Date.now(),
299
+ },
298
300
  });
299
301
  // Append description update if provided
300
302
  if (scenarioInput.description) {
301
303
  appendEvent(filePath, {
302
304
  type: 'ScenarioDescriptionUpdated',
303
- scenarioId,
304
- description: scenarioInput.description,
305
- timestamp: Date.now(),
305
+ data: {
306
+ scenarioId,
307
+ description: scenarioInput.description,
308
+ timestamp: Date.now(),
309
+ },
306
310
  });
307
311
  }
308
312
  // Append given events update if provided
309
313
  if (givenEvents.length > 0) {
310
314
  appendEvent(filePath, {
311
315
  type: 'ScenarioGivenEventsUpdated',
312
- scenarioId,
313
- givenEvents,
314
- timestamp: Date.now(),
316
+ data: {
317
+ scenarioId,
318
+ givenEvents,
319
+ timestamp: Date.now(),
320
+ },
315
321
  });
316
322
  }
317
323
  // Append when command update if provided
318
324
  if (whenCommand) {
319
325
  appendEvent(filePath, {
320
326
  type: 'ScenarioWhenCommandUpdated',
321
- scenarioId,
322
- whenCommand,
323
- timestamp: Date.now(),
327
+ data: {
328
+ scenarioId,
329
+ whenCommand,
330
+ timestamp: Date.now(),
331
+ },
324
332
  });
325
333
  }
326
334
  // Append when events update if provided
327
335
  if (whenEvents.length > 0) {
328
336
  appendEvent(filePath, {
329
337
  type: 'ScenarioWhenEventsUpdated',
330
- scenarioId,
331
- whenEvents,
332
- timestamp: Date.now(),
338
+ data: {
339
+ scenarioId,
340
+ whenEvents,
341
+ timestamp: Date.now(),
342
+ },
333
343
  });
334
344
  }
335
345
  // Append then update
336
346
  appendEvent(filePath, {
337
347
  type: 'ScenarioThenUpdated',
338
- scenarioId,
339
- then,
340
- timestamp: Date.now(),
348
+ data: {
349
+ scenarioId,
350
+ then,
351
+ timestamp: Date.now(),
352
+ },
341
353
  });
342
354
  console.log(`Added scenario "${scenarioInput.name}" to slice "${slice.name}"`);
343
355
  }
@@ -102,9 +102,11 @@ export function createAutomationSlice(model, filePath, xmlInput) {
102
102
  for (const { sliceId, newX, currentY } of toShift) {
103
103
  appendEvent(filePath, {
104
104
  type: 'SliceMoved',
105
- sliceId,
106
- position: { x: newX, y: currentY },
107
- timestamp: Date.now(),
105
+ data: {
106
+ sliceId,
107
+ position: { x: newX, y: currentY },
108
+ timestamp: Date.now(),
109
+ },
108
110
  });
109
111
  }
110
112
  }
@@ -145,125 +147,151 @@ export function createAutomationSlice(model, filePath, xmlInput) {
145
147
  // 1. Create the slice
146
148
  appendEvent(filePath, {
147
149
  type: 'SlicePlaced',
148
- sliceId,
149
- name: input.sliceName,
150
- position: slicePosition,
151
- size: { width: AUTOMATION_SLICE.width, height: AUTOMATION_SLICE.height },
152
- timestamp: Date.now(),
150
+ data: {
151
+ sliceId,
152
+ name: input.sliceName,
153
+ position: slicePosition,
154
+ size: { width: AUTOMATION_SLICE.width, height: AUTOMATION_SLICE.height },
155
+ timestamp: Date.now(),
156
+ },
153
157
  });
154
158
  // 2. Create the read model
155
159
  appendEvent(filePath, {
156
160
  type: 'ReadModelStickyPlaced',
157
- readModelStickyId: readModelId,
158
- name: input.readModel.name,
159
- position: readModelPosition,
160
- width: AUTOMATION_SLICE.readModel.width,
161
- height: AUTOMATION_SLICE.readModel.height,
162
- timestamp: Date.now(),
161
+ data: {
162
+ readModelStickyId: readModelId,
163
+ name: input.readModel.name,
164
+ position: readModelPosition,
165
+ width: AUTOMATION_SLICE.readModel.width,
166
+ height: AUTOMATION_SLICE.readModel.height,
167
+ timestamp: Date.now(),
168
+ },
163
169
  });
164
170
  // 3. Add read model fields
165
171
  for (const field of readModelFields) {
166
172
  appendEvent(filePath, {
167
173
  type: 'ReadModelFieldAdded',
168
- readModelStickyId: readModelId,
169
- field,
170
- timestamp: Date.now(),
174
+ data: {
175
+ readModelStickyId: readModelId,
176
+ field,
177
+ timestamp: Date.now(),
178
+ },
171
179
  });
172
180
  }
173
181
  // 4. Create the processor
174
182
  appendEvent(filePath, {
175
183
  type: 'ProcessorPlaced',
176
- processorId,
177
- name: input.processor.name,
178
- position: processorPosition,
179
- width: AUTOMATION_SLICE.processor.width,
180
- height: AUTOMATION_SLICE.processor.height,
181
- timestamp: Date.now(),
184
+ data: {
185
+ processorId,
186
+ name: input.processor.name,
187
+ position: processorPosition,
188
+ width: AUTOMATION_SLICE.processor.width,
189
+ height: AUTOMATION_SLICE.processor.height,
190
+ timestamp: Date.now(),
191
+ },
182
192
  });
183
193
  // 5. Create the command
184
194
  appendEvent(filePath, {
185
195
  type: 'CommandStickyPlaced',
186
- commandStickyId: commandId,
187
- name: input.command.name,
188
- position: commandPosition,
189
- width: AUTOMATION_SLICE.command.width,
190
- height: AUTOMATION_SLICE.command.height,
191
- timestamp: Date.now(),
196
+ data: {
197
+ commandStickyId: commandId,
198
+ name: input.command.name,
199
+ position: commandPosition,
200
+ width: AUTOMATION_SLICE.command.width,
201
+ height: AUTOMATION_SLICE.command.height,
202
+ timestamp: Date.now(),
203
+ },
192
204
  });
193
205
  // 6. Add command fields
194
206
  for (const field of commandFields) {
195
207
  appendEvent(filePath, {
196
208
  type: 'CommandFieldAdded',
197
- commandStickyId: commandId,
198
- field,
199
- timestamp: Date.now(),
209
+ data: {
210
+ commandStickyId: commandId,
211
+ field,
212
+ timestamp: Date.now(),
213
+ },
200
214
  });
201
215
  }
202
216
  // 7. Create the event
203
217
  appendEvent(filePath, {
204
218
  type: 'EventStickyPlaced',
205
- eventStickyId: eventId,
206
- name: input.event.name,
207
- position: eventPosition,
208
- width: AUTOMATION_SLICE.event.width,
209
- height: AUTOMATION_SLICE.event.height,
210
- timestamp: Date.now(),
219
+ data: {
220
+ eventStickyId: eventId,
221
+ name: input.event.name,
222
+ position: eventPosition,
223
+ width: AUTOMATION_SLICE.event.width,
224
+ height: AUTOMATION_SLICE.event.height,
225
+ timestamp: Date.now(),
226
+ },
211
227
  });
212
228
  // 8. Add event fields
213
229
  for (const field of eventFields) {
214
230
  appendEvent(filePath, {
215
231
  type: 'EventFieldAdded',
216
- eventStickyId: eventId,
217
- field,
218
- timestamp: Date.now(),
232
+ data: {
233
+ eventStickyId: eventId,
234
+ field,
235
+ timestamp: Date.now(),
236
+ },
219
237
  });
220
238
  }
221
239
  // 9. Create read model -> processor flow
222
240
  appendEvent(filePath, {
223
241
  type: 'ReadModelToProcessorFlowSpecified',
224
- flowId: readModelToProcessorFlowId,
225
- readModelStickyId: readModelId,
226
- processorId,
227
- sourceHandle: 'top-source',
228
- targetHandle: 'bottom-target',
229
- timestamp: Date.now(),
242
+ data: {
243
+ flowId: readModelToProcessorFlowId,
244
+ readModelStickyId: readModelId,
245
+ processorId,
246
+ sourceHandle: 'top-source',
247
+ targetHandle: 'bottom-target',
248
+ timestamp: Date.now(),
249
+ },
230
250
  });
231
251
  // 10. Add read model -> command field mappings
232
252
  if (readModelToCommandMappings.length > 0) {
233
253
  appendEvent(filePath, {
234
254
  type: 'FieldMappingSpecified',
235
- flowId: readModelToProcessorFlowId,
236
- mappings: readModelToCommandMappings,
237
- timestamp: Date.now(),
255
+ data: {
256
+ flowId: readModelToProcessorFlowId,
257
+ mappings: readModelToCommandMappings,
258
+ timestamp: Date.now(),
259
+ },
238
260
  });
239
261
  }
240
262
  // 11. Create processor -> command flow
241
263
  appendEvent(filePath, {
242
264
  type: 'ProcessorToCommandFlowSpecified',
243
- flowId: processorToCommandFlowId,
244
- processorId,
245
- commandStickyId: commandId,
246
- sourceHandle: 'bottom-source',
247
- targetHandle: 'top-target',
248
- timestamp: Date.now(),
265
+ data: {
266
+ flowId: processorToCommandFlowId,
267
+ processorId,
268
+ commandStickyId: commandId,
269
+ sourceHandle: 'bottom-source',
270
+ targetHandle: 'top-target',
271
+ timestamp: Date.now(),
272
+ },
249
273
  });
250
274
  // 12. Create command -> event flow
251
275
  appendEvent(filePath, {
252
276
  type: 'CommandToEventFlowSpecified',
253
- flowId: commandToEventFlowId,
254
- commandStickyId: commandId,
255
- eventStickyId: eventId,
256
- sourceHandle: 'bottom-source',
257
- targetHandle: 'top-target',
258
- timestamp: Date.now(),
277
+ data: {
278
+ flowId: commandToEventFlowId,
279
+ commandStickyId: commandId,
280
+ eventStickyId: eventId,
281
+ sourceHandle: 'bottom-source',
282
+ targetHandle: 'top-target',
283
+ timestamp: Date.now(),
284
+ },
259
285
  });
260
286
  // 13. Add command -> event field mappings
261
287
  if (commandToEventMappings.length > 0) {
262
288
  appendEvent(filePath, {
263
289
  type: 'FieldMappingSpecified',
264
- flowId: commandToEventFlowId,
265
- mappings: commandToEventMappings,
266
- timestamp: Date.now(),
290
+ data: {
291
+ flowId: commandToEventFlowId,
292
+ mappings: commandToEventMappings,
293
+ timestamp: Date.now(),
294
+ },
267
295
  });
268
296
  }
269
297
  console.log(`Created automation slice "${input.sliceName}"`);
@@ -98,12 +98,14 @@ export function createFlow(model, filePath, fromName, toName) {
98
98
  }
99
99
  event = {
100
100
  type: 'EventToReadModelFlowSpecified',
101
- flowId,
102
- eventStickyId: source.element.id,
103
- readModelStickyId: target.element.id,
104
- sourceHandle: 'top-source',
105
- targetHandle: 'bottom-target',
106
- timestamp: Date.now(),
101
+ data: {
102
+ flowId,
103
+ eventStickyId: source.element.id,
104
+ readModelStickyId: target.element.id,
105
+ sourceHandle: 'top-source',
106
+ targetHandle: 'bottom-target',
107
+ timestamp: Date.now(),
108
+ },
107
109
  };
108
110
  appendEvent(filePath, event);
109
111
  console.log(`Created flow: Event "${source.element.name}" → ReadModel "${target.element.name}"`);
@@ -116,12 +118,14 @@ export function createFlow(model, filePath, fromName, toName) {
116
118
  }
117
119
  event = {
118
120
  type: 'ReadModelToScreenFlowSpecified',
119
- flowId,
120
- readModelStickyId: source.element.id,
121
- screenId: target.element.id,
122
- sourceHandle: 'top-source',
123
- targetHandle: 'bottom-target',
124
- timestamp: Date.now(),
121
+ data: {
122
+ flowId,
123
+ readModelStickyId: source.element.id,
124
+ screenId: target.element.id,
125
+ sourceHandle: 'top-source',
126
+ targetHandle: 'bottom-target',
127
+ timestamp: Date.now(),
128
+ },
125
129
  };
126
130
  appendEvent(filePath, event);
127
131
  console.log(`Created flow: ReadModel "${source.element.name}" → Screen "${target.element.name}"`);
@@ -134,12 +138,14 @@ export function createFlow(model, filePath, fromName, toName) {
134
138
  }
135
139
  event = {
136
140
  type: 'ReadModelToProcessorFlowSpecified',
137
- flowId,
138
- readModelStickyId: source.element.id,
139
- processorId: target.element.id,
140
- sourceHandle: 'top-source',
141
- targetHandle: 'bottom-target',
142
- timestamp: Date.now(),
141
+ data: {
142
+ flowId,
143
+ readModelStickyId: source.element.id,
144
+ processorId: target.element.id,
145
+ sourceHandle: 'top-source',
146
+ targetHandle: 'bottom-target',
147
+ timestamp: Date.now(),
148
+ },
143
149
  };
144
150
  appendEvent(filePath, event);
145
151
  console.log(`Created flow: ReadModel "${source.element.name}" → Processor "${target.element.name}"`);
@@ -92,9 +92,11 @@ export function createStateChangeSlice(model, filePath, xmlInput) {
92
92
  for (const { sliceId, newX, currentY } of toShift) {
93
93
  appendEvent(filePath, {
94
94
  type: 'SliceMoved',
95
- sliceId,
96
- position: { x: newX, y: currentY },
97
- timestamp: Date.now(),
95
+ data: {
96
+ sliceId,
97
+ position: { x: newX, y: currentY },
98
+ timestamp: Date.now(),
99
+ },
98
100
  });
99
101
  }
100
102
  }
@@ -129,105 +131,127 @@ export function createStateChangeSlice(model, filePath, xmlInput) {
129
131
  // 1. Create the slice
130
132
  appendEvent(filePath, {
131
133
  type: 'SlicePlaced',
132
- sliceId,
133
- name: input.sliceName,
134
- position: slicePosition,
135
- size: { width: STATE_CHANGE_SLICE.width, height: STATE_CHANGE_SLICE.height },
136
- timestamp: Date.now(),
134
+ data: {
135
+ sliceId,
136
+ name: input.sliceName,
137
+ position: slicePosition,
138
+ size: { width: STATE_CHANGE_SLICE.width, height: STATE_CHANGE_SLICE.height },
139
+ timestamp: Date.now(),
140
+ },
137
141
  });
138
142
  // 2. Create the screen
139
143
  appendEvent(filePath, {
140
144
  type: 'ScreenPlaced',
141
- screenId,
142
- name: input.screen.name,
143
- position: screenPosition,
144
- width: STATE_CHANGE_SLICE.screen.width,
145
- height: STATE_CHANGE_SLICE.screen.height,
146
- timestamp: Date.now(),
145
+ data: {
146
+ screenId,
147
+ name: input.screen.name,
148
+ position: screenPosition,
149
+ width: STATE_CHANGE_SLICE.screen.width,
150
+ height: STATE_CHANGE_SLICE.screen.height,
151
+ timestamp: Date.now(),
152
+ },
147
153
  });
148
154
  // 3. Add screen fields
149
155
  for (const field of screenFields) {
150
156
  appendEvent(filePath, {
151
157
  type: 'ScreenFieldAdded',
152
- screenId,
153
- field,
154
- timestamp: Date.now(),
158
+ data: {
159
+ screenId,
160
+ field,
161
+ timestamp: Date.now(),
162
+ },
155
163
  });
156
164
  }
157
165
  // 4. Create the command
158
166
  appendEvent(filePath, {
159
167
  type: 'CommandStickyPlaced',
160
- commandStickyId: commandId,
161
- name: input.command.name,
162
- position: commandPosition,
163
- width: STATE_CHANGE_SLICE.command.width,
164
- height: STATE_CHANGE_SLICE.command.height,
165
- timestamp: Date.now(),
168
+ data: {
169
+ commandStickyId: commandId,
170
+ name: input.command.name,
171
+ position: commandPosition,
172
+ width: STATE_CHANGE_SLICE.command.width,
173
+ height: STATE_CHANGE_SLICE.command.height,
174
+ timestamp: Date.now(),
175
+ },
166
176
  });
167
177
  // 5. Add command fields
168
178
  for (const field of commandFields) {
169
179
  appendEvent(filePath, {
170
180
  type: 'CommandFieldAdded',
171
- commandStickyId: commandId,
172
- field,
173
- timestamp: Date.now(),
181
+ data: {
182
+ commandStickyId: commandId,
183
+ field,
184
+ timestamp: Date.now(),
185
+ },
174
186
  });
175
187
  }
176
188
  // 6. Create the event
177
189
  appendEvent(filePath, {
178
190
  type: 'EventStickyPlaced',
179
- eventStickyId: eventId,
180
- name: input.event.name,
181
- position: eventPosition,
182
- width: STATE_CHANGE_SLICE.event.width,
183
- height: STATE_CHANGE_SLICE.event.height,
184
- timestamp: Date.now(),
191
+ data: {
192
+ eventStickyId: eventId,
193
+ name: input.event.name,
194
+ position: eventPosition,
195
+ width: STATE_CHANGE_SLICE.event.width,
196
+ height: STATE_CHANGE_SLICE.event.height,
197
+ timestamp: Date.now(),
198
+ },
185
199
  });
186
200
  // 7. Add event fields
187
201
  for (const field of eventFields) {
188
202
  appendEvent(filePath, {
189
203
  type: 'EventFieldAdded',
190
- eventStickyId: eventId,
191
- field,
192
- timestamp: Date.now(),
204
+ data: {
205
+ eventStickyId: eventId,
206
+ field,
207
+ timestamp: Date.now(),
208
+ },
193
209
  });
194
210
  }
195
211
  // 8. Create screen -> command flow
196
212
  appendEvent(filePath, {
197
213
  type: 'ScreenToCommandFlowSpecified',
198
- flowId: screenToCommandFlowId,
199
- screenId,
200
- commandStickyId: commandId,
201
- sourceHandle: 'bottom-source',
202
- targetHandle: 'top-target',
203
- timestamp: Date.now(),
214
+ data: {
215
+ flowId: screenToCommandFlowId,
216
+ screenId,
217
+ commandStickyId: commandId,
218
+ sourceHandle: 'bottom-source',
219
+ targetHandle: 'top-target',
220
+ timestamp: Date.now(),
221
+ },
204
222
  });
205
223
  // 9. Add screen -> command field mappings
206
224
  if (screenToCommandMappings.length > 0) {
207
225
  appendEvent(filePath, {
208
226
  type: 'FieldMappingSpecified',
209
- flowId: screenToCommandFlowId,
210
- mappings: screenToCommandMappings,
211
- timestamp: Date.now(),
227
+ data: {
228
+ flowId: screenToCommandFlowId,
229
+ mappings: screenToCommandMappings,
230
+ timestamp: Date.now(),
231
+ },
212
232
  });
213
233
  }
214
234
  // 10. Create command -> event flow
215
235
  appendEvent(filePath, {
216
236
  type: 'CommandToEventFlowSpecified',
217
- flowId: commandToEventFlowId,
218
- commandStickyId: commandId,
219
- eventStickyId: eventId,
220
- sourceHandle: 'bottom-source',
221
- targetHandle: 'top-target',
222
- timestamp: Date.now(),
237
+ data: {
238
+ flowId: commandToEventFlowId,
239
+ commandStickyId: commandId,
240
+ eventStickyId: eventId,
241
+ sourceHandle: 'bottom-source',
242
+ targetHandle: 'top-target',
243
+ timestamp: Date.now(),
244
+ },
223
245
  });
224
246
  // 11. Add command -> event field mappings
225
247
  if (commandToEventMappings.length > 0) {
226
248
  appendEvent(filePath, {
227
249
  type: 'FieldMappingSpecified',
228
- flowId: commandToEventFlowId,
229
- mappings: commandToEventMappings,
230
- timestamp: Date.now(),
250
+ data: {
251
+ flowId: commandToEventFlowId,
252
+ mappings: commandToEventMappings,
253
+ timestamp: Date.now(),
254
+ },
231
255
  });
232
256
  }
233
257
  console.log(`Created state-change slice "${input.sliceName}"`);