@hostlink/light 3.3.0 → 3.3.2
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/auth.d.ts +36 -1
- package/dist/config.d.ts +2 -0
- package/dist/createClient.d.ts +19 -16
- package/dist/createClient.test.d.ts +1 -0
- package/dist/createCollection.d.ts +3 -1
- package/dist/createList.d.ts +3 -1
- package/dist/drive.d.ts +40 -4
- package/dist/file.d.ts +2 -1
- package/dist/filesystem.d.ts +1 -1
- package/dist/folder.d.ts +3 -2
- package/dist/light.js +647 -572
- package/dist/light.umd.cjs +1 -1
- package/dist/mail.d.ts +4 -0
- package/dist/model.d.ts +9 -2
- package/dist/mutation.d.ts +3 -0
- package/dist/query.d.ts +2 -0
- package/dist/role.d.ts +6 -0
- package/dist/users.d.ts +7 -0
- package/dist/webauthn.d.ts +7 -0
- package/package.json +1 -1
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("json-to-graphql-query"),require("collect.js"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","collect.js","axios"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.light={},h.jsonToGraphqlQuery,h.collect,h.axios))})(this,(function(h,m,k,mt){"use strict";function v(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 E(t,e,r=".",s){if(!v(e))return E(t,{},r,s);const o=Object.assign({},e);for(const u in t){if(u==="__proto__"||u==="constructor")continue;const c=t[u];c!=null&&(s&&s(o,u,c,r)||(Array.isArray(c)&&Array.isArray(o[u])?o[u]=[...c,...o[u]]:v(c)&&v(o[u])?o[u]=E(c,o[u],(r?`${r}.`:"")+u.toString(),s):o[u]=c))}return o}function wt(t){return(...e)=>e.reduce((r,s)=>E(r,s,"",t),{})}const C=wt();let U=null;const J=t=>{U=t},M=()=>{if(!U)throw new Error("Api client not initialized. Call setApiClient() first.");return U},bt=()=>U;function D(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function B(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&D(t[e]))return!0;return!1}function At(t){t="<~"+t+"~>";var e,r,s,o,u,c=String,p=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=[],o=0,u=t.length;u>o;o+=5)r=52200625*(t.charCodeAt(o)-33)+614125*(t.charCodeAt(o+1)-33)+7225*(t.charCodeAt(o+2)-33)+85*(t.charCodeAt(o+3)-33)+(t.charCodeAt(o+4)-33),s.push(p&r>>24,p&r>>16,p&r>>8,p&r);return(function(n,i){for(var a=i;a>0;a--)n.pop()})(s,e.length),c.fromCharCode.apply(c,s)}const q=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const o=new Uint8Array(e.length);for(let p=0;p<e.length;p++)o[p]=e.charCodeAt(p);const u=new Blob([o],{type:s});return URL.createObjectURL(u)};return{getContent:()=>e,getURL:r,download:s=>{const o=document.createElement("a");o.download=s,o.href=r(),document.body.appendChild(o),o.click(),document.body.removeChild(o)},open:s=>{window.open(r(s),"_blank")}}},Ct=t=>q(atob(t)),Ot=t=>q(At(t));function $(t,e,r,s,o){if(!(!t||typeof t!="object"))for(let u in t){const c=t[u];if(c&&typeof c=="object"){if("__args"in c){const p=c.__args,n={};Object.entries(p).forEach(([i,a])=>{if(a instanceof Array&&D(a)){n[i]=new m.VariableType(i);let l=0;a.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),s.append(o.current.toString(),f),o.current++,l++)}),e[i]="[Upload!]!"}else a instanceof File?(n[i]=new m.VariableType(i),r[o.current]=["variables."+i],s.append(o.current.toString(),a),e[i]="Upload!",o.current++):a instanceof Object&&B(a)?(n[i]={},Object.entries(a).forEach(([l,f])=>{if(f instanceof Array&&D(f)){n[i][l]=new m.VariableType(l);let g=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+g),s.append(o.current.toString(),_),o.current++,g++)}),e[l]="[Upload!]!"}else f instanceof File?(n[i][l]=new m.VariableType(l),r[o.current]=["variables."+l],s.append(o.current.toString(),f),e[l]="Upload!",o.current++):n[i][l]=f})):a!=null&&(n[i]=a)}),c.__args=n}$(c,e,r,s,o)}}}const F=async t=>{const{axios:e}=M(),r=t,s=new FormData;let o=!1;const u={},c={};$(r,u,c,s,{current:0}),o=Object.keys(u).length>0,o&&(r.__variables=u);let n=null;const i={query:r},a=m.jsonToGraphQLQuery(i);if(o?(s.append("map",JSON.stringify(c)),s.append("operations",JSON.stringify({query:a})),n=await e.post("",s)):n=await e.post("",{query:a}),n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};function S(t,e){let r,s=[],o,u;const c=n=>!n||typeof n!="object"?!1:Object.values(n).some(i=>i&&typeof i=="object"&&Object.keys(i).some(a=>a.startsWith("_"))),p=()=>s.length===0?(s.unshift({}),s[0]):(c(s[0])&&s.unshift({}),s[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const i=await this.limit(1).fetch();return Array.isArray(i)&&i.length>0?i[0]:null},async fetchWithMeta(){let i=await F(this.toQuery(!0));if(u){const a=u.split(".");for(const l of a)i=i[l];return i}return i[`list${t}`]},async fetch(){let i=await F(this.toQuery());if(u){const a=u.split(".");for(const l of a)i=i[l];return i.data}return i[`list${t}`].data},dataPath(n){return n&&typeof n=="string"&&(u=n),this},sort(n){return n&&typeof n=="string"&&(o=n),this},filters(n){return n&&typeof n=="object"&&(s=[n]),this},where(n,i,a){const l=(f,g,_)=>{const b={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[g];b&&s.push({[f]:{[b]:_}})};if(a!==void 0)l(n,String(i),a);else{const f=p(),g=C(f,{[n]:i});s[0]=g}return this},whereContains(n,i){if(n&&typeof n=="string"){const a=p(),l={_contains:i};a[n]?Array.isArray(a[n])?a[n].push(l):a[n]=[a[n],l]:a[n]=[l],s[0]=a}return this},whereIn(n,i){if(n&&typeof n=="string"&&Array.isArray(i)){const a=p(),l={_in:i};a[n]?Array.isArray(a[n])?a[n].push(l):a[n]=[a[n],l]:a[n]=[l],s[0]=a}return this},whereBetween(n,i,a){if(n&&typeof n=="string"){const l=p(),f={_between:[i,a]};l[n]?Array.isArray(l[n])?l[n].push(f):l[n]=[l[n],f]:l[n]=f,s[0]=l}return this},limit(n){return typeof n=="number"&&Number.isFinite(n)&&(r=C(r||{},{limit:n})),this},offset(n){return typeof n=="number"&&Number.isFinite(n)&&(r=C(r||{},{offset:n})),this},toQuery(n=!1){let i;const a=s.length>0&&Object.keys(s[0]||{}).length>0,l=a?1:0,f=s.length>l;a&&f?i=s:f?i=s.slice(l):a&&(i=s[0]);const g=C(o?{sort:o}:{},i?{filters:i}:{}),_={data:{...e}};if(r&&(_.data.__args=r),Object.keys(g).length>0&&(_.__args=g),n&&(_.meta={total:!0,key:!0,name:!0}),u){const A=u.split(".");let b=_;for(let w=A.length-1;w>=0;w--)b={[A[w]]:b};return b}return{[`list${t}`]:_}}}}const Dt="list",St=["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"],Ut=["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 y{_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}}y.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}},y.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},y.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},y.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},k().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),y.prototype.fetchData=async function(){try{if(this._batchData){const p=this._batchData;return this.meta=p.meta,k(p.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,o=e[e.length-1];for(const p of e){if(p===o){s[p]=t;break}s[p]={},s=s[p]}let c=await F(r);for(const p of e)c=c[p];return this.meta=c.meta,k(c.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},y.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},y.prototype.all=async function(){return(await this.processData()).all()};for(const t of St)y.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Ut)y.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};y.prototype.average=y.prototype.avg,y.prototype.first=async function(){return this.take(1),(await this.processData()).first()},y.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},y.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],o=t[2];switch(s){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: ${s}`)}}return this},y.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},y.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)},y.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},y.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},y.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},y.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},y.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},y.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},y.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},y.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)},y.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 y(e);return r.data_path=Dt+t,r},Pt=(t,e={})=>{const r=e;let s="list"+t;const o=u=>r[u]?r[u]:null;return{field:o,$fields:r,setDataPath(u){return s=u,s},getDataPath(){return s},gqlFields(u){let c={};for(const p of u)if(typeof p=="string"){const n=o(p);n&&(c=C(c,n.gqlField?typeof n.gqlField=="string"?{[n.gqlField]:!0}:n.gqlField:{[n.name||p]:!0}))}else typeof p=="object"&&(c=C(c,p));return c},update(u,c){return d({["update"+t]:{__args:{id:u,data:c}}}).then(p=>p["update"+t])},async delete(u){return d({["delete"+t]:{__args:{id:u}}}).then(c=>c["delete"+t])},add(u){return d({["add"+t]:{__args:{data:u}}}).then(c=>c["add"+t])},fields(u){let c=[];for(let p of u){const n=o(p);n&&c.push(n)}return c},async get(u,c){const p=N(t,Ft(c));for(const[n,i]of Object.entries(u))p.where(n,"==",i);return await p.first()},list(u){let c=u;const p={};Object.entries(u).forEach(([a])=>{r[a]&&(p[a]=r[a],r[a].gqlField&&(delete c[a],c=C(c,r[a].gqlField)),r[a].gql&&(delete c[a],c=C(c,r[a].gql)))});const n=S(t,c).dataPath(s),i=n.fetch.bind(n);return{...n,async fetch(){return(await i()).map(l=>{const f={...l};return Object.entries(p).forEach(([g,_])=>{_.field&&typeof _.field=="function"&&(f[g]=_.field(l[g],l))}),f})},async fetchFirst(){const l=await n.fetchFirst.bind(n)();if(!l)return l;const f={...l};return Object.entries(p).forEach(([g,_])=>{_.field&&typeof _.field=="function"&&(f[g]=_.field(l[g],l))}),f}}}}},O={},T=(t,e)=>{const r=Pt(t,e);return O[t]=r,r},P=t=>O[t]?O[t]:T(t,{}),jt=t=>!!O[t],kt=()=>Object.keys(O),vt=()=>{Object.keys(O).forEach(t=>delete O[t])},Et=t=>{Object.entries(t).forEach(([e,r])=>{T(e,r)})},Mt=()=>F({app:{permissions:!0}}).then(t=>t.app.permissions),z=async()=>{const{app:t}=await F({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 F({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:z,attestation:W,login:async()=>{const t=await z();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"})),G=(t=R)=>F({my:t}).then(e=>e.my),H=(t,e,r="")=>d({login:{__args:{username:t,password:e,code:r}}}).then(s=>s.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(s=>s.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(s=>s.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=>F({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),tt=t=>F({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)=>F({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(s=>s.app.drive.files),nt=(t,e)=>F({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),Bt=t=>({list:(e,r=rt)=>st(t,e,r),get:(e,r={name:!0,path:!0,size:!0,mime:!0,url:!0})=>F({app:{drive:{__args:{index:t},file:{__args:{path:e},...r}}}}).then(s=>s.app.drive.file),readFileAsBase64(e){return nt(t,e)},read:async e=>{let r=await F({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(s=>s.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(s=>s.lightDriveRenameFile),move:(e,r)=>d({lightDriveMoveFile:{__args:{index:t,source:e,destination:r}}}).then(s=>s.lightDriveMoveFile)}),it={name:!0,path:!0},ot=(t,e,r=it)=>F({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(s=>s.app.drive.folders),qt=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(s=>s.lightDriveRenameFolder)}),Nt=()=>F({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),at=t=>{const e=Bt(t),r=qt(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:s=>d({lightDriveUploadTempFile:{__args:{index:t,file:s},name:!0,path:!0,size:!0,mime:!0}}).then(o=>o.lightDriveUploadTempFile)}},R={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},lt=t=>d({addUser:{__args:t}}).then(e=>e.addUser),ct=t=>d({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),ut=(t=R)=>S("Users",t).dataPath("app.listUser").fetch(),ht=(t,e)=>d({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),Tt={list:ut,create:lt,delete:ct,update:ht},ft=t=>F({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]?.value),Rt={name:!0},pt=(t=Rt)=>F({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),Lt=()=>({list:pt,create:dt,delete:gt});function _t(t,e,r,s,o){if(!(!t||typeof t!="object"))for(let u in t){const c=t[u];if(c&&typeof c=="object"){if("__args"in c){const p=c.__args,n={};Object.entries(p).forEach(([i,a])=>{if(a instanceof Array&&D(a)){n[i]=new m.VariableType(i);let l=0;a.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),s.append(o.current.toString(),f),o.current++,l++)}),e[i]="[Upload!]!"}else a instanceof File?(n[i]=new m.VariableType(i),r[o.current]=["variables."+i],s.append(o.current.toString(),a),e[i]="Upload!",o.current++):a instanceof Object&&B(a)?(n[i]={},Object.entries(a).forEach(([l,f])=>{if(f instanceof Array&&D(f)){n[i][l]=new m.VariableType(l);let g=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+g),s.append(o.current.toString(),_),o.current++,g++)}),e[l]="[Upload!]!"}else f instanceof File?(n[i][l]=new m.VariableType(l),r[o.current]=["variables."+l],s.append(o.current.toString(),f),e[l]="Upload!",o.current++):n[i][l]=f})):a!=null&&(n[i]=a)}),c.__args=n}_t(c,e,r,s,o)}}}const d=async t=>{const{axios:e}=M(),r=t,s=new FormData;let o=!1;const u={},c={};_t(r,u,c,s,{current:0}),o=Object.keys(u).length>0,o&&(r.__variables=u);let n=null;const i={mutation:r},a=m.jsonToGraphQLQuery(i);if(o?(s.append("map",JSON.stringify(c)),s.append("operations",JSON.stringify({query:a})),n=await e.post("",s)):n=await e.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(s=>s.sendMail),Jt={send:yt},$t=Object.freeze(Object.defineProperty({__proto__:null,createFolder:t=>d({lightFSCreateFolder:{__args:{location:t}}}).then(e=>e.lightFSCreateFolder),deleteFile:t=>d({lightFSDeleteFile:{__args:{location:t}}}).then(e=>e.lightFSDeleteFile),deleteFolder:t=>d({lightFSDeleteFolder:{__args:{location:t}}}).then(e=>e.lightFSDeleteFolder),duplicateFile:t=>d({lightFSDuplicateFile:{__args:{location:t}}}).then(e=>e.lightFSDuplicateFile),exists:t=>F({app:{fs:{exists:{__args:{location:t}}}}}).then(e=>e.app.fs.exists),find:(t,e)=>{const r={};return t&&(r.search=t),e&&(r.label=e),F({app:{fs:{find:{__args:r,__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}}}).then(s=>s.app.fs.find)},list:t=>F({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"Folder",name:!0,location:!0,path:!0,children:{__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}]}}}}).then(r=>r.app.fs.node),listFiles:(t,e,r)=>{const s={location:t};return e&&(s.type=e),r&&(s.search=r),F({app:{fs:{listFiles:{__args:s,name:!0,path:!0,location:!0,size:!0,mimeType:!0,publicUrl:!0,lastModified:!0}}}}).then(o=>o.app.fs.listFiles)},move:(t,e)=>d({lightFSMove:{__args:{from:t,to:e}}}).then(r=>r.lightFSMove),readFile:(t,e="text")=>F({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"File",...e==="text"?{content:!0}:{base64Content:!0}}]}}}}).then(r=>{const s=r.app.fs.node;return s?.__typename==="File"?e==="text"?s.content:s.base64Content:null}),renameFile:(t,e)=>d({lightFSRenameFile:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFile),renameFolder:(t,e)=>d({lightFSRenameFolder:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFolder),uploadBase64:(t,e)=>d({lightFSUploadBase64:{__args:{location:t,base64:e},__typename:!0,name:!0,path:!0,location:!0,__on:[{__typename:"File",size:!0,mimeType:!0,lastModified:!0}]}}).then(r=>r.lightFSUploadBase64),uploadFile:(t,e)=>d({lightFSUploadFile:{__args:{location:t,file:e}}}).then(r=>r.lightFSUploadFile),uploadTempFile:(t,e)=>d({lightFSUploadTempFile:{__args:{location:t,file:e},name:!0,path:!0,location:!0,size:!0,mimeType:!0}}).then(r=>r.lightFSUploadTempFile),writeFile:(t,e)=>d({lightFSWriteFile:{__args:{location:t,content:e}}}).then(r=>r.lightFSWriteFile)},Symbol.toStringTag,{value:"Module"})),L=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(L(r)).forEach(([s,o])=>{e[s]=o})}),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]=L(s)}),e)},Ft=t=>L(t),zt=t=>{const e=typeof window>"u";let r=[];const s=mt.create({baseURL:t,withCredentials:!0});let o=!1,u=[];const c=(i,a=null)=>{u.forEach(l=>{i?l.reject(i):l.resolve(a)}),u=[]};s.interceptors.response.use(i=>{const a=i.data.errors;if(a&&a.some(l=>l.extensions?.code==="TOKEN_EXPIRED")){const l=i.config;return o?new Promise((f,g)=>{u.push({resolve:f,reject:g})}).then(()=>s(l)).catch(f=>Promise.reject(f)):(o=!0,p().then(()=>(o=!1,c(null),s(l))).catch(f=>(o=!1,c(f),Promise.reject(f))))}return i},i=>Promise.reject(i));function p(){return s.post("/refresh_token")}e&&(s.interceptors.request.use(i=>(i.withCredentials=!0,r.length>0&&(i.headers.Cookie=r.join("; ")),i)),s.interceptors.response.use(i=>{if(i.headers["set-cookie"]){const a=i.headers["set-cookie"].map(f=>f.split(";")[0]),l=new Map;r.forEach(f=>{const g=f.split("=")[0];l.set(g,f)}),a.forEach(f=>{const g=f.split("=")[0];l.set(g,f)}),r=Array.from(l.values())}return i}));const n={post:s.post,baseURL:t,axios:s,auth:et,mutation:d,query:F,config:ft,mail:Jt,users:Tt,model(i){return P(i)},roles:Lt(),collect:(i,a)=>{const l=N(i,a);return l.data_path=P(i).getDataPath(),l},list:(i,a)=>S(i,a).dataPath(P(i).getDataPath()),drive:at,async collects(i){const a={},l={};for(const g in i){const _=i[g].getQueryPayload();l[g]=_.data_path,a[g]={};const A=_.data_path.split(".");let b=A[A.length-1],w=a[g];for(const j of A){if(j===b){w[j]=_.query;break}w[j]=w[j]||{}}a[g].__aliasFor=A[0]}const f=await F(a);for(const g in i){const _=l[g].split(".");let A=_[_.length-1],b=f[g];for(const w of _){if(w===A){i[g]._batchData=f[g][w];break}b[w]=b[w]||{}}}return i}};return J(n),n},Wt=S;h.arrayHasFile=D,h.auth=et,h.changeExpiredPassword=X,h.clearModels=vt,h.createClient=zt,h.createCollection=N,h.createFileFromBase64=Ct,h.createFileFromBase85=Ot,h.createFileFromString=q,h.createList=S,h.createRole=dt,h.createUser=lt,h.defaultUserFields=R,h.defineModel=T,h.defineModels=Et,h.deleteRole=gt,h.deleteUser=ct,h.forgetPassword=I,h.fs=$t,h.getApiClient=M,h.getApiClientOptional=bt,h.getConfig=ft,h.getCurrentUser=G,h.getDrive=at,h.getGrantedRights=tt,h.getModel=P,h.hasModel=jt,h.isGranted=x,h.list=Wt,h.listDrives=Nt,h.listFiles=st,h.listFolders=ot,h.listModels=kt,h.listPermissions=Mt,h.listRoles=pt,h.listUsers=ut,h.login=H,h.logout=V,h.mutation=d,h.objectHasFile=B,h.query=F,h.readFileAsBase64=nt,h.resetPassword=Z,h.sendMail=yt,h.setApiClient=J,h.toQuery=Ft,h.updatePassword=Y,h.updateUser=ht,h.verifyCode=K,h.webAuthn=Q,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(c,U){typeof exports=="object"&&typeof module<"u"?U(exports,require("json-to-graphql-query"),require("collect.js"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","collect.js","axios"],U):(c=typeof globalThis<"u"?globalThis:c||self,U(c.light={},c.jsonToGraphqlQuery,c.collect,c.axios))})(this,(function(c,U,T,At){"use strict";function q(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.iterator in t?!1:Symbol.toStringTag in t?Object.prototype.toString.call(t)==="[object Module]":!0}function J(t,e,r=".",s){if(!q(e))return J(t,{},r,s);const n=Object.assign({},e);for(const h in t){if(h==="__proto__"||h==="constructor")continue;const l=t[h];l!=null&&(s&&s(n,h,l,r)||(Array.isArray(l)&&Array.isArray(n[h])?n[h]=[...l,...n[h]]:q(l)&&q(n[h])?n[h]=J(l,n[h],(r?`${r}.`:"")+h.toString(),s):n[h]=l))}return n}function Ct(t){return(...e)=>e.reduce((r,s)=>J(r,s,"",t),{})}const P=Ct();let E=null;const I=t=>{E=t},$=()=>{if(!E)throw new Error("Api client not initialized. Call setApiClient() first.");return E},Ut=()=>E;function S(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function z(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&S(t[e]))return!0;return!1}function Pt(t){t="<~"+t+"~>";var e,r,s,n,h,l=String,g=255;for(t.slice(0,2)==="<~"&&t.slice(-2),t=t.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),e="uuuuu".slice(t.length%5||5),t+=e,s=[],n=0,h=t.length;h>n;n+=5)r=52200625*(t.charCodeAt(n)-33)+614125*(t.charCodeAt(n+1)-33)+7225*(t.charCodeAt(n+2)-33)+85*(t.charCodeAt(n+3)-33)+(t.charCodeAt(n+4)-33),s.push(g&r>>24,g&r>>16,g&r>>8,g&r);return(function(f,i){for(var o=i;o>0;o--)f.pop()})(s,e.length),l.fromCharCode.apply(l,s)}const G=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const n=new Uint8Array(e.length);for(let g=0;g<e.length;g++)n[g]=e.charCodeAt(g);const h=new Blob([n],{type:s});return URL.createObjectURL(h)};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")}}},Ot=t=>G(atob(t)),Dt=t=>G(Pt(t));function K(t,e,r,s,n){if(!(!t||typeof t!="object"))for(let h in t){const l=t[h];if(l&&typeof l=="object"){if("__args"in l){const g=l.__args,f={};Object.entries(g).forEach(([i,o])=>{if(o instanceof Array&&S(o)){f[i]=new U.VariableType(i);let a=0;o.forEach(u=>{u instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+i+"."+a),s.append(n.current.toString(),u),n.current++,a++)}),e[i]="[Upload!]!"}else o instanceof File?(f[i]=new U.VariableType(i),r[n.current]=["variables."+i],s.append(n.current.toString(),o),e[i]="Upload!",n.current++):o instanceof Object&&z(o)?(f[i]={},Object.entries(o).forEach(([a,u])=>{if(u instanceof Array&&S(u)){f[i][a]=new U.VariableType(a);let A=0;u.forEach(b=>{b instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+a+"."+A),s.append(n.current.toString(),b),n.current++,A++)}),e[a]="[Upload!]!"}else u instanceof File?(f[i][a]=new U.VariableType(a),r[n.current]=["variables."+a],s.append(n.current.toString(),u),e[a]="Upload!",n.current++):f[i][a]=u})):o!=null&&(f[i]=o)}),l.__args=f}K(l,e,r,s,n)}}}const x=t=>async e=>{const r=e,s=new FormData;let n=!1;const h={},l={};K(r,h,l,s,{current:0}),n=Object.keys(h).length>0,n&&(r.__variables=h);let f=null;const i={query:r},o=U.jsonToGraphQLQuery(i);if(n?(s.append("map",JSON.stringify(l)),s.append("operations",JSON.stringify({query:o})),f=await t.post("",s)):f=await t.post("",{query:o}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data},m=async t=>x($().axios)(t);function M(t,e,r=m){let s,n=[],h,l;const g=i=>!i||typeof i!="object"?!1:Object.values(i).some(o=>o&&typeof o=="object"&&Object.keys(o).some(a=>a.startsWith("_"))),f=()=>n.length===0?(n.unshift({}),n[0]):(g(n[0])&&n.unshift({}),n[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const o=await this.limit(1).fetch();return Array.isArray(o)&&o.length>0?o[0]:null},async fetchWithMeta(){let o=await r(this.toQuery(!0));if(l){const a=l.split(".");for(const u of a)o=o[u];return o}return o[`list${t}`]},async fetch(){let o=await r(this.toQuery());if(l){const a=l.split(".");for(const u of a)o=o[u];return o.data}return o[`list${t}`].data},dataPath(i){return i&&typeof i=="string"&&(l=i),this},sort(i){return i&&typeof i=="string"&&(h=i),this},filters(i){return i&&typeof i=="object"&&(n=[i]),this},where(i,o,a){const u=(A,b,d)=>{const _={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[b];_&&n.push({[A]:{[_]:d}})};if(a!==void 0)u(i,String(o),a);else{const A=f(),b=P(A,{[i]:o});n[0]=b}return this},whereContains(i,o){if(i&&typeof i=="string"){const a=f(),u={_contains:o};a[i]?Array.isArray(a[i])?a[i].push(u):a[i]=[a[i],u]:a[i]=[u],n[0]=a}return this},whereIn(i,o){if(i&&typeof i=="string"&&Array.isArray(o)){const a=f(),u={_in:o};a[i]?Array.isArray(a[i])?a[i].push(u):a[i]=[a[i],u]:a[i]=[u],n[0]=a}return this},whereBetween(i,o,a){if(i&&typeof i=="string"){const u=f(),A={_between:[o,a]};u[i]?Array.isArray(u[i])?u[i].push(A):u[i]=[u[i],A]:u[i]=A,n[0]=u}return this},limit(i){return typeof i=="number"&&Number.isFinite(i)&&(s=P(s||{},{limit:i})),this},offset(i){return typeof i=="number"&&Number.isFinite(i)&&(s=P(s||{},{offset:i})),this},toQuery(i=!1){let o;const a=n.length>0&&Object.keys(n[0]||{}).length>0,u=a?1:0,A=n.length>u;a&&A?o=n:A?o=n.slice(u):a&&(o=n[0]);const b=P(h?{sort:h}:{},o?{filters:o}:{}),d={data:{...e}};if(s&&(d.data.__args=s),Object.keys(b).length>0&&(d.__args=b),i&&(d.meta={total:!0,key:!0,name:!0}),l){const y=l.split(".");let _=d;for(let w=y.length-1;w>=0;w--)_={[y[w]]:_};return _}return{[`list${t}`]:d}}}}const kt="list",St=["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"],jt=["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 F{_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}}F.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}},F.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},F.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},F.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},T().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),F.prototype.fetchData=async function(){try{if(this._batchData){const g=this._batchData;return this.meta=g.meta,T(g.data)}let t={meta:{total:!0,key:!0,name:!0}};t.__args=this.buildArgs(),t.data=this.fields,this.already_limit&&(t.data.__args=t.data.__args||{},t.data.__args.limit=this.limit),this.already_offset&&(t.data.__args=t.data.__args||{},t.data.__args.offset=this.offset);const e=this.data_path.split(".");let r={},s=r,n=e[e.length-1];for(const g of e){if(g===n){s[g]=t;break}s[g]={},s=s[g]}let l=await(this._queryFn||m)(r);for(const g of e)l=l[g];return this.meta=l.meta,T(l.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},F.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},F.prototype.all=async function(){return(await this.processData()).all()};for(const t of St)F.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of jt)F.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};F.prototype.average=F.prototype.avg,F.prototype.first=async function(){return this.take(1),(await this.processData()).first()},F.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},F.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},F.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},F.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)},F.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},F.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},F.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},F.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},F.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},F.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},F.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},F.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)},F.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 W=(t,e,r=m)=>{const s=new F(e);return s._queryFn=r,s.data_path=kt+t,s},tt=(t,e={},r={})=>{const s=r.mutation||p,n=r.createList||M,h=r.createCollection||W,l=e;let g="list"+t;const f=i=>l[i]?l[i]:null;return{field:f,$fields:l,setDataPath(i){return g=i,g},getDataPath(){return g},gqlFields(i){let o={};for(const a of i)if(typeof a=="string"){const u=f(a);u&&(o=P(o,u.gqlField?typeof u.gqlField=="string"?{[u.gqlField]:!0}:u.gqlField:{[u.name||a]:!0}))}else typeof a=="object"&&(o=P(o,a));return o},update(i,o){return s({["update"+t]:{__args:{id:i,data:o}}}).then(a=>a["update"+t])},async delete(i){return s({["delete"+t]:{__args:{id:i}}}).then(o=>o["delete"+t])},add(i){return s({["add"+t]:{__args:{data:i}}}).then(o=>o["add"+t])},fields(i){let o=[];for(let a of i){const u=f(a);u&&o.push(u)}return o},async get(i,o){const a=h(t,mt(o));for(const[u,A]of Object.entries(i))a.where(u,"==",A);return await a.first()},list(i){let o=i;const a={};Object.entries(i).forEach(([b])=>{l[b]&&(a[b]=l[b],l[b].gqlField&&(delete o[b],o=P(o,l[b].gqlField)),l[b].gql&&(delete o[b],o=P(o,l[b].gql)))});const u=n(t,o).dataPath(g),A=u.fetch.bind(u);return{...u,async fetch(){return(await A()).map(d=>{const y={...d};return Object.entries(a).forEach(([_,w])=>{w.field&&typeof w.field=="function"&&(y[_]=w.field(d[_],d))}),y})},async fetchFirst(){const d=await u.fetchFirst.bind(u)();if(!d)return d;const y={...d};return Object.entries(a).forEach(([_,w])=>{w.field&&typeof w.field=="function"&&(y[_]=w.field(d[_],d))}),y}}}}},D={},Q=(t,e)=>{const r=tt(t,e);return D[t]=r,r},R=t=>D[t]?D[t]:Q(t,{}),Mt=t=>!!D[t],vt=()=>Object.keys(D),Et=()=>{Object.keys(D).forEach(t=>delete D[t])},Rt=t=>{Object.entries(t).forEach(([e,r])=>{Q(e,r)})},Bt=()=>m({app:{permissions:!0}}).then(t=>t.app.permissions),H=(t,e)=>{const r=async()=>{const{app:l}=await t({app:{auth:{webAuthnRequestOptions:!0}}}),g=l.auth.webAuthnRequestOptions,f=PublicKeyCredential.parseRequestOptionsFromJSON(g);return await navigator.credentials.get({publicKey:f})},s=async()=>{const{app:l}=await t({app:{auth:{webAuthnCreationOptions:!0}}}),g=PublicKeyCredential.parseCreationOptionsFromJSON(l.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:g})};return{assertion:r,attestation:s,login:async()=>{const l=await r();return await e({webAuthnAssertion:{__args:{assertion:l.toJSON()}}}).then(g=>g.webAuthnAssertion)},register:async()=>{const l=await s();return await e({webAuthnRegister:{__args:{registration:l.toJSON()}}}).then(g=>g.webAuthnRegister)}}},B=H(m,p),Nt=B.assertion,Lt=B.attestation,Tt=B.login,qt=B.register,et=Object.freeze(Object.defineProperty({__proto__:null,assertion:Nt,attestation:Lt,createWebAuthn:H,login:Tt,register:qt},Symbol.toStringTag,{value:"Module"})),rt=(t,e)=>({getCurrentUser:(r=v)=>t({my:r}).then(s=>s.my),login:(r,s,n="")=>e({login:{__args:{username:r,password:s,code:n}}}).then(h=>h.login),logout:()=>e({logout:!0}).then(r=>r.logout),changeExpiredPassword:(r,s,n)=>e({changeExpiredPassword:{__args:{username:r,old_password:s,new_password:n}}}).then(h=>h.changeExpiredPassword),updatePassword:(r,s)=>e({changeUserPassword:{__args:{old_password:r,new_password:s}}}).then(n=>n.changeUserPassword),resetPassword:(r,s,n)=>e({resetPassword:{__args:{jwt:r,password:s,code:n}}}).then(h=>h.resetPassword),forgetPassword:(r,s)=>e({forgetPassword:{__args:{username:r,email:s}}}).then(n=>n.forgetPassword),verifyCode:(r,s)=>e({forgetPasswordVerifyCode:{__args:{jwt:r,code:s}}}).then(n=>n.forgetPasswordVerifyCode),grantedRights:r=>t({my:{grantedRights:{__args:{rights:r}}}}).then(s=>s.my.grantedRights),isGranted:r=>t({my:{granted:{__args:{right:r}}}}).then(s=>s.my.granted),webAuthn:H(t,e),google:{unlink:()=>e({lightAuthUnlinkGoogle:!0}).then(r=>r.lightAuthUnlinkGoogle),login:r=>e({lightAuthLoginGoogle:{__args:{credential:r}}}).then(s=>s.lightAuthLoginGoogle),register:r=>e({lightAuthRegisterGoogle:{__args:{credential:r}}}).then(s=>s.lightAuthRegisterGoogle)},facebook:{unlink:()=>e({lightAuthUnlinkFacebook:!0}).then(r=>r.lightAuthUnlinkFacebook),login:r=>e({lightAuthLoginFacebook:{__args:{access_token:r}}}).then(s=>s.lightAuthLoginFacebook),register:r=>e({lightAuthRegisterFacebook:{__args:{access_token:r}}}).then(s=>s.lightAuthRegisterFacebook)},microsoft:{unlink:()=>e({lightAuthUnlinkMicrosoft:!0}).then(r=>r.lightAuthUnlinkMicrosoft),login:r=>e({lightAuthLoginMicrosoft:{__args:{access_token:r}}}).then(s=>s.lightAuthLoginMicrosoft),register:r=>e({lightAuthRegisterMicrosoft:{__args:{account_id:r}}}).then(s=>s.lightAuthRegisterMicrosoft)}}),st=(t=v)=>m({my:t}).then(e=>e.my),nt=(t,e,r="")=>p({login:{__args:{username:t,password:e,code:r}}}).then(s=>s.login),it=()=>p({logout:!0}).then(t=>t.logout),ot=(t,e,r)=>p({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(s=>s.changeExpiredPassword),at=(t,e)=>p({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),lt=(t,e,r)=>p({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(s=>s.resetPassword),ct=(t,e)=>p({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),ut=(t,e)=>p({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),ht=t=>m({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),dt=t=>m({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),Jt={getCurrentUser:st,webAuthn:et,google:{unlink:()=>p({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>p({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>p({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>p({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>p({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>p({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>p({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>p({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>p({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:nt,logout:it,changeExpiredPassword:ot,updatePassword:at,resetPassword:lt,forgetPassword:ct,verifyCode:ut,grantedRights:dt,isGranted:ht},ft={name:!0,path:!0,size:!0,mime:!0,url:!0},$t=(t,e,r=ft)=>m({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(s=>s.app.drive.files),zt=(t,e)=>m({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),Gt=(t,e=m,r=p)=>({list:(s,n=ft)=>e({app:{drive:{__args:{index:t},files:{__args:{path:s},...n}}}}).then(h=>h.app.drive.files),get:(s,n={name:!0,path:!0,size:!0,mime:!0,url:!0})=>e({app:{drive:{__args:{index:t},file:{__args:{path:s},...n}}}}).then(h=>h.app.drive.file),readFileAsBase64(s){return e({app:{drive:{__args:{index:t},file:{__args:{path:s},base64Content:!0}}}}).then(n=>n.app.drive?.file?.base64Content)},read:async s=>{let n=await e({app:{drive:{__args:{index:t},file:{__args:{path:s},base64Content:!0}}}});if(!n.app.drive.file||!n.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${s}`);return typeof window<"u"&&window.atob?window.atob(n.app.drive.file.base64Content):n.app.drive.file.base64Content},write:(s,n)=>r({lightDriveWriteFile:{__args:{index:t,path:s,content:n}}}).then(h=>h.lightDriveWriteFile),delete:s=>r({lightDriveDeleteFile:{__args:{index:t,path:s}}}).then(n=>n.lightDriveDeleteFile),rename:(s,n)=>r({lightDriveRenameFile:{__args:{index:t,path:s,name:n}}}).then(h=>h.lightDriveRenameFile),move:(s,n)=>r({lightDriveMoveFile:{__args:{index:t,source:s,destination:n}}}).then(h=>h.lightDriveMoveFile)}),gt={name:!0,path:!0},Wt=(t,e,r=gt)=>m({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(s=>s.app.drive.folders),Qt=(t,e=m,r=p)=>({list:(s,n=gt)=>e({app:{drive:{__args:{index:t},folders:{__args:{path:s},...n}}}}).then(h=>h.app.drive.folders),create:s=>r({lightDriveCreateFolder:{__args:{index:t,path:s}}}).then(n=>n.lightDriveCreateFolder),delete:s=>r({lightDriveDeleteFolder:{__args:{index:t,path:s}}}).then(n=>n.lightDriveDeleteFolder),rename:(s,n)=>r({lightDriveRenameFolder:{__args:{index:t,path:s,name:n}}}).then(h=>h.lightDriveRenameFolder)}),Ht=()=>m({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),Vt=t=>V(m,p)(t),V=(t,e)=>r=>{const s=Gt(r,t,e),n=Qt(r,t,e);return{folders:n,files:s,listFiles:s.list,getFile:s.get,readFile:s.read,writeFile:s.write,deleteFile:s.delete,renameFile:s.rename,moveFile:s.move,listFolders:n.list,createFolder:n.create,deleteFolder:n.delete,renameFolder:n.rename,uploadTempFile:h=>e({lightDriveUploadTempFile:{__args:{index:r,file:h},name:!0,path:!0,size:!0,mime:!0}}).then(l=>l.lightDriveUploadTempFile)}},v={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},Xt=t=>p({addUser:{__args:t}}).then(e=>e.addUser),Yt=t=>p({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),Zt=(t=v)=>M("Users",t).dataPath("app.listUser").fetch(),It=(t,e)=>p({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),pt=(t,e)=>({list:(r=v)=>e("Users",r).dataPath("app.listUser").fetch(),create:r=>t({addUser:{__args:r}}).then(s=>s.addUser),delete:r=>t({deleteUser:{__args:{id:r}}}).then(s=>s.deleteUser),update:(r,s)=>t({updateUser:{__args:{id:r,data:s}}}).then(n=>n.updateUser)}),X=t=>e=>t({app:{listConfig:{__args:{filters:{name:e}},data:{name:!0,value:!0}}}}).then(r=>r.app.listConfig.data[0]?.value),Kt=X(m),_t={name:!0},xt=(t=_t)=>m({app:{roles:t}}).then(e=>e.app.roles),te=(t,e)=>p({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),ee=t=>p({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),yt=(t,e)=>({list:(r=_t)=>t({app:{roles:r}}).then(s=>s.app.roles),create:(r,s)=>e({addRole:{__args:{data:{name:r,childs:s}}}}).then(n=>n.addRole),delete:r=>e({deleteRole:{__args:{name:r}}}).then(s=>s.deleteRole)});function Y(t){if(Array.isArray(t))return t.map(e=>Y(e)).filter(e=>e!==void 0);if(t!==null&&typeof t=="object"){const e=Object.getPrototypeOf(t);if(e===Object.prototype||e===null)return Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0).map(([r,s])=>[r,Y(s)]))}return t}function wt(t,e,r,s,n){if(!(!t||typeof t!="object"))for(let h in t){const l=t[h];if(l&&typeof l=="object"){if("__args"in l){const g=Y(l.__args),f={};Object.entries(g).forEach(([i,o])=>{if(o instanceof Array&&S(o)){f[i]=new U.VariableType(i);let a=0;o.forEach(u=>{u instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+i+"."+a),s.append(n.current.toString(),u),n.current++,a++)}),e[i]="[Upload!]!"}else o instanceof File?(f[i]=new U.VariableType(i),r[n.current]=["variables."+i],s.append(n.current.toString(),o),e[i]="Upload!",n.current++):o instanceof Object&&z(o)?(f[i]={},Object.entries(o).forEach(([a,u])=>{if(u instanceof Array&&S(u)){f[i][a]=new U.VariableType(a);let A=0;u.forEach(b=>{b instanceof File&&(r[n.current]||(r[n.current]=[]),r[n.current].push("variables."+a+"."+A),s.append(n.current.toString(),b),n.current++,A++)}),e[a]="[Upload!]!"}else u instanceof File?(f[i][a]=new U.VariableType(a),r[n.current]=["variables."+a],s.append(n.current.toString(),u),e[a]="Upload!",n.current++):f[i][a]=u})):o!=null&&(f[i]=o)}),l.__args=f}wt(l,e,r,s,n)}}}const bt=t=>async e=>{const r=e,s=new FormData;let n=!1;const h={},l={};wt(r,h,l,s,{current:0}),n=Object.keys(h).length>0,n&&(r.__variables=h);let f=null;const i={mutation:r},o=U.jsonToGraphQLQuery(i);if(n?(s.append("map",JSON.stringify(l)),s.append("operations",JSON.stringify({query:o})),f=await t.post("",s)):f=await t.post("",{query:o}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data},p=async t=>bt($().axios)(t),re=(t,e,r)=>p({sendMail:{__args:{email:t,subject:e,message:r}}}).then(s=>s.sendMail),Ft=t=>({send:(e,r,s)=>t({sendMail:{__args:{email:e,subject:r,message:s}}}).then(n=>n.sendMail)}),se=Object.freeze(Object.defineProperty({__proto__:null,createFolder:t=>p({lightFSCreateFolder:{__args:{location:t}}}).then(e=>e.lightFSCreateFolder),deleteFile:t=>p({lightFSDeleteFile:{__args:{location:t}}}).then(e=>e.lightFSDeleteFile),deleteFolder:t=>p({lightFSDeleteFolder:{__args:{location:t}}}).then(e=>e.lightFSDeleteFolder),duplicateFile:t=>p({lightFSDuplicateFile:{__args:{location:t}}}).then(e=>e.lightFSDuplicateFile),exists:t=>m({app:{fs:{exists:{__args:{location:t}}}}}).then(e=>e.app.fs.exists),find:(t,e)=>{const r={};return t&&(r.search=t),e&&(r.label=e),m({app:{fs:{find:{__args:r,__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}}}).then(s=>s.app.fs.find)},list:t=>m({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"Folder",name:!0,location:!0,path:!0,children:{__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0,publicUrl:!0},{__typeName:"Folder"}]}}]}}}}).then(r=>r.app.fs.node),listFiles:(t,e,r)=>{const s={location:t};return e&&(s.type=e),r&&(s.search=r),m({app:{fs:{listFiles:{__args:s,name:!0,path:!0,location:!0,size:!0,mimeType:!0,publicUrl:!0,lastModified:!0}}}}).then(n=>n.app.fs.listFiles)},move:(t,e)=>p({lightFSMove:{__args:{from:t,to:e}}}).then(r=>r.lightFSMove),readFile:(t,e="text")=>m({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"File",...e==="text"?{content:!0}:{base64Content:!0}}]}}}}).then(r=>{const s=r.app.fs.node;return s?.__typename==="File"?e==="text"?s.content:s.base64Content:null}),renameFile:(t,e)=>p({lightFSRenameFile:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFile),renameFolder:(t,e)=>p({lightFSRenameFolder:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFolder),uploadBase64:(t,e)=>p({lightFSUploadBase64:{__args:{location:t,base64:e},__typename:!0,name:!0,path:!0,location:!0,__on:[{__typename:"File",size:!0,mimeType:!0,lastModified:!0}]}}).then(r=>r.lightFSUploadBase64),uploadFile:(t,e,r=!1)=>p({lightFSUploadFile:{__args:{location:t,file:e,rename:r}}}).then(s=>s.lightFSUploadFile),uploadTempFile:(t,e)=>p({lightFSUploadTempFile:{__args:{location:t,file:e},name:!0,path:!0,location:!0,size:!0,mimeType:!0}}).then(r=>r.lightFSUploadTempFile),writeFile:(t,e)=>p({lightFSWriteFile:{__args:{location:t,content:e}}}).then(r=>r.lightFSWriteFile)},Symbol.toStringTag,{value:"Module"})),Z=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(Z(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]=Z(s)}),e)},mt=t=>Z(t),ne=t=>{const e=typeof window>"u";let r=[];const s=At.create({baseURL:t,withCredentials:!0});let n=!1,h=[];const l=(d,y=null)=>{h.forEach(_=>{d?_.reject(d):_.resolve(y)}),h=[]};s.interceptors.response.use(d=>{const y=d.data.errors;if(y&&y.some(_=>_.extensions?.code==="TOKEN_EXPIRED")){const _=d.config;return n?new Promise((w,C)=>{h.push({resolve:w,reject:C})}).then(()=>s(_)).catch(w=>Promise.reject(w)):(n=!0,g().then(()=>(n=!1,l(null),s(_))).catch(w=>(n=!1,l(w),Promise.reject(w))))}return d},d=>Promise.reject(d));function g(){return s.post("/refresh_token")}e&&(s.interceptors.request.use(d=>(d.withCredentials=!0,r.length>0&&(d.headers.Cookie=r.join("; ")),d)),s.interceptors.response.use(d=>{if(d.headers["set-cookie"]){const y=d.headers["set-cookie"].map(w=>w.split(";")[0]),_=new Map;r.forEach(w=>{const C=w.split("=")[0];_.set(C,w)}),y.forEach(w=>{const C=w.split("=")[0];_.set(C,w)}),r=Array.from(_.values())}return d}));const f=x(s),i=bt(s),o=(d,y)=>M(d,y,f),a=(d,y)=>W(d,y,f),u=d=>{const y=R(d),_=tt(d,y.$fields,{mutation:i,createList:o,createCollection:a});return _.setDataPath(y.getDataPath()),_},A=rt(f,i),b={post:s.post.bind(s),baseURL:t,axios:s,auth:A,mutation:i,query:f,config:X(f),mail:Ft(i),users:pt(i,o),model(d){return u(d)},roles:yt(f,i),collect:(d,y)=>{const _=a(d,y);return _.data_path=R(d).getDataPath(),_},list:(d,y)=>o(d,y).dataPath(R(d).getDataPath()),drive:V(f,i),async collects(d){const y={},_={};for(const C in d){const k=d[C].getQueryPayload();_[C]=k.data_path,y[C]={};const j=k.data_path.split(".");let N=j[j.length-1],O=y[C];for(const L of j){if(L===N){O[L]=k.query;break}O[L]=O[L]||{}}y[C].__aliasFor=j[0]}const w=await f(y);for(const C in d){const k=_[C].split(".");let j=k[k.length-1],N=w[C];for(const O of k){if(O===j){d[C]._batchData=w[C][O];break}N[O]=N[O]||{}}}return d}};return I(b),b},ie=M;c.arrayHasFile=S,c.auth=Jt,c.changeExpiredPassword=ot,c.clearModels=Et,c.createAuth=rt,c.createClient=ne,c.createCollection=W,c.createConfig=X,c.createDrive=V,c.createFileFromBase64=Ot,c.createFileFromBase85=Dt,c.createFileFromString=G,c.createList=M,c.createMail=Ft,c.createRole=te,c.createRoles=yt,c.createUser=Xt,c.createUsers=pt,c.defaultUserFields=v,c.defineModel=Q,c.defineModels=Rt,c.deleteRole=ee,c.deleteUser=Yt,c.forgetPassword=ct,c.fs=se,c.getApiClient=$,c.getApiClientOptional=Ut,c.getConfig=Kt,c.getCurrentUser=st,c.getDrive=Vt,c.getGrantedRights=dt,c.getModel=R,c.hasModel=Mt,c.isGranted=ht,c.list=ie,c.listDrives=Ht,c.listFiles=$t,c.listFolders=Wt,c.listModels=vt,c.listPermissions=Bt,c.listRoles=xt,c.listUsers=Zt,c.login=nt,c.logout=it,c.mutation=p,c.objectHasFile=z,c.query=m,c.readFileAsBase64=zt,c.resetPassword=lt,c.sendMail=re,c.setApiClient=I,c.toQuery=mt,c.updatePassword=at,c.updateUser=It,c.verifyCode=ut,c.webAuthn=et,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/mail.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { default as mutation } from './mutation';
|
|
1
2
|
export declare const sendMail: (email: string, subject: string, message: string) => Promise<any>;
|
|
3
|
+
export declare const createMail: (mutationFn: typeof mutation) => {
|
|
4
|
+
send: (email: string, subject: string, message: string) => Promise<any>;
|
|
5
|
+
};
|
|
2
6
|
declare const _default: {
|
|
3
7
|
send: (email: string, subject: string, message: string) => Promise<any>;
|
|
4
8
|
};
|
package/dist/model.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Fields } from '.';
|
|
1
|
+
import { Fields, GraphQLQuery } from '.';
|
|
2
|
+
import { default as createList } from './createList';
|
|
3
|
+
import { default as createCollection } from './createCollection';
|
|
2
4
|
export type Field = {
|
|
3
5
|
name?: string;
|
|
4
6
|
/**
|
|
@@ -9,7 +11,12 @@ export type Field = {
|
|
|
9
11
|
field?: any;
|
|
10
12
|
format?: any;
|
|
11
13
|
};
|
|
12
|
-
|
|
14
|
+
type ModelContext = {
|
|
15
|
+
mutation?: (query: GraphQLQuery) => Promise<any>;
|
|
16
|
+
createList?: typeof createList;
|
|
17
|
+
createCollection?: typeof createCollection;
|
|
18
|
+
};
|
|
19
|
+
declare const _default: (name: string, fields?: Record<string, Field>, context?: ModelContext) => {
|
|
13
20
|
field: (f: string) => Field | null;
|
|
14
21
|
$fields: Record<string, Field>;
|
|
15
22
|
setDataPath(path: string): string;
|
package/dist/mutation.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
1
2
|
import { GraphQLQuery } from '.';
|
|
3
|
+
export declare function removeUndefined(value: any): any;
|
|
4
|
+
export declare const createMutation: (axios: AxiosInstance) => (q: GraphQLQuery) => Promise<any>;
|
|
2
5
|
declare const _default: (q: GraphQLQuery) => Promise<any>;
|
|
3
6
|
export default _default;
|
package/dist/query.d.ts
CHANGED
package/dist/role.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mutation, query } from '.';
|
|
1
2
|
import { UserFields } from './users';
|
|
2
3
|
export type RoleFields = {
|
|
3
4
|
name?: string;
|
|
@@ -16,3 +17,8 @@ declare const _default: () => {
|
|
|
16
17
|
delete: (name: string) => Promise<boolean>;
|
|
17
18
|
};
|
|
18
19
|
export default _default;
|
|
20
|
+
export declare const createRoles: (queryFn: typeof query, mutationFn: typeof mutation) => {
|
|
21
|
+
list: (fields?: QueryRoleFields) => Promise<Array<RoleFields>>;
|
|
22
|
+
create: (name: string, childs: string[]) => Promise<boolean>;
|
|
23
|
+
delete: (name: string) => Promise<boolean>;
|
|
24
|
+
};
|
package/dist/users.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createList, mutation } from '.';
|
|
1
2
|
export type UserFields = {
|
|
2
3
|
user_id?: number;
|
|
3
4
|
username?: string;
|
|
@@ -27,3 +28,9 @@ declare const _default: {
|
|
|
27
28
|
update: (id: number, fields: Partial<CreateUserFields>) => Promise<any>;
|
|
28
29
|
};
|
|
29
30
|
export default _default;
|
|
31
|
+
export declare const createUsers: (mutationFn: typeof mutation, createListFn: typeof createList) => {
|
|
32
|
+
list: (fields?: QueryUserFieldsUserFields) => Promise<any[]>;
|
|
33
|
+
create: (fields: CreateUserFields) => Promise<any>;
|
|
34
|
+
delete: (id: Number) => Promise<boolean>;
|
|
35
|
+
update: (id: number, fields: Partial<CreateUserFields>) => Promise<any>;
|
|
36
|
+
};
|
package/dist/webauthn.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { mutation, query } from '.';
|
|
2
|
+
export declare const createWebAuthn: (queryFn: typeof query, mutationFn: typeof mutation) => {
|
|
3
|
+
assertion: () => Promise<PublicKeyCredential>;
|
|
4
|
+
attestation: () => Promise<PublicKeyCredential>;
|
|
5
|
+
login: () => Promise<any>;
|
|
6
|
+
register: () => Promise<any>;
|
|
7
|
+
};
|
|
1
8
|
export declare const assertion: () => Promise<PublicKeyCredential>;
|
|
2
9
|
export declare const attestation: () => Promise<PublicKeyCredential>;
|
|
3
10
|
export declare const login: () => Promise<any>;
|