@directus/sdk
Advanced tools
Comparing version 10.2.0 to 10.3.0
@@ -507,2 +507,4 @@ import { ResponseType, AxiosRequestConfig } from 'axios'; | ||
onUploadProgress?: ((progressEvent: any) => void) | undefined; | ||
maxBodyLength?: number; | ||
maxContentLength?: number; | ||
}; | ||
@@ -509,0 +511,0 @@ declare type TransportOptions = TransportRequestOptions & { |
@@ -671,2 +671,4 @@ import axios from 'axios'; | ||
onUploadProgress: this.config.onUploadProgress, | ||
maxBodyLength: this.config.maxBodyLength, | ||
maxContentLength: this.config.maxContentLength, | ||
withCredentials: true, | ||
@@ -673,0 +675,0 @@ }); |
@@ -679,2 +679,4 @@ 'use strict'; | ||
onUploadProgress: this.config.onUploadProgress, | ||
maxBodyLength: this.config.maxBodyLength, | ||
maxContentLength: this.config.maxContentLength, | ||
withCredentials: true, | ||
@@ -681,0 +683,0 @@ }); |
@@ -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:i,meta:o}=await this.transport.get(`${this.endpoint}`,{params:{...e,filter:{[n.field]:{_in:t},...null==e?void 0:e.filter},sort:(null==e?void 0:e.sort)||n.field},...null==r?void 0:r.requestOptions});return{data:i,...o&&{meta:o}}}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 updateBatch(t,e,r){return await this.transport.patch(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.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 i{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 o extends n{constructor(t){super("directus_activity",t),this._comments=new i(this.transport)}get comments(){return this._comments}}class a{constructor(t){this.transport=t}async readOne(t){if(""==`${t}`)throw new s("id");return(await this.transport.get(`/assets/${t}`,{responseType:"stream"})).raw}}class u{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 c{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{data:(await this.transport.get(`/fields/${t}`)).data,meta:void 0}}async readAll(){return{data:(await this.transport.get("/fields")).data,meta:void 0}}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 h extends n{constructor(t){super("directus_files",t)}async import(t){return(await this.transport.post("/files/import",t)).data}}class l extends n{constructor(t){super("directus_folders",t)}}class p extends n{constructor(t){super("directus_permissions",t)}}class d extends n{constructor(t){super("directus_presets",t)}}class f{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}`,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 v 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}async oas(){return(await this.transport.get("/server/specs/oas")).raw}}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 _ 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 E{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 O{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new E(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 R 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 O(this.transport))}}class b{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 x{}class k{}class T 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,T.prototype)}}!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(r||(r={}));class A extends x{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 S extends A{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 $ extends A{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}`}}function j(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var q,P={exports:{}},U={exports:{}},N=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)}},C=N,B=Object.prototype.toString,D=(q=Object.create(null),function(t){var e=B.call(t);return q[e]||(q[e]=e.slice(8,-1).toLowerCase())});function L(t){return t=t.toLowerCase(),function(e){return D(e)===t}}function I(t){return Array.isArray(t)}function F(t){return void 0===t}var M=L("ArrayBuffer");function J(t){return null!==t&&"object"==typeof t}function W(t){if("object"!==D(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}var z=L("Date"),H=L("File"),V=L("Blob"),Q=L("FileList");function X(t){return"[object Function]"===B.call(t)}var K=L("URLSearchParams");function G(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),I(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 Y,Z=(Y="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(t){return Y&&t instanceof Y}),tt={isArray:I,isArrayBuffer:M,isBuffer:function(t){return null!==t&&!F(t)&&null!==t.constructor&&!F(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){var e="[object FormData]";return t&&("function"==typeof FormData&&t instanceof FormData||B.call(t)===e||X(t.toString)&&t.toString()===e)},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&M(t.buffer)},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:J,isPlainObject:W,isUndefined:F,isDate:z,isFile:H,isBlob:V,isFunction:X,isStream:function(t){return J(t)&&X(t.pipe)},isURLSearchParams:K,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:G,merge:function t(){var e={};function r(r,s){W(e[s])&&W(r)?e[s]=t(e[s],r):W(r)?e[s]=t({},r):I(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)G(arguments[s],r);return e},extend:function(t,e,r){return G(e,(function(e,s){t[s]=r&&"function"==typeof e?C(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},inherits:function(t,e,r,s){t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,r&&Object.assign(t.prototype,r)},toFlatObject:function(t,e,r){var s,n,i,o={};e=e||{};do{for(n=(s=Object.getOwnPropertyNames(t)).length;n-- >0;)o[i=s[n]]||(e[i]=t[i],o[i]=!0);t=Object.getPrototypeOf(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:D,kindOfTest:L,endsWith:function(t,e,r){t=String(t),(void 0===r||r>t.length)&&(r=t.length),r-=e.length;var s=t.indexOf(e,r);return-1!==s&&s===r},toArray:function(t){if(!t)return null;var e=t.length;if(F(e))return null;for(var r=new Array(e);e-- >0;)r[e]=t[e];return r},isTypedArray:Z,isFileList:Q},et=tt;function rt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var st=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(et.isURLSearchParams(e))s=e.toString();else{var n=[];et.forEach(e,(function(t,e){null!=t&&(et.isArray(t)?e+="[]":t=[t],et.forEach(t,(function(t){et.isDate(t)?t=t.toISOString():et.isObject(t)&&(t=JSON.stringify(t)),n.push(rt(e)+"="+rt(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},nt=tt;function it(){this.handlers=[]}it.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},it.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},it.prototype.forEach=function(t){nt.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var ot,at,ut=it,ct=tt;function ht(){if(at)return ot;at=1;var t=tt;function e(t,e,r,s,n){Error.call(this),this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),s&&(this.request=s),n&&(this.response=n)}t.inherits(e,Error,{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}}});var r=e.prototype,s={};return["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(t){s[t]={value:t}})),Object.defineProperties(e,s),Object.defineProperty(r,"isAxiosError",{value:!0}),e.from=function(s,n,i,o,a,u){var c=Object.create(r);return t.toFlatObject(s,c,(function(t){return t!==Error.prototype})),e.call(c,s.message,n,i,o,a),c.name=s.name,u&&Object.assign(c,u),c},ot=e}var lt,pt,dt,ft,vt,mt,gt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function wt(){if(pt)return lt;pt=1;var t=tt;return lt=function(e,r){r=r||new FormData;var s=[];function n(e){return null===e?"":t.isDate(e)?e.toISOString():t.isArrayBuffer(e)||t.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}return function e(i,o){if(t.isPlainObject(i)||t.isArray(i)){if(-1!==s.indexOf(i))throw Error("Circular reference detected in "+o);s.push(i),t.forEach(i,(function(s,i){if(!t.isUndefined(s)){var a,u=o?o+"."+i:i;if(s&&!o&&"object"==typeof s)if(t.endsWith(i,"{}"))s=JSON.stringify(s);else if(t.endsWith(i,"[]")&&(a=t.toArray(s)))return void a.forEach((function(e){!t.isUndefined(e)&&r.append(u,n(e))}));e(s,u)}})),s.pop()}else r.append(o,n(i))}(e),r},lt}function _t(){if(ft)return dt;ft=1;var t=ht();return dt=function(e,r,s){var n=s.config.validateStatus;s.status&&n&&!n(s.status)?r(new t("Request failed with status code "+s.status,[t.ERR_BAD_REQUEST,t.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):e(s)}}function yt(){if(mt)return vt;mt=1;var t=tt;return vt=t.isStandardBrowserEnv()?{write:function(e,r,s,n,i,o){var a=[];a.push(e+"="+encodeURIComponent(r)),t.isNumber(s)&&a.push("expires="+new Date(s).toGMTString()),t.isString(n)&&a.push("path="+n),t.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.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(){}}}var Et,Ot,Rt,bt,xt,kt,Tt,At,St,$t,jt,qt,Pt=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},Ut=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Nt=function(t,e){return t&&!Pt(e)?Ut(t,e):e};function Ct(){if(Ot)return Et;Ot=1;var t=tt,e=["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"];return Et=function(r){var s,n,i,o={};return r?(t.forEach(r.split("\n"),(function(r){if(i=r.indexOf(":"),s=t.trim(r.substr(0,i)).toLowerCase(),n=t.trim(r.substr(i+1)),s){if(o[s]&&e.indexOf(s)>=0)return;o[s]="set-cookie"===s?(o[s]?o[s]:[]).concat([n]):o[s]?o[s]+", "+n:n}})),o):o}}function Bt(){if(bt)return Rt;bt=1;var t=tt;return Rt=t.isStandardBrowserEnv()?function(){var e,r=/(msie|trident)/i.test(navigator.userAgent),s=document.createElement("a");function n(t){var e=t;return r&&(s.setAttribute("href",e),e=s.href),s.setAttribute("href",e),{href:s.href,protocol:s.protocol?s.protocol.replace(/:$/,""):"",host:s.host,search:s.search?s.search.replace(/^\?/,""):"",hash:s.hash?s.hash.replace(/^#/,""):"",hostname:s.hostname,port:s.port,pathname:"/"===s.pathname.charAt(0)?s.pathname:"/"+s.pathname}}return e=n(window.location.href),function(r){var s=t.isString(r)?n(r):r;return s.protocol===e.protocol&&s.host===e.host}}():function(){return!0}}function Dt(){if(kt)return xt;kt=1;var t=ht();function e(e){t.call(this,null==e?"canceled":e,t.ERR_CANCELED),this.name="CanceledError"}return tt.inherits(e,t,{__CANCEL__:!0}),xt=e}function Lt(){return At?Tt:(At=1,Tt=function(t){var e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""})}function It(){if($t)return St;$t=1;var t=tt,e=_t(),r=yt(),s=st,n=Nt,i=Ct(),o=Bt(),a=gt,u=ht(),c=Dt(),h=Lt();return St=function(l){return new Promise((function(p,d){var f,v=l.data,m=l.headers,g=l.responseType;function w(){l.cancelToken&&l.cancelToken.unsubscribe(f),l.signal&&l.signal.removeEventListener("abort",f)}t.isFormData(v)&&t.isStandardBrowserEnv()&&delete m["Content-Type"];var _=new XMLHttpRequest;if(l.auth){var y=l.auth.username||"",E=l.auth.password?unescape(encodeURIComponent(l.auth.password)):"";m.Authorization="Basic "+btoa(y+":"+E)}var O=n(l.baseURL,l.url);function R(){if(_){var t="getAllResponseHeaders"in _?i(_.getAllResponseHeaders()):null,r={data:g&&"text"!==g&&"json"!==g?_.response:_.responseText,status:_.status,statusText:_.statusText,headers:t,config:l,request:_};e((function(t){p(t),w()}),(function(t){d(t),w()}),r),_=null}}if(_.open(l.method.toUpperCase(),s(O,l.params,l.paramsSerializer),!0),_.timeout=l.timeout,"onloadend"in _?_.onloadend=R:_.onreadystatechange=function(){_&&4===_.readyState&&(0!==_.status||_.responseURL&&0===_.responseURL.indexOf("file:"))&&setTimeout(R)},_.onabort=function(){_&&(d(new u("Request aborted",u.ECONNABORTED,l,_)),_=null)},_.onerror=function(){d(new u("Network Error",u.ERR_NETWORK,l,_,_)),_=null},_.ontimeout=function(){var t=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded",e=l.transitional||a;l.timeoutErrorMessage&&(t=l.timeoutErrorMessage),d(new u(t,e.clarifyTimeoutError?u.ETIMEDOUT:u.ECONNABORTED,l,_)),_=null},t.isStandardBrowserEnv()){var b=(l.withCredentials||o(O))&&l.xsrfCookieName?r.read(l.xsrfCookieName):void 0;b&&(m[l.xsrfHeaderName]=b)}"setRequestHeader"in _&&t.forEach(m,(function(t,e){void 0===v&&"content-type"===e.toLowerCase()?delete m[e]:_.setRequestHeader(e,t)})),t.isUndefined(l.withCredentials)||(_.withCredentials=!!l.withCredentials),g&&"json"!==g&&(_.responseType=l.responseType),"function"==typeof l.onDownloadProgress&&_.addEventListener("progress",l.onDownloadProgress),"function"==typeof l.onUploadProgress&&_.upload&&_.upload.addEventListener("progress",l.onUploadProgress),(l.cancelToken||l.signal)&&(f=function(t){_&&(d(!t||t&&t.type?new c:t),_.abort(),_=null)},l.cancelToken&&l.cancelToken.subscribe(f),l.signal&&(l.signal.aborted?f():l.signal.addEventListener("abort",f))),v||(v=null);var x=h(O);x&&-1===["http","https","file"].indexOf(x)?d(new u("Unsupported protocol "+x+":",u.ERR_BAD_REQUEST,l)):_.send(v)}))},St}var Ft=tt,Mt=function(t,e){ct.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},Jt=ht(),Wt=gt,zt=wt(),Ht={"Content-Type":"application/x-www-form-urlencoded"};function Vt(t,e){!Ft.isUndefined(t)&&Ft.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var Qt,Xt={transitional:Wt,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Qt=It()),Qt),transformRequest:[function(t,e){if(Mt(e,"Accept"),Mt(e,"Content-Type"),Ft.isFormData(t)||Ft.isArrayBuffer(t)||Ft.isBuffer(t)||Ft.isStream(t)||Ft.isFile(t)||Ft.isBlob(t))return t;if(Ft.isArrayBufferView(t))return t.buffer;if(Ft.isURLSearchParams(t))return Vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString();var r,s=Ft.isObject(t),n=e&&e["Content-Type"];if((r=Ft.isFileList(t))||s&&"multipart/form-data"===n){var i=this.env&&this.env.FormData;return zt(r?{"files[]":t}:t,i&&new i)}return s||"application/json"===n?(Vt(e,"application/json"),function(t,e,r){if(Ft.isString(t))try{return(e||JSON.parse)(t),Ft.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||Xt.transitional,r=e&&e.silentJSONParsing,s=e&&e.forcedJSONParsing,n=!r&&"json"===this.responseType;if(n||s&&Ft.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(n){if("SyntaxError"===t.name)throw Jt.from(t,Jt.ERR_BAD_RESPONSE,this,null,this.response);throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:qt?jt:(qt=1,jt=null)},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};Ft.forEach(["delete","get","head"],(function(t){Xt.headers[t]={}})),Ft.forEach(["post","put","patch"],(function(t){Xt.headers[t]=Ft.merge(Ht)}));var Kt,Gt,Yt=Xt,Zt=tt,te=Yt;function ee(){return Gt?Kt:(Gt=1,Kt=function(t){return!(!t||!t.__CANCEL__)})}var re=tt,se=function(t,e,r){var s=this||te;return Zt.forEach(r,(function(r){t=r.call(s,t,e)})),t},ne=ee(),ie=Yt,oe=Dt();function ae(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new oe}var ue,ce,he=tt,le=function(t,e){e=e||{};var r={};function s(t,e){return he.isPlainObject(t)&&he.isPlainObject(e)?he.merge(t,e):he.isPlainObject(e)?he.merge({},e):he.isArray(e)?e.slice():e}function n(r){return he.isUndefined(e[r])?he.isUndefined(t[r])?void 0:s(void 0,t[r]):s(t[r],e[r])}function i(t){if(!he.isUndefined(e[t]))return s(void 0,e[t])}function o(r){return he.isUndefined(e[r])?he.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:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a};return he.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||n,s=e(t);he.isUndefined(s)&&e!==a||(r[t]=s)})),r};function pe(){return ce?ue:(ce=1,ue={version:"0.27.2"})}var de=pe().version,fe=ht(),ve={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){ve[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var me={};ve.transitional=function(t,e,r){function s(t,e){return"[Axios v"+de+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,i){if(!1===t)throw new fe(s(n," has been removed"+(e?" in "+e:"")),fe.ERR_DEPRECATED);return e&&!me[n]&&(me[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,i)}};var ge,we,_e,ye,Ee,Oe,Re={assertOptions:function(t,e,r){if("object"!=typeof t)throw new fe("options must be an object",fe.ERR_BAD_OPTION_VALUE);for(var s=Object.keys(t),n=s.length;n-- >0;){var i=s[n],o=e[i];if(o){var a=t[i],u=void 0===a||o(a,i,t);if(!0!==u)throw new fe("option "+i+" must be "+u,fe.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new fe("Unknown option "+i,fe.ERR_BAD_OPTION)}},validators:ve},be=tt,xe=st,ke=ut,Te=function(t){return ae(t),t.headers=t.headers||{},t.data=se.call(t,t.data,t.headers,t.transformRequest),t.headers=re.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),re.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||ie.adapter)(t).then((function(e){return ae(t),e.data=se.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return ne(e)||(ae(t),e&&e.response&&(e.response.data=se.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Ae=le,Se=Nt,$e=Re,je=$e.validators;function qe(t){this.defaults=t,this.interceptors={request:new ke,response:new ke}}qe.prototype.request=function(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},(e=Ae(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;void 0!==r&&$e.assertOptions(r,{silentJSONParsing:je.transitional(je.boolean),forcedJSONParsing:je.transitional(je.boolean),clarifyTimeoutError:je.transitional(je.boolean)},!1);var s=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,s.unshift(t.fulfilled,t.rejected))}));var i,o=[];if(this.interceptors.response.forEach((function(t){o.push(t.fulfilled,t.rejected)})),!n){var a=[Te,void 0];for(Array.prototype.unshift.apply(a,s),a=a.concat(o),i=Promise.resolve(e);a.length;)i=i.then(a.shift(),a.shift());return i}for(var u=e;s.length;){var c=s.shift(),h=s.shift();try{u=c(u)}catch(t){h(t);break}}try{i=Te(u)}catch(t){return Promise.reject(t)}for(;o.length;)i=i.then(o.shift(),o.shift());return i},qe.prototype.getUri=function(t){t=Ae(this.defaults,t);var e=Se(t.baseURL,t.url);return xe(e,t.params,t.paramsSerializer)},be.forEach(["delete","get","head","options"],(function(t){qe.prototype[t]=function(e,r){return this.request(Ae(r||{},{method:t,url:e,data:(r||{}).data}))}})),be.forEach(["post","put","patch"],(function(t){function e(e){return function(r,s,n){return this.request(Ae(n||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}qe.prototype[t]=e(),qe.prototype[t+"Form"]=e(!0)}));var Pe=tt,Ue=N,Ne=qe,Ce=le;var Be=function t(e){var r=new Ne(e),s=Ue(Ne.prototype.request,r);return Pe.extend(s,Ne.prototype,r),Pe.extend(s,r),s.create=function(r){return t(Ce(e,r))},s}(Yt);Be.Axios=Ne,Be.CanceledError=Dt(),Be.CancelToken=function(){if(we)return ge;we=1;var t=Dt();function e(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(t){r=t}));var s=this;this.promise.then((function(t){if(s._listeners){var e,r=s._listeners.length;for(e=0;e<r;e++)s._listeners[e](t);s._listeners=null}})),this.promise.then=function(t){var e,r=new Promise((function(t){s.subscribe(t),e=t})).then(t);return r.cancel=function(){s.unsubscribe(e)},r},e((function(e){s.reason||(s.reason=new t(e),r(s.reason))}))}return e.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},e.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},e.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},e.source=function(){var t;return{token:new e((function(e){t=e})),cancel:t}},ge=e}(),Be.isCancel=ee(),Be.VERSION=pe().version,Be.toFormData=wt(),Be.AxiosError=ht(),Be.Cancel=Be.CanceledError,Be.all=function(t){return Promise.all(t)},Be.spread=ye?_e:(ye=1,_e=function(t){return function(e){return t.apply(null,e)}}),Be.isAxiosError=function(){if(Oe)return Ee;Oe=1;var t=tt;return Ee=function(e){return t.isObject(e)&&!0===e.isAxiosError}}(),U.exports=Be,U.exports.default=Be;var De=j(P.exports=U.exports);class Le extends k{constructor(t){var e;super(),this.config=t,this.axios=De.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,i,o,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,responseType:null==s?void 0:s.responseType,onUploadProgress:null==s?void 0:s.onUploadProgress};n=await this.beforeRequest(n);const i=await this.axios.request(n),o={raw:i.data,status:i.status,statusText:i.statusText,headers:i.headers,data:i.data.data,meta:i.data.meta,errors:i.data.errors};if(i.data.errors)throw new T(null,o);return o}catch(t){if(!t||t instanceof Error==!1)throw t;if(De.isAxiosError(t)){const e=null===(n=t.response)||void 0===n?void 0:n.data;throw new T(t,{raw:null===(i=t.response)||void 0===i?void 0:i.data,status:null===(o=t.response)||void 0===o?void 0:o.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(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 Ie{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 Fe 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 Ie(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 Me{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 Je{constructor(e,r){var s,n,i,o,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 x)this._storage=this._options.storage;else{const t=null===(i=this._options)||void 0===i?void 0:i.storage,{mode:e,...r}=null!=t?t:{};"MemoryStorage"===e||"undefined"==typeof window?this._storage=new S(r):this._storage=new $(r)}(null===(o=this._options)||void 0===o?void 0:o.transport)&&(null===(a=this._options)||void 0===a?void 0:a.transport)instanceof k?this._transport=this._options.transport:this._transport=new Le({url:this.url,...null===(u=this._options)||void 0===u?void 0:u.transport,beforeRequest:async t=>{var e,r,s,n,i;await this._auth.refreshIfExpired();const o=this.storage.auth_token,a=o?o.startsWith("Bearer ")?String(this.storage.auth_token):`Bearer ${this.storage.auth_token}`:"",u={...t,headers:{Authorization:a,...t.headers}};return(null===(e=this._options)||void 0===e?void 0:e.transport)instanceof k||!(null===(s=null===(r=this._options)||void 0===r?void 0:r.transport)||void 0===s?void 0:s.beforeRequest)?u:null===(i=null===(n=this._options)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.beforeRequest(u)}}),(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 Fe({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 assets(){return this._assets||(this._assets=new a(this.transport))}get activity(){return this._activity||(this._activity=new o(this.transport))}get collections(){return this._collections||(this._collections=new u(this.transport))}get fields(){return this._fields||(this._fields=new c(this.transport))}get files(){return this._files||(this._files=new h(this.transport))}get folders(){return this._folders||(this._folders=new l(this.transport))}get permissions(){return this._permissions||(this._permissions=new p(this.transport))}get presets(){return this._presets||(this._presets=new d(this.transport))}get relations(){return this._relations||(this._relations=new f(this.transport))}get revisions(){return this._revisions||(this._revisions=new v(this.transport))}get roles(){return this._roles||(this._roles=new m(this.transport))}get users(){return this._users||(this._users=new R(this.transport))}get settings(){return this._settings||(this._settings=new _(this.transport))}get server(){return this._server||(this._server=new g(this.transport))}get utils(){return this._utils||(this._utils=new b(this.transport))}get graphql(){return this._graphql||(this._graphql=new Me(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{o as ActivityHandler,a as AssetsHandler,Fe as Auth,A as BaseStorage,u as CollectionsHandler,i as CommentsHandler,Je as Directus,s as EmptyParamError,c as FieldsHandler,h as FilesHandler,l as FoldersHandler,t as IAuth,x as IStorage,k as ITransport,n as ItemsHandler,$ as LocalStorage,S as MemoryStorage,e as Meta,p as PermissionsHandler,d as PresetsHandler,f as RelationsHandler,v as RevisionsHandler,m as RolesHandler,g as ServerHandler,_ as SettingsHandler,Le as Transport,T as TransportError,R as UsersHandler,b 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:i,meta:o}=await this.transport.get(`${this.endpoint}`,{params:{...e,filter:{[n.field]:{_in:t},...null==e?void 0:e.filter},sort:(null==e?void 0:e.sort)||n.field},...null==r?void 0:r.requestOptions});return{data:i,...o&&{meta:o}}}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 updateBatch(t,e,r){return await this.transport.patch(`${this.endpoint}`,t,{params:e,...null==r?void 0:r.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 i{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 o extends n{constructor(t){super("directus_activity",t),this._comments=new i(this.transport)}get comments(){return this._comments}}class a{constructor(t){this.transport=t}async readOne(t){if(""==`${t}`)throw new s("id");return(await this.transport.get(`/assets/${t}`,{responseType:"stream"})).raw}}class u{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 c{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{data:(await this.transport.get(`/fields/${t}`)).data,meta:void 0}}async readAll(){return{data:(await this.transport.get("/fields")).data,meta:void 0}}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 h extends n{constructor(t){super("directus_files",t)}async import(t){return(await this.transport.post("/files/import",t)).data}}class l extends n{constructor(t){super("directus_folders",t)}}class p extends n{constructor(t){super("directus_permissions",t)}}class d extends n{constructor(t){super("directus_presets",t)}}class f{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}`,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 v 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}async oas(){return(await this.transport.get("/server/specs/oas")).raw}}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 y extends w{constructor(t){super("directus_settings",t)}}class _{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 E{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 O{constructor(t){this._transport=t}get tfa(){return this._tfa||(this._tfa=new E(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 x extends n{constructor(t){super("directus_users",t)}get invites(){return this._invites||(this._invites=new _(this.transport))}get me(){return this._me||(this._me=new O(this.transport))}}class R{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 b{}class k{}class T 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,T.prototype)}}!function(t){t.AuthToken="auth_token",t.RefreshToken="auth_refresh_token",t.Expires="auth_expires",t.ExpiresAt="auth_expires_at"}(r||(r={}));class A extends b{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 S extends A{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 $ extends A{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}`}}function j(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var q,P={exports:{}},C={exports:{}},U=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)}},N=U,B=Object.prototype.toString,D=(q=Object.create(null),function(t){var e=B.call(t);return q[e]||(q[e]=e.slice(8,-1).toLowerCase())});function L(t){return t=t.toLowerCase(),function(e){return D(e)===t}}function I(t){return Array.isArray(t)}function F(t){return void 0===t}var M=L("ArrayBuffer");function J(t){return null!==t&&"object"==typeof t}function W(t){if("object"!==D(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}var z=L("Date"),H=L("File"),V=L("Blob"),Q=L("FileList");function X(t){return"[object Function]"===B.call(t)}var K=L("URLSearchParams");function G(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),I(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 Y,Z=(Y="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(t){return Y&&t instanceof Y}),tt={isArray:I,isArrayBuffer:M,isBuffer:function(t){return null!==t&&!F(t)&&null!==t.constructor&&!F(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){var e="[object FormData]";return t&&("function"==typeof FormData&&t instanceof FormData||B.call(t)===e||X(t.toString)&&t.toString()===e)},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&M(t.buffer)},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:J,isPlainObject:W,isUndefined:F,isDate:z,isFile:H,isBlob:V,isFunction:X,isStream:function(t){return J(t)&&X(t.pipe)},isURLSearchParams:K,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:G,merge:function t(){var e={};function r(r,s){W(e[s])&&W(r)?e[s]=t(e[s],r):W(r)?e[s]=t({},r):I(r)?e[s]=r.slice():e[s]=r}for(var s=0,n=arguments.length;s<n;s++)G(arguments[s],r);return e},extend:function(t,e,r){return G(e,(function(e,s){t[s]=r&&"function"==typeof e?N(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},inherits:function(t,e,r,s){t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,r&&Object.assign(t.prototype,r)},toFlatObject:function(t,e,r){var s,n,i,o={};e=e||{};do{for(n=(s=Object.getOwnPropertyNames(t)).length;n-- >0;)o[i=s[n]]||(e[i]=t[i],o[i]=!0);t=Object.getPrototypeOf(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},kindOf:D,kindOfTest:L,endsWith:function(t,e,r){t=String(t),(void 0===r||r>t.length)&&(r=t.length),r-=e.length;var s=t.indexOf(e,r);return-1!==s&&s===r},toArray:function(t){if(!t)return null;var e=t.length;if(F(e))return null;for(var r=new Array(e);e-- >0;)r[e]=t[e];return r},isTypedArray:Z,isFileList:Q},et=tt;function rt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var st=function(t,e,r){if(!e)return t;var s;if(r)s=r(e);else if(et.isURLSearchParams(e))s=e.toString();else{var n=[];et.forEach(e,(function(t,e){null!=t&&(et.isArray(t)?e+="[]":t=[t],et.forEach(t,(function(t){et.isDate(t)?t=t.toISOString():et.isObject(t)&&(t=JSON.stringify(t)),n.push(rt(e)+"="+rt(t))})))})),s=n.join("&")}if(s){var i=t.indexOf("#");-1!==i&&(t=t.slice(0,i)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t},nt=tt;function it(){this.handlers=[]}it.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},it.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},it.prototype.forEach=function(t){nt.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var ot,at,ut=it,ct=tt;function ht(){if(at)return ot;at=1;var t=tt;function e(t,e,r,s,n){Error.call(this),this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),s&&(this.request=s),n&&(this.response=n)}t.inherits(e,Error,{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}}});var r=e.prototype,s={};return["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(t){s[t]={value:t}})),Object.defineProperties(e,s),Object.defineProperty(r,"isAxiosError",{value:!0}),e.from=function(s,n,i,o,a,u){var c=Object.create(r);return t.toFlatObject(s,c,(function(t){return t!==Error.prototype})),e.call(c,s.message,n,i,o,a),c.name=s.name,u&&Object.assign(c,u),c},ot=e}var lt,pt,dt,ft,vt,mt,gt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};function wt(){if(pt)return lt;pt=1;var t=tt;return lt=function(e,r){r=r||new FormData;var s=[];function n(e){return null===e?"":t.isDate(e)?e.toISOString():t.isArrayBuffer(e)||t.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}return function e(i,o){if(t.isPlainObject(i)||t.isArray(i)){if(-1!==s.indexOf(i))throw Error("Circular reference detected in "+o);s.push(i),t.forEach(i,(function(s,i){if(!t.isUndefined(s)){var a,u=o?o+"."+i:i;if(s&&!o&&"object"==typeof s)if(t.endsWith(i,"{}"))s=JSON.stringify(s);else if(t.endsWith(i,"[]")&&(a=t.toArray(s)))return void a.forEach((function(e){!t.isUndefined(e)&&r.append(u,n(e))}));e(s,u)}})),s.pop()}else r.append(o,n(i))}(e),r},lt}function yt(){if(ft)return dt;ft=1;var t=ht();return dt=function(e,r,s){var n=s.config.validateStatus;s.status&&n&&!n(s.status)?r(new t("Request failed with status code "+s.status,[t.ERR_BAD_REQUEST,t.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):e(s)}}function _t(){if(mt)return vt;mt=1;var t=tt;return vt=t.isStandardBrowserEnv()?{write:function(e,r,s,n,i,o){var a=[];a.push(e+"="+encodeURIComponent(r)),t.isNumber(s)&&a.push("expires="+new Date(s).toGMTString()),t.isString(n)&&a.push("path="+n),t.isString(i)&&a.push("domain="+i),!0===o&&a.push("secure"),document.cookie=a.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(){}}}var Et,Ot,xt,Rt,bt,kt,Tt,At,St,$t,jt,qt,Pt=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},Ct=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t},Ut=function(t,e){return t&&!Pt(e)?Ct(t,e):e};function Nt(){if(Ot)return Et;Ot=1;var t=tt,e=["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"];return Et=function(r){var s,n,i,o={};return r?(t.forEach(r.split("\n"),(function(r){if(i=r.indexOf(":"),s=t.trim(r.substr(0,i)).toLowerCase(),n=t.trim(r.substr(i+1)),s){if(o[s]&&e.indexOf(s)>=0)return;o[s]="set-cookie"===s?(o[s]?o[s]:[]).concat([n]):o[s]?o[s]+", "+n:n}})),o):o}}function Bt(){if(Rt)return xt;Rt=1;var t=tt;return xt=t.isStandardBrowserEnv()?function(){var e,r=/(msie|trident)/i.test(navigator.userAgent),s=document.createElement("a");function n(t){var e=t;return r&&(s.setAttribute("href",e),e=s.href),s.setAttribute("href",e),{href:s.href,protocol:s.protocol?s.protocol.replace(/:$/,""):"",host:s.host,search:s.search?s.search.replace(/^\?/,""):"",hash:s.hash?s.hash.replace(/^#/,""):"",hostname:s.hostname,port:s.port,pathname:"/"===s.pathname.charAt(0)?s.pathname:"/"+s.pathname}}return e=n(window.location.href),function(r){var s=t.isString(r)?n(r):r;return s.protocol===e.protocol&&s.host===e.host}}():function(){return!0}}function Dt(){if(kt)return bt;kt=1;var t=ht();function e(e){t.call(this,null==e?"canceled":e,t.ERR_CANCELED),this.name="CanceledError"}return tt.inherits(e,t,{__CANCEL__:!0}),bt=e}function Lt(){return At?Tt:(At=1,Tt=function(t){var e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""})}function It(){if($t)return St;$t=1;var t=tt,e=yt(),r=_t(),s=st,n=Ut,i=Nt(),o=Bt(),a=gt,u=ht(),c=Dt(),h=Lt();return St=function(l){return new Promise((function(p,d){var f,v=l.data,m=l.headers,g=l.responseType;function w(){l.cancelToken&&l.cancelToken.unsubscribe(f),l.signal&&l.signal.removeEventListener("abort",f)}t.isFormData(v)&&t.isStandardBrowserEnv()&&delete m["Content-Type"];var y=new XMLHttpRequest;if(l.auth){var _=l.auth.username||"",E=l.auth.password?unescape(encodeURIComponent(l.auth.password)):"";m.Authorization="Basic "+btoa(_+":"+E)}var O=n(l.baseURL,l.url);function x(){if(y){var t="getAllResponseHeaders"in y?i(y.getAllResponseHeaders()):null,r={data:g&&"text"!==g&&"json"!==g?y.response:y.responseText,status:y.status,statusText:y.statusText,headers:t,config:l,request:y};e((function(t){p(t),w()}),(function(t){d(t),w()}),r),y=null}}if(y.open(l.method.toUpperCase(),s(O,l.params,l.paramsSerializer),!0),y.timeout=l.timeout,"onloadend"in y?y.onloadend=x:y.onreadystatechange=function(){y&&4===y.readyState&&(0!==y.status||y.responseURL&&0===y.responseURL.indexOf("file:"))&&setTimeout(x)},y.onabort=function(){y&&(d(new u("Request aborted",u.ECONNABORTED,l,y)),y=null)},y.onerror=function(){d(new u("Network Error",u.ERR_NETWORK,l,y,y)),y=null},y.ontimeout=function(){var t=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded",e=l.transitional||a;l.timeoutErrorMessage&&(t=l.timeoutErrorMessage),d(new u(t,e.clarifyTimeoutError?u.ETIMEDOUT:u.ECONNABORTED,l,y)),y=null},t.isStandardBrowserEnv()){var R=(l.withCredentials||o(O))&&l.xsrfCookieName?r.read(l.xsrfCookieName):void 0;R&&(m[l.xsrfHeaderName]=R)}"setRequestHeader"in y&&t.forEach(m,(function(t,e){void 0===v&&"content-type"===e.toLowerCase()?delete m[e]:y.setRequestHeader(e,t)})),t.isUndefined(l.withCredentials)||(y.withCredentials=!!l.withCredentials),g&&"json"!==g&&(y.responseType=l.responseType),"function"==typeof l.onDownloadProgress&&y.addEventListener("progress",l.onDownloadProgress),"function"==typeof l.onUploadProgress&&y.upload&&y.upload.addEventListener("progress",l.onUploadProgress),(l.cancelToken||l.signal)&&(f=function(t){y&&(d(!t||t&&t.type?new c:t),y.abort(),y=null)},l.cancelToken&&l.cancelToken.subscribe(f),l.signal&&(l.signal.aborted?f():l.signal.addEventListener("abort",f))),v||(v=null);var b=h(O);b&&-1===["http","https","file"].indexOf(b)?d(new u("Unsupported protocol "+b+":",u.ERR_BAD_REQUEST,l)):y.send(v)}))},St}var Ft=tt,Mt=function(t,e){ct.forEach(t,(function(r,s){s!==e&&s.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[s])}))},Jt=ht(),Wt=gt,zt=wt(),Ht={"Content-Type":"application/x-www-form-urlencoded"};function Vt(t,e){!Ft.isUndefined(t)&&Ft.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var Qt,Xt={transitional:Wt,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Qt=It()),Qt),transformRequest:[function(t,e){if(Mt(e,"Accept"),Mt(e,"Content-Type"),Ft.isFormData(t)||Ft.isArrayBuffer(t)||Ft.isBuffer(t)||Ft.isStream(t)||Ft.isFile(t)||Ft.isBlob(t))return t;if(Ft.isArrayBufferView(t))return t.buffer;if(Ft.isURLSearchParams(t))return Vt(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString();var r,s=Ft.isObject(t),n=e&&e["Content-Type"];if((r=Ft.isFileList(t))||s&&"multipart/form-data"===n){var i=this.env&&this.env.FormData;return zt(r?{"files[]":t}:t,i&&new i)}return s||"application/json"===n?(Vt(e,"application/json"),function(t,e,r){if(Ft.isString(t))try{return(e||JSON.parse)(t),Ft.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||Xt.transitional,r=e&&e.silentJSONParsing,s=e&&e.forcedJSONParsing,n=!r&&"json"===this.responseType;if(n||s&&Ft.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(n){if("SyntaxError"===t.name)throw Jt.from(t,Jt.ERR_BAD_RESPONSE,this,null,this.response);throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:qt?jt:(qt=1,jt=null)},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};Ft.forEach(["delete","get","head"],(function(t){Xt.headers[t]={}})),Ft.forEach(["post","put","patch"],(function(t){Xt.headers[t]=Ft.merge(Ht)}));var Kt,Gt,Yt=Xt,Zt=tt,te=Yt;function ee(){return Gt?Kt:(Gt=1,Kt=function(t){return!(!t||!t.__CANCEL__)})}var re=tt,se=function(t,e,r){var s=this||te;return Zt.forEach(r,(function(r){t=r.call(s,t,e)})),t},ne=ee(),ie=Yt,oe=Dt();function ae(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new oe}var ue,ce,he=tt,le=function(t,e){e=e||{};var r={};function s(t,e){return he.isPlainObject(t)&&he.isPlainObject(e)?he.merge(t,e):he.isPlainObject(e)?he.merge({},e):he.isArray(e)?e.slice():e}function n(r){return he.isUndefined(e[r])?he.isUndefined(t[r])?void 0:s(void 0,t[r]):s(t[r],e[r])}function i(t){if(!he.isUndefined(e[t]))return s(void 0,e[t])}function o(r){return he.isUndefined(e[r])?he.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:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a};return he.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||n,s=e(t);he.isUndefined(s)&&e!==a||(r[t]=s)})),r};function pe(){return ce?ue:(ce=1,ue={version:"0.27.2"})}var de=pe().version,fe=ht(),ve={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){ve[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var me={};ve.transitional=function(t,e,r){function s(t,e){return"[Axios v"+de+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,i){if(!1===t)throw new fe(s(n," has been removed"+(e?" in "+e:"")),fe.ERR_DEPRECATED);return e&&!me[n]&&(me[n]=!0,console.warn(s(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,i)}};var ge,we,ye,_e,Ee,Oe,xe={assertOptions:function(t,e,r){if("object"!=typeof t)throw new fe("options must be an object",fe.ERR_BAD_OPTION_VALUE);for(var s=Object.keys(t),n=s.length;n-- >0;){var i=s[n],o=e[i];if(o){var a=t[i],u=void 0===a||o(a,i,t);if(!0!==u)throw new fe("option "+i+" must be "+u,fe.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new fe("Unknown option "+i,fe.ERR_BAD_OPTION)}},validators:ve},Re=tt,be=st,ke=ut,Te=function(t){return ae(t),t.headers=t.headers||{},t.data=se.call(t,t.data,t.headers,t.transformRequest),t.headers=re.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),re.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||ie.adapter)(t).then((function(e){return ae(t),e.data=se.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return ne(e)||(ae(t),e&&e.response&&(e.response.data=se.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},Ae=le,Se=Ut,$e=xe,je=$e.validators;function qe(t){this.defaults=t,this.interceptors={request:new ke,response:new ke}}qe.prototype.request=function(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},(e=Ae(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;void 0!==r&&$e.assertOptions(r,{silentJSONParsing:je.transitional(je.boolean),forcedJSONParsing:je.transitional(je.boolean),clarifyTimeoutError:je.transitional(je.boolean)},!1);var s=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,s.unshift(t.fulfilled,t.rejected))}));var i,o=[];if(this.interceptors.response.forEach((function(t){o.push(t.fulfilled,t.rejected)})),!n){var a=[Te,void 0];for(Array.prototype.unshift.apply(a,s),a=a.concat(o),i=Promise.resolve(e);a.length;)i=i.then(a.shift(),a.shift());return i}for(var u=e;s.length;){var c=s.shift(),h=s.shift();try{u=c(u)}catch(t){h(t);break}}try{i=Te(u)}catch(t){return Promise.reject(t)}for(;o.length;)i=i.then(o.shift(),o.shift());return i},qe.prototype.getUri=function(t){t=Ae(this.defaults,t);var e=Se(t.baseURL,t.url);return be(e,t.params,t.paramsSerializer)},Re.forEach(["delete","get","head","options"],(function(t){qe.prototype[t]=function(e,r){return this.request(Ae(r||{},{method:t,url:e,data:(r||{}).data}))}})),Re.forEach(["post","put","patch"],(function(t){function e(e){return function(r,s,n){return this.request(Ae(n||{},{method:t,headers:e?{"Content-Type":"multipart/form-data"}:{},url:r,data:s}))}}qe.prototype[t]=e(),qe.prototype[t+"Form"]=e(!0)}));var Pe=tt,Ce=U,Ue=qe,Ne=le;var Be=function t(e){var r=new Ue(e),s=Ce(Ue.prototype.request,r);return Pe.extend(s,Ue.prototype,r),Pe.extend(s,r),s.create=function(r){return t(Ne(e,r))},s}(Yt);Be.Axios=Ue,Be.CanceledError=Dt(),Be.CancelToken=function(){if(we)return ge;we=1;var t=Dt();function e(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var r;this.promise=new Promise((function(t){r=t}));var s=this;this.promise.then((function(t){if(s._listeners){var e,r=s._listeners.length;for(e=0;e<r;e++)s._listeners[e](t);s._listeners=null}})),this.promise.then=function(t){var e,r=new Promise((function(t){s.subscribe(t),e=t})).then(t);return r.cancel=function(){s.unsubscribe(e)},r},e((function(e){s.reason||(s.reason=new t(e),r(s.reason))}))}return e.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},e.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},e.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},e.source=function(){var t;return{token:new e((function(e){t=e})),cancel:t}},ge=e}(),Be.isCancel=ee(),Be.VERSION=pe().version,Be.toFormData=wt(),Be.AxiosError=ht(),Be.Cancel=Be.CanceledError,Be.all=function(t){return Promise.all(t)},Be.spread=_e?ye:(_e=1,ye=function(t){return function(e){return t.apply(null,e)}}),Be.isAxiosError=function(){if(Oe)return Ee;Oe=1;var t=tt;return Ee=function(e){return t.isObject(e)&&!0===e.isAxiosError}}(),C.exports=Be,C.exports.default=Be;var De=j(P.exports=C.exports);class Le extends k{constructor(t){var e;super(),this.config=t,this.axios=De.create({baseURL:this.config.url,params:this.config.params,headers:this.config.headers,onUploadProgress:this.config.onUploadProgress,maxBodyLength:this.config.maxBodyLength,maxContentLength:this.config.maxContentLength,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,i,o,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,responseType:null==s?void 0:s.responseType,onUploadProgress:null==s?void 0:s.onUploadProgress};n=await this.beforeRequest(n);const i=await this.axios.request(n),o={raw:i.data,status:i.status,statusText:i.statusText,headers:i.headers,data:i.data.data,meta:i.data.meta,errors:i.data.errors};if(i.data.errors)throw new T(null,o);return o}catch(t){if(!t||t instanceof Error==!1)throw t;if(De.isAxiosError(t)){const e=null===(n=t.response)||void 0===n?void 0:n.data;throw new T(t,{raw:null===(i=t.response)||void 0===i?void 0:i.data,status:null===(o=t.response)||void 0===o?void 0:o.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(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 Ie{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 Fe 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 Ie(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 Me{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 Je{constructor(e,r){var s,n,i,o,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 b)this._storage=this._options.storage;else{const t=null===(i=this._options)||void 0===i?void 0:i.storage,{mode:e,...r}=null!=t?t:{};"MemoryStorage"===e||"undefined"==typeof window?this._storage=new S(r):this._storage=new $(r)}(null===(o=this._options)||void 0===o?void 0:o.transport)&&(null===(a=this._options)||void 0===a?void 0:a.transport)instanceof k?this._transport=this._options.transport:this._transport=new Le({url:this.url,...null===(u=this._options)||void 0===u?void 0:u.transport,beforeRequest:async t=>{var e,r,s,n,i;await this._auth.refreshIfExpired();const o=this.storage.auth_token,a=o?o.startsWith("Bearer ")?String(this.storage.auth_token):`Bearer ${this.storage.auth_token}`:"",u={...t,headers:{Authorization:a,...t.headers}};return(null===(e=this._options)||void 0===e?void 0:e.transport)instanceof k||!(null===(s=null===(r=this._options)||void 0===r?void 0:r.transport)||void 0===s?void 0:s.beforeRequest)?u:null===(i=null===(n=this._options)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.beforeRequest(u)}}),(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 Fe({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 assets(){return this._assets||(this._assets=new a(this.transport))}get activity(){return this._activity||(this._activity=new o(this.transport))}get collections(){return this._collections||(this._collections=new u(this.transport))}get fields(){return this._fields||(this._fields=new c(this.transport))}get files(){return this._files||(this._files=new h(this.transport))}get folders(){return this._folders||(this._folders=new l(this.transport))}get permissions(){return this._permissions||(this._permissions=new p(this.transport))}get presets(){return this._presets||(this._presets=new d(this.transport))}get relations(){return this._relations||(this._relations=new f(this.transport))}get revisions(){return this._revisions||(this._revisions=new v(this.transport))}get roles(){return this._roles||(this._roles=new m(this.transport))}get users(){return this._users||(this._users=new x(this.transport))}get settings(){return this._settings||(this._settings=new y(this.transport))}get server(){return this._server||(this._server=new g(this.transport))}get utils(){return this._utils||(this._utils=new R(this.transport))}get graphql(){return this._graphql||(this._graphql=new Me(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{o as ActivityHandler,a as AssetsHandler,Fe as Auth,A as BaseStorage,u as CollectionsHandler,i as CommentsHandler,Je as Directus,s as EmptyParamError,c as FieldsHandler,h as FilesHandler,l as FoldersHandler,t as IAuth,b as IStorage,k as ITransport,n as ItemsHandler,$ as LocalStorage,S as MemoryStorage,e as Meta,p as PermissionsHandler,d as PresetsHandler,f as RelationsHandler,v as RevisionsHandler,m as RolesHandler,g as ServerHandler,y as SettingsHandler,Le as Transport,T as TransportError,x as UsersHandler,R 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(a({},e),{filter:a((l={},l[i.field]={_in:t},l),null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)||i.field})},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.updateBatch=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.patch("".concat(this.endpoint),t,a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.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("id");return[4,this.transport.get("/assets/".concat(t),{responseType:"stream"})];case 1:return[2,e.sent().raw]}}))}))},t}(),b=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}(),g=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,{data:e.sent().data,meta:void 0}]}}))}))},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,{data:t.sent().data,meta:void 0}]}}))}))},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}(),_=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),w=function(t){function e(e){return t.call(this,"directus_folders",e)||this}return s(e,t),e}(f),m=function(t){function e(e){return t.call(this,"directus_permissions",e)||this}return s(e,t),e}(f),O=function(t){function e(e){return t.call(this,"directus_presets",e)||this}return s(e,t),e}(f),k=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),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}(),P=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),j=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.prototype.oas=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/specs/oas")];case 1:return[2,t.sent().raw]}}))}))},t}(),q=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}(),T=function(t){function e(e){return t.call(this,"directus_settings",e)||this}return s(e,t),e}(q),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}(),S=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}(),E=function(){function t(t){this._transport=t}return Object.defineProperty(t.prototype,"tfa",{get:function(){return this._tfa||(this._tfa=new S(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}(),A=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 E(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}(),H=function(){},U=function(){},M=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 B=function(t){function e(e){var n,r=this;return(r=t.call(this)||this).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}(H),C=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}(B),D=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}(B),F=function(t){function e(e){var n,o=this;return(o=t.call(this)||this).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,responseType:null==o?void 0:o.responseType,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 M(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 M(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 M(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),L=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}(),z=function(t){function e(e){var n,r,o,i=this;return(i=t.call(this)||this).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 L(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),W=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}(),N=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 H)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 C(_):this._storage=new D(_)}(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 F(a(a({url:this.url},null===(l=this._options)||void 0===l?void 0:l.transport),{beforeRequest:function(t){return c(v,void 0,void 0,(function(){var e,n,r,o,i,s,u,c;return h(this,(function(h){switch(h.label){case 0:return[4,this._auth.refreshIfExpired()];case 1:return h.sent(),e=this.storage.auth_token,n=e?e.startsWith("Bearer ")?String(this.storage.auth_token):"Bearer ".concat(this.storage.auth_token):"",r=a(a({},t),{headers:a({Authorization:n},t.headers)}),(null===(o=this._options)||void 0===o?void 0:o.transport)instanceof U||!(null===(s=null===(i=this._options)||void 0===i?void 0:i.transport)||void 0===s?void 0:s.beforeRequest)?[2,r]:[2,null===(c=null===(u=this._options)||void 0===u?void 0:u.transport)||void 0===c?void 0:c.beforeRequest(r)]}}))}))}})),(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 z(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,"assets",{get:function(){return this._assets||(this._assets=new y(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 b(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fields",{get:function(){return this._fields||(this._fields=new g(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"files",{get:function(){return this._files||(this._files=new _(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"folders",{get:function(){return this._folders||(this._folders=new w(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"permissions",{get:function(){return this._permissions||(this._permissions=new m(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"presets",{get:function(){return this._presets||(this._presets=new O(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"relations",{get:function(){return this._relations||(this._relations=new k(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"revisions",{get:function(){return this._revisions||(this._revisions=new P(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 A(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"settings",{get:function(){return this._settings||(this._settings=new T(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"server",{get:function(){return this._server||(this._server=new j(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 W(this.transport))},enumerable:!1,configurable:!0}),t.prototype.singleton=function(t){return this._singletons[t]||(this._singletons[t]=new q(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.AssetsHandler=y,t.Auth=z,t.BaseStorage=B,t.CollectionsHandler=b,t.CommentsHandler=d,t.Directus=N,t.EmptyParamError=p,t.FieldsHandler=g,t.FilesHandler=_,t.FoldersHandler=w,t.IAuth=o,t.IStorage=H,t.ITransport=U,t.ItemsHandler=f,t.LocalStorage=D,t.MemoryStorage=C,t.PermissionsHandler=m,t.PresetsHandler=O,t.RelationsHandler=k,t.RevisionsHandler=P,t.RolesHandler=x,t.ServerHandler=j,t.SettingsHandler=T,t.Transport=F,t.TransportError=M,t.UsersHandler=A,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(a({},e),{filter:a((l={},l[i.field]={_in:t},l),null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)||i.field})},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.updateBatch=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.patch("".concat(this.endpoint),t,a({params:e},null==n?void 0:n.requestOptions))];case 1:return[2,r.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("id");return[4,this.transport.get("/assets/".concat(t),{responseType:"stream"})];case 1:return[2,e.sent().raw]}}))}))},t}(),b=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}(),g=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,{data:e.sent().data,meta:void 0}]}}))}))},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,{data:t.sent().data,meta:void 0}]}}))}))},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}(),_=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),w=function(t){function e(e){return t.call(this,"directus_folders",e)||this}return s(e,t),e}(f),m=function(t){function e(e){return t.call(this,"directus_permissions",e)||this}return s(e,t),e}(f),O=function(t){function e(e){return t.call(this,"directus_presets",e)||this}return s(e,t),e}(f),k=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),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}(),x=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),j=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.prototype.oas=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/specs/oas")];case 1:return[2,t.sent().raw]}}))}))},t}(),q=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}(),T=function(t){function e(e){return t.call(this,"directus_settings",e)||this}return s(e,t),e}(q),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}(),S=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}(),E=function(){function t(t){this._transport=t}return Object.defineProperty(t.prototype,"tfa",{get:function(){return this._tfa||(this._tfa=new S(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}(),A=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 E(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}(),H=function(){},U=function(){},B=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=this;return(r=t.call(this)||this).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}(H),C=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),L=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=this;return(o=t.call(this)||this).config=e,o.axios=r.default.create({baseURL:o.config.url,params:o.config.params,headers:o.config.headers,onUploadProgress:o.config.onUploadProgress,maxBodyLength:o.config.maxBodyLength,maxContentLength:o.config.maxContentLength,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,responseType:null==o?void 0:o.responseType,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 B(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 B(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 B(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}(),z=function(t){function e(e){var n,r,o,i=this;return(i=t.call(this)||this).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),W=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}(),N=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 H)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 C(_):this._storage=new L(_)}(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(a({url:this.url},null===(l=this._options)||void 0===l?void 0:l.transport),{beforeRequest:function(t){return c(v,void 0,void 0,(function(){var e,n,r,o,i,s,u,c;return h(this,(function(h){switch(h.label){case 0:return[4,this._auth.refreshIfExpired()];case 1:return h.sent(),e=this.storage.auth_token,n=e?e.startsWith("Bearer ")?String(this.storage.auth_token):"Bearer ".concat(this.storage.auth_token):"",r=a(a({},t),{headers:a({Authorization:n},t.headers)}),(null===(o=this._options)||void 0===o?void 0:o.transport)instanceof U||!(null===(s=null===(i=this._options)||void 0===i?void 0:i.transport)||void 0===s?void 0:s.beforeRequest)?[2,r]:[2,null===(c=null===(u=this._options)||void 0===u?void 0:u.transport)||void 0===c?void 0:c.beforeRequest(r)]}}))}))}})),(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 z(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,"assets",{get:function(){return this._assets||(this._assets=new y(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 b(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fields",{get:function(){return this._fields||(this._fields=new g(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"files",{get:function(){return this._files||(this._files=new _(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"folders",{get:function(){return this._folders||(this._folders=new w(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"permissions",{get:function(){return this._permissions||(this._permissions=new m(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"presets",{get:function(){return this._presets||(this._presets=new O(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"relations",{get:function(){return this._relations||(this._relations=new k(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"revisions",{get:function(){return this._revisions||(this._revisions=new x(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 A(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"settings",{get:function(){return this._settings||(this._settings=new T(this.transport))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"server",{get:function(){return this._server||(this._server=new j(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 W(this.transport))},enumerable:!1,configurable:!0}),t.prototype.singleton=function(t){return this._singletons[t]||(this._singletons[t]=new q(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.AssetsHandler=y,t.Auth=z,t.BaseStorage=M,t.CollectionsHandler=b,t.CommentsHandler=d,t.Directus=N,t.EmptyParamError=p,t.FieldsHandler=g,t.FilesHandler=_,t.FoldersHandler=w,t.IAuth=o,t.IStorage=H,t.ITransport=U,t.ItemsHandler=f,t.LocalStorage=L,t.MemoryStorage=C,t.PermissionsHandler=m,t.PresetsHandler=O,t.RelationsHandler=k,t.RevisionsHandler=x,t.RolesHandler=P,t.ServerHandler=j,t.SettingsHandler=T,t.Transport=D,t.TransportError=B,t.UsersHandler=A,t.UtilsHandler=I,Object.defineProperty(t,"__esModule",{value:!0}),t}({},axios); | ||
//# sourceMappingURL=sdk.global.min.js.map |
{ | ||
"name": "@directus/sdk", | ||
"version": "10.2.0", | ||
"version": "10.3.0", | ||
"description": "The official Directus SDK for use in JavaScript!", | ||
@@ -5,0 +5,0 @@ "repository": "directus/sdk", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
285481
3334