Repository navigation
feat: type withSupabase with the engine's Composite - #209
Draft
johnstonmatt wants to merge 2 commits into
Draft
johnstonmatt wants to merge 2 commits into
johnstonmatt wants to merge 2 commits into
Conversation
Calls without a type argument resolve against the engine's Composite signatures. Calls that choose Database, explicitly or by annotation, resolve as before. A middleware nested inside it type-checks with supabase/middleware#55 on TypeScript 5.4 to 7.0. The runtime is unchanged. WithSupabase is exported, and type tests cover each call spelling. Refs FUNC-1187
commit: |
This branch has not been deployed
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
withSupabaseis typed with the engine's ownComposite, with the signatures that take aDatabasetype kept in front of it. Every call spelling in use compiles as before, and a middleware nested insidewithSupabasestays typed under the engine's handler-position typing (supabase/middleware#55) on every TypeScript version from 5.4.The hand-written generic signature it replaces breaks a nested middleware before TypeScript 5.9 once #55's typing ships: its unresolved
Basereaches the inner call, which then fails withNo overload matches this call. That includesdeno checkon Deno 2.0 to 2.4, and Edge Functions' runtime is built on Deno 2.1.4. The engine'sCompositedoesn't have the problem. The runtime is unchanged.Evidence
src/with-supabase.test.ts(withSupabase call spellings): nested without an anchor, nested inside another middleware, a collision below it, an explicitDatabasein the handler, nested, entry and<Db, Upstream>forms, and a handler annotation choosingDatabase. Each@ts-expect-erroronctx.supabase.from('nope')proves the client carries the chosenDatabase.mainon the same middleware build:withSupabase, failing onmaintoo, report 2 errors instead of 3maindeno checkof the packed build, with middleware sharing one copy, on Deno 2.1.4, 2.4.5, 2.5.0 and 2.9.8:typecheck,typecheck:examples,typecheck:e2e, lint,check-deps, the unit and NestJS tests, build, both smoke tests, attw, the JSR dry run and the docs build pass. The docs build hasmain's warnings and no new ones.Merge Danger
Door: two-way
Blast Radius: types
withSupabasegets the engine's collision check: a middleware below it that contributes one of its keys fails to compile in a stack anchored withsatisfies FetchHandler, as apipelinealready refuses the same stack.withSupabaseis now aconstof the exported typeWithSupabaserather than an overloaded function. Code that reads its type withtypeof withSupabasesees the new type.@supabase/serverand picks up a middleware release with feat: add NestJS adapter #55 still breaks on Deno 2.0 to 2.4.Refs FUNC-1187