@hostlink/light 2.0.0 → 2.0.2

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