@luminix/core 0.0.1-beta.9 → 0.1.0-beta.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/core.js +1034 -1922
- package/package.json +5 -9
- package/types/contracts/Builder.d.ts +46 -0
- package/types/contracts/ModelCollection.d.ts +7 -0
- package/{dist → types}/contracts/Plugin.d.ts +3 -3
- package/{dist → types}/contracts/Relation/BelongsTo.d.ts +3 -5
- package/{dist → types}/contracts/Relation/BelongsToMany.d.ts +7 -9
- package/{dist → types}/contracts/Relation/HasMany.d.ts +6 -7
- package/{dist → types}/contracts/Relation/HasOne.d.ts +3 -4
- package/{dist → types}/contracts/Relation/HasOneOrMany.d.ts +0 -1
- package/{dist → types}/contracts/Relation/MorphMany.d.ts +6 -7
- package/{dist → types}/contracts/Relation/MorphOne.d.ts +3 -4
- package/{dist → types}/contracts/Relation/MorphOneOrMany.d.ts +0 -1
- package/{dist → types}/contracts/Relation/MorphTo.d.ts +0 -1
- package/types/contracts/Relation/MorphToMany.d.ts +8 -0
- package/{dist → types}/contracts/Relation.d.ts +12 -9
- package/types/facades/App.d.ts +12 -0
- package/types/facades/Auth.d.ts +7 -0
- package/types/facades/Config.d.ts +7 -0
- package/types/facades/Error.d.ts +10 -0
- package/types/facades/Http.d.ts +8 -0
- package/types/facades/Log.d.ts +7 -0
- package/types/facades/Model.d.ts +8 -0
- package/types/facades/Route.d.ts +7 -0
- package/types/helpers/app.d.ts +4 -0
- package/{dist → types}/helpers/auth.d.ts +0 -1
- package/types/helpers/collect.d.ts +2 -0
- package/{dist → types}/helpers/config.d.ts +0 -1
- package/{dist → types}/helpers/error.d.ts +0 -1
- package/types/helpers/log.d.ts +5 -0
- package/{dist → types}/helpers/model.d.ts +2 -3
- package/{dist → types}/helpers/route.d.ts +2 -2
- package/{dist → types}/index.d.ts +10 -10
- package/types/mixins/BaseModel.d.ts +7 -0
- package/types/providers/LuminixServiceProvider.d.ts +9 -0
- package/types/services/AuthService.d.ts +18 -0
- package/{dist/facades/Error.d.ts → types/services/ErrorService.d.ts} +2 -6
- package/types/services/HttpService.d.ts +21 -0
- package/{dist/facades/Log.d.ts → types/services/LogService.d.ts} +2 -4
- package/types/services/ModelService.d.ts +21 -0
- package/types/services/RouteService.d.ts +21 -0
- package/{dist → types}/support/model.d.ts +0 -1
- package/types/types/App.d.ts +88 -0
- package/{dist → types}/types/Auth.d.ts +0 -1
- package/types/types/Builder.d.ts +46 -0
- package/{dist → types}/types/Config.d.ts +4 -2
- package/types/types/Error.d.ts +17 -0
- package/types/types/Http.d.ts +20 -0
- package/{dist → types}/types/Model.d.ts +61 -43
- package/{dist → types}/types/Relation.d.ts +1 -2
- package/types/types/Route.d.ts +27 -0
- package/{dist → types}/types/Support.d.ts +3 -2
- package/vite.config.js +2 -2
- package/dist/contracts/Builder.d.ts +0 -53
- package/dist/contracts/Collection.d.ts +0 -190
- package/dist/contracts/ModelCollection.d.ts +0 -9
- package/dist/contracts/PropertyBag.d.ts +0 -21
- package/dist/contracts/Relation/MorphToMany.d.ts +0 -16
- package/dist/facades/App.d.ts +0 -37
- package/dist/facades/Auth.d.ts +0 -14
- package/dist/facades/Model.d.ts +0 -41
- package/dist/facades/Route.d.ts +0 -32
- package/dist/helpers/app.d.ts +0 -5
- package/dist/helpers/collect.d.ts +0 -1
- package/dist/helpers/log.d.ts +0 -5
- package/dist/mixins/BaseModel.d.ts +0 -5
- package/dist/mixins/HasEvents.d.ts +0 -15
- package/dist/mixins/Reducible.d.ts +0 -17
- package/dist/support/collection.d.ts +0 -4
- package/dist/support/reader.d.ts +0 -2
- package/dist/support/searchParams.d.ts +0 -1
- package/dist/types/App.d.ts +0 -79
- package/dist/types/Builder.d.ts +0 -51
- package/dist/types/Collection.d.ts +0 -1804
- package/dist/types/Error.d.ts +0 -31
- package/dist/types/Event.d.ts +0 -14
- package/dist/types/PropertyBag.d.ts +0 -25
- package/dist/types/Reducer.d.ts +0 -17
- package/dist/types/Route.d.ts +0 -22
- /package/{dist → types}/exceptions/AttributeNotFillableException.d.ts +0 -0
- /package/{dist → types}/exceptions/FacadeNotFoundException.d.ts +0 -0
- /package/{dist → types}/exceptions/MethodNotImplementedException.d.ts +0 -0
- /package/{dist → types}/exceptions/ModelInvalidRelatedTypeException.d.ts +0 -0
- /package/{dist → types}/exceptions/ModelNotFoundException.d.ts +0 -0
- /package/{dist → types}/exceptions/ModelNotPersistedException.d.ts +0 -0
- /package/{dist → types}/exceptions/ModelWithoutPrimaryKeyException.d.ts +0 -0
- /package/{dist → types}/exceptions/NoEmbedException.d.ts +0 -0
- /package/{dist → types}/exceptions/NoInverseRelationException.d.ts +0 -0
- /package/{dist → types}/exceptions/NotModelException.d.ts +0 -0
- /package/{dist → types}/exceptions/NotReducibleException.d.ts +0 -0
- /package/{dist → types}/exceptions/ReducerOverrideException.d.ts +0 -0
- /package/{dist → types}/exceptions/RouteNotFoundException.d.ts +0 -0
- /package/{dist → types}/exceptions/UnsupportedRelationException.d.ts +0 -0
- /package/{dist → types}/types/Log.d.ts +0 -0
- /package/{dist → types}/types/Plugin.d.ts +0 -0
package/dist/core.js
CHANGED
|
@@ -1,1020 +1,185 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
m(this, V, "FacadeNotFoundException");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
class Le {
|
|
19
|
-
constructor(e) {
|
|
20
|
-
m(this, "_user");
|
|
21
|
-
this.app = e;
|
|
22
|
-
}
|
|
23
|
-
attempt(e, t = !1, r) {
|
|
24
|
-
const i = document.createElement("form");
|
|
25
|
-
i.method = "post", i.action = this.app.make("route").url("login"), i.style.display = "none";
|
|
26
|
-
const s = this.app.make("config").get("auth.csrf");
|
|
27
|
-
if (typeof s == "string") {
|
|
1
|
+
var ue = Object.defineProperty;
|
|
2
|
+
var he = (o, t, e) => t in o ? ue(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var d = (o, t, e) => he(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { reader as le, PropertyBag as T, EventSource as q, Collection as b, Query as S, Str as y, Obj as v, Reducible as se, isValidationError as ce, Macroable as re, Client as de, ServiceProvider as pe, MakeFacade as M, Application as ge, Response as ye } from "@luminix/support";
|
|
5
|
+
class me {
|
|
6
|
+
constructor(t, e, i) {
|
|
7
|
+
d(this, "_user");
|
|
8
|
+
this.config = t, this.model = e, this.route = i;
|
|
9
|
+
}
|
|
10
|
+
attempt(t, e = !1, i) {
|
|
11
|
+
const s = document.createElement("form");
|
|
12
|
+
s.method = "post", s.action = this.route.url("login"), s.style.display = "none";
|
|
13
|
+
const c = this.config.get("auth.csrf");
|
|
14
|
+
if (typeof c == "string") {
|
|
28
15
|
const a = document.createElement("input");
|
|
29
|
-
a.type = "hidden", a.name = "_token", a.value =
|
|
16
|
+
a.type = "hidden", a.name = "_token", a.value = c, s.appendChild(a);
|
|
30
17
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
18
|
+
const g = document.createElement("input");
|
|
19
|
+
g.type = "email", g.name = "email", g.value = t.email, s.appendChild(g);
|
|
20
|
+
const h = document.createElement("input");
|
|
21
|
+
if (h.type = "password", h.name = "password", h.value = t.password, s.appendChild(h), e) {
|
|
35
22
|
const a = document.createElement("input");
|
|
36
|
-
a.type = "checkbox", a.name = "remember", a.value = "1", a.checked = !0,
|
|
23
|
+
a.type = "checkbox", a.name = "remember", a.value = "1", a.checked = !0, s.appendChild(a);
|
|
37
24
|
}
|
|
38
|
-
|
|
25
|
+
i && s.addEventListener("submit", i), document.body.appendChild(s), s.submit();
|
|
39
26
|
}
|
|
40
27
|
check() {
|
|
41
|
-
return !!this.
|
|
28
|
+
return !!this.config.get("auth.user");
|
|
42
29
|
}
|
|
43
|
-
logout(
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
if (typeof
|
|
48
|
-
const
|
|
49
|
-
|
|
30
|
+
logout(t) {
|
|
31
|
+
const e = document.createElement("form");
|
|
32
|
+
e.method = "post", e.action = this.route.url("logout"), e.style.display = "none";
|
|
33
|
+
const i = this.config.get("auth.csrf");
|
|
34
|
+
if (typeof i == "string") {
|
|
35
|
+
const s = document.createElement("input");
|
|
36
|
+
s.type = "hidden", s.name = "_token", s.value = i, e.appendChild(s);
|
|
50
37
|
}
|
|
51
|
-
document.body.appendChild(
|
|
38
|
+
document.body.appendChild(e), t && e.addEventListener("submit", t), e.submit();
|
|
52
39
|
}
|
|
53
40
|
user() {
|
|
54
41
|
if (!this._user) {
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
return
|
|
58
|
-
this._user = new
|
|
42
|
+
const t = this.model.make("user"), e = this.config.get("auth.user");
|
|
43
|
+
if (!e)
|
|
44
|
+
return;
|
|
45
|
+
this._user = new t(e);
|
|
59
46
|
}
|
|
60
47
|
return this._user;
|
|
61
48
|
}
|
|
62
49
|
id() {
|
|
63
|
-
var
|
|
64
|
-
return ((
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
class Ce {
|
|
68
|
-
constructor(e) {
|
|
69
|
-
this._debug = e;
|
|
70
|
-
}
|
|
71
|
-
emergency(...e) {
|
|
72
|
-
this._debug && console.error(...e);
|
|
73
|
-
}
|
|
74
|
-
alert(...e) {
|
|
75
|
-
this._debug && console.error(...e);
|
|
76
|
-
}
|
|
77
|
-
critical(...e) {
|
|
78
|
-
this._debug && console.error(...e);
|
|
79
|
-
}
|
|
80
|
-
error(...e) {
|
|
81
|
-
this._debug && console.error(...e);
|
|
82
|
-
}
|
|
83
|
-
warning(...e) {
|
|
84
|
-
this._debug && console.warn(...e);
|
|
85
|
-
}
|
|
86
|
-
notice(...e) {
|
|
87
|
-
this._debug && console.info(...e);
|
|
88
|
-
}
|
|
89
|
-
info(...e) {
|
|
90
|
-
this._debug && console.info(...e);
|
|
91
|
-
}
|
|
92
|
-
debug(...e) {
|
|
93
|
-
this._debug && console.debug(...e);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
class S {
|
|
97
|
-
constructor(e) {
|
|
98
|
-
m(this, "locked", []);
|
|
99
|
-
this.bag = e, Object.freeze(this.bag);
|
|
100
|
-
}
|
|
101
|
-
get(e, t) {
|
|
102
|
-
return f.get(this.bag, e, t);
|
|
103
|
-
}
|
|
104
|
-
set(e, t) {
|
|
105
|
-
if (this.locked.some((r) => e.startsWith(r)))
|
|
106
|
-
throw new Error(`Cannot set a locked path "${e}"`);
|
|
107
|
-
if (typeof t == "object" && t !== null && this.locked.some((r) => f.has(t, r.slice(e.length + 1))))
|
|
108
|
-
throw new Error(`Cannot set a path "${e}" that would override a locked path`);
|
|
109
|
-
if (e === ".") {
|
|
110
|
-
if (this.locked.length)
|
|
111
|
-
throw new Error("Cannot set the root path when there are locked paths");
|
|
112
|
-
if (typeof t != "object" || t === null)
|
|
113
|
-
throw new TypeError("Value must be an object");
|
|
114
|
-
this.bag = R(this.bag, () => t), this.emit("change", {
|
|
115
|
-
path: e,
|
|
116
|
-
value: t,
|
|
117
|
-
type: "set"
|
|
118
|
-
});
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
this.bag = R(this.bag, (r) => {
|
|
122
|
-
f.set(r, e, t);
|
|
123
|
-
}), this.emit("change", {
|
|
124
|
-
path: e,
|
|
125
|
-
value: t,
|
|
126
|
-
type: "set"
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
merge(e, t) {
|
|
130
|
-
if (typeof t != "object" || t === null)
|
|
131
|
-
throw new TypeError("Value must be an object");
|
|
132
|
-
if (e === ".") {
|
|
133
|
-
if (this.locked.some((i) => f.has(t, i)))
|
|
134
|
-
throw new Error(`Cannot merge a path "${e}" that would override a locked path`);
|
|
135
|
-
this.bag = R(this.bag, (i) => ({
|
|
136
|
-
...i,
|
|
137
|
-
...t
|
|
138
|
-
})), this.emit("change", {
|
|
139
|
-
path: e,
|
|
140
|
-
value: t,
|
|
141
|
-
type: "merge"
|
|
142
|
-
});
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const r = this.get(e);
|
|
146
|
-
if (typeof r == "object" && r !== null)
|
|
147
|
-
return this.set(e, {
|
|
148
|
-
...r,
|
|
149
|
-
...t
|
|
150
|
-
});
|
|
151
|
-
if (r === null || typeof r > "u")
|
|
152
|
-
return this.set(e, t);
|
|
153
|
-
throw new Error(`Cannot merge a non-object path "${e}"`);
|
|
154
|
-
}
|
|
155
|
-
has(e) {
|
|
156
|
-
return f.has(this.bag, e);
|
|
157
|
-
}
|
|
158
|
-
delete(e) {
|
|
159
|
-
if (this.locked.some((t) => e.startsWith(t)))
|
|
160
|
-
throw new Error(`Cannot delete a locked path "${e}"`);
|
|
161
|
-
this.bag = R(this.bag, (t) => {
|
|
162
|
-
f.unset(t, e);
|
|
163
|
-
}), this.emit("change", {
|
|
164
|
-
path: e,
|
|
165
|
-
value: null,
|
|
166
|
-
type: "delete"
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
lock(e) {
|
|
170
|
-
if (!this.has(e))
|
|
171
|
-
throw new Error(`Cannot lock a non-existing path "${e}"`);
|
|
172
|
-
this.locked.push(e);
|
|
173
|
-
}
|
|
174
|
-
clone() {
|
|
175
|
-
return new S(this.bag);
|
|
176
|
-
}
|
|
177
|
-
all() {
|
|
178
|
-
return this.bag;
|
|
179
|
-
}
|
|
180
|
-
isEmpty() {
|
|
181
|
-
return f.isEmpty(this.bag);
|
|
182
|
-
}
|
|
183
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
184
|
-
on(e, t) {
|
|
185
|
-
return () => null;
|
|
186
|
-
}
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
188
|
-
once(e, t) {
|
|
189
|
-
}
|
|
190
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
191
|
-
emit(e, t) {
|
|
50
|
+
var t;
|
|
51
|
+
return ((t = this.user()) == null ? void 0 : t.getKey()) || null;
|
|
192
52
|
}
|
|
193
53
|
}
|
|
194
|
-
|
|
195
|
-
var e, t, r, $e, s;
|
|
196
|
-
return s = class extends (t = n, e = Symbol.toStringTag, t) {
|
|
197
|
-
constructor(...a) {
|
|
198
|
-
super(...a);
|
|
199
|
-
F(this, r);
|
|
200
|
-
m(this, "emitter");
|
|
201
|
-
m(this, e, n.name);
|
|
202
|
-
this.emitter = D(this, r, $e).call(this);
|
|
203
|
-
}
|
|
204
|
-
on(a, d) {
|
|
205
|
-
if (typeof a != "string")
|
|
206
|
-
throw new TypeError("event must be a string");
|
|
207
|
-
if (typeof d != "function")
|
|
208
|
-
throw new TypeError("callback must be a function");
|
|
209
|
-
return this.emitter.on(a, d);
|
|
210
|
-
}
|
|
211
|
-
once(a, d) {
|
|
212
|
-
if (typeof a != "string")
|
|
213
|
-
throw new TypeError("event must be a string");
|
|
214
|
-
if (typeof d != "function")
|
|
215
|
-
throw new TypeError("callback must be a function");
|
|
216
|
-
const p = this.emitter.on(a, (w) => {
|
|
217
|
-
p(), d(w);
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
emit(a, d = {}) {
|
|
221
|
-
if (typeof a != "string")
|
|
222
|
-
throw new TypeError("event must be a string");
|
|
223
|
-
if (typeof d != "object")
|
|
224
|
-
throw new TypeError("data must be an object");
|
|
225
|
-
this.emitter.emit(a, {
|
|
226
|
-
...d,
|
|
227
|
-
source: this
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
}, r = new WeakSet(), $e = function() {
|
|
231
|
-
return {
|
|
232
|
-
emit(a, d) {
|
|
233
|
-
for (let p = 0, w = this.events[a] || [], x = w.length; p < x; p++)
|
|
234
|
-
w[p](d);
|
|
235
|
-
},
|
|
236
|
-
events: {},
|
|
237
|
-
on(a, d) {
|
|
238
|
-
var p;
|
|
239
|
-
return ((p = this.events)[a] || (p[a] = [])).push(d), () => {
|
|
240
|
-
var w;
|
|
241
|
-
this.events[a] = (w = this.events[a]) == null ? void 0 : w.filter((x) => d !== x);
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
}, s;
|
|
246
|
-
}
|
|
247
|
-
function U(...n) {
|
|
248
|
-
return n.reduce((e, t) => e.flatMap((r) => t.map((i) => [r, i].flat())));
|
|
249
|
-
}
|
|
250
|
-
function $(n) {
|
|
251
|
-
return !(typeof n != "object" || n === null || !Reflect.has(n, "constructor") || Reflect.get(n.constructor, "name") !== "Collection");
|
|
252
|
-
}
|
|
253
|
-
var Y, Z;
|
|
254
|
-
class b extends (Z = Error, Y = Symbol.toStringTag, Z) {
|
|
54
|
+
class fe {
|
|
255
55
|
constructor() {
|
|
256
|
-
|
|
257
|
-
m(this, Y, "MethodNotImplementedException");
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
function c(n = [], e = P) {
|
|
261
|
-
if (!Array.isArray(n))
|
|
262
|
-
throw new TypeError("collect() expects an array");
|
|
263
|
-
return new (A(e))([...n]);
|
|
264
|
-
}
|
|
265
|
-
const _ = (n) => {
|
|
266
|
-
n.emit("change", {
|
|
267
|
-
items: n.all()
|
|
268
|
-
});
|
|
269
|
-
}, q = (n, e) => Array.isArray(n) ? n[e] ?? null : n.get(e);
|
|
270
|
-
var z, O, o;
|
|
271
|
-
class P {
|
|
272
|
-
constructor(e = []) {
|
|
273
|
-
// [Symbol.toStringTag] = 'Collection';
|
|
274
|
-
F(this, o);
|
|
275
|
-
m(this, z, "Collection");
|
|
276
|
-
J(this, o, e);
|
|
277
|
-
}
|
|
278
|
-
get items() {
|
|
279
|
-
return [...h(this, o)];
|
|
280
|
-
}
|
|
281
|
-
[(O = Symbol.iterator, z = Symbol.toStringTag, O)]() {
|
|
282
|
-
return h(this, o)[Symbol.iterator]();
|
|
283
|
-
}
|
|
284
|
-
all() {
|
|
285
|
-
return [...h(this, o)];
|
|
286
|
-
}
|
|
287
|
-
average(e) {
|
|
288
|
-
return typeof e == "string" ? this.avg(e) : this.avg();
|
|
289
|
-
}
|
|
290
|
-
avg(e) {
|
|
291
|
-
return typeof e == "string" ? this.sum(e) / h(this, o).length : this.sum() / h(this, o).length;
|
|
292
|
-
}
|
|
293
|
-
chunk(e) {
|
|
294
|
-
const t = [];
|
|
295
|
-
for (let r = 0; r < h(this, o).length; r += e)
|
|
296
|
-
t.push(h(this, o).slice(r, r + e));
|
|
297
|
-
return c(t.map((r) => c(r)));
|
|
298
|
-
}
|
|
299
|
-
chunkWhile(e) {
|
|
300
|
-
const t = [];
|
|
301
|
-
let r = c();
|
|
302
|
-
for (let i = 0; i < h(this, o).length; i++)
|
|
303
|
-
e(h(this, o)[i], i, r) ? r.push(h(this, o)[i]) : (t.push(r), r = c());
|
|
304
|
-
return r.count() > 0 && t.push(r), c(t);
|
|
305
|
-
}
|
|
306
|
-
collapse() {
|
|
307
|
-
return c(h(this, o).flat());
|
|
308
|
-
}
|
|
309
|
-
collect() {
|
|
310
|
-
return c(h(this, o));
|
|
311
|
-
}
|
|
312
|
-
combine(e) {
|
|
56
|
+
d(this, "bags");
|
|
313
57
|
const t = {};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
concat(e) {
|
|
321
|
-
return Array.isArray(e) ? c([...h(this, o), ...e]) : c([...h(this, o), ...e.all()]);
|
|
322
|
-
}
|
|
323
|
-
contains(e, t) {
|
|
324
|
-
return typeof e == "function" ? h(this, o).some((r, i) => e(r, i, this)) : h(this, o).some((r) => {
|
|
325
|
-
if (typeof t > "u")
|
|
326
|
-
return r == e;
|
|
327
|
-
if (typeof e != "string")
|
|
328
|
-
throw new TypeError("The key must be a string");
|
|
329
|
-
return r[e] == t;
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
containsOneItem() {
|
|
333
|
-
return h(this, o).length === 1;
|
|
334
|
-
}
|
|
335
|
-
containsStrict(e, t) {
|
|
336
|
-
return typeof e == "function" ? h(this, o).some((r, i) => e(r, i, this)) : h(this, o).some((r) => {
|
|
337
|
-
if (typeof t > "u")
|
|
338
|
-
return r === e;
|
|
339
|
-
if (typeof e != "string")
|
|
340
|
-
throw new TypeError("The key must be a string");
|
|
341
|
-
return r[e] === t;
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
count() {
|
|
345
|
-
return h(this, o).length;
|
|
346
|
-
}
|
|
347
|
-
countBy(e) {
|
|
348
|
-
return typeof e == "function" ? h(this, o).reduce((t, r, i) => {
|
|
349
|
-
const s = e(r, i, this);
|
|
350
|
-
return t[s] = t[s] ? t[s] + 1 : 1, t;
|
|
351
|
-
}, {}) : h(this, o).reduce((t, r) => {
|
|
352
|
-
if (!["string", "number"].includes(typeof r))
|
|
353
|
-
throw new TypeError("The countBy method expects the items to be strings or numbers");
|
|
354
|
-
return t[String(r)] = t[String(r)] ? t[String(r)] + 1 : 1, t;
|
|
355
|
-
}, {});
|
|
356
|
-
}
|
|
357
|
-
crossJoin(...e) {
|
|
358
|
-
return c(U(
|
|
359
|
-
h(this, o),
|
|
360
|
-
...e.map((t) => Array.isArray(t) ? t : t.all())
|
|
361
|
-
));
|
|
362
|
-
}
|
|
363
|
-
diff(e) {
|
|
364
|
-
return Array.isArray(e) ? c(h(this, o).filter((t) => !e.includes(t))) : c(h(this, o).filter((t) => !e.contains(t)));
|
|
365
|
-
}
|
|
366
|
-
doesntContain(e, t) {
|
|
367
|
-
return typeof e == "function" ? h(this, o).every((r, i) => !e(r, i, this)) : h(this, o).every((r) => {
|
|
368
|
-
if (typeof t > "u")
|
|
369
|
-
return r != e;
|
|
370
|
-
if (typeof e != "string")
|
|
371
|
-
throw new TypeError("The key must be a string");
|
|
372
|
-
return r[e] != t;
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
dump() {
|
|
376
|
-
console.log(this.toArray());
|
|
377
|
-
}
|
|
378
|
-
duplicates(e) {
|
|
379
|
-
return c(typeof e == "string" ? h(this, o).reduce((t, r, i) => (h(this, o).slice(i + 1).some((s) => s[e] == r[e]) && t.push(r[e]), t), []) : h(this, o).reduce((t, r, i) => (h(this, o).slice(i + 1).some((s) => s == r) && t.push(r), t), []));
|
|
380
|
-
}
|
|
381
|
-
duplicatesStrict(e) {
|
|
382
|
-
return c(typeof e == "string" ? h(this, o).reduce((t, r, i) => (h(this, o).slice(i + 1).some((s) => s[e] === r[e]) && t.push(r[e]), t), []) : h(this, o).reduce((t, r, i) => (h(this, o).slice(i + 1).some((s) => s === r) && t.push(r), t), []));
|
|
383
|
-
}
|
|
384
|
-
each(e) {
|
|
385
|
-
let t = 0;
|
|
386
|
-
for (const r of this) {
|
|
387
|
-
if (e(r, t, this) === !1)
|
|
388
|
-
break;
|
|
389
|
-
t++;
|
|
390
|
-
}
|
|
391
|
-
return this;
|
|
392
|
-
}
|
|
393
|
-
eachSpread(e) {
|
|
394
|
-
for (const t of this) {
|
|
395
|
-
if (!Array.isArray(t) && !$(t))
|
|
396
|
-
throw new TypeError("The items in the collection must be arrays or collections");
|
|
397
|
-
const r = Array.isArray(t) ? t : t.all();
|
|
398
|
-
if (e(...r) === !1)
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
return this;
|
|
402
|
-
}
|
|
403
|
-
ensure(e) {
|
|
404
|
-
const t = Array.isArray(e) ? e : [e];
|
|
405
|
-
return h(this, o).forEach((r, i) => {
|
|
406
|
-
if (!t.some((s) => typeof s == "string" ? typeof r === s : r instanceof s))
|
|
407
|
-
throw new TypeError(`The item at index ${i} is not of the expected type`);
|
|
408
|
-
}), this;
|
|
409
|
-
}
|
|
410
|
-
every(e) {
|
|
411
|
-
return h(this, o).every((t, r) => e(t, r, this));
|
|
412
|
-
}
|
|
413
|
-
except(e) {
|
|
414
|
-
return c(h(this, o).filter((t, r) => !e.includes(r)));
|
|
415
|
-
}
|
|
416
|
-
filter(e) {
|
|
417
|
-
return c(h(this, o).filter((t, r) => typeof e != "function" ? !!t : e(t, r, this)));
|
|
418
|
-
}
|
|
419
|
-
first(e) {
|
|
420
|
-
return typeof e == "function" ? h(this, o).find((t, r) => e(t, r, this)) ?? null : h(this, o)[0] ?? null;
|
|
421
|
-
}
|
|
422
|
-
firstOrFail(e) {
|
|
423
|
-
const t = this.first(e);
|
|
424
|
-
if (t === null)
|
|
425
|
-
throw new Error("No matching item found");
|
|
426
|
-
return t;
|
|
427
|
-
}
|
|
428
|
-
firstWhere(e, t, r) {
|
|
429
|
-
if (typeof e != "string")
|
|
430
|
-
throw new TypeError("The key must be a string");
|
|
431
|
-
if (typeof t > "u")
|
|
432
|
-
return this.first((i) => !!i[e]);
|
|
433
|
-
if (typeof r > "u")
|
|
434
|
-
return h(this, o).find((i) => i[e] == t) ?? null;
|
|
435
|
-
if (typeof t != "string")
|
|
436
|
-
throw new TypeError("The operator must be a string");
|
|
437
|
-
return r === null ? h(this, o).find((i) => i[e] === null) ?? null : h(this, o).find((i) => {
|
|
438
|
-
switch (t) {
|
|
439
|
-
case "=":
|
|
440
|
-
return i[e] == r;
|
|
441
|
-
case "!=":
|
|
442
|
-
return i[e] != r;
|
|
443
|
-
case ">":
|
|
444
|
-
return i[e] > r;
|
|
445
|
-
case "<":
|
|
446
|
-
return i[e] < r;
|
|
447
|
-
case ">=":
|
|
448
|
-
return i[e] >= r;
|
|
449
|
-
case "<=":
|
|
450
|
-
return i[e] <= r;
|
|
451
|
-
default:
|
|
452
|
-
throw new Error("Unsupported operator");
|
|
453
|
-
}
|
|
454
|
-
}) ?? null;
|
|
455
|
-
}
|
|
456
|
-
flatMap(e) {
|
|
457
|
-
return c(h(this, o).flatMap((t, r) => e(t, r, this)));
|
|
458
|
-
}
|
|
459
|
-
forget(e) {
|
|
460
|
-
return h(this, o).splice(e, 1), _(this), this;
|
|
461
|
-
}
|
|
462
|
-
forPage(e, t) {
|
|
463
|
-
return c(h(this, o).slice((e - 1) * t, e * t));
|
|
464
|
-
}
|
|
465
|
-
get(e, t) {
|
|
466
|
-
if (typeof e != "number")
|
|
467
|
-
throw new TypeError("The key must be a number");
|
|
468
|
-
return typeof t > "u" ? h(this, o)[e] ?? null : typeof t == "function" ? h(this, o)[e] ?? t() : h(this, o)[e] ?? t;
|
|
469
|
-
}
|
|
470
|
-
groupBy(e) {
|
|
471
|
-
const t = Array.isArray(e) ? e : [e];
|
|
472
|
-
return h(this, o).reduce((r, i, s) => {
|
|
473
|
-
const u = t.map((a) => {
|
|
474
|
-
if (typeof a == "function") {
|
|
475
|
-
const d = a(i, s, this);
|
|
476
|
-
return Array.isArray(d) ? d : [d];
|
|
477
|
-
}
|
|
478
|
-
return [String(i[a])];
|
|
479
|
-
});
|
|
480
|
-
return U(...u).forEach((a) => {
|
|
481
|
-
const d = Array.isArray(a) ? a.join(".") : a;
|
|
482
|
-
f.set(r, d, [
|
|
483
|
-
...f.get(r, d, []),
|
|
484
|
-
i
|
|
485
|
-
]);
|
|
486
|
-
}), r;
|
|
487
|
-
}, {});
|
|
488
|
-
}
|
|
489
|
-
has(e) {
|
|
490
|
-
return h(this, o).length > e;
|
|
491
|
-
}
|
|
492
|
-
hasAny(e) {
|
|
493
|
-
return e.some((t) => this.has(t));
|
|
494
|
-
}
|
|
495
|
-
implode(e, t) {
|
|
496
|
-
if (typeof t > "u") {
|
|
497
|
-
if (typeof e != "string")
|
|
498
|
-
throw new TypeError("The glue must be a string");
|
|
499
|
-
if (!h(this, o).every((r) => ["string", "number"].includes(typeof r)))
|
|
500
|
-
throw new TypeError("The items must be strings or numbers");
|
|
501
|
-
return h(this, o).join(e);
|
|
502
|
-
}
|
|
503
|
-
if (typeof e == "function")
|
|
504
|
-
return h(this, o).map((r, i) => e(r, i, this)).join(t);
|
|
505
|
-
if (typeof e != "string")
|
|
506
|
-
throw new TypeError("The key must be a string");
|
|
507
|
-
if (!h(this, o).every((r) => typeof r == "object"))
|
|
508
|
-
throw new TypeError("The items must be objects");
|
|
509
|
-
return h(this, o).map((r) => r[e]).join(t);
|
|
510
|
-
}
|
|
511
|
-
intersect(e) {
|
|
512
|
-
return Array.isArray(e) ? c(h(this, o).filter((t) => e.includes(t))) : c(h(this, o).filter((t) => e.contains(t)));
|
|
513
|
-
}
|
|
514
|
-
isEmpty() {
|
|
515
|
-
return h(this, o).length === 0;
|
|
516
|
-
}
|
|
517
|
-
isNotEmpty() {
|
|
518
|
-
return !this.isEmpty();
|
|
519
|
-
}
|
|
520
|
-
join(e, t) {
|
|
521
|
-
return typeof t > "u" ? h(this, o).join(e) : h(this, o).slice(0, -1).join(e) + t + h(this, o)[h(this, o).length - 1];
|
|
522
|
-
}
|
|
523
|
-
keyBy(e) {
|
|
524
|
-
if (typeof e == "function")
|
|
525
|
-
return h(this, o).reduce((t, r, i) => (t[e(r, i, this)] = r, t), {});
|
|
526
|
-
if (typeof e != "string")
|
|
527
|
-
throw new TypeError("The key must be a string");
|
|
528
|
-
return h(this, o).reduce((t, r) => (t[String(r[e])] = r, t), {});
|
|
529
|
-
}
|
|
530
|
-
last(e) {
|
|
531
|
-
return typeof e == "function" ? h(this, o).toReversed().find((t, r) => e(t, r, this)) ?? null : h(this, o)[h(this, o).length - 1] ?? null;
|
|
532
|
-
}
|
|
533
|
-
map(e) {
|
|
534
|
-
return c(h(this, o).map((t, r) => e(t, r, this)));
|
|
535
|
-
}
|
|
536
|
-
mapInto(e) {
|
|
537
|
-
return c(h(this, o).map((t) => new e(t)));
|
|
538
|
-
}
|
|
539
|
-
mapSpread(e) {
|
|
540
|
-
return c(h(this, o).map((t) => {
|
|
541
|
-
if (!Array.isArray(t) && !$(t))
|
|
542
|
-
throw new TypeError("The items in the collection must be arrays or collections");
|
|
543
|
-
const r = Array.isArray(t) ? t : t.all();
|
|
544
|
-
return e(...r);
|
|
545
|
-
}));
|
|
546
|
-
}
|
|
547
|
-
mapToGroups(e) {
|
|
548
|
-
return h(this, o).reduce((t, r, i) => {
|
|
549
|
-
const s = e(r, i, this);
|
|
550
|
-
return Object.entries(s).forEach(([u, l]) => {
|
|
551
|
-
t[u] = t[u] ?? [], t[u].push(l);
|
|
552
|
-
}), t;
|
|
553
|
-
}, {});
|
|
554
|
-
}
|
|
555
|
-
mapWithKeys(e) {
|
|
556
|
-
return h(this, o).reduce((t, r, i) => {
|
|
557
|
-
const s = e(r, i, this);
|
|
558
|
-
return Object.entries(s).forEach(([u, l]) => {
|
|
559
|
-
t[u] = l;
|
|
560
|
-
}), t;
|
|
561
|
-
}, {});
|
|
562
|
-
}
|
|
563
|
-
max(e) {
|
|
564
|
-
return typeof e == "string" ? h(this, o).reduce((t, r) => r[e] > t ? r[e] : t, h(this, o)[0][e]) : h(this, o).reduce((t, r) => r > t ? r : t, h(this, o)[0]);
|
|
565
|
-
}
|
|
566
|
-
median(e) {
|
|
567
|
-
if (typeof e == "string") {
|
|
568
|
-
const i = this.pluck(e).sort(), s = Math.floor(i.count() / 2);
|
|
569
|
-
return i.count() % 2 === 0 ? c([q(i, s - 1), q(i, s)]).avg() : q(i, s);
|
|
570
|
-
}
|
|
571
|
-
const t = h(this, o).toSorted(), r = Math.floor(t.length / 2);
|
|
572
|
-
return t.length % 2 === 0 ? c([t[r - 1], t[r]]).avg() : t[r] ?? null;
|
|
573
|
-
}
|
|
574
|
-
merge(e) {
|
|
575
|
-
return Array.isArray(e) ? c([...h(this, o), ...e]) : c([...h(this, o), ...e.all()]);
|
|
576
|
-
}
|
|
577
|
-
min(e) {
|
|
578
|
-
return typeof e == "string" ? h(this, o).reduce((t, r) => r[e] < t ? r[e] : t, h(this, o)[0][e]) : h(this, o).reduce((t, r) => r < t ? r : t, h(this, o)[0]);
|
|
579
|
-
}
|
|
580
|
-
mode(e) {
|
|
581
|
-
const t = typeof e == "string" ? this.filter((i) => ["number", "string"].includes(typeof i[e])).countBy((i) => i[e]) : this.countBy(), r = Math.max(...Object.values(t));
|
|
582
|
-
return Object.entries(t).filter(([, i]) => i === r).map(([i]) => i);
|
|
583
|
-
}
|
|
584
|
-
nth(e, t = 0) {
|
|
585
|
-
return this.chunk(e).filter((r) => r.count() > t).map((r) => r.get(t));
|
|
586
|
-
}
|
|
587
|
-
only(e) {
|
|
588
|
-
return c(h(this, o).filter((t, r) => e.includes(r)));
|
|
589
|
-
}
|
|
590
|
-
pad(e, t = null) {
|
|
591
|
-
const r = h(this, o).slice();
|
|
592
|
-
for (; r.length < Math.abs(e); )
|
|
593
|
-
e > 0 ? r.push(t) : r.unshift(t);
|
|
594
|
-
return c(r);
|
|
595
|
-
}
|
|
596
|
-
partition(e) {
|
|
597
|
-
return [
|
|
598
|
-
this.filter(e),
|
|
599
|
-
this.reject(e)
|
|
600
|
-
];
|
|
601
|
-
}
|
|
602
|
-
percentage(e, t = 2) {
|
|
603
|
-
return Math.round(
|
|
604
|
-
100 * (10 ^ t) * this.filter(e).count() / h(this, o).length
|
|
605
|
-
) / (10 ^ t);
|
|
606
|
-
}
|
|
607
|
-
pipe(e) {
|
|
608
|
-
return e(this);
|
|
609
|
-
}
|
|
610
|
-
pipeInto(e) {
|
|
611
|
-
return new e(this);
|
|
612
|
-
}
|
|
613
|
-
pipeThrough(e) {
|
|
614
|
-
return e.reduce((t, r) => {
|
|
615
|
-
if (!$(t) && !Array.isArray(t))
|
|
616
|
-
throw new TypeError("The pipeline expects the carry to be a collection or an array");
|
|
617
|
-
return r(
|
|
618
|
-
$(t) ? t : c(t)
|
|
619
|
-
);
|
|
620
|
-
}, this);
|
|
621
|
-
}
|
|
622
|
-
pluck(e) {
|
|
623
|
-
return this.map((t) => t[e]);
|
|
624
|
-
}
|
|
625
|
-
pop(e = 1) {
|
|
626
|
-
const t = h(this, o).splice(h(this, o).length - e, e);
|
|
627
|
-
return _(this), e === 1 ? t[0] ?? null : c(t);
|
|
628
|
-
}
|
|
629
|
-
prepend(e) {
|
|
630
|
-
const t = h(this, o).unshift(e);
|
|
631
|
-
return _(this), t;
|
|
632
|
-
}
|
|
633
|
-
pull(e) {
|
|
634
|
-
const t = h(this, o).splice(e, 1)[0] ?? null;
|
|
635
|
-
return _(this), t;
|
|
636
|
-
}
|
|
637
|
-
push(...e) {
|
|
638
|
-
const t = h(this, o).push(...e);
|
|
639
|
-
return _(this), t;
|
|
640
|
-
}
|
|
641
|
-
put(e, t) {
|
|
642
|
-
return h(this, o).splice(e, 1, t), _(this), this;
|
|
643
|
-
}
|
|
644
|
-
random(e = 1) {
|
|
645
|
-
if (h(this, o).length < e)
|
|
646
|
-
throw new Error("The collection has fewer items than the requested amount");
|
|
647
|
-
const t = c(f.sampleSize(h(this, o), e));
|
|
648
|
-
return e === 1 ? t.first() : t;
|
|
649
|
-
}
|
|
650
|
-
reduce(e, t = null) {
|
|
651
|
-
return h(this, o).reduce((r, i, s) => e(r, i, s, this), t);
|
|
652
|
-
}
|
|
653
|
-
reject(e) {
|
|
654
|
-
return this.filter((t, r) => !e(t, r, this));
|
|
655
|
-
}
|
|
656
|
-
replace(e) {
|
|
657
|
-
const t = h(this, o).slice();
|
|
658
|
-
return Object.entries(e).forEach(([r, i]) => {
|
|
659
|
-
t[parseInt(r)] = i;
|
|
660
|
-
}), c(t);
|
|
661
|
-
}
|
|
662
|
-
reverse() {
|
|
663
|
-
return c(h(this, o).toReversed());
|
|
664
|
-
}
|
|
665
|
-
search(e, t = !1) {
|
|
666
|
-
if (typeof e != "function" || h(this, o).every((i) => typeof i == "function")) {
|
|
667
|
-
const i = h(this, o).findIndex((s) => t ? s === e : s == e);
|
|
668
|
-
return i === -1 ? !1 : i;
|
|
669
|
-
}
|
|
670
|
-
const r = h(this, o).findIndex((i, s) => e(i, s, this));
|
|
671
|
-
return r === -1 ? !1 : r;
|
|
672
|
-
}
|
|
673
|
-
select(e) {
|
|
674
|
-
return this.map((t) => e.reduce((r, i) => (r[i] = t[i], r), {}));
|
|
675
|
-
}
|
|
676
|
-
shift(e = 1) {
|
|
677
|
-
const t = h(this, o).splice(0, e);
|
|
678
|
-
return _(this), e === 1 ? t[0] ?? null : c(t);
|
|
679
|
-
}
|
|
680
|
-
shuffle() {
|
|
681
|
-
return c(f.shuffle(h(this, o)));
|
|
682
|
-
}
|
|
683
|
-
skip(e) {
|
|
684
|
-
return c(h(this, o).slice(e));
|
|
685
|
-
}
|
|
686
|
-
skipUntil(e) {
|
|
687
|
-
return typeof e == "function" ? this.skip(h(this, o).findIndex((t, r) => e(t, r, this))) : this.skip(h(this, o).findIndex((t) => t == e));
|
|
688
|
-
}
|
|
689
|
-
skipWhile(e) {
|
|
690
|
-
return typeof e == "function" ? this.skip(h(this, o).findIndex((t, r) => !e(t, r, this))) : this.skip(h(this, o).findIndex((t) => t != e));
|
|
691
|
-
}
|
|
692
|
-
slice(e, t) {
|
|
693
|
-
return c(typeof t > "u" ? h(this, o).slice(e) : typeof e > "u" ? h(this, o).slice(0, t) : h(this, o).slice(e, e + t));
|
|
694
|
-
}
|
|
695
|
-
sliding(e, t = 1) {
|
|
696
|
-
const r = [];
|
|
697
|
-
for (let i = 0; i < h(this, o).length && !(i + e > h(this, o).length); i += t)
|
|
698
|
-
r.push(h(this, o).slice(i, i + e));
|
|
699
|
-
return c(r.map((i) => c(i)));
|
|
700
|
-
}
|
|
701
|
-
sole(e, t) {
|
|
702
|
-
if (typeof e == "function") {
|
|
703
|
-
const r = this.filter(e);
|
|
704
|
-
return r.count() === 1 ? r.first() : null;
|
|
705
|
-
}
|
|
706
|
-
if (typeof e == "string") {
|
|
707
|
-
const r = this.where(e, t);
|
|
708
|
-
return r.count() === 1 ? r.first() : null;
|
|
709
|
-
}
|
|
710
|
-
return h(this, o).length === 1 ? this.first() : null;
|
|
711
|
-
}
|
|
712
|
-
some(...e) {
|
|
713
|
-
return this.contains(...e);
|
|
58
|
+
document.querySelectorAll('#luminix-embed [id^="luminix-error"]').forEach((i) => {
|
|
59
|
+
const c = i.id.replace("luminix-error::", "");
|
|
60
|
+
t[c] = le(c, "error");
|
|
61
|
+
}), this.bags = {
|
|
62
|
+
default: new T(t)
|
|
63
|
+
};
|
|
714
64
|
}
|
|
715
|
-
|
|
716
|
-
return
|
|
65
|
+
bag(t = "default") {
|
|
66
|
+
return this.bags[t] || (this.bags[t] = new T({})), this.bags[t];
|
|
717
67
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
let r = -1;
|
|
721
|
-
return c(h(this, o).toSorted((i, s) => (r++, e(i, r, this) - e(s, r, this))));
|
|
722
|
-
}
|
|
723
|
-
if (Array.isArray(e))
|
|
724
|
-
return e.every((r) => Array.isArray(r)) ? c(h(this, o).toSorted((r, i) => {
|
|
725
|
-
for (const [s, u] of e) {
|
|
726
|
-
const l = r[s] ?? -1 / 0, a = i[s] ?? -1 / 0;
|
|
727
|
-
if (l > a)
|
|
728
|
-
return u === "asc" ? 1 : -1;
|
|
729
|
-
if (l < a)
|
|
730
|
-
return u === "asc" ? -1 : 1;
|
|
731
|
-
}
|
|
732
|
-
return 0;
|
|
733
|
-
})) : c(h(this, o).toSorted((r, i) => {
|
|
734
|
-
for (const s of e) {
|
|
735
|
-
const u = s(r, i);
|
|
736
|
-
if (u !== 0)
|
|
737
|
-
return u;
|
|
738
|
-
}
|
|
739
|
-
return 0;
|
|
740
|
-
}));
|
|
741
|
-
if (typeof e != "string")
|
|
742
|
-
throw new TypeError("The key must be a string");
|
|
743
|
-
return c(h(this, o).toSorted((r, i) => {
|
|
744
|
-
const s = r[e] ?? -1 / 0, u = i[e] ?? -1 / 0;
|
|
745
|
-
return s > u ? t === "asc" ? 1 : -1 : s < u ? t === "asc" ? -1 : 1 : 0;
|
|
746
|
-
}));
|
|
747
|
-
}
|
|
748
|
-
sortDesc() {
|
|
749
|
-
return this.sort((e, t) => e > t ? -1 : e < t ? 1 : 0);
|
|
750
|
-
}
|
|
751
|
-
splice(e, t, ...r) {
|
|
752
|
-
const i = t === void 0 ? h(this, o).length : t, s = h(this, o).splice(e, i, ...r);
|
|
753
|
-
return _(this), c(s);
|
|
754
|
-
}
|
|
755
|
-
split(e) {
|
|
756
|
-
const t = [];
|
|
757
|
-
for (let r = 0; r < e; r++) {
|
|
758
|
-
const i = h(this, o).slice(
|
|
759
|
-
t.flat().length,
|
|
760
|
-
t.flat().length + Math.min(
|
|
761
|
-
Math.ceil((h(this, o).length - t.flat().length) / (e - r)),
|
|
762
|
-
h(this, o).length - t.flat().length
|
|
763
|
-
)
|
|
764
|
-
);
|
|
765
|
-
t.push(c(i));
|
|
766
|
-
}
|
|
767
|
-
return c(t);
|
|
768
|
-
}
|
|
769
|
-
splitIn(e) {
|
|
770
|
-
const t = Math.ceil(h(this, o).length / e);
|
|
771
|
-
return this.chunk(t);
|
|
772
|
-
}
|
|
773
|
-
sum(e) {
|
|
774
|
-
return typeof e == "string" ? h(this, o).reduce((t, r) => {
|
|
775
|
-
const i = r[e];
|
|
776
|
-
if (typeof i != "number")
|
|
777
|
-
throw new TypeError("The items must be numbers");
|
|
778
|
-
return t + i;
|
|
779
|
-
}, 0) : h(this, o).reduce((t, r) => {
|
|
780
|
-
if (typeof r != "number")
|
|
781
|
-
throw new TypeError("The items must be numbers");
|
|
782
|
-
return t + r;
|
|
783
|
-
}, 0);
|
|
784
|
-
}
|
|
785
|
-
take(e) {
|
|
786
|
-
return c(h(this, o).slice(0, e));
|
|
787
|
-
}
|
|
788
|
-
takeUntil(e) {
|
|
789
|
-
return typeof e == "function" ? this.take(h(this, o).findIndex((t, r) => e(t, r, this))) : this.take(h(this, o).findIndex((t) => t == e));
|
|
790
|
-
}
|
|
791
|
-
takeWhile(e) {
|
|
792
|
-
return typeof e == "function" ? this.take(h(this, o).findIndex((t, r) => !e(t, r, this))) : this.take(h(this, o).findIndex((t) => t != e));
|
|
793
|
-
}
|
|
794
|
-
tap(e) {
|
|
795
|
-
return e(this), this;
|
|
796
|
-
}
|
|
797
|
-
toArray() {
|
|
798
|
-
const e = (t) => typeof t != "object" ? t : Array.isArray(t) ? t.map(e) : t && "toArray" in t && typeof t.toArray == "function" ? t.toArray() : t && "toJson" in t && typeof t.toJson == "function" ? t.toJson() : t;
|
|
799
|
-
return h(this, o).map(e);
|
|
800
|
-
}
|
|
801
|
-
toJson() {
|
|
802
|
-
return JSON.stringify(h(this, o));
|
|
803
|
-
}
|
|
804
|
-
transform(e) {
|
|
805
|
-
for (const [t, r] of h(this, o).entries())
|
|
806
|
-
h(this, o).splice(t, 1, e(r, t, this));
|
|
807
|
-
return _(this), this;
|
|
808
|
-
}
|
|
809
|
-
unique(e) {
|
|
810
|
-
return c(typeof e == "string" ? h(this, o).filter((t, r) => !h(this, o).some((i, s) => i[e] == t[e] && s !== r)) : [...new Set(h(this, o))]);
|
|
811
|
-
}
|
|
812
|
-
uniqueStrict(e) {
|
|
813
|
-
return c(typeof e == "string" ? h(this, o).filter((t, r) => !h(this, o).some((i, s) => i[e] === t[e] && s !== r)) : [...new Set(h(this, o))]);
|
|
814
|
-
}
|
|
815
|
-
unless(e, t, r) {
|
|
816
|
-
return e ? typeof r == "function" && r(this) : t(this), this;
|
|
817
|
-
}
|
|
818
|
-
unlessEmpty(e, t) {
|
|
819
|
-
return this.whenNotEmpty(e, t);
|
|
820
|
-
}
|
|
821
|
-
unlessNotEmpty(e, t) {
|
|
822
|
-
return this.whenEmpty(e, t);
|
|
823
|
-
}
|
|
824
|
-
value(e) {
|
|
825
|
-
return h(this, o).length === 0 ? null : h(this, o)[0][e];
|
|
826
|
-
}
|
|
827
|
-
when(e, t, r) {
|
|
828
|
-
return e ? t(this) : typeof r == "function" && r(this), this;
|
|
829
|
-
}
|
|
830
|
-
whenEmpty(e, t) {
|
|
831
|
-
return this.isEmpty() ? e(this) : typeof t == "function" && t(this), this;
|
|
832
|
-
}
|
|
833
|
-
whenNotEmpty(e, t) {
|
|
834
|
-
return this.isNotEmpty() ? e(this) : typeof t == "function" && t(this), this;
|
|
835
|
-
}
|
|
836
|
-
where(e, t, r) {
|
|
837
|
-
if (typeof r > "u")
|
|
838
|
-
return c(h(this, o).filter((s) => s[e] == t));
|
|
839
|
-
if (typeof t != "string")
|
|
840
|
-
throw new TypeError("The operator must be a string");
|
|
841
|
-
if (r === null)
|
|
842
|
-
return c(h(this, o).filter((s) => s[e] === null));
|
|
843
|
-
const i = {
|
|
844
|
-
"=": (s) => s[e] == r,
|
|
845
|
-
"!=": (s) => s[e] != r,
|
|
846
|
-
">": (s) => s[e] > r,
|
|
847
|
-
"<": (s) => s[e] < r,
|
|
848
|
-
">=": (s) => s[e] >= r,
|
|
849
|
-
"<=": (s) => s[e] <= r
|
|
850
|
-
};
|
|
851
|
-
if (!(t in i))
|
|
852
|
-
throw new Error("Unsupported operator");
|
|
853
|
-
return c(h(this, o).filter((s, u) => i[t](s, u, this)));
|
|
854
|
-
}
|
|
855
|
-
whereStrict(e, t, r) {
|
|
856
|
-
if (typeof r > "u")
|
|
857
|
-
return c(h(this, o).filter((s) => s[e] === t));
|
|
858
|
-
if (typeof t != "string")
|
|
859
|
-
throw new TypeError("The operator must be a string");
|
|
860
|
-
if (r === null)
|
|
861
|
-
return c(h(this, o).filter((s) => s[e] === null));
|
|
862
|
-
const i = {
|
|
863
|
-
"=": (s) => s[e] === r,
|
|
864
|
-
"!=": (s) => s[e] !== r,
|
|
865
|
-
">": (s) => s[e] > r,
|
|
866
|
-
"<": (s) => s[e] < r,
|
|
867
|
-
">=": (s) => s[e] >= r,
|
|
868
|
-
"<=": (s) => s[e] <= r
|
|
869
|
-
};
|
|
870
|
-
if (!(t in i))
|
|
871
|
-
throw new Error("Unsupported operator");
|
|
872
|
-
return c(h(this, o).filter((s, u) => i[t](s, u, this)));
|
|
68
|
+
add(t, e, i = "default") {
|
|
69
|
+
this.bag(i).set(t, e);
|
|
873
70
|
}
|
|
874
|
-
|
|
875
|
-
|
|
71
|
+
set(t, e = "default") {
|
|
72
|
+
this.bag(e).set(".", t);
|
|
876
73
|
}
|
|
877
|
-
|
|
878
|
-
return
|
|
74
|
+
all(t = "default") {
|
|
75
|
+
return this.bag(t).all();
|
|
879
76
|
}
|
|
880
|
-
|
|
881
|
-
return
|
|
77
|
+
get(t, e = "default") {
|
|
78
|
+
return this.bag(e).get(t, null);
|
|
882
79
|
}
|
|
883
|
-
|
|
884
|
-
|
|
80
|
+
clear(t = "default") {
|
|
81
|
+
this.bag(t).set(".", {});
|
|
885
82
|
}
|
|
886
|
-
|
|
887
|
-
|
|
83
|
+
}
|
|
84
|
+
class we {
|
|
85
|
+
constructor(t) {
|
|
86
|
+
this._debug = t;
|
|
888
87
|
}
|
|
889
|
-
|
|
890
|
-
|
|
88
|
+
emergency(...t) {
|
|
89
|
+
this._debug && console.error(...t);
|
|
891
90
|
}
|
|
892
|
-
|
|
893
|
-
|
|
91
|
+
alert(...t) {
|
|
92
|
+
this._debug && console.error(...t);
|
|
894
93
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
h(this, o).map((t, r) => [t, e[r] ?? null])
|
|
898
|
-
) : c(
|
|
899
|
-
h(this, o).map((t, r) => [t, e.get(r)])
|
|
900
|
-
);
|
|
94
|
+
critical(...t) {
|
|
95
|
+
this._debug && console.error(...t);
|
|
901
96
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
on(e, t) {
|
|
905
|
-
throw new b();
|
|
97
|
+
error(...t) {
|
|
98
|
+
this._debug && console.error(...t);
|
|
906
99
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
throw new b();
|
|
100
|
+
warning(...t) {
|
|
101
|
+
this._debug && console.warn(...t);
|
|
910
102
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
throw new b();
|
|
103
|
+
notice(...t) {
|
|
104
|
+
this._debug && console.info(...t);
|
|
914
105
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
const k = A(P);
|
|
918
|
-
var ee, te;
|
|
919
|
-
class H extends (te = P, ee = Symbol.toStringTag, te) {
|
|
920
|
-
constructor() {
|
|
921
|
-
super(...arguments);
|
|
922
|
-
m(this, ee, "Collection");
|
|
106
|
+
info(...t) {
|
|
107
|
+
this._debug && console.info(...t);
|
|
923
108
|
}
|
|
924
|
-
|
|
925
|
-
|
|
109
|
+
debug(...t) {
|
|
110
|
+
this._debug && console.debug(...t);
|
|
926
111
|
}
|
|
927
112
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
e.set(u, s);
|
|
934
|
-
});
|
|
935
|
-
}), e;
|
|
936
|
-
};
|
|
937
|
-
var re, se;
|
|
938
|
-
class Je extends (se = Error, re = Symbol.toStringTag, se) {
|
|
939
|
-
constructor(t) {
|
|
940
|
-
super(`[Luminix] Model "${t}" does not have a primary key`);
|
|
941
|
-
m(this, re, "ModelWithoutPrimaryKeyException");
|
|
113
|
+
var j, O;
|
|
114
|
+
class ve extends (O = Error, j = Symbol.toStringTag, O) {
|
|
115
|
+
constructor(e) {
|
|
116
|
+
super(`[Luminix] Model "${e}" does not have a primary key`);
|
|
117
|
+
d(this, j, "ModelWithoutPrimaryKeyException");
|
|
942
118
|
}
|
|
943
119
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
this.
|
|
120
|
+
class be extends q {
|
|
121
|
+
constructor(e, i, s = {}) {
|
|
122
|
+
super();
|
|
123
|
+
d(this, "bag");
|
|
124
|
+
this.services = e, this.abstract = i, this.query = s, this.bag = new T(s), this.bag.on("change", () => {
|
|
949
125
|
this.emit("change", {
|
|
950
|
-
data: this.bag
|
|
126
|
+
data: this.bag,
|
|
127
|
+
source: this
|
|
951
128
|
});
|
|
952
129
|
});
|
|
953
130
|
}
|
|
954
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
955
|
-
on(e, t) {
|
|
956
|
-
throw new b();
|
|
957
|
-
}
|
|
958
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
959
|
-
once(e, t) {
|
|
960
|
-
throw new b();
|
|
961
|
-
}
|
|
962
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
963
|
-
emit(e, t) {
|
|
964
|
-
throw new b();
|
|
965
|
-
}
|
|
966
131
|
lock(e) {
|
|
967
132
|
this.bag.lock(e);
|
|
968
133
|
}
|
|
969
|
-
whereBetween(e,
|
|
970
|
-
return this.
|
|
134
|
+
whereBetween(e, i) {
|
|
135
|
+
return this.where(e, "between", i);
|
|
971
136
|
}
|
|
972
|
-
whereNotBetween(e,
|
|
973
|
-
return this.
|
|
137
|
+
whereNotBetween(e, i) {
|
|
138
|
+
return this.where(e, "notBetween", i);
|
|
974
139
|
}
|
|
975
140
|
whereNull(e) {
|
|
976
|
-
return this.
|
|
141
|
+
return this.where(e, "null", null);
|
|
977
142
|
}
|
|
978
143
|
whereNotNull(e) {
|
|
979
|
-
return this.
|
|
144
|
+
return this.where(e, "notNull", null);
|
|
980
145
|
}
|
|
981
146
|
limit(e) {
|
|
982
147
|
return this.bag.set("per_page", e), this;
|
|
983
148
|
}
|
|
984
|
-
where(e,
|
|
149
|
+
where(e, i, s) {
|
|
985
150
|
if (this.bag.has("where") || this.bag.set("where", {}), typeof e == "function")
|
|
986
151
|
return e(this) || this;
|
|
987
|
-
if (typeof
|
|
988
|
-
return this.bag.set(`where.${
|
|
989
|
-
if (typeof
|
|
990
|
-
throw new Error(`Invalid operator ${
|
|
991
|
-
const
|
|
152
|
+
if (typeof s > "u")
|
|
153
|
+
return this.bag.set(`where.${e}`, i), this;
|
|
154
|
+
if (typeof i != "string")
|
|
155
|
+
throw new Error(`Invalid operator ${i} provided for where clause.`);
|
|
156
|
+
const g = {
|
|
992
157
|
"=": "",
|
|
993
|
-
"!=": "
|
|
994
|
-
">": "
|
|
995
|
-
">=": "
|
|
996
|
-
"<": "
|
|
997
|
-
"<=": "
|
|
998
|
-
}[
|
|
999
|
-
return this.bag.set(`where.${
|
|
158
|
+
"!=": "notEquals",
|
|
159
|
+
">": "greaterThan",
|
|
160
|
+
">=": "greaterThanOrEquals",
|
|
161
|
+
"<": "lessThan",
|
|
162
|
+
"<=": "lessThanOrEquals"
|
|
163
|
+
}[i] || i;
|
|
164
|
+
return this.bag.set(`where.${e}:${g}`, s), this;
|
|
1000
165
|
}
|
|
1001
166
|
with(e) {
|
|
1002
|
-
const
|
|
1003
|
-
return (Array.isArray(e) ? e : [e]).forEach((
|
|
1004
|
-
|
|
1005
|
-
}), this.bag.set("with",
|
|
167
|
+
const i = this.bag.get("with", []);
|
|
168
|
+
return (Array.isArray(e) ? e : [e]).forEach((c) => {
|
|
169
|
+
i.includes(c) || i.push(c);
|
|
170
|
+
}), this.bag.set("with", i), this;
|
|
1006
171
|
}
|
|
1007
172
|
withOnly(e) {
|
|
1008
173
|
return this.bag.set("with", Array.isArray(e) ? e : [e]), this;
|
|
1009
174
|
}
|
|
1010
175
|
without(e) {
|
|
1011
|
-
const
|
|
1012
|
-
return (Array.isArray(e) ? e : [e]).forEach((
|
|
1013
|
-
|
|
1014
|
-
}), this.bag.set("with",
|
|
176
|
+
const i = this.bag.get("with", []);
|
|
177
|
+
return (Array.isArray(e) ? e : [e]).forEach((c) => {
|
|
178
|
+
i.includes(c) && i.splice(i.indexOf(c), 1);
|
|
179
|
+
}), this.bag.set("with", i), this;
|
|
1015
180
|
}
|
|
1016
|
-
orderBy(e,
|
|
1017
|
-
return this.bag.set("order_by", `${e}:${
|
|
181
|
+
orderBy(e, i = "asc") {
|
|
182
|
+
return this.bag.set("order_by", `${e}:${i}`), this;
|
|
1018
183
|
}
|
|
1019
184
|
searchBy(e) {
|
|
1020
185
|
return this.bag.set("q", e), this;
|
|
@@ -1026,158 +191,153 @@ class Ue {
|
|
|
1026
191
|
return this.bag.delete(e), this;
|
|
1027
192
|
}
|
|
1028
193
|
include(e) {
|
|
1029
|
-
for (const [
|
|
1030
|
-
this.bag.set(
|
|
194
|
+
for (const [i, s] of e.entries())
|
|
195
|
+
this.bag.set(i, s);
|
|
1031
196
|
return this;
|
|
1032
197
|
}
|
|
1033
|
-
async exec(e = 1,
|
|
198
|
+
async exec(e = 1, i) {
|
|
1034
199
|
try {
|
|
1035
200
|
this.bag.set("page", e), this.emit("submit", {
|
|
1036
|
-
data: this.bag
|
|
201
|
+
data: this.bag,
|
|
202
|
+
source: this
|
|
1037
203
|
});
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1043
|
-
return
|
|
204
|
+
const s = await this.services.route.call(
|
|
205
|
+
`luminix.${this.abstract}.index`,
|
|
206
|
+
(h) => h.withQueryParameters(this.bag.all())
|
|
207
|
+
), c = this.services.model.make(this.abstract), g = new b(s.json("data").map((h) => {
|
|
208
|
+
const a = new c(h);
|
|
209
|
+
return a.exists = !0, this.services.model.emit("fetch", {
|
|
1044
210
|
class: this.abstract,
|
|
1045
|
-
model:
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
211
|
+
model: a,
|
|
212
|
+
source: this.services.model
|
|
213
|
+
}), a;
|
|
214
|
+
}));
|
|
215
|
+
if (i) {
|
|
216
|
+
const [h] = i.split("?");
|
|
1050
217
|
return {
|
|
1051
|
-
...
|
|
1052
|
-
data:
|
|
218
|
+
...s.json(),
|
|
219
|
+
data: g,
|
|
1053
220
|
links: {
|
|
1054
|
-
first: `${
|
|
1055
|
-
last: `${
|
|
1056
|
-
next:
|
|
1057
|
-
prev:
|
|
221
|
+
first: `${h}?${S.merge(i, s.json("links").first).toString()}`,
|
|
222
|
+
last: `${h}?${S.merge(i, s.json("links").last).toString()}`,
|
|
223
|
+
next: s.json("links").next && `${h}?${S.merge(i, s.json("links").next ?? "").toString()}`,
|
|
224
|
+
prev: s.json("links").prev && `${h}?${S.merge(i, s.json("links").prev ?? "").toString()}`
|
|
1058
225
|
},
|
|
1059
226
|
meta: {
|
|
1060
|
-
...
|
|
1061
|
-
links:
|
|
1062
|
-
...
|
|
1063
|
-
url:
|
|
227
|
+
...s.json("meta"),
|
|
228
|
+
links: s.json("meta").links.map((a) => ({
|
|
229
|
+
...a,
|
|
230
|
+
url: a.url && `${h}?${S.merge(i, a.url).toString()}`
|
|
1064
231
|
}))
|
|
1065
232
|
}
|
|
1066
233
|
};
|
|
1067
234
|
}
|
|
1068
235
|
return {
|
|
1069
|
-
...
|
|
1070
|
-
data:
|
|
236
|
+
...s.json(),
|
|
237
|
+
data: g
|
|
1071
238
|
};
|
|
1072
|
-
} catch (
|
|
239
|
+
} catch (s) {
|
|
1073
240
|
throw this.emit("error", {
|
|
1074
|
-
error:
|
|
1075
|
-
|
|
241
|
+
error: s,
|
|
242
|
+
source: this
|
|
243
|
+
}), s;
|
|
1076
244
|
}
|
|
1077
245
|
}
|
|
1078
|
-
async get(e = 1,
|
|
1079
|
-
const
|
|
246
|
+
async get(e = 1, i) {
|
|
247
|
+
const s = await this.exec(e, i);
|
|
1080
248
|
return this.emit("success", {
|
|
1081
|
-
response:
|
|
1082
|
-
items:
|
|
1083
|
-
|
|
249
|
+
response: s,
|
|
250
|
+
items: s.data,
|
|
251
|
+
source: this
|
|
252
|
+
}), s;
|
|
1084
253
|
}
|
|
1085
254
|
async first() {
|
|
1086
255
|
const e = await this.limit(1).exec(1);
|
|
1087
256
|
return this.emit("success", {
|
|
1088
257
|
response: e,
|
|
1089
|
-
items: e.data.first()
|
|
258
|
+
items: e.data.first(),
|
|
259
|
+
source: this
|
|
1090
260
|
}), e.data.first();
|
|
1091
261
|
}
|
|
1092
262
|
async find(e) {
|
|
1093
|
-
const
|
|
1094
|
-
if (!
|
|
1095
|
-
throw new
|
|
1096
|
-
const
|
|
263
|
+
const i = this.services.model.schema(this.abstract).primaryKey;
|
|
264
|
+
if (!i)
|
|
265
|
+
throw new ve(this.abstract);
|
|
266
|
+
const s = await this.where(i, e).limit(1).exec(1);
|
|
1097
267
|
return this.emit("success", {
|
|
1098
|
-
response:
|
|
1099
|
-
items:
|
|
1100
|
-
|
|
268
|
+
response: s,
|
|
269
|
+
items: s.data.sole(),
|
|
270
|
+
source: this
|
|
271
|
+
}), s.data.sole();
|
|
1101
272
|
}
|
|
1102
273
|
async all() {
|
|
1103
|
-
const e = this.
|
|
1104
|
-
if (
|
|
1105
|
-
return
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
),
|
|
1109
|
-
|
|
1110
|
-
H
|
|
274
|
+
const e = this.services.config.get("luminix.backend.api.max_per_page", 150), i = await this.limit(e).exec(1), s = i.meta.last_page;
|
|
275
|
+
if (s === 1)
|
|
276
|
+
return i.data;
|
|
277
|
+
const c = Array.from({ length: s - 1 }, (a, r) => r + 2), g = await Promise.all(
|
|
278
|
+
c.map((a) => this.limit(e).exec(a))
|
|
279
|
+
), h = new b(
|
|
280
|
+
g.reduce((a, r) => (a.push(...r.data), a), i.data).all()
|
|
1111
281
|
);
|
|
1112
282
|
return this.emit("success", {
|
|
1113
283
|
response: {
|
|
1114
|
-
...
|
|
1115
|
-
data:
|
|
284
|
+
...i,
|
|
285
|
+
data: h
|
|
1116
286
|
},
|
|
1117
|
-
items:
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
}
|
|
1121
|
-
const He = A(Ue);
|
|
1122
|
-
var ie, ne;
|
|
1123
|
-
class T extends (ne = Error, ie = Symbol.toStringTag, ne) {
|
|
1124
|
-
constructor(t) {
|
|
1125
|
-
super(`[Luminix] Expected ${t} to be reducible.`);
|
|
1126
|
-
m(this, ie, "NotReducibleException");
|
|
287
|
+
items: h,
|
|
288
|
+
source: this
|
|
289
|
+
}), h;
|
|
1127
290
|
}
|
|
1128
291
|
}
|
|
1129
|
-
var
|
|
1130
|
-
class
|
|
1131
|
-
constructor(
|
|
1132
|
-
super(`[Luminix] "${
|
|
1133
|
-
|
|
292
|
+
var B, C;
|
|
293
|
+
class w extends (C = TypeError, B = Symbol.toStringTag, C) {
|
|
294
|
+
constructor(e, i = "Model") {
|
|
295
|
+
super(`[Luminix] "${e}" expects ${i}`);
|
|
296
|
+
d(this, B, "NotModelException");
|
|
1134
297
|
}
|
|
1135
298
|
}
|
|
1136
|
-
var
|
|
1137
|
-
class
|
|
1138
|
-
constructor(
|
|
1139
|
-
super(`[Luminix] Could not determine inverse relation for "${
|
|
1140
|
-
|
|
299
|
+
var I, Q;
|
|
300
|
+
class xe extends (Q = Error, I = Symbol.toStringTag, Q) {
|
|
301
|
+
constructor(e, i, s, c) {
|
|
302
|
+
super(`[Luminix] Could not determine inverse relation for "${i}" in model "${e}". Please specify a relation in model "${s}" of type ${c} that points back to "${e}".`);
|
|
303
|
+
d(this, I, "NoInverseRelationException");
|
|
1141
304
|
}
|
|
1142
305
|
}
|
|
1143
|
-
var
|
|
1144
|
-
class
|
|
1145
|
-
constructor(
|
|
1146
|
-
super(`[Luminix] Relation "${
|
|
1147
|
-
|
|
306
|
+
var P, D;
|
|
307
|
+
class Me extends (D = Error, P = Symbol.toStringTag, D) {
|
|
308
|
+
constructor(e) {
|
|
309
|
+
super(`[Luminix] Relation "${e}" is not supported`);
|
|
310
|
+
d(this, P, "UnsupportedRelationException");
|
|
1148
311
|
}
|
|
1149
312
|
}
|
|
1150
|
-
function
|
|
1151
|
-
return typeof
|
|
313
|
+
function m(o) {
|
|
314
|
+
return typeof o == "object" && o !== null && o.__isModel === !0;
|
|
1152
315
|
}
|
|
1153
|
-
class
|
|
1154
|
-
constructor(
|
|
1155
|
-
|
|
1156
|
-
if (this.
|
|
1157
|
-
throw new
|
|
1158
|
-
}
|
|
1159
|
-
make(
|
|
1160
|
-
const
|
|
1161
|
-
if (
|
|
316
|
+
class N {
|
|
317
|
+
constructor(t, e, i, s = null) {
|
|
318
|
+
d(this, "unsubscribeQuery", null);
|
|
319
|
+
if (this.services = t, this.meta = e, this.parent = i, this.items = s, s !== null && !m(s) && !(s instanceof b && s.every(m)))
|
|
320
|
+
throw new w("Relation.constructor()", "Model, Collection<Model> or null");
|
|
321
|
+
}
|
|
322
|
+
make(t) {
|
|
323
|
+
const e = this.getRelated();
|
|
324
|
+
if (t === null || typeof t > "u") {
|
|
1162
325
|
this.set(null);
|
|
1163
326
|
return;
|
|
1164
327
|
}
|
|
1165
328
|
if (this.isSingle()) {
|
|
1166
|
-
if (typeof
|
|
329
|
+
if (typeof t != "object" || Array.isArray(t))
|
|
1167
330
|
throw new TypeError("Relation.make() expects an object");
|
|
1168
|
-
this.set(new t
|
|
331
|
+
this.set(new e(t));
|
|
1169
332
|
}
|
|
1170
333
|
if (this.isMultiple()) {
|
|
1171
|
-
if (!Array.isArray(
|
|
334
|
+
if (!Array.isArray(t))
|
|
1172
335
|
throw new TypeError("Relation.make() expects an array");
|
|
1173
|
-
this.set(
|
|
336
|
+
this.set(new b(t.map((i) => new e(i))));
|
|
1174
337
|
}
|
|
1175
338
|
}
|
|
1176
339
|
guessInverseRelation() {
|
|
1177
|
-
const { relations:
|
|
1178
|
-
if (typeof this.facades.model.guessInverseRelation != "function")
|
|
1179
|
-
throw new T("ModelFacade");
|
|
1180
|
-
const t = this.getType(), r = this.facades.model.guessInverseRelation({
|
|
340
|
+
const { relations: t } = this.getRelated().getSchema(), e = this.getType(), i = this.services.model.guessInverseRelation({
|
|
1181
341
|
HasOne: ["BelongsTo"],
|
|
1182
342
|
HasMany: ["BelongsTo"],
|
|
1183
343
|
BelongsTo: ["HasOne", "HasMany"],
|
|
@@ -1186,20 +346,20 @@ class K {
|
|
|
1186
346
|
MorphOne: ["MorphTo"],
|
|
1187
347
|
MorphMany: ["MorphTo"],
|
|
1188
348
|
MorphToMany: ["MorphToMany"]
|
|
1189
|
-
}, this.parent,
|
|
1190
|
-
if (!(
|
|
1191
|
-
throw new
|
|
1192
|
-
for (const
|
|
1193
|
-
const
|
|
1194
|
-
if ((
|
|
1195
|
-
return
|
|
349
|
+
}, this.parent, e, this.getRelated());
|
|
350
|
+
if (!(e in i))
|
|
351
|
+
throw new Me(e);
|
|
352
|
+
for (const s in t) {
|
|
353
|
+
const c = t[s];
|
|
354
|
+
if ((c.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(e)) && i[e].includes(c.type))
|
|
355
|
+
return s;
|
|
1196
356
|
}
|
|
1197
|
-
throw new
|
|
357
|
+
throw new xe(this.parent.getType(), e, this.getRelated().getSchemaName(), i[e].join(" or "));
|
|
1198
358
|
}
|
|
1199
|
-
set(
|
|
1200
|
-
if (
|
|
1201
|
-
throw new
|
|
1202
|
-
!this.items ||
|
|
359
|
+
set(t) {
|
|
360
|
+
if (t !== null && !m(t) && !(t instanceof b && t.every(m)))
|
|
361
|
+
throw new w("Relation.set()", "Model, Collection<Model> or null");
|
|
362
|
+
!this.items || m(this.items) ? this.items = t : t instanceof b && this.items.splice(0, this.items.count(), ...t);
|
|
1203
363
|
}
|
|
1204
364
|
getForeignKey() {
|
|
1205
365
|
return this.meta.foreignKey;
|
|
@@ -1214,13 +374,13 @@ class K {
|
|
|
1214
374
|
return this.meta.model;
|
|
1215
375
|
}
|
|
1216
376
|
getRelated() {
|
|
1217
|
-
return this.
|
|
377
|
+
return this.services.model.make(this.meta.model);
|
|
1218
378
|
}
|
|
1219
379
|
query() {
|
|
1220
|
-
const
|
|
1221
|
-
return this.unsubscribeQuery && this.unsubscribeQuery(), this.unsubscribeQuery =
|
|
1222
|
-
this.items =
|
|
1223
|
-
}),
|
|
380
|
+
const t = this.getRelated().query();
|
|
381
|
+
return this.unsubscribeQuery && this.unsubscribeQuery(), this.unsubscribeQuery = t.on("success", (e) => {
|
|
382
|
+
this.items = e.items;
|
|
383
|
+
}), t;
|
|
1224
384
|
}
|
|
1225
385
|
isLoaded() {
|
|
1226
386
|
return this.items !== null;
|
|
@@ -1229,40 +389,40 @@ class K {
|
|
|
1229
389
|
return this.items;
|
|
1230
390
|
}
|
|
1231
391
|
isSingle() {
|
|
1232
|
-
return
|
|
392
|
+
return m(this.items);
|
|
1233
393
|
}
|
|
1234
394
|
isMultiple() {
|
|
1235
|
-
return
|
|
395
|
+
return this.items instanceof b;
|
|
1236
396
|
}
|
|
1237
397
|
getParent() {
|
|
1238
398
|
return this.parent;
|
|
1239
399
|
}
|
|
1240
|
-
where(...
|
|
1241
|
-
return this.query().where(...
|
|
400
|
+
where(...t) {
|
|
401
|
+
return this.query().where(...t);
|
|
1242
402
|
}
|
|
1243
|
-
whereNull(
|
|
1244
|
-
return this.query().whereNull(
|
|
403
|
+
whereNull(t) {
|
|
404
|
+
return this.query().whereNull(t);
|
|
1245
405
|
}
|
|
1246
|
-
whereNotNull(
|
|
1247
|
-
return this.query().whereNotNull(
|
|
406
|
+
whereNotNull(t) {
|
|
407
|
+
return this.query().whereNotNull(t);
|
|
1248
408
|
}
|
|
1249
|
-
whereBetween(
|
|
1250
|
-
return this.query().whereBetween(
|
|
409
|
+
whereBetween(t, e) {
|
|
410
|
+
return this.query().whereBetween(t, e);
|
|
1251
411
|
}
|
|
1252
|
-
whereNotBetween(
|
|
1253
|
-
return this.query().whereNotBetween(
|
|
412
|
+
whereNotBetween(t, e) {
|
|
413
|
+
return this.query().whereNotBetween(t, e);
|
|
1254
414
|
}
|
|
1255
|
-
orderBy(
|
|
1256
|
-
return this.query().orderBy(
|
|
415
|
+
orderBy(t, e = "asc") {
|
|
416
|
+
return this.query().orderBy(t, e);
|
|
1257
417
|
}
|
|
1258
|
-
searchBy(
|
|
1259
|
-
return this.query().searchBy(
|
|
418
|
+
searchBy(t) {
|
|
419
|
+
return this.query().searchBy(t);
|
|
1260
420
|
}
|
|
1261
421
|
minified() {
|
|
1262
422
|
return this.query().minified();
|
|
1263
423
|
}
|
|
1264
|
-
limit(
|
|
1265
|
-
return this.query().limit(
|
|
424
|
+
limit(t) {
|
|
425
|
+
return this.query().limit(t);
|
|
1266
426
|
}
|
|
1267
427
|
// get(page = 1, perPage = 15, replaceLinksWith?: string): Promise<ModelPaginatedResponse>
|
|
1268
428
|
// {
|
|
@@ -1277,133 +437,161 @@ class K {
|
|
|
1277
437
|
// return this.query().find(id);
|
|
1278
438
|
// }
|
|
1279
439
|
}
|
|
1280
|
-
var
|
|
1281
|
-
class
|
|
1282
|
-
constructor(
|
|
1283
|
-
super(`[Luminix]
|
|
1284
|
-
|
|
440
|
+
var H, L;
|
|
441
|
+
class E extends (L = Error, H = Symbol.toStringTag, L) {
|
|
442
|
+
constructor(e) {
|
|
443
|
+
super(`[Luminix] Expected ${e} to be reducible.`);
|
|
444
|
+
d(this, H, "NotReducibleException");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
var J, U;
|
|
448
|
+
class Ee extends (U = Error, J = Symbol.toStringTag, U) {
|
|
449
|
+
constructor() {
|
|
450
|
+
super("[Luminix] Method not implemented.");
|
|
451
|
+
d(this, J, "MethodNotImplementedException");
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
var F, G;
|
|
455
|
+
class ie extends (G = Error, F = Symbol.toStringTag, G) {
|
|
456
|
+
constructor(e, i) {
|
|
457
|
+
super(`[Luminix] Model "${e}" must be persisted before calling "${i}"`);
|
|
458
|
+
d(this, F, "ModelNotPersistedException");
|
|
1285
459
|
}
|
|
1286
460
|
}
|
|
1287
|
-
function
|
|
1288
|
-
var
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
this
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
461
|
+
function $e(o, t, e, i, s) {
|
|
462
|
+
var c, g, h;
|
|
463
|
+
return h = class extends (g = q, c = Symbol.toStringTag, g) {
|
|
464
|
+
constructor(r = {}) {
|
|
465
|
+
super();
|
|
466
|
+
d(this, "_attributes", new T({}));
|
|
467
|
+
d(this, "_original", {});
|
|
468
|
+
d(this, "_relations", {});
|
|
469
|
+
d(this, "_changedKeys", []);
|
|
470
|
+
d(this, "exists", !1);
|
|
471
|
+
d(this, "wasRecentlyCreated", !1);
|
|
472
|
+
d(this, c, y.studly(s));
|
|
473
|
+
this.makeRelations(), this.makeAttributes(r);
|
|
474
|
+
}
|
|
475
|
+
cast(r, n) {
|
|
476
|
+
return r == null || !n ? r : ["boolean", "bool"].includes(n) ? !!r : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(n) && typeof r == "string" ? new Date(r) : ["float", "double", "integer", "int"].includes(n) || n.startsWith("decimal:") ? Number(r) : r;
|
|
477
|
+
}
|
|
478
|
+
mutate(r, n) {
|
|
479
|
+
return r == null || !n ? r : ["boolean", "bool"].includes(n) ? !!r : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(n) && r instanceof Date ? r.toISOString() : ["float", "double", "integer", "int"].includes(n) || n.startsWith("decimal:") ? Number(r) : r;
|
|
1305
480
|
}
|
|
1306
481
|
makeRelations() {
|
|
1307
|
-
const { relations:
|
|
1308
|
-
if (this._relations = {}, !
|
|
482
|
+
const { relations: r } = e.schema(s);
|
|
483
|
+
if (this._relations = {}, !r)
|
|
1309
484
|
return;
|
|
1310
|
-
const
|
|
1311
|
-
Object.entries(
|
|
1312
|
-
const { type:
|
|
1313
|
-
this._relations[
|
|
1314
|
-
{
|
|
1315
|
-
|
|
485
|
+
const n = e.getRelationConstructors(s);
|
|
486
|
+
Object.entries(r).forEach(([u, l]) => {
|
|
487
|
+
const { type: p } = l, f = p in n ? n[p] : N;
|
|
488
|
+
this._relations[u] = new f(
|
|
489
|
+
{ model: e, route: i },
|
|
490
|
+
{ name: u, ...l },
|
|
1316
491
|
this,
|
|
1317
492
|
null
|
|
1318
493
|
);
|
|
1319
494
|
});
|
|
1320
495
|
}
|
|
1321
|
-
makeAttributes(
|
|
1322
|
-
const { relations:
|
|
1323
|
-
if (this.fillable.filter((
|
|
1324
|
-
|
|
1325
|
-
}),
|
|
1326
|
-
this.relation(
|
|
1327
|
-
}), !this.validateJsonObject(
|
|
1328
|
-
if (
|
|
1329
|
-
throw new TypeError(`[Luminix] Invalid attributes for model "${
|
|
1330
|
-
|
|
496
|
+
makeAttributes(r) {
|
|
497
|
+
const { relations: n } = e.schema(s), u = Object.keys(n || {}), l = v.omit(r, ...u);
|
|
498
|
+
if (this.fillable.filter((p) => !(p in l)).forEach((p) => {
|
|
499
|
+
l[p] = null;
|
|
500
|
+
}), n && Object.keys(n).forEach((p) => {
|
|
501
|
+
this.relation(y.camel(p)).make(r[p]);
|
|
502
|
+
}), !this.validateJsonObject(l)) {
|
|
503
|
+
if (o.get("app.env", "production") === "production")
|
|
504
|
+
throw new TypeError(`[Luminix] Invalid attributes for model "${s}"`);
|
|
505
|
+
t.warning(`Invalid attributes for model "${s}".
|
|
1331
506
|
This will throw an error in production.`, {
|
|
1332
|
-
attributes:
|
|
1333
|
-
abstract:
|
|
507
|
+
attributes: r,
|
|
508
|
+
abstract: s
|
|
1334
509
|
});
|
|
1335
510
|
}
|
|
1336
|
-
this._attributes
|
|
511
|
+
this._attributes.set(".", l), this._original = l, this._changedKeys.splice(0, this._changedKeys.length);
|
|
1337
512
|
}
|
|
1338
513
|
makePrimaryKeyReplacer() {
|
|
1339
514
|
return {
|
|
1340
|
-
[this.
|
|
515
|
+
[this.getKeyName()]: this.getKey()
|
|
1341
516
|
};
|
|
1342
517
|
}
|
|
1343
|
-
dispatchChangeEvent(
|
|
518
|
+
dispatchChangeEvent(r) {
|
|
1344
519
|
this.emit("change", {
|
|
1345
|
-
value:
|
|
520
|
+
value: r,
|
|
521
|
+
source: this
|
|
1346
522
|
});
|
|
1347
523
|
}
|
|
1348
|
-
dispatchCreateEvent(
|
|
524
|
+
dispatchCreateEvent(r) {
|
|
1349
525
|
this.emit("create", {
|
|
1350
|
-
value:
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
526
|
+
value: r,
|
|
527
|
+
source: this
|
|
528
|
+
}), e.emit("create", {
|
|
529
|
+
class: s,
|
|
530
|
+
model: this,
|
|
531
|
+
source: e
|
|
1354
532
|
});
|
|
1355
533
|
}
|
|
1356
|
-
dispatchUpdateEvent(
|
|
534
|
+
dispatchUpdateEvent(r) {
|
|
1357
535
|
this.emit("update", {
|
|
1358
|
-
value:
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
536
|
+
value: r,
|
|
537
|
+
source: this
|
|
538
|
+
}), e.emit("update", {
|
|
539
|
+
class: s,
|
|
540
|
+
model: this,
|
|
541
|
+
source: e
|
|
1362
542
|
});
|
|
1363
543
|
}
|
|
1364
544
|
dispatchSaveEvent() {
|
|
1365
545
|
this.emit("save", {
|
|
1366
|
-
value: this.diff()
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
546
|
+
value: this.diff(),
|
|
547
|
+
source: this
|
|
548
|
+
}), e.emit("save", {
|
|
549
|
+
class: s,
|
|
550
|
+
model: this,
|
|
551
|
+
source: e
|
|
1370
552
|
});
|
|
1371
553
|
}
|
|
1372
|
-
dispatchDeleteEvent(
|
|
554
|
+
dispatchDeleteEvent(r = !1) {
|
|
1373
555
|
this.emit("delete", {
|
|
1374
|
-
force:
|
|
1375
|
-
[this.getKeyName()]: this.getKey()
|
|
1376
|
-
|
|
1377
|
-
|
|
556
|
+
force: r,
|
|
557
|
+
[this.getKeyName()]: this.getKey(),
|
|
558
|
+
source: this
|
|
559
|
+
}), e.emit("delete", {
|
|
560
|
+
class: s,
|
|
1378
561
|
model: this,
|
|
1379
|
-
|
|
562
|
+
source: e,
|
|
563
|
+
force: r
|
|
1380
564
|
});
|
|
1381
565
|
}
|
|
1382
566
|
dispatchRestoreEvent() {
|
|
1383
567
|
this.emit("restore", {
|
|
1384
|
-
value: this.attributes
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
568
|
+
value: this.attributes,
|
|
569
|
+
source: this
|
|
570
|
+
}), e.emit("restore", {
|
|
571
|
+
class: s,
|
|
572
|
+
model: this,
|
|
573
|
+
source: e
|
|
1388
574
|
});
|
|
1389
575
|
}
|
|
1390
|
-
dispatchErrorEvent(
|
|
576
|
+
dispatchErrorEvent(r, n) {
|
|
1391
577
|
this.emit("error", {
|
|
1392
|
-
error:
|
|
1393
|
-
operation:
|
|
1394
|
-
|
|
1395
|
-
|
|
578
|
+
error: r,
|
|
579
|
+
operation: n,
|
|
580
|
+
source: this
|
|
581
|
+
}), e.emit("error", {
|
|
582
|
+
class: s,
|
|
1396
583
|
model: this,
|
|
1397
|
-
|
|
1398
|
-
|
|
584
|
+
source: e,
|
|
585
|
+
error: r,
|
|
586
|
+
operation: n
|
|
1399
587
|
});
|
|
1400
588
|
}
|
|
1401
|
-
updateChangedKeys(
|
|
1402
|
-
const
|
|
1403
|
-
!this._changedKeys.includes(
|
|
589
|
+
updateChangedKeys(r) {
|
|
590
|
+
const n = (u, l) => typeof u == "object" && u !== null ? v.isEqual(u, l) : u == l;
|
|
591
|
+
!this._changedKeys.includes(r) && !n(v.get(this._original, r), this._attributes.get(r)) ? this._changedKeys.push(r) : this._changedKeys.includes(r) && n(v.get(this._original, r), this._attributes.get(r)) && this._changedKeys.splice(this._changedKeys.indexOf(r), 1);
|
|
1404
592
|
}
|
|
1405
|
-
validateJsonObject(
|
|
1406
|
-
return typeof
|
|
593
|
+
validateJsonObject(r) {
|
|
594
|
+
return typeof r != "object" || r === null ? !1 : Object.entries(r).every(([, n]) => ["boolean", "number", "string"].includes(typeof n) || n === null || this.validateJsonObject(n) || Array.isArray(n) && n.every((u) => this.validateJsonObject(u)));
|
|
1407
595
|
}
|
|
1408
596
|
get attributes() {
|
|
1409
597
|
return this._attributes.all();
|
|
@@ -1415,20 +603,20 @@ function Ve(n, e) {
|
|
|
1415
603
|
return this._relations;
|
|
1416
604
|
}
|
|
1417
605
|
get fillable() {
|
|
1418
|
-
return
|
|
606
|
+
return e.schema(s).fillable;
|
|
1419
607
|
}
|
|
1420
608
|
get primaryKey() {
|
|
1421
|
-
return
|
|
609
|
+
return e.schema(s).primaryKey;
|
|
1422
610
|
}
|
|
1423
611
|
get timestamps() {
|
|
1424
|
-
return
|
|
612
|
+
return e.schema(s).timestamps;
|
|
1425
613
|
}
|
|
1426
614
|
// get softDeletes() {
|
|
1427
|
-
// return
|
|
615
|
+
// return ModelFacade.schema(abstract).softDeletes;
|
|
1428
616
|
// }
|
|
1429
617
|
get casts() {
|
|
1430
618
|
return {
|
|
1431
|
-
...
|
|
619
|
+
...e.schema(s).casts,
|
|
1432
620
|
...this.timestamps ? { created_at: "datetime", updated_at: "datetime" } : {}
|
|
1433
621
|
// ...this.softDeletes ? { deleted_at: 'datetime' } : {},
|
|
1434
622
|
};
|
|
@@ -1436,36 +624,36 @@ function Ve(n, e) {
|
|
|
1436
624
|
get isDirty() {
|
|
1437
625
|
return this._changedKeys.length > 0;
|
|
1438
626
|
}
|
|
1439
|
-
getAttribute(
|
|
1440
|
-
let
|
|
1441
|
-
|
|
1442
|
-
const
|
|
1443
|
-
if (typeof
|
|
1444
|
-
throw new
|
|
1445
|
-
return
|
|
1446
|
-
}
|
|
1447
|
-
setAttribute(
|
|
1448
|
-
const
|
|
1449
|
-
if (typeof
|
|
1450
|
-
throw new
|
|
1451
|
-
const
|
|
1452
|
-
this.mutate(
|
|
627
|
+
getAttribute(r) {
|
|
628
|
+
let n = this._attributes.get(r, null);
|
|
629
|
+
r in this.casts && (n = this.cast(n, this.casts[r]));
|
|
630
|
+
const u = e[`model${y.studly(s)}Get${y.studly(r)}Attribute`];
|
|
631
|
+
if (typeof u != "function")
|
|
632
|
+
throw new E("ModelFacade");
|
|
633
|
+
return u.bind(e)(n, this);
|
|
634
|
+
}
|
|
635
|
+
setAttribute(r, n) {
|
|
636
|
+
const u = e[`model${y.studly(s)}Set${y.studly(r)}Attribute`];
|
|
637
|
+
if (typeof u != "function")
|
|
638
|
+
throw new E("ModelFacade");
|
|
639
|
+
const l = u.bind(e)(
|
|
640
|
+
this.mutate(n, this.casts[r]),
|
|
1453
641
|
this
|
|
1454
642
|
);
|
|
1455
|
-
if (!this.validateJsonObject({ [
|
|
1456
|
-
if (
|
|
1457
|
-
throw new TypeError(`[Luminix] Attribute "${
|
|
1458
|
-
|
|
643
|
+
if (!this.validateJsonObject({ [r]: l })) {
|
|
644
|
+
if (o.get("app.env", "production") === "production")
|
|
645
|
+
throw new TypeError(`[Luminix] Attribute "${r}" in model "${s}" must be a boolean, number, string or null`);
|
|
646
|
+
t.warning(`Invalid type for attribute "${r}" in model "${s}" after mutation.
|
|
1459
647
|
This will throw an error in production.`, {
|
|
1460
|
-
key:
|
|
1461
|
-
value:
|
|
1462
|
-
mutated:
|
|
1463
|
-
cast: this.casts[
|
|
648
|
+
key: r,
|
|
649
|
+
value: n,
|
|
650
|
+
mutated: l,
|
|
651
|
+
cast: this.casts[r],
|
|
1464
652
|
item: this.toJson()
|
|
1465
653
|
});
|
|
1466
654
|
return;
|
|
1467
655
|
}
|
|
1468
|
-
this._attributes.set(
|
|
656
|
+
this._attributes.set(r, l), this.updateChangedKeys(r), this.dispatchChangeEvent({ [r]: l });
|
|
1469
657
|
}
|
|
1470
658
|
getKey() {
|
|
1471
659
|
return this.getAttribute(this.primaryKey);
|
|
@@ -1473,369 +661,325 @@ function Ve(n, e) {
|
|
|
1473
661
|
getKeyName() {
|
|
1474
662
|
return this.primaryKey;
|
|
1475
663
|
}
|
|
1476
|
-
fill(
|
|
1477
|
-
const
|
|
1478
|
-
const
|
|
1479
|
-
if (typeof
|
|
1480
|
-
throw new
|
|
1481
|
-
return
|
|
1482
|
-
this.mutate(
|
|
664
|
+
fill(r) {
|
|
665
|
+
const n = v.pick(r, ...this.fillable), u = Object.entries(n).reduce((l, [p, f]) => {
|
|
666
|
+
const _ = e[`model${y.studly(s)}Set${y.studly(p)}Attribute`];
|
|
667
|
+
if (typeof _ != "function")
|
|
668
|
+
throw new E("ModelFacade");
|
|
669
|
+
return l[p] = _.bind(e)(
|
|
670
|
+
this.mutate(f, this.casts[p]),
|
|
1483
671
|
this
|
|
1484
|
-
),
|
|
672
|
+
), l;
|
|
1485
673
|
}, {});
|
|
1486
|
-
if (!this.validateJsonObject(
|
|
1487
|
-
if (
|
|
1488
|
-
throw new TypeError(`[Luminix] Invalid attributes for model "${
|
|
1489
|
-
|
|
674
|
+
if (!this.validateJsonObject(u)) {
|
|
675
|
+
if (o.get("app.env", "production") === "production")
|
|
676
|
+
throw new TypeError(`[Luminix] Invalid attributes for model "${s}"`);
|
|
677
|
+
t.warning(`Invalid attributes for model "${s}" after mutation.
|
|
1490
678
|
This will throw an error in production.`, {
|
|
1491
|
-
attributes:
|
|
1492
|
-
mutatedAttributes:
|
|
679
|
+
attributes: r,
|
|
680
|
+
mutatedAttributes: u,
|
|
1493
681
|
item: this.toJson(),
|
|
1494
682
|
casts: this.casts
|
|
1495
683
|
});
|
|
1496
684
|
return;
|
|
1497
685
|
}
|
|
1498
|
-
this._attributes.merge(".",
|
|
686
|
+
this._attributes.merge(".", u), Object.keys(u).forEach((l) => this.updateChangedKeys(l)), this.dispatchChangeEvent(u);
|
|
1499
687
|
}
|
|
1500
688
|
dump() {
|
|
1501
|
-
|
|
689
|
+
t.info({
|
|
1502
690
|
...this.toJson(),
|
|
1503
|
-
[Symbol.toStringTag]:
|
|
691
|
+
[Symbol.toStringTag]: y.studly(s)
|
|
1504
692
|
});
|
|
1505
693
|
}
|
|
1506
694
|
toJson() {
|
|
1507
|
-
const
|
|
1508
|
-
if (typeof
|
|
1509
|
-
throw new
|
|
1510
|
-
return
|
|
695
|
+
const r = Object.entries(this.relations).reduce((u, [l, p]) => (p.isLoaded() && (p.isSingle() ? u[y.snake(l)] = p.getLoadedItems().toJson() : p.isMultiple() && (u[y.snake(l)] = p.getLoadedItems().map((f) => f.toJson()).all())), u), {}), n = e[`model${y.studly(s)}Json`];
|
|
696
|
+
if (typeof n != "function")
|
|
697
|
+
throw new E("ModelFacade");
|
|
698
|
+
return n.bind(e)({
|
|
1511
699
|
...this.attributes,
|
|
1512
|
-
...
|
|
700
|
+
...r
|
|
1513
701
|
}, this);
|
|
1514
702
|
}
|
|
1515
703
|
diff() {
|
|
1516
|
-
return this._changedKeys.reduce((
|
|
704
|
+
return this._changedKeys.reduce((r, n) => (r[n] = this._attributes.get(n), r), {});
|
|
1517
705
|
}
|
|
1518
706
|
getType() {
|
|
1519
|
-
return
|
|
707
|
+
return s;
|
|
708
|
+
}
|
|
709
|
+
relation(r) {
|
|
710
|
+
if (r === y.camel(r))
|
|
711
|
+
return this.relations[y.snake(r)];
|
|
1520
712
|
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
713
|
+
getErrorBag(r) {
|
|
714
|
+
return `${this.exists ? `${s}[${this.getKey()}].` : `${s}.`}${r}`;
|
|
715
|
+
}
|
|
716
|
+
getRouteForSave() {
|
|
717
|
+
return this.exists ? [
|
|
718
|
+
`luminix.${s}.update`,
|
|
719
|
+
this.makePrimaryKeyReplacer()
|
|
720
|
+
] : `luminix.${s}.store`;
|
|
721
|
+
}
|
|
722
|
+
getRouteForUpdate() {
|
|
723
|
+
return [
|
|
724
|
+
`luminix.${s}.update`,
|
|
725
|
+
this.makePrimaryKeyReplacer()
|
|
726
|
+
];
|
|
727
|
+
}
|
|
728
|
+
getRouteForDelete() {
|
|
729
|
+
return [
|
|
730
|
+
`luminix.${s}.destroy`,
|
|
731
|
+
this.makePrimaryKeyReplacer()
|
|
732
|
+
];
|
|
733
|
+
}
|
|
734
|
+
getRouteForRefresh() {
|
|
735
|
+
return [
|
|
736
|
+
`luminix.${s}.show`,
|
|
737
|
+
this.makePrimaryKeyReplacer()
|
|
738
|
+
];
|
|
739
|
+
}
|
|
740
|
+
getLabel() {
|
|
741
|
+
const { labeledBy: r } = e.schema(s);
|
|
742
|
+
return this.getAttribute(r);
|
|
1524
743
|
}
|
|
1525
744
|
async refresh() {
|
|
1526
745
|
if (!this.exists)
|
|
1527
|
-
throw new
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1530
|
-
this.
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
});
|
|
1534
|
-
this.makeAttributes(s);
|
|
746
|
+
throw new ie(s, "refresh");
|
|
747
|
+
const r = await i.call(
|
|
748
|
+
this.getRouteForRefresh()
|
|
749
|
+
//{ errorBag: this.getErrorBag('fetch') }
|
|
750
|
+
);
|
|
751
|
+
this.makeAttributes(r.json());
|
|
1535
752
|
}
|
|
1536
|
-
async save(
|
|
753
|
+
async save(r = {}) {
|
|
1537
754
|
try {
|
|
1538
755
|
const {
|
|
1539
|
-
additionalPayload:
|
|
1540
|
-
sendsOnlyModifiedFields:
|
|
1541
|
-
} =
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
},
|
|
1554
|
-
errorBag: a ? `${e}[${this.getKey()}].update` : `${e}.store`
|
|
1555
|
-
}
|
|
756
|
+
additionalPayload: n = {},
|
|
757
|
+
sendsOnlyModifiedFields: u = !0
|
|
758
|
+
} = r, l = this.exists, p = {
|
|
759
|
+
...v.pick(
|
|
760
|
+
u && l ? this.diff() : this.attributes,
|
|
761
|
+
...this.fillable
|
|
762
|
+
),
|
|
763
|
+
...n
|
|
764
|
+
};
|
|
765
|
+
if (v.isEmpty(p))
|
|
766
|
+
return;
|
|
767
|
+
const f = await i.call(
|
|
768
|
+
this.getRouteForSave(),
|
|
769
|
+
(_) => _.withData(p)
|
|
1556
770
|
);
|
|
1557
|
-
if (
|
|
1558
|
-
return this.makeAttributes(
|
|
1559
|
-
throw
|
|
1560
|
-
} catch (
|
|
1561
|
-
throw
|
|
771
|
+
if (f.successful())
|
|
772
|
+
return this.makeAttributes(f.json()), this.exists = !0, this.dispatchSaveEvent(), l ? this.dispatchUpdateEvent(f.json()) : (this.wasRecentlyCreated = !0, this.dispatchCreateEvent(f.json())), f;
|
|
773
|
+
throw f;
|
|
774
|
+
} catch (n) {
|
|
775
|
+
throw this.dispatchErrorEvent(n, "save"), n;
|
|
1562
776
|
}
|
|
1563
777
|
}
|
|
1564
778
|
async push() {
|
|
1565
|
-
throw new
|
|
779
|
+
throw new Ee();
|
|
1566
780
|
}
|
|
1567
781
|
async delete() {
|
|
1568
782
|
try {
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1571
|
-
this.
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
throw
|
|
1578
|
-
} catch (s) {
|
|
1579
|
-
throw n.make("log").error(s), this.dispatchErrorEvent(s, "delete"), s;
|
|
783
|
+
const r = await i.call(
|
|
784
|
+
this.getRouteForDelete()
|
|
785
|
+
//{ errorBag: this.getErrorBag('delete') }
|
|
786
|
+
);
|
|
787
|
+
if (r.noContent())
|
|
788
|
+
return this.dispatchDeleteEvent(), r;
|
|
789
|
+
throw r;
|
|
790
|
+
} catch (r) {
|
|
791
|
+
throw this.dispatchErrorEvent(r, "delete"), r;
|
|
1580
792
|
}
|
|
1581
793
|
}
|
|
1582
|
-
async update(
|
|
794
|
+
async update(r) {
|
|
1583
795
|
try {
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
});
|
|
1591
|
-
if (u.status === 200) {
|
|
1592
|
-
this.makeAttributes(u.data), this.dispatchUpdateEvent(u.data);
|
|
796
|
+
const n = await i.call(
|
|
797
|
+
this.getRouteForUpdate(),
|
|
798
|
+
(u) => u.withData(r)
|
|
799
|
+
);
|
|
800
|
+
if (n.ok()) {
|
|
801
|
+
this.makeAttributes(n.json()), this.dispatchUpdateEvent(n.json());
|
|
1593
802
|
return;
|
|
1594
803
|
}
|
|
1595
|
-
throw
|
|
1596
|
-
} catch (
|
|
1597
|
-
throw
|
|
804
|
+
throw n;
|
|
805
|
+
} catch (n) {
|
|
806
|
+
throw this.dispatchErrorEvent(n, "save"), n;
|
|
1598
807
|
}
|
|
1599
808
|
}
|
|
1600
809
|
async forceDelete() {
|
|
1601
810
|
try {
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
errorBag: `${e}[${this.getKey()}].forceDelete`
|
|
1610
|
-
}
|
|
811
|
+
const r = await i.call(
|
|
812
|
+
this.getRouteForDelete(),
|
|
813
|
+
(n) => n.withQueryParameters({ force: !0 })
|
|
814
|
+
// {
|
|
815
|
+
// params: { force: true },
|
|
816
|
+
// errorBag: this.getErrorBag('forceDelete'),
|
|
817
|
+
// }
|
|
1611
818
|
);
|
|
1612
|
-
if (
|
|
1613
|
-
return this.dispatchDeleteEvent(!0),
|
|
1614
|
-
throw
|
|
1615
|
-
} catch (
|
|
1616
|
-
throw
|
|
819
|
+
if (r.noContent())
|
|
820
|
+
return this.dispatchDeleteEvent(!0), r;
|
|
821
|
+
throw r;
|
|
822
|
+
} catch (r) {
|
|
823
|
+
throw this.dispatchErrorEvent(r, "forceDelete"), r;
|
|
1617
824
|
}
|
|
1618
825
|
}
|
|
1619
826
|
async restore() {
|
|
1620
827
|
try {
|
|
1621
|
-
const
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
this.makePrimaryKeyReplacer()
|
|
1625
|
-
],
|
|
1626
|
-
{
|
|
1627
|
-
params: { restore: !0 },
|
|
1628
|
-
errorBag: `${e}[${this.getKey()}].restore`
|
|
1629
|
-
}
|
|
828
|
+
const r = await i.call(
|
|
829
|
+
this.getRouteForUpdate(),
|
|
830
|
+
(n) => n.withQueryParameters({ restore: !0 })
|
|
1630
831
|
);
|
|
1631
|
-
if (
|
|
1632
|
-
return this.dispatchRestoreEvent(),
|
|
1633
|
-
throw
|
|
1634
|
-
} catch (
|
|
1635
|
-
throw
|
|
832
|
+
if (r.ok())
|
|
833
|
+
return this.dispatchRestoreEvent(), r;
|
|
834
|
+
throw r;
|
|
835
|
+
} catch (r) {
|
|
836
|
+
throw this.dispatchErrorEvent(r, "restore"), r;
|
|
1636
837
|
}
|
|
1637
838
|
}
|
|
1638
839
|
static getSchemaName() {
|
|
1639
|
-
return
|
|
840
|
+
return s;
|
|
1640
841
|
}
|
|
1641
842
|
static getSchema() {
|
|
1642
|
-
return
|
|
843
|
+
return e.schema(s);
|
|
1643
844
|
}
|
|
1644
845
|
static query() {
|
|
1645
|
-
return new
|
|
846
|
+
return new be(
|
|
847
|
+
{ config: o, route: i, model: e },
|
|
848
|
+
s
|
|
849
|
+
);
|
|
1646
850
|
}
|
|
1647
|
-
static where(...
|
|
1648
|
-
return this.query().where(...
|
|
851
|
+
static where(...r) {
|
|
852
|
+
return this.query().where(...r);
|
|
1649
853
|
}
|
|
1650
|
-
static whereNull(
|
|
1651
|
-
return this.query().whereNull(
|
|
854
|
+
static whereNull(r) {
|
|
855
|
+
return this.query().whereNull(r);
|
|
1652
856
|
}
|
|
1653
|
-
static whereNotNull(
|
|
1654
|
-
return this.query().whereNotNull(
|
|
857
|
+
static whereNotNull(r) {
|
|
858
|
+
return this.query().whereNotNull(r);
|
|
1655
859
|
}
|
|
1656
|
-
static whereBetween(
|
|
1657
|
-
return this.query().whereBetween(
|
|
860
|
+
static whereBetween(r, n) {
|
|
861
|
+
return this.query().whereBetween(r, n);
|
|
1658
862
|
}
|
|
1659
|
-
static whereNotBetween(
|
|
1660
|
-
return this.query().whereNotBetween(
|
|
863
|
+
static whereNotBetween(r, n) {
|
|
864
|
+
return this.query().whereNotBetween(r, n);
|
|
1661
865
|
}
|
|
1662
|
-
static orderBy(
|
|
1663
|
-
return this.query().orderBy(
|
|
866
|
+
static orderBy(r, n = "asc") {
|
|
867
|
+
return this.query().orderBy(r, n);
|
|
1664
868
|
}
|
|
1665
|
-
static searchBy(
|
|
1666
|
-
return this.query().searchBy(
|
|
869
|
+
static searchBy(r) {
|
|
870
|
+
return this.query().searchBy(r);
|
|
1667
871
|
}
|
|
1668
872
|
static minified() {
|
|
1669
873
|
return this.query().minified();
|
|
1670
874
|
}
|
|
1671
|
-
static limit(
|
|
1672
|
-
return this.query().limit(
|
|
875
|
+
static limit(r) {
|
|
876
|
+
return this.query().limit(r);
|
|
1673
877
|
}
|
|
1674
|
-
static get(
|
|
1675
|
-
return this.query().get(
|
|
878
|
+
static get(r = 1, n) {
|
|
879
|
+
return this.query().get(r, n);
|
|
1676
880
|
}
|
|
1677
|
-
static find(
|
|
1678
|
-
return this.query().find(
|
|
881
|
+
static find(r) {
|
|
882
|
+
return this.query().find(r);
|
|
1679
883
|
}
|
|
1680
884
|
static first() {
|
|
1681
885
|
return this.query().first();
|
|
1682
886
|
}
|
|
1683
|
-
static async create(
|
|
1684
|
-
const
|
|
1685
|
-
return
|
|
887
|
+
static async create(r) {
|
|
888
|
+
const n = e.make(s), u = new n();
|
|
889
|
+
return u.fill(r), await u.save(), u;
|
|
1686
890
|
}
|
|
1687
|
-
static async update(
|
|
1688
|
-
const
|
|
1689
|
-
return
|
|
891
|
+
static async update(r, n) {
|
|
892
|
+
const u = e.make(s), l = new u({ id: r });
|
|
893
|
+
return l.fill(n), l.exists = !0, await l.save(), l;
|
|
1690
894
|
}
|
|
1691
|
-
static delete(
|
|
1692
|
-
if (Array.isArray(
|
|
1693
|
-
return
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
const
|
|
1698
|
-
return new
|
|
1699
|
-
}
|
|
1700
|
-
static async restore(
|
|
1701
|
-
if (Array.isArray(
|
|
1702
|
-
return
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
const
|
|
1707
|
-
return new
|
|
1708
|
-
}
|
|
1709
|
-
static forceDelete(
|
|
1710
|
-
if (Array.isArray(
|
|
1711
|
-
return
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
const
|
|
1716
|
-
return new
|
|
895
|
+
static delete(r) {
|
|
896
|
+
if (Array.isArray(r))
|
|
897
|
+
return i.call(
|
|
898
|
+
`luminix.${s}.destroyMany`,
|
|
899
|
+
(l) => l.withQueryParameters({ ids: r })
|
|
900
|
+
);
|
|
901
|
+
const n = e.make(s);
|
|
902
|
+
return new n({ id: r }).delete();
|
|
903
|
+
}
|
|
904
|
+
static async restore(r) {
|
|
905
|
+
if (Array.isArray(r))
|
|
906
|
+
return i.call(
|
|
907
|
+
`luminix.${s}.restoreMany`,
|
|
908
|
+
(l) => l.withData({ ids: r })
|
|
909
|
+
);
|
|
910
|
+
const n = e.make(s);
|
|
911
|
+
return new n({ id: r }).restore();
|
|
912
|
+
}
|
|
913
|
+
static forceDelete(r) {
|
|
914
|
+
if (Array.isArray(r))
|
|
915
|
+
return i.call(
|
|
916
|
+
`luminix.${s}.destroyMany`,
|
|
917
|
+
(l) => l.withQueryParameters({ ids: r, force: !0 })
|
|
918
|
+
);
|
|
919
|
+
const n = e.make(s);
|
|
920
|
+
return new n({ id: r }).forceDelete();
|
|
1717
921
|
}
|
|
1718
922
|
static singular() {
|
|
1719
|
-
return
|
|
923
|
+
return e.schema(s).displayName.singular;
|
|
1720
924
|
}
|
|
1721
925
|
static plural() {
|
|
1722
|
-
return
|
|
1723
|
-
}
|
|
1724
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1725
|
-
on(s, u) {
|
|
1726
|
-
throw new b();
|
|
1727
|
-
}
|
|
1728
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1729
|
-
once(s, u) {
|
|
1730
|
-
throw new b();
|
|
1731
|
-
}
|
|
1732
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1733
|
-
emit(s, u) {
|
|
1734
|
-
throw new b();
|
|
926
|
+
return e.schema(s).displayName.plural;
|
|
1735
927
|
}
|
|
1736
|
-
}
|
|
1737
|
-
return m(t, "name", f.upperFirst(f.camelCase(e))), A(t);
|
|
928
|
+
}, d(h, "name", y.studly(s)), h;
|
|
1738
929
|
}
|
|
1739
|
-
function
|
|
1740
|
-
var
|
|
1741
|
-
return class extends (
|
|
1742
|
-
constructor(
|
|
1743
|
-
super(
|
|
1744
|
-
|
|
930
|
+
function _e(o, t, e) {
|
|
931
|
+
var i, s;
|
|
932
|
+
return class extends (s = e, i = Symbol.toStringTag, s) {
|
|
933
|
+
constructor(g = {}) {
|
|
934
|
+
super(g);
|
|
935
|
+
d(this, i, y.studly(t));
|
|
1745
936
|
return new Proxy(this, {
|
|
1746
|
-
get: (
|
|
937
|
+
get: (h, a) => {
|
|
1747
938
|
if (a === "__isModel")
|
|
1748
939
|
return !0;
|
|
1749
|
-
if (a
|
|
1750
|
-
return Reflect.get(
|
|
1751
|
-
if (
|
|
1752
|
-
return;
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
if (typeof p != "function")
|
|
1763
|
-
throw new T("ModelFacade");
|
|
1764
|
-
return p.bind(n.model)(void 0, l);
|
|
940
|
+
if (Reflect.has(h, a))
|
|
941
|
+
return Reflect.get(h, a);
|
|
942
|
+
if (Object.keys(h.attributes).includes(a))
|
|
943
|
+
return h.getAttribute(a);
|
|
944
|
+
if (Object.keys(h.relations).includes(a))
|
|
945
|
+
return h.relations[a].getLoadedItems();
|
|
946
|
+
if (a.endsWith("Relation") && Object.keys(h.relations).includes(y.snake(a.slice(0, -8))))
|
|
947
|
+
return () => h.relation(a.slice(0, -8));
|
|
948
|
+
if (o.hasReducer(`model${y.studly(h.getType())}Get${y.studly(a)}Attribute`)) {
|
|
949
|
+
const r = o[`model${y.studly(h.getType())}Get${y.studly(a)}Attribute`];
|
|
950
|
+
if (typeof r != "function")
|
|
951
|
+
throw new E("ModelFacade");
|
|
952
|
+
return r.bind(o)(void 0, h);
|
|
1765
953
|
}
|
|
1766
|
-
return Reflect.get(
|
|
954
|
+
return Reflect.get(h, a);
|
|
1767
955
|
},
|
|
1768
|
-
set: (
|
|
1769
|
-
|
|
1770
|
-
|
|
956
|
+
set: (h, a, r) => a in h && typeof h[a] != "function" ? Reflect.set(h, a, r) : (h.setAttribute(
|
|
957
|
+
y.snake(a),
|
|
958
|
+
r
|
|
1771
959
|
), !0)
|
|
1772
960
|
});
|
|
1773
961
|
}
|
|
1774
962
|
};
|
|
1775
963
|
}
|
|
1776
|
-
var
|
|
1777
|
-
class
|
|
1778
|
-
constructor(
|
|
1779
|
-
super(`[Luminix]
|
|
1780
|
-
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
function Se(n) {
|
|
1784
|
-
return class extends n {
|
|
1785
|
-
constructor(...t) {
|
|
1786
|
-
super(...t);
|
|
1787
|
-
m(this, "reducers", {});
|
|
1788
|
-
return new Proxy(this, {
|
|
1789
|
-
get(r, i, s) {
|
|
1790
|
-
return typeof i == "symbol" || i in r ? Reflect.get(r, i, s) : (u, ...l) => {
|
|
1791
|
-
const { [i]: a = c() } = r.reducers;
|
|
1792
|
-
return Pe(u) ? R(u, (d) => a.sortBy("priority").reduce((p, w) => w.callback(p, ...l), d)) : a.sortBy("priority").reduce((d, p) => p.callback(d, ...l), u);
|
|
1793
|
-
};
|
|
1794
|
-
}
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
reducer(t, r, i = 10) {
|
|
1798
|
-
if (t in this)
|
|
1799
|
-
throw new Ye(t, this);
|
|
1800
|
-
return this.reducers[t] || (this.reducers[t] = c()), this.reducers[t].push({ callback: r, priority: i }), () => this.removeReducer(t, r);
|
|
1801
|
-
}
|
|
1802
|
-
removeReducer(t, r) {
|
|
1803
|
-
const i = this.reducers[t].search((s) => s.callback === r);
|
|
1804
|
-
i !== !1 && this.reducers[t].pull(i);
|
|
1805
|
-
}
|
|
1806
|
-
getReducer(t) {
|
|
1807
|
-
return this.reducers[t] || (this.reducers[t] = c()), this.reducers[t];
|
|
1808
|
-
}
|
|
1809
|
-
hasReducer(t) {
|
|
1810
|
-
return !!this.reducers[t] && this.reducers[t].count() > 0;
|
|
1811
|
-
}
|
|
1812
|
-
clearReducer(t) {
|
|
1813
|
-
this.reducers[t].splice(0, this.reducers[t].count());
|
|
1814
|
-
}
|
|
1815
|
-
flushReducers() {
|
|
1816
|
-
Object.values(this.reducers).forEach((t) => t.splice(0, t.count()));
|
|
1817
|
-
}
|
|
1818
|
-
};
|
|
1819
|
-
}
|
|
1820
|
-
var ge, ye;
|
|
1821
|
-
class W extends (ye = Error, ge = Symbol.toStringTag, ye) {
|
|
1822
|
-
constructor(t) {
|
|
1823
|
-
super(`[Luminix] Model "${t}" not found`);
|
|
1824
|
-
m(this, ge, "ModelNotFoundException");
|
|
964
|
+
var V, W;
|
|
965
|
+
class k extends (W = Error, V = Symbol.toStringTag, W) {
|
|
966
|
+
constructor(e) {
|
|
967
|
+
super(`[Luminix] Model "${e}" not found`);
|
|
968
|
+
d(this, V, "ModelNotFoundException");
|
|
1825
969
|
}
|
|
1826
970
|
}
|
|
1827
|
-
var
|
|
1828
|
-
class
|
|
1829
|
-
constructor(
|
|
1830
|
-
super(`[Luminix] "${
|
|
1831
|
-
|
|
971
|
+
var z, X;
|
|
972
|
+
class A extends (X = TypeError, z = Symbol.toStringTag, X) {
|
|
973
|
+
constructor(e, i, s) {
|
|
974
|
+
super(`[Luminix] "${e}" expects a related model of type "${i}". Received "${s}" instead.`);
|
|
975
|
+
d(this, z, "ModelInvalidRelatedTypeException");
|
|
1832
976
|
}
|
|
1833
977
|
}
|
|
1834
|
-
class
|
|
1835
|
-
constructor(
|
|
1836
|
-
if (!
|
|
1837
|
-
throw new
|
|
1838
|
-
super(
|
|
978
|
+
class ne extends N {
|
|
979
|
+
constructor(t, e, i, s = null) {
|
|
980
|
+
if (!m(s) && s !== null)
|
|
981
|
+
throw new w("BelongsTo.constructor()", "Model or null");
|
|
982
|
+
super(t, e, i, s), this.services = t, this.meta = e, this.parent = i, this.items = s;
|
|
1839
983
|
}
|
|
1840
984
|
isSingle() {
|
|
1841
985
|
return !0;
|
|
@@ -1844,21 +988,21 @@ class ve extends K {
|
|
|
1844
988
|
return !1;
|
|
1845
989
|
}
|
|
1846
990
|
query() {
|
|
1847
|
-
const
|
|
1848
|
-
return
|
|
991
|
+
const t = super.query(), e = this.guessInverseRelation();
|
|
992
|
+
return t.where(e, this.parent.getKey()), t.lock(`where.${e}`), t;
|
|
1849
993
|
}
|
|
1850
994
|
get() {
|
|
1851
995
|
return this.query().first();
|
|
1852
996
|
}
|
|
1853
|
-
async associate(
|
|
1854
|
-
if (!
|
|
1855
|
-
throw new
|
|
1856
|
-
if (
|
|
1857
|
-
throw new
|
|
1858
|
-
if (!
|
|
1859
|
-
throw new
|
|
997
|
+
async associate(t) {
|
|
998
|
+
if (!m(t))
|
|
999
|
+
throw new w("BelongsTo.associate()");
|
|
1000
|
+
if (t.getType() !== this.getRelated().getSchemaName())
|
|
1001
|
+
throw new A("BelongsTo.associate()", this.getRelated().getSchemaName(), t.getType());
|
|
1002
|
+
if (!t.exists)
|
|
1003
|
+
throw new ie(this.getRelated().getSchemaName(), "save");
|
|
1860
1004
|
return this.parent.update({
|
|
1861
|
-
[this.getForeignKey()]:
|
|
1005
|
+
[this.getForeignKey()]: t.getKey()
|
|
1862
1006
|
});
|
|
1863
1007
|
}
|
|
1864
1008
|
dissociate() {
|
|
@@ -1867,11 +1011,11 @@ class ve extends K {
|
|
|
1867
1011
|
});
|
|
1868
1012
|
}
|
|
1869
1013
|
}
|
|
1870
|
-
class
|
|
1871
|
-
constructor(
|
|
1872
|
-
if (
|
|
1873
|
-
throw new
|
|
1874
|
-
super(
|
|
1014
|
+
class oe extends N {
|
|
1015
|
+
constructor(t, e, i, s = null) {
|
|
1016
|
+
if (s !== null && !(s instanceof b && s.every(m)))
|
|
1017
|
+
throw new w("BelongsToMany.constructor()", "Collection<Model> or null");
|
|
1018
|
+
super(t, e, i, s), this.services = t, this.meta = e, this.parent = i, this.items = s;
|
|
1875
1019
|
}
|
|
1876
1020
|
isSingle() {
|
|
1877
1021
|
return !1;
|
|
@@ -1880,11 +1024,11 @@ class Ne extends K {
|
|
|
1880
1024
|
return !0;
|
|
1881
1025
|
}
|
|
1882
1026
|
query() {
|
|
1883
|
-
const
|
|
1884
|
-
return
|
|
1027
|
+
const t = super.query(), e = this.guessInverseRelation();
|
|
1028
|
+
return t.where(e, this.parent.getKey()), t.lock(`where.${e}`), t;
|
|
1885
1029
|
}
|
|
1886
|
-
get(
|
|
1887
|
-
return this.query().get(
|
|
1030
|
+
get(t = 1, e) {
|
|
1031
|
+
return this.query().get(t, e);
|
|
1888
1032
|
}
|
|
1889
1033
|
all() {
|
|
1890
1034
|
return this.query().all();
|
|
@@ -1892,104 +1036,95 @@ class Ne extends K {
|
|
|
1892
1036
|
first() {
|
|
1893
1037
|
return this.query().first();
|
|
1894
1038
|
}
|
|
1895
|
-
find(
|
|
1896
|
-
return this.query().find(
|
|
1039
|
+
find(t) {
|
|
1040
|
+
return this.query().find(t);
|
|
1897
1041
|
}
|
|
1898
|
-
attachQuietly(
|
|
1899
|
-
return this.
|
|
1042
|
+
attachQuietly(t, e = {}) {
|
|
1043
|
+
return this.services.route.call([
|
|
1900
1044
|
`luminix.${this.parent.getType()}.${this.getName()}:attach`,
|
|
1901
1045
|
{
|
|
1902
1046
|
[this.parent.getKeyName()]: this.parent.getKey(),
|
|
1903
|
-
itemId:
|
|
1047
|
+
itemId: t
|
|
1904
1048
|
}
|
|
1905
|
-
],
|
|
1906
|
-
data: t,
|
|
1907
|
-
errorBag: `${this.parent.getType()}[${this.parent.getKey()}].${this.getName()}:attach`
|
|
1908
|
-
});
|
|
1049
|
+
], (i) => i.withData(e));
|
|
1909
1050
|
}
|
|
1910
|
-
async attach(
|
|
1911
|
-
if (await this.attachQuietly(
|
|
1912
|
-
const
|
|
1913
|
-
if (!
|
|
1051
|
+
async attach(t, e = {}) {
|
|
1052
|
+
if (await this.attachQuietly(t, e), this.items) {
|
|
1053
|
+
const i = this.items.search((c) => c.getKey() === t), s = await this.getRelated().find(t);
|
|
1054
|
+
if (!s)
|
|
1914
1055
|
return;
|
|
1915
|
-
|
|
1056
|
+
i !== !1 ? this.items.put(i, s) : this.items.push(s);
|
|
1916
1057
|
} else
|
|
1917
1058
|
this.items = await this.all();
|
|
1918
1059
|
}
|
|
1919
|
-
async detachQuietly(
|
|
1920
|
-
await this.
|
|
1060
|
+
async detachQuietly(t) {
|
|
1061
|
+
await this.services.route.call(
|
|
1921
1062
|
[
|
|
1922
1063
|
`luminix.${this.parent.getType()}.${this.getName()}:detach`,
|
|
1923
1064
|
{
|
|
1924
1065
|
[this.parent.getKeyName()]: this.parent.getKey(),
|
|
1925
|
-
itemId:
|
|
1066
|
+
itemId: t
|
|
1926
1067
|
}
|
|
1927
|
-
]
|
|
1928
|
-
{
|
|
1929
|
-
|
|
1930
|
-
}
|
|
1068
|
+
]
|
|
1069
|
+
// {
|
|
1070
|
+
// errorBag: `${this.parent.getType()}[${this.parent.getKey()}].${this.getName()}:detach`
|
|
1071
|
+
// }
|
|
1931
1072
|
);
|
|
1932
1073
|
}
|
|
1933
|
-
async detach(
|
|
1934
|
-
if (await this.detachQuietly(
|
|
1935
|
-
const
|
|
1936
|
-
|
|
1074
|
+
async detach(t) {
|
|
1075
|
+
if (await this.detachQuietly(t), this.items) {
|
|
1076
|
+
const e = this.items.search((i) => i.getKey() === t);
|
|
1077
|
+
e !== !1 && this.items.pull(e);
|
|
1937
1078
|
}
|
|
1938
1079
|
}
|
|
1939
|
-
async syncQuietly(
|
|
1940
|
-
await this.
|
|
1080
|
+
async syncQuietly(t) {
|
|
1081
|
+
await this.services.route.call([
|
|
1941
1082
|
`luminix.${this.parent.getType()}.${this.getName()}:sync`,
|
|
1942
1083
|
{
|
|
1943
1084
|
[this.parent.getKeyName()]: this.parent.getKey()
|
|
1944
1085
|
}
|
|
1945
|
-
],
|
|
1946
|
-
data: e,
|
|
1947
|
-
errorBag: `${this.parent.getType()}[${this.parent.getKey()}].${this.getName()}:sync`
|
|
1948
|
-
});
|
|
1086
|
+
], (e) => e.withData(t));
|
|
1949
1087
|
}
|
|
1950
|
-
async syncWithPivotValuesQuietly(
|
|
1951
|
-
await this.
|
|
1088
|
+
async syncWithPivotValuesQuietly(t, e) {
|
|
1089
|
+
await this.services.route.call([
|
|
1952
1090
|
`luminix.${this.parent.getType()}.${this.getName()}:sync`,
|
|
1953
1091
|
{
|
|
1954
1092
|
[this.parent.getKeyName()]: this.parent.getKey()
|
|
1955
1093
|
}
|
|
1956
|
-
], {
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
})),
|
|
1961
|
-
errorBag: `${this.parent.getType()}[${this.parent.getKey()}].${this.getName()}:sync`
|
|
1962
|
-
});
|
|
1094
|
+
], (i) => i.withData(t.map((s) => ({
|
|
1095
|
+
[this.getRelated().getSchema().primaryKey]: s,
|
|
1096
|
+
...e
|
|
1097
|
+
}))));
|
|
1963
1098
|
}
|
|
1964
|
-
async sync(
|
|
1965
|
-
await this.syncQuietly(
|
|
1966
|
-
const
|
|
1967
|
-
this.items ? this.items.splice(0, this.items.count(), ...
|
|
1099
|
+
async sync(t) {
|
|
1100
|
+
await this.syncQuietly(t);
|
|
1101
|
+
const e = await this.all();
|
|
1102
|
+
this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
|
|
1968
1103
|
}
|
|
1969
|
-
async syncWithPivotValues(
|
|
1970
|
-
await this.syncWithPivotValuesQuietly(
|
|
1971
|
-
const
|
|
1972
|
-
this.items ? this.items.splice(0, this.items.count(), ...
|
|
1104
|
+
async syncWithPivotValues(t, e) {
|
|
1105
|
+
await this.syncWithPivotValuesQuietly(t, e);
|
|
1106
|
+
const i = await this.all();
|
|
1107
|
+
this.items ? this.items.splice(0, this.items.count(), ...i) : this.items = i;
|
|
1973
1108
|
}
|
|
1974
1109
|
}
|
|
1975
|
-
class
|
|
1110
|
+
class K extends N {
|
|
1976
1111
|
query() {
|
|
1977
|
-
const
|
|
1978
|
-
return
|
|
1112
|
+
const t = super.query(), e = this.guessInverseRelation();
|
|
1113
|
+
return t.where(e, this.parent.getKey()), t.lock(`where.${e}`), t;
|
|
1979
1114
|
}
|
|
1980
|
-
async saveQuietly(
|
|
1981
|
-
if (!
|
|
1982
|
-
throw new
|
|
1983
|
-
if (
|
|
1984
|
-
throw new
|
|
1985
|
-
|
|
1115
|
+
async saveQuietly(t) {
|
|
1116
|
+
if (!m(t))
|
|
1117
|
+
throw new w("HasOneOrMany.saveQuietly()");
|
|
1118
|
+
if (t.getType() !== this.getRelated().getSchemaName())
|
|
1119
|
+
throw new A("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), t.getType());
|
|
1120
|
+
t.setAttribute(this.getForeignKey(), this.parent.getKey()), await t.save();
|
|
1986
1121
|
}
|
|
1987
1122
|
}
|
|
1988
|
-
class
|
|
1989
|
-
constructor(
|
|
1990
|
-
if (!
|
|
1991
|
-
throw new
|
|
1992
|
-
super(
|
|
1123
|
+
class Re extends K {
|
|
1124
|
+
constructor(t, e, i, s = null) {
|
|
1125
|
+
if (!m(s) && s !== null)
|
|
1126
|
+
throw new w("HasOne.constructor()", "Model or null");
|
|
1127
|
+
super(t, e, i, s), this.services = t, this.meta = e, this.parent = i, this.items = s;
|
|
1993
1128
|
}
|
|
1994
1129
|
isSingle() {
|
|
1995
1130
|
return !0;
|
|
@@ -2000,15 +1135,15 @@ class Ze extends Q {
|
|
|
2000
1135
|
get() {
|
|
2001
1136
|
return this.query().first();
|
|
2002
1137
|
}
|
|
2003
|
-
async save(
|
|
2004
|
-
await this.saveQuietly(
|
|
1138
|
+
async save(t) {
|
|
1139
|
+
await this.saveQuietly(t), this.items = t;
|
|
2005
1140
|
}
|
|
2006
1141
|
}
|
|
2007
|
-
class
|
|
2008
|
-
constructor(
|
|
2009
|
-
if (
|
|
2010
|
-
throw new
|
|
2011
|
-
super(
|
|
1142
|
+
class Se extends K {
|
|
1143
|
+
constructor(t, e, i, s = null) {
|
|
1144
|
+
if (s !== null && !(s instanceof b && s.every(m)))
|
|
1145
|
+
throw new w("HasMany.constructor()", "Collection<Model> or null");
|
|
1146
|
+
super(t, e, i, s), this.services = t, this.meta = e, this.parent = i, this.items = s;
|
|
2012
1147
|
}
|
|
2013
1148
|
isSingle() {
|
|
2014
1149
|
return !1;
|
|
@@ -2016,8 +1151,8 @@ class ze extends Q {
|
|
|
2016
1151
|
isMultiple() {
|
|
2017
1152
|
return !0;
|
|
2018
1153
|
}
|
|
2019
|
-
get(
|
|
2020
|
-
return this.query().get(
|
|
1154
|
+
get(t = 1, e) {
|
|
1155
|
+
return this.query().get(t, e);
|
|
2021
1156
|
}
|
|
2022
1157
|
all() {
|
|
2023
1158
|
return this.query().all();
|
|
@@ -2025,48 +1160,48 @@ class ze extends Q {
|
|
|
2025
1160
|
first() {
|
|
2026
1161
|
return this.query().first();
|
|
2027
1162
|
}
|
|
2028
|
-
find(
|
|
2029
|
-
return this.query().find(
|
|
1163
|
+
find(t) {
|
|
1164
|
+
return this.query().find(t);
|
|
2030
1165
|
}
|
|
2031
|
-
async saveManyQuietly(
|
|
2032
|
-
if (!Array.isArray(
|
|
2033
|
-
throw new
|
|
2034
|
-
if (!
|
|
2035
|
-
throw new
|
|
2036
|
-
await Promise.all(
|
|
1166
|
+
async saveManyQuietly(t) {
|
|
1167
|
+
if (!Array.isArray(t) || !t.every(m))
|
|
1168
|
+
throw new w("HasMany.saveManyQuietly()", "Model[]");
|
|
1169
|
+
if (!t.every((e) => e.getType() === this.getRelated().getSchemaName()))
|
|
1170
|
+
throw new A("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), t.map((e) => e.getType()).join(", "));
|
|
1171
|
+
await Promise.all(t.map((e) => (e.setAttribute(this.getForeignKey(), this.parent.getKey()), e.save())));
|
|
2037
1172
|
}
|
|
2038
|
-
async saveMany(
|
|
2039
|
-
await this.saveManyQuietly(
|
|
2040
|
-
const
|
|
2041
|
-
this.items ? this.items.splice(0, this.items.count(), ...
|
|
1173
|
+
async saveMany(t) {
|
|
1174
|
+
await this.saveManyQuietly(t);
|
|
1175
|
+
const e = await this.all();
|
|
1176
|
+
this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
|
|
2042
1177
|
}
|
|
2043
|
-
async save(
|
|
2044
|
-
await this.saveQuietly(
|
|
1178
|
+
async save(t) {
|
|
1179
|
+
await this.saveQuietly(t), this.items === null ? this.items = await this.all() : this.items.push(t);
|
|
2045
1180
|
}
|
|
2046
1181
|
}
|
|
2047
|
-
class
|
|
1182
|
+
class ae extends K {
|
|
2048
1183
|
query() {
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
this.items =
|
|
1184
|
+
const t = this.getRelated().query();
|
|
1185
|
+
t.once("success", (i) => {
|
|
1186
|
+
this.items = i.items;
|
|
2052
1187
|
});
|
|
2053
|
-
const
|
|
2054
|
-
return
|
|
1188
|
+
const e = this.guessInverseRelation();
|
|
1189
|
+
return t.where(e + "_id", this.parent.getKey()), t.where(e + "_type", this.getRelated().getSchemaName()), t.lock(`where.${e}_id`), t.lock(`where.${e}_type`), t;
|
|
2055
1190
|
}
|
|
2056
|
-
async saveQuietly(
|
|
2057
|
-
if (!
|
|
2058
|
-
throw new
|
|
2059
|
-
if (
|
|
2060
|
-
throw new
|
|
2061
|
-
const
|
|
2062
|
-
|
|
1191
|
+
async saveQuietly(t) {
|
|
1192
|
+
if (!m(t))
|
|
1193
|
+
throw new w("MorphOneOrMany.saveQuietly()");
|
|
1194
|
+
if (t.getType() !== this.getRelated().getSchemaName())
|
|
1195
|
+
throw new A("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), t.getType());
|
|
1196
|
+
const e = this.guessInverseRelation();
|
|
1197
|
+
t.setAttribute(e + "_id", this.parent.getKey()), t.setAttribute(e + "_type", this.parent.getType()), await t.save();
|
|
2063
1198
|
}
|
|
2064
1199
|
}
|
|
2065
|
-
class
|
|
2066
|
-
constructor(
|
|
2067
|
-
if (
|
|
2068
|
-
throw new
|
|
2069
|
-
super(
|
|
1200
|
+
class Te extends ae {
|
|
1201
|
+
constructor(t, e, i, s = null) {
|
|
1202
|
+
if (s !== null && !(s instanceof b && s.every(m)))
|
|
1203
|
+
throw new w("MorphMany.constructor()", "Collection<Model> or null");
|
|
1204
|
+
super(t, e, i, s), this.services = t, this.meta = e, this.parent = i, this.items = s;
|
|
2070
1205
|
}
|
|
2071
1206
|
isSingle() {
|
|
2072
1207
|
return !1;
|
|
@@ -2074,8 +1209,8 @@ class Oe extends Re {
|
|
|
2074
1209
|
isMultiple() {
|
|
2075
1210
|
return !0;
|
|
2076
1211
|
}
|
|
2077
|
-
get(
|
|
2078
|
-
return this.query().get(
|
|
1212
|
+
get(t = 1, e) {
|
|
1213
|
+
return this.query().get(t, e);
|
|
2079
1214
|
}
|
|
2080
1215
|
all() {
|
|
2081
1216
|
return this.query().all();
|
|
@@ -2083,29 +1218,29 @@ class Oe extends Re {
|
|
|
2083
1218
|
first() {
|
|
2084
1219
|
return this.query().first();
|
|
2085
1220
|
}
|
|
2086
|
-
find(
|
|
2087
|
-
return this.query().find(
|
|
1221
|
+
find(t) {
|
|
1222
|
+
return this.query().find(t);
|
|
2088
1223
|
}
|
|
2089
|
-
async saveManyQuietly(
|
|
2090
|
-
if (!Array.isArray(
|
|
2091
|
-
throw new
|
|
2092
|
-
if (!
|
|
2093
|
-
throw new
|
|
2094
|
-
await Promise.all(
|
|
1224
|
+
async saveManyQuietly(t) {
|
|
1225
|
+
if (!Array.isArray(t) || !t.every(m))
|
|
1226
|
+
throw new w("MorphMany.saveManyQuietly()");
|
|
1227
|
+
if (!t.every((e) => e.getType() === this.getRelated().getSchemaName()))
|
|
1228
|
+
throw new A("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), t.map((e) => e.getType()).join(", "));
|
|
1229
|
+
await Promise.all(t.map((e) => (e.setAttribute(this.getName() + "_id", this.parent.getKey()), e.setAttribute(this.getName() + "_type", this.parent.getType()), e.save())));
|
|
2095
1230
|
}
|
|
2096
|
-
async save(
|
|
2097
|
-
await this.saveQuietly(
|
|
1231
|
+
async save(t) {
|
|
1232
|
+
await this.saveQuietly(t), this.items ? this.items.push(t) : this.items = await this.all();
|
|
2098
1233
|
}
|
|
2099
|
-
async saveMany(
|
|
2100
|
-
await this.saveManyQuietly(
|
|
2101
|
-
const
|
|
2102
|
-
this.items ? this.items.splice(0, this.items.count(), ...
|
|
1234
|
+
async saveMany(t) {
|
|
1235
|
+
await this.saveManyQuietly(t);
|
|
1236
|
+
const e = await this.all();
|
|
1237
|
+
this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
|
|
2103
1238
|
}
|
|
2104
1239
|
}
|
|
2105
|
-
class
|
|
2106
|
-
constructor(
|
|
2107
|
-
if (super(
|
|
2108
|
-
throw new
|
|
1240
|
+
class Ae extends ae {
|
|
1241
|
+
constructor(t, e, i, s = null) {
|
|
1242
|
+
if (super(t, e, i, s), this.services = t, this.meta = e, this.parent = i, this.items = s, s !== null && !m(s))
|
|
1243
|
+
throw new w("MorphOne.constructor()", "Model or null");
|
|
2109
1244
|
}
|
|
2110
1245
|
isSingle() {
|
|
2111
1246
|
return !0;
|
|
@@ -2116,13 +1251,13 @@ class et extends Re {
|
|
|
2116
1251
|
get() {
|
|
2117
1252
|
return this.query().first();
|
|
2118
1253
|
}
|
|
2119
|
-
async save(
|
|
2120
|
-
await this.saveQuietly(
|
|
1254
|
+
async save(t) {
|
|
1255
|
+
await this.saveQuietly(t), this.items = t;
|
|
2121
1256
|
}
|
|
2122
1257
|
}
|
|
2123
|
-
class
|
|
1258
|
+
class Ne extends ne {
|
|
2124
1259
|
getRelated() {
|
|
2125
|
-
return this.
|
|
1260
|
+
return this.services.model.make(
|
|
2126
1261
|
this.parent.getAttribute(this.getName() + "_type")
|
|
2127
1262
|
);
|
|
2128
1263
|
}
|
|
@@ -2134,12 +1269,12 @@ class tt extends ve {
|
|
|
2134
1269
|
// this.of(this.parent.getAttribute(this.getName() + '_type') as string);
|
|
2135
1270
|
// return super.query();
|
|
2136
1271
|
// }
|
|
2137
|
-
async associate(
|
|
2138
|
-
if (!
|
|
2139
|
-
throw new
|
|
2140
|
-
return
|
|
2141
|
-
[this.getName() + "_id"]:
|
|
2142
|
-
[this.getName() + "_type"]:
|
|
1272
|
+
async associate(t) {
|
|
1273
|
+
if (!m(t))
|
|
1274
|
+
throw new w("MorphTo.associate()");
|
|
1275
|
+
return t.exists || await t.save(), this.parent.update({
|
|
1276
|
+
[this.getName() + "_id"]: t.getKey(),
|
|
1277
|
+
[this.getName() + "_type"]: t.getType()
|
|
2143
1278
|
});
|
|
2144
1279
|
}
|
|
2145
1280
|
dissociate() {
|
|
@@ -2149,376 +1284,353 @@ class tt extends ve {
|
|
|
2149
1284
|
});
|
|
2150
1285
|
}
|
|
2151
1286
|
}
|
|
2152
|
-
class
|
|
2153
|
-
constructor(e, t, r, i = null) {
|
|
2154
|
-
super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
|
|
2155
|
-
}
|
|
1287
|
+
class qe extends oe {
|
|
2156
1288
|
query() {
|
|
2157
|
-
const
|
|
2158
|
-
return
|
|
1289
|
+
const t = super.query(), e = this.guessInverseRelation();
|
|
1290
|
+
return t.where(e + "_id", this.parent.getKey()), t.where(e + "_type", this.parent.getType()), t.lock(`where.${e}_id`), t.lock(`where.${e}_type`), t;
|
|
2159
1291
|
}
|
|
2160
1292
|
}
|
|
2161
|
-
var
|
|
2162
|
-
|
|
2163
|
-
class st {
|
|
1293
|
+
var Y, Z;
|
|
1294
|
+
class Ke extends (Z = q, Y = Symbol.toStringTag, Z) {
|
|
2164
1295
|
constructor(e) {
|
|
2165
|
-
|
|
2166
|
-
|
|
1296
|
+
super();
|
|
1297
|
+
d(this, "_models", {});
|
|
1298
|
+
d(this, Y, "ModelService");
|
|
2167
1299
|
this._schema = e;
|
|
2168
1300
|
}
|
|
2169
1301
|
boot(e) {
|
|
2170
|
-
this._schema &&
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
HasMany: ze,
|
|
2184
|
-
MorphMany: Oe,
|
|
2185
|
-
MorphOne: et,
|
|
2186
|
-
MorphTo: tt,
|
|
2187
|
-
MorphToMany: rt
|
|
2188
|
-
}), 0));
|
|
1302
|
+
this._schema && Object.keys(this._schema).forEach((i) => {
|
|
1303
|
+
const s = this[`model${y.studly(i)}`], c = this.model(
|
|
1304
|
+
$e(
|
|
1305
|
+
e.make("config"),
|
|
1306
|
+
e.make("log"),
|
|
1307
|
+
e.make("model"),
|
|
1308
|
+
e.make("route"),
|
|
1309
|
+
i
|
|
1310
|
+
),
|
|
1311
|
+
i
|
|
1312
|
+
), g = s(c);
|
|
1313
|
+
this._models[i] = _e(e.make("model"), i, g);
|
|
1314
|
+
});
|
|
2189
1315
|
}
|
|
2190
1316
|
schema(e) {
|
|
2191
1317
|
if (!this._schema || e && !this._schema[e])
|
|
2192
|
-
throw new
|
|
1318
|
+
throw new k(e || "undefined");
|
|
2193
1319
|
return e ? this._schema[e] : this._schema;
|
|
2194
1320
|
}
|
|
2195
1321
|
make(e) {
|
|
2196
1322
|
if (e && !this._models[e])
|
|
2197
|
-
throw new
|
|
1323
|
+
throw new k(e);
|
|
2198
1324
|
return e ? this._models[e] : this._models;
|
|
2199
1325
|
}
|
|
1326
|
+
getRelationConstructors(e) {
|
|
1327
|
+
return this.relationMap({
|
|
1328
|
+
BelongsTo: ne,
|
|
1329
|
+
BelongsToMany: oe,
|
|
1330
|
+
HasOne: Re,
|
|
1331
|
+
HasMany: Se,
|
|
1332
|
+
MorphMany: Te,
|
|
1333
|
+
MorphOne: Ae,
|
|
1334
|
+
MorphTo: Ne,
|
|
1335
|
+
MorphToMany: qe
|
|
1336
|
+
}, e);
|
|
1337
|
+
}
|
|
2200
1338
|
toString() {
|
|
2201
1339
|
return "model";
|
|
2202
1340
|
}
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
}
|
|
2211
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2212
|
-
emit(e, t) {
|
|
2213
|
-
throw new b();
|
|
1341
|
+
}
|
|
1342
|
+
const ke = se(Ke);
|
|
1343
|
+
var ee, te;
|
|
1344
|
+
class je extends (te = Error, ee = Symbol.toStringTag, te) {
|
|
1345
|
+
constructor(e) {
|
|
1346
|
+
super(`[Luminix] Route "${e}" not found`);
|
|
1347
|
+
d(this, ee, "RouteNotFoundException");
|
|
2214
1348
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
1349
|
+
}
|
|
1350
|
+
class Oe {
|
|
1351
|
+
constructor(t, e, i, s = "") {
|
|
1352
|
+
this.routes = t, this.error = e, this.http = i, this.appUrl = s;
|
|
2218
1353
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
1354
|
+
isRouteTuple(t) {
|
|
1355
|
+
if (!Array.isArray(t) || t.length < 2)
|
|
1356
|
+
return !1;
|
|
1357
|
+
const [e, ...i] = t;
|
|
1358
|
+
if (typeof e != "string")
|
|
1359
|
+
return !1;
|
|
1360
|
+
const s = ["get", "post", "put", "patch", "delete"];
|
|
1361
|
+
return !!i.every((c) => s.includes(c));
|
|
2222
1362
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
1363
|
+
extractGenerator(t) {
|
|
1364
|
+
let e, i = !1;
|
|
1365
|
+
return Array.isArray(t) ? [e, i] = t : e = t, [e, i];
|
|
2226
1366
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
1367
|
+
get(t) {
|
|
1368
|
+
if (!this.exists(t))
|
|
1369
|
+
throw new je(t);
|
|
1370
|
+
return v.get(this.routes, t);
|
|
2230
1371
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
1372
|
+
url(t) {
|
|
1373
|
+
const [e, i] = this.extractGenerator(t), s = this.get(e)[0].replace(/^\/|\/$/g, ""), c = /{([^}]+)}/g;
|
|
1374
|
+
if (i === !1) {
|
|
1375
|
+
if (typeof this.replaceRouteParams != "function")
|
|
1376
|
+
throw new E("RouteFacade");
|
|
1377
|
+
return this.appUrl + this.replaceRouteParams(`/${s}`);
|
|
1378
|
+
}
|
|
1379
|
+
const g = s.match(c), h = g ? g.map((l) => l.slice(1, -1)) : [], a = Object.keys(i), r = h.filter((l) => !a.includes(l)), n = a.filter((l) => !h.includes(l));
|
|
1380
|
+
if (r.length > 0)
|
|
1381
|
+
throw new TypeError(`Missing values for parameter(s): ${r.join(", ")}`);
|
|
1382
|
+
if (n.length > 0)
|
|
1383
|
+
throw new TypeError(`Unexpected parameters: ${n.join(", ")}`);
|
|
1384
|
+
const u = h.reduce((l, p) => l.replace(`{${p}}`, `${i[p]}`), s);
|
|
1385
|
+
return this.appUrl + `/${u}`;
|
|
1386
|
+
}
|
|
1387
|
+
methods(t) {
|
|
1388
|
+
const [e] = this.extractGenerator(t);
|
|
1389
|
+
return this.get(e).slice(1);
|
|
1390
|
+
}
|
|
1391
|
+
exists(t) {
|
|
1392
|
+
return v.has(this.routes, t) && this.isRouteTuple(v.get(this.routes, t));
|
|
1393
|
+
}
|
|
1394
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1395
|
+
async call(t, e = (i) => i) {
|
|
1396
|
+
if (typeof this.clientOptions != "function" || typeof this.clientError != "function")
|
|
1397
|
+
throw new E("RouteFacade");
|
|
1398
|
+
const [i, s] = this.extractGenerator(t), [, ...c] = this.get(i), g = this.url(s ? [i, s] : i), h = e(this.http()), a = this.clientOptions({}, i);
|
|
1399
|
+
v.isEmpty(a) || h.withOptions(a);
|
|
1400
|
+
const r = c[0] ?? a.method, n = a.errorBag ?? "default";
|
|
1401
|
+
this.error.clear(n);
|
|
1402
|
+
const u = await h[r](g);
|
|
1403
|
+
if (ce(u)) {
|
|
1404
|
+
const l = u.json("errors");
|
|
1405
|
+
this.error.set(Object.entries(l).reduce((p, [f, _]) => (p[f] = _.join(" "), p), {}), n);
|
|
1406
|
+
} else u.failed() && this.error.set(
|
|
1407
|
+
this.clientError({ axios: u.json("message") }, {
|
|
1408
|
+
response: u,
|
|
1409
|
+
name: i,
|
|
1410
|
+
replace: s,
|
|
1411
|
+
client: h
|
|
1412
|
+
}),
|
|
1413
|
+
n
|
|
1414
|
+
);
|
|
1415
|
+
return u;
|
|
2234
1416
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
throw new b();
|
|
1417
|
+
toString() {
|
|
1418
|
+
return "route";
|
|
2238
1419
|
}
|
|
2239
1420
|
}
|
|
2240
|
-
const
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
super("[Luminix] Embed element not found. Make sure to include the `@luminixEmbed()` directive in your Blade template.");
|
|
2245
|
-
m(this, xe, "NoEmbedException");
|
|
1421
|
+
const Be = se(Oe);
|
|
1422
|
+
class Ce {
|
|
1423
|
+
getClient() {
|
|
1424
|
+
return new de();
|
|
2246
1425
|
}
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
if (!document.querySelector("#luminix-embed"))
|
|
2250
|
-
throw new nt();
|
|
2251
|
-
const t = document.getElementById(`luminix-${e}::` + n);
|
|
2252
|
-
return t ? t.dataset.json && t.dataset.value ? JSON.parse(t.dataset.value) : t.dataset.value : null;
|
|
2253
|
-
}, G = A(S), ot = (n) => ke(n) && n.response !== void 0 && n.response.data !== null && "message" in n.response.data && typeof n.response.data.message == "string" && "errors" in n.response.data && typeof n.response.data.errors == "object" && n.response.data.errors !== null && Object.values(n.response.data.errors).every((e) => Array.isArray(e) && e.every((t) => typeof t == "string")) && n.response.status === 422;
|
|
2254
|
-
let ht = class {
|
|
2255
|
-
constructor() {
|
|
2256
|
-
m(this, "bags");
|
|
2257
|
-
const e = {};
|
|
2258
|
-
document.querySelectorAll('#luminix-embed [id^="luminix-error"]').forEach((r) => {
|
|
2259
|
-
const s = r.id.replace("luminix-error::", "");
|
|
2260
|
-
e[s] = Be(s, "error");
|
|
2261
|
-
}), this.bags = {
|
|
2262
|
-
default: new G(e)
|
|
2263
|
-
};
|
|
1426
|
+
baseUrl(t) {
|
|
1427
|
+
return this.getClient().baseUrl(t);
|
|
2264
1428
|
}
|
|
2265
|
-
|
|
2266
|
-
return this.
|
|
1429
|
+
asForm() {
|
|
1430
|
+
return this.getClient().asForm();
|
|
2267
1431
|
}
|
|
2268
|
-
|
|
2269
|
-
this.
|
|
1432
|
+
accept(t) {
|
|
1433
|
+
return this.getClient().accept(t);
|
|
2270
1434
|
}
|
|
2271
|
-
|
|
2272
|
-
this.
|
|
1435
|
+
acceptJson() {
|
|
1436
|
+
return this.getClient().acceptJson();
|
|
2273
1437
|
}
|
|
2274
|
-
|
|
2275
|
-
return this.
|
|
1438
|
+
withHeaders(t) {
|
|
1439
|
+
return this.getClient().withHeaders(t);
|
|
2276
1440
|
}
|
|
2277
|
-
|
|
2278
|
-
return this.
|
|
1441
|
+
withOptions(t) {
|
|
1442
|
+
return this.getClient().withOptions(t);
|
|
2279
1443
|
}
|
|
2280
|
-
|
|
2281
|
-
this.
|
|
1444
|
+
withData(t) {
|
|
1445
|
+
return this.getClient().withData(t);
|
|
2282
1446
|
}
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
class ut extends (Te = Error, _e = Symbol.toStringTag, Te) {
|
|
2286
|
-
constructor(t) {
|
|
2287
|
-
super(`[Luminix] Route "${t}" not found`);
|
|
2288
|
-
m(this, _e, "RouteNotFoundException");
|
|
1447
|
+
withQueryParameters(t) {
|
|
1448
|
+
return this.getClient().withQueryParameters(t);
|
|
2289
1449
|
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
constructor(e, t, r = "") {
|
|
2293
|
-
this.routes = e, this.error = t, this.appUrl = r;
|
|
1450
|
+
withBasicAuth(t, e) {
|
|
1451
|
+
return this.getClient().withBasicAuth(t, e);
|
|
2294
1452
|
}
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
return !1;
|
|
2298
|
-
const [t, ...r] = e;
|
|
2299
|
-
if (typeof t != "string")
|
|
2300
|
-
return !1;
|
|
2301
|
-
const i = ["get", "post", "put", "patch", "delete"];
|
|
2302
|
-
return !!r.every((s) => i.includes(s));
|
|
1453
|
+
withToken(t) {
|
|
1454
|
+
return this.getClient().withToken(t);
|
|
2303
1455
|
}
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
return
|
|
1456
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1457
|
+
get(t, e) {
|
|
1458
|
+
return this.getClient().get(t, e);
|
|
2307
1459
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
return f.get(this.routes, e);
|
|
1460
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1461
|
+
post(t, e) {
|
|
1462
|
+
return this.getClient().post(t, e);
|
|
2312
1463
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
if (typeof this.replaceRouteParams != "function")
|
|
2317
|
-
throw new T("RouteFacade");
|
|
2318
|
-
return this.appUrl + this.replaceRouteParams(`/${i}`);
|
|
2319
|
-
}
|
|
2320
|
-
const u = i.match(s), l = u ? u.map((x) => x.slice(1, -1)) : [], a = Object.keys(r), d = l.filter((x) => !a.includes(x)), p = a.filter((x) => !l.includes(x));
|
|
2321
|
-
if (d.length > 0)
|
|
2322
|
-
throw new TypeError(`Missing values for parameter(s): ${d.join(", ")}`);
|
|
2323
|
-
if (p.length > 0)
|
|
2324
|
-
throw new TypeError(`Unexpected parameters: ${p.join(", ")}`);
|
|
2325
|
-
const w = l.reduce((x, g) => x.replace(`{${g}}`, `${r[g]}`), i);
|
|
2326
|
-
return this.appUrl + `/${w}`;
|
|
2327
|
-
}
|
|
2328
|
-
methods(e) {
|
|
2329
|
-
const [t] = this.extractGenerator(e);
|
|
2330
|
-
return this.get(t).slice(1);
|
|
2331
|
-
}
|
|
2332
|
-
exists(e) {
|
|
2333
|
-
return f.has(this.routes, e) && this.isRouteTuple(f.get(this.routes, e));
|
|
2334
|
-
}
|
|
2335
|
-
async call(e, t = {}) {
|
|
2336
|
-
if (typeof this.axiosOptions != "function" || typeof this.axiosError != "function")
|
|
2337
|
-
throw new T("RouteFacade");
|
|
2338
|
-
const [r, i] = this.extractGenerator(e), [, ...s] = this.get(r), u = this.url(i ? [r, i] : r), l = this.axiosOptions(t, r), { method: a = s[0], errorBag: d = "route.call", ...p } = l, { data: w, ...x } = p;
|
|
2339
|
-
this.error.clear(d);
|
|
2340
|
-
try {
|
|
2341
|
-
return ["get", "delete"].includes(a) ? await I[a](u, p) : await I[a](u, w, x);
|
|
2342
|
-
} catch (g) {
|
|
2343
|
-
if (ot(g)) {
|
|
2344
|
-
const { errors: qe } = g.response.data;
|
|
2345
|
-
this.error.set(Object.entries(qe).reduce((L, [Ie, Ke]) => (L[Ie] = Ke.join(" "), L), {}));
|
|
2346
|
-
} else I.isAxiosError(g) && this.error.set(
|
|
2347
|
-
this.axiosError({ axios: g.message }, {
|
|
2348
|
-
error: g,
|
|
2349
|
-
name: r,
|
|
2350
|
-
replace: i,
|
|
2351
|
-
config: t
|
|
2352
|
-
}),
|
|
2353
|
-
d
|
|
2354
|
-
);
|
|
2355
|
-
throw g;
|
|
2356
|
-
}
|
|
1464
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1465
|
+
put(t, e) {
|
|
1466
|
+
return this.getClient().put(t, e);
|
|
2357
1467
|
}
|
|
2358
|
-
|
|
2359
|
-
|
|
1468
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1469
|
+
patch(t, e) {
|
|
1470
|
+
return this.getClient().patch(t, e);
|
|
1471
|
+
}
|
|
1472
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1473
|
+
delete(t, e) {
|
|
1474
|
+
return this.getClient().delete(t, e);
|
|
2360
1475
|
}
|
|
2361
1476
|
}
|
|
2362
|
-
const
|
|
2363
|
-
class
|
|
1477
|
+
const Ie = re(Ce);
|
|
1478
|
+
class Qe extends pe {
|
|
2364
1479
|
constructor() {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
m(this, "_plugins", []);
|
|
2368
|
-
}
|
|
2369
|
-
make(e = void 0) {
|
|
2370
|
-
if (!e)
|
|
2371
|
-
return this.facades;
|
|
2372
|
-
if (e in this.facades)
|
|
2373
|
-
return this.facades[e];
|
|
2374
|
-
}
|
|
2375
|
-
has(e) {
|
|
2376
|
-
return !!this.facades[e];
|
|
2377
|
-
}
|
|
2378
|
-
bind(e, t) {
|
|
2379
|
-
this.facades[e] || (this.facades[e] = t);
|
|
2380
|
-
}
|
|
2381
|
-
plugins() {
|
|
2382
|
-
return this._plugins;
|
|
2383
|
-
}
|
|
2384
|
-
async boot(e = {}) {
|
|
2385
|
-
var l, a, d, p, w, x;
|
|
2386
|
-
if (this.booted)
|
|
2387
|
-
throw new window.Error("[Luminix] App already booted");
|
|
2388
|
-
this.booted = !0, (l = e.app) != null && l.debug && console.log("[Luminix] Booting started..."), this.emit("init", {
|
|
2389
|
-
register: (g) => {
|
|
2390
|
-
this._plugins.push(g), typeof g.register == "function" && g.register(this);
|
|
2391
|
-
}
|
|
2392
|
-
});
|
|
2393
|
-
const t = (((a = e.app) == null ? void 0 : a.url) ?? "") + (((d = e.app) == null ? void 0 : d.bootUrl) ?? "/luminix-api/init");
|
|
2394
|
-
if (document.getElementById("luminix-data::config")) {
|
|
2395
|
-
if (document.getElementById("luminix-data::config")) {
|
|
2396
|
-
const g = Be("config");
|
|
2397
|
-
g && typeof g == "object" && f.merge(e, g);
|
|
2398
|
-
}
|
|
2399
|
-
} else try {
|
|
2400
|
-
const { data: g } = await I.get(t);
|
|
2401
|
-
g && typeof g == "object" && f.merge(e, g);
|
|
2402
|
-
} catch (g) {
|
|
2403
|
-
(p = e.app) != null && p.debug && console.error(g);
|
|
2404
|
-
}
|
|
2405
|
-
this.bind("log", new Ce(!!((w = e.app) != null && w.debug)));
|
|
2406
|
-
const { log: r } = this.facades, {
|
|
2407
|
-
manifest: { routes: i = {}, models: s = {} } = {},
|
|
2408
|
-
...u
|
|
2409
|
-
} = e;
|
|
2410
|
-
this.bind("config", new S(u)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user"), this.bind("error", new ht()), this.bind("route", new lt(i, this.facades.error, ((x = e.app) == null ? void 0 : x.url) ?? "")), this.bind("model", new it(s)), this.bind("auth", new Le(this)), this.emit("booting");
|
|
2411
|
-
for (const g of Object.values(this.facades))
|
|
2412
|
-
typeof g == "object" && g !== null && "boot" in g && typeof g.boot == "function" && g.boot(this);
|
|
2413
|
-
for (const g of this._plugins)
|
|
2414
|
-
typeof g.boot == "function" && g.boot(this.facades);
|
|
2415
|
-
return r.info("[Luminix] App boot completed", {
|
|
2416
|
-
config: this.facades.config.all(),
|
|
2417
|
-
plugins: this._plugins,
|
|
2418
|
-
manifest: {
|
|
2419
|
-
routes: i,
|
|
2420
|
-
models: s
|
|
2421
|
-
}
|
|
2422
|
-
}), this.emit("booted"), this.facades;
|
|
2423
|
-
}
|
|
2424
|
-
environment(...e) {
|
|
2425
|
-
return e.length > 0 ? e.includes(this.facades.config.get("app.env", "production")) : this.facades.config.get("app.env", "production");
|
|
2426
|
-
}
|
|
2427
|
-
getPlugin(e) {
|
|
2428
|
-
for (const t of this._plugins)
|
|
2429
|
-
if (t instanceof e)
|
|
2430
|
-
return t;
|
|
2431
|
-
}
|
|
2432
|
-
hasDebugModeEnabled() {
|
|
2433
|
-
return this.facades.config.get("app.debug", !1);
|
|
1480
|
+
super(...arguments);
|
|
1481
|
+
d(this, "flushReady");
|
|
2434
1482
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
1483
|
+
register() {
|
|
1484
|
+
this.registerServices(), this.registerMacros(), this.flushReady = this.app.on("ready", () => {
|
|
1485
|
+
this.app.dump("[Luminix] App boot completed");
|
|
1486
|
+
});
|
|
2437
1487
|
}
|
|
2438
|
-
|
|
2439
|
-
|
|
1488
|
+
boot() {
|
|
1489
|
+
this.app.make("model").boot(this.app);
|
|
1490
|
+
}
|
|
1491
|
+
flush() {
|
|
1492
|
+
this.flushReady && (this.flushReady(), delete this.flushReady);
|
|
1493
|
+
}
|
|
1494
|
+
registerServices() {
|
|
1495
|
+
this.app.singleton("auth", () => new me(
|
|
1496
|
+
this.app.make("config"),
|
|
1497
|
+
this.app.make("model"),
|
|
1498
|
+
this.app.make("route")
|
|
1499
|
+
)), this.app.singleton("config", () => {
|
|
1500
|
+
const e = new T(v.omit(this.app.configuration, "manifest"));
|
|
1501
|
+
return e.has("auth.user") || e.set("auth.user", null), e.lock("auth.user"), e;
|
|
1502
|
+
}), this.app.singleton("error", () => new fe()), this.app.singleton("http", () => new Ie()), this.app.singleton("log", () => {
|
|
1503
|
+
var e;
|
|
1504
|
+
return new we(((e = this.app.configuration.app) == null ? void 0 : e.debug) ?? !1);
|
|
1505
|
+
}), this.app.singleton("model", () => {
|
|
1506
|
+
var e;
|
|
1507
|
+
return new ke(
|
|
1508
|
+
((e = this.app.configuration.manifest) == null ? void 0 : e.models) ?? {}
|
|
1509
|
+
);
|
|
1510
|
+
}), this.app.singleton("route", () => {
|
|
1511
|
+
var e, i;
|
|
1512
|
+
return new Be(
|
|
1513
|
+
((e = this.app.configuration.manifest) == null ? void 0 : e.routes) ?? {},
|
|
1514
|
+
this.app.make("error"),
|
|
1515
|
+
() => this.app.make("http"),
|
|
1516
|
+
(i = this.app.configuration.app) == null ? void 0 : i.url
|
|
1517
|
+
);
|
|
1518
|
+
});
|
|
2440
1519
|
}
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
throw new window.Error("Method not implemented.");
|
|
1520
|
+
registerMacros() {
|
|
1521
|
+
this.app.macro("environment", (...e) => e.length > 0 ? e.includes(this.app.make("config").get("app.env", "production")) : this.app.make("config").get("app.env", "production")), this.app.macro("getLocale", () => this.app.make("config").get("app.locale", "en")), this.app.macro("hasDebugModeEnabled", () => this.app.make("config").get("app.debug", !1)), this.app.macro("isLocal", () => this.app.make("config").get("app.env", "production") === "local"), this.app.macro("isProduction", () => this.app.make("config").get("app.env", "production") === "production");
|
|
2444
1522
|
}
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
1523
|
+
}
|
|
1524
|
+
let R;
|
|
1525
|
+
class Pe {
|
|
1526
|
+
getFacadeAccessor() {
|
|
1527
|
+
return R || (R = new (re(ge))([
|
|
1528
|
+
Qe
|
|
1529
|
+
])), R;
|
|
2448
1530
|
}
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
throw new window.Error("Method not implemented.");
|
|
1531
|
+
down() {
|
|
1532
|
+
R && (R.flush(), R = void 0);
|
|
2452
1533
|
}
|
|
2453
1534
|
}
|
|
2454
|
-
const
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
if (y || (y = new dt()), typeof n != "string")
|
|
2458
|
-
return {
|
|
2459
|
-
boot: y.boot.bind(y),
|
|
2460
|
-
make: y.make.bind(y),
|
|
2461
|
-
plugins: y.plugins.bind(y),
|
|
2462
|
-
on: y.once.bind(y),
|
|
2463
|
-
environment: y.environment.bind(y),
|
|
2464
|
-
getPlugin: y.getPlugin.bind(y),
|
|
2465
|
-
hasDebugModeEnabled: y.hasDebugModeEnabled.bind(y),
|
|
2466
|
-
isLocal: y.isLocal.bind(y),
|
|
2467
|
-
isProduction: y.isProduction.bind(y)
|
|
2468
|
-
};
|
|
2469
|
-
if (!y.has(n))
|
|
2470
|
-
throw new Qe(n);
|
|
2471
|
-
return y.make(n);
|
|
1535
|
+
const x = M(Pe);
|
|
1536
|
+
function $(o = void 0) {
|
|
1537
|
+
return typeof o != "string" ? x : x.make(o);
|
|
2472
1538
|
}
|
|
2473
|
-
function
|
|
2474
|
-
return
|
|
1539
|
+
function ze() {
|
|
1540
|
+
return $("auth");
|
|
2475
1541
|
}
|
|
2476
|
-
function
|
|
2477
|
-
return
|
|
1542
|
+
function Xe(o) {
|
|
1543
|
+
return new b(o);
|
|
2478
1544
|
}
|
|
2479
|
-
function
|
|
2480
|
-
const
|
|
2481
|
-
return typeof
|
|
1545
|
+
function Ye(o, t) {
|
|
1546
|
+
const e = $("config");
|
|
1547
|
+
return typeof o > "u" ? e : e.get(o, t);
|
|
2482
1548
|
}
|
|
2483
|
-
function
|
|
2484
|
-
return
|
|
1549
|
+
function Ze(o, t = "default") {
|
|
1550
|
+
return o ? $().make("error").get(o, t) : $().make("error");
|
|
2485
1551
|
}
|
|
2486
|
-
function
|
|
2487
|
-
const
|
|
2488
|
-
return
|
|
1552
|
+
function et(...o) {
|
|
1553
|
+
const t = $("log");
|
|
1554
|
+
return o.length ? t.debug(...o) : t;
|
|
2489
1555
|
}
|
|
2490
|
-
function
|
|
2491
|
-
const
|
|
2492
|
-
return
|
|
1556
|
+
function tt(o) {
|
|
1557
|
+
const t = $("model");
|
|
1558
|
+
return o ? t.make(o) : t;
|
|
2493
1559
|
}
|
|
2494
|
-
function
|
|
2495
|
-
const
|
|
2496
|
-
return
|
|
1560
|
+
function st(o, t = !1) {
|
|
1561
|
+
const e = $("route");
|
|
1562
|
+
return o ? t ? e.url([o, t]) : e.url(o) : e;
|
|
2497
1563
|
}
|
|
2498
|
-
class
|
|
1564
|
+
class De {
|
|
1565
|
+
getFacadeAccessor() {
|
|
1566
|
+
return "auth";
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
const rt = M(De, x);
|
|
1570
|
+
class He {
|
|
1571
|
+
getFacadeAccessor() {
|
|
1572
|
+
return "config";
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
const it = M(He, x), nt = (o) => o instanceof ye && o.unprocessableEntity() && typeof o.json("message") == "string" && typeof o.json("errors") == "object" && o.json("errors") !== null && Object.values(o.json("errors")).every((t) => Array.isArray(t) && t.every((e) => typeof e == "string"));
|
|
1576
|
+
class Le {
|
|
1577
|
+
getFacadeAccessor() {
|
|
1578
|
+
return "error";
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
const ot = M(Le, x);
|
|
1582
|
+
class Je {
|
|
1583
|
+
getFacadeAccessor() {
|
|
1584
|
+
return "http";
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
const at = M(Je, x);
|
|
1588
|
+
class Ue {
|
|
1589
|
+
getFacadeAccessor() {
|
|
1590
|
+
return "log";
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
const ut = M(Ue, x);
|
|
1594
|
+
class Fe {
|
|
1595
|
+
getFacadeAccessor() {
|
|
1596
|
+
return "model";
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
const ht = M(Fe, x);
|
|
1600
|
+
class Ge {
|
|
1601
|
+
getFacadeAccessor() {
|
|
1602
|
+
return "route";
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
const lt = M(Ge, x);
|
|
1606
|
+
class ct {
|
|
2499
1607
|
constructor() {
|
|
2500
|
-
|
|
2501
|
-
|
|
1608
|
+
d(this, "name");
|
|
1609
|
+
d(this, "version");
|
|
2502
1610
|
}
|
|
2503
|
-
register(
|
|
1611
|
+
register(t) {
|
|
2504
1612
|
}
|
|
2505
|
-
boot(
|
|
1613
|
+
boot(t) {
|
|
2506
1614
|
}
|
|
2507
1615
|
}
|
|
2508
1616
|
export {
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
$ as
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
1617
|
+
x as App,
|
|
1618
|
+
rt as Auth,
|
|
1619
|
+
it as Config,
|
|
1620
|
+
ot as Error,
|
|
1621
|
+
at as Http,
|
|
1622
|
+
ut as Log,
|
|
1623
|
+
ht as Model,
|
|
1624
|
+
ct as Plugin,
|
|
1625
|
+
lt as Route,
|
|
1626
|
+
$ as app,
|
|
1627
|
+
ze as auth,
|
|
1628
|
+
Xe as collect,
|
|
1629
|
+
Ye as config,
|
|
1630
|
+
Ze as error,
|
|
1631
|
+
m as isModel,
|
|
1632
|
+
nt as isValidationError,
|
|
1633
|
+
et as log,
|
|
1634
|
+
tt as model,
|
|
1635
|
+
st as route
|
|
2524
1636
|
};
|