F1b: 6 tabelas anon-facing ficam em public (decisao roteamento anon)

Fluxos anon identificam tenant por token/slug e nao resolvem o schema fisico.
Decisao (opcao C): manter em public com RLS por token. Volta a global:
patient_intake_requests, patient_invites, patient_invite_attempts,
document_share_links, agendador_configuracoes, agendador_solicitacoes.

- migration 20260613000001_f1b: remove as 6 do _tenant_template (template v2,
  78 tabelas). Smoke: clone gera 78, zero tabelas anon no schema, drop limpo
- frontend: 38 cadeias em 14 arquivos revertidas tenantDb().from() ->
  supabase.from() com tenant_id/owner_id restaurado (via comparacao com main)
- edge: convert-abandoned-intakes restaurada do main (SELECT global)
- save-intake-progress: ja usava public, sem mudanca
- doc F0 atualizado: 78 tenant + 59 global

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Leonardo
2026-06-13 09:09:46 -03:00
parent 9b21642e15
commit f17e9ee786
17 changed files with 164 additions and 98 deletions
+6 -4
View File
@@ -432,15 +432,17 @@ async function load() {
.eq('tenant_id', tid)
.in('role', ['therapist', 'tenant_admin'])
.eq('status', 'active'),
tenantDb().from('agendador_solicitacoes')
supabase
.from('agendador_solicitacoes')
.select('id, paciente_nome, paciente_sobrenome, tipo, modalidade, data_solicitada, hora_solicitada')
.eq('tenant_id', tid)
.eq('status', 'pendente')
.order('created_at', { ascending: false })
.limit(10),
tenantDb().from('patient_intake_requests')
supabase
.from('patient_intake_requests')
.select('id, nome_completo, status, created_at')
.eq('tenant_id', tid)
.eq('status', 'new')
.order('created_at', { ascending: false })
.limit(10)
@@ -562,7 +562,7 @@ const solicitacoesPendentes = computed(() => solicitacoes.value.length);
async function aceitarSol(id) {
try {
await tenantDb().from('agendador_solicitacoes').update({ status: 'autorizado' }).eq('id', id);
await supabase.from('agendador_solicitacoes').update({ status: 'autorizado' }).eq('id', id);
_solicitacoesBruto.value = _solicitacoesBruto.value.filter((s) => s.id !== id);
} catch (e) {
console.error('[TherapistDashboard] aceitarSol:', e);
@@ -570,7 +570,7 @@ async function aceitarSol(id) {
}
async function recusarSol(id) {
try {
await tenantDb().from('agendador_solicitacoes').update({ status: 'recusado' }).eq('id', id);
await supabase.from('agendador_solicitacoes').update({ status: 'recusado' }).eq('id', id);
_solicitacoesBruto.value = _solicitacoesBruto.value.filter((s) => s.id !== id);
} catch (e) {
console.error('[TherapistDashboard] recusarSol:', e);
@@ -900,13 +900,14 @@ async function load() {
.order('start_date', { ascending: false });
return q;
})(),
tenantDb().from('agendador_solicitacoes')
supabase
.from('agendador_solicitacoes')
.select('id, paciente_nome, paciente_sobrenome, tipo, modalidade, data_solicitada, hora_solicitada')
.eq('owner_id', ownerId.value)
.eq('status', 'pendente')
.order('created_at', { ascending: false })
.limit(10),
tenantDb().from('patient_intake_requests').select('id, nome_completo, status, created_at').eq('owner_id', ownerId.value).eq('status', 'new').order('created_at', { ascending: false }).limit(10)
supabase.from('patient_intake_requests').select('id, nome_completo, status, created_at').eq('owner_id', ownerId.value).eq('status', 'new').order('created_at', { ascending: false }).limit(10)
]);
eventosDoMes.value = eventosRes.data || [];
_solicitacoesBruto.value = solRes.data || [];