@hostlink/light 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(h,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("json-to-graphql-query"),require("collect.js"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","collect.js","axios"],P):(h=typeof globalThis<"u"?globalThis:h||self,P(h.light={},h.jsonToGraphqlQuery,h.collect,h.axios))})(this,(function(h,P,W,Mt){"use strict";function Q(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.iterator in t?!1:Symbol.toStringTag in t?Object.prototype.toString.call(t)==="[object Module]":!0}function H(t,e,r=".",s){if(!Q(e))return H(t,{},r,s);const n=Object.assign({},e);for(const c in t){if(c==="__proto__"||c==="constructor")continue;const l=t[c];l!=null&&(s&&s(n,c,l,r)||(Array.isArray(l)&&Array.isArray(n[c])?n[c]=[...l,...n[c]]:Q(l)&&Q(n[c])?n[c]=H(l,n[c],(r?`${r}.`:"")+c.toString(),s):n[c]=l))}return n}function jt(t){return(...e)=>e.reduce((r,s)=>H(r,s,"",t),{})}const M=jt();let q=null;const st=t=>{q=t},V=()=>{if(!q)throw new Error("Api client not initialized. Call setApiClient() first.");return q},vt=()=>q;function T(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function X(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&T(t[e]))return!0;return!1}function Et(t){t="<~"+t+"~>";var e,r,s,n,c,l=String,g=255;for(t.slice(0,2)==="<~"&&t.slice(-2),t=t.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),e="uuuuu".slice(t.length%5||5),t+=e,s=[],n=0,c=t.length;c>n;n+=5)r=52200625*(t.charCodeAt(n)-33)+614125*(t.charCodeAt(n+1)-33)+7225*(t.charCodeAt(n+2)-33)+85*(t.charCodeAt(n+3)-33)+(t.charCodeAt(n+4)-33),s.push(g&r>>24,g&r>>16,g&r>>8,g&r);return(function(f,i){for(var o=i;o>0;o--)f.pop()})(s,e.length),l.fromCharCode.apply(l,s)}const Y=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const n=new Uint8Array(e.length);for(let g=0;g<e.length;g++)n[g]=e.charCodeAt(g);const c=new Blob([n],{type:s});return URL.createObjectURL(c)};return{getContent:()=>e,getURL:r,download:s=>{const n=document.createElement("a");n.download=s,n.href=r(),document.body.appendChild(n),n.click(),document.body.removeChild(n)},open:s=>{window.open(r(s),"_blank")}}},Tt=t=>Y(atob(t)),Rt=t=>Y(Et(t));function nt(t,e,r,s,n){if(!(!t||typeof t!="object"))for(let c in t){const l=t[c];if(l&&typeof l=="object"){if("__args"in l){const g=l.__args,f={};Object.entries(g).forEach(([i,o])=>{if(o instanceof Array&&T(o)){f[i]=new P.VariableType(i);let a=0;o.forEach(u=>{u instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+i+"."+a),s.append(n.current.toString(),u),n.current++,a++)}),e[i]="[Upload!]!"}else o instanceof File?(f[i]=new P.VariableType(i),r[n.current]=["variables."+i],s.append(n.current.toString(),o),e[i]="Upload!",n.current++):o instanceof Object&&X(o)?(f[i]={},Object.entries(o).forEach(([a,u])=>{if(u instanceof Array&&T(u)){f[i][a]=new P.VariableType(a);let A=0;u.forEach(_=>{_ instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+a+"."+A),s.append(n.current.toString(),_),n.current++,A++)}),e[a]="[Upload!]!"}else u instanceof File?(f[i][a]=new P.VariableType(a),r[n.current]=["variables."+a],s.append(n.current.toString(),u),e[a]="Upload!",n.current++):f[i][a]=u})):o!=null&&(f[i]=o)}),l.__args=f}nt(l,e,r,s,n)}}}const it=t=>async e=>{const r=e,s=new FormData;let n=!1;const c={},l={};nt(r,c,l,s,{current:0}),n=Object.keys(c).length>0,n&&(r.__variables=c);let f=null;const i={query:r},o=P.jsonToGraphQLQuery(i);if(n?(s.append("map",JSON.stringify(l)),s.append("operations",JSON.stringify({query:o})),f=await t.post("",s)):f=await t.post("",{query:o}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data},F=async t=>it(V().axios)(t);function B(t,e,r=F){let s,n=[],c,l;const g=i=>!i||typeof i!="object"?!1:Object.values(i).some(o=>o&&typeof o=="object"&&Object.keys(o).some(a=>a.startsWith("_"))),f=()=>n.length===0?(n.unshift({}),n[0]):(g(n[0])&&n.unshift({}),n[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const o=await this.limit(1).fetch();return Array.isArray(o)&&o.length>0?o[0]:null},async fetchWithMeta(){let o=await r(this.toQuery(!0));if(l){const a=l.split(".");for(const u of a)o=o[u];return o}return o[`list${t}`]},async fetch(){let o=await r(this.toQuery());if(l){const a=l.split(".");for(const u of a)o=o[u];return o.data}return o[`list${t}`].data},dataPath(i){return i&&typeof i=="string"&&(l=i),this},sort(i){return i&&typeof i=="string"&&(c=i),this},filters(i){return i&&typeof i=="object"&&(n=[i]),this},where(i,o,a){const u=(A,_,m)=>{const U={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[_];U&&n.push({[A]:{[U]:m}})};if(a!==void 0)u(i,String(o),a);else{const A=f(),_=M(A,{[i]:o});n[0]=_}return this},whereContains(i,o){if(i&&typeof i=="string"){const a=f(),u={_contains:o};a[i]?Array.isArray(a[i])?a[i].push(u):a[i]=[a[i],u]:a[i]=[u],n[0]=a}return this},whereIn(i,o){if(i&&typeof i=="string"&&Array.isArray(o)){const a=f(),u={_in:o};a[i]?Array.isArray(a[i])?a[i].push(u):a[i]=[a[i],u]:a[i]=[u],n[0]=a}return this},whereBetween(i,o,a){if(i&&typeof i=="string"){const u=f(),A={_between:[o,a]};u[i]?Array.isArray(u[i])?u[i].push(A):u[i]=[u[i],A]:u[i]=A,n[0]=u}return this},limit(i){return typeof i=="number"&&Number.isFinite(i)&&(s=M(s||{},{limit:i})),this},offset(i){return typeof i=="number"&&Number.isFinite(i)&&(s=M(s||{},{offset:i})),this},toQuery(i=!1){let o;const a=n.length>0&&Object.keys(n[0]||{}).length>0,u=a?1:0,A=n.length>u;a&&A?o=n:A?o=n.slice(u):a&&(o=n[0]);const _=M(c?{sort:c}:{},o?{filters:o}:{}),m={data:{...e}};if(s&&(m.data.__args=s),Object.keys(_).length>0&&(m.__args=_),i&&(m.meta={total:!0,key:!0,name:!0}),l){const O=l.split(".");let U=m;for(let D=O.length-1;D>=0;D--)U={[O[D]]:U};return U}return{[`list${t}`]:m}}}}const Bt="list",Nt=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap","sort"],Lt=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition"];class w{_batchData=null;data_path="";filters;steps;fields;already_limit=!1;already_offset=!1;limit=null;offset=null;_sort=null;_sortDesc=!1;meta={};constructor(e){this.filters={},this.steps=[],this.fields=e}}w.prototype.getQueryPayload=function(){let t={meta:{total:!0,key:!0,name:!0}};return t.__args=this.buildArgs(),t.data=this.fields,t.data.__args=t.data.__args||{},this.limit&&(t.data.__args.limit=this.limit),this.offset&&(t.data.__args.offset=this.offset),{data_path:this.data_path,query:t,steps:this.steps}},w.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},w.prototype.buildArgs=function(){let t={};return Object.keys(this.filters).length>0&&(t.filters=this.filters),this._sort&&(t.sort=this._sort,this._sortDesc&&(t.sort+=":desc")),t},w.prototype.clone=function(){const t=Object.create(this);return t.steps=JSON.parse(JSON.stringify(this.steps)),t.filters=JSON.parse(JSON.stringify(this.filters)),t.fields=JSON.parse(JSON.stringify(this.fields)),t},W().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),w.prototype.fetchData=async function(){try{if(this._batchData){const g=this._batchData;return this.meta=g.meta,W(g.data)}let t={meta:{total:!0,key:!0,name:!0}};t.__args=this.buildArgs(),t.data=this.fields,this.already_limit&&(t.data.__args=t.data.__args||{},t.data.__args.limit=this.limit),this.already_offset&&(t.data.__args=t.data.__args||{},t.data.__args.offset=this.offset);const e=this.data_path.split(".");let r={},s=r,n=e[e.length-1];for(const g of e){if(g===n){s[g]=t;break}s[g]={},s=s[g]}let l=await(this._queryFn||F)(r);for(const g of e)l=l[g];return this.meta=l.meta,W(l.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},w.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},w.prototype.all=async function(){return(await this.processData()).all()};for(const t of Nt)w.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Lt)w.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};w.prototype.average=w.prototype.avg,w.prototype.first=async function(){return this.take(1),(await this.processData()).first()},w.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},w.prototype.where=function(...t){const e=this._handleBatchData("where",t);if(e)return e;if(t.length===2)this.filters[t[0]]=t[1];else if(t.length===3){const r=t[0],s=t[1],n=t[2];switch(s){case"==":this.filters[r]=n;break;case"<":this.filters[r]={lt:n};break;case"<=":this.filters[r]={lte:n};break;case">":this.filters[r]={gt:n};break;case">=":this.filters[r]={gte:n};break;case"!==":this.filters[r]={ne:n};break;default:throw new Error(`Unsupported operator: ${s}`)}}return this},w.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},w.prototype.forPage=function(t,e){return t=Math.max(1,t),this.already_limit?(this.steps.push({type:"forPage",args:[t,e]}),this):(this.limit=e,this.offset=(t-1)*e,this.already_limit=!0,this.already_offset=!0,this)},w.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},w.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},w.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},w.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},w.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},w.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},w.prototype.skip=function(t){if(t<0)throw new Error("Offset must be non-negative");return this.already_offset&&this.steps.push({type:"skip",args:[t]}),this.offset=t,this.already_offset=!0,this},w.prototype.take=function(t){if(t<0)throw new Error("Length must be non-negative");return this.already_limit?(this.steps.push({type:"take",args:[t]}),this):(this.limit=t,this.already_limit=!0,this)},w.prototype.splice=function(t,e){return this.steps.push({type:"splice",args:[t,e]}),this.offset=t,this.limit=e,this.already_limit=!0,this.already_offset=!0,this};const Z=(t,e,r=F)=>{const s=new w(e);return s._queryFn=r,s.data_path=Bt+t,s},ot=(t,e={},r={})=>{const s=r.mutation||p,n=r.createList||B,c=r.createCollection||Z,l=e;let g="list"+t;const f=i=>l[i]?l[i]:null;return{field:f,$fields:l,setDataPath(i){return g=i,g},getDataPath(){return g},gqlFields(i){let o={};for(const a of i)if(typeof a=="string"){const u=f(a);u&&(o=M(o,u.gqlField?typeof u.gqlField=="string"?{[u.gqlField]:!0}:u.gqlField:{[u.name||a]:!0}))}else typeof a=="object"&&(o=M(o,a));return o},update(i,o){return s({["update"+t]:{__args:{id:i,data:o}}}).then(a=>a["update"+t])},async delete(i){return s({["delete"+t]:{__args:{id:i}}}).then(o=>o["delete"+t])},add(i){return s({["add"+t]:{__args:{data:i}}}).then(o=>o["add"+t])},fields(i){let o=[];for(let a of i){const u=f(a);u&&o.push(u)}return o},async get(i,o){const a=c(t,Ot(o));for(const[u,A]of Object.entries(i))a.where(u,"==",A);return await a.first()},list(i){let o=i;const a={};Object.entries(i).forEach(([_])=>{l[_]&&(a[_]=l[_],l[_].gqlField&&(delete o[_],o=M(o,l[_].gqlField)),l[_].gql&&(delete o[_],o=M(o,l[_].gql)))});const u=n(t,o).dataPath(g),A=u.fetch.bind(u);return{...u,async fetch(){return(await A()).map(m=>{const O={...m};return Object.entries(a).forEach(([U,D])=>{D.field&&typeof D.field=="function"&&(O[U]=D.field(m[U],m))}),O})},async fetchFirst(){const m=await u.fetchFirst.bind(u)();if(!m)return m;const O={...m};return Object.entries(a).forEach(([U,D])=>{D.field&&typeof D.field=="function"&&(O[U]=D.field(m[U],m))}),O}}}}},v={},I=(t,e)=>{const r=ot(t,e);return v[t]=r,r},J=t=>v[t]?v[t]:I(t,{}),qt=t=>!!v[t],Jt=()=>Object.keys(v),$t=()=>{Object.keys(v).forEach(t=>delete v[t])},zt=t=>{Object.entries(t).forEach(([e,r])=>{I(e,r)})},Gt=()=>F({app:{permissions:!0}}).then(t=>t.app.permissions),K=(t,e)=>{const r=async()=>{const{app:l}=await t({app:{auth:{webAuthnRequestOptions:!0}}}),g=l.auth.webAuthnRequestOptions,f=PublicKeyCredential.parseRequestOptionsFromJSON(g);return await navigator.credentials.get({publicKey:f})},s=async()=>{const{app:l}=await t({app:{auth:{webAuthnCreationOptions:!0}}}),g=PublicKeyCredential.parseCreationOptionsFromJSON(l.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:g})};return{assertion:r,attestation:s,login:async()=>{const l=await r();return await e({webAuthnAssertion:{__args:{assertion:l.toJSON()}}}).then(g=>g.webAuthnAssertion)},register:async()=>{const l=await s();return await e({webAuthnRegister:{__args:{registration:l.toJSON()}}}).then(g=>g.webAuthnRegister)}}},$=K(F,p),Wt=$.assertion,Qt=$.attestation,Ht=$.login,Vt=$.register,at=Object.freeze(Object.defineProperty({__proto__:null,assertion:Wt,attestation:Qt,createWebAuthn:K,login:Ht,register:Vt},Symbol.toStringTag,{value:"Module"})),lt=(t,e)=>({getCurrentUser:(r=N)=>t({my:r}).then(s=>s.my),login:(r,s,n="")=>e({login:{__args:{username:r,password:s,code:n}}}).then(c=>c.login),logout:()=>e({logout:!0}).then(r=>r.logout),changeExpiredPassword:(r,s,n)=>e({changeExpiredPassword:{__args:{username:r,old_password:s,new_password:n}}}).then(c=>c.changeExpiredPassword),updatePassword:(r,s)=>e({changeUserPassword:{__args:{old_password:r,new_password:s}}}).then(n=>n.changeUserPassword),resetPassword:(r,s,n)=>e({resetPassword:{__args:{jwt:r,password:s,code:n}}}).then(c=>c.resetPassword),forgetPassword:(r,s)=>e({forgetPassword:{__args:{username:r,email:s}}}).then(n=>n.forgetPassword),verifyCode:(r,s)=>e({forgetPasswordVerifyCode:{__args:{jwt:r,code:s}}}).then(n=>n.forgetPasswordVerifyCode),grantedRights:r=>t({my:{grantedRights:{__args:{rights:r}}}}).then(s=>s.my.grantedRights),isGranted:r=>t({my:{granted:{__args:{right:r}}}}).then(s=>s.my.granted),webAuthn:K(t,e),google:{unlink:()=>e({lightAuthUnlinkGoogle:!0}).then(r=>r.lightAuthUnlinkGoogle),login:r=>e({lightAuthLoginGoogle:{__args:{credential:r}}}).then(s=>s.lightAuthLoginGoogle),register:r=>e({lightAuthRegisterGoogle:{__args:{credential:r}}}).then(s=>s.lightAuthRegisterGoogle)},facebook:{unlink:()=>e({lightAuthUnlinkFacebook:!0}).then(r=>r.lightAuthUnlinkFacebook),login:r=>e({lightAuthLoginFacebook:{__args:{access_token:r}}}).then(s=>s.lightAuthLoginFacebook),register:r=>e({lightAuthRegisterFacebook:{__args:{access_token:r}}}).then(s=>s.lightAuthRegisterFacebook)},microsoft:{unlink:()=>e({lightAuthUnlinkMicrosoft:!0}).then(r=>r.lightAuthUnlinkMicrosoft),login:r=>e({lightAuthLoginMicrosoft:{__args:{access_token:r}}}).then(s=>s.lightAuthLoginMicrosoft),register:r=>e({lightAuthRegisterMicrosoft:{__args:{account_id:r}}}).then(s=>s.lightAuthRegisterMicrosoft)}}),ct=(t=N)=>F({my:t}).then(e=>e.my),ut=(t,e,r="")=>p({login:{__args:{username:t,password:e,code:r}}}).then(s=>s.login),ht=()=>p({logout:!0}).then(t=>t.logout),dt=(t,e,r)=>p({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(s=>s.changeExpiredPassword),ft=(t,e)=>p({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),gt=(t,e,r)=>p({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(s=>s.resetPassword),pt=(t,e)=>p({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),_t=(t,e)=>p({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),yt=t=>F({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),wt=t=>F({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),Xt={getCurrentUser:ct,webAuthn:at,google:{unlink:()=>p({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>p({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>p({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>p({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>p({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>p({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>p({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>p({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>p({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:ut,logout:ht,changeExpiredPassword:dt,updatePassword:ft,resetPassword:gt,forgetPassword:pt,verifyCode:_t,grantedRights:wt,isGranted:yt},bt={name:!0,path:!0,size:!0,mime:!0,url:!0},Yt=(t,e,r=bt)=>F({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(s=>s.app.drive.files),Zt=(t,e)=>F({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),It=(t,e=F,r=p)=>({list:(s,n=bt)=>e({app:{drive:{__args:{index:t},files:{__args:{path:s},...n}}}}).then(c=>c.app.drive.files),get:(s,n={name:!0,path:!0,size:!0,mime:!0,url:!0})=>e({app:{drive:{__args:{index:t},file:{__args:{path:s},...n}}}}).then(c=>c.app.drive.file),readFileAsBase64(s){return e({app:{drive:{__args:{index:t},file:{__args:{path:s},base64Content:!0}}}}).then(n=>n.app.drive?.file?.base64Content)},read:async s=>{let n=await e({app:{drive:{__args:{index:t},file:{__args:{path:s},base64Content:!0}}}});if(!n.app.drive.file||!n.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${s}`);return typeof window<"u"&&window.atob?window.atob(n.app.drive.file.base64Content):n.app.drive.file.base64Content},write:(s,n)=>r({lightDriveWriteFile:{__args:{index:t,path:s,content:n}}}).then(c=>c.lightDriveWriteFile),delete:s=>r({lightDriveDeleteFile:{__args:{index:t,path:s}}}).then(n=>n.lightDriveDeleteFile),rename:(s,n)=>r({lightDriveRenameFile:{__args:{index:t,path:s,name:n}}}).then(c=>c.lightDriveRenameFile),move:(s,n)=>r({lightDriveMoveFile:{__args:{index:t,source:s,destination:n}}}).then(c=>c.lightDriveMoveFile)}),mt={name:!0,path:!0},Kt=(t,e,r=mt)=>F({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(s=>s.app.drive.folders),xt=(t,e=F,r=p)=>({list:(s,n=mt)=>e({app:{drive:{__args:{index:t},folders:{__args:{path:s},...n}}}}).then(c=>c.app.drive.folders),create:s=>r({lightDriveCreateFolder:{__args:{index:t,path:s}}}).then(n=>n.lightDriveCreateFolder),delete:s=>r({lightDriveDeleteFolder:{__args:{index:t,path:s}}}).then(n=>n.lightDriveDeleteFolder),rename:(s,n)=>r({lightDriveRenameFolder:{__args:{index:t,path:s,name:n}}}).then(c=>c.lightDriveRenameFolder)}),te=()=>F({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),ee=t=>x(F,p)(t),x=(t,e)=>r=>{const s=It(r,t,e),n=xt(r,t,e);return{folders:n,files:s,listFiles:s.list,getFile:s.get,readFile:s.read,writeFile:s.write,deleteFile:s.delete,renameFile:s.rename,moveFile:s.move,listFolders:n.list,createFolder:n.create,deleteFolder:n.delete,renameFolder:n.rename,uploadTempFile:c=>e({lightDriveUploadTempFile:{__args:{index:r,file:c},name:!0,path:!0,size:!0,mime:!0}}).then(l=>l.lightDriveUploadTempFile)}},N={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},re=t=>p({addUser:{__args:t}}).then(e=>e.addUser),se=t=>p({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),ne=(t=N)=>B("Users",t).dataPath("app.listUser").fetch(),ie=(t,e)=>p({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),Ft=(t,e)=>({list:(r=N)=>e("Users",r).dataPath("app.listUser").fetch(),create:r=>t({addUser:{__args:r}}).then(s=>s.addUser),delete:r=>t({deleteUser:{__args:{id:r}}}).then(s=>s.deleteUser),update:(r,s)=>t({updateUser:{__args:{id:r,data:s}}}).then(n=>n.updateUser)}),tt=t=>e=>t({app:{listConfig:{__args:{filters:{name:e}},data:{name:!0,value:!0}}}}).then(r=>r.app.listConfig.data[0]?.value),oe=tt(F),At={name:!0},ae=(t=At)=>F({app:{roles:t}}).then(e=>e.app.roles),le=(t,e)=>p({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),ce=t=>p({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),Ct=(t,e)=>({list:(r=At)=>t({app:{roles:r}}).then(s=>s.app.roles),create:(r,s)=>e({addRole:{__args:{data:{name:r,childs:s}}}}).then(n=>n.addRole),delete:r=>e({deleteRole:{__args:{name:r}}}).then(s=>s.deleteRole)});function et(t){if(Array.isArray(t))return t.map(e=>et(e)).filter(e=>e!==void 0);if(t!==null&&typeof t=="object"){const e=Object.getPrototypeOf(t);if(e===Object.prototype||e===null)return Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0).map(([r,s])=>[r,et(s)]))}return t}function kt(t,e,r,s,n){if(!(!t||typeof t!="object"))for(let c in t){const l=t[c];if(l&&typeof l=="object"){if("__args"in l){const g=et(l.__args),f={};Object.entries(g).forEach(([i,o])=>{if(o instanceof Array&&T(o)){f[i]=new P.VariableType(i);let a=0;o.forEach(u=>{u instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+i+"."+a),s.append(n.current.toString(),u),n.current++,a++)}),e[i]="[Upload!]!"}else o instanceof File?(f[i]=new P.VariableType(i),r[n.current]=["variables."+i],s.append(n.current.toString(),o),e[i]="Upload!",n.current++):o instanceof Object&&X(o)?(f[i]={},Object.entries(o).forEach(([a,u])=>{if(u instanceof Array&&T(u)){f[i][a]=new P.VariableType(a);let A=0;u.forEach(_=>{_ instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+a+"."+A),s.append(n.current.toString(),_),n.current++,A++)}),e[a]="[Upload!]!"}else u instanceof File?(f[i][a]=new P.VariableType(a),r[n.current]=["variables."+a],s.append(n.current.toString(),u),e[a]="Upload!",n.current++):f[i][a]=u})):o!=null&&(f[i]=o)}),l.__args=f}kt(l,e,r,s,n)}}}const Ut=t=>async e=>{const r=e,s=new FormData;let n=!1;const c={},l={};kt(r,c,l,s,{current:0}),n=Object.keys(c).length>0,n&&(r.__variables=c);let f=null;const i={mutation:r},o=P.jsonToGraphQLQuery(i);if(n?(s.append("map",JSON.stringify(l)),s.append("operations",JSON.stringify({query:o})),f=await t.post("",s)):f=await t.post("",{query:o}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data},p=async t=>Ut(V().axios)(t),ue=(t,e,r)=>p({sendMail:{__args:{email:t,subject:e,message:r}}}).then(s=>s.sendMail),Pt=t=>({send:(e,r,s)=>t({sendMail:{__args:{email:e,subject:r,message:s}}}).then(n=>n.sendMail)}),he=Object.freeze(Object.defineProperty({__proto__:null,createFolder:t=>p({lightFSCreateFolder:{__args:{location:t}}}).then(e=>e.lightFSCreateFolder),deleteFile:t=>p({lightFSDeleteFile:{__args:{location:t}}}).then(e=>e.lightFSDeleteFile),deleteFolder:t=>p({lightFSDeleteFolder:{__args:{location:t}}}).then(e=>e.lightFSDeleteFolder),duplicateFile:t=>p({lightFSDuplicateFile:{__args:{location:t}}}).then(e=>e.lightFSDuplicateFile),exists:t=>F({app:{fs:{exists:{__args:{location:t}}}}}).then(e=>e.app.fs.exists),find:(t,e)=>{const r={};return t&&(r.search=t),e&&(r.label=e),F({app:{fs:{find:{__args:r,__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}}}).then(s=>s.app.fs.find)},list:t=>F({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"Folder",name:!0,location:!0,path:!0,children:{__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}]}}}}).then(r=>r.app.fs.node),listFiles:(t,e,r)=>{const s={location:t};return e&&(s.type=e),r&&(s.search=r),F({app:{fs:{listFiles:{__args:s,name:!0,path:!0,location:!0,size:!0,mimeType:!0,publicUrl:!0,lastModified:!0}}}}).then(n=>n.app.fs.listFiles)},move:(t,e)=>p({lightFSMove:{__args:{from:t,to:e}}}).then(r=>r.lightFSMove),readFile:(t,e="text")=>F({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"File",...e==="text"?{content:!0}:{base64Content:!0}}]}}}}).then(r=>{const s=r.app.fs.node;return s?.__typename==="File"?e==="text"?s.content:s.base64Content:null}),renameFile:(t,e)=>p({lightFSRenameFile:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFile),renameFolder:(t,e)=>p({lightFSRenameFolder:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFolder),uploadBase64:(t,e)=>p({lightFSUploadBase64:{__args:{location:t,base64:e},__typename:!0,name:!0,path:!0,location:!0,__on:[{__typename:"File",size:!0,mimeType:!0,lastModified:!0}]}}).then(r=>r.lightFSUploadBase64),uploadFile:(t,e,r=!1)=>p({lightFSUploadFile:{__args:{location:t,file:e,rename:r}}}).then(s=>s.lightFSUploadFile),uploadTempFile:(t,e)=>p({lightFSUploadTempFile:{__args:{location:t,file:e},name:!0,path:!0,location:!0,size:!0,mimeType:!0}}).then(r=>r.lightFSUploadTempFile),writeFile:(t,e)=>p({lightFSWriteFile:{__args:{location:t,content:e}}}).then(r=>r.lightFSWriteFile)},Symbol.toStringTag,{value:"Module"})),rt=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(rt(r)).forEach(([s,n])=>{e[s]=n})}),e):(Object.entries(t).forEach(([r,s])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=s;return}if(typeof s=="boolean"){e[r]=s;return}e[r]=rt(s)}),e)},Ot=t=>rt(t),de=t=>{const e=typeof window>"u";let r=[],s=null,n=null,c=null,l=null;const g=new Set,f=Mt.create({baseURL:t,withCredentials:!0}),i=async()=>s&&!fe(s)||!n?s:(c??=n().then(d=>(s=d,d)).finally(()=>{c=null}),c);f.interceptors.request.use(async d=>{const y=await i();return y&&(d.headers.Authorization=`Bearer ${y}`),d});let o=!1,a=[];const u=(d,y=null)=>{a.forEach(b=>{d?b.reject(d):b.resolve(y)}),a=[]};f.interceptors.response.use(d=>{const y=d.data.errors;if(y&&y.some(b=>b.extensions?.code==="TOKEN_EXPIRED")){const b=d.config;return b._lightTokenRetried?d:(b._lightTokenRetried=!0,n&&(s=null),o?new Promise((C,k)=>{a.push({resolve:C,reject:k})}).then(()=>f(b)).catch(C=>Promise.reject(C)):(o=!0,A().then(()=>(o=!1,u(null),f(b))).catch(C=>(o=!1,u(C),Promise.reject(C)))))}return d},d=>Promise.reject(d));function A(){return n?i().then(()=>{}):f.post("/refresh_token")}e&&(f.interceptors.request.use(d=>(d.withCredentials=!0,r.length>0&&(d.headers.Cookie=r.join("; ")),d)),f.interceptors.response.use(d=>{if(d.headers["set-cookie"]){const y=d.headers["set-cookie"].map(C=>C.split(";")[0]),b=new Map;r.forEach(C=>{const k=C.split("=")[0];b.set(k,C)}),y.forEach(C=>{const k=C.split("=")[0];b.set(k,C)}),r=Array.from(b.values())}return d}));const _=it(f),m=Ut(f),O=(d,y)=>B(d,y,_),U=(d,y)=>Z(d,y,_),D=d=>{const y=J(d),b=ot(d,y.$fields,{mutation:m,createList:O,createCollection:U});return b.setDataPath(y.getDataPath()),b},S=lt(_,m),Dt=()=>g.forEach(d=>d()),L=d=>(async(...y)=>{const b=await d(...y);return Dt(),b}),pe={...S,login:L(S.login),logout:(async()=>{try{return await S.logout()}finally{Dt()}}),google:{...S.google,login:L(S.google.login)},facebook:{...S.facebook,login:L(S.facebook.login)},microsoft:{...S.microsoft,login:L(S.microsoft.login)},webAuthn:{...S.webAuthn,login:L(S.webAuthn.login)}},St={post:f.post.bind(f),baseURL:t,axios:f,setAccessToken(d){s=d},getAccessToken(){return s},clearAccessToken(){s=null},setAccessTokenProvider(d){l?.(),l=null,n=d,s=null,c=null},onAuthChange(d){return g.add(d),()=>g.delete(d)},useAudience(d,y){l?.(),n=async()=>(await d.mutation({createAudienceAccessToken:{__args:{audience:y}}})).createAudienceAccessToken,s=null,c=null,l=d.onAuthChange(()=>{s=null,c=null})},auth:pe,mutation:m,query:_,config:tt(_),mail:Pt(m),users:Ft(m,O),model(d){return D(d)},roles:Ct(_,m),collect:(d,y)=>{const b=U(d,y);return b.data_path=J(d).getDataPath(),b},list:(d,y)=>O(d,y).dataPath(J(d).getDataPath()),drive:x(_,m),async collects(d){const y={},b={};for(const k in d){const E=d[k].getQueryPayload();b[k]=E.data_path,y[k]={};const R=E.data_path.split(".");let z=R[R.length-1],j=y[k];for(const G of R){if(G===z){j[G]=E.query;break}j[G]=j[G]||{}}y[k].__aliasFor=R[0]}const C=await _(y);for(const k in d){const E=b[k].split(".");let R=E[E.length-1],z=C[k];for(const j of E){if(j===R){d[k]._batchData=C[k][j];break}z[j]=z[j]||{}}}return d}};return st(St),St};function fe(t,e=30){try{const r=t.split(".")[1];if(!r)return!0;const s=r.replace(/-/g,"+").replace(/_/g,"/"),n=s.padEnd(Math.ceil(s.length/4)*4,"="),c=JSON.parse(globalThis.atob(n));return typeof c.exp=="number"?c.exp<=Math.floor(Date.now()/1e3)+e:!1}catch{return!0}}const ge=B;h.arrayHasFile=T,h.auth=Xt,h.changeExpiredPassword=dt,h.clearModels=$t,h.createAuth=lt,h.createClient=de,h.createCollection=Z,h.createConfig=tt,h.createDrive=x,h.createFileFromBase64=Tt,h.createFileFromBase85=Rt,h.createFileFromString=Y,h.createList=B,h.createMail=Pt,h.createRole=le,h.createRoles=Ct,h.createUser=re,h.createUsers=Ft,h.defaultUserFields=N,h.defineModel=I,h.defineModels=zt,h.deleteRole=ce,h.deleteUser=se,h.forgetPassword=pt,h.fs=he,h.getApiClient=V,h.getApiClientOptional=vt,h.getConfig=oe,h.getCurrentUser=ct,h.getDrive=ee,h.getGrantedRights=wt,h.getModel=J,h.hasModel=qt,h.isGranted=yt,h.list=ge,h.listDrives=te,h.listFiles=Yt,h.listFolders=Kt,h.listModels=Jt,h.listPermissions=Gt,h.listRoles=ae,h.listUsers=ne,h.login=ut,h.logout=ht,h.mutation=p,h.objectHasFile=X,h.query=F,h.readFileAsBase64=Zt,h.resetPassword=gt,h.sendMail=ue,h.setApiClient=st,h.toQuery=Ot,h.updatePassword=ft,h.updateUser=ie,h.verifyCode=_t,h.webAuthn=at,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(u,U){typeof exports=="object"&&typeof module<"u"?U(exports,require("json-to-graphql-query"),require("collect.js"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","collect.js","axios"],U):(u=typeof globalThis<"u"?globalThis:u||self,U(u.light={},u.jsonToGraphqlQuery,u.collect,u.axios))})(this,(function(u,U,Q,Ot){"use strict";function H(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.iterator in t?!1:Symbol.toStringTag in t?Object.prototype.toString.call(t)==="[object Module]":!0}function V(t,e,r=".",s){if(!H(e))return V(t,{},r,s);const n=Object.assign({},e);for(const g in t){if(g==="__proto__"||g==="constructor")continue;const c=t[g];c!=null&&(s&&s(n,g,c,r)||(Array.isArray(c)&&Array.isArray(n[g])?n[g]=[...c,...n[g]]:H(c)&&H(n[g])?n[g]=V(c,n[g],(r?`${r}.`:"")+g.toString(),s):n[g]=c))}return n}function St(t){return(...e)=>e.reduce((r,s)=>V(r,s,"",t),{})}const M=St();let J=null;const rt=t=>{J=t},v=()=>{if(!J)throw new Error("Api client not initialized. Call setApiClient() first.");return J},jt=()=>J;function R(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function X(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&R(t[e]))return!0;return!1}function Mt(t){t="<~"+t+"~>";var e,r,s,n,g,c=String,d=255;for(t.slice(0,2)==="<~"&&t.slice(-2),t=t.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),e="uuuuu".slice(t.length%5||5),t+=e,s=[],n=0,g=t.length;g>n;n+=5)r=52200625*(t.charCodeAt(n)-33)+614125*(t.charCodeAt(n+1)-33)+7225*(t.charCodeAt(n+2)-33)+85*(t.charCodeAt(n+3)-33)+(t.charCodeAt(n+4)-33),s.push(d&r>>24,d&r>>16,d&r>>8,d&r);return(function(f,o){for(var i=o;i>0;i--)f.pop()})(s,e.length),c.fromCharCode.apply(c,s)}const Y=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const n=new Uint8Array(e.length);for(let d=0;d<e.length;d++)n[d]=e.charCodeAt(d);const g=new Blob([n],{type:s});return URL.createObjectURL(g)};return{getContent:()=>e,getURL:r,download:s=>{const n=document.createElement("a");n.download=s,n.href=r(),document.body.appendChild(n),n.click(),document.body.removeChild(n)},open:s=>{window.open(r(s),"_blank")}}},Et=t=>Y(atob(t)),Dt=t=>Y(Mt(t));function st(t,e,r,s,n){if(!(!t||typeof t!="object"))for(let g in t){const c=t[g];if(c&&typeof c=="object"){if("__args"in c){const d=c.__args,f={};Object.entries(d).forEach(([o,i])=>{if(i instanceof Array&&R(i)){f[o]=new U.VariableType(o);let a=0;i.forEach(l=>{l instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+o+"."+a),s.append(n.current.toString(),l),n.current++,a++)}),e[o]="[Upload!]!"}else i instanceof File?(f[o]=new U.VariableType(o),r[n.current]=["variables."+o],s.append(n.current.toString(),i),e[o]="Upload!",n.current++):i instanceof Object&&X(i)?(f[o]={},Object.entries(i).forEach(([a,l])=>{if(l instanceof Array&&R(l)){f[o][a]=new U.VariableType(a);let A=0;l.forEach(_=>{_ instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+a+"."+A),s.append(n.current.toString(),_),n.current++,A++)}),e[a]="[Upload!]!"}else l instanceof File?(f[o][a]=new U.VariableType(a),r[n.current]=["variables."+a],s.append(n.current.toString(),l),e[a]="Upload!",n.current++):f[o][a]=l})):i!=null&&(f[o]=i)}),c.__args=f}st(c,e,r,s,n)}}}const nt=t=>async e=>{const r=e,s=new FormData;let n=!1;const g={},c={};st(r,g,c,s,{current:0}),n=Object.keys(g).length>0,n&&(r.__variables=g);let f=null;const o={query:r},i=U.jsonToGraphQLQuery(o);if(n?(s.append("map",JSON.stringify(c)),s.append("operations",JSON.stringify({query:i})),f=await t.post("",s)):f=await t.post("",{query:i}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data},k=async t=>nt(v().axios)(t);function N(t,e,r=k){let s,n=[],g,c;const d=o=>!o||typeof o!="object"?!1:Object.values(o).some(i=>i&&typeof i=="object"&&Object.keys(i).some(a=>a.startsWith("_"))),f=()=>n.length===0?(n.unshift({}),n[0]):(d(n[0])&&n.unshift({}),n[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const i=await this.limit(1).fetch();return Array.isArray(i)&&i.length>0?i[0]:null},async fetchWithMeta(){let i=await r(this.toQuery(!0));if(c){const a=c.split(".");for(const l of a)i=i[l];return i}return i[`list${t}`]},async fetch(){let i=await r(this.toQuery());if(c){const a=c.split(".");for(const l of a)i=i[l];return i.data}return i[`list${t}`].data},dataPath(o){return o&&typeof o=="string"&&(c=o),this},sort(o){return o&&typeof o=="string"&&(g=o),this},filters(o){return o&&typeof o=="object"&&(n=[o]),this},where(o,i,a){const l=(A,_,m)=>{const P={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[_];P&&n.push({[A]:{[P]:m}})};if(a!==void 0)l(o,String(i),a);else{const A=f(),_=M(A,{[o]:i});n[0]=_}return this},whereContains(o,i){if(o&&typeof o=="string"){const a=f(),l={_contains:i};a[o]?Array.isArray(a[o])?a[o].push(l):a[o]=[a[o],l]:a[o]=[l],n[0]=a}return this},whereIn(o,i){if(o&&typeof o=="string"&&Array.isArray(i)){const a=f(),l={_in:i};a[o]?Array.isArray(a[o])?a[o].push(l):a[o]=[a[o],l]:a[o]=[l],n[0]=a}return this},whereBetween(o,i,a){if(o&&typeof o=="string"){const l=f(),A={_between:[i,a]};l[o]?Array.isArray(l[o])?l[o].push(A):l[o]=[l[o],A]:l[o]=A,n[0]=l}return this},limit(o){return typeof o=="number"&&Number.isFinite(o)&&(s=M(s||{},{limit:o})),this},offset(o){return typeof o=="number"&&Number.isFinite(o)&&(s=M(s||{},{offset:o})),this},toQuery(o=!1){let i;const a=n.length>0&&Object.keys(n[0]||{}).length>0,l=a?1:0,A=n.length>l;a&&A?i=n:A?i=n.slice(l):a&&(i=n[0]);const _=M(g?{sort:g}:{},i?{filters:i}:{}),m={data:{...e}};if(s&&(m.data.__args=s),Object.keys(_).length>0&&(m.__args=_),o&&(m.meta={total:!0,key:!0,name:!0}),c){const O=c.split(".");let P=m;for(let S=O.length-1;S>=0;S--)P={[O[S]]:P};return P}return{[`list${t}`]:m}}}}const Tt="list",Rt=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap","sort"],Bt=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition"];class w{_batchData=null;data_path="";filters;steps;fields;already_limit=!1;already_offset=!1;limit=null;offset=null;_sort=null;_sortDesc=!1;meta={};constructor(e){this.filters={},this.steps=[],this.fields=e}}w.prototype.getQueryPayload=function(){let t={meta:{total:!0,key:!0,name:!0}};return t.__args=this.buildArgs(),t.data=this.fields,t.data.__args=t.data.__args||{},this.limit&&(t.data.__args.limit=this.limit),this.offset&&(t.data.__args.offset=this.offset),{data_path:this.data_path,query:t,steps:this.steps}},w.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},w.prototype.buildArgs=function(){let t={};return Object.keys(this.filters).length>0&&(t.filters=this.filters),this._sort&&(t.sort=this._sort,this._sortDesc&&(t.sort+=":desc")),t},w.prototype.clone=function(){const t=Object.create(this);return t.steps=JSON.parse(JSON.stringify(this.steps)),t.filters=JSON.parse(JSON.stringify(this.filters)),t.fields=JSON.parse(JSON.stringify(this.fields)),t},Q().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),w.prototype.fetchData=async function(){try{if(this._batchData){const d=this._batchData;return this.meta=d.meta,Q(d.data)}let t={meta:{total:!0,key:!0,name:!0}};t.__args=this.buildArgs(),t.data=this.fields,this.already_limit&&(t.data.__args=t.data.__args||{},t.data.__args.limit=this.limit),this.already_offset&&(t.data.__args=t.data.__args||{},t.data.__args.offset=this.offset);const e=this.data_path.split(".");let r={},s=r,n=e[e.length-1];for(const d of e){if(d===n){s[d]=t;break}s[d]={},s=s[d]}let c=await(this._queryFn||k)(r);for(const d of e)c=c[d];return this.meta=c.meta,Q(c.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},w.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},w.prototype.all=async function(){return(await this.processData()).all()};for(const t of Rt)w.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Bt)w.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};w.prototype.average=w.prototype.avg,w.prototype.first=async function(){return this.take(1),(await this.processData()).first()},w.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},w.prototype.where=function(...t){const e=this._handleBatchData("where",t);if(e)return e;if(t.length===2)this.filters[t[0]]=t[1];else if(t.length===3){const r=t[0],s=t[1],n=t[2];switch(s){case"==":this.filters[r]=n;break;case"<":this.filters[r]={lt:n};break;case"<=":this.filters[r]={lte:n};break;case">":this.filters[r]={gt:n};break;case">=":this.filters[r]={gte:n};break;case"!==":this.filters[r]={ne:n};break;default:throw new Error(`Unsupported operator: ${s}`)}}return this},w.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},w.prototype.forPage=function(t,e){return t=Math.max(1,t),this.already_limit?(this.steps.push({type:"forPage",args:[t,e]}),this):(this.limit=e,this.offset=(t-1)*e,this.already_limit=!0,this.already_offset=!0,this)},w.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},w.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},w.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},w.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},w.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},w.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},w.prototype.skip=function(t){if(t<0)throw new Error("Offset must be non-negative");return this.already_offset&&this.steps.push({type:"skip",args:[t]}),this.offset=t,this.already_offset=!0,this},w.prototype.take=function(t){if(t<0)throw new Error("Length must be non-negative");return this.already_limit?(this.steps.push({type:"take",args:[t]}),this):(this.limit=t,this.already_limit=!0,this)},w.prototype.splice=function(t,e){return this.steps.push({type:"splice",args:[t,e]}),this.offset=t,this.limit=e,this.already_limit=!0,this.already_offset=!0,this};const Z=(t,e,r=k)=>{const s=new w(e);return s._queryFn=r,s.data_path=Tt+t,s},ot=(t,e={},r={})=>{const s=r.mutation||p,n=r.createList||N,g=r.createCollection||Z,c=e;let d="list"+t;const f=o=>c[o]?c[o]:null;return{field:f,$fields:c,setDataPath(o){return d=o,d},getDataPath(){return d},gqlFields(o){let i={};for(const a of o)if(typeof a=="string"){const l=f(a);l&&(i=M(i,l.gqlField?typeof l.gqlField=="string"?{[l.gqlField]:!0}:l.gqlField:{[l.name||a]:!0}))}else typeof a=="object"&&(i=M(i,a));return i},update(o,i){return s({["update"+t]:{__args:{id:o,data:i}}}).then(a=>a["update"+t])},async delete(o){return s({["delete"+t]:{__args:{id:o}}}).then(i=>i["delete"+t])},add(o){return s({["add"+t]:{__args:{data:o}}}).then(i=>i["add"+t])},fields(o){let i=[];for(let a of o){const l=f(a);l&&i.push(l)}return i},async get(o,i){const a=g(t,Ct(i));for(const[l,A]of Object.entries(o))a.where(l,"==",A);return await a.first()},list(o){let i=o;const a={};Object.entries(o).forEach(([_])=>{c[_]&&(a[_]=c[_],c[_].gqlField&&(delete i[_],i=M(i,c[_].gqlField)),c[_].gql&&(delete i[_],i=M(i,c[_].gql)))});const l=n(t,i).dataPath(d),A=l.fetch.bind(l);return{...l,async fetch(){return(await A()).map(m=>{const O={...m};return Object.entries(a).forEach(([P,S])=>{S.field&&typeof S.field=="function"&&(O[P]=S.field(m[P],m))}),O})},async fetchFirst(){const m=await l.fetchFirst.bind(l)();if(!m)return m;const O={...m};return Object.entries(a).forEach(([P,S])=>{S.field&&typeof S.field=="function"&&(O[P]=S.field(m[P],m))}),O}}}}},D={},I=(t,e)=>{const r=ot(t,e);return D[t]=r,r},G=t=>D[t]?D[t]:I(t,{}),Nt=t=>!!D[t],qt=()=>Object.keys(D),Lt=()=>{Object.keys(D).forEach(t=>delete D[t])},Jt=t=>{Object.entries(t).forEach(([e,r])=>{I(e,r)})},Gt=()=>k({app:{permissions:!0}}).then(t=>t.app.permissions),K=(t,e)=>{const r=async()=>{const{app:c}=await t({app:{auth:{webAuthnRequestOptions:!0}}}),d=c.auth.webAuthnRequestOptions,f=PublicKeyCredential.parseRequestOptionsFromJSON(d);return await navigator.credentials.get({publicKey:f})},s=async()=>{const{app:c}=await t({app:{auth:{webAuthnCreationOptions:!0}}}),d=PublicKeyCredential.parseCreationOptionsFromJSON(c.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:d})};return{assertion:r,attestation:s,login:async()=>{const c=await r();return await e({webAuthnAssertion:{__args:{assertion:c.toJSON()}}}).then(d=>d.webAuthnAssertion)},register:async()=>{const c=await s();return await e({webAuthnRegister:{__args:{registration:c.toJSON()}}}).then(d=>d.webAuthnRegister)}}},$=K(t=>k(t),t=>p(t)),$t=$.assertion,zt=$.attestation,Wt=$.login,Qt=$.register,it=Object.freeze(Object.defineProperty({__proto__:null,assertion:$t,attestation:zt,createWebAuthn:K,login:Wt,register:Qt},Symbol.toStringTag,{value:"Module"})),at=(t,e)=>({getCurrentUser:(r=q)=>t({my:r}).then(s=>s.my),login:(r,s,n="")=>e({login:{__args:{username:r,password:s,code:n}}}).then(g=>g.login),logout:()=>e({logout:!0}).then(r=>r.logout),changeExpiredPassword:(r,s,n)=>e({changeExpiredPassword:{__args:{username:r,old_password:s,new_password:n}}}).then(g=>g.changeExpiredPassword),updatePassword:(r,s)=>e({changeUserPassword:{__args:{old_password:r,new_password:s}}}).then(n=>n.changeUserPassword),resetPassword:(r,s,n)=>e({resetPassword:{__args:{jwt:r,password:s,code:n}}}).then(g=>g.resetPassword),forgetPassword:(r,s)=>e({forgetPassword:{__args:{username:r,email:s}}}).then(n=>n.forgetPassword),verifyCode:(r,s)=>e({forgetPasswordVerifyCode:{__args:{jwt:r,code:s}}}).then(n=>n.forgetPasswordVerifyCode),grantedRights:r=>t({my:{grantedRights:{__args:{rights:r}}}}).then(s=>s.my.grantedRights),isGranted:r=>t({my:{granted:{__args:{right:r}}}}).then(s=>s.my.granted),webAuthn:K(t,e),google:{unlink:()=>e({lightAuthUnlinkGoogle:!0}).then(r=>r.lightAuthUnlinkGoogle),login:r=>e({lightAuthLoginGoogle:{__args:{credential:r}}}).then(s=>s.lightAuthLoginGoogle),register:r=>e({lightAuthRegisterGoogle:{__args:{credential:r}}}).then(s=>s.lightAuthRegisterGoogle)},facebook:{unlink:()=>e({lightAuthUnlinkFacebook:!0}).then(r=>r.lightAuthUnlinkFacebook),login:r=>e({lightAuthLoginFacebook:{__args:{access_token:r}}}).then(s=>s.lightAuthLoginFacebook),register:r=>e({lightAuthRegisterFacebook:{__args:{access_token:r}}}).then(s=>s.lightAuthRegisterFacebook)},microsoft:{unlink:()=>e({lightAuthUnlinkMicrosoft:!0}).then(r=>r.lightAuthUnlinkMicrosoft),login:r=>e({lightAuthLoginMicrosoft:{__args:{access_token:r}}}).then(s=>s.lightAuthLoginMicrosoft),register:r=>e({lightAuthRegisterMicrosoft:{__args:{account_id:r}}}).then(s=>s.lightAuthRegisterMicrosoft)}}),ct=(t=q)=>k({my:t}).then(e=>e.my),lt=(t,e,r="")=>p({login:{__args:{username:t,password:e,code:r}}}).then(s=>s.login),ut=()=>p({logout:!0}).then(t=>t.logout),ht=(t,e,r)=>p({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(s=>s.changeExpiredPassword),ft=(t,e)=>p({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),gt=(t,e,r)=>p({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(s=>s.resetPassword),dt=(t,e)=>p({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),pt=(t,e)=>p({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),_t=t=>k({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),yt=t=>k({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),Ht={getCurrentUser:ct,webAuthn:it,google:{unlink:()=>p({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>p({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>p({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>p({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>p({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>p({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>p({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>p({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>p({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:lt,logout:ut,changeExpiredPassword:ht,updatePassword:ft,resetPassword:gt,forgetPassword:dt,verifyCode:pt,grantedRights:yt,isGranted:_t},q={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},Vt=t=>p({addUser:{__args:t}}).then(e=>e.addUser),vt=t=>p({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),Xt=(t=q)=>N("Users",t).dataPath("app.listUser").fetch(),Yt=(t,e)=>p({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),wt=(t,e)=>({list:(r=q)=>e("Users",r).dataPath("app.listUser").fetch(),create:r=>t({addUser:{__args:r}}).then(s=>s.addUser),delete:r=>t({deleteUser:{__args:{id:r}}}).then(s=>s.deleteUser),update:(r,s)=>t({updateUser:{__args:{id:r,data:s}}}).then(n=>n.updateUser)}),x=t=>e=>t({app:{listConfig:{__args:{filters:{name:e}},data:{name:!0,value:!0}}}}).then(r=>r.app.listConfig.data[0]?.value),Zt=x(k),bt={name:!0},It=(t=bt)=>k({app:{roles:t}}).then(e=>e.app.roles),Kt=(t,e)=>p({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),xt=t=>p({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),mt=(t,e)=>({list:(r=bt)=>t({app:{roles:r}}).then(s=>s.app.roles),create:(r,s)=>e({addRole:{__args:{data:{name:r,childs:s}}}}).then(n=>n.addRole),delete:r=>e({deleteRole:{__args:{name:r}}}).then(s=>s.deleteRole)});function tt(t){if(Array.isArray(t))return t.map(e=>tt(e)).filter(e=>e!==void 0);if(t!==null&&typeof t=="object"){const e=Object.getPrototypeOf(t);if(e===Object.prototype||e===null)return Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0).map(([r,s])=>[r,tt(s)]))}return t}function At(t,e,r,s,n){if(!(!t||typeof t!="object"))for(let g in t){const c=t[g];if(c&&typeof c=="object"){if("__args"in c){const d=tt(c.__args),f={};Object.entries(d).forEach(([o,i])=>{if(i instanceof Array&&R(i)){f[o]=new U.VariableType(o);let a=0;i.forEach(l=>{l instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+o+"."+a),s.append(n.current.toString(),l),n.current++,a++)}),e[o]="[Upload!]!"}else i instanceof File?(f[o]=new U.VariableType(o),r[n.current]=["variables."+o],s.append(n.current.toString(),i),e[o]="Upload!",n.current++):i instanceof Object&&X(i)?(f[o]={},Object.entries(i).forEach(([a,l])=>{if(l instanceof Array&&R(l)){f[o][a]=new U.VariableType(a);let A=0;l.forEach(_=>{_ instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+a+"."+A),s.append(n.current.toString(),_),n.current++,A++)}),e[a]="[Upload!]!"}else l instanceof File?(f[o][a]=new U.VariableType(a),r[n.current]=["variables."+a],s.append(n.current.toString(),l),e[a]="Upload!",n.current++):f[o][a]=l})):i!=null&&(f[o]=i)}),c.__args=f}At(c,e,r,s,n)}}}const Ft=t=>async e=>{const r=e,s=new FormData;let n=!1;const g={},c={};At(r,g,c,s,{current:0}),n=Object.keys(g).length>0,n&&(r.__variables=g);let f=null;const o={mutation:r},i=U.jsonToGraphQLQuery(o);if(n?(s.append("map",JSON.stringify(c)),s.append("operations",JSON.stringify({query:i})),f=await t.post("",s)):f=await t.post("",{query:i}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data},p=async t=>Ft(v().axios)(t),te=(t,e,r)=>p({sendMail:{__args:{email:t,subject:e,message:r}}}).then(s=>s.sendMail),kt=t=>({send:(e,r,s)=>t({sendMail:{__args:{email:e,subject:r,message:s}}}).then(n=>n.sendMail)}),ee=Object.freeze(Object.defineProperty({__proto__:null,createFolder:t=>p({lightFSCreateFolder:{__args:{location:t}}}).then(e=>e.lightFSCreateFolder),deleteFile:t=>p({lightFSDeleteFile:{__args:{location:t}}}).then(e=>e.lightFSDeleteFile),deleteFolder:t=>p({lightFSDeleteFolder:{__args:{location:t}}}).then(e=>e.lightFSDeleteFolder),duplicateFile:t=>p({lightFSDuplicateFile:{__args:{location:t}}}).then(e=>e.lightFSDuplicateFile),exists:t=>k({app:{fs:{exists:{__args:{location:t}}}}}).then(e=>e.app.fs.exists),find:(t,e)=>{const r={};return t&&(r.search=t),e&&(r.label=e),k({app:{fs:{find:{__args:r,__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}}}).then(s=>s.app.fs.find)},list:t=>k({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"Folder",name:!0,location:!0,path:!0,children:{__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}]}}}}).then(r=>r.app.fs.node),listFiles:(t,e,r)=>{const s={location:t};return e&&(s.type=e),r&&(s.search=r),k({app:{fs:{listFiles:{__args:s,name:!0,path:!0,location:!0,size:!0,mimeType:!0,publicUrl:!0,lastModified:!0}}}}).then(n=>n.app.fs.listFiles)},move:(t,e)=>p({lightFSMove:{__args:{from:t,to:e}}}).then(r=>r.lightFSMove),readFile:(t,e="text")=>k({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"File",...e==="text"?{content:!0}:{base64Content:!0}}]}}}}).then(r=>{const s=r.app.fs.node;return s?.__typename==="File"?e==="text"?s.content:s.base64Content:null}),renameFile:(t,e)=>p({lightFSRenameFile:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFile),renameFolder:(t,e)=>p({lightFSRenameFolder:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFolder),uploadBase64:(t,e)=>p({lightFSUploadBase64:{__args:{location:t,base64:e},__typename:!0,name:!0,path:!0,location:!0,__on:[{__typename:"File",size:!0,mimeType:!0,lastModified:!0}]}}).then(r=>r.lightFSUploadBase64),uploadFile:(t,e,r=!1)=>p({lightFSUploadFile:{__args:{location:t,file:e,rename:r}}}).then(s=>s.lightFSUploadFile),uploadTempFile:(t,e)=>p({lightFSUploadTempFile:{__args:{location:t,file:e},name:!0,path:!0,location:!0,size:!0,mimeType:!0}}).then(r=>r.lightFSUploadTempFile),writeFile:(t,e)=>p({lightFSWriteFile:{__args:{location:t,content:e}}}).then(r=>r.lightFSWriteFile)},Symbol.toStringTag,{value:"Module"})),et=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(et(r)).forEach(([s,n])=>{e[s]=n})}),e):(Object.entries(t).forEach(([r,s])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=s;return}if(typeof s=="boolean"){e[r]=s;return}e[r]=et(s)}),e)},Ct=t=>et(t),re=t=>{const e=typeof window>"u";let r=[],s=null,n=null,g=null,c=null;const d=new Set,f=Ot.create({baseURL:t,withCredentials:!0}),o=async()=>s&&!se(s)||!n?s:(g??=n().then(h=>(s=h,h)).finally(()=>{g=null}),g);f.interceptors.request.use(async h=>{const y=await o();return y&&(h.headers.Authorization=`Bearer ${y}`),h});let i=!1,a=[];const l=(h,y=null)=>{a.forEach(b=>{h?b.reject(h):b.resolve(y)}),a=[]};f.interceptors.response.use(h=>{const y=h.data.errors;if(y&&y.some(b=>b.extensions?.code==="TOKEN_EXPIRED")){const b=h.config;return b._lightTokenRetried?h:(b._lightTokenRetried=!0,n&&(s=null),i?new Promise((F,C)=>{a.push({resolve:F,reject:C})}).then(()=>f(b)).catch(F=>Promise.reject(F)):(i=!0,A().then(()=>(i=!1,l(null),f(b))).catch(F=>(i=!1,l(F),Promise.reject(F)))))}return h},h=>Promise.reject(h));function A(){return n?o().then(()=>{}):f.post("/refresh_token")}e&&(f.interceptors.request.use(h=>(h.withCredentials=!0,r.length>0&&(h.headers.Cookie=r.join("; ")),h)),f.interceptors.response.use(h=>{if(h.headers["set-cookie"]){const y=h.headers["set-cookie"].map(F=>F.split(";")[0]),b=new Map;r.forEach(F=>{const C=F.split("=")[0];b.set(C,F)}),y.forEach(F=>{const C=F.split("=")[0];b.set(C,F)}),r=Array.from(b.values())}return h}));const _=nt(f),m=Ft(f),O=(h,y)=>N(h,y,_),P=(h,y)=>Z(h,y,_),S=h=>{const y=G(h),b=ot(h,y.$fields,{mutation:m,createList:O,createCollection:P});return b.setDataPath(y.getDataPath()),b},j=at(_,m),Pt=()=>d.forEach(h=>h()),L=h=>(async(...y)=>{const b=await h(...y);return Pt(),b}),oe={...j,login:L(j.login),logout:(async()=>{try{return await j.logout()}finally{Pt()}}),google:{...j.google,login:L(j.google.login)},facebook:{...j.facebook,login:L(j.facebook.login)},microsoft:{...j.microsoft,login:L(j.microsoft.login)},webAuthn:{...j.webAuthn,login:L(j.webAuthn.login)}},Ut={post:f.post.bind(f),baseURL:t,axios:f,setAccessToken(h){s=h},getAccessToken(){return s},clearAccessToken(){s=null},setAccessTokenProvider(h){c?.(),c=null,n=h,s=null,g=null},onAuthChange(h){return d.add(h),()=>d.delete(h)},useAudience(h,y){c?.(),n=async()=>(await h.mutation({createAudienceAccessToken:{__args:{audience:y}}})).createAudienceAccessToken,s=null,g=null,c=h.onAuthChange(()=>{s=null,g=null})},auth:oe,mutation:m,query:_,config:x(_),mail:kt(m),users:wt(m,O),model(h){return S(h)},roles:mt(_,m),collect:(h,y)=>{const b=P(h,y);return b.data_path=G(h).getDataPath(),b},list:(h,y)=>O(h,y).dataPath(G(h).getDataPath()),async collects(h){const y={},b={};for(const C in h){const T=h[C].getQueryPayload();b[C]=T.data_path,y[C]={};const B=T.data_path.split(".");let z=B[B.length-1],E=y[C];for(const W of B){if(W===z){E[W]=T.query;break}E[W]=E[W]||{}}y[C].__aliasFor=B[0]}const F=await _(y);for(const C in h){const T=b[C].split(".");let B=T[T.length-1],z=F[C];for(const E of T){if(E===B){h[C]._batchData=F[C][E];break}z[E]=z[E]||{}}}return h}};return rt(Ut),Ut};function se(t,e=30){try{const r=t.split(".")[1];if(!r)return!0;const s=r.replace(/-/g,"+").replace(/_/g,"/"),n=s.padEnd(Math.ceil(s.length/4)*4,"="),g=JSON.parse(globalThis.atob(n));return typeof g.exp=="number"?g.exp<=Math.floor(Date.now()/1e3)+e:!1}catch{return!0}}const ne=N;u.arrayHasFile=R,u.auth=Ht,u.changeExpiredPassword=ht,u.clearModels=Lt,u.createAuth=at,u.createClient=re,u.createCollection=Z,u.createConfig=x,u.createFileFromBase64=Et,u.createFileFromBase85=Dt,u.createFileFromString=Y,u.createList=N,u.createMail=kt,u.createRole=Kt,u.createRoles=mt,u.createUser=Vt,u.createUsers=wt,u.defaultUserFields=q,u.defineModel=I,u.defineModels=Jt,u.deleteRole=xt,u.deleteUser=vt,u.forgetPassword=dt,u.fs=ee,u.getApiClient=v,u.getApiClientOptional=jt,u.getConfig=Zt,u.getCurrentUser=ct,u.getGrantedRights=yt,u.getModel=G,u.hasModel=Nt,u.isGranted=_t,u.list=ne,u.listModels=qt,u.listPermissions=Gt,u.listRoles=It,u.listUsers=Xt,u.login=lt,u.logout=ut,u.mutation=p,u.objectHasFile=X,u.query=k,u.resetPassword=gt,u.sendMail=te,u.setApiClient=rt,u.toQuery=Ct,u.updatePassword=ft,u.updateUser=Yt,u.verifyCode=pt,u.webAuthn=it,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
package/dist/drive.d.ts DELETED
@@ -1,130 +0,0 @@
1
- import { query, mutation } from '.';
2
- /**
3
- * @deprecated Use `fs.listFolders` / `fs.listFiles` from `filesystem` instead.
4
- */
5
- export declare const listDrives: () => Promise<any>;
6
- /**
7
- * @deprecated Use functions from `filesystem` (fs.*) instead.
8
- * - listFiles → fs.listFiles(location)
9
- * - listFolders → fs.listFolders(location)
10
- * - writeFile → fs.writeFile(location, content)
11
- * - deleteFile → fs.deleteFile(location)
12
- * - renameFile → fs.renameFile(location, newName)
13
- * - moveFile → fs.move(from, to)
14
- * - createFolder → fs.createFolder(location)
15
- * - deleteFolder → fs.deleteFolder(location)
16
- * - renameFolder → fs.renameFolder(location, newName)
17
- * - uploadTempFile → fs.uploadTempFile(location, file)
18
- */
19
- export declare const getDrive: (index: number) => {
20
- folders: {
21
- list: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<any>;
22
- create: (path: string) => Promise<any>;
23
- delete: (path: string) => Promise<any>;
24
- rename: (path: string, name: string) => Promise<any>;
25
- };
26
- files: {
27
- list: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
28
- get: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
29
- readFileAsBase64(path: string): Promise<string>;
30
- read: (path: string) => Promise<any>;
31
- write: (path: string, content: string) => Promise<any>;
32
- delete: (path: string) => Promise<any>;
33
- rename: (path: string, name: string) => Promise<any>;
34
- move: (source: string, destination: string) => Promise<any>;
35
- };
36
- listFiles: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
37
- getFile: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
38
- readFile: (path: string) => Promise<any>;
39
- writeFile: (path: string, content: string) => Promise<any>;
40
- deleteFile: (path: string) => Promise<any>;
41
- renameFile: (path: string, name: string) => Promise<any>;
42
- moveFile: (source: string, destination: string) => Promise<any>;
43
- listFolders: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<any>;
44
- createFolder: (path: string) => Promise<any>;
45
- deleteFolder: (path: string) => Promise<any>;
46
- renameFolder: (path: string, name: string) => Promise<any>;
47
- uploadTempFile: (file: File) => Promise<{
48
- name: string;
49
- path: string;
50
- size: number;
51
- mime: string;
52
- }>;
53
- };
54
- export declare const createDrive: (queryFn: typeof query, mutationFn: typeof mutation) => (index: number) => {
55
- folders: {
56
- list: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<any>;
57
- create: (path: string) => Promise<any>;
58
- delete: (path: string) => Promise<any>;
59
- rename: (path: string, name: string) => Promise<any>;
60
- };
61
- files: {
62
- list: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
63
- get: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
64
- readFileAsBase64(path: string): Promise<string>;
65
- read: (path: string) => Promise<any>;
66
- write: (path: string, content: string) => Promise<any>;
67
- delete: (path: string) => Promise<any>;
68
- rename: (path: string, name: string) => Promise<any>;
69
- move: (source: string, destination: string) => Promise<any>;
70
- };
71
- listFiles: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
72
- getFile: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
73
- readFile: (path: string) => Promise<any>;
74
- writeFile: (path: string, content: string) => Promise<any>;
75
- deleteFile: (path: string) => Promise<any>;
76
- renameFile: (path: string, name: string) => Promise<any>;
77
- moveFile: (source: string, destination: string) => Promise<any>;
78
- listFolders: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<any>;
79
- createFolder: (path: string) => Promise<any>;
80
- deleteFolder: (path: string) => Promise<any>;
81
- renameFolder: (path: string, name: string) => Promise<any>;
82
- uploadTempFile: (file: File) => Promise<{
83
- name: string;
84
- path: string;
85
- size: number;
86
- mime: string;
87
- }>;
88
- };
89
- declare const _default: () => {
90
- list: Promise<Array<{
91
- index: number;
92
- name: string;
93
- }>>;
94
- get: (index: number) => {
95
- folders: {
96
- list: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<any>;
97
- create: (path: string) => Promise<any>;
98
- delete: (path: string) => Promise<any>;
99
- rename: (path: string, name: string) => Promise<any>;
100
- };
101
- files: {
102
- list: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
103
- get: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
104
- readFileAsBase64(path: string): Promise<string>;
105
- read: (path: string) => Promise<any>;
106
- write: (path: string, content: string) => Promise<any>;
107
- delete: (path: string) => Promise<any>;
108
- rename: (path: string, name: string) => Promise<any>;
109
- move: (source: string, destination: string) => Promise<any>;
110
- };
111
- listFiles: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
112
- getFile: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
113
- readFile: (path: string) => Promise<any>;
114
- writeFile: (path: string, content: string) => Promise<any>;
115
- deleteFile: (path: string) => Promise<any>;
116
- renameFile: (path: string, name: string) => Promise<any>;
117
- moveFile: (source: string, destination: string) => Promise<any>;
118
- listFolders: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<any>;
119
- createFolder: (path: string) => Promise<any>;
120
- deleteFolder: (path: string) => Promise<any>;
121
- renameFolder: (path: string, name: string) => Promise<any>;
122
- uploadTempFile: (file: File) => Promise<{
123
- name: string;
124
- path: string;
125
- size: number;
126
- mime: string;
127
- }>;
128
- };
129
- };
130
- export default _default;
package/dist/file.d.ts DELETED
@@ -1,32 +0,0 @@
1
- import { query, mutation } from '.';
2
- export type FileFields = {
3
- name?: string;
4
- path?: string;
5
- size?: number;
6
- mime?: string;
7
- url?: string;
8
- };
9
- export type QueryFileFields = Partial<Record<keyof FileFields, boolean>>;
10
- /**
11
- * @deprecated Use `fs.listFiles` / `fs.readFile` from `filesystem` instead.
12
- */
13
- export declare const listFiles: (index: number, path: string, fields?: QueryFileFields) => Promise<any>;
14
- /**
15
- * @deprecated Use `fs.readFile(location, 'base64')` from `filesystem` instead.
16
- */
17
- export declare const readFileAsBase64: (index: number, path: string) => Promise<string>;
18
- /**
19
- * @deprecated Use `fs.listFiles` from `filesystem` instead.
20
- * The default export factory function is also deprecated — use `fs.*` directly.
21
- */
22
- declare const _default: (index: number, queryFn?: typeof query, mutationFn?: typeof mutation) => {
23
- list: (path: string, fields?: QueryFileFields) => Promise<any>;
24
- get: (path: string, fields?: QueryFileFields) => Promise<any>;
25
- readFileAsBase64(path: string): Promise<string>;
26
- read: (path: string) => Promise<any>;
27
- write: (path: string, content: string) => Promise<any>;
28
- delete: (path: string) => Promise<any>;
29
- rename: (path: string, name: string) => Promise<any>;
30
- move: (source: string, destination: string) => Promise<any>;
31
- };
32
- export default _default;
package/dist/folder.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { query, mutation } from '.';
2
- export type FolderFields = {
3
- name?: string;
4
- path?: string;
5
- };
6
- export type QueryFolderFields = Record<keyof FolderFields, boolean>;
7
- /**
8
- * @deprecated Use `fs.listFolders` from `filesystem` instead.
9
- */
10
- export declare const listFolders: (index: number, path: string, fields?: QueryFolderFields) => Promise<Array<Record<keyof FolderFields, any>>>;
11
- /**
12
- * @deprecated Use `fs.createFolder` / `fs.deleteFolder` / `fs.renameFolder` from `filesystem` instead.
13
- */
14
- declare const _default: (index: number, queryFn?: typeof query, mutationFn?: typeof mutation) => {
15
- list: (path: string, fields?: QueryFolderFields) => Promise<any>;
16
- create: (path: string) => Promise<any>;
17
- delete: (path: string) => Promise<any>;
18
- rename: (path: string, name: string) => Promise<any>;
19
- };
20
- export default _default;