@luminix/core 0.4.5 → 0.4.7
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 +17 -16
- package/package.json +1 -1
- package/types/types/Model.d.ts +1 -0
package/dist/core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var ce = Object.defineProperty;
|
|
2
2
|
var de = (o, e, t) => e in o ? ce(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
3
|
var g = (o, e, t) => de(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { reader as pe, PropertyBag as _, EventSource as A, Collection as b, Query as
|
|
4
|
+
import { reader as pe, PropertyBag as _, EventSource as A, Collection as b, Query as S, Obj as p, Str as y, Reducible as re, isValidationError as ge, Macroable as ne, Client as ye, ServiceProvider as me, MakeFacade as M, Application as fe, Response as we } from "@luminix/support";
|
|
5
5
|
class ve {
|
|
6
6
|
constructor(e, t, r) {
|
|
7
7
|
g(this, "_user");
|
|
@@ -222,16 +222,16 @@ class Ee extends A {
|
|
|
222
222
|
...l.json(),
|
|
223
223
|
data: c,
|
|
224
224
|
links: {
|
|
225
|
-
first: `${s}?${
|
|
226
|
-
last: `${s}?${
|
|
227
|
-
next: l.json("links").next && `${s}?${
|
|
228
|
-
prev: l.json("links").prev && `${s}?${
|
|
225
|
+
first: `${s}?${S.merge(u, l.json("links").first).toString()}`,
|
|
226
|
+
last: `${s}?${S.merge(u, l.json("links").last).toString()}`,
|
|
227
|
+
next: l.json("links").next && `${s}?${S.merge(u, l.json("links").next ?? "").toString()}`,
|
|
228
|
+
prev: l.json("links").prev && `${s}?${S.merge(u, l.json("links").prev ?? "").toString()}`
|
|
229
229
|
},
|
|
230
230
|
meta: {
|
|
231
231
|
...l.json("meta"),
|
|
232
232
|
links: l.json("meta").links.map((n) => ({
|
|
233
233
|
...n,
|
|
234
|
-
url: n.url && `${s}?${
|
|
234
|
+
url: n.url && `${s}?${S.merge(u, n.url).toString()}`
|
|
235
235
|
}))
|
|
236
236
|
}
|
|
237
237
|
};
|
|
@@ -308,7 +308,7 @@ class $e extends (P = Error, I = Symbol.toStringTag, P) {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
var Q, L;
|
|
311
|
-
class
|
|
311
|
+
class Te extends (L = Error, Q = Symbol.toStringTag, L) {
|
|
312
312
|
constructor(t) {
|
|
313
313
|
super(`[Luminix] Relation "${t}" is not supported`);
|
|
314
314
|
g(this, Q, "UnsupportedRelationException");
|
|
@@ -349,7 +349,7 @@ class k {
|
|
|
349
349
|
MorphToMany: ["MorphToMany"]
|
|
350
350
|
}, this.parent, t, this.getRelated());
|
|
351
351
|
if (!(t in r))
|
|
352
|
-
throw new
|
|
352
|
+
throw new Te(t);
|
|
353
353
|
for (const i in e) {
|
|
354
354
|
const l = e[i];
|
|
355
355
|
if ((l.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(t)) && r[t].includes(l.type))
|
|
@@ -446,7 +446,7 @@ class E extends (H = Error, D = Symbol.toStringTag, H) {
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
var J, U;
|
|
449
|
-
class
|
|
449
|
+
class Se extends (U = Error, J = Symbol.toStringTag, U) {
|
|
450
450
|
constructor() {
|
|
451
451
|
super("[Luminix] Method not implemented.");
|
|
452
452
|
g(this, J, "MethodNotImplementedException");
|
|
@@ -496,8 +496,8 @@ function _e(o, e, t, r, i) {
|
|
|
496
496
|
}
|
|
497
497
|
makeAttributes(s) {
|
|
498
498
|
const { relations: n, attributes: a } = t.schema(i), h = Object.keys(n || {}), d = p.omit(s, ...h), v = (f) => {
|
|
499
|
-
const
|
|
500
|
-
return
|
|
499
|
+
const T = a.find((le) => le.name == f);
|
|
500
|
+
return T ? !(f in d) && T.nullable : !1;
|
|
501
501
|
};
|
|
502
502
|
if (this.fillable.filter(v).forEach((f) => {
|
|
503
503
|
d[f] = null;
|
|
@@ -773,7 +773,7 @@ function _e(o, e, t, r, i) {
|
|
|
773
773
|
return;
|
|
774
774
|
const f = await r.call(
|
|
775
775
|
this.getRouteForSave(),
|
|
776
|
-
(
|
|
776
|
+
(T) => n ? n(T.withData(v)) : T.withData(v),
|
|
777
777
|
this.getErrorBag(d ? "update" : "store")
|
|
778
778
|
);
|
|
779
779
|
if (f.successful())
|
|
@@ -784,7 +784,7 @@ function _e(o, e, t, r, i) {
|
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
async push() {
|
|
787
|
-
throw new
|
|
787
|
+
throw new Se();
|
|
788
788
|
}
|
|
789
789
|
async delete() {
|
|
790
790
|
try {
|
|
@@ -1299,8 +1299,9 @@ class Ke extends ae {
|
|
|
1299
1299
|
}
|
|
1300
1300
|
class je extends ue {
|
|
1301
1301
|
query() {
|
|
1302
|
-
|
|
1303
|
-
|
|
1302
|
+
var r;
|
|
1303
|
+
const e = super.query(), t = `${(r = this.meta.morphType) == null ? void 0 : r.slice(0, -5)}_id`;
|
|
1304
|
+
return e.where(t, this.parent.getKey()), e.where(this.meta.morphType, this.parent.getType()), e.lock(`where.${t}`), e.lock(`where.${this.meta.morphType}`), e;
|
|
1304
1305
|
}
|
|
1305
1306
|
}
|
|
1306
1307
|
var Y, Z;
|
|
@@ -1525,7 +1526,7 @@ class De extends (ie = me, se = Symbol.toStringTag, ie) {
|
|
|
1525
1526
|
return new Pe(
|
|
1526
1527
|
((t = this.app.configuration.manifest) == null ? void 0 : t.routes) ?? {},
|
|
1527
1528
|
this.app.make("error"),
|
|
1528
|
-
() => this.app.make("http"),
|
|
1529
|
+
() => this.app.make("http").getClient(),
|
|
1529
1530
|
(r = this.app.configuration.app) == null ? void 0 : r.url
|
|
1530
1531
|
);
|
|
1531
1532
|
});
|
package/package.json
CHANGED
package/types/types/Model.d.ts
CHANGED
|
@@ -153,6 +153,7 @@ export interface RelationMetaData {
|
|
|
153
153
|
type: 'HasOne' | 'HasMany' | 'BelongsTo' | 'BelongsToMany' | 'MorphOne' | 'MorphMany' | 'MorphTo' | 'MorphToMany' | 'MorphedByMany';
|
|
154
154
|
foreignKey: string | null;
|
|
155
155
|
name: string;
|
|
156
|
+
morphType?: string;
|
|
156
157
|
}
|
|
157
158
|
export interface ModelSchema {
|
|
158
159
|
[abstract: string]: ModelSchemaAttributes;
|