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