@hostlink/light 1.2.4 → 1.2.5
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/light.js +7 -7
- package/dist/light.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/light.js
CHANGED
|
@@ -195,7 +195,7 @@ const u = async (e, t = null, r = []) => {
|
|
|
195
195
|
}), _[f] = "[Upload!]!";
|
|
196
196
|
} else
|
|
197
197
|
h instanceof File ? (a = !0, g[f] = new R(f), m[w] = ["variables." + f], n.append(w.toString(), h), _[f] = "Upload!", w++) : h instanceof Object && Q(h) ? (a = !0, g[f] === void 0 && (g[f] = {}), Object.entries(h).forEach(([F, y]) => {
|
|
198
|
-
y instanceof File ? (g[f][F] = new R(F), m[w] = ["variables." + F], n.append(w.toString(), y), w++) : g[f][F] = y;
|
|
198
|
+
y instanceof File ? (g[f][F] = new R(F), m[w] = ["variables." + F], n.append(w.toString(), y), _[F] = "Upload!", w++) : g[f][F] = y;
|
|
199
199
|
})) : g[f] = h;
|
|
200
200
|
}), s[e].__args = g, s.__variables = _, a && n.append("map", JSON.stringify(m));
|
|
201
201
|
}
|
|
@@ -237,13 +237,13 @@ const we = (e, t, r) => u("sendMail", {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
})).config;
|
|
240
|
-
function
|
|
240
|
+
function U(e) {
|
|
241
241
|
const t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t, s = atob(r), n = new ArrayBuffer(s.length), a = new Uint8Array(n);
|
|
242
242
|
for (let l = 0; l < s.length; l++)
|
|
243
243
|
a[l] = s.charCodeAt(l);
|
|
244
244
|
return n;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function P(e) {
|
|
247
247
|
const t = new Uint8Array(e);
|
|
248
248
|
let r = "";
|
|
249
249
|
for (const a of t)
|
|
@@ -382,21 +382,21 @@ var D = {
|
|
|
382
382
|
)
|
|
383
383
|
};
|
|
384
384
|
function H(e) {
|
|
385
|
-
return A(
|
|
385
|
+
return A(U, G, e);
|
|
386
386
|
}
|
|
387
387
|
function I(e) {
|
|
388
388
|
return A(
|
|
389
|
-
|
|
389
|
+
P,
|
|
390
390
|
W,
|
|
391
391
|
e
|
|
392
392
|
);
|
|
393
393
|
}
|
|
394
394
|
function X(e) {
|
|
395
|
-
return A(
|
|
395
|
+
return A(U, $, e);
|
|
396
396
|
}
|
|
397
397
|
function Y(e) {
|
|
398
398
|
return A(
|
|
399
|
-
|
|
399
|
+
P,
|
|
400
400
|
z,
|
|
401
401
|
e
|
|
402
402
|
);
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("axios"),require("json-to-graphql-query")):typeof define=="function"&&define.amd?define(["exports","axios","json-to-graphql-query"],S):(s=typeof globalThis<"u"?globalThis:s||self,S(s.light={},s.axios,s.jsonToGraphqlQuery))})(this,function(s,S,R){"use strict";const Q=(e,t,n="")=>u("login",{username:e,password:t,code:n}),B=()=>u("logout"),W=(e,t)=>u("updatePassword",{old_password:e,new_password:t}),$=(e,t,n)=>u("resetPassword",{email:e,password:t,code:n}),z=e=>u("forgetPassword",{email:e});let q;const G=e=>{q=e},j=()=>(q||(q=S.create({withCredentials:!0})),q),H=async e=>(await h({granted:{__args:{rights:e}}})).granted,
|
|
1
|
+
(function(s,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("axios"),require("json-to-graphql-query")):typeof define=="function"&&define.amd?define(["exports","axios","json-to-graphql-query"],S):(s=typeof globalThis<"u"?globalThis:s||self,S(s.light={},s.axios,s.jsonToGraphqlQuery))})(this,function(s,S,R){"use strict";const Q=(e,t,n="")=>u("login",{username:e,password:t,code:n}),B=()=>u("logout"),W=(e,t)=>u("updatePassword",{old_password:e,new_password:t}),$=(e,t,n)=>u("resetPassword",{email:e,password:t,code:n}),z=e=>u("forgetPassword",{email:e});let q;const G=e=>{q=e},j=()=>(q||(q=S.create({withCredentials:!0})),q),H=async e=>(await h({granted:{__args:{rights:e}}})).granted,A={},I=(e,t)=>{A[e]={};for(const n of Object.entries(t)){const[i,r]=n;A[e][i]=()=>({name:r.name?r.name:i,raw:r,getName:()=>r.name?r.name:i,getGQLField:()=>r.gqlField!==void 0?r.gqlField:r.name||i,getRaw(){return r},getValue(o){return r.field&&typeof r.field=="function"?r.field(o):r.field&&typeof r.field=="string"?o[r.field]:o[this.getName()]},getFormattedValue(o){const f=this.getValue(o);return r.format?r.format(f):f}})}},N=(e,t)=>!A[e]||!A[e][t]?null:A[e][t](),X=(e,t)=>{const n=[];for(const i of t)if(typeof i=="string"){const r=N(e,i);r&&n.push(r.getGQLField())}else typeof i=="object"&&n.push(i);return n},Y=e=>{const t=e;return{name:t,$fields:A[e],async update(n,i){return await u("update"+t,{id:n,data:i})},async delete(n){return await u("delete"+t,{id:n})},async add(n){return await u("add"+t,{data:n})},fields(n){let i=[];for(let r of n){const o=N(t,r);o&&i.push(o)}return i},async get(n,i){return(await h({["list"+t]:{__args:{filters:n},data:{__args:{limit:1},...v(i)}}}))["list"+t].data[0]},async list(n,i){return(await h({["list"+t]:{__args:{filters:n},data:{...v(i)}}}))["list"+t].data}}};function Z(e){e="<~"+e+"~>";var t,n,i,r,o,f=String,p=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,i=[],r=0,o=e.length;o>r;r+=5)n=52200625*(e.charCodeAt(r)-33)+614125*(e.charCodeAt(r+1)-33)+7225*(e.charCodeAt(r+2)-33)+85*(e.charCodeAt(r+3)-33)+(e.charCodeAt(r+4)-33),i.push(p&n>>24,p&n>>16,p&n>>8,p&n);return function(w,F){for(var y=F;y>0;y--)w.pop()}(i,t.length),f.fromCharCode.apply(f,i)}const E=(e="")=>{const t=e,n=(i="application/octet-stream")=>{const r=new Uint8Array(t.length);for(let p=0;p<t.length;p++)r[p]=t.charCodeAt(p);const o=new Blob([r],{type:i});return URL.createObjectURL(o)};return{getContent:()=>t,getURL:n,download:i=>{const r=document.createElement("a");r.download=i,r.href=n(),document.body.appendChild(r),r.click(),document.body.removeChild(r)},open:i=>{window.open(n(i),"_blank")}}},x={fromBase85:e=>E(Z(e)),fromBase64:e=>E(atob(e)),fromString:e=>E(e)},P=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(n=>{Object.entries(P(n)).forEach(([i,r])=>{t[i]=r})}),t):(Object.entries(e).forEach(([n,i])=>{if(n=="__args"||n=="__aliasFor"||n=="__variables"||n=="__directives"||n=="__all_on"||n=="__name"){t[n]=i;return}if(typeof i=="boolean"){t[n]=i;return}t[n]=P(i)}),t)},v=e=>P(e),h=async e=>{let t=R.jsonToGraphQLQuery(v(e));const n=await j().post(L(),{query:`{ ${t} }`});if(n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};function k(e){for(let t=0;t<e.length;t++)if(e[t]instanceof File)return!0;return!1}function ee(e){for(let t in e)if(e[t]instanceof File)return!0;return!1}const u=async(e,t=null,n=[])=>{let i={[e]:{}};const r=new FormData;let o=!1;if(t){const w={},F={},y={};let b=0;Object.entries(t).forEach(([g,m])=>{if(m instanceof Array&&k(m)){o=!0;let _=0;m.forEach(O=>{O instanceof File&&(w[g]=new R.VariableType(g),F[b]=["variables."+g+"."+_],r.append(b.toString(),O),b++)}),y[g]="[Upload!]!"}else m instanceof File?(o=!0,w[g]=new R.VariableType(g),F[b]=["variables."+g],r.append(b.toString(),m),y[g]="Upload!",b++):m instanceof Object&&ee(m)?(o=!0,w[g]===void 0&&(w[g]={}),Object.entries(m).forEach(([_,O])=>{O instanceof File?(w[g][_]=new R.VariableType(_),F[b]=["variables."+_],r.append(b.toString(),O),y[_]="Upload!",b++):w[g][_]=O})):w[g]=m}),i[e].__args=w,i.__variables=y,o&&r.append("map",JSON.stringify(F))}Object.entries(v(n)).forEach(([w,F])=>{i[e][w]=F}),Object.entries(i[e]).length===0&&(i[e]=!0);let f=null;const p=R.jsonToGraphQLQuery({mutation:i});if(o?(r.append("operations",JSON.stringify({query:p})),f=await j().post(L(),r)):f=await j().post(L(),{query:p}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data[e]};let J="/api/";const te=e=>{J=e},L=()=>J;async function ne(e){return u("fsUploadTempFile",{file:e},{name:!0,path:!0,size:!0,mime:!0})}const re=(e,t,n)=>u("sendMail",{email:e,subject:t,message:n}),ie=async e=>(await h({config:{__args:{name:e}}})).config;function M(e){const t="==".slice(0,(4-e.length%4)%4),n=e.replace(/-/g,"+").replace(/_/g,"/")+t,i=atob(n),r=new ArrayBuffer(i.length),o=new Uint8Array(r);for(let f=0;f<i.length;f++)o[f]=i.charCodeAt(f);return r}function D(e){const t=new Uint8Array(e);let n="";for(const o of t)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var a="copy",d="convert";function C(e,t,n){if(t===a)return n;if(t===d)return e(n);if(t instanceof Array)return n.map(i=>C(e,t[0],i));if(t instanceof Object){const i={};for(const[r,o]of Object.entries(t)){if(o.derive){const f=o.derive(n);f!==void 0&&(n[r]=f)}if(!(r in n)){if(o.required)throw new Error(`Missing key: ${r}`);continue}if(n[r]==null){i[r]=null;continue}i[r]=C(e,o.schema,n[r])}return i}}function U(e,t){return{required:!0,schema:e,derive:t}}function l(e){return{required:!0,schema:e}}function c(e){return{required:!1,schema:e}}var T={type:l(a),id:l(d),transports:c(a)},V={appid:c(a),appidExclude:c(a),credProps:c(a)},K={appid:c(a),appidExclude:c(a),credProps:c(a)},se={publicKey:l({rp:l(a),user:l({id:l(d),name:l(a),displayName:l(a)}),challenge:l(d),pubKeyCredParams:l(a),timeout:c(a),excludeCredentials:c([T]),authenticatorSelection:c(a),attestation:c(a),extensions:c(V)}),signal:c(a)},ae={type:l(a),id:l(a),rawId:l(d),authenticatorAttachment:c(a),response:l({clientDataJSON:l(d),attestationObject:l(d),transports:U(a,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:U(K,e=>e.getClientExtensionResults())},oe={mediation:c(a),publicKey:l({challenge:l(d),timeout:c(a),rpId:c(a),allowCredentials:c([T]),userVerification:c(a),extensions:c(V)}),signal:c(a)},le={type:l(a),id:l(a),rawId:l(d),authenticatorAttachment:c(a),response:l({clientDataJSON:l(d),authenticatorData:l(d),signature:l(d),userHandle:l(d)}),clientExtensionResults:U(K,e=>e.getClientExtensionResults())};function ce(e){return C(M,se,e)}function ue(e){return C(D,ae,e)}function fe(e){return C(M,oe,e)}function de(e){return C(D,le,e)}async function ge(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>ue(t),t}async function pe(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>de(t),t}async function we(e){const n=(await h({webAuthnRequestOptions:{__args:{username:e}}})).webAuthnRequestOptions,i=fe({publicKey:n}),r=await pe(i);await u("webAuthnAssertion",{username:e,assertion:r.toJSON()})}async function he(){const e=await h({webAuthnCreationOptions:!0}),t=ce({publicKey:e.webAuthnCreationOptions}),n=await ge(t);await u("webAuthnRegister",{registration:n.toJSON()})}const be=async e=>(await h({fsListFiles:{__args:{path:e},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}})).fsListFiles,me=async e=>(await h({fsListFolders:{__args:{path:e},name:!0,path:!0}})).fsListFolders,Fe=async e=>{let t=await h({fsFile:{__args:{path:e},base64Content:!0}});return window.atob(t.fsFile.base64Content)},ye=(e,t)=>u("fsWriteFile",{path:e,content:t}),_e=e=>u("fsDeleteFile",{path:e}),Ae=e=>u("fsCreateFolder",{path:e}),Ce=e=>u("fsDeleteFolder",{path:e}),Oe=(e,t)=>u("fsRenameFile",{path:e,name:t}),Se=(e,t)=>u("fsRenameFolder",{path:e,name:t}),Re=(e,t)=>u("fsMoveFile",{source:e,target:t});s.File=x,s.defineModel=I,s.file=E,s.forgetPassword=z,s.fsCreateFolder=Ae,s.fsDeleteFile=_e,s.fsDeleteFolder=Ce,s.fsListFiles=be,s.fsListFolders=me,s.fsMoveFile=Re,s.fsReadFile=Fe,s.fsRenameFile=Oe,s.fsRenameFolder=Se,s.fsWriteFile=ye,s.getApiUrl=L,s.getAxios=j,s.getConfig=ie,s.getGQLFields=X,s.getModelField=N,s.granted=H,s.login=Q,s.logout=B,s.model=Y,s.mutation=u,s.query=h,s.resetPassword=$,s.sendMail=re,s.setApiUrl=te,s.setAxios=G,s.toQuery=v,s.updatePassword=W,s.uploadFile=ne,s.webauthnLogin=we,s.webauthnRegister=he,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|