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,71 +0,0 @@
1
- // Check if two chapters have X-overlap
2
- function hasXOverlap(parent, child) {
3
- const parentLeft = parent.position.x;
4
- const parentRight = parent.position.x + parent.size.width;
5
- const childLeft = child.position.x;
6
- const childRight = child.position.x + child.size.width;
7
- return childLeft < parentRight && childRight > parentLeft;
8
- }
9
- // Find the immediate parent of a chapter (nearest chapter above with X-overlap)
10
- export function findParentChapter(model, chapter) {
11
- let bestParent = null;
12
- let bestParentY = -Infinity;
13
- for (const candidate of model.chapters.values()) {
14
- if (candidate.id === chapter.id)
15
- continue;
16
- // Parent must be above (lower y value)
17
- if (candidate.position.y >= chapter.position.y)
18
- continue;
19
- // Must have X-overlap
20
- if (!hasXOverlap(candidate, chapter))
21
- continue;
22
- // Take the closest parent (highest y value that's still above)
23
- if (candidate.position.y > bestParentY) {
24
- bestParent = candidate;
25
- bestParentY = candidate.position.y;
26
- }
27
- }
28
- return bestParent;
29
- }
30
- // Build full hierarchy for a chapter (from root to this chapter)
31
- export function getChapterHierarchy(model, chapter) {
32
- const parent = findParentChapter(model, chapter);
33
- const result = {
34
- id: chapter.id,
35
- name: chapter.name,
36
- };
37
- if (parent) {
38
- result.parent = getChapterHierarchy(model, parent);
39
- }
40
- return result;
41
- }
42
- // Convert hierarchy to array (root first)
43
- export function hierarchyToArray(hierarchy) {
44
- const result = [];
45
- function collect(h) {
46
- if (h.parent)
47
- collect(h.parent);
48
- result.push({ id: h.id, name: h.name });
49
- }
50
- collect(hierarchy);
51
- return result;
52
- }
53
- // Find which chapter contains a slice (based on horizontal center)
54
- // Returns the deepest (highest y-value) chapter that contains the slice
55
- export function findChapterForSlice(model, slice) {
56
- const sliceCenterX = slice.position.x + slice.size.width / 2;
57
- let bestChapter = null;
58
- let bestY = -Infinity;
59
- for (const chapter of model.chapters.values()) {
60
- const chapterLeft = chapter.position.x;
61
- const chapterRight = chapter.position.x + chapter.size.width;
62
- if (sliceCenterX >= chapterLeft && sliceCenterX <= chapterRight) {
63
- // Take the deepest (highest y) chapter
64
- if (chapter.position.y > bestY) {
65
- bestChapter = chapter;
66
- bestY = chapter.position.y;
67
- }
68
- }
69
- }
70
- return bestChapter;
71
- }
@@ -1,69 +0,0 @@
1
- import type { RawEvent } from '../types.js';
2
- export interface ImportResult {
3
- success: boolean;
4
- modelId: string;
5
- eventCount: number;
6
- }
7
- export interface CloudClient {
8
- listModels(): Promise<CloudModelInfo[]>;
9
- dispatch(modelId: string, command: unknown): Promise<{
10
- success: boolean;
11
- events: unknown[];
12
- }>;
13
- importModel(modelId: string, modelName: string, events: RawEvent[]): Promise<ImportResult>;
14
- addField(modelId: string, elementType: string, elementName: string, field: Record<string, unknown>): Promise<{
15
- success: boolean;
16
- }>;
17
- removeField(modelId: string, elementType: string, elementName: string, fieldName: string): Promise<{
18
- success: boolean;
19
- }>;
20
- updateField(modelId: string, elementType: string, elementName: string, fieldName: string, updates: Record<string, unknown>): Promise<{
21
- success: boolean;
22
- }>;
23
- createStateChangeSlice(modelId: string, sliceName: string, after: string, before: string, screen: any, command: any, event: any): Promise<{
24
- sliceId: string;
25
- screenId: string;
26
- commandId: string;
27
- eventId: string;
28
- }>;
29
- createStateViewSlice(modelId: string, sliceName: string, after: string, before: string, readModel: any): Promise<{
30
- sliceId: string;
31
- readModelId: string;
32
- }>;
33
- createAutomationSlice(modelId: string, sliceName: string, after: string, before: string, readModel: any, processor: any, command: any, event: any): Promise<{
34
- sliceId: string;
35
- readModelId: string;
36
- processorId: string;
37
- commandId: string;
38
- eventId: string;
39
- }>;
40
- createFlow(modelId: string, fromName: string, toName: string): Promise<{
41
- flowId: string;
42
- }>;
43
- markSliceStatus(modelId: string, sliceName: string, status: string): Promise<{
44
- success: boolean;
45
- }>;
46
- createScenario(modelId: string, sliceName: string, scenario: {
47
- name: string;
48
- }): Promise<{
49
- scenarioId: string;
50
- }>;
51
- removeScenario(modelId: string, scenarioName: string, sliceName?: string): Promise<{
52
- success: boolean;
53
- }>;
54
- mapFields(modelId: string, sourceName: string, targetName: string, mappings: Array<{
55
- from: string;
56
- to: string;
57
- }>): Promise<{
58
- success: boolean;
59
- }>;
60
- }
61
- export interface CloudModelInfo {
62
- modelId: string;
63
- name: string;
64
- updatedAt?: string;
65
- }
66
- /**
67
- * Create a cloud client for interacting with the Axon backend.
68
- */
69
- export declare function createCloudClient(): Promise<CloudClient>;
@@ -1,364 +0,0 @@
1
- import { getBackendUrl } from './config.js';
2
- import { getValidAccessToken } from './auth.js';
3
- /**
4
- * Handle HTTP error responses with user-friendly messages
5
- */
6
- async function handleHttpError(response) {
7
- const text = await response.text().catch(() => '');
8
- const errorDetail = extractErrorDetail(text);
9
- switch (response.status) {
10
- case 401:
11
- throw new Error(`Authentication required. Run 'eventmodeler login' to authenticate.` +
12
- (errorDetail ? `\n\nOriginal error: ${errorDetail}` : ''));
13
- case 403:
14
- throw new Error(`Permission denied. You may not have access to this model, or you need editor permission for this action.` +
15
- (errorDetail ? `\n\nOriginal error: ${errorDetail}` : ''));
16
- case 404:
17
- throw new Error(errorDetail || `Not found`);
18
- default:
19
- throw new Error(errorDetail || `HTTP ${response.status}: ${response.statusText}`);
20
- }
21
- }
22
- const GENERIC_ERROR_MESSAGES = new Set([
23
- 'internal server error',
24
- 'bad request',
25
- 'unauthorized',
26
- 'forbidden',
27
- 'not found',
28
- ]);
29
- function isGenericErrorMessage(value) {
30
- return GENERIC_ERROR_MESSAGES.has(value.trim().toLowerCase());
31
- }
32
- function toStringValue(value) {
33
- return typeof value === 'string' ? value.trim() : '';
34
- }
35
- function collectCandidateMessages(node, out) {
36
- if (!node || typeof node !== 'object')
37
- return;
38
- const obj = node;
39
- // Prefer specific fields before generic "error".
40
- for (const key of ['message', 'detail', 'reason', 'description', 'title', 'error']) {
41
- const value = toStringValue(obj[key]);
42
- if (value)
43
- out.push(value);
44
- }
45
- const errors = obj.errors;
46
- if (Array.isArray(errors)) {
47
- for (const entry of errors) {
48
- if (typeof entry === 'string') {
49
- const value = entry.trim();
50
- if (value)
51
- out.push(value);
52
- }
53
- else if (entry && typeof entry === 'object') {
54
- collectCandidateMessages(entry, out);
55
- }
56
- }
57
- }
58
- const cause = obj.cause;
59
- if (cause && typeof cause === 'object') {
60
- collectCandidateMessages(cause, out);
61
- }
62
- }
63
- function extractErrorDetail(text) {
64
- const body = text.trim();
65
- if (!body)
66
- return '';
67
- try {
68
- const parsed = JSON.parse(body);
69
- if (typeof parsed === 'string') {
70
- return parsed.trim();
71
- }
72
- const candidates = [];
73
- collectCandidateMessages(parsed, candidates);
74
- if (candidates.length > 0) {
75
- const specific = candidates.find((value) => !isGenericErrorMessage(value));
76
- return specific ?? candidates[0];
77
- }
78
- }
79
- catch {
80
- // Not JSON. Fall back to plain text below.
81
- }
82
- // Avoid dumping full HTML error pages.
83
- if (body.startsWith('<')) {
84
- const title = body.match(/<title>([^<]+)<\/title>/i)?.[1]?.trim();
85
- return title && !isGenericErrorMessage(title) ? title : '';
86
- }
87
- return body;
88
- }
89
- /**
90
- * Create a cloud client for interacting with the Axon backend.
91
- */
92
- export async function createCloudClient() {
93
- const accessToken = await getValidAccessToken();
94
- return {
95
- async listModels() {
96
- const siteUrl = getBackendUrl();
97
- const response = await fetch(`${siteUrl}/cli/list-models`, {
98
- method: 'GET',
99
- headers: {
100
- 'Content-Type': 'application/json',
101
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
102
- },
103
- });
104
- if (!response.ok) {
105
- await handleHttpError(response);
106
- }
107
- const models = await response.json();
108
- if (!Array.isArray(models)) {
109
- return [];
110
- }
111
- return models;
112
- },
113
- async dispatch(modelId, command) {
114
- const siteUrl = getBackendUrl();
115
- const commandType = command.type;
116
- if (!commandType) {
117
- throw new Error('Command must have a type property');
118
- }
119
- // Map command type to slice endpoint name
120
- const sliceName = commandType.charAt(0).toLowerCase() + commandType.slice(1);
121
- const response = await fetch(`${siteUrl}/slices/${sliceName}`, {
122
- method: 'POST',
123
- headers: {
124
- 'Content-Type': 'application/json',
125
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
126
- },
127
- body: JSON.stringify({ modelId, command }),
128
- });
129
- if (!response.ok) {
130
- await handleHttpError(response);
131
- }
132
- const result = await response.json();
133
- return result;
134
- },
135
- async importModel(modelId, modelName, events) {
136
- const siteUrl = getBackendUrl();
137
- const response = await fetch(`${siteUrl}/cli/import-model`, {
138
- method: 'POST',
139
- headers: {
140
- 'Content-Type': 'application/json',
141
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
142
- },
143
- body: JSON.stringify({
144
- modelId,
145
- modelName,
146
- events,
147
- }),
148
- });
149
- if (!response.ok) {
150
- await handleHttpError(response);
151
- }
152
- return response.json();
153
- },
154
- async addField(modelId, elementType, elementName, field) {
155
- const siteUrl = getBackendUrl();
156
- const response = await fetch(`${siteUrl}/cli/add-field`, {
157
- method: 'POST',
158
- headers: {
159
- 'Content-Type': 'application/json',
160
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
161
- },
162
- body: JSON.stringify({ modelId, elementType, elementName, field }),
163
- });
164
- if (!response.ok) {
165
- await handleHttpError(response);
166
- }
167
- return response.json();
168
- },
169
- async removeField(modelId, elementType, elementName, fieldName) {
170
- const siteUrl = getBackendUrl();
171
- const response = await fetch(`${siteUrl}/cli/remove-field`, {
172
- method: 'POST',
173
- headers: {
174
- 'Content-Type': 'application/json',
175
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
176
- },
177
- body: JSON.stringify({ modelId, elementType, elementName, fieldName }),
178
- });
179
- if (!response.ok) {
180
- await handleHttpError(response);
181
- }
182
- return response.json();
183
- },
184
- async updateField(modelId, elementType, elementName, fieldName, updates) {
185
- const siteUrl = getBackendUrl();
186
- const response = await fetch(`${siteUrl}/cli/update-field`, {
187
- method: 'POST',
188
- headers: {
189
- 'Content-Type': 'application/json',
190
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
191
- },
192
- body: JSON.stringify({ modelId, elementType, elementName, fieldName, updates }),
193
- });
194
- if (!response.ok) {
195
- await handleHttpError(response);
196
- }
197
- return response.json();
198
- },
199
- async createStateChangeSlice(modelId, sliceName, after, before, screen, command, event) {
200
- const siteUrl = getBackendUrl();
201
- const response = await fetch(`${siteUrl}/cli/create-state-change-slice`, {
202
- method: 'POST',
203
- headers: {
204
- 'Content-Type': 'application/json',
205
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
206
- },
207
- body: JSON.stringify({
208
- modelId,
209
- sliceName,
210
- after,
211
- before,
212
- screen,
213
- command,
214
- event,
215
- }),
216
- });
217
- if (!response.ok) {
218
- await handleHttpError(response);
219
- }
220
- return response.json();
221
- },
222
- async createStateViewSlice(modelId, sliceName, after, before, readModel) {
223
- const siteUrl = getBackendUrl();
224
- const response = await fetch(`${siteUrl}/cli/create-state-view-slice`, {
225
- method: 'POST',
226
- headers: {
227
- 'Content-Type': 'application/json',
228
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
229
- },
230
- body: JSON.stringify({
231
- modelId,
232
- sliceName,
233
- after,
234
- before,
235
- readModel,
236
- }),
237
- });
238
- if (!response.ok) {
239
- await handleHttpError(response);
240
- }
241
- return response.json();
242
- },
243
- async createAutomationSlice(modelId, sliceName, after, before, readModel, processor, command, event) {
244
- const siteUrl = getBackendUrl();
245
- const response = await fetch(`${siteUrl}/cli/create-automation-slice`, {
246
- method: 'POST',
247
- headers: {
248
- 'Content-Type': 'application/json',
249
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
250
- },
251
- body: JSON.stringify({
252
- modelId,
253
- sliceName,
254
- after,
255
- before,
256
- readModel,
257
- processor,
258
- command,
259
- event,
260
- }),
261
- });
262
- if (!response.ok) {
263
- await handleHttpError(response);
264
- }
265
- return response.json();
266
- },
267
- async createFlow(modelId, fromName, toName) {
268
- const siteUrl = getBackendUrl();
269
- const response = await fetch(`${siteUrl}/cli/create-flow`, {
270
- method: 'POST',
271
- headers: {
272
- 'Content-Type': 'application/json',
273
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
274
- },
275
- body: JSON.stringify({
276
- modelId,
277
- fromName,
278
- toName,
279
- }),
280
- });
281
- if (!response.ok) {
282
- await handleHttpError(response);
283
- }
284
- return response.json();
285
- },
286
- async markSliceStatus(modelId, sliceName, status) {
287
- const siteUrl = getBackendUrl();
288
- const response = await fetch(`${siteUrl}/cli/mark-slice-status`, {
289
- method: 'POST',
290
- headers: {
291
- 'Content-Type': 'application/json',
292
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
293
- },
294
- body: JSON.stringify({
295
- modelId,
296
- sliceName,
297
- status,
298
- }),
299
- });
300
- if (!response.ok) {
301
- await handleHttpError(response);
302
- }
303
- return response.json();
304
- },
305
- async createScenario(modelId, sliceName, scenario) {
306
- const siteUrl = getBackendUrl();
307
- const response = await fetch(`${siteUrl}/cli/create-scenario`, {
308
- method: 'POST',
309
- headers: {
310
- 'Content-Type': 'application/json',
311
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
312
- },
313
- body: JSON.stringify({
314
- modelId,
315
- sliceName,
316
- scenario,
317
- }),
318
- });
319
- if (!response.ok) {
320
- await handleHttpError(response);
321
- }
322
- return response.json();
323
- },
324
- async removeScenario(modelId, scenarioName, sliceName) {
325
- const siteUrl = getBackendUrl();
326
- const response = await fetch(`${siteUrl}/cli/remove-scenario`, {
327
- method: 'POST',
328
- headers: {
329
- 'Content-Type': 'application/json',
330
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
331
- },
332
- body: JSON.stringify({
333
- modelId,
334
- scenarioName,
335
- sliceName,
336
- }),
337
- });
338
- if (!response.ok) {
339
- await handleHttpError(response);
340
- }
341
- return response.json();
342
- },
343
- async mapFields(modelId, sourceName, targetName, mappings) {
344
- const siteUrl = getBackendUrl();
345
- const response = await fetch(`${siteUrl}/cli/map-fields`, {
346
- method: 'POST',
347
- headers: {
348
- 'Content-Type': 'application/json',
349
- ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
350
- },
351
- body: JSON.stringify({
352
- modelId,
353
- sourceName,
354
- targetName,
355
- mappings,
356
- }),
357
- });
358
- if (!response.ok) {
359
- await handleHttpError(response);
360
- }
361
- return response.json();
362
- },
363
- };
364
- }
@@ -1,30 +0,0 @@
1
- type OutputFormat = 'xml' | 'json';
2
- export interface AuthTokens {
3
- accessToken: string;
4
- refreshToken: string;
5
- expiresAt: number;
6
- userId: string;
7
- email: string;
8
- }
9
- export interface GlobalConfig {
10
- format?: OutputFormat;
11
- auth?: AuthTokens;
12
- backendUrl?: string;
13
- keycloakUrl?: string;
14
- development?: boolean;
15
- }
16
- export declare function getConfigDir(): string;
17
- export declare function getConfigPath(): string;
18
- export declare function ensureConfigDir(): void;
19
- export declare function loadGlobalConfig(): GlobalConfig;
20
- export declare function saveGlobalConfig(config: GlobalConfig): void;
21
- export declare function getAuthTokens(): AuthTokens | null;
22
- export declare function saveAuthTokens(tokens: AuthTokens): void;
23
- export declare function clearAuthTokens(): void;
24
- export declare function isAuthenticated(): boolean;
25
- export declare function getBackendUrl(): string;
26
- export declare function setBackendUrl(url: string): void;
27
- export declare function getKeycloakUrl(): string;
28
- export declare function setKeycloakUrl(url: string): void;
29
- export declare function getDefaultFormat(): OutputFormat;
30
- export {};
@@ -1,45 +0,0 @@
1
- /**
2
- * Merge rules for Event Model conflicts.
3
- *
4
- * Based on analysis of user workflows, these rules define how to handle
5
- * different types of conflicts when merging two branches.
6
- */
7
- import type { EntityChange, FieldChange } from './types.js';
8
- export type ConflictResolution = {
9
- type: 'auto';
10
- action: string;
11
- } | {
12
- type: 'soft';
13
- reason: string;
14
- } | {
15
- type: 'hard';
16
- reason: string;
17
- };
18
- /**
19
- * Determine how to resolve a property conflict.
20
- */
21
- export declare function resolvePropertyConflict(property: string, oursValue: unknown, theirsValue: unknown, entityType: string): ConflictResolution;
22
- /**
23
- * Determine how to resolve a field conflict.
24
- */
25
- export declare function resolveFieldConflict(oursChange: FieldChange, theirsChange: FieldChange): ConflictResolution;
26
- /**
27
- * Merge two arrays (e.g., nodeIds) removing duplicates.
28
- */
29
- export declare function mergeArrays<T>(base: T[], ours: T[], theirs: T[]): T[];
30
- /**
31
- * Check if an entity change affects only layout properties.
32
- */
33
- export declare function isLayoutOnlyChange(change: EntityChange): boolean;
34
- /**
35
- * Categorize fields changes for merge.
36
- */
37
- export declare function categorizeFieldChanges(oursChanges: FieldChange[], theirsChanges: FieldChange[]): {
38
- oursOnly: FieldChange[];
39
- theirsOnly: FieldChange[];
40
- conflicts: Array<{
41
- ours: FieldChange;
42
- theirs: FieldChange;
43
- resolution: ConflictResolution;
44
- }>;
45
- };