@hostlink/light 3.0.0 → 3.0.3
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 +7 -2
- package/dist/drive.d.ts +26 -7
- package/dist/file.d.ts +3 -0
- package/dist/folder.d.ts +13 -0
- package/dist/index.d.ts +9 -0
- package/dist/light.js +304 -237
- package/dist/light.umd.cjs +1 -1
- package/dist/permission.d.ts +5 -0
- package/dist/users.d.ts +15 -2
- package/package.json +1 -1
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>;
|
|
@@ -6,8 +8,10 @@ export declare const updatePassword: (oldPassword: string, newPassword: string)
|
|
|
6
8
|
export declare const resetPassword: (jwt: string, password: string, code: string) => Promise<boolean>;
|
|
7
9
|
export declare const forgetPassword: (username: string, email: string) => Promise<string>;
|
|
8
10
|
export declare const verifyCode: (jwt: string, code: string) => Promise<boolean>;
|
|
9
|
-
export declare const
|
|
11
|
+
export declare const isGranted: (right: string) => Promise<boolean>;
|
|
12
|
+
export declare const getGrantedRights: (rights: string[]) => Promise<string[]>;
|
|
10
13
|
declare const _default: () => {
|
|
14
|
+
getCurrentUser: (fields?: QueryUserFieldsUserFields) => Promise<any>;
|
|
11
15
|
webAuthn: typeof webAuthn;
|
|
12
16
|
google: {
|
|
13
17
|
unlink: () => Promise<boolean>;
|
|
@@ -31,6 +35,7 @@ declare const _default: () => {
|
|
|
31
35
|
resetPassword: (jwt: string, password: string, code: string) => Promise<boolean>;
|
|
32
36
|
forgetPassword: (username: string, email: string) => Promise<string>;
|
|
33
37
|
verifyCode: (jwt: string, code: string) => Promise<boolean>;
|
|
34
|
-
|
|
38
|
+
grantedRights: (rights: string[]) => Promise<string[]>;
|
|
39
|
+
isGranted: (right: string) => Promise<boolean>;
|
|
35
40
|
};
|
|
36
41
|
export default _default;
|
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<
|
|
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>;
|
|
@@ -20,6 +26,7 @@ export declare const getDrive: (index: number) => {
|
|
|
20
26
|
files: {
|
|
21
27
|
list: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
22
28
|
get: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
29
|
+
readFileAsBase64(path: string): Promise<string>;
|
|
23
30
|
read: (path: string) => Promise<any>;
|
|
24
31
|
write: (path: string, content: string) => Promise<any>;
|
|
25
32
|
delete: (path: string) => Promise<any>;
|
|
@@ -33,6 +40,17 @@ declare const _default: () => {
|
|
|
33
40
|
name: string;
|
|
34
41
|
}>>;
|
|
35
42
|
get: (index: number) => {
|
|
43
|
+
listFiles: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
44
|
+
getFile: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
45
|
+
readFile: (path: string) => Promise<any>;
|
|
46
|
+
writeFile: (path: string, content: string) => Promise<any>;
|
|
47
|
+
deleteFile: (path: string) => Promise<any>;
|
|
48
|
+
renameFile: (path: string, name: string) => Promise<any>;
|
|
49
|
+
moveFile: (source: string, destination: string) => Promise<any>;
|
|
50
|
+
listFolders: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<Record<keyof import('./folder').FolderFields, any>[]>;
|
|
51
|
+
createFolder: (path: string) => Promise<any>;
|
|
52
|
+
deleteFolder: (path: string) => Promise<any>;
|
|
53
|
+
renameFolder: (path: string, name: string) => Promise<any>;
|
|
36
54
|
uploadTempFile: (file: File) => Promise<{
|
|
37
55
|
name: string;
|
|
38
56
|
path: string;
|
|
@@ -40,7 +58,7 @@ declare const _default: () => {
|
|
|
40
58
|
mime: string;
|
|
41
59
|
}>;
|
|
42
60
|
folders: {
|
|
43
|
-
list: (path: string, fields?: QueryFolderFields) => Promise<
|
|
61
|
+
list: (path: string, fields?: import('./folder').QueryFolderFields) => Promise<Record<keyof import('./folder').FolderFields, any>[]>;
|
|
44
62
|
create: (path: string) => Promise<any>;
|
|
45
63
|
delete: (path: string) => Promise<any>;
|
|
46
64
|
rename: (path: string, name: string) => Promise<any>;
|
|
@@ -48,6 +66,7 @@ declare const _default: () => {
|
|
|
48
66
|
files: {
|
|
49
67
|
list: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
50
68
|
get: (path: string, fields?: import('./file').QueryFileFields) => Promise<any>;
|
|
69
|
+
readFileAsBase64(path: string): Promise<string>;
|
|
51
70
|
read: (path: string) => Promise<any>;
|
|
52
71
|
write: (path: string, content: string) => Promise<any>;
|
|
53
72
|
delete: (path: string) => Promise<any>;
|
package/dist/file.d.ts
CHANGED
|
@@ -6,9 +6,12 @@ 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>;
|
|
10
|
+
export declare const readFileAsBase64: (index: number, path: string) => Promise<string>;
|
|
9
11
|
declare const _default: (index: number) => {
|
|
10
12
|
list: (path: string, fields?: QueryFileFields) => Promise<any>;
|
|
11
13
|
get: (path: string, fields?: QueryFileFields) => Promise<any>;
|
|
14
|
+
readFileAsBase64(path: string): Promise<string>;
|
|
12
15
|
read: (path: string) => Promise<any>;
|
|
13
16
|
write: (path: string, content: string) => Promise<any>;
|
|
14
17
|
delete: (path: string) => Promise<any>;
|
package/dist/folder.d.ts
ADDED
|
@@ -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,18 @@
|
|
|
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';
|
|
4
|
+
export * from './permission';
|
|
3
5
|
export * as webAuthn from './webauthn';
|
|
4
6
|
export * from './auth';
|
|
7
|
+
export { default as auth } from './auth';
|
|
5
8
|
export * from './drive';
|
|
9
|
+
export * from './folder';
|
|
10
|
+
export * from './users';
|
|
11
|
+
export * from './config';
|
|
12
|
+
export * from './role';
|
|
6
13
|
export * from './model';
|
|
7
14
|
export * from './file';
|
|
15
|
+
export * from './mail';
|
|
8
16
|
export { default as query } from './query';
|
|
9
17
|
export { default as mutation } from './mutation';
|
|
10
18
|
export { default as toQuery } from './toQuery';
|
|
@@ -13,5 +21,6 @@ export { default as createClient } from './createClient';
|
|
|
13
21
|
export type { LightClient } from './createClient';
|
|
14
22
|
export { default as createCollection } from './createCollection';
|
|
15
23
|
export { default as createList } from './createList';
|
|
24
|
+
export declare const list: typeof createList;
|
|
16
25
|
export type { RoleFields } from './role';
|
|
17
26
|
export { setApiClient, getApiClient, getApiClientOptional } from './apiClient';
|
package/dist/light.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { jsonToGraphQLQuery as q, VariableType as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
function
|
|
1
|
+
import { jsonToGraphQLQuery as q, VariableType as F } from "json-to-graphql-query";
|
|
2
|
+
import H from "axios";
|
|
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(),
|
|
@@ -24,34 +24,34 @@ function P(t, e, r = ".", n) {
|
|
|
24
24
|
}
|
|
25
25
|
return i;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
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
|
-
const A =
|
|
34
|
-
let
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
if (!
|
|
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
|
|
41
|
-
},
|
|
42
|
-
function
|
|
40
|
+
return k;
|
|
41
|
+
}, qt = () => 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
|
|
48
|
+
function B(t) {
|
|
49
49
|
for (let e in t)
|
|
50
|
-
if (t[e] instanceof File || t[e] instanceof Array &&
|
|
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
|
|
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,32 +59,32 @@ 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 &&
|
|
63
|
-
s[o] = new
|
|
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
|
|
69
|
-
if (h instanceof Array &&
|
|
70
|
-
s[o][l] = new
|
|
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
72
|
h.forEach((g) => {
|
|
73
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
|
-
} else h instanceof File ? (s[o][l] = new
|
|
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
|
-
|
|
79
|
+
J(a, e, r, n, i);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
const e =
|
|
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
|
-
|
|
87
|
+
J(r, f, a, n, { current: 0 }), i = Object.keys(f).length > 0, i && (r.__variables = f);
|
|
88
88
|
let s = null;
|
|
89
89
|
const c = q({ query: r });
|
|
90
90
|
if (i ? (n.append("map", JSON.stringify(a)), n.append("operations", JSON.stringify({
|
|
@@ -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
|
|
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 {
|
|
@@ -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
|
|
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
|
|
123
|
+
let o = await y(this.toQuery());
|
|
124
124
|
if (f) {
|
|
125
125
|
const c = f.split(".");
|
|
126
126
|
for (const l of c)
|
|
@@ -143,7 +143,7 @@ function E(t, e) {
|
|
|
143
143
|
// where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
|
|
144
144
|
where(s, o, c) {
|
|
145
145
|
const l = (h, _, g) => {
|
|
146
|
-
const
|
|
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
|
-
|
|
155
|
+
O && n.push({ [h]: { [O]: g } });
|
|
156
156
|
};
|
|
157
157
|
if (c !== void 0)
|
|
158
158
|
l(s, String(o), c);
|
|
@@ -214,13 +214,13 @@ function E(t, e) {
|
|
|
214
214
|
key: !0,
|
|
215
215
|
name: !0
|
|
216
216
|
}), f) {
|
|
217
|
-
const
|
|
218
|
-
let
|
|
219
|
-
for (let
|
|
220
|
-
|
|
221
|
-
[
|
|
217
|
+
const w = f.split(".");
|
|
218
|
+
let O = g;
|
|
219
|
+
for (let P = w.length - 1; P >= 0; P--)
|
|
220
|
+
O = {
|
|
221
|
+
[w[P]]: O
|
|
222
222
|
};
|
|
223
|
-
return
|
|
223
|
+
return O;
|
|
224
224
|
}
|
|
225
225
|
return {
|
|
226
226
|
[`list${t}`]: g
|
|
@@ -228,7 +228,7 @@ function E(t, e) {
|
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
|
-
const
|
|
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(() =>
|
|
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 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 =
|
|
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(([g,
|
|
301
|
-
|
|
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 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,
|
|
310
|
-
|
|
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
|
/**
|
|
@@ -322,7 +322,7 @@ const B = (t, e) => {
|
|
|
322
322
|
* @param fields 模型欄位定義
|
|
323
323
|
*/
|
|
324
324
|
create(r, n) {
|
|
325
|
-
const i =
|
|
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
|
-
},
|
|
360
|
-
const t =
|
|
359
|
+
}, Nt = () => {
|
|
360
|
+
const t = v(!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
|
-
},
|
|
390
|
-
const t =
|
|
389
|
+
}, Bt = () => {
|
|
390
|
+
const t = v(!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
|
-
},
|
|
419
|
+
}, Jt = () => ({
|
|
420
420
|
/**
|
|
421
421
|
* 創建全域模型
|
|
422
422
|
* @param name 模型名稱
|
|
423
423
|
* @param fields 模型欄位定義
|
|
424
424
|
*/
|
|
425
425
|
define(t, e) {
|
|
426
|
-
const r =
|
|
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
|
-
}),
|
|
459
|
-
|
|
458
|
+
}), Lt = () => 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
|
-
},
|
|
468
|
-
const { app: t } = await
|
|
471
|
+
}, T = async () => {
|
|
472
|
+
const { app: t } = await y({
|
|
469
473
|
app: {
|
|
470
474
|
auth: {
|
|
471
475
|
webAuthnCreationOptions: !0
|
|
@@ -473,27 +477,35 @@ const B = (t, e) => {
|
|
|
473
477
|
}
|
|
474
478
|
}), e = PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);
|
|
475
479
|
return await navigator.credentials.create({ publicKey: e });
|
|
476
|
-
},
|
|
477
|
-
const t = await
|
|
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
|
-
},
|
|
484
|
-
const t = await
|
|
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
|
-
},
|
|
494
|
+
}, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
491
495
|
__proto__: null,
|
|
492
|
-
assertion:
|
|
493
|
-
attestation:
|
|
494
|
-
login:
|
|
495
|
-
register:
|
|
496
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
496
|
+
assertion: Q,
|
|
497
|
+
attestation: T,
|
|
498
|
+
login: Z,
|
|
499
|
+
register: V
|
|
500
|
+
}, 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({
|
|
501
|
+
my: {
|
|
502
|
+
granted: {
|
|
503
|
+
__args: {
|
|
504
|
+
right: t
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}).then((e) => e.my.granted), at = (t) => y({
|
|
497
509
|
my: {
|
|
498
510
|
grantedRights: {
|
|
499
511
|
__args: {
|
|
@@ -501,8 +513,9 @@ const B = (t, e) => {
|
|
|
501
513
|
}
|
|
502
514
|
}
|
|
503
515
|
}
|
|
504
|
-
}).then((e) => e.my.grantedRights),
|
|
505
|
-
|
|
516
|
+
}).then((e) => e.my.grantedRights), ct = () => ({
|
|
517
|
+
getCurrentUser: I,
|
|
518
|
+
webAuthn: K,
|
|
506
519
|
google: {
|
|
507
520
|
unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
|
|
508
521
|
login: (t) => p({ lightAuthLoginGoogle: { __args: { credential: t } } }).then((e) => e.lightAuthLoginGoogle),
|
|
@@ -518,39 +531,54 @@ const B = (t, e) => {
|
|
|
518
531
|
login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
|
|
519
532
|
register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
|
|
520
533
|
},
|
|
521
|
-
login:
|
|
522
|
-
logout:
|
|
523
|
-
changeExpiredPassword:
|
|
524
|
-
updatePassword:
|
|
525
|
-
resetPassword:
|
|
526
|
-
forgetPassword:
|
|
527
|
-
verifyCode:
|
|
528
|
-
|
|
529
|
-
|
|
534
|
+
login: x,
|
|
535
|
+
logout: tt,
|
|
536
|
+
changeExpiredPassword: et,
|
|
537
|
+
updatePassword: rt,
|
|
538
|
+
resetPassword: st,
|
|
539
|
+
forgetPassword: nt,
|
|
540
|
+
verifyCode: ot,
|
|
541
|
+
grantedRights: at,
|
|
542
|
+
isGranted: it
|
|
543
|
+
}), $ = {
|
|
530
544
|
name: !0,
|
|
531
545
|
path: !0,
|
|
532
546
|
size: !0,
|
|
533
547
|
mime: !0,
|
|
534
548
|
url: !0
|
|
535
|
-
},
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
...r
|
|
543
|
-
}
|
|
549
|
+
}, lt = (t, e, r = $) => y({
|
|
550
|
+
app: {
|
|
551
|
+
drive: {
|
|
552
|
+
__args: { index: t },
|
|
553
|
+
files: {
|
|
554
|
+
__args: { path: e },
|
|
555
|
+
...r
|
|
544
556
|
}
|
|
545
557
|
}
|
|
546
|
-
}
|
|
558
|
+
}
|
|
559
|
+
}).then((n) => n.app.drive.files), ut = (t, e) => y({
|
|
560
|
+
app: {
|
|
561
|
+
drive: {
|
|
562
|
+
__args: {
|
|
563
|
+
index: t
|
|
564
|
+
},
|
|
565
|
+
file: {
|
|
566
|
+
__args: {
|
|
567
|
+
path: e
|
|
568
|
+
},
|
|
569
|
+
base64Content: !0
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}).then((r) => r.app.drive?.file?.base64Content), m = (t) => ({
|
|
574
|
+
list: (e, r = $) => lt(t, e, r),
|
|
547
575
|
get: (e, r = {
|
|
548
576
|
name: !0,
|
|
549
577
|
path: !0,
|
|
550
578
|
size: !0,
|
|
551
579
|
mime: !0,
|
|
552
580
|
url: !0
|
|
553
|
-
}) =>
|
|
581
|
+
}) => y({
|
|
554
582
|
app: {
|
|
555
583
|
drive: {
|
|
556
584
|
__args: {
|
|
@@ -565,8 +593,11 @@ const B = (t, e) => {
|
|
|
565
593
|
}
|
|
566
594
|
}
|
|
567
595
|
}).then((n) => n.app.drive.file),
|
|
596
|
+
readFileAsBase64(e) {
|
|
597
|
+
return ut(t, e);
|
|
598
|
+
},
|
|
568
599
|
read: async (e) => {
|
|
569
|
-
let r = await
|
|
600
|
+
let r = await y({
|
|
570
601
|
app: {
|
|
571
602
|
drive: {
|
|
572
603
|
__args: {
|
|
@@ -589,14 +620,43 @@ const B = (t, e) => {
|
|
|
589
620
|
delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
|
|
590
621
|
rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFile),
|
|
591
622
|
move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((n) => n.lightDriveMoveFile)
|
|
592
|
-
}),
|
|
623
|
+
}), G = {
|
|
624
|
+
name: !0,
|
|
625
|
+
path: !0
|
|
626
|
+
}, ht = (t, e, r = G) => y({
|
|
627
|
+
app: {
|
|
628
|
+
drive: {
|
|
629
|
+
__args: { index: t },
|
|
630
|
+
folders: {
|
|
631
|
+
__args: { path: e },
|
|
632
|
+
...r
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}).then((n) => n.app.drive.folders), D = (t) => ({
|
|
637
|
+
list: (e, r = G) => ht(t, e, r),
|
|
638
|
+
create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
|
|
639
|
+
delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
|
|
640
|
+
rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((n) => n.lightDriveRenameFolder)
|
|
641
|
+
}), Qt = () => y({
|
|
593
642
|
app: {
|
|
594
643
|
drives: {
|
|
595
644
|
index: !0,
|
|
596
645
|
name: !0
|
|
597
646
|
}
|
|
598
647
|
}
|
|
599
|
-
}).then((t) => t.app.drives),
|
|
648
|
+
}).then((t) => t.app.drives), ft = (t) => ({
|
|
649
|
+
listFiles: m(t).list,
|
|
650
|
+
getFile: m(t).get,
|
|
651
|
+
readFile: m(t).read,
|
|
652
|
+
writeFile: m(t).write,
|
|
653
|
+
deleteFile: m(t).delete,
|
|
654
|
+
renameFile: m(t).rename,
|
|
655
|
+
moveFile: m(t).move,
|
|
656
|
+
listFolders: D(t).list,
|
|
657
|
+
createFolder: D(t).create,
|
|
658
|
+
deleteFolder: D(t).delete,
|
|
659
|
+
renameFolder: D(t).rename,
|
|
600
660
|
uploadTempFile: (e) => p({
|
|
601
661
|
lightDriveUploadTempFile: {
|
|
602
662
|
__args: { index: t, file: e },
|
|
@@ -606,25 +666,70 @@ const B = (t, e) => {
|
|
|
606
666
|
mime: !0
|
|
607
667
|
}
|
|
608
668
|
}).then((r) => r.lightDriveUploadTempFile),
|
|
609
|
-
folders:
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
669
|
+
folders: D(t),
|
|
670
|
+
files: m(t)
|
|
671
|
+
}), W = {
|
|
672
|
+
user_id: !0,
|
|
673
|
+
username: !0,
|
|
674
|
+
first_name: !0,
|
|
675
|
+
last_name: !0,
|
|
676
|
+
status: !0
|
|
677
|
+
}, pt = (t) => p({
|
|
678
|
+
addUser: {
|
|
679
|
+
__args: t
|
|
680
|
+
}
|
|
681
|
+
}).then((e) => e.addUser), gt = (t) => p({
|
|
682
|
+
deleteUser: {
|
|
683
|
+
__args: { id: t }
|
|
684
|
+
}
|
|
685
|
+
}).then((e) => e.deleteUser), dt = (t = W) => C("Users", t).dataPath("app.listUser").fetch(), _t = (t, e) => p({
|
|
686
|
+
updateUser: {
|
|
687
|
+
__args: { id: t, data: e }
|
|
688
|
+
}
|
|
689
|
+
}).then((r) => r.updateUser), yt = () => ({
|
|
690
|
+
list: dt,
|
|
691
|
+
create: pt,
|
|
692
|
+
delete: gt,
|
|
693
|
+
update: _t
|
|
694
|
+
}), wt = (t) => y({
|
|
695
|
+
app: {
|
|
696
|
+
listConfig: {
|
|
697
|
+
__args: {
|
|
698
|
+
filters: {
|
|
699
|
+
name: t
|
|
618
700
|
}
|
|
701
|
+
},
|
|
702
|
+
data: {
|
|
703
|
+
name: !0,
|
|
704
|
+
value: !0
|
|
619
705
|
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}).then((e) => e.app.listConfig.data[0]?.value), bt = {
|
|
709
|
+
name: !0
|
|
710
|
+
}, mt = (t = bt) => y({
|
|
711
|
+
app: {
|
|
712
|
+
roles: t
|
|
713
|
+
}
|
|
714
|
+
}).then((e) => e.app.roles), Ft = (t, e) => p({
|
|
715
|
+
addRole: {
|
|
716
|
+
__args: {
|
|
717
|
+
data: {
|
|
718
|
+
name: t,
|
|
719
|
+
childs: e
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}).then((r) => r.addRole), At = (t) => p({
|
|
724
|
+
deleteRole: {
|
|
725
|
+
__args: { name: t }
|
|
726
|
+
}
|
|
727
|
+
}).then((e) => e.deleteRole), Ot = () => ({
|
|
728
|
+
list: mt,
|
|
729
|
+
create: Ft,
|
|
730
|
+
delete: At
|
|
626
731
|
});
|
|
627
|
-
function
|
|
732
|
+
function z(t, e, r, n, i) {
|
|
628
733
|
if (!(!t || typeof t != "object"))
|
|
629
734
|
for (let f in t) {
|
|
630
735
|
const a = t[f];
|
|
@@ -632,32 +737,32 @@ function Q(t, e, r, n, i) {
|
|
|
632
737
|
if ("__args" in a) {
|
|
633
738
|
const u = a.__args, s = {};
|
|
634
739
|
Object.entries(u).forEach(([o, c]) => {
|
|
635
|
-
if (c instanceof Array &&
|
|
636
|
-
s[o] = new
|
|
740
|
+
if (c instanceof Array && j(c)) {
|
|
741
|
+
s[o] = new F(o);
|
|
637
742
|
let l = 0;
|
|
638
743
|
c.forEach((h) => {
|
|
639
744
|
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
745
|
}), e[o] = "[Upload!]!";
|
|
641
|
-
} else c instanceof File ? (s[o] = new
|
|
642
|
-
if (h instanceof Array &&
|
|
643
|
-
s[o][l] = new
|
|
746
|
+
} 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]) => {
|
|
747
|
+
if (h instanceof Array && j(h)) {
|
|
748
|
+
s[o][l] = new F(l);
|
|
644
749
|
let _ = 0;
|
|
645
750
|
h.forEach((g) => {
|
|
646
751
|
g instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + l + "." + _), n.append(i.current.toString(), g), i.current++, _++);
|
|
647
752
|
}), e[l] = "[Upload!]!";
|
|
648
|
-
} else h instanceof File ? (s[o][l] = new
|
|
753
|
+
} 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
754
|
})) : c != null && (s[o] = c);
|
|
650
755
|
}), a.__args = s;
|
|
651
756
|
}
|
|
652
|
-
|
|
757
|
+
z(a, e, r, n, i);
|
|
653
758
|
}
|
|
654
759
|
}
|
|
655
760
|
}
|
|
656
761
|
const p = async (t) => {
|
|
657
|
-
const r =
|
|
762
|
+
const r = N().axios, n = t, i = new FormData();
|
|
658
763
|
let f = !1;
|
|
659
764
|
const a = {}, u = {};
|
|
660
|
-
|
|
765
|
+
z(n, a, u, i, { current: 0 }), f = Object.keys(a).length > 0, f && (n.__variables = a);
|
|
661
766
|
let o = null;
|
|
662
767
|
const l = q({ mutation: n });
|
|
663
768
|
if (f ? (i.append("map", JSON.stringify(u)), i.append("operations", JSON.stringify({
|
|
@@ -667,10 +772,12 @@ const p = async (t) => {
|
|
|
667
772
|
}), o.data.errors)
|
|
668
773
|
throw new Error(o.data.errors[0].message);
|
|
669
774
|
return o.data.data;
|
|
670
|
-
},
|
|
775
|
+
}, Dt = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((n) => n.sendMail), jt = {
|
|
776
|
+
send: Dt
|
|
777
|
+
}, U = (t) => {
|
|
671
778
|
let e = {};
|
|
672
779
|
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
673
|
-
Object.entries(
|
|
780
|
+
Object.entries(U(r)).forEach(([n, i]) => {
|
|
674
781
|
e[n] = i;
|
|
675
782
|
});
|
|
676
783
|
}), e) : (Object.entries(t).forEach(([r, n]) => {
|
|
@@ -682,48 +789,9 @@ const p = async (t) => {
|
|
|
682
789
|
e[r] = n;
|
|
683
790
|
return;
|
|
684
791
|
}
|
|
685
|
-
e[r] =
|
|
792
|
+
e[r] = U(n);
|
|
686
793
|
}), e);
|
|
687
|
-
},
|
|
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 = [
|
|
794
|
+
}, kt = (t) => U(t), Ct = "list", Pt = [
|
|
727
795
|
"flatMap",
|
|
728
796
|
"chunk",
|
|
729
797
|
"shuffle",
|
|
@@ -749,7 +817,7 @@ const p = async (t) => {
|
|
|
749
817
|
"slice",
|
|
750
818
|
"tap",
|
|
751
819
|
"sort"
|
|
752
|
-
],
|
|
820
|
+
], Mt = [
|
|
753
821
|
"avg",
|
|
754
822
|
"count",
|
|
755
823
|
"countBy",
|
|
@@ -820,14 +888,14 @@ d.prototype.clone = function() {
|
|
|
820
888
|
const t = Object.create(this);
|
|
821
889
|
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
890
|
};
|
|
823
|
-
|
|
891
|
+
E().macro("whereContains", function(t, e) {
|
|
824
892
|
return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
|
|
825
893
|
});
|
|
826
894
|
d.prototype.fetchData = async function() {
|
|
827
895
|
try {
|
|
828
896
|
if (this._batchData) {
|
|
829
897
|
const u = this._batchData;
|
|
830
|
-
return this.meta = u.meta,
|
|
898
|
+
return this.meta = u.meta, E(u.data);
|
|
831
899
|
}
|
|
832
900
|
let t = {
|
|
833
901
|
meta: {
|
|
@@ -846,10 +914,10 @@ d.prototype.fetchData = async function() {
|
|
|
846
914
|
}
|
|
847
915
|
n[u] = {}, n = n[u];
|
|
848
916
|
}
|
|
849
|
-
let a = await
|
|
917
|
+
let a = await y(r);
|
|
850
918
|
for (const u of e)
|
|
851
919
|
a = a[u];
|
|
852
|
-
return this.meta = a.meta,
|
|
920
|
+
return this.meta = a.meta, E(a.data);
|
|
853
921
|
} catch (t) {
|
|
854
922
|
throw console.error("Error fetching collection data:", t), t;
|
|
855
923
|
}
|
|
@@ -863,12 +931,12 @@ d.prototype.processData = async function() {
|
|
|
863
931
|
d.prototype.all = async function() {
|
|
864
932
|
return (await this.processData()).all();
|
|
865
933
|
};
|
|
866
|
-
for (const t of
|
|
934
|
+
for (const t of Pt)
|
|
867
935
|
d.prototype[t] = function(...e) {
|
|
868
936
|
const r = this.clone();
|
|
869
937
|
return r.steps.push({ type: t, args: e }), r;
|
|
870
938
|
};
|
|
871
|
-
for (const t of
|
|
939
|
+
for (const t of Mt)
|
|
872
940
|
d.prototype[t] = async function(...e) {
|
|
873
941
|
return (await this.clone().processData())[t](...e);
|
|
874
942
|
};
|
|
@@ -953,35 +1021,16 @@ d.prototype.take = function(t) {
|
|
|
953
1021
|
d.prototype.splice = function(t, e) {
|
|
954
1022
|
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
1023
|
};
|
|
956
|
-
const
|
|
1024
|
+
const R = (t, e) => {
|
|
957
1025
|
const r = new d(e);
|
|
958
|
-
return r.data_path =
|
|
959
|
-
},
|
|
1026
|
+
return r.data_path = Ct + t, r;
|
|
1027
|
+
}, Et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
960
1028
|
__proto__: null,
|
|
961
|
-
default:
|
|
962
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
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) => {
|
|
1029
|
+
default: R
|
|
1030
|
+
}, Symbol.toStringTag, { value: "Module" })), Tt = (t) => {
|
|
982
1031
|
const e = typeof window > "u";
|
|
983
1032
|
let r = [];
|
|
984
|
-
const n =
|
|
1033
|
+
const n = H.create({
|
|
985
1034
|
baseURL: t,
|
|
986
1035
|
withCredentials: !0
|
|
987
1036
|
});
|
|
@@ -998,27 +1047,27 @@ const T = (t, e) => {
|
|
|
998
1047
|
}
|
|
999
1048
|
return a;
|
|
1000
1049
|
}));
|
|
1001
|
-
const i =
|
|
1050
|
+
const i = v(), f = {
|
|
1002
1051
|
post: n.post,
|
|
1003
1052
|
baseURL: t,
|
|
1004
1053
|
axios: n,
|
|
1005
|
-
auth:
|
|
1054
|
+
auth: ct(),
|
|
1006
1055
|
mutation: p,
|
|
1007
|
-
query:
|
|
1008
|
-
config:
|
|
1009
|
-
mail:
|
|
1010
|
-
users:
|
|
1056
|
+
query: y,
|
|
1057
|
+
config: wt,
|
|
1058
|
+
mail: jt,
|
|
1059
|
+
users: yt(),
|
|
1011
1060
|
models: i,
|
|
1012
1061
|
model(a) {
|
|
1013
1062
|
return i.get(a);
|
|
1014
1063
|
},
|
|
1015
|
-
roles:
|
|
1064
|
+
roles: Ot(),
|
|
1016
1065
|
collect: (a, u) => {
|
|
1017
|
-
const s =
|
|
1066
|
+
const s = R(a, u);
|
|
1018
1067
|
return s.data_path = i.get(a).getDataPath(), s;
|
|
1019
1068
|
},
|
|
1020
|
-
list: (a, u) =>
|
|
1021
|
-
drive:
|
|
1069
|
+
list: (a, u) => C(a, u).dataPath(i.get(a).getDataPath()),
|
|
1070
|
+
drive: ft,
|
|
1022
1071
|
async collects(a) {
|
|
1023
1072
|
const u = {}, s = {};
|
|
1024
1073
|
for (const c in a) {
|
|
@@ -1026,16 +1075,16 @@ const T = (t, e) => {
|
|
|
1026
1075
|
s[c] = l.data_path, u[c] = {};
|
|
1027
1076
|
const h = l.data_path.split(".");
|
|
1028
1077
|
let _ = h[h.length - 1], g = u[c];
|
|
1029
|
-
for (const
|
|
1030
|
-
if (
|
|
1031
|
-
g[
|
|
1078
|
+
for (const w of h) {
|
|
1079
|
+
if (w === _) {
|
|
1080
|
+
g[w] = l.query;
|
|
1032
1081
|
break;
|
|
1033
1082
|
}
|
|
1034
|
-
g[
|
|
1083
|
+
g[w] = g[w] || {};
|
|
1035
1084
|
}
|
|
1036
1085
|
u[c].__aliasFor = h[0];
|
|
1037
1086
|
}
|
|
1038
|
-
const o = await
|
|
1087
|
+
const o = await y(u);
|
|
1039
1088
|
for (const c in a) {
|
|
1040
1089
|
const l = s[c].split(".");
|
|
1041
1090
|
let h = l[l.length - 1], _ = o[c];
|
|
@@ -1050,31 +1099,49 @@ const T = (t, e) => {
|
|
|
1050
1099
|
return a;
|
|
1051
1100
|
}
|
|
1052
1101
|
};
|
|
1053
|
-
return
|
|
1054
|
-
};
|
|
1102
|
+
return Y(f), f;
|
|
1103
|
+
}, $t = C;
|
|
1055
1104
|
export {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1105
|
+
ct as auth,
|
|
1106
|
+
et as changeExpiredPassword,
|
|
1107
|
+
Tt as createClient,
|
|
1108
|
+
R as createCollection,
|
|
1109
|
+
C as createList,
|
|
1110
|
+
v as createModelManager,
|
|
1111
|
+
Ft as createRole,
|
|
1112
|
+
pt as createUser,
|
|
1113
|
+
W as defaultUserFields,
|
|
1114
|
+
At as deleteRole,
|
|
1115
|
+
gt as deleteUser,
|
|
1116
|
+
nt as forgetPassword,
|
|
1117
|
+
N as getApiClient,
|
|
1118
|
+
qt as getApiClientOptional,
|
|
1119
|
+
wt as getConfig,
|
|
1120
|
+
I as getCurrentUser,
|
|
1121
|
+
ft as getDrive,
|
|
1122
|
+
at as getGrantedRights,
|
|
1123
|
+
it as isGranted,
|
|
1124
|
+
$t as list,
|
|
1125
|
+
Qt as listDrives,
|
|
1126
|
+
lt as listFiles,
|
|
1127
|
+
ht as listFolders,
|
|
1128
|
+
Lt as listPermissions,
|
|
1129
|
+
mt as listRoles,
|
|
1130
|
+
dt as listUsers,
|
|
1131
|
+
x as login,
|
|
1132
|
+
tt as logout,
|
|
1069
1133
|
p as mutation,
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1134
|
+
y as query,
|
|
1135
|
+
ut as readFileAsBase64,
|
|
1136
|
+
st as resetPassword,
|
|
1137
|
+
Dt as sendMail,
|
|
1138
|
+
Y as setApiClient,
|
|
1139
|
+
kt as toQuery,
|
|
1140
|
+
rt as updatePassword,
|
|
1141
|
+
_t as updateUser,
|
|
1142
|
+
Bt as useGlobalModel,
|
|
1143
|
+
Jt as useGlobalModels,
|
|
1144
|
+
Nt as useModel,
|
|
1145
|
+
ot as verifyCode,
|
|
1146
|
+
K as webAuthn
|
|
1080
1147
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -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,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:{assertion:t.toJSON()}}).then(e=>e.webAuthnAssertion)},register:async()=>{const t=await z();return await d({webAuthnRegister:{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/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:
|
|
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;
|