@hostlink/light 1.2.1 → 1.2.3

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
- }), ie = (e, t, r) => u("resetPassword", {
10
+ }), ae = (e, t, r) => u("resetPassword", {
11
11
  email: e,
12
12
  password: t,
13
13
  code: r
14
- }), ae = (e) => u("forgetPassword", {
14
+ }), ie = (e) => u("forgetPassword", {
15
15
  email: e
16
16
  });
17
17
  let O;
@@ -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,
@@ -37,16 +37,16 @@ const oe = (e) => {
37
37
  getRaw() {
38
38
  return n;
39
39
  },
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()];
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()];
42
42
  },
43
- getFormattedValue(a) {
44
- const l = this.getValue(a);
43
+ getFormattedValue(i) {
44
+ const l = this.getValue(i);
45
45
  return n.format ? n.format(l) : l;
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
  },
@@ -72,8 +72,8 @@ const oe = (e) => {
72
72
  fields(r) {
73
73
  let s = [];
74
74
  for (let n of r) {
75
- const a = L(t, n);
76
- a && s.push(a);
75
+ const i = L(t, n);
76
+ i && s.push(i);
77
77
  }
78
78
  return s;
79
79
  },
@@ -108,8 +108,8 @@ 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;
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)
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
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
114
  return function(p, m) {
115
115
  for (var _ = m; _ > 0; _--)
@@ -121,8 +121,8 @@ const v = (e = "") => {
121
121
  const n = new Uint8Array(t.length);
122
122
  for (let d = 0; d < t.length; d++)
123
123
  n[d] = t.charCodeAt(d);
124
- const a = new Blob([n], { type: s });
125
- return URL.createObjectURL(a);
124
+ const i = new Blob([n], { type: s });
125
+ return URL.createObjectURL(i);
126
126
  };
127
127
  return {
128
128
  getContent: () => t,
@@ -182,29 +182,29 @@ const u = async (e, t = null, r = []) => {
182
182
  [e]: {}
183
183
  };
184
184
  const n = new FormData();
185
- let a = !1;
185
+ let i = !1;
186
186
  if (t) {
187
187
  const p = {}, m = {}, _ = {};
188
- let w = 0;
189
- Object.entries(t).forEach(([h, g]) => {
190
- if (g instanceof Array && B(g)) {
191
- a = !0;
188
+ let g = 0;
189
+ Object.entries(t).forEach(([w, h]) => {
190
+ if (h instanceof Array && B(h)) {
191
+ i = !0;
192
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!]!";
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!]!";
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 ? (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));
201
201
  }
202
202
  Object.entries(S(r)).forEach(([p, m]) => {
203
203
  s[e][p] = m;
204
204
  }), Object.entries(s[e]).length === 0 && (s[e] = !0);
205
205
  let l = null;
206
206
  const d = N({ mutation: s });
207
- if (a ? (n.append("operations", JSON.stringify({
207
+ if (i ? (n.append("operations", JSON.stringify({
208
208
  query: d
209
209
  })), l = await E().post(q(), n)) : l = await E().post(q(), {
210
210
  query: d
@@ -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), a = 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), i = new Uint8Array(n);
242
242
  for (let l = 0; l < s.length; l++)
243
- a[l] = s.charCodeAt(l);
243
+ i[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 a of t)
250
- r += String.fromCharCode(a);
249
+ for (const i of t)
250
+ r += String.fromCharCode(i);
251
251
  return btoa(r).replace(/\+/g, "-").replace(
252
252
  /\//g,
253
253
  "_"
254
254
  ).replace(/=/g, "");
255
255
  }
256
- var i = "copy", f = "convert";
257
- function C(e, t, r) {
258
- if (t === i)
256
+ var a = "copy", f = "convert";
257
+ function A(e, t, r) {
258
+ if (t === a)
259
259
  return r;
260
260
  if (t === f)
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
- for (const [n, a] of Object.entries(t)) {
267
- if (a.derive) {
268
- const l = a.derive(r);
266
+ for (const [n, i] of Object.entries(t)) {
267
+ if (i.derive) {
268
+ const l = i.derive(r);
269
269
  l !== void 0 && (r[n] = l);
270
270
  }
271
271
  if (!(n in r)) {
272
- if (a.required)
272
+ if (i.required)
273
273
  throw new Error(`Missing key: ${n}`);
274
274
  continue;
275
275
  }
@@ -277,9 +277,9 @@ 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
- a.schema,
282
+ i.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(i),
309
+ type: o(a),
310
310
  id: o(f),
311
- transports: c(i)
311
+ transports: c(a)
312
312
  }, V = {
313
- appid: c(i),
314
- appidExclude: c(i),
315
- credProps: c(i)
313
+ appid: c(a),
314
+ appidExclude: c(a),
315
+ credProps: c(a)
316
316
  }, K = {
317
- appid: c(i),
318
- appidExclude: c(i),
319
- credProps: c(i)
317
+ appid: c(a),
318
+ appidExclude: c(a),
319
+ credProps: c(a)
320
320
  }, G = {
321
321
  publicKey: o({
322
- rp: o(i),
322
+ rp: o(a),
323
323
  user: o({
324
324
  id: o(f),
325
- name: o(i),
326
- displayName: o(i)
325
+ name: o(a),
326
+ displayName: o(a)
327
327
  }),
328
328
  challenge: o(f),
329
- pubKeyCredParams: o(i),
330
- timeout: c(i),
329
+ pubKeyCredParams: o(a),
330
+ timeout: c(a),
331
331
  excludeCredentials: c([D]),
332
- authenticatorSelection: c(i),
333
- attestation: c(i),
332
+ authenticatorSelection: c(a),
333
+ attestation: c(a),
334
334
  extensions: c(V)
335
335
  }),
336
- signal: c(i)
336
+ signal: c(a)
337
337
  }, W = {
338
- type: o(i),
339
- id: o(i),
338
+ type: o(a),
339
+ id: o(a),
340
340
  rawId: o(f),
341
- authenticatorAttachment: c(i),
341
+ authenticatorAttachment: c(a),
342
342
  response: o({
343
343
  clientDataJSON: o(f),
344
344
  attestationObject: o(f),
345
345
  transports: x(
346
- i,
346
+ a,
347
347
  (e) => {
348
348
  var t;
349
349
  return ((t = e.getTransports) == null ? void 0 : t.call(e)) || [];
@@ -355,21 +355,21 @@ var D = {
355
355
  (e) => e.getClientExtensionResults()
356
356
  )
357
357
  }, $ = {
358
- mediation: c(i),
358
+ mediation: c(a),
359
359
  publicKey: o({
360
360
  challenge: o(f),
361
- timeout: c(i),
362
- rpId: c(i),
361
+ timeout: c(a),
362
+ rpId: c(a),
363
363
  allowCredentials: c([D]),
364
- userVerification: c(i),
364
+ userVerification: c(a),
365
365
  extensions: c(V)
366
366
  }),
367
- signal: c(i)
367
+ signal: c(a)
368
368
  }, z = {
369
- type: o(i),
370
- id: o(i),
369
+ type: o(a),
370
+ id: o(a),
371
371
  rawId: o(f),
372
- authenticatorAttachment: c(i),
372
+ authenticatorAttachment: c(a),
373
373
  response: o({
374
374
  clientDataJSON: o(f),
375
375
  authenticatorData: o(f),
@@ -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
@@ -489,7 +489,7 @@ export {
489
489
  de as File,
490
490
  le as defineModel,
491
491
  v as file,
492
- ae as forgetPassword,
492
+ ie as forgetPassword,
493
493
  Oe as fsCreateFolder,
494
494
  Ae as fsDeleteFile,
495
495
  Se as fsDeleteFolder,
@@ -511,7 +511,7 @@ export {
511
511
  fe as model,
512
512
  u as mutation,
513
513
  b as query,
514
- ie as resetPassword,
514
+ ae as resetPassword,
515
515
  we as sendMail,
516
516
  pe as setApiUrl,
517
517
  oe as setAxios,
@@ -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 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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -8,6 +8,11 @@
8
8
  "main": "./dist/light.umd.cjs",
9
9
  "module": "./dist/light.js",
10
10
  "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/light.js"
14
+ }
15
+ },
11
16
  "scripts": {
12
17
  "dev": "vite --host",
13
18
  "build": "tsc && vite build",