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