Files
triqura-ecd/lib/supabase
colinislit 982b23c4dc fix: consolidate database types to single source of truth
BREAKING: Removed duplicate lib/database.types.ts in favor of
lib/supabase/database.types.ts

Problem:
- Database types existed in two locations causing sync issues
- Old lib/database.types.ts was empty (0 bytes)
- Import paths were inconsistent across codebase
- Build failed due to missing type definitions

Solution:
- Generated fresh types from remote Supabase database
- Updated all imports from @/lib/database.types to @/lib/supabase/database.types
- Removed duplicate lib/database.types.ts file

Affected modules:
- lib/auth/server.ts - Auth server utilities
- lib/auth/client.ts - Auth client utilities
- lib/types/client.ts - Client type definitions
- lib/fhir/transforms/patient.ts - FHIR patient transforms
- lib/fhir/transforms/practitioner.ts - FHIR practitioner transforms

Impact: All database queries now use up-to-date type definitions
including new tables (intakes, risk_assessments, encounters, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 12:19:47 +01:00
..

Supabase Configuration

Deze folder bevat de Supabase client configuratie voor het Mini-EPD project.

Bestanden

  • client.ts - Client-side Supabase client (browser-safe, gebruikt anon key)
  • server.ts - Server-side Supabase client (admin, gebruikt service role key)
  • types.ts - TypeScript types (auto-gegenereerd uit database schema)
  • index.ts - Export file voor makkelijke imports

Gebruik

Client-side (React components)

import { supabase } from '@/lib/supabase'

// Voorbeeld: ophalen van clients
const { data, error } = await supabase
  .from('clients')
  .select('*')

Server-side (API routes, Server Components)

import { supabaseAdmin } from '@/lib/supabase/server'

// Voorbeeld: admin operatie
const { data, error } = await supabaseAdmin
  .from('clients')
  .insert({ ... })

TypeScript Types Genereren

Na het aanmaken van database schema (EP01), run:

pnpm run types:generate

Dit genereert TypeScript types uit je Supabase database schema.

Environment Variables

Zorg dat deze variabelen in .env.local staan:

NEXT_PUBLIC_SUPABASE_URL=https://dqugbrpwtisgyxscpefg.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=...
SUPABASE_SERVICE_ROLE_KEY=...

Security

⚠️ Belangrijk:

  • NEXT_PUBLIC_* variabelen zijn zichtbaar in de browser
  • SUPABASE_SERVICE_ROLE_KEY moet NOOIT naar de client worden gestuurd
  • Gebruik supabase (client) voor frontend operaties
  • Gebruik supabaseAdmin (server) alleen in API routes en Server Components

Volgende Stappen

  1. EP00-ST03: Supabase configuratie (Done)
  2. EP01-ST01: Database schema aanmaken
  3. EP01-ST02: Row Level Security policies
  4. EP02-ST01: Authentication implementeren