chore: add Supabase schema and contributor docs#87
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR brings Supabase into the repo for reproducible local DB/Auth/Storage dev, adds generated type-safe Supabase Database typings across clients and affected query code, upgrades the web runtime baseline to Node.js 24, and consolidates contributor/deployment documentation into a new CONTRIBUTING.md.
Changes:
- Add Supabase CLI config (and migrations/types) to support
npx supabase startlocal development. - Introduce generated
web/lib/database.types.tsand wire theDatabasegeneric into Supabase client factories, adjusting call sites to satisfy stricter typing. - Upgrade Node baseline to 24 and reorganize docs (new CONTRIBUTING, slimmer READMEs, remove DEPLOYMENT).
Reviewed changes
Copilot reviewed 44 out of 46 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web/supabase/config.toml | Adds Supabase CLI local stack configuration (API/DB/Auth/Storage/etc.). |
| web/supabase/.gitignore | Ignores Supabase local working dirs and local env/key files under web/supabase/. |
| web/package.json | Pins Node engine to 24+, bumps @types/node, adds supabase CLI dev dependency. |
| web/package-lock.json | Lockfile updates for Node typings + Supabase CLI and transitive dependencies. |
| web/lib/user-management.ts | Adds Json typing and adjusts query/update return types/casts under typed Supabase client. |
| web/lib/usage-quota.ts | Adjusts RPC return typing cast to satisfy typed schema. |
| web/lib/supabase/server.ts | Types the SSR server client via createServerClient<Database>(). |
| web/lib/supabase/middleware.ts | Types middleware Supabase clients and tightens role-check typing. |
| web/lib/supabase/client.ts | Types the browser Supabase client via createBrowserClient<Database>(). |
| web/lib/supabase-utils.ts | Types the service role client factory via createSupabaseClient<Database>(). |
| web/lib/storage/delete.ts | Types SupabaseClient parameters with <Database> for storage helpers. |
| web/lib/spaced-repetition.ts | Types SupabaseClient parameter with <Database> for schedule updates. |
| web/lib/review-utils.ts | Types SupabaseClient parameters and adjusts result typing for filtered problems. |
| web/lib/insights-utils.ts | Types SupabaseClient parameters and casts digest reads under typed client. |
| web/lib/digest-generator.ts | Casts JSON-ish payload fields to Json for typed inserts/updates. |
| web/lib/database.types.ts | Adds generated Supabase schema/types (Database, Json, helpers). |
| web/lib/content-limits.ts | Adjusts override typing to match DB-returned numeric/string values. |
| web/lib/categorise-error.ts | Normalizes problem data for prompt building under stricter typing. |
| web/app/sitemap.ts | Adjusts sitemap lastModified to tolerate nullable updated_at. |
| web/app/api/review-sessions/[sessionId]/route.ts | Tightens typing around session_state JSON and persists healed state as Json. |
| web/app/api/review-sessions/[sessionId]/progress/route.ts | Tightens typing around session_state JSON and read-only detection. |
| web/app/api/review-sessions/[sessionId]/complete/route.ts | Tightens typing around session_state JSON and session summary typing. |
| web/app/api/qr-sessions/[sessionId]/status/route.ts | Narrows status typing for API response correctness. |
| web/app/api/profile/route.ts | Casts upsert payload to generated user_profiles.Insert type. |
| web/app/api/profile/avatar/route.ts | Casts avatar upserts to generated user_profiles.Insert type. |
| web/app/api/problems/route.ts | Casts status/type filters to generated enum arrays for typed .in(...) queries. |
| web/app/api/problems/[id]/attempt/route.ts | Casts answer_config to AnswerConfig for typed answer marking. |
| web/app/api/problem-sets/[id]/view/route.ts | Aligns RPC arg typing by omitting p_user_id when absent. |
| web/app/api/problem-sets/[id]/start-session/route.ts | Tightens parsing/casting of filter_config + session_config JSON. |
| web/app/api/problem-sets/[id]/progress/route.ts | Tightens parsing/casting of filter_config JSON for smart sets. |
| web/app/api/problem-sets/[id]/copy/route.ts | Tightens filter_config typing and narrows inserted status literal type. |
| web/app/api/problem-sets/[id]/copy-problem/route.ts | Tightens filter_config typing for membership checks. |
| web/app/api/attempts/route.ts | Casts submitted_answer to Json for typed inserts. |
| web/app/api/attempts/[id]/route.ts | Casts PATCH update payload to generated attempts.Update, with Json handling. |
| web/app/api/ai/categorise-error/[id]/route.ts | Adjusts override reset update payload to satisfy typed updates. |
| web/app/api/admin/settings/route.ts | Casts inserted settings value to Json for typed inserts. |
| web/app/[locale]/(app)/problem-sets/[id]/add-problems/page.tsx | Casts fetched problems to app Problem[] for client component props. |
| web/app/[locale]/(app)/insights/page.tsx | Casts initial digest to `InsightDigest |
| web/app/[locale]/(app)/insights/[subjectId]/page.tsx | Casts digest to `InsightDigest |
| web/.nvmrc | Pins local dev Node version to 24. |
| README.zh-CN.md | Updates runtime requirement and points setup details to CONTRIBUTING.md. |
| README.md | Updates runtime requirement and points setup details to CONTRIBUTING.md. |
| DEPLOYMENT.md | Removes standalone deployment doc (content moved to CONTRIBUTING.md). |
| CONTRIBUTING.md | Adds full contributor guide: Supabase local setup, env vars, DB workflow, tooling, deployment notes. |
| .github/workflows/i18n-check.yml | Updates CI Node version used by i18n workflow to 24. |
Files not reviewed (1)
- web/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use ReviewSessionState['session_state'], Partial<FilterConfig>, and generated DB row types instead of generic Record casts on Supabase JSONB columns. Adds is_read_only to ReviewSessionState interface.
Seeds two auth users (test@example.com and admin@example.com) with confirmed emails so contributors can log in immediately after db reset. The existing handle_new_user trigger auto-creates user_profiles rows.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 46 out of 48 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- web/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… casts - Change Problem.tags, ProblemWithTags.tags, ProblemInSet.tags from Tag[] to SimpleTag[] to match the (id, name) select used in all tag queries - Remove transformSimpleTagsToTags workaround in problem-form.tsx - Replace as string[] admin role check with as const for type-safe comparison - Use specific inline type for announcement value instead of Record - Use DB row type for categoriseSingleAttempt return
…ion override Validate that original_broad_category and original_granular_tag are present before resetting, preventing an inconsistent state where overridden values persist after is_user_override is flipped to false.
Summary
production schema into
web/supabase/migrations/, and addedconfig.tomlsocontributors can boot a local Postgres + Auth + Storage stack with
npx supabase startdatabase.types.tsfrom the liveschema, wired the
Databasegeneric into all 4 Supabase client factories, andfixed 73 pre-existing type errors across 31 files that were previously hidden by
untyped (
any) queriesengines,.nvmrc, and CI workflow; bumped@types/nodeto^24CONTRIBUTING.mdwith full local devsetup (Supabase, env vars, database workflow, code quality, deployment), slimmed
README.mdto a product overview, updatedREADME.zh-CN.mdto match, and removedDEPLOYMENT.md(content moved into CONTRIBUTING)