@luminix/core 0.4.1 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  var le = Object.defineProperty;
2
2
  var ce = (o, e, t) => e in o ? le(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
3
  var g = (o, e, t) => ce(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { reader as de, PropertyBag as T, EventSource as k, Collection as b, Query as S, Obj as p, Str as y, Reducible as re, isValidationError as pe, Macroable as ne, Client as ge, ServiceProvider as ye, MakeFacade as M, Application as me, Response as fe } from "@luminix/support";
4
+ import { reader as de, PropertyBag as _, EventSource as k, Collection as b, Query as S, Obj as p, Str as y, Reducible as re, isValidationError as pe, Macroable as ne, Client as ge, ServiceProvider as ye, MakeFacade as M, Application as me, Response as fe } from "@luminix/support";
5
5
  class we {
6
6
  constructor(e, t, r) {
7
7
  g(this, "_user");
@@ -42,7 +42,7 @@ class we {
42
42
  const e = this.model.make("user"), t = this.config.get("auth.user");
43
43
  if (!t)
44
44
  return;
45
- this._user = new e(t);
45
+ this._user = new e(t), this._user.exists = !0;
46
46
  }
47
47
  return this._user;
48
48
  }
@@ -59,11 +59,11 @@ class ve {
59
59
  const l = r.id.replace("luminix-error::", "");
60
60
  e[l] = de(l, "error");
61
61
  }), this.bags = {
62
- default: new T(e)
62
+ default: new _(e)
63
63
  };
64
64
  }
65
65
  bag(e = "default") {
66
- return this.bags[e] || (this.bags[e] = new T({})), this.bags[e];
66
+ return this.bags[e] || (this.bags[e] = new _({})), this.bags[e];
67
67
  }
68
68
  add(e, t, r = "default") {
69
69
  this.bag(r).set(e, t);
@@ -121,7 +121,7 @@ class Me extends k {
121
121
  constructor(t, r, i = {}) {
122
122
  super();
123
123
  g(this, "bag");
124
- this.services = t, this.abstract = r, this.bag = new T(i), this.bag.on("change", () => {
124
+ this.services = t, this.abstract = r, this.bag = new _(i), this.bag.on("change", () => {
125
125
  this.emit("change", {
126
126
  data: this.bag,
127
127
  source: this
@@ -459,12 +459,12 @@ class oe extends (W = Error, F = Symbol.toStringTag, W) {
459
459
  g(this, F, "ModelNotPersistedException");
460
460
  }
461
461
  }
462
- function Te(o, e, t, r, i) {
462
+ function _e(o, e, t, r, i) {
463
463
  var l, m, c;
464
464
  return c = class extends (m = k, l = Symbol.toStringTag, m) {
465
465
  constructor(s = {}) {
466
466
  super();
467
- g(this, "_attributes", new T({}));
467
+ g(this, "_attributes", new _({}));
468
468
  g(this, "_original", {});
469
469
  g(this, "_relations", {});
470
470
  g(this, "_changedKeys", []);
@@ -936,7 +936,7 @@ function Te(o, e, t, r, i) {
936
936
  }
937
937
  }, g(c, "name", y.studly(i)), c;
938
938
  }
939
- function _e(o, e, t) {
939
+ function Te(o, e, t) {
940
940
  var r, i;
941
941
  return class extends (i = t, r = Symbol.toStringTag, i) {
942
942
  constructor(m = {}) {
@@ -978,7 +978,7 @@ class q extends (V = Error, G = Symbol.toStringTag, V) {
978
978
  }
979
979
  }
980
980
  var z, X;
981
- class _ extends (X = TypeError, z = Symbol.toStringTag, X) {
981
+ class T extends (X = TypeError, z = Symbol.toStringTag, X) {
982
982
  constructor(t, r, i) {
983
983
  super(`[Luminix] "${t}" expects a related model of type "${r}". Received "${i}" instead.`);
984
984
  g(this, z, "ModelInvalidRelatedTypeException");
@@ -1007,7 +1007,7 @@ class ae extends R {
1007
1007
  if (!p.isModel(e))
1008
1008
  throw new f("BelongsTo.associate()");
1009
1009
  if (e.getType() !== this.getRelated().getSchemaName())
1010
- throw new _("BelongsTo.associate()", this.getRelated().getSchemaName(), e.getType());
1010
+ throw new T("BelongsTo.associate()", this.getRelated().getSchemaName(), e.getType());
1011
1011
  if (!e.exists)
1012
1012
  throw new oe(this.getRelated().getSchemaName(), "save");
1013
1013
  return this.parent.update({
@@ -1125,7 +1125,7 @@ class A extends R {
1125
1125
  if (!p.isModel(e))
1126
1126
  throw new f("HasOneOrMany.saveQuietly()");
1127
1127
  if (e.getType() !== this.getRelated().getSchemaName())
1128
- throw new _("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1128
+ throw new T("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1129
1129
  e.setAttribute(this.getForeignKey(), this.parent.getKey()), await e.save();
1130
1130
  }
1131
1131
  }
@@ -1179,7 +1179,7 @@ class ke extends A {
1179
1179
  if (!Array.isArray(e) || !e.every(p.isModel))
1180
1180
  throw new f("HasMany.saveManyQuietly()", "Model[]");
1181
1181
  if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
1182
- throw new _("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
1182
+ throw new T("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
1183
1183
  await Promise.all(e.map((t) => (t.setAttribute(this.getForeignKey(), this.parent.getKey()), t.save())));
1184
1184
  }
1185
1185
  async saveMany(e) {
@@ -1202,7 +1202,7 @@ class he extends A {
1202
1202
  if (!p.isModel(e))
1203
1203
  throw new f("MorphOneOrMany.saveQuietly()");
1204
1204
  if (e.getType() !== this.getRelated().getSchemaName())
1205
- throw new _("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1205
+ throw new T("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1206
1206
  const t = this.guessInverseRelation();
1207
1207
  e.setAttribute(t + "_id", this.parent.getKey()), e.setAttribute(t + "_type", this.parent.getType()), await e.save();
1208
1208
  }
@@ -1235,7 +1235,7 @@ class Ae extends he {
1235
1235
  if (!Array.isArray(e) || !e.every(p.isModel))
1236
1236
  throw new f("MorphMany.saveManyQuietly()");
1237
1237
  if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
1238
- throw new _("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
1238
+ throw new T("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
1239
1239
  await Promise.all(e.map((t) => (t.setAttribute(this.getName() + "_id", this.parent.getKey()), t.setAttribute(this.getName() + "_type", this.parent.getType()), t.save())));
1240
1240
  }
1241
1241
  async saveMany(e) {
@@ -1311,7 +1311,7 @@ class je extends (Z = k, Y = Symbol.toStringTag, Z) {
1311
1311
  boot(t) {
1312
1312
  this._schema && Object.keys(this._schema).forEach((r) => {
1313
1313
  const i = this[`model${y.studly(r)}`], l = this.model(
1314
- Te(
1314
+ _e(
1315
1315
  t.make("config"),
1316
1316
  t.make("log"),
1317
1317
  t.make("model"),
@@ -1320,7 +1320,7 @@ class je extends (Z = k, Y = Symbol.toStringTag, Z) {
1320
1320
  ),
1321
1321
  r
1322
1322
  ), m = i(l);
1323
- this._models[r] = _e(t.make("model"), r, m);
1323
+ this._models[r] = Te(t.make("model"), r, m);
1324
1324
  });
1325
1325
  }
1326
1326
  schema(t) {
@@ -1507,7 +1507,7 @@ class Le extends (ie = ye, se = Symbol.toStringTag, ie) {
1507
1507
  this.app.make("model"),
1508
1508
  this.app.make("route")
1509
1509
  )), this.app.singleton("config", () => {
1510
- const t = new T(p.omit(this.app.configuration, "manifest"));
1510
+ const t = new _(p.omit(this.app.configuration, "manifest"));
1511
1511
  return t.has("auth.user") || t.set("auth.user", null), t.lock("auth.user"), t;
1512
1512
  }), this.app.singleton("error", () => new ve()), this.app.singleton("http", () => new Qe()), this.app.singleton("log", () => {
1513
1513
  var t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminix/core",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "main": "dist/core.js",
5
5
  "module": "dist/core.js",
6
6
  "types": "types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -22,4 +22,5 @@ export type { BuilderInterface, Scope } from './types/Builder';
22
22
  export type { AppConfiguration } from './types/Config';
23
23
  export type { LogFacade } from './types/Log';
24
24
  export type { Model as ModelType, BaseModel, ModelAttribute, ModelSaveOptions, ModelPaginatedResponse, ModelPaginatedLink } from './types/Model';
25
+ export type { RelationInterface as Relation } from './types/Relation';
25
26
  export type { RouteFacade, RouteReducers, HttpMethod, RouteGenerator } from './types/Route';