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