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