@supabase/storage-js 2.91.1 → 2.91.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/dist/index.cjs +476 -865
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1441 -1491
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1441 -1491
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +477 -861
- package/dist/index.mjs.map +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +1 -1
- package/src/StorageClient.ts +2 -2
- package/src/index.ts +15 -2
- package/src/lib/common/BaseApiClient.ts +90 -0
- package/src/lib/common/errors.ts +144 -0
- package/src/lib/common/fetch.ts +286 -0
- package/src/lib/{helpers.ts → common/helpers.ts} +71 -17
- package/src/lib/types.ts +304 -1
- package/src/lib/version.ts +1 -1
- package/src/packages/BlobDownloadBuilder.ts +1 -1
- package/src/packages/StorageAnalyticsClient.ts +17 -68
- package/src/packages/StorageBucketApi.ts +25 -109
- package/src/packages/StorageFileApi.ts +44 -172
- package/src/{lib/vectors → packages}/StorageVectorsClient.ts +2 -2
- package/src/packages/StreamDownloadBuilder.ts +1 -1
- package/src/packages/VectorBucketApi.ts +73 -0
- package/src/packages/VectorDataApi.ts +98 -0
- package/src/{lib/vectors → packages}/VectorIndexApi.ts +21 -66
- package/src/lib/errors.ts +0 -43
- package/src/lib/fetch.ts +0 -148
- package/src/lib/index.ts +0 -5
- package/src/lib/vectors/VectorBucketApi.ts +0 -118
- package/src/lib/vectors/VectorDataApi.ts +0 -152
- package/src/lib/vectors/constants.ts +0 -5
- package/src/lib/vectors/errors.ts +0 -78
- package/src/lib/vectors/fetch.ts +0 -218
- package/src/lib/vectors/helpers.ts +0 -79
- package/src/lib/vectors/index.ts +0 -66
- package/src/lib/vectors/types.ts +0 -301
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
import { IcebergError, IcebergRestCatalog } from "iceberg-js";
|
|
2
2
|
|
|
3
|
-
//#region src/lib/errors.d.ts
|
|
3
|
+
//#region src/lib/common/errors.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Namespace type for error classes
|
|
7
|
+
* Determines the error class names and type guards
|
|
8
|
+
*/
|
|
9
|
+
type ErrorNamespace = 'storage' | 'vectors';
|
|
10
|
+
/**
|
|
11
|
+
* Base error class for all Storage errors
|
|
12
|
+
* Supports both 'storage' and 'vectors' namespaces
|
|
13
|
+
*/
|
|
4
14
|
declare class StorageError extends Error {
|
|
5
15
|
protected __isStorageError: boolean;
|
|
6
|
-
|
|
16
|
+
protected namespace: ErrorNamespace;
|
|
17
|
+
status?: number;
|
|
18
|
+
statusCode?: string;
|
|
19
|
+
constructor(message: string, namespace?: ErrorNamespace, status?: number, statusCode?: string);
|
|
7
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if an error is a StorageError
|
|
23
|
+
* @param error - The error to check
|
|
24
|
+
* @returns True if the error is a StorageError
|
|
25
|
+
*/
|
|
8
26
|
declare function isStorageError(error: unknown): error is StorageError;
|
|
27
|
+
/**
|
|
28
|
+
* API error returned from Storage service
|
|
29
|
+
* Includes HTTP status code and service-specific error code
|
|
30
|
+
*/
|
|
9
31
|
declare class StorageApiError extends StorageError {
|
|
10
32
|
status: number;
|
|
11
33
|
statusCode: string;
|
|
12
|
-
constructor(message: string, status: number, statusCode: string);
|
|
34
|
+
constructor(message: string, status: number, statusCode: string, namespace?: ErrorNamespace);
|
|
13
35
|
toJSON(): {
|
|
14
36
|
name: string;
|
|
15
37
|
message: string;
|
|
@@ -17,10 +39,129 @@ declare class StorageApiError extends StorageError {
|
|
|
17
39
|
statusCode: string;
|
|
18
40
|
};
|
|
19
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Unknown error that doesn't match expected error patterns
|
|
44
|
+
* Wraps the original error for debugging
|
|
45
|
+
*/
|
|
20
46
|
declare class StorageUnknownError extends StorageError {
|
|
21
47
|
originalError: unknown;
|
|
48
|
+
constructor(message: string, originalError: unknown, namespace?: ErrorNamespace);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Use StorageError with namespace='vectors' instead
|
|
52
|
+
* Alias for backward compatibility with existing vector storage code
|
|
53
|
+
*/
|
|
54
|
+
declare class StorageVectorsError extends StorageError {
|
|
55
|
+
constructor(message: string);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Type guard to check if an error is a StorageVectorsError
|
|
59
|
+
* @param error - The error to check
|
|
60
|
+
* @returns True if the error is a StorageVectorsError
|
|
61
|
+
*/
|
|
62
|
+
declare function isStorageVectorsError(error: unknown): error is StorageVectorsError;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated Use StorageApiError with namespace='vectors' instead
|
|
65
|
+
* Alias for backward compatibility with existing vector storage code
|
|
66
|
+
*/
|
|
67
|
+
declare class StorageVectorsApiError extends StorageApiError {
|
|
68
|
+
constructor(message: string, status: number, statusCode: string);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated Use StorageUnknownError with namespace='vectors' instead
|
|
72
|
+
* Alias for backward compatibility with existing vector storage code
|
|
73
|
+
*/
|
|
74
|
+
declare class StorageVectorsUnknownError extends StorageUnknownError {
|
|
22
75
|
constructor(message: string, originalError: unknown);
|
|
23
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Error codes specific to S3 Vectors API
|
|
79
|
+
* Maps AWS service errors to application-friendly error codes
|
|
80
|
+
*/
|
|
81
|
+
declare enum StorageVectorsErrorCode {
|
|
82
|
+
/** Internal server fault (HTTP 500) */
|
|
83
|
+
InternalError = "InternalError",
|
|
84
|
+
/** Resource already exists / conflict (HTTP 409) */
|
|
85
|
+
S3VectorConflictException = "S3VectorConflictException",
|
|
86
|
+
/** Resource not found (HTTP 404) */
|
|
87
|
+
S3VectorNotFoundException = "S3VectorNotFoundException",
|
|
88
|
+
/** Delete bucket while not empty (HTTP 400) */
|
|
89
|
+
S3VectorBucketNotEmpty = "S3VectorBucketNotEmpty",
|
|
90
|
+
/** Exceeds bucket quota/limit (HTTP 400) */
|
|
91
|
+
S3VectorMaxBucketsExceeded = "S3VectorMaxBucketsExceeded",
|
|
92
|
+
/** Exceeds index quota/limit (HTTP 400) */
|
|
93
|
+
S3VectorMaxIndexesExceeded = "S3VectorMaxIndexesExceeded",
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/lib/common/fetch.d.ts
|
|
97
|
+
type Fetch = typeof fetch;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/lib/common/BaseApiClient.d.ts
|
|
100
|
+
/**
|
|
101
|
+
* @ignore
|
|
102
|
+
* Base API client class for all Storage API classes
|
|
103
|
+
* Provides common infrastructure for error handling and configuration
|
|
104
|
+
*
|
|
105
|
+
* @typeParam TError - The error type (StorageError or subclass)
|
|
106
|
+
*/
|
|
107
|
+
declare abstract class BaseApiClient<TError extends StorageError = StorageError> {
|
|
108
|
+
protected url: string;
|
|
109
|
+
protected headers: {
|
|
110
|
+
[key: string]: string;
|
|
111
|
+
};
|
|
112
|
+
protected fetch: Fetch;
|
|
113
|
+
protected shouldThrowOnError: boolean;
|
|
114
|
+
protected namespace: ErrorNamespace;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a new BaseApiClient instance
|
|
117
|
+
* @param url - Base URL for API requests
|
|
118
|
+
* @param headers - Default headers for API requests
|
|
119
|
+
* @param fetch - Optional custom fetch implementation
|
|
120
|
+
* @param namespace - Error namespace ('storage' or 'vectors')
|
|
121
|
+
*/
|
|
122
|
+
constructor(url: string, headers?: {
|
|
123
|
+
[key: string]: string;
|
|
124
|
+
}, fetch?: Fetch, namespace?: ErrorNamespace);
|
|
125
|
+
/**
|
|
126
|
+
* Enable throwing errors instead of returning them.
|
|
127
|
+
* When enabled, errors are thrown instead of returned in { data, error } format.
|
|
128
|
+
*
|
|
129
|
+
* @returns this - For method chaining
|
|
130
|
+
*/
|
|
131
|
+
throwOnError(): this;
|
|
132
|
+
/**
|
|
133
|
+
* Handles API operation with standardized error handling
|
|
134
|
+
* Eliminates repetitive try-catch blocks across all API methods
|
|
135
|
+
*
|
|
136
|
+
* This wrapper:
|
|
137
|
+
* 1. Executes the operation
|
|
138
|
+
* 2. Returns { data, error: null } on success
|
|
139
|
+
* 3. Returns { data: null, error } on failure (if shouldThrowOnError is false)
|
|
140
|
+
* 4. Throws error on failure (if shouldThrowOnError is true)
|
|
141
|
+
*
|
|
142
|
+
* @typeParam T - The expected data type from the operation
|
|
143
|
+
* @param operation - Async function that performs the API call
|
|
144
|
+
* @returns Promise with { data, error } tuple
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* async listBuckets() {
|
|
149
|
+
* return this.handleOperation(async () => {
|
|
150
|
+
* return await get(this.fetch, `${this.url}/bucket`, {
|
|
151
|
+
* headers: this.headers,
|
|
152
|
+
* })
|
|
153
|
+
* })
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
protected handleOperation<T>(operation: () => Promise<T>): Promise<{
|
|
158
|
+
data: T;
|
|
159
|
+
error: null;
|
|
160
|
+
} | {
|
|
161
|
+
data: null;
|
|
162
|
+
error: TError;
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
24
165
|
//#endregion
|
|
25
166
|
//#region src/lib/types.d.ts
|
|
26
167
|
/**
|
|
@@ -244,1367 +385,25 @@ type DownloadResult<T> = {
|
|
|
244
385
|
data: null;
|
|
245
386
|
error: StorageError;
|
|
246
387
|
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
constructor(downloadFn: () => Promise<Response>, shouldThrowOnError: boolean);
|
|
256
|
-
then<TResult1 = DownloadResult<ReadableStream>, TResult2 = never>(onfulfilled?: ((value: DownloadResult<ReadableStream>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
257
|
-
private execute;
|
|
388
|
+
/**
|
|
389
|
+
* Configuration for encryption at rest
|
|
390
|
+
* @property kmsKeyArn - ARN of the KMS key used for encryption
|
|
391
|
+
* @property sseType - Server-side encryption type (e.g., 'KMS')
|
|
392
|
+
*/
|
|
393
|
+
interface EncryptionConfiguration {
|
|
394
|
+
kmsKeyArn?: string;
|
|
395
|
+
sseType?: string;
|
|
258
396
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<DownloadResult<Blob> | TResult>;
|
|
270
|
-
finally(onfinally?: (() => void) | null): Promise<DownloadResult<Blob>>;
|
|
271
|
-
private getPromise;
|
|
272
|
-
private execute;
|
|
273
|
-
}
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/packages/StorageFileApi.d.ts
|
|
276
|
-
type FileBody = ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string;
|
|
277
|
-
declare class StorageFileApi {
|
|
278
|
-
protected url: string;
|
|
279
|
-
protected headers: {
|
|
280
|
-
[key: string]: string;
|
|
281
|
-
};
|
|
282
|
-
protected bucketId?: string;
|
|
283
|
-
protected fetch: Fetch$1;
|
|
284
|
-
protected shouldThrowOnError: boolean;
|
|
285
|
-
constructor(url: string, headers?: {
|
|
286
|
-
[key: string]: string;
|
|
287
|
-
}, bucketId?: string, fetch?: Fetch$1);
|
|
288
|
-
/**
|
|
289
|
-
* Enable throwing errors instead of returning them.
|
|
290
|
-
*
|
|
291
|
-
* @category File Buckets
|
|
292
|
-
*/
|
|
293
|
-
throwOnError(): this;
|
|
294
|
-
/**
|
|
295
|
-
* Uploads a file to an existing bucket or replaces an existing file at the specified path with a new one.
|
|
296
|
-
*
|
|
297
|
-
* @param method HTTP method.
|
|
298
|
-
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
299
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
300
|
-
*/
|
|
301
|
-
private uploadOrUpdate;
|
|
302
|
-
/**
|
|
303
|
-
* Uploads a file to an existing bucket.
|
|
304
|
-
*
|
|
305
|
-
* @category File Buckets
|
|
306
|
-
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
307
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
308
|
-
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
309
|
-
* @returns Promise with response containing file path, id, and fullPath or error
|
|
310
|
-
*
|
|
311
|
-
* @example Upload file
|
|
312
|
-
* ```js
|
|
313
|
-
* const avatarFile = event.target.files[0]
|
|
314
|
-
* const { data, error } = await supabase
|
|
315
|
-
* .storage
|
|
316
|
-
* .from('avatars')
|
|
317
|
-
* .upload('public/avatar1.png', avatarFile, {
|
|
318
|
-
* cacheControl: '3600',
|
|
319
|
-
* upsert: false
|
|
320
|
-
* })
|
|
321
|
-
* ```
|
|
322
|
-
*
|
|
323
|
-
* Response:
|
|
324
|
-
* ```json
|
|
325
|
-
* {
|
|
326
|
-
* "data": {
|
|
327
|
-
* "path": "public/avatar1.png",
|
|
328
|
-
* "fullPath": "avatars/public/avatar1.png"
|
|
329
|
-
* },
|
|
330
|
-
* "error": null
|
|
331
|
-
* }
|
|
332
|
-
* ```
|
|
333
|
-
*
|
|
334
|
-
* @example Upload file using `ArrayBuffer` from base64 file data
|
|
335
|
-
* ```js
|
|
336
|
-
* import { decode } from 'base64-arraybuffer'
|
|
337
|
-
*
|
|
338
|
-
* const { data, error } = await supabase
|
|
339
|
-
* .storage
|
|
340
|
-
* .from('avatars')
|
|
341
|
-
* .upload('public/avatar1.png', decode('base64FileData'), {
|
|
342
|
-
* contentType: 'image/png'
|
|
343
|
-
* })
|
|
344
|
-
* ```
|
|
345
|
-
*/
|
|
346
|
-
upload(path: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
347
|
-
data: {
|
|
348
|
-
id: string;
|
|
349
|
-
path: string;
|
|
350
|
-
fullPath: string;
|
|
351
|
-
};
|
|
352
|
-
error: null;
|
|
353
|
-
} | {
|
|
354
|
-
data: null;
|
|
355
|
-
error: StorageError;
|
|
356
|
-
}>;
|
|
357
|
-
/**
|
|
358
|
-
* Upload a file with a token generated from `createSignedUploadUrl`.
|
|
359
|
-
*
|
|
360
|
-
* @category File Buckets
|
|
361
|
-
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
362
|
-
* @param token The token generated from `createSignedUploadUrl`
|
|
363
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
364
|
-
* @param fileOptions HTTP headers (cacheControl, contentType, etc.).
|
|
365
|
-
* **Note:** The `upsert` option has no effect here. To enable upsert behavior,
|
|
366
|
-
* pass `{ upsert: true }` when calling `createSignedUploadUrl()` instead.
|
|
367
|
-
* @returns Promise with response containing file path and fullPath or error
|
|
368
|
-
*
|
|
369
|
-
* @example Upload to a signed URL
|
|
370
|
-
* ```js
|
|
371
|
-
* const { data, error } = await supabase
|
|
372
|
-
* .storage
|
|
373
|
-
* .from('avatars')
|
|
374
|
-
* .uploadToSignedUrl('folder/cat.jpg', 'token-from-createSignedUploadUrl', file)
|
|
375
|
-
* ```
|
|
376
|
-
*
|
|
377
|
-
* Response:
|
|
378
|
-
* ```json
|
|
379
|
-
* {
|
|
380
|
-
* "data": {
|
|
381
|
-
* "path": "folder/cat.jpg",
|
|
382
|
-
* "fullPath": "avatars/folder/cat.jpg"
|
|
383
|
-
* },
|
|
384
|
-
* "error": null
|
|
385
|
-
* }
|
|
386
|
-
* ```
|
|
387
|
-
*/
|
|
388
|
-
uploadToSignedUrl(path: string, token: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
389
|
-
data: {
|
|
390
|
-
path: string;
|
|
391
|
-
fullPath: any;
|
|
392
|
-
};
|
|
393
|
-
error: null;
|
|
394
|
-
} | {
|
|
395
|
-
data: null;
|
|
396
|
-
error: StorageError;
|
|
397
|
-
}>;
|
|
398
|
-
/**
|
|
399
|
-
* Creates a signed upload URL.
|
|
400
|
-
* Signed upload URLs can be used to upload files to the bucket without further authentication.
|
|
401
|
-
* They are valid for 2 hours.
|
|
402
|
-
*
|
|
403
|
-
* @category File Buckets
|
|
404
|
-
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
405
|
-
* @param options.upsert If set to true, allows the file to be overwritten if it already exists.
|
|
406
|
-
* @returns Promise with response containing signed upload URL, token, and path or error
|
|
407
|
-
*
|
|
408
|
-
* @example Create Signed Upload URL
|
|
409
|
-
* ```js
|
|
410
|
-
* const { data, error } = await supabase
|
|
411
|
-
* .storage
|
|
412
|
-
* .from('avatars')
|
|
413
|
-
* .createSignedUploadUrl('folder/cat.jpg')
|
|
414
|
-
* ```
|
|
415
|
-
*
|
|
416
|
-
* Response:
|
|
417
|
-
* ```json
|
|
418
|
-
* {
|
|
419
|
-
* "data": {
|
|
420
|
-
* "signedUrl": "https://example.supabase.co/storage/v1/object/upload/sign/avatars/folder/cat.jpg?token=<TOKEN>",
|
|
421
|
-
* "path": "folder/cat.jpg",
|
|
422
|
-
* "token": "<TOKEN>"
|
|
423
|
-
* },
|
|
424
|
-
* "error": null
|
|
425
|
-
* }
|
|
426
|
-
* ```
|
|
427
|
-
*/
|
|
428
|
-
createSignedUploadUrl(path: string, options?: {
|
|
429
|
-
upsert: boolean;
|
|
430
|
-
}): Promise<{
|
|
431
|
-
data: {
|
|
432
|
-
signedUrl: string;
|
|
433
|
-
token: string;
|
|
434
|
-
path: string;
|
|
435
|
-
};
|
|
436
|
-
error: null;
|
|
437
|
-
} | {
|
|
438
|
-
data: null;
|
|
439
|
-
error: StorageError;
|
|
440
|
-
}>;
|
|
441
|
-
/**
|
|
442
|
-
* Replaces an existing file at the specified path with a new one.
|
|
443
|
-
*
|
|
444
|
-
* @category File Buckets
|
|
445
|
-
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.
|
|
446
|
-
* @param fileBody The body of the file to be stored in the bucket.
|
|
447
|
-
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
448
|
-
* @returns Promise with response containing file path, id, and fullPath or error
|
|
449
|
-
*
|
|
450
|
-
* @example Update file
|
|
451
|
-
* ```js
|
|
452
|
-
* const avatarFile = event.target.files[0]
|
|
453
|
-
* const { data, error } = await supabase
|
|
454
|
-
* .storage
|
|
455
|
-
* .from('avatars')
|
|
456
|
-
* .update('public/avatar1.png', avatarFile, {
|
|
457
|
-
* cacheControl: '3600',
|
|
458
|
-
* upsert: true
|
|
459
|
-
* })
|
|
460
|
-
* ```
|
|
461
|
-
*
|
|
462
|
-
* Response:
|
|
463
|
-
* ```json
|
|
464
|
-
* {
|
|
465
|
-
* "data": {
|
|
466
|
-
* "path": "public/avatar1.png",
|
|
467
|
-
* "fullPath": "avatars/public/avatar1.png"
|
|
468
|
-
* },
|
|
469
|
-
* "error": null
|
|
470
|
-
* }
|
|
471
|
-
* ```
|
|
472
|
-
*
|
|
473
|
-
* @example Update file using `ArrayBuffer` from base64 file data
|
|
474
|
-
* ```js
|
|
475
|
-
* import {decode} from 'base64-arraybuffer'
|
|
476
|
-
*
|
|
477
|
-
* const { data, error } = await supabase
|
|
478
|
-
* .storage
|
|
479
|
-
* .from('avatars')
|
|
480
|
-
* .update('public/avatar1.png', decode('base64FileData'), {
|
|
481
|
-
* contentType: 'image/png'
|
|
482
|
-
* })
|
|
483
|
-
* ```
|
|
484
|
-
*/
|
|
485
|
-
update(path: string, fileBody: ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string, fileOptions?: FileOptions): Promise<{
|
|
486
|
-
data: {
|
|
487
|
-
id: string;
|
|
488
|
-
path: string;
|
|
489
|
-
fullPath: string;
|
|
490
|
-
};
|
|
491
|
-
error: null;
|
|
492
|
-
} | {
|
|
493
|
-
data: null;
|
|
494
|
-
error: StorageError;
|
|
495
|
-
}>;
|
|
496
|
-
/**
|
|
497
|
-
* Moves an existing file to a new path in the same bucket.
|
|
498
|
-
*
|
|
499
|
-
* @category File Buckets
|
|
500
|
-
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
501
|
-
* @param toPath The new file path, including the new file name. For example `folder/image-new.png`.
|
|
502
|
-
* @param options The destination options.
|
|
503
|
-
* @returns Promise with response containing success message or error
|
|
504
|
-
*
|
|
505
|
-
* @example Move file
|
|
506
|
-
* ```js
|
|
507
|
-
* const { data, error } = await supabase
|
|
508
|
-
* .storage
|
|
509
|
-
* .from('avatars')
|
|
510
|
-
* .move('public/avatar1.png', 'private/avatar2.png')
|
|
511
|
-
* ```
|
|
512
|
-
*
|
|
513
|
-
* Response:
|
|
514
|
-
* ```json
|
|
515
|
-
* {
|
|
516
|
-
* "data": {
|
|
517
|
-
* "message": "Successfully moved"
|
|
518
|
-
* },
|
|
519
|
-
* "error": null
|
|
520
|
-
* }
|
|
521
|
-
* ```
|
|
522
|
-
*/
|
|
523
|
-
move(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
524
|
-
data: {
|
|
525
|
-
message: string;
|
|
526
|
-
};
|
|
527
|
-
error: null;
|
|
528
|
-
} | {
|
|
529
|
-
data: null;
|
|
530
|
-
error: StorageError;
|
|
531
|
-
}>;
|
|
532
|
-
/**
|
|
533
|
-
* Copies an existing file to a new path in the same bucket.
|
|
534
|
-
*
|
|
535
|
-
* @category File Buckets
|
|
536
|
-
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
537
|
-
* @param toPath The new file path, including the new file name. For example `folder/image-copy.png`.
|
|
538
|
-
* @param options The destination options.
|
|
539
|
-
* @returns Promise with response containing copied file path or error
|
|
540
|
-
*
|
|
541
|
-
* @example Copy file
|
|
542
|
-
* ```js
|
|
543
|
-
* const { data, error } = await supabase
|
|
544
|
-
* .storage
|
|
545
|
-
* .from('avatars')
|
|
546
|
-
* .copy('public/avatar1.png', 'private/avatar2.png')
|
|
547
|
-
* ```
|
|
548
|
-
*
|
|
549
|
-
* Response:
|
|
550
|
-
* ```json
|
|
551
|
-
* {
|
|
552
|
-
* "data": {
|
|
553
|
-
* "path": "avatars/private/avatar2.png"
|
|
554
|
-
* },
|
|
555
|
-
* "error": null
|
|
556
|
-
* }
|
|
557
|
-
* ```
|
|
558
|
-
*/
|
|
559
|
-
copy(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
560
|
-
data: {
|
|
561
|
-
path: string;
|
|
562
|
-
};
|
|
563
|
-
error: null;
|
|
564
|
-
} | {
|
|
565
|
-
data: null;
|
|
566
|
-
error: StorageError;
|
|
567
|
-
}>;
|
|
568
|
-
/**
|
|
569
|
-
* Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
|
|
570
|
-
*
|
|
571
|
-
* @category File Buckets
|
|
572
|
-
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
573
|
-
* @param expiresIn The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
|
|
574
|
-
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
575
|
-
* @param options.transform Transform the asset before serving it to the client.
|
|
576
|
-
* @returns Promise with response containing signed URL or error
|
|
577
|
-
*
|
|
578
|
-
* @example Create Signed URL
|
|
579
|
-
* ```js
|
|
580
|
-
* const { data, error } = await supabase
|
|
581
|
-
* .storage
|
|
582
|
-
* .from('avatars')
|
|
583
|
-
* .createSignedUrl('folder/avatar1.png', 60)
|
|
584
|
-
* ```
|
|
585
|
-
*
|
|
586
|
-
* Response:
|
|
587
|
-
* ```json
|
|
588
|
-
* {
|
|
589
|
-
* "data": {
|
|
590
|
-
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
591
|
-
* },
|
|
592
|
-
* "error": null
|
|
593
|
-
* }
|
|
594
|
-
* ```
|
|
595
|
-
*
|
|
596
|
-
* @example Create a signed URL for an asset with transformations
|
|
597
|
-
* ```js
|
|
598
|
-
* const { data } = await supabase
|
|
599
|
-
* .storage
|
|
600
|
-
* .from('avatars')
|
|
601
|
-
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
602
|
-
* transform: {
|
|
603
|
-
* width: 100,
|
|
604
|
-
* height: 100,
|
|
605
|
-
* }
|
|
606
|
-
* })
|
|
607
|
-
* ```
|
|
608
|
-
*
|
|
609
|
-
* @example Create a signed URL which triggers the download of the asset
|
|
610
|
-
* ```js
|
|
611
|
-
* const { data } = await supabase
|
|
612
|
-
* .storage
|
|
613
|
-
* .from('avatars')
|
|
614
|
-
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
615
|
-
* download: true,
|
|
616
|
-
* })
|
|
617
|
-
* ```
|
|
618
|
-
*/
|
|
619
|
-
createSignedUrl(path: string, expiresIn: number, options?: {
|
|
620
|
-
download?: string | boolean;
|
|
621
|
-
transform?: TransformOptions;
|
|
622
|
-
}): Promise<{
|
|
623
|
-
data: {
|
|
624
|
-
signedUrl: string;
|
|
625
|
-
};
|
|
626
|
-
error: null;
|
|
627
|
-
} | {
|
|
628
|
-
data: null;
|
|
629
|
-
error: StorageError;
|
|
630
|
-
}>;
|
|
631
|
-
/**
|
|
632
|
-
* Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.
|
|
633
|
-
*
|
|
634
|
-
* @category File Buckets
|
|
635
|
-
* @param paths The file paths to be downloaded, including the current file names. For example `['folder/image.png', 'folder2/image2.png']`.
|
|
636
|
-
* @param expiresIn The number of seconds until the signed URLs expire. For example, `60` for URLs which are valid for one minute.
|
|
637
|
-
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
638
|
-
* @returns Promise with response containing array of objects with signedUrl, path, and error or error
|
|
639
|
-
*
|
|
640
|
-
* @example Create Signed URLs
|
|
641
|
-
* ```js
|
|
642
|
-
* const { data, error } = await supabase
|
|
643
|
-
* .storage
|
|
644
|
-
* .from('avatars')
|
|
645
|
-
* .createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60)
|
|
646
|
-
* ```
|
|
647
|
-
*
|
|
648
|
-
* Response:
|
|
649
|
-
* ```json
|
|
650
|
-
* {
|
|
651
|
-
* "data": [
|
|
652
|
-
* {
|
|
653
|
-
* "error": null,
|
|
654
|
-
* "path": "folder/avatar1.png",
|
|
655
|
-
* "signedURL": "/object/sign/avatars/folder/avatar1.png?token=<TOKEN>",
|
|
656
|
-
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
657
|
-
* },
|
|
658
|
-
* {
|
|
659
|
-
* "error": null,
|
|
660
|
-
* "path": "folder/avatar2.png",
|
|
661
|
-
* "signedURL": "/object/sign/avatars/folder/avatar2.png?token=<TOKEN>",
|
|
662
|
-
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar2.png?token=<TOKEN>"
|
|
663
|
-
* }
|
|
664
|
-
* ],
|
|
665
|
-
* "error": null
|
|
666
|
-
* }
|
|
667
|
-
* ```
|
|
668
|
-
*/
|
|
669
|
-
createSignedUrls(paths: string[], expiresIn: number, options?: {
|
|
670
|
-
download: string | boolean;
|
|
671
|
-
}): Promise<{
|
|
672
|
-
data: {
|
|
673
|
-
error: string | null;
|
|
674
|
-
path: string | null;
|
|
675
|
-
signedUrl: string;
|
|
676
|
-
}[];
|
|
677
|
-
error: null;
|
|
678
|
-
} | {
|
|
679
|
-
data: null;
|
|
680
|
-
error: StorageError;
|
|
681
|
-
}>;
|
|
682
|
-
/**
|
|
683
|
-
* Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.
|
|
684
|
-
*
|
|
685
|
-
* @category File Buckets
|
|
686
|
-
* @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
|
|
687
|
-
* @param options.transform Transform the asset before serving it to the client.
|
|
688
|
-
* @returns BlobDownloadBuilder instance for downloading the file
|
|
689
|
-
*
|
|
690
|
-
* @example Download file
|
|
691
|
-
* ```js
|
|
692
|
-
* const { data, error } = await supabase
|
|
693
|
-
* .storage
|
|
694
|
-
* .from('avatars')
|
|
695
|
-
* .download('folder/avatar1.png')
|
|
696
|
-
* ```
|
|
697
|
-
*
|
|
698
|
-
* Response:
|
|
699
|
-
* ```json
|
|
700
|
-
* {
|
|
701
|
-
* "data": <BLOB>,
|
|
702
|
-
* "error": null
|
|
703
|
-
* }
|
|
704
|
-
* ```
|
|
705
|
-
*
|
|
706
|
-
* @example Download file with transformations
|
|
707
|
-
* ```js
|
|
708
|
-
* const { data, error } = await supabase
|
|
709
|
-
* .storage
|
|
710
|
-
* .from('avatars')
|
|
711
|
-
* .download('folder/avatar1.png', {
|
|
712
|
-
* transform: {
|
|
713
|
-
* width: 100,
|
|
714
|
-
* height: 100,
|
|
715
|
-
* quality: 80
|
|
716
|
-
* }
|
|
717
|
-
* })
|
|
718
|
-
* ```
|
|
719
|
-
*/
|
|
720
|
-
download<Options extends {
|
|
721
|
-
transform?: TransformOptions;
|
|
722
|
-
}>(path: string, options?: Options): BlobDownloadBuilder;
|
|
723
|
-
/**
|
|
724
|
-
* Retrieves the details of an existing file.
|
|
725
|
-
*
|
|
726
|
-
* @category File Buckets
|
|
727
|
-
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
728
|
-
* @returns Promise with response containing file metadata or error
|
|
729
|
-
*
|
|
730
|
-
* @example Get file info
|
|
731
|
-
* ```js
|
|
732
|
-
* const { data, error } = await supabase
|
|
733
|
-
* .storage
|
|
734
|
-
* .from('avatars')
|
|
735
|
-
* .info('folder/avatar1.png')
|
|
736
|
-
* ```
|
|
737
|
-
*/
|
|
738
|
-
info(path: string): Promise<{
|
|
739
|
-
data: Camelize<FileObjectV2>;
|
|
740
|
-
error: null;
|
|
741
|
-
} | {
|
|
742
|
-
data: null;
|
|
743
|
-
error: StorageError;
|
|
744
|
-
}>;
|
|
745
|
-
/**
|
|
746
|
-
* Checks the existence of a file.
|
|
747
|
-
*
|
|
748
|
-
* @category File Buckets
|
|
749
|
-
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
750
|
-
* @returns Promise with response containing boolean indicating file existence or error
|
|
751
|
-
*
|
|
752
|
-
* @example Check file existence
|
|
753
|
-
* ```js
|
|
754
|
-
* const { data, error } = await supabase
|
|
755
|
-
* .storage
|
|
756
|
-
* .from('avatars')
|
|
757
|
-
* .exists('folder/avatar1.png')
|
|
758
|
-
* ```
|
|
759
|
-
*/
|
|
760
|
-
exists(path: string): Promise<{
|
|
761
|
-
data: boolean;
|
|
762
|
-
error: null;
|
|
763
|
-
} | {
|
|
764
|
-
data: boolean;
|
|
765
|
-
error: StorageError;
|
|
766
|
-
}>;
|
|
767
|
-
/**
|
|
768
|
-
* A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.
|
|
769
|
-
* This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
|
|
770
|
-
*
|
|
771
|
-
* @category File Buckets
|
|
772
|
-
* @param path The path and name of the file to generate the public URL for. For example `folder/image.png`.
|
|
773
|
-
* @param options.download Triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
774
|
-
* @param options.transform Transform the asset before serving it to the client.
|
|
775
|
-
* @returns Object with public URL
|
|
776
|
-
*
|
|
777
|
-
* @example Returns the URL for an asset in a public bucket
|
|
778
|
-
* ```js
|
|
779
|
-
* const { data } = supabase
|
|
780
|
-
* .storage
|
|
781
|
-
* .from('public-bucket')
|
|
782
|
-
* .getPublicUrl('folder/avatar1.png')
|
|
783
|
-
* ```
|
|
784
|
-
*
|
|
785
|
-
* Response:
|
|
786
|
-
* ```json
|
|
787
|
-
* {
|
|
788
|
-
* "data": {
|
|
789
|
-
* "publicUrl": "https://example.supabase.co/storage/v1/object/public/public-bucket/folder/avatar1.png"
|
|
790
|
-
* }
|
|
791
|
-
* }
|
|
792
|
-
* ```
|
|
793
|
-
*
|
|
794
|
-
* @example Returns the URL for an asset in a public bucket with transformations
|
|
795
|
-
* ```js
|
|
796
|
-
* const { data } = supabase
|
|
797
|
-
* .storage
|
|
798
|
-
* .from('public-bucket')
|
|
799
|
-
* .getPublicUrl('folder/avatar1.png', {
|
|
800
|
-
* transform: {
|
|
801
|
-
* width: 100,
|
|
802
|
-
* height: 100,
|
|
803
|
-
* }
|
|
804
|
-
* })
|
|
805
|
-
* ```
|
|
806
|
-
*
|
|
807
|
-
* @example Returns the URL which triggers the download of an asset in a public bucket
|
|
808
|
-
* ```js
|
|
809
|
-
* const { data } = supabase
|
|
810
|
-
* .storage
|
|
811
|
-
* .from('public-bucket')
|
|
812
|
-
* .getPublicUrl('folder/avatar1.png', {
|
|
813
|
-
* download: true,
|
|
814
|
-
* })
|
|
815
|
-
* ```
|
|
816
|
-
*/
|
|
817
|
-
getPublicUrl(path: string, options?: {
|
|
818
|
-
download?: string | boolean;
|
|
819
|
-
transform?: TransformOptions;
|
|
820
|
-
}): {
|
|
821
|
-
data: {
|
|
822
|
-
publicUrl: string;
|
|
823
|
-
};
|
|
824
|
-
};
|
|
825
|
-
/**
|
|
826
|
-
* Deletes files within the same bucket
|
|
827
|
-
*
|
|
828
|
-
* @category File Buckets
|
|
829
|
-
* @param paths An array of files to delete, including the path and file name. For example [`'folder/image.png'`].
|
|
830
|
-
* @returns Promise with response containing array of deleted file objects or error
|
|
831
|
-
*
|
|
832
|
-
* @example Delete file
|
|
833
|
-
* ```js
|
|
834
|
-
* const { data, error } = await supabase
|
|
835
|
-
* .storage
|
|
836
|
-
* .from('avatars')
|
|
837
|
-
* .remove(['folder/avatar1.png'])
|
|
838
|
-
* ```
|
|
839
|
-
*
|
|
840
|
-
* Response:
|
|
841
|
-
* ```json
|
|
842
|
-
* {
|
|
843
|
-
* "data": [],
|
|
844
|
-
* "error": null
|
|
845
|
-
* }
|
|
846
|
-
* ```
|
|
847
|
-
*/
|
|
848
|
-
remove(paths: string[]): Promise<{
|
|
849
|
-
data: FileObject[];
|
|
850
|
-
error: null;
|
|
851
|
-
} | {
|
|
852
|
-
data: null;
|
|
853
|
-
error: StorageError;
|
|
854
|
-
}>;
|
|
855
|
-
/**
|
|
856
|
-
* Get file metadata
|
|
857
|
-
* @param id the file id to retrieve metadata
|
|
858
|
-
*/
|
|
859
|
-
/**
|
|
860
|
-
* Update file metadata
|
|
861
|
-
* @param id the file id to update metadata
|
|
862
|
-
* @param meta the new file metadata
|
|
863
|
-
*/
|
|
864
|
-
/**
|
|
865
|
-
* Lists all the files and folders within a path of the bucket.
|
|
866
|
-
*
|
|
867
|
-
* @category File Buckets
|
|
868
|
-
* @param path The folder path.
|
|
869
|
-
* @param options Search options including limit (defaults to 100), offset, sortBy, and search
|
|
870
|
-
* @param parameters Optional fetch parameters including signal for cancellation
|
|
871
|
-
* @returns Promise with response containing array of files or error
|
|
872
|
-
*
|
|
873
|
-
* @example List files in a bucket
|
|
874
|
-
* ```js
|
|
875
|
-
* const { data, error } = await supabase
|
|
876
|
-
* .storage
|
|
877
|
-
* .from('avatars')
|
|
878
|
-
* .list('folder', {
|
|
879
|
-
* limit: 100,
|
|
880
|
-
* offset: 0,
|
|
881
|
-
* sortBy: { column: 'name', order: 'asc' },
|
|
882
|
-
* })
|
|
883
|
-
* ```
|
|
884
|
-
*
|
|
885
|
-
* Response:
|
|
886
|
-
* ```json
|
|
887
|
-
* {
|
|
888
|
-
* "data": [
|
|
889
|
-
* {
|
|
890
|
-
* "name": "avatar1.png",
|
|
891
|
-
* "id": "e668cf7f-821b-4a2f-9dce-7dfa5dd1cfd2",
|
|
892
|
-
* "updated_at": "2024-05-22T23:06:05.580Z",
|
|
893
|
-
* "created_at": "2024-05-22T23:04:34.443Z",
|
|
894
|
-
* "last_accessed_at": "2024-05-22T23:04:34.443Z",
|
|
895
|
-
* "metadata": {
|
|
896
|
-
* "eTag": "\"c5e8c553235d9af30ef4f6e280790b92\"",
|
|
897
|
-
* "size": 32175,
|
|
898
|
-
* "mimetype": "image/png",
|
|
899
|
-
* "cacheControl": "max-age=3600",
|
|
900
|
-
* "lastModified": "2024-05-22T23:06:05.574Z",
|
|
901
|
-
* "contentLength": 32175,
|
|
902
|
-
* "httpStatusCode": 200
|
|
903
|
-
* }
|
|
904
|
-
* }
|
|
905
|
-
* ],
|
|
906
|
-
* "error": null
|
|
907
|
-
* }
|
|
908
|
-
* ```
|
|
909
|
-
*
|
|
910
|
-
* @example Search files in a bucket
|
|
911
|
-
* ```js
|
|
912
|
-
* const { data, error } = await supabase
|
|
913
|
-
* .storage
|
|
914
|
-
* .from('avatars')
|
|
915
|
-
* .list('folder', {
|
|
916
|
-
* limit: 100,
|
|
917
|
-
* offset: 0,
|
|
918
|
-
* sortBy: { column: 'name', order: 'asc' },
|
|
919
|
-
* search: 'jon'
|
|
920
|
-
* })
|
|
921
|
-
* ```
|
|
922
|
-
*/
|
|
923
|
-
list(path?: string, options?: SearchOptions, parameters?: FetchParameters): Promise<{
|
|
924
|
-
data: FileObject[];
|
|
925
|
-
error: null;
|
|
926
|
-
} | {
|
|
927
|
-
data: null;
|
|
928
|
-
error: StorageError;
|
|
929
|
-
}>;
|
|
930
|
-
/**
|
|
931
|
-
* @experimental this method signature might change in the future
|
|
932
|
-
*
|
|
933
|
-
* @category File Buckets
|
|
934
|
-
* @param options search options
|
|
935
|
-
* @param parameters
|
|
936
|
-
*/
|
|
937
|
-
listV2(options?: SearchV2Options, parameters?: FetchParameters): Promise<{
|
|
938
|
-
data: SearchV2Result;
|
|
939
|
-
error: null;
|
|
940
|
-
} | {
|
|
941
|
-
data: null;
|
|
942
|
-
error: StorageError;
|
|
943
|
-
}>;
|
|
944
|
-
protected encodeMetadata(metadata: Record<string, any>): string;
|
|
945
|
-
toBase64(data: string): string;
|
|
946
|
-
private _getFinalPath;
|
|
947
|
-
private _removeEmptyFolders;
|
|
948
|
-
private transformOptsToQueryString;
|
|
949
|
-
}
|
|
950
|
-
//#endregion
|
|
951
|
-
//#region src/packages/StorageBucketApi.d.ts
|
|
952
|
-
declare class StorageBucketApi {
|
|
953
|
-
protected url: string;
|
|
954
|
-
protected headers: {
|
|
955
|
-
[key: string]: string;
|
|
956
|
-
};
|
|
957
|
-
protected fetch: Fetch$1;
|
|
958
|
-
protected shouldThrowOnError: boolean;
|
|
959
|
-
constructor(url: string, headers?: {
|
|
960
|
-
[key: string]: string;
|
|
961
|
-
}, fetch?: Fetch$1, opts?: StorageClientOptions);
|
|
962
|
-
/**
|
|
963
|
-
* Enable throwing errors instead of returning them.
|
|
964
|
-
*
|
|
965
|
-
* @category File Buckets
|
|
966
|
-
*/
|
|
967
|
-
throwOnError(): this;
|
|
968
|
-
/**
|
|
969
|
-
* Retrieves the details of all Storage buckets within an existing project.
|
|
970
|
-
*
|
|
971
|
-
* @category File Buckets
|
|
972
|
-
* @param options Query parameters for listing buckets
|
|
973
|
-
* @param options.limit Maximum number of buckets to return
|
|
974
|
-
* @param options.offset Number of buckets to skip
|
|
975
|
-
* @param options.sortColumn Column to sort by ('id', 'name', 'created_at', 'updated_at')
|
|
976
|
-
* @param options.sortOrder Sort order ('asc' or 'desc')
|
|
977
|
-
* @param options.search Search term to filter bucket names
|
|
978
|
-
* @returns Promise with response containing array of buckets or error
|
|
979
|
-
*
|
|
980
|
-
* @example List buckets
|
|
981
|
-
* ```js
|
|
982
|
-
* const { data, error } = await supabase
|
|
983
|
-
* .storage
|
|
984
|
-
* .listBuckets()
|
|
985
|
-
* ```
|
|
986
|
-
*
|
|
987
|
-
* @example List buckets with options
|
|
988
|
-
* ```js
|
|
989
|
-
* const { data, error } = await supabase
|
|
990
|
-
* .storage
|
|
991
|
-
* .listBuckets({
|
|
992
|
-
* limit: 10,
|
|
993
|
-
* offset: 0,
|
|
994
|
-
* sortColumn: 'created_at',
|
|
995
|
-
* sortOrder: 'desc',
|
|
996
|
-
* search: 'prod'
|
|
997
|
-
* })
|
|
998
|
-
* ```
|
|
999
|
-
*/
|
|
1000
|
-
listBuckets(options?: ListBucketOptions): Promise<{
|
|
1001
|
-
data: Bucket[];
|
|
1002
|
-
error: null;
|
|
1003
|
-
} | {
|
|
1004
|
-
data: null;
|
|
1005
|
-
error: StorageError;
|
|
1006
|
-
}>;
|
|
1007
|
-
/**
|
|
1008
|
-
* Retrieves the details of an existing Storage bucket.
|
|
1009
|
-
*
|
|
1010
|
-
* @category File Buckets
|
|
1011
|
-
* @param id The unique identifier of the bucket you would like to retrieve.
|
|
1012
|
-
* @returns Promise with response containing bucket details or error
|
|
1013
|
-
*
|
|
1014
|
-
* @example Get bucket
|
|
1015
|
-
* ```js
|
|
1016
|
-
* const { data, error } = await supabase
|
|
1017
|
-
* .storage
|
|
1018
|
-
* .getBucket('avatars')
|
|
1019
|
-
* ```
|
|
1020
|
-
*
|
|
1021
|
-
* Response:
|
|
1022
|
-
* ```json
|
|
1023
|
-
* {
|
|
1024
|
-
* "data": {
|
|
1025
|
-
* "id": "avatars",
|
|
1026
|
-
* "name": "avatars",
|
|
1027
|
-
* "owner": "",
|
|
1028
|
-
* "public": false,
|
|
1029
|
-
* "file_size_limit": 1024,
|
|
1030
|
-
* "allowed_mime_types": [
|
|
1031
|
-
* "image/png"
|
|
1032
|
-
* ],
|
|
1033
|
-
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
1034
|
-
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
1035
|
-
* },
|
|
1036
|
-
* "error": null
|
|
1037
|
-
* }
|
|
1038
|
-
* ```
|
|
1039
|
-
*/
|
|
1040
|
-
getBucket(id: string): Promise<{
|
|
1041
|
-
data: Bucket;
|
|
1042
|
-
error: null;
|
|
1043
|
-
} | {
|
|
1044
|
-
data: null;
|
|
1045
|
-
error: StorageError;
|
|
1046
|
-
}>;
|
|
1047
|
-
/**
|
|
1048
|
-
* Creates a new Storage bucket
|
|
1049
|
-
*
|
|
1050
|
-
* @category File Buckets
|
|
1051
|
-
* @param id A unique identifier for the bucket you are creating.
|
|
1052
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.
|
|
1053
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
1054
|
-
* The global file size limit takes precedence over this value.
|
|
1055
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
1056
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
1057
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
1058
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
1059
|
-
* @param options.type (private-beta) specifies the bucket type. see `BucketType` for more details.
|
|
1060
|
-
* - default bucket type is `STANDARD`
|
|
1061
|
-
* @returns Promise with response containing newly created bucket name or error
|
|
1062
|
-
*
|
|
1063
|
-
* @example Create bucket
|
|
1064
|
-
* ```js
|
|
1065
|
-
* const { data, error } = await supabase
|
|
1066
|
-
* .storage
|
|
1067
|
-
* .createBucket('avatars', {
|
|
1068
|
-
* public: false,
|
|
1069
|
-
* allowedMimeTypes: ['image/png'],
|
|
1070
|
-
* fileSizeLimit: 1024
|
|
1071
|
-
* })
|
|
1072
|
-
* ```
|
|
1073
|
-
*
|
|
1074
|
-
* Response:
|
|
1075
|
-
* ```json
|
|
1076
|
-
* {
|
|
1077
|
-
* "data": {
|
|
1078
|
-
* "name": "avatars"
|
|
1079
|
-
* },
|
|
1080
|
-
* "error": null
|
|
1081
|
-
* }
|
|
1082
|
-
* ```
|
|
1083
|
-
*/
|
|
1084
|
-
createBucket(id: string, options?: {
|
|
1085
|
-
public: boolean;
|
|
1086
|
-
fileSizeLimit?: number | string | null;
|
|
1087
|
-
allowedMimeTypes?: string[] | null;
|
|
1088
|
-
type?: BucketType;
|
|
1089
|
-
}): Promise<{
|
|
1090
|
-
data: Pick<Bucket, 'name'>;
|
|
1091
|
-
error: null;
|
|
1092
|
-
} | {
|
|
1093
|
-
data: null;
|
|
1094
|
-
error: StorageError;
|
|
1095
|
-
}>;
|
|
1096
|
-
/**
|
|
1097
|
-
* Updates a Storage bucket
|
|
1098
|
-
*
|
|
1099
|
-
* @category File Buckets
|
|
1100
|
-
* @param id A unique identifier for the bucket you are updating.
|
|
1101
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations.
|
|
1102
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
1103
|
-
* The global file size limit takes precedence over this value.
|
|
1104
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
1105
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
1106
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
1107
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
1108
|
-
* @returns Promise with response containing success message or error
|
|
1109
|
-
*
|
|
1110
|
-
* @example Update bucket
|
|
1111
|
-
* ```js
|
|
1112
|
-
* const { data, error } = await supabase
|
|
1113
|
-
* .storage
|
|
1114
|
-
* .updateBucket('avatars', {
|
|
1115
|
-
* public: false,
|
|
1116
|
-
* allowedMimeTypes: ['image/png'],
|
|
1117
|
-
* fileSizeLimit: 1024
|
|
1118
|
-
* })
|
|
1119
|
-
* ```
|
|
1120
|
-
*
|
|
1121
|
-
* Response:
|
|
1122
|
-
* ```json
|
|
1123
|
-
* {
|
|
1124
|
-
* "data": {
|
|
1125
|
-
* "message": "Successfully updated"
|
|
1126
|
-
* },
|
|
1127
|
-
* "error": null
|
|
1128
|
-
* }
|
|
1129
|
-
* ```
|
|
1130
|
-
*/
|
|
1131
|
-
updateBucket(id: string, options: {
|
|
1132
|
-
public: boolean;
|
|
1133
|
-
fileSizeLimit?: number | string | null;
|
|
1134
|
-
allowedMimeTypes?: string[] | null;
|
|
1135
|
-
}): Promise<{
|
|
1136
|
-
data: {
|
|
1137
|
-
message: string;
|
|
1138
|
-
};
|
|
1139
|
-
error: null;
|
|
1140
|
-
} | {
|
|
1141
|
-
data: null;
|
|
1142
|
-
error: StorageError;
|
|
1143
|
-
}>;
|
|
1144
|
-
/**
|
|
1145
|
-
* Removes all objects inside a single bucket.
|
|
1146
|
-
*
|
|
1147
|
-
* @category File Buckets
|
|
1148
|
-
* @param id The unique identifier of the bucket you would like to empty.
|
|
1149
|
-
* @returns Promise with success message or error
|
|
1150
|
-
*
|
|
1151
|
-
* @example Empty bucket
|
|
1152
|
-
* ```js
|
|
1153
|
-
* const { data, error } = await supabase
|
|
1154
|
-
* .storage
|
|
1155
|
-
* .emptyBucket('avatars')
|
|
1156
|
-
* ```
|
|
1157
|
-
*
|
|
1158
|
-
* Response:
|
|
1159
|
-
* ```json
|
|
1160
|
-
* {
|
|
1161
|
-
* "data": {
|
|
1162
|
-
* "message": "Successfully emptied"
|
|
1163
|
-
* },
|
|
1164
|
-
* "error": null
|
|
1165
|
-
* }
|
|
1166
|
-
* ```
|
|
1167
|
-
*/
|
|
1168
|
-
emptyBucket(id: string): Promise<{
|
|
1169
|
-
data: {
|
|
1170
|
-
message: string;
|
|
1171
|
-
};
|
|
1172
|
-
error: null;
|
|
1173
|
-
} | {
|
|
1174
|
-
data: null;
|
|
1175
|
-
error: StorageError;
|
|
1176
|
-
}>;
|
|
1177
|
-
/**
|
|
1178
|
-
* Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
|
|
1179
|
-
* You must first `empty()` the bucket.
|
|
1180
|
-
*
|
|
1181
|
-
* @category File Buckets
|
|
1182
|
-
* @param id The unique identifier of the bucket you would like to delete.
|
|
1183
|
-
* @returns Promise with success message or error
|
|
1184
|
-
*
|
|
1185
|
-
* @example Delete bucket
|
|
1186
|
-
* ```js
|
|
1187
|
-
* const { data, error } = await supabase
|
|
1188
|
-
* .storage
|
|
1189
|
-
* .deleteBucket('avatars')
|
|
1190
|
-
* ```
|
|
1191
|
-
*
|
|
1192
|
-
* Response:
|
|
1193
|
-
* ```json
|
|
1194
|
-
* {
|
|
1195
|
-
* "data": {
|
|
1196
|
-
* "message": "Successfully deleted"
|
|
1197
|
-
* },
|
|
1198
|
-
* "error": null
|
|
1199
|
-
* }
|
|
1200
|
-
* ```
|
|
1201
|
-
*/
|
|
1202
|
-
deleteBucket(id: string): Promise<{
|
|
1203
|
-
data: {
|
|
1204
|
-
message: string;
|
|
1205
|
-
};
|
|
1206
|
-
error: null;
|
|
1207
|
-
} | {
|
|
1208
|
-
data: null;
|
|
1209
|
-
error: StorageError;
|
|
1210
|
-
}>;
|
|
1211
|
-
private listBucketOptionsToQueryString;
|
|
1212
|
-
}
|
|
1213
|
-
//#endregion
|
|
1214
|
-
//#region src/packages/StorageAnalyticsClient.d.ts
|
|
1215
|
-
type WrapAsyncMethod<T> = T extends ((...args: infer A) => Promise<infer R>) ? (...args: A) => Promise<{
|
|
1216
|
-
data: R;
|
|
1217
|
-
error: null;
|
|
1218
|
-
} | {
|
|
1219
|
-
data: null;
|
|
1220
|
-
error: IcebergError;
|
|
1221
|
-
}> : T;
|
|
1222
|
-
type WrappedIcebergRestCatalog = { [K in keyof IcebergRestCatalog]: WrapAsyncMethod<IcebergRestCatalog[K]> };
|
|
1223
|
-
/**
|
|
1224
|
-
* Client class for managing Analytics Buckets using Iceberg tables
|
|
1225
|
-
* Provides methods for creating, listing, and deleting analytics buckets
|
|
1226
|
-
*/
|
|
1227
|
-
declare class StorageAnalyticsClient {
|
|
1228
|
-
protected url: string;
|
|
1229
|
-
protected headers: {
|
|
1230
|
-
[key: string]: string;
|
|
1231
|
-
};
|
|
1232
|
-
protected fetch: Fetch$1;
|
|
1233
|
-
protected shouldThrowOnError: boolean;
|
|
1234
|
-
/**
|
|
1235
|
-
* @alpha
|
|
1236
|
-
*
|
|
1237
|
-
* Creates a new StorageAnalyticsClient instance
|
|
1238
|
-
*
|
|
1239
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1240
|
-
*
|
|
1241
|
-
* @category Analytics Buckets
|
|
1242
|
-
* @param url - The base URL for the storage API
|
|
1243
|
-
* @param headers - HTTP headers to include in requests
|
|
1244
|
-
* @param fetch - Optional custom fetch implementation
|
|
1245
|
-
*
|
|
1246
|
-
* @example
|
|
1247
|
-
* ```typescript
|
|
1248
|
-
* const client = new StorageAnalyticsClient(url, headers)
|
|
1249
|
-
* ```
|
|
1250
|
-
*/
|
|
1251
|
-
constructor(url: string, headers?: {
|
|
1252
|
-
[key: string]: string;
|
|
1253
|
-
}, fetch?: Fetch$1);
|
|
1254
|
-
/**
|
|
1255
|
-
* @alpha
|
|
1256
|
-
*
|
|
1257
|
-
* Enable throwing errors instead of returning them in the response
|
|
1258
|
-
* When enabled, failed operations will throw instead of returning { data: null, error }
|
|
1259
|
-
*
|
|
1260
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1261
|
-
*
|
|
1262
|
-
* @category Analytics Buckets
|
|
1263
|
-
* @returns This instance for method chaining
|
|
1264
|
-
*/
|
|
1265
|
-
throwOnError(): this;
|
|
1266
|
-
/**
|
|
1267
|
-
* @alpha
|
|
1268
|
-
*
|
|
1269
|
-
* Creates a new analytics bucket using Iceberg tables
|
|
1270
|
-
* Analytics buckets are optimized for analytical queries and data processing
|
|
1271
|
-
*
|
|
1272
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1273
|
-
*
|
|
1274
|
-
* @category Analytics Buckets
|
|
1275
|
-
* @param name A unique name for the bucket you are creating
|
|
1276
|
-
* @returns Promise with response containing newly created analytics bucket or error
|
|
1277
|
-
*
|
|
1278
|
-
* @example Create analytics bucket
|
|
1279
|
-
* ```js
|
|
1280
|
-
* const { data, error } = await supabase
|
|
1281
|
-
* .storage
|
|
1282
|
-
* .analytics
|
|
1283
|
-
* .createBucket('analytics-data')
|
|
1284
|
-
* ```
|
|
1285
|
-
*
|
|
1286
|
-
* Response:
|
|
1287
|
-
* ```json
|
|
1288
|
-
* {
|
|
1289
|
-
* "data": {
|
|
1290
|
-
* "name": "analytics-data",
|
|
1291
|
-
* "type": "ANALYTICS",
|
|
1292
|
-
* "format": "iceberg",
|
|
1293
|
-
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
1294
|
-
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
1295
|
-
* },
|
|
1296
|
-
* "error": null
|
|
1297
|
-
* }
|
|
1298
|
-
* ```
|
|
1299
|
-
*/
|
|
1300
|
-
createBucket(name: string): Promise<{
|
|
1301
|
-
data: AnalyticBucket;
|
|
1302
|
-
error: null;
|
|
1303
|
-
} | {
|
|
1304
|
-
data: null;
|
|
1305
|
-
error: StorageError;
|
|
1306
|
-
}>;
|
|
1307
|
-
/**
|
|
1308
|
-
* @alpha
|
|
1309
|
-
*
|
|
1310
|
-
* Retrieves the details of all Analytics Storage buckets within an existing project
|
|
1311
|
-
* Only returns buckets of type 'ANALYTICS'
|
|
1312
|
-
*
|
|
1313
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1314
|
-
*
|
|
1315
|
-
* @category Analytics Buckets
|
|
1316
|
-
* @param options Query parameters for listing buckets
|
|
1317
|
-
* @param options.limit Maximum number of buckets to return
|
|
1318
|
-
* @param options.offset Number of buckets to skip
|
|
1319
|
-
* @param options.sortColumn Column to sort by ('name', 'created_at', 'updated_at')
|
|
1320
|
-
* @param options.sortOrder Sort order ('asc' or 'desc')
|
|
1321
|
-
* @param options.search Search term to filter bucket names
|
|
1322
|
-
* @returns Promise with response containing array of analytics buckets or error
|
|
1323
|
-
*
|
|
1324
|
-
* @example List analytics buckets
|
|
1325
|
-
* ```js
|
|
1326
|
-
* const { data, error } = await supabase
|
|
1327
|
-
* .storage
|
|
1328
|
-
* .analytics
|
|
1329
|
-
* .listBuckets({
|
|
1330
|
-
* limit: 10,
|
|
1331
|
-
* offset: 0,
|
|
1332
|
-
* sortColumn: 'created_at',
|
|
1333
|
-
* sortOrder: 'desc'
|
|
1334
|
-
* })
|
|
1335
|
-
* ```
|
|
1336
|
-
*
|
|
1337
|
-
* Response:
|
|
1338
|
-
* ```json
|
|
1339
|
-
* {
|
|
1340
|
-
* "data": [
|
|
1341
|
-
* {
|
|
1342
|
-
* "name": "analytics-data",
|
|
1343
|
-
* "type": "ANALYTICS",
|
|
1344
|
-
* "format": "iceberg",
|
|
1345
|
-
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
1346
|
-
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
1347
|
-
* }
|
|
1348
|
-
* ],
|
|
1349
|
-
* "error": null
|
|
1350
|
-
* }
|
|
1351
|
-
* ```
|
|
1352
|
-
*/
|
|
1353
|
-
listBuckets(options?: {
|
|
1354
|
-
limit?: number;
|
|
1355
|
-
offset?: number;
|
|
1356
|
-
sortColumn?: 'name' | 'created_at' | 'updated_at';
|
|
1357
|
-
sortOrder?: 'asc' | 'desc';
|
|
1358
|
-
search?: string;
|
|
1359
|
-
}): Promise<{
|
|
1360
|
-
data: AnalyticBucket[];
|
|
1361
|
-
error: null;
|
|
1362
|
-
} | {
|
|
1363
|
-
data: null;
|
|
1364
|
-
error: StorageError;
|
|
1365
|
-
}>;
|
|
1366
|
-
/**
|
|
1367
|
-
* @alpha
|
|
1368
|
-
*
|
|
1369
|
-
* Deletes an existing analytics bucket
|
|
1370
|
-
* A bucket can't be deleted with existing objects inside it
|
|
1371
|
-
* You must first empty the bucket before deletion
|
|
1372
|
-
*
|
|
1373
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1374
|
-
*
|
|
1375
|
-
* @category Analytics Buckets
|
|
1376
|
-
* @param bucketName The unique identifier of the bucket you would like to delete
|
|
1377
|
-
* @returns Promise with response containing success message or error
|
|
1378
|
-
*
|
|
1379
|
-
* @example Delete analytics bucket
|
|
1380
|
-
* ```js
|
|
1381
|
-
* const { data, error } = await supabase
|
|
1382
|
-
* .storage
|
|
1383
|
-
* .analytics
|
|
1384
|
-
* .deleteBucket('analytics-data')
|
|
1385
|
-
* ```
|
|
1386
|
-
*
|
|
1387
|
-
* Response:
|
|
1388
|
-
* ```json
|
|
1389
|
-
* {
|
|
1390
|
-
* "data": {
|
|
1391
|
-
* "message": "Successfully deleted"
|
|
1392
|
-
* },
|
|
1393
|
-
* "error": null
|
|
1394
|
-
* }
|
|
1395
|
-
* ```
|
|
1396
|
-
*/
|
|
1397
|
-
deleteBucket(bucketName: string): Promise<{
|
|
1398
|
-
data: {
|
|
1399
|
-
message: string;
|
|
1400
|
-
};
|
|
1401
|
-
error: null;
|
|
1402
|
-
} | {
|
|
1403
|
-
data: null;
|
|
1404
|
-
error: StorageError;
|
|
1405
|
-
}>;
|
|
1406
|
-
/**
|
|
1407
|
-
* @alpha
|
|
1408
|
-
*
|
|
1409
|
-
* Get an Iceberg REST Catalog client configured for a specific analytics bucket
|
|
1410
|
-
* Use this to perform advanced table and namespace operations within the bucket
|
|
1411
|
-
* The returned client provides full access to the Apache Iceberg REST Catalog API
|
|
1412
|
-
* with the Supabase `{ data, error }` pattern for consistent error handling on all operations.
|
|
1413
|
-
*
|
|
1414
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1415
|
-
*
|
|
1416
|
-
* @category Analytics Buckets
|
|
1417
|
-
* @param bucketName - The name of the analytics bucket (warehouse) to connect to
|
|
1418
|
-
* @returns The wrapped Iceberg catalog client
|
|
1419
|
-
* @throws {StorageError} If the bucket name is invalid
|
|
1420
|
-
*
|
|
1421
|
-
* @example Get catalog and create table
|
|
1422
|
-
* ```js
|
|
1423
|
-
* // First, create an analytics bucket
|
|
1424
|
-
* const { data: bucket, error: bucketError } = await supabase
|
|
1425
|
-
* .storage
|
|
1426
|
-
* .analytics
|
|
1427
|
-
* .createBucket('analytics-data')
|
|
1428
|
-
*
|
|
1429
|
-
* // Get the Iceberg catalog for that bucket
|
|
1430
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1431
|
-
*
|
|
1432
|
-
* // Create a namespace
|
|
1433
|
-
* const { error: nsError } = await catalog.createNamespace({ namespace: ['default'] })
|
|
1434
|
-
*
|
|
1435
|
-
* // Create a table with schema
|
|
1436
|
-
* const { data: tableMetadata, error: tableError } = await catalog.createTable(
|
|
1437
|
-
* { namespace: ['default'] },
|
|
1438
|
-
* {
|
|
1439
|
-
* name: 'events',
|
|
1440
|
-
* schema: {
|
|
1441
|
-
* type: 'struct',
|
|
1442
|
-
* fields: [
|
|
1443
|
-
* { id: 1, name: 'id', type: 'long', required: true },
|
|
1444
|
-
* { id: 2, name: 'timestamp', type: 'timestamp', required: true },
|
|
1445
|
-
* { id: 3, name: 'user_id', type: 'string', required: false }
|
|
1446
|
-
* ],
|
|
1447
|
-
* 'schema-id': 0,
|
|
1448
|
-
* 'identifier-field-ids': [1]
|
|
1449
|
-
* },
|
|
1450
|
-
* 'partition-spec': {
|
|
1451
|
-
* 'spec-id': 0,
|
|
1452
|
-
* fields: []
|
|
1453
|
-
* },
|
|
1454
|
-
* 'write-order': {
|
|
1455
|
-
* 'order-id': 0,
|
|
1456
|
-
* fields: []
|
|
1457
|
-
* },
|
|
1458
|
-
* properties: {
|
|
1459
|
-
* 'write.format.default': 'parquet'
|
|
1460
|
-
* }
|
|
1461
|
-
* }
|
|
1462
|
-
* )
|
|
1463
|
-
* ```
|
|
1464
|
-
*
|
|
1465
|
-
* @example List tables in namespace
|
|
1466
|
-
* ```js
|
|
1467
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1468
|
-
*
|
|
1469
|
-
* // List all tables in the default namespace
|
|
1470
|
-
* const { data: tables, error: listError } = await catalog.listTables({ namespace: ['default'] })
|
|
1471
|
-
* if (listError) {
|
|
1472
|
-
* if (listError.isNotFound()) {
|
|
1473
|
-
* console.log('Namespace not found')
|
|
1474
|
-
* }
|
|
1475
|
-
* return
|
|
1476
|
-
* }
|
|
1477
|
-
* console.log(tables) // [{ namespace: ['default'], name: 'events' }]
|
|
1478
|
-
* ```
|
|
1479
|
-
*
|
|
1480
|
-
* @example Working with namespaces
|
|
1481
|
-
* ```js
|
|
1482
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1483
|
-
*
|
|
1484
|
-
* // List all namespaces
|
|
1485
|
-
* const { data: namespaces } = await catalog.listNamespaces()
|
|
1486
|
-
*
|
|
1487
|
-
* // Create namespace with properties
|
|
1488
|
-
* await catalog.createNamespace(
|
|
1489
|
-
* { namespace: ['production'] },
|
|
1490
|
-
* { properties: { owner: 'data-team', env: 'prod' } }
|
|
1491
|
-
* )
|
|
1492
|
-
* ```
|
|
1493
|
-
*
|
|
1494
|
-
* @example Cleanup operations
|
|
1495
|
-
* ```js
|
|
1496
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1497
|
-
*
|
|
1498
|
-
* // Drop table with purge option (removes all data)
|
|
1499
|
-
* const { error: dropError } = await catalog.dropTable(
|
|
1500
|
-
* { namespace: ['default'], name: 'events' },
|
|
1501
|
-
* { purge: true }
|
|
1502
|
-
* )
|
|
1503
|
-
*
|
|
1504
|
-
* if (dropError?.isNotFound()) {
|
|
1505
|
-
* console.log('Table does not exist')
|
|
1506
|
-
* }
|
|
1507
|
-
*
|
|
1508
|
-
* // Drop namespace (must be empty)
|
|
1509
|
-
* await catalog.dropNamespace({ namespace: ['default'] })
|
|
1510
|
-
* ```
|
|
1511
|
-
*
|
|
1512
|
-
* @remarks
|
|
1513
|
-
* This method provides a bridge between Supabase's bucket management and the standard
|
|
1514
|
-
* Apache Iceberg REST Catalog API. The bucket name maps to the Iceberg warehouse parameter.
|
|
1515
|
-
* All authentication and configuration is handled automatically using your Supabase credentials.
|
|
1516
|
-
*
|
|
1517
|
-
* **Error Handling**: Invalid bucket names throw immediately. All catalog
|
|
1518
|
-
* operations return `{ data, error }` where errors are `IcebergError` instances from iceberg-js.
|
|
1519
|
-
* Use helper methods like `error.isNotFound()` or check `error.status` for specific error handling.
|
|
1520
|
-
* Use `.throwOnError()` on the analytics client if you prefer exceptions for catalog operations.
|
|
1521
|
-
*
|
|
1522
|
-
* **Cleanup Operations**: When using `dropTable`, the `purge: true` option permanently
|
|
1523
|
-
* deletes all table data. Without it, the table is marked as deleted but data remains.
|
|
1524
|
-
*
|
|
1525
|
-
* **Library Dependency**: The returned catalog wraps `IcebergRestCatalog` from iceberg-js.
|
|
1526
|
-
* For complete API documentation and advanced usage, refer to the
|
|
1527
|
-
* [iceberg-js documentation](https://supabase.github.io/iceberg-js/).
|
|
1528
|
-
*/
|
|
1529
|
-
from(bucketName: string): WrappedIcebergRestCatalog;
|
|
1530
|
-
}
|
|
1531
|
-
//#endregion
|
|
1532
|
-
//#region src/lib/vectors/errors.d.ts
|
|
1533
|
-
/**
|
|
1534
|
-
* Base error class for all Storage Vectors errors
|
|
1535
|
-
*/
|
|
1536
|
-
declare class StorageVectorsError extends Error {
|
|
1537
|
-
protected __isStorageVectorsError: boolean;
|
|
1538
|
-
constructor(message: string);
|
|
1539
|
-
}
|
|
1540
|
-
/**
|
|
1541
|
-
* Type guard to check if an error is a StorageVectorsError
|
|
1542
|
-
* @param error - The error to check
|
|
1543
|
-
* @returns True if the error is a StorageVectorsError
|
|
1544
|
-
*/
|
|
1545
|
-
declare function isStorageVectorsError(error: unknown): error is StorageVectorsError;
|
|
1546
|
-
/**
|
|
1547
|
-
* API error returned from S3 Vectors service
|
|
1548
|
-
* Includes HTTP status code and service-specific error code
|
|
1549
|
-
*/
|
|
1550
|
-
declare class StorageVectorsApiError extends StorageVectorsError {
|
|
1551
|
-
status: number;
|
|
1552
|
-
statusCode: string;
|
|
1553
|
-
constructor(message: string, status: number, statusCode: string);
|
|
1554
|
-
toJSON(): {
|
|
1555
|
-
name: string;
|
|
1556
|
-
message: string;
|
|
1557
|
-
status: number;
|
|
1558
|
-
statusCode: string;
|
|
1559
|
-
};
|
|
1560
|
-
}
|
|
1561
|
-
/**
|
|
1562
|
-
* Unknown error that doesn't match expected error patterns
|
|
1563
|
-
* Wraps the original error for debugging
|
|
1564
|
-
*/
|
|
1565
|
-
declare class StorageVectorsUnknownError extends StorageVectorsError {
|
|
1566
|
-
originalError: unknown;
|
|
1567
|
-
constructor(message: string, originalError: unknown);
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Error codes specific to S3 Vectors API
|
|
1571
|
-
* Maps AWS service errors to application-friendly error codes
|
|
1572
|
-
*/
|
|
1573
|
-
declare enum StorageVectorsErrorCode {
|
|
1574
|
-
/** Internal server fault (HTTP 500) */
|
|
1575
|
-
InternalError = "InternalError",
|
|
1576
|
-
/** Resource already exists / conflict (HTTP 409) */
|
|
1577
|
-
S3VectorConflictException = "S3VectorConflictException",
|
|
1578
|
-
/** Resource not found (HTTP 404) */
|
|
1579
|
-
S3VectorNotFoundException = "S3VectorNotFoundException",
|
|
1580
|
-
/** Delete bucket while not empty (HTTP 400) */
|
|
1581
|
-
S3VectorBucketNotEmpty = "S3VectorBucketNotEmpty",
|
|
1582
|
-
/** Exceeds bucket quota/limit (HTTP 400) */
|
|
1583
|
-
S3VectorMaxBucketsExceeded = "S3VectorMaxBucketsExceeded",
|
|
1584
|
-
/** Exceeds index quota/limit (HTTP 400) */
|
|
1585
|
-
S3VectorMaxIndexesExceeded = "S3VectorMaxIndexesExceeded",
|
|
1586
|
-
}
|
|
1587
|
-
//#endregion
|
|
1588
|
-
//#region src/lib/vectors/types.d.ts
|
|
1589
|
-
/**
|
|
1590
|
-
* Configuration for encryption at rest
|
|
1591
|
-
* @property kmsKeyArn - ARN of the KMS key used for encryption
|
|
1592
|
-
* @property sseType - Server-side encryption type (e.g., 'KMS')
|
|
1593
|
-
*/
|
|
1594
|
-
interface EncryptionConfiguration {
|
|
1595
|
-
kmsKeyArn?: string;
|
|
1596
|
-
sseType?: string;
|
|
1597
|
-
}
|
|
1598
|
-
/**
|
|
1599
|
-
* Vector bucket metadata
|
|
1600
|
-
* @property vectorBucketName - Unique name of the vector bucket
|
|
1601
|
-
* @property creationTime - Unix timestamp of when the bucket was created
|
|
1602
|
-
* @property encryptionConfiguration - Optional encryption settings
|
|
1603
|
-
*/
|
|
1604
|
-
interface VectorBucket {
|
|
1605
|
-
vectorBucketName: string;
|
|
1606
|
-
creationTime?: number;
|
|
1607
|
-
encryptionConfiguration?: EncryptionConfiguration;
|
|
397
|
+
/**
|
|
398
|
+
* Vector bucket metadata
|
|
399
|
+
* @property vectorBucketName - Unique name of the vector bucket
|
|
400
|
+
* @property creationTime - Unix timestamp of when the bucket was created
|
|
401
|
+
* @property encryptionConfiguration - Optional encryption settings
|
|
402
|
+
*/
|
|
403
|
+
interface VectorBucket {
|
|
404
|
+
vectorBucketName: string;
|
|
405
|
+
creationTime?: number;
|
|
406
|
+
encryptionConfiguration?: EncryptionConfiguration;
|
|
1608
407
|
}
|
|
1609
408
|
/**
|
|
1610
409
|
* Metadata configuration for vector index
|
|
@@ -1824,65 +623,1286 @@ interface QueryVectorsOptions {
|
|
|
1824
623
|
returnDistance?: boolean;
|
|
1825
624
|
returnMetadata?: boolean;
|
|
1826
625
|
}
|
|
1827
|
-
/**
|
|
1828
|
-
* Response from vector similarity query
|
|
1829
|
-
* @property vectors - Array of similar vectors ordered by distance
|
|
1830
|
-
* @property distanceMetric - The distance metric used for the similarity search
|
|
1831
|
-
*/
|
|
1832
|
-
interface QueryVectorsResponse {
|
|
1833
|
-
vectors: VectorMatch[];
|
|
1834
|
-
distanceMetric?: DistanceMetric;
|
|
626
|
+
/**
|
|
627
|
+
* Response from vector similarity query
|
|
628
|
+
* @property vectors - Array of similar vectors ordered by distance
|
|
629
|
+
* @property distanceMetric - The distance metric used for the similarity search
|
|
630
|
+
*/
|
|
631
|
+
interface QueryVectorsResponse {
|
|
632
|
+
vectors: VectorMatch[];
|
|
633
|
+
distanceMetric?: DistanceMetric;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Fetch-specific parameters like abort signals
|
|
637
|
+
* @property signal - AbortSignal for cancelling requests
|
|
638
|
+
*/
|
|
639
|
+
interface VectorFetchParameters {
|
|
640
|
+
signal?: AbortSignal;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Standard response wrapper for successful operations
|
|
644
|
+
* @property data - Response data of type T
|
|
645
|
+
* @property error - Null on success
|
|
646
|
+
*/
|
|
647
|
+
interface SuccessResponse<T> {
|
|
648
|
+
data: T;
|
|
649
|
+
error: null;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Standard response wrapper for failed operations
|
|
653
|
+
* @property data - Null on error
|
|
654
|
+
* @property error - StorageError with details (named StorageVectorsError for vector operations)
|
|
655
|
+
*/
|
|
656
|
+
interface ErrorResponse {
|
|
657
|
+
data: null;
|
|
658
|
+
error: StorageError;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Union type for all API responses
|
|
662
|
+
* Follows the pattern: { data: T, error: null } | { data: null, error: Error }
|
|
663
|
+
*/
|
|
664
|
+
type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/packages/StreamDownloadBuilder.d.ts
|
|
667
|
+
declare class StreamDownloadBuilder implements PromiseLike<DownloadResult<ReadableStream>> {
|
|
668
|
+
private downloadFn;
|
|
669
|
+
private shouldThrowOnError;
|
|
670
|
+
constructor(downloadFn: () => Promise<Response>, shouldThrowOnError: boolean);
|
|
671
|
+
then<TResult1 = DownloadResult<ReadableStream>, TResult2 = never>(onfulfilled?: ((value: DownloadResult<ReadableStream>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
672
|
+
private execute;
|
|
673
|
+
}
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/packages/BlobDownloadBuilder.d.ts
|
|
676
|
+
declare class BlobDownloadBuilder implements Promise<DownloadResult<Blob>> {
|
|
677
|
+
private downloadFn;
|
|
678
|
+
private shouldThrowOnError;
|
|
679
|
+
readonly [Symbol.toStringTag]: string;
|
|
680
|
+
private promise;
|
|
681
|
+
constructor(downloadFn: () => Promise<Response>, shouldThrowOnError: boolean);
|
|
682
|
+
asStream(): StreamDownloadBuilder;
|
|
683
|
+
then<TResult1 = DownloadResult<Blob>, TResult2 = never>(onfulfilled?: ((value: DownloadResult<Blob>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
684
|
+
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<DownloadResult<Blob> | TResult>;
|
|
685
|
+
finally(onfinally?: (() => void) | null): Promise<DownloadResult<Blob>>;
|
|
686
|
+
private getPromise;
|
|
687
|
+
private execute;
|
|
688
|
+
}
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/packages/StorageFileApi.d.ts
|
|
691
|
+
type FileBody = ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string;
|
|
692
|
+
declare class StorageFileApi extends BaseApiClient<StorageError> {
|
|
693
|
+
protected bucketId?: string;
|
|
694
|
+
constructor(url: string, headers?: {
|
|
695
|
+
[key: string]: string;
|
|
696
|
+
}, bucketId?: string, fetch?: Fetch);
|
|
697
|
+
/**
|
|
698
|
+
* Uploads a file to an existing bucket or replaces an existing file at the specified path with a new one.
|
|
699
|
+
*
|
|
700
|
+
* @param method HTTP method.
|
|
701
|
+
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
702
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
703
|
+
*/
|
|
704
|
+
private uploadOrUpdate;
|
|
705
|
+
/**
|
|
706
|
+
* Uploads a file to an existing bucket.
|
|
707
|
+
*
|
|
708
|
+
* @category File Buckets
|
|
709
|
+
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
710
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
711
|
+
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
712
|
+
* @returns Promise with response containing file path, id, and fullPath or error
|
|
713
|
+
*
|
|
714
|
+
* @example Upload file
|
|
715
|
+
* ```js
|
|
716
|
+
* const avatarFile = event.target.files[0]
|
|
717
|
+
* const { data, error } = await supabase
|
|
718
|
+
* .storage
|
|
719
|
+
* .from('avatars')
|
|
720
|
+
* .upload('public/avatar1.png', avatarFile, {
|
|
721
|
+
* cacheControl: '3600',
|
|
722
|
+
* upsert: false
|
|
723
|
+
* })
|
|
724
|
+
* ```
|
|
725
|
+
*
|
|
726
|
+
* Response:
|
|
727
|
+
* ```json
|
|
728
|
+
* {
|
|
729
|
+
* "data": {
|
|
730
|
+
* "path": "public/avatar1.png",
|
|
731
|
+
* "fullPath": "avatars/public/avatar1.png"
|
|
732
|
+
* },
|
|
733
|
+
* "error": null
|
|
734
|
+
* }
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* @example Upload file using `ArrayBuffer` from base64 file data
|
|
738
|
+
* ```js
|
|
739
|
+
* import { decode } from 'base64-arraybuffer'
|
|
740
|
+
*
|
|
741
|
+
* const { data, error } = await supabase
|
|
742
|
+
* .storage
|
|
743
|
+
* .from('avatars')
|
|
744
|
+
* .upload('public/avatar1.png', decode('base64FileData'), {
|
|
745
|
+
* contentType: 'image/png'
|
|
746
|
+
* })
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
upload(path: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
750
|
+
data: {
|
|
751
|
+
id: string;
|
|
752
|
+
path: string;
|
|
753
|
+
fullPath: string;
|
|
754
|
+
};
|
|
755
|
+
error: null;
|
|
756
|
+
} | {
|
|
757
|
+
data: null;
|
|
758
|
+
error: StorageError;
|
|
759
|
+
}>;
|
|
760
|
+
/**
|
|
761
|
+
* Upload a file with a token generated from `createSignedUploadUrl`.
|
|
762
|
+
*
|
|
763
|
+
* @category File Buckets
|
|
764
|
+
* @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
|
|
765
|
+
* @param token The token generated from `createSignedUploadUrl`
|
|
766
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
767
|
+
* @param fileOptions HTTP headers (cacheControl, contentType, etc.).
|
|
768
|
+
* **Note:** The `upsert` option has no effect here. To enable upsert behavior,
|
|
769
|
+
* pass `{ upsert: true }` when calling `createSignedUploadUrl()` instead.
|
|
770
|
+
* @returns Promise with response containing file path and fullPath or error
|
|
771
|
+
*
|
|
772
|
+
* @example Upload to a signed URL
|
|
773
|
+
* ```js
|
|
774
|
+
* const { data, error } = await supabase
|
|
775
|
+
* .storage
|
|
776
|
+
* .from('avatars')
|
|
777
|
+
* .uploadToSignedUrl('folder/cat.jpg', 'token-from-createSignedUploadUrl', file)
|
|
778
|
+
* ```
|
|
779
|
+
*
|
|
780
|
+
* Response:
|
|
781
|
+
* ```json
|
|
782
|
+
* {
|
|
783
|
+
* "data": {
|
|
784
|
+
* "path": "folder/cat.jpg",
|
|
785
|
+
* "fullPath": "avatars/folder/cat.jpg"
|
|
786
|
+
* },
|
|
787
|
+
* "error": null
|
|
788
|
+
* }
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
uploadToSignedUrl(path: string, token: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
792
|
+
data: null;
|
|
793
|
+
error: StorageError;
|
|
794
|
+
} | {
|
|
795
|
+
data: {
|
|
796
|
+
path: string;
|
|
797
|
+
fullPath: any;
|
|
798
|
+
};
|
|
799
|
+
error: null;
|
|
800
|
+
}>;
|
|
801
|
+
/**
|
|
802
|
+
* Creates a signed upload URL.
|
|
803
|
+
* Signed upload URLs can be used to upload files to the bucket without further authentication.
|
|
804
|
+
* They are valid for 2 hours.
|
|
805
|
+
*
|
|
806
|
+
* @category File Buckets
|
|
807
|
+
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
808
|
+
* @param options.upsert If set to true, allows the file to be overwritten if it already exists.
|
|
809
|
+
* @returns Promise with response containing signed upload URL, token, and path or error
|
|
810
|
+
*
|
|
811
|
+
* @example Create Signed Upload URL
|
|
812
|
+
* ```js
|
|
813
|
+
* const { data, error } = await supabase
|
|
814
|
+
* .storage
|
|
815
|
+
* .from('avatars')
|
|
816
|
+
* .createSignedUploadUrl('folder/cat.jpg')
|
|
817
|
+
* ```
|
|
818
|
+
*
|
|
819
|
+
* Response:
|
|
820
|
+
* ```json
|
|
821
|
+
* {
|
|
822
|
+
* "data": {
|
|
823
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/upload/sign/avatars/folder/cat.jpg?token=<TOKEN>",
|
|
824
|
+
* "path": "folder/cat.jpg",
|
|
825
|
+
* "token": "<TOKEN>"
|
|
826
|
+
* },
|
|
827
|
+
* "error": null
|
|
828
|
+
* }
|
|
829
|
+
* ```
|
|
830
|
+
*/
|
|
831
|
+
createSignedUploadUrl(path: string, options?: {
|
|
832
|
+
upsert: boolean;
|
|
833
|
+
}): Promise<{
|
|
834
|
+
data: {
|
|
835
|
+
signedUrl: string;
|
|
836
|
+
token: string;
|
|
837
|
+
path: string;
|
|
838
|
+
};
|
|
839
|
+
error: null;
|
|
840
|
+
} | {
|
|
841
|
+
data: null;
|
|
842
|
+
error: StorageError;
|
|
843
|
+
}>;
|
|
844
|
+
/**
|
|
845
|
+
* Replaces an existing file at the specified path with a new one.
|
|
846
|
+
*
|
|
847
|
+
* @category File Buckets
|
|
848
|
+
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.
|
|
849
|
+
* @param fileBody The body of the file to be stored in the bucket.
|
|
850
|
+
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
851
|
+
* @returns Promise with response containing file path, id, and fullPath or error
|
|
852
|
+
*
|
|
853
|
+
* @example Update file
|
|
854
|
+
* ```js
|
|
855
|
+
* const avatarFile = event.target.files[0]
|
|
856
|
+
* const { data, error } = await supabase
|
|
857
|
+
* .storage
|
|
858
|
+
* .from('avatars')
|
|
859
|
+
* .update('public/avatar1.png', avatarFile, {
|
|
860
|
+
* cacheControl: '3600',
|
|
861
|
+
* upsert: true
|
|
862
|
+
* })
|
|
863
|
+
* ```
|
|
864
|
+
*
|
|
865
|
+
* Response:
|
|
866
|
+
* ```json
|
|
867
|
+
* {
|
|
868
|
+
* "data": {
|
|
869
|
+
* "path": "public/avatar1.png",
|
|
870
|
+
* "fullPath": "avatars/public/avatar1.png"
|
|
871
|
+
* },
|
|
872
|
+
* "error": null
|
|
873
|
+
* }
|
|
874
|
+
* ```
|
|
875
|
+
*
|
|
876
|
+
* @example Update file using `ArrayBuffer` from base64 file data
|
|
877
|
+
* ```js
|
|
878
|
+
* import {decode} from 'base64-arraybuffer'
|
|
879
|
+
*
|
|
880
|
+
* const { data, error } = await supabase
|
|
881
|
+
* .storage
|
|
882
|
+
* .from('avatars')
|
|
883
|
+
* .update('public/avatar1.png', decode('base64FileData'), {
|
|
884
|
+
* contentType: 'image/png'
|
|
885
|
+
* })
|
|
886
|
+
* ```
|
|
887
|
+
*/
|
|
888
|
+
update(path: string, fileBody: ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string, fileOptions?: FileOptions): Promise<{
|
|
889
|
+
data: {
|
|
890
|
+
id: string;
|
|
891
|
+
path: string;
|
|
892
|
+
fullPath: string;
|
|
893
|
+
};
|
|
894
|
+
error: null;
|
|
895
|
+
} | {
|
|
896
|
+
data: null;
|
|
897
|
+
error: StorageError;
|
|
898
|
+
}>;
|
|
899
|
+
/**
|
|
900
|
+
* Moves an existing file to a new path in the same bucket.
|
|
901
|
+
*
|
|
902
|
+
* @category File Buckets
|
|
903
|
+
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
904
|
+
* @param toPath The new file path, including the new file name. For example `folder/image-new.png`.
|
|
905
|
+
* @param options The destination options.
|
|
906
|
+
* @returns Promise with response containing success message or error
|
|
907
|
+
*
|
|
908
|
+
* @example Move file
|
|
909
|
+
* ```js
|
|
910
|
+
* const { data, error } = await supabase
|
|
911
|
+
* .storage
|
|
912
|
+
* .from('avatars')
|
|
913
|
+
* .move('public/avatar1.png', 'private/avatar2.png')
|
|
914
|
+
* ```
|
|
915
|
+
*
|
|
916
|
+
* Response:
|
|
917
|
+
* ```json
|
|
918
|
+
* {
|
|
919
|
+
* "data": {
|
|
920
|
+
* "message": "Successfully moved"
|
|
921
|
+
* },
|
|
922
|
+
* "error": null
|
|
923
|
+
* }
|
|
924
|
+
* ```
|
|
925
|
+
*/
|
|
926
|
+
move(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
927
|
+
data: {
|
|
928
|
+
message: string;
|
|
929
|
+
};
|
|
930
|
+
error: null;
|
|
931
|
+
} | {
|
|
932
|
+
data: null;
|
|
933
|
+
error: StorageError;
|
|
934
|
+
}>;
|
|
935
|
+
/**
|
|
936
|
+
* Copies an existing file to a new path in the same bucket.
|
|
937
|
+
*
|
|
938
|
+
* @category File Buckets
|
|
939
|
+
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
940
|
+
* @param toPath The new file path, including the new file name. For example `folder/image-copy.png`.
|
|
941
|
+
* @param options The destination options.
|
|
942
|
+
* @returns Promise with response containing copied file path or error
|
|
943
|
+
*
|
|
944
|
+
* @example Copy file
|
|
945
|
+
* ```js
|
|
946
|
+
* const { data, error } = await supabase
|
|
947
|
+
* .storage
|
|
948
|
+
* .from('avatars')
|
|
949
|
+
* .copy('public/avatar1.png', 'private/avatar2.png')
|
|
950
|
+
* ```
|
|
951
|
+
*
|
|
952
|
+
* Response:
|
|
953
|
+
* ```json
|
|
954
|
+
* {
|
|
955
|
+
* "data": {
|
|
956
|
+
* "path": "avatars/private/avatar2.png"
|
|
957
|
+
* },
|
|
958
|
+
* "error": null
|
|
959
|
+
* }
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
copy(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
963
|
+
data: {
|
|
964
|
+
path: string;
|
|
965
|
+
};
|
|
966
|
+
error: null;
|
|
967
|
+
} | {
|
|
968
|
+
data: null;
|
|
969
|
+
error: StorageError;
|
|
970
|
+
}>;
|
|
971
|
+
/**
|
|
972
|
+
* Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
|
|
973
|
+
*
|
|
974
|
+
* @category File Buckets
|
|
975
|
+
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
976
|
+
* @param expiresIn The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
|
|
977
|
+
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
978
|
+
* @param options.transform Transform the asset before serving it to the client.
|
|
979
|
+
* @returns Promise with response containing signed URL or error
|
|
980
|
+
*
|
|
981
|
+
* @example Create Signed URL
|
|
982
|
+
* ```js
|
|
983
|
+
* const { data, error } = await supabase
|
|
984
|
+
* .storage
|
|
985
|
+
* .from('avatars')
|
|
986
|
+
* .createSignedUrl('folder/avatar1.png', 60)
|
|
987
|
+
* ```
|
|
988
|
+
*
|
|
989
|
+
* Response:
|
|
990
|
+
* ```json
|
|
991
|
+
* {
|
|
992
|
+
* "data": {
|
|
993
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
994
|
+
* },
|
|
995
|
+
* "error": null
|
|
996
|
+
* }
|
|
997
|
+
* ```
|
|
998
|
+
*
|
|
999
|
+
* @example Create a signed URL for an asset with transformations
|
|
1000
|
+
* ```js
|
|
1001
|
+
* const { data } = await supabase
|
|
1002
|
+
* .storage
|
|
1003
|
+
* .from('avatars')
|
|
1004
|
+
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
1005
|
+
* transform: {
|
|
1006
|
+
* width: 100,
|
|
1007
|
+
* height: 100,
|
|
1008
|
+
* }
|
|
1009
|
+
* })
|
|
1010
|
+
* ```
|
|
1011
|
+
*
|
|
1012
|
+
* @example Create a signed URL which triggers the download of the asset
|
|
1013
|
+
* ```js
|
|
1014
|
+
* const { data } = await supabase
|
|
1015
|
+
* .storage
|
|
1016
|
+
* .from('avatars')
|
|
1017
|
+
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
1018
|
+
* download: true,
|
|
1019
|
+
* })
|
|
1020
|
+
* ```
|
|
1021
|
+
*/
|
|
1022
|
+
createSignedUrl(path: string, expiresIn: number, options?: {
|
|
1023
|
+
download?: string | boolean;
|
|
1024
|
+
transform?: TransformOptions;
|
|
1025
|
+
}): Promise<{
|
|
1026
|
+
data: {
|
|
1027
|
+
signedUrl: string;
|
|
1028
|
+
};
|
|
1029
|
+
error: null;
|
|
1030
|
+
} | {
|
|
1031
|
+
data: null;
|
|
1032
|
+
error: StorageError;
|
|
1033
|
+
}>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.
|
|
1036
|
+
*
|
|
1037
|
+
* @category File Buckets
|
|
1038
|
+
* @param paths The file paths to be downloaded, including the current file names. For example `['folder/image.png', 'folder2/image2.png']`.
|
|
1039
|
+
* @param expiresIn The number of seconds until the signed URLs expire. For example, `60` for URLs which are valid for one minute.
|
|
1040
|
+
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
1041
|
+
* @returns Promise with response containing array of objects with signedUrl, path, and error or error
|
|
1042
|
+
*
|
|
1043
|
+
* @example Create Signed URLs
|
|
1044
|
+
* ```js
|
|
1045
|
+
* const { data, error } = await supabase
|
|
1046
|
+
* .storage
|
|
1047
|
+
* .from('avatars')
|
|
1048
|
+
* .createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60)
|
|
1049
|
+
* ```
|
|
1050
|
+
*
|
|
1051
|
+
* Response:
|
|
1052
|
+
* ```json
|
|
1053
|
+
* {
|
|
1054
|
+
* "data": [
|
|
1055
|
+
* {
|
|
1056
|
+
* "error": null,
|
|
1057
|
+
* "path": "folder/avatar1.png",
|
|
1058
|
+
* "signedURL": "/object/sign/avatars/folder/avatar1.png?token=<TOKEN>",
|
|
1059
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
1060
|
+
* },
|
|
1061
|
+
* {
|
|
1062
|
+
* "error": null,
|
|
1063
|
+
* "path": "folder/avatar2.png",
|
|
1064
|
+
* "signedURL": "/object/sign/avatars/folder/avatar2.png?token=<TOKEN>",
|
|
1065
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar2.png?token=<TOKEN>"
|
|
1066
|
+
* }
|
|
1067
|
+
* ],
|
|
1068
|
+
* "error": null
|
|
1069
|
+
* }
|
|
1070
|
+
* ```
|
|
1071
|
+
*/
|
|
1072
|
+
createSignedUrls(paths: string[], expiresIn: number, options?: {
|
|
1073
|
+
download: string | boolean;
|
|
1074
|
+
}): Promise<{
|
|
1075
|
+
data: {
|
|
1076
|
+
error: string | null;
|
|
1077
|
+
path: string | null;
|
|
1078
|
+
signedUrl: string;
|
|
1079
|
+
}[];
|
|
1080
|
+
error: null;
|
|
1081
|
+
} | {
|
|
1082
|
+
data: null;
|
|
1083
|
+
error: StorageError;
|
|
1084
|
+
}>;
|
|
1085
|
+
/**
|
|
1086
|
+
* Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.
|
|
1087
|
+
*
|
|
1088
|
+
* @category File Buckets
|
|
1089
|
+
* @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
|
|
1090
|
+
* @param options.transform Transform the asset before serving it to the client.
|
|
1091
|
+
* @returns BlobDownloadBuilder instance for downloading the file
|
|
1092
|
+
*
|
|
1093
|
+
* @example Download file
|
|
1094
|
+
* ```js
|
|
1095
|
+
* const { data, error } = await supabase
|
|
1096
|
+
* .storage
|
|
1097
|
+
* .from('avatars')
|
|
1098
|
+
* .download('folder/avatar1.png')
|
|
1099
|
+
* ```
|
|
1100
|
+
*
|
|
1101
|
+
* Response:
|
|
1102
|
+
* ```json
|
|
1103
|
+
* {
|
|
1104
|
+
* "data": <BLOB>,
|
|
1105
|
+
* "error": null
|
|
1106
|
+
* }
|
|
1107
|
+
* ```
|
|
1108
|
+
*
|
|
1109
|
+
* @example Download file with transformations
|
|
1110
|
+
* ```js
|
|
1111
|
+
* const { data, error } = await supabase
|
|
1112
|
+
* .storage
|
|
1113
|
+
* .from('avatars')
|
|
1114
|
+
* .download('folder/avatar1.png', {
|
|
1115
|
+
* transform: {
|
|
1116
|
+
* width: 100,
|
|
1117
|
+
* height: 100,
|
|
1118
|
+
* quality: 80
|
|
1119
|
+
* }
|
|
1120
|
+
* })
|
|
1121
|
+
* ```
|
|
1122
|
+
*/
|
|
1123
|
+
download<Options extends {
|
|
1124
|
+
transform?: TransformOptions;
|
|
1125
|
+
}>(path: string, options?: Options): BlobDownloadBuilder;
|
|
1126
|
+
/**
|
|
1127
|
+
* Retrieves the details of an existing file.
|
|
1128
|
+
*
|
|
1129
|
+
* @category File Buckets
|
|
1130
|
+
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
1131
|
+
* @returns Promise with response containing file metadata or error
|
|
1132
|
+
*
|
|
1133
|
+
* @example Get file info
|
|
1134
|
+
* ```js
|
|
1135
|
+
* const { data, error } = await supabase
|
|
1136
|
+
* .storage
|
|
1137
|
+
* .from('avatars')
|
|
1138
|
+
* .info('folder/avatar1.png')
|
|
1139
|
+
* ```
|
|
1140
|
+
*/
|
|
1141
|
+
info(path: string): Promise<{
|
|
1142
|
+
data: Camelize<FileObjectV2>;
|
|
1143
|
+
error: null;
|
|
1144
|
+
} | {
|
|
1145
|
+
data: null;
|
|
1146
|
+
error: StorageError;
|
|
1147
|
+
}>;
|
|
1148
|
+
/**
|
|
1149
|
+
* Checks the existence of a file.
|
|
1150
|
+
*
|
|
1151
|
+
* @category File Buckets
|
|
1152
|
+
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
1153
|
+
* @returns Promise with response containing boolean indicating file existence or error
|
|
1154
|
+
*
|
|
1155
|
+
* @example Check file existence
|
|
1156
|
+
* ```js
|
|
1157
|
+
* const { data, error } = await supabase
|
|
1158
|
+
* .storage
|
|
1159
|
+
* .from('avatars')
|
|
1160
|
+
* .exists('folder/avatar1.png')
|
|
1161
|
+
* ```
|
|
1162
|
+
*/
|
|
1163
|
+
exists(path: string): Promise<{
|
|
1164
|
+
data: boolean;
|
|
1165
|
+
error: null;
|
|
1166
|
+
} | {
|
|
1167
|
+
data: boolean;
|
|
1168
|
+
error: StorageError;
|
|
1169
|
+
}>;
|
|
1170
|
+
/**
|
|
1171
|
+
* A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.
|
|
1172
|
+
* This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
|
|
1173
|
+
*
|
|
1174
|
+
* @category File Buckets
|
|
1175
|
+
* @param path The path and name of the file to generate the public URL for. For example `folder/image.png`.
|
|
1176
|
+
* @param options.download Triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
1177
|
+
* @param options.transform Transform the asset before serving it to the client.
|
|
1178
|
+
* @returns Object with public URL
|
|
1179
|
+
*
|
|
1180
|
+
* @example Returns the URL for an asset in a public bucket
|
|
1181
|
+
* ```js
|
|
1182
|
+
* const { data } = supabase
|
|
1183
|
+
* .storage
|
|
1184
|
+
* .from('public-bucket')
|
|
1185
|
+
* .getPublicUrl('folder/avatar1.png')
|
|
1186
|
+
* ```
|
|
1187
|
+
*
|
|
1188
|
+
* Response:
|
|
1189
|
+
* ```json
|
|
1190
|
+
* {
|
|
1191
|
+
* "data": {
|
|
1192
|
+
* "publicUrl": "https://example.supabase.co/storage/v1/object/public/public-bucket/folder/avatar1.png"
|
|
1193
|
+
* }
|
|
1194
|
+
* }
|
|
1195
|
+
* ```
|
|
1196
|
+
*
|
|
1197
|
+
* @example Returns the URL for an asset in a public bucket with transformations
|
|
1198
|
+
* ```js
|
|
1199
|
+
* const { data } = supabase
|
|
1200
|
+
* .storage
|
|
1201
|
+
* .from('public-bucket')
|
|
1202
|
+
* .getPublicUrl('folder/avatar1.png', {
|
|
1203
|
+
* transform: {
|
|
1204
|
+
* width: 100,
|
|
1205
|
+
* height: 100,
|
|
1206
|
+
* }
|
|
1207
|
+
* })
|
|
1208
|
+
* ```
|
|
1209
|
+
*
|
|
1210
|
+
* @example Returns the URL which triggers the download of an asset in a public bucket
|
|
1211
|
+
* ```js
|
|
1212
|
+
* const { data } = supabase
|
|
1213
|
+
* .storage
|
|
1214
|
+
* .from('public-bucket')
|
|
1215
|
+
* .getPublicUrl('folder/avatar1.png', {
|
|
1216
|
+
* download: true,
|
|
1217
|
+
* })
|
|
1218
|
+
* ```
|
|
1219
|
+
*/
|
|
1220
|
+
getPublicUrl(path: string, options?: {
|
|
1221
|
+
download?: string | boolean;
|
|
1222
|
+
transform?: TransformOptions;
|
|
1223
|
+
}): {
|
|
1224
|
+
data: {
|
|
1225
|
+
publicUrl: string;
|
|
1226
|
+
};
|
|
1227
|
+
};
|
|
1228
|
+
/**
|
|
1229
|
+
* Deletes files within the same bucket
|
|
1230
|
+
*
|
|
1231
|
+
* @category File Buckets
|
|
1232
|
+
* @param paths An array of files to delete, including the path and file name. For example [`'folder/image.png'`].
|
|
1233
|
+
* @returns Promise with response containing array of deleted file objects or error
|
|
1234
|
+
*
|
|
1235
|
+
* @example Delete file
|
|
1236
|
+
* ```js
|
|
1237
|
+
* const { data, error } = await supabase
|
|
1238
|
+
* .storage
|
|
1239
|
+
* .from('avatars')
|
|
1240
|
+
* .remove(['folder/avatar1.png'])
|
|
1241
|
+
* ```
|
|
1242
|
+
*
|
|
1243
|
+
* Response:
|
|
1244
|
+
* ```json
|
|
1245
|
+
* {
|
|
1246
|
+
* "data": [],
|
|
1247
|
+
* "error": null
|
|
1248
|
+
* }
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
remove(paths: string[]): Promise<{
|
|
1252
|
+
data: FileObject[];
|
|
1253
|
+
error: null;
|
|
1254
|
+
} | {
|
|
1255
|
+
data: null;
|
|
1256
|
+
error: StorageError;
|
|
1257
|
+
}>;
|
|
1258
|
+
/**
|
|
1259
|
+
* Get file metadata
|
|
1260
|
+
* @param id the file id to retrieve metadata
|
|
1261
|
+
*/
|
|
1262
|
+
/**
|
|
1263
|
+
* Update file metadata
|
|
1264
|
+
* @param id the file id to update metadata
|
|
1265
|
+
* @param meta the new file metadata
|
|
1266
|
+
*/
|
|
1267
|
+
/**
|
|
1268
|
+
* Lists all the files and folders within a path of the bucket.
|
|
1269
|
+
*
|
|
1270
|
+
* @category File Buckets
|
|
1271
|
+
* @param path The folder path.
|
|
1272
|
+
* @param options Search options including limit (defaults to 100), offset, sortBy, and search
|
|
1273
|
+
* @param parameters Optional fetch parameters including signal for cancellation
|
|
1274
|
+
* @returns Promise with response containing array of files or error
|
|
1275
|
+
*
|
|
1276
|
+
* @example List files in a bucket
|
|
1277
|
+
* ```js
|
|
1278
|
+
* const { data, error } = await supabase
|
|
1279
|
+
* .storage
|
|
1280
|
+
* .from('avatars')
|
|
1281
|
+
* .list('folder', {
|
|
1282
|
+
* limit: 100,
|
|
1283
|
+
* offset: 0,
|
|
1284
|
+
* sortBy: { column: 'name', order: 'asc' },
|
|
1285
|
+
* })
|
|
1286
|
+
* ```
|
|
1287
|
+
*
|
|
1288
|
+
* Response:
|
|
1289
|
+
* ```json
|
|
1290
|
+
* {
|
|
1291
|
+
* "data": [
|
|
1292
|
+
* {
|
|
1293
|
+
* "name": "avatar1.png",
|
|
1294
|
+
* "id": "e668cf7f-821b-4a2f-9dce-7dfa5dd1cfd2",
|
|
1295
|
+
* "updated_at": "2024-05-22T23:06:05.580Z",
|
|
1296
|
+
* "created_at": "2024-05-22T23:04:34.443Z",
|
|
1297
|
+
* "last_accessed_at": "2024-05-22T23:04:34.443Z",
|
|
1298
|
+
* "metadata": {
|
|
1299
|
+
* "eTag": "\"c5e8c553235d9af30ef4f6e280790b92\"",
|
|
1300
|
+
* "size": 32175,
|
|
1301
|
+
* "mimetype": "image/png",
|
|
1302
|
+
* "cacheControl": "max-age=3600",
|
|
1303
|
+
* "lastModified": "2024-05-22T23:06:05.574Z",
|
|
1304
|
+
* "contentLength": 32175,
|
|
1305
|
+
* "httpStatusCode": 200
|
|
1306
|
+
* }
|
|
1307
|
+
* }
|
|
1308
|
+
* ],
|
|
1309
|
+
* "error": null
|
|
1310
|
+
* }
|
|
1311
|
+
* ```
|
|
1312
|
+
*
|
|
1313
|
+
* @example Search files in a bucket
|
|
1314
|
+
* ```js
|
|
1315
|
+
* const { data, error } = await supabase
|
|
1316
|
+
* .storage
|
|
1317
|
+
* .from('avatars')
|
|
1318
|
+
* .list('folder', {
|
|
1319
|
+
* limit: 100,
|
|
1320
|
+
* offset: 0,
|
|
1321
|
+
* sortBy: { column: 'name', order: 'asc' },
|
|
1322
|
+
* search: 'jon'
|
|
1323
|
+
* })
|
|
1324
|
+
* ```
|
|
1325
|
+
*/
|
|
1326
|
+
list(path?: string, options?: SearchOptions, parameters?: FetchParameters): Promise<{
|
|
1327
|
+
data: FileObject[];
|
|
1328
|
+
error: null;
|
|
1329
|
+
} | {
|
|
1330
|
+
data: null;
|
|
1331
|
+
error: StorageError;
|
|
1332
|
+
}>;
|
|
1333
|
+
/**
|
|
1334
|
+
* @experimental this method signature might change in the future
|
|
1335
|
+
*
|
|
1336
|
+
* @category File Buckets
|
|
1337
|
+
* @param options search options
|
|
1338
|
+
* @param parameters
|
|
1339
|
+
*/
|
|
1340
|
+
listV2(options?: SearchV2Options, parameters?: FetchParameters): Promise<{
|
|
1341
|
+
data: SearchV2Result;
|
|
1342
|
+
error: null;
|
|
1343
|
+
} | {
|
|
1344
|
+
data: null;
|
|
1345
|
+
error: StorageError;
|
|
1346
|
+
}>;
|
|
1347
|
+
protected encodeMetadata(metadata: Record<string, any>): string;
|
|
1348
|
+
toBase64(data: string): string;
|
|
1349
|
+
private _getFinalPath;
|
|
1350
|
+
private _removeEmptyFolders;
|
|
1351
|
+
private transformOptsToQueryString;
|
|
1835
1352
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1353
|
+
//#endregion
|
|
1354
|
+
//#region src/packages/StorageBucketApi.d.ts
|
|
1355
|
+
declare class StorageBucketApi extends BaseApiClient<StorageError> {
|
|
1356
|
+
constructor(url: string, headers?: {
|
|
1357
|
+
[key: string]: string;
|
|
1358
|
+
}, fetch?: Fetch, opts?: StorageClientOptions);
|
|
1359
|
+
/**
|
|
1360
|
+
* Retrieves the details of all Storage buckets within an existing project.
|
|
1361
|
+
*
|
|
1362
|
+
* @category File Buckets
|
|
1363
|
+
* @param options Query parameters for listing buckets
|
|
1364
|
+
* @param options.limit Maximum number of buckets to return
|
|
1365
|
+
* @param options.offset Number of buckets to skip
|
|
1366
|
+
* @param options.sortColumn Column to sort by ('id', 'name', 'created_at', 'updated_at')
|
|
1367
|
+
* @param options.sortOrder Sort order ('asc' or 'desc')
|
|
1368
|
+
* @param options.search Search term to filter bucket names
|
|
1369
|
+
* @returns Promise with response containing array of buckets or error
|
|
1370
|
+
*
|
|
1371
|
+
* @example List buckets
|
|
1372
|
+
* ```js
|
|
1373
|
+
* const { data, error } = await supabase
|
|
1374
|
+
* .storage
|
|
1375
|
+
* .listBuckets()
|
|
1376
|
+
* ```
|
|
1377
|
+
*
|
|
1378
|
+
* @example List buckets with options
|
|
1379
|
+
* ```js
|
|
1380
|
+
* const { data, error } = await supabase
|
|
1381
|
+
* .storage
|
|
1382
|
+
* .listBuckets({
|
|
1383
|
+
* limit: 10,
|
|
1384
|
+
* offset: 0,
|
|
1385
|
+
* sortColumn: 'created_at',
|
|
1386
|
+
* sortOrder: 'desc',
|
|
1387
|
+
* search: 'prod'
|
|
1388
|
+
* })
|
|
1389
|
+
* ```
|
|
1390
|
+
*/
|
|
1391
|
+
listBuckets(options?: ListBucketOptions): Promise<{
|
|
1392
|
+
data: Bucket[];
|
|
1393
|
+
error: null;
|
|
1394
|
+
} | {
|
|
1395
|
+
data: null;
|
|
1396
|
+
error: StorageError;
|
|
1397
|
+
}>;
|
|
1398
|
+
/**
|
|
1399
|
+
* Retrieves the details of an existing Storage bucket.
|
|
1400
|
+
*
|
|
1401
|
+
* @category File Buckets
|
|
1402
|
+
* @param id The unique identifier of the bucket you would like to retrieve.
|
|
1403
|
+
* @returns Promise with response containing bucket details or error
|
|
1404
|
+
*
|
|
1405
|
+
* @example Get bucket
|
|
1406
|
+
* ```js
|
|
1407
|
+
* const { data, error } = await supabase
|
|
1408
|
+
* .storage
|
|
1409
|
+
* .getBucket('avatars')
|
|
1410
|
+
* ```
|
|
1411
|
+
*
|
|
1412
|
+
* Response:
|
|
1413
|
+
* ```json
|
|
1414
|
+
* {
|
|
1415
|
+
* "data": {
|
|
1416
|
+
* "id": "avatars",
|
|
1417
|
+
* "name": "avatars",
|
|
1418
|
+
* "owner": "",
|
|
1419
|
+
* "public": false,
|
|
1420
|
+
* "file_size_limit": 1024,
|
|
1421
|
+
* "allowed_mime_types": [
|
|
1422
|
+
* "image/png"
|
|
1423
|
+
* ],
|
|
1424
|
+
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
1425
|
+
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
1426
|
+
* },
|
|
1427
|
+
* "error": null
|
|
1428
|
+
* }
|
|
1429
|
+
* ```
|
|
1430
|
+
*/
|
|
1431
|
+
getBucket(id: string): Promise<{
|
|
1432
|
+
data: Bucket;
|
|
1433
|
+
error: null;
|
|
1434
|
+
} | {
|
|
1435
|
+
data: null;
|
|
1436
|
+
error: StorageError;
|
|
1437
|
+
}>;
|
|
1438
|
+
/**
|
|
1439
|
+
* Creates a new Storage bucket
|
|
1440
|
+
*
|
|
1441
|
+
* @category File Buckets
|
|
1442
|
+
* @param id A unique identifier for the bucket you are creating.
|
|
1443
|
+
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.
|
|
1444
|
+
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
1445
|
+
* The global file size limit takes precedence over this value.
|
|
1446
|
+
* The default value is null, which doesn't set a per bucket file size limit.
|
|
1447
|
+
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
1448
|
+
* The default value is null, which allows files with all mime types to be uploaded.
|
|
1449
|
+
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
1450
|
+
* @param options.type (private-beta) specifies the bucket type. see `BucketType` for more details.
|
|
1451
|
+
* - default bucket type is `STANDARD`
|
|
1452
|
+
* @returns Promise with response containing newly created bucket name or error
|
|
1453
|
+
*
|
|
1454
|
+
* @example Create bucket
|
|
1455
|
+
* ```js
|
|
1456
|
+
* const { data, error } = await supabase
|
|
1457
|
+
* .storage
|
|
1458
|
+
* .createBucket('avatars', {
|
|
1459
|
+
* public: false,
|
|
1460
|
+
* allowedMimeTypes: ['image/png'],
|
|
1461
|
+
* fileSizeLimit: 1024
|
|
1462
|
+
* })
|
|
1463
|
+
* ```
|
|
1464
|
+
*
|
|
1465
|
+
* Response:
|
|
1466
|
+
* ```json
|
|
1467
|
+
* {
|
|
1468
|
+
* "data": {
|
|
1469
|
+
* "name": "avatars"
|
|
1470
|
+
* },
|
|
1471
|
+
* "error": null
|
|
1472
|
+
* }
|
|
1473
|
+
* ```
|
|
1474
|
+
*/
|
|
1475
|
+
createBucket(id: string, options?: {
|
|
1476
|
+
public: boolean;
|
|
1477
|
+
fileSizeLimit?: number | string | null;
|
|
1478
|
+
allowedMimeTypes?: string[] | null;
|
|
1479
|
+
type?: BucketType;
|
|
1480
|
+
}): Promise<{
|
|
1481
|
+
data: Pick<Bucket, 'name'>;
|
|
1482
|
+
error: null;
|
|
1483
|
+
} | {
|
|
1484
|
+
data: null;
|
|
1485
|
+
error: StorageError;
|
|
1486
|
+
}>;
|
|
1487
|
+
/**
|
|
1488
|
+
* Updates a Storage bucket
|
|
1489
|
+
*
|
|
1490
|
+
* @category File Buckets
|
|
1491
|
+
* @param id A unique identifier for the bucket you are updating.
|
|
1492
|
+
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations.
|
|
1493
|
+
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
1494
|
+
* The global file size limit takes precedence over this value.
|
|
1495
|
+
* The default value is null, which doesn't set a per bucket file size limit.
|
|
1496
|
+
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
1497
|
+
* The default value is null, which allows files with all mime types to be uploaded.
|
|
1498
|
+
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
1499
|
+
* @returns Promise with response containing success message or error
|
|
1500
|
+
*
|
|
1501
|
+
* @example Update bucket
|
|
1502
|
+
* ```js
|
|
1503
|
+
* const { data, error } = await supabase
|
|
1504
|
+
* .storage
|
|
1505
|
+
* .updateBucket('avatars', {
|
|
1506
|
+
* public: false,
|
|
1507
|
+
* allowedMimeTypes: ['image/png'],
|
|
1508
|
+
* fileSizeLimit: 1024
|
|
1509
|
+
* })
|
|
1510
|
+
* ```
|
|
1511
|
+
*
|
|
1512
|
+
* Response:
|
|
1513
|
+
* ```json
|
|
1514
|
+
* {
|
|
1515
|
+
* "data": {
|
|
1516
|
+
* "message": "Successfully updated"
|
|
1517
|
+
* },
|
|
1518
|
+
* "error": null
|
|
1519
|
+
* }
|
|
1520
|
+
* ```
|
|
1521
|
+
*/
|
|
1522
|
+
updateBucket(id: string, options: {
|
|
1523
|
+
public: boolean;
|
|
1524
|
+
fileSizeLimit?: number | string | null;
|
|
1525
|
+
allowedMimeTypes?: string[] | null;
|
|
1526
|
+
}): Promise<{
|
|
1527
|
+
data: {
|
|
1528
|
+
message: string;
|
|
1529
|
+
};
|
|
1530
|
+
error: null;
|
|
1531
|
+
} | {
|
|
1532
|
+
data: null;
|
|
1533
|
+
error: StorageError;
|
|
1534
|
+
}>;
|
|
1535
|
+
/**
|
|
1536
|
+
* Removes all objects inside a single bucket.
|
|
1537
|
+
*
|
|
1538
|
+
* @category File Buckets
|
|
1539
|
+
* @param id The unique identifier of the bucket you would like to empty.
|
|
1540
|
+
* @returns Promise with success message or error
|
|
1541
|
+
*
|
|
1542
|
+
* @example Empty bucket
|
|
1543
|
+
* ```js
|
|
1544
|
+
* const { data, error } = await supabase
|
|
1545
|
+
* .storage
|
|
1546
|
+
* .emptyBucket('avatars')
|
|
1547
|
+
* ```
|
|
1548
|
+
*
|
|
1549
|
+
* Response:
|
|
1550
|
+
* ```json
|
|
1551
|
+
* {
|
|
1552
|
+
* "data": {
|
|
1553
|
+
* "message": "Successfully emptied"
|
|
1554
|
+
* },
|
|
1555
|
+
* "error": null
|
|
1556
|
+
* }
|
|
1557
|
+
* ```
|
|
1558
|
+
*/
|
|
1559
|
+
emptyBucket(id: string): Promise<{
|
|
1560
|
+
data: {
|
|
1561
|
+
message: string;
|
|
1562
|
+
};
|
|
1563
|
+
error: null;
|
|
1564
|
+
} | {
|
|
1565
|
+
data: null;
|
|
1566
|
+
error: StorageError;
|
|
1567
|
+
}>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
|
|
1570
|
+
* You must first `empty()` the bucket.
|
|
1571
|
+
*
|
|
1572
|
+
* @category File Buckets
|
|
1573
|
+
* @param id The unique identifier of the bucket you would like to delete.
|
|
1574
|
+
* @returns Promise with success message or error
|
|
1575
|
+
*
|
|
1576
|
+
* @example Delete bucket
|
|
1577
|
+
* ```js
|
|
1578
|
+
* const { data, error } = await supabase
|
|
1579
|
+
* .storage
|
|
1580
|
+
* .deleteBucket('avatars')
|
|
1581
|
+
* ```
|
|
1582
|
+
*
|
|
1583
|
+
* Response:
|
|
1584
|
+
* ```json
|
|
1585
|
+
* {
|
|
1586
|
+
* "data": {
|
|
1587
|
+
* "message": "Successfully deleted"
|
|
1588
|
+
* },
|
|
1589
|
+
* "error": null
|
|
1590
|
+
* }
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
deleteBucket(id: string): Promise<{
|
|
1594
|
+
data: {
|
|
1595
|
+
message: string;
|
|
1596
|
+
};
|
|
1597
|
+
error: null;
|
|
1598
|
+
} | {
|
|
1599
|
+
data: null;
|
|
1600
|
+
error: StorageError;
|
|
1601
|
+
}>;
|
|
1602
|
+
private listBucketOptionsToQueryString;
|
|
1842
1603
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
*/
|
|
1848
|
-
interface SuccessResponse<T> {
|
|
1849
|
-
data: T;
|
|
1604
|
+
//#endregion
|
|
1605
|
+
//#region src/packages/StorageAnalyticsClient.d.ts
|
|
1606
|
+
type WrapAsyncMethod<T> = T extends ((...args: infer A) => Promise<infer R>) ? (...args: A) => Promise<{
|
|
1607
|
+
data: R;
|
|
1850
1608
|
error: null;
|
|
1851
|
-
}
|
|
1852
|
-
/**
|
|
1853
|
-
* Standard response wrapper for failed operations
|
|
1854
|
-
* @property data - Null on error
|
|
1855
|
-
* @property error - StorageVectorsError with details
|
|
1856
|
-
*/
|
|
1857
|
-
interface ErrorResponse {
|
|
1609
|
+
} | {
|
|
1858
1610
|
data: null;
|
|
1859
|
-
error:
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
* Union type for all API responses
|
|
1863
|
-
* Follows the pattern: { data: T, error: null } | { data: null, error: Error }
|
|
1864
|
-
*/
|
|
1865
|
-
type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
|
|
1866
|
-
//#endregion
|
|
1867
|
-
//#region src/lib/vectors/fetch.d.ts
|
|
1868
|
-
type Fetch = typeof fetch;
|
|
1611
|
+
error: IcebergError;
|
|
1612
|
+
}> : T;
|
|
1613
|
+
type WrappedIcebergRestCatalog = { [K in keyof IcebergRestCatalog]: WrapAsyncMethod<IcebergRestCatalog[K]> };
|
|
1869
1614
|
/**
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
1872
|
-
* @property noResolveJson - If true, return raw Response instead of parsing JSON
|
|
1615
|
+
* Client class for managing Analytics Buckets using Iceberg tables
|
|
1616
|
+
* Provides methods for creating, listing, and deleting analytics buckets
|
|
1873
1617
|
*/
|
|
1874
|
-
|
|
1875
|
-
|
|
1618
|
+
declare class StorageAnalyticsClient extends BaseApiClient<StorageError> {
|
|
1619
|
+
/**
|
|
1620
|
+
* @alpha
|
|
1621
|
+
*
|
|
1622
|
+
* Creates a new StorageAnalyticsClient instance
|
|
1623
|
+
*
|
|
1624
|
+
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1625
|
+
*
|
|
1626
|
+
* @category Analytics Buckets
|
|
1627
|
+
* @param url - The base URL for the storage API
|
|
1628
|
+
* @param headers - HTTP headers to include in requests
|
|
1629
|
+
* @param fetch - Optional custom fetch implementation
|
|
1630
|
+
*
|
|
1631
|
+
* @example
|
|
1632
|
+
* ```typescript
|
|
1633
|
+
* const client = new StorageAnalyticsClient(url, headers)
|
|
1634
|
+
* ```
|
|
1635
|
+
*/
|
|
1636
|
+
constructor(url: string, headers?: {
|
|
1876
1637
|
[key: string]: string;
|
|
1877
|
-
};
|
|
1878
|
-
|
|
1638
|
+
}, fetch?: Fetch);
|
|
1639
|
+
/**
|
|
1640
|
+
* @alpha
|
|
1641
|
+
*
|
|
1642
|
+
* Creates a new analytics bucket using Iceberg tables
|
|
1643
|
+
* Analytics buckets are optimized for analytical queries and data processing
|
|
1644
|
+
*
|
|
1645
|
+
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1646
|
+
*
|
|
1647
|
+
* @category Analytics Buckets
|
|
1648
|
+
* @param name A unique name for the bucket you are creating
|
|
1649
|
+
* @returns Promise with response containing newly created analytics bucket or error
|
|
1650
|
+
*
|
|
1651
|
+
* @example Create analytics bucket
|
|
1652
|
+
* ```js
|
|
1653
|
+
* const { data, error } = await supabase
|
|
1654
|
+
* .storage
|
|
1655
|
+
* .analytics
|
|
1656
|
+
* .createBucket('analytics-data')
|
|
1657
|
+
* ```
|
|
1658
|
+
*
|
|
1659
|
+
* Response:
|
|
1660
|
+
* ```json
|
|
1661
|
+
* {
|
|
1662
|
+
* "data": {
|
|
1663
|
+
* "name": "analytics-data",
|
|
1664
|
+
* "type": "ANALYTICS",
|
|
1665
|
+
* "format": "iceberg",
|
|
1666
|
+
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
1667
|
+
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
1668
|
+
* },
|
|
1669
|
+
* "error": null
|
|
1670
|
+
* }
|
|
1671
|
+
* ```
|
|
1672
|
+
*/
|
|
1673
|
+
createBucket(name: string): Promise<{
|
|
1674
|
+
data: AnalyticBucket;
|
|
1675
|
+
error: null;
|
|
1676
|
+
} | {
|
|
1677
|
+
data: null;
|
|
1678
|
+
error: StorageError;
|
|
1679
|
+
}>;
|
|
1680
|
+
/**
|
|
1681
|
+
* @alpha
|
|
1682
|
+
*
|
|
1683
|
+
* Retrieves the details of all Analytics Storage buckets within an existing project
|
|
1684
|
+
* Only returns buckets of type 'ANALYTICS'
|
|
1685
|
+
*
|
|
1686
|
+
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1687
|
+
*
|
|
1688
|
+
* @category Analytics Buckets
|
|
1689
|
+
* @param options Query parameters for listing buckets
|
|
1690
|
+
* @param options.limit Maximum number of buckets to return
|
|
1691
|
+
* @param options.offset Number of buckets to skip
|
|
1692
|
+
* @param options.sortColumn Column to sort by ('name', 'created_at', 'updated_at')
|
|
1693
|
+
* @param options.sortOrder Sort order ('asc' or 'desc')
|
|
1694
|
+
* @param options.search Search term to filter bucket names
|
|
1695
|
+
* @returns Promise with response containing array of analytics buckets or error
|
|
1696
|
+
*
|
|
1697
|
+
* @example List analytics buckets
|
|
1698
|
+
* ```js
|
|
1699
|
+
* const { data, error } = await supabase
|
|
1700
|
+
* .storage
|
|
1701
|
+
* .analytics
|
|
1702
|
+
* .listBuckets({
|
|
1703
|
+
* limit: 10,
|
|
1704
|
+
* offset: 0,
|
|
1705
|
+
* sortColumn: 'created_at',
|
|
1706
|
+
* sortOrder: 'desc'
|
|
1707
|
+
* })
|
|
1708
|
+
* ```
|
|
1709
|
+
*
|
|
1710
|
+
* Response:
|
|
1711
|
+
* ```json
|
|
1712
|
+
* {
|
|
1713
|
+
* "data": [
|
|
1714
|
+
* {
|
|
1715
|
+
* "name": "analytics-data",
|
|
1716
|
+
* "type": "ANALYTICS",
|
|
1717
|
+
* "format": "iceberg",
|
|
1718
|
+
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
1719
|
+
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
1720
|
+
* }
|
|
1721
|
+
* ],
|
|
1722
|
+
* "error": null
|
|
1723
|
+
* }
|
|
1724
|
+
* ```
|
|
1725
|
+
*/
|
|
1726
|
+
listBuckets(options?: {
|
|
1727
|
+
limit?: number;
|
|
1728
|
+
offset?: number;
|
|
1729
|
+
sortColumn?: 'name' | 'created_at' | 'updated_at';
|
|
1730
|
+
sortOrder?: 'asc' | 'desc';
|
|
1731
|
+
search?: string;
|
|
1732
|
+
}): Promise<{
|
|
1733
|
+
data: AnalyticBucket[];
|
|
1734
|
+
error: null;
|
|
1735
|
+
} | {
|
|
1736
|
+
data: null;
|
|
1737
|
+
error: StorageError;
|
|
1738
|
+
}>;
|
|
1739
|
+
/**
|
|
1740
|
+
* @alpha
|
|
1741
|
+
*
|
|
1742
|
+
* Deletes an existing analytics bucket
|
|
1743
|
+
* A bucket can't be deleted with existing objects inside it
|
|
1744
|
+
* You must first empty the bucket before deletion
|
|
1745
|
+
*
|
|
1746
|
+
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1747
|
+
*
|
|
1748
|
+
* @category Analytics Buckets
|
|
1749
|
+
* @param bucketName The unique identifier of the bucket you would like to delete
|
|
1750
|
+
* @returns Promise with response containing success message or error
|
|
1751
|
+
*
|
|
1752
|
+
* @example Delete analytics bucket
|
|
1753
|
+
* ```js
|
|
1754
|
+
* const { data, error } = await supabase
|
|
1755
|
+
* .storage
|
|
1756
|
+
* .analytics
|
|
1757
|
+
* .deleteBucket('analytics-data')
|
|
1758
|
+
* ```
|
|
1759
|
+
*
|
|
1760
|
+
* Response:
|
|
1761
|
+
* ```json
|
|
1762
|
+
* {
|
|
1763
|
+
* "data": {
|
|
1764
|
+
* "message": "Successfully deleted"
|
|
1765
|
+
* },
|
|
1766
|
+
* "error": null
|
|
1767
|
+
* }
|
|
1768
|
+
* ```
|
|
1769
|
+
*/
|
|
1770
|
+
deleteBucket(bucketName: string): Promise<{
|
|
1771
|
+
data: {
|
|
1772
|
+
message: string;
|
|
1773
|
+
};
|
|
1774
|
+
error: null;
|
|
1775
|
+
} | {
|
|
1776
|
+
data: null;
|
|
1777
|
+
error: StorageError;
|
|
1778
|
+
}>;
|
|
1779
|
+
/**
|
|
1780
|
+
* @alpha
|
|
1781
|
+
*
|
|
1782
|
+
* Get an Iceberg REST Catalog client configured for a specific analytics bucket
|
|
1783
|
+
* Use this to perform advanced table and namespace operations within the bucket
|
|
1784
|
+
* The returned client provides full access to the Apache Iceberg REST Catalog API
|
|
1785
|
+
* with the Supabase `{ data, error }` pattern for consistent error handling on all operations.
|
|
1786
|
+
*
|
|
1787
|
+
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
1788
|
+
*
|
|
1789
|
+
* @category Analytics Buckets
|
|
1790
|
+
* @param bucketName - The name of the analytics bucket (warehouse) to connect to
|
|
1791
|
+
* @returns The wrapped Iceberg catalog client
|
|
1792
|
+
* @throws {StorageError} If the bucket name is invalid
|
|
1793
|
+
*
|
|
1794
|
+
* @example Get catalog and create table
|
|
1795
|
+
* ```js
|
|
1796
|
+
* // First, create an analytics bucket
|
|
1797
|
+
* const { data: bucket, error: bucketError } = await supabase
|
|
1798
|
+
* .storage
|
|
1799
|
+
* .analytics
|
|
1800
|
+
* .createBucket('analytics-data')
|
|
1801
|
+
*
|
|
1802
|
+
* // Get the Iceberg catalog for that bucket
|
|
1803
|
+
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1804
|
+
*
|
|
1805
|
+
* // Create a namespace
|
|
1806
|
+
* const { error: nsError } = await catalog.createNamespace({ namespace: ['default'] })
|
|
1807
|
+
*
|
|
1808
|
+
* // Create a table with schema
|
|
1809
|
+
* const { data: tableMetadata, error: tableError } = await catalog.createTable(
|
|
1810
|
+
* { namespace: ['default'] },
|
|
1811
|
+
* {
|
|
1812
|
+
* name: 'events',
|
|
1813
|
+
* schema: {
|
|
1814
|
+
* type: 'struct',
|
|
1815
|
+
* fields: [
|
|
1816
|
+
* { id: 1, name: 'id', type: 'long', required: true },
|
|
1817
|
+
* { id: 2, name: 'timestamp', type: 'timestamp', required: true },
|
|
1818
|
+
* { id: 3, name: 'user_id', type: 'string', required: false }
|
|
1819
|
+
* ],
|
|
1820
|
+
* 'schema-id': 0,
|
|
1821
|
+
* 'identifier-field-ids': [1]
|
|
1822
|
+
* },
|
|
1823
|
+
* 'partition-spec': {
|
|
1824
|
+
* 'spec-id': 0,
|
|
1825
|
+
* fields: []
|
|
1826
|
+
* },
|
|
1827
|
+
* 'write-order': {
|
|
1828
|
+
* 'order-id': 0,
|
|
1829
|
+
* fields: []
|
|
1830
|
+
* },
|
|
1831
|
+
* properties: {
|
|
1832
|
+
* 'write.format.default': 'parquet'
|
|
1833
|
+
* }
|
|
1834
|
+
* }
|
|
1835
|
+
* )
|
|
1836
|
+
* ```
|
|
1837
|
+
*
|
|
1838
|
+
* @example List tables in namespace
|
|
1839
|
+
* ```js
|
|
1840
|
+
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1841
|
+
*
|
|
1842
|
+
* // List all tables in the default namespace
|
|
1843
|
+
* const { data: tables, error: listError } = await catalog.listTables({ namespace: ['default'] })
|
|
1844
|
+
* if (listError) {
|
|
1845
|
+
* if (listError.isNotFound()) {
|
|
1846
|
+
* console.log('Namespace not found')
|
|
1847
|
+
* }
|
|
1848
|
+
* return
|
|
1849
|
+
* }
|
|
1850
|
+
* console.log(tables) // [{ namespace: ['default'], name: 'events' }]
|
|
1851
|
+
* ```
|
|
1852
|
+
*
|
|
1853
|
+
* @example Working with namespaces
|
|
1854
|
+
* ```js
|
|
1855
|
+
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1856
|
+
*
|
|
1857
|
+
* // List all namespaces
|
|
1858
|
+
* const { data: namespaces } = await catalog.listNamespaces()
|
|
1859
|
+
*
|
|
1860
|
+
* // Create namespace with properties
|
|
1861
|
+
* await catalog.createNamespace(
|
|
1862
|
+
* { namespace: ['production'] },
|
|
1863
|
+
* { properties: { owner: 'data-team', env: 'prod' } }
|
|
1864
|
+
* )
|
|
1865
|
+
* ```
|
|
1866
|
+
*
|
|
1867
|
+
* @example Cleanup operations
|
|
1868
|
+
* ```js
|
|
1869
|
+
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
1870
|
+
*
|
|
1871
|
+
* // Drop table with purge option (removes all data)
|
|
1872
|
+
* const { error: dropError } = await catalog.dropTable(
|
|
1873
|
+
* { namespace: ['default'], name: 'events' },
|
|
1874
|
+
* { purge: true }
|
|
1875
|
+
* )
|
|
1876
|
+
*
|
|
1877
|
+
* if (dropError?.isNotFound()) {
|
|
1878
|
+
* console.log('Table does not exist')
|
|
1879
|
+
* }
|
|
1880
|
+
*
|
|
1881
|
+
* // Drop namespace (must be empty)
|
|
1882
|
+
* await catalog.dropNamespace({ namespace: ['default'] })
|
|
1883
|
+
* ```
|
|
1884
|
+
*
|
|
1885
|
+
* @remarks
|
|
1886
|
+
* This method provides a bridge between Supabase's bucket management and the standard
|
|
1887
|
+
* Apache Iceberg REST Catalog API. The bucket name maps to the Iceberg warehouse parameter.
|
|
1888
|
+
* All authentication and configuration is handled automatically using your Supabase credentials.
|
|
1889
|
+
*
|
|
1890
|
+
* **Error Handling**: Invalid bucket names throw immediately. All catalog
|
|
1891
|
+
* operations return `{ data, error }` where errors are `IcebergError` instances from iceberg-js.
|
|
1892
|
+
* Use helper methods like `error.isNotFound()` or check `error.status` for specific error handling.
|
|
1893
|
+
* Use `.throwOnError()` on the analytics client if you prefer exceptions for catalog operations.
|
|
1894
|
+
*
|
|
1895
|
+
* **Cleanup Operations**: When using `dropTable`, the `purge: true` option permanently
|
|
1896
|
+
* deletes all table data. Without it, the table is marked as deleted but data remains.
|
|
1897
|
+
*
|
|
1898
|
+
* **Library Dependency**: The returned catalog wraps `IcebergRestCatalog` from iceberg-js.
|
|
1899
|
+
* For complete API documentation and advanced usage, refer to the
|
|
1900
|
+
* [iceberg-js documentation](https://supabase.github.io/iceberg-js/).
|
|
1901
|
+
*/
|
|
1902
|
+
from(bucketName: string): WrappedIcebergRestCatalog;
|
|
1879
1903
|
}
|
|
1880
|
-
/**
|
|
1881
|
-
* HTTP methods supported by the API
|
|
1882
|
-
*/
|
|
1883
|
-
type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
1884
1904
|
//#endregion
|
|
1885
|
-
//#region src/
|
|
1905
|
+
//#region src/packages/VectorIndexApi.d.ts
|
|
1886
1906
|
/**
|
|
1887
1907
|
* @alpha
|
|
1888
1908
|
*
|
|
@@ -1903,19 +1923,11 @@ interface CreateIndexOptions {
|
|
|
1903
1923
|
* Base implementation for vector index operations.
|
|
1904
1924
|
* Use {@link VectorBucketScope} via `supabase.storage.vectors.from('bucket')` instead.
|
|
1905
1925
|
*/
|
|
1906
|
-
declare class VectorIndexApi {
|
|
1907
|
-
protected url: string;
|
|
1908
|
-
protected headers: {
|
|
1909
|
-
[key: string]: string;
|
|
1910
|
-
};
|
|
1911
|
-
protected fetch: Fetch;
|
|
1912
|
-
protected shouldThrowOnError: boolean;
|
|
1926
|
+
declare class VectorIndexApi extends BaseApiClient<StorageError> {
|
|
1913
1927
|
/** Creates a new VectorIndexApi instance */
|
|
1914
1928
|
constructor(url: string, headers?: {
|
|
1915
1929
|
[key: string]: string;
|
|
1916
1930
|
}, fetch?: Fetch);
|
|
1917
|
-
/** Enable throwing errors instead of returning them in the response */
|
|
1918
|
-
throwOnError(): this;
|
|
1919
1931
|
/** Creates a new vector index within a bucket */
|
|
1920
1932
|
createIndex(options: CreateIndexOptions): Promise<ApiResponse<undefined>>;
|
|
1921
1933
|
/** Retrieves metadata for a specific vector index */
|
|
@@ -1928,25 +1940,17 @@ declare class VectorIndexApi {
|
|
|
1928
1940
|
deleteIndex(vectorBucketName: string, indexName: string): Promise<ApiResponse<undefined>>;
|
|
1929
1941
|
}
|
|
1930
1942
|
//#endregion
|
|
1931
|
-
//#region src/
|
|
1943
|
+
//#region src/packages/VectorDataApi.d.ts
|
|
1932
1944
|
/**
|
|
1933
1945
|
* @hidden
|
|
1934
1946
|
* Base implementation for vector data operations.
|
|
1935
1947
|
* Use {@link VectorIndexScope} via `supabase.storage.vectors.from('bucket').index('idx')` instead.
|
|
1936
1948
|
*/
|
|
1937
|
-
declare class VectorDataApi {
|
|
1938
|
-
protected url: string;
|
|
1939
|
-
protected headers: {
|
|
1940
|
-
[key: string]: string;
|
|
1941
|
-
};
|
|
1942
|
-
protected fetch: Fetch;
|
|
1943
|
-
protected shouldThrowOnError: boolean;
|
|
1949
|
+
declare class VectorDataApi extends BaseApiClient<StorageError> {
|
|
1944
1950
|
/** Creates a new VectorDataApi instance */
|
|
1945
1951
|
constructor(url: string, headers?: {
|
|
1946
1952
|
[key: string]: string;
|
|
1947
1953
|
}, fetch?: Fetch);
|
|
1948
|
-
/** Enable throwing errors instead of returning them in the response */
|
|
1949
|
-
throwOnError(): this;
|
|
1950
1954
|
/** Inserts or updates vectors in batch (1-500 per request) */
|
|
1951
1955
|
putVectors(options: PutVectorsOptions): Promise<ApiResponse<undefined>>;
|
|
1952
1956
|
/** Retrieves vectors by their keys in batch */
|
|
@@ -1959,25 +1963,17 @@ declare class VectorDataApi {
|
|
|
1959
1963
|
deleteVectors(options: DeleteVectorsOptions): Promise<ApiResponse<undefined>>;
|
|
1960
1964
|
}
|
|
1961
1965
|
//#endregion
|
|
1962
|
-
//#region src/
|
|
1966
|
+
//#region src/packages/VectorBucketApi.d.ts
|
|
1963
1967
|
/**
|
|
1964
1968
|
* @hidden
|
|
1965
1969
|
* Base implementation for vector bucket operations.
|
|
1966
1970
|
* Use {@link StorageVectorsClient} via `supabase.storage.vectors` instead.
|
|
1967
1971
|
*/
|
|
1968
|
-
declare class VectorBucketApi {
|
|
1969
|
-
protected url: string;
|
|
1970
|
-
protected headers: {
|
|
1971
|
-
[key: string]: string;
|
|
1972
|
-
};
|
|
1973
|
-
protected fetch: Fetch;
|
|
1974
|
-
protected shouldThrowOnError: boolean;
|
|
1972
|
+
declare class VectorBucketApi extends BaseApiClient<StorageError> {
|
|
1975
1973
|
/** Creates a new VectorBucketApi instance */
|
|
1976
1974
|
constructor(url: string, headers?: {
|
|
1977
1975
|
[key: string]: string;
|
|
1978
1976
|
}, fetch?: Fetch);
|
|
1979
|
-
/** Enable throwing errors instead of returning them in the response */
|
|
1980
|
-
throwOnError(): this;
|
|
1981
1977
|
/** Creates a new vector bucket */
|
|
1982
1978
|
createBucket(vectorBucketName: string): Promise<ApiResponse<undefined>>;
|
|
1983
1979
|
/** Retrieves metadata for a specific vector bucket */
|
|
@@ -1990,7 +1986,7 @@ declare class VectorBucketApi {
|
|
|
1990
1986
|
deleteBucket(vectorBucketName: string): Promise<ApiResponse<undefined>>;
|
|
1991
1987
|
}
|
|
1992
1988
|
//#endregion
|
|
1993
|
-
//#region src/
|
|
1989
|
+
//#region src/packages/StorageVectorsClient.d.ts
|
|
1994
1990
|
/**
|
|
1995
1991
|
*
|
|
1996
1992
|
* @alpha
|
|
@@ -2491,52 +2487,6 @@ declare class VectorIndexScope extends VectorDataApi {
|
|
|
2491
2487
|
deleteVectors(options: Omit<DeleteVectorsOptions, 'vectorBucketName' | 'indexName'>): Promise<ApiResponse<undefined>>;
|
|
2492
2488
|
}
|
|
2493
2489
|
//#endregion
|
|
2494
|
-
//#region src/lib/vectors/helpers.d.ts
|
|
2495
|
-
type Fetch$2 = typeof fetch;
|
|
2496
|
-
/**
|
|
2497
|
-
* Resolves the fetch implementation to use
|
|
2498
|
-
* Uses custom fetch if provided, otherwise uses native fetch
|
|
2499
|
-
*
|
|
2500
|
-
* @param customFetch - Optional custom fetch implementation
|
|
2501
|
-
* @returns Resolved fetch function
|
|
2502
|
-
*/
|
|
2503
|
-
declare const resolveFetch: (customFetch?: Fetch$2) => Fetch$2;
|
|
2504
|
-
/**
|
|
2505
|
-
* Resolves the Response constructor to use
|
|
2506
|
-
* Returns native Response constructor
|
|
2507
|
-
*
|
|
2508
|
-
* @returns Response constructor
|
|
2509
|
-
*/
|
|
2510
|
-
declare const resolveResponse: () => typeof Response;
|
|
2511
|
-
/**
|
|
2512
|
-
* Determine if input is a plain object
|
|
2513
|
-
* An object is plain if it's created by either {}, new Object(), or Object.create(null)
|
|
2514
|
-
*
|
|
2515
|
-
* @param value - Value to check
|
|
2516
|
-
* @returns True if value is a plain object
|
|
2517
|
-
* @source https://github.com/sindresorhus/is-plain-obj
|
|
2518
|
-
*/
|
|
2519
|
-
declare const isPlainObject: (value: object) => boolean;
|
|
2520
|
-
/**
|
|
2521
|
-
* Normalizes a number array to float32 format
|
|
2522
|
-
* Ensures all vector values are valid 32-bit floats
|
|
2523
|
-
*
|
|
2524
|
-
* @param values - Array of numbers to normalize
|
|
2525
|
-
* @returns Normalized float32 array
|
|
2526
|
-
*/
|
|
2527
|
-
declare const normalizeToFloat32: (values: number[]) => number[];
|
|
2528
|
-
/**
|
|
2529
|
-
* Validates vector dimensions match expected dimension
|
|
2530
|
-
* Throws error if dimensions don't match
|
|
2531
|
-
*
|
|
2532
|
-
* @param vector - Vector data to validate
|
|
2533
|
-
* @param expectedDimension - Expected vector dimension
|
|
2534
|
-
* @throws Error if dimensions don't match
|
|
2535
|
-
*/
|
|
2536
|
-
declare const validateVectorDimension: (vector: {
|
|
2537
|
-
float32: number[];
|
|
2538
|
-
}, expectedDimension?: number) => void;
|
|
2539
|
-
//#endregion
|
|
2540
2490
|
//#region src/StorageClient.d.ts
|
|
2541
2491
|
interface StorageClientOptions {
|
|
2542
2492
|
useNewHostname?: boolean;
|
|
@@ -2558,7 +2508,7 @@ declare class StorageClient extends StorageBucketApi {
|
|
|
2558
2508
|
*/
|
|
2559
2509
|
constructor(url: string, headers?: {
|
|
2560
2510
|
[key: string]: string;
|
|
2561
|
-
}, fetch?: Fetch
|
|
2511
|
+
}, fetch?: Fetch, opts?: StorageClientOptions);
|
|
2562
2512
|
/**
|
|
2563
2513
|
* Perform file operation in a bucket.
|
|
2564
2514
|
*
|
|
@@ -2597,5 +2547,5 @@ declare class StorageClient extends StorageBucketApi {
|
|
|
2597
2547
|
get analytics(): StorageAnalyticsClient;
|
|
2598
2548
|
}
|
|
2599
2549
|
//#endregion
|
|
2600
|
-
export { AnalyticBucket, ApiResponse, Bucket, BucketType, Camelize, CreateIndexOptions, DeleteVectorsOptions, DestinationOptions, DistanceMetric, DownloadResult, EncryptionConfiguration,
|
|
2550
|
+
export { AnalyticBucket, ApiResponse, Bucket, BucketType, Camelize, type CreateIndexOptions, DeleteVectorsOptions, DestinationOptions, DistanceMetric, DownloadResult, EncryptionConfiguration, ErrorNamespace, ErrorResponse, FetchParameters, FileObject, FileObjectV2, FileOptions, GetVectorsOptions, GetVectorsResponse, ListBucketOptions, ListIndexesOptions, ListIndexesResponse, ListVectorBucketsOptions, ListVectorBucketsResponse, ListVectorsOptions, ListVectorsResponse, Metadata, MetadataConfiguration, PutVectorsOptions, QueryVectorsOptions, QueryVectorsResponse, SearchOptions, SearchV2Folder, SearchV2Object, SearchV2Options, SearchV2Result, SortBy, SortByV2, StorageAnalyticsClient, StorageApiError, StorageClient, type StorageClientOptions, StorageError, StorageUnknownError, StorageVectorsApiError, StorageVectorsClient, type StorageVectorsClientOptions, StorageVectorsError, StorageVectorsErrorCode, StorageVectorsUnknownError, SuccessResponse, TransformOptions, VectorBucket, VectorBucketApi, VectorBucketScope, VectorData, VectorDataApi, VectorDataType, VectorFetchParameters, VectorFilter, VectorIndex, VectorIndexApi, VectorIndexScope, VectorMatch, VectorMetadata, VectorObject, isStorageError, isStorageVectorsError };
|
|
2601
2551
|
//# sourceMappingURL=index.d.cts.map
|