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