mirror of
https://github.com/AeThex-Corporation/AeThex-OS.git
synced 2026-04-18 14:27:20 +00:00
- 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
37 lines
1.6 KiB
TypeScript
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;
|
|
}
|