Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@directus/sdk

Package Overview
Dependencies
Maintainers
2
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@directus/sdk - npm Package Compare versions

Comparing version 15.0.0 to 15.0.1

2

dist/index.js

@@ -1,2 +0,2 @@

var I="/",W=(e,t)=>(e.endsWith(I)&&(e=e.slice(0,-1)),t.startsWith(I)||(t=I+t),e+t),j=(e,t,o)=>{let s=e.pathname===I?t:W(e.pathname,t),a=new globalThis.URL(s,e);if(o)for(let[p,c]of Object.entries(N(o)))if(c&&typeof c=="object"&&!Array.isArray(c))for(let[i,h]of Object.entries(c))a.searchParams.set(`${p}[${i}]`,String(h));else a.searchParams.set(p,c);return a};function v(e){return typeof e!="object"||!e?!1:"headers"in e&&"ok"in e&&"json"in e&&typeof e.json=="function"&&"text"in e&&typeof e.json=="function"}async function U(e){if(!(typeof e!="object"||!e)){if(v(e)){let t=e.headers.get("Content-Type")?.toLowerCase();if(t?.startsWith("application/json")||t?.startsWith("application/health+json")){let o=await e.json();if(!e.ok)throw o;return"data"in o?o.data:o}if(t?.startsWith("text/html")||t?.startsWith("text/plain")){let o=await e.text();if(!e.ok)throw o;return o}return e}return"data"in e?e.data:e}}var R=async(e,t,o=globalThis.fetch)=>{t.headers=typeof t.headers=="object"&&!Array.isArray(t.headers)?t.headers:{};let s=await o(e,t);return U(s).catch(a=>{throw{errors:typeof a=="object"&&"errors"in a?a.errors:a,response:s}})};var J=()=>{let e=null;return{get:async()=>e,set:async t=>{e=t}}};var K={msRefreshBeforeExpires:3e4,autoRefresh:!0},re=(e="cookie",t={})=>o=>{let s={...K,...t},a=null,p=null,c=s.storage??J(),i=()=>{c.set({access_token:null,refresh_token:null,expires:null,expires_at:null})},h=async()=>{try{await a}finally{a=null}},f=async()=>{let y=await c.get();if(a||!y?.expires_at){await h();return}y.expires_at<new Date().getTime()+s.msRefreshBeforeExpires&&Q().catch(u=>{}),await h()},g=y=>{let u=y.expires??0;y.expires_at=new Date().getTime()+u,c.set(y),s.autoRefresh&&u>s.msRefreshBeforeExpires&&u<Number.MAX_SAFE_INTEGER&&(p&&clearTimeout(p),p=setTimeout(()=>{p=null,Q().catch(b=>{})},u-s.msRefreshBeforeExpires))},Q=async()=>(a=(async()=>{let u=await c.get();i();let b={method:"POST",headers:{"Content-Type":"application/json"}};"credentials"in s&&(b.credentials=s.credentials);let m={mode:e};e==="json"&&u?.refresh_token&&(m.refresh_token=u.refresh_token),b.body=JSON.stringify(m);let n=j(o.url,"/auth/refresh"),d=await R(n.toString(),b,o.globals.fetch);return g(d),d})().catch(u=>{throw u}),a);return{refresh:Q,async login(y,u,b={}){i();let m=j(o.url,"/auth/login"),n={email:y,password:u};"otp"in b&&(n.otp=b.otp),n.mode=b.mode??e;let d={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)};"credentials"in s&&(d.credentials=s.credentials);let l=await R(m.toString(),d,o.globals.fetch);return g(l),l},async logout(){let y=await c.get(),u={method:"POST",headers:{"Content-Type":"application/json"}};"credentials"in s&&(u.credentials=s.credentials),e==="json"&&y?.refresh_token&&(u.body=JSON.stringify({refresh_token:y.refresh_token}));let b=j(o.url,"/auth/logout");await R(b.toString(),u,o.globals.fetch),p&&clearTimeout(p),i()},async getToken(){return await f(),(await c.get())?.access_token??null},setToken(y){c.set({access_token:y,refresh_token:null,expires:null,expires_at:null})}}};var se=e=>t=>{let o=e??null;return{async getToken(){return o},setToken(s){o=s}}};var $={fetch:globalThis.fetch,WebSocket:globalThis.WebSocket,URL:globalThis.URL,logger:globalThis.console},pe=(e,t={})=>{let o=t.globals?{...$,...t.globals}:$;return{globals:o,url:new o.URL(e),with(s){return{...this,...s(this)}}}};var G={},ye=(e={})=>t=>{let o={...G,...e};return{async query(s,a,p="items"){let c={method:"POST",body:JSON.stringify({query:s,variables:a})};"credentials"in o&&(c.credentials=o.credentials);let i={};if("getToken"in this){let g=await this.getToken();g&&(i.Authorization=`Bearer ${g}`)}"Content-Type"in i||(i["Content-Type"]="application/json"),c.headers=i;let h=p==="items"?"/graphql":"/graphql/system",f=j(t.url,h);return await R(f.toString(),c,t.globals.fetch)}}};function E(e){return JSON.stringify({...e,type:"auth"})}var k=()=>JSON.stringify({type:"pong"});var F=(e,t=1e3)=>new Promise((o,s)=>{let a=h=>{try{let f=JSON.parse(h.data);typeof f=="object"&&!Array.isArray(f)&&f!==null?(c(),o(f)):(c(),p())}catch{c(),o(h)}},p=()=>s(),c=()=>{clearTimeout(i),e.removeEventListener("message",a),e.removeEventListener("error",p),e.removeEventListener("close",p)};e.addEventListener("message",a),e.addEventListener("error",p),e.addEventListener("close",p);let i=setTimeout(()=>{c(),o(void 0)},t)});function*A(){let e=1;for(;;)yield String(e),e++}var L={authMode:"handshake",heartbeat:!0,debug:!1,reconnect:{delay:1e3,retries:10}};function Ie(e={}){return t=>{e={...L,...e};let o=A(),s={code:"closed"},a={attempts:0,active:!1},p=new Set,c=m=>"getToken"in m,i=(m,...n)=>e.debug&&t.globals.logger[m]("[Directus SDK]",...n),h=async(m,n)=>{if(e.authMode==="strict"&&c(n)){let d=await n.getToken();d&&m.searchParams.set("access_token",d)}return m},f=async m=>{if("url"in e)return await h(new t.globals.URL(e.url),m);if(["ws:","wss:"].includes(t.url.protocol))return await h(t.url,m);let n=new t.globals.URL(t.url.toString());return n.protocol=t.url.protocol==="https:"?"wss:":"ws:",n.pathname="/websocket",await h(n,m)},g=m=>{let n=new Promise((d,l)=>{if(!e.reconnect)return l();if(i("info",`reconnect #${a.attempts} `+(a.attempts>=e.reconnect.retries?"maximum retries reached":`trying again in ${Math.max(100,e.reconnect.delay)}ms`)),a.active)return a.active;if(a.attempts>=e.reconnect.retries)return l();setTimeout(()=>m.connect().then(D=>(p.forEach(S=>{m.sendMessage(S)}),D)).then(d).catch(l),Math.max(100,e.reconnect.delay))});a.attempts+=1,a.active=n.catch(()=>{}).finally(()=>{a.active=!1})},Q={open:new Set([]),error:new Set([]),close:new Set([]),message:new Set([])};function y(m){return"type"in m&&"status"in m&&"error"in m&&"code"in m.error&&"message"in m.error&&m.type==="auth"&&m.status==="error"}async function u(m,n){if(s.code==="open"){if(m.error.code==="TOKEN_EXPIRED"&&(i("warn","Authentication token expired!"),c(n))){let d=await n.getToken();if(!d)throw Error("No token for re-authenticating the websocket");s.connection.send(E({access_token:d}))}if(m.error.code==="AUTH_TIMEOUT")return s.firstMessage&&e.authMode==="public"?(i("warn",'Authentication failed! Currently the "authMode" is "public" try using "handshake" instead'),e.reconnect=!1):i("warn","Authentication timed out!"),s.connection.close();if(m.error.code==="AUTH_FAILED"){if(s.firstMessage&&e.authMode==="public")return i("warn",'Authentication failed! Currently the "authMode" is "public" try using "handshake" instead'),e.reconnect=!1,s.connection.close();i("warn","Authentication failed!")}}}let b=async m=>{for(;s.code==="open";){let n=await F(s.connection).catch(()=>{});if(n){if(y(n)){await u(n,m),s.firstMessage=!1;continue}if(e.heartbeat&&n.type==="ping"){s.connection.send(k()),s.firstMessage=!1;continue}Q.message.forEach(d=>{s.code==="open"&&d.call(s.connection,n)}),s.firstMessage=!1}}};return{async connect(){if(s.code==="connecting")return await s.connection;if(s.code!=="closed")throw new Error(`Cannot connect when state is "${s.code}"`);let m=this,n=await f(m);i("info",`Connecting to ${n}...`);let d=new Promise((l,D)=>{let S=!1,T=new t.globals.WebSocket(n);T.addEventListener("open",async O=>{if(i("info","Connection open."),e.authMode==="handshake"&&c(m)){let C=await m.getToken();if(!C)throw Error("No token for authenticating the websocket. Make sure to provide one or call the login() function beforehand.");T.send(E({access_token:C}));let P=await F(T);if(P&&"type"in P&&"status"in P&&P.type==="auth"&&P.status==="ok")i("info","Authentication successful!");else return D("Authentication failed while opening websocket connection")}s={code:"open",connection:T,firstMessage:!0},a.attempts=0,a.active=!1,Q.open.forEach(C=>C.call(T,O)),b(m),S=!0,l(T)}),T.addEventListener("error",O=>{i("warn","Connection errored."),Q.error.forEach(C=>C.call(T,O)),T.close(),s={code:"error"},S||D(O)}),T.addEventListener("close",O=>{i("info","Connection closed."),Q.close.forEach(C=>C.call(T,O)),o=A(),s={code:"closed"},g(this),S||D(O)})});return s={code:"connecting",connection:d},d},disconnect(){s.code==="open"&&s.connection.close()},onWebSocket(m,n){if(m==="message"){let d=function(l){if(typeof l.data!="string")return n.call(this,l);try{return n.call(this,JSON.parse(l.data))}catch{return n.call(this,l)}};return Q[m].add(d),()=>Q[m].delete(d)}return Q[m].add(n),()=>Q[m].delete(n)},sendMessage(m){if(s.code!=="open")throw new Error('Cannot send messages without an open connection. Make sure you are calling "await client.connect()".');if(typeof m=="string")return s.connection.send(m);"uid"in m||(m.uid=o.next().value),s.connection.send(JSON.stringify(m))},async subscribe(m,n={}){"uid"in n||(n.uid=o.next().value),p.add({...n,collection:m,type:"subscribe"}),s.code!=="open"&&(i("info","No connection available for subscribing!"),await this.connect()),this.sendMessage({...n,collection:m,type:"subscribe"});let d=!0;async function*l(){for(;d&&s.code==="open";){let S=await F(s.connection).catch(()=>{});if(S){if("type"in S&&"status"in S&&S.type==="subscribe"&&S.status==="error")throw S;"type"in S&&"uid"in S&&S.type==="subscription"&&S.uid===n.uid&&(yield S)}}e.reconnect&&a.active&&(await a.active,s.code==="open"&&(s.connection.send(JSON.stringify({...n,collection:m,type:"subscribe"})),yield*l()))}let D=()=>{p.delete({...n,collection:m,type:"subscribe"}),this.sendMessage({uid:n.uid,type:"unsubscribe"}),d=!1};return{subscription:l(),unsubscribe:D}}}}}var Ee=e=>new Promise(t=>setTimeout(()=>t(),e));var Ge=(e,t,o={})=>()=>{let s={email:e,password:t};return"otp"in o&&(s.otp=o.otp),s.mode=o.mode??"cookie",{path:"/auth/login",method:"POST",body:JSON.stringify(s)}};var He=e=>()=>({path:"/auth/logout",method:"POST",body:JSON.stringify(e?{refresh_token:e}:{})});var Me=(e,t)=>()=>({path:"/auth/password/request",method:"POST",body:JSON.stringify({email:e,...t?{reset_url:t}:{}})});var Be=(e,t)=>()=>({path:"/auth/password/reset",method:"POST",body:JSON.stringify({token:e,password:t})});var ze=()=>()=>({path:"/auth",method:"GET"});var Ye=(e="cookie",t)=>()=>({path:"/auth/refresh",method:"POST",body:JSON.stringify(e==="json"?{refresh_token:t,mode:e}:{mode:e})});var nt=(e,t)=>()=>({path:"/activity/comment",params:t??{},body:JSON.stringify(e),method:"POST"});var it=(e,t)=>()=>({path:"/collections",params:t??{},body:JSON.stringify(e),method:"POST"});var dt=(e,t)=>()=>({path:"/dashboards",params:t??{},body:JSON.stringify(e),method:"POST"}),ht=(e,t)=>()=>({path:"/dashboards",params:t??{},body:JSON.stringify(e),method:"POST"});var yt=(e,t,o)=>()=>({path:`/fields/${e}`,params:o??{},body:JSON.stringify(t),method:"POST"});var lt=(e,t)=>()=>({path:"/files",method:"POST",body:e,params:t??{},headers:{"Content-Type":"multipart/form-data"}}),ft=(e,t={},o)=>()=>({path:"/files/import",method:"POST",body:JSON.stringify({url:e,data:t}),params:o??{}});var Qt=(e,t)=>()=>({path:"/flows",params:t??{},body:JSON.stringify(e),method:"POST"}),bt=(e,t)=>()=>({path:"/flows",params:t??{},body:JSON.stringify(e),method:"POST"});var Ct=(e,t)=>()=>({path:"/folders",params:t??{},body:JSON.stringify(e),method:"POST"}),jt=(e,t)=>()=>({path:"/folders",params:t??{},body:JSON.stringify(e),method:"POST"});var gt=(e,t,o)=>()=>{let s=String(e);if(s.startsWith("directus_"))throw new Error("Cannot use createItems for core collections");return{path:`/items/${s}`,params:o??{},body:JSON.stringify(t),method:"POST"}},Dt=(e,t,o)=>()=>{let s=String(e);if(s.startsWith("directus_"))throw new Error("Cannot use createItem for core collections");return{path:`/items/${s}`,params:o??{},body:JSON.stringify(t),method:"POST"}};var Pt=(e,t)=>()=>({path:"/notifications",params:t??{},body:JSON.stringify(e),method:"POST"}),It=(e,t)=>()=>({path:"/notifications",params:t??{},body:JSON.stringify(e),method:"POST"});var Et=(e,t)=>()=>({path:"/operations",params:t??{},body:JSON.stringify(e),method:"POST"}),At=(e,t)=>()=>({path:"/operations",params:t??{},body:JSON.stringify(e),method:"POST"});var Nt=(e,t)=>()=>({path:"/panels",params:t??{},body:JSON.stringify(e),method:"POST"}),vt=(e,t)=>()=>({path:"/panels",params:t??{},body:JSON.stringify(e),method:"POST"});var Jt=(e,t)=>()=>({path:"/permissions",params:t??{},body:JSON.stringify(e),method:"POST"}),$t=(e,t)=>()=>({path:"/permissions",params:t??{},body:JSON.stringify(e),method:"POST"});var Wt=(e,t)=>()=>({path:"/presets",params:t??{},body:JSON.stringify(e),method:"POST"}),Kt=(e,t)=>()=>({path:"/presets",params:t??{},body:JSON.stringify(e),method:"POST"});var Lt=e=>()=>({path:"/relations",body:JSON.stringify(e),method:"POST"});var Vt=(e,t)=>()=>({path:"/roles",params:t??{},body:JSON.stringify(e),method:"POST"}),Mt=(e,t)=>()=>({path:"/roles",params:t??{},body:JSON.stringify(e),method:"POST"});var Bt=(e,t)=>()=>({path:"/shares",params:t??{},body:JSON.stringify(e),method:"POST"}),qt=(e,t)=>()=>({path:"/shares",params:t??{},body:JSON.stringify(e),method:"POST"});var Xt=(e,t)=>()=>({path:"/translations",params:t??{},body:JSON.stringify(e),method:"POST"}),Yt=(e,t)=>()=>({path:"/translations",params:t??{},body:JSON.stringify(e),method:"POST"});var er=(e,t)=>()=>({path:"/users",params:t??{},body:JSON.stringify(e),method:"POST"}),tr=(e,t)=>()=>({path:"/users",params:t??{},body:JSON.stringify(e),method:"POST"});var or=(e,t)=>()=>({path:"/versions",params:t??{},body:JSON.stringify(e),method:"POST"}),sr=(e,t)=>()=>({path:"/versions",params:t??{},body:JSON.stringify(e),method:"POST"});var mr=(e,t)=>()=>({path:"/webhooks",params:t??{},body:JSON.stringify(e),method:"POST"}),nr=(e,t)=>()=>({path:"/webhooks",params:t??{},body:JSON.stringify(e),method:"POST"});var Fr=e=>()=>({path:`/activity/comment/${e}`,method:"DELETE"});var Ar=e=>()=>({path:`/collections/${e}`,method:"DELETE"});var w=e=>{let t=(o,s=[])=>{if(typeof o=="object"){let a=[];for(let p in o){let c=o[p]??[];if(Array.isArray(c))for(let i of c)a.push(t(i,[...s,p]));else if(typeof c=="object")for(let i of Object.keys(c)){let h=c[i];for(let f of h)a.push(t(f,[...s,`${p}:${i}`]))}}return a.flatMap(p=>p)}return[...s,String(o)].join(".")};return e.flatMap(o=>t(o))},N=e=>{let t={};Array.isArray(e.fields)&&e.fields.length>0&&(t.fields=w(e.fields).join(",")),e.filter&&Object.keys(e.filter).length>0&&(t.filter=JSON.stringify(e.filter)),e.search&&(t.search=e.search),"sort"in e&&e.sort&&(t.sort=typeof e.sort=="string"?e.sort:e.sort.join(",")),typeof e.limit=="number"&&e.limit>=-1&&(t.limit=String(e.limit)),typeof e.offset=="number"&&e.offset>=0&&(t.offset=String(e.offset)),typeof e.page=="number"&&e.page>=1&&(t.page=String(e.page)),e.deep&&Object.keys(e.deep).length>0&&(t.deep=JSON.stringify(e.deep)),e.alias&&Object.keys(e.alias).length>0&&(t.alias=JSON.stringify(e.alias)),e.aggregate&&Object.keys(e.aggregate).length>0&&(t.aggregate=JSON.stringify(e.aggregate)),e.groupBy&&e.groupBy.length>0&&(t.groupBy=e.groupBy.join(","));for(let[o,s]of Object.entries(e))o in t||(typeof s=="string"||typeof s=="number"||typeof s=="boolean"?t[o]=String(s):t[o]=JSON.stringify(s));return t};var r=(e,t)=>{if(e.length===0)throw new Error(t)};var x=(e,t)=>{if(String(e).startsWith("directus_"))throw new Error(t)};var Gr=e=>()=>(r(e,"Keys cannot be empty"),{path:"/dashboards",body:JSON.stringify(e),method:"DELETE"}),Lr=e=>()=>(r(e,"Key cannot be empty"),{path:`/dashboards/${e}`,method:"DELETE"});var Mr=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/fields/${e}/${t}`,method:"DELETE"});var qr=e=>()=>(r(e,"Keys cannot be empty"),{path:"/files",body:JSON.stringify(e),method:"DELETE"}),zr=e=>()=>(r(e,"Key cannot be empty"),{path:`/files/${e}`,method:"DELETE"});var Zr=e=>()=>(r(e,"Keys cannot be empty"),{path:"/flows",body:JSON.stringify(e),method:"DELETE"}),eo=e=>()=>(r(e,"Key cannot be empty"),{path:`/flows/${e}`,method:"DELETE"});var oo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/folders",body:JSON.stringify(e),method:"DELETE"}),so=e=>()=>(r(e,"Key cannot be empty"),{path:`/folders/${e}`,method:"DELETE"});var no=(e,t)=>()=>{let o={};return r(String(e),"Collection cannot be empty"),x(e,"Cannot use deleteItems for core collections"),Array.isArray(t)?(r(t,"keysOrQuery cannot be empty"),o={keys:t}):(r(Object.keys(t),"keysOrQuery cannot be empty"),o={query:t}),{path:`/items/${e}`,body:JSON.stringify(o),method:"DELETE"}},co=(e,t)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use deleteItem for core collections"),r(String(t),"Key cannot be empty"),{path:`/items/${e}/${t}`,method:"DELETE"});var ho=e=>()=>(r(e,"Keys cannot be empty"),{path:"/notifications",body:JSON.stringify(e),method:"DELETE"}),uo=e=>()=>(r(e,"Key cannot be empty"),{path:`/notifications/${e}`,method:"DELETE"});var lo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/operations",body:JSON.stringify(e),method:"DELETE"}),fo=e=>()=>(r(e,"Key cannot be empty"),{path:`/operations/${e}`,method:"DELETE"});var bo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/panels",body:JSON.stringify(e),method:"DELETE"}),To=e=>()=>(r(e,"Key cannot be empty"),{path:`/panels/${e}`,method:"DELETE"});var Ro=e=>()=>(r(e,"Keys cannot be empty"),{path:"/permissions",body:JSON.stringify(e),method:"DELETE"}),go=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/permissions/${e}`,method:"DELETE"});var Po=e=>()=>(r(e,"Keys cannot be empty"),{path:"/presets",body:JSON.stringify(e),method:"DELETE"}),Io=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/presets/${e}`,method:"DELETE"});var Ao=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/relations/${e}/${t}`,method:"DELETE"});var vo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/roles",body:JSON.stringify(e),method:"DELETE"}),Uo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/roles/${e}`,method:"DELETE"});var ko=e=>()=>(r(e,"Keys cannot be empty"),{path:"/shares",body:JSON.stringify(e),method:"DELETE"}),Wo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/shares/${e}`,method:"DELETE"});var Lo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/translations",body:JSON.stringify(e),method:"DELETE"}),Ho=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/translations/${e}`,method:"DELETE"});var _o=e=>()=>(r(e,"Keys cannot be empty"),{path:"/users",body:JSON.stringify(e),method:"DELETE"}),Bo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/users/${e}`,method:"DELETE"});var Xo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/versions",body:JSON.stringify(e),method:"DELETE"}),Yo=e=>()=>(r(e,"Key cannot be empty"),{path:`/versions/${e}`,method:"DELETE"});var ts=e=>()=>(r(e,"Keys cannot be empty"),{path:"/webhooks",body:JSON.stringify(e),method:"DELETE"}),rs=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/webhooks/${e}`,method:"DELETE"});var Ds=e=>()=>({path:"/activity",params:e??{},method:"GET"}),Os=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/activity/${e}`,params:t??{},method:"GET"});var Fs=(e,t)=>()=>{let o=String(e);return r(o,"Collection cannot be empty"),{path:o.startsWith("directus_")?`/${o.substring(9)}`:`/items/${o}`,method:"GET",params:{...t.query??{},...t.groupBy?{groupBy:t.groupBy}:{},aggregate:t.aggregate}}};var ws=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/assets/${e}`,params:t??{},method:"GET",onResponse:o=>o.body}),Ns=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/assets/${e}`,params:t??{},method:"GET",onResponse:o=>o.blob()}),vs=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/assets/${e}`,params:t??{},method:"GET",onResponse:o=>o.arrayBuffer()});var $s=()=>()=>({path:"/collections",method:"GET"}),ks=e=>()=>(r(e,"Collection cannot be empty"),{path:`/collections/${e}`,method:"GET"});var Gs=e=>()=>({path:"/dashboards",params:e??{},method:"GET"}),Ls=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/dashboards/${e}`,params:t??{},method:"GET"});var Vs=()=>()=>({path:"/extensions/",method:"GET"});var Bs=()=>()=>({path:"/fields",method:"GET"}),qs=e=>()=>(r(e,"Collection cannot be empty"),{path:`/fields/${e}`,method:"GET"}),zs=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/fields/${e}/${t}`,method:"GET"});var Zs=e=>()=>({path:"/files",params:e??{},method:"GET"}),ea=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/files/${e}`,params:t??{},method:"GET"});var oa=e=>()=>({path:"/flows",params:e??{},method:"GET"}),sa=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/flows/${e}`,params:t??{},method:"GET"});var na=e=>()=>({path:"/folders",params:e??{},method:"GET"}),ca=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/folders/${e}`,params:t??{},method:"GET"});var da=(e,t)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use readItems for core collections"),{path:`/items/${e}`,params:t??{},method:"GET"}),ha=(e,t,o)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use readItem for core collections"),r(String(t),"Key cannot be empty"),{path:`/items/${e}/${t}`,params:o??{},method:"GET"});var Sa=e=>()=>({path:"/notifications",params:e??{},method:"GET"}),la=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/notifications/${e}`,params:t??{},method:"GET"});var Qa=e=>()=>({path:"/operations",params:e??{},method:"GET"}),ba=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/operations/${e}`,params:t??{},method:"GET"});var ja=e=>()=>({path:"/panels",params:e??{},method:"GET"}),Ra=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/panels/${e}`,params:t??{},method:"GET"});var Oa=e=>()=>({path:"/permissions",params:e??{},method:"GET"}),Pa=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/permissions/${e}`,params:t??{},method:"GET"});var Ea=e=>()=>({path:"/presets",params:e??{},method:"GET"}),Aa=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/presets/${e}`,params:t??{},method:"GET"});var va=()=>()=>({path:"/relations",method:"GET"}),Ua=e=>()=>({path:`/relations/${e}`,method:"GET"}),Ja=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/relations/${e}/${t}`,method:"GET"});var Wa=e=>()=>({path:"/revisions",params:e??{},method:"GET"}),Ka=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/revisions/${e}`,params:t??{},method:"GET"});var Ha=e=>()=>({path:"/roles",params:e??{},method:"GET"}),Va=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/roles/${e}`,params:t??{},method:"GET"});var _a=e=>()=>({path:"/settings",params:e??{},method:"GET"});var za=e=>()=>({path:"/shares",params:e??{},method:"GET"}),Xa=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/shares/${e}`,params:t??{},method:"GET"});var em=(e,t)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use readSingleton for core collections"),{path:`/items/${e}`,params:t??{},method:"GET"});var om=e=>()=>({path:"/translations",params:e??{},method:"GET"}),sm=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/translations/${e}`,params:t??{},method:"GET"});var nm=e=>()=>({path:"/users",params:e??{},method:"GET"}),cm=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/users/${e}`,params:t??{},method:"GET"}),im=e=>()=>({path:"/users/me",params:e??{},method:"GET"});var hm=e=>()=>({path:"/versions",params:e??{},method:"GET"}),um=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/versions/${e}`,params:t??{},method:"GET"});var lm=e=>()=>({path:"/webhooks",params:e??{},method:"GET"}),fm=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/webhooks/${e}`,params:t??{},method:"GET"});var Mm=e=>()=>({method:"POST",path:"/schema/apply",body:JSON.stringify(e)});var Bm=(e,t=!1)=>()=>({method:"POST",path:"/schema/diff",params:t?{force:t}:{},body:JSON.stringify(e)});var zm=()=>()=>({method:"GET",path:"/schema/snapshot"});var rn=(e="item")=>()=>({method:"GET",path:e==="item"?"/server/specs/graphql":"/server/specs/graphql/system"});var sn=()=>()=>({method:"GET",path:"/server/health"});var mn=()=>()=>({method:"GET",path:"/server/info"});var cn=()=>()=>({method:"GET",path:"/server/specs/oas"});var dn=()=>()=>({method:"GET",path:"/server/ping"});var bn=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/activity/comment/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var jn=(e,t,o)=>()=>(r(e,"Collection cannot be empty"),{path:`/collections/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Dn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/dashboards",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),On=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/dashboards/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Fn=(e,t,o)=>()=>(e!==null&&r(e,"Bundle cannot be an empty string"),r(t,"Name cannot be empty"),{path:e?`/extensions/${e}/${t}`:`/extensions/${t}`,params:{},body:JSON.stringify(o),method:"PATCH"});var wn=(e,t,o,s)=>()=>(r(e,"Keys cannot be empty"),r(t,"Field cannot be empty"),{path:`/fields/${e}/${t}`,params:s??{},body:JSON.stringify(o),method:"PATCH"});var Un=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/files",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Jn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),t instanceof FormData?{path:`/files/${e}`,params:o??{},body:t,method:"PATCH",headers:{"Content-Type":"multipart/form-data"}}:{path:`/files/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Wn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/flows",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Kn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/flows/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Hn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/folders",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Vn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/folders/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Bn=(e,t,o,s)=>()=>{let a={};return r(String(e),"Collection cannot be empty"),x(e,"Cannot use updateItems for core collections"),Array.isArray(t)?(r(t,"keysOrQuery cannot be empty"),a={keys:t}):(r(Object.keys(t),"keysOrQuery cannot be empty"),a={query:t}),a.data=o,{path:`/items/${e}`,params:s??{},body:JSON.stringify(a),method:"PATCH"}},qn=(e,t,o,s)=>()=>(r(String(t),"Key cannot be empty"),r(String(e),"Collection cannot be empty"),x(e,"Cannot use updateItem for core collections"),{path:`/items/${e}/${t}`,params:s??{},body:JSON.stringify(o),method:"PATCH"});var Yn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/notifications",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Zn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/notifications/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var rc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/operations",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),oc=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/operations/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var mc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/panels",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),nc=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/panels/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var pc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/permissions",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),dc=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/permissions/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var yc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/presets",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Sc=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/presets/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var xc=(e,t,o,s)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/relations/${e}/${t}`,params:s??{},body:JSON.stringify(o),method:"PATCH"});var Tc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/roles",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Cc=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/roles/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Rc=(e,t)=>()=>({path:"/settings",params:t??{},body:JSON.stringify(e),method:"PATCH"});var Oc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/shares",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Pc=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/shares/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Ec=(e,t,o)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use updateSingleton for core collections"),{path:`/items/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Nc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/translations",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),vc=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/translations/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var $c=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/users",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),kc=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/users/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"}),Wc=(e,t)=>()=>({path:"/users/me",params:t??{},body:JSON.stringify(e),method:"PATCH"});var Lc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/versions",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Hc=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/versions/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var _c=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/webhooks",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Bc=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/webhooks/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var bi=()=>()=>({method:"POST",path:"/utils/cache/clear"});var Ci=(e,t,o,s)=>()=>({method:"POST",path:`/utils/export/${e}`,body:JSON.stringify({format:t,query:o,file:s})});var Ri=(e,t,o)=>()=>e==="GET"?{path:`/flows/trigger/${t}`,params:o??{},method:"GET"}:{path:`/flows/trigger/${t}`,body:JSON.stringify(o??{}),method:"POST"};var Di=e=>()=>({method:"POST",path:"/utils/hash/generate",body:JSON.stringify({string:e})}),Oi=(e,t)=>()=>({method:"POST",path:"/utils/hash/verify",body:JSON.stringify({string:e,hash:t})});var Ii=(e,t)=>()=>({path:`/utils/import/${e}`,method:"POST",body:t,headers:{"Content-Type":"multipart/form-data"}});var Ei=(e,t)=>()=>({path:`/operations/trigger/${e}`,body:JSON.stringify(t??{}),method:"POST"});var wi=(e,t)=>()=>({path:"/shares/auth",method:"POST",body:JSON.stringify({share:e,password:t})}),Ni=(e,t)=>()=>({path:"/shares/invite",method:"POST",body:JSON.stringify({share:e,emails:t})}),vi=e=>()=>({path:`/shares/info/${e}`,method:"GET"});var Ji=(e,t,o)=>()=>({method:"POST",path:`/utils/sort/${e}`,body:JSON.stringify({item:t,to:o})});var ki=(e,t,o)=>()=>({path:"/users/invite",method:"POST",body:JSON.stringify({email:e,role:t,...o?{invite_url:o}:{}})}),Wi=(e,t)=>()=>({path:"/users/invite/accept",method:"POST",body:JSON.stringify({token:e,password:t})}),Ki=e=>()=>({path:"/users/me/tfa/generate",method:"POST",body:JSON.stringify({password:e})}),Gi=(e,t)=>()=>({path:"/users/me/tfa/enable",method:"POST",body:JSON.stringify({secret:e,otp:t})}),Li=e=>()=>({path:"/users/me/tfa/disable",method:"POST",body:JSON.stringify({otp:e})});var Mi=(e,t)=>()=>(r(e,"ID cannot be empty"),{path:`/versions/${e}/save`,method:"POST",body:JSON.stringify(t)}),_i=e=>()=>(r(e,"ID cannot be empty"),{path:`/versions/${e}/compare`,method:"GET"}),Bi=(e,t,o)=>()=>(r(e,"ID cannot be empty"),{path:`/versions/${e}/promote`,method:"POST",body:JSON.stringify(o?{mainHash:t,fields:o}:{mainHash:t})});var H={},xp=(e={})=>t=>{let o={...H,...e};return{async request(s){let a=s();if(a.headers||(a.headers={}),"Content-Type"in a.headers?a.headers["Content-Type"]==="multipart/form-data"&&delete a.headers["Content-Type"]:a.headers["Content-Type"]="application/json","getToken"in this){let h=await this.getToken();h&&(a.headers||(a.headers={}),a.headers.Authorization=`Bearer ${h}`)}let p=j(t.url,a.path,a.params),c={method:a.method??"GET",headers:a.headers??{}};"credentials"in o&&(c.credentials=o.credentials),a.body&&(c.body=a.body),a.onRequest&&(c=await a.onRequest(c)),o.onRequest&&(c=await o.onRequest(c));let i=await R(p.toString(),c,t.globals.fetch);return"onResponse"in a&&(i=await a.onResponse(i,c)),"onResponse"in e&&(i=await e.onResponse(i,c)),i}}};function bp(e,t){return()=>{let o=e();return typeof t=="function"?o.onRequest=t:o.onRequest=s=>({...s,...t}),o}}function jp(e){return()=>{let t=e();return t.method==="GET"&&t.params&&(t.method="SEARCH",t.body=JSON.stringify({query:{...t.params,fields:w(t.params.fields??[])}}),delete t.params),t}}function gp(e,t){return()=>{let o=t();return e&&(o.headers||(o.headers={}),o.headers.Authorization=`Bearer ${e}`),o}}export{Wi as acceptUserInvite,Fs as aggregate,E as auth,wi as authenticateShare,re as authentication,bi as clearCache,_i as compareContentVersion,it as createCollection,nt as createComment,sr as createContentVersion,or as createContentVersions,ht as createDashboard,dt as createDashboards,pe as createDirectus,yt as createField,bt as createFlow,Qt as createFlows,jt as createFolder,Ct as createFolders,Dt as createItem,gt as createItems,It as createNotification,Pt as createNotifications,At as createOperation,Et as createOperations,vt as createPanel,Nt as createPanels,$t as createPermission,Jt as createPermissions,Kt as createPreset,Wt as createPresets,Lt as createRelation,Mt as createRole,Vt as createRoles,qt as createShare,Bt as createShares,Yt as createTranslation,Xt as createTranslations,tr as createUser,er as createUsers,nr as createWebhook,mr as createWebhooks,Ar as deleteCollection,Fr as deleteComment,Yo as deleteContentVersion,Xo as deleteContentVersions,Lr as deleteDashboard,Gr as deleteDashboards,Mr as deleteField,zr as deleteFile,qr as deleteFiles,eo as deleteFlow,Zr as deleteFlows,so as deleteFolder,oo as deleteFolders,co as deleteItem,no as deleteItems,uo as deleteNotification,ho as deleteNotifications,fo as deleteOperation,lo as deleteOperations,To as deletePanel,bo as deletePanels,go as deletePermission,Ro as deletePermissions,Io as deletePreset,Po as deletePresets,Ao as deleteRelation,Uo as deleteRole,vo as deleteRoles,Wo as deleteShare,ko as deleteShares,Ho as deleteTranslation,Lo as deleteTranslations,Bo as deleteUser,_o as deleteUsers,rs as deleteWebhook,ts as deleteWebhooks,Li as disableTwoFactor,Gi as enableTwoFactor,w as formatFields,Di as generateHash,Ki as generateTwoFactorSecret,A as generateUid,ye as graphql,ft as importFile,Ni as inviteShare,ki as inviteUser,Ge as login,He as logout,J as memoryStorage,F as messageCallback,Me as passwordRequest,Be as passwordReset,k as pong,Bi as promoteContentVersion,N as queryToParams,Ds as readActivities,Os as readActivity,vs as readAssetArrayBuffer,Ns as readAssetBlob,ws as readAssetRaw,ks as readCollection,$s as readCollections,um as readContentVersion,hm as readContentVersions,Ls as readDashboard,Gs as readDashboards,Vs as readExtensions,zs as readField,Bs as readFields,qs as readFieldsByCollection,ea as readFile,Zs as readFiles,sa as readFlow,oa as readFlows,ca as readFolder,na as readFolders,rn as readGraphqlSdl,ha as readItem,da as readItems,im as readMe,la as readNotification,Sa as readNotifications,cn as readOpenApiSpec,ba as readOperation,Qa as readOperations,Ra as readPanel,ja as readPanels,Pa as readPermission,Oa as readPermissions,Aa as readPreset,Ea as readPresets,ze as readProviders,Ja as readRelation,Ua as readRelationByCollection,va as readRelations,Ka as readRevision,Wa as readRevisions,Va as readRole,Ha as readRoles,_a as readSettings,Xa as readShare,vi as readShareInfo,za as readShares,em as readSingleton,sm as readTranslation,om as readTranslations,cm as readUser,nm as readUsers,fm as readWebhook,lm as readWebhooks,Ie as realtime,Ye as refresh,xp as rest,Mi as saveToContentVersion,Mm as schemaApply,Bm as schemaDiff,zm as schemaSnapshot,sn as serverHealth,mn as serverInfo,dn as serverPing,Ee as sleep,se as staticToken,x as throwIfCoreCollection,r as throwIfEmpty,Ri as triggerFlow,Ei as triggerOperation,jn as updateCollection,bn as updateComment,Hc as updateContentVersion,Lc as updateContentVersions,On as updateDashboard,Dn as updateDashboards,Fn as updateExtension,wn as updateField,Jn as updateFile,Un as updateFiles,Kn as updateFlow,Wn as updateFlows,Vn as updateFolder,Hn as updateFolders,qn as updateItem,Bn as updateItems,Wc as updateMe,Zn as updateNotification,Yn as updateNotifications,oc as updateOperation,rc as updateOperations,nc as updatePanel,mc as updatePanels,dc as updatePermission,pc as updatePermissions,Sc as updatePreset,yc as updatePresets,xc as updateRelation,Cc as updateRole,Tc as updateRoles,Rc as updateSettings,Pc as updateShare,Oc as updateShares,Ec as updateSingleton,vc as updateTranslation,Nc as updateTranslations,kc as updateUser,$c as updateUsers,Bc as updateWebhook,_c as updateWebhooks,lt as uploadFiles,Ji as utilitySort,Ci as utilsExport,Ii as utilsImport,Oi as verifyHash,bp as withOptions,jp as withSearch,gp as withToken};
var I="/",W=(e,t)=>(e.endsWith(I)&&(e=e.slice(0,-1)),t.startsWith(I)||(t=I+t),e+t),j=(e,t,o)=>{let s=e.pathname===I?t:W(e.pathname,t),a=new globalThis.URL(s,e);if(o)for(let[p,i]of Object.entries(N(o)))if(i&&typeof i=="object"&&!Array.isArray(i))for(let[c,h]of Object.entries(i))a.searchParams.set(`${p}[${c}]`,String(h));else a.searchParams.set(p,i);return a};function v(e){return typeof e!="object"||!e?!1:"headers"in e&&"ok"in e&&"json"in e&&typeof e.json=="function"&&"text"in e&&typeof e.json=="function"}async function U(e){if(!(typeof e!="object"||!e)){if(v(e)){let t=e.headers.get("Content-Type")?.toLowerCase();if(t?.startsWith("application/json")||t?.startsWith("application/health+json")){let o=await e.json();if(!e.ok)throw o;return"data"in o?o.data:o}if(t?.startsWith("text/html")||t?.startsWith("text/plain")){let o=await e.text();if(!e.ok)throw o;return o}return e}return"data"in e?e.data:e}}var g=async(e,t,o=globalThis.fetch)=>{t.headers=typeof t.headers=="object"&&!Array.isArray(t.headers)?t.headers:{};let s=await o(e,t);return U(s).catch(a=>{throw{errors:typeof a=="object"&&"errors"in a?a.errors:a,response:s}})};var J=()=>{let e=null;return{get:async()=>e,set:async t=>{e=t}}};var G={msRefreshBeforeExpires:3e4,autoRefresh:!0},ae=(e="cookie",t={})=>o=>{let s={...G,...t},a=null,p=null,i=s.storage??J(),c=()=>{i.set({access_token:null,refresh_token:null,expires:null,expires_at:null})},h=async()=>{try{await a}finally{a=null}},f=async()=>{let y=await i.get();if(a||!y?.expires_at){await h();return}y.expires_at<new Date().getTime()+s.msRefreshBeforeExpires&&b().catch(u=>{}),await h()},R=y=>{let u=y.expires??0;y.expires_at=new Date().getTime()+u,i.set(y),s.autoRefresh&&u>s.msRefreshBeforeExpires&&u<Number.MAX_SAFE_INTEGER&&(p&&clearTimeout(p),p=setTimeout(()=>{p=null,b().catch(Q=>{})},u-s.msRefreshBeforeExpires))},b=async()=>(a=(async()=>{let u=await i.get();c();let Q={method:"POST",headers:{"Content-Type":"application/json"}};"credentials"in s&&(Q.credentials=s.credentials);let m={mode:e};e==="json"&&u?.refresh_token&&(m.refresh_token=u.refresh_token),Q.body=JSON.stringify(m);let n=j(o.url,"/auth/refresh"),d=await g(n.toString(),Q,o.globals.fetch);return R(d),d})().catch(u=>{throw u}),a);return{refresh:b,async login(y,u,Q={}){c();let m=j(o.url,"/auth/login"),n={email:y,password:u};"otp"in Q&&(n.otp=Q.otp),n.mode=Q.mode??e;let d={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)};"credentials"in s&&(d.credentials=s.credentials);let l=await g(m.toString(),d,o.globals.fetch);return R(l),l},async logout(){let y=await i.get(),u={method:"POST",headers:{"Content-Type":"application/json"}};"credentials"in s&&(u.credentials=s.credentials),e==="json"&&y?.refresh_token&&(u.body=JSON.stringify({refresh_token:y.refresh_token}));let Q=j(o.url,"/auth/logout");await g(Q.toString(),u,o.globals.fetch),p&&clearTimeout(p),c()},async getToken(){return await f(),(await i.get())?.access_token??null},setToken(y){i.set({access_token:y,refresh_token:null,expires:null,expires_at:null})}}};var ne=e=>t=>{let o=e??null;return{async getToken(){return o},setToken(s){o=s}}};var $={fetch:globalThis.fetch,WebSocket:globalThis.WebSocket,URL:globalThis.URL,logger:globalThis.console},ue=(e,t={})=>{let o=t.globals?{...$,...t.globals}:$;return{globals:o,url:new o.URL(e),with(s){return{...this,...s(this)}}}};var L={},fe=(e={})=>t=>{let o={...L,...e};return{async query(s,a,p="items"){let i={method:"POST",body:JSON.stringify({query:s,variables:a})};"credentials"in o&&(i.credentials=o.credentials);let c={};if("getToken"in this){let R=await this.getToken();R&&(c.Authorization=`Bearer ${R}`)}"Content-Type"in c||(c["Content-Type"]="application/json"),i.headers=c;let h=p==="items"?"/graphql":"/graphql/system",f=j(t.url,h);return await g(f.toString(),i,t.globals.fetch)}}};function E(e){return JSON.stringify({...e,type:"auth"})}var k=()=>JSON.stringify({type:"pong"});var F=(e,t=1e3)=>new Promise((o,s)=>{let a=h=>{try{let f=JSON.parse(h.data);typeof f=="object"&&!Array.isArray(f)&&f!==null?(i(),o(f)):(i(),p())}catch{i(),o(h)}},p=()=>s(),i=()=>{clearTimeout(c),e.removeEventListener("message",a),e.removeEventListener("error",p),e.removeEventListener("close",p)};e.addEventListener("message",a),e.addEventListener("error",p),e.addEventListener("close",p);let c=setTimeout(()=>{i(),o(void 0)},t)});function*A(){let e=1;for(;;)yield String(e),e++}var H={authMode:"handshake",heartbeat:!0,debug:!1,reconnect:{delay:1e3,retries:10}};function Ae(e={}){return t=>{e={...H,...e};let o=A(),s={code:"closed"},a={attempts:0,active:!1},p=new Set,i=m=>"getToken"in m,c=(m,...n)=>e.debug&&t.globals.logger[m]("[Directus SDK]",...n),h=async(m,n)=>{if(e.authMode==="strict"&&i(n)){let d=await n.getToken();d&&m.searchParams.set("access_token",d)}return m},f=async m=>{if("url"in e)return await h(new t.globals.URL(e.url),m);if(["ws:","wss:"].includes(t.url.protocol))return await h(t.url,m);let n=new t.globals.URL(t.url.toString());return n.protocol=t.url.protocol==="https:"?"wss:":"ws:",n.pathname="/websocket",await h(n,m)},R=m=>{let n=new Promise((d,l)=>{if(!e.reconnect)return l();if(c("info",`reconnect #${a.attempts} `+(a.attempts>=e.reconnect.retries?"maximum retries reached":`trying again in ${Math.max(100,e.reconnect.delay)}ms`)),a.active)return a.active;if(a.attempts>=e.reconnect.retries)return l();setTimeout(()=>m.connect().then(D=>(p.forEach(S=>{m.sendMessage(S)}),D)).then(d).catch(l),Math.max(100,e.reconnect.delay))});a.attempts+=1,a.active=n.catch(()=>{}).finally(()=>{a.active=!1})},b={open:new Set([]),error:new Set([]),close:new Set([]),message:new Set([])};function y(m){return"type"in m&&"status"in m&&"error"in m&&"code"in m.error&&"message"in m.error&&m.type==="auth"&&m.status==="error"}async function u(m,n){if(s.code==="open"){if(m.error.code==="TOKEN_EXPIRED"&&(c("warn","Authentication token expired!"),i(n))){let d=await n.getToken();if(!d)throw Error("No token for re-authenticating the websocket");s.connection.send(E({access_token:d}))}if(m.error.code==="AUTH_TIMEOUT")return s.firstMessage&&e.authMode==="public"?(c("warn",'Authentication failed! Currently the "authMode" is "public" try using "handshake" instead'),e.reconnect=!1):c("warn","Authentication timed out!"),s.connection.close();if(m.error.code==="AUTH_FAILED"){if(s.firstMessage&&e.authMode==="public")return c("warn",'Authentication failed! Currently the "authMode" is "public" try using "handshake" instead'),e.reconnect=!1,s.connection.close();c("warn","Authentication failed!")}}}let Q=async m=>{for(;s.code==="open";){let n=await F(s.connection).catch(()=>{});if(n){if(y(n)){await u(n,m),s.firstMessage=!1;continue}if(e.heartbeat&&n.type==="ping"){s.connection.send(k()),s.firstMessage=!1;continue}b.message.forEach(d=>{s.code==="open"&&d.call(s.connection,n)}),s.firstMessage=!1}}};return{async connect(){if(s.code==="connecting")return await s.connection;if(s.code!=="closed")throw new Error(`Cannot connect when state is "${s.code}"`);let m=this,n=await f(m);c("info",`Connecting to ${n}...`);let d=new Promise((l,D)=>{let S=!1,T=new t.globals.WebSocket(n);T.addEventListener("open",async O=>{if(c("info","Connection open."),e.authMode==="handshake"&&i(m)){let C=await m.getToken();if(!C)throw Error("No token for authenticating the websocket. Make sure to provide one or call the login() function beforehand.");T.send(E({access_token:C}));let P=await F(T);if(P&&"type"in P&&"status"in P&&P.type==="auth"&&P.status==="ok")c("info","Authentication successful!");else return D("Authentication failed while opening websocket connection")}s={code:"open",connection:T,firstMessage:!0},a.attempts=0,a.active=!1,b.open.forEach(C=>C.call(T,O)),Q(m),S=!0,l(T)}),T.addEventListener("error",O=>{c("warn","Connection errored."),b.error.forEach(C=>C.call(T,O)),T.close(),s={code:"error"},S||D(O)}),T.addEventListener("close",O=>{c("info","Connection closed."),b.close.forEach(C=>C.call(T,O)),o=A(),s={code:"closed"},R(this),S||D(O)})});return s={code:"connecting",connection:d},d},disconnect(){s.code==="open"&&s.connection.close()},onWebSocket(m,n){if(m==="message"){let d=function(l){if(typeof l.data!="string")return n.call(this,l);try{return n.call(this,JSON.parse(l.data))}catch{return n.call(this,l)}};return b[m].add(d),()=>b[m].delete(d)}return b[m].add(n),()=>b[m].delete(n)},sendMessage(m){if(s.code!=="open")throw new Error('Cannot send messages without an open connection. Make sure you are calling "await client.connect()".');if(typeof m=="string")return s.connection.send(m);"uid"in m||(m.uid=o.next().value),s.connection.send(JSON.stringify(m))},async subscribe(m,n={}){"uid"in n||(n.uid=o.next().value),p.add({...n,collection:m,type:"subscribe"}),s.code!=="open"&&(c("info","No connection available for subscribing!"),await this.connect()),this.sendMessage({...n,collection:m,type:"subscribe"});let d=!0;async function*l(){for(;d&&s.code==="open";){let S=await F(s.connection).catch(()=>{});if(S){if("type"in S&&"status"in S&&S.type==="subscribe"&&S.status==="error")throw S;"type"in S&&"uid"in S&&S.type==="subscription"&&S.uid===n.uid&&(yield S)}}e.reconnect&&a.active&&(await a.active,s.code==="open"&&(s.connection.send(JSON.stringify({...n,collection:m,type:"subscribe"})),yield*l()))}let D=()=>{p.delete({...n,collection:m,type:"subscribe"}),this.sendMessage({uid:n.uid,type:"unsubscribe"}),d=!1};return{subscription:l(),unsubscribe:D}}}}}var Ne=e=>new Promise(t=>setTimeout(()=>t(),e));var Ve=(e,t,o={})=>()=>{let s={email:e,password:t};return"otp"in o&&(s.otp=o.otp),s.mode=o.mode??"cookie",{path:"/auth/login",method:"POST",body:JSON.stringify(s)}};var _e=e=>()=>({path:"/auth/logout",method:"POST",body:JSON.stringify(e?{refresh_token:e}:{})});var qe=(e,t)=>()=>({path:"/auth/password/request",method:"POST",body:JSON.stringify({email:e,...t?{reset_url:t}:{}})});var Xe=(e,t)=>()=>({path:"/auth/password/reset",method:"POST",body:JSON.stringify({token:e,password:t})});var Ze=()=>()=>({path:"/auth",method:"GET"});var tt=(e="cookie",t)=>()=>({path:"/auth/refresh",method:"POST",body:JSON.stringify(e==="json"?{refresh_token:t,mode:e}:{mode:e})});var pt=(e,t)=>()=>({path:"/activity/comment",params:t??{},body:JSON.stringify(e),method:"POST"});var ht=(e,t)=>()=>({path:"/collections",params:t??{},body:JSON.stringify(e),method:"POST"});var yt=(e,t)=>()=>({path:"/dashboards",params:t??{},body:JSON.stringify(e),method:"POST"}),St=(e,t)=>()=>({path:"/dashboards",params:t??{},body:JSON.stringify(e),method:"POST"});var ft=(e,t,o)=>()=>({path:`/fields/${e}`,params:o??{},body:JSON.stringify(t),method:"POST"});var bt=(e,t)=>()=>({path:"/files",method:"POST",body:e,params:t??{},headers:{"Content-Type":"multipart/form-data"}}),Qt=(e,t={},o)=>()=>({path:"/files/import",method:"POST",body:JSON.stringify({url:e,data:t}),params:o??{}});var Ct=(e,t)=>()=>({path:"/flows",params:t??{},body:JSON.stringify(e),method:"POST"}),jt=(e,t)=>()=>({path:"/flows",params:t??{},body:JSON.stringify(e),method:"POST"});var Rt=(e,t)=>()=>({path:"/folders",params:t??{},body:JSON.stringify(e),method:"POST"}),Dt=(e,t)=>()=>({path:"/folders",params:t??{},body:JSON.stringify(e),method:"POST"});import{isSystemCollection as K}from"@directus/system-data";var It=(e,t,o)=>()=>{let s=String(e);if(K(s))throw new Error("Cannot use createItems for core collections");return{path:`/items/${s}`,params:o??{},body:JSON.stringify(t),method:"POST"}},Ft=(e,t,o)=>()=>{let s=String(e);if(K(s))throw new Error("Cannot use createItem for core collections");return{path:`/items/${s}`,params:o??{},body:JSON.stringify(t),method:"POST"}};var At=(e,t)=>()=>({path:"/notifications",params:t??{},body:JSON.stringify(e),method:"POST"}),wt=(e,t)=>()=>({path:"/notifications",params:t??{},body:JSON.stringify(e),method:"POST"});var vt=(e,t)=>()=>({path:"/operations",params:t??{},body:JSON.stringify(e),method:"POST"}),Ut=(e,t)=>()=>({path:"/operations",params:t??{},body:JSON.stringify(e),method:"POST"});var $t=(e,t)=>()=>({path:"/panels",params:t??{},body:JSON.stringify(e),method:"POST"}),kt=(e,t)=>()=>({path:"/panels",params:t??{},body:JSON.stringify(e),method:"POST"});var Wt=(e,t)=>()=>({path:"/permissions",params:t??{},body:JSON.stringify(e),method:"POST"}),Gt=(e,t)=>()=>({path:"/permissions",params:t??{},body:JSON.stringify(e),method:"POST"});var Ht=(e,t)=>()=>({path:"/presets",params:t??{},body:JSON.stringify(e),method:"POST"}),Vt=(e,t)=>()=>({path:"/presets",params:t??{},body:JSON.stringify(e),method:"POST"});var _t=e=>()=>({path:"/relations",body:JSON.stringify(e),method:"POST"});var qt=(e,t)=>()=>({path:"/roles",params:t??{},body:JSON.stringify(e),method:"POST"}),zt=(e,t)=>()=>({path:"/roles",params:t??{},body:JSON.stringify(e),method:"POST"});var Yt=(e,t)=>()=>({path:"/shares",params:t??{},body:JSON.stringify(e),method:"POST"}),Zt=(e,t)=>()=>({path:"/shares",params:t??{},body:JSON.stringify(e),method:"POST"});var tr=(e,t)=>()=>({path:"/translations",params:t??{},body:JSON.stringify(e),method:"POST"}),rr=(e,t)=>()=>({path:"/translations",params:t??{},body:JSON.stringify(e),method:"POST"});var sr=(e,t)=>()=>({path:"/users",params:t??{},body:JSON.stringify(e),method:"POST"}),ar=(e,t)=>()=>({path:"/users",params:t??{},body:JSON.stringify(e),method:"POST"});var nr=(e,t)=>()=>({path:"/versions",params:t??{},body:JSON.stringify(e),method:"POST"}),ir=(e,t)=>()=>({path:"/versions",params:t??{},body:JSON.stringify(e),method:"POST"});var pr=(e,t)=>()=>({path:"/webhooks",params:t??{},body:JSON.stringify(e),method:"POST"}),dr=(e,t)=>()=>({path:"/webhooks",params:t??{},body:JSON.stringify(e),method:"POST"});var Nr=e=>()=>({path:`/activity/comment/${e}`,method:"DELETE"});var Ur=e=>()=>({path:`/collections/${e}`,method:"DELETE"});var w=e=>{let t=(o,s=[])=>{if(typeof o=="object"){let a=[];for(let p in o){let i=o[p]??[];if(Array.isArray(i))for(let c of i)a.push(t(c,[...s,p]));else if(typeof i=="object")for(let c of Object.keys(i)){let h=i[c];for(let f of h)a.push(t(f,[...s,`${p}:${c}`]))}}return a.flatMap(p=>p)}return[...s,String(o)].join(".")};return e.flatMap(o=>t(o))},N=e=>{let t={};Array.isArray(e.fields)&&e.fields.length>0&&(t.fields=w(e.fields).join(",")),e.filter&&Object.keys(e.filter).length>0&&(t.filter=JSON.stringify(e.filter)),e.search&&(t.search=e.search),"sort"in e&&e.sort&&(t.sort=typeof e.sort=="string"?e.sort:e.sort.join(",")),typeof e.limit=="number"&&e.limit>=-1&&(t.limit=String(e.limit)),typeof e.offset=="number"&&e.offset>=0&&(t.offset=String(e.offset)),typeof e.page=="number"&&e.page>=1&&(t.page=String(e.page)),e.deep&&Object.keys(e.deep).length>0&&(t.deep=JSON.stringify(e.deep)),e.alias&&Object.keys(e.alias).length>0&&(t.alias=JSON.stringify(e.alias)),e.aggregate&&Object.keys(e.aggregate).length>0&&(t.aggregate=JSON.stringify(e.aggregate)),e.groupBy&&e.groupBy.length>0&&(t.groupBy=e.groupBy.join(","));for(let[o,s]of Object.entries(e))o in t||(typeof s=="string"||typeof s=="number"||typeof s=="boolean"?t[o]=String(s):t[o]=JSON.stringify(s));return t};var r=(e,t)=>{if(e.length===0)throw new Error(t)};import{isSystemCollection as V}from"@directus/system-data";var x=(e,t)=>{if(V(String(e)))throw new Error(t)};var _r=e=>()=>(r(e,"Keys cannot be empty"),{path:"/dashboards",body:JSON.stringify(e),method:"DELETE"}),Br=e=>()=>(r(e,"Key cannot be empty"),{path:`/dashboards/${e}`,method:"DELETE"});var Xr=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/fields/${e}/${t}`,method:"DELETE"});var eo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/files",body:JSON.stringify(e),method:"DELETE"}),to=e=>()=>(r(e,"Key cannot be empty"),{path:`/files/${e}`,method:"DELETE"});var so=e=>()=>(r(e,"Keys cannot be empty"),{path:"/flows",body:JSON.stringify(e),method:"DELETE"}),ao=e=>()=>(r(e,"Key cannot be empty"),{path:`/flows/${e}`,method:"DELETE"});var io=e=>()=>(r(e,"Keys cannot be empty"),{path:"/folders",body:JSON.stringify(e),method:"DELETE"}),co=e=>()=>(r(e,"Key cannot be empty"),{path:`/folders/${e}`,method:"DELETE"});var uo=(e,t)=>()=>{let o={};return r(String(e),"Collection cannot be empty"),x(e,"Cannot use deleteItems for core collections"),Array.isArray(t)?(r(t,"keysOrQuery cannot be empty"),o={keys:t}):(r(Object.keys(t),"keysOrQuery cannot be empty"),o={query:t}),{path:`/items/${e}`,body:JSON.stringify(o),method:"DELETE"}},yo=(e,t)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use deleteItem for core collections"),r(String(t),"Key cannot be empty"),{path:`/items/${e}/${t}`,method:"DELETE"});var fo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/notifications",body:JSON.stringify(e),method:"DELETE"}),xo=e=>()=>(r(e,"Key cannot be empty"),{path:`/notifications/${e}`,method:"DELETE"});var To=e=>()=>(r(e,"Keys cannot be empty"),{path:"/operations",body:JSON.stringify(e),method:"DELETE"}),Co=e=>()=>(r(e,"Key cannot be empty"),{path:`/operations/${e}`,method:"DELETE"});var Ro=e=>()=>(r(e,"Keys cannot be empty"),{path:"/panels",body:JSON.stringify(e),method:"DELETE"}),Do=e=>()=>(r(e,"Key cannot be empty"),{path:`/panels/${e}`,method:"DELETE"});var Io=e=>()=>(r(e,"Keys cannot be empty"),{path:"/permissions",body:JSON.stringify(e),method:"DELETE"}),Fo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/permissions/${e}`,method:"DELETE"});var wo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/presets",body:JSON.stringify(e),method:"DELETE"}),No=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/presets/${e}`,method:"DELETE"});var Jo=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/relations/${e}/${t}`,method:"DELETE"});var Ko=e=>()=>(r(e,"Keys cannot be empty"),{path:"/roles",body:JSON.stringify(e),method:"DELETE"}),Wo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/roles/${e}`,method:"DELETE"});var Ho=e=>()=>(r(e,"Keys cannot be empty"),{path:"/shares",body:JSON.stringify(e),method:"DELETE"}),Vo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/shares/${e}`,method:"DELETE"});var Bo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/translations",body:JSON.stringify(e),method:"DELETE"}),qo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/translations/${e}`,method:"DELETE"});var Yo=e=>()=>(r(e,"Keys cannot be empty"),{path:"/users",body:JSON.stringify(e),method:"DELETE"}),Zo=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/users/${e}`,method:"DELETE"});var rs=e=>()=>(r(e,"Keys cannot be empty"),{path:"/versions",body:JSON.stringify(e),method:"DELETE"}),os=e=>()=>(r(e,"Key cannot be empty"),{path:`/versions/${e}`,method:"DELETE"});var ms=e=>()=>(r(e,"Keys cannot be empty"),{path:"/webhooks",body:JSON.stringify(e),method:"DELETE"}),ns=e=>()=>(r(String(e),"Key cannot be empty"),{path:`/webhooks/${e}`,method:"DELETE"});var Es=e=>()=>({path:"/activity",params:e??{},method:"GET"}),As=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/activity/${e}`,params:t??{},method:"GET"});import{isSystemCollection as M}from"@directus/system-data";var Js=(e,t)=>()=>{let o=String(e);return r(o,"Collection cannot be empty"),{path:M(o)?`/${o.substring(9)}`:`/items/${o}`,method:"GET",params:{...t.query??{},...t.groupBy?{groupBy:t.groupBy}:{},aggregate:t.aggregate}}};var Ks=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/assets/${e}`,params:t??{},method:"GET",onResponse:o=>o.body}),Ws=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/assets/${e}`,params:t??{},method:"GET",onResponse:o=>o.blob()}),Gs=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/assets/${e}`,params:t??{},method:"GET",onResponse:o=>o.arrayBuffer()});var Vs=()=>()=>({path:"/collections",method:"GET"}),Ms=e=>()=>(r(e,"Collection cannot be empty"),{path:`/collections/${e}`,method:"GET"});var qs=e=>()=>({path:"/dashboards",params:e??{},method:"GET"}),zs=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/dashboards/${e}`,params:t??{},method:"GET"});var Ys=()=>()=>({path:"/extensions/",method:"GET"});var ta=()=>()=>({path:"/fields",method:"GET"}),ra=e=>()=>(r(e,"Collection cannot be empty"),{path:`/fields/${e}`,method:"GET"}),oa=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/fields/${e}/${t}`,method:"GET"});var ma=e=>()=>({path:"/files",params:e??{},method:"GET"}),na=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/files/${e}`,params:t??{},method:"GET"});var pa=e=>()=>({path:"/flows",params:e??{},method:"GET"}),da=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/flows/${e}`,params:t??{},method:"GET"});var ya=e=>()=>({path:"/folders",params:e??{},method:"GET"}),Sa=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/folders/${e}`,params:t??{},method:"GET"});var xa=(e,t)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use readItems for core collections"),{path:`/items/${e}`,params:t??{},method:"GET"}),ba=(e,t,o)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use readItem for core collections"),r(String(t),"Key cannot be empty"),{path:`/items/${e}/${t}`,params:o??{},method:"GET"});var Ca=e=>()=>({path:"/notifications",params:e??{},method:"GET"}),ja=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/notifications/${e}`,params:t??{},method:"GET"});var Da=e=>()=>({path:"/operations",params:e??{},method:"GET"}),Oa=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/operations/${e}`,params:t??{},method:"GET"});var Fa=e=>()=>({path:"/panels",params:e??{},method:"GET"}),Ea=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/panels/${e}`,params:t??{},method:"GET"});var Na=e=>()=>({path:"/permissions",params:e??{},method:"GET"}),va=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/permissions/${e}`,params:t??{},method:"GET"}),Ua=(e,t)=>()=>(r(String(e),"Collection cannot be empty"),{path:`/permissions/me/${t?`${e}/${t}`:`${e}`}`,method:"GET"});var ka=e=>()=>({path:"/presets",params:e??{},method:"GET"}),Ka=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/presets/${e}`,params:t??{},method:"GET"});var La=()=>()=>({path:"/relations",method:"GET"}),Ha=e=>()=>({path:`/relations/${e}`,method:"GET"}),Va=(e,t)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/relations/${e}/${t}`,method:"GET"});var Ba=e=>()=>({path:"/revisions",params:e??{},method:"GET"}),qa=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/revisions/${e}`,params:t??{},method:"GET"});var Ya=e=>()=>({path:"/roles",params:e??{},method:"GET"}),Za=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/roles/${e}`,params:t??{},method:"GET"});var tm=e=>()=>({path:"/settings",params:e??{},method:"GET"});var sm=e=>()=>({path:"/shares",params:e??{},method:"GET"}),am=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/shares/${e}`,params:t??{},method:"GET"});var im=(e,t)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use readSingleton for core collections"),{path:`/items/${e}`,params:t??{},method:"GET"});var dm=e=>()=>({path:"/translations",params:e??{},method:"GET"}),hm=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/translations/${e}`,params:t??{},method:"GET"});var Sm=e=>()=>({path:"/users",params:e??{},method:"GET"}),lm=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/users/${e}`,params:t??{},method:"GET"}),fm=e=>()=>({path:"/users/me",params:e??{},method:"GET"});var Qm=e=>()=>({path:"/versions",params:e??{},method:"GET"}),Tm=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/versions/${e}`,params:t??{},method:"GET"});var gm=e=>()=>({path:"/webhooks",params:e??{},method:"GET"}),Rm=(e,t)=>()=>(r(String(e),"Key cannot be empty"),{path:`/webhooks/${e}`,params:t??{},method:"GET"});var en=e=>()=>({method:"POST",path:"/schema/apply",body:JSON.stringify(e)});var rn=(e,t=!1)=>()=>({method:"POST",path:"/schema/diff",params:t?{force:t}:{},body:JSON.stringify(e)});var sn=()=>()=>({method:"GET",path:"/schema/snapshot"});var dn=(e="item")=>()=>({method:"GET",path:e==="item"?"/server/specs/graphql":"/server/specs/graphql/system"});var un=()=>()=>({method:"GET",path:"/server/health"});var Sn=()=>()=>({method:"GET",path:"/server/info"});var fn=()=>()=>({method:"GET",path:"/server/specs/oas"});var bn=()=>()=>({method:"GET",path:"/server/ping"});var Pn=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/activity/comment/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var En=(e,t,o)=>()=>(r(e,"Collection cannot be empty"),{path:`/collections/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Nn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/dashboards",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),vn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/dashboards/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var $n=(e,t,o)=>()=>(e!==null&&r(e,"Bundle cannot be an empty string"),r(t,"Name cannot be empty"),{path:e?`/extensions/${e}/${t}`:`/extensions/${t}`,params:{},body:JSON.stringify(o),method:"PATCH"});var Wn=(e,t,o,s)=>()=>(r(e,"Keys cannot be empty"),r(t,"Field cannot be empty"),{path:`/fields/${e}/${t}`,params:s??{},body:JSON.stringify(o),method:"PATCH"});var Hn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/files",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Vn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),t instanceof FormData?{path:`/files/${e}`,params:o??{},body:t,method:"PATCH",headers:{"Content-Type":"multipart/form-data"}}:{path:`/files/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Bn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/flows",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),qn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/flows/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Yn=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/folders",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Zn=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/folders/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var ri=(e,t,o,s)=>()=>{let a={};return r(String(e),"Collection cannot be empty"),x(e,"Cannot use updateItems for core collections"),Array.isArray(t)?(r(t,"keysOrQuery cannot be empty"),a={keys:t}):(r(Object.keys(t),"keysOrQuery cannot be empty"),a={query:t}),a.data=o,{path:`/items/${e}`,params:s??{},body:JSON.stringify(a),method:"PATCH"}},oi=(e,t,o,s)=>()=>(r(String(t),"Key cannot be empty"),r(String(e),"Collection cannot be empty"),x(e,"Cannot use updateItem for core collections"),{path:`/items/${e}/${t}`,params:s??{},body:JSON.stringify(o),method:"PATCH"});var mi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/notifications",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),ni=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/notifications/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var pi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/operations",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),di=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/operations/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var yi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/panels",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Si=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/panels/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var xi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/permissions",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),bi=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/permissions/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Ci=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/presets",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),ji=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/presets/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Di=(e,t,o,s)=>()=>(r(e,"Collection cannot be empty"),r(t,"Field cannot be empty"),{path:`/relations/${e}/${t}`,params:s??{},body:JSON.stringify(o),method:"PATCH"});var Ii=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/roles",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Fi=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/roles/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Ai=(e,t)=>()=>({path:"/settings",params:t??{},body:JSON.stringify(e),method:"PATCH"});var vi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/shares",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Ui=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/shares/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var ki=(e,t,o)=>()=>(r(String(e),"Collection cannot be empty"),x(e,"Cannot use updateSingleton for core collections"),{path:`/items/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Gi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/translations",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Li=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/translations/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Mi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/users",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),_i=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/users/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"}),Bi=(e,t)=>()=>({path:"/users/me",params:t??{},body:JSON.stringify(e),method:"PATCH"});var Xi=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/versions",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),Yi=(e,t,o)=>()=>(r(e,"Key cannot be empty"),{path:`/versions/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var tc=(e,t,o)=>()=>(r(e,"Keys cannot be empty"),{path:"/webhooks",params:o??{},body:JSON.stringify({keys:e,data:t}),method:"PATCH"}),rc=(e,t,o)=>()=>(r(String(e),"Key cannot be empty"),{path:`/webhooks/${e}`,params:o??{},body:JSON.stringify(t),method:"PATCH"});var Pc=()=>()=>({method:"POST",path:"/utils/cache/clear"});var Fc=(e,t,o,s)=>()=>({method:"POST",path:`/utils/export/${e}`,body:JSON.stringify({format:t,query:o,file:s})});var Ac=(e,t,o)=>()=>e==="GET"?{path:`/flows/trigger/${t}`,params:o??{},method:"GET"}:{path:`/flows/trigger/${t}`,body:JSON.stringify(o??{}),method:"POST"};var Nc=e=>()=>({method:"POST",path:"/utils/hash/generate",body:JSON.stringify({string:e})}),vc=(e,t)=>()=>({method:"POST",path:"/utils/hash/verify",body:JSON.stringify({string:e,hash:t})});var Jc=(e,t)=>()=>({path:`/utils/import/${e}`,method:"POST",body:t,headers:{"Content-Type":"multipart/form-data"}});var kc=(e,t)=>()=>({path:`/operations/trigger/${e}`,body:JSON.stringify(t??{}),method:"POST"});var Wc=(e,t)=>()=>({path:"/shares/auth",method:"POST",body:JSON.stringify({share:e,password:t})}),Gc=(e,t)=>()=>({path:"/shares/invite",method:"POST",body:JSON.stringify({share:e,emails:t})}),Lc=e=>()=>({path:`/shares/info/${e}`,method:"GET"});var Vc=(e,t,o)=>()=>({method:"POST",path:`/utils/sort/${e}`,body:JSON.stringify({item:t,to:o})});var _c=(e,t,o)=>()=>({path:"/users/invite",method:"POST",body:JSON.stringify({email:e,role:t,...o?{invite_url:o}:{}})}),Bc=(e,t)=>()=>({path:"/users/invite/accept",method:"POST",body:JSON.stringify({token:e,password:t})}),qc=e=>()=>({path:"/users/me/tfa/generate",method:"POST",body:JSON.stringify({password:e})}),zc=(e,t)=>()=>({path:"/users/me/tfa/enable",method:"POST",body:JSON.stringify({secret:e,otp:t})}),Xc=e=>()=>({path:"/users/me/tfa/disable",method:"POST",body:JSON.stringify({otp:e})});var ep=(e,t)=>()=>(r(e,"ID cannot be empty"),{path:`/versions/${e}/save`,method:"POST",body:JSON.stringify(t)}),tp=e=>()=>(r(e,"ID cannot be empty"),{path:`/versions/${e}/compare`,method:"GET"}),rp=(e,t,o)=>()=>(r(e,"ID cannot be empty"),{path:`/versions/${e}/promote`,method:"POST",body:JSON.stringify(o?{mainHash:t,fields:o}:{mainHash:t})});var _={},Dp=(e={})=>t=>{let o={..._,...e};return{async request(s){let a=s();if(a.headers||(a.headers={}),"Content-Type"in a.headers?a.headers["Content-Type"]==="multipart/form-data"&&delete a.headers["Content-Type"]:a.headers["Content-Type"]="application/json","getToken"in this){let h=await this.getToken();h&&(a.headers||(a.headers={}),a.headers.Authorization=`Bearer ${h}`)}let p=j(t.url,a.path,a.params),i={method:a.method??"GET",headers:a.headers??{}};"credentials"in o&&(i.credentials=o.credentials),a.body&&(i.body=a.body),a.onRequest&&(i=await a.onRequest(i)),o.onRequest&&(i=await o.onRequest(i));let c=await g(p.toString(),i,t.globals.fetch);return"onResponse"in a&&(c=await a.onResponse(c,i)),"onResponse"in e&&(c=await e.onResponse(c,i)),c}}};function Pp(e,t){return()=>{let o=e();return typeof t=="function"?o.onRequest=t:o.onRequest=s=>({...s,...t}),o}}function Ep(e){return()=>{let t=e();return t.method==="GET"&&t.params&&(t.method="SEARCH",t.body=JSON.stringify({query:{...t.params,fields:w(t.params.fields??[])}}),delete t.params),t}}function wp(e,t){return()=>{let o=t();return e&&(o.headers||(o.headers={}),o.headers.Authorization=`Bearer ${e}`),o}}export{Bc as acceptUserInvite,Js as aggregate,E as auth,Wc as authenticateShare,ae as authentication,Pc as clearCache,tp as compareContentVersion,ht as createCollection,pt as createComment,ir as createContentVersion,nr as createContentVersions,St as createDashboard,yt as createDashboards,ue as createDirectus,ft as createField,jt as createFlow,Ct as createFlows,Dt as createFolder,Rt as createFolders,Ft as createItem,It as createItems,wt as createNotification,At as createNotifications,Ut as createOperation,vt as createOperations,kt as createPanel,$t as createPanels,Gt as createPermission,Wt as createPermissions,Vt as createPreset,Ht as createPresets,_t as createRelation,zt as createRole,qt as createRoles,Zt as createShare,Yt as createShares,rr as createTranslation,tr as createTranslations,ar as createUser,sr as createUsers,dr as createWebhook,pr as createWebhooks,Ur as deleteCollection,Nr as deleteComment,os as deleteContentVersion,rs as deleteContentVersions,Br as deleteDashboard,_r as deleteDashboards,Xr as deleteField,to as deleteFile,eo as deleteFiles,ao as deleteFlow,so as deleteFlows,co as deleteFolder,io as deleteFolders,yo as deleteItem,uo as deleteItems,xo as deleteNotification,fo as deleteNotifications,Co as deleteOperation,To as deleteOperations,Do as deletePanel,Ro as deletePanels,Fo as deletePermission,Io as deletePermissions,No as deletePreset,wo as deletePresets,Jo as deleteRelation,Wo as deleteRole,Ko as deleteRoles,Vo as deleteShare,Ho as deleteShares,qo as deleteTranslation,Bo as deleteTranslations,Zo as deleteUser,Yo as deleteUsers,ns as deleteWebhook,ms as deleteWebhooks,Xc as disableTwoFactor,zc as enableTwoFactor,w as formatFields,Nc as generateHash,qc as generateTwoFactorSecret,A as generateUid,fe as graphql,Qt as importFile,Gc as inviteShare,_c as inviteUser,Ve as login,_e as logout,J as memoryStorage,F as messageCallback,qe as passwordRequest,Xe as passwordReset,k as pong,rp as promoteContentVersion,N as queryToParams,Es as readActivities,As as readActivity,Gs as readAssetArrayBuffer,Ws as readAssetBlob,Ks as readAssetRaw,Ms as readCollection,Vs as readCollections,Tm as readContentVersion,Qm as readContentVersions,zs as readDashboard,qs as readDashboards,Ys as readExtensions,oa as readField,ta as readFields,ra as readFieldsByCollection,na as readFile,ma as readFiles,da as readFlow,pa as readFlows,Sa as readFolder,ya as readFolders,dn as readGraphqlSdl,ba as readItem,Ua as readItemPermissions,xa as readItems,fm as readMe,ja as readNotification,Ca as readNotifications,fn as readOpenApiSpec,Oa as readOperation,Da as readOperations,Ea as readPanel,Fa as readPanels,va as readPermission,Na as readPermissions,Ka as readPreset,ka as readPresets,Ze as readProviders,Va as readRelation,Ha as readRelationByCollection,La as readRelations,qa as readRevision,Ba as readRevisions,Za as readRole,Ya as readRoles,tm as readSettings,am as readShare,Lc as readShareInfo,sm as readShares,im as readSingleton,hm as readTranslation,dm as readTranslations,lm as readUser,Sm as readUsers,Rm as readWebhook,gm as readWebhooks,Ae as realtime,tt as refresh,Dp as rest,ep as saveToContentVersion,en as schemaApply,rn as schemaDiff,sn as schemaSnapshot,un as serverHealth,Sn as serverInfo,bn as serverPing,Ne as sleep,ne as staticToken,x as throwIfCoreCollection,r as throwIfEmpty,Ac as triggerFlow,kc as triggerOperation,En as updateCollection,Pn as updateComment,Yi as updateContentVersion,Xi as updateContentVersions,vn as updateDashboard,Nn as updateDashboards,$n as updateExtension,Wn as updateField,Vn as updateFile,Hn as updateFiles,qn as updateFlow,Bn as updateFlows,Zn as updateFolder,Yn as updateFolders,oi as updateItem,ri as updateItems,Bi as updateMe,ni as updateNotification,mi as updateNotifications,di as updateOperation,pi as updateOperations,Si as updatePanel,yi as updatePanels,bi as updatePermission,xi as updatePermissions,ji as updatePreset,Ci as updatePresets,Di as updateRelation,Fi as updateRole,Ii as updateRoles,Ai as updateSettings,Ui as updateShare,vi as updateShares,ki as updateSingleton,Li as updateTranslation,Gi as updateTranslations,_i as updateUser,Mi as updateUsers,rc as updateWebhook,tc as updateWebhooks,bt as uploadFiles,Vc as utilitySort,Fc as utilsExport,Jc as utilsImport,vc as verifyHash,Pp as withOptions,Ep as withSearch,wp as withToken};
//# sourceMappingURL=index.js.map
{
"name": "@directus/sdk",
"version": "15.0.0",
"version": "15.0.1",
"description": "Directus JavaScript SDK",

@@ -27,5 +27,8 @@ "homepage": "https://directus.io",

],
"dependencies": {
"@directus/system-data": "1.0.0"
},
"devDependencies": {
"@types/node-fetch": "2.6.11",
"tsup": "8.0.1",
"tsup": "8.0.2",
"typescript": "5.3.3",

@@ -32,0 +35,0 @@ "vitest": "1.2.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc