@luminix/core 0.4.8 → 1.0.0

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/README.md CHANGED
@@ -1,3 +1,64 @@
1
- # Luminix JS Core
1
+ # @luminix/core
2
2
 
3
- > Projeto em desenvolvimento
3
+ Biblioteca JavaScript fundamental do stack Luminix. Agnóstica de framework frontend — funciona com React, Vue, Svelte ou vanilla JS/TS.
4
+
5
+ ## Posição no stack
6
+
7
+ ```
8
+ @luminix/mui-cms ← CMS completo com Material UI
9
+ └── @luminix/react ← Integração com React
10
+ └── @luminix/core ← este pacote
11
+ └── @luminix/support
12
+ ```
13
+
14
+ ## O que faz
15
+
16
+ - **Models** — API Eloquent-like para consumir os endpoints REST do `luminix/backend`
17
+ - **Facades** — `App`, `Auth`, `Config`, `Route`, `Http`, `Log`, `Error`
18
+ - **Plugins e Reducers** — para estender e customizar o comportamento
19
+ - **Helpers** — `app()`, `auth()`, `config()`, `model()`, `route()`, `log()`, `error()`, `collect()`
20
+
21
+ ## Pré-requisitos
22
+
23
+ Uma aplicação Laravel 11 com:
24
+ - [`luminix/backend`](https://github.com/luminix-cms/backend) — gera a API REST automaticamente
25
+ - [`luminix/frontend`](https://github.com/luminix-cms/frontend) — injeta os dados de boot na página via `@luminixEmbed()`
26
+
27
+ ## Instalação
28
+
29
+ ```bash
30
+ npm install @luminix/core
31
+ ```
32
+
33
+ ## Uso rápido
34
+
35
+ ```typescript
36
+ import { App, model, auth, config } from '@luminix/core';
37
+
38
+ // Inicializa (lê config do @luminixEmbed() automaticamente)
39
+ App.create();
40
+
41
+ // Acessa dados de configuração
42
+ console.log(config('app.name'));
43
+
44
+ // Verifica autenticação
45
+ if (auth().check()) {
46
+ console.log(`Bem-vindo, ${auth().user()?.name}`);
47
+ }
48
+
49
+ // Usa um model
50
+ const User = model('user');
51
+ const { data } = await User.where('role', 'admin').orderBy('name').get();
52
+ data.each((user) => console.log(user.name, user.email));
53
+
54
+ // Cria um registro
55
+ const post = await model('post').create({ title: 'Olá mundo', content: '...' });
56
+ ```
57
+
58
+ ## Documentação
59
+
60
+ [Documentação completa (pt-BR) →](docs/pt-BR/README.md)
61
+
62
+ ## Licença
63
+
64
+ MIT
package/dist/core.js CHANGED
@@ -1,8 +1,8 @@
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 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
- class ve {
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";
5
+ class we {
6
6
  constructor(e, t, r) {
7
7
  g(this, "_user");
8
8
  this.config = e, this.model = t, this.route = r;
@@ -51,7 +51,7 @@ class ve {
51
51
  return ((e = this.user()) == null ? void 0 : e.getKey()) || null;
52
52
  }
53
53
  }
54
- class be {
54
+ class ve {
55
55
  constructor() {
56
56
  g(this, "bags");
57
57
  const e = {};
@@ -81,7 +81,7 @@ class be {
81
81
  this.bag(e).set(".", {});
82
82
  }
83
83
  }
84
- class xe {
84
+ class be {
85
85
  constructor(e) {
86
86
  this._debug = e;
87
87
  }
@@ -110,14 +110,14 @@ class xe {
110
110
  this._debug && console.debug(...e);
111
111
  }
112
112
  }
113
- var j, O;
114
- class Me extends (O = Error, j = Symbol.toStringTag, O) {
113
+ var O, j;
114
+ class xe extends (j = Error, O = Symbol.toStringTag, j) {
115
115
  constructor(t) {
116
116
  super(`[Luminix] Model "${t}" does not have a primary key`);
117
- g(this, j, "ModelWithoutPrimaryKeyException");
117
+ g(this, O, "ModelWithoutPrimaryKeyException");
118
118
  }
119
119
  }
120
- class Ee extends A {
120
+ class Me extends N {
121
121
  constructor(t, r, i = {}) {
122
122
  super();
123
123
  g(this, "bag");
@@ -266,7 +266,7 @@ class Ee extends A {
266
266
  async find(t) {
267
267
  const r = this.services.model.schema(this.abstract).primaryKey;
268
268
  if (!r)
269
- throw new Me(this.abstract);
269
+ throw new xe(this.abstract);
270
270
  const i = await this.where(r, t).limit(1).exec();
271
271
  return this.emit("success", {
272
272
  response: i,
@@ -301,14 +301,14 @@ class w extends (C = TypeError, B = Symbol.toStringTag, C) {
301
301
  }
302
302
  }
303
303
  var I, P;
304
- class $e extends (P = Error, I = Symbol.toStringTag, P) {
304
+ class Ee extends (P = Error, I = Symbol.toStringTag, P) {
305
305
  constructor(t, r, i, l) {
306
306
  super(`[Luminix] Could not determine inverse relation for "${r}" in model "${t}". Please specify a relation in model "${i}" of type ${l} that points back to "${t}".`);
307
307
  g(this, I, "NoInverseRelationException");
308
308
  }
309
309
  }
310
310
  var Q, L;
311
- class Te extends (L = Error, Q = Symbol.toStringTag, L) {
311
+ class $e 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,13 +349,13 @@ class k {
349
349
  MorphToMany: ["MorphToMany"]
350
350
  }, this.parent, t, this.getRelated());
351
351
  if (!(t in r))
352
- throw new Te(t);
352
+ throw new $e(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))
356
356
  return i;
357
357
  }
358
- throw new $e(this.parent.getType(), t, this.getRelated().getSchemaName(), r[t].join(" or "));
358
+ throw new Ee(this.parent.getType(), t, this.getRelated().getSchemaName(), r[t].join(" or "));
359
359
  }
360
360
  set(e) {
361
361
  if (e !== null && !p.isModel(e) && !(e instanceof b && e.every(p.isModel)))
@@ -439,14 +439,14 @@ class k {
439
439
  // }
440
440
  }
441
441
  var D, H;
442
- class E extends (H = Error, D = Symbol.toStringTag, H) {
442
+ class $ extends (H = Error, D = Symbol.toStringTag, H) {
443
443
  constructor(t) {
444
444
  super(`[Luminix] Expected ${t} to be reducible.`);
445
445
  g(this, D, "NotReducibleException");
446
446
  }
447
447
  }
448
448
  var J, U;
449
- class Se extends (U = Error, J = Symbol.toStringTag, U) {
449
+ class Te extends (U = Error, J = Symbol.toStringTag, U) {
450
450
  constructor() {
451
451
  super("[Luminix] Method not implemented.");
452
452
  g(this, J, "MethodNotImplementedException");
@@ -459,9 +459,9 @@ class oe extends (W = Error, F = Symbol.toStringTag, W) {
459
459
  g(this, F, "ModelNotPersistedException");
460
460
  }
461
461
  }
462
- function _e(o, e, t, r, i) {
462
+ function Se(o, e, t, r, i) {
463
463
  var l, m, c;
464
- return c = class extends (m = A, l = Symbol.toStringTag, m) {
464
+ return c = class extends (m = N, l = Symbol.toStringTag, m) {
465
465
  constructor(s = {}) {
466
466
  super();
467
467
  g(this, "_attributes", new _({}));
@@ -495,7 +495,7 @@ function _e(o, e, t, r, i) {
495
495
  });
496
496
  }
497
497
  makeAttributes(s) {
498
- const { relations: n, attributes: a } = t.schema(i), h = Object.keys(n || {}), d = p.omit(s, ...h), v = (f) => {
498
+ const { relations: n, attributes: a = [] } = t.schema(i), h = Object.keys(n || {}), d = p.omit(s, ...h), v = (f) => {
499
499
  const T = a.find((le) => le.name == f);
500
500
  return T ? !(f in d) && T.nullable : !1;
501
501
  };
@@ -634,14 +634,11 @@ function _e(o, e, t, r, i) {
634
634
  s in this.casts && (n = this.cast(n, this.casts[s]));
635
635
  const a = t[`model${y.studly(i)}Get${y.studly(s)}Attribute`];
636
636
  if (typeof a != "function")
637
- throw new E("ModelFacade");
637
+ throw new $("ModelFacade");
638
638
  return a.bind(t)(n, this);
639
639
  }
640
640
  setAttribute(s, n) {
641
- const a = t[`model${y.studly(i)}Set${y.studly(s)}Attribute`];
642
- if (typeof a != "function")
643
- throw new E("ModelFacade");
644
- const h = a.bind(t)(
641
+ const h = t[`model${y.studly(i)}Set${y.studly(s)}Attribute`].bind(t)(
645
642
  this.mutate(n, this.casts[s]),
646
643
  this
647
644
  );
@@ -670,7 +667,7 @@ function _e(o, e, t, r, i) {
670
667
  const n = p.pick(s, ...this.fillable), a = Object.entries(n).reduce((h, [d, v]) => {
671
668
  const f = t[`model${y.studly(i)}Set${y.studly(d)}Attribute`];
672
669
  if (typeof f != "function")
673
- throw new E("ModelFacade");
670
+ throw new $("ModelFacade");
674
671
  return h[d] = f.bind(t)(
675
672
  this.mutate(v, this.casts[d]),
676
673
  this
@@ -699,7 +696,7 @@ function _e(o, e, t, r, i) {
699
696
  toJson() {
700
697
  const s = Object.entries(this.relations).reduce((a, [h, d]) => (d.isLoaded() && (d.isSingle() ? a[y.snake(h)] = d.getLoadedItems().toJson() : d.isMultiple() && (a[y.snake(h)] = d.getLoadedItems().map((v) => v.toJson()).all())), a), {}), n = t[`model${y.studly(i)}Json`];
701
698
  if (typeof n != "function")
702
- throw new E("ModelFacade");
699
+ throw new $("ModelFacade");
703
700
  return n.bind(t)({
704
701
  ...this.attributes,
705
702
  ...s
@@ -784,7 +781,7 @@ function _e(o, e, t, r, i) {
784
781
  }
785
782
  }
786
783
  async push() {
787
- throw new Se();
784
+ throw new Te();
788
785
  }
789
786
  async delete() {
790
787
  try {
@@ -852,7 +849,7 @@ function _e(o, e, t, r, i) {
852
849
  return t.schema(i);
853
850
  }
854
851
  static query() {
855
- return new Ee(
852
+ return new Me(
856
853
  { config: o, route: r, model: t },
857
854
  i
858
855
  );
@@ -939,7 +936,7 @@ function _e(o, e, t, r, i) {
939
936
  }
940
937
  }, g(c, "name", y.studly(i)), c;
941
938
  }
942
- function Re(o, e, t) {
939
+ function _e(o, e, t) {
943
940
  var r, i;
944
941
  return class extends (i = t, r = Symbol.toStringTag, i) {
945
942
  constructor(m = {}) {
@@ -960,13 +957,13 @@ function Re(o, e, t) {
960
957
  if (o.hasReducer(`model${y.studly(c.getType())}Get${y.studly(u)}Attribute`)) {
961
958
  const s = o[`model${y.studly(c.getType())}Get${y.studly(u)}Attribute`];
962
959
  if (typeof s != "function")
963
- throw new E("ModelFacade");
960
+ throw new $("ModelFacade");
964
961
  return s.bind(o)(void 0, c);
965
962
  }
966
963
  return Reflect.get(c, u);
967
964
  },
968
965
  set: (c, u, s) => u in c && typeof c[u] != "function" ? Reflect.set(c, u, s) : (c.setAttribute(
969
- y.snake(u),
966
+ u,
970
967
  s
971
968
  ), !0)
972
969
  });
@@ -1119,7 +1116,7 @@ class ue extends k {
1119
1116
  this.items ? this.items.splice(0, this.items.count(), ...r) : this.items = r;
1120
1117
  }
1121
1118
  }
1122
- class N extends k {
1119
+ class A extends k {
1123
1120
  query() {
1124
1121
  const e = super.query(), t = this.guessInverseRelation();
1125
1122
  return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
@@ -1132,7 +1129,7 @@ class N extends k {
1132
1129
  e.setAttribute(this.getForeignKey(), this.parent.getKey()), await e.save();
1133
1130
  }
1134
1131
  }
1135
- class ke extends N {
1132
+ class Re extends A {
1136
1133
  constructor(e, t, r, i = null) {
1137
1134
  if (!p.isModel(i) && i !== null)
1138
1135
  throw new w("HasOne.constructor()", "Model or null");
@@ -1154,7 +1151,7 @@ class ke extends N {
1154
1151
  function K(o) {
1155
1152
  return new b(o);
1156
1153
  }
1157
- class Ae extends N {
1154
+ class ke extends A {
1158
1155
  constructor(e, t, r, i = null) {
1159
1156
  if (i !== null && !(i instanceof b && i.every(p.isModel)))
1160
1157
  throw new w("HasMany.constructor()", "Collection<Model> or null");
@@ -1192,7 +1189,7 @@ class Ae extends N {
1192
1189
  await this.saveQuietly(e), this.items === null ? this.items = K([e]) : this.items.push(e);
1193
1190
  }
1194
1191
  }
1195
- class he extends N {
1192
+ class he extends A {
1196
1193
  query() {
1197
1194
  const e = this.getRelated().query();
1198
1195
  e.once("success", (r) => {
@@ -1250,7 +1247,7 @@ class Ne extends he {
1250
1247
  await this.saveQuietly(e), this.items ? this.items.push(e) : this.items = await this.all();
1251
1248
  }
1252
1249
  }
1253
- class qe extends he {
1250
+ class Ae extends he {
1254
1251
  constructor(e, t, r, i = null) {
1255
1252
  if (super(e, t, r, i), this.services = e, this.meta = t, this.parent = r, this.items = i, i !== null && !p.isModel(i))
1256
1253
  throw new w("MorphOne.constructor()", "Model or null");
@@ -1268,7 +1265,7 @@ class qe extends he {
1268
1265
  await this.saveQuietly(e), this.items = e;
1269
1266
  }
1270
1267
  }
1271
- class Ke extends ae {
1268
+ class qe extends ae {
1272
1269
  getRelated() {
1273
1270
  return this.services.model.make(
1274
1271
  this.parent.getAttribute(this.getName() + "_type")
@@ -1297,7 +1294,7 @@ class Ke extends ae {
1297
1294
  });
1298
1295
  }
1299
1296
  }
1300
- class je extends ue {
1297
+ class Ke extends ue {
1301
1298
  query() {
1302
1299
  var r;
1303
1300
  const e = super.query(), t = `${(r = this.meta.morphType) == null ? void 0 : r.slice(0, -5)}_id`;
@@ -1305,7 +1302,7 @@ class je extends ue {
1305
1302
  }
1306
1303
  }
1307
1304
  var Y, Z;
1308
- class Oe extends (Z = A, Y = Symbol.toStringTag, Z) {
1305
+ class Oe extends (Z = N, Y = Symbol.toStringTag, Z) {
1309
1306
  constructor(t) {
1310
1307
  super();
1311
1308
  g(this, "_models", {});
@@ -1315,7 +1312,7 @@ class Oe extends (Z = A, Y = Symbol.toStringTag, Z) {
1315
1312
  boot(t) {
1316
1313
  this._schema && Object.keys(this._schema).forEach((r) => {
1317
1314
  const i = this[`model${y.studly(r)}`], l = this.model(
1318
- _e(
1315
+ Se(
1319
1316
  t.make("config"),
1320
1317
  t.make("log"),
1321
1318
  t.make("model"),
@@ -1324,7 +1321,7 @@ class Oe extends (Z = A, Y = Symbol.toStringTag, Z) {
1324
1321
  ),
1325
1322
  r
1326
1323
  ), m = i(l);
1327
- this._models[r] = Re(t.make("model"), r, m);
1324
+ this._models[r] = _e(t.make("model"), r, m);
1328
1325
  });
1329
1326
  }
1330
1327
  schema(t) {
@@ -1341,27 +1338,27 @@ class Oe extends (Z = A, Y = Symbol.toStringTag, Z) {
1341
1338
  return this.relationMap({
1342
1339
  BelongsTo: ae,
1343
1340
  BelongsToMany: ue,
1344
- HasOne: ke,
1345
- HasMany: Ae,
1341
+ HasOne: Re,
1342
+ HasMany: ke,
1346
1343
  MorphMany: Ne,
1347
- MorphOne: qe,
1348
- MorphTo: Ke,
1349
- MorphToMany: je
1344
+ MorphOne: Ae,
1345
+ MorphTo: qe,
1346
+ MorphToMany: Ke
1350
1347
  }, t);
1351
1348
  }
1352
1349
  toString() {
1353
1350
  return "model";
1354
1351
  }
1355
1352
  }
1356
- const Be = re(Oe);
1353
+ const je = re(Oe);
1357
1354
  var ee, te;
1358
- class Ce extends (te = Error, ee = Symbol.toStringTag, te) {
1355
+ class Be extends (te = Error, ee = Symbol.toStringTag, te) {
1359
1356
  constructor(t) {
1360
1357
  super(`[Luminix] Route "${t}" not found`);
1361
1358
  g(this, ee, "RouteNotFoundException");
1362
1359
  }
1363
1360
  }
1364
- class Ie {
1361
+ class Ce {
1365
1362
  constructor(e, t, r, i = "") {
1366
1363
  this.routes = e, this.error = t, this.http = r, this.appUrl = i;
1367
1364
  }
@@ -1380,7 +1377,7 @@ class Ie {
1380
1377
  }
1381
1378
  get(e) {
1382
1379
  if (!this.exists(e))
1383
- throw new Ce(e);
1380
+ throw new Be(e);
1384
1381
  return p.get(this.routes, e);
1385
1382
  }
1386
1383
  url(e) {
@@ -1390,7 +1387,7 @@ class Ie {
1390
1387
  const [t, r] = this.extractGenerator(e), i = this.get(t)[0].replace(/^\/|\/$/g, ""), l = /{([^}]+)}/g;
1391
1388
  if (r === !1) {
1392
1389
  if (typeof this.replaceRouteParams != "function")
1393
- throw new E("RouteFacade");
1390
+ throw new $("RouteFacade");
1394
1391
  return this.replaceRouteParams(`/${i}`);
1395
1392
  }
1396
1393
  const m = i.match(l), c = m ? m.map((h) => h.slice(1, -1)) : [], u = Object.keys(r), s = c.filter((h) => !u.includes(h)), n = u.filter((h) => !c.includes(h));
@@ -1410,7 +1407,7 @@ class Ie {
1410
1407
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1411
1408
  async call(e, t = (i) => i, r = "default") {
1412
1409
  if (typeof this.clientOptions != "function" || typeof this.clientError != "function")
1413
- throw new E("RouteFacade");
1410
+ throw new $("RouteFacade");
1414
1411
  const [i, l] = this.extractGenerator(e), [, ...m] = this.get(i), c = this.url(l ? [i, l] : i), u = t(this.http()), s = this.clientOptions({}, i);
1415
1412
  p.isEmpty(s) || u.withOptions(s);
1416
1413
  const n = m[0] ?? s.method;
@@ -1434,10 +1431,10 @@ class Ie {
1434
1431
  return "route";
1435
1432
  }
1436
1433
  }
1437
- const Pe = re(Ie);
1438
- class Qe {
1434
+ const Ie = re(Ce);
1435
+ class Pe {
1439
1436
  getClient() {
1440
- return new ye();
1437
+ return new me();
1441
1438
  }
1442
1439
  baseUrl(e) {
1443
1440
  return this.getClient().baseUrl(e);
@@ -1490,9 +1487,9 @@ class Qe {
1490
1487
  return this.getClient().delete(e, t);
1491
1488
  }
1492
1489
  }
1493
- const Le = ne(Qe);
1490
+ const Qe = ne(Pe);
1494
1491
  var se, ie;
1495
- class De extends (ie = me, se = Symbol.toStringTag, ie) {
1492
+ class Le extends (ie = ye, se = Symbol.toStringTag, ie) {
1496
1493
  constructor() {
1497
1494
  super(...arguments);
1498
1495
  g(this, se, "LuminixServiceProvider");
@@ -1506,24 +1503,24 @@ class De extends (ie = me, se = Symbol.toStringTag, ie) {
1506
1503
  this.app.make("model").boot(this.app);
1507
1504
  }
1508
1505
  registerServices() {
1509
- this.app.singleton("auth", () => new ve(
1506
+ this.app.singleton("auth", () => new we(
1510
1507
  this.app.make("config"),
1511
1508
  this.app.make("model"),
1512
1509
  this.app.make("route")
1513
1510
  )), this.app.singleton("config", () => {
1514
1511
  const t = new _(p.omit(this.app.configuration, "manifest"));
1515
1512
  return t.has("auth.user") || t.set("auth.user", null), t.lock("auth.user"), t;
1516
- }), this.app.singleton("error", () => new be()), this.app.singleton("http", () => new Le()), this.app.singleton("log", () => {
1513
+ }), this.app.singleton("error", () => new ve()), this.app.singleton("http", () => new Qe()), this.app.singleton("log", () => {
1517
1514
  var t;
1518
- return new xe(((t = this.app.configuration.app) == null ? void 0 : t.debug) ?? !1);
1515
+ return new be(((t = this.app.configuration.app) == null ? void 0 : t.debug) ?? !1);
1519
1516
  }), this.app.singleton("model", () => {
1520
1517
  var t;
1521
- return new Be(
1518
+ return new je(
1522
1519
  ((t = this.app.configuration.manifest) == null ? void 0 : t.models) ?? {}
1523
1520
  );
1524
1521
  }), this.app.singleton("route", () => {
1525
1522
  var t, r;
1526
- return new Pe(
1523
+ return new Ie(
1527
1524
  ((t = this.app.configuration.manifest) == null ? void 0 : t.routes) ?? {},
1528
1525
  this.app.make("error"),
1529
1526
  () => this.app.make("http").getClient(),
@@ -1537,13 +1534,13 @@ class De extends (ie = me, se = Symbol.toStringTag, ie) {
1537
1534
  });
1538
1535
  }
1539
1536
  }
1540
- class He {
1537
+ class De {
1541
1538
  constructor() {
1542
1539
  g(this, "app");
1543
1540
  }
1544
1541
  getFacadeAccessor() {
1545
1542
  return this.app || (this.app = new (ne(fe))([
1546
- De
1543
+ Le
1547
1544
  ])), this.app;
1548
1545
  }
1549
1546
  down() {
@@ -1553,101 +1550,89 @@ class He {
1553
1550
  this.down(), this.app = e;
1554
1551
  }
1555
1552
  }
1556
- const x = M(He);
1557
- function $(o = void 0) {
1553
+ const x = M(De);
1554
+ function E(o = void 0) {
1558
1555
  return typeof o != "string" ? x : x.make(o);
1559
1556
  }
1560
- function Ze() {
1561
- return $("auth");
1557
+ function Ye() {
1558
+ return E("auth");
1562
1559
  }
1563
- function et(o, e) {
1564
- const t = $("config");
1560
+ function Ze(o, e) {
1561
+ const t = E("config");
1565
1562
  return typeof o > "u" ? t : t.get(o, e);
1566
1563
  }
1567
- function tt(o, e = "default") {
1568
- return o ? $().make("error").get(o, e) : $().make("error");
1564
+ function et(o, e = "default") {
1565
+ return o ? E().make("error").get(o, e) : E().make("error");
1569
1566
  }
1570
- function st(...o) {
1571
- const e = $("log");
1567
+ function tt(...o) {
1568
+ const e = E("log");
1572
1569
  return o.length ? e.debug(...o) : e;
1573
1570
  }
1574
- function it(o) {
1575
- const e = $("model");
1571
+ function st(o) {
1572
+ const e = E("model");
1576
1573
  return o ? e.make(o) : e;
1577
1574
  }
1578
- function rt(o, e = !1) {
1579
- const t = $("route");
1575
+ function it(o, e = !1) {
1576
+ const t = E("route");
1580
1577
  return o ? e ? t.url([o, e]) : t.url(o) : t;
1581
1578
  }
1582
- class Je {
1579
+ class He {
1583
1580
  getFacadeAccessor() {
1584
1581
  return "auth";
1585
1582
  }
1586
1583
  }
1587
- const nt = M(Je, x);
1588
- class Ue {
1584
+ const rt = M(He, x);
1585
+ class Je {
1589
1586
  getFacadeAccessor() {
1590
1587
  return "config";
1591
1588
  }
1592
1589
  }
1593
- const ot = M(Ue, x), at = (o) => o instanceof we && o.unprocessableEntity() && typeof o.json("message") == "string" && typeof o.json("errors") == "object" && o.json("errors") !== null && Object.values(o.json("errors")).every((e) => Array.isArray(e) && e.every((t) => typeof t == "string"));
1594
- class Fe {
1590
+ const nt = M(Je, x);
1591
+ class Ue {
1595
1592
  getFacadeAccessor() {
1596
1593
  return "error";
1597
1594
  }
1598
1595
  }
1599
- const ut = M(Fe, x);
1600
- class We {
1596
+ const ot = M(Ue, x);
1597
+ class Fe {
1601
1598
  getFacadeAccessor() {
1602
1599
  return "http";
1603
1600
  }
1604
1601
  }
1605
- const ht = M(We, x);
1606
- class Ge {
1602
+ const at = M(Fe, x);
1603
+ class We {
1607
1604
  getFacadeAccessor() {
1608
1605
  return "log";
1609
1606
  }
1610
1607
  }
1611
- const lt = M(Ge, x);
1612
- class Ve {
1608
+ const ut = M(We, x);
1609
+ class Ge {
1613
1610
  getFacadeAccessor() {
1614
1611
  return "model";
1615
1612
  }
1616
1613
  }
1617
- const ct = M(Ve, x);
1618
- class ze {
1614
+ const ht = M(Ge, x);
1615
+ class Ve {
1619
1616
  getFacadeAccessor() {
1620
1617
  return "route";
1621
1618
  }
1622
1619
  }
1623
- const dt = M(ze, x);
1624
- class pt {
1625
- constructor() {
1626
- g(this, "name");
1627
- g(this, "version");
1628
- }
1629
- register(e) {
1630
- }
1631
- boot(e) {
1632
- }
1633
- }
1620
+ const lt = M(Ve, x);
1634
1621
  export {
1635
1622
  x as App,
1636
- nt as Auth,
1637
- ot as Config,
1638
- ut as Error,
1639
- ht as Http,
1640
- lt as Log,
1641
- ct as Model,
1642
- pt as Plugin,
1643
- dt as Route,
1644
- $ as app,
1645
- Ze as auth,
1623
+ rt as Auth,
1624
+ nt as Config,
1625
+ ot as Error,
1626
+ at as Http,
1627
+ ut as Log,
1628
+ ht as Model,
1629
+ lt as Route,
1630
+ E as app,
1631
+ Ye as auth,
1646
1632
  K as collect,
1647
- et as config,
1648
- tt as error,
1649
- at as isValidationError,
1650
- st as log,
1651
- it as model,
1652
- rt as route
1633
+ Ze as config,
1634
+ et as error,
1635
+ tt as log,
1636
+ st as model,
1637
+ it as route
1653
1638
  };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@luminix/core",
3
- "version": "0.4.8",
3
+ "version": "1.0.0",
4
4
  "main": "dist/core.js",
5
5
  "module": "dist/core.js",
6
6
  "types": "types/index.d.ts",
7
7
  "type": "module",
8
+ "repository": "luminix-cms/js-core",
8
9
  "scripts": {
9
10
  "prebuild": "rm -rf types",
10
11
  "build": "tsc && vite build",
@@ -37,6 +38,6 @@
37
38
  "vite-plugin-dts": "^4.0.0-beta.1"
38
39
  },
39
40
  "peerDependencies": {
40
- "@luminix/support": "^0.4.9"
41
+ "@luminix/support": "^1.0.0"
41
42
  }
42
43
  }
@@ -1,8 +1,5 @@
1
- import { HasFacadeAccessor, Response } from '@luminix/support';
2
- import { ValidationError } from '../types/Error';
1
+ import { HasFacadeAccessor } from '@luminix/support';
3
2
  import { default as ErrorService } from '../services/ErrorService';
4
- /** @deprecated */
5
- export declare const isValidationError: (response: unknown) => response is Response<ValidationError, any>;
6
3
  declare class ErrorFacade implements HasFacadeAccessor {
7
4
  getFacadeAccessor(): string | object;
8
5
  }
package/types/index.d.ts CHANGED
@@ -9,13 +9,12 @@ import { default as route } from './helpers/route';
9
9
  import { default as App } from './facades/App';
10
10
  import { default as Auth } from './facades/Auth';
11
11
  import { default as Config } from './facades/Config';
12
- import { default as Error, isValidationError } from './facades/Error';
12
+ import { default as Error } from './facades/Error';
13
13
  import { default as Http } from './facades/Http';
14
14
  import { default as Log } from './facades/Log';
15
15
  import { default as Model } from './facades/Model';
16
16
  import { default as Route } from './facades/Route';
17
- import { default as Plugin } from './contracts/Plugin';
18
- export { app, App, auth, Auth, collect, config, Config, error, Error, Http, log, Log, model, Model, route, Route, isValidationError, Plugin, };
17
+ export { app, App, auth, Auth, collect, config, Config, error, Error, Http, log, Log, model, Model, route, Route, };
19
18
  export type { AppFacade, AppEvents, AppContainers } from './types/App';
20
19
  export type { AuthFacade } from './types/Auth';
21
20
  export type { BuilderInterface, Scope } from './types/Builder';
@@ -1,6 +1,5 @@
1
1
  import { EventSource, Event, ReducibleInterface, FacadeOf, HasFacadeAccessor, Application, MacroableInterface, Constructor } from '@luminix/support';
2
2
  import { AppConfiguration, ConfigFacade } from './Config';
3
- import { PluginInterface } from './Plugin';
4
3
  import { LogFacade } from './Log';
5
4
  import { BaseModel, Model, ModelPaginatedResponse, ModelReducers, ModelSchema, ModelSchemaAttributes } from './Model';
6
5
  import { RouteFacade } from './Route';
@@ -8,7 +7,6 @@ import { ErrorFacade } from './Error';
8
7
  import { RelationInterface } from './Relation';
9
8
  import { AuthFacade } from './Auth';
10
9
  import { HttpFacade } from './Http';
11
- type Plugin = PluginInterface<AppFacade, AppContainers>;
12
10
  export type GlobalModelEvents = {
13
11
  'save': (e: ModelGlobalEvent) => void;
14
12
  'delete': (e: ModelGlobalEvent) => void;
@@ -85,4 +83,3 @@ export type AppMacros = {
85
83
  isLocal(): boolean;
86
84
  isProduction(): boolean;
87
85
  };
88
- export {};
@@ -1,8 +0,0 @@
1
- import { AppFacade, AppContainers } from '../types/App';
2
- /** @deprecated */
3
- export default abstract class Plugin {
4
- readonly name?: string;
5
- readonly version?: string;
6
- register(_app: AppFacade): void;
7
- boot(_facades: AppContainers): void;
8
- }
@@ -1,4 +0,0 @@
1
- export type PluginInterface<A, F> = {
2
- register(app: A): void;
3
- boot(facades: F): void;
4
- };