@hostlink/light 3.0.7 → 3.0.8

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,21 +1,21 @@
1
1
  import { jsonToGraphQLQuery as v, VariableType as w } from "json-to-graphql-query";
2
- import z from "axios";
3
2
  import U from "collect.js";
4
- function k(t) {
3
+ import z from "axios";
4
+ function j(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
10
  function E(t, e, r = ".", n) {
11
- if (!k(e))
11
+ if (!j(e))
12
12
  return E(t, {}, r, n);
13
13
  const o = Object.assign({}, e);
14
14
  for (const c in t) {
15
15
  if (c === "__proto__" || c === "constructor")
16
16
  continue;
17
17
  const l = t[c];
18
- l != null && (n && n(o, c, l, r) || (Array.isArray(l) && Array.isArray(o[c]) ? o[c] = [...l, ...o[c]] : k(l) && k(o[c]) ? o[c] = E(
18
+ l != null && (n && n(o, c, l, r) || (Array.isArray(l) && Array.isArray(o[c]) ? o[c] = [...l, ...o[c]] : j(l) && j(o[c]) ? o[c] = E(
19
19
  l,
20
20
  o[c],
21
21
  (r ? `${r}.` : "") + c.toString(),
@@ -38,7 +38,7 @@ const X = (t) => {
38
38
  if (!O)
39
39
  throw new Error("Api client not initialized. Call setApiClient() first.");
40
40
  return O;
41
- }, Jt = () => O;
41
+ }, Mt = () => O;
42
42
  function A(t) {
43
43
  for (let e = 0; e < t.length; e++)
44
44
  if (t[e] instanceof File)
@@ -55,11 +55,11 @@ function Y(t) {
55
55
  t = "<~" + t + "~>";
56
56
  var e, r, n, o, c, l = String, h = 255;
57
57
  for (t.slice(0, 2) === "<~" && t.slice(-2), t = t.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), e = "uuuuu".slice(t.length % 5 || 5), t += e, n = [], o = 0, c = t.length; c > o; o += 5) r = 52200625 * (t.charCodeAt(o) - 33) + 614125 * (t.charCodeAt(o + 1) - 33) + 7225 * (t.charCodeAt(o + 2) - 33) + 85 * (t.charCodeAt(o + 3) - 33) + (t.charCodeAt(o + 4) - 33), n.push(h & r >> 24, h & r >> 16, h & r >> 8, h & r);
58
- return (function(s, a) {
59
- for (var i = a; i > 0; i--) s.pop();
58
+ return (function(s, i) {
59
+ for (var a = i; a > 0; a--) s.pop();
60
60
  })(n, e.length), l.fromCharCode.apply(l, n);
61
61
  }
62
- const M = (t = "") => {
62
+ const N = (t = "") => {
63
63
  const e = t, r = (n = "application/octet-stream") => {
64
64
  const o = new Uint8Array(e.length);
65
65
  for (let h = 0; h < e.length; h++)
@@ -78,33 +78,33 @@ const M = (t = "") => {
78
78
  window.open(r(n), "_blank");
79
79
  }
80
80
  };
81
- }, Lt = (t) => M(atob(t)), $t = (t) => M(Y(t));
82
- function N(t, e, r, n, o) {
81
+ }, Jt = (t) => N(atob(t)), Lt = (t) => N(Y(t));
82
+ function M(t, e, r, n, o) {
83
83
  if (!(!t || typeof t != "object"))
84
84
  for (let c in t) {
85
85
  const l = t[c];
86
86
  if (l && typeof l == "object") {
87
87
  if ("__args" in l) {
88
88
  const h = l.__args, s = {};
89
- Object.entries(h).forEach(([a, i]) => {
90
- if (i instanceof Array && A(i)) {
91
- s[a] = new w(a);
89
+ Object.entries(h).forEach(([i, a]) => {
90
+ if (a instanceof Array && A(a)) {
91
+ s[i] = new w(i);
92
92
  let u = 0;
93
- i.forEach((f) => {
94
- f instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + a + "." + u), n.append(o.current.toString(), f), o.current++, u++);
95
- }), e[a] = "[Upload!]!";
96
- } else i instanceof File ? (s[a] = new w(a), r[o.current] = ["variables." + a], n.append(o.current.toString(), i), e[a] = "Upload!", o.current++) : i instanceof Object && B(i) ? (s[a] = {}, Object.entries(i).forEach(([u, f]) => {
97
- if (f instanceof Array && A(f)) {
98
- s[a][u] = new w(u);
93
+ a.forEach((p) => {
94
+ p instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + i + "." + u), n.append(o.current.toString(), p), o.current++, u++);
95
+ }), e[i] = "[Upload!]!";
96
+ } else a instanceof File ? (s[i] = new w(i), r[o.current] = ["variables." + i], n.append(o.current.toString(), a), e[i] = "Upload!", o.current++) : a instanceof Object && B(a) ? (s[i] = {}, Object.entries(a).forEach(([u, p]) => {
97
+ if (p instanceof Array && A(p)) {
98
+ s[i][u] = new w(u);
99
99
  let _ = 0;
100
- f.forEach((d) => {
100
+ p.forEach((d) => {
101
101
  d instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + u + "." + _), n.append(o.current.toString(), d), o.current++, _++);
102
102
  }), e[u] = "[Upload!]!";
103
- } else f instanceof File ? (s[a][u] = new w(u), r[o.current] = ["variables." + u], n.append(o.current.toString(), f), e[u] = "Upload!", o.current++) : s[a][u] = f;
104
- })) : i != null && (s[a] = i);
103
+ } else p instanceof File ? (s[i][u] = new w(u), r[o.current] = ["variables." + u], n.append(o.current.toString(), p), e[u] = "Upload!", o.current++) : s[i][u] = p;
104
+ })) : a != null && (s[i] = a);
105
105
  }), l.__args = s;
106
106
  }
107
- N(l, e, r, n, o);
107
+ M(l, e, r, n, o);
108
108
  }
109
109
  }
110
110
  }
@@ -112,20 +112,20 @@ const y = async (t) => {
112
112
  const { axios: e } = q(), r = t, n = new FormData();
113
113
  let o = !1;
114
114
  const c = {}, l = {};
115
- N(r, c, l, n, { current: 0 }), o = Object.keys(c).length > 0, o && (r.__variables = c);
115
+ M(r, c, l, n, { current: 0 }), o = Object.keys(c).length > 0, o && (r.__variables = c);
116
116
  let s = null;
117
- const i = v({ query: r });
117
+ const a = v({ query: r });
118
118
  if (o ? (n.append("map", JSON.stringify(l)), n.append("operations", JSON.stringify({
119
- query: i
119
+ query: a
120
120
  })), s = await e.post("", n)) : s = await e.post("", {
121
- query: i
121
+ query: a
122
122
  }), s.data.errors)
123
123
  throw new Error(s.data.errors[0].message);
124
124
  return s.data.data;
125
125
  };
126
126
  function C(t, e) {
127
127
  let r, n = [], o, c;
128
- const l = (s) => !s || typeof s != "object" ? !1 : Object.values(s).some((a) => a && typeof a == "object" && Object.keys(a).some((i) => i.startsWith("_"))), h = () => n.length === 0 ? (n.unshift({}), n[0]) : (l(n[0]) && n.unshift({}), n[0]);
128
+ const l = (s) => !s || typeof s != "object" ? !1 : Object.values(s).some((i) => i && typeof i == "object" && Object.keys(i).some((a) => a.startsWith("_"))), h = () => n.length === 0 ? (n.unshift({}), n[0]) : (l(n[0]) && n.unshift({}), n[0]);
129
129
  return {
130
130
  first() {
131
131
  return this.fetchFirst();
@@ -134,28 +134,28 @@ function C(t, e) {
134
134
  return this.fetch();
135
135
  },
136
136
  async fetchFirst() {
137
- const a = await this.limit(1).fetch();
138
- return Array.isArray(a) && a.length > 0 ? a[0] : null;
137
+ const i = await this.limit(1).fetch();
138
+ return Array.isArray(i) && i.length > 0 ? i[0] : null;
139
139
  },
140
140
  async fetchWithMeta() {
141
- let a = await y(this.toQuery(!0));
141
+ let i = await y(this.toQuery(!0));
142
142
  if (c) {
143
- const i = c.split(".");
144
- for (const u of i)
145
- a = a[u];
146
- return a;
143
+ const a = c.split(".");
144
+ for (const u of a)
145
+ i = i[u];
146
+ return i;
147
147
  }
148
- return a[`list${t}`];
148
+ return i[`list${t}`];
149
149
  },
150
150
  async fetch() {
151
- let a = await y(this.toQuery());
151
+ let i = await y(this.toQuery());
152
152
  if (c) {
153
- const i = c.split(".");
154
- for (const u of i)
155
- a = a[u];
156
- return a.data;
153
+ const a = c.split(".");
154
+ for (const u of a)
155
+ i = i[u];
156
+ return i.data;
157
157
  }
158
- return a[`list${t}`].data;
158
+ return i[`list${t}`].data;
159
159
  },
160
160
  dataPath(s) {
161
161
  return s && typeof s == "string" && (c = s), this;
@@ -169,8 +169,8 @@ function C(t, e) {
169
169
  // where can be called as:
170
170
  // where('key', value) -> exact match
171
171
  // where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
172
- where(s, a, i) {
173
- const u = (f, _, d) => {
172
+ where(s, i, a) {
173
+ const u = (p, _, d) => {
174
174
  const F = {
175
175
  ">": "_gt",
176
176
  "<": "_lt",
@@ -180,40 +180,40 @@ function C(t, e) {
180
180
  in: "_in",
181
181
  contains: "_contains"
182
182
  }[_];
183
- F && n.push({ [f]: { [F]: d } });
183
+ F && n.push({ [p]: { [F]: d } });
184
184
  };
185
- if (i !== void 0)
186
- u(s, String(a), i);
185
+ if (a !== void 0)
186
+ u(s, String(i), a);
187
187
  else {
188
- const f = h(), _ = m(f, { [s]: a });
188
+ const p = h(), _ = m(p, { [s]: i });
189
189
  n[0] = _;
190
190
  }
191
191
  return this;
192
192
  },
193
193
  // whereContains adds a _contains filter for a specific field
194
194
  // If the same field is used multiple times, it merges them into an array
195
- whereContains(s, a) {
195
+ whereContains(s, i) {
196
196
  if (s && typeof s == "string") {
197
- const i = h(), u = { _contains: a };
198
- i[s] ? Array.isArray(i[s]) ? i[s].push(u) : i[s] = [i[s], u] : i[s] = [u], n[0] = i;
197
+ const a = h(), u = { _contains: i };
198
+ a[s] ? Array.isArray(a[s]) ? a[s].push(u) : a[s] = [a[s], u] : a[s] = [u], n[0] = a;
199
199
  }
200
200
  return this;
201
201
  },
202
202
  // ...existing code...
203
203
  // whereIn adds an _in filter for a specific field
204
204
  // If the same field is used multiple times, it merges them into an array
205
- whereIn(s, a) {
206
- if (s && typeof s == "string" && Array.isArray(a)) {
207
- const i = h(), u = { _in: a };
208
- i[s] ? Array.isArray(i[s]) ? i[s].push(u) : i[s] = [i[s], u] : i[s] = [u], n[0] = i;
205
+ whereIn(s, i) {
206
+ if (s && typeof s == "string" && Array.isArray(i)) {
207
+ const a = h(), u = { _in: i };
208
+ a[s] ? Array.isArray(a[s]) ? a[s].push(u) : a[s] = [a[s], u] : a[s] = [u], n[0] = a;
209
209
  }
210
210
  return this;
211
211
  },
212
212
  // whereBetween adds a _between filter for a specific field
213
- whereBetween(s, a, i) {
213
+ whereBetween(s, i, a) {
214
214
  if (s && typeof s == "string") {
215
- const u = h(), f = { _between: [a, i] };
216
- u[s] ? Array.isArray(u[s]) ? u[s].push(f) : u[s] = [u[s], f] : u[s] = f, n[0] = u;
215
+ const u = h(), p = { _between: [i, a] };
216
+ u[s] ? Array.isArray(u[s]) ? u[s].push(p) : u[s] = [u[s], p] : u[s] = p, n[0] = u;
217
217
  }
218
218
  return this;
219
219
  },
@@ -226,12 +226,12 @@ function C(t, e) {
226
226
  return typeof s == "number" && Number.isFinite(s) && (r = m(r || {}, { offset: s })), this;
227
227
  },
228
228
  toQuery(s = !1) {
229
- let a;
230
- const i = n.length > 0 && Object.keys(n[0] || {}).length > 0, u = i ? 1 : 0, f = n.length > u;
231
- i && f ? a = n : f ? a = n.slice(u) : i && (a = n[0]);
229
+ let i;
230
+ const a = n.length > 0 && Object.keys(n[0] || {}).length > 0, u = a ? 1 : 0, p = n.length > u;
231
+ a && p ? i = n : p ? i = n.slice(u) : a && (i = n[0]);
232
232
  const _ = m(
233
233
  o ? { sort: o } : {},
234
- a ? { filters: a } : {}
234
+ i ? { filters: i } : {}
235
235
  ), d = {
236
236
  data: {
237
237
  ...e
@@ -244,9 +244,9 @@ function C(t, e) {
244
244
  }), c) {
245
245
  const D = c.split(".");
246
246
  let F = d;
247
- for (let j = D.length - 1; j >= 0; j--)
247
+ for (let k = D.length - 1; k >= 0; k--)
248
248
  F = {
249
- [D[j]]: F
249
+ [D[k]]: F
250
250
  };
251
251
  return F;
252
252
  }
@@ -256,7 +256,240 @@ function C(t, e) {
256
256
  }
257
257
  };
258
258
  }
259
- const Z = (t, e = {}) => {
259
+ const Z = "list", V = [
260
+ "flatMap",
261
+ "chunk",
262
+ "shuffle",
263
+ "splice",
264
+ "sortBy",
265
+ "map",
266
+ "reverse",
267
+ "groupBy",
268
+ "keyBy",
269
+ "keys",
270
+ "mapToDictionary",
271
+ "mapWithKeys",
272
+ "nth",
273
+ "skipUntil",
274
+ "skipWhile",
275
+ "takeUntil",
276
+ "takeWhile",
277
+ "unique",
278
+ "pluck",
279
+ "push",
280
+ "only",
281
+ "pad",
282
+ "slice",
283
+ "tap",
284
+ "sort"
285
+ ], I = [
286
+ "avg",
287
+ "count",
288
+ "countBy",
289
+ "dd",
290
+ "each",
291
+ "every",
292
+ "filter",
293
+ "firstWhere",
294
+ "isEmpty",
295
+ "isNotEmpty",
296
+ "last",
297
+ "mapToGroups",
298
+ "max",
299
+ "median",
300
+ "min",
301
+ "mode",
302
+ "contains",
303
+ "sole",
304
+ "sort",
305
+ "split",
306
+ "sum",
307
+ "toJson",
308
+ "get",
309
+ "has",
310
+ "implode",
311
+ "partition"
312
+ ];
313
+ class g {
314
+ _batchData = null;
315
+ data_path = "";
316
+ filters;
317
+ steps;
318
+ fields;
319
+ already_limit = !1;
320
+ already_offset = !1;
321
+ limit = null;
322
+ offset = null;
323
+ _sort = null;
324
+ _sortDesc = !1;
325
+ meta = {};
326
+ constructor(e) {
327
+ this.filters = {}, this.steps = [], this.fields = e;
328
+ }
329
+ }
330
+ g.prototype.getQueryPayload = function() {
331
+ let t = {
332
+ meta: {
333
+ total: !0,
334
+ key: !0,
335
+ name: !0
336
+ }
337
+ };
338
+ return t.__args = this.buildArgs(), t.data = this.fields, t.data.__args = t.data.__args || {}, this.limit && (t.data.__args.limit = this.limit), this.offset && (t.data.__args.offset = this.offset), {
339
+ data_path: this.data_path,
340
+ query: t,
341
+ steps: this.steps
342
+ };
343
+ };
344
+ g.prototype.dataPath = function(t) {
345
+ const e = this.clone();
346
+ return e.data_path = t, e;
347
+ };
348
+ g.prototype.buildArgs = function() {
349
+ let t = {};
350
+ return Object.keys(this.filters).length > 0 && (t.filters = this.filters), this._sort && (t.sort = this._sort, this._sortDesc && (t.sort += ":desc")), t;
351
+ };
352
+ g.prototype.clone = function() {
353
+ const t = Object.create(this);
354
+ 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;
355
+ };
356
+ U().macro("whereContains", function(t, e) {
357
+ return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
358
+ });
359
+ g.prototype.fetchData = async function() {
360
+ try {
361
+ if (this._batchData) {
362
+ const h = this._batchData;
363
+ return this.meta = h.meta, U(h.data);
364
+ }
365
+ let t = {
366
+ meta: {
367
+ total: !0,
368
+ key: !0,
369
+ name: !0
370
+ }
371
+ };
372
+ 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);
373
+ const e = this.data_path.split(".");
374
+ let r = {}, n = r, o = e[e.length - 1];
375
+ for (const h of e) {
376
+ if (h === o) {
377
+ n[h] = t;
378
+ break;
379
+ }
380
+ n[h] = {}, n = n[h];
381
+ }
382
+ let l = await y(r);
383
+ for (const h of e)
384
+ l = l[h];
385
+ return this.meta = l.meta, U(l.data);
386
+ } catch (t) {
387
+ throw console.error("Error fetching collection data:", t), t;
388
+ }
389
+ };
390
+ g.prototype.processData = async function() {
391
+ let t = await this.fetchData();
392
+ for (const e of this.steps)
393
+ t = t[e.type](...e.args);
394
+ return t;
395
+ };
396
+ g.prototype.all = async function() {
397
+ return (await this.processData()).all();
398
+ };
399
+ for (const t of V)
400
+ g.prototype[t] = function(...e) {
401
+ const r = this.clone();
402
+ return r.steps.push({ type: t, args: e }), r;
403
+ };
404
+ for (const t of I)
405
+ g.prototype[t] = async function(...e) {
406
+ return (await this.clone().processData())[t](...e);
407
+ };
408
+ g.prototype.average = g.prototype.avg;
409
+ g.prototype.first = async function() {
410
+ return this.take(1), (await this.processData()).first();
411
+ };
412
+ g.prototype._handleBatchData = function(t, e) {
413
+ return this._batchData ? (this.steps.push({ type: t, args: e }), this) : null;
414
+ };
415
+ g.prototype.where = function(...t) {
416
+ const e = this._handleBatchData("where", t);
417
+ if (e) return e;
418
+ if (t.length === 2)
419
+ this.filters[t[0]] = t[1];
420
+ else if (t.length === 3) {
421
+ const r = t[0], n = t[1], o = t[2];
422
+ switch (n) {
423
+ case "==":
424
+ this.filters[r] = o;
425
+ break;
426
+ case "<":
427
+ this.filters[r] = { lt: o };
428
+ break;
429
+ case "<=":
430
+ this.filters[r] = { lte: o };
431
+ break;
432
+ case ">":
433
+ this.filters[r] = { gt: o };
434
+ break;
435
+ case ">=":
436
+ this.filters[r] = { gte: o };
437
+ break;
438
+ case "!==":
439
+ this.filters[r] = { ne: o };
440
+ break;
441
+ default:
442
+ throw new Error(`Unsupported operator: ${n}`);
443
+ }
444
+ }
445
+ return this;
446
+ };
447
+ g.prototype.whereContains = function(t, e) {
448
+ const r = this._handleBatchData("whereContains", [t, e]);
449
+ return r || (this.filters[t] = { contains: e }, this);
450
+ };
451
+ g.prototype.forPage = function(t, e) {
452
+ 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);
453
+ };
454
+ g.prototype.whereIn = function(t, e) {
455
+ const r = this._handleBatchData("whereIn", [t, e]);
456
+ return r || (this.filters[t] = { in: e }, this);
457
+ };
458
+ g.prototype.whereNotIn = function(t, e) {
459
+ const r = this._handleBatchData("whereNotIn", [t, e]);
460
+ return r || (this.filters[t] = { nin: e }, this);
461
+ };
462
+ g.prototype.whereNotBetween = function(t, e) {
463
+ const r = this._handleBatchData("whereNotBetween", [t, e]);
464
+ return r || (this.filters[t] = { notBetween: e }, this);
465
+ };
466
+ g.prototype.whereBetween = function(t, e) {
467
+ const r = this._handleBatchData("whereBetween", [t, e]);
468
+ return r || (this.filters[t] = { between: e }, this);
469
+ };
470
+ g.prototype.sortBy = function(t) {
471
+ return this.steps.push({ type: "sortBy", args: [t] }), typeof t == "string" && (this._sort = t), this;
472
+ };
473
+ g.prototype.sortByDesc = function(t) {
474
+ return this.steps.push({ type: "sortByDesc", args: [t] }), typeof t == "string" && (this._sort = t, this._sortDesc = !0), this;
475
+ };
476
+ g.prototype.skip = function(t) {
477
+ if (t < 0)
478
+ throw new Error("Offset must be non-negative");
479
+ return this.already_offset && this.steps.push({ type: "skip", args: [t] }), this.offset = t, this.already_offset = !0, this;
480
+ };
481
+ g.prototype.take = function(t) {
482
+ if (t < 0)
483
+ throw new Error("Length must be non-negative");
484
+ return this.already_limit ? (this.steps.push({ type: "take", args: [t] }), this) : (this.limit = t, this.already_limit = !0, this);
485
+ };
486
+ g.prototype.splice = function(t, e) {
487
+ return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
488
+ };
489
+ const J = (t, e) => {
490
+ const r = new g(e);
491
+ return r.data_path = Z + t, r;
492
+ }, K = (t, e = {}) => {
260
493
  const r = e;
261
494
  let n = "list" + t;
262
495
  const o = (c) => r[c] ? r[c] : null;
@@ -279,21 +512,21 @@ const Z = (t, e = {}) => {
279
512
  return l;
280
513
  },
281
514
  update(c, l) {
282
- return p({
515
+ return f({
283
516
  ["update" + t]: {
284
517
  __args: { id: c, data: l }
285
518
  }
286
519
  }).then((h) => h["update" + t]);
287
520
  },
288
521
  async delete(c) {
289
- return p({
522
+ return f({
290
523
  ["delete" + t]: {
291
524
  __args: { id: c }
292
525
  }
293
526
  }).then((l) => l["delete" + t]);
294
527
  },
295
528
  add(c) {
296
- return p({
529
+ return f({
297
530
  ["add" + t]: {
298
531
  __args: { data: c }
299
532
  }
@@ -308,53 +541,53 @@ const Z = (t, e = {}) => {
308
541
  return l;
309
542
  },
310
543
  async get(c, l) {
311
- const h = (await Promise.resolve().then(() => qt)).default, s = h(t, Ut(l));
312
- for (const [a, i] of Object.entries(c))
313
- s.where(a, "==", i);
314
- return await s.first();
544
+ const h = J(t, vt(l));
545
+ for (const [s, i] of Object.entries(c))
546
+ h.where(s, "==", i);
547
+ return await h.first();
315
548
  },
316
549
  list(c) {
317
550
  let l = c;
318
551
  const h = {};
319
- Object.entries(c).forEach(([i]) => {
320
- r[i] && (h[i] = r[i], r[i].gqlField && (delete l[i], l = m(l, r[i].gqlField)), r[i].gql && (l = m(l, r[i].gql), delete l[i]));
552
+ Object.entries(c).forEach(([a]) => {
553
+ r[a] && (h[a] = r[a], r[a].gqlField && (delete l[a], l = m(l, r[a].gqlField)), r[a].gql && (l = m(l, r[a].gql), delete l[a]));
321
554
  });
322
- const s = C(t, l).dataPath(n), a = s.fetch.bind(s);
555
+ const s = C(t, l).dataPath(n), i = s.fetch.bind(s);
323
556
  return {
324
557
  ...s,
325
558
  async fetch() {
326
- return (await a()).map((u) => {
327
- const f = { ...u };
559
+ return (await i()).map((u) => {
560
+ const p = { ...u };
328
561
  return Object.entries(h).forEach(([_, d]) => {
329
- d.format && typeof d.format == "function" && (f[_] = d.format(u));
330
- }), f;
562
+ d.format && typeof d.format == "function" && (p[_] = d.format(u));
563
+ }), p;
331
564
  });
332
565
  },
333
566
  async fetchFirst() {
334
567
  const u = await s.fetchFirst.bind(s)();
335
568
  if (!u) return u;
336
- const f = { ...u };
569
+ const p = { ...u };
337
570
  return Object.entries(h).forEach(([_, d]) => {
338
- d.format && typeof d.format == "function" && (f[_] = d.format(u));
339
- }), f;
571
+ d.format && typeof d.format == "function" && (p[_] = d.format(u));
572
+ }), p;
340
573
  }
341
574
  };
342
575
  }
343
576
  };
344
- }, b = {}, J = (t, e) => {
345
- const r = Z(t, e);
577
+ }, b = {}, L = (t, e) => {
578
+ const r = K(t, e);
346
579
  return b[t] = r, r;
347
- }, P = (t) => b[t] ? b[t] : J(t, {}), Qt = (t) => !!b[t], Tt = () => Object.keys(b), Gt = () => {
580
+ }, P = (t) => b[t] ? b[t] : L(t, {}), $t = (t) => !!b[t], Qt = () => Object.keys(b), Gt = () => {
348
581
  Object.keys(b).forEach((t) => delete b[t]);
349
- }, Rt = (t) => {
582
+ }, Tt = (t) => {
350
583
  Object.entries(t).forEach(([e, r]) => {
351
- J(e, r);
584
+ L(e, r);
352
585
  });
353
- }, Wt = () => y({
586
+ }, Rt = () => y({
354
587
  app: {
355
588
  permissions: !0
356
589
  }
357
- }).then((t) => t.app.permissions), L = async () => {
590
+ }).then((t) => t.app.permissions), $ = async () => {
358
591
  const { app: t } = await y({
359
592
  app: {
360
593
  auth: {
@@ -363,7 +596,7 @@ const Z = (t, e = {}) => {
363
596
  }
364
597
  }), e = t.auth.webAuthnRequestOptions, r = PublicKeyCredential.parseRequestOptionsFromJSON(e);
365
598
  return await navigator.credentials.get({ publicKey: r });
366
- }, $ = async () => {
599
+ }, Q = async () => {
367
600
  const { app: t } = await y({
368
601
  app: {
369
602
  auth: {
@@ -372,31 +605,31 @@ const Z = (t, e = {}) => {
372
605
  }
373
606
  }), e = PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);
374
607
  return await navigator.credentials.create({ publicKey: e });
375
- }, V = async () => {
376
- const t = await L();
377
- return await p({
608
+ }, x = async () => {
609
+ const t = await $();
610
+ return await f({
378
611
  webAuthnAssertion: {
379
612
  __args: {
380
613
  assertion: t.toJSON()
381
614
  }
382
615
  }
383
616
  }).then((e) => e.webAuthnAssertion);
384
- }, I = async () => {
385
- const t = await $();
386
- return await p({
617
+ }, tt = async () => {
618
+ const t = await Q();
619
+ return await f({
387
620
  webAuthnRegister: {
388
621
  __args: {
389
622
  registration: t.toJSON()
390
623
  }
391
624
  }
392
625
  }).then((e) => e.webAuthnRegister);
393
- }, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
626
+ }, et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
394
627
  __proto__: null,
395
- assertion: L,
396
- attestation: $,
397
- login: V,
398
- register: I
399
- }, Symbol.toStringTag, { value: "Module" })), x = (t = G) => y({ my: t }).then((e) => e.my), tt = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((n) => n.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((n) => n.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((n) => n.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({
628
+ assertion: $,
629
+ attestation: Q,
630
+ login: x,
631
+ register: tt
632
+ }, Symbol.toStringTag, { value: "Module" })), rt = (t = R) => y({ my: t }).then((e) => e.my), st = (t, e, r = "") => f({ login: { __args: { username: t, password: e, code: r } } }).then((n) => n.login), nt = () => f({ logout: !0 }).then((t) => t.logout), ot = (t, e, r) => f({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((n) => n.changeExpiredPassword), it = (t, e) => f({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), at = (t, e, r) => f({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((n) => n.resetPassword), ct = (t, e) => f({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), lt = (t, e) => f({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), ut = (t) => y({
400
633
  my: {
401
634
  granted: {
402
635
  __args: {
@@ -404,7 +637,7 @@ const Z = (t, e = {}) => {
404
637
  }
405
638
  }
406
639
  }
407
- }).then((e) => e.my.granted), ct = (t) => y({
640
+ }).then((e) => e.my.granted), ht = (t) => y({
408
641
  my: {
409
642
  grantedRights: {
410
643
  __args: {
@@ -412,40 +645,40 @@ const Z = (t, e = {}) => {
412
645
  }
413
646
  }
414
647
  }
415
- }).then((e) => e.my.grantedRights), lt = {
416
- getCurrentUser: x,
417
- webAuthn: K,
648
+ }).then((e) => e.my.grantedRights), pt = {
649
+ getCurrentUser: rt,
650
+ webAuthn: et,
418
651
  google: {
419
- unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
420
- login: (t) => p({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
421
- register: (t) => p({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
652
+ unlink: () => f({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
653
+ login: (t) => f({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
654
+ register: (t) => f({ lightAuthRegisterGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthRegisterGoogle)
422
655
  },
423
656
  facebook: {
424
- unlink: () => p({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
425
- login: (t) => p({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
426
- register: (t) => p({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
657
+ unlink: () => f({ lightAuthUnlinkFacebook: !0 }).then((t) => t.lightAuthUnlinkFacebook),
658
+ login: (t) => f({ lightAuthLoginFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginFacebook),
659
+ register: (t) => f({ lightAuthRegisterFacebook: { __args: { access_token: t } } }).then((e) => e.lightAuthRegisterFacebook)
427
660
  },
428
661
  microsoft: {
429
- unlink: () => p({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
430
- login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
431
- register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
662
+ unlink: () => f({ lightAuthUnlinkMicrosoft: !0 }).then((t) => t.lightAuthUnlinkMicrosoft),
663
+ login: (t) => f({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
664
+ register: (t) => f({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
432
665
  },
433
- login: tt,
434
- logout: et,
435
- changeExpiredPassword: rt,
436
- updatePassword: st,
437
- resetPassword: nt,
438
- forgetPassword: ot,
439
- verifyCode: it,
440
- grantedRights: ct,
441
- isGranted: at
442
- }, Q = {
666
+ login: st,
667
+ logout: nt,
668
+ changeExpiredPassword: ot,
669
+ updatePassword: it,
670
+ resetPassword: at,
671
+ forgetPassword: ct,
672
+ verifyCode: lt,
673
+ grantedRights: ht,
674
+ isGranted: ut
675
+ }, G = {
443
676
  name: !0,
444
677
  path: !0,
445
678
  size: !0,
446
679
  mime: !0,
447
680
  url: !0
448
- }, ut = (t, e, r = Q) => y({
681
+ }, ft = (t, e, r = G) => y({
449
682
  app: {
450
683
  drive: {
451
684
  __args: { index: t },
@@ -455,7 +688,7 @@ const Z = (t, e = {}) => {
455
688
  }
456
689
  }
457
690
  }
458
- }).then((n) => n.app.drive.files), ht = (t, e) => y({
691
+ }).then((n) => n.app.drive.files), dt = (t, e) => y({
459
692
  app: {
460
693
  drive: {
461
694
  __args: {
@@ -469,8 +702,8 @@ const Z = (t, e = {}) => {
469
702
  }
470
703
  }
471
704
  }
472
- }).then((r) => r.app.drive?.file?.base64Content), ft = (t) => ({
473
- list: (e, r = Q) => ut(t, e, r),
705
+ }).then((r) => r.app.drive?.file?.base64Content), gt = (t) => ({
706
+ list: (e, r = G) => ft(t, e, r),
474
707
  get: (e, r = {
475
708
  name: !0,
476
709
  path: !0,
@@ -493,7 +726,7 @@ const Z = (t, e = {}) => {
493
726
  }
494
727
  }).then((n) => n.app.drive.file),
495
728
  readFileAsBase64(e) {
496
- return ht(t, e);
729
+ return dt(t, e);
497
730
  },
498
731
  read: async (e) => {
499
732
  let r = await y({
@@ -515,14 +748,14 @@ const Z = (t, e = {}) => {
515
748
  throw new Error(`File not found or cannot read content: ${e}`);
516
749
  return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
517
750
  },
518
- write: (e, r) => p({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((n) => n.lightDriveWriteFile),
519
- delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
520
- rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
521
- move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((n) => n.lightDriveMoveFile)
751
+ write: (e, r) => f({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((n) => n.lightDriveWriteFile),
752
+ delete: (e) => f({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
753
+ rename: (e, r) => f({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
754
+ move: (e, r) => f({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((n) => n.lightDriveMoveFile)
522
755
  }), T = {
523
756
  name: !0,
524
757
  path: !0
525
- }, pt = (t, e, r = T) => y({
758
+ }, _t = (t, e, r = T) => y({
526
759
  app: {
527
760
  drive: {
528
761
  __args: { index: t },
@@ -532,20 +765,20 @@ const Z = (t, e = {}) => {
532
765
  }
533
766
  }
534
767
  }
535
- }).then((n) => n.app.drive.folders), dt = (t) => ({
536
- list: (e, r = T) => pt(t, e, r),
537
- create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
538
- delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
539
- rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
540
- }), zt = () => y({
768
+ }).then((n) => n.app.drive.folders), yt = (t) => ({
769
+ list: (e, r = T) => _t(t, e, r),
770
+ create: (e) => f({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
771
+ delete: (e) => f({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
772
+ rename: (e, r) => f({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
773
+ }), Wt = () => y({
541
774
  app: {
542
775
  drives: {
543
776
  index: !0,
544
777
  name: !0
545
778
  }
546
779
  }
547
- }).then((t) => t.app.drives), gt = (t) => {
548
- const e = ft(t), r = dt(t);
780
+ }).then((t) => t.app.drives), wt = (t) => {
781
+ const e = gt(t), r = yt(t);
549
782
  return {
550
783
  folders: r,
551
784
  files: e,
@@ -560,7 +793,7 @@ const Z = (t, e = {}) => {
560
793
  createFolder: r.create,
561
794
  deleteFolder: r.delete,
562
795
  renameFolder: r.rename,
563
- uploadTempFile: (n) => p({
796
+ uploadTempFile: (n) => f({
564
797
  lightDriveUploadTempFile: {
565
798
  __args: { index: t, file: n },
566
799
  name: !0,
@@ -570,30 +803,30 @@ const Z = (t, e = {}) => {
570
803
  }
571
804
  }).then((o) => o.lightDriveUploadTempFile)
572
805
  };
573
- }, G = {
806
+ }, R = {
574
807
  user_id: !0,
575
808
  username: !0,
576
809
  first_name: !0,
577
810
  last_name: !0,
578
811
  status: !0
579
- }, _t = (t) => p({
812
+ }, mt = (t) => f({
580
813
  addUser: {
581
814
  __args: t
582
815
  }
583
- }).then((e) => e.addUser), yt = (t) => p({
816
+ }).then((e) => e.addUser), bt = (t) => f({
584
817
  deleteUser: {
585
818
  __args: { id: t }
586
819
  }
587
- }).then((e) => e.deleteUser), wt = (t = G) => C("Users", t).dataPath("app.listUser").fetch(), mt = (t, e) => p({
820
+ }).then((e) => e.deleteUser), Ft = (t = R) => C("Users", t).dataPath("app.listUser").fetch(), At = (t, e) => f({
588
821
  updateUser: {
589
822
  __args: { id: t, data: e }
590
823
  }
591
- }).then((r) => r.updateUser), bt = {
592
- list: wt,
593
- create: _t,
594
- delete: yt,
595
- update: mt
596
- }, Ft = (t) => y({
824
+ }).then((r) => r.updateUser), Ot = {
825
+ list: Ft,
826
+ create: mt,
827
+ delete: bt,
828
+ update: At
829
+ }, Ct = (t) => y({
597
830
  app: {
598
831
  listConfig: {
599
832
  __args: {
@@ -607,13 +840,13 @@ const Z = (t, e = {}) => {
607
840
  }
608
841
  }
609
842
  }
610
- }).then((e) => e.app.listConfig.data[0]?.value), At = {
843
+ }).then((e) => e.app.listConfig.data[0]?.value), Dt = {
611
844
  name: !0
612
- }, Ot = (t = At) => y({
845
+ }, kt = (t = Dt) => y({
613
846
  app: {
614
847
  roles: t
615
848
  }
616
- }).then((e) => e.app.roles), Ct = (t, e) => p({
849
+ }).then((e) => e.app.roles), jt = (t, e) => f({
617
850
  addRole: {
618
851
  __args: {
619
852
  data: {
@@ -622,60 +855,60 @@ const Z = (t, e = {}) => {
622
855
  }
623
856
  }
624
857
  }
625
- }).then((r) => r.addRole), Dt = (t) => p({
858
+ }).then((r) => r.addRole), Pt = (t) => f({
626
859
  deleteRole: {
627
860
  __args: { name: t }
628
861
  }
629
- }).then((e) => e.deleteRole), jt = () => ({
630
- list: Ot,
631
- create: Ct,
632
- delete: Dt
862
+ }).then((e) => e.deleteRole), Ut = () => ({
863
+ list: kt,
864
+ create: jt,
865
+ delete: Pt
633
866
  });
634
- function R(t, e, r, n, o) {
867
+ function W(t, e, r, n, o) {
635
868
  if (!(!t || typeof t != "object"))
636
869
  for (let c in t) {
637
870
  const l = t[c];
638
871
  if (l && typeof l == "object") {
639
872
  if ("__args" in l) {
640
873
  const h = l.__args, s = {};
641
- Object.entries(h).forEach(([a, i]) => {
642
- if (i instanceof Array && A(i)) {
643
- s[a] = new w(a);
874
+ Object.entries(h).forEach(([i, a]) => {
875
+ if (a instanceof Array && A(a)) {
876
+ s[i] = new w(i);
644
877
  let u = 0;
645
- i.forEach((f) => {
646
- f instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + a + "." + u), n.append(o.current.toString(), f), o.current++, u++);
647
- }), e[a] = "[Upload!]!";
648
- } else i instanceof File ? (s[a] = new w(a), r[o.current] = ["variables." + a], n.append(o.current.toString(), i), e[a] = "Upload!", o.current++) : i instanceof Object && B(i) ? (s[a] = {}, Object.entries(i).forEach(([u, f]) => {
649
- if (f instanceof Array && A(f)) {
650
- s[a][u] = new w(u);
878
+ a.forEach((p) => {
879
+ p instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + i + "." + u), n.append(o.current.toString(), p), o.current++, u++);
880
+ }), e[i] = "[Upload!]!";
881
+ } else a instanceof File ? (s[i] = new w(i), r[o.current] = ["variables." + i], n.append(o.current.toString(), a), e[i] = "Upload!", o.current++) : a instanceof Object && B(a) ? (s[i] = {}, Object.entries(a).forEach(([u, p]) => {
882
+ if (p instanceof Array && A(p)) {
883
+ s[i][u] = new w(u);
651
884
  let _ = 0;
652
- f.forEach((d) => {
885
+ p.forEach((d) => {
653
886
  d instanceof File && (r[o.current] || (r[o.current] = []), r[o.current].push("variables." + u + "." + _), n.append(o.current.toString(), d), o.current++, _++);
654
887
  }), e[u] = "[Upload!]!";
655
- } else f instanceof File ? (s[a][u] = new w(u), r[o.current] = ["variables." + u], n.append(o.current.toString(), f), e[u] = "Upload!", o.current++) : s[a][u] = f;
656
- })) : i != null && (s[a] = i);
888
+ } else p instanceof File ? (s[i][u] = new w(u), r[o.current] = ["variables." + u], n.append(o.current.toString(), p), e[u] = "Upload!", o.current++) : s[i][u] = p;
889
+ })) : a != null && (s[i] = a);
657
890
  }), l.__args = s;
658
891
  }
659
- R(l, e, r, n, o);
892
+ W(l, e, r, n, o);
660
893
  }
661
894
  }
662
895
  }
663
- const p = async (t) => {
896
+ const f = async (t) => {
664
897
  const { axios: e } = q(), r = t, n = new FormData();
665
898
  let o = !1;
666
899
  const c = {}, l = {};
667
- R(r, c, l, n, { current: 0 }), o = Object.keys(c).length > 0, o && (r.__variables = c);
900
+ W(r, c, l, n, { current: 0 }), o = Object.keys(c).length > 0, o && (r.__variables = c);
668
901
  let s = null;
669
- const i = v({ mutation: r });
902
+ const a = v({ mutation: r });
670
903
  if (o ? (n.append("map", JSON.stringify(l)), n.append("operations", JSON.stringify({
671
- query: i
904
+ query: a
672
905
  })), s = await e.post("", n)) : s = await e.post("", {
673
- query: i
906
+ query: a
674
907
  }), s.data.errors)
675
908
  throw new Error(s.data.errors[0].message);
676
909
  return s.data.data;
677
- }, kt = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), Pt = {
678
- send: kt
910
+ }, Et = (t, e, r) => f({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), St = {
911
+ send: Et
679
912
  }, S = (t) => {
680
913
  let e = {};
681
914
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
@@ -693,243 +926,7 @@ const p = async (t) => {
693
926
  }
694
927
  e[r] = S(n);
695
928
  }), e);
696
- }, Ut = (t) => S(t), Et = "list", St = [
697
- "flatMap",
698
- "chunk",
699
- "shuffle",
700
- "splice",
701
- "sortBy",
702
- "map",
703
- "reverse",
704
- "groupBy",
705
- "keyBy",
706
- "keys",
707
- "mapToDictionary",
708
- "mapWithKeys",
709
- "nth",
710
- "skipUntil",
711
- "skipWhile",
712
- "takeUntil",
713
- "takeWhile",
714
- "unique",
715
- "pluck",
716
- "push",
717
- "only",
718
- "pad",
719
- "slice",
720
- "tap",
721
- "sort"
722
- ], vt = [
723
- "avg",
724
- "count",
725
- "countBy",
726
- "dd",
727
- "each",
728
- "every",
729
- "filter",
730
- "firstWhere",
731
- "isEmpty",
732
- "isNotEmpty",
733
- "last",
734
- "mapToGroups",
735
- "max",
736
- "median",
737
- "min",
738
- "mode",
739
- "contains",
740
- "sole",
741
- "sort",
742
- "split",
743
- "sum",
744
- "toJson",
745
- "get",
746
- "has",
747
- "implode",
748
- "partition"
749
- ];
750
- class g {
751
- _batchData = null;
752
- data_path = "";
753
- filters;
754
- steps;
755
- fields;
756
- already_limit = !1;
757
- already_offset = !1;
758
- limit = null;
759
- offset = null;
760
- _sort = null;
761
- _sortDesc = !1;
762
- meta = {};
763
- constructor(e) {
764
- this.filters = {}, this.steps = [], this.fields = e;
765
- }
766
- }
767
- g.prototype.getQueryPayload = function() {
768
- let t = {
769
- meta: {
770
- total: !0,
771
- key: !0,
772
- name: !0
773
- }
774
- };
775
- return t.__args = this.buildArgs(), t.data = this.fields, t.data.__args = t.data.__args || {}, this.limit && (t.data.__args.limit = this.limit), this.offset && (t.data.__args.offset = this.offset), {
776
- data_path: this.data_path,
777
- query: t,
778
- steps: this.steps
779
- };
780
- };
781
- g.prototype.dataPath = function(t) {
782
- const e = this.clone();
783
- return e.data_path = t, e;
784
- };
785
- g.prototype.buildArgs = function() {
786
- let t = {};
787
- return Object.keys(this.filters).length > 0 && (t.filters = this.filters), this._sort && (t.sort = this._sort, this._sortDesc && (t.sort += ":desc")), t;
788
- };
789
- g.prototype.clone = function() {
790
- const t = Object.create(this);
791
- 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;
792
- };
793
- U().macro("whereContains", function(t, e) {
794
- return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
795
- });
796
- g.prototype.fetchData = async function() {
797
- try {
798
- if (this._batchData) {
799
- const h = this._batchData;
800
- return this.meta = h.meta, U(h.data);
801
- }
802
- let t = {
803
- meta: {
804
- total: !0,
805
- key: !0,
806
- name: !0
807
- }
808
- };
809
- 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);
810
- const e = this.data_path.split(".");
811
- let r = {}, n = r, o = e[e.length - 1];
812
- for (const h of e) {
813
- if (h === o) {
814
- n[h] = t;
815
- break;
816
- }
817
- n[h] = {}, n = n[h];
818
- }
819
- let l = await y(r);
820
- for (const h of e)
821
- l = l[h];
822
- return this.meta = l.meta, U(l.data);
823
- } catch (t) {
824
- throw console.error("Error fetching collection data:", t), t;
825
- }
826
- };
827
- g.prototype.processData = async function() {
828
- let t = await this.fetchData();
829
- for (const e of this.steps)
830
- t = t[e.type](...e.args);
831
- return t;
832
- };
833
- g.prototype.all = async function() {
834
- return (await this.processData()).all();
835
- };
836
- for (const t of St)
837
- g.prototype[t] = function(...e) {
838
- const r = this.clone();
839
- return r.steps.push({ type: t, args: e }), r;
840
- };
841
- for (const t of vt)
842
- g.prototype[t] = async function(...e) {
843
- return (await this.clone().processData())[t](...e);
844
- };
845
- g.prototype.average = g.prototype.avg;
846
- g.prototype.first = async function() {
847
- return this.take(1), (await this.processData()).first();
848
- };
849
- g.prototype._handleBatchData = function(t, e) {
850
- return this._batchData ? (this.steps.push({ type: t, args: e }), this) : null;
851
- };
852
- g.prototype.where = function(...t) {
853
- const e = this._handleBatchData("where", t);
854
- if (e) return e;
855
- if (t.length === 2)
856
- this.filters[t[0]] = t[1];
857
- else if (t.length === 3) {
858
- const r = t[0], n = t[1], o = t[2];
859
- switch (n) {
860
- case "==":
861
- this.filters[r] = o;
862
- break;
863
- case "<":
864
- this.filters[r] = { lt: o };
865
- break;
866
- case "<=":
867
- this.filters[r] = { lte: o };
868
- break;
869
- case ">":
870
- this.filters[r] = { gt: o };
871
- break;
872
- case ">=":
873
- this.filters[r] = { gte: o };
874
- break;
875
- case "!==":
876
- this.filters[r] = { ne: o };
877
- break;
878
- default:
879
- throw new Error(`Unsupported operator: ${n}`);
880
- }
881
- }
882
- return this;
883
- };
884
- g.prototype.whereContains = function(t, e) {
885
- const r = this._handleBatchData("whereContains", [t, e]);
886
- return r || (this.filters[t] = { contains: e }, this);
887
- };
888
- g.prototype.forPage = function(t, e) {
889
- 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);
890
- };
891
- g.prototype.whereIn = function(t, e) {
892
- const r = this._handleBatchData("whereIn", [t, e]);
893
- return r || (this.filters[t] = { in: e }, this);
894
- };
895
- g.prototype.whereNotIn = function(t, e) {
896
- const r = this._handleBatchData("whereNotIn", [t, e]);
897
- return r || (this.filters[t] = { nin: e }, this);
898
- };
899
- g.prototype.whereNotBetween = function(t, e) {
900
- const r = this._handleBatchData("whereNotBetween", [t, e]);
901
- return r || (this.filters[t] = { notBetween: e }, this);
902
- };
903
- g.prototype.whereBetween = function(t, e) {
904
- const r = this._handleBatchData("whereBetween", [t, e]);
905
- return r || (this.filters[t] = { between: e }, this);
906
- };
907
- g.prototype.sortBy = function(t) {
908
- return this.steps.push({ type: "sortBy", args: [t] }), typeof t == "string" && (this._sort = t), this;
909
- };
910
- g.prototype.sortByDesc = function(t) {
911
- return this.steps.push({ type: "sortByDesc", args: [t] }), typeof t == "string" && (this._sort = t, this._sortDesc = !0), this;
912
- };
913
- g.prototype.skip = function(t) {
914
- if (t < 0)
915
- throw new Error("Offset must be non-negative");
916
- return this.already_offset && this.steps.push({ type: "skip", args: [t] }), this.offset = t, this.already_offset = !0, this;
917
- };
918
- g.prototype.take = function(t) {
919
- if (t < 0)
920
- throw new Error("Length must be non-negative");
921
- return this.already_limit ? (this.steps.push({ type: "take", args: [t] }), this) : (this.limit = t, this.already_limit = !0, this);
922
- };
923
- g.prototype.splice = function(t, e) {
924
- return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
925
- };
926
- const W = (t, e) => {
927
- const r = new g(e);
928
- return r.data_path = Et + t, r;
929
- }, qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
930
- __proto__: null,
931
- default: W
932
- }, Symbol.toStringTag, { value: "Module" })), Ht = (t) => {
929
+ }, vt = (t) => S(t), zt = (t) => {
933
930
  const e = typeof window > "u";
934
931
  let r = [];
935
932
  const n = z.create({
@@ -940,11 +937,11 @@ const W = (t, e) => {
940
937
  if (c.headers["set-cookie"]) {
941
938
  const l = c.headers["set-cookie"].map((s) => s.split(";")[0]), h = /* @__PURE__ */ new Map();
942
939
  r.forEach((s) => {
943
- const a = s.split("=")[0];
944
- h.set(a, s);
940
+ const i = s.split("=")[0];
941
+ h.set(i, s);
945
942
  }), l.forEach((s) => {
946
- const a = s.split("=")[0];
947
- h.set(a, s);
943
+ const i = s.split("=")[0];
944
+ h.set(i, s);
948
945
  }), r = Array.from(h.values());
949
946
  }
950
947
  return c;
@@ -953,103 +950,103 @@ const W = (t, e) => {
953
950
  post: n.post,
954
951
  baseURL: t,
955
952
  axios: n,
956
- auth: lt,
957
- mutation: p,
953
+ auth: pt,
954
+ mutation: f,
958
955
  query: y,
959
- config: Ft,
960
- mail: Pt,
961
- users: bt,
956
+ config: Ct,
957
+ mail: St,
958
+ users: Ot,
962
959
  model(c) {
963
960
  return P(c);
964
961
  },
965
- roles: jt(),
962
+ roles: Ut(),
966
963
  collect: (c, l) => {
967
- const h = W(c, l);
964
+ const h = J(c, l);
968
965
  return h.data_path = P(c).getDataPath(), h;
969
966
  },
970
967
  list: (c, l) => C(c, l).dataPath(P(c).getDataPath()),
971
- drive: gt,
968
+ drive: wt,
972
969
  async collects(c) {
973
970
  const l = {}, h = {};
974
- for (const a in c) {
975
- const i = c[a].getQueryPayload();
976
- h[a] = i.data_path, l[a] = {};
977
- const u = i.data_path.split(".");
978
- let f = u[u.length - 1], _ = l[a];
971
+ for (const i in c) {
972
+ const a = c[i].getQueryPayload();
973
+ h[i] = a.data_path, l[i] = {};
974
+ const u = a.data_path.split(".");
975
+ let p = u[u.length - 1], _ = l[i];
979
976
  for (const d of u) {
980
- if (d === f) {
981
- _[d] = i.query;
977
+ if (d === p) {
978
+ _[d] = a.query;
982
979
  break;
983
980
  }
984
981
  _[d] = _[d] || {};
985
982
  }
986
- l[a].__aliasFor = u[0];
983
+ l[i].__aliasFor = u[0];
987
984
  }
988
985
  const s = await y(l);
989
- for (const a in c) {
990
- const i = h[a].split(".");
991
- let u = i[i.length - 1], f = s[a];
992
- for (const _ of i) {
986
+ for (const i in c) {
987
+ const a = h[i].split(".");
988
+ let u = a[a.length - 1], p = s[i];
989
+ for (const _ of a) {
993
990
  if (_ === u) {
994
- c[a]._batchData = s[a][_];
991
+ c[i]._batchData = s[i][_];
995
992
  break;
996
993
  }
997
- f[_] = f[_] || {};
994
+ p[_] = p[_] || {};
998
995
  }
999
996
  }
1000
997
  return c;
1001
998
  }
1002
999
  };
1003
1000
  return X(o), o;
1004
- }, Xt = C;
1001
+ }, Ht = C;
1005
1002
  export {
1006
1003
  A as arrayHasFile,
1007
- lt as auth,
1008
- rt as changeExpiredPassword,
1004
+ pt as auth,
1005
+ ot as changeExpiredPassword,
1009
1006
  Gt as clearModels,
1010
- Ht as createClient,
1011
- W as createCollection,
1012
- Lt as createFileFromBase64,
1013
- $t as createFileFromBase85,
1014
- M as createFileFromString,
1007
+ zt as createClient,
1008
+ J as createCollection,
1009
+ Jt as createFileFromBase64,
1010
+ Lt as createFileFromBase85,
1011
+ N as createFileFromString,
1015
1012
  C as createList,
1016
- Ct as createRole,
1017
- _t as createUser,
1018
- G as defaultUserFields,
1019
- J as defineModel,
1020
- Rt as defineModels,
1021
- Dt as deleteRole,
1022
- yt as deleteUser,
1023
- ot as forgetPassword,
1013
+ jt as createRole,
1014
+ mt as createUser,
1015
+ R as defaultUserFields,
1016
+ L as defineModel,
1017
+ Tt as defineModels,
1018
+ Pt as deleteRole,
1019
+ bt as deleteUser,
1020
+ ct as forgetPassword,
1024
1021
  q as getApiClient,
1025
- Jt as getApiClientOptional,
1026
- Ft as getConfig,
1027
- x as getCurrentUser,
1028
- gt as getDrive,
1029
- ct as getGrantedRights,
1022
+ Mt as getApiClientOptional,
1023
+ Ct as getConfig,
1024
+ rt as getCurrentUser,
1025
+ wt as getDrive,
1026
+ ht as getGrantedRights,
1030
1027
  P as getModel,
1031
- Qt as hasModel,
1032
- at as isGranted,
1033
- Xt as list,
1034
- zt as listDrives,
1035
- ut as listFiles,
1036
- pt as listFolders,
1037
- Tt as listModels,
1038
- Wt as listPermissions,
1039
- Ot as listRoles,
1040
- wt as listUsers,
1041
- tt as login,
1042
- et as logout,
1043
- p as mutation,
1028
+ $t as hasModel,
1029
+ ut as isGranted,
1030
+ Ht as list,
1031
+ Wt as listDrives,
1032
+ ft as listFiles,
1033
+ _t as listFolders,
1034
+ Qt as listModels,
1035
+ Rt as listPermissions,
1036
+ kt as listRoles,
1037
+ Ft as listUsers,
1038
+ st as login,
1039
+ nt as logout,
1040
+ f as mutation,
1044
1041
  B as objectHasFile,
1045
1042
  y as query,
1046
- ht as readFileAsBase64,
1047
- nt as resetPassword,
1048
- kt as sendMail,
1043
+ dt as readFileAsBase64,
1044
+ at as resetPassword,
1045
+ Et as sendMail,
1049
1046
  X as setApiClient,
1050
- Ut as toQuery,
1051
- st as updatePassword,
1052
- mt as updateUser,
1053
- it as verifyCode,
1054
- K as webAuthn
1047
+ vt as toQuery,
1048
+ it as updatePassword,
1049
+ At as updateUser,
1050
+ lt as verifyCode,
1051
+ et as webAuthn
1055
1052
  };