refactor: expose plugin lookup table normalizer

This commit is contained in:
Shakker
2026-04-27 07:11:32 +01:00
parent 354eb37ff5
commit 635af612d5
2 changed files with 6 additions and 1 deletions

View File

@@ -98,7 +98,7 @@ describe("loadPluginLookUpTable", () => {
createManifestRecord({
id: "openai",
origin: "bundled",
providers: ["openai"],
providers: ["openai", "openai-codex"],
cliBackends: ["codex-cli"],
setup: {
providers: [{ id: "openai" }],
@@ -128,6 +128,7 @@ describe("loadPluginLookUpTable", () => {
expect(table.manifestRegistry).toBe(manifestRegistry);
expect(table.byPluginId.get("telegram")?.id).toBe("telegram");
expect(table.normalizePluginId("openai-codex")).toBe("openai");
expect(table.owners.channels.get("telegram")).toEqual(["telegram"]);
expect(table.owners.providers.get("openai")).toEqual(["openai"]);
expect(table.owners.cliBackends.get("codex-cli")).toEqual(["openai"]);

View File

@@ -9,6 +9,7 @@ import { loadPluginManifestRegistryForInstalledIndex } from "./manifest-registry
import type { PluginManifestRecord, PluginManifestRegistry } from "./manifest-registry.js";
import type { PluginDiagnostic } from "./manifest-types.js";
import {
createPluginRegistryIdNormalizer,
loadPluginRegistrySnapshotWithMetadata,
type PluginRegistrySnapshot,
type PluginRegistrySnapshotDiagnostic,
@@ -35,6 +36,7 @@ export type PluginLookUpTable = {
plugins: readonly PluginManifestRecord[];
diagnostics: readonly PluginDiagnostic[];
byPluginId: ReadonlyMap<string, PluginManifestRecord>;
normalizePluginId: (pluginId: string) => string;
owners: PluginLookUpTableOwnerMaps;
startup: PluginLookUpTableStartupPlan;
};
@@ -122,6 +124,7 @@ export function loadPluginLookUpTable(params: LoadPluginLookUpTableParams): Plug
index,
manifestRegistry,
});
const normalizePluginId = createPluginRegistryIdNormalizer(index, { manifestRegistry });
const byPluginId = new Map(manifestRegistry.plugins.map((plugin) => [plugin.id, plugin]));
const owners = buildOwnerMaps(manifestRegistry.plugins);
const startup = {
@@ -147,6 +150,7 @@ export function loadPluginLookUpTable(params: LoadPluginLookUpTableParams): Plug
plugins: manifestRegistry.plugins,
diagnostics: [...index.diagnostics, ...manifestRegistry.diagnostics],
byPluginId,
normalizePluginId,
owners,
startup,
};