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