From b2b463491ae271623db31897915231da7317292d Mon Sep 17 00:00:00 2001 From: Moheeb Zara Date: Tue, 4 Aug 2026 22:21:29 -0700 Subject: [PATCH] refactor(types): regenerate database types from canonical schema; drop TODO(types) join casts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regenerate types/database.ts from a local Supabase built from the canonical scripts/schema.sql. The running dev DB was stale (missing the 'stripe' payment_platform value, members_with_permission, spaces.host_requires_card, payments.link_status, dues_payment_methods.space_id), so it was rebuilt from schema.sql first. With real relationship metadata the 11 `as unknown as … // TODO(types)` join casts are no longer needed: - me portal, session-attendance, member-certifications, equipment-reservations: narrow the action result with `'data' in res` instead of a blanket cast. - stripe / door embeds read the now-typed relation directly. - completeSession + listEquipmentReservations route the embedded-select query through the fully-typed createClient() rather than the wide ServerSupabase gate client (the pattern documented in auth-helpers.ts); equipment disambiguates its two space_members FKs with an explicit !fkey hint. Collapse the hand-maintained governance rows/enums in types/domain/governance.ts into Tables<>/Enums<> aliases. Tighten duesPaymentMethodSchema.platform to the DUES_LINK_PLATFORMS literal union (the old `as unknown as [string,...]` erased it), which the now-correct payment_platform enum requires. The hand-added class_signup_tx / class_cancel_tx RPC entries are now generated natively. typecheck 0 · lint 0 errors · 645 tests · build ok --- app/(app)/me/page.tsx | 6 +- .../member-certifications-dialog.tsx | 3 +- components/classes/session-attendance.tsx | 3 +- .../equipment/equipment-reservations.tsx | 3 +- lib/actions/classes/instructor.ts | 6 +- lib/actions/classes/sessions.ts | 23 +- lib/actions/classes/signups.ts | 5 +- lib/actions/door/operate.ts | 3 +- lib/actions/equipment.ts | 5 +- lib/actions/stripe.ts | 3 +- lib/validations/dues.ts | 2 +- types/database.ts | 2277 +++++++++++++++-- types/domain/governance.ts | 181 +- 13 files changed, 2055 insertions(+), 465 deletions(-) diff --git a/app/(app)/me/page.tsx b/app/(app)/me/page.tsx index 9fb5e5d..b1d6a86 100644 --- a/app/(app)/me/page.tsx +++ b/app/(app)/me/page.tsx @@ -98,12 +98,10 @@ export default async function MePage() { })) const signupRes = await getMyClassSignups() - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - const classSignups: ClassSignup[] = 'data' in signupRes ? (signupRes.data as unknown as ClassSignup[]) : [] + const classSignups: ClassSignup[] = 'data' in signupRes ? (signupRes.data ?? []) : [] const reservationRes = await getMyReservations() - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - const reservations: Reservation[] = 'data' in reservationRes ? (reservationRes.data as unknown as Reservation[]) : [] + const reservations: Reservation[] = 'data' in reservationRes ? (reservationRes.data ?? []) : [] const cardsRes = await getMyCards() const myCards: MyCard[] = 'data' in cardsRes ? (cardsRes.data as MyCard[]) : [] diff --git a/components/certifications/member-certifications-dialog.tsx b/components/certifications/member-certifications-dialog.tsx index 6bcbb6c..4f02c05 100644 --- a/components/certifications/member-certifications-dialog.tsx +++ b/components/certifications/member-certifications-dialog.tsx @@ -68,8 +68,7 @@ export function MemberCertificationsDialog({ if ('error' in g && g.error) { toast.error(g.error) } else { - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - setGrants(((g as unknown as { data: Grant[] }).data) ?? []) + setGrants(('data' in g ? g.data : []) ?? []) } if (!('error' in t) || !t.error) { setTypes(((t as { data: CertType[] }).data ?? []).filter(c => c.is_active)) diff --git a/components/classes/session-attendance.tsx b/components/classes/session-attendance.tsx index 137326c..e325c49 100644 --- a/components/classes/session-attendance.tsx +++ b/components/classes/session-attendance.tsx @@ -35,8 +35,7 @@ export function SessionAttendance({ toast.error(res.error) return } - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - setRows(((res as unknown as { data: Signup[] }).data) ?? []) + setRows(('data' in res ? res.data : []) ?? []) }, [sessionId]) useEffect(() => { diff --git a/components/equipment/equipment-reservations.tsx b/components/equipment/equipment-reservations.tsx index 95fbf3d..4ce28d3 100644 --- a/components/equipment/equipment-reservations.tsx +++ b/components/equipment/equipment-reservations.tsx @@ -33,8 +33,7 @@ export function EquipmentReservations({ equipmentId }: { equipmentId: string }) toast.error(res.error) return } - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - setRows(((res as unknown as { data: Reservation[] }).data) ?? []) + setRows(('data' in res ? res.data : []) ?? []) }, [equipmentId]) useEffect(() => { diff --git a/lib/actions/classes/instructor.ts b/lib/actions/classes/instructor.ts index 84d6e62..6dcaa7b 100644 --- a/lib/actions/classes/instructor.ts +++ b/lib/actions/classes/instructor.ts @@ -80,7 +80,8 @@ export async function markAttendance(input: unknown) { export async function completeSession(input: unknown) { const gate = await requirePermission('classes.instruct') if (!gate.ok) return { error: gate.error } - const { supabase, member } = gate + const { member } = gate + const supabase = await createClient() const v = parseInput(sessionIdSchema, input) if (!v.ok) return { error: v.error } @@ -105,8 +106,7 @@ export async function completeSession(input: unknown) { .eq('space_id', member.space_id) if (upErr) return { error: upErr.message } - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - const cls = (session as unknown as { classes?: { title: string; grants_certification_id: string | null } | null }).classes + const cls = session.classes let issued = 0 let certSkipped = false if (cls?.grants_certification_id) { diff --git a/lib/actions/classes/sessions.ts b/lib/actions/classes/sessions.ts index ab3686f..e4fc2f1 100644 --- a/lib/actions/classes/sessions.ts +++ b/lib/actions/classes/sessions.ts @@ -212,27 +212,8 @@ export async function listUpcomingSessions() { .order('starts_at', { ascending: true }) if (error) return { error: error.message } - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - const rows = ((sessions ?? []) as unknown as Array<{ - id: string - class_id: string - starts_at: string - ends_at: string | null - location: string | null - capacity: number | null - status: string - notes: string | null - classes: { - title: string - description: string | null - payment_link: string | null - capacity: number | null - is_active: boolean - grants_certification_id: string | null - required_form_id: string | null - } | null - }>).filter( - (s: { classes?: { is_active?: boolean } | null }) => s.classes?.is_active !== false, + const rows = (sessions ?? []).filter( + (s) => s.classes?.is_active !== false, ) const ids = rows.map((s: { id: string }) => s.id) diff --git a/lib/actions/classes/signups.ts b/lib/actions/classes/signups.ts index 3bad483..f18ce74 100644 --- a/lib/actions/classes/signups.ts +++ b/lib/actions/classes/signups.ts @@ -43,10 +43,7 @@ export async function signUpForClass(input: unknown) { .eq('space_id', member.space_id) .maybeSingle() if (!session) return { error: 'Session not found' } - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - const cls = (session as unknown as { - classes?: { title: string | null; capacity: number | null; is_active: boolean; required_form_id: string | null } | null - }).classes + const cls = session.classes if (cls && cls.is_active === false) return { error: 'This class is no longer available.' } const { data: isMgr } = await supabase.rpc('user_has_permission', { diff --git a/lib/actions/door/operate.ts b/lib/actions/door/operate.ts index 8279389..6e5218c 100644 --- a/lib/actions/door/operate.ts +++ b/lib/actions/door/operate.ts @@ -225,8 +225,7 @@ export async function listDoorCards(input: unknown) { return { data: (cards ?? []).map(c => { - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - const sm = c.space_members as unknown as { display_name: string | null } | { display_name: string | null }[] | null + const sm = c.space_members const name = Array.isArray(sm) ? sm[0]?.display_name : sm?.display_name return { cardId: c.id as string, diff --git a/lib/actions/equipment.ts b/lib/actions/equipment.ts index 19d0993..ca87716 100644 --- a/lib/actions/equipment.ts +++ b/lib/actions/equipment.ts @@ -450,14 +450,15 @@ export async function cancelReservation(input: unknown) { export async function listEquipmentReservations(input: unknown) { const gate = await requireEquipmentManager() if (!gate.ok) return { error: gate.error } - const { supabase, member } = gate + const { member } = gate + const supabase = await createClient() const v = parseInput(listEquipmentReservationsSchema, input) if (!v.ok) return { error: v.error } const { data, error } = await supabase .from('equipment_reservations') - .select('id, member_id, starts_at, ends_at, status, notes, space_members(display_name, email)') + .select('id, member_id, starts_at, ends_at, status, notes, space_members!equipment_reservations_member_id_fkey(display_name, email)') .eq('space_id', member.space_id) .eq('equipment_id', v.data.equipmentId) .order('starts_at', { ascending: true }) diff --git a/lib/actions/stripe.ts b/lib/actions/stripe.ts index 0e6386f..94afa0f 100644 --- a/lib/actions/stripe.ts +++ b/lib/actions/stripe.ts @@ -257,8 +257,7 @@ export async function listMemberBilling() { if (error) return { error: error.message } return { data: (data ?? []).map(r => { - // TODO(types): remove after regenerating types/database.ts (missing FK relationship metadata) - const sm = r.space_members as unknown as { display_name: string | null; email: string | null; tier: string | null } | { display_name: string | null; email: string | null; tier: string | null }[] | null + const sm = r.space_members const mem = Array.isArray(sm) ? sm[0] : sm return { memberId: r.member_id as string, diff --git a/lib/validations/dues.ts b/lib/validations/dues.ts index e8daac0..6c9609a 100644 --- a/lib/validations/dues.ts +++ b/lib/validations/dues.ts @@ -6,7 +6,7 @@ import { DUES_LINK_PLATFORMS, isSafeDuesUrl } from '../dues-payments-logic' // member-clickable anchor. instructions is an optional memo hint (e.g. "put // your member name in the note") to help the treasurer reconcile later. export const duesPaymentMethodSchema = z.object({ - platform: z.enum(DUES_LINK_PLATFORMS as unknown as [string, ...string[]]), + platform: z.enum(DUES_LINK_PLATFORMS), url: z .string() .trim() diff --git a/types/database.ts b/types/database.ts index 63706ab..a2fe9a6 100644 --- a/types/database.ts +++ b/types/database.ts @@ -1,19 +1,3 @@ -// ============================================================================= -// GENERATED FILE — do not edit by hand. -// -// This is the Supabase-generated database type surface. Regenerate it wholesale -// from the live schema rather than hand-editing: -// -// supabase gen types typescript --schema public > types/database.ts -// -// Hand-written domain types live in types/domain/* (aliases, composites), NOT -// here. A few entries (the class_signup_tx / class_cancel_tx RPCs) are -// currently hand-added to match scripts/*.sql until the next regeneration; some -// embedded-select relationships are also missing from this file, which is why a -// handful of call sites carry `as unknown as // TODO(types)` casts — those -// disappear once this is regenerated against the real database. -// ============================================================================= - export type Json = | string | number @@ -23,219 +7,8 @@ export type Json = | Json[] export type Database = { - graphql_public: { - Tables: { - [_ in never]: never - } - Views: { - [_ in never]: never - } - Functions: { - graphql: { - Args: { - extensions?: Json - operationName?: string - query?: string - variables?: Json - } - Returns: Json - } - } - Enums: { - [_ in never]: never - } - CompositeTypes: { - [_ in never]: never - } - } public: { Tables: { - space_role_permissions: { - Row: { id: string; space_id: string; subject: string; permission: string; created_at: string } - Insert: { id?: string; space_id: string; subject: string; permission: string; created_at?: string } - Update: { id?: string; space_id?: string; subject?: string; permission?: string; created_at?: string } - Relationships: [] - } - ops_acl: { - Row: { id: string; space_id: string; entity_type: string; entity_id: string; role: string; created_at: string } - Insert: { id?: string; space_id: string; entity_type: string; entity_id: string; role: string; created_at?: string } - Update: { id?: string; space_id?: string; entity_type?: string; entity_id?: string; role?: string; created_at?: string } - Relationships: [] - } - forum_threads: { - Row: { id: string; space_id: string; author_id: string | null; title: string; body: string | null; category: string; pinned: boolean; locked: boolean; comment_count: number; last_comment_at: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; author_id?: string | null; title: string; body?: string | null; category?: string; pinned?: boolean; locked?: boolean; comment_count?: number; last_comment_at?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; author_id?: string | null; title?: string; body?: string | null; category?: string; pinned?: boolean; locked?: boolean; comment_count?: number; last_comment_at?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - comments: { - Row: { id: string; space_id: string; entity_type: Database['public']['Enums']['comment_entity_type']; entity_id: string; author_id: string | null; parent_id: string | null; body: string; edited_at: string | null; created_at: string } - Insert: { id?: string; space_id: string; entity_type: Database['public']['Enums']['comment_entity_type']; entity_id: string; author_id?: string | null; parent_id?: string | null; body: string; edited_at?: string | null; created_at?: string } - Update: { id?: string; space_id?: string; entity_type?: Database['public']['Enums']['comment_entity_type']; entity_id?: string; author_id?: string | null; parent_id?: string | null; body?: string; edited_at?: string | null; created_at?: string } - Relationships: [] - } - space_tiers: { - Row: { id: string; space_id: string; slug: string; name: string; description: string | null; monthly_price_cents: number; billing_cadence: string; is_system: boolean; is_archived: boolean; sort_order: number; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; slug: string; name: string; description?: string | null; monthly_price_cents?: number; billing_cadence?: string; is_system?: boolean; is_archived?: boolean; sort_order?: number; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; slug?: string; name?: string; description?: string | null; monthly_price_cents?: number; billing_cadence?: string; is_system?: boolean; is_archived?: boolean; sort_order?: number; created_at?: string; updated_at?: string } - Relationships: [] - } - space_invites: { - Row: { id: string; space_id: string; code: string; label: string | null; expires_at: string | null; max_uses: number | null; uses_count: number; is_enabled: boolean; role: Database["public"]["Enums"]["member_role"]; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; code: string; label?: string | null; expires_at?: string | null; max_uses?: number | null; uses_count?: number; is_enabled?: boolean; role?: Database["public"]["Enums"]["member_role"]; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; code?: string; label?: string | null; expires_at?: string | null; max_uses?: number | null; uses_count?: number; is_enabled?: boolean; role?: Database["public"]["Enums"]["member_role"]; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - space_onboarding_steps: { - Row: { id: string; space_id: string; step_key: string; step_type: string; title: string; body: string | null; config: Json; is_enabled: boolean; is_required: boolean; is_system: boolean; sort_order: number; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; step_key: string; step_type: string; title: string; body?: string | null; config?: Json; is_enabled?: boolean; is_required?: boolean; is_system?: boolean; sort_order?: number; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; step_key?: string; step_type?: string; title?: string; body?: string | null; config?: Json; is_enabled?: boolean; is_required?: boolean; is_system?: boolean; sort_order?: number; created_at?: string; updated_at?: string } - Relationships: [] - } - space_role_labels: { - Row: { id: string; space_id: string; role: string; display_name: string | null; description: string | null; color: string | null; sort_order: number; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; role: string; display_name?: string | null; description?: string | null; color?: string | null; sort_order?: number; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; role?: string; display_name?: string | null; description?: string | null; color?: string | null; sort_order?: number; created_at?: string; updated_at?: string } - Relationships: [] - } - space_custom_roles: { - Row: { id: string; space_id: string; slug: string; name: string; description: string | null; color: string | null; sort_order: number; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; slug: string; name: string; description?: string | null; color?: string | null; sort_order?: number; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; slug?: string; name?: string; description?: string | null; color?: string | null; sort_order?: number; created_at?: string; updated_at?: string } - Relationships: [] - } - space_member_custom_roles: { - Row: { member_id: string; custom_role_id: string; assigned_at: string } - Insert: { member_id: string; custom_role_id: string; assigned_at?: string } - Update: { member_id?: string; custom_role_id?: string; assigned_at?: string } - Relationships: [] - } - forms: { - Row: { id: string; space_id: string; slug: string; title: string; description: string | null; kind: string; visibility: string; status: string; schema: Json; legal_text: string | null; version: number; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; slug: string; title: string; description?: string | null; kind?: string; visibility?: string; status?: string; schema?: Json; legal_text?: string | null; version?: number; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; slug?: string; title?: string; description?: string | null; kind?: string; visibility?: string; status?: string; schema?: Json; legal_text?: string | null; version?: number; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - form_submissions: { - Row: { id: string; form_id: string; space_id: string; member_id: string | null; submitter_email: string | null; answers: Json; form_snapshot: Json; legal_text_snapshot: string | null; form_version: number; ip: string | null; user_agent: string | null; created_at: string } - Insert: { id?: string; form_id: string; space_id: string; member_id?: string | null; submitter_email?: string | null; answers?: Json; form_snapshot: Json; legal_text_snapshot?: string | null; form_version: number; ip?: string | null; user_agent?: string | null; created_at?: string } - Update: { id?: string; form_id?: string; space_id?: string; member_id?: string | null; submitter_email?: string | null; answers?: Json; form_snapshot?: Json; legal_text_snapshot?: string | null; form_version?: number; ip?: string | null; user_agent?: string | null; created_at?: string } - Relationships: [] - } - certifications: { - Row: { id: string; space_id: string; name: string; description: string | null; validity_months: number | null; is_active: boolean; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; name: string; description?: string | null; validity_months?: number | null; is_active?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; name?: string; description?: string | null; validity_months?: number | null; is_active?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - member_certifications: { - Row: { id: string; space_id: string; member_id: string; certification_id: string; granted_by: string | null; granted_at: string; expires_at: string | null; revoked_at: string | null; revoked_by: string | null; revoked_reason: string | null; note: string | null; created_at: string } - Insert: { id?: string; space_id: string; member_id: string; certification_id: string; granted_by?: string | null; granted_at?: string; expires_at?: string | null; revoked_at?: string | null; revoked_by?: string | null; revoked_reason?: string | null; note?: string | null; created_at?: string } - Update: { id?: string; space_id?: string; member_id?: string; certification_id?: string; granted_by?: string | null; granted_at?: string; expires_at?: string | null; revoked_at?: string | null; revoked_by?: string | null; revoked_reason?: string | null; note?: string | null; created_at?: string } - Relationships: [] - } - classes: { - Row: { id: string; space_id: string; title: string; description: string | null; payment_link: string | null; capacity: number | null; is_active: boolean; grants_certification_id: string | null; required_form_id: string | null; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; title: string; description?: string | null; payment_link?: string | null; capacity?: number | null; is_active?: boolean; grants_certification_id?: string | null; required_form_id?: string | null; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; title?: string; description?: string | null; payment_link?: string | null; capacity?: number | null; is_active?: boolean; grants_certification_id?: string | null; required_form_id?: string | null; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - class_sessions: { - Row: { id: string; class_id: string; space_id: string; starts_at: string; ends_at: string | null; location: string | null; capacity: number | null; status: string; notes: string | null; created_at: string; updated_at: string } - Insert: { id?: string; class_id: string; space_id: string; starts_at: string; ends_at?: string | null; location?: string | null; capacity?: number | null; status?: string; notes?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; class_id?: string; space_id?: string; starts_at?: string; ends_at?: string | null; location?: string | null; capacity?: number | null; status?: string; notes?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - class_signups: { - Row: { id: string; session_id: string; space_id: string; member_id: string; status: string; attended: boolean; signed_up_at: string; created_at: string } - Insert: { id?: string; session_id: string; space_id: string; member_id: string; status?: string; attended?: boolean; signed_up_at?: string; created_at?: string } - Update: { id?: string; session_id?: string; space_id?: string; member_id?: string; status?: string; attended?: boolean; signed_up_at?: string; created_at?: string } - Relationships: [] - } - equipment: { - Row: { id: string; space_id: string; name: string; description: string | null; location: string | null; status: string; required_certification_id: string | null; asset_tag: string | null; is_active: boolean; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; name: string; description?: string | null; location?: string | null; status?: string; required_certification_id?: string | null; asset_tag?: string | null; is_active?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; name?: string; description?: string | null; location?: string | null; status?: string; required_certification_id?: string | null; asset_tag?: string | null; is_active?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - equipment_reservations: { - Row: { id: string; equipment_id: string; space_id: string; member_id: string; starts_at: string; ends_at: string; status: string; notes: string | null; created_by: string | null; created_at: string } - Insert: { id?: string; equipment_id: string; space_id: string; member_id: string; starts_at: string; ends_at: string; status?: string; notes?: string | null; created_by?: string | null; created_at?: string } - Update: { id?: string; equipment_id?: string; space_id?: string; member_id?: string; starts_at?: string; ends_at?: string; status?: string; notes?: string | null; created_by?: string | null; created_at?: string } - Relationships: [] - } - member_cards: { - Row: { id: string; space_id: string; member_id: string; card_uid: string; card_type: string; label: string | null; is_active: boolean; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; member_id: string; card_uid: string; card_type?: string; label?: string | null; is_active?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; member_id?: string; card_uid?: string; card_type?: string; label?: string | null; is_active?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - door_connections: { - Row: { id: string; space_id: string; name: string; adapter: string; base_url: string; pinned_host: string; auth_mode: string; auth_param: string | null; secret_ref: string | null; verbs: Json; allow_member_self_entry: boolean; is_enabled: boolean; inbound_enabled: boolean; inbound_secret_ref: string | null; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; name: string; adapter?: string; base_url: string; pinned_host: string; auth_mode?: string; auth_param?: string | null; secret_ref?: string | null; verbs?: Json; allow_member_self_entry?: boolean; is_enabled?: boolean; inbound_enabled?: boolean; inbound_secret_ref?: string | null; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; name?: string; adapter?: string; base_url?: string; pinned_host?: string; auth_mode?: string; auth_param?: string | null; secret_ref?: string | null; verbs?: Json; allow_member_self_entry?: boolean; is_enabled?: boolean; inbound_enabled?: boolean; inbound_secret_ref?: string | null; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - door_access_log: { - Row: { id: string; space_id: string; connection_id: string | null; actor_member_id: string | null; target_member_id: string | null; action: string; success: boolean; detail: string | null; dedupe_key: string | null; occurred_at: string } - Insert: { id?: string; space_id: string; connection_id?: string | null; actor_member_id?: string | null; target_member_id?: string | null; action: string; success?: boolean; detail?: string | null; dedupe_key?: string | null; occurred_at?: string } - Update: { id?: string; space_id?: string; connection_id?: string | null; actor_member_id?: string | null; target_member_id?: string | null; action?: string; success?: boolean; detail?: string | null; dedupe_key?: string | null; occurred_at?: string } - Relationships: [] - } - door_card_slots: { - Row: { id: string; space_id: string; connection_id: string; card_id: string; slot: number; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; connection_id: string; card_id: string; slot: number; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; connection_id?: string; card_id?: string; slot?: number; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - api_buttons: { - Row: { id: string; space_id: string; label: string; button_group: string; sort_order: number; method: string; base_url: string; pinned_host: string; url_template: string | null; headers: Json; body_template: string | null; auth_mode: string; auth_param: string | null; secret_ref: string | null; required_permission: string; confirm: boolean; is_enabled: boolean; created_by: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; label: string; button_group?: string; sort_order?: number; method?: string; base_url: string; pinned_host: string; url_template?: string | null; headers?: Json; body_template?: string | null; auth_mode?: string; auth_param?: string | null; secret_ref?: string | null; required_permission?: string; confirm?: boolean; is_enabled?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; label?: string; button_group?: string; sort_order?: number; method?: string; base_url?: string; pinned_host?: string; url_template?: string | null; headers?: Json; body_template?: string | null; auth_mode?: string; auth_param?: string | null; secret_ref?: string | null; required_permission?: string; confirm?: boolean; is_enabled?: boolean; created_by?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - api_call_log: { - Row: { id: string; space_id: string; button_id: string | null; actor_member_id: string | null; action: string; success: boolean; detail: string | null; occurred_at: string } - Insert: { id?: string; space_id: string; button_id?: string | null; actor_member_id?: string | null; action: string; success?: boolean; detail?: string | null; occurred_at?: string } - Update: { id?: string; space_id?: string; button_id?: string | null; actor_member_id?: string | null; action?: string; success?: boolean; detail?: string | null; occurred_at?: string } - Relationships: [] - } - space_visits: { - Row: { id: string; space_id: string; member_id: string; checked_in_at: string; checked_out_at: string | null; is_host: boolean; check_in_note: string | null; check_out_note: string | null; created_at: string } - Insert: { id?: string; space_id: string; member_id: string; checked_in_at?: string; checked_out_at?: string | null; is_host?: boolean; check_in_note?: string | null; check_out_note?: string | null; created_at?: string } - Update: { id?: string; space_id?: string; member_id?: string; checked_in_at?: string; checked_out_at?: string | null; is_host?: boolean; check_in_note?: string | null; check_out_note?: string | null; created_at?: string } - Relationships: [] - } - member_billing: { - Row: { id: string; space_id: string; member_id: string; stripe_customer_id: string | null; stripe_subscription_id: string | null; subscription_status: string | null; current_period_end: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; member_id: string; stripe_customer_id?: string | null; stripe_subscription_id?: string | null; subscription_status?: string | null; current_period_end?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; member_id?: string; stripe_customer_id?: string | null; stripe_subscription_id?: string | null; subscription_status?: string | null; current_period_end?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - stripe_webhook_events: { - Row: { event_id: string; space_id: string | null; type: string | null; received_at: string } - Insert: { event_id: string; space_id?: string | null; type?: string | null; received_at?: string } - Update: { event_id?: string; space_id?: string | null; type?: string | null; received_at?: string } - Relationships: [] - } - notifications: { - Row: { id: string; space_id: string; member_id: string | null; type: string; channel: string; recipient: string; subject: string; body_html: string; body_text: string; status: string; attempts: number; last_error: string | null; dedupe_key: string; sent_at: string | null; read_at: string | null; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; member_id?: string | null; type: string; channel?: string; recipient: string; subject: string; body_html: string; body_text: string; status?: string; attempts?: number; last_error?: string | null; dedupe_key: string; sent_at?: string | null; read_at?: string | null; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; member_id?: string | null; type?: string; channel?: string; recipient?: string; subject?: string; body_html?: string; body_text?: string; status?: string; attempts?: number; last_error?: string | null; dedupe_key?: string; sent_at?: string | null; read_at?: string | null; created_at?: string; updated_at?: string } - Relationships: [] - } - notification_preferences: { - Row: { space_id: string; member_id: string; category: string; enabled: boolean; created_at: string; updated_at: string } - Insert: { space_id: string; member_id: string; category: string; enabled?: boolean; created_at?: string; updated_at?: string } - Update: { space_id?: string; member_id?: string; category?: string; enabled?: boolean; created_at?: string; updated_at?: string } - Relationships: [] - } - dues_payment_methods: { - Row: { id: string; space_id: string; platform: string; url: string; instructions: string | null; is_active: boolean; sort_order: number; created_at: string; updated_at: string } - Insert: { id?: string; space_id: string; platform: string; url: string; instructions?: string | null; is_active?: boolean; sort_order?: number; created_at?: string; updated_at?: string } - Update: { id?: string; space_id?: string; platform?: string; url?: string; instructions?: string | null; is_active?: boolean; sort_order?: number; created_at?: string; updated_at?: string } - Relationships: [] - } activity_log: { Row: { action: string @@ -283,6 +56,166 @@ export type Database = { }, ] } + api_buttons: { + Row: { + auth_mode: string + auth_param: string | null + base_url: string + body_template: string | null + button_group: string + confirm: boolean + created_at: string + created_by: string | null + headers: Json + id: string + is_enabled: boolean + label: string + method: string + pinned_host: string + required_permission: string + secret_ref: string | null + sort_order: number + space_id: string + updated_at: string + url_template: string | null + } + Insert: { + auth_mode?: string + auth_param?: string | null + base_url: string + body_template?: string | null + button_group?: string + confirm?: boolean + created_at?: string + created_by?: string | null + headers?: Json + id?: string + is_enabled?: boolean + label: string + method?: string + pinned_host: string + required_permission?: string + secret_ref?: string | null + sort_order?: number + space_id: string + updated_at?: string + url_template?: string | null + } + Update: { + auth_mode?: string + auth_param?: string | null + base_url?: string + body_template?: string | null + button_group?: string + confirm?: boolean + created_at?: string + created_by?: string | null + headers?: Json + id?: string + is_enabled?: boolean + label?: string + method?: string + pinned_host?: string + required_permission?: string + secret_ref?: string | null + sort_order?: number + space_id?: string + updated_at?: string + url_template?: string | null + } + Relationships: [ + { + foreignKeyName: "api_buttons_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "api_buttons_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "api_buttons_secret_ref_fkey" + columns: ["secret_ref"] + isOneToOne: false + referencedRelation: "secrets" + referencedColumns: ["id"] + }, + { + foreignKeyName: "api_buttons_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + api_call_log: { + Row: { + action: string + actor_member_id: string | null + button_id: string | null + detail: string | null + id: string + occurred_at: string + space_id: string + success: boolean + } + Insert: { + action: string + actor_member_id?: string | null + button_id?: string | null + detail?: string | null + id?: string + occurred_at?: string + space_id: string + success?: boolean + } + Update: { + action?: string + actor_member_id?: string | null + button_id?: string | null + detail?: string | null + id?: string + occurred_at?: string + space_id?: string + success?: boolean + } + Relationships: [ + { + foreignKeyName: "api_call_log_actor_member_id_fkey" + columns: ["actor_member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "api_call_log_actor_member_id_fkey" + columns: ["actor_member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "api_call_log_button_id_fkey" + columns: ["button_id"] + isOneToOne: false + referencedRelation: "api_buttons" + referencedColumns: ["id"] + }, + { + foreignKeyName: "api_call_log_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } area_leads: { Row: { area_code: string | null @@ -347,6 +280,329 @@ export type Database = { }, ] } + certifications: { + Row: { + created_at: string + created_by: string | null + description: string | null + id: string + is_active: boolean + name: string + space_id: string + updated_at: string + validity_months: number | null + } + Insert: { + created_at?: string + created_by?: string | null + description?: string | null + id?: string + is_active?: boolean + name: string + space_id: string + updated_at?: string + validity_months?: number | null + } + Update: { + created_at?: string + created_by?: string | null + description?: string | null + id?: string + is_active?: boolean + name?: string + space_id?: string + updated_at?: string + validity_months?: number | null + } + Relationships: [ + { + foreignKeyName: "certifications_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "certifications_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "certifications_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + class_sessions: { + Row: { + capacity: number | null + class_id: string + created_at: string + ends_at: string | null + id: string + location: string | null + notes: string | null + space_id: string + starts_at: string + status: string + updated_at: string + } + Insert: { + capacity?: number | null + class_id: string + created_at?: string + ends_at?: string | null + id?: string + location?: string | null + notes?: string | null + space_id: string + starts_at: string + status?: string + updated_at?: string + } + Update: { + capacity?: number | null + class_id?: string + created_at?: string + ends_at?: string | null + id?: string + location?: string | null + notes?: string | null + space_id?: string + starts_at?: string + status?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "class_sessions_class_id_fkey" + columns: ["class_id"] + isOneToOne: false + referencedRelation: "classes" + referencedColumns: ["id"] + }, + { + foreignKeyName: "class_sessions_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + class_signups: { + Row: { + attended: boolean + created_at: string + id: string + member_id: string + session_id: string + signed_up_at: string + space_id: string + status: string + } + Insert: { + attended?: boolean + created_at?: string + id?: string + member_id: string + session_id: string + signed_up_at?: string + space_id: string + status?: string + } + Update: { + attended?: boolean + created_at?: string + id?: string + member_id?: string + session_id?: string + signed_up_at?: string + space_id?: string + status?: string + } + Relationships: [ + { + foreignKeyName: "class_signups_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "class_signups_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "class_signups_session_id_fkey" + columns: ["session_id"] + isOneToOne: false + referencedRelation: "class_sessions" + referencedColumns: ["id"] + }, + { + foreignKeyName: "class_signups_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + classes: { + Row: { + capacity: number | null + created_at: string + created_by: string | null + description: string | null + grants_certification_id: string | null + id: string + is_active: boolean + payment_link: string | null + required_form_id: string | null + space_id: string + title: string + updated_at: string + } + Insert: { + capacity?: number | null + created_at?: string + created_by?: string | null + description?: string | null + grants_certification_id?: string | null + id?: string + is_active?: boolean + payment_link?: string | null + required_form_id?: string | null + space_id: string + title: string + updated_at?: string + } + Update: { + capacity?: number | null + created_at?: string + created_by?: string | null + description?: string | null + grants_certification_id?: string | null + id?: string + is_active?: boolean + payment_link?: string | null + required_form_id?: string | null + space_id?: string + title?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "classes_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "classes_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "classes_grants_certification_id_fkey" + columns: ["grants_certification_id"] + isOneToOne: false + referencedRelation: "certifications" + referencedColumns: ["id"] + }, + { + foreignKeyName: "classes_required_form_id_fkey" + columns: ["required_form_id"] + isOneToOne: false + referencedRelation: "forms" + referencedColumns: ["id"] + }, + { + foreignKeyName: "classes_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + comments: { + Row: { + author_id: string | null + body: string + created_at: string + edited_at: string | null + entity_id: string + entity_type: Database["public"]["Enums"]["comment_entity_type"] + id: string + parent_id: string | null + space_id: string + } + Insert: { + author_id?: string | null + body: string + created_at?: string + edited_at?: string | null + entity_id: string + entity_type: Database["public"]["Enums"]["comment_entity_type"] + id?: string + parent_id?: string | null + space_id: string + } + Update: { + author_id?: string | null + body?: string + created_at?: string + edited_at?: string | null + entity_id?: string + entity_type?: Database["public"]["Enums"]["comment_entity_type"] + id?: string + parent_id?: string | null + space_id?: string + } + Relationships: [ + { + foreignKeyName: "comments_author_id_fkey" + columns: ["author_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "comments_author_id_fkey" + columns: ["author_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "comments_parent_id_fkey" + columns: ["parent_id"] + isOneToOne: false + referencedRelation: "comments" + referencedColumns: ["id"] + }, + { + foreignKeyName: "comments_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } comms_channels: { Row: { area_reference: string | null @@ -538,6 +794,667 @@ export type Database = { }, ] } + door_access_log: { + Row: { + action: string + actor_member_id: string | null + connection_id: string | null + dedupe_key: string | null + detail: string | null + id: string + occurred_at: string + space_id: string + success: boolean + target_member_id: string | null + } + Insert: { + action: string + actor_member_id?: string | null + connection_id?: string | null + dedupe_key?: string | null + detail?: string | null + id?: string + occurred_at?: string + space_id: string + success?: boolean + target_member_id?: string | null + } + Update: { + action?: string + actor_member_id?: string | null + connection_id?: string | null + dedupe_key?: string | null + detail?: string | null + id?: string + occurred_at?: string + space_id?: string + success?: boolean + target_member_id?: string | null + } + Relationships: [ + { + foreignKeyName: "door_access_log_actor_member_id_fkey" + columns: ["actor_member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_access_log_actor_member_id_fkey" + columns: ["actor_member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_access_log_connection_id_fkey" + columns: ["connection_id"] + isOneToOne: false + referencedRelation: "door_connections" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_access_log_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_access_log_target_member_id_fkey" + columns: ["target_member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_access_log_target_member_id_fkey" + columns: ["target_member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + ] + } + door_card_slots: { + Row: { + card_id: string + connection_id: string + created_at: string + created_by: string | null + id: string + slot: number + space_id: string + updated_at: string + } + Insert: { + card_id: string + connection_id: string + created_at?: string + created_by?: string | null + id?: string + slot: number + space_id: string + updated_at?: string + } + Update: { + card_id?: string + connection_id?: string + created_at?: string + created_by?: string | null + id?: string + slot?: number + space_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "door_card_slots_card_id_fkey" + columns: ["card_id"] + isOneToOne: false + referencedRelation: "member_cards" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_card_slots_connection_id_fkey" + columns: ["connection_id"] + isOneToOne: false + referencedRelation: "door_connections" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_card_slots_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_card_slots_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_card_slots_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + door_connections: { + Row: { + adapter: string + allow_member_self_entry: boolean + auth_mode: string + auth_param: string | null + base_url: string + created_at: string + created_by: string | null + id: string + inbound_enabled: boolean + inbound_secret_ref: string | null + is_enabled: boolean + name: string + pinned_host: string + secret_ref: string | null + space_id: string + updated_at: string + verbs: Json + } + Insert: { + adapter?: string + allow_member_self_entry?: boolean + auth_mode?: string + auth_param?: string | null + base_url: string + created_at?: string + created_by?: string | null + id?: string + inbound_enabled?: boolean + inbound_secret_ref?: string | null + is_enabled?: boolean + name: string + pinned_host: string + secret_ref?: string | null + space_id: string + updated_at?: string + verbs?: Json + } + Update: { + adapter?: string + allow_member_self_entry?: boolean + auth_mode?: string + auth_param?: string | null + base_url?: string + created_at?: string + created_by?: string | null + id?: string + inbound_enabled?: boolean + inbound_secret_ref?: string | null + is_enabled?: boolean + name?: string + pinned_host?: string + secret_ref?: string | null + space_id?: string + updated_at?: string + verbs?: Json + } + Relationships: [ + { + foreignKeyName: "door_connections_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_connections_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_connections_inbound_secret_ref_fkey" + columns: ["inbound_secret_ref"] + isOneToOne: false + referencedRelation: "secrets" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_connections_secret_ref_fkey" + columns: ["secret_ref"] + isOneToOne: false + referencedRelation: "secrets" + referencedColumns: ["id"] + }, + { + foreignKeyName: "door_connections_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + dues_payment_methods: { + Row: { + created_at: string + id: string + instructions: string | null + is_active: boolean + platform: Database["public"]["Enums"]["payment_platform"] + sort_order: number + space_id: string + updated_at: string + url: string + } + Insert: { + created_at?: string + id?: string + instructions?: string | null + is_active?: boolean + platform: Database["public"]["Enums"]["payment_platform"] + sort_order?: number + space_id: string + updated_at?: string + url: string + } + Update: { + created_at?: string + id?: string + instructions?: string | null + is_active?: boolean + platform?: Database["public"]["Enums"]["payment_platform"] + sort_order?: number + space_id?: string + updated_at?: string + url?: string + } + Relationships: [ + { + foreignKeyName: "dues_payment_methods_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + equipment: { + Row: { + asset_tag: string | null + created_at: string + created_by: string | null + description: string | null + id: string + is_active: boolean + location: string | null + name: string + required_certification_id: string | null + space_id: string + status: string + updated_at: string + } + Insert: { + asset_tag?: string | null + created_at?: string + created_by?: string | null + description?: string | null + id?: string + is_active?: boolean + location?: string | null + name: string + required_certification_id?: string | null + space_id: string + status?: string + updated_at?: string + } + Update: { + asset_tag?: string | null + created_at?: string + created_by?: string | null + description?: string | null + id?: string + is_active?: boolean + location?: string | null + name?: string + required_certification_id?: string | null + space_id?: string + status?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "equipment_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_required_certification_id_fkey" + columns: ["required_certification_id"] + isOneToOne: false + referencedRelation: "certifications" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + equipment_reservations: { + Row: { + created_at: string + created_by: string | null + ends_at: string + equipment_id: string + id: string + member_id: string + notes: string | null + space_id: string + starts_at: string + status: string + } + Insert: { + created_at?: string + created_by?: string | null + ends_at: string + equipment_id: string + id?: string + member_id: string + notes?: string | null + space_id: string + starts_at: string + status?: string + } + Update: { + created_at?: string + created_by?: string | null + ends_at?: string + equipment_id?: string + id?: string + member_id?: string + notes?: string | null + space_id?: string + starts_at?: string + status?: string + } + Relationships: [ + { + foreignKeyName: "equipment_reservations_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_reservations_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_reservations_equipment_id_fkey" + columns: ["equipment_id"] + isOneToOne: false + referencedRelation: "equipment" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_reservations_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_reservations_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "equipment_reservations_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + form_submissions: { + Row: { + answers: Json + created_at: string + form_id: string + form_snapshot: Json + form_version: number + id: string + ip: unknown + legal_text_snapshot: string | null + member_id: string | null + space_id: string + submitter_email: string | null + user_agent: string | null + } + Insert: { + answers?: Json + created_at?: string + form_id: string + form_snapshot: Json + form_version: number + id?: string + ip?: unknown + legal_text_snapshot?: string | null + member_id?: string | null + space_id: string + submitter_email?: string | null + user_agent?: string | null + } + Update: { + answers?: Json + created_at?: string + form_id?: string + form_snapshot?: Json + form_version?: number + id?: string + ip?: unknown + legal_text_snapshot?: string | null + member_id?: string | null + space_id?: string + submitter_email?: string | null + user_agent?: string | null + } + Relationships: [ + { + foreignKeyName: "form_submissions_form_id_fkey" + columns: ["form_id"] + isOneToOne: false + referencedRelation: "forms" + referencedColumns: ["id"] + }, + { + foreignKeyName: "form_submissions_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "form_submissions_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "form_submissions_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + forms: { + Row: { + created_at: string + created_by: string | null + description: string | null + id: string + kind: string + legal_text: string | null + schema: Json + slug: string + space_id: string + status: string + title: string + updated_at: string + version: number + visibility: string + } + Insert: { + created_at?: string + created_by?: string | null + description?: string | null + id?: string + kind?: string + legal_text?: string | null + schema?: Json + slug: string + space_id: string + status?: string + title: string + updated_at?: string + version?: number + visibility?: string + } + Update: { + created_at?: string + created_by?: string | null + description?: string | null + id?: string + kind?: string + legal_text?: string | null + schema?: Json + slug?: string + space_id?: string + status?: string + title?: string + updated_at?: string + version?: number + visibility?: string + } + Relationships: [ + { + foreignKeyName: "forms_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "forms_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "forms_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + forum_threads: { + Row: { + author_id: string | null + body: string | null + category: string + comment_count: number + created_at: string + id: string + last_comment_at: string | null + locked: boolean + pinned: boolean + space_id: string + title: string + updated_at: string + } + Insert: { + author_id?: string | null + body?: string | null + category?: string + comment_count?: number + created_at?: string + id?: string + last_comment_at?: string | null + locked?: boolean + pinned?: boolean + space_id: string + title: string + updated_at?: string + } + Update: { + author_id?: string | null + body?: string | null + category?: string + comment_count?: number + created_at?: string + id?: string + last_comment_at?: string | null + locked?: boolean + pinned?: boolean + space_id?: string + title?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "forum_threads_author_id_fkey" + columns: ["author_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "forum_threads_author_id_fkey" + columns: ["author_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "forum_threads_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } incident_updates: { Row: { author_id: string | null @@ -753,9 +1670,9 @@ export type Database = { id: string is_meeting_minutes: boolean is_pinned: boolean - render_markdown: boolean meeting_date: string | null pinned: boolean + render_markdown: boolean space_id: string tags: string[] | null title: string @@ -776,9 +1693,9 @@ export type Database = { id?: string is_meeting_minutes?: boolean is_pinned?: boolean - render_markdown?: boolean meeting_date?: string | null pinned?: boolean + render_markdown?: boolean space_id: string tags?: string[] | null title: string @@ -799,9 +1716,9 @@ export type Database = { id?: string is_meeting_minutes?: boolean is_pinned?: boolean - render_markdown?: boolean meeting_date?: string | null pinned?: boolean + render_markdown?: boolean space_id?: string tags?: string[] | null title?: string @@ -835,6 +1752,400 @@ export type Database = { }, ] } + member_billing: { + Row: { + created_at: string + current_period_end: string | null + id: string + member_id: string + space_id: string + stripe_customer_id: string | null + stripe_subscription_id: string | null + subscription_status: string | null + updated_at: string + } + Insert: { + created_at?: string + current_period_end?: string | null + id?: string + member_id: string + space_id: string + stripe_customer_id?: string | null + stripe_subscription_id?: string | null + subscription_status?: string | null + updated_at?: string + } + Update: { + created_at?: string + current_period_end?: string | null + id?: string + member_id?: string + space_id?: string + stripe_customer_id?: string | null + stripe_subscription_id?: string | null + subscription_status?: string | null + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "member_billing_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_billing_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_billing_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + member_cards: { + Row: { + card_type: string + card_uid: string + created_at: string + created_by: string | null + id: string + is_active: boolean + label: string | null + member_id: string + space_id: string + updated_at: string + } + Insert: { + card_type?: string + card_uid: string + created_at?: string + created_by?: string | null + id?: string + is_active?: boolean + label?: string | null + member_id: string + space_id: string + updated_at?: string + } + Update: { + card_type?: string + card_uid?: string + created_at?: string + created_by?: string | null + id?: string + is_active?: boolean + label?: string | null + member_id?: string + space_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "member_cards_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_cards_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_cards_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_cards_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_cards_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + member_certifications: { + Row: { + certification_id: string + created_at: string + expires_at: string | null + granted_at: string + granted_by: string | null + id: string + member_id: string + note: string | null + revoked_at: string | null + revoked_by: string | null + revoked_reason: string | null + space_id: string + } + Insert: { + certification_id: string + created_at?: string + expires_at?: string | null + granted_at?: string + granted_by?: string | null + id?: string + member_id: string + note?: string | null + revoked_at?: string | null + revoked_by?: string | null + revoked_reason?: string | null + space_id: string + } + Update: { + certification_id?: string + created_at?: string + expires_at?: string | null + granted_at?: string + granted_by?: string | null + id?: string + member_id?: string + note?: string | null + revoked_at?: string | null + revoked_by?: string | null + revoked_reason?: string | null + space_id?: string + } + Relationships: [ + { + foreignKeyName: "member_certifications_certification_id_fkey" + columns: ["certification_id"] + isOneToOne: false + referencedRelation: "certifications" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_certifications_granted_by_fkey" + columns: ["granted_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_certifications_granted_by_fkey" + columns: ["granted_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_certifications_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_certifications_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_certifications_revoked_by_fkey" + columns: ["revoked_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_certifications_revoked_by_fkey" + columns: ["revoked_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "member_certifications_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + notification_preferences: { + Row: { + category: string + created_at: string + enabled: boolean + member_id: string + space_id: string + updated_at: string + } + Insert: { + category: string + created_at?: string + enabled?: boolean + member_id: string + space_id: string + updated_at?: string + } + Update: { + category?: string + created_at?: string + enabled?: boolean + member_id?: string + space_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "notification_preferences_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "notification_preferences_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + ] + } + notifications: { + Row: { + attempts: number + body_html: string + body_text: string + channel: string + created_at: string + dedupe_key: string + id: string + last_error: string | null + member_id: string | null + read_at: string | null + recipient: string + sent_at: string | null + space_id: string + status: string + subject: string + type: string + updated_at: string + } + Insert: { + attempts?: number + body_html: string + body_text: string + channel?: string + created_at?: string + dedupe_key: string + id?: string + last_error?: string | null + member_id?: string | null + read_at?: string | null + recipient: string + sent_at?: string | null + space_id: string + status?: string + subject: string + type: string + updated_at?: string + } + Update: { + attempts?: number + body_html?: string + body_text?: string + channel?: string + created_at?: string + dedupe_key?: string + id?: string + last_error?: string | null + member_id?: string | null + read_at?: string | null + recipient?: string + sent_at?: string | null + space_id?: string + status?: string + subject?: string + type?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "notifications_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "notifications_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "notifications_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + ops_acl: { + Row: { + created_at: string + entity_id: string + entity_type: string + id: string + role: string + space_id: string + } + Insert: { + created_at?: string + entity_id: string + entity_type: string + id?: string + role: string + space_id: string + } + Update: { + created_at?: string + entity_id?: string + entity_type?: string + id?: string + role?: string + space_id?: string + } + Relationships: [ + { + foreignKeyName: "ops_acl_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } payments: { Row: { amount: number @@ -1265,14 +2576,14 @@ export type Database = { created_at: string created_by: string | null description: string | null + encrypted_value: string | null + encryption_version: number icon: string | null id: string label: string notes: string | null space_id: string title: string | null - encrypted_value: string | null - encryption_version: number updated_at: string value: string } @@ -1282,14 +2593,14 @@ export type Database = { created_at?: string created_by?: string | null description?: string | null + encrypted_value?: string | null + encryption_version?: number icon?: string | null id?: string label: string notes?: string | null space_id: string title?: string | null - encrypted_value?: string | null - encryption_version?: number updated_at?: string value: string } @@ -1299,14 +2610,14 @@ export type Database = { created_at?: string created_by?: string | null description?: string | null + encrypted_value?: string | null + encryption_version?: number icon?: string | null id?: string label?: string notes?: string | null space_id?: string title?: string | null - encrypted_value?: string | null - encryption_version?: number updated_at?: string value?: string } @@ -1364,6 +2675,157 @@ export type Database = { }, ] } + space_custom_roles: { + Row: { + color: string | null + created_at: string + description: string | null + id: string + name: string + slug: string + sort_order: number + space_id: string + updated_at: string + } + Insert: { + color?: string | null + created_at?: string + description?: string | null + id?: string + name: string + slug: string + sort_order?: number + space_id: string + updated_at?: string + } + Update: { + color?: string | null + created_at?: string + description?: string | null + id?: string + name?: string + slug?: string + sort_order?: number + space_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "space_custom_roles_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + space_invites: { + Row: { + code: string + created_at: string + created_by: string | null + expires_at: string | null + id: string + is_enabled: boolean + label: string | null + max_uses: number | null + role: Database["public"]["Enums"]["member_role"] + space_id: string + updated_at: string + uses_count: number + } + Insert: { + code: string + created_at?: string + created_by?: string | null + expires_at?: string | null + id?: string + is_enabled?: boolean + label?: string | null + max_uses?: number | null + role?: Database["public"]["Enums"]["member_role"] + space_id: string + updated_at?: string + uses_count?: number + } + Update: { + code?: string + created_at?: string + created_by?: string | null + expires_at?: string | null + id?: string + is_enabled?: boolean + label?: string | null + max_uses?: number | null + role?: Database["public"]["Enums"]["member_role"] + space_id?: string + updated_at?: string + uses_count?: number + } + Relationships: [ + { + foreignKeyName: "space_invites_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "space_invites_created_by_fkey" + columns: ["created_by"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "space_invites_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + space_member_custom_roles: { + Row: { + assigned_at: string + custom_role_id: string + member_id: string + } + Insert: { + assigned_at?: string + custom_role_id: string + member_id: string + } + Update: { + assigned_at?: string + custom_role_id?: string + member_id?: string + } + Relationships: [ + { + foreignKeyName: "space_member_custom_roles_custom_role_id_fkey" + columns: ["custom_role_id"] + isOneToOne: false + referencedRelation: "space_custom_roles" + referencedColumns: ["id"] + }, + { + foreignKeyName: "space_member_custom_roles_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "space_member_custom_roles_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + ] + } space_members: { Row: { affiliations: string[] @@ -1382,6 +2844,8 @@ export type Database = { joined_at: string | null last_paid_at: string | null last_payment_at: string | null + onboarding_completed_at: string | null + onboarding_progress: Json payment_note: string | null payment_status: string | null phone: string | null @@ -1392,8 +2856,6 @@ export type Database = { stripe_customer_id: string | null tier: Database["public"]["Enums"]["member_tier"] tier_id: string | null - onboarding_completed_at: string | null - onboarding_progress: Json updated_at: string user_id: string | null willing_to: string[] @@ -1415,6 +2877,8 @@ export type Database = { joined_at?: string | null last_paid_at?: string | null last_payment_at?: string | null + onboarding_completed_at?: string | null + onboarding_progress?: Json payment_note?: string | null payment_status?: string | null phone?: string | null @@ -1425,8 +2889,6 @@ export type Database = { stripe_customer_id?: string | null tier?: Database["public"]["Enums"]["member_tier"] tier_id?: string | null - onboarding_completed_at?: string | null - onboarding_progress?: Json updated_at?: string user_id?: string | null willing_to?: string[] @@ -1448,6 +2910,8 @@ export type Database = { joined_at?: string | null last_paid_at?: string | null last_payment_at?: string | null + onboarding_completed_at?: string | null + onboarding_progress?: Json payment_note?: string | null payment_status?: string | null phone?: string | null @@ -1458,8 +2922,6 @@ export type Database = { stripe_customer_id?: string | null tier?: Database["public"]["Enums"]["member_tier"] tier_id?: string | null - onboarding_completed_at?: string | null - onboarding_progress?: Json updated_at?: string user_id?: string | null willing_to?: string[] @@ -1472,6 +2934,256 @@ export type Database = { referencedRelation: "spaces" referencedColumns: ["id"] }, + { + foreignKeyName: "space_members_tier_id_fkey" + columns: ["tier_id"] + isOneToOne: false + referencedRelation: "space_tiers" + referencedColumns: ["id"] + }, + ] + } + space_onboarding_steps: { + Row: { + body: string | null + config: Json + created_at: string + id: string + is_enabled: boolean + is_required: boolean + is_system: boolean + sort_order: number + space_id: string + step_key: string + step_type: string + title: string + updated_at: string + } + Insert: { + body?: string | null + config?: Json + created_at?: string + id?: string + is_enabled?: boolean + is_required?: boolean + is_system?: boolean + sort_order?: number + space_id: string + step_key: string + step_type: string + title: string + updated_at?: string + } + Update: { + body?: string | null + config?: Json + created_at?: string + id?: string + is_enabled?: boolean + is_required?: boolean + is_system?: boolean + sort_order?: number + space_id?: string + step_key?: string + step_type?: string + title?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "space_onboarding_steps_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + space_role_labels: { + Row: { + color: string | null + created_at: string + description: string | null + display_name: string | null + id: string + role: Database["public"]["Enums"]["member_role"] + sort_order: number + space_id: string + updated_at: string + } + Insert: { + color?: string | null + created_at?: string + description?: string | null + display_name?: string | null + id?: string + role: Database["public"]["Enums"]["member_role"] + sort_order?: number + space_id: string + updated_at?: string + } + Update: { + color?: string | null + created_at?: string + description?: string | null + display_name?: string | null + id?: string + role?: Database["public"]["Enums"]["member_role"] + sort_order?: number + space_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "space_role_labels_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + space_role_permissions: { + Row: { + created_at: string + id: string + permission: string + space_id: string + subject: string + } + Insert: { + created_at?: string + id?: string + permission: string + space_id: string + subject: string + } + Update: { + created_at?: string + id?: string + permission?: string + space_id?: string + subject?: string + } + Relationships: [ + { + foreignKeyName: "space_role_permissions_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + space_tiers: { + Row: { + billing_cadence: string + created_at: string + description: string | null + id: string + is_archived: boolean + is_system: boolean + monthly_price_cents: number + name: string + slug: string + sort_order: number + space_id: string + updated_at: string + } + Insert: { + billing_cadence?: string + created_at?: string + description?: string | null + id?: string + is_archived?: boolean + is_system?: boolean + monthly_price_cents?: number + name: string + slug: string + sort_order?: number + space_id: string + updated_at?: string + } + Update: { + billing_cadence?: string + created_at?: string + description?: string | null + id?: string + is_archived?: boolean + is_system?: boolean + monthly_price_cents?: number + name?: string + slug?: string + sort_order?: number + space_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "space_tiers_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } + space_visits: { + Row: { + check_in_note: string | null + check_out_note: string | null + checked_in_at: string + checked_out_at: string | null + created_at: string + id: string + is_host: boolean + member_id: string + space_id: string + } + Insert: { + check_in_note?: string | null + check_out_note?: string | null + checked_in_at?: string + checked_out_at?: string | null + created_at?: string + id?: string + is_host?: boolean + member_id: string + space_id: string + } + Update: { + check_in_note?: string | null + check_out_note?: string | null + checked_in_at?: string + checked_out_at?: string | null + created_at?: string + id?: string + is_host?: boolean + member_id?: string + space_id?: string + } + Relationships: [ + { + foreignKeyName: "space_visits_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "inactive_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "space_visits_member_id_fkey" + columns: ["member_id"] + isOneToOne: false + referencedRelation: "space_members" + referencedColumns: ["id"] + }, + { + foreignKeyName: "space_visits_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, ] } spaces: { @@ -1555,6 +3267,35 @@ export type Database = { } Relationships: [] } + stripe_webhook_events: { + Row: { + event_id: string + received_at: string + space_id: string | null + type: string | null + } + Insert: { + event_id: string + received_at?: string + space_id?: string | null + type?: string | null + } + Update: { + event_id?: string + received_at?: string + space_id?: string | null + type?: string | null + } + Relationships: [ + { + foreignKeyName: "stripe_webhook_events_space_id_fkey" + columns: ["space_id"] + isOneToOne: false + referencedRelation: "spaces" + referencedColumns: ["id"] + }, + ] + } tasks: { Row: { area: string | null @@ -1703,31 +3444,42 @@ export type Database = { } } Functions: { + class_cancel_tx: { + Args: { p_member_id: string; p_session_id: string; p_space_id: string } + Returns: { + cancelled_id: string + err: string + promoted_id: string + }[] + } + class_signup_tx: { + Args: { p_member_id: string; p_session_id: string; p_space_id: string } + Returns: { + err: string + signup_id: string + signup_status: string + }[] + } expire_proposals: { Args: never; Returns: number } get_user_space_ids: { Args: { uid: string }; Returns: string[] } + members_with_permission: { + Args: { perm: string; sid: string } + Returns: { + member_id: string + }[] + } + user_effective_roles: { + Args: { sid: string; uid: string } + Returns: string[] + } + user_has_permission: { + Args: { perm: string; sid: string; uid: string } + Returns: boolean + } user_has_role_in_space: { Args: { allowed_roles: string[]; sid: string; uid: string } Returns: boolean } - user_effective_roles: { Args: { uid: string; sid: string }; Returns: string[] } - user_has_permission: { - Args: { uid: string; sid: string; perm: string } - Returns: boolean - } - members_with_permission: { - Args: { sid: string; perm: string } - Returns: { member_id: string }[] - } - // Hand-added to match scripts/045_class_signup_concurrency.sql until this - // file is regenerated from the live schema (`supabase gen types typescript`). - class_signup_tx: { - Args: { p_session_id: string; p_space_id: string; p_member_id: string } - Returns: { signup_id: string | null; signup_status: string | null; err: string | null }[] - } - class_cancel_tx: { - Args: { p_session_id: string; p_space_id: string; p_member_id: string } - Returns: { cancelled_id: string | null; promoted_id: string | null; err: string | null }[] - } } Enums: { area_lead_status: "active" | "vacant" | "handoff" @@ -1909,9 +3661,6 @@ export type CompositeTypes< : never export const Constants = { - graphql_public: { - Enums: {}, - }, public: { Enums: { area_lead_status: ["active", "vacant", "handoff"], diff --git a/types/domain/governance.ts b/types/domain/governance.ts index b543211..1f6dfb8 100644 --- a/types/domain/governance.ts +++ b/types/domain/governance.ts @@ -1,161 +1,30 @@ /** - * Hand-written governance-kernel domain types (proposals, votes, incidents, - * policies, areas) and their enums. + * Governance-kernel domain types (proposals, votes, incidents, policies, + * areas) and their enums. * - * NOTE: the underlying tables and enums now ALSO exist in the generated - * `types/database.ts` (proposals, proposal_votes, incidents, incident_updates, - * policies, space_areas; proposal_type, incident_status, etc.). These shapes - * were hand-authored before that regeneration and are kept verbatim here to - * avoid a behavior change. Follow-up: after verifying field parity, replace the - * row types with `Tables<'proposals'>` etc. and the enums with - * `Enums<'proposal_type'>` etc., and delete the duplication. + * These are thin aliases over the generated database types (`types/database.ts`, + * regenerated from the canonical schema). Keep them as `Tables<>` / `Enums<>` + * aliases — do NOT hand-maintain the row shapes here; regenerate the database + * types instead. */ +import type { Tables, Enums } from '@/types/database' -export type ProposalType = - | 'bylaw_change' - | 'board_action' - | 'membership_vote' - | 'advisory_poll' - | 'recall' - | 'budget' +// Enums +export type ProposalType = Enums<'proposal_type'> +export type ProposalStatus = Enums<'proposal_status'> +export type ThresholdRule = Enums<'threshold_rule'> +export type VotePosition = Enums<'vote_position'> +export type IncidentStatus = Enums<'incident_status'> +export type IncidentSeverity = Enums<'incident_severity'> +export type IncidentUpdateVisibility = Enums<'incident_update_visibility'> +export type PolicyStatus = Enums<'policy_status'> +export type FinancialVisibility = Enums<'financial_visibility'> +export type DirectoryVisibility = Enums<'directory_visibility'> -export type ProposalStatus = - | 'draft' - | 'open' - | 'decided' - | 'withdrawn' - | 'expired' - -export type ThresholdRule = - | 'simple_majority' - | 'two_thirds' - | 'three_fourths' - | 'unanimous' - -export type VotePosition = 'yes' | 'no' | 'abstain' | 'recused' - -export type IncidentStatus = - | 'received' - | 'under_review' - | 'decided' - | 'appealed' - | 'closed' - -export type IncidentSeverity = 'low' | 'medium' | 'high' | 'critical' - -export type IncidentUpdateVisibility = - | 'reporter_only' - | 'all_parties' - | 'board_only' - -export type PolicyStatus = 'draft' | 'active' | 'deprecated' | 'superseded' - -export type SpaceArea = { - id: string - space_id: string - code: string - name: string - icon: string | null - sort_order: number - is_archived: boolean - created_at: string - updated_at: string -} - -export type FinancialVisibility = 'treasurer_only' | 'board_visible' | 'all_members_visible' - -export type DirectoryVisibility = - | 'board_only' - | 'member_count_visible' - | 'members_visible' - | 'public_members_visible' - -export type Proposal = { - id: string - space_id: string - proposer_id: string | null - proposer_name: string | null - title: string - body: string - proposal_type: ProposalType - status: ProposalStatus - quorum_required: number - quorum_percent: number - quorum_floor: number - threshold: ThresholdRule - voting_opens_at: string | null - voting_closes_at: string | null - policy_ref_id: string | null - parent_incident_id: string | null - outcome_yes: number - outcome_no: number - outcome_abstain: number - outcome_recused: number - total_voters: number - quorum_met: boolean | null - passed: boolean | null - created_at: string - updated_at: string - decided_at: string | null -} - -export type ProposalVote = { - id: string - proposal_id: string - member_id: string - position: VotePosition - recusal_reason: string | null - comment: string | null - voted_at: string -} - -export type Incident = { - id: string - space_id: string - reporter_id: string | null - reporter_token: string | null - is_anonymous: boolean - subjects: string[] - category: string - severity: IncidentSeverity - title: string - body: string - status: IncidentStatus - disposition: string | null - decision_maker_ids: string[] - appeal_proposal_id: string | null - sla_response_by: string | null - created_at: string - updated_at: string - acknowledged_at: string | null - decided_at: string | null - closed_at: string | null -} - -export type IncidentUpdateRow = { - id: string - incident_id: string - author_id: string | null - author_name: string | null - body: string - visibility: IncidentUpdateVisibility - created_at: string -} - -export type Policy = { - id: string - space_id: string - slug: string - section_ref: string | null - parent_policy_id: string | null - title: string - body_formal: string - body_plain: string | null - version: number - prior_version_id: string | null - status: PolicyStatus - effective_at: string | null - adopted_by_proposal_id: string | null - created_at: string - updated_at: string -} +// Rows +export type SpaceArea = Tables<'space_areas'> +export type Proposal = Tables<'proposals'> +export type ProposalVote = Tables<'proposal_votes'> +export type Incident = Tables<'incidents'> +export type IncidentUpdateRow = Tables<'incident_updates'> +export type Policy = Tables<'policies'>