mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 19:01:44 +00:00
fix: align discord registry and runtime test helpers
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { resolveGlobalMap } from "openclaw/plugin-sdk/global-singleton";
|
||||
import type { DiscordComponentEntry, DiscordModalEntry } from "./components.js";
|
||||
|
||||
const DEFAULT_COMPONENT_TTL_MS = 30 * 60 * 1000;
|
||||
@@ -7,24 +8,15 @@ const DISCORD_MODAL_ENTRIES_KEY = Symbol.for("openclaw.discord.modalEntries");
|
||||
let componentEntries: Map<string, DiscordComponentEntry> | undefined;
|
||||
let modalEntries: Map<string, DiscordModalEntry> | undefined;
|
||||
|
||||
function resolveGlobalMap<T>(key: symbol): Map<string, T> {
|
||||
const globalStore = globalThis as Record<PropertyKey, unknown>;
|
||||
const existing = globalStore[key];
|
||||
if (existing instanceof Map) {
|
||||
return existing as Map<string, T>;
|
||||
}
|
||||
const created = new Map<string, T>();
|
||||
globalStore[key] = created;
|
||||
return created;
|
||||
}
|
||||
|
||||
function getComponentEntries(): Map<string, DiscordComponentEntry> {
|
||||
componentEntries ??= resolveGlobalMap<DiscordComponentEntry>(DISCORD_COMPONENT_ENTRIES_KEY);
|
||||
componentEntries ??= resolveGlobalMap<string, DiscordComponentEntry>(
|
||||
DISCORD_COMPONENT_ENTRIES_KEY,
|
||||
);
|
||||
return componentEntries;
|
||||
}
|
||||
|
||||
function getModalEntries(): Map<string, DiscordModalEntry> {
|
||||
modalEntries ??= resolveGlobalMap<DiscordModalEntry>(DISCORD_MODAL_ENTRIES_KEY);
|
||||
modalEntries ??= resolveGlobalMap<string, DiscordModalEntry>(DISCORD_MODAL_ENTRIES_KEY);
|
||||
return modalEntries;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ describe("resolvePluginCapabilityProviders", () => {
|
||||
origin: "workspace",
|
||||
contracts: {},
|
||||
},
|
||||
] as Array<Record<string, unknown>>,
|
||||
],
|
||||
diagnostics: [],
|
||||
});
|
||||
mocks.withBundledPluginAllowlistCompat.mockReturnValue(allowlistCompat);
|
||||
|
||||
Reference in New Issue
Block a user