Skip to content

Commit ab7be9a

Browse files
committed
Move registry into its own dir
1 parent 1456229 commit ab7be9a

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { packageInfo } from "./common/packageInfo.js";
2222
import { type ConnectionErrorHandler } from "./common/connectionErrorHandler.js";
2323
import type { Elicitation } from "./elicitation.js";
2424
import { AllTools } from "./tools/index.js";
25-
import { UIRegistry } from "./ui/registry.js";
25+
import { UIRegistry } from "./ui/registry/index.js";
2626

2727
export interface ServerOptions {
2828
session: Session;

src/tools/tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { UserConfig } from "../common/config/userConfig.js";
99
import type { Server } from "../server.js";
1010
import type { Elicitation } from "../elicitation.js";
1111
import type { PreviewFeature } from "../common/schemas.js";
12-
import type { UIRegistry } from "../ui/registry.js";
12+
import type { UIRegistry } from "../ui/registry/index.js";
1313

1414
export type ToolArgs<T extends ZodRawShape> = {
1515
[K in keyof T]: z.infer<T[K]>;

src/ui/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { UIRegistry, getDefaultUIRegistry, setDefaultUIRegistry } from "./registry.js";
1+
export { UIRegistry, getDefaultUIRegistry, setDefaultUIRegistry } from "./registry/index.js";
22
export { useRenderData } from "./hooks/index.js";
33
export { createUIBuildConfig } from "./build/index.js";

src/ui/registry/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { UIRegistry, getDefaultUIRegistry, setDefaultUIRegistry } from "./registry.js";
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readFileSync, existsSync } from "fs";
22
import { join, dirname } from "path";
3+
import { uiMap } from "./uiMap.js";
34

45
/**
56
* Get the default UI dist path by finding the package root.
@@ -19,15 +20,6 @@ function getDefaultUIDistPath(): string {
1920
}
2021
}
2122

22-
/**
23-
* Mapping from tool names to their bundled UI HTML file names
24-
* Tool names use kebab-case (e.g., 'list-databases')
25-
* HTML files use PascalCase (e.g., 'ListDatabases.html')
26-
*/
27-
const TOOL_TO_UI_FILE: Record<string, string> = {
28-
"list-databases": "ListDatabases.html",
29-
};
30-
3123
/**
3224
* UI Registry that manages bundled UI HTML strings for tools.
3325
*
@@ -75,7 +67,7 @@ export class UIRegistry {
7567
* @param toolName The name of the tool
7668
*/
7769
has(toolName: string): boolean {
78-
return this.overrides.has(toolName) || toolName in TOOL_TO_UI_FILE;
70+
return this.overrides.has(toolName) || toolName in uiMap;
7971
}
8072

8173
/**
@@ -91,7 +83,7 @@ export class UIRegistry {
9183
}
9284

9385
// Check if we have a mapping for this tool
94-
const htmlFileName = TOOL_TO_UI_FILE[toolName];
86+
const htmlFileName = uiMap[toolName];
9587
if (!htmlFileName) {
9688
return undefined;
9789
}
@@ -128,7 +120,7 @@ export class UIRegistry {
128120
* Get all registered tool names (both overrides and defaults)
129121
*/
130122
getRegisteredTools(): string[] {
131-
const tools = new Set<string>([...this.overrides.keys(), ...Object.keys(TOOL_TO_UI_FILE)]);
123+
const tools = new Set<string>([...this.overrides.keys(), ...Object.keys(uiMap)]);
132124
return Array.from(tools);
133125
}
134126
}

src/ui/registry/uiMap.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Mapping from tool names to their bundled UI HTML file names
3+
* Tool names use kebab-case (e.g., 'list-databases')
4+
* HTML files use PascalCase (e.g., 'ListDatabases.html')
5+
*/
6+
export const uiMap: Record<string, string> = {
7+
"list-databases": "ListDatabases.html",
8+
};

0 commit comments

Comments
 (0)