eventmodeler 0.2.3 → 0.2.5
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 +63 -0
- package/dist/lib/element-lookup.d.ts +47 -0
- package/dist/lib/element-lookup.js +86 -0
- package/dist/lib/slice-utils.d.ts +83 -0
- package/dist/lib/slice-utils.js +135 -0
- package/dist/slices/add-field/index.js +4 -33
- package/dist/slices/add-scenario/index.js +15 -77
- package/dist/slices/create-automation-slice/index.d.ts +2 -0
- package/dist/slices/create-automation-slice/index.js +217 -0
- package/dist/slices/create-flow/index.d.ts +2 -0
- package/dist/slices/create-flow/index.js +177 -0
- package/dist/slices/create-state-change-slice/index.d.ts +2 -0
- package/dist/slices/create-state-change-slice/index.js +239 -0
- package/dist/slices/create-state-view-slice/index.d.ts +2 -0
- package/dist/slices/create-state-view-slice/index.js +120 -0
- package/dist/slices/list-chapters/index.js +2 -2
- package/dist/slices/list-commands/index.js +2 -2
- package/dist/slices/list-events/index.js +3 -2
- package/dist/slices/list-slices/index.js +2 -2
- package/dist/slices/mark-slice-status/index.js +2 -11
- package/dist/slices/remove-field/index.js +4 -33
- package/dist/slices/remove-scenario/index.js +45 -11
- package/dist/slices/show-actor/index.js +2 -11
- package/dist/slices/show-aggregate-completeness/index.js +2 -11
- package/dist/slices/show-chapter/index.js +6 -14
- package/dist/slices/show-command/index.js +4 -12
- package/dist/slices/show-completeness/index.js +378 -32
- package/dist/slices/show-event/index.js +4 -12
- package/dist/slices/show-slice/index.js +14 -17
- package/dist/slices/update-field/index.js +4 -33
- package/package.json +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { appendEvent } from '../../lib/file-loader.js';
|
|
2
|
+
import { STATE_VIEW_SLICE, SLICE_GAP, calculateSlicePosition, validateSliceNameUnique, parseFieldsFromXml, getSlicesToShift, fieldInputToField, } from '../../lib/slice-utils.js';
|
|
3
|
+
function getAttr(attrs, name) {
|
|
4
|
+
const match = attrs.match(new RegExp(`${name}="([^"]*)"`));
|
|
5
|
+
return match ? match[1] : undefined;
|
|
6
|
+
}
|
|
7
|
+
function parseXmlInput(xml) {
|
|
8
|
+
// Parse <state-view-slice name="..." after="..." before="...">
|
|
9
|
+
const sliceMatch = xml.match(/<state-view-slice([^>]*)>/);
|
|
10
|
+
if (!sliceMatch) {
|
|
11
|
+
throw new Error('Invalid XML: missing <state-view-slice> tag');
|
|
12
|
+
}
|
|
13
|
+
const sliceName = getAttr(sliceMatch[1], 'name');
|
|
14
|
+
if (!sliceName) {
|
|
15
|
+
throw new Error('Invalid XML: state-view-slice must have a name attribute');
|
|
16
|
+
}
|
|
17
|
+
const after = getAttr(sliceMatch[1], 'after');
|
|
18
|
+
const before = getAttr(sliceMatch[1], 'before');
|
|
19
|
+
// Parse read-model
|
|
20
|
+
const readModelMatch = xml.match(/<read-model([^>]*)>([\s\S]*?)<\/read-model>/);
|
|
21
|
+
if (!readModelMatch) {
|
|
22
|
+
throw new Error('Invalid XML: missing <read-model> element');
|
|
23
|
+
}
|
|
24
|
+
const readModelName = getAttr(readModelMatch[1], 'name');
|
|
25
|
+
if (!readModelName) {
|
|
26
|
+
throw new Error('Invalid XML: read-model must have a name attribute');
|
|
27
|
+
}
|
|
28
|
+
const readModelFields = parseFieldsFromXml(readModelMatch[2]);
|
|
29
|
+
return {
|
|
30
|
+
sliceName,
|
|
31
|
+
after,
|
|
32
|
+
before,
|
|
33
|
+
readModel: { name: readModelName, fields: readModelFields },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function createStateViewSlice(model, filePath, xmlInput) {
|
|
37
|
+
// Parse input
|
|
38
|
+
let input;
|
|
39
|
+
try {
|
|
40
|
+
input = parseXmlInput(xmlInput);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(`Error: ${err.message}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
// Validate slice name is unique
|
|
47
|
+
try {
|
|
48
|
+
validateSliceNameUnique(model, input.sliceName);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
console.error(`Error: ${err.message}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
// Calculate position
|
|
55
|
+
let slicePosition;
|
|
56
|
+
try {
|
|
57
|
+
slicePosition = calculateSlicePosition(model, STATE_VIEW_SLICE.width, {
|
|
58
|
+
after: input.after,
|
|
59
|
+
before: input.before,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error(`Error: ${err.message}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
// Handle "before" positioning - shift existing slices
|
|
67
|
+
if (input.before) {
|
|
68
|
+
const shiftAmount = STATE_VIEW_SLICE.width + SLICE_GAP;
|
|
69
|
+
const toShift = getSlicesToShift(model, slicePosition.x, shiftAmount);
|
|
70
|
+
for (const { sliceId, newX, currentY } of toShift) {
|
|
71
|
+
appendEvent(filePath, {
|
|
72
|
+
type: 'SliceMoved',
|
|
73
|
+
sliceId,
|
|
74
|
+
position: { x: newX, y: currentY },
|
|
75
|
+
timestamp: Date.now(),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Generate IDs
|
|
80
|
+
const sliceId = crypto.randomUUID();
|
|
81
|
+
const readModelId = crypto.randomUUID();
|
|
82
|
+
// Convert field inputs to fields with IDs
|
|
83
|
+
const readModelFields = input.readModel.fields.map(fieldInputToField);
|
|
84
|
+
// Calculate absolute position for read model within the slice
|
|
85
|
+
const readModelPosition = {
|
|
86
|
+
x: slicePosition.x + STATE_VIEW_SLICE.readModel.offsetX,
|
|
87
|
+
y: slicePosition.y + STATE_VIEW_SLICE.readModel.offsetY,
|
|
88
|
+
};
|
|
89
|
+
// Emit atomic events in sequence
|
|
90
|
+
// 1. Create the slice
|
|
91
|
+
appendEvent(filePath, {
|
|
92
|
+
type: 'SlicePlaced',
|
|
93
|
+
sliceId,
|
|
94
|
+
name: input.sliceName,
|
|
95
|
+
position: slicePosition,
|
|
96
|
+
size: { width: STATE_VIEW_SLICE.width, height: STATE_VIEW_SLICE.height },
|
|
97
|
+
timestamp: Date.now(),
|
|
98
|
+
});
|
|
99
|
+
// 2. Create the read model
|
|
100
|
+
appendEvent(filePath, {
|
|
101
|
+
type: 'ReadModelStickyPlaced',
|
|
102
|
+
readModelStickyId: readModelId,
|
|
103
|
+
name: input.readModel.name,
|
|
104
|
+
position: readModelPosition,
|
|
105
|
+
width: STATE_VIEW_SLICE.readModel.width,
|
|
106
|
+
height: STATE_VIEW_SLICE.readModel.height,
|
|
107
|
+
timestamp: Date.now(),
|
|
108
|
+
});
|
|
109
|
+
// 3. Add read model fields
|
|
110
|
+
for (const field of readModelFields) {
|
|
111
|
+
appendEvent(filePath, {
|
|
112
|
+
type: 'ReadModelFieldAdded',
|
|
113
|
+
readModelStickyId: readModelId,
|
|
114
|
+
field,
|
|
115
|
+
timestamp: Date.now(),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
console.log(`Created state-view slice "${input.sliceName}"`);
|
|
119
|
+
console.log(` ReadModel: ${input.readModel.name} (${readModelFields.length} fields)`);
|
|
120
|
+
}
|
|
@@ -5,7 +5,7 @@ export function listChapters(model, format) {
|
|
|
5
5
|
const sorted = [...chapters].sort((a, b) => a.position.x - b.position.x);
|
|
6
6
|
if (format === 'json') {
|
|
7
7
|
outputJson({
|
|
8
|
-
chapters: sorted.map(ch => ({ name: ch.name }))
|
|
8
|
+
chapters: sorted.map(ch => ({ id: ch.id, name: ch.name }))
|
|
9
9
|
});
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
@@ -15,7 +15,7 @@ export function listChapters(model, format) {
|
|
|
15
15
|
}
|
|
16
16
|
console.log('<chapters>');
|
|
17
17
|
for (const chapter of sorted) {
|
|
18
|
-
console.log(` <chapter name="${escapeXml(chapter.name)}"/>`);
|
|
18
|
+
console.log(` <chapter id="${chapter.id}" name="${escapeXml(chapter.name)}"/>`);
|
|
19
19
|
}
|
|
20
20
|
console.log('</chapters>');
|
|
21
21
|
}
|
|
@@ -4,7 +4,7 @@ export function listCommands(model, format) {
|
|
|
4
4
|
const sorted = [...commands].sort((a, b) => a.name.localeCompare(b.name));
|
|
5
5
|
if (format === 'json') {
|
|
6
6
|
outputJson({
|
|
7
|
-
commands: sorted.map(cmd => ({ name: cmd.name, fields: cmd.fields.length }))
|
|
7
|
+
commands: sorted.map(cmd => ({ id: cmd.id, name: cmd.name, fields: cmd.fields.length }))
|
|
8
8
|
});
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
@@ -14,7 +14,7 @@ export function listCommands(model, format) {
|
|
|
14
14
|
}
|
|
15
15
|
console.log('<commands>');
|
|
16
16
|
for (const cmd of sorted) {
|
|
17
|
-
console.log(` <command name="${escapeXml(cmd.name)}" fields="${cmd.fields.length}"/>`);
|
|
17
|
+
console.log(` <command id="${cmd.id}" name="${escapeXml(cmd.name)}" fields="${cmd.fields.length}"/>`);
|
|
18
18
|
}
|
|
19
19
|
console.log('</commands>');
|
|
20
20
|
}
|
|
@@ -47,6 +47,7 @@ export function listEvents(model, format) {
|
|
|
47
47
|
events: sorted.map(evt => {
|
|
48
48
|
const aggregate = findAggregateForEvent(model, evt);
|
|
49
49
|
const result = {
|
|
50
|
+
id: evt.id,
|
|
50
51
|
name: evt.name,
|
|
51
52
|
fields: evt.fields.length,
|
|
52
53
|
};
|
|
@@ -82,7 +83,7 @@ export function listEvents(model, format) {
|
|
|
82
83
|
const original = model.events.get(evt.originalNodeId);
|
|
83
84
|
const originSlice = original ? findSliceForEvent(model, original) : null;
|
|
84
85
|
const originAttr = originSlice ? ` origin-slice="${escapeXml(originSlice)}"` : '';
|
|
85
|
-
console.log(` <event name="${escapeXml(evt.name)}" fields="${evt.fields.length}"${aggregateAttr} linked-copy="true"${originAttr}/>`);
|
|
86
|
+
console.log(` <event id="${evt.id}" name="${escapeXml(evt.name)}" fields="${evt.fields.length}"${aggregateAttr} linked-copy="true"${originAttr}/>`);
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
88
89
|
// This is an original - show copy count
|
|
@@ -90,7 +91,7 @@ export function listEvents(model, format) {
|
|
|
90
91
|
? [...model.events.values()].filter(e => e.canonicalId === evt.canonicalId && e.originalNodeId).length
|
|
91
92
|
: 0;
|
|
92
93
|
const copiesAttr = copyCount > 0 ? ` copies="${copyCount}"` : '';
|
|
93
|
-
console.log(` <event name="${escapeXml(evt.name)}" fields="${evt.fields.length}"${aggregateAttr}${copiesAttr}/>`);
|
|
94
|
+
console.log(` <event id="${evt.id}" name="${escapeXml(evt.name)}" fields="${evt.fields.length}"${aggregateAttr}${copiesAttr}/>`);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
console.log('</events>');
|
|
@@ -4,7 +4,7 @@ export function listSlices(model, format) {
|
|
|
4
4
|
const sorted = [...slices].sort((a, b) => a.position.x - b.position.x);
|
|
5
5
|
if (format === 'json') {
|
|
6
6
|
outputJson({
|
|
7
|
-
slices: sorted.map(s => ({ name: s.name, status: s.status }))
|
|
7
|
+
slices: sorted.map(s => ({ id: s.id, name: s.name, status: s.status }))
|
|
8
8
|
});
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
@@ -14,7 +14,7 @@ export function listSlices(model, format) {
|
|
|
14
14
|
}
|
|
15
15
|
console.log('<slices>');
|
|
16
16
|
for (const slice of sorted) {
|
|
17
|
-
console.log(` <slice name="${escapeXml(slice.name)}" status="${slice.status}"/>`);
|
|
17
|
+
console.log(` <slice id="${slice.id}" name="${escapeXml(slice.name)}" status="${slice.status}"/>`);
|
|
18
18
|
}
|
|
19
19
|
console.log('</slices>');
|
|
20
20
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { appendEvent } from '../../lib/file-loader.js';
|
|
2
|
+
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
2
3
|
const validStatuses = ['created', 'in-progress', 'blocked', 'done'];
|
|
3
4
|
const eventTypeMap = {
|
|
4
5
|
'created': 'SliceMarkedAsCreated',
|
|
@@ -13,17 +14,7 @@ export function markSliceStatus(model, filePath, sliceName, status) {
|
|
|
13
14
|
process.exit(1);
|
|
14
15
|
}
|
|
15
16
|
const newStatus = status;
|
|
16
|
-
const
|
|
17
|
-
const sliceNameLower = sliceName.toLowerCase();
|
|
18
|
-
const slice = slices.find(s => s.name.toLowerCase() === sliceNameLower || s.name.toLowerCase().includes(sliceNameLower));
|
|
19
|
-
if (!slice) {
|
|
20
|
-
console.error(`Error: Slice not found: ${sliceName}`);
|
|
21
|
-
console.error('Available slices:');
|
|
22
|
-
for (const s of slices) {
|
|
23
|
-
console.error(` - ${s.name}`);
|
|
24
|
-
}
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
17
|
+
const slice = findElementOrExit(model.slices, sliceName, 'slice');
|
|
27
18
|
if (slice.status === newStatus) {
|
|
28
19
|
console.log(`Slice "${slice.name}" is already marked as ${newStatus}`);
|
|
29
20
|
return;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { appendEvent } from '../../lib/file-loader.js';
|
|
2
|
+
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
2
3
|
export function removeField(model, filePath, options, fieldName) {
|
|
3
4
|
// Determine which entity type
|
|
4
5
|
const entityCount = [options.command, options.event, options.readModel].filter(Boolean).length;
|
|
@@ -21,17 +22,7 @@ export function removeField(model, filePath, options, fieldName) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
function removeFieldFromCommand(model, filePath, commandName, fieldName) {
|
|
24
|
-
const
|
|
25
|
-
const commands = [...model.commands.values()];
|
|
26
|
-
const command = commands.find(c => c.name.toLowerCase() === nameLower || c.name.toLowerCase().includes(nameLower));
|
|
27
|
-
if (!command) {
|
|
28
|
-
console.error(`Error: Command not found: ${commandName}`);
|
|
29
|
-
console.error('Available commands:');
|
|
30
|
-
for (const c of commands) {
|
|
31
|
-
console.error(` - ${c.name}`);
|
|
32
|
-
}
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
25
|
+
const command = findElementOrExit(model.commands, commandName, 'command');
|
|
35
26
|
const fieldNameLower = fieldName.toLowerCase();
|
|
36
27
|
const field = command.fields.find(f => f.name.toLowerCase() === fieldNameLower);
|
|
37
28
|
if (!field) {
|
|
@@ -56,17 +47,7 @@ function removeFieldFromCommand(model, filePath, commandName, fieldName) {
|
|
|
56
47
|
console.log(`Removed field "${field.name}" from command "${command.name}"`);
|
|
57
48
|
}
|
|
58
49
|
function removeFieldFromEvent(model, filePath, eventName, fieldName) {
|
|
59
|
-
const
|
|
60
|
-
const events = [...model.events.values()];
|
|
61
|
-
const event = events.find(e => e.name.toLowerCase() === nameLower || e.name.toLowerCase().includes(nameLower));
|
|
62
|
-
if (!event) {
|
|
63
|
-
console.error(`Error: Event not found: ${eventName}`);
|
|
64
|
-
console.error('Available events:');
|
|
65
|
-
for (const e of events) {
|
|
66
|
-
console.error(` - ${e.name}`);
|
|
67
|
-
}
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
50
|
+
const event = findElementOrExit(model.events, eventName, 'event');
|
|
70
51
|
const fieldNameLower = fieldName.toLowerCase();
|
|
71
52
|
const field = event.fields.find(f => f.name.toLowerCase() === fieldNameLower);
|
|
72
53
|
if (!field) {
|
|
@@ -91,17 +72,7 @@ function removeFieldFromEvent(model, filePath, eventName, fieldName) {
|
|
|
91
72
|
console.log(`Removed field "${field.name}" from event "${event.name}"`);
|
|
92
73
|
}
|
|
93
74
|
function removeFieldFromReadModel(model, filePath, readModelName, fieldName) {
|
|
94
|
-
const
|
|
95
|
-
const readModels = [...model.readModels.values()];
|
|
96
|
-
const readModel = readModels.find(rm => rm.name.toLowerCase() === nameLower || rm.name.toLowerCase().includes(nameLower));
|
|
97
|
-
if (!readModel) {
|
|
98
|
-
console.error(`Error: Read model not found: ${readModelName}`);
|
|
99
|
-
console.error('Available read models:');
|
|
100
|
-
for (const rm of readModels) {
|
|
101
|
-
console.error(` - ${rm.name}`);
|
|
102
|
-
}
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
75
|
+
const readModel = findElementOrExit(model.readModels, readModelName, 'read model');
|
|
105
76
|
const fieldNameLower = fieldName.toLowerCase();
|
|
106
77
|
const field = readModel.fields.find(f => f.name.toLowerCase() === fieldNameLower);
|
|
107
78
|
if (!field) {
|
|
@@ -1,31 +1,65 @@
|
|
|
1
1
|
import { appendEvent } from '../../lib/file-loader.js';
|
|
2
|
+
import { findElement, formatElementWithId } from '../../lib/element-lookup.js';
|
|
2
3
|
export function removeScenario(model, filePath, scenarioName, sliceName) {
|
|
4
|
+
// Check for UUID lookup
|
|
5
|
+
if (scenarioName.startsWith('id:')) {
|
|
6
|
+
const idSearch = scenarioName.slice(3).toLowerCase();
|
|
7
|
+
const scenario = [...model.scenarios.values()].find(s => s.id.toLowerCase().startsWith(idSearch));
|
|
8
|
+
if (!scenario) {
|
|
9
|
+
console.error(`Error: Scenario not found with ID starting with: "${idSearch}"`);
|
|
10
|
+
console.error('Available scenarios:');
|
|
11
|
+
for (const s of model.scenarios.values()) {
|
|
12
|
+
const slice = model.slices.get(s.sliceId);
|
|
13
|
+
console.error(` - "${s.name}" (id: ${s.id.slice(0, 8)}) (in slice "${slice?.name ?? 'unknown'}")`);
|
|
14
|
+
}
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const slice = model.slices.get(scenario.sliceId);
|
|
18
|
+
appendEvent(filePath, {
|
|
19
|
+
type: 'ScenarioRemoved',
|
|
20
|
+
scenarioId: scenario.id,
|
|
21
|
+
timestamp: Date.now(),
|
|
22
|
+
});
|
|
23
|
+
console.log(`Removed scenario "${scenario.name}" from slice "${slice?.name ?? 'unknown'}"`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Case-insensitive exact name match
|
|
3
27
|
const scenarioNameLower = scenarioName.toLowerCase();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// If slice name provided, filter to that slice
|
|
28
|
+
let matchingScenarios = [...model.scenarios.values()].filter(s => s.name.toLowerCase() === scenarioNameLower);
|
|
29
|
+
// If slice name provided, filter to that slice using exact match
|
|
7
30
|
if (sliceName && matchingScenarios.length > 0) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
31
|
+
const sliceResult = findElement(model.slices, sliceName);
|
|
32
|
+
if (sliceResult.success) {
|
|
33
|
+
matchingScenarios = matchingScenarios.filter(s => s.sliceId === sliceResult.element.id);
|
|
34
|
+
}
|
|
35
|
+
else if (sliceResult.error === 'ambiguous') {
|
|
36
|
+
console.error(`Error: Multiple slices found with name "${sliceName}"`);
|
|
37
|
+
console.error('Please specify using the slice ID:');
|
|
38
|
+
for (const s of sliceResult.matches) {
|
|
39
|
+
console.error(` - ${formatElementWithId(s, false)}`);
|
|
40
|
+
}
|
|
41
|
+
process.exit(1);
|
|
12
42
|
}
|
|
43
|
+
// If slice not found, just proceed without filtering
|
|
13
44
|
}
|
|
14
45
|
if (matchingScenarios.length === 0) {
|
|
15
|
-
console.error(`Error: Scenario not found: ${scenarioName}`);
|
|
46
|
+
console.error(`Error: Scenario not found: "${scenarioName}"`);
|
|
16
47
|
console.error('Available scenarios:');
|
|
17
48
|
for (const s of model.scenarios.values()) {
|
|
18
49
|
const slice = model.slices.get(s.sliceId);
|
|
19
|
-
console.error(` - "${s.name}" (in slice "${slice?.name ?? 'unknown'}")`);
|
|
50
|
+
console.error(` - "${s.name}" (id: ${s.id.slice(0, 8)}) (in slice "${slice?.name ?? 'unknown'}")`);
|
|
20
51
|
}
|
|
21
52
|
process.exit(1);
|
|
22
53
|
}
|
|
23
54
|
if (matchingScenarios.length > 1) {
|
|
24
|
-
console.error(`Error: Multiple scenarios
|
|
55
|
+
console.error(`Error: Multiple scenarios found with name "${scenarioName}"`);
|
|
56
|
+
console.error('Please specify using the scenario ID or --slice to disambiguate:');
|
|
25
57
|
for (const s of matchingScenarios) {
|
|
26
58
|
const slice = model.slices.get(s.sliceId);
|
|
27
|
-
console.error(` - "${s.name}" in slice "${slice?.name ?? 'unknown'}"`);
|
|
59
|
+
console.error(` - "${s.name}" (id: ${s.id.slice(0, 8)}) (in slice "${slice?.name ?? 'unknown'}")`);
|
|
28
60
|
}
|
|
61
|
+
console.error('');
|
|
62
|
+
console.error(`Usage: eventmodeler remove scenario "id:${matchingScenarios[0].id.slice(0, 8)}"`);
|
|
29
63
|
process.exit(1);
|
|
30
64
|
}
|
|
31
65
|
const scenario = matchingScenarios[0];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { escapeXml, outputJson } from '../../lib/format.js';
|
|
2
|
+
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
2
3
|
// Get screens whose center point is inside the actor bounds
|
|
3
4
|
function getScreensInActor(model, actor) {
|
|
4
5
|
const bounds = {
|
|
@@ -30,17 +31,7 @@ function findSliceForScreen(model, screen) {
|
|
|
30
31
|
}
|
|
31
32
|
export function showActor(model, actorName, format) {
|
|
32
33
|
// Find the actor
|
|
33
|
-
const
|
|
34
|
-
const actors = [...model.actors.values()];
|
|
35
|
-
const actor = actors.find(a => a.name.toLowerCase() === nameLower || a.name.toLowerCase().includes(nameLower));
|
|
36
|
-
if (!actor) {
|
|
37
|
-
console.error(`Error: Actor not found: ${actorName}`);
|
|
38
|
-
console.error('Available actors:');
|
|
39
|
-
for (const a of actors) {
|
|
40
|
-
console.error(` - ${a.name}`);
|
|
41
|
-
}
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
34
|
+
const actor = findElementOrExit(model.actors, actorName, 'actor');
|
|
44
35
|
// Get screens dynamically based on position (center point inside actor bounds)
|
|
45
36
|
const screensInActor = getScreensInActor(model, actor);
|
|
46
37
|
if (format === 'json') {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { escapeXml, outputJson } from '../../lib/format.js';
|
|
2
|
+
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
2
3
|
function findMatchingField(fields, targetName, targetType) {
|
|
3
4
|
for (const field of fields) {
|
|
4
5
|
// Check if name and type match
|
|
@@ -34,17 +35,7 @@ function getEventsInAggregate(model, aggregate) {
|
|
|
34
35
|
}
|
|
35
36
|
export function showAggregateCompleteness(model, aggregateName, format) {
|
|
36
37
|
// Find the aggregate
|
|
37
|
-
const
|
|
38
|
-
const aggregates = [...model.aggregates.values()];
|
|
39
|
-
const aggregate = aggregates.find(a => a.name.toLowerCase() === nameLower || a.name.toLowerCase().includes(nameLower));
|
|
40
|
-
if (!aggregate) {
|
|
41
|
-
console.error(`Error: Aggregate not found: ${aggregateName}`);
|
|
42
|
-
console.error('Available aggregates:');
|
|
43
|
-
for (const a of aggregates) {
|
|
44
|
-
console.error(` - ${a.name}`);
|
|
45
|
-
}
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
38
|
+
const aggregate = findElementOrExit(model.aggregates, aggregateName, 'aggregate');
|
|
48
39
|
// Get events dynamically based on position (center point inside aggregate bounds)
|
|
49
40
|
const eventsInAggregate = getEventsInAggregate(model, aggregate);
|
|
50
41
|
// Check if aggregate has ID field configured
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { escapeXml, outputJson } from '../../lib/format.js';
|
|
2
|
+
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
2
3
|
function getSlicesUnderChapter(model, chapter) {
|
|
3
4
|
// A slice is "under" a chapter if its horizontal center falls within the chapter's x range
|
|
4
5
|
const chapterLeft = chapter.position.x;
|
|
@@ -9,33 +10,24 @@ function getSlicesUnderChapter(model, chapter) {
|
|
|
9
10
|
}).sort((a, b) => a.position.x - b.position.x);
|
|
10
11
|
}
|
|
11
12
|
export function showChapter(model, name, format) {
|
|
12
|
-
const
|
|
13
|
-
const nameLower = name.toLowerCase();
|
|
14
|
-
const chapter = chapters.find(c => c.name.toLowerCase() === nameLower || c.name.toLowerCase().includes(nameLower));
|
|
15
|
-
if (!chapter) {
|
|
16
|
-
console.error(`Error: Chapter not found: ${name}`);
|
|
17
|
-
console.error('Available chapters:');
|
|
18
|
-
for (const c of chapters) {
|
|
19
|
-
console.error(` - ${c.name}`);
|
|
20
|
-
}
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
13
|
+
const chapter = findElementOrExit(model.chapters, name, 'chapter');
|
|
23
14
|
const slices = getSlicesUnderChapter(model, chapter);
|
|
24
15
|
if (format === 'json') {
|
|
25
16
|
outputJson({
|
|
17
|
+
id: chapter.id,
|
|
26
18
|
name: chapter.name,
|
|
27
|
-
slices: slices.map(s => ({ name: s.name, status: s.status }))
|
|
19
|
+
slices: slices.map(s => ({ id: s.id, name: s.name, status: s.status }))
|
|
28
20
|
});
|
|
29
21
|
return;
|
|
30
22
|
}
|
|
31
|
-
console.log(`<chapter name="${escapeXml(chapter.name)}">`);
|
|
23
|
+
console.log(`<chapter id="${chapter.id}" name="${escapeXml(chapter.name)}">`);
|
|
32
24
|
if (slices.length === 0) {
|
|
33
25
|
console.log(' <slices/>');
|
|
34
26
|
}
|
|
35
27
|
else {
|
|
36
28
|
console.log(' <slices>');
|
|
37
29
|
for (const slice of slices) {
|
|
38
|
-
console.log(` <slice name="${escapeXml(slice.name)}" status="${slice.status}"/>`);
|
|
30
|
+
console.log(` <slice id="${slice.id}" name="${escapeXml(slice.name)}" status="${slice.status}"/>`);
|
|
39
31
|
}
|
|
40
32
|
console.log(' </slices>');
|
|
41
33
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { escapeXml, outputJson } from '../../lib/format.js';
|
|
2
|
+
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
2
3
|
function formatFieldXml(field, indent) {
|
|
3
4
|
const attrs = [
|
|
4
5
|
`name="${escapeXml(field.name)}"`,
|
|
@@ -54,7 +55,7 @@ function findAggregateForEvent(model, event) {
|
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
56
57
|
function formatCommandXml(model, command) {
|
|
57
|
-
let xml = `<command name="${escapeXml(command.name)}">\n`;
|
|
58
|
+
let xml = `<command id="${command.id}" name="${escapeXml(command.name)}">\n`;
|
|
58
59
|
if (command.fields.length > 0) {
|
|
59
60
|
xml += ' <fields>\n';
|
|
60
61
|
for (const field of command.fields) {
|
|
@@ -92,21 +93,12 @@ function formatCommandXml(model, command) {
|
|
|
92
93
|
return xml;
|
|
93
94
|
}
|
|
94
95
|
export function showCommand(model, name, format) {
|
|
95
|
-
const
|
|
96
|
-
const nameLower = name.toLowerCase();
|
|
97
|
-
const command = commands.find(c => c.name.toLowerCase() === nameLower || c.name.toLowerCase().includes(nameLower));
|
|
98
|
-
if (!command) {
|
|
99
|
-
console.error(`Error: Command not found: ${name}`);
|
|
100
|
-
console.error('Available commands:');
|
|
101
|
-
for (const c of commands) {
|
|
102
|
-
console.error(` - ${c.name}`);
|
|
103
|
-
}
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
96
|
+
const command = findElementOrExit(model.commands, name, 'command');
|
|
106
97
|
if (format === 'json') {
|
|
107
98
|
const incomingFlows = [...model.flows.values()].filter(f => f.targetId === command.id);
|
|
108
99
|
const outgoingFlows = [...model.flows.values()].filter(f => f.sourceId === command.id);
|
|
109
100
|
const result = {
|
|
101
|
+
id: command.id,
|
|
110
102
|
name: command.name,
|
|
111
103
|
fields: command.fields.map(fieldToJson)
|
|
112
104
|
};
|