mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +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
24 lines
877 B
JSON
24 lines
877 B
JSON
{
|
|
"name": "api-types",
|
|
"version": "0.0.0",
|
|
"description": "Types shared between Supabase apps and packages",
|
|
"main": "./index.ts",
|
|
"types": "./index.ts",
|
|
"scripts": {
|
|
"preinstall": "npx only-allow pnpm",
|
|
"clean": "rimraf .turbo tsconfig.tsbuildinfo",
|
|
"codegen": "openapi-typescript --redocly ./redocly.yaml --alphabetize --default-non-nullable=false && node ./scripts/generate-fga-requirements.mjs && prettier --cache --write types/*.d.ts types/fga-requirements.ts",
|
|
"codegen:prod": "node ./scripts/generate-production-types.mjs",
|
|
"verify-production-types": "node ./scripts/verify-production-types.mjs",
|
|
"test": "node --test ./scripts/*.test.mjs"
|
|
},
|
|
"author": "",
|
|
"license": "MIT",
|
|
"devDependencies": {
|
|
"openapi-typescript": "^7.4.3",
|
|
"prettier": "*",
|
|
"@typescript/native": "catalog:",
|
|
"typescript": "catalog:"
|
|
}
|
|
}
|