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.
- package/dist/cloud/slices/index.d.ts +215 -0
- package/dist/cloud/slices/index.js +247 -0
- package/dist/index.js +984 -39
- package/dist/lib/auth.d.ts +24 -0
- package/dist/lib/auth.js +332 -0
- package/dist/lib/backend.d.ts +48 -0
- package/dist/lib/backend.js +103 -0
- package/dist/lib/cloud-client.d.ts +70 -0
- package/dist/lib/cloud-client.js +528 -0
- package/dist/lib/config.d.ts +27 -0
- package/dist/lib/config.js +80 -11
- package/dist/lib/diff/three-way-merge.js +4 -4
- package/dist/lib/file-loader.js +43 -12
- package/dist/lib/project-config.d.ts +30 -0
- package/dist/lib/project-config.js +90 -0
- package/dist/lib/slice-utils.d.ts +28 -0
- package/dist/lib/slice-utils.js +80 -0
- package/dist/local/slices/index.d.ts +11 -0
- package/dist/local/slices/index.js +13 -0
- package/dist/projection.js +372 -371
- package/dist/slices/add-field/index.js +25 -15
- package/dist/slices/add-scenario/index.js +34 -22
- package/dist/slices/create-automation-slice/index.js +93 -65
- package/dist/slices/create-flow/index.js +24 -18
- package/dist/slices/create-state-change-slice/index.js +77 -53
- package/dist/slices/create-state-view-slice/index.js +25 -17
- package/dist/slices/import/index.d.ts +8 -0
- package/dist/slices/import/index.js +63 -0
- package/dist/slices/init/index.d.ts +4 -0
- package/dist/slices/init/index.js +133 -0
- package/dist/slices/list-processors/index.d.ts +3 -0
- package/dist/slices/list-processors/index.js +20 -0
- package/dist/slices/list-readmodels/index.d.ts +3 -0
- package/dist/slices/list-readmodels/index.js +21 -0
- package/dist/slices/list-scenarios/index.d.ts +3 -0
- package/dist/slices/list-scenarios/index.js +35 -0
- package/dist/slices/list-screens/index.d.ts +3 -0
- package/dist/slices/list-screens/index.js +47 -0
- package/dist/slices/login/index.d.ts +1 -0
- package/dist/slices/login/index.js +24 -0
- package/dist/slices/logout/index.d.ts +1 -0
- package/dist/slices/logout/index.js +14 -0
- package/dist/slices/map-fields/index.js +5 -3
- package/dist/slices/mark-slice-status/index.js +4 -2
- package/dist/slices/remove-field/index.js +25 -15
- package/dist/slices/remove-scenario/index.js +8 -4
- package/dist/slices/show-aggregate/index.d.ts +3 -0
- package/dist/slices/show-aggregate/index.js +108 -0
- package/dist/slices/show-processor/index.d.ts +3 -0
- package/dist/slices/show-processor/index.js +111 -0
- package/dist/slices/show-readmodel/index.d.ts +3 -0
- package/dist/slices/show-readmodel/index.js +158 -0
- package/dist/slices/show-scenario/index.d.ts +3 -0
- package/dist/slices/show-scenario/index.js +196 -0
- package/dist/slices/show-screen/index.d.ts +3 -0
- package/dist/slices/show-screen/index.js +139 -0
- package/dist/slices/update-field/index.js +30 -20
- package/dist/slices/whoami/index.d.ts +2 -0
- package/dist/slices/whoami/index.js +35 -0
- package/dist/types.d.ts +1 -2
- 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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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}"`);
|