eventmodeler 0.4.7 → 0.6.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/api/client-config.js +10 -0
- package/dist/api/generated/client/client.gen.js +235 -0
- package/dist/api/generated/client/index.js +6 -0
- package/dist/api/generated/client/types.gen.js +2 -0
- package/dist/api/generated/client/utils.gen.js +228 -0
- package/dist/api/generated/client.gen.js +4 -0
- package/dist/api/generated/core/auth.gen.js +14 -0
- package/dist/api/generated/core/bodySerializer.gen.js +57 -0
- package/dist/api/generated/core/params.gen.js +100 -0
- package/dist/api/generated/core/pathSerializer.gen.js +106 -0
- package/dist/api/generated/core/queryKeySerializer.gen.js +92 -0
- package/dist/api/generated/core/serverSentEvents.gen.js +133 -0
- package/dist/api/generated/core/types.gen.js +2 -0
- package/dist/api/generated/core/utils.gen.js +87 -0
- package/dist/api/generated/index.js +2 -0
- package/dist/api/generated/sdk.gen.js +4222 -0
- package/dist/api/generated/types.gen.js +2 -0
- package/dist/api/generated/zod.gen.js +7217 -0
- package/dist/commands/add.js +315 -0
- package/dist/commands/auth.js +14 -0
- package/dist/commands/create.js +192 -0
- package/dist/commands/design.js +108 -0
- package/dist/commands/guide.js +15 -0
- package/dist/commands/init.js +21 -0
- package/dist/commands/list-schemas.js +177 -0
- package/dist/commands/list.js +39 -0
- package/dist/commands/loop.js +101 -0
- package/dist/commands/map.js +40 -0
- package/dist/commands/mark.js +27 -0
- package/dist/commands/move.js +35 -0
- package/dist/commands/remove.js +170 -0
- package/dist/commands/rename.js +53 -0
- package/dist/commands/resize.js +30 -0
- package/dist/commands/search.js +14 -0
- package/dist/commands/set.js +199 -0
- package/dist/commands/show-schemas.js +259 -0
- package/dist/commands/show.js +56 -0
- package/dist/commands/summary.js +13 -0
- package/dist/commands/update.js +240 -0
- package/dist/index.js +46 -2379
- package/dist/lib/auth.js +1 -1
- package/dist/lib/config.js +0 -15
- package/dist/lib/excalidraw-schema.js +66 -0
- package/dist/lib/globals.js +8 -0
- package/dist/lib/model.js +11 -0
- package/dist/lib/project-config.js +20 -0
- package/dist/lib/resolve.js +59 -0
- package/dist/lib/scenario.js +15 -0
- package/dist/slices/add-scenario/index.js +2 -206
- package/dist/slices/guide/guides/codegen.js +1 -1
- package/dist/slices/guide/guides/connect-slices.js +12 -37
- package/dist/slices/guide/guides/create-slices.js +110 -140
- package/dist/slices/guide/guides/explore.js +37 -26
- package/dist/slices/guide/guides/information-flow.js +70 -82
- package/dist/slices/guide/guides/scenarios.js +82 -137
- package/dist/slices/guide/index.js +6 -6
- package/dist/slices/help/index.js +96 -0
- package/dist/slices/help/topics/build-codegen.js +109 -0
- package/dist/slices/help/topics/build-slice.js +147 -0
- package/dist/slices/help/topics/check-completeness.js +57 -0
- package/dist/slices/help/topics/connect-slices.js +99 -0
- package/dist/slices/help/topics/explore-model.js +112 -0
- package/dist/slices/help/topics/json-reference.js +188 -0
- package/dist/slices/help/topics/linked-copies.js +89 -0
- package/dist/slices/help/topics/manipulate-canvas.js +150 -0
- package/dist/slices/help/topics/write-scenarios.js +162 -0
- package/dist/slices/init/index.js +10 -4
- package/dist/slices/init/loop.js +60 -0
- package/dist/slices/login/index.js +2 -2
- package/dist/slices/logout/index.js +2 -2
- package/dist/slices/whoami/index.js +11 -36
- package/package.json +8 -3
- package/dist/api/index.d.ts +0 -285
- package/dist/api/index.js +0 -323
- package/dist/cloud/slices/index.d.ts +0 -276
- package/dist/cloud/slices/index.js +0 -406
- package/dist/eventmodeler.js +0 -5646
- package/dist/formatters.d.ts +0 -17
- package/dist/formatters.js +0 -482
- package/dist/index.d.ts +0 -2
- package/dist/lib/auth.d.ts +0 -24
- package/dist/lib/backend.d.ts +0 -43
- package/dist/lib/backend.js +0 -73
- package/dist/lib/chapter-utils.d.ts +0 -13
- package/dist/lib/chapter-utils.js +0 -71
- package/dist/lib/cloud-client.d.ts +0 -69
- package/dist/lib/cloud-client.js +0 -364
- package/dist/lib/config.d.ts +0 -30
- package/dist/lib/diff/merge-rules.d.ts +0 -45
- package/dist/lib/diff/merge-rules.js +0 -210
- package/dist/lib/diff/model-differ.d.ts +0 -8
- package/dist/lib/diff/model-differ.js +0 -568
- package/dist/lib/diff/three-way-merge.d.ts +0 -7
- package/dist/lib/diff/three-way-merge.js +0 -390
- package/dist/lib/diff/types.d.ts +0 -75
- package/dist/lib/diff/types.js +0 -1
- package/dist/lib/element-lookup.d.ts +0 -58
- package/dist/lib/element-lookup.js +0 -126
- package/dist/lib/file-loader.d.ts +0 -8
- package/dist/lib/file-loader.js +0 -108
- package/dist/lib/flow-utils.d.ts +0 -53
- package/dist/lib/flow-utils.js +0 -348
- package/dist/lib/format.d.ts +0 -10
- package/dist/lib/format.js +0 -23
- package/dist/lib/project-config.d.ts +0 -27
- package/dist/lib/slice-utils.d.ts +0 -59
- package/dist/lib/slice-utils.js +0 -140
- package/dist/local/slices/index.d.ts +0 -11
- package/dist/local/slices/index.js +0 -13
- package/dist/projection.d.ts +0 -3
- package/dist/projection.js +0 -828
- package/dist/slices/add-field/index.d.ts +0 -8
- package/dist/slices/add-field/index.js +0 -211
- package/dist/slices/add-scenario/index.d.ts +0 -27
- package/dist/slices/codegen-chapter-events/index.d.ts +0 -2
- package/dist/slices/codegen-chapter-events/index.js +0 -145
- package/dist/slices/codegen-slice/index.d.ts +0 -2
- package/dist/slices/codegen-slice/index.js +0 -448
- package/dist/slices/create-automation-slice/index.d.ts +0 -2
- package/dist/slices/create-automation-slice/index.js +0 -304
- package/dist/slices/create-flow/index.d.ts +0 -2
- package/dist/slices/create-flow/index.js +0 -183
- package/dist/slices/create-state-change-slice/index.d.ts +0 -2
- package/dist/slices/create-state-change-slice/index.js +0 -263
- package/dist/slices/create-state-view-slice/index.d.ts +0 -2
- package/dist/slices/create-state-view-slice/index.js +0 -128
- package/dist/slices/diff/index.d.ts +0 -11
- package/dist/slices/diff/index.js +0 -293
- package/dist/slices/export-eventmodel-to-json/index.d.ts +0 -2
- package/dist/slices/export-eventmodel-to-json/index.js +0 -355
- package/dist/slices/git/index.d.ts +0 -2
- package/dist/slices/git/index.js +0 -125
- package/dist/slices/guide/guides/codegen.d.ts +0 -5
- package/dist/slices/guide/guides/connect-slices.d.ts +0 -5
- package/dist/slices/guide/guides/create-slices.d.ts +0 -5
- package/dist/slices/guide/guides/explore.d.ts +0 -5
- package/dist/slices/guide/guides/information-flow.d.ts +0 -5
- package/dist/slices/guide/guides/scenarios.d.ts +0 -5
- package/dist/slices/guide/index.d.ts +0 -1
- package/dist/slices/import/index.d.ts +0 -8
- package/dist/slices/import/index.js +0 -63
- package/dist/slices/init/index.d.ts +0 -5
- package/dist/slices/list-chapters/index.d.ts +0 -3
- package/dist/slices/list-chapters/index.js +0 -21
- package/dist/slices/list-commands/index.d.ts +0 -3
- package/dist/slices/list-commands/index.js +0 -20
- package/dist/slices/list-events/index.d.ts +0 -3
- package/dist/slices/list-events/index.js +0 -98
- package/dist/slices/list-processors/index.d.ts +0 -3
- package/dist/slices/list-processors/index.js +0 -20
- package/dist/slices/list-readmodels/index.d.ts +0 -3
- package/dist/slices/list-readmodels/index.js +0 -21
- package/dist/slices/list-scenarios/index.d.ts +0 -3
- package/dist/slices/list-scenarios/index.js +0 -35
- package/dist/slices/list-screens/index.d.ts +0 -3
- package/dist/slices/list-screens/index.js +0 -47
- package/dist/slices/list-slices/index.d.ts +0 -3
- package/dist/slices/list-slices/index.js +0 -35
- package/dist/slices/login/index.d.ts +0 -1
- package/dist/slices/logout/index.d.ts +0 -1
- package/dist/slices/map-fields/index.d.ts +0 -2
- package/dist/slices/map-fields/index.js +0 -269
- package/dist/slices/mark-slice-status/index.d.ts +0 -2
- package/dist/slices/mark-slice-status/index.js +0 -31
- package/dist/slices/merge/index.d.ts +0 -19
- package/dist/slices/merge/index.js +0 -147
- package/dist/slices/open-app/index.d.ts +0 -1
- package/dist/slices/remove-field/index.d.ts +0 -8
- package/dist/slices/remove-field/index.js +0 -167
- package/dist/slices/remove-scenario/index.d.ts +0 -2
- package/dist/slices/remove-scenario/index.js +0 -77
- package/dist/slices/search/index.d.ts +0 -3
- package/dist/slices/search/index.js +0 -302
- package/dist/slices/show-actor/index.d.ts +0 -4
- package/dist/slices/show-actor/index.js +0 -115
- package/dist/slices/show-aggregate/index.d.ts +0 -3
- package/dist/slices/show-aggregate/index.js +0 -108
- package/dist/slices/show-aggregate-completeness/index.d.ts +0 -4
- package/dist/slices/show-aggregate-completeness/index.js +0 -181
- package/dist/slices/show-chapter/index.d.ts +0 -3
- package/dist/slices/show-chapter/index.js +0 -195
- package/dist/slices/show-command/index.d.ts +0 -3
- package/dist/slices/show-command/index.js +0 -133
- package/dist/slices/show-completeness/index.d.ts +0 -4
- package/dist/slices/show-completeness/index.js +0 -731
- package/dist/slices/show-event/index.d.ts +0 -3
- package/dist/slices/show-event/index.js +0 -118
- package/dist/slices/show-model-summary/index.d.ts +0 -3
- package/dist/slices/show-model-summary/index.js +0 -31
- package/dist/slices/show-processor/index.d.ts +0 -3
- package/dist/slices/show-processor/index.js +0 -111
- package/dist/slices/show-readmodel/index.d.ts +0 -3
- package/dist/slices/show-readmodel/index.js +0 -158
- package/dist/slices/show-scenario/index.d.ts +0 -3
- package/dist/slices/show-scenario/index.js +0 -196
- package/dist/slices/show-screen/index.d.ts +0 -3
- package/dist/slices/show-screen/index.js +0 -139
- package/dist/slices/show-slice/index.d.ts +0 -3
- package/dist/slices/show-slice/index.js +0 -696
- package/dist/slices/update-field/index.d.ts +0 -15
- package/dist/slices/update-field/index.js +0 -208
- package/dist/slices/whoami/index.d.ts +0 -2
- package/dist/types.d.ts +0 -195
- package/dist/types.js +0 -1
|
@@ -1,696 +0,0 @@
|
|
|
1
|
-
import { escapeXml, escapeXmlText, outputJson } from '../../lib/format.js';
|
|
2
|
-
import { findElementOrExit } from '../../lib/element-lookup.js';
|
|
3
|
-
import { findChapterForSlice, getChapterHierarchy } from '../../lib/chapter-utils.js';
|
|
4
|
-
import { getInboundFlows, getOutboundFlows, getFlowsForElement, getSliceComponentIds, resolveToCanonical, } from '../../lib/flow-utils.js';
|
|
5
|
-
function formatFieldValues(values) {
|
|
6
|
-
if (!values || Object.keys(values).length === 0)
|
|
7
|
-
return '';
|
|
8
|
-
return Object.entries(values)
|
|
9
|
-
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
|
|
10
|
-
.join(', ');
|
|
11
|
-
}
|
|
12
|
-
function formatFieldXml(field, indent, sourceInfo) {
|
|
13
|
-
const attrs = [
|
|
14
|
-
`name="${escapeXml(field.name)}"`,
|
|
15
|
-
`type="${field.fieldType}"`,
|
|
16
|
-
];
|
|
17
|
-
if (field.isList)
|
|
18
|
-
attrs.push('list="true"');
|
|
19
|
-
if (field.isGenerated)
|
|
20
|
-
attrs.push('generated="true"');
|
|
21
|
-
if (field.isOptional)
|
|
22
|
-
attrs.push('optional="true"');
|
|
23
|
-
if (field.isUserInput)
|
|
24
|
-
attrs.push('user-input="true"');
|
|
25
|
-
if (sourceInfo)
|
|
26
|
-
attrs.push(`source="${escapeXml(sourceInfo)}"`);
|
|
27
|
-
if (field.subfields && field.subfields.length > 0) {
|
|
28
|
-
let xml = `${indent}<field ${attrs.join(' ')}>\n`;
|
|
29
|
-
for (const subfield of field.subfields) {
|
|
30
|
-
xml += formatFieldXml(subfield, indent + ' ');
|
|
31
|
-
}
|
|
32
|
-
xml += `${indent}</field>\n`;
|
|
33
|
-
return xml;
|
|
34
|
-
}
|
|
35
|
-
return `${indent}<field ${attrs.join(' ')}/>\n`;
|
|
36
|
-
}
|
|
37
|
-
function getSliceComponents(model, slice) {
|
|
38
|
-
const bounds = {
|
|
39
|
-
left: slice.position.x,
|
|
40
|
-
right: slice.position.x + slice.size.width,
|
|
41
|
-
top: slice.position.y,
|
|
42
|
-
bottom: slice.position.y + slice.size.height,
|
|
43
|
-
};
|
|
44
|
-
function isInSlice(pos, width, height) {
|
|
45
|
-
const centerX = pos.x + width / 2;
|
|
46
|
-
const centerY = pos.y + height / 2;
|
|
47
|
-
return centerX >= bounds.left && centerX <= bounds.right && centerY >= bounds.top && centerY <= bounds.bottom;
|
|
48
|
-
}
|
|
49
|
-
// Only include canonical elements - linked copies are UI-only conveniences
|
|
50
|
-
// and should not appear as slice contents in CLI output
|
|
51
|
-
return {
|
|
52
|
-
commands: [...model.commands.values()].filter(c => isInSlice(c.position, c.width, c.height)),
|
|
53
|
-
events: [...model.events.values()].filter(e => !e.originalNodeId && isInSlice(e.position, e.width, e.height)),
|
|
54
|
-
readModels: [...model.readModels.values()].filter(rm => !rm.originalNodeId && isInSlice(rm.position, rm.width, rm.height)),
|
|
55
|
-
screens: [...model.screens.values()].filter(s => !s.originalNodeId && isInSlice(s.position, s.width, s.height)),
|
|
56
|
-
processors: [...model.processors.values()].filter(p => isInSlice(p.position, p.width, p.height)),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
// Find which aggregate an event belongs to (center point inside aggregate bounds)
|
|
60
|
-
function findAggregateForEvent(model, event) {
|
|
61
|
-
const centerX = event.position.x + event.width / 2;
|
|
62
|
-
const centerY = event.position.y + event.height / 2;
|
|
63
|
-
for (const aggregate of model.aggregates.values()) {
|
|
64
|
-
if (centerX >= aggregate.position.x &&
|
|
65
|
-
centerX <= aggregate.position.x + aggregate.size.width &&
|
|
66
|
-
centerY >= aggregate.position.y &&
|
|
67
|
-
centerY <= aggregate.position.y + aggregate.size.height) {
|
|
68
|
-
return aggregate;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
// Find which actor a screen belongs to (center point inside actor bounds)
|
|
74
|
-
function findActorForScreen(model, screen) {
|
|
75
|
-
const centerX = screen.position.x + screen.width / 2;
|
|
76
|
-
const centerY = screen.position.y + screen.height / 2;
|
|
77
|
-
for (const actor of model.actors.values()) {
|
|
78
|
-
if (centerX >= actor.position.x &&
|
|
79
|
-
centerX <= actor.position.x + actor.size.width &&
|
|
80
|
-
centerY >= actor.position.y &&
|
|
81
|
-
centerY <= actor.position.y + actor.size.height) {
|
|
82
|
-
return actor;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
function formatChapterXml(hierarchy, indent) {
|
|
88
|
-
let xml = `${indent}<chapter id="${hierarchy.id}" name="${escapeXml(hierarchy.name)}"`;
|
|
89
|
-
if (hierarchy.parent) {
|
|
90
|
-
xml += '>\n';
|
|
91
|
-
xml += formatChapterXml(hierarchy.parent, indent + ' ');
|
|
92
|
-
xml += `${indent}</chapter>\n`;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
xml += '/>\n';
|
|
96
|
-
}
|
|
97
|
-
return xml;
|
|
98
|
-
}
|
|
99
|
-
// Format inline flow annotations for a component
|
|
100
|
-
function formatFlowAnnotationsXml(elementId, incoming, outgoing, componentIds, indent) {
|
|
101
|
-
let xml = '';
|
|
102
|
-
// Flows coming into this element
|
|
103
|
-
const flowsFrom = incoming.map(f => {
|
|
104
|
-
const external = !componentIds.has(f.source.id);
|
|
105
|
-
return external
|
|
106
|
-
? `${escapeXml(f.source.name)} (${f.source.type}) [external]`
|
|
107
|
-
: `${escapeXml(f.source.name)} (${f.source.type})`;
|
|
108
|
-
});
|
|
109
|
-
if (flowsFrom.length > 0) {
|
|
110
|
-
xml += `${indent}<flows-from>${flowsFrom.join(', ')}</flows-from>\n`;
|
|
111
|
-
}
|
|
112
|
-
// Flows going out of this element
|
|
113
|
-
const flowsTo = outgoing.map(f => {
|
|
114
|
-
const external = !componentIds.has(f.target.id);
|
|
115
|
-
return external
|
|
116
|
-
? `${escapeXml(f.target.name)} (${f.target.type}) [external]`
|
|
117
|
-
: `${escapeXml(f.target.name)} (${f.target.type})`;
|
|
118
|
-
});
|
|
119
|
-
if (flowsTo.length > 0) {
|
|
120
|
-
xml += `${indent}<flows-to>${flowsTo.join(', ')}</flows-to>\n`;
|
|
121
|
-
}
|
|
122
|
-
return xml;
|
|
123
|
-
}
|
|
124
|
-
// Format inbound flows section
|
|
125
|
-
function formatInboundFlowsXml(flows) {
|
|
126
|
-
if (flows.length === 0)
|
|
127
|
-
return '';
|
|
128
|
-
let xml = ' <inbound-flows>\n';
|
|
129
|
-
for (const flow of flows) {
|
|
130
|
-
xml += ` <flow type="${flow.flowType}">\n`;
|
|
131
|
-
const sourceSliceInfo = flow.sourceSlice ? ` slice="${escapeXml(flow.sourceSlice.name)}"` : '';
|
|
132
|
-
xml += ` <from${sourceSliceInfo}>${escapeXml(flow.source.name)} (${flow.source.type})</from>\n`;
|
|
133
|
-
xml += ` <to>${escapeXml(flow.target.name)} (${flow.target.type})</to>\n`;
|
|
134
|
-
if (flow.fieldMappings.length > 0) {
|
|
135
|
-
xml += ' <mappings>\n';
|
|
136
|
-
for (const mapping of flow.fieldMappings) {
|
|
137
|
-
xml += ` <map from="${escapeXml(mapping.from)}" to="${escapeXml(mapping.to)}"/>\n`;
|
|
138
|
-
}
|
|
139
|
-
xml += ' </mappings>\n';
|
|
140
|
-
}
|
|
141
|
-
xml += ' </flow>\n';
|
|
142
|
-
}
|
|
143
|
-
xml += ' </inbound-flows>\n';
|
|
144
|
-
return xml;
|
|
145
|
-
}
|
|
146
|
-
// Format outbound flows section
|
|
147
|
-
function formatOutboundFlowsXml(flows) {
|
|
148
|
-
if (flows.length === 0)
|
|
149
|
-
return '';
|
|
150
|
-
let xml = ' <outbound-flows>\n';
|
|
151
|
-
for (const flow of flows) {
|
|
152
|
-
xml += ` <flow type="${flow.flowType}">\n`;
|
|
153
|
-
xml += ` <from>${escapeXml(flow.source.name)} (${flow.source.type})</from>\n`;
|
|
154
|
-
const targetSliceInfo = flow.targetSlice ? ` slice="${escapeXml(flow.targetSlice.name)}"` : '';
|
|
155
|
-
xml += ` <to${targetSliceInfo}>${escapeXml(flow.target.name)} (${flow.target.type})</to>\n`;
|
|
156
|
-
if (flow.fieldMappings.length > 0) {
|
|
157
|
-
xml += ' <mappings>\n';
|
|
158
|
-
for (const mapping of flow.fieldMappings) {
|
|
159
|
-
xml += ` <map from="${escapeXml(mapping.from)}" to="${escapeXml(mapping.to)}"/>\n`;
|
|
160
|
-
}
|
|
161
|
-
xml += ' </mappings>\n';
|
|
162
|
-
}
|
|
163
|
-
xml += ' </flow>\n';
|
|
164
|
-
}
|
|
165
|
-
xml += ' </outbound-flows>\n';
|
|
166
|
-
return xml;
|
|
167
|
-
}
|
|
168
|
-
function formatSliceXml(model, slice) {
|
|
169
|
-
const components = getSliceComponents(model, slice);
|
|
170
|
-
const scenarios = [...model.scenarios.values()].filter(s => s.sliceId === slice.id);
|
|
171
|
-
const chapter = findChapterForSlice(model, slice);
|
|
172
|
-
// Use shared function that handles canonical groups for linked copies
|
|
173
|
-
const componentIds = getSliceComponentIds(model, slice);
|
|
174
|
-
// Resolve linked copies to canonical originals when checking flow containment
|
|
175
|
-
const flows = [...model.flows.values()].filter(f => {
|
|
176
|
-
const canonicalSourceId = resolveToCanonical(model, f.sourceId);
|
|
177
|
-
const canonicalTargetId = resolveToCanonical(model, f.targetId);
|
|
178
|
-
return componentIds.has(canonicalSourceId) || componentIds.has(canonicalTargetId);
|
|
179
|
-
});
|
|
180
|
-
const internalFlows = flows.filter(f => {
|
|
181
|
-
const canonicalSourceId = resolveToCanonical(model, f.sourceId);
|
|
182
|
-
const canonicalTargetId = resolveToCanonical(model, f.targetId);
|
|
183
|
-
return componentIds.has(canonicalSourceId) && componentIds.has(canonicalTargetId);
|
|
184
|
-
});
|
|
185
|
-
// Get inbound and outbound flows for the slice
|
|
186
|
-
const inboundFlows = getInboundFlows(model, slice);
|
|
187
|
-
const outboundFlows = getOutboundFlows(model, slice);
|
|
188
|
-
function getName(id) {
|
|
189
|
-
return (model.commands.get(id)?.name ??
|
|
190
|
-
model.events.get(id)?.name ??
|
|
191
|
-
model.readModels.get(id)?.name ??
|
|
192
|
-
model.screens.get(id)?.name ??
|
|
193
|
-
model.processors.get(id)?.name ??
|
|
194
|
-
id);
|
|
195
|
-
}
|
|
196
|
-
let xml = `<slice id="${slice.id}" name="${escapeXml(slice.name)}" status="${slice.status}">\n`;
|
|
197
|
-
if (chapter) {
|
|
198
|
-
xml += formatChapterXml(getChapterHierarchy(model, chapter), ' ');
|
|
199
|
-
}
|
|
200
|
-
xml += ' <components>\n';
|
|
201
|
-
for (const screen of components.screens) {
|
|
202
|
-
// Check which actor this screen belongs to
|
|
203
|
-
const actor = findActorForScreen(model, screen);
|
|
204
|
-
const actorAttr = actor ? ` actor="${escapeXml(actor.name)}"` : '';
|
|
205
|
-
xml += ` <screen id="${screen.id}" name="${escapeXml(screen.name)}"${actorAttr}>\n`;
|
|
206
|
-
// Add flow annotations
|
|
207
|
-
const screenFlows = getFlowsForElement(model, screen.id);
|
|
208
|
-
xml += formatFlowAnnotationsXml(screen.id, screenFlows.incoming, screenFlows.outgoing, componentIds, ' ');
|
|
209
|
-
if (screen.fields.length > 0) {
|
|
210
|
-
xml += ' <fields>\n';
|
|
211
|
-
for (const field of screen.fields) {
|
|
212
|
-
xml += formatFieldXml(field, ' ', field.isUserInput ? 'user-input' : undefined);
|
|
213
|
-
}
|
|
214
|
-
xml += ' </fields>\n';
|
|
215
|
-
}
|
|
216
|
-
xml += ' </screen>\n';
|
|
217
|
-
}
|
|
218
|
-
for (const command of components.commands) {
|
|
219
|
-
xml += ` <command id="${command.id}" name="${escapeXml(command.name)}">\n`;
|
|
220
|
-
// Add flow annotations
|
|
221
|
-
const commandFlows = getFlowsForElement(model, command.id);
|
|
222
|
-
xml += formatFlowAnnotationsXml(command.id, commandFlows.incoming, commandFlows.outgoing, componentIds, ' ');
|
|
223
|
-
if (command.fields.length > 0) {
|
|
224
|
-
xml += ' <fields>\n';
|
|
225
|
-
for (const field of command.fields) {
|
|
226
|
-
const incomingFlow = flows.find(f => f.targetId === command.id);
|
|
227
|
-
let sourceInfo;
|
|
228
|
-
if (incomingFlow) {
|
|
229
|
-
const source = model.screens.get(incomingFlow.sourceId) ?? model.processors.get(incomingFlow.sourceId);
|
|
230
|
-
if (source?.fields.some(f => f.name === field.name)) {
|
|
231
|
-
sourceInfo = `${source.name}.${field.name}`;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
xml += formatFieldXml(field, ' ', sourceInfo);
|
|
235
|
-
}
|
|
236
|
-
xml += ' </fields>\n';
|
|
237
|
-
}
|
|
238
|
-
xml += ' </command>\n';
|
|
239
|
-
}
|
|
240
|
-
for (const event of components.events) {
|
|
241
|
-
// Check which aggregate this event belongs to
|
|
242
|
-
const aggregate = findAggregateForEvent(model, event);
|
|
243
|
-
const aggregateAttr = aggregate ? ` aggregate="${escapeXml(aggregate.name)}"` : '';
|
|
244
|
-
xml += ` <event id="${event.id}" name="${escapeXml(event.name)}"${aggregateAttr}>\n`;
|
|
245
|
-
// Add flow annotations
|
|
246
|
-
const eventFlows = getFlowsForElement(model, event.id);
|
|
247
|
-
xml += formatFlowAnnotationsXml(event.id, eventFlows.incoming, eventFlows.outgoing, componentIds, ' ');
|
|
248
|
-
if (event.fields.length > 0) {
|
|
249
|
-
xml += ' <fields>\n';
|
|
250
|
-
for (const field of event.fields) {
|
|
251
|
-
const incomingFlow = flows.find(f => f.targetId === event.id);
|
|
252
|
-
let sourceInfo;
|
|
253
|
-
if (field.isGenerated) {
|
|
254
|
-
sourceInfo = 'generated';
|
|
255
|
-
}
|
|
256
|
-
else if (incomingFlow) {
|
|
257
|
-
const source = model.commands.get(incomingFlow.sourceId);
|
|
258
|
-
if (source?.fields.some(f => f.name === field.name)) {
|
|
259
|
-
sourceInfo = `${source.name}.${field.name}`;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
xml += formatFieldXml(field, ' ', sourceInfo);
|
|
263
|
-
}
|
|
264
|
-
xml += ' </fields>\n';
|
|
265
|
-
}
|
|
266
|
-
xml += ' </event>\n';
|
|
267
|
-
}
|
|
268
|
-
for (const readModel of components.readModels) {
|
|
269
|
-
xml += ` <read-model id="${readModel.id}" name="${escapeXml(readModel.name)}">\n`;
|
|
270
|
-
// Add flow annotations
|
|
271
|
-
const rmFlows = getFlowsForElement(model, readModel.id);
|
|
272
|
-
xml += formatFlowAnnotationsXml(readModel.id, rmFlows.incoming, rmFlows.outgoing, componentIds, ' ');
|
|
273
|
-
if (readModel.fields.length > 0) {
|
|
274
|
-
xml += ' <fields>\n';
|
|
275
|
-
for (const field of readModel.fields) {
|
|
276
|
-
xml += formatFieldXml(field, ' ');
|
|
277
|
-
}
|
|
278
|
-
xml += ' </fields>\n';
|
|
279
|
-
}
|
|
280
|
-
xml += ' </read-model>\n';
|
|
281
|
-
}
|
|
282
|
-
for (const processor of components.processors) {
|
|
283
|
-
xml += ` <processor id="${processor.id}" name="${escapeXml(processor.name)}">\n`;
|
|
284
|
-
// Add flow annotations
|
|
285
|
-
const procFlows = getFlowsForElement(model, processor.id);
|
|
286
|
-
xml += formatFlowAnnotationsXml(processor.id, procFlows.incoming, procFlows.outgoing, componentIds, ' ');
|
|
287
|
-
if (processor.fields.length > 0) {
|
|
288
|
-
xml += ' <fields>\n';
|
|
289
|
-
for (const field of processor.fields) {
|
|
290
|
-
xml += formatFieldXml(field, ' ');
|
|
291
|
-
}
|
|
292
|
-
xml += ' </fields>\n';
|
|
293
|
-
}
|
|
294
|
-
xml += ' </processor>\n';
|
|
295
|
-
}
|
|
296
|
-
xml += ' </components>\n';
|
|
297
|
-
if (internalFlows.length > 0) {
|
|
298
|
-
xml += ' <information-flow>\n';
|
|
299
|
-
for (const flow of internalFlows) {
|
|
300
|
-
xml += ` ${escapeXml(getName(flow.sourceId))} → ${escapeXml(getName(flow.targetId))}\n`;
|
|
301
|
-
}
|
|
302
|
-
xml += ' </information-flow>\n';
|
|
303
|
-
}
|
|
304
|
-
if (scenarios.length > 0) {
|
|
305
|
-
xml += ' <scenarios>\n';
|
|
306
|
-
for (const scenario of scenarios) {
|
|
307
|
-
xml += ` <scenario name="${escapeXml(scenario.name)}">\n`;
|
|
308
|
-
if (scenario.description) {
|
|
309
|
-
xml += ` <description>${escapeXmlText(scenario.description)}</description>\n`;
|
|
310
|
-
}
|
|
311
|
-
if (scenario.givenEvents.length > 0) {
|
|
312
|
-
xml += ' <given>\n';
|
|
313
|
-
for (const given of scenario.givenEvents) {
|
|
314
|
-
const evt = model.events.get(given.eventStickyId);
|
|
315
|
-
const name = evt?.name ?? 'UnknownEvent';
|
|
316
|
-
const values = formatFieldValues(given.fieldValues);
|
|
317
|
-
xml += values
|
|
318
|
-
? ` <event type="${escapeXml(name)}">${escapeXmlText(values)}</event>\n`
|
|
319
|
-
: ` <event type="${escapeXml(name)}"/>\n`;
|
|
320
|
-
}
|
|
321
|
-
xml += ' </given>\n';
|
|
322
|
-
}
|
|
323
|
-
if (scenario.whenCommand) {
|
|
324
|
-
const cmd = model.commands.get(scenario.whenCommand.commandStickyId);
|
|
325
|
-
const name = cmd?.name ?? 'UnknownCommand';
|
|
326
|
-
const values = formatFieldValues(scenario.whenCommand.fieldValues);
|
|
327
|
-
xml += ' <when>\n';
|
|
328
|
-
xml += values
|
|
329
|
-
? ` <command type="${escapeXml(name)}">${escapeXmlText(values)}</command>\n`
|
|
330
|
-
: ` <command type="${escapeXml(name)}"/>\n`;
|
|
331
|
-
xml += ' </when>\n';
|
|
332
|
-
}
|
|
333
|
-
else if (scenario.whenEvents && scenario.whenEvents.length > 0) {
|
|
334
|
-
xml += ' <when>\n';
|
|
335
|
-
for (const whenEvent of scenario.whenEvents) {
|
|
336
|
-
const evt = model.events.get(whenEvent.eventStickyId);
|
|
337
|
-
const name = evt?.name ?? 'UnknownEvent';
|
|
338
|
-
const values = formatFieldValues(whenEvent.fieldValues);
|
|
339
|
-
xml += values
|
|
340
|
-
? ` <event type="${escapeXml(name)}">${escapeXmlText(values)}</event>\n`
|
|
341
|
-
: ` <event type="${escapeXml(name)}"/>\n`;
|
|
342
|
-
}
|
|
343
|
-
xml += ' </when>\n';
|
|
344
|
-
}
|
|
345
|
-
xml += ' <then>\n';
|
|
346
|
-
if (scenario.then.type === 'error') {
|
|
347
|
-
xml += ` <error`;
|
|
348
|
-
if (scenario.then.errorType)
|
|
349
|
-
xml += ` type="${escapeXml(scenario.then.errorType)}"`;
|
|
350
|
-
xml += `>${escapeXmlText(scenario.then.errorMessage ?? '')}</error>\n`;
|
|
351
|
-
}
|
|
352
|
-
else if (scenario.then.type === 'events' && scenario.then.expectedEvents) {
|
|
353
|
-
for (const expected of scenario.then.expectedEvents) {
|
|
354
|
-
const evt = model.events.get(expected.eventStickyId);
|
|
355
|
-
const name = evt?.name ?? 'UnknownEvent';
|
|
356
|
-
const values = formatFieldValues(expected.fieldValues);
|
|
357
|
-
xml += values
|
|
358
|
-
? ` <event type="${escapeXml(name)}">${escapeXmlText(values)}</event>\n`
|
|
359
|
-
: ` <event type="${escapeXml(name)}"/>\n`;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
else if (scenario.then.type === 'command' && scenario.then.expectedCommand) {
|
|
363
|
-
const cmd = model.commands.get(scenario.then.expectedCommand.commandStickyId);
|
|
364
|
-
const name = cmd?.name ?? 'UnknownCommand';
|
|
365
|
-
const values = formatFieldValues(scenario.then.expectedCommand.fieldValues);
|
|
366
|
-
xml += values
|
|
367
|
-
? ` <command type="${escapeXml(name)}">${escapeXmlText(values)}</command>\n`
|
|
368
|
-
: ` <command type="${escapeXml(name)}"/>\n`;
|
|
369
|
-
}
|
|
370
|
-
else if (scenario.then.type === 'noCommand') {
|
|
371
|
-
xml += ' <no-command/>\n';
|
|
372
|
-
}
|
|
373
|
-
else if (scenario.then.type === 'readModelAssertion' && scenario.then.readModelAssertion) {
|
|
374
|
-
const assertion = scenario.then.readModelAssertion;
|
|
375
|
-
const rm = model.readModels.get(assertion.readModelStickyId);
|
|
376
|
-
const name = rm?.name ?? 'UnknownReadModel';
|
|
377
|
-
xml += ` <read-model-assertion type="${escapeXml(name)}">\n`;
|
|
378
|
-
xml += ` <expected>${escapeXmlText(formatFieldValues(assertion.expectedFieldValues))}</expected>\n`;
|
|
379
|
-
xml += ' </read-model-assertion>\n';
|
|
380
|
-
}
|
|
381
|
-
xml += ' </then>\n';
|
|
382
|
-
xml += ' </scenario>\n';
|
|
383
|
-
}
|
|
384
|
-
xml += ' </scenarios>\n';
|
|
385
|
-
}
|
|
386
|
-
// Add inbound and outbound flows sections
|
|
387
|
-
xml += formatInboundFlowsXml(inboundFlows);
|
|
388
|
-
xml += formatOutboundFlowsXml(outboundFlows);
|
|
389
|
-
xml += '</slice>';
|
|
390
|
-
return xml;
|
|
391
|
-
}
|
|
392
|
-
function fieldToJson(field) {
|
|
393
|
-
const result = {
|
|
394
|
-
name: field.name,
|
|
395
|
-
type: field.fieldType
|
|
396
|
-
};
|
|
397
|
-
if (field.isList)
|
|
398
|
-
result.list = true;
|
|
399
|
-
if (field.isGenerated)
|
|
400
|
-
result.generated = true;
|
|
401
|
-
if (field.isOptional)
|
|
402
|
-
result.optional = true;
|
|
403
|
-
if (field.isUserInput)
|
|
404
|
-
result.userInput = true;
|
|
405
|
-
if (field.subfields && field.subfields.length > 0) {
|
|
406
|
-
result.subfields = field.subfields.map(fieldToJson);
|
|
407
|
-
}
|
|
408
|
-
return result;
|
|
409
|
-
}
|
|
410
|
-
function formatSliceJson(model, slice) {
|
|
411
|
-
const components = getSliceComponents(model, slice);
|
|
412
|
-
const scenarios = [...model.scenarios.values()].filter(s => s.sliceId === slice.id);
|
|
413
|
-
const chapter = findChapterForSlice(model, slice);
|
|
414
|
-
// Use shared function that handles canonical groups for linked copies
|
|
415
|
-
const componentIds = getSliceComponentIds(model, slice);
|
|
416
|
-
// Resolve linked copies to canonical originals when checking flow containment
|
|
417
|
-
const flows = [...model.flows.values()].filter(f => {
|
|
418
|
-
const canonicalSourceId = resolveToCanonical(model, f.sourceId);
|
|
419
|
-
const canonicalTargetId = resolveToCanonical(model, f.targetId);
|
|
420
|
-
return componentIds.has(canonicalSourceId) || componentIds.has(canonicalTargetId);
|
|
421
|
-
});
|
|
422
|
-
const internalFlows = flows.filter(f => {
|
|
423
|
-
const canonicalSourceId = resolveToCanonical(model, f.sourceId);
|
|
424
|
-
const canonicalTargetId = resolveToCanonical(model, f.targetId);
|
|
425
|
-
return componentIds.has(canonicalSourceId) && componentIds.has(canonicalTargetId);
|
|
426
|
-
});
|
|
427
|
-
// Get inbound and outbound flows for the slice
|
|
428
|
-
const inboundFlows = getInboundFlows(model, slice);
|
|
429
|
-
const outboundFlows = getOutboundFlows(model, slice);
|
|
430
|
-
function getName(id) {
|
|
431
|
-
return (model.commands.get(id)?.name ??
|
|
432
|
-
model.events.get(id)?.name ??
|
|
433
|
-
model.readModels.get(id)?.name ??
|
|
434
|
-
model.screens.get(id)?.name ??
|
|
435
|
-
model.processors.get(id)?.name ??
|
|
436
|
-
id);
|
|
437
|
-
}
|
|
438
|
-
const result = {
|
|
439
|
-
id: slice.id,
|
|
440
|
-
name: slice.name,
|
|
441
|
-
status: slice.status,
|
|
442
|
-
...(chapter && { chapter: getChapterHierarchy(model, chapter) }),
|
|
443
|
-
components: {
|
|
444
|
-
screens: components.screens.map(screen => {
|
|
445
|
-
const screenObj = {
|
|
446
|
-
id: screen.id,
|
|
447
|
-
name: screen.name,
|
|
448
|
-
fields: screen.fields.map(fieldToJson)
|
|
449
|
-
};
|
|
450
|
-
const actor = findActorForScreen(model, screen);
|
|
451
|
-
if (actor)
|
|
452
|
-
screenObj.actor = actor.name;
|
|
453
|
-
// Add flow annotations
|
|
454
|
-
const screenFlows = getFlowsForElement(model, screen.id);
|
|
455
|
-
if (screenFlows.incoming.length > 0) {
|
|
456
|
-
screenObj.flowsFrom = screenFlows.incoming.map(f => ({
|
|
457
|
-
element: f.source.name,
|
|
458
|
-
type: f.source.type,
|
|
459
|
-
external: !componentIds.has(f.source.id)
|
|
460
|
-
}));
|
|
461
|
-
}
|
|
462
|
-
if (screenFlows.outgoing.length > 0) {
|
|
463
|
-
screenObj.flowsTo = screenFlows.outgoing.map(f => ({
|
|
464
|
-
element: f.target.name,
|
|
465
|
-
type: f.target.type,
|
|
466
|
-
external: !componentIds.has(f.target.id)
|
|
467
|
-
}));
|
|
468
|
-
}
|
|
469
|
-
return screenObj;
|
|
470
|
-
}),
|
|
471
|
-
commands: components.commands.map(cmd => {
|
|
472
|
-
const cmdObj = {
|
|
473
|
-
id: cmd.id,
|
|
474
|
-
name: cmd.name,
|
|
475
|
-
fields: cmd.fields.map(fieldToJson)
|
|
476
|
-
};
|
|
477
|
-
const cmdFlows = getFlowsForElement(model, cmd.id);
|
|
478
|
-
if (cmdFlows.incoming.length > 0) {
|
|
479
|
-
cmdObj.flowsFrom = cmdFlows.incoming.map(f => ({
|
|
480
|
-
element: f.source.name,
|
|
481
|
-
type: f.source.type,
|
|
482
|
-
external: !componentIds.has(f.source.id)
|
|
483
|
-
}));
|
|
484
|
-
}
|
|
485
|
-
if (cmdFlows.outgoing.length > 0) {
|
|
486
|
-
cmdObj.flowsTo = cmdFlows.outgoing.map(f => ({
|
|
487
|
-
element: f.target.name,
|
|
488
|
-
type: f.target.type,
|
|
489
|
-
external: !componentIds.has(f.target.id)
|
|
490
|
-
}));
|
|
491
|
-
}
|
|
492
|
-
return cmdObj;
|
|
493
|
-
}),
|
|
494
|
-
events: components.events.map(event => {
|
|
495
|
-
const eventObj = {
|
|
496
|
-
id: event.id,
|
|
497
|
-
name: event.name,
|
|
498
|
-
fields: event.fields.map(fieldToJson)
|
|
499
|
-
};
|
|
500
|
-
const aggregate = findAggregateForEvent(model, event);
|
|
501
|
-
if (aggregate)
|
|
502
|
-
eventObj.aggregate = aggregate.name;
|
|
503
|
-
// Add flow annotations
|
|
504
|
-
const eventFlows = getFlowsForElement(model, event.id);
|
|
505
|
-
if (eventFlows.incoming.length > 0) {
|
|
506
|
-
eventObj.flowsFrom = eventFlows.incoming.map(f => ({
|
|
507
|
-
element: f.source.name,
|
|
508
|
-
type: f.source.type,
|
|
509
|
-
external: !componentIds.has(f.source.id)
|
|
510
|
-
}));
|
|
511
|
-
}
|
|
512
|
-
if (eventFlows.outgoing.length > 0) {
|
|
513
|
-
eventObj.flowsTo = eventFlows.outgoing.map(f => ({
|
|
514
|
-
element: f.target.name,
|
|
515
|
-
type: f.target.type,
|
|
516
|
-
external: !componentIds.has(f.target.id)
|
|
517
|
-
}));
|
|
518
|
-
}
|
|
519
|
-
return eventObj;
|
|
520
|
-
}),
|
|
521
|
-
readModels: components.readModels.map(rm => {
|
|
522
|
-
const rmObj = {
|
|
523
|
-
id: rm.id,
|
|
524
|
-
name: rm.name,
|
|
525
|
-
fields: rm.fields.map(fieldToJson)
|
|
526
|
-
};
|
|
527
|
-
// Add flow annotations
|
|
528
|
-
const rmFlows = getFlowsForElement(model, rm.id);
|
|
529
|
-
if (rmFlows.incoming.length > 0) {
|
|
530
|
-
rmObj.flowsFrom = rmFlows.incoming.map(f => ({
|
|
531
|
-
element: f.source.name,
|
|
532
|
-
type: f.source.type,
|
|
533
|
-
external: !componentIds.has(f.source.id)
|
|
534
|
-
}));
|
|
535
|
-
}
|
|
536
|
-
if (rmFlows.outgoing.length > 0) {
|
|
537
|
-
rmObj.flowsTo = rmFlows.outgoing.map(f => ({
|
|
538
|
-
element: f.target.name,
|
|
539
|
-
type: f.target.type,
|
|
540
|
-
external: !componentIds.has(f.target.id)
|
|
541
|
-
}));
|
|
542
|
-
}
|
|
543
|
-
return rmObj;
|
|
544
|
-
}),
|
|
545
|
-
processors: components.processors.map(proc => {
|
|
546
|
-
const procObj = {
|
|
547
|
-
id: proc.id,
|
|
548
|
-
name: proc.name,
|
|
549
|
-
fields: proc.fields.map(fieldToJson)
|
|
550
|
-
};
|
|
551
|
-
const procFlows = getFlowsForElement(model, proc.id);
|
|
552
|
-
if (procFlows.incoming.length > 0) {
|
|
553
|
-
procObj.flowsFrom = procFlows.incoming.map(f => ({
|
|
554
|
-
element: f.source.name,
|
|
555
|
-
type: f.source.type,
|
|
556
|
-
external: !componentIds.has(f.source.id)
|
|
557
|
-
}));
|
|
558
|
-
}
|
|
559
|
-
if (procFlows.outgoing.length > 0) {
|
|
560
|
-
procObj.flowsTo = procFlows.outgoing.map(f => ({
|
|
561
|
-
element: f.target.name,
|
|
562
|
-
type: f.target.type,
|
|
563
|
-
external: !componentIds.has(f.target.id)
|
|
564
|
-
}));
|
|
565
|
-
}
|
|
566
|
-
return procObj;
|
|
567
|
-
})
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
if (internalFlows.length > 0) {
|
|
571
|
-
result.informationFlow = internalFlows.map(flow => ({
|
|
572
|
-
from: getName(flow.sourceId),
|
|
573
|
-
to: getName(flow.targetId)
|
|
574
|
-
}));
|
|
575
|
-
}
|
|
576
|
-
if (scenarios.length > 0) {
|
|
577
|
-
result.scenarios = scenarios.map(scenario => {
|
|
578
|
-
const scenarioObj = { name: scenario.name };
|
|
579
|
-
if (scenario.description)
|
|
580
|
-
scenarioObj.description = scenario.description;
|
|
581
|
-
if (scenario.givenEvents.length > 0) {
|
|
582
|
-
scenarioObj.given = scenario.givenEvents.map(given => {
|
|
583
|
-
const evt = model.events.get(given.eventStickyId);
|
|
584
|
-
return {
|
|
585
|
-
eventType: evt?.name ?? 'UnknownEvent',
|
|
586
|
-
...(given.fieldValues && Object.keys(given.fieldValues).length > 0 ? { fieldValues: given.fieldValues } : {})
|
|
587
|
-
};
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
if (scenario.whenCommand) {
|
|
591
|
-
const cmd = model.commands.get(scenario.whenCommand.commandStickyId);
|
|
592
|
-
scenarioObj.when = {
|
|
593
|
-
commandType: cmd?.name ?? 'UnknownCommand',
|
|
594
|
-
...(scenario.whenCommand.fieldValues && Object.keys(scenario.whenCommand.fieldValues).length > 0 ? { fieldValues: scenario.whenCommand.fieldValues } : {})
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
else if (scenario.whenEvents && scenario.whenEvents.length > 0) {
|
|
598
|
-
scenarioObj.when = {
|
|
599
|
-
events: scenario.whenEvents.map(whenEvent => {
|
|
600
|
-
const evt = model.events.get(whenEvent.eventStickyId);
|
|
601
|
-
return {
|
|
602
|
-
eventType: evt?.name ?? 'UnknownEvent',
|
|
603
|
-
...(whenEvent.fieldValues && Object.keys(whenEvent.fieldValues).length > 0 ? { fieldValues: whenEvent.fieldValues } : {})
|
|
604
|
-
};
|
|
605
|
-
})
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
if (scenario.then.type === 'error') {
|
|
609
|
-
scenarioObj.then = {
|
|
610
|
-
type: 'error',
|
|
611
|
-
...(scenario.then.errorType ? { errorType: scenario.then.errorType } : {}),
|
|
612
|
-
...(scenario.then.errorMessage ? { errorMessage: scenario.then.errorMessage } : {})
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
else if (scenario.then.type === 'events' && scenario.then.expectedEvents) {
|
|
616
|
-
scenarioObj.then = {
|
|
617
|
-
type: 'events',
|
|
618
|
-
expectedEvents: scenario.then.expectedEvents.map(expected => {
|
|
619
|
-
const evt = model.events.get(expected.eventStickyId);
|
|
620
|
-
return {
|
|
621
|
-
eventType: evt?.name ?? 'UnknownEvent',
|
|
622
|
-
...(expected.fieldValues && Object.keys(expected.fieldValues).length > 0 ? { fieldValues: expected.fieldValues } : {})
|
|
623
|
-
};
|
|
624
|
-
})
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
else if (scenario.then.type === 'command' && scenario.then.expectedCommand) {
|
|
628
|
-
const cmd = model.commands.get(scenario.then.expectedCommand.commandStickyId);
|
|
629
|
-
scenarioObj.then = {
|
|
630
|
-
type: 'command',
|
|
631
|
-
commandType: cmd?.name ?? 'UnknownCommand',
|
|
632
|
-
...(scenario.then.expectedCommand.fieldValues && Object.keys(scenario.then.expectedCommand.fieldValues).length > 0 ? { fieldValues: scenario.then.expectedCommand.fieldValues } : {})
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
else if (scenario.then.type === 'noCommand') {
|
|
636
|
-
scenarioObj.then = {
|
|
637
|
-
type: 'noCommand'
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
else if (scenario.then.type === 'readModelAssertion' && scenario.then.readModelAssertion) {
|
|
641
|
-
const assertion = scenario.then.readModelAssertion;
|
|
642
|
-
const rm = model.readModels.get(assertion.readModelStickyId);
|
|
643
|
-
scenarioObj.then = {
|
|
644
|
-
type: 'readModelAssertion',
|
|
645
|
-
readModelType: rm?.name ?? 'UnknownReadModel',
|
|
646
|
-
expectedFieldValues: assertion.expectedFieldValues
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
return scenarioObj;
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
// Add inbound and outbound flows
|
|
653
|
-
if (inboundFlows.length > 0) {
|
|
654
|
-
result.inboundFlows = inboundFlows.map(f => ({
|
|
655
|
-
type: f.flowType,
|
|
656
|
-
from: {
|
|
657
|
-
element: f.source.name,
|
|
658
|
-
type: f.source.type,
|
|
659
|
-
...(f.sourceSlice && { slice: f.sourceSlice.name })
|
|
660
|
-
},
|
|
661
|
-
to: {
|
|
662
|
-
element: f.target.name,
|
|
663
|
-
type: f.target.type
|
|
664
|
-
},
|
|
665
|
-
...(f.fieldMappings.length > 0 && {
|
|
666
|
-
mappings: f.fieldMappings.map(m => ({ from: m.from, to: m.to }))
|
|
667
|
-
})
|
|
668
|
-
}));
|
|
669
|
-
}
|
|
670
|
-
if (outboundFlows.length > 0) {
|
|
671
|
-
result.outboundFlows = outboundFlows.map(f => ({
|
|
672
|
-
type: f.flowType,
|
|
673
|
-
from: {
|
|
674
|
-
element: f.source.name,
|
|
675
|
-
type: f.source.type
|
|
676
|
-
},
|
|
677
|
-
to: {
|
|
678
|
-
element: f.target.name,
|
|
679
|
-
type: f.target.type,
|
|
680
|
-
...(f.targetSlice && { slice: f.targetSlice.name })
|
|
681
|
-
},
|
|
682
|
-
...(f.fieldMappings.length > 0 && {
|
|
683
|
-
mappings: f.fieldMappings.map(m => ({ from: m.from, to: m.to }))
|
|
684
|
-
})
|
|
685
|
-
}));
|
|
686
|
-
}
|
|
687
|
-
return result;
|
|
688
|
-
}
|
|
689
|
-
export function showSlice(model, name, format) {
|
|
690
|
-
const slice = findElementOrExit(model.slices, name, 'slice');
|
|
691
|
-
if (format === 'json') {
|
|
692
|
-
outputJson(formatSliceJson(model, slice));
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
console.log(formatSliceXml(model, slice));
|
|
696
|
-
}
|