@hostlink/light 2.5.4 → 2.6.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/auth.d.ts +1 -1
- package/dist/light.js +72 -76
- package/dist/light.umd.cjs +1 -1
- package/dist/webauthn.d.ts +1 -1
- package/package.json +1 -1
package/dist/auth.d.ts
CHANGED
package/dist/light.js
CHANGED
|
@@ -5,16 +5,16 @@ import { jsonToGraphQLQuery as R, VariableType as S } from "json-to-graphql-quer
|
|
|
5
5
|
import W from "axios";
|
|
6
6
|
import k from "collect.js";
|
|
7
7
|
function q(e) {
|
|
8
|
-
const t = "==".slice(0, (4 - e.length % 4) % 4), r = e.replace(/-/g, "+").replace(/_/g, "/") + t, s = atob(r), n = new ArrayBuffer(s.length),
|
|
8
|
+
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);
|
|
9
9
|
for (let u = 0; u < s.length; u++)
|
|
10
|
-
|
|
10
|
+
i[u] = s.charCodeAt(u);
|
|
11
11
|
return n;
|
|
12
12
|
}
|
|
13
13
|
function N(e) {
|
|
14
14
|
const t = new Uint8Array(e);
|
|
15
15
|
let r = "";
|
|
16
|
-
for (const
|
|
17
|
-
r += String.fromCharCode(
|
|
16
|
+
for (const i of t)
|
|
17
|
+
r += String.fromCharCode(i);
|
|
18
18
|
return btoa(r).replace(/\+/g, "-").replace(
|
|
19
19
|
/\//g,
|
|
20
20
|
"_"
|
|
@@ -30,13 +30,13 @@ function A(e, t, r) {
|
|
|
30
30
|
return r.map((s) => A(e, t[0], s));
|
|
31
31
|
if (t instanceof Object) {
|
|
32
32
|
const s = {};
|
|
33
|
-
for (const [n,
|
|
34
|
-
if (
|
|
35
|
-
const u =
|
|
33
|
+
for (const [n, i] of Object.entries(t)) {
|
|
34
|
+
if (i.derive) {
|
|
35
|
+
const u = i.derive(r);
|
|
36
36
|
u !== void 0 && (r[n] = u);
|
|
37
37
|
}
|
|
38
38
|
if (!(n in r)) {
|
|
39
|
-
if (
|
|
39
|
+
if (i.required)
|
|
40
40
|
throw new Error(`Missing key: ${n}`);
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
@@ -46,7 +46,7 @@ function A(e, t, r) {
|
|
|
46
46
|
}
|
|
47
47
|
s[n] = A(
|
|
48
48
|
e,
|
|
49
|
-
|
|
49
|
+
i.schema,
|
|
50
50
|
r[n]
|
|
51
51
|
);
|
|
52
52
|
}
|
|
@@ -181,23 +181,18 @@ async function Z(e) {
|
|
|
181
181
|
return t.toJSON = () => X(t), t;
|
|
182
182
|
}
|
|
183
183
|
const x = (e) => ({
|
|
184
|
-
login: async (
|
|
185
|
-
const { app:
|
|
184
|
+
login: async () => {
|
|
185
|
+
const { app: t } = await y(e, {
|
|
186
186
|
app: {
|
|
187
187
|
auth: {
|
|
188
|
-
webAuthnRequestOptions:
|
|
189
|
-
__args: {
|
|
190
|
-
username: t
|
|
191
|
-
}
|
|
192
|
-
}
|
|
188
|
+
webAuthnRequestOptions: !0
|
|
193
189
|
}
|
|
194
190
|
}
|
|
195
|
-
}),
|
|
196
|
-
publicKey:
|
|
197
|
-
}),
|
|
191
|
+
}), r = t.auth.webAuthnRequestOptions, s = H({
|
|
192
|
+
publicKey: r
|
|
193
|
+
}), n = await Z(s);
|
|
198
194
|
await o(e, "webAuthnAssertion", {
|
|
199
|
-
|
|
200
|
-
assertion: a.toJSON()
|
|
195
|
+
assertion: n.toJSON()
|
|
201
196
|
});
|
|
202
197
|
},
|
|
203
198
|
register: async () => {
|
|
@@ -281,49 +276,49 @@ const x = (e) => ({
|
|
|
281
276
|
}
|
|
282
277
|
})).granted
|
|
283
278
|
}), te = (e, t, r) => {
|
|
284
|
-
const s = t, n = e,
|
|
279
|
+
const s = t, n = e, i = r;
|
|
285
280
|
let u = "list" + t;
|
|
286
|
-
const l = (
|
|
281
|
+
const l = (a) => i[a] ? i[a]() : null;
|
|
287
282
|
return {
|
|
288
283
|
field: l,
|
|
289
|
-
$fields:
|
|
290
|
-
setDataPath(
|
|
291
|
-
return u =
|
|
284
|
+
$fields: i,
|
|
285
|
+
setDataPath(a) {
|
|
286
|
+
return u = a, u;
|
|
292
287
|
},
|
|
293
288
|
getDataPath() {
|
|
294
289
|
return u;
|
|
295
290
|
},
|
|
296
|
-
gqlFields(
|
|
291
|
+
gqlFields(a) {
|
|
297
292
|
const c = [];
|
|
298
|
-
for (const d of
|
|
293
|
+
for (const d of a)
|
|
299
294
|
if (typeof d == "string") {
|
|
300
295
|
const b = l(d);
|
|
301
296
|
b && c.push(b.getGQLField());
|
|
302
297
|
} else typeof d == "object" && c.push(d);
|
|
303
298
|
return c;
|
|
304
299
|
},
|
|
305
|
-
async update(
|
|
306
|
-
return await o(n, "update" + s, { id:
|
|
300
|
+
async update(a, c) {
|
|
301
|
+
return await o(n, "update" + s, { id: a, data: c });
|
|
307
302
|
},
|
|
308
|
-
async delete(
|
|
309
|
-
return await o(n, "delete" + s, { id:
|
|
303
|
+
async delete(a) {
|
|
304
|
+
return await o(n, "delete" + s, { id: a });
|
|
310
305
|
},
|
|
311
|
-
async add(
|
|
312
|
-
return await o(n, "add" + s, { data:
|
|
306
|
+
async add(a) {
|
|
307
|
+
return await o(n, "add" + s, { data: a });
|
|
313
308
|
},
|
|
314
|
-
fields(
|
|
309
|
+
fields(a) {
|
|
315
310
|
let c = [];
|
|
316
|
-
for (let d of
|
|
311
|
+
for (let d of a) {
|
|
317
312
|
const b = l(d);
|
|
318
313
|
b && c.push(b);
|
|
319
314
|
}
|
|
320
315
|
return c;
|
|
321
316
|
},
|
|
322
|
-
async get(
|
|
317
|
+
async get(a, c) {
|
|
323
318
|
return (await y(n, {
|
|
324
319
|
["list" + s]: {
|
|
325
320
|
__args: {
|
|
326
|
-
filters:
|
|
321
|
+
filters: a
|
|
327
322
|
},
|
|
328
323
|
data: {
|
|
329
324
|
__args: {
|
|
@@ -334,11 +329,11 @@ const x = (e) => ({
|
|
|
334
329
|
}
|
|
335
330
|
}))["list" + s].data[0];
|
|
336
331
|
},
|
|
337
|
-
async list(
|
|
332
|
+
async list(a, c) {
|
|
338
333
|
return (await y(n, {
|
|
339
334
|
["list" + s]: {
|
|
340
335
|
__args: {
|
|
341
|
-
filters:
|
|
336
|
+
filters: a
|
|
342
337
|
},
|
|
343
338
|
data: {
|
|
344
339
|
...O(c)
|
|
@@ -350,10 +345,10 @@ const x = (e) => ({
|
|
|
350
345
|
};
|
|
351
346
|
function re(e) {
|
|
352
347
|
e = "<~" + e + "~>";
|
|
353
|
-
var t, r, s, n,
|
|
354
|
-
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,
|
|
355
|
-
return function(
|
|
356
|
-
for (var d = c; d > 0; d--)
|
|
348
|
+
var t, r, s, n, i, u = String, l = 255;
|
|
349
|
+
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) 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(l & r >> 24, l & r >> 16, l & r >> 8, l & r);
|
|
350
|
+
return function(a, c) {
|
|
351
|
+
for (var d = c; d > 0; d--) a.pop();
|
|
357
352
|
}(s, t.length), u.fromCharCode.apply(u, s);
|
|
358
353
|
}
|
|
359
354
|
const B = (e = "") => {
|
|
@@ -361,8 +356,8 @@ const B = (e = "") => {
|
|
|
361
356
|
const n = new Uint8Array(t.length);
|
|
362
357
|
for (let l = 0; l < t.length; l++)
|
|
363
358
|
n[l] = t.charCodeAt(l);
|
|
364
|
-
const
|
|
365
|
-
return URL.createObjectURL(
|
|
359
|
+
const i = new Blob([n], { type: s });
|
|
360
|
+
return URL.createObjectURL(i);
|
|
366
361
|
};
|
|
367
362
|
return {
|
|
368
363
|
getContent: () => t,
|
|
@@ -421,7 +416,7 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
421
416
|
let n = {
|
|
422
417
|
[t]: {}
|
|
423
418
|
};
|
|
424
|
-
const
|
|
419
|
+
const i = new FormData();
|
|
425
420
|
let u = !1;
|
|
426
421
|
if (r) {
|
|
427
422
|
const c = {}, d = {}, b = {};
|
|
@@ -431,22 +426,22 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
431
426
|
u = !0;
|
|
432
427
|
let C = 0;
|
|
433
428
|
v.forEach((D) => {
|
|
434
|
-
D instanceof File && (c[w] = new S(w), d[F] = ["variables." + w + "." + C],
|
|
429
|
+
D instanceof File && (c[w] = new S(w), d[F] = ["variables." + w + "." + C], i.append(F.toString(), D), F++);
|
|
435
430
|
}), b[w] = "[Upload!]!";
|
|
436
|
-
} else v instanceof File ? (u = !0, c[w] = new S(w), d[F] = ["variables." + w],
|
|
437
|
-
D instanceof File ? (c[w][C] = new S(C), d[F] = ["variables." + C],
|
|
431
|
+
} else v instanceof File ? (u = !0, c[w] = new S(w), d[F] = ["variables." + w], i.append(F.toString(), v), b[w] = "Upload!", F++) : v instanceof Object && ne(v) ? (u = !0, c[w] = {}, Object.entries(v).forEach(([C, D]) => {
|
|
432
|
+
D instanceof File ? (c[w][C] = new S(C), d[F] = ["variables." + C], i.append(F.toString(), D), b[C] = "Upload!", F++) : c[w][C] = D;
|
|
438
433
|
})) : v !== void 0 && (c[w] = v);
|
|
439
|
-
}), n[t].__args = c, n.__variables = b, u &&
|
|
434
|
+
}), n[t].__args = c, n.__variables = b, u && i.append("map", JSON.stringify(d));
|
|
440
435
|
}
|
|
441
436
|
Object.entries(O(s)).forEach(([c, d]) => {
|
|
442
437
|
n[t][c] = d;
|
|
443
438
|
}), Object.entries(n[t]).length === 0 && (n[t] = !0);
|
|
444
439
|
let l = null;
|
|
445
|
-
const
|
|
446
|
-
if (u ? (
|
|
447
|
-
query:
|
|
448
|
-
})), l = await e.post("",
|
|
449
|
-
query:
|
|
440
|
+
const a = R({ mutation: n });
|
|
441
|
+
if (u ? (i.append("operations", JSON.stringify({
|
|
442
|
+
query: a
|
|
443
|
+
})), l = await e.post("", i)) : l = await e.post("", {
|
|
444
|
+
query: a
|
|
450
445
|
}), l.data.errors)
|
|
451
446
|
throw new Error(l.data.errors[0].message);
|
|
452
447
|
return l.data.data[t];
|
|
@@ -536,27 +531,27 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
536
531
|
return {
|
|
537
532
|
create(s, n) {
|
|
538
533
|
r[s] = null;
|
|
539
|
-
let
|
|
534
|
+
let i = {};
|
|
540
535
|
for (const u of Object.entries(n)) {
|
|
541
|
-
const [l,
|
|
542
|
-
|
|
543
|
-
name:
|
|
544
|
-
raw:
|
|
545
|
-
getName: () =>
|
|
546
|
-
getGQLField: () =>
|
|
536
|
+
const [l, a] = u;
|
|
537
|
+
i[l] = () => ({
|
|
538
|
+
name: a.name ? a.name : l,
|
|
539
|
+
raw: a,
|
|
540
|
+
getName: () => a.name ? a.name : l,
|
|
541
|
+
getGQLField: () => a.gqlField !== void 0 ? a.gqlField : a.name || l,
|
|
547
542
|
getRaw() {
|
|
548
|
-
return
|
|
543
|
+
return a;
|
|
549
544
|
},
|
|
550
545
|
getValue(c) {
|
|
551
|
-
return
|
|
546
|
+
return a.field && typeof a.field == "function" ? a.field(c) : a.field && typeof a.field == "string" ? c[a.field] : c[this.getName()];
|
|
552
547
|
},
|
|
553
548
|
getFormattedValue(c) {
|
|
554
549
|
const d = this.getValue(c);
|
|
555
|
-
return
|
|
550
|
+
return a.format ? a.format(d) : d;
|
|
556
551
|
}
|
|
557
552
|
});
|
|
558
553
|
}
|
|
559
|
-
r[s] = te(t, s,
|
|
554
|
+
r[s] = te(t, s, i);
|
|
560
555
|
},
|
|
561
556
|
get(s) {
|
|
562
557
|
return r[s] || this.create(s, {}), r[s];
|
|
@@ -597,7 +592,8 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
597
592
|
"only",
|
|
598
593
|
"pad",
|
|
599
594
|
"slice",
|
|
600
|
-
"tap"
|
|
595
|
+
"tap",
|
|
596
|
+
"sort"
|
|
601
597
|
], fe = ["forPage", "sortByDesc", "sortBy", "skip", "take", "splice", "whereBetween", "whereIn", "whereNotBetween", "whereNotIn", "first", "where", "whereContains"], pe = [
|
|
602
598
|
"avg",
|
|
603
599
|
"count",
|
|
@@ -840,7 +836,7 @@ const T = (e, t, r) => {
|
|
|
840
836
|
const t = W.create({
|
|
841
837
|
baseURL: e,
|
|
842
838
|
withCredentials: !0
|
|
843
|
-
}), r = (
|
|
839
|
+
}), r = (i, u = null, l = []) => o(t, i, u, l), s = (i) => y(t, i), n = ue(t);
|
|
844
840
|
return {
|
|
845
841
|
baseURL: e,
|
|
846
842
|
axios: t,
|
|
@@ -852,16 +848,16 @@ const T = (e, t, r) => {
|
|
|
852
848
|
users: le(t),
|
|
853
849
|
fs: ae(t),
|
|
854
850
|
models: n,
|
|
855
|
-
model(
|
|
856
|
-
return n.get(
|
|
851
|
+
model(i) {
|
|
852
|
+
return n.get(i);
|
|
857
853
|
},
|
|
858
854
|
roles: ce(t),
|
|
859
|
-
collect: (
|
|
860
|
-
const l = T(
|
|
861
|
-
return l.data_path = n.get(
|
|
855
|
+
collect: (i, u) => {
|
|
856
|
+
const l = T(i, t, u);
|
|
857
|
+
return l.data_path = n.get(i).getDataPath(), l;
|
|
862
858
|
},
|
|
863
|
-
drive(
|
|
864
|
-
return he(
|
|
859
|
+
drive(i) {
|
|
860
|
+
return he(i, t);
|
|
865
861
|
}
|
|
866
862
|
};
|
|
867
863
|
};
|
package/dist/light.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("json-to-graphql-query"),require("axios"),require("collect.js")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios","collect.js"],y):(d=typeof globalThis<"u"?globalThis:d||self,y(d.light={},d.jsonToGraphqlQuery,d.axios,d.collect))})(this,function(d,y,O,k){"use strict";var de=Object.defineProperty;var ge=(d,y,O)=>y in d?de(d,y,{enumerable:!0,configurable:!0,writable:!0,value:O}):d[y]=O;var b=(d,y,O)=>ge(d,typeof y!="symbol"?y+"":y,O);function N(e){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);for(let u=0;u<s.length;u++)i[u]=s.charCodeAt(u);return n}function L(e){const t=new Uint8Array(e);let r="";for(const i of t)r+=String.fromCharCode(i);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var f="copy",m="convert";function S(e,t,r){if(t===f)return r;if(t===m)return e(r);if(t instanceof Array)return r.map(s=>S(e,t[0],s));if(t instanceof Object){const s={};for(const[n,i]of Object.entries(t)){if(i.derive){const u=i.derive(r);u!==void 0&&(r[n]=u)}if(!(n in r)){if(i.required)throw new Error(`Missing key: ${n}`);continue}if(r[n]==null){s[n]=null;continue}s[n]=S(e,i.schema,r[n])}return s}}function E(e,t){return{required:!0,schema:e,derive:t}}function p(e){return{required:!0,schema:e}}function h(e){return{required:!1,schema:e}}var T={type:p(f),id:p(m),transports:h(f)},U={appid:h(f),appidExclude:h(f),credProps:h(f)},J={appid:h(f),appidExclude:h(f),credProps:h(f)},I={publicKey:p({rp:p(f),user:p({id:p(m),name:p(f),displayName:p(f)}),challenge:p(m),pubKeyCredParams:p(f),timeout:h(f),excludeCredentials:h([T]),authenticatorSelection:h(f),attestation:h(f),extensions:h(U)}),signal:h(f)},W={type:p(f),id:p(f),rawId:p(m),authenticatorAttachment:h(f),response:p({clientDataJSON:p(m),attestationObject:p(m),transports:E(f,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:E(J,e=>e.getClientExtensionResults())},K={mediation:h(f),publicKey:p({challenge:p(m),timeout:h(f),rpId:h(f),allowCredentials:h([T]),userVerification:h(f),extensions:h(U)}),signal:h(f)},M={type:p(f),id:p(f),rawId:p(m),authenticatorAttachment:h(f),response:p({clientDataJSON:p(m),authenticatorData:p(m),signature:p(m),userHandle:p(m)}),clientExtensionResults:E(J,e=>e.getClientExtensionResults())};function z(e){return S(N,I,e)}function Q(e){return S(L,W,e)}function G(e){return S(N,K,e)}function $(e){return S(L,M,e)}async function H(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>Q(t),t}async function X(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>$(t),t}const Y=e=>({login:async t=>{const{app:r}=await w(e,{app:{auth:{webAuthnRequestOptions:{__args:{username:t}}}}}),s=r.auth.webAuthnRequestOptions,n=G({publicKey:s}),i=await X(n);await o(e,"webAuthnAssertion",{username:t,assertion:i.toJSON()})},register:async()=>{const{app:t}=await w(e,{app:{auth:{webAuthnCreationOptions:!0}}}),r=z({publicKey:t.auth.webAuthnCreationOptions}),s=await H(r);await o(e,"webAuthnRegister",{registration:s.toJSON()})}}),Z=e=>({WebAuthn:Y(e),google:{unlink:()=>o(e,"lightAuthUnlinkGoogle"),login:t=>o(e,"lightAuthLoginGoogle",{credential:t}),register:t=>o(e,"lightAuthRegisterGoogle",{credential:t})},facebook:{unlink:()=>o(e,"lightAuthUnlinkFacebook"),login:t=>o(e,"lightAuthLoginFacebook",{access_token:t}),register:t=>o(e,"lightAuthRegisterFacebook",{access_token:t})},microsoft:{unlink:()=>o(e,"lightAuthUnlinkMicrosoft"),login:t=>o(e,"lightAuthLoginMicrosoft",{access_token:t}),register:t=>o(e,"lightAuthRegisterMicrosoft",{account_id:t})},login:(t,r,s="")=>o(e,"login",{username:t,password:r,code:s}),logout:()=>o(e,"logout"),changeExpiredPassword:(t,r,s)=>o(e,"changeExpiredPassword",{username:t,old_password:r,new_password:s}),updatePassword:(t,r)=>o(e,"updatePassword",{old_password:t,new_password:r}),resetPassword:(t,r,s)=>o(e,"resetPassword",{username:t,password:r,code:s}),forgetPassword:(t,r)=>o(e,"forgetPassword",{username:t,email:r}),verifyCode(t,r){return o(e,"forgetPasswordVerifyCode",{username:t,code:r})},granted:async t=>(await w(e,{granted:{__args:{rights:t}}})).granted}),x=(e,t,r)=>{const s=t,n=e,i=r;let u="list"+t;const l=a=>i[a]?i[a]():null;return{field:l,$fields:i,setDataPath(a){return u=a,u},getDataPath(){return u},gqlFields(a){const c=[];for(const g of a)if(typeof g=="string"){const C=l(g);C&&c.push(C.getGQLField())}else typeof g=="object"&&c.push(g);return c},async update(a,c){return await o(n,"update"+s,{id:a,data:c})},async delete(a){return await o(n,"delete"+s,{id:a})},async add(a){return await o(n,"add"+s,{data:a})},fields(a){let c=[];for(let g of a){const C=l(g);C&&c.push(C)}return c},async get(a,c){return(await w(n,{["list"+s]:{__args:{filters:a},data:{__args:{limit:1},...B(c)}}}))["list"+s].data[0]},async list(a,c){return(await w(n,{["list"+s]:{__args:{filters:a},data:{...B(c)}}}))["list"+s].data}}};function ee(e){e="<~"+e+"~>";var t,r,s,n,i,u=String,l=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=[],n=0,i=e.length;i>n;n+=5)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(l&r>>24,l&r>>16,l&r>>8,l&r);return function(a,c){for(var g=c;g>0;g--)a.pop()}(s,t.length),u.fromCharCode.apply(u,s)}const P=(e="")=>{const t=e,r=(s="application/octet-stream")=>{const n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);const i=new Blob([n],{type:s});return URL.createObjectURL(i)};return{getContent:()=>t,getURL:r,download:s=>{const n=document.createElement("a");n.download=s,n.href=r(),document.body.appendChild(n),n.click(),document.body.removeChild(n)},open:s=>{window.open(r(s),"_blank")}}},te={fromBase85:e=>P(ee(e)),fromBase64:e=>P(atob(e)),fromString:e=>P(e)},R=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(r=>{Object.entries(R(r)).forEach(([s,n])=>{t[s]=n})}),t):(Object.entries(e).forEach(([r,s])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){t[r]=s;return}if(typeof s=="boolean"){t[r]=s;return}t[r]=R(s)}),t)},B=e=>R(e),w=async(e,t)=>{let r=y.jsonToGraphQLQuery(B(t));const s=await e.post("",{query:`{ ${r} }`});if(s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function re(e){for(let t=0;t<e.length;t++)if(e[t]instanceof File)return!0;return!1}function se(e){for(let t in e)if(e[t]instanceof File)return!0;return!1}const o=async(e,t,r=null,s=[])=>{let n={[t]:{}};const i=new FormData;let u=!1;if(r){const c={},g={},C={};let D=0;Object.entries(r).forEach(([v,F])=>{if(F instanceof Array&&re(F)){u=!0;let A=0;F.forEach(q=>{q instanceof File&&(c[v]=new y.VariableType(v),g[D]=["variables."+v+"."+A],i.append(D.toString(),q),D++)}),C[v]="[Upload!]!"}else F instanceof File?(u=!0,c[v]=new y.VariableType(v),g[D]=["variables."+v],i.append(D.toString(),F),C[v]="Upload!",D++):F instanceof Object&&se(F)?(u=!0,c[v]={},Object.entries(F).forEach(([A,q])=>{q instanceof File?(c[v][A]=new y.VariableType(A),g[D]=["variables."+A],i.append(D.toString(),q),C[A]="Upload!",D++):c[v][A]=q})):F!==void 0&&(c[v]=F)}),n[t].__args=c,n.__variables=C,u&&i.append("map",JSON.stringify(g))}Object.entries(B(s)).forEach(([c,g])=>{n[t][c]=g}),Object.entries(n[t]).length===0&&(n[t]=!0);let l=null;const a=y.jsonToGraphQLQuery({mutation:n});if(u?(i.append("operations",JSON.stringify({query:a})),l=await e.post("",i)):l=await e.post("",{query:a}),l.data.errors)throw new Error(l.data.errors[0].message);return l.data.data[t]},ne=e=>({uploadTempFile:t=>o(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=>o(e,"fsCreateFolder",{path:t}),delete:t=>o(e,"fsDeleteFolder",{path:t}),rename:(t,r)=>o(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)=>o(e,"fsWriteFile",{path:t,content:r}),delete:t=>o(e,"fsDeleteFile",{path:t}),rename:(t,r)=>o(e,"fsRenameFile",{path:t,name:r}),move:(t,r)=>o(e,"fsMoveFile",{source:t,target:r})}}),ie=e=>({get:async t=>(await e({config:{__args:{name:t}}})).config}),ae=e=>({send:(t,r,s)=>o(e,"sendMail",{email:t,subject:r,message:s})}),oe=e=>({list:async(t={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0})=>{const r=j("Users",e,t);return r.data_path="app.users",r.all()}}),le=e=>{const t=e,r={};return{create(s,n){r[s]=null;let i={};for(const u of Object.entries(n)){const[l,a]=u;i[l]=()=>({name:a.name?a.name:l,raw:a,getName:()=>a.name?a.name:l,getGQLField:()=>a.gqlField!==void 0?a.gqlField:a.name||l,getRaw(){return a},getValue(c){return a.field&&typeof a.field=="function"?a.field(c):a.field&&typeof a.field=="string"?c[a.field]:c[this.getName()]},getFormattedValue(c){const g=this.getValue(c);return a.format?a.format(g):g}})}r[s]=x(t,s,i)},get(s){return r[s]||this.create(s,{}),r[s]}}},ue=e=>({list:async(t={name:!0})=>{const{app:{roles:r}}=await w(e,{app:{roles:t}});return r}}),V=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap"],ce=["forPage","sortByDesc","sortBy","skip","take","splice","whereBetween","whereIn","whereNotBetween","whereNotIn","first","where","whereContains"],fe=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition","sole"];class _{constructor(t,r){b(this,"data_path","");b(this,"axios");b(this,"filters");b(this,"steps");b(this,"fields");b(this,"already_limit",!1);b(this,"already_offset",!1);b(this,"limit",null);b(this,"offset",null);b(this,"_sort",null);b(this,"_sortDesc",!1);b(this,"meta",{});this.axios=r,this.filters={},this.steps=[],this.fields=t}}_.prototype.dataPath=function(e){const t=this.clone();return t.data_path=e,t},_.prototype.buildArgs=function(){let e={};return Object.keys(this.filters).length>0&&(e.filters=this.filters),this._sort&&(e.sort=this._sort,this._sortDesc&&(e.sort+=":desc")),e},_.prototype.clone=function(){const e=Object.create(this);return e.steps=[...this.steps],e},k().macro("whereContains",function(e,t){return this.filter(r=>r[e].toLowerCase().includes(t.toLowerCase()))}),_.prototype.fetchData=async function(){let e={meta:{total:!0,key:!0,name:!0}};e.__args=this.buildArgs(),e.data=this.fields,this.already_limit&&(e.data.__args=e.data.__args||{},e.data.__args.limit=this.limit),this.already_offset&&(e.data.__args=e.data.__args||{},e.data.__args.offset=this.offset);const t=this.data_path.split(".");let r={},s=r,n=t[t.length-1];for(const l of t){if(l===n){s[l]=e;break}s[l]={},s=s[l]}let u=await w(this.axios,r);for(const l of t)u=u[l];return this.meta=u.meta,k(u.data)},_.prototype.processData=async function(){let e=null;for(const t of this.steps){if(V.includes(t.type)){e||(e=await this.fetchData()),e=e[t.type](...t.args);continue}if(t.type==="forPage"&&(e?e=e.forPage(t.args[0],t.args[1]):this.already_limit||this.already_offset?(e=await this.fetchData(),e=e.forPage(t.args[0],t.args[1])):(this.offset=(t.args[0]-1)*t.args[1],this.limit=t.args[1]),this.already_limit=!0,this.already_offset=!0),t.type==="where")if(e)e=e.where(...t.args);else{const r=t.args[0];let s="==",n=null;t.args.length==2&&(n=t.args[1]),t.args.length==3&&(s=t.args[1],n=t.args[2]),s==="=="&&(this.filters[r]=n),s==="<"&&(this.filters[r]={lt:n}),s==="<="&&(this.filters[r]={lte:n}),s===">"&&(this.filters[r]={gt:n}),s===">="&&(this.filters[r]={gte:n}),s==="!=="&&(this.filters[r]={ne:n})}t.type==="whereContains"&&(e?e=e.whereContains(...t.args):this.filters[t.args[0]]={contains:t.args[1]}),t.type==="whereIn"&&(e?e=e.whereIn(...t.args):this.filters[t.args[0]]={in:t.args[1]}),t.type==="whereNotBetween"&&(e?e=e.whereNotBetween(...t.args):this.filters[t.args[0]]={notBetween:t.args[1]}),t.type==="whereNotIn"&&(e?e=e.whereNotIn(...t.args):this.filters[t.args[0]]={notIn:t.args[1]}),t.type=="whereBetween"&&(e?e=e.whereBetween(...t.args):this.filters[t.args[0]]={between:t.args[1]}),t.type==="sortByDesc"&&(e?e=e.sortByDesc(t.args[0]):this.already_limit||this.already_offset?(e=await this.fetchData(),e=e.sortByDesc(t.args[0])):(this._sort=t.args[0],this._sortDesc=!0)),t.type==="sortBy"&&(e?e=e.sortBy(t.args[0]):this.already_limit||this.already_offset?(e=await this.fetchData(),e=e.sortBy(t.args[0])):this._sort=t.args[0]),t.type==="skip"&&(e?e=e.skip(t.args[0]):this.already_offset||this.already_limit?(e=await this.fetchData(),e=e.skip(t.args[0])):this.offset=t.args[0],this.already_offset=!0),t.type==="take"&&(e?e=e.take(...t.args):this.already_offset||this.already_limit?(e=await this.fetchData(),e=e.take(t.args[0])):this.limit=t.args[0],this.already_limit=!0),t.type==="splice"&&(e?e=e.splice(...t.args):(this.offset=t.args[0],this.limit=t.args[1]),this.already_limit=!0,this.already_offset=!0),t.type==="pop"&&(e?e=e.pop(...t.args):(e=await this.fetchData(),e.pop(...t.args))),t.type==="prepend"&&(e?e=e.prepend(...t.args):(e=await this.fetchData(),e.prepend(...t.args)))}return e||(e=await this.fetchData()),e},_.prototype.all=async function(){return(await this.processData()).all()};for(const e of[...V,...ce])_.prototype[e]=function(...t){const r=this.clone();return r.steps.push({type:e,args:t}),r};for(const e of fe)_.prototype[e]=async function(...t){return(await this.clone().processData())[e](...t)};_.prototype.average=_.prototype.avg,_.prototype.first=async function(){return this.take(1),(await this.processData()).first()},_.prototype.push=function(e){return this.steps.push({type:"push",args:[e]}),this},_.prototype.pop=async function(...e){const r=(await this.clone().processData()).pop(...e);return this.steps.push({type:"pop",args:e}),r},_.prototype.prepend=function(...e){return this.steps.push({type:"prepend",args:e}),this},_.prototype.shift=async function(...e){const r=(await this.clone().processData()).shift(...e);return this.steps.push({type:"shift",args:e}),r},_.prototype.transform=function(...e){return this.steps.push({type:"transform",args:e}),this};const j=(e,t,r)=>{const s=new _(r,t);return s.data_path="list"+e,s},pe=(e,t)=>({uploadTempFile:r=>o(t,"lightDriveUploadTempFile",{index:e,file:r},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async(r,s={name:!0,path:!0})=>(await w(t,{app:{drive:{__args:{index:e},folders:{__args:{path:r},...s}}}})).app.drive.folders,create:r=>o(t,"lightDriveCreateFolder",{index:e,path:r}),delete:r=>o(t,"lightDriveDeleteFolder",{index:e,path:r}),rename:(r,s)=>o(t,"lightDriveRenameFolder",{index:e,path:r,name:s})},files:{list:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await w(t,{app:{drive:{__args:{index:e},files:{__args:{path:r},...s}}}})).app.drive.files,get:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await w(t,{app:{drive:{__args:{index:e},file:{__args:{path:r},...s}}}})).app.drive.file,read:async r=>{let s=await w(t,{app:{drive:{__args:{index:e},file:{__args:{path:r},base64Content:!0}}}});return window.atob(s.app.drive.file.base64Content)},write:(r,s)=>o(t,"lightDriveWriteFile",{index:e,path:r,content:s}),delete:r=>o(t,"lightDriveDeleteFile",{index:e,path:r}),rename:(r,s)=>o(t,"lightDriveRenameFile",{index:e,path:r,name:s}),move:(r,s)=>o(t,"lightDriveMoveFile",{index:e,source:r,destination:s})}}),he=e=>{const t=O.create({baseURL:e,withCredentials:!0}),r=(i,u=null,l=[])=>o(t,i,u,l),s=i=>w(t,i),n=le(t);return{baseURL:e,axios:t,auth:Z(t),mutation:r,query:s,config:ie(s),mail:ae(t),users:oe(t),fs:ne(t),models:n,model(i){return n.get(i)},roles:ue(t),collect:(i,u)=>{const l=j(i,t,u);return l.data_path=n.get(i).getDataPath(),l},drive(i){return pe(i,t)}}};d.File=te,d.createClient=he,d.createCollection=j,d.file=P,d.mutation=o,d.query=w,d.toQuery=B,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("json-to-graphql-query"),require("axios"),require("collect.js")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios","collect.js"],y):(d=typeof globalThis<"u"?globalThis:d||self,y(d.light={},d.jsonToGraphqlQuery,d.axios,d.collect))})(this,function(d,y,O,k){"use strict";var de=Object.defineProperty;var ge=(d,y,O)=>y in d?de(d,y,{enumerable:!0,configurable:!0,writable:!0,value:O}):d[y]=O;var b=(d,y,O)=>ge(d,typeof y!="symbol"?y+"":y,O);function N(e){const t="==".slice(0,(4-e.length%4)%4),r=e.replace(/-/g,"+").replace(/_/g,"/")+t,s=atob(r),n=new ArrayBuffer(s.length),o=new Uint8Array(n);for(let u=0;u<s.length;u++)o[u]=s.charCodeAt(u);return n}function L(e){const t=new Uint8Array(e);let r="";for(const o of t)r+=String.fromCharCode(o);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var f="copy",m="convert";function S(e,t,r){if(t===f)return r;if(t===m)return e(r);if(t instanceof Array)return r.map(s=>S(e,t[0],s));if(t instanceof Object){const s={};for(const[n,o]of Object.entries(t)){if(o.derive){const u=o.derive(r);u!==void 0&&(r[n]=u)}if(!(n in r)){if(o.required)throw new Error(`Missing key: ${n}`);continue}if(r[n]==null){s[n]=null;continue}s[n]=S(e,o.schema,r[n])}return s}}function E(e,t){return{required:!0,schema:e,derive:t}}function p(e){return{required:!0,schema:e}}function h(e){return{required:!1,schema:e}}var T={type:p(f),id:p(m),transports:h(f)},U={appid:h(f),appidExclude:h(f),credProps:h(f)},J={appid:h(f),appidExclude:h(f),credProps:h(f)},I={publicKey:p({rp:p(f),user:p({id:p(m),name:p(f),displayName:p(f)}),challenge:p(m),pubKeyCredParams:p(f),timeout:h(f),excludeCredentials:h([T]),authenticatorSelection:h(f),attestation:h(f),extensions:h(U)}),signal:h(f)},W={type:p(f),id:p(f),rawId:p(m),authenticatorAttachment:h(f),response:p({clientDataJSON:p(m),attestationObject:p(m),transports:E(f,e=>{var t;return((t=e.getTransports)==null?void 0:t.call(e))||[]})}),clientExtensionResults:E(J,e=>e.getClientExtensionResults())},K={mediation:h(f),publicKey:p({challenge:p(m),timeout:h(f),rpId:h(f),allowCredentials:h([T]),userVerification:h(f),extensions:h(U)}),signal:h(f)},M={type:p(f),id:p(f),rawId:p(m),authenticatorAttachment:h(f),response:p({clientDataJSON:p(m),authenticatorData:p(m),signature:p(m),userHandle:p(m)}),clientExtensionResults:E(J,e=>e.getClientExtensionResults())};function z(e){return S(N,I,e)}function Q(e){return S(L,W,e)}function G(e){return S(N,K,e)}function $(e){return S(L,M,e)}async function H(e){const t=await navigator.credentials.create(e);return t.toJSON=()=>Q(t),t}async function X(e){const t=await navigator.credentials.get(e);return t.toJSON=()=>$(t),t}const Y=e=>({login:async()=>{const{app:t}=await w(e,{app:{auth:{webAuthnRequestOptions:!0}}}),r=t.auth.webAuthnRequestOptions,s=G({publicKey:r}),n=await X(s);await a(e,"webAuthnAssertion",{assertion:n.toJSON()})},register:async()=>{const{app:t}=await w(e,{app:{auth:{webAuthnCreationOptions:!0}}}),r=z({publicKey:t.auth.webAuthnCreationOptions}),s=await H(r);await a(e,"webAuthnRegister",{registration:s.toJSON()})}}),Z=e=>({WebAuthn:Y(e),google:{unlink:()=>a(e,"lightAuthUnlinkGoogle"),login:t=>a(e,"lightAuthLoginGoogle",{credential:t}),register:t=>a(e,"lightAuthRegisterGoogle",{credential:t})},facebook:{unlink:()=>a(e,"lightAuthUnlinkFacebook"),login:t=>a(e,"lightAuthLoginFacebook",{access_token:t}),register:t=>a(e,"lightAuthRegisterFacebook",{access_token:t})},microsoft:{unlink:()=>a(e,"lightAuthUnlinkMicrosoft"),login:t=>a(e,"lightAuthLoginMicrosoft",{access_token:t}),register:t=>a(e,"lightAuthRegisterMicrosoft",{account_id:t})},login:(t,r,s="")=>a(e,"login",{username:t,password:r,code:s}),logout:()=>a(e,"logout"),changeExpiredPassword:(t,r,s)=>a(e,"changeExpiredPassword",{username:t,old_password:r,new_password:s}),updatePassword:(t,r)=>a(e,"updatePassword",{old_password:t,new_password:r}),resetPassword:(t,r,s)=>a(e,"resetPassword",{username:t,password:r,code:s}),forgetPassword:(t,r)=>a(e,"forgetPassword",{username:t,email:r}),verifyCode(t,r){return a(e,"forgetPasswordVerifyCode",{username:t,code:r})},granted:async t=>(await w(e,{granted:{__args:{rights:t}}})).granted}),x=(e,t,r)=>{const s=t,n=e,o=r;let u="list"+t;const l=i=>o[i]?o[i]():null;return{field:l,$fields:o,setDataPath(i){return u=i,u},getDataPath(){return u},gqlFields(i){const c=[];for(const g of i)if(typeof g=="string"){const C=l(g);C&&c.push(C.getGQLField())}else typeof g=="object"&&c.push(g);return c},async update(i,c){return await a(n,"update"+s,{id:i,data:c})},async delete(i){return await a(n,"delete"+s,{id:i})},async add(i){return await a(n,"add"+s,{data:i})},fields(i){let c=[];for(let g of i){const C=l(g);C&&c.push(C)}return c},async get(i,c){return(await w(n,{["list"+s]:{__args:{filters:i},data:{__args:{limit:1},...B(c)}}}))["list"+s].data[0]},async list(i,c){return(await w(n,{["list"+s]:{__args:{filters:i},data:{...B(c)}}}))["list"+s].data}}};function ee(e){e="<~"+e+"~>";var t,r,s,n,o,u=String,l=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=[],n=0,o=e.length;o>n;n+=5)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(l&r>>24,l&r>>16,l&r>>8,l&r);return function(i,c){for(var g=c;g>0;g--)i.pop()}(s,t.length),u.fromCharCode.apply(u,s)}const P=(e="")=>{const t=e,r=(s="application/octet-stream")=>{const n=new Uint8Array(t.length);for(let l=0;l<t.length;l++)n[l]=t.charCodeAt(l);const o=new Blob([n],{type:s});return URL.createObjectURL(o)};return{getContent:()=>t,getURL:r,download:s=>{const n=document.createElement("a");n.download=s,n.href=r(),document.body.appendChild(n),n.click(),document.body.removeChild(n)},open:s=>{window.open(r(s),"_blank")}}},te={fromBase85:e=>P(ee(e)),fromBase64:e=>P(atob(e)),fromString:e=>P(e)},R=e=>{let t={};return typeof e=="string"?(t[e]=!0,t):e instanceof Array?(e.forEach(r=>{Object.entries(R(r)).forEach(([s,n])=>{t[s]=n})}),t):(Object.entries(e).forEach(([r,s])=>{if(r=="__args"||r=="__aliasFor"||r=="__variables"||r=="__directives"||r=="__all_on"||r=="__name"){t[r]=s;return}if(typeof s=="boolean"){t[r]=s;return}t[r]=R(s)}),t)},B=e=>R(e),w=async(e,t)=>{let r=y.jsonToGraphQLQuery(B(t));const s=await e.post("",{query:`{ ${r} }`});if(s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data};function re(e){for(let t=0;t<e.length;t++)if(e[t]instanceof File)return!0;return!1}function se(e){for(let t in e)if(e[t]instanceof File)return!0;return!1}const a=async(e,t,r=null,s=[])=>{let n={[t]:{}};const o=new FormData;let u=!1;if(r){const c={},g={},C={};let D=0;Object.entries(r).forEach(([v,F])=>{if(F instanceof Array&&re(F)){u=!0;let A=0;F.forEach(q=>{q instanceof File&&(c[v]=new y.VariableType(v),g[D]=["variables."+v+"."+A],o.append(D.toString(),q),D++)}),C[v]="[Upload!]!"}else F instanceof File?(u=!0,c[v]=new y.VariableType(v),g[D]=["variables."+v],o.append(D.toString(),F),C[v]="Upload!",D++):F instanceof Object&&se(F)?(u=!0,c[v]={},Object.entries(F).forEach(([A,q])=>{q instanceof File?(c[v][A]=new y.VariableType(A),g[D]=["variables."+A],o.append(D.toString(),q),C[A]="Upload!",D++):c[v][A]=q})):F!==void 0&&(c[v]=F)}),n[t].__args=c,n.__variables=C,u&&o.append("map",JSON.stringify(g))}Object.entries(B(s)).forEach(([c,g])=>{n[t][c]=g}),Object.entries(n[t]).length===0&&(n[t]=!0);let l=null;const i=y.jsonToGraphQLQuery({mutation:n});if(u?(o.append("operations",JSON.stringify({query:i})),l=await e.post("",o)):l=await e.post("",{query:i}),l.data.errors)throw new Error(l.data.errors[0].message);return l.data.data[t]},ne=e=>({uploadTempFile:t=>a(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=>a(e,"fsCreateFolder",{path:t}),delete:t=>a(e,"fsDeleteFolder",{path:t}),rename:(t,r)=>a(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)=>a(e,"fsWriteFile",{path:t,content:r}),delete:t=>a(e,"fsDeleteFile",{path:t}),rename:(t,r)=>a(e,"fsRenameFile",{path:t,name:r}),move:(t,r)=>a(e,"fsMoveFile",{source:t,target:r})}}),ie=e=>({get:async t=>(await e({config:{__args:{name:t}}})).config}),ae=e=>({send:(t,r,s)=>a(e,"sendMail",{email:t,subject:r,message:s})}),oe=e=>({list:async(t={user_id:!0,username:!0,first_name:!0,last_name:!0,status:!0})=>{const r=j("Users",e,t);return r.data_path="app.users",r.all()}}),le=e=>{const t=e,r={};return{create(s,n){r[s]=null;let o={};for(const u of Object.entries(n)){const[l,i]=u;o[l]=()=>({name:i.name?i.name:l,raw:i,getName:()=>i.name?i.name:l,getGQLField:()=>i.gqlField!==void 0?i.gqlField:i.name||l,getRaw(){return i},getValue(c){return i.field&&typeof i.field=="function"?i.field(c):i.field&&typeof i.field=="string"?c[i.field]:c[this.getName()]},getFormattedValue(c){const g=this.getValue(c);return i.format?i.format(g):g}})}r[s]=x(t,s,o)},get(s){return r[s]||this.create(s,{}),r[s]}}},ue=e=>({list:async(t={name:!0})=>{const{app:{roles:r}}=await w(e,{app:{roles:t}});return r}}),V=["flatMap","chunk","shuffle","splice","sortBy","map","reverse","groupBy","keyBy","keys","mapToDictionary","mapWithKeys","nth","skipUntil","skipWhile","takeUntil","takeWhile","unique","pluck","push","only","pad","slice","tap","sort"],ce=["forPage","sortByDesc","sortBy","skip","take","splice","whereBetween","whereIn","whereNotBetween","whereNotIn","first","where","whereContains"],fe=["avg","count","countBy","dd","each","every","filter","firstWhere","isEmpty","isNotEmpty","last","mapToGroups","max","median","min","mode","contains","sole","sort","split","sum","toJson","get","has","implode","partition","sole"];class _{constructor(t,r){b(this,"data_path","");b(this,"axios");b(this,"filters");b(this,"steps");b(this,"fields");b(this,"already_limit",!1);b(this,"already_offset",!1);b(this,"limit",null);b(this,"offset",null);b(this,"_sort",null);b(this,"_sortDesc",!1);b(this,"meta",{});this.axios=r,this.filters={},this.steps=[],this.fields=t}}_.prototype.dataPath=function(e){const t=this.clone();return t.data_path=e,t},_.prototype.buildArgs=function(){let e={};return Object.keys(this.filters).length>0&&(e.filters=this.filters),this._sort&&(e.sort=this._sort,this._sortDesc&&(e.sort+=":desc")),e},_.prototype.clone=function(){const e=Object.create(this);return e.steps=[...this.steps],e},k().macro("whereContains",function(e,t){return this.filter(r=>r[e].toLowerCase().includes(t.toLowerCase()))}),_.prototype.fetchData=async function(){let e={meta:{total:!0,key:!0,name:!0}};e.__args=this.buildArgs(),e.data=this.fields,this.already_limit&&(e.data.__args=e.data.__args||{},e.data.__args.limit=this.limit),this.already_offset&&(e.data.__args=e.data.__args||{},e.data.__args.offset=this.offset);const t=this.data_path.split(".");let r={},s=r,n=t[t.length-1];for(const l of t){if(l===n){s[l]=e;break}s[l]={},s=s[l]}let u=await w(this.axios,r);for(const l of t)u=u[l];return this.meta=u.meta,k(u.data)},_.prototype.processData=async function(){let e=null;for(const t of this.steps){if(V.includes(t.type)){e||(e=await this.fetchData()),e=e[t.type](...t.args);continue}if(t.type==="forPage"&&(e?e=e.forPage(t.args[0],t.args[1]):this.already_limit||this.already_offset?(e=await this.fetchData(),e=e.forPage(t.args[0],t.args[1])):(this.offset=(t.args[0]-1)*t.args[1],this.limit=t.args[1]),this.already_limit=!0,this.already_offset=!0),t.type==="where")if(e)e=e.where(...t.args);else{const r=t.args[0];let s="==",n=null;t.args.length==2&&(n=t.args[1]),t.args.length==3&&(s=t.args[1],n=t.args[2]),s==="=="&&(this.filters[r]=n),s==="<"&&(this.filters[r]={lt:n}),s==="<="&&(this.filters[r]={lte:n}),s===">"&&(this.filters[r]={gt:n}),s===">="&&(this.filters[r]={gte:n}),s==="!=="&&(this.filters[r]={ne:n})}t.type==="whereContains"&&(e?e=e.whereContains(...t.args):this.filters[t.args[0]]={contains:t.args[1]}),t.type==="whereIn"&&(e?e=e.whereIn(...t.args):this.filters[t.args[0]]={in:t.args[1]}),t.type==="whereNotBetween"&&(e?e=e.whereNotBetween(...t.args):this.filters[t.args[0]]={notBetween:t.args[1]}),t.type==="whereNotIn"&&(e?e=e.whereNotIn(...t.args):this.filters[t.args[0]]={notIn:t.args[1]}),t.type=="whereBetween"&&(e?e=e.whereBetween(...t.args):this.filters[t.args[0]]={between:t.args[1]}),t.type==="sortByDesc"&&(e?e=e.sortByDesc(t.args[0]):this.already_limit||this.already_offset?(e=await this.fetchData(),e=e.sortByDesc(t.args[0])):(this._sort=t.args[0],this._sortDesc=!0)),t.type==="sortBy"&&(e?e=e.sortBy(t.args[0]):this.already_limit||this.already_offset?(e=await this.fetchData(),e=e.sortBy(t.args[0])):this._sort=t.args[0]),t.type==="skip"&&(e?e=e.skip(t.args[0]):this.already_offset||this.already_limit?(e=await this.fetchData(),e=e.skip(t.args[0])):this.offset=t.args[0],this.already_offset=!0),t.type==="take"&&(e?e=e.take(...t.args):this.already_offset||this.already_limit?(e=await this.fetchData(),e=e.take(t.args[0])):this.limit=t.args[0],this.already_limit=!0),t.type==="splice"&&(e?e=e.splice(...t.args):(this.offset=t.args[0],this.limit=t.args[1]),this.already_limit=!0,this.already_offset=!0),t.type==="pop"&&(e?e=e.pop(...t.args):(e=await this.fetchData(),e.pop(...t.args))),t.type==="prepend"&&(e?e=e.prepend(...t.args):(e=await this.fetchData(),e.prepend(...t.args)))}return e||(e=await this.fetchData()),e},_.prototype.all=async function(){return(await this.processData()).all()};for(const e of[...V,...ce])_.prototype[e]=function(...t){const r=this.clone();return r.steps.push({type:e,args:t}),r};for(const e of fe)_.prototype[e]=async function(...t){return(await this.clone().processData())[e](...t)};_.prototype.average=_.prototype.avg,_.prototype.first=async function(){return this.take(1),(await this.processData()).first()},_.prototype.push=function(e){return this.steps.push({type:"push",args:[e]}),this},_.prototype.pop=async function(...e){const r=(await this.clone().processData()).pop(...e);return this.steps.push({type:"pop",args:e}),r},_.prototype.prepend=function(...e){return this.steps.push({type:"prepend",args:e}),this},_.prototype.shift=async function(...e){const r=(await this.clone().processData()).shift(...e);return this.steps.push({type:"shift",args:e}),r},_.prototype.transform=function(...e){return this.steps.push({type:"transform",args:e}),this};const j=(e,t,r)=>{const s=new _(r,t);return s.data_path="list"+e,s},pe=(e,t)=>({uploadTempFile:r=>a(t,"lightDriveUploadTempFile",{index:e,file:r},{name:!0,path:!0,size:!0,mime:!0}),folders:{list:async(r,s={name:!0,path:!0})=>(await w(t,{app:{drive:{__args:{index:e},folders:{__args:{path:r},...s}}}})).app.drive.folders,create:r=>a(t,"lightDriveCreateFolder",{index:e,path:r}),delete:r=>a(t,"lightDriveDeleteFolder",{index:e,path:r}),rename:(r,s)=>a(t,"lightDriveRenameFolder",{index:e,path:r,name:s})},files:{list:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await w(t,{app:{drive:{__args:{index:e},files:{__args:{path:r},...s}}}})).app.drive.files,get:async(r,s={name:!0,path:!0,size:!0,mime:!0,url:!0})=>(await w(t,{app:{drive:{__args:{index:e},file:{__args:{path:r},...s}}}})).app.drive.file,read:async r=>{let s=await w(t,{app:{drive:{__args:{index:e},file:{__args:{path:r},base64Content:!0}}}});return window.atob(s.app.drive.file.base64Content)},write:(r,s)=>a(t,"lightDriveWriteFile",{index:e,path:r,content:s}),delete:r=>a(t,"lightDriveDeleteFile",{index:e,path:r}),rename:(r,s)=>a(t,"lightDriveRenameFile",{index:e,path:r,name:s}),move:(r,s)=>a(t,"lightDriveMoveFile",{index:e,source:r,destination:s})}}),he=e=>{const t=O.create({baseURL:e,withCredentials:!0}),r=(o,u=null,l=[])=>a(t,o,u,l),s=o=>w(t,o),n=le(t);return{baseURL:e,axios:t,auth:Z(t),mutation:r,query:s,config:ie(s),mail:ae(t),users:oe(t),fs:ne(t),models:n,model(o){return n.get(o)},roles:ue(t),collect:(o,u)=>{const l=j(o,t,u);return l.data_path=n.get(o).getDataPath(),l},drive(o){return pe(o,t)}}};d.File=te,d.createClient=he,d.createCollection=j,d.file=P,d.mutation=a,d.query=w,d.toQuery=B,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/dist/webauthn.d.ts
CHANGED