@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.
Files changed (38) hide show
  1. package/dist/index.cjs +476 -865
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +1441 -1491
  4. package/dist/index.d.cts.map +1 -1
  5. package/dist/index.d.mts +1441 -1491
  6. package/dist/index.d.mts.map +1 -1
  7. package/dist/index.mjs +477 -861
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/umd/supabase.js +1 -1
  10. package/package.json +1 -1
  11. package/src/StorageClient.ts +2 -2
  12. package/src/index.ts +15 -2
  13. package/src/lib/common/BaseApiClient.ts +90 -0
  14. package/src/lib/common/errors.ts +144 -0
  15. package/src/lib/common/fetch.ts +286 -0
  16. package/src/lib/{helpers.ts → common/helpers.ts} +71 -17
  17. package/src/lib/types.ts +304 -1
  18. package/src/lib/version.ts +1 -1
  19. package/src/packages/BlobDownloadBuilder.ts +1 -1
  20. package/src/packages/StorageAnalyticsClient.ts +17 -68
  21. package/src/packages/StorageBucketApi.ts +25 -109
  22. package/src/packages/StorageFileApi.ts +44 -172
  23. package/src/{lib/vectors → packages}/StorageVectorsClient.ts +2 -2
  24. package/src/packages/StreamDownloadBuilder.ts +1 -1
  25. package/src/packages/VectorBucketApi.ts +73 -0
  26. package/src/packages/VectorDataApi.ts +98 -0
  27. package/src/{lib/vectors → packages}/VectorIndexApi.ts +21 -66
  28. package/src/lib/errors.ts +0 -43
  29. package/src/lib/fetch.ts +0 -148
  30. package/src/lib/index.ts +0 -5
  31. package/src/lib/vectors/VectorBucketApi.ts +0 -118
  32. package/src/lib/vectors/VectorDataApi.ts +0 -152
  33. package/src/lib/vectors/constants.ts +0 -5
  34. package/src/lib/vectors/errors.ts +0 -78
  35. package/src/lib/vectors/fetch.ts +0 -218
  36. package/src/lib/vectors/helpers.ts +0 -79
  37. package/src/lib/vectors/index.ts +0 -66
  38. package/src/lib/vectors/types.ts +0 -301
package/dist/index.cjs CHANGED
@@ -1,20 +1,36 @@
1
1
  let iceberg_js = require("iceberg-js");
2
2
 
3
- //#region src/lib/errors.ts
3
+ //#region src/lib/common/errors.ts
4
+ /**
5
+ * Base error class for all Storage errors
6
+ * Supports both 'storage' and 'vectors' namespaces
7
+ */
4
8
  var StorageError = class extends Error {
5
- constructor(message) {
9
+ constructor(message, namespace = "storage", status, statusCode) {
6
10
  super(message);
7
11
  this.__isStorageError = true;
8
- this.name = "StorageError";
12
+ this.namespace = namespace;
13
+ this.name = namespace === "vectors" ? "StorageVectorsError" : "StorageError";
14
+ this.status = status;
15
+ this.statusCode = statusCode;
9
16
  }
10
17
  };
18
+ /**
19
+ * Type guard to check if an error is a StorageError
20
+ * @param error - The error to check
21
+ * @returns True if the error is a StorageError
22
+ */
11
23
  function isStorageError(error) {
12
24
  return typeof error === "object" && error !== null && "__isStorageError" in error;
13
25
  }
26
+ /**
27
+ * API error returned from Storage service
28
+ * Includes HTTP status code and service-specific error code
29
+ */
14
30
  var StorageApiError = class extends StorageError {
15
- constructor(message, status, statusCode) {
16
- super(message);
17
- this.name = "StorageApiError";
31
+ constructor(message, status, statusCode, namespace = "storage") {
32
+ super(message, namespace, status, statusCode);
33
+ this.name = namespace === "vectors" ? "StorageVectorsApiError" : "StorageApiError";
18
34
  this.status = status;
19
35
  this.statusCode = statusCode;
20
36
  }
@@ -27,23 +43,105 @@ var StorageApiError = class extends StorageError {
27
43
  };
28
44
  }
29
45
  };
46
+ /**
47
+ * Unknown error that doesn't match expected error patterns
48
+ * Wraps the original error for debugging
49
+ */
30
50
  var StorageUnknownError = class extends StorageError {
31
- constructor(message, originalError) {
32
- super(message);
33
- this.name = "StorageUnknownError";
51
+ constructor(message, originalError, namespace = "storage") {
52
+ super(message, namespace);
53
+ this.name = namespace === "vectors" ? "StorageVectorsUnknownError" : "StorageUnknownError";
34
54
  this.originalError = originalError;
35
55
  }
36
56
  };
57
+ /**
58
+ * @deprecated Use StorageError with namespace='vectors' instead
59
+ * Alias for backward compatibility with existing vector storage code
60
+ */
61
+ var StorageVectorsError = class extends StorageError {
62
+ constructor(message) {
63
+ super(message, "vectors");
64
+ }
65
+ };
66
+ /**
67
+ * Type guard to check if an error is a StorageVectorsError
68
+ * @param error - The error to check
69
+ * @returns True if the error is a StorageVectorsError
70
+ */
71
+ function isStorageVectorsError(error) {
72
+ return isStorageError(error) && error["namespace"] === "vectors";
73
+ }
74
+ /**
75
+ * @deprecated Use StorageApiError with namespace='vectors' instead
76
+ * Alias for backward compatibility with existing vector storage code
77
+ */
78
+ var StorageVectorsApiError = class extends StorageApiError {
79
+ constructor(message, status, statusCode) {
80
+ super(message, status, statusCode, "vectors");
81
+ }
82
+ };
83
+ /**
84
+ * @deprecated Use StorageUnknownError with namespace='vectors' instead
85
+ * Alias for backward compatibility with existing vector storage code
86
+ */
87
+ var StorageVectorsUnknownError = class extends StorageUnknownError {
88
+ constructor(message, originalError) {
89
+ super(message, originalError, "vectors");
90
+ }
91
+ };
92
+ /**
93
+ * Error codes specific to S3 Vectors API
94
+ * Maps AWS service errors to application-friendly error codes
95
+ */
96
+ let StorageVectorsErrorCode = /* @__PURE__ */ function(StorageVectorsErrorCode$1) {
97
+ /** Internal server fault (HTTP 500) */
98
+ StorageVectorsErrorCode$1["InternalError"] = "InternalError";
99
+ /** Resource already exists / conflict (HTTP 409) */
100
+ StorageVectorsErrorCode$1["S3VectorConflictException"] = "S3VectorConflictException";
101
+ /** Resource not found (HTTP 404) */
102
+ StorageVectorsErrorCode$1["S3VectorNotFoundException"] = "S3VectorNotFoundException";
103
+ /** Delete bucket while not empty (HTTP 400) */
104
+ StorageVectorsErrorCode$1["S3VectorBucketNotEmpty"] = "S3VectorBucketNotEmpty";
105
+ /** Exceeds bucket quota/limit (HTTP 400) */
106
+ StorageVectorsErrorCode$1["S3VectorMaxBucketsExceeded"] = "S3VectorMaxBucketsExceeded";
107
+ /** Exceeds index quota/limit (HTTP 400) */
108
+ StorageVectorsErrorCode$1["S3VectorMaxIndexesExceeded"] = "S3VectorMaxIndexesExceeded";
109
+ return StorageVectorsErrorCode$1;
110
+ }({});
37
111
 
38
112
  //#endregion
39
- //#region src/lib/helpers.ts
40
- const resolveFetch$1 = (customFetch) => {
113
+ //#region src/lib/common/helpers.ts
114
+ /**
115
+ * Resolves the fetch implementation to use
116
+ * Uses custom fetch if provided, otherwise uses native fetch
117
+ *
118
+ * @param customFetch - Optional custom fetch implementation
119
+ * @returns Resolved fetch function
120
+ */
121
+ const resolveFetch = (customFetch) => {
41
122
  if (customFetch) return (...args) => customFetch(...args);
42
123
  return (...args) => fetch(...args);
43
124
  };
44
- const resolveResponse$1 = () => {
45
- return Response;
125
+ /**
126
+ * Determine if input is a plain object
127
+ * An object is plain if it's created by either {}, new Object(), or Object.create(null)
128
+ *
129
+ * @param value - Value to check
130
+ * @returns True if value is a plain object
131
+ * @source https://github.com/sindresorhus/is-plain-obj
132
+ */
133
+ const isPlainObject = (value) => {
134
+ if (typeof value !== "object" || value === null) return false;
135
+ const prototype = Object.getPrototypeOf(value);
136
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
46
137
  };
138
+ /**
139
+ * Recursively converts object keys from snake_case to camelCase
140
+ * Used for normalizing API responses
141
+ *
142
+ * @param item - Object to convert
143
+ * @returns Converted object with camelCase keys
144
+ */
47
145
  const recursiveToCamel = (item) => {
48
146
  if (Array.isArray(item)) return item.map((el) => recursiveToCamel(el));
49
147
  else if (typeof item === "function" || item !== Object(item)) return item;
@@ -55,16 +153,6 @@ const recursiveToCamel = (item) => {
55
153
  return result;
56
154
  };
57
155
  /**
58
- * Determine if input is a plain object
59
- * An object is plain if it's created by either {}, new Object(), or Object.create(null)
60
- * source: https://github.com/sindresorhus/is-plain-obj
61
- */
62
- const isPlainObject$1 = (value) => {
63
- if (typeof value !== "object" || value === null) return false;
64
- const prototype = Object.getPrototypeOf(value);
65
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
66
- };
67
- /**
68
156
  * Validates if a given bucket name is valid according to Supabase Storage API rules
69
157
  * Mirrors backend validation from: storage/src/storage/limits.ts:isValidBucketName()
70
158
  *
@@ -154,58 +242,193 @@ function _objectSpread2(e) {
154
242
  }
155
243
 
156
244
  //#endregion
157
- //#region src/lib/fetch.ts
158
- const _getErrorMessage$1 = (err) => {
245
+ //#region src/lib/common/fetch.ts
246
+ /**
247
+ * Extracts error message from various error response formats
248
+ * @param err - Error object from API
249
+ * @returns Human-readable error message
250
+ */
251
+ const _getErrorMessage = (err) => {
159
252
  var _err$error;
160
253
  return err.msg || err.message || err.error_description || (typeof err.error === "string" ? err.error : (_err$error = err.error) === null || _err$error === void 0 ? void 0 : _err$error.message) || JSON.stringify(err);
161
254
  };
162
- const handleError$1 = async (error, reject, options) => {
163
- if (error instanceof await resolveResponse$1() && !(options === null || options === void 0 ? void 0 : options.noResolveJson)) error.json().then((err) => {
164
- const status = error.status || 500;
165
- const statusCode = (err === null || err === void 0 ? void 0 : err.statusCode) || status + "";
166
- reject(new StorageApiError(_getErrorMessage$1(err), status, statusCode));
167
- }).catch((err) => {
168
- reject(new StorageUnknownError(_getErrorMessage$1(err), err));
169
- });
170
- else reject(new StorageUnknownError(_getErrorMessage$1(error), error));
255
+ /**
256
+ * Handles fetch errors and converts them to Storage error types
257
+ * @param error - The error caught from fetch
258
+ * @param reject - Promise rejection function
259
+ * @param options - Fetch options that may affect error handling
260
+ * @param namespace - Error namespace ('storage' or 'vectors')
261
+ */
262
+ const handleError = async (error, reject, options, namespace) => {
263
+ if (error && typeof error === "object" && "status" in error && "ok" in error && typeof error.status === "number" && !(options === null || options === void 0 ? void 0 : options.noResolveJson)) {
264
+ const responseError = error;
265
+ const status = responseError.status || 500;
266
+ if (typeof responseError.json === "function") responseError.json().then((err) => {
267
+ const statusCode = (err === null || err === void 0 ? void 0 : err.statusCode) || (err === null || err === void 0 ? void 0 : err.code) || status + "";
268
+ reject(new StorageApiError(_getErrorMessage(err), status, statusCode, namespace));
269
+ }).catch(() => {
270
+ if (namespace === "vectors") {
271
+ const statusCode = status + "";
272
+ reject(new StorageApiError(responseError.statusText || `HTTP ${status} error`, status, statusCode, namespace));
273
+ } else {
274
+ const statusCode = status + "";
275
+ reject(new StorageApiError(responseError.statusText || `HTTP ${status} error`, status, statusCode, namespace));
276
+ }
277
+ });
278
+ else {
279
+ const statusCode = status + "";
280
+ reject(new StorageApiError(responseError.statusText || `HTTP ${status} error`, status, statusCode, namespace));
281
+ }
282
+ } else reject(new StorageUnknownError(_getErrorMessage(error), error, namespace));
171
283
  };
172
- const _getRequestParams$1 = (method, options, parameters, body) => {
284
+ /**
285
+ * Builds request parameters for fetch calls
286
+ * @param method - HTTP method
287
+ * @param options - Custom fetch options
288
+ * @param parameters - Additional fetch parameters like AbortSignal
289
+ * @param body - Request body (will be JSON stringified if plain object)
290
+ * @returns Complete fetch request parameters
291
+ */
292
+ const _getRequestParams = (method, options, parameters, body) => {
173
293
  const params = {
174
294
  method,
175
295
  headers: (options === null || options === void 0 ? void 0 : options.headers) || {}
176
296
  };
177
- if (method === "GET" || !body) return params;
178
- if (isPlainObject$1(body)) {
297
+ if (method === "GET" || method === "HEAD" || !body) return _objectSpread2(_objectSpread2({}, params), parameters);
298
+ if (isPlainObject(body)) {
179
299
  params.headers = _objectSpread2({ "Content-Type": "application/json" }, options === null || options === void 0 ? void 0 : options.headers);
180
300
  params.body = JSON.stringify(body);
181
301
  } else params.body = body;
182
302
  if (options === null || options === void 0 ? void 0 : options.duplex) params.duplex = options.duplex;
183
303
  return _objectSpread2(_objectSpread2({}, params), parameters);
184
304
  };
185
- async function _handleRequest$1(fetcher, method, url, options, parameters, body) {
305
+ /**
306
+ * Internal request handler that wraps fetch with error handling
307
+ * @param fetcher - Fetch function to use
308
+ * @param method - HTTP method
309
+ * @param url - Request URL
310
+ * @param options - Custom fetch options
311
+ * @param parameters - Additional fetch parameters
312
+ * @param body - Request body
313
+ * @param namespace - Error namespace ('storage' or 'vectors')
314
+ * @returns Promise with parsed response or error
315
+ */
316
+ async function _handleRequest(fetcher, method, url, options, parameters, body, namespace) {
186
317
  return new Promise((resolve, reject) => {
187
- fetcher(url, _getRequestParams$1(method, options, parameters, body)).then((result) => {
318
+ fetcher(url, _getRequestParams(method, options, parameters, body)).then((result) => {
188
319
  if (!result.ok) throw result;
189
320
  if (options === null || options === void 0 ? void 0 : options.noResolveJson) return result;
321
+ if (namespace === "vectors") {
322
+ const contentType = result.headers.get("content-type");
323
+ if (!contentType || !contentType.includes("application/json")) return {};
324
+ }
190
325
  return result.json();
191
- }).then((data) => resolve(data)).catch((error) => handleError$1(error, reject, options));
326
+ }).then((data) => resolve(data)).catch((error) => handleError(error, reject, options, namespace));
192
327
  });
193
328
  }
194
- async function get(fetcher, url, options, parameters) {
195
- return _handleRequest$1(fetcher, "GET", url, options, parameters);
196
- }
197
- async function post$1(fetcher, url, body, options, parameters) {
198
- return _handleRequest$1(fetcher, "POST", url, options, parameters, body);
199
- }
200
- async function put(fetcher, url, body, options, parameters) {
201
- return _handleRequest$1(fetcher, "PUT", url, options, parameters, body);
202
- }
203
- async function head(fetcher, url, options, parameters) {
204
- return _handleRequest$1(fetcher, "HEAD", url, _objectSpread2(_objectSpread2({}, options), {}, { noResolveJson: true }), parameters);
205
- }
206
- async function remove(fetcher, url, body, options, parameters) {
207
- return _handleRequest$1(fetcher, "DELETE", url, options, parameters, body);
329
+ /**
330
+ * Creates a fetch API with the specified namespace
331
+ * @param namespace - Error namespace ('storage' or 'vectors')
332
+ * @returns Object with HTTP method functions
333
+ */
334
+ function createFetchApi(namespace = "storage") {
335
+ return {
336
+ get: async (fetcher, url, options, parameters) => {
337
+ return _handleRequest(fetcher, "GET", url, options, parameters, void 0, namespace);
338
+ },
339
+ post: async (fetcher, url, body, options, parameters) => {
340
+ return _handleRequest(fetcher, "POST", url, options, parameters, body, namespace);
341
+ },
342
+ put: async (fetcher, url, body, options, parameters) => {
343
+ return _handleRequest(fetcher, "PUT", url, options, parameters, body, namespace);
344
+ },
345
+ head: async (fetcher, url, options, parameters) => {
346
+ return _handleRequest(fetcher, "HEAD", url, _objectSpread2(_objectSpread2({}, options), {}, { noResolveJson: true }), parameters, void 0, namespace);
347
+ },
348
+ remove: async (fetcher, url, body, options, parameters) => {
349
+ return _handleRequest(fetcher, "DELETE", url, options, parameters, body, namespace);
350
+ }
351
+ };
208
352
  }
353
+ const defaultApi = createFetchApi("storage");
354
+ const { get, post, put, head, remove } = defaultApi;
355
+
356
+ //#endregion
357
+ //#region src/lib/common/BaseApiClient.ts
358
+ /**
359
+ * @ignore
360
+ * Base API client class for all Storage API classes
361
+ * Provides common infrastructure for error handling and configuration
362
+ *
363
+ * @typeParam TError - The error type (StorageError or subclass)
364
+ */
365
+ var BaseApiClient = class {
366
+ /**
367
+ * Creates a new BaseApiClient instance
368
+ * @param url - Base URL for API requests
369
+ * @param headers - Default headers for API requests
370
+ * @param fetch - Optional custom fetch implementation
371
+ * @param namespace - Error namespace ('storage' or 'vectors')
372
+ */
373
+ constructor(url, headers = {}, fetch$1, namespace = "storage") {
374
+ this.shouldThrowOnError = false;
375
+ this.url = url;
376
+ this.headers = headers;
377
+ this.fetch = resolveFetch(fetch$1);
378
+ this.namespace = namespace;
379
+ }
380
+ /**
381
+ * Enable throwing errors instead of returning them.
382
+ * When enabled, errors are thrown instead of returned in { data, error } format.
383
+ *
384
+ * @returns this - For method chaining
385
+ */
386
+ throwOnError() {
387
+ this.shouldThrowOnError = true;
388
+ return this;
389
+ }
390
+ /**
391
+ * Handles API operation with standardized error handling
392
+ * Eliminates repetitive try-catch blocks across all API methods
393
+ *
394
+ * This wrapper:
395
+ * 1. Executes the operation
396
+ * 2. Returns { data, error: null } on success
397
+ * 3. Returns { data: null, error } on failure (if shouldThrowOnError is false)
398
+ * 4. Throws error on failure (if shouldThrowOnError is true)
399
+ *
400
+ * @typeParam T - The expected data type from the operation
401
+ * @param operation - Async function that performs the API call
402
+ * @returns Promise with { data, error } tuple
403
+ *
404
+ * @example
405
+ * ```typescript
406
+ * async listBuckets() {
407
+ * return this.handleOperation(async () => {
408
+ * return await get(this.fetch, `${this.url}/bucket`, {
409
+ * headers: this.headers,
410
+ * })
411
+ * })
412
+ * }
413
+ * ```
414
+ */
415
+ async handleOperation(operation) {
416
+ var _this = this;
417
+ try {
418
+ return {
419
+ data: await operation(),
420
+ error: null
421
+ };
422
+ } catch (error) {
423
+ if (_this.shouldThrowOnError) throw error;
424
+ if (isStorageError(error)) return {
425
+ data: null,
426
+ error
427
+ };
428
+ throw error;
429
+ }
430
+ }
431
+ };
209
432
 
210
433
  //#endregion
211
434
  //#region src/packages/StreamDownloadBuilder.ts
@@ -295,22 +518,10 @@ const DEFAULT_FILE_OPTIONS = {
295
518
  contentType: "text/plain;charset=UTF-8",
296
519
  upsert: false
297
520
  };
298
- var StorageFileApi = class {
521
+ var StorageFileApi = class extends BaseApiClient {
299
522
  constructor(url, headers = {}, bucketId, fetch$1) {
300
- this.shouldThrowOnError = false;
301
- this.url = url;
302
- this.headers = headers;
523
+ super(url, headers, fetch$1, "storage");
303
524
  this.bucketId = bucketId;
304
- this.fetch = resolveFetch$1(fetch$1);
305
- }
306
- /**
307
- * Enable throwing errors instead of returning them.
308
- *
309
- * @category File Buckets
310
- */
311
- throwOnError() {
312
- this.shouldThrowOnError = true;
313
- return this;
314
525
  }
315
526
  /**
316
527
  * Uploads a file to an existing bucket or replaces an existing file at the specified path with a new one.
@@ -321,7 +532,7 @@ var StorageFileApi = class {
321
532
  */
322
533
  async uploadOrUpdate(method, path, fileBody, fileOptions) {
323
534
  var _this = this;
324
- try {
535
+ return _this.handleOperation(async () => {
325
536
  let body;
326
537
  const options = _objectSpread2(_objectSpread2({}, DEFAULT_FILE_OPTIONS), fileOptions);
327
538
  let headers = _objectSpread2(_objectSpread2({}, _this.headers), method === "POST" && { "x-upsert": String(options.upsert) });
@@ -345,23 +556,13 @@ var StorageFileApi = class {
345
556
  if (fileOptions === null || fileOptions === void 0 ? void 0 : fileOptions.headers) headers = _objectSpread2(_objectSpread2({}, headers), fileOptions.headers);
346
557
  const cleanPath = _this._removeEmptyFolders(path);
347
558
  const _path = _this._getFinalPath(cleanPath);
348
- const data = await (method == "PUT" ? put : post$1)(_this.fetch, `${_this.url}/object/${_path}`, body, _objectSpread2({ headers }, (options === null || options === void 0 ? void 0 : options.duplex) ? { duplex: options.duplex } : {}));
559
+ const data = await (method == "PUT" ? put : post)(_this.fetch, `${_this.url}/object/${_path}`, body, _objectSpread2({ headers }, (options === null || options === void 0 ? void 0 : options.duplex) ? { duplex: options.duplex } : {}));
349
560
  return {
350
- data: {
351
- path: cleanPath,
352
- id: data.Id,
353
- fullPath: data.Key
354
- },
355
- error: null
356
- };
357
- } catch (error) {
358
- if (_this.shouldThrowOnError) throw error;
359
- if (isStorageError(error)) return {
360
- data: null,
361
- error
561
+ path: cleanPath,
562
+ id: data.Id,
563
+ fullPath: data.Key
362
564
  };
363
- throw error;
364
- }
565
+ });
365
566
  }
366
567
  /**
367
568
  * Uploads a file to an existing bucket.
@@ -447,7 +648,7 @@ var StorageFileApi = class {
447
648
  const _path = _this3._getFinalPath(cleanPath);
448
649
  const url = new URL(_this3.url + `/object/upload/sign/${_path}`);
449
650
  url.searchParams.set("token", token);
450
- try {
651
+ return _this3.handleOperation(async () => {
451
652
  let body;
452
653
  const options = _objectSpread2({ upsert: DEFAULT_FILE_OPTIONS.upsert }, fileOptions);
453
654
  const headers = _objectSpread2(_objectSpread2({}, _this3.headers), { "x-upsert": String(options.upsert) });
@@ -464,20 +665,10 @@ var StorageFileApi = class {
464
665
  headers["content-type"] = options.contentType;
465
666
  }
466
667
  return {
467
- data: {
468
- path: cleanPath,
469
- fullPath: (await put(_this3.fetch, url.toString(), body, { headers })).Key
470
- },
471
- error: null
472
- };
473
- } catch (error) {
474
- if (_this3.shouldThrowOnError) throw error;
475
- if (isStorageError(error)) return {
476
- data: null,
477
- error
668
+ path: cleanPath,
669
+ fullPath: (await put(_this3.fetch, url.toString(), body, { headers })).Key
478
670
  };
479
- throw error;
480
- }
671
+ });
481
672
  }
482
673
  /**
483
674
  * Creates a signed upload URL.
@@ -511,30 +702,20 @@ var StorageFileApi = class {
511
702
  */
512
703
  async createSignedUploadUrl(path, options) {
513
704
  var _this4 = this;
514
- try {
705
+ return _this4.handleOperation(async () => {
515
706
  let _path = _this4._getFinalPath(path);
516
707
  const headers = _objectSpread2({}, _this4.headers);
517
708
  if (options === null || options === void 0 ? void 0 : options.upsert) headers["x-upsert"] = "true";
518
- const data = await post$1(_this4.fetch, `${_this4.url}/object/upload/sign/${_path}`, {}, { headers });
709
+ const data = await post(_this4.fetch, `${_this4.url}/object/upload/sign/${_path}`, {}, { headers });
519
710
  const url = new URL(_this4.url + data.url);
520
711
  const token = url.searchParams.get("token");
521
712
  if (!token) throw new StorageError("No token returned by API");
522
713
  return {
523
- data: {
524
- signedUrl: url.toString(),
525
- path,
526
- token
527
- },
528
- error: null
714
+ signedUrl: url.toString(),
715
+ path,
716
+ token
529
717
  };
530
- } catch (error) {
531
- if (_this4.shouldThrowOnError) throw error;
532
- if (isStorageError(error)) return {
533
- data: null,
534
- error
535
- };
536
- throw error;
537
- }
718
+ });
538
719
  }
539
720
  /**
540
721
  * Replaces an existing file at the specified path with a new one.
@@ -612,24 +793,14 @@ var StorageFileApi = class {
612
793
  */
613
794
  async move(fromPath, toPath, options) {
614
795
  var _this6 = this;
615
- try {
616
- return {
617
- data: await post$1(_this6.fetch, `${_this6.url}/object/move`, {
618
- bucketId: _this6.bucketId,
619
- sourceKey: fromPath,
620
- destinationKey: toPath,
621
- destinationBucket: options === null || options === void 0 ? void 0 : options.destinationBucket
622
- }, { headers: _this6.headers }),
623
- error: null
624
- };
625
- } catch (error) {
626
- if (_this6.shouldThrowOnError) throw error;
627
- if (isStorageError(error)) return {
628
- data: null,
629
- error
630
- };
631
- throw error;
632
- }
796
+ return _this6.handleOperation(async () => {
797
+ return await post(_this6.fetch, `${_this6.url}/object/move`, {
798
+ bucketId: _this6.bucketId,
799
+ sourceKey: fromPath,
800
+ destinationKey: toPath,
801
+ destinationBucket: options === null || options === void 0 ? void 0 : options.destinationBucket
802
+ }, { headers: _this6.headers });
803
+ });
633
804
  }
634
805
  /**
635
806
  * Copies an existing file to a new path in the same bucket.
@@ -660,24 +831,14 @@ var StorageFileApi = class {
660
831
  */
661
832
  async copy(fromPath, toPath, options) {
662
833
  var _this7 = this;
663
- try {
664
- return {
665
- data: { path: (await post$1(_this7.fetch, `${_this7.url}/object/copy`, {
666
- bucketId: _this7.bucketId,
667
- sourceKey: fromPath,
668
- destinationKey: toPath,
669
- destinationBucket: options === null || options === void 0 ? void 0 : options.destinationBucket
670
- }, { headers: _this7.headers })).Key },
671
- error: null
672
- };
673
- } catch (error) {
674
- if (_this7.shouldThrowOnError) throw error;
675
- if (isStorageError(error)) return {
676
- data: null,
677
- error
678
- };
679
- throw error;
680
- }
834
+ return _this7.handleOperation(async () => {
835
+ return { path: (await post(_this7.fetch, `${_this7.url}/object/copy`, {
836
+ bucketId: _this7.bucketId,
837
+ sourceKey: fromPath,
838
+ destinationKey: toPath,
839
+ destinationBucket: options === null || options === void 0 ? void 0 : options.destinationBucket
840
+ }, { headers: _this7.headers })).Key };
841
+ });
681
842
  }
682
843
  /**
683
844
  * Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
@@ -732,23 +893,12 @@ var StorageFileApi = class {
732
893
  */
733
894
  async createSignedUrl(path, expiresIn, options) {
734
895
  var _this8 = this;
735
- try {
896
+ return _this8.handleOperation(async () => {
736
897
  let _path = _this8._getFinalPath(path);
737
- let data = await post$1(_this8.fetch, `${_this8.url}/object/sign/${_path}`, _objectSpread2({ expiresIn }, (options === null || options === void 0 ? void 0 : options.transform) ? { transform: options.transform } : {}), { headers: _this8.headers });
898
+ let data = await post(_this8.fetch, `${_this8.url}/object/sign/${_path}`, _objectSpread2({ expiresIn }, (options === null || options === void 0 ? void 0 : options.transform) ? { transform: options.transform } : {}), { headers: _this8.headers });
738
899
  const downloadQueryParam = (options === null || options === void 0 ? void 0 : options.download) ? `&download=${options.download === true ? "" : options.download}` : "";
739
- data = { signedUrl: encodeURI(`${_this8.url}${data.signedURL}${downloadQueryParam}`) };
740
- return {
741
- data,
742
- error: null
743
- };
744
- } catch (error) {
745
- if (_this8.shouldThrowOnError) throw error;
746
- if (isStorageError(error)) return {
747
- data: null,
748
- error
749
- };
750
- throw error;
751
- }
900
+ return { signedUrl: encodeURI(`${_this8.url}${data.signedURL}${downloadQueryParam}`) };
901
+ });
752
902
  }
753
903
  /**
754
904
  * Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.
@@ -790,24 +940,14 @@ var StorageFileApi = class {
790
940
  */
791
941
  async createSignedUrls(paths, expiresIn, options) {
792
942
  var _this9 = this;
793
- try {
794
- const data = await post$1(_this9.fetch, `${_this9.url}/object/sign/${_this9.bucketId}`, {
943
+ return _this9.handleOperation(async () => {
944
+ const data = await post(_this9.fetch, `${_this9.url}/object/sign/${_this9.bucketId}`, {
795
945
  expiresIn,
796
946
  paths
797
947
  }, { headers: _this9.headers });
798
948
  const downloadQueryParam = (options === null || options === void 0 ? void 0 : options.download) ? `&download=${options.download === true ? "" : options.download}` : "";
799
- return {
800
- data: data.map((datum) => _objectSpread2(_objectSpread2({}, datum), {}, { signedUrl: datum.signedURL ? encodeURI(`${_this9.url}${datum.signedURL}${downloadQueryParam}`) : null })),
801
- error: null
802
- };
803
- } catch (error) {
804
- if (_this9.shouldThrowOnError) throw error;
805
- if (isStorageError(error)) return {
806
- data: null,
807
- error
808
- };
809
- throw error;
810
- }
949
+ return data.map((datum) => _objectSpread2(_objectSpread2({}, datum), {}, { signedUrl: datum.signedURL ? encodeURI(`${_this9.url}${datum.signedURL}${downloadQueryParam}`) : null }));
950
+ });
811
951
  }
812
952
  /**
813
953
  * Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.
@@ -876,19 +1016,9 @@ var StorageFileApi = class {
876
1016
  async info(path) {
877
1017
  var _this10 = this;
878
1018
  const _path = _this10._getFinalPath(path);
879
- try {
880
- return {
881
- data: recursiveToCamel(await get(_this10.fetch, `${_this10.url}/object/info/${_path}`, { headers: _this10.headers })),
882
- error: null
883
- };
884
- } catch (error) {
885
- if (_this10.shouldThrowOnError) throw error;
886
- if (isStorageError(error)) return {
887
- data: null,
888
- error
889
- };
890
- throw error;
891
- }
1019
+ return _this10.handleOperation(async () => {
1020
+ return recursiveToCamel(await get(_this10.fetch, `${_this10.url}/object/info/${_path}`, { headers: _this10.headers }));
1021
+ });
892
1022
  }
893
1023
  /**
894
1024
  * Checks the existence of a file.
@@ -1013,19 +1143,9 @@ var StorageFileApi = class {
1013
1143
  */
1014
1144
  async remove(paths) {
1015
1145
  var _this12 = this;
1016
- try {
1017
- return {
1018
- data: await remove(_this12.fetch, `${_this12.url}/object/${_this12.bucketId}`, { prefixes: paths }, { headers: _this12.headers }),
1019
- error: null
1020
- };
1021
- } catch (error) {
1022
- if (_this12.shouldThrowOnError) throw error;
1023
- if (isStorageError(error)) return {
1024
- data: null,
1025
- error
1026
- };
1027
- throw error;
1028
- }
1146
+ return _this12.handleOperation(async () => {
1147
+ return await remove(_this12.fetch, `${_this12.url}/object/${_this12.bucketId}`, { prefixes: paths }, { headers: _this12.headers });
1148
+ });
1029
1149
  }
1030
1150
  /**
1031
1151
  * Get file metadata
@@ -1097,20 +1217,10 @@ var StorageFileApi = class {
1097
1217
  */
1098
1218
  async list(path, options, parameters) {
1099
1219
  var _this13 = this;
1100
- try {
1220
+ return _this13.handleOperation(async () => {
1101
1221
  const body = _objectSpread2(_objectSpread2(_objectSpread2({}, DEFAULT_SEARCH_OPTIONS), options), {}, { prefix: path || "" });
1102
- return {
1103
- data: await post$1(_this13.fetch, `${_this13.url}/object/list/${_this13.bucketId}`, body, { headers: _this13.headers }, parameters),
1104
- error: null
1105
- };
1106
- } catch (error) {
1107
- if (_this13.shouldThrowOnError) throw error;
1108
- if (isStorageError(error)) return {
1109
- data: null,
1110
- error
1111
- };
1112
- throw error;
1113
- }
1222
+ return await post(_this13.fetch, `${_this13.url}/object/list/${_this13.bucketId}`, body, { headers: _this13.headers }, parameters);
1223
+ });
1114
1224
  }
1115
1225
  /**
1116
1226
  * @experimental this method signature might change in the future
@@ -1121,20 +1231,10 @@ var StorageFileApi = class {
1121
1231
  */
1122
1232
  async listV2(options, parameters) {
1123
1233
  var _this14 = this;
1124
- try {
1234
+ return _this14.handleOperation(async () => {
1125
1235
  const body = _objectSpread2({}, options);
1126
- return {
1127
- data: await post$1(_this14.fetch, `${_this14.url}/object/list-v2/${_this14.bucketId}`, body, { headers: _this14.headers }, parameters),
1128
- error: null
1129
- };
1130
- } catch (error) {
1131
- if (_this14.shouldThrowOnError) throw error;
1132
- if (isStorageError(error)) return {
1133
- data: null,
1134
- error
1135
- };
1136
- throw error;
1137
- }
1236
+ return await post(_this14.fetch, `${_this14.url}/object/list-v2/${_this14.bucketId}`, body, { headers: _this14.headers }, parameters);
1237
+ });
1138
1238
  }
1139
1239
  encodeMetadata(metadata) {
1140
1240
  return JSON.stringify(metadata);
@@ -1162,33 +1262,23 @@ var StorageFileApi = class {
1162
1262
 
1163
1263
  //#endregion
1164
1264
  //#region src/lib/version.ts
1165
- const version = "2.91.1";
1265
+ const version = "2.91.2";
1166
1266
 
1167
1267
  //#endregion
1168
1268
  //#region src/lib/constants.ts
1169
- const DEFAULT_HEADERS$1 = { "X-Client-Info": `storage-js/${version}` };
1269
+ const DEFAULT_HEADERS = { "X-Client-Info": `storage-js/${version}` };
1170
1270
 
1171
1271
  //#endregion
1172
1272
  //#region src/packages/StorageBucketApi.ts
1173
- var StorageBucketApi = class {
1273
+ var StorageBucketApi = class extends BaseApiClient {
1174
1274
  constructor(url, headers = {}, fetch$1, opts) {
1175
- this.shouldThrowOnError = false;
1176
1275
  const baseUrl = new URL(url);
1177
1276
  if (opts === null || opts === void 0 ? void 0 : opts.useNewHostname) {
1178
1277
  if (/supabase\.(co|in|red)$/.test(baseUrl.hostname) && !baseUrl.hostname.includes("storage.supabase.")) baseUrl.hostname = baseUrl.hostname.replace("supabase.", "storage.supabase.");
1179
1278
  }
1180
- this.url = baseUrl.href.replace(/\/$/, "");
1181
- this.headers = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS$1), headers);
1182
- this.fetch = resolveFetch$1(fetch$1);
1183
- }
1184
- /**
1185
- * Enable throwing errors instead of returning them.
1186
- *
1187
- * @category File Buckets
1188
- */
1189
- throwOnError() {
1190
- this.shouldThrowOnError = true;
1191
- return this;
1279
+ const finalUrl = baseUrl.href.replace(/\/$/, "");
1280
+ const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), headers);
1281
+ super(finalUrl, finalHeaders, fetch$1, "storage");
1192
1282
  }
1193
1283
  /**
1194
1284
  * Retrieves the details of all Storage buckets within an existing project.
@@ -1224,20 +1314,10 @@ var StorageBucketApi = class {
1224
1314
  */
1225
1315
  async listBuckets(options) {
1226
1316
  var _this = this;
1227
- try {
1317
+ return _this.handleOperation(async () => {
1228
1318
  const queryString = _this.listBucketOptionsToQueryString(options);
1229
- return {
1230
- data: await get(_this.fetch, `${_this.url}/bucket${queryString}`, { headers: _this.headers }),
1231
- error: null
1232
- };
1233
- } catch (error) {
1234
- if (_this.shouldThrowOnError) throw error;
1235
- if (isStorageError(error)) return {
1236
- data: null,
1237
- error
1238
- };
1239
- throw error;
1240
- }
1319
+ return await get(_this.fetch, `${_this.url}/bucket${queryString}`, { headers: _this.headers });
1320
+ });
1241
1321
  }
1242
1322
  /**
1243
1323
  * Retrieves the details of an existing Storage bucket.
@@ -1274,19 +1354,9 @@ var StorageBucketApi = class {
1274
1354
  */
1275
1355
  async getBucket(id) {
1276
1356
  var _this2 = this;
1277
- try {
1278
- return {
1279
- data: await get(_this2.fetch, `${_this2.url}/bucket/${id}`, { headers: _this2.headers }),
1280
- error: null
1281
- };
1282
- } catch (error) {
1283
- if (_this2.shouldThrowOnError) throw error;
1284
- if (isStorageError(error)) return {
1285
- data: null,
1286
- error
1287
- };
1288
- throw error;
1289
- }
1357
+ return _this2.handleOperation(async () => {
1358
+ return await get(_this2.fetch, `${_this2.url}/bucket/${id}`, { headers: _this2.headers });
1359
+ });
1290
1360
  }
1291
1361
  /**
1292
1362
  * Creates a new Storage bucket
@@ -1327,26 +1397,16 @@ var StorageBucketApi = class {
1327
1397
  */
1328
1398
  async createBucket(id, options = { public: false }) {
1329
1399
  var _this3 = this;
1330
- try {
1331
- return {
1332
- data: await post$1(_this3.fetch, `${_this3.url}/bucket`, {
1333
- id,
1334
- name: id,
1335
- type: options.type,
1336
- public: options.public,
1337
- file_size_limit: options.fileSizeLimit,
1338
- allowed_mime_types: options.allowedMimeTypes
1339
- }, { headers: _this3.headers }),
1340
- error: null
1341
- };
1342
- } catch (error) {
1343
- if (_this3.shouldThrowOnError) throw error;
1344
- if (isStorageError(error)) return {
1345
- data: null,
1346
- error
1347
- };
1348
- throw error;
1349
- }
1400
+ return _this3.handleOperation(async () => {
1401
+ return await post(_this3.fetch, `${_this3.url}/bucket`, {
1402
+ id,
1403
+ name: id,
1404
+ type: options.type,
1405
+ public: options.public,
1406
+ file_size_limit: options.fileSizeLimit,
1407
+ allowed_mime_types: options.allowedMimeTypes
1408
+ }, { headers: _this3.headers });
1409
+ });
1350
1410
  }
1351
1411
  /**
1352
1412
  * Updates a Storage bucket
@@ -1385,25 +1445,15 @@ var StorageBucketApi = class {
1385
1445
  */
1386
1446
  async updateBucket(id, options) {
1387
1447
  var _this4 = this;
1388
- try {
1389
- return {
1390
- data: await put(_this4.fetch, `${_this4.url}/bucket/${id}`, {
1391
- id,
1392
- name: id,
1393
- public: options.public,
1394
- file_size_limit: options.fileSizeLimit,
1395
- allowed_mime_types: options.allowedMimeTypes
1396
- }, { headers: _this4.headers }),
1397
- error: null
1398
- };
1399
- } catch (error) {
1400
- if (_this4.shouldThrowOnError) throw error;
1401
- if (isStorageError(error)) return {
1402
- data: null,
1403
- error
1404
- };
1405
- throw error;
1406
- }
1448
+ return _this4.handleOperation(async () => {
1449
+ return await put(_this4.fetch, `${_this4.url}/bucket/${id}`, {
1450
+ id,
1451
+ name: id,
1452
+ public: options.public,
1453
+ file_size_limit: options.fileSizeLimit,
1454
+ allowed_mime_types: options.allowedMimeTypes
1455
+ }, { headers: _this4.headers });
1456
+ });
1407
1457
  }
1408
1458
  /**
1409
1459
  * Removes all objects inside a single bucket.
@@ -1431,19 +1481,9 @@ var StorageBucketApi = class {
1431
1481
  */
1432
1482
  async emptyBucket(id) {
1433
1483
  var _this5 = this;
1434
- try {
1435
- return {
1436
- data: await post$1(_this5.fetch, `${_this5.url}/bucket/${id}/empty`, {}, { headers: _this5.headers }),
1437
- error: null
1438
- };
1439
- } catch (error) {
1440
- if (_this5.shouldThrowOnError) throw error;
1441
- if (isStorageError(error)) return {
1442
- data: null,
1443
- error
1444
- };
1445
- throw error;
1446
- }
1484
+ return _this5.handleOperation(async () => {
1485
+ return await post(_this5.fetch, `${_this5.url}/bucket/${id}/empty`, {}, { headers: _this5.headers });
1486
+ });
1447
1487
  }
1448
1488
  /**
1449
1489
  * Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
@@ -1472,19 +1512,9 @@ var StorageBucketApi = class {
1472
1512
  */
1473
1513
  async deleteBucket(id) {
1474
1514
  var _this6 = this;
1475
- try {
1476
- return {
1477
- data: await remove(_this6.fetch, `${_this6.url}/bucket/${id}`, {}, { headers: _this6.headers }),
1478
- error: null
1479
- };
1480
- } catch (error) {
1481
- if (_this6.shouldThrowOnError) throw error;
1482
- if (isStorageError(error)) return {
1483
- data: null,
1484
- error
1485
- };
1486
- throw error;
1487
- }
1515
+ return _this6.handleOperation(async () => {
1516
+ return await remove(_this6.fetch, `${_this6.url}/bucket/${id}`, {}, { headers: _this6.headers });
1517
+ });
1488
1518
  }
1489
1519
  listBucketOptionsToQueryString(options) {
1490
1520
  const params = {};
@@ -1505,7 +1535,7 @@ var StorageBucketApi = class {
1505
1535
  * Client class for managing Analytics Buckets using Iceberg tables
1506
1536
  * Provides methods for creating, listing, and deleting analytics buckets
1507
1537
  */
1508
- var StorageAnalyticsClient = class {
1538
+ var StorageAnalyticsClient = class extends BaseApiClient {
1509
1539
  /**
1510
1540
  * @alpha
1511
1541
  *
@@ -1524,25 +1554,9 @@ var StorageAnalyticsClient = class {
1524
1554
  * ```
1525
1555
  */
1526
1556
  constructor(url, headers = {}, fetch$1) {
1527
- this.shouldThrowOnError = false;
1528
- this.url = url.replace(/\/$/, "");
1529
- this.headers = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS$1), headers);
1530
- this.fetch = resolveFetch$1(fetch$1);
1531
- }
1532
- /**
1533
- * @alpha
1534
- *
1535
- * Enable throwing errors instead of returning them in the response
1536
- * When enabled, failed operations will throw instead of returning { data: null, error }
1537
- *
1538
- * **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
1539
- *
1540
- * @category Analytics Buckets
1541
- * @returns This instance for method chaining
1542
- */
1543
- throwOnError() {
1544
- this.shouldThrowOnError = true;
1545
- return this;
1557
+ const finalUrl = url.replace(/\/$/, "");
1558
+ const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), headers);
1559
+ super(finalUrl, finalHeaders, fetch$1, "storage");
1546
1560
  }
1547
1561
  /**
1548
1562
  * @alpha
@@ -1580,19 +1594,9 @@ var StorageAnalyticsClient = class {
1580
1594
  */
1581
1595
  async createBucket(name) {
1582
1596
  var _this = this;
1583
- try {
1584
- return {
1585
- data: await post$1(_this.fetch, `${_this.url}/bucket`, { name }, { headers: _this.headers }),
1586
- error: null
1587
- };
1588
- } catch (error) {
1589
- if (_this.shouldThrowOnError) throw error;
1590
- if (isStorageError(error)) return {
1591
- data: null,
1592
- error
1593
- };
1594
- throw error;
1595
- }
1597
+ return _this.handleOperation(async () => {
1598
+ return await post(_this.fetch, `${_this.url}/bucket`, { name }, { headers: _this.headers });
1599
+ });
1596
1600
  }
1597
1601
  /**
1598
1602
  * @alpha
@@ -1642,7 +1646,7 @@ var StorageAnalyticsClient = class {
1642
1646
  */
1643
1647
  async listBuckets(options) {
1644
1648
  var _this2 = this;
1645
- try {
1649
+ return _this2.handleOperation(async () => {
1646
1650
  const queryParams = new URLSearchParams();
1647
1651
  if ((options === null || options === void 0 ? void 0 : options.limit) !== void 0) queryParams.set("limit", options.limit.toString());
1648
1652
  if ((options === null || options === void 0 ? void 0 : options.offset) !== void 0) queryParams.set("offset", options.offset.toString());
@@ -1651,18 +1655,8 @@ var StorageAnalyticsClient = class {
1651
1655
  if (options === null || options === void 0 ? void 0 : options.search) queryParams.set("search", options.search);
1652
1656
  const queryString = queryParams.toString();
1653
1657
  const url = queryString ? `${_this2.url}/bucket?${queryString}` : `${_this2.url}/bucket`;
1654
- return {
1655
- data: await get(_this2.fetch, url, { headers: _this2.headers }),
1656
- error: null
1657
- };
1658
- } catch (error) {
1659
- if (_this2.shouldThrowOnError) throw error;
1660
- if (isStorageError(error)) return {
1661
- data: null,
1662
- error
1663
- };
1664
- throw error;
1665
- }
1658
+ return await get(_this2.fetch, url, { headers: _this2.headers });
1659
+ });
1666
1660
  }
1667
1661
  /**
1668
1662
  * @alpha
@@ -1697,19 +1691,9 @@ var StorageAnalyticsClient = class {
1697
1691
  */
1698
1692
  async deleteBucket(bucketName) {
1699
1693
  var _this3 = this;
1700
- try {
1701
- return {
1702
- data: await remove(_this3.fetch, `${_this3.url}/bucket/${bucketName}`, {}, { headers: _this3.headers }),
1703
- error: null
1704
- };
1705
- } catch (error) {
1706
- if (_this3.shouldThrowOnError) throw error;
1707
- if (isStorageError(error)) return {
1708
- data: null,
1709
- error
1710
- };
1711
- throw error;
1712
- }
1694
+ return _this3.handleOperation(async () => {
1695
+ return await remove(_this3.fetch, `${_this3.url}/bucket/${bucketName}`, {}, { headers: _this3.headers });
1696
+ });
1713
1697
  }
1714
1698
  /**
1715
1699
  * @alpha
@@ -1869,528 +1853,160 @@ var StorageAnalyticsClient = class {
1869
1853
  };
1870
1854
 
1871
1855
  //#endregion
1872
- //#region src/lib/vectors/constants.ts
1873
- const DEFAULT_HEADERS = {
1874
- "X-Client-Info": `storage-js/${version}`,
1875
- "Content-Type": "application/json"
1876
- };
1877
-
1878
- //#endregion
1879
- //#region src/lib/vectors/errors.ts
1856
+ //#region src/packages/VectorIndexApi.ts
1880
1857
  /**
1881
- * Base error class for all Storage Vectors errors
1858
+ * @hidden
1859
+ * Base implementation for vector index operations.
1860
+ * Use {@link VectorBucketScope} via `supabase.storage.vectors.from('bucket')` instead.
1882
1861
  */
1883
- var StorageVectorsError = class extends Error {
1884
- constructor(message) {
1885
- super(message);
1886
- this.__isStorageVectorsError = true;
1887
- this.name = "StorageVectorsError";
1862
+ var VectorIndexApi = class extends BaseApiClient {
1863
+ /** Creates a new VectorIndexApi instance */
1864
+ constructor(url, headers = {}, fetch$1) {
1865
+ const finalUrl = url.replace(/\/$/, "");
1866
+ const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
1867
+ super(finalUrl, finalHeaders, fetch$1, "vectors");
1868
+ }
1869
+ /** Creates a new vector index within a bucket */
1870
+ async createIndex(options) {
1871
+ var _this = this;
1872
+ return _this.handleOperation(async () => {
1873
+ return await post(_this.fetch, `${_this.url}/CreateIndex`, options, { headers: _this.headers }) || {};
1874
+ });
1875
+ }
1876
+ /** Retrieves metadata for a specific vector index */
1877
+ async getIndex(vectorBucketName, indexName) {
1878
+ var _this2 = this;
1879
+ return _this2.handleOperation(async () => {
1880
+ return await post(_this2.fetch, `${_this2.url}/GetIndex`, {
1881
+ vectorBucketName,
1882
+ indexName
1883
+ }, { headers: _this2.headers });
1884
+ });
1885
+ }
1886
+ /** Lists vector indexes within a bucket with optional filtering and pagination */
1887
+ async listIndexes(options) {
1888
+ var _this3 = this;
1889
+ return _this3.handleOperation(async () => {
1890
+ return await post(_this3.fetch, `${_this3.url}/ListIndexes`, options, { headers: _this3.headers });
1891
+ });
1892
+ }
1893
+ /** Deletes a vector index and all its data */
1894
+ async deleteIndex(vectorBucketName, indexName) {
1895
+ var _this4 = this;
1896
+ return _this4.handleOperation(async () => {
1897
+ return await post(_this4.fetch, `${_this4.url}/DeleteIndex`, {
1898
+ vectorBucketName,
1899
+ indexName
1900
+ }, { headers: _this4.headers }) || {};
1901
+ });
1888
1902
  }
1889
1903
  };
1904
+
1905
+ //#endregion
1906
+ //#region src/packages/VectorDataApi.ts
1890
1907
  /**
1891
- * Type guard to check if an error is a StorageVectorsError
1892
- * @param error - The error to check
1893
- * @returns True if the error is a StorageVectorsError
1894
- */
1895
- function isStorageVectorsError(error) {
1896
- return typeof error === "object" && error !== null && "__isStorageVectorsError" in error;
1897
- }
1898
- /**
1899
- * API error returned from S3 Vectors service
1900
- * Includes HTTP status code and service-specific error code
1908
+ * @hidden
1909
+ * Base implementation for vector data operations.
1910
+ * Use {@link VectorIndexScope} via `supabase.storage.vectors.from('bucket').index('idx')` instead.
1901
1911
  */
1902
- var StorageVectorsApiError = class extends StorageVectorsError {
1903
- constructor(message, status, statusCode) {
1904
- super(message);
1905
- this.name = "StorageVectorsApiError";
1906
- this.status = status;
1907
- this.statusCode = statusCode;
1908
- }
1909
- toJSON() {
1910
- return {
1911
- name: this.name,
1912
- message: this.message,
1913
- status: this.status,
1914
- statusCode: this.statusCode
1915
- };
1916
- }
1917
- };
1918
- /**
1919
- * Unknown error that doesn't match expected error patterns
1920
- * Wraps the original error for debugging
1921
- */
1922
- var StorageVectorsUnknownError = class extends StorageVectorsError {
1923
- constructor(message, originalError) {
1924
- super(message);
1925
- this.name = "StorageVectorsUnknownError";
1926
- this.originalError = originalError;
1927
- }
1928
- };
1929
- /**
1930
- * Error codes specific to S3 Vectors API
1931
- * Maps AWS service errors to application-friendly error codes
1932
- */
1933
- let StorageVectorsErrorCode = /* @__PURE__ */ function(StorageVectorsErrorCode$1) {
1934
- /** Internal server fault (HTTP 500) */
1935
- StorageVectorsErrorCode$1["InternalError"] = "InternalError";
1936
- /** Resource already exists / conflict (HTTP 409) */
1937
- StorageVectorsErrorCode$1["S3VectorConflictException"] = "S3VectorConflictException";
1938
- /** Resource not found (HTTP 404) */
1939
- StorageVectorsErrorCode$1["S3VectorNotFoundException"] = "S3VectorNotFoundException";
1940
- /** Delete bucket while not empty (HTTP 400) */
1941
- StorageVectorsErrorCode$1["S3VectorBucketNotEmpty"] = "S3VectorBucketNotEmpty";
1942
- /** Exceeds bucket quota/limit (HTTP 400) */
1943
- StorageVectorsErrorCode$1["S3VectorMaxBucketsExceeded"] = "S3VectorMaxBucketsExceeded";
1944
- /** Exceeds index quota/limit (HTTP 400) */
1945
- StorageVectorsErrorCode$1["S3VectorMaxIndexesExceeded"] = "S3VectorMaxIndexesExceeded";
1946
- return StorageVectorsErrorCode$1;
1947
- }({});
1948
-
1949
- //#endregion
1950
- //#region src/lib/vectors/helpers.ts
1951
- /**
1952
- * Resolves the fetch implementation to use
1953
- * Uses custom fetch if provided, otherwise uses native fetch
1954
- *
1955
- * @param customFetch - Optional custom fetch implementation
1956
- * @returns Resolved fetch function
1957
- */
1958
- const resolveFetch = (customFetch) => {
1959
- if (customFetch) return (...args) => customFetch(...args);
1960
- return (...args) => fetch(...args);
1961
- };
1962
- /**
1963
- * Resolves the Response constructor to use
1964
- * Returns native Response constructor
1965
- *
1966
- * @returns Response constructor
1967
- */
1968
- const resolveResponse = () => {
1969
- return Response;
1970
- };
1971
- /**
1972
- * Determine if input is a plain object
1973
- * An object is plain if it's created by either {}, new Object(), or Object.create(null)
1974
- *
1975
- * @param value - Value to check
1976
- * @returns True if value is a plain object
1977
- * @source https://github.com/sindresorhus/is-plain-obj
1978
- */
1979
- const isPlainObject = (value) => {
1980
- if (typeof value !== "object" || value === null) return false;
1981
- const prototype = Object.getPrototypeOf(value);
1982
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
1983
- };
1984
- /**
1985
- * Normalizes a number array to float32 format
1986
- * Ensures all vector values are valid 32-bit floats
1987
- *
1988
- * @param values - Array of numbers to normalize
1989
- * @returns Normalized float32 array
1990
- */
1991
- const normalizeToFloat32 = (values) => {
1992
- return Array.from(new Float32Array(values));
1993
- };
1994
- /**
1995
- * Validates vector dimensions match expected dimension
1996
- * Throws error if dimensions don't match
1997
- *
1998
- * @param vector - Vector data to validate
1999
- * @param expectedDimension - Expected vector dimension
2000
- * @throws Error if dimensions don't match
2001
- */
2002
- const validateVectorDimension = (vector, expectedDimension) => {
2003
- if (expectedDimension !== void 0 && vector.float32.length !== expectedDimension) throw new Error(`Vector dimension mismatch: expected ${expectedDimension}, got ${vector.float32.length}`);
2004
- };
2005
-
2006
- //#endregion
2007
- //#region src/lib/vectors/fetch.ts
2008
- /**
2009
- * Extracts error message from various error response formats
2010
- * @param err - Error object from API
2011
- * @returns Human-readable error message
2012
- */
2013
- const _getErrorMessage = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err);
2014
- /**
2015
- * Handles fetch errors and converts them to StorageVectors error types
2016
- * @param error - The error caught from fetch
2017
- * @param reject - Promise rejection function
2018
- * @param options - Fetch options that may affect error handling
2019
- */
2020
- const handleError = async (error, reject, options) => {
2021
- if (error && typeof error === "object" && "status" in error && "ok" in error && typeof error.status === "number" && !(options === null || options === void 0 ? void 0 : options.noResolveJson)) {
2022
- const status = error.status || 500;
2023
- const responseError = error;
2024
- if (typeof responseError.json === "function") responseError.json().then((err) => {
2025
- const statusCode = (err === null || err === void 0 ? void 0 : err.statusCode) || (err === null || err === void 0 ? void 0 : err.code) || status + "";
2026
- reject(new StorageVectorsApiError(_getErrorMessage(err), status, statusCode));
2027
- }).catch(() => {
2028
- const statusCode = status + "";
2029
- reject(new StorageVectorsApiError(responseError.statusText || `HTTP ${status} error`, status, statusCode));
2030
- });
2031
- else {
2032
- const statusCode = status + "";
2033
- reject(new StorageVectorsApiError(responseError.statusText || `HTTP ${status} error`, status, statusCode));
2034
- }
2035
- } else reject(new StorageVectorsUnknownError(_getErrorMessage(error), error));
2036
- };
2037
- /**
2038
- * Builds request parameters for fetch calls
2039
- * @param method - HTTP method
2040
- * @param options - Custom fetch options
2041
- * @param parameters - Additional fetch parameters like AbortSignal
2042
- * @param body - Request body (will be JSON stringified if plain object)
2043
- * @returns Complete fetch request parameters
2044
- */
2045
- const _getRequestParams = (method, options, parameters, body) => {
2046
- const params = {
2047
- method,
2048
- headers: (options === null || options === void 0 ? void 0 : options.headers) || {}
2049
- };
2050
- if (method === "GET" || !body) return params;
2051
- if (isPlainObject(body)) {
2052
- params.headers = _objectSpread2({ "Content-Type": "application/json" }, options === null || options === void 0 ? void 0 : options.headers);
2053
- params.body = JSON.stringify(body);
2054
- } else params.body = body;
2055
- return _objectSpread2(_objectSpread2({}, params), parameters);
2056
- };
2057
- /**
2058
- * Internal request handler that wraps fetch with error handling
2059
- * @param fetcher - Fetch function to use
2060
- * @param method - HTTP method
2061
- * @param url - Request URL
2062
- * @param options - Custom fetch options
2063
- * @param parameters - Additional fetch parameters
2064
- * @param body - Request body
2065
- * @returns Promise with parsed response or error
2066
- */
2067
- async function _handleRequest(fetcher, method, url, options, parameters, body) {
2068
- return new Promise((resolve, reject) => {
2069
- fetcher(url, _getRequestParams(method, options, parameters, body)).then((result) => {
2070
- if (!result.ok) throw result;
2071
- if (options === null || options === void 0 ? void 0 : options.noResolveJson) return result;
2072
- const contentType = result.headers.get("content-type");
2073
- if (!contentType || !contentType.includes("application/json")) return {};
2074
- return result.json();
2075
- }).then((data) => resolve(data)).catch((error) => handleError(error, reject, options));
2076
- });
2077
- }
2078
- /**
2079
- * Performs a POST request
2080
- * @param fetcher - Fetch function to use
2081
- * @param url - Request URL
2082
- * @param body - Request body to be JSON stringified
2083
- * @param options - Custom fetch options
2084
- * @param parameters - Additional fetch parameters
2085
- * @returns Promise with parsed response
2086
- */
2087
- async function post(fetcher, url, body, options, parameters) {
2088
- return _handleRequest(fetcher, "POST", url, options, parameters, body);
2089
- }
2090
-
2091
- //#endregion
2092
- //#region src/lib/vectors/VectorIndexApi.ts
2093
- /**
2094
- * @hidden
2095
- * Base implementation for vector index operations.
2096
- * Use {@link VectorBucketScope} via `supabase.storage.vectors.from('bucket')` instead.
2097
- */
2098
- var VectorIndexApi = class {
2099
- /** Creates a new VectorIndexApi instance */
2100
- constructor(url, headers = {}, fetch$1) {
2101
- this.shouldThrowOnError = false;
2102
- this.url = url.replace(/\/$/, "");
2103
- this.headers = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), headers);
2104
- this.fetch = resolveFetch(fetch$1);
2105
- }
2106
- /** Enable throwing errors instead of returning them in the response */
2107
- throwOnError() {
2108
- this.shouldThrowOnError = true;
2109
- return this;
2110
- }
2111
- /** Creates a new vector index within a bucket */
2112
- async createIndex(options) {
2113
- var _this = this;
2114
- try {
2115
- return {
2116
- data: await post(_this.fetch, `${_this.url}/CreateIndex`, options, { headers: _this.headers }) || {},
2117
- error: null
2118
- };
2119
- } catch (error) {
2120
- if (_this.shouldThrowOnError) throw error;
2121
- if (isStorageVectorsError(error)) return {
2122
- data: null,
2123
- error
2124
- };
2125
- throw error;
2126
- }
2127
- }
2128
- /** Retrieves metadata for a specific vector index */
2129
- async getIndex(vectorBucketName, indexName) {
2130
- var _this2 = this;
2131
- try {
2132
- return {
2133
- data: await post(_this2.fetch, `${_this2.url}/GetIndex`, {
2134
- vectorBucketName,
2135
- indexName
2136
- }, { headers: _this2.headers }),
2137
- error: null
2138
- };
2139
- } catch (error) {
2140
- if (_this2.shouldThrowOnError) throw error;
2141
- if (isStorageVectorsError(error)) return {
2142
- data: null,
2143
- error
2144
- };
2145
- throw error;
2146
- }
2147
- }
2148
- /** Lists vector indexes within a bucket with optional filtering and pagination */
2149
- async listIndexes(options) {
2150
- var _this3 = this;
2151
- try {
2152
- return {
2153
- data: await post(_this3.fetch, `${_this3.url}/ListIndexes`, options, { headers: _this3.headers }),
2154
- error: null
2155
- };
2156
- } catch (error) {
2157
- if (_this3.shouldThrowOnError) throw error;
2158
- if (isStorageVectorsError(error)) return {
2159
- data: null,
2160
- error
2161
- };
2162
- throw error;
2163
- }
2164
- }
2165
- /** Deletes a vector index and all its data */
2166
- async deleteIndex(vectorBucketName, indexName) {
2167
- var _this4 = this;
2168
- try {
2169
- return {
2170
- data: await post(_this4.fetch, `${_this4.url}/DeleteIndex`, {
2171
- vectorBucketName,
2172
- indexName
2173
- }, { headers: _this4.headers }) || {},
2174
- error: null
2175
- };
2176
- } catch (error) {
2177
- if (_this4.shouldThrowOnError) throw error;
2178
- if (isStorageVectorsError(error)) return {
2179
- data: null,
2180
- error
2181
- };
2182
- throw error;
2183
- }
2184
- }
2185
- };
2186
-
2187
- //#endregion
2188
- //#region src/lib/vectors/VectorDataApi.ts
2189
- /**
2190
- * @hidden
2191
- * Base implementation for vector data operations.
2192
- * Use {@link VectorIndexScope} via `supabase.storage.vectors.from('bucket').index('idx')` instead.
2193
- */
2194
- var VectorDataApi = class {
2195
- /** Creates a new VectorDataApi instance */
2196
- constructor(url, headers = {}, fetch$1) {
2197
- this.shouldThrowOnError = false;
2198
- this.url = url.replace(/\/$/, "");
2199
- this.headers = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), headers);
2200
- this.fetch = resolveFetch(fetch$1);
2201
- }
2202
- /** Enable throwing errors instead of returning them in the response */
2203
- throwOnError() {
2204
- this.shouldThrowOnError = true;
2205
- return this;
1912
+ var VectorDataApi = class extends BaseApiClient {
1913
+ /** Creates a new VectorDataApi instance */
1914
+ constructor(url, headers = {}, fetch$1) {
1915
+ const finalUrl = url.replace(/\/$/, "");
1916
+ const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
1917
+ super(finalUrl, finalHeaders, fetch$1, "vectors");
2206
1918
  }
2207
1919
  /** Inserts or updates vectors in batch (1-500 per request) */
2208
1920
  async putVectors(options) {
2209
1921
  var _this = this;
2210
- try {
2211
- if (options.vectors.length < 1 || options.vectors.length > 500) throw new Error("Vector batch size must be between 1 and 500 items");
2212
- return {
2213
- data: await post(_this.fetch, `${_this.url}/PutVectors`, options, { headers: _this.headers }) || {},
2214
- error: null
2215
- };
2216
- } catch (error) {
2217
- if (_this.shouldThrowOnError) throw error;
2218
- if (isStorageVectorsError(error)) return {
2219
- data: null,
2220
- error
2221
- };
2222
- throw error;
2223
- }
1922
+ if (options.vectors.length < 1 || options.vectors.length > 500) throw new Error("Vector batch size must be between 1 and 500 items");
1923
+ return _this.handleOperation(async () => {
1924
+ return await post(_this.fetch, `${_this.url}/PutVectors`, options, { headers: _this.headers }) || {};
1925
+ });
2224
1926
  }
2225
1927
  /** Retrieves vectors by their keys in batch */
2226
1928
  async getVectors(options) {
2227
1929
  var _this2 = this;
2228
- try {
2229
- return {
2230
- data: await post(_this2.fetch, `${_this2.url}/GetVectors`, options, { headers: _this2.headers }),
2231
- error: null
2232
- };
2233
- } catch (error) {
2234
- if (_this2.shouldThrowOnError) throw error;
2235
- if (isStorageVectorsError(error)) return {
2236
- data: null,
2237
- error
2238
- };
2239
- throw error;
2240
- }
1930
+ return _this2.handleOperation(async () => {
1931
+ return await post(_this2.fetch, `${_this2.url}/GetVectors`, options, { headers: _this2.headers });
1932
+ });
2241
1933
  }
2242
1934
  /** Lists vectors in an index with pagination */
2243
1935
  async listVectors(options) {
2244
1936
  var _this3 = this;
2245
- try {
2246
- if (options.segmentCount !== void 0) {
2247
- if (options.segmentCount < 1 || options.segmentCount > 16) throw new Error("segmentCount must be between 1 and 16");
2248
- if (options.segmentIndex !== void 0) {
2249
- if (options.segmentIndex < 0 || options.segmentIndex >= options.segmentCount) throw new Error(`segmentIndex must be between 0 and ${options.segmentCount - 1}`);
2250
- }
1937
+ if (options.segmentCount !== void 0) {
1938
+ if (options.segmentCount < 1 || options.segmentCount > 16) throw new Error("segmentCount must be between 1 and 16");
1939
+ if (options.segmentIndex !== void 0) {
1940
+ if (options.segmentIndex < 0 || options.segmentIndex >= options.segmentCount) throw new Error(`segmentIndex must be between 0 and ${options.segmentCount - 1}`);
2251
1941
  }
2252
- return {
2253
- data: await post(_this3.fetch, `${_this3.url}/ListVectors`, options, { headers: _this3.headers }),
2254
- error: null
2255
- };
2256
- } catch (error) {
2257
- if (_this3.shouldThrowOnError) throw error;
2258
- if (isStorageVectorsError(error)) return {
2259
- data: null,
2260
- error
2261
- };
2262
- throw error;
2263
1942
  }
1943
+ return _this3.handleOperation(async () => {
1944
+ return await post(_this3.fetch, `${_this3.url}/ListVectors`, options, { headers: _this3.headers });
1945
+ });
2264
1946
  }
2265
1947
  /** Queries for similar vectors using approximate nearest neighbor search */
2266
1948
  async queryVectors(options) {
2267
1949
  var _this4 = this;
2268
- try {
2269
- return {
2270
- data: await post(_this4.fetch, `${_this4.url}/QueryVectors`, options, { headers: _this4.headers }),
2271
- error: null
2272
- };
2273
- } catch (error) {
2274
- if (_this4.shouldThrowOnError) throw error;
2275
- if (isStorageVectorsError(error)) return {
2276
- data: null,
2277
- error
2278
- };
2279
- throw error;
2280
- }
1950
+ return _this4.handleOperation(async () => {
1951
+ return await post(_this4.fetch, `${_this4.url}/QueryVectors`, options, { headers: _this4.headers });
1952
+ });
2281
1953
  }
2282
1954
  /** Deletes vectors by their keys in batch (1-500 per request) */
2283
1955
  async deleteVectors(options) {
2284
1956
  var _this5 = this;
2285
- try {
2286
- if (options.keys.length < 1 || options.keys.length > 500) throw new Error("Keys batch size must be between 1 and 500 items");
2287
- return {
2288
- data: await post(_this5.fetch, `${_this5.url}/DeleteVectors`, options, { headers: _this5.headers }) || {},
2289
- error: null
2290
- };
2291
- } catch (error) {
2292
- if (_this5.shouldThrowOnError) throw error;
2293
- if (isStorageVectorsError(error)) return {
2294
- data: null,
2295
- error
2296
- };
2297
- throw error;
2298
- }
1957
+ if (options.keys.length < 1 || options.keys.length > 500) throw new Error("Keys batch size must be between 1 and 500 items");
1958
+ return _this5.handleOperation(async () => {
1959
+ return await post(_this5.fetch, `${_this5.url}/DeleteVectors`, options, { headers: _this5.headers }) || {};
1960
+ });
2299
1961
  }
2300
1962
  };
2301
1963
 
2302
1964
  //#endregion
2303
- //#region src/lib/vectors/VectorBucketApi.ts
1965
+ //#region src/packages/VectorBucketApi.ts
2304
1966
  /**
2305
1967
  * @hidden
2306
1968
  * Base implementation for vector bucket operations.
2307
1969
  * Use {@link StorageVectorsClient} via `supabase.storage.vectors` instead.
2308
1970
  */
2309
- var VectorBucketApi = class {
1971
+ var VectorBucketApi = class extends BaseApiClient {
2310
1972
  /** Creates a new VectorBucketApi instance */
2311
1973
  constructor(url, headers = {}, fetch$1) {
2312
- this.shouldThrowOnError = false;
2313
- this.url = url.replace(/\/$/, "");
2314
- this.headers = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), headers);
2315
- this.fetch = resolveFetch(fetch$1);
2316
- }
2317
- /** Enable throwing errors instead of returning them in the response */
2318
- throwOnError() {
2319
- this.shouldThrowOnError = true;
2320
- return this;
1974
+ const finalUrl = url.replace(/\/$/, "");
1975
+ const finalHeaders = _objectSpread2(_objectSpread2({}, DEFAULT_HEADERS), {}, { "Content-Type": "application/json" }, headers);
1976
+ super(finalUrl, finalHeaders, fetch$1, "vectors");
2321
1977
  }
2322
1978
  /** Creates a new vector bucket */
2323
1979
  async createBucket(vectorBucketName) {
2324
1980
  var _this = this;
2325
- try {
2326
- return {
2327
- data: await post(_this.fetch, `${_this.url}/CreateVectorBucket`, { vectorBucketName }, { headers: _this.headers }) || {},
2328
- error: null
2329
- };
2330
- } catch (error) {
2331
- if (_this.shouldThrowOnError) throw error;
2332
- if (isStorageVectorsError(error)) return {
2333
- data: null,
2334
- error
2335
- };
2336
- throw error;
2337
- }
1981
+ return _this.handleOperation(async () => {
1982
+ return await post(_this.fetch, `${_this.url}/CreateVectorBucket`, { vectorBucketName }, { headers: _this.headers }) || {};
1983
+ });
2338
1984
  }
2339
1985
  /** Retrieves metadata for a specific vector bucket */
2340
1986
  async getBucket(vectorBucketName) {
2341
1987
  var _this2 = this;
2342
- try {
2343
- return {
2344
- data: await post(_this2.fetch, `${_this2.url}/GetVectorBucket`, { vectorBucketName }, { headers: _this2.headers }),
2345
- error: null
2346
- };
2347
- } catch (error) {
2348
- if (_this2.shouldThrowOnError) throw error;
2349
- if (isStorageVectorsError(error)) return {
2350
- data: null,
2351
- error
2352
- };
2353
- throw error;
2354
- }
1988
+ return _this2.handleOperation(async () => {
1989
+ return await post(_this2.fetch, `${_this2.url}/GetVectorBucket`, { vectorBucketName }, { headers: _this2.headers });
1990
+ });
2355
1991
  }
2356
1992
  /** Lists vector buckets with optional filtering and pagination */
2357
1993
  async listBuckets(options = {}) {
2358
1994
  var _this3 = this;
2359
- try {
2360
- return {
2361
- data: await post(_this3.fetch, `${_this3.url}/ListVectorBuckets`, options, { headers: _this3.headers }),
2362
- error: null
2363
- };
2364
- } catch (error) {
2365
- if (_this3.shouldThrowOnError) throw error;
2366
- if (isStorageVectorsError(error)) return {
2367
- data: null,
2368
- error
2369
- };
2370
- throw error;
2371
- }
1995
+ return _this3.handleOperation(async () => {
1996
+ return await post(_this3.fetch, `${_this3.url}/ListVectorBuckets`, options, { headers: _this3.headers });
1997
+ });
2372
1998
  }
2373
1999
  /** Deletes a vector bucket (must be empty first) */
2374
2000
  async deleteBucket(vectorBucketName) {
2375
2001
  var _this4 = this;
2376
- try {
2377
- return {
2378
- data: await post(_this4.fetch, `${_this4.url}/DeleteVectorBucket`, { vectorBucketName }, { headers: _this4.headers }) || {},
2379
- error: null
2380
- };
2381
- } catch (error) {
2382
- if (_this4.shouldThrowOnError) throw error;
2383
- if (isStorageVectorsError(error)) return {
2384
- data: null,
2385
- error
2386
- };
2387
- throw error;
2388
- }
2002
+ return _this4.handleOperation(async () => {
2003
+ return await post(_this4.fetch, `${_this4.url}/DeleteVectorBucket`, { vectorBucketName }, { headers: _this4.headers }) || {};
2004
+ });
2389
2005
  }
2390
2006
  };
2391
2007
 
2392
2008
  //#endregion
2393
- //#region src/lib/vectors/StorageVectorsClient.ts
2009
+ //#region src/packages/StorageVectorsClient.ts
2394
2010
  /**
2395
2011
  *
2396
2012
  * @alpha
@@ -3009,11 +2625,6 @@ exports.VectorBucketScope = VectorBucketScope;
3009
2625
  exports.VectorDataApi = VectorDataApi;
3010
2626
  exports.VectorIndexApi = VectorIndexApi;
3011
2627
  exports.VectorIndexScope = VectorIndexScope;
3012
- exports.isPlainObject = isPlainObject;
3013
2628
  exports.isStorageError = isStorageError;
3014
2629
  exports.isStorageVectorsError = isStorageVectorsError;
3015
- exports.normalizeToFloat32 = normalizeToFloat32;
3016
- exports.resolveFetch = resolveFetch;
3017
- exports.resolveResponse = resolveResponse;
3018
- exports.validateVectorDimension = validateVectorDimension;
3019
2630
  //# sourceMappingURL=index.cjs.map