feat(types): generate and wire Supabase Database types - #106
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem — the Supabase client was untyped, so
supabase.from(...)/.rpc(...)returnedany-shaped data. Every read leaned on hand-writtenas unknown as …/as …Record[]casts, and a schema/RPC drift would compile silently.Solution — add a generated
Databasetype (from the live gitgud schema,tlmlevnvkfycgavxjlov, viasupabase 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>()), plusSupabaseClient<Database>on the authorized-user result. Direct queries are now schema-checked bysvelte-check.Scope kept deliberately tight:
src/lib/types/database.ts) is kept byte-identical to the generator output and exempted from prettier/eslint (so re-runningsupabase gen typesproduces no diff/lint noise).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 runscheck(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
Databasetype reflects the current live schema; if the schema changes, regenerate withsupabase gen types.Opened by an Augment PR Author agent on behalf of @cameroncuster.