AeThex-OS/temp-forge-extract/aethex-forge-main/client/lib/builder.ts
MrPiglr b3c308b2c8 Add functional marketplace modules, bottom nav bar, root terminal, arcade games
- ModuleManager: Central tracking for installed marketplace modules
- DataAnalyzerWidget: Real-time CPU/RAM/Battery/Storage widget (unlocked by Data Analyzer module)
- BottomNavBar: Navigation bar for Projects/Chat/Marketplace/Settings
- RootShell: Real root command execution utility
- TerminalActivity: Full root shell with neofetch, sysinfo, real Linux commands
- Terminal Pro module: Adds aliases (ll, la, h), command history
- ArcadeActivity + SnakeGame: Pixel Arcade module unlocks retro games
- fade_in/fade_out animations for smooth transitions
2026-02-18 22:03:50 -07:00

37 lines
1.6 KiB
TypeScript

const API_ROOT = "https://cdn.builder.io/api/v3";
export type BuilderResult<T = any> = {
results: Array<{
id: string;
name?: string;
data?: T & { slug?: string; image?: string; category?: string; author?: string; date?: string; excerpt?: string; readTime?: string };
url?: string;
published?: string;
}>;
};
export function getBuilderApiKey() {
return import.meta.env.VITE_BUILDER_API_KEY;
}
export async function fetchBuilderList<T = any>(model: string, opts: { limit?: number; query?: Record<string, any>; fields?: string } = {}) {
const apiKey = getBuilderApiKey();
if (!apiKey) throw new Error("Missing VITE_BUILDER_API_KEY");
const params = new URLSearchParams({ apiKey });
if (opts.limit) params.set("limit", String(opts.limit));
if (opts.fields) params.set("fields", opts.fields);
if (opts.query) params.set("query", JSON.stringify(opts.query));
const res = await fetch(`${API_ROOT}/content/${encodeURIComponent(model)}?${params.toString()}`);
if (!res.ok) throw new Error(`Builder fetch failed: ${res.status}`);
return (await res.json()) as BuilderResult<T>;
}
export async function fetchBuilderOne<T = any>(model: string, slug: string) {
const apiKey = getBuilderApiKey();
if (!apiKey) throw new Error("Missing VITE_BUILDER_API_KEY");
const params = new URLSearchParams({ apiKey, limit: "1", query: JSON.stringify({ "data.slug": slug }) });
const res = await fetch(`${API_ROOT}/content/${encodeURIComponent(model)}?${params.toString()}`);
if (!res.ok) throw new Error(`Builder fetch failed: ${res.status}`);
const json = (await res.json()) as BuilderResult<T>;
return json.results?.[0] || null;
}