@hostlink/light 1.2.3 → 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
@@ -7,11 +7,11 @@ const re = (e, t, r = "") => u("login", {
7
7
  }), ne = () => u("logout"), se = (e, t) => u("updatePassword", {
8
8
  old_password: e,
9
9
  new_password: t
10
- }), ae = (e, t, r) => u("resetPassword", {
10
+ }), ie = (e, t, r) => u("resetPassword", {
11
11
  email: e,
12
12
  password: t,
13
13
  code: r
14
- }), ie = (e) => u("forgetPassword", {
14
+ }), ae = (e) => u("forgetPassword", {
15
15
  email: e
16
16
  });
17
17
  let O;
@@ -37,11 +37,11 @@ const oe = (e) => {
37
37
  getRaw() {
38
38
  return n;
39
39
  },
40
- getValue(i) {
41
- return n.field && typeof n.field == "function" ? n.field(i) : n.field && typeof n.field == "string" ? i[n.field] : i[this.getName()];
40
+ getValue(a) {
41
+ return n.field && typeof n.field == "function" ? n.field(a) : n.field && typeof n.field == "string" ? a[n.field] : a[this.getName()];
42
42
  },
43
- getFormattedValue(i) {
44
- const l = this.getValue(i);
43
+ getFormattedValue(a) {
44
+ const l = this.getValue(a);
45
45
  return n.format ? n.format(l) : l;
46
46
  }
47
47
  });
@@ -72,8 +72,8 @@ const oe = (e) => {
72
72
  fields(r) {
73
73
  let s = [];
74
74
  for (let n of r) {
75
- const i = L(t, n);
76
- i && s.push(i);
75
+ const a = L(t, n);
76
+ a && s.push(a);
77
77
  }
78
78
  return s;
79
79
  },
@@ -108,21 +108,21 @@ const oe = (e) => {
108
108
  };
109
109
  function M(e) {
110
110
  e = "<~" + e + "~>";
111
- var t, r, s, n, i, l = String, d = 255;
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, i = e.length; i > 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) {
111
+ var t, r, s, n, a, l = String, p = 255;
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(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);
124
- const i = new Blob([n], { type: s });
125
- return URL.createObjectURL(i);
122
+ for (let p = 0; p < t.length; p++)
123
+ n[p] = t.charCodeAt(p);
124
+ const a = new Blob([n], { type: s });
125
+ return URL.createObjectURL(a);
126
126
  };
127
127
  return {
128
128
  getContent: () => t,
@@ -182,32 +182,32 @@ const u = async (e, t = null, r = []) => {
182
182
  [e]: {}
183
183
  };
184
184
  const n = new FormData();
185
- let i = !1;
185
+ let a = !1;
186
186
  if (t) {
187
- const p = {}, m = {}, _ = {};
188
- let g = 0;
189
- Object.entries(t).forEach(([w, h]) => {
187
+ const g = {}, m = {}, _ = {};
188
+ let w = 0;
189
+ Object.entries(t).forEach(([f, h]) => {
190
190
  if (h instanceof Array && B(h)) {
191
- i = !0;
192
- let y = 0;
193
- h.forEach((F) => {
194
- F instanceof File && (p[w] = new R(w), m[g] = ["variables." + w + "." + y], n.append(g.toString(), F), g++);
195
- }), _[w] = "[Upload!]!";
191
+ a = !0;
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
- h instanceof File ? (i = !0, p[w] = new R(w), m[g] = ["variables." + w], n.append(g.toString(), h), _[w] = "Upload!", g++) : h instanceof Object && Q(h) ? (i = !0, Object.entries(h).forEach(([y, F]) => {
198
- F instanceof File ? (p[y] = new R(y), m[g] = ["variables." + y], n.append(g.toString(), F), g++) : p[y] = F;
199
- })) : p[w] = h;
200
- }), s[e].__args = p, s.__variables = _, i && 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 });
207
- if (i ? (n.append("operations", JSON.stringify({
208
- query: d
206
+ const p = N({ mutation: s });
207
+ if (a ? (n.append("operations", JSON.stringify({
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];
@@ -238,38 +238,38 @@ const we = (e, t, r) => u("sendMail", {
238
238
  }
239
239
  })).config;
240
240
  function P(e) {
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), i = new Uint8Array(n);
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
- i[l] = s.charCodeAt(l);
243
+ a[l] = s.charCodeAt(l);
244
244
  return n;
245
245
  }
246
246
  function U(e) {
247
247
  const t = new Uint8Array(e);
248
248
  let r = "";
249
- for (const i of t)
250
- r += String.fromCharCode(i);
249
+ for (const a of t)
250
+ r += String.fromCharCode(a);
251
251
  return btoa(r).replace(/\+/g, "-").replace(
252
252
  /\//g,
253
253
  "_"
254
254
  ).replace(/=/g, "");
255
255
  }
256
- var a = "copy", f = "convert";
256
+ var i = "copy", d = "convert";
257
257
  function A(e, t, r) {
258
- if (t === a)
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
263
  return r.map((s) => A(e, t[0], s));
264
264
  if (t instanceof Object) {
265
265
  const s = {};
266
- for (const [n, i] of Object.entries(t)) {
267
- if (i.derive) {
268
- const l = i.derive(r);
266
+ for (const [n, a] of Object.entries(t)) {
267
+ if (a.derive) {
268
+ const l = a.derive(r);
269
269
  l !== void 0 && (r[n] = l);
270
270
  }
271
271
  if (!(n in r)) {
272
- if (i.required)
272
+ if (a.required)
273
273
  throw new Error(`Missing key: ${n}`);
274
274
  continue;
275
275
  }
@@ -279,7 +279,7 @@ function A(e, t, r) {
279
279
  }
280
280
  s[n] = A(
281
281
  e,
282
- i.schema,
282
+ a.schema,
283
283
  r[n]
284
284
  );
285
285
  }
@@ -306,44 +306,44 @@ function c(e) {
306
306
  };
307
307
  }
308
308
  var D = {
309
- type: o(a),
310
- id: o(f),
311
- transports: c(a)
309
+ type: o(i),
310
+ id: o(d),
311
+ transports: c(i)
312
312
  }, V = {
313
- appid: c(a),
314
- appidExclude: c(a),
315
- credProps: c(a)
313
+ appid: c(i),
314
+ appidExclude: c(i),
315
+ credProps: c(i)
316
316
  }, K = {
317
- appid: c(a),
318
- appidExclude: c(a),
319
- credProps: c(a)
317
+ appid: c(i),
318
+ appidExclude: c(i),
319
+ credProps: c(i)
320
320
  }, G = {
321
321
  publicKey: o({
322
- rp: o(a),
322
+ rp: o(i),
323
323
  user: o({
324
- id: o(f),
325
- name: o(a),
326
- displayName: o(a)
324
+ id: o(d),
325
+ name: o(i),
326
+ displayName: o(i)
327
327
  }),
328
- challenge: o(f),
329
- pubKeyCredParams: o(a),
330
- timeout: c(a),
328
+ challenge: o(d),
329
+ pubKeyCredParams: o(i),
330
+ timeout: c(i),
331
331
  excludeCredentials: c([D]),
332
- authenticatorSelection: c(a),
333
- attestation: c(a),
332
+ authenticatorSelection: c(i),
333
+ attestation: c(i),
334
334
  extensions: c(V)
335
335
  }),
336
- signal: c(a)
336
+ signal: c(i)
337
337
  }, W = {
338
- type: o(a),
339
- id: o(a),
340
- rawId: o(f),
341
- authenticatorAttachment: c(a),
338
+ type: o(i),
339
+ id: o(i),
340
+ rawId: o(d),
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
- a,
346
+ i,
347
347
  (e) => {
348
348
  var t;
349
349
  return ((t = e.getTransports) == null ? void 0 : t.call(e)) || [];
@@ -355,26 +355,26 @@ var D = {
355
355
  (e) => e.getClientExtensionResults()
356
356
  )
357
357
  }, $ = {
358
- mediation: c(a),
358
+ mediation: c(i),
359
359
  publicKey: o({
360
- challenge: o(f),
361
- timeout: c(a),
362
- rpId: c(a),
360
+ challenge: o(d),
361
+ timeout: c(i),
362
+ rpId: c(i),
363
363
  allowCredentials: c([D]),
364
- userVerification: c(a),
364
+ userVerification: c(i),
365
365
  extensions: c(V)
366
366
  }),
367
- signal: c(a)
367
+ signal: c(i)
368
368
  }, z = {
369
- type: o(a),
370
- id: o(a),
371
- rawId: o(f),
372
- authenticatorAttachment: c(a),
369
+ type: o(i),
370
+ id: o(i),
371
+ rawId: o(d),
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,
@@ -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: {
@@ -489,14 +489,14 @@ export {
489
489
  de as File,
490
490
  le as defineModel,
491
491
  v as file,
492
- ie as forgetPassword,
492
+ ae as forgetPassword,
493
493
  Oe as fsCreateFolder,
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,
@@ -511,7 +511,7 @@ export {
511
511
  fe as model,
512
512
  u as mutation,
513
513
  b as query,
514
- ae as resetPassword,
514
+ ie as resetPassword,
515
515
  we as sendMail,
516
516
  pe as setApiUrl,
517
517
  oe as setAxios,
@@ -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 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},...v(i)}}}))["list"+t].data[0]},async list(n,i){return(await p({["list"+t]:{__args:{filters:n},data:{...v(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)},v=e=>P(e),p=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 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 h=0;Object.entries(t).forEach(([b,m])=>{if(m instanceof Array&&x(m)){o=!0;let C=0;m.forEach(O=>{O instanceof File&&(w[b]=new R.VariableType(b),F[h]=["variables."+b+"."+C],r.append(h.toString(),O),h++)}),A[b]="[Upload!]!"}else m instanceof File?(o=!0,w[b]=new R.VariableType(b),F[h]=["variables."+b],r.append(h.toString(),m),A[b]="Upload!",h++):m instanceof Object&&ee(m)?(o=!0,Object.entries(m).forEach(([C,O])=>{O instanceof File?(w[C]=new R.VariableType(C),F[h]=["variables."+C],r.append(h.toString(),O),h++):w[C]=O})):w[b]=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 g=R.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=v,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.3",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"