@hostlink/light 2.5.0 → 2.5.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 CHANGED
@@ -6,7 +6,7 @@ declare const _default: (axios: AxiosInstance) => {
6
6
  };
7
7
  google: {
8
8
  unlink: () => Promise<boolean>;
9
- login: (accessToken: string) => Promise<boolean>;
9
+ login: (credential: string) => Promise<boolean>;
10
10
  register: (credential: string) => Promise<boolean>;
11
11
  };
12
12
  facebook: {
package/dist/index.d.ts CHANGED
@@ -9,3 +9,5 @@ export * from './fs';
9
9
  export { default as createClient } from './createClient';
10
10
  export type { LightClient } from './createClient';
11
11
  export { default as createCollection } from './createCollection';
12
+ export type { UserFields } from './users';
13
+ export type { RoleFields } from './roles';
package/dist/light.js CHANGED
@@ -218,7 +218,7 @@ const fr = (e) => ({
218
218
  google: {
219
219
  unlink: () => f(e, "lightAuthUnlinkGoogle"),
220
220
  login: (t) => f(e, "lightAuthLoginGoogle", {
221
- access_token: t
221
+ credential: t
222
222
  }),
223
223
  register: (t) => f(e, "lightAuthRegisterGoogle", {
224
224
  credential: t
@@ -1,4 +1,4 @@
1
- (function(g,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],w):(g=typeof globalThis<"u"?globalThis:g||self,w(g.light={},g.jsonToGraphqlQuery,g.axios))})(this,function(g,w,T){"use strict";var co=Object.defineProperty;var fo=(g,w,T)=>w in g?co(g,w,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[w]=T;var S=(g,w,T)=>fo(g,typeof w!="symbol"?w+"":w,T);function dt(e){const t="==".slice(0,(4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,n=atob(r),i=new ArrayBuffer(n.length),s=new Uint8Array(i);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return i}function vt(e){const t=new Uint8Array(e);let r="";for(const s of t)r+=String.fromCharCode(s);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var l="copy",O="convert";function D(e,t,r){if(t===l)return r;if(t===O)return e(r);if(t instanceof Array)return r.map(n=>D(e,t[0],n));if(t instanceof Object){const n={};for(const[i,s]of Object.entries(t)){if(s.derive){const o=s.derive(r);o!==void 0&&(r[i]=o)}if(!(i in r)){if(s.required)throw new Error(`Missing key: ${i}`);continue}if(r[i]==null){n[i]=null;continue}n[i]=D(e,s.schema,r[i])}return n}}function L(e,t){return{required:!0,schema:e,derive:t}}function y(e){return{required:!0,schema:e}}function v(e){return{required:!1,schema:e}}var bt={type:y(l),id:y(O),transports:v(l)},gt={appid:v(l),appidExclude:v(l),credProps:v(l)},wt={appid:v(l),appidExclude:v(l),credProps:v(l)},Zt={publicKey:y({rp:y(l),user:y({id:y(O),name:y(l),displayName:y(l)}),challenge:y(O),pubKeyCredParams:y(l),timeout:v(l),excludeCredentials:v([bt]),authenticatorSelection:v(l),attestation:v(l),extensions:v(gt)}),signal:v(l)},kt={type:y(l),id:y(l),rawId:y(O),authenticatorAttachment:v(l),response:y({clientDataJSON:y(O),attestationObject:y(O),transports:L(l,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:L(wt,e=>e.getClientExtensionResults())},tr={mediation:v(l),publicKey:y({challenge:y(O),timeout:v(l),rpId:v(l),allowCredentials:v([bt]),userVerification:v(l),extensions:v(gt)}),signal:v(l)},rr={type:y(l),id:y(l),rawId:y(O),authenticatorAttachment:v(l),response:y({clientDataJSON:y(O),authenticatorData:y(O),signature:y(O),userHandle:y(O)}),clientExtensionResults:L(wt,e=>e.getClientExtensionResults())};function er(e){return D(dt,Zt,e)}function nr(e){return D(vt,kt,e)}function ir(e){return D(dt,tr,e)}function sr(e){return D(vt,rr,e)}async function or(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>nr(t),t}async function ar(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>sr(t),t}const ur=e=>({login:async t=>{const{app:r}=await A(e,{app:{auth:{webAuthnRequestOptions:{__args:{username:t}}}}}),n=r.auth.webAuthnRequestOptions,i=ir({publicKey:n}),s=await ar(i);await f(e,"webAuthnAssertion",{username:t,assertion:s.toJSON()})},register:async()=>{const{app:t}=await A(e,{app:{auth:{webAuthnCreationOptions:!0}}}),r=er({publicKey:t.auth.webAuthnCreationOptions}),n=await or(r);await f(e,"webAuthnRegister",{registration:n.toJSON()})}}),cr=e=>({WebAuthn:ur(e),google:{unlink:()=>f(e,"lightAuthUnlinkGoogle"),login:t=>f(e,"lightAuthLoginGoogle",{access_token:t}),register:t=>f(e,"lightAuthRegisterGoogle",{credential:t})},facebook:{unlink:()=>f(e,"lightAuthUnlinkFacebook"),login:t=>f(e,"lightAuthLoginFacebook",{access_token:t}),register:t=>f(e,"lightAuthRegisterFacebook",{access_token:t})},microsoft:{unlink:()=>f(e,"lightAuthUnlinkMicrosoft"),login:t=>f(e,"lightAuthLoginMicrosoft",{access_token:t}),register:t=>f(e,"lightAuthRegisterMicrosoft",{account_id:t})},login:(t,r,n="")=>f(e,"login",{username:t,password:r,code:n}),logout:()=>f(e,"logout"),changeExpiredPassword:(t,r,n)=>f(e,"changeExpiredPassword",{username:t,old_password:r,new_password:n}),updatePassword:(t,r)=>f(e,"updatePassword",{old_password:t,new_password:r}),resetPassword:(t,r,n)=>f(e,"resetPassword",{username:t,password:r,code:n}),forgetPassword:(t,r)=>f(e,"forgetPassword",{username:t,email:r}),verifyCode(t,r){return f(e,"forgetPasswordVerifyCode",{username:t,code:r})},granted:async t=>(await A(e,{granted:{__args:{rights:t}}})).granted}),fr=(e,t,r)=>{const n=t,i=e,s=r;let o="list"+t;const u=a=>s[a]?s[a]():null;return{field:u,$fields:s,setDataPath(a){return o=a,o},getDataPath(){return o},gqlFields(a){const c=[];for(const p of a)if(typeof p=="string"){const b=u(p);b&&c.push(b.getGQLField())}else typeof p=="object"&&c.push(p);return c},async update(a,c){return await f(i,"update"+n,{id:a,data:c})},async delete(a){return await f(i,"delete"+n,{id:a})},async add(a){return await f(i,"add"+n,{data:a})},fields(a){let c=[];for(let p of a){const b=u(p);b&&c.push(b)}return c},async get(a,c){return(await A(i,{["list"+n]:{__args:{filters:a},data:{__args:{limit:1},...B(c)}}}))["list"+n].data[0]},async list(a,c){return(await A(i,{["list"+n]:{__args:{filters:a},data:{...B(c)}}}))["list"+n].data}}};function lr(e){e="<~"+e+"~>";var t,r,n,i,s,o=String,u=255;for(e.slice(0,2)==="<~"&&e.slice(-2),e=e.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),t="uuuuu".slice(e.length%5||5),e+=t,n=[],i=0,s=e.length;s>i;i+=5)r=52200625*(e.charCodeAt(i)-33)+614125*(e.charCodeAt(i+1)-33)+7225*(e.charCodeAt(i+2)-33)+85*(e.charCodeAt(i+3)-33)+(e.charCodeAt(i+4)-33),n.push(u&r>>24,u&r>>16,u&r>>8,u&r);return function(a,c){for(var p=c;p>0;p--)a.pop()}(n,t.length),o.fromCharCode.apply(o,n)}const q=(e="")=>{const t=e,r=(n="application/octet-stream")=>{const i=new Uint8Array(t.length);for(let u=0;u<t.length;u++)i[u]=t.charCodeAt(u);const s=new Blob([i],{type:n});return URL.createObjectURL(s)};return{getContent:()=>t,getURL:r,download:n=>{const i=document.createElement("a");i.download=n,i.href=r(),document.body.appendChild(i),i.click(),document.body.removeChild(i)},open:n=>{window.open(r(n),"_blank")}}},hr={fromBase85:e=>q(lr(e)),fromBase64:e=>q(atob(e)),fromString:e=>q(e)},H=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(r=>{Object.entries(H(r)).forEach(([n,i])=>{t[n]=i})}),t):(Object.entries(e).forEach(([r,n])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){t[r]=n;return}if(typeof n=="boolean"){t[r]=n;return}t[r]=H(n)}),t)},B=e=>H(e),A=async(e,t)=>{let r=w.jsonToGraphQLQuery(B(t));const n=await e.post("",{query:`{ ${r} }`});if(n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};function pr(e){for(let t=0;t<e.length;t++)if(e[t]instanceof File)return!0;return!1}function yr(e){for(let t in e)if(e[t]instanceof File)return!0;return!1}const f=async(e,t,r=null,n=[])=>{let i={[t]:{}};const s=new FormData;let o=!1;if(r){const c={},p={},b={};let h=0;Object.entries(r).forEach(([m,_])=>{if(_ instanceof Array&&pr(_)){o=!0;let F=0;_.forEach(N=>{N instanceof File&&(c[m]=new w.VariableType(m),p[h]=["variables."+m+"."+F],s.append(h.toString(),N),h++)}),b[m]="[Upload!]!"}else _ instanceof File?(o=!0,c[m]=new w.VariableType(m),p[h]=["variables."+m],s.append(h.toString(),_),b[m]="Upload!",h++):_ instanceof Object&&yr(_)?(o=!0,c[m]={},Object.entries(_).forEach(([F,N])=>{N instanceof File?(c[m][F]=new w.VariableType(F),p[h]=["variables."+F],s.append(h.toString(),N),b[F]="Upload!",h++):c[m][F]=N})):_!==void 0&&(c[m]=_)}),i[t].__args=c,i.__variables=b,o&&s.append("map",JSON.stringify(p))}Object.entries(B(n)).forEach(([c,p])=>{i[t][c]=p}),Object.entries(i[t]).length===0&&(i[t]=!0);let u=null;const a=w.jsonToGraphQLQuery({mutation:i});if(o?(s.append("operations",JSON.stringify({query:a})),u=await e.post("",s)):u=await e.post("",{query:a}),u.data.errors)throw new Error(u.data.errors[0].message);return u.data.data[t]},mr=e=>({uploadTempFile:t=>f(e,"fsUploadTempFile",{file:t},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async t=>(await A(e,{fsListFolders:{__args:{path:t},name:!0,path:!0}})).fsListFolders,create:t=>f(e,"fsCreateFolder",{path:t}),delete:t=>f(e,"fsDeleteFolder",{path:t}),rename:(t,r)=>f(e,"fsRenameFolder",{path:t,name:r})},files:{list:async t=>(await A(e,{fsListFiles:{__args:{path:t},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}})).fsListFiles,read:async t=>{let r=await A(e,{fsFile:{__args:{path:t},base64Content:!0}});return window.atob(r.fsFile.base64Content)},write:(t,r)=>f(e,"fsWriteFile",{path:t,content:r}),delete:t=>f(e,"fsDeleteFile",{path:t}),rename:(t,r)=>f(e,"fsRenameFile",{path:t,name:r}),move:(t,r)=>f(e,"fsMoveFile",{source:t,target:r})}}),dr=e=>({get:async t=>(await e({config:{__args:{name:t}}})).config}),vr=e=>({send:(t,r,n)=>f(e,"sendMail",{email:t,subject:r,message:n})}),br=e=>({list:async(t={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0})=>{const r=mt("Users",e,t);return r.data_path="app.users",r.all()}}),gr=e=>{const t=e,r={};return{create(n,i){r[n]=null;let s={};for(const o of Object.entries(i)){const[u,a]=o;s[u]=()=>({name:a.name?a.name:u,raw:a,getName:()=>a.name?a.name:u,getGQLField:()=>a.gqlField!==void 0?a.gqlField:a.name||u,getRaw(){return a},getValue(c){return a.field&&typeof a.field=="function"?a.field(c):a.field&&typeof a.field=="string"?c[a.field]:c[this.getName()]},getFormattedValue(c){const p=this.getValue(c);return a.format?a.format(p):p}})}r[n]=fr(t,n,s)},get(n){return r[n]||this.create(n,{}),r[n]}}},wr=e=>({list:async(t={name:!0})=>{const{app:{roles:r}}=await A(e,{app:{roles:t}});return r}});function Ar(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var At={exports:{}},_r=function(){var t=this,r=-1;return{next:function(){return r+=1,{value:t.items[r],done:r>=t.items.length}}}},Or=function(){return this.items};function x(e){"@babel/helpers - typeof";return x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(e)}var d={isArray:function(t){return Array.isArray(t)},isObject:function(t){return x(t)==="object"&&Array.isArray(t)===!1&&t!==null},isFunction:function(t){return typeof t=="function"}},Sr=d,$r=Sr.isFunction,_t=function(t){return t===void 0?this.sum()/this.items.length:$r(t)?new this.constructor(this.items).sum(t)/this.items.length:new this.constructor(this.items).pluck(t).sum()/this.items.length},jr=_t,Er=jr;function G(e){"@babel/helpers - typeof";return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(e)}var Ir=function(t){var r=this,n=[],i=0;if(Array.isArray(this.items))do{var s=this.items.slice(i,i+t),o=new this.constructor(s);n.push(o),i+=t}while(i<this.items.length);else if(G(this.items)==="object"){var u=Object.keys(this.items),a=function(){var p=u.slice(i,i+t),b=new r.constructor({});p.forEach(function(h){return b.put(h,r.items[h])}),n.push(b),i+=t};do a();while(i<u.length)}else n.push(new this.constructor([this.items]));return new this.constructor(n)};function Cr(e){return Pr(e)||Dr(e)||Tr(e)||Fr()}function Fr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ (function(g,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],w):(g=typeof globalThis<"u"?globalThis:g||self,w(g.light={},g.jsonToGraphqlQuery,g.axios))})(this,function(g,w,T){"use strict";var co=Object.defineProperty;var fo=(g,w,T)=>w in g?co(g,w,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[w]=T;var S=(g,w,T)=>fo(g,typeof w!="symbol"?w+"":w,T);function dt(e){const t="==".slice(0,(4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,n=atob(r),i=new ArrayBuffer(n.length),s=new Uint8Array(i);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return i}function vt(e){const t=new Uint8Array(e);let r="";for(const s of t)r+=String.fromCharCode(s);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var l="copy",O="convert";function D(e,t,r){if(t===l)return r;if(t===O)return e(r);if(t instanceof Array)return r.map(n=>D(e,t[0],n));if(t instanceof Object){const n={};for(const[i,s]of Object.entries(t)){if(s.derive){const o=s.derive(r);o!==void 0&&(r[i]=o)}if(!(i in r)){if(s.required)throw new Error(`Missing key: ${i}`);continue}if(r[i]==null){n[i]=null;continue}n[i]=D(e,s.schema,r[i])}return n}}function L(e,t){return{required:!0,schema:e,derive:t}}function y(e){return{required:!0,schema:e}}function v(e){return{required:!1,schema:e}}var bt={type:y(l),id:y(O),transports:v(l)},gt={appid:v(l),appidExclude:v(l),credProps:v(l)},wt={appid:v(l),appidExclude:v(l),credProps:v(l)},Zt={publicKey:y({rp:y(l),user:y({id:y(O),name:y(l),displayName:y(l)}),challenge:y(O),pubKeyCredParams:y(l),timeout:v(l),excludeCredentials:v([bt]),authenticatorSelection:v(l),attestation:v(l),extensions:v(gt)}),signal:v(l)},kt={type:y(l),id:y(l),rawId:y(O),authenticatorAttachment:v(l),response:y({clientDataJSON:y(O),attestationObject:y(O),transports:L(l,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:L(wt,e=>e.getClientExtensionResults())},tr={mediation:v(l),publicKey:y({challenge:y(O),timeout:v(l),rpId:v(l),allowCredentials:v([bt]),userVerification:v(l),extensions:v(gt)}),signal:v(l)},rr={type:y(l),id:y(l),rawId:y(O),authenticatorAttachment:v(l),response:y({clientDataJSON:y(O),authenticatorData:y(O),signature:y(O),userHandle:y(O)}),clientExtensionResults:L(wt,e=>e.getClientExtensionResults())};function er(e){return D(dt,Zt,e)}function nr(e){return D(vt,kt,e)}function ir(e){return D(dt,tr,e)}function sr(e){return D(vt,rr,e)}async function or(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>nr(t),t}async function ar(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>sr(t),t}const ur=e=>({login:async t=>{const{app:r}=await A(e,{app:{auth:{webAuthnRequestOptions:{__args:{username:t}}}}}),n=r.auth.webAuthnRequestOptions,i=ir({publicKey:n}),s=await ar(i);await f(e,"webAuthnAssertion",{username:t,assertion:s.toJSON()})},register:async()=>{const{app:t}=await A(e,{app:{auth:{webAuthnCreationOptions:!0}}}),r=er({publicKey:t.auth.webAuthnCreationOptions}),n=await or(r);await f(e,"webAuthnRegister",{registration:n.toJSON()})}}),cr=e=>({WebAuthn:ur(e),google:{unlink:()=>f(e,"lightAuthUnlinkGoogle"),login:t=>f(e,"lightAuthLoginGoogle",{credential:t}),register:t=>f(e,"lightAuthRegisterGoogle",{credential:t})},facebook:{unlink:()=>f(e,"lightAuthUnlinkFacebook"),login:t=>f(e,"lightAuthLoginFacebook",{access_token:t}),register:t=>f(e,"lightAuthRegisterFacebook",{access_token:t})},microsoft:{unlink:()=>f(e,"lightAuthUnlinkMicrosoft"),login:t=>f(e,"lightAuthLoginMicrosoft",{access_token:t}),register:t=>f(e,"lightAuthRegisterMicrosoft",{account_id:t})},login:(t,r,n="")=>f(e,"login",{username:t,password:r,code:n}),logout:()=>f(e,"logout"),changeExpiredPassword:(t,r,n)=>f(e,"changeExpiredPassword",{username:t,old_password:r,new_password:n}),updatePassword:(t,r)=>f(e,"updatePassword",{old_password:t,new_password:r}),resetPassword:(t,r,n)=>f(e,"resetPassword",{username:t,password:r,code:n}),forgetPassword:(t,r)=>f(e,"forgetPassword",{username:t,email:r}),verifyCode(t,r){return f(e,"forgetPasswordVerifyCode",{username:t,code:r})},granted:async t=>(await A(e,{granted:{__args:{rights:t}}})).granted}),fr=(e,t,r)=>{const n=t,i=e,s=r;let o="list"+t;const u=a=>s[a]?s[a]():null;return{field:u,$fields:s,setDataPath(a){return o=a,o},getDataPath(){return o},gqlFields(a){const c=[];for(const p of a)if(typeof p=="string"){const b=u(p);b&&c.push(b.getGQLField())}else typeof p=="object"&&c.push(p);return c},async update(a,c){return await f(i,"update"+n,{id:a,data:c})},async delete(a){return await f(i,"delete"+n,{id:a})},async add(a){return await f(i,"add"+n,{data:a})},fields(a){let c=[];for(let p of a){const b=u(p);b&&c.push(b)}return c},async get(a,c){return(await A(i,{["list"+n]:{__args:{filters:a},data:{__args:{limit:1},...B(c)}}}))["list"+n].data[0]},async list(a,c){return(await A(i,{["list"+n]:{__args:{filters:a},data:{...B(c)}}}))["list"+n].data}}};function lr(e){e="<~"+e+"~>";var t,r,n,i,s,o=String,u=255;for(e.slice(0,2)==="<~"&&e.slice(-2),e=e.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),t="uuuuu".slice(e.length%5||5),e+=t,n=[],i=0,s=e.length;s>i;i+=5)r=52200625*(e.charCodeAt(i)-33)+614125*(e.charCodeAt(i+1)-33)+7225*(e.charCodeAt(i+2)-33)+85*(e.charCodeAt(i+3)-33)+(e.charCodeAt(i+4)-33),n.push(u&r>>24,u&r>>16,u&r>>8,u&r);return function(a,c){for(var p=c;p>0;p--)a.pop()}(n,t.length),o.fromCharCode.apply(o,n)}const q=(e="")=>{const t=e,r=(n="application/octet-stream")=>{const i=new Uint8Array(t.length);for(let u=0;u<t.length;u++)i[u]=t.charCodeAt(u);const s=new Blob([i],{type:n});return URL.createObjectURL(s)};return{getContent:()=>t,getURL:r,download:n=>{const i=document.createElement("a");i.download=n,i.href=r(),document.body.appendChild(i),i.click(),document.body.removeChild(i)},open:n=>{window.open(r(n),"_blank")}}},hr={fromBase85:e=>q(lr(e)),fromBase64:e=>q(atob(e)),fromString:e=>q(e)},H=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(r=>{Object.entries(H(r)).forEach(([n,i])=>{t[n]=i})}),t):(Object.entries(e).forEach(([r,n])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){t[r]=n;return}if(typeof n=="boolean"){t[r]=n;return}t[r]=H(n)}),t)},B=e=>H(e),A=async(e,t)=>{let r=w.jsonToGraphQLQuery(B(t));const n=await e.post("",{query:`{ ${r} }`});if(n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};function pr(e){for(let t=0;t<e.length;t++)if(e[t]instanceof File)return!0;return!1}function yr(e){for(let t in e)if(e[t]instanceof File)return!0;return!1}const f=async(e,t,r=null,n=[])=>{let i={[t]:{}};const s=new FormData;let o=!1;if(r){const c={},p={},b={};let h=0;Object.entries(r).forEach(([m,_])=>{if(_ instanceof Array&&pr(_)){o=!0;let F=0;_.forEach(N=>{N instanceof File&&(c[m]=new w.VariableType(m),p[h]=["variables."+m+"."+F],s.append(h.toString(),N),h++)}),b[m]="[Upload!]!"}else _ instanceof File?(o=!0,c[m]=new w.VariableType(m),p[h]=["variables."+m],s.append(h.toString(),_),b[m]="Upload!",h++):_ instanceof Object&&yr(_)?(o=!0,c[m]={},Object.entries(_).forEach(([F,N])=>{N instanceof File?(c[m][F]=new w.VariableType(F),p[h]=["variables."+F],s.append(h.toString(),N),b[F]="Upload!",h++):c[m][F]=N})):_!==void 0&&(c[m]=_)}),i[t].__args=c,i.__variables=b,o&&s.append("map",JSON.stringify(p))}Object.entries(B(n)).forEach(([c,p])=>{i[t][c]=p}),Object.entries(i[t]).length===0&&(i[t]=!0);let u=null;const a=w.jsonToGraphQLQuery({mutation:i});if(o?(s.append("operations",JSON.stringify({query:a})),u=await e.post("",s)):u=await e.post("",{query:a}),u.data.errors)throw new Error(u.data.errors[0].message);return u.data.data[t]},mr=e=>({uploadTempFile:t=>f(e,"fsUploadTempFile",{file:t},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async t=>(await A(e,{fsListFolders:{__args:{path:t},name:!0,path:!0}})).fsListFolders,create:t=>f(e,"fsCreateFolder",{path:t}),delete:t=>f(e,"fsDeleteFolder",{path:t}),rename:(t,r)=>f(e,"fsRenameFolder",{path:t,name:r})},files:{list:async t=>(await A(e,{fsListFiles:{__args:{path:t},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}})).fsListFiles,read:async t=>{let r=await A(e,{fsFile:{__args:{path:t},base64Content:!0}});return window.atob(r.fsFile.base64Content)},write:(t,r)=>f(e,"fsWriteFile",{path:t,content:r}),delete:t=>f(e,"fsDeleteFile",{path:t}),rename:(t,r)=>f(e,"fsRenameFile",{path:t,name:r}),move:(t,r)=>f(e,"fsMoveFile",{source:t,target:r})}}),dr=e=>({get:async t=>(await e({config:{__args:{name:t}}})).config}),vr=e=>({send:(t,r,n)=>f(e,"sendMail",{email:t,subject:r,message:n})}),br=e=>({list:async(t={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0})=>{const r=mt("Users",e,t);return r.data_path="app.users",r.all()}}),gr=e=>{const t=e,r={};return{create(n,i){r[n]=null;let s={};for(const o of Object.entries(i)){const[u,a]=o;s[u]=()=>({name:a.name?a.name:u,raw:a,getName:()=>a.name?a.name:u,getGQLField:()=>a.gqlField!==void 0?a.gqlField:a.name||u,getRaw(){return a},getValue(c){return a.field&&typeof a.field=="function"?a.field(c):a.field&&typeof a.field=="string"?c[a.field]:c[this.getName()]},getFormattedValue(c){const p=this.getValue(c);return a.format?a.format(p):p}})}r[n]=fr(t,n,s)},get(n){return r[n]||this.create(n,{}),r[n]}}},wr=e=>({list:async(t={name:!0})=>{const{app:{roles:r}}=await A(e,{app:{roles:t}});return r}});function Ar(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var At={exports:{}},_r=function(){var t=this,r=-1;return{next:function(){return r+=1,{value:t.items[r],done:r>=t.items.length}}}},Or=function(){return this.items};function x(e){"@babel/helpers - typeof";return x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(e)}var d={isArray:function(t){return Array.isArray(t)},isObject:function(t){return x(t)==="object"&&Array.isArray(t)===!1&&t!==null},isFunction:function(t){return typeof t=="function"}},Sr=d,$r=Sr.isFunction,_t=function(t){return t===void 0?this.sum()/this.items.length:$r(t)?new this.constructor(this.items).sum(t)/this.items.length:new this.constructor(this.items).pluck(t).sum()/this.items.length},jr=_t,Er=jr;function G(e){"@babel/helpers - typeof";return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(e)}var Ir=function(t){var r=this,n=[],i=0;if(Array.isArray(this.items))do{var s=this.items.slice(i,i+t),o=new this.constructor(s);n.push(o),i+=t}while(i<this.items.length);else if(G(this.items)==="object"){var u=Object.keys(this.items),a=function(){var p=u.slice(i,i+t),b=new r.constructor({});p.forEach(function(h){return b.put(h,r.items[h])}),n.push(b),i+=t};do a();while(i<u.length)}else n.push(new this.constructor([this.items]));return new this.constructor(n)};function Cr(e){return Pr(e)||Dr(e)||Tr(e)||Fr()}function Fr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tr(e,t){if(e){if(typeof e=="string")return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Q(e,t)}}function Dr(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Pr(e){if(Array.isArray(e))return Q(e)}function Q(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Nr=function(){var t;return new this.constructor((t=[]).concat.apply(t,Cr(this.items)))};function Br(e,t){return Rr(e)||Ur(e,t)||Mr(e,t)||qr()}function qr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mr(e,t){if(e){if(typeof e=="string")return Ot(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ot(e,t)}}function Ot(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ur(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,s=!1,o,u;try{for(r=r.call(e);!(i=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));i=!0);}catch(a){s=!0,u=a}finally{try{!i&&r.return!=null&&r.return()}finally{if(s)throw u}}return n}}function Rr(e){if(Array.isArray(e))return e}function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}var Kr=function(t){var r=this,n=t;n instanceof this.constructor&&(n=t.all());var i={};if(Array.isArray(this.items)&&Array.isArray(n))this.items.forEach(function(u,a){i[u]=n[a]});else if(M(this.items)==="object"&&M(n)==="object")Object.keys(this.items).forEach(function(u,a){i[r.items[u]]=n[Object.keys(n)[a]]});else if(Array.isArray(this.items))i[this.items[0]]=n;else if(typeof this.items=="string"&&Array.isArray(n)){var s=n,o=Br(s,1);i[this.items]=o[0]}else typeof this.items=="string"&&(i[this.items]=n);return new this.constructor(i)};function Wr(e){return Hr(e)||Lr(e)||Vr(e)||Jr()}function Jr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vr(e,t){if(e){if(typeof e=="string")return z(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return z(e,t)}}function Lr(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Hr(e){if(Array.isArray(e))return z(e)}function z(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var St=function(t){var r;if(Array.isArray(t)){var n;r=[],(n=r).push.apply(n,Wr(t))}else r={},Object.keys(t).forEach(function(i){r[i]=t[i]});return r};function U(e){"@babel/helpers - typeof";return U=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},U(e)}var xr=St,Gr=function(t){var r=t;t instanceof this.constructor?r=t.all():U(t)==="object"&&(r=[],Object.keys(t).forEach(function(i){r.push(t[i])}));var n=xr(this.items);return r.forEach(function(i){U(i)==="object"?Object.keys(i).forEach(function(s){return n.push(i[s])}):n.push(i)}),new this.constructor(n)};function $t(e){return Yr(e)||Xr(e)||zr(e)||Qr()}function Qr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"