@hostlink/light 3.0.4 → 3.0.6

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,93 +1,121 @@
1
- import { jsonToGraphQLQuery as q, VariableType as F } from "json-to-graphql-query";
2
- import H from "axios";
3
- import E from "collect.js";
4
- function M(t) {
1
+ import { jsonToGraphQLQuery as B, VariableType as b } from "json-to-graphql-query";
2
+ import X from "axios";
3
+ import S from "collect.js";
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
- function S(t, e, r = ".", n) {
11
- if (!M(e))
12
- return S(t, {}, r, n);
10
+ function v(t, e, r = ".", n) {
11
+ if (!U(e))
12
+ return v(t, {}, r, n);
13
13
  const i = Object.assign({}, e);
14
- for (const f in t) {
15
- if (f === "__proto__" || f === "constructor")
14
+ for (const h in t) {
15
+ if (h === "__proto__" || h === "constructor")
16
16
  continue;
17
- const a = t[f];
18
- a != null && (n && n(i, f, a, r) || (Array.isArray(a) && Array.isArray(i[f]) ? i[f] = [...a, ...i[f]] : M(a) && M(i[f]) ? i[f] = S(
19
- a,
20
- i[f],
21
- (r ? `${r}.` : "") + f.toString(),
17
+ const l = t[h];
18
+ l != null && (n && n(i, h, l, r) || (Array.isArray(l) && Array.isArray(i[h]) ? i[h] = [...l, ...i[h]] : U(l) && U(i[h]) ? i[h] = v(
19
+ l,
20
+ i[h],
21
+ (r ? `${r}.` : "") + h.toString(),
22
22
  n
23
- ) : i[f] = a));
23
+ ) : i[h] = l));
24
24
  }
25
25
  return i;
26
26
  }
27
- function X(t) {
27
+ function Y(t) {
28
28
  return (...e) => (
29
29
  // eslint-disable-next-line unicorn/no-array-reduce
30
- e.reduce((r, n) => S(r, n, "", t), {})
30
+ e.reduce((r, n) => v(r, n, "", t), {})
31
31
  );
32
32
  }
33
- const A = X();
34
- let k = null;
35
- const Y = (t) => {
36
- k = t;
37
- }, N = () => {
38
- if (!k)
33
+ const F = Y();
34
+ let j = null;
35
+ const Z = (t) => {
36
+ j = t;
37
+ }, M = () => {
38
+ if (!j)
39
39
  throw new Error("Api client not initialized. Call setApiClient() first.");
40
- return k;
41
- }, qt = () => k;
42
- function j(t) {
40
+ return j;
41
+ }, Jt = () => j;
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 B(t) {
48
+ function N(t) {
49
49
  for (let e in t)
50
- if (t[e] instanceof File || t[e] instanceof Array && j(t[e]))
50
+ if (t[e] instanceof File || t[e] instanceof Array && D(t[e]))
51
51
  return !0;
52
52
  return !1;
53
53
  }
54
- function J(t, e, r, n, i) {
54
+ function V(t) {
55
+ t = "<~" + t + "~>";
56
+ var e, r, n, i, h, l = String, u = 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, n = [], i = 0, h = t.length; h > 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), n.push(u & r >> 24, u & r >> 16, u & r >> 8, u & r);
58
+ return (function(s, o) {
59
+ for (var c = o; c > 0; c--) s.pop();
60
+ })(n, e.length), l.fromCharCode.apply(l, n);
61
+ }
62
+ const J = (t = "") => {
63
+ const e = t, r = (n = "application/octet-stream") => {
64
+ const i = new Uint8Array(e.length);
65
+ for (let u = 0; u < e.length; u++)
66
+ i[u] = e.charCodeAt(u);
67
+ const h = new Blob([i], { type: n });
68
+ return URL.createObjectURL(h);
69
+ };
70
+ return {
71
+ getContent: () => e,
72
+ getURL: r,
73
+ download: (n) => {
74
+ const i = document.createElement("a");
75
+ i.download = n, i.href = r(), document.body.appendChild(i), i.click(), document.body.removeChild(i);
76
+ },
77
+ open: (n) => {
78
+ window.open(r(n), "_blank");
79
+ }
80
+ };
81
+ }, Lt = (t) => J(atob(t)), Qt = (t) => J(V(t));
82
+ function L(t, e, r, n, i) {
55
83
  if (!(!t || typeof t != "object"))
56
- for (let f in t) {
57
- const a = t[f];
58
- if (a && typeof a == "object") {
59
- if ("__args" in a) {
60
- const u = a.__args, s = {};
84
+ for (let h in t) {
85
+ const l = t[h];
86
+ if (l && typeof l == "object") {
87
+ if ("__args" in l) {
88
+ const u = l.__args, s = {};
61
89
  Object.entries(u).forEach(([o, c]) => {
62
- if (c instanceof Array && j(c)) {
63
- s[o] = new F(o);
64
- let l = 0;
65
- c.forEach((h) => {
66
- h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + l), n.append(i.current.toString(), h), i.current++, l++);
90
+ if (c instanceof Array && D(c)) {
91
+ s[o] = new b(o);
92
+ let a = 0;
93
+ c.forEach((p) => {
94
+ p instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + a), n.append(i.current.toString(), p), i.current++, a++);
67
95
  }), e[o] = "[Upload!]!";
68
- } else c instanceof File ? (s[o] = new F(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[o] = {}, Object.entries(c).forEach(([l, h]) => {
69
- if (h instanceof Array && j(h)) {
70
- s[o][l] = new F(l);
71
- let _ = 0;
72
- h.forEach((g) => {
73
- g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
74
- }), e[l] = "[Upload!]!";
75
- } else h instanceof File ? (s[o][l] = new F(l), r[i.current] = ["variables." + l], n.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : s[o][l] = h;
96
+ } else c instanceof File ? (s[o] = new b(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && N(c) ? (s[o] = {}, Object.entries(c).forEach(([a, p]) => {
97
+ if (p instanceof Array && D(p)) {
98
+ s[o][a] = new b(a);
99
+ let d = 0;
100
+ p.forEach((_) => {
101
+ _ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + a + "." + d), n.append(i.current.toString(), _), i.current++, d++);
102
+ }), e[a] = "[Upload!]!";
103
+ } else p instanceof File ? (s[o][a] = new b(a), r[i.current] = ["variables." + a], n.append(i.current.toString(), p), e[a] = "Upload!", i.current++) : s[o][a] = p;
76
104
  })) : c != null && (s[o] = c);
77
- }), a.__args = s;
105
+ }), l.__args = s;
78
106
  }
79
- J(a, e, r, n, i);
107
+ L(l, e, r, n, i);
80
108
  }
81
109
  }
82
110
  }
83
111
  const y = async (t) => {
84
- const e = N(), r = t, n = new FormData();
112
+ const e = M(), r = t, n = new FormData();
85
113
  let i = !1;
86
- const f = {}, a = {};
87
- J(r, f, a, n, { current: 0 }), i = Object.keys(f).length > 0, i && (r.__variables = f);
114
+ const h = {}, l = {};
115
+ L(r, h, l, n, { current: 0 }), i = Object.keys(h).length > 0, i && (r.__variables = h);
88
116
  let s = null;
89
- const c = q({ query: r });
90
- if (i ? (n.append("map", JSON.stringify(a)), n.append("operations", JSON.stringify({
117
+ const c = B({ query: r });
118
+ if (i ? (n.append("map", JSON.stringify(l)), n.append("operations", JSON.stringify({
91
119
  query: c
92
120
  })), s = await e.axios.post("", n)) : s = await e.axios.post("", {
93
121
  query: c
@@ -95,9 +123,9 @@ const y = async (t) => {
95
123
  throw new Error(s.data.errors[0].message);
96
124
  return s.data.data;
97
125
  };
98
- function C(t, e) {
99
- let r, n = [], i, f;
100
- const a = (s) => !s || typeof s != "object" ? !1 : Object.values(s).some((o) => o && typeof o == "object" && Object.keys(o).some((c) => c.startsWith("_"))), u = () => n.length === 0 ? (n.unshift({}), n[0]) : (a(n[0]) && n.unshift({}), n[0]);
126
+ function k(t, e) {
127
+ let r, n = [], i, h;
128
+ const l = (s) => !s || typeof s != "object" ? !1 : Object.values(s).some((o) => o && typeof o == "object" && Object.keys(o).some((c) => c.startsWith("_"))), u = () => n.length === 0 ? (n.unshift({}), n[0]) : (l(n[0]) && n.unshift({}), n[0]);
101
129
  return {
102
130
  first() {
103
131
  return this.fetchFirst();
@@ -111,26 +139,26 @@ function C(t, e) {
111
139
  },
112
140
  async fetchWithMeta() {
113
141
  let o = await y(this.toQuery(!0));
114
- if (f) {
115
- const c = f.split(".");
116
- for (const l of c)
117
- o = o[l];
142
+ if (h) {
143
+ const c = h.split(".");
144
+ for (const a of c)
145
+ o = o[a];
118
146
  return o;
119
147
  }
120
148
  return o[`list${t}`];
121
149
  },
122
150
  async fetch() {
123
151
  let o = await y(this.toQuery());
124
- if (f) {
125
- const c = f.split(".");
126
- for (const l of c)
127
- o = o[l];
152
+ if (h) {
153
+ const c = h.split(".");
154
+ for (const a of c)
155
+ o = o[a];
128
156
  return o.data;
129
157
  }
130
158
  return o[`list${t}`].data;
131
159
  },
132
160
  dataPath(s) {
133
- return s && typeof s == "string" && (f = s), this;
161
+ return s && typeof s == "string" && (h = s), this;
134
162
  },
135
163
  sort(s) {
136
164
  return s && typeof s == "string" && (i = s), this;
@@ -142,7 +170,7 @@ function C(t, e) {
142
170
  // where('key', value) -> exact match
143
171
  // where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
144
172
  where(s, o, c) {
145
- const l = (h, _, g) => {
173
+ const a = (p, d, _) => {
146
174
  const O = {
147
175
  ">": "_gt",
148
176
  "<": "_lt",
@@ -151,14 +179,14 @@ function C(t, e) {
151
179
  "!=": "_ne",
152
180
  in: "_in",
153
181
  contains: "_contains"
154
- }[_];
155
- O && n.push({ [h]: { [O]: g } });
182
+ }[d];
183
+ O && n.push({ [p]: { [O]: _ } });
156
184
  };
157
185
  if (c !== void 0)
158
- l(s, String(o), c);
186
+ a(s, String(o), c);
159
187
  else {
160
- const h = u(), _ = A(h, { [s]: o });
161
- n[0] = _;
188
+ const p = u(), d = F(p, { [s]: o });
189
+ n[0] = d;
162
190
  }
163
191
  return this;
164
192
  },
@@ -166,8 +194,8 @@ function C(t, e) {
166
194
  // If the same field is used multiple times, it merges them into an array
167
195
  whereContains(s, o) {
168
196
  if (s && typeof s == "string") {
169
- const c = u(), l = { _contains: o };
170
- c[s] ? Array.isArray(c[s]) ? c[s].push(l) : c[s] = [c[s], l] : c[s] = [l], n[0] = c;
197
+ const c = u(), a = { _contains: o };
198
+ c[s] ? Array.isArray(c[s]) ? c[s].push(a) : c[s] = [c[s], a] : c[s] = [a], n[0] = c;
171
199
  }
172
200
  return this;
173
201
  },
@@ -176,46 +204,46 @@ function C(t, e) {
176
204
  // If the same field is used multiple times, it merges them into an array
177
205
  whereIn(s, o) {
178
206
  if (s && typeof s == "string" && Array.isArray(o)) {
179
- const c = u(), l = { _in: o };
180
- c[s] ? Array.isArray(c[s]) ? c[s].push(l) : c[s] = [c[s], l] : c[s] = [l], n[0] = c;
207
+ const c = u(), a = { _in: o };
208
+ c[s] ? Array.isArray(c[s]) ? c[s].push(a) : c[s] = [c[s], a] : c[s] = [a], n[0] = c;
181
209
  }
182
210
  return this;
183
211
  },
184
212
  // whereBetween adds a _between filter for a specific field
185
213
  whereBetween(s, o, c) {
186
214
  if (s && typeof s == "string") {
187
- const l = u(), h = { _between: [o, c] };
188
- l[s] ? Array.isArray(l[s]) ? l[s].push(h) : l[s] = [l[s], h] : l[s] = h, n[0] = l;
215
+ const a = u(), p = { _between: [o, c] };
216
+ a[s] ? Array.isArray(a[s]) ? a[s].push(p) : a[s] = [a[s], p] : a[s] = p, n[0] = a;
189
217
  }
190
218
  return this;
191
219
  },
192
220
  // limit sets paging/limit for the data selection
193
221
  limit(s) {
194
- return typeof s == "number" && Number.isFinite(s) && (r = A(r || {}, { limit: s })), this;
222
+ return typeof s == "number" && Number.isFinite(s) && (r = F(r || {}, { limit: s })), this;
195
223
  },
196
224
  // offset sets the starting index for the data selection
197
225
  offset(s) {
198
- return typeof s == "number" && Number.isFinite(s) && (r = A(r || {}, { offset: s })), this;
226
+ return typeof s == "number" && Number.isFinite(s) && (r = F(r || {}, { offset: s })), this;
199
227
  },
200
228
  toQuery(s = !1) {
201
229
  let o;
202
- const c = n.length > 0 && Object.keys(n[0] || {}).length > 0, l = c ? 1 : 0, h = n.length > l;
203
- c && h ? o = n : h ? o = n.slice(l) : c && (o = n[0]);
204
- const _ = A(
230
+ const c = n.length > 0 && Object.keys(n[0] || {}).length > 0, a = c ? 1 : 0, p = n.length > a;
231
+ c && p ? o = n : p ? o = n.slice(a) : c && (o = n[0]);
232
+ const d = F(
205
233
  i ? { sort: i } : {},
206
234
  o ? { filters: o } : {}
207
- ), g = {
235
+ ), _ = {
208
236
  data: {
209
237
  ...e
210
238
  }
211
239
  };
212
- if (r && (g.data.__args = r), Object.keys(_).length > 0 && (g.__args = _), s && (g.meta = {
240
+ if (r && (_.data.__args = r), Object.keys(d).length > 0 && (_.__args = d), s && (_.meta = {
213
241
  total: !0,
214
242
  key: !0,
215
243
  name: !0
216
- }), f) {
217
- const w = f.split(".");
218
- let O = g;
244
+ }), h) {
245
+ const w = h.split(".");
246
+ let O = _;
219
247
  for (let P = w.length - 1; P >= 0; P--)
220
248
  O = {
221
249
  [w[P]]: O
@@ -223,243 +251,110 @@ function C(t, e) {
223
251
  return O;
224
252
  }
225
253
  return {
226
- [`list${t}`]: g
254
+ [`list${t}`]: _
227
255
  };
228
256
  }
229
257
  };
230
258
  }
231
- const L = (t, e) => {
259
+ const I = (t, e = {}) => {
232
260
  const r = t, n = e;
233
261
  let i = "list" + t;
234
- const f = (a) => n[a] ? n[a] : null;
262
+ const h = (l) => n[l] ? n[l] : null;
235
263
  return {
236
- field: f,
264
+ field: h,
237
265
  $fields: n,
238
- setDataPath(a) {
239
- return i = a, i;
266
+ setDataPath(l) {
267
+ return i = l, i;
240
268
  },
241
269
  getDataPath() {
242
270
  return i;
243
271
  },
244
- gqlFields(a) {
272
+ gqlFields(l) {
245
273
  let u = {};
246
- for (const s of a)
274
+ for (const s of l)
247
275
  if (typeof s == "string") {
248
- const o = f(s);
249
- o && (u = A(u, o.gqlField ? typeof o.gqlField == "string" ? { [o.gqlField]: !0 } : o.gqlField : { [o.name || s]: !0 }));
250
- } else typeof s == "object" && (u = A(u, s));
276
+ const o = h(s);
277
+ o && (u = F(u, o.gqlField ? typeof o.gqlField == "string" ? { [o.gqlField]: !0 } : o.gqlField : { [o.name || s]: !0 }));
278
+ } else typeof s == "object" && (u = F(u, s));
251
279
  return u;
252
280
  },
253
- update(a, u) {
254
- return p({
281
+ update(l, u) {
282
+ return f({
255
283
  ["update" + r]: {
256
- __args: { id: a, data: u }
284
+ __args: { id: l, data: u }
257
285
  }
258
286
  }).then((s) => s["update" + r]);
259
287
  },
260
- async delete(a) {
261
- return p({
288
+ async delete(l) {
289
+ return f({
262
290
  ["delete" + r]: {
263
- __args: { id: a }
291
+ __args: { id: l }
264
292
  }
265
293
  }).then((u) => u["delete" + r]);
266
294
  },
267
- add(a) {
268
- return p({
295
+ add(l) {
296
+ return f({
269
297
  ["add" + r]: {
270
- __args: { data: a }
298
+ __args: { data: l }
271
299
  }
272
300
  }).then((u) => u["add" + r]);
273
301
  },
274
- fields(a) {
302
+ fields(l) {
275
303
  let u = [];
276
- for (let s of a) {
277
- const o = f(s);
304
+ for (let s of l) {
305
+ const o = h(s);
278
306
  o && u.push(o);
279
307
  }
280
308
  return u;
281
309
  },
282
- async get(a, u) {
283
- const s = (await Promise.resolve().then(() => Et)).default, o = s(r, kt(u));
284
- for (const [c, l] of Object.entries(a))
285
- o.where(c, "==", l);
310
+ async get(l, u) {
311
+ const s = (await Promise.resolve().then(() => qt)).default, o = s(r, Ut(u));
312
+ for (const [c, a] of Object.entries(l))
313
+ o.where(c, "==", a);
286
314
  return await o.first();
287
315
  },
288
- list(a) {
289
- let u = a;
316
+ list(l) {
317
+ let u = l;
290
318
  const s = {};
291
- Object.entries(a).forEach(([l]) => {
292
- n[l] && (s[l] = n[l], n[l].gqlField && (delete u[l], u = A(u, n[l].gqlField)), n[l].gql && (u = A(u, n[l].gql), delete u[l]));
319
+ Object.entries(l).forEach(([a]) => {
320
+ n[a] && (s[a] = n[a], n[a].gqlField && (delete u[a], u = F(u, n[a].gqlField)), n[a].gql && (u = F(u, n[a].gql), delete u[a]));
293
321
  });
294
- const o = C(r, u).dataPath(i), c = o.fetch.bind(o);
322
+ const o = k(r, u).dataPath(i), c = o.fetch.bind(o);
295
323
  return {
296
324
  ...o,
297
325
  async fetch() {
298
- return (await c()).map((h) => {
299
- const _ = { ...h };
300
- return Object.entries(s).forEach(([g, w]) => {
301
- w.format && typeof w.format == "function" && (_[g] = w.format(h));
302
- }), _;
326
+ return (await c()).map((p) => {
327
+ const d = { ...p };
328
+ return Object.entries(s).forEach(([_, w]) => {
329
+ w.format && typeof w.format == "function" && (d[_] = w.format(p));
330
+ }), d;
303
331
  });
304
332
  },
305
333
  async fetchFirst() {
306
- const h = await o.fetchFirst.bind(o)();
307
- if (!h) return h;
308
- const _ = { ...h };
309
- return Object.entries(s).forEach(([g, w]) => {
310
- w.format && typeof w.format == "function" && (_[g] = w.format(h));
311
- }), _;
334
+ const p = await o.fetchFirst.bind(o)();
335
+ if (!p) return p;
336
+ const d = { ...p };
337
+ return Object.entries(s).forEach(([_, w]) => {
338
+ w.format && typeof w.format == "function" && (d[_] = w.format(p));
339
+ }), d;
312
340
  }
313
341
  };
314
342
  }
315
343
  };
316
- }, b = {}, v = (t = !1) => {
317
- const e = {};
318
- return {
319
- /**
320
- * 創建新模型
321
- * @param name 模型名稱
322
- * @param fields 模型欄位定義
323
- */
324
- create(r, n) {
325
- const i = L(r, n);
326
- e[r] = i, t && (b[r] = i);
327
- },
328
- /**
329
- * 獲取模型
330
- * @param name 模型名稱
331
- * @returns 模型實例
332
- */
333
- get(r) {
334
- return e[r] || (t && b[r] ? e[r] = b[r] : this.create(r, {})), e[r];
335
- },
336
- /**
337
- * 檢查模型是否存在
338
- * @param name 模型名稱
339
- * @returns 是否存在
340
- */
341
- has(r) {
342
- return !!e[r] || t && !!b[r];
343
- },
344
- /**
345
- * 列出所有模型名稱
346
- * @returns 模型名稱陣列
347
- */
348
- list() {
349
- const r = Object.keys(e), n = t ? Object.keys(b) : [];
350
- return [.../* @__PURE__ */ new Set([...r, ...n])];
351
- },
352
- /**
353
- * 清除所有模型
354
- */
355
- clear() {
356
- Object.keys(e).forEach((r) => delete e[r]);
357
- }
358
- };
359
- }, Nt = () => {
360
- const t = v(!1);
361
- return {
362
- // 暴露完整的管理器
363
- manager: t,
364
- // 便利方法 - 直接暴露常用功能
365
- createModel: t.create,
366
- getModel: t.get,
367
- hasModel: t.has,
368
- listModels: t.list,
369
- clearModels: t.clear,
370
- /**
371
- * 快速創建並獲取模型
372
- * @param name 模型名稱
373
- * @param fields 模型欄位定義
374
- * @returns 模型實例
375
- */
376
- defineModel(e, r) {
377
- return t.create(e, r), t.get(e);
378
- },
379
- /**
380
- * 批量創建模型
381
- * @param models 模型定義對象
382
- */
383
- defineModels(e) {
384
- Object.entries(e).forEach(([r, n]) => {
385
- t.create(r, n);
386
- });
387
- }
388
- };
389
- }, Bt = () => {
390
- const t = v(!0);
391
- return {
392
- // 暴露完整的管理器
393
- manager: t,
394
- // 便利方法 - 直接暴露常用功能
395
- createModel: t.create,
396
- getModel: t.get,
397
- hasModel: t.has,
398
- listModels: t.list,
399
- clearModels: t.clear,
400
- /**
401
- * 快速創建並獲取模型
402
- * @param name 模型名稱
403
- * @param fields 模型欄位定義
404
- * @returns 模型實例
405
- */
406
- defineModel(e, r) {
407
- return t.create(e, r), t.get(e);
408
- },
409
- /**
410
- * 批量創建模型
411
- * @param models 模型定義對象
412
- */
413
- defineModels(e) {
414
- Object.entries(e).forEach(([r, n]) => {
415
- t.create(r, n);
416
- });
417
- }
418
- };
419
- }, Jt = () => ({
420
- /**
421
- * 創建全域模型
422
- * @param name 模型名稱
423
- * @param fields 模型欄位定義
424
- */
425
- define(t, e) {
426
- const r = L(t, e);
427
- return b[t] = r, r;
428
- },
429
- /**
430
- * 獲取全域模型
431
- * @param name 模型名稱
432
- * @returns 模型實例
433
- */
434
- get(t) {
435
- return b[t];
436
- },
437
- /**
438
- * 檢查全域模型是否存在
439
- * @param name 模型名稱
440
- * @returns 是否存在
441
- */
442
- has(t) {
443
- return !!b[t];
444
- },
445
- /**
446
- * 列出所有全域模型
447
- * @returns 模型名稱陣列
448
- */
449
- list() {
450
- return Object.keys(b);
451
- },
452
- /**
453
- * 清除所有全域模型
454
- */
455
- clear() {
456
- Object.keys(b).forEach((t) => delete b[t]);
457
- }
458
- }), Lt = () => y({
344
+ }, A = {}, Q = (t, e) => {
345
+ const r = I(t, e);
346
+ return A[t] = r, r;
347
+ }, E = (t) => A[t] ? A[t] : Q(t, {}), Tt = (t) => !!A[t], $t = () => Object.keys(A), Gt = () => {
348
+ Object.keys(A).forEach((t) => delete A[t]);
349
+ }, Rt = (t) => {
350
+ Object.entries(t).forEach(([e, r]) => {
351
+ Q(e, r);
352
+ });
353
+ }, Wt = () => y({
459
354
  app: {
460
355
  permissions: !0
461
356
  }
462
- }).then((t) => t.app.permissions), Q = async () => {
357
+ }).then((t) => t.app.permissions), T = async () => {
463
358
  const { app: t } = await y({
464
359
  app: {
465
360
  auth: {
@@ -468,7 +363,7 @@ const L = (t, e) => {
468
363
  }
469
364
  }), e = t.auth.webAuthnRequestOptions, r = PublicKeyCredential.parseRequestOptionsFromJSON(e);
470
365
  return await navigator.credentials.get({ publicKey: r });
471
- }, T = async () => {
366
+ }, $ = async () => {
472
367
  const { app: t } = await y({
473
368
  app: {
474
369
  auth: {
@@ -477,31 +372,31 @@ const L = (t, e) => {
477
372
  }
478
373
  }), e = PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);
479
374
  return await navigator.credentials.create({ publicKey: e });
480
- }, Z = async () => {
481
- const t = await Q();
482
- return await p({
375
+ }, K = async () => {
376
+ const t = await T();
377
+ return await f({
483
378
  webAuthnAssertion: {
484
379
  __args: {
485
380
  assertion: t.toJSON()
486
381
  }
487
382
  }
488
383
  }).then((e) => e.webAuthnAssertion);
489
- }, V = async () => {
490
- const t = await T();
491
- return await p({
384
+ }, x = async () => {
385
+ const t = await $();
386
+ return await f({
492
387
  webAuthnRegister: {
493
388
  __args: {
494
389
  registration: t.toJSON()
495
390
  }
496
391
  }
497
392
  }).then((e) => e.webAuthnRegister);
498
- }, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
393
+ }, tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
499
394
  __proto__: null,
500
- assertion: Q,
501
- attestation: T,
502
- login: Z,
503
- register: V
504
- }, Symbol.toStringTag, { value: "Module" })), I = (t = W) => y({ my: t }).then((e) => e.my), x = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((n) => n.login), tt = () => p({ logout: !0 }).then((t) => t.logout), et = (t, e, r) => p({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((n) => n.changeExpiredPassword), rt = (t, e) => p({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), st = (t, e, r) => p({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((n) => n.resetPassword), nt = (t, e) => p({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), ot = (t, e) => p({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), it = (t) => y({
395
+ assertion: T,
396
+ attestation: $,
397
+ login: K,
398
+ register: x
399
+ }, Symbol.toStringTag, { value: "Module" })), et = (t = W) => y({ my: t }).then((e) => e.my), rt = (t, e, r = "") => f({ login: { __args: { username: t, password: e, code: r } } }).then((n) => n.login), st = () => f({ logout: !0 }).then((t) => t.logout), nt = (t, e, r) => f({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((n) => n.changeExpiredPassword), ot = (t, e) => f({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), it = (t, e, r) => f({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((n) => n.resetPassword), at = (t, e) => f({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), ct = (t, e) => f({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), lt = (t) => y({
505
400
  my: {
506
401
  granted: {
507
402
  __args: {
@@ -509,7 +404,7 @@ const L = (t, e) => {
509
404
  }
510
405
  }
511
406
  }
512
- }).then((e) => e.my.granted), at = (t) => y({
407
+ }).then((e) => e.my.granted), ut = (t) => y({
513
408
  my: {
514
409
  grantedRights: {
515
410
  __args: {
@@ -517,40 +412,40 @@ const L = (t, e) => {
517
412
  }
518
413
  }
519
414
  }
520
- }).then((e) => e.my.grantedRights), ct = () => ({
521
- getCurrentUser: I,
522
- webAuthn: K,
415
+ }).then((e) => e.my.grantedRights), ht = () => ({
416
+ getCurrentUser: et,
417
+ webAuthn: tt,
523
418
  google: {
524
- unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
525
- login: (t) => p({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
526
- register: (t) => p({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
419
+ unlink: () => f({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
420
+ login: (t) => f({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
421
+ register: (t) => f({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
527
422
  },
528
423
  facebook: {
529
- unlink: () => p({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
530
- login: (t) => p({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
531
- register: (t) => p({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
424
+ unlink: () => f({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
425
+ login: (t) => f({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
426
+ register: (t) => f({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
532
427
  },
533
428
  microsoft: {
534
- unlink: () => p({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
535
- login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
536
- register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
429
+ unlink: () => f({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
430
+ login: (t) => f({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
431
+ register: (t) => f({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
537
432
  },
538
- login: x,
539
- logout: tt,
540
- changeExpiredPassword: et,
541
- updatePassword: rt,
542
- resetPassword: st,
543
- forgetPassword: nt,
544
- verifyCode: ot,
545
- grantedRights: at,
546
- isGranted: it
547
- }), $ = {
433
+ login: rt,
434
+ logout: st,
435
+ changeExpiredPassword: nt,
436
+ updatePassword: ot,
437
+ resetPassword: it,
438
+ forgetPassword: at,
439
+ verifyCode: ct,
440
+ grantedRights: ut,
441
+ isGranted: lt
442
+ }), G = {
548
443
  name: !0,
549
444
  path: !0,
550
445
  size: !0,
551
446
  mime: !0,
552
447
  url: !0
553
- }, lt = (t, e, r = $) => y({
448
+ }, pt = (t, e, r = G) => y({
554
449
  app: {
555
450
  drive: {
556
451
  __args: { index: t },
@@ -560,7 +455,7 @@ const L = (t, e) => {
560
455
  }
561
456
  }
562
457
  }
563
- }).then((n) => n.app.drive.files), ut = (t, e) => y({
458
+ }).then((n) => n.app.drive.files), ft = (t, e) => y({
564
459
  app: {
565
460
  drive: {
566
461
  __args: {
@@ -575,7 +470,7 @@ const L = (t, e) => {
575
470
  }
576
471
  }
577
472
  }).then((r) => r.app.drive?.file?.base64Content), m = (t) => ({
578
- list: (e, r = $) => lt(t, e, r),
473
+ list: (e, r = G) => pt(t, e, r),
579
474
  get: (e, r = {
580
475
  name: !0,
581
476
  path: !0,
@@ -598,7 +493,7 @@ const L = (t, e) => {
598
493
  }
599
494
  }).then((n) => n.app.drive.file),
600
495
  readFileAsBase64(e) {
601
- return ut(t, e);
496
+ return ft(t, e);
602
497
  },
603
498
  read: async (e) => {
604
499
  let r = await y({
@@ -620,14 +515,14 @@ const L = (t, e) => {
620
515
  throw new Error(`File not found or cannot read content: ${e}`);
621
516
  return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
622
517
  },
623
- write: (e, r) => p({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((n) => n.lightDriveWriteFile),
624
- delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
625
- rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
626
- move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((n) => n.lightDriveMoveFile)
627
- }), G = {
518
+ write: (e, r) => f({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((n) => n.lightDriveWriteFile),
519
+ delete: (e) => f({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
520
+ rename: (e, r) => f({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
521
+ move: (e, r) => f({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((n) => n.lightDriveMoveFile)
522
+ }), R = {
628
523
  name: !0,
629
524
  path: !0
630
- }, ht = (t, e, r = G) => y({
525
+ }, dt = (t, e, r = R) => y({
631
526
  app: {
632
527
  drive: {
633
528
  __args: { index: t },
@@ -637,19 +532,19 @@ const L = (t, e) => {
637
532
  }
638
533
  }
639
534
  }
640
- }).then((n) => n.app.drive.folders), D = (t) => ({
641
- list: (e, r = G) => ht(t, e, r),
642
- create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
643
- delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
644
- rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
645
- }), Qt = () => y({
535
+ }).then((n) => n.app.drive.folders), C = (t) => ({
536
+ list: (e, r = R) => dt(t, e, r),
537
+ create: (e) => f({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
538
+ delete: (e) => f({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
539
+ rename: (e, r) => f({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
540
+ }), zt = () => y({
646
541
  app: {
647
542
  drives: {
648
543
  index: !0,
649
544
  name: !0
650
545
  }
651
546
  }
652
- }).then((t) => t.app.drives), ft = (t) => ({
547
+ }).then((t) => t.app.drives), gt = (t) => ({
653
548
  listFiles: m(t).list,
654
549
  getFile: m(t).get,
655
550
  readFile: m(t).read,
@@ -657,11 +552,11 @@ const L = (t, e) => {
657
552
  deleteFile: m(t).delete,
658
553
  renameFile: m(t).rename,
659
554
  moveFile: m(t).move,
660
- listFolders: D(t).list,
661
- createFolder: D(t).create,
662
- deleteFolder: D(t).delete,
663
- renameFolder: D(t).rename,
664
- uploadTempFile: (e) => p({
555
+ listFolders: C(t).list,
556
+ createFolder: C(t).create,
557
+ deleteFolder: C(t).delete,
558
+ renameFolder: C(t).rename,
559
+ uploadTempFile: (e) => f({
665
560
  lightDriveUploadTempFile: {
666
561
  __args: { index: t, file: e },
667
562
  name: !0,
@@ -670,7 +565,7 @@ const L = (t, e) => {
670
565
  mime: !0
671
566
  }
672
567
  }).then((r) => r.lightDriveUploadTempFile),
673
- folders: D(t),
568
+ folders: C(t),
674
569
  files: m(t)
675
570
  }), W = {
676
571
  user_id: !0,
@@ -678,24 +573,24 @@ const L = (t, e) => {
678
573
  first_name: !0,
679
574
  last_name: !0,
680
575
  status: !0
681
- }, pt = (t) => p({
576
+ }, _t = (t) => f({
682
577
  addUser: {
683
578
  __args: t
684
579
  }
685
- }).then((e) => e.addUser), gt = (t) => p({
580
+ }).then((e) => e.addUser), yt = (t) => f({
686
581
  deleteUser: {
687
582
  __args: { id: t }
688
583
  }
689
- }).then((e) => e.deleteUser), dt = (t = W) => C("Users", t).dataPath("app.listUser").fetch(), _t = (t, e) => p({
584
+ }).then((e) => e.deleteUser), wt = (t = W) => k("Users", t).dataPath("app.listUser").fetch(), mt = (t, e) => f({
690
585
  updateUser: {
691
586
  __args: { id: t, data: e }
692
587
  }
693
- }).then((r) => r.updateUser), yt = () => ({
694
- list: dt,
695
- create: pt,
696
- delete: gt,
697
- update: _t
698
- }), wt = (t) => y({
588
+ }).then((r) => r.updateUser), bt = () => ({
589
+ list: wt,
590
+ create: _t,
591
+ delete: yt,
592
+ update: mt
593
+ }), Ft = (t) => y({
699
594
  app: {
700
595
  listConfig: {
701
596
  __args: {
@@ -709,13 +604,13 @@ const L = (t, e) => {
709
604
  }
710
605
  }
711
606
  }
712
- }).then((e) => e.app.listConfig.data[0]?.value), bt = {
607
+ }).then((e) => e.app.listConfig.data[0]?.value), At = {
713
608
  name: !0
714
- }, mt = (t = bt) => y({
609
+ }, Ot = (t = At) => y({
715
610
  app: {
716
611
  roles: t
717
612
  }
718
- }).then((e) => e.app.roles), Ft = (t, e) => p({
613
+ }).then((e) => e.app.roles), Ct = (t, e) => f({
719
614
  addRole: {
720
615
  __args: {
721
616
  data: {
@@ -724,64 +619,64 @@ const L = (t, e) => {
724
619
  }
725
620
  }
726
621
  }
727
- }).then((r) => r.addRole), At = (t) => p({
622
+ }).then((r) => r.addRole), Dt = (t) => f({
728
623
  deleteRole: {
729
624
  __args: { name: t }
730
625
  }
731
- }).then((e) => e.deleteRole), Ot = () => ({
732
- list: mt,
733
- create: Ft,
734
- delete: At
626
+ }).then((e) => e.deleteRole), jt = () => ({
627
+ list: Ot,
628
+ create: Ct,
629
+ delete: Dt
735
630
  });
736
631
  function z(t, e, r, n, i) {
737
632
  if (!(!t || typeof t != "object"))
738
- for (let f in t) {
739
- const a = t[f];
740
- if (a && typeof a == "object") {
741
- if ("__args" in a) {
742
- const u = a.__args, s = {};
633
+ for (let h in t) {
634
+ const l = t[h];
635
+ if (l && typeof l == "object") {
636
+ if ("__args" in l) {
637
+ const u = l.__args, s = {};
743
638
  Object.entries(u).forEach(([o, c]) => {
744
- if (c instanceof Array && j(c)) {
745
- s[o] = new F(o);
746
- let l = 0;
747
- c.forEach((h) => {
748
- h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + l), n.append(i.current.toString(), h), i.current++, l++);
639
+ if (c instanceof Array && D(c)) {
640
+ s[o] = new b(o);
641
+ let a = 0;
642
+ c.forEach((p) => {
643
+ p instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + a), n.append(i.current.toString(), p), i.current++, a++);
749
644
  }), e[o] = "[Upload!]!";
750
- } else c instanceof File ? (s[o] = new F(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[o] = {}, Object.entries(c).forEach(([l, h]) => {
751
- if (h instanceof Array && j(h)) {
752
- s[o][l] = new F(l);
753
- let _ = 0;
754
- h.forEach((g) => {
755
- g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
756
- }), e[l] = "[Upload!]!";
757
- } else h instanceof File ? (s[o][l] = new F(l), r[i.current] = ["variables." + l], n.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : s[o][l] = h;
645
+ } else c instanceof File ? (s[o] = new b(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && N(c) ? (s[o] = {}, Object.entries(c).forEach(([a, p]) => {
646
+ if (p instanceof Array && D(p)) {
647
+ s[o][a] = new b(a);
648
+ let d = 0;
649
+ p.forEach((_) => {
650
+ _ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + a + "." + d), n.append(i.current.toString(), _), i.current++, d++);
651
+ }), e[a] = "[Upload!]!";
652
+ } else p instanceof File ? (s[o][a] = new b(a), r[i.current] = ["variables." + a], n.append(i.current.toString(), p), e[a] = "Upload!", i.current++) : s[o][a] = p;
758
653
  })) : c != null && (s[o] = c);
759
- }), a.__args = s;
654
+ }), l.__args = s;
760
655
  }
761
- z(a, e, r, n, i);
656
+ z(l, e, r, n, i);
762
657
  }
763
658
  }
764
659
  }
765
- const p = async (t) => {
766
- const r = N().axios, n = t, i = new FormData();
767
- let f = !1;
768
- const a = {}, u = {};
769
- z(n, a, u, i, { current: 0 }), f = Object.keys(a).length > 0, f && (n.__variables = a);
660
+ const f = async (t) => {
661
+ const r = M().axios, n = t, i = new FormData();
662
+ let h = !1;
663
+ const l = {}, u = {};
664
+ z(n, l, u, i, { current: 0 }), h = Object.keys(l).length > 0, h && (n.__variables = l);
770
665
  let o = null;
771
- const l = q({ mutation: n });
772
- if (f ? (i.append("map", JSON.stringify(u)), i.append("operations", JSON.stringify({
773
- query: l
666
+ const a = B({ mutation: n });
667
+ if (h ? (i.append("map", JSON.stringify(u)), i.append("operations", JSON.stringify({
668
+ query: a
774
669
  })), o = await r.post("", i)) : o = await r.post("", {
775
- query: l
670
+ query: a
776
671
  }), o.data.errors)
777
672
  throw new Error(o.data.errors[0].message);
778
673
  return o.data.data;
779
- }, Dt = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), jt = {
780
- send: Dt
781
- }, U = (t) => {
674
+ }, kt = (t, e, r) => f({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), Pt = {
675
+ send: kt
676
+ }, q = (t) => {
782
677
  let e = {};
783
678
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
784
- Object.entries(U(r)).forEach(([n, i]) => {
679
+ Object.entries(q(r)).forEach(([n, i]) => {
785
680
  e[n] = i;
786
681
  });
787
682
  }), e) : (Object.entries(t).forEach(([r, n]) => {
@@ -793,9 +688,9 @@ const p = async (t) => {
793
688
  e[r] = n;
794
689
  return;
795
690
  }
796
- e[r] = U(n);
691
+ e[r] = q(n);
797
692
  }), e);
798
- }, kt = (t) => U(t), Ct = "list", Pt = [
693
+ }, Ut = (t) => q(t), Et = "list", St = [
799
694
  "flatMap",
800
695
  "chunk",
801
696
  "shuffle",
@@ -821,7 +716,7 @@ const p = async (t) => {
821
716
  "slice",
822
717
  "tap",
823
718
  "sort"
824
- ], Mt = [
719
+ ], vt = [
825
720
  "avg",
826
721
  "count",
827
722
  "countBy",
@@ -849,7 +744,7 @@ const p = async (t) => {
849
744
  "implode",
850
745
  "partition"
851
746
  ];
852
- class d {
747
+ class g {
853
748
  _batchData = null;
854
749
  data_path = "";
855
750
  filters;
@@ -866,7 +761,7 @@ class d {
866
761
  this.filters = {}, this.steps = [], this.fields = e;
867
762
  }
868
763
  }
869
- d.prototype.getQueryPayload = function() {
764
+ g.prototype.getQueryPayload = function() {
870
765
  let t = {
871
766
  meta: {
872
767
  total: !0,
@@ -880,26 +775,26 @@ d.prototype.getQueryPayload = function() {
880
775
  steps: this.steps
881
776
  };
882
777
  };
883
- d.prototype.dataPath = function(t) {
778
+ g.prototype.dataPath = function(t) {
884
779
  const e = this.clone();
885
780
  return e.data_path = t, e;
886
781
  };
887
- d.prototype.buildArgs = function() {
782
+ g.prototype.buildArgs = function() {
888
783
  let t = {};
889
784
  return Object.keys(this.filters).length > 0 && (t.filters = this.filters), this._sort && (t.sort = this._sort, this._sortDesc && (t.sort += ":desc")), t;
890
785
  };
891
- d.prototype.clone = function() {
786
+ g.prototype.clone = function() {
892
787
  const t = Object.create(this);
893
788
  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;
894
789
  };
895
- E().macro("whereContains", function(t, e) {
790
+ S().macro("whereContains", function(t, e) {
896
791
  return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
897
792
  });
898
- d.prototype.fetchData = async function() {
793
+ g.prototype.fetchData = async function() {
899
794
  try {
900
795
  if (this._batchData) {
901
796
  const u = this._batchData;
902
- return this.meta = u.meta, E(u.data);
797
+ return this.meta = u.meta, S(u.data);
903
798
  }
904
799
  let t = {
905
800
  meta: {
@@ -918,40 +813,40 @@ d.prototype.fetchData = async function() {
918
813
  }
919
814
  n[u] = {}, n = n[u];
920
815
  }
921
- let a = await y(r);
816
+ let l = await y(r);
922
817
  for (const u of e)
923
- a = a[u];
924
- return this.meta = a.meta, E(a.data);
818
+ l = l[u];
819
+ return this.meta = l.meta, S(l.data);
925
820
  } catch (t) {
926
821
  throw console.error("Error fetching collection data:", t), t;
927
822
  }
928
823
  };
929
- d.prototype.processData = async function() {
824
+ g.prototype.processData = async function() {
930
825
  let t = await this.fetchData();
931
826
  for (const e of this.steps)
932
827
  t = t[e.type](...e.args);
933
828
  return t;
934
829
  };
935
- d.prototype.all = async function() {
830
+ g.prototype.all = async function() {
936
831
  return (await this.processData()).all();
937
832
  };
938
- for (const t of Pt)
939
- d.prototype[t] = function(...e) {
833
+ for (const t of St)
834
+ g.prototype[t] = function(...e) {
940
835
  const r = this.clone();
941
836
  return r.steps.push({ type: t, args: e }), r;
942
837
  };
943
- for (const t of Mt)
944
- d.prototype[t] = async function(...e) {
838
+ for (const t of vt)
839
+ g.prototype[t] = async function(...e) {
945
840
  return (await this.clone().processData())[t](...e);
946
841
  };
947
- d.prototype.average = d.prototype.avg;
948
- d.prototype.first = async function() {
842
+ g.prototype.average = g.prototype.avg;
843
+ g.prototype.first = async function() {
949
844
  return this.take(1), (await this.processData()).first();
950
845
  };
951
- d.prototype._handleBatchData = function(t, e) {
846
+ g.prototype._handleBatchData = function(t, e) {
952
847
  return this._batchData ? (this.steps.push({ type: t, args: e }), this) : null;
953
848
  };
954
- d.prototype.where = function(...t) {
849
+ g.prototype.where = function(...t) {
955
850
  const e = this._handleBatchData("where", t);
956
851
  if (e) return e;
957
852
  if (t.length === 2)
@@ -983,169 +878,175 @@ d.prototype.where = function(...t) {
983
878
  }
984
879
  return this;
985
880
  };
986
- d.prototype.whereContains = function(t, e) {
881
+ g.prototype.whereContains = function(t, e) {
987
882
  const r = this._handleBatchData("whereContains", [t, e]);
988
883
  return r || (this.filters[t] = { contains: e }, this);
989
884
  };
990
- d.prototype.forPage = function(t, e) {
885
+ g.prototype.forPage = function(t, e) {
991
886
  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);
992
887
  };
993
- d.prototype.whereIn = function(t, e) {
888
+ g.prototype.whereIn = function(t, e) {
994
889
  const r = this._handleBatchData("whereIn", [t, e]);
995
890
  return r || (this.filters[t] = { in: e }, this);
996
891
  };
997
- d.prototype.whereNotIn = function(t, e) {
892
+ g.prototype.whereNotIn = function(t, e) {
998
893
  const r = this._handleBatchData("whereNotIn", [t, e]);
999
894
  return r || (this.filters[t] = { nin: e }, this);
1000
895
  };
1001
- d.prototype.whereNotBetween = function(t, e) {
896
+ g.prototype.whereNotBetween = function(t, e) {
1002
897
  const r = this._handleBatchData("whereNotBetween", [t, e]);
1003
898
  return r || (this.filters[t] = { notBetween: e }, this);
1004
899
  };
1005
- d.prototype.whereBetween = function(t, e) {
900
+ g.prototype.whereBetween = function(t, e) {
1006
901
  const r = this._handleBatchData("whereBetween", [t, e]);
1007
902
  return r || (this.filters[t] = { between: e }, this);
1008
903
  };
1009
- d.prototype.sortBy = function(t) {
904
+ g.prototype.sortBy = function(t) {
1010
905
  return this.steps.push({ type: "sortBy", args: [t] }), typeof t == "string" && (this._sort = t), this;
1011
906
  };
1012
- d.prototype.sortByDesc = function(t) {
907
+ g.prototype.sortByDesc = function(t) {
1013
908
  return this.steps.push({ type: "sortByDesc", args: [t] }), typeof t == "string" && (this._sort = t, this._sortDesc = !0), this;
1014
909
  };
1015
- d.prototype.skip = function(t) {
910
+ g.prototype.skip = function(t) {
1016
911
  if (t < 0)
1017
912
  throw new Error("Offset must be non-negative");
1018
913
  return this.already_offset && this.steps.push({ type: "skip", args: [t] }), this.offset = t, this.already_offset = !0, this;
1019
914
  };
1020
- d.prototype.take = function(t) {
915
+ g.prototype.take = function(t) {
1021
916
  if (t < 0)
1022
917
  throw new Error("Length must be non-negative");
1023
918
  return this.already_limit ? (this.steps.push({ type: "take", args: [t] }), this) : (this.limit = t, this.already_limit = !0, this);
1024
919
  };
1025
- d.prototype.splice = function(t, e) {
920
+ g.prototype.splice = function(t, e) {
1026
921
  return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
1027
922
  };
1028
- const R = (t, e) => {
1029
- const r = new d(e);
1030
- return r.data_path = Ct + t, r;
1031
- }, Et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
923
+ const H = (t, e) => {
924
+ const r = new g(e);
925
+ return r.data_path = Et + t, r;
926
+ }, qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1032
927
  __proto__: null,
1033
- default: R
1034
- }, Symbol.toStringTag, { value: "Module" })), Tt = (t) => {
928
+ default: H
929
+ }, Symbol.toStringTag, { value: "Module" })), Ht = (t) => {
1035
930
  const e = typeof window > "u";
1036
931
  let r = [];
1037
- const n = H.create({
932
+ const n = X.create({
1038
933
  baseURL: t,
1039
934
  withCredentials: !0
1040
935
  });
1041
- e && (n.interceptors.request.use((a) => (a.withCredentials = !0, r.length > 0 && (a.headers.Cookie = r.join("; ")), a)), n.interceptors.response.use((a) => {
1042
- if (a.headers["set-cookie"]) {
1043
- const u = a.headers["set-cookie"].map((o) => o.split(";")[0]), s = /* @__PURE__ */ new Map();
1044
- r.forEach((o) => {
1045
- const c = o.split("=")[0];
1046
- s.set(c, o);
1047
- }), u.forEach((o) => {
1048
- const c = o.split("=")[0];
1049
- s.set(c, o);
1050
- }), r = Array.from(s.values());
936
+ e && (n.interceptors.request.use((h) => (h.withCredentials = !0, r.length > 0 && (h.headers.Cookie = r.join("; ")), h)), n.interceptors.response.use((h) => {
937
+ if (h.headers["set-cookie"]) {
938
+ const l = h.headers["set-cookie"].map((s) => s.split(";")[0]), u = /* @__PURE__ */ new Map();
939
+ r.forEach((s) => {
940
+ const o = s.split("=")[0];
941
+ u.set(o, s);
942
+ }), l.forEach((s) => {
943
+ const o = s.split("=")[0];
944
+ u.set(o, s);
945
+ }), r = Array.from(u.values());
1051
946
  }
1052
- return a;
947
+ return h;
1053
948
  }));
1054
- const i = v(), f = {
949
+ const i = {
1055
950
  post: n.post,
1056
951
  baseURL: t,
1057
952
  axios: n,
1058
- auth: ct(),
1059
- mutation: p,
953
+ auth: ht(),
954
+ mutation: f,
1060
955
  query: y,
1061
- config: wt,
1062
- mail: jt,
1063
- users: yt(),
1064
- models: i,
1065
- model(a) {
1066
- return i.get(a);
956
+ config: Ft,
957
+ mail: Pt,
958
+ users: bt(),
959
+ model(h) {
960
+ return E(h);
1067
961
  },
1068
- roles: Ot(),
1069
- collect: (a, u) => {
1070
- const s = R(a, u);
1071
- return s.data_path = i.get(a).getDataPath(), s;
962
+ roles: jt(),
963
+ collect: (h, l) => {
964
+ const u = H(h, l);
965
+ return u.data_path = E(h).getDataPath(), u;
1072
966
  },
1073
- list: (a, u) => C(a, u).dataPath(i.get(a).getDataPath()),
1074
- drive: ft,
1075
- async collects(a) {
1076
- const u = {}, s = {};
1077
- for (const c in a) {
1078
- const l = a[c].getQueryPayload();
1079
- s[c] = l.data_path, u[c] = {};
1080
- const h = l.data_path.split(".");
1081
- let _ = h[h.length - 1], g = u[c];
1082
- for (const w of h) {
1083
- if (w === _) {
1084
- g[w] = l.query;
967
+ list: (h, l) => k(h, l).dataPath(E(h).getDataPath()),
968
+ drive: gt,
969
+ async collects(h) {
970
+ const l = {}, u = {};
971
+ for (const o in h) {
972
+ const c = h[o].getQueryPayload();
973
+ u[o] = c.data_path, l[o] = {};
974
+ const a = c.data_path.split(".");
975
+ let p = a[a.length - 1], d = l[o];
976
+ for (const _ of a) {
977
+ if (_ === p) {
978
+ d[_] = c.query;
1085
979
  break;
1086
980
  }
1087
- g[w] = g[w] || {};
981
+ d[_] = d[_] || {};
1088
982
  }
1089
- u[c].__aliasFor = h[0];
983
+ l[o].__aliasFor = a[0];
1090
984
  }
1091
- const o = await y(u);
1092
- for (const c in a) {
1093
- const l = s[c].split(".");
1094
- let h = l[l.length - 1], _ = o[c];
1095
- for (const g of l) {
1096
- if (g === h) {
1097
- a[c]._batchData = o[c][g];
985
+ const s = await y(l);
986
+ for (const o in h) {
987
+ const c = u[o].split(".");
988
+ let a = c[c.length - 1], p = s[o];
989
+ for (const d of c) {
990
+ if (d === a) {
991
+ h[o]._batchData = s[o][d];
1098
992
  break;
1099
993
  }
1100
- _[g] = _[g] || {};
994
+ p[d] = p[d] || {};
1101
995
  }
1102
996
  }
1103
- return a;
997
+ return h;
1104
998
  }
1105
999
  };
1106
- return Y(f), f;
1107
- }, $t = C;
1000
+ return Z(i), i;
1001
+ }, Xt = k;
1108
1002
  export {
1109
- ct as auth,
1110
- et as changeExpiredPassword,
1111
- Tt as createClient,
1112
- R as createCollection,
1113
- C as createList,
1114
- v as createModelManager,
1115
- Ft as createRole,
1116
- pt as createUser,
1003
+ D as arrayHasFile,
1004
+ ht as auth,
1005
+ nt as changeExpiredPassword,
1006
+ Gt as clearModels,
1007
+ Ht as createClient,
1008
+ H as createCollection,
1009
+ Lt as createFileFromBase64,
1010
+ Qt as createFileFromBase85,
1011
+ J as createFileFromString,
1012
+ k as createList,
1013
+ Ct as createRole,
1014
+ _t as createUser,
1117
1015
  W as defaultUserFields,
1118
- At as deleteRole,
1119
- gt as deleteUser,
1120
- nt as forgetPassword,
1121
- N as getApiClient,
1122
- qt as getApiClientOptional,
1123
- wt as getConfig,
1124
- I as getCurrentUser,
1125
- ft as getDrive,
1126
- at as getGrantedRights,
1127
- it as isGranted,
1128
- $t as list,
1129
- Qt as listDrives,
1130
- lt as listFiles,
1131
- ht as listFolders,
1132
- Lt as listPermissions,
1133
- mt as listRoles,
1134
- dt as listUsers,
1135
- x as login,
1136
- tt as logout,
1137
- p as mutation,
1016
+ Q as defineModel,
1017
+ Rt as defineModels,
1018
+ Dt as deleteRole,
1019
+ yt as deleteUser,
1020
+ at as forgetPassword,
1021
+ M as getApiClient,
1022
+ Jt as getApiClientOptional,
1023
+ Ft as getConfig,
1024
+ et as getCurrentUser,
1025
+ gt as getDrive,
1026
+ ut as getGrantedRights,
1027
+ E as getModel,
1028
+ Tt as hasModel,
1029
+ lt as isGranted,
1030
+ Xt as list,
1031
+ zt as listDrives,
1032
+ pt as listFiles,
1033
+ dt as listFolders,
1034
+ $t as listModels,
1035
+ Wt as listPermissions,
1036
+ Ot as listRoles,
1037
+ wt as listUsers,
1038
+ rt as login,
1039
+ st as logout,
1040
+ f as mutation,
1041
+ N as objectHasFile,
1138
1042
  y as query,
1139
- ut as readFileAsBase64,
1140
- st as resetPassword,
1141
- Dt as sendMail,
1142
- Y as setApiClient,
1143
- kt as toQuery,
1144
- rt as updatePassword,
1145
- _t as updateUser,
1146
- Bt as useGlobalModel,
1147
- Jt as useGlobalModels,
1148
- Nt as useModel,
1149
- ot as verifyCode,
1150
- K as webAuthn
1043
+ ft as readFileAsBase64,
1044
+ it as resetPassword,
1045
+ kt as sendMail,
1046
+ Z as setApiClient,
1047
+ Ut as toQuery,
1048
+ ot as updatePassword,
1049
+ mt as updateUser,
1050
+ ct as verifyCode,
1051
+ tt as webAuthn
1151
1052
  };