22
33## Files Read
44
5- | Path | Format | When |
6- | -------------------------------- | ---------- | ------------------------------------------------------------------- |
7- | ` ~/.supabase/access-token ` | plain text | when ` SUPABASE_ACCESS_TOKEN ` unset and ` --linked ` or ` --project-id ` |
8- | ` <workdir>/supabase/config.toml ` | TOML | when ` --local ` is specified |
5+ | Path | Format | When |
6+ | ----------------------------------------- | ---------- | ---------------------------------------------------------------------------------------- |
7+ | ` ~/.supabase/access-token ` | plain text | when ` SUPABASE_ACCESS_TOKEN ` unset and ` --linked ` or ` --project-id ` |
8+ | ` <workdir>/supabase/config.toml ` | TOML | when ` --local ` (required) or ` --db-url ` (best-effort) is specified |
9+ | ` <workdir>/supabase/.temp/rest-version ` | plain text | ` --local ` only, when ` db.major_version > 14 ` — forces v9 compat if the tag contains ` v9 ` |
10+ | ` <workdir>/supabase/.temp/pgmeta-version ` | plain text | ` --local ` only — overrides the pg-meta docker image tag |
911
1012## Files Written
1113
1214| Path | Format | When |
1315| ---- | ------ | ---- |
1416| — | — | — |
1517
18+ No files are written. Container env (including the DB URL and TLS CA bundle) is
19+ passed via ` docker run --env KEY=VALUE ` arguments, mirroring Go's
20+ ` container.Config.Env ` ; no temporary env-file is created.
21+
1622## API Routes
1723
1824| Method | Path | Auth | Request body | Response (used fields) |
1925| ------ | ------------------------------------- | ------------ | ------------ | -------------------------------- |
2026| ` GET ` | ` /v1/projects/{ref}/types/typescript ` | Bearer token | none | TypeScript type definitions text |
2127
28+ Called only for ` --linked ` , ` --project-id ` , and the implicit linked-project
29+ fallback. ` --local ` and ` --db-url ` do not call the Management API.
30+
31+ ## Subprocesses
32+
33+ | Command | When | Purpose |
34+ | ----------------------------------------------------------------------------- | --------------------- | -------------------------------------------------- |
35+ | ` docker container inspect supabase_db_<project_id> ` | ` --local ` | assert ` supabase start ` is running |
36+ | ` docker run --rm --network <net> --env … <pgmeta> node dist/server/server.js ` | ` --local ` , ` --db-url ` | run pg-meta to generate types from a live database |
37+
38+ A raw TCP ` SSLRequest ` probe is also opened to the target database host/port to
39+ detect TLS support before launching pg-meta (mirrors Go's ` isRequireSSL ` ).
40+
2241## Environment Variables
2342
24- | Variable | Purpose | Required? |
25- | ----------------------- | ------------------------------------- | ------------------------------------------------------- |
26- | ` SUPABASE_ACCESS_TOKEN ` | auth token for linked/project-id mode | no (falls back to keyring → ` ~/.supabase/access-token ` ) |
27- | ` SUPABASE_API_URL ` | override Management API base URL | no (defaults to ` https://api.supabase.com ` ) |
43+ | Variable | Purpose | Required? |
44+ | ---------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------- |
45+ | ` SUPABASE_ACCESS_TOKEN ` | auth token for linked/project-id mode | no (falls back to keyring → ` ~/.supabase/access-token ` ) |
46+ | ` SUPABASE_API_URL ` | override Management API base URL | no (defaults to ` https://api.supabase.com ` ) |
47+ | ` SUPABASE_DB_PASSWORD ` | local database password for ` --local ` | no (defaults to ` postgres ` ) |
48+ | ` SUPABASE_SERVICES_HOSTNAME ` | host used for the local TLS probe | no (defaults to ` 127.0.0.1 ` ) |
49+ | ` SUPABASE_INTERNAL_IMAGE_REGISTRY ` | pg-meta image registry override (` docker.io ` → Docker Hub) | no (defaults to the ECR registry) |
50+ | ` SUPABASE_CA_SKIP_VERIFY ` | when ` true ` , prints a TLS-verification-disabled warning to stderr | no |
2851
2952## Exit Codes
3053
31- | Code | Condition |
32- | ---- | ---------------------------------------- |
33- | ` 0 ` | success — types printed to stdout |
34- | ` 1 ` | no target specified (must use one flag) |
35- | ` 1 ` | API error or database connection failure |
54+ | Code | Condition |
55+ | ---- | ---------------------------------------------------------------- |
56+ | ` 0 ` | success — types printed to stdout |
57+ | ` 1 ` | no target specified (must use one flag) |
58+ | ` 1 ` | mutually exclusive flags combined |
59+ | ` 1 ` | ` --postgrest-v9-compat ` used without ` --db-url ` |
60+ | ` 1 ` | invalid ` --query-timeout ` duration or invalid ` --db-url ` |
61+ | ` 1 ` | ` supabase start ` not running (` --local ` ) or db inspection failed |
62+ | ` 1 ` | API error, TLS probe failure, or pg-meta container non-zero exit |
3663
3764## Output
3865
3966### ` --output-format text ` (Go CLI compatible)
4067
4168Prints generated TypeScript (or other language) type definitions to stdout.
69+ Diagnostics (` Connecting to … ` , pg-meta logs) go to stderr.
4270
4371### ` --output-format json `
4472
@@ -51,8 +79,14 @@ Not applicable.
5179## Notes
5280
5381- Exactly one of ` --local ` , ` --linked ` , ` --project-id ` , or ` --db-url ` must be specified.
54- - ` --lang ` flag accepts ` typescript ` (default), ` go ` , ` swift ` , or ` python ` .
82+ - ` --lang ` flag accepts ` typescript ` (default), ` go ` , ` swift ` , or ` python ` . Non-typescript
83+ languages require a direct database connection (` --local ` or ` --db-url ` ).
5584- ` --schema ` / ` -s ` accepts a comma-separated list of schemas to include.
5685- ` --swift-access-control ` accepts ` internal ` (default) or ` public ` .
5786- ` --postgrest-v9-compat ` generates types compatible with PostgREST v9 and below (requires ` --db-url ` ).
5887- ` --query-timeout ` sets the maximum timeout for the database query (default 15s, direct connection only).
88+ - The legacy positional language argument (` supabase gen types typescript ` ) is still accepted;
89+ any other positional language requires an explicit ` --lang ` flag.
90+ - The linked-project telemetry cache is written only when a project ref is resolved
91+ (` --linked ` /` --project-id ` /fallback), matching Go's ` ensureProjectGroupsCached ` , which
92+ returns early when no ref is available.
0 commit comments