@hostlink/light 1.0.1 → 1.1.0
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/file.d.ts +26 -0
- package/dist/fs.d.ts +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/light.js +329 -224
- package/dist/light.umd.cjs +1 -1
- package/dist/model.d.ts +23 -0
- package/dist/mutation.d.ts +4 -1
- package/dist/mutation.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/file.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const file: (s?: string) => {
|
|
2
|
+
getContent: () => string;
|
|
3
|
+
getURL: (mime?: string) => string;
|
|
4
|
+
download: (filename: string) => void;
|
|
5
|
+
open: (mime: string) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const File: {
|
|
8
|
+
fromBase85: (a: string) => {
|
|
9
|
+
getContent: () => string;
|
|
10
|
+
getURL: (mime?: string) => string;
|
|
11
|
+
download: (filename: string) => void;
|
|
12
|
+
open: (mime: string) => void;
|
|
13
|
+
};
|
|
14
|
+
fromBase64: (a: string) => {
|
|
15
|
+
getContent: () => string;
|
|
16
|
+
getURL: (mime?: string) => string;
|
|
17
|
+
download: (filename: string) => void;
|
|
18
|
+
open: (mime: string) => void;
|
|
19
|
+
};
|
|
20
|
+
fromString: (a: string) => {
|
|
21
|
+
getContent: () => string;
|
|
22
|
+
getURL: (mime?: string) => string;
|
|
23
|
+
download: (filename: string) => void;
|
|
24
|
+
open: (mime: string) => void;
|
|
25
|
+
};
|
|
26
|
+
};
|
package/dist/fs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type FSFile = {
|
|
2
2
|
name: string;
|
|
3
3
|
path: string;
|
|
4
4
|
size: number;
|
|
@@ -6,12 +6,12 @@ export type File = {
|
|
|
6
6
|
canPreview: boolean;
|
|
7
7
|
imagePath: string;
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
9
|
+
export type FSFolder = {
|
|
10
10
|
name: String;
|
|
11
11
|
path: String;
|
|
12
12
|
};
|
|
13
13
|
export declare const fsListFiles: (path: string) => Promise<Array<File>>;
|
|
14
|
-
export declare const fsListFolders: (path: string) => Promise<Array<
|
|
14
|
+
export declare const fsListFolders: (path: string) => Promise<Array<FSFolder>>;
|
|
15
15
|
export declare const fsReadFile: (path: string) => Promise<string>;
|
|
16
16
|
export declare const fsWriteFile: (path: string, content: string) => Promise<boolean>;
|
|
17
17
|
export declare const fsDeleteFile: (path: string) => Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
package/dist/light.js
CHANGED
|
@@ -1,111 +1,212 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
1
|
+
import U from "axios";
|
|
2
|
+
import { VariableType as R, jsonToGraphQLQuery as v } from "json-to-graphql-query";
|
|
3
|
+
const X = (e, t, r = "") => u("login", {
|
|
4
4
|
username: e,
|
|
5
5
|
password: t,
|
|
6
6
|
code: r
|
|
7
|
-
}),
|
|
7
|
+
}), Y = () => u("logout"), Z = (e, t) => u("updatePassword", {
|
|
8
8
|
old_password: e,
|
|
9
9
|
new_password: t
|
|
10
|
-
}),
|
|
10
|
+
}), k = (e, t, r) => u("resetPassword", {
|
|
11
11
|
email: e,
|
|
12
12
|
password: t,
|
|
13
13
|
code: r
|
|
14
|
-
}),
|
|
14
|
+
}), ee = (e) => u("forgetPassword", {
|
|
15
15
|
email: e
|
|
16
16
|
});
|
|
17
|
-
let
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
},
|
|
17
|
+
let h;
|
|
18
|
+
const te = (e) => {
|
|
19
|
+
h = e;
|
|
20
|
+
}, b = () => (h || (h = U.create({
|
|
21
21
|
withCredentials: !0
|
|
22
|
-
})),
|
|
22
|
+
})), h), re = async (e) => (await p({
|
|
23
23
|
granted: {
|
|
24
24
|
__args: {
|
|
25
25
|
rights: e
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
})).granted,
|
|
29
|
-
|
|
28
|
+
})).granted, m = {}, ne = (e, t) => {
|
|
29
|
+
m[e] = {};
|
|
30
30
|
for (const r of Object.entries(t)) {
|
|
31
|
-
const [
|
|
32
|
-
|
|
33
|
-
name:
|
|
34
|
-
raw:
|
|
35
|
-
getName: () =>
|
|
36
|
-
getGQLField: () =>
|
|
31
|
+
const [s, n] = r;
|
|
32
|
+
m[e][s] = () => ({
|
|
33
|
+
name: n.name ? n.name : s,
|
|
34
|
+
raw: n,
|
|
35
|
+
getName: () => n.name ? n.name : s,
|
|
36
|
+
getGQLField: () => n.gqlField !== void 0 ? n.gqlField : n.name || s,
|
|
37
37
|
getRaw() {
|
|
38
|
-
return
|
|
38
|
+
return n;
|
|
39
39
|
},
|
|
40
|
-
getValue(
|
|
41
|
-
return
|
|
40
|
+
getValue(a) {
|
|
41
|
+
return n.field && typeof n.field == "function" ? n.field(a) : n.field && typeof n.field == "string" ? a[n.field] : a[this.getName()];
|
|
42
42
|
},
|
|
43
|
-
getFormattedValue(
|
|
44
|
-
const
|
|
45
|
-
return
|
|
43
|
+
getFormattedValue(a) {
|
|
44
|
+
const c = this.getValue(a);
|
|
45
|
+
return n.format ? n.format(c) : c;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
}, q = (e, t) => !
|
|
49
|
+
}, q = (e, t) => !m[e] || !m[e][t] ? null : m[e][t](), se = (e, t) => {
|
|
50
50
|
const r = [];
|
|
51
|
-
for (const
|
|
52
|
-
if (typeof
|
|
53
|
-
const
|
|
54
|
-
|
|
51
|
+
for (const s of t)
|
|
52
|
+
if (typeof s == "string") {
|
|
53
|
+
const n = q(e, s);
|
|
54
|
+
n && r.push(n.getGQLField());
|
|
55
55
|
} else
|
|
56
|
-
typeof
|
|
56
|
+
typeof s == "object" && r.push(s);
|
|
57
57
|
return r;
|
|
58
|
-
},
|
|
58
|
+
}, S = (e) => {
|
|
59
|
+
const t = new FormData(), r = {}, s = {}, n = {};
|
|
60
|
+
let a = 0, c = !1;
|
|
61
|
+
return Object.entries(e).forEach(([d, g]) => {
|
|
62
|
+
g instanceof File ? (c = !0, s[d] = "Upload!", n[d] = new R(d), t.append(a.toString(), g), r[a] = ["variables." + d], a++) : n[d] = g;
|
|
63
|
+
}), c ? (t.append("map", JSON.stringify(r)), {
|
|
64
|
+
data: n,
|
|
65
|
+
formData: t,
|
|
66
|
+
mutation: {
|
|
67
|
+
__variables: s
|
|
68
|
+
}
|
|
69
|
+
}) : {
|
|
70
|
+
data: n,
|
|
71
|
+
formData: null,
|
|
72
|
+
mutation: {}
|
|
73
|
+
};
|
|
74
|
+
}, ae = (e) => {
|
|
75
|
+
const t = e;
|
|
76
|
+
return {
|
|
77
|
+
name: t,
|
|
78
|
+
async update(r, s) {
|
|
79
|
+
const n = S(s);
|
|
80
|
+
return await u("update" + t, { id: r, data: n.data }, [], n.mutation, n.formData);
|
|
81
|
+
},
|
|
82
|
+
async delete(r) {
|
|
83
|
+
return await u("delete" + t, { id: r });
|
|
84
|
+
},
|
|
85
|
+
async add(r) {
|
|
86
|
+
const s = S(r);
|
|
87
|
+
return await u("add" + t, { data: s.data }, [], s.mutation, s.formData);
|
|
88
|
+
},
|
|
89
|
+
fields(r) {
|
|
90
|
+
let s = [];
|
|
91
|
+
for (let n of r) {
|
|
92
|
+
const a = q(t, n);
|
|
93
|
+
a && s.push(a);
|
|
94
|
+
}
|
|
95
|
+
return s;
|
|
96
|
+
},
|
|
97
|
+
async get(r, s) {
|
|
98
|
+
return (await p({
|
|
99
|
+
["list" + t]: {
|
|
100
|
+
__args: {
|
|
101
|
+
filters: r
|
|
102
|
+
},
|
|
103
|
+
data: {
|
|
104
|
+
__args: {
|
|
105
|
+
limit: 1
|
|
106
|
+
},
|
|
107
|
+
...y(s)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}))["list" + t].data[0];
|
|
111
|
+
},
|
|
112
|
+
async list(r, s) {
|
|
113
|
+
return (await p({
|
|
114
|
+
["list" + t]: {
|
|
115
|
+
__args: {
|
|
116
|
+
filters: r
|
|
117
|
+
},
|
|
118
|
+
data: {
|
|
119
|
+
...y(s)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}))["list" + t].data;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
function P(e) {
|
|
127
|
+
e = "<~" + e + "~>";
|
|
128
|
+
var t, r, s, n, a, c = String, d = 255;
|
|
129
|
+
for (e.slice(0, 2) === "<~" && e.slice(-2), e = e.slice(2, -2).replace(/\s/g, "").replace("z", "!!!!!"), t = "uuuuu".slice(e.length % 5 || 5), e += t, s = [], n = 0, a = e.length; a > n; n += 5)
|
|
130
|
+
r = 52200625 * (e.charCodeAt(n) - 33) + 614125 * (e.charCodeAt(n + 1) - 33) + 7225 * (e.charCodeAt(n + 2) - 33) + 85 * (e.charCodeAt(n + 3) - 33) + (e.charCodeAt(n + 4) - 33), s.push(d & r >> 24, d & r >> 16, d & r >> 8, d & r);
|
|
131
|
+
return function(g, L) {
|
|
132
|
+
for (var O = L; O > 0; O--)
|
|
133
|
+
g.pop();
|
|
134
|
+
}(s, t.length), c.fromCharCode.apply(c, s);
|
|
135
|
+
}
|
|
136
|
+
const F = (e = "") => {
|
|
137
|
+
const t = e, r = (s = "application/octet-stream") => {
|
|
138
|
+
const n = new Uint8Array(t.length);
|
|
139
|
+
for (let d = 0; d < t.length; d++)
|
|
140
|
+
n[d] = t.charCodeAt(d);
|
|
141
|
+
const a = new Blob([n], { type: s });
|
|
142
|
+
return URL.createObjectURL(a);
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
getContent: () => t,
|
|
146
|
+
getURL: r,
|
|
147
|
+
download: (s) => {
|
|
148
|
+
const n = document.createElement("a");
|
|
149
|
+
n.download = s, n.href = r(), document.body.appendChild(n), n.click(), document.body.removeChild(n);
|
|
150
|
+
},
|
|
151
|
+
open: (s) => {
|
|
152
|
+
window.open(r(s), "_blank");
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}, oe = {
|
|
156
|
+
fromBase85: (e) => F(P(e)),
|
|
157
|
+
fromBase64: (e) => F(atob(e)),
|
|
158
|
+
fromString: (e) => F(e)
|
|
159
|
+
}, C = (e) => {
|
|
59
160
|
let t = {};
|
|
60
161
|
return typeof e == "string" ? (t[e] = !0, t) : e instanceof Array ? (e.forEach((r) => {
|
|
61
|
-
Object.entries(
|
|
62
|
-
t[
|
|
162
|
+
Object.entries(C(r)).forEach(([s, n]) => {
|
|
163
|
+
t[s] = n;
|
|
63
164
|
});
|
|
64
|
-
}), t) : (Object.entries(e).forEach(([r,
|
|
165
|
+
}), t) : (Object.entries(e).forEach(([r, s]) => {
|
|
65
166
|
if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
|
|
66
|
-
t[r] =
|
|
167
|
+
t[r] = s;
|
|
67
168
|
return;
|
|
68
169
|
}
|
|
69
|
-
if (typeof
|
|
70
|
-
t[r] =
|
|
170
|
+
if (typeof s == "boolean") {
|
|
171
|
+
t[r] = s;
|
|
71
172
|
return;
|
|
72
173
|
}
|
|
73
|
-
t[r] =
|
|
174
|
+
t[r] = C(s);
|
|
74
175
|
}), t);
|
|
75
|
-
},
|
|
76
|
-
let t =
|
|
77
|
-
const r = await
|
|
176
|
+
}, y = (e) => C(e), p = async (e) => {
|
|
177
|
+
let t = v(y(e));
|
|
178
|
+
const r = await b().post(_(), {
|
|
78
179
|
query: `{ ${t} }`
|
|
79
180
|
});
|
|
80
181
|
if (r.data.errors)
|
|
81
182
|
throw new Error(r.data.errors[0].message);
|
|
82
183
|
return r.data.data;
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
n.mutation[e] = !0, r instanceof Array && r.length != 0 && (n.mutation[e] = {}), t && (n.mutation[e] = {}, n.mutation[e].__args = t), Object.entries(F(r)).forEach(([u, f]) => {
|
|
88
|
-
n.mutation[e][u] = f;
|
|
184
|
+
}, u = async (e, t = null, r = [], s = {}, n = null) => {
|
|
185
|
+
s[e] = !0, r instanceof Array && r.length != 0 && (s[e] = {}), t && (s[e] = {}, s[e].__args = t), Object.entries(y(r)).forEach(([d, g]) => {
|
|
186
|
+
s[e][d] = g;
|
|
89
187
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
188
|
+
let a = null;
|
|
189
|
+
const c = v({ mutation: s });
|
|
190
|
+
if (n ? (n.append("operations", JSON.stringify({
|
|
191
|
+
query: c
|
|
192
|
+
})), a = await b().post(_(), n)) : a = await b().post(_(), {
|
|
193
|
+
query: c
|
|
194
|
+
}), a.data.errors)
|
|
195
|
+
throw new Error(a.data.errors[0].message);
|
|
196
|
+
return a.data.data[e];
|
|
96
197
|
};
|
|
97
|
-
let
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
}, _ = () =>
|
|
101
|
-
async function
|
|
198
|
+
let E = "/api/";
|
|
199
|
+
const ie = (e) => {
|
|
200
|
+
E = e;
|
|
201
|
+
}, _ = () => E;
|
|
202
|
+
async function le(e) {
|
|
102
203
|
const t = {
|
|
103
204
|
__variables: {
|
|
104
205
|
file: "Upload!"
|
|
105
206
|
},
|
|
106
207
|
fsUploadTempFile: {
|
|
107
208
|
__args: {
|
|
108
|
-
file: new
|
|
209
|
+
file: new R("file")
|
|
109
210
|
},
|
|
110
211
|
name: !0,
|
|
111
212
|
path: !0,
|
|
@@ -114,224 +215,224 @@ async function k(e) {
|
|
|
114
215
|
}
|
|
115
216
|
}, r = new FormData();
|
|
116
217
|
r.append("operations", JSON.stringify({
|
|
117
|
-
query:
|
|
218
|
+
query: v({ mutation: t })
|
|
118
219
|
})), r.append("map", JSON.stringify({ 0: ["variables.file"] })), r.append("0", e);
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
throw new Error(
|
|
122
|
-
return
|
|
220
|
+
const s = await b().post(_(), r);
|
|
221
|
+
if (s.data.errors)
|
|
222
|
+
throw new Error(s.data.errors[0].message);
|
|
223
|
+
return s.data.data.fsUploadTempFile;
|
|
123
224
|
}
|
|
124
|
-
const
|
|
225
|
+
const ce = (e, t, r) => u("sendMail", {
|
|
125
226
|
email: e,
|
|
126
227
|
subject: t,
|
|
127
228
|
message: r
|
|
128
|
-
}),
|
|
229
|
+
}), ue = async (e) => (await p({
|
|
129
230
|
config: {
|
|
130
231
|
__args: {
|
|
131
232
|
name: e
|
|
132
233
|
}
|
|
133
234
|
}
|
|
134
235
|
})).config;
|
|
135
|
-
function
|
|
136
|
-
const t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t,
|
|
137
|
-
for (let
|
|
138
|
-
|
|
139
|
-
return
|
|
236
|
+
function N(e) {
|
|
237
|
+
const t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t, s = atob(r), n = new ArrayBuffer(s.length), a = new Uint8Array(n);
|
|
238
|
+
for (let c = 0; c < s.length; c++)
|
|
239
|
+
a[c] = s.charCodeAt(c);
|
|
240
|
+
return n;
|
|
140
241
|
}
|
|
141
|
-
function
|
|
242
|
+
function x(e) {
|
|
142
243
|
const t = new Uint8Array(e);
|
|
143
244
|
let r = "";
|
|
144
|
-
for (const
|
|
145
|
-
r += String.fromCharCode(
|
|
245
|
+
for (const a of t)
|
|
246
|
+
r += String.fromCharCode(a);
|
|
146
247
|
return btoa(r).replace(/\+/g, "-").replace(
|
|
147
248
|
/\//g,
|
|
148
249
|
"_"
|
|
149
250
|
).replace(/=/g, "");
|
|
150
251
|
}
|
|
151
|
-
var
|
|
152
|
-
function
|
|
153
|
-
if (t ===
|
|
252
|
+
var o = "copy", f = "convert";
|
|
253
|
+
function w(e, t, r) {
|
|
254
|
+
if (t === o)
|
|
154
255
|
return r;
|
|
155
|
-
if (t ===
|
|
256
|
+
if (t === f)
|
|
156
257
|
return e(r);
|
|
157
258
|
if (t instanceof Array)
|
|
158
|
-
return r.map((
|
|
259
|
+
return r.map((s) => w(e, t[0], s));
|
|
159
260
|
if (t instanceof Object) {
|
|
160
|
-
const
|
|
161
|
-
for (const [
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
|
|
261
|
+
const s = {};
|
|
262
|
+
for (const [n, a] of Object.entries(t)) {
|
|
263
|
+
if (a.derive) {
|
|
264
|
+
const c = a.derive(r);
|
|
265
|
+
c !== void 0 && (r[n] = c);
|
|
165
266
|
}
|
|
166
|
-
if (!(
|
|
167
|
-
if (
|
|
168
|
-
throw new Error(`Missing key: ${
|
|
267
|
+
if (!(n in r)) {
|
|
268
|
+
if (a.required)
|
|
269
|
+
throw new Error(`Missing key: ${n}`);
|
|
169
270
|
continue;
|
|
170
271
|
}
|
|
171
|
-
if (r[
|
|
172
|
-
n
|
|
272
|
+
if (r[n] == null) {
|
|
273
|
+
s[n] = null;
|
|
173
274
|
continue;
|
|
174
275
|
}
|
|
175
|
-
n
|
|
276
|
+
s[n] = w(
|
|
176
277
|
e,
|
|
177
|
-
|
|
178
|
-
r[
|
|
278
|
+
a.schema,
|
|
279
|
+
r[n]
|
|
179
280
|
);
|
|
180
281
|
}
|
|
181
|
-
return
|
|
282
|
+
return s;
|
|
182
283
|
}
|
|
183
284
|
}
|
|
184
|
-
function
|
|
285
|
+
function A(e, t) {
|
|
185
286
|
return {
|
|
186
287
|
required: !0,
|
|
187
288
|
schema: e,
|
|
188
289
|
derive: t
|
|
189
290
|
};
|
|
190
291
|
}
|
|
191
|
-
function
|
|
292
|
+
function i(e) {
|
|
192
293
|
return {
|
|
193
294
|
required: !0,
|
|
194
295
|
schema: e
|
|
195
296
|
};
|
|
196
297
|
}
|
|
197
|
-
function
|
|
298
|
+
function l(e) {
|
|
198
299
|
return {
|
|
199
300
|
required: !1,
|
|
200
301
|
schema: e
|
|
201
302
|
};
|
|
202
303
|
}
|
|
203
|
-
var
|
|
204
|
-
type: o
|
|
205
|
-
id:
|
|
206
|
-
transports:
|
|
207
|
-
},
|
|
208
|
-
appid:
|
|
209
|
-
appidExclude:
|
|
210
|
-
credProps:
|
|
211
|
-
},
|
|
212
|
-
appid:
|
|
213
|
-
appidExclude:
|
|
214
|
-
credProps:
|
|
215
|
-
},
|
|
216
|
-
publicKey:
|
|
217
|
-
rp: o
|
|
218
|
-
user:
|
|
219
|
-
id:
|
|
220
|
-
name: o
|
|
221
|
-
displayName: o
|
|
304
|
+
var J = {
|
|
305
|
+
type: i(o),
|
|
306
|
+
id: i(f),
|
|
307
|
+
transports: l(o)
|
|
308
|
+
}, j = {
|
|
309
|
+
appid: l(o),
|
|
310
|
+
appidExclude: l(o),
|
|
311
|
+
credProps: l(o)
|
|
312
|
+
}, D = {
|
|
313
|
+
appid: l(o),
|
|
314
|
+
appidExclude: l(o),
|
|
315
|
+
credProps: l(o)
|
|
316
|
+
}, T = {
|
|
317
|
+
publicKey: i({
|
|
318
|
+
rp: i(o),
|
|
319
|
+
user: i({
|
|
320
|
+
id: i(f),
|
|
321
|
+
name: i(o),
|
|
322
|
+
displayName: i(o)
|
|
222
323
|
}),
|
|
223
|
-
challenge:
|
|
224
|
-
pubKeyCredParams: o
|
|
225
|
-
timeout:
|
|
226
|
-
excludeCredentials:
|
|
227
|
-
authenticatorSelection:
|
|
228
|
-
attestation:
|
|
229
|
-
extensions:
|
|
324
|
+
challenge: i(f),
|
|
325
|
+
pubKeyCredParams: i(o),
|
|
326
|
+
timeout: l(o),
|
|
327
|
+
excludeCredentials: l([J]),
|
|
328
|
+
authenticatorSelection: l(o),
|
|
329
|
+
attestation: l(o),
|
|
330
|
+
extensions: l(j)
|
|
230
331
|
}),
|
|
231
|
-
signal:
|
|
232
|
-
},
|
|
233
|
-
type: o
|
|
234
|
-
id: o
|
|
235
|
-
rawId:
|
|
236
|
-
authenticatorAttachment:
|
|
237
|
-
response:
|
|
238
|
-
clientDataJSON:
|
|
239
|
-
attestationObject:
|
|
240
|
-
transports:
|
|
241
|
-
|
|
332
|
+
signal: l(o)
|
|
333
|
+
}, V = {
|
|
334
|
+
type: i(o),
|
|
335
|
+
id: i(o),
|
|
336
|
+
rawId: i(f),
|
|
337
|
+
authenticatorAttachment: l(o),
|
|
338
|
+
response: i({
|
|
339
|
+
clientDataJSON: i(f),
|
|
340
|
+
attestationObject: i(f),
|
|
341
|
+
transports: A(
|
|
342
|
+
o,
|
|
242
343
|
(e) => {
|
|
243
344
|
var t;
|
|
244
345
|
return ((t = e.getTransports) == null ? void 0 : t.call(e)) || [];
|
|
245
346
|
}
|
|
246
347
|
)
|
|
247
348
|
}),
|
|
248
|
-
clientExtensionResults:
|
|
249
|
-
|
|
349
|
+
clientExtensionResults: A(
|
|
350
|
+
D,
|
|
250
351
|
(e) => e.getClientExtensionResults()
|
|
251
352
|
)
|
|
252
|
-
},
|
|
253
|
-
mediation:
|
|
254
|
-
publicKey:
|
|
255
|
-
challenge:
|
|
256
|
-
timeout:
|
|
257
|
-
rpId:
|
|
258
|
-
allowCredentials:
|
|
259
|
-
userVerification:
|
|
260
|
-
extensions:
|
|
353
|
+
}, K = {
|
|
354
|
+
mediation: l(o),
|
|
355
|
+
publicKey: i({
|
|
356
|
+
challenge: i(f),
|
|
357
|
+
timeout: l(o),
|
|
358
|
+
rpId: l(o),
|
|
359
|
+
allowCredentials: l([J]),
|
|
360
|
+
userVerification: l(o),
|
|
361
|
+
extensions: l(j)
|
|
261
362
|
}),
|
|
262
|
-
signal:
|
|
263
|
-
},
|
|
264
|
-
type: o
|
|
265
|
-
id: o
|
|
266
|
-
rawId:
|
|
267
|
-
authenticatorAttachment:
|
|
268
|
-
response:
|
|
269
|
-
clientDataJSON:
|
|
270
|
-
authenticatorData:
|
|
271
|
-
signature:
|
|
272
|
-
userHandle:
|
|
363
|
+
signal: l(o)
|
|
364
|
+
}, M = {
|
|
365
|
+
type: i(o),
|
|
366
|
+
id: i(o),
|
|
367
|
+
rawId: i(f),
|
|
368
|
+
authenticatorAttachment: l(o),
|
|
369
|
+
response: i({
|
|
370
|
+
clientDataJSON: i(f),
|
|
371
|
+
authenticatorData: i(f),
|
|
372
|
+
signature: i(f),
|
|
373
|
+
userHandle: i(f)
|
|
273
374
|
}),
|
|
274
|
-
clientExtensionResults:
|
|
275
|
-
|
|
375
|
+
clientExtensionResults: A(
|
|
376
|
+
D,
|
|
276
377
|
(e) => e.getClientExtensionResults()
|
|
277
378
|
)
|
|
278
379
|
};
|
|
279
|
-
function
|
|
280
|
-
return
|
|
380
|
+
function B(e) {
|
|
381
|
+
return w(N, T, e);
|
|
281
382
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
|
|
383
|
+
function Q(e) {
|
|
384
|
+
return w(
|
|
385
|
+
x,
|
|
386
|
+
V,
|
|
286
387
|
e
|
|
287
388
|
);
|
|
288
389
|
}
|
|
289
|
-
function
|
|
290
|
-
return
|
|
390
|
+
function G(e) {
|
|
391
|
+
return w(N, K, e);
|
|
291
392
|
}
|
|
292
|
-
function
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
393
|
+
function W(e) {
|
|
394
|
+
return w(
|
|
395
|
+
x,
|
|
396
|
+
M,
|
|
296
397
|
e
|
|
297
398
|
);
|
|
298
399
|
}
|
|
299
|
-
async function
|
|
400
|
+
async function z(e) {
|
|
300
401
|
const t = await navigator.credentials.create(
|
|
301
402
|
e
|
|
302
403
|
);
|
|
303
|
-
return t.toJSON = () =>
|
|
404
|
+
return t.toJSON = () => Q(t), t;
|
|
304
405
|
}
|
|
305
|
-
async function
|
|
406
|
+
async function I(e) {
|
|
306
407
|
const t = await navigator.credentials.get(
|
|
307
408
|
e
|
|
308
409
|
);
|
|
309
|
-
return t.toJSON = () =>
|
|
410
|
+
return t.toJSON = () => W(t), t;
|
|
310
411
|
}
|
|
311
|
-
async function
|
|
312
|
-
const r = (await
|
|
412
|
+
async function de(e) {
|
|
413
|
+
const r = (await p({
|
|
313
414
|
webAuthnRequestOptions: {
|
|
314
415
|
__args: {
|
|
315
416
|
username: e
|
|
316
417
|
}
|
|
317
418
|
}
|
|
318
|
-
})).webAuthnRequestOptions,
|
|
419
|
+
})).webAuthnRequestOptions, s = G({
|
|
319
420
|
publicKey: r
|
|
320
|
-
}),
|
|
321
|
-
await
|
|
421
|
+
}), n = await I(s);
|
|
422
|
+
await u("webAuthnAssertion", {
|
|
322
423
|
username: e,
|
|
323
|
-
assertion:
|
|
424
|
+
assertion: n.toJSON()
|
|
324
425
|
});
|
|
325
426
|
}
|
|
326
|
-
async function
|
|
327
|
-
const e = await
|
|
427
|
+
async function fe() {
|
|
428
|
+
const e = await p({ webAuthnCreationOptions: !0 }), t = B({
|
|
328
429
|
publicKey: e.webAuthnCreationOptions
|
|
329
|
-
}), r = await
|
|
330
|
-
await
|
|
430
|
+
}), r = await z(t);
|
|
431
|
+
await u("webAuthnRegister", {
|
|
331
432
|
registration: r.toJSON()
|
|
332
433
|
});
|
|
333
434
|
}
|
|
334
|
-
const
|
|
435
|
+
const pe = async (e) => (await p({
|
|
335
436
|
fsListFiles: {
|
|
336
437
|
__args: {
|
|
337
438
|
path: e
|
|
@@ -343,7 +444,7 @@ const se = async (e) => (await d({
|
|
|
343
444
|
canPreview: !0,
|
|
344
445
|
imagePath: !0
|
|
345
446
|
}
|
|
346
|
-
})).fsListFiles,
|
|
447
|
+
})).fsListFiles, ge = async (e) => (await p({
|
|
347
448
|
fsListFolders: {
|
|
348
449
|
__args: {
|
|
349
450
|
path: e
|
|
@@ -351,8 +452,8 @@ const se = async (e) => (await d({
|
|
|
351
452
|
name: !0,
|
|
352
453
|
path: !0
|
|
353
454
|
}
|
|
354
|
-
})).fsListFolders,
|
|
355
|
-
let t = await
|
|
455
|
+
})).fsListFolders, we = async (e) => {
|
|
456
|
+
let t = await p({
|
|
356
457
|
fsFile: {
|
|
357
458
|
__args: {
|
|
358
459
|
path: e
|
|
@@ -361,55 +462,59 @@ const se = async (e) => (await d({
|
|
|
361
462
|
}
|
|
362
463
|
});
|
|
363
464
|
return window.atob(t.fsFile.base64Content);
|
|
364
|
-
},
|
|
465
|
+
}, me = (e, t) => u("fsWriteFile", {
|
|
365
466
|
path: e,
|
|
366
467
|
content: t
|
|
367
|
-
}),
|
|
468
|
+
}), he = (e) => u("fsDeleteFile", {
|
|
368
469
|
path: e
|
|
369
|
-
}),
|
|
470
|
+
}), be = (e) => u("fsCreateFolder", {
|
|
370
471
|
path: e
|
|
371
|
-
}),
|
|
472
|
+
}), ye = (e) => u("fsDeleteFolder", {
|
|
372
473
|
path: e
|
|
373
|
-
}),
|
|
474
|
+
}), _e = (e, t) => u("fsRenameFile", {
|
|
374
475
|
path: e,
|
|
375
476
|
name: t
|
|
376
|
-
}),
|
|
477
|
+
}), Fe = (e, t) => u("fsRenameFolder", {
|
|
377
478
|
path: e,
|
|
378
479
|
name: t
|
|
379
|
-
}),
|
|
480
|
+
}), Ce = (e, t) => u("fsMoveFile", {
|
|
380
481
|
source: e,
|
|
381
482
|
target: t
|
|
382
483
|
});
|
|
383
484
|
export {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
485
|
+
oe as File,
|
|
486
|
+
S as convertData,
|
|
487
|
+
ne as defineModel,
|
|
488
|
+
F as file,
|
|
489
|
+
ee as forgetPassword,
|
|
490
|
+
be as fsCreateFolder,
|
|
491
|
+
he as fsDeleteFile,
|
|
492
|
+
ye as fsDeleteFolder,
|
|
493
|
+
pe as fsListFiles,
|
|
494
|
+
ge as fsListFolders,
|
|
495
|
+
Ce as fsMoveFile,
|
|
496
|
+
we as fsReadFile,
|
|
497
|
+
_e as fsRenameFile,
|
|
498
|
+
Fe as fsRenameFolder,
|
|
499
|
+
me as fsWriteFile,
|
|
396
500
|
_ as getApiUrl,
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
501
|
+
b as getAxios,
|
|
502
|
+
ue as getConfig,
|
|
503
|
+
se as getGQLFields,
|
|
400
504
|
q as getModelField,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
505
|
+
re as granted,
|
|
506
|
+
X as login,
|
|
507
|
+
Y as logout,
|
|
508
|
+
ae as model,
|
|
509
|
+
u as mutation,
|
|
510
|
+
p as query,
|
|
511
|
+
k as resetPassword,
|
|
512
|
+
ce as sendMail,
|
|
513
|
+
ie as setApiUrl,
|
|
514
|
+
te as setAxios,
|
|
515
|
+
y as toQuery,
|
|
516
|
+
Z as updatePassword,
|
|
517
|
+
le as uploadFile,
|
|
518
|
+
de as webauthnLogin,
|
|
519
|
+
fe as webauthnRegister
|
|
415
520
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("axios"),require("json-to-graphql-query")):typeof define=="function"&&define.amd?define(["exports","axios","json-to-graphql-query"],m):(s=typeof globalThis<"u"?globalThis:s||self,m(s.light={},s.axios,s.jsonToGraphqlQuery))})(this,function(s,m,y){"use strict";const U=(e,t,r="")=>d("login",{username:e,password:t,code:r}),M=()=>d("logout"),T=(e,t)=>d("updatePassword",{old_password:e,new_password:t}),V=(e,t,r)=>d("resetPassword",{email:e,password:t,code:r}),Q=e=>d("forgetPassword",{email:e});let C;const K=e=>{C=e},b=()=>(C||(C=m.create({withCredentials:!0})),C),B=async e=>(await p({granted:{__args:{rights:e}}})).granted,F={},W=(e,t)=>{F[e]={};for(const r of Object.entries(t)){const[a,n]=r;F[e][a]=()=>({name:n.name?n.name:a,raw:n,getName:()=>n.name?n.name:a,getGQLField:()=>n.gqlField!==void 0?n.gqlField:n.name||a,getRaw(){return n},getValue(i){return n.field&&typeof n.field=="function"?n.field(i):n.field&&typeof n.field=="string"?i[n.field]:i[this.getName()]},getFormattedValue(i){const u=this.getValue(i);return n.format?n.format(u):u}})}},O=(e,t)=>!F[e]||!F[e][t]?null:F[e][t](),G=(e,t)=>{const r=[];for(const a of t)if(typeof a=="string"){const n=O(e,a);n&&r.push(n.getGQLField())}else typeof a=="object"&&r.push(a);return r},S=e=>{const t=new FormData,r={},a={},n={};let i=0,u=!1;return Object.entries(e).forEach(([f,w])=>{w instanceof File?(u=!0,a[f]="Upload!",n[f]=new y.VariableType(f),t.append(i.toString(),w),r[i]=["variables."+f],i++):n[f]=w}),u?(t.append("map",JSON.stringify(r)),{data:n,formData:t,mutation:{__variables:a}}):{data:n,formData:null,mutation:{}}},z=e=>{const t=e;return{name:t,async update(r,a){const n=S(a);return await d("update"+t,{id:r,data:n.data},[],n.mutation,n.formData)},async delete(r){return await d("delete"+t,{id:r})},async add(r){const a=S(r);return await d("add"+t,{data:a.data},[],a.mutation,a.formData)},fields(r){let a=[];for(let n of r){const i=O(t,n);i&&a.push(i)}return a},async get(r,a){return(await p({["list"+t]:{__args:{filters:r},data:{__args:{limit:1},..._(a)}}}))["list"+t].data[0]},async list(r,a){return(await p({["list"+t]:{__args:{filters:r},data:{..._(a)}}}))["list"+t].data}}};function I(e){e="<~"+e+"~>";var t,r,a,n,i,u=String,f=255;for(e.slice(0,2)==="<~"&&e.slice(-2),e=e.slice(2,-2).replace(/\s/g,"").replace("z","!!!!!"),t="uuuuu".slice(e.length%5||5),e+=t,a=[],n=0,i=e.length;i>n;n+=5)r=52200625*(e.charCodeAt(n)-33)+614125*(e.charCodeAt(n+1)-33)+7225*(e.charCodeAt(n+2)-33)+85*(e.charCodeAt(n+3)-33)+(e.charCodeAt(n+4)-33),a.push(f&r>>24,f&r>>16,f&r>>8,f&r);return function(w,Fe){for(var P=Fe;P>0;P--)w.pop()}(a,t.length),u.fromCharCode.apply(u,a)}const v=(e="")=>{const t=e,r=(a="application/octet-stream")=>{const n=new Uint8Array(t.length);for(let f=0;f<t.length;f++)n[f]=t.charCodeAt(f);const i=new Blob([n],{type:a});return URL.createObjectURL(i)};return{getContent:()=>t,getURL:r,download:a=>{const n=document.createElement("a");n.download=a,n.href=r(),document.body.appendChild(n),n.click(),document.body.removeChild(n)},open:a=>{window.open(r(a),"_blank")}}},$={fromBase85:e=>v(I(e)),fromBase64:e=>v(atob(e)),fromString:e=>v(e)},R=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(r=>{Object.entries(R(r)).forEach(([a,n])=>{t[a]=n})}),t):(Object.entries(e).forEach(([r,a])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){t[r]=a;return}if(typeof a=="boolean"){t[r]=a;return}t[r]=R(a)}),t)},_=e=>R(e),p=async e=>{let t=y.jsonToGraphQLQuery(_(e));const r=await b().post(A(),{query:`{ ${t} }`});if(r.data.errors)throw new Error(r.data.errors[0].message);return r.data.data},d=async(e,t=null,r=[],a={},n=null)=>{a[e]=!0,r instanceof Array&&r.length!=0&&(a[e]={}),t&&(a[e]={},a[e].__args=t),Object.entries(_(r)).forEach(([f,w])=>{a[e][f]=w});let i=null;const u=y.jsonToGraphQLQuery({mutation:a});if(n?(n.append("operations",JSON.stringify({query:u})),i=await b().post(A(),n)):i=await b().post(A(),{query:u}),i.data.errors)throw new Error(i.data.errors[0].message);return i.data.data[e]};let L="/api/";const H=e=>{L=e},A=()=>L;async function X(e){const t={__variables:{file:"Upload!"},fsUploadTempFile:{__args:{file:new y.VariableType("file")},name:!0,path:!0,size:!0,mime:!0}},r=new FormData;r.append("operations",JSON.stringify({query:y.jsonToGraphQLQuery({mutation:t})})),r.append("map",JSON.stringify({0:["variables.file"]})),r.append("0",e);const a=await b().post(A(),r);if(a.data.errors)throw new Error(a.data.errors[0].message);return a.data.data.fsUploadTempFile}const Y=(e,t,r)=>d("sendMail",{email:e,subject:t,message:r}),Z=async e=>(await p({config:{__args:{name:e}}})).config;function E(e){const t="==".slice(0,(4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,a=atob(r),n=new ArrayBuffer(a.length),i=new Uint8Array(n);for(let u=0;u<a.length;u++)i[u]=a.charCodeAt(u);return n}function j(e){const t=new Uint8Array(e);let r="";for(const i of t)r+=String.fromCharCode(i);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var o="copy",g="convert";function h(e,t,r){if(t===o)return r;if(t===g)return e(r);if(t instanceof Array)return r.map(a=>h(e,t[0],a));if(t instanceof Object){const a={};for(const[n,i]of Object.entries(t)){if(i.derive){const u=i.derive(r);u!==void 0&&(r[n]=u)}if(!(n in r)){if(i.required)throw new Error(`Missing key: ${n}`);continue}if(r[n]==null){a[n]=null;continue}a[n]=h(e,i.schema,r[n])}return a}}function q(e,t){return{required:!0,schema:e,derive:t}}function l(e){return{required:!0,schema:e}}function c(e){return{required:!1,schema:e}}var D={type:l(o),id:l(g),transports:c(o)},N={appid:c(o),appidExclude:c(o),credProps:c(o)},J={appid:c(o),appidExclude:c(o),credProps:c(o)},k={publicKey:l({rp:l(o),user:l({id:l(g),name:l(o),displayName:l(o)}),challenge:l(g),pubKeyCredParams:l(o),timeout:c(o),excludeCredentials:c([D]),authenticatorSelection:c(o),attestation:c(o),extensions:c(N)}),signal:c(o)},x={type:l(o),id:l(o),rawId:l(g),authenticatorAttachment:c(o),response:l({clientDataJSON:l(g),attestationObject:l(g),transports:q(o,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:q(J,e=>e.getClientExtensionResults())},ee={mediation:c(o),publicKey:l({challenge:l(g),timeout:c(o),rpId:c(o),allowCredentials:c([D]),userVerification:c(o),extensions:c(N)}),signal:c(o)},te={type:l(o),id:l(o),rawId:l(g),authenticatorAttachment:c(o),response:l({clientDataJSON:l(g),authenticatorData:l(g),signature:l(g),userHandle:l(g)}),clientExtensionResults:q(J,e=>e.getClientExtensionResults())};function re(e){return h(E,k,e)}function ne(e){return h(j,x,e)}function ae(e){return h(E,ee,e)}function se(e){return h(j,te,e)}async function ie(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>ne(t),t}async function oe(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>se(t),t}async function le(e){const r=(await p({webAuthnRequestOptions:{__args:{username:e}}})).webAuthnRequestOptions,a=ae({publicKey:r}),n=await oe(a);await d("webAuthnAssertion",{username:e,assertion:n.toJSON()})}async function ce(){const e=await p({webAuthnCreationOptions:!0}),t=re({publicKey:e.webAuthnCreationOptions}),r=await ie(t);await d("webAuthnRegister",{registration:r.toJSON()})}const ue=async e=>(await p({fsListFiles:{__args:{path:e},name:!0,path:!0,size:!0,mime:!0,canPreview:!0,imagePath:!0}})).fsListFiles,de=async e=>(await p({fsListFolders:{__args:{path:e},name:!0,path:!0}})).fsListFolders,fe=async e=>{let t=await p({fsFile:{__args:{path:e},base64Content:!0}});return window.atob(t.fsFile.base64Content)},ge=(e,t)=>d("fsWriteFile",{path:e,content:t}),pe=e=>d("fsDeleteFile",{path:e}),we=e=>d("fsCreateFolder",{path:e}),he=e=>d("fsDeleteFolder",{path:e}),me=(e,t)=>d("fsRenameFile",{path:e,name:t}),ye=(e,t)=>d("fsRenameFolder",{path:e,name:t}),be=(e,t)=>d("fsMoveFile",{source:e,target:t});s.File=$,s.convertData=S,s.defineModel=W,s.file=v,s.forgetPassword=Q,s.fsCreateFolder=we,s.fsDeleteFile=pe,s.fsDeleteFolder=he,s.fsListFiles=ue,s.fsListFolders=de,s.fsMoveFile=be,s.fsReadFile=fe,s.fsRenameFile=me,s.fsRenameFolder=ye,s.fsWriteFile=ge,s.getApiUrl=A,s.getAxios=b,s.getConfig=Z,s.getGQLFields=G,s.getModelField=O,s.granted=B,s.login=U,s.logout=M,s.model=z,s.mutation=d,s.query=p,s.resetPassword=V,s.sendMail=Y,s.setApiUrl=H,s.setAxios=K,s.toQuery=_,s.updatePassword=T,s.uploadFile=X,s.webauthnLogin=le,s.webauthnRegister=ce,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/dist/model.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Fields } from ".";
|
|
1
2
|
export type ModelField = {
|
|
2
3
|
name: string;
|
|
3
4
|
raw: FieldOption;
|
|
@@ -23,3 +24,25 @@ export declare const defineModel: (name: string, fields: {
|
|
|
23
24
|
}) => void;
|
|
24
25
|
export declare const getModelField: (name: string, field: string) => ModelField | null;
|
|
25
26
|
export declare const getGQLFields: (model: string, fields: (string | object)[]) => any[];
|
|
27
|
+
export declare const convertData: (data: Object) => {
|
|
28
|
+
data: any;
|
|
29
|
+
formData: FormData;
|
|
30
|
+
mutation: {
|
|
31
|
+
__variables: any;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
data: any;
|
|
35
|
+
formData: null;
|
|
36
|
+
mutation: {
|
|
37
|
+
__variables?: undefined;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const model: (name: string) => {
|
|
41
|
+
name: string;
|
|
42
|
+
update(id: number, data: Object): Promise<any>;
|
|
43
|
+
delete(id: number): Promise<any>;
|
|
44
|
+
add(data: Object): Promise<any>;
|
|
45
|
+
fields(fields: string[]): ModelField[];
|
|
46
|
+
get(filters: any, fields: Fields): Promise<any>;
|
|
47
|
+
list(filters: any, fields: Fields): Promise<any>;
|
|
48
|
+
};
|
package/dist/mutation.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Fields } from '.';
|
|
2
|
-
|
|
2
|
+
import { Nullable } from 'vitest';
|
|
3
|
+
declare const _default: (operation: string, args?: any, fields?: Fields, mutation?: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}, formData?: Nullable<FormData>) => Promise<any>;
|
|
3
6
|
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|