Files
supabase/.agents/skills/ask-the-docs/reference/management-api-reference.md
Ivan VasilovandClaude Opus 5.5 11a71d795a chore(docs): replace pnpm lifecycle hooks with turbo task dependencies (#52556)
## Problem

`apps/docs` ordered its build, dev and codegen steps with pnpm
`pre`/`post` hooks and `&&` chains. Turbo couldn't see those steps, so
it couldn't cache or parallelize them, and running the build through
turbo ran the codegen twice. Part of
[FE-4948](https://linear.app/supabase/issue/FE-4948/migrate-the-pnpm-scripts-to-use-turbo).

## Solution

The ordering now lives in `apps/docs/turbo.jsonc` as `dependsOn`, and
every pre/post hook is gone. The new `maybe-turbo` workspace bin runs a
script through `turbo run` unless it's already inside turbo, so `pnpm
build`, `pnpm dev`, `pnpm codegen:references` and the other entry points
keep running their prerequisites.

Turbo is bumped to 2.11.10 for its `jit` input mode. Tasks downstream of
the uncached remote fetches use it to hash the gitignored files those
fetches write after they finish, so a cache hit can't restore output
built from older content. Strict-mode env vars are declared.

Other changes:
- The R2 upload moves from `postbuild` to the `vercel.json` build
command, so it still runs when the build is a cache hit.
- `codegen:references:new:ensure` re-downloads when any JavaScript
TypeDoc dump is missing or empty.
- The guides manifest is now sorted, so its output is deterministic.
- A new `turbo-scripts` agent skill (listed in `AGENTS.md`) documents
these conventions for every app. Its audit script, `node
.agents/skills/turbo-scripts/scripts/audit.mjs apps/<name>`, flags
scripts that need `maybe-turbo`, leftover `pre`/`post` hooks, script
chains, and wrapped scripts without a turbo task.

## Review instructions

1. Read `packages/maybe-turbo/README.md`, `apps/docs/turbo.jsonc` and
`.agents/skills/turbo-scripts/SKILL.md`.
2. From `apps/docs`, set `GH_TOKEN=$(gh auth token)` for the federated
fetch and run `pnpm run build:markdown` a few times. Once warm, every
task except `build:federated-content` and
`codegen:references:new:ensure` should hit the cache.
3. Run `pnpm build` from `apps/docs` and check that the docs Vercel
preview deploys and renders normally.

## Checklist

Check all before review:

- [ ] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-09 16:33:28 +01:00

5.7 KiB

Management API reference generation

How /docs/reference/api/* is built from the live Management API OpenAPI spec. Verify against apps/docs/spec/Makefile and features/docs/Reference.generated.script.ts before acting — paths drift.

Pipeline

flowchart LR
  live["api.supabase.com<br/>/api/v1-json + v2-json"]
  raw["spec/api_v{1,2}_openapi.json"]
  redocly["Redocly bundle<br/>(no --dereferenced)"]
  bundled["spec/transforms/<br/>api_v*_openapi_deparsed.json"]
  sections["common-api-sections.json"]
  codegen["codegen:references:legacy"]
  gen["features/docs/generated/<br/>api.latest.*.json"]
  page["ApiReferencePage →<br/>ApiEndpointSection"]
  md["public/markdown/reference/api.md"]

  live --> raw --> redocly --> bundled
  bundled --> sections
  bundled --> codegen
  sections --> codegen
  codegen --> gen --> page
  gen --> md
  1. Download — make download.api.v1 in apps/docs/spec/ curls the live OpenAPI into api_v1_openapi.json / api_v2_openapi.json.
  2. Bundle — make dereference.api.v1 runs Redocly CLI (@redocly/cli) bundle into transforms/*_deparsed.json. Management API deliberately omits --dereferenced (circular $ref in APIErrorObject.issues). $refs are resolved later in codegen with a cycle guard.
  3. Nav sections — sections/generateMgmtApiSections.cts walks operations/tags into common-api-sections.json.
  4. Codegen — codegen:references:legacy (Reference.generated.script.ts) merges v1+v2, resolves refs, writes api.latest.endpointsById.json, sections.json, flat.json, bySlug.json under features/docs/generated/.
  5. Runtime — /reference/api/[operation] via ApiReferencePage → SectionSwitch → ApiEndpointSection (custom React, not MDX). One endpoint per page (DOCS-1268). Hand-written intro MDX lives under docs/ref/api/.
  6. Agents — generate-reference-markdown.ts exports the same data to public/markdown/reference/api.md.

Legacy EJS (generator/api.ts + ApiTemplate.ts) is not the live path.

Redocly today (bundle / lint)

Job Where Notes
Bundle make dereference.api.v1 (and sibling targets for auth/storage/analytics) Invoked via npx --package=@redocly/cli redocly bundle
Lint make validate.analytics.v0 only redocly lint --extends=minimal. Management API has no lint target

Redocly is the OpenAPI toolchain (bundle/lint), not the page renderer.

Rendering: keep the custom path

Pages render via custom React (ApiEndpointSection), not Scalar / Redoc / Stoplight Elements. Reasons (see also adding-features.md and known-issues.md):

  • Two pipelines — HTML + markdown export + GraphQL search share one IApiEndPoint / generated-JSON shape. A third-party viewer forks that.
  • Custom extensions — x-oauth-scope, x-allowed-plans, x-fga-permissions need first-class rendering.
  • Modular pages — DOCS-1268 already split the monolithic API page; embedding a full-spec viewer would reverse that.
  • Surface — new dep + theming + parity work fights docs-app direction (reduce surface, don't add parallel renderers).

Prefer improving ApiEndpointSection / schema helpers, or deepening Redocly lint on download/transform. Do not propose swapping the renderer for an OpenAPI UI kit without addressing markdown/search/x-* parity.

Closest CLI substitutes if Redocly were unavailable: @apidevtools/swagger-parser or swagger-cli for bundle; Spectral for lint. Switching buys little while the custom cycle-safe resolve remains required.

Key files

Path Role
apps/docs/spec/Makefile download / Redocly bundle / section generate
apps/docs/spec/sections/generateMgmtApiSections.cts OpenAPI → common-api-sections.json
apps/docs/features/docs/Reference.generated.script.ts merge, resolve refs, write api.latest.*
apps/docs/features/docs/Reference.api.utils.ts IApiEndPoint + schema display helpers
apps/docs/features/docs/Reference.apiPage.tsx route → one operation page
apps/docs/features/docs/Reference.sections.tsx ApiEndpointSection UI
apps/docs/internals/generate-reference-markdown.ts agent markdown export

Scoped personal access token permission tables

The "Personal Access Tokens" guide's permission and MCP tables are generated from the Management API specs, MCP permission map, and the same shared catalog Studio uses. Regenerate content/_partials/access-control/scoped_pat_*.mdx with make -C apps/docs/spec generate.partials.access-control. Docs Tests runs this on relevant pull requests and fails if the partials drift; the weekly Management API update also runs it after refreshing the live inputs.