mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
Part 1 of 7 in a stack that splits #52331 into reviewable pieces. Resolves part of [FE-4693](https://linear.app/supabase/issue/FE-4693/pilot-migrate-branches-to-grants-8-endpoints-createbranchmodal). There are no functional changes beyond #52331, and the top of the stack is identical to it. See #52331 for the full rationale. ## Stack 1. 👉 #52372 Grant infra for branch variants 2. #52373 Branches list query 3. #52374 Page gates on the list grant 4. #52375 Branch creation 5. #52376 Branch read, delete, reset, and restore 6. #52377 Branch update and push 7. #52378 Branch diff and merge ## Changes Adds `lib/fga-refinements.ts` entries: `production`/`development` variants for the 8 single-branch endpoints, with a new `variantRequired` flag. The fetch wrapper and `assertGrant` reject a grant without a variant. Also adds the `production` variant for `POST /v1/projects/{ref}/branches` when the body sets `is_default` or `with_data`. Adds `GrantForVariants`, the `useBranchGrant` hook, and shared fixtures in `tests/lib/branch-test-utils.ts`. Behavior-neutral: existing branch calls still use `unguarded.migrating`, which skips these checks. ## Testing `guarded-fetch.test.ts` and `useBranchGrant.test.ts`.