eventmodeler 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6776 -2132
- package/package.json +11 -5
- package/dist/api/index.d.ts +0 -285
- package/dist/api/index.js +0 -323
- package/dist/cloud/slices/index.d.ts +0 -276
- package/dist/cloud/slices/index.js +0 -406
- package/dist/eventmodeler.js +0 -5646
- package/dist/formatters.d.ts +0 -17
- package/dist/formatters.js +0 -482
- package/dist/index.d.ts +0 -2
- package/dist/lib/auth.d.ts +0 -24
- package/dist/lib/auth.js +0 -331
- package/dist/lib/backend.d.ts +0 -43
- package/dist/lib/backend.js +0 -73
- package/dist/lib/chapter-utils.d.ts +0 -13
- package/dist/lib/chapter-utils.js +0 -71
- package/dist/lib/cloud-client.d.ts +0 -69
- package/dist/lib/cloud-client.js +0 -364
- package/dist/lib/config.d.ts +0 -30
- package/dist/lib/config.js +0 -95
- package/dist/lib/diff/merge-rules.d.ts +0 -45
- package/dist/lib/diff/merge-rules.js +0 -210
- package/dist/lib/diff/model-differ.d.ts +0 -8
- package/dist/lib/diff/model-differ.js +0 -568
- package/dist/lib/diff/three-way-merge.d.ts +0 -7
- package/dist/lib/diff/three-way-merge.js +0 -390
- package/dist/lib/diff/types.d.ts +0 -75
- package/dist/lib/diff/types.js +0 -1
- package/dist/lib/element-lookup.d.ts +0 -58
- package/dist/lib/element-lookup.js +0 -126
- package/dist/lib/file-loader.d.ts +0 -8
- package/dist/lib/file-loader.js +0 -108
- package/dist/lib/flow-utils.d.ts +0 -53
- package/dist/lib/flow-utils.js +0 -348
- package/dist/lib/format.d.ts +0 -10
- package/dist/lib/format.js +0 -23
- package/dist/lib/project-config.d.ts +0 -27
- package/dist/lib/project-config.js +0 -83
- package/dist/lib/slice-utils.d.ts +0 -59
- package/dist/lib/slice-utils.js +0 -140
- package/dist/local/slices/index.d.ts +0 -11
- package/dist/local/slices/index.js +0 -13
- package/dist/projection.d.ts +0 -3
- package/dist/projection.js +0 -828
- package/dist/slices/add-field/index.d.ts +0 -8
- package/dist/slices/add-field/index.js +0 -211
- package/dist/slices/add-scenario/index.d.ts +0 -27
- package/dist/slices/add-scenario/index.js +0 -307
- package/dist/slices/codegen-chapter-events/index.d.ts +0 -2
- package/dist/slices/codegen-chapter-events/index.js +0 -145
- package/dist/slices/codegen-slice/index.d.ts +0 -2
- package/dist/slices/codegen-slice/index.js +0 -448
- package/dist/slices/create-automation-slice/index.d.ts +0 -2
- package/dist/slices/create-automation-slice/index.js +0 -304
- package/dist/slices/create-flow/index.d.ts +0 -2
- package/dist/slices/create-flow/index.js +0 -183
- package/dist/slices/create-state-change-slice/index.d.ts +0 -2
- package/dist/slices/create-state-change-slice/index.js +0 -263
- package/dist/slices/create-state-view-slice/index.d.ts +0 -2
- package/dist/slices/create-state-view-slice/index.js +0 -128
- package/dist/slices/diff/index.d.ts +0 -11
- package/dist/slices/diff/index.js +0 -293
- package/dist/slices/export-eventmodel-to-json/index.d.ts +0 -2
- package/dist/slices/export-eventmodel-to-json/index.js +0 -355
- package/dist/slices/git/index.d.ts +0 -2
- package/dist/slices/git/index.js +0 -125
- package/dist/slices/guide/guides/codegen.d.ts +0 -5
- package/dist/slices/guide/guides/codegen.js +0 -339
- package/dist/slices/guide/guides/connect-slices.d.ts +0 -5
- package/dist/slices/guide/guides/connect-slices.js +0 -202
- package/dist/slices/guide/guides/create-slices.d.ts +0 -5
- package/dist/slices/guide/guides/create-slices.js +0 -303
- package/dist/slices/guide/guides/explore.d.ts +0 -5
- package/dist/slices/guide/guides/explore.js +0 -251
- package/dist/slices/guide/guides/information-flow.d.ts +0 -5
- package/dist/slices/guide/guides/information-flow.js +0 -318
- package/dist/slices/guide/guides/scenarios.d.ts +0 -5
- package/dist/slices/guide/guides/scenarios.js +0 -269
- package/dist/slices/guide/index.d.ts +0 -1
- package/dist/slices/guide/index.js +0 -40
- package/dist/slices/import/index.d.ts +0 -8
- package/dist/slices/import/index.js +0 -63
- package/dist/slices/init/index.d.ts +0 -5
- package/dist/slices/init/index.js +0 -80
- package/dist/slices/list-chapters/index.d.ts +0 -3
- package/dist/slices/list-chapters/index.js +0 -21
- package/dist/slices/list-commands/index.d.ts +0 -3
- package/dist/slices/list-commands/index.js +0 -20
- package/dist/slices/list-events/index.d.ts +0 -3
- package/dist/slices/list-events/index.js +0 -98
- package/dist/slices/list-processors/index.d.ts +0 -3
- package/dist/slices/list-processors/index.js +0 -20
- package/dist/slices/list-readmodels/index.d.ts +0 -3
- package/dist/slices/list-readmodels/index.js +0 -21
- package/dist/slices/list-scenarios/index.d.ts +0 -3
- package/dist/slices/list-scenarios/index.js +0 -35
- package/dist/slices/list-screens/index.d.ts +0 -3
- package/dist/slices/list-screens/index.js +0 -47
- package/dist/slices/list-slices/index.d.ts +0 -3
- package/dist/slices/list-slices/index.js +0 -35
- package/dist/slices/login/index.d.ts +0 -1
- package/dist/slices/login/index.js +0 -20
- package/dist/slices/logout/index.d.ts +0 -1
- package/dist/slices/logout/index.js +0 -14
- package/dist/slices/map-fields/index.d.ts +0 -2
- package/dist/slices/map-fields/index.js +0 -269
- package/dist/slices/mark-slice-status/index.d.ts +0 -2
- package/dist/slices/mark-slice-status/index.js +0 -31
- package/dist/slices/merge/index.d.ts +0 -19
- package/dist/slices/merge/index.js +0 -147
- package/dist/slices/open-app/index.d.ts +0 -1
- package/dist/slices/open-app/index.js +0 -36
- package/dist/slices/remove-field/index.d.ts +0 -8
- package/dist/slices/remove-field/index.js +0 -167
- package/dist/slices/remove-scenario/index.d.ts +0 -2
- package/dist/slices/remove-scenario/index.js +0 -77
- package/dist/slices/search/index.d.ts +0 -3
- package/dist/slices/search/index.js +0 -302
- package/dist/slices/show-actor/index.d.ts +0 -4
- package/dist/slices/show-actor/index.js +0 -115
- package/dist/slices/show-aggregate/index.d.ts +0 -3
- package/dist/slices/show-aggregate/index.js +0 -108
- package/dist/slices/show-aggregate-completeness/index.d.ts +0 -4
- package/dist/slices/show-aggregate-completeness/index.js +0 -181
- package/dist/slices/show-chapter/index.d.ts +0 -3
- package/dist/slices/show-chapter/index.js +0 -195
- package/dist/slices/show-command/index.d.ts +0 -3
- package/dist/slices/show-command/index.js +0 -133
- package/dist/slices/show-completeness/index.d.ts +0 -4
- package/dist/slices/show-completeness/index.js +0 -731
- package/dist/slices/show-event/index.d.ts +0 -3
- package/dist/slices/show-event/index.js +0 -118
- package/dist/slices/show-model-summary/index.d.ts +0 -3
- package/dist/slices/show-model-summary/index.js +0 -31
- package/dist/slices/show-processor/index.d.ts +0 -3
- package/dist/slices/show-processor/index.js +0 -111
- package/dist/slices/show-readmodel/index.d.ts +0 -3
- package/dist/slices/show-readmodel/index.js +0 -158
- package/dist/slices/show-scenario/index.d.ts +0 -3
- package/dist/slices/show-scenario/index.js +0 -196
- package/dist/slices/show-screen/index.d.ts +0 -3
- package/dist/slices/show-screen/index.js +0 -139
- package/dist/slices/show-slice/index.d.ts +0 -3
- package/dist/slices/show-slice/index.js +0 -696
- package/dist/slices/update-field/index.d.ts +0 -15
- package/dist/slices/update-field/index.js +0 -208
- package/dist/slices/whoami/index.d.ts +0 -2
- package/dist/slices/whoami/index.js +0 -44
- package/dist/types.d.ts +0 -195
- package/dist/types.js +0 -1
package/dist/lib/cloud-client.js
DELETED
|
@@ -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
|
-
}
|
package/dist/lib/config.d.ts
DELETED
|
@@ -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 {};
|
package/dist/lib/config.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import * as os from 'node:os';
|
|
4
|
-
const CONFIG_DIR = path.join(os.homedir(), '.eventmodeler');
|
|
5
|
-
const CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');
|
|
6
|
-
export function getConfigDir() {
|
|
7
|
-
return CONFIG_DIR;
|
|
8
|
-
}
|
|
9
|
-
export function getConfigPath() {
|
|
10
|
-
return CONFIG_PATH;
|
|
11
|
-
}
|
|
12
|
-
export function ensureConfigDir() {
|
|
13
|
-
if (!fs.existsSync(CONFIG_DIR)) {
|
|
14
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export function loadGlobalConfig() {
|
|
18
|
-
try {
|
|
19
|
-
if (fs.existsSync(CONFIG_PATH)) {
|
|
20
|
-
return JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
// Ignore errors, return empty config
|
|
25
|
-
}
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
export function saveGlobalConfig(config) {
|
|
29
|
-
ensureConfigDir();
|
|
30
|
-
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
31
|
-
}
|
|
32
|
-
export function getAuthTokens() {
|
|
33
|
-
const config = loadGlobalConfig();
|
|
34
|
-
return config.auth ?? null;
|
|
35
|
-
}
|
|
36
|
-
export function saveAuthTokens(tokens) {
|
|
37
|
-
const config = loadGlobalConfig();
|
|
38
|
-
config.auth = tokens;
|
|
39
|
-
saveGlobalConfig(config);
|
|
40
|
-
}
|
|
41
|
-
export function clearAuthTokens() {
|
|
42
|
-
const config = loadGlobalConfig();
|
|
43
|
-
delete config.auth;
|
|
44
|
-
saveGlobalConfig(config);
|
|
45
|
-
}
|
|
46
|
-
export function isAuthenticated() {
|
|
47
|
-
const tokens = getAuthTokens();
|
|
48
|
-
if (!tokens)
|
|
49
|
-
return false;
|
|
50
|
-
// Check if token is expired (with 5 minute buffer)
|
|
51
|
-
return tokens.expiresAt > Date.now() + 5 * 60 * 1000;
|
|
52
|
-
}
|
|
53
|
-
export function getBackendUrl() {
|
|
54
|
-
const config = loadGlobalConfig();
|
|
55
|
-
if (config.backendUrl)
|
|
56
|
-
return config.backendUrl;
|
|
57
|
-
if (process.env.EVENTMODELER_BACKEND_URL)
|
|
58
|
-
return process.env.EVENTMODELER_BACKEND_URL;
|
|
59
|
-
// Default to production unless development mode is enabled
|
|
60
|
-
return config.development ? 'http://localhost:8080' : 'https://api.eventmodeler.com';
|
|
61
|
-
}
|
|
62
|
-
export function setBackendUrl(url) {
|
|
63
|
-
const config = loadGlobalConfig();
|
|
64
|
-
config.backendUrl = url;
|
|
65
|
-
saveGlobalConfig(config);
|
|
66
|
-
}
|
|
67
|
-
export function getKeycloakUrl() {
|
|
68
|
-
const config = loadGlobalConfig();
|
|
69
|
-
if (config.keycloakUrl)
|
|
70
|
-
return config.keycloakUrl;
|
|
71
|
-
if (process.env.EVENTMODELER_KEYCLOAK_URL)
|
|
72
|
-
return process.env.EVENTMODELER_KEYCLOAK_URL;
|
|
73
|
-
// Default to production unless development mode is enabled
|
|
74
|
-
return config.development ? 'http://localhost:18180/realms/eventmodeler' : 'https://auth.eventmodeler.com/realms/eventmodeler';
|
|
75
|
-
}
|
|
76
|
-
export function setKeycloakUrl(url) {
|
|
77
|
-
const config = loadGlobalConfig();
|
|
78
|
-
config.keycloakUrl = url;
|
|
79
|
-
saveGlobalConfig(config);
|
|
80
|
-
}
|
|
81
|
-
export function getDefaultFormat() {
|
|
82
|
-
// 1. Check environment variable
|
|
83
|
-
const envFormat = process.env.EVENTMODELER_FORMAT;
|
|
84
|
-
if (envFormat === 'json')
|
|
85
|
-
return 'json';
|
|
86
|
-
if (envFormat === 'xml')
|
|
87
|
-
return 'xml';
|
|
88
|
-
// 2. Check config file
|
|
89
|
-
const config = loadGlobalConfig();
|
|
90
|
-
if (config.format === 'json' || config.format === 'xml') {
|
|
91
|
-
return config.format;
|
|
92
|
-
}
|
|
93
|
-
// 3. Default to XML (better for AI agents)
|
|
94
|
-
return 'xml';
|
|
95
|
-
}
|
|
@@ -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
|
-
};
|