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