@hostlink/light 3.2.8 → 3.3.0

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
@@ -1,28 +1,28 @@
1
1
  import { jsonToGraphQLQuery as q, VariableType as b } from "json-to-graphql-query";
2
- import U from "collect.js";
2
+ import P from "collect.js";
3
3
  import H from "axios";
4
- function k(t) {
4
+ function U(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
10
  function E(t, e, r = ".", s) {
11
- if (!k(e))
11
+ if (!U(e))
12
12
  return E(t, {}, r, s);
13
- const i = Object.assign({}, e);
13
+ const o = Object.assign({}, e);
14
14
  for (const u in t) {
15
15
  if (u === "__proto__" || u === "constructor")
16
16
  continue;
17
17
  const c = t[u];
18
- c != null && (s && s(i, u, c, r) || (Array.isArray(c) && Array.isArray(i[u]) ? i[u] = [...c, ...i[u]] : k(c) && k(i[u]) ? i[u] = E(
18
+ c != null && (s && s(o, u, c, r) || (Array.isArray(c) && Array.isArray(o[u]) ? o[u] = [...c, ...o[u]] : U(c) && U(o[u]) ? o[u] = E(
19
19
  c,
20
- i[u],
20
+ o[u],
21
21
  (r ? `${r}.` : "") + u.toString(),
22
22
  s
23
- ) : i[u] = c));
23
+ ) : o[u] = c));
24
24
  }
25
- return i;
25
+ return o;
26
26
  }
27
27
  function X(t) {
28
28
  return (...e) => (
@@ -38,7 +38,7 @@ const Y = (t) => {
38
38
  if (!S)
39
39
  throw new Error("Api client not initialized. Call setApiClient() first.");
40
40
  return S;
41
- }, Vt = () => S;
41
+ }, xt = () => S;
42
42
  function D(t) {
43
43
  for (let e = 0; e < t.length; e++)
44
44
  if (t[e] instanceof File)
@@ -53,69 +53,69 @@ function N(t) {
53
53
  }
54
54
  function Z(t) {
55
55
  t = "<~" + t + "~>";
56
- var e, r, s, i, u, c = 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
- return (function(n, o) {
59
- for (var a = o; a > 0; a--) n.pop();
56
+ var e, r, s, o, u, c = 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 = [], 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);
58
+ return (function(n, i) {
59
+ for (var a = i; a > 0; a--) n.pop();
60
60
  })(s, e.length), c.fromCharCode.apply(c, s);
61
61
  }
62
62
  const B = (t = "") => {
63
63
  const e = t, r = (s = "application/octet-stream") => {
64
- const i = new Uint8Array(e.length);
64
+ const o = new Uint8Array(e.length);
65
65
  for (let p = 0; p < e.length; p++)
66
- i[p] = e.charCodeAt(p);
67
- const u = new Blob([i], { type: s });
66
+ o[p] = e.charCodeAt(p);
67
+ const u = new Blob([o], { type: s });
68
68
  return URL.createObjectURL(u);
69
69
  };
70
70
  return {
71
71
  getContent: () => e,
72
72
  getURL: r,
73
73
  download: (s) => {
74
- const i = document.createElement("a");
75
- i.download = s, i.href = r(), document.body.appendChild(i), i.click(), document.body.removeChild(i);
74
+ const o = document.createElement("a");
75
+ o.download = s, o.href = r(), document.body.appendChild(o), o.click(), document.body.removeChild(o);
76
76
  },
77
77
  open: (s) => {
78
78
  window.open(r(s), "_blank");
79
79
  }
80
80
  };
81
- }, It = (t) => B(atob(t)), Kt = (t) => B(Z(t));
82
- function J(t, e, r, s, i) {
81
+ }, te = (t) => B(atob(t)), ee = (t) => B(Z(t));
82
+ function T(t, e, r, s, o) {
83
83
  if (!(!t || typeof t != "object"))
84
84
  for (let u in t) {
85
85
  const c = t[u];
86
86
  if (c && typeof c == "object") {
87
87
  if ("__args" in c) {
88
88
  const p = c.__args, n = {};
89
- Object.entries(p).forEach(([o, a]) => {
89
+ Object.entries(p).forEach(([i, a]) => {
90
90
  if (a instanceof Array && D(a)) {
91
- n[o] = new b(o);
91
+ n[i] = new b(i);
92
92
  let l = 0;
93
93
  a.forEach((h) => {
94
- h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + l), s.append(i.current.toString(), h), i.current++, l++);
95
- }), e[o] = "[Upload!]!";
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(([l, h]) => {
94
+ h instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + i + "." + l), s.append(o.current.toString(), h), o.current++, l++);
95
+ }), e[i] = "[Upload!]!";
96
+ } else a instanceof File ? (n[i] = new b(i), r[o.current] = ["variables." + i], s.append(o.current.toString(), a), e[i] = "Upload!", o.current++) : a instanceof Object && N(a) ? (n[i] = {}, Object.entries(a).forEach(([l, h]) => {
97
97
  if (h instanceof Array && D(h)) {
98
- n[o][l] = new b(l);
98
+ n[i][l] = new b(l);
99
99
  let d = 0;
100
100
  h.forEach((_) => {
101
- _ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + d), s.append(i.current.toString(), _), i.current++, d++);
101
+ _ instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + l + "." + d), s.append(o.current.toString(), _), o.current++, d++);
102
102
  }), e[l] = "[Upload!]!";
103
- } else h instanceof File ? (n[o][l] = new b(l), r[i.current] = ["variables." + l], s.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : n[o][l] = h;
104
- })) : a != null && (n[o] = a);
103
+ } else h instanceof File ? (n[i][l] = new b(l), r[o.current] = ["variables." + l], s.append(o.current.toString(), h), e[l] = "Upload!", o.current++) : n[i][l] = h;
104
+ })) : a != null && (n[i] = a);
105
105
  }), c.__args = n;
106
106
  }
107
- J(c, e, r, s, i);
107
+ T(c, e, r, s, o);
108
108
  }
109
109
  }
110
110
  }
111
111
  const y = async (t) => {
112
112
  const { axios: e } = M(), r = t, s = new FormData();
113
- let i = !1;
113
+ let o = !1;
114
114
  const u = {}, c = {};
115
- J(r, u, c, s, { current: 0 }), i = Object.keys(u).length > 0, i && (r.__variables = u);
115
+ T(r, u, c, s, { current: 0 }), o = Object.keys(u).length > 0, o && (r.__variables = u);
116
116
  let n = null;
117
117
  const a = q({ query: r });
118
- if (i ? (s.append("map", JSON.stringify(c)), s.append("operations", JSON.stringify({
118
+ if (o ? (s.append("map", JSON.stringify(c)), s.append("operations", JSON.stringify({
119
119
  query: a
120
120
  })), n = await e.post("", s)) : n = await e.post("", {
121
121
  query: a
@@ -124,8 +124,8 @@ const y = async (t) => {
124
124
  return n.data.data;
125
125
  };
126
126
  function j(t, e) {
127
- let r, s = [], i, u;
128
- const c = (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]) : (c(s[0]) && s.unshift({}), s[0]);
127
+ let r, s = [], o, u;
128
+ const c = (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]) : (c(s[0]) && s.unshift({}), s[0]);
129
129
  return {
130
130
  first() {
131
131
  return this.fetchFirst();
@@ -134,34 +134,34 @@ function j(t, e) {
134
134
  return this.fetch();
135
135
  },
136
136
  async fetchFirst() {
137
- const o = await this.limit(1).fetch();
138
- return Array.isArray(o) && o.length > 0 ? o[0] : null;
137
+ const i = await this.limit(1).fetch();
138
+ return Array.isArray(i) && i.length > 0 ? i[0] : null;
139
139
  },
140
140
  async fetchWithMeta() {
141
- let o = await y(this.toQuery(!0));
141
+ let i = await y(this.toQuery(!0));
142
142
  if (u) {
143
143
  const a = u.split(".");
144
144
  for (const l of a)
145
- o = o[l];
146
- return o;
145
+ i = i[l];
146
+ return i;
147
147
  }
148
- return o[`list${t}`];
148
+ return i[`list${t}`];
149
149
  },
150
150
  async fetch() {
151
- let o = await y(this.toQuery());
151
+ let i = await y(this.toQuery());
152
152
  if (u) {
153
153
  const a = u.split(".");
154
154
  for (const l of a)
155
- o = o[l];
156
- return o.data;
155
+ i = i[l];
156
+ return i.data;
157
157
  }
158
- return o[`list${t}`].data;
158
+ return i[`list${t}`].data;
159
159
  },
160
160
  dataPath(n) {
161
161
  return n && typeof n == "string" && (u = n), this;
162
162
  },
163
163
  sort(n) {
164
- return n && typeof n == "string" && (i = n), this;
164
+ return n && typeof n == "string" && (o = n), this;
165
165
  },
166
166
  filters(n) {
167
167
  return n && typeof n == "object" && (s = [n]), this;
@@ -169,9 +169,9 @@ function j(t, e) {
169
169
  // where can be called as:
170
170
  // where('key', value) -> exact match
171
171
  // where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
172
- where(n, o, a) {
172
+ where(n, i, a) {
173
173
  const l = (h, d, _) => {
174
- const w = {
174
+ const F = {
175
175
  ">": "_gt",
176
176
  "<": "_lt",
177
177
  ">=": "_gte",
@@ -180,21 +180,21 @@ function j(t, e) {
180
180
  in: "_in",
181
181
  contains: "_contains"
182
182
  }[d];
183
- w && s.push({ [h]: { [w]: _ } });
183
+ F && s.push({ [h]: { [F]: _ } });
184
184
  };
185
185
  if (a !== void 0)
186
- l(n, String(o), a);
186
+ l(n, String(i), a);
187
187
  else {
188
- const h = p(), d = A(h, { [n]: o });
188
+ const h = p(), d = A(h, { [n]: i });
189
189
  s[0] = d;
190
190
  }
191
191
  return this;
192
192
  },
193
193
  // whereContains adds a _contains filter for a specific field
194
194
  // If the same field is used multiple times, it merges them into an array
195
- whereContains(n, o) {
195
+ whereContains(n, i) {
196
196
  if (n && typeof n == "string") {
197
- const a = p(), l = { _contains: o };
197
+ const a = p(), l = { _contains: i };
198
198
  a[n] ? Array.isArray(a[n]) ? a[n].push(l) : a[n] = [a[n], l] : a[n] = [l], s[0] = a;
199
199
  }
200
200
  return this;
@@ -202,17 +202,17 @@ function j(t, e) {
202
202
  // ...existing code...
203
203
  // whereIn adds an _in filter for a specific field
204
204
  // If the same field is used multiple times, it merges them into an array
205
- whereIn(n, o) {
206
- if (n && typeof n == "string" && Array.isArray(o)) {
207
- const a = p(), l = { _in: o };
205
+ whereIn(n, i) {
206
+ if (n && typeof n == "string" && Array.isArray(i)) {
207
+ const a = p(), l = { _in: i };
208
208
  a[n] ? Array.isArray(a[n]) ? a[n].push(l) : a[n] = [a[n], l] : a[n] = [l], s[0] = a;
209
209
  }
210
210
  return this;
211
211
  },
212
212
  // whereBetween adds a _between filter for a specific field
213
- whereBetween(n, o, a) {
213
+ whereBetween(n, i, a) {
214
214
  if (n && typeof n == "string") {
215
- const l = p(), h = { _between: [o, a] };
215
+ const l = p(), h = { _between: [i, a] };
216
216
  l[n] ? Array.isArray(l[n]) ? l[n].push(h) : l[n] = [l[n], h] : l[n] = h, s[0] = l;
217
217
  }
218
218
  return this;
@@ -226,12 +226,12 @@ function j(t, e) {
226
226
  return typeof n == "number" && Number.isFinite(n) && (r = A(r || {}, { offset: n })), this;
227
227
  },
228
228
  toQuery(n = !1) {
229
- let o;
229
+ let i;
230
230
  const a = s.length > 0 && Object.keys(s[0] || {}).length > 0, l = a ? 1 : 0, h = s.length > l;
231
- a && h ? o = s : h ? o = s.slice(l) : a && (o = s[0]);
231
+ a && h ? i = s : h ? i = s.slice(l) : a && (i = s[0]);
232
232
  const d = A(
233
- i ? { sort: i } : {},
234
- o ? { filters: o } : {}
233
+ o ? { sort: o } : {},
234
+ i ? { filters: i } : {}
235
235
  ), _ = {
236
236
  data: {
237
237
  ...e
@@ -242,13 +242,13 @@ function j(t, e) {
242
242
  key: !0,
243
243
  name: !0
244
244
  }), u) {
245
- const F = u.split(".");
246
- let w = _;
247
- for (let m = F.length - 1; m >= 0; m--)
248
- w = {
249
- [F[m]]: w
245
+ const w = u.split(".");
246
+ let F = _;
247
+ for (let m = w.length - 1; m >= 0; m--)
248
+ F = {
249
+ [w[m]]: F
250
250
  };
251
- return w;
251
+ return F;
252
252
  }
253
253
  return {
254
254
  [`list${t}`]: _
@@ -353,14 +353,14 @@ g.prototype.clone = function() {
353
353
  const t = Object.create(this);
354
354
  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;
355
355
  };
356
- U().macro("whereContains", function(t, e) {
356
+ P().macro("whereContains", function(t, e) {
357
357
  return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
358
358
  });
359
359
  g.prototype.fetchData = async function() {
360
360
  try {
361
361
  if (this._batchData) {
362
362
  const p = this._batchData;
363
- return this.meta = p.meta, U(p.data);
363
+ return this.meta = p.meta, P(p.data);
364
364
  }
365
365
  let t = {
366
366
  meta: {
@@ -371,9 +371,9 @@ g.prototype.fetchData = async function() {
371
371
  };
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
- let r = {}, s = r, i = e[e.length - 1];
374
+ let r = {}, s = r, o = e[e.length - 1];
375
375
  for (const p of e) {
376
- if (p === i) {
376
+ if (p === o) {
377
377
  s[p] = t;
378
378
  break;
379
379
  }
@@ -382,7 +382,7 @@ g.prototype.fetchData = async function() {
382
382
  let c = await y(r);
383
383
  for (const p of e)
384
384
  c = c[p];
385
- return this.meta = c.meta, U(c.data);
385
+ return this.meta = c.meta, P(c.data);
386
386
  } catch (t) {
387
387
  throw console.error("Error fetching collection data:", t), t;
388
388
  }
@@ -418,25 +418,25 @@ g.prototype.where = function(...t) {
418
418
  if (t.length === 2)
419
419
  this.filters[t[0]] = t[1];
420
420
  else if (t.length === 3) {
421
- const r = t[0], s = t[1], i = t[2];
421
+ const r = t[0], s = t[1], o = t[2];
422
422
  switch (s) {
423
423
  case "==":
424
- this.filters[r] = i;
424
+ this.filters[r] = o;
425
425
  break;
426
426
  case "<":
427
- this.filters[r] = { lt: i };
427
+ this.filters[r] = { lt: o };
428
428
  break;
429
429
  case "<=":
430
- this.filters[r] = { lte: i };
430
+ this.filters[r] = { lte: o };
431
431
  break;
432
432
  case ">":
433
- this.filters[r] = { gt: i };
433
+ this.filters[r] = { gt: o };
434
434
  break;
435
435
  case ">=":
436
- this.filters[r] = { gte: i };
436
+ this.filters[r] = { gte: o };
437
437
  break;
438
438
  case "!==":
439
- this.filters[r] = { ne: i };
439
+ this.filters[r] = { ne: o };
440
440
  break;
441
441
  default:
442
442
  throw new Error(`Unsupported operator: ${s}`);
@@ -486,15 +486,15 @@ g.prototype.take = function(t) {
486
486
  g.prototype.splice = function(t, e) {
487
487
  return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
488
488
  };
489
- const L = (t, e) => {
489
+ const J = (t, e) => {
490
490
  const r = new g(e);
491
491
  return r.data_path = V + t, r;
492
492
  }, x = (t, e = {}) => {
493
493
  const r = e;
494
494
  let s = "list" + t;
495
- const i = (u) => r[u] ? r[u] : null;
495
+ const o = (u) => r[u] ? r[u] : null;
496
496
  return {
497
- field: i,
497
+ field: o,
498
498
  $fields: r,
499
499
  setDataPath(u) {
500
500
  return s = u, s;
@@ -506,7 +506,7 @@ const L = (t, e) => {
506
506
  let c = {};
507
507
  for (const p of u)
508
508
  if (typeof p == "string") {
509
- const n = i(p);
509
+ const n = o(p);
510
510
  n && (c = A(c, n.gqlField ? typeof n.gqlField == "string" ? { [n.gqlField]: !0 } : n.gqlField : { [n.name || p]: !0 }));
511
511
  } else typeof p == "object" && (c = A(c, p));
512
512
  return c;
@@ -535,15 +535,15 @@ const L = (t, e) => {
535
535
  fields(u) {
536
536
  let c = [];
537
537
  for (let p of u) {
538
- const n = i(p);
538
+ const n = o(p);
539
539
  n && c.push(n);
540
540
  }
541
541
  return c;
542
542
  },
543
543
  async get(u, c) {
544
- const p = L(t, Ht(c));
545
- for (const [n, o] of Object.entries(u))
546
- p.where(n, "==", o);
544
+ const p = J(t, Zt(c));
545
+ for (const [n, i] of Object.entries(u))
546
+ p.where(n, "==", i);
547
547
  return await p.first();
548
548
  },
549
549
  list(u) {
@@ -552,11 +552,11 @@ const L = (t, e) => {
552
552
  Object.entries(u).forEach(([a]) => {
553
553
  r[a] && (p[a] = r[a], r[a].gqlField && (delete c[a], c = A(c, r[a].gqlField)), r[a].gql && (delete c[a], c = A(c, r[a].gql)));
554
554
  });
555
- const n = j(t, c).dataPath(s), o = n.fetch.bind(n);
555
+ const n = j(t, c).dataPath(s), i = n.fetch.bind(n);
556
556
  return {
557
557
  ...n,
558
558
  async fetch() {
559
- return (await o()).map((l) => {
559
+ return (await i()).map((l) => {
560
560
  const h = { ...l };
561
561
  return Object.entries(p).forEach(([d, _]) => {
562
562
  _.field && typeof _.field == "function" && (h[d] = _.field(l[d], l));
@@ -574,16 +574,16 @@ const L = (t, e) => {
574
574
  };
575
575
  }
576
576
  };
577
- }, O = {}, T = (t, e) => {
577
+ }, O = {}, L = (t, e) => {
578
578
  const r = x(t, e);
579
579
  return O[t] = r, r;
580
- }, P = (t) => O[t] ? O[t] : T(t, {}), xt = (t) => !!O[t], te = () => Object.keys(O), ee = () => {
580
+ }, k = (t) => O[t] ? O[t] : L(t, {}), re = (t) => !!O[t], se = () => Object.keys(O), ne = () => {
581
581
  Object.keys(O).forEach((t) => delete O[t]);
582
- }, re = (t) => {
582
+ }, ie = (t) => {
583
583
  Object.entries(t).forEach(([e, r]) => {
584
- T(e, r);
584
+ L(e, r);
585
585
  });
586
- }, se = () => y({
586
+ }, oe = () => 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
- }, Q = async () => {
599
+ }, $ = async () => {
600
600
  const { app: t } = await y({
601
601
  app: {
602
602
  auth: {
@@ -615,7 +615,7 @@ const L = (t, e) => {
615
615
  }
616
616
  }).then((e) => e.webAuthnAssertion);
617
617
  }, et = async () => {
618
- const t = await Q();
618
+ const t = await $();
619
619
  return await f({
620
620
  webAuthnRegister: {
621
621
  __args: {
@@ -626,10 +626,10 @@ const L = (t, e) => {
626
626
  }, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
627
627
  __proto__: null,
628
628
  assertion: R,
629
- attestation: Q,
629
+ attestation: $,
630
630
  login: tt,
631
631
  register: et
632
- }, Symbol.toStringTag, { value: "Module" })), st = (t = G) => 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), lt = (t, e, r) => f({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((s) => s.resetPassword), ct = (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({
632
+ }, Symbol.toStringTag, { value: "Module" })), st = (t = G) => y({ my: t }).then((e) => e.my), nt = (t, e, r = "") => f({ login: { __args: { username: t, password: e, code: r } } }).then((s) => s.login), it = () => f({ logout: !0 }).then((t) => t.logout), ot = (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), lt = (t, e, r) => f({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((s) => s.resetPassword), ct = (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: {
@@ -664,21 +664,21 @@ const L = (t, e) => {
664
664
  register: (t) => f({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
665
665
  },
666
666
  login: nt,
667
- logout: ot,
668
- changeExpiredPassword: it,
667
+ logout: it,
668
+ changeExpiredPassword: ot,
669
669
  updatePassword: at,
670
670
  resetPassword: lt,
671
671
  forgetPassword: ct,
672
672
  verifyCode: ut,
673
673
  grantedRights: pt,
674
674
  isGranted: ht
675
- }, $ = {
675
+ }, Q = {
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 = $) => y({
681
+ }, dt = (t, e, r = Q) => 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), gt = (t) => ({
706
- list: (e, r = $) => dt(t, e, r),
706
+ list: (e, r = Q) => dt(t, e, r),
707
707
  get: (e, r = {
708
708
  name: !0,
709
709
  path: !0,
@@ -770,14 +770,14 @@ const L = (t, e) => {
770
770
  create: (e) => f({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
771
771
  delete: (e) => f({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
772
772
  rename: (e, r) => f({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((s) => s.lightDriveRenameFolder)
773
- }), ne = () => y({
773
+ }), ae = () => 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), wt = (t) => {
780
+ }).then((t) => t.app.drives), Ft = (t) => {
781
781
  const e = gt(t), r = mt(t);
782
782
  return {
783
783
  folders: r,
@@ -801,7 +801,7 @@ const L = (t, e) => {
801
801
  size: !0,
802
802
  mime: !0
803
803
  }
804
- }).then((i) => i.lightDriveUploadTempFile)
804
+ }).then((o) => o.lightDriveUploadTempFile)
805
805
  };
806
806
  }, G = {
807
807
  user_id: !0,
@@ -809,7 +809,7 @@ const L = (t, e) => {
809
809
  first_name: !0,
810
810
  last_name: !0,
811
811
  status: !0
812
- }, Ft = (t) => f({
812
+ }, wt = (t) => f({
813
813
  addUser: {
814
814
  __args: t
815
815
  }
@@ -823,7 +823,7 @@ const L = (t, e) => {
823
823
  }
824
824
  }).then((r) => r.updateUser), Dt = {
825
825
  list: At,
826
- create: Ft,
826
+ create: wt,
827
827
  delete: bt,
828
828
  update: Ot
829
829
  }, Ct = (t) => y({
@@ -846,7 +846,7 @@ const L = (t, e) => {
846
846
  app: {
847
847
  roles: t
848
848
  }
849
- }).then((e) => e.app.roles), kt = (t, e) => f({
849
+ }).then((e) => e.app.roles), Ut = (t, e) => f({
850
850
  addRole: {
851
851
  __args: {
852
852
  data: {
@@ -855,52 +855,52 @@ const L = (t, e) => {
855
855
  }
856
856
  }
857
857
  }
858
- }).then((r) => r.addRole), Pt = (t) => f({
858
+ }).then((r) => r.addRole), kt = (t) => f({
859
859
  deleteRole: {
860
860
  __args: { name: t }
861
861
  }
862
- }).then((e) => e.deleteRole), Ut = () => ({
862
+ }).then((e) => e.deleteRole), Pt = () => ({
863
863
  list: jt,
864
- create: kt,
865
- delete: Pt
864
+ create: Ut,
865
+ delete: kt
866
866
  });
867
- function W(t, e, r, s, i) {
867
+ function W(t, e, r, s, o) {
868
868
  if (!(!t || typeof t != "object"))
869
869
  for (let u in t) {
870
870
  const c = t[u];
871
871
  if (c && typeof c == "object") {
872
872
  if ("__args" in c) {
873
873
  const p = c.__args, n = {};
874
- Object.entries(p).forEach(([o, a]) => {
874
+ Object.entries(p).forEach(([i, a]) => {
875
875
  if (a instanceof Array && D(a)) {
876
- n[o] = new b(o);
876
+ n[i] = new b(i);
877
877
  let l = 0;
878
878
  a.forEach((h) => {
879
- h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + l), s.append(i.current.toString(), h), i.current++, l++);
880
- }), e[o] = "[Upload!]!";
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(([l, h]) => {
879
+ h instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + i + "." + l), s.append(o.current.toString(), h), o.current++, l++);
880
+ }), e[i] = "[Upload!]!";
881
+ } else a instanceof File ? (n[i] = new b(i), r[o.current] = ["variables." + i], s.append(o.current.toString(), a), e[i] = "Upload!", o.current++) : a instanceof Object && N(a) ? (n[i] = {}, Object.entries(a).forEach(([l, h]) => {
882
882
  if (h instanceof Array && D(h)) {
883
- n[o][l] = new b(l);
883
+ n[i][l] = new b(l);
884
884
  let d = 0;
885
885
  h.forEach((_) => {
886
- _ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + d), s.append(i.current.toString(), _), i.current++, d++);
886
+ _ instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + l + "." + d), s.append(o.current.toString(), _), o.current++, d++);
887
887
  }), e[l] = "[Upload!]!";
888
- } else h instanceof File ? (n[o][l] = new b(l), r[i.current] = ["variables." + l], s.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : n[o][l] = h;
889
- })) : a != null && (n[o] = a);
888
+ } else h instanceof File ? (n[i][l] = new b(l), r[o.current] = ["variables." + l], s.append(o.current.toString(), h), e[l] = "Upload!", o.current++) : n[i][l] = h;
889
+ })) : a != null && (n[i] = a);
890
890
  }), c.__args = n;
891
891
  }
892
- W(c, e, r, s, i);
892
+ W(c, e, r, s, o);
893
893
  }
894
894
  }
895
895
  }
896
896
  const f = async (t) => {
897
897
  const { axios: e } = M(), r = t, s = new FormData();
898
- let i = !1;
898
+ let o = !1;
899
899
  const u = {}, c = {};
900
- W(r, u, c, s, { current: 0 }), i = Object.keys(u).length > 0, i && (r.__variables = u);
900
+ W(r, u, c, s, { current: 0 }), o = Object.keys(u).length > 0, o && (r.__variables = u);
901
901
  let n = null;
902
902
  const a = q({ mutation: r });
903
- if (i ? (s.append("map", JSON.stringify(c)), s.append("operations", JSON.stringify({
903
+ if (o ? (s.append("map", JSON.stringify(c)), s.append("operations", JSON.stringify({
904
904
  query: a
905
905
  })), n = await e.post("", s)) : n = await e.post("", {
906
906
  query: a
@@ -925,15 +925,15 @@ const f = async (t) => {
925
925
  lightFSRenameFile: {
926
926
  __args: { location: t, newName: e }
927
927
  }
928
- }).then((r) => r.lightFSRenameFile), Jt = (t, e) => f({
928
+ }).then((r) => r.lightFSRenameFile), Tt = (t, e) => f({
929
929
  lightFSWriteFile: {
930
930
  __args: { location: t, content: e }
931
931
  }
932
- }).then((r) => r.lightFSWriteFile), Lt = (t, e) => f({
932
+ }).then((r) => r.lightFSWriteFile), Jt = (t, e) => f({
933
933
  lightFSUploadFile: {
934
934
  __args: { location: t, file: e }
935
935
  }
936
- }).then((r) => r.lightFSUploadFile), Tt = (t) => f({
936
+ }).then((r) => r.lightFSUploadFile), Lt = (t) => f({
937
937
  lightFSDeleteFile: {
938
938
  __args: { location: t }
939
939
  }
@@ -941,7 +941,7 @@ const f = async (t) => {
941
941
  lightFSMove: {
942
942
  __args: { from: t, to: e }
943
943
  }
944
- }).then((r) => r.lightFSMove), Qt = (t) => y({
944
+ }).then((r) => r.lightFSMove), $t = (t) => y({
945
945
  app: {
946
946
  fs: {
947
947
  exists: {
@@ -949,7 +949,7 @@ const f = async (t) => {
949
949
  }
950
950
  }
951
951
  }
952
- }).then((e) => e.app.fs.exists), $t = (t, e) => {
952
+ }).then((e) => e.app.fs.exists), Qt = (t, e) => {
953
953
  const r = {};
954
954
  return t && (r.search = t), e && (r.label = e), y({
955
955
  app: {
@@ -1023,7 +1023,6 @@ const f = async (t) => {
1023
1023
  }), Wt = (t, e) => f({
1024
1024
  lightFSUploadBase64: {
1025
1025
  __args: { location: t, base64: e },
1026
- // 回傳 File 物件的欄位,方便前端立即顯示
1027
1026
  __typename: !0,
1028
1027
  name: !0,
1029
1028
  path: !0,
@@ -1035,26 +1034,60 @@ const f = async (t) => {
1035
1034
  lastModified: !0
1036
1035
  }]
1037
1036
  }
1038
- }).then((r) => r.lightFSUploadBase64), oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1037
+ }).then((r) => r.lightFSUploadBase64), Ht = (t) => f({
1038
+ lightFSDuplicateFile: {
1039
+ __args: { location: t }
1040
+ }
1041
+ }).then((e) => e.lightFSDuplicateFile), Xt = (t, e) => f({
1042
+ lightFSUploadTempFile: {
1043
+ __args: { location: t, file: e },
1044
+ name: !0,
1045
+ path: !0,
1046
+ location: !0,
1047
+ size: !0,
1048
+ mimeType: !0
1049
+ }
1050
+ }).then((r) => r.lightFSUploadTempFile), Yt = (t, e, r) => {
1051
+ const s = { location: t };
1052
+ return e && (s.type = e), r && (s.search = r), y({
1053
+ app: {
1054
+ fs: {
1055
+ listFiles: {
1056
+ __args: s,
1057
+ name: !0,
1058
+ path: !0,
1059
+ location: !0,
1060
+ size: !0,
1061
+ mimeType: !0,
1062
+ publicUrl: !0,
1063
+ lastModified: !0
1064
+ }
1065
+ }
1066
+ }
1067
+ }).then((o) => o.app.fs.listFiles);
1068
+ }, le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1039
1069
  __proto__: null,
1040
1070
  createFolder: qt,
1041
- deleteFile: Tt,
1071
+ deleteFile: Lt,
1042
1072
  deleteFolder: Mt,
1043
- exists: Qt,
1044
- find: $t,
1073
+ duplicateFile: Ht,
1074
+ exists: $t,
1075
+ find: Qt,
1045
1076
  list: zt,
1077
+ listFiles: Yt,
1046
1078
  move: Rt,
1047
1079
  readFile: Gt,
1048
1080
  renameFile: Bt,
1049
1081
  renameFolder: Nt,
1050
1082
  uploadBase64: Wt,
1051
- uploadFile: Lt,
1052
- writeFile: Jt
1083
+ uploadFile: Jt,
1084
+ uploadTempFile: Xt,
1085
+ writeFile: Tt
1053
1086
  }, Symbol.toStringTag, { value: "Module" })), v = (t) => {
1054
1087
  let e = {};
1055
1088
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
1056
- Object.entries(v(r)).forEach(([s, i]) => {
1057
- e[s] = i;
1089
+ Object.entries(v(r)).forEach(([s, o]) => {
1090
+ e[s] = o;
1058
1091
  });
1059
1092
  }), e) : (Object.entries(t).forEach(([r, s]) => {
1060
1093
  if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
@@ -1067,38 +1100,38 @@ const f = async (t) => {
1067
1100
  }
1068
1101
  e[r] = v(s);
1069
1102
  }), e);
1070
- }, Ht = (t) => v(t), ie = (t) => {
1103
+ }, Zt = (t) => v(t), ce = (t) => {
1071
1104
  const e = typeof window > "u";
1072
1105
  let r = [];
1073
1106
  const s = H.create({
1074
1107
  baseURL: t,
1075
1108
  withCredentials: !0
1076
1109
  });
1077
- let i = !1, u = [];
1078
- const c = (o, a = null) => {
1110
+ let o = !1, u = [];
1111
+ const c = (i, a = null) => {
1079
1112
  u.forEach((l) => {
1080
- o ? l.reject(o) : l.resolve(a);
1113
+ i ? l.reject(i) : l.resolve(a);
1081
1114
  }), u = [];
1082
1115
  };
1083
1116
  s.interceptors.response.use(
1084
- (o) => {
1085
- const a = o.data.errors;
1117
+ (i) => {
1118
+ const a = i.data.errors;
1086
1119
  if (a && a.some((l) => l.extensions?.code === "TOKEN_EXPIRED")) {
1087
- const l = o.config;
1088
- return i ? new Promise((h, d) => {
1120
+ const l = i.config;
1121
+ return o ? new Promise((h, d) => {
1089
1122
  u.push({ resolve: h, reject: d });
1090
- }).then(() => s(l)).catch((h) => Promise.reject(h)) : (i = !0, p().then(() => (i = !1, c(null), s(l))).catch((h) => (i = !1, c(h), Promise.reject(h))));
1123
+ }).then(() => s(l)).catch((h) => Promise.reject(h)) : (o = !0, p().then(() => (o = !1, c(null), s(l))).catch((h) => (o = !1, c(h), Promise.reject(h))));
1091
1124
  }
1092
- return o;
1125
+ return i;
1093
1126
  },
1094
- (o) => Promise.reject(o)
1127
+ (i) => Promise.reject(i)
1095
1128
  );
1096
1129
  function p() {
1097
1130
  return s.post("/refresh_token");
1098
1131
  }
1099
- e && (s.interceptors.request.use((o) => (o.withCredentials = !0, r.length > 0 && (o.headers.Cookie = r.join("; ")), o)), s.interceptors.response.use((o) => {
1100
- if (o.headers["set-cookie"]) {
1101
- const a = o.headers["set-cookie"].map((h) => h.split(";")[0]), l = /* @__PURE__ */ new Map();
1132
+ e && (s.interceptors.request.use((i) => (i.withCredentials = !0, r.length > 0 && (i.headers.Cookie = r.join("; ")), i)), s.interceptors.response.use((i) => {
1133
+ if (i.headers["set-cookie"]) {
1134
+ const a = i.headers["set-cookie"].map((h) => h.split(";")[0]), l = /* @__PURE__ */ new Map();
1102
1135
  r.forEach((h) => {
1103
1136
  const d = h.split("=")[0];
1104
1137
  l.set(d, h);
@@ -1107,7 +1140,7 @@ const f = async (t) => {
1107
1140
  l.set(d, h);
1108
1141
  }), r = Array.from(l.values());
1109
1142
  }
1110
- return o;
1143
+ return i;
1111
1144
  }));
1112
1145
  const n = {
1113
1146
  post: s.post,
@@ -1119,88 +1152,88 @@ const f = async (t) => {
1119
1152
  config: Ct,
1120
1153
  mail: vt,
1121
1154
  users: Dt,
1122
- model(o) {
1123
- return P(o);
1155
+ model(i) {
1156
+ return k(i);
1124
1157
  },
1125
- roles: Ut(),
1126
- collect: (o, a) => {
1127
- const l = L(o, a);
1128
- return l.data_path = P(o).getDataPath(), l;
1158
+ roles: Pt(),
1159
+ collect: (i, a) => {
1160
+ const l = J(i, a);
1161
+ return l.data_path = k(i).getDataPath(), l;
1129
1162
  },
1130
- list: (o, a) => j(o, a).dataPath(P(o).getDataPath()),
1131
- drive: wt,
1132
- async collects(o) {
1163
+ list: (i, a) => j(i, a).dataPath(k(i).getDataPath()),
1164
+ drive: Ft,
1165
+ async collects(i) {
1133
1166
  const a = {}, l = {};
1134
- for (const d in o) {
1135
- const _ = o[d].getQueryPayload();
1167
+ for (const d in i) {
1168
+ const _ = i[d].getQueryPayload();
1136
1169
  l[d] = _.data_path, a[d] = {};
1137
- const F = _.data_path.split(".");
1138
- let w = F[F.length - 1], m = a[d];
1139
- for (const C of F) {
1140
- if (C === w) {
1170
+ const w = _.data_path.split(".");
1171
+ let F = w[w.length - 1], m = a[d];
1172
+ for (const C of w) {
1173
+ if (C === F) {
1141
1174
  m[C] = _.query;
1142
1175
  break;
1143
1176
  }
1144
1177
  m[C] = m[C] || {};
1145
1178
  }
1146
- a[d].__aliasFor = F[0];
1179
+ a[d].__aliasFor = w[0];
1147
1180
  }
1148
1181
  const h = await y(a);
1149
- for (const d in o) {
1182
+ for (const d in i) {
1150
1183
  const _ = l[d].split(".");
1151
- let F = _[_.length - 1], w = h[d];
1184
+ let w = _[_.length - 1], F = h[d];
1152
1185
  for (const m of _) {
1153
- if (m === F) {
1154
- o[d]._batchData = h[d][m];
1186
+ if (m === w) {
1187
+ i[d]._batchData = h[d][m];
1155
1188
  break;
1156
1189
  }
1157
- w[m] = w[m] || {};
1190
+ F[m] = F[m] || {};
1158
1191
  }
1159
1192
  }
1160
- return o;
1193
+ return i;
1161
1194
  }
1162
1195
  };
1163
1196
  return Y(n), n;
1164
- }, ae = j;
1197
+ }, ue = j;
1165
1198
  export {
1166
1199
  D as arrayHasFile,
1167
1200
  ft as auth,
1168
- it as changeExpiredPassword,
1169
- ee as clearModels,
1170
- ie as createClient,
1171
- L as createCollection,
1172
- It as createFileFromBase64,
1173
- Kt as createFileFromBase85,
1201
+ ot as changeExpiredPassword,
1202
+ ne as clearModels,
1203
+ ce as createClient,
1204
+ J as createCollection,
1205
+ te as createFileFromBase64,
1206
+ ee as createFileFromBase85,
1174
1207
  B as createFileFromString,
1175
1208
  j as createList,
1176
- kt as createRole,
1177
- Ft as createUser,
1209
+ Ut as createRole,
1210
+ wt as createUser,
1178
1211
  G as defaultUserFields,
1179
- T as defineModel,
1180
- re as defineModels,
1181
- Pt as deleteRole,
1212
+ L as defineModel,
1213
+ ie as defineModels,
1214
+ kt as deleteRole,
1182
1215
  bt as deleteUser,
1183
1216
  ct as forgetPassword,
1184
- oe as fs,
1217
+ le as fs,
1185
1218
  M as getApiClient,
1186
- Vt as getApiClientOptional,
1219
+ xt as getApiClientOptional,
1187
1220
  Ct as getConfig,
1188
1221
  st as getCurrentUser,
1189
- wt as getDrive,
1222
+ Ft as getDrive,
1190
1223
  pt as getGrantedRights,
1191
- P as getModel,
1192
- xt as hasModel,
1224
+ k as getModel,
1225
+ re as hasModel,
1193
1226
  ht as isGranted,
1194
- ae as list,
1195
- ne as listDrives,
1227
+ ue as list,
1228
+ ae as listDrives,
1196
1229
  dt as listFiles,
1197
1230
  yt as listFolders,
1198
- te as listModels,
1199
- se as listPermissions,
1231
+ se as listModels,
1232
+ oe as listPermissions,
1200
1233
  jt as listRoles,
1201
1234
  At as listUsers,
1202
1235
  nt as login,
1203
- ot as logout,
1236
+ it as logout,
1204
1237
  f as mutation,
1205
1238
  N as objectHasFile,
1206
1239
  y as query,
@@ -1208,7 +1241,7 @@ export {
1208
1241
  lt as resetPassword,
1209
1242
  Et as sendMail,
1210
1243
  Y as setApiClient,
1211
- Ht as toQuery,
1244
+ Zt as toQuery,
1212
1245
  at as updatePassword,
1213
1246
  Ot as updateUser,
1214
1247
  ut as verifyCode,