@hostlink/light 3.0.4 → 3.0.5

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,45 +1,45 @@
1
- import { jsonToGraphQLQuery as q, VariableType as F } from "json-to-graphql-query";
1
+ import { jsonToGraphQLQuery as M, VariableType as b } from "json-to-graphql-query";
2
2
  import H from "axios";
3
- import E from "collect.js";
4
- function M(t) {
3
+ import S from "collect.js";
4
+ function E(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 = ".", o) {
11
+ if (!E(e))
12
+ return v(t, {}, r, o);
13
13
  const i = Object.assign({}, e);
14
- for (const f in t) {
15
- if (f === "__proto__" || f === "constructor")
14
+ for (const u in t) {
15
+ if (u === "__proto__" || u === "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(),
22
- n
23
- ) : i[f] = a));
17
+ const l = t[u];
18
+ l != null && (o && o(i, u, l, r) || (Array.isArray(l) && Array.isArray(i[u]) ? i[u] = [...l, ...i[u]] : E(l) && E(i[u]) ? i[u] = v(
19
+ l,
20
+ i[u],
21
+ (r ? `${r}.` : "") + u.toString(),
22
+ o
23
+ ) : i[u] = l));
24
24
  }
25
25
  return i;
26
26
  }
27
27
  function X(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, o) => v(r, o, "", t), {})
31
31
  );
32
32
  }
33
- const A = X();
34
- let k = null;
33
+ const F = X();
34
+ let j = null;
35
35
  const Y = (t) => {
36
- k = t;
36
+ j = t;
37
37
  }, N = () => {
38
- if (!k)
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
+ }, Nt = () => j;
42
+ function C(t) {
43
43
  for (let e = 0; e < t.length; e++)
44
44
  if (t[e] instanceof File)
45
45
  return !0;
@@ -47,57 +47,57 @@ function j(t) {
47
47
  }
48
48
  function B(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 && C(t[e]))
51
51
  return !0;
52
52
  return !1;
53
53
  }
54
- function J(t, e, r, n, i) {
54
+ function J(t, e, r, o, i) {
55
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 && 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++);
67
- }), 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;
76
- })) : c != null && (s[o] = c);
77
- }), a.__args = s;
56
+ for (let u in t) {
57
+ const l = t[u];
58
+ if (l && typeof l == "object") {
59
+ if ("__args" in l) {
60
+ const h = l.__args, s = {};
61
+ Object.entries(h).forEach(([n, c]) => {
62
+ if (c instanceof Array && C(c)) {
63
+ s[n] = new b(n);
64
+ let a = 0;
65
+ c.forEach((f) => {
66
+ f instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + n + "." + a), o.append(i.current.toString(), f), i.current++, a++);
67
+ }), e[n] = "[Upload!]!";
68
+ } else c instanceof File ? (s[n] = new b(n), r[i.current] = ["variables." + n], o.append(i.current.toString(), c), e[n] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[n] = {}, Object.entries(c).forEach(([a, f]) => {
69
+ if (f instanceof Array && C(f)) {
70
+ s[n][a] = new b(a);
71
+ let g = 0;
72
+ f.forEach((_) => {
73
+ _ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + a + "." + g), o.append(i.current.toString(), _), i.current++, g++);
74
+ }), e[a] = "[Upload!]!";
75
+ } else f instanceof File ? (s[n][a] = new b(a), r[i.current] = ["variables." + a], o.append(i.current.toString(), f), e[a] = "Upload!", i.current++) : s[n][a] = f;
76
+ })) : c != null && (s[n] = c);
77
+ }), l.__args = s;
78
78
  }
79
- J(a, e, r, n, i);
79
+ J(l, e, r, o, i);
80
80
  }
81
81
  }
82
82
  }
83
83
  const y = async (t) => {
84
- const e = N(), r = t, n = new FormData();
84
+ const e = N(), r = t, o = new FormData();
85
85
  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);
86
+ const u = {}, l = {};
87
+ J(r, u, l, o, { current: 0 }), i = Object.keys(u).length > 0, i && (r.__variables = u);
88
88
  let s = null;
89
- const c = q({ query: r });
90
- if (i ? (n.append("map", JSON.stringify(a)), n.append("operations", JSON.stringify({
89
+ const c = M({ query: r });
90
+ if (i ? (o.append("map", JSON.stringify(l)), o.append("operations", JSON.stringify({
91
91
  query: c
92
- })), s = await e.axios.post("", n)) : s = await e.axios.post("", {
92
+ })), s = await e.axios.post("", o)) : s = await e.axios.post("", {
93
93
  query: c
94
94
  }), s.data.errors)
95
95
  throw new Error(s.data.errors[0].message);
96
96
  return s.data.data;
97
97
  };
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]);
98
+ function k(t, e) {
99
+ let r, o = [], i, u;
100
+ const l = (s) => !s || typeof s != "object" ? !1 : Object.values(s).some((n) => n && typeof n == "object" && Object.keys(n).some((c) => c.startsWith("_"))), h = () => o.length === 0 ? (o.unshift({}), o[0]) : (l(o[0]) && o.unshift({}), o[0]);
101
101
  return {
102
102
  first() {
103
103
  return this.fetchFirst();
@@ -106,43 +106,43 @@ function C(t, e) {
106
106
  return this.fetch();
107
107
  },
108
108
  async fetchFirst() {
109
- const o = await this.limit(1).fetch();
110
- return Array.isArray(o) && o.length > 0 ? o[0] : null;
109
+ const n = await this.limit(1).fetch();
110
+ return Array.isArray(n) && n.length > 0 ? n[0] : null;
111
111
  },
112
112
  async fetchWithMeta() {
113
- 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];
118
- return o;
113
+ let n = await y(this.toQuery(!0));
114
+ if (u) {
115
+ const c = u.split(".");
116
+ for (const a of c)
117
+ n = n[a];
118
+ return n;
119
119
  }
120
- return o[`list${t}`];
120
+ return n[`list${t}`];
121
121
  },
122
122
  async fetch() {
123
- let o = await y(this.toQuery());
124
- if (f) {
125
- const c = f.split(".");
126
- for (const l of c)
127
- o = o[l];
128
- return o.data;
123
+ let n = await y(this.toQuery());
124
+ if (u) {
125
+ const c = u.split(".");
126
+ for (const a of c)
127
+ n = n[a];
128
+ return n.data;
129
129
  }
130
- return o[`list${t}`].data;
130
+ return n[`list${t}`].data;
131
131
  },
132
132
  dataPath(s) {
133
- return s && typeof s == "string" && (f = s), this;
133
+ return s && typeof s == "string" && (u = s), this;
134
134
  },
135
135
  sort(s) {
136
136
  return s && typeof s == "string" && (i = s), this;
137
137
  },
138
138
  filters(s) {
139
- return s && typeof s == "object" && (n = [s]), this;
139
+ return s && typeof s == "object" && (o = [s]), this;
140
140
  },
141
141
  // where can be called as:
142
142
  // where('key', value) -> exact match
143
143
  // where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
144
- where(s, o, c) {
145
- const l = (h, _, g) => {
144
+ where(s, n, c) {
145
+ const a = (f, g, _) => {
146
146
  const O = {
147
147
  ">": "_gt",
148
148
  "<": "_lt",
@@ -151,71 +151,71 @@ function C(t, e) {
151
151
  "!=": "_ne",
152
152
  in: "_in",
153
153
  contains: "_contains"
154
- }[_];
155
- O && n.push({ [h]: { [O]: g } });
154
+ }[g];
155
+ O && o.push({ [f]: { [O]: _ } });
156
156
  };
157
157
  if (c !== void 0)
158
- l(s, String(o), c);
158
+ a(s, String(n), c);
159
159
  else {
160
- const h = u(), _ = A(h, { [s]: o });
161
- n[0] = _;
160
+ const f = h(), g = F(f, { [s]: n });
161
+ o[0] = g;
162
162
  }
163
163
  return this;
164
164
  },
165
165
  // whereContains adds a _contains filter for a specific field
166
166
  // If the same field is used multiple times, it merges them into an array
167
- whereContains(s, o) {
167
+ whereContains(s, n) {
168
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;
169
+ const c = h(), a = { _contains: n };
170
+ c[s] ? Array.isArray(c[s]) ? c[s].push(a) : c[s] = [c[s], a] : c[s] = [a], o[0] = c;
171
171
  }
172
172
  return this;
173
173
  },
174
174
  // ...existing code...
175
175
  // whereIn adds an _in filter for a specific field
176
176
  // If the same field is used multiple times, it merges them into an array
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;
177
+ whereIn(s, n) {
178
+ if (s && typeof s == "string" && Array.isArray(n)) {
179
+ const c = h(), a = { _in: n };
180
+ c[s] ? Array.isArray(c[s]) ? c[s].push(a) : c[s] = [c[s], a] : c[s] = [a], o[0] = c;
181
181
  }
182
182
  return this;
183
183
  },
184
184
  // whereBetween adds a _between filter for a specific field
185
- whereBetween(s, o, c) {
185
+ whereBetween(s, n, c) {
186
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;
187
+ const a = h(), f = { _between: [n, c] };
188
+ a[s] ? Array.isArray(a[s]) ? a[s].push(f) : a[s] = [a[s], f] : a[s] = f, o[0] = a;
189
189
  }
190
190
  return this;
191
191
  },
192
192
  // limit sets paging/limit for the data selection
193
193
  limit(s) {
194
- return typeof s == "number" && Number.isFinite(s) && (r = A(r || {}, { limit: s })), this;
194
+ return typeof s == "number" && Number.isFinite(s) && (r = F(r || {}, { limit: s })), this;
195
195
  },
196
196
  // offset sets the starting index for the data selection
197
197
  offset(s) {
198
- return typeof s == "number" && Number.isFinite(s) && (r = A(r || {}, { offset: s })), this;
198
+ return typeof s == "number" && Number.isFinite(s) && (r = F(r || {}, { offset: s })), this;
199
199
  },
200
200
  toQuery(s = !1) {
201
- 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(
201
+ let n;
202
+ const c = o.length > 0 && Object.keys(o[0] || {}).length > 0, a = c ? 1 : 0, f = o.length > a;
203
+ c && f ? n = o : f ? n = o.slice(a) : c && (n = o[0]);
204
+ const g = F(
205
205
  i ? { sort: i } : {},
206
- o ? { filters: o } : {}
207
- ), g = {
206
+ n ? { filters: n } : {}
207
+ ), _ = {
208
208
  data: {
209
209
  ...e
210
210
  }
211
211
  };
212
- if (r && (g.data.__args = r), Object.keys(_).length > 0 && (g.__args = _), s && (g.meta = {
212
+ if (r && (_.data.__args = r), Object.keys(g).length > 0 && (_.__args = g), s && (_.meta = {
213
213
  total: !0,
214
214
  key: !0,
215
215
  name: !0
216
- }), f) {
217
- const w = f.split(".");
218
- let O = g;
216
+ }), u) {
217
+ const w = u.split(".");
218
+ let O = _;
219
219
  for (let P = w.length - 1; P >= 0; P--)
220
220
  O = {
221
221
  [w[P]]: O
@@ -223,239 +223,106 @@ function C(t, e) {
223
223
  return O;
224
224
  }
225
225
  return {
226
- [`list${t}`]: g
226
+ [`list${t}`]: _
227
227
  };
228
228
  }
229
229
  };
230
230
  }
231
- const L = (t, e) => {
232
- const r = t, n = e;
231
+ const Z = (t, e = {}) => {
232
+ const r = t, o = e;
233
233
  let i = "list" + t;
234
- const f = (a) => n[a] ? n[a] : null;
234
+ const u = (l) => o[l] ? o[l] : null;
235
235
  return {
236
- field: f,
237
- $fields: n,
238
- setDataPath(a) {
239
- return i = a, i;
236
+ field: u,
237
+ $fields: o,
238
+ setDataPath(l) {
239
+ return i = l, i;
240
240
  },
241
241
  getDataPath() {
242
242
  return i;
243
243
  },
244
- gqlFields(a) {
245
- let u = {};
246
- for (const s of a)
244
+ gqlFields(l) {
245
+ let h = {};
246
+ for (const s of l)
247
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;
248
+ const n = u(s);
249
+ n && (h = F(h, n.gqlField ? typeof n.gqlField == "string" ? { [n.gqlField]: !0 } : n.gqlField : { [n.name || s]: !0 }));
250
+ } else typeof s == "object" && (h = F(h, s));
251
+ return h;
252
252
  },
253
- update(a, u) {
253
+ update(l, h) {
254
254
  return p({
255
255
  ["update" + r]: {
256
- __args: { id: a, data: u }
256
+ __args: { id: l, data: h }
257
257
  }
258
258
  }).then((s) => s["update" + r]);
259
259
  },
260
- async delete(a) {
260
+ async delete(l) {
261
261
  return p({
262
262
  ["delete" + r]: {
263
- __args: { id: a }
263
+ __args: { id: l }
264
264
  }
265
- }).then((u) => u["delete" + r]);
265
+ }).then((h) => h["delete" + r]);
266
266
  },
267
- add(a) {
267
+ add(l) {
268
268
  return p({
269
269
  ["add" + r]: {
270
- __args: { data: a }
270
+ __args: { data: l }
271
271
  }
272
- }).then((u) => u["add" + r]);
272
+ }).then((h) => h["add" + r]);
273
273
  },
274
- fields(a) {
275
- let u = [];
276
- for (let s of a) {
277
- const o = f(s);
278
- o && u.push(o);
274
+ fields(l) {
275
+ let h = [];
276
+ for (let s of l) {
277
+ const n = u(s);
278
+ n && h.push(n);
279
279
  }
280
- return u;
280
+ return h;
281
281
  },
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);
286
- return await o.first();
282
+ async get(l, h) {
283
+ const s = (await Promise.resolve().then(() => St)).default, n = s(r, kt(h));
284
+ for (const [c, a] of Object.entries(l))
285
+ n.where(c, "==", a);
286
+ return await n.first();
287
287
  },
288
- list(a) {
289
- let u = a;
288
+ list(l) {
289
+ let h = l;
290
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]));
291
+ Object.entries(l).forEach(([a]) => {
292
+ o[a] && (s[a] = o[a], o[a].gqlField && (delete h[a], h = F(h, o[a].gqlField)), o[a].gql && (h = F(h, o[a].gql), delete h[a]));
293
293
  });
294
- const o = C(r, u).dataPath(i), c = o.fetch.bind(o);
294
+ const n = k(r, h).dataPath(i), c = n.fetch.bind(n);
295
295
  return {
296
- ...o,
296
+ ...n,
297
297
  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
- }), _;
298
+ return (await c()).map((f) => {
299
+ const g = { ...f };
300
+ return Object.entries(s).forEach(([_, w]) => {
301
+ w.format && typeof w.format == "function" && (g[_] = w.format(f));
302
+ }), g;
303
303
  });
304
304
  },
305
305
  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
- }), _;
306
+ const f = await n.fetchFirst.bind(n)();
307
+ if (!f) return f;
308
+ const g = { ...f };
309
+ return Object.entries(s).forEach(([_, w]) => {
310
+ w.format && typeof w.format == "function" && (g[_] = w.format(f));
311
+ }), g;
312
312
  }
313
313
  };
314
314
  }
315
315
  };
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({
316
+ }, A = {}, L = (t, e) => {
317
+ const r = Z(t, e);
318
+ return A[t] = r, r;
319
+ }, U = (t) => A[t] ? A[t] : L(t, {}), Bt = (t) => !!A[t], Jt = () => Object.keys(A), Lt = () => {
320
+ Object.keys(A).forEach((t) => delete A[t]);
321
+ }, Qt = (t) => {
322
+ Object.entries(t).forEach(([e, r]) => {
323
+ L(e, r);
324
+ });
325
+ }, Tt = () => y({
459
326
  app: {
460
327
  permissions: !0
461
328
  }
@@ -477,7 +344,7 @@ const L = (t, e) => {
477
344
  }
478
345
  }), e = PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);
479
346
  return await navigator.credentials.create({ publicKey: e });
480
- }, Z = async () => {
347
+ }, V = async () => {
481
348
  const t = await Q();
482
349
  return await p({
483
350
  webAuthnAssertion: {
@@ -486,7 +353,7 @@ const L = (t, e) => {
486
353
  }
487
354
  }
488
355
  }).then((e) => e.webAuthnAssertion);
489
- }, V = async () => {
356
+ }, I = async () => {
490
357
  const t = await T();
491
358
  return await p({
492
359
  webAuthnRegister: {
@@ -499,9 +366,9 @@ const L = (t, e) => {
499
366
  __proto__: null,
500
367
  assertion: Q,
501
368
  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({
369
+ login: V,
370
+ register: I
371
+ }, Symbol.toStringTag, { value: "Module" })), x = (t = W) => y({ my: t }).then((e) => e.my), tt = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((o) => o.login), et = () => p({ logout: !0 }).then((t) => t.logout), rt = (t, e, r) => p({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((o) => o.changeExpiredPassword), st = (t, e) => p({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), nt = (t, e, r) => p({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((o) => o.resetPassword), ot = (t, e) => p({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), it = (t, e) => p({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), at = (t) => y({
505
372
  my: {
506
373
  granted: {
507
374
  __args: {
@@ -509,7 +376,7 @@ const L = (t, e) => {
509
376
  }
510
377
  }
511
378
  }
512
- }).then((e) => e.my.granted), at = (t) => y({
379
+ }).then((e) => e.my.granted), ct = (t) => y({
513
380
  my: {
514
381
  grantedRights: {
515
382
  __args: {
@@ -517,8 +384,8 @@ const L = (t, e) => {
517
384
  }
518
385
  }
519
386
  }
520
- }).then((e) => e.my.grantedRights), ct = () => ({
521
- getCurrentUser: I,
387
+ }).then((e) => e.my.grantedRights), lt = () => ({
388
+ getCurrentUser: x,
522
389
  webAuthn: K,
523
390
  google: {
524
391
  unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
@@ -535,22 +402,22 @@ const L = (t, e) => {
535
402
  login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
536
403
  register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
537
404
  },
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
405
+ login: tt,
406
+ logout: et,
407
+ changeExpiredPassword: rt,
408
+ updatePassword: st,
409
+ resetPassword: nt,
410
+ forgetPassword: ot,
411
+ verifyCode: it,
412
+ grantedRights: ct,
413
+ isGranted: at
547
414
  }), $ = {
548
415
  name: !0,
549
416
  path: !0,
550
417
  size: !0,
551
418
  mime: !0,
552
419
  url: !0
553
- }, lt = (t, e, r = $) => y({
420
+ }, ut = (t, e, r = $) => y({
554
421
  app: {
555
422
  drive: {
556
423
  __args: { index: t },
@@ -560,7 +427,7 @@ const L = (t, e) => {
560
427
  }
561
428
  }
562
429
  }
563
- }).then((n) => n.app.drive.files), ut = (t, e) => y({
430
+ }).then((o) => o.app.drive.files), ht = (t, e) => y({
564
431
  app: {
565
432
  drive: {
566
433
  __args: {
@@ -575,7 +442,7 @@ const L = (t, e) => {
575
442
  }
576
443
  }
577
444
  }).then((r) => r.app.drive?.file?.base64Content), m = (t) => ({
578
- list: (e, r = $) => lt(t, e, r),
445
+ list: (e, r = $) => ut(t, e, r),
579
446
  get: (e, r = {
580
447
  name: !0,
581
448
  path: !0,
@@ -596,9 +463,9 @@ const L = (t, e) => {
596
463
  }
597
464
  }
598
465
  }
599
- }).then((n) => n.app.drive.file),
466
+ }).then((o) => o.app.drive.file),
600
467
  readFileAsBase64(e) {
601
- return ut(t, e);
468
+ return ht(t, e);
602
469
  },
603
470
  read: async (e) => {
604
471
  let r = await y({
@@ -620,14 +487,14 @@ const L = (t, e) => {
620
487
  throw new Error(`File not found or cannot read content: ${e}`);
621
488
  return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
622
489
  },
623
- write: (e, r) => p({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((n) => n.lightDriveWriteFile),
490
+ write: (e, r) => p({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((o) => o.lightDriveWriteFile),
624
491
  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)
492
+ rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((o) => o.lightDriveRenameFile),
493
+ move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((o) => o.lightDriveMoveFile)
627
494
  }), G = {
628
495
  name: !0,
629
496
  path: !0
630
- }, ht = (t, e, r = G) => y({
497
+ }, ft = (t, e, r = G) => y({
631
498
  app: {
632
499
  drive: {
633
500
  __args: { index: t },
@@ -637,19 +504,19 @@ const L = (t, e) => {
637
504
  }
638
505
  }
639
506
  }
640
- }).then((n) => n.app.drive.folders), D = (t) => ({
641
- list: (e, r = G) => ht(t, e, r),
507
+ }).then((o) => o.app.drive.folders), D = (t) => ({
508
+ list: (e, r = G) => ft(t, e, r),
642
509
  create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
643
510
  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({
511
+ rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((o) => o.lightDriveRenameFolder)
512
+ }), $t = () => y({
646
513
  app: {
647
514
  drives: {
648
515
  index: !0,
649
516
  name: !0
650
517
  }
651
518
  }
652
- }).then((t) => t.app.drives), ft = (t) => ({
519
+ }).then((t) => t.app.drives), pt = (t) => ({
653
520
  listFiles: m(t).list,
654
521
  getFile: m(t).get,
655
522
  readFile: m(t).read,
@@ -678,24 +545,24 @@ const L = (t, e) => {
678
545
  first_name: !0,
679
546
  last_name: !0,
680
547
  status: !0
681
- }, pt = (t) => p({
548
+ }, gt = (t) => p({
682
549
  addUser: {
683
550
  __args: t
684
551
  }
685
- }).then((e) => e.addUser), gt = (t) => p({
552
+ }).then((e) => e.addUser), dt = (t) => p({
686
553
  deleteUser: {
687
554
  __args: { id: t }
688
555
  }
689
- }).then((e) => e.deleteUser), dt = (t = W) => C("Users", t).dataPath("app.listUser").fetch(), _t = (t, e) => p({
556
+ }).then((e) => e.deleteUser), _t = (t = W) => k("Users", t).dataPath("app.listUser").fetch(), yt = (t, e) => p({
690
557
  updateUser: {
691
558
  __args: { id: t, data: e }
692
559
  }
693
- }).then((r) => r.updateUser), yt = () => ({
694
- list: dt,
695
- create: pt,
696
- delete: gt,
697
- update: _t
698
- }), wt = (t) => y({
560
+ }).then((r) => r.updateUser), wt = () => ({
561
+ list: _t,
562
+ create: gt,
563
+ delete: dt,
564
+ update: yt
565
+ }), mt = (t) => y({
699
566
  app: {
700
567
  listConfig: {
701
568
  __args: {
@@ -711,11 +578,11 @@ const L = (t, e) => {
711
578
  }
712
579
  }).then((e) => e.app.listConfig.data[0]?.value), bt = {
713
580
  name: !0
714
- }, mt = (t = bt) => y({
581
+ }, Ft = (t = bt) => y({
715
582
  app: {
716
583
  roles: t
717
584
  }
718
- }).then((e) => e.app.roles), Ft = (t, e) => p({
585
+ }).then((e) => e.app.roles), At = (t, e) => p({
719
586
  addRole: {
720
587
  __args: {
721
588
  data: {
@@ -724,78 +591,78 @@ const L = (t, e) => {
724
591
  }
725
592
  }
726
593
  }
727
- }).then((r) => r.addRole), At = (t) => p({
594
+ }).then((r) => r.addRole), Ot = (t) => p({
728
595
  deleteRole: {
729
596
  __args: { name: t }
730
597
  }
731
- }).then((e) => e.deleteRole), Ot = () => ({
732
- list: mt,
733
- create: Ft,
734
- delete: At
598
+ }).then((e) => e.deleteRole), Dt = () => ({
599
+ list: Ft,
600
+ create: At,
601
+ delete: Ot
735
602
  });
736
- function z(t, e, r, n, i) {
603
+ function z(t, e, r, o, i) {
737
604
  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 = {};
743
- 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++);
749
- }), 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;
758
- })) : c != null && (s[o] = c);
759
- }), a.__args = s;
605
+ for (let u in t) {
606
+ const l = t[u];
607
+ if (l && typeof l == "object") {
608
+ if ("__args" in l) {
609
+ const h = l.__args, s = {};
610
+ Object.entries(h).forEach(([n, c]) => {
611
+ if (c instanceof Array && C(c)) {
612
+ s[n] = new b(n);
613
+ let a = 0;
614
+ c.forEach((f) => {
615
+ f instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + n + "." + a), o.append(i.current.toString(), f), i.current++, a++);
616
+ }), e[n] = "[Upload!]!";
617
+ } else c instanceof File ? (s[n] = new b(n), r[i.current] = ["variables." + n], o.append(i.current.toString(), c), e[n] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[n] = {}, Object.entries(c).forEach(([a, f]) => {
618
+ if (f instanceof Array && C(f)) {
619
+ s[n][a] = new b(a);
620
+ let g = 0;
621
+ f.forEach((_) => {
622
+ _ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + a + "." + g), o.append(i.current.toString(), _), i.current++, g++);
623
+ }), e[a] = "[Upload!]!";
624
+ } else f instanceof File ? (s[n][a] = new b(a), r[i.current] = ["variables." + a], o.append(i.current.toString(), f), e[a] = "Upload!", i.current++) : s[n][a] = f;
625
+ })) : c != null && (s[n] = c);
626
+ }), l.__args = s;
760
627
  }
761
- z(a, e, r, n, i);
628
+ z(l, e, r, o, i);
762
629
  }
763
630
  }
764
631
  }
765
632
  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);
770
- 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
774
- })), o = await r.post("", i)) : o = await r.post("", {
775
- query: l
776
- }), o.data.errors)
777
- throw new Error(o.data.errors[0].message);
778
- 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) => {
633
+ const r = N().axios, o = t, i = new FormData();
634
+ let u = !1;
635
+ const l = {}, h = {};
636
+ z(o, l, h, i, { current: 0 }), u = Object.keys(l).length > 0, u && (o.__variables = l);
637
+ let n = null;
638
+ const a = M({ mutation: o });
639
+ if (u ? (i.append("map", JSON.stringify(h)), i.append("operations", JSON.stringify({
640
+ query: a
641
+ })), n = await r.post("", i)) : n = await r.post("", {
642
+ query: a
643
+ }), n.data.errors)
644
+ throw new Error(n.data.errors[0].message);
645
+ return n.data.data;
646
+ }, Ct = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((o) => o.sendMail), jt = {
647
+ send: Ct
648
+ }, q = (t) => {
782
649
  let e = {};
783
650
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
784
- Object.entries(U(r)).forEach(([n, i]) => {
785
- e[n] = i;
651
+ Object.entries(q(r)).forEach(([o, i]) => {
652
+ e[o] = i;
786
653
  });
787
- }), e) : (Object.entries(t).forEach(([r, n]) => {
654
+ }), e) : (Object.entries(t).forEach(([r, o]) => {
788
655
  if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
789
- e[r] = n;
656
+ e[r] = o;
790
657
  return;
791
658
  }
792
- if (typeof n == "boolean") {
793
- e[r] = n;
659
+ if (typeof o == "boolean") {
660
+ e[r] = o;
794
661
  return;
795
662
  }
796
- e[r] = U(n);
663
+ e[r] = q(o);
797
664
  }), e);
798
- }, kt = (t) => U(t), Ct = "list", Pt = [
665
+ }, kt = (t) => q(t), Pt = "list", Et = [
799
666
  "flatMap",
800
667
  "chunk",
801
668
  "shuffle",
@@ -821,7 +688,7 @@ const p = async (t) => {
821
688
  "slice",
822
689
  "tap",
823
690
  "sort"
824
- ], Mt = [
691
+ ], Ut = [
825
692
  "avg",
826
693
  "count",
827
694
  "countBy",
@@ -892,14 +759,14 @@ d.prototype.clone = function() {
892
759
  const t = Object.create(this);
893
760
  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
761
  };
895
- E().macro("whereContains", function(t, e) {
762
+ S().macro("whereContains", function(t, e) {
896
763
  return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
897
764
  });
898
765
  d.prototype.fetchData = async function() {
899
766
  try {
900
767
  if (this._batchData) {
901
- const u = this._batchData;
902
- return this.meta = u.meta, E(u.data);
768
+ const h = this._batchData;
769
+ return this.meta = h.meta, S(h.data);
903
770
  }
904
771
  let t = {
905
772
  meta: {
@@ -910,18 +777,18 @@ d.prototype.fetchData = async function() {
910
777
  };
911
778
  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);
912
779
  const e = this.data_path.split(".");
913
- let r = {}, n = r, i = e[e.length - 1];
914
- for (const u of e) {
915
- if (u === i) {
916
- n[u] = t;
780
+ let r = {}, o = r, i = e[e.length - 1];
781
+ for (const h of e) {
782
+ if (h === i) {
783
+ o[h] = t;
917
784
  break;
918
785
  }
919
- n[u] = {}, n = n[u];
786
+ o[h] = {}, o = o[h];
920
787
  }
921
- let a = await y(r);
922
- for (const u of e)
923
- a = a[u];
924
- return this.meta = a.meta, E(a.data);
788
+ let l = await y(r);
789
+ for (const h of e)
790
+ l = l[h];
791
+ return this.meta = l.meta, S(l.data);
925
792
  } catch (t) {
926
793
  throw console.error("Error fetching collection data:", t), t;
927
794
  }
@@ -935,12 +802,12 @@ d.prototype.processData = async function() {
935
802
  d.prototype.all = async function() {
936
803
  return (await this.processData()).all();
937
804
  };
938
- for (const t of Pt)
805
+ for (const t of Et)
939
806
  d.prototype[t] = function(...e) {
940
807
  const r = this.clone();
941
808
  return r.steps.push({ type: t, args: e }), r;
942
809
  };
943
- for (const t of Mt)
810
+ for (const t of Ut)
944
811
  d.prototype[t] = async function(...e) {
945
812
  return (await this.clone().processData())[t](...e);
946
813
  };
@@ -957,8 +824,8 @@ d.prototype.where = function(...t) {
957
824
  if (t.length === 2)
958
825
  this.filters[t[0]] = t[1];
959
826
  else if (t.length === 3) {
960
- const r = t[0], n = t[1], i = t[2];
961
- switch (n) {
827
+ const r = t[0], o = t[1], i = t[2];
828
+ switch (o) {
962
829
  case "==":
963
830
  this.filters[r] = i;
964
831
  break;
@@ -978,7 +845,7 @@ d.prototype.where = function(...t) {
978
845
  this.filters[r] = { ne: i };
979
846
  break;
980
847
  default:
981
- throw new Error(`Unsupported operator: ${n}`);
848
+ throw new Error(`Unsupported operator: ${o}`);
982
849
  }
983
850
  }
984
851
  return this;
@@ -1027,125 +894,126 @@ d.prototype.splice = function(t, e) {
1027
894
  };
1028
895
  const R = (t, e) => {
1029
896
  const r = new d(e);
1030
- return r.data_path = Ct + t, r;
1031
- }, Et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
897
+ return r.data_path = Pt + t, r;
898
+ }, St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1032
899
  __proto__: null,
1033
900
  default: R
1034
- }, Symbol.toStringTag, { value: "Module" })), Tt = (t) => {
901
+ }, Symbol.toStringTag, { value: "Module" })), Gt = (t) => {
1035
902
  const e = typeof window > "u";
1036
903
  let r = [];
1037
- const n = H.create({
904
+ const o = H.create({
1038
905
  baseURL: t,
1039
906
  withCredentials: !0
1040
907
  });
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());
908
+ e && (o.interceptors.request.use((u) => (u.withCredentials = !0, r.length > 0 && (u.headers.Cookie = r.join("; ")), u)), o.interceptors.response.use((u) => {
909
+ if (u.headers["set-cookie"]) {
910
+ const l = u.headers["set-cookie"].map((s) => s.split(";")[0]), h = /* @__PURE__ */ new Map();
911
+ r.forEach((s) => {
912
+ const n = s.split("=")[0];
913
+ h.set(n, s);
914
+ }), l.forEach((s) => {
915
+ const n = s.split("=")[0];
916
+ h.set(n, s);
917
+ }), r = Array.from(h.values());
1051
918
  }
1052
- return a;
919
+ return u;
1053
920
  }));
1054
- const i = v(), f = {
1055
- post: n.post,
921
+ const i = {
922
+ post: o.post,
1056
923
  baseURL: t,
1057
- axios: n,
1058
- auth: ct(),
924
+ axios: o,
925
+ auth: lt(),
1059
926
  mutation: p,
1060
927
  query: y,
1061
- config: wt,
928
+ config: mt,
1062
929
  mail: jt,
1063
- users: yt(),
1064
- models: i,
1065
- model(a) {
1066
- return i.get(a);
930
+ users: wt(),
931
+ model(u) {
932
+ return U(u);
1067
933
  },
1068
- roles: Ot(),
1069
- collect: (a, u) => {
1070
- const s = R(a, u);
1071
- return s.data_path = i.get(a).getDataPath(), s;
934
+ roles: Dt(),
935
+ collect: (u, l) => {
936
+ const h = R(u, l);
937
+ return h.data_path = U(u).getDataPath(), h;
1072
938
  },
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;
939
+ list: (u, l) => k(u, l).dataPath(U(u).getDataPath()),
940
+ drive: pt,
941
+ async collects(u) {
942
+ const l = {}, h = {};
943
+ for (const n in u) {
944
+ const c = u[n].getQueryPayload();
945
+ h[n] = c.data_path, l[n] = {};
946
+ const a = c.data_path.split(".");
947
+ let f = a[a.length - 1], g = l[n];
948
+ for (const _ of a) {
949
+ if (_ === f) {
950
+ g[_] = c.query;
1085
951
  break;
1086
952
  }
1087
- g[w] = g[w] || {};
953
+ g[_] = g[_] || {};
1088
954
  }
1089
- u[c].__aliasFor = h[0];
955
+ l[n].__aliasFor = a[0];
1090
956
  }
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];
957
+ const s = await y(l);
958
+ for (const n in u) {
959
+ const c = h[n].split(".");
960
+ let a = c[c.length - 1], f = s[n];
961
+ for (const g of c) {
962
+ if (g === a) {
963
+ u[n]._batchData = s[n][g];
1098
964
  break;
1099
965
  }
1100
- _[g] = _[g] || {};
966
+ f[g] = f[g] || {};
1101
967
  }
1102
968
  }
1103
- return a;
969
+ return u;
1104
970
  }
1105
971
  };
1106
- return Y(f), f;
1107
- }, $t = C;
972
+ return Y(i), i;
973
+ }, Wt = k;
1108
974
  export {
1109
- ct as auth,
1110
- et as changeExpiredPassword,
1111
- Tt as createClient,
975
+ lt as auth,
976
+ rt as changeExpiredPassword,
977
+ Lt as clearModels,
978
+ Gt as createClient,
1112
979
  R as createCollection,
1113
- C as createList,
1114
- v as createModelManager,
1115
- Ft as createRole,
1116
- pt as createUser,
980
+ k as createList,
981
+ At as createRole,
982
+ gt as createUser,
1117
983
  W as defaultUserFields,
1118
- At as deleteRole,
1119
- gt as deleteUser,
1120
- nt as forgetPassword,
984
+ L as defineModel,
985
+ Qt as defineModels,
986
+ Ot as deleteRole,
987
+ dt as deleteUser,
988
+ ot as forgetPassword,
1121
989
  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,
990
+ Nt as getApiClientOptional,
991
+ mt as getConfig,
992
+ x as getCurrentUser,
993
+ pt as getDrive,
994
+ ct as getGrantedRights,
995
+ U as getModel,
996
+ Bt as hasModel,
997
+ at as isGranted,
998
+ Wt as list,
999
+ $t as listDrives,
1000
+ ut as listFiles,
1001
+ ft as listFolders,
1002
+ Jt as listModels,
1003
+ Tt as listPermissions,
1004
+ Ft as listRoles,
1005
+ _t as listUsers,
1006
+ tt as login,
1007
+ et as logout,
1137
1008
  p as mutation,
1138
1009
  y as query,
1139
- ut as readFileAsBase64,
1140
- st as resetPassword,
1141
- Dt as sendMail,
1010
+ ht as readFileAsBase64,
1011
+ nt as resetPassword,
1012
+ Ct as sendMail,
1142
1013
  Y as setApiClient,
1143
1014
  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,
1015
+ st as updatePassword,
1016
+ yt as updateUser,
1017
+ it as verifyCode,
1150
1018
  K as webAuthn
1151
1019
  };