@hostlink/light 1.2.5 → 1.2.6

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