flowspec-mcp 4.1.0 → 4.2.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/README.md +4 -159
- package/dist/db.d.ts +0 -26
- package/dist/db.js +396 -318
- package/dist/db.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/server.js +7 -26
- package/dist/server.js.map +1 -1
- package/dist/tools/createEdge.d.ts +4 -4
- package/dist/tools/createNode.d.ts +2 -2
- package/dist/tools/deleteEdge.js +4 -20
- package/dist/tools/deleteEdge.js.map +1 -1
- package/dist/tools/deleteNode.js +4 -20
- package/dist/tools/deleteNode.js.map +1 -1
- package/dist/tools/updateEdge.d.ts +2 -2
- package/dist/tools/updateEdge.js +3 -19
- package/dist/tools/updateEdge.js.map +1 -1
- package/dist/tools/updateNode.d.ts +2 -2
- package/dist/tools/updateNode.js +5 -21
- package/dist/tools/updateNode.js.map +1 -1
- package/dist/tools/updateProject.d.ts +2 -2
- package/dist/types.d.ts +0 -12
- package/package.json +2 -2
- package/dist/analysis/analysisUtils.d.ts +0 -36
- package/dist/analysis/analysisUtils.js +0 -284
- package/dist/analysis/analysisUtils.js.map +0 -1
- package/dist/export/jsonExporter.d.ts +0 -17
- package/dist/export/jsonExporter.js +0 -176
- package/dist/export/jsonExporter.js.map +0 -1
- package/dist/layout/semanticLayout.d.ts +0 -24
- package/dist/layout/semanticLayout.js +0 -233
- package/dist/layout/semanticLayout.js.map +0 -1
- package/dist/resources/selection.d.ts +0 -5
- package/dist/resources/selection.js +0 -88
- package/dist/resources/selection.js.map +0 -1
- package/dist/tools/captureScreen.d.ts +0 -48
- package/dist/tools/captureScreen.js +0 -135
- package/dist/tools/captureScreen.js.map +0 -1
- package/dist/tools/createSubview.d.ts +0 -50
- package/dist/tools/createSubview.js +0 -29
- package/dist/tools/createSubview.js.map +0 -1
- package/dist/tools/deleteSubview.d.ts +0 -24
- package/dist/tools/deleteSubview.js +0 -19
- package/dist/tools/deleteSubview.js.map +0 -1
- package/dist/tools/generateSpec.d.ts +0 -26
- package/dist/tools/generateSpec.js +0 -336
- package/dist/tools/generateSpec.js.map +0 -1
- package/dist/tools/getJson.d.ts +0 -21
- package/dist/tools/getJson.js +0 -24
- package/dist/tools/getJson.js.map +0 -1
- package/dist/tools/healthCheck.d.ts +0 -8
- package/dist/tools/healthCheck.js +0 -16
- package/dist/tools/healthCheck.js.map +0 -1
- package/dist/tools/ingestCodebase.d.ts +0 -27
- package/dist/tools/ingestCodebase.js +0 -516
- package/dist/tools/ingestCodebase.js.map +0 -1
- package/dist/tools/listSubviews.d.ts +0 -21
- package/dist/tools/listSubviews.js +0 -34
- package/dist/tools/listSubviews.js.map +0 -1
- package/dist/tools/smartLayout.d.ts +0 -30
- package/dist/tools/smartLayout.js +0 -74
- package/dist/tools/smartLayout.js.map +0 -1
- package/dist/tools/updateSubview.d.ts +0 -53
- package/dist/tools/updateSubview.js +0 -33
- package/dist/tools/updateSubview.js.map +0 -1
- package/dist/utils/selectionHelper.d.ts +0 -61
- package/dist/utils/selectionHelper.js +0 -111
- package/dist/utils/selectionHelper.js.map +0 -1
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { getProject, updateProjectViaApi } from '../db.js';
|
|
3
|
-
import { parseNaturalLanguageLayout, applySemanticLayout, SUPPORTED_COMMANDS, SUPPORTED_REGIONS } from '../layout/semanticLayout.js';
|
|
4
|
-
export const smartLayoutSchema = z.object({
|
|
5
|
-
projectId: z.string().describe('UUID of the project to apply smart layout to'),
|
|
6
|
-
command: z.string().describe(`Natural language layout command. Examples: ${SUPPORTED_COMMANDS.slice(0, 3).join('; ')}. ` +
|
|
7
|
-
`Supported regions: ${SUPPORTED_REGIONS.slice(0, 5).join(', ')}, etc.`),
|
|
8
|
-
canvasWidth: z.number().optional().default(2000).describe('Canvas width for region calculation'),
|
|
9
|
-
canvasHeight: z.number().optional().default(2000).describe('Canvas height for region calculation')
|
|
10
|
-
});
|
|
11
|
-
export async function handleSmartLayout(args) {
|
|
12
|
-
const project = await getProject(args.projectId);
|
|
13
|
-
if (!project) {
|
|
14
|
-
return {
|
|
15
|
-
content: [{ type: 'text', text: `Project not found: ${args.projectId}` }],
|
|
16
|
-
isError: true
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const nodes = project.canvas_state?.nodes ?? [];
|
|
20
|
-
const edges = project.canvas_state?.edges ?? [];
|
|
21
|
-
if (nodes.length === 0) {
|
|
22
|
-
return {
|
|
23
|
-
content: [{ type: 'text', text: `Project has no nodes to layout.` }],
|
|
24
|
-
isError: true
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
// Parse natural language command
|
|
28
|
-
const layoutCommand = parseNaturalLanguageLayout(args.command, nodes, { width: args.canvasWidth, height: args.canvasHeight });
|
|
29
|
-
if ('error' in layoutCommand) {
|
|
30
|
-
return {
|
|
31
|
-
content: [{ type: 'text', text: `Layout parsing error: ${layoutCommand.error}` }],
|
|
32
|
-
isError: true
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
// Apply semantic layout
|
|
36
|
-
const newPositions = applySemanticLayout(nodes, edges, layoutCommand);
|
|
37
|
-
if (newPositions.size === 0) {
|
|
38
|
-
return {
|
|
39
|
-
content: [{ type: 'text', text: `No nodes matched the layout command.` }],
|
|
40
|
-
isError: true
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// Update node positions
|
|
44
|
-
let updatedCount = 0;
|
|
45
|
-
for (const node of nodes) {
|
|
46
|
-
const newPos = newPositions.get(node.id);
|
|
47
|
-
if (newPos) {
|
|
48
|
-
node.position = newPos;
|
|
49
|
-
updatedCount++;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Save project
|
|
53
|
-
await updateProjectViaApi(args.projectId, { canvas_state: project.canvas_state });
|
|
54
|
-
// Format result
|
|
55
|
-
const affectedLabels = nodes
|
|
56
|
-
.filter((n) => newPositions.has(n.id))
|
|
57
|
-
.map((n) => n.data?.label ?? 'Untitled')
|
|
58
|
-
.join(', ');
|
|
59
|
-
return {
|
|
60
|
-
content: [
|
|
61
|
-
{
|
|
62
|
-
type: 'text',
|
|
63
|
-
text: [
|
|
64
|
-
`✅ Smart layout applied to ${updatedCount} node(s).`,
|
|
65
|
-
`Command: "${args.command}"`,
|
|
66
|
-
`Arrangement: ${layoutCommand.arrangement}${layoutCommand.direction ? ` (${layoutCommand.direction})` : ''}`,
|
|
67
|
-
`Region: (${layoutCommand.targetBounds.x}, ${layoutCommand.targetBounds.y})`,
|
|
68
|
-
`Nodes: ${affectedLabels}`
|
|
69
|
-
].join('\n')
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=smartLayout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smartLayout.js","sourceRoot":"","sources":["../../src/tools/smartLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EACN,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;IAC9E,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAC3B,8CAA8C,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;QAC3F,sBAAsB,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CACtE;IACD,WAAW,EAAE,CAAC,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AW,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBAC5G,YAAY,aAAa,CAAC,YAAY,CAAC,CAAC,KAAK,aAAa,CAAC,YAAY,CAAC,CAAC,GAAG;oBAC5E,UAAU,cAAc,EAAE;iBAC1B,CAAC,IAAI,CAAC,IAAI,CAAC;aACZ;SACD;KACD,CAAC;AACH,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const updateSubviewSchema: z.ZodObject<{
|
|
3
|
-
projectId: z.ZodString;
|
|
4
|
-
subviewId: z.ZodString;
|
|
5
|
-
name: z.ZodOptional<z.ZodString>;
|
|
6
|
-
description: z.ZodOptional<z.ZodString>;
|
|
7
|
-
nodePositions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
8
|
-
nodeId: z.ZodString;
|
|
9
|
-
x: z.ZodNumber;
|
|
10
|
-
y: z.ZodNumber;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
nodeId: string;
|
|
15
|
-
}, {
|
|
16
|
-
x: number;
|
|
17
|
-
y: number;
|
|
18
|
-
nodeId: string;
|
|
19
|
-
}>, "many">>;
|
|
20
|
-
}, "strip", z.ZodTypeAny, {
|
|
21
|
-
projectId: string;
|
|
22
|
-
subviewId: string;
|
|
23
|
-
name?: string | undefined;
|
|
24
|
-
description?: string | undefined;
|
|
25
|
-
nodePositions?: {
|
|
26
|
-
x: number;
|
|
27
|
-
y: number;
|
|
28
|
-
nodeId: string;
|
|
29
|
-
}[] | undefined;
|
|
30
|
-
}, {
|
|
31
|
-
projectId: string;
|
|
32
|
-
subviewId: string;
|
|
33
|
-
name?: string | undefined;
|
|
34
|
-
description?: string | undefined;
|
|
35
|
-
nodePositions?: {
|
|
36
|
-
x: number;
|
|
37
|
-
y: number;
|
|
38
|
-
nodeId: string;
|
|
39
|
-
}[] | undefined;
|
|
40
|
-
}>;
|
|
41
|
-
export declare function handleUpdateSubview(args: z.infer<typeof updateSubviewSchema>): Promise<{
|
|
42
|
-
content: {
|
|
43
|
-
type: "text";
|
|
44
|
-
text: string;
|
|
45
|
-
}[];
|
|
46
|
-
isError: boolean;
|
|
47
|
-
} | {
|
|
48
|
-
content: {
|
|
49
|
-
type: "text";
|
|
50
|
-
text: string;
|
|
51
|
-
}[];
|
|
52
|
-
isError?: undefined;
|
|
53
|
-
}>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { updateSubviewViaApi } from '../db.js';
|
|
3
|
-
export const updateSubviewSchema = z.object({
|
|
4
|
-
projectId: z.string().describe('UUID of the project'),
|
|
5
|
-
subviewId: z.string().describe('UUID of the subview to update'),
|
|
6
|
-
name: z.string().optional().describe('New subview name'),
|
|
7
|
-
description: z.string().optional().describe('New subview description'),
|
|
8
|
-
nodePositions: z.array(z.object({
|
|
9
|
-
nodeId: z.string().describe('Node ID from the main canvas'),
|
|
10
|
-
x: z.number().describe('X position in subview canvas'),
|
|
11
|
-
y: z.number().describe('Y position in subview canvas'),
|
|
12
|
-
})).optional().describe('Updated node positions (replaces all existing positions)'),
|
|
13
|
-
});
|
|
14
|
-
export async function handleUpdateSubview(args) {
|
|
15
|
-
const updates = {};
|
|
16
|
-
if (args.name !== undefined)
|
|
17
|
-
updates.name = args.name;
|
|
18
|
-
if (args.description !== undefined)
|
|
19
|
-
updates.description = args.description;
|
|
20
|
-
if (args.nodePositions !== undefined)
|
|
21
|
-
updates.nodePositions = args.nodePositions;
|
|
22
|
-
const subview = await updateSubviewViaApi(args.projectId, args.subviewId, updates);
|
|
23
|
-
if (!subview) {
|
|
24
|
-
return {
|
|
25
|
-
content: [{ type: 'text', text: `Subview or project not found: ${args.subviewId}` }],
|
|
26
|
-
isError: true,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
content: [{ type: 'text', text: `Updated subview ${args.subviewId}` }],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=updateSubview.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updateSubview.js","sourceRoot":"","sources":["../../src/tools/updateSubview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACrD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IAC/D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IACxD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IACtE,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;QAC3D,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;QACtD,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;KACvD,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;CACpF,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAyC;IACjF,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACtD,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS;QAAE,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IAC3E,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS;QAAE,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;IAEjF,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEnF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,iCAAiC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;YAC7F,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,mBAAmB,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;KAChF,CAAC;AACJ,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Selection state from desktop server
|
|
3
|
-
*/
|
|
4
|
-
interface SelectionState {
|
|
5
|
-
type: 'none' | 'selection';
|
|
6
|
-
timestamp: string;
|
|
7
|
-
projectId?: string;
|
|
8
|
-
projectName?: string;
|
|
9
|
-
selectedNodes?: Array<{
|
|
10
|
-
id: string;
|
|
11
|
-
type: string;
|
|
12
|
-
label: string;
|
|
13
|
-
position: {
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
-
};
|
|
17
|
-
data: Record<string, unknown>;
|
|
18
|
-
}>;
|
|
19
|
-
selectedEdges?: Array<{
|
|
20
|
-
id: string;
|
|
21
|
-
source: string;
|
|
22
|
-
target: string;
|
|
23
|
-
edgeType: string;
|
|
24
|
-
label?: string;
|
|
25
|
-
sourceHandle?: string;
|
|
26
|
-
targetHandle?: string;
|
|
27
|
-
}>;
|
|
28
|
-
viewport?: {
|
|
29
|
-
x: number;
|
|
30
|
-
y: number;
|
|
31
|
-
zoom: number;
|
|
32
|
-
};
|
|
33
|
-
stale?: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Fetch current selection state from desktop server
|
|
37
|
-
*/
|
|
38
|
-
export declare function fetchCurrentSelection(): Promise<SelectionState | null>;
|
|
39
|
-
/**
|
|
40
|
-
* Resolve "current" node ID to the actual selected node ID.
|
|
41
|
-
*
|
|
42
|
-
* @param nodeId - Either a real UUID or the string "current"
|
|
43
|
-
* @param projectId - Optional project ID to validate selection matches
|
|
44
|
-
* @returns The resolved node ID
|
|
45
|
-
* @throws Error if "current" is used but no node is selected, or multiple nodes selected
|
|
46
|
-
*/
|
|
47
|
-
export declare function resolveCurrentNodeId(nodeId: string, projectId?: string): Promise<string>;
|
|
48
|
-
/**
|
|
49
|
-
* Resolve "current" edge ID to the actual selected edge ID.
|
|
50
|
-
*
|
|
51
|
-
* @param edgeId - Either a real UUID or the string "current"
|
|
52
|
-
* @param projectId - Optional project ID to validate selection matches
|
|
53
|
-
* @returns The resolved edge ID
|
|
54
|
-
* @throws Error if "current" is used but no edge is selected, or multiple edges selected
|
|
55
|
-
*/
|
|
56
|
-
export declare function resolveCurrentEdgeId(edgeId: string, projectId?: string): Promise<string>;
|
|
57
|
-
/**
|
|
58
|
-
* Get information about the current selection for user-friendly error messages.
|
|
59
|
-
*/
|
|
60
|
-
export declare function getSelectionSummary(): Promise<string>;
|
|
61
|
-
export {};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { MODE, LOCAL_API_BASE, getLocalAuthToken } from '../config.js';
|
|
2
|
-
/**
|
|
3
|
-
* Fetch current selection state from desktop server
|
|
4
|
-
*/
|
|
5
|
-
export async function fetchCurrentSelection() {
|
|
6
|
-
if (MODE !== 'local') {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
const token = getLocalAuthToken();
|
|
11
|
-
const headers = {
|
|
12
|
-
'Content-Type': 'application/json',
|
|
13
|
-
};
|
|
14
|
-
if (token) {
|
|
15
|
-
headers['Authorization'] = `Bearer ${token}`;
|
|
16
|
-
}
|
|
17
|
-
const res = await fetch(`${LOCAL_API_BASE}/api/selection/current`, {
|
|
18
|
-
headers,
|
|
19
|
-
signal: AbortSignal.timeout(2000)
|
|
20
|
-
});
|
|
21
|
-
if (!res.ok) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return res.json();
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Resolve "current" node ID to the actual selected node ID.
|
|
32
|
-
*
|
|
33
|
-
* @param nodeId - Either a real UUID or the string "current"
|
|
34
|
-
* @param projectId - Optional project ID to validate selection matches
|
|
35
|
-
* @returns The resolved node ID
|
|
36
|
-
* @throws Error if "current" is used but no node is selected, or multiple nodes selected
|
|
37
|
-
*/
|
|
38
|
-
export async function resolveCurrentNodeId(nodeId, projectId) {
|
|
39
|
-
if (nodeId !== 'current') {
|
|
40
|
-
return nodeId;
|
|
41
|
-
}
|
|
42
|
-
const selection = await fetchCurrentSelection();
|
|
43
|
-
if (!selection || selection.type === 'none' || selection.stale) {
|
|
44
|
-
throw new Error('No node currently selected in FlowSpec editor. Please click a node first or provide the node ID explicitly.');
|
|
45
|
-
}
|
|
46
|
-
if (projectId && selection.projectId !== projectId) {
|
|
47
|
-
throw new Error(`Selection is from a different project (${selection.projectName}). Please switch to the correct project or provide the node ID explicitly.`);
|
|
48
|
-
}
|
|
49
|
-
const selectedNodes = selection.selectedNodes || [];
|
|
50
|
-
if (selectedNodes.length === 0) {
|
|
51
|
-
throw new Error('No node currently selected. Please click a node first or provide the node ID explicitly.');
|
|
52
|
-
}
|
|
53
|
-
if (selectedNodes.length > 1) {
|
|
54
|
-
const nodeList = selectedNodes.map(n => `"${n.label}" (${n.id})`).join(', ');
|
|
55
|
-
throw new Error(`Multiple nodes selected: ${nodeList}. Please click a single node or provide the node ID explicitly.`);
|
|
56
|
-
}
|
|
57
|
-
return selectedNodes[0].id;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Resolve "current" edge ID to the actual selected edge ID.
|
|
61
|
-
*
|
|
62
|
-
* @param edgeId - Either a real UUID or the string "current"
|
|
63
|
-
* @param projectId - Optional project ID to validate selection matches
|
|
64
|
-
* @returns The resolved edge ID
|
|
65
|
-
* @throws Error if "current" is used but no edge is selected, or multiple edges selected
|
|
66
|
-
*/
|
|
67
|
-
export async function resolveCurrentEdgeId(edgeId, projectId) {
|
|
68
|
-
if (edgeId !== 'current') {
|
|
69
|
-
return edgeId;
|
|
70
|
-
}
|
|
71
|
-
const selection = await fetchCurrentSelection();
|
|
72
|
-
if (!selection || selection.type === 'none' || selection.stale) {
|
|
73
|
-
throw new Error('No edge currently selected in FlowSpec editor. Please click an edge first or provide the edge ID explicitly.');
|
|
74
|
-
}
|
|
75
|
-
if (projectId && selection.projectId !== projectId) {
|
|
76
|
-
throw new Error(`Selection is from a different project (${selection.projectName}). Please switch to the correct project or provide the edge ID explicitly.`);
|
|
77
|
-
}
|
|
78
|
-
const selectedEdges = selection.selectedEdges || [];
|
|
79
|
-
if (selectedEdges.length === 0) {
|
|
80
|
-
throw new Error('No edge currently selected. Please click an edge first or provide the edge ID explicitly.');
|
|
81
|
-
}
|
|
82
|
-
if (selectedEdges.length > 1) {
|
|
83
|
-
throw new Error(`Multiple edges selected. Please click a single edge or provide the edge ID explicitly.`);
|
|
84
|
-
}
|
|
85
|
-
return selectedEdges[0].id;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Get information about the current selection for user-friendly error messages.
|
|
89
|
-
*/
|
|
90
|
-
export async function getSelectionSummary() {
|
|
91
|
-
const selection = await fetchCurrentSelection();
|
|
92
|
-
if (!selection || selection.type === 'none') {
|
|
93
|
-
return 'No selection';
|
|
94
|
-
}
|
|
95
|
-
if (selection.stale) {
|
|
96
|
-
return 'Selection stale (>60s)';
|
|
97
|
-
}
|
|
98
|
-
const nodeCount = selection.selectedNodes?.length || 0;
|
|
99
|
-
const edgeCount = selection.selectedEdges?.length || 0;
|
|
100
|
-
if (nodeCount > 0 && edgeCount > 0) {
|
|
101
|
-
return `${nodeCount} node(s) and ${edgeCount} edge(s) selected`;
|
|
102
|
-
}
|
|
103
|
-
else if (nodeCount > 0) {
|
|
104
|
-
return `${nodeCount} node(s) selected`;
|
|
105
|
-
}
|
|
106
|
-
else if (edgeCount > 0) {
|
|
107
|
-
return `${edgeCount} edge(s) selected`;
|
|
108
|
-
}
|
|
109
|
-
return 'No selection';
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=selectionHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectionHelper.js","sourceRoot":"","sources":["../../src/utils/selectionHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAkCvE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IAC1C,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,KAAK,GAAG,iBAAiB,EAAE,CAAC;QAClC,MAAM,OAAO,GAA2B;YACvC,cAAc,EAAE,kBAAkB;SAClC,CAAC;QACF,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAC;QAC9C,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,cAAc,wBAAwB,EAAE;YAClE,OAAO;YACP,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAA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