Skip to content

refactor!: share one HttpMethod enum across the client packages - #1645

Open
spydon wants to merge 1 commit into
breaking/supabase-exception-basefrom
breaking/shared-http-method
Open

refactor!: share one HttpMethod enum across the client packages#1645
spydon wants to merge 1 commit into
breaking/supabase-exception-basefrom
breaking/shared-http-method

Conversation

@spydon

@spydon spydon commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Tier 3 of #1572, second of four PRs. Stacked on #1644, so review that one first.

What

Four packages had four takes on the same enum:

Package Before
postgrest HttpMethod { get, head, post, put, patch, delete } with String get value
functions_client HttpMethod { get, post, put, delete, patch }, callers did method.name.toUpperCase()
gotrue RequestMethodType { get, post, put, patch, delete }
storage_client raw 'GET' / 'POST' / 'HEAD' strings threaded through the fetch layer and the Iceberg catalog

All four now use one HttpMethod in supabase_common:

enum HttpMethod {
  get, head, post, put, patch, delete;

  /// The method as it appears on the wire, for example `GET`.
  String get value => name.toUpperCase();
}

The conflict this removes

supabase could not re-export both packages' enums, so it carried:

export 'package:postgrest/postgrest.dart' hide HttpMethod;

Both now resolve to the same declaration, so the hide is gone and HttpMethod is reachable from package:supabase and package:supabase_flutter for the first time (previously functions.invoke(method: ...) was usable from supabase_flutter only because functions_client's copy happened to win).

Breaking changes

  • RequestMethodType is gone; gotrue's GotrueFetch.request takes HttpMethod. It lived in lib/src/ and was not exported from package:gotrue.
  • functions_client's HttpMethod gains a head value and a value getter. Existing HttpMethod.post style usage is unaffected.
  • postgrest's HttpMethod is unchanged in shape, it just moved packages.

Storage's changes are internal: its fetch layer and Iceberg REST catalog take HttpMethod instead of a String, which removes the last stringly-typed methods in the monorepo.

gotrue's request switch gained a head branch to stay exhaustive; it sends via Client.head like the other verbs.

Compliance matrix

functions.invocation.method_override listed the HttpMethod symbol. The enum now lives in the internal supabase_common, which is excluded from the public API scan, so the entry points at FunctionsClient.invoke (the method that actually takes the override) instead.

Testing

melos analyze and melos format clean. Full suites pass for gotrue, postgrest, storage_client, functions_client, realtime_client, supabase, supabase_common and supabase_flutter, plus the examples analyzer. The capability matrix symbol, drift and compliance checks pass.

@spydon
spydon requested a review from a team as a code owner August 5, 2026 09:39
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ecdb6b7-0d17-48f4-b136-3caa225c76a2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 changed the title breaking: share one HttpMethod enum across the client packages refactor!: share one HttpMethod enum across the client packages Aug 5, 2026
Three packages each declared their own HTTP method enum: `HttpMethod` in
postgrest (with a `value` getter), `HttpMethod` in functions_client (without
one) and `RequestMethodType` in gotrue, while storage passed method strings
around. They now all use a single `HttpMethod` in `supabase_common`.

The two public enums collided when re-exported together, which is why
`supabase` had to `hide HttpMethod` from postgrest. Both now resolve to the
same declaration, so the workaround is gone and `HttpMethod` is finally
reachable from `package:supabase` and `package:supabase_flutter`.

For consumers: postgrest's `HttpMethod` is unchanged, functions_client's
gains `head`, and gotrue's `RequestMethodType` is removed in favour of
`HttpMethod` (it was only reachable through `src/`).

The compliance matrix pointed `functions.invocation.method_override` at the
`HttpMethod` symbol; since the enum now lives in the internal, unscanned
`supabase_common`, the entry points at `FunctionsClient.invoke` instead.

Part of #1572 (tier 3), under the v3 umbrella #1278.
@spydon
spydon force-pushed the breaking/supabase-exception-base branch from d68a53b to aa160d3 Compare August 5, 2026 15:14
@spydon
spydon force-pushed the breaking/shared-http-method branch from 9a136d8 to 4b05226 Compare August 5, 2026 15:14
@spydon spydon added the v3 label Aug 5, 2026
spydon added a commit that referenced this pull request Aug 6, 2026
…1654)

Closes #1652

## What

A Dart enum type names one value rather than the set, so its name should
be singular. Five enums were ports of `realtime-js` / `gotrue-js` names
instead:

| Before | After | Was reachable by consumers? |
| --- | --- | --- |
| `ChannelStates` | `ChannelState` | No (omitted from the `show` list) |
| `ChannelEvents` | `ChannelEvent` | No (omitted from the `show` list) |
| `RealtimeListenTypes` | `RealtimeListenType` | No (named in the `hide`
clause) |
| `PostgresTypes` | `PostgresType` | Yes |
| `AuthenticatorAssuranceLevels` | `AuthenticatorAssuranceLevel` | Yes |

The three unreachable ones are now annotated `@internal`, which is both
the accurate annotation and enough to keep them out of the capability
matrix scan.

Sweeping the rest of the monorepo's 51 enums turned up one more name
that did not read as a noun naming a single value: `LoadTableSnapshots`
(storage, Iceberg) is now `TableSnapshotScope`.

## Enum extensions folded in

Enums can declare methods and static methods directly, so every
extension that only existed to hang helpers off an enum is now part of
the enum:

- `ChannelEventsExtended` → `ChannelEvent.fromType` /
`ChannelEvent.eventName`
- `ToType` → `RealtimeListenType.toType`
- `PostgresChangeEventMethods` → `PostgresChangeEvent.fromString` /
`PostgresChangeEvent.toRealtimeEvent`
- `PresenceEventExtended` → `PresenceEvent.fromString`
- `AuthChangeEventExtended` → `AuthChangeEvent.fromString`
- `GenerateLinkTypeExtended` → `GenerateLinkType.fromString`

Those helpers decode wire values, so the folded members carry
`@internal`, matching the visibility the extensions already had through
the `hide` clauses. The now-unnecessary `hide` entries are dropped from
the gotrue and realtime_client exports.

`SupabaseEventTypesName` is deliberately left alone: its member is
`name()`, which would shadow `Enum.name` if declared on the enum, and
both it and its deprecated enum are due for removal anyway.

## Not changed

- `SocketStates`, because #1404 already renames it.
- `AMRMethod` / `AMREntry` violate Dart's "capitalize acronyms longer
than two letters like words" rule (`AmrMethod` / `AmrEntry`). Out of
scope here, worth a follow-up.
- `RequestMethodType` in gotrue is replaced by the shared `HttpMethod`
in #1645.
- `FactorStatus`, `RealtimeHeartbeatStatus` and
`RealtimeSubscribeStatus` end in `s` but are singular ("status").
- Enum *values* such as `GenerateLinkType.magiclink` and
`OtpType.magiclink` are not lowerCamelCase, but they are load-bearing:
the wire value is derived from the value name.

## Behaviour

None. No enum value changes: `ChannelEvent.eventName()` still produces
the same `phx_*` strings and `TableSnapshotScope` still sends `all` /
`refs`.

## Capability matrix

`PostgresType`, `AuthenticatorAssuranceLevel` and `TableSnapshotScope`
are registered under `realtime.subscriptions.postgres_changes`,
`auth.mfa.get_authenticator_assurance_level` and
`storage.analytics.iceberg_table` (replacing the stale
`LoadTableSnapshots` entries).

## Testing

- `dart analyze packages examples`: clean
- `realtime_client`, `supabase`, `supabase_flutter` suites: pass
- `gotrue` MFA, constants and types suites: pass (the rest of the
`gotrue` suite has pre-existing failures against my local stack on
`main` too)
- supabase/sdk `check-api-symbols`, `check-drift` and
`validate-compliance` run locally against this branch: all pass

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Breaking Changes**
- Renamed authentication assurance-level, realtime channel/event,
Postgres type, and table snapshot enums.
- Updated related method parameters and response fields to use the new
names.

- **Improvements**
  - Simplified enum parsing and conversion APIs.
  - Corrected public exports for supported types and utilities.
- Preserved existing authentication, MFA, realtime, storage, and
data-conversion behavior.

- **Tests**
- Updated coverage for enum parsing, serialization, realtime events, and
MFA flows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants