@supabase/storage-js
Advanced tools
Comparing version 1.6.1 to 1.6.2
@@ -103,3 +103,4 @@ /// <reference types="node" /> | ||
data: { | ||
path: string; | ||
error: string | null; | ||
path: string | null; | ||
signedURL: string; | ||
@@ -106,0 +107,0 @@ }[] | null; |
@@ -187,3 +187,6 @@ "use strict"; | ||
const data = yield fetch_1.post(this.fetch, `${this.url}/object/sign/${this.bucketId}`, { expiresIn, paths }, { headers: this.headers }); | ||
return { data, error: null }; | ||
return { | ||
data: data.map((datum) => (Object.assign(Object.assign({}, datum), { signedURL: datum.signedURL ? `${this.url}${datum.signedURL}` : null }))), | ||
error: null, | ||
}; | ||
} | ||
@@ -190,0 +193,0 @@ catch (error) { |
@@ -103,3 +103,4 @@ /// <reference types="node" /> | ||
data: { | ||
path: string; | ||
error: string | null; | ||
path: string | null; | ||
signedURL: string; | ||
@@ -106,0 +107,0 @@ }[] | null; |
@@ -181,3 +181,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const data = yield post(this.fetch, `${this.url}/object/sign/${this.bucketId}`, { expiresIn, paths }, { headers: this.headers }); | ||
return { data, error: null }; | ||
return { | ||
data: data.map((datum) => (Object.assign(Object.assign({}, datum), { signedURL: datum.signedURL ? `${this.url}${datum.signedURL}` : null }))), | ||
error: null, | ||
}; | ||
} | ||
@@ -184,0 +187,0 @@ catch (error) { |
@@ -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}),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(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})); |
{ | ||
"name": "@supabase/storage-js", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "Isomorphic storage client for Supabase.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -251,3 +251,3 @@ import { Fetch, FetchParameters, get, post, remove } from './fetch' | ||
): Promise<{ | ||
data: { path: string; signedURL: string }[] | null | ||
data: { error: string | null; path: string | null; signedURL: string }[] | null | ||
error: Error | null | ||
@@ -262,3 +262,9 @@ }> { | ||
) | ||
return { data, error: null } | ||
return { | ||
data: data.map((datum: { signedURL: string }) => ({ | ||
...datum, | ||
signedURL: datum.signedURL ? `${this.url}${datum.signedURL}` : null, | ||
})), | ||
error: null, | ||
} | ||
} catch (error) { | ||
@@ -265,0 +271,0 @@ return { data: null, error } |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165816
2353