@supabase/storage-js 2.76.2-canary.0 → 2.76.2-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/lib/types.ts CHANGED
@@ -19,6 +19,14 @@ export interface Bucket {
19
19
  public: boolean
20
20
  }
21
21
 
22
+ export interface ListBucketOptions {
23
+ limit?: number
24
+ offset?: number
25
+ sortColumn?: 'id' | 'name' | 'created_at' | 'updated_at'
26
+ sortOrder?: 'asc' | 'desc'
27
+ search?: string
28
+ }
29
+
22
30
  /**
23
31
  * Represents an Analytics Bucket using Apache Iceberg table format.
24
32
  * Analytics buckets are optimized for analytical queries and data processing.
@@ -43,6 +51,7 @@ export interface FileObject {
43
51
  id: string
44
52
  updated_at: string
45
53
  created_at: string
54
+ /** @deprecated */
46
55
  last_accessed_at: string
47
56
  metadata: Record<string, any>
48
57
  buckets: Bucket
@@ -55,6 +64,7 @@ export interface FileObjectV2 {
55
64
  bucket_id: string
56
65
  updated_at: string
57
66
  created_at: string
67
+ /** @deprecated */
58
68
  last_accessed_at: string
59
69
  size?: number
60
70
  cache_control?: string
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '2.76.2-canary.0'
7
+ export const version = '2.76.2-canary.2'
@@ -2,7 +2,7 @@ import { DEFAULT_HEADERS } from '../lib/constants'
2
2
  import { isStorageError, StorageError } from '../lib/errors'
3
3
  import { Fetch, get, post, put, remove } from '../lib/fetch'
4
4
  import { resolveFetch } from '../lib/helpers'
5
- import { Bucket, BucketType } from '../lib/types'
5
+ import { Bucket, BucketType, ListBucketOptions } from '../lib/types'
6
6
  import { StorageClientOptions } from '../StorageClient'
7
7
 
8
8
  export default class StorageBucketApi {
@@ -44,7 +44,7 @@ export default class StorageBucketApi {
44
44
  /**
45
45
  * Retrieves the details of all Storage buckets within an existing project.
46
46
  */
47
- async listBuckets(): Promise<
47
+ async listBuckets(options?: ListBucketOptions): Promise<
48
48
  | {
49
49
  data: Bucket[]
50
50
  error: null
@@ -55,7 +55,10 @@ export default class StorageBucketApi {
55
55
  }
56
56
  > {
57
57
  try {
58
- const data = await get(this.fetch, `${this.url}/bucket`, { headers: this.headers })
58
+ const queryString = this.listBucketOptionsToQueryString(options)
59
+ const data = await get(this.fetch, `${this.url}/bucket${queryString}`, {
60
+ headers: this.headers,
61
+ })
59
62
  return { data, error: null }
60
63
  } catch (error) {
61
64
  if (this.shouldThrowOnError) {
@@ -286,4 +289,26 @@ export default class StorageBucketApi {
286
289
  throw error
287
290
  }
288
291
  }
292
+
293
+ private listBucketOptionsToQueryString(options?: ListBucketOptions): string {
294
+ const params: Record<string, string> = {}
295
+ if (options) {
296
+ if ('limit' in options) {
297
+ params.limit = String(options.limit)
298
+ }
299
+ if ('offset' in options) {
300
+ params.offset = String(options.offset)
301
+ }
302
+ if (options.search) {
303
+ params.search = options.search
304
+ }
305
+ if (options.sortColumn) {
306
+ params.sortColumn = options.sortColumn
307
+ }
308
+ if (options.sortOrder) {
309
+ params.sortOrder = options.sortOrder
310
+ }
311
+ }
312
+ return Object.keys(params).length > 0 ? '?' + new URLSearchParams(params).toString() : ''
313
+ }
289
314
  }