@supabase/storage-js 1.7.2 → 1.8.0-next.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.
- package/README.md +11 -1
- package/dist/main/index.d.ts +1 -0
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +6 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/StorageBucketApi.d.ts +31 -12
- package/dist/main/lib/StorageBucketApi.d.ts.map +1 -1
- package/dist/main/lib/StorageBucketApi.js +32 -13
- package/dist/main/lib/StorageBucketApi.js.map +1 -1
- package/dist/main/lib/StorageFileApi.d.ts +53 -30
- package/dist/main/lib/StorageFileApi.d.ts.map +1 -1
- package/dist/main/lib/StorageFileApi.js +88 -38
- package/dist/main/lib/StorageFileApi.js.map +1 -1
- package/dist/main/lib/errors.d.ts +19 -0
- package/dist/main/lib/errors.d.ts.map +1 -0
- package/dist/main/lib/errors.js +39 -0
- package/dist/main/lib/errors.js.map +1 -0
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +13 -11
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +6 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +15 -3
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/index.js +5 -1
- package/dist/main/lib/index.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/index.d.ts +1 -0
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/StorageBucketApi.d.ts +31 -12
- package/dist/module/lib/StorageBucketApi.d.ts.map +1 -1
- package/dist/module/lib/StorageBucketApi.js +25 -6
- package/dist/module/lib/StorageBucketApi.js.map +1 -1
- package/dist/module/lib/StorageFileApi.d.ts +53 -30
- package/dist/module/lib/StorageFileApi.d.ts.map +1 -1
- package/dist/module/lib/StorageFileApi.js +80 -30
- package/dist/module/lib/StorageFileApi.js.map +1 -1
- package/dist/module/lib/errors.d.ts +19 -0
- package/dist/module/lib/errors.d.ts.map +1 -0
- package/dist/module/lib/errors.js +32 -0
- package/dist/module/lib/errors.js.map +1 -0
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js +13 -11
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +6 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +6 -0
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +3 -8
- package/src/index.ts +1 -0
- package/src/lib/StorageBucketApi.ts +93 -12
- package/src/lib/StorageFileApi.ts +197 -53
- package/src/lib/errors.ts +40 -0
- package/src/lib/fetch.ts +13 -10
- package/src/lib/helpers.ts +8 -0
- package/src/lib/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAiB3C,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAAU,EAAE,CAC5C,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;AAErF,MAAM,WAAW,GAAG,CAAO,KAAc,EAAE,MAA8B,EAAE,EAAE;IAC3E,MAAM,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E,CAAC;CAAA"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
declare type Fetch = typeof fetch;
|
|
2
2
|
export declare const resolveFetch: (customFetch?: typeof fetch | undefined) => Fetch;
|
|
3
|
+
export declare const resolveResponse: () => Promise<{
|
|
4
|
+
new (body?: BodyInit | null | undefined, init?: ResponseInit | undefined): Response;
|
|
5
|
+
prototype: Response;
|
|
6
|
+
error(): Response;
|
|
7
|
+
redirect(url: string | URL, status?: number | undefined): Response;
|
|
8
|
+
}>;
|
|
3
9
|
export {};
|
|
4
10
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK,GAAG,OAAO,KAAK,CAAA;AAEzB,eAAO,MAAM,YAAY,8CAA0B,KAUlD,CAAA"}
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK,GAAG,OAAO,KAAK,CAAA;AAEzB,eAAO,MAAM,YAAY,8CAA0B,KAUlD,CAAA;AAED,eAAO,MAAM,eAAe;;;;;EAM3B,CAAA"}
|
|
@@ -20,4 +20,10 @@ export const resolveFetch = (customFetch) => {
|
|
|
20
20
|
}
|
|
21
21
|
return (...args) => _fetch(...args);
|
|
22
22
|
};
|
|
23
|
+
export const resolveResponse = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
if (typeof Response === 'undefined') {
|
|
25
|
+
return (yield import('cross-fetch')).Response;
|
|
26
|
+
}
|
|
27
|
+
return Response;
|
|
28
|
+
});
|
|
23
29
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":";;;;;;;;;AAEA,MAAM,CAAC,MAAM,YAAY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ED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "1.8.0-next.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/umd/supabase.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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},274:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StorageClient=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.StorageClient=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=e.StorageClient=void 0;var i=r(274);Object.defineProperty(e,"StorageClient",{enumerable:!0,get:function(){return i.StorageClient}}),Object.defineProperty(e,"SupabaseStorageClient",{enumerable:!0,get:function(){return i.StorageClient}}),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.__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.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e},s=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.resolveFetch=void 0,e.resolveFetch=t=>{let e;return e=t||("undefined"==typeof fetch?(...t)=>s(void 0,void 0,void 0,(function*(){return yield(yield Promise.resolve().then((()=>i(r(98))))).fetch(...t)})):fetch),(...t)=>e(...t)}},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}));
|
|
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,o=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,o="Symbol"in t&&"iterator"in Symbol,n="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 o&&(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:n&&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&&n&&(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"))},n&&(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,o=f(this);if(o)return o;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),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);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(w)}),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)},o&&(l.prototype[Symbol.iterator]=l.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function m(t,e){var r,o,n=(e=e||{}).body;if(t instanceof m){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,n||null==t._bodyInit||(n=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=(o=(r=e.method||this.method||"GET").toUpperCase(),g.indexOf(o)>-1?o:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function w(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function _(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)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},v.call(m.prototype),v.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},_.error=function(){var t=new _(null,{status:0,statusText:""});return t.type="error",t};var E=[301,302,303,307,308];_.redirect=function(t,e){if(-1===E.indexOf(e))throw new RangeError("Invalid status code");return new _(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 O(t,r){return new Promise((function(o,i){var s=new m(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(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();e.append(o,n)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;o(new _(n,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&&n&&(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)}))}O.polyfill=!0,t.fetch||(t.fetch=O,t.Headers=l,t.Request=m,t.Response=_),e.Headers=l,e.Request=m,e.Response=_,e.fetch=O,Object.defineProperty(e,"__esModule",{value:!0})}({})}(o),o.fetch.ponyfill=!0,delete o.fetch.polyfill;var n=o;(e=n.fetch).default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,t.exports=e},274:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StorageClient=void 0;const o=r(965);class n extends o.StorageBucketApi{constructor(t,e={},r){super(t,e,r)}from(t){return new o.StorageFileApi(this.url,this.headers,t,this.fetch)}}e.StorageClient=n},341:function(t,e,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,o,n)}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),n=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||o(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.SupabaseStorageClient=e.StorageClient=void 0;var i=r(274);Object.defineProperty(e,"StorageClient",{enumerable:!0,get:function(){return i.StorageClient}}),Object.defineProperty(e,"SupabaseStorageClient",{enumerable:!0,get:function(){return i.StorageClient}}),n(r(717),e),n(r(752),e)},150:function(t,e,r){"use strict";var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageBucketApi=void 0;const n=r(678),i=r(752),s=r(716),a=r(610);e.StorageBucketApi=class{constructor(t,e={},r){this.url=t,this.headers=Object.assign(Object.assign({},n.DEFAULT_HEADERS),e),this.fetch=(0,a.resolveFetch)(r)}listBuckets(){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,s.get)(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(t){if((0,i.isStorageError)(t))return{data:null,error:t};throw t}}))}getBucket(t){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,s.get)(this.fetch,`${this.url}/bucket/${t}`,{headers:this.headers}),error:null}}catch(t){if((0,i.isStorageError)(t))return{data:null,error:t};throw t}}))}createBucket(t,e={public:!1}){return o(this,void 0,void 0,(function*(){try{return{data:(yield(0,s.post)(this.fetch,`${this.url}/bucket`,{id:t,name:t,public:e.public},{headers:this.headers})).name,error:null}}catch(t){if((0,i.isStorageError)(t))return{data:null,error:t};throw t}}))}updateBucket(t,e){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,s.put)(this.fetch,`${this.url}/bucket/${t}`,{id:t,name:t,public:e.public},{headers:this.headers}),error:null}}catch(t){if((0,i.isStorageError)(t))return{data:null,error:t};throw t}}))}emptyBucket(t){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,s.post)(this.fetch,`${this.url}/bucket/${t}/empty`,{},{headers:this.headers}),error:null}}catch(t){if((0,i.isStorageError)(t))return{data:null,error:t};throw t}}))}deleteBucket(t){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,s.remove)(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(t){if((0,i.isStorageError)(t))return{data:null,error:t};throw t}}))}}},948:function(t,e,r){"use strict";var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageFileApi=void 0;const n=r(752),i=r(716),s=r(610),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,o){this.url=t,this.headers=e,this.bucketId=r,this.fetch=(0,s.resolveFetch)(o)}uploadOrUpdate(t,e,r,i){return o(this,void 0,void 0,(function*(){try{let o;const n=Object.assign(Object.assign({},u),i),s=Object.assign(Object.assign({},this.headers),"POST"===t&&{"x-upsert":String(n.upsert)});"undefined"!=typeof Blob&&r instanceof Blob?(o=new FormData,o.append("cacheControl",n.cacheControl),o.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?(o=r,o.append("cacheControl",n.cacheControl)):(o=r,s["cache-control"]=`max-age=${n.cacheControl}`,s["content-type"]=n.contentType);const a=this._removeEmptyFolders(e),c=this._getFinalPath(a),h=yield this.fetch(`${this.url}/object/${c}`,{method:t,body:o,headers:s});return h.ok?{data:{path:a},error:null}:{data:null,error:yield h.json()}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t};throw t}}))}upload(t,e,r){return o(this,void 0,void 0,(function*(){return this.uploadOrUpdate("POST",t,e,r)}))}update(t,e,r){return o(this,void 0,void 0,(function*(){return this.uploadOrUpdate("PUT",t,e,r)}))}move(t,e){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,i.post)(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:t,destinationKey:e},{headers:this.headers}),error:null}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t};throw t}}))}copy(t,e){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,i.post)(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:t,destinationKey:e},{headers:this.headers}),error:null}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t};throw t}}))}createSignedUrl(t,e){return o(this,void 0,void 0,(function*(){try{const r=this._getFinalPath(t);let o=yield(0,i.post)(this.fetch,`${this.url}/object/sign/${r}`,{expiresIn:e},{headers:this.headers});const n=encodeURI(`${this.url}${o.signedURL}`);return o={signedURL:n},{data:o,error:null,signedURL:n}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t,signedURL:null};throw t}}))}createSignedUrls(t,e){return o(this,void 0,void 0,(function*(){try{return{data:(yield(0,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?encodeURI(`${this.url}${t.signedURL}`):null}))),error:null}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t};throw t}}))}download(t){return o(this,void 0,void 0,(function*(){try{const e=this._getFinalPath(t),r=yield(0,i.get)(this.fetch,`${this.url}/object/${e}`,{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t};throw t}}))}getPublicUrl(t){const e=this._getFinalPath(t);return encodeURI(`${this.url}/object/public/${e}`)}remove(t){return o(this,void 0,void 0,(function*(){try{return{data:yield(0,i.remove)(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:t},{headers:this.headers}),error:null}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t};throw t}}))}list(t,e,r){return o(this,void 0,void 0,(function*(){try{const o=Object.assign(Object.assign(Object.assign({},a),e),{prefix:t||""});return{data:yield(0,i.post)(this.fetch,`${this.url}/object/list/${this.bucketId}`,o,{headers:this.headers},r),error:null}}catch(t){if((0,n.isStorageError)(t))return{data:null,error:t};throw 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 o=r(506);e.DEFAULT_HEADERS={"X-Client-Info":`storage-js/${o.version}`}},752:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StorageUnknownError=e.StorageApiError=e.isStorageError=e.StorageError=void 0;class r extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}}e.StorageError=r,e.isStorageError=function(t){return"object"==typeof t&&null!==t&&"__isStorageError"in t},e.StorageApiError=class extends r{constructor(t,e){super(t),this.name="StorageApiError",this.status=e}toJSON(){return{name:this.name,message:this.message,status:this.status}}},e.StorageUnknownError=class extends r{constructor(t,e){super(t),this.name="StorageUnknownError",this.originalError=e}}},716:function(t,e,r){"use strict";var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.remove=e.put=e.post=e.get=void 0;const n=r(752),i=r(610),s=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t);function a(t,e,r,a,u,c){return o(this,void 0,void 0,(function*(){return new Promise(((h,d)=>{t(r,((t,e,r,o)=>{const n={method:t,headers:(null==e?void 0:e.headers)||{}};return"GET"===t?n:(n.headers=Object.assign({"Content-Type":"application/json"},null==e?void 0:e.headers),n.body=JSON.stringify(o),Object.assign(Object.assign({},n),r))})(e,a,u,c)).then((t=>{if(!t.ok)throw t;return(null==a?void 0:a.noResolveJson)?t:t.json()})).then((t=>h(t))).catch((t=>((t,e)=>o(void 0,void 0,void 0,(function*(){const r=yield(0,i.resolveResponse)();t instanceof r?t.json().then((r=>{e(new n.StorageApiError(s(r),t.status||500))})):e(new n.StorageUnknownError(s(t),t))})))(t,d)))}))}))}e.get=function(t,e,r,n){return o(this,void 0,void 0,(function*(){return a(t,"GET",e,r,n)}))},e.post=function(t,e,r,n,i){return o(this,void 0,void 0,(function*(){return a(t,"POST",e,n,i,r)}))},e.put=function(t,e,r,n,i){return o(this,void 0,void 0,(function*(){return a(t,"PUT",e,n,i,r)}))},e.remove=function(t,e,r,n,i){return o(this,void 0,void 0,(function*(){return a(t,"DELETE",e,n,i,r)}))}},610:function(t,e,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,o,n)}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),n=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&o(e,t,r);return n(e,t),e},s=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.resolveResponse=e.resolveFetch=void 0,e.resolveFetch=t=>{let e;return e=t||("undefined"==typeof fetch?(...t)=>s(void 0,void 0,void 0,(function*(){return yield(yield Promise.resolve().then((()=>i(r(98))))).fetch(...t)})):fetch),(...t)=>e(...t)},e.resolveResponse=()=>s(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then((()=>i(r(98))))).Response:Response}))},965:function(t,e,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,o,n)}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),n=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||o(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(r(150),e),n(r(948),e),n(r(717),e),n(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(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={exports:{}};return t[o].call(i.exports,i,i.exports,r),i.exports}(341);var t,e}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/storage-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-next.2",
|
|
4
4
|
"description": "Isomorphic storage client for Supabase.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"docs:json": "typedoc --json docs/spec.json --mode modules --includeDeclarations --excludeExternals"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"cross-fetch": "^3.1.
|
|
39
|
+
"cross-fetch": "^3.1.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/jest": "^26.0.13",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"ts-jest": "^26.3.0",
|
|
52
52
|
"ts-loader": "^8.0.11",
|
|
53
53
|
"typedoc": "^0.19.1",
|
|
54
|
-
"typescript": "^4.
|
|
54
|
+
"typescript": "^4.6.3",
|
|
55
55
|
"webpack": "^5.4.0",
|
|
56
56
|
"webpack-cli": "^4.2.0"
|
|
57
57
|
},
|
|
@@ -62,11 +62,6 @@
|
|
|
62
62
|
},
|
|
63
63
|
"jsdelivr": "dist/umd/supabase.js",
|
|
64
64
|
"unpkg": "dist/umd/supabase.js",
|
|
65
|
-
"release": {
|
|
66
|
-
"branches": [
|
|
67
|
-
"main"
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
65
|
"publishConfig": {
|
|
71
66
|
"access": "public"
|
|
72
67
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_HEADERS } from './constants'
|
|
2
|
+
import { isStorageError, StorageError } from './errors'
|
|
2
3
|
import { Fetch, get, post, put, remove } from './fetch'
|
|
3
4
|
import { resolveFetch } from './helpers'
|
|
4
5
|
import { Bucket } from './types'
|
|
@@ -17,12 +18,25 @@ export class StorageBucketApi {
|
|
|
17
18
|
/**
|
|
18
19
|
* Retrieves the details of all Storage buckets within an existing project.
|
|
19
20
|
*/
|
|
20
|
-
async listBuckets(): Promise<
|
|
21
|
+
async listBuckets(): Promise<
|
|
22
|
+
| {
|
|
23
|
+
data: Bucket[]
|
|
24
|
+
error: null
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
data: null
|
|
28
|
+
error: StorageError
|
|
29
|
+
}
|
|
30
|
+
> {
|
|
21
31
|
try {
|
|
22
32
|
const data = await get(this.fetch, `${this.url}/bucket`, { headers: this.headers })
|
|
23
33
|
return { data, error: null }
|
|
24
34
|
} catch (error) {
|
|
25
|
-
|
|
35
|
+
if (isStorageError(error)) {
|
|
36
|
+
return { data: null, error }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
throw error
|
|
26
40
|
}
|
|
27
41
|
}
|
|
28
42
|
|
|
@@ -31,12 +45,27 @@ export class StorageBucketApi {
|
|
|
31
45
|
*
|
|
32
46
|
* @param id The unique identifier of the bucket you would like to retrieve.
|
|
33
47
|
*/
|
|
34
|
-
async getBucket(
|
|
48
|
+
async getBucket(
|
|
49
|
+
id: string
|
|
50
|
+
): Promise<
|
|
51
|
+
| {
|
|
52
|
+
data: Bucket
|
|
53
|
+
error: null
|
|
54
|
+
}
|
|
55
|
+
| {
|
|
56
|
+
data: null
|
|
57
|
+
error: StorageError
|
|
58
|
+
}
|
|
59
|
+
> {
|
|
35
60
|
try {
|
|
36
61
|
const data = await get(this.fetch, `${this.url}/bucket/${id}`, { headers: this.headers })
|
|
37
62
|
return { data, error: null }
|
|
38
63
|
} catch (error) {
|
|
39
|
-
|
|
64
|
+
if (isStorageError(error)) {
|
|
65
|
+
return { data: null, error }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
throw error
|
|
40
69
|
}
|
|
41
70
|
}
|
|
42
71
|
|
|
@@ -49,7 +78,16 @@ export class StorageBucketApi {
|
|
|
49
78
|
async createBucket(
|
|
50
79
|
id: string,
|
|
51
80
|
options: { public: boolean } = { public: false }
|
|
52
|
-
): Promise<
|
|
81
|
+
): Promise<
|
|
82
|
+
| {
|
|
83
|
+
data: string
|
|
84
|
+
error: null
|
|
85
|
+
}
|
|
86
|
+
| {
|
|
87
|
+
data: null
|
|
88
|
+
error: StorageError
|
|
89
|
+
}
|
|
90
|
+
> {
|
|
53
91
|
try {
|
|
54
92
|
const data = await post(
|
|
55
93
|
this.fetch,
|
|
@@ -59,7 +97,11 @@ export class StorageBucketApi {
|
|
|
59
97
|
)
|
|
60
98
|
return { data: data.name, error: null }
|
|
61
99
|
} catch (error) {
|
|
62
|
-
|
|
100
|
+
if (isStorageError(error)) {
|
|
101
|
+
return { data: null, error }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
throw error
|
|
63
105
|
}
|
|
64
106
|
}
|
|
65
107
|
|
|
@@ -71,7 +113,16 @@ export class StorageBucketApi {
|
|
|
71
113
|
async updateBucket(
|
|
72
114
|
id: string,
|
|
73
115
|
options: { public: boolean }
|
|
74
|
-
): Promise<
|
|
116
|
+
): Promise<
|
|
117
|
+
| {
|
|
118
|
+
data: { message: string }
|
|
119
|
+
error: null
|
|
120
|
+
}
|
|
121
|
+
| {
|
|
122
|
+
data: null
|
|
123
|
+
error: StorageError
|
|
124
|
+
}
|
|
125
|
+
> {
|
|
75
126
|
try {
|
|
76
127
|
const data = await put(
|
|
77
128
|
this.fetch,
|
|
@@ -81,7 +132,11 @@ export class StorageBucketApi {
|
|
|
81
132
|
)
|
|
82
133
|
return { data, error: null }
|
|
83
134
|
} catch (error) {
|
|
84
|
-
|
|
135
|
+
if (isStorageError(error)) {
|
|
136
|
+
return { data: null, error }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
throw error
|
|
85
140
|
}
|
|
86
141
|
}
|
|
87
142
|
|
|
@@ -92,7 +147,16 @@ export class StorageBucketApi {
|
|
|
92
147
|
*/
|
|
93
148
|
async emptyBucket(
|
|
94
149
|
id: string
|
|
95
|
-
): Promise<
|
|
150
|
+
): Promise<
|
|
151
|
+
| {
|
|
152
|
+
data: { message: string }
|
|
153
|
+
error: null
|
|
154
|
+
}
|
|
155
|
+
| {
|
|
156
|
+
data: null
|
|
157
|
+
error: StorageError
|
|
158
|
+
}
|
|
159
|
+
> {
|
|
96
160
|
try {
|
|
97
161
|
const data = await post(
|
|
98
162
|
this.fetch,
|
|
@@ -102,7 +166,11 @@ export class StorageBucketApi {
|
|
|
102
166
|
)
|
|
103
167
|
return { data, error: null }
|
|
104
168
|
} catch (error) {
|
|
105
|
-
|
|
169
|
+
if (isStorageError(error)) {
|
|
170
|
+
return { data: null, error }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
throw error
|
|
106
174
|
}
|
|
107
175
|
}
|
|
108
176
|
|
|
@@ -114,7 +182,16 @@ export class StorageBucketApi {
|
|
|
114
182
|
*/
|
|
115
183
|
async deleteBucket(
|
|
116
184
|
id: string
|
|
117
|
-
): Promise<
|
|
185
|
+
): Promise<
|
|
186
|
+
| {
|
|
187
|
+
data: { message: string }
|
|
188
|
+
error: null
|
|
189
|
+
}
|
|
190
|
+
| {
|
|
191
|
+
data: null
|
|
192
|
+
error: StorageError
|
|
193
|
+
}
|
|
194
|
+
> {
|
|
118
195
|
try {
|
|
119
196
|
const data = await remove(
|
|
120
197
|
this.fetch,
|
|
@@ -124,7 +201,11 @@ export class StorageBucketApi {
|
|
|
124
201
|
)
|
|
125
202
|
return { data, error: null }
|
|
126
203
|
} catch (error) {
|
|
127
|
-
|
|
204
|
+
if (isStorageError(error)) {
|
|
205
|
+
return { data: null, error }
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
throw error
|
|
128
209
|
}
|
|
129
210
|
}
|
|
130
211
|
}
|