@hostlink/light 2.11.1 → 2.13.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.
- package/dist/createClient.d.ts +2 -2
- package/dist/createList.d.ts +3 -1
- package/dist/index.d.ts +3 -0
- package/dist/light.js +634 -493
- package/dist/light.umd.cjs +1 -1
- package/dist/model.d.ts +176 -16
- package/dist/useModel.d.ts +271 -0
- package/dist/users.d.ts +17 -1
- package/package.json +1 -1
- package/dist/gqlBuilder.d.ts +0 -6
- package/dist/model.test.d.ts +0 -1
- package/dist/models.d.ts +0 -9
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_,m){typeof exports=="object"&&typeof module<"u"?m(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"],m):(_=typeof globalThis<"u"?globalThis:_||self,m(_.light={},_.jsonToGraphqlQuery,_.axios,_.collect))})(this,function(_,m,O,P){"use strict";var rt=Object.defineProperty;var st=(_,m,O)=>m in _?rt(_,m,{enumerable:!0,configurable:!0,writable:!0,value:O}):_[m]=O;var C=(_,m,O)=>st(_,typeof m!="symbol"?m+"":m,O);const q=t=>({assertion:async()=>{const{app:s}=await b(t,{app:{auth:{webAuthnRequestOptions:!0}}}),i=s.auth.webAuthnRequestOptions,h=PublicKeyCredential.parseRequestOptionsFromJSON(i);return await navigator.credentials.get({publicKey:h})},attestation:async()=>{const{app:s}=await b(t,{app:{auth:{webAuthnCreationOptions:!0}}}),i=PublicKeyCredential.parseCreationOptionsFromJSON(s.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:i})}}),L=t=>{const{assertion:e,attestation:r}=q(t);return{login:async()=>{const s=await e();await p(t,"webAuthnAssertion",{assertion:s.toJSON()})},register:async()=>{const s=await r();await p(t,"webAuthnRegister",{registration:s.toJSON()})}}},U=t=>({WebAuthn:L(t),google:{unlink:()=>p(t,"lightAuthUnlinkGoogle"),login:e=>p(t,"lightAuthLoginGoogle",{credential:e}),register:e=>p(t,"lightAuthRegisterGoogle",{credential:e})},facebook:{unlink:()=>p(t,"lightAuthUnlinkFacebook"),login:e=>p(t,"lightAuthLoginFacebook",{access_token:e}),register:e=>p(t,"lightAuthRegisterFacebook",{access_token:e})},microsoft:{unlink:()=>p(t,"lightAuthUnlinkMicrosoft"),login:e=>p(t,"lightAuthLoginMicrosoft",{access_token:e}),register:e=>p(t,"lightAuthRegisterMicrosoft",{account_id:e})},login:(e,r,s="")=>p(t,"login",{username:e,password:r,code:s}),logout:()=>p(t,"logout"),changeExpiredPassword:(e,r,s)=>p(t,"changeExpiredPassword",{username:e,old_password:r,new_password:s}),updatePassword:(e,r)=>p(t,"changeUserPassword",{old_password:e,new_password:r}),resetPassword:(e,r,s)=>p(t,"resetPassword",{jwt:e,password:r,code:s}),forgetPassword:(e,r)=>p(t,"forgetPassword",{username:e,email:r}),verifyCode(e,r){return p(t,"forgetPasswordVerifyCode",{jwt:e,code:r})},granted:async e=>{const{my:r}=await b(t,{my:{grantedRights:{__args:{rights:e}}}});return r.grantedRights}}),J=(t,e,r)=>{const s=e,i=t,h=r;let f="list"+e;const o=u=>h[u]?h[u]():null;return{field:o,$fields:h,setDataPath(u){return f=u,f},getDataPath(){return f},gqlFields(u){const n=[];for(const a of u)if(typeof a=="string"){const l=o(a);l&&n.push(l.getGQLField())}else typeof a=="object"&&n.push(a);return n},async update(u,n){return await p(i,"update"+s,{id:u,data:n})},async delete(u){return await p(i,"delete"+s,{id:u})},async add(u){return await p(i,"add"+s,{data:u})},fields(u){let n=[];for(let a of u){const l=o(a);l&&n.push(l)}return n},async get(u,n){const a=(await Promise.resolve().then(()=>R)).default,l=a(s,i,k(n));for(const[c,d]of Object.entries(u))l.where(c,"==",d);return await l.first()},async list(u,n){const a=(await Promise.resolve().then(()=>R)).default,l=a(s,i,k(n));for(const[c,d]of Object.entries(u))l.where(c,"==",d);return await l.all()}}};function M(t){t="<~"+t+"~>";var e,r,s,i,h,f=String,o=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=[],i=0,h=t.length;h>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),s.push(o&r>>24,o&r>>16,o&r>>8,o&r);return function(u,n){for(var a=n;a>0;a--)u.pop()}(s,e.length),f.fromCharCode.apply(f,s)}const D=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const i=new Uint8Array(e.length);for(let o=0;o<e.length;o++)i[o]=e.charCodeAt(o);const h=new Blob([i],{type:s});return URL.createObjectURL(h)};return{getContent:()=>e,getURL:r,download:s=>{const i=document.createElement("a");i.download=s,i.href=r(),document.body.appendChild(i),i.click(),document.body.removeChild(i)},open:s=>{window.open(r(s),"_blank")}}},T={fromBase85:t=>D(M(t)),fromBase64:t=>D(atob(t)),fromString:t=>D(t)},S=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(S(r)).forEach(([s,i])=>{e[s]=i})}),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]=S(s)}),e)},k=t=>S(t),b=async(t,e)=>{let r=m.jsonToGraphQLQuery(k(e));const s=await t.post("",{query:`{ ${r} }`});if(s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function W(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function Q(t){for(let e in t)if(t[e]instanceof File)return!0;return!1}const p=async(t,e,r=null,s=[])=>{let i={[e]:{}};const h=new FormData;let f=!1;if(r){const n={},a={},l={};let c=0;Object.entries(r).forEach(([d,w])=>{if(w instanceof Array&&W(w)){f=!0;let y=0;w.forEach(A=>{A instanceof File&&(n[d]=new m.VariableType(d),a[c]=["variables."+d+"."+y],h.append(c.toString(),A),c++)}),l[d]="[Upload!]!"}else w instanceof File?(f=!0,n[d]=new m.VariableType(d),a[c]=["variables."+d],h.append(c.toString(),w),l[d]="Upload!",c++):w instanceof Object&&Q(w)?(f=!0,n[d]={},Object.entries(w).forEach(([y,A])=>{A instanceof File?(n[d][y]=new m.VariableType(y),a[c]=["variables."+y],h.append(c.toString(),A),l[y]="Upload!",c++):n[d][y]=A})):w!==void 0&&(n[d]=w)}),i[e].__args=n,i.__variables=l,f&&h.append("map",JSON.stringify(a))}Object.entries(k(s)).forEach(([n,a])=>{i[e][n]=a}),Object.entries(i[e]).length===0&&(i[e]=!0);let o=null;const u=m.jsonToGraphQLQuery({mutation:i});if(f?(h.append("operations",JSON.stringify({query:u})),o=await t.post("",h)):o=await t.post("",{query:u}),o.data.errors)throw new Error(o.data.errors[0].message);return o.data.data[e]},$=t=>({uploadTempFile:e=>p(t,"fsUploadTempFile",{file:e},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async e=>(await b(t,{fsListFolders:{__args:{path:e},name:!0,path:!0}})).fsListFolders,create:e=>p(t,"fsCreateFolder",{path:e}),delete:e=>p(t,"fsDeleteFolder",{path:e}),rename:(e,r)=>p(t,"fsRenameFolder",{path:e,name:r})},files:{list:async e=>{let{app:r}=await b(t,{app:{drive:{files:{__args:{path:e},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}}}});return r.drive.files},read:async e=>{let{app:r}=await b(t,{app:{drive:{files:{__args:{path:e},base64Content:!0}}}});return window.atob(r.drive.files[0].base64Content)},write:(e,r)=>p(t,"fsWriteFile",{path:e,content:r}),delete:e=>p(t,"fsDeleteFile",{path:e}),rename:(e,r)=>p(t,"fsRenameFile",{path:e,name:r}),move:(e,r)=>p(t,"fsMoveFile",{source:e,target:r})}}),z=t=>({get:async e=>(await t({config:{__args:{name:e}}})).config}),I=t=>({send:(e,r,s)=>p(t,"sendMail",{email:e,subject:r,message:s})}),K=t=>({list:async(e={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0})=>{const r=j("Users",t,e);return r.data_path="app.users",r.all()}}),G=t=>{const e=t,r={};return{create(s,i){r[s]=null;let h={};for(const f of Object.entries(i)){const[o,u]=f;h[o]=()=>({name:u.name?u.name:o,raw:u,getName:()=>u.name?u.name:o,getGQLField:()=>u.gqlField!==void 0?u.gqlField:u.name||o,getRaw(){return u},getValue(n){return u.field&&typeof u.field=="function"?u.field(n):u.field&&typeof u.field=="string"?n[u.field]:n[this.getName()]},getFormattedValue(n){const a=this.getValue(n);return u.format?u.format(a):a}})}r[s]=J(e,s,h)},get(s){return r[s]||this.create(s,{}),r[s]}}},V=t=>({list:async(e={name:!0})=>{const{app:{roles:r}}=await b(t,{app:{roles:e}});return r}}),H="list",X=["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"],Y=["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{constructor(e,r){C(this,"_batchData",null);C(this,"data_path","");C(this,"axios");C(this,"filters");C(this,"steps");C(this,"fields");C(this,"already_limit",!1);C(this,"already_offset",!1);C(this,"limit",null);C(this,"offset",null);C(this,"_sort",null);C(this,"_sortDesc",!1);C(this,"meta",{});this.axios=r,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},P().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 o=this._batchData;return this.meta=o.meta,P(o.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,i=e[e.length-1];for(const o of e){if(o===i){s[o]=t;break}s[o]={},s=s[o]}let f=await b(this.axios,r);for(const o of e)f=f[o];return this.meta=f.meta,P(f.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 X)g.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Y)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],s=t[1],i=t[2];switch(s){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: ${s}`)}}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 j=(t,e,r)=>{const s=new g(r,e);return s.data_path=H+t,s},R=Object.freeze(Object.defineProperty({__proto__:null,default:j},Symbol.toStringTag,{value:"Module"})),Z=(t,e)=>({uploadTempFile:r=>p(e,"lightDriveUploadTempFile",{index:t,file:r},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async(r,s={name:!0,path:!0})=>(await b(e,{app:{drive:{__args:{index:t},folders:{__args:{path:r},...s}}}})).app.drive.folders,create:r=>p(e,"lightDriveCreateFolder",{index:t,path:r}),delete:r=>p(e,"lightDriveDeleteFolder",{index:t,path:r}),rename:(r,s)=>p(e,"lightDriveRenameFolder",{index:t,path:r,name:s})},files:{list:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await b(e,{app:{drive:{__args:{index:t},files:{__args:{path:r},...s}}}})).app.drive.files,get:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await b(e,{app:{drive:{__args:{index:t},file:{__args:{path:r},...s}}}})).app.drive.file,read:async r=>{let s=await b(e,{app:{drive:{__args:{index:t},file:{__args:{path:r},base64Content:!0}}}});if(!s.app.drive.file||!s.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${r}`);return typeof window<"u"&&window.atob?window.atob(s.app.drive.file.base64Content):s.app.drive.file.base64Content},write:(r,s)=>p(e,"lightDriveWriteFile",{index:t,path:r,content:s}),delete:r=>p(e,"lightDriveDeleteFile",{index:t,path:r}),rename:(r,s)=>p(e,"lightDriveRenameFile",{index:t,path:r,name:s}),move:(r,s)=>p(e,"lightDriveMoveFile",{index:t,source:r,destination:s})}});function N(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 B(t,e,r=".",s){if(!N(e))return B(t,{},r,s);const i=Object.assign({},e);for(const h in t){if(h==="__proto__"||h==="constructor")continue;const f=t[h];f!=null&&(s&&s(i,h,f,r)||(Array.isArray(f)&&Array.isArray(i[h])?i[h]=[...f,...i[h]]:N(f)&&N(i[h])?i[h]=B(f,i[h],(r?`${r}.`:"")+h.toString(),s):i[h]=f))}return i}function x(t){return(...e)=>e.reduce((r,s)=>B(r,s,"",t),{})}const v=x();function tt(t,e,r){let s,i=[],h,f;const o=n=>!n||typeof n!="object"?!1:Object.values(n).some(a=>a&&typeof a=="object"&&Object.keys(a).some(l=>l.startsWith("_"))),u=()=>i.length===0?(i.unshift({}),i[0]):(o(i[0])&&i.unshift({}),i[0]);return{async fetchFirst(){return await this.limit(1).fetch().then(a=>Array.isArray(a)&&a.length>0?a[0]:null)},async fetchWithMeta(){let a=await b(t,this.toQuery(!0));if(f){const l=f.split(".");for(const c of l)a=a[c];return a}return a[`list${e}`]},async fetch(){let a=await b(t,this.toQuery());if(f){const l=f.split(".");for(const c of l)a=a[c];return a.data}return a[`list${e}`].data},dataPath(n){return n&&typeof n=="string"&&(f=n),this},sort(n){return n&&typeof n=="string"&&(h=n),this},filters(n){return n&&typeof n=="object"&&(i=[n]),this},where(n,a,l){const c=(d,w,y)=>{const F={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[w];F&&i.push({[d]:{[F]:y}})};if(l!==void 0)c(n,String(a),l);else{const d=u(),w=v(d,{[n]:a});i[0]=w}return this},whereContains(n,a){if(n&&typeof n=="string"){const l=u(),c={_contains:a};l[n]?Array.isArray(l[n])?l[n].push(c):l[n]=[l[n],c]:l[n]=[c],i[0]=l}return this},whereIn(n,a){if(n&&typeof n=="string"&&Array.isArray(a)){const l=u(),c={_in:a};l[n]?Array.isArray(l[n])?l[n].push(c):l[n]=[l[n],c]:l[n]=[c],i[0]=l}return this},whereBetween(n,a,l){if(n&&typeof n=="string"){const c=u(),d={_between:[a,l]};c[n]?Array.isArray(c[n])?c[n].push(d):c[n]=[c[n],d]:c[n]=d,i[0]=c}return this},limit(n){return typeof n=="number"&&Number.isFinite(n)&&(s=v(s||{},{limit:n})),this},offset(n){return typeof n=="number"&&Number.isFinite(n)&&(s=v(s||{},{offset:n})),this},toQuery(n=!1){let a;const l=i.length>0&&Object.keys(i[0]||{}).length>0,c=l?1:0,d=i.length>c;l&&d?a=i:d?a=i.slice(c):l&&(a=i[0]);const w=v(h?{sort:h}:{},a?{filters:a}:{}),y={data:{...r}};if(s&&(y.data.__args=s),Object.keys(w).length>0&&(y.__args=w),n&&(y.meta={total:!0,key:!0,name:!0}),f){const A=f.split(".");let F=y;for(let E=A.length-1;E>=0;E--)F={[A[E]]:F};return F}return{[`list${e}`]:y}}}}const et=t=>{const e=typeof window>"u";let r=[];const s=O.create({baseURL:t,withCredentials:!0});e&&(s.interceptors.request.use(o=>(o.withCredentials=!0,r.length>0&&(o.headers.Cookie=r.join("; ")),o)),s.interceptors.response.use(o=>{if(o.headers["set-cookie"]){const u=o.headers["set-cookie"].map(a=>a.split(";")[0]),n=new Map;r.forEach(a=>{const l=a.split("=")[0];n.set(l,a)}),u.forEach(a=>{const l=a.split("=")[0];n.set(l,a)}),r=Array.from(n.values())}return o}));const i=(o,u=null,n=[])=>p(s,o,u,n),h=o=>b(s,o),f=G(s);return{baseURL:t,axios:s,auth:U(s),mutation:i,query:h,config:z(h),mail:I(s),users:K(s),fs:$(s),models:f,model(o){return f.get(o)},roles:V(s),collect:(o,u)=>{const n=j(o,s,u);return n.data_path=f.get(o).getDataPath(),n},list:(o,u)=>tt(s,o,u).dataPath(f.get(o).getDataPath()),drive(o){return Z(o,s)},async collects(o){const u={},n={};for(const l in o){const c=o[l].getQueryPayload();n[l]=c.data_path,u[l]={};const d=c.data_path.split(".");let w=d[d.length-1],y=u[l];for(const A of d){if(A===w){y[A]=c.query;break}y[A]=y[A]||{}}u[l].__aliasFor=d[0]}const a=await b(s,u);for(const l in o){const c=n[l].split(".");let d=c[c.length-1],w=a[l];for(const y of c){if(y===d){o[l]._batchData=a[l][y];break}w[y]=w[y]||{}}}return o}}};_.File=T,_.createClient=et,_.createCollection=j,_.file=D,_.mutation=p,_.query=b,_.toQuery=k,_.useWebAuthn=q,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(_,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):(_=typeof globalThis<"u"?globalThis:_||self,b(_.light={},_.jsonToGraphqlQuery,_.axios,_.collect))})(this,function(_,b,D,E){"use strict";var at=Object.defineProperty;var ot=(_,b,D)=>b in _?at(_,b,{enumerable:!0,configurable:!0,writable:!0,value:D}):_[b]=D;var A=(_,b,D)=>ot(_,typeof b!="symbol"?b+"":b,D);const L=t=>({assertion:async()=>{const{app:s}=await O(t,{app:{auth:{webAuthnRequestOptions:!0}}}),n=s.auth.webAuthnRequestOptions,c=PublicKeyCredential.parseRequestOptionsFromJSON(n);return await navigator.credentials.get({publicKey:c})},attestation:async()=>{const{app:s}=await O(t,{app:{auth:{webAuthnCreationOptions:!0}}}),n=PublicKeyCredential.parseCreationOptionsFromJSON(s.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:n})}});function S(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 q(t,e,r=".",s){if(!S(e))return q(t,{},r,s);const n=Object.assign({},e);for(const c in t){if(c==="__proto__"||c==="constructor")continue;const f=t[c];f!=null&&(s&&s(n,c,f,r)||(Array.isArray(f)&&Array.isArray(n[c])?n[c]=[...f,...n[c]]:S(f)&&S(n[c])?n[c]=q(f,n[c],(r?`${r}.`:"")+c.toString(),s):n[c]=f))}return n}function J(t){return(...e)=>e.reduce((r,s)=>q(r,s,"",t),{})}const C=J(),B=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(B(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]=B(s)}),e)},k=t=>B(t),O=async(t,e)=>{let r=b.jsonToGraphQLQuery(k(e));const s=await t.post("",{query:`{ ${r} }`});if(s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function M(t,e,r){let s,n=[],c,f;const l=i=>!i||typeof i!="object"?!1:Object.values(i).some(o=>o&&typeof o=="object"&&Object.keys(o).some(a=>a.startsWith("_"))),h=()=>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 O(t,this.toQuery(!0));if(f){const a=f.split(".");for(const u of a)o=o[u];return o}return o[`list${e}`]},async fetch(){let o=await O(t,this.toQuery());if(f){const a=f.split(".");for(const u of a)o=o[u];return o.data}return o[`list${e}`].data},dataPath(i){return i&&typeof i=="string"&&(f=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=(p,g,y)=>{const F={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[g];F&&n.push({[p]:{[F]:y}})};if(a!==void 0)u(i,String(o),a);else{const p=h(),g=C(p,{[i]:o});n[0]=g}return this},whereContains(i,o){if(i&&typeof i=="string"){const a=h(),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=h(),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=h(),p={_between:[o,a]};u[i]?Array.isArray(u[i])?u[i].push(p):u[i]=[u[i],p]:u[i]=p,n[0]=u}return this},limit(i){return typeof i=="number"&&Number.isFinite(i)&&(s=C(s||{},{limit:i})),this},offset(i){return typeof i=="number"&&Number.isFinite(i)&&(s=C(s||{},{offset:i})),this},toQuery(i=!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 g=C(c?{sort:c}:{},o?{filters:o}:{}),y={data:{...r}};if(s&&(y.data.__args=s),Object.keys(g).length>0&&(y.__args=g),i&&(y.meta={total:!0,key:!0,name:!0}),f){const m=f.split(".");let F=y;for(let R=m.length-1;R>=0;R--)F={[m[R]]:F};return F}return{[`list${e}`]:y}}}}const U=(t,e,r)=>{const s=e,n=t,c=r;let f="list"+e;const l=h=>c[h]?c[h]:null;return{field:l,$fields:c,setDataPath(h){return f=h,f},getDataPath(){return f},gqlFields(h){let i={};for(const o of h)if(typeof o=="string"){const a=l(o);a&&(i=C(i,a.gqlField?typeof a.gqlField=="string"?{[a.gqlField]:!0}:a.gqlField:{[a.name||o]:!0}))}else typeof o=="object"&&(i=C(i,o));return i},async update(h,i){return await d(n,"update"+s,{id:h,data:i})},async delete(h){return await d(n,"delete"+s,{id:h})},async add(h){return await d(n,"add"+s,{data:h})},fields(h){let i=[];for(let o of h){const a=l(o);a&&i.push(a)}return i},async get(h,i){const o=(await Promise.resolve().then(()=>st)).default,a=o(s,n,k(i));for(const[u,p]of Object.entries(h))a.where(u,"==",p);return await a.first()},list(h){let i=h;const o={};Object.entries(h).forEach(([p])=>{c[p]&&(o[p]=c[p],c[p].gqlField&&(delete i[p],i=C(i,c[p].gqlField)))});const a=M(n,s,i).dataPath(f),u=a.fetch.bind(a);return{...a,async fetch(){return(await u()).map(g=>{const y={...g};return Object.entries(o).forEach(([m,F])=>{F.format&&typeof F.format=="function"&&(y[m]=F.format(g))}),y})},async fetchFirst(){const g=await a.fetchFirst.bind(a)();if(!g)return g;const y={...g};return Object.entries(o).forEach(([m,F])=>{F.format&&typeof F.format=="function"&&(y[m]=F.format(g))}),y}}}}},j={},P=(t,e=!1)=>{const r=t,s={};return{create(n,c){const f=U(r,n,c);s[n]=f,e&&(j[n]=f)},get(n){return s[n]||(e&&j[n]?s[n]=j[n]:this.create(n,{})),s[n]},has(n){return!!s[n]||e&&!!j[n]},list(){const n=Object.keys(s),c=e?Object.keys(j):[];return[...new Set([...n,...c])]},clear(){Object.keys(s).forEach(n=>delete s[n])}}},T=t=>{const e=P(t,!1);return{manager:e,createModel:e.create,getModel:e.get,hasModel:e.has,listModels:e.list,clearModels:e.clear,defineModel(r,s){return e.create(r,s),e.get(r)},defineModels(r){Object.entries(r).forEach(([s,n])=>{e.create(s,n)})}}},W=t=>{const e=P(t,!0);return{manager:e,createModel:e.create,getModel:e.get,hasModel:e.has,listModels:e.list,clearModels:e.clear,defineModel(r,s){return e.create(r,s),e.get(r)},defineModels(r){Object.entries(r).forEach(([s,n])=>{e.create(s,n)})}}},I=t=>({define(e,r){const s=U(t,e,r);return j[e]=s,s},get(e){return j[e]},has(e){return!!j[e]},list(){return Object.keys(j)},clear(){Object.keys(j).forEach(e=>delete j[e])}}),$=t=>{const{assertion:e,attestation:r}=L(t);return{login:async()=>{const s=await e();await d(t,"webAuthnAssertion",{assertion:s.toJSON()})},register:async()=>{const s=await r();await d(t,"webAuthnRegister",{registration:s.toJSON()})}}},Q=t=>({WebAuthn:$(t),google:{unlink:()=>d(t,"lightAuthUnlinkGoogle"),login:e=>d(t,"lightAuthLoginGoogle",{credential:e}),register:e=>d(t,"lightAuthRegisterGoogle",{credential:e})},facebook:{unlink:()=>d(t,"lightAuthUnlinkFacebook"),login:e=>d(t,"lightAuthLoginFacebook",{access_token:e}),register:e=>d(t,"lightAuthRegisterFacebook",{access_token:e})},microsoft:{unlink:()=>d(t,"lightAuthUnlinkMicrosoft"),login:e=>d(t,"lightAuthLoginMicrosoft",{access_token:e}),register:e=>d(t,"lightAuthRegisterMicrosoft",{account_id:e})},login:(e,r,s="")=>d(t,"login",{username:e,password:r,code:s}),logout:()=>d(t,"logout"),changeExpiredPassword:(e,r,s)=>d(t,"changeExpiredPassword",{username:e,old_password:r,new_password:s}),updatePassword:(e,r)=>d(t,"changeUserPassword",{old_password:e,new_password:r}),resetPassword:(e,r,s)=>d(t,"resetPassword",{jwt:e,password:r,code:s}),forgetPassword:(e,r)=>d(t,"forgetPassword",{username:e,email:r}),verifyCode(e,r){return d(t,"forgetPasswordVerifyCode",{jwt:e,code:r})},granted:async e=>{const{my:r}=await O(t,{my:{grantedRights:{__args:{rights:e}}}});return r.grantedRights}});function K(t){t="<~"+t+"~>";var e,r,s,n,c,f=String,l=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(l&r>>24,l&r>>16,l&r>>8,l&r);return function(h,i){for(var o=i;o>0;o--)h.pop()}(s,e.length),f.fromCharCode.apply(f,s)}const v=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const n=new Uint8Array(e.length);for(let l=0;l<e.length;l++)n[l]=e.charCodeAt(l);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")}}},z={fromBase85:t=>v(K(t)),fromBase64:t=>v(atob(t)),fromString:t=>v(t)};function G(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function H(t){for(let e in t)if(t[e]instanceof File)return!0;return!1}const d=async(t,e,r=null,s=[])=>{let n={[e]:{}};const c=new FormData;let f=!1;if(r){const i={},o={},a={};let u=0;Object.entries(r).forEach(([p,g])=>{if(g instanceof Array&&G(g)){f=!0;let y=0;g.forEach(m=>{m instanceof File&&(i[p]=new b.VariableType(p),o[u]=["variables."+p+"."+y],c.append(u.toString(),m),u++)}),a[p]="[Upload!]!"}else g instanceof File?(f=!0,i[p]=new b.VariableType(p),o[u]=["variables."+p],c.append(u.toString(),g),a[p]="Upload!",u++):g instanceof Object&&H(g)?(f=!0,i[p]={},Object.entries(g).forEach(([y,m])=>{m instanceof File?(i[p][y]=new b.VariableType(y),o[u]=["variables."+y],c.append(u.toString(),m),a[y]="Upload!",u++):i[p][y]=m})):g!==void 0&&(i[p]=g)}),n[e].__args=i,n.__variables=a,f&&c.append("map",JSON.stringify(o))}Object.entries(k(s)).forEach(([i,o])=>{n[e][i]=o}),Object.entries(n[e]).length===0&&(n[e]=!0);let l=null;const h=b.jsonToGraphQLQuery({mutation:n});if(f?(c.append("operations",JSON.stringify({query:h})),l=await t.post("",c)):l=await t.post("",{query:h}),l.data.errors)throw new Error(l.data.errors[0].message);return l.data.data[e]},V=t=>({uploadTempFile:e=>d(t,"fsUploadTempFile",{file:e},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async e=>(await O(t,{fsListFolders:{__args:{path:e},name:!0,path:!0}})).fsListFolders,create:e=>d(t,"fsCreateFolder",{path:e}),delete:e=>d(t,"fsDeleteFolder",{path:e}),rename:(e,r)=>d(t,"fsRenameFolder",{path:e,name:r})},files:{list:async e=>{let{app:r}=await O(t,{app:{drive:{files:{__args:{path:e},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}}}});return r.drive.files},read:async e=>{let{app:r}=await O(t,{app:{drive:{files:{__args:{path:e},base64Content:!0}}}});return window.atob(r.drive.files[0].base64Content)},write:(e,r)=>d(t,"fsWriteFile",{path:e,content:r}),delete:e=>d(t,"fsDeleteFile",{path:e}),rename:(e,r)=>d(t,"fsRenameFile",{path:e,name:r}),move:(e,r)=>d(t,"fsMoveFile",{source:e,target:r})}}),X=t=>({get:async e=>(await t({config:{__args:{name:e}}})).config}),Y=t=>({send:(e,r,s)=>d(t,"sendMail",{email:e,subject:r,message:s})}),Z=t=>({list:(e={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0})=>M(t,"Users",e).dataPath("app.users")}),x=t=>({list:async(e={name:!0})=>{const{app:{roles:r}}=await O(t,{app:{roles:e}});return r}}),tt="list",et=["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"],rt=["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{constructor(e,r){A(this,"_batchData",null);A(this,"data_path","");A(this,"axios");A(this,"filters");A(this,"steps");A(this,"fields");A(this,"already_limit",!1);A(this,"already_offset",!1);A(this,"limit",null);A(this,"offset",null);A(this,"_sort",null);A(this,"_sortDesc",!1);A(this,"meta",{});this.axios=r,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},E().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 l=this._batchData;return this.meta=l.meta,E(l.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 l of e){if(l===n){s[l]=t;break}s[l]={},s=s[l]}let f=await O(this.axios,r);for(const l of e)f=f[l];return this.meta=f.meta,E(f.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 et)w.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of rt)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 N=(t,e,r)=>{const s=new w(r,e);return s.data_path=tt+t,s},st=Object.freeze(Object.defineProperty({__proto__:null,default:N},Symbol.toStringTag,{value:"Module"})),nt=(t,e)=>({uploadTempFile:r=>d(e,"lightDriveUploadTempFile",{index:t,file:r},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async(r,s={name:!0,path:!0})=>(await O(e,{app:{drive:{__args:{index:t},folders:{__args:{path:r},...s}}}})).app.drive.folders,create:r=>d(e,"lightDriveCreateFolder",{index:t,path:r}),delete:r=>d(e,"lightDriveDeleteFolder",{index:t,path:r}),rename:(r,s)=>d(e,"lightDriveRenameFolder",{index:t,path:r,name:s})},files:{list:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await O(e,{app:{drive:{__args:{index:t},files:{__args:{path:r},...s}}}})).app.drive.files,get:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await O(e,{app:{drive:{__args:{index:t},file:{__args:{path:r},...s}}}})).app.drive.file,read:async r=>{let s=await O(e,{app:{drive:{__args:{index:t},file:{__args:{path:r},base64Content:!0}}}});if(!s.app.drive.file||!s.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${r}`);return typeof window<"u"&&window.atob?window.atob(s.app.drive.file.base64Content):s.app.drive.file.base64Content},write:(r,s)=>d(e,"lightDriveWriteFile",{index:t,path:r,content:s}),delete:r=>d(e,"lightDriveDeleteFile",{index:t,path:r}),rename:(r,s)=>d(e,"lightDriveRenameFile",{index:t,path:r,name:s}),move:(r,s)=>d(e,"lightDriveMoveFile",{index:t,source:r,destination:s})}}),it=t=>{const e=typeof window>"u";let r=[];const s=D.create({baseURL:t,withCredentials:!0});e&&(s.interceptors.request.use(l=>(l.withCredentials=!0,r.length>0&&(l.headers.Cookie=r.join("; ")),l)),s.interceptors.response.use(l=>{if(l.headers["set-cookie"]){const h=l.headers["set-cookie"].map(o=>o.split(";")[0]),i=new Map;r.forEach(o=>{const a=o.split("=")[0];i.set(a,o)}),h.forEach(o=>{const a=o.split("=")[0];i.set(a,o)}),r=Array.from(i.values())}return l}));const n=(l,h=null,i=[])=>d(s,l,h,i),c=l=>O(s,l),f=P(s);return{baseURL:t,axios:s,auth:Q(s),mutation:n,query:c,config:X(c),mail:Y(s),users:Z(s),fs:V(s),models:f,model(l){return f.get(l)},roles:x(s),collect:(l,h)=>{const i=N(l,s,h);return i.data_path=f.get(l).getDataPath(),i},list:(l,h)=>M(s,l,h).dataPath(f.get(l).getDataPath()),drive(l){return nt(l,s)},async collects(l){const h={},i={};for(const a in l){const u=l[a].getQueryPayload();i[a]=u.data_path,h[a]={};const p=u.data_path.split(".");let g=p[p.length-1],y=h[a];for(const m of p){if(m===g){y[m]=u.query;break}y[m]=y[m]||{}}h[a].__aliasFor=p[0]}const o=await O(s,h);for(const a in l){const u=i[a].split(".");let p=u[u.length-1],g=o[a];for(const y of u){if(y===p){l[a]._batchData=o[a][y];break}g[y]=g[y]||{}}}return l}}};_.File=z,_.createClient=it,_.createCollection=N,_.createList=M,_.createModelManager=P,_.file=v,_.mutation=d,_.query=O,_.toQuery=k,_.useGlobalModel=W,_.useGlobalModels=I,_.useModel=T,_.useWebAuthn=L,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
package/dist/model.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { Fields } from '.';
|
|
3
|
-
export type
|
|
4
|
-
name: string;
|
|
5
|
-
raw: FieldOption;
|
|
6
|
-
getName: () => string;
|
|
7
|
-
getGQLField: () => string | object;
|
|
8
|
-
getRaw: () => FieldOption;
|
|
9
|
-
getValue: (model: object) => any;
|
|
10
|
-
getFormattedValue: (model: object) => any;
|
|
11
|
-
};
|
|
12
|
-
export type FieldOption = {
|
|
3
|
+
export type Field = {
|
|
13
4
|
label: string;
|
|
14
5
|
name?: string;
|
|
15
6
|
gqlField?: string | object;
|
|
@@ -20,17 +11,186 @@ export type FieldOption = {
|
|
|
20
11
|
field?: any;
|
|
21
12
|
format?: any;
|
|
22
13
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
export type Model = {
|
|
15
|
+
name: string;
|
|
16
|
+
raw: Field;
|
|
17
|
+
getName: () => string;
|
|
18
|
+
getGQLField: () => string | object;
|
|
19
|
+
getRaw: () => Field;
|
|
20
|
+
getValue: (model: object) => any;
|
|
21
|
+
getFormattedValue: (model: object) => any;
|
|
22
|
+
};
|
|
23
|
+
declare const _default: (axios: AxiosInstance, name: string, fields: Record<string, Field>) => {
|
|
24
|
+
field: (f: string) => Field | null;
|
|
25
|
+
$fields: Record<string, Field>;
|
|
26
26
|
setDataPath(path: string): string;
|
|
27
27
|
getDataPath(): string;
|
|
28
|
-
gqlFields(fields: (string | object)[]): any
|
|
28
|
+
gqlFields(fields: (string | object)[]): Record<string, any>;
|
|
29
29
|
update(id: number, data: Object): Promise<any>;
|
|
30
30
|
delete(id: number): Promise<any>;
|
|
31
31
|
add(data: Object): Promise<any>;
|
|
32
|
-
fields(fields: string[]):
|
|
32
|
+
fields(fields: string[]): Field[];
|
|
33
33
|
get(filters: any, fields: Fields): Promise<any>;
|
|
34
|
-
list(
|
|
34
|
+
list(fields: Record<string, any>): {
|
|
35
|
+
fetch(): Promise<any[]>;
|
|
36
|
+
fetchFirst(): Promise<any>;
|
|
37
|
+
first(): Promise<any>;
|
|
38
|
+
all(): Promise<any[]>;
|
|
39
|
+
fetchWithMeta(): Promise<any>;
|
|
40
|
+
dataPath(dataPath?: string): {
|
|
41
|
+
first(): Promise<any>;
|
|
42
|
+
all(): Promise<any[]>;
|
|
43
|
+
fetchFirst(): Promise<any>;
|
|
44
|
+
fetchWithMeta(): Promise<any>;
|
|
45
|
+
fetch(): Promise<any[]>;
|
|
46
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
47
|
+
sort(sortStr: string): /*elided*/ any;
|
|
48
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
49
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
50
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
51
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
52
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
53
|
+
limit(n: number): /*elided*/ any;
|
|
54
|
+
offset(n: number): /*elided*/ any;
|
|
55
|
+
toQuery(includeMeta?: boolean): any;
|
|
56
|
+
};
|
|
57
|
+
sort(sortStr: string): {
|
|
58
|
+
first(): Promise<any>;
|
|
59
|
+
all(): Promise<any[]>;
|
|
60
|
+
fetchFirst(): Promise<any>;
|
|
61
|
+
fetchWithMeta(): Promise<any>;
|
|
62
|
+
fetch(): Promise<any[]>;
|
|
63
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
64
|
+
sort(sortStr: string): /*elided*/ any;
|
|
65
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
66
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
67
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
68
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
69
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
70
|
+
limit(n: number): /*elided*/ any;
|
|
71
|
+
offset(n: number): /*elided*/ any;
|
|
72
|
+
toQuery(includeMeta?: boolean): any;
|
|
73
|
+
};
|
|
74
|
+
filters(filterObj: Record<string, any>): {
|
|
75
|
+
first(): Promise<any>;
|
|
76
|
+
all(): Promise<any[]>;
|
|
77
|
+
fetchFirst(): Promise<any>;
|
|
78
|
+
fetchWithMeta(): Promise<any>;
|
|
79
|
+
fetch(): Promise<any[]>;
|
|
80
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
81
|
+
sort(sortStr: string): /*elided*/ any;
|
|
82
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
83
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
84
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
85
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
86
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
87
|
+
limit(n: number): /*elided*/ any;
|
|
88
|
+
offset(n: number): /*elided*/ any;
|
|
89
|
+
toQuery(includeMeta?: boolean): any;
|
|
90
|
+
};
|
|
91
|
+
where(key: string, opOrVal?: any, maybeVal?: any): {
|
|
92
|
+
first(): Promise<any>;
|
|
93
|
+
all(): Promise<any[]>;
|
|
94
|
+
fetchFirst(): Promise<any>;
|
|
95
|
+
fetchWithMeta(): Promise<any>;
|
|
96
|
+
fetch(): Promise<any[]>;
|
|
97
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
98
|
+
sort(sortStr: string): /*elided*/ any;
|
|
99
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
100
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
101
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
102
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
103
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
104
|
+
limit(n: number): /*elided*/ any;
|
|
105
|
+
offset(n: number): /*elided*/ any;
|
|
106
|
+
toQuery(includeMeta?: boolean): any;
|
|
107
|
+
};
|
|
108
|
+
whereContains(field: string, val: any): {
|
|
109
|
+
first(): Promise<any>;
|
|
110
|
+
all(): Promise<any[]>;
|
|
111
|
+
fetchFirst(): Promise<any>;
|
|
112
|
+
fetchWithMeta(): Promise<any>;
|
|
113
|
+
fetch(): Promise<any[]>;
|
|
114
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
115
|
+
sort(sortStr: string): /*elided*/ any;
|
|
116
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
117
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
118
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
119
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
120
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
121
|
+
limit(n: number): /*elided*/ any;
|
|
122
|
+
offset(n: number): /*elided*/ any;
|
|
123
|
+
toQuery(includeMeta?: boolean): any;
|
|
124
|
+
};
|
|
125
|
+
whereIn(field: string, vals: any[]): {
|
|
126
|
+
first(): Promise<any>;
|
|
127
|
+
all(): Promise<any[]>;
|
|
128
|
+
fetchFirst(): Promise<any>;
|
|
129
|
+
fetchWithMeta(): Promise<any>;
|
|
130
|
+
fetch(): Promise<any[]>;
|
|
131
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
132
|
+
sort(sortStr: string): /*elided*/ any;
|
|
133
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
134
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
135
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
136
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
137
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
138
|
+
limit(n: number): /*elided*/ any;
|
|
139
|
+
offset(n: number): /*elided*/ any;
|
|
140
|
+
toQuery(includeMeta?: boolean): any;
|
|
141
|
+
};
|
|
142
|
+
whereBetween(field: string, min: any, max: any): {
|
|
143
|
+
first(): Promise<any>;
|
|
144
|
+
all(): Promise<any[]>;
|
|
145
|
+
fetchFirst(): Promise<any>;
|
|
146
|
+
fetchWithMeta(): Promise<any>;
|
|
147
|
+
fetch(): Promise<any[]>;
|
|
148
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
149
|
+
sort(sortStr: string): /*elided*/ any;
|
|
150
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
151
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
152
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
153
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
154
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
155
|
+
limit(n: number): /*elided*/ any;
|
|
156
|
+
offset(n: number): /*elided*/ any;
|
|
157
|
+
toQuery(includeMeta?: boolean): any;
|
|
158
|
+
};
|
|
159
|
+
limit(n: number): {
|
|
160
|
+
first(): Promise<any>;
|
|
161
|
+
all(): Promise<any[]>;
|
|
162
|
+
fetchFirst(): Promise<any>;
|
|
163
|
+
fetchWithMeta(): Promise<any>;
|
|
164
|
+
fetch(): Promise<any[]>;
|
|
165
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
166
|
+
sort(sortStr: string): /*elided*/ any;
|
|
167
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
168
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
169
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
170
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
171
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
172
|
+
limit(n: number): /*elided*/ any;
|
|
173
|
+
offset(n: number): /*elided*/ any;
|
|
174
|
+
toQuery(includeMeta?: boolean): any;
|
|
175
|
+
};
|
|
176
|
+
offset(n: number): {
|
|
177
|
+
first(): Promise<any>;
|
|
178
|
+
all(): Promise<any[]>;
|
|
179
|
+
fetchFirst(): Promise<any>;
|
|
180
|
+
fetchWithMeta(): Promise<any>;
|
|
181
|
+
fetch(): Promise<any[]>;
|
|
182
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
183
|
+
sort(sortStr: string): /*elided*/ any;
|
|
184
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
185
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
186
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
187
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
188
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
189
|
+
limit(n: number): /*elided*/ any;
|
|
190
|
+
offset(n: number): /*elided*/ any;
|
|
191
|
+
toQuery(includeMeta?: boolean): any;
|
|
192
|
+
};
|
|
193
|
+
toQuery(includeMeta?: boolean): any;
|
|
194
|
+
};
|
|
35
195
|
};
|
|
36
196
|
export default _default;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { Field } from './model';
|
|
3
|
+
export interface ModelManager {
|
|
4
|
+
create: (name: string, fields: Record<string, Field>) => void;
|
|
5
|
+
get: (name: string) => any;
|
|
6
|
+
has: (name: string) => boolean;
|
|
7
|
+
list: () => string[];
|
|
8
|
+
clear: () => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 創建模型管理器的工廠函數
|
|
12
|
+
* @param axios AxiosInstance 實例
|
|
13
|
+
* @returns ModelManager 實例
|
|
14
|
+
*/
|
|
15
|
+
export declare const createModelManager: (axios: AxiosInstance, useGlobal?: boolean) => ModelManager;
|
|
16
|
+
/**
|
|
17
|
+
* 主要的 useModel hook
|
|
18
|
+
* @param axios AxiosInstance 實例
|
|
19
|
+
* @returns 模型管理器和便利方法
|
|
20
|
+
*/
|
|
21
|
+
export declare const useModel: (axios: AxiosInstance) => {
|
|
22
|
+
manager: ModelManager;
|
|
23
|
+
createModel: (name: string, fields: Record<string, Field>) => void;
|
|
24
|
+
getModel: (name: string) => any;
|
|
25
|
+
hasModel: (name: string) => boolean;
|
|
26
|
+
listModels: () => string[];
|
|
27
|
+
clearModels: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* 快速創建並獲取模型
|
|
30
|
+
* @param name 模型名稱
|
|
31
|
+
* @param fields 模型欄位定義
|
|
32
|
+
* @returns 模型實例
|
|
33
|
+
*/
|
|
34
|
+
defineModel(name: string, fields: Record<string, Field>): any;
|
|
35
|
+
/**
|
|
36
|
+
* 批量創建模型
|
|
37
|
+
* @param models 模型定義對象
|
|
38
|
+
*/
|
|
39
|
+
defineModels(models: Record<string, Record<string, Field>>): void;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 創建一個會自動使用全域模型的 useModel
|
|
43
|
+
* @param axios AxiosInstance 實例
|
|
44
|
+
* @returns 使用全域模型的管理器
|
|
45
|
+
*/
|
|
46
|
+
export declare const useGlobalModel: (axios: AxiosInstance) => {
|
|
47
|
+
manager: ModelManager;
|
|
48
|
+
createModel: (name: string, fields: Record<string, Field>) => void;
|
|
49
|
+
getModel: (name: string) => any;
|
|
50
|
+
hasModel: (name: string) => boolean;
|
|
51
|
+
listModels: () => string[];
|
|
52
|
+
clearModels: () => void;
|
|
53
|
+
/**
|
|
54
|
+
* 快速創建並獲取模型
|
|
55
|
+
* @param name 模型名稱
|
|
56
|
+
* @param fields 模型欄位定義
|
|
57
|
+
* @returns 模型實例
|
|
58
|
+
*/
|
|
59
|
+
defineModel(name: string, fields: Record<string, Field>): any;
|
|
60
|
+
/**
|
|
61
|
+
* 批量創建模型
|
|
62
|
+
* @param models 模型定義對象
|
|
63
|
+
*/
|
|
64
|
+
defineModels(models: Record<string, Record<string, Field>>): void;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 全域模型管理器 - 用於跨組件共享模型
|
|
68
|
+
* 所有創建的模型都會儲存在全域範圍內,可以在不同的組件或模組中共享
|
|
69
|
+
*/
|
|
70
|
+
export declare const useGlobalModels: (axios: AxiosInstance) => {
|
|
71
|
+
/**
|
|
72
|
+
* 創建全域模型
|
|
73
|
+
* @param name 模型名稱
|
|
74
|
+
* @param fields 模型欄位定義
|
|
75
|
+
*/
|
|
76
|
+
define(name: string, fields: Record<string, Field>): {
|
|
77
|
+
field: (f: string) => Field | null;
|
|
78
|
+
$fields: Record<string, Field>;
|
|
79
|
+
setDataPath(path: string): string;
|
|
80
|
+
getDataPath(): string;
|
|
81
|
+
gqlFields(fields: (string | object)[]): Record<string, any>;
|
|
82
|
+
update(id: number, data: Object): Promise<any>;
|
|
83
|
+
delete(id: number): Promise<any>;
|
|
84
|
+
add(data: Object): Promise<any>;
|
|
85
|
+
fields(fields: string[]): Field[];
|
|
86
|
+
get(filters: any, fields: import('.').Fields): Promise<any>;
|
|
87
|
+
list(fields: Record<string, any>): {
|
|
88
|
+
fetch(): Promise<any[]>;
|
|
89
|
+
fetchFirst(): Promise<any>;
|
|
90
|
+
first(): Promise<any>;
|
|
91
|
+
all(): Promise<any[]>;
|
|
92
|
+
fetchWithMeta(): Promise<any>;
|
|
93
|
+
dataPath(dataPath?: string): {
|
|
94
|
+
first(): Promise<any>;
|
|
95
|
+
all(): Promise<any[]>;
|
|
96
|
+
fetchFirst(): Promise<any>;
|
|
97
|
+
fetchWithMeta(): Promise<any>;
|
|
98
|
+
fetch(): Promise<any[]>;
|
|
99
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
100
|
+
sort(sortStr: string): /*elided*/ any;
|
|
101
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
102
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
103
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
104
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
105
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
106
|
+
limit(n: number): /*elided*/ any;
|
|
107
|
+
offset(n: number): /*elided*/ any;
|
|
108
|
+
toQuery(includeMeta?: boolean): any;
|
|
109
|
+
};
|
|
110
|
+
sort(sortStr: string): {
|
|
111
|
+
first(): Promise<any>;
|
|
112
|
+
all(): Promise<any[]>;
|
|
113
|
+
fetchFirst(): Promise<any>;
|
|
114
|
+
fetchWithMeta(): Promise<any>;
|
|
115
|
+
fetch(): Promise<any[]>;
|
|
116
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
117
|
+
sort(sortStr: string): /*elided*/ any;
|
|
118
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
119
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
120
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
121
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
122
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
123
|
+
limit(n: number): /*elided*/ any;
|
|
124
|
+
offset(n: number): /*elided*/ any;
|
|
125
|
+
toQuery(includeMeta?: boolean): any;
|
|
126
|
+
};
|
|
127
|
+
filters(filterObj: Record<string, any>): {
|
|
128
|
+
first(): Promise<any>;
|
|
129
|
+
all(): Promise<any[]>;
|
|
130
|
+
fetchFirst(): Promise<any>;
|
|
131
|
+
fetchWithMeta(): Promise<any>;
|
|
132
|
+
fetch(): Promise<any[]>;
|
|
133
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
134
|
+
sort(sortStr: string): /*elided*/ any;
|
|
135
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
136
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
137
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
138
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
139
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
140
|
+
limit(n: number): /*elided*/ any;
|
|
141
|
+
offset(n: number): /*elided*/ any;
|
|
142
|
+
toQuery(includeMeta?: boolean): any;
|
|
143
|
+
};
|
|
144
|
+
where(key: string, opOrVal?: any, maybeVal?: any): {
|
|
145
|
+
first(): Promise<any>;
|
|
146
|
+
all(): Promise<any[]>;
|
|
147
|
+
fetchFirst(): Promise<any>;
|
|
148
|
+
fetchWithMeta(): Promise<any>;
|
|
149
|
+
fetch(): Promise<any[]>;
|
|
150
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
151
|
+
sort(sortStr: string): /*elided*/ any;
|
|
152
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
153
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
154
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
155
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
156
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
157
|
+
limit(n: number): /*elided*/ any;
|
|
158
|
+
offset(n: number): /*elided*/ any;
|
|
159
|
+
toQuery(includeMeta?: boolean): any;
|
|
160
|
+
};
|
|
161
|
+
whereContains(field: string, val: any): {
|
|
162
|
+
first(): Promise<any>;
|
|
163
|
+
all(): Promise<any[]>;
|
|
164
|
+
fetchFirst(): Promise<any>;
|
|
165
|
+
fetchWithMeta(): Promise<any>;
|
|
166
|
+
fetch(): Promise<any[]>;
|
|
167
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
168
|
+
sort(sortStr: string): /*elided*/ any;
|
|
169
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
170
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
171
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
172
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
173
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
174
|
+
limit(n: number): /*elided*/ any;
|
|
175
|
+
offset(n: number): /*elided*/ any;
|
|
176
|
+
toQuery(includeMeta?: boolean): any;
|
|
177
|
+
};
|
|
178
|
+
whereIn(field: string, vals: any[]): {
|
|
179
|
+
first(): Promise<any>;
|
|
180
|
+
all(): Promise<any[]>;
|
|
181
|
+
fetchFirst(): Promise<any>;
|
|
182
|
+
fetchWithMeta(): Promise<any>;
|
|
183
|
+
fetch(): Promise<any[]>;
|
|
184
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
185
|
+
sort(sortStr: string): /*elided*/ any;
|
|
186
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
187
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
188
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
189
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
190
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
191
|
+
limit(n: number): /*elided*/ any;
|
|
192
|
+
offset(n: number): /*elided*/ any;
|
|
193
|
+
toQuery(includeMeta?: boolean): any;
|
|
194
|
+
};
|
|
195
|
+
whereBetween(field: string, min: any, max: any): {
|
|
196
|
+
first(): Promise<any>;
|
|
197
|
+
all(): Promise<any[]>;
|
|
198
|
+
fetchFirst(): Promise<any>;
|
|
199
|
+
fetchWithMeta(): Promise<any>;
|
|
200
|
+
fetch(): Promise<any[]>;
|
|
201
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
202
|
+
sort(sortStr: string): /*elided*/ any;
|
|
203
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
204
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
205
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
206
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
207
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
208
|
+
limit(n: number): /*elided*/ any;
|
|
209
|
+
offset(n: number): /*elided*/ any;
|
|
210
|
+
toQuery(includeMeta?: boolean): any;
|
|
211
|
+
};
|
|
212
|
+
limit(n: number): {
|
|
213
|
+
first(): Promise<any>;
|
|
214
|
+
all(): Promise<any[]>;
|
|
215
|
+
fetchFirst(): Promise<any>;
|
|
216
|
+
fetchWithMeta(): Promise<any>;
|
|
217
|
+
fetch(): Promise<any[]>;
|
|
218
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
219
|
+
sort(sortStr: string): /*elided*/ any;
|
|
220
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
221
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
222
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
223
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
224
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
225
|
+
limit(n: number): /*elided*/ any;
|
|
226
|
+
offset(n: number): /*elided*/ any;
|
|
227
|
+
toQuery(includeMeta?: boolean): any;
|
|
228
|
+
};
|
|
229
|
+
offset(n: number): {
|
|
230
|
+
first(): Promise<any>;
|
|
231
|
+
all(): Promise<any[]>;
|
|
232
|
+
fetchFirst(): Promise<any>;
|
|
233
|
+
fetchWithMeta(): Promise<any>;
|
|
234
|
+
fetch(): Promise<any[]>;
|
|
235
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
236
|
+
sort(sortStr: string): /*elided*/ any;
|
|
237
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
238
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
239
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
240
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
241
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
242
|
+
limit(n: number): /*elided*/ any;
|
|
243
|
+
offset(n: number): /*elided*/ any;
|
|
244
|
+
toQuery(includeMeta?: boolean): any;
|
|
245
|
+
};
|
|
246
|
+
toQuery(includeMeta?: boolean): any;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* 獲取全域模型
|
|
251
|
+
* @param name 模型名稱
|
|
252
|
+
* @returns 模型實例
|
|
253
|
+
*/
|
|
254
|
+
get(name: string): any;
|
|
255
|
+
/**
|
|
256
|
+
* 檢查全域模型是否存在
|
|
257
|
+
* @param name 模型名稱
|
|
258
|
+
* @returns 是否存在
|
|
259
|
+
*/
|
|
260
|
+
has(name: string): boolean;
|
|
261
|
+
/**
|
|
262
|
+
* 列出所有全域模型
|
|
263
|
+
* @returns 模型名稱陣列
|
|
264
|
+
*/
|
|
265
|
+
list(): string[];
|
|
266
|
+
/**
|
|
267
|
+
* 清除所有全域模型
|
|
268
|
+
*/
|
|
269
|
+
clear(): void;
|
|
270
|
+
};
|
|
271
|
+
export default useModel;
|
package/dist/users.d.ts
CHANGED
|
@@ -7,6 +7,22 @@ export type UserFields = {
|
|
|
7
7
|
status?: boolean;
|
|
8
8
|
};
|
|
9
9
|
declare const _default: (axios: AxiosInstance) => {
|
|
10
|
-
list: (fields?: UserFields) =>
|
|
10
|
+
list: (fields?: UserFields) => {
|
|
11
|
+
first(): Promise<any>;
|
|
12
|
+
all(): Promise<any[]>;
|
|
13
|
+
fetchFirst(): Promise<any>;
|
|
14
|
+
fetchWithMeta(): Promise<any>;
|
|
15
|
+
fetch(): Promise<any[]>;
|
|
16
|
+
dataPath(dataPath?: string): /*elided*/ any;
|
|
17
|
+
sort(sortStr: string): /*elided*/ any;
|
|
18
|
+
filters(filterObj: Record<string, any>): /*elided*/ any;
|
|
19
|
+
where(key: string, opOrVal?: any, maybeVal?: any): /*elided*/ any;
|
|
20
|
+
whereContains(field: string, val: any): /*elided*/ any;
|
|
21
|
+
whereIn(field: string, vals: any[]): /*elided*/ any;
|
|
22
|
+
whereBetween(field: string, min: any, max: any): /*elided*/ any;
|
|
23
|
+
limit(n: number): /*elided*/ any;
|
|
24
|
+
offset(n: number): /*elided*/ any;
|
|
25
|
+
toQuery(includeMeta?: boolean): any;
|
|
26
|
+
};
|
|
11
27
|
};
|
|
12
28
|
export default _default;
|
package/package.json
CHANGED
package/dist/gqlBuilder.d.ts
DELETED
package/dist/model.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/models.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { FieldOption } from './model';
|
|
3
|
-
declare const _default: (axios: AxiosInstance) => {
|
|
4
|
-
create(name: string, fields: {
|
|
5
|
-
[key: string]: FieldOption;
|
|
6
|
-
}): void;
|
|
7
|
-
get(name: string): any;
|
|
8
|
-
};
|
|
9
|
-
export default _default;
|