@luminix/core 1.0.0 → 1.0.1

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 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 N, Collection as b, Query as S, Obj as p, Str as y, Reducible as re, isValidationError as ge, Macroable as ne, Client as me, ServiceProvider as ye, MakeFacade as M, Application as fe } from "@luminix/support";
4
+ import { reader as pe, PropertyBag as _, EventSource as k, Collection as b, Query as S, Obj as p, Str as y, Reducible as re, isValidationError as ge, Macroable as ne, Client as me, ServiceProvider as ye, MakeFacade as M, Application as fe } from "@luminix/support";
5
5
  class we {
6
6
  constructor(e, t, r) {
7
7
  g(this, "_user");
@@ -117,7 +117,7 @@ class xe extends (j = Error, O = Symbol.toStringTag, j) {
117
117
  g(this, O, "ModelWithoutPrimaryKeyException");
118
118
  }
119
119
  }
120
- class Me extends N {
120
+ class Me extends k {
121
121
  constructor(t, r, i = {}) {
122
122
  super();
123
123
  g(this, "bag");
@@ -314,7 +314,7 @@ class $e extends (L = Error, Q = Symbol.toStringTag, L) {
314
314
  g(this, Q, "UnsupportedRelationException");
315
315
  }
316
316
  }
317
- class k {
317
+ class N {
318
318
  constructor(e, t, r, i = null) {
319
319
  g(this, "unsubscribeQuery", null);
320
320
  if (this.services = e, this.meta = t, this.parent = r, this.items = i, i !== null && !p.isModel(i) && !(i instanceof b && i.every(p.isModel)))
@@ -461,7 +461,7 @@ class oe extends (W = Error, F = Symbol.toStringTag, W) {
461
461
  }
462
462
  function Se(o, e, t, r, i) {
463
463
  var l, m, c;
464
- return c = class extends (m = N, l = Symbol.toStringTag, m) {
464
+ return c = class extends (m = k, l = Symbol.toStringTag, m) {
465
465
  constructor(s = {}) {
466
466
  super();
467
467
  g(this, "_attributes", new _({}));
@@ -485,7 +485,7 @@ function Se(o, e, t, r, i) {
485
485
  return;
486
486
  const n = t.getRelationConstructors(i);
487
487
  Object.entries(s).forEach(([a, h]) => {
488
- const { type: d } = h, v = d in n ? n[d] : k;
488
+ const { type: d } = h, v = d in n ? n[d] : N;
489
489
  this._relations[a] = new v(
490
490
  { model: t, route: r },
491
491
  { name: a, ...h },
@@ -773,9 +773,7 @@ function Se(o, e, t, r, i) {
773
773
  (T) => n ? n(T.withData(v)) : T.withData(v),
774
774
  this.getErrorBag(d ? "update" : "store")
775
775
  );
776
- if (f.successful())
777
- return this.makeAttributes(f.json()), this.exists = !0, this.dispatchSaveEvent(), d ? this.dispatchUpdateEvent(f.json()) : (this.wasRecentlyCreated = !0, this.dispatchCreateEvent(f.json())), f;
778
- throw f;
776
+ return f.throw(), this.makeAttributes(f.json()), this.exists = !0, this.dispatchSaveEvent(), d ? this.dispatchUpdateEvent(f.json()) : (this.wasRecentlyCreated = !0, this.dispatchCreateEvent(f.json())), f;
779
777
  } catch (a) {
780
778
  throw this.dispatchErrorEvent(a, "save"), a;
781
779
  }
@@ -790,9 +788,7 @@ function Se(o, e, t, r, i) {
790
788
  void 0,
791
789
  this.getErrorBag("delete")
792
790
  );
793
- if (s.noContent())
794
- return this.dispatchDeleteEvent(), s;
795
- throw s;
791
+ return s.throw(), this.dispatchDeleteEvent(), s;
796
792
  } catch (s) {
797
793
  throw this.dispatchErrorEvent(s, "delete"), s;
798
794
  }
@@ -804,11 +800,7 @@ function Se(o, e, t, r, i) {
804
800
  (h) => n ? n(h.withData(s)) : h.withData(s),
805
801
  this.getErrorBag("update")
806
802
  );
807
- if (a.ok()) {
808
- this.makeAttributes(a.json()), this.dispatchUpdateEvent(a.json());
809
- return;
810
- }
811
- throw a;
803
+ a.throw(), this.makeAttributes(a.json()), this.dispatchUpdateEvent(a.json());
812
804
  } catch (a) {
813
805
  throw this.dispatchErrorEvent(a, "save"), a;
814
806
  }
@@ -820,9 +812,7 @@ function Se(o, e, t, r, i) {
820
812
  (n) => n.withQueryParameters({ force: !0 }),
821
813
  this.getErrorBag("forceDelete")
822
814
  );
823
- if (s.noContent())
824
- return this.dispatchDeleteEvent(!0), s;
825
- throw s;
815
+ return s.throw(), this.dispatchDeleteEvent(!0), s;
826
816
  } catch (s) {
827
817
  throw this.dispatchErrorEvent(s, "forceDelete"), s;
828
818
  }
@@ -834,9 +824,7 @@ function Se(o, e, t, r, i) {
834
824
  (n) => n.withQueryParameters({ restore: !0 }),
835
825
  this.getErrorBag("restore")
836
826
  );
837
- if (s.ok())
838
- return this.dispatchRestoreEvent(), s;
839
- throw s;
827
+ return s.throw(), this.dispatchRestoreEvent(), s;
840
828
  } catch (s) {
841
829
  throw this.dispatchErrorEvent(s, "restore"), s;
842
830
  }
@@ -984,7 +972,7 @@ class R extends (X = TypeError, z = Symbol.toStringTag, X) {
984
972
  g(this, z, "ModelInvalidRelatedTypeException");
985
973
  }
986
974
  }
987
- class ae extends k {
975
+ class ae extends N {
988
976
  constructor(e, t, r, i = null) {
989
977
  if (!p.isModel(i) && i !== null)
990
978
  throw new w("BelongsTo.constructor()", "Model or null");
@@ -1020,7 +1008,7 @@ class ae extends k {
1020
1008
  });
1021
1009
  }
1022
1010
  }
1023
- class ue extends k {
1011
+ class ue extends N {
1024
1012
  constructor(e, t, r, i = null) {
1025
1013
  if (i !== null && !(i instanceof b && i.every(p.isModel)))
1026
1014
  throw new w("BelongsToMany.constructor()", "Collection<Model> or null");
@@ -1116,7 +1104,7 @@ class ue extends k {
1116
1104
  this.items ? this.items.splice(0, this.items.count(), ...r) : this.items = r;
1117
1105
  }
1118
1106
  }
1119
- class A extends k {
1107
+ class A extends N {
1120
1108
  query() {
1121
1109
  const e = super.query(), t = this.guessInverseRelation();
1122
1110
  return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
@@ -1151,7 +1139,7 @@ class Re extends A {
1151
1139
  function K(o) {
1152
1140
  return new b(o);
1153
1141
  }
1154
- class ke extends A {
1142
+ class Ne extends A {
1155
1143
  constructor(e, t, r, i = null) {
1156
1144
  if (i !== null && !(i instanceof b && i.every(p.isModel)))
1157
1145
  throw new w("HasMany.constructor()", "Collection<Model> or null");
@@ -1207,7 +1195,7 @@ class he extends A {
1207
1195
  e.setAttribute(t + "_id", this.parent.getKey()), e.setAttribute(t + "_type", this.parent.getType()), await e.save();
1208
1196
  }
1209
1197
  }
1210
- class Ne extends he {
1198
+ class ke extends he {
1211
1199
  constructor(e, t, r, i = null) {
1212
1200
  if (i !== null && !(i instanceof b && i.every(p.isModel)))
1213
1201
  throw new w("MorphMany.constructor()", "Collection<Model> or null");
@@ -1302,7 +1290,7 @@ class Ke extends ue {
1302
1290
  }
1303
1291
  }
1304
1292
  var Y, Z;
1305
- class Oe extends (Z = N, Y = Symbol.toStringTag, Z) {
1293
+ class Oe extends (Z = k, Y = Symbol.toStringTag, Z) {
1306
1294
  constructor(t) {
1307
1295
  super();
1308
1296
  g(this, "_models", {});
@@ -1339,8 +1327,8 @@ class Oe extends (Z = N, Y = Symbol.toStringTag, Z) {
1339
1327
  BelongsTo: ae,
1340
1328
  BelongsToMany: ue,
1341
1329
  HasOne: Re,
1342
- HasMany: ke,
1343
- MorphMany: Ne,
1330
+ HasMany: Ne,
1331
+ MorphMany: ke,
1344
1332
  MorphOne: Ae,
1345
1333
  MorphTo: qe,
1346
1334
  MorphToMany: Ke
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminix/core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/core.js",
5
5
  "module": "dist/core.js",
6
6
  "types": "types/index.d.ts",
@@ -13,12 +13,10 @@
13
13
  "lint:fix": "eslint ./src ./tests --ext .ts --fix",
14
14
  "test": "jest",
15
15
  "test:coverage": "jest --coverage",
16
- "ci": "npm run lint && npm run test",
17
- "publish:beta": "npm run build && npm publish --tag beta"
16
+ "ci": "npm run lint && npm run test"
18
17
  },
19
18
  "author": "",
20
19
  "license": "MIT",
21
- "description": "> Projeto em desenvolvimento",
22
20
  "devDependencies": {
23
21
  "@babel/core": "^7.26.0",
24
22
  "@babel/preset-env": "^7.26.0",
package/babel.config.json DELETED
@@ -1,5 +0,0 @@
1
-
2
- {
3
- "presets": [[ "@babel/preset-env", { "targets": { "node": "current"}} ]],
4
- "plugins": [ "transform-es2015-modules-commonjs" ]
5
- }