feat(postgrest-typegen): formatter hook, oxfmt default, concurrent introspection - #118
Merged
Conversation
Add an optional `format` callback to GenerateTypescriptOptions, defaulting to prettier.format so existing callers see no behavior change. Callers on a latency-sensitive path, like postgres-meta's hosted generator route, can substitute a worker-pool-backed formatter instead of blocking the event loop on every call.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
… to oxfmt Replace prettier with oxfmt as the default formatter for generated TypeScript output. Prettier spends 73-92% of generateTypescript's runtime on large schemas; oxfmt is roughly an order of magnitude faster for this kind of machine-generated output that nobody diffs by hand. printWidth is pinned to 80 to match prettier's default and keep output churn to a formatter-only, mostly cosmetic diff (oxfmt's default is 100). The prettier dependency is dropped; oxfmt moves from a devDependency (used only for this package's own source) to a runtime dependency. The `format` option's signature drops the now formatter-specific `prettier.Options` parameter in favor of a plain `(code: string) => Promise<string>`; since `format` itself is new and unreleased in this same PR, this is not a breaking change to any shipped version. The nightly parity job against real postgres-meta (which still formats with prettier) now canonicalizes postgres-meta's output through this package's own oxfmt formatter before diffing, so the comparison reflects generator content, not which formatting engine produced it.
Tr00d
approved these changes
Aug 31, 2026
Closed
2 tasks
spydon
added a commit
that referenced
this pull request
Aug 31, 2026
…mits (#120) ## Summary Removes the `release-as` entries from `release-please-config.json` for both packages. `release-as` pins every release PR to that exact version. The pins were used to force the initial versions when the per-package release-please setup landed (#111/#112), but both packages have since shipped those versions (`capability-matrix` 1.6.0, `postgrest-typegen` 0.1.0), so the pins now block any further version bump. Concretely: #118 landed as a `feat` on `postgrest-typegen`, which with `bump-minor-pre-major: true` should produce 0.2.0, but the release PR #119 proposed a no-op `v0.1.0...v0.1.0` release with only a changelog change because the config forced 0.1.0 again. `capability-matrix` would hit the same wall on its next release. Once this merges, release-please will refresh #119 to a proper 0.2.0 (changelog, `package.json`, and manifest bump). ## Test plan - [x] `release-please-config.json` still validates against its $schema (structure unchanged, only the two `release-as` keys removed) - [ ] After merge: release-please refreshes #119 to `postgrest-typegen: 0.2.0`
Merged
spydon
pushed a commit
that referenced
this pull request
Aug 31, 2026
🤖 I have created a release *beep* *boop* --- <details><summary>postgrest-typegen: 0.2.0</summary> ## [0.2.0](postgrest-typegen-v0.1.0...postgrest-typegen-v0.2.0) (2026-08-31) ### Features * **postgrest-typegen:** formatter hook, oxfmt default, concurrent introspection ([#118](#118)) ([fa2286c](fa2286c)) </details> --- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
formatcallback toGenerateTypescriptOptionsfor the TypeScript generator, and switches the default formatter itself from prettier to oxfmt.This unblocks supabase/postgres-meta#1084, whose description flags that
@supabase/postgrest-typegenformats inline withprettierand exposed no formatting hook yet, which that PR states should land here first. Tracked in Linear as SDK-1649.The review comment on that PR (supabase/postgres-meta#1084 (comment)) measured prettier at roughly 73-92% of
generateTypescript's time and made two asks against this package:postgrest-typegen— it already usesoxfmt/oxlinton its own source, so the dependency is familiar there." Addressed by theformatoption.oxfmtis roughly an order of magnitude faster on this kind of workload." Addressed by switching the default itself, not just making it overridable.Neither of these fully eliminates main-thread blocking on its own; that review's own benchmark achieved its largest win (~1000ms -> ~21ms main-thread block) by additionally wrapping the entire
generateTypescript()call in a worker, which is an architecture choice for the consumer (postgres-meta) to make, not something needed here.Changes
introspect()now issues its ten introspection queries underPromise.allinstead of awaiting them one at a time. The same review flagged that postgres-meta's CLI path (supabase gen types) went from parallel to sequential in the migration, adding one round trip per query on remote databases; this restores the old parallelism for every consumer. A pooledQueryableruns the queries in parallel, a single-connection one pipelines them.GenerateTypescriptOptions.format?: (code: string) => Promise<string>— optional, defaults to a newoxfmt-backed formatter (semi: false,printWidth: 80to match prettier's default and minimize output churn).prettierdropped as a dependency;oxfmtmoves from a devDependency to a runtime dependency.The nightly parity job against real postgres-meta (still prettier-formatted) now canonicalizes postgres-meta's TypeScript output through this package's own oxfmt formatter before diffing, so it keeps catching real content drift without flagging the formatter swap itself every night.
test/parity/expected/typescript.txtand the inline snapshots intest/generation/typescript.test.tsregenerated for the new formatter's output. Verified the only remaining differences from the previous prettier-formatted goldens are formatter style choices (confirmed by reformatting the old prettier golden through the new oxfmt formatter and diffing against a fresh regeneration; the only residual difference is oxfmt adding parentheses around a conditional type in a couple of generic-default positions, which is semantically inert).Test plan
bun run check-typesbun run format-and-lintbun run knipbun run buildbun run test(93 pass, including a regression test asserting a customformatcallback is invoked and its output is used verbatim)