eventmodeler 0.5.0 → 0.6.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.
Files changed (150) hide show
  1. package/dist/index.js +6776 -2132
  2. package/package.json +11 -5
  3. package/dist/api/index.d.ts +0 -285
  4. package/dist/api/index.js +0 -323
  5. package/dist/cloud/slices/index.d.ts +0 -276
  6. package/dist/cloud/slices/index.js +0 -406
  7. package/dist/eventmodeler.js +0 -5646
  8. package/dist/formatters.d.ts +0 -17
  9. package/dist/formatters.js +0 -482
  10. package/dist/index.d.ts +0 -2
  11. package/dist/lib/auth.d.ts +0 -24
  12. package/dist/lib/auth.js +0 -331
  13. package/dist/lib/backend.d.ts +0 -43
  14. package/dist/lib/backend.js +0 -73
  15. package/dist/lib/chapter-utils.d.ts +0 -13
  16. package/dist/lib/chapter-utils.js +0 -71
  17. package/dist/lib/cloud-client.d.ts +0 -69
  18. package/dist/lib/cloud-client.js +0 -364
  19. package/dist/lib/config.d.ts +0 -30
  20. package/dist/lib/config.js +0 -95
  21. package/dist/lib/diff/merge-rules.d.ts +0 -45
  22. package/dist/lib/diff/merge-rules.js +0 -210
  23. package/dist/lib/diff/model-differ.d.ts +0 -8
  24. package/dist/lib/diff/model-differ.js +0 -568
  25. package/dist/lib/diff/three-way-merge.d.ts +0 -7
  26. package/dist/lib/diff/three-way-merge.js +0 -390
  27. package/dist/lib/diff/types.d.ts +0 -75
  28. package/dist/lib/diff/types.js +0 -1
  29. package/dist/lib/element-lookup.d.ts +0 -58
  30. package/dist/lib/element-lookup.js +0 -126
  31. package/dist/lib/file-loader.d.ts +0 -8
  32. package/dist/lib/file-loader.js +0 -108
  33. package/dist/lib/flow-utils.d.ts +0 -53
  34. package/dist/lib/flow-utils.js +0 -348
  35. package/dist/lib/format.d.ts +0 -10
  36. package/dist/lib/format.js +0 -23
  37. package/dist/lib/project-config.d.ts +0 -27
  38. package/dist/lib/project-config.js +0 -83
  39. package/dist/lib/slice-utils.d.ts +0 -59
  40. package/dist/lib/slice-utils.js +0 -140
  41. package/dist/local/slices/index.d.ts +0 -11
  42. package/dist/local/slices/index.js +0 -13
  43. package/dist/projection.d.ts +0 -3
  44. package/dist/projection.js +0 -828
  45. package/dist/slices/add-field/index.d.ts +0 -8
  46. package/dist/slices/add-field/index.js +0 -211
  47. package/dist/slices/add-scenario/index.d.ts +0 -27
  48. package/dist/slices/add-scenario/index.js +0 -307
  49. package/dist/slices/codegen-chapter-events/index.d.ts +0 -2
  50. package/dist/slices/codegen-chapter-events/index.js +0 -145
  51. package/dist/slices/codegen-slice/index.d.ts +0 -2
  52. package/dist/slices/codegen-slice/index.js +0 -448
  53. package/dist/slices/create-automation-slice/index.d.ts +0 -2
  54. package/dist/slices/create-automation-slice/index.js +0 -304
  55. package/dist/slices/create-flow/index.d.ts +0 -2
  56. package/dist/slices/create-flow/index.js +0 -183
  57. package/dist/slices/create-state-change-slice/index.d.ts +0 -2
  58. package/dist/slices/create-state-change-slice/index.js +0 -263
  59. package/dist/slices/create-state-view-slice/index.d.ts +0 -2
  60. package/dist/slices/create-state-view-slice/index.js +0 -128
  61. package/dist/slices/diff/index.d.ts +0 -11
  62. package/dist/slices/diff/index.js +0 -293
  63. package/dist/slices/export-eventmodel-to-json/index.d.ts +0 -2
  64. package/dist/slices/export-eventmodel-to-json/index.js +0 -355
  65. package/dist/slices/git/index.d.ts +0 -2
  66. package/dist/slices/git/index.js +0 -125
  67. package/dist/slices/guide/guides/codegen.d.ts +0 -5
  68. package/dist/slices/guide/guides/codegen.js +0 -339
  69. package/dist/slices/guide/guides/connect-slices.d.ts +0 -5
  70. package/dist/slices/guide/guides/connect-slices.js +0 -202
  71. package/dist/slices/guide/guides/create-slices.d.ts +0 -5
  72. package/dist/slices/guide/guides/create-slices.js +0 -303
  73. package/dist/slices/guide/guides/explore.d.ts +0 -5
  74. package/dist/slices/guide/guides/explore.js +0 -251
  75. package/dist/slices/guide/guides/information-flow.d.ts +0 -5
  76. package/dist/slices/guide/guides/information-flow.js +0 -318
  77. package/dist/slices/guide/guides/scenarios.d.ts +0 -5
  78. package/dist/slices/guide/guides/scenarios.js +0 -269
  79. package/dist/slices/guide/index.d.ts +0 -1
  80. package/dist/slices/guide/index.js +0 -40
  81. package/dist/slices/import/index.d.ts +0 -8
  82. package/dist/slices/import/index.js +0 -63
  83. package/dist/slices/init/index.d.ts +0 -5
  84. package/dist/slices/init/index.js +0 -80
  85. package/dist/slices/list-chapters/index.d.ts +0 -3
  86. package/dist/slices/list-chapters/index.js +0 -21
  87. package/dist/slices/list-commands/index.d.ts +0 -3
  88. package/dist/slices/list-commands/index.js +0 -20
  89. package/dist/slices/list-events/index.d.ts +0 -3
  90. package/dist/slices/list-events/index.js +0 -98
  91. package/dist/slices/list-processors/index.d.ts +0 -3
  92. package/dist/slices/list-processors/index.js +0 -20
  93. package/dist/slices/list-readmodels/index.d.ts +0 -3
  94. package/dist/slices/list-readmodels/index.js +0 -21
  95. package/dist/slices/list-scenarios/index.d.ts +0 -3
  96. package/dist/slices/list-scenarios/index.js +0 -35
  97. package/dist/slices/list-screens/index.d.ts +0 -3
  98. package/dist/slices/list-screens/index.js +0 -47
  99. package/dist/slices/list-slices/index.d.ts +0 -3
  100. package/dist/slices/list-slices/index.js +0 -35
  101. package/dist/slices/login/index.d.ts +0 -1
  102. package/dist/slices/login/index.js +0 -20
  103. package/dist/slices/logout/index.d.ts +0 -1
  104. package/dist/slices/logout/index.js +0 -14
  105. package/dist/slices/map-fields/index.d.ts +0 -2
  106. package/dist/slices/map-fields/index.js +0 -269
  107. package/dist/slices/mark-slice-status/index.d.ts +0 -2
  108. package/dist/slices/mark-slice-status/index.js +0 -31
  109. package/dist/slices/merge/index.d.ts +0 -19
  110. package/dist/slices/merge/index.js +0 -147
  111. package/dist/slices/open-app/index.d.ts +0 -1
  112. package/dist/slices/open-app/index.js +0 -36
  113. package/dist/slices/remove-field/index.d.ts +0 -8
  114. package/dist/slices/remove-field/index.js +0 -167
  115. package/dist/slices/remove-scenario/index.d.ts +0 -2
  116. package/dist/slices/remove-scenario/index.js +0 -77
  117. package/dist/slices/search/index.d.ts +0 -3
  118. package/dist/slices/search/index.js +0 -302
  119. package/dist/slices/show-actor/index.d.ts +0 -4
  120. package/dist/slices/show-actor/index.js +0 -115
  121. package/dist/slices/show-aggregate/index.d.ts +0 -3
  122. package/dist/slices/show-aggregate/index.js +0 -108
  123. package/dist/slices/show-aggregate-completeness/index.d.ts +0 -4
  124. package/dist/slices/show-aggregate-completeness/index.js +0 -181
  125. package/dist/slices/show-chapter/index.d.ts +0 -3
  126. package/dist/slices/show-chapter/index.js +0 -195
  127. package/dist/slices/show-command/index.d.ts +0 -3
  128. package/dist/slices/show-command/index.js +0 -133
  129. package/dist/slices/show-completeness/index.d.ts +0 -4
  130. package/dist/slices/show-completeness/index.js +0 -731
  131. package/dist/slices/show-event/index.d.ts +0 -3
  132. package/dist/slices/show-event/index.js +0 -118
  133. package/dist/slices/show-model-summary/index.d.ts +0 -3
  134. package/dist/slices/show-model-summary/index.js +0 -31
  135. package/dist/slices/show-processor/index.d.ts +0 -3
  136. package/dist/slices/show-processor/index.js +0 -111
  137. package/dist/slices/show-readmodel/index.d.ts +0 -3
  138. package/dist/slices/show-readmodel/index.js +0 -158
  139. package/dist/slices/show-scenario/index.d.ts +0 -3
  140. package/dist/slices/show-scenario/index.js +0 -196
  141. package/dist/slices/show-screen/index.d.ts +0 -3
  142. package/dist/slices/show-screen/index.js +0 -139
  143. package/dist/slices/show-slice/index.d.ts +0 -3
  144. package/dist/slices/show-slice/index.js +0 -696
  145. package/dist/slices/update-field/index.d.ts +0 -15
  146. package/dist/slices/update-field/index.js +0 -208
  147. package/dist/slices/whoami/index.d.ts +0 -2
  148. package/dist/slices/whoami/index.js +0 -44
  149. package/dist/types.d.ts +0 -195
  150. package/dist/types.js +0 -1
@@ -1,17 +0,0 @@
1
- import type { EventModel, Slice, CommandSticky, EventSticky, ReadModelSticky, Screen, Processor, Scenario, Flow } from './types.js';
2
- export declare function getSliceComponents(model: EventModel, slice: Slice): {
3
- commands: CommandSticky[];
4
- events: EventSticky[];
5
- readModels: ReadModelSticky[];
6
- screens: Screen[];
7
- processors: Processor[];
8
- };
9
- export declare function getSliceScenarios(model: EventModel, sliceId: string): Scenario[];
10
- export declare function getRelevantFlows(model: EventModel, componentIds: Set<string>): Flow[];
11
- export declare function formatSliceXml(model: EventModel, slice: Slice): string;
12
- export declare function formatSlicesTable(slices: Slice[]): string;
13
- export declare function formatEventsTable(events: EventSticky[]): string;
14
- export declare function formatCommandsTable(commands: CommandSticky[]): string;
15
- export declare function formatModelSummary(model: EventModel): string;
16
- export declare function formatEventXml(model: EventModel, event: EventSticky): string;
17
- export declare function formatCommandXml(model: EventModel, command: CommandSticky): string;
@@ -1,482 +0,0 @@
1
- // Helper to escape XML special characters
2
- function escapeXml(str) {
3
- return str
4
- .replace(/&/g, '&amp;')
5
- .replace(/</g, '&lt;')
6
- .replace(/>/g, '&gt;')
7
- .replace(/"/g, '&quot;')
8
- .replace(/'/g, '&apos;');
9
- }
10
- // Helper to format field values for display
11
- function formatFieldValues(values) {
12
- if (!values || Object.keys(values).length === 0)
13
- return '';
14
- return Object.entries(values)
15
- .map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
16
- .join(', ');
17
- }
18
- // Format a single field as XML
19
- function formatFieldXml(field, indent, sourceInfo) {
20
- const attrs = [
21
- `name="${escapeXml(field.name)}"`,
22
- `type="${field.fieldType}"`,
23
- ];
24
- if (field.isList)
25
- attrs.push('list="true"');
26
- if (field.isGenerated)
27
- attrs.push('generated="true"');
28
- if (field.isOptional)
29
- attrs.push('optional="true"');
30
- if (field.isUserInput)
31
- attrs.push('user-input="true"');
32
- if (sourceInfo)
33
- attrs.push(`source="${escapeXml(sourceInfo)}"`);
34
- if (field.subfields && field.subfields.length > 0) {
35
- let xml = `${indent}<field ${attrs.join(' ')}>\n`;
36
- for (const subfield of field.subfields) {
37
- xml += formatFieldXml(subfield, indent + ' ');
38
- }
39
- xml += `${indent}</field>\n`;
40
- return xml;
41
- }
42
- return `${indent}<field ${attrs.join(' ')}/>\n`;
43
- }
44
- // Get all components that belong to a slice (by position intersection)
45
- export function getSliceComponents(model, slice) {
46
- const sliceBounds = {
47
- left: slice.position.x,
48
- right: slice.position.x + slice.size.width,
49
- top: slice.position.y,
50
- bottom: slice.position.y + slice.size.height,
51
- };
52
- function isInSlice(pos, width, height) {
53
- const centerX = pos.x + width / 2;
54
- const centerY = pos.y + height / 2;
55
- return (centerX >= sliceBounds.left &&
56
- centerX <= sliceBounds.right &&
57
- centerY >= sliceBounds.top &&
58
- centerY <= sliceBounds.bottom);
59
- }
60
- const commands = [];
61
- const events = [];
62
- const readModels = [];
63
- const screens = [];
64
- const processors = [];
65
- for (const cmd of model.commands.values()) {
66
- if (isInSlice(cmd.position, cmd.width, cmd.height)) {
67
- commands.push(cmd);
68
- }
69
- }
70
- for (const evt of model.events.values()) {
71
- if (isInSlice(evt.position, evt.width, evt.height)) {
72
- events.push(evt);
73
- }
74
- }
75
- for (const rm of model.readModels.values()) {
76
- if (isInSlice(rm.position, rm.width, rm.height)) {
77
- readModels.push(rm);
78
- }
79
- }
80
- for (const scr of model.screens.values()) {
81
- if (isInSlice(scr.position, scr.width, scr.height)) {
82
- screens.push(scr);
83
- }
84
- }
85
- for (const proc of model.processors.values()) {
86
- if (isInSlice(proc.position, proc.width, proc.height)) {
87
- processors.push(proc);
88
- }
89
- }
90
- return { commands, events, readModels, screens, processors };
91
- }
92
- // Get scenarios for a slice
93
- export function getSliceScenarios(model, sliceId) {
94
- const scenarios = [];
95
- for (const scenario of model.scenarios.values()) {
96
- if (scenario.sliceId === sliceId) {
97
- scenarios.push(scenario);
98
- }
99
- }
100
- return scenarios;
101
- }
102
- // Get flows relevant to a set of components
103
- export function getRelevantFlows(model, componentIds) {
104
- const flows = [];
105
- for (const flow of model.flows.values()) {
106
- if (componentIds.has(flow.sourceId) || componentIds.has(flow.targetId)) {
107
- flows.push(flow);
108
- }
109
- }
110
- return flows;
111
- }
112
- // Build information flow chains for a slice
113
- function buildInformationFlows(model, components, flows) {
114
- const componentIds = new Set();
115
- components.commands.forEach(c => componentIds.add(c.id));
116
- components.events.forEach(e => componentIds.add(e.id));
117
- components.readModels.forEach(rm => componentIds.add(rm.id));
118
- components.screens.forEach(s => componentIds.add(s.id));
119
- components.processors.forEach(p => componentIds.add(p.id));
120
- // Build adjacency for flows within the slice
121
- const internalFlows = flows.filter(f => componentIds.has(f.sourceId) && componentIds.has(f.targetId));
122
- // Get component name by ID
123
- function getName(id) {
124
- const cmd = model.commands.get(id);
125
- if (cmd)
126
- return cmd.name;
127
- const evt = model.events.get(id);
128
- if (evt)
129
- return evt.name;
130
- const rm = model.readModels.get(id);
131
- if (rm)
132
- return rm.name;
133
- const scr = model.screens.get(id);
134
- if (scr)
135
- return scr.name;
136
- const proc = model.processors.get(id);
137
- if (proc)
138
- return proc.name;
139
- return id;
140
- }
141
- // Simple representation of flows
142
- const flowStrings = [];
143
- for (const flow of internalFlows) {
144
- flowStrings.push(`${getName(flow.sourceId)} → ${getName(flow.targetId)}`);
145
- }
146
- return flowStrings;
147
- }
148
- // Format a slice as XML
149
- export function formatSliceXml(model, slice) {
150
- const components = getSliceComponents(model, slice);
151
- const scenarios = getSliceScenarios(model, slice.id);
152
- const componentIds = new Set();
153
- components.commands.forEach(c => componentIds.add(c.id));
154
- components.events.forEach(e => componentIds.add(e.id));
155
- components.readModels.forEach(rm => componentIds.add(rm.id));
156
- components.screens.forEach(s => componentIds.add(s.id));
157
- components.processors.forEach(p => componentIds.add(p.id));
158
- const flows = getRelevantFlows(model, componentIds);
159
- const infoFlows = buildInformationFlows(model, components, flows);
160
- let xml = `<slice name="${escapeXml(slice.name)}" status="${slice.status}">\n`;
161
- // Components section
162
- xml += ' <components>\n';
163
- // Screens
164
- for (const screen of components.screens) {
165
- xml += ` <screen name="${escapeXml(screen.name)}">\n`;
166
- if (screen.fields.length > 0) {
167
- xml += ' <fields>\n';
168
- for (const field of screen.fields) {
169
- const sourceInfo = field.isUserInput ? 'user-input' : undefined;
170
- xml += formatFieldXml(field, ' ', sourceInfo);
171
- }
172
- xml += ' </fields>\n';
173
- }
174
- xml += ' </screen>\n';
175
- }
176
- // Commands
177
- for (const command of components.commands) {
178
- xml += ` <command name="${escapeXml(command.name)}">\n`;
179
- if (command.fields.length > 0) {
180
- xml += ' <fields>\n';
181
- for (const field of command.fields) {
182
- // Try to find source from incoming flows
183
- const incomingFlow = flows.find(f => f.targetId === command.id);
184
- let sourceInfo;
185
- if (incomingFlow) {
186
- const sourceScreen = model.screens.get(incomingFlow.sourceId);
187
- const sourceProcessor = model.processors.get(incomingFlow.sourceId);
188
- if (sourceScreen) {
189
- const sourceField = sourceScreen.fields.find(f => f.name === field.name);
190
- if (sourceField) {
191
- sourceInfo = `${sourceScreen.name}.${field.name}`;
192
- }
193
- }
194
- else if (sourceProcessor) {
195
- const sourceField = sourceProcessor.fields.find(f => f.name === field.name);
196
- if (sourceField) {
197
- sourceInfo = `${sourceProcessor.name}.${field.name}`;
198
- }
199
- }
200
- }
201
- xml += formatFieldXml(field, ' ', sourceInfo);
202
- }
203
- xml += ' </fields>\n';
204
- }
205
- xml += ' </command>\n';
206
- }
207
- // Events
208
- for (const event of components.events) {
209
- xml += ` <event name="${escapeXml(event.name)}">\n`;
210
- if (event.fields.length > 0) {
211
- xml += ' <fields>\n';
212
- for (const field of event.fields) {
213
- // Try to find source from incoming flows
214
- const incomingFlow = flows.find(f => f.targetId === event.id);
215
- let sourceInfo;
216
- if (field.isGenerated) {
217
- sourceInfo = 'generated';
218
- }
219
- else if (incomingFlow) {
220
- const sourceCommand = model.commands.get(incomingFlow.sourceId);
221
- if (sourceCommand) {
222
- const sourceField = sourceCommand.fields.find(f => f.name === field.name);
223
- if (sourceField) {
224
- sourceInfo = `${sourceCommand.name}.${field.name}`;
225
- }
226
- }
227
- }
228
- xml += formatFieldXml(field, ' ', sourceInfo);
229
- }
230
- xml += ' </fields>\n';
231
- }
232
- xml += ' </event>\n';
233
- }
234
- // Read Models
235
- for (const readModel of components.readModels) {
236
- xml += ` <read-model name="${escapeXml(readModel.name)}">\n`;
237
- if (readModel.fields.length > 0) {
238
- xml += ' <fields>\n';
239
- for (const field of readModel.fields) {
240
- xml += formatFieldXml(field, ' ');
241
- }
242
- xml += ' </fields>\n';
243
- }
244
- xml += ' </read-model>\n';
245
- }
246
- // Processors
247
- for (const processor of components.processors) {
248
- xml += ` <processor name="${escapeXml(processor.name)}">\n`;
249
- if (processor.fields.length > 0) {
250
- xml += ' <fields>\n';
251
- for (const field of processor.fields) {
252
- xml += formatFieldXml(field, ' ');
253
- }
254
- xml += ' </fields>\n';
255
- }
256
- xml += ' </processor>\n';
257
- }
258
- xml += ' </components>\n';
259
- // Information flow section
260
- if (infoFlows.length > 0) {
261
- xml += ' <information-flow>\n';
262
- for (const flow of infoFlows) {
263
- xml += ` ${escapeXml(flow)}\n`;
264
- }
265
- xml += ' </information-flow>\n';
266
- }
267
- // Scenarios section
268
- if (scenarios.length > 0) {
269
- xml += ' <scenarios>\n';
270
- for (const scenario of scenarios) {
271
- xml += ` <scenario name="${escapeXml(scenario.name)}">\n`;
272
- if (scenario.description) {
273
- xml += ` <description>${escapeXml(scenario.description)}</description>\n`;
274
- }
275
- // Given events
276
- if (scenario.givenEvents.length > 0) {
277
- xml += ' <given>\n';
278
- for (const givenEvent of scenario.givenEvents) {
279
- const evt = model.events.get(givenEvent.eventStickyId);
280
- const evtName = evt?.name ?? 'UnknownEvent';
281
- const fieldValuesStr = formatFieldValues(givenEvent.fieldValues);
282
- if (fieldValuesStr) {
283
- xml += ` <event type="${escapeXml(evtName)}">${escapeXml(fieldValuesStr)}</event>\n`;
284
- }
285
- else {
286
- xml += ` <event type="${escapeXml(evtName)}"/>\n`;
287
- }
288
- }
289
- xml += ' </given>\n';
290
- }
291
- // When command
292
- if (scenario.whenCommand) {
293
- const cmd = model.commands.get(scenario.whenCommand.commandStickyId);
294
- const cmdName = cmd?.name ?? 'UnknownCommand';
295
- const fieldValuesStr = formatFieldValues(scenario.whenCommand.fieldValues);
296
- if (fieldValuesStr) {
297
- xml += ` <when>\n <command type="${escapeXml(cmdName)}">${escapeXml(fieldValuesStr)}</command>\n </when>\n`;
298
- }
299
- else {
300
- xml += ` <when>\n <command type="${escapeXml(cmdName)}"/>\n </when>\n`;
301
- }
302
- }
303
- // Then
304
- xml += ' <then>\n';
305
- if (scenario.then.type === 'error') {
306
- xml += ` <error`;
307
- if (scenario.then.errorType) {
308
- xml += ` type="${escapeXml(scenario.then.errorType)}"`;
309
- }
310
- xml += `>${escapeXml(scenario.then.errorMessage ?? '')}</error>\n`;
311
- }
312
- else if (scenario.then.type === 'events' && scenario.then.expectedEvents) {
313
- for (const expectedEvent of scenario.then.expectedEvents) {
314
- const evt = model.events.get(expectedEvent.eventStickyId);
315
- const evtName = evt?.name ?? 'UnknownEvent';
316
- const fieldValuesStr = formatFieldValues(expectedEvent.fieldValues);
317
- if (fieldValuesStr) {
318
- xml += ` <event type="${escapeXml(evtName)}">${escapeXml(fieldValuesStr)}</event>\n`;
319
- }
320
- else {
321
- xml += ` <event type="${escapeXml(evtName)}"/>\n`;
322
- }
323
- }
324
- }
325
- else if (scenario.then.type === 'readModelAssertion' && scenario.then.readModelAssertion) {
326
- const assertion = scenario.then.readModelAssertion;
327
- const rm = model.readModels.get(assertion.readModelStickyId);
328
- const rmName = rm?.name ?? 'UnknownReadModel';
329
- xml += ` <read-model-assertion type="${escapeXml(rmName)}">\n`;
330
- xml += ` <expected>${escapeXml(formatFieldValues(assertion.expectedFieldValues))}</expected>\n`;
331
- xml += ' </read-model-assertion>\n';
332
- }
333
- xml += ' </then>\n';
334
- xml += ' </scenario>\n';
335
- }
336
- xml += ' </scenarios>\n';
337
- }
338
- xml += '</slice>';
339
- return xml;
340
- }
341
- // Format slices list as table
342
- export function formatSlicesTable(slices) {
343
- if (slices.length === 0) {
344
- return 'No slices found.';
345
- }
346
- // Sort by position (left to right)
347
- const sorted = [...slices].sort((a, b) => a.position.x - b.position.x);
348
- // Calculate column widths
349
- const nameWidth = Math.max(4, ...sorted.map(s => s.name.length));
350
- const statusWidth = 11; // 'in-progress' is longest
351
- let output = '';
352
- output += `${'NAME'.padEnd(nameWidth)} ${'STATUS'.padEnd(statusWidth)}\n`;
353
- output += `${'-'.repeat(nameWidth)} ${'-'.repeat(statusWidth)}\n`;
354
- for (const slice of sorted) {
355
- const statusDisplay = slice.status === 'in-progress' ? 'in-progress' : slice.status;
356
- output += `${slice.name.padEnd(nameWidth)} ${statusDisplay.padEnd(statusWidth)}\n`;
357
- }
358
- return output;
359
- }
360
- // Format events list as table
361
- export function formatEventsTable(events) {
362
- if (events.length === 0) {
363
- return 'No events found.';
364
- }
365
- const sorted = [...events].sort((a, b) => a.name.localeCompare(b.name));
366
- const nameWidth = Math.max(4, ...sorted.map(e => e.name.length));
367
- const fieldsWidth = 6;
368
- let output = '';
369
- output += `${'NAME'.padEnd(nameWidth)} ${'FIELDS'.padEnd(fieldsWidth)}\n`;
370
- output += `${'-'.repeat(nameWidth)} ${'-'.repeat(fieldsWidth)}\n`;
371
- for (const evt of sorted) {
372
- output += `${evt.name.padEnd(nameWidth)} ${String(evt.fields.length).padEnd(fieldsWidth)}\n`;
373
- }
374
- return output;
375
- }
376
- // Format commands list as table
377
- export function formatCommandsTable(commands) {
378
- if (commands.length === 0) {
379
- return 'No commands found.';
380
- }
381
- const sorted = [...commands].sort((a, b) => a.name.localeCompare(b.name));
382
- const nameWidth = Math.max(4, ...sorted.map(c => c.name.length));
383
- const fieldsWidth = 6;
384
- let output = '';
385
- output += `${'NAME'.padEnd(nameWidth)} ${'FIELDS'.padEnd(fieldsWidth)}\n`;
386
- output += `${'-'.repeat(nameWidth)} ${'-'.repeat(fieldsWidth)}\n`;
387
- for (const cmd of sorted) {
388
- output += `${cmd.name.padEnd(nameWidth)} ${String(cmd.fields.length).padEnd(fieldsWidth)}\n`;
389
- }
390
- return output;
391
- }
392
- // Format model summary
393
- export function formatModelSummary(model) {
394
- let output = `Event Model: ${model.name}\n`;
395
- output += `${'='.repeat(model.name.length + 13)}\n\n`;
396
- output += `Slices: ${model.slices.size}\n`;
397
- output += `Commands: ${model.commands.size}\n`;
398
- output += `Events: ${model.events.size}\n`;
399
- output += `Read Models: ${model.readModels.size}\n`;
400
- output += `Screens: ${model.screens.size}\n`;
401
- output += `Processors: ${model.processors.size}\n`;
402
- output += `Scenarios: ${model.scenarios.size}\n`;
403
- output += `Flows: ${model.flows.size}\n`;
404
- return output;
405
- }
406
- // Format entity details as XML
407
- export function formatEventXml(model, event) {
408
- let xml = `<event name="${escapeXml(event.name)}">\n`;
409
- if (event.fields.length > 0) {
410
- xml += ' <fields>\n';
411
- for (const field of event.fields) {
412
- xml += formatFieldXml(field, ' ');
413
- }
414
- xml += ' </fields>\n';
415
- }
416
- // Find incoming flows (what produces this event)
417
- const incomingFlows = [...model.flows.values()].filter(f => f.targetId === event.id);
418
- // Find outgoing flows (what consumes this event)
419
- const outgoingFlows = [...model.flows.values()].filter(f => f.sourceId === event.id);
420
- if (incomingFlows.length > 0) {
421
- xml += ' <produced-by>\n';
422
- for (const flow of incomingFlows) {
423
- const source = model.commands.get(flow.sourceId);
424
- if (source) {
425
- xml += ` <command name="${escapeXml(source.name)}"/>\n`;
426
- }
427
- }
428
- xml += ' </produced-by>\n';
429
- }
430
- if (outgoingFlows.length > 0) {
431
- xml += ' <consumed-by>\n';
432
- for (const flow of outgoingFlows) {
433
- const target = model.readModels.get(flow.targetId);
434
- if (target) {
435
- xml += ` <read-model name="${escapeXml(target.name)}"/>\n`;
436
- }
437
- }
438
- xml += ' </consumed-by>\n';
439
- }
440
- xml += '</event>';
441
- return xml;
442
- }
443
- export function formatCommandXml(model, command) {
444
- let xml = `<command name="${escapeXml(command.name)}">\n`;
445
- if (command.fields.length > 0) {
446
- xml += ' <fields>\n';
447
- for (const field of command.fields) {
448
- xml += formatFieldXml(field, ' ');
449
- }
450
- xml += ' </fields>\n';
451
- }
452
- // Find incoming flows (what triggers this command)
453
- const incomingFlows = [...model.flows.values()].filter(f => f.targetId === command.id);
454
- // Find outgoing flows (what events this command produces)
455
- const outgoingFlows = [...model.flows.values()].filter(f => f.sourceId === command.id);
456
- if (incomingFlows.length > 0) {
457
- xml += ' <triggered-by>\n';
458
- for (const flow of incomingFlows) {
459
- const sourceScreen = model.screens.get(flow.sourceId);
460
- const sourceProcessor = model.processors.get(flow.sourceId);
461
- if (sourceScreen) {
462
- xml += ` <screen name="${escapeXml(sourceScreen.name)}"/>\n`;
463
- }
464
- else if (sourceProcessor) {
465
- xml += ` <processor name="${escapeXml(sourceProcessor.name)}"/>\n`;
466
- }
467
- }
468
- xml += ' </triggered-by>\n';
469
- }
470
- if (outgoingFlows.length > 0) {
471
- xml += ' <produces>\n';
472
- for (const flow of outgoingFlows) {
473
- const target = model.events.get(flow.targetId);
474
- if (target) {
475
- xml += ` <event name="${escapeXml(target.name)}"/>\n`;
476
- }
477
- }
478
- xml += ' </produces>\n';
479
- }
480
- xml += '</command>';
481
- return xml;
482
- }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,24 +0,0 @@
1
- import { type AuthTokens } from './config.js';
2
- interface AuthResult {
3
- success: boolean;
4
- tokens?: AuthTokens;
5
- error?: string;
6
- }
7
- /**
8
- * Starts the OAuth flow using Keycloak PKCE.
9
- * Opens browser and waits for the callback.
10
- */
11
- export declare function startAuthFlow(): Promise<AuthResult>;
12
- /**
13
- * Refresh the access token using the refresh token.
14
- */
15
- export declare function refreshAccessToken(): Promise<AuthResult>;
16
- /**
17
- * Get a valid access token, refreshing if needed.
18
- */
19
- export declare function getValidAccessToken(): Promise<string | null>;
20
- /**
21
- * Log out by clearing stored tokens.
22
- */
23
- export declare function logout(): void;
24
- export {};