@hostlink/light 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import { QueryUserFieldsUserFields } from '.';
1
2
  import * as webAuthn from "./webauthn";
3
+ export declare const getCurrentUser: (fields?: QueryUserFieldsUserFields) => Promise<any>;
2
4
  export declare const login: (username: string, password: string, code?: string) => Promise<boolean>;
3
5
  export declare const logout: () => Promise<boolean>;
4
6
  export declare const changeExpiredPassword: (username: string, oldPassword: string, newPassword: string) => Promise<boolean>;
@@ -8,6 +10,7 @@ export declare const forgetPassword: (username: string, email: string) => Promis
8
10
  export declare const verifyCode: (jwt: string, code: string) => Promise<boolean>;
9
11
  export declare const granted: (rights: string[]) => Promise<string[]>;
10
12
  declare const _default: () => {
13
+ getCurrentUser: (fields?: QueryUserFieldsUserFields) => Promise<any>;
11
14
  webAuthn: typeof webAuthn;
12
15
  google: {
13
16
  unlink: () => Promise<boolean>;
package/dist/drive.d.ts CHANGED
@@ -1,10 +1,16 @@
1
- export type FolderFields = {
2
- name?: string;
3
- path?: string;
4
- };
5
- export type QueryFolderFields = Record<keyof FolderFields, boolean>;
6
1
  export declare const listDrives: () => Promise<any>;
7
2
  export declare const getDrive: (index: number) => {
3
+ listFiles: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
4
+ getFile: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
5
+ readFile: (path: string) => Promise<any>;
6
+ writeFile: (path: string, content: string) => Promise<any>;
7
+ deleteFile: (path: string) => Promise<any>;
8
+ renameFile: (path: string, name: string) => Promise<any>;
9
+ moveFile: (source: string, destination: string) => Promise<any>;
10
+ listFolders: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<Record<keyof import('./folder').FolderFields, any>[]>;
11
+ createFolder: (path: string) => Promise<any>;
12
+ deleteFolder: (path: string) => Promise<any>;
13
+ renameFolder: (path: string, name: string) => Promise<any>;
8
14
  uploadTempFile: (file: File) => Promise<{
9
15
  name: string;
10
16
  path: string;
@@ -12,7 +18,7 @@ export declare const getDrive: (index: number) => {
12
18
  mime: string;
13
19
  }>;
14
20
  folders: {
15
- list: (path: string, fields?: QueryFolderFields) => Promise<Array<Record<keyof FolderFields, any>>>;
21
+ list: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<Record<keyof import('./folder').FolderFields, any>[]>;
16
22
  create: (path: string) => Promise<any>;
17
23
  delete: (path: string) => Promise<any>;
18
24
  rename: (path: string, name: string) => Promise<any>;
@@ -33,6 +39,17 @@ declare const _default: () => {
33
39
  name: string;
34
40
  }>>;
35
41
  get: (index: number) => {
42
+ listFiles: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
43
+ getFile: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
44
+ readFile: (path: string) => Promise<any>;
45
+ writeFile: (path: string, content: string) => Promise<any>;
46
+ deleteFile: (path: string) => Promise<any>;
47
+ renameFile: (path: string, name: string) => Promise<any>;
48
+ moveFile: (source: string, destination: string) => Promise<any>;
49
+ listFolders: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<Record<keyof import('./folder').FolderFields, any>[]>;
50
+ createFolder: (path: string) => Promise<any>;
51
+ deleteFolder: (path: string) => Promise<any>;
52
+ renameFolder: (path: string, name: string) => Promise<any>;
36
53
  uploadTempFile: (file: File) => Promise<{
37
54
  name: string;
38
55
  path: string;
@@ -40,7 +57,7 @@ declare const _default: () => {
40
57
  mime: string;
41
58
  }>;
42
59
  folders: {
43
- list: (path: string, fields?: QueryFolderFields) => Promise<Array<Record<keyof FolderFields, any>>>;
60
+ list: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<Record<keyof import('./folder').FolderFields, any>[]>;
44
61
  create: (path: string) => Promise<any>;
45
62
  delete: (path: string) => Promise<any>;
46
63
  rename: (path: string, name: string) => Promise<any>;
package/dist/file.d.ts CHANGED
@@ -6,6 +6,7 @@ export type FileFields = {
6
6
  url?: string;
7
7
  };
8
8
  export type QueryFileFields = Partial<Record<keyof FileFields, boolean>>;
9
+ export declare const listFiles: (index: number, path: string, fields?: QueryFileFields) => Promise<any>;
9
10
  declare const _default: (index: number) => {
10
11
  list: (path: string, fields?: QueryFileFields) => Promise<any>;
11
12
  get: (path: string, fields?: QueryFileFields) => Promise<any>;
@@ -0,0 +1,13 @@
1
+ export type FolderFields = {
2
+ name?: string;
3
+ path?: string;
4
+ };
5
+ export type QueryFolderFields = Record<keyof FolderFields, boolean>;
6
+ export declare const listFolders: (index: number, path: string, fields?: QueryFolderFields) => Promise<Array<Record<keyof FolderFields, any>>>;
7
+ declare const _default: (index: number) => {
8
+ list: (path: string, fields?: QueryFolderFields) => Promise<Record<keyof FolderFields, any>[]>;
9
+ create: (path: string) => Promise<any>;
10
+ delete: (path: string) => Promise<any>;
11
+ rename: (path: string, name: string) => Promise<any>;
12
+ };
13
+ export default _default;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,16 @@
1
1
  export { default as useModel, useGlobalModel, useGlobalModels, createModelManager } from './models';
2
2
  export type { ModelManager } from './models';
3
+ export * from './permission';
3
4
  export * as webAuthn from './webauthn';
4
5
  export * from './auth';
6
+ export { default as auth } from './auth';
5
7
  export * from './drive';
8
+ export * from './users';
9
+ export * from './config';
10
+ export * from './role';
6
11
  export * from './model';
7
12
  export * from './file';
13
+ export * from './mail';
8
14
  export { default as query } from './query';
9
15
  export { default as mutation } from './mutation';
10
16
  export { default as toQuery } from './toQuery';
package/dist/light.js CHANGED
@@ -1,21 +1,21 @@
1
- import { jsonToGraphQLQuery as q, VariableType as m } from "json-to-graphql-query";
2
- import $ from "axios";
3
- import C from "collect.js";
4
- function k(t) {
1
+ import { jsonToGraphQLQuery as v, VariableType as F } from "json-to-graphql-query";
2
+ import H from "axios";
3
+ import M from "collect.js";
4
+ function P(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 P(t, e, r = ".", n) {
11
- if (!k(e))
12
- return P(t, {}, r, n);
10
+ function E(t, e, r = ".", n) {
11
+ if (!P(e))
12
+ return E(t, {}, r, n);
13
13
  const i = Object.assign({}, e);
14
14
  for (const f in t) {
15
15
  if (f === "__proto__" || f === "constructor")
16
16
  continue;
17
17
  const a = t[f];
18
- a != null && (n && n(i, f, a, r) || (Array.isArray(a) && Array.isArray(i[f]) ? i[f] = [...a, ...i[f]] : k(a) && k(i[f]) ? i[f] = P(
18
+ a != null && (n && n(i, f, a, r) || (Array.isArray(a) && Array.isArray(i[f]) ? i[f] = [...a, ...i[f]] : P(a) && P(i[f]) ? i[f] = E(
19
19
  a,
20
20
  i[f],
21
21
  (r ? `${r}.` : "") + f.toString(),
@@ -24,34 +24,34 @@ function P(t, e, r = ".", n) {
24
24
  }
25
25
  return i;
26
26
  }
27
- function W(t) {
27
+ function X(t) {
28
28
  return (...e) => (
29
29
  // eslint-disable-next-line unicorn/no-array-reduce
30
- e.reduce((r, n) => P(r, n, "", t), {})
30
+ e.reduce((r, n) => E(r, n, "", t), {})
31
31
  );
32
32
  }
33
- const A = W();
34
- let D = null;
35
- const G = (t) => {
36
- D = t;
37
- }, U = () => {
38
- if (!D)
33
+ const A = X();
34
+ let k = null;
35
+ const Y = (t) => {
36
+ k = t;
37
+ }, N = () => {
38
+ if (!k)
39
39
  throw new Error("Api client not initialized. Call setApiClient() first.");
40
- return D;
41
- }, jt = () => D;
42
- function O(t) {
40
+ return k;
41
+ }, Ut = () => k;
42
+ function j(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 v(t) {
48
+ function B(t) {
49
49
  for (let e in t)
50
- if (t[e] instanceof File || t[e] instanceof Array && O(t[e]))
50
+ if (t[e] instanceof File || t[e] instanceof Array && j(t[e]))
51
51
  return !0;
52
52
  return !1;
53
53
  }
54
- function N(t, e, r, n, i) {
54
+ function J(t, e, r, n, i) {
55
55
  if (!(!t || typeof t != "object"))
56
56
  for (let f in t) {
57
57
  const a = t[f];
@@ -59,34 +59,34 @@ function N(t, e, r, n, i) {
59
59
  if ("__args" in a) {
60
60
  const u = a.__args, s = {};
61
61
  Object.entries(u).forEach(([o, c]) => {
62
- if (c instanceof Array && O(c)) {
63
- s[o] = new m(o);
62
+ if (c instanceof Array && j(c)) {
63
+ s[o] = new F(o);
64
64
  let l = 0;
65
65
  c.forEach((h) => {
66
66
  h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + l), n.append(i.current.toString(), h), i.current++, l++);
67
67
  }), e[o] = "[Upload!]!";
68
- } else c instanceof File ? (s[o] = new m(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && v(c) ? (s[o] = {}, Object.entries(c).forEach(([l, h]) => {
69
- if (h instanceof Array && O(h)) {
70
- s[o][l] = new m(l);
68
+ } else c instanceof File ? (s[o] = new F(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[o] = {}, Object.entries(c).forEach(([l, h]) => {
69
+ if (h instanceof Array && j(h)) {
70
+ s[o][l] = new F(l);
71
71
  let _ = 0;
72
- h.forEach((g) => {
73
- g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
72
+ h.forEach((d) => {
73
+ d instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), d), i.current++, _++);
74
74
  }), e[l] = "[Upload!]!";
75
- } else h instanceof File ? (s[o][l] = new m(l), r[i.current] = ["variables." + l], n.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : s[o][l] = h;
75
+ } else h instanceof File ? (s[o][l] = new F(l), r[i.current] = ["variables." + l], n.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : s[o][l] = h;
76
76
  })) : c != null && (s[o] = c);
77
77
  }), a.__args = s;
78
78
  }
79
- N(a, e, r, n, i);
79
+ J(a, e, r, n, i);
80
80
  }
81
81
  }
82
82
  }
83
- const w = async (t) => {
84
- const e = U(), r = t, n = new FormData();
83
+ const y = async (t) => {
84
+ const e = N(), r = t, n = new FormData();
85
85
  let i = !1;
86
86
  const f = {}, a = {};
87
- N(r, f, a, n, { current: 0 }), i = Object.keys(f).length > 0, i && (r.__variables = f);
87
+ J(r, f, a, n, { current: 0 }), i = Object.keys(f).length > 0, i && (r.__variables = f);
88
88
  let s = null;
89
- const c = q({ query: r });
89
+ const c = v({ query: r });
90
90
  if (i ? (n.append("map", JSON.stringify(a)), n.append("operations", JSON.stringify({
91
91
  query: c
92
92
  })), s = await e.axios.post("", n)) : s = await e.axios.post("", {
@@ -95,7 +95,7 @@ const w = async (t) => {
95
95
  throw new Error(s.data.errors[0].message);
96
96
  return s.data.data;
97
97
  };
98
- function E(t, e) {
98
+ function U(t, e) {
99
99
  let r, n = [], i, f;
100
100
  const a = (s) => !s || typeof s != "object" ? !1 : Object.values(s).some((o) => o && typeof o == "object" && Object.keys(o).some((c) => c.startsWith("_"))), u = () => n.length === 0 ? (n.unshift({}), n[0]) : (a(n[0]) && n.unshift({}), n[0]);
101
101
  return {
@@ -110,7 +110,7 @@ function E(t, e) {
110
110
  return Array.isArray(o) && o.length > 0 ? o[0] : null;
111
111
  },
112
112
  async fetchWithMeta() {
113
- let o = await w(this.toQuery(!0));
113
+ let o = await y(this.toQuery(!0));
114
114
  if (f) {
115
115
  const c = f.split(".");
116
116
  for (const l of c)
@@ -120,7 +120,7 @@ function E(t, e) {
120
120
  return o[`list${t}`];
121
121
  },
122
122
  async fetch() {
123
- let o = await w(this.toQuery());
123
+ let o = await y(this.toQuery());
124
124
  if (f) {
125
125
  const c = f.split(".");
126
126
  for (const l of c)
@@ -142,8 +142,8 @@ function E(t, e) {
142
142
  // where('key', value) -> exact match
143
143
  // where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
144
144
  where(s, o, c) {
145
- const l = (h, _, g) => {
146
- const F = {
145
+ const l = (h, _, d) => {
146
+ const O = {
147
147
  ">": "_gt",
148
148
  "<": "_lt",
149
149
  ">=": "_gte",
@@ -152,7 +152,7 @@ function E(t, e) {
152
152
  in: "_in",
153
153
  contains: "_contains"
154
154
  }[_];
155
- F && n.push({ [h]: { [F]: g } });
155
+ O && n.push({ [h]: { [O]: d } });
156
156
  };
157
157
  if (c !== void 0)
158
158
  l(s, String(o), c);
@@ -204,31 +204,31 @@ function E(t, e) {
204
204
  const _ = A(
205
205
  i ? { sort: i } : {},
206
206
  o ? { filters: o } : {}
207
- ), g = {
207
+ ), d = {
208
208
  data: {
209
209
  ...e
210
210
  }
211
211
  };
212
- if (r && (g.data.__args = r), Object.keys(_).length > 0 && (g.__args = _), s && (g.meta = {
212
+ if (r && (d.data.__args = r), Object.keys(_).length > 0 && (d.__args = _), s && (d.meta = {
213
213
  total: !0,
214
214
  key: !0,
215
215
  name: !0
216
216
  }), f) {
217
- const y = f.split(".");
218
- let F = g;
219
- for (let j = y.length - 1; j >= 0; j--)
220
- F = {
221
- [y[j]]: F
217
+ const w = f.split(".");
218
+ let O = d;
219
+ for (let C = w.length - 1; C >= 0; C--)
220
+ O = {
221
+ [w[C]]: O
222
222
  };
223
- return F;
223
+ return O;
224
224
  }
225
225
  return {
226
- [`list${t}`]: g
226
+ [`list${t}`]: d
227
227
  };
228
228
  }
229
229
  };
230
230
  }
231
- const B = (t, e) => {
231
+ const L = (t, e) => {
232
232
  const r = t, n = e;
233
233
  let i = "list" + t;
234
234
  const f = (a) => n[a] ? n[a] : null;
@@ -280,7 +280,7 @@ const B = (t, e) => {
280
280
  return u;
281
281
  },
282
282
  async get(a, u) {
283
- const s = (await Promise.resolve().then(() => yt)).default, o = s(r, ot(u));
283
+ const s = (await Promise.resolve().then(() => Pt)).default, o = s(r, Dt(u));
284
284
  for (const [c, l] of Object.entries(a))
285
285
  o.where(c, "==", l);
286
286
  return await o.first();
@@ -291,14 +291,14 @@ const B = (t, e) => {
291
291
  Object.entries(a).forEach(([l]) => {
292
292
  n[l] && (s[l] = n[l], n[l].gqlField && (delete u[l], u = A(u, n[l].gqlField)), n[l].gql && (u = A(u, n[l].gql), delete u[l]));
293
293
  });
294
- const o = E(r, u).dataPath(i), c = o.fetch.bind(o);
294
+ const o = U(r, u).dataPath(i), c = o.fetch.bind(o);
295
295
  return {
296
296
  ...o,
297
297
  async fetch() {
298
298
  return (await c()).map((h) => {
299
299
  const _ = { ...h };
300
- return Object.entries(s).forEach(([g, y]) => {
301
- y.format && typeof y.format == "function" && (_[g] = y.format(h));
300
+ return Object.entries(s).forEach(([d, w]) => {
301
+ w.format && typeof w.format == "function" && (_[d] = w.format(h));
302
302
  }), _;
303
303
  });
304
304
  },
@@ -306,14 +306,14 @@ const B = (t, e) => {
306
306
  const h = await o.fetchFirst.bind(o)();
307
307
  if (!h) return h;
308
308
  const _ = { ...h };
309
- return Object.entries(s).forEach(([g, y]) => {
310
- y.format && typeof y.format == "function" && (_[g] = y.format(h));
309
+ return Object.entries(s).forEach(([d, w]) => {
310
+ w.format && typeof w.format == "function" && (_[d] = w.format(h));
311
311
  }), _;
312
312
  }
313
313
  };
314
314
  }
315
315
  };
316
- }, b = {}, S = (t = !1) => {
316
+ }, b = {}, q = (t = !1) => {
317
317
  const e = {};
318
318
  return {
319
319
  /**
@@ -322,7 +322,7 @@ const B = (t, e) => {
322
322
  * @param fields 模型欄位定義
323
323
  */
324
324
  create(r, n) {
325
- const i = B(r, n);
325
+ const i = L(r, n);
326
326
  e[r] = i, t && (b[r] = i);
327
327
  },
328
328
  /**
@@ -356,8 +356,8 @@ const B = (t, e) => {
356
356
  Object.keys(e).forEach((r) => delete e[r]);
357
357
  }
358
358
  };
359
- }, kt = () => {
360
- const t = S(!1);
359
+ }, qt = () => {
360
+ const t = q(!1);
361
361
  return {
362
362
  // 暴露完整的管理器
363
363
  manager: t,
@@ -386,8 +386,8 @@ const B = (t, e) => {
386
386
  });
387
387
  }
388
388
  };
389
- }, Ct = () => {
390
- const t = S(!0);
389
+ }, vt = () => {
390
+ const t = q(!0);
391
391
  return {
392
392
  // 暴露完整的管理器
393
393
  manager: t,
@@ -416,14 +416,14 @@ const B = (t, e) => {
416
416
  });
417
417
  }
418
418
  };
419
- }, Pt = () => ({
419
+ }, Nt = () => ({
420
420
  /**
421
421
  * 創建全域模型
422
422
  * @param name 模型名稱
423
423
  * @param fields 模型欄位定義
424
424
  */
425
425
  define(t, e) {
426
- const r = B(t, e);
426
+ const r = L(t, e);
427
427
  return b[t] = r, r;
428
428
  },
429
429
  /**
@@ -455,8 +455,12 @@ const B = (t, e) => {
455
455
  clear() {
456
456
  Object.keys(b).forEach((t) => delete b[t]);
457
457
  }
458
- }), J = async () => {
459
- const { app: t } = await w({
458
+ }), Bt = () => y({
459
+ app: {
460
+ permissions: !0
461
+ }
462
+ }).then((t) => t.app.permissions), Q = async () => {
463
+ const { app: t } = await y({
460
464
  app: {
461
465
  auth: {
462
466
  webAuthnRequestOptions: !0
@@ -464,8 +468,8 @@ const B = (t, e) => {
464
468
  }
465
469
  }), e = t.auth.webAuthnRequestOptions, r = PublicKeyCredential.parseRequestOptionsFromJSON(e);
466
470
  return await navigator.credentials.get({ publicKey: r });
467
- }, L = async () => {
468
- const { app: t } = await w({
471
+ }, T = async () => {
472
+ const { app: t } = await y({
469
473
  app: {
470
474
  auth: {
471
475
  webAuthnCreationOptions: !0
@@ -473,27 +477,27 @@ const B = (t, e) => {
473
477
  }
474
478
  }), e = PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);
475
479
  return await navigator.credentials.create({ publicKey: e });
476
- }, z = async () => {
477
- const t = await J();
480
+ }, Z = async () => {
481
+ const t = await Q();
478
482
  return await p({
479
483
  webAuthnAssertion: {
480
484
  assertion: t.toJSON()
481
485
  }
482
486
  }).then((e) => e.webAuthnAssertion);
483
- }, R = async () => {
484
- const t = await L();
487
+ }, V = async () => {
488
+ const t = await T();
485
489
  return await p({
486
490
  webAuthnRegister: {
487
491
  registration: t.toJSON()
488
492
  }
489
493
  }).then((e) => e.webAuthnRegister);
490
- }, H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
494
+ }, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
491
495
  __proto__: null,
492
- assertion: J,
493
- attestation: L,
494
- login: z,
495
- register: R
496
- }, Symbol.toStringTag, { value: "Module" })), X = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((n) => n.login), Y = () => p({ logout: !0 }).then((t) => t.logout), Z = (t, e, r) => p({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((n) => n.changeExpiredPassword), V = (t, e) => p({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), K = (t, e, r) => p({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((n) => n.resetPassword), I = (t, e) => p({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), x = (t, e) => p({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), tt = (t) => w({
496
+ assertion: Q,
497
+ attestation: T,
498
+ login: Z,
499
+ register: V
500
+ }, Symbol.toStringTag, { value: "Module" })), I = (t = G) => y({ my: t }).then((e) => e.my), x = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((n) => n.login), tt = () => p({ logout: !0 }).then((t) => t.logout), et = (t, e, r) => p({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((n) => n.changeExpiredPassword), rt = (t, e) => p({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), st = (t, e, r) => p({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((n) => n.resetPassword), nt = (t, e) => p({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), ot = (t, e) => p({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), it = (t) => y({
497
501
  my: {
498
502
  grantedRights: {
499
503
  __args: {
@@ -501,8 +505,9 @@ const B = (t, e) => {
501
505
  }
502
506
  }
503
507
  }
504
- }).then((e) => e.my.grantedRights), et = () => ({
505
- webAuthn: H,
508
+ }).then((e) => e.my.grantedRights), at = () => ({
509
+ getCurrentUser: I,
510
+ webAuthn: K,
506
511
  google: {
507
512
  unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
508
513
  login: (t) => p({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
@@ -518,39 +523,39 @@ const B = (t, e) => {
518
523
  login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
519
524
  register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
520
525
  },
521
- login: X,
522
- logout: Y,
523
- changeExpiredPassword: Z,
524
- updatePassword: V,
525
- resetPassword: K,
526
- forgetPassword: I,
527
- verifyCode: x,
528
- granted: tt
529
- }), rt = {
526
+ login: x,
527
+ logout: tt,
528
+ changeExpiredPassword: et,
529
+ updatePassword: rt,
530
+ resetPassword: st,
531
+ forgetPassword: nt,
532
+ verifyCode: ot,
533
+ granted: it
534
+ }), $ = {
530
535
  name: !0,
531
536
  path: !0,
532
537
  size: !0,
533
538
  mime: !0,
534
539
  url: !0
535
- }, st = (t) => ({
536
- list: (e, r = rt) => w({
537
- app: {
538
- drive: {
539
- __args: { index: t },
540
- files: {
541
- __args: { path: e },
542
- ...r
543
- }
540
+ }, ct = (t, e, r = $) => y({
541
+ app: {
542
+ drive: {
543
+ __args: { index: t },
544
+ files: {
545
+ __args: { path: e },
546
+ ...r
544
547
  }
545
548
  }
546
- }).then((n) => n.app.drive.files),
549
+ }
550
+ }).then((n) => n.app.drive.files), m = (t) => ({
551
+ list: (e, r = $) => ct(t, e, r),
547
552
  get: (e, r = {
548
553
  name: !0,
549
554
  path: !0,
550
555
  size: !0,
551
556
  mime: !0,
552
557
  url: !0
553
- }) => w({
558
+ }) => y({
554
559
  app: {
555
560
  drive: {
556
561
  __args: {
@@ -566,7 +571,7 @@ const B = (t, e) => {
566
571
  }
567
572
  }).then((n) => n.app.drive.file),
568
573
  read: async (e) => {
569
- let r = await w({
574
+ let r = await y({
570
575
  app: {
571
576
  drive: {
572
577
  __args: {
@@ -589,14 +594,43 @@ const B = (t, e) => {
589
594
  delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
590
595
  rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
591
596
  move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((n) => n.lightDriveMoveFile)
592
- }), Mt = () => w({
597
+ }), W = {
598
+ name: !0,
599
+ path: !0
600
+ }, lt = (t, e, r = W) => y({
601
+ app: {
602
+ drive: {
603
+ __args: { index: t },
604
+ folders: {
605
+ __args: { path: e },
606
+ ...r
607
+ }
608
+ }
609
+ }
610
+ }).then((n) => n.app.drive.folders), D = (t) => ({
611
+ list: (e, r = W) => lt(t, e, r),
612
+ create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
613
+ delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
614
+ rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
615
+ }), Jt = () => y({
593
616
  app: {
594
617
  drives: {
595
618
  index: !0,
596
619
  name: !0
597
620
  }
598
621
  }
599
- }).then((t) => t.app.drives), nt = (t) => ({
622
+ }).then((t) => t.app.drives), ut = (t) => ({
623
+ listFiles: m(t).list,
624
+ getFile: m(t).get,
625
+ readFile: m(t).read,
626
+ writeFile: m(t).write,
627
+ deleteFile: m(t).delete,
628
+ renameFile: m(t).rename,
629
+ moveFile: m(t).move,
630
+ listFolders: D(t).list,
631
+ createFolder: D(t).create,
632
+ deleteFolder: D(t).delete,
633
+ renameFolder: D(t).rename,
600
634
  uploadTempFile: (e) => p({
601
635
  lightDriveUploadTempFile: {
602
636
  __args: { index: t, file: e },
@@ -606,25 +640,70 @@ const B = (t, e) => {
606
640
  mime: !0
607
641
  }
608
642
  }).then((r) => r.lightDriveUploadTempFile),
609
- folders: {
610
- list: (e, r = { name: !0, path: !0 }) => w({
611
- app: {
612
- drive: {
613
- __args: { index: t },
614
- folders: {
615
- __args: { path: e },
616
- ...r
617
- }
643
+ folders: D(t),
644
+ files: m(t)
645
+ }), G = {
646
+ user_id: !0,
647
+ username: !0,
648
+ first_name: !0,
649
+ last_name: !0,
650
+ status: !0
651
+ }, ht = (t) => p({
652
+ addUser: {
653
+ __args: t
654
+ }
655
+ }).then((e) => e.addUser), ft = (t) => p({
656
+ deleteUser: {
657
+ __args: { id: t }
658
+ }
659
+ }).then((e) => e.deleteUser), pt = (t = G) => U("Users", t).dataPath("app.listUser").fetch(), dt = (t, e) => p({
660
+ updateUser: {
661
+ __args: { id: t, data: e }
662
+ }
663
+ }).then((r) => r.updateUser), gt = () => ({
664
+ list: pt,
665
+ create: ht,
666
+ delete: ft,
667
+ update: dt
668
+ }), _t = (t) => y({
669
+ app: {
670
+ listConfig: {
671
+ __args: {
672
+ filters: {
673
+ name: t
618
674
  }
675
+ },
676
+ data: {
677
+ name: !0,
678
+ value: !0
619
679
  }
620
- }).then((n) => n.app.drive.folders),
621
- create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
622
- delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
623
- rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
624
- },
625
- files: st(t)
680
+ }
681
+ }
682
+ }).then((e) => e.app.listConfig.data[0]?.value), yt = {
683
+ name: !0
684
+ }, wt = (t = yt) => y({
685
+ app: {
686
+ roles: t
687
+ }
688
+ }).then((e) => e.app.roles), bt = (t, e) => p({
689
+ addRole: {
690
+ __args: {
691
+ data: {
692
+ name: t,
693
+ childs: e
694
+ }
695
+ }
696
+ }
697
+ }).then((r) => r.addRole), mt = (t) => p({
698
+ deleteRole: {
699
+ __args: { name: t }
700
+ }
701
+ }).then((e) => e.deleteRole), Ft = () => ({
702
+ list: wt,
703
+ create: bt,
704
+ delete: mt
626
705
  });
627
- function Q(t, e, r, n, i) {
706
+ function z(t, e, r, n, i) {
628
707
  if (!(!t || typeof t != "object"))
629
708
  for (let f in t) {
630
709
  const a = t[f];
@@ -632,34 +711,34 @@ function Q(t, e, r, n, i) {
632
711
  if ("__args" in a) {
633
712
  const u = a.__args, s = {};
634
713
  Object.entries(u).forEach(([o, c]) => {
635
- if (c instanceof Array && O(c)) {
636
- s[o] = new m(o);
714
+ if (c instanceof Array && j(c)) {
715
+ s[o] = new F(o);
637
716
  let l = 0;
638
717
  c.forEach((h) => {
639
718
  h instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + o + "." + l), n.append(i.current.toString(), h), i.current++, l++);
640
719
  }), e[o] = "[Upload!]!";
641
- } else c instanceof File ? (s[o] = new m(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && v(c) ? (s[o] = {}, Object.entries(c).forEach(([l, h]) => {
642
- if (h instanceof Array && O(h)) {
643
- s[o][l] = new m(l);
720
+ } else c instanceof File ? (s[o] = new F(o), r[i.current] = ["variables." + o], n.append(i.current.toString(), c), e[o] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[o] = {}, Object.entries(c).forEach(([l, h]) => {
721
+ if (h instanceof Array && j(h)) {
722
+ s[o][l] = new F(l);
644
723
  let _ = 0;
645
- h.forEach((g) => {
646
- g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
724
+ h.forEach((d) => {
725
+ d instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), d), i.current++, _++);
647
726
  }), e[l] = "[Upload!]!";
648
- } else h instanceof File ? (s[o][l] = new m(l), r[i.current] = ["variables." + l], n.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : s[o][l] = h;
727
+ } else h instanceof File ? (s[o][l] = new F(l), r[i.current] = ["variables." + l], n.append(i.current.toString(), h), e[l] = "Upload!", i.current++) : s[o][l] = h;
649
728
  })) : c != null && (s[o] = c);
650
729
  }), a.__args = s;
651
730
  }
652
- Q(a, e, r, n, i);
731
+ z(a, e, r, n, i);
653
732
  }
654
733
  }
655
734
  }
656
735
  const p = async (t) => {
657
- const r = U().axios, n = t, i = new FormData();
736
+ const r = N().axios, n = t, i = new FormData();
658
737
  let f = !1;
659
738
  const a = {}, u = {};
660
- Q(n, a, u, i, { current: 0 }), f = Object.keys(a).length > 0, f && (n.__variables = a);
739
+ z(n, a, u, i, { current: 0 }), f = Object.keys(a).length > 0, f && (n.__variables = a);
661
740
  let o = null;
662
- const l = q({ mutation: n });
741
+ const l = v({ mutation: n });
663
742
  if (f ? (i.append("map", JSON.stringify(u)), i.append("operations", JSON.stringify({
664
743
  query: l
665
744
  })), o = await r.post("", i)) : o = await r.post("", {
@@ -667,10 +746,12 @@ const p = async (t) => {
667
746
  }), o.data.errors)
668
747
  throw new Error(o.data.errors[0].message);
669
748
  return o.data.data;
670
- }, M = (t) => {
749
+ }, At = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), Ot = {
750
+ send: At
751
+ }, S = (t) => {
671
752
  let e = {};
672
753
  return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
673
- Object.entries(M(r)).forEach(([n, i]) => {
754
+ Object.entries(S(r)).forEach(([n, i]) => {
674
755
  e[n] = i;
675
756
  });
676
757
  }), e) : (Object.entries(t).forEach(([r, n]) => {
@@ -682,48 +763,9 @@ const p = async (t) => {
682
763
  e[r] = n;
683
764
  return;
684
765
  }
685
- e[r] = M(n);
766
+ e[r] = S(n);
686
767
  }), e);
687
- }, ot = (t) => M(t), it = (t) => w({
688
- app: {
689
- listConfig: {
690
- __args: {
691
- filters: {
692
- name: t
693
- }
694
- },
695
- data: {
696
- name: !0,
697
- value: !0
698
- }
699
- }
700
- }
701
- }).then((e) => e.app.listConfig.data[0]), at = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), ct = {
702
- send: at
703
- }, lt = {
704
- name: !0
705
- }, ut = (t = lt) => w({
706
- app: {
707
- roles: t
708
- }
709
- }).then((e) => e.app.roles), ht = (t, e) => p({
710
- addRole: {
711
- __args: {
712
- data: {
713
- name: t,
714
- childs: e
715
- }
716
- }
717
- }
718
- }).then((r) => r.addRole), ft = (t) => p({
719
- deleteRole: {
720
- __args: { name: t }
721
- }
722
- }).then((e) => e.deleteRole), pt = () => ({
723
- list: ut,
724
- create: ht,
725
- delete: ft
726
- }), gt = "list", dt = [
768
+ }, Dt = (t) => S(t), jt = "list", kt = [
727
769
  "flatMap",
728
770
  "chunk",
729
771
  "shuffle",
@@ -749,7 +791,7 @@ const p = async (t) => {
749
791
  "slice",
750
792
  "tap",
751
793
  "sort"
752
- ], _t = [
794
+ ], Ct = [
753
795
  "avg",
754
796
  "count",
755
797
  "countBy",
@@ -777,7 +819,7 @@ const p = async (t) => {
777
819
  "implode",
778
820
  "partition"
779
821
  ];
780
- class d {
822
+ class g {
781
823
  _batchData = null;
782
824
  data_path = "";
783
825
  filters;
@@ -794,7 +836,7 @@ class d {
794
836
  this.filters = {}, this.steps = [], this.fields = e;
795
837
  }
796
838
  }
797
- d.prototype.getQueryPayload = function() {
839
+ g.prototype.getQueryPayload = function() {
798
840
  let t = {
799
841
  meta: {
800
842
  total: !0,
@@ -808,26 +850,26 @@ d.prototype.getQueryPayload = function() {
808
850
  steps: this.steps
809
851
  };
810
852
  };
811
- d.prototype.dataPath = function(t) {
853
+ g.prototype.dataPath = function(t) {
812
854
  const e = this.clone();
813
855
  return e.data_path = t, e;
814
856
  };
815
- d.prototype.buildArgs = function() {
857
+ g.prototype.buildArgs = function() {
816
858
  let t = {};
817
859
  return Object.keys(this.filters).length > 0 && (t.filters = this.filters), this._sort && (t.sort = this._sort, this._sortDesc && (t.sort += ":desc")), t;
818
860
  };
819
- d.prototype.clone = function() {
861
+ g.prototype.clone = function() {
820
862
  const t = Object.create(this);
821
863
  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;
822
864
  };
823
- C().macro("whereContains", function(t, e) {
865
+ M().macro("whereContains", function(t, e) {
824
866
  return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
825
867
  });
826
- d.prototype.fetchData = async function() {
868
+ g.prototype.fetchData = async function() {
827
869
  try {
828
870
  if (this._batchData) {
829
871
  const u = this._batchData;
830
- return this.meta = u.meta, C(u.data);
872
+ return this.meta = u.meta, M(u.data);
831
873
  }
832
874
  let t = {
833
875
  meta: {
@@ -846,40 +888,40 @@ d.prototype.fetchData = async function() {
846
888
  }
847
889
  n[u] = {}, n = n[u];
848
890
  }
849
- let a = await w(r);
891
+ let a = await y(r);
850
892
  for (const u of e)
851
893
  a = a[u];
852
- return this.meta = a.meta, C(a.data);
894
+ return this.meta = a.meta, M(a.data);
853
895
  } catch (t) {
854
896
  throw console.error("Error fetching collection data:", t), t;
855
897
  }
856
898
  };
857
- d.prototype.processData = async function() {
899
+ g.prototype.processData = async function() {
858
900
  let t = await this.fetchData();
859
901
  for (const e of this.steps)
860
902
  t = t[e.type](...e.args);
861
903
  return t;
862
904
  };
863
- d.prototype.all = async function() {
905
+ g.prototype.all = async function() {
864
906
  return (await this.processData()).all();
865
907
  };
866
- for (const t of dt)
867
- d.prototype[t] = function(...e) {
908
+ for (const t of kt)
909
+ g.prototype[t] = function(...e) {
868
910
  const r = this.clone();
869
911
  return r.steps.push({ type: t, args: e }), r;
870
912
  };
871
- for (const t of _t)
872
- d.prototype[t] = async function(...e) {
913
+ for (const t of Ct)
914
+ g.prototype[t] = async function(...e) {
873
915
  return (await this.clone().processData())[t](...e);
874
916
  };
875
- d.prototype.average = d.prototype.avg;
876
- d.prototype.first = async function() {
917
+ g.prototype.average = g.prototype.avg;
918
+ g.prototype.first = async function() {
877
919
  return this.take(1), (await this.processData()).first();
878
920
  };
879
- d.prototype._handleBatchData = function(t, e) {
921
+ g.prototype._handleBatchData = function(t, e) {
880
922
  return this._batchData ? (this.steps.push({ type: t, args: e }), this) : null;
881
923
  };
882
- d.prototype.where = function(...t) {
924
+ g.prototype.where = function(...t) {
883
925
  const e = this._handleBatchData("where", t);
884
926
  if (e) return e;
885
927
  if (t.length === 2)
@@ -911,77 +953,58 @@ d.prototype.where = function(...t) {
911
953
  }
912
954
  return this;
913
955
  };
914
- d.prototype.whereContains = function(t, e) {
956
+ g.prototype.whereContains = function(t, e) {
915
957
  const r = this._handleBatchData("whereContains", [t, e]);
916
958
  return r || (this.filters[t] = { contains: e }, this);
917
959
  };
918
- d.prototype.forPage = function(t, e) {
960
+ g.prototype.forPage = function(t, e) {
919
961
  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);
920
962
  };
921
- d.prototype.whereIn = function(t, e) {
963
+ g.prototype.whereIn = function(t, e) {
922
964
  const r = this._handleBatchData("whereIn", [t, e]);
923
965
  return r || (this.filters[t] = { in: e }, this);
924
966
  };
925
- d.prototype.whereNotIn = function(t, e) {
967
+ g.prototype.whereNotIn = function(t, e) {
926
968
  const r = this._handleBatchData("whereNotIn", [t, e]);
927
969
  return r || (this.filters[t] = { nin: e }, this);
928
970
  };
929
- d.prototype.whereNotBetween = function(t, e) {
971
+ g.prototype.whereNotBetween = function(t, e) {
930
972
  const r = this._handleBatchData("whereNotBetween", [t, e]);
931
973
  return r || (this.filters[t] = { notBetween: e }, this);
932
974
  };
933
- d.prototype.whereBetween = function(t, e) {
975
+ g.prototype.whereBetween = function(t, e) {
934
976
  const r = this._handleBatchData("whereBetween", [t, e]);
935
977
  return r || (this.filters[t] = { between: e }, this);
936
978
  };
937
- d.prototype.sortBy = function(t) {
979
+ g.prototype.sortBy = function(t) {
938
980
  return this.steps.push({ type: "sortBy", args: [t] }), typeof t == "string" && (this._sort = t), this;
939
981
  };
940
- d.prototype.sortByDesc = function(t) {
982
+ g.prototype.sortByDesc = function(t) {
941
983
  return this.steps.push({ type: "sortByDesc", args: [t] }), typeof t == "string" && (this._sort = t, this._sortDesc = !0), this;
942
984
  };
943
- d.prototype.skip = function(t) {
985
+ g.prototype.skip = function(t) {
944
986
  if (t < 0)
945
987
  throw new Error("Offset must be non-negative");
946
988
  return this.already_offset && this.steps.push({ type: "skip", args: [t] }), this.offset = t, this.already_offset = !0, this;
947
989
  };
948
- d.prototype.take = function(t) {
990
+ g.prototype.take = function(t) {
949
991
  if (t < 0)
950
992
  throw new Error("Length must be non-negative");
951
993
  return this.already_limit ? (this.steps.push({ type: "take", args: [t] }), this) : (this.limit = t, this.already_limit = !0, this);
952
994
  };
953
- d.prototype.splice = function(t, e) {
995
+ g.prototype.splice = function(t, e) {
954
996
  return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
955
997
  };
956
- const T = (t, e) => {
957
- const r = new d(e);
958
- return r.data_path = gt + t, r;
959
- }, yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
998
+ const R = (t, e) => {
999
+ const r = new g(e);
1000
+ return r.data_path = jt + t, r;
1001
+ }, Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
960
1002
  __proto__: null,
961
- default: T
962
- }, Symbol.toStringTag, { value: "Module" })), wt = {
963
- user_id: !0,
964
- username: !0,
965
- first_name: !0,
966
- last_name: !0,
967
- status: !0
968
- }, bt = (t) => p({
969
- createUser: {
970
- __args: {},
971
- ...t
972
- }
973
- }).then((e) => e.createUser), mt = (t) => p({
974
- deleteUser: {
975
- __args: { id: t }
976
- }
977
- }).then((e) => e.deleteUser), At = () => ({
978
- list: async (t = wt) => E("Users", t).dataPath("app.listUser").fetch(),
979
- create: (t) => bt(t),
980
- delete: (t) => mt(t)
981
- }), Et = (t) => {
1003
+ default: R
1004
+ }, Symbol.toStringTag, { value: "Module" })), Lt = (t) => {
982
1005
  const e = typeof window > "u";
983
1006
  let r = [];
984
- const n = $.create({
1007
+ const n = H.create({
985
1008
  baseURL: t,
986
1009
  withCredentials: !0
987
1010
  });
@@ -998,83 +1021,97 @@ const T = (t, e) => {
998
1021
  }
999
1022
  return a;
1000
1023
  }));
1001
- const i = S(), f = {
1024
+ const i = q(), f = {
1002
1025
  post: n.post,
1003
1026
  baseURL: t,
1004
1027
  axios: n,
1005
- auth: et(),
1028
+ auth: at(),
1006
1029
  mutation: p,
1007
- query: w,
1008
- config: it,
1009
- mail: ct,
1010
- users: At(),
1030
+ query: y,
1031
+ config: _t,
1032
+ mail: Ot,
1033
+ users: gt(),
1011
1034
  models: i,
1012
1035
  model(a) {
1013
1036
  return i.get(a);
1014
1037
  },
1015
- roles: pt(),
1038
+ roles: Ft(),
1016
1039
  collect: (a, u) => {
1017
- const s = T(a, u);
1040
+ const s = R(a, u);
1018
1041
  return s.data_path = i.get(a).getDataPath(), s;
1019
1042
  },
1020
- list: (a, u) => E(a, u).dataPath(i.get(a).getDataPath()),
1021
- drive: nt,
1043
+ list: (a, u) => U(a, u).dataPath(i.get(a).getDataPath()),
1044
+ drive: ut,
1022
1045
  async collects(a) {
1023
1046
  const u = {}, s = {};
1024
1047
  for (const c in a) {
1025
1048
  const l = a[c].getQueryPayload();
1026
1049
  s[c] = l.data_path, u[c] = {};
1027
1050
  const h = l.data_path.split(".");
1028
- let _ = h[h.length - 1], g = u[c];
1029
- for (const y of h) {
1030
- if (y === _) {
1031
- g[y] = l.query;
1051
+ let _ = h[h.length - 1], d = u[c];
1052
+ for (const w of h) {
1053
+ if (w === _) {
1054
+ d[w] = l.query;
1032
1055
  break;
1033
1056
  }
1034
- g[y] = g[y] || {};
1057
+ d[w] = d[w] || {};
1035
1058
  }
1036
1059
  u[c].__aliasFor = h[0];
1037
1060
  }
1038
- const o = await w(u);
1061
+ const o = await y(u);
1039
1062
  for (const c in a) {
1040
1063
  const l = s[c].split(".");
1041
1064
  let h = l[l.length - 1], _ = o[c];
1042
- for (const g of l) {
1043
- if (g === h) {
1044
- a[c]._batchData = o[c][g];
1065
+ for (const d of l) {
1066
+ if (d === h) {
1067
+ a[c]._batchData = o[c][d];
1045
1068
  break;
1046
1069
  }
1047
- _[g] = _[g] || {};
1070
+ _[d] = _[d] || {};
1048
1071
  }
1049
1072
  }
1050
1073
  return a;
1051
1074
  }
1052
1075
  };
1053
- return G(f), f;
1076
+ return Y(f), f;
1054
1077
  };
1055
1078
  export {
1056
- Z as changeExpiredPassword,
1057
- Et as createClient,
1058
- T as createCollection,
1059
- E as createList,
1060
- S as createModelManager,
1061
- I as forgetPassword,
1062
- U as getApiClient,
1063
- jt as getApiClientOptional,
1064
- nt as getDrive,
1065
- tt as granted,
1066
- Mt as listDrives,
1067
- X as login,
1068
- Y as logout,
1079
+ at as auth,
1080
+ et as changeExpiredPassword,
1081
+ Lt as createClient,
1082
+ R as createCollection,
1083
+ U as createList,
1084
+ q as createModelManager,
1085
+ bt as createRole,
1086
+ ht as createUser,
1087
+ G as defaultUserFields,
1088
+ mt as deleteRole,
1089
+ ft as deleteUser,
1090
+ nt as forgetPassword,
1091
+ N as getApiClient,
1092
+ Ut as getApiClientOptional,
1093
+ _t as getConfig,
1094
+ I as getCurrentUser,
1095
+ ut as getDrive,
1096
+ it as granted,
1097
+ Jt as listDrives,
1098
+ ct as listFiles,
1099
+ Bt as listPermissions,
1100
+ wt as listRoles,
1101
+ pt as listUsers,
1102
+ x as login,
1103
+ tt as logout,
1069
1104
  p as mutation,
1070
- w as query,
1071
- K as resetPassword,
1072
- G as setApiClient,
1073
- ot as toQuery,
1074
- V as updatePassword,
1075
- Ct as useGlobalModel,
1076
- Pt as useGlobalModels,
1077
- kt as useModel,
1078
- x as verifyCode,
1079
- H as webAuthn
1105
+ y as query,
1106
+ st as resetPassword,
1107
+ At as sendMail,
1108
+ Y as setApiClient,
1109
+ Dt as toQuery,
1110
+ rt as updatePassword,
1111
+ dt as updateUser,
1112
+ vt as useGlobalModel,
1113
+ Nt as useGlobalModels,
1114
+ qt as useModel,
1115
+ ot as verifyCode,
1116
+ K as webAuthn
1080
1117
  };
@@ -1 +1 @@
1
- (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("json-to-graphql-query"),require("axios"),require("collect.js")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios","collect.js"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d.light={},d.jsonToGraphqlQuery,d.axios,d.collect))})(this,(function(d,m,x,P){"use strict";function k(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);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}function E(t,e,r=".",n){if(!k(e))return E(t,{},r,n);const o=Object.assign({},e);for(const f in t){if(f==="__proto__"||f==="constructor")continue;const a=t[f];a!=null&&(n&&n(o,f,a,r)||(Array.isArray(a)&&Array.isArray(o[f])?o[f]=[...a,...o[f]]:k(a)&&k(o[f])?o[f]=E(a,o[f],(r?`${r}.`:"")+f.toString(),n):o[f]=a))}return o}function tt(t){return(...e)=>e.reduce((r,n)=>E(r,n,"",t),{})}const F=tt();let C=null;const N=t=>{C=t},S=()=>{if(!C)throw new Error("Api client not initialized. Call setApiClient() first.");return C},et=()=>C;function D(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function B(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&D(t[e]))return!0;return!1}function J(t,e,r,n,o){if(!(!t||typeof t!="object"))for(let f in t){const a=t[f];if(a&&typeof a=="object"){if("__args"in a){const u=a.__args,s={};Object.entries(u).forEach(([i,c])=>{if(c instanceof Array&&D(c)){s[i]=new m.VariableType(i);let l=0;c.forEach(h=>{h instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),n.append(o.current.toString(),h),o.current++,l++)}),e[i]="[Upload!]!"}else c instanceof File?(s[i]=new m.VariableType(i),r[o.current]=["variables."+i],n.append(o.current.toString(),c),e[i]="Upload!",o.current++):c instanceof Object&&B(c)?(s[i]={},Object.entries(c).forEach(([l,h])=>{if(h instanceof Array&&D(h)){s[i][l]=new m.VariableType(l);let y=0;h.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+y),n.append(o.current.toString(),_),o.current++,y++)}),e[l]="[Upload!]!"}else h instanceof File?(s[i][l]=new m.VariableType(l),r[o.current]=["variables."+l],n.append(o.current.toString(),h),e[l]="Upload!",o.current++):s[i][l]=h})):c!=null&&(s[i]=c)}),a.__args=s}J(a,e,r,n,o)}}}const w=async t=>{const e=S(),r=t,n=new FormData;let o=!1;const f={},a={};J(r,f,a,n,{current:0}),o=Object.keys(f).length>0,o&&(r.__variables=f);let s=null;const i={query:r},c=m.jsonToGraphQLQuery(i);if(o?(n.append("map",JSON.stringify(a)),n.append("operations",JSON.stringify({query:c})),s=await e.axios.post("",n)):s=await e.axios.post("",{query:c}),s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function j(t,e){let r,n=[],o,f;const a=s=>!s||typeof s!="object"?!1:Object.values(s).some(i=>i&&typeof i=="object"&&Object.keys(i).some(c=>c.startsWith("_"))),u=()=>n.length===0?(n.unshift({}),n[0]):(a(n[0])&&n.unshift({}),n[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const i=await this.limit(1).fetch();return Array.isArray(i)&&i.length>0?i[0]:null},async fetchWithMeta(){let i=await w(this.toQuery(!0));if(f){const c=f.split(".");for(const l of c)i=i[l];return i}return i[`list${t}`]},async fetch(){let i=await w(this.toQuery());if(f){const c=f.split(".");for(const l of c)i=i[l];return i.data}return i[`list${t}`].data},dataPath(s){return s&&typeof s=="string"&&(f=s),this},sort(s){return s&&typeof s=="string"&&(o=s),this},filters(s){return s&&typeof s=="object"&&(n=[s]),this},where(s,i,c){const l=(h,y,_)=>{const O={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[y];O&&n.push({[h]:{[O]:_}})};if(c!==void 0)l(s,String(i),c);else{const h=u(),y=F(h,{[s]:i});n[0]=y}return this},whereContains(s,i){if(s&&typeof s=="string"){const c=u(),l={_contains:i};c[s]?Array.isArray(c[s])?c[s].push(l):c[s]=[c[s],l]:c[s]=[l],n[0]=c}return this},whereIn(s,i){if(s&&typeof s=="string"&&Array.isArray(i)){const c=u(),l={_in:i};c[s]?Array.isArray(c[s])?c[s].push(l):c[s]=[c[s],l]:c[s]=[l],n[0]=c}return this},whereBetween(s,i,c){if(s&&typeof s=="string"){const l=u(),h={_between:[i,c]};l[s]?Array.isArray(l[s])?l[s].push(h):l[s]=[l[s],h]:l[s]=h,n[0]=l}return this},limit(s){return typeof s=="number"&&Number.isFinite(s)&&(r=F(r||{},{limit:s})),this},offset(s){return typeof s=="number"&&Number.isFinite(s)&&(r=F(r||{},{offset:s})),this},toQuery(s=!1){let i;const c=n.length>0&&Object.keys(n[0]||{}).length>0,l=c?1:0,h=n.length>l;c&&h?i=n:h?i=n.slice(l):c&&(i=n[0]);const y=F(o?{sort:o}:{},i?{filters:i}:{}),_={data:{...e}};if(r&&(_.data.__args=r),Object.keys(y).length>0&&(_.__args=y),s&&(_.meta={total:!0,key:!0,name:!0}),f){const b=f.split(".");let O=_;for(let q=b.length-1;q>=0;q--)O={[b[q]]:O};return O}return{[`list${t}`]:_}}}}const L=(t,e)=>{const r=t,n=e;let o="list"+t;const f=a=>n[a]?n[a]:null;return{field:f,$fields:n,setDataPath(a){return o=a,o},getDataPath(){return o},gqlFields(a){let u={};for(const s of a)if(typeof s=="string"){const i=f(s);i&&(u=F(u,i.gqlField?typeof i.gqlField=="string"?{[i.gqlField]:!0}:i.gqlField:{[i.name||s]:!0}))}else typeof s=="object"&&(u=F(u,s));return u},update(a,u){return p({["update"+r]:{__args:{id:a,data:u}}}).then(s=>s["update"+r])},async delete(a){return p({["delete"+r]:{__args:{id:a}}}).then(u=>u["delete"+r])},add(a){return p({["add"+r]:{__args:{data:a}}}).then(u=>u["add"+r])},fields(a){let u=[];for(let s of a){const i=f(s);i&&u.push(i)}return u},async get(a,u){const s=(await Promise.resolve().then(()=>bt)).default,i=s(r,I(u));for(const[c,l]of Object.entries(a))i.where(c,"==",l);return await i.first()},list(a){let u=a;const s={};Object.entries(a).forEach(([l])=>{n[l]&&(s[l]=n[l],n[l].gqlField&&(delete u[l],u=F(u,n[l].gqlField)),n[l].gql&&(u=F(u,n[l].gql),delete u[l]))});const i=j(r,u).dataPath(o),c=i.fetch.bind(i);return{...i,async fetch(){return(await c()).map(h=>{const y={...h};return Object.entries(s).forEach(([_,b])=>{b.format&&typeof b.format=="function"&&(y[_]=b.format(h))}),y})},async fetchFirst(){const h=await i.fetchFirst.bind(i)();if(!h)return h;const y={...h};return Object.entries(s).forEach(([_,b])=>{b.format&&typeof b.format=="function"&&(y[_]=b.format(h))}),y}}}}},A={},M=(t=!1)=>{const e={};return{create(r,n){const o=L(r,n);e[r]=o,t&&(A[r]=o)},get(r){return e[r]||(t&&A[r]?e[r]=A[r]:this.create(r,{})),e[r]},has(r){return!!e[r]||t&&!!A[r]},list(){const r=Object.keys(e),n=t?Object.keys(A):[];return[...new Set([...r,...n])]},clear(){Object.keys(e).forEach(r=>delete e[r])}}},rt=()=>{const t=M(!1);return{manager:t,createModel:t.create,getModel:t.get,hasModel:t.has,listModels:t.list,clearModels:t.clear,defineModel(e,r){return t.create(e,r),t.get(e)},defineModels(e){Object.entries(e).forEach(([r,n])=>{t.create(r,n)})}}},st=()=>{const t=M(!0);return{manager:t,createModel:t.create,getModel:t.get,hasModel:t.has,listModels:t.list,clearModels:t.clear,defineModel(e,r){return t.create(e,r),t.get(e)},defineModels(e){Object.entries(e).forEach(([r,n])=>{t.create(r,n)})}}},nt=()=>({define(t,e){const r=L(t,e);return A[t]=r,r},get(t){return A[t]},has(t){return!!A[t]},list(){return Object.keys(A)},clear(){Object.keys(A).forEach(t=>delete A[t])}}),T=async()=>{const{app:t}=await w({app:{auth:{webAuthnRequestOptions:!0}}}),e=t.auth.webAuthnRequestOptions,r=PublicKeyCredential.parseRequestOptionsFromJSON(e);return await navigator.credentials.get({publicKey:r})},$=async()=>{const{app:t}=await w({app:{auth:{webAuthnCreationOptions:!0}}}),e=PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:e})},W=Object.freeze(Object.defineProperty({__proto__:null,assertion:T,attestation:$,login:async()=>{const t=await T();return await p({webAuthnAssertion:{assertion:t.toJSON()}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await $();return await p({webAuthnRegister:{registration:t.toJSON()}}).then(e=>e.webAuthnRegister)}},Symbol.toStringTag,{value:"Module"})),z=(t,e,r="")=>p({login:{__args:{username:t,password:e,code:r}}}).then(n=>n.login),Q=()=>p({logout:!0}).then(t=>t.logout),R=(t,e,r)=>p({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(n=>n.changeExpiredPassword),G=(t,e)=>p({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),H=(t,e,r)=>p({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(n=>n.resetPassword),V=(t,e)=>p({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),X=(t,e)=>p({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),Y=t=>w({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),it=()=>({webAuthn:W,google:{unlink:()=>p({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>p({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>p({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>p({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>p({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>p({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>p({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>p({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>p({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:z,logout:Q,changeExpiredPassword:R,updatePassword:G,resetPassword:H,forgetPassword:V,verifyCode:X,granted:Y}),ot={name:!0,path:!0,size:!0,mime:!0,url:!0},at=t=>({list:(e,r=ot)=>w({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(n=>n.app.drive.files),get:(e,r={name:!0,path:!0,size:!0,mime:!0,url:!0})=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},...r}}}}).then(n=>n.app.drive.file),read:async e=>{let r=await w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}});if(!r.app.drive.file||!r.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${e}`);return typeof window<"u"&&window.atob?window.atob(r.app.drive.file.base64Content):r.app.drive.file.base64Content},write:(e,r)=>p({lightDriveWriteFile:{__args:{index:t,path:e,content:r}}}).then(n=>n.lightDriveWriteFile),delete:e=>p({lightDriveDeleteFile:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFile),rename:(e,r)=>p({lightDriveRenameFile:{__args:{index:t,path:e,name:r}}}).then(n=>n.lightDriveRenameFile),move:(e,r)=>p({lightDriveMoveFile:{__args:{index:t,source:e,destination:r}}}).then(n=>n.lightDriveMoveFile)}),ct=()=>w({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),Z=t=>({uploadTempFile:e=>p({lightDriveUploadTempFile:{__args:{index:t,file:e},name:!0,path:!0,size:!0,mime:!0}}).then(r=>r.lightDriveUploadTempFile),folders:{list:(e,r={name:!0,path:!0})=>w({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(n=>n.app.drive.folders),create:e=>p({lightDriveCreateFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveCreateFolder),delete:e=>p({lightDriveDeleteFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFolder),rename:(e,r)=>p({lightDriveRenameFolder:{__args:{index:t,path:e,name:r}}}).then(n=>n.lightDriveRenameFolder)},files:at(t)});function K(t,e,r,n,o){if(!(!t||typeof t!="object"))for(let f in t){const a=t[f];if(a&&typeof a=="object"){if("__args"in a){const u=a.__args,s={};Object.entries(u).forEach(([i,c])=>{if(c instanceof Array&&D(c)){s[i]=new m.VariableType(i);let l=0;c.forEach(h=>{h instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),n.append(o.current.toString(),h),o.current++,l++)}),e[i]="[Upload!]!"}else c instanceof File?(s[i]=new m.VariableType(i),r[o.current]=["variables."+i],n.append(o.current.toString(),c),e[i]="Upload!",o.current++):c instanceof Object&&B(c)?(s[i]={},Object.entries(c).forEach(([l,h])=>{if(h instanceof Array&&D(h)){s[i][l]=new m.VariableType(l);let y=0;h.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+y),n.append(o.current.toString(),_),o.current++,y++)}),e[l]="[Upload!]!"}else h instanceof File?(s[i][l]=new m.VariableType(l),r[o.current]=["variables."+l],n.append(o.current.toString(),h),e[l]="Upload!",o.current++):s[i][l]=h})):c!=null&&(s[i]=c)}),a.__args=s}K(a,e,r,n,o)}}}const p=async t=>{const r=S().axios,n=t,o=new FormData;let f=!1;const a={},u={};K(n,a,u,o,{current:0}),f=Object.keys(a).length>0,f&&(n.__variables=a);let i=null;const c={mutation:n},l=m.jsonToGraphQLQuery(c);if(f?(o.append("map",JSON.stringify(u)),o.append("operations",JSON.stringify({query:l})),i=await r.post("",o)):i=await r.post("",{query:l}),i.data.errors)throw new Error(i.data.errors[0].message);return i.data.data},v=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(v(r)).forEach(([n,o])=>{e[n]=o})}),e):(Object.entries(t).forEach(([r,n])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=n;return}if(typeof n=="boolean"){e[r]=n;return}e[r]=v(n)}),e)},I=t=>v(t),lt=t=>w({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]),ut={send:(t,e,r)=>p({sendMail:{__args:{email:t,subject:e,message:r}}}).then(n=>n.sendMail)},ht={name:!0},ft=(t=ht)=>w({app:{roles:t}}).then(e=>e.app.roles),pt=(t,e)=>p({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),dt=t=>p({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),gt=()=>({list:ft,create:pt,delete:dt}),_t="list",yt=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap","sort"],wt=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition"];class g{_batchData=null;data_path="";filters;steps;fields;already_limit=!1;already_offset=!1;limit=null;offset=null;_sort=null;_sortDesc=!1;meta={};constructor(e){this.filters={},this.steps=[],this.fields=e}}g.prototype.getQueryPayload=function(){let t={meta:{total:!0,key:!0,name:!0}};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),{data_path:this.data_path,query:t,steps:this.steps}},g.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},g.prototype.buildArgs=function(){let t={};return Object.keys(this.filters).length>0&&(t.filters=this.filters),this._sort&&(t.sort=this._sort,this._sortDesc&&(t.sort+=":desc")),t},g.prototype.clone=function(){const t=Object.create(this);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},P().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),g.prototype.fetchData=async function(){try{if(this._batchData){const u=this._batchData;return this.meta=u.meta,P(u.data)}let t={meta:{total:!0,key:!0,name:!0}};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);const e=this.data_path.split(".");let r={},n=r,o=e[e.length-1];for(const u of e){if(u===o){n[u]=t;break}n[u]={},n=n[u]}let a=await w(r);for(const u of e)a=a[u];return this.meta=a.meta,P(a.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},g.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},g.prototype.all=async function(){return(await this.processData()).all()};for(const t of yt)g.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of wt)g.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};g.prototype.average=g.prototype.avg,g.prototype.first=async function(){return this.take(1),(await this.processData()).first()},g.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},g.prototype.where=function(...t){const e=this._handleBatchData("where",t);if(e)return e;if(t.length===2)this.filters[t[0]]=t[1];else if(t.length===3){const r=t[0],n=t[1],o=t[2];switch(n){case"==":this.filters[r]=o;break;case"<":this.filters[r]={lt:o};break;case"<=":this.filters[r]={lte:o};break;case">":this.filters[r]={gt:o};break;case">=":this.filters[r]={gte:o};break;case"!==":this.filters[r]={ne:o};break;default:throw new Error(`Unsupported operator: ${n}`)}}return this},g.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},g.prototype.forPage=function(t,e){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)},g.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},g.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},g.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},g.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},g.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},g.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},g.prototype.skip=function(t){if(t<0)throw new Error("Offset must be non-negative");return this.already_offset&&this.steps.push({type:"skip",args:[t]}),this.offset=t,this.already_offset=!0,this},g.prototype.take=function(t){if(t<0)throw new Error("Length must be non-negative");return this.already_limit?(this.steps.push({type:"take",args:[t]}),this):(this.limit=t,this.already_limit=!0,this)},g.prototype.splice=function(t,e){return this.steps.push({type:"splice",args:[t,e]}),this.offset=t,this.limit=e,this.already_limit=!0,this.already_offset=!0,this};const U=(t,e)=>{const r=new g(e);return r.data_path=_t+t,r},bt=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),mt={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},At=t=>p({createUser:{__args:{},...t}}).then(e=>e.createUser),Ft=t=>p({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),Ot=()=>({list:async(t=mt)=>j("Users",t).dataPath("app.listUser").fetch(),create:t=>At(t),delete:t=>Ft(t)}),Dt=t=>{const e=typeof window>"u";let r=[];const n=x.create({baseURL:t,withCredentials:!0});e&&(n.interceptors.request.use(a=>(a.withCredentials=!0,r.length>0&&(a.headers.Cookie=r.join("; ")),a)),n.interceptors.response.use(a=>{if(a.headers["set-cookie"]){const u=a.headers["set-cookie"].map(i=>i.split(";")[0]),s=new Map;r.forEach(i=>{const c=i.split("=")[0];s.set(c,i)}),u.forEach(i=>{const c=i.split("=")[0];s.set(c,i)}),r=Array.from(s.values())}return a}));const o=M(),f={post:n.post,baseURL:t,axios:n,auth:it(),mutation:p,query:w,config:lt,mail:ut,users:Ot(),models:o,model(a){return o.get(a)},roles:gt(),collect:(a,u)=>{const s=U(a,u);return s.data_path=o.get(a).getDataPath(),s},list:(a,u)=>j(a,u).dataPath(o.get(a).getDataPath()),drive:Z,async collects(a){const u={},s={};for(const c in a){const l=a[c].getQueryPayload();s[c]=l.data_path,u[c]={};const h=l.data_path.split(".");let y=h[h.length-1],_=u[c];for(const b of h){if(b===y){_[b]=l.query;break}_[b]=_[b]||{}}u[c].__aliasFor=h[0]}const i=await w(u);for(const c in a){const l=s[c].split(".");let h=l[l.length-1],y=i[c];for(const _ of l){if(_===h){a[c]._batchData=i[c][_];break}y[_]=y[_]||{}}}return a}};return N(f),f};d.changeExpiredPassword=R,d.createClient=Dt,d.createCollection=U,d.createList=j,d.createModelManager=M,d.forgetPassword=V,d.getApiClient=S,d.getApiClientOptional=et,d.getDrive=Z,d.granted=Y,d.listDrives=ct,d.login=z,d.logout=Q,d.mutation=p,d.query=w,d.resetPassword=H,d.setApiClient=N,d.toQuery=I,d.updatePassword=G,d.useGlobalModel=st,d.useGlobalModels=nt,d.useModel=rt,d.verifyCode=X,d.webAuthn=W,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("json-to-graphql-query"),require("axios"),require("collect.js")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios","collect.js"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.light={},h.jsonToGraphqlQuery,h.axios,h.collect))})(this,(function(h,m,_t,U){"use strict";function E(t){if(t===null||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);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}function S(t,e,r=".",n){if(!E(e))return S(t,{},r,n);const o=Object.assign({},e);for(const p in t){if(p==="__proto__"||p==="constructor")continue;const a=t[p];a!=null&&(n&&n(o,p,a,r)||(Array.isArray(a)&&Array.isArray(o[p])?o[p]=[...a,...o[p]]:E(a)&&E(o[p])?o[p]=S(a,o[p],(r?`${r}.`:"")+p.toString(),n):o[p]=a))}return o}function yt(t){return(...e)=>e.reduce((r,n)=>S(r,n,"",t),{})}const A=yt();let j=null;const L=t=>{j=t},v=()=>{if(!j)throw new Error("Api client not initialized. Call setApiClient() first.");return j},wt=()=>j;function C(t){for(let e=0;e<t.length;e++)if(t[e]instanceof File)return!0;return!1}function T(t){for(let e in t)if(t[e]instanceof File||t[e]instanceof Array&&C(t[e]))return!0;return!1}function $(t,e,r,n,o){if(!(!t||typeof t!="object"))for(let p in t){const a=t[p];if(a&&typeof a=="object"){if("__args"in a){const u=a.__args,s={};Object.entries(u).forEach(([i,c])=>{if(c instanceof Array&&C(c)){s[i]=new m.VariableType(i);let l=0;c.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),n.append(o.current.toString(),f),o.current++,l++)}),e[i]="[Upload!]!"}else c instanceof File?(s[i]=new m.VariableType(i),r[o.current]=["variables."+i],n.append(o.current.toString(),c),e[i]="Upload!",o.current++):c instanceof Object&&T(c)?(s[i]={},Object.entries(c).forEach(([l,f])=>{if(f instanceof Array&&C(f)){s[i][l]=new m.VariableType(l);let y=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+y),n.append(o.current.toString(),_),o.current++,y++)}),e[l]="[Upload!]!"}else f instanceof File?(s[i][l]=new m.VariableType(l),r[o.current]=["variables."+l],n.append(o.current.toString(),f),e[l]="Upload!",o.current++):s[i][l]=f})):c!=null&&(s[i]=c)}),a.__args=s}$(a,e,r,n,o)}}}const w=async t=>{const e=v(),r=t,n=new FormData;let o=!1;const p={},a={};$(r,p,a,n,{current:0}),o=Object.keys(p).length>0,o&&(r.__variables=p);let s=null;const i={query:r},c=m.jsonToGraphQLQuery(i);if(o?(n.append("map",JSON.stringify(a)),n.append("operations",JSON.stringify({query:c})),s=await e.axios.post("",n)):s=await e.axios.post("",{query:c}),s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function M(t,e){let r,n=[],o,p;const a=s=>!s||typeof s!="object"?!1:Object.values(s).some(i=>i&&typeof i=="object"&&Object.keys(i).some(c=>c.startsWith("_"))),u=()=>n.length===0?(n.unshift({}),n[0]):(a(n[0])&&n.unshift({}),n[0]);return{first(){return this.fetchFirst()},all(){return this.fetch()},async fetchFirst(){const i=await this.limit(1).fetch();return Array.isArray(i)&&i.length>0?i[0]:null},async fetchWithMeta(){let i=await w(this.toQuery(!0));if(p){const c=p.split(".");for(const l of c)i=i[l];return i}return i[`list${t}`]},async fetch(){let i=await w(this.toQuery());if(p){const c=p.split(".");for(const l of c)i=i[l];return i.data}return i[`list${t}`].data},dataPath(s){return s&&typeof s=="string"&&(p=s),this},sort(s){return s&&typeof s=="string"&&(o=s),this},filters(s){return s&&typeof s=="object"&&(n=[s]),this},where(s,i,c){const l=(f,y,_)=>{const D={">":"_gt","<":"_lt",">=":"_gte","<=":"_lte","!=":"_ne",in:"_in",contains:"_contains"}[y];D&&n.push({[f]:{[D]:_}})};if(c!==void 0)l(s,String(i),c);else{const f=u(),y=A(f,{[s]:i});n[0]=y}return this},whereContains(s,i){if(s&&typeof s=="string"){const c=u(),l={_contains:i};c[s]?Array.isArray(c[s])?c[s].push(l):c[s]=[c[s],l]:c[s]=[l],n[0]=c}return this},whereIn(s,i){if(s&&typeof s=="string"&&Array.isArray(i)){const c=u(),l={_in:i};c[s]?Array.isArray(c[s])?c[s].push(l):c[s]=[c[s],l]:c[s]=[l],n[0]=c}return this},whereBetween(s,i,c){if(s&&typeof s=="string"){const l=u(),f={_between:[i,c]};l[s]?Array.isArray(l[s])?l[s].push(f):l[s]=[l[s],f]:l[s]=f,n[0]=l}return this},limit(s){return typeof s=="number"&&Number.isFinite(s)&&(r=A(r||{},{limit:s})),this},offset(s){return typeof s=="number"&&Number.isFinite(s)&&(r=A(r||{},{offset:s})),this},toQuery(s=!1){let i;const c=n.length>0&&Object.keys(n[0]||{}).length>0,l=c?1:0,f=n.length>l;c&&f?i=n:f?i=n.slice(l):c&&(i=n[0]);const y=A(o?{sort:o}:{},i?{filters:i}:{}),_={data:{...e}};if(r&&(_.data.__args=r),Object.keys(y).length>0&&(_.__args=y),s&&(_.meta={total:!0,key:!0,name:!0}),p){const b=p.split(".");let D=_;for(let J=b.length-1;J>=0;J--)D={[b[J]]:D};return D}return{[`list${t}`]:_}}}}const W=(t,e)=>{const r=t,n=e;let o="list"+t;const p=a=>n[a]?n[a]:null;return{field:p,$fields:n,setDataPath(a){return o=a,o},getDataPath(){return o},gqlFields(a){let u={};for(const s of a)if(typeof s=="string"){const i=p(s);i&&(u=A(u,i.gqlField?typeof i.gqlField=="string"?{[i.gqlField]:!0}:i.gqlField:{[i.name||s]:!0}))}else typeof s=="object"&&(u=A(u,s));return u},update(a,u){return d({["update"+r]:{__args:{id:a,data:u}}}).then(s=>s["update"+r])},async delete(a){return d({["delete"+r]:{__args:{id:a}}}).then(u=>u["delete"+r])},add(a){return d({["add"+r]:{__args:{data:a}}}).then(u=>u["add"+r])},fields(a){let u=[];for(let s of a){const i=p(s);i&&u.push(i)}return u},async get(a,u){const s=(await Promise.resolve().then(()=>St)).default,i=s(r,gt(u));for(const[c,l]of Object.entries(a))i.where(c,"==",l);return await i.first()},list(a){let u=a;const s={};Object.entries(a).forEach(([l])=>{n[l]&&(s[l]=n[l],n[l].gqlField&&(delete u[l],u=A(u,n[l].gqlField)),n[l].gql&&(u=A(u,n[l].gql),delete u[l]))});const i=M(r,u).dataPath(o),c=i.fetch.bind(i);return{...i,async fetch(){return(await c()).map(f=>{const y={...f};return Object.entries(s).forEach(([_,b])=>{b.format&&typeof b.format=="function"&&(y[_]=b.format(f))}),y})},async fetchFirst(){const f=await i.fetchFirst.bind(i)();if(!f)return f;const y={...f};return Object.entries(s).forEach(([_,b])=>{b.format&&typeof b.format=="function"&&(y[_]=b.format(f))}),y}}}}},F={},k=(t=!1)=>{const e={};return{create(r,n){const o=W(r,n);e[r]=o,t&&(F[r]=o)},get(r){return e[r]||(t&&F[r]?e[r]=F[r]:this.create(r,{})),e[r]},has(r){return!!e[r]||t&&!!F[r]},list(){const r=Object.keys(e),n=t?Object.keys(F):[];return[...new Set([...r,...n])]},clear(){Object.keys(e).forEach(r=>delete e[r])}}},bt=()=>{const t=k(!1);return{manager:t,createModel:t.create,getModel:t.get,hasModel:t.has,listModels:t.list,clearModels:t.clear,defineModel(e,r){return t.create(e,r),t.get(e)},defineModels(e){Object.entries(e).forEach(([r,n])=>{t.create(r,n)})}}},mt=()=>{const t=k(!0);return{manager:t,createModel:t.create,getModel:t.get,hasModel:t.has,listModels:t.list,clearModels:t.clear,defineModel(e,r){return t.create(e,r),t.get(e)},defineModels(e){Object.entries(e).forEach(([r,n])=>{t.create(r,n)})}}},Ft=()=>({define(t,e){const r=W(t,e);return F[t]=r,r},get(t){return F[t]},has(t){return!!F[t]},list(){return Object.keys(F)},clear(){Object.keys(F).forEach(t=>delete F[t])}}),At=()=>w({app:{permissions:!0}}).then(t=>t.app.permissions),z=async()=>{const{app:t}=await w({app:{auth:{webAuthnRequestOptions:!0}}}),e=t.auth.webAuthnRequestOptions,r=PublicKeyCredential.parseRequestOptionsFromJSON(e);return await navigator.credentials.get({publicKey:r})},Q=async()=>{const{app:t}=await w({app:{auth:{webAuthnCreationOptions:!0}}}),e=PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:e})},R=Object.freeze(Object.defineProperty({__proto__:null,assertion:z,attestation:Q,login:async()=>{const t=await z();return await d({webAuthnAssertion:{assertion:t.toJSON()}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await Q();return await d({webAuthnRegister:{registration:t.toJSON()}}).then(e=>e.webAuthnRegister)}},Symbol.toStringTag,{value:"Module"})),G=(t=q)=>w({my:t}).then(e=>e.my),H=(t,e,r="")=>d({login:{__args:{username:t,password:e,code:r}}}).then(n=>n.login),V=()=>d({logout:!0}).then(t=>t.logout),X=(t,e,r)=>d({changeExpiredPassword:{__args:{username:t,old_password:e,new_password:r}}}).then(n=>n.changeExpiredPassword),Y=(t,e)=>d({changeUserPassword:{__args:{old_password:t,new_password:e}}}).then(r=>r.changeUserPassword),Z=(t,e,r)=>d({resetPassword:{__args:{jwt:t,password:e,code:r}}}).then(n=>n.resetPassword),K=(t,e)=>d({forgetPassword:{__args:{username:t,email:e}}}).then(r=>r.forgetPassword),I=(t,e)=>d({forgetPasswordVerifyCode:{__args:{jwt:t,code:e}}}).then(r=>r.forgetPasswordVerifyCode),x=t=>w({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),tt=()=>({getCurrentUser:G,webAuthn:R,google:{unlink:()=>d({lightAuthUnlinkGoogle:!0}).then(t=>t.lightAuthUnlinkGoogle),login:t=>d({lightAuthLoginGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthLoginGoogle),register:t=>d({lightAuthRegisterGoogle:{__args:{credential:t}}}).then(e=>e.lightAuthRegisterGoogle)},facebook:{unlink:()=>d({lightAuthUnlinkFacebook:!0}).then(t=>t.lightAuthUnlinkFacebook),login:t=>d({lightAuthLoginFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginFacebook),register:t=>d({lightAuthRegisterFacebook:{__args:{access_token:t}}}).then(e=>e.lightAuthRegisterFacebook)},microsoft:{unlink:()=>d({lightAuthUnlinkMicrosoft:!0}).then(t=>t.lightAuthUnlinkMicrosoft),login:t=>d({lightAuthLoginMicrosoft:{__args:{access_token:t}}}).then(e=>e.lightAuthLoginMicrosoft),register:t=>d({lightAuthRegisterMicrosoft:{__args:{account_id:t}}}).then(e=>e.lightAuthRegisterMicrosoft)},login:H,logout:V,changeExpiredPassword:X,updatePassword:Y,resetPassword:Z,forgetPassword:K,verifyCode:I,granted:x}),et={name:!0,path:!0,size:!0,mime:!0,url:!0},rt=(t,e,r=et)=>w({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(n=>n.app.drive.files),O=t=>({list:(e,r=et)=>rt(t,e,r),get:(e,r={name:!0,path:!0,size:!0,mime:!0,url:!0})=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},...r}}}}).then(n=>n.app.drive.file),read:async e=>{let r=await w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}});if(!r.app.drive.file||!r.app.drive.file.base64Content)throw new Error(`File not found or cannot read content: ${e}`);return typeof window<"u"&&window.atob?window.atob(r.app.drive.file.base64Content):r.app.drive.file.base64Content},write:(e,r)=>d({lightDriveWriteFile:{__args:{index:t,path:e,content:r}}}).then(n=>n.lightDriveWriteFile),delete:e=>d({lightDriveDeleteFile:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFile),rename:(e,r)=>d({lightDriveRenameFile:{__args:{index:t,path:e,name:r}}}).then(n=>n.lightDriveRenameFile),move:(e,r)=>d({lightDriveMoveFile:{__args:{index:t,source:e,destination:r}}}).then(n=>n.lightDriveMoveFile)}),st={name:!0,path:!0},Ot=(t,e,r=st)=>w({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(n=>n.app.drive.folders),P=t=>({list:(e,r=st)=>Ot(t,e,r),create:e=>d({lightDriveCreateFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveCreateFolder),delete:e=>d({lightDriveDeleteFolder:{__args:{index:t,path:e}}}).then(r=>r.lightDriveDeleteFolder),rename:(e,r)=>d({lightDriveRenameFolder:{__args:{index:t,path:e,name:r}}}).then(n=>n.lightDriveRenameFolder)}),Dt=()=>w({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),nt=t=>({listFiles:O(t).list,getFile:O(t).get,readFile:O(t).read,writeFile:O(t).write,deleteFile:O(t).delete,renameFile:O(t).rename,moveFile:O(t).move,listFolders:P(t).list,createFolder:P(t).create,deleteFolder:P(t).delete,renameFolder:P(t).rename,uploadTempFile:e=>d({lightDriveUploadTempFile:{__args:{index:t,file:e},name:!0,path:!0,size:!0,mime:!0}}).then(r=>r.lightDriveUploadTempFile),folders:P(t),files:O(t)}),q={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},it=t=>d({addUser:{__args:t}}).then(e=>e.addUser),ot=t=>d({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),at=(t=q)=>M("Users",t).dataPath("app.listUser").fetch(),ct=(t,e)=>d({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),Ct=()=>({list:at,create:it,delete:ot,update:ct}),lt=t=>w({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]?.value),Pt={name:!0},ut=(t=Pt)=>w({app:{roles:t}}).then(e=>e.app.roles),ht=(t,e)=>d({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),ft=t=>d({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),jt=()=>({list:ut,create:ht,delete:ft});function pt(t,e,r,n,o){if(!(!t||typeof t!="object"))for(let p in t){const a=t[p];if(a&&typeof a=="object"){if("__args"in a){const u=a.__args,s={};Object.entries(u).forEach(([i,c])=>{if(c instanceof Array&&C(c)){s[i]=new m.VariableType(i);let l=0;c.forEach(f=>{f instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+i+"."+l),n.append(o.current.toString(),f),o.current++,l++)}),e[i]="[Upload!]!"}else c instanceof File?(s[i]=new m.VariableType(i),r[o.current]=["variables."+i],n.append(o.current.toString(),c),e[i]="Upload!",o.current++):c instanceof Object&&T(c)?(s[i]={},Object.entries(c).forEach(([l,f])=>{if(f instanceof Array&&C(f)){s[i][l]=new m.VariableType(l);let y=0;f.forEach(_=>{_ instanceof File&&(r[o.current]||(r[o.current]=[]),r[o.current].push("variables."+l+"."+y),n.append(o.current.toString(),_),o.current++,y++)}),e[l]="[Upload!]!"}else f instanceof File?(s[i][l]=new m.VariableType(l),r[o.current]=["variables."+l],n.append(o.current.toString(),f),e[l]="Upload!",o.current++):s[i][l]=f})):c!=null&&(s[i]=c)}),a.__args=s}pt(a,e,r,n,o)}}}const d=async t=>{const r=v().axios,n=t,o=new FormData;let p=!1;const a={},u={};pt(n,a,u,o,{current:0}),p=Object.keys(a).length>0,p&&(n.__variables=a);let i=null;const c={mutation:n},l=m.jsonToGraphQLQuery(c);if(p?(o.append("map",JSON.stringify(u)),o.append("operations",JSON.stringify({query:l})),i=await r.post("",o)):i=await r.post("",{query:l}),i.data.errors)throw new Error(i.data.errors[0].message);return i.data.data},dt=(t,e,r)=>d({sendMail:{__args:{email:t,subject:e,message:r}}}).then(n=>n.sendMail),Mt={send:dt},N=t=>{let e={};return typeof t=="string"?(e[t]=!0,e):t instanceof Array?(t.forEach(r=>{Object.entries(N(r)).forEach(([n,o])=>{e[n]=o})}),e):(Object.entries(t).forEach(([r,n])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){e[r]=n;return}if(typeof n=="boolean"){e[r]=n;return}e[r]=N(n)}),e)},gt=t=>N(t),kt="list",Ut=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap","sort"],Et=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition"];class g{_batchData=null;data_path="";filters;steps;fields;already_limit=!1;already_offset=!1;limit=null;offset=null;_sort=null;_sortDesc=!1;meta={};constructor(e){this.filters={},this.steps=[],this.fields=e}}g.prototype.getQueryPayload=function(){let t={meta:{total:!0,key:!0,name:!0}};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),{data_path:this.data_path,query:t,steps:this.steps}},g.prototype.dataPath=function(t){const e=this.clone();return e.data_path=t,e},g.prototype.buildArgs=function(){let t={};return Object.keys(this.filters).length>0&&(t.filters=this.filters),this._sort&&(t.sort=this._sort,this._sortDesc&&(t.sort+=":desc")),t},g.prototype.clone=function(){const t=Object.create(this);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},U().macro("whereContains",function(t,e){return this.filter(r=>r[t].toLowerCase().includes(e.toLowerCase()))}),g.prototype.fetchData=async function(){try{if(this._batchData){const u=this._batchData;return this.meta=u.meta,U(u.data)}let t={meta:{total:!0,key:!0,name:!0}};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);const e=this.data_path.split(".");let r={},n=r,o=e[e.length-1];for(const u of e){if(u===o){n[u]=t;break}n[u]={},n=n[u]}let a=await w(r);for(const u of e)a=a[u];return this.meta=a.meta,U(a.data)}catch(t){throw console.error("Error fetching collection data:",t),t}},g.prototype.processData=async function(){let t=await this.fetchData();for(const e of this.steps)t=t[e.type](...e.args);return t},g.prototype.all=async function(){return(await this.processData()).all()};for(const t of Ut)g.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of Et)g.prototype[t]=async function(...e){return(await this.clone().processData())[t](...e)};g.prototype.average=g.prototype.avg,g.prototype.first=async function(){return this.take(1),(await this.processData()).first()},g.prototype._handleBatchData=function(t,e){return this._batchData?(this.steps.push({type:t,args:e}),this):null},g.prototype.where=function(...t){const e=this._handleBatchData("where",t);if(e)return e;if(t.length===2)this.filters[t[0]]=t[1];else if(t.length===3){const r=t[0],n=t[1],o=t[2];switch(n){case"==":this.filters[r]=o;break;case"<":this.filters[r]={lt:o};break;case"<=":this.filters[r]={lte:o};break;case">":this.filters[r]={gt:o};break;case">=":this.filters[r]={gte:o};break;case"!==":this.filters[r]={ne:o};break;default:throw new Error(`Unsupported operator: ${n}`)}}return this},g.prototype.whereContains=function(t,e){const r=this._handleBatchData("whereContains",[t,e]);return r||(this.filters[t]={contains:e},this)},g.prototype.forPage=function(t,e){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)},g.prototype.whereIn=function(t,e){const r=this._handleBatchData("whereIn",[t,e]);return r||(this.filters[t]={in:e},this)},g.prototype.whereNotIn=function(t,e){const r=this._handleBatchData("whereNotIn",[t,e]);return r||(this.filters[t]={nin:e},this)},g.prototype.whereNotBetween=function(t,e){const r=this._handleBatchData("whereNotBetween",[t,e]);return r||(this.filters[t]={notBetween:e},this)},g.prototype.whereBetween=function(t,e){const r=this._handleBatchData("whereBetween",[t,e]);return r||(this.filters[t]={between:e},this)},g.prototype.sortBy=function(t){return this.steps.push({type:"sortBy",args:[t]}),typeof t=="string"&&(this._sort=t),this},g.prototype.sortByDesc=function(t){return this.steps.push({type:"sortByDesc",args:[t]}),typeof t=="string"&&(this._sort=t,this._sortDesc=!0),this},g.prototype.skip=function(t){if(t<0)throw new Error("Offset must be non-negative");return this.already_offset&&this.steps.push({type:"skip",args:[t]}),this.offset=t,this.already_offset=!0,this},g.prototype.take=function(t){if(t<0)throw new Error("Length must be non-negative");return this.already_limit?(this.steps.push({type:"take",args:[t]}),this):(this.limit=t,this.already_limit=!0,this)},g.prototype.splice=function(t,e){return this.steps.push({type:"splice",args:[t,e]}),this.offset=t,this.limit=e,this.already_limit=!0,this.already_offset=!0,this};const B=(t,e)=>{const r=new g(e);return r.data_path=kt+t,r},St=Object.freeze(Object.defineProperty({__proto__:null,default:B},Symbol.toStringTag,{value:"Module"})),vt=t=>{const e=typeof window>"u";let r=[];const n=_t.create({baseURL:t,withCredentials:!0});e&&(n.interceptors.request.use(a=>(a.withCredentials=!0,r.length>0&&(a.headers.Cookie=r.join("; ")),a)),n.interceptors.response.use(a=>{if(a.headers["set-cookie"]){const u=a.headers["set-cookie"].map(i=>i.split(";")[0]),s=new Map;r.forEach(i=>{const c=i.split("=")[0];s.set(c,i)}),u.forEach(i=>{const c=i.split("=")[0];s.set(c,i)}),r=Array.from(s.values())}return a}));const o=k(),p={post:n.post,baseURL:t,axios:n,auth:tt(),mutation:d,query:w,config:lt,mail:Mt,users:Ct(),models:o,model(a){return o.get(a)},roles:jt(),collect:(a,u)=>{const s=B(a,u);return s.data_path=o.get(a).getDataPath(),s},list:(a,u)=>M(a,u).dataPath(o.get(a).getDataPath()),drive:nt,async collects(a){const u={},s={};for(const c in a){const l=a[c].getQueryPayload();s[c]=l.data_path,u[c]={};const f=l.data_path.split(".");let y=f[f.length-1],_=u[c];for(const b of f){if(b===y){_[b]=l.query;break}_[b]=_[b]||{}}u[c].__aliasFor=f[0]}const i=await w(u);for(const c in a){const l=s[c].split(".");let f=l[l.length-1],y=i[c];for(const _ of l){if(_===f){a[c]._batchData=i[c][_];break}y[_]=y[_]||{}}}return a}};return L(p),p};h.auth=tt,h.changeExpiredPassword=X,h.createClient=vt,h.createCollection=B,h.createList=M,h.createModelManager=k,h.createRole=ht,h.createUser=it,h.defaultUserFields=q,h.deleteRole=ft,h.deleteUser=ot,h.forgetPassword=K,h.getApiClient=v,h.getApiClientOptional=wt,h.getConfig=lt,h.getCurrentUser=G,h.getDrive=nt,h.granted=x,h.listDrives=Dt,h.listFiles=rt,h.listPermissions=At,h.listRoles=ut,h.listUsers=at,h.login=H,h.logout=V,h.mutation=d,h.query=w,h.resetPassword=Z,h.sendMail=dt,h.setApiClient=L,h.toQuery=gt,h.updatePassword=Y,h.updateUser=ct,h.useGlobalModel=mt,h.useGlobalModels=Ft,h.useModel=bt,h.verifyCode=I,h.webAuthn=R,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,5 @@
1
+ export declare const listPermissions: () => Promise<Array<string>>;
2
+ declare const _default: () => {
3
+ list: () => Promise<Array<string>>;
4
+ };
5
+ export default _default;
package/dist/users.d.ts CHANGED
@@ -7,10 +7,23 @@ export type UserFields = {
7
7
  password?: string;
8
8
  join_date?: string;
9
9
  };
10
- type QueryUserFieldsUserFields = Partial<Record<keyof UserFields, boolean>>;
10
+ export type QueryUserFieldsUserFields = Partial<Record<keyof UserFields, boolean>>;
11
+ export declare const defaultUserFields: QueryUserFieldsUserFields;
12
+ export type CreateUserFields = {
13
+ username: string;
14
+ first_name: string;
15
+ last_name?: string;
16
+ password: string;
17
+ join_date: string;
18
+ };
19
+ export declare const createUser: (fields: CreateUserFields) => Promise<any>;
20
+ export declare const deleteUser: (id: Number) => Promise<boolean>;
21
+ export declare const listUsers: (fields?: QueryUserFieldsUserFields) => Promise<any[]>;
22
+ export declare const updateUser: (id: number, fields: Partial<CreateUserFields>) => Promise<any>;
11
23
  declare const _default: () => {
12
24
  list: (fields?: QueryUserFieldsUserFields) => Promise<any[]>;
13
- create: (fields: UserFields) => Promise<any>;
25
+ create: (fields: CreateUserFields) => Promise<any>;
14
26
  delete: (id: Number) => Promise<boolean>;
27
+ update: (id: number, fields: Partial<CreateUserFields>) => Promise<any>;
15
28
  };
16
29
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"