@supabase/storage-js
Advanced tools
Comparing version 1.6.2 to 1.6.3
@@ -12,6 +12,6 @@ export declare type Fetch = typeof fetch; | ||
export declare type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
export declare function get(fetcher: Fetch | undefined, url: string, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function post(fetcher: Fetch | undefined, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function put(fetcher: Fetch | undefined, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function remove(fetcher: Fetch | undefined, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function get(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function post(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function put(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function remove(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
//# sourceMappingURL=fetch.d.ts.map |
@@ -11,8 +11,4 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.remove = exports.put = exports.post = exports.get = void 0; | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
const _getErrorMessage = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err); | ||
@@ -39,3 +35,3 @@ const handleError = (error, reject) => { | ||
}; | ||
function _handleRequest(fetcher = cross_fetch_1.default, method, url, options, parameters, body) { | ||
function _handleRequest(fetcher, method, url, options, parameters, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -42,0 +38,0 @@ return new Promise((resolve, reject) => { |
@@ -1,2 +0,4 @@ | ||
export declare const isBrowser: () => boolean; | ||
declare type Fetch = typeof fetch; | ||
export declare const resolveFetch: (customFetch?: typeof fetch | undefined) => Fetch; | ||
export {}; | ||
//# sourceMappingURL=helpers.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isBrowser = void 0; | ||
exports.isBrowser = () => typeof window !== 'undefined'; | ||
exports.resolveFetch = void 0; | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
exports.resolveFetch = (customFetch) => { | ||
if (customFetch) { | ||
return customFetch; | ||
} | ||
else if (typeof fetch === 'undefined') { | ||
return cross_fetch_1.default; | ||
} | ||
else { | ||
return fetch; | ||
} | ||
}; | ||
//# sourceMappingURL=helpers.js.map |
@@ -8,3 +8,3 @@ import { Fetch } from './fetch'; | ||
}; | ||
protected fetch?: Fetch; | ||
protected fetch: Fetch; | ||
constructor(url: string, headers?: { | ||
@@ -11,0 +11,0 @@ [key: string]: string; |
@@ -13,4 +13,5 @@ "use strict"; | ||
exports.StorageBucketApi = void 0; | ||
const constants_1 = require("./constants"); | ||
const fetch_1 = require("./fetch"); | ||
const constants_1 = require("./constants"); | ||
const helpers_1 = require("./helpers"); | ||
class StorageBucketApi { | ||
@@ -20,3 +21,3 @@ constructor(url, headers = {}, fetch) { | ||
this.headers = Object.assign(Object.assign({}, constants_1.DEFAULT_HEADERS), headers); | ||
this.fetch = fetch; | ||
this.fetch = helpers_1.resolveFetch(fetch); | ||
} | ||
@@ -23,0 +24,0 @@ /** |
@@ -10,3 +10,3 @@ /// <reference types="node" /> | ||
protected bucketId?: string; | ||
protected fetch?: Fetch; | ||
protected fetch: Fetch; | ||
constructor(url: string, headers?: { | ||
@@ -13,0 +13,0 @@ [key: string]: string; |
@@ -11,9 +11,6 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StorageFileApi = void 0; | ||
const fetch_1 = require("./fetch"); | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
const helpers_1 = require("./helpers"); | ||
const DEFAULT_SEARCH_OPTIONS = { | ||
@@ -37,3 +34,3 @@ limit: 100, | ||
this.bucketId = bucketId; | ||
this.fetch = fetch; | ||
this.fetch = helpers_1.resolveFetch(fetch); | ||
} | ||
@@ -52,3 +49,2 @@ /** | ||
uploadOrUpdate(method, path, fileBody, fileOptions) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -75,4 +71,3 @@ try { | ||
const _path = this._getFinalPath(cleanPath); | ||
const fetcher = (_a = this.fetch) !== null && _a !== void 0 ? _a : cross_fetch_1.default; | ||
const res = yield fetcher(`${this.url}/object/${_path}`, { | ||
const res = yield this.fetch(`${this.url}/object/${_path}`, { | ||
method, | ||
@@ -79,0 +74,0 @@ body: body, |
@@ -12,6 +12,6 @@ export declare type Fetch = typeof fetch; | ||
export declare type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
export declare function get(fetcher: Fetch | undefined, url: string, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function post(fetcher: Fetch | undefined, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function put(fetcher: Fetch | undefined, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function remove(fetcher: Fetch | undefined, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function get(fetcher: Fetch, url: string, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function post(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function put(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
export declare function remove(fetcher: Fetch, url: string, body: object, options?: FetchOptions, parameters?: FetchParameters): Promise<any>; | ||
//# sourceMappingURL=fetch.d.ts.map |
@@ -10,3 +10,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import crossFetch from 'cross-fetch'; | ||
const _getErrorMessage = (err) => err.msg || err.message || err.error_description || err.error || JSON.stringify(err); | ||
@@ -33,3 +32,3 @@ const handleError = (error, reject) => { | ||
}; | ||
function _handleRequest(fetcher = crossFetch, method, url, options, parameters, body) { | ||
function _handleRequest(fetcher, method, url, options, parameters, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -36,0 +35,0 @@ return new Promise((resolve, reject) => { |
@@ -1,2 +0,4 @@ | ||
export declare const isBrowser: () => boolean; | ||
declare type Fetch = typeof fetch; | ||
export declare const resolveFetch: (customFetch?: typeof fetch | undefined) => Fetch; | ||
export {}; | ||
//# sourceMappingURL=helpers.d.ts.map |
@@ -1,2 +0,13 @@ | ||
export const isBrowser = () => typeof window !== 'undefined'; | ||
import crossFetch from 'cross-fetch'; | ||
export const resolveFetch = (customFetch) => { | ||
if (customFetch) { | ||
return customFetch; | ||
} | ||
else if (typeof fetch === 'undefined') { | ||
return crossFetch; | ||
} | ||
else { | ||
return fetch; | ||
} | ||
}; | ||
//# sourceMappingURL=helpers.js.map |
@@ -8,3 +8,3 @@ import { Fetch } from './fetch'; | ||
}; | ||
protected fetch?: Fetch; | ||
protected fetch: Fetch; | ||
constructor(url: string, headers?: { | ||
@@ -11,0 +11,0 @@ [key: string]: string; |
@@ -10,4 +10,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { DEFAULT_HEADERS } from './constants'; | ||
import { get, post, put, remove } from './fetch'; | ||
import { DEFAULT_HEADERS } from './constants'; | ||
import { resolveFetch } from './helpers'; | ||
export class StorageBucketApi { | ||
@@ -17,3 +18,3 @@ constructor(url, headers = {}, fetch) { | ||
this.headers = Object.assign(Object.assign({}, DEFAULT_HEADERS), headers); | ||
this.fetch = fetch; | ||
this.fetch = resolveFetch(fetch); | ||
} | ||
@@ -20,0 +21,0 @@ /** |
@@ -10,3 +10,3 @@ /// <reference types="node" /> | ||
protected bucketId?: string; | ||
protected fetch?: Fetch; | ||
protected fetch: Fetch; | ||
constructor(url: string, headers?: { | ||
@@ -13,0 +13,0 @@ [key: string]: string; |
@@ -11,3 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { get, post, remove } from './fetch'; | ||
import fetch from 'cross-fetch'; | ||
import { resolveFetch } from './helpers'; | ||
const DEFAULT_SEARCH_OPTIONS = { | ||
@@ -31,3 +31,3 @@ limit: 100, | ||
this.bucketId = bucketId; | ||
this.fetch = fetch; | ||
this.fetch = resolveFetch(fetch); | ||
} | ||
@@ -46,3 +46,2 @@ /** | ||
uploadOrUpdate(method, path, fileBody, fileOptions) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -69,4 +68,3 @@ try { | ||
const _path = this._getFinalPath(cleanPath); | ||
const fetcher = (_a = this.fetch) !== null && _a !== void 0 ? _a : fetch; | ||
const res = yield fetcher(`${this.url}/object/${_path}`, { | ||
const res = yield this.fetch(`${this.url}/object/${_path}`, { | ||
method, | ||
@@ -73,0 +71,0 @@ body: body, |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.supabase=e():t.supabase=e()}(self,(function(){return t={98:function(t,e){var r="undefined"!=typeof self?self:this,n=function(){function t(){this.fetch=!1,this.DOMException=r.DOMException}return t.prototype=r,new t}();!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function l(t){this.map={},t instanceof l?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function b(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=b(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=b(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=f(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,r=p(e=new FileReader),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,e){t=c(t),e=h(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},l.prototype.delete=function(t){delete this.map[c(t)]},l.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},l.prototype.set=function(t,e){this.map[c(t)]=h(e)},l.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},l.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},n&&(l.prototype[Symbol.iterator]=l.prototype.entries);var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(t,e){var r,n,o=(e=e||{}).body;if(t instanceof g){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new l(e.headers)),this.method=(n=(r=e.method||this.method||"GET").toUpperCase(),m.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function _(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new l(e.headers),this.url=e.url||"",this._initBody(t)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},v.call(g.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var O=[301,302,303,307,308];w.redirect=function(t,e){if(-1===O.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function j(t,r){return new Promise((function(n,i){var s=new g(t,r);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new w(o,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&o&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}j.polyfill=!0,t.fetch||(t.fetch=j,t.Headers=l,t.Request=g,t.Response=w),e.Headers=l,e.Request=g,e.Response=w,e.fetch=j,Object.defineProperty(e,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var o=n;(e=o.fetch).default=o.fetch,e.fetch=o.fetch,e.Headers=o.Headers,e.Request=o.Request,e.Response=o.Response,t.exports=e},215:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SupabaseStorageClient=void 0;const n=r(965);class o extends n.StorageBucketApi{constructor(t,e={},r){super(t,e,r)}from(t){return new n.StorageFileApi(this.url,this.headers,t,this.fetch)}}e.SupabaseStorageClient=o},341:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.SupabaseStorageClient=void 0;const i=r(215);Object.defineProperty(e,"SupabaseStorageClient",{enumerable:!0,get:function(){return i.SupabaseStorageClient}}),o(r(717),e)},150:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageBucketApi=void 0;const o=r(716),i=r(678);e.StorageBucketApi=class{constructor(t,e={},r){this.url=t,this.headers=Object.assign(Object.assign({},i.DEFAULT_HEADERS),e),this.fetch=r}listBuckets(){return n(this,void 0,void 0,(function*(){try{return{data:yield o.get(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}getBucket(t){return n(this,void 0,void 0,(function*(){try{return{data:yield o.get(this.fetch,`${this.url}/bucket/${t}`,{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}createBucket(t,e={public:!1}){return n(this,void 0,void 0,(function*(){try{return{data:(yield o.post(this.fetch,`${this.url}/bucket`,{id:t,name:t,public:e.public},{headers:this.headers})).name,error:null}}catch(t){return{data:null,error:t}}}))}updateBucket(t,e){return n(this,void 0,void 0,(function*(){try{return{data:yield o.put(this.fetch,`${this.url}/bucket/${t}`,{id:t,name:t,public:e.public},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}emptyBucket(t){return n(this,void 0,void 0,(function*(){try{return{data:yield o.post(this.fetch,`${this.url}/bucket/${t}/empty`,{},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}deleteBucket(t){return n(this,void 0,void 0,(function*(){try{return{data:yield o.remove(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}}},948:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageFileApi=void 0;const i=r(716),s=o(r(98)),a={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},u={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};e.StorageFileApi=class{constructor(t,e={},r,n){this.url=t,this.headers=e,this.bucketId=r,this.fetch=n}uploadOrUpdate(t,e,r,o){var i;return n(this,void 0,void 0,(function*(){try{let n;const a=Object.assign(Object.assign({},u),o),c=Object.assign(Object.assign({},this.headers),"POST"===t&&{"x-upsert":String(a.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?(n=new FormData,n.append("cacheControl",a.cacheControl),n.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(n=r,n.append("cacheControl",a.cacheControl)):(n=r,c["cache-control"]=`max-age=${a.cacheControl}`,c["content-type"]=a.contentType);const h=this._removeEmptyFolders(e),d=this._getFinalPath(h),l=null!==(i=this.fetch)&&void 0!==i?i:s.default,f=yield l(`${this.url}/object/${d}`,{method:t,body:n,headers:c});return f.ok?{data:{Key:d},error:null}:{data:null,error:yield f.json()}}catch(t){return{data:null,error:t}}}))}upload(t,e,r){return n(this,void 0,void 0,(function*(){return this.uploadOrUpdate("POST",t,e,r)}))}update(t,e,r){return n(this,void 0,void 0,(function*(){return this.uploadOrUpdate("PUT",t,e,r)}))}move(t,e){return n(this,void 0,void 0,(function*(){try{return{data:yield i.post(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:t,destinationKey:e},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}copy(t,e){return n(this,void 0,void 0,(function*(){try{return{data:yield i.post(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:t,destinationKey:e},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}createSignedUrl(t,e){return n(this,void 0,void 0,(function*(){try{const r=this._getFinalPath(t);let n=yield i.post(this.fetch,`${this.url}/object/sign/${r}`,{expiresIn:e},{headers:this.headers});const o=`${this.url}${n.signedURL}`;return n={signedURL:o},{data:n,error:null,signedURL:o}}catch(t){return{data:null,error:t,signedURL:null}}}))}createSignedUrls(t,e){return n(this,void 0,void 0,(function*(){try{return{data:(yield i.post(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:e,paths:t},{headers:this.headers})).map((t=>Object.assign(Object.assign({},t),{signedURL:t.signedURL?`${this.url}${t.signedURL}`:null}))),error:null}}catch(t){return{data:null,error:t}}}))}download(t){return n(this,void 0,void 0,(function*(){try{const e=this._getFinalPath(t),r=yield i.get(this.fetch,`${this.url}/object/${e}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(t){return{data:null,error:t}}}))}getPublicUrl(t){try{const e=this._getFinalPath(t),r=`${this.url}/object/public/${e}`;return{data:{publicURL:r},error:null,publicURL:r}}catch(t){return{data:null,error:t,publicURL:null}}}remove(t){return n(this,void 0,void 0,(function*(){try{return{data:yield i.remove(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:t},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}list(t,e,r){return n(this,void 0,void 0,(function*(){try{const n=Object.assign(Object.assign(Object.assign({},a),e),{prefix:t||""});return{data:yield i.post(this.fetch,`${this.url}/object/list/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(t){return{data:null,error:t}}}))}_getFinalPath(t){return`${this.bucketId}/${t}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}}},678:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_HEADERS=void 0;const n=r(506);e.DEFAULT_HEADERS={"X-Client-Info":`storage-js/${n.version}`}},716:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.remove=e.put=e.post=e.get=void 0;const i=o(r(98)),s=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t);function a(t=i.default,e,r,o,a,u){return n(this,void 0,void 0,(function*(){return new Promise(((n,i)=>{t(r,((t,e,r,n)=>{const o={method:t,headers:(null==e?void 0:e.headers)||{}};return"GET"===t?o:(o.headers=Object.assign({"Content-Type":"application/json"},null==e?void 0:e.headers),o.body=JSON.stringify(n),Object.assign(Object.assign({},o),r))})(e,o,a,u)).then((t=>{if(!t.ok)throw t;return(null==o?void 0:o.noResolveJson)?n(t):t.json()})).then((t=>n(t))).catch((t=>((t,e)=>{if("function"!=typeof t.json)return e(t);t.json().then((r=>e({message:s(r),status:(null==t?void 0:t.status)||500})))})(t,i)))}))}))}e.get=function(t,e,r,o){return n(this,void 0,void 0,(function*(){return a(t,"GET",e,r,o)}))},e.post=function(t,e,r,o,i){return n(this,void 0,void 0,(function*(){return a(t,"POST",e,o,i,r)}))},e.put=function(t,e,r,o,i){return n(this,void 0,void 0,(function*(){return a(t,"PUT",e,o,i,r)}))},e.remove=function(t,e,r,o,i){return n(this,void 0,void 0,(function*(){return a(t,"DELETE",e,o,i,r)}))}},965:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(150),e),o(r(948),e),o(r(717),e),o(r(678),e)},717:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},506:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="0.0.0"}},e={},function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(341);var t,e})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.supabase=e():t.supabase=e()}(self,(function(){return t={98:function(t,e){var r="undefined"!=typeof self?self:this,n=function(){function t(){this.fetch=!1,this.DOMException=r.DOMException}return t.prototype=r,new t}();!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function l(t){this.map={},t instanceof l?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function b(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=b(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=b(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=f(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,r=p(e=new FileReader),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(t,e){t=c(t),e=h(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},l.prototype.delete=function(t){delete this.map[c(t)]},l.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},l.prototype.set=function(t,e){this.map[c(t)]=h(e)},l.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},l.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},n&&(l.prototype[Symbol.iterator]=l.prototype.entries);var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(t,e){var r,n,o=(e=e||{}).body;if(t instanceof g){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new l(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new l(e.headers)),this.method=(n=(r=e.method||this.method||"GET").toUpperCase(),m.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function _(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new l(e.headers),this.url=e.url||"",this._initBody(t)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},v.call(g.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var O=[301,302,303,307,308];w.redirect=function(t,e){if(-1===O.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function j(t,r){return new Promise((function(n,i){var s=new g(t,r);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new l,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new w(o,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&o&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}j.polyfill=!0,t.fetch||(t.fetch=j,t.Headers=l,t.Request=g,t.Response=w),e.Headers=l,e.Request=g,e.Response=w,e.fetch=j,Object.defineProperty(e,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var o=n;(e=o.fetch).default=o.fetch,e.fetch=o.fetch,e.Headers=o.Headers,e.Request=o.Request,e.Response=o.Response,t.exports=e},215:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SupabaseStorageClient=void 0;const n=r(965);class o extends n.StorageBucketApi{constructor(t,e={},r){super(t,e,r)}from(t){return new n.StorageFileApi(this.url,this.headers,t,this.fetch)}}e.SupabaseStorageClient=o},341:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.SupabaseStorageClient=void 0;const i=r(215);Object.defineProperty(e,"SupabaseStorageClient",{enumerable:!0,get:function(){return i.SupabaseStorageClient}}),o(r(717),e)},150:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageBucketApi=void 0;const o=r(678),i=r(716),s=r(610);e.StorageBucketApi=class{constructor(t,e={},r){this.url=t,this.headers=Object.assign(Object.assign({},o.DEFAULT_HEADERS),e),this.fetch=s.resolveFetch(r)}listBuckets(){return n(this,void 0,void 0,(function*(){try{return{data:yield i.get(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}getBucket(t){return n(this,void 0,void 0,(function*(){try{return{data:yield i.get(this.fetch,`${this.url}/bucket/${t}`,{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}createBucket(t,e={public:!1}){return n(this,void 0,void 0,(function*(){try{return{data:(yield i.post(this.fetch,`${this.url}/bucket`,{id:t,name:t,public:e.public},{headers:this.headers})).name,error:null}}catch(t){return{data:null,error:t}}}))}updateBucket(t,e){return n(this,void 0,void 0,(function*(){try{return{data:yield i.put(this.fetch,`${this.url}/bucket/${t}`,{id:t,name:t,public:e.public},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}emptyBucket(t){return n(this,void 0,void 0,(function*(){try{return{data:yield i.post(this.fetch,`${this.url}/bucket/${t}/empty`,{},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}deleteBucket(t){return n(this,void 0,void 0,(function*(){try{return{data:yield i.remove(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}}},948:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageFileApi=void 0;const o=r(716),i=r(610),s={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},a={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};e.StorageFileApi=class{constructor(t,e={},r,n){this.url=t,this.headers=e,this.bucketId=r,this.fetch=i.resolveFetch(n)}uploadOrUpdate(t,e,r,o){return n(this,void 0,void 0,(function*(){try{let n;const i=Object.assign(Object.assign({},a),o),s=Object.assign(Object.assign({},this.headers),"POST"===t&&{"x-upsert":String(i.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?(n=new FormData,n.append("cacheControl",i.cacheControl),n.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(n=r,n.append("cacheControl",i.cacheControl)):(n=r,s["cache-control"]=`max-age=${i.cacheControl}`,s["content-type"]=i.contentType);const u=this._removeEmptyFolders(e),c=this._getFinalPath(u),h=yield this.fetch(`${this.url}/object/${c}`,{method:t,body:n,headers:s});return h.ok?{data:{Key:c},error:null}:{data:null,error:yield h.json()}}catch(t){return{data:null,error:t}}}))}upload(t,e,r){return n(this,void 0,void 0,(function*(){return this.uploadOrUpdate("POST",t,e,r)}))}update(t,e,r){return n(this,void 0,void 0,(function*(){return this.uploadOrUpdate("PUT",t,e,r)}))}move(t,e){return n(this,void 0,void 0,(function*(){try{return{data:yield o.post(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:t,destinationKey:e},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}copy(t,e){return n(this,void 0,void 0,(function*(){try{return{data:yield o.post(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:t,destinationKey:e},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}createSignedUrl(t,e){return n(this,void 0,void 0,(function*(){try{const r=this._getFinalPath(t);let n=yield o.post(this.fetch,`${this.url}/object/sign/${r}`,{expiresIn:e},{headers:this.headers});const i=`${this.url}${n.signedURL}`;return n={signedURL:i},{data:n,error:null,signedURL:i}}catch(t){return{data:null,error:t,signedURL:null}}}))}createSignedUrls(t,e){return n(this,void 0,void 0,(function*(){try{return{data:(yield o.post(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:e,paths:t},{headers:this.headers})).map((t=>Object.assign(Object.assign({},t),{signedURL:t.signedURL?`${this.url}${t.signedURL}`:null}))),error:null}}catch(t){return{data:null,error:t}}}))}download(t){return n(this,void 0,void 0,(function*(){try{const e=this._getFinalPath(t),r=yield o.get(this.fetch,`${this.url}/object/${e}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(t){return{data:null,error:t}}}))}getPublicUrl(t){try{const e=this._getFinalPath(t),r=`${this.url}/object/public/${e}`;return{data:{publicURL:r},error:null,publicURL:r}}catch(t){return{data:null,error:t,publicURL:null}}}remove(t){return n(this,void 0,void 0,(function*(){try{return{data:yield o.remove(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:t},{headers:this.headers}),error:null}}catch(t){return{data:null,error:t}}}))}list(t,e,r){return n(this,void 0,void 0,(function*(){try{const n=Object.assign(Object.assign(Object.assign({},s),e),{prefix:t||""});return{data:yield o.post(this.fetch,`${this.url}/object/list/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(t){return{data:null,error:t}}}))}_getFinalPath(t){return`${this.bucketId}/${t}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}}},678:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_HEADERS=void 0;const n=r(506);e.DEFAULT_HEADERS={"X-Client-Info":`storage-js/${n.version}`}},716:function(t,e){"use strict";var r=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.remove=e.put=e.post=e.get=void 0;const n=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t);function o(t,e,o,i,s,a){return r(this,void 0,void 0,(function*(){return new Promise(((r,u)=>{t(o,((t,e,r,n)=>{const o={method:t,headers:(null==e?void 0:e.headers)||{}};return"GET"===t?o:(o.headers=Object.assign({"Content-Type":"application/json"},null==e?void 0:e.headers),o.body=JSON.stringify(n),Object.assign(Object.assign({},o),r))})(e,i,s,a)).then((t=>{if(!t.ok)throw t;return(null==i?void 0:i.noResolveJson)?r(t):t.json()})).then((t=>r(t))).catch((t=>((t,e)=>{if("function"!=typeof t.json)return e(t);t.json().then((r=>e({message:n(r),status:(null==t?void 0:t.status)||500})))})(t,u)))}))}))}e.get=function(t,e,n,i){return r(this,void 0,void 0,(function*(){return o(t,"GET",e,n,i)}))},e.post=function(t,e,n,i,s){return r(this,void 0,void 0,(function*(){return o(t,"POST",e,i,s,n)}))},e.put=function(t,e,n,i,s){return r(this,void 0,void 0,(function*(){return o(t,"PUT",e,i,s,n)}))},e.remove=function(t,e,n,i,s){return r(this,void 0,void 0,(function*(){return o(t,"DELETE",e,i,s,n)}))}},610:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.resolveFetch=void 0;const o=n(r(98));e.resolveFetch=t=>t||("undefined"==typeof fetch?o.default:fetch)},965:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(150),e),o(r(948),e),o(r(717),e),o(r(678),e)},717:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},506:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="0.0.0"}},e={},function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(341);var t,e})); |
{ | ||
"name": "@supabase/storage-js", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "Isomorphic storage client for Supabase.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,3 +0,1 @@ | ||
import crossFetch from 'cross-fetch' | ||
export type Fetch = typeof fetch | ||
@@ -51,3 +49,3 @@ | ||
async function _handleRequest( | ||
fetcher: Fetch = crossFetch, | ||
fetcher: Fetch, | ||
method: RequestMethodType, | ||
@@ -72,3 +70,3 @@ url: string, | ||
export async function get( | ||
fetcher: Fetch | undefined, | ||
fetcher: Fetch, | ||
url: string, | ||
@@ -82,3 +80,3 @@ options?: FetchOptions, | ||
export async function post( | ||
fetcher: Fetch | undefined, | ||
fetcher: Fetch, | ||
url: string, | ||
@@ -93,3 +91,3 @@ body: object, | ||
export async function put( | ||
fetcher: Fetch | undefined, | ||
fetcher: Fetch, | ||
url: string, | ||
@@ -104,3 +102,3 @@ body: object, | ||
export async function remove( | ||
fetcher: Fetch | undefined, | ||
fetcher: Fetch, | ||
url: string, | ||
@@ -107,0 +105,0 @@ body: object, |
@@ -1,1 +0,13 @@ | ||
export const isBrowser = () => typeof window !== 'undefined' | ||
import crossFetch from 'cross-fetch' | ||
type Fetch = typeof fetch | ||
export const resolveFetch = (customFetch?: Fetch): Fetch => { | ||
if (customFetch) { | ||
return customFetch | ||
} else if (typeof fetch === 'undefined') { | ||
return (crossFetch as unknown) as Fetch | ||
} else { | ||
return fetch | ||
} | ||
} |
@@ -0,4 +1,5 @@ | ||
import { DEFAULT_HEADERS } from './constants' | ||
import { Fetch, get, post, put, remove } from './fetch' | ||
import { resolveFetch } from './helpers' | ||
import { Bucket } from './types' | ||
import { DEFAULT_HEADERS } from './constants' | ||
@@ -8,3 +9,3 @@ export class StorageBucketApi { | ||
protected headers: { [key: string]: string } | ||
protected fetch?: Fetch | ||
protected fetch: Fetch | ||
@@ -14,3 +15,3 @@ constructor(url: string, headers: { [key: string]: string } = {}, fetch?: Fetch) { | ||
this.headers = { ...DEFAULT_HEADERS, ...headers } | ||
this.fetch = fetch | ||
this.fetch = resolveFetch(fetch) | ||
} | ||
@@ -17,0 +18,0 @@ |
import { Fetch, FetchParameters, get, post, remove } from './fetch' | ||
import { isBrowser } from './helpers' | ||
import { resolveFetch } from './helpers' | ||
import { FileObject, FileOptions, SearchOptions } from './types' | ||
import fetch from 'cross-fetch' | ||
@@ -25,3 +24,3 @@ const DEFAULT_SEARCH_OPTIONS = { | ||
protected bucketId?: string | ||
protected fetch?: Fetch | ||
protected fetch: Fetch | ||
@@ -37,3 +36,3 @@ constructor( | ||
this.bucketId = bucketId | ||
this.fetch = fetch | ||
this.fetch = resolveFetch(fetch) | ||
} | ||
@@ -91,4 +90,3 @@ | ||
const _path = this._getFinalPath(cleanPath) | ||
const fetcher = this.fetch ?? fetch | ||
const res = await fetcher(`${this.url}/object/${_path}`, { | ||
const res = await this.fetch(`${this.url}/object/${_path}`, { | ||
method, | ||
@@ -95,0 +93,0 @@ body: body as BodyInit, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
166455
2380
12