eventmodeler 0.5.0 → 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 +38 -38
  52. package/dist/slices/guide/guides/create-slices.js +110 -140
  53. package/dist/slices/guide/guides/explore.js +37 -50
  54. package/dist/slices/guide/guides/information-flow.js +70 -84
  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
@@ -0,0 +1,30 @@
1
+ import { getGlobalId } from '../lib/globals';
2
+ import { requireModelId } from '../lib/model';
3
+ import { resolve, unwrap, elementIdKey } from '../lib/resolve';
4
+ import * as sdk from '../api/generated/sdk.gen';
5
+ const RESIZE_MAP = {
6
+ slice: sdk.resizeSlice,
7
+ aggregate: sdk.resizeAggregate,
8
+ actor: sdk.resizeActor,
9
+ chapter: sdk.resizeChapter,
10
+ context: sdk.resizeContext,
11
+ swimlane: sdk.resizeSwimLane,
12
+ };
13
+ export function registerResizeCommands(program) {
14
+ program.command('resize <type> [name]')
15
+ .description('Resize an element')
16
+ .requiredOption('--x <n>', 'X coordinate', Number)
17
+ .requiredOption('--y <n>', 'Y coordinate', Number)
18
+ .requiredOption('--width <n>', 'Width', Number)
19
+ .requiredOption('--height <n>', 'Height', Number)
20
+ .action(async (type, name, opts, cmd) => {
21
+ const modelId = requireModelId();
22
+ const fn = RESIZE_MAP[type];
23
+ if (!fn)
24
+ throw new Error(`Unknown type: ${type}. Valid types: ${Object.keys(RESIZE_MAP).join(', ')}`);
25
+ const id = await resolve(modelId, type, name ?? '', getGlobalId());
26
+ const key = elementIdKey(type);
27
+ unwrap(await fn({ body: { modelId, [key]: id, x: opts.x, y: opts.y, width: opts.width, height: opts.height } }));
28
+ console.log(`Resized ${type}.`);
29
+ });
30
+ }
@@ -0,0 +1,14 @@
1
+ import { requireModelId } from '../lib/model';
2
+ import { unwrap, out } from '../lib/resolve';
3
+ import * as sdk from '../api/generated/sdk.gen';
4
+ import { SEARCH_HELP } from './list-schemas';
5
+ export function registerSearchCommands(program) {
6
+ program.command('search <term...>')
7
+ .description('Search elements by name')
8
+ .addHelpText('after', SEARCH_HELP)
9
+ .action(async (terms) => {
10
+ const modelId = requireModelId();
11
+ const search = terms.join(' ');
12
+ out(unwrap(await sdk.search({ path: { modelId }, query: { search } })));
13
+ });
14
+ }
@@ -0,0 +1,199 @@
1
+ import { getGlobalId } from '../lib/globals';
2
+ import { requireModelId } from '../lib/model';
3
+ import { resolve, unwrap } from '../lib/resolve';
4
+ import { resolveScenarioId } from '../lib/scenario';
5
+ import * as sdk from '../api/generated/sdk.gen';
6
+ const SET_FIELD_VALUE_MAP = {
7
+ event: sdk.setScenarioEventFieldValue,
8
+ command: sdk.setScenarioCommandFieldValue,
9
+ readmodel: sdk.setScenarioReadModelFieldValue,
10
+ };
11
+ const SET_FIELD_LIST_VALUES_MAP = {
12
+ event: sdk.setScenarioEventFieldListValues,
13
+ command: sdk.setScenarioCommandFieldListValues,
14
+ readmodel: sdk.setScenarioReadModelFieldListValues,
15
+ };
16
+ const SET_FIELD_CUSTOM_VALUE_MAP = {
17
+ event: sdk.setScenarioEventFieldCustomValue,
18
+ command: sdk.setScenarioCommandFieldCustomValue,
19
+ readmodel: sdk.setScenarioReadModelFieldCustomValue,
20
+ };
21
+ const SET_FIELD_CUSTOM_LIST_VALUES_MAP = {
22
+ event: sdk.setScenarioEventFieldCustomListValues,
23
+ command: sdk.setScenarioCommandFieldCustomListValues,
24
+ readmodel: sdk.setScenarioReadModelFieldCustomListValues,
25
+ };
26
+ function collectListValue(value, previous) {
27
+ return [...previous, value];
28
+ }
29
+ export function registerSetCommands(program) {
30
+ const set = program.command('set').description('Set values on elements');
31
+ // set example --scenario <name> --entry <entryId> --type event|command|readmodel --field <name>
32
+ // Primitive scalar: --value <val>
33
+ // Primitive list: --value <v> [--value <v> ...] or --values <csv>
34
+ // Custom (any shape): --json '<obj or array>'
35
+ // Primitive list is auto-detected when --values is given or --value is repeated.
36
+ // Custom mode is auto-detected from --json (object → scalar, array → list).
37
+ set.command('example')
38
+ .description('Set a field example value on a scenario entry (primitive or Custom)')
39
+ .requiredOption('--scenario <name>', 'Scenario name')
40
+ .requiredOption('--entry <entryId>', 'Entry ID (from show output)')
41
+ .requiredOption('--type <type>', 'Entry type: event, command, or readmodel')
42
+ .requiredOption('--field <name>', 'Field name')
43
+ .option('--value <val>', 'Primitive value (repeat for list-typed fields)', collectListValue, [])
44
+ .option('--values <csv>', 'Comma-separated values for a primitive list-typed field')
45
+ .option('--json <json>', 'JSON for a Custom-typed field (object for scalar, array of objects for list)')
46
+ .addHelpText('after', `
47
+ Pick the input flag based on the field's type and shape — discover both via:
48
+ show element <elementName>
49
+
50
+ Primitive scalar field:
51
+ --value "42"
52
+ Primitive list field (any of):
53
+ --value "a" --value "b"
54
+ --values "a,b,c"
55
+ Custom scalar field (object tree):
56
+ --json '{ "city": "NYC", "zip": "10001" }'
57
+ Custom list field (array of objects):
58
+ --json '[{"sku":"a","qty":"2"},{"sku":"b","qty":"1"}]'
59
+
60
+ Inside a Custom tree, primitive leaves MUST be JSON strings ("42", "true", ISO dates).
61
+ Nested Custom subfields nest as inner objects/arrays.
62
+
63
+ Tip: to set many fields / many entries at once, use 'add scenario' which takes
64
+ a single JSON spec covering the whole given/when/then.
65
+ `)
66
+ .action(async (opts) => {
67
+ const modelId = requireModelId();
68
+ const scenarioId = await resolveScenarioId(modelId, opts.scenario, getGlobalId());
69
+ const collected = opts.value;
70
+ const csvProvided = opts.values !== undefined;
71
+ const jsonProvided = opts.json !== undefined;
72
+ if (jsonProvided && (csvProvided || collected.length > 0)) {
73
+ throw new Error('Use either --json (Custom) or --value/--values (primitive), not both.');
74
+ }
75
+ if (!jsonProvided && !csvProvided && collected.length === 0) {
76
+ throw new Error('Provide --value (repeatable), --values <csv>, or --json <tree>.');
77
+ }
78
+ if (jsonProvided) {
79
+ let parsed;
80
+ try {
81
+ parsed = JSON.parse(opts.json);
82
+ }
83
+ catch (e) {
84
+ throw new Error(`--json must be valid JSON: ${e.message}`);
85
+ }
86
+ if (Array.isArray(parsed)) {
87
+ const fn = SET_FIELD_CUSTOM_LIST_VALUES_MAP[opts.type];
88
+ if (!fn)
89
+ throw new Error(`Cannot set Custom list examples on type: ${opts.type}. Use event, command, or readmodel.`);
90
+ for (const item of parsed) {
91
+ if (item === null || typeof item !== 'object' || Array.isArray(item)) {
92
+ throw new Error('--json array items must be objects (one per list entry).');
93
+ }
94
+ }
95
+ unwrap(await fn({
96
+ body: { modelId, scenarioId, entryId: opts.entry, fieldName: opts.field, items: parsed }
97
+ }));
98
+ console.log(`Set "${opts.field}" = ${parsed.length} Custom item(s).`);
99
+ }
100
+ else if (parsed !== null && typeof parsed === 'object') {
101
+ const fn = SET_FIELD_CUSTOM_VALUE_MAP[opts.type];
102
+ if (!fn)
103
+ throw new Error(`Cannot set Custom examples on type: ${opts.type}. Use event, command, or readmodel.`);
104
+ unwrap(await fn({
105
+ body: { modelId, scenarioId, entryId: opts.entry, fieldName: opts.field, value: parsed }
106
+ }));
107
+ console.log(`Set "${opts.field}" = Custom value.`);
108
+ }
109
+ else {
110
+ throw new Error('--json must be an object (Custom scalar) or array of objects (Custom list).');
111
+ }
112
+ return;
113
+ }
114
+ const isList = csvProvided || collected.length > 1;
115
+ if (isList) {
116
+ const fn = SET_FIELD_LIST_VALUES_MAP[opts.type];
117
+ if (!fn)
118
+ throw new Error(`Cannot set list examples on type: ${opts.type}. Use event, command, or readmodel.`);
119
+ const values = csvProvided
120
+ ? String(opts.values).split(',').map((s) => s.trim())
121
+ : collected;
122
+ unwrap(await fn({
123
+ body: { modelId, scenarioId, entryId: opts.entry, fieldName: opts.field, values }
124
+ }));
125
+ console.log(`Set "${opts.field}" = [${values.map((v) => `"${v}"`).join(', ')}].`);
126
+ }
127
+ else {
128
+ const fn = SET_FIELD_VALUE_MAP[opts.type];
129
+ if (!fn)
130
+ throw new Error(`Cannot set examples on type: ${opts.type}. Use event, command, or readmodel.`);
131
+ const value = collected[0];
132
+ unwrap(await fn({
133
+ body: { modelId, scenarioId, entryId: opts.entry, fieldName: opts.field, value: String(value) }
134
+ }));
135
+ console.log(`Set "${opts.field}" = "${value}".`);
136
+ }
137
+ });
138
+ // set description --scenario <name> --text <description>
139
+ set.command('description')
140
+ .description('Set a scenario description')
141
+ .requiredOption('--scenario <name>', 'Scenario name')
142
+ .requiredOption('--text <description>', 'Description text')
143
+ .action(async (opts) => {
144
+ const modelId = requireModelId();
145
+ const scenarioId = await resolveScenarioId(modelId, opts.scenario, getGlobalId());
146
+ unwrap(await sdk.redescribeScenario({
147
+ body: { modelId, scenarioId, description: opts.text }
148
+ }));
149
+ console.log(`Set description on scenario.`);
150
+ });
151
+ // reorder entry --scenario <name> --section given|when|then --entry <entryId> --position <n>
152
+ const REORDER_ENTRY_MAP = {
153
+ given: sdk.reorderScenarioGivenEntry,
154
+ when: sdk.reorderScenarioWhenEntry,
155
+ then: sdk.reorderScenarioThenEntry,
156
+ };
157
+ set.command('position')
158
+ .description('Reorder a scenario entry within its section')
159
+ .requiredOption('--scenario <name>', 'Scenario name')
160
+ .requiredOption('--section <section>', 'Section: given, when, or then')
161
+ .requiredOption('--entry <entryId>', 'Entry ID (from show output)')
162
+ .requiredOption('--position <n>', 'New position (0-based)', parseInt)
163
+ .action(async (opts) => {
164
+ const modelId = requireModelId();
165
+ const scenarioId = await resolveScenarioId(modelId, opts.scenario, getGlobalId());
166
+ const fn = REORDER_ENTRY_MAP[opts.section];
167
+ if (!fn)
168
+ throw new Error(`Unknown section: ${opts.section}. Use given, when, or then.`);
169
+ unwrap(await fn({
170
+ body: { modelId, scenarioId, entryId: opts.entry, position: opts.position }
171
+ }));
172
+ console.log(`Moved entry to position ${opts.position}.`);
173
+ });
174
+ // set aggregate-id [aggregateName] --field-name <name> --field-type <type>
175
+ set.command('aggregate-id [aggregateName]')
176
+ .description('Set the ID field on an aggregate')
177
+ .requiredOption('--field-name <name>', 'ID field name')
178
+ .option('--field-type <type>', 'ID field type', 'UUID')
179
+ .action(async (aggregateName, opts) => {
180
+ const modelId = requireModelId();
181
+ const aggregateId = await resolve(modelId, 'aggregate', aggregateName ?? '', getGlobalId());
182
+ unwrap(await sdk.setAggregateIdField({
183
+ body: { modelId, aggregateId, aggregateIdFieldName: opts.fieldName, aggregateIdFieldType: opts.fieldType }
184
+ }));
185
+ console.log(`Set aggregate ID field to "${opts.fieldName}: ${opts.fieldType}".`);
186
+ });
187
+ // set note-description [noteName] --text <description>
188
+ set.command('note-description [noteName]')
189
+ .description('Set a note description')
190
+ .requiredOption('--text <description>', 'Description text')
191
+ .action(async (noteName, opts) => {
192
+ const modelId = requireModelId();
193
+ const noteId = await resolve(modelId, 'note', noteName ?? '', getGlobalId());
194
+ unwrap(await sdk.redescribeNote({
195
+ body: { modelId, noteId, description: opts.text }
196
+ }));
197
+ console.log('Set note description.');
198
+ });
199
+ }
@@ -0,0 +1,259 @@
1
+ // Response shapes for show-* commands, pulled from the backend ReadModels.
2
+ // Attached to each command's --help so agents can consume without out-of-band docs.
3
+ const FIELD_VIEW = `FieldView:
4
+ {
5
+ "fieldId": "<uuid>",
6
+ "name": "customerId",
7
+ "fieldType": "UUID" | "String" | "Int" | "Long" | "Double"
8
+ | "Decimal" | "Boolean" | "Date" | "DateTime" | "Custom",
9
+ "isList": false,
10
+ "isOptional": false,
11
+ "isGenerated": false,
12
+ "isUserInput": false, // screens only
13
+ "subfields": [FieldView, ...] // non-empty only when fieldType = "Custom"
14
+ }`;
15
+ const MAPPING_VIEW = `MappingView:
16
+ { "sourceFieldName": "customerId", "targetFieldName": "customerId" }`;
17
+ const FLOW_VIEW = `FlowView:
18
+ {
19
+ "flowId": "<uuid>",
20
+ "flowType": "screen->command" | "command->event" | "event->readmodel"
21
+ | "readmodel->screen" | "readmodel->processor"
22
+ | "processor->command" | "command->external-event"
23
+ | "external-event->processor",
24
+ "sourceName": "OrderForm",
25
+ "sourceId": "<uuid>",
26
+ "targetName": "PlaceOrder",
27
+ "targetId": "<uuid>",
28
+ "direction": "forward" | "reverse",
29
+ "mappings": [MappingView, ...]
30
+ }`;
31
+ const SCENARIO_ENTRY_VIEW = `ScenarioEntryView:
32
+ {
33
+ "entryId": "<uuid>",
34
+ "entryType": "event" | "command" | "readmodel" | ...,
35
+ "elementName": "OrderPlaced",
36
+ "fieldValues": { "customerId": "abc-123", "tags": ["a", "b"], ... }
37
+ // string for scalar fields, array for fields marked isList=true
38
+ }`;
39
+ const SCENARIO_VIEW = `ScenarioView:
40
+ {
41
+ "scenarioId": "<uuid>",
42
+ "name": "happy path",
43
+ "description": "A customer places a valid order",
44
+ "given": [ScenarioEntryView, ...],
45
+ "when": [ScenarioEntryView, ...],
46
+ "then": [ScenarioEntryView, ...]
47
+ }`;
48
+ const ELEMENT_VIEW_IN_SLICE = `ElementView (as returned inside slices):
49
+ {
50
+ "elementId": "<uuid>",
51
+ "elementType": "screen" | "command" | "event" | "readmodel"
52
+ | "processor" | "external-event",
53
+ "name": "PlaceOrder",
54
+ "x": 0, "y": 0, "width": 0, "height": 0,
55
+ "fields": [FieldView, ...],
56
+ "linkedCopy": false, // true = visual proxy; real element lives elsewhere
57
+ "originalId": "<uuid>", // only when linkedCopy = true
58
+ "originalSlice": "Place Order" // only when linkedCopy = true
59
+ }`;
60
+ const SLICE_VIEW = `SliceView:
61
+ {
62
+ "sliceId": "<uuid>",
63
+ "name": "Place Order",
64
+ "status": "created" | "planned" | "in-progress" | "blocked" | "done",
65
+ "x": 0, "y": 0, "width": 0, "height": 0,
66
+ "aggregate": { "aggregateId": "<uuid>", "name": "Order" } | null,
67
+ "elements": [ElementView, ...],
68
+ "flows": [FlowView, ...],
69
+ "scenarios": [ScenarioView, ...]
70
+ }`;
71
+ const CHAPTER_VIEW = `ChapterView:
72
+ {
73
+ "chapterId": "<uuid>",
74
+ "name": "User Onboarding",
75
+ "x": 0, "y": 0, "width": 0, "height": 0,
76
+ "chapters": [ChapterView, ...], // nested chapters
77
+ "slices": [SliceView, ...],
78
+ "uncontained": [ElementView, ...] // elements in the chapter but outside any slice
79
+ }`;
80
+ const CONTEXT_VIEW = `ContextView:
81
+ {
82
+ "contextId": "<uuid>",
83
+ "name": "Orders",
84
+ "x": 0, "y": 0, "width": 0, "height": 0,
85
+ "chapters": [ChapterView, ...],
86
+ "slices": [SliceView, ...],
87
+ "uncontained": [ElementView, ...]
88
+ }`;
89
+ // show slice → SliceView (with nested ElementView/FlowView/ScenarioView)
90
+ export const SHOW_SLICE_HELP = `
91
+ Response (JSON on stdout):
92
+
93
+ ${SLICE_VIEW}
94
+
95
+ ${ELEMENT_VIEW_IN_SLICE}
96
+
97
+ ${FIELD_VIEW}
98
+
99
+ ${FLOW_VIEW}
100
+
101
+ ${MAPPING_VIEW}
102
+
103
+ ${SCENARIO_VIEW}
104
+
105
+ ${SCENARIO_ENTRY_VIEW}
106
+ `;
107
+ // show chapter → ChapterView
108
+ export const SHOW_CHAPTER_HELP = `
109
+ Response (JSON on stdout):
110
+
111
+ ${CHAPTER_VIEW}
112
+
113
+ ${SLICE_VIEW}
114
+
115
+ ${ELEMENT_VIEW_IN_SLICE}
116
+
117
+ ${FIELD_VIEW}
118
+
119
+ ${FLOW_VIEW}
120
+
121
+ ${MAPPING_VIEW}
122
+
123
+ ${SCENARIO_VIEW}
124
+
125
+ ${SCENARIO_ENTRY_VIEW}
126
+ `;
127
+ // show context → ContextView
128
+ export const SHOW_CONTEXT_HELP = `
129
+ Response (JSON on stdout):
130
+
131
+ ${CONTEXT_VIEW}
132
+
133
+ ${CHAPTER_VIEW}
134
+
135
+ ${SLICE_VIEW}
136
+
137
+ ${ELEMENT_VIEW_IN_SLICE}
138
+
139
+ ${FIELD_VIEW}
140
+
141
+ ${FLOW_VIEW}
142
+
143
+ ${MAPPING_VIEW}
144
+
145
+ ${SCENARIO_VIEW}
146
+
147
+ ${SCENARIO_ENTRY_VIEW}
148
+ `;
149
+ // show model → ModelView
150
+ export const SHOW_MODEL_HELP = `
151
+ Response (JSON on stdout):
152
+
153
+ ModelView:
154
+ {
155
+ "modelId": "<uuid>",
156
+ "modelName": "My Model",
157
+ "contexts": [ContextView, ...],
158
+ "chapters": [ChapterView, ...], // chapters not inside any context
159
+ "slices": [SliceView, ...], // slices not inside any chapter
160
+ "uncontained": [ElementView, ...] // elements outside every container
161
+ }
162
+
163
+ ${CONTEXT_VIEW}
164
+
165
+ ${CHAPTER_VIEW}
166
+
167
+ ${SLICE_VIEW}
168
+
169
+ ${ELEMENT_VIEW_IN_SLICE}
170
+
171
+ ${FIELD_VIEW}
172
+
173
+ ${FLOW_VIEW}
174
+
175
+ ${MAPPING_VIEW}
176
+
177
+ ${SCENARIO_VIEW}
178
+
179
+ ${SCENARIO_ENTRY_VIEW}
180
+ `;
181
+ // show <element> → richer element response with cross-slice context
182
+ export const SHOW_ELEMENT_HELP = `
183
+ Response (JSON on stdout):
184
+
185
+ ShowElementView:
186
+ {
187
+ "elementId": "<uuid>",
188
+ "elementType": "screen" | "command" | "event" | "readmodel"
189
+ | "processor" | "external-event",
190
+ "name": "OrderPlaced",
191
+ "x": 0, "y": 0, "width": 0, "height": 0,
192
+ "fields": [FieldEntry, ...],
193
+ "linkedCopy": false,
194
+ "originalId": "<uuid>", // only when linkedCopy = true
195
+ "copies": [CopyEntry, ...], // all visual proxies of this element
196
+ "appearsInSlices": [SliceEntry, ...], // slices this element belongs to
197
+ "inboundFlows": [FlowEntry, ...], // flows pointing at this element
198
+ "outboundFlows": [FlowEntry, ...] // flows leaving this element
199
+ }
200
+
201
+ FieldEntry:
202
+ {
203
+ "fieldId": "<uuid>",
204
+ "name": "customerId",
205
+ "fieldType": "UUID" | "String" | "Int" | "Long" | "Double"
206
+ | "Decimal" | "Boolean" | "Date" | "DateTime" | "Custom",
207
+ "isList": false,
208
+ "isOptional": false,
209
+ "isGenerated": false,
210
+ "isUserInput": false,
211
+ "subfields": [FieldEntry, ...]
212
+ }
213
+
214
+ CopyEntry:
215
+ {
216
+ "copyId": "<uuid>",
217
+ "x": 0, "y": 0,
218
+ "sliceName": "Place Order" | null
219
+ }
220
+
221
+ SliceEntry:
222
+ { "sliceId": "<uuid>", "sliceName": "Place Order" }
223
+
224
+ FlowEntry:
225
+ {
226
+ "flowId": "<uuid>",
227
+ "flowType": "screen->command" | "command->event" | ...,
228
+ "sourceName": "OrderForm",
229
+ "sourceId": "<uuid>",
230
+ "targetName": "PlaceOrder",
231
+ "targetId": "<uuid>",
232
+ "mappings": [{ "sourceFieldName": "customerId", "targetFieldName": "customerId" }, ...]
233
+ }
234
+ `;
235
+ // show completeness → model-level coverage report
236
+ export const SHOW_COMPLETENESS_HELP = `
237
+ Response (JSON on stdout):
238
+
239
+ CompletenessReport:
240
+ {
241
+ "modelId": "<uuid>",
242
+ "complete": 0, // count of fields with full traceability
243
+ "incomplete": 0, // count of fields missing mappings
244
+ "total": 0,
245
+ "incompleteElements": [IncompleteElement, ...]
246
+ }
247
+
248
+ IncompleteElement:
249
+ {
250
+ "elementId": "<uuid>",
251
+ "elementName": "PlaceOrder",
252
+ "elementType": "command" | "event" | "readmodel" | "screen" | "processor" | "external-event",
253
+ "unmappedFields": ["fieldName", ...],
254
+ "missingAggregateIdField": {
255
+ "aggregateName": "Order",
256
+ "expectedField": "orderId"
257
+ } | null
258
+ }
259
+ `;
@@ -0,0 +1,56 @@
1
+ import { getGlobalId } from '../lib/globals';
2
+ import { requireModelId } from '../lib/model';
3
+ import { resolve, unwrap, out } from '../lib/resolve';
4
+ import * as sdk from '../api/generated/sdk.gen';
5
+ import { SHOW_MODEL_HELP, SHOW_CONTEXT_HELP, SHOW_CHAPTER_HELP, SHOW_SLICE_HELP, SHOW_ELEMENT_HELP, SHOW_COMPLETENESS_HELP, } from './show-schemas';
6
+ export function registerShowCommands(program) {
7
+ const show = program.command('show').description('Show detailed information');
8
+ show.command('model')
9
+ .description('Show full model hierarchy')
10
+ .addHelpText('after', SHOW_MODEL_HELP)
11
+ .action(async () => {
12
+ const modelId = requireModelId();
13
+ out(unwrap(await sdk.showModel({ path: { modelId } })));
14
+ });
15
+ show.command('context [name]')
16
+ .description('Show context with contained chapters and slices')
17
+ .addHelpText('after', SHOW_CONTEXT_HELP)
18
+ .action(async (name, cmd) => {
19
+ const modelId = requireModelId();
20
+ const contextId = await resolve(modelId, 'context', name ?? '', getGlobalId());
21
+ out(unwrap(await sdk.showContext({ path: { modelId, contextId } })));
22
+ });
23
+ show.command('chapter [name]')
24
+ .description('Show chapter with contained slices')
25
+ .addHelpText('after', SHOW_CHAPTER_HELP)
26
+ .action(async (name, cmd) => {
27
+ const modelId = requireModelId();
28
+ const chapterId = await resolve(modelId, 'chapter', name ?? '', getGlobalId());
29
+ out(unwrap(await sdk.showChapter({ path: { modelId, chapterId } })));
30
+ });
31
+ show.command('slice [name]')
32
+ .description('Show slice with all elements, flows, and scenarios')
33
+ .addHelpText('after', SHOW_SLICE_HELP)
34
+ .action(async (name, cmd) => {
35
+ const modelId = requireModelId();
36
+ const sliceId = await resolve(modelId, 'slice', name ?? '', getGlobalId());
37
+ out(unwrap(await sdk.showSlice({ path: { modelId, sliceId } })));
38
+ });
39
+ for (const type of ['event', 'command', 'readmodel', 'screen', 'processor', 'external-event']) {
40
+ show.command(`${type} [name]`)
41
+ .description(`Show ${type} detail with fields and flows`)
42
+ .addHelpText('after', SHOW_ELEMENT_HELP)
43
+ .action(async (name, cmd) => {
44
+ const modelId = requireModelId();
45
+ const elementId = await resolve(modelId, type, name ?? '', getGlobalId());
46
+ out(unwrap(await sdk.showElement({ path: { modelId, elementId } })));
47
+ });
48
+ }
49
+ show.command('completeness')
50
+ .description('Show completeness for the entire model')
51
+ .addHelpText('after', SHOW_COMPLETENESS_HELP)
52
+ .action(async () => {
53
+ const modelId = requireModelId();
54
+ out(unwrap(await sdk.showCompleteness({ path: { modelId } })));
55
+ });
56
+ }
@@ -0,0 +1,13 @@
1
+ import { requireModelId } from '../lib/model';
2
+ import { unwrap, out } from '../lib/resolve';
3
+ import * as sdk from '../api/generated/sdk.gen';
4
+ import { SUMMARY_HELP } from './list-schemas';
5
+ export function registerSummaryCommands(program) {
6
+ program.command('summary')
7
+ .description('Show model summary')
8
+ .addHelpText('after', SUMMARY_HELP)
9
+ .action(async () => {
10
+ const modelId = requireModelId();
11
+ out(unwrap(await sdk.summary({ path: { modelId } })));
12
+ });
13
+ }