@luminix/core 1.0.3 → 1.0.4

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,24 +1,24 @@
1
- var ce = Object.defineProperty;
2
- var de = (o, e, t) => e in o ? ce(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var g = (o, e, t) => de(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { reader as pe, PropertyBag as _, EventSource as k, Collection as b, Query as S, Obj as p, Str as m, Reducible as re, isValidationError as ge, Macroable as ne, Client as ye, ServiceProvider as me, MakeFacade as M, Application as fe } from "@luminix/support";
5
- class we {
6
- constructor(e, t, r) {
1
+ var pe = Object.defineProperty;
2
+ var ge = (o, t, e) => t in o ? pe(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var g = (o, t, e) => ge(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { reader as me, PropertyBag as _, EventSource as A, Collection as b, Query as T, Obj as p, Str as y, Reducible as oe, isValidationError as ye, Macroable as ae, Client as fe, ServiceProvider as we, MakeFacade as M, Application as ve } from "@luminix/support";
5
+ class be {
6
+ constructor(t, e, r) {
7
7
  g(this, "_user");
8
- this.config = e, this.model = t, this.route = r;
8
+ this.config = t, this.model = e, this.route = r;
9
9
  }
10
- attempt(e, t = !1, r) {
10
+ attempt(t, e = !1, r) {
11
11
  const i = document.createElement("form");
12
12
  i.method = "post", i.action = this.route.url("login"), i.style.display = "none";
13
- const l = this.config.get("auth.csrf");
14
- if (typeof l == "string") {
13
+ const h = this.config.get("auth.csrf");
14
+ if (typeof h == "string") {
15
15
  const u = document.createElement("input");
16
- u.type = "hidden", u.name = "_token", u.value = l, i.appendChild(u);
16
+ u.type = "hidden", u.name = "_token", u.value = h, i.appendChild(u);
17
17
  }
18
- const y = document.createElement("input");
19
- y.type = "email", y.name = "email", y.value = e.email, i.appendChild(y);
18
+ const m = document.createElement("input");
19
+ m.type = "email", m.name = "email", m.value = t.email, i.appendChild(m);
20
20
  const c = document.createElement("input");
21
- if (c.type = "password", c.name = "password", c.value = e.password, i.appendChild(c), t) {
21
+ if (c.type = "password", c.name = "password", c.value = t.password, i.appendChild(c), e) {
22
22
  const u = document.createElement("input");
23
23
  u.type = "checkbox", u.name = "remember", u.value = "1", u.checked = !0, i.appendChild(u);
24
24
  }
@@ -27,133 +27,142 @@ class we {
27
27
  check() {
28
28
  return !!this.config.get("auth.user");
29
29
  }
30
- logout(e) {
31
- const t = document.createElement("form");
32
- t.method = "post", t.action = this.route.url("logout"), t.style.display = "none";
30
+ logout(t) {
31
+ const e = document.createElement("form");
32
+ e.method = "post", e.action = this.route.url("logout"), e.style.display = "none";
33
33
  const r = this.config.get("auth.csrf");
34
34
  if (typeof r == "string") {
35
35
  const i = document.createElement("input");
36
- i.type = "hidden", i.name = "_token", i.value = r, t.appendChild(i);
36
+ i.type = "hidden", i.name = "_token", i.value = r, e.appendChild(i);
37
37
  }
38
- document.body.appendChild(t), e && t.addEventListener("submit", e), t.submit();
38
+ document.body.appendChild(e), t && e.addEventListener("submit", t), e.submit();
39
39
  }
40
40
  user() {
41
41
  if (!this._user) {
42
- const e = this.model.make("user"), t = this.config.get("auth.user");
43
- if (!t)
42
+ const t = this.model.make("user"), e = this.config.get("auth.user");
43
+ if (!e)
44
44
  return;
45
- this._user = new e(t), this._user.exists = !0;
45
+ this._user = new t(e), this._user.exists = !0;
46
46
  }
47
47
  return this._user;
48
48
  }
49
49
  id() {
50
- var e;
51
- return ((e = this.user()) == null ? void 0 : e.getKey()) || null;
50
+ var t;
51
+ return ((t = this.user()) == null ? void 0 : t.getKey()) || null;
52
52
  }
53
53
  }
54
- class ve {
54
+ class xe {
55
55
  constructor() {
56
56
  g(this, "bags");
57
- const e = {};
57
+ const t = {};
58
58
  document.querySelectorAll('#luminix-embed [id^="luminix-error"]').forEach((r) => {
59
- const l = r.id.replace("luminix-error::", "");
60
- e[l] = pe(l, "error");
59
+ const h = r.id.replace("luminix-error::", "");
60
+ t[h] = me(h, "error");
61
61
  }), this.bags = {
62
- default: new _(e)
62
+ default: new _(t)
63
63
  };
64
64
  }
65
- bag(e = "default") {
66
- return this.bags[e] || (this.bags[e] = new _({})), this.bags[e];
65
+ bag(t = "default") {
66
+ return this.bags[t] || (this.bags[t] = new _({})), this.bags[t];
67
67
  }
68
- add(e, t, r = "default") {
69
- this.bag(r).set(e, t);
68
+ add(t, e, r = "default") {
69
+ this.bag(r).set(t, e);
70
70
  }
71
- set(e, t = "default") {
72
- this.bag(t).set(".", e);
71
+ set(t, e = "default") {
72
+ this.bag(e).set(".", t);
73
73
  }
74
- all(e = "default") {
75
- return this.bag(e).all();
74
+ all(t = "default") {
75
+ return this.bag(t).all();
76
76
  }
77
- get(e, t = "default") {
78
- return this.bag(t).get(e, null);
77
+ get(t, e = "default") {
78
+ return this.bag(e).get(t, null);
79
79
  }
80
- clear(e = "default") {
81
- this.bag(e).set(".", {});
80
+ clear(t = "default") {
81
+ this.bag(t).set(".", {});
82
82
  }
83
83
  }
84
- class be {
85
- constructor(e) {
86
- this._debug = e;
84
+ class Me {
85
+ constructor(t) {
86
+ this._debug = t;
87
87
  }
88
- emergency(...e) {
89
- this._debug && console.error(...e);
88
+ emergency(...t) {
89
+ this._debug && console.error(...t);
90
90
  }
91
- alert(...e) {
92
- this._debug && console.error(...e);
91
+ alert(...t) {
92
+ this._debug && console.error(...t);
93
93
  }
94
- critical(...e) {
95
- this._debug && console.error(...e);
94
+ critical(...t) {
95
+ this._debug && console.error(...t);
96
96
  }
97
- error(...e) {
98
- this._debug && console.error(...e);
97
+ error(...t) {
98
+ this._debug && console.error(...t);
99
99
  }
100
- warning(...e) {
101
- this._debug && console.warn(...e);
100
+ warning(...t) {
101
+ this._debug && console.warn(...t);
102
102
  }
103
- notice(...e) {
104
- this._debug && console.info(...e);
103
+ notice(...t) {
104
+ this._debug && console.info(...t);
105
105
  }
106
- info(...e) {
107
- this._debug && console.info(...e);
106
+ info(...t) {
107
+ this._debug && console.info(...t);
108
108
  }
109
- debug(...e) {
110
- this._debug && console.debug(...e);
109
+ debug(...t) {
110
+ this._debug && console.debug(...t);
111
111
  }
112
112
  }
113
113
  var O, j;
114
- class xe extends (j = Error, O = Symbol.toStringTag, j) {
115
- constructor(t) {
116
- super(`[Luminix] Model "${t}" does not have a primary key`);
117
- g(this, O, "ModelWithoutPrimaryKeyException");
114
+ class Ee extends (j = Error, O = Symbol.toStringTag, j) {
115
+ constructor(e, r) {
116
+ const i = r.json("message");
117
+ super(`[Luminix] Query for model "${e}" failed with status ${r.status()}` + (typeof i == "string" && i !== "" ? `: ${i}` : ""));
118
+ g(this, O, "ModelQueryFailedException");
119
+ this.response = r;
118
120
  }
119
121
  }
120
- class Me extends k {
121
- constructor(t, r, i = {}) {
122
+ var B, C;
123
+ class $e extends (C = Error, B = Symbol.toStringTag, C) {
124
+ constructor(e) {
125
+ super(`[Luminix] Model "${e}" does not have a primary key`);
126
+ g(this, B, "ModelWithoutPrimaryKeyException");
127
+ }
128
+ }
129
+ class Se extends A {
130
+ constructor(e, r, i = {}) {
122
131
  super();
123
132
  g(this, "bag");
124
- this.services = t, this.abstract = r, this.bag = new _(i), this.bag.on("change", () => {
133
+ this.services = e, this.abstract = r, this.bag = new _(i), this.bag.on("change", () => {
125
134
  this.emit("change", {
126
135
  data: this.bag,
127
136
  source: this
128
137
  });
129
138
  });
130
139
  }
131
- lock(t) {
132
- this.bag.lock(t);
140
+ lock(e) {
141
+ this.bag.lock(e);
133
142
  }
134
- whereBetween(t, r) {
135
- return this.where(t, "between", r);
143
+ whereBetween(e, r) {
144
+ return this.where(e, "between", r);
136
145
  }
137
- whereNotBetween(t, r) {
138
- return this.where(t, "notBetween", r);
146
+ whereNotBetween(e, r) {
147
+ return this.where(e, "notBetween", r);
139
148
  }
140
- whereNull(t) {
141
- return this.where(t, "null", null);
149
+ whereNull(e) {
150
+ return this.where(e, "null", null);
142
151
  }
143
- whereNotNull(t) {
144
- return this.where(t, "notNull", null);
152
+ whereNotNull(e) {
153
+ return this.where(e, "notNull", null);
145
154
  }
146
- limit(t) {
147
- return this.bag.set("per_page", t), this;
155
+ limit(e) {
156
+ return this.bag.set("per_page", e), this;
148
157
  }
149
- where(t, r, i) {
150
- if (this.bag.has("where") || this.bag.set("where", {}), typeof t == "function")
151
- return t(this) || this;
158
+ where(e, r, i) {
159
+ if (this.bag.has("where") || this.bag.set("where", {}), typeof e == "function")
160
+ return e(this) || this;
152
161
  if (typeof i > "u")
153
- return this.bag.set(`where.${t}`, r), this;
162
+ return this.bag.set(`where.${e}`, r), this;
154
163
  if (typeof r != "string")
155
164
  throw new Error(`Invalid operator ${r} provided for where clause.`);
156
- const y = {
165
+ const m = {
157
166
  "=": "",
158
167
  "!=": "notEquals",
159
168
  ">": "greaterThan",
@@ -161,55 +170,58 @@ class Me extends k {
161
170
  "<": "lessThan",
162
171
  "<=": "lessThanOrEquals"
163
172
  }[r] || r;
164
- return this.bag.set(`where.${t}:${y}`, i), this;
173
+ return this.bag.set(`where.${e}:${m}`, i), this;
165
174
  }
166
- with(t) {
175
+ with(e) {
167
176
  const r = this.bag.get("with", []);
168
- return (Array.isArray(t) ? t : [t]).forEach((l) => {
169
- r.includes(l) || r.push(l);
177
+ return (Array.isArray(e) ? e : [e]).forEach((h) => {
178
+ r.includes(h) || r.push(h);
170
179
  }), this.bag.set("with", r), this;
171
180
  }
172
- withOnly(t) {
173
- return this.bag.set("with", Array.isArray(t) ? t : [t]), this;
181
+ withOnly(e) {
182
+ return this.bag.set("with", Array.isArray(e) ? e : [e]), this;
174
183
  }
175
- without(t) {
184
+ without(e) {
176
185
  const r = this.bag.get("with", []);
177
- return (Array.isArray(t) ? t : [t]).forEach((l) => {
178
- r.includes(l) && r.splice(r.indexOf(l), 1);
186
+ return (Array.isArray(e) ? e : [e]).forEach((h) => {
187
+ r.includes(h) && r.splice(r.indexOf(h), 1);
179
188
  }), this.bag.set("with", r), this;
180
189
  }
181
- orderBy(t, r = "asc") {
182
- return this.bag.set("order_by", `${t}:${r}`), this;
190
+ orderBy(e, r = "asc") {
191
+ return this.bag.set("order_by", `${e}:${r}`), this;
183
192
  }
184
- searchBy(t) {
185
- return t === "" ? (this.bag.delete("q"), this) : (this.bag.set("q", t), this);
193
+ searchBy(e) {
194
+ return e === "" ? (this.bag.delete("q"), this) : (this.bag.set("q", e), this);
186
195
  }
187
196
  minified() {
188
197
  return this.bag.set("minified", 1), this;
189
198
  }
190
- unset(t) {
191
- return this.bag.delete(t), this;
199
+ unset(e) {
200
+ return this.bag.delete(e), this;
192
201
  }
193
- include(t) {
194
- for (const [r, i] of t.entries())
202
+ include(e) {
203
+ for (const [r, i] of e.entries())
195
204
  this.bag.set(r, i);
196
205
  return this;
197
206
  }
198
- async exec(t = {}) {
207
+ async exec(e = {}) {
199
208
  try {
200
209
  const {
201
210
  page: r = 1,
202
211
  replaceLinks: i = !1
203
- } = t;
212
+ } = e;
204
213
  this.bag.set("page", r), this.emit("submit", {
205
214
  data: this.bag,
206
215
  source: this
207
216
  });
208
- const l = await this.services.route.call(
217
+ const h = await this.services.route.call(
209
218
  `luminix.${this.abstract}.index`,
210
219
  (u) => u.withQueryParameters(this.bag.all())
211
- ), y = this.services.model.make(this.abstract), c = new b(l.json("data").map((u) => {
212
- const s = new y(u);
220
+ );
221
+ if (h.failed())
222
+ throw new Ee(this.abstract, h);
223
+ const m = this.services.model.make(this.abstract), c = new b(h.json("data").map((u) => {
224
+ const s = new m(u);
213
225
  return s.exists = !0, this.services.model.emit("fetch", {
214
226
  class: this.abstract,
215
227
  model: s,
@@ -219,25 +231,25 @@ class Me extends k {
219
231
  if (i) {
220
232
  const u = window.location.href, [s] = u.split("?");
221
233
  return {
222
- ...l.json(),
234
+ ...h.json(),
223
235
  data: c,
224
236
  links: {
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()}`
237
+ first: `${s}?${T.merge(u, h.json("links").first).toString()}`,
238
+ last: `${s}?${T.merge(u, h.json("links").last).toString()}`,
239
+ next: h.json("links").next && `${s}?${T.merge(u, h.json("links").next ?? "").toString()}`,
240
+ prev: h.json("links").prev && `${s}?${T.merge(u, h.json("links").prev ?? "").toString()}`
229
241
  },
230
242
  meta: {
231
- ...l.json("meta"),
232
- links: l.json("meta").links.map((n) => ({
243
+ ...h.json("meta"),
244
+ links: h.json("meta").links.map((n) => ({
233
245
  ...n,
234
- url: n.url && `${s}?${S.merge(u, n.url).toString()}`
246
+ url: n.url && `${s}?${T.merge(u, n.url).toString()}`
235
247
  }))
236
248
  }
237
249
  };
238
250
  }
239
251
  return {
240
- ...l.json(),
252
+ ...h.json(),
241
253
  data: c
242
254
  };
243
255
  } catch (r) {
@@ -247,8 +259,8 @@ class Me extends k {
247
259
  }), r;
248
260
  }
249
261
  }
250
- async get(t = {}) {
251
- const r = await this.exec(t);
262
+ async get(e = {}) {
263
+ const r = await this.exec(e);
252
264
  return this.emit("success", {
253
265
  response: r,
254
266
  items: r.data,
@@ -256,18 +268,18 @@ class Me extends k {
256
268
  }), r;
257
269
  }
258
270
  async first() {
259
- const t = await this.limit(1).exec();
271
+ const e = await this.limit(1).exec();
260
272
  return this.emit("success", {
261
- response: t,
262
- items: t.data.first(),
273
+ response: e,
274
+ items: e.data.first(),
263
275
  source: this
264
- }), t.data.first();
276
+ }), e.data.first();
265
277
  }
266
- async find(t) {
278
+ async find(e) {
267
279
  const r = this.services.model.schema(this.abstract).primaryKey;
268
280
  if (!r)
269
- throw new xe(this.abstract);
270
- const i = await this.where(r, t).limit(1).exec();
281
+ throw new $e(this.abstract);
282
+ const i = await this.where(r, e).limit(1).exec();
271
283
  return this.emit("success", {
272
284
  response: i,
273
285
  items: i.data.sole(),
@@ -275,13 +287,13 @@ class Me extends k {
275
287
  }), i.data.sole();
276
288
  }
277
289
  async all() {
278
- const t = this.services.config.get("luminix.backend.api.max_per_page", 150), r = await this.limit(t).exec(), i = r.meta.last_page;
290
+ const e = this.services.config.get("luminix.backend.api.max_per_page", 150), r = await this.limit(e).exec(), i = r.meta.last_page;
279
291
  if (i === 1)
280
292
  return r.data;
281
- const l = Array.from({ length: i - 1 }, (u, s) => s + 2), y = await Promise.all(
282
- l.map((u) => this.limit(t).exec({ page: u }))
293
+ const h = Array.from({ length: i - 1 }, (u, s) => s + 2), m = await Promise.all(
294
+ h.map((u) => this.limit(e).exec({ page: u }))
283
295
  ), c = new b(
284
- y.reduce((u, s) => (u.push(...s.data), u), r.data).all()
296
+ m.reduce((u, s) => (u.push(...s.data), u), r.data).all()
285
297
  );
286
298
  return this.emit("success", {
287
299
  response: {
@@ -293,52 +305,52 @@ class Me extends k {
293
305
  }), c;
294
306
  }
295
307
  }
296
- var B, C;
297
- class w extends (C = TypeError, B = Symbol.toStringTag, C) {
298
- constructor(t, r = "Model") {
299
- super(`[Luminix] "${t}" expects ${r}`);
300
- g(this, B, "NotModelException");
308
+ var Q, I;
309
+ class w extends (I = TypeError, Q = Symbol.toStringTag, I) {
310
+ constructor(e, r = "Model") {
311
+ super(`[Luminix] "${e}" expects ${r}`);
312
+ g(this, Q, "NotModelException");
301
313
  }
302
314
  }
303
- var I, P;
304
- class Ee extends (P = Error, I = Symbol.toStringTag, P) {
305
- constructor(t, r, i, l) {
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
- g(this, I, "NoInverseRelationException");
315
+ var P, L;
316
+ class Te extends (L = Error, P = Symbol.toStringTag, L) {
317
+ constructor(e, r, i, h) {
318
+ super(`[Luminix] Could not determine inverse relation for "${r}" in model "${e}". Please specify a relation in model "${i}" of type ${h} that points back to "${e}".`);
319
+ g(this, P, "NoInverseRelationException");
308
320
  }
309
321
  }
310
- var Q, L;
311
- class $e extends (L = Error, Q = Symbol.toStringTag, L) {
312
- constructor(t) {
313
- super(`[Luminix] Relation "${t}" is not supported`);
314
- g(this, Q, "UnsupportedRelationException");
322
+ var D, H;
323
+ class _e extends (H = Error, D = Symbol.toStringTag, H) {
324
+ constructor(e) {
325
+ super(`[Luminix] Relation "${e}" is not supported`);
326
+ g(this, D, "UnsupportedRelationException");
315
327
  }
316
328
  }
317
329
  class N {
318
- constructor(e, t, r, i = null) {
330
+ constructor(t, e, r, i = null) {
319
331
  g(this, "unsubscribeQuery", null);
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)))
332
+ if (this.services = t, this.meta = e, this.parent = r, this.items = i, i !== null && !p.isModel(i) && !(i instanceof b && i.every(p.isModel)))
321
333
  throw new w("Relation.constructor()", "Model, Collection<Model> or null");
322
334
  }
323
- make(e) {
324
- if (e === null || typeof e > "u") {
335
+ make(t) {
336
+ if (t === null || typeof t > "u") {
325
337
  this.set(null);
326
338
  return;
327
339
  }
328
- const t = this.getRelated();
340
+ const e = this.getRelated();
329
341
  if (this.isSingle()) {
330
- if (typeof e != "object" || Array.isArray(e))
342
+ if (typeof t != "object" || Array.isArray(t))
331
343
  throw new TypeError("Relation.make() expects an object");
332
- this.set(new t(e));
344
+ this.set(new e(t));
333
345
  }
334
346
  if (this.isMultiple()) {
335
- if (!Array.isArray(e))
347
+ if (!Array.isArray(t))
336
348
  throw new TypeError("Relation.make() expects an array");
337
- this.set(new b(e.map((r) => new t(r))));
349
+ this.set(new b(t.map((r) => new e(r))));
338
350
  }
339
351
  }
340
352
  guessInverseRelation() {
341
- const { relations: e } = this.getRelated().getSchema(), t = this.getType(), r = this.services.model.guessInverseRelation({
353
+ const { relations: t } = this.getRelated().getSchema(), e = this.getType(), r = this.services.model.guessInverseRelation({
342
354
  HasOne: ["BelongsTo"],
343
355
  HasMany: ["BelongsTo"],
344
356
  BelongsTo: ["HasOne", "HasMany"],
@@ -347,20 +359,20 @@ class N {
347
359
  MorphOne: ["MorphTo"],
348
360
  MorphMany: ["MorphTo"],
349
361
  MorphToMany: ["MorphToMany"]
350
- }, this.parent, t, this.getRelated());
351
- if (!(t in r))
352
- throw new $e(t);
353
- for (const i in e) {
354
- const l = e[i];
355
- if ((l.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(t)) && r[t].includes(l.type))
362
+ }, this.parent, e, this.getRelated());
363
+ if (!(e in r))
364
+ throw new _e(e);
365
+ for (const i in t) {
366
+ const h = t[i];
367
+ if ((h.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(e)) && r[e].includes(h.type))
356
368
  return i;
357
369
  }
358
- throw new Ee(this.parent.getType(), t, this.getRelated().getSchemaName(), r[t].join(" or "));
370
+ throw new Te(this.parent.getType(), e, this.getRelated().getSchemaName(), r[e].join(" or "));
359
371
  }
360
- set(e) {
361
- if (e !== null && !p.isModel(e) && !(e instanceof b && e.every(p.isModel)))
372
+ set(t) {
373
+ if (t !== null && !p.isModel(t) && !(t instanceof b && t.every(p.isModel)))
362
374
  throw new w("Relation.set()", "Model, Collection<Model> or null");
363
- !this.items || p.isModel(this.items) ? this.items = e : e instanceof b && this.items.splice(0, this.items.count(), ...e);
375
+ !this.items || p.isModel(this.items) ? this.items = t : t instanceof b && this.items.splice(0, this.items.count(), ...t);
364
376
  }
365
377
  getForeignKey() {
366
378
  return this.meta.foreignKey;
@@ -378,10 +390,10 @@ class N {
378
390
  return this.services.model.make(this.meta.model);
379
391
  }
380
392
  query() {
381
- const e = this.getRelated().query();
382
- return this.unsubscribeQuery && this.unsubscribeQuery(), this.unsubscribeQuery = e.on("success", (t) => {
383
- this.items = t.items;
384
- }), e;
393
+ const t = this.getRelated().query();
394
+ return this.unsubscribeQuery && this.unsubscribeQuery(), this.unsubscribeQuery = t.on("success", (e) => {
395
+ this.items = e.items;
396
+ }), t;
385
397
  }
386
398
  isLoaded() {
387
399
  return this.items !== null;
@@ -398,32 +410,32 @@ class N {
398
410
  getParent() {
399
411
  return this.parent;
400
412
  }
401
- where(...e) {
402
- return this.query().where(...e);
413
+ where(...t) {
414
+ return this.query().where(...t);
403
415
  }
404
- whereNull(e) {
405
- return this.query().whereNull(e);
416
+ whereNull(t) {
417
+ return this.query().whereNull(t);
406
418
  }
407
- whereNotNull(e) {
408
- return this.query().whereNotNull(e);
419
+ whereNotNull(t) {
420
+ return this.query().whereNotNull(t);
409
421
  }
410
- whereBetween(e, t) {
411
- return this.query().whereBetween(e, t);
422
+ whereBetween(t, e) {
423
+ return this.query().whereBetween(t, e);
412
424
  }
413
- whereNotBetween(e, t) {
414
- return this.query().whereNotBetween(e, t);
425
+ whereNotBetween(t, e) {
426
+ return this.query().whereNotBetween(t, e);
415
427
  }
416
- orderBy(e, t = "asc") {
417
- return this.query().orderBy(e, t);
428
+ orderBy(t, e = "asc") {
429
+ return this.query().orderBy(t, e);
418
430
  }
419
- searchBy(e) {
420
- return this.query().searchBy(e);
431
+ searchBy(t) {
432
+ return this.query().searchBy(t);
421
433
  }
422
434
  minified() {
423
435
  return this.query().minified();
424
436
  }
425
- limit(e) {
426
- return this.query().limit(e);
437
+ limit(t) {
438
+ return this.query().limit(t);
427
439
  }
428
440
  // get(page = 1, perPage = 15, replaceLinksWith?: string): Promise<ModelPaginatedResponse>
429
441
  // {
@@ -438,30 +450,30 @@ class N {
438
450
  // return this.query().find(id);
439
451
  // }
440
452
  }
441
- var D, H;
442
- class $ extends (H = Error, D = Symbol.toStringTag, H) {
443
- constructor(t) {
444
- super(`[Luminix] Expected ${t} to be reducible.`);
445
- g(this, D, "NotReducibleException");
453
+ var J, U;
454
+ class $ extends (U = Error, J = Symbol.toStringTag, U) {
455
+ constructor(e) {
456
+ super(`[Luminix] Expected ${e} to be reducible.`);
457
+ g(this, J, "NotReducibleException");
446
458
  }
447
459
  }
448
- var J, U;
449
- class Te extends (U = Error, J = Symbol.toStringTag, U) {
460
+ var F, W;
461
+ class Re extends (W = Error, F = Symbol.toStringTag, W) {
450
462
  constructor() {
451
463
  super("[Luminix] Method not implemented.");
452
- g(this, J, "MethodNotImplementedException");
464
+ g(this, F, "MethodNotImplementedException");
453
465
  }
454
466
  }
455
- var F, W;
456
- class oe extends (W = Error, F = Symbol.toStringTag, W) {
457
- constructor(t, r) {
458
- super(`[Luminix] Model "${t}" must be persisted before calling "${r}"`);
459
- g(this, F, "ModelNotPersistedException");
467
+ var G, V;
468
+ class ue extends (V = Error, G = Symbol.toStringTag, V) {
469
+ constructor(e, r) {
470
+ super(`[Luminix] Model "${e}" must be persisted before calling "${r}"`);
471
+ g(this, G, "ModelNotPersistedException");
460
472
  }
461
473
  }
462
- function Se(o, e, t, r, i) {
463
- var l, y, c;
464
- return c = class extends (y = k, l = Symbol.toStringTag, y) {
474
+ function Ne(o, t, e, r, i) {
475
+ var h, m, c;
476
+ return c = class extends (m = A, h = Symbol.toStringTag, m) {
465
477
  constructor(s = {}) {
466
478
  super();
467
479
  g(this, "_attributes", new _({}));
@@ -470,7 +482,7 @@ function Se(o, e, t, r, i) {
470
482
  g(this, "_changedKeys", []);
471
483
  g(this, "exists", !1);
472
484
  g(this, "wasRecentlyCreated", !1);
473
- g(this, l, m.studly(i));
485
+ g(this, h, y.studly(i));
474
486
  this.makeRelations(), this.makeAttributes(s);
475
487
  }
476
488
  cast(s, n) {
@@ -480,38 +492,38 @@ function Se(o, e, t, r, i) {
480
492
  return s == null || !n ? s : ["boolean", "bool"].includes(n) ? !!s : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(n) && s instanceof Date ? s.toISOString() : ["float", "double", "integer", "int"].includes(n) || n.startsWith("decimal:") ? Number(s) : s;
481
493
  }
482
494
  makeRelations() {
483
- const { relations: s } = t.schema(i);
495
+ const { relations: s } = e.schema(i);
484
496
  if (this._relations = {}, !s)
485
497
  return;
486
- const n = t.getRelationConstructors(i);
487
- Object.entries(s).forEach(([a, h]) => {
488
- const { type: d } = h, v = d in n ? n[d] : N;
498
+ const n = e.getRelationConstructors(i);
499
+ Object.entries(s).forEach(([a, l]) => {
500
+ const { type: d } = l, v = d in n ? n[d] : N;
489
501
  this._relations[a] = new v(
490
- { model: t, route: r },
491
- { name: a, ...h },
502
+ { model: e, route: r },
503
+ { name: a, ...l },
492
504
  this,
493
505
  null
494
506
  );
495
507
  });
496
508
  }
497
509
  makeAttributes(s) {
498
- const { relations: n, attributes: a = [] } = t.schema(i), h = Object.keys(n || {}), d = p.omit(s, ...h), v = (f) => {
499
- const T = a.find((le) => le.name == f);
500
- return T ? !(f in d) && T.nullable : !1;
510
+ const { relations: n, attributes: a = [] } = e.schema(i), l = Object.keys(n || {}), d = p.omit(s, ...l), v = (f) => {
511
+ const S = a.find((de) => de.name == f);
512
+ return S ? !(f in d) && S.nullable : !1;
501
513
  };
502
514
  if (this.fillable.filter(v).forEach((f) => {
503
515
  d[f] = null;
504
516
  }), !this.validateJsonObject(d)) {
505
517
  if (o.get("app.env", "production") === "production")
506
518
  throw new TypeError(`[Luminix] Invalid attributes for model "${i}"`);
507
- e.warning(`Invalid attributes for model "${i}".
519
+ t.warning(`Invalid attributes for model "${i}".
508
520
  This will throw an error in production.`, {
509
521
  attributes: s,
510
522
  abstract: i
511
523
  });
512
524
  }
513
525
  this._attributes.set(".", d), this._original = d, this._changedKeys.splice(0, this._changedKeys.length), n && Object.keys(n).forEach((f) => {
514
- this.relation(m.camel(f)).make(s[f]);
526
+ this.relation(y.camel(f)).make(s[f]);
515
527
  });
516
528
  }
517
529
  makePrimaryKeyReplacer() {
@@ -529,30 +541,30 @@ function Se(o, e, t, r, i) {
529
541
  this.emit("create", {
530
542
  value: s,
531
543
  source: this
532
- }), t.emit("create", {
544
+ }), e.emit("create", {
533
545
  class: i,
534
546
  model: this,
535
- source: t
547
+ source: e
536
548
  });
537
549
  }
538
550
  dispatchUpdateEvent(s) {
539
551
  this.emit("update", {
540
552
  value: s,
541
553
  source: this
542
- }), t.emit("update", {
554
+ }), e.emit("update", {
543
555
  class: i,
544
556
  model: this,
545
- source: t
557
+ source: e
546
558
  });
547
559
  }
548
560
  dispatchSaveEvent() {
549
561
  this.emit("save", {
550
562
  value: this.diff(),
551
563
  source: this
552
- }), t.emit("save", {
564
+ }), e.emit("save", {
553
565
  class: i,
554
566
  model: this,
555
- source: t
567
+ source: e
556
568
  });
557
569
  }
558
570
  dispatchDeleteEvent(s = !1) {
@@ -560,10 +572,10 @@ function Se(o, e, t, r, i) {
560
572
  force: s,
561
573
  [this.getKeyName()]: this.getKey(),
562
574
  source: this
563
- }), t.emit("delete", {
575
+ }), e.emit("delete", {
564
576
  class: i,
565
577
  model: this,
566
- source: t,
578
+ source: e,
567
579
  force: s
568
580
  });
569
581
  }
@@ -571,10 +583,10 @@ function Se(o, e, t, r, i) {
571
583
  this.emit("restore", {
572
584
  value: this.attributes,
573
585
  source: this
574
- }), t.emit("restore", {
586
+ }), e.emit("restore", {
575
587
  class: i,
576
588
  model: this,
577
- source: t
589
+ source: e
578
590
  });
579
591
  }
580
592
  dispatchErrorEvent(s, n) {
@@ -582,16 +594,16 @@ function Se(o, e, t, r, i) {
582
594
  error: s,
583
595
  operation: n,
584
596
  source: this
585
- }), t.emit("error", {
597
+ }), e.emit("error", {
586
598
  class: i,
587
599
  model: this,
588
- source: t,
600
+ source: e,
589
601
  error: s,
590
602
  operation: n
591
603
  });
592
604
  }
593
605
  updateChangedKeys(s) {
594
- const n = (h, d) => typeof h == "object" && h !== null ? p.isEqual(h, d) : h == d, a = s.includes(".") || s.includes("[") ? s.split(/[.[]/)[0] : s;
606
+ const n = (l, d) => typeof l == "object" && l !== null ? p.isEqual(l, d) : l == d, a = s.includes(".") || s.includes("[") ? s.split(/[.[]/)[0] : s;
595
607
  !this._changedKeys.includes(a) && !n(p.get(this._original, a), this._attributes.get(a)) ? this._changedKeys.push(a) : this._changedKeys.includes(a) && n(p.get(this._original, a), this._attributes.get(a)) && this._changedKeys.splice(this._changedKeys.indexOf(a), 1);
596
608
  }
597
609
  validateJsonObject(s) {
@@ -607,20 +619,20 @@ function Se(o, e, t, r, i) {
607
619
  return this._relations;
608
620
  }
609
621
  get fillable() {
610
- return t.schema(i).fillable;
622
+ return e.schema(i).fillable;
611
623
  }
612
624
  get primaryKey() {
613
- return t.schema(i).primaryKey;
625
+ return e.schema(i).primaryKey;
614
626
  }
615
627
  get timestamps() {
616
- return t.schema(i).timestamps;
628
+ return e.schema(i).timestamps;
617
629
  }
618
630
  // get softDeletes() {
619
631
  // return ModelFacade.schema(abstract).softDeletes;
620
632
  // }
621
633
  get casts() {
622
634
  return {
623
- ...t.schema(i).casts,
635
+ ...e.schema(i).casts,
624
636
  ...this.timestamps ? { created_at: "datetime", updated_at: "datetime" } : {}
625
637
  // ...this.softDeletes ? { deleted_at: 'datetime' } : {},
626
638
  };
@@ -632,30 +644,30 @@ function Se(o, e, t, r, i) {
632
644
  getAttribute(s) {
633
645
  let n = this._attributes.get(s, null);
634
646
  s in this.casts && (n = this.cast(n, this.casts[s]));
635
- const a = t[`model${m.studly(i)}Get${m.studly(s)}Attribute`];
647
+ const a = e[`model${y.studly(i)}Get${y.studly(s)}Attribute`];
636
648
  if (typeof a != "function")
637
649
  throw new $("ModelFacade");
638
- return a.bind(t)(n, this);
650
+ return a.bind(e)(n, this);
639
651
  }
640
652
  setAttribute(s, n) {
641
- const h = t[`model${m.studly(i)}Set${m.studly(s)}Attribute`].bind(t)(
653
+ const l = e[`model${y.studly(i)}Set${y.studly(s)}Attribute`].bind(e)(
642
654
  this.mutate(n, this.casts[s]),
643
655
  this
644
656
  );
645
- if (!this.validateJsonObject({ [s]: h })) {
657
+ if (!this.validateJsonObject({ [s]: l })) {
646
658
  if (o.get("app.env", "production") === "production")
647
659
  throw new TypeError(`[Luminix] Attribute "${s}" in model "${i}" must be a boolean, number, string or null`);
648
- e.warning(`Invalid type for attribute "${s}" in model "${i}" after mutation.
660
+ t.warning(`Invalid type for attribute "${s}" in model "${i}" after mutation.
649
661
  This will throw an error in production.`, {
650
662
  key: s,
651
663
  value: n,
652
- mutated: h,
664
+ mutated: l,
653
665
  cast: this.casts[s],
654
666
  item: this.toJson()
655
667
  });
656
668
  return;
657
669
  }
658
- this._attributes.set(s, h), this.updateChangedKeys(s), this.dispatchChangeEvent({ [s]: h });
670
+ this._attributes.set(s, l), this.updateChangedKeys(s), this.dispatchChangeEvent({ [s]: l });
659
671
  }
660
672
  getKey() {
661
673
  return this.getAttribute(this.primaryKey);
@@ -664,19 +676,19 @@ function Se(o, e, t, r, i) {
664
676
  return this.primaryKey;
665
677
  }
666
678
  fill(s) {
667
- const n = p.pick(s, ...this.fillable), a = Object.entries(n).reduce((h, [d, v]) => {
668
- const f = t[`model${m.studly(i)}Set${m.studly(d)}Attribute`];
679
+ const n = p.pick(s, ...this.fillable), a = Object.entries(n).reduce((l, [d, v]) => {
680
+ const f = e[`model${y.studly(i)}Set${y.studly(d)}Attribute`];
669
681
  if (typeof f != "function")
670
682
  throw new $("ModelFacade");
671
- return h[d] = f.bind(t)(
683
+ return l[d] = f.bind(e)(
672
684
  this.mutate(v, this.casts[d]),
673
685
  this
674
- ), h;
686
+ ), l;
675
687
  }, {});
676
688
  if (!this.validateJsonObject(a)) {
677
689
  if (o.get("app.env", "production") === "production")
678
690
  throw new TypeError(`[Luminix] Invalid attributes for model "${i}"`);
679
- e.warning(`Invalid attributes for model "${i}" after mutation.
691
+ t.warning(`Invalid attributes for model "${i}" after mutation.
680
692
  This will throw an error in production.`, {
681
693
  attributes: s,
682
694
  mutatedAttributes: a,
@@ -685,19 +697,19 @@ function Se(o, e, t, r, i) {
685
697
  });
686
698
  return;
687
699
  }
688
- this._attributes.merge(".", a), Object.keys(a).forEach((h) => this.updateChangedKeys(h)), this.dispatchChangeEvent(a);
700
+ this._attributes.merge(".", a), Object.keys(a).forEach((l) => this.updateChangedKeys(l)), this.dispatchChangeEvent(a);
689
701
  }
690
702
  dump() {
691
- e.info({
703
+ t.info({
692
704
  ...this.toJson(),
693
- [Symbol.toStringTag]: m.studly(i)
705
+ [Symbol.toStringTag]: y.studly(i)
694
706
  });
695
707
  }
696
708
  toJson() {
697
- const s = Object.entries(this.relations).reduce((a, [h, d]) => (d.isLoaded() && (d.isSingle() ? a[m.snake(h)] = d.getLoadedItems().toJson() : d.isMultiple() && (a[m.snake(h)] = d.getLoadedItems().map((v) => v.toJson()).all())), a), {}), n = t[`model${m.studly(i)}Json`];
709
+ const s = Object.entries(this.relations).reduce((a, [l, d]) => (d.isLoaded() && (d.isSingle() ? a[y.snake(l)] = d.getLoadedItems().toJson() : d.isMultiple() && (a[y.snake(l)] = d.getLoadedItems().map((v) => v.toJson()).all())), a), {}), n = e[`model${y.studly(i)}Json`];
698
710
  if (typeof n != "function")
699
711
  throw new $("ModelFacade");
700
- return n.bind(t)({
712
+ return n.bind(e)({
701
713
  ...this.attributes,
702
714
  ...s
703
715
  }, this);
@@ -709,8 +721,8 @@ function Se(o, e, t, r, i) {
709
721
  return i;
710
722
  }
711
723
  relation(s) {
712
- if (s === m.camel(s))
713
- return this.relations[m.snake(s)];
724
+ if (s === y.camel(s))
725
+ return this.relations[y.snake(s)];
714
726
  }
715
727
  getErrorBag(s) {
716
728
  return `${this.exists ? `${i}[${this.getKey()}].` : `${i}.`}${s}`;
@@ -740,13 +752,13 @@ function Se(o, e, t, r, i) {
740
752
  ];
741
753
  }
742
754
  getLabel() {
743
- const { labeledBy: s } = t.schema(i);
755
+ const { labeledBy: s } = e.schema(i);
744
756
  return this.getAttribute(s);
745
757
  }
746
758
  /* * * * */
747
759
  async refresh(s) {
748
760
  if (!this.exists)
749
- throw new oe(i, "refresh");
761
+ throw new ue(i, "refresh");
750
762
  const n = await r.call(
751
763
  this.getRouteForRefresh(),
752
764
  s,
@@ -758,10 +770,10 @@ function Se(o, e, t, r, i) {
758
770
  try {
759
771
  const {
760
772
  additionalPayload: a = {},
761
- sendsOnlyModifiedFields: h = !0
773
+ sendsOnlyModifiedFields: l = !0
762
774
  } = s, d = this.exists, v = {
763
775
  ...p.pick(
764
- h && d ? this.diff() : this.attributes,
776
+ l && d ? this.diff() : this.attributes,
765
777
  ...this.fillable
766
778
  ),
767
779
  ...a
@@ -770,7 +782,7 @@ function Se(o, e, t, r, i) {
770
782
  return;
771
783
  const f = await r.call(
772
784
  this.getRouteForSave(),
773
- (T) => n ? n(T.withData(v)) : T.withData(v),
785
+ (S) => n ? n(S.withData(v)) : S.withData(v),
774
786
  this.getErrorBag(d ? "update" : "store")
775
787
  );
776
788
  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,7 +791,7 @@ function Se(o, e, t, r, i) {
779
791
  }
780
792
  }
781
793
  async push() {
782
- throw new Te();
794
+ throw new Re();
783
795
  }
784
796
  async delete() {
785
797
  try {
@@ -797,7 +809,7 @@ function Se(o, e, t, r, i) {
797
809
  try {
798
810
  const a = await r.call(
799
811
  this.getRouteForUpdate(),
800
- (h) => n ? n(h.withData(s)) : h.withData(s),
812
+ (l) => n ? n(l.withData(s)) : l.withData(s),
801
813
  this.getErrorBag("update")
802
814
  );
803
815
  a.throw(), this.makeAttributes(a.json()), this.dispatchUpdateEvent(a.json());
@@ -834,11 +846,11 @@ function Se(o, e, t, r, i) {
834
846
  return i;
835
847
  }
836
848
  static getSchema() {
837
- return t.schema(i);
849
+ return e.schema(i);
838
850
  }
839
851
  static query() {
840
- return new Me(
841
- { config: o, route: r, model: t },
852
+ return new Se(
853
+ { config: o, route: r, model: e },
842
854
  i
843
855
  );
844
856
  }
@@ -879,57 +891,57 @@ function Se(o, e, t, r, i) {
879
891
  return this.query().first();
880
892
  }
881
893
  static async create(s) {
882
- const n = t.make(i), a = new n();
894
+ const n = e.make(i), a = new n();
883
895
  return a.fill(s), await a.save(), a;
884
896
  }
885
897
  static async update(s, n) {
886
- const a = t.make(i), h = new a({ id: s });
887
- return h.fill(n), h.exists = !0, await h.save(), h;
898
+ const a = e.make(i), l = new a({ id: s });
899
+ return l.fill(n), l.exists = !0, await l.save(), l;
888
900
  }
889
901
  static delete(s) {
890
902
  if (Array.isArray(s))
891
903
  return r.call(
892
904
  `luminix.${i}.destroyMany`,
893
- (h) => h.withQueryParameters({ ids: s }),
905
+ (l) => l.withQueryParameters({ ids: s }),
894
906
  `${i}.deleteMany`
895
907
  );
896
- const n = t.make(i);
908
+ const n = e.make(i);
897
909
  return new n({ id: s }).delete();
898
910
  }
899
911
  static async restore(s) {
900
912
  if (Array.isArray(s))
901
913
  return r.call(
902
914
  `luminix.${i}.restoreMany`,
903
- (h) => h.withData({ ids: s }),
915
+ (l) => l.withData({ ids: s }),
904
916
  `${i}.restoreMany`
905
917
  );
906
- const n = t.make(i);
918
+ const n = e.make(i);
907
919
  return new n({ id: s }).restore();
908
920
  }
909
921
  static forceDelete(s) {
910
922
  if (Array.isArray(s))
911
923
  return r.call(
912
924
  `luminix.${i}.destroyMany`,
913
- (h) => h.withQueryParameters({ ids: s, force: !0 }),
925
+ (l) => l.withQueryParameters({ ids: s, force: !0 }),
914
926
  `${i}.forceDeleteMany`
915
927
  );
916
- const n = t.make(i);
928
+ const n = e.make(i);
917
929
  return new n({ id: s }).forceDelete();
918
930
  }
919
931
  static singular() {
920
- return t.schema(i).displayName.singular;
932
+ return e.schema(i).displayName.singular;
921
933
  }
922
934
  static plural() {
923
- return t.schema(i).displayName.plural;
935
+ return e.schema(i).displayName.plural;
924
936
  }
925
- }, g(c, "name", m.studly(i)), c;
937
+ }, g(c, "name", y.studly(i)), c;
926
938
  }
927
- function _e(o, e, t) {
939
+ function Ae(o, t, e) {
928
940
  var r, i;
929
- return class extends (i = t, r = Symbol.toStringTag, i) {
930
- constructor(y = {}) {
931
- super(y);
932
- g(this, r, m.studly(e));
941
+ return class extends (i = e, r = Symbol.toStringTag, i) {
942
+ constructor(m = {}) {
943
+ super(m);
944
+ g(this, r, y.studly(t));
933
945
  return new Proxy(this, {
934
946
  get: (c, u) => {
935
947
  if (u === "__isModel")
@@ -940,10 +952,10 @@ function _e(o, e, t) {
940
952
  return c.getAttribute(u);
941
953
  if (Object.keys(c.relations).includes(u))
942
954
  return c.relations[u].getLoadedItems();
943
- if (u.endsWith("Relation") && Object.keys(c.relations).includes(m.snake(u.slice(0, -8))))
955
+ if (u.endsWith("Relation") && Object.keys(c.relations).includes(y.snake(u.slice(0, -8))))
944
956
  return () => c.relation(u.slice(0, -8));
945
- if (o.hasReducer(`model${m.studly(c.getType())}Get${m.studly(u)}Attribute`)) {
946
- const s = o[`model${m.studly(c.getType())}Get${m.studly(u)}Attribute`];
957
+ if (o.hasReducer(`model${y.studly(c.getType())}Get${y.studly(u)}Attribute`)) {
958
+ const s = o[`model${y.studly(c.getType())}Get${y.studly(u)}Attribute`];
947
959
  if (typeof s != "function")
948
960
  throw new $("ModelFacade");
949
961
  return s.bind(o)(void 0, c);
@@ -958,25 +970,25 @@ function _e(o, e, t) {
958
970
  }
959
971
  };
960
972
  }
961
- var G, V;
962
- class q extends (V = Error, G = Symbol.toStringTag, V) {
963
- constructor(t) {
964
- super(`[Luminix] Model "${t}" not found`);
965
- g(this, G, "ModelNotFoundException");
973
+ var z, X;
974
+ class q extends (X = Error, z = Symbol.toStringTag, X) {
975
+ constructor(e) {
976
+ super(`[Luminix] Model "${e}" not found`);
977
+ g(this, z, "ModelNotFoundException");
966
978
  }
967
979
  }
968
- var z, X;
969
- class R extends (X = TypeError, z = Symbol.toStringTag, X) {
970
- constructor(t, r, i) {
971
- super(`[Luminix] "${t}" expects a related model of type "${r}". Received "${i}" instead.`);
972
- g(this, z, "ModelInvalidRelatedTypeException");
980
+ var Y, Z;
981
+ class R extends (Z = TypeError, Y = Symbol.toStringTag, Z) {
982
+ constructor(e, r, i) {
983
+ super(`[Luminix] "${e}" expects a related model of type "${r}". Received "${i}" instead.`);
984
+ g(this, Y, "ModelInvalidRelatedTypeException");
973
985
  }
974
986
  }
975
- class ae extends N {
976
- constructor(e, t, r, i = null) {
987
+ class he extends N {
988
+ constructor(t, e, r, i = null) {
977
989
  if (!p.isModel(i) && i !== null)
978
990
  throw new w("BelongsTo.constructor()", "Model or null");
979
- super(e, t, r, i), this.services = e, this.meta = t, this.parent = r, this.items = i;
991
+ super(t, e, r, i), this.services = t, this.meta = e, this.parent = r, this.items = i;
980
992
  }
981
993
  isSingle() {
982
994
  return !0;
@@ -985,21 +997,21 @@ class ae extends N {
985
997
  return !1;
986
998
  }
987
999
  query() {
988
- const e = super.query(), t = this.guessInverseRelation();
989
- return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
1000
+ const t = super.query(), e = this.guessInverseRelation();
1001
+ return t.where(e, this.parent.getKey()), t.lock(`where.${e}`), t;
990
1002
  }
991
1003
  get() {
992
1004
  return this.query().first();
993
1005
  }
994
- async associate(e) {
995
- if (!p.isModel(e))
1006
+ async associate(t) {
1007
+ if (!p.isModel(t))
996
1008
  throw new w("BelongsTo.associate()");
997
- if (e.getType() !== this.getRelated().getSchemaName())
998
- throw new R("BelongsTo.associate()", this.getRelated().getSchemaName(), e.getType());
999
- if (!e.exists)
1000
- throw new oe(this.getRelated().getSchemaName(), "save");
1009
+ if (t.getType() !== this.getRelated().getSchemaName())
1010
+ throw new R("BelongsTo.associate()", this.getRelated().getSchemaName(), t.getType());
1011
+ if (!t.exists)
1012
+ throw new ue(this.getRelated().getSchemaName(), "save");
1001
1013
  return this.parent.update({
1002
- [this.getForeignKey()]: e.getKey()
1014
+ [this.getForeignKey()]: t.getKey()
1003
1015
  });
1004
1016
  }
1005
1017
  dissociate() {
@@ -1008,11 +1020,11 @@ class ae extends N {
1008
1020
  });
1009
1021
  }
1010
1022
  }
1011
- class ue extends N {
1012
- constructor(e, t, r, i = null) {
1023
+ class le extends N {
1024
+ constructor(t, e, r, i = null) {
1013
1025
  if (i !== null && !(i instanceof b && i.every(p.isModel)))
1014
1026
  throw new w("BelongsToMany.constructor()", "Collection<Model> or null");
1015
- super(e, t, r, i), this.services = e, this.meta = t, this.parent = r, this.items = i;
1027
+ super(t, e, r, i), this.services = t, this.meta = e, this.parent = r, this.items = i;
1016
1028
  }
1017
1029
  isSingle() {
1018
1030
  return !1;
@@ -1021,11 +1033,11 @@ class ue extends N {
1021
1033
  return !0;
1022
1034
  }
1023
1035
  query() {
1024
- const e = super.query(), t = this.guessInverseRelation();
1025
- return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
1036
+ const t = super.query(), e = this.guessInverseRelation();
1037
+ return t.where(e, this.parent.getKey()), t.lock(`where.${e}`), t;
1026
1038
  }
1027
- get(e) {
1028
- return this.query().get(e);
1039
+ get(t) {
1040
+ return this.query().get(t);
1029
1041
  }
1030
1042
  all() {
1031
1043
  return this.query().all();
@@ -1033,34 +1045,34 @@ class ue extends N {
1033
1045
  first() {
1034
1046
  return this.query().first();
1035
1047
  }
1036
- find(e) {
1037
- return this.query().find(e);
1048
+ find(t) {
1049
+ return this.query().find(t);
1038
1050
  }
1039
- attachQuietly(e, t = {}) {
1051
+ attachQuietly(t, e = {}) {
1040
1052
  return this.services.route.call([
1041
1053
  `luminix.${this.parent.getType()}.${this.getName()}:attach`,
1042
1054
  {
1043
1055
  [this.parent.getKeyName()]: this.parent.getKey(),
1044
- itemId: e
1056
+ itemId: t
1045
1057
  }
1046
- ], (r) => r.withData(t));
1058
+ ], (r) => r.withData(e));
1047
1059
  }
1048
- async attach(e, t = {}) {
1049
- if (await this.attachQuietly(e, t), this.items) {
1050
- const r = this.items.search((l) => l.getKey() === e), i = await this.getRelated().find(e);
1060
+ async attach(t, e = {}) {
1061
+ if (await this.attachQuietly(t, e), this.items) {
1062
+ const r = this.items.search((h) => h.getKey() === t), i = await this.getRelated().find(t);
1051
1063
  if (!i)
1052
1064
  return;
1053
1065
  r !== !1 ? this.items.put(r, i) : this.items.push(i);
1054
1066
  } else
1055
1067
  this.items = await this.all();
1056
1068
  }
1057
- async detachQuietly(e) {
1069
+ async detachQuietly(t) {
1058
1070
  await this.services.route.call(
1059
1071
  [
1060
1072
  `luminix.${this.parent.getType()}.${this.getName()}:detach`,
1061
1073
  {
1062
1074
  [this.parent.getKeyName()]: this.parent.getKey(),
1063
- itemId: e
1075
+ itemId: t
1064
1076
  }
1065
1077
  ]
1066
1078
  // {
@@ -1068,60 +1080,60 @@ class ue extends N {
1068
1080
  // }
1069
1081
  );
1070
1082
  }
1071
- async detach(e) {
1072
- if (await this.detachQuietly(e), this.items) {
1073
- const t = this.items.search((r) => r.getKey() === e);
1074
- t !== !1 && this.items.pull(t);
1083
+ async detach(t) {
1084
+ if (await this.detachQuietly(t), this.items) {
1085
+ const e = this.items.search((r) => r.getKey() === t);
1086
+ e !== !1 && this.items.pull(e);
1075
1087
  }
1076
1088
  }
1077
- async syncQuietly(e) {
1089
+ async syncQuietly(t) {
1078
1090
  await this.services.route.call([
1079
1091
  `luminix.${this.parent.getType()}.${this.getName()}:sync`,
1080
1092
  {
1081
1093
  [this.parent.getKeyName()]: this.parent.getKey()
1082
1094
  }
1083
- ], (t) => t.withData(e));
1095
+ ], (e) => e.withData(t));
1084
1096
  }
1085
- async sync(e) {
1086
- await this.syncQuietly(e);
1087
- const t = await this.all();
1088
- this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = t;
1097
+ async sync(t) {
1098
+ await this.syncQuietly(t);
1099
+ const e = await this.all();
1100
+ this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
1089
1101
  }
1090
- async syncWithPivotValuesQuietly(e, t) {
1102
+ async syncWithPivotValuesQuietly(t, e) {
1091
1103
  await this.services.route.call([
1092
1104
  `luminix.${this.parent.getType()}.${this.getName()}:sync`,
1093
1105
  {
1094
1106
  [this.parent.getKeyName()]: this.parent.getKey()
1095
1107
  }
1096
- ], (r) => r.withData(e.map((i) => ({
1108
+ ], (r) => r.withData(t.map((i) => ({
1097
1109
  [this.getRelated().getSchema().primaryKey]: i,
1098
- ...t
1110
+ ...e
1099
1111
  }))));
1100
1112
  }
1101
- async syncWithPivotValues(e, t) {
1102
- await this.syncWithPivotValuesQuietly(e, t);
1113
+ async syncWithPivotValues(t, e) {
1114
+ await this.syncWithPivotValuesQuietly(t, e);
1103
1115
  const r = await this.all();
1104
1116
  this.items ? this.items.splice(0, this.items.count(), ...r) : this.items = r;
1105
1117
  }
1106
1118
  }
1107
- class A extends N {
1119
+ class k extends N {
1108
1120
  query() {
1109
- const e = super.query(), t = this.guessInverseRelation();
1110
- return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
1121
+ const t = super.query(), e = this.guessInverseRelation();
1122
+ return t.where(e, this.parent.getKey()), t.lock(`where.${e}`), t;
1111
1123
  }
1112
- async saveQuietly(e) {
1113
- if (!p.isModel(e))
1124
+ async saveQuietly(t) {
1125
+ if (!p.isModel(t))
1114
1126
  throw new w("HasOneOrMany.saveQuietly()");
1115
- if (e.getType() !== this.getRelated().getSchemaName())
1116
- throw new R("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1117
- e.setAttribute(this.getForeignKey(), this.parent.getKey()), await e.save();
1127
+ if (t.getType() !== this.getRelated().getSchemaName())
1128
+ throw new R("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), t.getType());
1129
+ t.setAttribute(this.getForeignKey(), this.parent.getKey()), await t.save();
1118
1130
  }
1119
1131
  }
1120
- class Re extends A {
1121
- constructor(e, t, r, i = null) {
1132
+ class ke extends k {
1133
+ constructor(t, e, r, i = null) {
1122
1134
  if (!p.isModel(i) && i !== null)
1123
1135
  throw new w("HasOne.constructor()", "Model or null");
1124
- super(e, t, r, i), this.services = e, this.meta = t, this.parent = r, this.items = i;
1136
+ super(t, e, r, i), this.services = t, this.meta = e, this.parent = r, this.items = i;
1125
1137
  }
1126
1138
  isSingle() {
1127
1139
  return !0;
@@ -1132,18 +1144,18 @@ class Re extends A {
1132
1144
  get() {
1133
1145
  return this.query().first();
1134
1146
  }
1135
- async save(e) {
1136
- await this.saveQuietly(e), this.items = e;
1147
+ async save(t) {
1148
+ await this.saveQuietly(t), this.items = t;
1137
1149
  }
1138
1150
  }
1139
1151
  function K(o) {
1140
1152
  return new b(o);
1141
1153
  }
1142
- class Ne extends A {
1143
- constructor(e, t, r, i = null) {
1154
+ class qe extends k {
1155
+ constructor(t, e, r, i = null) {
1144
1156
  if (i !== null && !(i instanceof b && i.every(p.isModel)))
1145
1157
  throw new w("HasMany.constructor()", "Collection<Model> or null");
1146
- super(e, t, r, i), this.services = e, this.meta = t, this.parent = r, this.items = i;
1158
+ super(t, e, r, i), this.services = t, this.meta = e, this.parent = r, this.items = i;
1147
1159
  }
1148
1160
  isSingle() {
1149
1161
  return !1;
@@ -1151,8 +1163,8 @@ class Ne extends A {
1151
1163
  isMultiple() {
1152
1164
  return !0;
1153
1165
  }
1154
- get(e) {
1155
- return this.query().get(e);
1166
+ get(t) {
1167
+ return this.query().get(t);
1156
1168
  }
1157
1169
  all() {
1158
1170
  return this.query().all();
@@ -1160,46 +1172,46 @@ class Ne extends A {
1160
1172
  first() {
1161
1173
  return this.query().first();
1162
1174
  }
1163
- find(e) {
1164
- return this.query().find(e);
1175
+ find(t) {
1176
+ return this.query().find(t);
1165
1177
  }
1166
- async saveManyQuietly(e) {
1167
- if (!Array.isArray(e) || !e.every(p.isModel))
1178
+ async saveManyQuietly(t) {
1179
+ if (!Array.isArray(t) || !t.every(p.isModel))
1168
1180
  throw new w("HasMany.saveManyQuietly()", "Model[]");
1169
- if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
1170
- throw new R("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
1171
- await Promise.all(e.map((t) => (t.setAttribute(this.getForeignKey(), this.parent.getKey()), t.save())));
1181
+ if (!t.every((e) => e.getType() === this.getRelated().getSchemaName()))
1182
+ throw new R("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), t.map((e) => e.getType()).join(", "));
1183
+ await Promise.all(t.map((e) => (e.setAttribute(this.getForeignKey(), this.parent.getKey()), e.save())));
1172
1184
  }
1173
- async saveMany(e) {
1174
- await this.saveManyQuietly(e), this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = K(e);
1185
+ async saveMany(t) {
1186
+ await this.saveManyQuietly(t), this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = K(t);
1175
1187
  }
1176
- async save(e) {
1177
- await this.saveQuietly(e), this.items === null ? this.items = K([e]) : this.items.push(e);
1188
+ async save(t) {
1189
+ await this.saveQuietly(t), this.items === null ? this.items = K([t]) : this.items.push(t);
1178
1190
  }
1179
1191
  }
1180
- class he extends A {
1192
+ class ce extends k {
1181
1193
  query() {
1182
- const e = this.getRelated().query();
1183
- e.once("success", (r) => {
1194
+ const t = this.getRelated().query();
1195
+ t.once("success", (r) => {
1184
1196
  this.items = r.items;
1185
1197
  });
1186
- const t = this.guessInverseRelation();
1187
- return e.where(t + "_id", this.parent.getKey()), e.where(t + "_type", this.getRelated().getSchemaName()), e.lock(`where.${t}_id`), e.lock(`where.${t}_type`), e;
1198
+ const e = this.guessInverseRelation();
1199
+ return t.where(e + "_id", this.parent.getKey()), t.where(e + "_type", this.getRelated().getSchemaName()), t.lock(`where.${e}_id`), t.lock(`where.${e}_type`), t;
1188
1200
  }
1189
- async saveQuietly(e) {
1190
- if (!p.isModel(e))
1201
+ async saveQuietly(t) {
1202
+ if (!p.isModel(t))
1191
1203
  throw new w("MorphOneOrMany.saveQuietly()");
1192
- if (e.getType() !== this.getRelated().getSchemaName())
1193
- throw new R("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1194
- const t = this.guessInverseRelation();
1195
- e.setAttribute(t + "_id", this.parent.getKey()), e.setAttribute(t + "_type", this.parent.getType()), await e.save();
1204
+ if (t.getType() !== this.getRelated().getSchemaName())
1205
+ throw new R("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), t.getType());
1206
+ const e = this.guessInverseRelation();
1207
+ t.setAttribute(e + "_id", this.parent.getKey()), t.setAttribute(e + "_type", this.parent.getType()), await t.save();
1196
1208
  }
1197
1209
  }
1198
- class ke extends he {
1199
- constructor(e, t, r, i = null) {
1210
+ class Ke extends ce {
1211
+ constructor(t, e, r, i = null) {
1200
1212
  if (i !== null && !(i instanceof b && i.every(p.isModel)))
1201
1213
  throw new w("MorphMany.constructor()", "Collection<Model> or null");
1202
- super(e, t, r, i), this.services = e, this.meta = t, this.parent = r, this.items = i;
1214
+ super(t, e, r, i), this.services = t, this.meta = e, this.parent = r, this.items = i;
1203
1215
  }
1204
1216
  isSingle() {
1205
1217
  return !1;
@@ -1207,8 +1219,8 @@ class ke extends he {
1207
1219
  isMultiple() {
1208
1220
  return !0;
1209
1221
  }
1210
- get(e) {
1211
- return this.query().get(e);
1222
+ get(t) {
1223
+ return this.query().get(t);
1212
1224
  }
1213
1225
  all() {
1214
1226
  return this.query().all();
@@ -1216,28 +1228,28 @@ class ke extends he {
1216
1228
  first() {
1217
1229
  return this.query().first();
1218
1230
  }
1219
- find(e) {
1220
- return this.query().find(e);
1231
+ find(t) {
1232
+ return this.query().find(t);
1221
1233
  }
1222
- async saveManyQuietly(e) {
1223
- if (!Array.isArray(e) || !e.every(p.isModel))
1234
+ async saveManyQuietly(t) {
1235
+ if (!Array.isArray(t) || !t.every(p.isModel))
1224
1236
  throw new w("MorphMany.saveManyQuietly()");
1225
- if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
1226
- throw new R("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
1227
- await Promise.all(e.map((t) => (t.setAttribute(this.getName() + "_id", this.parent.getKey()), t.setAttribute(this.getName() + "_type", this.parent.getType()), t.save())));
1237
+ if (!t.every((e) => e.getType() === this.getRelated().getSchemaName()))
1238
+ throw new R("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), t.map((e) => e.getType()).join(", "));
1239
+ await Promise.all(t.map((e) => (e.setAttribute(this.getName() + "_id", this.parent.getKey()), e.setAttribute(this.getName() + "_type", this.parent.getType()), e.save())));
1228
1240
  }
1229
- async saveMany(e) {
1230
- await this.saveManyQuietly(e);
1231
- const t = await this.all();
1232
- this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = t;
1241
+ async saveMany(t) {
1242
+ await this.saveManyQuietly(t);
1243
+ const e = await this.all();
1244
+ this.items ? this.items.splice(0, this.items.count(), ...e) : this.items = e;
1233
1245
  }
1234
- async save(e) {
1235
- await this.saveQuietly(e), this.items ? this.items.push(e) : this.items = await this.all();
1246
+ async save(t) {
1247
+ await this.saveQuietly(t), this.items ? this.items.push(t) : this.items = await this.all();
1236
1248
  }
1237
1249
  }
1238
- class Ae extends he {
1239
- constructor(e, t, r, i = null) {
1240
- if (super(e, t, r, i), this.services = e, this.meta = t, this.parent = r, this.items = i, i !== null && !p.isModel(i))
1250
+ class Oe extends ce {
1251
+ constructor(t, e, r, i = null) {
1252
+ if (super(t, e, r, i), this.services = t, this.meta = e, this.parent = r, this.items = i, i !== null && !p.isModel(i))
1241
1253
  throw new w("MorphOne.constructor()", "Model or null");
1242
1254
  }
1243
1255
  isSingle() {
@@ -1249,11 +1261,11 @@ class Ae extends he {
1249
1261
  get() {
1250
1262
  return this.query().first();
1251
1263
  }
1252
- async save(e) {
1253
- await this.saveQuietly(e), this.items = e;
1264
+ async save(t) {
1265
+ await this.saveQuietly(t), this.items = t;
1254
1266
  }
1255
1267
  }
1256
- class qe extends ae {
1268
+ class je extends he {
1257
1269
  getRelated() {
1258
1270
  return this.services.model.make(
1259
1271
  this.parent.getAttribute(this.getName() + "_type")
@@ -1267,12 +1279,12 @@ class qe extends ae {
1267
1279
  // this.of(this.parent.getAttribute(this.getName() + '_type') as string);
1268
1280
  // return super.query();
1269
1281
  // }
1270
- async associate(e) {
1271
- if (!p.isModel(e))
1282
+ async associate(t) {
1283
+ if (!p.isModel(t))
1272
1284
  throw new w("MorphTo.associate()");
1273
- return e.exists || await e.save(), this.parent.update({
1274
- [this.getName() + "_id"]: e.getKey(),
1275
- [this.getName() + "_type"]: e.getType()
1285
+ return t.exists || await t.save(), this.parent.update({
1286
+ [this.getName() + "_id"]: t.getKey(),
1287
+ [this.getName() + "_type"]: t.getType()
1276
1288
  });
1277
1289
  }
1278
1290
  dissociate() {
@@ -1282,133 +1294,128 @@ class qe extends ae {
1282
1294
  });
1283
1295
  }
1284
1296
  }
1285
- class Ke extends ue {
1286
- query() {
1287
- var r;
1288
- const e = super.query(), t = `${(r = this.meta.morphType) == null ? void 0 : r.slice(0, -5)}_id`;
1289
- 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;
1290
- }
1297
+ class Be extends le {
1291
1298
  }
1292
- var Y, Z;
1293
- class Oe extends (Z = k, Y = Symbol.toStringTag, Z) {
1294
- constructor(t) {
1299
+ var ee, te;
1300
+ class Ce extends (te = A, ee = Symbol.toStringTag, te) {
1301
+ constructor(e) {
1295
1302
  super();
1296
1303
  g(this, "_models", {});
1297
- g(this, Y, "ModelService");
1298
- this._schema = t;
1304
+ g(this, ee, "ModelService");
1305
+ this._schema = e;
1299
1306
  }
1300
- boot(t) {
1307
+ boot(e) {
1301
1308
  this._schema && Object.keys(this._schema).forEach((r) => {
1302
- const i = this[`model${m.studly(r)}`], l = this.model(
1303
- Se(
1304
- t.make("config"),
1305
- t.make("log"),
1306
- t.make("model"),
1307
- t.make("route"),
1309
+ const i = this[`model${y.studly(r)}`], h = this.model(
1310
+ Ne(
1311
+ e.make("config"),
1312
+ e.make("log"),
1313
+ e.make("model"),
1314
+ e.make("route"),
1308
1315
  r
1309
1316
  ),
1310
1317
  r
1311
- ), y = i(l);
1312
- this._models[r] = _e(t.make("model"), r, y);
1318
+ ), m = i(h);
1319
+ this._models[r] = Ae(e.make("model"), r, m);
1313
1320
  });
1314
1321
  }
1315
- schema(t) {
1316
- if (!this._schema || t && !this._schema[t])
1317
- throw new q(t || "undefined");
1318
- return t ? this._schema[t] : this._schema;
1322
+ schema(e) {
1323
+ if (!this._schema || e && !this._schema[e])
1324
+ throw new q(e || "undefined");
1325
+ return e ? this._schema[e] : this._schema;
1319
1326
  }
1320
- make(t) {
1321
- if (t && !this._models[t])
1322
- throw new q(t);
1323
- return t ? this._models[t] : this._models;
1327
+ make(e) {
1328
+ if (e && !this._models[e])
1329
+ throw new q(e);
1330
+ return e ? this._models[e] : this._models;
1324
1331
  }
1325
- getRelationConstructors(t) {
1332
+ getRelationConstructors(e) {
1326
1333
  return this.relationMap({
1327
- BelongsTo: ae,
1328
- BelongsToMany: ue,
1329
- HasOne: Re,
1330
- HasMany: Ne,
1331
- MorphMany: ke,
1332
- MorphOne: Ae,
1333
- MorphTo: qe,
1334
- MorphToMany: Ke
1335
- }, t);
1334
+ BelongsTo: he,
1335
+ BelongsToMany: le,
1336
+ HasOne: ke,
1337
+ HasMany: qe,
1338
+ MorphMany: Ke,
1339
+ MorphOne: Oe,
1340
+ MorphTo: je,
1341
+ MorphToMany: Be
1342
+ }, e);
1336
1343
  }
1337
1344
  toString() {
1338
1345
  return "model";
1339
1346
  }
1340
1347
  }
1341
- const je = re(Oe);
1342
- var ee, te;
1343
- class Be extends (te = Error, ee = Symbol.toStringTag, te) {
1344
- constructor(t) {
1345
- super(`[Luminix] Route "${t}" not found`);
1346
- g(this, ee, "RouteNotFoundException");
1348
+ const Qe = oe(Ce);
1349
+ var se, ie;
1350
+ class Ie extends (ie = Error, se = Symbol.toStringTag, ie) {
1351
+ constructor(e) {
1352
+ super(`[Luminix] Route "${e}" not found`);
1353
+ g(this, se, "RouteNotFoundException");
1347
1354
  }
1348
1355
  }
1349
- class Ce {
1350
- constructor(e, t, r, i = "") {
1351
- this.routes = e, this.error = t, this.http = r, this.appUrl = i;
1356
+ class Pe {
1357
+ constructor(t, e, r, i = "") {
1358
+ this.routes = t, this.error = e, this.http = r, this.appUrl = i;
1352
1359
  }
1353
- isRouteTuple(e) {
1354
- if (!Array.isArray(e) || e.length < 2)
1360
+ isRouteTuple(t) {
1361
+ if (!Array.isArray(t) || t.length < 2)
1355
1362
  return !1;
1356
- const [t, ...r] = e;
1357
- if (typeof t != "string")
1363
+ const [e, ...r] = t;
1364
+ if (typeof e != "string")
1358
1365
  return !1;
1359
1366
  const i = ["get", "post", "put", "patch", "delete"];
1360
- return !!r.every((l) => i.includes(l));
1367
+ return !!r.every((h) => i.includes(h));
1361
1368
  }
1362
- extractGenerator(e) {
1363
- let t, r = !1;
1364
- return Array.isArray(e) ? [t, r] = e : t = e, [t, r];
1369
+ extractGenerator(t) {
1370
+ let e, r = !1;
1371
+ return Array.isArray(t) ? [e, r] = t : e = t, [e, r];
1365
1372
  }
1366
- get(e) {
1367
- if (!this.exists(e))
1368
- throw new Be(e);
1369
- return p.get(this.routes, e);
1373
+ get(t) {
1374
+ if (!this.exists(t))
1375
+ throw new Ie(t);
1376
+ return p.get(this.routes, t);
1370
1377
  }
1371
- url(e) {
1372
- return this.appUrl + this.path(e);
1378
+ url(t) {
1379
+ return this.appUrl + this.path(t);
1373
1380
  }
1374
- path(e) {
1375
- const [t, r] = this.extractGenerator(e), i = this.get(t)[0].replace(/^\/|\/$/g, ""), l = /{([^}]+)}/g;
1381
+ path(t) {
1382
+ const [e, r] = this.extractGenerator(t), i = this.get(e)[0].replace(/^\/|\/$/g, ""), h = /{([^}]+)}/g;
1376
1383
  if (r === !1) {
1377
1384
  if (typeof this.replaceRouteParams != "function")
1378
1385
  throw new $("RouteFacade");
1379
1386
  return this.replaceRouteParams(`/${i}`);
1380
1387
  }
1381
- const y = i.match(l), c = y ? y.map((h) => h.slice(1, -1)) : [], u = Object.keys(r), s = c.filter((h) => !u.includes(h)), n = u.filter((h) => !c.includes(h));
1388
+ const m = i.match(h), c = m ? m.map((l) => l.slice(1, -1)) : [], u = Object.keys(r), s = c.filter((l) => !u.includes(l)), n = u.filter((l) => !c.includes(l));
1382
1389
  if (s.length > 0)
1383
1390
  throw new TypeError(`Missing values for parameter(s): ${s.join(", ")}`);
1384
1391
  if (n.length > 0)
1385
1392
  throw new TypeError(`Unexpected parameters: ${n.join(", ")}`);
1386
- return `/${c.reduce((h, d) => h.replace(`{${d}}`, `${r[d]}`), i)}`;
1393
+ return `/${c.reduce((l, d) => l.replace(`{${d}}`, `${r[d]}`), i)}`;
1387
1394
  }
1388
- methods(e) {
1389
- const [t] = this.extractGenerator(e);
1390
- return this.get(t).slice(1);
1395
+ methods(t) {
1396
+ const [e] = this.extractGenerator(t);
1397
+ return this.get(e).slice(1);
1391
1398
  }
1392
- exists(e) {
1393
- return p.has(this.routes, e) && this.isRouteTuple(p.get(this.routes, e));
1399
+ exists(t) {
1400
+ return p.has(this.routes, t) && this.isRouteTuple(p.get(this.routes, t));
1394
1401
  }
1395
1402
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1396
- async call(e, t = (i) => i, r = "default") {
1403
+ async call(t, e = (i) => i, r = "default") {
1397
1404
  if (typeof this.clientOptions != "function" || typeof this.clientError != "function")
1398
1405
  throw new $("RouteFacade");
1399
- const [i, l] = this.extractGenerator(e), [, ...y] = this.get(i), c = this.url(l ? [i, l] : i), u = t(this.http()), s = this.clientOptions({}, i);
1406
+ const [i, h] = this.extractGenerator(t), [, ...m] = this.get(i), c = this.url(h ? [i, h] : i), u = e(this.http()), s = this.clientOptions({}, i);
1400
1407
  p.isEmpty(s) || u.withOptions(s);
1401
- const n = y[0] ?? s.method;
1408
+ const n = m[0] ?? s.method;
1402
1409
  this.error.clear(r);
1403
1410
  const a = await u[n](c);
1404
- if (ge(a)) {
1405
- const h = a.json("errors");
1406
- this.error.set(Object.entries(h).reduce((d, [v, f]) => (d[v] = f.join(" "), d), {}), r);
1411
+ if (ye(a)) {
1412
+ const l = a.json("errors");
1413
+ this.error.set(Object.entries(l).reduce((d, [v, f]) => (d[v] = f.join(" "), d), {}), r);
1407
1414
  } else a.failed() && this.error.set(
1408
1415
  this.clientError({ axios: a.json("message") }, {
1409
1416
  response: a,
1410
1417
  name: i,
1411
- replace: l,
1418
+ replace: h,
1412
1419
  client: u
1413
1420
  }),
1414
1421
  r
@@ -1419,68 +1426,68 @@ class Ce {
1419
1426
  return "route";
1420
1427
  }
1421
1428
  }
1422
- const Ie = re(Ce);
1423
- class Pe {
1429
+ const Le = oe(Pe);
1430
+ class De {
1424
1431
  getClient() {
1425
- return new ye();
1432
+ return new fe();
1426
1433
  }
1427
- baseUrl(e) {
1428
- return this.getClient().baseUrl(e);
1434
+ baseUrl(t) {
1435
+ return this.getClient().baseUrl(t);
1429
1436
  }
1430
1437
  asForm() {
1431
1438
  return this.getClient().asForm();
1432
1439
  }
1433
- accept(e) {
1434
- return this.getClient().accept(e);
1440
+ accept(t) {
1441
+ return this.getClient().accept(t);
1435
1442
  }
1436
1443
  acceptJson() {
1437
1444
  return this.getClient().acceptJson();
1438
1445
  }
1439
- withHeaders(e) {
1440
- return this.getClient().withHeaders(e);
1446
+ withHeaders(t) {
1447
+ return this.getClient().withHeaders(t);
1441
1448
  }
1442
- withOptions(e) {
1443
- return this.getClient().withOptions(e);
1449
+ withOptions(t) {
1450
+ return this.getClient().withOptions(t);
1444
1451
  }
1445
- withData(e) {
1446
- return this.getClient().withData(e);
1452
+ withData(t) {
1453
+ return this.getClient().withData(t);
1447
1454
  }
1448
- withQueryParameters(e) {
1449
- return this.getClient().withQueryParameters(e);
1455
+ withQueryParameters(t) {
1456
+ return this.getClient().withQueryParameters(t);
1450
1457
  }
1451
- withBasicAuth(e, t) {
1452
- return this.getClient().withBasicAuth(e, t);
1458
+ withBasicAuth(t, e) {
1459
+ return this.getClient().withBasicAuth(t, e);
1453
1460
  }
1454
- withToken(e) {
1455
- return this.getClient().withToken(e);
1461
+ withToken(t) {
1462
+ return this.getClient().withToken(t);
1456
1463
  }
1457
1464
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1458
- get(e, t) {
1459
- return this.getClient().get(e, t);
1465
+ get(t, e) {
1466
+ return this.getClient().get(t, e);
1460
1467
  }
1461
1468
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1462
- post(e, t) {
1463
- return this.getClient().post(e, t);
1469
+ post(t, e) {
1470
+ return this.getClient().post(t, e);
1464
1471
  }
1465
1472
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1466
- put(e, t) {
1467
- return this.getClient().put(e, t);
1473
+ put(t, e) {
1474
+ return this.getClient().put(t, e);
1468
1475
  }
1469
1476
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1470
- patch(e, t) {
1471
- return this.getClient().patch(e, t);
1477
+ patch(t, e) {
1478
+ return this.getClient().patch(t, e);
1472
1479
  }
1473
1480
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1474
- delete(e, t) {
1475
- return this.getClient().delete(e, t);
1481
+ delete(t, e) {
1482
+ return this.getClient().delete(t, e);
1476
1483
  }
1477
1484
  }
1478
- const Qe = ne(Pe);
1479
- var se, ie;
1480
- class Le extends (ie = me, se = Symbol.toStringTag, ie) {
1485
+ const He = ae(De);
1486
+ var re, ne;
1487
+ class Je extends (ne = we, re = Symbol.toStringTag, ne) {
1481
1488
  constructor() {
1482
1489
  super(...arguments);
1483
- g(this, se, "LuminixServiceProvider");
1490
+ g(this, re, "LuminixServiceProvider");
1484
1491
  }
1485
1492
  register() {
1486
1493
  this.registerServices(), this.registerMacros(), this.app.on("ready", () => {
@@ -1491,25 +1498,25 @@ class Le extends (ie = me, se = Symbol.toStringTag, ie) {
1491
1498
  this.app.make("model").boot(this.app);
1492
1499
  }
1493
1500
  registerServices() {
1494
- this.app.singleton("auth", () => new we(
1501
+ this.app.singleton("auth", () => new be(
1495
1502
  this.app.make("config"),
1496
1503
  this.app.make("model"),
1497
1504
  this.app.make("route")
1498
1505
  )), this.app.singleton("config", () => {
1499
- const t = new _(p.omit(this.app.configuration, "manifest"));
1500
- return t.has("auth.user") || t.set("auth.user", null), t.lock("auth.user"), t;
1501
- }), this.app.singleton("error", () => new ve()), this.app.singleton("http", () => new Qe()), this.app.singleton("log", () => {
1502
- var t;
1503
- return new be(((t = this.app.configuration.app) == null ? void 0 : t.debug) ?? !1);
1506
+ const e = new _(p.omit(this.app.configuration, "manifest"));
1507
+ return e.has("auth.user") || e.set("auth.user", null), e.lock("auth.user"), e;
1508
+ }), this.app.singleton("error", () => new xe()), this.app.singleton("http", () => new He()), this.app.singleton("log", () => {
1509
+ var e;
1510
+ return new Me(((e = this.app.configuration.app) == null ? void 0 : e.debug) ?? !1);
1504
1511
  }), this.app.singleton("model", () => {
1505
- var t;
1506
- return new je(
1507
- ((t = this.app.configuration.manifest) == null ? void 0 : t.models) ?? {}
1512
+ var e;
1513
+ return new Qe(
1514
+ ((e = this.app.configuration.manifest) == null ? void 0 : e.models) ?? {}
1508
1515
  );
1509
1516
  }), this.app.singleton("route", () => {
1510
- var t, r;
1511
- return new Ie(
1512
- ((t = this.app.configuration.manifest) == null ? void 0 : t.routes) ?? {},
1517
+ var e, r;
1518
+ return new Le(
1519
+ ((e = this.app.configuration.manifest) == null ? void 0 : e.routes) ?? {},
1513
1520
  this.app.make("error"),
1514
1521
  () => this.app.make("http").getClient(),
1515
1522
  (r = this.app.configuration.app) == null ? void 0 : r.url
@@ -1517,110 +1524,110 @@ class Le extends (ie = me, se = Symbol.toStringTag, ie) {
1517
1524
  });
1518
1525
  }
1519
1526
  registerMacros() {
1520
- this.app.macro("environment", (...t) => t.length > 0 ? t.includes(this.app.make("config").get("app.env", "production")) : this.app.make("config").get("app.env", "production")), this.app.macro("getLocale", () => this.app.make("config").get("app.locale", "en")), this.app.macro("hasDebugModeEnabled", () => this.app.make("config").get("app.debug", !1)), this.app.macro("isLocal", () => this.app.make("config").get("app.env", "production") === "local"), this.app.macro("isProduction", () => this.app.make("config").get("app.env", "production") === "production"), p.macro("isModel", function(t) {
1521
- return typeof t == "object" && t !== null && t.__isModel === !0;
1527
+ this.app.macro("environment", (...e) => e.length > 0 ? e.includes(this.app.make("config").get("app.env", "production")) : this.app.make("config").get("app.env", "production")), this.app.macro("getLocale", () => this.app.make("config").get("app.locale", "en")), this.app.macro("hasDebugModeEnabled", () => this.app.make("config").get("app.debug", !1)), this.app.macro("isLocal", () => this.app.make("config").get("app.env", "production") === "local"), this.app.macro("isProduction", () => this.app.make("config").get("app.env", "production") === "production"), p.macro("isModel", function(e) {
1528
+ return typeof e == "object" && e !== null && e.__isModel === !0;
1522
1529
  });
1523
1530
  }
1524
1531
  }
1525
- class De {
1532
+ class Ue {
1526
1533
  constructor() {
1527
1534
  g(this, "app");
1528
1535
  }
1529
1536
  getFacadeAccessor() {
1530
- return this.app || (this.app = new (ne(fe))([
1531
- Le
1537
+ return this.app || (this.app = new (ae(ve))([
1538
+ Je
1532
1539
  ])), this.app;
1533
1540
  }
1534
1541
  down() {
1535
1542
  this.app && (this.app.flush(), delete this.app);
1536
1543
  }
1537
- setInstance(e) {
1538
- this.down(), this.app = e;
1544
+ setInstance(t) {
1545
+ this.down(), this.app = t;
1539
1546
  }
1540
1547
  }
1541
- const x = M(De);
1548
+ const x = M(Ue);
1542
1549
  function E(o = void 0) {
1543
1550
  return typeof o != "string" ? x : x.make(o);
1544
1551
  }
1545
- function Ye() {
1552
+ function tt() {
1546
1553
  return E("auth");
1547
1554
  }
1548
- function Ze(o, e) {
1549
- const t = E("config");
1550
- return typeof o > "u" ? t : t.get(o, e);
1555
+ function st(o, t) {
1556
+ const e = E("config");
1557
+ return typeof o > "u" ? e : e.get(o, t);
1551
1558
  }
1552
- function et(o, e = "default") {
1553
- return o ? E().make("error").get(o, e) : E().make("error");
1559
+ function it(o, t = "default") {
1560
+ return o ? E().make("error").get(o, t) : E().make("error");
1554
1561
  }
1555
- function tt(...o) {
1556
- const e = E("log");
1557
- return o.length ? e.debug(...o) : e;
1562
+ function rt(...o) {
1563
+ const t = E("log");
1564
+ return o.length ? t.debug(...o) : t;
1558
1565
  }
1559
- function st(o) {
1560
- const e = E("model");
1561
- return o ? e.make(o) : e;
1566
+ function nt(o) {
1567
+ const t = E("model");
1568
+ return o ? t.make(o) : t;
1562
1569
  }
1563
- function it(o, e = !1) {
1564
- const t = E("route");
1565
- return o ? e ? t.url([o, e]) : t.url(o) : t;
1570
+ function ot(o, t = !1) {
1571
+ const e = E("route");
1572
+ return o ? t ? e.url([o, t]) : e.url(o) : e;
1566
1573
  }
1567
- class He {
1574
+ class Fe {
1568
1575
  getFacadeAccessor() {
1569
1576
  return "auth";
1570
1577
  }
1571
1578
  }
1572
- const rt = M(He, x);
1573
- class Je {
1579
+ const at = M(Fe, x);
1580
+ class We {
1574
1581
  getFacadeAccessor() {
1575
1582
  return "config";
1576
1583
  }
1577
1584
  }
1578
- const nt = M(Je, x);
1579
- class Ue {
1585
+ const ut = M(We, x);
1586
+ class Ge {
1580
1587
  getFacadeAccessor() {
1581
1588
  return "error";
1582
1589
  }
1583
1590
  }
1584
- const ot = M(Ue, x);
1585
- class Fe {
1591
+ const ht = M(Ge, x);
1592
+ class Ve {
1586
1593
  getFacadeAccessor() {
1587
1594
  return "http";
1588
1595
  }
1589
1596
  }
1590
- const at = M(Fe, x);
1591
- class We {
1597
+ const lt = M(Ve, x);
1598
+ class ze {
1592
1599
  getFacadeAccessor() {
1593
1600
  return "log";
1594
1601
  }
1595
1602
  }
1596
- const ut = M(We, x);
1597
- class Ge {
1603
+ const ct = M(ze, x);
1604
+ class Xe {
1598
1605
  getFacadeAccessor() {
1599
1606
  return "model";
1600
1607
  }
1601
1608
  }
1602
- const ht = M(Ge, x);
1603
- class Ve {
1609
+ const dt = M(Xe, x);
1610
+ class Ye {
1604
1611
  getFacadeAccessor() {
1605
1612
  return "route";
1606
1613
  }
1607
1614
  }
1608
- const lt = M(Ve, x);
1615
+ const pt = M(Ye, x);
1609
1616
  export {
1610
1617
  x as App,
1611
- rt as Auth,
1612
- nt as Config,
1613
- ot as Error,
1614
- at as Http,
1615
- ut as Log,
1616
- ht as Model,
1617
- lt as Route,
1618
+ at as Auth,
1619
+ ut as Config,
1620
+ ht as Error,
1621
+ lt as Http,
1622
+ ct as Log,
1623
+ dt as Model,
1624
+ pt as Route,
1618
1625
  E as app,
1619
- Ye as auth,
1626
+ tt as auth,
1620
1627
  K as collect,
1621
- Ze as config,
1622
- et as error,
1623
- tt as log,
1624
- st as model,
1625
- it as route
1628
+ st as config,
1629
+ it as error,
1630
+ rt as log,
1631
+ nt as model,
1632
+ ot as route
1626
1633
  };