@hostlink/light 2.5.4 → 2.7.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 +4 -4
- package/dist/createClient.d.ts +5 -0
- package/dist/createCollection.d.ts +1 -0
- package/dist/light.js +505 -447
- package/dist/light.umd.cjs +1 -1
- package/dist/webauthn.d.ts +1 -1
- package/package.json +1 -1
package/dist/light.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
var
|
|
2
|
-
var V = (
|
|
3
|
-
var
|
|
4
|
-
import { jsonToGraphQLQuery as
|
|
1
|
+
var T = Object.defineProperty;
|
|
2
|
+
var V = (t, e, r) => e in t ? T(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var C = (t, e, r) => V(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { jsonToGraphQLQuery as E, VariableType as S } from "json-to-graphql-query";
|
|
5
5
|
import W from "axios";
|
|
6
|
-
import
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
for (let
|
|
10
|
-
|
|
6
|
+
import N from "collect.js";
|
|
7
|
+
function R(t) {
|
|
8
|
+
const e = "==".slice(0, (4 - t.length % 4) % 4), r = t.replace(/-/g, "+").replace(/_/g, "/") + e, s = atob(r), n = new ArrayBuffer(s.length), i = new Uint8Array(n);
|
|
9
|
+
for (let c = 0; c < s.length; c++)
|
|
10
|
+
i[c] = s.charCodeAt(c);
|
|
11
11
|
return n;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
13
|
+
function J(t) {
|
|
14
|
+
const e = new Uint8Array(t);
|
|
15
15
|
let r = "";
|
|
16
|
-
for (const
|
|
17
|
-
r += String.fromCharCode(
|
|
16
|
+
for (const i of e)
|
|
17
|
+
r += String.fromCharCode(i);
|
|
18
18
|
return btoa(r).replace(/\+/g, "-").replace(
|
|
19
19
|
/\//g,
|
|
20
20
|
"_"
|
|
21
21
|
).replace(/=/g, "");
|
|
22
22
|
}
|
|
23
|
-
var f = "copy",
|
|
24
|
-
function
|
|
25
|
-
if (
|
|
23
|
+
var f = "copy", F = "convert";
|
|
24
|
+
function D(t, e, r) {
|
|
25
|
+
if (e === f)
|
|
26
26
|
return r;
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
29
|
-
if (
|
|
30
|
-
return r.map((s) =>
|
|
31
|
-
if (
|
|
27
|
+
if (e === F)
|
|
28
|
+
return t(r);
|
|
29
|
+
if (e instanceof Array)
|
|
30
|
+
return r.map((s) => D(t, e[0], s));
|
|
31
|
+
if (e instanceof Object) {
|
|
32
32
|
const s = {};
|
|
33
|
-
for (const [n,
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
33
|
+
for (const [n, i] of Object.entries(e)) {
|
|
34
|
+
if (i.derive) {
|
|
35
|
+
const c = i.derive(r);
|
|
36
|
+
c !== void 0 && (r[n] = c);
|
|
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
|
}
|
|
@@ -44,328 +44,323 @@ function A(e, t, r) {
|
|
|
44
44
|
s[n] = null;
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
s[n] =
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
s[n] = D(
|
|
48
|
+
t,
|
|
49
|
+
i.schema,
|
|
50
50
|
r[n]
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
return s;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function q(t, e) {
|
|
57
57
|
return {
|
|
58
58
|
required: !0,
|
|
59
|
-
schema:
|
|
60
|
-
derive:
|
|
59
|
+
schema: t,
|
|
60
|
+
derive: e
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function h(t) {
|
|
64
64
|
return {
|
|
65
65
|
required: !0,
|
|
66
|
-
schema:
|
|
66
|
+
schema: t
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function g(t) {
|
|
70
70
|
return {
|
|
71
71
|
required: !1,
|
|
72
|
-
schema:
|
|
72
|
+
schema: t
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
var
|
|
76
|
-
type:
|
|
77
|
-
id:
|
|
78
|
-
transports:
|
|
75
|
+
var B = {
|
|
76
|
+
type: h(f),
|
|
77
|
+
id: h(F),
|
|
78
|
+
transports: g(f)
|
|
79
|
+
}, j = {
|
|
80
|
+
appid: g(f),
|
|
81
|
+
appidExclude: g(f),
|
|
82
|
+
credProps: g(f)
|
|
79
83
|
}, U = {
|
|
80
|
-
appid:
|
|
81
|
-
appidExclude:
|
|
82
|
-
credProps:
|
|
83
|
-
}, L = {
|
|
84
|
-
appid: h(f),
|
|
85
|
-
appidExclude: h(f),
|
|
86
|
-
credProps: h(f)
|
|
84
|
+
appid: g(f),
|
|
85
|
+
appidExclude: g(f),
|
|
86
|
+
credProps: g(f)
|
|
87
87
|
}, K = {
|
|
88
|
-
publicKey:
|
|
89
|
-
rp:
|
|
90
|
-
user:
|
|
91
|
-
id:
|
|
92
|
-
name:
|
|
93
|
-
displayName:
|
|
88
|
+
publicKey: h({
|
|
89
|
+
rp: h(f),
|
|
90
|
+
user: h({
|
|
91
|
+
id: h(F),
|
|
92
|
+
name: h(f),
|
|
93
|
+
displayName: h(f)
|
|
94
94
|
}),
|
|
95
|
-
challenge:
|
|
96
|
-
pubKeyCredParams:
|
|
97
|
-
timeout:
|
|
98
|
-
excludeCredentials:
|
|
99
|
-
authenticatorSelection:
|
|
100
|
-
attestation:
|
|
101
|
-
extensions:
|
|
95
|
+
challenge: h(F),
|
|
96
|
+
pubKeyCredParams: h(f),
|
|
97
|
+
timeout: g(f),
|
|
98
|
+
excludeCredentials: g([B]),
|
|
99
|
+
authenticatorSelection: g(f),
|
|
100
|
+
attestation: g(f),
|
|
101
|
+
extensions: g(j)
|
|
102
102
|
}),
|
|
103
|
-
signal:
|
|
103
|
+
signal: g(f)
|
|
104
104
|
}, M = {
|
|
105
|
-
type:
|
|
106
|
-
id:
|
|
107
|
-
rawId:
|
|
108
|
-
authenticatorAttachment:
|
|
109
|
-
response:
|
|
110
|
-
clientDataJSON:
|
|
111
|
-
attestationObject:
|
|
112
|
-
transports:
|
|
105
|
+
type: h(f),
|
|
106
|
+
id: h(f),
|
|
107
|
+
rawId: h(F),
|
|
108
|
+
authenticatorAttachment: g(f),
|
|
109
|
+
response: h({
|
|
110
|
+
clientDataJSON: h(F),
|
|
111
|
+
attestationObject: h(F),
|
|
112
|
+
transports: q(
|
|
113
113
|
f,
|
|
114
|
-
(
|
|
115
|
-
var
|
|
116
|
-
return ((
|
|
114
|
+
(t) => {
|
|
115
|
+
var e;
|
|
116
|
+
return ((e = t.getTransports) == null ? void 0 : e.call(t)) || [];
|
|
117
117
|
}
|
|
118
118
|
)
|
|
119
119
|
}),
|
|
120
|
-
clientExtensionResults:
|
|
121
|
-
|
|
122
|
-
(
|
|
120
|
+
clientExtensionResults: q(
|
|
121
|
+
U,
|
|
122
|
+
(t) => t.getClientExtensionResults()
|
|
123
123
|
)
|
|
124
124
|
}, G = {
|
|
125
|
-
mediation:
|
|
126
|
-
publicKey:
|
|
127
|
-
challenge:
|
|
128
|
-
timeout:
|
|
129
|
-
rpId:
|
|
130
|
-
allowCredentials:
|
|
131
|
-
userVerification:
|
|
132
|
-
extensions:
|
|
125
|
+
mediation: g(f),
|
|
126
|
+
publicKey: h({
|
|
127
|
+
challenge: h(F),
|
|
128
|
+
timeout: g(f),
|
|
129
|
+
rpId: g(f),
|
|
130
|
+
allowCredentials: g([B]),
|
|
131
|
+
userVerification: g(f),
|
|
132
|
+
extensions: g(j)
|
|
133
133
|
}),
|
|
134
|
-
signal:
|
|
135
|
-
},
|
|
136
|
-
type:
|
|
137
|
-
id:
|
|
138
|
-
rawId:
|
|
139
|
-
authenticatorAttachment:
|
|
140
|
-
response:
|
|
141
|
-
clientDataJSON:
|
|
142
|
-
authenticatorData:
|
|
143
|
-
signature:
|
|
144
|
-
userHandle:
|
|
134
|
+
signal: g(f)
|
|
135
|
+
}, I = {
|
|
136
|
+
type: h(f),
|
|
137
|
+
id: h(f),
|
|
138
|
+
rawId: h(F),
|
|
139
|
+
authenticatorAttachment: g(f),
|
|
140
|
+
response: h({
|
|
141
|
+
clientDataJSON: h(F),
|
|
142
|
+
authenticatorData: h(F),
|
|
143
|
+
signature: h(F),
|
|
144
|
+
userHandle: h(F)
|
|
145
145
|
}),
|
|
146
|
-
clientExtensionResults:
|
|
147
|
-
|
|
148
|
-
(
|
|
146
|
+
clientExtensionResults: q(
|
|
147
|
+
U,
|
|
148
|
+
(t) => t.getClientExtensionResults()
|
|
149
149
|
)
|
|
150
150
|
};
|
|
151
|
-
function Q(
|
|
152
|
-
return
|
|
151
|
+
function Q(t) {
|
|
152
|
+
return D(R, K, t);
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
return
|
|
156
|
-
|
|
154
|
+
function z(t) {
|
|
155
|
+
return D(
|
|
156
|
+
J,
|
|
157
157
|
M,
|
|
158
|
-
|
|
158
|
+
t
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
return
|
|
161
|
+
function $(t) {
|
|
162
|
+
return D(R, G, t);
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
function H(t) {
|
|
165
|
+
return D(
|
|
166
|
+
J,
|
|
167
|
+
I,
|
|
168
|
+
t
|
|
169
169
|
);
|
|
170
170
|
}
|
|
171
|
-
async function
|
|
172
|
-
const
|
|
173
|
-
|
|
171
|
+
async function X(t) {
|
|
172
|
+
const e = await navigator.credentials.create(
|
|
173
|
+
t
|
|
174
174
|
);
|
|
175
|
-
return
|
|
175
|
+
return e.toJSON = () => z(e), e;
|
|
176
176
|
}
|
|
177
|
-
async function
|
|
178
|
-
const
|
|
179
|
-
|
|
177
|
+
async function Y(t) {
|
|
178
|
+
const e = await navigator.credentials.get(
|
|
179
|
+
t
|
|
180
180
|
);
|
|
181
|
-
return
|
|
181
|
+
return e.toJSON = () => H(e), e;
|
|
182
182
|
}
|
|
183
|
-
const
|
|
184
|
-
login: async (
|
|
185
|
-
const { app:
|
|
183
|
+
const Z = (t) => ({
|
|
184
|
+
login: async () => {
|
|
185
|
+
const { app: e } = await m(t, {
|
|
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
|
-
}),
|
|
198
|
-
await
|
|
199
|
-
|
|
200
|
-
assertion: a.toJSON()
|
|
191
|
+
}), r = e.auth.webAuthnRequestOptions, s = $({
|
|
192
|
+
publicKey: r
|
|
193
|
+
}), n = await Y(s);
|
|
194
|
+
await u(t, "webAuthnAssertion", {
|
|
195
|
+
assertion: n.toJSON()
|
|
201
196
|
});
|
|
202
197
|
},
|
|
203
198
|
register: async () => {
|
|
204
|
-
const { app:
|
|
199
|
+
const { app: e } = await m(t, {
|
|
205
200
|
app: {
|
|
206
201
|
auth: {
|
|
207
202
|
webAuthnCreationOptions: !0
|
|
208
203
|
}
|
|
209
204
|
}
|
|
210
205
|
}), r = Q({
|
|
211
|
-
publicKey:
|
|
212
|
-
}), s = await
|
|
213
|
-
await
|
|
206
|
+
publicKey: e.auth.webAuthnCreationOptions
|
|
207
|
+
}), s = await X(r);
|
|
208
|
+
await u(t, "webAuthnRegister", {
|
|
214
209
|
registration: s.toJSON()
|
|
215
210
|
});
|
|
216
211
|
}
|
|
217
|
-
}),
|
|
218
|
-
WebAuthn:
|
|
212
|
+
}), x = (t) => ({
|
|
213
|
+
WebAuthn: Z(t),
|
|
219
214
|
google: {
|
|
220
|
-
unlink: () =>
|
|
221
|
-
login: (
|
|
222
|
-
credential:
|
|
215
|
+
unlink: () => u(t, "lightAuthUnlinkGoogle"),
|
|
216
|
+
login: (e) => u(t, "lightAuthLoginGoogle", {
|
|
217
|
+
credential: e
|
|
223
218
|
}),
|
|
224
|
-
register: (
|
|
225
|
-
credential:
|
|
219
|
+
register: (e) => u(t, "lightAuthRegisterGoogle", {
|
|
220
|
+
credential: e
|
|
226
221
|
})
|
|
227
222
|
},
|
|
228
223
|
facebook: {
|
|
229
|
-
unlink: () =>
|
|
230
|
-
login: (
|
|
231
|
-
access_token:
|
|
224
|
+
unlink: () => u(t, "lightAuthUnlinkFacebook"),
|
|
225
|
+
login: (e) => u(t, "lightAuthLoginFacebook", {
|
|
226
|
+
access_token: e
|
|
232
227
|
}),
|
|
233
|
-
register: (
|
|
234
|
-
access_token:
|
|
228
|
+
register: (e) => u(t, "lightAuthRegisterFacebook", {
|
|
229
|
+
access_token: e
|
|
235
230
|
})
|
|
236
231
|
},
|
|
237
232
|
microsoft: {
|
|
238
|
-
unlink: () =>
|
|
239
|
-
login: (
|
|
240
|
-
access_token:
|
|
233
|
+
unlink: () => u(t, "lightAuthUnlinkMicrosoft"),
|
|
234
|
+
login: (e) => u(t, "lightAuthLoginMicrosoft", {
|
|
235
|
+
access_token: e
|
|
241
236
|
}),
|
|
242
|
-
register: (
|
|
243
|
-
account_id:
|
|
237
|
+
register: (e) => u(t, "lightAuthRegisterMicrosoft", {
|
|
238
|
+
account_id: e
|
|
244
239
|
})
|
|
245
240
|
},
|
|
246
|
-
login: (
|
|
247
|
-
username:
|
|
241
|
+
login: (e, r, s = "") => u(t, "login", {
|
|
242
|
+
username: e,
|
|
248
243
|
password: r,
|
|
249
244
|
code: s
|
|
250
245
|
}),
|
|
251
|
-
logout: () =>
|
|
252
|
-
changeExpiredPassword: (
|
|
253
|
-
username:
|
|
246
|
+
logout: () => u(t, "logout"),
|
|
247
|
+
changeExpiredPassword: (e, r, s) => u(t, "changeExpiredPassword", {
|
|
248
|
+
username: e,
|
|
254
249
|
old_password: r,
|
|
255
250
|
new_password: s
|
|
256
251
|
}),
|
|
257
|
-
updatePassword: (
|
|
258
|
-
old_password:
|
|
252
|
+
updatePassword: (e, r) => u(t, "updatePassword", {
|
|
253
|
+
old_password: e,
|
|
259
254
|
new_password: r
|
|
260
255
|
}),
|
|
261
|
-
resetPassword: (
|
|
262
|
-
|
|
256
|
+
resetPassword: (e, r, s) => u(t, "resetPassword", {
|
|
257
|
+
jwt: e,
|
|
263
258
|
password: r,
|
|
264
259
|
code: s
|
|
265
260
|
}),
|
|
266
|
-
forgetPassword: (
|
|
267
|
-
username:
|
|
261
|
+
forgetPassword: (e, r) => u(t, "forgetPassword", {
|
|
262
|
+
username: e,
|
|
268
263
|
email: r
|
|
269
264
|
}),
|
|
270
|
-
verifyCode(
|
|
271
|
-
return
|
|
272
|
-
|
|
265
|
+
verifyCode(e, r) {
|
|
266
|
+
return u(t, "forgetPasswordVerifyCode", {
|
|
267
|
+
jwt: e,
|
|
273
268
|
code: r
|
|
274
269
|
});
|
|
275
270
|
},
|
|
276
|
-
granted: async (
|
|
271
|
+
granted: async (e) => (await m(t, {
|
|
277
272
|
granted: {
|
|
278
273
|
__args: {
|
|
279
|
-
rights:
|
|
274
|
+
rights: e
|
|
280
275
|
}
|
|
281
276
|
}
|
|
282
277
|
})).granted
|
|
283
|
-
}),
|
|
284
|
-
const s =
|
|
285
|
-
let
|
|
286
|
-
const
|
|
278
|
+
}), tt = (t, e, r) => {
|
|
279
|
+
const s = e, n = t, i = r;
|
|
280
|
+
let c = "list" + e;
|
|
281
|
+
const o = (a) => i[a] ? i[a]() : null;
|
|
287
282
|
return {
|
|
288
|
-
field:
|
|
289
|
-
$fields:
|
|
290
|
-
setDataPath(
|
|
291
|
-
return
|
|
283
|
+
field: o,
|
|
284
|
+
$fields: i,
|
|
285
|
+
setDataPath(a) {
|
|
286
|
+
return c = a, c;
|
|
292
287
|
},
|
|
293
288
|
getDataPath() {
|
|
294
|
-
return u;
|
|
295
|
-
},
|
|
296
|
-
gqlFields(i) {
|
|
297
|
-
const c = [];
|
|
298
|
-
for (const d of i)
|
|
299
|
-
if (typeof d == "string") {
|
|
300
|
-
const b = l(d);
|
|
301
|
-
b && c.push(b.getGQLField());
|
|
302
|
-
} else typeof d == "object" && c.push(d);
|
|
303
289
|
return c;
|
|
304
290
|
},
|
|
305
|
-
|
|
306
|
-
|
|
291
|
+
gqlFields(a) {
|
|
292
|
+
const l = [];
|
|
293
|
+
for (const p of a)
|
|
294
|
+
if (typeof p == "string") {
|
|
295
|
+
const _ = o(p);
|
|
296
|
+
_ && l.push(_.getGQLField());
|
|
297
|
+
} else typeof p == "object" && l.push(p);
|
|
298
|
+
return l;
|
|
299
|
+
},
|
|
300
|
+
async update(a, l) {
|
|
301
|
+
return await u(n, "update" + s, { id: a, data: l });
|
|
307
302
|
},
|
|
308
|
-
async delete(
|
|
309
|
-
return await
|
|
303
|
+
async delete(a) {
|
|
304
|
+
return await u(n, "delete" + s, { id: a });
|
|
310
305
|
},
|
|
311
|
-
async add(
|
|
312
|
-
return await
|
|
306
|
+
async add(a) {
|
|
307
|
+
return await u(n, "add" + s, { data: a });
|
|
313
308
|
},
|
|
314
|
-
fields(
|
|
315
|
-
let
|
|
316
|
-
for (let
|
|
317
|
-
const
|
|
318
|
-
|
|
309
|
+
fields(a) {
|
|
310
|
+
let l = [];
|
|
311
|
+
for (let p of a) {
|
|
312
|
+
const _ = o(p);
|
|
313
|
+
_ && l.push(_);
|
|
319
314
|
}
|
|
320
|
-
return
|
|
315
|
+
return l;
|
|
321
316
|
},
|
|
322
|
-
async get(
|
|
323
|
-
return (await
|
|
317
|
+
async get(a, l) {
|
|
318
|
+
return (await m(n, {
|
|
324
319
|
["list" + s]: {
|
|
325
320
|
__args: {
|
|
326
|
-
filters:
|
|
321
|
+
filters: a
|
|
327
322
|
},
|
|
328
323
|
data: {
|
|
329
324
|
__args: {
|
|
330
325
|
limit: 1
|
|
331
326
|
},
|
|
332
|
-
...O(
|
|
327
|
+
...O(l)
|
|
333
328
|
}
|
|
334
329
|
}
|
|
335
330
|
}))["list" + s].data[0];
|
|
336
331
|
},
|
|
337
|
-
async list(
|
|
338
|
-
return (await
|
|
332
|
+
async list(a, l) {
|
|
333
|
+
return (await m(n, {
|
|
339
334
|
["list" + s]: {
|
|
340
335
|
__args: {
|
|
341
|
-
filters:
|
|
336
|
+
filters: a
|
|
342
337
|
},
|
|
343
338
|
data: {
|
|
344
|
-
...O(
|
|
339
|
+
...O(l)
|
|
345
340
|
}
|
|
346
341
|
}
|
|
347
342
|
}))["list" + s].data;
|
|
348
343
|
}
|
|
349
344
|
};
|
|
350
345
|
};
|
|
351
|
-
function
|
|
352
|
-
|
|
353
|
-
var
|
|
354
|
-
for (
|
|
355
|
-
return function(
|
|
356
|
-
for (var
|
|
357
|
-
}(s,
|
|
346
|
+
function et(t) {
|
|
347
|
+
t = "<~" + t + "~>";
|
|
348
|
+
var e, r, s, n, i, c = String, o = 255;
|
|
349
|
+
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, s = [], n = 0, i = t.length; i > n; n += 5) r = 52200625 * (t.charCodeAt(n) - 33) + 614125 * (t.charCodeAt(n + 1) - 33) + 7225 * (t.charCodeAt(n + 2) - 33) + 85 * (t.charCodeAt(n + 3) - 33) + (t.charCodeAt(n + 4) - 33), s.push(o & r >> 24, o & r >> 16, o & r >> 8, o & r);
|
|
350
|
+
return function(a, l) {
|
|
351
|
+
for (var p = l; p > 0; p--) a.pop();
|
|
352
|
+
}(s, e.length), c.fromCharCode.apply(c, s);
|
|
358
353
|
}
|
|
359
|
-
const
|
|
360
|
-
const
|
|
361
|
-
const n = new Uint8Array(
|
|
362
|
-
for (let
|
|
363
|
-
n[
|
|
364
|
-
const
|
|
365
|
-
return URL.createObjectURL(
|
|
354
|
+
const k = (t = "") => {
|
|
355
|
+
const e = t, r = (s = "application/octet-stream") => {
|
|
356
|
+
const n = new Uint8Array(e.length);
|
|
357
|
+
for (let o = 0; o < e.length; o++)
|
|
358
|
+
n[o] = e.charCodeAt(o);
|
|
359
|
+
const i = new Blob([n], { type: s });
|
|
360
|
+
return URL.createObjectURL(i);
|
|
366
361
|
};
|
|
367
362
|
return {
|
|
368
|
-
getContent: () =>
|
|
363
|
+
getContent: () => e,
|
|
369
364
|
getURL: r,
|
|
370
365
|
download: (s) => {
|
|
371
366
|
const n = document.createElement("a");
|
|
@@ -375,84 +370,84 @@ const B = (e = "") => {
|
|
|
375
370
|
window.open(r(s), "_blank");
|
|
376
371
|
}
|
|
377
372
|
};
|
|
378
|
-
},
|
|
379
|
-
fromBase85: (
|
|
380
|
-
fromBase64: (
|
|
381
|
-
fromString: (
|
|
382
|
-
}, P = (
|
|
383
|
-
let
|
|
384
|
-
return typeof
|
|
373
|
+
}, _t = {
|
|
374
|
+
fromBase85: (t) => k(et(t)),
|
|
375
|
+
fromBase64: (t) => k(atob(t)),
|
|
376
|
+
fromString: (t) => k(t)
|
|
377
|
+
}, P = (t) => {
|
|
378
|
+
let e = {};
|
|
379
|
+
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
385
380
|
Object.entries(P(r)).forEach(([s, n]) => {
|
|
386
|
-
|
|
381
|
+
e[s] = n;
|
|
387
382
|
});
|
|
388
|
-
}),
|
|
383
|
+
}), e) : (Object.entries(t).forEach(([r, s]) => {
|
|
389
384
|
if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
|
|
390
|
-
|
|
385
|
+
e[r] = s;
|
|
391
386
|
return;
|
|
392
387
|
}
|
|
393
388
|
if (typeof s == "boolean") {
|
|
394
|
-
|
|
389
|
+
e[r] = s;
|
|
395
390
|
return;
|
|
396
391
|
}
|
|
397
|
-
|
|
398
|
-
}),
|
|
399
|
-
}, O = (
|
|
400
|
-
let r =
|
|
401
|
-
const s = await
|
|
392
|
+
e[r] = P(s);
|
|
393
|
+
}), e);
|
|
394
|
+
}, O = (t) => P(t), m = async (t, e) => {
|
|
395
|
+
let r = E(O(e));
|
|
396
|
+
const s = await t.post("", {
|
|
402
397
|
query: `{ ${r} }`
|
|
403
398
|
});
|
|
404
399
|
if (s.data.errors)
|
|
405
400
|
throw new Error(s.data.errors[0].message);
|
|
406
401
|
return s.data.data;
|
|
407
402
|
};
|
|
408
|
-
function
|
|
409
|
-
for (let
|
|
410
|
-
if (e
|
|
403
|
+
function rt(t) {
|
|
404
|
+
for (let e = 0; e < t.length; e++)
|
|
405
|
+
if (t[e] instanceof File)
|
|
411
406
|
return !0;
|
|
412
407
|
return !1;
|
|
413
408
|
}
|
|
414
|
-
function
|
|
415
|
-
for (let
|
|
416
|
-
if (e
|
|
409
|
+
function st(t) {
|
|
410
|
+
for (let e in t)
|
|
411
|
+
if (t[e] instanceof File)
|
|
417
412
|
return !0;
|
|
418
413
|
return !1;
|
|
419
414
|
}
|
|
420
|
-
const
|
|
415
|
+
const u = async (t, e, r = null, s = []) => {
|
|
421
416
|
let n = {
|
|
422
|
-
[
|
|
417
|
+
[e]: {}
|
|
423
418
|
};
|
|
424
|
-
const
|
|
425
|
-
let
|
|
419
|
+
const i = new FormData();
|
|
420
|
+
let c = !1;
|
|
426
421
|
if (r) {
|
|
427
|
-
const
|
|
428
|
-
let
|
|
429
|
-
Object.entries(r).forEach(([
|
|
430
|
-
if (
|
|
431
|
-
|
|
432
|
-
let
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}),
|
|
436
|
-
} else
|
|
437
|
-
|
|
438
|
-
})) :
|
|
439
|
-
}), n[
|
|
422
|
+
const l = {}, p = {}, _ = {};
|
|
423
|
+
let b = 0;
|
|
424
|
+
Object.entries(r).forEach(([y, w]) => {
|
|
425
|
+
if (w instanceof Array && rt(w)) {
|
|
426
|
+
c = !0;
|
|
427
|
+
let A = 0;
|
|
428
|
+
w.forEach((v) => {
|
|
429
|
+
v instanceof File && (l[y] = new S(y), p[b] = ["variables." + y + "." + A], i.append(b.toString(), v), b++);
|
|
430
|
+
}), _[y] = "[Upload!]!";
|
|
431
|
+
} else w instanceof File ? (c = !0, l[y] = new S(y), p[b] = ["variables." + y], i.append(b.toString(), w), _[y] = "Upload!", b++) : w instanceof Object && st(w) ? (c = !0, l[y] = {}, Object.entries(w).forEach(([A, v]) => {
|
|
432
|
+
v instanceof File ? (l[y][A] = new S(A), p[b] = ["variables." + A], i.append(b.toString(), v), _[A] = "Upload!", b++) : l[y][A] = v;
|
|
433
|
+
})) : w !== void 0 && (l[y] = w);
|
|
434
|
+
}), n[e].__args = l, n.__variables = _, c && i.append("map", JSON.stringify(p));
|
|
440
435
|
}
|
|
441
|
-
Object.entries(O(s)).forEach(([
|
|
442
|
-
n[
|
|
443
|
-
}), Object.entries(n[
|
|
444
|
-
let
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
query:
|
|
448
|
-
})),
|
|
449
|
-
query:
|
|
450
|
-
}),
|
|
451
|
-
throw new Error(
|
|
452
|
-
return
|
|
453
|
-
},
|
|
454
|
-
uploadTempFile: (
|
|
455
|
-
file:
|
|
436
|
+
Object.entries(O(s)).forEach(([l, p]) => {
|
|
437
|
+
n[e][l] = p;
|
|
438
|
+
}), Object.entries(n[e]).length === 0 && (n[e] = !0);
|
|
439
|
+
let o = null;
|
|
440
|
+
const a = E({ mutation: n });
|
|
441
|
+
if (c ? (i.append("operations", JSON.stringify({
|
|
442
|
+
query: a
|
|
443
|
+
})), o = await t.post("", i)) : o = await t.post("", {
|
|
444
|
+
query: a
|
|
445
|
+
}), o.data.errors)
|
|
446
|
+
throw new Error(o.data.errors[0].message);
|
|
447
|
+
return o.data.data[e];
|
|
448
|
+
}, nt = (t) => ({
|
|
449
|
+
uploadTempFile: (e) => u(t, "fsUploadTempFile", {
|
|
450
|
+
file: e
|
|
456
451
|
}, {
|
|
457
452
|
name: !0,
|
|
458
453
|
path: !0,
|
|
@@ -460,24 +455,24 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
460
455
|
mime: !0
|
|
461
456
|
}),
|
|
462
457
|
folders: {
|
|
463
|
-
list: async (
|
|
458
|
+
list: async (e) => (await m(t, {
|
|
464
459
|
fsListFolders: {
|
|
465
460
|
__args: {
|
|
466
|
-
path:
|
|
461
|
+
path: e
|
|
467
462
|
},
|
|
468
463
|
name: !0,
|
|
469
464
|
path: !0
|
|
470
465
|
}
|
|
471
466
|
})).fsListFolders,
|
|
472
|
-
create: (
|
|
473
|
-
delete: (
|
|
474
|
-
rename: (
|
|
467
|
+
create: (e) => u(t, "fsCreateFolder", { path: e }),
|
|
468
|
+
delete: (e) => u(t, "fsDeleteFolder", { path: e }),
|
|
469
|
+
rename: (e, r) => u(t, "fsRenameFolder", { path: e, name: r })
|
|
475
470
|
},
|
|
476
471
|
files: {
|
|
477
|
-
list: async (
|
|
472
|
+
list: async (e) => (await m(t, {
|
|
478
473
|
fsListFiles: {
|
|
479
474
|
__args: {
|
|
480
|
-
path:
|
|
475
|
+
path: e
|
|
481
476
|
},
|
|
482
477
|
name: !0,
|
|
483
478
|
path: !0,
|
|
@@ -487,93 +482,93 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
487
482
|
imagePath: !0
|
|
488
483
|
}
|
|
489
484
|
})).fsListFiles,
|
|
490
|
-
read: async (
|
|
491
|
-
let r = await
|
|
485
|
+
read: async (e) => {
|
|
486
|
+
let r = await m(t, {
|
|
492
487
|
fsFile: {
|
|
493
488
|
__args: {
|
|
494
|
-
path:
|
|
489
|
+
path: e
|
|
495
490
|
},
|
|
496
491
|
base64Content: !0
|
|
497
492
|
}
|
|
498
493
|
});
|
|
499
494
|
return window.atob(r.fsFile.base64Content);
|
|
500
495
|
},
|
|
501
|
-
write: (
|
|
502
|
-
path:
|
|
496
|
+
write: (e, r) => u(t, "fsWriteFile", {
|
|
497
|
+
path: e,
|
|
503
498
|
content: r
|
|
504
499
|
}),
|
|
505
|
-
delete: (
|
|
506
|
-
rename: (
|
|
507
|
-
move: (
|
|
500
|
+
delete: (e) => u(t, "fsDeleteFile", { path: e }),
|
|
501
|
+
rename: (e, r) => u(t, "fsRenameFile", { path: e, name: r }),
|
|
502
|
+
move: (e, r) => u(t, "fsMoveFile", { source: e, target: r })
|
|
508
503
|
}
|
|
509
|
-
}),
|
|
510
|
-
get: async (
|
|
504
|
+
}), it = (t) => ({
|
|
505
|
+
get: async (e) => (await t({
|
|
511
506
|
config: {
|
|
512
507
|
__args: {
|
|
513
|
-
name:
|
|
508
|
+
name: e
|
|
514
509
|
}
|
|
515
510
|
}
|
|
516
511
|
})).config
|
|
517
|
-
}),
|
|
518
|
-
send: (
|
|
519
|
-
email:
|
|
512
|
+
}), at = (t) => ({
|
|
513
|
+
send: (e, r, s) => u(t, "sendMail", {
|
|
514
|
+
email: e,
|
|
520
515
|
subject: r,
|
|
521
516
|
message: s
|
|
522
517
|
})
|
|
523
|
-
}),
|
|
524
|
-
list: async (
|
|
518
|
+
}), ot = (t) => ({
|
|
519
|
+
list: async (e = {
|
|
525
520
|
user_id: !0,
|
|
526
521
|
username: !0,
|
|
527
522
|
first_name: !0,
|
|
528
523
|
last_name: !0,
|
|
529
524
|
status: !0
|
|
530
525
|
}) => {
|
|
531
|
-
const r =
|
|
526
|
+
const r = L("Users", t, e);
|
|
532
527
|
return r.data_path = "app.users", r.all();
|
|
533
528
|
}
|
|
534
|
-
}),
|
|
535
|
-
const
|
|
529
|
+
}), lt = (t) => {
|
|
530
|
+
const e = t, r = {};
|
|
536
531
|
return {
|
|
537
532
|
create(s, n) {
|
|
538
533
|
r[s] = null;
|
|
539
|
-
let
|
|
540
|
-
for (const
|
|
541
|
-
const [
|
|
542
|
-
|
|
543
|
-
name:
|
|
544
|
-
raw:
|
|
545
|
-
getName: () =>
|
|
546
|
-
getGQLField: () =>
|
|
534
|
+
let i = {};
|
|
535
|
+
for (const c of Object.entries(n)) {
|
|
536
|
+
const [o, a] = c;
|
|
537
|
+
i[o] = () => ({
|
|
538
|
+
name: a.name ? a.name : o,
|
|
539
|
+
raw: a,
|
|
540
|
+
getName: () => a.name ? a.name : o,
|
|
541
|
+
getGQLField: () => a.gqlField !== void 0 ? a.gqlField : a.name || o,
|
|
547
542
|
getRaw() {
|
|
548
|
-
return
|
|
543
|
+
return a;
|
|
549
544
|
},
|
|
550
|
-
getValue(
|
|
551
|
-
return
|
|
545
|
+
getValue(l) {
|
|
546
|
+
return a.field && typeof a.field == "function" ? a.field(l) : a.field && typeof a.field == "string" ? l[a.field] : l[this.getName()];
|
|
552
547
|
},
|
|
553
|
-
getFormattedValue(
|
|
554
|
-
const
|
|
555
|
-
return
|
|
548
|
+
getFormattedValue(l) {
|
|
549
|
+
const p = this.getValue(l);
|
|
550
|
+
return a.format ? a.format(p) : p;
|
|
556
551
|
}
|
|
557
552
|
});
|
|
558
553
|
}
|
|
559
|
-
r[s] =
|
|
554
|
+
r[s] = tt(e, s, i);
|
|
560
555
|
},
|
|
561
556
|
get(s) {
|
|
562
557
|
return r[s] || this.create(s, {}), r[s];
|
|
563
558
|
}
|
|
564
559
|
};
|
|
565
|
-
},
|
|
566
|
-
list: async (
|
|
560
|
+
}, ut = (t) => ({
|
|
561
|
+
list: async (e = {
|
|
567
562
|
name: !0
|
|
568
563
|
}) => {
|
|
569
|
-
const { app: { roles: r } } = await
|
|
564
|
+
const { app: { roles: r } } = await m(t, {
|
|
570
565
|
app: {
|
|
571
|
-
roles:
|
|
566
|
+
roles: e
|
|
572
567
|
}
|
|
573
568
|
});
|
|
574
569
|
return r;
|
|
575
570
|
}
|
|
576
|
-
}),
|
|
571
|
+
}), ct = [
|
|
577
572
|
"flatMap",
|
|
578
573
|
"chunk",
|
|
579
574
|
"shuffle",
|
|
@@ -597,8 +592,9 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
597
592
|
"only",
|
|
598
593
|
"pad",
|
|
599
594
|
"slice",
|
|
600
|
-
"tap"
|
|
601
|
-
|
|
595
|
+
"tap",
|
|
596
|
+
"sort"
|
|
597
|
+
], pt = [
|
|
602
598
|
"avg",
|
|
603
599
|
"count",
|
|
604
600
|
"countBy",
|
|
@@ -627,119 +623,151 @@ const o = async (e, t, r = null, s = []) => {
|
|
|
627
623
|
"partition",
|
|
628
624
|
"sole"
|
|
629
625
|
];
|
|
630
|
-
class
|
|
631
|
-
constructor(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
this
|
|
626
|
+
class d {
|
|
627
|
+
constructor(e, r) {
|
|
628
|
+
C(this, "_batchData", null);
|
|
629
|
+
// 新增
|
|
630
|
+
C(this, "data_path", "");
|
|
631
|
+
C(this, "axios");
|
|
632
|
+
C(this, "filters");
|
|
633
|
+
C(this, "steps");
|
|
634
|
+
C(this, "fields");
|
|
635
|
+
C(this, "already_limit", !1);
|
|
636
|
+
C(this, "already_offset", !1);
|
|
637
|
+
C(this, "limit", null);
|
|
638
|
+
C(this, "offset", null);
|
|
639
|
+
C(this, "_sort", null);
|
|
640
|
+
C(this, "_sortDesc", !1);
|
|
641
|
+
C(this, "meta", {});
|
|
642
|
+
this.axios = r, this.filters = {}, this.steps = [], this.fields = e;
|
|
645
643
|
}
|
|
646
644
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
645
|
+
d.prototype.getQueryPayload = function() {
|
|
646
|
+
let t = {
|
|
647
|
+
meta: {
|
|
648
|
+
total: !0,
|
|
649
|
+
key: !0,
|
|
650
|
+
name: !0
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
return t.__args = this.buildArgs(), t.data = this.fields, t.data.__args = t.data.__args || {}, this.limit && (t.data.__args.limit = this.limit), this.offset && (t.data.__args.offset = this.offset), {
|
|
654
|
+
data_path: this.data_path,
|
|
655
|
+
query: t,
|
|
656
|
+
steps: this.steps
|
|
657
|
+
};
|
|
650
658
|
};
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
return
|
|
659
|
+
d.prototype.dataPath = function(t) {
|
|
660
|
+
const e = this.clone();
|
|
661
|
+
return e.data_path = t, e;
|
|
662
|
+
};
|
|
663
|
+
d.prototype.buildArgs = function() {
|
|
664
|
+
let t = {};
|
|
665
|
+
return Object.keys(this.filters).length > 0 && (t.filters = this.filters), this._sort && (t.sort = this._sort, this._sortDesc && (t.sort += ":desc")), t;
|
|
654
666
|
};
|
|
655
|
-
|
|
656
|
-
const
|
|
657
|
-
return
|
|
667
|
+
d.prototype.clone = function() {
|
|
668
|
+
const t = Object.create(this);
|
|
669
|
+
return t.steps = JSON.parse(JSON.stringify(this.steps)), t.filters = JSON.parse(JSON.stringify(this.filters)), t.fields = JSON.parse(JSON.stringify(this.fields)), t;
|
|
658
670
|
};
|
|
659
|
-
|
|
660
|
-
return this.filter((r) => r[
|
|
671
|
+
N().macro("whereContains", function(t, e) {
|
|
672
|
+
return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
|
|
661
673
|
});
|
|
662
|
-
|
|
663
|
-
|
|
674
|
+
d.prototype.fetchData = async function() {
|
|
675
|
+
if (this._batchData) {
|
|
676
|
+
const o = this._batchData;
|
|
677
|
+
return this.meta = o.meta, N(o.data);
|
|
678
|
+
}
|
|
679
|
+
let t = {
|
|
664
680
|
meta: {
|
|
665
681
|
total: !0,
|
|
666
682
|
key: !0,
|
|
667
683
|
name: !0
|
|
668
684
|
}
|
|
669
685
|
};
|
|
670
|
-
|
|
671
|
-
const
|
|
672
|
-
let r = {}, s = r, n =
|
|
673
|
-
for (const
|
|
674
|
-
if (
|
|
675
|
-
s[
|
|
686
|
+
t.__args = this.buildArgs(), t.data = this.fields, this.already_limit && (t.data.__args = t.data.__args || {}, t.data.__args.limit = this.limit), this.already_offset && (t.data.__args = t.data.__args || {}, t.data.__args.offset = this.offset);
|
|
687
|
+
const e = this.data_path.split(".");
|
|
688
|
+
let r = {}, s = r, n = e[e.length - 1];
|
|
689
|
+
for (const o of e) {
|
|
690
|
+
if (o === n) {
|
|
691
|
+
s[o] = t;
|
|
676
692
|
break;
|
|
677
693
|
}
|
|
678
|
-
s[
|
|
694
|
+
s[o] = {}, s = s[o];
|
|
679
695
|
}
|
|
680
|
-
let
|
|
681
|
-
for (const
|
|
682
|
-
|
|
683
|
-
return this.meta =
|
|
696
|
+
let c = await m(this.axios, r);
|
|
697
|
+
for (const o of e)
|
|
698
|
+
c = c[o];
|
|
699
|
+
return this.meta = c.meta, N(c.data);
|
|
684
700
|
};
|
|
685
|
-
|
|
686
|
-
let
|
|
687
|
-
for (const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
continue;
|
|
691
|
-
}
|
|
692
|
-
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")
|
|
693
|
-
if (e)
|
|
694
|
-
e = e.where(...t.args);
|
|
695
|
-
else {
|
|
696
|
-
const r = t.args[0];
|
|
697
|
-
let s = "==", n = null;
|
|
698
|
-
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 });
|
|
699
|
-
}
|
|
700
|
-
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)));
|
|
701
|
-
}
|
|
702
|
-
return e || (e = await this.fetchData()), e;
|
|
701
|
+
d.prototype.processData = async function() {
|
|
702
|
+
let t = await this.fetchData();
|
|
703
|
+
for (const e of this.steps)
|
|
704
|
+
t = t[e.type](...e.args);
|
|
705
|
+
return t;
|
|
703
706
|
};
|
|
704
|
-
|
|
707
|
+
d.prototype.all = async function() {
|
|
705
708
|
return (await this.processData()).all();
|
|
706
709
|
};
|
|
707
|
-
for (const
|
|
708
|
-
|
|
710
|
+
for (const t of ct)
|
|
711
|
+
d.prototype[t] = function(...e) {
|
|
709
712
|
const r = this.clone();
|
|
710
|
-
return r.steps.push({ type:
|
|
713
|
+
return r.steps.push({ type: t, args: e }), r;
|
|
711
714
|
};
|
|
712
|
-
for (const
|
|
713
|
-
|
|
714
|
-
return (await this.clone().processData())[
|
|
715
|
+
for (const t of pt)
|
|
716
|
+
d.prototype[t] = async function(...e) {
|
|
717
|
+
return (await this.clone().processData())[t](...e);
|
|
715
718
|
};
|
|
716
|
-
|
|
717
|
-
|
|
719
|
+
d.prototype.average = d.prototype.avg;
|
|
720
|
+
d.prototype.first = async function() {
|
|
718
721
|
return this.take(1), (await this.processData()).first();
|
|
719
722
|
};
|
|
720
|
-
|
|
721
|
-
|
|
723
|
+
d.prototype.where = function(...t) {
|
|
724
|
+
if (t.length == 2)
|
|
725
|
+
this.filters[t[0]] = t[1];
|
|
726
|
+
else if (t.length == 3) {
|
|
727
|
+
let e = "==", r = t[0], s = null;
|
|
728
|
+
t.length == 3 && (e = t[1], s = t[2]), e === "==" && (this.filters[r] = s), e === "<" && (this.filters[r] = { lt: s }), e === "<=" && (this.filters[r] = { lte: s }), e === ">" && (this.filters[r] = { gt: s }), e === ">=" && (this.filters[r] = { gte: s }), e === "!==" && (this.filters[r] = { ne: s });
|
|
729
|
+
}
|
|
730
|
+
return this.steps.push({ type: "where", args: t }), this;
|
|
731
|
+
};
|
|
732
|
+
d.prototype.whereContains = function(t, e) {
|
|
733
|
+
return this.steps.push({ type: "whereContains", args: [t, e] }), this.filters[t] = { contains: e }, this;
|
|
734
|
+
};
|
|
735
|
+
d.prototype.forPage = function(t, e) {
|
|
736
|
+
return t = Math.max(1, t), this.already_limit ? (this.steps.push({ type: "forPage", args: [t, e] }), this) : (this.limit = e, this.offset = (t - 1) * e, this.already_limit = !0, this.already_offset = !0, this);
|
|
737
|
+
};
|
|
738
|
+
d.prototype.whereIn = function(t, e) {
|
|
739
|
+
return this.steps.push({ type: "whereIn", args: [t, e] }), this.filters[t] = { in: e }, this;
|
|
740
|
+
};
|
|
741
|
+
d.prototype.whereNotIn = function(t, e) {
|
|
742
|
+
return this.steps.push({ type: "whereNotIn", args: [t, e] }), this.filters[t] = { nin: e }, this;
|
|
743
|
+
};
|
|
744
|
+
d.prototype.whereNotBetween = function(t, e) {
|
|
745
|
+
return this.steps.push({ type: "whereNotBetween", args: [t, e] }), this.filters[t] = { notBetween: e }, this;
|
|
722
746
|
};
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
return this.steps.push({ type: "pop", args: e }), r;
|
|
747
|
+
d.prototype.whereBetween = function(t, e) {
|
|
748
|
+
return this.steps.push({ type: "whereBetween", args: [t, e] }), this.filters[t] = { between: e }, this;
|
|
726
749
|
};
|
|
727
|
-
|
|
728
|
-
return this.steps.push({ type: "
|
|
750
|
+
d.prototype.sortBy = function(t) {
|
|
751
|
+
return this.steps.push({ type: "sortBy", args: [t] }), typeof t == "string" && (this._sort = t), this;
|
|
729
752
|
};
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
return this.steps.push({ type: "shift", args: e }), r;
|
|
753
|
+
d.prototype.sortByDesc = function(t) {
|
|
754
|
+
return this.steps.push({ type: "sortByDesc", args: [t] }), typeof t == "string" && (this._sort = t, this._sortDesc = !0), this;
|
|
733
755
|
};
|
|
734
|
-
|
|
735
|
-
return this.steps.push({ type: "
|
|
756
|
+
d.prototype.skip = function(t) {
|
|
757
|
+
return this.already_offset && this.steps.push({ type: "skip", args: [t] }), this.offset = t, this.already_offset = !0, this;
|
|
736
758
|
};
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
759
|
+
d.prototype.take = function(t) {
|
|
760
|
+
return this.already_limit ? (this.steps.push({ type: "take", args: [t] }), this) : (this.limit = t, this.already_limit = !0, this);
|
|
761
|
+
};
|
|
762
|
+
d.prototype.splice = function(t, e) {
|
|
763
|
+
return this.steps.push({ type: "splice", args: [t, e] }), this.offset = t, this.limit = e, this.already_limit = !0, this.already_offset = !0, this;
|
|
764
|
+
};
|
|
765
|
+
const L = (t, e, r) => {
|
|
766
|
+
const s = new d(r, e);
|
|
767
|
+
return s.data_path = "list" + t, s;
|
|
768
|
+
}, ft = (t, e) => ({
|
|
769
|
+
uploadTempFile: (r) => u(e, "lightDriveUploadTempFile", {
|
|
770
|
+
index: t,
|
|
743
771
|
file: r
|
|
744
772
|
}, {
|
|
745
773
|
name: !0,
|
|
@@ -751,11 +779,11 @@ const T = (e, t, r) => {
|
|
|
751
779
|
list: async (r, s = {
|
|
752
780
|
name: !0,
|
|
753
781
|
path: !0
|
|
754
|
-
}) => (await
|
|
782
|
+
}) => (await m(e, {
|
|
755
783
|
app: {
|
|
756
784
|
drive: {
|
|
757
785
|
__args: {
|
|
758
|
-
index:
|
|
786
|
+
index: t
|
|
759
787
|
},
|
|
760
788
|
folders: {
|
|
761
789
|
__args: {
|
|
@@ -766,9 +794,9 @@ const T = (e, t, r) => {
|
|
|
766
794
|
}
|
|
767
795
|
}
|
|
768
796
|
})).app.drive.folders,
|
|
769
|
-
create: (r) =>
|
|
770
|
-
delete: (r) =>
|
|
771
|
-
rename: (r, s) =>
|
|
797
|
+
create: (r) => u(e, "lightDriveCreateFolder", { index: t, path: r }),
|
|
798
|
+
delete: (r) => u(e, "lightDriveDeleteFolder", { index: t, path: r }),
|
|
799
|
+
rename: (r, s) => u(e, "lightDriveRenameFolder", { index: t, path: r, name: s })
|
|
772
800
|
},
|
|
773
801
|
files: {
|
|
774
802
|
list: async (r, s = {
|
|
@@ -777,11 +805,11 @@ const T = (e, t, r) => {
|
|
|
777
805
|
size: !0,
|
|
778
806
|
mime: !0,
|
|
779
807
|
url: !0
|
|
780
|
-
}) => (await
|
|
808
|
+
}) => (await m(e, {
|
|
781
809
|
app: {
|
|
782
810
|
drive: {
|
|
783
811
|
__args: {
|
|
784
|
-
index:
|
|
812
|
+
index: t
|
|
785
813
|
},
|
|
786
814
|
files: {
|
|
787
815
|
__args: {
|
|
@@ -798,11 +826,11 @@ const T = (e, t, r) => {
|
|
|
798
826
|
size: !0,
|
|
799
827
|
mime: !0,
|
|
800
828
|
url: !0
|
|
801
|
-
}) => (await
|
|
829
|
+
}) => (await m(e, {
|
|
802
830
|
app: {
|
|
803
831
|
drive: {
|
|
804
832
|
__args: {
|
|
805
|
-
index:
|
|
833
|
+
index: t
|
|
806
834
|
},
|
|
807
835
|
file: {
|
|
808
836
|
__args: {
|
|
@@ -814,11 +842,11 @@ const T = (e, t, r) => {
|
|
|
814
842
|
}
|
|
815
843
|
})).app.drive.file,
|
|
816
844
|
read: async (r) => {
|
|
817
|
-
let s = await
|
|
845
|
+
let s = await m(e, {
|
|
818
846
|
app: {
|
|
819
847
|
drive: {
|
|
820
848
|
__args: {
|
|
821
|
-
index:
|
|
849
|
+
index: t
|
|
822
850
|
},
|
|
823
851
|
file: {
|
|
824
852
|
__args: {
|
|
@@ -831,46 +859,76 @@ const T = (e, t, r) => {
|
|
|
831
859
|
});
|
|
832
860
|
return window.atob(s.app.drive.file.base64Content);
|
|
833
861
|
},
|
|
834
|
-
write: (r, s) =>
|
|
835
|
-
delete: (r) =>
|
|
836
|
-
rename: (r, s) =>
|
|
837
|
-
move: (r, s) =>
|
|
862
|
+
write: (r, s) => u(e, "lightDriveWriteFile", { index: t, path: r, content: s }),
|
|
863
|
+
delete: (r) => u(e, "lightDriveDeleteFile", { index: t, path: r }),
|
|
864
|
+
rename: (r, s) => u(e, "lightDriveRenameFile", { index: t, path: r, name: s }),
|
|
865
|
+
move: (r, s) => u(e, "lightDriveMoveFile", { index: t, source: r, destination: s })
|
|
838
866
|
}
|
|
839
|
-
}),
|
|
840
|
-
const
|
|
841
|
-
baseURL:
|
|
867
|
+
}), mt = (t) => {
|
|
868
|
+
const e = W.create({
|
|
869
|
+
baseURL: t,
|
|
842
870
|
withCredentials: !0
|
|
843
|
-
}), r = (
|
|
871
|
+
}), r = (i, c = null, o = []) => u(e, i, c, o), s = (i) => m(e, i), n = lt(e);
|
|
844
872
|
return {
|
|
845
|
-
baseURL:
|
|
846
|
-
axios:
|
|
847
|
-
auth:
|
|
873
|
+
baseURL: t,
|
|
874
|
+
axios: e,
|
|
875
|
+
auth: x(e),
|
|
848
876
|
mutation: r,
|
|
849
877
|
query: s,
|
|
850
|
-
config:
|
|
851
|
-
mail:
|
|
852
|
-
users:
|
|
853
|
-
fs:
|
|
878
|
+
config: it(s),
|
|
879
|
+
mail: at(e),
|
|
880
|
+
users: ot(e),
|
|
881
|
+
fs: nt(e),
|
|
854
882
|
models: n,
|
|
855
|
-
model(
|
|
856
|
-
return n.get(
|
|
883
|
+
model(i) {
|
|
884
|
+
return n.get(i);
|
|
885
|
+
},
|
|
886
|
+
roles: ut(e),
|
|
887
|
+
collect: (i, c) => {
|
|
888
|
+
const o = L(i, e, c);
|
|
889
|
+
return o.data_path = n.get(i).getDataPath(), o;
|
|
857
890
|
},
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
const l = T(a, t, u);
|
|
861
|
-
return l.data_path = n.get(a).getDataPath(), l;
|
|
891
|
+
drive(i) {
|
|
892
|
+
return ft(i, e);
|
|
862
893
|
},
|
|
863
|
-
|
|
864
|
-
|
|
894
|
+
async collects(i) {
|
|
895
|
+
const c = {}, o = {};
|
|
896
|
+
for (const l in i) {
|
|
897
|
+
const p = i[l].getQueryPayload();
|
|
898
|
+
o[l] = p.data_path, c[l] = {};
|
|
899
|
+
const _ = p.data_path.split(".");
|
|
900
|
+
let b = _[_.length - 1], y = c[l];
|
|
901
|
+
for (const w of _) {
|
|
902
|
+
if (w === b) {
|
|
903
|
+
y[w] = p.query;
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
y[w] = y[w] || {};
|
|
907
|
+
}
|
|
908
|
+
c[l].__aliasFor = _[0];
|
|
909
|
+
}
|
|
910
|
+
const a = await m(e, c);
|
|
911
|
+
for (const l in i) {
|
|
912
|
+
const p = o[l].split(".");
|
|
913
|
+
let _ = p[p.length - 1], b = a[l];
|
|
914
|
+
for (const y of p) {
|
|
915
|
+
if (y === _) {
|
|
916
|
+
i[l]._batchData = a[l][y];
|
|
917
|
+
break;
|
|
918
|
+
}
|
|
919
|
+
b[y] = b[y] || {};
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
return i;
|
|
865
923
|
}
|
|
866
924
|
};
|
|
867
925
|
};
|
|
868
926
|
export {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
927
|
+
_t as File,
|
|
928
|
+
mt as createClient,
|
|
929
|
+
L as createCollection,
|
|
930
|
+
k as file,
|
|
931
|
+
u as mutation,
|
|
932
|
+
m as query,
|
|
875
933
|
O as toQuery
|
|
876
934
|
};
|