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