@directus/sdk
Advanced tools
Comparing version 9.14.2 to 10.0.0
@@ -267,3 +267,3 @@ import { AxiosRequestConfig } from 'axios'; | ||
mode: AuthMode; | ||
abstract readonly token: string | null; | ||
abstract readonly token: Promise<string | null>; | ||
abstract readonly password: PasswordsHandler; | ||
@@ -653,3 +653,3 @@ abstract login(credentials: AuthCredentials): Promise<AuthResult>; | ||
get transport(): ITransport; | ||
get token(): string | null; | ||
get token(): Promise<string | null>; | ||
get password(): PasswordsHandler; | ||
@@ -656,0 +656,0 @@ private resetStorage; |
@@ -764,3 +764,13 @@ import axios from 'axios'; | ||
get token() { | ||
return this._storage.auth_token; | ||
return (async () => { | ||
if (this._refreshPromise) { | ||
try { | ||
await this._refreshPromise; | ||
} | ||
finally { | ||
this._refreshPromise = undefined; | ||
} | ||
} | ||
return this._storage.auth_token; | ||
})(); | ||
} | ||
@@ -800,3 +810,3 @@ get password() { | ||
if (this._storage.auth_expires_at < new Date().getTime() + this.msRefreshBeforeExpires) { | ||
this._refreshPromise = this.refresh(); | ||
this.refresh(); | ||
} | ||
@@ -810,17 +820,18 @@ try { | ||
} | ||
async refresh() { | ||
var _a; | ||
const refresh_token = this._storage.auth_refresh_token; | ||
this.resetStorage(); | ||
const response = await this._transport.post('/auth/refresh', { | ||
refresh_token: this.mode === 'json' ? refresh_token : undefined, | ||
}); | ||
this.updateStorage(response.data); | ||
return { | ||
access_token: response.data.access_token, | ||
...(((_a = response.data) === null || _a === void 0 ? void 0 : _a.refresh_token) && { | ||
refresh_token: response.data.refresh_token, | ||
}), | ||
expires: response.data.expires, | ||
refresh() { | ||
const refreshPromise = async () => { | ||
var _a; | ||
const refresh_token = this._storage.auth_refresh_token; | ||
this.resetStorage(); | ||
const response = await this._transport.post('/auth/refresh', { | ||
refresh_token: this.mode === 'json' ? refresh_token : undefined, | ||
}); | ||
this.updateStorage(response.data); | ||
return { | ||
access_token: response.data.access_token, | ||
...(((_a = response.data) === null || _a === void 0 ? void 0 : _a.refresh_token) && { refresh_token: response.data.refresh_token }), | ||
expires: response.data.expires, | ||
}; | ||
}; | ||
return (this._refreshPromise = refreshPromise()); | ||
} | ||
@@ -827,0 +838,0 @@ async login(credentials) { |
@@ -772,3 +772,13 @@ 'use strict'; | ||
get token() { | ||
return this._storage.auth_token; | ||
return (async () => { | ||
if (this._refreshPromise) { | ||
try { | ||
await this._refreshPromise; | ||
} | ||
finally { | ||
this._refreshPromise = undefined; | ||
} | ||
} | ||
return this._storage.auth_token; | ||
})(); | ||
} | ||
@@ -808,3 +818,3 @@ get password() { | ||
if (this._storage.auth_expires_at < new Date().getTime() + this.msRefreshBeforeExpires) { | ||
this._refreshPromise = this.refresh(); | ||
this.refresh(); | ||
} | ||
@@ -818,17 +828,18 @@ try { | ||
} | ||
async refresh() { | ||
var _a; | ||
const refresh_token = this._storage.auth_refresh_token; | ||
this.resetStorage(); | ||
const response = await this._transport.post('/auth/refresh', { | ||
refresh_token: this.mode === 'json' ? refresh_token : undefined, | ||
}); | ||
this.updateStorage(response.data); | ||
return { | ||
access_token: response.data.access_token, | ||
...(((_a = response.data) === null || _a === void 0 ? void 0 : _a.refresh_token) && { | ||
refresh_token: response.data.refresh_token, | ||
}), | ||
expires: response.data.expires, | ||
refresh() { | ||
const refreshPromise = async () => { | ||
var _a; | ||
const refresh_token = this._storage.auth_refresh_token; | ||
this.resetStorage(); | ||
const response = await this._transport.post('/auth/refresh', { | ||
refresh_token: this.mode === 'json' ? refresh_token : undefined, | ||
}); | ||
this.updateStorage(response.data); | ||
return { | ||
access_token: response.data.access_token, | ||
...(((_a = response.data) === null || _a === void 0 ? void 0 : _a.refresh_token) && { refresh_token: response.data.refresh_token }), | ||
expires: response.data.expires, | ||
}; | ||
}; | ||
return (this._refreshPromise = refreshPromise()); | ||
} | ||
@@ -835,0 +846,0 @@ async login(credentials) { |
@@ -1,2 +0,2 @@ | ||
class t{constructor(){this.mode="undefined"==typeof window?"json":"cookie"}}var e,r;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(e||(e={}));class s extends Error{constructor(t){super(`${null!=t?t:"ID"} cannot be an empty string`)}}class n{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async readOne(t,e,r){if(""==`${t}`)throw new s("id");return(await this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e,...null==r?void 0:r.requestOptions})).data}async readMany(t,e,r){var s;const n=null===(s=(await this.transport.get(`/fields/${this.collection}`)).data)||void 0===s?void 0:s.find((t=>!0===t.schema.is_primary_key)),{data:o,meta:i}=await this.transport.get(`${this.endpoint}`,{params:{filter:{[n.field]:{_in:t},...null==e?void 0:e.filter},sort:(null==e?void 0:e.sort)||n.field,...e},...null==r?void 0:r.requestOptions});return{data:o,...i&&{meta:i}}}async readByQuery(t,e){const{data:r,meta:s}=await this.transport.get(`${this.endpoint}`,{params:t,...null==e?void 0:e.requestOptions});return{data:r,...s&&{meta:s}}}async createOne(t,e,r){return(await this.transport.post(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.requestOptions})).data}async createMany(t,e,r){return await this.transport.post(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.requestOptions})}async updateOne(t,e,r,n){if(""==`${t}`)throw new s("id");return(await this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:r,...null==n?void 0:n.requestOptions})).data}async updateMany(t,e,r,s){return await this.transport.patch(`${this.endpoint}`,{keys:t,data:e},{params:r,...null==s?void 0:s.requestOptions})}async updateByQuery(t,e,r,s){return await this.transport.patch(`${this.endpoint}`,{query:t,data:e},{params:r,...null==s?void 0:s.requestOptions})}async deleteOne(t,e){if(""==`${t}`)throw new s("id");await this.transport.delete(`${this.endpoint}/${encodeURI(t)}`,void 0,null==e?void 0:e.requestOptions)}async deleteMany(t,e){await this.transport.delete(`${this.endpoint}`,t,null==e?void 0:e.requestOptions)}}class o{constructor(t){this.transport=t}async create(t){return(await this.transport.post("/activity/comment",t)).data}async update(t,e){if(""==`${t}`)throw new s("comment_activity_id");return(await this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}async delete(t){if(""==`${t}`)throw new s("comment_activity_id");await this.transport.delete(`/activity/comment/${encodeURI(t)}`)}}class i extends n{constructor(t){super("directus_activity",t),this._comments=new o(this.transport)}get comments(){return this._comments}}class a{constructor(t){this.transport=t}async readOne(t){if(""==`${t}`)throw new s("collection");return(await this.transport.get(`/collections/${t}`)).data}async readAll(){const{data:t,meta:e}=await this.transport.get("/collections");return{data:t,meta:e}}async createOne(t){return(await this.transport.post("/collections",t)).data}async createMany(t){const{data:e,meta:r}=await this.transport.post("/collections",t);return{data:e,meta:r}}async updateOne(t,e,r){if(""==`${t}`)throw new s("collection");return(await this.transport.patch(`/collections/${t}`,e,{params:r})).data}async deleteOne(t){if(""==`${t}`)throw new s("collection");await this.transport.delete(`/collections/${t}`)}}class u{constructor(t){this.transport=t}async readOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("id");return(await this.transport.get(`/fields/${t}/${e}`)).data}async readMany(t){if(""==`${t}`)throw new s("collection");return(await this.transport.get(`/fields/${t}`)).data}async readAll(){return(await this.transport.get("/fields")).data}async createOne(t,e){if(""==`${t}`)throw new s("collection");return(await this.transport.post(`/fields/${t}`,e)).data}async updateOne(t,e,r){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");return(await this.transport.patch(`/fields/${t}/${e}`,r)).data}async deleteOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");await this.transport.delete(`/fields/${t}/${e}`)}}class c extends n{constructor(t){super("directus_files",t)}async import(t){return(await this.transport.post("/files/import",t)).data}}class h extends n{constructor(t){super("directus_folders",t)}}class l extends n{constructor(t){super("directus_permissions",t)}}class p extends n{constructor(t){super("directus_presets",t)}}class d{constructor(t){this.transport=t}async readOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("id");return(await this.transport.get(`/relations/${t}/${e}`)).data}async readMany(t){if(""==`${t}`)throw new s("collection");return(await this.transport.get(`/relations/${t}`)).data}async readAll(){return(await this.transport.get("/relations")).data}async createOne(t){return(await this.transport.post("/relations",t)).data}async updateOne(t,e,r){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");return(await this.transport.patch(`/relations/${t}/${e}`,{params:r})).data}async deleteOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");await this.transport.delete(`/relations/${t}/${e}`)}}class f extends n{constructor(t){super("directus_revisions",t)}}class m extends n{constructor(t){super("directus_roles",t)}}class g{constructor(t){this.transport=t}async ping(){return(await this.transport.get("/server/ping")).raw}async info(){return(await this.transport.get("/server/info")).data}}class w{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async read(t){return(await this.transport.get(`${this.endpoint}`,{params:t})).data}async update(t,e){return(await this.transport.patch(`${this.endpoint}`,t,{params:e})).data}}class v extends w{constructor(t){super("directus_settings",t)}}class y{constructor(t){this.transport=t}async send(t,e,r){await this.transport.post("/users/invite",{email:t,role:e,invite_url:r})}async accept(t,e){await this.transport.post("/users/invite/accept",{token:t,password:e})}}class _{constructor(t){this.transport=t}async generate(t){return(await this.transport.post("/users/me/tfa/generate",{password:t})).data}async enable(t,e){await this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})}async disable(t){await this.transport.post("/users/me/tfa/disable",{otp:t})}}class x{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new _(this._transport))}async read(t){return(await this._transport.get("/users/me",{params:t})).data}async update(t,e){return(await this._transport.patch("/users/me",t,{params:e})).data}}class b extends n{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new y(this.transport))}get me(){return this._me||(this._me=new x(this.transport))}}class k{constructor(t){this.random={string:async(t=32)=>(await this.transport.get("/utils/random/string",{params:{length:t}})).data},this.hash={generate:async t=>(await this.transport.post("/utils/hash/generate",{string:t})).data,verify:async(t,e)=>(await this.transport.post("/utils/hash/verify",{string:t,hash:e})).data},this.transport=t}async sort(t,e,r){await this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:r})}async revert(t){await this.transport.post(`/utils/revert/${encodeURI(t)}`)}}class O{}class E{}class $ 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,$.prototype)}}!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(r||(r={}));class S extends O{constructor(t){var e;super(),this.prefix=null!==(e=null==t?void 0:t.prefix)&&void 0!==e?e:""}get auth_token(){return this.get(r.AuthToken)}set auth_token(t){null===t?this.delete(r.AuthToken):this.set(r.AuthToken,t)}get auth_expires(){const t=this.get(r.Expires);return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete(r.Expires):this.set(r.Expires,t.toString())}get auth_expires_at(){const t=this.get(r.ExpiresAt);return null===t?null:parseInt(t)}set auth_expires_at(t){null===t?this.delete(r.ExpiresAt):this.set(r.ExpiresAt,t.toString())}get auth_refresh_token(){return this.get(r.RefreshToken)}set auth_refresh_token(t){null===t?this.delete(r.RefreshToken):this.set(r.RefreshToken,t)}}class R extends S{constructor(){super(...arguments),this.values={}}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class T extends S{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 q={exports:{}},A=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=A,U=Object.prototype.toString;function C(t){return"[object Array]"===U.call(t)}function N(t){return void 0===t}function P(t){return null!==t&&"object"==typeof t}function B(t){if("[object Object]"!==U.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function L(t){return"[object Function]"===U.call(t)}function I(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),C(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 D={isArray:C,isArrayBuffer:function(t){return"[object ArrayBuffer]"===U.call(t)},isBuffer:function(t){return null!==t&&!N(t)&&null!==t.constructor&&!N(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:P,isPlainObject:B,isUndefined:N,isDate:function(t){return"[object Date]"===U.call(t)},isFile:function(t){return"[object File]"===U.call(t)},isBlob:function(t){return"[object Blob]"===U.call(t)},isFunction:L,isStream:function(t){return P(t)&&L(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:I,merge:function t(){var e={};function r(r,s){B(e[s])&&B(r)?e[s]=t(e[s],r):B(r)?e[s]=t({},r):C(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)I(arguments[s],r);return e},extend:function(t,e,r){return I(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},M=D;function F(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var J=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(M.isURLSearchParams(e))s=e.toString();else{var n=[];M.forEach(e,(function(t,e){null!=t&&(M.isArray(t)?e+="[]":t=[t],M.forEach(t,(function(t){M.isDate(t)?t=t.toISOString():M.isObject(t)&&(t=JSON.stringify(t)),n.push(F(e)+"="+F(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},z=D;function H(){this.handlers=[]}H.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){z.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var W=H,V=D,X=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t},K=X,Q=function(t,e,r,s,n){var o=new Error(t);return K(o,e,r,s,n)},G=Q,Y=D,Z=Y.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),Y.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),Y.isString(s)&&i.push("path="+s),Y.isString(n)&&i.push("domain="+n),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},tt=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},et=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},rt=D,st=["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"],nt=D,ot=nt.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=nt.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0};function it(t){this.message=t}it.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},it.prototype.__CANCEL__=!0;var at=it,ut=D,ct=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(G("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ht=Z,lt=J,pt=function(t,e){return t&&!tt(e)?et(t,e):e},dt=function(t){var e,r,s,n={};return t?(rt.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=rt.trim(t.substr(0,s)).toLowerCase(),r=rt.trim(t.substr(s+1)),e){if(n[e]&&st.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ft=ot,mt=Q,gt=$t,wt=at,vt=function(t){return new Promise((function(e,r){var s,n=t.data,o=t.headers,i=t.responseType;function a(){t.cancelToken&&t.cancelToken.unsubscribe(s),t.signal&&t.signal.removeEventListener("abort",s)}ut.isFormData(n)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(t.auth){var c=t.auth.username||"",h=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";o.Authorization="Basic "+btoa(c+":"+h)}var l=pt(t.baseURL,t.url);function p(){if(u){var s="getAllResponseHeaders"in u?dt(u.getAllResponseHeaders()):null,n={data:i&&"text"!==i&&"json"!==i?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:s,config:t,request:u};ct((function(t){e(t),a()}),(function(t){r(t),a()}),n),u=null}}if(u.open(t.method.toUpperCase(),lt(l,t.params,t.paramsSerializer),!0),u.timeout=t.timeout,"onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(p)},u.onabort=function(){u&&(r(mt("Request aborted",t,"ECONNABORTED",u)),u=null)},u.onerror=function(){r(mt("Network Error",t,null,u)),u=null},u.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",s=t.transitional||gt.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(mt(e,t,s.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},ut.isStandardBrowserEnv()){var d=(t.withCredentials||ft(l))&&t.xsrfCookieName?ht.read(t.xsrfCookieName):void 0;d&&(o[t.xsrfHeaderName]=d)}"setRequestHeader"in u&&ut.forEach(o,(function(t,e){void 0===n&&"content-type"===e.toLowerCase()?delete o[e]:u.setRequestHeader(e,t)})),ut.isUndefined(t.withCredentials)||(u.withCredentials=!!t.withCredentials),i&&"json"!==i&&(u.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&u.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(s=function(t){u&&(r(!t||t&&t.type?new wt("canceled"):t),u.abort(),u=null)},t.cancelToken&&t.cancelToken.subscribe(s),t.signal&&(t.signal.aborted?s():t.signal.addEventListener("abort",s))),n||(n=null),u.send(n)}))},yt=D,_t=function(t,e){V.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},xt=X,bt={"Content-Type":"application/x-www-form-urlencoded"};function kt(t,e){!yt.isUndefined(t)&&yt.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var Ot,Et={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Ot=vt),Ot),transformRequest:[function(t,e){return _t(e,"Accept"),_t(e,"Content-Type"),yt.isFormData(t)||yt.isArrayBuffer(t)||yt.isBuffer(t)||yt.isStream(t)||yt.isFile(t)||yt.isBlob(t)?t:yt.isArrayBufferView(t)?t.buffer:yt.isURLSearchParams(t)?(kt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):yt.isObject(t)||e&&"application/json"===e["Content-Type"]?(kt(e,"application/json"),function(t,e,r){if(yt.isString(t))try{return(e||JSON.parse)(t),yt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||Et.transitional,r=e&&e.silentJSONParsing,s=e&&e.forcedJSONParsing,n=!r&&"json"===this.responseType;if(n||s&&yt.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(n){if("SyntaxError"===t.name)throw xt(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};yt.forEach(["delete","get","head"],(function(t){Et.headers[t]={}})),yt.forEach(["post","put","patch"],(function(t){Et.headers[t]=yt.merge(bt)}));var $t=Et,St=D,Rt=$t,Tt=function(t){return!(!t||!t.__CANCEL__)},qt=D,At=function(t,e,r){var s=this||Rt;return St.forEach(r,(function(r){t=r.call(s,t,e)})),t},jt=Tt,Ut=$t,Ct=at;function Nt(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ct("canceled")}var Pt=D,Bt=function(t,e){e=e||{};var r={};function s(t,e){return Pt.isPlainObject(t)&&Pt.isPlainObject(e)?Pt.merge(t,e):Pt.isPlainObject(e)?Pt.merge({},e):Pt.isArray(e)?e.slice():e}function n(r){return Pt.isUndefined(e[r])?Pt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(t[r],e[r])}function o(t){if(!Pt.isUndefined(e[t]))return s(void 0,e[t])}function i(r){return Pt.isUndefined(e[r])?Pt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(void 0,e[r])}function a(r){return r in e?s(t[r],e[r]):r in t?s(void 0,t[r]):void 0}var u={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a};return Pt.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||n,s=e(t);Pt.isUndefined(s)&&e!==a||(r[t]=s)})),r},Lt="0.24.0",It=Lt,Dt={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){Dt[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var Mt={};Dt.transitional=function(t,e,r){function s(t,e){return"[Axios v"+It+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,o){if(!1===t)throw new Error(s(n," has been removed"+(e?" in "+e:"")));return e&&!Mt[n]&&(Mt[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,o)}};var Ft={assertOptions:function(t,e,r){if("object"!=typeof t)throw new TypeError("options must be an object");for(var s=Object.keys(t),n=s.length;n-- >0;){var o=s[n],i=e[o];if(i){var a=t[o],u=void 0===a||i(a,o,t);if(!0!==u)throw new TypeError("option "+o+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+o)}},validators:Dt},Jt=D,zt=J,Ht=W,Wt=function(t){return Nt(t),t.headers=t.headers||{},t.data=At.call(t,t.data,t.headers,t.transformRequest),t.headers=qt.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),qt.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Ut.adapter)(t).then((function(e){return Nt(t),e.data=At.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return jt(e)||(Nt(t),e&&e.response&&(e.response.data=At.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Vt=Bt,Xt=Ft,Kt=Xt.validators;function Qt(t){this.defaults=t,this.interceptors={request:new Ht,response:new Ht}}Qt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Vt(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&Xt.assertOptions(e,{silentJSONParsing:Kt.transitional(Kt.boolean),forcedJSONParsing:Kt.transitional(Kt.boolean),clarifyTimeoutError:Kt.transitional(Kt.boolean)},!1);var r=[],s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var n,o=[];if(this.interceptors.response.forEach((function(t){o.push(t.fulfilled,t.rejected)})),!s){var i=[Wt,void 0];for(Array.prototype.unshift.apply(i,r),i=i.concat(o),n=Promise.resolve(t);i.length;)n=n.then(i.shift(),i.shift());return n}for(var a=t;r.length;){var u=r.shift(),c=r.shift();try{a=u(a)}catch(t){c(t);break}}try{n=Wt(a)}catch(t){return Promise.reject(t)}for(;o.length;)n=n.then(o.shift(),o.shift());return n},Qt.prototype.getUri=function(t){return t=Vt(this.defaults,t),zt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Jt.forEach(["delete","get","head","options"],(function(t){Qt.prototype[t]=function(e,r){return this.request(Vt(r||{},{method:t,url:e,data:(r||{}).data}))}})),Jt.forEach(["post","put","patch"],(function(t){Qt.prototype[t]=function(e,r,s){return this.request(Vt(s||{},{method:t,url:e,data:r}))}}));var Gt=Qt,Yt=at;function Zt(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;this.promise.then((function(t){if(r._listeners){var e,s=r._listeners.length;for(e=0;e<s;e++)r._listeners[e](t);r._listeners=null}})),this.promise.then=function(t){var e,s=new Promise((function(t){r.subscribe(t),e=t})).then(t);return s.cancel=function(){r.unsubscribe(e)},s},t((function(t){r.reason||(r.reason=new Yt(t),e(r.reason))}))}Zt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Zt.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},Zt.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},Zt.source=function(){var t;return{token:new Zt((function(e){t=e})),cancel:t}};var te=Zt,ee=D,re=A,se=Gt,ne=Bt;var oe=function t(e){var r=new se(e),s=re(se.prototype.request,r);return ee.extend(s,se.prototype,r),ee.extend(s,r),s.create=function(r){return t(ne(e,r))},s}($t);oe.Axios=se,oe.Cancel=at,oe.CancelToken=te,oe.isCancel=Tt,oe.VERSION=Lt,oe.all=function(t){return Promise.all(t)},oe.spread=function(t){return function(e){return t.apply(null,e)}},oe.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},q.exports=oe,q.exports.default=oe;var ie=q.exports;class ae extends E{constructor(t){var e;super(),this.config=t,this.axios=ie.create({baseURL:this.config.url,params:this.config.params,headers:this.config.headers,onUploadProgress:this.config.onUploadProgress,withCredentials:!0}),(null===(e=this.config)||void 0===e?void 0:e.beforeRequest)&&(this.beforeRequest=this.config.beforeRequest)}async beforeRequest(t){return t}get url(){return this.config.url}async request(t,e,r,s){var n,o,i,a,u;try{let n={method:t,url:e,data:r,params:null==s?void 0:s.params,headers:null==s?void 0:s.headers,onUploadProgress:null==s?void 0:s.onUploadProgress};n=await this.beforeRequest(n);const o=await this.axios.request(n),i={raw:o.data,status:o.status,statusText:o.statusText,headers:o.headers,data:o.data.data,meta:o.data.meta,errors:o.data.errors};if(o.data.errors)throw new $(null,i);return i}catch(t){if(!t||t instanceof Error==!1)throw t;if(ie.isAxiosError(t)){const e=null===(n=t.response)||void 0===n?void 0:n.data;throw new $(t,{raw:null===(o=t.response)||void 0===o?void 0:o.data,status:null===(i=t.response)||void 0===i?void 0:i.status,statusText:null===(a=t.response)||void 0===a?void 0:a.statusText,headers:null===(u=t.response)||void 0===u?void 0:u.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new $(t)}}async get(t,e){return await this.request("get",t,void 0,e)}async head(t,e){return await this.request("head",t,void 0,e)}async options(t,e){return await this.request("options",t,void 0,e)}async delete(t,e,r){return await this.request("delete",t,e,r)}async put(t,e,r){return await this.request("put",t,e,r)}async post(t,e,r){return await this.request("post",t,e,r)}async patch(t,e,r){return await this.request("patch",t,e,r)}}class ue{constructor(t){this.transport=t}async request(t,e){await this.transport.post("/auth/password/request",{email:t,reset_url:e})}async reset(t,e){await this.transport.post("/auth/password/reset",{token:t,password:e})}}class ce extends t{constructor(t){var e,r,s;super(),this.autoRefresh=!0,this.msRefreshBeforeExpires=3e4,this.staticToken="",this._transport=t.transport,this._storage=t.storage,this.autoRefresh=null!==(e=null==t?void 0:t.autoRefresh)&&void 0!==e?e:this.autoRefresh,this.mode=null!==(r=null==t?void 0:t.mode)&&void 0!==r?r:this.mode,this.msRefreshBeforeExpires=null!==(s=null==t?void 0:t.msRefreshBeforeExpires)&&void 0!==s?s:this.msRefreshBeforeExpires,(null==t?void 0:t.staticToken)&&(this.staticToken=null==t?void 0:t.staticToken,this.updateStorage({access_token:this.staticToken,expires:null,refresh_token:null}))}get storage(){return this._storage}get transport(){return this._transport}get token(){return this._storage.auth_token}get password(){return this.passwords=this.passwords||new ue(this._transport)}resetStorage(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null,this._storage.auth_expires_at=null}updateStorage(t){var e,r;const s=null!==(e=t.expires)&&void 0!==e?e:null;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(r=t.refresh_token)&&void 0!==r?r:null,this._storage.auth_expires=s,this._storage.auth_expires_at=(new Date).getTime()+(null!=s?s:0)}async refreshIfExpired(){if(!this.staticToken&&this.autoRefresh)if(this._storage.auth_expires_at){this._storage.auth_expires_at<(new Date).getTime()+this.msRefreshBeforeExpires&&(this._refreshPromise=this.refresh());try{await this._refreshPromise}finally{this._refreshPromise=void 0}}else try{await this._refreshPromise}finally{this._refreshPromise=void 0}}async refresh(){var t;const e=this._storage.auth_refresh_token;this.resetStorage();const r=await this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?e:void 0});return this.updateStorage(r.data),{access_token:r.data.access_token,...(null===(t=r.data)||void 0===t?void 0:t.refresh_token)&&{refresh_token:r.data.refresh_token},expires:r.data.expires}}async login(t){var e;this.resetStorage();const r=await this._transport.post("/auth/login",{mode:this.mode,...t},{headers:{Authorization:null}});return this.updateStorage(r.data),{access_token:r.data.access_token,...(null===(e=r.data)||void 0===e?void 0:e.refresh_token)&&{refresh_token:r.data.refresh_token},expires:r.data.expires}}async static(t){return this.staticToken||(this.staticToken=t),await this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}}),this.updateStorage({access_token:t,expires:null,refresh_token:null}),!0}async logout(){let t;"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),await this._transport.post("/auth/logout",{refresh_token:t}),this.updateStorage({access_token:null,expires:null,refresh_token:null})}}class he{constructor(t){this.transport=t}async request(t,e,r){return await this.transport.post(t,{query:e,variables:void 0===r?{}:r})}async items(t,e){return await this.request("/graphql",t,e)}async system(t,e){return await this.request("/graphql/system",t,e)}}class le{constructor(e,r){var s,n,o,i,a,u,c,h,l;if(this._url=e,this._options=r,this._items={},this._singletons={},(null===(s=this._options)||void 0===s?void 0:s.storage)&&(null===(n=this._options)||void 0===n?void 0:n.storage)instanceof O)this._storage=this._options.storage;else{const t=null===(o=this._options)||void 0===o?void 0:o.storage,{mode:e,...r}=null!=t?t:{};"MemoryStorage"===e||"undefined"==typeof window?this._storage=new R(r):this._storage=new T(r)}(null===(i=this._options)||void 0===i?void 0:i.transport)&&(null===(a=this._options)||void 0===a?void 0:a.transport)instanceof E?this._transport=this._options.transport:this._transport=new ae({url:this.url,beforeRequest:async t=>{await this._auth.refreshIfExpired();const e=this.storage.auth_token,r=e?e.startsWith("Bearer ")?String(this.storage.auth_token):`Bearer ${this.storage.auth_token}`:"";return{...t,headers:{Authorization:r,...t.headers}}},...null===(u=this._options)||void 0===u?void 0:u.transport}),(null===(c=this._options)||void 0===c?void 0:c.auth)&&(null===(h=this._options)||void 0===h?void 0:h.auth)instanceof t?this._auth=this._options.auth:this._auth=new ce({transport:this._transport,storage:this._storage,...null===(l=this._options)||void 0===l?void 0:l.auth})}get url(){return this._url}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new i(this.transport))}get collections(){return this._collections||(this._collections=new a(this.transport))}get fields(){return this._fields||(this._fields=new u(this.transport))}get files(){return this._files||(this._files=new c(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new l(this.transport))}get presets(){return this._presets||(this._presets=new p(this.transport))}get relations(){return this._relations||(this._relations=new d(this.transport))}get revisions(){return this._revisions||(this._revisions=new f(this.transport))}get roles(){return this._roles||(this._roles=new m(this.transport))}get users(){return this._users||(this._users=new b(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get server(){return this._server||(this._server=new g(this.transport))}get utils(){return this._utils||(this._utils=new k(this.transport))}get graphql(){return this._graphql||(this._graphql=new he(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new w(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new n(t,this.transport))}}export{i as ActivityHandler,ce as Auth,S as BaseStorage,a as CollectionsHandler,o as CommentsHandler,le as Directus,s as EmptyParamError,u as FieldsHandler,c as FilesHandler,h as FoldersHandler,t as IAuth,O as IStorage,E as ITransport,n as ItemsHandler,T as LocalStorage,R as MemoryStorage,e as Meta,l as PermissionsHandler,p as PresetsHandler,d as RelationsHandler,f as RevisionsHandler,m as RolesHandler,g as ServerHandler,v as SettingsHandler,ae as Transport,$ as TransportError,b as UsersHandler,k as UtilsHandler}; | ||
class t{constructor(){this.mode="undefined"==typeof window?"json":"cookie"}}var e,r;!function(t){t.TOTAL_COUNT="total_count",t.FILTER_COUNT="filter_count"}(e||(e={}));class s extends Error{constructor(t){super(`${null!=t?t:"ID"} cannot be an empty string`)}}class n{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async readOne(t,e,r){if(""==`${t}`)throw new s("id");return(await this.transport.get(`${this.endpoint}/${encodeURI(t)}`,{params:e,...null==r?void 0:r.requestOptions})).data}async readMany(t,e,r){var s;const n=null===(s=(await this.transport.get(`/fields/${this.collection}`)).data)||void 0===s?void 0:s.find((t=>!0===t.schema.is_primary_key)),{data:o,meta:i}=await this.transport.get(`${this.endpoint}`,{params:{filter:{[n.field]:{_in:t},...null==e?void 0:e.filter},sort:(null==e?void 0:e.sort)||n.field,...e},...null==r?void 0:r.requestOptions});return{data:o,...i&&{meta:i}}}async readByQuery(t,e){const{data:r,meta:s}=await this.transport.get(`${this.endpoint}`,{params:t,...null==e?void 0:e.requestOptions});return{data:r,...s&&{meta:s}}}async createOne(t,e,r){return(await this.transport.post(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.requestOptions})).data}async createMany(t,e,r){return await this.transport.post(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.requestOptions})}async updateOne(t,e,r,n){if(""==`${t}`)throw new s("id");return(await this.transport.patch(`${this.endpoint}/${encodeURI(t)}`,e,{params:r,...null==n?void 0:n.requestOptions})).data}async updateMany(t,e,r,s){return await this.transport.patch(`${this.endpoint}`,{keys:t,data:e},{params:r,...null==s?void 0:s.requestOptions})}async updateByQuery(t,e,r,s){return await this.transport.patch(`${this.endpoint}`,{query:t,data:e},{params:r,...null==s?void 0:s.requestOptions})}async deleteOne(t,e){if(""==`${t}`)throw new s("id");await this.transport.delete(`${this.endpoint}/${encodeURI(t)}`,void 0,null==e?void 0:e.requestOptions)}async deleteMany(t,e){await this.transport.delete(`${this.endpoint}`,t,null==e?void 0:e.requestOptions)}}class o{constructor(t){this.transport=t}async create(t){return(await this.transport.post("/activity/comment",t)).data}async update(t,e){if(""==`${t}`)throw new s("comment_activity_id");return(await this.transport.patch(`/activity/comment/${encodeURI(t)}`,{comment:e})).data}async delete(t){if(""==`${t}`)throw new s("comment_activity_id");await this.transport.delete(`/activity/comment/${encodeURI(t)}`)}}class i extends n{constructor(t){super("directus_activity",t),this._comments=new o(this.transport)}get comments(){return this._comments}}class a{constructor(t){this.transport=t}async readOne(t){if(""==`${t}`)throw new s("collection");return(await this.transport.get(`/collections/${t}`)).data}async readAll(){const{data:t,meta:e}=await this.transport.get("/collections");return{data:t,meta:e}}async createOne(t){return(await this.transport.post("/collections",t)).data}async createMany(t){const{data:e,meta:r}=await this.transport.post("/collections",t);return{data:e,meta:r}}async updateOne(t,e,r){if(""==`${t}`)throw new s("collection");return(await this.transport.patch(`/collections/${t}`,e,{params:r})).data}async deleteOne(t){if(""==`${t}`)throw new s("collection");await this.transport.delete(`/collections/${t}`)}}class u{constructor(t){this.transport=t}async readOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("id");return(await this.transport.get(`/fields/${t}/${e}`)).data}async readMany(t){if(""==`${t}`)throw new s("collection");return(await this.transport.get(`/fields/${t}`)).data}async readAll(){return(await this.transport.get("/fields")).data}async createOne(t,e){if(""==`${t}`)throw new s("collection");return(await this.transport.post(`/fields/${t}`,e)).data}async updateOne(t,e,r){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");return(await this.transport.patch(`/fields/${t}/${e}`,r)).data}async deleteOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");await this.transport.delete(`/fields/${t}/${e}`)}}class c extends n{constructor(t){super("directus_files",t)}async import(t){return(await this.transport.post("/files/import",t)).data}}class h extends n{constructor(t){super("directus_folders",t)}}class l extends n{constructor(t){super("directus_permissions",t)}}class p extends n{constructor(t){super("directus_presets",t)}}class d{constructor(t){this.transport=t}async readOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("id");return(await this.transport.get(`/relations/${t}/${e}`)).data}async readMany(t){if(""==`${t}`)throw new s("collection");return(await this.transport.get(`/relations/${t}`)).data}async readAll(){return(await this.transport.get("/relations")).data}async createOne(t){return(await this.transport.post("/relations",t)).data}async updateOne(t,e,r){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");return(await this.transport.patch(`/relations/${t}/${e}`,{params:r})).data}async deleteOne(t,e){if(""==`${t}`)throw new s("collection");if(""==`${e}`)throw new s("field");await this.transport.delete(`/relations/${t}/${e}`)}}class f extends n{constructor(t){super("directus_revisions",t)}}class m extends n{constructor(t){super("directus_roles",t)}}class g{constructor(t){this.transport=t}async ping(){return(await this.transport.get("/server/ping")).raw}async info(){return(await this.transport.get("/server/info")).data}}class w{constructor(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?`/${t.substring(9)}`:`/items/${t}`}async read(t){return(await this.transport.get(`${this.endpoint}`,{params:t})).data}async update(t,e){return(await this.transport.patch(`${this.endpoint}`,t,{params:e})).data}}class v extends w{constructor(t){super("directus_settings",t)}}class y{constructor(t){this.transport=t}async send(t,e,r){await this.transport.post("/users/invite",{email:t,role:e,invite_url:r})}async accept(t,e){await this.transport.post("/users/invite/accept",{token:t,password:e})}}class _{constructor(t){this.transport=t}async generate(t){return(await this.transport.post("/users/me/tfa/generate",{password:t})).data}async enable(t,e){await this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})}async disable(t){await this.transport.post("/users/me/tfa/disable",{otp:t})}}class x{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new _(this._transport))}async read(t){return(await this._transport.get("/users/me",{params:t})).data}async update(t,e){return(await this._transport.patch("/users/me",t,{params:e})).data}}class b extends n{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new y(this.transport))}get me(){return this._me||(this._me=new x(this.transport))}}class k{constructor(t){this.random={string:async(t=32)=>(await this.transport.get("/utils/random/string",{params:{length:t}})).data},this.hash={generate:async t=>(await this.transport.post("/utils/hash/generate",{string:t})).data,verify:async(t,e)=>(await this.transport.post("/utils/hash/verify",{string:t,hash:e})).data},this.transport=t}async sort(t,e,r){await this.transport.post(`/utils/sort/${encodeURI(t)}`,{item:e,to:r})}async revert(t){await this.transport.post(`/utils/revert/${encodeURI(t)}`)}}class O{}class E{}class $ 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,$.prototype)}}!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(r||(r={}));class S extends O{constructor(t){var e;super(),this.prefix=null!==(e=null==t?void 0:t.prefix)&&void 0!==e?e:""}get auth_token(){return this.get(r.AuthToken)}set auth_token(t){null===t?this.delete(r.AuthToken):this.set(r.AuthToken,t)}get auth_expires(){const t=this.get(r.Expires);return null===t?null:parseInt(t)}set auth_expires(t){null===t?this.delete(r.Expires):this.set(r.Expires,t.toString())}get auth_expires_at(){const t=this.get(r.ExpiresAt);return null===t?null:parseInt(t)}set auth_expires_at(t){null===t?this.delete(r.ExpiresAt):this.set(r.ExpiresAt,t.toString())}get auth_refresh_token(){return this.get(r.RefreshToken)}set auth_refresh_token(t){null===t?this.delete(r.RefreshToken):this.set(r.RefreshToken,t)}}class R extends S{constructor(){super(...arguments),this.values={}}get(t){const e=this.key(t);return e in this.values?this.values[e]:null}set(t,e){return this.values[this.key(t)]=e,e}delete(t){const e=this.key(t),r=this.get(t);return e in this.values&&delete this.values[e],r}key(t){return`${this.prefix}${t}`}}class T extends S{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 q={exports:{}},A=function(t,e){return function(){for(var r=new Array(arguments.length),s=0;s<r.length;s++)r[s]=arguments[s];return t.apply(e,r)}},j=A,U=Object.prototype.toString;function P(t){return"[object Array]"===U.call(t)}function C(t){return void 0===t}function N(t){return null!==t&&"object"==typeof t}function B(t){if("[object Object]"!==U.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function L(t){return"[object Function]"===U.call(t)}function I(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),P(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 D={isArray:P,isArrayBuffer:function(t){return"[object ArrayBuffer]"===U.call(t)},isBuffer:function(t){return null!==t&&!C(t)&&null!==t.constructor&&!C(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:N,isPlainObject:B,isUndefined:C,isDate:function(t){return"[object Date]"===U.call(t)},isFile:function(t){return"[object File]"===U.call(t)},isBlob:function(t){return"[object Blob]"===U.call(t)},isFunction:L,isStream:function(t){return N(t)&&L(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:I,merge:function t(){var e={};function r(r,s){B(e[s])&&B(r)?e[s]=t(e[s],r):B(r)?e[s]=t({},r):P(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)I(arguments[s],r);return e},extend:function(t,e,r){return I(e,(function(e,s){t[s]=r&&"function"==typeof e?j(e,r):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}},M=D;function F(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var J=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(M.isURLSearchParams(e))s=e.toString();else{var n=[];M.forEach(e,(function(t,e){null!=t&&(M.isArray(t)?e+="[]":t=[t],M.forEach(t,(function(t){M.isDate(t)?t=t.toISOString():M.isObject(t)&&(t=JSON.stringify(t)),n.push(F(e)+"="+F(t))})))})),s=n.join("&")}if(s){var o=t.indexOf("#");-1!==o&&(t=t.slice(0,o)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},z=D;function H(){this.handlers=[]}H.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},H.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},H.prototype.forEach=function(t){z.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var W=H,V=D,X=function(t,e,r,s,n){return t.config=e,r&&(t.code=r),t.request=s,t.response=n,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t},K=X,Q=function(t,e,r,s,n){var o=new Error(t);return K(o,e,r,s,n)},G=Q,Y=D,Z=Y.isStandardBrowserEnv()?{write:function(t,e,r,s,n,o){var i=[];i.push(t+"="+encodeURIComponent(e)),Y.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),Y.isString(s)&&i.push("path="+s),Y.isString(n)&&i.push("domain="+n),!0===o&&i.push("secure"),document.cookie=i.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},tt=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)},et=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},rt=D,st=["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"],nt=D,ot=nt.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=nt.isString(e)?s(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0};function it(t){this.message=t}it.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},it.prototype.__CANCEL__=!0;var at=it,ut=D,ct=function(t,e,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?e(G("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)},ht=Z,lt=J,pt=function(t,e){return t&&!tt(e)?et(t,e):e},dt=function(t){var e,r,s,n={};return t?(rt.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=rt.trim(t.substr(0,s)).toLowerCase(),r=rt.trim(t.substr(s+1)),e){if(n[e]&&st.indexOf(e)>=0)return;n[e]="set-cookie"===e?(n[e]?n[e]:[]).concat([r]):n[e]?n[e]+", "+r:r}})),n):n},ft=ot,mt=Q,gt=$t,wt=at,vt=function(t){return new Promise((function(e,r){var s,n=t.data,o=t.headers,i=t.responseType;function a(){t.cancelToken&&t.cancelToken.unsubscribe(s),t.signal&&t.signal.removeEventListener("abort",s)}ut.isFormData(n)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(t.auth){var c=t.auth.username||"",h=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";o.Authorization="Basic "+btoa(c+":"+h)}var l=pt(t.baseURL,t.url);function p(){if(u){var s="getAllResponseHeaders"in u?dt(u.getAllResponseHeaders()):null,n={data:i&&"text"!==i&&"json"!==i?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:s,config:t,request:u};ct((function(t){e(t),a()}),(function(t){r(t),a()}),n),u=null}}if(u.open(t.method.toUpperCase(),lt(l,t.params,t.paramsSerializer),!0),u.timeout=t.timeout,"onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(p)},u.onabort=function(){u&&(r(mt("Request aborted",t,"ECONNABORTED",u)),u=null)},u.onerror=function(){r(mt("Network Error",t,null,u)),u=null},u.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",s=t.transitional||gt.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(mt(e,t,s.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},ut.isStandardBrowserEnv()){var d=(t.withCredentials||ft(l))&&t.xsrfCookieName?ht.read(t.xsrfCookieName):void 0;d&&(o[t.xsrfHeaderName]=d)}"setRequestHeader"in u&&ut.forEach(o,(function(t,e){void 0===n&&"content-type"===e.toLowerCase()?delete o[e]:u.setRequestHeader(e,t)})),ut.isUndefined(t.withCredentials)||(u.withCredentials=!!t.withCredentials),i&&"json"!==i&&(u.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&u.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(s=function(t){u&&(r(!t||t&&t.type?new wt("canceled"):t),u.abort(),u=null)},t.cancelToken&&t.cancelToken.subscribe(s),t.signal&&(t.signal.aborted?s():t.signal.addEventListener("abort",s))),n||(n=null),u.send(n)}))},yt=D,_t=function(t,e){V.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},xt=X,bt={"Content-Type":"application/x-www-form-urlencoded"};function kt(t,e){!yt.isUndefined(t)&&yt.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var Ot,Et={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Ot=vt),Ot),transformRequest:[function(t,e){return _t(e,"Accept"),_t(e,"Content-Type"),yt.isFormData(t)||yt.isArrayBuffer(t)||yt.isBuffer(t)||yt.isStream(t)||yt.isFile(t)||yt.isBlob(t)?t:yt.isArrayBufferView(t)?t.buffer:yt.isURLSearchParams(t)?(kt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):yt.isObject(t)||e&&"application/json"===e["Content-Type"]?(kt(e,"application/json"),function(t,e,r){if(yt.isString(t))try{return(e||JSON.parse)(t),yt.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||Et.transitional,r=e&&e.silentJSONParsing,s=e&&e.forcedJSONParsing,n=!r&&"json"===this.responseType;if(n||s&&yt.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(n){if("SyntaxError"===t.name)throw xt(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};yt.forEach(["delete","get","head"],(function(t){Et.headers[t]={}})),yt.forEach(["post","put","patch"],(function(t){Et.headers[t]=yt.merge(bt)}));var $t=Et,St=D,Rt=$t,Tt=function(t){return!(!t||!t.__CANCEL__)},qt=D,At=function(t,e,r){var s=this||Rt;return St.forEach(r,(function(r){t=r.call(s,t,e)})),t},jt=Tt,Ut=$t,Pt=at;function Ct(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Pt("canceled")}var Nt=D,Bt=function(t,e){e=e||{};var r={};function s(t,e){return Nt.isPlainObject(t)&&Nt.isPlainObject(e)?Nt.merge(t,e):Nt.isPlainObject(e)?Nt.merge({},e):Nt.isArray(e)?e.slice():e}function n(r){return Nt.isUndefined(e[r])?Nt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(t[r],e[r])}function o(t){if(!Nt.isUndefined(e[t]))return s(void 0,e[t])}function i(r){return Nt.isUndefined(e[r])?Nt.isUndefined(t[r])?void 0:s(void 0,t[r]):s(void 0,e[r])}function a(r){return r in e?s(t[r],e[r]):r in t?s(void 0,t[r]):void 0}var u={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a};return Nt.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||n,s=e(t);Nt.isUndefined(s)&&e!==a||(r[t]=s)})),r},Lt="0.24.0",It=Lt,Dt={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){Dt[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var Mt={};Dt.transitional=function(t,e,r){function s(t,e){return"[Axios v"+It+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,o){if(!1===t)throw new Error(s(n," has been removed"+(e?" in "+e:"")));return e&&!Mt[n]&&(Mt[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,o)}};var Ft={assertOptions:function(t,e,r){if("object"!=typeof t)throw new TypeError("options must be an object");for(var s=Object.keys(t),n=s.length;n-- >0;){var o=s[n],i=e[o];if(i){var a=t[o],u=void 0===a||i(a,o,t);if(!0!==u)throw new TypeError("option "+o+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+o)}},validators:Dt},Jt=D,zt=J,Ht=W,Wt=function(t){return Ct(t),t.headers=t.headers||{},t.data=At.call(t,t.data,t.headers,t.transformRequest),t.headers=qt.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),qt.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||Ut.adapter)(t).then((function(e){return Ct(t),e.data=At.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return jt(e)||(Ct(t),e&&e.response&&(e.response.data=At.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Vt=Bt,Xt=Ft,Kt=Xt.validators;function Qt(t){this.defaults=t,this.interceptors={request:new Ht,response:new Ht}}Qt.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Vt(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&Xt.assertOptions(e,{silentJSONParsing:Kt.transitional(Kt.boolean),forcedJSONParsing:Kt.transitional(Kt.boolean),clarifyTimeoutError:Kt.transitional(Kt.boolean)},!1);var r=[],s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,r.unshift(e.fulfilled,e.rejected))}));var n,o=[];if(this.interceptors.response.forEach((function(t){o.push(t.fulfilled,t.rejected)})),!s){var i=[Wt,void 0];for(Array.prototype.unshift.apply(i,r),i=i.concat(o),n=Promise.resolve(t);i.length;)n=n.then(i.shift(),i.shift());return n}for(var a=t;r.length;){var u=r.shift(),c=r.shift();try{a=u(a)}catch(t){c(t);break}}try{n=Wt(a)}catch(t){return Promise.reject(t)}for(;o.length;)n=n.then(o.shift(),o.shift());return n},Qt.prototype.getUri=function(t){return t=Vt(this.defaults,t),zt(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},Jt.forEach(["delete","get","head","options"],(function(t){Qt.prototype[t]=function(e,r){return this.request(Vt(r||{},{method:t,url:e,data:(r||{}).data}))}})),Jt.forEach(["post","put","patch"],(function(t){Qt.prototype[t]=function(e,r,s){return this.request(Vt(s||{},{method:t,url:e,data:r}))}}));var Gt=Qt,Yt=at;function Zt(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;this.promise.then((function(t){if(r._listeners){var e,s=r._listeners.length;for(e=0;e<s;e++)r._listeners[e](t);r._listeners=null}})),this.promise.then=function(t){var e,s=new Promise((function(t){r.subscribe(t),e=t})).then(t);return s.cancel=function(){r.unsubscribe(e)},s},t((function(t){r.reason||(r.reason=new Yt(t),e(r.reason))}))}Zt.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Zt.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},Zt.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},Zt.source=function(){var t;return{token:new Zt((function(e){t=e})),cancel:t}};var te=Zt,ee=D,re=A,se=Gt,ne=Bt;var oe=function t(e){var r=new se(e),s=re(se.prototype.request,r);return ee.extend(s,se.prototype,r),ee.extend(s,r),s.create=function(r){return t(ne(e,r))},s}($t);oe.Axios=se,oe.Cancel=at,oe.CancelToken=te,oe.isCancel=Tt,oe.VERSION=Lt,oe.all=function(t){return Promise.all(t)},oe.spread=function(t){return function(e){return t.apply(null,e)}},oe.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError},q.exports=oe,q.exports.default=oe;var ie=q.exports;class ae extends E{constructor(t){var e;super(),this.config=t,this.axios=ie.create({baseURL:this.config.url,params:this.config.params,headers:this.config.headers,onUploadProgress:this.config.onUploadProgress,withCredentials:!0}),(null===(e=this.config)||void 0===e?void 0:e.beforeRequest)&&(this.beforeRequest=this.config.beforeRequest)}async beforeRequest(t){return t}get url(){return this.config.url}async request(t,e,r,s){var n,o,i,a,u;try{let n={method:t,url:e,data:r,params:null==s?void 0:s.params,headers:null==s?void 0:s.headers,onUploadProgress:null==s?void 0:s.onUploadProgress};n=await this.beforeRequest(n);const o=await this.axios.request(n),i={raw:o.data,status:o.status,statusText:o.statusText,headers:o.headers,data:o.data.data,meta:o.data.meta,errors:o.data.errors};if(o.data.errors)throw new $(null,i);return i}catch(t){if(!t||t instanceof Error==!1)throw t;if(ie.isAxiosError(t)){const e=null===(n=t.response)||void 0===n?void 0:n.data;throw new $(t,{raw:null===(o=t.response)||void 0===o?void 0:o.data,status:null===(i=t.response)||void 0===i?void 0:i.status,statusText:null===(a=t.response)||void 0===a?void 0:a.statusText,headers:null===(u=t.response)||void 0===u?void 0:u.headers,data:null==e?void 0:e.data,meta:null==e?void 0:e.meta,errors:null==e?void 0:e.errors})}throw new $(t)}}async get(t,e){return await this.request("get",t,void 0,e)}async head(t,e){return await this.request("head",t,void 0,e)}async options(t,e){return await this.request("options",t,void 0,e)}async delete(t,e,r){return await this.request("delete",t,e,r)}async put(t,e,r){return await this.request("put",t,e,r)}async post(t,e,r){return await this.request("post",t,e,r)}async patch(t,e,r){return await this.request("patch",t,e,r)}}class ue{constructor(t){this.transport=t}async request(t,e){await this.transport.post("/auth/password/request",{email:t,reset_url:e})}async reset(t,e){await this.transport.post("/auth/password/reset",{token:t,password:e})}}class ce extends t{constructor(t){var e,r,s;super(),this.autoRefresh=!0,this.msRefreshBeforeExpires=3e4,this.staticToken="",this._transport=t.transport,this._storage=t.storage,this.autoRefresh=null!==(e=null==t?void 0:t.autoRefresh)&&void 0!==e?e:this.autoRefresh,this.mode=null!==(r=null==t?void 0:t.mode)&&void 0!==r?r:this.mode,this.msRefreshBeforeExpires=null!==(s=null==t?void 0:t.msRefreshBeforeExpires)&&void 0!==s?s:this.msRefreshBeforeExpires,(null==t?void 0:t.staticToken)&&(this.staticToken=null==t?void 0:t.staticToken,this.updateStorage({access_token:this.staticToken,expires:null,refresh_token:null}))}get storage(){return this._storage}get transport(){return this._transport}get token(){return(async()=>{if(this._refreshPromise)try{await this._refreshPromise}finally{this._refreshPromise=void 0}return this._storage.auth_token})()}get password(){return this.passwords=this.passwords||new ue(this._transport)}resetStorage(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null,this._storage.auth_expires_at=null}updateStorage(t){var e,r;const s=null!==(e=t.expires)&&void 0!==e?e:null;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(r=t.refresh_token)&&void 0!==r?r:null,this._storage.auth_expires=s,this._storage.auth_expires_at=(new Date).getTime()+(null!=s?s:0)}async refreshIfExpired(){if(!this.staticToken&&this.autoRefresh)if(this._storage.auth_expires_at){this._storage.auth_expires_at<(new Date).getTime()+this.msRefreshBeforeExpires&&this.refresh();try{await this._refreshPromise}finally{this._refreshPromise=void 0}}else try{await this._refreshPromise}finally{this._refreshPromise=void 0}}refresh(){return this._refreshPromise=(async()=>{var t;const e=this._storage.auth_refresh_token;this.resetStorage();const r=await this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?e:void 0});return this.updateStorage(r.data),{access_token:r.data.access_token,...(null===(t=r.data)||void 0===t?void 0:t.refresh_token)&&{refresh_token:r.data.refresh_token},expires:r.data.expires}})()}async login(t){var e;this.resetStorage();const r=await this._transport.post("/auth/login",{mode:this.mode,...t},{headers:{Authorization:null}});return this.updateStorage(r.data),{access_token:r.data.access_token,...(null===(e=r.data)||void 0===e?void 0:e.refresh_token)&&{refresh_token:r.data.refresh_token},expires:r.data.expires}}async static(t){return this.staticToken||(this.staticToken=t),await this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}}),this.updateStorage({access_token:t,expires:null,refresh_token:null}),!0}async logout(){let t;"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),await this._transport.post("/auth/logout",{refresh_token:t}),this.updateStorage({access_token:null,expires:null,refresh_token:null})}}class he{constructor(t){this.transport=t}async request(t,e,r){return await this.transport.post(t,{query:e,variables:void 0===r?{}:r})}async items(t,e){return await this.request("/graphql",t,e)}async system(t,e){return await this.request("/graphql/system",t,e)}}class le{constructor(e,r){var s,n,o,i,a,u,c,h,l;if(this._url=e,this._options=r,this._items={},this._singletons={},(null===(s=this._options)||void 0===s?void 0:s.storage)&&(null===(n=this._options)||void 0===n?void 0:n.storage)instanceof O)this._storage=this._options.storage;else{const t=null===(o=this._options)||void 0===o?void 0:o.storage,{mode:e,...r}=null!=t?t:{};"MemoryStorage"===e||"undefined"==typeof window?this._storage=new R(r):this._storage=new T(r)}(null===(i=this._options)||void 0===i?void 0:i.transport)&&(null===(a=this._options)||void 0===a?void 0:a.transport)instanceof E?this._transport=this._options.transport:this._transport=new ae({url:this.url,beforeRequest:async t=>{await this._auth.refreshIfExpired();const e=this.storage.auth_token,r=e?e.startsWith("Bearer ")?String(this.storage.auth_token):`Bearer ${this.storage.auth_token}`:"";return{...t,headers:{Authorization:r,...t.headers}}},...null===(u=this._options)||void 0===u?void 0:u.transport}),(null===(c=this._options)||void 0===c?void 0:c.auth)&&(null===(h=this._options)||void 0===h?void 0:h.auth)instanceof t?this._auth=this._options.auth:this._auth=new ce({transport:this._transport,storage:this._storage,...null===(l=this._options)||void 0===l?void 0:l.auth})}get url(){return this._url}get auth(){return this._auth}get storage(){return this._storage}get transport(){return this._transport}get activity(){return this._activity||(this._activity=new i(this.transport))}get collections(){return this._collections||(this._collections=new a(this.transport))}get fields(){return this._fields||(this._fields=new u(this.transport))}get files(){return this._files||(this._files=new c(this.transport))}get folders(){return this._folders||(this._folders=new h(this.transport))}get permissions(){return this._permissions||(this._permissions=new l(this.transport))}get presets(){return this._presets||(this._presets=new p(this.transport))}get relations(){return this._relations||(this._relations=new d(this.transport))}get revisions(){return this._revisions||(this._revisions=new f(this.transport))}get roles(){return this._roles||(this._roles=new m(this.transport))}get users(){return this._users||(this._users=new b(this.transport))}get settings(){return this._settings||(this._settings=new v(this.transport))}get server(){return this._server||(this._server=new g(this.transport))}get utils(){return this._utils||(this._utils=new k(this.transport))}get graphql(){return this._graphql||(this._graphql=new he(this.transport))}singleton(t){return this._singletons[t]||(this._singletons[t]=new w(t,this.transport))}items(t){return this._items[t]||(this._items[t]=new n(t,this.transport))}}export{i as ActivityHandler,ce as Auth,S as BaseStorage,a as CollectionsHandler,o as CommentsHandler,le as Directus,s as EmptyParamError,u as FieldsHandler,c as FilesHandler,h as FoldersHandler,t as IAuth,O as IStorage,E as ITransport,n as ItemsHandler,T as LocalStorage,R as MemoryStorage,e as Meta,l as PermissionsHandler,p as PresetsHandler,d as RelationsHandler,f as RevisionsHandler,m as RolesHandler,g as ServerHandler,v as SettingsHandler,ae as Transport,$ as TransportError,b as UsersHandler,k as UtilsHandler}; | ||
//# sourceMappingURL=sdk.esm.min.js.map |
@@ -1,2 +0,2 @@ | ||
var DirectusSdk=function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e),o=function(){this.mode="undefined"==typeof window?"json":"cookie"},i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u,a=function(){return a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)};function c(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function u(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function h(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}t.Meta=void 0,(u=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",u.FILTER_COUNT="filter_count";var l,p=function(t){function e(e){return t.call(this,"".concat(null!=e?e:"ID"," cannot be an empty string"))||this}return s(e,t),e}(Error),f=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.readOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("id");return[4,this.transport.get("".concat(this.endpoint,"/").concat(encodeURI(t)),a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent().data]}}))}))},t.prototype.readMany=function(t,e,n){var r;return c(this,void 0,void 0,(function(){var o,i,s,u,c,l;return h(this,(function(h){switch(h.label){case 0:return[4,this.transport.get("/fields/".concat(this.collection))];case 1:return o=h.sent(),i=null===(r=o.data)||void 0===r?void 0:r.find((function(t){return!0===t.schema.is_primary_key})),[4,this.transport.get("".concat(this.endpoint),a({params:a({filter:a((l={},l[i.field]={_in:t},l),null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)||i.field},e)},null==n?void 0:n.requestOptions))];case 2:return s=h.sent(),u=s.data,c=s.meta,[2,a({data:u},c&&{meta:c})]}}))}))},t.prototype.readByQuery=function(t,e){return c(this,void 0,void 0,(function(){var n,r,o;return h(this,(function(i){switch(i.label){case 0:return[4,this.transport.get("".concat(this.endpoint),a({params:t},null==e?void 0:e.requestOptions))];case 1:return n=i.sent(),r=n.data,o=n.meta,[2,a({data:r},o&&{meta:o})]}}))}))},t.prototype.createOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent().data]}}))}))},t.prototype.createMany=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent()]}}))}))},t.prototype.updateOne=function(t,e,n,r){return c(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:if(""==="".concat(t))throw new p("id");return[4,this.transport.patch("".concat(this.endpoint,"/").concat(encodeURI(t)),e,a({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent().data]}}))}))},t.prototype.updateMany=function(t,e,n,r){return c(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{keys:t,data:e},a({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent()]}}))}))},t.prototype.updateByQuery=function(t,e,n,r){return c(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{query:t,data:e},a({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent()]}}))}))},t.prototype.deleteOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("id");return[4,this.transport.delete("".concat(this.endpoint,"/").concat(encodeURI(t)),void 0,null==e?void 0:e.requestOptions)];case 1:return n.sent(),[2]}}))}))},t.prototype.deleteMany=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("".concat(this.endpoint),t,null==e?void 0:e.requestOptions)];case 1:return n.sent(),[2]}}))}))},t}(),d=function(){function t(t){this.transport=t}return t.prototype.create=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/activity/comment",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("comment_activity_id");return[4,this.transport.patch("/activity/comment/".concat(encodeURI(t)),{comment:e})];case 1:return[2,n.sent().data]}}))}))},t.prototype.delete=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("comment_activity_id");return[4,this.transport.delete("/activity/comment/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}(),v=function(t){function e(e){var n=t.call(this,"directus_activity",e)||this;return n._comments=new d(n.transport),n}return s(e,t),Object.defineProperty(e.prototype,"comments",{get:function(){return this._comments},enumerable:!1,configurable:!0}),e}(f),y=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.get("/collections/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return c(this,void 0,void 0,(function(){var t,e,n;return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.get("/collections")];case 1:return t=r.sent(),e=t.data,n=t.meta,[2,{data:e,meta:n}]}}))}))},t.prototype.createOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.createMany=function(t){return c(this,void 0,void 0,(function(){var e,n,r;return h(this,(function(o){switch(o.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return e=o.sent(),n=e.data,r=e.meta,[2,{data:n,meta:r}]}}))}))},t.prototype.updateOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.patch("/collections/".concat(t),e,{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.delete("/collections/".concat(t))];case 1:return e.sent(),[2]}}))}))},t}(),b=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("id");return[4,this.transport.get("/fields/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.get("/fields/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/fields")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.post("/fields/".concat(t),e)];case 1:return[2,n.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.patch("/fields/".concat(t,"/").concat(e),n)];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.delete("/fields/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),g=function(t){function e(e){return t.call(this,"directus_files",e)||this}return s(e,t),e.prototype.import=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/files/import",t)];case 1:return[2,e.sent().data]}}))}))},e}(f),_=function(t){function e(e){return t.call(this,"directus_folders",e)||this}return s(e,t),e}(f),w=function(t){function e(e){return t.call(this,"directus_permissions",e)||this}return s(e,t),e}(f),m=function(t){function e(e){return t.call(this,"directus_presets",e)||this}return s(e,t),e}(f),O=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("id");return[4,this.transport.get("/relations/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.get("/relations/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/relations")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/relations",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.patch("/relations/".concat(t,"/").concat(e),{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.delete("/relations/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),k=function(t){function e(e){return t.call(this,"directus_revisions",e)||this}return s(e,t),e}(f),x=function(t){function e(e){return t.call(this,"directus_roles",e)||this}return s(e,t),e}(f),P=function(){function t(t){this.transport=t}return t.prototype.ping=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/ping")];case 1:return[2,t.sent().raw]}}))}))},t.prototype.info=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/info")];case 1:return[2,t.sent().data]}}))}))},t}(),j=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.read=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("".concat(this.endpoint),{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),q=function(t){function e(e){return t.call(this,"directus_settings",e)||this}return s(e,t),e}(j),R=function(){function t(t){this.transport=t}return t.prototype.send=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/users/invite",{email:t,role:e,invite_url:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.accept=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/invite/accept",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),T=function(){function t(t){this.transport=t}return t.prototype.generate=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/generate",{password:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.enable=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.disable=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/disable",{otp:t})];case 1:return e.sent(),[2]}}))}))},t}(),S=function(){function t(t){this._transport=t}return Object.defineProperty(t.prototype,"tfa",{get:function(){return this._tfa||(this._tfa=new T(this._transport))},enumerable:!1,configurable:!0}),t.prototype.read=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._transport.get("/users/me",{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this._transport.patch("/users/me",t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),E=function(t){function e(e){return t.call(this,"directus_users",e)||this}return s(e,t),Object.defineProperty(e.prototype,"invites",{get:function(){return this._invites||(this._invites=new R(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"me",{get:function(){return this._me||(this._me=new S(this.transport))},enumerable:!1,configurable:!0}),e}(f),I=function(){function t(t){var e=this;this.random={string:function(t){return void 0===t&&(t=32),c(e,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/utils/random/string",{params:{length:t}})];case 1:return[2,e.sent().data]}}))}))}},this.hash={generate:function(t){return c(e,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/generate",{string:t})];case 1:return[2,e.sent().data]}}))}))},verify:function(t,n){return c(e,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/verify",{string:t,hash:n})];case 1:return[2,e.sent().data]}}))}))}},this.transport=t}return t.prototype.sort=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/utils/sort/".concat(encodeURI(t)),{item:e,to:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.revert=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/revert/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}(),A=function(){},U=function(){},H=function(t){function e(n,r){var o,i,s=this;return(s=(null===(o=null==r?void 0:r.errors)||void 0===o?void 0:o.length)?t.call(this,null===(i=null==r?void 0:r.errors[0])||void 0===i?void 0:i.message)||this:t.call(this,(null==n?void 0:n.message)||"Unknown transport error")||this).parent=n,s.response=r,s.errors=(null==r?void 0:r.errors)||[],Object.values(r||{}).some((function(t){return void 0!==t}))||(s.response=void 0),Object.setPrototypeOf(s,e.prototype),s}return s(e,t),e}(Error);!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(l||(l={}));var M=function(t){function e(e){var n,r=t.call(this)||this;return r.prefix=null!==(n=null==e?void 0:e.prefix)&&void 0!==n?n:"",r}return s(e,t),Object.defineProperty(e.prototype,"auth_token",{get:function(){return this.get(l.AuthToken)},set:function(t){null===t?this.delete(l.AuthToken):this.set(l.AuthToken,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_expires",{get:function(){var t=this.get(l.Expires);return null===t?null:parseInt(t)},set:function(t){null===t?this.delete(l.Expires):this.set(l.Expires,t.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_expires_at",{get:function(){var t=this.get(l.ExpiresAt);return null===t?null:parseInt(t)},set:function(t){null===t?this.delete(l.ExpiresAt):this.set(l.ExpiresAt,t.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_refresh_token",{get:function(){return this.get(l.RefreshToken)},set:function(t){null===t?this.delete(l.RefreshToken):this.set(l.RefreshToken,t)},enumerable:!1,configurable:!0}),e}(A),B=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.values={},e}return s(e,t),e.prototype.get=function(t){var e=this.key(t);return e in this.values?this.values[e]:null},e.prototype.set=function(t,e){return this.values[this.key(t)]=e,e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(t);return e in this.values&&delete this.values[e],n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(M),C=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.get=function(t){var e=localStorage.getItem(this.key(t));return null!==e?e:null},e.prototype.set=function(t,e){return localStorage.setItem(this.key(t),e),e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(e);return n&&localStorage.removeItem(e),n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(M),D=function(t){function e(e){var n,o=t.call(this)||this;return o.config=e,o.axios=r.default.create({baseURL:o.config.url,params:o.config.params,headers:o.config.headers,onUploadProgress:o.config.onUploadProgress,withCredentials:!0}),(null===(n=o.config)||void 0===n?void 0:n.beforeRequest)&&(o.beforeRequest=o.config.beforeRequest),o}return s(e,t),e.prototype.beforeRequest=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){return[2,t]}))}))},Object.defineProperty(e.prototype,"url",{get:function(){return this.config.url},enumerable:!1,configurable:!0}),e.prototype.request=function(t,e,n,o){var i,s,u,a,l;return c(this,void 0,void 0,(function(){var c,p,f,d,v;return h(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),c={method:t,url:e,data:n,params:null==o?void 0:o.params,headers:null==o?void 0:o.headers,onUploadProgress:null==o?void 0:o.onUploadProgress},[4,this.beforeRequest(c)];case 1:return c=h.sent(),[4,this.axios.request(c)];case 2:if(p=h.sent(),f={raw:p.data,status:p.status,statusText:p.statusText,headers:p.headers,data:p.data.data,meta:p.data.meta,errors:p.data.errors},p.data.errors)throw new H(null,f);return[2,f];case 3:if(!(d=h.sent())||d instanceof Error==!1)throw d;if(r.default.isAxiosError(d))throw v=null===(i=d.response)||void 0===i?void 0:i.data,new H(d,{raw:null===(s=d.response)||void 0===s?void 0:s.data,status:null===(u=d.response)||void 0===u?void 0:u.status,statusText:null===(a=d.response)||void 0===a?void 0:a.statusText,headers:null===(l=d.response)||void 0===l?void 0:l.headers,data:null==v?void 0:v.data,meta:null==v?void 0:v.meta,errors:null==v?void 0:v.errors});throw new H(d);case 4:return[2]}}))}))},e.prototype.get=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("get",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.head=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("head",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.options=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("options",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.delete=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("delete",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.put=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("put",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.post=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("post",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.patch=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("patch",t,e,n)];case 1:return[2,r.sent()]}}))}))},e}(U),F=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/request",{email:t,reset_url:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.reset=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/reset",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),L=function(t){function e(e){var n,r,o,i=t.call(this)||this;return i.autoRefresh=!0,i.msRefreshBeforeExpires=3e4,i.staticToken="",i._transport=e.transport,i._storage=e.storage,i.autoRefresh=null!==(n=null==e?void 0:e.autoRefresh)&&void 0!==n?n:i.autoRefresh,i.mode=null!==(r=null==e?void 0:e.mode)&&void 0!==r?r:i.mode,i.msRefreshBeforeExpires=null!==(o=null==e?void 0:e.msRefreshBeforeExpires)&&void 0!==o?o:i.msRefreshBeforeExpires,(null==e?void 0:e.staticToken)&&(i.staticToken=null==e?void 0:e.staticToken,i.updateStorage({access_token:i.staticToken,expires:null,refresh_token:null})),i}return s(e,t),Object.defineProperty(e.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"token",{get:function(){return this._storage.auth_token},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"password",{get:function(){return this.passwords=this.passwords||new F(this._transport)},enumerable:!1,configurable:!0}),e.prototype.resetStorage=function(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null,this._storage.auth_expires_at=null},e.prototype.updateStorage=function(t){var e,n,r=null!==(e=t.expires)&&void 0!==e?e:null;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(n=t.refresh_token)&&void 0!==n?n:null,this._storage.auth_expires=r,this._storage.auth_expires_at=(new Date).getTime()+(null!=r?r:0)},e.prototype.refreshIfExpired=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:if(this.staticToken)return[2];if(!this.autoRefresh)return[2];if(this._storage.auth_expires_at)return[3,5];t.label=1;case 1:return t.trys.push([1,,3,4]),[4,this._refreshPromise];case 2:return t.sent(),[3,4];case 3:return this._refreshPromise=void 0,[7];case 4:return[2];case 5:this._storage.auth_expires_at<(new Date).getTime()+this.msRefreshBeforeExpires&&(this._refreshPromise=this.refresh()),t.label=6;case 6:return t.trys.push([6,,8,9]),[4,this._refreshPromise];case 7:return t.sent(),[3,9];case 8:return this._refreshPromise=void 0,[7];case 9:return[2]}}))}))},e.prototype.refresh=function(){var t;return c(this,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:return e=this._storage.auth_refresh_token,this.resetStorage(),[4,this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?e:void 0})];case 1:return n=r.sent(),this.updateStorage(n.data),[2,a(a({access_token:n.data.access_token},(null===(t=n.data)||void 0===t?void 0:t.refresh_token)&&{refresh_token:n.data.refresh_token}),{expires:n.data.expires})]}}))}))},e.prototype.login=function(t){var e;return c(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.resetStorage(),[4,this._transport.post("/auth/login",a({mode:this.mode},t),{headers:{Authorization:null}})];case 1:return n=r.sent(),this.updateStorage(n.data),[2,a(a({access_token:n.data.access_token},(null===(e=n.data)||void 0===e?void 0:e.refresh_token)&&{refresh_token:n.data.refresh_token}),{expires:n.data.expires})]}}))}))},e.prototype.static=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this.staticToken||(this.staticToken=t),[4,this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}})];case 1:return e.sent(),this.updateStorage({access_token:t,expires:null,refresh_token:null}),[2,!0]}}))}))},e.prototype.logout=function(){return c(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),[4,this._transport.post("/auth/logout",{refresh_token:t})];case 1:return e.sent(),this.updateStorage({access_token:null,expires:null,refresh_token:null}),[2]}}))}))},e}(o),z=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post(t,{query:e,variables:void 0===n?{}:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.items=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql",t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.system=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql/system",t,e)];case 1:return[2,n.sent()]}}))}))},t}(),W=function(){function t(t,e){var n,r,i,s,u,l,p,f,d,v=this;if(this._url=t,this._options=e,this._items={},this._singletons={},(null===(n=this._options)||void 0===n?void 0:n.storage)&&(null===(r=this._options)||void 0===r?void 0:r.storage)instanceof A)this._storage=this._options.storage;else{var y=null===(i=this._options)||void 0===i?void 0:i.storage,b=null!=y?y:{},g=b.mode,_=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(b,["mode"]);"MemoryStorage"===g||"undefined"==typeof window?this._storage=new B(_):this._storage=new C(_)}(null===(s=this._options)||void 0===s?void 0:s.transport)&&(null===(u=this._options)||void 0===u?void 0:u.transport)instanceof U?this._transport=this._options.transport:this._transport=new D(a({url:this.url,beforeRequest:function(t){return c(v,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:return[4,this._auth.refreshIfExpired()];case 1:return r.sent(),e=this.storage.auth_token,n=e?e.startsWith("Bearer ")?String(this.storage.auth_token):"Bearer ".concat(this.storage.auth_token):"",[2,a(a({},t),{headers:a({Authorization:n},t.headers)})]}}))}))}},null===(l=this._options)||void 0===l?void 0:l.transport)),(null===(p=this._options)||void 0===p?void 0:p.auth)&&(null===(f=this._options)||void 0===f?void 0:f.auth)instanceof o?this._auth=this._options.auth:this._auth=new L(a({transport:this._transport,storage:this._storage},null===(d=this._options)||void 0===d?void 0:d.auth))}return Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"auth",{get:function(){return this._auth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activity",{get:function(){return this._activity||(this._activity=new v(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collections",{get:function(){return this._collections||(this._collections=new y(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fields",{get:function(){return this._fields||(this._fields=new b(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"files",{get:function(){return this._files||(this._files=new g(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"folders",{get:function(){return this._folders||(this._folders=new _(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"permissions",{get:function(){return this._permissions||(this._permissions=new w(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"presets",{get:function(){return this._presets||(this._presets=new m(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"relations",{get:function(){return this._relations||(this._relations=new O(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"revisions",{get:function(){return this._revisions||(this._revisions=new k(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roles",{get:function(){return this._roles||(this._roles=new x(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"users",{get:function(){return this._users||(this._users=new E(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"settings",{get:function(){return this._settings||(this._settings=new q(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"server",{get:function(){return this._server||(this._server=new P(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"utils",{get:function(){return this._utils||(this._utils=new I(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"graphql",{get:function(){return this._graphql||(this._graphql=new z(this.transport))},enumerable:!1,configurable:!0}),t.prototype.singleton=function(t){return this._singletons[t]||(this._singletons[t]=new j(t,this.transport))},t.prototype.items=function(t){return this._items[t]||(this._items[t]=new f(t,this.transport))},t}();return t.ActivityHandler=v,t.Auth=L,t.BaseStorage=M,t.CollectionsHandler=y,t.CommentsHandler=d,t.Directus=W,t.EmptyParamError=p,t.FieldsHandler=b,t.FilesHandler=g,t.FoldersHandler=_,t.IAuth=o,t.IStorage=A,t.ITransport=U,t.ItemsHandler=f,t.LocalStorage=C,t.MemoryStorage=B,t.PermissionsHandler=w,t.PresetsHandler=m,t.RelationsHandler=O,t.RevisionsHandler=k,t.RolesHandler=x,t.ServerHandler=P,t.SettingsHandler=q,t.Transport=D,t.TransportError=H,t.UsersHandler=E,t.UtilsHandler=I,Object.defineProperty(t,"__esModule",{value:!0}),t}({},axios); | ||
var DirectusSdk=function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e),o=function(){this.mode="undefined"==typeof window?"json":"cookie"},i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u,a=function(){return a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)};function c(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function u(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function h(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}t.Meta=void 0,(u=t.Meta||(t.Meta={})).TOTAL_COUNT="total_count",u.FILTER_COUNT="filter_count";var l,p=function(t){function e(e){return t.call(this,"".concat(null!=e?e:"ID"," cannot be an empty string"))||this}return s(e,t),e}(Error),f=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.readOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("id");return[4,this.transport.get("".concat(this.endpoint,"/").concat(encodeURI(t)),a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent().data]}}))}))},t.prototype.readMany=function(t,e,n){var r;return c(this,void 0,void 0,(function(){var o,i,s,u,c,l;return h(this,(function(h){switch(h.label){case 0:return[4,this.transport.get("/fields/".concat(this.collection))];case 1:return o=h.sent(),i=null===(r=o.data)||void 0===r?void 0:r.find((function(t){return!0===t.schema.is_primary_key})),[4,this.transport.get("".concat(this.endpoint),a({params:a({filter:a((l={},l[i.field]={_in:t},l),null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)||i.field},e)},null==n?void 0:n.requestOptions))];case 2:return s=h.sent(),u=s.data,c=s.meta,[2,a({data:u},c&&{meta:c})]}}))}))},t.prototype.readByQuery=function(t,e){return c(this,void 0,void 0,(function(){var n,r,o;return h(this,(function(i){switch(i.label){case 0:return[4,this.transport.get("".concat(this.endpoint),a({params:t},null==e?void 0:e.requestOptions))];case 1:return n=i.sent(),r=n.data,o=n.meta,[2,a({data:r},o&&{meta:o})]}}))}))},t.prototype.createOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent().data]}}))}))},t.prototype.createMany=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("".concat(this.endpoint),t,a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.sent()]}}))}))},t.prototype.updateOne=function(t,e,n,r){return c(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:if(""==="".concat(t))throw new p("id");return[4,this.transport.patch("".concat(this.endpoint,"/").concat(encodeURI(t)),e,a({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent().data]}}))}))},t.prototype.updateMany=function(t,e,n,r){return c(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{keys:t,data:e},a({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent()]}}))}))},t.prototype.updateByQuery=function(t,e,n,r){return c(this,void 0,void 0,(function(){return h(this,(function(o){switch(o.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),{query:t,data:e},a({params:n},null==r?void 0:r.requestOptions))];case 1:return[2,o.sent()]}}))}))},t.prototype.deleteOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("id");return[4,this.transport.delete("".concat(this.endpoint,"/").concat(encodeURI(t)),void 0,null==e?void 0:e.requestOptions)];case 1:return n.sent(),[2]}}))}))},t.prototype.deleteMany=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.delete("".concat(this.endpoint),t,null==e?void 0:e.requestOptions)];case 1:return n.sent(),[2]}}))}))},t}(),d=function(){function t(t){this.transport=t}return t.prototype.create=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/activity/comment",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("comment_activity_id");return[4,this.transport.patch("/activity/comment/".concat(encodeURI(t)),{comment:e})];case 1:return[2,n.sent().data]}}))}))},t.prototype.delete=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("comment_activity_id");return[4,this.transport.delete("/activity/comment/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}(),v=function(t){function e(e){var n=t.call(this,"directus_activity",e)||this;return n._comments=new d(n.transport),n}return s(e,t),Object.defineProperty(e.prototype,"comments",{get:function(){return this._comments},enumerable:!1,configurable:!0}),e}(f),y=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.get("/collections/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return c(this,void 0,void 0,(function(){var t,e,n;return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.get("/collections")];case 1:return t=r.sent(),e=t.data,n=t.meta,[2,{data:e,meta:n}]}}))}))},t.prototype.createOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.createMany=function(t){return c(this,void 0,void 0,(function(){var e,n,r;return h(this,(function(o){switch(o.label){case 0:return[4,this.transport.post("/collections",t)];case 1:return e=o.sent(),n=e.data,r=e.meta,[2,{data:n,meta:r}]}}))}))},t.prototype.updateOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.patch("/collections/".concat(t),e,{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.delete("/collections/".concat(t))];case 1:return e.sent(),[2]}}))}))},t}(),b=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("id");return[4,this.transport.get("/fields/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.get("/fields/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/fields")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.post("/fields/".concat(t),e)];case 1:return[2,n.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.patch("/fields/".concat(t,"/").concat(e),n)];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.delete("/fields/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),g=function(t){function e(e){return t.call(this,"directus_files",e)||this}return s(e,t),e.prototype.import=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/files/import",t)];case 1:return[2,e.sent().data]}}))}))},e}(f),_=function(t){function e(e){return t.call(this,"directus_folders",e)||this}return s(e,t),e}(f),w=function(t){function e(e){return t.call(this,"directus_permissions",e)||this}return s(e,t),e}(f),m=function(t){function e(e){return t.call(this,"directus_presets",e)||this}return s(e,t),e}(f),O=function(){function t(t){this.transport=t}return t.prototype.readOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("id");return[4,this.transport.get("/relations/".concat(t,"/").concat(e))];case 1:return[2,n.sent().data]}}))}))},t.prototype.readMany=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:if(""==="".concat(t))throw new p("collection");return[4,this.transport.get("/relations/".concat(t))];case 1:return[2,e.sent().data]}}))}))},t.prototype.readAll=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/relations")];case 1:return[2,t.sent().data]}}))}))},t.prototype.createOne=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/relations",t)];case 1:return[2,e.sent().data]}}))}))},t.prototype.updateOne=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.patch("/relations/".concat(t,"/").concat(e),{params:n})];case 1:return[2,r.sent().data]}}))}))},t.prototype.deleteOne=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:if(""==="".concat(t))throw new p("collection");if(""==="".concat(e))throw new p("field");return[4,this.transport.delete("/relations/".concat(t,"/").concat(e))];case 1:return n.sent(),[2]}}))}))},t}(),k=function(t){function e(e){return t.call(this,"directus_revisions",e)||this}return s(e,t),e}(f),P=function(t){function e(e){return t.call(this,"directus_roles",e)||this}return s(e,t),e}(f),x=function(){function t(t){this.transport=t}return t.prototype.ping=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/ping")];case 1:return[2,t.sent().raw]}}))}))},t.prototype.info=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:return[4,this.transport.get("/server/info")];case 1:return[2,t.sent().data]}}))}))},t}(),j=function(){function t(t,e){this.collection=t,this.transport=e,this.endpoint=t.startsWith("directus_")?"/".concat(t.substring(9)):"/items/".concat(t)}return t.prototype.read=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("".concat(this.endpoint),{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.patch("".concat(this.endpoint),t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),q=function(t){function e(e){return t.call(this,"directus_settings",e)||this}return s(e,t),e}(j),R=function(){function t(t){this.transport=t}return t.prototype.send=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/users/invite",{email:t,role:e,invite_url:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.accept=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/invite/accept",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),T=function(){function t(t){this.transport=t}return t.prototype.generate=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/generate",{password:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.enable=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/users/me/tfa/enable",{secret:t,otp:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.disable=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/users/me/tfa/disable",{otp:t})];case 1:return e.sent(),[2]}}))}))},t}(),S=function(){function t(t){this._transport=t}return Object.defineProperty(t.prototype,"tfa",{get:function(){return this._tfa||(this._tfa=new T(this._transport))},enumerable:!1,configurable:!0}),t.prototype.read=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this._transport.get("/users/me",{params:t})];case 1:return[2,e.sent().data]}}))}))},t.prototype.update=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this._transport.patch("/users/me",t,{params:e})];case 1:return[2,n.sent().data]}}))}))},t}(),E=function(t){function e(e){return t.call(this,"directus_users",e)||this}return s(e,t),Object.defineProperty(e.prototype,"invites",{get:function(){return this._invites||(this._invites=new R(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"me",{get:function(){return this._me||(this._me=new S(this.transport))},enumerable:!1,configurable:!0}),e}(f),I=function(){function t(t){var e=this;this.random={string:function(t){return void 0===t&&(t=32),c(e,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.get("/utils/random/string",{params:{length:t}})];case 1:return[2,e.sent().data]}}))}))}},this.hash={generate:function(t){return c(e,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/generate",{string:t})];case 1:return[2,e.sent().data]}}))}))},verify:function(t,n){return c(e,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/hash/verify",{string:t,hash:n})];case 1:return[2,e.sent().data]}}))}))}},this.transport=t}return t.prototype.sort=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post("/utils/sort/".concat(encodeURI(t)),{item:e,to:n})];case 1:return r.sent(),[2]}}))}))},t.prototype.revert=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return[4,this.transport.post("/utils/revert/".concat(encodeURI(t)))];case 1:return e.sent(),[2]}}))}))},t}(),A=function(){},U=function(){},H=function(t){function e(n,r){var o,i,s=this;return(s=(null===(o=null==r?void 0:r.errors)||void 0===o?void 0:o.length)?t.call(this,null===(i=null==r?void 0:r.errors[0])||void 0===i?void 0:i.message)||this:t.call(this,(null==n?void 0:n.message)||"Unknown transport error")||this).parent=n,s.response=r,s.errors=(null==r?void 0:r.errors)||[],Object.values(r||{}).some((function(t){return void 0!==t}))||(s.response=void 0),Object.setPrototypeOf(s,e.prototype),s}return s(e,t),e}(Error);!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(l||(l={}));var M=function(t){function e(e){var n,r=t.call(this)||this;return r.prefix=null!==(n=null==e?void 0:e.prefix)&&void 0!==n?n:"",r}return s(e,t),Object.defineProperty(e.prototype,"auth_token",{get:function(){return this.get(l.AuthToken)},set:function(t){null===t?this.delete(l.AuthToken):this.set(l.AuthToken,t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_expires",{get:function(){var t=this.get(l.Expires);return null===t?null:parseInt(t)},set:function(t){null===t?this.delete(l.Expires):this.set(l.Expires,t.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_expires_at",{get:function(){var t=this.get(l.ExpiresAt);return null===t?null:parseInt(t)},set:function(t){null===t?this.delete(l.ExpiresAt):this.set(l.ExpiresAt,t.toString())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"auth_refresh_token",{get:function(){return this.get(l.RefreshToken)},set:function(t){null===t?this.delete(l.RefreshToken):this.set(l.RefreshToken,t)},enumerable:!1,configurable:!0}),e}(A),B=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.values={},e}return s(e,t),e.prototype.get=function(t){var e=this.key(t);return e in this.values?this.values[e]:null},e.prototype.set=function(t,e){return this.values[this.key(t)]=e,e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(t);return e in this.values&&delete this.values[e],n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(M),C=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.get=function(t){var e=localStorage.getItem(this.key(t));return null!==e?e:null},e.prototype.set=function(t,e){return localStorage.setItem(this.key(t),e),e},e.prototype.delete=function(t){var e=this.key(t),n=this.get(e);return n&&localStorage.removeItem(e),n},e.prototype.key=function(t){return"".concat(this.prefix).concat(t)},e}(M),D=function(t){function e(e){var n,o=t.call(this)||this;return o.config=e,o.axios=r.default.create({baseURL:o.config.url,params:o.config.params,headers:o.config.headers,onUploadProgress:o.config.onUploadProgress,withCredentials:!0}),(null===(n=o.config)||void 0===n?void 0:n.beforeRequest)&&(o.beforeRequest=o.config.beforeRequest),o}return s(e,t),e.prototype.beforeRequest=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){return[2,t]}))}))},Object.defineProperty(e.prototype,"url",{get:function(){return this.config.url},enumerable:!1,configurable:!0}),e.prototype.request=function(t,e,n,o){var i,s,u,a,l;return c(this,void 0,void 0,(function(){var c,p,f,d,v;return h(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),c={method:t,url:e,data:n,params:null==o?void 0:o.params,headers:null==o?void 0:o.headers,onUploadProgress:null==o?void 0:o.onUploadProgress},[4,this.beforeRequest(c)];case 1:return c=h.sent(),[4,this.axios.request(c)];case 2:if(p=h.sent(),f={raw:p.data,status:p.status,statusText:p.statusText,headers:p.headers,data:p.data.data,meta:p.data.meta,errors:p.data.errors},p.data.errors)throw new H(null,f);return[2,f];case 3:if(!(d=h.sent())||d instanceof Error==!1)throw d;if(r.default.isAxiosError(d))throw v=null===(i=d.response)||void 0===i?void 0:i.data,new H(d,{raw:null===(s=d.response)||void 0===s?void 0:s.data,status:null===(u=d.response)||void 0===u?void 0:u.status,statusText:null===(a=d.response)||void 0===a?void 0:a.statusText,headers:null===(l=d.response)||void 0===l?void 0:l.headers,data:null==v?void 0:v.data,meta:null==v?void 0:v.meta,errors:null==v?void 0:v.errors});throw new H(d);case 4:return[2]}}))}))},e.prototype.get=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("get",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.head=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("head",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.options=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("options",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},e.prototype.delete=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("delete",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.put=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("put",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.post=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("post",t,e,n)];case 1:return[2,r.sent()]}}))}))},e.prototype.patch=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.request("patch",t,e,n)];case 1:return[2,r.sent()]}}))}))},e}(U),F=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/request",{email:t,reset_url:e})];case 1:return n.sent(),[2]}}))}))},t.prototype.reset=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.transport.post("/auth/password/reset",{token:t,password:e})];case 1:return n.sent(),[2]}}))}))},t}(),L=function(t){function e(e){var n,r,o,i=t.call(this)||this;return i.autoRefresh=!0,i.msRefreshBeforeExpires=3e4,i.staticToken="",i._transport=e.transport,i._storage=e.storage,i.autoRefresh=null!==(n=null==e?void 0:e.autoRefresh)&&void 0!==n?n:i.autoRefresh,i.mode=null!==(r=null==e?void 0:e.mode)&&void 0!==r?r:i.mode,i.msRefreshBeforeExpires=null!==(o=null==e?void 0:e.msRefreshBeforeExpires)&&void 0!==o?o:i.msRefreshBeforeExpires,(null==e?void 0:e.staticToken)&&(i.staticToken=null==e?void 0:e.staticToken,i.updateStorage({access_token:i.staticToken,expires:null,refresh_token:null})),i}return s(e,t),Object.defineProperty(e.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"token",{get:function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:if(!this._refreshPromise)return[3,4];t.label=1;case 1:return t.trys.push([1,,3,4]),[4,this._refreshPromise];case 2:return t.sent(),[3,4];case 3:return this._refreshPromise=void 0,[7];case 4:return[2,this._storage.auth_token]}}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"password",{get:function(){return this.passwords=this.passwords||new F(this._transport)},enumerable:!1,configurable:!0}),e.prototype.resetStorage=function(){this._storage.auth_token=null,this._storage.auth_refresh_token=null,this._storage.auth_expires=null,this._storage.auth_expires_at=null},e.prototype.updateStorage=function(t){var e,n,r=null!==(e=t.expires)&&void 0!==e?e:null;this._storage.auth_token=t.access_token,this._storage.auth_refresh_token=null!==(n=t.refresh_token)&&void 0!==n?n:null,this._storage.auth_expires=r,this._storage.auth_expires_at=(new Date).getTime()+(null!=r?r:0)},e.prototype.refreshIfExpired=function(){return c(this,void 0,void 0,(function(){return h(this,(function(t){switch(t.label){case 0:if(this.staticToken)return[2];if(!this.autoRefresh)return[2];if(this._storage.auth_expires_at)return[3,5];t.label=1;case 1:return t.trys.push([1,,3,4]),[4,this._refreshPromise];case 2:return t.sent(),[3,4];case 3:return this._refreshPromise=void 0,[7];case 4:return[2];case 5:this._storage.auth_expires_at<(new Date).getTime()+this.msRefreshBeforeExpires&&this.refresh(),t.label=6;case 6:return t.trys.push([6,,8,9]),[4,this._refreshPromise];case 7:return t.sent(),[3,9];case 8:return this._refreshPromise=void 0,[7];case 9:return[2]}}))}))},e.prototype.refresh=function(){var t=this;return this._refreshPromise=c(t,void 0,void 0,(function(){var t,e,n;return h(this,(function(r){switch(r.label){case 0:return t=this._storage.auth_refresh_token,this.resetStorage(),[4,this._transport.post("/auth/refresh",{refresh_token:"json"===this.mode?t:void 0})];case 1:return e=r.sent(),this.updateStorage(e.data),[2,a(a({access_token:e.data.access_token},(null===(n=e.data)||void 0===n?void 0:n.refresh_token)&&{refresh_token:e.data.refresh_token}),{expires:e.data.expires})]}}))}))},e.prototype.login=function(t){var e;return c(this,void 0,void 0,(function(){var n;return h(this,(function(r){switch(r.label){case 0:return this.resetStorage(),[4,this._transport.post("/auth/login",a({mode:this.mode},t),{headers:{Authorization:null}})];case 1:return n=r.sent(),this.updateStorage(n.data),[2,a(a({access_token:n.data.access_token},(null===(e=n.data)||void 0===e?void 0:e.refresh_token)&&{refresh_token:n.data.refresh_token}),{expires:n.data.expires})]}}))}))},e.prototype.static=function(t){return c(this,void 0,void 0,(function(){return h(this,(function(e){switch(e.label){case 0:return this.staticToken||(this.staticToken=t),[4,this._transport.get("/users/me",{params:{access_token:t},headers:{Authorization:null}})];case 1:return e.sent(),this.updateStorage({access_token:t,expires:null,refresh_token:null}),[2,!0]}}))}))},e.prototype.logout=function(){return c(this,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return"json"===this.mode&&(t=this._storage.auth_refresh_token||void 0),[4,this._transport.post("/auth/logout",{refresh_token:t})];case 1:return e.sent(),this.updateStorage({access_token:null,expires:null,refresh_token:null}),[2]}}))}))},e}(o),z=function(){function t(t){this.transport=t}return t.prototype.request=function(t,e,n){return c(this,void 0,void 0,(function(){return h(this,(function(r){switch(r.label){case 0:return[4,this.transport.post(t,{query:e,variables:void 0===n?{}:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.items=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql",t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.system=function(t,e){return c(this,void 0,void 0,(function(){return h(this,(function(n){switch(n.label){case 0:return[4,this.request("/graphql/system",t,e)];case 1:return[2,n.sent()]}}))}))},t}(),W=function(){function t(t,e){var n,r,i,s,u,l,p,f,d,v=this;if(this._url=t,this._options=e,this._items={},this._singletons={},(null===(n=this._options)||void 0===n?void 0:n.storage)&&(null===(r=this._options)||void 0===r?void 0:r.storage)instanceof A)this._storage=this._options.storage;else{var y=null===(i=this._options)||void 0===i?void 0:i.storage,b=null!=y?y:{},g=b.mode,_=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(b,["mode"]);"MemoryStorage"===g||"undefined"==typeof window?this._storage=new B(_):this._storage=new C(_)}(null===(s=this._options)||void 0===s?void 0:s.transport)&&(null===(u=this._options)||void 0===u?void 0:u.transport)instanceof U?this._transport=this._options.transport:this._transport=new D(a({url:this.url,beforeRequest:function(t){return c(v,void 0,void 0,(function(){var e,n;return h(this,(function(r){switch(r.label){case 0:return[4,this._auth.refreshIfExpired()];case 1:return r.sent(),e=this.storage.auth_token,n=e?e.startsWith("Bearer ")?String(this.storage.auth_token):"Bearer ".concat(this.storage.auth_token):"",[2,a(a({},t),{headers:a({Authorization:n},t.headers)})]}}))}))}},null===(l=this._options)||void 0===l?void 0:l.transport)),(null===(p=this._options)||void 0===p?void 0:p.auth)&&(null===(f=this._options)||void 0===f?void 0:f.auth)instanceof o?this._auth=this._options.auth:this._auth=new L(a({transport:this._transport,storage:this._storage},null===(d=this._options)||void 0===d?void 0:d.auth))}return Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"auth",{get:function(){return this._auth},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"storage",{get:function(){return this._storage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transport",{get:function(){return this._transport},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"activity",{get:function(){return this._activity||(this._activity=new v(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collections",{get:function(){return this._collections||(this._collections=new y(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fields",{get:function(){return this._fields||(this._fields=new b(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"files",{get:function(){return this._files||(this._files=new g(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"folders",{get:function(){return this._folders||(this._folders=new _(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"permissions",{get:function(){return this._permissions||(this._permissions=new w(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"presets",{get:function(){return this._presets||(this._presets=new m(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"relations",{get:function(){return this._relations||(this._relations=new O(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"revisions",{get:function(){return this._revisions||(this._revisions=new k(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roles",{get:function(){return this._roles||(this._roles=new P(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"users",{get:function(){return this._users||(this._users=new E(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"settings",{get:function(){return this._settings||(this._settings=new q(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"server",{get:function(){return this._server||(this._server=new x(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"utils",{get:function(){return this._utils||(this._utils=new I(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"graphql",{get:function(){return this._graphql||(this._graphql=new z(this.transport))},enumerable:!1,configurable:!0}),t.prototype.singleton=function(t){return this._singletons[t]||(this._singletons[t]=new j(t,this.transport))},t.prototype.items=function(t){return this._items[t]||(this._items[t]=new f(t,this.transport))},t}();return t.ActivityHandler=v,t.Auth=L,t.BaseStorage=M,t.CollectionsHandler=y,t.CommentsHandler=d,t.Directus=W,t.EmptyParamError=p,t.FieldsHandler=b,t.FilesHandler=g,t.FoldersHandler=_,t.IAuth=o,t.IStorage=A,t.ITransport=U,t.ItemsHandler=f,t.LocalStorage=C,t.MemoryStorage=B,t.PermissionsHandler=w,t.PresetsHandler=m,t.RelationsHandler=O,t.RevisionsHandler=k,t.RolesHandler=P,t.ServerHandler=x,t.SettingsHandler=q,t.Transport=D,t.TransportError=H,t.UsersHandler=E,t.UtilsHandler=I,Object.defineProperty(t,"__esModule",{value:!0}),t}({},axios); | ||
//# sourceMappingURL=sdk.global.min.js.map |
{ | ||
"name": "@directus/sdk", | ||
"version": "9.14.2", | ||
"version": "10.0.0", | ||
"description": "The official Directus SDK for use in JavaScript!", | ||
@@ -5,0 +5,0 @@ "repository": "directus/sdk", |
@@ -9,3 +9,3 @@ # Directus JS SDK | ||
## Usage | ||
## Basic Usage | ||
@@ -34,4 +34,30 @@ ```js | ||
## Docs | ||
## Reference | ||
See [the docs](https://docs.directus.io/reference/sdk/) | ||
See [the docs](https://docs.directus.io/reference/sdk/) for a full usage reference and all supported methods. | ||
## Contributing | ||
### Requirements | ||
- NodeJS LTS | ||
- pnpm 7.5.0 or newer | ||
### Commands | ||
The following `pnpm` scripts are available: | ||
- `pnpm lint` – Lint the code using Eslint / Prettier | ||
- `pnpm test` – Run the unit tests | ||
Make sure that both commands pass locally before creating a Pull Request. | ||
### Pushing a Release | ||
_This applies to maintainers only_ | ||
1. Create a new version / tag by running `pnpm version <version>`. Tip: use `pnpm version patch|minor|major` to | ||
auto-bump the version number | ||
1. Push the version commit / tag to GitHub (`git push && git push --tags`) | ||
The CI will automatically build and release to npm, and generate the release notes. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
281308
2929
62