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.
Files changed (204) hide show
  1. package/dist/api/client-config.js +10 -0
  2. package/dist/api/generated/client/client.gen.js +235 -0
  3. package/dist/api/generated/client/index.js +6 -0
  4. package/dist/api/generated/client/types.gen.js +2 -0
  5. package/dist/api/generated/client/utils.gen.js +228 -0
  6. package/dist/api/generated/client.gen.js +4 -0
  7. package/dist/api/generated/core/auth.gen.js +14 -0
  8. package/dist/api/generated/core/bodySerializer.gen.js +57 -0
  9. package/dist/api/generated/core/params.gen.js +100 -0
  10. package/dist/api/generated/core/pathSerializer.gen.js +106 -0
  11. package/dist/api/generated/core/queryKeySerializer.gen.js +92 -0
  12. package/dist/api/generated/core/serverSentEvents.gen.js +133 -0
  13. package/dist/api/generated/core/types.gen.js +2 -0
  14. package/dist/api/generated/core/utils.gen.js +87 -0
  15. package/dist/api/generated/index.js +2 -0
  16. package/dist/api/generated/sdk.gen.js +4222 -0
  17. package/dist/api/generated/types.gen.js +2 -0
  18. package/dist/api/generated/zod.gen.js +7217 -0
  19. package/dist/commands/add.js +315 -0
  20. package/dist/commands/auth.js +14 -0
  21. package/dist/commands/create.js +192 -0
  22. package/dist/commands/design.js +108 -0
  23. package/dist/commands/guide.js +15 -0
  24. package/dist/commands/init.js +21 -0
  25. package/dist/commands/list-schemas.js +177 -0
  26. package/dist/commands/list.js +39 -0
  27. package/dist/commands/loop.js +101 -0
  28. package/dist/commands/map.js +40 -0
  29. package/dist/commands/mark.js +27 -0
  30. package/dist/commands/move.js +35 -0
  31. package/dist/commands/remove.js +170 -0
  32. package/dist/commands/rename.js +53 -0
  33. package/dist/commands/resize.js +30 -0
  34. package/dist/commands/search.js +14 -0
  35. package/dist/commands/set.js +199 -0
  36. package/dist/commands/show-schemas.js +259 -0
  37. package/dist/commands/show.js +56 -0
  38. package/dist/commands/summary.js +13 -0
  39. package/dist/commands/update.js +240 -0
  40. package/dist/index.js +46 -2379
  41. package/dist/lib/auth.js +1 -1
  42. package/dist/lib/config.js +0 -15
  43. package/dist/lib/excalidraw-schema.js +66 -0
  44. package/dist/lib/globals.js +8 -0
  45. package/dist/lib/model.js +11 -0
  46. package/dist/lib/project-config.js +20 -0
  47. package/dist/lib/resolve.js +59 -0
  48. package/dist/lib/scenario.js +15 -0
  49. package/dist/slices/add-scenario/index.js +2 -206
  50. package/dist/slices/guide/guides/codegen.js +1 -1
  51. package/dist/slices/guide/guides/connect-slices.js +12 -37
  52. package/dist/slices/guide/guides/create-slices.js +110 -140
  53. package/dist/slices/guide/guides/explore.js +37 -26
  54. package/dist/slices/guide/guides/information-flow.js +70 -82
  55. package/dist/slices/guide/guides/scenarios.js +82 -137
  56. package/dist/slices/guide/index.js +6 -6
  57. package/dist/slices/help/index.js +96 -0
  58. package/dist/slices/help/topics/build-codegen.js +109 -0
  59. package/dist/slices/help/topics/build-slice.js +147 -0
  60. package/dist/slices/help/topics/check-completeness.js +57 -0
  61. package/dist/slices/help/topics/connect-slices.js +99 -0
  62. package/dist/slices/help/topics/explore-model.js +112 -0
  63. package/dist/slices/help/topics/json-reference.js +188 -0
  64. package/dist/slices/help/topics/linked-copies.js +89 -0
  65. package/dist/slices/help/topics/manipulate-canvas.js +150 -0
  66. package/dist/slices/help/topics/write-scenarios.js +162 -0
  67. package/dist/slices/init/index.js +10 -4
  68. package/dist/slices/init/loop.js +60 -0
  69. package/dist/slices/login/index.js +2 -2
  70. package/dist/slices/logout/index.js +2 -2
  71. package/dist/slices/whoami/index.js +11 -36
  72. package/package.json +8 -3
  73. package/dist/api/index.d.ts +0 -285
  74. package/dist/api/index.js +0 -323
  75. package/dist/cloud/slices/index.d.ts +0 -276
  76. package/dist/cloud/slices/index.js +0 -406
  77. package/dist/eventmodeler.js +0 -5646
  78. package/dist/formatters.d.ts +0 -17
  79. package/dist/formatters.js +0 -482
  80. package/dist/index.d.ts +0 -2
  81. package/dist/lib/auth.d.ts +0 -24
  82. package/dist/lib/backend.d.ts +0 -43
  83. package/dist/lib/backend.js +0 -73
  84. package/dist/lib/chapter-utils.d.ts +0 -13
  85. package/dist/lib/chapter-utils.js +0 -71
  86. package/dist/lib/cloud-client.d.ts +0 -69
  87. package/dist/lib/cloud-client.js +0 -364
  88. package/dist/lib/config.d.ts +0 -30
  89. package/dist/lib/diff/merge-rules.d.ts +0 -45
  90. package/dist/lib/diff/merge-rules.js +0 -210
  91. package/dist/lib/diff/model-differ.d.ts +0 -8
  92. package/dist/lib/diff/model-differ.js +0 -568
  93. package/dist/lib/diff/three-way-merge.d.ts +0 -7
  94. package/dist/lib/diff/three-way-merge.js +0 -390
  95. package/dist/lib/diff/types.d.ts +0 -75
  96. package/dist/lib/diff/types.js +0 -1
  97. package/dist/lib/element-lookup.d.ts +0 -58
  98. package/dist/lib/element-lookup.js +0 -126
  99. package/dist/lib/file-loader.d.ts +0 -8
  100. package/dist/lib/file-loader.js +0 -108
  101. package/dist/lib/flow-utils.d.ts +0 -53
  102. package/dist/lib/flow-utils.js +0 -348
  103. package/dist/lib/format.d.ts +0 -10
  104. package/dist/lib/format.js +0 -23
  105. package/dist/lib/project-config.d.ts +0 -27
  106. package/dist/lib/slice-utils.d.ts +0 -59
  107. package/dist/lib/slice-utils.js +0 -140
  108. package/dist/local/slices/index.d.ts +0 -11
  109. package/dist/local/slices/index.js +0 -13
  110. package/dist/projection.d.ts +0 -3
  111. package/dist/projection.js +0 -828
  112. package/dist/slices/add-field/index.d.ts +0 -8
  113. package/dist/slices/add-field/index.js +0 -211
  114. package/dist/slices/add-scenario/index.d.ts +0 -27
  115. package/dist/slices/codegen-chapter-events/index.d.ts +0 -2
  116. package/dist/slices/codegen-chapter-events/index.js +0 -145
  117. package/dist/slices/codegen-slice/index.d.ts +0 -2
  118. package/dist/slices/codegen-slice/index.js +0 -448
  119. package/dist/slices/create-automation-slice/index.d.ts +0 -2
  120. package/dist/slices/create-automation-slice/index.js +0 -304
  121. package/dist/slices/create-flow/index.d.ts +0 -2
  122. package/dist/slices/create-flow/index.js +0 -183
  123. package/dist/slices/create-state-change-slice/index.d.ts +0 -2
  124. package/dist/slices/create-state-change-slice/index.js +0 -263
  125. package/dist/slices/create-state-view-slice/index.d.ts +0 -2
  126. package/dist/slices/create-state-view-slice/index.js +0 -128
  127. package/dist/slices/diff/index.d.ts +0 -11
  128. package/dist/slices/diff/index.js +0 -293
  129. package/dist/slices/export-eventmodel-to-json/index.d.ts +0 -2
  130. package/dist/slices/export-eventmodel-to-json/index.js +0 -355
  131. package/dist/slices/git/index.d.ts +0 -2
  132. package/dist/slices/git/index.js +0 -125
  133. package/dist/slices/guide/guides/codegen.d.ts +0 -5
  134. package/dist/slices/guide/guides/connect-slices.d.ts +0 -5
  135. package/dist/slices/guide/guides/create-slices.d.ts +0 -5
  136. package/dist/slices/guide/guides/explore.d.ts +0 -5
  137. package/dist/slices/guide/guides/information-flow.d.ts +0 -5
  138. package/dist/slices/guide/guides/scenarios.d.ts +0 -5
  139. package/dist/slices/guide/index.d.ts +0 -1
  140. package/dist/slices/import/index.d.ts +0 -8
  141. package/dist/slices/import/index.js +0 -63
  142. package/dist/slices/init/index.d.ts +0 -5
  143. package/dist/slices/list-chapters/index.d.ts +0 -3
  144. package/dist/slices/list-chapters/index.js +0 -21
  145. package/dist/slices/list-commands/index.d.ts +0 -3
  146. package/dist/slices/list-commands/index.js +0 -20
  147. package/dist/slices/list-events/index.d.ts +0 -3
  148. package/dist/slices/list-events/index.js +0 -98
  149. package/dist/slices/list-processors/index.d.ts +0 -3
  150. package/dist/slices/list-processors/index.js +0 -20
  151. package/dist/slices/list-readmodels/index.d.ts +0 -3
  152. package/dist/slices/list-readmodels/index.js +0 -21
  153. package/dist/slices/list-scenarios/index.d.ts +0 -3
  154. package/dist/slices/list-scenarios/index.js +0 -35
  155. package/dist/slices/list-screens/index.d.ts +0 -3
  156. package/dist/slices/list-screens/index.js +0 -47
  157. package/dist/slices/list-slices/index.d.ts +0 -3
  158. package/dist/slices/list-slices/index.js +0 -35
  159. package/dist/slices/login/index.d.ts +0 -1
  160. package/dist/slices/logout/index.d.ts +0 -1
  161. package/dist/slices/map-fields/index.d.ts +0 -2
  162. package/dist/slices/map-fields/index.js +0 -269
  163. package/dist/slices/mark-slice-status/index.d.ts +0 -2
  164. package/dist/slices/mark-slice-status/index.js +0 -31
  165. package/dist/slices/merge/index.d.ts +0 -19
  166. package/dist/slices/merge/index.js +0 -147
  167. package/dist/slices/open-app/index.d.ts +0 -1
  168. package/dist/slices/remove-field/index.d.ts +0 -8
  169. package/dist/slices/remove-field/index.js +0 -167
  170. package/dist/slices/remove-scenario/index.d.ts +0 -2
  171. package/dist/slices/remove-scenario/index.js +0 -77
  172. package/dist/slices/search/index.d.ts +0 -3
  173. package/dist/slices/search/index.js +0 -302
  174. package/dist/slices/show-actor/index.d.ts +0 -4
  175. package/dist/slices/show-actor/index.js +0 -115
  176. package/dist/slices/show-aggregate/index.d.ts +0 -3
  177. package/dist/slices/show-aggregate/index.js +0 -108
  178. package/dist/slices/show-aggregate-completeness/index.d.ts +0 -4
  179. package/dist/slices/show-aggregate-completeness/index.js +0 -181
  180. package/dist/slices/show-chapter/index.d.ts +0 -3
  181. package/dist/slices/show-chapter/index.js +0 -195
  182. package/dist/slices/show-command/index.d.ts +0 -3
  183. package/dist/slices/show-command/index.js +0 -133
  184. package/dist/slices/show-completeness/index.d.ts +0 -4
  185. package/dist/slices/show-completeness/index.js +0 -731
  186. package/dist/slices/show-event/index.d.ts +0 -3
  187. package/dist/slices/show-event/index.js +0 -118
  188. package/dist/slices/show-model-summary/index.d.ts +0 -3
  189. package/dist/slices/show-model-summary/index.js +0 -31
  190. package/dist/slices/show-processor/index.d.ts +0 -3
  191. package/dist/slices/show-processor/index.js +0 -111
  192. package/dist/slices/show-readmodel/index.d.ts +0 -3
  193. package/dist/slices/show-readmodel/index.js +0 -158
  194. package/dist/slices/show-scenario/index.d.ts +0 -3
  195. package/dist/slices/show-scenario/index.js +0 -196
  196. package/dist/slices/show-screen/index.d.ts +0 -3
  197. package/dist/slices/show-screen/index.js +0 -139
  198. package/dist/slices/show-slice/index.d.ts +0 -3
  199. package/dist/slices/show-slice/index.js +0 -696
  200. package/dist/slices/update-field/index.d.ts +0 -15
  201. package/dist/slices/update-field/index.js +0 -208
  202. package/dist/slices/whoami/index.d.ts +0 -2
  203. package/dist/types.d.ts +0 -195
  204. 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 {};
@@ -1,43 +0,0 @@
1
- import type { EventModel } from '../types.js';
2
- import { type ProjectConfig } from './project-config.js';
3
- /**
4
- * Backend abstraction for CLI operations.
5
- * Allows commands to work with either local files or cloud backend.
6
- */
7
- export interface CliBackend {
8
- /** Get the current event model */
9
- getModel(): Promise<EventModel>;
10
- /** Dispatch a command (for mutations) */
11
- dispatch(command: unknown): Promise<void>;
12
- /** Whether this is a cloud backend */
13
- isCloud(): boolean;
14
- /** Get the model name or file path */
15
- getModelIdentifier(): string;
16
- /** Append a raw event (for local backend only, used by existing commands) */
17
- appendEvent?(event: unknown): Promise<void>;
18
- }
19
- /**
20
- * Create a local file-based backend.
21
- */
22
- export declare function createLocalBackend(filePath: string): CliBackend;
23
- export interface ResolveBackendOptions {
24
- /** Explicit file path (overrides auto-detection) */
25
- filePath?: string;
26
- /** Force cloud mode */
27
- forceCloud?: boolean;
28
- }
29
- /**
30
- * Resolve which backend to use based on:
31
- * 1. Explicit -f <file> flag
32
- * 2. .eventmodeler.json project config
33
- * 3. .eventmodel file in current directory (legacy)
34
- */
35
- export declare function resolveBackend(options?: ResolveBackendOptions): Promise<CliBackend>;
36
- /**
37
- * Check if we're in a configured project.
38
- */
39
- export declare function isInConfiguredProject(): boolean;
40
- /**
41
- * Get the project config if available.
42
- */
43
- export declare function getProjectConfig(): ProjectConfig | null;
@@ -1,73 +0,0 @@
1
- import { loadModel, appendEvent as appendEventToFile } from './file-loader.js';
2
- import { loadProjectConfig } from './project-config.js';
3
- import { findEventModelFile } from './file-loader.js';
4
- /**
5
- * Create a local file-based backend.
6
- */
7
- export function createLocalBackend(filePath) {
8
- return {
9
- async getModel() {
10
- return loadModel(filePath);
11
- },
12
- async dispatch(_command) {
13
- // Local backend doesn't use dispatch - existing commands use appendEvent directly
14
- throw new Error('Local backend does not support dispatch. Use appendEvent instead.');
15
- },
16
- isCloud() {
17
- return false;
18
- },
19
- getModelIdentifier() {
20
- return filePath;
21
- },
22
- async appendEvent(event) {
23
- appendEventToFile(filePath, event);
24
- },
25
- };
26
- }
27
- /**
28
- * Resolve which backend to use based on:
29
- * 1. Explicit -f <file> flag
30
- * 2. .eventmodeler.json project config
31
- * 3. .eventmodel file in current directory (legacy)
32
- */
33
- export async function resolveBackend(options = {}) {
34
- // 1. Explicit file path always wins
35
- if (options.filePath) {
36
- return createLocalBackend(options.filePath);
37
- }
38
- // 2. Check for project config
39
- const projectConfig = loadProjectConfig();
40
- if (projectConfig) {
41
- if (projectConfig.type === 'local') {
42
- return createLocalBackend(projectConfig.file);
43
- }
44
- if (projectConfig.type === 'cloud') {
45
- // Cloud mode uses cloud slices directly, not the CliBackend abstraction
46
- throw new Error('Cloud mode detected but CliBackend abstraction is not supported for cloud.\n' +
47
- 'Use cloud slices directly for cloud operations.');
48
- }
49
- }
50
- // 3. Legacy: look for .eventmodel file in current directory
51
- const localFile = await findEventModelFile();
52
- if (localFile) {
53
- return createLocalBackend(localFile);
54
- }
55
- // 4. No backend found
56
- throw new Error('No event model found.\n\n' +
57
- 'Options:\n' +
58
- ' - Run "eventmodeler init" to set up a project\n' +
59
- ' - Use "-f <file>" to specify a local .eventmodel file\n' +
60
- ' - Create a .eventmodel file in the current directory');
61
- }
62
- /**
63
- * Check if we're in a configured project.
64
- */
65
- export function isInConfiguredProject() {
66
- return loadProjectConfig() !== null;
67
- }
68
- /**
69
- * Get the project config if available.
70
- */
71
- export function getProjectConfig() {
72
- return loadProjectConfig();
73
- }
@@ -1,13 +0,0 @@
1
- import type { Chapter, EventModel, Slice } from '../types.js';
2
- export interface ChapterWithHierarchy {
3
- id: string;
4
- name: string;
5
- parent?: ChapterWithHierarchy;
6
- }
7
- export declare function findParentChapter(model: EventModel, chapter: Chapter): Chapter | null;
8
- export declare function getChapterHierarchy(model: EventModel, chapter: Chapter): ChapterWithHierarchy;
9
- export declare function hierarchyToArray(hierarchy: ChapterWithHierarchy): Array<{
10
- id: string;
11
- name: string;
12
- }>;
13
- export declare function findChapterForSlice(model: EventModel, slice: Slice): Chapter | null;