@luminix/core 0.0.1-beta.10 → 0.0.1-beta.11
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 +15 -10
- package/dist/types/Model.d.ts +2 -0
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var Ke = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var L = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
5
|
var je = (n, e, t) => e in n ? Ke(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
6
|
-
var m = (n, e, t) => je(n, typeof e != "symbol" ? e + "" : e, t), K = (n, e, t) => e.has(n) ||
|
|
7
|
-
var h = (n, e, t) => (K(n, e, "read from private field"), t ? t.call(n) : e.get(n)), j = (n, e, t) => e.has(n) ?
|
|
6
|
+
var m = (n, e, t) => je(n, typeof e != "symbol" ? e + "" : e, t), K = (n, e, t) => e.has(n) || L("Cannot " + t);
|
|
7
|
+
var h = (n, e, t) => (K(n, e, "read from private field"), t ? t.call(n) : e.get(n)), j = (n, e, t) => e.has(n) ? L("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), D = (n, e, t, r) => (K(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t), U = (n, e, t) => (K(n, e, "access private method"), t);
|
|
8
8
|
import d from "lodash";
|
|
9
9
|
import { produce as N, isDraftable as Pe } from "immer";
|
|
10
10
|
import I, { isAxiosError as ke } from "axios";
|
|
@@ -15,7 +15,7 @@ class Qe extends (X = Error, V = Symbol.toStringTag, X) {
|
|
|
15
15
|
m(this, V, "FacadeNotFoundException");
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class Ce {
|
|
19
19
|
constructor(e) {
|
|
20
20
|
m(this, "_user");
|
|
21
21
|
this.app = e;
|
|
@@ -64,7 +64,7 @@ class Le {
|
|
|
64
64
|
return ((e = this.user()) == null ? void 0 : e.getKey()) || null;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
class
|
|
67
|
+
class Le {
|
|
68
68
|
constructor(e) {
|
|
69
69
|
this._debug = e;
|
|
70
70
|
}
|
|
@@ -1294,6 +1294,7 @@ function Ve(n, e) {
|
|
|
1294
1294
|
m(this, "_relations", {});
|
|
1295
1295
|
m(this, "_changedKeys", []);
|
|
1296
1296
|
m(this, "exists", !1);
|
|
1297
|
+
m(this, "wasRecentlyCreated", !1);
|
|
1297
1298
|
m(this, r, d.upperFirst(d.camelCase(e)));
|
|
1298
1299
|
this.makeRelations(), this.makeAttributes(s);
|
|
1299
1300
|
}
|
|
@@ -1337,7 +1338,7 @@ function Ve(n, e) {
|
|
|
1337
1338
|
}
|
|
1338
1339
|
makePrimaryKeyReplacer() {
|
|
1339
1340
|
return {
|
|
1340
|
-
[this.
|
|
1341
|
+
[this.getKeyName()]: this.getKey()
|
|
1341
1342
|
};
|
|
1342
1343
|
}
|
|
1343
1344
|
dispatchChangeEvent(s) {
|
|
@@ -1561,6 +1562,10 @@ function Ve(n, e) {
|
|
|
1561
1562
|
this.makePrimaryKeyReplacer()
|
|
1562
1563
|
];
|
|
1563
1564
|
}
|
|
1565
|
+
getLabel() {
|
|
1566
|
+
const { labeledBy: s } = n.make("model").schema(e);
|
|
1567
|
+
return this.getAttribute(s);
|
|
1568
|
+
}
|
|
1564
1569
|
async refresh() {
|
|
1565
1570
|
if (!this.exists)
|
|
1566
1571
|
throw new Re(e, "refresh");
|
|
@@ -1592,7 +1597,7 @@ function Ve(n, e) {
|
|
|
1592
1597
|
}
|
|
1593
1598
|
);
|
|
1594
1599
|
if ([200, 201].includes(p.status))
|
|
1595
|
-
return this.makeAttributes(p.data), this.exists = !0, this.dispatchSaveEvent(), a ? this.dispatchUpdateEvent(p.data) : this.dispatchCreateEvent(p.data), p;
|
|
1600
|
+
return this.makeAttributes(p.data), this.exists = !0, this.dispatchSaveEvent(), a ? this.dispatchUpdateEvent(p.data) : (this.wasRecentlyCreated = !0, this.dispatchCreateEvent(p.data)), p;
|
|
1596
1601
|
throw p;
|
|
1597
1602
|
} catch (u) {
|
|
1598
1603
|
throw this.dispatchErrorEvent(u, "save"), u;
|
|
@@ -2371,7 +2376,7 @@ class at {
|
|
|
2371
2376
|
} catch (g) {
|
|
2372
2377
|
if (ot(g)) {
|
|
2373
2378
|
const { errors: qe } = g.response.data;
|
|
2374
|
-
this.error.set(Object.entries(qe).reduce((
|
|
2379
|
+
this.error.set(Object.entries(qe).reduce((C, [Ie, Fe]) => (C[Ie] = Fe.join(" "), C), {}), f);
|
|
2375
2380
|
} else I.isAxiosError(g) && this.error.set(
|
|
2376
2381
|
this.axiosError({ axios: g.message }, {
|
|
2377
2382
|
error: g,
|
|
@@ -2431,12 +2436,12 @@ class ct {
|
|
|
2431
2436
|
} catch (g) {
|
|
2432
2437
|
(p = e.app) != null && p.debug && console.error(g);
|
|
2433
2438
|
}
|
|
2434
|
-
this.bind("log", new
|
|
2439
|
+
this.bind("log", new Le(!!((w = e.app) != null && w.debug)));
|
|
2435
2440
|
const { log: r } = this.facades, {
|
|
2436
2441
|
manifest: { routes: i = {}, models: s = {} } = {},
|
|
2437
2442
|
...u
|
|
2438
2443
|
} = e;
|
|
2439
|
-
this.bind("config", new A(u)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user"), this.bind("error", new ht()), this.bind("route", new lt(i, this.facades.error, ((x = e.app) == null ? void 0 : x.url) ?? "")), this.bind("model", new it(s)), this.bind("auth", new
|
|
2444
|
+
this.bind("config", new A(u)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user"), this.bind("error", new ht()), this.bind("route", new lt(i, this.facades.error, ((x = e.app) == null ? void 0 : x.url) ?? "")), this.bind("model", new it(s)), this.bind("auth", new Ce(this)), this.emit("booting");
|
|
2440
2445
|
for (const g of Object.values(this.facades))
|
|
2441
2446
|
typeof g == "object" && g !== null && "boot" in g && typeof g.boot == "function" && g.boot(this);
|
|
2442
2447
|
for (const g of this._plugins)
|
package/dist/types/Model.d.ts
CHANGED
|
@@ -42,10 +42,12 @@ export declare class BaseModel implements EventSource<ModelEvents> {
|
|
|
42
42
|
get isDirty(): boolean;
|
|
43
43
|
get casts(): ModelSchemaAttributes['casts'];
|
|
44
44
|
exists: boolean;
|
|
45
|
+
wasRecentlyCreated: boolean;
|
|
45
46
|
getAttribute(key: string): unknown;
|
|
46
47
|
setAttribute(key: string, value: unknown): void;
|
|
47
48
|
getKey(): string | number;
|
|
48
49
|
getKeyName(): string;
|
|
50
|
+
getLabel(): string;
|
|
49
51
|
fill(attributes: object): void;
|
|
50
52
|
toJson(): JsonObject;
|
|
51
53
|
diff(): JsonObject;
|