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