From 83fdf8e4b2536e0a7493c70c8b2b2a6ba06f93ed Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:24:00 +0000 Subject: [PATCH 1/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/integrations/supabase/types.ts | 136 +++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index 0d23437..0476004 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -1477,6 +1477,93 @@ export type Database = { } Relationships: [] } + email_send_log: { + Row: { + created_at: string + error_message: string | null + id: string + message_id: string | null + metadata: Json | null + recipient_email: string + status: string + template_name: string + } + Insert: { + created_at?: string + error_message?: string | null + id?: string + message_id?: string | null + metadata?: Json | null + recipient_email: string + status: string + template_name: string + } + Update: { + created_at?: string + error_message?: string | null + id?: string + message_id?: string | null + metadata?: Json | null + recipient_email?: string + status?: string + template_name?: string + } + Relationships: [] + } + email_send_state: { + Row: { + auth_email_ttl_minutes: number + batch_size: number + id: number + retry_after_until: string | null + send_delay_ms: number + transactional_email_ttl_minutes: number + updated_at: string + } + Insert: { + auth_email_ttl_minutes?: number + batch_size?: number + id?: number + retry_after_until?: string | null + send_delay_ms?: number + transactional_email_ttl_minutes?: number + updated_at?: string + } + Update: { + auth_email_ttl_minutes?: number + batch_size?: number + id?: number + retry_after_until?: string | null + send_delay_ms?: number + transactional_email_ttl_minutes?: number + updated_at?: string + } + Relationships: [] + } + email_unsubscribe_tokens: { + Row: { + created_at: string + email: string + id: string + token: string + used_at: string | null + } + Insert: { + created_at?: string + email: string + id?: string + token: string + used_at?: string | null + } + Update: { + created_at?: string + email?: string + id?: string + token?: string + used_at?: string | null + } + Relationships: [] + } events: { Row: { all_day: boolean @@ -2780,6 +2867,30 @@ export type Database = { }, ] } + suppressed_emails: { + Row: { + created_at: string + email: string + id: string + metadata: Json | null + reason: string + } + Insert: { + created_at?: string + email: string + id?: string + metadata?: Json | null + reason: string + } + Update: { + created_at?: string + email?: string + id?: string + metadata?: Json | null + reason?: string + } + Relationships: [] + } task_assignees: { Row: { assigned_by: string | null @@ -3239,6 +3350,14 @@ export type Database = { Args: { _task_id: string; _user_id: string } Returns: boolean } + delete_email: { + Args: { message_id: number; queue_name: string } + Returns: boolean + } + enqueue_email: { + Args: { payload: Json; queue_name: string } + Returns: number + } has_role: { Args: { _role: Database["public"]["Enums"]["app_role"] @@ -3251,6 +3370,23 @@ export type Database = { Args: { _conv_id: string; _user_id: string } Returns: boolean } + move_to_dlq: { + Args: { + dlq_name: string + message_id: number + payload: Json + source_queue: string + } + Returns: number + } + read_email_batch: { + Args: { batch_size: number; queue_name: string; vt: number } + Returns: { + message: Json + msg_id: number + read_ct: number + }[] + } } Enums: { app_role: "admin" | "attorney" | "staff" | "paralegal" | "legal_clerk" From 04eced26a14f16eb0d59c8824734d690f0a91fe2 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:24:12 +0000 Subject: [PATCH 2/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/lovable/email/queue/process.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/routes/lovable/email/queue/process.ts b/src/routes/lovable/email/queue/process.ts index c424679..4608eec 100644 --- a/src/routes/lovable/email/queue/process.ts +++ b/src/routes/lovable/email/queue/process.ts @@ -2,11 +2,6 @@ import { sendLovableEmail } from '@lovable.dev/email-js' import { createClient } from '@supabase/supabase-js' import { createFileRoute } from '@tanstack/react-router' -// The email infra tables (email_send_log, email_send_state, etc.) are not in -// the generated Database types, so we use an untyped client throughout this -// route. Tables are created by the email infra migration. -type AnyClient = ReturnType> - const MAX_RETRIES = 5 const DEFAULT_BATCH_SIZE = 10 const DEFAULT_SEND_DELAY_MS = 200 @@ -42,7 +37,7 @@ function getRetryAfterSeconds(error: unknown): number { // Move a message to the dead letter queue and log the reason. async function moveToDlq( - supabase: AnyClient, + supabase: ReturnType, queue: string, msg: { msg_id: number; message: Record }, reason: string @@ -94,7 +89,7 @@ export const Route = createFileRoute("/lovable/email/queue/process")({ return Response.json({ error: 'Forbidden' }, { status: 403 }) } - const supabase = createClient(supabaseUrl, supabaseServiceKey) + const supabase = createClient(supabaseUrl, supabaseServiceKey) // 1. Check rate-limit cooldown and read queue config const { data: state } = await supabase From babb57c42801b4d05dcc1b3ae38f63ede00d20f4 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:24:30 +0000 Subject: [PATCH 3/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/lovable/email/queue/process.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/lovable/email/queue/process.ts b/src/routes/lovable/email/queue/process.ts index 4608eec..ddb0c90 100644 --- a/src/routes/lovable/email/queue/process.ts +++ b/src/routes/lovable/email/queue/process.ts @@ -2,6 +2,11 @@ import { sendLovableEmail } from '@lovable.dev/email-js' import { createClient } from '@supabase/supabase-js' import { createFileRoute } from '@tanstack/react-router' +// The email infra tables (email_send_log, email_send_state, etc.) are not in +// the generated Database types, so we use an untyped client throughout this +// route. Tables are created by the email infra migration. +type AnyClient = ReturnType> + const MAX_RETRIES = 5 const DEFAULT_BATCH_SIZE = 10 const DEFAULT_SEND_DELAY_MS = 200 @@ -37,7 +42,7 @@ function getRetryAfterSeconds(error: unknown): number { // Move a message to the dead letter queue and log the reason. async function moveToDlq( - supabase: ReturnType, + supabase: AnyClient, queue: string, msg: { msg_id: number; message: Record }, reason: string From 5f65fd20c576fe14cd974d0bf188fafc2624ce1f Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:24:44 +0000 Subject: [PATCH 4/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/lovable/email/queue/process.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/lovable/email/queue/process.ts b/src/routes/lovable/email/queue/process.ts index ddb0c90..c424679 100644 --- a/src/routes/lovable/email/queue/process.ts +++ b/src/routes/lovable/email/queue/process.ts @@ -94,7 +94,7 @@ export const Route = createFileRoute("/lovable/email/queue/process")({ return Response.json({ error: 'Forbidden' }, { status: 403 }) } - const supabase = createClient(supabaseUrl, supabaseServiceKey) + const supabase = createClient(supabaseUrl, supabaseServiceKey) // 1. Check rate-limit cooldown and read queue config const { data: state } = await supabase