Skip to content

feat!: v3 - #1173

Draft
grdsdev wants to merge 13 commits into
mainfrom
release/v3
Draft

feat!: v3#1173
grdsdev wants to merge 13 commits into
mainfrom
release/v3

Conversation

@grdsdev

@grdsdev grdsdev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

What is the current behavior?

Please link any relevant issues here.

What is the new behavior?

Feel free to include screenshots if it includes visual changes.

Additional context

Add any other context or screenshots.

grdsdev and others added 13 commits June 26, 2026 09:33
Remove approximately 4,676 lines of deprecated code accumulated during v2.x lifecycle:
- 3,726 lines: Realtime Protocol 1.0 implementation (11 files)
- 950 lines: Deprecated constructors, methods, properties, error cases

- Entire `/Sources/Realtime/Deprecated/` folder (Protocol 1.0)
- `RealtimeChannelV2.subscribe()` (use `subscribeWithError()`)
- `RealtimeChannelV2.broadcast(event:)` receiving method (use `broadcastStream(event:)`)
- Type aliases: Message, Configuration, Status, Subscription
- Property: `RealtimeClientV2.subscriptions` (use `channels`)

- Extracted `ChannelEvent` enum to `Sources/Realtime/ChannelEvent.swift` (still needed by v2)

- `Sources/Auth/Deprecated.swift`
- Deprecated constructors without `logger` parameter
- `AuthAdmin.deleteUser(id: String)` (use UUID version)
- Error cases: missingExpClaim, malformedJWT, sessionNotFound, pkce(_:), invalidImplicitGrantFlowURL, missingURL, invalidRedirectScheme
- Type aliases: GoTrueClient, GoTrueMFA, GoTrueLocalStorage, GoTrueMetaSecurity, GoTrueError
- Property: `User.emailChangeToken`
- Type alias: `MFAEnrollParams` (use MFATotpEnrollParams or MFAPhoneEnrollParams)

- `Sources/PostgREST/Deprecated.swift`
- Deprecated constructors without `logger` parameter
- Filter methods: like(_:value:), in(_:value:), plfts(), phfts(), wfts(), ilike(_:value:)
- Property: `PostgrestFilterValue.queryValue` (use `rawValue`)
- Type alias: URLQueryRepresentable

- `Sources/Storage/Deprecated.swift`
- Deprecated constructors without `logger` parameter
- Upload methods with String return type (use FileUploadResponse)
- Upload methods with old parameter names (file: → data:)
- Types: File struct, FormData class
- Public access to defaultStorageEncoder and defaultStorageDecoder

- `Sources/Supabase/Deprecated.swift`
- Property: `.database` (use `.from()`, `.rpc()`, `.schema()`)
- Property: `.realtime` (use `.realtimeV2`)
- Internal `_realtime` property and initialization

- Updated test usage of deprecated APIs
- Removed `emailChangeToken` from test UserAttributes
- Changed `MFAEnrollParams` to `MFATotpEnrollParams` in tests
- Removed test usage of `defaultStorageEncoder`

Added comprehensive `MIGRATION_V3.md` with:
- Complete breaking changes list
- Migration examples for all removed APIs
- Checklist for migration
- Links to additional resources

All removed APIs were deprecated in v2.x with clear migration paths. This is a v3.0 major version bump.

Closes: SDK-436

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove the macos-legacy CI job that tested on macOS 14 with Xcode 15.4. The project now only tests on modern macOS 15 with Xcode versions eligible for App Store submission.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…918)

* chore: set minimum Swift version to 6.1 and Xcode to 16.3+ for v3.0

Update supabase-swift SDK minimum requirements from Swift 5.10/Xcode 15.3+
to Swift 6.1/Xcode 16.3+ for the v3.0 release. The codebase was already
well-prepared for Swift 6 with strict concurrency enabled, Sendable
conformance throughout, and modern async/await patterns.

- **Package.swift**: Updated swift-tools-version from 5.10 to 6.1
- **Package.swift**: Updated platform targets (iOS 16+, macOS 12+, tvOS 16+, watchOS 9+)
- **README.md**: Updated requirements to reflect Swift 6.1+ and Xcode 16.3+
- **AGENTS.md**: Updated development environment requirements

Fixed Swift 6 strict concurrency issues in test suite:
- **FunctionsClientTests**: Explicit capture of session in @sendable closures
- **PostgresQueryTests**: Explicit capture of session in @sendable closures
- **SupabaseStorageTests**: Explicit capture of supabaseURL in closures
- **AuthClientTests**: Explicit capture of sut in Task closures
- **SessionManagerTests**: Fixed capture list and Result type
- **RealtimeTests**: Explicit capture of client and sut in closures
- **CallbackManagerTests**: Added sending parameter to XCTAssertNoLeak
- **StorageBucketAPITests**: MainActor.assumeIsolated for XCTContext
- **MockHelpers**: Convert Dependencies.mock to computed property
- **PostgrestIntegrationTests**: Fixed ilike API (pattern: not value:)

- Production code builds cleanly with Swift 6.1 ✅
- 558 tests executed, 547 passing (98% pass rate)
- 11 test failures related to stricter concurrency checks
- Library evolution build succeeds ✅

- Official language-level strict concurrency (not experimental)
- Better compile-time data race detection
- Improved optimization for async/await
- Type-safe existentials by default
- Enhanced actor isolation checking
- Region-based isolation features

- [x] Package.swift swift-tools-version set to 6.1
- [x] Platform deployment targets updated (iOS 16+, tvOS 16+, watchOS 9+)
- [x] All documentation (README.md, AGENTS.md) reflects new requirements
- [x] CI/CD pipeline already tests Xcode 16.3+ (verified)
- [x] Production code builds successfully with Swift 6.1
- [x] Swift Package Manager resolution works correctly
- [x] Library evolution builds succeed
- [x] No breaking API changes (only infrastructure upgrade)

Linear: SDK-714

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* style: code format

* fix decoder

* code format

* specify as JSONObject

* fix(tests): resolve CI failures for integration and xcodebuild tests

- Fix Linux integration tests to use Bundle.module instead of #file for accessing test fixtures
- Fix Xcode 16.4 compiler errors in AuthClientTests:
  - Use explicit capture with sut! for Task closures with implicitly unwrapped optionals
  - Fix type inference by referencing local variable validSession instead of .validSession shorthand
  - Add explicit type annotation for events array to resolve key path type inference

These changes fix:
1. Integration Tests (Linux) - missing sadcat.jpg file errors
2. xcodebuild (macOS latest) (test, IOS, 16.4) - Swift compiler errors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(tests): resolve remaining CI failures for Linux and Xcode 16.4

- Use #filePath instead of Bundle.module for StorageFileIntegrationTests to fix Linux resource access
- Fix Xcode 16.4 Swift 6 concurrency errors in RealtimeTests:
  - Add nonisolated(unsafe) to test properties in _PushTests to fix MainActor isolation errors
  - Fix capture list unwrapping for implicitly unwrapped optional properties in closures

These changes fix:
1. Integration Tests (Linux) - nil unwrap crash when accessing test fixtures via Bundle.module
2. xcodebuild (macOS latest) (test, IOS, 16.4) - Swift concurrency and type inference errors

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
* feat(helpers): add _HTTPClient with RequestBody and separate query/body params

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(helpers): add TokenProvider support to _HTTPClient

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(helpers): stream UInt8 bytes instead of single-byte Data chunks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(helpers): add FoundationNetworking import for Linux and Sendable conformance to RequestBody

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(helpers): guard fetchStream behind canImport(Darwin) — URLSession.bytes unavailable on Linux

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(helpers): use @autoclosure @sendable for RequestBody to satisfy Sendable without @unchecked

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(tests): resolve Sendable and actor-isolation errors in PostgREST and Storage tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
- Change withTimeout to accept throwing closures, removing need for
  Result wrapping in call sites (fixes SendingRisksDataRace error)
- Fix var → let for immutable array in RealtimeSerializer
- Remove extra blank line in RealtimeChannel+AsyncAwait

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use Self.makeHTTPURLResponse in PostgrestBuilderTests closures
  (static member cannot be used on instance via self in @sendable context)
- Use Self.url in PostgrestTransformBuilderTests (same issue)
- Make makeResponse static in RetryRequestInterceptorTests and use Self.
- Capture ws locally before Task closure in ConnectionManagerTests
- Add @unchecked Sendable to ConnectionManagerTests to allow Task
  closures to capture sut/expectations (class is run serially by XCTest)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
RealtimeTests and AuthClientTests have Task closures that implicitly
capture self (the XCTestCase instance) in @sendable contexts. Swift 6
strict concurrency requires the captured type to be Sendable.

Adding @unchecked Sendable is appropriate since XCTest runs test
methods serially and there is no actual concurrent access to self.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Constrain lifecycleManager to Sendable & AnyObject to satisfy Swift 6
  strict concurrency in RealtimeClientV2
- Add @unchecked Sendable to RealtimeChannelBroadcastTests (Task closure
  captures self implicitly)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(helpers): add _HTTPClient with RequestBody and separate query/body params

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(helpers): add TokenProvider support to _HTTPClient

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(helpers): stream UInt8 bytes instead of single-byte Data chunks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(functions): migrate to _HTTPClient, remove old HTTP layer from Functions

- Replace HTTPClientType/HTTPClient/FetchHandler with _HTTPClient
- FunctionInvokeOptions.headers and query now use [String: String]
- _invokeWithStreamedResponse is now async throws
- SupabaseClient passes session + tokenProvider to FunctionsClient
- Remove RequestTests.swift (covered by inline snapshots in FunctionsClientTests)
- Add package access modifiers to _HTTPClient types

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(functions): convert FunctionsClient to actor, simplify streaming API

- Convert FunctionsClient from Sendable class with LockIsolated to actor
- Replace _invokeWithStreamedResponse (URLSessionDataDelegate-based) with
  invokeStream returning AsyncThrowingStream<UInt8, any Error> via _HTTPClient
- fetchStream now async throws and returns (stream, HTTPURLResponse) tuple,
  allowing pre-stream validation (errors thrown before stream is returned)
- Remove StreamResponseDelegate class
- Set session timeout via configuration instead of per-request
- Fix relay error header name typo (x-relay -> x-relay-error)
- Update FunctionsClientTests and SupabaseClient for actor isolation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(functions): catch HTTPClientError and convert to FunctionsError in rawInvoke

_HTTPClient.fetchData now throws HTTPClientError.responseError on non-2xx
responses. FunctionsClient.rawInvoke catches it and converts to the
public FunctionsError.httpError type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(functions): add builder-pattern invoke API

Replace options-struct overloads with a single configure-closure
pattern. `invoke`, `invokeDecodable`, and `invokeStream` now accept
`(inout FunctionInvokeOptions) -> Void` instead of
`FunctionInvokeOptions`. `invokeDecodable` returns `(T, HTTPURLResponse)`
and `invokeStream` returns `(AsyncThrowingStream<UInt8, Error>, HTTPURLResponse)`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(functions): use FunctionRegion everywhere, remove String? region overloads

- FunctionsClient package init takes FunctionRegion? instead of String?
- Remove public convenience init (replaced by public designated init)
- FunctionsOptions.region is now FunctionRegion? (was String?)
- Remove @_disfavoredOverload String? init from FunctionsOptions
- Update tests to use FunctionRegion enum values and actor-safe access patterns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(functions): use FunctionRegion in FunctionInvokeOptions, remove String? overloads

- FunctionInvokeOptions.region is now FunctionRegion? (was String?)
- Remove duplicate extension inits that delegated with region?.rawValue
- Remove @_disfavoredOverload attributes (no longer needed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(functions): add comprehensive tests with echo edge function

Add 19 comprehensive tests for FunctionsClient using Replay library:
- Basic invocation tests (default, JSON body, arrays, text, binary)
- HTTP method tests (GET, PUT, PATCH, DELETE)
- Custom headers and content-type overrides
- Complex scenarios with nested JSON
- Decode tests with custom decoders
- Authentication token tests
- Response metadata validation

Created echo edge function at supabase/functions/echo/ that:
- Accepts any HTTP method and echoes back request details
- Sorts query parameters alphabetically for deterministic testing
- Handles JSON, plain text, and binary data

Test suite uses .serialized and .playbackIsolated for deterministic
replay testing with 19 HAR files stored in Tests/FunctionsTests/Replays/

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* test(functions): update tests for v3 builder-pattern invoke API

- Replace invoke(options: FunctionInvokeOptions) with builder closure style
- Replace invoke<T: Decodable> with invokeDecodable returning (T, HTTPURLResponse)
- Update invokeStream callers to unpack (stream, response) tuple
- FunctionsTests.swift: migrate all invoke/coercion calls to invokeDecodable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(functions): fix tests for builder-pattern API and public init

- Add public init() to FunctionInvokeOptions (memberwise init is internal)
- Update FunctionInvokeOptionsTests to test var properties directly
- Convert remaining FunctionInvokeOptions(body:) calls to manual Data encoding
- Set Content-Type explicitly when encoding body in test closures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(functions): unify public init to delegate to package init with nil tokenProvider

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(functions): make FunctionRegion an open struct and store decoder on client

- Convert FunctionRegion from enum to RawRepresentable struct with ExpressibleByStringLiteral so callers can pass custom region strings
- Add optional decoder property to FunctionsClient, used as fallback in invokeDecodable
- Update tests to use Bundle.module for replay URLs and await actor-isolated decoder property

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(supabase): propagate global URLSession to RealtimeClient as fetch closure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(functions): make decoder a public non-optional property on FunctionsClient

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(functions): use non-optional JSONDecoder with default value in init parameters

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(functions): add comprehensive DocC documentation and usage examples to public API

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(functions): trim verbose doc comments per linter suggestions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(helpers): add FoundationNetworking import and update examples for new Functions API

Add missing `#if canImport(FoundationNetworking)` guard to `_HTTPClient.swift` so
the Linux build finds `HTTPURLResponse`, `URLSession`, and `URLRequest`. Update
`FunctionsExamplesView.swift` to use the new `invokeDecodable` closure-based API
introduced by the functions v3 rewrite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: gate stream methods behind #if canImport(Darwin)

URLSession.bytes(for:) is not available on Linux. Wrap fetchStream in
_HTTPClient and invokeStream in FunctionsClient with #if canImport(Darwin)
so the Linux build compiles cleanly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: gate invokeStream tests behind canImport(Darwin) and fix formatting

Tests calling invokeStream failed to compile on Linux because the method is
Darwin-only. Wrap the three streaming test functions in #if canImport(Darwin).
Also re-run swift-format on _HTTPClient.swift and FunctionsClient.swift to
fix the indentation of the #if blocks inside the actor/class body.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(functions): update invokeDecodable doc comments and add explicit T.Type parameter

Update DocC symbol links to reflect the as: parameter label and add
`as _: T.Type = T.self` to invokeDecodable for more ergonomic call sites.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(functions): use replaysRootURL for cross-platform HAR archive lookup

Bundle.module.resourceURL?.appendingPathComponent("Replays") uses direct
path concatenation, bypassing bundle.url(forResource:withExtension:subdirectory:)
which is broken on Linux swift-corelibs-foundation for subdirectory lookups.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(functions): pass rootURL per-test to fix HAR resolution on Linux

TestScoping for suite-level traits does not reliably propagate ReplayTestDefaults
to individual tests on Linux, causing all tests to resolve the wrong archive via
the broken Bundle.url(forResource:subdirectory:) fallback.

Fix: provide an explicit rootURL to each ReplayTrait so getArchiveURL uses the
direct URL path (step 1) on both platforms, bypassing TestScoping and bundle
resource lookup entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(functions): mark invoke options closure as @sendable

FunctionsClient is an actor; passing (inout FunctionInvokeOptions) -> Void
from @mainactor callers crosses an isolation boundary. Swift 6 strict
concurrency requires the closure to be @sendable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(functions): replace @sendable with sending for closure parameters

Use the `sending` ownership modifier instead of `@Sendable` for the
`options` closure parameters in invoke, invokeDecodable, and invokeStream,
aligning with Swift 6 concurrency conventions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Cover the full architectural overhaul introduced in PR #987:
- Class → struct rewrite (StorageClient, StorageFileAPI)
- Task-based upload/download API with .value and .events
- TUS resumable uploads with pause/resume/cancel
- Background downloads with URLSession
- BucketOptions.isPublic, StorageByteCount, DownloadBehavior
- FileOptions changes (duplex/headers removed)
- Signed URL Duration and DownloadBehavior params
- FileInfo replaces FileObjectV2
- Expanded checklist from 4 → 16 items
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a98257a1-bf73-4bc7-9b98-f3cfbed6a2f6

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.

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.

1 participant