@supabase/storage-js 2.103.3 → 2.104.0-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 +38 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +38 -11
- package/dist/index.mjs.map +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +1 -1
- package/src/lib/common/BaseApiClient.ts +3 -2
- package/src/lib/common/fetch.ts +2 -14
- package/src/lib/common/headers.ts +43 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/StorageFileApi.ts +4 -1
package/dist/index.cjs
CHANGED
|
@@ -178,6 +178,39 @@ let StorageVectorsErrorCode = /* @__PURE__ */ function(StorageVectorsErrorCode$1
|
|
|
178
178
|
return StorageVectorsErrorCode$1;
|
|
179
179
|
}({});
|
|
180
180
|
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/lib/common/headers.ts
|
|
183
|
+
/**
|
|
184
|
+
* Sets a header with case-insensitive deduplication.
|
|
185
|
+
* Removes any existing headers whose name matches (case-insensitive),
|
|
186
|
+
* then sets the value under the lowercase key. Does not mutate the input object.
|
|
187
|
+
*
|
|
188
|
+
* @param headers - Existing headers object
|
|
189
|
+
* @param name - Header name to set (stored as lowercase)
|
|
190
|
+
* @param value - Header value
|
|
191
|
+
* @returns New headers object with the header set
|
|
192
|
+
*/
|
|
193
|
+
function setHeader(headers, name, value) {
|
|
194
|
+
const result = _objectSpread2({}, headers);
|
|
195
|
+
const nameLower = name.toLowerCase();
|
|
196
|
+
for (const key of Object.keys(result)) if (key.toLowerCase() === nameLower) delete result[key];
|
|
197
|
+
result[nameLower] = value;
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Normalizes all header keys to lowercase with case-insensitive deduplication.
|
|
202
|
+
* When duplicate keys exist (differing only in case), the last value wins.
|
|
203
|
+
* Does not mutate the input object.
|
|
204
|
+
*
|
|
205
|
+
* @param headers - Headers object to normalize
|
|
206
|
+
* @returns New headers object with all keys lowercased
|
|
207
|
+
*/
|
|
208
|
+
function normalizeHeaders(headers) {
|
|
209
|
+
const result = {};
|
|
210
|
+
for (const [key, value] of Object.entries(headers)) result[key.toLowerCase()] = value;
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
181
214
|
//#endregion
|
|
182
215
|
//#region src/lib/common/helpers.ts
|
|
183
216
|
/**
|
|
@@ -295,18 +328,12 @@ const _getRequestParams = (method, options, parameters, body) => {
|
|
|
295
328
|
const headers = (options === null || options === void 0 ? void 0 : options.headers) || {};
|
|
296
329
|
let contentType;
|
|
297
330
|
for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === "content-type") contentType = value;
|
|
298
|
-
params.headers =
|
|
331
|
+
params.headers = setHeader(headers, "Content-Type", (_contentType = contentType) !== null && _contentType !== void 0 ? _contentType : "application/json");
|
|
299
332
|
params.body = JSON.stringify(body);
|
|
300
333
|
} else params.body = body;
|
|
301
334
|
if (options === null || options === void 0 ? void 0 : options.duplex) params.duplex = options.duplex;
|
|
302
335
|
return _objectSpread2(_objectSpread2({}, params), parameters);
|
|
303
336
|
};
|
|
304
|
-
function setRequestHeader(headers, name, value) {
|
|
305
|
-
const nextHeaders = _objectSpread2({}, headers);
|
|
306
|
-
for (const key of Object.keys(nextHeaders)) if (key.toLowerCase() === name.toLowerCase()) delete nextHeaders[key];
|
|
307
|
-
nextHeaders[name] = value;
|
|
308
|
-
return nextHeaders;
|
|
309
|
-
}
|
|
310
337
|
/**
|
|
311
338
|
* Internal request handler that wraps fetch with error handling
|
|
312
339
|
* @param fetcher - Fetch function to use
|
|
@@ -380,7 +407,7 @@ var BaseApiClient = class {
|
|
|
380
407
|
constructor(url, headers = {}, fetch$1, namespace = "storage") {
|
|
381
408
|
this.shouldThrowOnError = false;
|
|
382
409
|
this.url = url;
|
|
383
|
-
this.headers =
|
|
410
|
+
this.headers = normalizeHeaders(headers);
|
|
384
411
|
this.fetch = resolveFetch(fetch$1);
|
|
385
412
|
this.namespace = namespace;
|
|
386
413
|
}
|
|
@@ -403,7 +430,7 @@ var BaseApiClient = class {
|
|
|
403
430
|
* @returns this - For method chaining
|
|
404
431
|
*/
|
|
405
432
|
setHeader(name, value) {
|
|
406
|
-
this.headers =
|
|
433
|
+
this.headers = setHeader(this.headers, name, value);
|
|
407
434
|
return this;
|
|
408
435
|
}
|
|
409
436
|
/**
|
|
@@ -572,7 +599,7 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
572
599
|
if (metadata) headers["x-metadata"] = _this.toBase64(_this.encodeMetadata(metadata));
|
|
573
600
|
if ((typeof ReadableStream !== "undefined" && body instanceof ReadableStream || body && typeof body === "object" && "pipe" in body && typeof body.pipe === "function") && !options.duplex) options.duplex = "half";
|
|
574
601
|
}
|
|
575
|
-
if (fileOptions === null || fileOptions === void 0 ? void 0 : fileOptions.headers) headers =
|
|
602
|
+
if (fileOptions === null || fileOptions === void 0 ? void 0 : fileOptions.headers) for (const [key, value] of Object.entries(fileOptions.headers)) headers = setHeader(headers, key, value);
|
|
576
603
|
const cleanPath = _this._removeEmptyFolders(path);
|
|
577
604
|
const _path = _this._getFinalPath(cleanPath);
|
|
578
605
|
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 } : {}));
|
|
@@ -1454,7 +1481,7 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1454
1481
|
|
|
1455
1482
|
//#endregion
|
|
1456
1483
|
//#region src/lib/version.ts
|
|
1457
|
-
const version = "2.
|
|
1484
|
+
const version = "2.104.0-canary.1";
|
|
1458
1485
|
|
|
1459
1486
|
//#endregion
|
|
1460
1487
|
//#region src/lib/constants.ts
|