@directus/sdk
Advanced tools
Comparing version 9.0.0-rc.62 to 9.0.0-rc.63
@@ -13,3 +13,3 @@ import { ITransport } from '../transport'; | ||
updateOne(id: ID, item: PartialItem<T>, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
updateMany(items: PartialItem<T>[], query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
updateMany(ids: ID[], data: PartialItem<T>, query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
deleteOne(id: ID): Promise<void>; | ||
@@ -16,0 +16,0 @@ deleteMany(ids: ID[]): Promise<void>; |
@@ -58,7 +58,8 @@ "use strict"; | ||
} | ||
// TODO: needs to support submitting arrays | ||
// async updateMany(ids: item: PartialItem<T>, query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
updateMany(items, query) { | ||
updateMany(ids, data, query) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.transport.patch(`${this.endpoint}`, items, { | ||
return yield this.transport.patch(`${this.endpoint}`, { | ||
keys: ids, | ||
data, | ||
}, { | ||
params: query, | ||
@@ -65,0 +66,0 @@ }); |
@@ -25,3 +25,3 @@ import { ID } from './types'; | ||
deep?: Record<string, QueryMany<T>>; | ||
export?: 'json' | 'csv'; | ||
export?: 'json' | 'csv' | 'xml'; | ||
filter?: Filter<T>; | ||
@@ -54,3 +54,3 @@ }; | ||
updateOne(id: ID, item: PartialItem<T>, query?: QueryOne<T>): Promise<OneItem<T>>; | ||
updateMany(items: PartialItem<T>[], query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
updateMany(ids: ID[], item: PartialItem<T>, query?: QueryMany<T>): Promise<ManyItems<T>>; | ||
deleteOne(id: ID): Promise<void>; | ||
@@ -57,0 +57,0 @@ deleteMany(ids: ID[]): Promise<void>; |
@@ -15,3 +15,3 @@ /*! ***************************************************************************** | ||
***************************************************************************** */ | ||
function t(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}class e{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(e)}`,{params:r})).data}))}readMany(e){return t(this,void 0,void 0,(function*(){const{data:t,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:e});return{data:t,meta:r}}))}createOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,e,{params:r})).data}))}createMany(e,r){return t(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,e,{params:r})}))}updateOne(e,r,s){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(e)}`,r,{params:s})).data}))}updateMany(e,r){return t(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,e,{params:r})}))}deleteOne(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(e)}`)}))}deleteMany(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,e)}))}}class r{constructor(t){this.transport=t}create(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",e)).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(e)}`,{comment:r})).data}))}delete(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(e)}`)}))}}class s extends e{constructor(t){super("directus_activity",t),this._comments=new r(this.transport)}get comments(){return this._comments}}class n extends e{constructor(t){super("directus_collections",t)}}class i extends e{constructor(t){super("directus_fields",t)}}class o extends e{constructor(t){super("directus_files",t)}}class a extends e{constructor(t){super("directus_folders",t)}}class u extends e{constructor(t){super("directus_permissions",t)}}class h extends e{constructor(t){super("directus_presets",t)}}class c extends e{constructor(t){super("directus_relations",t)}}class d extends e{constructor(t){super("directus_revisions",t)}}class l extends e{constructor(t){super("directus_roles",t)}}class p{constructor(t){this.transport=t}ping(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class f extends e{constructor(t){super("directus_settings",t)}}class v{constructor(t){this.transport=t}send(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:e,role:r})}))}accept(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:e,password:r})}))}}class m{constructor(t){this.transport=t}enable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:e})}))}disable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:e})}))}}class g{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new m(this._transport))}read(e){return t(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",e,{params:r})).data}))}}class y extends e{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new v(this.transport))}get me(){return this._me||(this._me=new g(this.transport))}}class _{constructor(e){this.random={string:(e=32)=>t(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:e}})).data}))},this.hash={generate:e=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:e})).data})),verify:(e,r)=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:e,hash:r})).data}))},this.transport=e}sort(e,r,s){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(e)}`,{item:r,to:s})}))}revert(e){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(e)}`)}))}}var w;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(w||(w={}));class x extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,x.prototype)}}class b{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class k extends b{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends b{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var R=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)}},T=Object.prototype.toString;function j(t){return"[object Array]"===T.call(t)}function O(t){return void 0===t}function S(t){return null!==t&&"object"==typeof t}function A(t){if("[object Object]"!==T.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function C(t){return"[object Function]"===T.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 U={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===T.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:S,isPlainObject:A,isUndefined:O,isDate:function(t){return"[object Date]"===T.call(t)},isFile:function(t){return"[object File]"===T.call(t)},isBlob:function(t){return"[object Blob]"===T.call(t)},isFunction:C,isStream:function(t){return S(t)&&C(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){A(e[s])&&A(r)?e[s]=t(e[s],r):A(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?R(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 N(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var B=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(N(e)+"="+N(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 P(){this.handlers=[]}P.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},P.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},P.prototype.forEach=function(t){U.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=P,L=function(t,e,r){return U.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){U.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)},F=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(){}},H=["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"],M=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},X=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(),B(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]&&H.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(z("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(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},U.isStandardBrowserEnv()){var d=(t.withCredentials||M(c))&&t.xsrfCookieName?F.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)}))},J={"Content-Type":"application/x-www-form-urlencoded"};function V(t,e){!U.isUndefined(t)&&U.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var K,W={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(K=X),K),transformRequest:[function(t,e){return D(e,"Accept"),D(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)?(V(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):U.isObject(t)?(V(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}};W.headers={common:{Accept:"application/json, text/plain, */*"}},U.forEach(["delete","get","head"],(function(t){W.headers[t]={}})),U.forEach(["post","put","patch"],(function(t){W.headers[t]=U.merge(J)}));var G=W;function Q(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Y=function(t){return Q(t),t.headers=t.headers||{},t.data=L(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||G.adapter)(t).then((function(e){return Q(t),e.data=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Q(t),e&&e.response&&(e.response.data=L(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Z=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 tt(t){this.defaults=t,this.interceptors={request:new $,response:new $}}tt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Z(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Y,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},tt.prototype.getUri=function(t){return t=Z(this.defaults,t),B(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},U.forEach(["delete","get","head","options"],(function(t){tt.prototype[t]=function(e,r){return this.request(Z(r||{},{method:t,url:e,data:(r||{}).data}))}})),U.forEach(["post","put","patch"],(function(t){tt.prototype[t]=function(e,r,s){return this.request(Z(s||{},{method:t,url:e,data:r}))}}));var et=tt;function rt(t){this.message=t}rt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},rt.prototype.__CANCEL__=!0;var st=rt;function nt(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 st(t),e(r.reason))}))}nt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},nt.source=function(){var t;return{token:new nt((function(e){t=e})),cancel:t}};var it=nt;function ot(t){var e=new et(t),r=R(et.prototype.request,e);return U.extend(r,et.prototype,e),U.extend(r,e),r}var at=ot(G);at.Axios=et,at.create=function(t){return ot(Z(at.defaults,t))},at.Cancel=st,at.CancelToken=it,at.isCancel=I,at.all=function(t){return Promise.all(t)},at.spread=function(t){return function(e){return t.apply(null,e)}},at.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var ut=at,ht=at;ut.default=ht;var ct=ut;class dt{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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(e,r,s,n){var i,o,a,u,h,c,d,l;return t(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const t={method:e,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?t.headers.Authorization=u:t.headers.Authorization=`Bearer ${u}`);const c=yield this.axios.request(t),d=c.data,l={raw:c.data,status:c.status,statusText:c.statusText,headers:c.headers,data:d.data,meta:d.meta,errors:d.errors};if(d.errors)throw new x(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new x(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(c=t.response)||void 0===c?void 0:c.status,statusText:null===(d=t.response)||void 0===d?void 0:d.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new x(t)}}))}get(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("get",e,void 0,r)}))}head(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("head",e,void 0,r)}))}options(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("options",e,void 0,r)}))}delete(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("delete",e,r,s)}))}put(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("put",e,r,s)}))}post(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("post",e,r,s)}))}patch(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("patch",e,r,s)}))}}class lt{constructor(t){this.transport=t}request(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:e,reset_url:r})}))}reset(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:e,password:r})}))}}class pt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...e){return t(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((t,r)=>{this.func(...e).then((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.resolve(e)))})).catch((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.reject(e)))}))})))}))}}class ft{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 pt(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 lt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(e=!1){var r;return t(this,void 0,void 0,(function*(){if(!e&&!this.expiring)return!1;const t=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(t.data),this.updateRefresh(),{access_token:t.data.access_token,refresh_token:null===(r=t.data)||void 0===r?void 0:r.refresh_token,expires:t.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(e=!1){return t(this,void 0,void 0,(function*(){return yield this.refresher.debounce(e)}))}login(e,r){var s;return t(this,void 0,void 0,(function*(){r=r||{};const t=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},e),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(t.data),this.updateRefresh(r.refresh),{access_token:t.data.access_token,refresh_token:null===(s=t.data)||void 0===s?void 0:s.refresh_token,expires:t.data.expires}}))}static(e){return t(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:e}}),this.storage.auth_token=e,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return t(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class vt{constructor(t){this.transport=t}request(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.transport.post(e,{query:r,variables:void 0===s?{}:s})}))}items(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql",e,r)}))}system(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",e,r)}))}}class mt{constructor(t,e){this.collection=t,this.transport=e}read(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,e,{params:r})).data}))}}class gt{constructor(e,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new k),this._transport=(null==r?void 0:r.transport)||new dt(e,this._storage,(()=>t(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new ft(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new s(this.transport))}get collections(){return this._collections||(this._collections=new n(this.transport))}get fields(){return this._fields||(this._fields=new i(this.transport))}get files(){return this._files||(this._files=new o(this.transport))}get folders(){return this._folders||(this._folders=new a(this.transport))}get permissions(){return this._permissions||(this._permissions=new u(this.transport))}get presets(){return this._presets||(this._presets=new h(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new d(this.transport))}get roles(){return this._roles||(this._roles=new l(this.transport))}get settings(){return this._settings||(this._settings=new f(this.transport))}get users(){return this._users||(this._users=new y(this.transport))}get server(){return this._server||(this._server=new p(this.transport))}get utils(){return this._utils||(this._utils=new _(this.transport))}get graphql(){return this._graphql||(this._graphql=new vt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new mt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new e(t,this.transport))}}export{s as ActivityHandler,ft as Auth,dt as AxiosTransport,b as BaseStorage,n as CollectionsHandler,r as CommentsHandler,gt as Directus,i as FieldsHandler,o as FilesHandler,a as FoldersHandler,e as ItemsHandler,E as LocalStorage,k as MemoryStorage,w as Meta,u as PermissionsHandler,h as PresetsHandler,c as RelationsHandler,d as RevisionsHandler,l as RolesHandler,p as ServerHandler,f as SettingsHandler,x as TransportError,y as UsersHandler,_ as UtilsHandler}; | ||
function t(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}class e{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(e)}`,{params:r})).data}))}readMany(e){return t(this,void 0,void 0,(function*(){const{data:t,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:e});return{data:t,meta:r}}))}createOne(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,e,{params:r})).data}))}createMany(e,r){return t(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,e,{params:r})}))}updateOne(e,r,s){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(e)}`,r,{params:s})).data}))}updateMany(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:e,data:r},{params:s})}))}deleteOne(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(e)}`)}))}deleteMany(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,e)}))}}class r{constructor(t){this.transport=t}create(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",e)).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(e)}`,{comment:r})).data}))}delete(e){return t(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(e)}`)}))}}class s extends e{constructor(t){super("directus_activity",t),this._comments=new r(this.transport)}get comments(){return this._comments}}class n extends e{constructor(t){super("directus_collections",t)}}class i extends e{constructor(t){super("directus_fields",t)}}class o extends e{constructor(t){super("directus_files",t)}}class a extends e{constructor(t){super("directus_folders",t)}}class u extends e{constructor(t){super("directus_permissions",t)}}class h extends e{constructor(t){super("directus_presets",t)}}class c extends e{constructor(t){super("directus_relations",t)}}class d extends e{constructor(t){super("directus_revisions",t)}}class l extends e{constructor(t){super("directus_roles",t)}}class p{constructor(t){this.transport=t}ping(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return t(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class f extends e{constructor(t){super("directus_settings",t)}}class v{constructor(t){this.transport=t}send(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:e,role:r})}))}accept(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:e,password:r})}))}}class m{constructor(t){this.transport=t}enable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:e})}))}disable(e){return t(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:e})}))}}class g{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new m(this._transport))}read(e){return t(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",e,{params:r})).data}))}}class y extends e{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new v(this.transport))}get me(){return this._me||(this._me=new g(this.transport))}}class _{constructor(e){this.random={string:(e=32)=>t(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:e}})).data}))},this.hash={generate:e=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:e})).data})),verify:(e,r)=>t(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:e,hash:r})).data}))},this.transport=e}sort(e,r,s){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(e)}`,{item:r,to:s})}))}revert(e){return t(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(e)}`)}))}}var w;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(w||(w={}));class x extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,x.prototype)}}class b{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class k extends b{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends b{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var R=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)}},T=Object.prototype.toString;function j(t){return"[object Array]"===T.call(t)}function O(t){return void 0===t}function S(t){return null!==t&&"object"==typeof t}function A(t){if("[object Object]"!==T.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function C(t){return"[object Function]"===T.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 U={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===T.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:S,isPlainObject:A,isUndefined:O,isDate:function(t){return"[object Date]"===T.call(t)},isFile:function(t){return"[object File]"===T.call(t)},isBlob:function(t){return"[object Blob]"===T.call(t)},isFunction:C,isStream:function(t){return S(t)&&C(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){A(e[s])&&A(r)?e[s]=t(e[s],r):A(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?R(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 N(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var B=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(N(e)+"="+N(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 P(){this.handlers=[]}P.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},P.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},P.prototype.forEach=function(t){U.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=P,L=function(t,e,r){return U.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){U.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)},F=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(){}},H=["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"],M=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},X=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(),B(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]&&H.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(z("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(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},U.isStandardBrowserEnv()){var d=(t.withCredentials||M(c))&&t.xsrfCookieName?F.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)}))},J={"Content-Type":"application/x-www-form-urlencoded"};function V(t,e){!U.isUndefined(t)&&U.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var K,W={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(K=X),K),transformRequest:[function(t,e){return D(e,"Accept"),D(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)?(V(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):U.isObject(t)?(V(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}};W.headers={common:{Accept:"application/json, text/plain, */*"}},U.forEach(["delete","get","head"],(function(t){W.headers[t]={}})),U.forEach(["post","put","patch"],(function(t){W.headers[t]=U.merge(J)}));var G=W;function Q(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var Y=function(t){return Q(t),t.headers=t.headers||{},t.data=L(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||G.adapter)(t).then((function(e){return Q(t),e.data=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Q(t),e&&e.response&&(e.response.data=L(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Z=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 tt(t){this.defaults=t,this.interceptors={request:new $,response:new $}}tt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Z(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[Y,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},tt.prototype.getUri=function(t){return t=Z(this.defaults,t),B(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},U.forEach(["delete","get","head","options"],(function(t){tt.prototype[t]=function(e,r){return this.request(Z(r||{},{method:t,url:e,data:(r||{}).data}))}})),U.forEach(["post","put","patch"],(function(t){tt.prototype[t]=function(e,r,s){return this.request(Z(s||{},{method:t,url:e,data:r}))}}));var et=tt;function rt(t){this.message=t}rt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},rt.prototype.__CANCEL__=!0;var st=rt;function nt(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 st(t),e(r.reason))}))}nt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},nt.source=function(){var t;return{token:new nt((function(e){t=e})),cancel:t}};var it=nt;function ot(t){var e=new et(t),r=R(et.prototype.request,e);return U.extend(r,et.prototype,e),U.extend(r,e),r}var at=ot(G);at.Axios=et,at.create=function(t){return ot(Z(at.defaults,t))},at.Cancel=st,at.CancelToken=it,at.isCancel=I,at.all=function(t){return Promise.all(t)},at.spread=function(t){return function(e){return t.apply(null,e)}},at.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var ut=at,ht=at;ut.default=ht;var ct=ut;class dt{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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(e,r,s,n){var i,o,a,u,h,c,d,l;return t(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const t={method:e,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?t.headers.Authorization=u:t.headers.Authorization=`Bearer ${u}`);const c=yield this.axios.request(t),d=c.data,l={raw:c.data,status:c.status,statusText:c.statusText,headers:c.headers,data:d.data,meta:d.meta,errors:d.errors};if(d.errors)throw new x(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new x(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(c=t.response)||void 0===c?void 0:c.status,statusText:null===(d=t.response)||void 0===d?void 0:d.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new x(t)}}))}get(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("get",e,void 0,r)}))}head(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("head",e,void 0,r)}))}options(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("options",e,void 0,r)}))}delete(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("delete",e,r,s)}))}put(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("put",e,r,s)}))}post(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("post",e,r,s)}))}patch(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.request("patch",e,r,s)}))}}class lt{constructor(t){this.transport=t}request(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/request",{email:e,reset_url:r})}))}reset(e,r){return t(this,void 0,void 0,(function*(){yield this.transport.post("/auth/password/reset",{token:e,password:r})}))}}class pt{constructor(t){this.func=t,this.debounced=[],this.debouncing=!1}debounce(...e){return t(this,void 0,void 0,(function*(){return this.debouncing?yield new Promise(((t,e)=>{this.debounced.push({resolve:e=>t(e),reject:t=>e(t)})})):(this.debouncing=!0,new Promise(((t,r)=>{this.func(...e).then((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.resolve(e)))})).catch((e=>{const s=[{resolve:t,reject:r},...this.debounced];this.debounced=[],this.debouncing=!1,s.forEach((t=>t.reject(e)))}))})))}))}}class ft{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 pt(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 lt(this.transport)}get expiring(){var t,e;const r=this.storage.auth_expires;if(null===r)return!1;return r-(null!==(e=null===(t=this.options.refresh)||void 0===t?void 0:t.time)&&void 0!==e?e:0)<=Date.now()}refreshToken(e=!1){var r;return t(this,void 0,void 0,(function*(){if(!e&&!this.expiring)return!1;const t=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(t.data),this.updateRefresh(),{access_token:t.data.access_token,refresh_token:null===(r=t.data)||void 0===r?void 0:r.refresh_token,expires:t.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(e=!1){return t(this,void 0,void 0,(function*(){return yield this.refresher.debounce(e)}))}login(e,r){var s;return t(this,void 0,void 0,(function*(){r=r||{};const t=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},e),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(t.data),this.updateRefresh(r.refresh),{access_token:t.data.access_token,refresh_token:null===(s=t.data)||void 0===s?void 0:s.refresh_token,expires:t.data.expires}}))}static(e){return t(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:e}}),this.storage.auth_token=e,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return t(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class vt{constructor(t){this.transport=t}request(e,r,s){return t(this,void 0,void 0,(function*(){return yield this.transport.post(e,{query:r,variables:void 0===s?{}:s})}))}items(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql",e,r)}))}system(e,r){return t(this,void 0,void 0,(function*(){return yield this.request("/graphql/system",e,r)}))}}class mt{constructor(t,e){this.collection=t,this.transport=e}read(e){return t(this,void 0,void 0,(function*(){return(yield this.transport.get(`/items/${this.collection}`,{params:e})).data}))}update(e,r){return t(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/items/${this.collection}`,e,{params:r})).data}))}}class gt{constructor(e,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new k),this._transport=(null==r?void 0:r.transport)||new dt(e,this._storage,(()=>t(this,void 0,void 0,(function*(){yield this._auth.refresh()})))),this._auth=(null==r?void 0:r.auth)||new ft(this._transport,this._storage),this._items={},this._singletons={}}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new s(this.transport))}get collections(){return this._collections||(this._collections=new n(this.transport))}get fields(){return this._fields||(this._fields=new i(this.transport))}get files(){return this._files||(this._files=new o(this.transport))}get folders(){return this._folders||(this._folders=new a(this.transport))}get permissions(){return this._permissions||(this._permissions=new u(this.transport))}get presets(){return this._presets||(this._presets=new h(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new d(this.transport))}get roles(){return this._roles||(this._roles=new l(this.transport))}get settings(){return this._settings||(this._settings=new f(this.transport))}get users(){return this._users||(this._users=new y(this.transport))}get server(){return this._server||(this._server=new p(this.transport))}get utils(){return this._utils||(this._utils=new _(this.transport))}get graphql(){return this._graphql||(this._graphql=new vt(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new mt(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new e(t,this.transport))}}export{s as ActivityHandler,ft as Auth,dt as AxiosTransport,b as BaseStorage,n as CollectionsHandler,r as CommentsHandler,gt as Directus,i as FieldsHandler,o as FilesHandler,a as FoldersHandler,e as ItemsHandler,E as LocalStorage,k as MemoryStorage,w as Meta,u as PermissionsHandler,h as PresetsHandler,c as RelationsHandler,d as RevisionsHandler,l as RolesHandler,p as ServerHandler,f as SettingsHandler,x as TransportError,y as UsersHandler,_ as UtilsHandler}; | ||
//# sourceMappingURL=sdk.esm.min.js.map |
@@ -15,3 +15,3 @@ var Directus=function(t){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r){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 d extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class p extends r{constructor(t){super("directus_roles",t)}}class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var S=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)}},T=Object.prototype.toString;function j(t){return"[object Array]"===T.call(t)}function O(t){return void 0===t}function A(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==T.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function U(t){return"[object Function]"===T.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 N={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===T.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:A,isPlainObject:C,isUndefined:O,isDate:function(t){return"[object Date]"===T.call(t)},isFile:function(t){return"[object File]"===T.call(t)},isBlob:function(t){return"[object Blob]"===T.call(t)},isFunction:U,isStream:function(t){return A(t)&&U(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:q,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):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?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 P(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var B=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(N.isURLSearchParams(e))s=e.toString();else{var n=[];N.forEach(e,(function(t,e){null!=t&&(N.isArray(t)?e+="[]":t=[t],N.forEach(t,(function(t){N.isDate(t)?t=t.toISOString():N.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 H(){this.handlers=[]}H.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){N.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=H,L=function(t,e,r){return N.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){N.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)},M=N.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),N.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),N.isString(s)&&o.push("path="+s),N.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(){}},z=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],X=N.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=N.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;N.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(),B(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?(N.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=N.trim(t.substr(0,a)).toLowerCase(),o=N.trim(t.substr(a+1)),n){if(u[n]&&z.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(F("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(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},N.isStandardBrowserEnv()){var c=(t.withCredentials||X(d))&&t.xsrfCookieName?M.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&N.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),N.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){!N.isUndefined(t)&&N.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 D(e,"Accept"),D(e,"Content-Type"),N.isFormData(t)||N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)?t:N.isArrayBufferView(t)?t.buffer:N.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):N.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, */*"}},N.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),N.forEach(["post","put","patch"],(function(t){G.headers[t]=N.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=L(t.data,t.headers,t.transformRequest),t.headers=N.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),N.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=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Y(t),e&&e.response&&(e.response.data=L(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 N.isPlainObject(t)&&N.isPlainObject(e)?N.merge(t,e):N.isPlainObject(e)?N.merge({},e):N.isArray(e)?e.slice():e}function u(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}N.forEach(s,(function(t){N.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),N.forEach(n,u),N.forEach(i,(function(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),N.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 N.forEach(d,u),r};function et(t){this.defaults=t,this.interceptors={request:new $,response:new $}}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),B(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},N.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}))}})),N.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=S(rt.prototype.request,e);return N.extend(r,rt.prototype,e),N.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=I,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,dt=ut;ht.default=dt;var ct=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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class 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(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class 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}))}}return t.ActivityHandler=n,t.Auth=vt,t.AxiosTransport=lt,t.BaseStorage=k,t.CollectionsHandler=i,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new 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 d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new 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))}},t.FieldsHandler=o,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=h,t.PresetsHandler=d,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=p,t.ServerHandler=f,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}class i extends r{constructor(t){super("directus_collections",t)}}class o extends r{constructor(t){super("directus_fields",t)}}class a extends r{constructor(t){super("directus_files",t)}}class u extends r{constructor(t){super("directus_folders",t)}}class h extends r{constructor(t){super("directus_permissions",t)}}class d extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class p extends r{constructor(t){super("directus_roles",t)}}class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var S=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)}},T=Object.prototype.toString;function j(t){return"[object Array]"===T.call(t)}function O(t){return void 0===t}function A(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==T.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function U(t){return"[object Function]"===T.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 N={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===T.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:A,isPlainObject:C,isUndefined:O,isDate:function(t){return"[object Date]"===T.call(t)},isFile:function(t){return"[object File]"===T.call(t)},isBlob:function(t){return"[object Blob]"===T.call(t)},isFunction:U,isStream:function(t){return A(t)&&U(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:q,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):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?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 P(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var B=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(N.isURLSearchParams(e))s=e.toString();else{var n=[];N.forEach(e,(function(t,e){null!=t&&(N.isArray(t)?e+="[]":t=[t],N.forEach(t,(function(t){N.isDate(t)?t=t.toISOString():N.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 H(){this.handlers=[]}H.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){N.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=H,L=function(t,e,r){return N.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){N.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)},M=N.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),N.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),N.isString(s)&&o.push("path="+s),N.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(){}},z=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],X=N.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=N.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;N.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(),B(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?(N.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=N.trim(t.substr(0,a)).toLowerCase(),o=N.trim(t.substr(a+1)),n){if(u[n]&&z.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(F("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(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},N.isStandardBrowserEnv()){var c=(t.withCredentials||X(d))&&t.xsrfCookieName?M.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&N.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),N.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){!N.isUndefined(t)&&N.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 D(e,"Accept"),D(e,"Content-Type"),N.isFormData(t)||N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)?t:N.isArrayBufferView(t)?t.buffer:N.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):N.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, */*"}},N.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),N.forEach(["post","put","patch"],(function(t){G.headers[t]=N.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=L(t.data,t.headers,t.transformRequest),t.headers=N.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),N.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=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Y(t),e&&e.response&&(e.response.data=L(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 N.isPlainObject(t)&&N.isPlainObject(e)?N.merge(t,e):N.isPlainObject(e)?N.merge({},e):N.isArray(e)?e.slice():e}function u(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}N.forEach(s,(function(t){N.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),N.forEach(n,u),N.forEach(i,(function(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),N.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 N.forEach(d,u),r};function et(t){this.defaults=t,this.interceptors={request:new $,response:new $}}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),B(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},N.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}))}})),N.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=S(rt.prototype.request,e);return N.extend(r,rt.prototype,e),N.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=I,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,dt=ut;ht.default=dt;var ct=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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class 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(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class 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}))}}return t.ActivityHandler=n,t.Auth=vt,t.AxiosTransport=lt,t.BaseStorage=k,t.CollectionsHandler=i,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new 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 d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new 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))}},t.FieldsHandler=o,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=h,t.PresetsHandler=d,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=p,t.ServerHandler=f,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
//# sourceMappingURL=sdk.iife.min.js.map |
@@ -16,3 +16,3 @@ System.register("Directus",[],(function(t){"use strict";return{execute:function(){ | ||
***************************************************************************** */ | ||
function e(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}t("Meta",void 0);class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r){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)}))}}t("ItemsHandler",r);class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}t("CommentsHandler",s);class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}t("ActivityHandler",n);class i extends r{constructor(t){super("directus_collections",t)}}t("CollectionsHandler",i);class o extends r{constructor(t){super("directus_fields",t)}}t("FieldsHandler",o);class a extends r{constructor(t){super("directus_files",t)}}t("FilesHandler",a);class u extends r{constructor(t){super("directus_folders",t)}}t("FoldersHandler",u);class h extends r{constructor(t){super("directus_permissions",t)}}t("PermissionsHandler",h);class d extends r{constructor(t){super("directus_presets",t)}}t("PresetsHandler",d);class c extends r{constructor(t){super("directus_relations",t)}}t("RelationsHandler",c);class l extends r{constructor(t){super("directus_revisions",t)}}t("RevisionsHandler",l);class p extends r{constructor(t){super("directus_roles",t)}}t("RolesHandler",p);class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}t("ServerHandler",f);class v extends r{constructor(t){super("directus_settings",t)}}t("SettingsHandler",v);class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}t("UsersHandler",_);class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t("UtilsHandler",w),function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(x||(x=t("Meta",{})));class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}t("TransportError",b);class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}t("BaseStorage",k);class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}t("MemoryStorage",R);class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}t("LocalStorage",E);var S=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)}},T=Object.prototype.toString;function j(t){return"[object Array]"===T.call(t)}function A(t){return void 0===t}function O(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==T.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function U(t){return"[object Function]"===T.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 N={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===T.call(t)},isBuffer:function(t){return null!==t&&!A(t)&&null!==t.constructor&&!A(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:O,isPlainObject:C,isUndefined:A,isDate:function(t){return"[object Date]"===T.call(t)},isFile:function(t){return"[object File]"===T.call(t)},isBlob:function(t){return"[object Blob]"===T.call(t)},isFunction:U,isStream:function(t){return O(t)&&U(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:q,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):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?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 P=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(N.isURLSearchParams(e))s=e.toString();else{var n=[];N.forEach(e,(function(t,e){null!=t&&(N.isArray(t)?e+="[]":t=[t],N.forEach(t,(function(t){N.isDate(t)?t=t.toISOString():N.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 H(){this.handlers=[]}H.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){N.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=H,L=function(t,e,r){return N.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){N.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)},z=N.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),N.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),N.isString(s)&&o.push("path="+s),N.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=N.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=N.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;N.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(),P(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?(N.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=N.trim(t.substr(0,a)).toLowerCase(),o=N.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,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(F("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(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},N.isStandardBrowserEnv()){var c=(t.withCredentials||X(d))&&t.xsrfCookieName?z.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&N.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),N.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){!N.isUndefined(t)&&N.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 D(e,"Accept"),D(e,"Content-Type"),N.isFormData(t)||N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)?t:N.isArrayBufferView(t)?t.buffer:N.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):N.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, */*"}},N.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),N.forEach(["post","put","patch"],(function(t){G.headers[t]=N.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=L(t.data,t.headers,t.transformRequest),t.headers=N.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),N.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=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Y(t),e&&e.response&&(e.response.data=L(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 N.isPlainObject(t)&&N.isPlainObject(e)?N.merge(t,e):N.isPlainObject(e)?N.merge({},e):N.isArray(e)?e.slice():e}function u(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}N.forEach(s,(function(t){N.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),N.forEach(n,u),N.forEach(i,(function(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),N.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 N.forEach(d,u),r};function et(t){this.defaults=t,this.interceptors={request:new $,response:new $}}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(/^\?/,"")},N.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}))}})),N.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=S(rt.prototype.request,e);return N.extend(r,rt.prototype,e),N.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=I,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,dt=ut;ht.default=dt;var ct=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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}t("AxiosTransport",lt);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(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}t("Auth",vt);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}))}}t("Directus",class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new 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 d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new 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))}})}}})); | ||
function e(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}t("Meta",void 0);class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}t("ItemsHandler",r);class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}t("CommentsHandler",s);class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}t("ActivityHandler",n);class i extends r{constructor(t){super("directus_collections",t)}}t("CollectionsHandler",i);class o extends r{constructor(t){super("directus_fields",t)}}t("FieldsHandler",o);class a extends r{constructor(t){super("directus_files",t)}}t("FilesHandler",a);class u extends r{constructor(t){super("directus_folders",t)}}t("FoldersHandler",u);class h extends r{constructor(t){super("directus_permissions",t)}}t("PermissionsHandler",h);class d extends r{constructor(t){super("directus_presets",t)}}t("PresetsHandler",d);class c extends r{constructor(t){super("directus_relations",t)}}t("RelationsHandler",c);class l extends r{constructor(t){super("directus_revisions",t)}}t("RevisionsHandler",l);class p extends r{constructor(t){super("directus_roles",t)}}t("RolesHandler",p);class f{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}t("ServerHandler",f);class v extends r{constructor(t){super("directus_settings",t)}}t("SettingsHandler",v);class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}t("UsersHandler",_);class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t("UtilsHandler",w),function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(x||(x=t("Meta",{})));class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}t("TransportError",b);class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}t("BaseStorage",k);class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}t("MemoryStorage",R);class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}t("LocalStorage",E);var S=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)}},T=Object.prototype.toString;function j(t){return"[object Array]"===T.call(t)}function A(t){return void 0===t}function O(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==T.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function U(t){return"[object Function]"===T.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 N={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===T.call(t)},isBuffer:function(t){return null!==t&&!A(t)&&null!==t.constructor&&!A(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:O,isPlainObject:C,isUndefined:A,isDate:function(t){return"[object Date]"===T.call(t)},isFile:function(t){return"[object File]"===T.call(t)},isBlob:function(t){return"[object Blob]"===T.call(t)},isFunction:U,isStream:function(t){return O(t)&&U(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:q,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):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?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 P=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(N.isURLSearchParams(e))s=e.toString();else{var n=[];N.forEach(e,(function(t,e){null!=t&&(N.isArray(t)?e+="[]":t=[t],N.forEach(t,(function(t){N.isDate(t)?t=t.toISOString():N.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 H(){this.handlers=[]}H.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){N.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=H,L=function(t,e,r){return N.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){N.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)},z=N.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),N.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),N.isString(s)&&o.push("path="+s),N.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=N.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=N.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;N.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(),P(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?(N.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=N.trim(t.substr(0,a)).toLowerCase(),o=N.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,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(F("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(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},N.isStandardBrowserEnv()){var c=(t.withCredentials||X(d))&&t.xsrfCookieName?z.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&N.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),N.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){!N.isUndefined(t)&&N.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 D(e,"Accept"),D(e,"Content-Type"),N.isFormData(t)||N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)?t:N.isArrayBufferView(t)?t.buffer:N.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):N.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, */*"}},N.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),N.forEach(["post","put","patch"],(function(t){G.headers[t]=N.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=L(t.data,t.headers,t.transformRequest),t.headers=N.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),N.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=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Y(t),e&&e.response&&(e.response.data=L(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 N.isPlainObject(t)&&N.isPlainObject(e)?N.merge(t,e):N.isPlainObject(e)?N.merge({},e):N.isArray(e)?e.slice():e}function u(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}N.forEach(s,(function(t){N.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),N.forEach(n,u),N.forEach(i,(function(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),N.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 N.forEach(d,u),r};function et(t){this.defaults=t,this.interceptors={request:new $,response:new $}}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(/^\?/,"")},N.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}))}})),N.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=S(rt.prototype.request,e);return N.extend(r,rt.prototype,e),N.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=I,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,dt=ut;ht.default=dt;var ct=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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}t("AxiosTransport",lt);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(t=!1){var r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}t("Auth",vt);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}))}}t("Directus",class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new 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 d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new p(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new f(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new 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))}})}}})); | ||
//# sourceMappingURL=sdk.system.min.js.map |
@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Directus={})}(this,(function(t){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,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 d extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class f extends r{constructor(t){super("directus_roles",t)}}class p{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var T=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)}},S=Object.prototype.toString;function j(t){return"[object Array]"===S.call(t)}function O(t){return void 0===t}function A(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==S.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function U(t){return"[object Function]"===S.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 N={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===S.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:A,isPlainObject:C,isUndefined:O,isDate:function(t){return"[object Date]"===S.call(t)},isFile:function(t){return"[object File]"===S.call(t)},isBlob:function(t){return"[object Blob]"===S.call(t)},isFunction:U,isStream:function(t){return A(t)&&U(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:q,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):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 B=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(N.isURLSearchParams(e))s=e.toString();else{var n=[];N.forEach(e,(function(t,e){null!=t&&(N.isArray(t)?e+="[]":t=[t],N.forEach(t,(function(t){N.isDate(t)?t=t.toISOString():N.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 H(){this.handlers=[]}H.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){N.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=H,L=function(t,e,r){return N.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){N.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)},M=N.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),N.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),N.isString(s)&&o.push("path="+s),N.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(){}},z=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],X=N.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=N.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;N.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(),B(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?(N.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=N.trim(t.substr(0,a)).toLowerCase(),o=N.trim(t.substr(a+1)),n){if(u[n]&&z.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(F("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(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},N.isStandardBrowserEnv()){var c=(t.withCredentials||X(d))&&t.xsrfCookieName?M.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&N.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),N.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){!N.isUndefined(t)&&N.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 D(e,"Accept"),D(e,"Content-Type"),N.isFormData(t)||N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)?t:N.isArrayBufferView(t)?t.buffer:N.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):N.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, */*"}},N.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),N.forEach(["post","put","patch"],(function(t){G.headers[t]=N.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=L(t.data,t.headers,t.transformRequest),t.headers=N.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),N.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=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Y(t),e&&e.response&&(e.response.data=L(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 N.isPlainObject(t)&&N.isPlainObject(e)?N.merge(t,e):N.isPlainObject(e)?N.merge({},e):N.isArray(e)?e.slice():e}function u(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}N.forEach(s,(function(t){N.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),N.forEach(n,u),N.forEach(i,(function(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),N.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 N.forEach(d,u),r};function et(t){this.defaults=t,this.interceptors={request:new $,response:new $}}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),B(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},N.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}))}})),N.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 N.extend(r,rt.prototype,e),N.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=I,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,dt=ut;ht.default=dt;var ct=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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class ft{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 pt{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 pt(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 r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class 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}))}}t.ActivityHandler=n,t.Auth=vt,t.AxiosTransport=lt,t.BaseStorage=k,t.CollectionsHandler=i,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new 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 d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new f(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new p(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new 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))}},t.FieldsHandler=o,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=h,t.PresetsHandler=d,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=f,t.ServerHandler=p,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
***************************************************************************** */function e(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{u(s.next(t))}catch(t){i(t)}}function a(t){try{u(s.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}u((s=s.apply(t,e||[])).next())}))}class r{constructor(t,e){this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}readOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:r})).data}))}readMany(t){return e(this,void 0,void 0,(function*(){const{data:e,meta:r}=yield this.transport.get(`${this.endpoint}`,{params:t});return{data:e,meta:r}}))}createOne(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.post(`${this.endpoint}`,t,{params:r})).data}))}createMany(t,r){return e(this,void 0,void 0,(function*(){return yield this.transport.post(`${this.endpoint}`,t,{params:r})}))}updateOne(t,r,s){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,r,{params:s})).data}))}updateMany(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.transport.patch(`${this.endpoint}`,{keys:t,data:r},{params:s})}))}deleteOne(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}/${encodeURI(t)}`)}))}deleteMany(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`${this.endpoint}`,t)}))}}class s{constructor(t){this.transport=t}create(t){return e(this,void 0,void 0,(function*(){return(yield this.transport.post("/activity/comment",t)).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:r})).data}))}delete(t){return e(this,void 0,void 0,(function*(){yield this.transport.delete(`/activity/comment/${encodeURI(t)}`)}))}}class n extends r{constructor(t){super("directus_activity",t),this._comments=new s(this.transport)}get comments(){return this._comments}}class i extends r{constructor(t){super("directus_collections",t)}}class o extends r{constructor(t){super("directus_fields",t)}}class a extends r{constructor(t){super("directus_files",t)}}class u extends r{constructor(t){super("directus_folders",t)}}class h extends r{constructor(t){super("directus_permissions",t)}}class d extends r{constructor(t){super("directus_presets",t)}}class c extends r{constructor(t){super("directus_relations",t)}}class l extends r{constructor(t){super("directus_revisions",t)}}class f extends r{constructor(t){super("directus_roles",t)}}class p{constructor(t){this.transport=t}ping(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/ping")).raw}))}info(){return e(this,void 0,void 0,(function*(){return(yield this.transport.get("/server/info")).data}))}}class v extends r{constructor(t){super("directus_settings",t)}}class m{constructor(t){this.transport=t}send(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/invite",{email:t,role:r})}))}accept(t,r){return e(this,void 0,void 0,(function*(){yield this.transport.patch("/users/invite/accept",{token:t,password:r})}))}}class g{constructor(t){this.transport=t}enable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/enable",{password:t})}))}disable(t){return e(this,void 0,void 0,(function*(){yield this.transport.post("/users/me/tfa/disable",{otp:t})}))}}class y{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new g(this._transport))}read(t){return e(this,void 0,void 0,(function*(){return(yield this._transport.get("/users/me",{params:t})).data}))}update(t,r){return e(this,void 0,void 0,(function*(){return(yield this._transport.patch("/users/me",t,{params:r})).data}))}}class _ extends r{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new m(this.transport))}get me(){return this._me||(this._me=new y(this.transport))}}class w{constructor(t){this.random={string:(t=32)=>e(this,void 0,void 0,(function*(){return(yield this.transport.get("/utils/random/string",{params:{length:t}})).data}))},this.hash={generate:t=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/generate",{string:t})).data})),verify:(t,r)=>e(this,void 0,void 0,(function*(){return(yield this.transport.post("/utils/hash/verify",{string:t,hash:r})).data}))},this.transport=t}sort(t,r,s){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:r,to:s})}))}revert(t){return e(this,void 0,void 0,(function*(){yield this.transport.post(`/utils/revert/${encodeURI(t)}`)}))}}var x;t.Meta=void 0,(x=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",x.FILTER_COUNT="filter_count";class b extends Error{constructor(t,e){var r,s;(null===(r=null==e?void 0:e.errors)||void 0===r?void 0:r.length)?super(null===(s=null==e?void 0:e.errors[0])||void 0===s?void 0:s.message):super((null==t?void 0:t.message)||"Unknown transport error"),this.parent=t,this.response=e,this.errors=(null==e?void 0:e.errors)||[],Object.values(e||{}).some((t=>void 0!==t))||(this.response=void 0),Object.setPrototypeOf(this,b.prototype)}}class k{get auth_token(){return this.get("auth_token")}set auth_token(t){null===t?this.delete("auth_token"):this.set("auth_token",t)}get auth_expires(){const t=this.get("auth_expires");return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete("auth_expires"):this.set("auth_expires",t.toString())}get auth_refresh_token(){return this.get("auth_refresh_token")}set auth_refresh_token(t){null===t?this.delete("auth_refresh_token"):this.set("auth_refresh_token",t)}}class R extends k{constructor(t=""){super(),this.values={},this.prefix=t}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class E extends k{constructor(t=""){super(),this.prefix=t}get(t){const e=localStorage.getItem(this.key(t));return null!==e?e:null}set(t,e){return localStorage.setItem(this.key(t),e),e}delete(t){const e=this.key(t),r=this.get(e);return r&&localStorage.removeItem(e),r}key(t){return`${this.prefix}${t}`}}var T=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)}},S=Object.prototype.toString;function j(t){return"[object Array]"===S.call(t)}function O(t){return void 0===t}function A(t){return null!==t&&"object"==typeof t}function C(t){if("[object Object]"!==S.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function U(t){return"[object Function]"===S.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 N={isArray:j,isArrayBuffer:function(t){return"[object ArrayBuffer]"===S.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:A,isPlainObject:C,isUndefined:O,isDate:function(t){return"[object Date]"===S.call(t)},isFile:function(t){return"[object File]"===S.call(t)},isBlob:function(t){return"[object Blob]"===S.call(t)},isFunction:U,isStream:function(t){return A(t)&&U(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:q,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):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 B=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(N.isURLSearchParams(e))s=e.toString();else{var n=[];N.forEach(e,(function(t,e){null!=t&&(N.isArray(t)?e+="[]":t=[t],N.forEach(t,(function(t){N.isDate(t)?t=t.toISOString():N.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 H(){this.handlers=[]}H.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){N.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var $=H,L=function(t,e,r){return N.forEach(r,(function(r){t=r(t,e)})),t},I=function(t){return!(!t||!t.__CANCEL__)},D=function(t,e){N.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)},M=N.isStandardBrowserEnv()?{write:function(t,e,r,s,n,i){var o=[];o.push(t+"="+encodeURIComponent(e)),N.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),N.isString(s)&&o.push("path="+s),N.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(){}},z=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],X=N.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=N.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;N.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(),B(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?(N.forEach(s.split("\n"),(function(t){if(a=t.indexOf(":"),n=N.trim(t.substr(0,a)).toLowerCase(),o=N.trim(t.substr(a+1)),n){if(u[n]&&z.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(F("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(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},N.isStandardBrowserEnv()){var c=(t.withCredentials||X(d))&&t.xsrfCookieName?M.read(t.xsrfCookieName):void 0;c&&(n[t.xsrfHeaderName]=c)}if("setRequestHeader"in i&&N.forEach(n,(function(t,e){void 0===s&&"content-type"===e.toLowerCase()?delete n[e]:i.setRequestHeader(e,t)})),N.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){!N.isUndefined(t)&&N.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 D(e,"Accept"),D(e,"Content-Type"),N.isFormData(t)||N.isArrayBuffer(t)||N.isBuffer(t)||N.isStream(t)||N.isFile(t)||N.isBlob(t)?t:N.isArrayBufferView(t)?t.buffer:N.isURLSearchParams(t)?(K(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):N.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, */*"}},N.forEach(["delete","get","head"],(function(t){G.headers[t]={}})),N.forEach(["post","put","patch"],(function(t){G.headers[t]=N.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=L(t.data,t.headers,t.transformRequest),t.headers=N.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),N.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=L(e.data,e.headers,t.transformResponse),e}),(function(e){return I(e)||(Y(t),e&&e.response&&(e.response.data=L(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 N.isPlainObject(t)&&N.isPlainObject(e)?N.merge(t,e):N.isPlainObject(e)?N.merge({},e):N.isArray(e)?e.slice():e}function u(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(t[s],e[s])}N.forEach(s,(function(t){N.isUndefined(e[t])||(r[t]=a(void 0,e[t]))})),N.forEach(n,u),N.forEach(i,(function(s){N.isUndefined(e[s])?N.isUndefined(t[s])||(r[s]=a(void 0,t[s])):r[s]=a(void 0,e[s])})),N.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 N.forEach(d,u),r};function et(t){this.defaults=t,this.interceptors={request:new $,response:new $}}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),B(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},N.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}))}})),N.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 N.extend(r,rt.prototype,e),N.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=I,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,dt=ut;ht.default=dt;var ct=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=ct.create({baseURL:t,withCredentials:!0})}get axios(){return this._axios}request(t,r,s,n){var i,o,a,u,h,d,c,l;return e(this,void 0,void 0,(function*(){try{(n=n||{}).sendAuthorizationHeaders=null===(i=n.sendAuthorizationHeaders)||void 0===i||i,n.refreshTokenIfNeeded=null===(o=n.refreshTokenIfNeeded)||void 0===o||o,n.headers=null!==(a=n.headers)&&void 0!==a?a:{},n.refreshTokenIfNeeded&&(yield this._refresh());const e={method:t,url:r,data:s,params:n.params,headers:n.headers},u=this._storage.auth_token,h=this._storage.auth_expires;n.sendAuthorizationHeaders&&u&&(null!==h&&h>Date.now()||null===h)&&(u.startsWith("Bearer ")?e.headers.Authorization=u:e.headers.Authorization=`Bearer ${u}`);const d=yield this.axios.request(e),c=d.data,l={raw:d.data,status:d.status,statusText:d.statusText,headers:d.headers,data:c.data,meta:c.meta,errors:c.errors};if(c.errors)throw new b(null,l);return l}catch(t){if(ct.isAxiosError(t)){const e=null===(u=t.response)||void 0===u?void 0:u.data;throw new b(t,{raw:null===(h=t.response)||void 0===h?void 0:h.data,status:null===(d=t.response)||void 0===d?void 0:d.status,statusText:null===(c=t.response)||void 0===c?void 0:c.statusText,headers:null===(l=t.response)||void 0===l?void 0:l.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new b(t)}}))}get(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("get",t,void 0,r)}))}head(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("head",t,void 0,r)}))}options(t,r){return e(this,void 0,void 0,(function*(){return yield this.request("options",t,void 0,r)}))}delete(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("delete",t,r,s)}))}put(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("put",t,r,s)}))}post(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("post",t,r,s)}))}patch(t,r,s){return e(this,void 0,void 0,(function*(){return yield this.request("patch",t,r,s)}))}}class ft{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 pt{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 pt(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 r;return e(this,void 0,void 0,(function*(){if(!t&&!this.expiring)return!1;const e=yield this.transport.post("/auth/refresh",{refresh_token:"json"===this.options.mode?this.storage.auth_refresh_token:void 0},{refreshTokenIfNeeded:!1});return this.updateStorage(e.data),this.updateRefresh(),{access_token:e.data.access_token,refresh_token:null===(r=e.data)||void 0===r?void 0:r.refresh_token,expires:e.data.expires}}))}updateStorage(t){var e;this.storage.auth_token=t.access_token,this.storage.auth_refresh_token=null!==(e=t.refresh_token)&&void 0!==e?e:null,t.expires?this.storage.auth_expires=Date.now()+t.expires:this.storage.auth_expires=null}updateRefresh(t){var e,r;const s=this.storage.auth_expires;if(null===s)return void clearTimeout(this.timer);t&&(this.options.refresh.auto=null!==(e=t.auto)&&void 0!==e?e:this.options.refresh.auto,this.options.refresh.time=null!==(r=t.time)&&void 0!==r?r:this.options.refresh.time),clearTimeout(this.timer);let n=s-this.options.refresh.time-Date.now();if(n<0){if(s<Date.now())return;n=0}this.options.refresh.auto&&(this.timer=setTimeout((()=>{this.refresh().then((()=>{})).catch((()=>{}))}),n))}refresh(t=!1){return e(this,void 0,void 0,(function*(){return yield this.refresher.debounce(t)}))}login(t,r){var s;return e(this,void 0,void 0,(function*(){r=r||{};const e=yield this.transport.post("/auth/login",Object.assign({mode:this.options.mode},t),{refreshTokenIfNeeded:!1,sendAuthorizationHeaders:!1});return this.updateStorage(e.data),this.updateRefresh(r.refresh),{access_token:e.data.access_token,refresh_token:null===(s=e.data)||void 0===s?void 0:s.refresh_token,expires:e.data.expires}}))}static(t){return e(this,void 0,void 0,(function*(){return yield this.transport.get("/users/me",{params:{access_token:t}}),this.storage.auth_token=t,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,!0}))}logout(){return e(this,void 0,void 0,(function*(){let t;"json"===this.options.mode&&(t=this.storage.auth_refresh_token||void 0),yield this.transport.post("/auth/logout",{refresh_token:t},{refreshTokenIfNeeded:!1}),this.storage.auth_token=null,this.storage.auth_expires=null,this.storage.auth_refresh_token=null,clearTimeout(this.timer)}))}}class 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}))}}t.ActivityHandler=n,t.Auth=vt,t.AxiosTransport=lt,t.BaseStorage=k,t.CollectionsHandler=i,t.CommentsHandler=s,t.Directus=class{constructor(t,r){this._storage=(null==r?void 0:r.storage)||("undefined"!=typeof window?new E:new R),this._transport=(null==r?void 0:r.transport)||new 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 d(this.transport))}get relations(){return this._relations||(this._relations=new c(this.transport))}get revisions(){return this._revisions||(this._revisions=new l(this.transport))}get roles(){return this._roles||(this._roles=new f(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get users(){return this._users||(this._users=new _(this.transport))}get server(){return this._server||(this._server=new p(this.transport))}get utils(){return this._utils||(this._utils=new w(this.transport))}get graphql(){return this._graphql||(this._graphql=new 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))}},t.FieldsHandler=o,t.FilesHandler=a,t.FoldersHandler=u,t.ItemsHandler=r,t.LocalStorage=E,t.MemoryStorage=R,t.PermissionsHandler=h,t.PresetsHandler=d,t.RelationsHandler=c,t.RevisionsHandler=l,t.RolesHandler=f,t.ServerHandler=p,t.SettingsHandler=v,t.TransportError=b,t.UsersHandler=_,t.UtilsHandler=w,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=sdk.umd.min.js.map |
{ | ||
"name": "@directus/sdk", | ||
"version": "9.0.0-rc.62", | ||
"version": "9.0.0-rc.63", | ||
"description": "The official Directus SDK for use in JavaScript!", | ||
@@ -63,3 +63,3 @@ "repository": { | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.40.0", | ||
"rollup": "^2.46.0", | ||
"rollup-plugin-copy": "^3.4.0", | ||
@@ -73,3 +73,3 @@ "rollup-plugin-sourcemaps": "^0.6.3", | ||
}, | ||
"gitHead": "c653b167298289ff3540ba66b7516350a96f7ac5" | ||
"gitHead": "5df6696bc029902b57eb5eb118c6fc39960937ef" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
11238
1271256