@nhost/nhost-js 0.3.8 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,2 @@
1
- "use strict";var Pt=Object.defineProperty,It=Object.defineProperties;var jt=Object.getOwnPropertyDescriptors;var cr=Object.getOwnPropertySymbols;var Ft=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable;var lr=(t,e,r)=>e in t?Pt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R=(t,e)=>{for(var r in e||(e={}))Ft.call(e,r)&&lr(t,r,e[r]);if(cr)for(var r of cr(e))Lt.call(e,r)&&lr(t,r,e[r]);return t},ee=(t,e)=>It(t,jt(e));Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var xe={exports:{}},fr=function(e,r){return function(){for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];return e.apply(r,s)}},Dt=fr,B=Object.prototype.toString;function Re(t){return Array.isArray(t)}function Ne(t){return typeof t=="undefined"}function Bt(t){return t!==null&&!Ne(t)&&t.constructor!==null&&!Ne(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function dr(t){return B.call(t)==="[object ArrayBuffer]"}function _t(t){return B.call(t)==="[object FormData]"}function qt(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&dr(t.buffer),e}function Ht(t){return typeof t=="string"}function Mt(t){return typeof t=="number"}function hr(t){return t!==null&&typeof t=="object"}function re(t){if(B.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Jt(t){return B.call(t)==="[object Date]"}function zt(t){return B.call(t)==="[object File]"}function Vt(t){return B.call(t)==="[object Blob]"}function pr(t){return B.call(t)==="[object Function]"}function Wt(t){return hr(t)&&pr(t.pipe)}function Xt(t){return B.call(t)==="[object URLSearchParams]"}function Kt(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Gt(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function ke(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Re(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}function Ue(){var t={};function e(s,a){re(t[a])&&re(s)?t[a]=Ue(t[a],s):re(s)?t[a]=Ue({},s):Re(s)?t[a]=s.slice():t[a]=s}for(var r=0,n=arguments.length;r<n;r++)ke(arguments[r],e);return t}function Qt(t,e,r){return ke(e,function(s,a){r&&typeof s=="function"?t[a]=Dt(s,r):t[a]=s}),t}function Yt(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var N={isArray:Re,isArrayBuffer:dr,isBuffer:Bt,isFormData:_t,isArrayBufferView:qt,isString:Ht,isNumber:Mt,isObject:hr,isPlainObject:re,isUndefined:Ne,isDate:Jt,isFile:zt,isBlob:Vt,isFunction:pr,isStream:Wt,isURLSearchParams:Xt,isStandardBrowserEnv:Gt,forEach:ke,merge:Ue,extend:Qt,trim:Kt,stripBOM:Yt},M=N;function mr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var vr=function(e,r,n){if(!r)return e;var s;if(n)s=n(r);else if(M.isURLSearchParams(r))s=r.toString();else{var a=[];M.forEach(r,function(c,g){c===null||typeof c=="undefined"||(M.isArray(c)?g=g+"[]":c=[c],M.forEach(c,function(h){M.isDate(h)?h=h.toISOString():M.isObject(h)&&(h=JSON.stringify(h)),a.push(mr(g)+"="+mr(h))}))}),s=a.join("&")}if(s){var i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e},Zt=N;function te(){this.handlers=[]}te.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};te.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};te.prototype.forEach=function(e){Zt.forEach(this.handlers,function(n){n!==null&&e(n)})};var en=te,rn=N,tn=function(e,r){rn.forEach(e,function(s,a){a!==r&&a.toUpperCase()===r.toUpperCase()&&(e[r]=s,delete e[a])})},yr=function(e,r,n,s,a){return e.config=r,n&&(e.code=n),e.request=s,e.response=a,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e},nn=yr,gr=function(e,r,n,s,a){var i=new Error(e);return nn(i,r,n,s,a)},sn=gr,an=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(sn("Request failed with status code "+n.status,n.config,null,n.request,n))},ne=N,on=ne.isStandardBrowserEnv()?function(){return{write:function(r,n,s,a,i,u){var c=[];c.push(r+"="+encodeURIComponent(n)),ne.isNumber(s)&&c.push("expires="+new Date(s).toGMTString()),ne.isString(a)&&c.push("path="+a),ne.isString(i)&&c.push("domain="+i),u===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),un=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},cn=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},ln=un,fn=cn,dn=function(e,r){return e&&!ln(r)?fn(e,r):r},Pe=N,hn=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],pn=function(e){var r={},n,s,a;return e&&Pe.forEach(e.split(`
2
- `),function(u){if(a=u.indexOf(":"),n=Pe.trim(u.substr(0,a)).toLowerCase(),s=Pe.trim(u.substr(a+1)),n){if(r[n]&&hn.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r},wr=N,mn=wr.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(a){var i=a;return e&&(r.setAttribute("href",i),i=r.href),r.setAttribute("href",i),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(i){var u=wr.isString(i)?s(i):i;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}();function Ie(t){this.message=t}Ie.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Ie.prototype.__CANCEL__=!0;var se=Ie,ae=N,vn=an,yn=on,gn=vr,wn=dn,bn=pn,Sn=mn,je=gr,En=oe,$n=se,br=function(e){return new Promise(function(n,s){var a=e.data,i=e.headers,u=e.responseType,c;function g(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}ae.isFormData(a)&&delete i["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",y=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(h+":"+y)}var v=wn(e.baseURL,e.url);o.open(e.method.toUpperCase(),gn(v,e.params,e.paramsSerializer),!0),o.timeout=e.timeout;function x(){if(!!o){var b="getAllResponseHeaders"in o?bn(o.getAllResponseHeaders()):null,T=!u||u==="text"||u==="json"?o.responseText:o.response,l={data:T,status:o.status,statusText:o.statusText,headers:b,config:e,request:o};vn(function(d){n(d),g()},function(d){s(d),g()},l),o=null}}if("onloadend"in o?o.onloadend=x:o.onreadystatechange=function(){!o||o.readyState!==4||o.status===0&&!(o.responseURL&&o.responseURL.indexOf("file:")===0)||setTimeout(x)},o.onabort=function(){!o||(s(je("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){s(je("Network Error",e,null,o)),o=null},o.ontimeout=function(){var T=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",l=e.transitional||En.transitional;e.timeoutErrorMessage&&(T=e.timeoutErrorMessage),s(je(T,e,l.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},ae.isStandardBrowserEnv()){var E=(e.withCredentials||Sn(v))&&e.xsrfCookieName?yn.read(e.xsrfCookieName):void 0;E&&(i[e.xsrfHeaderName]=E)}"setRequestHeader"in o&&ae.forEach(i,function(T,l){typeof a=="undefined"&&l.toLowerCase()==="content-type"?delete i[l]:o.setRequestHeader(l,T)}),ae.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),u&&u!=="json"&&(o.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&o.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(c=function(b){!o||(s(!b||b&&b.type?new $n("canceled"):b),o.abort(),o=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),a||(a=null),o.send(a)})},$=N,Sr=tn,Cn=yr,An={"Content-Type":"application/x-www-form-urlencoded"};function Er(t,e){!$.isUndefined(t)&&$.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Tn(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=br),t}function On(t,e,r){if($.isString(t))try{return(e||JSON.parse)(t),$.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var ie={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Tn(),transformRequest:[function(e,r){return Sr(r,"Accept"),Sr(r,"Content-Type"),$.isFormData(e)||$.isArrayBuffer(e)||$.isBuffer(e)||$.isStream(e)||$.isFile(e)||$.isBlob(e)?e:$.isArrayBufferView(e)?e.buffer:$.isURLSearchParams(e)?(Er(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):$.isObject(e)||r&&r["Content-Type"]==="application/json"?(Er(r,"application/json"),On(e)):e}],transformResponse:[function(e){var r=this.transitional||ie.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,a=!n&&this.responseType==="json";if(a||s&&$.isString(e)&&e.length)try{return JSON.parse(e)}catch(i){if(a)throw i.name==="SyntaxError"?Cn(i,this,"E_JSON_PARSE"):i}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};$.forEach(["delete","get","head"],function(e){ie.headers[e]={}});$.forEach(["post","put","patch"],function(e){ie.headers[e]=$.merge(An)});var oe=ie,xn=N,Rn=oe,Nn=function(e,r,n){var s=this||Rn;return xn.forEach(n,function(i){e=i.call(s,e,r)}),e},$r=function(e){return!!(e&&e.__CANCEL__)},Cr=N,Fe=Nn,kn=$r,Un=oe,Pn=se;function Le(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Pn("canceled")}var In=function(e){Le(e),e.headers=e.headers||{},e.data=Fe.call(e,e.data,e.headers,e.transformRequest),e.headers=Cr.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Cr.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||Un.adapter;return r(e).then(function(s){return Le(e),s.data=Fe.call(e,s.data,s.headers,e.transformResponse),s},function(s){return kn(s)||(Le(e),s&&s.response&&(s.response.data=Fe.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})},U=N,Ar=function(e,r){r=r||{};var n={};function s(o,h){return U.isPlainObject(o)&&U.isPlainObject(h)?U.merge(o,h):U.isPlainObject(h)?U.merge({},h):U.isArray(h)?h.slice():h}function a(o){if(U.isUndefined(r[o])){if(!U.isUndefined(e[o]))return s(void 0,e[o])}else return s(e[o],r[o])}function i(o){if(!U.isUndefined(r[o]))return s(void 0,r[o])}function u(o){if(U.isUndefined(r[o])){if(!U.isUndefined(e[o]))return s(void 0,e[o])}else return s(void 0,r[o])}function c(o){if(o in r)return s(e[o],r[o]);if(o in e)return s(void 0,e[o])}var g={url:i,method:i,data:i,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:c};return U.forEach(Object.keys(e).concat(Object.keys(r)),function(h){var y=g[h]||a,v=y(h);U.isUndefined(v)&&y!==c||(n[h]=v)}),n},Tr={version:"0.25.0"},jn=Tr.version,De={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){De[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var Or={};De.transitional=function(e,r,n){function s(a,i){return"[Axios v"+jn+"] Transitional option '"+a+"'"+i+(n?". "+n:"")}return function(a,i,u){if(e===!1)throw new Error(s(i," has been removed"+(r?" in "+r:"")));return r&&!Or[i]&&(Or[i]=!0,console.warn(s(i," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,i,u):!0}};function Fn(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var a=n[s],i=e[a];if(i){var u=t[a],c=u===void 0||i(u,a,t);if(c!==!0)throw new TypeError("option "+a+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+a)}}var Ln={assertOptions:Fn,validators:De},xr=N,Dn=vr,Rr=en,Nr=In,ue=Ar,kr=Ln,J=kr.validators;function Q(t){this.defaults=t,this.interceptors={request:new Rr,response:new Rr}}Q.prototype.request=function(e,r){if(typeof e=="string"?(r=r||{},r.url=e):r=e||{},!r.url)throw new Error("Provided config url is not valid");r=ue(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var n=r.transitional;n!==void 0&&kr.assertOptions(n,{silentJSONParsing:J.transitional(J.boolean),forcedJSONParsing:J.transitional(J.boolean),clarifyTimeoutError:J.transitional(J.boolean)},!1);var s=[],a=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(r)===!1||(a=a&&v.synchronous,s.unshift(v.fulfilled,v.rejected))});var i=[];this.interceptors.response.forEach(function(v){i.push(v.fulfilled,v.rejected)});var u;if(!a){var c=[Nr,void 0];for(Array.prototype.unshift.apply(c,s),c=c.concat(i),u=Promise.resolve(r);c.length;)u=u.then(c.shift(),c.shift());return u}for(var g=r;s.length;){var o=s.shift(),h=s.shift();try{g=o(g)}catch(y){h(y);break}}try{u=Nr(g)}catch(y){return Promise.reject(y)}for(;i.length;)u=u.then(i.shift(),i.shift());return u};Q.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=ue(this.defaults,e),Dn(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};xr.forEach(["delete","get","head","options"],function(e){Q.prototype[e]=function(r,n){return this.request(ue(n||{},{method:e,url:r,data:(n||{}).data}))}});xr.forEach(["post","put","patch"],function(e){Q.prototype[e]=function(r,n,s){return this.request(ue(s||{},{method:e,url:r,data:n}))}});var Bn=Q,_n=se;function z(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;this.promise.then(function(n){if(!!r._listeners){var s,a=r._listeners.length;for(s=0;s<a;s++)r._listeners[s](n);r._listeners=null}}),this.promise.then=function(n){var s,a=new Promise(function(i){r.subscribe(i),s=i}).then(n);return a.cancel=function(){r.unsubscribe(s)},a},t(function(s){r.reason||(r.reason=new _n(s),e(r.reason))})}z.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};z.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};z.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};z.source=function(){var e,r=new z(function(s){e=s});return{token:r,cancel:e}};var qn=z,Hn=function(e){return function(n){return e.apply(null,n)}},Mn=N,Jn=function(e){return Mn.isObject(e)&&e.isAxiosError===!0},Ur=N,zn=fr,ce=Bn,Vn=Ar,Wn=oe;function Pr(t){var e=new ce(t),r=zn(ce.prototype.request,e);return Ur.extend(r,ce.prototype,e),Ur.extend(r,e),r.create=function(s){return Pr(Vn(t,s))},r}var L=Pr(Wn);L.Axios=ce;L.Cancel=se;L.CancelToken=qn;L.isCancel=$r;L.VERSION=Tr.version;L.all=function(e){return Promise.all(e)};L.spread=Hn;L.isAxiosError=Jn;xe.exports=L;xe.exports.default=L;var Xn=xe.exports;const Kn=500;class Gn{constructor({url:e=""}){this.url=e,this.httpClient=Xn.create({baseURL:this.url}),this.httpClient.interceptors.response.use(r=>r,r=>{var n,s,a,i,u,c;return Promise.reject({message:(i=(a=(s=(n=r.response)==null?void 0:n.data)==null?void 0:s.message)!=null?a:r.message)!=null?i:JSON.stringify(r),status:(c=(u=r.response)==null?void 0:u.status)!=null?c:Kn})})}async signUpEmailPassword(e){try{return{data:(await this.httpClient.post("/signup/email-password",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInEmailPassword(e){try{return{data:(await this.httpClient.post("/signin/email-password",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessEmail(e){try{return{data:(await this.httpClient.post("/signin/passwordless/email",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessSms(e){try{return{data:(await this.httpClient.post("/signin/passwordless/sms",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessSmsOtp(e){try{return{data:(await this.httpClient.post("/signin/passwordless/sms/otp",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signOut(e){try{return await this.httpClient.post("/signout",e),{error:null}}catch(r){return{error:r}}}async refreshToken(e){try{const r=await this.httpClient.post("/token",e);return{error:null,session:r.data}}catch(r){return{error:r,session:null}}}async resetPassword(e){try{return await this.httpClient.post("/user/password/reset",e),{error:null}}catch(r){return{error:r}}}async changePassword(e){try{return await this.httpClient.post("/user/password",e,{headers:R({},this.generateAuthHeaders())}),{error:null}}catch(r){return{error:r}}}async sendVerificationEmail(e){try{return await this.httpClient.post("/user/email/send-verification-email",e),{error:null}}catch(r){return{error:r}}}async changeEmail(e){try{return await this.httpClient.post("/user/email/change",e,{headers:R({},this.generateAuthHeaders())}),{error:null}}catch(r){return{error:r}}}async deanonymize(e){try{return await this.httpClient.post("/user/deanonymize",e),{error:null}}catch(r){return{error:r}}}async verifyEmail(e){try{return{data:(await this.httpClient.post("/user/email/verify",e)).data,error:null}}catch(r){return{data:null,error:r}}}setAccessToken(e){this.accessToken=e}generateAuthHeaders(){return this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:null}}var Ir={},Qn=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),jr="%[a-f0-9]{2}",Fr=new RegExp(jr,"gi"),Lr=new RegExp("("+jr+")+","gi");function Be(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Be(r),Be(n))}function Yn(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Fr),r=1;r<e.length;r++)t=Be(e,r).join(""),e=t.match(Fr);return t}}function Zn(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Lr.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=Yn(r[0]);n!==r[0]&&(e[r[0]]=n)}r=Lr.exec(t)}e["%C2"]="\uFFFD";for(var s=Object.keys(e),a=0;a<s.length;a++){var i=s[a];t=t.replace(new RegExp(i,"g"),e[i])}return t}var es=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return Zn(t)}},rs=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},ts=function(t,e){for(var r={},n=Object.keys(t),s=Array.isArray(e),a=0;a<n.length;a++){var i=n[a],u=t[i];(s?e.indexOf(i)!==-1:e(i,u,t))&&(r[i]=u)}return r};(function(t){const e=Qn,r=es,n=rs,s=ts,a=l=>l==null,i=Symbol("encodeFragmentIdentifier");function u(l){switch(l.arrayFormat){case"index":return f=>(d,p)=>{const m=d.length;return p===void 0||l.skipNull&&p===null||l.skipEmptyString&&p===""?d:p===null?[...d,[o(f,l),"[",m,"]"].join("")]:[...d,[o(f,l),"[",o(m,l),"]=",o(p,l)].join("")]};case"bracket":return f=>(d,p)=>p===void 0||l.skipNull&&p===null||l.skipEmptyString&&p===""?d:p===null?[...d,[o(f,l),"[]"].join("")]:[...d,[o(f,l),"[]=",o(p,l)].join("")];case"colon-list-separator":return f=>(d,p)=>p===void 0||l.skipNull&&p===null||l.skipEmptyString&&p===""?d:p===null?[...d,[o(f,l),":list="].join("")]:[...d,[o(f,l),":list=",o(p,l)].join("")];case"comma":case"separator":case"bracket-separator":{const f=l.arrayFormat==="bracket-separator"?"[]=":"=";return d=>(p,m)=>m===void 0||l.skipNull&&m===null||l.skipEmptyString&&m===""?p:(m=m===null?"":m,p.length===0?[[o(d,l),f,o(m,l)].join("")]:[[p,o(m,l)].join(l.arrayFormatSeparator)])}default:return f=>(d,p)=>p===void 0||l.skipNull&&p===null||l.skipEmptyString&&p===""?d:p===null?[...d,o(f,l)]:[...d,[o(f,l),"=",o(p,l)].join("")]}}function c(l){let f;switch(l.arrayFormat){case"index":return(d,p,m)=>{if(f=/\[(\d*)\]$/.exec(d),d=d.replace(/\[\d*\]$/,""),!f){m[d]=p;return}m[d]===void 0&&(m[d]={}),m[d][f[1]]=p};case"bracket":return(d,p,m)=>{if(f=/(\[\])$/.exec(d),d=d.replace(/\[\]$/,""),!f){m[d]=p;return}if(m[d]===void 0){m[d]=[p];return}m[d]=[].concat(m[d],p)};case"colon-list-separator":return(d,p,m)=>{if(f=/(:list)$/.exec(d),d=d.replace(/:list$/,""),!f){m[d]=p;return}if(m[d]===void 0){m[d]=[p];return}m[d]=[].concat(m[d],p)};case"comma":case"separator":return(d,p,m)=>{const S=typeof p=="string"&&p.includes(l.arrayFormatSeparator),w=typeof p=="string"&&!S&&h(p,l).includes(l.arrayFormatSeparator);p=w?h(p,l):p;const k=S||w?p.split(l.arrayFormatSeparator).map(Ut=>h(Ut,l)):p===null?p:h(p,l);m[d]=k};case"bracket-separator":return(d,p,m)=>{const S=/(\[\])$/.test(d);if(d=d.replace(/\[\]$/,""),!S){m[d]=p&&h(p,l);return}const w=p===null?[]:p.split(l.arrayFormatSeparator).map(k=>h(k,l));if(m[d]===void 0){m[d]=w;return}m[d]=[].concat(m[d],w)};default:return(d,p,m)=>{if(m[d]===void 0){m[d]=p;return}m[d]=[].concat(m[d],p)}}}function g(l){if(typeof l!="string"||l.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function o(l,f){return f.encode?f.strict?e(l):encodeURIComponent(l):l}function h(l,f){return f.decode?r(l):l}function y(l){return Array.isArray(l)?l.sort():typeof l=="object"?y(Object.keys(l)).sort((f,d)=>Number(f)-Number(d)).map(f=>l[f]):l}function v(l){const f=l.indexOf("#");return f!==-1&&(l=l.slice(0,f)),l}function x(l){let f="";const d=l.indexOf("#");return d!==-1&&(f=l.slice(d)),f}function E(l){l=v(l);const f=l.indexOf("?");return f===-1?"":l.slice(f+1)}function b(l,f){return f.parseNumbers&&!Number.isNaN(Number(l))&&typeof l=="string"&&l.trim()!==""?l=Number(l):f.parseBooleans&&l!==null&&(l.toLowerCase()==="true"||l.toLowerCase()==="false")&&(l=l.toLowerCase()==="true"),l}function T(l,f){f=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},f),g(f.arrayFormatSeparator);const d=c(f),p=Object.create(null);if(typeof l!="string"||(l=l.trim().replace(/^[?#&]/,""),!l))return p;for(const m of l.split("&")){if(m==="")continue;let[S,w]=n(f.decode?m.replace(/\+/g," "):m,"=");w=w===void 0?null:["comma","separator","bracket-separator"].includes(f.arrayFormat)?w:h(w,f),d(h(S,f),w,p)}for(const m of Object.keys(p)){const S=p[m];if(typeof S=="object"&&S!==null)for(const w of Object.keys(S))S[w]=b(S[w],f);else p[m]=b(S,f)}return f.sort===!1?p:(f.sort===!0?Object.keys(p).sort():Object.keys(p).sort(f.sort)).reduce((m,S)=>{const w=p[S];return Boolean(w)&&typeof w=="object"&&!Array.isArray(w)?m[S]=y(w):m[S]=w,m},Object.create(null))}t.extract=E,t.parse=T,t.stringify=(l,f)=>{if(!l)return"";f=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},f),g(f.arrayFormatSeparator);const d=w=>f.skipNull&&a(l[w])||f.skipEmptyString&&l[w]==="",p=u(f),m={};for(const w of Object.keys(l))d(w)||(m[w]=l[w]);const S=Object.keys(m);return f.sort!==!1&&S.sort(f.sort),S.map(w=>{const k=l[w];return k===void 0?"":k===null?o(w,f):Array.isArray(k)?k.length===0&&f.arrayFormat==="bracket-separator"?o(w,f)+"[]":k.reduce(p(w),[]).join("&"):o(w,f)+"="+o(k,f)}).filter(w=>w.length>0).join("&")},t.parseUrl=(l,f)=>{f=Object.assign({decode:!0},f);const[d,p]=n(l,"#");return Object.assign({url:d.split("?")[0]||"",query:T(E(l),f)},f&&f.parseFragmentIdentifier&&p?{fragmentIdentifier:h(p,f)}:{})},t.stringifyUrl=(l,f)=>{f=Object.assign({encode:!0,strict:!0,[i]:!0},f);const d=v(l.url).split("?")[0]||"",p=t.extract(l.url),m=t.parse(p,{sort:!1}),S=Object.assign(m,l.query);let w=t.stringify(S,f);w&&(w=`?${w}`);let k=x(l.url);return l.fragmentIdentifier&&(k=`#${f[i]?o(l.fragmentIdentifier,f):l.fragmentIdentifier}`),`${d}${w}${k}`},t.pick=(l,f,d)=>{d=Object.assign({parseFragmentIdentifier:!0,[i]:!1},d);const{url:p,query:m,fragmentIdentifier:S}=t.parseUrl(l,d);return t.stringifyUrl({url:p,query:s(m,f),fragmentIdentifier:S},d)},t.exclude=(l,f,d)=>{const p=Array.isArray(f)?m=>!f.includes(m):(m,S)=>!f(m,S);return t.pick(l,p,d)}})(Ir);const _="nhostRefreshToken",le=()=>typeof window!="undefined";class ns{constructor(){this.memory={}}setItem(e,r){this.memory[e]=r}getItem(e){return this.memory[e]}removeItem(e){delete this.memory[e]}}class ss{constructor({url:e,autoRefreshToken:r=!0,autoLogin:n=!0,refreshIntervalTime:s,clientStorage:a,clientStorageType:i="web"}){this.refreshIntervalTime=s,a?this.clientStorage=a:this.clientStorage=le()?localStorage:new ns,this.clientStorageType=i,this.onTokenChangedFunctions=[],this.onAuthChangedFunctions=[],this.refreshInterval,this.refreshSleepCheckInterval=0,this.refreshIntervalSleepCheckLastSample=Date.now(),this.sampleRate=2e3,this.url=e,this.autoRefreshToken=r,this.initAuthLoading=!0,this.session=null,this.api=new Gn({url:this.url});let u=null,c=!1;if(n&&le()&&window.location){const g=Ir.parse(window.location.toString().split("#")[1]);if("refreshToken"in g&&(u=g.refreshToken),"otp"in g&&"email"in g){const{otp:o,email:h}=g;this.signIn({otp:o,email:h}),c=!0}}!c&&n?this._autoLogin(u):u&&this._setItem(_,u)}async signUp(e){const{email:r,password:n}=e;if(r&&n){const{data:s,error:a}=await this.api.signUpEmailPassword(e);if(a)return{session:null,error:a};if(!s)return{session:null,error:{message:"An error occurred on sign up.",status:500}};const{session:i}=s;return i&&await this._setSession(i),{session:i,error:null}}return{session:null,error:{message:"Incorrect parameters",status:500}}}async signIn(e){if("provider"in e){const{provider:r}=e,n=`${this.url}/signin/provider/${r}`;return le()&&(window.location.href=n),{providerUrl:n,provider:r,session:null,mfa:null,error:null}}if("email"in e&&"password"in e){const{data:r,error:n}=await this.api.signInEmailPassword(e);if(n)return{session:null,mfa:null,error:n};if(!r)return{session:null,mfa:null,error:{message:"Incorrect Data",status:500}};const{session:s,mfa:a}=r;return s&&await this._setSession(s),{session:s,mfa:a,error:null}}if("email"in e&&!("otp"in e)){const{error:r}=await this.api.signInPasswordlessEmail(e);return r?{session:null,mfa:null,error:r}:{session:null,mfa:null,error:null}}if("phoneNumber"in e&&!("otp"in e)){const{error:r}=await this.api.signInPasswordlessSms(e);return r?{session:null,mfa:null,error:r}:{session:null,mfa:null,error:null}}if("otp"in e){const{data:r,error:n}=await this.api.signInPasswordlessSmsOtp(e);if(n)return{session:null,mfa:null,error:n};if(!r)return{session:null,mfa:null,error:{message:"Incorrect data",status:500}};const{session:s,mfa:a}=r;return s&&await this._setSession(s),{session:s,mfa:a,error:null}}return{session:null,mfa:null,error:{message:"Incorrect parameters",status:500}}}async signOut(e){const r=await this._getItem(_);this._clearSession();const{error:n}=await this.api.signOut({refreshToken:r,all:e==null?void 0:e.all});return{error:n}}async verifyEmail(e){return await this.api.verifyEmail(e)}async resetPassword(e){const{error:r}=await this.api.resetPassword(e);return{error:r}}async changePassword(e){const{error:r}=await this.api.changePassword(e);return{error:r}}async sendVerificationEmail(e){const{error:r}=await this.api.sendVerificationEmail(e);return{error:r}}async changeEmail(e){const{error:r}=await this.api.changeEmail(e);return{error:r}}async deanonymize(e){const{error:r}=await this.api.deanonymize(e);return{error:r}}onTokenChanged(e){this.onTokenChangedFunctions.push(e);const r=this.onTokenChangedFunctions.length-1;return()=>{try{this.onTokenChangedFunctions[r]=()=>{}}catch{console.warn("Unable to unsubscribe onTokenChanged function. Maybe the functions is already unsubscribed?")}}}onAuthStateChanged(e){this.onAuthChangedFunctions.push(e);const r=this.onAuthChangedFunctions.length-1;return()=>{try{this.onAuthChangedFunctions[r]=()=>{}}catch{console.warn("Unable to unsubscribe onAuthStateChanged function. Maybe you already did?")}}}isAuthenticated(){return this.session!==null}async isAuthenticatedAsync(){return new Promise(e=>{if(!this.initAuthLoading)e(this.isAuthenticated());else{const r=this.onAuthStateChanged((n,s)=>{e(n==="SIGNED_IN"),r()})}})}getAuthenticationStatus(){return this.initAuthLoading?{isAuthenticated:!1,isLoading:!0}:{isAuthenticated:this.session!==null,isLoading:!1}}getJWTToken(){return this.getAccessToken()}getAccessToken(){if(!!this.session)return this.session.accessToken}async refreshSession(e){const r=e||await this._getItem(_);return r||console.warn("no refresh token found. No way of refreshing session"),this._refreshTokens(r)}getSession(){return this.session}getUser(){return this.session?this.session.user:null}async _setItem(e,r){if(typeof r!="string"){console.error('value is not of type "string"');return}switch(this.clientStorageType){case"web":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}this.clientStorage.setItem(e,r);break;case"custom":case"react-native":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}await this.clientStorage.setItem(e,r);break;case"capacitor":if(typeof this.clientStorage.set!="function"){console.error("this.clientStorage.set is not a function");break}await this.clientStorage.set({key:e,value:r});break;case"expo-secure-storage":if(typeof this.clientStorage.setItemAsync!="function"){console.error("this.clientStorage.setItemAsync is not a function");break}this.clientStorage.setItemAsync(e,r);break}}async _getItem(e){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return this.clientStorage.getItem(e);case"custom":case"react-native":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return await this.clientStorage.getItem(e);case"capacitor":if(typeof this.clientStorage.get!="function"){console.error("this.clientStorage.get is not a function");break}return(await this.clientStorage.get({key:e})).value;case"expo-secure-storage":if(typeof this.clientStorage.getItemAsync!="function"){console.error("this.clientStorage.getItemAsync is not a function");break}return this.clientStorage.getItemAsync(e);default:return""}return""}async _removeItem(e){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(e);case"custom":case"react-native":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(e);case"capacitor":if(typeof this.clientStorage.remove!="function"){console.error("this.clientStorage.remove is not a function");break}await this.clientStorage.remove({key:e});break;case"expo-secure-storage":if(typeof this.clientStorage.deleteItemAsync!="function"){console.error("this.clientStorage.deleteItemAsync is not a function");break}this.clientStorage.deleteItemAsync(e);break}}_autoLogin(e){!le()||this._refreshTokens(e)}async _refreshTokens(e){const r=e||await this._getItem(_);if(!r){setTimeout(async()=>{await this._clearSession()},0);return}try{const{session:n,error:s}=await this.api.refreshToken({refreshToken:r});if(s&&s.status===401){await this._clearSession();return}if(!n)throw new Error("Invalid session data");await this._setSession(n),this.tokenChanged()}catch{}}tokenChanged(){for(const e of this.onTokenChangedFunctions)e(this.session)}authStateChanged({event:e,session:r}){e==="SIGNED_IN"&&r?this.api.setAccessToken(r.accessToken):this.api.setAccessToken(void 0);for(const n of this.onAuthChangedFunctions)n(e,r)}async _clearSession(){const{isLoading:e,isAuthenticated:r}=this.getAuthenticationStatus();this.session=null,this.initAuthLoading=!1,await this._removeItem(_),(e||r)&&(clearInterval(this.refreshInterval),clearInterval(this.refreshSleepCheckInterval),this.authStateChanged({event:"SIGNED_OUT",session:null}))}async _setSession(e){const{isAuthenticated:r}=this.getAuthenticationStatus();if(this.session=e,await this._setItem(_,e.refreshToken),this.autoRefreshToken&&!r){const n=e.accessTokenExpiresIn,s=this.refreshIntervalTime?this.refreshIntervalTime:Math.max(1,n-1);this.refreshInterval=setInterval(async()=>{const a=await this._getItem(_);await this._refreshTokens(a)},s*1e3),this.refreshIntervalSleepCheckLastSample=Date.now(),this.refreshSleepCheckInterval=setInterval(async()=>{if(Date.now()-this.refreshIntervalSleepCheckLastSample>=this.sampleRate*2){const a=await this._getItem(_);await this._refreshTokens(a)}this.refreshIntervalSleepCheckLastSample=Date.now()},this.sampleRate),this.authStateChanged({event:"SIGNED_IN",session:this.session})}this.initAuthLoading=!1}}var _e={exports:{}},Dr=function(e,r){return function(){for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];return e.apply(r,s)}},as=Dr,q=Object.prototype.toString;function qe(t){return q.call(t)==="[object Array]"}function He(t){return typeof t=="undefined"}function is(t){return t!==null&&!He(t)&&t.constructor!==null&&!He(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function os(t){return q.call(t)==="[object ArrayBuffer]"}function us(t){return typeof FormData!="undefined"&&t instanceof FormData}function cs(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function ls(t){return typeof t=="string"}function fs(t){return typeof t=="number"}function Br(t){return t!==null&&typeof t=="object"}function fe(t){if(q.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function ds(t){return q.call(t)==="[object Date]"}function hs(t){return q.call(t)==="[object File]"}function ps(t){return q.call(t)==="[object Blob]"}function _r(t){return q.call(t)==="[object Function]"}function ms(t){return Br(t)&&_r(t.pipe)}function vs(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function ys(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function gs(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Me(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),qe(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}function Je(){var t={};function e(s,a){fe(t[a])&&fe(s)?t[a]=Je(t[a],s):fe(s)?t[a]=Je({},s):qe(s)?t[a]=s.slice():t[a]=s}for(var r=0,n=arguments.length;r<n;r++)Me(arguments[r],e);return t}function ws(t,e,r){return Me(e,function(s,a){r&&typeof s=="function"?t[a]=as(s,r):t[a]=s}),t}function bs(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var P={isArray:qe,isArrayBuffer:os,isBuffer:is,isFormData:us,isArrayBufferView:cs,isString:ls,isNumber:fs,isObject:Br,isPlainObject:fe,isUndefined:He,isDate:ds,isFile:hs,isBlob:ps,isFunction:_r,isStream:ms,isURLSearchParams:vs,isStandardBrowserEnv:gs,forEach:Me,merge:Je,extend:ws,trim:ys,stripBOM:bs},V=P;function qr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Hr=function(e,r,n){if(!r)return e;var s;if(n)s=n(r);else if(V.isURLSearchParams(r))s=r.toString();else{var a=[];V.forEach(r,function(c,g){c===null||typeof c=="undefined"||(V.isArray(c)?g=g+"[]":c=[c],V.forEach(c,function(h){V.isDate(h)?h=h.toISOString():V.isObject(h)&&(h=JSON.stringify(h)),a.push(qr(g)+"="+qr(h))}))}),s=a.join("&")}if(s){var i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e},Ss=P;function de(){this.handlers=[]}de.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};de.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};de.prototype.forEach=function(e){Ss.forEach(this.handlers,function(n){n!==null&&e(n)})};var Es=de,$s=P,Cs=function(e,r){$s.forEach(e,function(s,a){a!==r&&a.toUpperCase()===r.toUpperCase()&&(e[r]=s,delete e[a])})},Mr=function(e,r,n,s,a){return e.config=r,n&&(e.code=n),e.request=s,e.response=a,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},As=Mr,Jr=function(e,r,n,s,a){var i=new Error(e);return As(i,r,n,s,a)},Ts=Jr,Os=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(Ts("Request failed with status code "+n.status,n.config,null,n.request,n))},he=P,xs=he.isStandardBrowserEnv()?function(){return{write:function(r,n,s,a,i,u){var c=[];c.push(r+"="+encodeURIComponent(n)),he.isNumber(s)&&c.push("expires="+new Date(s).toGMTString()),he.isString(a)&&c.push("path="+a),he.isString(i)&&c.push("domain="+i),u===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),Rs=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Ns=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},ks=Rs,Us=Ns,Ps=function(e,r){return e&&!ks(r)?Us(e,r):r},ze=P,Is=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],js=function(e){var r={},n,s,a;return e&&ze.forEach(e.split(`
3
- `),function(u){if(a=u.indexOf(":"),n=ze.trim(u.substr(0,a)).toLowerCase(),s=ze.trim(u.substr(a+1)),n){if(r[n]&&Is.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r},zr=P,Fs=zr.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(a){var i=a;return e&&(r.setAttribute("href",i),i=r.href),r.setAttribute("href",i),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(i){var u=zr.isString(i)?s(i):i;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}(),pe=P,Ls=Os,Ds=xs,Bs=Hr,_s=Ps,qs=js,Hs=Fs,Ve=Jr,Vr=function(e){return new Promise(function(n,s){var a=e.data,i=e.headers,u=e.responseType;pe.isFormData(a)&&delete i["Content-Type"];var c=new XMLHttpRequest;if(e.auth){var g=e.auth.username||"",o=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(g+":"+o)}var h=_s(e.baseURL,e.url);c.open(e.method.toUpperCase(),Bs(h,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function y(){if(!!c){var x="getAllResponseHeaders"in c?qs(c.getAllResponseHeaders()):null,E=!u||u==="text"||u==="json"?c.responseText:c.response,b={data:E,status:c.status,statusText:c.statusText,headers:x,config:e,request:c};Ls(n,s,b),c=null}}if("onloadend"in c?c.onloadend=y:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(y)},c.onabort=function(){!c||(s(Ve("Request aborted",e,"ECONNABORTED",c)),c=null)},c.onerror=function(){s(Ve("Network Error",e,null,c)),c=null},c.ontimeout=function(){var E="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(E=e.timeoutErrorMessage),s(Ve(E,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},pe.isStandardBrowserEnv()){var v=(e.withCredentials||Hs(h))&&e.xsrfCookieName?Ds.read(e.xsrfCookieName):void 0;v&&(i[e.xsrfHeaderName]=v)}"setRequestHeader"in c&&pe.forEach(i,function(E,b){typeof a=="undefined"&&b.toLowerCase()==="content-type"?delete i[b]:c.setRequestHeader(b,E)}),pe.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),u&&u!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(E){!c||(c.abort(),s(E),c=null)}),a||(a=null),c.send(a)})},C=P,Wr=Cs,Ms=Mr,Js={"Content-Type":"application/x-www-form-urlencoded"};function Xr(t,e){!C.isUndefined(t)&&C.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function zs(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=Vr),t}function Vs(t,e,r){if(C.isString(t))try{return(e||JSON.parse)(t),C.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var me={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:zs(),transformRequest:[function(e,r){return Wr(r,"Accept"),Wr(r,"Content-Type"),C.isFormData(e)||C.isArrayBuffer(e)||C.isBuffer(e)||C.isStream(e)||C.isFile(e)||C.isBlob(e)?e:C.isArrayBufferView(e)?e.buffer:C.isURLSearchParams(e)?(Xr(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):C.isObject(e)||r&&r["Content-Type"]==="application/json"?(Xr(r,"application/json"),Vs(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,a=!n&&this.responseType==="json";if(a||s&&C.isString(e)&&e.length)try{return JSON.parse(e)}catch(i){if(a)throw i.name==="SyntaxError"?Ms(i,this,"E_JSON_PARSE"):i}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};me.headers={common:{Accept:"application/json, text/plain, */*"}};C.forEach(["delete","get","head"],function(e){me.headers[e]={}});C.forEach(["post","put","patch"],function(e){me.headers[e]=C.merge(Js)});var We=me,Ws=P,Xs=We,Ks=function(e,r,n){var s=this||Xs;return Ws.forEach(n,function(i){e=i.call(s,e,r)}),e},Kr=function(e){return!!(e&&e.__CANCEL__)},Gr=P,Xe=Ks,Gs=Kr,Qs=We;function Ke(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Ys=function(e){Ke(e),e.headers=e.headers||{},e.data=Xe.call(e,e.data,e.headers,e.transformRequest),e.headers=Gr.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Gr.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||Qs.adapter;return r(e).then(function(s){return Ke(e),s.data=Xe.call(e,s.data,s.headers,e.transformResponse),s},function(s){return Gs(s)||(Ke(e),s&&s.response&&(s.response.data=Xe.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})},O=P,Qr=function(e,r){r=r||{};var n={},s=["url","method","data"],a=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],u=["validateStatus"];function c(y,v){return O.isPlainObject(y)&&O.isPlainObject(v)?O.merge(y,v):O.isPlainObject(v)?O.merge({},v):O.isArray(v)?v.slice():v}function g(y){O.isUndefined(r[y])?O.isUndefined(e[y])||(n[y]=c(void 0,e[y])):n[y]=c(e[y],r[y])}O.forEach(s,function(v){O.isUndefined(r[v])||(n[v]=c(void 0,r[v]))}),O.forEach(a,g),O.forEach(i,function(v){O.isUndefined(r[v])?O.isUndefined(e[v])||(n[v]=c(void 0,e[v])):n[v]=c(void 0,r[v])}),O.forEach(u,function(v){v in r?n[v]=c(e[v],r[v]):v in e&&(n[v]=c(void 0,e[v]))});var o=s.concat(a).concat(i).concat(u),h=Object.keys(e).concat(Object.keys(r)).filter(function(v){return o.indexOf(v)===-1});return O.forEach(h,g),n};const Zs="axios",ea="0.21.4",ra="Promise based HTTP client for the browser and node.js",ta="index.js",na={test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},sa={type:"git",url:"https://github.com/axios/axios.git"},aa=["xhr","http","ajax","promise","node"],ia="Matt Zabriskie",oa="MIT",ua={url:"https://github.com/axios/axios/issues"},ca="https://axios-http.com",la={coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},fa={"./lib/adapters/http.js":"./lib/adapters/xhr.js"},da="dist/axios.min.js",ha="dist/axios.min.js",pa="./index.d.ts",ma={"follow-redirects":"^1.14.0"},va=[{path:"./dist/axios.min.js",threshold:"5kB"}];var ya={name:Zs,version:ea,description:ra,main:ta,scripts:na,repository:sa,keywords:aa,author:ia,license:oa,bugs:ua,homepage:ca,devDependencies:la,browser:fa,jsdelivr:da,unpkg:ha,typings:pa,dependencies:ma,bundlesize:va},Yr=ya,Ge={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){Ge[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var Zr={},ga=Yr.version.split(".");function et(t,e){for(var r=e?e.split("."):ga,n=t.split("."),s=0;s<3;s++){if(r[s]>n[s])return!0;if(r[s]<n[s])return!1}return!1}Ge.transitional=function(e,r,n){var s=r&&et(r);function a(i,u){return"[Axios v"+Yr.version+"] Transitional option '"+i+"'"+u+(n?". "+n:"")}return function(i,u,c){if(e===!1)throw new Error(a(u," has been removed in "+r));return s&&!Zr[u]&&(Zr[u]=!0,console.warn(a(u," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,u,c):!0}};function wa(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var a=n[s],i=e[a];if(i){var u=t[a],c=u===void 0||i(u,a,t);if(c!==!0)throw new TypeError("option "+a+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+a)}}var ba={isOlderVersion:et,assertOptions:wa,validators:Ge},rt=P,Sa=Hr,tt=Es,nt=Ys,ve=Qr,st=ba,W=st.validators;function Y(t){this.defaults=t,this.interceptors={request:new tt,response:new tt}}Y.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=ve(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&st.assertOptions(r,{silentJSONParsing:W.transitional(W.boolean,"1.0.0"),forcedJSONParsing:W.transitional(W.boolean,"1.0.0"),clarifyTimeoutError:W.transitional(W.boolean,"1.0.0")},!1);var n=[],s=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(e)===!1||(s=s&&y.synchronous,n.unshift(y.fulfilled,y.rejected))});var a=[];this.interceptors.response.forEach(function(y){a.push(y.fulfilled,y.rejected)});var i;if(!s){var u=[nt,void 0];for(Array.prototype.unshift.apply(u,n),u=u.concat(a),i=Promise.resolve(e);u.length;)i=i.then(u.shift(),u.shift());return i}for(var c=e;n.length;){var g=n.shift(),o=n.shift();try{c=g(c)}catch(h){o(h);break}}try{i=nt(c)}catch(h){return Promise.reject(h)}for(;a.length;)i=i.then(a.shift(),a.shift());return i};Y.prototype.getUri=function(e){return e=ve(this.defaults,e),Sa(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};rt.forEach(["delete","get","head","options"],function(e){Y.prototype[e]=function(r,n){return this.request(ve(n||{},{method:e,url:r,data:(n||{}).data}))}});rt.forEach(["post","put","patch"],function(e){Y.prototype[e]=function(r,n,s){return this.request(ve(s||{},{method:e,url:r,data:n}))}});var Ea=Y;function Qe(t){this.message=t}Qe.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Qe.prototype.__CANCEL__=!0;var at=Qe,$a=at;function ye(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;t(function(s){r.reason||(r.reason=new $a(s),e(r.reason))})}ye.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};ye.source=function(){var e,r=new ye(function(s){e=s});return{token:r,cancel:e}};var Ca=ye,Aa=function(e){return function(n){return e.apply(null,n)}},Ta=function(e){return typeof e=="object"&&e.isAxiosError===!0},it=P,Oa=Dr,ge=Ea,xa=Qr,Ra=We;function ot(t){var e=new ge(t),r=Oa(ge.prototype.request,e);return it.extend(r,ge.prototype,e),it.extend(r,e),r}var F=ot(Ra);F.Axios=ge;F.create=function(e){return ot(xa(F.defaults,e))};F.Cancel=at;F.CancelToken=Ca;F.isCancel=Kr;F.all=function(e){return Promise.all(e)};F.spread=Aa;F.isAxiosError=Ta;_e.exports=F;_e.exports.default=F;var Na=_e.exports;class ka{constructor({url:e}){this.url=e,this.httpClient=Na.create({baseURL:this.url})}async upload(e){try{return{fileMetadata:(await this.httpClient.post("/files",e.file,{headers:R(R({},this.generateUploadHeaders(e)),this.generateAuthHeaders())})).data,error:null}}catch(r){return{fileMetadata:null,error:r}}}async getPresignedUrl(e){try{const{fileId:r}=e;return{presignedUrl:(await this.httpClient.get(`/files/${r}/presignedurl`,{headers:R({},this.generateAuthHeaders())})).data,error:null}}catch(r){return{presignedUrl:null,error:r}}}async delete(e){try{const{fileId:r}=e;return await this.httpClient.delete(`/files/${r}`,{headers:R({},this.generateAuthHeaders())}),{error:null}}catch(r){return{error:r}}}setAccessToken(e){this.accessToken=e}generateUploadHeaders(e){const{bucketId:r,name:n,id:s}=e,a={};return r&&(a["x-nhost-bucket-id"]=r),s&&(a["x-nhost-file-id"]=s),n&&(a["x-nhost-file-name"]=n),a}generateAuthHeaders(){return this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:null}}class Ua{constructor({url:e}){this.url=e,this.api=new ka({url:e})}async upload(e){const r=new FormData;r.append("file",e.file);const{fileMetadata:n,error:s}=await this.api.upload(ee(R({},e),{file:r}));return s?{fileMetadata:null,error:s}:n?{fileMetadata:n,error:null}:{fileMetadata:null,error:new Error("Invalid file returned")}}getUrl(e){const{fileId:r}=e;return`${this.url}/files/${r}`}async getPresignedUrl(e){const{presignedUrl:r,error:n}=await this.api.getPresignedUrl(e);return n?{presignedUrl:null,error:n}:r?{presignedUrl:r,error:null}:{presignedUrl:null,error:new Error("Invalid file id")}}async delete(e){const{error:r}=await this.api.delete(e);return r?{error:r}:{error:null}}setAccessToken(e){this.api.setAccessToken(e)}}var Ye={exports:{}},ut=function(e,r){return function(){for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];return e.apply(r,s)}},Pa=ut,H=Object.prototype.toString;function Ze(t){return H.call(t)==="[object Array]"}function er(t){return typeof t=="undefined"}function Ia(t){return t!==null&&!er(t)&&t.constructor!==null&&!er(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function ja(t){return H.call(t)==="[object ArrayBuffer]"}function Fa(t){return typeof FormData!="undefined"&&t instanceof FormData}function La(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function Da(t){return typeof t=="string"}function Ba(t){return typeof t=="number"}function ct(t){return t!==null&&typeof t=="object"}function we(t){if(H.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function _a(t){return H.call(t)==="[object Date]"}function qa(t){return H.call(t)==="[object File]"}function Ha(t){return H.call(t)==="[object Blob]"}function lt(t){return H.call(t)==="[object Function]"}function Ma(t){return ct(t)&&lt(t.pipe)}function Ja(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function za(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Va(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function rr(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Ze(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}function tr(){var t={};function e(s,a){we(t[a])&&we(s)?t[a]=tr(t[a],s):we(s)?t[a]=tr({},s):Ze(s)?t[a]=s.slice():t[a]=s}for(var r=0,n=arguments.length;r<n;r++)rr(arguments[r],e);return t}function Wa(t,e,r){return rr(e,function(s,a){r&&typeof s=="function"?t[a]=Pa(s,r):t[a]=s}),t}function Xa(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var I={isArray:Ze,isArrayBuffer:ja,isBuffer:Ia,isFormData:Fa,isArrayBufferView:La,isString:Da,isNumber:Ba,isObject:ct,isPlainObject:we,isUndefined:er,isDate:_a,isFile:qa,isBlob:Ha,isFunction:lt,isStream:Ma,isURLSearchParams:Ja,isStandardBrowserEnv:Va,forEach:rr,merge:tr,extend:Wa,trim:za,stripBOM:Xa},X=I;function ft(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var dt=function(e,r,n){if(!r)return e;var s;if(n)s=n(r);else if(X.isURLSearchParams(r))s=r.toString();else{var a=[];X.forEach(r,function(c,g){c===null||typeof c=="undefined"||(X.isArray(c)?g=g+"[]":c=[c],X.forEach(c,function(h){X.isDate(h)?h=h.toISOString():X.isObject(h)&&(h=JSON.stringify(h)),a.push(ft(g)+"="+ft(h))}))}),s=a.join("&")}if(s){var i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e},Ka=I;function be(){this.handlers=[]}be.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};be.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};be.prototype.forEach=function(e){Ka.forEach(this.handlers,function(n){n!==null&&e(n)})};var Ga=be,Qa=I,Ya=function(e,r){Qa.forEach(e,function(s,a){a!==r&&a.toUpperCase()===r.toUpperCase()&&(e[r]=s,delete e[a])})},ht=function(e,r,n,s,a){return e.config=r,n&&(e.code=n),e.request=s,e.response=a,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e},Za=ht,pt=function(e,r,n,s,a){var i=new Error(e);return Za(i,r,n,s,a)},ei=pt,ri=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(ei("Request failed with status code "+n.status,n.config,null,n.request,n))},Se=I,ti=Se.isStandardBrowserEnv()?function(){return{write:function(r,n,s,a,i,u){var c=[];c.push(r+"="+encodeURIComponent(n)),Se.isNumber(s)&&c.push("expires="+new Date(s).toGMTString()),Se.isString(a)&&c.push("path="+a),Se.isString(i)&&c.push("domain="+i),u===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),ni=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},si=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},ai=ni,ii=si,oi=function(e,r){return e&&!ai(r)?ii(e,r):r},nr=I,ui=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],ci=function(e){var r={},n,s,a;return e&&nr.forEach(e.split(`
4
- `),function(u){if(a=u.indexOf(":"),n=nr.trim(u.substr(0,a)).toLowerCase(),s=nr.trim(u.substr(a+1)),n){if(r[n]&&ui.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r},mt=I,li=mt.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(a){var i=a;return e&&(r.setAttribute("href",i),i=r.href),r.setAttribute("href",i),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(i){var u=mt.isString(i)?s(i):i;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}();function sr(t){this.message=t}sr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};sr.prototype.__CANCEL__=!0;var Ee=sr,$e=I,fi=ri,di=ti,hi=dt,pi=oi,mi=ci,vi=li,ar=pt,yi=Ae,gi=Ee,vt=function(e){return new Promise(function(n,s){var a=e.data,i=e.headers,u=e.responseType,c;function g(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}$e.isFormData(a)&&delete i["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",y=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(h+":"+y)}var v=pi(e.baseURL,e.url);o.open(e.method.toUpperCase(),hi(v,e.params,e.paramsSerializer),!0),o.timeout=e.timeout;function x(){if(!!o){var b="getAllResponseHeaders"in o?mi(o.getAllResponseHeaders()):null,T=!u||u==="text"||u==="json"?o.responseText:o.response,l={data:T,status:o.status,statusText:o.statusText,headers:b,config:e,request:o};fi(function(d){n(d),g()},function(d){s(d),g()},l),o=null}}if("onloadend"in o?o.onloadend=x:o.onreadystatechange=function(){!o||o.readyState!==4||o.status===0&&!(o.responseURL&&o.responseURL.indexOf("file:")===0)||setTimeout(x)},o.onabort=function(){!o||(s(ar("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){s(ar("Network Error",e,null,o)),o=null},o.ontimeout=function(){var T=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",l=e.transitional||yi.transitional;e.timeoutErrorMessage&&(T=e.timeoutErrorMessage),s(ar(T,e,l.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},$e.isStandardBrowserEnv()){var E=(e.withCredentials||vi(v))&&e.xsrfCookieName?di.read(e.xsrfCookieName):void 0;E&&(i[e.xsrfHeaderName]=E)}"setRequestHeader"in o&&$e.forEach(i,function(T,l){typeof a=="undefined"&&l.toLowerCase()==="content-type"?delete i[l]:o.setRequestHeader(l,T)}),$e.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),u&&u!=="json"&&(o.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&o.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(c=function(b){!o||(s(!b||b&&b.type?new gi("canceled"):b),o.abort(),o=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),a||(a=null),o.send(a)})},A=I,yt=Ya,wi=ht,bi={"Content-Type":"application/x-www-form-urlencoded"};function gt(t,e){!A.isUndefined(t)&&A.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Si(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=vt),t}function Ei(t,e,r){if(A.isString(t))try{return(e||JSON.parse)(t),A.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Ce={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Si(),transformRequest:[function(e,r){return yt(r,"Accept"),yt(r,"Content-Type"),A.isFormData(e)||A.isArrayBuffer(e)||A.isBuffer(e)||A.isStream(e)||A.isFile(e)||A.isBlob(e)?e:A.isArrayBufferView(e)?e.buffer:A.isURLSearchParams(e)?(gt(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):A.isObject(e)||r&&r["Content-Type"]==="application/json"?(gt(r,"application/json"),Ei(e)):e}],transformResponse:[function(e){var r=this.transitional||Ce.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,a=!n&&this.responseType==="json";if(a||s&&A.isString(e)&&e.length)try{return JSON.parse(e)}catch(i){if(a)throw i.name==="SyntaxError"?wi(i,this,"E_JSON_PARSE"):i}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};A.forEach(["delete","get","head"],function(e){Ce.headers[e]={}});A.forEach(["post","put","patch"],function(e){Ce.headers[e]=A.merge(bi)});var Ae=Ce,$i=I,Ci=Ae,Ai=function(e,r,n){var s=this||Ci;return $i.forEach(n,function(i){e=i.call(s,e,r)}),e},wt=function(e){return!!(e&&e.__CANCEL__)},bt=I,ir=Ai,Ti=wt,Oi=Ae,xi=Ee;function or(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new xi("canceled")}var Ri=function(e){or(e),e.headers=e.headers||{},e.data=ir.call(e,e.data,e.headers,e.transformRequest),e.headers=bt.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),bt.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||Oi.adapter;return r(e).then(function(s){return or(e),s.data=ir.call(e,s.data,s.headers,e.transformResponse),s},function(s){return Ti(s)||(or(e),s&&s.response&&(s.response.data=ir.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})},j=I,St=function(e,r){r=r||{};var n={};function s(o,h){return j.isPlainObject(o)&&j.isPlainObject(h)?j.merge(o,h):j.isPlainObject(h)?j.merge({},h):j.isArray(h)?h.slice():h}function a(o){if(j.isUndefined(r[o])){if(!j.isUndefined(e[o]))return s(void 0,e[o])}else return s(e[o],r[o])}function i(o){if(!j.isUndefined(r[o]))return s(void 0,r[o])}function u(o){if(j.isUndefined(r[o])){if(!j.isUndefined(e[o]))return s(void 0,e[o])}else return s(void 0,r[o])}function c(o){if(o in r)return s(e[o],r[o]);if(o in e)return s(void 0,e[o])}var g={url:i,method:i,data:i,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:c};return j.forEach(Object.keys(e).concat(Object.keys(r)),function(h){var y=g[h]||a,v=y(h);j.isUndefined(v)&&y!==c||(n[h]=v)}),n},Et={version:"0.23.0"},Ni=Et.version,ur={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){ur[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var $t={};ur.transitional=function(e,r,n){function s(a,i){return"[Axios v"+Ni+"] Transitional option '"+a+"'"+i+(n?". "+n:"")}return function(a,i,u){if(e===!1)throw new Error(s(i," has been removed"+(r?" in "+r:"")));return r&&!$t[i]&&($t[i]=!0,console.warn(s(i," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,i,u):!0}};function ki(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var a=n[s],i=e[a];if(i){var u=t[a],c=u===void 0||i(u,a,t);if(c!==!0)throw new TypeError("option "+a+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+a)}}var Ui={assertOptions:ki,validators:ur},Ct=I,Pi=dt,At=Ga,Tt=Ri,Te=St,Ot=Ui,K=Ot.validators;function Z(t){this.defaults=t,this.interceptors={request:new At,response:new At}}Z.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Te(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&Ot.assertOptions(r,{silentJSONParsing:K.transitional(K.boolean),forcedJSONParsing:K.transitional(K.boolean),clarifyTimeoutError:K.transitional(K.boolean)},!1);var n=[],s=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(e)===!1||(s=s&&y.synchronous,n.unshift(y.fulfilled,y.rejected))});var a=[];this.interceptors.response.forEach(function(y){a.push(y.fulfilled,y.rejected)});var i;if(!s){var u=[Tt,void 0];for(Array.prototype.unshift.apply(u,n),u=u.concat(a),i=Promise.resolve(e);u.length;)i=i.then(u.shift(),u.shift());return i}for(var c=e;n.length;){var g=n.shift(),o=n.shift();try{c=g(c)}catch(h){o(h);break}}try{i=Tt(c)}catch(h){return Promise.reject(h)}for(;a.length;)i=i.then(a.shift(),a.shift());return i};Z.prototype.getUri=function(e){return e=Te(this.defaults,e),Pi(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Ct.forEach(["delete","get","head","options"],function(e){Z.prototype[e]=function(r,n){return this.request(Te(n||{},{method:e,url:r,data:(n||{}).data}))}});Ct.forEach(["post","put","patch"],function(e){Z.prototype[e]=function(r,n,s){return this.request(Te(s||{},{method:e,url:r,data:n}))}});var Ii=Z,ji=Ee;function G(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;this.promise.then(function(n){if(!!r._listeners){var s,a=r._listeners.length;for(s=0;s<a;s++)r._listeners[s](n);r._listeners=null}}),this.promise.then=function(n){var s,a=new Promise(function(i){r.subscribe(i),s=i}).then(n);return a.cancel=function(){r.unsubscribe(s)},a},t(function(s){r.reason||(r.reason=new ji(s),e(r.reason))})}G.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};G.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};G.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};G.source=function(){var e,r=new G(function(s){e=s});return{token:r,cancel:e}};var Fi=G,Li=function(e){return function(n){return e.apply(null,n)}},Di=function(e){return typeof e=="object"&&e.isAxiosError===!0},xt=I,Bi=ut,Oe=Ii,_i=St,qi=Ae;function Rt(t){var e=new Oe(t),r=Bi(Oe.prototype.request,e);return xt.extend(r,Oe.prototype,e),xt.extend(r,e),r.create=function(s){return Rt(_i(t,s))},r}var D=Rt(qi);D.Axios=Oe;D.Cancel=Ee;D.CancelToken=Fi;D.isCancel=wt;D.VERSION=Et.version;D.all=function(e){return Promise.all(e)};D.spread=Li;D.isAxiosError=Di;Ye.exports=D;Ye.exports.default=D;var Nt=Ye.exports;class Hi{constructor(e){const{url:r}=e;this.accessToken=null,this.instance=Nt.create({baseURL:r})}async call(e,r,n){const s=R(R({},this.generateAccessTokenHeaders()),n==null?void 0:n.headers);let a;try{a=await this.instance.post(e,r,ee(R({},n),{headers:s}))}catch(i){if(i instanceof Error)return{res:null,error:i}}return a?{res:a,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}}class Mi{constructor(e){const{url:r}=e;this.url=r,this.accessToken=null,this.instance=Nt.create({baseURL:r})}async request(e,r,n){const s=R(R({},n==null?void 0:n.headers),this.generateAccessTokenHeaders()),a="";let i;try{i=(await this.instance.post("",{operationName:a||void 0,query:e,variables:r},ee(R({},n),{headers:s}))).data}catch(u){return u instanceof Error?{data:null,error:u}:(console.error(u),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof i!="object"||Array.isArray(i)||i===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(i=i,i.errors?{data:null,error:i.errors}:{data:i.data,error:null})}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}}class kt{constructor(e){if(!e.backendUrl)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");const{backendUrl:r,refreshIntervalTime:n,clientStorage:s,clientStorageType:a,autoRefreshToken:i,autoLogin:u}=e;this.auth=new ss({url:`${r}/v1/auth`,refreshIntervalTime:n,clientStorage:s,clientStorageType:a,autoRefreshToken:i,autoLogin:u}),this.storage=new Ua({url:`${r}/v1/storage`}),this.functions=new Hi({url:`${r}/v1/functions`}),this.graphql=new Mi({url:`${r}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.onAuthStateChanged((c,g)=>{this.storage.setAccessToken(g==null?void 0:g.accessToken),this.functions.setAccessToken(g==null?void 0:g.accessToken),this.graphql.setAccessToken(g==null?void 0:g.accessToken)}),this.auth.onTokenChanged(c=>{this.storage.setAccessToken(c==null?void 0:c.accessToken),this.functions.setAccessToken(c==null?void 0:c.accessToken),this.graphql.setAccessToken(c==null?void 0:c.accessToken)})}}const Ji=t=>new kt(t);exports.NhostClient=kt;exports.createClient=Ji;
1
+ var N=Object.create;var h=Object.defineProperty,b=Object.defineProperties,w=Object.getOwnPropertyDescriptor,P=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,G=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var m=(t,e,r)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,i=(t,e)=>{for(var r in e||(e={}))A.call(e,r)&&m(t,r,e[r]);if(f)for(var r of f(e))U.call(e,r)&&m(t,r,e[r]);return t},p=(t,e)=>b(t,P(e)),C=t=>h(t,"__esModule",{value:!0});var H=(t,e)=>{for(var r in e)h(t,r,{get:e[r],enumerable:!0})},d=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of S(e))!A.call(t,a)&&(r||a!=="default")&&h(t,a,{get:()=>e[a],enumerable:!(n=w(e,a))||n.enumerable});return t},q=(t,e)=>d(C(h(t!=null?N(G(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),E=(t=>(e,r)=>t&&t.get(e)||(r=d(C({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var I={};H(I,{NhostClient:()=>T,createClient:()=>F});var v=require("@nhost/hasura-auth-js"),y=require("@nhost/hasura-storage-js");var x=q(require("axios")),k=class{constructor(e){let{url:r}=e;this.accessToken=null,this.instance=x.default.create({baseURL:r})}async call(e,r,n){let a=i(i({},this.generateAccessTokenHeaders()),n==null?void 0:n.headers),u;try{u=await this.instance.post(e,r,p(i({},n),{headers:a}))}catch(s){if(s instanceof Error)return{res:null,error:s}}return u?{res:u,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var R=q(require("axios")),g=class{constructor(e){let{url:r}=e;this.url=r,this.accessToken=null,this.instance=R.default.create({baseURL:r})}async request(e,r,n){let a=i(i({},n==null?void 0:n.headers),this.generateAccessTokenHeaders()),u="",s;try{s=(await this.instance.post("",{operationName:u||void 0,query:e,variables:r},p(i({},n),{headers:a}))).data}catch(l){return l instanceof Error?{data:null,error:l}:(console.error(l),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof s!="object"||Array.isArray(s)||s===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(s=s,s.errors?{data:null,error:s.errors}:{data:s.data,error:null})}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var T=class{constructor(e){if(!e.backendUrl)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");let{backendUrl:r,refreshIntervalTime:n,clientStorage:a,clientStorageType:u,autoRefreshToken:s,autoLogin:l}=e;this.auth=new v.HasuraAuthClient({url:`${r}/v1/auth`,refreshIntervalTime:n,clientStorage:a,clientStorageType:u,autoRefreshToken:s,autoLogin:l}),this.storage=new y.HasuraStorageClient({url:`${r}/v1/storage`}),this.functions=new k({url:`${r}/v1/functions`}),this.graphql=new g({url:`${r}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.onAuthStateChanged((o,c)=>{this.storage.setAccessToken(c==null?void 0:c.accessToken),this.functions.setAccessToken(c==null?void 0:c.accessToken),this.graphql.setAccessToken(c==null?void 0:c.accessToken)}),this.auth.onTokenChanged(o=>{this.storage.setAccessToken(o==null?void 0:o.accessToken),this.functions.setAccessToken(o==null?void 0:o.accessToken),this.graphql.setAccessToken(o==null?void 0:o.accessToken)})}};var F=t=>new T(t);module.exports=E(I);0&&(module.exports={NhostClient,createClient});
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/core/nhost-client.ts", "../src/clients/functions.ts", "../src/clients/graphql.ts"],
4
+ "sourcesContent": ["import { NhostClient, NhostClientConstructorParams } from './core'\n\nconst createClient = (config: NhostClientConstructorParams) => new NhostClient(config)\n\nexport * from './core'\nexport { createClient }\n", "import { ClientStorage, ClientStorageType, HasuraAuthClient } from '@nhost/hasura-auth-js'\nimport { HasuraStorageClient } from '@nhost/hasura-storage-js'\n\nimport { NhostFunctionsClient } from '../clients/functions'\nimport { NhostGraphqlClient } from '../clients/graphql'\n\nexport interface NhostClientConstructorParams {\n backendUrl: string\n refreshIntervalTime?: number\n clientStorage?: ClientStorage\n clientStorageType?: ClientStorageType\n autoRefreshToken?: boolean\n autoLogin?: boolean\n}\n\nexport class NhostClient {\n auth: HasuraAuthClient\n storage: HasuraStorageClient\n functions: NhostFunctionsClient\n graphql: NhostGraphqlClient\n\n /**\n * Nhost Client\n *\n * @example\n * const nhost = new NhostClient({ url });\n *\n * @docs https://docs.nhost.io/TODO\n */\n constructor(params: NhostClientConstructorParams) {\n if (!params.backendUrl) throw new Error('Please specify a `backendUrl`. Docs: [todo]!')\n\n const {\n backendUrl,\n refreshIntervalTime,\n clientStorage,\n clientStorageType,\n autoRefreshToken,\n autoLogin\n } = params\n\n this.auth = new HasuraAuthClient({\n url: `${backendUrl}/v1/auth`,\n refreshIntervalTime,\n clientStorage,\n clientStorageType,\n autoRefreshToken,\n autoLogin\n })\n\n this.storage = new HasuraStorageClient({\n url: `${backendUrl}/v1/storage`\n })\n\n this.functions = new NhostFunctionsClient({\n url: `${backendUrl}/v1/functions`\n })\n\n this.graphql = new NhostGraphqlClient({\n url: `${backendUrl}/v1/graphql`\n })\n\n // set current token if token is already accessable\n this.storage.setAccessToken(this.auth.getAccessToken())\n this.functions.setAccessToken(this.auth.getAccessToken())\n this.graphql.setAccessToken(this.auth.getAccessToken())\n\n // update access token for clients\n this.auth.onAuthStateChanged((_event, session) => {\n this.storage.setAccessToken(session?.accessToken)\n this.functions.setAccessToken(session?.accessToken)\n this.graphql.setAccessToken(session?.accessToken)\n })\n\n // update access token for clients\n this.auth.onTokenChanged((session) => {\n this.storage.setAccessToken(session?.accessToken)\n this.functions.setAccessToken(session?.accessToken)\n this.graphql.setAccessToken(session?.accessToken)\n })\n }\n}\n", "import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'\n\nimport { FunctionCallResponse } from '../types'\nexport interface NhostFunctionsConstructorParams {\n url: string\n}\n\nexport class NhostFunctionsClient {\n private instance: AxiosInstance\n private accessToken: string | null\n\n constructor(params: NhostFunctionsConstructorParams) {\n const { url } = params\n\n this.accessToken = null\n this.instance = axios.create({\n baseURL: url\n })\n }\n\n async call(url: string, data: any, config?: AxiosRequestConfig): Promise<FunctionCallResponse> {\n const headers = {\n ...this.generateAccessTokenHeaders(),\n ...config?.headers\n }\n\n let res\n try {\n res = await this.instance.post(url, data, { ...config, headers })\n } catch (error) {\n if (error instanceof Error) {\n return { res: null, error }\n }\n }\n\n if (!res) {\n return {\n res: null,\n error: new Error('Unable to make post request to funtion')\n }\n }\n\n return { res, error: null }\n }\n\n setAccessToken(accessToken: string | undefined) {\n if (!accessToken) {\n this.accessToken = null\n return\n }\n\n this.accessToken = accessToken\n }\n\n private generateAccessTokenHeaders(): { Authorization: string } | undefined {\n if (!this.accessToken) {\n return\n }\n\n // eslint-disable-next-line consistent-return\n return {\n Authorization: `Bearer ${this.accessToken}`\n }\n }\n}\n", "import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'\n\nimport { GraphqlRequestResponse, GraphqlResponse } from '../types'\n\nexport interface NhostGraphqlConstructorParams {\n url: string\n}\n\nexport class NhostGraphqlClient {\n private url: string\n private instance: AxiosInstance\n private accessToken: string | null\n\n constructor(params: NhostGraphqlConstructorParams) {\n const { url } = params\n\n this.url = url\n this.accessToken = null\n this.instance = axios.create({\n baseURL: url\n })\n }\n\n async request(\n document: string,\n variables?: any,\n config?: AxiosRequestConfig\n ): Promise<GraphqlRequestResponse> {\n // add auth headers if any\n const headers = {\n ...config?.headers,\n ...this.generateAccessTokenHeaders()\n }\n\n const operationName = ''\n\n let responseData\n try {\n const res = await this.instance.post(\n '',\n {\n operationName: operationName || undefined,\n query: document,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n variables\n },\n { ...config, headers }\n )\n\n responseData = res.data\n } catch (error) {\n if (error instanceof Error) {\n return { data: null, error }\n }\n console.error(error)\n return {\n data: null,\n error: new Error('Unable to get do GraphQL request')\n }\n }\n\n if (typeof responseData !== 'object' || Array.isArray(responseData) || responseData === null) {\n return {\n data: null,\n error: new Error('incorrect response data from GraphQL server')\n }\n }\n\n responseData = responseData as GraphqlResponse\n\n if (responseData.errors) {\n return {\n data: null,\n error: responseData.errors\n }\n }\n\n return { data: responseData.data, error: null }\n }\n\n getUrl(): string {\n return this.url\n }\n\n setAccessToken(accessToken: string | undefined) {\n if (!accessToken) {\n this.accessToken = null\n return\n }\n\n this.accessToken = accessToken\n }\n\n private generateAccessTokenHeaders() {\n if (!this.accessToken) {\n return\n }\n\n // eslint-disable-next-line consistent-return\n return {\n Authorization: `Bearer ${this.accessToken}`\n }\n }\n}\n"],
5
+ "mappings": "wgCAAA,qDCAA,MAAmE,iCACnE,EAAoC,oCCDpC,MAAyD,oBAOlD,OAA2B,CAIhC,YAAY,EAAyC,CACnD,GAAM,CAAE,OAAQ,EAEhB,KAAK,YAAc,KACnB,KAAK,SAAW,UAAM,OAAO,CAC3B,QAAS,SAIP,MAAK,EAAa,EAAW,EAA4D,CAC7F,GAAM,GAAU,OACX,KAAK,8BACL,iBAAQ,SAGT,EACJ,GAAI,CACF,EAAM,KAAM,MAAK,SAAS,KAAK,EAAK,EAAM,OAAK,GAAL,CAAa,mBAChD,EAAP,CACA,GAAI,YAAiB,OACnB,MAAO,CAAE,IAAK,KAAM,SAIxB,MAAK,GAOE,CAAE,MAAK,MAAO,MANZ,CACL,IAAK,KACL,MAAO,GAAI,OAAM,2CAOvB,eAAe,EAAiC,CAC9C,GAAI,CAAC,EAAa,CAChB,KAAK,YAAc,KACnB,OAGF,KAAK,YAAc,EAGb,4BAAoE,CAC1E,GAAI,EAAC,KAAK,YAKV,MAAO,CACL,cAAe,UAAU,KAAK,iBC7DpC,MAAyD,oBAQlD,OAAyB,CAK9B,YAAY,EAAuC,CACjD,GAAM,CAAE,OAAQ,EAEhB,KAAK,IAAM,EACX,KAAK,YAAc,KACnB,KAAK,SAAW,UAAM,OAAO,CAC3B,QAAS,SAIP,SACJ,EACA,EACA,EACiC,CAEjC,GAAM,GAAU,OACX,iBAAQ,SACR,KAAK,8BAGJ,EAAgB,GAElB,EACJ,GAAI,CAYF,EAAe,AAXH,MAAM,MAAK,SAAS,KAC9B,GACA,CACE,cAAe,GAAiB,OAChC,MAAO,EAEP,aAEF,OAAK,GAAL,CAAa,cAGI,WACZ,EAAP,CACA,MAAI,aAAiB,OACZ,CAAE,KAAM,KAAM,SAEvB,SAAQ,MAAM,GACP,CACL,KAAM,KACN,MAAO,GAAI,OAAM,sCAIrB,MAAI,OAAO,IAAiB,UAAY,MAAM,QAAQ,IAAiB,IAAiB,KAC/E,CACL,KAAM,KACN,MAAO,GAAI,OAAM,gDAIrB,GAAe,EAEX,EAAa,OACR,CACL,KAAM,KACN,MAAO,EAAa,QAIjB,CAAE,KAAM,EAAa,KAAM,MAAO,OAG3C,QAAiB,CACf,MAAO,MAAK,IAGd,eAAe,EAAiC,CAC9C,GAAI,CAAC,EAAa,CAChB,KAAK,YAAc,KACnB,OAGF,KAAK,YAAc,EAGb,4BAA6B,CACnC,GAAI,EAAC,KAAK,YAKV,MAAO,CACL,cAAe,UAAU,KAAK,iBFrF7B,WAAkB,CAcvB,YAAY,EAAsC,CAChD,GAAI,CAAC,EAAO,WAAY,KAAM,IAAI,OAAM,gDAExC,GAAM,CACJ,aACA,sBACA,gBACA,oBACA,mBACA,aACE,EAEJ,KAAK,KAAO,GAAI,oBAAiB,CAC/B,IAAK,GAAG,YACR,sBACA,gBACA,oBACA,mBACA,cAGF,KAAK,QAAU,GAAI,uBAAoB,CACrC,IAAK,GAAG,iBAGV,KAAK,UAAY,GAAI,GAAqB,CACxC,IAAK,GAAG,mBAGV,KAAK,QAAU,GAAI,GAAmB,CACpC,IAAK,GAAG,iBAIV,KAAK,QAAQ,eAAe,KAAK,KAAK,kBACtC,KAAK,UAAU,eAAe,KAAK,KAAK,kBACxC,KAAK,QAAQ,eAAe,KAAK,KAAK,kBAGtC,KAAK,KAAK,mBAAmB,CAAC,EAAQ,IAAY,CAChD,KAAK,QAAQ,eAAe,iBAAS,aACrC,KAAK,UAAU,eAAe,iBAAS,aACvC,KAAK,QAAQ,eAAe,iBAAS,eAIvC,KAAK,KAAK,eAAe,AAAC,GAAY,CACpC,KAAK,QAAQ,eAAe,iBAAS,aACrC,KAAK,UAAU,eAAe,iBAAS,aACvC,KAAK,QAAQ,eAAe,iBAAS,iBD5E3C,GAAM,GAAe,AAAC,GAAyC,GAAI,GAAY",
6
+ "names": []
7
+ }