Skip to content

refactor(storage)!: align remaining API with the Swift API Design Guidelines - #1368

Merged
grdsdev merged 2 commits into
mainfrom
refactor/storage-api-design-guidelines
Sep 17, 2026
Merged

grdsdev merged 2 commits into
mainfrom
refactor/storage-api-design-guidelines

Conversation

@grdsdev

@grdsdev grdsdev commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #1358's review — audited the rest of Sources/Storage/ (excluding Deprecated/) against the Swift API Design Guidelines, judging each call site on its own rather than by precedent in this file. Two findings, both fixed here.

SortBy.order is now SortOrder, not String

SortBy.order stored the raw "asc"/"desc" string even though its own initializer already took a type-safe SortOrder, discarding that safety one property read later — the exact pattern AGENTS.md's "Enum-like Values" section exists to prevent.

// Before
public var order: String?
public init(column: String? = nil, order: SortOrder? = nil) {
  self.order = order?.rawValue
}

// After
public var order: SortOrder?
public init(column: String? = nil, order: SortOrder? = nil) {
  self.order = order
}

upload/update/uploadToSignedURL label their file path

Every other StorageFileApi method taking a path labels it path: (download(path:), info(path:), exists(path:), createSignedURL(path:...), createSignedUploadURL(path:...)). upload, update, and uploadToSignedURL were the odd ones out, taking it positionally — an unlabeled String at the call site doesn't tell a reader whether it's a path, a key, or a URL, and it's inconsistent with its own siblings in the same file.

// Before
try await storage.from("avatars").upload("user123.png", data: imageData)

// After
try await storage.from("avatars").upload(path: "user123.png", data: imageData)

All six overloads (data:/fileURL: variants of upload/update/uploadToSignedURL) move together.

Shape

  • Both are breaking; this SDK is already accumulating breaking changes toward v3, so they're bundled in one PR rather than trickled in individually. Migration guide: V3_MIGRATION.md.
  • No wire-format changes — SortOrder still encodes to "asc"/"desc", and the HTTP requests upload/update/uploadToSignedURL make are untouched.
  • Every call site across Sources/, Tests/, and Examples/ updated to match.

Testing

$ swift build   # exit 0
$ swift test --skip IntegrationTests   # exit 0, 1411 tests in 141 suites passed
$ swift test --filter StorageTests   # exit 0, 193 tests passed
$ xcrun swift-format lint --recursive --strict Sources Tests   # exit 0
$ ./scripts/spell-check.sh   # exit 0, 413 files checked, 0 issues
$ ./scripts/test-docs.sh   # exit 0, no warnings

Didn't run IntegrationTests (no local Supabase instance in this session) — none of the changed call sites are integration-only, and the request shapes are unchanged, only argument labels and one property's static type.

…delines

SortBy.order stored the raw "asc"/"desc" string even though its own
initializer already took a type-safe SortOrder, discarding that safety
one property read later. Type it SortOrder directly.

upload, update, and uploadToSignedURL left their file path unlabeled
while every other StorageFileApi method taking a path (download, info,
exists, createSignedURL, ...) labels it path:. Label it there too, for
the same reason the others do: an unlabeled String at the call site
doesn't tell a reader whether it's a path, a key, or a URL.

See V3_MIGRATION.md for call-site examples.
@grdsdev
grdsdev requested a review from a team as a code owner September 17, 2026 16:48
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: cc0b35cf-42bb-4f0f-b4cc-f9917ef3bae4

📥 Commits

Reviewing files that changed from the base of the PR and between b31fb4e and 4585821.

📒 Files selected for processing (13)
  • .claude/skills/swift-api-design-guidelines/SKILL.md
  • Examples/Examples/Storage/FileUploadView.swift
  • Examples/UserManagement/ProfileView.swift
  • Sources/Storage/StorageFileApi.swift
  • Sources/Storage/SupabaseStorage.swift
  • Sources/Storage/Types.swift
  • Tests/DefaultIsolationTests/DefaultIsolationTests.swift
  • Tests/IntegrationTests/MemoryProbeIntegrationTests.swift
  • Tests/IntegrationTests/StorageFileIntegrationTests.swift
  • Tests/StorageTests/StorageFileAPITests.swift
  • Tests/StorageTests/SupabaseStorageTests.swift
  • Tests/StorageTests/ValueTypesTests.swift
  • V3_MIGRATION.md

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Changed

    • Storage upload, update, and signed-upload methods now require the file destination through the labeled path: argument.
    • SortBy.order now uses the type-safe SortOrder value instead of a raw string, while preserving the existing wire format.
  • Documentation

    • Added migration guidance covering the Storage argument-label updates and SortOrder transition.
    • Added Swift API naming and clarity guidelines for contributors.

Walkthrough

The public Storage upload, update, and signed-upload methods now require a labeled path: argument. Examples, tests, documentation, and migration guidance use the updated signatures. SortBy.order now uses SortOrder instead of String. A new Claude skill documents Swift API design and naming guidelines.

Priority: ⬇️ Low

Change: Refactor

Merge Risk: ⚪ Minimal · up to 45858

The API migration preserves current repository callers and request encoding, with no identified merge-blocking risk.


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.

Captures the naming/clarity rules from swift.org's API Design
Guidelines as a project skill, alongside swift-docc and
writing-migration-guides. Used to review #1358 and drive this PR.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Capability matrix drift detected

The following capabilities are marked implemented in the matrix but could not be found in swift:

  • client.session_management.persist_session → expected symbol: AuthLocalStorage.defaultLocalStorage
  • functions.invocation.streaming_response → expected symbol: FunctionsClient._invokeWithStreamedResponse

The following capabilities are marked implemented in swift but have no registered symbols to verify:

  • auth.passkey.register_passkey (no symbols list — cannot confirm implementation exists)
  • auth.passkey.sign_in_with_passkey (no symbols list — cannot confirm implementation exists)
  • client.observability.trace_propagation (no symbols list — cannot confirm implementation exists)
  • database.using_modifiers.request_cancellation (no symbols list — cannot confirm implementation exists)
  • functions.invocation.request_cancellation (no symbols list — cannot confirm implementation exists)
  • storage.file_buckets.url_cache_nonce (no symbols list — cannot confirm implementation exists)
  • storage.file_buckets.request_cancellation (no symbols list — cannot confirm implementation exists)

These may have been renamed, removed, or never registered. Please update the capability matrix.
See: https://github.com/supabase/sdk/blob/main/packages/capability-matrix/docs/capability-matrix.md

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 35249193306

Coverage remained the same at 89.413%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 11958
Covered Lines: 10692
Line Coverage: 89.41%
Coverage Strength: 898086.6 hits per line

💛 - Coveralls

@grdsdev
grdsdev enabled auto-merge (squash) September 17, 2026 17:03
@grdsdev
grdsdev merged commit 0e4b166 into main Sep 17, 2026
36 checks passed
@grdsdev
grdsdev deleted the refactor/storage-api-design-guidelines branch September 17, 2026 17:24
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.

3 participants