Files
myeasycms-v2/apps/web/lib/resolve-account.ts
2026-03-29 19:44:57 +02:00

25 lines
538 B
TypeScript

import type { SupabaseClient } from '@supabase/supabase-js';
import type { Database } from '@kit/supabase/database';
/**
* Resolve an account slug to its UUID.
* Used by every data loader in the CMS.
*/
export async function resolveAccountId(
client: SupabaseClient<Database>,
slug: string,
): Promise<string> {
const { data, error } = await client
.from('accounts')
.select('id')
.eq('slug', slug)
.single();
if (error || !data) {
throw new Error(`Account not found: ${slug}`);
}
return data.id;
}