@hostlink/light 3.0.4 → 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 +1 -2
- package/dist/light.js +366 -498
- package/dist/light.umd.cjs +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/models.d.ts +205 -88
- 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,7 +344,7 @@ 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: {
|
|
@@ -486,7 +353,7 @@ const L = (t, e) => {
|
|
|
486
353
|
}
|
|
487
354
|
}
|
|
488
355
|
}).then((e) => e.webAuthnAssertion);
|
|
489
|
-
},
|
|
356
|
+
}, I = async () => {
|
|
490
357
|
const t = await T();
|
|
491
358
|
return await p({
|
|
492
359
|
webAuthnRegister: {
|
|
@@ -499,9 +366,9 @@ const L = (t, e) => {
|
|
|
499
366
|
__proto__: null,
|
|
500
367
|
assertion: Q,
|
|
501
368
|
attestation: T,
|
|
502
|
-
login:
|
|
503
|
-
register:
|
|
504
|
-
}, 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({
|
|
505
372
|
my: {
|
|
506
373
|
granted: {
|
|
507
374
|
__args: {
|
|
@@ -509,7 +376,7 @@ const L = (t, e) => {
|
|
|
509
376
|
}
|
|
510
377
|
}
|
|
511
378
|
}
|
|
512
|
-
}).then((e) => e.my.granted),
|
|
379
|
+
}).then((e) => e.my.granted), ct = (t) => y({
|
|
513
380
|
my: {
|
|
514
381
|
grantedRights: {
|
|
515
382
|
__args: {
|
|
@@ -517,8 +384,8 @@ const L = (t, e) => {
|
|
|
517
384
|
}
|
|
518
385
|
}
|
|
519
386
|
}
|
|
520
|
-
}).then((e) => e.my.grantedRights),
|
|
521
|
-
getCurrentUser:
|
|
387
|
+
}).then((e) => e.my.grantedRights), lt = () => ({
|
|
388
|
+
getCurrentUser: x,
|
|
522
389
|
webAuthn: K,
|
|
523
390
|
google: {
|
|
524
391
|
unlink: () => p({ lightAuthUnlinkGoogle: !0 }).then((t) => t.lightAuthUnlinkGoogle),
|
|
@@ -535,22 +402,22 @@ const L = (t, e) => {
|
|
|
535
402
|
login: (t) => p({ lightAuthLoginMicrosoft: { __args: { access_token: t } } }).then((e) => e.lightAuthLoginMicrosoft),
|
|
536
403
|
register: (t) => p({ lightAuthRegisterMicrosoft: { __args: { account_id: t } } }).then((e) => e.lightAuthRegisterMicrosoft)
|
|
537
404
|
},
|
|
538
|
-
login:
|
|
539
|
-
logout:
|
|
540
|
-
changeExpiredPassword:
|
|
541
|
-
updatePassword:
|
|
542
|
-
resetPassword:
|
|
543
|
-
forgetPassword:
|
|
544
|
-
verifyCode:
|
|
545
|
-
grantedRights:
|
|
546
|
-
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
|
|
547
414
|
}), $ = {
|
|
548
415
|
name: !0,
|
|
549
416
|
path: !0,
|
|
550
417
|
size: !0,
|
|
551
418
|
mime: !0,
|
|
552
419
|
url: !0
|
|
553
|
-
},
|
|
420
|
+
}, ut = (t, e, r = $) => y({
|
|
554
421
|
app: {
|
|
555
422
|
drive: {
|
|
556
423
|
__args: { index: t },
|
|
@@ -560,7 +427,7 @@ const L = (t, e) => {
|
|
|
560
427
|
}
|
|
561
428
|
}
|
|
562
429
|
}
|
|
563
|
-
}).then((
|
|
430
|
+
}).then((o) => o.app.drive.files), ht = (t, e) => y({
|
|
564
431
|
app: {
|
|
565
432
|
drive: {
|
|
566
433
|
__args: {
|
|
@@ -575,7 +442,7 @@ const L = (t, e) => {
|
|
|
575
442
|
}
|
|
576
443
|
}
|
|
577
444
|
}).then((r) => r.app.drive?.file?.base64Content), m = (t) => ({
|
|
578
|
-
list: (e, r = $) =>
|
|
445
|
+
list: (e, r = $) => ut(t, e, r),
|
|
579
446
|
get: (e, r = {
|
|
580
447
|
name: !0,
|
|
581
448
|
path: !0,
|
|
@@ -596,9 +463,9 @@ const L = (t, e) => {
|
|
|
596
463
|
}
|
|
597
464
|
}
|
|
598
465
|
}
|
|
599
|
-
}).then((
|
|
466
|
+
}).then((o) => o.app.drive.file),
|
|
600
467
|
readFileAsBase64(e) {
|
|
601
|
-
return
|
|
468
|
+
return ht(t, e);
|
|
602
469
|
},
|
|
603
470
|
read: async (e) => {
|
|
604
471
|
let r = await y({
|
|
@@ -620,14 +487,14 @@ const L = (t, e) => {
|
|
|
620
487
|
throw new Error(`File not found or cannot read content: ${e}`);
|
|
621
488
|
return typeof window < "u" && window.atob ? window.atob(r.app.drive.file.base64Content) : r.app.drive.file.base64Content;
|
|
622
489
|
},
|
|
623
|
-
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),
|
|
624
491
|
delete: (e) => p({ lightDriveDeleteFile: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFile),
|
|
625
|
-
rename: (e, r) => p({ lightDriveRenameFile: { __args: { index: t, path: e, name: r } } }).then((
|
|
626
|
-
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)
|
|
627
494
|
}), G = {
|
|
628
495
|
name: !0,
|
|
629
496
|
path: !0
|
|
630
|
-
},
|
|
497
|
+
}, ft = (t, e, r = G) => y({
|
|
631
498
|
app: {
|
|
632
499
|
drive: {
|
|
633
500
|
__args: { index: t },
|
|
@@ -637,19 +504,19 @@ const L = (t, e) => {
|
|
|
637
504
|
}
|
|
638
505
|
}
|
|
639
506
|
}
|
|
640
|
-
}).then((
|
|
641
|
-
list: (e, r = G) =>
|
|
507
|
+
}).then((o) => o.app.drive.folders), D = (t) => ({
|
|
508
|
+
list: (e, r = G) => ft(t, e, r),
|
|
642
509
|
create: (e) => p({ lightDriveCreateFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveCreateFolder),
|
|
643
510
|
delete: (e) => p({ lightDriveDeleteFolder: { __args: { index: t, path: e } } }).then((r) => r.lightDriveDeleteFolder),
|
|
644
|
-
rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((
|
|
645
|
-
}),
|
|
511
|
+
rename: (e, r) => p({ lightDriveRenameFolder: { __args: { index: t, path: e, name: r } } }).then((o) => o.lightDriveRenameFolder)
|
|
512
|
+
}), $t = () => y({
|
|
646
513
|
app: {
|
|
647
514
|
drives: {
|
|
648
515
|
index: !0,
|
|
649
516
|
name: !0
|
|
650
517
|
}
|
|
651
518
|
}
|
|
652
|
-
}).then((t) => t.app.drives),
|
|
519
|
+
}).then((t) => t.app.drives), pt = (t) => ({
|
|
653
520
|
listFiles: m(t).list,
|
|
654
521
|
getFile: m(t).get,
|
|
655
522
|
readFile: m(t).read,
|
|
@@ -678,24 +545,24 @@ const L = (t, e) => {
|
|
|
678
545
|
first_name: !0,
|
|
679
546
|
last_name: !0,
|
|
680
547
|
status: !0
|
|
681
|
-
},
|
|
548
|
+
}, gt = (t) => p({
|
|
682
549
|
addUser: {
|
|
683
550
|
__args: t
|
|
684
551
|
}
|
|
685
|
-
}).then((e) => e.addUser),
|
|
552
|
+
}).then((e) => e.addUser), dt = (t) => p({
|
|
686
553
|
deleteUser: {
|
|
687
554
|
__args: { id: t }
|
|
688
555
|
}
|
|
689
|
-
}).then((e) => e.deleteUser),
|
|
556
|
+
}).then((e) => e.deleteUser), _t = (t = W) => k("Users", t).dataPath("app.listUser").fetch(), yt = (t, e) => p({
|
|
690
557
|
updateUser: {
|
|
691
558
|
__args: { id: t, data: e }
|
|
692
559
|
}
|
|
693
|
-
}).then((r) => r.updateUser),
|
|
694
|
-
list:
|
|
695
|
-
create:
|
|
696
|
-
delete:
|
|
697
|
-
update:
|
|
698
|
-
}),
|
|
560
|
+
}).then((r) => r.updateUser), wt = () => ({
|
|
561
|
+
list: _t,
|
|
562
|
+
create: gt,
|
|
563
|
+
delete: dt,
|
|
564
|
+
update: yt
|
|
565
|
+
}), mt = (t) => y({
|
|
699
566
|
app: {
|
|
700
567
|
listConfig: {
|
|
701
568
|
__args: {
|
|
@@ -711,11 +578,11 @@ const L = (t, e) => {
|
|
|
711
578
|
}
|
|
712
579
|
}).then((e) => e.app.listConfig.data[0]?.value), bt = {
|
|
713
580
|
name: !0
|
|
714
|
-
},
|
|
581
|
+
}, Ft = (t = bt) => y({
|
|
715
582
|
app: {
|
|
716
583
|
roles: t
|
|
717
584
|
}
|
|
718
|
-
}).then((e) => e.app.roles),
|
|
585
|
+
}).then((e) => e.app.roles), At = (t, e) => p({
|
|
719
586
|
addRole: {
|
|
720
587
|
__args: {
|
|
721
588
|
data: {
|
|
@@ -724,78 +591,78 @@ const L = (t, e) => {
|
|
|
724
591
|
}
|
|
725
592
|
}
|
|
726
593
|
}
|
|
727
|
-
}).then((r) => r.addRole),
|
|
594
|
+
}).then((r) => r.addRole), Ot = (t) => p({
|
|
728
595
|
deleteRole: {
|
|
729
596
|
__args: { name: t }
|
|
730
597
|
}
|
|
731
|
-
}).then((e) => e.deleteRole),
|
|
732
|
-
list:
|
|
733
|
-
create:
|
|
734
|
-
delete:
|
|
598
|
+
}).then((e) => e.deleteRole), Dt = () => ({
|
|
599
|
+
list: Ft,
|
|
600
|
+
create: At,
|
|
601
|
+
delete: Ot
|
|
735
602
|
});
|
|
736
|
-
function z(t, e, r,
|
|
603
|
+
function z(t, e, r, o, i) {
|
|
737
604
|
if (!(!t || typeof t != "object"))
|
|
738
|
-
for (let
|
|
739
|
-
const
|
|
740
|
-
if (
|
|
741
|
-
if ("__args" in
|
|
742
|
-
const
|
|
743
|
-
Object.entries(
|
|
744
|
-
if (c instanceof Array &&
|
|
745
|
-
s[
|
|
746
|
-
let
|
|
747
|
-
c.forEach((
|
|
748
|
-
|
|
749
|
-
}), e[
|
|
750
|
-
} else c instanceof File ? (s[
|
|
751
|
-
if (
|
|
752
|
-
s[
|
|
753
|
-
let
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}), e[
|
|
757
|
-
} else
|
|
758
|
-
})) : c != null && (s[
|
|
759
|
-
}),
|
|
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;
|
|
760
627
|
}
|
|
761
|
-
z(
|
|
628
|
+
z(l, e, r, o, i);
|
|
762
629
|
}
|
|
763
630
|
}
|
|
764
631
|
}
|
|
765
632
|
const p = async (t) => {
|
|
766
|
-
const r = N().axios,
|
|
767
|
-
let
|
|
768
|
-
const
|
|
769
|
-
z(
|
|
770
|
-
let
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
773
|
-
query:
|
|
774
|
-
})),
|
|
775
|
-
query:
|
|
776
|
-
}),
|
|
777
|
-
throw new Error(
|
|
778
|
-
return
|
|
779
|
-
},
|
|
780
|
-
send:
|
|
781
|
-
},
|
|
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) => {
|
|
782
649
|
let e = {};
|
|
783
650
|
return typeof t == "string" ? (e[t] = !0, e) : t instanceof Array ? (t.forEach((r) => {
|
|
784
|
-
Object.entries(
|
|
785
|
-
e[
|
|
651
|
+
Object.entries(q(r)).forEach(([o, i]) => {
|
|
652
|
+
e[o] = i;
|
|
786
653
|
});
|
|
787
|
-
}), e) : (Object.entries(t).forEach(([r,
|
|
654
|
+
}), e) : (Object.entries(t).forEach(([r, o]) => {
|
|
788
655
|
if (r == "__args" || r == "__aliasFor" || r == "__variables" || r == "__directives" || r == "__all_on" || r == "__name") {
|
|
789
|
-
e[r] =
|
|
656
|
+
e[r] = o;
|
|
790
657
|
return;
|
|
791
658
|
}
|
|
792
|
-
if (typeof
|
|
793
|
-
e[r] =
|
|
659
|
+
if (typeof o == "boolean") {
|
|
660
|
+
e[r] = o;
|
|
794
661
|
return;
|
|
795
662
|
}
|
|
796
|
-
e[r] =
|
|
663
|
+
e[r] = q(o);
|
|
797
664
|
}), e);
|
|
798
|
-
}, kt = (t) =>
|
|
665
|
+
}, kt = (t) => q(t), Pt = "list", Et = [
|
|
799
666
|
"flatMap",
|
|
800
667
|
"chunk",
|
|
801
668
|
"shuffle",
|
|
@@ -821,7 +688,7 @@ const p = async (t) => {
|
|
|
821
688
|
"slice",
|
|
822
689
|
"tap",
|
|
823
690
|
"sort"
|
|
824
|
-
],
|
|
691
|
+
], Ut = [
|
|
825
692
|
"avg",
|
|
826
693
|
"count",
|
|
827
694
|
"countBy",
|
|
@@ -892,14 +759,14 @@ d.prototype.clone = function() {
|
|
|
892
759
|
const t = Object.create(this);
|
|
893
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;
|
|
894
761
|
};
|
|
895
|
-
|
|
762
|
+
S().macro("whereContains", function(t, e) {
|
|
896
763
|
return this.filter((r) => r[t].toLowerCase().includes(e.toLowerCase()));
|
|
897
764
|
});
|
|
898
765
|
d.prototype.fetchData = async function() {
|
|
899
766
|
try {
|
|
900
767
|
if (this._batchData) {
|
|
901
|
-
const
|
|
902
|
-
return this.meta =
|
|
768
|
+
const h = this._batchData;
|
|
769
|
+
return this.meta = h.meta, S(h.data);
|
|
903
770
|
}
|
|
904
771
|
let t = {
|
|
905
772
|
meta: {
|
|
@@ -910,18 +777,18 @@ d.prototype.fetchData = async function() {
|
|
|
910
777
|
};
|
|
911
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);
|
|
912
779
|
const e = this.data_path.split(".");
|
|
913
|
-
let r = {},
|
|
914
|
-
for (const
|
|
915
|
-
if (
|
|
916
|
-
|
|
780
|
+
let r = {}, o = r, i = e[e.length - 1];
|
|
781
|
+
for (const h of e) {
|
|
782
|
+
if (h === i) {
|
|
783
|
+
o[h] = t;
|
|
917
784
|
break;
|
|
918
785
|
}
|
|
919
|
-
|
|
786
|
+
o[h] = {}, o = o[h];
|
|
920
787
|
}
|
|
921
|
-
let
|
|
922
|
-
for (const
|
|
923
|
-
|
|
924
|
-
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);
|
|
925
792
|
} catch (t) {
|
|
926
793
|
throw console.error("Error fetching collection data:", t), t;
|
|
927
794
|
}
|
|
@@ -935,12 +802,12 @@ d.prototype.processData = async function() {
|
|
|
935
802
|
d.prototype.all = async function() {
|
|
936
803
|
return (await this.processData()).all();
|
|
937
804
|
};
|
|
938
|
-
for (const t of
|
|
805
|
+
for (const t of Et)
|
|
939
806
|
d.prototype[t] = function(...e) {
|
|
940
807
|
const r = this.clone();
|
|
941
808
|
return r.steps.push({ type: t, args: e }), r;
|
|
942
809
|
};
|
|
943
|
-
for (const t of
|
|
810
|
+
for (const t of Ut)
|
|
944
811
|
d.prototype[t] = async function(...e) {
|
|
945
812
|
return (await this.clone().processData())[t](...e);
|
|
946
813
|
};
|
|
@@ -957,8 +824,8 @@ d.prototype.where = function(...t) {
|
|
|
957
824
|
if (t.length === 2)
|
|
958
825
|
this.filters[t[0]] = t[1];
|
|
959
826
|
else if (t.length === 3) {
|
|
960
|
-
const r = t[0],
|
|
961
|
-
switch (
|
|
827
|
+
const r = t[0], o = t[1], i = t[2];
|
|
828
|
+
switch (o) {
|
|
962
829
|
case "==":
|
|
963
830
|
this.filters[r] = i;
|
|
964
831
|
break;
|
|
@@ -978,7 +845,7 @@ d.prototype.where = function(...t) {
|
|
|
978
845
|
this.filters[r] = { ne: i };
|
|
979
846
|
break;
|
|
980
847
|
default:
|
|
981
|
-
throw new Error(`Unsupported operator: ${
|
|
848
|
+
throw new Error(`Unsupported operator: ${o}`);
|
|
982
849
|
}
|
|
983
850
|
}
|
|
984
851
|
return this;
|
|
@@ -1027,125 +894,126 @@ d.prototype.splice = function(t, e) {
|
|
|
1027
894
|
};
|
|
1028
895
|
const R = (t, e) => {
|
|
1029
896
|
const r = new d(e);
|
|
1030
|
-
return r.data_path =
|
|
1031
|
-
},
|
|
897
|
+
return r.data_path = Pt + t, r;
|
|
898
|
+
}, St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1032
899
|
__proto__: null,
|
|
1033
900
|
default: R
|
|
1034
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
901
|
+
}, Symbol.toStringTag, { value: "Module" })), Gt = (t) => {
|
|
1035
902
|
const e = typeof window > "u";
|
|
1036
903
|
let r = [];
|
|
1037
|
-
const
|
|
904
|
+
const o = H.create({
|
|
1038
905
|
baseURL: t,
|
|
1039
906
|
withCredentials: !0
|
|
1040
907
|
});
|
|
1041
|
-
e && (
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
r.forEach((
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
}),
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
}), 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());
|
|
1051
918
|
}
|
|
1052
|
-
return
|
|
919
|
+
return u;
|
|
1053
920
|
}));
|
|
1054
|
-
const i =
|
|
1055
|
-
post:
|
|
921
|
+
const i = {
|
|
922
|
+
post: o.post,
|
|
1056
923
|
baseURL: t,
|
|
1057
|
-
axios:
|
|
1058
|
-
auth:
|
|
924
|
+
axios: o,
|
|
925
|
+
auth: lt(),
|
|
1059
926
|
mutation: p,
|
|
1060
927
|
query: y,
|
|
1061
|
-
config:
|
|
928
|
+
config: mt,
|
|
1062
929
|
mail: jt,
|
|
1063
|
-
users:
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
return i.get(a);
|
|
930
|
+
users: wt(),
|
|
931
|
+
model(u) {
|
|
932
|
+
return U(u);
|
|
1067
933
|
},
|
|
1068
|
-
roles:
|
|
1069
|
-
collect: (
|
|
1070
|
-
const
|
|
1071
|
-
return
|
|
934
|
+
roles: Dt(),
|
|
935
|
+
collect: (u, l) => {
|
|
936
|
+
const h = R(u, l);
|
|
937
|
+
return h.data_path = U(u).getDataPath(), h;
|
|
1072
938
|
},
|
|
1073
|
-
list: (
|
|
1074
|
-
drive:
|
|
1075
|
-
async collects(
|
|
1076
|
-
const
|
|
1077
|
-
for (const
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
const
|
|
1081
|
-
let
|
|
1082
|
-
for (const
|
|
1083
|
-
if (
|
|
1084
|
-
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;
|
|
1085
951
|
break;
|
|
1086
952
|
}
|
|
1087
|
-
g[
|
|
953
|
+
g[_] = g[_] || {};
|
|
1088
954
|
}
|
|
1089
|
-
|
|
955
|
+
l[n].__aliasFor = a[0];
|
|
1090
956
|
}
|
|
1091
|
-
const
|
|
1092
|
-
for (const
|
|
1093
|
-
const
|
|
1094
|
-
let
|
|
1095
|
-
for (const g of
|
|
1096
|
-
if (g ===
|
|
1097
|
-
|
|
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];
|
|
1098
964
|
break;
|
|
1099
965
|
}
|
|
1100
|
-
|
|
966
|
+
f[g] = f[g] || {};
|
|
1101
967
|
}
|
|
1102
968
|
}
|
|
1103
|
-
return
|
|
969
|
+
return u;
|
|
1104
970
|
}
|
|
1105
971
|
};
|
|
1106
|
-
return Y(
|
|
1107
|
-
},
|
|
972
|
+
return Y(i), i;
|
|
973
|
+
}, Wt = k;
|
|
1108
974
|
export {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
975
|
+
lt as auth,
|
|
976
|
+
rt as changeExpiredPassword,
|
|
977
|
+
Lt as clearModels,
|
|
978
|
+
Gt as createClient,
|
|
1112
979
|
R as createCollection,
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
pt as createUser,
|
|
980
|
+
k as createList,
|
|
981
|
+
At as createRole,
|
|
982
|
+
gt as createUser,
|
|
1117
983
|
W as defaultUserFields,
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
984
|
+
L as defineModel,
|
|
985
|
+
Qt as defineModels,
|
|
986
|
+
Ot as deleteRole,
|
|
987
|
+
dt as deleteUser,
|
|
988
|
+
ot as forgetPassword,
|
|
1121
989
|
N as getApiClient,
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
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,
|
|
1137
1008
|
p as mutation,
|
|
1138
1009
|
y as query,
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1010
|
+
ht as readFileAsBase64,
|
|
1011
|
+
nt as resetPassword,
|
|
1012
|
+
Ct as sendMail,
|
|
1142
1013
|
Y as setApiClient,
|
|
1143
1014
|
kt as toQuery,
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
Jt as useGlobalModels,
|
|
1148
|
-
Nt as useModel,
|
|
1149
|
-
ot as verifyCode,
|
|
1015
|
+
st as updatePassword,
|
|
1016
|
+
yt as updateUser,
|
|
1017
|
+
it as verifyCode,
|
|
1150
1018
|
K as webAuthn
|
|
1151
1019
|
};
|