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
133
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.1 to 15.0.2

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,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};
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,t="cookie")=>()=>({path:"/auth/logout",method:"POST",body:JSON.stringify(e?{refresh_token:e,mode:t}:{mode:t})});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.1",
"version": "15.0.2",
"description": "Directus JavaScript SDK",

@@ -17,4 +17,3 @@ "homepage": "https://directus.io",

"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
"require": "./dist/index.cjs"
},

@@ -24,3 +23,2 @@ "./package.json": "./package.json"

"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [

@@ -30,3 +28,3 @@ "dist"

"dependencies": {
"@directus/system-data": "1.0.0"
"@directus/system-data": "1.0.1"
},

@@ -37,3 +35,3 @@ "devDependencies": {

"typescript": "5.3.3",
"vitest": "1.2.2",
"vitest": "1.3.1",
"@directus/tsconfig": "1.0.1"

@@ -40,0 +38,0 @@ },

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