@directus/sdk
Advanced tools
Comparing version 9.0.0-rc.71 to 9.0.0-rc.72
@@ -43,3 +43,3 @@ "use strict"; | ||
request(method, path, data, options) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -51,2 +51,3 @@ try { | ||
options.headers = (_c = options.headers) !== null && _c !== void 0 ? _c : {}; | ||
options.onUploadProgress = (_d = options.onUploadProgress) !== null && _d !== void 0 ? _d : undefined; | ||
if (options.refreshTokenIfNeeded) { | ||
@@ -61,2 +62,3 @@ yield this._refresh(); | ||
headers: options.headers, | ||
onUploadProgress: options.onUploadProgress, | ||
}; | ||
@@ -93,8 +95,8 @@ const token = this._storage.auth_token; | ||
if (axios_1.default.isAxiosError(err)) { | ||
const data = (_d = err.response) === null || _d === void 0 ? void 0 : _d.data; | ||
const data = (_e = err.response) === null || _e === void 0 ? void 0 : _e.data; | ||
throw new transport_1.TransportError(err, { | ||
raw: (_e = err.response) === null || _e === void 0 ? void 0 : _e.data, | ||
status: (_f = err.response) === null || _f === void 0 ? void 0 : _f.status, | ||
statusText: (_g = err.response) === null || _g === void 0 ? void 0 : _g.statusText, | ||
headers: (_h = err.response) === null || _h === void 0 ? void 0 : _h.headers, | ||
raw: (_f = err.response) === null || _f === void 0 ? void 0 : _f.data, | ||
status: (_g = err.response) === null || _g === void 0 ? void 0 : _g.status, | ||
statusText: (_h = err.response) === null || _h === void 0 ? void 0 : _h.statusText, | ||
headers: (_j = err.response) === null || _j === void 0 ? void 0 : _j.headers, | ||
data: data === null || data === void 0 ? void 0 : data.data, | ||
@@ -101,0 +103,0 @@ meta: data === null || data === void 0 ? void 0 : data.meta, |
@@ -15,3 +15,3 @@ /*! ***************************************************************************** | ||
***************************************************************************** */ | ||
function t(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}class e{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(e)}`,{params:r})).data}))}readMany(e){return t(this,void 0,void 0,(function*(){const{data:t,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:e});return{data:t,meta:r}}))}createOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,e,{params:r})).data}))}createMany(e,r){return t(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,e,{params:r})}))}updateOne(e,r,s){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(e)}`,r,{params:s})).data}))}updateMany(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:e,data:r},{params:s})}))}deleteOne(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(e)}`)}))}deleteMany(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,e)}))}}class r{constructor(t){this.transport=t}create(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",e)).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(e)}`,{comment:r})).data}))}delete(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(e)}`)}))}}class s extends e{constructor(t){super("directus_activity",t),this._comments=new r(this.transport)}get comments(){return this._comments}}class n extends e{constructor(t){super("directus_collections",t)}}class i extends e{constructor(t){super("directus_fields",t)}}class o extends e{constructor(t){super("directus_files",t)}}class a extends e{constructor(t){super("directus_folders",t)}}class u extends e{constructor(t){super("directus_permissions",t)}}class h extends e{constructor(t){super("directus_presets",t)}}class c extends e{constructor(t){super("directus_relations",t)}}class d extends e{constructor(t){super("directus_revisions",t)}}class l extends e{constructor(t){super("directus_roles",t)}}class p{constructor(t){this.transport=t}ping(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class f extends e{constructor(t){super("directus_settings",t)}}class v{constructor(t){this.transport=t}send(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:e,role:r})}))}accept(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:e,password:r})}))}}class m{constructor(t){this.transport=t}enable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:e})}))}disable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:e})}))}}class g{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new m(this._transport))}read(e){return t(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",e,{params:r})).data}))}}class y extends e{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new v(this.transport))}get me(){return this._me||(this._me=new g(this.transport))}}class _{constructor(e){this.random={string:(e=32)=>t(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:e}})).data}))},this.hash={generate:e=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:e})).data})),verify:(e,r)=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:e,hash:r})).data}))},this.transport=e}sort(e,r,s){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(e)}`,{item:r,to:s})}))}revert(e){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(e)}`)}))}}var w;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(w||(w={}));class x extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,x.prototype)}}class b{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class k extends b{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends b{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var R={exports:{}},T=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=T,O=Object.prototype.toString;function S(t){return"[object Array]"===O.call(t)}function A(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function q(t){if("[object Object]"!==O.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function U(t){return"[object Function]"===O.call(t)}function N(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),S(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var B={isArray:S,isArrayBuffer:function(t){return"[object ArrayBuffer]"===O.call(t)},isBuffer:function(t){return null!==t&&!A(t)&&null!==t.constructor&&!A(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:C,isPlainObject:q,isUndefined:A,isDate:function(t){return"[object Date]"===O.call(t)},isFile:function(t){return"[object File]"===O.call(t)},isBlob:function(t){return"[object Blob]"===O.call(t)},isFunction:U,isStream:function(t){return C(t)&&U(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:N,merge:function t(){var e={};function r(r,s){q(e[s])&&q(r)?e[s]=t(e[s],r):q(r)?e[s]=t({},r):S(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)N(arguments[s],r);return e},extend:function(t,e,r){return N(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},P=B;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(P.isURLSearchParams(e))s=e.toString();else{var n=[];P.forEach(e,(function(t,e){null!=t&&(P.isArray(t)?e+="[]":t=[t],P.forEach(t,(function(t){P.isDate(t)?t=t.toISOString():P.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=B;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var z=D,F=B,H=function(t){return!(!t||!t.__CANCEL__)},M=B,X=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},J=function(t,e,r,s,n){var i=new Error(t);return X(i,e,r,s,n)},V=J,K=B,W=K.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),K.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),K.isString(s)&&o.push("path="+s),K.isString(n)&&o.push("domain="+n),!0===i&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},G=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Q=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Y=B,Z=["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"],tt=B,et=tt.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=tt.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},rt=B,st=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(V("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},nt=W,it=L,ot=function(t,e){return t&&!G(e)?Q(t,e):e},at=function(t){var e,r,s,n={};return t?(Y.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Y.trim(t.substr(0,s)).toLowerCase(),r=Y.trim(t.substr(s+1)),e){if(n[e]&&Z.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ut=et,ht=J,ct=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;rt.isFormData(s)&&delete n["Content-Type"];var i=new XMLHttpRequest;if(t.auth){var o=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(o+":"+a)}var u=ot(t.baseURL,t.url);if(i.open(t.method.toUpperCase(),it(u,t.params,t.paramsSerializer),!0),i.timeout=t.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in i?at(i.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:s,config:t,request:i};st(e,r,n),i=null}},i.onabort=function(){i&&(r(ht("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(ht("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(ht(e,t,"ECONNABORTED",i)),i=null},rt.isStandardBrowserEnv()){var h=(t.withCredentials||ut(u))&&t.xsrfCookieName?nt.read(t.xsrfCookieName):void 0;h&&(n[t.xsrfHeaderName]=h)}if("setRequestHeader"in i&&rt.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),rt.isUndefined(t.withCredentials)||(i.withCredentials=!!t.withCredentials),t.responseType)try{i.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&i.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){i&&(i.abort(),r(t),i=null)})),s||(s=null),i.send(s)}))},dt=B,lt=function(t,e){M.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},pt={"Content-Type":"application/x-www-form-urlencoded"};function ft(t,e){!dt.isUndefined(t)&&dt.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var vt,mt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(vt=ct),vt),transformRequest:[function(t,e){return lt(e,"Accept"),lt(e,"Content-Type"),dt.isFormData(t)||dt.isArrayBuffer(t)||dt.isBuffer(t)||dt.isStream(t)||dt.isFile(t)||dt.isBlob(t)?t:dt.isArrayBufferView(t)?t.buffer:dt.isURLSearchParams(t)?(ft(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):dt.isObject(t)?(ft(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};mt.headers={common:{Accept:"application/json, text/plain, */*"}},dt.forEach(["delete","get","head"],(function(t){mt.headers[t]={}})),dt.forEach(["post","put","patch"],(function(t){mt.headers[t]=dt.merge(pt)}));var gt=mt,yt=B,_t=function(t,e,r){return F.forEach(r,(function(r){t=r(t,e)})),t},wt=H,xt=gt;function bt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var kt=B,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["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"],o=["validateStatus"];function a(t,e){return kt.isPlainObject(t)&&kt.isPlainObject(e)?kt.merge(t,e):kt.isPlainObject(e)?kt.merge({},e):kt.isArray(e)?e.slice():e}function u(s){kt.isUndefined(e[s])?kt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}kt.forEach(s,(function(t){kt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),kt.forEach(n,u),kt.forEach(i,(function(s){kt.isUndefined(e[s])?kt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),kt.forEach(o,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var h=s.concat(n).concat(i).concat(o),c=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return kt.forEach(c,u),r},Rt=B,Tt=L,jt=z,Ot=function(t){return bt(t),t.headers=t.headers||{},t.data=_t(t.data,t.headers,t.transformRequest),t.headers=yt.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),yt.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||xt.adapter)(t).then((function(e){return bt(t),e.data=_t(e.data,e.headers,t.transformResponse),e}),(function(e){return wt(e)||(bt(t),e&&e.response&&(e.response.data=_t(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},St=Et;function At(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}At.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=St(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Ot,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},At.prototype.getUri=function(t){return t=St(this.defaults,t),Tt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Rt.forEach(["delete","get","head","options"],(function(t){At.prototype[t]=function(e,r){return this.request(St(r||{},{method:t,url:e,data:(r||{}).data}))}})),Rt.forEach(["post","put","patch"],(function(t){At.prototype[t]=function(e,r,s){return this.request(St(s||{},{method:t,url:e,data:r}))}}));var Ct=At;function qt(t){this.message=t}qt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},qt.prototype.__CANCEL__=!0;var Ut=qt,Nt=Ut;function Bt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Nt(t),e(r.reason))}))}Bt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Bt.source=function(){var t;return{token:new Bt((function(e){t=e})),cancel:t}};var Pt=Bt,$t=B,Lt=T,It=Ct,Dt=Et;function zt(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var Ft=zt(gt);Ft.Axios=It,Ft.create=function(t){return zt(Dt(Ft.defaults,t))},Ft.Cancel=Ut,Ft.CancelToken=Pt,Ft.isCancel=H,Ft.all=function(t){return Promise.all(t)},Ft.spread=function(t){return function(e){return t.apply(null,e)}},Ft.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},R.exports=Ft,R.exports.default=Ft;var Ht=R.exports;class Mt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=Ht.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(e,r,s,n){var i,o,a,u,h,c,d,l;return t(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const t={method:e,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?t.headers.Authorization=u:t.headers.Authorization=`Bearer ${u}`);const c=yield this.axios.request(t),d=c.data,l={raw:c.data,status:c.status,statusText:c.statusText,headers:c.headers,data:d.data,meta:d.meta,errors:d.errors};if(d.errors)throw new x(null,l);return l}catch(t){if(Ht.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new x(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(c=t.response)||void 0===c?void 0:c.status,statusText:null===(d=t.response)||void 0===d?void 0:d.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new x(t)}}))}get(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("get",e,void 0,r)}))}head(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("head",e,void 0,r)}))}options(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("options",e,void 0,r)}))}delete(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("delete",e,r,s)}))}put(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("put",e,r,s)}))}post(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("post",e,r,s)}))}patch(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("patch",e,r,s)}))}}class Xt{constructor(t){this.transport=t}request(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:e,reset_url:r})}))}reset(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:e,password:r})}))}}class Jt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...e){return t(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((t,r)=>{this.func(...e).then((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.resolve(e)))})).catch((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.reject(e)))}))})))}))}}class Vt{constructor(t,e,r){var s,n,i,o,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(o=null===(i=this.options.refresh)||void 0===i?void 0:i.time)&&void 0!==o?o:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Jt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Xt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(e=!1){var r;return t(this,void 0,void 0,(function*(){if(!e&&!this.expiring)return!1;const t=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(t.data),this.updateRefresh(),{access_token:t.data.access_token,refresh_token:null===(r=t.data)||void 0===r?void 0:r.refresh_token,expires:t.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(e=!1){return t(this,void 0,void 0,(function*(){return yield this.refresher.debounce(e)}))}login(e,r){var s;return t(this,void 0,void 0,(function*(){r=r||{};const t=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},e),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(t.data),this.updateRefresh(r.refresh),{access_token:t.data.access_token,refresh_token:null===(s=t.data)||void 0===s?void 0:s.refresh_token,expires:t.data.expires}}))}static(e){return t(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:e}}),this.storage.auth_token=e,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return t(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class Kt{constructor(t){this.transport=t}request(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.transport.post(e,{query:r,variables:void 0===s?{}:s})}))}items(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql",e,r)}))}system(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",e,r)}))}}class Wt{constructor(t,e){this.collection=t,this.transport=e}read(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,e,{params:r})).data}))}}class Gt{constructor(e,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new k),this._transport=(null==r?void 0:r.transport)||new Mt(e,this._storage,(()=>t(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Vt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new s(this.transport))}get collections(){return this._collections||(this._collections=new n(this.transport))}get fields(){return this._fields||(this._fields=new i(this.transport))}get files(){return this._files||(this._files=new o(this.transport))}get folders(){return this._folders||(this._folders=new a(this.transport))}get permissions(){return this._permissions||(this._permissions=new u(this.transport))}get presets(){return this._presets||(this._presets=new h(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new d(this.transport))}get roles(){return this._roles||(this._roles=new l(this.transport))}get settings(){return this._settings||(this._settings=new f(this.transport))}get users(){return this._users||(this._users=new y(this.transport))}get server(){return this._server||(this._server=new p(this.transport))}get utils(){return this._utils||(this._utils=new _(this.transport))}get graphql(){return this._graphql||(this._graphql=new Kt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Wt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new e(t,this.transport))}}export{s as ActivityHandler,Vt as Auth,Mt as AxiosTransport,b as BaseStorage,n as CollectionsHandler,r as CommentsHandler,Gt as Directus,i as FieldsHandler,o as FilesHandler,a as FoldersHandler,e as ItemsHandler,E as LocalStorage,k as MemoryStorage,w as Meta,u as PermissionsHandler,h as PresetsHandler,c as RelationsHandler,d as RevisionsHandler,l as RolesHandler,p as ServerHandler,f as SettingsHandler,x as TransportError,y as UsersHandler,_ as UtilsHandler}; | ||
function t(t,e,r,s){return new(r||(r=Promise))((function(n,o){function i(t){try{u(s.next(t))}catch(t){o(t)}}function a(t){try{u(s.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}u((s=s.apply(t,e||[])).next())}))}class e{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(e)}`,{params:r})).data}))}readMany(e){return t(this,void 0,void 0,(function*(){const{data:t,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:e});return{data:t,meta:r}}))}createOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,e,{params:r})).data}))}createMany(e,r){return t(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,e,{params:r})}))}updateOne(e,r,s){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(e)}`,r,{params:s})).data}))}updateMany(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:e,data:r},{params:s})}))}deleteOne(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(e)}`)}))}deleteMany(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,e)}))}}class r{constructor(t){this.transport=t}create(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",e)).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(e)}`,{comment:r})).data}))}delete(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(e)}`)}))}}class s extends e{constructor(t){super("directus_activity",t),this._comments=new r(this.transport)}get comments(){return this._comments}}class n extends e{constructor(t){super("directus_collections",t)}}class o extends e{constructor(t){super("directus_fields",t)}}class i extends e{constructor(t){super("directus_files",t)}}class a extends e{constructor(t){super("directus_folders",t)}}class u extends e{constructor(t){super("directus_permissions",t)}}class h extends e{constructor(t){super("directus_presets",t)}}class d extends e{constructor(t){super("directus_relations",t)}}class c extends e{constructor(t){super("directus_revisions",t)}}class l extends e{constructor(t){super("directus_roles",t)}}class p{constructor(t){this.transport=t}ping(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class f extends e{constructor(t){super("directus_settings",t)}}class v{constructor(t){this.transport=t}send(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:e,role:r})}))}accept(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:e,password:r})}))}}class m{constructor(t){this.transport=t}enable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:e})}))}disable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:e})}))}}class g{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new m(this._transport))}read(e){return t(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",e,{params:r})).data}))}}class y extends e{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new v(this.transport))}get me(){return this._me||(this._me=new g(this.transport))}}class _{constructor(e){this.random={string:(e=32)=>t(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:e}})).data}))},this.hash={generate:e=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:e})).data})),verify:(e,r)=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:e,hash:r})).data}))},this.transport=e}sort(e,r,s){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(e)}`,{item:r,to:s})}))}revert(e){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(e)}`)}))}}var w;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(w||(w={}));class x extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,x.prototype)}}class b{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class k extends b{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends b{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var R={exports:{}},T=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=T,O=Object.prototype.toString;function S(t){return"[object Array]"===O.call(t)}function U(t){return void 0===t}function A(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==O.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function q(t){return"[object Function]"===O.call(t)}function N(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),S(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var P={isArray:S,isArrayBuffer:function(t){return"[object ArrayBuffer]"===O.call(t)},isBuffer:function(t){return null!==t&&!U(t)&&null!==t.constructor&&!U(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:A,isPlainObject:C,isUndefined:U,isDate:function(t){return"[object Date]"===O.call(t)},isFile:function(t){return"[object File]"===O.call(t)},isBlob:function(t){return"[object Blob]"===O.call(t)},isFunction:q,isStream:function(t){return A(t)&&q(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:N,merge:function t(){var e={};function r(r,s){C(e[s])&&C(r)?e[s]=t(e[s],r):C(r)?e[s]=t({},r):S(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)N(arguments[s],r);return e},extend:function(t,e,r){return N(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},B=P;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(B.isURLSearchParams(e))s=e.toString();else{var n=[];B.forEach(e,(function(t,e){null!=t&&(B.isArray(t)?e+="[]":t=[t],B.forEach(t,(function(t){B.isDate(t)?t=t.toISOString():B.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=P;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var z=D,F=P,H=function(t){return!(!t||!t.__CANCEL__)},M=P,X=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},J=function(t,e,r,s,n){var o=new Error(t);return X(o,e,r,s,n)},V=J,K=P,W=K.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),K.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),K.isString(s)&&i.push("path="+s),K.isString(n)&&i.push("domain="+n),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},G=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Q=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Y=P,Z=["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"],tt=P,et=tt.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=tt.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},rt=P,st=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(V("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},nt=W,ot=L,it=function(t,e){return t&&!G(e)?Q(t,e):e},at=function(t){var e,r,s,n={};return t?(Y.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Y.trim(t.substr(0,s)).toLowerCase(),r=Y.trim(t.substr(s+1)),e){if(n[e]&&Z.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ut=et,ht=J,dt=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;rt.isFormData(s)&&delete n["Content-Type"];var o=new XMLHttpRequest;if(t.auth){var i=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(i+":"+a)}var u=it(t.baseURL,t.url);if(o.open(t.method.toUpperCase(),ot(u,t.params,t.paramsSerializer),!0),o.timeout=t.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in o?at(o.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:s,config:t,request:o};st(e,r,n),o=null}},o.onabort=function(){o&&(r(ht("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(ht("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(ht(e,t,"ECONNABORTED",o)),o=null},rt.isStandardBrowserEnv()){var h=(t.withCredentials||ut(u))&&t.xsrfCookieName?nt.read(t.xsrfCookieName):void 0;h&&(n[t.xsrfHeaderName]=h)}if("setRequestHeader"in o&&rt.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:o.setRequestHeader(e,t)})),rt.isUndefined(t.withCredentials)||(o.withCredentials=!!t.withCredentials),t.responseType)try{o.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&o.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){o&&(o.abort(),r(t),o=null)})),s||(s=null),o.send(s)}))},ct=P,lt=function(t,e){M.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},pt={"Content-Type":"application/x-www-form-urlencoded"};function ft(t,e){!ct.isUndefined(t)&&ct.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var vt,mt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(vt=dt),vt),transformRequest:[function(t,e){return lt(e,"Accept"),lt(e,"Content-Type"),ct.isFormData(t)||ct.isArrayBuffer(t)||ct.isBuffer(t)||ct.isStream(t)||ct.isFile(t)||ct.isBlob(t)?t:ct.isArrayBufferView(t)?t.buffer:ct.isURLSearchParams(t)?(ft(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):ct.isObject(t)?(ft(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};mt.headers={common:{Accept:"application/json, text/plain, */*"}},ct.forEach(["delete","get","head"],(function(t){mt.headers[t]={}})),ct.forEach(["post","put","patch"],(function(t){mt.headers[t]=ct.merge(pt)}));var gt=mt,yt=P,_t=function(t,e,r){return F.forEach(r,(function(r){t=r(t,e)})),t},wt=H,xt=gt;function bt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var kt=P,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function a(t,e){return kt.isPlainObject(t)&&kt.isPlainObject(e)?kt.merge(t,e):kt.isPlainObject(e)?kt.merge({},e):kt.isArray(e)?e.slice():e}function u(s){kt.isUndefined(e[s])?kt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}kt.forEach(s,(function(t){kt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),kt.forEach(n,u),kt.forEach(o,(function(s){kt.isUndefined(e[s])?kt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),kt.forEach(i,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var h=s.concat(n).concat(o).concat(i),d=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return kt.forEach(d,u),r},Rt=P,Tt=L,jt=z,Ot=function(t){return bt(t),t.headers=t.headers||{},t.data=_t(t.data,t.headers,t.transformRequest),t.headers=yt.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),yt.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||xt.adapter)(t).then((function(e){return bt(t),e.data=_t(e.data,e.headers,t.transformResponse),e}),(function(e){return wt(e)||(bt(t),e&&e.response&&(e.response.data=_t(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},St=Et;function Ut(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}Ut.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=St(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Ot,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},Ut.prototype.getUri=function(t){return t=St(this.defaults,t),Tt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Rt.forEach(["delete","get","head","options"],(function(t){Ut.prototype[t]=function(e,r){return this.request(St(r||{},{method:t,url:e,data:(r||{}).data}))}})),Rt.forEach(["post","put","patch"],(function(t){Ut.prototype[t]=function(e,r,s){return this.request(St(s||{},{method:t,url:e,data:r}))}}));var At=Ut;function Ct(t){this.message=t}Ct.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Ct.prototype.__CANCEL__=!0;var qt=Ct,Nt=qt;function Pt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Nt(t),e(r.reason))}))}Pt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Pt.source=function(){var t;return{token:new Pt((function(e){t=e})),cancel:t}};var Bt=Pt,$t=P,Lt=T,It=At,Dt=Et;function zt(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var Ft=zt(gt);Ft.Axios=It,Ft.create=function(t){return zt(Dt(Ft.defaults,t))},Ft.Cancel=qt,Ft.CancelToken=Bt,Ft.isCancel=H,Ft.all=function(t){return Promise.all(t)},Ft.spread=function(t){return function(e){return t.apply(null,e)}},Ft.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},R.exports=Ft,R.exports.default=Ft;var Ht=R.exports;class Mt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=Ht.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(e,r,s,n){var o,i,a,u,h,d,c,l,p;return t(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(o=n.sendAuthorizationHeaders)||void 0===o||o,n.refreshTokenIfNeeded=null===(i=n.refreshTokenIfNeeded)||void 0===i||i,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.onUploadProgress=null!==(u=n.onUploadProgress)&&void 0!==u?u:void 0,n.refreshTokenIfNeeded&&(yield this._refresh());const t={method:e,url:r,data:s,params:n.params,headers:n.headers,onUploadProgress:n.onUploadProgress},h=this._storage.auth_token,d=this._storage.auth_expires;n.sendAuthorizationHeaders&&h&&(null!==d&&d>Date.now()||null===d)&&(h.startsWith("Bearer ")?t.headers.Authorization=h:t.headers.Authorization=`Bearer ${h}`);const c=yield this.axios.request(t),l=c.data,p={raw:c.data,status:c.status,statusText:c.statusText,headers:c.headers,data:l.data,meta:l.meta,errors:l.errors};if(l.errors)throw new x(null,p);return p}catch(t){if(Ht.isAxiosError(t)){const e=null===(h=t.response)||void 0===h?void 0:h.data;throw new x(t,{raw:null===(d=t.response)||void 0===d?void 0:d.data,status:null===(c=t.response)||void 0===c?void 0:c.status,statusText:null===(l=t.response)||void 0===l?void 0:l.statusText,headers:null===(p=t.response)||void 0===p?void 0:p.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new x(t)}}))}get(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("get",e,void 0,r)}))}head(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("head",e,void 0,r)}))}options(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("options",e,void 0,r)}))}delete(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("delete",e,r,s)}))}put(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("put",e,r,s)}))}post(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("post",e,r,s)}))}patch(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("patch",e,r,s)}))}}class Xt{constructor(t){this.transport=t}request(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:e,reset_url:r})}))}reset(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:e,password:r})}))}}class Jt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...e){return t(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((t,r)=>{this.func(...e).then((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.resolve(e)))})).catch((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.reject(e)))}))})))}))}}class Vt{constructor(t,e,r){var s,n,o,i,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(i=null===(o=this.options.refresh)||void 0===o?void 0:o.time)&&void 0!==i?i:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Jt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Xt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(e=!1){var r;return t(this,void 0,void 0,(function*(){if(!e&&!this.expiring)return!1;const t=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(t.data),this.updateRefresh(),{access_token:t.data.access_token,refresh_token:null===(r=t.data)||void 0===r?void 0:r.refresh_token,expires:t.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(e=!1){return t(this,void 0,void 0,(function*(){return yield this.refresher.debounce(e)}))}login(e,r){var s;return t(this,void 0,void 0,(function*(){r=r||{};const t=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},e),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(t.data),this.updateRefresh(r.refresh),{access_token:t.data.access_token,refresh_token:null===(s=t.data)||void 0===s?void 0:s.refresh_token,expires:t.data.expires}}))}static(e){return t(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:e}}),this.storage.auth_token=e,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return t(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class Kt{constructor(t){this.transport=t}request(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.transport.post(e,{query:r,variables:void 0===s?{}:s})}))}items(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql",e,r)}))}system(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",e,r)}))}}class Wt{constructor(t,e){this.collection=t,this.transport=e}read(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,e,{params:r})).data}))}}class Gt{constructor(e,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new k),this._transport=(null==r?void 0:r.transport)||new Mt(e,this._storage,(()=>t(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Vt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new s(this.transport))}get collections(){return this._collections||(this._collections=new n(this.transport))}get fields(){return this._fields||(this._fields=new o(this.transport))}get files(){return this._files||(this._files=new i(this.transport))}get folders(){return this._folders||(this._folders=new a(this.transport))}get permissions(){return this._permissions||(this._permissions=new u(this.transport))}get presets(){return this._presets||(this._presets=new h(this.transport))}get relations(){return this._relations||(this._relations=new d(this.transport))}get revisions(){return this._revisions||(this._revisions=new c(this.transport))}get roles(){return this._roles||(this._roles=new l(this.transport))}get settings(){return this._settings||(this._settings=new f(this.transport))}get users(){return this._users||(this._users=new y(this.transport))}get server(){return this._server||(this._server=new p(this.transport))}get utils(){return this._utils||(this._utils=new _(this.transport))}get graphql(){return this._graphql||(this._graphql=new Kt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Wt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new e(t,this.transport))}}export{s as ActivityHandler,Vt as Auth,Mt as AxiosTransport,b as BaseStorage,n as CollectionsHandler,r as CommentsHandler,Gt as Directus,o as FieldsHandler,i as FilesHandler,a as FoldersHandler,e as ItemsHandler,E as LocalStorage,k as MemoryStorage,w as Meta,u as PermissionsHandler,h as PresetsHandler,d as RelationsHandler,c as RevisionsHandler,l as RolesHandler,p as ServerHandler,f as SettingsHandler,x as TransportError,y as UsersHandler,_ as UtilsHandler}; | ||
//# sourceMappingURL=sdk.esm.min.js.map |
@@ -15,3 +15,3 @@ var Directus=function(t){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}class i extends r{constructor(t){super("directus_collections",t)}}class o extends r{constructor(t){super("directus_fields",t)}}class a extends r{constructor(t){super("directus_files",t)}}class u extends r{constructor(t){super("directus_folders",t)}}class h extends r{constructor(t){super("directus_permissions",t)}}class d extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class p extends r{constructor(t){super("directus_roles",t)}}class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var S={exports:{}},T=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=T,O=Object.prototype.toString;function A(t){return"[object Array]"===O.call(t)}function C(t){return void 0===t}function U(t){return null!==t&&"object"==typeof t}function q(t){if("[object Object]"!==O.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===O.call(t)}function P(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),A(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var B={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===O.call(t)},isBuffer:function(t){return null!==t&&!C(t)&&null!==t.constructor&&!C(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:U,isPlainObject:q,isUndefined:C,isDate:function(t){return"[object Date]"===O.call(t)},isFile:function(t){return"[object File]"===O.call(t)},isBlob:function(t){return"[object Blob]"===O.call(t)},isFunction:N,isStream:function(t){return U(t)&&N(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:P,merge:function t(){var e={};function r(r,s){q(e[s])&&q(r)?e[s]=t(e[s],r):q(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)P(arguments[s],r);return e},extend:function(t,e,r){return P(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},H=B;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(H.isURLSearchParams(e))s=e.toString();else{var n=[];H.forEach(e,(function(t,e){null!=t&&(H.isArray(t)?e+="[]":t=[t],H.forEach(t,(function(t){H.isDate(t)?t=t.toISOString():H.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=B;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var F=D,M=B,z=function(t){return!(!t||!t.__CANCEL__)},X=B,J=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},V=function(t,e,r,s,n){var i=new Error(t);return J(i,e,r,s,n)},K=V,W=B,G=W.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),W.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),W.isString(s)&&o.push("path="+s),W.isString(n)&&o.push("domain="+n),!0===i&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Q=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Y=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Z=B,tt=["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"],et=B,rt=et.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=et.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},st=B,nt=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(K("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},it=G,ot=L,at=function(t,e){return t&&!Q(e)?Y(t,e):e},ut=function(t){var e,r,s,n={};return t?(Z.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Z.trim(t.substr(0,s)).toLowerCase(),r=Z.trim(t.substr(s+1)),e){if(n[e]&&tt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ht=rt,dt=V,ct=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;st.isFormData(s)&&delete n["Content-Type"];var i=new XMLHttpRequest;if(t.auth){var o=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(o+":"+a)}var u=at(t.baseURL,t.url);if(i.open(t.method.toUpperCase(),ot(u,t.params,t.paramsSerializer),!0),i.timeout=t.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in i?ut(i.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:s,config:t,request:i};nt(e,r,n),i=null}},i.onabort=function(){i&&(r(dt("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(dt("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(dt(e,t,"ECONNABORTED",i)),i=null},st.isStandardBrowserEnv()){var h=(t.withCredentials||ht(u))&&t.xsrfCookieName?it.read(t.xsrfCookieName):void 0;h&&(n[t.xsrfHeaderName]=h)}if("setRequestHeader"in i&&st.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),st.isUndefined(t.withCredentials)||(i.withCredentials=!!t.withCredentials),t.responseType)try{i.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&i.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){i&&(i.abort(),r(t),i=null)})),s||(s=null),i.send(s)}))},lt=B,pt=function(t,e){X.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},ft={"Content-Type":"application/x-www-form-urlencoded"};function vt(t,e){!lt.isUndefined(t)&<.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var mt,gt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(mt=ct),mt),transformRequest:[function(t,e){return pt(e,"Accept"),pt(e,"Content-Type"),lt.isFormData(t)||lt.isArrayBuffer(t)||lt.isBuffer(t)||lt.isStream(t)||lt.isFile(t)||lt.isBlob(t)?t:lt.isArrayBufferView(t)?t.buffer:lt.isURLSearchParams(t)?(vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):lt.isObject(t)?(vt(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};gt.headers={common:{Accept:"application/json, text/plain, */*"}},lt.forEach(["delete","get","head"],(function(t){gt.headers[t]={}})),lt.forEach(["post","put","patch"],(function(t){gt.headers[t]=lt.merge(ft)}));var yt=gt,_t=B,wt=function(t,e,r){return M.forEach(r,(function(r){t=r(t,e)})),t},xt=z,bt=yt;function kt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Rt=B,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["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"],o=["validateStatus"];function a(t,e){return Rt.isPlainObject(t)&&Rt.isPlainObject(e)?Rt.merge(t,e):Rt.isPlainObject(e)?Rt.merge({},e):Rt.isArray(e)?e.slice():e}function u(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}Rt.forEach(s,(function(t){Rt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),Rt.forEach(n,u),Rt.forEach(i,(function(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),Rt.forEach(o,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var h=s.concat(n).concat(i).concat(o),d=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return Rt.forEach(d,u),r},St=B,Tt=L,jt=F,Ot=function(t){return kt(t),t.headers=t.headers||{},t.data=wt(t.data,t.headers,t.transformRequest),t.headers=_t.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),_t.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||bt.adapter)(t).then((function(e){return kt(t),e.data=wt(e.data,e.headers,t.transformResponse),e}),(function(e){return xt(e)||(kt(t),e&&e.response&&(e.response.data=wt(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},At=Et;function Ct(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}Ct.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=At(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Ot,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},Ct.prototype.getUri=function(t){return t=At(this.defaults,t),Tt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},St.forEach(["delete","get","head","options"],(function(t){Ct.prototype[t]=function(e,r){return this.request(At(r||{},{method:t,url:e,data:(r||{}).data}))}})),St.forEach(["post","put","patch"],(function(t){Ct.prototype[t]=function(e,r,s){return this.request(At(s||{},{method:t,url:e,data:r}))}}));var Ut=Ct;function qt(t){this.message=t}qt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},qt.prototype.__CANCEL__=!0;var Nt=qt,Pt=Nt;function Bt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Pt(t),e(r.reason))}))}Bt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Bt.source=function(){var t;return{token:new Bt((function(e){t=e})),cancel:t}};var Ht=Bt,$t=B,Lt=T,It=Ut,Dt=Et;function Ft(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var Mt=Ft(yt);Mt.Axios=It,Mt.create=function(t){return Ft(Dt(Mt.defaults,t))},Mt.Cancel=Nt,Mt.CancelToken=Ht,Mt.isCancel=z,Mt.all=function(t){return Promise.all(t)},Mt.spread=function(t){return function(e){return t.apply(null,e)}},Mt.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},S.exports=Mt,S.exports.default=Mt;var zt=S.exports;class Xt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=zt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(zt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class Jt{constructor(t){this.transport=t}request(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:r})}))}reset(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:r})}))}}class Vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return e(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((e,r)=>{this.func(...t).then((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.resolve(t)))})).catch((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.reject(t)))}))})))}))}}class Kt{constructor(t,e,r){var s,n,i,o,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(o=null===(i=this.options.refresh)||void 0===i?void 0:i.time)&&void 0!==o?o:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Vt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Jt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class Wt{constructor(t){this.transport=t}request(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:r,variables:void 0===s?{}:s})}))}items(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,r)}))}system(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,r)}))}}class Gt{constructor(t,e){this.collection=t,this.transport=e}read(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:r})).data}))}}return t.ActivityHandler=n,t.Auth=Kt,t.AxiosTransport=Xt,t.BaseStorage=k,t.CollectionsHandler=i,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new Xt(t,this._storage,(()=>e(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Kt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new n(this.transport))}get collections(){return this._collections||(this._collections=new i(this.transport))}get fields(){return this._fields||(this._fields=new o(this.transport))}get files(){return this._files||(this._files=new a(this.transport))}get folders(){return this._folders||(this._folders=new u(this.transport))}get permissions(){return this._permissions||(this._permissions=new h(this.transport))}get presets(){return this._presets||(this._presets=new d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new Wt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Gt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new r(t,this.transport))}},t.FieldsHandler=o,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=h,t.PresetsHandler=d,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=p,t.ServerHandler=f,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,o){function i(t){try{u(s.next(t))}catch(t){o(t)}}function a(t){try{u(s.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}u((s=s.apply(t,e||[])).next())}))}class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}class o extends r{constructor(t){super("directus_collections",t)}}class i extends r{constructor(t){super("directus_fields",t)}}class a extends r{constructor(t){super("directus_files",t)}}class u extends r{constructor(t){super("directus_folders",t)}}class h extends r{constructor(t){super("directus_permissions",t)}}class d extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class p extends r{constructor(t){super("directus_roles",t)}}class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var S={exports:{}},T=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=T,O=Object.prototype.toString;function A(t){return"[object Array]"===O.call(t)}function U(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function q(t){if("[object Object]"!==O.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===O.call(t)}function P(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),A(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var B={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===O.call(t)},isBuffer:function(t){return null!==t&&!U(t)&&null!==t.constructor&&!U(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:C,isPlainObject:q,isUndefined:U,isDate:function(t){return"[object Date]"===O.call(t)},isFile:function(t){return"[object File]"===O.call(t)},isBlob:function(t){return"[object Blob]"===O.call(t)},isFunction:N,isStream:function(t){return C(t)&&N(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:P,merge:function t(){var e={};function r(r,s){q(e[s])&&q(r)?e[s]=t(e[s],r):q(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)P(arguments[s],r);return e},extend:function(t,e,r){return P(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},H=B;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(H.isURLSearchParams(e))s=e.toString();else{var n=[];H.forEach(e,(function(t,e){null!=t&&(H.isArray(t)?e+="[]":t=[t],H.forEach(t,(function(t){H.isDate(t)?t=t.toISOString():H.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=B;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var F=D,M=B,z=function(t){return!(!t||!t.__CANCEL__)},X=B,J=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},V=function(t,e,r,s,n){var o=new Error(t);return J(o,e,r,s,n)},K=V,W=B,G=W.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),W.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),W.isString(s)&&i.push("path="+s),W.isString(n)&&i.push("domain="+n),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Q=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Y=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Z=B,tt=["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"],et=B,rt=et.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=et.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},st=B,nt=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(K("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ot=G,it=L,at=function(t,e){return t&&!Q(e)?Y(t,e):e},ut=function(t){var e,r,s,n={};return t?(Z.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Z.trim(t.substr(0,s)).toLowerCase(),r=Z.trim(t.substr(s+1)),e){if(n[e]&&tt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ht=rt,dt=V,ct=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;st.isFormData(s)&&delete n["Content-Type"];var o=new XMLHttpRequest;if(t.auth){var i=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(i+":"+a)}var u=at(t.baseURL,t.url);if(o.open(t.method.toUpperCase(),it(u,t.params,t.paramsSerializer),!0),o.timeout=t.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in o?ut(o.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:s,config:t,request:o};nt(e,r,n),o=null}},o.onabort=function(){o&&(r(dt("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(dt("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(dt(e,t,"ECONNABORTED",o)),o=null},st.isStandardBrowserEnv()){var h=(t.withCredentials||ht(u))&&t.xsrfCookieName?ot.read(t.xsrfCookieName):void 0;h&&(n[t.xsrfHeaderName]=h)}if("setRequestHeader"in o&&st.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:o.setRequestHeader(e,t)})),st.isUndefined(t.withCredentials)||(o.withCredentials=!!t.withCredentials),t.responseType)try{o.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&o.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){o&&(o.abort(),r(t),o=null)})),s||(s=null),o.send(s)}))},lt=B,pt=function(t,e){X.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},ft={"Content-Type":"application/x-www-form-urlencoded"};function vt(t,e){!lt.isUndefined(t)&<.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var mt,gt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(mt=ct),mt),transformRequest:[function(t,e){return pt(e,"Accept"),pt(e,"Content-Type"),lt.isFormData(t)||lt.isArrayBuffer(t)||lt.isBuffer(t)||lt.isStream(t)||lt.isFile(t)||lt.isBlob(t)?t:lt.isArrayBufferView(t)?t.buffer:lt.isURLSearchParams(t)?(vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):lt.isObject(t)?(vt(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};gt.headers={common:{Accept:"application/json, text/plain, */*"}},lt.forEach(["delete","get","head"],(function(t){gt.headers[t]={}})),lt.forEach(["post","put","patch"],(function(t){gt.headers[t]=lt.merge(ft)}));var yt=gt,_t=B,wt=function(t,e,r){return M.forEach(r,(function(r){t=r(t,e)})),t},xt=z,bt=yt;function kt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Rt=B,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function a(t,e){return Rt.isPlainObject(t)&&Rt.isPlainObject(e)?Rt.merge(t,e):Rt.isPlainObject(e)?Rt.merge({},e):Rt.isArray(e)?e.slice():e}function u(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}Rt.forEach(s,(function(t){Rt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),Rt.forEach(n,u),Rt.forEach(o,(function(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),Rt.forEach(i,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var h=s.concat(n).concat(o).concat(i),d=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return Rt.forEach(d,u),r},St=B,Tt=L,jt=F,Ot=function(t){return kt(t),t.headers=t.headers||{},t.data=wt(t.data,t.headers,t.transformRequest),t.headers=_t.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),_t.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||bt.adapter)(t).then((function(e){return kt(t),e.data=wt(e.data,e.headers,t.transformResponse),e}),(function(e){return xt(e)||(kt(t),e&&e.response&&(e.response.data=wt(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},At=Et;function Ut(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}Ut.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=At(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Ot,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},Ut.prototype.getUri=function(t){return t=At(this.defaults,t),Tt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},St.forEach(["delete","get","head","options"],(function(t){Ut.prototype[t]=function(e,r){return this.request(At(r||{},{method:t,url:e,data:(r||{}).data}))}})),St.forEach(["post","put","patch"],(function(t){Ut.prototype[t]=function(e,r,s){return this.request(At(s||{},{method:t,url:e,data:r}))}}));var Ct=Ut;function qt(t){this.message=t}qt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},qt.prototype.__CANCEL__=!0;var Nt=qt,Pt=Nt;function Bt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Pt(t),e(r.reason))}))}Bt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Bt.source=function(){var t;return{token:new Bt((function(e){t=e})),cancel:t}};var Ht=Bt,$t=B,Lt=T,It=Ct,Dt=Et;function Ft(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var Mt=Ft(yt);Mt.Axios=It,Mt.create=function(t){return Ft(Dt(Mt.defaults,t))},Mt.Cancel=Nt,Mt.CancelToken=Ht,Mt.isCancel=z,Mt.all=function(t){return Promise.all(t)},Mt.spread=function(t){return function(e){return t.apply(null,e)}},Mt.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},S.exports=Mt,S.exports.default=Mt;var zt=S.exports;class Xt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=zt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var o,i,a,u,h,d,c,l,p;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(o=n.sendAuthorizationHeaders)||void 0===o||o,n.refreshTokenIfNeeded=null===(i=n.refreshTokenIfNeeded)||void 0===i||i,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.onUploadProgress=null!==(u=n.onUploadProgress)&&void 0!==u?u:void 0,n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers,onUploadProgress:n.onUploadProgress},h=this._storage.auth_token,d=this._storage.auth_expires;n.sendAuthorizationHeaders&&h&&(null!==d&&d>Date.now()||null===d)&&(h.startsWith("Bearer ")?e.headers.Authorization=h:e.headers.Authorization=`Bearer ${h}`);const c=yield this.axios.request(e),l=c.data,p={raw:c.data,status:c.status,statusText:c.statusText,headers:c.headers,data:l.data,meta:l.meta,errors:l.errors};if(l.errors)throw new b(null,p);return p}catch(t){if(zt.isAxiosError(t)){const e=null===(h=t.response)||void 0===h?void 0:h.data;throw new b(t,{raw:null===(d=t.response)||void 0===d?void 0:d.data,status:null===(c=t.response)||void 0===c?void 0:c.status,statusText:null===(l=t.response)||void 0===l?void 0:l.statusText,headers:null===(p=t.response)||void 0===p?void 0:p.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class Jt{constructor(t){this.transport=t}request(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:r})}))}reset(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:r})}))}}class Vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return e(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((e,r)=>{this.func(...t).then((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.resolve(t)))})).catch((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.reject(t)))}))})))}))}}class Kt{constructor(t,e,r){var s,n,o,i,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(i=null===(o=this.options.refresh)||void 0===o?void 0:o.time)&&void 0!==i?i:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Vt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Jt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class Wt{constructor(t){this.transport=t}request(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:r,variables:void 0===s?{}:s})}))}items(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,r)}))}system(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,r)}))}}class Gt{constructor(t,e){this.collection=t,this.transport=e}read(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:r})).data}))}}return t.ActivityHandler=n,t.Auth=Kt,t.AxiosTransport=Xt,t.BaseStorage=k,t.CollectionsHandler=o,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new Xt(t,this._storage,(()=>e(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Kt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new n(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new i(this.transport))}get files(){return this._files||(this._files=new a(this.transport))}get folders(){return this._folders||(this._folders=new u(this.transport))}get permissions(){return this._permissions||(this._permissions=new h(this.transport))}get presets(){return this._presets||(this._presets=new d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new Wt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Gt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new r(t,this.transport))}},t.FieldsHandler=i,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=h,t.PresetsHandler=d,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=p,t.ServerHandler=f,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
//# sourceMappingURL=sdk.iife.min.js.map |
@@ -16,3 +16,3 @@ System.register("Directus",[],(function(t){"use strict";return{execute:function(){ | ||
***************************************************************************** */ | ||
function e(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}t("Meta",void 0);class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}t("ItemsHandler",r);class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}t("CommentsHandler",s);class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}t("ActivityHandler",n);class i extends r{constructor(t){super("directus_collections",t)}}t("CollectionsHandler",i);class o extends r{constructor(t){super("directus_fields",t)}}t("FieldsHandler",o);class a extends r{constructor(t){super("directus_files",t)}}t("FilesHandler",a);class u extends r{constructor(t){super("directus_folders",t)}}t("FoldersHandler",u);class h extends r{constructor(t){super("directus_permissions",t)}}t("PermissionsHandler",h);class d extends r{constructor(t){super("directus_presets",t)}}t("PresetsHandler",d);class c extends r{constructor(t){super("directus_relations",t)}}t("RelationsHandler",c);class l extends r{constructor(t){super("directus_revisions",t)}}t("RevisionsHandler",l);class p extends r{constructor(t){super("directus_roles",t)}}t("RolesHandler",p);class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}t("ServerHandler",f);class v extends r{constructor(t){super("directus_settings",t)}}t("SettingsHandler",v);class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}t("UsersHandler",_);class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t("UtilsHandler",w),function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(x||(x=t("Meta",{})));class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}t("TransportError",b);class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}t("BaseStorage",k);class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}t("MemoryStorage",R);class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}t("LocalStorage",E);var S={exports:{}},T=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=T,A=Object.prototype.toString;function O(t){return"[object Array]"===A.call(t)}function C(t){return void 0===t}function U(t){return null!==t&&"object"==typeof t}function q(t){if("[object Object]"!==A.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===A.call(t)}function B(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),O(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var P={isArray:O,isArrayBuffer:function(t){return"[object ArrayBuffer]"===A.call(t)},isBuffer:function(t){return null!==t&&!C(t)&&null!==t.constructor&&!C(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:U,isPlainObject:q,isUndefined:C,isDate:function(t){return"[object Date]"===A.call(t)},isFile:function(t){return"[object File]"===A.call(t)},isBlob:function(t){return"[object Blob]"===A.call(t)},isFunction:N,isStream:function(t){return U(t)&&N(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:B,merge:function t(){var e={};function r(r,s){q(e[s])&&q(r)?e[s]=t(e[s],r):q(r)?e[s]=t({},r):O(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)B(arguments[s],r);return e},extend:function(t,e,r){return B(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},H=P;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(H.isURLSearchParams(e))s=e.toString();else{var n=[];H.forEach(e,(function(t,e){null!=t&&(H.isArray(t)?e+="[]":t=[t],H.forEach(t,(function(t){H.isDate(t)?t=t.toISOString():H.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=P;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var F=D,z=P,M=function(t){return!(!t||!t.__CANCEL__)},X=P,J=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},V=function(t,e,r,s,n){var i=new Error(t);return J(i,e,r,s,n)},K=V,W=P,G=W.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),W.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),W.isString(s)&&o.push("path="+s),W.isString(n)&&o.push("domain="+n),!0===i&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Q=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Y=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Z=P,tt=["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"],et=P,rt=et.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=et.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},st=P,nt=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(K("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},it=G,ot=L,at=function(t,e){return t&&!Q(e)?Y(t,e):e},ut=function(t){var e,r,s,n={};return t?(Z.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Z.trim(t.substr(0,s)).toLowerCase(),r=Z.trim(t.substr(s+1)),e){if(n[e]&&tt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ht=rt,dt=V,ct=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;st.isFormData(s)&&delete n["Content-Type"];var i=new XMLHttpRequest;if(t.auth){var o=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(o+":"+a)}var u=at(t.baseURL,t.url);if(i.open(t.method.toUpperCase(),ot(u,t.params,t.paramsSerializer),!0),i.timeout=t.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in i?ut(i.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:s,config:t,request:i};nt(e,r,n),i=null}},i.onabort=function(){i&&(r(dt("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(dt("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(dt(e,t,"ECONNABORTED",i)),i=null},st.isStandardBrowserEnv()){var h=(t.withCredentials||ht(u))&&t.xsrfCookieName?it.read(t.xsrfCookieName):void 0;h&&(n[t.xsrfHeaderName]=h)}if("setRequestHeader"in i&&st.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),st.isUndefined(t.withCredentials)||(i.withCredentials=!!t.withCredentials),t.responseType)try{i.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&i.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){i&&(i.abort(),r(t),i=null)})),s||(s=null),i.send(s)}))},lt=P,pt=function(t,e){X.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},ft={"Content-Type":"application/x-www-form-urlencoded"};function vt(t,e){!lt.isUndefined(t)&<.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var mt,gt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(mt=ct),mt),transformRequest:[function(t,e){return pt(e,"Accept"),pt(e,"Content-Type"),lt.isFormData(t)||lt.isArrayBuffer(t)||lt.isBuffer(t)||lt.isStream(t)||lt.isFile(t)||lt.isBlob(t)?t:lt.isArrayBufferView(t)?t.buffer:lt.isURLSearchParams(t)?(vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):lt.isObject(t)?(vt(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};gt.headers={common:{Accept:"application/json, text/plain, */*"}},lt.forEach(["delete","get","head"],(function(t){gt.headers[t]={}})),lt.forEach(["post","put","patch"],(function(t){gt.headers[t]=lt.merge(ft)}));var yt=gt,_t=P,wt=function(t,e,r){return z.forEach(r,(function(r){t=r(t,e)})),t},xt=M,bt=yt;function kt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Rt=P,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["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"],o=["validateStatus"];function a(t,e){return Rt.isPlainObject(t)&&Rt.isPlainObject(e)?Rt.merge(t,e):Rt.isPlainObject(e)?Rt.merge({},e):Rt.isArray(e)?e.slice():e}function u(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}Rt.forEach(s,(function(t){Rt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),Rt.forEach(n,u),Rt.forEach(i,(function(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),Rt.forEach(o,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var h=s.concat(n).concat(i).concat(o),d=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return Rt.forEach(d,u),r},St=P,Tt=L,jt=F,At=function(t){return kt(t),t.headers=t.headers||{},t.data=wt(t.data,t.headers,t.transformRequest),t.headers=_t.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),_t.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||bt.adapter)(t).then((function(e){return kt(t),e.data=wt(e.data,e.headers,t.transformResponse),e}),(function(e){return xt(e)||(kt(t),e&&e.response&&(e.response.data=wt(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Ot=Et;function Ct(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}Ct.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Ot(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[At,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},Ct.prototype.getUri=function(t){return t=Ot(this.defaults,t),Tt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},St.forEach(["delete","get","head","options"],(function(t){Ct.prototype[t]=function(e,r){return this.request(Ot(r||{},{method:t,url:e,data:(r||{}).data}))}})),St.forEach(["post","put","patch"],(function(t){Ct.prototype[t]=function(e,r,s){return this.request(Ot(s||{},{method:t,url:e,data:r}))}}));var Ut=Ct;function qt(t){this.message=t}qt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},qt.prototype.__CANCEL__=!0;var Nt=qt,Bt=Nt;function Pt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Bt(t),e(r.reason))}))}Pt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Pt.source=function(){var t;return{token:new Pt((function(e){t=e})),cancel:t}};var Ht=Pt,$t=P,Lt=T,It=Ut,Dt=Et;function Ft(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var zt=Ft(yt);zt.Axios=It,zt.create=function(t){return Ft(Dt(zt.defaults,t))},zt.Cancel=Nt,zt.CancelToken=Ht,zt.isCancel=M,zt.all=function(t){return Promise.all(t)},zt.spread=function(t){return function(e){return t.apply(null,e)}},zt.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},S.exports=zt,S.exports.default=zt;var Mt=S.exports;class Xt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=Mt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(Mt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}t("AxiosTransport",Xt);class Jt{constructor(t){this.transport=t}request(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:r})}))}reset(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:r})}))}}class Vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return e(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((e,r)=>{this.func(...t).then((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.resolve(t)))})).catch((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.reject(t)))}))})))}))}}class Kt{constructor(t,e,r){var s,n,i,o,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(o=null===(i=this.options.refresh)||void 0===i?void 0:i.time)&&void 0!==o?o:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Vt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Jt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}t("Auth",Kt);class Wt{constructor(t){this.transport=t}request(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:r,variables:void 0===s?{}:s})}))}items(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,r)}))}system(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,r)}))}}class Gt{constructor(t,e){this.collection=t,this.transport=e}read(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:r})).data}))}}t("Directus",class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new Xt(t,this._storage,(()=>e(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Kt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new n(this.transport))}get collections(){return this._collections||(this._collections=new i(this.transport))}get fields(){return this._fields||(this._fields=new o(this.transport))}get files(){return this._files||(this._files=new a(this.transport))}get folders(){return this._folders||(this._folders=new u(this.transport))}get permissions(){return this._permissions||(this._permissions=new h(this.transport))}get presets(){return this._presets||(this._presets=new d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new Wt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Gt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new r(t,this.transport))}})}}})); | ||
function e(t,e,r,s){return new(r||(r=Promise))((function(n,o){function i(t){try{u(s.next(t))}catch(t){o(t)}}function a(t){try{u(s.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}u((s=s.apply(t,e||[])).next())}))}t("Meta",void 0);class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}t("ItemsHandler",r);class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}t("CommentsHandler",s);class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}t("ActivityHandler",n);class o extends r{constructor(t){super("directus_collections",t)}}t("CollectionsHandler",o);class i extends r{constructor(t){super("directus_fields",t)}}t("FieldsHandler",i);class a extends r{constructor(t){super("directus_files",t)}}t("FilesHandler",a);class u extends r{constructor(t){super("directus_folders",t)}}t("FoldersHandler",u);class h extends r{constructor(t){super("directus_permissions",t)}}t("PermissionsHandler",h);class d extends r{constructor(t){super("directus_presets",t)}}t("PresetsHandler",d);class c extends r{constructor(t){super("directus_relations",t)}}t("RelationsHandler",c);class l extends r{constructor(t){super("directus_revisions",t)}}t("RevisionsHandler",l);class p extends r{constructor(t){super("directus_roles",t)}}t("RolesHandler",p);class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}t("ServerHandler",f);class v extends r{constructor(t){super("directus_settings",t)}}t("SettingsHandler",v);class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}t("UsersHandler",_);class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t("UtilsHandler",w),function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(x||(x=t("Meta",{})));class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}t("TransportError",b);class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}t("BaseStorage",k);class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}t("MemoryStorage",R);class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}t("LocalStorage",E);var S={exports:{}},T=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=T,A=Object.prototype.toString;function O(t){return"[object Array]"===A.call(t)}function U(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function q(t){if("[object Object]"!==A.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===A.call(t)}function P(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),O(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var B={isArray:O,isArrayBuffer:function(t){return"[object ArrayBuffer]"===A.call(t)},isBuffer:function(t){return null!==t&&!U(t)&&null!==t.constructor&&!U(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:C,isPlainObject:q,isUndefined:U,isDate:function(t){return"[object Date]"===A.call(t)},isFile:function(t){return"[object File]"===A.call(t)},isBlob:function(t){return"[object Blob]"===A.call(t)},isFunction:N,isStream:function(t){return C(t)&&N(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:P,merge:function t(){var e={};function r(r,s){q(e[s])&&q(r)?e[s]=t(e[s],r):q(r)?e[s]=t({},r):O(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)P(arguments[s],r);return e},extend:function(t,e,r){return P(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},H=B;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(H.isURLSearchParams(e))s=e.toString();else{var n=[];H.forEach(e,(function(t,e){null!=t&&(H.isArray(t)?e+="[]":t=[t],H.forEach(t,(function(t){H.isDate(t)?t=t.toISOString():H.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=B;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var F=D,z=B,M=function(t){return!(!t||!t.__CANCEL__)},X=B,J=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},V=function(t,e,r,s,n){var o=new Error(t);return J(o,e,r,s,n)},K=V,W=B,G=W.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),W.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),W.isString(s)&&i.push("path="+s),W.isString(n)&&i.push("domain="+n),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Q=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Y=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Z=B,tt=["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"],et=B,rt=et.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=et.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},st=B,nt=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(K("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ot=G,it=L,at=function(t,e){return t&&!Q(e)?Y(t,e):e},ut=function(t){var e,r,s,n={};return t?(Z.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Z.trim(t.substr(0,s)).toLowerCase(),r=Z.trim(t.substr(s+1)),e){if(n[e]&&tt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ht=rt,dt=V,ct=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;st.isFormData(s)&&delete n["Content-Type"];var o=new XMLHttpRequest;if(t.auth){var i=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(i+":"+a)}var u=at(t.baseURL,t.url);if(o.open(t.method.toUpperCase(),it(u,t.params,t.paramsSerializer),!0),o.timeout=t.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in o?ut(o.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:s,config:t,request:o};nt(e,r,n),o=null}},o.onabort=function(){o&&(r(dt("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(dt("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(dt(e,t,"ECONNABORTED",o)),o=null},st.isStandardBrowserEnv()){var h=(t.withCredentials||ht(u))&&t.xsrfCookieName?ot.read(t.xsrfCookieName):void 0;h&&(n[t.xsrfHeaderName]=h)}if("setRequestHeader"in o&&st.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:o.setRequestHeader(e,t)})),st.isUndefined(t.withCredentials)||(o.withCredentials=!!t.withCredentials),t.responseType)try{o.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&o.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){o&&(o.abort(),r(t),o=null)})),s||(s=null),o.send(s)}))},lt=B,pt=function(t,e){X.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},ft={"Content-Type":"application/x-www-form-urlencoded"};function vt(t,e){!lt.isUndefined(t)&<.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var mt,gt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(mt=ct),mt),transformRequest:[function(t,e){return pt(e,"Accept"),pt(e,"Content-Type"),lt.isFormData(t)||lt.isArrayBuffer(t)||lt.isBuffer(t)||lt.isStream(t)||lt.isFile(t)||lt.isBlob(t)?t:lt.isArrayBufferView(t)?t.buffer:lt.isURLSearchParams(t)?(vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):lt.isObject(t)?(vt(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};gt.headers={common:{Accept:"application/json, text/plain, */*"}},lt.forEach(["delete","get","head"],(function(t){gt.headers[t]={}})),lt.forEach(["post","put","patch"],(function(t){gt.headers[t]=lt.merge(ft)}));var yt=gt,_t=B,wt=function(t,e,r){return z.forEach(r,(function(r){t=r(t,e)})),t},xt=M,bt=yt;function kt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Rt=B,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function a(t,e){return Rt.isPlainObject(t)&&Rt.isPlainObject(e)?Rt.merge(t,e):Rt.isPlainObject(e)?Rt.merge({},e):Rt.isArray(e)?e.slice():e}function u(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}Rt.forEach(s,(function(t){Rt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),Rt.forEach(n,u),Rt.forEach(o,(function(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),Rt.forEach(i,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var h=s.concat(n).concat(o).concat(i),d=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return Rt.forEach(d,u),r},St=B,Tt=L,jt=F,At=function(t){return kt(t),t.headers=t.headers||{},t.data=wt(t.data,t.headers,t.transformRequest),t.headers=_t.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),_t.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||bt.adapter)(t).then((function(e){return kt(t),e.data=wt(e.data,e.headers,t.transformResponse),e}),(function(e){return xt(e)||(kt(t),e&&e.response&&(e.response.data=wt(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Ot=Et;function Ut(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}Ut.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Ot(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[At,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},Ut.prototype.getUri=function(t){return t=Ot(this.defaults,t),Tt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},St.forEach(["delete","get","head","options"],(function(t){Ut.prototype[t]=function(e,r){return this.request(Ot(r||{},{method:t,url:e,data:(r||{}).data}))}})),St.forEach(["post","put","patch"],(function(t){Ut.prototype[t]=function(e,r,s){return this.request(Ot(s||{},{method:t,url:e,data:r}))}}));var Ct=Ut;function qt(t){this.message=t}qt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},qt.prototype.__CANCEL__=!0;var Nt=qt,Pt=Nt;function Bt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Pt(t),e(r.reason))}))}Bt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Bt.source=function(){var t;return{token:new Bt((function(e){t=e})),cancel:t}};var Ht=Bt,$t=B,Lt=T,It=Ct,Dt=Et;function Ft(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var zt=Ft(yt);zt.Axios=It,zt.create=function(t){return Ft(Dt(zt.defaults,t))},zt.Cancel=Nt,zt.CancelToken=Ht,zt.isCancel=M,zt.all=function(t){return Promise.all(t)},zt.spread=function(t){return function(e){return t.apply(null,e)}},zt.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},S.exports=zt,S.exports.default=zt;var Mt=S.exports;class Xt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=Mt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var o,i,a,u,h,d,c,l,p;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(o=n.sendAuthorizationHeaders)||void 0===o||o,n.refreshTokenIfNeeded=null===(i=n.refreshTokenIfNeeded)||void 0===i||i,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.onUploadProgress=null!==(u=n.onUploadProgress)&&void 0!==u?u:void 0,n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers,onUploadProgress:n.onUploadProgress},h=this._storage.auth_token,d=this._storage.auth_expires;n.sendAuthorizationHeaders&&h&&(null!==d&&d>Date.now()||null===d)&&(h.startsWith("Bearer ")?e.headers.Authorization=h:e.headers.Authorization=`Bearer ${h}`);const c=yield this.axios.request(e),l=c.data,p={raw:c.data,status:c.status,statusText:c.statusText,headers:c.headers,data:l.data,meta:l.meta,errors:l.errors};if(l.errors)throw new b(null,p);return p}catch(t){if(Mt.isAxiosError(t)){const e=null===(h=t.response)||void 0===h?void 0:h.data;throw new b(t,{raw:null===(d=t.response)||void 0===d?void 0:d.data,status:null===(c=t.response)||void 0===c?void 0:c.status,statusText:null===(l=t.response)||void 0===l?void 0:l.statusText,headers:null===(p=t.response)||void 0===p?void 0:p.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}t("AxiosTransport",Xt);class Jt{constructor(t){this.transport=t}request(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:r})}))}reset(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:r})}))}}class Vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return e(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((e,r)=>{this.func(...t).then((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.resolve(t)))})).catch((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.reject(t)))}))})))}))}}class Kt{constructor(t,e,r){var s,n,o,i,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(i=null===(o=this.options.refresh)||void 0===o?void 0:o.time)&&void 0!==i?i:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Vt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Jt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}t("Auth",Kt);class Wt{constructor(t){this.transport=t}request(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:r,variables:void 0===s?{}:s})}))}items(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,r)}))}system(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,r)}))}}class Gt{constructor(t,e){this.collection=t,this.transport=e}read(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:r})).data}))}}t("Directus",class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new Xt(t,this._storage,(()=>e(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Kt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new n(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new i(this.transport))}get files(){return this._files||(this._files=new a(this.transport))}get folders(){return this._folders||(this._folders=new u(this.transport))}get permissions(){return this._permissions||(this._permissions=new h(this.transport))}get presets(){return this._presets||(this._presets=new d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new Wt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Gt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new r(t,this.transport))}})}}})); | ||
//# sourceMappingURL=sdk.system.min.js.map |
@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Directus={})}(this,(function(t){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,o){function i(t){try{u(s.next(t))}catch(t){o(t)}}function a(t){try{u(s.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}u((s=s.apply(t,e||[])).next())}))}class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}class o extends r{constructor(t){super("directus_collections",t)}}class i extends r{constructor(t){super("directus_fields",t)}}class a extends r{constructor(t){super("directus_files",t)}}class u extends r{constructor(t){super("directus_folders",t)}}class h extends r{constructor(t){super("directus_permissions",t)}}class d extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class f extends r{constructor(t){super("directus_roles",t)}}class p{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var T={exports:{}},S=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=S,O=Object.prototype.toString;function A(t){return"[object Array]"===O.call(t)}function C(t){return void 0===t}function U(t){return null!==t&&"object"==typeof t}function q(t){if("[object Object]"!==O.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===O.call(t)}function P(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),A(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var B={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===O.call(t)},isBuffer:function(t){return null!==t&&!C(t)&&null!==t.constructor&&!C(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:U,isPlainObject:q,isUndefined:C,isDate:function(t){return"[object Date]"===O.call(t)},isFile:function(t){return"[object File]"===O.call(t)},isBlob:function(t){return"[object Blob]"===O.call(t)},isFunction:N,isStream:function(t){return U(t)&&N(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:P,merge:function t(){var e={};function r(r,s){q(e[s])&&q(r)?e[s]=t(e[s],r):q(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)P(arguments[s],r);return e},extend:function(t,e,r){return P(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},H=B;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(H.isURLSearchParams(e))s=e.toString();else{var n=[];H.forEach(e,(function(t,e){null!=t&&(H.isArray(t)?e+="[]":t=[t],H.forEach(t,(function(t){H.isDate(t)?t=t.toISOString():H.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=B;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var F=D,M=B,z=function(t){return!(!t||!t.__CANCEL__)},X=B,J=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},V=function(t,e,r,s,n){var o=new Error(t);return J(o,e,r,s,n)},K=V,W=B,G=W.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),W.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),W.isString(s)&&i.push("path="+s),W.isString(n)&&i.push("domain="+n),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Q=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Y=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Z=B,tt=["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"],et=B,rt=et.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=et.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},st=B,nt=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(K("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ot=G,it=L,at=function(t,e){return t&&!Q(e)?Y(t,e):e},ut=function(t){var e,r,s,n={};return t?(Z.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Z.trim(t.substr(0,s)).toLowerCase(),r=Z.trim(t.substr(s+1)),e){if(n[e]&&tt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ht=rt,dt=V,ct=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;st.isFormData(s)&&delete n["Content-Type"];var o=new XMLHttpRequest;if(t.auth){var i=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(i+":"+a)}var u=at(t.baseURL,t.url);if(o.open(t.method.toUpperCase(),it(u,t.params,t.paramsSerializer),!0),o.timeout=t.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in o?ut(o.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:s,config:t,request:o};nt(e,r,n),o=null}},o.onabort=function(){o&&(r(dt("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(dt("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(dt(e,t,"ECONNABORTED",o)),o=null},st.isStandardBrowserEnv()){var h=(t.withCredentials||ht(u))&&t.xsrfCookieName?ot.read(t.xsrfCookieName):void 0;h&&(n[t.xsrfHeaderName]=h)}if("setRequestHeader"in o&&st.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:o.setRequestHeader(e,t)})),st.isUndefined(t.withCredentials)||(o.withCredentials=!!t.withCredentials),t.responseType)try{o.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&o.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){o&&(o.abort(),r(t),o=null)})),s||(s=null),o.send(s)}))},lt=B,ft=function(t,e){X.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},pt={"Content-Type":"application/x-www-form-urlencoded"};function vt(t,e){!lt.isUndefined(t)&<.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var mt,gt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(mt=ct),mt),transformRequest:[function(t,e){return ft(e,"Accept"),ft(e,"Content-Type"),lt.isFormData(t)||lt.isArrayBuffer(t)||lt.isBuffer(t)||lt.isStream(t)||lt.isFile(t)||lt.isBlob(t)?t:lt.isArrayBufferView(t)?t.buffer:lt.isURLSearchParams(t)?(vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):lt.isObject(t)?(vt(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};gt.headers={common:{Accept:"application/json, text/plain, */*"}},lt.forEach(["delete","get","head"],(function(t){gt.headers[t]={}})),lt.forEach(["post","put","patch"],(function(t){gt.headers[t]=lt.merge(pt)}));var yt=gt,_t=B,wt=function(t,e,r){return M.forEach(r,(function(r){t=r(t,e)})),t},xt=z,bt=yt;function kt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Rt=B,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function a(t,e){return Rt.isPlainObject(t)&&Rt.isPlainObject(e)?Rt.merge(t,e):Rt.isPlainObject(e)?Rt.merge({},e):Rt.isArray(e)?e.slice():e}function u(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}Rt.forEach(s,(function(t){Rt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),Rt.forEach(n,u),Rt.forEach(o,(function(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),Rt.forEach(i,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var h=s.concat(n).concat(o).concat(i),d=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return Rt.forEach(d,u),r},Tt=B,St=L,jt=F,Ot=function(t){return kt(t),t.headers=t.headers||{},t.data=wt(t.data,t.headers,t.transformRequest),t.headers=_t.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),_t.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||bt.adapter)(t).then((function(e){return kt(t),e.data=wt(e.data,e.headers,t.transformResponse),e}),(function(e){return xt(e)||(kt(t),e&&e.response&&(e.response.data=wt(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},At=Et;function Ct(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}Ct.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=At(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Ot,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},Ct.prototype.getUri=function(t){return t=At(this.defaults,t),St(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Tt.forEach(["delete","get","head","options"],(function(t){Ct.prototype[t]=function(e,r){return this.request(At(r||{},{method:t,url:e,data:(r||{}).data}))}})),Tt.forEach(["post","put","patch"],(function(t){Ct.prototype[t]=function(e,r,s){return this.request(At(s||{},{method:t,url:e,data:r}))}}));var Ut=Ct;function qt(t){this.message=t}qt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},qt.prototype.__CANCEL__=!0;var Nt=qt,Pt=Nt;function Bt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Pt(t),e(r.reason))}))}Bt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Bt.source=function(){var t;return{token:new Bt((function(e){t=e})),cancel:t}};var Ht=Bt,$t=B,Lt=S,It=Ut,Dt=Et;function Ft(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var Mt=Ft(yt);Mt.Axios=It,Mt.create=function(t){return Ft(Dt(Mt.defaults,t))},Mt.Cancel=Nt,Mt.CancelToken=Ht,Mt.isCancel=z,Mt.all=function(t){return Promise.all(t)},Mt.spread=function(t){return function(e){return t.apply(null,e)}},Mt.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},T.exports=Mt,T.exports.default=Mt;var zt=T.exports;class Xt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=zt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var o,i,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(o=n.sendAuthorizationHeaders)||void 0===o||o,n.refreshTokenIfNeeded=null===(i=n.refreshTokenIfNeeded)||void 0===i||i,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(zt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class Jt{constructor(t){this.transport=t}request(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:r})}))}reset(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:r})}))}}class Vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return e(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((e,r)=>{this.func(...t).then((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.resolve(t)))})).catch((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.reject(t)))}))})))}))}}class Kt{constructor(t,e,r){var s,n,o,i,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(i=null===(o=this.options.refresh)||void 0===o?void 0:o.time)&&void 0!==i?i:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Vt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Jt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class Wt{constructor(t){this.transport=t}request(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:r,variables:void 0===s?{}:s})}))}items(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,r)}))}system(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,r)}))}}class Gt{constructor(t,e){this.collection=t,this.transport=e}read(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:r})).data}))}}t.ActivityHandler=n,t.Auth=Kt,t.AxiosTransport=Xt,t.BaseStorage=k,t.CollectionsHandler=o,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new Xt(t,this._storage,(()=>e(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Kt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new n(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new i(this.transport))}get files(){return this._files||(this._files=new a(this.transport))}get folders(){return this._folders||(this._folders=new u(this.transport))}get permissions(){return this._permissions||(this._permissions=new h(this.transport))}get presets(){return this._presets||(this._presets=new d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new f(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new p(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new Wt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Gt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new r(t,this.transport))}},t.FieldsHandler=i,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=h,t.PresetsHandler=d,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=f,t.ServerHandler=p,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,o){function i(t){try{u(s.next(t))}catch(t){o(t)}}function a(t){try{u(s.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}u((s=s.apply(t,e||[])).next())}))}class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}class o extends r{constructor(t){super("directus_collections",t)}}class i extends r{constructor(t){super("directus_fields",t)}}class a extends r{constructor(t){super("directus_files",t)}}class u extends r{constructor(t){super("directus_folders",t)}}class d extends r{constructor(t){super("directus_permissions",t)}}class h extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class p extends r{constructor(t){super("directus_roles",t)}}class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var T={exports:{}},S=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=S,O=Object.prototype.toString;function A(t){return"[object Array]"===O.call(t)}function U(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function q(t){if("[object Object]"!==O.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===O.call(t)}function P(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),A(t))for(var r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.call(null,t[n],n,t)}var B={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===O.call(t)},isBuffer:function(t){return null!==t&&!U(t)&&null!==t.constructor&&!U(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:C,isPlainObject:q,isUndefined:U,isDate:function(t){return"[object Date]"===O.call(t)},isFile:function(t){return"[object File]"===O.call(t)},isBlob:function(t){return"[object Blob]"===O.call(t)},isFunction:N,isStream:function(t){return C(t)&&N(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:P,merge:function t(){var e={};function r(r,s){q(e[s])&&q(r)?e[s]=t(e[s],r):q(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)P(arguments[s],r);return e},extend:function(t,e,r){return P(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},H=B;function $(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var L=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(H.isURLSearchParams(e))s=e.toString();else{var n=[];H.forEach(e,(function(t,e){null!=t&&(H.isArray(t)?e+="[]":t=[t],H.forEach(t,(function(t){H.isDate(t)?t=t.toISOString():H.isObject(t)&&(t=JSON.stringify(t)),n.push($(e)+"="+$(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},I=B;function D(){this.handlers=[]}D.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},D.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},D.prototype.forEach=function(t){I.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var F=D,M=B,z=function(t){return!(!t||!t.__CANCEL__)},X=B,J=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.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}},t},V=function(t,e,r,s,n){var o=new Error(t);return J(o,e,r,s,n)},K=V,W=B,G=W.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),W.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),W.isString(s)&&i.push("path="+s),W.isString(n)&&i.push("domain="+n),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Q=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},Y=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Z=B,tt=["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"],et=B,rt=et.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function s(t){var s=t;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{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 t=s(window.location.href),function(e){var r=et.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},st=B,nt=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(K("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ot=G,it=L,at=function(t,e){return t&&!Q(e)?Y(t,e):e},ut=function(t){var e,r,s,n={};return t?(Z.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=Z.trim(t.substr(0,s)).toLowerCase(),r=Z.trim(t.substr(s+1)),e){if(n[e]&&tt.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},dt=rt,ht=V,ct=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;st.isFormData(s)&&delete n["Content-Type"];var o=new XMLHttpRequest;if(t.auth){var i=t.auth.username||"",a=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";n.Authorization="Basic "+btoa(i+":"+a)}var u=at(t.baseURL,t.url);if(o.open(t.method.toUpperCase(),it(u,t.params,t.paramsSerializer),!0),o.timeout=t.timeout,o.onreadystatechange=function(){if(o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in o?ut(o.getAllResponseHeaders()):null,n={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:s,config:t,request:o};nt(e,r,n),o=null}},o.onabort=function(){o&&(r(ht("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(ht("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(ht(e,t,"ECONNABORTED",o)),o=null},st.isStandardBrowserEnv()){var d=(t.withCredentials||dt(u))&&t.xsrfCookieName?ot.read(t.xsrfCookieName):void 0;d&&(n[t.xsrfHeaderName]=d)}if("setRequestHeader"in o&&st.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:o.setRequestHeader(e,t)})),st.isUndefined(t.withCredentials)||(o.withCredentials=!!t.withCredentials),t.responseType)try{o.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&o.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){o&&(o.abort(),r(t),o=null)})),s||(s=null),o.send(s)}))},lt=B,pt=function(t,e){X.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},ft={"Content-Type":"application/x-www-form-urlencoded"};function vt(t,e){!lt.isUndefined(t)&<.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var mt,gt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(mt=ct),mt),transformRequest:[function(t,e){return pt(e,"Accept"),pt(e,"Content-Type"),lt.isFormData(t)||lt.isArrayBuffer(t)||lt.isBuffer(t)||lt.isStream(t)||lt.isFile(t)||lt.isBlob(t)?t:lt.isArrayBufferView(t)?t.buffer:lt.isURLSearchParams(t)?(vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):lt.isObject(t)?(vt(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};gt.headers={common:{Accept:"application/json, text/plain, */*"}},lt.forEach(["delete","get","head"],(function(t){gt.headers[t]={}})),lt.forEach(["post","put","patch"],(function(t){gt.headers[t]=lt.merge(ft)}));var yt=gt,_t=B,wt=function(t,e,r){return M.forEach(r,(function(r){t=r(t,e)})),t},xt=z,bt=yt;function kt(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Rt=B,Et=function(t,e){e=e||{};var r={},s=["url","method","data"],n=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function a(t,e){return Rt.isPlainObject(t)&&Rt.isPlainObject(e)?Rt.merge(t,e):Rt.isPlainObject(e)?Rt.merge({},e):Rt.isArray(e)?e.slice():e}function u(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}Rt.forEach(s,(function(t){Rt.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),Rt.forEach(n,u),Rt.forEach(o,(function(s){Rt.isUndefined(e[s])?Rt.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),Rt.forEach(i,(function(s){s in e?r[s]=a(t[s],e[s]):s in t&&(r[s]=a(void 0,t[s]))}));var d=s.concat(n).concat(o).concat(i),h=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===d.indexOf(t)}));return Rt.forEach(h,u),r},Tt=B,St=L,jt=F,Ot=function(t){return kt(t),t.headers=t.headers||{},t.data=wt(t.data,t.headers,t.transformRequest),t.headers=_t.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),_t.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||bt.adapter)(t).then((function(e){return kt(t),e.data=wt(e.data,e.headers,t.transformResponse),e}),(function(e){return xt(e)||(kt(t),e&&e.response&&(e.response.data=wt(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},At=Et;function Ut(t){this.defaults=t,this.interceptors={request:new jt,response:new jt}}Ut.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=At(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Ot,void 0],r=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)r=r.then(e.shift(),e.shift());return r},Ut.prototype.getUri=function(t){return t=At(this.defaults,t),St(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Tt.forEach(["delete","get","head","options"],(function(t){Ut.prototype[t]=function(e,r){return this.request(At(r||{},{method:t,url:e,data:(r||{}).data}))}})),Tt.forEach(["post","put","patch"],(function(t){Ut.prototype[t]=function(e,r,s){return this.request(At(s||{},{method:t,url:e,data:r}))}}));var Ct=Ut;function qt(t){this.message=t}qt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},qt.prototype.__CANCEL__=!0;var Nt=qt,Pt=Nt;function Bt(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;t((function(t){r.reason||(r.reason=new Pt(t),e(r.reason))}))}Bt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Bt.source=function(){var t;return{token:new Bt((function(e){t=e})),cancel:t}};var Ht=Bt,$t=B,Lt=S,It=Ct,Dt=Et;function Ft(t){var e=new It(t),r=Lt(It.prototype.request,e);return $t.extend(r,It.prototype,e),$t.extend(r,e),r}var Mt=Ft(yt);Mt.Axios=It,Mt.create=function(t){return Ft(Dt(Mt.defaults,t))},Mt.Cancel=Nt,Mt.CancelToken=Ht,Mt.isCancel=z,Mt.all=function(t){return Promise.all(t)},Mt.spread=function(t){return function(e){return t.apply(null,e)}},Mt.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},T.exports=Mt,T.exports.default=Mt;var zt=T.exports;class Xt{constructor(t,e,r=(()=>Promise.resolve())){this._url=t,this._storage=e,this._axios=null,this._refresh=r,this.url=t}get url(){return this._url}set url(t){this._url=t,this._axios=zt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var o,i,a,u,d,h,c,l,p;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(o=n.sendAuthorizationHeaders)||void 0===o||o,n.refreshTokenIfNeeded=null===(i=n.refreshTokenIfNeeded)||void 0===i||i,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.onUploadProgress=null!==(u=n.onUploadProgress)&&void 0!==u?u:void 0,n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers,onUploadProgress:n.onUploadProgress},d=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&d&&(null!==h&&h>Date.now()||null===h)&&(d.startsWith("Bearer ")?e.headers.Authorization=d:e.headers.Authorization=`Bearer ${d}`);const c=yield this.axios.request(e),l=c.data,p={raw:c.data,status:c.status,statusText:c.statusText,headers:c.headers,data:l.data,meta:l.meta,errors:l.errors};if(l.errors)throw new b(null,p);return p}catch(t){if(zt.isAxiosError(t)){const e=null===(d=t.response)||void 0===d?void 0:d.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(c=t.response)||void 0===c?void 0:c.status,statusText:null===(l=t.response)||void 0===l?void 0:l.statusText,headers:null===(p=t.response)||void 0===p?void 0:p.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class Jt{constructor(t){this.transport=t}request(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:r})}))}reset(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:r})}))}}class Vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return e(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((e,r)=>{this.func(...t).then((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.resolve(t)))})).catch((t=>{const s=[{resolve:e,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((e=>e.reject(t)))}))})))}))}}class Kt{constructor(t,e,r){var s,n,o,i,a;this.options=r||{},this.options.mode=(null==r?void 0:r.mode)||("undefined"!=typeof window?"cookie":"json"),this.options.refresh=(null==r?void 0:r.refresh)||{auto:!1,time:3e4},this.options.refresh.auto=null!==(n=null===(s=this.options.refresh)||void 0===s?void 0:s.auto)&&void 0!==n&&n,this.options.refresh.time=null!==(i=null===(o=this.options.refresh)||void 0===o?void 0:o.time)&&void 0!==i?i:3e4,this.transport=t,this.storage=e,this.timer=!1,this.refresher=new Vt(this.refreshToken.bind(this));try{this.updateRefresh(null===(a=this.options)||void 0===a?void 0:a.refresh)}catch(t){}}get token(){return this.storage.auth_token}get password(){return this.passwords=this.passwords||new Jt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class Wt{constructor(t){this.transport=t}request(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:r,variables:void 0===s?{}:s})}))}items(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,r)}))}system(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,r)}))}}class Gt{constructor(t,e){this.collection=t,this.transport=e}read(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:r})).data}))}}t.ActivityHandler=n,t.Auth=Kt,t.AxiosTransport=Xt,t.BaseStorage=k,t.CollectionsHandler=o,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new Xt(t,this._storage,(()=>e(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new Kt(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new n(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new i(this.transport))}get files(){return this._files||(this._files=new a(this.transport))}get folders(){return this._folders||(this._folders=new u(this.transport))}get permissions(){return this._permissions||(this._permissions=new d(this.transport))}get presets(){return this._presets||(this._presets=new h(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new Wt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new Gt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new r(t,this.transport))}},t.FieldsHandler=i,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=d,t.PresetsHandler=h,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=p,t.ServerHandler=f,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=sdk.umd.min.js.map |
@@ -23,2 +23,3 @@ import { ItemMetadata } from './items'; | ||
sendAuthorizationHeaders?: boolean; | ||
onUploadProgress?: ((progressEvent: any) => void) | undefined; | ||
}; | ||
@@ -25,0 +26,0 @@ export interface ITransport { |
{ | ||
"name": "@directus/sdk", | ||
"version": "9.0.0-rc.71", | ||
"version": "9.0.0-rc.72", | ||
"description": "The official Directus SDK for use in JavaScript!", | ||
@@ -54,3 +54,3 @@ "repository": { | ||
"@types/jest": "^26.0.22", | ||
"argon2": "^0.27.1", | ||
"argon2": "^0.28.1", | ||
"dotenv": "^9.0.2", | ||
@@ -73,3 +73,3 @@ "jest": "^27.0.3", | ||
}, | ||
"gitHead": "44e443bf99cbf1370aea35b39357ec2287d46d1f" | ||
"gitHead": "2f0099e0db2777ec29b5dc6a46f604f70870ec8e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1290050
11403