@supabase/storage-js 2.98.0 → 2.98.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +78 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -25
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +171 -25
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +78 -10
- package/dist/index.mjs.map +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +1 -1
- package/src/lib/common/fetch.ts +1 -1
- package/src/lib/types.ts +101 -20
- package/src/lib/version.ts +1 -1
- package/src/packages/StorageFileApi.ts +94 -10
package/dist/index.cjs
CHANGED
|
@@ -260,7 +260,7 @@ const _getErrorMessage = (err) => {
|
|
|
260
260
|
* @param namespace - Error namespace ('storage' or 'vectors')
|
|
261
261
|
*/
|
|
262
262
|
const handleError = async (error, reject, options, namespace) => {
|
|
263
|
-
if (error && typeof error === "object" && "status" in error && "ok" in error && typeof error.status === "number"
|
|
263
|
+
if (error && typeof error === "object" && "status" in error && "ok" in error && typeof error.status === "number") {
|
|
264
264
|
const responseError = error;
|
|
265
265
|
const status = responseError.status || 500;
|
|
266
266
|
if (typeof responseError.json === "function") responseError.json().then((err) => {
|
|
@@ -911,7 +911,8 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
911
911
|
let _path = _this8._getFinalPath(path);
|
|
912
912
|
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 });
|
|
913
913
|
const downloadQueryParam = (options === null || options === void 0 ? void 0 : options.download) ? `&download=${options.download === true ? "" : options.download}` : "";
|
|
914
|
-
|
|
914
|
+
const returnedPath = (options === null || options === void 0 ? void 0 : options.transform) && data.signedURL.includes("/object/sign/") ? data.signedURL.replace("/object/sign/", "/render/image/sign/") : data.signedURL;
|
|
915
|
+
return { signedUrl: encodeURI(`${_this8.url}${returnedPath}${downloadQueryParam}`) };
|
|
915
916
|
});
|
|
916
917
|
}
|
|
917
918
|
/**
|
|
@@ -1035,6 +1036,9 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1035
1036
|
/**
|
|
1036
1037
|
* Retrieves the details of an existing file.
|
|
1037
1038
|
*
|
|
1039
|
+
* Returns detailed file metadata including size, content type, and timestamps.
|
|
1040
|
+
* Note: The API returns `last_modified` field, not `updated_at`.
|
|
1041
|
+
*
|
|
1038
1042
|
* @category File Buckets
|
|
1039
1043
|
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
1040
1044
|
* @returns Promise with response containing file metadata or error
|
|
@@ -1045,6 +1049,11 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1045
1049
|
* .storage
|
|
1046
1050
|
* .from('avatars')
|
|
1047
1051
|
* .info('folder/avatar1.png')
|
|
1052
|
+
*
|
|
1053
|
+
* if (data) {
|
|
1054
|
+
* console.log('Last modified:', data.lastModified)
|
|
1055
|
+
* console.log('Size:', data.size)
|
|
1056
|
+
* }
|
|
1048
1057
|
* ```
|
|
1049
1058
|
*/
|
|
1050
1059
|
async info(path) {
|
|
@@ -1080,9 +1089,10 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1080
1089
|
};
|
|
1081
1090
|
} catch (error) {
|
|
1082
1091
|
if (_this11.shouldThrowOnError) throw error;
|
|
1083
|
-
if (isStorageError(error)
|
|
1084
|
-
|
|
1085
|
-
|
|
1092
|
+
if (isStorageError(error)) {
|
|
1093
|
+
var _error$originalError;
|
|
1094
|
+
const status = error instanceof StorageApiError ? error.status : error instanceof StorageUnknownError ? (_error$originalError = error.originalError) === null || _error$originalError === void 0 ? void 0 : _error$originalError.status : void 0;
|
|
1095
|
+
if (status !== void 0 && [400, 404].includes(status)) return {
|
|
1086
1096
|
data: false,
|
|
1087
1097
|
error
|
|
1088
1098
|
};
|
|
@@ -1155,6 +1165,9 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1155
1165
|
/**
|
|
1156
1166
|
* Deletes files within the same bucket
|
|
1157
1167
|
*
|
|
1168
|
+
* Returns an array of FileObject entries for the deleted files. Note that deprecated
|
|
1169
|
+
* fields like `bucket_id` may or may not be present in the response - do not rely on them.
|
|
1170
|
+
*
|
|
1158
1171
|
* @category File Buckets
|
|
1159
1172
|
* @param paths An array of files to delete, including the path and file name. For example [`'folder/image.png'`].
|
|
1160
1173
|
* @returns Promise with response containing array of deleted file objects or error
|
|
@@ -1193,11 +1206,16 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1193
1206
|
/**
|
|
1194
1207
|
* Lists all the files and folders within a path of the bucket.
|
|
1195
1208
|
*
|
|
1209
|
+
* **Important:** For folder entries, fields like `id`, `updated_at`, `created_at`,
|
|
1210
|
+
* `last_accessed_at`, and `metadata` will be `null`. Only files have these fields populated.
|
|
1211
|
+
* Additionally, deprecated fields like `bucket_id`, `owner`, and `buckets` are NOT returned
|
|
1212
|
+
* by this method.
|
|
1213
|
+
*
|
|
1196
1214
|
* @category File Buckets
|
|
1197
1215
|
* @param path The folder path.
|
|
1198
1216
|
* @param options Search options including limit (defaults to 100), offset, sortBy, and search
|
|
1199
1217
|
* @param parameters Optional fetch parameters including signal for cancellation
|
|
1200
|
-
* @returns Promise with response containing array of files or error
|
|
1218
|
+
* @returns Promise with response containing array of files/folders or error
|
|
1201
1219
|
*
|
|
1202
1220
|
* @example List files in a bucket
|
|
1203
1221
|
* ```js
|
|
@@ -1209,9 +1227,20 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1209
1227
|
* offset: 0,
|
|
1210
1228
|
* sortBy: { column: 'name', order: 'asc' },
|
|
1211
1229
|
* })
|
|
1230
|
+
*
|
|
1231
|
+
* // Handle files vs folders
|
|
1232
|
+
* data?.forEach(item => {
|
|
1233
|
+
* if (item.id !== null) {
|
|
1234
|
+
* // It's a file
|
|
1235
|
+
* console.log('File:', item.name, 'Size:', item.metadata?.size)
|
|
1236
|
+
* } else {
|
|
1237
|
+
* // It's a folder
|
|
1238
|
+
* console.log('Folder:', item.name)
|
|
1239
|
+
* }
|
|
1240
|
+
* })
|
|
1212
1241
|
* ```
|
|
1213
1242
|
*
|
|
1214
|
-
* Response:
|
|
1243
|
+
* Response (file entry):
|
|
1215
1244
|
* ```json
|
|
1216
1245
|
* {
|
|
1217
1246
|
* "data": [
|
|
@@ -1257,11 +1286,50 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1257
1286
|
});
|
|
1258
1287
|
}
|
|
1259
1288
|
/**
|
|
1289
|
+
* Lists all the files and folders within a bucket using the V2 API with pagination support.
|
|
1290
|
+
*
|
|
1291
|
+
* **Important:** Folder entries in the `folders` array only contain `name` and optionally `key` —
|
|
1292
|
+
* they have no `id`, timestamps, or `metadata` fields. Full file metadata is only available
|
|
1293
|
+
* on entries in the `objects` array.
|
|
1294
|
+
*
|
|
1260
1295
|
* @experimental this method signature might change in the future
|
|
1261
1296
|
*
|
|
1262
1297
|
* @category File Buckets
|
|
1263
|
-
* @param options
|
|
1264
|
-
* @param parameters
|
|
1298
|
+
* @param options Search options including prefix, cursor for pagination, limit, with_delimiter
|
|
1299
|
+
* @param parameters Optional fetch parameters including signal for cancellation
|
|
1300
|
+
* @returns Promise with response containing folders/objects arrays with pagination info or error
|
|
1301
|
+
*
|
|
1302
|
+
* @example List files with pagination
|
|
1303
|
+
* ```js
|
|
1304
|
+
* const { data, error } = await supabase
|
|
1305
|
+
* .storage
|
|
1306
|
+
* .from('avatars')
|
|
1307
|
+
* .listV2({
|
|
1308
|
+
* prefix: 'folder/',
|
|
1309
|
+
* limit: 100,
|
|
1310
|
+
* })
|
|
1311
|
+
*
|
|
1312
|
+
* // Handle pagination
|
|
1313
|
+
* if (data?.hasNext) {
|
|
1314
|
+
* const nextPage = await supabase
|
|
1315
|
+
* .storage
|
|
1316
|
+
* .from('avatars')
|
|
1317
|
+
* .listV2({
|
|
1318
|
+
* prefix: 'folder/',
|
|
1319
|
+
* cursor: data.nextCursor,
|
|
1320
|
+
* })
|
|
1321
|
+
* }
|
|
1322
|
+
*
|
|
1323
|
+
* // Handle files vs folders
|
|
1324
|
+
* data?.objects.forEach(file => {
|
|
1325
|
+
* if (file.id !== null) {
|
|
1326
|
+
* console.log('File:', file.name, 'Size:', file.metadata?.size)
|
|
1327
|
+
* }
|
|
1328
|
+
* })
|
|
1329
|
+
* data?.folders.forEach(folder => {
|
|
1330
|
+
* console.log('Folder:', folder.name)
|
|
1331
|
+
* })
|
|
1332
|
+
* ```
|
|
1265
1333
|
*/
|
|
1266
1334
|
async listV2(options, parameters) {
|
|
1267
1335
|
var _this14 = this;
|
|
@@ -1296,7 +1364,7 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1296
1364
|
|
|
1297
1365
|
//#endregion
|
|
1298
1366
|
//#region src/lib/version.ts
|
|
1299
|
-
const version = "2.98.
|
|
1367
|
+
const version = "2.98.1-canary.1";
|
|
1300
1368
|
|
|
1301
1369
|
//#endregion
|
|
1302
1370
|
//#region src/lib/constants.ts
|