mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## What Generates `packages/api-types/types/fga-requirements.ts`, a map from `'METHOD /path'` to the FGA permission groups that endpoint requires, from the `x-fga-permissions` annotations in the v1, v2, and platform OpenAPI specs. Groups are OR-of-AND (a caller needs every permission in at least one group) and are preserved verbatim. Keys are the path literals passed to openapi-fetch, so later work can type-check permission grants against fetch calls. - `codegen:prod` and the production drift check (`verify-production-types`) now generate and compare the new file. - Local `codegen` also generates it, from the local API (`LOCAL_API_URL`, defaults to `http://localhost:8080`). - Permission IDs are validated against the platform spec's `CreateScopedAccessTokenBody.permissions` enum. Generation fails on malformed annotations, empty groups, unknown IDs, or an endpoint annotated in two specs. An empty annotation (`[]`) is treated as ungated and omitted. - The drift-check workflow now also runs when `packages/api-types/scripts/` changes, so generator changes without regenerated output are caught. - Exported from `api-types` as `fgaRequirements`, with `FgaRequirements` and `FgaGuardedEndpoint` types. No Studio changes. ## Testing - `pnpm --filter=api-types test` - `pnpm --filter=api-types codegen:prod` regenerates the committed file with no diff. Resolves FE-4686