refactor: migrate discord gateway ownership

This commit is contained in:
Tak Hoffman 2026-03-18 15:05:08 -05:00
parent 4aca379dc5
commit 347610d1c7
No known key found for this signature in database
3 changed files with 20 additions and 4 deletions

View File

@ -419,6 +419,18 @@ describe("channel import guardrails", () => {
expect(text).toMatch(/from\s+"..\/..\/extensions\/discord\/runtime-api\.js";/);
});
it("keeps Discord gateway ownership on extension public seams", () => {
const text = readSource("src/plugin-sdk/discord.ts");
const bridgeImports = [...text.matchAll(/import(?: type)?\s*\{[\s\S]*?\}\s*from\s+"[^"]+";/g)]
.map((match) => match[0])
.filter((statement) => statement.includes("../channels/discord/plugin-sdk-bridge.js"))
.join("\n");
expect(bridgeImports).not.toMatch(
/\b(?:fetchVoiceStatusDiscord|getGateway|getPresence|monitorDiscordProvider)\b/,
);
expect(text).toMatch(/from\s+"..\/..\/extensions\/discord\/runtime-api\.js";/);
});
it("keeps channel helper modules off their own SDK barrels", () => {
for (const source of SAME_CHANNEL_SDK_GUARDS) {
const text = readSource(source.path);

View File

@ -33,6 +33,9 @@ import {
fetchReactionsDiscord,
fetchRoleInfoDiscord,
fetchChannelInfoDiscord,
fetchVoiceStatusDiscord,
getGateway,
getPresence,
getThreadBindingManager,
listDiscordDirectoryGroupsLive,
listDiscordDirectoryPeersLive,
@ -42,6 +45,7 @@ import {
listPinsDiscord,
listScheduledEventsDiscord,
listThreadsDiscord,
monitorDiscordProvider,
moveChannelDiscord,
pinMessageDiscord,
reactMessageDiscord,
@ -90,12 +94,8 @@ import {
import {
DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS,
DISCORD_DEFAULT_LISTENER_TIMEOUT_MS,
fetchVoiceStatusDiscord,
getGateway,
getPresence,
hasAnyGuildPermissionDiscord,
kickMemberDiscord,
monitorDiscordProvider,
probeDiscord,
unpinMessageDiscord,
} from "../channels/discord/plugin-sdk-bridge.js";

View File

@ -273,7 +273,11 @@ describe("plugin-sdk subpath exports", () => {
expect(typeof discordSdk.listDiscordDirectoryGroupsLive).toBe("function");
expect(typeof discordSdk.listDiscordDirectoryPeersLive).toBe("function");
expect(typeof discordSdk.fetchChannelInfoDiscord).toBe("function");
expect(typeof discordSdk.fetchVoiceStatusDiscord).toBe("function");
expect(typeof discordSdk.getGateway).toBe("function");
expect(typeof discordSdk.getPresence).toBe("function");
expect(typeof discordSdk.listThreadsDiscord).toBe("function");
expect(typeof discordSdk.monitorDiscordProvider).toBe("function");
expect(typeof discordSdk.normalizeDiscordOutboundTarget).toBe("function");
expect(typeof discordSdk.readMessagesDiscord).toBe("function");
expect(typeof discordSdk.resolveDiscordChannelId).toBe("function");