@luminix/core 0.0.1-beta.18 → 0.0.1-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +210 -208
- package/dist/core.umd.cjs +4 -4
- package/dist/types/Config.d.ts +3 -0
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var Ke = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var D = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
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),
|
|
7
|
-
var h = (n, e, t) => (
|
|
6
|
+
var m = (n, e, t) => je(n, typeof e != "symbol" ? e + "" : e, t), L = (n, e, t) => e.has(n) || D("Cannot " + t);
|
|
7
|
+
var h = (n, e, t) => (L(n, e, "read from private field"), t ? t.call(n) : e.get(n)), k = (n, e, t) => e.has(n) ? D("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), J = (n, e, t, r) => (L(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t), H = (n, e, t) => (L(n, e, "access private method"), t);
|
|
8
8
|
import d from "lodash";
|
|
9
|
-
import { produce as
|
|
10
|
-
import
|
|
11
|
-
var
|
|
12
|
-
class ke extends (
|
|
9
|
+
import { produce as q, isDraftable as Pe } from "immer";
|
|
10
|
+
import j, { isAxiosError as Le } from "axios";
|
|
11
|
+
var Y, Z;
|
|
12
|
+
class ke extends (Z = Error, Y = Symbol.toStringTag, Z) {
|
|
13
13
|
constructor(t) {
|
|
14
14
|
super(`[Luminix] Facade "${t}" not found`);
|
|
15
|
-
m(this,
|
|
15
|
+
m(this, Y, "FacadeNotFoundException");
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
class Qe {
|
|
@@ -93,7 +93,7 @@ class Ce {
|
|
|
93
93
|
this._debug && console.debug(...e);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
class
|
|
96
|
+
class v {
|
|
97
97
|
constructor(e) {
|
|
98
98
|
m(this, "locked", []);
|
|
99
99
|
this.bag = e, Object.freeze(this.bag);
|
|
@@ -111,14 +111,14 @@ class R {
|
|
|
111
111
|
throw new Error("Cannot set the root path when there are locked paths");
|
|
112
112
|
if (typeof t != "object" || t === null)
|
|
113
113
|
throw new TypeError("Value must be an object");
|
|
114
|
-
this.bag =
|
|
114
|
+
this.bag = q(this.bag, () => t), this.emit("change", {
|
|
115
115
|
path: e,
|
|
116
116
|
value: t,
|
|
117
117
|
type: "set"
|
|
118
118
|
});
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
|
-
this.bag =
|
|
121
|
+
this.bag = q(this.bag, (r) => {
|
|
122
122
|
d.set(r, e, t);
|
|
123
123
|
}), this.emit("change", {
|
|
124
124
|
path: e,
|
|
@@ -132,7 +132,7 @@ class R {
|
|
|
132
132
|
if (e === ".") {
|
|
133
133
|
if (this.locked.some((i) => d.has(t, i)))
|
|
134
134
|
throw new Error(`Cannot merge a path "${e}" that would override a locked path`);
|
|
135
|
-
this.bag =
|
|
135
|
+
this.bag = q(this.bag, (i) => ({
|
|
136
136
|
...i,
|
|
137
137
|
...t
|
|
138
138
|
})), this.emit("change", {
|
|
@@ -158,7 +158,7 @@ class R {
|
|
|
158
158
|
delete(e) {
|
|
159
159
|
if (this.locked.some((t) => e.startsWith(t)))
|
|
160
160
|
throw new Error(`Cannot delete a locked path "${e}"`);
|
|
161
|
-
this.bag =
|
|
161
|
+
this.bag = q(this.bag, (t) => {
|
|
162
162
|
d.unset(t, e);
|
|
163
163
|
}), this.emit("change", {
|
|
164
164
|
path: e,
|
|
@@ -172,7 +172,7 @@ class R {
|
|
|
172
172
|
this.locked.push(e);
|
|
173
173
|
}
|
|
174
174
|
clone() {
|
|
175
|
-
return new
|
|
175
|
+
return new v(this.bag);
|
|
176
176
|
}
|
|
177
177
|
all() {
|
|
178
178
|
return this.bag;
|
|
@@ -191,15 +191,15 @@ class R {
|
|
|
191
191
|
emit(e, t) {
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
var e, t, r,
|
|
194
|
+
function A(n) {
|
|
195
|
+
var e, t, r, Ae, s;
|
|
196
196
|
return s = class extends (t = n, e = Symbol.toStringTag, t) {
|
|
197
197
|
constructor(...a) {
|
|
198
198
|
super(...a);
|
|
199
|
-
|
|
199
|
+
k(this, r);
|
|
200
200
|
m(this, "emitter");
|
|
201
201
|
m(this, e, n.name);
|
|
202
|
-
this.emitter =
|
|
202
|
+
this.emitter = H(this, r, Ae).call(this);
|
|
203
203
|
}
|
|
204
204
|
on(a, f) {
|
|
205
205
|
if (typeof a != "string")
|
|
@@ -227,7 +227,7 @@ function S(n) {
|
|
|
227
227
|
source: this
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
-
}, r = new WeakSet(),
|
|
230
|
+
}, r = new WeakSet(), Ae = function() {
|
|
231
231
|
return {
|
|
232
232
|
emit(a, f) {
|
|
233
233
|
for (let p = 0, w = this.events[a] || [], x = w.length; p < x; p++)
|
|
@@ -244,41 +244,41 @@ function S(n) {
|
|
|
244
244
|
};
|
|
245
245
|
}, s;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function W(...n) {
|
|
248
248
|
return n.reduce((e, t) => e.flatMap((r) => t.map((i) => [r, i].flat())));
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function S(n) {
|
|
251
251
|
return !(typeof n != "object" || n === null || !Reflect.has(n, "constructor") || Reflect.get(n.constructor, "name") !== "Collection");
|
|
252
252
|
}
|
|
253
|
-
var
|
|
254
|
-
class b extends (
|
|
253
|
+
var z, O;
|
|
254
|
+
class b extends (O = Error, z = Symbol.toStringTag, O) {
|
|
255
255
|
constructor() {
|
|
256
256
|
super("[Luminix] Method not implemented.");
|
|
257
|
-
m(this,
|
|
257
|
+
m(this, z, "MethodNotImplementedException");
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function c(n = [], e =
|
|
260
|
+
function c(n = [], e = Q) {
|
|
261
261
|
if (!Array.isArray(n))
|
|
262
262
|
throw new TypeError("collect() expects an array");
|
|
263
|
-
return new (
|
|
263
|
+
return new (A(e))([...n]);
|
|
264
264
|
}
|
|
265
|
-
const
|
|
265
|
+
const T = (n) => {
|
|
266
266
|
n.emit("change", {
|
|
267
267
|
items: n.all()
|
|
268
268
|
});
|
|
269
|
-
},
|
|
270
|
-
var
|
|
271
|
-
class
|
|
269
|
+
}, K = (n, e) => Array.isArray(n) ? n[e] ?? null : n.get(e);
|
|
270
|
+
var ee, te, o;
|
|
271
|
+
class Q {
|
|
272
272
|
constructor(e = []) {
|
|
273
273
|
// [Symbol.toStringTag] = 'Collection';
|
|
274
|
-
|
|
275
|
-
m(this,
|
|
276
|
-
|
|
274
|
+
k(this, o);
|
|
275
|
+
m(this, ee, "Collection");
|
|
276
|
+
J(this, o, e);
|
|
277
277
|
}
|
|
278
278
|
get items() {
|
|
279
279
|
return [...h(this, o)];
|
|
280
280
|
}
|
|
281
|
-
[(
|
|
281
|
+
[(te = Symbol.iterator, ee = Symbol.toStringTag, te)]() {
|
|
282
282
|
return h(this, o)[Symbol.iterator]();
|
|
283
283
|
}
|
|
284
284
|
all() {
|
|
@@ -314,7 +314,7 @@ class P {
|
|
|
314
314
|
return h(this, o).forEach((r, i) => {
|
|
315
315
|
if (typeof r != "string")
|
|
316
316
|
throw new TypeError("The `combine` method expects the keys to be strings");
|
|
317
|
-
t[r] =
|
|
317
|
+
t[r] = K(e, i);
|
|
318
318
|
}), t;
|
|
319
319
|
}
|
|
320
320
|
concat(e) {
|
|
@@ -355,7 +355,7 @@ class P {
|
|
|
355
355
|
}, {});
|
|
356
356
|
}
|
|
357
357
|
crossJoin(...e) {
|
|
358
|
-
return c(
|
|
358
|
+
return c(W(
|
|
359
359
|
h(this, o),
|
|
360
360
|
...e.map((t) => Array.isArray(t) ? t : t.all())
|
|
361
361
|
));
|
|
@@ -392,7 +392,7 @@ class P {
|
|
|
392
392
|
}
|
|
393
393
|
eachSpread(e) {
|
|
394
394
|
for (const t of this) {
|
|
395
|
-
if (!Array.isArray(t) &&
|
|
395
|
+
if (!Array.isArray(t) && !S(t))
|
|
396
396
|
throw new TypeError("The items in the collection must be arrays or collections");
|
|
397
397
|
const r = Array.isArray(t) ? t : t.all();
|
|
398
398
|
if (e(...r) === !1)
|
|
@@ -457,7 +457,7 @@ class P {
|
|
|
457
457
|
return c(h(this, o).flatMap((t, r) => e(t, r, this)));
|
|
458
458
|
}
|
|
459
459
|
forget(e) {
|
|
460
|
-
return h(this, o).splice(e, 1),
|
|
460
|
+
return h(this, o).splice(e, 1), T(this), this;
|
|
461
461
|
}
|
|
462
462
|
forPage(e, t) {
|
|
463
463
|
return c(h(this, o).slice((e - 1) * t, e * t));
|
|
@@ -477,7 +477,7 @@ class P {
|
|
|
477
477
|
}
|
|
478
478
|
return [String(i[a])];
|
|
479
479
|
});
|
|
480
|
-
return
|
|
480
|
+
return W(...u).forEach((a) => {
|
|
481
481
|
const f = Array.isArray(a) ? a.join(".") : a;
|
|
482
482
|
d.set(r, f, [
|
|
483
483
|
...d.get(r, f, []),
|
|
@@ -538,7 +538,7 @@ class P {
|
|
|
538
538
|
}
|
|
539
539
|
mapSpread(e) {
|
|
540
540
|
return c(h(this, o).map((t) => {
|
|
541
|
-
if (!Array.isArray(t) &&
|
|
541
|
+
if (!Array.isArray(t) && !S(t))
|
|
542
542
|
throw new TypeError("The items in the collection must be arrays or collections");
|
|
543
543
|
const r = Array.isArray(t) ? t : t.all();
|
|
544
544
|
return e(...r);
|
|
@@ -566,7 +566,7 @@ class P {
|
|
|
566
566
|
median(e) {
|
|
567
567
|
if (typeof e == "string") {
|
|
568
568
|
const i = this.pluck(e).sort(), s = Math.floor(i.count() / 2);
|
|
569
|
-
return i.count() % 2 === 0 ? c([
|
|
569
|
+
return i.count() % 2 === 0 ? c([K(i, s - 1), K(i, s)]).avg() : K(i, s);
|
|
570
570
|
}
|
|
571
571
|
const t = h(this, o).toSorted(), r = Math.floor(t.length / 2);
|
|
572
572
|
return t.length % 2 === 0 ? c([t[r - 1], t[r]]).avg() : t[r] ?? null;
|
|
@@ -612,10 +612,10 @@ class P {
|
|
|
612
612
|
}
|
|
613
613
|
pipeThrough(e) {
|
|
614
614
|
return e.reduce((t, r) => {
|
|
615
|
-
if (
|
|
615
|
+
if (!S(t) && !Array.isArray(t))
|
|
616
616
|
throw new TypeError("The pipeline expects the carry to be a collection or an array");
|
|
617
617
|
return r(
|
|
618
|
-
|
|
618
|
+
S(t) ? t : c(t)
|
|
619
619
|
);
|
|
620
620
|
}, this);
|
|
621
621
|
}
|
|
@@ -624,22 +624,22 @@ class P {
|
|
|
624
624
|
}
|
|
625
625
|
pop(e = 1) {
|
|
626
626
|
const t = h(this, o).splice(h(this, o).length - e, e);
|
|
627
|
-
return
|
|
627
|
+
return T(this), e === 1 ? t[0] ?? null : c(t);
|
|
628
628
|
}
|
|
629
629
|
prepend(e) {
|
|
630
630
|
const t = h(this, o).unshift(e);
|
|
631
|
-
return
|
|
631
|
+
return T(this), t;
|
|
632
632
|
}
|
|
633
633
|
pull(e) {
|
|
634
634
|
const t = h(this, o).splice(e, 1)[0] ?? null;
|
|
635
|
-
return
|
|
635
|
+
return T(this), t;
|
|
636
636
|
}
|
|
637
637
|
push(...e) {
|
|
638
638
|
const t = h(this, o).push(...e);
|
|
639
|
-
return
|
|
639
|
+
return T(this), t;
|
|
640
640
|
}
|
|
641
641
|
put(e, t) {
|
|
642
|
-
return h(this, o).splice(e, 1, t),
|
|
642
|
+
return h(this, o).splice(e, 1, t), T(this), this;
|
|
643
643
|
}
|
|
644
644
|
random(e = 1) {
|
|
645
645
|
if (h(this, o).length < e)
|
|
@@ -675,7 +675,7 @@ class P {
|
|
|
675
675
|
}
|
|
676
676
|
shift(e = 1) {
|
|
677
677
|
const t = h(this, o).splice(0, e);
|
|
678
|
-
return
|
|
678
|
+
return T(this), e === 1 ? t[0] ?? null : c(t);
|
|
679
679
|
}
|
|
680
680
|
shuffle() {
|
|
681
681
|
return c(d.shuffle(h(this, o)));
|
|
@@ -750,7 +750,7 @@ class P {
|
|
|
750
750
|
}
|
|
751
751
|
splice(e, t, ...r) {
|
|
752
752
|
const i = t === void 0 ? h(this, o).length : t, s = h(this, o).splice(e, i, ...r);
|
|
753
|
-
return
|
|
753
|
+
return T(this), c(s);
|
|
754
754
|
}
|
|
755
755
|
split(e) {
|
|
756
756
|
const t = [];
|
|
@@ -804,7 +804,7 @@ class P {
|
|
|
804
804
|
transform(e) {
|
|
805
805
|
for (const [t, r] of h(this, o).entries())
|
|
806
806
|
h(this, o).splice(t, 1, e(r, t, this));
|
|
807
|
-
return
|
|
807
|
+
return T(this), this;
|
|
808
808
|
}
|
|
809
809
|
unique(e) {
|
|
810
810
|
return c(
|
|
@@ -918,18 +918,18 @@ class P {
|
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
920
|
o = new WeakMap();
|
|
921
|
-
const
|
|
922
|
-
var
|
|
923
|
-
class
|
|
921
|
+
const C = A(Q);
|
|
922
|
+
var re, se;
|
|
923
|
+
class G extends (se = Q, re = Symbol.toStringTag, se) {
|
|
924
924
|
constructor() {
|
|
925
925
|
super(...arguments);
|
|
926
|
-
m(this,
|
|
926
|
+
m(this, re, "Collection");
|
|
927
927
|
}
|
|
928
928
|
intersect(t) {
|
|
929
929
|
return this.filter((r) => t.some((i) => i.getKey() === r.getKey()));
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
|
-
const
|
|
932
|
+
const B = (...n) => {
|
|
933
933
|
const e = new URLSearchParams();
|
|
934
934
|
return n.forEach((t) => {
|
|
935
935
|
const [, ...r] = t.split("?");
|
|
@@ -938,18 +938,18 @@ const v = (...n) => {
|
|
|
938
938
|
});
|
|
939
939
|
}), e;
|
|
940
940
|
};
|
|
941
|
-
var
|
|
942
|
-
class
|
|
941
|
+
var ie, ne;
|
|
942
|
+
class Ue extends (ne = Error, ie = Symbol.toStringTag, ne) {
|
|
943
943
|
constructor(t) {
|
|
944
944
|
super(`[Luminix] Model "${t}" does not have a primary key`);
|
|
945
|
-
m(this,
|
|
945
|
+
m(this, ie, "ModelWithoutPrimaryKeyException");
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
|
-
const
|
|
948
|
+
const De = A(v);
|
|
949
949
|
class Je {
|
|
950
950
|
constructor(e, t, r = {}) {
|
|
951
951
|
m(this, "bag");
|
|
952
|
-
this.facades = e, this.abstract = t, this.query = r, this.bag = new
|
|
952
|
+
this.facades = e, this.abstract = t, this.query = r, this.bag = new De(r), this.bag.on("change", () => {
|
|
953
953
|
this.emit("change", {
|
|
954
954
|
data: this.bag
|
|
955
955
|
});
|
|
@@ -1048,23 +1048,23 @@ class Je {
|
|
|
1048
1048
|
class: this.abstract,
|
|
1049
1049
|
model: l
|
|
1050
1050
|
}), l;
|
|
1051
|
-
}),
|
|
1051
|
+
}), G);
|
|
1052
1052
|
if (t) {
|
|
1053
1053
|
const [u] = t.split("?");
|
|
1054
1054
|
return {
|
|
1055
1055
|
...r,
|
|
1056
1056
|
data: s,
|
|
1057
1057
|
links: {
|
|
1058
|
-
first: `${u}?${
|
|
1059
|
-
last: `${u}?${
|
|
1060
|
-
next: r.links.next && `${u}?${
|
|
1061
|
-
prev: r.links.prev && `${u}?${
|
|
1058
|
+
first: `${u}?${B(t, r.links.first).toString()}`,
|
|
1059
|
+
last: `${u}?${B(t, r.links.last).toString()}`,
|
|
1060
|
+
next: r.links.next && `${u}?${B(t, r.links.next).toString()}`,
|
|
1061
|
+
prev: r.links.prev && `${u}?${B(t, r.links.prev).toString()}`
|
|
1062
1062
|
},
|
|
1063
1063
|
meta: {
|
|
1064
1064
|
...r.meta,
|
|
1065
1065
|
links: r.meta.links.map((l) => ({
|
|
1066
1066
|
...l,
|
|
1067
|
-
url: l.url && `${u}?${
|
|
1067
|
+
url: l.url && `${u}?${B(t, l.url).toString()}`
|
|
1068
1068
|
}))
|
|
1069
1069
|
}
|
|
1070
1070
|
};
|
|
@@ -1096,7 +1096,7 @@ class Je {
|
|
|
1096
1096
|
async find(e) {
|
|
1097
1097
|
const t = this.facades.model.schema(this.abstract).primaryKey;
|
|
1098
1098
|
if (!t)
|
|
1099
|
-
throw new
|
|
1099
|
+
throw new Ue(this.abstract);
|
|
1100
1100
|
const r = await this.where(t, e).limit(1).exec(1);
|
|
1101
1101
|
return this.emit("success", {
|
|
1102
1102
|
response: r,
|
|
@@ -1111,7 +1111,7 @@ class Je {
|
|
|
1111
1111
|
i.map((l) => this.limit(e).exec(l))
|
|
1112
1112
|
), u = c(
|
|
1113
1113
|
s.reduce((l, a) => (l.push(...a.data), l), t.data).all(),
|
|
1114
|
-
|
|
1114
|
+
G
|
|
1115
1115
|
);
|
|
1116
1116
|
return this.emit("success", {
|
|
1117
1117
|
response: {
|
|
@@ -1122,42 +1122,42 @@ class Je {
|
|
|
1122
1122
|
}), u;
|
|
1123
1123
|
}
|
|
1124
1124
|
}
|
|
1125
|
-
const He =
|
|
1126
|
-
var
|
|
1127
|
-
class
|
|
1125
|
+
const He = A(Je);
|
|
1126
|
+
var oe, he;
|
|
1127
|
+
class $ extends (he = Error, oe = Symbol.toStringTag, he) {
|
|
1128
1128
|
constructor(t) {
|
|
1129
1129
|
super(`[Luminix] Expected ${t} to be reducible.`);
|
|
1130
|
-
m(this,
|
|
1130
|
+
m(this, oe, "NotReducibleException");
|
|
1131
1131
|
}
|
|
1132
1132
|
}
|
|
1133
|
-
var
|
|
1134
|
-
class M extends (
|
|
1133
|
+
var ue, ae;
|
|
1134
|
+
class M extends (ae = TypeError, ue = Symbol.toStringTag, ae) {
|
|
1135
1135
|
constructor(t, r = "Model") {
|
|
1136
1136
|
super(`[Luminix] "${t}" expects ${r}`);
|
|
1137
|
-
m(this,
|
|
1137
|
+
m(this, ue, "NotModelException");
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
|
-
var
|
|
1141
|
-
class We extends (
|
|
1140
|
+
var le, ce;
|
|
1141
|
+
class We extends (ce = Error, le = Symbol.toStringTag, ce) {
|
|
1142
1142
|
constructor(t, r, i, s) {
|
|
1143
1143
|
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}".`);
|
|
1144
|
-
m(this,
|
|
1144
|
+
m(this, le, "NoInverseRelationException");
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
var
|
|
1148
|
-
class Ge extends (
|
|
1147
|
+
var de, fe;
|
|
1148
|
+
class Ge extends (fe = Error, de = Symbol.toStringTag, fe) {
|
|
1149
1149
|
constructor(t) {
|
|
1150
1150
|
super(`[Luminix] Relation "${t}" is not supported`);
|
|
1151
|
-
m(this,
|
|
1151
|
+
m(this, de, "UnsupportedRelationException");
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
function E(n) {
|
|
1155
1155
|
return typeof n == "object" && n !== null && n.__isModel === !0;
|
|
1156
1156
|
}
|
|
1157
|
-
class
|
|
1157
|
+
class P {
|
|
1158
1158
|
constructor(e, t, r, i = null) {
|
|
1159
1159
|
m(this, "unsubscribeQuery", null);
|
|
1160
|
-
if (this.meta = e, this.facades = t, this.parent = r, this.items = i, i !== null && !E(i) && !(
|
|
1160
|
+
if (this.meta = e, this.facades = t, this.parent = r, this.items = i, i !== null && !E(i) && !(S(i) && i.every(E)))
|
|
1161
1161
|
throw new M("Relation.constructor()", "Model, Collection<Model> or null");
|
|
1162
1162
|
}
|
|
1163
1163
|
make(e) {
|
|
@@ -1180,7 +1180,7 @@ class F {
|
|
|
1180
1180
|
guessInverseRelation() {
|
|
1181
1181
|
const { relations: e } = this.getRelated().getSchema();
|
|
1182
1182
|
if (typeof this.facades.model.guessInverseRelation != "function")
|
|
1183
|
-
throw new
|
|
1183
|
+
throw new $("ModelFacade");
|
|
1184
1184
|
const t = this.getType(), r = this.facades.model.guessInverseRelation({
|
|
1185
1185
|
HasOne: ["BelongsTo"],
|
|
1186
1186
|
HasMany: ["BelongsTo"],
|
|
@@ -1201,9 +1201,9 @@ class F {
|
|
|
1201
1201
|
throw new We(this.parent.getType(), t, this.getRelated().getSchemaName(), r[t].join(" or "));
|
|
1202
1202
|
}
|
|
1203
1203
|
set(e) {
|
|
1204
|
-
if (e !== null && !E(e) && !(
|
|
1204
|
+
if (e !== null && !E(e) && !(S(e) && e.every(E)))
|
|
1205
1205
|
throw new M("Relation.set()", "Model, Collection<Model> or null");
|
|
1206
|
-
!this.items || E(this.items) ? this.items = e :
|
|
1206
|
+
!this.items || E(this.items) ? this.items = e : S(e) && this.items.splice(0, this.items.count(), ...e);
|
|
1207
1207
|
}
|
|
1208
1208
|
getForeignKey() {
|
|
1209
1209
|
return this.meta.foreignKey;
|
|
@@ -1236,7 +1236,7 @@ class F {
|
|
|
1236
1236
|
return E(this.items);
|
|
1237
1237
|
}
|
|
1238
1238
|
isMultiple() {
|
|
1239
|
-
return
|
|
1239
|
+
return S(this.items);
|
|
1240
1240
|
}
|
|
1241
1241
|
getParent() {
|
|
1242
1242
|
return this.parent;
|
|
@@ -1281,11 +1281,11 @@ class F {
|
|
|
1281
1281
|
// return this.query().find(id);
|
|
1282
1282
|
// }
|
|
1283
1283
|
}
|
|
1284
|
-
var
|
|
1285
|
-
class
|
|
1284
|
+
var me, pe;
|
|
1285
|
+
class Re extends (pe = Error, me = Symbol.toStringTag, pe) {
|
|
1286
1286
|
constructor(t, r) {
|
|
1287
1287
|
super(`[Luminix] Model "${t}" must be persisted before calling "${r}"`);
|
|
1288
|
-
m(this,
|
|
1288
|
+
m(this, me, "ModelNotPersistedException");
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
1291
|
function Ve(n, e) {
|
|
@@ -1293,7 +1293,7 @@ function Ve(n, e) {
|
|
|
1293
1293
|
r = Symbol.toStringTag;
|
|
1294
1294
|
class t {
|
|
1295
1295
|
constructor(s = {}) {
|
|
1296
|
-
m(this, "_attributes", new
|
|
1296
|
+
m(this, "_attributes", new v({}));
|
|
1297
1297
|
m(this, "_original", {});
|
|
1298
1298
|
m(this, "_relations", {});
|
|
1299
1299
|
m(this, "_changedKeys", []);
|
|
@@ -1314,7 +1314,7 @@ function Ve(n, e) {
|
|
|
1314
1314
|
return;
|
|
1315
1315
|
const u = n.make("model").relationMap({}, e);
|
|
1316
1316
|
Object.entries(s).forEach(([l, a]) => {
|
|
1317
|
-
const { type: f } = a, p = f in u ? u[f] :
|
|
1317
|
+
const { type: f } = a, p = f in u ? u[f] : P;
|
|
1318
1318
|
this._relations[l] = new p(
|
|
1319
1319
|
{ name: l, ...a },
|
|
1320
1320
|
n.make(),
|
|
@@ -1446,13 +1446,13 @@ function Ve(n, e) {
|
|
|
1446
1446
|
s in this.casts && (u = this.cast(u, this.casts[s]));
|
|
1447
1447
|
const l = n.make("model")[`model${d.upperFirst(d.camelCase(e))}Get${d.upperFirst(d.camelCase(s))}Attribute`];
|
|
1448
1448
|
if (typeof l != "function")
|
|
1449
|
-
throw new
|
|
1449
|
+
throw new $("ModelFacade");
|
|
1450
1450
|
return l.bind(n.make("model"))(u, this);
|
|
1451
1451
|
}
|
|
1452
1452
|
setAttribute(s, u) {
|
|
1453
1453
|
const l = n.make("model")[`model${d.upperFirst(d.camelCase(e))}Set${d.upperFirst(d.camelCase(s))}Attribute`];
|
|
1454
1454
|
if (typeof l != "function")
|
|
1455
|
-
throw new
|
|
1455
|
+
throw new $("ModelFacade");
|
|
1456
1456
|
const a = l.bind(n.make("model"))(
|
|
1457
1457
|
this.mutate(u, this.casts[s]),
|
|
1458
1458
|
this
|
|
@@ -1482,7 +1482,7 @@ function Ve(n, e) {
|
|
|
1482
1482
|
const u = d.pick(s, this.fillable), l = Object.entries(u).reduce((a, [f, p]) => {
|
|
1483
1483
|
const w = n.make("model")[`model${d.upperFirst(d.camelCase(e))}Set${d.upperFirst(d.camelCase(f))}Attribute`];
|
|
1484
1484
|
if (typeof w != "function")
|
|
1485
|
-
throw new
|
|
1485
|
+
throw new $("ModelFacade");
|
|
1486
1486
|
return a[f] = w.bind(n.make("model"))(
|
|
1487
1487
|
this.mutate(p, this.casts[f]),
|
|
1488
1488
|
this
|
|
@@ -1511,7 +1511,7 @@ function Ve(n, e) {
|
|
|
1511
1511
|
toJson() {
|
|
1512
1512
|
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`];
|
|
1513
1513
|
if (typeof u != "function")
|
|
1514
|
-
throw new
|
|
1514
|
+
throw new $("ModelFacade");
|
|
1515
1515
|
return u.bind(n.make("model"))({
|
|
1516
1516
|
...this.attributes,
|
|
1517
1517
|
...s
|
|
@@ -1560,7 +1560,7 @@ function Ve(n, e) {
|
|
|
1560
1560
|
}
|
|
1561
1561
|
async refresh() {
|
|
1562
1562
|
if (!this.exists)
|
|
1563
|
-
throw new
|
|
1563
|
+
throw new Re(e, "refresh");
|
|
1564
1564
|
const { data: s } = await n.make("route").call(
|
|
1565
1565
|
this.getRouteForRefresh(),
|
|
1566
1566
|
{ errorBag: this.getErrorBag("fetch") }
|
|
@@ -1760,7 +1760,7 @@ function Ve(n, e) {
|
|
|
1760
1760
|
throw new b();
|
|
1761
1761
|
}
|
|
1762
1762
|
}
|
|
1763
|
-
return m(t, "name", d.upperFirst(d.camelCase(e))),
|
|
1763
|
+
return m(t, "name", d.upperFirst(d.camelCase(e))), A(t);
|
|
1764
1764
|
}
|
|
1765
1765
|
function Xe(n, e, t) {
|
|
1766
1766
|
var r, i;
|
|
@@ -1786,7 +1786,7 @@ function Xe(n, e, t) {
|
|
|
1786
1786
|
if (n.model.hasReducer(`model${l.constructor.name}Get${d.upperFirst(a)}Attribute`)) {
|
|
1787
1787
|
const p = n.model[`model${l.constructor.name}Get${d.upperFirst(a)}Attribute`];
|
|
1788
1788
|
if (typeof p != "function")
|
|
1789
|
-
throw new
|
|
1789
|
+
throw new $("ModelFacade");
|
|
1790
1790
|
return p.bind(n.model)(void 0, l);
|
|
1791
1791
|
}
|
|
1792
1792
|
return Reflect.get(l, a);
|
|
@@ -1799,14 +1799,14 @@ function Xe(n, e, t) {
|
|
|
1799
1799
|
}
|
|
1800
1800
|
};
|
|
1801
1801
|
}
|
|
1802
|
-
var
|
|
1803
|
-
class Ye extends (
|
|
1802
|
+
var ge, ye;
|
|
1803
|
+
class Ye extends (ye = Error, ge = Symbol.toStringTag, ye) {
|
|
1804
1804
|
constructor(t, r) {
|
|
1805
1805
|
super(`[Luminix] Cannot create reducer '${t}' on '${r}' as it is a reserved property`);
|
|
1806
|
-
m(this,
|
|
1806
|
+
m(this, ge, "ReducerOverrideException");
|
|
1807
1807
|
}
|
|
1808
1808
|
}
|
|
1809
|
-
function
|
|
1809
|
+
function ve(n) {
|
|
1810
1810
|
return class extends n {
|
|
1811
1811
|
constructor(...t) {
|
|
1812
1812
|
super(...t);
|
|
@@ -1815,7 +1815,7 @@ function Ae(n) {
|
|
|
1815
1815
|
get(r, i, s) {
|
|
1816
1816
|
return typeof i == "symbol" || i in r ? Reflect.get(r, i, s) : (u, ...l) => {
|
|
1817
1817
|
const { [i]: a = c() } = r.reducers;
|
|
1818
|
-
return Pe(u) ?
|
|
1818
|
+
return Pe(u) ? q(u, (f) => a.sortBy("priority").reduce((p, w) => w.callback(p, ...l), f)) : a.sortBy("priority").reduce((f, p) => p.callback(f, ...l), u);
|
|
1819
1819
|
};
|
|
1820
1820
|
}
|
|
1821
1821
|
});
|
|
@@ -1843,21 +1843,21 @@ function Ae(n) {
|
|
|
1843
1843
|
}
|
|
1844
1844
|
};
|
|
1845
1845
|
}
|
|
1846
|
-
var
|
|
1847
|
-
class
|
|
1846
|
+
var we, be;
|
|
1847
|
+
class V extends (be = Error, we = Symbol.toStringTag, be) {
|
|
1848
1848
|
constructor(t) {
|
|
1849
1849
|
super(`[Luminix] Model "${t}" not found`);
|
|
1850
|
-
m(this,
|
|
1850
|
+
m(this, we, "ModelNotFoundException");
|
|
1851
1851
|
}
|
|
1852
1852
|
}
|
|
1853
|
-
var
|
|
1854
|
-
class
|
|
1853
|
+
var Ee, xe;
|
|
1854
|
+
class I extends (xe = TypeError, Ee = Symbol.toStringTag, xe) {
|
|
1855
1855
|
constructor(t, r, i) {
|
|
1856
1856
|
super(`[Luminix] "${t}" expects a related model of type "${r}". Received "${i}" instead.`);
|
|
1857
|
-
m(this,
|
|
1857
|
+
m(this, Ee, "ModelInvalidRelatedTypeException");
|
|
1858
1858
|
}
|
|
1859
1859
|
}
|
|
1860
|
-
class
|
|
1860
|
+
class Ne extends P {
|
|
1861
1861
|
constructor(e, t, r, i = null) {
|
|
1862
1862
|
if (!E(i) && i !== null)
|
|
1863
1863
|
throw new M("BelongsTo.constructor()", "Model or null");
|
|
@@ -1880,9 +1880,9 @@ class Re extends F {
|
|
|
1880
1880
|
if (!E(e))
|
|
1881
1881
|
throw new M("BelongsTo.associate()");
|
|
1882
1882
|
if (e.getType() !== this.getRelated().getSchemaName())
|
|
1883
|
-
throw new
|
|
1883
|
+
throw new I("BelongsTo.associate()", this.getRelated().getSchemaName(), e.getType());
|
|
1884
1884
|
if (!e.exists)
|
|
1885
|
-
throw new
|
|
1885
|
+
throw new Re(this.getRelated().getSchemaName(), "save");
|
|
1886
1886
|
return this.parent.update({
|
|
1887
1887
|
[this.getForeignKey()]: e.getKey()
|
|
1888
1888
|
});
|
|
@@ -1893,9 +1893,9 @@ class Re extends F {
|
|
|
1893
1893
|
});
|
|
1894
1894
|
}
|
|
1895
1895
|
}
|
|
1896
|
-
class
|
|
1896
|
+
class Be extends P {
|
|
1897
1897
|
constructor(e, t, r, i = null) {
|
|
1898
|
-
if (i !== null && !(i instanceof
|
|
1898
|
+
if (i !== null && !(i instanceof C && i.every(E)))
|
|
1899
1899
|
throw new M("BelongsToMany.constructor()", "Collection<Model> or null");
|
|
1900
1900
|
super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
|
|
1901
1901
|
}
|
|
@@ -1998,7 +1998,7 @@ class ve extends F {
|
|
|
1998
1998
|
this.items ? this.items.splice(0, this.items.count(), ...r) : this.items = r;
|
|
1999
1999
|
}
|
|
2000
2000
|
}
|
|
2001
|
-
class
|
|
2001
|
+
class U extends P {
|
|
2002
2002
|
query() {
|
|
2003
2003
|
const e = super.query(), t = this.guessInverseRelation();
|
|
2004
2004
|
return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
|
|
@@ -2007,11 +2007,11 @@ class k extends F {
|
|
|
2007
2007
|
if (!E(e))
|
|
2008
2008
|
throw new M("HasOneOrMany.saveQuietly()");
|
|
2009
2009
|
if (e.getType() !== this.getRelated().getSchemaName())
|
|
2010
|
-
throw new
|
|
2010
|
+
throw new I("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
|
|
2011
2011
|
e.setAttribute(this.getForeignKey(), this.parent.getKey()), await e.save();
|
|
2012
2012
|
}
|
|
2013
2013
|
}
|
|
2014
|
-
class Ze extends
|
|
2014
|
+
class Ze extends U {
|
|
2015
2015
|
constructor(e, t, r, i = null) {
|
|
2016
2016
|
if (!E(i) && i !== null)
|
|
2017
2017
|
throw new M("HasOne.constructor()", "Model or null");
|
|
@@ -2030,9 +2030,9 @@ class Ze extends k {
|
|
|
2030
2030
|
await this.saveQuietly(e), this.items = e;
|
|
2031
2031
|
}
|
|
2032
2032
|
}
|
|
2033
|
-
class ze extends
|
|
2033
|
+
class ze extends U {
|
|
2034
2034
|
constructor(e, t, r, i = null) {
|
|
2035
|
-
if (i !== null && !(i instanceof
|
|
2035
|
+
if (i !== null && !(i instanceof C && i.every(E)))
|
|
2036
2036
|
throw new M("HasMany.constructor()", "Collection<Model> or null");
|
|
2037
2037
|
super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
|
|
2038
2038
|
}
|
|
@@ -2058,7 +2058,7 @@ class ze extends k {
|
|
|
2058
2058
|
if (!Array.isArray(e) || !e.every(E))
|
|
2059
2059
|
throw new M("HasMany.saveManyQuietly()", "Model[]");
|
|
2060
2060
|
if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
|
|
2061
|
-
throw new
|
|
2061
|
+
throw new I("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
|
|
2062
2062
|
await Promise.all(e.map((t) => (t.setAttribute(this.getForeignKey(), this.parent.getKey()), t.save())));
|
|
2063
2063
|
}
|
|
2064
2064
|
async saveMany(e) {
|
|
@@ -2070,7 +2070,7 @@ class ze extends k {
|
|
|
2070
2070
|
await this.saveQuietly(e), this.items === null ? this.items = await this.all() : this.items.push(e);
|
|
2071
2071
|
}
|
|
2072
2072
|
}
|
|
2073
|
-
class
|
|
2073
|
+
class qe extends U {
|
|
2074
2074
|
query() {
|
|
2075
2075
|
const e = this.getRelated().query();
|
|
2076
2076
|
e.once("success", (r) => {
|
|
@@ -2083,14 +2083,14 @@ class Ne extends k {
|
|
|
2083
2083
|
if (!E(e))
|
|
2084
2084
|
throw new M("MorphOneOrMany.saveQuietly()");
|
|
2085
2085
|
if (e.getType() !== this.getRelated().getSchemaName())
|
|
2086
|
-
throw new
|
|
2086
|
+
throw new I("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
|
|
2087
2087
|
const t = this.guessInverseRelation();
|
|
2088
2088
|
e.setAttribute(t + "_id", this.parent.getKey()), e.setAttribute(t + "_type", this.parent.getType()), await e.save();
|
|
2089
2089
|
}
|
|
2090
2090
|
}
|
|
2091
|
-
class Oe extends
|
|
2091
|
+
class Oe extends qe {
|
|
2092
2092
|
constructor(e, t, r, i = null) {
|
|
2093
|
-
if (i !== null && !(i instanceof
|
|
2093
|
+
if (i !== null && !(i instanceof C && i.every(E)))
|
|
2094
2094
|
throw new M("MorphMany.constructor()", "Collection<Model> or null");
|
|
2095
2095
|
super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
|
|
2096
2096
|
}
|
|
@@ -2116,7 +2116,7 @@ class Oe extends Ne {
|
|
|
2116
2116
|
if (!Array.isArray(e) || !e.every(E))
|
|
2117
2117
|
throw new M("MorphMany.saveManyQuietly()");
|
|
2118
2118
|
if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
|
|
2119
|
-
throw new
|
|
2119
|
+
throw new I("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
|
|
2120
2120
|
await Promise.all(e.map((t) => (t.setAttribute(this.getName() + "_id", this.parent.getKey()), t.setAttribute(this.getName() + "_type", this.parent.getType()), t.save())));
|
|
2121
2121
|
}
|
|
2122
2122
|
async save(e) {
|
|
@@ -2128,7 +2128,7 @@ class Oe extends Ne {
|
|
|
2128
2128
|
this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = t;
|
|
2129
2129
|
}
|
|
2130
2130
|
}
|
|
2131
|
-
class et extends
|
|
2131
|
+
class et extends qe {
|
|
2132
2132
|
constructor(e, t, r, i = null) {
|
|
2133
2133
|
if (super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i, i !== null && !E(i))
|
|
2134
2134
|
throw new M("MorphOne.constructor()", "Model or null");
|
|
@@ -2146,7 +2146,7 @@ class et extends Ne {
|
|
|
2146
2146
|
await this.saveQuietly(e), this.items = e;
|
|
2147
2147
|
}
|
|
2148
2148
|
}
|
|
2149
|
-
class tt extends
|
|
2149
|
+
class tt extends Ne {
|
|
2150
2150
|
getRelated() {
|
|
2151
2151
|
return this.facades.model.make(
|
|
2152
2152
|
this.parent.getAttribute(this.getName() + "_type")
|
|
@@ -2175,7 +2175,7 @@ class tt extends Re {
|
|
|
2175
2175
|
});
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
|
-
class rt extends
|
|
2178
|
+
class rt extends Be {
|
|
2179
2179
|
constructor(e, t, r, i = null) {
|
|
2180
2180
|
super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
|
|
2181
2181
|
}
|
|
@@ -2184,27 +2184,27 @@ class rt extends ve {
|
|
|
2184
2184
|
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;
|
|
2185
2185
|
}
|
|
2186
2186
|
}
|
|
2187
|
-
var
|
|
2188
|
-
|
|
2187
|
+
var Me;
|
|
2188
|
+
Me = Symbol.toStringTag;
|
|
2189
2189
|
class st {
|
|
2190
2190
|
constructor(e) {
|
|
2191
2191
|
m(this, "_models", {});
|
|
2192
|
-
m(this,
|
|
2192
|
+
m(this, Me, "ModelFacade");
|
|
2193
2193
|
this._schema = e;
|
|
2194
2194
|
}
|
|
2195
2195
|
boot(e) {
|
|
2196
2196
|
this._schema && (Object.keys(this._schema).forEach((t) => {
|
|
2197
2197
|
const r = this[`model${d.upperFirst(d.camelCase(t))}`];
|
|
2198
2198
|
if (typeof this.model != "function" || typeof r != "function")
|
|
2199
|
-
throw new
|
|
2199
|
+
throw new $("ModelFacade");
|
|
2200
2200
|
const i = this.model(
|
|
2201
2201
|
Ve(e, t),
|
|
2202
2202
|
t
|
|
2203
2203
|
), s = r(i);
|
|
2204
2204
|
this._models[t] = Xe(e.make(), t, s);
|
|
2205
2205
|
}), this.reducer("relationMap", () => ({
|
|
2206
|
-
BelongsTo:
|
|
2207
|
-
BelongsToMany:
|
|
2206
|
+
BelongsTo: Ne,
|
|
2207
|
+
BelongsToMany: Be,
|
|
2208
2208
|
HasOne: Ze,
|
|
2209
2209
|
HasMany: ze,
|
|
2210
2210
|
MorphMany: Oe,
|
|
@@ -2215,12 +2215,12 @@ class st {
|
|
|
2215
2215
|
}
|
|
2216
2216
|
schema(e) {
|
|
2217
2217
|
if (!this._schema || e && !this._schema[e])
|
|
2218
|
-
throw new
|
|
2218
|
+
throw new V(e || "undefined");
|
|
2219
2219
|
return e ? this._schema[e] : this._schema;
|
|
2220
2220
|
}
|
|
2221
2221
|
make(e) {
|
|
2222
2222
|
if (e && !this._models[e])
|
|
2223
|
-
throw new
|
|
2223
|
+
throw new V(e);
|
|
2224
2224
|
return e ? this._models[e] : this._models;
|
|
2225
2225
|
}
|
|
2226
2226
|
toString() {
|
|
@@ -2263,33 +2263,33 @@ class st {
|
|
|
2263
2263
|
throw new b();
|
|
2264
2264
|
}
|
|
2265
2265
|
}
|
|
2266
|
-
const it =
|
|
2267
|
-
var
|
|
2268
|
-
class nt extends (
|
|
2266
|
+
const it = A(ve(st));
|
|
2267
|
+
var _e, Te;
|
|
2268
|
+
class nt extends (Te = Error, _e = Symbol.toStringTag, Te) {
|
|
2269
2269
|
constructor() {
|
|
2270
2270
|
super("[Luminix] Embed element not found. Make sure to include the `@luminixEmbed()` directive in your Blade template.");
|
|
2271
|
-
m(this,
|
|
2271
|
+
m(this, _e, "NoEmbedException");
|
|
2272
2272
|
}
|
|
2273
2273
|
}
|
|
2274
|
-
const
|
|
2274
|
+
const Ie = (n, e = "data") => {
|
|
2275
2275
|
if (!document.querySelector("#luminix-embed"))
|
|
2276
2276
|
throw new nt();
|
|
2277
2277
|
const t = document.getElementById(`luminix-${e}::` + n);
|
|
2278
2278
|
return t ? t.dataset.json && t.dataset.value ? JSON.parse(t.dataset.value) : t.dataset.value : null;
|
|
2279
|
-
},
|
|
2279
|
+
}, X = A(v), ot = (n) => Le(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;
|
|
2280
2280
|
let ht = class {
|
|
2281
2281
|
constructor() {
|
|
2282
2282
|
m(this, "bags");
|
|
2283
2283
|
const e = {};
|
|
2284
2284
|
document.querySelectorAll('#luminix-embed [id^="luminix-error"]').forEach((r) => {
|
|
2285
2285
|
const s = r.id.replace("luminix-error::", "");
|
|
2286
|
-
e[s] =
|
|
2286
|
+
e[s] = Ie(s, "error");
|
|
2287
2287
|
}), this.bags = {
|
|
2288
|
-
default: new
|
|
2288
|
+
default: new X(e)
|
|
2289
2289
|
};
|
|
2290
2290
|
}
|
|
2291
2291
|
bag(e = "default") {
|
|
2292
|
-
return this.bags[e] || (this.bags[e] = new
|
|
2292
|
+
return this.bags[e] || (this.bags[e] = new X({})), this.bags[e];
|
|
2293
2293
|
}
|
|
2294
2294
|
add(e, t, r = "default") {
|
|
2295
2295
|
this.bag(r).set(e, t);
|
|
@@ -2307,11 +2307,11 @@ let ht = class {
|
|
|
2307
2307
|
this.bag(e).set(".", {});
|
|
2308
2308
|
}
|
|
2309
2309
|
};
|
|
2310
|
-
var
|
|
2311
|
-
class ut extends (
|
|
2310
|
+
var $e, Se;
|
|
2311
|
+
class ut extends (Se = Error, $e = Symbol.toStringTag, Se) {
|
|
2312
2312
|
constructor(t) {
|
|
2313
2313
|
super(`[Luminix] Route "${t}" not found`);
|
|
2314
|
-
m(this,
|
|
2314
|
+
m(this, $e, "RouteNotFoundException");
|
|
2315
2315
|
}
|
|
2316
2316
|
}
|
|
2317
2317
|
class at {
|
|
@@ -2340,7 +2340,7 @@ class at {
|
|
|
2340
2340
|
const [t, r] = this.extractGenerator(e), i = this.get(t)[0].replace(/^\/|\/$/g, ""), s = /{([^}]+)}/g;
|
|
2341
2341
|
if (r === !1) {
|
|
2342
2342
|
if (typeof this.replaceRouteParams != "function")
|
|
2343
|
-
throw new
|
|
2343
|
+
throw new $("RouteFacade");
|
|
2344
2344
|
return this.appUrl + this.replaceRouteParams(`/${i}`);
|
|
2345
2345
|
}
|
|
2346
2346
|
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));
|
|
@@ -2348,7 +2348,7 @@ class at {
|
|
|
2348
2348
|
throw new TypeError(`Missing values for parameter(s): ${f.join(", ")}`);
|
|
2349
2349
|
if (p.length > 0)
|
|
2350
2350
|
throw new TypeError(`Unexpected parameters: ${p.join(", ")}`);
|
|
2351
|
-
const w = l.reduce((x,
|
|
2351
|
+
const w = l.reduce((x, _) => x.replace(`{${_}}`, `${r[_]}`), i);
|
|
2352
2352
|
return this.appUrl + `/${w}`;
|
|
2353
2353
|
}
|
|
2354
2354
|
methods(e) {
|
|
@@ -2360,32 +2360,32 @@ class at {
|
|
|
2360
2360
|
}
|
|
2361
2361
|
async call(e, t = {}) {
|
|
2362
2362
|
if (typeof this.axiosOptions != "function" || typeof this.axiosError != "function")
|
|
2363
|
-
throw new
|
|
2363
|
+
throw new $("RouteFacade");
|
|
2364
2364
|
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;
|
|
2365
2365
|
this.error.clear(f);
|
|
2366
2366
|
try {
|
|
2367
|
-
return ["get", "delete"].includes(a) ? await
|
|
2368
|
-
} catch (
|
|
2369
|
-
if (ot(
|
|
2370
|
-
const { errors:
|
|
2371
|
-
this.error.set(Object.entries(
|
|
2372
|
-
} else
|
|
2373
|
-
this.axiosError({ axios:
|
|
2374
|
-
error:
|
|
2367
|
+
return ["get", "delete"].includes(a) ? await j[a](u, p) : await j[a](u, w, x);
|
|
2368
|
+
} catch (_) {
|
|
2369
|
+
if (ot(_)) {
|
|
2370
|
+
const { errors: F } = _.response.data;
|
|
2371
|
+
this.error.set(Object.entries(F).reduce((N, [y, Fe]) => (N[y] = Fe.join(" "), N), {}), f);
|
|
2372
|
+
} else j.isAxiosError(_) && this.error.set(
|
|
2373
|
+
this.axiosError({ axios: _.message }, {
|
|
2374
|
+
error: _,
|
|
2375
2375
|
name: r,
|
|
2376
2376
|
replace: i,
|
|
2377
2377
|
config: t
|
|
2378
2378
|
}),
|
|
2379
2379
|
f
|
|
2380
2380
|
);
|
|
2381
|
-
throw
|
|
2381
|
+
throw _;
|
|
2382
2382
|
}
|
|
2383
2383
|
}
|
|
2384
2384
|
toString() {
|
|
2385
2385
|
return "route";
|
|
2386
2386
|
}
|
|
2387
2387
|
}
|
|
2388
|
-
const lt =
|
|
2388
|
+
const lt = ve(at);
|
|
2389
2389
|
class ct {
|
|
2390
2390
|
constructor() {
|
|
2391
2391
|
m(this, "facades", {});
|
|
@@ -2408,36 +2408,38 @@ class ct {
|
|
|
2408
2408
|
return this._plugins;
|
|
2409
2409
|
}
|
|
2410
2410
|
async boot(e = {}) {
|
|
2411
|
-
var
|
|
2411
|
+
var f, p, w, x, _, F, N;
|
|
2412
2412
|
if (this.booted)
|
|
2413
2413
|
throw new window.Error("[Luminix] App already booted");
|
|
2414
|
-
this.booted = !0, (
|
|
2415
|
-
register: (
|
|
2416
|
-
this._plugins.push(
|
|
2414
|
+
this.booted = !0, (f = e.app) != null && f.debug && console.log("[Luminix] Booting started..."), this.emit("init", {
|
|
2415
|
+
register: (y) => {
|
|
2416
|
+
this._plugins.push(y), typeof y.register == "function" && y.register(this);
|
|
2417
2417
|
}
|
|
2418
2418
|
});
|
|
2419
|
-
const t = (((
|
|
2419
|
+
const t = (((p = e.app) == null ? void 0 : p.url) ?? "") + (((w = e.app) == null ? void 0 : w.bootUrl) ?? "/luminix-api/init");
|
|
2420
2420
|
if (document.getElementById("luminix-data::config")) {
|
|
2421
2421
|
if (document.getElementById("luminix-data::config")) {
|
|
2422
|
-
const
|
|
2423
|
-
|
|
2422
|
+
const y = Ie("config");
|
|
2423
|
+
y && typeof y == "object" && d.merge(e, y);
|
|
2424
2424
|
}
|
|
2425
2425
|
} else try {
|
|
2426
|
-
const { data:
|
|
2427
|
-
|
|
2428
|
-
} catch (
|
|
2429
|
-
(
|
|
2426
|
+
const { data: y } = await j.get(t);
|
|
2427
|
+
y && typeof y == "object" && d.merge(e, y);
|
|
2428
|
+
} catch (y) {
|
|
2429
|
+
(x = e.app) != null && x.debug && console.error(y);
|
|
2430
2430
|
}
|
|
2431
|
-
this.bind("log", new Ce(!!((
|
|
2431
|
+
this.bind("log", new Ce(!!((_ = e.app) != null && _.debug)));
|
|
2432
2432
|
const { log: r } = this.facades, {
|
|
2433
2433
|
manifest: { routes: i = {}, models: s = {} } = {},
|
|
2434
2434
|
...u
|
|
2435
2435
|
} = e;
|
|
2436
|
-
this.bind("config", new
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
for (const
|
|
2440
|
-
typeof
|
|
2436
|
+
this.bind("config", new v(u)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user");
|
|
2437
|
+
const l = new URL(((F = e.app) == null ? void 0 : F.url) ?? "http://localhost"), a = ((N = e.app) == null ? void 0 : N.port) ?? "";
|
|
2438
|
+
a && (l.port = `${a}`), this.bind("error", new ht()), this.bind("route", new lt(i, this.facades.error, l.toString())), this.bind("model", new it(s)), this.bind("auth", new Qe(this)), this.emit("booting");
|
|
2439
|
+
for (const y of Object.values(this.facades))
|
|
2440
|
+
typeof y == "object" && y !== null && "boot" in y && typeof y.boot == "function" && y.boot(this);
|
|
2441
|
+
for (const y of this._plugins)
|
|
2442
|
+
typeof y.boot == "function" && y.boot(this.facades);
|
|
2441
2443
|
return r.info("[Luminix] App boot completed", {
|
|
2442
2444
|
config: this.facades.config.all(),
|
|
2443
2445
|
plugins: this._plugins,
|
|
@@ -2480,50 +2482,50 @@ class ct {
|
|
|
2480
2482
|
throw new window.Error("Method not implemented.");
|
|
2481
2483
|
}
|
|
2482
2484
|
}
|
|
2483
|
-
const dt =
|
|
2484
|
-
let
|
|
2485
|
-
function
|
|
2486
|
-
if (
|
|
2485
|
+
const dt = A(ct);
|
|
2486
|
+
let g;
|
|
2487
|
+
function R(n = void 0) {
|
|
2488
|
+
if (g || (g = new dt()), typeof n != "string")
|
|
2487
2489
|
return {
|
|
2488
|
-
boot:
|
|
2489
|
-
make:
|
|
2490
|
-
plugins:
|
|
2491
|
-
on:
|
|
2492
|
-
environment:
|
|
2493
|
-
getLocale:
|
|
2494
|
-
getPlugin:
|
|
2495
|
-
hasDebugModeEnabled:
|
|
2496
|
-
isLocal:
|
|
2497
|
-
isProduction:
|
|
2498
|
-
setInstance: (e) =>
|
|
2490
|
+
boot: g.boot.bind(g),
|
|
2491
|
+
make: g.make.bind(g),
|
|
2492
|
+
plugins: g.plugins.bind(g),
|
|
2493
|
+
on: g.once.bind(g),
|
|
2494
|
+
environment: g.environment.bind(g),
|
|
2495
|
+
getLocale: g.getLocale.bind(g),
|
|
2496
|
+
getPlugin: g.getPlugin.bind(g),
|
|
2497
|
+
hasDebugModeEnabled: g.hasDebugModeEnabled.bind(g),
|
|
2498
|
+
isLocal: g.isLocal.bind(g),
|
|
2499
|
+
isProduction: g.isProduction.bind(g),
|
|
2500
|
+
setInstance: (e) => g = e
|
|
2499
2501
|
};
|
|
2500
|
-
if (!
|
|
2502
|
+
if (!g.has(n))
|
|
2501
2503
|
throw new ke(n);
|
|
2502
|
-
return
|
|
2504
|
+
return g.make(n);
|
|
2503
2505
|
}
|
|
2504
2506
|
function bt() {
|
|
2505
|
-
return
|
|
2507
|
+
return R("auth");
|
|
2506
2508
|
}
|
|
2507
2509
|
function Et(n) {
|
|
2508
2510
|
return c(n);
|
|
2509
2511
|
}
|
|
2510
2512
|
function xt(n, e) {
|
|
2511
|
-
const t =
|
|
2513
|
+
const t = R("config");
|
|
2512
2514
|
return typeof n > "u" ? t : t.get(n, e);
|
|
2513
2515
|
}
|
|
2514
2516
|
function Mt(n, e = "default") {
|
|
2515
|
-
return n ?
|
|
2517
|
+
return n ? R().make("error").get(n, e) : R().make("error");
|
|
2516
2518
|
}
|
|
2517
2519
|
function _t(...n) {
|
|
2518
|
-
const e =
|
|
2520
|
+
const e = R("log");
|
|
2519
2521
|
return n.length ? e.debug(...n) : e;
|
|
2520
2522
|
}
|
|
2521
2523
|
function Tt(n) {
|
|
2522
|
-
const e =
|
|
2524
|
+
const e = R("model");
|
|
2523
2525
|
return n ? e.make(n) : e;
|
|
2524
2526
|
}
|
|
2525
2527
|
function $t(n, e = !1) {
|
|
2526
|
-
const t =
|
|
2528
|
+
const t = R("route");
|
|
2527
2529
|
return n ? e ? t.url([n, e]) : t.url(n) : t;
|
|
2528
2530
|
}
|
|
2529
2531
|
class St {
|
|
@@ -2538,16 +2540,16 @@ class St {
|
|
|
2538
2540
|
}
|
|
2539
2541
|
export {
|
|
2540
2542
|
dt as App,
|
|
2541
|
-
|
|
2543
|
+
A as HasEvents,
|
|
2542
2544
|
St as Plugin,
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2545
|
+
v as PropertyBag,
|
|
2546
|
+
ve as Reducible,
|
|
2547
|
+
R as app,
|
|
2546
2548
|
bt as auth,
|
|
2547
2549
|
Et as collect,
|
|
2548
2550
|
xt as config,
|
|
2549
2551
|
Mt as error,
|
|
2550
|
-
|
|
2552
|
+
S as isCollection,
|
|
2551
2553
|
E as isModel,
|
|
2552
2554
|
ot as isValidationError,
|
|
2553
2555
|
_t as log,
|