refactor(types): regenerate database types from canonical schema; drop TODO(types) join casts

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
This commit is contained in:
Moheeb Zara
2026-08-04 22:21:29 -07:00
parent 4f4e3096ca
commit b2b463491a
13 changed files with 2055 additions and 465 deletions
+25 -156
View File
@@ -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'>