eventmodeler 0.4.0 → 0.4.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/cloud/slices/index.d.ts +215 -0
- package/dist/cloud/slices/index.js +247 -0
- package/dist/index.js +984 -39
- package/dist/lib/auth.d.ts +24 -0
- package/dist/lib/auth.js +332 -0
- package/dist/lib/backend.d.ts +48 -0
- package/dist/lib/backend.js +103 -0
- package/dist/lib/cloud-client.d.ts +70 -0
- package/dist/lib/cloud-client.js +528 -0
- package/dist/lib/config.d.ts +27 -0
- package/dist/lib/config.js +80 -11
- package/dist/lib/diff/three-way-merge.js +4 -4
- package/dist/lib/file-loader.js +43 -12
- package/dist/lib/project-config.d.ts +30 -0
- package/dist/lib/project-config.js +90 -0
- package/dist/lib/slice-utils.d.ts +28 -0
- package/dist/lib/slice-utils.js +80 -0
- package/dist/local/slices/index.d.ts +11 -0
- package/dist/local/slices/index.js +13 -0
- package/dist/projection.js +372 -371
- package/dist/slices/add-field/index.js +25 -15
- package/dist/slices/add-scenario/index.js +34 -22
- package/dist/slices/create-automation-slice/index.js +93 -65
- package/dist/slices/create-flow/index.js +24 -18
- package/dist/slices/create-state-change-slice/index.js +77 -53
- package/dist/slices/create-state-view-slice/index.js +25 -17
- package/dist/slices/import/index.d.ts +8 -0
- package/dist/slices/import/index.js +63 -0
- package/dist/slices/init/index.d.ts +4 -0
- package/dist/slices/init/index.js +133 -0
- package/dist/slices/list-processors/index.d.ts +3 -0
- package/dist/slices/list-processors/index.js +20 -0
- package/dist/slices/list-readmodels/index.d.ts +3 -0
- package/dist/slices/list-readmodels/index.js +21 -0
- package/dist/slices/list-scenarios/index.d.ts +3 -0
- package/dist/slices/list-scenarios/index.js +35 -0
- package/dist/slices/list-screens/index.d.ts +3 -0
- package/dist/slices/list-screens/index.js +47 -0
- package/dist/slices/login/index.d.ts +1 -0
- package/dist/slices/login/index.js +24 -0
- package/dist/slices/logout/index.d.ts +1 -0
- package/dist/slices/logout/index.js +14 -0
- package/dist/slices/map-fields/index.js +5 -3
- package/dist/slices/mark-slice-status/index.js +4 -2
- package/dist/slices/remove-field/index.js +25 -15
- package/dist/slices/remove-scenario/index.js +8 -4
- package/dist/slices/show-aggregate/index.d.ts +3 -0
- package/dist/slices/show-aggregate/index.js +108 -0
- package/dist/slices/show-processor/index.d.ts +3 -0
- package/dist/slices/show-processor/index.js +111 -0
- package/dist/slices/show-readmodel/index.d.ts +3 -0
- package/dist/slices/show-readmodel/index.js +158 -0
- package/dist/slices/show-scenario/index.d.ts +3 -0
- package/dist/slices/show-scenario/index.js +196 -0
- package/dist/slices/show-screen/index.d.ts +3 -0
- package/dist/slices/show-screen/index.js +139 -0
- package/dist/slices/update-field/index.js +30 -20
- package/dist/slices/whoami/index.d.ts +2 -0
- package/dist/slices/whoami/index.js +35 -0
- package/dist/types.d.ts +1 -2
- package/package.json +1 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
export declare function listSlices(modelId: string, format?: OutputFormat, chapterFilter?: string): Promise<string>;
|
|
2
|
+
export declare function listEvents(modelId: string, format?: OutputFormat): Promise<string>;
|
|
3
|
+
export declare function listCommands(modelId: string, format?: OutputFormat): Promise<string>;
|
|
4
|
+
export declare function listChapters(modelId: string, format?: OutputFormat): Promise<string>;
|
|
5
|
+
export declare function listActors(modelId: string, format?: OutputFormat): Promise<string>;
|
|
6
|
+
export interface SearchResult {
|
|
7
|
+
type: string;
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SearchResponse {
|
|
12
|
+
query: string;
|
|
13
|
+
count: number;
|
|
14
|
+
results: SearchResult[];
|
|
15
|
+
}
|
|
16
|
+
export declare function search(modelId: string, term: string): Promise<SearchResponse>;
|
|
17
|
+
export interface ModelSummary {
|
|
18
|
+
modelName: string;
|
|
19
|
+
slices: {
|
|
20
|
+
total: number;
|
|
21
|
+
byStatus: {
|
|
22
|
+
created: number;
|
|
23
|
+
inProgress: number;
|
|
24
|
+
blocked: number;
|
|
25
|
+
done: number;
|
|
26
|
+
};
|
|
27
|
+
byType: {
|
|
28
|
+
stateChange: number;
|
|
29
|
+
automation: number;
|
|
30
|
+
stateView: number;
|
|
31
|
+
unknown: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
events: number;
|
|
35
|
+
commands: number;
|
|
36
|
+
readModels: number;
|
|
37
|
+
screens: number;
|
|
38
|
+
processors: number;
|
|
39
|
+
chapters: number;
|
|
40
|
+
aggregates: number;
|
|
41
|
+
actors: number;
|
|
42
|
+
flows: number;
|
|
43
|
+
scenarios: number;
|
|
44
|
+
}
|
|
45
|
+
export declare function getSummary(modelId: string): Promise<ModelSummary>;
|
|
46
|
+
export type SliceStatus = 'created' | 'in-progress' | 'blocked' | 'done';
|
|
47
|
+
export declare function markSliceStatus(modelId: string, sliceName: string, status: SliceStatus): Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
export type ElementType = 'command' | 'event' | 'readModel' | 'screen' | 'processor';
|
|
51
|
+
export interface FieldInput {
|
|
52
|
+
name: string;
|
|
53
|
+
fieldType: string;
|
|
54
|
+
isList?: boolean;
|
|
55
|
+
isOptional?: boolean;
|
|
56
|
+
isGenerated?: boolean;
|
|
57
|
+
isUserInput?: boolean;
|
|
58
|
+
subfields?: FieldInput[];
|
|
59
|
+
}
|
|
60
|
+
export declare function addField(modelId: string, elementType: ElementType, elementName: string, field: FieldInput): Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
export declare function removeField(modelId: string, elementType: ElementType, elementName: string, fieldName: string): Promise<{
|
|
64
|
+
success: boolean;
|
|
65
|
+
}>;
|
|
66
|
+
export interface FieldUpdates {
|
|
67
|
+
name?: string;
|
|
68
|
+
fieldType?: string;
|
|
69
|
+
isList?: boolean;
|
|
70
|
+
isOptional?: boolean;
|
|
71
|
+
isGenerated?: boolean;
|
|
72
|
+
isUserInput?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export declare function updateField(modelId: string, elementType: ElementType, elementName: string, fieldName: string, updates: FieldUpdates): Promise<{
|
|
75
|
+
success: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
export interface FieldMappingInput {
|
|
78
|
+
from: string;
|
|
79
|
+
to: string;
|
|
80
|
+
}
|
|
81
|
+
export declare function mapFields(modelId: string, sourceName: string, targetName: string, mappings: FieldMappingInput[]): Promise<{
|
|
82
|
+
success: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
export interface ScenarioInput {
|
|
85
|
+
name: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
given?: {
|
|
88
|
+
type: 'events';
|
|
89
|
+
events: string[];
|
|
90
|
+
};
|
|
91
|
+
when?: {
|
|
92
|
+
type: 'command' | 'events';
|
|
93
|
+
command?: string;
|
|
94
|
+
events?: string[];
|
|
95
|
+
};
|
|
96
|
+
then: {
|
|
97
|
+
type: 'events' | 'error' | 'command';
|
|
98
|
+
events?: string[];
|
|
99
|
+
errorMessage?: string;
|
|
100
|
+
errorType?: string;
|
|
101
|
+
command?: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export declare function createScenario(modelId: string, sliceName: string, scenario: ScenarioInput): Promise<{
|
|
105
|
+
success: boolean;
|
|
106
|
+
scenarioId: string;
|
|
107
|
+
}>;
|
|
108
|
+
export declare function removeScenario(modelId: string, scenarioName: string, sliceName?: string): Promise<{
|
|
109
|
+
success: boolean;
|
|
110
|
+
}>;
|
|
111
|
+
export declare function createFlow(modelId: string, fromName: string, toName: string): Promise<{
|
|
112
|
+
success: boolean;
|
|
113
|
+
}>;
|
|
114
|
+
export interface CompoundFieldInput {
|
|
115
|
+
name: string;
|
|
116
|
+
fieldType: string;
|
|
117
|
+
isList?: boolean;
|
|
118
|
+
isOptional?: boolean;
|
|
119
|
+
isGenerated?: boolean;
|
|
120
|
+
isUserInput?: boolean;
|
|
121
|
+
}
|
|
122
|
+
export interface StateChangeSliceInput {
|
|
123
|
+
sliceName: string;
|
|
124
|
+
after?: string;
|
|
125
|
+
before?: string;
|
|
126
|
+
screen: {
|
|
127
|
+
name: string;
|
|
128
|
+
fields: CompoundFieldInput[];
|
|
129
|
+
};
|
|
130
|
+
command: {
|
|
131
|
+
name: string;
|
|
132
|
+
fields: CompoundFieldInput[];
|
|
133
|
+
};
|
|
134
|
+
event: {
|
|
135
|
+
name: string;
|
|
136
|
+
fields: CompoundFieldInput[];
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
export interface StateChangeSliceResult {
|
|
140
|
+
success: boolean;
|
|
141
|
+
sliceId: string;
|
|
142
|
+
screenId: string;
|
|
143
|
+
commandId: string;
|
|
144
|
+
eventId: string;
|
|
145
|
+
screenToCommandMappings: number;
|
|
146
|
+
commandToEventMappings: number;
|
|
147
|
+
}
|
|
148
|
+
export declare function createStateChangeSlice(modelId: string, input: StateChangeSliceInput): Promise<StateChangeSliceResult>;
|
|
149
|
+
export interface AutomationSliceInput {
|
|
150
|
+
sliceName: string;
|
|
151
|
+
after?: string;
|
|
152
|
+
before?: string;
|
|
153
|
+
readModel: {
|
|
154
|
+
name: string;
|
|
155
|
+
fields: CompoundFieldInput[];
|
|
156
|
+
};
|
|
157
|
+
processor: {
|
|
158
|
+
name: string;
|
|
159
|
+
};
|
|
160
|
+
command: {
|
|
161
|
+
name: string;
|
|
162
|
+
fields: CompoundFieldInput[];
|
|
163
|
+
};
|
|
164
|
+
event: {
|
|
165
|
+
name: string;
|
|
166
|
+
fields: CompoundFieldInput[];
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export interface AutomationSliceResult {
|
|
170
|
+
success: boolean;
|
|
171
|
+
sliceId: string;
|
|
172
|
+
readModelId: string;
|
|
173
|
+
processorId: string;
|
|
174
|
+
commandId: string;
|
|
175
|
+
eventId: string;
|
|
176
|
+
readModelToCommandMappings: number;
|
|
177
|
+
commandToEventMappings: number;
|
|
178
|
+
}
|
|
179
|
+
export declare function createAutomationSlice(modelId: string, input: AutomationSliceInput): Promise<AutomationSliceResult>;
|
|
180
|
+
export interface StateViewSliceInput {
|
|
181
|
+
sliceName: string;
|
|
182
|
+
after?: string;
|
|
183
|
+
before?: string;
|
|
184
|
+
readModel: {
|
|
185
|
+
name: string;
|
|
186
|
+
fields: CompoundFieldInput[];
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export interface StateViewSliceResult {
|
|
190
|
+
success: boolean;
|
|
191
|
+
sliceId: string;
|
|
192
|
+
readModelId: string;
|
|
193
|
+
}
|
|
194
|
+
export declare function createStateViewSlice(modelId: string, input: StateViewSliceInput): Promise<StateViewSliceResult>;
|
|
195
|
+
export type OutputFormat = 'xml' | 'json';
|
|
196
|
+
export declare function showSlice(modelId: string, sliceName: string, format?: OutputFormat): Promise<string>;
|
|
197
|
+
export declare function showEvent(modelId: string, eventName: string, format?: OutputFormat): Promise<string>;
|
|
198
|
+
export declare function showCommand(modelId: string, commandName: string, format?: OutputFormat): Promise<string>;
|
|
199
|
+
export declare function showChapter(modelId: string, chapterName: string, format?: OutputFormat): Promise<string>;
|
|
200
|
+
export declare function showActor(modelId: string, actorName: string, format?: OutputFormat): Promise<string>;
|
|
201
|
+
export declare function exportJson(modelId: string): Promise<string>;
|
|
202
|
+
export declare function codegenSlice(modelId: string, sliceName: string): Promise<string>;
|
|
203
|
+
export declare function listAggregates(modelId: string, format?: OutputFormat): Promise<string>;
|
|
204
|
+
export declare function listReadModels(modelId: string, format?: OutputFormat): Promise<string>;
|
|
205
|
+
export declare function listScreens(modelId: string, format?: OutputFormat): Promise<string>;
|
|
206
|
+
export declare function listProcessors(modelId: string, format?: OutputFormat): Promise<string>;
|
|
207
|
+
export declare function showCompleteness(modelId: string, elementName: string, format?: OutputFormat): Promise<string>;
|
|
208
|
+
export declare function showModelCompleteness(modelId: string, format?: OutputFormat): Promise<string>;
|
|
209
|
+
export declare function showAggregateCompleteness(modelId: string, aggregateName: string, format?: OutputFormat): Promise<string>;
|
|
210
|
+
export declare function showReadModel(modelId: string, name: string, format?: OutputFormat): Promise<string>;
|
|
211
|
+
export declare function showScreen(modelId: string, name: string, format?: OutputFormat): Promise<string>;
|
|
212
|
+
export declare function showProcessor(modelId: string, name: string, format?: OutputFormat): Promise<string>;
|
|
213
|
+
export declare function showAggregate(modelId: string, name: string, format?: OutputFormat): Promise<string>;
|
|
214
|
+
export declare function showScenario(modelId: string, name: string, format?: OutputFormat): Promise<string>;
|
|
215
|
+
export declare function listScenarios(modelId: string, format?: OutputFormat): Promise<string>;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Cloud slice implementations - thin wrappers that call backend CLI endpoints
|
|
2
|
+
// The backend does all the heavy lifting (name resolution, data denormalization)
|
|
3
|
+
import { getBackendUrl } from '../../lib/config.js';
|
|
4
|
+
import { getValidAccessToken } from '../../lib/auth.js';
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// HTTP Client for CLI endpoints
|
|
7
|
+
// =============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* Handle HTTP error responses with user-friendly messages.
|
|
10
|
+
* Tries to extract error detail from response body, falls back to status-based messages.
|
|
11
|
+
*/
|
|
12
|
+
async function handleHttpError(response, path) {
|
|
13
|
+
const text = await response.text().catch(() => '');
|
|
14
|
+
let errorDetail = '';
|
|
15
|
+
if (text.trim()) {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(text);
|
|
18
|
+
errorDetail = parsed.error ?? parsed.message ?? '';
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Response body isn't JSON (could be HTML error page, etc.)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
switch (response.status) {
|
|
25
|
+
case 401:
|
|
26
|
+
throw new Error(`Authentication required. Run 'eventmodeler login' to authenticate.` +
|
|
27
|
+
(errorDetail ? `\n\nOriginal error: ${errorDetail}` : ''));
|
|
28
|
+
case 403:
|
|
29
|
+
throw new Error(`Permission denied. You may not have access to this model, or you need editor permission for this action.` +
|
|
30
|
+
(errorDetail ? `\n\nOriginal error: ${errorDetail}` : ''));
|
|
31
|
+
case 404:
|
|
32
|
+
throw new Error(errorDetail || `Not found: ${path}`);
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(errorDetail || `HTTP ${response.status}: ${response.statusText}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function cliGet(path, params) {
|
|
38
|
+
const backendUrl = getBackendUrl();
|
|
39
|
+
const accessToken = await getValidAccessToken();
|
|
40
|
+
const url = new URL(`${backendUrl}${path}`);
|
|
41
|
+
for (const [key, value] of Object.entries(params)) {
|
|
42
|
+
if (value !== undefined) {
|
|
43
|
+
url.searchParams.set(key, value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const response = await fetch(url.toString(), {
|
|
47
|
+
method: 'GET',
|
|
48
|
+
headers: {
|
|
49
|
+
Accept: 'application/json',
|
|
50
|
+
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
await handleHttpError(response, path);
|
|
55
|
+
}
|
|
56
|
+
const text = await response.text();
|
|
57
|
+
if (!text.trim()) {
|
|
58
|
+
throw new Error(`Empty response from ${path}`);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(text);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
65
|
+
const snippet = text.slice(0, 200);
|
|
66
|
+
throw new Error(`Invalid JSON from ${path}: ${message}. Body: ${snippet}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function cliPost(path, body) {
|
|
70
|
+
const backendUrl = getBackendUrl();
|
|
71
|
+
const accessToken = await getValidAccessToken();
|
|
72
|
+
const response = await fetch(`${backendUrl}${path}`, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
Accept: 'application/json',
|
|
77
|
+
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
|
|
78
|
+
},
|
|
79
|
+
body: JSON.stringify(body),
|
|
80
|
+
});
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
await handleHttpError(response, path);
|
|
83
|
+
}
|
|
84
|
+
const text = await response.text();
|
|
85
|
+
if (!text.trim()) {
|
|
86
|
+
throw new Error(`Empty response from ${path}`);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(text);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
93
|
+
const snippet = text.slice(0, 200);
|
|
94
|
+
throw new Error(`Invalid JSON from ${path}: ${message}. Body: ${snippet}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// =============================================================================
|
|
98
|
+
// Query Functions (read-only, return denormalized data)
|
|
99
|
+
// =============================================================================
|
|
100
|
+
export async function listSlices(modelId, format = 'xml', chapterFilter) {
|
|
101
|
+
const params = { modelId };
|
|
102
|
+
if (chapterFilter)
|
|
103
|
+
params.chapter = chapterFilter;
|
|
104
|
+
return cliGetText('/cli/list-slices', params, format);
|
|
105
|
+
}
|
|
106
|
+
export async function listEvents(modelId, format = 'xml') {
|
|
107
|
+
return cliGetText('/cli/list-events', { modelId }, format);
|
|
108
|
+
}
|
|
109
|
+
export async function listCommands(modelId, format = 'xml') {
|
|
110
|
+
return cliGetText('/cli/list-commands', { modelId }, format);
|
|
111
|
+
}
|
|
112
|
+
export async function listChapters(modelId, format = 'xml') {
|
|
113
|
+
return cliGetText('/cli/list-chapters', { modelId }, format);
|
|
114
|
+
}
|
|
115
|
+
export async function listActors(modelId, format = 'xml') {
|
|
116
|
+
return cliGetText('/cli/list-actors', { modelId }, format);
|
|
117
|
+
}
|
|
118
|
+
export async function search(modelId, term) {
|
|
119
|
+
return cliGet('/cli/search', { modelId, term });
|
|
120
|
+
}
|
|
121
|
+
export async function getSummary(modelId) {
|
|
122
|
+
return cliGet('/cli/summary', { modelId });
|
|
123
|
+
}
|
|
124
|
+
export async function markSliceStatus(modelId, sliceName, status) {
|
|
125
|
+
return cliPost('/cli/mark-slice-status', { modelId, sliceName, status });
|
|
126
|
+
}
|
|
127
|
+
export async function addField(modelId, elementType, elementName, field) {
|
|
128
|
+
return cliPost('/cli/add-field', { modelId, elementType, elementName, field });
|
|
129
|
+
}
|
|
130
|
+
export async function removeField(modelId, elementType, elementName, fieldName) {
|
|
131
|
+
return cliPost('/cli/remove-field', { modelId, elementType, elementName, fieldName });
|
|
132
|
+
}
|
|
133
|
+
export async function updateField(modelId, elementType, elementName, fieldName, updates) {
|
|
134
|
+
return cliPost('/cli/update-field', { modelId, elementType, elementName, fieldName, updates });
|
|
135
|
+
}
|
|
136
|
+
export async function mapFields(modelId, sourceName, targetName, mappings) {
|
|
137
|
+
return cliPost('/cli/map-fields', { modelId, sourceName, targetName, mappings });
|
|
138
|
+
}
|
|
139
|
+
export async function createScenario(modelId, sliceName, scenario) {
|
|
140
|
+
return cliPost('/cli/create-scenario', { modelId, sliceName, scenario });
|
|
141
|
+
}
|
|
142
|
+
export async function removeScenario(modelId, scenarioName, sliceName) {
|
|
143
|
+
return cliPost('/cli/remove-scenario', { modelId, scenarioName, sliceName });
|
|
144
|
+
}
|
|
145
|
+
export async function createFlow(modelId, fromName, toName) {
|
|
146
|
+
return cliPost('/cli/create-flow', { modelId, fromName, toName });
|
|
147
|
+
}
|
|
148
|
+
export async function createStateChangeSlice(modelId, input) {
|
|
149
|
+
return cliPost('/cli/create-state-change-slice', { modelId, ...input });
|
|
150
|
+
}
|
|
151
|
+
export async function createAutomationSlice(modelId, input) {
|
|
152
|
+
return cliPost('/cli/create-automation-slice', { modelId, ...input });
|
|
153
|
+
}
|
|
154
|
+
export async function createStateViewSlice(modelId, input) {
|
|
155
|
+
return cliPost('/cli/create-state-view-slice', { modelId, ...input });
|
|
156
|
+
}
|
|
157
|
+
// =============================================================================
|
|
158
|
+
// View Functions (read-only, return formatted XML/JSON strings)
|
|
159
|
+
// =============================================================================
|
|
160
|
+
// Maps format to Accept header media type for content negotiation with the backend
|
|
161
|
+
function formatToMediaType(format) {
|
|
162
|
+
return format === 'xml' ? 'application/xml' : 'application/json';
|
|
163
|
+
}
|
|
164
|
+
// Helper for view queries that return text (XML or JSON string).
|
|
165
|
+
// Uses Accept header for content negotiation instead of a format query param.
|
|
166
|
+
async function cliGetText(path, params, format) {
|
|
167
|
+
const backendUrl = getBackendUrl();
|
|
168
|
+
const accessToken = await getValidAccessToken();
|
|
169
|
+
const url = new URL(`${backendUrl}${path}`);
|
|
170
|
+
for (const [key, value] of Object.entries(params)) {
|
|
171
|
+
if (value !== undefined) {
|
|
172
|
+
url.searchParams.set(key, value);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const response = await fetch(url.toString(), {
|
|
176
|
+
method: 'GET',
|
|
177
|
+
headers: {
|
|
178
|
+
Accept: formatToMediaType(format),
|
|
179
|
+
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
if (!response.ok) {
|
|
183
|
+
await handleHttpError(response, path);
|
|
184
|
+
}
|
|
185
|
+
const text = await response.text();
|
|
186
|
+
return text.trimEnd();
|
|
187
|
+
}
|
|
188
|
+
export async function showSlice(modelId, sliceName, format = 'xml') {
|
|
189
|
+
return cliGetText('/cli/show-slice', { modelId, name: sliceName }, format);
|
|
190
|
+
}
|
|
191
|
+
export async function showEvent(modelId, eventName, format = 'xml') {
|
|
192
|
+
return cliGetText('/cli/show-event', { modelId, name: eventName }, format);
|
|
193
|
+
}
|
|
194
|
+
export async function showCommand(modelId, commandName, format = 'xml') {
|
|
195
|
+
return cliGetText('/cli/show-command', { modelId, name: commandName }, format);
|
|
196
|
+
}
|
|
197
|
+
export async function showChapter(modelId, chapterName, format = 'xml') {
|
|
198
|
+
return cliGetText('/cli/show-chapter', { modelId, name: chapterName }, format);
|
|
199
|
+
}
|
|
200
|
+
export async function showActor(modelId, actorName, format = 'xml') {
|
|
201
|
+
return cliGetText('/cli/show-actor', { modelId, name: actorName }, format);
|
|
202
|
+
}
|
|
203
|
+
export async function exportJson(modelId) {
|
|
204
|
+
return cliGetText('/cli/export-json', { modelId });
|
|
205
|
+
}
|
|
206
|
+
export async function codegenSlice(modelId, sliceName) {
|
|
207
|
+
return cliGetText('/cli/codegen-slice', { modelId, name: sliceName });
|
|
208
|
+
}
|
|
209
|
+
export async function listAggregates(modelId, format = 'xml') {
|
|
210
|
+
return cliGetText('/cli/list-aggregates', { modelId }, format);
|
|
211
|
+
}
|
|
212
|
+
export async function listReadModels(modelId, format = 'xml') {
|
|
213
|
+
return cliGetText('/cli/list-readmodels', { modelId }, format);
|
|
214
|
+
}
|
|
215
|
+
export async function listScreens(modelId, format = 'xml') {
|
|
216
|
+
return cliGetText('/cli/list-screens', { modelId }, format);
|
|
217
|
+
}
|
|
218
|
+
export async function listProcessors(modelId, format = 'xml') {
|
|
219
|
+
return cliGetText('/cli/list-processors', { modelId }, format);
|
|
220
|
+
}
|
|
221
|
+
export async function showCompleteness(modelId, elementName, format = 'xml') {
|
|
222
|
+
return cliGetText('/cli/show-completeness', { modelId, name: elementName }, format);
|
|
223
|
+
}
|
|
224
|
+
export async function showModelCompleteness(modelId, format = 'xml') {
|
|
225
|
+
return cliGetText('/cli/show-model-completeness', { modelId }, format);
|
|
226
|
+
}
|
|
227
|
+
export async function showAggregateCompleteness(modelId, aggregateName, format = 'xml') {
|
|
228
|
+
return cliGetText('/cli/show-aggregate-completeness', { modelId, name: aggregateName }, format);
|
|
229
|
+
}
|
|
230
|
+
export async function showReadModel(modelId, name, format = 'xml') {
|
|
231
|
+
return cliGetText('/cli/show-readmodel', { modelId, name }, format);
|
|
232
|
+
}
|
|
233
|
+
export async function showScreen(modelId, name, format = 'xml') {
|
|
234
|
+
return cliGetText('/cli/show-screen', { modelId, name }, format);
|
|
235
|
+
}
|
|
236
|
+
export async function showProcessor(modelId, name, format = 'xml') {
|
|
237
|
+
return cliGetText('/cli/show-processor', { modelId, name }, format);
|
|
238
|
+
}
|
|
239
|
+
export async function showAggregate(modelId, name, format = 'xml') {
|
|
240
|
+
return cliGetText('/cli/show-aggregate', { modelId, name }, format);
|
|
241
|
+
}
|
|
242
|
+
export async function showScenario(modelId, name, format = 'xml') {
|
|
243
|
+
return cliGetText('/cli/show-scenario', { modelId, name }, format);
|
|
244
|
+
}
|
|
245
|
+
export async function listScenarios(modelId, format = 'xml') {
|
|
246
|
+
return cliGetText('/cli/list-scenarios', { modelId }, format);
|
|
247
|
+
}
|