@supabase/storage-js 2.87.4-canary.2 → 2.87.4-canary.4

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 (206) hide show
  1. package/README.md +2 -106
  2. package/dist/index.cjs +3019 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +2601 -0
  5. package/dist/index.d.cts.map +1 -0
  6. package/dist/index.d.mts +2601 -0
  7. package/dist/index.d.mts.map +1 -0
  8. package/dist/index.mjs +2998 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/umd/supabase.js +1 -1
  11. package/package.json +21 -12
  12. package/src/lib/version.ts +1 -1
  13. package/dist/main/StorageClient.d.ts +0 -64
  14. package/dist/main/StorageClient.d.ts.map +0 -1
  15. package/dist/main/StorageClient.js +0 -74
  16. package/dist/main/StorageClient.js.map +0 -1
  17. package/dist/main/index.d.ts +0 -7
  18. package/dist/main/index.d.ts.map +0 -1
  19. package/dist/main/index.js +0 -12
  20. package/dist/main/index.js.map +0 -1
  21. package/dist/main/lib/constants.d.ts +0 -4
  22. package/dist/main/lib/constants.d.ts.map +0 -1
  23. package/dist/main/lib/constants.js +0 -8
  24. package/dist/main/lib/constants.js.map +0 -1
  25. package/dist/main/lib/errors.d.ts +0 -21
  26. package/dist/main/lib/errors.d.ts.map +0 -1
  27. package/dist/main/lib/errors.js +0 -41
  28. package/dist/main/lib/errors.js.map +0 -1
  29. package/dist/main/lib/fetch.d.ts +0 -16
  30. package/dist/main/lib/fetch.d.ts.map +0 -1
  31. package/dist/main/lib/fetch.js +0 -95
  32. package/dist/main/lib/fetch.js.map +0 -1
  33. package/dist/main/lib/helpers.d.ts +0 -28
  34. package/dist/main/lib/helpers.d.ts.map +0 -1
  35. package/dist/main/lib/helpers.js +0 -87
  36. package/dist/main/lib/helpers.js.map +0 -1
  37. package/dist/main/lib/index.d.ts +0 -6
  38. package/dist/main/lib/index.d.ts.map +0 -1
  39. package/dist/main/lib/index.js +0 -9
  40. package/dist/main/lib/index.js.map +0 -1
  41. package/dist/main/lib/types.d.ts +0 -226
  42. package/dist/main/lib/types.d.ts.map +0 -1
  43. package/dist/main/lib/types.js +0 -3
  44. package/dist/main/lib/types.js.map +0 -1
  45. package/dist/main/lib/vectors/StorageVectorsClient.d.ts +0 -505
  46. package/dist/main/lib/vectors/StorageVectorsClient.d.ts.map +0 -1
  47. package/dist/main/lib/vectors/StorageVectorsClient.js +0 -582
  48. package/dist/main/lib/vectors/StorageVectorsClient.js.map +0 -1
  49. package/dist/main/lib/vectors/VectorBucketApi.d.ts +0 -32
  50. package/dist/main/lib/vectors/VectorBucketApi.d.ts.map +0 -1
  51. package/dist/main/lib/vectors/VectorBucketApi.js +0 -102
  52. package/dist/main/lib/vectors/VectorBucketApi.js.map +0 -1
  53. package/dist/main/lib/vectors/VectorDataApi.d.ts +0 -32
  54. package/dist/main/lib/vectors/VectorDataApi.d.ts.map +0 -1
  55. package/dist/main/lib/vectors/VectorDataApi.js +0 -147
  56. package/dist/main/lib/vectors/VectorDataApi.js.map +0 -1
  57. package/dist/main/lib/vectors/VectorIndexApi.d.ts +0 -47
  58. package/dist/main/lib/vectors/VectorIndexApi.d.ts.map +0 -1
  59. package/dist/main/lib/vectors/VectorIndexApi.js +0 -104
  60. package/dist/main/lib/vectors/VectorIndexApi.js.map +0 -1
  61. package/dist/main/lib/vectors/constants.d.ts +0 -5
  62. package/dist/main/lib/vectors/constants.d.ts.map +0 -1
  63. package/dist/main/lib/vectors/constants.js +0 -9
  64. package/dist/main/lib/vectors/constants.js.map +0 -1
  65. package/dist/main/lib/vectors/errors.d.ts +0 -55
  66. package/dist/main/lib/vectors/errors.d.ts.map +0 -1
  67. package/dist/main/lib/vectors/errors.js +0 -76
  68. package/dist/main/lib/vectors/errors.js.map +0 -1
  69. package/dist/main/lib/vectors/fetch.d.ts +0 -57
  70. package/dist/main/lib/vectors/fetch.d.ts.map +0 -1
  71. package/dist/main/lib/vectors/fetch.js +0 -167
  72. package/dist/main/lib/vectors/fetch.js.map +0 -1
  73. package/dist/main/lib/vectors/helpers.d.ts +0 -46
  74. package/dist/main/lib/vectors/helpers.d.ts.map +0 -1
  75. package/dist/main/lib/vectors/helpers.js +0 -74
  76. package/dist/main/lib/vectors/helpers.js.map +0 -1
  77. package/dist/main/lib/vectors/index.d.ts +0 -11
  78. package/dist/main/lib/vectors/index.d.ts.map +0 -1
  79. package/dist/main/lib/vectors/index.js +0 -31
  80. package/dist/main/lib/vectors/index.js.map +0 -1
  81. package/dist/main/lib/vectors/types.d.ts +0 -279
  82. package/dist/main/lib/vectors/types.d.ts.map +0 -1
  83. package/dist/main/lib/vectors/types.js +0 -3
  84. package/dist/main/lib/vectors/types.js.map +0 -1
  85. package/dist/main/lib/version.d.ts +0 -2
  86. package/dist/main/lib/version.d.ts.map +0 -1
  87. package/dist/main/lib/version.js +0 -11
  88. package/dist/main/lib/version.js.map +0 -1
  89. package/dist/main/packages/BlobDownloadBuilder.d.ts +0 -16
  90. package/dist/main/packages/BlobDownloadBuilder.d.ts.map +0 -1
  91. package/dist/main/packages/BlobDownloadBuilder.js +0 -55
  92. package/dist/main/packages/BlobDownloadBuilder.js.map +0 -1
  93. package/dist/main/packages/StorageAnalyticsClient.d.ts +0 -324
  94. package/dist/main/packages/StorageAnalyticsClient.d.ts.map +0 -1
  95. package/dist/main/packages/StorageAnalyticsClient.js +0 -395
  96. package/dist/main/packages/StorageAnalyticsClient.js.map +0 -1
  97. package/dist/main/packages/StorageBucketApi.d.ts +0 -266
  98. package/dist/main/packages/StorageBucketApi.d.ts.map +0 -1
  99. package/dist/main/packages/StorageBucketApi.js +0 -362
  100. package/dist/main/packages/StorageBucketApi.js.map +0 -1
  101. package/dist/main/packages/StorageFileApi.d.ts +0 -680
  102. package/dist/main/packages/StorageFileApi.d.ts.map +0 -1
  103. package/dist/main/packages/StorageFileApi.js +0 -1002
  104. package/dist/main/packages/StorageFileApi.js.map +0 -1
  105. package/dist/main/packages/StreamDownloadBuilder.d.ts +0 -9
  106. package/dist/main/packages/StreamDownloadBuilder.d.ts.map +0 -1
  107. package/dist/main/packages/StreamDownloadBuilder.js +0 -35
  108. package/dist/main/packages/StreamDownloadBuilder.js.map +0 -1
  109. package/dist/module/StorageClient.d.ts +0 -64
  110. package/dist/module/StorageClient.d.ts.map +0 -1
  111. package/dist/module/StorageClient.js +0 -69
  112. package/dist/module/StorageClient.js.map +0 -1
  113. package/dist/module/index.d.ts +0 -7
  114. package/dist/module/index.d.ts.map +0 -1
  115. package/dist/module/index.js +0 -6
  116. package/dist/module/index.js.map +0 -1
  117. package/dist/module/lib/constants.d.ts +0 -4
  118. package/dist/module/lib/constants.d.ts.map +0 -1
  119. package/dist/module/lib/constants.js +0 -5
  120. package/dist/module/lib/constants.js.map +0 -1
  121. package/dist/module/lib/errors.d.ts +0 -21
  122. package/dist/module/lib/errors.d.ts.map +0 -1
  123. package/dist/module/lib/errors.js +0 -34
  124. package/dist/module/lib/errors.js.map +0 -1
  125. package/dist/module/lib/fetch.d.ts +0 -16
  126. package/dist/module/lib/fetch.d.ts.map +0 -1
  127. package/dist/module/lib/fetch.js +0 -88
  128. package/dist/module/lib/fetch.js.map +0 -1
  129. package/dist/module/lib/helpers.d.ts +0 -28
  130. package/dist/module/lib/helpers.d.ts.map +0 -1
  131. package/dist/module/lib/helpers.js +0 -79
  132. package/dist/module/lib/helpers.js.map +0 -1
  133. package/dist/module/lib/index.d.ts +0 -6
  134. package/dist/module/lib/index.d.ts.map +0 -1
  135. package/dist/module/lib/index.js +0 -6
  136. package/dist/module/lib/index.js.map +0 -1
  137. package/dist/module/lib/types.d.ts +0 -226
  138. package/dist/module/lib/types.d.ts.map +0 -1
  139. package/dist/module/lib/types.js +0 -2
  140. package/dist/module/lib/types.js.map +0 -1
  141. package/dist/module/lib/vectors/StorageVectorsClient.d.ts +0 -505
  142. package/dist/module/lib/vectors/StorageVectorsClient.d.ts.map +0 -1
  143. package/dist/module/lib/vectors/StorageVectorsClient.js +0 -576
  144. package/dist/module/lib/vectors/StorageVectorsClient.js.map +0 -1
  145. package/dist/module/lib/vectors/VectorBucketApi.d.ts +0 -32
  146. package/dist/module/lib/vectors/VectorBucketApi.d.ts.map +0 -1
  147. package/dist/module/lib/vectors/VectorBucketApi.js +0 -99
  148. package/dist/module/lib/vectors/VectorBucketApi.js.map +0 -1
  149. package/dist/module/lib/vectors/VectorDataApi.d.ts +0 -32
  150. package/dist/module/lib/vectors/VectorDataApi.d.ts.map +0 -1
  151. package/dist/module/lib/vectors/VectorDataApi.js +0 -144
  152. package/dist/module/lib/vectors/VectorDataApi.js.map +0 -1
  153. package/dist/module/lib/vectors/VectorIndexApi.d.ts +0 -47
  154. package/dist/module/lib/vectors/VectorIndexApi.d.ts.map +0 -1
  155. package/dist/module/lib/vectors/VectorIndexApi.js +0 -101
  156. package/dist/module/lib/vectors/VectorIndexApi.js.map +0 -1
  157. package/dist/module/lib/vectors/constants.d.ts +0 -5
  158. package/dist/module/lib/vectors/constants.d.ts.map +0 -1
  159. package/dist/module/lib/vectors/constants.js +0 -6
  160. package/dist/module/lib/vectors/constants.js.map +0 -1
  161. package/dist/module/lib/vectors/errors.d.ts +0 -55
  162. package/dist/module/lib/vectors/errors.d.ts.map +0 -1
  163. package/dist/module/lib/vectors/errors.js +0 -69
  164. package/dist/module/lib/vectors/errors.js.map +0 -1
  165. package/dist/module/lib/vectors/fetch.d.ts +0 -57
  166. package/dist/module/lib/vectors/fetch.d.ts.map +0 -1
  167. package/dist/module/lib/vectors/fetch.js +0 -161
  168. package/dist/module/lib/vectors/fetch.js.map +0 -1
  169. package/dist/module/lib/vectors/helpers.d.ts +0 -46
  170. package/dist/module/lib/vectors/helpers.d.ts.map +0 -1
  171. package/dist/module/lib/vectors/helpers.js +0 -66
  172. package/dist/module/lib/vectors/helpers.js.map +0 -1
  173. package/dist/module/lib/vectors/index.d.ts +0 -11
  174. package/dist/module/lib/vectors/index.d.ts.map +0 -1
  175. package/dist/module/lib/vectors/index.js +0 -11
  176. package/dist/module/lib/vectors/index.js.map +0 -1
  177. package/dist/module/lib/vectors/types.d.ts +0 -279
  178. package/dist/module/lib/vectors/types.d.ts.map +0 -1
  179. package/dist/module/lib/vectors/types.js +0 -2
  180. package/dist/module/lib/vectors/types.js.map +0 -1
  181. package/dist/module/lib/version.d.ts +0 -2
  182. package/dist/module/lib/version.d.ts.map +0 -1
  183. package/dist/module/lib/version.js +0 -8
  184. package/dist/module/lib/version.js.map +0 -1
  185. package/dist/module/packages/BlobDownloadBuilder.d.ts +0 -16
  186. package/dist/module/packages/BlobDownloadBuilder.d.ts.map +0 -1
  187. package/dist/module/packages/BlobDownloadBuilder.js +0 -53
  188. package/dist/module/packages/BlobDownloadBuilder.js.map +0 -1
  189. package/dist/module/packages/StorageAnalyticsClient.d.ts +0 -324
  190. package/dist/module/packages/StorageAnalyticsClient.d.ts.map +0 -1
  191. package/dist/module/packages/StorageAnalyticsClient.js +0 -392
  192. package/dist/module/packages/StorageAnalyticsClient.js.map +0 -1
  193. package/dist/module/packages/StorageBucketApi.d.ts +0 -266
  194. package/dist/module/packages/StorageBucketApi.d.ts.map +0 -1
  195. package/dist/module/packages/StorageBucketApi.js +0 -359
  196. package/dist/module/packages/StorageBucketApi.js.map +0 -1
  197. package/dist/module/packages/StorageFileApi.d.ts +0 -680
  198. package/dist/module/packages/StorageFileApi.d.ts.map +0 -1
  199. package/dist/module/packages/StorageFileApi.js +0 -999
  200. package/dist/module/packages/StorageFileApi.js.map +0 -1
  201. package/dist/module/packages/StreamDownloadBuilder.d.ts +0 -9
  202. package/dist/module/packages/StreamDownloadBuilder.d.ts.map +0 -1
  203. package/dist/module/packages/StreamDownloadBuilder.js +0 -32
  204. package/dist/module/packages/StreamDownloadBuilder.js.map +0 -1
  205. package/dist/tsconfig.module.tsbuildinfo +0 -1
  206. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,362 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const constants_1 = require("../lib/constants");
5
- const errors_1 = require("../lib/errors");
6
- const fetch_1 = require("../lib/fetch");
7
- const helpers_1 = require("../lib/helpers");
8
- class StorageBucketApi {
9
- constructor(url, headers = {}, fetch, opts) {
10
- this.shouldThrowOnError = false;
11
- const baseUrl = new URL(url);
12
- // if legacy uri is used, replace with new storage host (disables request buffering to allow > 50GB uploads)
13
- // "project-ref.supabase.co" becomes "project-ref.storage.supabase.co"
14
- if (opts === null || opts === void 0 ? void 0 : opts.useNewHostname) {
15
- const isSupabaseHost = /supabase\.(co|in|red)$/.test(baseUrl.hostname);
16
- if (isSupabaseHost && !baseUrl.hostname.includes('storage.supabase.')) {
17
- baseUrl.hostname = baseUrl.hostname.replace('supabase.', 'storage.supabase.');
18
- }
19
- }
20
- this.url = baseUrl.href.replace(/\/$/, '');
21
- this.headers = Object.assign(Object.assign({}, constants_1.DEFAULT_HEADERS), headers);
22
- this.fetch = (0, helpers_1.resolveFetch)(fetch);
23
- }
24
- /**
25
- * Enable throwing errors instead of returning them.
26
- *
27
- * @category File Buckets
28
- */
29
- throwOnError() {
30
- this.shouldThrowOnError = true;
31
- return this;
32
- }
33
- /**
34
- * Retrieves the details of all Storage buckets within an existing project.
35
- *
36
- * @category File Buckets
37
- * @param options Query parameters for listing buckets
38
- * @param options.limit Maximum number of buckets to return
39
- * @param options.offset Number of buckets to skip
40
- * @param options.sortColumn Column to sort by ('id', 'name', 'created_at', 'updated_at')
41
- * @param options.sortOrder Sort order ('asc' or 'desc')
42
- * @param options.search Search term to filter bucket names
43
- * @returns Promise with response containing array of buckets or error
44
- *
45
- * @example List buckets
46
- * ```js
47
- * const { data, error } = await supabase
48
- * .storage
49
- * .listBuckets()
50
- * ```
51
- *
52
- * @example List buckets with options
53
- * ```js
54
- * const { data, error } = await supabase
55
- * .storage
56
- * .listBuckets({
57
- * limit: 10,
58
- * offset: 0,
59
- * sortColumn: 'created_at',
60
- * sortOrder: 'desc',
61
- * search: 'prod'
62
- * })
63
- * ```
64
- */
65
- listBuckets(options) {
66
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
67
- try {
68
- const queryString = this.listBucketOptionsToQueryString(options);
69
- const data = yield (0, fetch_1.get)(this.fetch, `${this.url}/bucket${queryString}`, {
70
- headers: this.headers,
71
- });
72
- return { data, error: null };
73
- }
74
- catch (error) {
75
- if (this.shouldThrowOnError) {
76
- throw error;
77
- }
78
- if ((0, errors_1.isStorageError)(error)) {
79
- return { data: null, error };
80
- }
81
- throw error;
82
- }
83
- });
84
- }
85
- /**
86
- * Retrieves the details of an existing Storage bucket.
87
- *
88
- * @category File Buckets
89
- * @param id The unique identifier of the bucket you would like to retrieve.
90
- * @returns Promise with response containing bucket details or error
91
- *
92
- * @example Get bucket
93
- * ```js
94
- * const { data, error } = await supabase
95
- * .storage
96
- * .getBucket('avatars')
97
- * ```
98
- *
99
- * Response:
100
- * ```json
101
- * {
102
- * "data": {
103
- * "id": "avatars",
104
- * "name": "avatars",
105
- * "owner": "",
106
- * "public": false,
107
- * "file_size_limit": 1024,
108
- * "allowed_mime_types": [
109
- * "image/png"
110
- * ],
111
- * "created_at": "2024-05-22T22:26:05.100Z",
112
- * "updated_at": "2024-05-22T22:26:05.100Z"
113
- * },
114
- * "error": null
115
- * }
116
- * ```
117
- */
118
- getBucket(id) {
119
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
120
- try {
121
- const data = yield (0, fetch_1.get)(this.fetch, `${this.url}/bucket/${id}`, { headers: this.headers });
122
- return { data, error: null };
123
- }
124
- catch (error) {
125
- if (this.shouldThrowOnError) {
126
- throw error;
127
- }
128
- if ((0, errors_1.isStorageError)(error)) {
129
- return { data: null, error };
130
- }
131
- throw error;
132
- }
133
- });
134
- }
135
- /**
136
- * Creates a new Storage bucket
137
- *
138
- * @category File Buckets
139
- * @param id A unique identifier for the bucket you are creating.
140
- * @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.
141
- * @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
142
- * The global file size limit takes precedence over this value.
143
- * The default value is null, which doesn't set a per bucket file size limit.
144
- * @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
145
- * The default value is null, which allows files with all mime types to be uploaded.
146
- * Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
147
- * @param options.type (private-beta) specifies the bucket type. see `BucketType` for more details.
148
- * - default bucket type is `STANDARD`
149
- * @returns Promise with response containing newly created bucket name or error
150
- *
151
- * @example Create bucket
152
- * ```js
153
- * const { data, error } = await supabase
154
- * .storage
155
- * .createBucket('avatars', {
156
- * public: false,
157
- * allowedMimeTypes: ['image/png'],
158
- * fileSizeLimit: 1024
159
- * })
160
- * ```
161
- *
162
- * Response:
163
- * ```json
164
- * {
165
- * "data": {
166
- * "name": "avatars"
167
- * },
168
- * "error": null
169
- * }
170
- * ```
171
- */
172
- createBucket(id_1) {
173
- return tslib_1.__awaiter(this, arguments, void 0, function* (id, options = {
174
- public: false,
175
- }) {
176
- try {
177
- const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/bucket`, {
178
- id,
179
- name: id,
180
- type: options.type,
181
- public: options.public,
182
- file_size_limit: options.fileSizeLimit,
183
- allowed_mime_types: options.allowedMimeTypes,
184
- }, { headers: this.headers });
185
- return { data, error: null };
186
- }
187
- catch (error) {
188
- if (this.shouldThrowOnError) {
189
- throw error;
190
- }
191
- if ((0, errors_1.isStorageError)(error)) {
192
- return { data: null, error };
193
- }
194
- throw error;
195
- }
196
- });
197
- }
198
- /**
199
- * Updates a Storage bucket
200
- *
201
- * @category File Buckets
202
- * @param id A unique identifier for the bucket you are updating.
203
- * @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.
204
- * @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
205
- * The global file size limit takes precedence over this value.
206
- * The default value is null, which doesn't set a per bucket file size limit.
207
- * @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
208
- * The default value is null, which allows files with all mime types to be uploaded.
209
- * Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
210
- * @returns Promise with response containing success message or error
211
- *
212
- * @example Update bucket
213
- * ```js
214
- * const { data, error } = await supabase
215
- * .storage
216
- * .updateBucket('avatars', {
217
- * public: false,
218
- * allowedMimeTypes: ['image/png'],
219
- * fileSizeLimit: 1024
220
- * })
221
- * ```
222
- *
223
- * Response:
224
- * ```json
225
- * {
226
- * "data": {
227
- * "message": "Successfully updated"
228
- * },
229
- * "error": null
230
- * }
231
- * ```
232
- */
233
- updateBucket(id, options) {
234
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
235
- try {
236
- const data = yield (0, fetch_1.put)(this.fetch, `${this.url}/bucket/${id}`, {
237
- id,
238
- name: id,
239
- public: options.public,
240
- file_size_limit: options.fileSizeLimit,
241
- allowed_mime_types: options.allowedMimeTypes,
242
- }, { headers: this.headers });
243
- return { data, error: null };
244
- }
245
- catch (error) {
246
- if (this.shouldThrowOnError) {
247
- throw error;
248
- }
249
- if ((0, errors_1.isStorageError)(error)) {
250
- return { data: null, error };
251
- }
252
- throw error;
253
- }
254
- });
255
- }
256
- /**
257
- * Removes all objects inside a single bucket.
258
- *
259
- * @category File Buckets
260
- * @param id The unique identifier of the bucket you would like to empty.
261
- * @returns Promise with success message or error
262
- *
263
- * @example Empty bucket
264
- * ```js
265
- * const { data, error } = await supabase
266
- * .storage
267
- * .emptyBucket('avatars')
268
- * ```
269
- *
270
- * Response:
271
- * ```json
272
- * {
273
- * "data": {
274
- * "message": "Successfully emptied"
275
- * },
276
- * "error": null
277
- * }
278
- * ```
279
- */
280
- emptyBucket(id) {
281
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
282
- try {
283
- const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/bucket/${id}/empty`, {}, { headers: this.headers });
284
- return { data, error: null };
285
- }
286
- catch (error) {
287
- if (this.shouldThrowOnError) {
288
- throw error;
289
- }
290
- if ((0, errors_1.isStorageError)(error)) {
291
- return { data: null, error };
292
- }
293
- throw error;
294
- }
295
- });
296
- }
297
- /**
298
- * Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
299
- * You must first `empty()` the bucket.
300
- *
301
- * @category File Buckets
302
- * @param id The unique identifier of the bucket you would like to delete.
303
- * @returns Promise with success message or error
304
- *
305
- * @example Delete bucket
306
- * ```js
307
- * const { data, error } = await supabase
308
- * .storage
309
- * .deleteBucket('avatars')
310
- * ```
311
- *
312
- * Response:
313
- * ```json
314
- * {
315
- * "data": {
316
- * "message": "Successfully deleted"
317
- * },
318
- * "error": null
319
- * }
320
- * ```
321
- */
322
- deleteBucket(id) {
323
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
324
- try {
325
- const data = yield (0, fetch_1.remove)(this.fetch, `${this.url}/bucket/${id}`, {}, { headers: this.headers });
326
- return { data, error: null };
327
- }
328
- catch (error) {
329
- if (this.shouldThrowOnError) {
330
- throw error;
331
- }
332
- if ((0, errors_1.isStorageError)(error)) {
333
- return { data: null, error };
334
- }
335
- throw error;
336
- }
337
- });
338
- }
339
- listBucketOptionsToQueryString(options) {
340
- const params = {};
341
- if (options) {
342
- if ('limit' in options) {
343
- params.limit = String(options.limit);
344
- }
345
- if ('offset' in options) {
346
- params.offset = String(options.offset);
347
- }
348
- if (options.search) {
349
- params.search = options.search;
350
- }
351
- if (options.sortColumn) {
352
- params.sortColumn = options.sortColumn;
353
- }
354
- if (options.sortOrder) {
355
- params.sortOrder = options.sortOrder;
356
- }
357
- }
358
- return Object.keys(params).length > 0 ? '?' + new URLSearchParams(params).toString() : '';
359
- }
360
- }
361
- exports.default = StorageBucketApi;
362
- //# sourceMappingURL=StorageBucketApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StorageBucketApi.js","sourceRoot":"","sources":["../../../src/packages/StorageBucketApi.ts"],"names":[],"mappings":";;;AAAA,gDAAkD;AAClD,0CAA4D;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