eventmodeler 0.2.10 → 0.3.0
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/index.js +15 -9
- package/dist/slices/add-field/index.d.ts +2 -0
- package/dist/slices/add-field/index.js +41 -3
- package/dist/slices/remove-field/index.d.ts +2 -0
- package/dist/slices/remove-field/index.js +59 -3
- package/dist/slices/update-field/index.d.ts +2 -0
- package/dist/slices/update-field/index.js +57 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,18 +80,18 @@ COMMANDS:
|
|
|
80
80
|
|
|
81
81
|
add scenario --slice <name> --json|--xml <data>
|
|
82
82
|
Add a scenario to a slice
|
|
83
|
-
add field --command|--event|--read-model <name> --json|--xml <data>
|
|
83
|
+
add field --command|--event|--read-model|--screen|--processor <name> --json|--xml <data>
|
|
84
84
|
Add a field to an entity
|
|
85
85
|
|
|
86
86
|
remove scenario <name> [--slice <name>]
|
|
87
87
|
Remove a scenario by name
|
|
88
|
-
remove field --command|--event|--read-model <name> --field <name>
|
|
88
|
+
remove field --command|--event|--read-model|--screen|--processor <name> --field <name>
|
|
89
89
|
Remove a field from an entity
|
|
90
90
|
|
|
91
91
|
map fields --flow <source→target> --json|--xml <mappings>
|
|
92
92
|
Set field mappings on a flow
|
|
93
93
|
|
|
94
|
-
update field --command|--event|--read-model <name> --field <name> [--optional true|false] [--generated true|false]
|
|
94
|
+
update field --command|--event|--read-model|--screen|--processor <name> --field <name> [--optional true|false] [--generated true|false]
|
|
95
95
|
Update field properties
|
|
96
96
|
|
|
97
97
|
create state-change-slice --xml <data>
|
|
@@ -332,15 +332,17 @@ async function main() {
|
|
|
332
332
|
const commandArg = getNamedArg(filteredArgs, '--command');
|
|
333
333
|
const eventArg = getNamedArg(filteredArgs, '--event');
|
|
334
334
|
const readModelArg = getNamedArg(filteredArgs, '--read-model');
|
|
335
|
+
const screenArg = getNamedArg(filteredArgs, '--screen');
|
|
336
|
+
const processorArg = getNamedArg(filteredArgs, '--processor');
|
|
335
337
|
const jsonArg = getNamedArg(filteredArgs, '--json');
|
|
336
338
|
const xmlArg = getNamedArg(filteredArgs, '--xml');
|
|
337
339
|
const inputData = jsonArg ?? xmlArg;
|
|
338
340
|
if (!inputData) {
|
|
339
341
|
console.error('Error: --json or --xml is required');
|
|
340
|
-
console.error('Usage: eventmodeler add field --command|--event|--read-model <name> --json|--xml <data>');
|
|
342
|
+
console.error('Usage: eventmodeler add field --command|--event|--read-model|--screen|--processor <name> --json|--xml <data>');
|
|
341
343
|
process.exit(1);
|
|
342
344
|
}
|
|
343
|
-
addField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg }, inputData);
|
|
345
|
+
addField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg, screen: screenArg, processor: processorArg }, inputData);
|
|
344
346
|
break;
|
|
345
347
|
}
|
|
346
348
|
default:
|
|
@@ -365,13 +367,15 @@ async function main() {
|
|
|
365
367
|
const commandArg = getNamedArg(filteredArgs, '--command');
|
|
366
368
|
const eventArg = getNamedArg(filteredArgs, '--event');
|
|
367
369
|
const readModelArg = getNamedArg(filteredArgs, '--read-model');
|
|
370
|
+
const screenArg = getNamedArg(filteredArgs, '--screen');
|
|
371
|
+
const processorArg = getNamedArg(filteredArgs, '--processor');
|
|
368
372
|
const fieldArg = getNamedArg(filteredArgs, '--field');
|
|
369
373
|
if (!fieldArg) {
|
|
370
374
|
console.error('Error: --field is required');
|
|
371
|
-
console.error('Usage: eventmodeler remove field --command|--event|--read-model <name> --field <field-name>');
|
|
375
|
+
console.error('Usage: eventmodeler remove field --command|--event|--read-model|--screen|--processor <name> --field <field-name>');
|
|
372
376
|
process.exit(1);
|
|
373
377
|
}
|
|
374
|
-
removeField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg }, fieldArg);
|
|
378
|
+
removeField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg, screen: screenArg, processor: processorArg }, fieldArg);
|
|
375
379
|
break;
|
|
376
380
|
}
|
|
377
381
|
default:
|
|
@@ -412,13 +416,15 @@ async function main() {
|
|
|
412
416
|
const commandArg = getNamedArg(filteredArgs, '--command');
|
|
413
417
|
const eventArg = getNamedArg(filteredArgs, '--event');
|
|
414
418
|
const readModelArg = getNamedArg(filteredArgs, '--read-model');
|
|
419
|
+
const screenArg = getNamedArg(filteredArgs, '--screen');
|
|
420
|
+
const processorArg = getNamedArg(filteredArgs, '--processor');
|
|
415
421
|
const fieldArg = getNamedArg(filteredArgs, '--field');
|
|
416
422
|
const optionalArg = getNamedArg(filteredArgs, '--optional');
|
|
417
423
|
const generatedArg = getNamedArg(filteredArgs, '--generated');
|
|
418
424
|
const typeArg = getNamedArg(filteredArgs, '--type');
|
|
419
425
|
if (!fieldArg) {
|
|
420
426
|
console.error('Error: --field is required');
|
|
421
|
-
console.error('Usage: eventmodeler update field --command|--event|--read-model <name> --field <field-name> [--optional true|false] [--generated true|false]');
|
|
427
|
+
console.error('Usage: eventmodeler update field --command|--event|--read-model|--screen|--processor <name> --field <field-name> [--optional true|false] [--generated true|false]');
|
|
422
428
|
process.exit(1);
|
|
423
429
|
}
|
|
424
430
|
const updates = {};
|
|
@@ -435,7 +441,7 @@ async function main() {
|
|
|
435
441
|
console.error('Error: Must specify at least one update (--optional, --generated, or --type)');
|
|
436
442
|
process.exit(1);
|
|
437
443
|
}
|
|
438
|
-
updateField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg }, fieldArg, updates);
|
|
444
|
+
updateField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg, screen: screenArg, processor: processorArg }, fieldArg, updates);
|
|
439
445
|
break;
|
|
440
446
|
}
|
|
441
447
|
default:
|
|
@@ -68,13 +68,13 @@ function createFieldFromInput(input) {
|
|
|
68
68
|
}
|
|
69
69
|
export function addField(model, filePath, options, input) {
|
|
70
70
|
// Determine which entity type
|
|
71
|
-
const entityCount = [options.command, options.event, options.readModel].filter(Boolean).length;
|
|
71
|
+
const entityCount = [options.command, options.event, options.readModel, options.screen, options.processor].filter(Boolean).length;
|
|
72
72
|
if (entityCount === 0) {
|
|
73
|
-
console.error('Error: Must specify one of --command, --event,
|
|
73
|
+
console.error('Error: Must specify one of --command, --event, --read-model, --screen, or --processor');
|
|
74
74
|
process.exit(1);
|
|
75
75
|
}
|
|
76
76
|
if (entityCount > 1) {
|
|
77
|
-
console.error('Error: Can only specify one of --command, --event,
|
|
77
|
+
console.error('Error: Can only specify one of --command, --event, --read-model, --screen, or --processor');
|
|
78
78
|
process.exit(1);
|
|
79
79
|
}
|
|
80
80
|
// Parse input
|
|
@@ -107,6 +107,12 @@ export function addField(model, filePath, options, input) {
|
|
|
107
107
|
else if (options.readModel) {
|
|
108
108
|
addFieldToReadModel(model, filePath, options.readModel, fieldInput);
|
|
109
109
|
}
|
|
110
|
+
else if (options.screen) {
|
|
111
|
+
addFieldToScreen(model, filePath, options.screen, fieldInput);
|
|
112
|
+
}
|
|
113
|
+
else if (options.processor) {
|
|
114
|
+
addFieldToProcessor(model, filePath, options.processor, fieldInput);
|
|
115
|
+
}
|
|
110
116
|
}
|
|
111
117
|
function addFieldToCommand(model, filePath, commandName, fieldInput) {
|
|
112
118
|
const command = findElementOrExit(model.commands, commandName, 'command');
|
|
@@ -156,3 +162,35 @@ function addFieldToReadModel(model, filePath, readModelName, fieldInput) {
|
|
|
156
162
|
});
|
|
157
163
|
console.log(`Added field "${field.name}" to read model "${readModel.name}"`);
|
|
158
164
|
}
|
|
165
|
+
function addFieldToScreen(model, filePath, screenName, fieldInput) {
|
|
166
|
+
const screen = findElementOrExit(model.screens, screenName, 'screen');
|
|
167
|
+
// Check for duplicate field name
|
|
168
|
+
if (screen.fields.some(f => f.name.toLowerCase() === fieldInput.name.toLowerCase())) {
|
|
169
|
+
console.error(`Error: Field "${fieldInput.name}" already exists on screen "${screen.name}"`);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
const field = createFieldFromInput(fieldInput);
|
|
173
|
+
appendEvent(filePath, {
|
|
174
|
+
type: 'ScreenFieldAdded',
|
|
175
|
+
screenId: screen.id,
|
|
176
|
+
field,
|
|
177
|
+
timestamp: Date.now(),
|
|
178
|
+
});
|
|
179
|
+
console.log(`Added field "${field.name}" to screen "${screen.name}"`);
|
|
180
|
+
}
|
|
181
|
+
function addFieldToProcessor(model, filePath, processorName, fieldInput) {
|
|
182
|
+
const processor = findElementOrExit(model.processors, processorName, 'processor');
|
|
183
|
+
// Check for duplicate field name
|
|
184
|
+
if (processor.fields.some(f => f.name.toLowerCase() === fieldInput.name.toLowerCase())) {
|
|
185
|
+
console.error(`Error: Field "${fieldInput.name}" already exists on processor "${processor.name}"`);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
const field = createFieldFromInput(fieldInput);
|
|
189
|
+
appendEvent(filePath, {
|
|
190
|
+
type: 'ProcessorFieldAdded',
|
|
191
|
+
processorId: processor.id,
|
|
192
|
+
field,
|
|
193
|
+
timestamp: Date.now(),
|
|
194
|
+
});
|
|
195
|
+
console.log(`Added field "${field.name}" to processor "${processor.name}"`);
|
|
196
|
+
}
|
|
@@ -2,13 +2,13 @@ import { appendEvent } from '../../lib/file-loader.js';
|
|
|
2
2
|
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
3
3
|
export function removeField(model, filePath, options, fieldName) {
|
|
4
4
|
// Determine which entity type
|
|
5
|
-
const entityCount = [options.command, options.event, options.readModel].filter(Boolean).length;
|
|
5
|
+
const entityCount = [options.command, options.event, options.readModel, options.screen, options.processor].filter(Boolean).length;
|
|
6
6
|
if (entityCount === 0) {
|
|
7
|
-
console.error('Error: Must specify one of --command, --event,
|
|
7
|
+
console.error('Error: Must specify one of --command, --event, --read-model, --screen, or --processor');
|
|
8
8
|
process.exit(1);
|
|
9
9
|
}
|
|
10
10
|
if (entityCount > 1) {
|
|
11
|
-
console.error('Error: Can only specify one of --command, --event,
|
|
11
|
+
console.error('Error: Can only specify one of --command, --event, --read-model, --screen, or --processor');
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
if (options.command) {
|
|
@@ -20,6 +20,12 @@ export function removeField(model, filePath, options, fieldName) {
|
|
|
20
20
|
else if (options.readModel) {
|
|
21
21
|
removeFieldFromReadModel(model, filePath, options.readModel, fieldName);
|
|
22
22
|
}
|
|
23
|
+
else if (options.screen) {
|
|
24
|
+
removeFieldFromScreen(model, filePath, options.screen, fieldName);
|
|
25
|
+
}
|
|
26
|
+
else if (options.processor) {
|
|
27
|
+
removeFieldFromProcessor(model, filePath, options.processor, fieldName);
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
30
|
function removeFieldFromCommand(model, filePath, commandName, fieldName) {
|
|
25
31
|
const command = findElementOrExit(model.commands, commandName, 'command');
|
|
@@ -96,3 +102,53 @@ function removeFieldFromReadModel(model, filePath, readModelName, fieldName) {
|
|
|
96
102
|
});
|
|
97
103
|
console.log(`Removed field "${field.name}" from read model "${readModel.name}"`);
|
|
98
104
|
}
|
|
105
|
+
function removeFieldFromScreen(model, filePath, screenName, fieldName) {
|
|
106
|
+
const screen = findElementOrExit(model.screens, screenName, 'screen');
|
|
107
|
+
const fieldNameLower = fieldName.toLowerCase();
|
|
108
|
+
const field = screen.fields.find(f => f.name.toLowerCase() === fieldNameLower);
|
|
109
|
+
if (!field) {
|
|
110
|
+
console.error(`Error: Field "${fieldName}" not found on screen "${screen.name}"`);
|
|
111
|
+
if (screen.fields.length > 0) {
|
|
112
|
+
console.error('Available fields:');
|
|
113
|
+
for (const f of screen.fields) {
|
|
114
|
+
console.error(` - ${f.name} (${f.fieldType})`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.error('This screen has no fields.');
|
|
119
|
+
}
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
appendEvent(filePath, {
|
|
123
|
+
type: 'ScreenFieldRemoved',
|
|
124
|
+
screenId: screen.id,
|
|
125
|
+
fieldId: field.id,
|
|
126
|
+
timestamp: Date.now(),
|
|
127
|
+
});
|
|
128
|
+
console.log(`Removed field "${field.name}" from screen "${screen.name}"`);
|
|
129
|
+
}
|
|
130
|
+
function removeFieldFromProcessor(model, filePath, processorName, fieldName) {
|
|
131
|
+
const processor = findElementOrExit(model.processors, processorName, 'processor');
|
|
132
|
+
const fieldNameLower = fieldName.toLowerCase();
|
|
133
|
+
const field = processor.fields.find(f => f.name.toLowerCase() === fieldNameLower);
|
|
134
|
+
if (!field) {
|
|
135
|
+
console.error(`Error: Field "${fieldName}" not found on processor "${processor.name}"`);
|
|
136
|
+
if (processor.fields.length > 0) {
|
|
137
|
+
console.error('Available fields:');
|
|
138
|
+
for (const f of processor.fields) {
|
|
139
|
+
console.error(` - ${f.name} (${f.fieldType})`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
console.error('This processor has no fields.');
|
|
144
|
+
}
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
appendEvent(filePath, {
|
|
148
|
+
type: 'ProcessorFieldRemoved',
|
|
149
|
+
processorId: processor.id,
|
|
150
|
+
fieldId: field.id,
|
|
151
|
+
timestamp: Date.now(),
|
|
152
|
+
});
|
|
153
|
+
console.log(`Removed field "${field.name}" from processor "${processor.name}"`);
|
|
154
|
+
}
|
|
@@ -33,13 +33,13 @@ function createUpdatedField(original, updates) {
|
|
|
33
33
|
}
|
|
34
34
|
export function updateField(model, filePath, options, fieldName, updates) {
|
|
35
35
|
// Determine which entity type
|
|
36
|
-
const entityCount = [options.command, options.event, options.readModel].filter(Boolean).length;
|
|
36
|
+
const entityCount = [options.command, options.event, options.readModel, options.screen, options.processor].filter(Boolean).length;
|
|
37
37
|
if (entityCount === 0) {
|
|
38
|
-
console.error('Error: Must specify one of --command, --event,
|
|
38
|
+
console.error('Error: Must specify one of --command, --event, --read-model, --screen, or --processor');
|
|
39
39
|
process.exit(1);
|
|
40
40
|
}
|
|
41
41
|
if (entityCount > 1) {
|
|
42
|
-
console.error('Error: Can only specify one of --command, --event,
|
|
42
|
+
console.error('Error: Can only specify one of --command, --event, --read-model, --screen, or --processor');
|
|
43
43
|
process.exit(1);
|
|
44
44
|
}
|
|
45
45
|
if (options.command) {
|
|
@@ -51,6 +51,12 @@ export function updateField(model, filePath, options, fieldName, updates) {
|
|
|
51
51
|
else if (options.readModel) {
|
|
52
52
|
updateReadModelField(model, filePath, options.readModel, fieldName, updates);
|
|
53
53
|
}
|
|
54
|
+
else if (options.screen) {
|
|
55
|
+
updateScreenField(model, filePath, options.screen, fieldName, updates);
|
|
56
|
+
}
|
|
57
|
+
else if (options.processor) {
|
|
58
|
+
updateProcessorField(model, filePath, options.processor, fieldName, updates);
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
function updateCommandField(model, filePath, commandName, fieldName, updates) {
|
|
56
62
|
const command = findElementOrExit(model.commands, commandName, 'command');
|
|
@@ -124,6 +130,54 @@ function updateReadModelField(model, filePath, readModelName, fieldName, updates
|
|
|
124
130
|
console.log(`Updated field "${field.name}" on read model "${readModel.name}"`);
|
|
125
131
|
logUpdates(updates);
|
|
126
132
|
}
|
|
133
|
+
function updateScreenField(model, filePath, screenName, fieldName, updates) {
|
|
134
|
+
const screen = findElementOrExit(model.screens, screenName, 'screen');
|
|
135
|
+
const field = findFieldByName(screen.fields, fieldName);
|
|
136
|
+
if (!field) {
|
|
137
|
+
console.error(`Error: Field "${fieldName}" not found on screen "${screen.name}"`);
|
|
138
|
+
if (screen.fields.length > 0) {
|
|
139
|
+
console.error('Available fields:');
|
|
140
|
+
for (const f of screen.fields) {
|
|
141
|
+
console.error(` - ${f.name}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
const updatedField = createUpdatedField(field, updates);
|
|
147
|
+
appendEvent(filePath, {
|
|
148
|
+
type: 'ScreenFieldAdjusted',
|
|
149
|
+
screenId: screen.id,
|
|
150
|
+
fieldId: field.id,
|
|
151
|
+
field: updatedField,
|
|
152
|
+
timestamp: Date.now(),
|
|
153
|
+
});
|
|
154
|
+
console.log(`Updated field "${field.name}" on screen "${screen.name}"`);
|
|
155
|
+
logUpdates(updates);
|
|
156
|
+
}
|
|
157
|
+
function updateProcessorField(model, filePath, processorName, fieldName, updates) {
|
|
158
|
+
const processor = findElementOrExit(model.processors, processorName, 'processor');
|
|
159
|
+
const field = findFieldByName(processor.fields, fieldName);
|
|
160
|
+
if (!field) {
|
|
161
|
+
console.error(`Error: Field "${fieldName}" not found on processor "${processor.name}"`);
|
|
162
|
+
if (processor.fields.length > 0) {
|
|
163
|
+
console.error('Available fields:');
|
|
164
|
+
for (const f of processor.fields) {
|
|
165
|
+
console.error(` - ${f.name}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
const updatedField = createUpdatedField(field, updates);
|
|
171
|
+
appendEvent(filePath, {
|
|
172
|
+
type: 'ProcessorFieldAdjusted',
|
|
173
|
+
processorId: processor.id,
|
|
174
|
+
fieldId: field.id,
|
|
175
|
+
field: updatedField,
|
|
176
|
+
timestamp: Date.now(),
|
|
177
|
+
});
|
|
178
|
+
console.log(`Updated field "${field.name}" on processor "${processor.name}"`);
|
|
179
|
+
logUpdates(updates);
|
|
180
|
+
}
|
|
127
181
|
function logUpdates(updates) {
|
|
128
182
|
if (updates.optional !== undefined) {
|
|
129
183
|
console.log(` isOptional: ${updates.optional}`);
|