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