eventmodeler 0.2.10 → 0.3.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/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] [--user-input true|false (screen only)]
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,21 @@ 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');
424
+ const userInputArg = getNamedArg(filteredArgs, '--user-input');
418
425
  const typeArg = getNamedArg(filteredArgs, '--type');
419
426
  if (!fieldArg) {
420
427
  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]');
428
+ console.error('Usage: eventmodeler update field --command|--event|--read-model|--screen|--processor <name> --field <field-name> [--optional true|false] [--generated true|false] [--user-input true|false (screen only)]');
429
+ process.exit(1);
430
+ }
431
+ // --user-input is only valid for screens
432
+ if (userInputArg !== undefined && !screenArg) {
433
+ console.error('Error: --user-input can only be used with --screen');
422
434
  process.exit(1);
423
435
  }
424
436
  const updates = {};
@@ -428,14 +440,17 @@ async function main() {
428
440
  if (generatedArg !== undefined) {
429
441
  updates.generated = generatedArg === 'true';
430
442
  }
443
+ if (userInputArg !== undefined) {
444
+ updates.userInput = userInputArg === 'true';
445
+ }
431
446
  if (typeArg !== undefined) {
432
447
  updates.type = typeArg;
433
448
  }
434
449
  if (Object.keys(updates).length === 0) {
435
- console.error('Error: Must specify at least one update (--optional, --generated, or --type)');
450
+ console.error('Error: Must specify at least one update (--optional, --generated, --user-input, or --type)');
436
451
  process.exit(1);
437
452
  }
438
- updateField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg }, fieldArg, updates);
453
+ updateField(model, filePath, { command: commandArg, event: eventArg, readModel: readModelArg, screen: screenArg, processor: processorArg }, fieldArg, updates);
439
454
  break;
440
455
  }
441
456
  default:
@@ -3,4 +3,6 @@ export declare function addField(model: EventModel, filePath: string, options: {
3
3
  command?: string;
4
4
  event?: string;
5
5
  readModel?: string;
6
+ screen?: string;
7
+ processor?: string;
6
8
  }, input: string): void;
@@ -36,6 +36,7 @@ function parseXmlInput(input) {
36
36
  isList: getBoolAttr(fieldMatch[1], 'isList'),
37
37
  isGenerated: getBoolAttr(fieldMatch[1], 'isGenerated'),
38
38
  isOptional: getBoolAttr(fieldMatch[1], 'isOptional'),
39
+ isUserInput: getBoolAttr(fieldMatch[1], 'isUserInput'),
39
40
  };
40
41
  // Parse nested subfields for Custom type
41
42
  if (type === 'Custom' && fieldMatch[2]) {
@@ -63,18 +64,19 @@ function createFieldFromInput(input) {
63
64
  isList: input.isList ?? false,
64
65
  isGenerated: input.isGenerated ?? false,
65
66
  isOptional: input.isOptional,
67
+ isUserInput: input.isUserInput,
66
68
  subfields: input.subfields?.map(createFieldFromInput),
67
69
  };
68
70
  }
69
71
  export function addField(model, filePath, options, input) {
70
72
  // Determine which entity type
71
- const entityCount = [options.command, options.event, options.readModel].filter(Boolean).length;
73
+ const entityCount = [options.command, options.event, options.readModel, options.screen, options.processor].filter(Boolean).length;
72
74
  if (entityCount === 0) {
73
- console.error('Error: Must specify one of --command, --event, or --read-model');
75
+ console.error('Error: Must specify one of --command, --event, --read-model, --screen, or --processor');
74
76
  process.exit(1);
75
77
  }
76
78
  if (entityCount > 1) {
77
- console.error('Error: Can only specify one of --command, --event, or --read-model');
79
+ console.error('Error: Can only specify one of --command, --event, --read-model, --screen, or --processor');
78
80
  process.exit(1);
79
81
  }
80
82
  // Parse input
@@ -107,6 +109,12 @@ export function addField(model, filePath, options, input) {
107
109
  else if (options.readModel) {
108
110
  addFieldToReadModel(model, filePath, options.readModel, fieldInput);
109
111
  }
112
+ else if (options.screen) {
113
+ addFieldToScreen(model, filePath, options.screen, fieldInput);
114
+ }
115
+ else if (options.processor) {
116
+ addFieldToProcessor(model, filePath, options.processor, fieldInput);
117
+ }
110
118
  }
111
119
  function addFieldToCommand(model, filePath, commandName, fieldInput) {
112
120
  const command = findElementOrExit(model.commands, commandName, 'command');
@@ -156,3 +164,35 @@ function addFieldToReadModel(model, filePath, readModelName, fieldInput) {
156
164
  });
157
165
  console.log(`Added field "${field.name}" to read model "${readModel.name}"`);
158
166
  }
167
+ function addFieldToScreen(model, filePath, screenName, fieldInput) {
168
+ const screen = findElementOrExit(model.screens, screenName, 'screen');
169
+ // Check for duplicate field name
170
+ if (screen.fields.some(f => f.name.toLowerCase() === fieldInput.name.toLowerCase())) {
171
+ console.error(`Error: Field "${fieldInput.name}" already exists on screen "${screen.name}"`);
172
+ process.exit(1);
173
+ }
174
+ const field = createFieldFromInput(fieldInput);
175
+ appendEvent(filePath, {
176
+ type: 'ScreenFieldAdded',
177
+ screenId: screen.id,
178
+ field,
179
+ timestamp: Date.now(),
180
+ });
181
+ console.log(`Added field "${field.name}" to screen "${screen.name}"`);
182
+ }
183
+ function addFieldToProcessor(model, filePath, processorName, fieldInput) {
184
+ const processor = findElementOrExit(model.processors, processorName, 'processor');
185
+ // Check for duplicate field name
186
+ if (processor.fields.some(f => f.name.toLowerCase() === fieldInput.name.toLowerCase())) {
187
+ console.error(`Error: Field "${fieldInput.name}" already exists on processor "${processor.name}"`);
188
+ process.exit(1);
189
+ }
190
+ const field = createFieldFromInput(fieldInput);
191
+ appendEvent(filePath, {
192
+ type: 'ProcessorFieldAdded',
193
+ processorId: processor.id,
194
+ field,
195
+ timestamp: Date.now(),
196
+ });
197
+ console.log(`Added field "${field.name}" to processor "${processor.name}"`);
198
+ }
@@ -3,4 +3,6 @@ export declare function removeField(model: EventModel, filePath: string, options
3
3
  command?: string;
4
4
  event?: string;
5
5
  readModel?: string;
6
+ screen?: string;
7
+ processor?: string;
6
8
  }, fieldName: string): void;
@@ -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, or --read-model');
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, or --read-model');
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
+ }
@@ -2,11 +2,14 @@ import type { EventModel } from '../../types.js';
2
2
  interface UpdateOptions {
3
3
  optional?: boolean;
4
4
  generated?: boolean;
5
+ userInput?: boolean;
5
6
  type?: string;
6
7
  }
7
8
  export declare function updateField(model: EventModel, filePath: string, options: {
8
9
  command?: string;
9
10
  event?: string;
10
11
  readModel?: string;
12
+ screen?: string;
13
+ processor?: string;
11
14
  }, fieldName: string, updates: UpdateOptions): void;
12
15
  export {};
@@ -28,18 +28,19 @@ function createUpdatedField(original, updates) {
28
28
  ...original,
29
29
  isOptional: updates.optional !== undefined ? updates.optional : original.isOptional,
30
30
  isGenerated: updates.generated !== undefined ? updates.generated : original.isGenerated,
31
+ isUserInput: updates.userInput !== undefined ? updates.userInput : original.isUserInput,
31
32
  fieldType: updates.type !== undefined ? updates.type : original.fieldType,
32
33
  };
33
34
  }
34
35
  export function updateField(model, filePath, options, fieldName, updates) {
35
36
  // Determine which entity type
36
- const entityCount = [options.command, options.event, options.readModel].filter(Boolean).length;
37
+ const entityCount = [options.command, options.event, options.readModel, options.screen, options.processor].filter(Boolean).length;
37
38
  if (entityCount === 0) {
38
- console.error('Error: Must specify one of --command, --event, or --read-model');
39
+ console.error('Error: Must specify one of --command, --event, --read-model, --screen, or --processor');
39
40
  process.exit(1);
40
41
  }
41
42
  if (entityCount > 1) {
42
- console.error('Error: Can only specify one of --command, --event, or --read-model');
43
+ console.error('Error: Can only specify one of --command, --event, --read-model, --screen, or --processor');
43
44
  process.exit(1);
44
45
  }
45
46
  if (options.command) {
@@ -51,6 +52,12 @@ export function updateField(model, filePath, options, fieldName, updates) {
51
52
  else if (options.readModel) {
52
53
  updateReadModelField(model, filePath, options.readModel, fieldName, updates);
53
54
  }
55
+ else if (options.screen) {
56
+ updateScreenField(model, filePath, options.screen, fieldName, updates);
57
+ }
58
+ else if (options.processor) {
59
+ updateProcessorField(model, filePath, options.processor, fieldName, updates);
60
+ }
54
61
  }
55
62
  function updateCommandField(model, filePath, commandName, fieldName, updates) {
56
63
  const command = findElementOrExit(model.commands, commandName, 'command');
@@ -124,6 +131,54 @@ function updateReadModelField(model, filePath, readModelName, fieldName, updates
124
131
  console.log(`Updated field "${field.name}" on read model "${readModel.name}"`);
125
132
  logUpdates(updates);
126
133
  }
134
+ function updateScreenField(model, filePath, screenName, fieldName, updates) {
135
+ const screen = findElementOrExit(model.screens, screenName, 'screen');
136
+ const field = findFieldByName(screen.fields, fieldName);
137
+ if (!field) {
138
+ console.error(`Error: Field "${fieldName}" not found on screen "${screen.name}"`);
139
+ if (screen.fields.length > 0) {
140
+ console.error('Available fields:');
141
+ for (const f of screen.fields) {
142
+ console.error(` - ${f.name}`);
143
+ }
144
+ }
145
+ process.exit(1);
146
+ }
147
+ const updatedField = createUpdatedField(field, updates);
148
+ appendEvent(filePath, {
149
+ type: 'ScreenFieldAdjusted',
150
+ screenId: screen.id,
151
+ fieldId: field.id,
152
+ field: updatedField,
153
+ timestamp: Date.now(),
154
+ });
155
+ console.log(`Updated field "${field.name}" on screen "${screen.name}"`);
156
+ logUpdates(updates);
157
+ }
158
+ function updateProcessorField(model, filePath, processorName, fieldName, updates) {
159
+ const processor = findElementOrExit(model.processors, processorName, 'processor');
160
+ const field = findFieldByName(processor.fields, fieldName);
161
+ if (!field) {
162
+ console.error(`Error: Field "${fieldName}" not found on processor "${processor.name}"`);
163
+ if (processor.fields.length > 0) {
164
+ console.error('Available fields:');
165
+ for (const f of processor.fields) {
166
+ console.error(` - ${f.name}`);
167
+ }
168
+ }
169
+ process.exit(1);
170
+ }
171
+ const updatedField = createUpdatedField(field, updates);
172
+ appendEvent(filePath, {
173
+ type: 'ProcessorFieldAdjusted',
174
+ processorId: processor.id,
175
+ fieldId: field.id,
176
+ field: updatedField,
177
+ timestamp: Date.now(),
178
+ });
179
+ console.log(`Updated field "${field.name}" on processor "${processor.name}"`);
180
+ logUpdates(updates);
181
+ }
127
182
  function logUpdates(updates) {
128
183
  if (updates.optional !== undefined) {
129
184
  console.log(` isOptional: ${updates.optional}`);
@@ -131,6 +186,9 @@ function logUpdates(updates) {
131
186
  if (updates.generated !== undefined) {
132
187
  console.log(` isGenerated: ${updates.generated}`);
133
188
  }
189
+ if (updates.userInput !== undefined) {
190
+ console.log(` isUserInput: ${updates.userInput}`);
191
+ }
134
192
  if (updates.type !== undefined) {
135
193
  console.log(` fieldType: ${updates.type}`);
136
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eventmodeler",
3
- "version": "0.2.10",
3
+ "version": "0.3.1",
4
4
  "description": "CLI tool for interacting with Event Model files - query, update, and export event models from the terminal",
5
5
  "type": "module",
6
6
  "bin": {