@hostlink/light 1.0.2 → 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 +281 -245
- package/dist/light.umd.cjs +1 -1
- 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,101 +1,101 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { VariableType as
|
|
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, m = {},
|
|
28
|
+
})).granted, m = {}, ne = (e, t) => {
|
|
29
29
|
m[e] = {};
|
|
30
30
|
for (const r of Object.entries(t)) {
|
|
31
|
-
const [
|
|
32
|
-
m[e][
|
|
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
|
-
},
|
|
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 = {},
|
|
60
|
-
let
|
|
61
|
-
return Object.entries(e).forEach(([
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
data:
|
|
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
65
|
formData: t,
|
|
66
66
|
mutation: {
|
|
67
|
-
__variables:
|
|
67
|
+
__variables: s
|
|
68
68
|
}
|
|
69
69
|
}) : {
|
|
70
|
-
data:
|
|
70
|
+
data: n,
|
|
71
71
|
formData: null,
|
|
72
72
|
mutation: {}
|
|
73
73
|
};
|
|
74
|
-
},
|
|
74
|
+
}, ae = (e) => {
|
|
75
75
|
const t = e;
|
|
76
76
|
return {
|
|
77
77
|
name: t,
|
|
78
|
-
async update(r,
|
|
79
|
-
const
|
|
80
|
-
return await
|
|
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
81
|
},
|
|
82
82
|
async delete(r) {
|
|
83
|
-
return await
|
|
83
|
+
return await u("delete" + t, { id: r });
|
|
84
84
|
},
|
|
85
85
|
async add(r) {
|
|
86
|
-
const
|
|
87
|
-
return await
|
|
86
|
+
const s = S(r);
|
|
87
|
+
return await u("add" + t, { data: s.data }, [], s.mutation, s.formData);
|
|
88
88
|
},
|
|
89
89
|
fields(r) {
|
|
90
|
-
let
|
|
91
|
-
for (let
|
|
92
|
-
const
|
|
93
|
-
|
|
90
|
+
let s = [];
|
|
91
|
+
for (let n of r) {
|
|
92
|
+
const a = q(t, n);
|
|
93
|
+
a && s.push(a);
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return s;
|
|
96
96
|
},
|
|
97
|
-
async get(r,
|
|
98
|
-
return (await
|
|
97
|
+
async get(r, s) {
|
|
98
|
+
return (await p({
|
|
99
99
|
["list" + t]: {
|
|
100
100
|
__args: {
|
|
101
101
|
filters: r
|
|
@@ -104,75 +104,109 @@ const Y = (e) => {
|
|
|
104
104
|
__args: {
|
|
105
105
|
limit: 1
|
|
106
106
|
},
|
|
107
|
-
...y(
|
|
107
|
+
...y(s)
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}))["list" + t].data[0];
|
|
111
111
|
},
|
|
112
|
-
async list(r,
|
|
113
|
-
return (await
|
|
112
|
+
async list(r, s) {
|
|
113
|
+
return (await p({
|
|
114
114
|
["list" + t]: {
|
|
115
115
|
__args: {
|
|
116
116
|
filters: r
|
|
117
117
|
},
|
|
118
118
|
data: {
|
|
119
|
-
...y(
|
|
119
|
+
...y(s)
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}))["list" + t].data;
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
}
|
|
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) => {
|
|
126
160
|
let t = {};
|
|
127
161
|
return typeof e == "string" ? (t[e] = !0, t) : e instanceof Array ? (e.forEach((r) => {
|
|
128
|
-
Object.entries(
|
|
129
|
-
t[
|
|
162
|
+
Object.entries(C(r)).forEach(([s, n]) => {
|
|
163
|
+
t[s] = n;
|
|
130
164
|
});
|
|
131
|
-
}), t) : (Object.entries(e).forEach(([r,
|
|
165
|
+
}), t) : (Object.entries(e).forEach(([r, s]) => {
|
|
132
166
|
if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
|
|
133
|
-
t[r] =
|
|
167
|
+
t[r] = s;
|
|
134
168
|
return;
|
|
135
169
|
}
|
|
136
|
-
if (typeof
|
|
137
|
-
t[r] =
|
|
170
|
+
if (typeof s == "boolean") {
|
|
171
|
+
t[r] = s;
|
|
138
172
|
return;
|
|
139
173
|
}
|
|
140
|
-
t[r] =
|
|
174
|
+
t[r] = C(s);
|
|
141
175
|
}), t);
|
|
142
|
-
}, y = (e) =>
|
|
176
|
+
}, y = (e) => C(e), p = async (e) => {
|
|
143
177
|
let t = v(y(e));
|
|
144
|
-
const r = await
|
|
178
|
+
const r = await b().post(_(), {
|
|
145
179
|
query: `{ ${t} }`
|
|
146
180
|
});
|
|
147
181
|
if (r.data.errors)
|
|
148
182
|
throw new Error(r.data.errors[0].message);
|
|
149
183
|
return r.data.data;
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
|
|
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;
|
|
153
187
|
});
|
|
154
|
-
let
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
query:
|
|
158
|
-
})),
|
|
159
|
-
query:
|
|
160
|
-
}),
|
|
161
|
-
throw new Error(
|
|
162
|
-
return
|
|
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];
|
|
163
197
|
};
|
|
164
|
-
let
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
}, _ = () =>
|
|
168
|
-
async function
|
|
198
|
+
let E = "/api/";
|
|
199
|
+
const ie = (e) => {
|
|
200
|
+
E = e;
|
|
201
|
+
}, _ = () => E;
|
|
202
|
+
async function le(e) {
|
|
169
203
|
const t = {
|
|
170
204
|
__variables: {
|
|
171
205
|
file: "Upload!"
|
|
172
206
|
},
|
|
173
207
|
fsUploadTempFile: {
|
|
174
208
|
__args: {
|
|
175
|
-
file: new
|
|
209
|
+
file: new R("file")
|
|
176
210
|
},
|
|
177
211
|
name: !0,
|
|
178
212
|
path: !0,
|
|
@@ -183,79 +217,79 @@ async function ne(e) {
|
|
|
183
217
|
r.append("operations", JSON.stringify({
|
|
184
218
|
query: v({ mutation: t })
|
|
185
219
|
})), r.append("map", JSON.stringify({ 0: ["variables.file"] })), r.append("0", e);
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
throw new Error(
|
|
189
|
-
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;
|
|
190
224
|
}
|
|
191
|
-
const
|
|
225
|
+
const ce = (e, t, r) => u("sendMail", {
|
|
192
226
|
email: e,
|
|
193
227
|
subject: t,
|
|
194
228
|
message: r
|
|
195
|
-
}),
|
|
229
|
+
}), ue = async (e) => (await p({
|
|
196
230
|
config: {
|
|
197
231
|
__args: {
|
|
198
232
|
name: e
|
|
199
233
|
}
|
|
200
234
|
}
|
|
201
235
|
})).config;
|
|
202
|
-
function
|
|
203
|
-
const t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t,
|
|
204
|
-
for (let
|
|
205
|
-
|
|
206
|
-
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;
|
|
207
241
|
}
|
|
208
|
-
function
|
|
242
|
+
function x(e) {
|
|
209
243
|
const t = new Uint8Array(e);
|
|
210
244
|
let r = "";
|
|
211
|
-
for (const
|
|
212
|
-
r += String.fromCharCode(
|
|
245
|
+
for (const a of t)
|
|
246
|
+
r += String.fromCharCode(a);
|
|
213
247
|
return btoa(r).replace(/\+/g, "-").replace(
|
|
214
248
|
/\//g,
|
|
215
249
|
"_"
|
|
216
250
|
).replace(/=/g, "");
|
|
217
251
|
}
|
|
218
|
-
var
|
|
219
|
-
function
|
|
220
|
-
if (t ===
|
|
252
|
+
var o = "copy", f = "convert";
|
|
253
|
+
function w(e, t, r) {
|
|
254
|
+
if (t === o)
|
|
221
255
|
return r;
|
|
222
256
|
if (t === f)
|
|
223
257
|
return e(r);
|
|
224
258
|
if (t instanceof Array)
|
|
225
|
-
return r.map((
|
|
259
|
+
return r.map((s) => w(e, t[0], s));
|
|
226
260
|
if (t instanceof Object) {
|
|
227
|
-
const
|
|
228
|
-
for (const [
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
|
|
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);
|
|
232
266
|
}
|
|
233
|
-
if (!(
|
|
234
|
-
if (
|
|
235
|
-
throw new Error(`Missing key: ${
|
|
267
|
+
if (!(n in r)) {
|
|
268
|
+
if (a.required)
|
|
269
|
+
throw new Error(`Missing key: ${n}`);
|
|
236
270
|
continue;
|
|
237
271
|
}
|
|
238
|
-
if (r[
|
|
239
|
-
n
|
|
272
|
+
if (r[n] == null) {
|
|
273
|
+
s[n] = null;
|
|
240
274
|
continue;
|
|
241
275
|
}
|
|
242
|
-
n
|
|
276
|
+
s[n] = w(
|
|
243
277
|
e,
|
|
244
|
-
|
|
245
|
-
r[
|
|
278
|
+
a.schema,
|
|
279
|
+
r[n]
|
|
246
280
|
);
|
|
247
281
|
}
|
|
248
|
-
return
|
|
282
|
+
return s;
|
|
249
283
|
}
|
|
250
284
|
}
|
|
251
|
-
function
|
|
285
|
+
function A(e, t) {
|
|
252
286
|
return {
|
|
253
287
|
required: !0,
|
|
254
288
|
schema: e,
|
|
255
289
|
derive: t
|
|
256
290
|
};
|
|
257
291
|
}
|
|
258
|
-
function
|
|
292
|
+
function i(e) {
|
|
259
293
|
return {
|
|
260
294
|
required: !0,
|
|
261
295
|
schema: e
|
|
@@ -267,138 +301,138 @@ function l(e) {
|
|
|
267
301
|
schema: e
|
|
268
302
|
};
|
|
269
303
|
}
|
|
270
|
-
var
|
|
271
|
-
type: o
|
|
272
|
-
id:
|
|
273
|
-
transports: l(
|
|
274
|
-
}, x = {
|
|
275
|
-
appid: l(a),
|
|
276
|
-
appidExclude: l(a),
|
|
277
|
-
credProps: l(a)
|
|
278
|
-
}, J = {
|
|
279
|
-
appid: l(a),
|
|
280
|
-
appidExclude: l(a),
|
|
281
|
-
credProps: l(a)
|
|
304
|
+
var J = {
|
|
305
|
+
type: i(o),
|
|
306
|
+
id: i(f),
|
|
307
|
+
transports: l(o)
|
|
282
308
|
}, j = {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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)
|
|
289
323
|
}),
|
|
290
|
-
challenge:
|
|
291
|
-
pubKeyCredParams: o
|
|
292
|
-
timeout: l(
|
|
293
|
-
excludeCredentials: l([
|
|
294
|
-
authenticatorSelection: l(
|
|
295
|
-
attestation: l(
|
|
296
|
-
extensions: l(
|
|
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)
|
|
297
331
|
}),
|
|
298
|
-
signal: l(
|
|
299
|
-
},
|
|
300
|
-
type: o
|
|
301
|
-
id: o
|
|
302
|
-
rawId:
|
|
303
|
-
authenticatorAttachment: l(
|
|
304
|
-
response:
|
|
305
|
-
clientDataJSON:
|
|
306
|
-
attestationObject:
|
|
307
|
-
transports:
|
|
308
|
-
|
|
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,
|
|
309
343
|
(e) => {
|
|
310
344
|
var t;
|
|
311
345
|
return ((t = e.getTransports) == null ? void 0 : t.call(e)) || [];
|
|
312
346
|
}
|
|
313
347
|
)
|
|
314
348
|
}),
|
|
315
|
-
clientExtensionResults:
|
|
316
|
-
|
|
349
|
+
clientExtensionResults: A(
|
|
350
|
+
D,
|
|
317
351
|
(e) => e.getClientExtensionResults()
|
|
318
352
|
)
|
|
319
|
-
},
|
|
320
|
-
mediation: l(
|
|
321
|
-
publicKey:
|
|
322
|
-
challenge:
|
|
323
|
-
timeout: l(
|
|
324
|
-
rpId: l(
|
|
325
|
-
allowCredentials: l([
|
|
326
|
-
userVerification: l(
|
|
327
|
-
extensions: l(
|
|
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)
|
|
328
362
|
}),
|
|
329
|
-
signal: l(
|
|
330
|
-
},
|
|
331
|
-
type: o
|
|
332
|
-
id: o
|
|
333
|
-
rawId:
|
|
334
|
-
authenticatorAttachment: l(
|
|
335
|
-
response:
|
|
336
|
-
clientDataJSON:
|
|
337
|
-
authenticatorData:
|
|
338
|
-
signature:
|
|
339
|
-
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)
|
|
340
374
|
}),
|
|
341
|
-
clientExtensionResults:
|
|
342
|
-
|
|
375
|
+
clientExtensionResults: A(
|
|
376
|
+
D,
|
|
343
377
|
(e) => e.getClientExtensionResults()
|
|
344
378
|
)
|
|
345
379
|
};
|
|
346
|
-
function
|
|
347
|
-
return
|
|
380
|
+
function B(e) {
|
|
381
|
+
return w(N, T, e);
|
|
348
382
|
}
|
|
349
|
-
function
|
|
350
|
-
return
|
|
351
|
-
|
|
352
|
-
|
|
383
|
+
function Q(e) {
|
|
384
|
+
return w(
|
|
385
|
+
x,
|
|
386
|
+
V,
|
|
353
387
|
e
|
|
354
388
|
);
|
|
355
389
|
}
|
|
356
|
-
function
|
|
357
|
-
return
|
|
390
|
+
function G(e) {
|
|
391
|
+
return w(N, K, e);
|
|
358
392
|
}
|
|
359
|
-
function
|
|
360
|
-
return
|
|
361
|
-
|
|
362
|
-
|
|
393
|
+
function W(e) {
|
|
394
|
+
return w(
|
|
395
|
+
x,
|
|
396
|
+
M,
|
|
363
397
|
e
|
|
364
398
|
);
|
|
365
399
|
}
|
|
366
|
-
async function
|
|
400
|
+
async function z(e) {
|
|
367
401
|
const t = await navigator.credentials.create(
|
|
368
402
|
e
|
|
369
403
|
);
|
|
370
|
-
return t.toJSON = () =>
|
|
404
|
+
return t.toJSON = () => Q(t), t;
|
|
371
405
|
}
|
|
372
|
-
async function
|
|
406
|
+
async function I(e) {
|
|
373
407
|
const t = await navigator.credentials.get(
|
|
374
408
|
e
|
|
375
409
|
);
|
|
376
|
-
return t.toJSON = () =>
|
|
410
|
+
return t.toJSON = () => W(t), t;
|
|
377
411
|
}
|
|
378
|
-
async function
|
|
379
|
-
const r = (await
|
|
412
|
+
async function de(e) {
|
|
413
|
+
const r = (await p({
|
|
380
414
|
webAuthnRequestOptions: {
|
|
381
415
|
__args: {
|
|
382
416
|
username: e
|
|
383
417
|
}
|
|
384
418
|
}
|
|
385
|
-
})).webAuthnRequestOptions,
|
|
419
|
+
})).webAuthnRequestOptions, s = G({
|
|
386
420
|
publicKey: r
|
|
387
|
-
}),
|
|
388
|
-
await
|
|
421
|
+
}), n = await I(s);
|
|
422
|
+
await u("webAuthnAssertion", {
|
|
389
423
|
username: e,
|
|
390
|
-
assertion:
|
|
424
|
+
assertion: n.toJSON()
|
|
391
425
|
});
|
|
392
426
|
}
|
|
393
|
-
async function
|
|
394
|
-
const e = await
|
|
427
|
+
async function fe() {
|
|
428
|
+
const e = await p({ webAuthnCreationOptions: !0 }), t = B({
|
|
395
429
|
publicKey: e.webAuthnCreationOptions
|
|
396
|
-
}), r = await
|
|
397
|
-
await
|
|
430
|
+
}), r = await z(t);
|
|
431
|
+
await u("webAuthnRegister", {
|
|
398
432
|
registration: r.toJSON()
|
|
399
433
|
});
|
|
400
434
|
}
|
|
401
|
-
const
|
|
435
|
+
const pe = async (e) => (await p({
|
|
402
436
|
fsListFiles: {
|
|
403
437
|
__args: {
|
|
404
438
|
path: e
|
|
@@ -410,7 +444,7 @@ const le = async (e) => (await d({
|
|
|
410
444
|
canPreview: !0,
|
|
411
445
|
imagePath: !0
|
|
412
446
|
}
|
|
413
|
-
})).fsListFiles,
|
|
447
|
+
})).fsListFiles, ge = async (e) => (await p({
|
|
414
448
|
fsListFolders: {
|
|
415
449
|
__args: {
|
|
416
450
|
path: e
|
|
@@ -418,8 +452,8 @@ const le = async (e) => (await d({
|
|
|
418
452
|
name: !0,
|
|
419
453
|
path: !0
|
|
420
454
|
}
|
|
421
|
-
})).fsListFolders,
|
|
422
|
-
let t = await
|
|
455
|
+
})).fsListFolders, we = async (e) => {
|
|
456
|
+
let t = await p({
|
|
423
457
|
fsFile: {
|
|
424
458
|
__args: {
|
|
425
459
|
path: e
|
|
@@ -428,57 +462,59 @@ const le = async (e) => (await d({
|
|
|
428
462
|
}
|
|
429
463
|
});
|
|
430
464
|
return window.atob(t.fsFile.base64Content);
|
|
431
|
-
},
|
|
465
|
+
}, me = (e, t) => u("fsWriteFile", {
|
|
432
466
|
path: e,
|
|
433
467
|
content: t
|
|
434
|
-
}),
|
|
468
|
+
}), he = (e) => u("fsDeleteFile", {
|
|
435
469
|
path: e
|
|
436
|
-
}),
|
|
470
|
+
}), be = (e) => u("fsCreateFolder", {
|
|
437
471
|
path: e
|
|
438
|
-
}),
|
|
472
|
+
}), ye = (e) => u("fsDeleteFolder", {
|
|
439
473
|
path: e
|
|
440
|
-
}),
|
|
474
|
+
}), _e = (e, t) => u("fsRenameFile", {
|
|
441
475
|
path: e,
|
|
442
476
|
name: t
|
|
443
|
-
}),
|
|
477
|
+
}), Fe = (e, t) => u("fsRenameFolder", {
|
|
444
478
|
path: e,
|
|
445
479
|
name: t
|
|
446
|
-
}),
|
|
480
|
+
}), Ce = (e, t) => u("fsMoveFile", {
|
|
447
481
|
source: e,
|
|
448
482
|
target: t
|
|
449
483
|
});
|
|
450
484
|
export {
|
|
485
|
+
oe as File,
|
|
451
486
|
S as convertData,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
we as
|
|
462
|
-
|
|
463
|
-
|
|
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,
|
|
464
500
|
_ as getApiUrl,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
501
|
+
b as getAxios,
|
|
502
|
+
ue as getConfig,
|
|
503
|
+
se as getGQLFields,
|
|
504
|
+
q as getModelField,
|
|
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,
|
|
479
515
|
y as toQuery,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
516
|
+
Z as updatePassword,
|
|
517
|
+
le as uploadFile,
|
|
518
|
+
de as webauthnLogin,
|
|
519
|
+
fe as webauthnRegister
|
|
484
520
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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"})});
|