Skip to content

Commit f4e9a6e

Browse files
committed
refactor(channels): remove stale bundled channel helpers
1 parent 2ae84f7 commit f4e9a6e

2 files changed

Lines changed: 15 additions & 39 deletions

File tree

src/channels/plugins/bundled.shape-guard.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ afterEach(() => {
197197
describe("bundled channel entry shape guards", () => {
198198
const bundledPluginRoots = listSourceBundledPluginRoots();
199199
let realBundledSourceTreeProbe: {
200-
hasAccountInspect: boolean;
200+
hasAccountInspector: boolean;
201201
pluginIds: readonly string[];
202202
};
203203

@@ -221,7 +221,7 @@ describe("bundled channel entry shape guards", () => {
221221
"./bundled.js?scope=real-bundled-source-tree-preload",
222222
);
223223
realBundledSourceTreeProbe = {
224-
hasAccountInspect: bundled.hasBundledChannelEntryFeature("slack", "accountInspect"),
224+
hasAccountInspector: typeof bundled.getBundledChannelAccountInspector("slack") === "function",
225225
pluginIds: [...bundled.listBundledChannelPluginIds()],
226226
};
227227
});
@@ -256,7 +256,7 @@ describe("bundled channel entry shape guards", () => {
256256

257257
it("loads real bundled channel entry contracts from the source tree", async () => {
258258
expect(realBundledSourceTreeProbe.pluginIds).toEqual(["slack"]);
259-
expect(realBundledSourceTreeProbe.hasAccountInspect).toBe(true);
259+
expect(realBundledSourceTreeProbe.hasAccountInspector).toBe(true);
260260
});
261261

262262
it("fills sparse bundled channel plugin metadata from package metadata", async () => {
@@ -316,12 +316,12 @@ describe("bundled channel entry shape guards", () => {
316316
"./bundled.js?scope=bundled-package-metadata",
317317
);
318318

319-
const plugin = bundled.requireBundledChannelPlugin("alpha");
320-
expect(plugin.meta.id).toBe("alpha");
321-
expect(plugin.meta.label).toBe("Alpha");
322-
expect(plugin.meta.selectionLabel).toBe("Use Alpha");
323-
expect(plugin.meta.docsPath).toBe("/channels/alpha");
324-
expect(plugin.meta.blurb).toBe("Alpha channel metadata.");
319+
const plugin = bundled.getBundledChannelPlugin("alpha");
320+
expect(plugin?.meta.id).toBe("alpha");
321+
expect(plugin?.meta.label).toBe("Alpha");
322+
expect(plugin?.meta.selectionLabel).toBe("Use Alpha");
323+
expect(plugin?.meta.docsPath).toBe("/channels/alpha");
324+
expect(plugin?.meta.blurb).toBe("Alpha channel metadata.");
325325
} finally {
326326
restoreBundledPluginsDir(previousBundledPluginsDir);
327327
fs.rmSync(tempRoot, { recursive: true, force: true });
@@ -392,7 +392,7 @@ describe("bundled channel entry shape guards", () => {
392392
expect(metadataRootDir).toBe(tempRoot);
393393
expect(generatedRootDir).toBe(tempRoot);
394394
expect(testGlobal["__bundledOverrideRuntime"]).toBe("ok");
395-
expect(bundled.requireBundledChannelPlugin("alpha").id).toBe("alpha");
395+
expect(bundled.getBundledChannelPlugin("alpha")?.id).toBe("alpha");
396396
} finally {
397397
restoreBundledPluginsDir(previousBundledPluginsDir);
398398
fs.rmSync(tempRoot, { recursive: true, force: true });
@@ -459,7 +459,7 @@ describe("bundled channel entry shape guards", () => {
459459
"./bundled.js?scope=bundled-package-local-dist-sdk-alias",
460460
);
461461

462-
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Package dist Alpha");
462+
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Package dist Alpha");
463463
} finally {
464464
fs.rmSync(root, { recursive: true, force: true });
465465
}
@@ -514,7 +514,7 @@ describe("bundled channel entry shape guards", () => {
514514
"./bundled.js?scope=bundled-direct-dist-sdk-alias",
515515
);
516516

517-
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Direct dist Alpha");
517+
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Direct dist Alpha");
518518
} finally {
519519
restoreBundledPluginsDir(previousBundledPluginsDir);
520520
fs.rmSync(root, { recursive: true, force: true });
@@ -588,7 +588,7 @@ describe("bundled channel entry shape guards", () => {
588588
expect(generatedRootDir).toBe(pluginsRoot);
589589
expect(generatedScanDir).toBe(pluginsRoot);
590590
expect(testGlobal["__bundledOverrideRuntime"]).toBe("ok");
591-
expect(bundled.requireBundledChannelPlugin("alpha").id).toBe("alpha");
591+
expect(bundled.getBundledChannelPlugin("alpha")?.id).toBe("alpha");
592592
} finally {
593593
restoreBundledPluginsDir(previousBundledPluginsDir);
594594
fs.rmSync(tempRoot, { recursive: true, force: true });
@@ -673,7 +673,7 @@ describe("bundled channel entry shape guards", () => {
673673
);
674674

675675
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = path.join(rootA, "dist", "extensions");
676-
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Alpha A");
676+
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Alpha A");
677677
expect(bundled.getBundledChannelSetupPlugin("alpha")?.meta.label).toBe("Setup A");
678678
expect(bundled.getBundledChannelSecrets("alpha")?.secretTargetRegistryEntries?.[0]?.id).toBe(
679679
"channels.alpha.A.entry-token",
@@ -684,7 +684,7 @@ describe("bundled channel entry shape guards", () => {
684684
bundled.setBundledChannelRuntime("alpha", { marker: "first" } as never);
685685

686686
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = path.join(rootB, "dist", "extensions");
687-
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Alpha B");
687+
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Alpha B");
688688
expect(bundled.getBundledChannelSetupPlugin("alpha")?.meta.label).toBe("Setup B");
689689
expect(bundled.getBundledChannelSecrets("alpha")?.secretTargetRegistryEntries?.[0]?.id).toBe(
690690
"channels.alpha.B.entry-token",

src/channels/plugins/bundled.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,6 @@ function hasSetupEntryFeature(
172172
return entry?.features?.[feature] === true;
173173
}
174174

175-
function hasChannelEntryFeature(
176-
entry: BundledChannelEntryRuntimeContract | undefined,
177-
feature: keyof NonNullable<BundledChannelEntryRuntimeContract["features"]>,
178-
): boolean {
179-
return entry?.features?.[feature] === true;
180-
}
181-
182175
function resolveBundledChannelBoundaryRoot(params: {
183176
packageRoot: string;
184177
pluginsDir?: string;
@@ -879,15 +872,6 @@ export function listBundledChannelLegacyStateMigrationDetectors(
879872
});
880873
}
881874

882-
export function hasBundledChannelEntryFeature(
883-
id: ChannelId,
884-
feature: keyof NonNullable<BundledChannelEntryRuntimeContract["features"]>,
885-
): boolean {
886-
const { rootScope, loadContext } = resolveActiveBundledChannelLoadScope();
887-
const entry = getLazyGeneratedBundledChannelEntryForRoot(id, rootScope, loadContext)?.entry;
888-
return hasChannelEntryFeature(entry, feature);
889-
}
890-
891875
export function getBundledChannelAccountInspector(
892876
id: ChannelId,
893877
): NonNullable<ChannelPlugin["config"]["inspectAccount"]> | undefined {
@@ -921,14 +905,6 @@ export function getBundledChannelSetupSecrets(
921905
return getBundledChannelSetupSecretsForRoot(id, rootScope, loadContext);
922906
}
923907

924-
export function requireBundledChannelPlugin(id: ChannelId): ChannelPlugin {
925-
const plugin = getBundledChannelPlugin(id);
926-
if (!plugin) {
927-
throw new Error(`missing bundled channel plugin: ${id}`);
928-
}
929-
return plugin;
930-
}
931-
932908
export function setBundledChannelRuntime(id: ChannelId, runtime: PluginRuntime): void {
933909
const { rootScope, loadContext } = resolveActiveBundledChannelLoadScope();
934910
const setter = getLazyGeneratedBundledChannelEntryForRoot(id, rootScope, loadContext)?.entry

0 commit comments

Comments
 (0)