@hostlink/light 3.0.5 → 3.0.7

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(f,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("json-to-graphql-query"),require("axios"),require("collect.js")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios","collect.js"],b):(f=typeof globalThis<"u"?globalThis:f||self,b(f.light={},f.jsonToGraphqlQuery,f.axios,f.collect))})(this,(function(f,b,bt,v){"use strict";function E(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 S(t,e,r=".",i){if(!E(e))return S(t,{},r,i);const o=Object.assign({},e);for(const u in t){if(u==="__proto__"||u==="constructor")continue;const l=t[u];l!=null&&(i&&i(o,u,l,r)||(Array.isArray(l)&&Array.isArray(o[u])?o[u]=[...l,...o[u]]:E(l)&&E(o[u])?o[u]=S(l,o[u],(r?`${r}.`:"")+u.toString(),i):o[u]=l))}return o}function mt(t){return(...e)=>e.reduce((r,i)=>S(r,i,"",t),{})}const F=mt();let k=null;const T=t=>{k=t},M=()=>{if(!k)throw new Error("Api client not initialized. Call setApiClient() first.");return k},Ft=()=>k;function C(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function $(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&C(t[e]))return!0;return!1}function R(t,e,r,i,o){if(!(!t||typeof t!="object"))for(let u in t){const l=t[u];if(l&&typeof l=="object"){if("__args"in l){const h=l.__args,s={};Object.entries(h).forEach(([n,c])=>{if(c instanceof Array&&C(c)){s[n]=new b.VariableType(n);let a=0;c.forEach(p=>{p instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+n+"."+a),i.append(o.current.toString(),p),o.current++,a++)}),e[n]="[Upload!]!"}else c instanceof File?(s[n]=new b.VariableType(n),r[o.current]=["variables."+n],i.append(o.current.toString(),c),e[n]="Upload!",o.current++):c instanceof Object&&$(c)?(s[n]={},Object.entries(c).forEach(([a,p])=>{if(p instanceof Array&&C(p)){s[n][a]=new b.VariableType(a);let g=0;p.forEach(y=>{y instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+a+"."+g),i.append(o.current.toString(),y),o.current++,g++)}),e[a]="[Upload!]!"}else p instanceof File?(s[n][a]=new b.VariableType(a),r[o.current]=["variables."+a],i.append(o.current.toString(),p),e[a]="Upload!",o.current++):s[n][a]=p})):c!=null&&(s[n]=c)}),l.__args=s}R(l,e,r,i,o)}}}const w=async t=>{const e=M(),r=t,i=new FormData;let o=!1;const u={},l={};R(r,u,l,i,{current:0}),o=Object.keys(u).length>0,o&&(r.__variables=u);let s=null;const n={query:r},c=b.jsonToGraphQLQuery(n);if(o?(i.append("map",JSON.stringify(l)),i.append("operations",JSON.stringify({query:c})),s=await e.axios.post("",i)):s=await e.axios.post("",{query:c}),s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function P(t,e){let r,i=[],o,u;const l=s=>!s||typeof s!="object"?!1:Object.values(s).some(n=>n&&typeof n=="object"&&Object.keys(n).some(c=>c.startsWith("_"))),h=()=>i.length===0?(i.unshift({}),i[0]):(l(i[0])&&i.unshift({}),i[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const n=await this.limit(1).fetch();return Array.isArray(n)&&n.length>0?n[0]:null},async fetchWithMeta(){let n=await w(this.toQuery(!0));if(u){const c=u.split(".");for(const a of c)n=n[a];return n}return n[`list${t}`]},async fetch(){let n=await w(this.toQuery());if(u){const c=u.split(".");for(const a of c)n=n[a];return n.data}return n[`list${t}`].data},dataPath(s){return s&&typeof s=="string"&&(u=s),this},sort(s){return s&&typeof s=="string"&&(o=s),this},filters(s){return s&&typeof s=="object"&&(i=[s]),this},where(s,n,c){const a=(p,g,y)=>{const D={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[g];D&&i.push({[p]:{[D]:y}})};if(c!==void 0)a(s,String(n),c);else{const p=h(),g=F(p,{[s]:n});i[0]=g}return this},whereContains(s,n){if(s&&typeof s=="string"){const c=h(),a={_contains:n};c[s]?Array.isArray(c[s])?c[s].push(a):c[s]=[c[s],a]:c[s]=[a],i[0]=c}return this},whereIn(s,n){if(s&&typeof s=="string"&&Array.isArray(n)){const c=h(),a={_in:n};c[s]?Array.isArray(c[s])?c[s].push(a):c[s]=[c[s],a]:c[s]=[a],i[0]=c}return this},whereBetween(s,n,c){if(s&&typeof s=="string"){const a=h(),p={_between:[n,c]};a[s]?Array.isArray(a[s])?a[s].push(p):a[s]=[a[s],p]:a[s]=p,i[0]=a}return this},limit(s){return typeof s=="number"&&Number.isFinite(s)&&(r=F(r||{},{limit:s})),this},offset(s){return typeof s=="number"&&Number.isFinite(s)&&(r=F(r||{},{offset:s})),this},toQuery(s=!1){let n;const c=i.length>0&&Object.keys(i[0]||{}).length>0,a=c?1:0,p=i.length>a;c&&p?n=i:p?n=i.slice(a):c&&(n=i[0]);const g=F(o?{sort:o}:{},n?{filters:n}:{}),y={data:{...e}};if(r&&(y.data.__args=r),Object.keys(g).length>0&&(y.__args=g),s&&(y.meta={total:!0,key:!0,name:!0}),u){const m=u.split(".");let D=y;for(let L=m.length-1;L>=0;L--)D={[m[L]]:D};return D}return{[`list${t}`]:y}}}}const At=(t,e={})=>{const r=t,i=e;let o="list"+t;const u=l=>i[l]?i[l]:null;return{field:u,$fields:i,setDataPath(l){return o=l,o},getDataPath(){return o},gqlFields(l){let h={};for(const s of l)if(typeof s=="string"){const n=u(s);n&&(h=F(h,n.gqlField?typeof n.gqlField=="string"?{[n.gqlField]:!0}:n.gqlField:{[n.name||s]:!0}))}else typeof s=="object"&&(h=F(h,s));return h},update(l,h){return d({["update"+r]:{__args:{id:l,data:h}}}).then(s=>s["update"+r])},async delete(l){return d({["delete"+r]:{__args:{id:l}}}).then(h=>h["delete"+r])},add(l){return d({["add"+r]:{__args:{data:l}}}).then(h=>h["add"+r])},fields(l){let h=[];for(let s of l){const n=u(s);n&&h.push(n)}return h},async get(l,h){const s=(await Promise.resolve().then(()=>Bt)).default,n=s(r,wt(h));for(const[c,a]of Object.entries(l))n.where(c,"==",a);return await n.first()},list(l){let h=l;const s={};Object.entries(l).forEach(([a])=>{i[a]&&(s[a]=i[a],i[a].gqlField&&(delete h[a],h=F(h,i[a].gqlField)),i[a].gql&&(h=F(h,i[a].gql),delete h[a]))});const n=P(r,h).dataPath(o),c=n.fetch.bind(n);return{...n,async fetch(){return(await c()).map(p=>{const g={...p};return Object.entries(s).forEach(([y,m])=>{m.format&&typeof m.format=="function"&&(g[y]=m.format(p))}),g})},async fetchFirst(){const p=await n.fetchFirst.bind(n)();if(!p)return p;const g={...p};return Object.entries(s).forEach(([y,m])=>{m.format&&typeof m.format=="function"&&(g[y]=m.format(p))}),g}}}}},O={},q=(t,e)=>{const r=At(t,e);return O[t]=r,r},U=t=>O[t]?O[t]:q(t,{}),Ot=t=>!!O[t],Dt=()=>Object.keys(O),Ct=()=>{Object.keys(O).forEach(t=>delete O[t])},Pt=t=>{Object.entries(t).forEach(([e,r])=>{q(e,r)})},jt=()=>w({app:{permissions:!0}}).then(t=>t.app.permissions),W=async()=>{const{app:t}=await w({app:{auth:{webAuthnRequestOptions:!0}}}),e=t.auth.webAuthnRequestOptions,r=PublicKeyCredential.parseRequestOptionsFromJSON(e);return await navigator.credentials.get({publicKey:r})},z=async()=>{const{app:t}=await w({app:{auth:{webAuthnCreationOptions:!0}}}),e=PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:e})},Q=Object.freeze(Object.defineProperty({__proto__:null,assertion:W,attestation:z,login:async()=>{const t=await W();return await d({webAuthnAssertion:{__args:{assertion:t.toJSON()}}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await z();return await d({webAuthnRegister:{__args:{registration:t.toJSON()}}}).then(e=>e.webAuthnRegister)}},Symbol.toStringTag,{value:"Module"})),G=(t=N)=>w({my:t}).then(e=>e.my),H=(t,e,r="")=>d({login:{__args:{username:t,password:e,code:r}}}).then(i=>i.login),V=()=>d({logout:!0}).then(t=>t.logout),X=(t,e,r)=>d({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(i=>i.changeExpiredPassword),Y=(t,e)=>d({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),Z=(t,e,r)=>d({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(i=>i.resetPassword),I=(t,e)=>d({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),K=(t,e)=>d({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),x=t=>w({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),tt=t=>w({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),et=()=>({getCurrentUser:G,webAuthn:Q,google:{unlink:()=>d({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>d({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>d({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>d({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>d({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>d({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>d({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>d({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>d({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:H,logout:V,changeExpiredPassword:X,updatePassword:Y,resetPassword:Z,forgetPassword:I,verifyCode:K,grantedRights:tt,isGranted:x}),rt={name:!0,path:!0,size:!0,mime:!0,url:!0},st=(t,e,r=rt)=>w({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(i=>i.app.drive.files),nt=(t,e)=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),A=t=>({list:(e,r=rt)=>st(t,e,r),get:(e,r={name:!0,path:!0,size:!0,mime:!0,url:!0})=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},...r}}}}).then(i=>i.app.drive.file),readFileAsBase64(e){return nt(t,e)},read:async e=>{let r=await w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}});if(!r.app.drive.file||!r.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${e}`);return typeof window<"u"&&window.atob?window.atob(r.app.drive.file.base64Content):r.app.drive.file.base64Content},write:(e,r)=>d({lightDriveWriteFile:{__args:{index:t,path:e,content:r}}}).then(i=>i.lightDriveWriteFile),delete:e=>d({lightDriveDeleteFile:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFile),rename:(e,r)=>d({lightDriveRenameFile:{__args:{index:t,path:e,name:r}}}).then(i=>i.lightDriveRenameFile),move:(e,r)=>d({lightDriveMoveFile:{__args:{index:t,source:e,destination:r}}}).then(i=>i.lightDriveMoveFile)}),it={name:!0,path:!0},ot=(t,e,r=it)=>w({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(i=>i.app.drive.folders),j=t=>({list:(e,r=it)=>ot(t,e,r),create:e=>d({lightDriveCreateFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveCreateFolder),delete:e=>d({lightDriveDeleteFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFolder),rename:(e,r)=>d({lightDriveRenameFolder:{__args:{index:t,path:e,name:r}}}).then(i=>i.lightDriveRenameFolder)}),kt=()=>w({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),at=t=>({listFiles:A(t).list,getFile:A(t).get,readFile:A(t).read,writeFile:A(t).write,deleteFile:A(t).delete,renameFile:A(t).rename,moveFile:A(t).move,listFolders:j(t).list,createFolder:j(t).create,deleteFolder:j(t).delete,renameFolder:j(t).rename,uploadTempFile:e=>d({lightDriveUploadTempFile:{__args:{index:t,file:e},name:!0,path:!0,size:!0,mime:!0}}).then(r=>r.lightDriveUploadTempFile),folders:j(t),files:A(t)}),N={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},ct=t=>d({addUser:{__args:t}}).then(e=>e.addUser),lt=t=>d({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),ut=(t=N)=>P("Users",t).dataPath("app.listUser").fetch(),ht=(t,e)=>d({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),Ut=()=>({list:ut,create:ct,delete:lt,update:ht}),ft=t=>w({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]?.value),vt={name:!0},pt=(t=vt)=>w({app:{roles:t}}).then(e=>e.app.roles),dt=(t,e)=>d({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),gt=t=>d({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),Et=()=>({list:pt,create:dt,delete:gt});function _t(t,e,r,i,o){if(!(!t||typeof t!="object"))for(let u in t){const l=t[u];if(l&&typeof l=="object"){if("__args"in l){const h=l.__args,s={};Object.entries(h).forEach(([n,c])=>{if(c instanceof Array&&C(c)){s[n]=new b.VariableType(n);let a=0;c.forEach(p=>{p instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+n+"."+a),i.append(o.current.toString(),p),o.current++,a++)}),e[n]="[Upload!]!"}else c instanceof File?(s[n]=new b.VariableType(n),r[o.current]=["variables."+n],i.append(o.current.toString(),c),e[n]="Upload!",o.current++):c instanceof Object&&$(c)?(s[n]={},Object.entries(c).forEach(([a,p])=>{if(p instanceof Array&&C(p)){s[n][a]=new b.VariableType(a);let g=0;p.forEach(y=>{y instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+a+"."+g),i.append(o.current.toString(),y),o.current++,g++)}),e[a]="[Upload!]!"}else p instanceof File?(s[n][a]=new b.VariableType(a),r[o.current]=["variables."+a],i.append(o.current.toString(),p),e[a]="Upload!",o.current++):s[n][a]=p})):c!=null&&(s[n]=c)}),l.__args=s}_t(l,e,r,i,o)}}}const d=async t=>{const r=M().axios,i=t,o=new FormData;let u=!1;const l={},h={};_t(i,l,h,o,{current:0}),u=Object.keys(l).length>0,u&&(i.__variables=l);let n=null;const c={mutation:i},a=b.jsonToGraphQLQuery(c);if(u?(o.append("map",JSON.stringify(h)),o.append("operations",JSON.stringify({query:a})),n=await r.post("",o)):n=await r.post("",{query:a}),n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data},yt=(t,e,r)=>d({sendMail:{__args:{email:t,subject:e,message:r}}}).then(i=>i.sendMail),St={send:yt},B=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(B(r)).forEach(([i,o])=>{e[i]=o})}),e):(Object.entries(t).forEach(([r,i])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=i;return}if(typeof i=="boolean"){e[r]=i;return}e[r]=B(i)}),e)},wt=t=>B(t),Mt="list",qt=["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"],Nt=["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 _{_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}}_.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}},_.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},_.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},_.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},v().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),_.prototype.fetchData=async function(){try{if(this._batchData){const h=this._batchData;return this.meta=h.meta,v(h.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={},i=r,o=e[e.length-1];for(const h of e){if(h===o){i[h]=t;break}i[h]={},i=i[h]}let l=await w(r);for(const h of e)l=l[h];return this.meta=l.meta,v(l.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},_.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},_.prototype.all=async function(){return(await this.processData()).all()};for(const t of qt)_.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Nt)_.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};_.prototype.average=_.prototype.avg,_.prototype.first=async function(){return this.take(1),(await this.processData()).first()},_.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},_.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],i=t[1],o=t[2];switch(i){case"==":this.filters[r]=o;break;case"<":this.filters[r]={lt:o};break;case"<=":this.filters[r]={lte:o};break;case">":this.filters[r]={gt:o};break;case">=":this.filters[r]={gte:o};break;case"!==":this.filters[r]={ne:o};break;default:throw new Error(`Unsupported operator: ${i}`)}}return this},_.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},_.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)},_.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},_.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},_.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},_.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},_.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},_.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},_.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},_.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)},_.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 J=(t,e)=>{const r=new _(e);return r.data_path=Mt+t,r},Bt=Object.freeze(Object.defineProperty({__proto__:null,default:J},Symbol.toStringTag,{value:"Module"})),Jt=t=>{const e=typeof window>"u";let r=[];const i=bt.create({baseURL:t,withCredentials:!0});e&&(i.interceptors.request.use(u=>(u.withCredentials=!0,r.length>0&&(u.headers.Cookie=r.join("; ")),u)),i.interceptors.response.use(u=>{if(u.headers["set-cookie"]){const l=u.headers["set-cookie"].map(s=>s.split(";")[0]),h=new Map;r.forEach(s=>{const n=s.split("=")[0];h.set(n,s)}),l.forEach(s=>{const n=s.split("=")[0];h.set(n,s)}),r=Array.from(h.values())}return u}));const o={post:i.post,baseURL:t,axios:i,auth:et(),mutation:d,query:w,config:ft,mail:St,users:Ut(),model(u){return U(u)},roles:Et(),collect:(u,l)=>{const h=J(u,l);return h.data_path=U(u).getDataPath(),h},list:(u,l)=>P(u,l).dataPath(U(u).getDataPath()),drive:at,async collects(u){const l={},h={};for(const n in u){const c=u[n].getQueryPayload();h[n]=c.data_path,l[n]={};const a=c.data_path.split(".");let p=a[a.length-1],g=l[n];for(const y of a){if(y===p){g[y]=c.query;break}g[y]=g[y]||{}}l[n].__aliasFor=a[0]}const s=await w(l);for(const n in u){const c=h[n].split(".");let a=c[c.length-1],p=s[n];for(const g of c){if(g===a){u[n]._batchData=s[n][g];break}p[g]=p[g]||{}}}return u}};return T(o),o},Lt=P;f.auth=et,f.changeExpiredPassword=X,f.clearModels=Ct,f.createClient=Jt,f.createCollection=J,f.createList=P,f.createRole=dt,f.createUser=ct,f.defaultUserFields=N,f.defineModel=q,f.defineModels=Pt,f.deleteRole=gt,f.deleteUser=lt,f.forgetPassword=I,f.getApiClient=M,f.getApiClientOptional=Ft,f.getConfig=ft,f.getCurrentUser=G,f.getDrive=at,f.getGrantedRights=tt,f.getModel=U,f.hasModel=Ot,f.isGranted=x,f.list=Lt,f.listDrives=kt,f.listFiles=st,f.listFolders=ot,f.listModels=Dt,f.listPermissions=jt,f.listRoles=pt,f.listUsers=ut,f.login=H,f.logout=V,f.mutation=d,f.query=w,f.readFileAsBase64=nt,f.resetPassword=Z,f.sendMail=yt,f.setApiClient=T,f.toQuery=wt,f.updatePassword=Y,f.updateUser=ht,f.verifyCode=K,f.webAuthn=Q,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(h,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("json-to-graphql-query"),require("axios"),require("collect.js")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios","collect.js"],b):(h=typeof globalThis<"u"?globalThis:h||self,b(h.light={},h.jsonToGraphqlQuery,h.axios,h.collect))})(this,(function(h,b,wt,j){"use strict";function k(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 U(t,e,r=".",n){if(!k(e))return U(t,{},r,n);const i=Object.assign({},e);for(const c in t){if(c==="__proto__"||c==="constructor")continue;const l=t[c];l!=null&&(n&&n(i,c,l,r)||(Array.isArray(l)&&Array.isArray(i[c])?i[c]=[...l,...i[c]]:k(l)&&k(i[c])?i[c]=U(l,i[c],(r?`${r}.`:"")+c.toString(),n):i[c]=l))}return i}function bt(t){return(...e)=>e.reduce((r,n)=>U(r,n,"",t),{})}const m=bt();let D=null;const T=t=>{D=t},v=()=>{if(!D)throw new Error("Api client not initialized. Call setApiClient() first.");return D},mt=()=>D;function A(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function S(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&A(t[e]))return!0;return!1}function Ft(t){t="<~"+t+"~>";var e,r,n,i,c,l=String,f=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,n=[],i=0,c=t.length;c>i;i+=5)r=52200625*(t.charCodeAt(i)-33)+614125*(t.charCodeAt(i+1)-33)+7225*(t.charCodeAt(i+2)-33)+85*(t.charCodeAt(i+3)-33)+(t.charCodeAt(i+4)-33),n.push(f&r>>24,f&r>>16,f&r>>8,f&r);return(function(s,o){for(var a=o;a>0;a--)s.pop()})(n,e.length),l.fromCharCode.apply(l,n)}const E=(t="")=>{const e=t,r=(n="application/octet-stream")=>{const i=new Uint8Array(e.length);for(let f=0;f<e.length;f++)i[f]=e.charCodeAt(f);const c=new Blob([i],{type:n});return URL.createObjectURL(c)};return{getContent:()=>e,getURL:r,download:n=>{const i=document.createElement("a");i.download=n,i.href=r(),document.body.appendChild(i),i.click(),document.body.removeChild(i)},open:n=>{window.open(r(n),"_blank")}}},At=t=>E(atob(t)),Ct=t=>E(Ft(t));function $(t,e,r,n,i){if(!(!t||typeof t!="object"))for(let c in t){const l=t[c];if(l&&typeof l=="object"){if("__args"in l){const f=l.__args,s={};Object.entries(f).forEach(([o,a])=>{if(a instanceof Array&&A(a)){s[o]=new b.VariableType(o);let u=0;a.forEach(p=>{p instanceof File&&(r[i.current]||(r[i.current]=[]),r[i.current].push("variables."+o+"."+u),n.append(i.current.toString(),p),i.current++,u++)}),e[o]="[Upload!]!"}else a instanceof File?(s[o]=new b.VariableType(o),r[i.current]=["variables."+o],n.append(i.current.toString(),a),e[o]="Upload!",i.current++):a instanceof Object&&S(a)?(s[o]={},Object.entries(a).forEach(([u,p])=>{if(p instanceof Array&&A(p)){s[o][u]=new b.VariableType(u);let y=0;p.forEach(_=>{_ instanceof File&&(r[i.current]||(r[i.current]=[]),r[i.current].push("variables."+u+"."+y),n.append(i.current.toString(),_),i.current++,y++)}),e[u]="[Upload!]!"}else p instanceof File?(s[o][u]=new b.VariableType(u),r[i.current]=["variables."+u],n.append(i.current.toString(),p),e[u]="Upload!",i.current++):s[o][u]=p})):a!=null&&(s[o]=a)}),l.__args=s}$(l,e,r,n,i)}}}const w=async t=>{const{axios:e}=v(),r=t,n=new FormData;let i=!1;const c={},l={};$(r,c,l,n,{current:0}),i=Object.keys(c).length>0,i&&(r.__variables=c);let s=null;const o={query:r},a=b.jsonToGraphQLQuery(o);if(i?(n.append("map",JSON.stringify(l)),n.append("operations",JSON.stringify({query:a})),s=await e.post("",n)):s=await e.post("",{query:a}),s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function O(t,e){let r,n=[],i,c;const l=s=>!s||typeof s!="object"?!1:Object.values(s).some(o=>o&&typeof o=="object"&&Object.keys(o).some(a=>a.startsWith("_"))),f=()=>n.length===0?(n.unshift({}),n[0]):(l(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 w(this.toQuery(!0));if(c){const a=c.split(".");for(const u of a)o=o[u];return o}return o[`list${t}`]},async fetch(){let o=await w(this.toQuery());if(c){const a=c.split(".");for(const u of a)o=o[u];return o.data}return o[`list${t}`].data},dataPath(s){return s&&typeof s=="string"&&(c=s),this},sort(s){return s&&typeof s=="string"&&(i=s),this},filters(s){return s&&typeof s=="object"&&(n=[s]),this},where(s,o,a){const u=(p,y,_)=>{const C={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[y];C&&n.push({[p]:{[C]:_}})};if(a!==void 0)u(s,String(o),a);else{const p=f(),y=m(p,{[s]:o});n[0]=y}return this},whereContains(s,o){if(s&&typeof s=="string"){const a=f(),u={_contains:o};a[s]?Array.isArray(a[s])?a[s].push(u):a[s]=[a[s],u]:a[s]=[u],n[0]=a}return this},whereIn(s,o){if(s&&typeof s=="string"&&Array.isArray(o)){const a=f(),u={_in:o};a[s]?Array.isArray(a[s])?a[s].push(u):a[s]=[a[s],u]:a[s]=[u],n[0]=a}return this},whereBetween(s,o,a){if(s&&typeof s=="string"){const u=f(),p={_between:[o,a]};u[s]?Array.isArray(u[s])?u[s].push(p):u[s]=[u[s],p]:u[s]=p,n[0]=u}return this},limit(s){return typeof s=="number"&&Number.isFinite(s)&&(r=m(r||{},{limit:s})),this},offset(s){return typeof s=="number"&&Number.isFinite(s)&&(r=m(r||{},{offset:s})),this},toQuery(s=!1){let o;const a=n.length>0&&Object.keys(n[0]||{}).length>0,u=a?1:0,p=n.length>u;a&&p?o=n:p?o=n.slice(u):a&&(o=n[0]);const y=m(i?{sort:i}:{},o?{filters:o}:{}),_={data:{...e}};if(r&&(_.data.__args=r),Object.keys(y).length>0&&(_.__args=y),s&&(_.meta={total:!0,key:!0,name:!0}),c){const L=c.split(".");let C=_;for(let J=L.length-1;J>=0;J--)C={[L[J]]:C};return C}return{[`list${t}`]:_}}}}const Ot=(t,e={})=>{const r=e;let n="list"+t;const i=c=>r[c]?r[c]:null;return{field:i,$fields:r,setDataPath(c){return n=c,n},getDataPath(){return n},gqlFields(c){let l={};for(const f of c)if(typeof f=="string"){const s=i(f);s&&(l=m(l,s.gqlField?typeof s.gqlField=="string"?{[s.gqlField]:!0}:s.gqlField:{[s.name||f]:!0}))}else typeof f=="object"&&(l=m(l,f));return l},update(c,l){return d({["update"+t]:{__args:{id:c,data:l}}}).then(f=>f["update"+t])},async delete(c){return d({["delete"+t]:{__args:{id:c}}}).then(l=>l["delete"+t])},add(c){return d({["add"+t]:{__args:{data:c}}}).then(l=>l["add"+t])},fields(c){let l=[];for(let f of c){const s=i(f);s&&l.push(s)}return l},async get(c,l){const f=(await Promise.resolve().then(()=>$t)).default,s=f(t,yt(l));for(const[o,a]of Object.entries(c))s.where(o,"==",a);return await s.first()},list(c){let l=c;const f={};Object.entries(c).forEach(([a])=>{r[a]&&(f[a]=r[a],r[a].gqlField&&(delete l[a],l=m(l,r[a].gqlField)),r[a].gql&&(l=m(l,r[a].gql),delete l[a]))});const s=O(t,l).dataPath(n),o=s.fetch.bind(s);return{...s,async fetch(){return(await o()).map(u=>{const p={...u};return Object.entries(f).forEach(([y,_])=>{_.format&&typeof _.format=="function"&&(p[y]=_.format(u))}),p})},async fetchFirst(){const u=await s.fetchFirst.bind(s)();if(!u)return u;const p={...u};return Object.entries(f).forEach(([y,_])=>{_.format&&typeof _.format=="function"&&(p[y]=_.format(u))}),p}}}}},F={},M=(t,e)=>{const r=Ot(t,e);return F[t]=r,r},P=t=>F[t]?F[t]:M(t,{}),Dt=t=>!!F[t],Pt=()=>Object.keys(F),jt=()=>{Object.keys(F).forEach(t=>delete F[t])},kt=t=>{Object.entries(t).forEach(([e,r])=>{M(e,r)})},Ut=()=>w({app:{permissions:!0}}).then(t=>t.app.permissions),R=async()=>{const{app:t}=await w({app:{auth:{webAuthnRequestOptions:!0}}}),e=t.auth.webAuthnRequestOptions,r=PublicKeyCredential.parseRequestOptionsFromJSON(e);return await navigator.credentials.get({publicKey:r})},W=async()=>{const{app:t}=await w({app:{auth:{webAuthnCreationOptions:!0}}}),e=PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:e})},z=Object.freeze(Object.defineProperty({__proto__:null,assertion:R,attestation:W,login:async()=>{const t=await R();return await d({webAuthnAssertion:{__args:{assertion:t.toJSON()}}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await W();return await d({webAuthnRegister:{__args:{registration:t.toJSON()}}}).then(e=>e.webAuthnRegister)}},Symbol.toStringTag,{value:"Module"})),Q=(t=B)=>w({my:t}).then(e=>e.my),G=(t,e,r="")=>d({login:{__args:{username:t,password:e,code:r}}}).then(n=>n.login),H=()=>d({logout:!0}).then(t=>t.logout),V=(t,e,r)=>d({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(n=>n.changeExpiredPassword),X=(t,e)=>d({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),Y=(t,e,r)=>d({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(n=>n.resetPassword),Z=(t,e)=>d({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),I=(t,e)=>d({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),K=t=>w({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),x=t=>w({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),tt={getCurrentUser:Q,webAuthn:z,google:{unlink:()=>d({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>d({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>d({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>d({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>d({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>d({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>d({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>d({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>d({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:G,logout:H,changeExpiredPassword:V,updatePassword:X,resetPassword:Y,forgetPassword:Z,verifyCode:I,grantedRights:x,isGranted:K},et={name:!0,path:!0,size:!0,mime:!0,url:!0},rt=(t,e,r=et)=>w({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(n=>n.app.drive.files),st=(t,e)=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),vt=t=>({list:(e,r=et)=>rt(t,e,r),get:(e,r={name:!0,path:!0,size:!0,mime:!0,url:!0})=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},...r}}}}).then(n=>n.app.drive.file),readFileAsBase64(e){return st(t,e)},read:async e=>{let r=await w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}});if(!r.app.drive.file||!r.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${e}`);return typeof window<"u"&&window.atob?window.atob(r.app.drive.file.base64Content):r.app.drive.file.base64Content},write:(e,r)=>d({lightDriveWriteFile:{__args:{index:t,path:e,content:r}}}).then(n=>n.lightDriveWriteFile),delete:e=>d({lightDriveDeleteFile:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFile),rename:(e,r)=>d({lightDriveRenameFile:{__args:{index:t,path:e,name:r}}}).then(n=>n.lightDriveRenameFile),move:(e,r)=>d({lightDriveMoveFile:{__args:{index:t,source:e,destination:r}}}).then(n=>n.lightDriveMoveFile)}),nt={name:!0,path:!0},it=(t,e,r=nt)=>w({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(n=>n.app.drive.folders),St=t=>({list:(e,r=nt)=>it(t,e,r),create:e=>d({lightDriveCreateFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveCreateFolder),delete:e=>d({lightDriveDeleteFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFolder),rename:(e,r)=>d({lightDriveRenameFolder:{__args:{index:t,path:e,name:r}}}).then(n=>n.lightDriveRenameFolder)}),Et=()=>w({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),ot=t=>{const e=vt(t),r=St(t);return{folders:r,files:e,listFiles:e.list,getFile:e.get,readFile:e.read,writeFile:e.write,deleteFile:e.delete,renameFile:e.rename,moveFile:e.move,listFolders:r.list,createFolder:r.create,deleteFolder:r.delete,renameFolder:r.rename,uploadTempFile:n=>d({lightDriveUploadTempFile:{__args:{index:t,file:n},name:!0,path:!0,size:!0,mime:!0}}).then(i=>i.lightDriveUploadTempFile)}},B={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},at=t=>d({addUser:{__args:t}}).then(e=>e.addUser),ct=t=>d({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),lt=(t=B)=>O("Users",t).dataPath("app.listUser").fetch(),ut=(t,e)=>d({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),Mt={list:lt,create:at,delete:ct,update:ut},ht=t=>w({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]?.value),Bt={name:!0},ft=(t=Bt)=>w({app:{roles:t}}).then(e=>e.app.roles),pt=(t,e)=>d({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),dt=t=>d({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),qt=()=>({list:ft,create:pt,delete:dt});function gt(t,e,r,n,i){if(!(!t||typeof t!="object"))for(let c in t){const l=t[c];if(l&&typeof l=="object"){if("__args"in l){const f=l.__args,s={};Object.entries(f).forEach(([o,a])=>{if(a instanceof Array&&A(a)){s[o]=new b.VariableType(o);let u=0;a.forEach(p=>{p instanceof File&&(r[i.current]||(r[i.current]=[]),r[i.current].push("variables."+o+"."+u),n.append(i.current.toString(),p),i.current++,u++)}),e[o]="[Upload!]!"}else a instanceof File?(s[o]=new b.VariableType(o),r[i.current]=["variables."+o],n.append(i.current.toString(),a),e[o]="Upload!",i.current++):a instanceof Object&&S(a)?(s[o]={},Object.entries(a).forEach(([u,p])=>{if(p instanceof Array&&A(p)){s[o][u]=new b.VariableType(u);let y=0;p.forEach(_=>{_ instanceof File&&(r[i.current]||(r[i.current]=[]),r[i.current].push("variables."+u+"."+y),n.append(i.current.toString(),_),i.current++,y++)}),e[u]="[Upload!]!"}else p instanceof File?(s[o][u]=new b.VariableType(u),r[i.current]=["variables."+u],n.append(i.current.toString(),p),e[u]="Upload!",i.current++):s[o][u]=p})):a!=null&&(s[o]=a)}),l.__args=s}gt(l,e,r,n,i)}}}const d=async t=>{const{axios:e}=v(),r=t,n=new FormData;let i=!1;const c={},l={};gt(r,c,l,n,{current:0}),i=Object.keys(c).length>0,i&&(r.__variables=c);let s=null;const o={mutation:r},a=b.jsonToGraphQLQuery(o);if(i?(n.append("map",JSON.stringify(l)),n.append("operations",JSON.stringify({query:a})),s=await e.post("",n)):s=await e.post("",{query:a}),s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data},_t=(t,e,r)=>d({sendMail:{__args:{email:t,subject:e,message:r}}}).then(n=>n.sendMail),Nt={send:_t},q=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(q(r)).forEach(([n,i])=>{e[n]=i})}),e):(Object.entries(t).forEach(([r,n])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=n;return}if(typeof n=="boolean"){e[r]=n;return}e[r]=q(n)}),e)},yt=t=>q(t),Lt="list",Jt=["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"],Tt=["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 g{_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}}g.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}},g.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},g.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},g.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},j().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),g.prototype.fetchData=async function(){try{if(this._batchData){const f=this._batchData;return this.meta=f.meta,j(f.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={},n=r,i=e[e.length-1];for(const f of e){if(f===i){n[f]=t;break}n[f]={},n=n[f]}let l=await w(r);for(const f of e)l=l[f];return this.meta=l.meta,j(l.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},g.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},g.prototype.all=async function(){return(await this.processData()).all()};for(const t of Jt)g.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Tt)g.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};g.prototype.average=g.prototype.avg,g.prototype.first=async function(){return this.take(1),(await this.processData()).first()},g.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},g.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],n=t[1],i=t[2];switch(n){case"==":this.filters[r]=i;break;case"<":this.filters[r]={lt:i};break;case"<=":this.filters[r]={lte:i};break;case">":this.filters[r]={gt:i};break;case">=":this.filters[r]={gte:i};break;case"!==":this.filters[r]={ne:i};break;default:throw new Error(`Unsupported operator: ${n}`)}}return this},g.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},g.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)},g.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},g.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},g.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},g.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},g.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},g.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},g.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},g.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)},g.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 N=(t,e)=>{const r=new g(e);return r.data_path=Lt+t,r},$t=Object.freeze(Object.defineProperty({__proto__:null,default:N},Symbol.toStringTag,{value:"Module"})),Rt=t=>{const e=typeof window>"u";let r=[];const n=wt.create({baseURL:t,withCredentials:!0});e&&(n.interceptors.request.use(c=>(c.withCredentials=!0,r.length>0&&(c.headers.Cookie=r.join("; ")),c)),n.interceptors.response.use(c=>{if(c.headers["set-cookie"]){const l=c.headers["set-cookie"].map(s=>s.split(";")[0]),f=new Map;r.forEach(s=>{const o=s.split("=")[0];f.set(o,s)}),l.forEach(s=>{const o=s.split("=")[0];f.set(o,s)}),r=Array.from(f.values())}return c}));const i={post:n.post,baseURL:t,axios:n,auth:tt,mutation:d,query:w,config:ht,mail:Nt,users:Mt,model(c){return P(c)},roles:qt(),collect:(c,l)=>{const f=N(c,l);return f.data_path=P(c).getDataPath(),f},list:(c,l)=>O(c,l).dataPath(P(c).getDataPath()),drive:ot,async collects(c){const l={},f={};for(const o in c){const a=c[o].getQueryPayload();f[o]=a.data_path,l[o]={};const u=a.data_path.split(".");let p=u[u.length-1],y=l[o];for(const _ of u){if(_===p){y[_]=a.query;break}y[_]=y[_]||{}}l[o].__aliasFor=u[0]}const s=await w(l);for(const o in c){const a=f[o].split(".");let u=a[a.length-1],p=s[o];for(const y of a){if(y===u){c[o]._batchData=s[o][y];break}p[y]=p[y]||{}}}return c}};return T(i),i},Wt=O;h.arrayHasFile=A,h.auth=tt,h.changeExpiredPassword=V,h.clearModels=jt,h.createClient=Rt,h.createCollection=N,h.createFileFromBase64=At,h.createFileFromBase85=Ct,h.createFileFromString=E,h.createList=O,h.createRole=pt,h.createUser=at,h.defaultUserFields=B,h.defineModel=M,h.defineModels=kt,h.deleteRole=dt,h.deleteUser=ct,h.forgetPassword=Z,h.getApiClient=v,h.getApiClientOptional=mt,h.getConfig=ht,h.getCurrentUser=Q,h.getDrive=ot,h.getGrantedRights=x,h.getModel=P,h.hasModel=Dt,h.isGranted=K,h.list=Wt,h.listDrives=Et,h.listFiles=rt,h.listFolders=it,h.listModels=Pt,h.listPermissions=Ut,h.listRoles=ft,h.listUsers=lt,h.login=G,h.logout=H,h.mutation=d,h.objectHasFile=S,h.query=w,h.readFileAsBase64=st,h.resetPassword=Y,h.sendMail=_t,h.setApiClient=T,h.toQuery=yt,h.updatePassword=X,h.updateUser=ut,h.verifyCode=I,h.webAuthn=z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
package/dist/model.d.ts CHANGED
@@ -9,10 +9,6 @@ export type Field = {
9
9
  field?: any;
10
10
  format?: any;
11
11
  };
12
- export type Model = {
13
- name: string;
14
- fields: Record<string, Field>;
15
- };
16
12
  declare const _default: (name: string, fields?: Record<string, Field>) => {
17
13
  field: (f: string) => Field | null;
18
14
  $fields: Record<string, Field>;
package/dist/models.d.ts CHANGED
@@ -183,7 +183,179 @@ export declare const defineModel: (name: string, fields: Record<string, Field>)
183
183
  * @param name 模型名稱
184
184
  * @returns 模型實例
185
185
  */
186
- export declare const getModel: (name: string) => any;
186
+ export declare const getModel: (name: string) => {
187
+ field: (f: string) => Field | null;
188
+ $fields: Record<string, Field>;
189
+ setDataPath(path: string): string;
190
+ getDataPath(): string;
191
+ gqlFields(fields: (string | object)[]): Record<string, any>;
192
+ update(id: number, data: Object): Promise<any>;
193
+ delete(id: number): Promise<any>;
194
+ add(data: Object): Promise<any>;
195
+ fields(fields: string[]): Field[];
196
+ get(filters: any, fields: import('.').Fields): Promise<any>;
197
+ list(fields: Record<string, any>): {
198
+ fetch(): Promise<any[]>;
199
+ fetchFirst(): Promise<any>;
200
+ first(): Promise<any>;
201
+ all(): Promise<any[]>;
202
+ fetchWithMeta(): Promise<any>;
203
+ dataPath(dataPath?: string): {
204
+ first(): Promise<any>;
205
+ all(): Promise<any[]>;
206
+ fetchFirst(): Promise<any>;
207
+ fetchWithMeta(): Promise<any>;
208
+ fetch(): Promise<any[]>;
209
+ dataPath(dataPath?: string): /*elided*/ any;
210
+ sort(sortStr: string): /*elided*/ any;
211
+ filters(filterObj: Record<string, any>): /*elided*/ any;
212
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
213
+ whereContains(field: string, val: any): /*elided*/ any;
214
+ whereIn(field: string, vals: any[]): /*elided*/ any;
215
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
216
+ limit(n: number): /*elided*/ any;
217
+ offset(n: number): /*elided*/ any;
218
+ toQuery(includeMeta?: boolean): any;
219
+ };
220
+ sort(sortStr: string): {
221
+ first(): Promise<any>;
222
+ all(): Promise<any[]>;
223
+ fetchFirst(): Promise<any>;
224
+ fetchWithMeta(): Promise<any>;
225
+ fetch(): Promise<any[]>;
226
+ dataPath(dataPath?: string): /*elided*/ any;
227
+ sort(sortStr: string): /*elided*/ any;
228
+ filters(filterObj: Record<string, any>): /*elided*/ any;
229
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
230
+ whereContains(field: string, val: any): /*elided*/ any;
231
+ whereIn(field: string, vals: any[]): /*elided*/ any;
232
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
233
+ limit(n: number): /*elided*/ any;
234
+ offset(n: number): /*elided*/ any;
235
+ toQuery(includeMeta?: boolean): any;
236
+ };
237
+ filters(filterObj: Record<string, any>): {
238
+ first(): Promise<any>;
239
+ all(): Promise<any[]>;
240
+ fetchFirst(): Promise<any>;
241
+ fetchWithMeta(): Promise<any>;
242
+ fetch(): Promise<any[]>;
243
+ dataPath(dataPath?: string): /*elided*/ any;
244
+ sort(sortStr: string): /*elided*/ any;
245
+ filters(filterObj: Record<string, any>): /*elided*/ any;
246
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
247
+ whereContains(field: string, val: any): /*elided*/ any;
248
+ whereIn(field: string, vals: any[]): /*elided*/ any;
249
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
250
+ limit(n: number): /*elided*/ any;
251
+ offset(n: number): /*elided*/ any;
252
+ toQuery(includeMeta?: boolean): any;
253
+ };
254
+ where(key: string, opOrVal?: any, maybeVal?: any): {
255
+ first(): Promise<any>;
256
+ all(): Promise<any[]>;
257
+ fetchFirst(): Promise<any>;
258
+ fetchWithMeta(): Promise<any>;
259
+ fetch(): Promise<any[]>;
260
+ dataPath(dataPath?: string): /*elided*/ any;
261
+ sort(sortStr: string): /*elided*/ any;
262
+ filters(filterObj: Record<string, any>): /*elided*/ any;
263
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
264
+ whereContains(field: string, val: any): /*elided*/ any;
265
+ whereIn(field: string, vals: any[]): /*elided*/ any;
266
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
267
+ limit(n: number): /*elided*/ any;
268
+ offset(n: number): /*elided*/ any;
269
+ toQuery(includeMeta?: boolean): any;
270
+ };
271
+ whereContains(field: string, val: any): {
272
+ first(): Promise<any>;
273
+ all(): Promise<any[]>;
274
+ fetchFirst(): Promise<any>;
275
+ fetchWithMeta(): Promise<any>;
276
+ fetch(): Promise<any[]>;
277
+ dataPath(dataPath?: string): /*elided*/ any;
278
+ sort(sortStr: string): /*elided*/ any;
279
+ filters(filterObj: Record<string, any>): /*elided*/ any;
280
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
281
+ whereContains(field: string, val: any): /*elided*/ any;
282
+ whereIn(field: string, vals: any[]): /*elided*/ any;
283
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
284
+ limit(n: number): /*elided*/ any;
285
+ offset(n: number): /*elided*/ any;
286
+ toQuery(includeMeta?: boolean): any;
287
+ };
288
+ whereIn(field: string, vals: any[]): {
289
+ first(): Promise<any>;
290
+ all(): Promise<any[]>;
291
+ fetchFirst(): Promise<any>;
292
+ fetchWithMeta(): Promise<any>;
293
+ fetch(): Promise<any[]>;
294
+ dataPath(dataPath?: string): /*elided*/ any;
295
+ sort(sortStr: string): /*elided*/ any;
296
+ filters(filterObj: Record<string, any>): /*elided*/ any;
297
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
298
+ whereContains(field: string, val: any): /*elided*/ any;
299
+ whereIn(field: string, vals: any[]): /*elided*/ any;
300
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
301
+ limit(n: number): /*elided*/ any;
302
+ offset(n: number): /*elided*/ any;
303
+ toQuery(includeMeta?: boolean): any;
304
+ };
305
+ whereBetween(field: string, min: any, max: any): {
306
+ first(): Promise<any>;
307
+ all(): Promise<any[]>;
308
+ fetchFirst(): Promise<any>;
309
+ fetchWithMeta(): Promise<any>;
310
+ fetch(): Promise<any[]>;
311
+ dataPath(dataPath?: string): /*elided*/ any;
312
+ sort(sortStr: string): /*elided*/ any;
313
+ filters(filterObj: Record<string, any>): /*elided*/ any;
314
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
315
+ whereContains(field: string, val: any): /*elided*/ any;
316
+ whereIn(field: string, vals: any[]): /*elided*/ any;
317
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
318
+ limit(n: number): /*elided*/ any;
319
+ offset(n: number): /*elided*/ any;
320
+ toQuery(includeMeta?: boolean): any;
321
+ };
322
+ limit(n: number): {
323
+ first(): Promise<any>;
324
+ all(): Promise<any[]>;
325
+ fetchFirst(): Promise<any>;
326
+ fetchWithMeta(): Promise<any>;
327
+ fetch(): Promise<any[]>;
328
+ dataPath(dataPath?: string): /*elided*/ any;
329
+ sort(sortStr: string): /*elided*/ any;
330
+ filters(filterObj: Record<string, any>): /*elided*/ any;
331
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
332
+ whereContains(field: string, val: any): /*elided*/ any;
333
+ whereIn(field: string, vals: any[]): /*elided*/ any;
334
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
335
+ limit(n: number): /*elided*/ any;
336
+ offset(n: number): /*elided*/ any;
337
+ toQuery(includeMeta?: boolean): any;
338
+ };
339
+ offset(n: number): {
340
+ first(): Promise<any>;
341
+ all(): Promise<any[]>;
342
+ fetchFirst(): Promise<any>;
343
+ fetchWithMeta(): Promise<any>;
344
+ fetch(): Promise<any[]>;
345
+ dataPath(dataPath?: string): /*elided*/ any;
346
+ sort(sortStr: string): /*elided*/ any;
347
+ filters(filterObj: Record<string, any>): /*elided*/ any;
348
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
349
+ whereContains(field: string, val: any): /*elided*/ any;
350
+ whereIn(field: string, vals: any[]): /*elided*/ any;
351
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
352
+ limit(n: number): /*elided*/ any;
353
+ offset(n: number): /*elided*/ any;
354
+ toQuery(includeMeta?: boolean): any;
355
+ };
356
+ toQuery(includeMeta?: boolean): any;
357
+ };
358
+ };
187
359
  /**
188
360
  * 檢查模型是否存在
189
361
  * @param name 模型名稱
@@ -378,7 +550,179 @@ declare const _default: {
378
550
  toQuery(includeMeta?: boolean): any;
379
551
  };
380
552
  };
381
- getModel: (name: string) => any;
553
+ getModel: (name: string) => {
554
+ field: (f: string) => Field | null;
555
+ $fields: Record<string, Field>;
556
+ setDataPath(path: string): string;
557
+ getDataPath(): string;
558
+ gqlFields(fields: (string | object)[]): Record<string, any>;
559
+ update(id: number, data: Object): Promise<any>;
560
+ delete(id: number): Promise<any>;
561
+ add(data: Object): Promise<any>;
562
+ fields(fields: string[]): Field[];
563
+ get(filters: any, fields: import('.').Fields): Promise<any>;
564
+ list(fields: Record<string, any>): {
565
+ fetch(): Promise<any[]>;
566
+ fetchFirst(): Promise<any>;
567
+ first(): Promise<any>;
568
+ all(): Promise<any[]>;
569
+ fetchWithMeta(): Promise<any>;
570
+ dataPath(dataPath?: string): {
571
+ first(): Promise<any>;
572
+ all(): Promise<any[]>;
573
+ fetchFirst(): Promise<any>;
574
+ fetchWithMeta(): Promise<any>;
575
+ fetch(): Promise<any[]>;
576
+ dataPath(dataPath?: string): /*elided*/ any;
577
+ sort(sortStr: string): /*elided*/ any;
578
+ filters(filterObj: Record<string, any>): /*elided*/ any;
579
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
580
+ whereContains(field: string, val: any): /*elided*/ any;
581
+ whereIn(field: string, vals: any[]): /*elided*/ any;
582
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
583
+ limit(n: number): /*elided*/ any;
584
+ offset(n: number): /*elided*/ any;
585
+ toQuery(includeMeta?: boolean): any;
586
+ };
587
+ sort(sortStr: string): {
588
+ first(): Promise<any>;
589
+ all(): Promise<any[]>;
590
+ fetchFirst(): Promise<any>;
591
+ fetchWithMeta(): Promise<any>;
592
+ fetch(): Promise<any[]>;
593
+ dataPath(dataPath?: string): /*elided*/ any;
594
+ sort(sortStr: string): /*elided*/ any;
595
+ filters(filterObj: Record<string, any>): /*elided*/ any;
596
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
597
+ whereContains(field: string, val: any): /*elided*/ any;
598
+ whereIn(field: string, vals: any[]): /*elided*/ any;
599
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
600
+ limit(n: number): /*elided*/ any;
601
+ offset(n: number): /*elided*/ any;
602
+ toQuery(includeMeta?: boolean): any;
603
+ };
604
+ filters(filterObj: Record<string, any>): {
605
+ first(): Promise<any>;
606
+ all(): Promise<any[]>;
607
+ fetchFirst(): Promise<any>;
608
+ fetchWithMeta(): Promise<any>;
609
+ fetch(): Promise<any[]>;
610
+ dataPath(dataPath?: string): /*elided*/ any;
611
+ sort(sortStr: string): /*elided*/ any;
612
+ filters(filterObj: Record<string, any>): /*elided*/ any;
613
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
614
+ whereContains(field: string, val: any): /*elided*/ any;
615
+ whereIn(field: string, vals: any[]): /*elided*/ any;
616
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
617
+ limit(n: number): /*elided*/ any;
618
+ offset(n: number): /*elided*/ any;
619
+ toQuery(includeMeta?: boolean): any;
620
+ };
621
+ where(key: string, opOrVal?: any, maybeVal?: any): {
622
+ first(): Promise<any>;
623
+ all(): Promise<any[]>;
624
+ fetchFirst(): Promise<any>;
625
+ fetchWithMeta(): Promise<any>;
626
+ fetch(): Promise<any[]>;
627
+ dataPath(dataPath?: string): /*elided*/ any;
628
+ sort(sortStr: string): /*elided*/ any;
629
+ filters(filterObj: Record<string, any>): /*elided*/ any;
630
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
631
+ whereContains(field: string, val: any): /*elided*/ any;
632
+ whereIn(field: string, vals: any[]): /*elided*/ any;
633
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
634
+ limit(n: number): /*elided*/ any;
635
+ offset(n: number): /*elided*/ any;
636
+ toQuery(includeMeta?: boolean): any;
637
+ };
638
+ whereContains(field: string, val: any): {
639
+ first(): Promise<any>;
640
+ all(): Promise<any[]>;
641
+ fetchFirst(): Promise<any>;
642
+ fetchWithMeta(): Promise<any>;
643
+ fetch(): Promise<any[]>;
644
+ dataPath(dataPath?: string): /*elided*/ any;
645
+ sort(sortStr: string): /*elided*/ any;
646
+ filters(filterObj: Record<string, any>): /*elided*/ any;
647
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
648
+ whereContains(field: string, val: any): /*elided*/ any;
649
+ whereIn(field: string, vals: any[]): /*elided*/ any;
650
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
651
+ limit(n: number): /*elided*/ any;
652
+ offset(n: number): /*elided*/ any;
653
+ toQuery(includeMeta?: boolean): any;
654
+ };
655
+ whereIn(field: string, vals: any[]): {
656
+ first(): Promise<any>;
657
+ all(): Promise<any[]>;
658
+ fetchFirst(): Promise<any>;
659
+ fetchWithMeta(): Promise<any>;
660
+ fetch(): Promise<any[]>;
661
+ dataPath(dataPath?: string): /*elided*/ any;
662
+ sort(sortStr: string): /*elided*/ any;
663
+ filters(filterObj: Record<string, any>): /*elided*/ any;
664
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
665
+ whereContains(field: string, val: any): /*elided*/ any;
666
+ whereIn(field: string, vals: any[]): /*elided*/ any;
667
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
668
+ limit(n: number): /*elided*/ any;
669
+ offset(n: number): /*elided*/ any;
670
+ toQuery(includeMeta?: boolean): any;
671
+ };
672
+ whereBetween(field: string, min: any, max: any): {
673
+ first(): Promise<any>;
674
+ all(): Promise<any[]>;
675
+ fetchFirst(): Promise<any>;
676
+ fetchWithMeta(): Promise<any>;
677
+ fetch(): Promise<any[]>;
678
+ dataPath(dataPath?: string): /*elided*/ any;
679
+ sort(sortStr: string): /*elided*/ any;
680
+ filters(filterObj: Record<string, any>): /*elided*/ any;
681
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
682
+ whereContains(field: string, val: any): /*elided*/ any;
683
+ whereIn(field: string, vals: any[]): /*elided*/ any;
684
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
685
+ limit(n: number): /*elided*/ any;
686
+ offset(n: number): /*elided*/ any;
687
+ toQuery(includeMeta?: boolean): any;
688
+ };
689
+ limit(n: number): {
690
+ first(): Promise<any>;
691
+ all(): Promise<any[]>;
692
+ fetchFirst(): Promise<any>;
693
+ fetchWithMeta(): Promise<any>;
694
+ fetch(): Promise<any[]>;
695
+ dataPath(dataPath?: string): /*elided*/ any;
696
+ sort(sortStr: string): /*elided*/ any;
697
+ filters(filterObj: Record<string, any>): /*elided*/ any;
698
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
699
+ whereContains(field: string, val: any): /*elided*/ any;
700
+ whereIn(field: string, vals: any[]): /*elided*/ any;
701
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
702
+ limit(n: number): /*elided*/ any;
703
+ offset(n: number): /*elided*/ any;
704
+ toQuery(includeMeta?: boolean): any;
705
+ };
706
+ offset(n: number): {
707
+ first(): Promise<any>;
708
+ all(): Promise<any[]>;
709
+ fetchFirst(): Promise<any>;
710
+ fetchWithMeta(): Promise<any>;
711
+ fetch(): Promise<any[]>;
712
+ dataPath(dataPath?: string): /*elided*/ any;
713
+ sort(sortStr: string): /*elided*/ any;
714
+ filters(filterObj: Record<string, any>): /*elided*/ any;
715
+ where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
716
+ whereContains(field: string, val: any): /*elided*/ any;
717
+ whereIn(field: string, vals: any[]): /*elided*/ any;
718
+ whereBetween(field: string, min: any, max: any): /*elided*/ any;
719
+ limit(n: number): /*elided*/ any;
720
+ offset(n: number): /*elided*/ any;
721
+ toQuery(includeMeta?: boolean): any;
722
+ };
723
+ toQuery(includeMeta?: boolean): any;
724
+ };
725
+ };
382
726
  hasModel: (name: string) => boolean;
383
727
  listModels: () => string[];
384
728
  clearModels: () => void;
@@ -1,5 +1,5 @@
1
1
  export declare const listPermissions: () => Promise<Array<string>>;
2
- declare const _default: () => {
2
+ declare const _default: {
3
3
  list: () => Promise<Array<string>>;
4
4
  };
5
5
  export default _default;
package/dist/users.d.ts CHANGED
@@ -20,7 +20,7 @@ export declare const createUser: (fields: CreateUserFields) => Promise<any>;
20
20
  export declare const deleteUser: (id: Number) => Promise<boolean>;
21
21
  export declare const listUsers: (fields?: QueryUserFieldsUserFields) => Promise<any[]>;
22
22
  export declare const updateUser: (id: number, fields: Partial<CreateUserFields>) => Promise<any>;
23
- declare const _default: () => {
23
+ declare const _default: {
24
24
  list: (fields?: QueryUserFieldsUserFields) => Promise<any[]>;
25
25
  create: (fields: CreateUserFields) => Promise<any>;
26
26
  delete: (id: Number) => Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,32 +0,0 @@
1
- import { default as auth } from './auth';
2
- import { getDrive } from './drive';
3
- import { AxiosInstance } from 'axios';
4
- import { Fields } from '.';
5
- import { getConfig } from './config';
6
- import { default as mail } from './mail';
7
- import { default as roles } from './role';
8
- import { default as createCollection } from './createCollection';
9
- import { default as createList } from './createList';
10
- import { default as users } from './users';
11
- export interface LightClient {
12
- baseURL: string;
13
- axios: AxiosInstance;
14
- auth: ReturnType<typeof auth>;
15
- mutation: (q: Record<string, any>) => Promise<any>;
16
- query: (q: Record<string, any>) => Promise<any>;
17
- config: typeof getConfig;
18
- mail: typeof mail;
19
- users: ReturnType<typeof users>;
20
- roles: ReturnType<typeof roles>;
21
- collect(name: string, fields: Record<string, any>): ReturnType<typeof createCollection>;
22
- drive(index: number): ReturnType<typeof getDrive>;
23
- collects(collections: {
24
- [key: string]: any;
25
- }): Promise<{
26
- [key: string]: any;
27
- }>;
28
- list(entity: string, fields: Fields): ReturnType<typeof createList>;
29
- post: AxiosInstance['post'];
30
- }
31
- declare const _default: (baseURL: string) => LightClient;
32
- export default _default;