@directus/sdk
Advanced tools
Comparing version 9.0.0-rc.60 to 9.0.0-rc.61
@@ -63,3 +63,3 @@ "use strict"; | ||
if (options.sendAuthorizationHeaders) { | ||
if (token && ((expiration !== null && expiration < Date.now()) || expiration === null)) { | ||
if (token && ((expiration !== null && expiration > Date.now()) || expiration === null)) { | ||
if (token.startsWith(`Bearer `)) { | ||
@@ -66,0 +66,0 @@ config.headers.Authorization = token; |
@@ -15,3 +15,3 @@ class t extends Error{constructor(){super("No authentication")}} | ||
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){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:r})}))}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 c extends r{constructor(t){super("directus_presets",t)}}class d 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;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(x||(x={}));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 E 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 R 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=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=Object.prototype.toString;function O(t){return"[object Array]"===j.call(t)}function S(t){return void 0===t}function A(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==j.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function q(t){return"[object Function]"===j.call(t)}function N(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 U={isArray:O,isArrayBuffer:function(t){return"[object ArrayBuffer]"===j.call(t)},isBuffer:function(t){return null!==t&&!S(t)&&null!==t.constructor&&!S(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:S,isDate:function(t){return"[object Date]"===j.call(t)},isFile:function(t){return"[object File]"===j.call(t)},isBlob:function(t){return"[object Blob]"===j.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):O(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?T(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}};function B(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var P=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(U.isURLSearchParams(e))s=e.toString();else{var n=[];U.forEach(e,(function(t,e){null!=t&&(U.isArray(t)?e+="[]":t=[t],U.forEach(t,(function(t){U.isDate(t)?t=t.toISOString():U.isObject(t)&&(t=JSON.stringify(t)),n.push(B(e)+"="+B(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){U.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return U.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},z=function(t,e){U.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},F=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},H=U.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),U.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),U.isString(s)&&o.push("path="+s),U.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(){}},M=["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"],X=U.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=U.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},J=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;U.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,h,c=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(i.open(t.method.toUpperCase(),P(c,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,n,o,a,u,h="getAllResponseHeaders"in i?(s=i.getAllResponseHeaders(),u={},s?(U.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=U.trim(t.substr(0,a)).toLowerCase(),o=U.trim(t.substr(a+1)),n){if(u[n]&&M.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([o]):u[n]?u[n]+", "+o:o}})),u):u):null,c={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:t,request:i};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(F("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,c),i=null}},i.onabort=function(){i&&(r(F("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(F("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(F(e,t,"ECONNABORTED",i)),i=null},U.isStandardBrowserEnv()){var d=(t.withCredentials||X(c))&&t.xsrfCookieName?H.read(t.xsrfCookieName):void 0;d&&(n[t.xsrfHeaderName]=d)}if("setRequestHeader"in i&&U.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),U.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)}))},V={"Content-Type":"application/x-www-form-urlencoded"};function K(t,e){!U.isUndefined(t)&&U.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var W,G={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(W=J),W),transformRequest:[function(t,e){return z(e,"Accept"),z(e,"Content-Type"),U.isFormData(t)||U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)?t:U.isArrayBufferView(t)?t.buffer:U.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):U.isObject(t)?(K(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}};G.headers={common:{Accept:"application/json, text/plain, */*"}},U.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),U.forEach(["post","put","patch"],(function(t){G.headers[t]=U.merge(V)}));var Q=G;function Y(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Z=function(t){return Y(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=U.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),U.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Q.adapter)(t).then((function(e){return Y(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Y(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},tt=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 U.isPlainObject(t)&&U.isPlainObject(e)?U.merge(t,e):U.isPlainObject(e)?U.merge({},e):U.isArray(e)?e.slice():e}function u(s){U.isUndefined(e[s])?U.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}U.forEach(s,(function(t){U.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),U.forEach(n,u),U.forEach(i,(function(s){U.isUndefined(e[s])?U.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),U.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 U.forEach(c,u),r};function et(t){this.defaults=t,this.interceptors={request:new L,response:new L}}et.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=tt(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Z,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},et.prototype.getUri=function(t){return t=tt(this.defaults,t),P(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},U.forEach(["delete","get","head","options"],(function(t){et.prototype[t]=function(e,r){return this.request(tt(r||{},{method:t,url:e,data:(r||{}).data}))}})),U.forEach(["post","put","patch"],(function(t){et.prototype[t]=function(e,r,s){return this.request(tt(s||{},{method:t,url:e,data:r}))}}));var rt=et;function st(t){this.message=t}st.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},st.prototype.__CANCEL__=!0;var nt=st;function it(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))}))}it.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},it.source=function(){var t;return{token:new it((function(e){t=e})),cancel:t}};var ot=it;function at(t){var e=new rt(t),r=T(rt.prototype.request,e);return U.extend(r,rt.prototype,e),U.extend(r,e),r}var ut=at(Q);ut.Axios=rt,ut.create=function(t){return at(tt(ut.defaults,t))},ut.Cancel=nt,ut.CancelToken=ot,ut.isCancel=D,ut.all=function(t){return Promise.all(t)},ut.spread=function(t){return function(e){return t.apply(null,e)}},ut.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var ht=ut,ct=ut;ht.default=ct;var dt=ht;class lt{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=dt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,c,d,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 c=yield this.axios.request(e),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 b(null,l);return l}catch(t){if(dt.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===(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 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 pt{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 ft{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 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 ft(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 pt(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(r=!1){var s;return e(this,void 0,void 0,(function*(){if(r&&null===this.storage.auth_token)throw new t;if(!r&&!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===(s=e.data)||void 0===s?void 0:s.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),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 mt{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}))}}class yt{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new R:new E),this._transport=(null==r?void 0:r.transport)||new lt(t,this._storage,(()=>e(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 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 c(this.transport))}get relations(){return this._relations||(this._relations=new d(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 mt(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))}}export{n as ActivityHandler,vt as Auth,lt as AxiosTransport,k as BaseStorage,i as CollectionsHandler,s as CommentsHandler,yt as Directus,o as FieldsHandler,a as FilesHandler,u as FoldersHandler,r as ItemsHandler,R as LocalStorage,E as MemoryStorage,x as Meta,t as NotAuthenticated,h as PermissionsHandler,c as PresetsHandler,d as RelationsHandler,l as RevisionsHandler,p as RolesHandler,f as ServerHandler,v as SettingsHandler,b as TransportError,_ as UsersHandler,w as UtilsHandler}; | ||
***************************************************************************** */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){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:r})}))}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 c extends r{constructor(t){super("directus_presets",t)}}class d 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;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(x||(x={}));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 E 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 R 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=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=Object.prototype.toString;function O(t){return"[object Array]"===j.call(t)}function S(t){return void 0===t}function A(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==j.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function q(t){return"[object Function]"===j.call(t)}function N(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 U={isArray:O,isArrayBuffer:function(t){return"[object ArrayBuffer]"===j.call(t)},isBuffer:function(t){return null!==t&&!S(t)&&null!==t.constructor&&!S(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:S,isDate:function(t){return"[object Date]"===j.call(t)},isFile:function(t){return"[object File]"===j.call(t)},isBlob:function(t){return"[object Blob]"===j.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):O(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?T(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}};function B(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var P=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(U.isURLSearchParams(e))s=e.toString();else{var n=[];U.forEach(e,(function(t,e){null!=t&&(U.isArray(t)?e+="[]":t=[t],U.forEach(t,(function(t){U.isDate(t)?t=t.toISOString():U.isObject(t)&&(t=JSON.stringify(t)),n.push(B(e)+"="+B(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){U.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return U.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},z=function(t,e){U.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},F=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},H=U.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),U.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),U.isString(s)&&o.push("path="+s),U.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(){}},M=["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"],X=U.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=U.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},J=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;U.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,h,c=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(i.open(t.method.toUpperCase(),P(c,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,n,o,a,u,h="getAllResponseHeaders"in i?(s=i.getAllResponseHeaders(),u={},s?(U.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=U.trim(t.substr(0,a)).toLowerCase(),o=U.trim(t.substr(a+1)),n){if(u[n]&&M.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([o]):u[n]?u[n]+", "+o:o}})),u):u):null,c={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:t,request:i};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(F("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,c),i=null}},i.onabort=function(){i&&(r(F("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(F("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(F(e,t,"ECONNABORTED",i)),i=null},U.isStandardBrowserEnv()){var d=(t.withCredentials||X(c))&&t.xsrfCookieName?H.read(t.xsrfCookieName):void 0;d&&(n[t.xsrfHeaderName]=d)}if("setRequestHeader"in i&&U.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),U.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)}))},V={"Content-Type":"application/x-www-form-urlencoded"};function K(t,e){!U.isUndefined(t)&&U.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var W,G={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(W=J),W),transformRequest:[function(t,e){return z(e,"Accept"),z(e,"Content-Type"),U.isFormData(t)||U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)?t:U.isArrayBufferView(t)?t.buffer:U.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):U.isObject(t)?(K(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}};G.headers={common:{Accept:"application/json, text/plain, */*"}},U.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),U.forEach(["post","put","patch"],(function(t){G.headers[t]=U.merge(V)}));var Q=G;function Y(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Z=function(t){return Y(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=U.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),U.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Q.adapter)(t).then((function(e){return Y(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Y(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},tt=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 U.isPlainObject(t)&&U.isPlainObject(e)?U.merge(t,e):U.isPlainObject(e)?U.merge({},e):U.isArray(e)?e.slice():e}function u(s){U.isUndefined(e[s])?U.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}U.forEach(s,(function(t){U.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),U.forEach(n,u),U.forEach(i,(function(s){U.isUndefined(e[s])?U.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),U.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 U.forEach(c,u),r};function et(t){this.defaults=t,this.interceptors={request:new L,response:new L}}et.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=tt(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Z,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},et.prototype.getUri=function(t){return t=tt(this.defaults,t),P(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},U.forEach(["delete","get","head","options"],(function(t){et.prototype[t]=function(e,r){return this.request(tt(r||{},{method:t,url:e,data:(r||{}).data}))}})),U.forEach(["post","put","patch"],(function(t){et.prototype[t]=function(e,r,s){return this.request(tt(s||{},{method:t,url:e,data:r}))}}));var rt=et;function st(t){this.message=t}st.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},st.prototype.__CANCEL__=!0;var nt=st;function it(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))}))}it.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},it.source=function(){var t;return{token:new it((function(e){t=e})),cancel:t}};var ot=it;function at(t){var e=new rt(t),r=T(rt.prototype.request,e);return U.extend(r,rt.prototype,e),U.extend(r,e),r}var ut=at(Q);ut.Axios=rt,ut.create=function(t){return at(tt(ut.defaults,t))},ut.Cancel=nt,ut.CancelToken=ot,ut.isCancel=D,ut.all=function(t){return Promise.all(t)},ut.spread=function(t){return function(e){return t.apply(null,e)}},ut.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var ht=ut,ct=ut;ht.default=ct;var dt=ht;class lt{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=dt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,c,d,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 c=yield this.axios.request(e),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 b(null,l);return l}catch(t){if(dt.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===(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 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 pt{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 ft{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 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 ft(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 pt(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(r=!1){var s;return e(this,void 0,void 0,(function*(){if(r&&null===this.storage.auth_token)throw new t;if(!r&&!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===(s=e.data)||void 0===s?void 0:s.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),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 mt{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}))}}class yt{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new R:new E),this._transport=(null==r?void 0:r.transport)||new lt(t,this._storage,(()=>e(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 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 c(this.transport))}get relations(){return this._relations||(this._relations=new d(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 mt(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))}}export{n as ActivityHandler,vt as Auth,lt as AxiosTransport,k as BaseStorage,i as CollectionsHandler,s as CommentsHandler,yt as Directus,o as FieldsHandler,a as FilesHandler,u as FoldersHandler,r as ItemsHandler,R as LocalStorage,E as MemoryStorage,x as Meta,t as NotAuthenticated,h as PermissionsHandler,c as PresetsHandler,d as RelationsHandler,l as RevisionsHandler,p as RolesHandler,f as ServerHandler,v as SettingsHandler,b as TransportError,_ as UsersHandler,w as UtilsHandler}; | ||
//# sourceMappingURL=sdk.esm.min.js.map |
@@ -15,3 +15,3 @@ var Directus=function(t){"use strict";class e extends Error{constructor(){super("No authentication")}} | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function r(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 s{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e})).data}))}readMany(t){return r(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,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:e})).data}))}createMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:e})}))}updateOne(t,e,s){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:s})).data}))}updateMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:e})}))}deleteOne(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class n{constructor(t){this.transport=t}create(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}))}delete(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class i extends s{constructor(t){super("directus_activity",t),this._comments=new n(this.transport)}get comments(){return this._comments}}class o extends s{constructor(t){super("directus_collections",t)}}class a extends s{constructor(t){super("directus_fields",t)}}class u extends s{constructor(t){super("directus_files",t)}}class h extends s{constructor(t){super("directus_folders",t)}}class d extends s{constructor(t){super("directus_permissions",t)}}class c extends s{constructor(t){super("directus_presets",t)}}class l extends s{constructor(t){super("directus_relations",t)}}class p extends s{constructor(t){super("directus_revisions",t)}}class f extends s{constructor(t){super("directus_roles",t)}}class v{constructor(t){this.transport=t}ping(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class m extends s{constructor(t){super("directus_settings",t)}}class g{constructor(t){this.transport=t}send(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:e})}))}accept(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:e})}))}}class y{constructor(t){this.transport=t}enable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class _{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new y(this._transport))}read(t){return r(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:e})).data}))}}class w extends s{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new g(this.transport))}get me(){return this._me||(this._me=new _(this.transport))}}class x{constructor(t){this.random={string:(t=32)=>r(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,e)=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:e})).data}))},this.transport=t}sort(t,e,s){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:s})}))}revert(t){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var b;t.Meta=void 0,(b=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",b.FILTER_COUNT="filter_count";class k 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,k.prototype)}}class E{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 E{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 S extends E{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=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=Object.prototype.toString;function A(t){return"[object Array]"===j.call(t)}function O(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function U(t){if("[object Object]"!==j.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===j.call(t)}function q(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 P={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===j.call(t)},isBuffer:function(t){return null!==t&&!O(t)&&null!==t.constructor&&!O(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:U,isUndefined:O,isDate:function(t){return"[object Date]"===j.call(t)},isFile:function(t){return"[object File]"===j.call(t)},isBlob:function(t){return"[object Blob]"===j.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:q,merge:function t(){var e={};function r(r,s){U(e[s])&&U(r)?e[s]=t(e[s],r):U(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)q(arguments[s],r);return e},extend:function(t,e,r){return q(e,(function(e,s){t[s]=r&&"function"==typeof e?T(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}};function B(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var H=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(B(e)+"="+B(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){P.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return P.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},F=function(t,e){P.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},M=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},z=P.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),P.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),P.isString(s)&&o.push("path="+s),P.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(){}},X=["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"],J=P.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=P.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},V=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;P.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,h,d=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(i.open(t.method.toUpperCase(),H(d,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,n,o,a,u,h="getAllResponseHeaders"in i?(s=i.getAllResponseHeaders(),u={},s?(P.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=P.trim(t.substr(0,a)).toLowerCase(),o=P.trim(t.substr(a+1)),n){if(u[n]&&X.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([o]):u[n]?u[n]+", "+o:o}})),u):u):null,d={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:t,request:i};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(M("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,d),i=null}},i.onabort=function(){i&&(r(M("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(M("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(M(e,t,"ECONNABORTED",i)),i=null},P.isStandardBrowserEnv()){var c=(t.withCredentials||J(d))&&t.xsrfCookieName?z.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&P.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),P.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)}))},K={"Content-Type":"application/x-www-form-urlencoded"};function W(t,e){!P.isUndefined(t)&&P.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var G,Q={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(G=V),G),transformRequest:[function(t,e){return F(e,"Accept"),F(e,"Content-Type"),P.isFormData(t)||P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)?t:P.isArrayBufferView(t)?t.buffer:P.isURLSearchParams(t)?(W(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):P.isObject(t)?(W(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}};Q.headers={common:{Accept:"application/json, text/plain, */*"}},P.forEach(["delete","get","head"],(function(t){Q.headers[t]={}})),P.forEach(["post","put","patch"],(function(t){Q.headers[t]=P.merge(K)}));var Y=Q;function Z(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var tt=function(t){return Z(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=P.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),P.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Y.adapter)(t).then((function(e){return Z(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Z(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},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 P.isPlainObject(t)&&P.isPlainObject(e)?P.merge(t,e):P.isPlainObject(e)?P.merge({},e):P.isArray(e)?e.slice():e}function u(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}P.forEach(s,(function(t){P.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),P.forEach(n,u),P.forEach(i,(function(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),P.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 P.forEach(d,u),r};function rt(t){this.defaults=t,this.interceptors={request:new L,response:new L}}rt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=et(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[tt,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},rt.prototype.getUri=function(t){return t=et(this.defaults,t),H(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},P.forEach(["delete","get","head","options"],(function(t){rt.prototype[t]=function(e,r){return this.request(et(r||{},{method:t,url:e,data:(r||{}).data}))}})),P.forEach(["post","put","patch"],(function(t){rt.prototype[t]=function(e,r,s){return this.request(et(s||{},{method:t,url:e,data:r}))}}));var st=rt;function nt(t){this.message=t}nt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},nt.prototype.__CANCEL__=!0;var it=nt;function ot(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 it(t),e(r.reason))}))}ot.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ot.source=function(){var t;return{token:new ot((function(e){t=e})),cancel:t}};var at=ot;function ut(t){var e=new st(t),r=T(st.prototype.request,e);return P.extend(r,st.prototype,e),P.extend(r,e),r}var ht=ut(Y);ht.Axios=st,ht.create=function(t){return ut(et(ht.defaults,t))},ht.Cancel=it,ht.CancelToken=at,ht.isCancel=D,ht.all=function(t){return Promise.all(t)},ht.spread=function(t){return function(e){return t.apply(null,e)}},ht.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var dt=ht,ct=ht;dt.default=ct;var lt=dt;class pt{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=lt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,e,s,n){var i,o,a,u,h,d,c,l;return r(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 r={method:t,url:e,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 ")?r.headers.Authorization=u:r.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(r),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 k(null,l);return l}catch(t){if(lt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new k(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 k(t)}}))}get(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,e)}))}head(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,e)}))}options(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,e)}))}delete(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("delete",t,e,s)}))}put(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("put",t,e,s)}))}post(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("post",t,e,s)}))}patch(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("patch",t,e,s)}))}}class ft{constructor(t){this.transport=t}request(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:e})}))}reset(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:e})}))}}class vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return r(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 mt{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 ft(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 s;return r(this,void 0,void 0,(function*(){if(t&&null===this.storage.auth_token)throw new e;if(!t&&!this.expiring)return!1;const r=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(r.data),this.updateRefresh(),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),n))}refresh(t=!1){return r(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,e){var s;return r(this,void 0,void 0,(function*(){e=e||{};const r=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(r.data),this.updateRefresh(e.refresh),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.data.expires}}))}static(t){return r(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 r(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 gt{constructor(t){this.transport=t}request(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:e,variables:void 0===s?{}:s})}))}items(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,e)}))}system(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,e)}))}}class yt{constructor(t,e){this.collection=t,this.transport=e}read(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:e})).data}))}}return t.ActivityHandler=i,t.Auth=mt,t.AxiosTransport=pt,t.BaseStorage=E,t.CollectionsHandler=o,t.CommentsHandler=n,t.Directus=class{constructor(t,e){this._storage=(null==e?void 0:e.storage)||("undefined"!=typeof window?new S:new R),this._transport=(null==e?void 0:e.transport)||new pt(t,this._storage,(()=>r(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==e?void 0:e.auth)||new mt(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 i(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new u(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new d(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new l(this.transport))}get revisions(){return this._revisions||(this._revisions=new p(this.transport))}get roles(){return this._roles||(this._roles=new f(this.transport))}get settings(){return this._settings||(this._settings=new m(this.transport))}get users(){return this._users||(this._users=new w(this.transport))}get server(){return this._server||(this._server=new v(this.transport))}get utils(){return this._utils||(this._utils=new x(this.transport))}get graphql(){return this._graphql||(this._graphql=new gt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new yt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new s(t,this.transport))}},t.FieldsHandler=a,t.FilesHandler=u,t.FoldersHandler=h,t.ItemsHandler=s,t.LocalStorage=S,t.MemoryStorage=R,t.NotAuthenticated=e,t.PermissionsHandler=d,t.PresetsHandler=c,t.RelationsHandler=l,t.RevisionsHandler=p,t.RolesHandler=f,t.ServerHandler=v,t.SettingsHandler=m,t.TransportError=k,t.UsersHandler=w,t.UtilsHandler=x,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
***************************************************************************** */function r(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 s{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e})).data}))}readMany(t){return r(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,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:e})).data}))}createMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:e})}))}updateOne(t,e,s){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:s})).data}))}updateMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:e})}))}deleteOne(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class n{constructor(t){this.transport=t}create(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}))}delete(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class i extends s{constructor(t){super("directus_activity",t),this._comments=new n(this.transport)}get comments(){return this._comments}}class o extends s{constructor(t){super("directus_collections",t)}}class a extends s{constructor(t){super("directus_fields",t)}}class u extends s{constructor(t){super("directus_files",t)}}class h extends s{constructor(t){super("directus_folders",t)}}class d extends s{constructor(t){super("directus_permissions",t)}}class c extends s{constructor(t){super("directus_presets",t)}}class l extends s{constructor(t){super("directus_relations",t)}}class p extends s{constructor(t){super("directus_revisions",t)}}class f extends s{constructor(t){super("directus_roles",t)}}class v{constructor(t){this.transport=t}ping(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class m extends s{constructor(t){super("directus_settings",t)}}class g{constructor(t){this.transport=t}send(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:e})}))}accept(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:e})}))}}class y{constructor(t){this.transport=t}enable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class _{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new y(this._transport))}read(t){return r(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:e})).data}))}}class w extends s{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new g(this.transport))}get me(){return this._me||(this._me=new _(this.transport))}}class x{constructor(t){this.random={string:(t=32)=>r(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,e)=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:e})).data}))},this.transport=t}sort(t,e,s){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:s})}))}revert(t){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var b;t.Meta=void 0,(b=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",b.FILTER_COUNT="filter_count";class k 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,k.prototype)}}class E{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 E{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 S extends E{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=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=Object.prototype.toString;function A(t){return"[object Array]"===j.call(t)}function O(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function U(t){if("[object Object]"!==j.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===j.call(t)}function q(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 P={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===j.call(t)},isBuffer:function(t){return null!==t&&!O(t)&&null!==t.constructor&&!O(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:U,isUndefined:O,isDate:function(t){return"[object Date]"===j.call(t)},isFile:function(t){return"[object File]"===j.call(t)},isBlob:function(t){return"[object Blob]"===j.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:q,merge:function t(){var e={};function r(r,s){U(e[s])&&U(r)?e[s]=t(e[s],r):U(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)q(arguments[s],r);return e},extend:function(t,e,r){return q(e,(function(e,s){t[s]=r&&"function"==typeof e?T(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}};function B(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var H=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(B(e)+"="+B(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){P.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return P.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},F=function(t,e){P.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},M=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},z=P.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),P.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),P.isString(s)&&o.push("path="+s),P.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(){}},X=["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"],J=P.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=P.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},V=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;P.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,h,d=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(i.open(t.method.toUpperCase(),H(d,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,n,o,a,u,h="getAllResponseHeaders"in i?(s=i.getAllResponseHeaders(),u={},s?(P.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=P.trim(t.substr(0,a)).toLowerCase(),o=P.trim(t.substr(a+1)),n){if(u[n]&&X.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([o]):u[n]?u[n]+", "+o:o}})),u):u):null,d={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:t,request:i};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(M("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,d),i=null}},i.onabort=function(){i&&(r(M("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(M("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(M(e,t,"ECONNABORTED",i)),i=null},P.isStandardBrowserEnv()){var c=(t.withCredentials||J(d))&&t.xsrfCookieName?z.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&P.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),P.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)}))},K={"Content-Type":"application/x-www-form-urlencoded"};function W(t,e){!P.isUndefined(t)&&P.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var G,Q={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(G=V),G),transformRequest:[function(t,e){return F(e,"Accept"),F(e,"Content-Type"),P.isFormData(t)||P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)?t:P.isArrayBufferView(t)?t.buffer:P.isURLSearchParams(t)?(W(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):P.isObject(t)?(W(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}};Q.headers={common:{Accept:"application/json, text/plain, */*"}},P.forEach(["delete","get","head"],(function(t){Q.headers[t]={}})),P.forEach(["post","put","patch"],(function(t){Q.headers[t]=P.merge(K)}));var Y=Q;function Z(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var tt=function(t){return Z(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=P.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),P.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Y.adapter)(t).then((function(e){return Z(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Z(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},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 P.isPlainObject(t)&&P.isPlainObject(e)?P.merge(t,e):P.isPlainObject(e)?P.merge({},e):P.isArray(e)?e.slice():e}function u(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}P.forEach(s,(function(t){P.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),P.forEach(n,u),P.forEach(i,(function(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),P.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 P.forEach(d,u),r};function rt(t){this.defaults=t,this.interceptors={request:new L,response:new L}}rt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=et(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[tt,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},rt.prototype.getUri=function(t){return t=et(this.defaults,t),H(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},P.forEach(["delete","get","head","options"],(function(t){rt.prototype[t]=function(e,r){return this.request(et(r||{},{method:t,url:e,data:(r||{}).data}))}})),P.forEach(["post","put","patch"],(function(t){rt.prototype[t]=function(e,r,s){return this.request(et(s||{},{method:t,url:e,data:r}))}}));var st=rt;function nt(t){this.message=t}nt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},nt.prototype.__CANCEL__=!0;var it=nt;function ot(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 it(t),e(r.reason))}))}ot.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ot.source=function(){var t;return{token:new ot((function(e){t=e})),cancel:t}};var at=ot;function ut(t){var e=new st(t),r=T(st.prototype.request,e);return P.extend(r,st.prototype,e),P.extend(r,e),r}var ht=ut(Y);ht.Axios=st,ht.create=function(t){return ut(et(ht.defaults,t))},ht.Cancel=it,ht.CancelToken=at,ht.isCancel=D,ht.all=function(t){return Promise.all(t)},ht.spread=function(t){return function(e){return t.apply(null,e)}},ht.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var dt=ht,ct=ht;dt.default=ct;var lt=dt;class pt{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=lt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,e,s,n){var i,o,a,u,h,d,c,l;return r(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 r={method:t,url:e,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 ")?r.headers.Authorization=u:r.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(r),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 k(null,l);return l}catch(t){if(lt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new k(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 k(t)}}))}get(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,e)}))}head(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,e)}))}options(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,e)}))}delete(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("delete",t,e,s)}))}put(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("put",t,e,s)}))}post(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("post",t,e,s)}))}patch(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("patch",t,e,s)}))}}class ft{constructor(t){this.transport=t}request(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:e})}))}reset(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:e})}))}}class vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return r(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 mt{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 ft(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 s;return r(this,void 0,void 0,(function*(){if(t&&null===this.storage.auth_token)throw new e;if(!t&&!this.expiring)return!1;const r=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(r.data),this.updateRefresh(),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),n))}refresh(t=!1){return r(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,e){var s;return r(this,void 0,void 0,(function*(){e=e||{};const r=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(r.data),this.updateRefresh(e.refresh),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.data.expires}}))}static(t){return r(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 r(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 gt{constructor(t){this.transport=t}request(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:e,variables:void 0===s?{}:s})}))}items(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,e)}))}system(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,e)}))}}class yt{constructor(t,e){this.collection=t,this.transport=e}read(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:e})).data}))}}return t.ActivityHandler=i,t.Auth=mt,t.AxiosTransport=pt,t.BaseStorage=E,t.CollectionsHandler=o,t.CommentsHandler=n,t.Directus=class{constructor(t,e){this._storage=(null==e?void 0:e.storage)||("undefined"!=typeof window?new S:new R),this._transport=(null==e?void 0:e.transport)||new pt(t,this._storage,(()=>r(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==e?void 0:e.auth)||new mt(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 i(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new u(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new d(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new l(this.transport))}get revisions(){return this._revisions||(this._revisions=new p(this.transport))}get roles(){return this._roles||(this._roles=new f(this.transport))}get settings(){return this._settings||(this._settings=new m(this.transport))}get users(){return this._users||(this._users=new w(this.transport))}get server(){return this._server||(this._server=new v(this.transport))}get utils(){return this._utils||(this._utils=new x(this.transport))}get graphql(){return this._graphql||(this._graphql=new gt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new yt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new s(t,this.transport))}},t.FieldsHandler=a,t.FilesHandler=u,t.FoldersHandler=h,t.ItemsHandler=s,t.LocalStorage=S,t.MemoryStorage=R,t.NotAuthenticated=e,t.PermissionsHandler=d,t.PresetsHandler=c,t.RelationsHandler=l,t.RevisionsHandler=p,t.RolesHandler=f,t.ServerHandler=v,t.SettingsHandler=m,t.TransportError=k,t.UsersHandler=w,t.UtilsHandler=x,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(){t("Meta",void 0);class e extends Error{constructor(){super("No authentication")}} | ||
***************************************************************************** */ | ||
function r(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("NotAuthenticated",e);class s{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e})).data}))}readMany(t){return r(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,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:e})).data}))}createMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:e})}))}updateOne(t,e,s){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:s})).data}))}updateMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:e})}))}deleteOne(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}t("ItemsHandler",s);class n{constructor(t){this.transport=t}create(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}))}delete(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}t("CommentsHandler",n);class i extends s{constructor(t){super("directus_activity",t),this._comments=new n(this.transport)}get comments(){return this._comments}}t("ActivityHandler",i);class o extends s{constructor(t){super("directus_collections",t)}}t("CollectionsHandler",o);class a extends s{constructor(t){super("directus_fields",t)}}t("FieldsHandler",a);class u extends s{constructor(t){super("directus_files",t)}}t("FilesHandler",u);class h extends s{constructor(t){super("directus_folders",t)}}t("FoldersHandler",h);class d extends s{constructor(t){super("directus_permissions",t)}}t("PermissionsHandler",d);class c extends s{constructor(t){super("directus_presets",t)}}t("PresetsHandler",c);class l extends s{constructor(t){super("directus_relations",t)}}t("RelationsHandler",l);class p extends s{constructor(t){super("directus_revisions",t)}}t("RevisionsHandler",p);class f extends s{constructor(t){super("directus_roles",t)}}t("RolesHandler",f);class v{constructor(t){this.transport=t}ping(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}t("ServerHandler",v);class m extends s{constructor(t){super("directus_settings",t)}}t("SettingsHandler",m);class g{constructor(t){this.transport=t}send(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:e})}))}accept(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:e})}))}}class y{constructor(t){this.transport=t}enable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class _{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new y(this._transport))}read(t){return r(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:e})).data}))}}class w extends s{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new g(this.transport))}get me(){return this._me||(this._me=new _(this.transport))}}t("UsersHandler",w);class x{constructor(t){this.random={string:(t=32)=>r(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,e)=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:e})).data}))},this.transport=t}sort(t,e,s){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:s})}))}revert(t){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var b;t("UtilsHandler",x),function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(b||(b=t("Meta",{})));class k 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,k.prototype)}}t("TransportError",k);class E{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",E);class R extends E{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 S extends E{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",S);var 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)}},A=Object.prototype.toString;function j(t){return"[object Array]"===A.call(t)}function O(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function U(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 q(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),j(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:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===A.call(t)},isBuffer:function(t){return null!==t&&!O(t)&&null!==t.constructor&&!O(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:U,isUndefined:O,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:q,merge:function t(){var e={};function r(r,s){U(e[s])&&U(r)?e[s]=t(e[s],r):U(r)?e[s]=t({},r):j(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)q(arguments[s],r);return e},extend:function(t,e,r){return q(e,(function(e,s){t[s]=r&&"function"==typeof e?T(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}};function P(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var H=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(P(e)+"="+P(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){B.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return B.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},F=function(t,e){B.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},z=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},M=B.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),B.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),B.isString(s)&&o.push("path="+s),B.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(){}},X=["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"],J=B.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=B.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},V=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;B.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,h,d=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(i.open(t.method.toUpperCase(),H(d,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,n,o,a,u,h="getAllResponseHeaders"in i?(s=i.getAllResponseHeaders(),u={},s?(B.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=B.trim(t.substr(0,a)).toLowerCase(),o=B.trim(t.substr(a+1)),n){if(u[n]&&X.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([o]):u[n]?u[n]+", "+o:o}})),u):u):null,d={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:t,request:i};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(z("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,d),i=null}},i.onabort=function(){i&&(r(z("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(z("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(z(e,t,"ECONNABORTED",i)),i=null},B.isStandardBrowserEnv()){var c=(t.withCredentials||J(d))&&t.xsrfCookieName?M.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&B.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),B.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)}))},K={"Content-Type":"application/x-www-form-urlencoded"};function W(t,e){!B.isUndefined(t)&&B.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var G,Q={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(G=V),G),transformRequest:[function(t,e){return F(e,"Accept"),F(e,"Content-Type"),B.isFormData(t)||B.isArrayBuffer(t)||B.isBuffer(t)||B.isStream(t)||B.isFile(t)||B.isBlob(t)?t:B.isArrayBufferView(t)?t.buffer:B.isURLSearchParams(t)?(W(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):B.isObject(t)?(W(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}};Q.headers={common:{Accept:"application/json, text/plain, */*"}},B.forEach(["delete","get","head"],(function(t){Q.headers[t]={}})),B.forEach(["post","put","patch"],(function(t){Q.headers[t]=B.merge(K)}));var Y=Q;function Z(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var tt=function(t){return Z(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=B.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),B.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Y.adapter)(t).then((function(e){return Z(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Z(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},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 B.isPlainObject(t)&&B.isPlainObject(e)?B.merge(t,e):B.isPlainObject(e)?B.merge({},e):B.isArray(e)?e.slice():e}function u(s){B.isUndefined(e[s])?B.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}B.forEach(s,(function(t){B.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),B.forEach(n,u),B.forEach(i,(function(s){B.isUndefined(e[s])?B.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),B.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 B.forEach(d,u),r};function rt(t){this.defaults=t,this.interceptors={request:new L,response:new L}}rt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=et(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[tt,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},rt.prototype.getUri=function(t){return t=et(this.defaults,t),H(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},B.forEach(["delete","get","head","options"],(function(t){rt.prototype[t]=function(e,r){return this.request(et(r||{},{method:t,url:e,data:(r||{}).data}))}})),B.forEach(["post","put","patch"],(function(t){rt.prototype[t]=function(e,r,s){return this.request(et(s||{},{method:t,url:e,data:r}))}}));var st=rt;function nt(t){this.message=t}nt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},nt.prototype.__CANCEL__=!0;var it=nt;function ot(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 it(t),e(r.reason))}))}ot.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ot.source=function(){var t;return{token:new ot((function(e){t=e})),cancel:t}};var at=ot;function ut(t){var e=new st(t),r=T(st.prototype.request,e);return B.extend(r,st.prototype,e),B.extend(r,e),r}var ht=ut(Y);ht.Axios=st,ht.create=function(t){return ut(et(ht.defaults,t))},ht.Cancel=it,ht.CancelToken=at,ht.isCancel=D,ht.all=function(t){return Promise.all(t)},ht.spread=function(t){return function(e){return t.apply(null,e)}},ht.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var dt=ht,ct=ht;dt.default=ct;var lt=dt;class pt{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=lt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,e,s,n){var i,o,a,u,h,d,c,l;return r(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 r={method:t,url:e,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 ")?r.headers.Authorization=u:r.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(r),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 k(null,l);return l}catch(t){if(lt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new k(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 k(t)}}))}get(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,e)}))}head(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,e)}))}options(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,e)}))}delete(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("delete",t,e,s)}))}put(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("put",t,e,s)}))}post(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("post",t,e,s)}))}patch(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("patch",t,e,s)}))}}t("AxiosTransport",pt);class ft{constructor(t){this.transport=t}request(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:e})}))}reset(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:e})}))}}class vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return r(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 mt{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 ft(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 s;return r(this,void 0,void 0,(function*(){if(t&&null===this.storage.auth_token)throw new e;if(!t&&!this.expiring)return!1;const r=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(r.data),this.updateRefresh(),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),n))}refresh(t=!1){return r(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,e){var s;return r(this,void 0,void 0,(function*(){e=e||{};const r=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(r.data),this.updateRefresh(e.refresh),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.data.expires}}))}static(t){return r(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 r(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",mt);class gt{constructor(t){this.transport=t}request(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:e,variables:void 0===s?{}:s})}))}items(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,e)}))}system(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,e)}))}}class yt{constructor(t,e){this.collection=t,this.transport=e}read(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:e})).data}))}}t("Directus",class{constructor(t,e){this._storage=(null==e?void 0:e.storage)||("undefined"!=typeof window?new S:new R),this._transport=(null==e?void 0:e.transport)||new pt(t,this._storage,(()=>r(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==e?void 0:e.auth)||new mt(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 i(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new u(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new d(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new l(this.transport))}get revisions(){return this._revisions||(this._revisions=new p(this.transport))}get roles(){return this._roles||(this._roles=new f(this.transport))}get settings(){return this._settings||(this._settings=new m(this.transport))}get users(){return this._users||(this._users=new w(this.transport))}get server(){return this._server||(this._server=new v(this.transport))}get utils(){return this._utils||(this._utils=new x(this.transport))}get graphql(){return this._graphql||(this._graphql=new gt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new yt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new s(t,this.transport))}})}}})); | ||
function r(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("NotAuthenticated",e);class s{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e})).data}))}readMany(t){return r(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,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:e})).data}))}createMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:e})}))}updateOne(t,e,s){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:s})).data}))}updateMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:e})}))}deleteOne(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}t("ItemsHandler",s);class n{constructor(t){this.transport=t}create(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}))}delete(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}t("CommentsHandler",n);class i extends s{constructor(t){super("directus_activity",t),this._comments=new n(this.transport)}get comments(){return this._comments}}t("ActivityHandler",i);class o extends s{constructor(t){super("directus_collections",t)}}t("CollectionsHandler",o);class a extends s{constructor(t){super("directus_fields",t)}}t("FieldsHandler",a);class u extends s{constructor(t){super("directus_files",t)}}t("FilesHandler",u);class h extends s{constructor(t){super("directus_folders",t)}}t("FoldersHandler",h);class d extends s{constructor(t){super("directus_permissions",t)}}t("PermissionsHandler",d);class c extends s{constructor(t){super("directus_presets",t)}}t("PresetsHandler",c);class l extends s{constructor(t){super("directus_relations",t)}}t("RelationsHandler",l);class p extends s{constructor(t){super("directus_revisions",t)}}t("RevisionsHandler",p);class f extends s{constructor(t){super("directus_roles",t)}}t("RolesHandler",f);class v{constructor(t){this.transport=t}ping(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}t("ServerHandler",v);class m extends s{constructor(t){super("directus_settings",t)}}t("SettingsHandler",m);class g{constructor(t){this.transport=t}send(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:e})}))}accept(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:e})}))}}class y{constructor(t){this.transport=t}enable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class _{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new y(this._transport))}read(t){return r(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:e})).data}))}}class w extends s{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new g(this.transport))}get me(){return this._me||(this._me=new _(this.transport))}}t("UsersHandler",w);class x{constructor(t){this.random={string:(t=32)=>r(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,e)=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:e})).data}))},this.transport=t}sort(t,e,s){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:s})}))}revert(t){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var b;t("UtilsHandler",x),function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(b||(b=t("Meta",{})));class k 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,k.prototype)}}t("TransportError",k);class E{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",E);class R extends E{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 S extends E{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",S);var 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)}},A=Object.prototype.toString;function j(t){return"[object Array]"===A.call(t)}function O(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function U(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 q(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),j(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:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===A.call(t)},isBuffer:function(t){return null!==t&&!O(t)&&null!==t.constructor&&!O(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:U,isUndefined:O,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:q,merge:function t(){var e={};function r(r,s){U(e[s])&&U(r)?e[s]=t(e[s],r):U(r)?e[s]=t({},r):j(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)q(arguments[s],r);return e},extend:function(t,e,r){return q(e,(function(e,s){t[s]=r&&"function"==typeof e?T(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}};function P(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var H=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(P(e)+"="+P(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){B.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return B.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},F=function(t,e){B.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},z=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},M=B.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),B.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),B.isString(s)&&o.push("path="+s),B.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(){}},X=["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"],J=B.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=B.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},V=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;B.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,h,d=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(i.open(t.method.toUpperCase(),H(d,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,n,o,a,u,h="getAllResponseHeaders"in i?(s=i.getAllResponseHeaders(),u={},s?(B.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=B.trim(t.substr(0,a)).toLowerCase(),o=B.trim(t.substr(a+1)),n){if(u[n]&&X.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([o]):u[n]?u[n]+", "+o:o}})),u):u):null,d={data:t.responseType&&"text"!==t.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:t,request:i};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(z("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,d),i=null}},i.onabort=function(){i&&(r(z("Request aborted",t,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(z("Network Error",t,null,i)),i=null},i.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(z(e,t,"ECONNABORTED",i)),i=null},B.isStandardBrowserEnv()){var c=(t.withCredentials||J(d))&&t.xsrfCookieName?M.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&B.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),B.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)}))},K={"Content-Type":"application/x-www-form-urlencoded"};function W(t,e){!B.isUndefined(t)&&B.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var G,Q={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(G=V),G),transformRequest:[function(t,e){return F(e,"Accept"),F(e,"Content-Type"),B.isFormData(t)||B.isArrayBuffer(t)||B.isBuffer(t)||B.isStream(t)||B.isFile(t)||B.isBlob(t)?t:B.isArrayBufferView(t)?t.buffer:B.isURLSearchParams(t)?(W(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):B.isObject(t)?(W(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}};Q.headers={common:{Accept:"application/json, text/plain, */*"}},B.forEach(["delete","get","head"],(function(t){Q.headers[t]={}})),B.forEach(["post","put","patch"],(function(t){Q.headers[t]=B.merge(K)}));var Y=Q;function Z(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var tt=function(t){return Z(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=B.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),B.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Y.adapter)(t).then((function(e){return Z(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Z(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},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 B.isPlainObject(t)&&B.isPlainObject(e)?B.merge(t,e):B.isPlainObject(e)?B.merge({},e):B.isArray(e)?e.slice():e}function u(s){B.isUndefined(e[s])?B.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}B.forEach(s,(function(t){B.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),B.forEach(n,u),B.forEach(i,(function(s){B.isUndefined(e[s])?B.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),B.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 B.forEach(d,u),r};function rt(t){this.defaults=t,this.interceptors={request:new L,response:new L}}rt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=et(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[tt,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},rt.prototype.getUri=function(t){return t=et(this.defaults,t),H(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},B.forEach(["delete","get","head","options"],(function(t){rt.prototype[t]=function(e,r){return this.request(et(r||{},{method:t,url:e,data:(r||{}).data}))}})),B.forEach(["post","put","patch"],(function(t){rt.prototype[t]=function(e,r,s){return this.request(et(s||{},{method:t,url:e,data:r}))}}));var st=rt;function nt(t){this.message=t}nt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},nt.prototype.__CANCEL__=!0;var it=nt;function ot(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 it(t),e(r.reason))}))}ot.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ot.source=function(){var t;return{token:new ot((function(e){t=e})),cancel:t}};var at=ot;function ut(t){var e=new st(t),r=T(st.prototype.request,e);return B.extend(r,st.prototype,e),B.extend(r,e),r}var ht=ut(Y);ht.Axios=st,ht.create=function(t){return ut(et(ht.defaults,t))},ht.Cancel=it,ht.CancelToken=at,ht.isCancel=D,ht.all=function(t){return Promise.all(t)},ht.spread=function(t){return function(e){return t.apply(null,e)}},ht.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var dt=ht,ct=ht;dt.default=ct;var lt=dt;class pt{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=lt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,e,s,n){var i,o,a,u,h,d,c,l;return r(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 r={method:t,url:e,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 ")?r.headers.Authorization=u:r.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(r),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 k(null,l);return l}catch(t){if(lt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new k(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 k(t)}}))}get(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,e)}))}head(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,e)}))}options(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,e)}))}delete(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("delete",t,e,s)}))}put(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("put",t,e,s)}))}post(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("post",t,e,s)}))}patch(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("patch",t,e,s)}))}}t("AxiosTransport",pt);class ft{constructor(t){this.transport=t}request(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:e})}))}reset(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:e})}))}}class vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return r(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 mt{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 ft(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 s;return r(this,void 0,void 0,(function*(){if(t&&null===this.storage.auth_token)throw new e;if(!t&&!this.expiring)return!1;const r=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(r.data),this.updateRefresh(),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),n))}refresh(t=!1){return r(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,e){var s;return r(this,void 0,void 0,(function*(){e=e||{};const r=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(r.data),this.updateRefresh(e.refresh),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.data.expires}}))}static(t){return r(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 r(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",mt);class gt{constructor(t){this.transport=t}request(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:e,variables:void 0===s?{}:s})}))}items(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,e)}))}system(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,e)}))}}class yt{constructor(t,e){this.collection=t,this.transport=e}read(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:e})).data}))}}t("Directus",class{constructor(t,e){this._storage=(null==e?void 0:e.storage)||("undefined"!=typeof window?new S:new R),this._transport=(null==e?void 0:e.transport)||new pt(t,this._storage,(()=>r(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==e?void 0:e.auth)||new mt(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 i(this.transport))}get collections(){return this._collections||(this._collections=new o(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new u(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new d(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new l(this.transport))}get revisions(){return this._revisions||(this._revisions=new p(this.transport))}get roles(){return this._roles||(this._roles=new f(this.transport))}get settings(){return this._settings||(this._settings=new m(this.transport))}get users(){return this._users||(this._users=new w(this.transport))}get server(){return this._server||(this._server=new v(this.transport))}get utils(){return this._utils||(this._utils=new x(this.transport))}get graphql(){return this._graphql||(this._graphql=new gt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new yt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new s(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";class e extends Error{constructor(){super("No authentication")}} | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function r(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 s{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e})).data}))}readMany(t){return r(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,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:e})).data}))}createMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:e})}))}updateOne(t,e,s){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:s})).data}))}updateMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:e})}))}deleteOne(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class n{constructor(t){this.transport=t}create(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}))}delete(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class o extends s{constructor(t){super("directus_activity",t),this._comments=new n(this.transport)}get comments(){return this._comments}}class i extends s{constructor(t){super("directus_collections",t)}}class a extends s{constructor(t){super("directus_fields",t)}}class u extends s{constructor(t){super("directus_files",t)}}class h extends s{constructor(t){super("directus_folders",t)}}class d extends s{constructor(t){super("directus_permissions",t)}}class c extends s{constructor(t){super("directus_presets",t)}}class l extends s{constructor(t){super("directus_relations",t)}}class f extends s{constructor(t){super("directus_revisions",t)}}class p extends s{constructor(t){super("directus_roles",t)}}class v{constructor(t){this.transport=t}ping(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class m extends s{constructor(t){super("directus_settings",t)}}class g{constructor(t){this.transport=t}send(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:e})}))}accept(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:e})}))}}class y{constructor(t){this.transport=t}enable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class _{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new y(this._transport))}read(t){return r(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:e})).data}))}}class w extends s{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new g(this.transport))}get me(){return this._me||(this._me=new _(this.transport))}}class x{constructor(t){this.random={string:(t=32)=>r(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,e)=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:e})).data}))},this.transport=t}sort(t,e,s){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:s})}))}revert(t){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var b;t.Meta=void 0,(b=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",b.FILTER_COUNT="filter_count";class k 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,k.prototype)}}class E{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 E{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 T extends E{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=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=Object.prototype.toString;function A(t){return"[object Array]"===j.call(t)}function O(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function U(t){if("[object Object]"!==j.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===j.call(t)}function q(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 P={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===j.call(t)},isBuffer:function(t){return null!==t&&!O(t)&&null!==t.constructor&&!O(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:U,isUndefined:O,isDate:function(t){return"[object Date]"===j.call(t)},isFile:function(t){return"[object File]"===j.call(t)},isBlob:function(t){return"[object Blob]"===j.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:q,merge:function t(){var e={};function r(r,s){U(e[s])&&U(r)?e[s]=t(e[s],r):U(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)q(arguments[s],r);return e},extend:function(t,e,r){return q(e,(function(e,s){t[s]=r&&"function"==typeof e?S(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}};function B(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var H=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(B(e)+"="+B(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){P.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return P.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},F=function(t,e){P.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},M=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},z=P.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),P.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),P.isString(s)&&i.push("path="+s),P.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(){}},X=["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"],J=P.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=P.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},V=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;P.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,h,d=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(o.open(t.method.toUpperCase(),H(d,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,n,i,a,u,h="getAllResponseHeaders"in o?(s=o.getAllResponseHeaders(),u={},s?(P.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=P.trim(t.substr(0,a)).toLowerCase(),i=P.trim(t.substr(a+1)),n){if(u[n]&&X.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([i]):u[n]?u[n]+", "+i:i}})),u):u):null,d={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:h,config:t,request:o};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(M("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,d),o=null}},o.onabort=function(){o&&(r(M("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(M("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(M(e,t,"ECONNABORTED",o)),o=null},P.isStandardBrowserEnv()){var c=(t.withCredentials||J(d))&&t.xsrfCookieName?z.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in o&&P.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:o.setRequestHeader(e,t)})),P.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)}))},K={"Content-Type":"application/x-www-form-urlencoded"};function W(t,e){!P.isUndefined(t)&&P.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var G,Q={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(G=V),G),transformRequest:[function(t,e){return F(e,"Accept"),F(e,"Content-Type"),P.isFormData(t)||P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)?t:P.isArrayBufferView(t)?t.buffer:P.isURLSearchParams(t)?(W(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):P.isObject(t)?(W(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}};Q.headers={common:{Accept:"application/json, text/plain, */*"}},P.forEach(["delete","get","head"],(function(t){Q.headers[t]={}})),P.forEach(["post","put","patch"],(function(t){Q.headers[t]=P.merge(K)}));var Y=Q;function Z(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var tt=function(t){return Z(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=P.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),P.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Y.adapter)(t).then((function(e){return Z(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Z(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},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 P.isPlainObject(t)&&P.isPlainObject(e)?P.merge(t,e):P.isPlainObject(e)?P.merge({},e):P.isArray(e)?e.slice():e}function u(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}P.forEach(s,(function(t){P.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),P.forEach(n,u),P.forEach(o,(function(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),P.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 P.forEach(d,u),r};function rt(t){this.defaults=t,this.interceptors={request:new L,response:new L}}rt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=et(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[tt,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},rt.prototype.getUri=function(t){return t=et(this.defaults,t),H(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},P.forEach(["delete","get","head","options"],(function(t){rt.prototype[t]=function(e,r){return this.request(et(r||{},{method:t,url:e,data:(r||{}).data}))}})),P.forEach(["post","put","patch"],(function(t){rt.prototype[t]=function(e,r,s){return this.request(et(s||{},{method:t,url:e,data:r}))}}));var st=rt;function nt(t){this.message=t}nt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},nt.prototype.__CANCEL__=!0;var ot=nt;function it(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 ot(t),e(r.reason))}))}it.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},it.source=function(){var t;return{token:new it((function(e){t=e})),cancel:t}};var at=it;function ut(t){var e=new st(t),r=S(st.prototype.request,e);return P.extend(r,st.prototype,e),P.extend(r,e),r}var ht=ut(Y);ht.Axios=st,ht.create=function(t){return ut(et(ht.defaults,t))},ht.Cancel=ot,ht.CancelToken=at,ht.isCancel=D,ht.all=function(t){return Promise.all(t)},ht.spread=function(t){return function(e){return t.apply(null,e)}},ht.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var dt=ht,ct=ht;dt.default=ct;var lt=dt;class ft{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=lt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,e,s,n){var o,i,a,u,h,d,c,l;return r(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 r={method:t,url:e,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 ")?r.headers.Authorization=u:r.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(r),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 k(null,l);return l}catch(t){if(lt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new k(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 k(t)}}))}get(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,e)}))}head(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,e)}))}options(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,e)}))}delete(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("delete",t,e,s)}))}put(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("put",t,e,s)}))}post(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("post",t,e,s)}))}patch(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("patch",t,e,s)}))}}class pt{constructor(t){this.transport=t}request(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:e})}))}reset(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:e})}))}}class vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return r(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 mt{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 pt(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 s;return r(this,void 0,void 0,(function*(){if(t&&null===this.storage.auth_token)throw new e;if(!t&&!this.expiring)return!1;const r=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(r.data),this.updateRefresh(),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),n))}refresh(t=!1){return r(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,e){var s;return r(this,void 0,void 0,(function*(){e=e||{};const r=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(r.data),this.updateRefresh(e.refresh),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.data.expires}}))}static(t){return r(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 r(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 gt{constructor(t){this.transport=t}request(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:e,variables:void 0===s?{}:s})}))}items(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,e)}))}system(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,e)}))}}class yt{constructor(t,e){this.collection=t,this.transport=e}read(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:e})).data}))}}t.ActivityHandler=o,t.Auth=mt,t.AxiosTransport=ft,t.BaseStorage=E,t.CollectionsHandler=i,t.CommentsHandler=n,t.Directus=class{constructor(t,e){this._storage=(null==e?void 0:e.storage)||("undefined"!=typeof window?new T:new R),this._transport=(null==e?void 0:e.transport)||new ft(t,this._storage,(()=>r(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==e?void 0:e.auth)||new mt(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 o(this.transport))}get collections(){return this._collections||(this._collections=new i(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new u(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new d(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new l(this.transport))}get revisions(){return this._revisions||(this._revisions=new f(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new m(this.transport))}get users(){return this._users||(this._users=new w(this.transport))}get server(){return this._server||(this._server=new v(this.transport))}get utils(){return this._utils||(this._utils=new x(this.transport))}get graphql(){return this._graphql||(this._graphql=new gt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new yt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new s(t,this.transport))}},t.FieldsHandler=a,t.FilesHandler=u,t.FoldersHandler=h,t.ItemsHandler=s,t.LocalStorage=T,t.MemoryStorage=R,t.NotAuthenticated=e,t.PermissionsHandler=d,t.PresetsHandler=c,t.RelationsHandler=l,t.RevisionsHandler=f,t.RolesHandler=p,t.ServerHandler=v,t.SettingsHandler=m,t.TransportError=k,t.UsersHandler=w,t.UtilsHandler=x,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
***************************************************************************** */function r(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 s{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e})).data}))}readMany(t){return r(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,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:e})).data}))}createMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:e})}))}updateOne(t,e,s){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:s})).data}))}updateMany(t,e){return r(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,t,{params:e})}))}deleteOne(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class n{constructor(t){this.transport=t}create(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}))}delete(t){return r(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class o extends s{constructor(t){super("directus_activity",t),this._comments=new n(this.transport)}get comments(){return this._comments}}class i extends s{constructor(t){super("directus_collections",t)}}class a extends s{constructor(t){super("directus_fields",t)}}class u extends s{constructor(t){super("directus_files",t)}}class h extends s{constructor(t){super("directus_folders",t)}}class d extends s{constructor(t){super("directus_permissions",t)}}class c extends s{constructor(t){super("directus_presets",t)}}class l extends s{constructor(t){super("directus_relations",t)}}class f extends s{constructor(t){super("directus_revisions",t)}}class p extends s{constructor(t){super("directus_roles",t)}}class v{constructor(t){this.transport=t}ping(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return r(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class m extends s{constructor(t){super("directus_settings",t)}}class g{constructor(t){this.transport=t}send(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:e})}))}accept(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:e})}))}}class y{constructor(t){this.transport=t}enable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return r(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class _{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new y(this._transport))}read(t){return r(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:e})).data}))}}class w extends s{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new g(this.transport))}get me(){return this._me||(this._me=new _(this.transport))}}class x{constructor(t){this.random={string:(t=32)=>r(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,e)=>r(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:e})).data}))},this.transport=t}sort(t,e,s){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:s})}))}revert(t){return r(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var b;t.Meta=void 0,(b=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",b.FILTER_COUNT="filter_count";class k 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,k.prototype)}}class E{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 E{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 T extends E{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=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=Object.prototype.toString;function A(t){return"[object Array]"===j.call(t)}function O(t){return void 0===t}function C(t){return null!==t&&"object"==typeof t}function U(t){if("[object Object]"!==j.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function N(t){return"[object Function]"===j.call(t)}function q(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 P={isArray:A,isArrayBuffer:function(t){return"[object ArrayBuffer]"===j.call(t)},isBuffer:function(t){return null!==t&&!O(t)&&null!==t.constructor&&!O(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:U,isUndefined:O,isDate:function(t){return"[object Date]"===j.call(t)},isFile:function(t){return"[object File]"===j.call(t)},isBlob:function(t){return"[object Blob]"===j.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:q,merge:function t(){var e={};function r(r,s){U(e[s])&&U(r)?e[s]=t(e[s],r):U(r)?e[s]=t({},r):A(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)q(arguments[s],r);return e},extend:function(t,e,r){return q(e,(function(e,s){t[s]=r&&"function"==typeof e?S(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}};function B(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var H=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(B(e)+"="+B(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t};function $(){this.handlers=[]}$.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},$.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},$.prototype.forEach=function(t){P.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var L=$,I=function(t,e,r){return P.forEach(r,(function(r){t=r(t,e)})),t},D=function(t){return!(!t||!t.__CANCEL__)},F=function(t,e){P.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},M=function(t,e,r,s,n){return 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}(new Error(t),e,r,s,n)},z=P.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),P.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),P.isString(s)&&i.push("path="+s),P.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(){}},X=["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"],J=P.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=P.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},V=function(t){return new Promise((function(e,r){var s=t.data,n=t.headers;P.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,h,d=(u=t.baseURL,h=t.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(u,h):h);if(o.open(t.method.toUpperCase(),H(d,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,n,i,a,u,h="getAllResponseHeaders"in o?(s=o.getAllResponseHeaders(),u={},s?(P.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=P.trim(t.substr(0,a)).toLowerCase(),i=P.trim(t.substr(a+1)),n){if(u[n]&&X.indexOf(n)>=0)return;u[n]="set-cookie"===n?(u[n]?u[n]:[]).concat([i]):u[n]?u[n]+", "+i:i}})),u):u):null,d={data:t.responseType&&"text"!==t.responseType?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:h,config:t,request:o};!function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(M("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}(e,r,d),o=null}},o.onabort=function(){o&&(r(M("Request aborted",t,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(M("Network Error",t,null,o)),o=null},o.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(M(e,t,"ECONNABORTED",o)),o=null},P.isStandardBrowserEnv()){var c=(t.withCredentials||J(d))&&t.xsrfCookieName?z.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in o&&P.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:o.setRequestHeader(e,t)})),P.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)}))},K={"Content-Type":"application/x-www-form-urlencoded"};function W(t,e){!P.isUndefined(t)&&P.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var G,Q={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(G=V),G),transformRequest:[function(t,e){return F(e,"Accept"),F(e,"Content-Type"),P.isFormData(t)||P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)?t:P.isArrayBufferView(t)?t.buffer:P.isURLSearchParams(t)?(W(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):P.isObject(t)?(W(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}};Q.headers={common:{Accept:"application/json, text/plain, */*"}},P.forEach(["delete","get","head"],(function(t){Q.headers[t]={}})),P.forEach(["post","put","patch"],(function(t){Q.headers[t]=P.merge(K)}));var Y=Q;function Z(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var tt=function(t){return Z(t),t.headers=t.headers||{},t.data=I(t.data,t.headers,t.transformRequest),t.headers=P.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),P.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Y.adapter)(t).then((function(e){return Z(t),e.data=I(e.data,e.headers,t.transformResponse),e}),(function(e){return D(e)||(Z(t),e&&e.response&&(e.response.data=I(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},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 P.isPlainObject(t)&&P.isPlainObject(e)?P.merge(t,e):P.isPlainObject(e)?P.merge({},e):P.isArray(e)?e.slice():e}function u(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}P.forEach(s,(function(t){P.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),P.forEach(n,u),P.forEach(o,(function(s){P.isUndefined(e[s])?P.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),P.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 P.forEach(d,u),r};function rt(t){this.defaults=t,this.interceptors={request:new L,response:new L}}rt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=et(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[tt,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},rt.prototype.getUri=function(t){return t=et(this.defaults,t),H(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},P.forEach(["delete","get","head","options"],(function(t){rt.prototype[t]=function(e,r){return this.request(et(r||{},{method:t,url:e,data:(r||{}).data}))}})),P.forEach(["post","put","patch"],(function(t){rt.prototype[t]=function(e,r,s){return this.request(et(s||{},{method:t,url:e,data:r}))}}));var st=rt;function nt(t){this.message=t}nt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},nt.prototype.__CANCEL__=!0;var ot=nt;function it(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 ot(t),e(r.reason))}))}it.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},it.source=function(){var t;return{token:new it((function(e){t=e})),cancel:t}};var at=it;function ut(t){var e=new st(t),r=S(st.prototype.request,e);return P.extend(r,st.prototype,e),P.extend(r,e),r}var ht=ut(Y);ht.Axios=st,ht.create=function(t){return ut(et(ht.defaults,t))},ht.Cancel=ot,ht.CancelToken=at,ht.isCancel=D,ht.all=function(t){return Promise.all(t)},ht.spread=function(t){return function(e){return t.apply(null,e)}},ht.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var dt=ht,ct=ht;dt.default=ct;var lt=dt;class ft{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=lt.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,e,s,n){var o,i,a,u,h,d,c,l;return r(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 r={method:t,url:e,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 ")?r.headers.Authorization=u:r.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(r),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 k(null,l);return l}catch(t){if(lt.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new k(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 k(t)}}))}get(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,e)}))}head(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,e)}))}options(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,e)}))}delete(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("delete",t,e,s)}))}put(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("put",t,e,s)}))}post(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("post",t,e,s)}))}patch(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.request("patch",t,e,s)}))}}class pt{constructor(t){this.transport=t}request(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:t,reset_url:e})}))}reset(t,e){return r(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:t,password:e})}))}}class vt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...t){return r(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 mt{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 pt(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 s;return r(this,void 0,void 0,(function*(){if(t&&null===this.storage.auth_token)throw new e;if(!t&&!this.expiring)return!1;const r=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(r.data),this.updateRefresh(),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.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 this.storage.auth_expires=null,void(this.storage.auth_token=null);n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((t=>{}))}),n))}refresh(t=!1){return r(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,e){var s;return r(this,void 0,void 0,(function*(){e=e||{};const r=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(r.data),this.updateRefresh(e.refresh),{access_token:r.data.access_token,refresh_token:null===(s=r.data)||void 0===s?void 0:s.refresh_token,expires:r.data.expires}}))}static(t){return r(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 r(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 gt{constructor(t){this.transport=t}request(t,e,s){return r(this,void 0,void 0,(function*(){return yield this.transport.post(t,{query:e,variables:void 0===s?{}:s})}))}items(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql",t,e)}))}system(t,e){return r(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",t,e)}))}}class yt{constructor(t,e){this.collection=t,this.transport=e}read(t){return r(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:t})).data}))}update(t,e){return r(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,t,{params:e})).data}))}}t.ActivityHandler=o,t.Auth=mt,t.AxiosTransport=ft,t.BaseStorage=E,t.CollectionsHandler=i,t.CommentsHandler=n,t.Directus=class{constructor(t,e){this._storage=(null==e?void 0:e.storage)||("undefined"!=typeof window?new T:new R),this._transport=(null==e?void 0:e.transport)||new ft(t,this._storage,(()=>r(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==e?void 0:e.auth)||new mt(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 o(this.transport))}get collections(){return this._collections||(this._collections=new i(this.transport))}get fields(){return this._fields||(this._fields=new a(this.transport))}get files(){return this._files||(this._files=new u(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new d(this.transport))}get presets(){return this._presets||(this._presets=new c(this.transport))}get relations(){return this._relations||(this._relations=new l(this.transport))}get revisions(){return this._revisions||(this._revisions=new f(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new m(this.transport))}get users(){return this._users||(this._users=new w(this.transport))}get server(){return this._server||(this._server=new v(this.transport))}get utils(){return this._utils||(this._utils=new x(this.transport))}get graphql(){return this._graphql||(this._graphql=new gt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new yt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new s(t,this.transport))}},t.FieldsHandler=a,t.FilesHandler=u,t.FoldersHandler=h,t.ItemsHandler=s,t.LocalStorage=T,t.MemoryStorage=R,t.NotAuthenticated=e,t.PermissionsHandler=d,t.PresetsHandler=c,t.RelationsHandler=l,t.RevisionsHandler=f,t.RolesHandler=p,t.ServerHandler=v,t.SettingsHandler=m,t.TransportError=k,t.UsersHandler=w,t.UtilsHandler=x,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=sdk.umd.min.js.map |
{ | ||
"name": "@directus/sdk", | ||
"version": "9.0.0-rc.60", | ||
"version": "9.0.0-rc.61", | ||
"description": "The official Directus SDK for use in JavaScript!", | ||
@@ -72,3 +72,3 @@ "repository": { | ||
}, | ||
"gitHead": "d9b0fc1e339419a9ae4fd954b9e8a6edc4b3bdd8" | ||
"gitHead": "3e89bcc239a2e967e3d1811bbc274236c8398a00" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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