TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DavidCevallos15/inforario-IA-null/llms.txt
Use this file to discover all available pages before exploring further.
supabaseClient.ts service is the single entry point for all communication between Inforario’s frontend and the Supabase backend. It handles safe client initialization with a graceful dummy-object fallback, exposes typed wrappers around the schedules and profiles tables, provides authentication helpers, and calls the extract-schedule Edge Function for AI-powered PDF parsing.
Initialization exports
supabase
The shared Supabase client instance, created once at module load. Configuration is resolved in priority order:
VITE_SUPABASE_URL/VITE_SUPABASE_ANON_KEYenvironment variables (.env.local)- Hardcoded constants from
src/constants.ts(development fallback)
supabase is assigned a dummy object that mirrors the full Supabase client API (including from(), auth.*, and functions.invoke()). Every dummy method returns a resolved Promise containing { data: null, error: { message: "Database not configured" } } so the app never white-screens on misconfiguration.
Always check
isSupabaseConfigured() before performing writes. The dummy object silently swallows operations — data will not be persisted.isSupabaseConfigured()
true only when both VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY are present, non-empty, and do not contain the string "placeholder", and the real Supabase client was instantiated without throwing.
Database operations
All database functions silently guard against invaliduserId values that are not RFC 4122 UUIDs (e.g. guest device IDs) to prevent Supabase from returning HTTP 400 errors.
saveScheduleToDB()
schedule.id is present, otherwise performs an INSERT. Always writes last_updated as the current ISO timestamp.
Returns null when:
- Supabase is not configured
userIdis not a valid UUID- The database operation throws any error (logged to console)
The authenticated user’s UUID from Supabase Auth. Non-UUID values (guest device IDs) are silently rejected and
null is returned.The schedule object to persist. If
schedule.id is set the existing row is updated; otherwise a new row is inserted.schedules table
| Column | Value |
|---|---|
user_id | userId (INSERT only) |
title | schedule.title |
academic_period | schedule.academic_period |
schedule_data | schedule.sessions (JSON) |
faculty | schedule.faculty |
last_updated | new Date().toISOString() |
getUserSchedules()
schedule_data blob to keep list views fast. The returned objects are partial rows, not full DBResponseSchedule shapes.
Returns [] when:
- Supabase is not configured
userIdis falsy or not a valid UUID (guest users)- The query errors
The authenticated user’s UUID. Guest/device IDs (non-UUID) skip the network request entirely and return an empty array.
id, title, academic_period, last_updatedOrder:
last_updated descending (most recently saved first)
getScheduleById()
schedule_data JSON column (i.e. the complete ClassSession[] array). Returns null if Supabase is unconfigured, the row is not found, or any error occurs.
The UUID of the schedule row to retrieve.
deleteSchedule()
UUID of the schedule to delete.
getUserProfile()
profiles table. Returns null if Supabase is unconfigured, userId is not a UUID, the row is missing, or any query error occurs (error is swallowed — null is returned rather than throwing).
The authenticated user’s UUID.
Authentication helpers
All auth helpers delegate tosupabase.auth and follow the same pattern: they call the underlying Supabase method, throw if error is truthy, and return data on success.
signInWithGoogle()
window.location.origin so the user is returned to the current deployment after consent.
signInWithEmail()
supabase.auth.signInWithPassword.
The user’s registered email address.
The user’s password.
signUpWithEmail()
full_name inside the options.data metadata object so Supabase can populate the profiles table via trigger.
New user’s email address.
Password for the new account.
Display name stored under
data.full_name in the Supabase Auth user record.resetPasswordForEmail()
supabase.auth.resetPasswordForEmail. The redirectTo is set to window.location.origin.
Email address of the account to reset.
AI extraction
parseScheduleFileWithEdge()
pdfjs-dist, sends the plain-text content to the extract-schedule Supabase Edge Function (which calls an LLM), then maps and validates the response into a typed ClassSession[].
A base64-encoded data URL of the PDF file (e.g.
data:application/pdf;base64,JVBERi0x…). The data:*;base64, prefix is stripped internally before decoding.mapSessions()
isVirtualistrueifitem.isVirtual === trueor the location contains"VIRTUAL"(case-insensitive)dayis mapped throughDAY_MAP(Lunes→'Lunes', etc.); unknown days becomeundefinedstartTimeandendTimeare validated against/^([01]\d|2[0-3]):[0-5]\d$/- Subject names have
"TECNOLOGÍAS DE LA"prefixes and parenthetical codes (e.g.(A19)) stripped - Sessions with an empty
subjectare dropped - Non-virtual sessions with a missing
dayor invalid times are dropped - Each valid session receives a fresh
crypto.randomUUID()as itsid
| Condition | Error message |
|---|---|
| Supabase not configured | 'Supabase no está configurado para usar extracción por IA.' |
| PDF text extraction fails | 'No se pudo extraer texto del PDF.' |
| Edge Function returns an error | The Edge Function’s error message |
| Response contains no valid sessions | 'La IA no devolvió sesiones válidas.' |