@hostlink/light 2.11.2 → 2.13.1

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