Skip to content

feat(types): generate and wire Supabase Database types - #106

Merged
cameroncuster merged 2 commits into
mainfrom
cameroncuster/supabase-generated-types
Jul 25, 2026
Merged

feat(types): generate and wire Supabase Database types#106
cameroncuster merged 2 commits into
mainfrom
cameroncuster/supabase-generated-types

Conversation

@cameroncuster

Copy link
Copy Markdown
Owner

Problem — the Supabase client was untyped, so supabase.from(...)/.rpc(...) returned any-shaped data. Every read leaned on hand-written as unknown as … / as …Record[] casts, and a schema/RPC drift would compile silently.

Solution — add a generated Database type (from the live gitgud schema, tlmlevnvkfycgavxjlov, via supabase gen types) and thread it through the three client constructors: the browser client, the bearer-auth server client, and the anon server client (createClient<Database>()), plus SupabaseClient<Database> on the authorized-user result. Direct queries are now schema-checked by svelte-check.

Scope kept deliberately tight:

  • The generated file (src/lib/types/database.ts) is kept byte-identical to the generator output and exempted from prettier/eslint (so re-running supabase gen types produces no diff/lint noise).
  • I intentionally did not remove the existing casts. The as unknown as <Client> casts in the engagement gateways / submit providers bridge to hand-rolled minimal client interfaces that exist as test seams; unifying those is a separate, focused change (pairs with the gateway-unification follow-up). The dynamic-string .select(COLUMNS) casts also can't be narrowed without switching to typed selects. Doing either here would widen the blast radius.

Testing — I could not run the toolchain locally (only Node 22 available; repo requires Node ≥24 with engine-strict). Opened as draft so CI on Node 24 runs check (the meaningful gate here — it type-checks the new wiring), lint, lint:es, unit tests, build, and the Playwright suite. I'll address any CI feedback.

Misc — the Database type reflects the current live schema; if the schema changes, regenerate with supabase gen types.

Opened by an Augment PR Author agent on behalf of @cameroncuster.

Add a generated `Database` type (from the live gitgud schema via
`supabase gen types`) and type the Supabase clients with it:
`createClient<Database>()` in the browser client, the bearer-auth server
client, and the anon server client, plus `SupabaseClient<Database>` on
the authorized-user result.

This gives every direct `supabase.from(...)`/`.rpc(...)` call real
schema-aware type-checking, so a column/RPC drift now fails `svelte-check`
instead of silently returning `any`. The generated file is kept
byte-identical to the generator output and is exempt from prettier/eslint.

The remaining `as unknown as <Client>` casts in the engagement gateways
and submit providers bridge to hand-rolled minimal client interfaces used
as test seams; unifying those is left to a focused follow-up so this PR
stays scoped to the type wiring.
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitgud Ready Ready Preview, Comment Jul 25, 2026 1:43am

@cameroncuster

Copy link
Copy Markdown
Owner Author

PR Author Agent⚡ on behalf of @cameroncuster

👋 This PR is monitored by an Augment Agent.

I'll answer questions, implement suggestions, fix CI failures, and resolve merge conflicts. I slow down if the PR goes quiet, but any new comment wakes me back up.

…oundary

Typing the Supabase client surfaced that `feedback_type` is `text` in the
schema (`string`), while fetchProblemFeedback/fetchContestFeedback declare a
`Record<string, 'like' | 'dislike' | null>` contract consumed downstream as
`Reaction`. The write path constrains the column to those values, so narrow
the value to the reaction union at the map site rather than loosening the
public return type.
@cameroncuster
cameroncuster marked this pull request as ready for review July 25, 2026 01:46
@cameroncuster
cameroncuster merged commit 04e82c0 into main Jul 25, 2026
7 checks passed
@cameroncuster
cameroncuster deleted the cameroncuster/supabase-generated-types branch July 25, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant