@hostlink/light 3.0.3 → 3.0.5
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/createClient.d.ts +0 -4
- package/dist/index.d.ts +9 -2
- package/dist/light.js +372 -500
- package/dist/light.umd.cjs +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/models.d.ts +205 -88
- package/dist/mutation.d.ts +2 -1
- package/dist/query.d.ts +2 -1
- package/package.json +1 -1
package/dist/light.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { jsonToGraphQLQuery as
|
|
1
|
+
import { jsonToGraphQLQuery as M, VariableType as b } from "json-to-graphql-query";
|
|
2
2
|
import H from "axios";
|
|
3
|
-
import
|
|
4
|
-
function
|
|
3
|
+
import S from "collect.js";
|
|
4
|
+
function E(t) {
|
|
5
5
|
if (t === null || typeof t != "object")
|
|
6
6
|
return !1;
|
|
7
7
|
const e = Object.getPrototypeOf(t);
|
|
8
8
|
return e !== null && e !== Object.prototype && Object.getPrototypeOf(e) !== null || Symbol.iterator in t ? !1 : Symbol.toStringTag in t ? Object.prototype.toString.call(t) === "[object Module]" : !0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
if (!
|
|
12
|
-
return
|
|
10
|
+
function v(t, e, r = ".", o) {
|
|
11
|
+
if (!E(e))
|
|
12
|
+
return v(t, {}, r, o);
|
|
13
13
|
const i = Object.assign({}, e);
|
|
14
|
-
for (const
|
|
15
|
-
if (
|
|
14
|
+
for (const u in t) {
|
|
15
|
+
if (u === "__proto__" || u === "constructor")
|
|
16
16
|
continue;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
i[
|
|
21
|
-
(r ? `${r}.` : "") +
|
|
22
|
-
|
|
23
|
-
) : i[
|
|
17
|
+
const l = t[u];
|
|
18
|
+
l != null && (o && o(i, u, l, r) || (Array.isArray(l) && Array.isArray(i[u]) ? i[u] = [...l, ...i[u]] : E(l) && E(i[u]) ? i[u] = v(
|
|
19
|
+
l,
|
|
20
|
+
i[u],
|
|
21
|
+
(r ? `${r}.` : "") + u.toString(),
|
|
22
|
+
o
|
|
23
|
+
) : i[u] = l));
|
|
24
24
|
}
|
|
25
25
|
return i;
|
|
26
26
|
}
|
|
27
27
|
function X(t) {
|
|
28
28
|
return (...e) => (
|
|
29
29
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
30
|
-
e.reduce((r,
|
|
30
|
+
e.reduce((r, o) => v(r, o, "", t), {})
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
let
|
|
33
|
+
const F = X();
|
|
34
|
+
let j = null;
|
|
35
35
|
const Y = (t) => {
|
|
36
|
-
|
|
36
|
+
j = t;
|
|
37
37
|
}, N = () => {
|
|
38
|
-
if (!
|
|
38
|
+
if (!j)
|
|
39
39
|
throw new Error("Api client not initialized. Call setApiClient() first.");
|
|
40
|
-
return
|
|
41
|
-
},
|
|
42
|
-
function
|
|
40
|
+
return j;
|
|
41
|
+
}, Nt = () => j;
|
|
42
|
+
function C(t) {
|
|
43
43
|
for (let e = 0; e < t.length; e++)
|
|
44
44
|
if (t[e] instanceof File)
|
|
45
45
|
return !0;
|
|
@@ -47,57 +47,57 @@ function j(t) {
|
|
|
47
47
|
}
|
|
48
48
|
function B(t) {
|
|
49
49
|
for (let e in t)
|
|
50
|
-
if (t[e] instanceof File || t[e] instanceof Array &&
|
|
50
|
+
if (t[e] instanceof File || t[e] instanceof Array && C(t[e]))
|
|
51
51
|
return !0;
|
|
52
52
|
return !1;
|
|
53
53
|
}
|
|
54
|
-
function J(t, e, r,
|
|
54
|
+
function J(t, e, r, o, i) {
|
|
55
55
|
if (!(!t || typeof t != "object"))
|
|
56
|
-
for (let
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
if ("__args" in
|
|
60
|
-
const
|
|
61
|
-
Object.entries(
|
|
62
|
-
if (c instanceof Array &&
|
|
63
|
-
s[
|
|
64
|
-
let
|
|
65
|
-
c.forEach((
|
|
66
|
-
|
|
67
|
-
}), e[
|
|
68
|
-
} else c instanceof File ? (s[
|
|
69
|
-
if (
|
|
70
|
-
s[
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}), e[
|
|
75
|
-
} else
|
|
76
|
-
})) : c != null && (s[
|
|
77
|
-
}),
|
|
56
|
+
for (let u in t) {
|
|
57
|
+
const l = t[u];
|
|
58
|
+
if (l && typeof l == "object") {
|
|
59
|
+
if ("__args" in l) {
|
|
60
|
+
const h = l.__args, s = {};
|
|
61
|
+
Object.entries(h).forEach(([n, c]) => {
|
|
62
|
+
if (c instanceof Array && C(c)) {
|
|
63
|
+
s[n] = new b(n);
|
|
64
|
+
let a = 0;
|
|
65
|
+
c.forEach((f) => {
|
|
66
|
+
f instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + n + "." + a), o.append(i.current.toString(), f), i.current++, a++);
|
|
67
|
+
}), e[n] = "[Upload!]!";
|
|
68
|
+
} else c instanceof File ? (s[n] = new b(n), r[i.current] = ["variables." + n], o.append(i.current.toString(), c), e[n] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[n] = {}, Object.entries(c).forEach(([a, f]) => {
|
|
69
|
+
if (f instanceof Array && C(f)) {
|
|
70
|
+
s[n][a] = new b(a);
|
|
71
|
+
let g = 0;
|
|
72
|
+
f.forEach((_) => {
|
|
73
|
+
_ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + a + "." + g), o.append(i.current.toString(), _), i.current++, g++);
|
|
74
|
+
}), e[a] = "[Upload!]!";
|
|
75
|
+
} else f instanceof File ? (s[n][a] = new b(a), r[i.current] = ["variables." + a], o.append(i.current.toString(), f), e[a] = "Upload!", i.current++) : s[n][a] = f;
|
|
76
|
+
})) : c != null && (s[n] = c);
|
|
77
|
+
}), l.__args = s;
|
|
78
78
|
}
|
|
79
|
-
J(
|
|
79
|
+
J(l, e, r, o, i);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
const y = async (t) => {
|
|
84
|
-
const e = N(), r = t,
|
|
84
|
+
const e = N(), r = t, o = new FormData();
|
|
85
85
|
let i = !1;
|
|
86
|
-
const
|
|
87
|
-
J(r,
|
|
86
|
+
const u = {}, l = {};
|
|
87
|
+
J(r, u, l, o, { current: 0 }), i = Object.keys(u).length > 0, i && (r.__variables = u);
|
|
88
88
|
let s = null;
|
|
89
|
-
const c =
|
|
90
|
-
if (i ? (
|
|
89
|
+
const c = M({ query: r });
|
|
90
|
+
if (i ? (o.append("map", JSON.stringify(l)), o.append("operations", JSON.stringify({
|
|
91
91
|
query: c
|
|
92
|
-
})), s = await e.axios.post("",
|
|
92
|
+
})), s = await e.axios.post("", o)) : s = await e.axios.post("", {
|
|
93
93
|
query: c
|
|
94
94
|
}), s.data.errors)
|
|
95
95
|
throw new Error(s.data.errors[0].message);
|
|
96
96
|
return s.data.data;
|
|
97
97
|
};
|
|
98
|
-
function
|
|
99
|
-
let r,
|
|
100
|
-
const
|
|
98
|
+
function k(t, e) {
|
|
99
|
+
let r, o = [], i, u;
|
|
100
|
+
const l = (s) => !s || typeof s != "object" ? !1 : Object.values(s).some((n) => n && typeof n == "object" && Object.keys(n).some((c) => c.startsWith("_"))), h = () => o.length === 0 ? (o.unshift({}), o[0]) : (l(o[0]) && o.unshift({}), o[0]);
|
|
101
101
|
return {
|
|
102
102
|
first() {
|
|
103
103
|
return this.fetchFirst();
|
|
@@ -106,43 +106,43 @@ function C(t, e) {
|
|
|
106
106
|
return this.fetch();
|
|
107
107
|
},
|
|
108
108
|
async fetchFirst() {
|
|
109
|
-
const
|
|
110
|
-
return Array.isArray(
|
|
109
|
+
const n = await this.limit(1).fetch();
|
|
110
|
+
return Array.isArray(n) && n.length > 0 ? n[0] : null;
|
|
111
111
|
},
|
|
112
112
|
async fetchWithMeta() {
|
|
113
|
-
let
|
|
114
|
-
if (
|
|
115
|
-
const c =
|
|
116
|
-
for (const
|
|
117
|
-
|
|
118
|
-
return
|
|
113
|
+
let n = await y(this.toQuery(!0));
|
|
114
|
+
if (u) {
|
|
115
|
+
const c = u.split(".");
|
|
116
|
+
for (const a of c)
|
|
117
|
+
n = n[a];
|
|
118
|
+
return n;
|
|
119
119
|
}
|
|
120
|
-
return
|
|
120
|
+
return n[`list${t}`];
|
|
121
121
|
},
|
|
122
122
|
async fetch() {
|
|
123
|
-
let
|
|
124
|
-
if (
|
|
125
|
-
const c =
|
|
126
|
-
for (const
|
|
127
|
-
|
|
128
|
-
return
|
|
123
|
+
let n = await y(this.toQuery());
|
|
124
|
+
if (u) {
|
|
125
|
+
const c = u.split(".");
|
|
126
|
+
for (const a of c)
|
|
127
|
+
n = n[a];
|
|
128
|
+
return n.data;
|
|
129
129
|
}
|
|
130
|
-
return
|
|
130
|
+
return n[`list${t}`].data;
|
|
131
131
|
},
|
|
132
132
|
dataPath(s) {
|
|
133
|
-
return s && typeof s == "string" && (
|
|
133
|
+
return s && typeof s == "string" && (u = s), this;
|
|
134
134
|
},
|
|
135
135
|
sort(s) {
|
|
136
136
|
return s && typeof s == "string" && (i = s), this;
|
|
137
137
|
},
|
|
138
138
|
filters(s) {
|
|
139
|
-
return s && typeof s == "object" && (
|
|
139
|
+
return s && typeof s == "object" && (o = [s]), this;
|
|
140
140
|
},
|
|
141
141
|
// where can be called as:
|
|
142
142
|
// where('key', value) -> exact match
|
|
143
143
|
// where('key', '>', value) -> operator-based (>, <, >=, <=, !=, in, contains)
|
|
144
|
-
where(s,
|
|
145
|
-
const
|
|
144
|
+
where(s, n, c) {
|
|
145
|
+
const a = (f, g, _) => {
|
|
146
146
|
const O = {
|
|
147
147
|
">": "_gt",
|
|
148
148
|
"<": "_lt",
|
|
@@ -151,71 +151,71 @@ function C(t, e) {
|
|
|
151
151
|
"!=": "_ne",
|
|
152
152
|
in: "_in",
|
|
153
153
|
contains: "_contains"
|
|
154
|
-
}[
|
|
155
|
-
O &&
|
|
154
|
+
}[g];
|
|
155
|
+
O && o.push({ [f]: { [O]: _ } });
|
|
156
156
|
};
|
|
157
157
|
if (c !== void 0)
|
|
158
|
-
|
|
158
|
+
a(s, String(n), c);
|
|
159
159
|
else {
|
|
160
|
-
const
|
|
161
|
-
|
|
160
|
+
const f = h(), g = F(f, { [s]: n });
|
|
161
|
+
o[0] = g;
|
|
162
162
|
}
|
|
163
163
|
return this;
|
|
164
164
|
},
|
|
165
165
|
// whereContains adds a _contains filter for a specific field
|
|
166
166
|
// If the same field is used multiple times, it merges them into an array
|
|
167
|
-
whereContains(s,
|
|
167
|
+
whereContains(s, n) {
|
|
168
168
|
if (s && typeof s == "string") {
|
|
169
|
-
const c =
|
|
170
|
-
c[s] ? Array.isArray(c[s]) ? c[s].push(
|
|
169
|
+
const c = h(), a = { _contains: n };
|
|
170
|
+
c[s] ? Array.isArray(c[s]) ? c[s].push(a) : c[s] = [c[s], a] : c[s] = [a], o[0] = c;
|
|
171
171
|
}
|
|
172
172
|
return this;
|
|
173
173
|
},
|
|
174
174
|
// ...existing code...
|
|
175
175
|
// whereIn adds an _in filter for a specific field
|
|
176
176
|
// If the same field is used multiple times, it merges them into an array
|
|
177
|
-
whereIn(s,
|
|
178
|
-
if (s && typeof s == "string" && Array.isArray(
|
|
179
|
-
const c =
|
|
180
|
-
c[s] ? Array.isArray(c[s]) ? c[s].push(
|
|
177
|
+
whereIn(s, n) {
|
|
178
|
+
if (s && typeof s == "string" && Array.isArray(n)) {
|
|
179
|
+
const c = h(), a = { _in: n };
|
|
180
|
+
c[s] ? Array.isArray(c[s]) ? c[s].push(a) : c[s] = [c[s], a] : c[s] = [a], o[0] = c;
|
|
181
181
|
}
|
|
182
182
|
return this;
|
|
183
183
|
},
|
|
184
184
|
// whereBetween adds a _between filter for a specific field
|
|
185
|
-
whereBetween(s,
|
|
185
|
+
whereBetween(s, n, c) {
|
|
186
186
|
if (s && typeof s == "string") {
|
|
187
|
-
const
|
|
188
|
-
|
|
187
|
+
const a = h(), f = { _between: [n, c] };
|
|
188
|
+
a[s] ? Array.isArray(a[s]) ? a[s].push(f) : a[s] = [a[s], f] : a[s] = f, o[0] = a;
|
|
189
189
|
}
|
|
190
190
|
return this;
|
|
191
191
|
},
|
|
192
192
|
// limit sets paging/limit for the data selection
|
|
193
193
|
limit(s) {
|
|
194
|
-
return typeof s == "number" && Number.isFinite(s) && (r =
|
|
194
|
+
return typeof s == "number" && Number.isFinite(s) && (r = F(r || {}, { limit: s })), this;
|
|
195
195
|
},
|
|
196
196
|
// offset sets the starting index for the data selection
|
|
197
197
|
offset(s) {
|
|
198
|
-
return typeof s == "number" && Number.isFinite(s) && (r =
|
|
198
|
+
return typeof s == "number" && Number.isFinite(s) && (r = F(r || {}, { offset: s })), this;
|
|
199
199
|
},
|
|
200
200
|
toQuery(s = !1) {
|
|
201
|
-
let
|
|
202
|
-
const c =
|
|
203
|
-
c &&
|
|
204
|
-
const
|
|
201
|
+
let n;
|
|
202
|
+
const c = o.length > 0 && Object.keys(o[0] || {}).length > 0, a = c ? 1 : 0, f = o.length > a;
|
|
203
|
+
c && f ? n = o : f ? n = o.slice(a) : c && (n = o[0]);
|
|
204
|
+
const g = F(
|
|
205
205
|
i ? { sort: i } : {},
|
|
206
|
-
|
|
207
|
-
),
|
|
206
|
+
n ? { filters: n } : {}
|
|
207
|
+
), _ = {
|
|
208
208
|
data: {
|
|
209
209
|
...e
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
|
-
if (r && (
|
|
212
|
+
if (r && (_.data.__args = r), Object.keys(g).length > 0 && (_.__args = g), s && (_.meta = {
|
|
213
213
|
total: !0,
|
|
214
214
|
key: !0,
|
|
215
215
|
name: !0
|
|
216
|
-
}),
|
|
217
|
-
const w =
|
|
218
|
-
let O =
|
|
216
|
+
}), u) {
|
|
217
|
+
const w = u.split(".");
|
|
218
|
+
let O = _;
|
|
219
219
|
for (let P = w.length - 1; P >= 0; P--)
|
|
220
220
|
O = {
|
|
221
221
|
[w[P]]: O
|
|
@@ -223,239 +223,106 @@ function C(t, e) {
|
|
|
223
223
|
return O;
|
|
224
224
|
}
|
|
225
225
|
return {
|
|
226
|
-
[`list${t}`]:
|
|
226
|
+
[`list${t}`]: _
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
const r = t,
|
|
231
|
+
const Z = (t, e = {}) => {
|
|
232
|
+
const r = t, o = e;
|
|
233
233
|
let i = "list" + t;
|
|
234
|
-
const
|
|
234
|
+
const u = (l) => o[l] ? o[l] : null;
|
|
235
235
|
return {
|
|
236
|
-
field:
|
|
237
|
-
$fields:
|
|
238
|
-
setDataPath(
|
|
239
|
-
return i =
|
|
236
|
+
field: u,
|
|
237
|
+
$fields: o,
|
|
238
|
+
setDataPath(l) {
|
|
239
|
+
return i = l, i;
|
|
240
240
|
},
|
|
241
241
|
getDataPath() {
|
|
242
242
|
return i;
|
|
243
243
|
},
|
|
244
|
-
gqlFields(
|
|
245
|
-
let
|
|
246
|
-
for (const s of
|
|
244
|
+
gqlFields(l) {
|
|
245
|
+
let h = {};
|
|
246
|
+
for (const s of l)
|
|
247
247
|
if (typeof s == "string") {
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
} else typeof s == "object" && (
|
|
251
|
-
return
|
|
248
|
+
const n = u(s);
|
|
249
|
+
n && (h = F(h, n.gqlField ? typeof n.gqlField == "string" ? { [n.gqlField]: !0 } : n.gqlField : { [n.name || s]: !0 }));
|
|
250
|
+
} else typeof s == "object" && (h = F(h, s));
|
|
251
|
+
return h;
|
|
252
252
|
},
|
|
253
|
-
update(
|
|
253
|
+
update(l, h) {
|
|
254
254
|
return p({
|
|
255
255
|
["update" + r]: {
|
|
256
|
-
__args: { id:
|
|
256
|
+
__args: { id: l, data: h }
|
|
257
257
|
}
|
|
258
258
|
}).then((s) => s["update" + r]);
|
|
259
259
|
},
|
|
260
|
-
async delete(
|
|
260
|
+
async delete(l) {
|
|
261
261
|
return p({
|
|
262
262
|
["delete" + r]: {
|
|
263
|
-
__args: { id:
|
|
263
|
+
__args: { id: l }
|
|
264
264
|
}
|
|
265
|
-
}).then((
|
|
265
|
+
}).then((h) => h["delete" + r]);
|
|
266
266
|
},
|
|
267
|
-
add(
|
|
267
|
+
add(l) {
|
|
268
268
|
return p({
|
|
269
269
|
["add" + r]: {
|
|
270
|
-
__args: { data:
|
|
270
|
+
__args: { data: l }
|
|
271
271
|
}
|
|
272
|
-
}).then((
|
|
272
|
+
}).then((h) => h["add" + r]);
|
|
273
273
|
},
|
|
274
|
-
fields(
|
|
275
|
-
let
|
|
276
|
-
for (let s of
|
|
277
|
-
const
|
|
278
|
-
|
|
274
|
+
fields(l) {
|
|
275
|
+
let h = [];
|
|
276
|
+
for (let s of l) {
|
|
277
|
+
const n = u(s);
|
|
278
|
+
n && h.push(n);
|
|
279
279
|
}
|
|
280
|
-
return
|
|
280
|
+
return h;
|
|
281
281
|
},
|
|
282
|
-
async get(
|
|
283
|
-
const s = (await Promise.resolve().then(() =>
|
|
284
|
-
for (const [c,
|
|
285
|
-
|
|
286
|
-
return await
|
|
282
|
+
async get(l, h) {
|
|
283
|
+
const s = (await Promise.resolve().then(() => St)).default, n = s(r, kt(h));
|
|
284
|
+
for (const [c, a] of Object.entries(l))
|
|
285
|
+
n.where(c, "==", a);
|
|
286
|
+
return await n.first();
|
|
287
287
|
},
|
|
288
|
-
list(
|
|
289
|
-
let
|
|
288
|
+
list(l) {
|
|
289
|
+
let h = l;
|
|
290
290
|
const s = {};
|
|
291
|
-
Object.entries(
|
|
292
|
-
|
|
291
|
+
Object.entries(l).forEach(([a]) => {
|
|
292
|
+
o[a] && (s[a] = o[a], o[a].gqlField && (delete h[a], h = F(h, o[a].gqlField)), o[a].gql && (h = F(h, o[a].gql), delete h[a]));
|
|
293
293
|
});
|
|
294
|
-
const
|
|
294
|
+
const n = k(r, h).dataPath(i), c = n.fetch.bind(n);
|
|
295
295
|
return {
|
|
296
|
-
...
|
|
296
|
+
...n,
|
|
297
297
|
async fetch() {
|
|
298
|
-
return (await c()).map((
|
|
299
|
-
const
|
|
300
|
-
return Object.entries(s).forEach(([
|
|
301
|
-
w.format && typeof w.format == "function" && (_
|
|
302
|
-
}),
|
|
298
|
+
return (await c()).map((f) => {
|
|
299
|
+
const g = { ...f };
|
|
300
|
+
return Object.entries(s).forEach(([_, w]) => {
|
|
301
|
+
w.format && typeof w.format == "function" && (g[_] = w.format(f));
|
|
302
|
+
}), g;
|
|
303
303
|
});
|
|
304
304
|
},
|
|
305
305
|
async fetchFirst() {
|
|
306
|
-
const
|
|
307
|
-
if (!
|
|
308
|
-
const
|
|
309
|
-
return Object.entries(s).forEach(([
|
|
310
|
-
w.format && typeof w.format == "function" && (_
|
|
311
|
-
}),
|
|
306
|
+
const f = await n.fetchFirst.bind(n)();
|
|
307
|
+
if (!f) return f;
|
|
308
|
+
const g = { ...f };
|
|
309
|
+
return Object.entries(s).forEach(([_, w]) => {
|
|
310
|
+
w.format && typeof w.format == "function" && (g[_] = w.format(f));
|
|
311
|
+
}), g;
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
|
-
},
|
|
317
|
-
const
|
|
318
|
-
return
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
e[r] = i, t && (b[r] = i);
|
|
327
|
-
},
|
|
328
|
-
/**
|
|
329
|
-
* 獲取模型
|
|
330
|
-
* @param name 模型名稱
|
|
331
|
-
* @returns 模型實例
|
|
332
|
-
*/
|
|
333
|
-
get(r) {
|
|
334
|
-
return e[r] || (t && b[r] ? e[r] = b[r] : this.create(r, {})), e[r];
|
|
335
|
-
},
|
|
336
|
-
/**
|
|
337
|
-
* 檢查模型是否存在
|
|
338
|
-
* @param name 模型名稱
|
|
339
|
-
* @returns 是否存在
|
|
340
|
-
*/
|
|
341
|
-
has(r) {
|
|
342
|
-
return !!e[r] || t && !!b[r];
|
|
343
|
-
},
|
|
344
|
-
/**
|
|
345
|
-
* 列出所有模型名稱
|
|
346
|
-
* @returns 模型名稱陣列
|
|
347
|
-
*/
|
|
348
|
-
list() {
|
|
349
|
-
const r = Object.keys(e), n = t ? Object.keys(b) : [];
|
|
350
|
-
return [.../* @__PURE__ */ new Set([...r, ...n])];
|
|
351
|
-
},
|
|
352
|
-
/**
|
|
353
|
-
* 清除所有模型
|
|
354
|
-
*/
|
|
355
|
-
clear() {
|
|
356
|
-
Object.keys(e).forEach((r) => delete e[r]);
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}, Nt = () => {
|
|
360
|
-
const t = v(!1);
|
|
361
|
-
return {
|
|
362
|
-
// 暴露完整的管理器
|
|
363
|
-
manager: t,
|
|
364
|
-
// 便利方法 - 直接暴露常用功能
|
|
365
|
-
createModel: t.create,
|
|
366
|
-
getModel: t.get,
|
|
367
|
-
hasModel: t.has,
|
|
368
|
-
listModels: t.list,
|
|
369
|
-
clearModels: t.clear,
|
|
370
|
-
/**
|
|
371
|
-
* 快速創建並獲取模型
|
|
372
|
-
* @param name 模型名稱
|
|
373
|
-
* @param fields 模型欄位定義
|
|
374
|
-
* @returns 模型實例
|
|
375
|
-
*/
|
|
376
|
-
defineModel(e, r) {
|
|
377
|
-
return t.create(e, r), t.get(e);
|
|
378
|
-
},
|
|
379
|
-
/**
|
|
380
|
-
* 批量創建模型
|
|
381
|
-
* @param models 模型定義對象
|
|
382
|
-
*/
|
|
383
|
-
defineModels(e) {
|
|
384
|
-
Object.entries(e).forEach(([r, n]) => {
|
|
385
|
-
t.create(r, n);
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
}, Bt = () => {
|
|
390
|
-
const t = v(!0);
|
|
391
|
-
return {
|
|
392
|
-
// 暴露完整的管理器
|
|
393
|
-
manager: t,
|
|
394
|
-
// 便利方法 - 直接暴露常用功能
|
|
395
|
-
createModel: t.create,
|
|
396
|
-
getModel: t.get,
|
|
397
|
-
hasModel: t.has,
|
|
398
|
-
listModels: t.list,
|
|
399
|
-
clearModels: t.clear,
|
|
400
|
-
/**
|
|
401
|
-
* 快速創建並獲取模型
|
|
402
|
-
* @param name 模型名稱
|
|
403
|
-
* @param fields 模型欄位定義
|
|
404
|
-
* @returns 模型實例
|
|
405
|
-
*/
|
|
406
|
-
defineModel(e, r) {
|
|
407
|
-
return t.create(e, r), t.get(e);
|
|
408
|
-
},
|
|
409
|
-
/**
|
|
410
|
-
* 批量創建模型
|
|
411
|
-
* @param models 模型定義對象
|
|
412
|
-
*/
|
|
413
|
-
defineModels(e) {
|
|
414
|
-
Object.entries(e).forEach(([r, n]) => {
|
|
415
|
-
t.create(r, n);
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
}, Jt = () => ({
|
|
420
|
-
/**
|
|
421
|
-
* 創建全域模型
|
|
422
|
-
* @param name 模型名稱
|
|
423
|
-
* @param fields 模型欄位定義
|
|
424
|
-
*/
|
|
425
|
-
define(t, e) {
|
|
426
|
-
const r = L(t, e);
|
|
427
|
-
return b[t] = r, r;
|
|
428
|
-
},
|
|
429
|
-
/**
|
|
430
|
-
* 獲取全域模型
|
|
431
|
-
* @param name 模型名稱
|
|
432
|
-
* @returns 模型實例
|
|
433
|
-
*/
|
|
434
|
-
get(t) {
|
|
435
|
-
return b[t];
|
|
436
|
-
},
|
|
437
|
-
/**
|
|
438
|
-
* 檢查全域模型是否存在
|
|
439
|
-
* @param name 模型名稱
|
|
440
|
-
* @returns 是否存在
|
|
441
|
-
*/
|
|
442
|
-
has(t) {
|
|
443
|
-
return !!b[t];
|
|
444
|
-
},
|
|
445
|
-
/**
|
|
446
|
-
* 列出所有全域模型
|
|
447
|
-
* @returns 模型名稱陣列
|
|
448
|
-
*/
|
|
449
|
-
list() {
|
|
450
|
-
return Object.keys(b);
|
|
451
|
-
},
|
|
452
|
-
/**
|
|
453
|
-
* 清除所有全域模型
|
|
454
|
-
*/
|
|
455
|
-
clear() {
|
|
456
|
-
Object.keys(b).forEach((t) => delete b[t]);
|
|
457
|
-
}
|
|
458
|
-
}), Lt = () => y({
|
|
316
|
+
}, A = {}, L = (t, e) => {
|
|
317
|
+
const r = Z(t, e);
|
|
318
|
+
return A[t] = r, r;
|
|
319
|
+
}, U = (t) => A[t] ? A[t] : L(t, {}), Bt = (t) => !!A[t], Jt = () => Object.keys(A), Lt = () => {
|
|
320
|
+
Object.keys(A).forEach((t) => delete A[t]);
|
|
321
|
+
}, Qt = (t) => {
|
|
322
|
+
Object.entries(t).forEach(([e, r]) => {
|
|
323
|
+
L(e, r);
|
|
324
|
+
});
|
|
325
|
+
}, Tt = () => y({
|
|
459
326
|
app: {
|
|
460
327
|
permissions: !0
|
|
461
328
|
}
|
|
@@ -477,27 +344,31 @@ const L = (t, e) => {
|
|
|
477
344
|
}
|
|
478
345
|
}), e = PublicKeyCredential.parseCreationOptionsFromJSON(t.auth.webAuthnCreationOptions);
|
|
479
346
|
return await navigator.credentials.create({ publicKey: e });
|
|
480
|
-
},
|
|
347
|
+
}, V = async () => {
|
|
481
348
|
const t = await Q();
|
|
482
349
|
return await p({
|
|
483
350
|
webAuthnAssertion: {
|
|
484
|
-
|
|
351
|
+
__args: {
|
|
352
|
+
assertion: t.toJSON()
|
|
353
|
+
}
|
|
485
354
|
}
|
|
486
355
|
}).then((e) => e.webAuthnAssertion);
|
|
487
|
-
},
|
|
356
|
+
}, I = async () => {
|
|
488
357
|
const t = await T();
|
|
489
358
|
return await p({
|
|
490
359
|
webAuthnRegister: {
|
|
491
|
-
|
|
360
|
+
__args: {
|
|
361
|
+
registration: t.toJSON()
|
|
362
|
+
}
|
|
492
363
|
}
|
|
493
364
|
}).then((e) => e.webAuthnRegister);
|
|
494
365
|
}, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
495
366
|
__proto__: null,
|
|
496
367
|
assertion: Q,
|
|
497
368
|
attestation: T,
|
|
498
|
-
login:
|
|
499
|
-
register:
|
|
500
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
369
|
+
login: V,
|
|
370
|
+
register: I
|
|
371
|
+
}, Symbol.toStringTag, { value: "Module" })), x = (t = W) => y({ my: t }).then((e) => e.my), tt = (t, e, r = "") => p({ login: { __args: { username: t, password: e, code: r } } }).then((o) => o.login), et = () => p({ logout: !0 }).then((t) => t.logout), rt = (t, e, r) => p({ changeExpiredPassword: { __args: { username: t, old_password: e, new_password: r } } }).then((o) => o.changeExpiredPassword), st = (t, e) => p({ changeUserPassword: { __args: { old_password: t, new_password: e } } }).then((r) => r.changeUserPassword), nt = (t, e, r) => p({ resetPassword: { __args: { jwt: t, password: e, code: r } } }).then((o) => o.resetPassword), ot = (t, e) => p({ forgetPassword: { __args: { username: t, email: e } } }).then((r) => r.forgetPassword), it = (t, e) => p({ forgetPasswordVerifyCode: { __args: { jwt: t, code: e } } }).then((r) => r.forgetPasswordVerifyCode), at = (t) => y({
|
|
501
372
|
my: {
|
|
502
373
|
granted: {
|
|
503
374
|
__args: {
|
|
@@ -505,7 +376,7 @@ const L = (t, e) => {
|
|
|
505
376
|
}
|
|
506
377
|
}
|
|
507
378
|
}
|
|
508
|
-
}).then((e) => e.my.granted),
|
|
379
|
+
}).then((e) => e.my.granted), ct = (t) => y({
|
|
509
380
|
my: {
|
|
510
381
|
grantedRights: {
|
|
511
382
|
__args: {
|
|
@@ -513,8 +384,8 @@ const L = (t, e) => {
|
|
|
513
384
|
}
|
|
514
385
|
}
|
|
515
386
|
}
|
|
516
|
-
}).then((e) => e.my.grantedRights),
|
|
517
|
-
getCurrentUser:
|
|
387
|
+
}).then((e) => e.my.grantedRights), lt = () => ({
|
|
388
|
+
getCurrentUser: x,
|
|
518
389
|
webAuthn: K,
|
|
519
390
|
google: {
|
|
520
391
|
unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
|
|
@@ -531,22 +402,22 @@ const L = (t, e) => {
|
|
|
531
402
|
login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
|
|
532
403
|
register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
|
|
533
404
|
},
|
|
534
|
-
login:
|
|
535
|
-
logout:
|
|
536
|
-
changeExpiredPassword:
|
|
537
|
-
updatePassword:
|
|
538
|
-
resetPassword:
|
|
539
|
-
forgetPassword:
|
|
540
|
-
verifyCode:
|
|
541
|
-
grantedRights:
|
|
542
|
-
isGranted:
|
|
405
|
+
login: tt,
|
|
406
|
+
logout: et,
|
|
407
|
+
changeExpiredPassword: rt,
|
|
408
|
+
updatePassword: st,
|
|
409
|
+
resetPassword: nt,
|
|
410
|
+
forgetPassword: ot,
|
|
411
|
+
verifyCode: it,
|
|
412
|
+
grantedRights: ct,
|
|
413
|
+
isGranted: at
|
|
543
414
|
}), $ = {
|
|
544
415
|
name: !0,
|
|
545
416
|
path: !0,
|
|
546
417
|
size: !0,
|
|
547
418
|
mime: !0,
|
|
548
419
|
url: !0
|
|
549
|
-
},
|
|
420
|
+
}, ut = (t, e, r = $) => y({
|
|
550
421
|
app: {
|
|
551
422
|
drive: {
|
|
552
423
|
__args: { index: t },
|
|
@@ -556,7 +427,7 @@ const L = (t, e) => {
|
|
|
556
427
|
}
|
|
557
428
|
}
|
|
558
429
|
}
|
|
559
|
-
}).then((
|
|
430
|
+
}).then((o) => o.app.drive.files), ht = (t, e) => y({
|
|
560
431
|
app: {
|
|
561
432
|
drive: {
|
|
562
433
|
__args: {
|
|
@@ -571,7 +442,7 @@ const L = (t, e) => {
|
|
|
571
442
|
}
|
|
572
443
|
}
|
|
573
444
|
}).then((r) => r.app.drive?.file?.base64Content), m = (t) => ({
|
|
574
|
-
list: (e, r = $) =>
|
|
445
|
+
list: (e, r = $) => ut(t, e, r),
|
|
575
446
|
get: (e, r = {
|
|
576
447
|
name: !0,
|
|
577
448
|
path: !0,
|
|
@@ -592,9 +463,9 @@ const L = (t, e) => {
|
|
|
592
463
|
}
|
|
593
464
|
}
|
|
594
465
|
}
|
|
595
|
-
}).then((
|
|
466
|
+
}).then((o) => o.app.drive.file),
|
|
596
467
|
readFileAsBase64(e) {
|
|
597
|
-
return
|
|
468
|
+
return ht(t, e);
|
|
598
469
|
},
|
|
599
470
|
read: async (e) => {
|
|
600
471
|
let r = await y({
|
|
@@ -616,14 +487,14 @@ const L = (t, e) => {
|
|
|
616
487
|
throw new Error(`File not found or cannot read content: ${e}`);
|
|
617
488
|
return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
|
|
618
489
|
},
|
|
619
|
-
write: (e, r) => p({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((
|
|
490
|
+
write: (e, r) => p({ lightDriveWriteFile: { __args: { index: t, path: e, content: r } } }).then((o) => o.lightDriveWriteFile),
|
|
620
491
|
delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
|
|
621
|
-
rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((
|
|
622
|
-
move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((
|
|
492
|
+
rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((o) => o.lightDriveRenameFile),
|
|
493
|
+
move: (e, r) => p({ lightDriveMoveFile: { __args: { index: t, source: e, destination: r } } }).then((o) => o.lightDriveMoveFile)
|
|
623
494
|
}), G = {
|
|
624
495
|
name: !0,
|
|
625
496
|
path: !0
|
|
626
|
-
},
|
|
497
|
+
}, ft = (t, e, r = G) => y({
|
|
627
498
|
app: {
|
|
628
499
|
drive: {
|
|
629
500
|
__args: { index: t },
|
|
@@ -633,19 +504,19 @@ const L = (t, e) => {
|
|
|
633
504
|
}
|
|
634
505
|
}
|
|
635
506
|
}
|
|
636
|
-
}).then((
|
|
637
|
-
list: (e, r = G) =>
|
|
507
|
+
}).then((o) => o.app.drive.folders), D = (t) => ({
|
|
508
|
+
list: (e, r = G) => ft(t, e, r),
|
|
638
509
|
create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
|
|
639
510
|
delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
|
|
640
|
-
rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((
|
|
641
|
-
}),
|
|
511
|
+
rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((o) => o.lightDriveRenameFolder)
|
|
512
|
+
}), $t = () => y({
|
|
642
513
|
app: {
|
|
643
514
|
drives: {
|
|
644
515
|
index: !0,
|
|
645
516
|
name: !0
|
|
646
517
|
}
|
|
647
518
|
}
|
|
648
|
-
}).then((t) => t.app.drives),
|
|
519
|
+
}).then((t) => t.app.drives), pt = (t) => ({
|
|
649
520
|
listFiles: m(t).list,
|
|
650
521
|
getFile: m(t).get,
|
|
651
522
|
readFile: m(t).read,
|
|
@@ -674,24 +545,24 @@ const L = (t, e) => {
|
|
|
674
545
|
first_name: !0,
|
|
675
546
|
last_name: !0,
|
|
676
547
|
status: !0
|
|
677
|
-
},
|
|
548
|
+
}, gt = (t) => p({
|
|
678
549
|
addUser: {
|
|
679
550
|
__args: t
|
|
680
551
|
}
|
|
681
|
-
}).then((e) => e.addUser),
|
|
552
|
+
}).then((e) => e.addUser), dt = (t) => p({
|
|
682
553
|
deleteUser: {
|
|
683
554
|
__args: { id: t }
|
|
684
555
|
}
|
|
685
|
-
}).then((e) => e.deleteUser),
|
|
556
|
+
}).then((e) => e.deleteUser), _t = (t = W) => k("Users", t).dataPath("app.listUser").fetch(), yt = (t, e) => p({
|
|
686
557
|
updateUser: {
|
|
687
558
|
__args: { id: t, data: e }
|
|
688
559
|
}
|
|
689
|
-
}).then((r) => r.updateUser),
|
|
690
|
-
list:
|
|
691
|
-
create:
|
|
692
|
-
delete:
|
|
693
|
-
update:
|
|
694
|
-
}),
|
|
560
|
+
}).then((r) => r.updateUser), wt = () => ({
|
|
561
|
+
list: _t,
|
|
562
|
+
create: gt,
|
|
563
|
+
delete: dt,
|
|
564
|
+
update: yt
|
|
565
|
+
}), mt = (t) => y({
|
|
695
566
|
app: {
|
|
696
567
|
listConfig: {
|
|
697
568
|
__args: {
|
|
@@ -707,11 +578,11 @@ const L = (t, e) => {
|
|
|
707
578
|
}
|
|
708
579
|
}).then((e) => e.app.listConfig.data[0]?.value), bt = {
|
|
709
580
|
name: !0
|
|
710
|
-
},
|
|
581
|
+
}, Ft = (t = bt) => y({
|
|
711
582
|
app: {
|
|
712
583
|
roles: t
|
|
713
584
|
}
|
|
714
|
-
}).then((e) => e.app.roles),
|
|
585
|
+
}).then((e) => e.app.roles), At = (t, e) => p({
|
|
715
586
|
addRole: {
|
|
716
587
|
__args: {
|
|
717
588
|
data: {
|
|
@@ -720,78 +591,78 @@ const L = (t, e) => {
|
|
|
720
591
|
}
|
|
721
592
|
}
|
|
722
593
|
}
|
|
723
|
-
}).then((r) => r.addRole),
|
|
594
|
+
}).then((r) => r.addRole), Ot = (t) => p({
|
|
724
595
|
deleteRole: {
|
|
725
596
|
__args: { name: t }
|
|
726
597
|
}
|
|
727
|
-
}).then((e) => e.deleteRole),
|
|
728
|
-
list:
|
|
729
|
-
create:
|
|
730
|
-
delete:
|
|
598
|
+
}).then((e) => e.deleteRole), Dt = () => ({
|
|
599
|
+
list: Ft,
|
|
600
|
+
create: At,
|
|
601
|
+
delete: Ot
|
|
731
602
|
});
|
|
732
|
-
function z(t, e, r,
|
|
603
|
+
function z(t, e, r, o, i) {
|
|
733
604
|
if (!(!t || typeof t != "object"))
|
|
734
|
-
for (let
|
|
735
|
-
const
|
|
736
|
-
if (
|
|
737
|
-
if ("__args" in
|
|
738
|
-
const
|
|
739
|
-
Object.entries(
|
|
740
|
-
if (c instanceof Array &&
|
|
741
|
-
s[
|
|
742
|
-
let
|
|
743
|
-
c.forEach((
|
|
744
|
-
|
|
745
|
-
}), e[
|
|
746
|
-
} else c instanceof File ? (s[
|
|
747
|
-
if (
|
|
748
|
-
s[
|
|
749
|
-
let
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
}), e[
|
|
753
|
-
} else
|
|
754
|
-
})) : c != null && (s[
|
|
755
|
-
}),
|
|
605
|
+
for (let u in t) {
|
|
606
|
+
const l = t[u];
|
|
607
|
+
if (l && typeof l == "object") {
|
|
608
|
+
if ("__args" in l) {
|
|
609
|
+
const h = l.__args, s = {};
|
|
610
|
+
Object.entries(h).forEach(([n, c]) => {
|
|
611
|
+
if (c instanceof Array && C(c)) {
|
|
612
|
+
s[n] = new b(n);
|
|
613
|
+
let a = 0;
|
|
614
|
+
c.forEach((f) => {
|
|
615
|
+
f instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + n + "." + a), o.append(i.current.toString(), f), i.current++, a++);
|
|
616
|
+
}), e[n] = "[Upload!]!";
|
|
617
|
+
} else c instanceof File ? (s[n] = new b(n), r[i.current] = ["variables." + n], o.append(i.current.toString(), c), e[n] = "Upload!", i.current++) : c instanceof Object && B(c) ? (s[n] = {}, Object.entries(c).forEach(([a, f]) => {
|
|
618
|
+
if (f instanceof Array && C(f)) {
|
|
619
|
+
s[n][a] = new b(a);
|
|
620
|
+
let g = 0;
|
|
621
|
+
f.forEach((_) => {
|
|
622
|
+
_ instanceof File && (r[i.current] || (r[i.current] = []), r[i.current].push("variables." + a + "." + g), o.append(i.current.toString(), _), i.current++, g++);
|
|
623
|
+
}), e[a] = "[Upload!]!";
|
|
624
|
+
} else f instanceof File ? (s[n][a] = new b(a), r[i.current] = ["variables." + a], o.append(i.current.toString(), f), e[a] = "Upload!", i.current++) : s[n][a] = f;
|
|
625
|
+
})) : c != null && (s[n] = c);
|
|
626
|
+
}), l.__args = s;
|
|
756
627
|
}
|
|
757
|
-
z(
|
|
628
|
+
z(l, e, r, o, i);
|
|
758
629
|
}
|
|
759
630
|
}
|
|
760
631
|
}
|
|
761
632
|
const p = async (t) => {
|
|
762
|
-
const r = N().axios,
|
|
763
|
-
let
|
|
764
|
-
const
|
|
765
|
-
z(
|
|
766
|
-
let
|
|
767
|
-
const
|
|
768
|
-
if (
|
|
769
|
-
query:
|
|
770
|
-
})),
|
|
771
|
-
query:
|
|
772
|
-
}),
|
|
773
|
-
throw new Error(
|
|
774
|
-
return
|
|
775
|
-
},
|
|
776
|
-
send:
|
|
777
|
-
},
|
|
633
|
+
const r = N().axios, o = t, i = new FormData();
|
|
634
|
+
let u = !1;
|
|
635
|
+
const l = {}, h = {};
|
|
636
|
+
z(o, l, h, i, { current: 0 }), u = Object.keys(l).length > 0, u && (o.__variables = l);
|
|
637
|
+
let n = null;
|
|
638
|
+
const a = M({ mutation: o });
|
|
639
|
+
if (u ? (i.append("map", JSON.stringify(h)), i.append("operations", JSON.stringify({
|
|
640
|
+
query: a
|
|
641
|
+
})), n = await r.post("", i)) : n = await r.post("", {
|
|
642
|
+
query: a
|
|
643
|
+
}), n.data.errors)
|
|
644
|
+
throw new Error(n.data.errors[0].message);
|
|
645
|
+
return n.data.data;
|
|
646
|
+
}, Ct = (t, e, r) => p({ sendMail: { __args: { email: t, subject: e, message: r } } }).then((o) => o.sendMail), jt = {
|
|
647
|
+
send: Ct
|
|
648
|
+
}, q = (t) => {
|
|
778
649
|
let e = {};
|
|
779
650
|
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
780
|
-
Object.entries(
|
|
781
|
-
e[
|
|
651
|
+
Object.entries(q(r)).forEach(([o, i]) => {
|
|
652
|
+
e[o] = i;
|
|
782
653
|
});
|
|
783
|
-
}), e) : (Object.entries(t).forEach(([r,
|
|
654
|
+
}), e) : (Object.entries(t).forEach(([r, o]) => {
|
|
784
655
|
if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
|
|
785
|
-
e[r] =
|
|
656
|
+
e[r] = o;
|
|
786
657
|
return;
|
|
787
658
|
}
|
|
788
|
-
if (typeof
|
|
789
|
-
e[r] =
|
|
659
|
+
if (typeof o == "boolean") {
|
|
660
|
+
e[r] = o;
|
|
790
661
|
return;
|
|
791
662
|
}
|
|
792
|
-
e[r] =
|
|
663
|
+
e[r] = q(o);
|
|
793
664
|
}), e);
|
|
794
|
-
}, kt = (t) =>
|
|
665
|
+
}, kt = (t) => q(t), Pt = "list", Et = [
|
|
795
666
|
"flatMap",
|
|
796
667
|
"chunk",
|
|
797
668
|
"shuffle",
|
|
@@ -817,7 +688,7 @@ const p = async (t) => {
|
|
|
817
688
|
"slice",
|
|
818
689
|
"tap",
|
|
819
690
|
"sort"
|
|
820
|
-
],
|
|
691
|
+
], Ut = [
|
|
821
692
|
"avg",
|
|
822
693
|
"count",
|
|
823
694
|
"countBy",
|
|
@@ -888,14 +759,14 @@ d.prototype.clone = function() {
|
|
|
888
759
|
const t = Object.create(this);
|
|
889
760
|
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;
|
|
890
761
|
};
|
|
891
|
-
|
|
762
|
+
S().macro("whereContains", function(t, e) {
|
|
892
763
|
return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
|
|
893
764
|
});
|
|
894
765
|
d.prototype.fetchData = async function() {
|
|
895
766
|
try {
|
|
896
767
|
if (this._batchData) {
|
|
897
|
-
const
|
|
898
|
-
return this.meta =
|
|
768
|
+
const h = this._batchData;
|
|
769
|
+
return this.meta = h.meta, S(h.data);
|
|
899
770
|
}
|
|
900
771
|
let t = {
|
|
901
772
|
meta: {
|
|
@@ -906,18 +777,18 @@ d.prototype.fetchData = async function() {
|
|
|
906
777
|
};
|
|
907
778
|
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);
|
|
908
779
|
const e = this.data_path.split(".");
|
|
909
|
-
let r = {},
|
|
910
|
-
for (const
|
|
911
|
-
if (
|
|
912
|
-
|
|
780
|
+
let r = {}, o = r, i = e[e.length - 1];
|
|
781
|
+
for (const h of e) {
|
|
782
|
+
if (h === i) {
|
|
783
|
+
o[h] = t;
|
|
913
784
|
break;
|
|
914
785
|
}
|
|
915
|
-
|
|
786
|
+
o[h] = {}, o = o[h];
|
|
916
787
|
}
|
|
917
|
-
let
|
|
918
|
-
for (const
|
|
919
|
-
|
|
920
|
-
return this.meta =
|
|
788
|
+
let l = await y(r);
|
|
789
|
+
for (const h of e)
|
|
790
|
+
l = l[h];
|
|
791
|
+
return this.meta = l.meta, S(l.data);
|
|
921
792
|
} catch (t) {
|
|
922
793
|
throw console.error("Error fetching collection data:", t), t;
|
|
923
794
|
}
|
|
@@ -931,12 +802,12 @@ d.prototype.processData = async function() {
|
|
|
931
802
|
d.prototype.all = async function() {
|
|
932
803
|
return (await this.processData()).all();
|
|
933
804
|
};
|
|
934
|
-
for (const t of
|
|
805
|
+
for (const t of Et)
|
|
935
806
|
d.prototype[t] = function(...e) {
|
|
936
807
|
const r = this.clone();
|
|
937
808
|
return r.steps.push({ type: t, args: e }), r;
|
|
938
809
|
};
|
|
939
|
-
for (const t of
|
|
810
|
+
for (const t of Ut)
|
|
940
811
|
d.prototype[t] = async function(...e) {
|
|
941
812
|
return (await this.clone().processData())[t](...e);
|
|
942
813
|
};
|
|
@@ -953,8 +824,8 @@ d.prototype.where = function(...t) {
|
|
|
953
824
|
if (t.length === 2)
|
|
954
825
|
this.filters[t[0]] = t[1];
|
|
955
826
|
else if (t.length === 3) {
|
|
956
|
-
const r = t[0],
|
|
957
|
-
switch (
|
|
827
|
+
const r = t[0], o = t[1], i = t[2];
|
|
828
|
+
switch (o) {
|
|
958
829
|
case "==":
|
|
959
830
|
this.filters[r] = i;
|
|
960
831
|
break;
|
|
@@ -974,7 +845,7 @@ d.prototype.where = function(...t) {
|
|
|
974
845
|
this.filters[r] = { ne: i };
|
|
975
846
|
break;
|
|
976
847
|
default:
|
|
977
|
-
throw new Error(`Unsupported operator: ${
|
|
848
|
+
throw new Error(`Unsupported operator: ${o}`);
|
|
978
849
|
}
|
|
979
850
|
}
|
|
980
851
|
return this;
|
|
@@ -1023,125 +894,126 @@ d.prototype.splice = function(t, e) {
|
|
|
1023
894
|
};
|
|
1024
895
|
const R = (t, e) => {
|
|
1025
896
|
const r = new d(e);
|
|
1026
|
-
return r.data_path =
|
|
1027
|
-
},
|
|
897
|
+
return r.data_path = Pt + t, r;
|
|
898
|
+
}, St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1028
899
|
__proto__: null,
|
|
1029
900
|
default: R
|
|
1030
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
901
|
+
}, Symbol.toStringTag, { value: "Module" })), Gt = (t) => {
|
|
1031
902
|
const e = typeof window > "u";
|
|
1032
903
|
let r = [];
|
|
1033
|
-
const
|
|
904
|
+
const o = H.create({
|
|
1034
905
|
baseURL: t,
|
|
1035
906
|
withCredentials: !0
|
|
1036
907
|
});
|
|
1037
|
-
e && (
|
|
1038
|
-
if (
|
|
1039
|
-
const
|
|
1040
|
-
r.forEach((
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
}),
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1046
|
-
}), r = Array.from(
|
|
908
|
+
e && (o.interceptors.request.use((u) => (u.withCredentials = !0, r.length > 0 && (u.headers.Cookie = r.join("; ")), u)), o.interceptors.response.use((u) => {
|
|
909
|
+
if (u.headers["set-cookie"]) {
|
|
910
|
+
const l = u.headers["set-cookie"].map((s) => s.split(";")[0]), h = /* @__PURE__ */ new Map();
|
|
911
|
+
r.forEach((s) => {
|
|
912
|
+
const n = s.split("=")[0];
|
|
913
|
+
h.set(n, s);
|
|
914
|
+
}), l.forEach((s) => {
|
|
915
|
+
const n = s.split("=")[0];
|
|
916
|
+
h.set(n, s);
|
|
917
|
+
}), r = Array.from(h.values());
|
|
1047
918
|
}
|
|
1048
|
-
return
|
|
919
|
+
return u;
|
|
1049
920
|
}));
|
|
1050
|
-
const i =
|
|
1051
|
-
post:
|
|
921
|
+
const i = {
|
|
922
|
+
post: o.post,
|
|
1052
923
|
baseURL: t,
|
|
1053
|
-
axios:
|
|
1054
|
-
auth:
|
|
924
|
+
axios: o,
|
|
925
|
+
auth: lt(),
|
|
1055
926
|
mutation: p,
|
|
1056
927
|
query: y,
|
|
1057
|
-
config:
|
|
928
|
+
config: mt,
|
|
1058
929
|
mail: jt,
|
|
1059
|
-
users:
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
return i.get(a);
|
|
930
|
+
users: wt(),
|
|
931
|
+
model(u) {
|
|
932
|
+
return U(u);
|
|
1063
933
|
},
|
|
1064
|
-
roles:
|
|
1065
|
-
collect: (
|
|
1066
|
-
const
|
|
1067
|
-
return
|
|
934
|
+
roles: Dt(),
|
|
935
|
+
collect: (u, l) => {
|
|
936
|
+
const h = R(u, l);
|
|
937
|
+
return h.data_path = U(u).getDataPath(), h;
|
|
1068
938
|
},
|
|
1069
|
-
list: (
|
|
1070
|
-
drive:
|
|
1071
|
-
async collects(
|
|
1072
|
-
const
|
|
1073
|
-
for (const
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
const
|
|
1077
|
-
let
|
|
1078
|
-
for (const
|
|
1079
|
-
if (
|
|
1080
|
-
g[
|
|
939
|
+
list: (u, l) => k(u, l).dataPath(U(u).getDataPath()),
|
|
940
|
+
drive: pt,
|
|
941
|
+
async collects(u) {
|
|
942
|
+
const l = {}, h = {};
|
|
943
|
+
for (const n in u) {
|
|
944
|
+
const c = u[n].getQueryPayload();
|
|
945
|
+
h[n] = c.data_path, l[n] = {};
|
|
946
|
+
const a = c.data_path.split(".");
|
|
947
|
+
let f = a[a.length - 1], g = l[n];
|
|
948
|
+
for (const _ of a) {
|
|
949
|
+
if (_ === f) {
|
|
950
|
+
g[_] = c.query;
|
|
1081
951
|
break;
|
|
1082
952
|
}
|
|
1083
|
-
g[
|
|
953
|
+
g[_] = g[_] || {};
|
|
1084
954
|
}
|
|
1085
|
-
|
|
955
|
+
l[n].__aliasFor = a[0];
|
|
1086
956
|
}
|
|
1087
|
-
const
|
|
1088
|
-
for (const
|
|
1089
|
-
const
|
|
1090
|
-
let
|
|
1091
|
-
for (const g of
|
|
1092
|
-
if (g ===
|
|
1093
|
-
|
|
957
|
+
const s = await y(l);
|
|
958
|
+
for (const n in u) {
|
|
959
|
+
const c = h[n].split(".");
|
|
960
|
+
let a = c[c.length - 1], f = s[n];
|
|
961
|
+
for (const g of c) {
|
|
962
|
+
if (g === a) {
|
|
963
|
+
u[n]._batchData = s[n][g];
|
|
1094
964
|
break;
|
|
1095
965
|
}
|
|
1096
|
-
|
|
966
|
+
f[g] = f[g] || {};
|
|
1097
967
|
}
|
|
1098
968
|
}
|
|
1099
|
-
return
|
|
969
|
+
return u;
|
|
1100
970
|
}
|
|
1101
971
|
};
|
|
1102
|
-
return Y(
|
|
1103
|
-
},
|
|
972
|
+
return Y(i), i;
|
|
973
|
+
}, Wt = k;
|
|
1104
974
|
export {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
975
|
+
lt as auth,
|
|
976
|
+
rt as changeExpiredPassword,
|
|
977
|
+
Lt as clearModels,
|
|
978
|
+
Gt as createClient,
|
|
1108
979
|
R as createCollection,
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
pt as createUser,
|
|
980
|
+
k as createList,
|
|
981
|
+
At as createRole,
|
|
982
|
+
gt as createUser,
|
|
1113
983
|
W as defaultUserFields,
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
984
|
+
L as defineModel,
|
|
985
|
+
Qt as defineModels,
|
|
986
|
+
Ot as deleteRole,
|
|
987
|
+
dt as deleteUser,
|
|
988
|
+
ot as forgetPassword,
|
|
1117
989
|
N as getApiClient,
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
990
|
+
Nt as getApiClientOptional,
|
|
991
|
+
mt as getConfig,
|
|
992
|
+
x as getCurrentUser,
|
|
993
|
+
pt as getDrive,
|
|
994
|
+
ct as getGrantedRights,
|
|
995
|
+
U as getModel,
|
|
996
|
+
Bt as hasModel,
|
|
997
|
+
at as isGranted,
|
|
998
|
+
Wt as list,
|
|
999
|
+
$t as listDrives,
|
|
1000
|
+
ut as listFiles,
|
|
1001
|
+
ft as listFolders,
|
|
1002
|
+
Jt as listModels,
|
|
1003
|
+
Tt as listPermissions,
|
|
1004
|
+
Ft as listRoles,
|
|
1005
|
+
_t as listUsers,
|
|
1006
|
+
tt as login,
|
|
1007
|
+
et as logout,
|
|
1133
1008
|
p as mutation,
|
|
1134
1009
|
y as query,
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1010
|
+
ht as readFileAsBase64,
|
|
1011
|
+
nt as resetPassword,
|
|
1012
|
+
Ct as sendMail,
|
|
1138
1013
|
Y as setApiClient,
|
|
1139
1014
|
kt as toQuery,
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
Jt as useGlobalModels,
|
|
1144
|
-
Nt as useModel,
|
|
1145
|
-
ot as verifyCode,
|
|
1015
|
+
st as updatePassword,
|
|
1016
|
+
yt as updateUser,
|
|
1017
|
+
it as verifyCode,
|
|
1146
1018
|
K as webAuthn
|
|
1147
1019
|
};
|