Skip to content

feat(storage): list analytics buckets - #856

Merged
Tr00d merged 2 commits into
masterfrom
feat/storage.analytics.list_analytics_buckets
Nov 25, 2026
Merged

Tr00d merged 2 commits into
masterfrom
feat/storage.analytics.list_analytics_buckets

Conversation

@Tr00d

@Tr00d Tr00d commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

A caller can list the project's analytics (Apache Iceberg) buckets through storage.Analytics.ListBucketsAsync, with optional pagination, sort and search.

Capability: storage.analytics.list_analytics_buckets - List Analytics Buckets. No capability spec exists; the contract is the storage route GET /iceberg/bucket and its source.

Public API

// IStorageAnalyticsApi
Task<IReadOnlyList<AnalyticsBucket>> ListBucketsAsync(ListAnalyticsBucketsOptions? options = null, CancellationToken cancellationToken = default);

// Supabase.Storage.ListAnalyticsBuckets
public sealed record ListAnalyticsBucketsOptions
{
    int? Limit { get; init; }
    int? Offset { get; init; }
    AnalyticsBucketSort? Sort { get; init; }
    string? Search { get; init; }
}
public sealed record AnalyticsBucketSort(AnalyticsBucketSortColumn Column, ListSortDirection Direction = ListSortDirection.Ascending);
public enum AnalyticsBucketSortColumn { Name, CreatedAt, UpdatedAt }

AnalyticsBucket moves from Supabase.Storage.CreateAnalyticsBucket to Supabase.Storage.Common, now that create and list both return it. It has not shipped in a release (still in PublicAPI.Unshipped.txt), so the move breaks no released caller; the gate's public-API diff reports it as 16 removals for that reason.

var storage = new Client(url, headers);
var buckets = await storage.Analytics.ListBucketsAsync(new ListAnalyticsBucketsOptions
{
    Limit = 10,
    Sort = new AnalyticsBucketSort(AnalyticsBucketSortColumn.CreatedAt, ListSortDirection.Descending),
});

Behavior

  • Operation: GET {storageUrl}/iceberg/bucket, no body. Requires a service-role key; headers are read at call time.
  • Inputs: every option is optional and only sent when set: limit, offset, sortColumn (name / created_at / updated_at), sortOrder (asc / desc, ascending unless specified), search (escaped as one query value). Without options, no query is sent and the service applies its defaults: every bucket, sorted by name ASC.
  • Checks before the wire: only an undefined AnalyticsBucketSortColumn value throws ArgumentOutOfRangeException. Pagination ranges (limit >= 1, offset >= 0) are validated by the service (400).
  • Output: the buckets in the service's order, as IReadOnlyList<AnalyticsBucket> (name, created_at, updated_at; id is dropped, it always equals name). A JSON null body maps to an empty list; an empty success body is not a listing and surfaces as SupabaseStorageException, as for create.
  • Failures: any non-2xx becomes SupabaseStorageException through the existing hint mapping (400 out-of-range pagination, 401 NotAuthorized, 403 feature not enabled, 500 Internal). The Iceberg error envelope carries no top-level statusCode, so the HTTP status is reported.
  • State: none.

Deviations from supabase-js

  • Sort column and direction are one Sort value: the service ignores a direction without a column, so the type cannot express it.
  • Enums replace string unions; the direction reuses the BCL's System.ComponentModel.ListSortDirection.
  • id is not offered as a sort column (the route accepts it, supabase-js does not; it equals name).
  • The result has no type or format: the route does not return them (same as create).
  • Errors throw instead of returning { data, error }.

Tests

Tier Class Pins
Contract ListAnalyticsBucketsContractTests method, path, no body, headers, query for each option and its wire names, no query when unset, search escaping, response mapping and order, empty and null bodies, 400/401/403/500, call-time headers, cancellation, no capture of the caller's context
Unit ListAnalyticsBucketsTests an undefined sort column throws before the wire

No E2E: the CLI stack does not serve Iceberg yet, consistent with create and delete. No wire-shape approval: the request has no body; the query is pinned by the contract tests.

Changed-line coverage: 100% (33 lines). Mutation: 24/25 killed, 1 timeout (the ConfigureAwait(true) mutant, caught by the blocking-caller test), 0 survivors.

@Tr00d
Tr00d marked this pull request as ready for review November 25, 2026 06:43
@Tr00d
Tr00d merged commit 5e648b2 into master Nov 25, 2026
7 checks passed
@Tr00d
Tr00d deleted the feat/storage.analytics.list_analytics_buckets branch November 25, 2026 06:55
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