From 1b454bf090cb0825a965491514f7eee6646a9058 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 00:52:30 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/integrations/supabase/types.ts | 60 +++++++++++++++++++ src/routeTree.gen.ts | 9 --- ...7_b33318a9-974b-43ed-8d91-2a11bc98e11b.sql | 44 ++++++++++++++ 3 files changed, 104 insertions(+), 9 deletions(-) create mode 100644 supabase/migrations/20260418005227_b33318a9-974b-43ed-8d91-2a11bc98e11b.sql diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index d940019..9c91749 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -968,6 +968,63 @@ export type Database = { }, ] } + email_logs: { + Row: { + bcc_addresses: string[] + body_html: string | null + body_text: string | null + case_id: string | null + cc_addresses: string[] + context: string | null + created_at: string + error_message: string | null + from_address: string | null + id: string + reply_to: string | null + sent_at: string + sent_by: string | null + status: string + subject: string + to_addresses: string[] + } + Insert: { + bcc_addresses?: string[] + body_html?: string | null + body_text?: string | null + case_id?: string | null + cc_addresses?: string[] + context?: string | null + created_at?: string + error_message?: string | null + from_address?: string | null + id?: string + reply_to?: string | null + sent_at?: string + sent_by?: string | null + status?: string + subject: string + to_addresses?: string[] + } + Update: { + bcc_addresses?: string[] + body_html?: string | null + body_text?: string | null + case_id?: string | null + cc_addresses?: string[] + context?: string | null + created_at?: string + error_message?: string | null + from_address?: string | null + id?: string + reply_to?: string | null + sent_at?: string + sent_by?: string | null + status?: string + subject?: string + to_addresses?: string[] + } + Relationships: [] + } expenses: { Row: { amount: number @@ -1789,6 +1846,7 @@ export type Database = { smtp_settings: { Row: { created_at: string + default_bcc: string | null enabled: boolean from_email: string from_name: string | null @@ -1804,6 +1862,7 @@ export type Database = { } Insert: { created_at?: string + default_bcc?: string | null enabled?: boolean from_email: string from_name?: string | null @@ -1819,6 +1878,7 @@ export type Database = { } Update: { created_at?: string + default_bcc?: string | null enabled?: boolean from_email?: string from_name?: string | null diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index da410ca..fb097a5 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -742,12 +742,3 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) ._addFileTypes() - -import type { getRouter } from './router.tsx' -import type { createStart } from '@tanstack/react-start' -declare module '@tanstack/react-start' { - interface Register { - ssr: true - router: Awaited> - } -} diff --git a/supabase/migrations/20260418005227_b33318a9-974b-43ed-8d91-2a11bc98e11b.sql b/supabase/migrations/20260418005227_b33318a9-974b-43ed-8d91-2a11bc98e11b.sql new file mode 100644 index 0000000..37c26e5 --- /dev/null +++ b/supabase/migrations/20260418005227_b33318a9-974b-43ed-8d91-2a11bc98e11b.sql @@ -0,0 +1,44 @@ +-- Add BCC default to SMTP settings +ALTER TABLE public.smtp_settings + ADD COLUMN IF NOT EXISTS default_bcc text; + +-- Email log table +CREATE TABLE IF NOT EXISTS public.email_logs ( + id uuid PRIMARY KEY DEFAULT gen_random_uuid(), + sent_at timestamptz NOT NULL DEFAULT now(), + sent_by uuid, + to_addresses text[] NOT NULL DEFAULT '{}', + cc_addresses text[] NOT NULL DEFAULT '{}', + bcc_addresses text[] NOT NULL DEFAULT '{}', + reply_to text, + from_address text, + subject text NOT NULL, + body_html text, + body_text text, + status text NOT NULL DEFAULT 'sent', + error_message text, + context text, + case_id uuid, + created_at timestamptz NOT NULL DEFAULT now() +); + +CREATE INDEX IF NOT EXISTS email_logs_sent_at_idx ON public.email_logs (sent_at DESC); +CREATE INDEX IF NOT EXISTS email_logs_sent_by_idx ON public.email_logs (sent_by); +CREATE INDEX IF NOT EXISTS email_logs_case_id_idx ON public.email_logs (case_id); + +ALTER TABLE public.email_logs ENABLE ROW LEVEL SECURITY; + +DROP POLICY IF EXISTS email_logs_select ON public.email_logs; +CREATE POLICY email_logs_select ON public.email_logs + FOR SELECT TO authenticated + USING (public.is_admin(auth.uid()) OR sent_by = auth.uid()); + +DROP POLICY IF EXISTS email_logs_insert ON public.email_logs; +CREATE POLICY email_logs_insert ON public.email_logs + FOR INSERT TO authenticated + WITH CHECK (auth.uid() IS NOT NULL); + +DROP POLICY IF EXISTS email_logs_delete ON public.email_logs; +CREATE POLICY email_logs_delete ON public.email_logs + FOR DELETE TO authenticated + USING (public.is_admin(auth.uid()));