F6.2 Lote D: RPCs user-facing roteadas pro schema do tenant
DB (supabase_admin, manual/f6_2d_user_rpcs.supabase_admin.sql): 14 RPCs. Helper _tenant_route(p_tenant_id) valida is_tenant_member + retorna schema (retorna, nao seta — set_config em helper com SET search_path proprio seria revertido na saida). Cada RPC: set_config search_path pro schema + unqualify tabelas tenant + remove WHERE tenant_id= e tenant_id de inserts. - Grupo 1 (ja tinham p_tenant_id, jsonb/void): delete_commitment_full, delete_determined_commitment, seed_default_patient_groups, seed_determined_commitments (no-op se schema nao existe) - Grupo 2 (novo p_tenant_id 1o param, DROP+CREATE): cancel_recurrence_from, cancelar_eventos_serie, split_recurrence_at, safe_delete_patient, export_patient_data (audit_logs global mantido), search_global (patient_intake_requests fica em public/F1b -> qualificado + filtro tenant_id) - Grupo 3 (RETURNS <tabela>->jsonb): mark_as_paid, create_financial_record_ for_session, mark_payout_as_paid, create_therapist_payout - can_delete_patient: unqualified, herda search_path do chamador Smoke: mark_as_paid (status=paid, jsonb) + search_global (acha paciente) OK. Frontend (18 sites): p_tenant_id de useTenantStore().activeTenantId (ou helper local resolveTenantId/currentTenantId). create_financial_record_for_session ja passava tenant; retorno SETOF->jsonb transparente (nenhum consumidor indexava array). Build passa. list_my_signatures (cross-tenant) -> Lote F. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
import { ref, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue';
|
||||
import { supabase } from '@/lib/supabase/client';
|
||||
import { useTenantStore } from '@/stores/tenantStore';
|
||||
import { useRecentPatients } from '@/composables/useRecentPatients';
|
||||
|
||||
const props = defineProps({
|
||||
@@ -35,6 +36,8 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['acao', 'paciente', 'evento', 'documento', 'intake', 'goto-date']);
|
||||
|
||||
const tenantStore = useTenantStore();
|
||||
|
||||
const rootEl = ref(null);
|
||||
const inputEl = ref(null);
|
||||
const query = ref('');
|
||||
@@ -277,7 +280,7 @@ watch(query, (v) => {
|
||||
const mySeq = ++searchSeq;
|
||||
debounceT = setTimeout(async () => {
|
||||
try {
|
||||
const { data, error } = await supabase.rpc('search_global', { p_q: q, p_limit: 6 });
|
||||
const { data, error } = await supabase.rpc('search_global', { p_tenant_id: tenantStore.activeTenantId, p_q: q, p_limit: 6 });
|
||||
if (mySeq !== searchSeq) return;
|
||||
if (error) {
|
||||
console.error('[MelissaBusca search_global]', error);
|
||||
|
||||
Reference in New Issue
Block a user