@hostlink/light 1.2.2 → 1.2.4

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 CHANGED
@@ -25,11 +25,11 @@ const oe = (e) => {
25
25
  rights: e
26
26
  }
27
27
  }
28
- })).granted, F = {}, le = (e, t) => {
29
- F[e] = {};
28
+ })).granted, C = {}, le = (e, t) => {
29
+ C[e] = {};
30
30
  for (const r of Object.entries(t)) {
31
31
  const [s, n] = r;
32
- F[e][s] = () => ({
32
+ C[e][s] = () => ({
33
33
  name: n.name ? n.name : s,
34
34
  raw: n,
35
35
  getName: () => n.name ? n.name : s,
@@ -46,7 +46,7 @@ const oe = (e) => {
46
46
  }
47
47
  });
48
48
  }
49
- }, L = (e, t) => !F[e] || !F[e][t] ? null : F[e][t](), ue = (e, t) => {
49
+ }, L = (e, t) => !C[e] || !C[e][t] ? null : C[e][t](), ue = (e, t) => {
50
50
  const r = [];
51
51
  for (const s of t)
52
52
  if (typeof s == "string") {
@@ -59,7 +59,7 @@ const oe = (e) => {
59
59
  const t = e;
60
60
  return {
61
61
  name: t,
62
- $fields: F[e],
62
+ $fields: C[e],
63
63
  async update(r, s) {
64
64
  return await u("update" + t, { id: r, data: s });
65
65
  },
@@ -108,19 +108,19 @@ const oe = (e) => {
108
108
  };
109
109
  function M(e) {
110
110
  e = "<~" + e + "~>";
111
- var t, r, s, n, a, l = String, d = 255;
111
+ var t, r, s, n, a, l = String, p = 255;
112
112
  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, s = [], n = 0, a = e.length; a > n; n += 5)
113
- r = 52200625 * (e.charCodeAt(n) - 33) + 614125 * (e.charCodeAt(n + 1) - 33) + 7225 * (e.charCodeAt(n + 2) - 33) + 85 * (e.charCodeAt(n + 3) - 33) + (e.charCodeAt(n + 4) - 33), s.push(d & r >> 24, d & r >> 16, d & r >> 8, d & r);
114
- return function(p, m) {
113
+ r = 52200625 * (e.charCodeAt(n) - 33) + 614125 * (e.charCodeAt(n + 1) - 33) + 7225 * (e.charCodeAt(n + 2) - 33) + 85 * (e.charCodeAt(n + 3) - 33) + (e.charCodeAt(n + 4) - 33), s.push(p & r >> 24, p & r >> 16, p & r >> 8, p & r);
114
+ return function(g, m) {
115
115
  for (var _ = m; _ > 0; _--)
116
- p.pop();
116
+ g.pop();
117
117
  }(s, t.length), l.fromCharCode.apply(l, s);
118
118
  }
119
119
  const v = (e = "") => {
120
120
  const t = e, r = (s = "application/octet-stream") => {
121
121
  const n = new Uint8Array(t.length);
122
- for (let d = 0; d < t.length; d++)
123
- n[d] = t.charCodeAt(d);
122
+ for (let p = 0; p < t.length; p++)
123
+ n[p] = t.charCodeAt(p);
124
124
  const a = new Blob([n], { type: s });
125
125
  return URL.createObjectURL(a);
126
126
  };
@@ -184,30 +184,30 @@ const u = async (e, t = null, r = []) => {
184
184
  const n = new FormData();
185
185
  let a = !1;
186
186
  if (t) {
187
- const p = {}, m = {}, _ = {};
187
+ const g = {}, m = {}, _ = {};
188
188
  let w = 0;
189
- Object.entries(t).forEach(([h, g]) => {
190
- if (g instanceof Array && B(g)) {
189
+ Object.entries(t).forEach(([f, h]) => {
190
+ if (h instanceof Array && B(h)) {
191
191
  a = !0;
192
- let y = 0;
193
- g.forEach((A) => {
194
- A instanceof File && (p[h] = new R(h), m[w] = ["variables." + h + "." + y], n.append(w.toString(), A), w++);
195
- }), _[h] = "[Upload!]!";
192
+ let F = 0;
193
+ h.forEach((y) => {
194
+ y instanceof File && (g[f] = new R(f), m[w] = ["variables." + f + "." + F], n.append(w.toString(), y), w++);
195
+ }), _[f] = "[Upload!]!";
196
196
  } else
197
- g instanceof File ? (a = !0, p[h] = new R(h), m[w] = ["variables." + h], n.append(w.toString(), g), _[h] = "Upload!", w++) : g instanceof Object && Q(g) ? (a = !0, Object.entries(g).forEach(([y, A]) => {
198
- A instanceof File ? (p[y] = new R(y), m[w] = ["variables." + y], n.append(w.toString(), A), w++) : p[y] = g;
199
- })) : p[h] = g;
200
- }), s[e].__args = p, s.__variables = _, a && n.append("map", JSON.stringify(m));
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;
199
+ })) : g[f] = h;
200
+ }), s[e].__args = g, s.__variables = _, a && n.append("map", JSON.stringify(m));
201
201
  }
202
- Object.entries(S(r)).forEach(([p, m]) => {
203
- s[e][p] = m;
202
+ Object.entries(S(r)).forEach(([g, m]) => {
203
+ s[e][g] = m;
204
204
  }), Object.entries(s[e]).length === 0 && (s[e] = !0);
205
205
  let l = null;
206
- const d = N({ mutation: s });
206
+ const p = N({ mutation: s });
207
207
  if (a ? (n.append("operations", JSON.stringify({
208
- query: d
208
+ query: p
209
209
  })), l = await E().post(q(), n)) : l = await E().post(q(), {
210
- query: d
210
+ query: p
211
211
  }), l.data.errors)
212
212
  throw new Error(l.data.errors[0].message);
213
213
  return l.data.data[e];
@@ -253,14 +253,14 @@ function U(e) {
253
253
  "_"
254
254
  ).replace(/=/g, "");
255
255
  }
256
- var i = "copy", f = "convert";
257
- function C(e, t, r) {
256
+ var i = "copy", d = "convert";
257
+ function A(e, t, r) {
258
258
  if (t === i)
259
259
  return r;
260
- if (t === f)
260
+ if (t === d)
261
261
  return e(r);
262
262
  if (t instanceof Array)
263
- return r.map((s) => C(e, t[0], s));
263
+ return r.map((s) => A(e, t[0], s));
264
264
  if (t instanceof Object) {
265
265
  const s = {};
266
266
  for (const [n, a] of Object.entries(t)) {
@@ -277,7 +277,7 @@ function C(e, t, r) {
277
277
  s[n] = null;
278
278
  continue;
279
279
  }
280
- s[n] = C(
280
+ s[n] = A(
281
281
  e,
282
282
  a.schema,
283
283
  r[n]
@@ -307,7 +307,7 @@ function c(e) {
307
307
  }
308
308
  var D = {
309
309
  type: o(i),
310
- id: o(f),
310
+ id: o(d),
311
311
  transports: c(i)
312
312
  }, V = {
313
313
  appid: c(i),
@@ -321,11 +321,11 @@ var D = {
321
321
  publicKey: o({
322
322
  rp: o(i),
323
323
  user: o({
324
- id: o(f),
324
+ id: o(d),
325
325
  name: o(i),
326
326
  displayName: o(i)
327
327
  }),
328
- challenge: o(f),
328
+ challenge: o(d),
329
329
  pubKeyCredParams: o(i),
330
330
  timeout: c(i),
331
331
  excludeCredentials: c([D]),
@@ -337,11 +337,11 @@ var D = {
337
337
  }, W = {
338
338
  type: o(i),
339
339
  id: o(i),
340
- rawId: o(f),
340
+ rawId: o(d),
341
341
  authenticatorAttachment: c(i),
342
342
  response: o({
343
- clientDataJSON: o(f),
344
- attestationObject: o(f),
343
+ clientDataJSON: o(d),
344
+ attestationObject: o(d),
345
345
  transports: x(
346
346
  i,
347
347
  (e) => {
@@ -357,7 +357,7 @@ var D = {
357
357
  }, $ = {
358
358
  mediation: c(i),
359
359
  publicKey: o({
360
- challenge: o(f),
360
+ challenge: o(d),
361
361
  timeout: c(i),
362
362
  rpId: c(i),
363
363
  allowCredentials: c([D]),
@@ -368,13 +368,13 @@ var D = {
368
368
  }, z = {
369
369
  type: o(i),
370
370
  id: o(i),
371
- rawId: o(f),
371
+ rawId: o(d),
372
372
  authenticatorAttachment: c(i),
373
373
  response: o({
374
- clientDataJSON: o(f),
375
- authenticatorData: o(f),
376
- signature: o(f),
377
- userHandle: o(f)
374
+ clientDataJSON: o(d),
375
+ authenticatorData: o(d),
376
+ signature: o(d),
377
+ userHandle: o(d)
378
378
  }),
379
379
  clientExtensionResults: x(
380
380
  K,
@@ -382,20 +382,20 @@ var D = {
382
382
  )
383
383
  };
384
384
  function H(e) {
385
- return C(P, G, e);
385
+ return A(P, G, e);
386
386
  }
387
387
  function I(e) {
388
- return C(
388
+ return A(
389
389
  U,
390
390
  W,
391
391
  e
392
392
  );
393
393
  }
394
394
  function X(e) {
395
- return C(P, $, e);
395
+ return A(P, $, e);
396
396
  }
397
397
  function Y(e) {
398
- return C(
398
+ return A(
399
399
  U,
400
400
  z,
401
401
  e
@@ -448,7 +448,7 @@ const _e = async (e) => (await b({
448
448
  canPreview: !0,
449
449
  imagePath: !0
450
450
  }
451
- })).fsListFiles, ye = async (e) => (await b({
451
+ })).fsListFiles, Fe = async (e) => (await b({
452
452
  fsListFolders: {
453
453
  __args: {
454
454
  path: e
@@ -456,7 +456,7 @@ const _e = async (e) => (await b({
456
456
  name: !0,
457
457
  path: !0
458
458
  }
459
- })).fsListFolders, Fe = async (e) => {
459
+ })).fsListFolders, ye = async (e) => {
460
460
  let t = await b({
461
461
  fsFile: {
462
462
  __args: {
@@ -494,9 +494,9 @@ export {
494
494
  Ae as fsDeleteFile,
495
495
  Se as fsDeleteFolder,
496
496
  _e as fsListFiles,
497
- ye as fsListFolders,
497
+ Fe as fsListFolders,
498
498
  Ee as fsMoveFile,
499
- Fe as fsReadFile,
499
+ ye as fsReadFile,
500
500
  Re as fsRenameFile,
501
501
  ve as fsRenameFolder,
502
502
  Ce as fsWriteFile,
@@ -1 +1 @@
1
- (function(s,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("json-to-graphql-query")):typeof define=="function"&&define.amd?define(["exports","axios","json-to-graphql-query"],O):(s=typeof globalThis<"u"?globalThis:s||self,O(s.light={},s.axios,s.jsonToGraphqlQuery))})(this,function(s,O,S){"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=O.create({withCredentials:!0})),q),H=async e=>(await p({granted:{__args:{rights:e}}})).granted,y={},I=(e,t)=>{y[e]={};for(const n of Object.entries(t)){const[i,r]=n;y[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)=>!y[e]||!y[e][t]?null:y[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:y[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 p({["list"+t]:{__args:{filters:n},data:{__args:{limit:1},...R(i)}}}))["list"+t].data[0]},async list(n,i){return(await p({["list"+t]:{__args:{filters:n},data:{...R(i)}}}))["list"+t].data}}};function Z(e){e="<~"+e+"~>";var t,n,i,r,o,f=String,g=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(g&n>>24,g&n>>16,g&n>>8,g&n);return function(w,F){for(var A=F;A>0;A--)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 g=0;g<t.length;g++)r[g]=t.charCodeAt(g);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")}}},k={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)},R=e=>P(e),p=async e=>{let t=S.jsonToGraphQLQuery(R(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 x(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={},A={};let b=0;Object.entries(t).forEach(([m,h])=>{if(h instanceof Array&&x(h)){o=!0;let C=0;h.forEach(v=>{v instanceof File&&(w[m]=new S.VariableType(m),F[b]=["variables."+m+"."+C],r.append(b.toString(),v),b++)}),A[m]="[Upload!]!"}else h instanceof File?(o=!0,w[m]=new S.VariableType(m),F[b]=["variables."+m],r.append(b.toString(),h),A[m]="Upload!",b++):h instanceof Object&&ee(h)?(o=!0,Object.entries(h).forEach(([C,v])=>{v instanceof File?(w[C]=new S.VariableType(C),F[b]=["variables."+C],r.append(b.toString(),v),b++):w[C]=h})):w[m]=h}),i[e].__args=w,i.__variables=A,o&&r.append("map",JSON.stringify(F))}Object.entries(R(n)).forEach(([w,F])=>{i[e][w]=F}),Object.entries(i[e]).length===0&&(i[e]=!0);let f=null;const g=S.jsonToGraphQLQuery({mutation:i});if(o?(r.append("operations",JSON.stringify({query:g})),f=await j().post(L(),r)):f=await j().post(L(),{query:g}),f.data.errors)throw new Error(f.data.errors[0].message);return f.data.data[e]};let U="/api/";const te=e=>{U=e},L=()=>U;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 p({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 _(e,t,n){if(t===a)return n;if(t===d)return e(n);if(t instanceof Array)return n.map(i=>_(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]=_(e,o.schema,n[r])}return i}}function J(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:J(a,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:J(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:J(K,e=>e.getClientExtensionResults())};function ce(e){return _(M,se,e)}function ue(e){return _(D,ae,e)}function fe(e){return _(M,oe,e)}function de(e){return _(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 p({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 p({webAuthnCreationOptions:!0}),t=ce({publicKey:e.webAuthnCreationOptions}),n=await ge(t);await u("webAuthnRegister",{registration:n.toJSON()})}const be=async e=>(await p({fsListFiles:{__args:{path:e},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}})).fsListFiles,me=async e=>(await p({fsListFolders:{__args:{path:e},name:!0,path:!0}})).fsListFolders,Fe=async e=>{let t=await p({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=k,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=p,s.resetPassword=$,s.sendMail=re,s.setApiUrl=te,s.setAxios=G,s.toQuery=R,s.updatePassword=W,s.uploadFile=ne,s.webauthnLogin=we,s.webauthnRegister=he,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
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,y={},I=(e,t)=>{y[e]={};for(const n of Object.entries(t)){const[i,r]=n;y[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)=>!y[e]||!y[e][t]?null:y[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:y[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 A=F;A>0;A--)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={},A={};let b=0;Object.entries(t).forEach(([g,m])=>{if(m instanceof Array&&k(m)){o=!0;let C=0;m.forEach(O=>{O instanceof File&&(w[g]=new R.VariableType(g),F[b]=["variables."+g+"."+C],r.append(b.toString(),O),b++)}),A[g]="[Upload!]!"}else m instanceof File?(o=!0,w[g]=new R.VariableType(g),F[b]=["variables."+g],r.append(b.toString(),m),A[g]="Upload!",b++):m instanceof Object&&ee(m)?(o=!0,w[g]===void 0&&(w[g]={}),Object.entries(m).forEach(([C,O])=>{O instanceof File?(w[g][C]=new R.VariableType(C),F[b]=["variables."+C],r.append(b.toString(),O),b++):w[g][C]=O})):w[g]=m}),i[e].__args=w,i.__variables=A,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 U="/api/";const te=e=>{U=e},L=()=>U;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 _(e,t,n){if(t===a)return n;if(t===d)return e(n);if(t instanceof Array)return n.map(i=>_(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]=_(e,o.schema,n[r])}return i}}function J(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:J(a,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:J(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:J(K,e=>e.getClientExtensionResults())};function ce(e){return _(M,se,e)}function ue(e){return _(D,ae,e)}function fe(e){return _(M,oe,e)}function de(e){return _(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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"