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