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.
- package/dist/api/client-config.js +10 -0
- package/dist/api/generated/client/client.gen.js +235 -0
- package/dist/api/generated/client/index.js +6 -0
- package/dist/api/generated/client/types.gen.js +2 -0
- package/dist/api/generated/client/utils.gen.js +228 -0
- package/dist/api/generated/client.gen.js +4 -0
- package/dist/api/generated/core/auth.gen.js +14 -0
- package/dist/api/generated/core/bodySerializer.gen.js +57 -0
- package/dist/api/generated/core/params.gen.js +100 -0
- package/dist/api/generated/core/pathSerializer.gen.js +106 -0
- package/dist/api/generated/core/queryKeySerializer.gen.js +92 -0
- package/dist/api/generated/core/serverSentEvents.gen.js +133 -0
- package/dist/api/generated/core/types.gen.js +2 -0
- package/dist/api/generated/core/utils.gen.js +87 -0
- package/dist/api/generated/index.js +2 -0
- package/dist/api/generated/sdk.gen.js +4222 -0
- package/dist/api/generated/types.gen.js +2 -0
- package/dist/api/generated/zod.gen.js +7217 -0
- package/dist/commands/add.js +315 -0
- package/dist/commands/auth.js +14 -0
- package/dist/commands/create.js +192 -0
- package/dist/commands/design.js +108 -0
- package/dist/commands/guide.js +15 -0
- package/dist/commands/init.js +21 -0
- package/dist/commands/list-schemas.js +177 -0
- package/dist/commands/list.js +39 -0
- package/dist/commands/loop.js +101 -0
- package/dist/commands/map.js +40 -0
- package/dist/commands/mark.js +27 -0
- package/dist/commands/move.js +35 -0
- package/dist/commands/remove.js +170 -0
- package/dist/commands/rename.js +53 -0
- package/dist/commands/resize.js +30 -0
- package/dist/commands/search.js +14 -0
- package/dist/commands/set.js +199 -0
- package/dist/commands/show-schemas.js +259 -0
- package/dist/commands/show.js +56 -0
- package/dist/commands/summary.js +13 -0
- package/dist/commands/update.js +240 -0
- package/dist/index.js +46 -2379
- package/dist/lib/auth.js +1 -1
- package/dist/lib/config.js +0 -15
- package/dist/lib/excalidraw-schema.js +66 -0
- package/dist/lib/globals.js +8 -0
- package/dist/lib/model.js +11 -0
- package/dist/lib/project-config.js +20 -0
- package/dist/lib/resolve.js +59 -0
- package/dist/lib/scenario.js +15 -0
- package/dist/slices/add-scenario/index.js +2 -206
- package/dist/slices/guide/guides/codegen.js +1 -1
- package/dist/slices/guide/guides/connect-slices.js +38 -38
- package/dist/slices/guide/guides/create-slices.js +110 -140
- package/dist/slices/guide/guides/explore.js +37 -50
- package/dist/slices/guide/guides/information-flow.js +70 -84
- package/dist/slices/guide/guides/scenarios.js +82 -137
- package/dist/slices/guide/index.js +6 -6
- package/dist/slices/help/index.js +96 -0
- package/dist/slices/help/topics/build-codegen.js +109 -0
- package/dist/slices/help/topics/build-slice.js +147 -0
- package/dist/slices/help/topics/check-completeness.js +57 -0
- package/dist/slices/help/topics/connect-slices.js +99 -0
- package/dist/slices/help/topics/explore-model.js +112 -0
- package/dist/slices/help/topics/json-reference.js +188 -0
- package/dist/slices/help/topics/linked-copies.js +89 -0
- package/dist/slices/help/topics/manipulate-canvas.js +150 -0
- package/dist/slices/help/topics/write-scenarios.js +162 -0
- package/dist/slices/init/index.js +10 -4
- package/dist/slices/init/loop.js +60 -0
- package/dist/slices/login/index.js +2 -2
- package/dist/slices/logout/index.js +2 -2
- package/dist/slices/whoami/index.js +11 -36
- package/package.json +8 -3
- 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/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/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/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/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/connect-slices.d.ts +0 -5
- package/dist/slices/guide/guides/create-slices.d.ts +0 -5
- package/dist/slices/guide/guides/explore.d.ts +0 -5
- package/dist/slices/guide/guides/information-flow.d.ts +0 -5
- package/dist/slices/guide/guides/scenarios.d.ts +0 -5
- package/dist/slices/guide/index.d.ts +0 -1
- 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/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/logout/index.d.ts +0 -1
- 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/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/types.d.ts +0 -195
- package/dist/types.js +0 -1
package/dist/lib/file-loader.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import * as readline from 'node:readline';
|
|
4
|
-
import { projectEvents } from '../projection.js';
|
|
5
|
-
export async function promptForFile(files) {
|
|
6
|
-
const rl = readline.createInterface({
|
|
7
|
-
input: process.stdin,
|
|
8
|
-
output: process.stderr,
|
|
9
|
-
});
|
|
10
|
-
console.error('\nMultiple .eventmodel files found:\n');
|
|
11
|
-
files.forEach((file, index) => {
|
|
12
|
-
console.error(` ${index + 1}) ${file}`);
|
|
13
|
-
});
|
|
14
|
-
console.error('');
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
rl.question('Select a file (number): ', (answer) => {
|
|
17
|
-
rl.close();
|
|
18
|
-
const index = parseInt(answer, 10) - 1;
|
|
19
|
-
if (index >= 0 && index < files.length) {
|
|
20
|
-
resolve(path.join(process.cwd(), files[index]));
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
console.error('Invalid selection. Using first file.');
|
|
24
|
-
resolve(path.join(process.cwd(), files[0]));
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export async function findEventModelFile() {
|
|
30
|
-
const files = fs.readdirSync(process.cwd());
|
|
31
|
-
const eventModelFiles = files.filter(f => f.endsWith('.eventmodel'));
|
|
32
|
-
if (eventModelFiles.length === 0) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
if (eventModelFiles.length === 1) {
|
|
36
|
-
return path.join(process.cwd(), eventModelFiles[0]);
|
|
37
|
-
}
|
|
38
|
-
return promptForFile(eventModelFiles);
|
|
39
|
-
}
|
|
40
|
-
export function loadModel(filePath) {
|
|
41
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
42
|
-
if (!content.trim()) {
|
|
43
|
-
return projectEvents([]);
|
|
44
|
-
}
|
|
45
|
-
const lines = content.split('\n');
|
|
46
|
-
const events = [];
|
|
47
|
-
for (let i = 0; i < lines.length; i++) {
|
|
48
|
-
const line = lines[i].trim();
|
|
49
|
-
if (!line)
|
|
50
|
-
continue;
|
|
51
|
-
try {
|
|
52
|
-
events.push(JSON.parse(line));
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
56
|
-
throw new Error(`Invalid JSON in ${filePath} at line ${i + 1}: ${message}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return projectEvents(events);
|
|
60
|
-
}
|
|
61
|
-
export function appendEvent(filePath, event) {
|
|
62
|
-
fs.appendFileSync(filePath, JSON.stringify(event) + '\n');
|
|
63
|
-
}
|
|
64
|
-
export function loadRawEvents(filePath) {
|
|
65
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
66
|
-
if (!content.trim()) {
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
|
-
const lines = content.split('\n');
|
|
70
|
-
const events = [];
|
|
71
|
-
for (let i = 0; i < lines.length; i++) {
|
|
72
|
-
const line = lines[i].trim();
|
|
73
|
-
if (!line)
|
|
74
|
-
continue;
|
|
75
|
-
try {
|
|
76
|
-
events.push(JSON.parse(line));
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
80
|
-
throw new Error(`Invalid JSON in ${filePath} at line ${i + 1}: ${message}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return events;
|
|
84
|
-
}
|
|
85
|
-
export function writeEvents(filePath, events) {
|
|
86
|
-
const content = events.map(e => JSON.stringify(e)).join('\n') + '\n';
|
|
87
|
-
fs.writeFileSync(filePath, content);
|
|
88
|
-
}
|
|
89
|
-
export function loadModelFromContent(content) {
|
|
90
|
-
if (!content.trim()) {
|
|
91
|
-
return projectEvents([]);
|
|
92
|
-
}
|
|
93
|
-
const lines = content.split('\n');
|
|
94
|
-
const events = [];
|
|
95
|
-
for (let i = 0; i < lines.length; i++) {
|
|
96
|
-
const line = lines[i].trim();
|
|
97
|
-
if (!line)
|
|
98
|
-
continue;
|
|
99
|
-
try {
|
|
100
|
-
events.push(JSON.parse(line));
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
104
|
-
throw new Error(`Invalid JSON in event model input at line ${i + 1}: ${message}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return projectEvents(events);
|
|
108
|
-
}
|
package/dist/lib/flow-utils.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { EventModel, Slice } from '../types.js';
|
|
2
|
-
export type ElementType = 'screen' | 'command' | 'event' | 'read-model' | 'processor';
|
|
3
|
-
export interface ElementInfo {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
type: ElementType;
|
|
7
|
-
}
|
|
8
|
-
export interface FieldMappingInfo {
|
|
9
|
-
from: string;
|
|
10
|
-
to: string;
|
|
11
|
-
}
|
|
12
|
-
export interface FlowInfo {
|
|
13
|
-
flowId: string;
|
|
14
|
-
flowType: string;
|
|
15
|
-
source: ElementInfo;
|
|
16
|
-
target: ElementInfo;
|
|
17
|
-
fieldMappings: FieldMappingInfo[];
|
|
18
|
-
}
|
|
19
|
-
export interface SliceFlowInfo extends FlowInfo {
|
|
20
|
-
sourceSlice?: {
|
|
21
|
-
id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
targetSlice?: {
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare function resolveToCanonical(model: EventModel, id: string): string;
|
|
30
|
-
export declare function getElementInfo(model: EventModel, id: string): ElementInfo | null;
|
|
31
|
-
export declare function getSliceComponentIds(model: EventModel, slice: Slice): Set<string>;
|
|
32
|
-
export declare function findSliceForComponent(model: EventModel, componentId: string): Slice | null;
|
|
33
|
-
export declare function getInboundFlows(model: EventModel, slice: Slice): SliceFlowInfo[];
|
|
34
|
-
export declare function getOutboundFlows(model: EventModel, slice: Slice): SliceFlowInfo[];
|
|
35
|
-
export declare function getInternalFlows(model: EventModel, slice: Slice): FlowInfo[];
|
|
36
|
-
export declare function getFlowsForElement(model: EventModel, elementId: string): {
|
|
37
|
-
incoming: FlowInfo[];
|
|
38
|
-
outgoing: FlowInfo[];
|
|
39
|
-
};
|
|
40
|
-
export interface SliceToSliceFlow {
|
|
41
|
-
fromSlice: {
|
|
42
|
-
id: string;
|
|
43
|
-
name: string;
|
|
44
|
-
};
|
|
45
|
-
toSlice: {
|
|
46
|
-
id: string;
|
|
47
|
-
name: string;
|
|
48
|
-
};
|
|
49
|
-
flows: SliceFlowInfo[];
|
|
50
|
-
}
|
|
51
|
-
export declare function findSliceToSliceFlows(model: EventModel, slices: Slice[]): SliceToSliceFlow[];
|
|
52
|
-
export declare function findChapterInboundFlows(model: EventModel, slices: Slice[]): SliceFlowInfo[];
|
|
53
|
-
export declare function findChapterOutboundFlows(model: EventModel, slices: Slice[]): SliceFlowInfo[];
|
package/dist/lib/flow-utils.js
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
// Resolve a linked copy to its canonical original, or return the ID unchanged if not a copy
|
|
2
|
-
export function resolveToCanonical(model, id) {
|
|
3
|
-
const screen = model.screens.get(id);
|
|
4
|
-
if (screen?.originalNodeId)
|
|
5
|
-
return screen.originalNodeId;
|
|
6
|
-
const event = model.events.get(id);
|
|
7
|
-
if (event?.originalNodeId)
|
|
8
|
-
return event.originalNodeId;
|
|
9
|
-
const readModel = model.readModels.get(id);
|
|
10
|
-
if (readModel?.originalNodeId)
|
|
11
|
-
return readModel.originalNodeId;
|
|
12
|
-
return id;
|
|
13
|
-
}
|
|
14
|
-
// Get element info (name and type) by ID
|
|
15
|
-
export function getElementInfo(model, id) {
|
|
16
|
-
const screen = model.screens.get(id);
|
|
17
|
-
if (screen)
|
|
18
|
-
return { id, name: screen.name, type: 'screen' };
|
|
19
|
-
const command = model.commands.get(id);
|
|
20
|
-
if (command)
|
|
21
|
-
return { id, name: command.name, type: 'command' };
|
|
22
|
-
const event = model.events.get(id);
|
|
23
|
-
if (event)
|
|
24
|
-
return { id, name: event.name, type: 'event' };
|
|
25
|
-
const readModel = model.readModels.get(id);
|
|
26
|
-
if (readModel)
|
|
27
|
-
return { id, name: readModel.name, type: 'read-model' };
|
|
28
|
-
const processor = model.processors.get(id);
|
|
29
|
-
if (processor)
|
|
30
|
-
return { id, name: processor.name, type: 'processor' };
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
// Get fields for an element
|
|
34
|
-
function getElementFields(model, id) {
|
|
35
|
-
return (model.screens.get(id)?.fields ??
|
|
36
|
-
model.commands.get(id)?.fields ??
|
|
37
|
-
model.events.get(id)?.fields ??
|
|
38
|
-
model.readModels.get(id)?.fields ??
|
|
39
|
-
model.processors.get(id)?.fields ??
|
|
40
|
-
[]);
|
|
41
|
-
}
|
|
42
|
-
// Find a field by ID in a fields array (recursive for subfields)
|
|
43
|
-
function findFieldById(fields, fieldId) {
|
|
44
|
-
for (const field of fields) {
|
|
45
|
-
if (field.id === fieldId)
|
|
46
|
-
return field;
|
|
47
|
-
if (field.subfields) {
|
|
48
|
-
const found = findFieldById(field.subfields, fieldId);
|
|
49
|
-
if (found)
|
|
50
|
-
return found;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
// Enrich field mappings with field names
|
|
56
|
-
function enrichFieldMappings(model, flow) {
|
|
57
|
-
const sourceFields = getElementFields(model, flow.sourceId);
|
|
58
|
-
const targetFields = getElementFields(model, flow.targetId);
|
|
59
|
-
return flow.fieldMappings.map(mapping => {
|
|
60
|
-
const sourceField = findFieldById(sourceFields, mapping.sourceFieldId);
|
|
61
|
-
const targetField = findFieldById(targetFields, mapping.targetFieldId);
|
|
62
|
-
return {
|
|
63
|
-
from: sourceField?.name ?? 'unknown',
|
|
64
|
-
to: targetField?.name ?? 'unknown',
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// Check if an element's center point is within a slice's bounds
|
|
69
|
-
function isElementInSlice(slice, position, width, height) {
|
|
70
|
-
const centerX = position.x + width / 2;
|
|
71
|
-
const centerY = position.y + height / 2;
|
|
72
|
-
return (centerX >= slice.position.x &&
|
|
73
|
-
centerX <= slice.position.x + slice.size.width &&
|
|
74
|
-
centerY >= slice.position.y &&
|
|
75
|
-
centerY <= slice.position.y + slice.size.height);
|
|
76
|
-
}
|
|
77
|
-
// Get all component IDs in a slice (excludes linked copies - they are UI-only)
|
|
78
|
-
export function getSliceComponentIds(model, slice) {
|
|
79
|
-
const ids = new Set();
|
|
80
|
-
// Only include canonical elements (not linked copies) that are spatially in the slice
|
|
81
|
-
for (const screen of model.screens.values()) {
|
|
82
|
-
if (!screen.originalNodeId && isElementInSlice(slice, screen.position, screen.width, screen.height)) {
|
|
83
|
-
ids.add(screen.id);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
for (const command of model.commands.values()) {
|
|
87
|
-
if (isElementInSlice(slice, command.position, command.width, command.height)) {
|
|
88
|
-
ids.add(command.id);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
for (const event of model.events.values()) {
|
|
92
|
-
if (!event.originalNodeId && isElementInSlice(slice, event.position, event.width, event.height)) {
|
|
93
|
-
ids.add(event.id);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
for (const readModel of model.readModels.values()) {
|
|
97
|
-
if (!readModel.originalNodeId && isElementInSlice(slice, readModel.position, readModel.width, readModel.height)) {
|
|
98
|
-
ids.add(readModel.id);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
for (const processor of model.processors.values()) {
|
|
102
|
-
if (isElementInSlice(slice, processor.position, processor.width, processor.height)) {
|
|
103
|
-
ids.add(processor.id);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return ids;
|
|
107
|
-
}
|
|
108
|
-
// Find which slice contains a component
|
|
109
|
-
export function findSliceForComponent(model, componentId) {
|
|
110
|
-
// Get element position and size
|
|
111
|
-
let position = null;
|
|
112
|
-
let width = 0;
|
|
113
|
-
let height = 0;
|
|
114
|
-
const screen = model.screens.get(componentId);
|
|
115
|
-
if (screen) {
|
|
116
|
-
position = screen.position;
|
|
117
|
-
width = screen.width;
|
|
118
|
-
height = screen.height;
|
|
119
|
-
}
|
|
120
|
-
const command = model.commands.get(componentId);
|
|
121
|
-
if (command) {
|
|
122
|
-
position = command.position;
|
|
123
|
-
width = command.width;
|
|
124
|
-
height = command.height;
|
|
125
|
-
}
|
|
126
|
-
const event = model.events.get(componentId);
|
|
127
|
-
if (event) {
|
|
128
|
-
position = event.position;
|
|
129
|
-
width = event.width;
|
|
130
|
-
height = event.height;
|
|
131
|
-
}
|
|
132
|
-
const readModel = model.readModels.get(componentId);
|
|
133
|
-
if (readModel) {
|
|
134
|
-
position = readModel.position;
|
|
135
|
-
width = readModel.width;
|
|
136
|
-
height = readModel.height;
|
|
137
|
-
}
|
|
138
|
-
const processor = model.processors.get(componentId);
|
|
139
|
-
if (processor) {
|
|
140
|
-
position = processor.position;
|
|
141
|
-
width = processor.width;
|
|
142
|
-
height = processor.height;
|
|
143
|
-
}
|
|
144
|
-
if (!position)
|
|
145
|
-
return null;
|
|
146
|
-
for (const slice of model.slices.values()) {
|
|
147
|
-
if (isElementInSlice(slice, position, width, height)) {
|
|
148
|
-
return slice;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
// Build FlowInfo from a Flow (resolves linked copies to their canonical originals)
|
|
154
|
-
function buildFlowInfo(model, flow) {
|
|
155
|
-
// Resolve linked copies to canonical originals
|
|
156
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
157
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
158
|
-
const source = getElementInfo(model, canonicalSourceId);
|
|
159
|
-
const target = getElementInfo(model, canonicalTargetId);
|
|
160
|
-
if (!source || !target)
|
|
161
|
-
return null;
|
|
162
|
-
return {
|
|
163
|
-
flowId: flow.id,
|
|
164
|
-
flowType: flow.flowType,
|
|
165
|
-
source,
|
|
166
|
-
target,
|
|
167
|
-
fieldMappings: enrichFieldMappings(model, flow),
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
// Build SliceFlowInfo from a Flow (includes slice info for source/target, resolves linked copies)
|
|
171
|
-
function buildSliceFlowInfo(model, flow) {
|
|
172
|
-
const base = buildFlowInfo(model, flow);
|
|
173
|
-
if (!base)
|
|
174
|
-
return null;
|
|
175
|
-
// Resolve linked copies to canonical originals for slice lookup
|
|
176
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
177
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
178
|
-
const sourceSlice = findSliceForComponent(model, canonicalSourceId);
|
|
179
|
-
const targetSlice = findSliceForComponent(model, canonicalTargetId);
|
|
180
|
-
return {
|
|
181
|
-
...base,
|
|
182
|
-
sourceSlice: sourceSlice ? { id: sourceSlice.id, name: sourceSlice.name } : undefined,
|
|
183
|
-
targetSlice: targetSlice ? { id: targetSlice.id, name: targetSlice.name } : undefined,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
// Get flows entering a slice (target in slice, source outside)
|
|
187
|
-
export function getInboundFlows(model, slice) {
|
|
188
|
-
const componentIds = getSliceComponentIds(model, slice);
|
|
189
|
-
const flows = [];
|
|
190
|
-
for (const flow of model.flows.values()) {
|
|
191
|
-
// Resolve linked copies to canonical originals for containment check
|
|
192
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
193
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
194
|
-
if (componentIds.has(canonicalTargetId) && !componentIds.has(canonicalSourceId)) {
|
|
195
|
-
const flowInfo = buildSliceFlowInfo(model, flow);
|
|
196
|
-
if (flowInfo)
|
|
197
|
-
flows.push(flowInfo);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return flows;
|
|
201
|
-
}
|
|
202
|
-
// Get flows leaving a slice (source in slice, target outside)
|
|
203
|
-
export function getOutboundFlows(model, slice) {
|
|
204
|
-
const componentIds = getSliceComponentIds(model, slice);
|
|
205
|
-
const flows = [];
|
|
206
|
-
for (const flow of model.flows.values()) {
|
|
207
|
-
// Resolve linked copies to canonical originals for containment check
|
|
208
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
209
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
210
|
-
if (componentIds.has(canonicalSourceId) && !componentIds.has(canonicalTargetId)) {
|
|
211
|
-
const flowInfo = buildSliceFlowInfo(model, flow);
|
|
212
|
-
if (flowInfo)
|
|
213
|
-
flows.push(flowInfo);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return flows;
|
|
217
|
-
}
|
|
218
|
-
// Get flows within a slice (both source and target in slice)
|
|
219
|
-
export function getInternalFlows(model, slice) {
|
|
220
|
-
const componentIds = getSliceComponentIds(model, slice);
|
|
221
|
-
const flows = [];
|
|
222
|
-
for (const flow of model.flows.values()) {
|
|
223
|
-
// Resolve linked copies to canonical originals for containment check
|
|
224
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
225
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
226
|
-
if (componentIds.has(canonicalSourceId) && componentIds.has(canonicalTargetId)) {
|
|
227
|
-
const flowInfo = buildFlowInfo(model, flow);
|
|
228
|
-
if (flowInfo)
|
|
229
|
-
flows.push(flowInfo);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return flows;
|
|
233
|
-
}
|
|
234
|
-
// Get all flows for a specific element (both directions, resolves linked copies)
|
|
235
|
-
export function getFlowsForElement(model, elementId) {
|
|
236
|
-
const incoming = [];
|
|
237
|
-
const outgoing = [];
|
|
238
|
-
// Resolve element ID to canonical if it's a linked copy
|
|
239
|
-
const canonicalElementId = resolveToCanonical(model, elementId);
|
|
240
|
-
for (const flow of model.flows.values()) {
|
|
241
|
-
// Resolve flow endpoints to canonical originals
|
|
242
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
243
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
244
|
-
if (canonicalTargetId === canonicalElementId) {
|
|
245
|
-
const flowInfo = buildFlowInfo(model, flow);
|
|
246
|
-
if (flowInfo)
|
|
247
|
-
incoming.push(flowInfo);
|
|
248
|
-
}
|
|
249
|
-
if (canonicalSourceId === canonicalElementId) {
|
|
250
|
-
const flowInfo = buildFlowInfo(model, flow);
|
|
251
|
-
if (flowInfo)
|
|
252
|
-
outgoing.push(flowInfo);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return { incoming, outgoing };
|
|
256
|
-
}
|
|
257
|
-
export function findSliceToSliceFlows(model, slices) {
|
|
258
|
-
const sliceMap = new Map(slices.map(s => [s.id, s]));
|
|
259
|
-
const sliceComponentMap = new Map();
|
|
260
|
-
// Build component ID sets for each slice
|
|
261
|
-
for (const slice of slices) {
|
|
262
|
-
sliceComponentMap.set(slice.id, getSliceComponentIds(model, slice));
|
|
263
|
-
}
|
|
264
|
-
// Group flows by slice pair
|
|
265
|
-
const flowsBySlicePair = new Map();
|
|
266
|
-
for (const flow of model.flows.values()) {
|
|
267
|
-
// Resolve linked copies to canonical originals
|
|
268
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
269
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
270
|
-
let sourceSliceId = null;
|
|
271
|
-
let targetSliceId = null;
|
|
272
|
-
// Find which slice contains source and target
|
|
273
|
-
for (const [sliceId, componentIds] of sliceComponentMap.entries()) {
|
|
274
|
-
if (componentIds.has(canonicalSourceId))
|
|
275
|
-
sourceSliceId = sliceId;
|
|
276
|
-
if (componentIds.has(canonicalTargetId))
|
|
277
|
-
targetSliceId = sliceId;
|
|
278
|
-
}
|
|
279
|
-
// Only include flows between different slices in our set
|
|
280
|
-
if (sourceSliceId && targetSliceId && sourceSliceId !== targetSliceId) {
|
|
281
|
-
const key = `${sourceSliceId}:${targetSliceId}`;
|
|
282
|
-
const flowInfo = buildSliceFlowInfo(model, flow);
|
|
283
|
-
if (flowInfo) {
|
|
284
|
-
if (!flowsBySlicePair.has(key)) {
|
|
285
|
-
flowsBySlicePair.set(key, []);
|
|
286
|
-
}
|
|
287
|
-
flowsBySlicePair.get(key).push(flowInfo);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
// Convert to result format
|
|
292
|
-
const result = [];
|
|
293
|
-
for (const [key, flows] of flowsBySlicePair.entries()) {
|
|
294
|
-
const [fromId, toId] = key.split(':');
|
|
295
|
-
const fromSlice = sliceMap.get(fromId);
|
|
296
|
-
const toSlice = sliceMap.get(toId);
|
|
297
|
-
if (fromSlice && toSlice) {
|
|
298
|
-
result.push({
|
|
299
|
-
fromSlice: { id: fromSlice.id, name: fromSlice.name },
|
|
300
|
-
toSlice: { id: toSlice.id, name: toSlice.name },
|
|
301
|
-
flows,
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return result;
|
|
306
|
-
}
|
|
307
|
-
// Find flows entering a chapter (target in chapter slices, source outside)
|
|
308
|
-
export function findChapterInboundFlows(model, slices) {
|
|
309
|
-
const chapterComponentIds = new Set();
|
|
310
|
-
for (const slice of slices) {
|
|
311
|
-
for (const id of getSliceComponentIds(model, slice)) {
|
|
312
|
-
chapterComponentIds.add(id);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
const flows = [];
|
|
316
|
-
for (const flow of model.flows.values()) {
|
|
317
|
-
// Resolve linked copies to canonical originals
|
|
318
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
319
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
320
|
-
if (chapterComponentIds.has(canonicalTargetId) && !chapterComponentIds.has(canonicalSourceId)) {
|
|
321
|
-
const flowInfo = buildSliceFlowInfo(model, flow);
|
|
322
|
-
if (flowInfo)
|
|
323
|
-
flows.push(flowInfo);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return flows;
|
|
327
|
-
}
|
|
328
|
-
// Find flows leaving a chapter (source in chapter slices, target outside)
|
|
329
|
-
export function findChapterOutboundFlows(model, slices) {
|
|
330
|
-
const chapterComponentIds = new Set();
|
|
331
|
-
for (const slice of slices) {
|
|
332
|
-
for (const id of getSliceComponentIds(model, slice)) {
|
|
333
|
-
chapterComponentIds.add(id);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const flows = [];
|
|
337
|
-
for (const flow of model.flows.values()) {
|
|
338
|
-
// Resolve linked copies to canonical originals
|
|
339
|
-
const canonicalSourceId = resolveToCanonical(model, flow.sourceId);
|
|
340
|
-
const canonicalTargetId = resolveToCanonical(model, flow.targetId);
|
|
341
|
-
if (chapterComponentIds.has(canonicalSourceId) && !chapterComponentIds.has(canonicalTargetId)) {
|
|
342
|
-
const flowInfo = buildSliceFlowInfo(model, flow);
|
|
343
|
-
if (flowInfo)
|
|
344
|
-
flows.push(flowInfo);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return flows;
|
|
348
|
-
}
|
package/dist/lib/format.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type OutputFormat = 'xml' | 'json';
|
|
2
|
-
/**
|
|
3
|
-
* Escape string for use in XML attributes (escapes quotes)
|
|
4
|
-
*/
|
|
5
|
-
export declare function escapeXml(str: string): string;
|
|
6
|
-
/**
|
|
7
|
-
* Escape string for use in XML text content (doesn't escape quotes)
|
|
8
|
-
*/
|
|
9
|
-
export declare function escapeXmlText(str: string): string;
|
|
10
|
-
export declare function outputJson(data: unknown): void;
|
package/dist/lib/format.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Escape string for use in XML attributes (escapes quotes)
|
|
3
|
-
*/
|
|
4
|
-
export function escapeXml(str) {
|
|
5
|
-
return str
|
|
6
|
-
.replace(/&/g, '&')
|
|
7
|
-
.replace(/</g, '<')
|
|
8
|
-
.replace(/>/g, '>')
|
|
9
|
-
.replace(/"/g, '"')
|
|
10
|
-
.replace(/'/g, ''');
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Escape string for use in XML text content (doesn't escape quotes)
|
|
14
|
-
*/
|
|
15
|
-
export function escapeXmlText(str) {
|
|
16
|
-
return str
|
|
17
|
-
.replace(/&/g, '&')
|
|
18
|
-
.replace(/</g, '<')
|
|
19
|
-
.replace(/>/g, '>');
|
|
20
|
-
}
|
|
21
|
-
export function outputJson(data) {
|
|
22
|
-
console.log(JSON.stringify(data, null, 2));
|
|
23
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type ProjectConfig = {
|
|
2
|
-
type: 'cloud';
|
|
3
|
-
modelId: string;
|
|
4
|
-
modelName: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Find .eventmodeler.json by walking up from cwd to find the repo root.
|
|
8
|
-
* Returns the path to the config file if found, null otherwise.
|
|
9
|
-
*/
|
|
10
|
-
export declare function findProjectConfigPath(startDir?: string): string | null;
|
|
11
|
-
/**
|
|
12
|
-
* Load the project config from the nearest .eventmodeler.json file.
|
|
13
|
-
*/
|
|
14
|
-
export declare function loadProjectConfig(startDir?: string): ProjectConfig | null;
|
|
15
|
-
/**
|
|
16
|
-
* Save a project config to the current directory or specified path.
|
|
17
|
-
*/
|
|
18
|
-
export declare function saveProjectConfig(config: ProjectConfig, targetDir?: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Get the project root directory (where .eventmodeler.json is or should be).
|
|
21
|
-
* Falls back to git root or current directory.
|
|
22
|
-
*/
|
|
23
|
-
export declare function getProjectRoot(startDir?: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Check if the current directory is within a project with .eventmodeler.json.
|
|
26
|
-
*/
|
|
27
|
-
export declare function isInProject(startDir?: string): boolean;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export interface FieldInput {
|
|
2
|
-
name: string;
|
|
3
|
-
type: string;
|
|
4
|
-
isList?: boolean;
|
|
5
|
-
isGenerated?: boolean;
|
|
6
|
-
isOptional?: boolean;
|
|
7
|
-
isUserInput?: boolean;
|
|
8
|
-
subfields?: FieldInput[];
|
|
9
|
-
}
|
|
10
|
-
export declare function parseFieldsFromXml(xml: string): FieldInput[];
|
|
11
|
-
export interface StateChangeSliceInput {
|
|
12
|
-
sliceName: string;
|
|
13
|
-
after?: string;
|
|
14
|
-
before?: string;
|
|
15
|
-
screen: {
|
|
16
|
-
name: string;
|
|
17
|
-
fields: FieldInput[];
|
|
18
|
-
};
|
|
19
|
-
command: {
|
|
20
|
-
name: string;
|
|
21
|
-
fields: FieldInput[];
|
|
22
|
-
};
|
|
23
|
-
event: {
|
|
24
|
-
name: string;
|
|
25
|
-
fields: FieldInput[];
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export declare function parseStateChangeSliceXml(xml: string): StateChangeSliceInput;
|
|
29
|
-
export interface AutomationSliceInput {
|
|
30
|
-
sliceName: string;
|
|
31
|
-
after?: string;
|
|
32
|
-
before?: string;
|
|
33
|
-
readModel: {
|
|
34
|
-
name: string;
|
|
35
|
-
fields: FieldInput[];
|
|
36
|
-
};
|
|
37
|
-
processor: {
|
|
38
|
-
name: string;
|
|
39
|
-
};
|
|
40
|
-
command: {
|
|
41
|
-
name: string;
|
|
42
|
-
fields: FieldInput[];
|
|
43
|
-
};
|
|
44
|
-
event: {
|
|
45
|
-
name: string;
|
|
46
|
-
fields: FieldInput[];
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export declare function parseAutomationSliceXml(xml: string): AutomationSliceInput;
|
|
50
|
-
export interface StateViewSliceInput {
|
|
51
|
-
sliceName: string;
|
|
52
|
-
after?: string;
|
|
53
|
-
before?: string;
|
|
54
|
-
readModel: {
|
|
55
|
-
name: string;
|
|
56
|
-
fields: FieldInput[];
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export declare function parseStateViewSliceXml(xml: string): StateViewSliceInput;
|