Skip to content

refactor: extract shared code into supabase_common package - #1573

Merged
spydon merged 1 commit into
mainfrom
refactor/extract-supabase-common
Jul 9, 2026
Merged

spydon merged 1 commit into
mainfrom
refactor/extract-supabase-common

Conversation

@spydon

@spydon spydon commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Introduces a new published supabase_common package and moves the non-breaking shared/duplicated code from #1572 into it.

Stacked: main ← #1569 (drop rxdart) ← #1571 (drop retry, in-house helper) ← this PR.

Note

Review/merge in stack order. Retarget this PR's base as each parent merges (→ refactor/inline-retry, then refactor/supabase-drop-rxdart, then main).

Moved into supabase_common

Item Was
ToSnakeCase enum extension duplicated (byte-for-byte) in gotrue + storage_client
Platform detection (platform_io/platform_stub) duplicated in supabase + supabase_flutter (kept the extra isRunningInFlutterTest)
buildClientInfoHeader (X-Client-Info) built in all 7 client packages (simple + platform-aware forms)
isSuccessStatusCode (2xx) inlined/duplicated in gotrue, storage_client, postgrest, functions_client
FetchOptions duplicated internally in gotrue + storage_client
Base64Url / PKCE / uuid helpers gotrue-only; also fixes an intra-gotrue duplication in jwt.dart
ReplaySubject unifies gotrue's _ReplaySubject and supabase's _BehaviorSubject
retry / RetryOptions helper the in-house copy #1571 added to gotrue + storage_client (identical); @internal dropped since it is now used across packages

Not included

Notes

  • supabase_common is an internal, published package (client packages cannot depend on an unpublished local package). Its README flags it as internal with breaking changes expected.
  • Registered in the workspace, test.yml (DART_PACKAGES + Coveralls carryforward), and release-pana.yml.
  • No public API changes: every moved symbol was either internal or re-exported so consumers importing from the client packages are unaffected.

Verification

  • dart analyze clean across the whole workspace.
  • supabase_common unit tests pass (ToSnakeCase, client-info header, isSuccessStatusCode, Base64Url, PKCE, uuid, ReplaySubject sync/async/replay/hooks/addStream, retry).
  • gotrue (constants/helper), functions_client (full suite), and supabase (utilities) tests pass locally. Backend-dependent suites run in CI.

Refs #1572

@spydon
spydon requested a review from a team as a code owner July 9, 2026 12:34
@spydon
spydon force-pushed the refactor/extract-supabase-common branch from 5dbf1ef to b6aa2d7 Compare July 9, 2026 12:45
@spydon
spydon changed the base branch from refactor/supabase-drop-rxdart to refactor/inline-retry July 9, 2026 12:45
@spydon
spydon force-pushed the refactor/extract-supabase-common branch from b6aa2d7 to 56b8147 Compare July 9, 2026 13:03
@spydon
spydon force-pushed the refactor/inline-retry branch from 3b2af42 to 358f8e1 Compare July 9, 2026 13:53
@spydon
spydon force-pushed the refactor/extract-supabase-common branch from 56b8147 to 0101b08 Compare July 9, 2026 13:54
Base automatically changed from refactor/inline-retry to main July 9, 2026 13:58
@spydon
spydon force-pushed the refactor/extract-supabase-common branch from 0101b08 to 4230c62 Compare July 9, 2026 14:09
Introduces a new published supabase_common package and moves the
non-breaking shared/duplicated code into it:

- ToSnakeCase enum extension (was duplicated in gotrue and storage_client)
- Platform detection (was duplicated in supabase and supabase_flutter,
  keeping the extra isRunningInFlutterTest flag)
- buildClientInfoHeader for the X-Client-Info header (simple and
  platform-aware forms) used by all client packages
- isSuccessStatusCode 2xx helper
- FetchOptions (was duplicated internally in gotrue and storage_client)
- Base64Url, PKCE and uuid helpers (moved out of gotrue, also fixing an
  intra-gotrue duplication in jwt.dart)
- A unified ReplaySubject replacing gotrue's _ReplaySubject and
  supabase's _BehaviorSubject
- The in-house retry helper (was duplicated in gotrue and storage_client
  by #1571)

supabase_common is excluded from the SDK compliance public-API scan via
.sdk-parse-ignore: its symbols are consumed across packages and so cannot
be marked @internal without tripping invalid_use_of_internal_member.

Refs #1572
@spydon
spydon force-pushed the refactor/extract-supabase-common branch from 4230c62 to 64c4258 Compare July 9, 2026 14:17
@spydon
spydon merged commit 46601bb into main Jul 9, 2026
33 checks passed
@spydon
spydon deleted the refactor/extract-supabase-common branch July 9, 2026 15:44
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