Skip to content

feat(typegen): depend on the registry alone and prepare it for hosted consumers - #213

Merged
spydon merged 8 commits into
mainfrom
lukasklingsbo/typegen-single-cli-dependency
Sep 25, 2026
Merged

spydon merged 8 commits into
mainfrom
lukasklingsbo/typegen-single-cli-dependency

Conversation

@spydon

@spydon spydon commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #211 (SDK-1955), preparing for the CLI adapter in SDK-1956.

Summary

  • @supabase/typegen re-exports introspect, Queryable, IntrospectOptions, GeneratorMetadata and GENERATOR_METADATA_VERSION from @supabase/postgrest-typegen. The CLI can then depend on the registry alone: one dependency to bump when a language is added, and the document is always produced by the same postgrest-typegen version the in-process generators were built against. Depending on both packages directly would let a lockfile resolve two versions, introspecting with one and generating with the other.

  • @supabase/typegen now declares engines.node as >=22.12.0. It ships ES modules only and its require export condition resolves to one, the finding CodeRabbit raised on feat(typegen): add language registry package so new languages need no CLI change #211; 22.12.0 is the first Node 22 release that accepts that without a flag. Node 20 reached end of life in April 2026 and Node 21 was never an LTS line, so neither is worth keeping in the range. The same change for @supabase/postgrest-typegen is fix(postgrest-typegen): require Node 22.12 or newer #214, kept separate so release-please records it as a patch on that package. The Supabase CLI is unaffected either way: it compiles with Bun and bundles both packages.

  • Two changes that prepare postgres-meta for dispatching its hosted /generators/* routes through the registry. The Swift option now accepts all four generator access levels (internal, public, private, package), since postgres-meta's route always did and extra choices change nothing for existing CLI users. Host.spawn is optional: a hosted service cannot run processes, so an out-of-process language asked to generate without one fails with a SpawnUnavailableError rather than the consumer stubbing a runner.

  • postgrest-v9-compat is gone as a registry option. It was the CLI's inverted name for the generator's detectOneToOneRelationships, only ever worked with --db-url, and targets PostgREST 9 from 2022; the CLI sniffs the local stack's PostgREST version itself and postgres-meta's route exposes the positive parameter. The option is now detect-one-to-one-relationships, a consumer option defaulting to true, so both consumers set it from what they know about the target and no user sees a 2022 compatibility switch. TypeScript therefore has no user flags; swift-access-control is the only one left in the registry. The CLI adapter (SDK-1956) keeps --postgrest-v9-compat as a deprecated alias that sets the option to false.

Changes

  • packages/typegen/src/index.ts: the re-exports, with a comment stating why.
  • packages/typegen/test/reexports.test.ts: introspect is the same function postgrest-typegen exports and the document version matches.
  • packages/typegen/README.md and CLAUDE.md: the usage example imports introspect from @supabase/typegen, and the "Where it sits" section explains the single-dependency rule.
  • packages/typegen/package.json: engines range.
  • packages/typegen/src/contract.ts: the Host comment points at the re-exported introspect(); spawn is optional.
  • packages/typegen/src/errors.ts and src/languages/external.ts: SpawnUnavailableError.
  • packages/typegen/src/languages/index.ts: Swift choice list; detect-one-to-one-relationships replaces postgrest-v9-compat.

Notes

  • The re-export is a plain pass-through; postgrest-typegen remains the implementation and its own release cadence is unchanged.
  • This PR touches only packages/typegen, so the squash commit lands in the typegen changelog alone.

…stry alone

`introspect`, `Queryable`, `IntrospectOptions`, `GeneratorMetadata` and
`GENERATOR_METADATA_VERSION` are re-exported from
@supabase/postgrest-typegen. A consumer that depended on both packages
directly could resolve two postgrest-typegen versions, introspecting
with one and generating with the other; with a single dependency the
registry pins the version the in-process generators were built against,
and adding a language is one dependency bump in the CLI.
…of ES modules works

The package ships ES modules only and its `require` export condition
resolves to one. Node accepts that without a flag from 20.19.0, so the
engines range now says so, matching @supabase/typegen.
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 4b185adc-12b4-42a5-878b-0c618ff6b04a

📥 Commits

Reviewing files that changed from the base of the PR and between 190ee12 and d261747.

📒 Files selected for processing (12)
  • packages/typegen/CLAUDE.md
  • packages/typegen/README.md
  • packages/typegen/package.json
  • packages/typegen/src/contract.ts
  • packages/typegen/src/errors.ts
  • packages/typegen/src/index.ts
  • packages/typegen/src/languages/external.ts
  • packages/typegen/src/languages/index.ts
  • packages/typegen/test/dart.test.ts
  • packages/typegen/test/in-process.test.ts
  • packages/typegen/test/languages.test.ts
  • packages/typegen/test/reexports.test.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: aba87444-6876-4112-9dfe-badfaad8767e

📥 Commits

Reviewing files that changed from the base of the PR and between 468306d and 190ee12.

📒 Files selected for processing (5)
  • packages/postgrest-typegen/package.json
  • packages/typegen/CLAUDE.md
  • packages/typegen/README.md
  • packages/typegen/src/index.ts
  • packages/typegen/test/reexports.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • The type generation package now re-exports the introspection API and metadata version information from the PostgREST type generation package, so consumers can access them from one package.
    • Updated usage examples to import introspect from the type generation package.
  • Documentation

    • Clarified that consumers perform introspection and pass the resulting metadata to the generator.
  • Compatibility

    • The PostgREST type generation package now requires Node.js 20.19.0 or later.

Walkthrough

Typegen now re-exports introspection APIs and metadata contracts from postgrest-typegen. Its documentation and tests reflect and verify these exports. The postgrest-typegen package also raises its minimum supported Node.js version to 20.19.0.

Priority: ⚪ Not assessed

Change: Feature

Merge Risk: ⚪ Minimal · up to 190ee

No actionable merge risk is established. The API is wired through the package roots, and the Node.js minimum change does not expand the runtime requirement for typegen consumers.

Architecture Summary

Architecture risk: 🔵 Low · up to 190ee

The change affects 2 systems.

Changed systems: packages/typegen, packages/postgrest-typegen

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/typegen (library) was modified; 4 changed files map to changed impact.
  • observed — packages/postgrest-typegen (library) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/postgrest-typegen/package.json: The declared minimum Node.js version changes from 20.0.0 to 20.19.0.
  • observed — Modified behavior in packages/typegen/CLAUDE.md: The documentation now says the consumer calls introspect() and supplies GeneratorMetadata, and lists the introspection types and version constant re-exported from @supabase/postgrest-typegen. It replaces wording that directed consumers to call introspect() from that dependency directly.
  • observed — Modified behavior in packages/typegen/README.md: The documentation now assigns introspection to the consumer and says @supabase/typegen re-exports introspect, its related types, and metadata version from @supabase/postgrest-typegen. It replaces the description of the registry depending on that package for contract types and sorting/serialization helpers with the stated single-dependency and version-alignment arrangement.
  • observed — Modified behavior in packages/typegen/README.md: The usage example now imports introspect from @supabase/typegen alongside the registry APIs, instead of importing it directly from @supabase/postgrest-typegen.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@spydon
spydon marked this pull request as ready for review September 25, 2026 06:53
@spydon
spydon requested a review from a team as a code owner September 25, 2026 06:53
…ules works

`>=20.19.0` admitted Node 21 and 22.0 through 22.11, where require()
of an ES module still needs a flag; `^20.19.0 || >=22.12.0` matches the
actual requirement in both packages. Also point the remaining docs and
the Host comment at the re-exported introspect(), drop a redundant
comment, and merge the two pass-through tests into one.
Node 20 reached end of life in April 2026 and Node 21 was never an LTS
line, so the compound range only kept dead lines alive. 22.12.0 is the
first Node 22 release that accepts require() of an ES module without a
flag, and postgres-meta, the one Node consumer, already runs on 22.
…ional

Both prepare postgres-meta for dispatching its hosted generator routes
through the registry. Its Swift route has always accepted `private` and
`package`, so the choice list now carries all four generator levels;
extra choices change nothing for existing CLI users. A hosted service
cannot run processes, so `Host.spawn` is optional and an out-of-process
language asked to generate without one fails with a clear
SpawnUnavailableError instead of the consumer having to stub it.
…pull request

It lives in #214 now, so release-please records it as a patch on
postgrest-typegen instead of attributing this feature to that package.
@spydon spydon changed the title feat(typegen): re-export introspection so the CLI depends on the registry alone feat(typegen): depend on the registry alone and prepare it for hosted consumers Sep 25, 2026
…etect-one-to-one-relationships

The registry named the option after the CLI's inverted flag. The flag
only ever worked with --db-url, targets PostgREST 9 from 2022, and the
CLI already sniffs the local stack's PostgREST version itself, while
postgres-meta's route exposes the positive parameter. So the option
now carries the generator's own name and polarity, defaults to true,
and is a consumer option: the calling program knows the target's
PostgREST version. The CLI adapter keeps --postgrest-v9-compat as a
deprecated alias that sets it to false.
@spydon
spydon merged commit ff5e98d into main Sep 25, 2026
4 of 5 checks passed
@spydon
spydon deleted the lukasklingsbo/typegen-single-cli-dependency branch September 25, 2026 07:46
spydon added a commit that referenced this pull request Sep 25, 2026
Split out of #213 so release-please records it as a patch on
postgrest-typegen rather than folding it into the typegen feature.

## Summary

`@supabase/postgrest-typegen` now declares `engines.node` as
`>=22.12.0`, replacing `>=20.0.0`.

- The package ships ES modules only and its `require` export condition
resolves to one. Node accepts `require()` of an ES module without a flag
from 22.12.0; on earlier versions it throws `ERR_REQUIRE_ESM`, so the
old range advertised support that did not work for CommonJS consumers.
CodeRabbit raised this on #211 for `@supabase/typegen`, which already
declares the same range.
- Node 20 reached end of life in April 2026 and Node 21 was never a
long-term-support line, so neither is worth keeping in the range.
- postgres-meta, the one consumer that runs this package under Node, is
on Node 22 in its Dockerfile and `.nvmrc`. The Supabase CLI is
unaffected: it compiles with Bun and bundles the package.

## Consequence

Anyone installing on Node 20 will now see an engines warning. That is a
declared-support change on a published package, not a behavior change:
nothing in the package differs between the two ranges.
spydon added a commit that referenced this pull request Sep 25, 2026
## Summary

`@supabase/typegen` depended on `@supabase/postgrest-typegen` through
`^0.2.3` and its lockfile still resolved 0.2.3. This pins the dependency
to the exact `0.2.4` released in #215.

## Why an exact pin

The registry's contract, added in #213, is that a consumer depends on
`@supabase/typegen` alone and gets one postgrest-typegen version for
both introspection (re-exported `introspect`) and the in-process
generators. A caret range lets a consumer's lockfile resolve any later
0.2.x, so "the version the generators were built against" would not be a
guarantee. With an exact pin it is: every postgrest-typegen bump becomes
a registry release, and dependabot's existing bun group bumps the pin.

## Changes

- `packages/typegen/package.json` and `bun.lock`: `0.2.4`, exact.
- README and CLAUDE.md: one sentence each on why the pin is exact.

Checks: typecheck, format and lint, knip, 47 tests, and a
frozen-lockfile install all pass.
mandarini pushed a commit that referenced this pull request Sep 25, 2026
🤖 I have created a release *beep* *boop*
---


## 0.1.0 (2026-09-25)


### Features

* **typegen:** depend on the registry alone and prepare it for hosted
consumers ([#213](#213))
([ff5e98d](ff5e98d))


### Bug Fixes

* **typegen:** pin @supabase/postgrest-typegen to 0.2.4
([#216](#216))
([de4806e](de4806e))


### Miscellaneous Chores

* release 1.3.0 ([#97](#97))
([ee2ef6e](ee2ef6e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants