Sessoes 1-6 acumuladas: hardening B2, defesa em camadas, +192 testes
Repositorio estava ha ~5 sessoes sem commit. Consolida tudo desde d088a89.
Ver commit.md na raiz para descricao completa por sessao.
# Numeros
- A# auditoria abertos: 0/30
- V# verificacoes abertos: 5/52 (todos adiados com plano)
- T# testes escritos: 10/10
- Vitest: 192/192
- SQL integration: 33/33
- E2E (Playwright, novo): 5/5
- Migrations: 17 (10 novas Sessao 6)
- Areas auditadas: 7 (+documentos com 10 V#)
# Highlights Sessao 6 (hoje)
- V#34/V#41 Opcao B2: tenant_features com plano + override (RPC SECURITY DEFINER, tela /saas/tenant-features)
- A#20 rev2 self-hosted: defesa em 5 camadas (honeypot + rate limit + math captcha condicional + paranoid mode + dashboard /saas/security)
- Documentos hardening (V#43-V#49): tenant scoping em storage policies (vazamento entre clinicas eliminado), RPC validate_share_token, signatures policy granular
- SaaS Twilio Config (/saas/twilio-config): UI editavel para SID/webhook/cotacao; AUTH_TOKEN permanece em env var
- T#9 + T#10: useAgendaEvents.spec.js + Playwright E2E (descobriu bug no front que foi corrigido)
# Sessoes anteriores (1-5) consolidadas
- Sessao 1: auth/router/session, normalizeRole extraido
- Sessao 2: agenda - composables/services consolidados
- Sessao 3: pacientes - tenant_id em todas queries
- Sessao 4: security review pagina publica - 14/15 vulnerabilidades corrigidas
- Sessao 5: SaaS - P0 (A#30: 7 tabelas com RLS off corrigidas)
# .gitignore ajustado
- supabase/* + !supabase/functions/ (mantem 10 edge functions, ignora .temp/migrations gerados pelo CLI)
- database-novo/backups/ (regeneravel via db.cjs backup)
- test-results/ + playwright-report/
- .claude/settings.local.json (config local com senha de dev removida do tracking)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* useAgendaEvents.spec.js — T#9
|
||||
*
|
||||
* Wrapper fino do agendaRepository. Cobertura focada nos contratos:
|
||||
* - rows/loading/error reativos
|
||||
* - delega I/O ao repository (nada de fetch direto)
|
||||
* - sem ownerId, loadMyRange é no-op (proteção tenant scoping)
|
||||
* - error é capturado em loadMyRange e zera rows; create/update/remove propagam
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
const listMock = vi.fn();
|
||||
const createMock = vi.fn();
|
||||
const updateMock = vi.fn();
|
||||
const removeMock = vi.fn();
|
||||
|
||||
vi.mock('@/features/agenda/services/agendaRepository', () => ({
|
||||
listMyAgendaEvents: (...a) => listMock(...a),
|
||||
createAgendaEvento: (...a) => createMock(...a),
|
||||
updateAgendaEvento: (...a) => updateMock(...a),
|
||||
deleteAgendaEvento: (...a) => removeMock(...a)
|
||||
}));
|
||||
|
||||
const { useAgendaEvents } = await import('../useAgendaEvents.js');
|
||||
|
||||
beforeEach(() => {
|
||||
listMock.mockReset();
|
||||
createMock.mockReset();
|
||||
updateMock.mockReset();
|
||||
removeMock.mockReset();
|
||||
});
|
||||
|
||||
describe('useAgendaEvents — estado inicial', () => {
|
||||
it('rows vazio, loading false, error null', () => {
|
||||
const { rows, loading, error } = useAgendaEvents();
|
||||
expect(rows.value).toEqual([]);
|
||||
expect(loading.value).toBe(false);
|
||||
expect(error.value).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('loadMyRange', () => {
|
||||
it('sem ownerId, não chama o repository (no-op de segurança)', async () => {
|
||||
const { rows, loadMyRange } = useAgendaEvents();
|
||||
await loadMyRange('2026-01-01', '2026-01-31', null);
|
||||
await loadMyRange('2026-01-01', '2026-01-31', '');
|
||||
await loadMyRange('2026-01-01', '2026-01-31', undefined);
|
||||
expect(listMock).not.toHaveBeenCalled();
|
||||
expect(rows.value).toEqual([]);
|
||||
});
|
||||
|
||||
it('chama listMyAgendaEvents com payload correto e popula rows', async () => {
|
||||
listMock.mockResolvedValue([{ id: 'a' }, { id: 'b' }]);
|
||||
const { rows, loading, loadMyRange } = useAgendaEvents();
|
||||
|
||||
const promise = loadMyRange('2026-01-01', '2026-01-31', 'u-1');
|
||||
// loading vira true durante a execução
|
||||
expect(loading.value).toBe(true);
|
||||
await promise;
|
||||
|
||||
expect(listMock).toHaveBeenCalledWith({
|
||||
startISO: '2026-01-01',
|
||||
endISO: '2026-01-31',
|
||||
ownerId: 'u-1'
|
||||
});
|
||||
expect(rows.value).toEqual([{ id: 'a' }, { id: 'b' }]);
|
||||
expect(loading.value).toBe(false);
|
||||
});
|
||||
|
||||
it('captura erro, zera rows e seta error.message', async () => {
|
||||
listMock.mockRejectedValue(new Error('fetch fail'));
|
||||
const { rows, loading, error, loadMyRange } = useAgendaEvents();
|
||||
|
||||
await loadMyRange('2026-01-01', '2026-01-31', 'u-1');
|
||||
|
||||
expect(rows.value).toEqual([]);
|
||||
expect(loading.value).toBe(false);
|
||||
expect(error.value).toBe('fetch fail');
|
||||
});
|
||||
|
||||
it('reseta error em call subsequente bem-sucedida', async () => {
|
||||
listMock.mockRejectedValueOnce(new Error('first fail')).mockResolvedValueOnce([{ id: 'x' }]);
|
||||
const { error, loadMyRange } = useAgendaEvents();
|
||||
|
||||
await loadMyRange('2026-01-01', '2026-01-31', 'u-1');
|
||||
expect(error.value).toBe('first fail');
|
||||
|
||||
await loadMyRange('2026-01-01', '2026-01-31', 'u-1');
|
||||
expect(error.value).toBe(null);
|
||||
});
|
||||
|
||||
it('error sem message vira fallback string', async () => {
|
||||
listMock.mockRejectedValue({}); // sem .message
|
||||
const { error, loadMyRange } = useAgendaEvents();
|
||||
await loadMyRange('2026-01-01', '2026-01-31', 'u-1');
|
||||
expect(error.value).toBe('Erro ao carregar eventos');
|
||||
});
|
||||
});
|
||||
|
||||
describe('create / update / remove — delegação pura', () => {
|
||||
it('create encaminha payload e retorna o resultado do repository', async () => {
|
||||
createMock.mockResolvedValue({ id: 'new', titulo: 'X' });
|
||||
const { create } = useAgendaEvents();
|
||||
const result = await create({ titulo: 'X' });
|
||||
expect(createMock).toHaveBeenCalledWith({ titulo: 'X' });
|
||||
expect(result).toEqual({ id: 'new', titulo: 'X' });
|
||||
});
|
||||
|
||||
it('update encaminha id+patch e retorna o resultado', async () => {
|
||||
updateMock.mockResolvedValue({ id: '42', titulo: 'updated' });
|
||||
const { update } = useAgendaEvents();
|
||||
const result = await update('42', { titulo: 'updated' });
|
||||
expect(updateMock).toHaveBeenCalledWith('42', { titulo: 'updated' });
|
||||
expect(result).toEqual({ id: '42', titulo: 'updated' });
|
||||
});
|
||||
|
||||
it('remove encaminha id (sem retorno)', async () => {
|
||||
removeMock.mockResolvedValue(undefined);
|
||||
const { remove } = useAgendaEvents();
|
||||
const result = await remove('99');
|
||||
expect(removeMock).toHaveBeenCalledWith('99');
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('create propaga erro (não engole)', async () => {
|
||||
createMock.mockRejectedValue(new Error('insert blocked by RLS'));
|
||||
const { create } = useAgendaEvents();
|
||||
await expect(create({ titulo: 'X' })).rejects.toThrow(/RLS/);
|
||||
});
|
||||
|
||||
it('update propaga erro', async () => {
|
||||
updateMock.mockRejectedValue(new Error('not found'));
|
||||
const { update } = useAgendaEvents();
|
||||
await expect(update('1', { x: 1 })).rejects.toThrow(/not found/);
|
||||
});
|
||||
|
||||
it('remove propaga erro', async () => {
|
||||
removeMock.mockRejectedValue(new Error('cascade fail'));
|
||||
const { remove } = useAgendaEvents();
|
||||
await expect(remove('1')).rejects.toThrow(/cascade/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isolamento entre instâncias', () => {
|
||||
it('cada useAgendaEvents() retorna refs independentes', async () => {
|
||||
listMock.mockResolvedValue([{ id: 'a' }]);
|
||||
const a = useAgendaEvents();
|
||||
const b = useAgendaEvents();
|
||||
|
||||
await a.loadMyRange('2026-01-01', '2026-01-31', 'u-1');
|
||||
|
||||
expect(a.rows.value).toEqual([{ id: 'a' }]);
|
||||
expect(b.rows.value).toEqual([]); // b não foi tocado
|
||||
});
|
||||
});
|
||||
@@ -16,75 +16,33 @@
|
||||
*/
|
||||
/**
|
||||
* useAgendaEvents.js
|
||||
* src/features/agenda/composables/useAgendaEvents.js
|
||||
*
|
||||
* Gerencia apenas eventos reais (agenda_eventos).
|
||||
* Sessões com recurrence_id são sessões reais de uma série.
|
||||
* Wrapper fino sobre agendaRepository — agrega estado reativo (rows/loading/error)
|
||||
* e delega toda a lógica de I/O ao repository. Mesmo padrão de useAgendaClinicEvents.
|
||||
*
|
||||
* Só gerencia eventos reais (agenda_eventos). Ocorrências virtuais de séries são
|
||||
* responsabilidade do useRecurrence.
|
||||
*/
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { supabase } from '@/lib/supabase/client';
|
||||
import { useTenantStore } from '@/stores/tenantStore';
|
||||
|
||||
// ─── helpers internos ────────────────────────────────────────────────────────
|
||||
|
||||
function assertTenantId(tenantId) {
|
||||
if (!tenantId || tenantId === 'null' || tenantId === 'undefined') {
|
||||
throw new Error('Tenant ativo inválido. Selecione a clínica/tenant antes de operar na agenda.');
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const BASE_SELECT = `
|
||||
id, owner_id, patient_id, tipo, status,
|
||||
titulo, titulo_custom, observacoes, inicio_em, fim_em,
|
||||
terapeuta_id, tenant_id, visibility_scope,
|
||||
determined_commitment_id, link_online, extra_fields, modalidade,
|
||||
recurrence_id, recurrence_date,
|
||||
mirror_of_event_id, price,
|
||||
insurance_plan_id, insurance_guide_number, insurance_value, insurance_plan_service_id,
|
||||
patients!agenda_eventos_patient_id_fkey (
|
||||
id, nome_completo, avatar_url, status
|
||||
),
|
||||
determined_commitments!agenda_eventos_determined_commitment_fk (
|
||||
id, bg_color, text_color
|
||||
)
|
||||
`.trim();
|
||||
import {
|
||||
listMyAgendaEvents,
|
||||
createAgendaEvento,
|
||||
updateAgendaEvento,
|
||||
deleteAgendaEvento
|
||||
} from '@/features/agenda/services/agendaRepository';
|
||||
|
||||
export function useAgendaEvents() {
|
||||
const rows = ref([]);
|
||||
const loading = ref(false);
|
||||
const error = ref(null);
|
||||
|
||||
async function loadMyRange(start, end, ownerId) {
|
||||
async function loadMyRange(startISO, endISO, ownerId) {
|
||||
if (!ownerId) return;
|
||||
|
||||
const tenantStore = useTenantStore();
|
||||
const tenantId = tenantStore.activeTenantId;
|
||||
assertTenantId(tenantId);
|
||||
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
const { data, error: err } = await supabase
|
||||
.from('agenda_eventos')
|
||||
.select(BASE_SELECT)
|
||||
.eq('tenant_id', tenantId)
|
||||
.eq('owner_id', ownerId)
|
||||
.is('mirror_of_event_id', null)
|
||||
.gte('inicio_em', start)
|
||||
.lte('inicio_em', end)
|
||||
.order('inicio_em', { ascending: true });
|
||||
|
||||
if (err) throw err;
|
||||
rows.value = (data || []).map(flattenRow);
|
||||
rows.value = await listMyAgendaEvents({ startISO, endISO, ownerId });
|
||||
} catch (e) {
|
||||
error.value = e?.message || 'Erro ao carregar eventos';
|
||||
rows.value = [];
|
||||
@@ -93,89 +51,17 @@ export function useAgendaEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cria um evento injetando tenant_id e owner_id automaticamente.
|
||||
* owner_id é sempre o usuário autenticado — nunca vem do payload externo.
|
||||
* tenant_id vem do tenantStore ativo — nunca do payload externo.
|
||||
*/
|
||||
async function create(payload) {
|
||||
const tenantStore = useTenantStore();
|
||||
const tenantId = tenantStore.activeTenantId;
|
||||
assertTenantId(tenantId);
|
||||
|
||||
const uid = await getUid();
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { paciente_id: _dropped, ...rest } = payload;
|
||||
const safePayload = {
|
||||
...rest,
|
||||
tenant_id: tenantId,
|
||||
owner_id: uid
|
||||
};
|
||||
|
||||
const { data, error: err } = await supabase.from('agenda_eventos').insert([safePayload]).select(BASE_SELECT).single();
|
||||
if (err) throw err;
|
||||
return flattenRow(data);
|
||||
return createAgendaEvento(payload);
|
||||
}
|
||||
|
||||
async function update(id, patch) {
|
||||
if (!id) throw new Error('ID inválido.');
|
||||
|
||||
const tenantStore = useTenantStore();
|
||||
const tenantId = tenantStore.activeTenantId;
|
||||
assertTenantId(tenantId);
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { paciente_id: _dropped, ...safePatch } = patch;
|
||||
|
||||
const { data, error: err } = await supabase.from('agenda_eventos').update(safePatch).eq('id', id).eq('tenant_id', tenantId).select(BASE_SELECT).single();
|
||||
if (err) throw err;
|
||||
return flattenRow(data);
|
||||
return updateAgendaEvento(id, patch);
|
||||
}
|
||||
|
||||
async function remove(id) {
|
||||
if (!id) throw new Error('ID inválido.');
|
||||
|
||||
const tenantStore = useTenantStore();
|
||||
const tenantId = tenantStore.activeTenantId;
|
||||
assertTenantId(tenantId);
|
||||
|
||||
const { error: err } = await supabase.from('agenda_eventos').delete().eq('id', id).eq('tenant_id', tenantId);
|
||||
if (err) throw err;
|
||||
await deleteAgendaEvento(id);
|
||||
}
|
||||
|
||||
async function removeSeriesFrom(recurrenceId, fromDateISO) {
|
||||
if (!recurrenceId) throw new Error('recurrenceId inválido.');
|
||||
|
||||
const tenantStore = useTenantStore();
|
||||
const tenantId = tenantStore.activeTenantId;
|
||||
assertTenantId(tenantId);
|
||||
|
||||
const { error: err } = await supabase.from('agenda_eventos').delete().eq('recurrence_id', recurrenceId).eq('tenant_id', tenantId).gte('recurrence_date', fromDateISO);
|
||||
if (err) throw err;
|
||||
}
|
||||
|
||||
async function removeAllSeries(recurrenceId) {
|
||||
if (!recurrenceId) throw new Error('recurrenceId inválido.');
|
||||
|
||||
const tenantStore = useTenantStore();
|
||||
const tenantId = tenantStore.activeTenantId;
|
||||
assertTenantId(tenantId);
|
||||
|
||||
const { error: err } = await supabase.from('agenda_eventos').delete().eq('recurrence_id', recurrenceId).eq('tenant_id', tenantId);
|
||||
if (err) throw err;
|
||||
}
|
||||
|
||||
return { rows, loading, error, loadMyRange, create, update, remove, removeSeriesFrom, removeAllSeries };
|
||||
}
|
||||
|
||||
function flattenRow(r) {
|
||||
if (!r) return r;
|
||||
const patient = r.patients || null;
|
||||
const out = { ...r };
|
||||
delete out.patients;
|
||||
out.paciente_nome = patient?.nome_completo || out.paciente_nome || '';
|
||||
out.paciente_avatar = patient?.avatar_url || out.paciente_avatar || '';
|
||||
out.paciente_status = patient?.status || out.paciente_status || '';
|
||||
return out;
|
||||
return { rows, loading, error, loadMyRange, create, update, remove };
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { supabase } from '@/lib/supabase/client';
|
||||
import { useTenantStore } from '@/stores/tenantStore';
|
||||
import { assertTenantId } from '@/features/agenda/services/_tenantGuards';
|
||||
import { logRecurrence, logError, logPerf } from '@/support/supportLogger';
|
||||
|
||||
// ─── helpers de data ────────────────────────────────────────────────────────
|
||||
@@ -197,6 +199,11 @@ export function generateDates(rule, rangeStart, rangeEnd) {
|
||||
|
||||
// ─── expansão principal ──────────────────────────────────────────────────────
|
||||
|
||||
// Cap defensivo: a agenda real sempre passa ranges mensais/semanais (≤42d).
|
||||
// Range muito grande com muitas regras = milhares de ocorrências no browser.
|
||||
// Não bloqueamos (relatórios legítimos podem precisar), só avisamos.
|
||||
const MAX_RANGE_DAYS = 730; // 2 anos
|
||||
|
||||
/**
|
||||
* Expande regras em ocorrências, aplica exceções.
|
||||
*
|
||||
@@ -207,6 +214,15 @@ export function generateDates(rule, rangeStart, rangeEnd) {
|
||||
* @returns {Array} occurrences — objetos com shape compatível com FullCalendar
|
||||
*/
|
||||
export function expandRules(rules, exceptions, rangeStart, rangeEnd) {
|
||||
const rangeDays = Math.round((rangeEnd.getTime() - rangeStart.getTime()) / 86_400_000);
|
||||
if (rangeDays > MAX_RANGE_DAYS) {
|
||||
logError('useRecurrence', 'expandRules: range grande pode degradar UI', {
|
||||
rangeDays,
|
||||
maxRecommended: MAX_RANGE_DAYS,
|
||||
ruleCount: (rules || []).length
|
||||
});
|
||||
}
|
||||
|
||||
// índice de exceções por regra+data
|
||||
const exMap = new Map();
|
||||
for (const ex of exceptions || []) {
|
||||
@@ -399,6 +415,13 @@ export function useRecurrence() {
|
||||
const exceptions = ref([]);
|
||||
const loading = ref(false);
|
||||
const error = ref(null);
|
||||
const tenantStore = useTenantStore();
|
||||
|
||||
function currentTenantId() {
|
||||
const tid = tenantStore.activeTenantId;
|
||||
assertTenantId(tid);
|
||||
return tid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Carrega regras ativas para um owner no range dado.
|
||||
@@ -493,6 +516,7 @@ export function useRecurrence() {
|
||||
return true;
|
||||
});
|
||||
} catch (e) {
|
||||
logError('useRecurrence', 'loadExceptions ERRO', e);
|
||||
error.value = e?.message || 'Erro ao carregar exceções';
|
||||
exceptions.value = [];
|
||||
}
|
||||
@@ -546,13 +570,16 @@ export function useRecurrence() {
|
||||
// ── CRUD de regras ──────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Cria uma nova regra de recorrência
|
||||
* Cria uma nova regra de recorrência.
|
||||
* tenant_id é injetado do tenantStore se não vier no payload (defesa em profundidade).
|
||||
* @param {Object} rule - campos da tabela recurrence_rules
|
||||
* @returns {Object} regra criada
|
||||
*/
|
||||
async function createRule(rule) {
|
||||
const tenantId = currentTenantId();
|
||||
logRecurrence('createRule →', { patient_id: rule?.patient_id, type: rule?.type });
|
||||
const { data, error: err } = await supabase.from('recurrence_rules').insert([rule]).select('*').single();
|
||||
const safeRule = { ...rule, tenant_id: rule?.tenant_id || tenantId };
|
||||
const { data, error: err } = await supabase.from('recurrence_rules').insert([safeRule]).select('*').single();
|
||||
if (err) {
|
||||
logError('useRecurrence', 'createRule ERRO', err);
|
||||
throw err;
|
||||
@@ -562,13 +589,16 @@ export function useRecurrence() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Atualiza a regra toda (editar todos)
|
||||
* Atualiza a regra toda (editar todos).
|
||||
* Filtro adicional por tenant_id — defesa em profundidade (RLS cobre, mas reforçamos).
|
||||
*/
|
||||
async function updateRule(id, patch) {
|
||||
const tenantId = currentTenantId();
|
||||
const { data, error: err } = await supabase
|
||||
.from('recurrence_rules')
|
||||
.update({ ...patch, updated_at: new Date().toISOString() })
|
||||
.eq('id', id)
|
||||
.eq('tenant_id', tenantId)
|
||||
.select('*')
|
||||
.single();
|
||||
if (err) throw err;
|
||||
@@ -576,10 +606,15 @@ export function useRecurrence() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancela a série inteira
|
||||
* Cancela a série inteira (filtro por tenant_id — defesa em profundidade).
|
||||
*/
|
||||
async function cancelRule(id) {
|
||||
const { error: err } = await supabase.from('recurrence_rules').update({ status: 'cancelado', updated_at: new Date().toISOString() }).eq('id', id);
|
||||
const tenantId = currentTenantId();
|
||||
const { error: err } = await supabase
|
||||
.from('recurrence_rules')
|
||||
.update({ status: 'cancelado', updated_at: new Date().toISOString() })
|
||||
.eq('id', id)
|
||||
.eq('tenant_id', tenantId);
|
||||
if (err) throw err;
|
||||
}
|
||||
|
||||
@@ -610,19 +645,33 @@ export function useRecurrence() {
|
||||
// ── CRUD de exceções ────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Cria ou atualiza uma exceção para uma ocorrência específica
|
||||
* Cria ou atualiza uma exceção para uma ocorrência específica.
|
||||
* tenant_id é injetado do tenantStore se não vier no payload.
|
||||
*/
|
||||
async function upsertException(ex) {
|
||||
const { data, error: err } = await supabase.from('recurrence_exceptions').upsert([ex], { onConflict: 'recurrence_id,original_date' }).select('*').single();
|
||||
const tenantId = currentTenantId();
|
||||
const safeEx = { ...ex, tenant_id: ex?.tenant_id || tenantId };
|
||||
const { data, error: err } = await supabase
|
||||
.from('recurrence_exceptions')
|
||||
.upsert([safeEx], { onConflict: 'recurrence_id,original_date' })
|
||||
.select('*')
|
||||
.single();
|
||||
if (err) throw err;
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove uma exceção (restaura a ocorrência ao normal)
|
||||
* Remove uma exceção (restaura a ocorrência ao normal).
|
||||
* Filtro por tenant_id — defesa em profundidade.
|
||||
*/
|
||||
async function deleteException(recurrenceId, originalDate) {
|
||||
const { error: err } = await supabase.from('recurrence_exceptions').delete().eq('recurrence_id', recurrenceId).eq('original_date', originalDate);
|
||||
const tenantId = currentTenantId();
|
||||
const { error: err } = await supabase
|
||||
.from('recurrence_exceptions')
|
||||
.delete()
|
||||
.eq('recurrence_id', recurrenceId)
|
||||
.eq('original_date', originalDate)
|
||||
.eq('tenant_id', tenantId);
|
||||
if (err) throw err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user