import { definePlugin } from "../../utils/plugin-utils";
export const connectionsPlugin = definePlugin((sdk) => {
    let cachedMap;
    async function loadConnectionsMap() {
        if (cachedMap === undefined) {
            cachedMap = (await sdk.context.getManifestConnections()) ?? null;
        }
        return cachedMap;
    }
    return {
        context: {
            resolveConnection: async (name) => {
                const map = await loadConnectionsMap();
                return map?.[name];
            },
            getConnectionsMap: async () => {
                return loadConnectionsMap();
            },
        },
    };
});
