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