@hostlink/light 3.0.1 → 3.0.4
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 +4 -2
- package/dist/drive.d.ts +2 -0
- package/dist/file.d.ts +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/light.js +183 -149
- package/dist/light.umd.cjs +1 -1
- package/dist/mutation.d.ts +2 -1
- package/dist/query.d.ts +2 -1
- package/package.json +1 -1
package/dist/auth.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export declare const updatePassword: (oldPassword: string, newPassword: string)
|
|
|
8
8
|
export declare const resetPassword: (jwt: string, password: string, code: string) => Promise<boolean>;
|
|
9
9
|
export declare const forgetPassword: (username: string, email: string) => Promise<string>;
|
|
10
10
|
export declare const verifyCode: (jwt: string, code: string) => Promise<boolean>;
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const isGranted: (right: string) => Promise<boolean>;
|
|
12
|
+
export declare const getGrantedRights: (rights: string[]) => Promise<string[]>;
|
|
12
13
|
declare const _default: () => {
|
|
13
14
|
getCurrentUser: (fields?: QueryUserFieldsUserFields) => Promise<any>;
|
|
14
15
|
webAuthn: typeof webAuthn;
|
|
@@ -34,6 +35,7 @@ declare const _default: () => {
|
|
|
34
35
|
resetPassword: (jwt: string, password: string, code: string) => Promise<boolean>;
|
|
35
36
|
forgetPassword: (username: string, email: string) => Promise<string>;
|
|
36
37
|
verifyCode: (jwt: string, code: string) => Promise<boolean>;
|
|
37
|
-
|
|
38
|
+
grantedRights: (rights: string[]) => Promise<string[]>;
|
|
39
|
+
isGranted: (right: string) => Promise<boolean>;
|
|
38
40
|
};
|
|
39
41
|
export default _default;
|
package/dist/drive.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare const getDrive: (index: number) => {
|
|
|
26
26
|
files: {
|
|
27
27
|
list: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
28
28
|
get: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
29
|
+
readFileAsBase64(path: string): Promise<string>;
|
|
29
30
|
read: (path: string) => Promise<any>;
|
|
30
31
|
write: (path: string, content: string) => Promise<any>;
|
|
31
32
|
delete: (path: string) => Promise<any>;
|
|
@@ -65,6 +66,7 @@ declare const _default: () => {
|
|
|
65
66
|
files: {
|
|
66
67
|
list: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
67
68
|
get: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
69
|
+
readFileAsBase64(path: string): Promise<string>;
|
|
68
70
|
read: (path: string) => Promise<any>;
|
|
69
71
|
write: (path: string, content: string) => Promise<any>;
|
|
70
72
|
delete: (path: string) => Promise<any>;
|
package/dist/file.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export type FileFields = {
|
|
|
7
7
|
};
|
|
8
8
|
export type QueryFileFields = Partial<Record<keyof FileFields, boolean>>;
|
|
9
9
|
export declare const listFiles: (index: number, path: string, fields?: QueryFileFields) => Promise<any>;
|
|
10
|
+
export declare const readFileAsBase64: (index: number, path: string) => Promise<string>;
|
|
10
11
|
declare const _default: (index: number) => {
|
|
11
12
|
list: (path: string, fields?: QueryFileFields) => Promise<any>;
|
|
12
13
|
get: (path: string, fields?: QueryFileFields) => Promise<any>;
|
|
14
|
+
readFileAsBase64(path: string): Promise<string>;
|
|
13
15
|
read: (path: string) => Promise<any>;
|
|
14
16
|
write: (path: string, content: string) => Promise<any>;
|
|
15
17
|
delete: (path: string) => Promise<any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { default as createList } from './createList';
|
|
1
2
|
export { default as useModel, useGlobalModel, useGlobalModels, createModelManager } from './models';
|
|
2
3
|
export type { ModelManager } from './models';
|
|
3
4
|
export * from './permission';
|
|
@@ -5,6 +6,7 @@ export * as webAuthn from './webauthn';
|
|
|
5
6
|
export * from './auth';
|
|
6
7
|
export { default as auth } from './auth';
|
|
7
8
|
export * from './drive';
|
|
9
|
+
export * from './folder';
|
|
8
10
|
export * from './users';
|
|
9
11
|
export * from './config';
|
|
10
12
|
export * from './role';
|
|
@@ -19,5 +21,14 @@ export { default as createClient } from './createClient';
|
|
|
19
21
|
export type { LightClient } from './createClient';
|
|
20
22
|
export { default as createCollection } from './createCollection';
|
|
21
23
|
export { default as createList } from './createList';
|
|
24
|
+
export declare const list: typeof createList;
|
|
22
25
|
export type { RoleFields } from './role';
|
|
23
26
|
export { setApiClient, getApiClient, getApiClientOptional } from './apiClient';
|
|
27
|
+
export interface GraphQLQuery {
|
|
28
|
+
[key: string]: boolean | GraphQLQuery | {
|
|
29
|
+
__args: Record<string, any>;
|
|
30
|
+
__aliasFor?: string;
|
|
31
|
+
__variables?: Record<string, string>;
|
|
32
|
+
__name?: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
package/dist/light.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsonToGraphQLQuery as
|
|
1
|
+
import { jsonToGraphQLQuery as q, VariableType as F } from "json-to-graphql-query";
|
|
2
2
|
import H from "axios";
|
|
3
|
-
import
|
|
4
|
-
function
|
|
3
|
+
import E from "collect.js";
|
|
4
|
+
function M(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
|
|
11
|
-
if (!
|
|
12
|
-
return
|
|
10
|
+
function S(t, e, r = ".", n) {
|
|
11
|
+
if (!M(e))
|
|
12
|
+
return S(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]] :
|
|
18
|
+
a != null && (n && n(i, f, a, r) || (Array.isArray(a) && Array.isArray(i[f]) ? i[f] = [...a, ...i[f]] : M(a) && M(i[f]) ? i[f] = S(
|
|
19
19
|
a,
|
|
20
20
|
i[f],
|
|
21
21
|
(r ? `${r}.` : "") + f.toString(),
|
|
@@ -27,7 +27,7 @@ function E(t, e, r = ".", n) {
|
|
|
27
27
|
function X(t) {
|
|
28
28
|
return (...e) => (
|
|
29
29
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
30
|
-
e.reduce((r, n) =>
|
|
30
|
+
e.reduce((r, n) => S(r, n, "", t), {})
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
const A = X();
|
|
@@ -38,7 +38,7 @@ const Y = (t) => {
|
|
|
38
38
|
if (!k)
|
|
39
39
|
throw new Error("Api client not initialized. Call setApiClient() first.");
|
|
40
40
|
return k;
|
|
41
|
-
},
|
|
41
|
+
}, qt = () => k;
|
|
42
42
|
function j(t) {
|
|
43
43
|
for (let e = 0; e < t.length; e++)
|
|
44
44
|
if (t[e] instanceof File)
|
|
@@ -69,8 +69,8 @@ function J(t, e, r, n, i) {
|
|
|
69
69
|
if (h instanceof Array && j(h)) {
|
|
70
70
|
s[o][l] = new F(l);
|
|
71
71
|
let _ = 0;
|
|
72
|
-
h.forEach((
|
|
73
|
-
|
|
72
|
+
h.forEach((g) => {
|
|
73
|
+
g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
|
|
74
74
|
}), e[l] = "[Upload!]!";
|
|
75
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);
|
|
@@ -86,7 +86,7 @@ const y = async (t) => {
|
|
|
86
86
|
const f = {}, a = {};
|
|
87
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 =
|
|
89
|
+
const c = q({ 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 y = async (t) => {
|
|
|
95
95
|
throw new Error(s.data.errors[0].message);
|
|
96
96
|
return s.data.data;
|
|
97
97
|
};
|
|
98
|
-
function
|
|
98
|
+
function C(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 {
|
|
@@ -142,7 +142,7 @@ function U(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, _,
|
|
145
|
+
const l = (h, _, g) => {
|
|
146
146
|
const O = {
|
|
147
147
|
">": "_gt",
|
|
148
148
|
"<": "_lt",
|
|
@@ -152,7 +152,7 @@ function U(t, e) {
|
|
|
152
152
|
in: "_in",
|
|
153
153
|
contains: "_contains"
|
|
154
154
|
}[_];
|
|
155
|
-
O && n.push({ [h]: { [O]:
|
|
155
|
+
O && n.push({ [h]: { [O]: g } });
|
|
156
156
|
};
|
|
157
157
|
if (c !== void 0)
|
|
158
158
|
l(s, String(o), c);
|
|
@@ -204,26 +204,26 @@ function U(t, e) {
|
|
|
204
204
|
const _ = A(
|
|
205
205
|
i ? { sort: i } : {},
|
|
206
206
|
o ? { filters: o } : {}
|
|
207
|
-
),
|
|
207
|
+
), g = {
|
|
208
208
|
data: {
|
|
209
209
|
...e
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
|
-
if (r && (
|
|
212
|
+
if (r && (g.data.__args = r), Object.keys(_).length > 0 && (g.__args = _), s && (g.meta = {
|
|
213
213
|
total: !0,
|
|
214
214
|
key: !0,
|
|
215
215
|
name: !0
|
|
216
216
|
}), f) {
|
|
217
217
|
const w = f.split(".");
|
|
218
|
-
let O =
|
|
219
|
-
for (let
|
|
218
|
+
let O = g;
|
|
219
|
+
for (let P = w.length - 1; P >= 0; P--)
|
|
220
220
|
O = {
|
|
221
|
-
[w[
|
|
221
|
+
[w[P]]: O
|
|
222
222
|
};
|
|
223
223
|
return O;
|
|
224
224
|
}
|
|
225
225
|
return {
|
|
226
|
-
[`list${t}`]:
|
|
226
|
+
[`list${t}`]: g
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
};
|
|
@@ -280,7 +280,7 @@ const L = (t, e) => {
|
|
|
280
280
|
return u;
|
|
281
281
|
},
|
|
282
282
|
async get(a, u) {
|
|
283
|
-
const s = (await Promise.resolve().then(() =>
|
|
283
|
+
const s = (await Promise.resolve().then(() => Et)).default, o = s(r, kt(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 L = (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 =
|
|
294
|
+
const o = C(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(([
|
|
301
|
-
w.format && typeof w.format == "function" && (_[
|
|
300
|
+
return Object.entries(s).forEach(([g, w]) => {
|
|
301
|
+
w.format && typeof w.format == "function" && (_[g] = w.format(h));
|
|
302
302
|
}), _;
|
|
303
303
|
});
|
|
304
304
|
},
|
|
@@ -306,14 +306,14 @@ const L = (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(([
|
|
310
|
-
w.format && typeof w.format == "function" && (_[
|
|
309
|
+
return Object.entries(s).forEach(([g, w]) => {
|
|
310
|
+
w.format && typeof w.format == "function" && (_[g] = w.format(h));
|
|
311
311
|
}), _;
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
|
-
}, b = {},
|
|
316
|
+
}, b = {}, v = (t = !1) => {
|
|
317
317
|
const e = {};
|
|
318
318
|
return {
|
|
319
319
|
/**
|
|
@@ -356,8 +356,8 @@ const L = (t, e) => {
|
|
|
356
356
|
Object.keys(e).forEach((r) => delete e[r]);
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
|
-
},
|
|
360
|
-
const t =
|
|
359
|
+
}, Nt = () => {
|
|
360
|
+
const t = v(!1);
|
|
361
361
|
return {
|
|
362
362
|
// 暴露完整的管理器
|
|
363
363
|
manager: t,
|
|
@@ -386,8 +386,8 @@ const L = (t, e) => {
|
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
|
-
},
|
|
390
|
-
const t =
|
|
389
|
+
}, Bt = () => {
|
|
390
|
+
const t = v(!0);
|
|
391
391
|
return {
|
|
392
392
|
// 暴露完整的管理器
|
|
393
393
|
manager: t,
|
|
@@ -416,7 +416,7 @@ const L = (t, e) => {
|
|
|
416
416
|
});
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
|
-
},
|
|
419
|
+
}, Jt = () => ({
|
|
420
420
|
/**
|
|
421
421
|
* 創建全域模型
|
|
422
422
|
* @param name 模型名稱
|
|
@@ -455,7 +455,7 @@ const L = (t, e) => {
|
|
|
455
455
|
clear() {
|
|
456
456
|
Object.keys(b).forEach((t) => delete b[t]);
|
|
457
457
|
}
|
|
458
|
-
}),
|
|
458
|
+
}), Lt = () => y({
|
|
459
459
|
app: {
|
|
460
460
|
permissions: !0
|
|
461
461
|
}
|
|
@@ -481,14 +481,18 @@ const L = (t, e) => {
|
|
|
481
481
|
const t = await Q();
|
|
482
482
|
return await p({
|
|
483
483
|
webAuthnAssertion: {
|
|
484
|
-
|
|
484
|
+
__args: {
|
|
485
|
+
assertion: t.toJSON()
|
|
486
|
+
}
|
|
485
487
|
}
|
|
486
488
|
}).then((e) => e.webAuthnAssertion);
|
|
487
489
|
}, V = async () => {
|
|
488
490
|
const t = await T();
|
|
489
491
|
return await p({
|
|
490
492
|
webAuthnRegister: {
|
|
491
|
-
|
|
493
|
+
__args: {
|
|
494
|
+
registration: t.toJSON()
|
|
495
|
+
}
|
|
492
496
|
}
|
|
493
497
|
}).then((e) => e.webAuthnRegister);
|
|
494
498
|
}, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
@@ -497,7 +501,15 @@ const L = (t, e) => {
|
|
|
497
501
|
attestation: T,
|
|
498
502
|
login: Z,
|
|
499
503
|
register: V
|
|
500
|
-
}, Symbol.toStringTag, { value: "Module" })), I = (t =
|
|
504
|
+
}, Symbol.toStringTag, { value: "Module" })), I = (t = W) => y({ my: t }).then((e) => e.my), x = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((n) => n.login), tt = () => p({ logout: !0 }).then((t) => t.logout), et = (t, e, r) => p({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((n) => n.changeExpiredPassword), rt = (t, e) => p({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), st = (t, e, r) => p({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((n) => n.resetPassword), nt = (t, e) => p({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), ot = (t, e) => p({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), it = (t) => y({
|
|
505
|
+
my: {
|
|
506
|
+
granted: {
|
|
507
|
+
__args: {
|
|
508
|
+
right: t
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}).then((e) => e.my.granted), at = (t) => y({
|
|
501
513
|
my: {
|
|
502
514
|
grantedRights: {
|
|
503
515
|
__args: {
|
|
@@ -505,7 +517,7 @@ const L = (t, e) => {
|
|
|
505
517
|
}
|
|
506
518
|
}
|
|
507
519
|
}
|
|
508
|
-
}).then((e) => e.my.grantedRights),
|
|
520
|
+
}).then((e) => e.my.grantedRights), ct = () => ({
|
|
509
521
|
getCurrentUser: I,
|
|
510
522
|
webAuthn: K,
|
|
511
523
|
google: {
|
|
@@ -530,14 +542,15 @@ const L = (t, e) => {
|
|
|
530
542
|
resetPassword: st,
|
|
531
543
|
forgetPassword: nt,
|
|
532
544
|
verifyCode: ot,
|
|
533
|
-
|
|
545
|
+
grantedRights: at,
|
|
546
|
+
isGranted: it
|
|
534
547
|
}), $ = {
|
|
535
548
|
name: !0,
|
|
536
549
|
path: !0,
|
|
537
550
|
size: !0,
|
|
538
551
|
mime: !0,
|
|
539
552
|
url: !0
|
|
540
|
-
},
|
|
553
|
+
}, lt = (t, e, r = $) => y({
|
|
541
554
|
app: {
|
|
542
555
|
drive: {
|
|
543
556
|
__args: { index: t },
|
|
@@ -547,8 +560,22 @@ const L = (t, e) => {
|
|
|
547
560
|
}
|
|
548
561
|
}
|
|
549
562
|
}
|
|
550
|
-
}).then((n) => n.app.drive.files),
|
|
551
|
-
|
|
563
|
+
}).then((n) => n.app.drive.files), ut = (t, e) => y({
|
|
564
|
+
app: {
|
|
565
|
+
drive: {
|
|
566
|
+
__args: {
|
|
567
|
+
index: t
|
|
568
|
+
},
|
|
569
|
+
file: {
|
|
570
|
+
__args: {
|
|
571
|
+
path: e
|
|
572
|
+
},
|
|
573
|
+
base64Content: !0
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}).then((r) => r.app.drive?.file?.base64Content), m = (t) => ({
|
|
578
|
+
list: (e, r = $) => lt(t, e, r),
|
|
552
579
|
get: (e, r = {
|
|
553
580
|
name: !0,
|
|
554
581
|
path: !0,
|
|
@@ -570,6 +597,9 @@ const L = (t, e) => {
|
|
|
570
597
|
}
|
|
571
598
|
}
|
|
572
599
|
}).then((n) => n.app.drive.file),
|
|
600
|
+
readFileAsBase64(e) {
|
|
601
|
+
return ut(t, e);
|
|
602
|
+
},
|
|
573
603
|
read: async (e) => {
|
|
574
604
|
let r = await y({
|
|
575
605
|
app: {
|
|
@@ -594,10 +624,10 @@ const L = (t, e) => {
|
|
|
594
624
|
delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
|
|
595
625
|
rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
|
|
596
626
|
move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((n) => n.lightDriveMoveFile)
|
|
597
|
-
}),
|
|
627
|
+
}), G = {
|
|
598
628
|
name: !0,
|
|
599
629
|
path: !0
|
|
600
|
-
},
|
|
630
|
+
}, ht = (t, e, r = G) => y({
|
|
601
631
|
app: {
|
|
602
632
|
drive: {
|
|
603
633
|
__args: { index: t },
|
|
@@ -608,18 +638,18 @@ const L = (t, e) => {
|
|
|
608
638
|
}
|
|
609
639
|
}
|
|
610
640
|
}).then((n) => n.app.drive.folders), D = (t) => ({
|
|
611
|
-
list: (e, r =
|
|
641
|
+
list: (e, r = G) => ht(t, e, r),
|
|
612
642
|
create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
|
|
613
643
|
delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
|
|
614
644
|
rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
|
|
615
|
-
}),
|
|
645
|
+
}), Qt = () => y({
|
|
616
646
|
app: {
|
|
617
647
|
drives: {
|
|
618
648
|
index: !0,
|
|
619
649
|
name: !0
|
|
620
650
|
}
|
|
621
651
|
}
|
|
622
|
-
}).then((t) => t.app.drives),
|
|
652
|
+
}).then((t) => t.app.drives), ft = (t) => ({
|
|
623
653
|
listFiles: m(t).list,
|
|
624
654
|
getFile: m(t).get,
|
|
625
655
|
readFile: m(t).read,
|
|
@@ -642,30 +672,30 @@ const L = (t, e) => {
|
|
|
642
672
|
}).then((r) => r.lightDriveUploadTempFile),
|
|
643
673
|
folders: D(t),
|
|
644
674
|
files: m(t)
|
|
645
|
-
}),
|
|
675
|
+
}), W = {
|
|
646
676
|
user_id: !0,
|
|
647
677
|
username: !0,
|
|
648
678
|
first_name: !0,
|
|
649
679
|
last_name: !0,
|
|
650
680
|
status: !0
|
|
651
|
-
},
|
|
681
|
+
}, pt = (t) => p({
|
|
652
682
|
addUser: {
|
|
653
683
|
__args: t
|
|
654
684
|
}
|
|
655
|
-
}).then((e) => e.addUser),
|
|
685
|
+
}).then((e) => e.addUser), gt = (t) => p({
|
|
656
686
|
deleteUser: {
|
|
657
687
|
__args: { id: t }
|
|
658
688
|
}
|
|
659
|
-
}).then((e) => e.deleteUser),
|
|
689
|
+
}).then((e) => e.deleteUser), dt = (t = W) => C("Users", t).dataPath("app.listUser").fetch(), _t = (t, e) => p({
|
|
660
690
|
updateUser: {
|
|
661
691
|
__args: { id: t, data: e }
|
|
662
692
|
}
|
|
663
|
-
}).then((r) => r.updateUser),
|
|
664
|
-
list:
|
|
665
|
-
create:
|
|
666
|
-
delete:
|
|
667
|
-
update:
|
|
668
|
-
}),
|
|
693
|
+
}).then((r) => r.updateUser), yt = () => ({
|
|
694
|
+
list: dt,
|
|
695
|
+
create: pt,
|
|
696
|
+
delete: gt,
|
|
697
|
+
update: _t
|
|
698
|
+
}), wt = (t) => y({
|
|
669
699
|
app: {
|
|
670
700
|
listConfig: {
|
|
671
701
|
__args: {
|
|
@@ -679,13 +709,13 @@ const L = (t, e) => {
|
|
|
679
709
|
}
|
|
680
710
|
}
|
|
681
711
|
}
|
|
682
|
-
}).then((e) => e.app.listConfig.data[0]?.value),
|
|
712
|
+
}).then((e) => e.app.listConfig.data[0]?.value), bt = {
|
|
683
713
|
name: !0
|
|
684
|
-
},
|
|
714
|
+
}, mt = (t = bt) => y({
|
|
685
715
|
app: {
|
|
686
716
|
roles: t
|
|
687
717
|
}
|
|
688
|
-
}).then((e) => e.app.roles),
|
|
718
|
+
}).then((e) => e.app.roles), Ft = (t, e) => p({
|
|
689
719
|
addRole: {
|
|
690
720
|
__args: {
|
|
691
721
|
data: {
|
|
@@ -694,14 +724,14 @@ const L = (t, e) => {
|
|
|
694
724
|
}
|
|
695
725
|
}
|
|
696
726
|
}
|
|
697
|
-
}).then((r) => r.addRole),
|
|
727
|
+
}).then((r) => r.addRole), At = (t) => p({
|
|
698
728
|
deleteRole: {
|
|
699
729
|
__args: { name: t }
|
|
700
730
|
}
|
|
701
|
-
}).then((e) => e.deleteRole),
|
|
702
|
-
list:
|
|
703
|
-
create:
|
|
704
|
-
delete:
|
|
731
|
+
}).then((e) => e.deleteRole), Ot = () => ({
|
|
732
|
+
list: mt,
|
|
733
|
+
create: Ft,
|
|
734
|
+
delete: At
|
|
705
735
|
});
|
|
706
736
|
function z(t, e, r, n, i) {
|
|
707
737
|
if (!(!t || typeof t != "object"))
|
|
@@ -721,8 +751,8 @@ function z(t, e, r, n, i) {
|
|
|
721
751
|
if (h instanceof Array && j(h)) {
|
|
722
752
|
s[o][l] = new F(l);
|
|
723
753
|
let _ = 0;
|
|
724
|
-
h.forEach((
|
|
725
|
-
|
|
754
|
+
h.forEach((g) => {
|
|
755
|
+
g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
|
|
726
756
|
}), e[l] = "[Upload!]!";
|
|
727
757
|
} 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;
|
|
728
758
|
})) : c != null && (s[o] = c);
|
|
@@ -738,7 +768,7 @@ const p = async (t) => {
|
|
|
738
768
|
const a = {}, u = {};
|
|
739
769
|
z(n, a, u, i, { current: 0 }), f = Object.keys(a).length > 0, f && (n.__variables = a);
|
|
740
770
|
let o = null;
|
|
741
|
-
const l =
|
|
771
|
+
const l = q({ mutation: n });
|
|
742
772
|
if (f ? (i.append("map", JSON.stringify(u)), i.append("operations", JSON.stringify({
|
|
743
773
|
query: l
|
|
744
774
|
})), o = await r.post("", i)) : o = await r.post("", {
|
|
@@ -746,12 +776,12 @@ const p = async (t) => {
|
|
|
746
776
|
}), o.data.errors)
|
|
747
777
|
throw new Error(o.data.errors[0].message);
|
|
748
778
|
return o.data.data;
|
|
749
|
-
},
|
|
750
|
-
send:
|
|
751
|
-
},
|
|
779
|
+
}, Dt = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), jt = {
|
|
780
|
+
send: Dt
|
|
781
|
+
}, U = (t) => {
|
|
752
782
|
let e = {};
|
|
753
783
|
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
754
|
-
Object.entries(
|
|
784
|
+
Object.entries(U(r)).forEach(([n, i]) => {
|
|
755
785
|
e[n] = i;
|
|
756
786
|
});
|
|
757
787
|
}), e) : (Object.entries(t).forEach(([r, n]) => {
|
|
@@ -763,9 +793,9 @@ const p = async (t) => {
|
|
|
763
793
|
e[r] = n;
|
|
764
794
|
return;
|
|
765
795
|
}
|
|
766
|
-
e[r] =
|
|
796
|
+
e[r] = U(n);
|
|
767
797
|
}), e);
|
|
768
|
-
},
|
|
798
|
+
}, kt = (t) => U(t), Ct = "list", Pt = [
|
|
769
799
|
"flatMap",
|
|
770
800
|
"chunk",
|
|
771
801
|
"shuffle",
|
|
@@ -791,7 +821,7 @@ const p = async (t) => {
|
|
|
791
821
|
"slice",
|
|
792
822
|
"tap",
|
|
793
823
|
"sort"
|
|
794
|
-
],
|
|
824
|
+
], Mt = [
|
|
795
825
|
"avg",
|
|
796
826
|
"count",
|
|
797
827
|
"countBy",
|
|
@@ -819,7 +849,7 @@ const p = async (t) => {
|
|
|
819
849
|
"implode",
|
|
820
850
|
"partition"
|
|
821
851
|
];
|
|
822
|
-
class
|
|
852
|
+
class d {
|
|
823
853
|
_batchData = null;
|
|
824
854
|
data_path = "";
|
|
825
855
|
filters;
|
|
@@ -836,7 +866,7 @@ class g {
|
|
|
836
866
|
this.filters = {}, this.steps = [], this.fields = e;
|
|
837
867
|
}
|
|
838
868
|
}
|
|
839
|
-
|
|
869
|
+
d.prototype.getQueryPayload = function() {
|
|
840
870
|
let t = {
|
|
841
871
|
meta: {
|
|
842
872
|
total: !0,
|
|
@@ -850,26 +880,26 @@ g.prototype.getQueryPayload = function() {
|
|
|
850
880
|
steps: this.steps
|
|
851
881
|
};
|
|
852
882
|
};
|
|
853
|
-
|
|
883
|
+
d.prototype.dataPath = function(t) {
|
|
854
884
|
const e = this.clone();
|
|
855
885
|
return e.data_path = t, e;
|
|
856
886
|
};
|
|
857
|
-
|
|
887
|
+
d.prototype.buildArgs = function() {
|
|
858
888
|
let t = {};
|
|
859
889
|
return Object.keys(this.filters).length > 0 && (t.filters = this.filters), this._sort && (t.sort = this._sort, this._sortDesc && (t.sort += ":desc")), t;
|
|
860
890
|
};
|
|
861
|
-
|
|
891
|
+
d.prototype.clone = function() {
|
|
862
892
|
const t = Object.create(this);
|
|
863
893
|
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;
|
|
864
894
|
};
|
|
865
|
-
|
|
895
|
+
E().macro("whereContains", function(t, e) {
|
|
866
896
|
return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
|
|
867
897
|
});
|
|
868
|
-
|
|
898
|
+
d.prototype.fetchData = async function() {
|
|
869
899
|
try {
|
|
870
900
|
if (this._batchData) {
|
|
871
901
|
const u = this._batchData;
|
|
872
|
-
return this.meta = u.meta,
|
|
902
|
+
return this.meta = u.meta, E(u.data);
|
|
873
903
|
}
|
|
874
904
|
let t = {
|
|
875
905
|
meta: {
|
|
@@ -891,37 +921,37 @@ g.prototype.fetchData = async function() {
|
|
|
891
921
|
let a = await y(r);
|
|
892
922
|
for (const u of e)
|
|
893
923
|
a = a[u];
|
|
894
|
-
return this.meta = a.meta,
|
|
924
|
+
return this.meta = a.meta, E(a.data);
|
|
895
925
|
} catch (t) {
|
|
896
926
|
throw console.error("Error fetching collection data:", t), t;
|
|
897
927
|
}
|
|
898
928
|
};
|
|
899
|
-
|
|
929
|
+
d.prototype.processData = async function() {
|
|
900
930
|
let t = await this.fetchData();
|
|
901
931
|
for (const e of this.steps)
|
|
902
932
|
t = t[e.type](...e.args);
|
|
903
933
|
return t;
|
|
904
934
|
};
|
|
905
|
-
|
|
935
|
+
d.prototype.all = async function() {
|
|
906
936
|
return (await this.processData()).all();
|
|
907
937
|
};
|
|
908
|
-
for (const t of
|
|
909
|
-
|
|
938
|
+
for (const t of Pt)
|
|
939
|
+
d.prototype[t] = function(...e) {
|
|
910
940
|
const r = this.clone();
|
|
911
941
|
return r.steps.push({ type: t, args: e }), r;
|
|
912
942
|
};
|
|
913
|
-
for (const t of
|
|
914
|
-
|
|
943
|
+
for (const t of Mt)
|
|
944
|
+
d.prototype[t] = async function(...e) {
|
|
915
945
|
return (await this.clone().processData())[t](...e);
|
|
916
946
|
};
|
|
917
|
-
|
|
918
|
-
|
|
947
|
+
d.prototype.average = d.prototype.avg;
|
|
948
|
+
d.prototype.first = async function() {
|
|
919
949
|
return this.take(1), (await this.processData()).first();
|
|
920
950
|
};
|
|
921
|
-
|
|
951
|
+
d.prototype._handleBatchData = function(t, e) {
|
|
922
952
|
return this._batchData ? (this.steps.push({ type: t, args: e }), this) : null;
|
|
923
953
|
};
|
|
924
|
-
|
|
954
|
+
d.prototype.where = function(...t) {
|
|
925
955
|
const e = this._handleBatchData("where", t);
|
|
926
956
|
if (e) return e;
|
|
927
957
|
if (t.length === 2)
|
|
@@ -953,55 +983,55 @@ g.prototype.where = function(...t) {
|
|
|
953
983
|
}
|
|
954
984
|
return this;
|
|
955
985
|
};
|
|
956
|
-
|
|
986
|
+
d.prototype.whereContains = function(t, e) {
|
|
957
987
|
const r = this._handleBatchData("whereContains", [t, e]);
|
|
958
988
|
return r || (this.filters[t] = { contains: e }, this);
|
|
959
989
|
};
|
|
960
|
-
|
|
990
|
+
d.prototype.forPage = function(t, e) {
|
|
961
991
|
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);
|
|
962
992
|
};
|
|
963
|
-
|
|
993
|
+
d.prototype.whereIn = function(t, e) {
|
|
964
994
|
const r = this._handleBatchData("whereIn", [t, e]);
|
|
965
995
|
return r || (this.filters[t] = { in: e }, this);
|
|
966
996
|
};
|
|
967
|
-
|
|
997
|
+
d.prototype.whereNotIn = function(t, e) {
|
|
968
998
|
const r = this._handleBatchData("whereNotIn", [t, e]);
|
|
969
999
|
return r || (this.filters[t] = { nin: e }, this);
|
|
970
1000
|
};
|
|
971
|
-
|
|
1001
|
+
d.prototype.whereNotBetween = function(t, e) {
|
|
972
1002
|
const r = this._handleBatchData("whereNotBetween", [t, e]);
|
|
973
1003
|
return r || (this.filters[t] = { notBetween: e }, this);
|
|
974
1004
|
};
|
|
975
|
-
|
|
1005
|
+
d.prototype.whereBetween = function(t, e) {
|
|
976
1006
|
const r = this._handleBatchData("whereBetween", [t, e]);
|
|
977
1007
|
return r || (this.filters[t] = { between: e }, this);
|
|
978
1008
|
};
|
|
979
|
-
|
|
1009
|
+
d.prototype.sortBy = function(t) {
|
|
980
1010
|
return this.steps.push({ type: "sortBy", args: [t] }), typeof t == "string" && (this._sort = t), this;
|
|
981
1011
|
};
|
|
982
|
-
|
|
1012
|
+
d.prototype.sortByDesc = function(t) {
|
|
983
1013
|
return this.steps.push({ type: "sortByDesc", args: [t] }), typeof t == "string" && (this._sort = t, this._sortDesc = !0), this;
|
|
984
1014
|
};
|
|
985
|
-
|
|
1015
|
+
d.prototype.skip = function(t) {
|
|
986
1016
|
if (t < 0)
|
|
987
1017
|
throw new Error("Offset must be non-negative");
|
|
988
1018
|
return this.already_offset && this.steps.push({ type: "skip", args: [t] }), this.offset = t, this.already_offset = !0, this;
|
|
989
1019
|
};
|
|
990
|
-
|
|
1020
|
+
d.prototype.take = function(t) {
|
|
991
1021
|
if (t < 0)
|
|
992
1022
|
throw new Error("Length must be non-negative");
|
|
993
1023
|
return this.already_limit ? (this.steps.push({ type: "take", args: [t] }), this) : (this.limit = t, this.already_limit = !0, this);
|
|
994
1024
|
};
|
|
995
|
-
|
|
1025
|
+
d.prototype.splice = function(t, e) {
|
|
996
1026
|
return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
|
|
997
1027
|
};
|
|
998
1028
|
const R = (t, e) => {
|
|
999
|
-
const r = new
|
|
1000
|
-
return r.data_path =
|
|
1001
|
-
},
|
|
1029
|
+
const r = new d(e);
|
|
1030
|
+
return r.data_path = Ct + t, r;
|
|
1031
|
+
}, Et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1002
1032
|
__proto__: null,
|
|
1003
1033
|
default: R
|
|
1004
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
1034
|
+
}, Symbol.toStringTag, { value: "Module" })), Tt = (t) => {
|
|
1005
1035
|
const e = typeof window > "u";
|
|
1006
1036
|
let r = [];
|
|
1007
1037
|
const n = H.create({
|
|
@@ -1021,40 +1051,40 @@ const R = (t, e) => {
|
|
|
1021
1051
|
}
|
|
1022
1052
|
return a;
|
|
1023
1053
|
}));
|
|
1024
|
-
const i =
|
|
1054
|
+
const i = v(), f = {
|
|
1025
1055
|
post: n.post,
|
|
1026
1056
|
baseURL: t,
|
|
1027
1057
|
axios: n,
|
|
1028
|
-
auth:
|
|
1058
|
+
auth: ct(),
|
|
1029
1059
|
mutation: p,
|
|
1030
1060
|
query: y,
|
|
1031
|
-
config:
|
|
1032
|
-
mail:
|
|
1033
|
-
users:
|
|
1061
|
+
config: wt,
|
|
1062
|
+
mail: jt,
|
|
1063
|
+
users: yt(),
|
|
1034
1064
|
models: i,
|
|
1035
1065
|
model(a) {
|
|
1036
1066
|
return i.get(a);
|
|
1037
1067
|
},
|
|
1038
|
-
roles:
|
|
1068
|
+
roles: Ot(),
|
|
1039
1069
|
collect: (a, u) => {
|
|
1040
1070
|
const s = R(a, u);
|
|
1041
1071
|
return s.data_path = i.get(a).getDataPath(), s;
|
|
1042
1072
|
},
|
|
1043
|
-
list: (a, u) =>
|
|
1044
|
-
drive:
|
|
1073
|
+
list: (a, u) => C(a, u).dataPath(i.get(a).getDataPath()),
|
|
1074
|
+
drive: ft,
|
|
1045
1075
|
async collects(a) {
|
|
1046
1076
|
const u = {}, s = {};
|
|
1047
1077
|
for (const c in a) {
|
|
1048
1078
|
const l = a[c].getQueryPayload();
|
|
1049
1079
|
s[c] = l.data_path, u[c] = {};
|
|
1050
1080
|
const h = l.data_path.split(".");
|
|
1051
|
-
let _ = h[h.length - 1],
|
|
1081
|
+
let _ = h[h.length - 1], g = u[c];
|
|
1052
1082
|
for (const w of h) {
|
|
1053
1083
|
if (w === _) {
|
|
1054
|
-
|
|
1084
|
+
g[w] = l.query;
|
|
1055
1085
|
break;
|
|
1056
1086
|
}
|
|
1057
|
-
|
|
1087
|
+
g[w] = g[w] || {};
|
|
1058
1088
|
}
|
|
1059
1089
|
u[c].__aliasFor = h[0];
|
|
1060
1090
|
}
|
|
@@ -1062,56 +1092,60 @@ const R = (t, e) => {
|
|
|
1062
1092
|
for (const c in a) {
|
|
1063
1093
|
const l = s[c].split(".");
|
|
1064
1094
|
let h = l[l.length - 1], _ = o[c];
|
|
1065
|
-
for (const
|
|
1066
|
-
if (
|
|
1067
|
-
a[c]._batchData = o[c][
|
|
1095
|
+
for (const g of l) {
|
|
1096
|
+
if (g === h) {
|
|
1097
|
+
a[c]._batchData = o[c][g];
|
|
1068
1098
|
break;
|
|
1069
1099
|
}
|
|
1070
|
-
_[
|
|
1100
|
+
_[g] = _[g] || {};
|
|
1071
1101
|
}
|
|
1072
1102
|
}
|
|
1073
1103
|
return a;
|
|
1074
1104
|
}
|
|
1075
1105
|
};
|
|
1076
1106
|
return Y(f), f;
|
|
1077
|
-
};
|
|
1107
|
+
}, $t = C;
|
|
1078
1108
|
export {
|
|
1079
|
-
|
|
1109
|
+
ct as auth,
|
|
1080
1110
|
et as changeExpiredPassword,
|
|
1081
|
-
|
|
1111
|
+
Tt as createClient,
|
|
1082
1112
|
R as createCollection,
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1113
|
+
C as createList,
|
|
1114
|
+
v as createModelManager,
|
|
1115
|
+
Ft as createRole,
|
|
1116
|
+
pt as createUser,
|
|
1117
|
+
W as defaultUserFields,
|
|
1118
|
+
At as deleteRole,
|
|
1119
|
+
gt as deleteUser,
|
|
1090
1120
|
nt as forgetPassword,
|
|
1091
1121
|
N as getApiClient,
|
|
1092
|
-
|
|
1093
|
-
|
|
1122
|
+
qt as getApiClientOptional,
|
|
1123
|
+
wt as getConfig,
|
|
1094
1124
|
I as getCurrentUser,
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1125
|
+
ft as getDrive,
|
|
1126
|
+
at as getGrantedRights,
|
|
1127
|
+
it as isGranted,
|
|
1128
|
+
$t as list,
|
|
1129
|
+
Qt as listDrives,
|
|
1130
|
+
lt as listFiles,
|
|
1131
|
+
ht as listFolders,
|
|
1132
|
+
Lt as listPermissions,
|
|
1133
|
+
mt as listRoles,
|
|
1134
|
+
dt as listUsers,
|
|
1102
1135
|
x as login,
|
|
1103
1136
|
tt as logout,
|
|
1104
1137
|
p as mutation,
|
|
1105
1138
|
y as query,
|
|
1139
|
+
ut as readFileAsBase64,
|
|
1106
1140
|
st as resetPassword,
|
|
1107
|
-
|
|
1141
|
+
Dt as sendMail,
|
|
1108
1142
|
Y as setApiClient,
|
|
1109
|
-
|
|
1143
|
+
kt as toQuery,
|
|
1110
1144
|
rt as updatePassword,
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1145
|
+
_t as updateUser,
|
|
1146
|
+
Bt as useGlobalModel,
|
|
1147
|
+
Jt as useGlobalModels,
|
|
1148
|
+
Nt as useModel,
|
|
1115
1149
|
ot as verifyCode,
|
|
1116
1150
|
K as webAuthn
|
|
1117
1151
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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"})}));
|
|
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,bt,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 mt(t){return(...e)=>e.reduce((r,n)=>S(r,n,"",t),{})}const A=mt();let M=null;const L=t=>{M=t},v=()=>{if(!M)throw new Error("Api client not initialized. Call setApiClient() first.");return M},Ft=()=>M;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 P(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 R=(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(()=>qt)).default,i=s(r,wt(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=P(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=R(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])}}},At=()=>{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)})}}},Ot=()=>{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)})}}},Dt=()=>({define(t,e){const r=R(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])}}),Ct=()=>w({app:{permissions:!0}}).then(t=>t.app.permissions),W=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})},z=async()=>{const{app:t}=await w({app:{auth:{webAuthnCreationOptions:!0}}}),e=PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);return await navigator.credentials.create({publicKey:e})},G=Object.freeze(Object.defineProperty({__proto__:null,assertion:W,attestation:z,login:async()=>{const t=await W();return await d({webAuthnAssertion:{__args:{assertion:t.toJSON()}}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await z();return await d({webAuthnRegister:{__args:{registration:t.toJSON()}}}).then(e=>e.webAuthnRegister)}},Symbol.toStringTag,{value:"Module"})),Q=(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:{granted:{__args:{right:t}}}}).then(e=>e.my.granted),tt=t=>w({my:{grantedRights:{__args:{rights:t}}}}).then(e=>e.my.grantedRights),et=()=>({getCurrentUser:Q,webAuthn:G,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,grantedRights:tt,isGranted:x}),rt={name:!0,path:!0,size:!0,mime:!0,url:!0},st=(t,e,r=rt)=>w({app:{drive:{__args:{index:t},files:{__args:{path:e},...r}}}}).then(n=>n.app.drive.files),nt=(t,e)=>w({app:{drive:{__args:{index:t},file:{__args:{path:e},base64Content:!0}}}}).then(r=>r.app.drive?.file?.base64Content),O=t=>({list:(e,r=rt)=>st(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),readFileAsBase64(e){return nt(t,e)},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)}),it={name:!0,path:!0},ot=(t,e,r=it)=>w({app:{drive:{__args:{index:t},folders:{__args:{path:e},...r}}}}).then(n=>n.app.drive.folders),j=t=>({list:(e,r=it)=>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)}),Pt=()=>w({app:{drives:{index:!0,name:!0}}}).then(t=>t.app.drives),at=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:j(t).list,createFolder:j(t).create,deleteFolder:j(t).delete,renameFolder:j(t).rename,uploadTempFile:e=>d({lightDriveUploadTempFile:{__args:{index:t,file:e},name:!0,path:!0,size:!0,mime:!0}}).then(r=>r.lightDriveUploadTempFile),folders:j(t),files:O(t)}),q={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0},ct=t=>d({addUser:{__args:t}}).then(e=>e.addUser),lt=t=>d({deleteUser:{__args:{id:t}}}).then(e=>e.deleteUser),ut=(t=q)=>P("Users",t).dataPath("app.listUser").fetch(),ht=(t,e)=>d({updateUser:{__args:{id:t,data:e}}}).then(r=>r.updateUser),jt=()=>({list:ut,create:ct,delete:lt,update:ht}),ft=t=>w({app:{listConfig:{__args:{filters:{name:t}},data:{name:!0,value:!0}}}}).then(e=>e.app.listConfig.data[0]?.value),Mt={name:!0},pt=(t=Mt)=>w({app:{roles:t}}).then(e=>e.app.roles),dt=(t,e)=>d({addRole:{__args:{data:{name:t,childs:e}}}}).then(r=>r.addRole),gt=t=>d({deleteRole:{__args:{name:t}}}).then(e=>e.deleteRole),kt=()=>({list:pt,create:dt,delete:gt});function _t(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}_t(a,e,r,n,o)}}}const d=async t=>{const r=v().axios,n=t,o=new FormData;let p=!1;const a={},u={};_t(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},yt=(t,e,r)=>d({sendMail:{__args:{email:t,subject:e,message:r}}}).then(n=>n.sendMail),Ut={send:yt},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)},wt=t=>N(t),Et="list",St=["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"],vt=["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 St)g.prototype[t]=function(...e){const r=this.clone();return r.steps.push({type:t,args:e}),r};for(const t of vt)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=Et+t,r},qt=Object.freeze(Object.defineProperty({__proto__:null,default:B},Symbol.toStringTag,{value:"Module"})),Nt=t=>{const e=typeof window>"u";let r=[];const n=bt.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:et(),mutation:d,query:w,config:ft,mail:Ut,users:jt(),models:o,model(a){return o.get(a)},roles:kt(),collect:(a,u)=>{const s=B(a,u);return s.data_path=o.get(a).getDataPath(),s},list:(a,u)=>P(a,u).dataPath(o.get(a).getDataPath()),drive:at,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},Bt=P;h.auth=et,h.changeExpiredPassword=X,h.createClient=Nt,h.createCollection=B,h.createList=P,h.createModelManager=k,h.createRole=dt,h.createUser=ct,h.defaultUserFields=q,h.deleteRole=gt,h.deleteUser=lt,h.forgetPassword=K,h.getApiClient=v,h.getApiClientOptional=Ft,h.getConfig=ft,h.getCurrentUser=Q,h.getDrive=at,h.getGrantedRights=tt,h.isGranted=x,h.list=Bt,h.listDrives=Pt,h.listFiles=st,h.listFolders=ot,h.listPermissions=Ct,h.listRoles=pt,h.listUsers=ut,h.login=H,h.logout=V,h.mutation=d,h.query=w,h.readFileAsBase64=nt,h.resetPassword=Z,h.sendMail=yt,h.setApiClient=L,h.toQuery=wt,h.updatePassword=Y,h.updateUser=ht,h.useGlobalModel=Ot,h.useGlobalModels=Dt,h.useModel=At,h.verifyCode=I,h.webAuthn=G,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/mutation.d.ts
CHANGED
package/dist/query.d.ts
CHANGED