From 195f3472b2f4a76f2828c2a54d784f91400d00a2 Mon Sep 17 00:00:00 2001 From: Ally Founder Date: Tue, 11 Aug 2026 17:58:30 -0400 Subject: [PATCH] RosePlugs: add Nexus plugin metadata fetch/cache --- plugins/rose-plugs/src/lib/nexusApi.ts | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 plugins/rose-plugs/src/lib/nexusApi.ts diff --git a/plugins/rose-plugs/src/lib/nexusApi.ts b/plugins/rose-plugs/src/lib/nexusApi.ts new file mode 100644 index 0000000..9ed885b --- /dev/null +++ b/plugins/rose-plugs/src/lib/nexusApi.ts @@ -0,0 +1,50 @@ +export interface NexusPlugin { + id: string; + name: string; + description: string; + authors: string[]; + category: string; + status: string; + accent: string; + tagline: string; + note: string; + howItWorks: string; + features: string[]; + commands: string[]; + limitations: string; + pageUrl: string; + installUrl: string; + sourceUrl: string; + issueUrl: string; +} + +const NEXUS_URL = "https://rp.jarviscli.dev/plugins-data.json"; + +let cache: NexusPlugin[] | null = null; +let inflight: Promise | null = null; + +export async function fetchNexusPlugins(force = false): Promise { + if (!force && cache) return cache; + if (!force && inflight) return inflight; + + inflight = fetch(NEXUS_URL) + .then((res) => { + if (!res.ok) throw new Error(`Nexus fetch failed: ${res.status}`); + return res.json(); + }) + .then((data: NexusPlugin[]) => { + cache = data; + inflight = null; + return data; + }) + .catch((e) => { + inflight = null; + throw e; + }); + + return inflight; +} + +export function clearNexusCache(): void { + cache = null; +}