refactor: migrate discord messaging ownership

This commit is contained in:
Tak Hoffman 2026-03-18 15:01:10 -05:00
parent beab2a6d00
commit 4aca379dc5
No known key found for this signature in database
4 changed files with 23 additions and 16 deletions

View File

@ -18,20 +18,12 @@ export {
export {
DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS,
DISCORD_DEFAULT_LISTENER_TIMEOUT_MS,
fetchChannelInfoDiscord,
fetchVoiceStatusDiscord,
getGateway,
getPresence,
hasAnyGuildPermissionDiscord,
kickMemberDiscord,
listGuildChannelsDiscord,
listGuildEmojisDiscord,
listPinsDiscord,
listScheduledEventsDiscord,
listThreadsDiscord,
monitorDiscordProvider,
probeDiscord,
readMessagesDiscord,
searchMessagesDiscord,
unpinMessageDiscord,
} from "../../../extensions/discord/runtime-api.js";

View File

@ -407,6 +407,18 @@ describe("channel import guardrails", () => {
expect(text).toMatch(/from\s+"..\/..\/extensions\/discord\/runtime-api\.js";/);
});
it("keeps Discord messaging 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(?:fetchChannelInfoDiscord|listGuildChannelsDiscord|listGuildEmojisDiscord|listPinsDiscord|listScheduledEventsDiscord|listThreadsDiscord|readMessagesDiscord|searchMessagesDiscord)\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

@ -32,10 +32,16 @@ import {
fetchMessageDiscord,
fetchReactionsDiscord,
fetchRoleInfoDiscord,
fetchChannelInfoDiscord,
getThreadBindingManager,
listDiscordDirectoryGroupsLive,
listDiscordDirectoryPeersLive,
listThreadBindingsBySessionKey,
listGuildChannelsDiscord,
listGuildEmojisDiscord,
listPinsDiscord,
listScheduledEventsDiscord,
listThreadsDiscord,
moveChannelDiscord,
pinMessageDiscord,
reactMessageDiscord,
@ -62,6 +68,8 @@ import {
unbindThreadBindingsBySessionKey,
uploadEmojiDiscord,
uploadStickerDiscord,
readMessagesDiscord,
searchMessagesDiscord,
} from "../../extensions/discord/runtime-api.js";
import { normalizeExplicitDiscordSessionKey } from "../../extensions/discord/session-key-api.js";
import type {
@ -82,21 +90,13 @@ import {
import {
DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS,
DISCORD_DEFAULT_LISTENER_TIMEOUT_MS,
fetchChannelInfoDiscord,
fetchVoiceStatusDiscord,
getGateway,
getPresence,
hasAnyGuildPermissionDiscord,
kickMemberDiscord,
listGuildChannelsDiscord,
listGuildEmojisDiscord,
listPinsDiscord,
listScheduledEventsDiscord,
listThreadsDiscord,
monitorDiscordProvider,
probeDiscord,
readMessagesDiscord,
searchMessagesDiscord,
unpinMessageDiscord,
} from "../channels/discord/plugin-sdk-bridge.js";

View File

@ -272,7 +272,10 @@ describe("plugin-sdk subpath exports", () => {
expect(typeof discordSdk.listDiscordDirectoryPeersFromConfig).toBe("function");
expect(typeof discordSdk.listDiscordDirectoryGroupsLive).toBe("function");
expect(typeof discordSdk.listDiscordDirectoryPeersLive).toBe("function");
expect(typeof discordSdk.fetchChannelInfoDiscord).toBe("function");
expect(typeof discordSdk.listThreadsDiscord).toBe("function");
expect(typeof discordSdk.normalizeDiscordOutboundTarget).toBe("function");
expect(typeof discordSdk.readMessagesDiscord).toBe("function");
expect(typeof discordSdk.resolveDiscordChannelId).toBe("function");
expect(typeof discordSdk.sendMessageDiscord).toBe("function");
expect(typeof discordSdk.getThreadBindingManager).toBe("function");