/* |-------------------------------------------------------------------------- | Agência PSI |-------------------------------------------------------------------------- | Arquivo: src/features/insurance/services/_tenantGuards.js | | Guards compartilhados entre repositories do feature insurance. | Pattern canônico — ver blueprints/repository-blueprint.md seção 3. |-------------------------------------------------------------------------- */ import { supabase } from '@/lib/supabase/client'; export function assertTenantId(tenantId) { if (!tenantId || tenantId === 'null' || tenantId === 'undefined') { throw new Error('Tenant ativo inválido. Selecione a clínica/tenant antes de operar.'); } } export async function getUid() { const { data, error } = await supabase.auth.getUser(); if (error) throw error; const uid = data?.user?.id; if (!uid) throw new Error('Usuário não autenticado.'); return uid; }