refactor(storage)!: share one SortDirection enum across the packages - #1752
Conversation
`SearchOptions.sortBy` took its sort direction as a `String`, so an invalid value only surfaced as a 400 from the storage server. `SortBy.order` is now the `FileSortOrder` enum that `listPaginated` already used, non-nullable and defaulting to `FileSortOrder.ascending`. `column` stays a `String`, since `list()` accepts any column of a `FileObject`. Closes SDK-1549
|
Warning Review limit reached
Next review available in: 13 minutes Limit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
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. Comment |
`BucketSortOrder` and `FileSortOrder` in supabase_storage and `SortDirection` in iceberg all described the same ascending or descending direction. They are now one `SortDirection` in supabase_common, re-exported from the clients that use it. `FileSortOrder` was only introduced in the previous commit, so the storage list sort direction lands as `SortDirection` from the start. Closes SDK-1549
What
StorageFileApi.list()took its sort direction as aString:Nothing validated that string, so
order: 'ascending'ororder: 'DESC'compiled fine and onlysurfaced as a 400 from the storage server.
While fixing that, the same asc/desc direction turned out to be modelled three times over:
BucketSortOrdersupabase_storageListBucketsOptions.sortOrderFileSortOrdersupabase_storageFileSort.order(listPaginated)SortDirectionicebergSortField.directionAll three had identical
ascending('asc')/descending('desc')values.Change
One
SortDirectioninsupabase_common, re-exported fromicebergandsupabase_storage(and sofrom
supabaseandsupabase_flutter):SortBy.orderis now that enum, non-nullable and defaulting toSortDirection.ascending:columnstays aString?with its'name'default, sincelist()accepts any column of aFileObjectwhileFileSortColumnonly covers the three the paginated endpoint sorts by.supabase-swift made the same
SortBychange in its storage v3 rewrite(supabase/supabase-swift#987).
SortDirectionis the name that survives rather thanSortOrder, becausepackage:icebergalready has a public
SortOrderclass (the Iceberg spec's sort-order object, withorderIdandfields) thatsupabase_storagere-exports, so aSortOrderenum would make the name ambiguousfor consumers.
The wire format is untouched: every serializer still emits
asc/desc.Breaking changes
BucketSortOrderandFileSortOrderare gone; useSortDirection, whose values are identicalSortBy(order: 'desc')becomesSortBy(order: SortDirection.descending)SortBy(order: null)no longer compiles; leaveorderout to sort ascendingicebergcallers are unaffected:SortDirectionkeeps its name and is still exported frompackage:iceberg/iceberg.dart.Documented in
MIGRATION.md. The default-filling behavior from #1490 is preserved: a partialSortBystill sends both keys, andordercan no longer be null at all.Query ordering keeps its bool
PostgrestTransformBuilder.order()andSupabaseStreamBuilder.order()deliberately keepascending: boolrather than taking aSortDirection. They build theasc/descstringinternally, so there was never an invalid value a caller could pass, and the bool matches
supabase-js (
{ ascending: false }) and supabase-swift, which keeps shared docs and cross-SDKexamples portable. v3 already changed that call once by flipping the
ascendingdefault, so anenum would make users touch the same line twice for no safety gain.
Compliance matrix
BucketSortOrderandFileSortOrderare removed from the storage features.SortDirectionwasalready registered in the shared
supporting_symbolsblock for iceberg, which is the right homefor it now that no single capability owns it.
.sdk-parse-ignoregains an exception forsort_direction.dart, alongside the existing one forretry_options.dart, since both aresupabase_commonsources the clients re-export as user facing API.Tests
SortBy.toMapcovers the null column fallback and the enum serializationlist sortBy defaultsgroup passes the enum, and its explicit-null case narrowed tocolumnsince
ordercannot be null anymoredart testpasses forsupabase_storage(203),iceberg(30) andsupabase_common(109), anddart analyzeis clean acrosspackagesandexamples.Closes #1491
Closes SDK-1549