@hostlink/light 3.0.3 → 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,27 +344,31 @@ 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: {
484
- assertion: t.toJSON()
351
+ __args: {
352
+ assertion: t.toJSON()
353
+ }
485
354
  }
486
355
  }).then((e) => e.webAuthnAssertion);
487
- }, V = async () => {
356
+ }, I = async () => {
488
357
  const t = await T();
489
358
  return await p({
490
359
  webAuthnRegister: {
491
- registration: t.toJSON()
360
+ __args: {
361
+ registration: t.toJSON()
362
+ }
492
363
  }
493
364
  }).then((e) => e.webAuthnRegister);
494
365
  }, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
495
366
  __proto__: null,
496
367
  assertion: Q,
497
368
  attestation: T,
498
- login: Z,
499
- register: V
500
- }, 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({
501
372
  my: {
502
373
  granted: {
503
374
  __args: {
@@ -505,7 +376,7 @@ const L = (t, e) => {
505
376
  }
506
377
  }
507
378
  }
508
- }).then((e) => e.my.granted), at = (t) => y({
379
+ }).then((e) => e.my.granted), ct = (t) => y({
509
380
  my: {
510
381
  grantedRights: {
511
382
  __args: {
@@ -513,8 +384,8 @@ const L = (t, e) => {
513
384
  }
514
385
  }
515
386
  }
516
- }).then((e) => e.my.grantedRights), ct = () => ({
517
- getCurrentUser: I,
387
+ }).then((e) => e.my.grantedRights), lt = () => ({
388
+ getCurrentUser: x,
518
389
  webAuthn: K,
519
390
  google: {
520
391
  unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
@@ -531,22 +402,22 @@ const L = (t, e) => {
531
402
  login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
532
403
  register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
533
404
  },
534
- login: x,
535
- logout: tt,
536
- changeExpiredPassword: et,
537
- updatePassword: rt,
538
- resetPassword: st,
539
- forgetPassword: nt,
540
- verifyCode: ot,
541
- grantedRights: at,
542
- 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
543
414
  }), $ = {
544
415
  name: !0,
545
416
  path: !0,
546
417
  size: !0,
547
418
  mime: !0,
548
419
  url: !0
549
- }, lt = (t, e, r = $) => y({
420
+ }, ut = (t, e, r = $) => y({
550
421
  app: {
551
422
  drive: {
552
423
  __args: { index: t },
@@ -556,7 +427,7 @@ const L = (t, e) => {
556
427
  }
557
428
  }
558
429
  }
559
- }).then((n) => n.app.drive.files), ut = (t, e) => y({
430
+ }).then((o) => o.app.drive.files), ht = (t, e) => y({
560
431
  app: {
561
432
  drive: {
562
433
  __args: {
@@ -571,7 +442,7 @@ const L = (t, e) => {
571
442
  }
572
443
  }
573
444
  }).then((r) => r.app.drive?.file?.base64Content), m = (t) => ({
574
- list: (e, r = $) => lt(t, e, r),
445
+ list: (e, r = $) => ut(t, e, r),
575
446
  get: (e, r = {
576
447
  name: !0,
577
448
  path: !0,
@@ -592,9 +463,9 @@ const L = (t, e) => {
592
463
  }
593
464
  }
594
465
  }
595
- }).then((n) => n.app.drive.file),
466
+ }).then((o) => o.app.drive.file),
596
467
  readFileAsBase64(e) {
597
- return ut(t, e);
468
+ return ht(t, e);
598
469
  },
599
470
  read: async (e) => {
600
471
  let r = await y({
@@ -616,14 +487,14 @@ const L = (t, e) => {
616
487
  throw new Error(`File not found or cannot read content: ${e}`);
617
488
  return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
618
489
  },
619
- 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),
620
491
  delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
621
- rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
622
- 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)
623
494
  }), G = {
624
495
  name: !0,
625
496
  path: !0
626
- }, ht = (t, e, r = G) => y({
497
+ }, ft = (t, e, r = G) => y({
627
498
  app: {
628
499
  drive: {
629
500
  __args: { index: t },
@@ -633,19 +504,19 @@ const L = (t, e) => {
633
504
  }
634
505
  }
635
506
  }
636
- }).then((n) => n.app.drive.folders), D = (t) => ({
637
- 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),
638
509
  create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
639
510
  delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
640
- rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
641
- }), Qt = () => y({
511
+ rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((o) => o.lightDriveRenameFolder)
512
+ }), $t = () => y({
642
513
  app: {
643
514
  drives: {
644
515
  index: !0,
645
516
  name: !0
646
517
  }
647
518
  }
648
- }).then((t) => t.app.drives), ft = (t) => ({
519
+ }).then((t) => t.app.drives), pt = (t) => ({
649
520
  listFiles: m(t).list,
650
521
  getFile: m(t).get,
651
522
  readFile: m(t).read,
@@ -674,24 +545,24 @@ const L = (t, e) => {
674
545
  first_name: !0,
675
546
  last_name: !0,
676
547
  status: !0
677
- }, pt = (t) => p({
548
+ }, gt = (t) => p({
678
549
  addUser: {
679
550
  __args: t
680
551
  }
681
- }).then((e) => e.addUser), gt = (t) => p({
552
+ }).then((e) => e.addUser), dt = (t) => p({
682
553
  deleteUser: {
683
554
  __args: { id: t }
684
555
  }
685
- }).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({
686
557
  updateUser: {
687
558
  __args: { id: t, data: e }
688
559
  }
689
- }).then((r) => r.updateUser), yt = () => ({
690
- list: dt,
691
- create: pt,
692
- delete: gt,
693
- update: _t
694
- }), 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({
695
566
  app: {
696
567
  listConfig: {
697
568
  __args: {
@@ -707,11 +578,11 @@ const L = (t, e) => {
707
578
  }
708
579
  }).then((e) => e.app.listConfig.data[0]?.value), bt = {
709
580
  name: !0
710
- }, mt = (t = bt) => y({
581
+ }, Ft = (t = bt) => y({
711
582
  app: {
712
583
  roles: t
713
584
  }
714
- }).then((e) => e.app.roles), Ft = (t, e) => p({
585
+ }).then((e) => e.app.roles), At = (t, e) => p({
715
586
  addRole: {
716
587
  __args: {
717
588
  data: {
@@ -720,78 +591,78 @@ const L = (t, e) => {
720
591
  }
721
592
  }
722
593
  }
723
- }).then((r) => r.addRole), At = (t) => p({
594
+ }).then((r) => r.addRole), Ot = (t) => p({
724
595
  deleteRole: {
725
596
  __args: { name: t }
726
597
  }
727
- }).then((e) => e.deleteRole), Ot = () => ({
728
- list: mt,
729
- create: Ft,
730
- delete: At
598
+ }).then((e) => e.deleteRole), Dt = () => ({
599
+ list: Ft,
600
+ create: At,
601
+ delete: Ot
731
602
  });
732
- function z(t, e, r, n, i) {
603
+ function z(t, e, r, o, i) {
733
604
  if (!(!t || typeof t != "object"))
734
- for (let f in t) {
735
- const a = t[f];
736
- if (a && typeof a == "object") {
737
- if ("__args" in a) {
738
- const u = a.__args, s = {};
739
- Object.entries(u).forEach(([o, c]) => {
740
- if (c instanceof Array && j(c)) {
741
- s[o] = new F(o);
742
- let l = 0;
743
- c.forEach((h) => {
744
- 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++);
745
- }), e[o] = "[Upload!]!";
746
- } 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]) => {
747
- if (h instanceof Array && j(h)) {
748
- s[o][l] = new F(l);
749
- let _ = 0;
750
- h.forEach((g) => {
751
- g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
752
- }), e[l] = "[Upload!]!";
753
- } 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;
754
- })) : c != null && (s[o] = c);
755
- }), 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;
756
627
  }
757
- z(a, e, r, n, i);
628
+ z(l, e, r, o, i);
758
629
  }
759
630
  }
760
631
  }
761
632
  const p = async (t) => {
762
- const r = N().axios, n = t, i = new FormData();
763
- let f = !1;
764
- const a = {}, u = {};
765
- z(n, a, u, i, { current: 0 }), f = Object.keys(a).length > 0, f && (n.__variables = a);
766
- let o = null;
767
- const l = q({ mutation: n });
768
- if (f ? (i.append("map", JSON.stringify(u)), i.append("operations", JSON.stringify({
769
- query: l
770
- })), o = await r.post("", i)) : o = await r.post("", {
771
- query: l
772
- }), o.data.errors)
773
- throw new Error(o.data.errors[0].message);
774
- return o.data.data;
775
- }, Dt = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), jt = {
776
- send: Dt
777
- }, 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) => {
778
649
  let e = {};
779
650
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
780
- Object.entries(U(r)).forEach(([n, i]) => {
781
- e[n] = i;
651
+ Object.entries(q(r)).forEach(([o, i]) => {
652
+ e[o] = i;
782
653
  });
783
- }), e) : (Object.entries(t).forEach(([r, n]) => {
654
+ }), e) : (Object.entries(t).forEach(([r, o]) => {
784
655
  if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
785
- e[r] = n;
656
+ e[r] = o;
786
657
  return;
787
658
  }
788
- if (typeof n == "boolean") {
789
- e[r] = n;
659
+ if (typeof o == "boolean") {
660
+ e[r] = o;
790
661
  return;
791
662
  }
792
- e[r] = U(n);
663
+ e[r] = q(o);
793
664
  }), e);
794
- }, kt = (t) => U(t), Ct = "list", Pt = [
665
+ }, kt = (t) => q(t), Pt = "list", Et = [
795
666
  "flatMap",
796
667
  "chunk",
797
668
  "shuffle",
@@ -817,7 +688,7 @@ const p = async (t) => {
817
688
  "slice",
818
689
  "tap",
819
690
  "sort"
820
- ], Mt = [
691
+ ], Ut = [
821
692
  "avg",
822
693
  "count",
823
694
  "countBy",
@@ -888,14 +759,14 @@ d.prototype.clone = function() {
888
759
  const t = Object.create(this);
889
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;
890
761
  };
891
- E().macro("whereContains", function(t, e) {
762
+ S().macro("whereContains", function(t, e) {
892
763
  return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
893
764
  });
894
765
  d.prototype.fetchData = async function() {
895
766
  try {
896
767
  if (this._batchData) {
897
- const u = this._batchData;
898
- return this.meta = u.meta, E(u.data);
768
+ const h = this._batchData;
769
+ return this.meta = h.meta, S(h.data);
899
770
  }
900
771
  let t = {
901
772
  meta: {
@@ -906,18 +777,18 @@ d.prototype.fetchData = async function() {
906
777
  };
907
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);
908
779
  const e = this.data_path.split(".");
909
- let r = {}, n = r, i = e[e.length - 1];
910
- for (const u of e) {
911
- if (u === i) {
912
- 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;
913
784
  break;
914
785
  }
915
- n[u] = {}, n = n[u];
786
+ o[h] = {}, o = o[h];
916
787
  }
917
- let a = await y(r);
918
- for (const u of e)
919
- a = a[u];
920
- 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);
921
792
  } catch (t) {
922
793
  throw console.error("Error fetching collection data:", t), t;
923
794
  }
@@ -931,12 +802,12 @@ d.prototype.processData = async function() {
931
802
  d.prototype.all = async function() {
932
803
  return (await this.processData()).all();
933
804
  };
934
- for (const t of Pt)
805
+ for (const t of Et)
935
806
  d.prototype[t] = function(...e) {
936
807
  const r = this.clone();
937
808
  return r.steps.push({ type: t, args: e }), r;
938
809
  };
939
- for (const t of Mt)
810
+ for (const t of Ut)
940
811
  d.prototype[t] = async function(...e) {
941
812
  return (await this.clone().processData())[t](...e);
942
813
  };
@@ -953,8 +824,8 @@ d.prototype.where = function(...t) {
953
824
  if (t.length === 2)
954
825
  this.filters[t[0]] = t[1];
955
826
  else if (t.length === 3) {
956
- const r = t[0], n = t[1], i = t[2];
957
- switch (n) {
827
+ const r = t[0], o = t[1], i = t[2];
828
+ switch (o) {
958
829
  case "==":
959
830
  this.filters[r] = i;
960
831
  break;
@@ -974,7 +845,7 @@ d.prototype.where = function(...t) {
974
845
  this.filters[r] = { ne: i };
975
846
  break;
976
847
  default:
977
- throw new Error(`Unsupported operator: ${n}`);
848
+ throw new Error(`Unsupported operator: ${o}`);
978
849
  }
979
850
  }
980
851
  return this;
@@ -1023,125 +894,126 @@ d.prototype.splice = function(t, e) {
1023
894
  };
1024
895
  const R = (t, e) => {
1025
896
  const r = new d(e);
1026
- return r.data_path = Ct + t, r;
1027
- }, Et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
897
+ return r.data_path = Pt + t, r;
898
+ }, St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1028
899
  __proto__: null,
1029
900
  default: R
1030
- }, Symbol.toStringTag, { value: "Module" })), Tt = (t) => {
901
+ }, Symbol.toStringTag, { value: "Module" })), Gt = (t) => {
1031
902
  const e = typeof window > "u";
1032
903
  let r = [];
1033
- const n = H.create({
904
+ const o = H.create({
1034
905
  baseURL: t,
1035
906
  withCredentials: !0
1036
907
  });
1037
- e && (n.interceptors.request.use((a) => (a.withCredentials = !0, r.length > 0 && (a.headers.Cookie = r.join("; ")), a)), n.interceptors.response.use((a) => {
1038
- if (a.headers["set-cookie"]) {
1039
- const u = a.headers["set-cookie"].map((o) => o.split(";")[0]), s = /* @__PURE__ */ new Map();
1040
- r.forEach((o) => {
1041
- const c = o.split("=")[0];
1042
- s.set(c, o);
1043
- }), u.forEach((o) => {
1044
- const c = o.split("=")[0];
1045
- s.set(c, o);
1046
- }), 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());
1047
918
  }
1048
- return a;
919
+ return u;
1049
920
  }));
1050
- const i = v(), f = {
1051
- post: n.post,
921
+ const i = {
922
+ post: o.post,
1052
923
  baseURL: t,
1053
- axios: n,
1054
- auth: ct(),
924
+ axios: o,
925
+ auth: lt(),
1055
926
  mutation: p,
1056
927
  query: y,
1057
- config: wt,
928
+ config: mt,
1058
929
  mail: jt,
1059
- users: yt(),
1060
- models: i,
1061
- model(a) {
1062
- return i.get(a);
930
+ users: wt(),
931
+ model(u) {
932
+ return U(u);
1063
933
  },
1064
- roles: Ot(),
1065
- collect: (a, u) => {
1066
- const s = R(a, u);
1067
- 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;
1068
938
  },
1069
- list: (a, u) => C(a, u).dataPath(i.get(a).getDataPath()),
1070
- drive: ft,
1071
- async collects(a) {
1072
- const u = {}, s = {};
1073
- for (const c in a) {
1074
- const l = a[c].getQueryPayload();
1075
- s[c] = l.data_path, u[c] = {};
1076
- const h = l.data_path.split(".");
1077
- let _ = h[h.length - 1], g = u[c];
1078
- for (const w of h) {
1079
- if (w === _) {
1080
- 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;
1081
951
  break;
1082
952
  }
1083
- g[w] = g[w] || {};
953
+ g[_] = g[_] || {};
1084
954
  }
1085
- u[c].__aliasFor = h[0];
955
+ l[n].__aliasFor = a[0];
1086
956
  }
1087
- const o = await y(u);
1088
- for (const c in a) {
1089
- const l = s[c].split(".");
1090
- let h = l[l.length - 1], _ = o[c];
1091
- for (const g of l) {
1092
- if (g === h) {
1093
- 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];
1094
964
  break;
1095
965
  }
1096
- _[g] = _[g] || {};
966
+ f[g] = f[g] || {};
1097
967
  }
1098
968
  }
1099
- return a;
969
+ return u;
1100
970
  }
1101
971
  };
1102
- return Y(f), f;
1103
- }, $t = C;
972
+ return Y(i), i;
973
+ }, Wt = k;
1104
974
  export {
1105
- ct as auth,
1106
- et as changeExpiredPassword,
1107
- Tt as createClient,
975
+ lt as auth,
976
+ rt as changeExpiredPassword,
977
+ Lt as clearModels,
978
+ Gt as createClient,
1108
979
  R as createCollection,
1109
- C as createList,
1110
- v as createModelManager,
1111
- Ft as createRole,
1112
- pt as createUser,
980
+ k as createList,
981
+ At as createRole,
982
+ gt as createUser,
1113
983
  W as defaultUserFields,
1114
- At as deleteRole,
1115
- gt as deleteUser,
1116
- nt as forgetPassword,
984
+ L as defineModel,
985
+ Qt as defineModels,
986
+ Ot as deleteRole,
987
+ dt as deleteUser,
988
+ ot as forgetPassword,
1117
989
  N as getApiClient,
1118
- qt as getApiClientOptional,
1119
- wt as getConfig,
1120
- I as getCurrentUser,
1121
- ft as getDrive,
1122
- at as getGrantedRights,
1123
- it as isGranted,
1124
- $t as list,
1125
- Qt as listDrives,
1126
- lt as listFiles,
1127
- ht as listFolders,
1128
- Lt as listPermissions,
1129
- mt as listRoles,
1130
- dt as listUsers,
1131
- x as login,
1132
- 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,
1133
1008
  p as mutation,
1134
1009
  y as query,
1135
- ut as readFileAsBase64,
1136
- st as resetPassword,
1137
- Dt as sendMail,
1010
+ ht as readFileAsBase64,
1011
+ nt as resetPassword,
1012
+ Ct as sendMail,
1138
1013
  Y as setApiClient,
1139
1014
  kt as toQuery,
1140
- rt as updatePassword,
1141
- _t as updateUser,
1142
- Bt as useGlobalModel,
1143
- Jt as useGlobalModels,
1144
- Nt as useModel,
1145
- ot as verifyCode,
1015
+ st as updatePassword,
1016
+ yt as updateUser,
1017
+ it as verifyCode,
1146
1018
  K as webAuthn
1147
1019
  };