@hostlink/light 3.2.2 → 3.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/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './model';
13
13
  export * from './file';
14
14
  export * from './mail';
15
15
  export * from './fileUtils';
16
+ export * as fs from './filesystem';
16
17
  export { default as query } from './query';
17
18
  export { default as mutation } from './mutation';
18
19
  export { default as toQuery } from './toQuery';
package/dist/light.js CHANGED
@@ -1,21 +1,21 @@
1
- import { jsonToGraphQLQuery as q, VariableType as F } from "json-to-graphql-query";
1
+ import { jsonToGraphQLQuery as q, VariableType as b } from "json-to-graphql-query";
2
2
  import U from "collect.js";
3
3
  import H from "axios";
4
- function P(t) {
4
+ function k(t) {
5
5
  if (t === null || typeof t != "object")
6
6
  return !1;
7
7
  const e = Object.getPrototypeOf(t);
8
8
  return e !== null && e !== Object.prototype && Object.getPrototypeOf(e) !== null || Symbol.iterator in t ? !1 : Symbol.toStringTag in t ? Object.prototype.toString.call(t) === "[object Module]" : !0;
9
9
  }
10
- function v(t, e, r = ".", s) {
11
- if (!P(e))
12
- return v(t, {}, r, s);
10
+ function E(t, e, r = ".", s) {
11
+ if (!k(e))
12
+ return E(t, {}, r, s);
13
13
  const i = Object.assign({}, e);
14
14
  for (const u in t) {
15
15
  if (u === "__proto__" || u === "constructor")
16
16
  continue;
17
17
  const l = t[u];
18
- l != null && (s && s(i, u, l, r) || (Array.isArray(l) && Array.isArray(i[u]) ? i[u] = [...l, ...i[u]] : P(l) && P(i[u]) ? i[u] = v(
18
+ l != null && (s && s(i, u, l, r) || (Array.isArray(l) && Array.isArray(i[u]) ? i[u] = [...l, ...i[u]] : k(l) && k(i[u]) ? i[u] = E(
19
19
  l,
20
20
  i[u],
21
21
  (r ? `${r}.` : "") + u.toString(),
@@ -27,25 +27,25 @@ function v(t, e, r = ".", s) {
27
27
  function X(t) {
28
28
  return (...e) => (
29
29
  // eslint-disable-next-line unicorn/no-array-reduce
30
- e.reduce((r, s) => v(r, s, "", t), {})
30
+ e.reduce((r, s) => E(r, s, "", t), {})
31
31
  );
32
32
  }
33
33
  const A = X();
34
- let j = null;
34
+ let S = null;
35
35
  const Y = (t) => {
36
- j = t;
37
- }, B = () => {
38
- if (!j)
36
+ S = t;
37
+ }, M = () => {
38
+ if (!S)
39
39
  throw new Error("Api client not initialized. Call setApiClient() first.");
40
- return j;
41
- }, Jt = () => j;
40
+ return S;
41
+ }, Yt = () => S;
42
42
  function D(t) {
43
43
  for (let e = 0; e < t.length; e++)
44
44
  if (t[e] instanceof File)
45
45
  return !0;
46
46
  return !1;
47
47
  }
48
- function M(t) {
48
+ function N(t) {
49
49
  for (let e in t)
50
50
  if (t[e] instanceof File || t[e] instanceof Array && D(t[e]))
51
51
  return !0;
@@ -53,17 +53,17 @@ function M(t) {
53
53
  }
54
54
  function Z(t) {
55
55
  t = "<~" + t + "~>";
56
- var e, r, s, i, u, l = String, f = 255;
57
- for (t.slice(0, 2) === "<~" && t.slice(-2), t = t.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), e = "uuuuu".slice(t.length % 5 || 5), t += e, s = [], i = 0, u = t.length; u > i; i += 5) r = 52200625 * (t.charCodeAt(i) - 33) + 614125 * (t.charCodeAt(i + 1) - 33) + 7225 * (t.charCodeAt(i + 2) - 33) + 85 * (t.charCodeAt(i + 3) - 33) + (t.charCodeAt(i + 4) - 33), s.push(f & r >> 24, f & r >> 16, f & r >> 8, f & r);
56
+ var e, r, s, i, u, l = String, p = 255;
57
+ for (t.slice(0, 2) === "<~" && t.slice(-2), t = t.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), e = "uuuuu".slice(t.length % 5 || 5), t += e, s = [], i = 0, u = t.length; u > i; i += 5) r = 52200625 * (t.charCodeAt(i) - 33) + 614125 * (t.charCodeAt(i + 1) - 33) + 7225 * (t.charCodeAt(i + 2) - 33) + 85 * (t.charCodeAt(i + 3) - 33) + (t.charCodeAt(i + 4) - 33), s.push(p & r >> 24, p & r >> 16, p & r >> 8, p & r);
58
58
  return (function(n, o) {
59
59
  for (var a = o; a > 0; a--) n.pop();
60
60
  })(s, e.length), l.fromCharCode.apply(l, s);
61
61
  }
62
- const N = (t = "") => {
62
+ const B = (t = "") => {
63
63
  const e = t, r = (s = "application/octet-stream") => {
64
64
  const i = new Uint8Array(e.length);
65
- for (let f = 0; f < e.length; f++)
66
- i[f] = e.charCodeAt(f);
65
+ for (let p = 0; p < e.length; p++)
66
+ i[p] = e.charCodeAt(p);
67
67
  const u = new Blob([i], { type: s });
68
68
  return URL.createObjectURL(u);
69
69
  };
@@ -78,29 +78,29 @@ const N = (t = "") => {
78
78
  window.open(r(s), "_blank");
79
79
  }
80
80
  };
81
- }, Lt = (t) => N(atob(t)), Qt = (t) => N(Z(t));
81
+ }, Zt = (t) => B(atob(t)), Vt = (t) => B(Z(t));
82
82
  function J(t, e, r, s, i) {
83
83
  if (!(!t || typeof t != "object"))
84
84
  for (let u in t) {
85
85
  const l = t[u];
86
86
  if (l && typeof l == "object") {
87
87
  if ("__args" in l) {
88
- const f = l.__args, n = {};
89
- Object.entries(f).forEach(([o, a]) => {
88
+ const p = l.__args, n = {};
89
+ Object.entries(p).forEach(([o, a]) => {
90
90
  if (a instanceof Array && D(a)) {
91
- n[o] = new F(o);
91
+ n[o] = new b(o);
92
92
  let c = 0;
93
93
  a.forEach((h) => {
94
94
  h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + c), s.append(i.current.toString(), h), i.current++, c++);
95
95
  }), e[o] = "[Upload!]!";
96
- } else a instanceof File ? (n[o] = new F(o), r[i.current] = ["variables." + o], s.append(i.current.toString(), a), e[o] = "Upload!", i.current++) : a instanceof Object && M(a) ? (n[o] = {}, Object.entries(a).forEach(([c, h]) => {
96
+ } else a instanceof File ? (n[o] = new b(o), r[i.current] = ["variables." + o], s.append(i.current.toString(), a), e[o] = "Upload!", i.current++) : a instanceof Object && N(a) ? (n[o] = {}, Object.entries(a).forEach(([c, h]) => {
97
97
  if (h instanceof Array && D(h)) {
98
- n[o][c] = new F(c);
98
+ n[o][c] = new b(c);
99
99
  let d = 0;
100
100
  h.forEach((g) => {
101
101
  g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + c + "." + d), s.append(i.current.toString(), g), i.current++, d++);
102
102
  }), e[c] = "[Upload!]!";
103
- } else h instanceof File ? (n[o][c] = new F(c), r[i.current] = ["variables." + c], s.append(i.current.toString(), h), e[c] = "Upload!", i.current++) : n[o][c] = h;
103
+ } else h instanceof File ? (n[o][c] = new b(c), r[i.current] = ["variables." + c], s.append(i.current.toString(), h), e[c] = "Upload!", i.current++) : n[o][c] = h;
104
104
  })) : a != null && (n[o] = a);
105
105
  }), l.__args = n;
106
106
  }
@@ -109,7 +109,7 @@ function J(t, e, r, s, i) {
109
109
  }
110
110
  }
111
111
  const y = async (t) => {
112
- const { axios: e } = B(), r = t, s = new FormData();
112
+ const { axios: e } = M(), r = t, s = new FormData();
113
113
  let i = !1;
114
114
  const u = {}, l = {};
115
115
  J(r, u, l, s, { current: 0 }), i = Object.keys(u).length > 0, i && (r.__variables = u);
@@ -123,9 +123,9 @@ const y = async (t) => {
123
123
  throw new Error(n.data.errors[0].message);
124
124
  return n.data.data;
125
125
  };
126
- function k(t, e) {
126
+ function j(t, e) {
127
127
  let r, s = [], i, u;
128
- const l = (n) => !n || typeof n != "object" ? !1 : Object.values(n).some((o) => o && typeof o == "object" && Object.keys(o).some((a) => a.startsWith("_"))), f = () => s.length === 0 ? (s.unshift({}), s[0]) : (l(s[0]) && s.unshift({}), s[0]);
128
+ const l = (n) => !n || typeof n != "object" ? !1 : Object.values(n).some((o) => o && typeof o == "object" && Object.keys(o).some((a) => a.startsWith("_"))), p = () => s.length === 0 ? (s.unshift({}), s[0]) : (l(s[0]) && s.unshift({}), s[0]);
129
129
  return {
130
130
  first() {
131
131
  return this.fetchFirst();
@@ -171,7 +171,7 @@ function k(t, e) {
171
171
  // where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
172
172
  where(n, o, a) {
173
173
  const c = (h, d, g) => {
174
- const b = {
174
+ const m = {
175
175
  ">": "_gt",
176
176
  "<": "_lt",
177
177
  ">=": "_gte",
@@ -180,12 +180,12 @@ function k(t, e) {
180
180
  in: "_in",
181
181
  contains: "_contains"
182
182
  }[d];
183
- b && s.push({ [h]: { [b]: g } });
183
+ m && s.push({ [h]: { [m]: g } });
184
184
  };
185
185
  if (a !== void 0)
186
186
  c(n, String(o), a);
187
187
  else {
188
- const h = f(), d = A(h, { [n]: o });
188
+ const h = p(), d = A(h, { [n]: o });
189
189
  s[0] = d;
190
190
  }
191
191
  return this;
@@ -194,7 +194,7 @@ function k(t, e) {
194
194
  // If the same field is used multiple times, it merges them into an array
195
195
  whereContains(n, o) {
196
196
  if (n && typeof n == "string") {
197
- const a = f(), c = { _contains: o };
197
+ const a = p(), c = { _contains: o };
198
198
  a[n] ? Array.isArray(a[n]) ? a[n].push(c) : a[n] = [a[n], c] : a[n] = [c], s[0] = a;
199
199
  }
200
200
  return this;
@@ -204,7 +204,7 @@ function k(t, e) {
204
204
  // If the same field is used multiple times, it merges them into an array
205
205
  whereIn(n, o) {
206
206
  if (n && typeof n == "string" && Array.isArray(o)) {
207
- const a = f(), c = { _in: o };
207
+ const a = p(), c = { _in: o };
208
208
  a[n] ? Array.isArray(a[n]) ? a[n].push(c) : a[n] = [a[n], c] : a[n] = [c], s[0] = a;
209
209
  }
210
210
  return this;
@@ -212,7 +212,7 @@ function k(t, e) {
212
212
  // whereBetween adds a _between filter for a specific field
213
213
  whereBetween(n, o, a) {
214
214
  if (n && typeof n == "string") {
215
- const c = f(), h = { _between: [o, a] };
215
+ const c = p(), h = { _between: [o, a] };
216
216
  c[n] ? Array.isArray(c[n]) ? c[n].push(h) : c[n] = [c[n], h] : c[n] = h, s[0] = c;
217
217
  }
218
218
  return this;
@@ -242,13 +242,13 @@ function k(t, e) {
242
242
  key: !0,
243
243
  name: !0
244
244
  }), u) {
245
- const m = u.split(".");
246
- let b = g;
247
- for (let w = m.length - 1; w >= 0; w--)
248
- b = {
249
- [m[w]]: b
245
+ const F = u.split(".");
246
+ let m = g;
247
+ for (let w = F.length - 1; w >= 0; w--)
248
+ m = {
249
+ [F[w]]: m
250
250
  };
251
- return b;
251
+ return m;
252
252
  }
253
253
  return {
254
254
  [`list${t}`]: g
@@ -359,8 +359,8 @@ U().macro("whereContains", function(t, e) {
359
359
  _.prototype.fetchData = async function() {
360
360
  try {
361
361
  if (this._batchData) {
362
- const f = this._batchData;
363
- return this.meta = f.meta, U(f.data);
362
+ const p = this._batchData;
363
+ return this.meta = p.meta, U(p.data);
364
364
  }
365
365
  let t = {
366
366
  meta: {
@@ -372,16 +372,16 @@ _.prototype.fetchData = async function() {
372
372
  t.__args = this.buildArgs(), t.data = this.fields, this.already_limit && (t.data.__args = t.data.__args || {}, t.data.__args.limit = this.limit), this.already_offset && (t.data.__args = t.data.__args || {}, t.data.__args.offset = this.offset);
373
373
  const e = this.data_path.split(".");
374
374
  let r = {}, s = r, i = e[e.length - 1];
375
- for (const f of e) {
376
- if (f === i) {
377
- s[f] = t;
375
+ for (const p of e) {
376
+ if (p === i) {
377
+ s[p] = t;
378
378
  break;
379
379
  }
380
- s[f] = {}, s = s[f];
380
+ s[p] = {}, s = s[p];
381
381
  }
382
382
  let l = await y(r);
383
- for (const f of e)
384
- l = l[f];
383
+ for (const p of e)
384
+ l = l[p];
385
385
  return this.meta = l.meta, U(l.data);
386
386
  } catch (t) {
387
387
  throw console.error("Error fetching collection data:", t), t;
@@ -504,29 +504,29 @@ const L = (t, e) => {
504
504
  },
505
505
  gqlFields(u) {
506
506
  let l = {};
507
- for (const f of u)
508
- if (typeof f == "string") {
509
- const n = i(f);
510
- n && (l = A(l, n.gqlField ? typeof n.gqlField == "string" ? { [n.gqlField]: !0 } : n.gqlField : { [n.name || f]: !0 }));
511
- } else typeof f == "object" && (l = A(l, f));
507
+ for (const p of u)
508
+ if (typeof p == "string") {
509
+ const n = i(p);
510
+ n && (l = A(l, n.gqlField ? typeof n.gqlField == "string" ? { [n.gqlField]: !0 } : n.gqlField : { [n.name || p]: !0 }));
511
+ } else typeof p == "object" && (l = A(l, p));
512
512
  return l;
513
513
  },
514
514
  update(u, l) {
515
- return p({
515
+ return f({
516
516
  ["update" + t]: {
517
517
  __args: { id: u, data: l }
518
518
  }
519
- }).then((f) => f["update" + t]);
519
+ }).then((p) => p["update" + t]);
520
520
  },
521
521
  async delete(u) {
522
- return p({
522
+ return f({
523
523
  ["delete" + t]: {
524
524
  __args: { id: u }
525
525
  }
526
526
  }).then((l) => l["delete" + t]);
527
527
  },
528
528
  add(u) {
529
- return p({
529
+ return f({
530
530
  ["add" + t]: {
531
531
  __args: { data: u }
532
532
  }
@@ -534,31 +534,31 @@ const L = (t, e) => {
534
534
  },
535
535
  fields(u) {
536
536
  let l = [];
537
- for (let f of u) {
538
- const n = i(f);
537
+ for (let p of u) {
538
+ const n = i(p);
539
539
  n && l.push(n);
540
540
  }
541
541
  return l;
542
542
  },
543
543
  async get(u, l) {
544
- const f = L(t, qt(l));
544
+ const p = L(t, Wt(l));
545
545
  for (const [n, o] of Object.entries(u))
546
- f.where(n, "==", o);
547
- return await f.first();
546
+ p.where(n, "==", o);
547
+ return await p.first();
548
548
  },
549
549
  list(u) {
550
550
  let l = u;
551
- const f = {};
551
+ const p = {};
552
552
  Object.entries(u).forEach(([a]) => {
553
- r[a] && (f[a] = r[a], r[a].gqlField && (delete l[a], l = A(l, r[a].gqlField)), r[a].gql && (delete l[a], l = A(l, r[a].gql)));
553
+ r[a] && (p[a] = r[a], r[a].gqlField && (delete l[a], l = A(l, r[a].gqlField)), r[a].gql && (delete l[a], l = A(l, r[a].gql)));
554
554
  });
555
- const n = k(t, l).dataPath(s), o = n.fetch.bind(n);
555
+ const n = j(t, l).dataPath(s), o = n.fetch.bind(n);
556
556
  return {
557
557
  ...n,
558
558
  async fetch() {
559
559
  return (await o()).map((c) => {
560
560
  const h = { ...c };
561
- return Object.entries(f).forEach(([d, g]) => {
561
+ return Object.entries(p).forEach(([d, g]) => {
562
562
  g.field && typeof g.field == "function" && (h[d] = g.field(c[d], c));
563
563
  }), h;
564
564
  });
@@ -567,23 +567,23 @@ const L = (t, e) => {
567
567
  const c = await n.fetchFirst.bind(n)();
568
568
  if (!c) return c;
569
569
  const h = { ...c };
570
- return Object.entries(f).forEach(([d, g]) => {
570
+ return Object.entries(p).forEach(([d, g]) => {
571
571
  g.field && typeof g.field == "function" && (h[d] = g.field(c[d], c));
572
572
  }), h;
573
573
  }
574
574
  };
575
575
  }
576
576
  };
577
- }, O = {}, Q = (t, e) => {
577
+ }, O = {}, R = (t, e) => {
578
578
  const r = x(t, e);
579
579
  return O[t] = r, r;
580
- }, E = (t) => O[t] ? O[t] : Q(t, {}), Tt = (t) => !!O[t], $t = () => Object.keys(O), Rt = () => {
580
+ }, P = (t) => O[t] ? O[t] : R(t, {}), It = (t) => !!O[t], Kt = () => Object.keys(O), xt = () => {
581
581
  Object.keys(O).forEach((t) => delete O[t]);
582
- }, Gt = (t) => {
582
+ }, te = (t) => {
583
583
  Object.entries(t).forEach(([e, r]) => {
584
- Q(e, r);
584
+ R(e, r);
585
585
  });
586
- }, Wt = () => y({
586
+ }, ee = () => y({
587
587
  app: {
588
588
  permissions: !0
589
589
  }
@@ -596,7 +596,7 @@ const L = (t, e) => {
596
596
  }
597
597
  }), e = t.auth.webAuthnRequestOptions, r = PublicKeyCredential.parseRequestOptionsFromJSON(e);
598
598
  return await navigator.credentials.get({ publicKey: r });
599
- }, $ = async () => {
599
+ }, Q = async () => {
600
600
  const { app: t } = await y({
601
601
  app: {
602
602
  auth: {
@@ -607,7 +607,7 @@ const L = (t, e) => {
607
607
  return await navigator.credentials.create({ publicKey: e });
608
608
  }, tt = async () => {
609
609
  const t = await T();
610
- return await p({
610
+ return await f({
611
611
  webAuthnAssertion: {
612
612
  __args: {
613
613
  assertion: t.toJSON()
@@ -615,8 +615,8 @@ const L = (t, e) => {
615
615
  }
616
616
  }).then((e) => e.webAuthnAssertion);
617
617
  }, et = async () => {
618
- const t = await $();
619
- return await p({
618
+ const t = await Q();
619
+ return await f({
620
620
  webAuthnRegister: {
621
621
  __args: {
622
622
  registration: t.toJSON()
@@ -626,10 +626,10 @@ const L = (t, e) => {
626
626
  }, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
627
627
  __proto__: null,
628
628
  assertion: T,
629
- attestation: $,
629
+ attestation: Q,
630
630
  login: tt,
631
631
  register: et
632
- }, Symbol.toStringTag, { value: "Module" })), st = (t = W) => y({ my: t }).then((e) => e.my), nt = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((s) => s.login), ot = () => p({ logout: !0 }).then((t) => t.logout), it = (t, e, r) => p({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((s) => s.changeExpiredPassword), at = (t, e) => p({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), ct = (t, e, r) => p({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((s) => s.resetPassword), lt = (t, e) => p({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), ut = (t, e) => p({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), ht = (t) => y({
632
+ }, Symbol.toStringTag, { value: "Module" })), st = (t = W) => y({ my: t }).then((e) => e.my), nt = (t, e, r = "") => f({ login: { __args: { username: t, password: e, code: r } } }).then((s) => s.login), ot = () => f({ logout: !0 }).then((t) => t.logout), it = (t, e, r) => f({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((s) => s.changeExpiredPassword), at = (t, e) => f({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), ct = (t, e, r) => f({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((s) => s.resetPassword), lt = (t, e) => f({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), ut = (t, e) => f({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), ht = (t) => y({
633
633
  my: {
634
634
  granted: {
635
635
  __args: {
@@ -637,7 +637,7 @@ const L = (t, e) => {
637
637
  }
638
638
  }
639
639
  }
640
- }).then((e) => e.my.granted), ft = (t) => y({
640
+ }).then((e) => e.my.granted), pt = (t) => y({
641
641
  my: {
642
642
  grantedRights: {
643
643
  __args: {
@@ -645,23 +645,23 @@ const L = (t, e) => {
645
645
  }
646
646
  }
647
647
  }
648
- }).then((e) => e.my.grantedRights), pt = {
648
+ }).then((e) => e.my.grantedRights), ft = {
649
649
  getCurrentUser: st,
650
650
  webAuthn: rt,
651
651
  google: {
652
- unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
653
- login: (t) => p({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
654
- register: (t) => p({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
652
+ unlink: () => f({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
653
+ login: (t) => f({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
654
+ register: (t) => f({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
655
655
  },
656
656
  facebook: {
657
- unlink: () => p({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
658
- login: (t) => p({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
659
- register: (t) => p({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
657
+ unlink: () => f({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
658
+ login: (t) => f({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
659
+ register: (t) => f({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
660
660
  },
661
661
  microsoft: {
662
- unlink: () => p({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
663
- login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
664
- register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
662
+ unlink: () => f({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
663
+ login: (t) => f({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
664
+ register: (t) => f({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
665
665
  },
666
666
  login: nt,
667
667
  logout: ot,
@@ -670,15 +670,15 @@ const L = (t, e) => {
670
670
  resetPassword: ct,
671
671
  forgetPassword: lt,
672
672
  verifyCode: ut,
673
- grantedRights: ft,
673
+ grantedRights: pt,
674
674
  isGranted: ht
675
- }, R = {
675
+ }, $ = {
676
676
  name: !0,
677
677
  path: !0,
678
678
  size: !0,
679
679
  mime: !0,
680
680
  url: !0
681
- }, dt = (t, e, r = R) => y({
681
+ }, dt = (t, e, r = $) => y({
682
682
  app: {
683
683
  drive: {
684
684
  __args: { index: t },
@@ -703,7 +703,7 @@ const L = (t, e) => {
703
703
  }
704
704
  }
705
705
  }).then((r) => r.app.drive?.file?.base64Content), _t = (t) => ({
706
- list: (e, r = R) => dt(t, e, r),
706
+ list: (e, r = $) => dt(t, e, r),
707
707
  get: (e, r = {
708
708
  name: !0,
709
709
  path: !0,
@@ -748,10 +748,10 @@ const L = (t, e) => {
748
748
  throw new Error(`File not found or cannot read content: ${e}`);
749
749
  return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
750
750
  },
751
- write: (e, r) => p({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((s) => s.lightDriveWriteFile),
752
- delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
753
- rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((s) => s.lightDriveRenameFile),
754
- move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((s) => s.lightDriveMoveFile)
751
+ write: (e, r) => f({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((s) => s.lightDriveWriteFile),
752
+ delete: (e) => f({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
753
+ rename: (e, r) => f({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((s) => s.lightDriveRenameFile),
754
+ move: (e, r) => f({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((s) => s.lightDriveMoveFile)
755
755
  }), G = {
756
756
  name: !0,
757
757
  path: !0
@@ -767,17 +767,17 @@ const L = (t, e) => {
767
767
  }
768
768
  }).then((s) => s.app.drive.folders), wt = (t) => ({
769
769
  list: (e, r = G) => yt(t, e, r),
770
- create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
771
- delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
772
- rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((s) => s.lightDriveRenameFolder)
773
- }), zt = () => y({
770
+ create: (e) => f({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
771
+ delete: (e) => f({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
772
+ rename: (e, r) => f({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((s) => s.lightDriveRenameFolder)
773
+ }), re = () => y({
774
774
  app: {
775
775
  drives: {
776
776
  index: !0,
777
777
  name: !0
778
778
  }
779
779
  }
780
- }).then((t) => t.app.drives), bt = (t) => {
780
+ }).then((t) => t.app.drives), mt = (t) => {
781
781
  const e = _t(t), r = wt(t);
782
782
  return {
783
783
  folders: r,
@@ -793,7 +793,7 @@ const L = (t, e) => {
793
793
  createFolder: r.create,
794
794
  deleteFolder: r.delete,
795
795
  renameFolder: r.rename,
796
- uploadTempFile: (s) => p({
796
+ uploadTempFile: (s) => f({
797
797
  lightDriveUploadTempFile: {
798
798
  __args: { index: t, file: s },
799
799
  name: !0,
@@ -809,22 +809,22 @@ const L = (t, e) => {
809
809
  first_name: !0,
810
810
  last_name: !0,
811
811
  status: !0
812
- }, mt = (t) => p({
812
+ }, Ft = (t) => f({
813
813
  addUser: {
814
814
  __args: t
815
815
  }
816
- }).then((e) => e.addUser), Ft = (t) => p({
816
+ }).then((e) => e.addUser), bt = (t) => f({
817
817
  deleteUser: {
818
818
  __args: { id: t }
819
819
  }
820
- }).then((e) => e.deleteUser), At = (t = W) => k("Users", t).dataPath("app.listUser").fetch(), Ot = (t, e) => p({
820
+ }).then((e) => e.deleteUser), At = (t = W) => j("Users", t).dataPath("app.listUser").fetch(), Ot = (t, e) => f({
821
821
  updateUser: {
822
822
  __args: { id: t, data: e }
823
823
  }
824
824
  }).then((r) => r.updateUser), Dt = {
825
825
  list: At,
826
- create: mt,
827
- delete: Ft,
826
+ create: Ft,
827
+ delete: bt,
828
828
  update: Ot
829
829
  }, Ct = (t) => y({
830
830
  app: {
@@ -840,13 +840,13 @@ const L = (t, e) => {
840
840
  }
841
841
  }
842
842
  }
843
- }).then((e) => e.app.listConfig.data[0]?.value), jt = {
843
+ }).then((e) => e.app.listConfig.data[0]?.value), St = {
844
844
  name: !0
845
- }, kt = (t = jt) => y({
845
+ }, jt = (t = St) => y({
846
846
  app: {
847
847
  roles: t
848
848
  }
849
- }).then((e) => e.app.roles), Pt = (t, e) => p({
849
+ }).then((e) => e.app.roles), kt = (t, e) => f({
850
850
  addRole: {
851
851
  __args: {
852
852
  data: {
@@ -855,14 +855,14 @@ const L = (t, e) => {
855
855
  }
856
856
  }
857
857
  }
858
- }).then((r) => r.addRole), Et = (t) => p({
858
+ }).then((r) => r.addRole), Pt = (t) => f({
859
859
  deleteRole: {
860
860
  __args: { name: t }
861
861
  }
862
862
  }).then((e) => e.deleteRole), Ut = () => ({
863
- list: kt,
864
- create: Pt,
865
- delete: Et
863
+ list: jt,
864
+ create: kt,
865
+ delete: Pt
866
866
  });
867
867
  function z(t, e, r, s, i) {
868
868
  if (!(!t || typeof t != "object"))
@@ -870,22 +870,22 @@ function z(t, e, r, s, i) {
870
870
  const l = t[u];
871
871
  if (l && typeof l == "object") {
872
872
  if ("__args" in l) {
873
- const f = l.__args, n = {};
874
- Object.entries(f).forEach(([o, a]) => {
873
+ const p = l.__args, n = {};
874
+ Object.entries(p).forEach(([o, a]) => {
875
875
  if (a instanceof Array && D(a)) {
876
- n[o] = new F(o);
876
+ n[o] = new b(o);
877
877
  let c = 0;
878
878
  a.forEach((h) => {
879
879
  h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + c), s.append(i.current.toString(), h), i.current++, c++);
880
880
  }), e[o] = "[Upload!]!";
881
- } else a instanceof File ? (n[o] = new F(o), r[i.current] = ["variables." + o], s.append(i.current.toString(), a), e[o] = "Upload!", i.current++) : a instanceof Object && M(a) ? (n[o] = {}, Object.entries(a).forEach(([c, h]) => {
881
+ } else a instanceof File ? (n[o] = new b(o), r[i.current] = ["variables." + o], s.append(i.current.toString(), a), e[o] = "Upload!", i.current++) : a instanceof Object && N(a) ? (n[o] = {}, Object.entries(a).forEach(([c, h]) => {
882
882
  if (h instanceof Array && D(h)) {
883
- n[o][c] = new F(c);
883
+ n[o][c] = new b(c);
884
884
  let d = 0;
885
885
  h.forEach((g) => {
886
886
  g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + c + "." + d), s.append(i.current.toString(), g), i.current++, d++);
887
887
  }), e[c] = "[Upload!]!";
888
- } else h instanceof File ? (n[o][c] = new F(c), r[i.current] = ["variables." + c], s.append(i.current.toString(), h), e[c] = "Upload!", i.current++) : n[o][c] = h;
888
+ } else h instanceof File ? (n[o][c] = new b(c), r[i.current] = ["variables." + c], s.append(i.current.toString(), h), e[c] = "Upload!", i.current++) : n[o][c] = h;
889
889
  })) : a != null && (n[o] = a);
890
890
  }), l.__args = n;
891
891
  }
@@ -893,8 +893,8 @@ function z(t, e, r, s, i) {
893
893
  }
894
894
  }
895
895
  }
896
- const p = async (t) => {
897
- const { axios: e } = B(), r = t, s = new FormData();
896
+ const f = async (t) => {
897
+ const { axios: e } = M(), r = t, s = new FormData();
898
898
  let i = !1;
899
899
  const u = {}, l = {};
900
900
  z(r, u, l, s, { current: 0 }), i = Object.keys(u).length > 0, i && (r.__variables = u);
@@ -907,12 +907,108 @@ const p = async (t) => {
907
907
  }), n.data.errors)
908
908
  throw new Error(n.data.errors[0].message);
909
909
  return n.data.data;
910
- }, vt = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((s) => s.sendMail), St = {
911
- send: vt
912
- }, S = (t) => {
910
+ }, Et = (t, e, r) => f({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((s) => s.sendMail), vt = {
911
+ send: Et
912
+ }, qt = (t) => f({
913
+ lightFSCreateFolder: {
914
+ __args: { location: t }
915
+ }
916
+ }).then((e) => e.lightFSCreateFolder), Mt = (t) => f({
917
+ lightFSDeleteFolder: {
918
+ __args: { location: t }
919
+ }
920
+ }).then((e) => e.lightFSDeleteFolder), Nt = (t, e) => f({
921
+ lightFSRenameFolder: {
922
+ __args: { location: t, newName: e }
923
+ }
924
+ }).then((r) => r.lightFSRenameFolder), Bt = (t, e) => f({
925
+ lightFSRenameFile: {
926
+ __args: { location: t, newName: e }
927
+ }
928
+ }).then((r) => r.lightFSRenameFile), Jt = (t, e) => f({
929
+ lightFSWriteFile: {
930
+ __args: { location: t, content: e }
931
+ }
932
+ }).then((r) => r.lightFSWriteFile), Lt = (t, e) => f({
933
+ lightFSUploadFile: {
934
+ __args: { location: t, file: e }
935
+ }
936
+ }).then((r) => r.lightFSUploadFile), Rt = (t) => f({
937
+ lightFSDeleteFile: {
938
+ __args: { location: t }
939
+ }
940
+ }).then((e) => e.lightFSDeleteFile), Tt = (t, e) => f({
941
+ lightFSMove: {
942
+ __args: { from: t, to: e }
943
+ }
944
+ }).then((r) => r.lightFSMove), Qt = (t) => y({
945
+ app: {
946
+ fs: {
947
+ exists: {
948
+ __args: { location: t }
949
+ }
950
+ }
951
+ }
952
+ }).then((e) => e.app.fs.exists), $t = (t) => y({
953
+ app: {
954
+ fs: {
955
+ node: {
956
+ __args: { location: t },
957
+ __typename: !0,
958
+ __on: [{
959
+ __typeName: "Folder",
960
+ name: !0,
961
+ location: !0,
962
+ path: !0,
963
+ children: {
964
+ __typename: !0,
965
+ name: !0,
966
+ lastModified: !0,
967
+ location: !0,
968
+ path: !0,
969
+ __on: [{
970
+ __typeName: "File",
971
+ size: !0,
972
+ mimeType: !0
973
+ }, {
974
+ __typeName: "Folder"
975
+ }]
976
+ }
977
+ }]
978
+ }
979
+ }
980
+ }
981
+ }).then((r) => r.app.fs.node), Gt = (t) => y({
982
+ app: {
983
+ fs: {
984
+ node: {
985
+ __args: { location: t },
986
+ __on: [
987
+ {
988
+ __typeName: "File",
989
+ content: !0
990
+ }
991
+ ]
992
+ }
993
+ }
994
+ }
995
+ }).then((e) => e.app.fs.node.content), se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
996
+ __proto__: null,
997
+ createFolder: qt,
998
+ deleteFile: Rt,
999
+ deleteFolder: Mt,
1000
+ exists: Qt,
1001
+ list: $t,
1002
+ move: Tt,
1003
+ read: Gt,
1004
+ renameFile: Bt,
1005
+ renameFolder: Nt,
1006
+ uploadFile: Lt,
1007
+ writeFile: Jt
1008
+ }, Symbol.toStringTag, { value: "Module" })), v = (t) => {
913
1009
  let e = {};
914
1010
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
915
- Object.entries(S(r)).forEach(([s, i]) => {
1011
+ Object.entries(v(r)).forEach(([s, i]) => {
916
1012
  e[s] = i;
917
1013
  });
918
1014
  }), e) : (Object.entries(t).forEach(([r, s]) => {
@@ -924,9 +1020,9 @@ const p = async (t) => {
924
1020
  e[r] = s;
925
1021
  return;
926
1022
  }
927
- e[r] = S(s);
1023
+ e[r] = v(s);
928
1024
  }), e);
929
- }, qt = (t) => S(t), Ht = (t) => {
1025
+ }, Wt = (t) => v(t), ne = (t) => {
930
1026
  const e = typeof window > "u";
931
1027
  let r = [];
932
1028
  const s = H.create({
@@ -946,13 +1042,13 @@ const p = async (t) => {
946
1042
  const c = o.config;
947
1043
  return i ? new Promise((h, d) => {
948
1044
  u.push({ resolve: h, reject: d });
949
- }).then(() => s(c)).catch((h) => Promise.reject(h)) : (i = !0, f().then(() => (i = !1, l(null), s(c))).catch((h) => (i = !1, l(h), Promise.reject(h))));
1045
+ }).then(() => s(c)).catch((h) => Promise.reject(h)) : (i = !0, p().then(() => (i = !1, l(null), s(c))).catch((h) => (i = !1, l(h), Promise.reject(h))));
950
1046
  }
951
1047
  return o;
952
1048
  },
953
1049
  (o) => Promise.reject(o)
954
1050
  );
955
- function f() {
1051
+ function p() {
956
1052
  return s.post("/refresh_token");
957
1053
  }
958
1054
  e && (s.interceptors.request.use((o) => (o.withCredentials = !0, r.length > 0 && (o.headers.Cookie = r.join("; ")), o)), s.interceptors.response.use((o) => {
@@ -972,101 +1068,102 @@ const p = async (t) => {
972
1068
  post: s.post,
973
1069
  baseURL: t,
974
1070
  axios: s,
975
- auth: pt,
976
- mutation: p,
1071
+ auth: ft,
1072
+ mutation: f,
977
1073
  query: y,
978
1074
  config: Ct,
979
- mail: St,
1075
+ mail: vt,
980
1076
  users: Dt,
981
1077
  model(o) {
982
- return E(o);
1078
+ return P(o);
983
1079
  },
984
1080
  roles: Ut(),
985
1081
  collect: (o, a) => {
986
1082
  const c = L(o, a);
987
- return c.data_path = E(o).getDataPath(), c;
1083
+ return c.data_path = P(o).getDataPath(), c;
988
1084
  },
989
- list: (o, a) => k(o, a).dataPath(E(o).getDataPath()),
990
- drive: bt,
1085
+ list: (o, a) => j(o, a).dataPath(P(o).getDataPath()),
1086
+ drive: mt,
991
1087
  async collects(o) {
992
1088
  const a = {}, c = {};
993
1089
  for (const d in o) {
994
1090
  const g = o[d].getQueryPayload();
995
1091
  c[d] = g.data_path, a[d] = {};
996
- const m = g.data_path.split(".");
997
- let b = m[m.length - 1], w = a[d];
998
- for (const C of m) {
999
- if (C === b) {
1092
+ const F = g.data_path.split(".");
1093
+ let m = F[F.length - 1], w = a[d];
1094
+ for (const C of F) {
1095
+ if (C === m) {
1000
1096
  w[C] = g.query;
1001
1097
  break;
1002
1098
  }
1003
1099
  w[C] = w[C] || {};
1004
1100
  }
1005
- a[d].__aliasFor = m[0];
1101
+ a[d].__aliasFor = F[0];
1006
1102
  }
1007
1103
  const h = await y(a);
1008
1104
  for (const d in o) {
1009
1105
  const g = c[d].split(".");
1010
- let m = g[g.length - 1], b = h[d];
1106
+ let F = g[g.length - 1], m = h[d];
1011
1107
  for (const w of g) {
1012
- if (w === m) {
1108
+ if (w === F) {
1013
1109
  o[d]._batchData = h[d][w];
1014
1110
  break;
1015
1111
  }
1016
- b[w] = b[w] || {};
1112
+ m[w] = m[w] || {};
1017
1113
  }
1018
1114
  }
1019
1115
  return o;
1020
1116
  }
1021
1117
  };
1022
1118
  return Y(n), n;
1023
- }, Xt = k;
1119
+ }, oe = j;
1024
1120
  export {
1025
1121
  D as arrayHasFile,
1026
- pt as auth,
1122
+ ft as auth,
1027
1123
  it as changeExpiredPassword,
1028
- Rt as clearModels,
1029
- Ht as createClient,
1124
+ xt as clearModels,
1125
+ ne as createClient,
1030
1126
  L as createCollection,
1031
- Lt as createFileFromBase64,
1032
- Qt as createFileFromBase85,
1033
- N as createFileFromString,
1034
- k as createList,
1035
- Pt as createRole,
1036
- mt as createUser,
1127
+ Zt as createFileFromBase64,
1128
+ Vt as createFileFromBase85,
1129
+ B as createFileFromString,
1130
+ j as createList,
1131
+ kt as createRole,
1132
+ Ft as createUser,
1037
1133
  W as defaultUserFields,
1038
- Q as defineModel,
1039
- Gt as defineModels,
1040
- Et as deleteRole,
1041
- Ft as deleteUser,
1134
+ R as defineModel,
1135
+ te as defineModels,
1136
+ Pt as deleteRole,
1137
+ bt as deleteUser,
1042
1138
  lt as forgetPassword,
1043
- B as getApiClient,
1044
- Jt as getApiClientOptional,
1139
+ se as fs,
1140
+ M as getApiClient,
1141
+ Yt as getApiClientOptional,
1045
1142
  Ct as getConfig,
1046
1143
  st as getCurrentUser,
1047
- bt as getDrive,
1048
- ft as getGrantedRights,
1049
- E as getModel,
1050
- Tt as hasModel,
1144
+ mt as getDrive,
1145
+ pt as getGrantedRights,
1146
+ P as getModel,
1147
+ It as hasModel,
1051
1148
  ht as isGranted,
1052
- Xt as list,
1053
- zt as listDrives,
1149
+ oe as list,
1150
+ re as listDrives,
1054
1151
  dt as listFiles,
1055
1152
  yt as listFolders,
1056
- $t as listModels,
1057
- Wt as listPermissions,
1058
- kt as listRoles,
1153
+ Kt as listModels,
1154
+ ee as listPermissions,
1155
+ jt as listRoles,
1059
1156
  At as listUsers,
1060
1157
  nt as login,
1061
1158
  ot as logout,
1062
- p as mutation,
1063
- M as objectHasFile,
1159
+ f as mutation,
1160
+ N as objectHasFile,
1064
1161
  y as query,
1065
1162
  gt as readFileAsBase64,
1066
1163
  ct as resetPassword,
1067
- vt as sendMail,
1164
+ Et as sendMail,
1068
1165
  Y as setApiClient,
1069
- qt as toQuery,
1166
+ Wt as toQuery,
1070
1167
  at as updatePassword,
1071
1168
  Ot as updateUser,
1072
1169
  ut as verifyCode,
@@ -1 +1 @@
1
- (function(h,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("json-to-graphql-query"),require("collect.js"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","collect.js","axios"],b):(h=typeof globalThis<"u"?globalThis:h||self,b(h.light={},h.jsonToGraphqlQuery,h.collect,h.axios))})(this,(function(h,b,E,bt){"use strict";function v(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.iterator in t?!1:Symbol.toStringTag in t?Object.prototype.toString.call(t)==="[object Module]":!0}function S(t,e,r=".",s){if(!v(e))return S(t,{},r,s);const o=Object.assign({},e);for(const u in t){if(u==="__proto__"||u==="constructor")continue;const l=t[u];l!=null&&(s&&s(o,u,l,r)||(Array.isArray(l)&&Array.isArray(o[u])?o[u]=[...l,...o[u]]:v(l)&&v(o[u])?o[u]=S(l,o[u],(r?`${r}.`:"")+u.toString(),s):o[u]=l))}return o}function mt(t){return(...e)=>e.reduce((r,s)=>S(r,s,"",t),{})}const C=mt();let j=null;const T=t=>{j=t},M=()=>{if(!j)throw new Error("Api client not initialized. Call setApiClient() first.");return j},Ft=()=>j;function D(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function B(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&D(t[e]))return!0;return!1}function At(t){t="<~"+t+"~>";var e,r,s,o,u,l=String,p=255;for(t.slice(0,2)==="<~"&&t.slice(-2),t=t.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),e="uuuuu".slice(t.length%5||5),t+=e,s=[],o=0,u=t.length;u>o;o+=5)r=52200625*(t.charCodeAt(o)-33)+614125*(t.charCodeAt(o+1)-33)+7225*(t.charCodeAt(o+2)-33)+85*(t.charCodeAt(o+3)-33)+(t.charCodeAt(o+4)-33),s.push(p&r>>24,p&r>>16,p&r>>8,p&r);return(function(n,i){for(var a=i;a>0;a--)n.pop()})(s,e.length),l.fromCharCode.apply(l,s)}const q=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const o=new Uint8Array(e.length);for(let p=0;p<e.length;p++)o[p]=e.charCodeAt(p);const u=new Blob([o],{type:s});return URL.createObjectURL(u)};return{getContent:()=>e,getURL:r,download:s=>{const o=document.createElement("a");o.download=s,o.href=r(),document.body.appendChild(o),o.click(),document.body.removeChild(o)},open:s=>{window.open(r(s),"_blank")}}},Ct=t=>q(atob(t)),Ot=t=>q(At(t));function $(t,e,r,s,o){if(!(!t||typeof t!="object"))for(let u in t){const l=t[u];if(l&&typeof l=="object"){if("__args"in l){const p=l.__args,n={};Object.entries(p).forEach(([i,a])=>{if(a instanceof Array&&D(a)){n[i]=new b.VariableType(i);let c=0;a.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+c),s.append(o.current.toString(),f),o.current++,c++)}),e[i]="[Upload!]!"}else a instanceof File?(n[i]=new b.VariableType(i),r[o.current]=["variables."+i],s.append(o.current.toString(),a),e[i]="Upload!",o.current++):a instanceof Object&&B(a)?(n[i]={},Object.entries(a).forEach(([c,f])=>{if(f instanceof Array&&D(f)){n[i][c]=new b.VariableType(c);let g=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+c+"."+g),s.append(o.current.toString(),_),o.current++,g++)}),e[c]="[Upload!]!"}else f instanceof File?(n[i][c]=new b.VariableType(c),r[o.current]=["variables."+c],s.append(o.current.toString(),f),e[c]="Upload!",o.current++):n[i][c]=f})):a!=null&&(n[i]=a)}),l.__args=n}$(l,e,r,s,o)}}}const w=async t=>{const{axios:e}=M(),r=t,s=new FormData;let o=!1;const u={},l={};$(r,u,l,s,{current:0}),o=Object.keys(u).length>0,o&&(r.__variables=u);let n=null;const i={query:r},a=b.jsonToGraphQLQuery(i);if(o?(s.append("map",JSON.stringify(l)),s.append("operations",JSON.stringify({query:a})),n=await e.post("",s)):n=await e.post("",{query:a}),n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};function P(t,e){let r,s=[],o,u;const l=n=>!n||typeof n!="object"?!1:Object.values(n).some(i=>i&&typeof i=="object"&&Object.keys(i).some(a=>a.startsWith("_"))),p=()=>s.length===0?(s.unshift({}),s[0]):(l(s[0])&&s.unshift({}),s[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const i=await this.limit(1).fetch();return Array.isArray(i)&&i.length>0?i[0]:null},async fetchWithMeta(){let i=await w(this.toQuery(!0));if(u){const a=u.split(".");for(const c of a)i=i[c];return i}return i[`list${t}`]},async fetch(){let i=await w(this.toQuery());if(u){const a=u.split(".");for(const c of a)i=i[c];return i.data}return i[`list${t}`].data},dataPath(n){return n&&typeof n=="string"&&(u=n),this},sort(n){return n&&typeof n=="string"&&(o=n),this},filters(n){return n&&typeof n=="object"&&(s=[n]),this},where(n,i,a){const c=(f,g,_)=>{const F={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[g];F&&s.push({[f]:{[F]:_}})};if(a!==void 0)c(n,String(i),a);else{const f=p(),g=C(f,{[n]:i});s[0]=g}return this},whereContains(n,i){if(n&&typeof n=="string"){const a=p(),c={_contains:i};a[n]?Array.isArray(a[n])?a[n].push(c):a[n]=[a[n],c]:a[n]=[c],s[0]=a}return this},whereIn(n,i){if(n&&typeof n=="string"&&Array.isArray(i)){const a=p(),c={_in:i};a[n]?Array.isArray(a[n])?a[n].push(c):a[n]=[a[n],c]:a[n]=[c],s[0]=a}return this},whereBetween(n,i,a){if(n&&typeof n=="string"){const c=p(),f={_between:[i,a]};c[n]?Array.isArray(c[n])?c[n].push(f):c[n]=[c[n],f]:c[n]=f,s[0]=c}return this},limit(n){return typeof n=="number"&&Number.isFinite(n)&&(r=C(r||{},{limit:n})),this},offset(n){return typeof n=="number"&&Number.isFinite(n)&&(r=C(r||{},{offset:n})),this},toQuery(n=!1){let i;const a=s.length>0&&Object.keys(s[0]||{}).length>0,c=a?1:0,f=s.length>c;a&&f?i=s:f?i=s.slice(c):a&&(i=s[0]);const g=C(o?{sort:o}:{},i?{filters:i}:{}),_={data:{...e}};if(r&&(_.data.__args=r),Object.keys(g).length>0&&(_.__args=g),n&&(_.meta={total:!0,key:!0,name:!0}),u){const A=u.split(".");let F=_;for(let m=A.length-1;m>=0;m--)F={[A[m]]:F};return F}return{[`list${t}`]:_}}}}const Dt="list",Pt=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap","sort"],jt=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition"];class y{_batchData=null;data_path="";filters;steps;fields;already_limit=!1;already_offset=!1;limit=null;offset=null;_sort=null;_sortDesc=!1;meta={};constructor(e){this.filters={},this.steps=[],this.fields=e}}y.prototype.getQueryPayload=function(){let t={meta:{total:!0,key:!0,name:!0}};return t.__args=this.buildArgs(),t.data=this.fields,t.data.__args=t.data.__args||{},this.limit&&(t.data.__args.limit=this.limit),this.offset&&(t.data.__args.offset=this.offset),{data_path:this.data_path,query:t,steps:this.steps}},y.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},y.prototype.buildArgs=function(){let t={};return Object.keys(this.filters).length>0&&(t.filters=this.filters),this._sort&&(t.sort=this._sort,this._sortDesc&&(t.sort+=":desc")),t},y.prototype.clone=function(){const t=Object.create(this);return t.steps=JSON.parse(JSON.stringify(this.steps)),t.filters=JSON.parse(JSON.stringify(this.filters)),t.fields=JSON.parse(JSON.stringify(this.fields)),t},E().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),y.prototype.fetchData=async function(){try{if(this._batchData){const p=this._batchData;return this.meta=p.meta,E(p.data)}let t={meta:{total:!0,key:!0,name:!0}};t.__args=this.buildArgs(),t.data=this.fields,this.already_limit&&(t.data.__args=t.data.__args||{},t.data.__args.limit=this.limit),this.already_offset&&(t.data.__args=t.data.__args||{},t.data.__args.offset=this.offset);const e=this.data_path.split(".");let r={},s=r,o=e[e.length-1];for(const p of e){if(p===o){s[p]=t;break}s[p]={},s=s[p]}let l=await w(r);for(const p of e)l=l[p];return this.meta=l.meta,E(l.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},y.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},y.prototype.all=async function(){return(await this.processData()).all()};for(const t of Pt)y.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of jt)y.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};y.prototype.average=y.prototype.avg,y.prototype.first=async function(){return this.take(1),(await this.processData()).first()},y.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},y.prototype.where=function(...t){const e=this._handleBatchData("where",t);if(e)return e;if(t.length===2)this.filters[t[0]]=t[1];else if(t.length===3){const r=t[0],s=t[1],o=t[2];switch(s){case"==":this.filters[r]=o;break;case"<":this.filters[r]={lt:o};break;case"<=":this.filters[r]={lte:o};break;case">":this.filters[r]={gt:o};break;case">=":this.filters[r]={gte:o};break;case"!==":this.filters[r]={ne:o};break;default:throw new Error(`Unsupported operator: ${s}`)}}return this},y.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},y.prototype.forPage=function(t,e){return t=Math.max(1,t),this.already_limit?(this.steps.push({type:"forPage",args:[t,e]}),this):(this.limit=e,this.offset=(t-1)*e,this.already_limit=!0,this.already_offset=!0,this)},y.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},y.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},y.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},y.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},y.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},y.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},y.prototype.skip=function(t){if(t<0)throw new Error("Offset must be non-negative");return this.already_offset&&this.steps.push({type:"skip",args:[t]}),this.offset=t,this.already_offset=!0,this},y.prototype.take=function(t){if(t<0)throw new Error("Length must be non-negative");return this.already_limit?(this.steps.push({type:"take",args:[t]}),this):(this.limit=t,this.already_limit=!0,this)},y.prototype.splice=function(t,e){return this.steps.push({type:"splice",args:[t,e]}),this.offset=t,this.limit=e,this.already_limit=!0,this.already_offset=!0,this};const N=(t,e)=>{const r=new y(e);return r.data_path=Dt+t,r},kt=(t,e={})=>{const r=e;let s="list"+t;const o=u=>r[u]?r[u]:null;return{field:o,$fields:r,setDataPath(u){return s=u,s},getDataPath(){return s},gqlFields(u){let l={};for(const p of u)if(typeof p=="string"){const n=o(p);n&&(l=C(l,n.gqlField?typeof n.gqlField=="string"?{[n.gqlField]:!0}:n.gqlField:{[n.name||p]:!0}))}else typeof p=="object"&&(l=C(l,p));return l},update(u,l){return d({["update"+t]:{__args:{id:u,data:l}}}).then(p=>p["update"+t])},async delete(u){return d({["delete"+t]:{__args:{id:u}}}).then(l=>l["delete"+t])},add(u){return d({["add"+t]:{__args:{data:u}}}).then(l=>l["add"+t])},fields(u){let l=[];for(let p of u){const n=o(p);n&&l.push(n)}return l},async get(u,l){const p=N(t,wt(l));for(const[n,i]of Object.entries(u))p.where(n,"==",i);return await p.first()},list(u){let l=u;const p={};Object.entries(u).forEach(([a])=>{r[a]&&(p[a]=r[a],r[a].gqlField&&(delete l[a],l=C(l,r[a].gqlField)),r[a].gql&&(delete l[a],l=C(l,r[a].gql)))});const n=P(t,l).dataPath(s),i=n.fetch.bind(n);return{...n,async fetch(){return(await i()).map(c=>{const f={...c};return Object.entries(p).forEach(([g,_])=>{_.field&&typeof _.field=="function"&&(f[g]=_.field(c[g],c))}),f})},async fetchFirst(){const c=await n.fetchFirst.bind(n)();if(!c)return c;const f={...c};return Object.entries(p).forEach(([g,_])=>{_.field&&typeof _.field=="function"&&(f[g]=_.field(c[g],c))}),f}}}}},O={},L=(t,e)=>{const r=kt(t,e);return O[t]=r,r},k=t=>O[t]?O[t]:L(t,{}),Ut=t=>!!O[t],Et=()=>Object.keys(O),vt=()=>{Object.keys(O).forEach(t=>delete O[t])},St=t=>{Object.entries(t).forEach(([e,r])=>{L(e,r)})},Mt=()=>w({app:{permissions:!0}}).then(t=>t.app.permissions),Q=async()=>{const{app:t}=await w({app:{auth:{webAuthnRequestOptions:!0}}}),e=t.auth.webAuthnRequestOptions,r=PublicKeyCredential.parseRequestOptionsFromJSON(e);return await navigator.credentials.get({publicKey:r})},W=async()=>{const{app:t}=await w({app:{auth:{webAuthnCreationOptions:!0}}}),e=PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:e})},z=Object.freeze(Object.defineProperty({__proto__:null,assertion:Q,attestation:W,login:async()=>{const t=await Q();return await d({webAuthnAssertion:{__args:{assertion:t.toJSON()}}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await W();return await d({webAuthnRegister:{__args:{registration:t.toJSON()}}}).then(e=>e.webAuthnRegister)}},Symbol.toStringTag,{value:"Module"})),G=(t=J)=>w({my:t}).then(e=>e.my),H=(t,e,r="")=>d({login:{__args:{username:t,password:e,code:r}}}).then(s=>s.login),V=()=>d({logout:!0}).then(t=>t.logout),X=(t,e,r)=>d({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(s=>s.changeExpiredPassword),Y=(t,e)=>d({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),Z=(t,e,r)=>d({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(s=>s.resetPassword),I=(t,e)=>d({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),K=(t,e)=>d({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),x=t=>w({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),tt=t=>w({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),et={getCurrentUser:G,webAuthn:z,google:{unlink:()=>d({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>d({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>d({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>d({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>d({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>d({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>d({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>d({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>d({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:H,logout:V,changeExpiredPassword:X,updatePassword:Y,resetPassword:Z,forgetPassword:I,verifyCode:K,grantedRights:tt,isGranted:x},rt={name:!0,path:!0,size:!0,mime:!0,url:!0},st=(t,e,r=rt)=>w({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(s=>s.app.drive.files),nt=(t,e)=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),Bt=t=>({list:(e,r=rt)=>st(t,e,r),get:(e,r={name:!0,path:!0,size:!0,mime:!0,url:!0})=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},...r}}}}).then(s=>s.app.drive.file),readFileAsBase64(e){return nt(t,e)},read:async e=>{let r=await w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}});if(!r.app.drive.file||!r.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${e}`);return typeof window<"u"&&window.atob?window.atob(r.app.drive.file.base64Content):r.app.drive.file.base64Content},write:(e,r)=>d({lightDriveWriteFile:{__args:{index:t,path:e,content:r}}}).then(s=>s.lightDriveWriteFile),delete:e=>d({lightDriveDeleteFile:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFile),rename:(e,r)=>d({lightDriveRenameFile:{__args:{index:t,path:e,name:r}}}).then(s=>s.lightDriveRenameFile),move:(e,r)=>d({lightDriveMoveFile:{__args:{index:t,source:e,destination:r}}}).then(s=>s.lightDriveMoveFile)}),it={name:!0,path:!0},ot=(t,e,r=it)=>w({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(s=>s.app.drive.folders),qt=t=>({list:(e,r=it)=>ot(t,e,r),create:e=>d({lightDriveCreateFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveCreateFolder),delete:e=>d({lightDriveDeleteFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFolder),rename:(e,r)=>d({lightDriveRenameFolder:{__args:{index:t,path:e,name:r}}}).then(s=>s.lightDriveRenameFolder)}),Nt=()=>w({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),at=t=>{const e=Bt(t),r=qt(t);return{folders:r,files:e,listFiles:e.list,getFile:e.get,readFile:e.read,writeFile:e.write,deleteFile:e.delete,renameFile:e.rename,moveFile:e.move,listFolders:r.list,createFolder:r.create,deleteFolder:r.delete,renameFolder:r.rename,uploadTempFile:s=>d({lightDriveUploadTempFile:{__args:{index:t,file:s},name:!0,path:!0,size:!0,mime:!0}}).then(o=>o.lightDriveUploadTempFile)}},J={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},ct=t=>d({addUser:{__args:t}}).then(e=>e.addUser),lt=t=>d({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),ut=(t=J)=>P("Users",t).dataPath("app.listUser").fetch(),ht=(t,e)=>d({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),Lt={list:ut,create:ct,delete:lt,update:ht},ft=t=>w({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]?.value),Jt={name:!0},pt=(t=Jt)=>w({app:{roles:t}}).then(e=>e.app.roles),dt=(t,e)=>d({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),gt=t=>d({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),Rt=()=>({list:pt,create:dt,delete:gt});function _t(t,e,r,s,o){if(!(!t||typeof t!="object"))for(let u in t){const l=t[u];if(l&&typeof l=="object"){if("__args"in l){const p=l.__args,n={};Object.entries(p).forEach(([i,a])=>{if(a instanceof Array&&D(a)){n[i]=new b.VariableType(i);let c=0;a.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+c),s.append(o.current.toString(),f),o.current++,c++)}),e[i]="[Upload!]!"}else a instanceof File?(n[i]=new b.VariableType(i),r[o.current]=["variables."+i],s.append(o.current.toString(),a),e[i]="Upload!",o.current++):a instanceof Object&&B(a)?(n[i]={},Object.entries(a).forEach(([c,f])=>{if(f instanceof Array&&D(f)){n[i][c]=new b.VariableType(c);let g=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+c+"."+g),s.append(o.current.toString(),_),o.current++,g++)}),e[c]="[Upload!]!"}else f instanceof File?(n[i][c]=new b.VariableType(c),r[o.current]=["variables."+c],s.append(o.current.toString(),f),e[c]="Upload!",o.current++):n[i][c]=f})):a!=null&&(n[i]=a)}),l.__args=n}_t(l,e,r,s,o)}}}const d=async t=>{const{axios:e}=M(),r=t,s=new FormData;let o=!1;const u={},l={};_t(r,u,l,s,{current:0}),o=Object.keys(u).length>0,o&&(r.__variables=u);let n=null;const i={mutation:r},a=b.jsonToGraphQLQuery(i);if(o?(s.append("map",JSON.stringify(l)),s.append("operations",JSON.stringify({query:a})),n=await e.post("",s)):n=await e.post("",{query:a}),n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data},yt=(t,e,r)=>d({sendMail:{__args:{email:t,subject:e,message:r}}}).then(s=>s.sendMail),Tt={send:yt},R=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(R(r)).forEach(([s,o])=>{e[s]=o})}),e):(Object.entries(t).forEach(([r,s])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=s;return}if(typeof s=="boolean"){e[r]=s;return}e[r]=R(s)}),e)},wt=t=>R(t),$t=t=>{const e=typeof window>"u";let r=[];const s=bt.create({baseURL:t,withCredentials:!0});let o=!1,u=[];const l=(i,a=null)=>{u.forEach(c=>{i?c.reject(i):c.resolve(a)}),u=[]};s.interceptors.response.use(i=>{const a=i.data.errors;if(a&&a.some(c=>c.extensions?.code==="TOKEN_EXPIRED")){const c=i.config;return o?new Promise((f,g)=>{u.push({resolve:f,reject:g})}).then(()=>s(c)).catch(f=>Promise.reject(f)):(o=!0,p().then(()=>(o=!1,l(null),s(c))).catch(f=>(o=!1,l(f),Promise.reject(f))))}return i},i=>Promise.reject(i));function p(){return s.post("/refresh_token")}e&&(s.interceptors.request.use(i=>(i.withCredentials=!0,r.length>0&&(i.headers.Cookie=r.join("; ")),i)),s.interceptors.response.use(i=>{if(i.headers["set-cookie"]){const a=i.headers["set-cookie"].map(f=>f.split(";")[0]),c=new Map;r.forEach(f=>{const g=f.split("=")[0];c.set(g,f)}),a.forEach(f=>{const g=f.split("=")[0];c.set(g,f)}),r=Array.from(c.values())}return i}));const n={post:s.post,baseURL:t,axios:s,auth:et,mutation:d,query:w,config:ft,mail:Tt,users:Lt,model(i){return k(i)},roles:Rt(),collect:(i,a)=>{const c=N(i,a);return c.data_path=k(i).getDataPath(),c},list:(i,a)=>P(i,a).dataPath(k(i).getDataPath()),drive:at,async collects(i){const a={},c={};for(const g in i){const _=i[g].getQueryPayload();c[g]=_.data_path,a[g]={};const A=_.data_path.split(".");let F=A[A.length-1],m=a[g];for(const U of A){if(U===F){m[U]=_.query;break}m[U]=m[U]||{}}a[g].__aliasFor=A[0]}const f=await w(a);for(const g in i){const _=c[g].split(".");let A=_[_.length-1],F=f[g];for(const m of _){if(m===A){i[g]._batchData=f[g][m];break}F[m]=F[m]||{}}}return i}};return T(n),n},Qt=P;h.arrayHasFile=D,h.auth=et,h.changeExpiredPassword=X,h.clearModels=vt,h.createClient=$t,h.createCollection=N,h.createFileFromBase64=Ct,h.createFileFromBase85=Ot,h.createFileFromString=q,h.createList=P,h.createRole=dt,h.createUser=ct,h.defaultUserFields=J,h.defineModel=L,h.defineModels=St,h.deleteRole=gt,h.deleteUser=lt,h.forgetPassword=I,h.getApiClient=M,h.getApiClientOptional=Ft,h.getConfig=ft,h.getCurrentUser=G,h.getDrive=at,h.getGrantedRights=tt,h.getModel=k,h.hasModel=Ut,h.isGranted=x,h.list=Qt,h.listDrives=Nt,h.listFiles=st,h.listFolders=ot,h.listModels=Et,h.listPermissions=Mt,h.listRoles=pt,h.listUsers=ut,h.login=H,h.logout=V,h.mutation=d,h.objectHasFile=B,h.query=w,h.readFileAsBase64=nt,h.resetPassword=Z,h.sendMail=yt,h.setApiClient=T,h.toQuery=wt,h.updatePassword=Y,h.updateUser=ht,h.verifyCode=K,h.webAuthn=z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(h,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("json-to-graphql-query"),require("collect.js"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","collect.js","axios"],w):(h=typeof globalThis<"u"?globalThis:h||self,w(h.light={},h.jsonToGraphqlQuery,h.collect,h.axios))})(this,(function(h,w,U,wt){"use strict";function v(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.iterator in t?!1:Symbol.toStringTag in t?Object.prototype.toString.call(t)==="[object Module]":!0}function E(t,e,r=".",s){if(!v(e))return E(t,{},r,s);const o=Object.assign({},e);for(const u in t){if(u==="__proto__"||u==="constructor")continue;const c=t[u];c!=null&&(s&&s(o,u,c,r)||(Array.isArray(c)&&Array.isArray(o[u])?o[u]=[...c,...o[u]]:v(c)&&v(o[u])?o[u]=E(c,o[u],(r?`${r}.`:"")+u.toString(),s):o[u]=c))}return o}function mt(t){return(...e)=>e.reduce((r,s)=>E(r,s,"",t),{})}const C=mt();let P=null;const J=t=>{P=t},M=()=>{if(!P)throw new Error("Api client not initialized. Call setApiClient() first.");return P},bt=()=>P;function D(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function q(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&D(t[e]))return!0;return!1}function At(t){t="<~"+t+"~>";var e,r,s,o,u,c=String,d=255;for(t.slice(0,2)==="<~"&&t.slice(-2),t=t.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),e="uuuuu".slice(t.length%5||5),t+=e,s=[],o=0,u=t.length;u>o;o+=5)r=52200625*(t.charCodeAt(o)-33)+614125*(t.charCodeAt(o+1)-33)+7225*(t.charCodeAt(o+2)-33)+85*(t.charCodeAt(o+3)-33)+(t.charCodeAt(o+4)-33),s.push(d&r>>24,d&r>>16,d&r>>8,d&r);return(function(n,i){for(var a=i;a>0;a--)n.pop()})(s,e.length),c.fromCharCode.apply(c,s)}const B=(t="")=>{const e=t,r=(s="application/octet-stream")=>{const o=new Uint8Array(e.length);for(let d=0;d<e.length;d++)o[d]=e.charCodeAt(d);const u=new Blob([o],{type:s});return URL.createObjectURL(u)};return{getContent:()=>e,getURL:r,download:s=>{const o=document.createElement("a");o.download=s,o.href=r(),document.body.appendChild(o),o.click(),document.body.removeChild(o)},open:s=>{window.open(r(s),"_blank")}}},Ct=t=>B(atob(t)),Ot=t=>B(At(t));function $(t,e,r,s,o){if(!(!t||typeof t!="object"))for(let u in t){const c=t[u];if(c&&typeof c=="object"){if("__args"in c){const d=c.__args,n={};Object.entries(d).forEach(([i,a])=>{if(a instanceof Array&&D(a)){n[i]=new w.VariableType(i);let l=0;a.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),s.append(o.current.toString(),f),o.current++,l++)}),e[i]="[Upload!]!"}else a instanceof File?(n[i]=new w.VariableType(i),r[o.current]=["variables."+i],s.append(o.current.toString(),a),e[i]="Upload!",o.current++):a instanceof Object&&q(a)?(n[i]={},Object.entries(a).forEach(([l,f])=>{if(f instanceof Array&&D(f)){n[i][l]=new w.VariableType(l);let g=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+g),s.append(o.current.toString(),_),o.current++,g++)}),e[l]="[Upload!]!"}else f instanceof File?(n[i][l]=new w.VariableType(l),r[o.current]=["variables."+l],s.append(o.current.toString(),f),e[l]="Upload!",o.current++):n[i][l]=f})):a!=null&&(n[i]=a)}),c.__args=n}$(c,e,r,s,o)}}}const F=async t=>{const{axios:e}=M(),r=t,s=new FormData;let o=!1;const u={},c={};$(r,u,c,s,{current:0}),o=Object.keys(u).length>0,o&&(r.__variables=u);let n=null;const i={query:r},a=w.jsonToGraphQLQuery(i);if(o?(s.append("map",JSON.stringify(c)),s.append("operations",JSON.stringify({query:a})),n=await e.post("",s)):n=await e.post("",{query:a}),n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data};function S(t,e){let r,s=[],o,u;const c=n=>!n||typeof n!="object"?!1:Object.values(n).some(i=>i&&typeof i=="object"&&Object.keys(i).some(a=>a.startsWith("_"))),d=()=>s.length===0?(s.unshift({}),s[0]):(c(s[0])&&s.unshift({}),s[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const i=await this.limit(1).fetch();return Array.isArray(i)&&i.length>0?i[0]:null},async fetchWithMeta(){let i=await F(this.toQuery(!0));if(u){const a=u.split(".");for(const l of a)i=i[l];return i}return i[`list${t}`]},async fetch(){let i=await F(this.toQuery());if(u){const a=u.split(".");for(const l of a)i=i[l];return i.data}return i[`list${t}`].data},dataPath(n){return n&&typeof n=="string"&&(u=n),this},sort(n){return n&&typeof n=="string"&&(o=n),this},filters(n){return n&&typeof n=="object"&&(s=[n]),this},where(n,i,a){const l=(f,g,_)=>{const b={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[g];b&&s.push({[f]:{[b]:_}})};if(a!==void 0)l(n,String(i),a);else{const f=d(),g=C(f,{[n]:i});s[0]=g}return this},whereContains(n,i){if(n&&typeof n=="string"){const a=d(),l={_contains:i};a[n]?Array.isArray(a[n])?a[n].push(l):a[n]=[a[n],l]:a[n]=[l],s[0]=a}return this},whereIn(n,i){if(n&&typeof n=="string"&&Array.isArray(i)){const a=d(),l={_in:i};a[n]?Array.isArray(a[n])?a[n].push(l):a[n]=[a[n],l]:a[n]=[l],s[0]=a}return this},whereBetween(n,i,a){if(n&&typeof n=="string"){const l=d(),f={_between:[i,a]};l[n]?Array.isArray(l[n])?l[n].push(f):l[n]=[l[n],f]:l[n]=f,s[0]=l}return this},limit(n){return typeof n=="number"&&Number.isFinite(n)&&(r=C(r||{},{limit:n})),this},offset(n){return typeof n=="number"&&Number.isFinite(n)&&(r=C(r||{},{offset:n})),this},toQuery(n=!1){let i;const a=s.length>0&&Object.keys(s[0]||{}).length>0,l=a?1:0,f=s.length>l;a&&f?i=s:f?i=s.slice(l):a&&(i=s[0]);const g=C(o?{sort:o}:{},i?{filters:i}:{}),_={data:{...e}};if(r&&(_.data.__args=r),Object.keys(g).length>0&&(_.__args=g),n&&(_.meta={total:!0,key:!0,name:!0}),u){const A=u.split(".");let b=_;for(let m=A.length-1;m>=0;m--)b={[A[m]]:b};return b}return{[`list${t}`]:_}}}}const Dt="list",St=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap","sort"],Pt=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition"];class y{_batchData=null;data_path="";filters;steps;fields;already_limit=!1;already_offset=!1;limit=null;offset=null;_sort=null;_sortDesc=!1;meta={};constructor(e){this.filters={},this.steps=[],this.fields=e}}y.prototype.getQueryPayload=function(){let t={meta:{total:!0,key:!0,name:!0}};return t.__args=this.buildArgs(),t.data=this.fields,t.data.__args=t.data.__args||{},this.limit&&(t.data.__args.limit=this.limit),this.offset&&(t.data.__args.offset=this.offset),{data_path:this.data_path,query:t,steps:this.steps}},y.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},y.prototype.buildArgs=function(){let t={};return Object.keys(this.filters).length>0&&(t.filters=this.filters),this._sort&&(t.sort=this._sort,this._sortDesc&&(t.sort+=":desc")),t},y.prototype.clone=function(){const t=Object.create(this);return t.steps=JSON.parse(JSON.stringify(this.steps)),t.filters=JSON.parse(JSON.stringify(this.filters)),t.fields=JSON.parse(JSON.stringify(this.fields)),t},U().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),y.prototype.fetchData=async function(){try{if(this._batchData){const d=this._batchData;return this.meta=d.meta,U(d.data)}let t={meta:{total:!0,key:!0,name:!0}};t.__args=this.buildArgs(),t.data=this.fields,this.already_limit&&(t.data.__args=t.data.__args||{},t.data.__args.limit=this.limit),this.already_offset&&(t.data.__args=t.data.__args||{},t.data.__args.offset=this.offset);const e=this.data_path.split(".");let r={},s=r,o=e[e.length-1];for(const d of e){if(d===o){s[d]=t;break}s[d]={},s=s[d]}let c=await F(r);for(const d of e)c=c[d];return this.meta=c.meta,U(c.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},y.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},y.prototype.all=async function(){return(await this.processData()).all()};for(const t of St)y.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Pt)y.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};y.prototype.average=y.prototype.avg,y.prototype.first=async function(){return this.take(1),(await this.processData()).first()},y.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},y.prototype.where=function(...t){const e=this._handleBatchData("where",t);if(e)return e;if(t.length===2)this.filters[t[0]]=t[1];else if(t.length===3){const r=t[0],s=t[1],o=t[2];switch(s){case"==":this.filters[r]=o;break;case"<":this.filters[r]={lt:o};break;case"<=":this.filters[r]={lte:o};break;case">":this.filters[r]={gt:o};break;case">=":this.filters[r]={gte:o};break;case"!==":this.filters[r]={ne:o};break;default:throw new Error(`Unsupported operator: ${s}`)}}return this},y.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},y.prototype.forPage=function(t,e){return t=Math.max(1,t),this.already_limit?(this.steps.push({type:"forPage",args:[t,e]}),this):(this.limit=e,this.offset=(t-1)*e,this.already_limit=!0,this.already_offset=!0,this)},y.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},y.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},y.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},y.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},y.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},y.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},y.prototype.skip=function(t){if(t<0)throw new Error("Offset must be non-negative");return this.already_offset&&this.steps.push({type:"skip",args:[t]}),this.offset=t,this.already_offset=!0,this},y.prototype.take=function(t){if(t<0)throw new Error("Length must be non-negative");return this.already_limit?(this.steps.push({type:"take",args:[t]}),this):(this.limit=t,this.already_limit=!0,this)},y.prototype.splice=function(t,e){return this.steps.push({type:"splice",args:[t,e]}),this.offset=t,this.limit=e,this.already_limit=!0,this.already_offset=!0,this};const N=(t,e)=>{const r=new y(e);return r.data_path=Dt+t,r},jt=(t,e={})=>{const r=e;let s="list"+t;const o=u=>r[u]?r[u]:null;return{field:o,$fields:r,setDataPath(u){return s=u,s},getDataPath(){return s},gqlFields(u){let c={};for(const d of u)if(typeof d=="string"){const n=o(d);n&&(c=C(c,n.gqlField?typeof n.gqlField=="string"?{[n.gqlField]:!0}:n.gqlField:{[n.name||d]:!0}))}else typeof d=="object"&&(c=C(c,d));return c},update(u,c){return p({["update"+t]:{__args:{id:u,data:c}}}).then(d=>d["update"+t])},async delete(u){return p({["delete"+t]:{__args:{id:u}}}).then(c=>c["delete"+t])},add(u){return p({["add"+t]:{__args:{data:u}}}).then(c=>c["add"+t])},fields(u){let c=[];for(let d of u){const n=o(d);n&&c.push(n)}return c},async get(u,c){const d=N(t,Ft(c));for(const[n,i]of Object.entries(u))d.where(n,"==",i);return await d.first()},list(u){let c=u;const d={};Object.entries(u).forEach(([a])=>{r[a]&&(d[a]=r[a],r[a].gqlField&&(delete c[a],c=C(c,r[a].gqlField)),r[a].gql&&(delete c[a],c=C(c,r[a].gql)))});const n=S(t,c).dataPath(s),i=n.fetch.bind(n);return{...n,async fetch(){return(await i()).map(l=>{const f={...l};return Object.entries(d).forEach(([g,_])=>{_.field&&typeof _.field=="function"&&(f[g]=_.field(l[g],l))}),f})},async fetchFirst(){const l=await n.fetchFirst.bind(n)();if(!l)return l;const f={...l};return Object.entries(d).forEach(([g,_])=>{_.field&&typeof _.field=="function"&&(f[g]=_.field(l[g],l))}),f}}}}},O={},R=(t,e)=>{const r=jt(t,e);return O[t]=r,r},j=t=>O[t]?O[t]:R(t,{}),kt=t=>!!O[t],Ut=()=>Object.keys(O),vt=()=>{Object.keys(O).forEach(t=>delete O[t])},Et=t=>{Object.entries(t).forEach(([e,r])=>{R(e,r)})},Mt=()=>F({app:{permissions:!0}}).then(t=>t.app.permissions),W=async()=>{const{app:t}=await F({app:{auth:{webAuthnRequestOptions:!0}}}),e=t.auth.webAuthnRequestOptions,r=PublicKeyCredential.parseRequestOptionsFromJSON(e);return await navigator.credentials.get({publicKey:r})},z=async()=>{const{app:t}=await F({app:{auth:{webAuthnCreationOptions:!0}}}),e=PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:e})},Q=Object.freeze(Object.defineProperty({__proto__:null,assertion:W,attestation:z,login:async()=>{const t=await W();return await p({webAuthnAssertion:{__args:{assertion:t.toJSON()}}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await z();return await p({webAuthnRegister:{__args:{registration:t.toJSON()}}}).then(e=>e.webAuthnRegister)}},Symbol.toStringTag,{value:"Module"})),G=(t=L)=>F({my:t}).then(e=>e.my),H=(t,e,r="")=>p({login:{__args:{username:t,password:e,code:r}}}).then(s=>s.login),V=()=>p({logout:!0}).then(t=>t.logout),X=(t,e,r)=>p({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(s=>s.changeExpiredPassword),Y=(t,e)=>p({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),Z=(t,e,r)=>p({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(s=>s.resetPassword),I=(t,e)=>p({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),K=(t,e)=>p({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),x=t=>F({my:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),tt=t=>F({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),et={getCurrentUser:G,webAuthn:Q,google:{unlink:()=>p({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>p({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>p({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>p({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>p({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>p({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>p({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>p({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>p({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:H,logout:V,changeExpiredPassword:X,updatePassword:Y,resetPassword:Z,forgetPassword:I,verifyCode:K,grantedRights:tt,isGranted:x},rt={name:!0,path:!0,size:!0,mime:!0,url:!0},st=(t,e,r=rt)=>F({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(s=>s.app.drive.files),nt=(t,e)=>F({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),qt=t=>({list:(e,r=rt)=>st(t,e,r),get:(e,r={name:!0,path:!0,size:!0,mime:!0,url:!0})=>F({app:{drive:{__args:{index:t},file:{__args:{path:e},...r}}}}).then(s=>s.app.drive.file),readFileAsBase64(e){return nt(t,e)},read:async e=>{let r=await F({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}});if(!r.app.drive.file||!r.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${e}`);return typeof window<"u"&&window.atob?window.atob(r.app.drive.file.base64Content):r.app.drive.file.base64Content},write:(e,r)=>p({lightDriveWriteFile:{__args:{index:t,path:e,content:r}}}).then(s=>s.lightDriveWriteFile),delete:e=>p({lightDriveDeleteFile:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFile),rename:(e,r)=>p({lightDriveRenameFile:{__args:{index:t,path:e,name:r}}}).then(s=>s.lightDriveRenameFile),move:(e,r)=>p({lightDriveMoveFile:{__args:{index:t,source:e,destination:r}}}).then(s=>s.lightDriveMoveFile)}),it={name:!0,path:!0},ot=(t,e,r=it)=>F({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(s=>s.app.drive.folders),Bt=t=>({list:(e,r=it)=>ot(t,e,r),create:e=>p({lightDriveCreateFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveCreateFolder),delete:e=>p({lightDriveDeleteFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFolder),rename:(e,r)=>p({lightDriveRenameFolder:{__args:{index:t,path:e,name:r}}}).then(s=>s.lightDriveRenameFolder)}),Nt=()=>F({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),at=t=>{const e=qt(t),r=Bt(t);return{folders:r,files:e,listFiles:e.list,getFile:e.get,readFile:e.read,writeFile:e.write,deleteFile:e.delete,renameFile:e.rename,moveFile:e.move,listFolders:r.list,createFolder:r.create,deleteFolder:r.delete,renameFolder:r.rename,uploadTempFile:s=>p({lightDriveUploadTempFile:{__args:{index:t,file:s},name:!0,path:!0,size:!0,mime:!0}}).then(o=>o.lightDriveUploadTempFile)}},L={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},lt=t=>p({addUser:{__args:t}}).then(e=>e.addUser),ct=t=>p({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),ut=(t=L)=>S("Users",t).dataPath("app.listUser").fetch(),ht=(t,e)=>p({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),Rt={list:ut,create:lt,delete:ct,update:ht},ft=t=>F({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]?.value),Lt={name:!0},dt=(t=Lt)=>F({app:{roles:t}}).then(e=>e.app.roles),pt=(t,e)=>p({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),gt=t=>p({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),Tt=()=>({list:dt,create:pt,delete:gt});function _t(t,e,r,s,o){if(!(!t||typeof t!="object"))for(let u in t){const c=t[u];if(c&&typeof c=="object"){if("__args"in c){const d=c.__args,n={};Object.entries(d).forEach(([i,a])=>{if(a instanceof Array&&D(a)){n[i]=new w.VariableType(i);let l=0;a.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),s.append(o.current.toString(),f),o.current++,l++)}),e[i]="[Upload!]!"}else a instanceof File?(n[i]=new w.VariableType(i),r[o.current]=["variables."+i],s.append(o.current.toString(),a),e[i]="Upload!",o.current++):a instanceof Object&&q(a)?(n[i]={},Object.entries(a).forEach(([l,f])=>{if(f instanceof Array&&D(f)){n[i][l]=new w.VariableType(l);let g=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+g),s.append(o.current.toString(),_),o.current++,g++)}),e[l]="[Upload!]!"}else f instanceof File?(n[i][l]=new w.VariableType(l),r[o.current]=["variables."+l],s.append(o.current.toString(),f),e[l]="Upload!",o.current++):n[i][l]=f})):a!=null&&(n[i]=a)}),c.__args=n}_t(c,e,r,s,o)}}}const p=async t=>{const{axios:e}=M(),r=t,s=new FormData;let o=!1;const u={},c={};_t(r,u,c,s,{current:0}),o=Object.keys(u).length>0,o&&(r.__variables=u);let n=null;const i={mutation:r},a=w.jsonToGraphQLQuery(i);if(o?(s.append("map",JSON.stringify(c)),s.append("operations",JSON.stringify({query:a})),n=await e.post("",s)):n=await e.post("",{query:a}),n.data.errors)throw new Error(n.data.errors[0].message);return n.data.data},yt=(t,e,r)=>p({sendMail:{__args:{email:t,subject:e,message:r}}}).then(s=>s.sendMail),Jt={send:yt},$t=Object.freeze(Object.defineProperty({__proto__:null,createFolder:t=>p({lightFSCreateFolder:{__args:{location:t}}}).then(e=>e.lightFSCreateFolder),deleteFile:t=>p({lightFSDeleteFile:{__args:{location:t}}}).then(e=>e.lightFSDeleteFile),deleteFolder:t=>p({lightFSDeleteFolder:{__args:{location:t}}}).then(e=>e.lightFSDeleteFolder),exists:t=>F({app:{fs:{exists:{__args:{location:t}}}}}).then(e=>e.app.fs.exists),list:t=>F({app:{fs:{node:{__args:{location:t},__typename:!0,__on:[{__typeName:"Folder",name:!0,location:!0,path:!0,children:{__typename:!0,name:!0,lastModified:!0,location:!0,path:!0,__on:[{__typeName:"File",size:!0,mimeType:!0},{__typeName:"Folder"}]}}]}}}}).then(r=>r.app.fs.node),move:(t,e)=>p({lightFSMove:{__args:{from:t,to:e}}}).then(r=>r.lightFSMove),read:t=>F({app:{fs:{node:{__args:{location:t},__on:[{__typeName:"File",content:!0}]}}}}).then(e=>e.app.fs.node.content),renameFile:(t,e)=>p({lightFSRenameFile:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFile),renameFolder:(t,e)=>p({lightFSRenameFolder:{__args:{location:t,newName:e}}}).then(r=>r.lightFSRenameFolder),uploadFile:(t,e)=>p({lightFSUploadFile:{__args:{location:t,file:e}}}).then(r=>r.lightFSUploadFile),writeFile:(t,e)=>p({lightFSWriteFile:{__args:{location:t,content:e}}}).then(r=>r.lightFSWriteFile)},Symbol.toStringTag,{value:"Module"})),T=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(T(r)).forEach(([s,o])=>{e[s]=o})}),e):(Object.entries(t).forEach(([r,s])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=s;return}if(typeof s=="boolean"){e[r]=s;return}e[r]=T(s)}),e)},Ft=t=>T(t),Wt=t=>{const e=typeof window>"u";let r=[];const s=wt.create({baseURL:t,withCredentials:!0});let o=!1,u=[];const c=(i,a=null)=>{u.forEach(l=>{i?l.reject(i):l.resolve(a)}),u=[]};s.interceptors.response.use(i=>{const a=i.data.errors;if(a&&a.some(l=>l.extensions?.code==="TOKEN_EXPIRED")){const l=i.config;return o?new Promise((f,g)=>{u.push({resolve:f,reject:g})}).then(()=>s(l)).catch(f=>Promise.reject(f)):(o=!0,d().then(()=>(o=!1,c(null),s(l))).catch(f=>(o=!1,c(f),Promise.reject(f))))}return i},i=>Promise.reject(i));function d(){return s.post("/refresh_token")}e&&(s.interceptors.request.use(i=>(i.withCredentials=!0,r.length>0&&(i.headers.Cookie=r.join("; ")),i)),s.interceptors.response.use(i=>{if(i.headers["set-cookie"]){const a=i.headers["set-cookie"].map(f=>f.split(";")[0]),l=new Map;r.forEach(f=>{const g=f.split("=")[0];l.set(g,f)}),a.forEach(f=>{const g=f.split("=")[0];l.set(g,f)}),r=Array.from(l.values())}return i}));const n={post:s.post,baseURL:t,axios:s,auth:et,mutation:p,query:F,config:ft,mail:Jt,users:Rt,model(i){return j(i)},roles:Tt(),collect:(i,a)=>{const l=N(i,a);return l.data_path=j(i).getDataPath(),l},list:(i,a)=>S(i,a).dataPath(j(i).getDataPath()),drive:at,async collects(i){const a={},l={};for(const g in i){const _=i[g].getQueryPayload();l[g]=_.data_path,a[g]={};const A=_.data_path.split(".");let b=A[A.length-1],m=a[g];for(const k of A){if(k===b){m[k]=_.query;break}m[k]=m[k]||{}}a[g].__aliasFor=A[0]}const f=await F(a);for(const g in i){const _=l[g].split(".");let A=_[_.length-1],b=f[g];for(const m of _){if(m===A){i[g]._batchData=f[g][m];break}b[m]=b[m]||{}}}return i}};return J(n),n},zt=S;h.arrayHasFile=D,h.auth=et,h.changeExpiredPassword=X,h.clearModels=vt,h.createClient=Wt,h.createCollection=N,h.createFileFromBase64=Ct,h.createFileFromBase85=Ot,h.createFileFromString=B,h.createList=S,h.createRole=pt,h.createUser=lt,h.defaultUserFields=L,h.defineModel=R,h.defineModels=Et,h.deleteRole=gt,h.deleteUser=ct,h.forgetPassword=I,h.fs=$t,h.getApiClient=M,h.getApiClientOptional=bt,h.getConfig=ft,h.getCurrentUser=G,h.getDrive=at,h.getGrantedRights=tt,h.getModel=j,h.hasModel=kt,h.isGranted=x,h.list=zt,h.listDrives=Nt,h.listFiles=st,h.listFolders=ot,h.listModels=Ut,h.listPermissions=Mt,h.listRoles=dt,h.listUsers=ut,h.login=H,h.logout=V,h.mutation=p,h.objectHasFile=q,h.query=F,h.readFileAsBase64=nt,h.resetPassword=Z,h.sendMail=yt,h.setApiClient=J,h.toQuery=Ft,h.updatePassword=Y,h.updateUser=ht,h.verifyCode=K,h.webAuthn=Q,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "3.2.2",
3
+ "version": "3.2.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"