pinia-orm-edge 1.9.3-28676556.ba65169 → 1.10.0-28683029.86bd359
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/casts.d.cts +1 -1
- package/dist/casts.d.mts +1 -1
- package/dist/casts.d.ts +1 -1
- package/dist/decorators.cjs +11 -0
- package/dist/decorators.d.cts +8 -3
- package/dist/decorators.d.mts +8 -3
- package/dist/decorators.d.ts +8 -3
- package/dist/decorators.mjs +11 -1
- package/dist/helpers.d.cts +1 -1
- package/dist/helpers.d.mts +1 -1
- package/dist/helpers.d.ts +1 -1
- package/dist/index.cjs +282 -158
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +282 -158
- package/dist/nanoid/async.d.cts +1 -1
- package/dist/nanoid/async.d.mts +1 -1
- package/dist/nanoid/async.d.ts +1 -1
- package/dist/nanoid/index.d.cts +1 -1
- package/dist/nanoid/index.d.mts +1 -1
- package/dist/nanoid/index.d.ts +1 -1
- package/dist/nanoid/non-secure.d.cts +1 -1
- package/dist/nanoid/non-secure.d.mts +1 -1
- package/dist/nanoid/non-secure.d.ts +1 -1
- package/dist/shared/{pinia-orm.ae01a7ce.d.cts → pinia-orm.52557866.d.cts} +4 -0
- package/dist/shared/{pinia-orm.ae01a7ce.d.mts → pinia-orm.52557866.d.mts} +4 -0
- package/dist/shared/{pinia-orm.ae01a7ce.d.ts → pinia-orm.52557866.d.ts} +4 -0
- package/dist/uuid/v1.d.cts +1 -1
- package/dist/uuid/v1.d.mts +1 -1
- package/dist/uuid/v1.d.ts +1 -1
- package/dist/uuid/v4.d.cts +1 -1
- package/dist/uuid/v4.d.mts +1 -1
- package/dist/uuid/v4.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -5,10 +5,10 @@ const pinia = require('pinia');
|
|
5
5
|
const normalizr = require('@pinia-orm/normalizr');
|
6
6
|
const CastAttribute = require('./shared/pinia-orm.a7e3e0f3.cjs');
|
7
7
|
|
8
|
-
var __defProp$
|
9
|
-
var __defNormalProp$
|
10
|
-
var __publicField$
|
11
|
-
__defNormalProp$
|
8
|
+
var __defProp$l = Object.defineProperty;
|
9
|
+
var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
10
|
+
var __publicField$l = (obj, key, value) => {
|
11
|
+
__defNormalProp$l(obj, typeof key !== "symbol" ? key + "" : key, value);
|
12
12
|
return value;
|
13
13
|
};
|
14
14
|
class Attribute {
|
@@ -19,11 +19,11 @@ class Attribute {
|
|
19
19
|
/**
|
20
20
|
* The model instance.
|
21
21
|
*/
|
22
|
-
__publicField$
|
22
|
+
__publicField$l(this, "model");
|
23
23
|
/**
|
24
24
|
* The field name
|
25
25
|
*/
|
26
|
-
__publicField$
|
26
|
+
__publicField$l(this, "key");
|
27
27
|
this.model = model;
|
28
28
|
this.key = "";
|
29
29
|
}
|
@@ -36,10 +36,10 @@ class Attribute {
|
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
39
|
-
var __defProp$
|
40
|
-
var __defNormalProp$
|
41
|
-
var __publicField$
|
42
|
-
__defNormalProp$
|
39
|
+
var __defProp$k = Object.defineProperty;
|
40
|
+
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
41
|
+
var __publicField$k = (obj, key, value) => {
|
42
|
+
__defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
|
43
43
|
return value;
|
44
44
|
};
|
45
45
|
class Relation extends Attribute {
|
@@ -51,15 +51,15 @@ class Relation extends Attribute {
|
|
51
51
|
/**
|
52
52
|
* The parent model.
|
53
53
|
*/
|
54
|
-
__publicField$
|
54
|
+
__publicField$k(this, "parent");
|
55
55
|
/**
|
56
56
|
* The related model.
|
57
57
|
*/
|
58
|
-
__publicField$
|
58
|
+
__publicField$k(this, "related");
|
59
59
|
/**
|
60
60
|
* The delete mode
|
61
61
|
*/
|
62
|
-
__publicField$
|
62
|
+
__publicField$k(this, "onDeleteMode");
|
63
63
|
this.parent = parent;
|
64
64
|
this.related = related;
|
65
65
|
}
|
@@ -121,10 +121,10 @@ class Relation extends Attribute {
|
|
121
121
|
}
|
122
122
|
}
|
123
123
|
|
124
|
-
var __defProp$
|
125
|
-
var __defNormalProp$
|
126
|
-
var __publicField$
|
127
|
-
__defNormalProp$
|
124
|
+
var __defProp$j = Object.defineProperty;
|
125
|
+
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
126
|
+
var __publicField$j = (obj, key, value) => {
|
127
|
+
__defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
|
128
128
|
return value;
|
129
129
|
};
|
130
130
|
class MorphTo extends Relation {
|
@@ -136,23 +136,23 @@ class MorphTo extends Relation {
|
|
136
136
|
/**
|
137
137
|
* The related models.
|
138
138
|
*/
|
139
|
-
__publicField$
|
139
|
+
__publicField$j(this, "relatedModels");
|
140
140
|
/**
|
141
141
|
* The related model dictionary.
|
142
142
|
*/
|
143
|
-
__publicField$
|
143
|
+
__publicField$j(this, "relatedTypes");
|
144
144
|
/**
|
145
145
|
* The field name that contains id of the parent model.
|
146
146
|
*/
|
147
|
-
__publicField$
|
147
|
+
__publicField$j(this, "morphId");
|
148
148
|
/**
|
149
149
|
* The field name that contains type of the parent model.
|
150
150
|
*/
|
151
|
-
__publicField$
|
151
|
+
__publicField$j(this, "morphType");
|
152
152
|
/**
|
153
153
|
* The associated key of the child model.
|
154
154
|
*/
|
155
|
-
__publicField$
|
155
|
+
__publicField$j(this, "ownerKey");
|
156
156
|
this.relatedModels = relatedModels;
|
157
157
|
this.relatedTypes = this.createRelatedTypes(relatedModels);
|
158
158
|
this.morphId = morphId;
|
@@ -267,10 +267,10 @@ class MorphTo extends Relation {
|
|
267
267
|
}
|
268
268
|
}
|
269
269
|
|
270
|
-
var __defProp$
|
271
|
-
var __defNormalProp$
|
272
|
-
var __publicField$
|
273
|
-
__defNormalProp$
|
270
|
+
var __defProp$i = Object.defineProperty;
|
271
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
272
|
+
var __publicField$i = (obj, key, value) => {
|
273
|
+
__defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
|
274
274
|
return value;
|
275
275
|
};
|
276
276
|
class Type extends Attribute {
|
@@ -282,11 +282,11 @@ class Type extends Attribute {
|
|
282
282
|
/**
|
283
283
|
* The raw default value for the attribute (can be a function).
|
284
284
|
*/
|
285
|
-
__publicField$
|
285
|
+
__publicField$i(this, "rawDefaultValue");
|
286
286
|
/**
|
287
287
|
* Whether the attribute accepts `null` value or not.
|
288
288
|
*/
|
289
|
-
__publicField$
|
289
|
+
__publicField$i(this, "isNullable", true);
|
290
290
|
this.rawDefaultValue = defaultValue;
|
291
291
|
}
|
292
292
|
/**
|
@@ -325,24 +325,24 @@ class Type extends Attribute {
|
|
325
325
|
}
|
326
326
|
}
|
327
327
|
|
328
|
-
var __defProp$
|
329
|
-
var __defNormalProp$
|
330
|
-
var __publicField$
|
331
|
-
__defNormalProp$
|
328
|
+
var __defProp$h = Object.defineProperty;
|
329
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
330
|
+
var __publicField$h = (obj, key, value) => {
|
331
|
+
__defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
|
332
332
|
return value;
|
333
333
|
};
|
334
334
|
class Uid extends Type {
|
335
335
|
constructor(model, options = {}) {
|
336
336
|
super(model);
|
337
|
-
__publicField$
|
337
|
+
__publicField$h(this, "options");
|
338
338
|
// This alphabet uses `A-Za-z0-9_-` symbols.
|
339
339
|
// The order of characters is optimized for better gzip and brotli compression.
|
340
340
|
// References to the same file (works both for gzip and brotli):
|
341
341
|
// `'use`, `andom`, and `rict'`
|
342
342
|
// References to the brotli default dictionary:
|
343
343
|
// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
|
344
|
-
__publicField$
|
345
|
-
__publicField$
|
344
|
+
__publicField$h(this, "alphabet", "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict");
|
345
|
+
__publicField$h(this, "size", 21);
|
346
346
|
this.options = typeof options === "number" ? { size: options } : options;
|
347
347
|
this.alphabet = this.options.alphabet ?? this.alphabet;
|
348
348
|
this.size = this.options.size ?? this.size;
|
@@ -359,10 +359,10 @@ class Uid extends Type {
|
|
359
359
|
}
|
360
360
|
}
|
361
361
|
|
362
|
-
var __defProp$
|
363
|
-
var __defNormalProp$
|
364
|
-
var __publicField$
|
365
|
-
__defNormalProp$
|
362
|
+
var __defProp$g = Object.defineProperty;
|
363
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
364
|
+
var __publicField$g = (obj, key, value) => {
|
365
|
+
__defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
|
366
366
|
return value;
|
367
367
|
};
|
368
368
|
class Schema {
|
@@ -373,11 +373,11 @@ class Schema {
|
|
373
373
|
/**
|
374
374
|
* The list of generated schemas.
|
375
375
|
*/
|
376
|
-
__publicField$
|
376
|
+
__publicField$g(this, "schemas", {});
|
377
377
|
/**
|
378
378
|
* The model instance.
|
379
379
|
*/
|
380
|
-
__publicField$
|
380
|
+
__publicField$g(this, "model");
|
381
381
|
this.model = model;
|
382
382
|
}
|
383
383
|
/**
|
@@ -492,10 +492,10 @@ class Schema {
|
|
492
492
|
}
|
493
493
|
}
|
494
494
|
|
495
|
-
var __defProp$
|
496
|
-
var __defNormalProp$
|
497
|
-
var __publicField$
|
498
|
-
__defNormalProp$
|
495
|
+
var __defProp$f = Object.defineProperty;
|
496
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
497
|
+
var __publicField$f = (obj, key, value) => {
|
498
|
+
__defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
|
499
499
|
return value;
|
500
500
|
};
|
501
501
|
class Interpreter {
|
@@ -506,7 +506,7 @@ class Interpreter {
|
|
506
506
|
/**
|
507
507
|
* The model object.
|
508
508
|
*/
|
509
|
-
__publicField$
|
509
|
+
__publicField$f(this, "model");
|
510
510
|
this.model = model;
|
511
511
|
}
|
512
512
|
process(data) {
|
@@ -594,10 +594,10 @@ function useDataStore(id, options, query) {
|
|
594
594
|
});
|
595
595
|
}
|
596
596
|
|
597
|
-
var __defProp$
|
598
|
-
var __defNormalProp$
|
599
|
-
var __publicField$
|
600
|
-
__defNormalProp$
|
597
|
+
var __defProp$e = Object.defineProperty;
|
598
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
599
|
+
var __publicField$e = (obj, key, value) => {
|
600
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
601
601
|
return value;
|
602
602
|
};
|
603
603
|
class BelongsToMany extends Relation {
|
@@ -609,27 +609,27 @@ class BelongsToMany extends Relation {
|
|
609
609
|
/**
|
610
610
|
* The pivot model.
|
611
611
|
*/
|
612
|
-
__publicField$
|
612
|
+
__publicField$e(this, "pivot");
|
613
613
|
/**
|
614
614
|
* The foreign key of the parent model.
|
615
615
|
*/
|
616
|
-
__publicField$
|
616
|
+
__publicField$e(this, "foreignPivotKey");
|
617
617
|
/**
|
618
618
|
* The associated key of the relation.
|
619
619
|
*/
|
620
|
-
__publicField$
|
620
|
+
__publicField$e(this, "relatedPivotKey");
|
621
621
|
/**
|
622
622
|
* The key name of the parent model.
|
623
623
|
*/
|
624
|
-
__publicField$
|
624
|
+
__publicField$e(this, "parentKey");
|
625
625
|
/**
|
626
626
|
* The key name of the related model.
|
627
627
|
*/
|
628
|
-
__publicField$
|
628
|
+
__publicField$e(this, "relatedKey");
|
629
629
|
/**
|
630
630
|
* The key name of the pivot data.
|
631
631
|
*/
|
632
|
-
__publicField$
|
632
|
+
__publicField$e(this, "pivotKey", "pivot");
|
633
633
|
this.pivot = pivot;
|
634
634
|
this.foreignPivotKey = foreignPivotKey;
|
635
635
|
this.relatedPivotKey = relatedPivotKey;
|
@@ -690,10 +690,10 @@ class BelongsToMany extends Relation {
|
|
690
690
|
}
|
691
691
|
}
|
692
692
|
|
693
|
-
var __defProp$
|
694
|
-
var __defNormalProp$
|
695
|
-
var __publicField$
|
696
|
-
__defNormalProp$
|
693
|
+
var __defProp$d = Object.defineProperty;
|
694
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
695
|
+
var __publicField$d = (obj, key, value) => {
|
696
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
697
697
|
return value;
|
698
698
|
};
|
699
699
|
class Query {
|
@@ -704,58 +704,58 @@ class Query {
|
|
704
704
|
/**
|
705
705
|
* The database instance.
|
706
706
|
*/
|
707
|
-
__publicField$
|
707
|
+
__publicField$d(this, "database");
|
708
708
|
/**
|
709
709
|
* The model object.
|
710
710
|
*/
|
711
|
-
__publicField$
|
711
|
+
__publicField$d(this, "model");
|
712
712
|
/**
|
713
713
|
* The where constraints for the query.
|
714
714
|
*/
|
715
|
-
__publicField$
|
715
|
+
__publicField$d(this, "wheres", []);
|
716
716
|
/**
|
717
717
|
* The orderings for the query.
|
718
718
|
*/
|
719
|
-
__publicField$
|
719
|
+
__publicField$d(this, "orders", []);
|
720
720
|
/**
|
721
721
|
* The orderings for the query.
|
722
722
|
*/
|
723
|
-
__publicField$
|
723
|
+
__publicField$d(this, "groups", []);
|
724
724
|
/**
|
725
725
|
* The maximum number of records to return.
|
726
726
|
*/
|
727
|
-
__publicField$
|
727
|
+
__publicField$d(this, "take", null);
|
728
728
|
/**
|
729
729
|
* The number of records to skip.
|
730
730
|
*/
|
731
|
-
__publicField$
|
731
|
+
__publicField$d(this, "skip", 0);
|
732
732
|
/**
|
733
733
|
* Fields that should be visible.
|
734
734
|
*/
|
735
|
-
__publicField$
|
735
|
+
__publicField$d(this, "visible", ["*"]);
|
736
736
|
/**
|
737
737
|
* Fields that should be hidden.
|
738
738
|
*/
|
739
|
-
__publicField$
|
739
|
+
__publicField$d(this, "hidden", []);
|
740
740
|
/**
|
741
741
|
* The cache object.
|
742
742
|
*/
|
743
|
-
__publicField$
|
743
|
+
__publicField$d(this, "cache");
|
744
744
|
/**
|
745
745
|
* The relationships that should be eager loaded.
|
746
746
|
*/
|
747
|
-
__publicField$
|
747
|
+
__publicField$d(this, "eagerLoad", {});
|
748
748
|
/**
|
749
749
|
* The pinia store.
|
750
750
|
*/
|
751
|
-
__publicField$
|
752
|
-
__publicField$
|
753
|
-
__publicField$
|
754
|
-
__publicField$
|
751
|
+
__publicField$d(this, "pinia");
|
752
|
+
__publicField$d(this, "fromCache", false);
|
753
|
+
__publicField$d(this, "cacheConfig", {});
|
754
|
+
__publicField$d(this, "getNewHydrated", false);
|
755
755
|
/**
|
756
756
|
* Hydrated models. They are stored to prevent rerendering of child components.
|
757
757
|
*/
|
758
|
-
__publicField$
|
758
|
+
__publicField$d(this, "hydratedDataCache");
|
759
759
|
this.database = database;
|
760
760
|
this.model = model;
|
761
761
|
this.pinia = pinia;
|
@@ -1550,10 +1550,10 @@ class Query {
|
|
1550
1550
|
}
|
1551
1551
|
}
|
1552
1552
|
|
1553
|
-
var __defProp$
|
1554
|
-
var __defNormalProp$
|
1555
|
-
var __publicField$
|
1556
|
-
__defNormalProp$
|
1553
|
+
var __defProp$c = Object.defineProperty;
|
1554
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
1555
|
+
var __publicField$c = (obj, key, value) => {
|
1556
|
+
__defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
|
1557
1557
|
return value;
|
1558
1558
|
};
|
1559
1559
|
var __accessCheck = (obj, member, msg) => {
|
@@ -1573,7 +1573,7 @@ var _a, _map;
|
|
1573
1573
|
class WeakCache {
|
1574
1574
|
constructor() {
|
1575
1575
|
// @ts-expect-error dont know
|
1576
|
-
__publicField$
|
1576
|
+
__publicField$c(this, _a);
|
1577
1577
|
__privateAdd(this, _map, /* @__PURE__ */ new Map());
|
1578
1578
|
}
|
1579
1579
|
has(key) {
|
@@ -1656,10 +1656,10 @@ const CONFIG_DEFAULTS = {
|
|
1656
1656
|
};
|
1657
1657
|
const config = { ...CONFIG_DEFAULTS };
|
1658
1658
|
|
1659
|
-
var __defProp$
|
1660
|
-
var __defNormalProp$
|
1661
|
-
var __publicField$
|
1662
|
-
__defNormalProp$
|
1659
|
+
var __defProp$b = Object.defineProperty;
|
1660
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
1661
|
+
var __publicField$b = (obj, key, value) => {
|
1662
|
+
__defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
1663
1663
|
return value;
|
1664
1664
|
};
|
1665
1665
|
class Repository {
|
@@ -1670,31 +1670,31 @@ class Repository {
|
|
1670
1670
|
/**
|
1671
1671
|
* The database instance.
|
1672
1672
|
*/
|
1673
|
-
__publicField$
|
1673
|
+
__publicField$b(this, "database");
|
1674
1674
|
/**
|
1675
1675
|
* The model instance.
|
1676
1676
|
*/
|
1677
|
-
__publicField$
|
1677
|
+
__publicField$b(this, "model");
|
1678
1678
|
/**
|
1679
1679
|
* The pinia instance
|
1680
1680
|
*/
|
1681
|
-
__publicField$
|
1681
|
+
__publicField$b(this, "pinia");
|
1682
1682
|
/**
|
1683
1683
|
* The cache instance
|
1684
1684
|
*/
|
1685
|
-
__publicField$
|
1685
|
+
__publicField$b(this, "queryCache");
|
1686
1686
|
/**
|
1687
1687
|
* Hydrated models. They are stored to prevent rerendering of child components.
|
1688
1688
|
*/
|
1689
|
-
__publicField$
|
1689
|
+
__publicField$b(this, "hydratedDataCache");
|
1690
1690
|
/**
|
1691
1691
|
* The model object to be used for the custom repository.
|
1692
1692
|
*/
|
1693
|
-
__publicField$
|
1693
|
+
__publicField$b(this, "use");
|
1694
1694
|
/**
|
1695
1695
|
* Global config
|
1696
1696
|
*/
|
1697
|
-
__publicField$
|
1697
|
+
__publicField$b(this, "config");
|
1698
1698
|
this.config = config;
|
1699
1699
|
this.database = database;
|
1700
1700
|
this.pinia = pinia;
|
@@ -1965,16 +1965,16 @@ class Repository {
|
|
1965
1965
|
* used when retrieving repository instance from `store.$repo()` method to
|
1966
1966
|
* determine whether the passed in class is either a repository or a model.
|
1967
1967
|
*/
|
1968
|
-
__publicField$
|
1968
|
+
__publicField$b(Repository, "_isRepository", true);
|
1969
1969
|
/**
|
1970
1970
|
* The model object to be used for the custom repository.
|
1971
1971
|
*/
|
1972
|
-
__publicField$
|
1972
|
+
__publicField$b(Repository, "useModel");
|
1973
1973
|
|
1974
|
-
var __defProp$
|
1975
|
-
var __defNormalProp$
|
1976
|
-
var __publicField$
|
1977
|
-
__defNormalProp$
|
1974
|
+
var __defProp$a = Object.defineProperty;
|
1975
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
1976
|
+
var __publicField$a = (obj, key, value) => {
|
1977
|
+
__defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
1978
1978
|
return value;
|
1979
1979
|
};
|
1980
1980
|
class Database {
|
@@ -1982,7 +1982,7 @@ class Database {
|
|
1982
1982
|
/**
|
1983
1983
|
* The list of registered models.
|
1984
1984
|
*/
|
1985
|
-
__publicField$
|
1985
|
+
__publicField$a(this, "models", {});
|
1986
1986
|
}
|
1987
1987
|
/**
|
1988
1988
|
* Register the given model.
|
@@ -2122,10 +2122,10 @@ class Boolean extends Type {
|
|
2122
2122
|
}
|
2123
2123
|
}
|
2124
2124
|
|
2125
|
-
var __defProp$
|
2126
|
-
var __defNormalProp$
|
2127
|
-
var __publicField$
|
2128
|
-
__defNormalProp$
|
2125
|
+
var __defProp$9 = Object.defineProperty;
|
2126
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2127
|
+
var __publicField$9 = (obj, key, value) => {
|
2128
|
+
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2129
2129
|
return value;
|
2130
2130
|
};
|
2131
2131
|
class HasOne extends Relation {
|
@@ -2137,11 +2137,11 @@ class HasOne extends Relation {
|
|
2137
2137
|
/**
|
2138
2138
|
* The foreign key of the parent model.
|
2139
2139
|
*/
|
2140
|
-
__publicField$
|
2140
|
+
__publicField$9(this, "foreignKey");
|
2141
2141
|
/**
|
2142
2142
|
* The local key of the parent model.
|
2143
2143
|
*/
|
2144
|
-
__publicField$
|
2144
|
+
__publicField$9(this, "localKey");
|
2145
2145
|
this.foreignKey = foreignKey;
|
2146
2146
|
this.localKey = localKey;
|
2147
2147
|
}
|
@@ -2205,10 +2205,10 @@ class HasOne extends Relation {
|
|
2205
2205
|
}
|
2206
2206
|
}
|
2207
2207
|
|
2208
|
-
var __defProp$
|
2209
|
-
var __defNormalProp$
|
2210
|
-
var __publicField$
|
2211
|
-
__defNormalProp$
|
2208
|
+
var __defProp$8 = Object.defineProperty;
|
2209
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2210
|
+
var __publicField$8 = (obj, key, value) => {
|
2211
|
+
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2212
2212
|
return value;
|
2213
2213
|
};
|
2214
2214
|
class BelongsTo extends Relation {
|
@@ -2220,15 +2220,15 @@ class BelongsTo extends Relation {
|
|
2220
2220
|
/**
|
2221
2221
|
* The child model instance of the relation.
|
2222
2222
|
*/
|
2223
|
-
__publicField$
|
2223
|
+
__publicField$8(this, "child");
|
2224
2224
|
/**
|
2225
2225
|
* The foreign key of the parent model.
|
2226
2226
|
*/
|
2227
|
-
__publicField$
|
2227
|
+
__publicField$8(this, "foreignKey");
|
2228
2228
|
/**
|
2229
2229
|
* The associated key on the parent model.
|
2230
2230
|
*/
|
2231
|
-
__publicField$
|
2231
|
+
__publicField$8(this, "ownerKey");
|
2232
2232
|
this.foreignKey = foreignKey;
|
2233
2233
|
this.ownerKey = ownerKey;
|
2234
2234
|
this.child = child;
|
@@ -2305,10 +2305,10 @@ class BelongsTo extends Relation {
|
|
2305
2305
|
}
|
2306
2306
|
}
|
2307
2307
|
|
2308
|
-
var __defProp$
|
2309
|
-
var __defNormalProp$
|
2310
|
-
var __publicField$
|
2311
|
-
__defNormalProp$
|
2308
|
+
var __defProp$7 = Object.defineProperty;
|
2309
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2310
|
+
var __publicField$7 = (obj, key, value) => {
|
2311
|
+
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2312
2312
|
return value;
|
2313
2313
|
};
|
2314
2314
|
class HasMany extends Relation {
|
@@ -2320,11 +2320,11 @@ class HasMany extends Relation {
|
|
2320
2320
|
/**
|
2321
2321
|
* The foreign key of the parent model.
|
2322
2322
|
*/
|
2323
|
-
__publicField$
|
2323
|
+
__publicField$7(this, "foreignKey");
|
2324
2324
|
/**
|
2325
2325
|
* The local key of the parent model.
|
2326
2326
|
*/
|
2327
|
-
__publicField$
|
2327
|
+
__publicField$7(this, "localKey");
|
2328
2328
|
this.foreignKey = foreignKey;
|
2329
2329
|
this.localKey = localKey;
|
2330
2330
|
}
|
@@ -2393,10 +2393,10 @@ class HasMany extends Relation {
|
|
2393
2393
|
}
|
2394
2394
|
}
|
2395
2395
|
|
2396
|
-
var __defProp$
|
2397
|
-
var __defNormalProp$
|
2398
|
-
var __publicField$
|
2399
|
-
__defNormalProp$
|
2396
|
+
var __defProp$6 = Object.defineProperty;
|
2397
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2398
|
+
var __publicField$6 = (obj, key, value) => {
|
2399
|
+
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2400
2400
|
return value;
|
2401
2401
|
};
|
2402
2402
|
class HasManyBy extends Relation {
|
@@ -2408,15 +2408,15 @@ class HasManyBy extends Relation {
|
|
2408
2408
|
/**
|
2409
2409
|
* The child model instance of the relation.
|
2410
2410
|
*/
|
2411
|
-
__publicField$
|
2411
|
+
__publicField$6(this, "child");
|
2412
2412
|
/**
|
2413
2413
|
* The foreign key of the parent model.
|
2414
2414
|
*/
|
2415
|
-
__publicField$
|
2415
|
+
__publicField$6(this, "foreignKey");
|
2416
2416
|
/**
|
2417
2417
|
* The owner key of the parent model.
|
2418
2418
|
*/
|
2419
|
-
__publicField$
|
2419
|
+
__publicField$6(this, "ownerKey");
|
2420
2420
|
this.foreignKey = foreignKey;
|
2421
2421
|
this.ownerKey = ownerKey;
|
2422
2422
|
this.child = child;
|
@@ -2508,10 +2508,10 @@ class HasManyBy extends Relation {
|
|
2508
2508
|
}
|
2509
2509
|
}
|
2510
2510
|
|
2511
|
-
var __defProp$
|
2512
|
-
var __defNormalProp$
|
2513
|
-
var __publicField$
|
2514
|
-
__defNormalProp$
|
2511
|
+
var __defProp$5 = Object.defineProperty;
|
2512
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2513
|
+
var __publicField$5 = (obj, key, value) => {
|
2514
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2515
2515
|
return value;
|
2516
2516
|
};
|
2517
2517
|
class MorphOne extends Relation {
|
@@ -2523,15 +2523,15 @@ class MorphOne extends Relation {
|
|
2523
2523
|
/**
|
2524
2524
|
* The field name that contains id of the parent model.
|
2525
2525
|
*/
|
2526
|
-
__publicField$
|
2526
|
+
__publicField$5(this, "morphId");
|
2527
2527
|
/**
|
2528
2528
|
* The field name that contains type of the parent model.
|
2529
2529
|
*/
|
2530
|
-
__publicField$
|
2530
|
+
__publicField$5(this, "morphType");
|
2531
2531
|
/**
|
2532
2532
|
* The local key of the model.
|
2533
2533
|
*/
|
2534
|
-
__publicField$
|
2534
|
+
__publicField$5(this, "localKey");
|
2535
2535
|
this.morphId = morphId;
|
2536
2536
|
this.morphType = morphType;
|
2537
2537
|
this.localKey = localKey;
|
@@ -2588,10 +2588,10 @@ class MorphOne extends Relation {
|
|
2588
2588
|
}
|
2589
2589
|
}
|
2590
2590
|
|
2591
|
-
var __defProp$
|
2592
|
-
var __defNormalProp$
|
2593
|
-
var __publicField$
|
2594
|
-
__defNormalProp$
|
2591
|
+
var __defProp$4 = Object.defineProperty;
|
2592
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2593
|
+
var __publicField$4 = (obj, key, value) => {
|
2594
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2595
2595
|
return value;
|
2596
2596
|
};
|
2597
2597
|
class MorphMany extends Relation {
|
@@ -2603,15 +2603,15 @@ class MorphMany extends Relation {
|
|
2603
2603
|
/**
|
2604
2604
|
* The field name that contains id of the parent model.
|
2605
2605
|
*/
|
2606
|
-
__publicField$
|
2606
|
+
__publicField$4(this, "morphId");
|
2607
2607
|
/**
|
2608
2608
|
* The field name that contains type of the parent model.
|
2609
2609
|
*/
|
2610
|
-
__publicField$
|
2610
|
+
__publicField$4(this, "morphType");
|
2611
2611
|
/**
|
2612
2612
|
* The local key of the model.
|
2613
2613
|
*/
|
2614
|
-
__publicField$
|
2614
|
+
__publicField$4(this, "localKey");
|
2615
2615
|
this.morphId = morphId;
|
2616
2616
|
this.morphType = morphType;
|
2617
2617
|
this.localKey = localKey;
|
@@ -2668,10 +2668,10 @@ class MorphMany extends Relation {
|
|
2668
2668
|
}
|
2669
2669
|
}
|
2670
2670
|
|
2671
|
-
var __defProp$
|
2672
|
-
var __defNormalProp$
|
2673
|
-
var __publicField$
|
2674
|
-
__defNormalProp$
|
2671
|
+
var __defProp$3 = Object.defineProperty;
|
2672
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2673
|
+
var __publicField$3 = (obj, key, value) => {
|
2674
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2675
2675
|
return value;
|
2676
2676
|
};
|
2677
2677
|
class HasManyThrough extends Relation {
|
@@ -2683,23 +2683,23 @@ class HasManyThrough extends Relation {
|
|
2683
2683
|
/**
|
2684
2684
|
* The "through" parent model.
|
2685
2685
|
*/
|
2686
|
-
__publicField$
|
2686
|
+
__publicField$3(this, "through");
|
2687
2687
|
/**
|
2688
2688
|
* The near key on the relationship.
|
2689
2689
|
*/
|
2690
|
-
__publicField$
|
2690
|
+
__publicField$3(this, "firstKey");
|
2691
2691
|
/**
|
2692
2692
|
* The far key on the relationship.
|
2693
2693
|
*/
|
2694
|
-
__publicField$
|
2694
|
+
__publicField$3(this, "secondKey");
|
2695
2695
|
/**
|
2696
2696
|
* The local key on the relationship.
|
2697
2697
|
*/
|
2698
|
-
__publicField$
|
2698
|
+
__publicField$3(this, "localKey");
|
2699
2699
|
/**
|
2700
2700
|
* The local key on the intermediary model.
|
2701
2701
|
*/
|
2702
|
-
__publicField$
|
2702
|
+
__publicField$3(this, "secondLocalKey");
|
2703
2703
|
this.through = through;
|
2704
2704
|
this.firstKey = firstKey;
|
2705
2705
|
this.secondKey = secondKey;
|
@@ -2757,13 +2757,114 @@ class HasManyThrough extends Relation {
|
|
2757
2757
|
}
|
2758
2758
|
}
|
2759
2759
|
|
2760
|
+
var __defProp$2 = Object.defineProperty;
|
2761
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2762
|
+
var __publicField$2 = (obj, key, value) => {
|
2763
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2764
|
+
return value;
|
2765
|
+
};
|
2766
|
+
class MorphToMany extends Relation {
|
2767
|
+
/**
|
2768
|
+
* Create a new morph to many to instance.
|
2769
|
+
*/
|
2770
|
+
constructor(parent, related, pivot, relatedId, morphId, morphType, parentKey, relatedKey) {
|
2771
|
+
super(parent, related);
|
2772
|
+
/**
|
2773
|
+
* The pivot model.
|
2774
|
+
*/
|
2775
|
+
__publicField$2(this, "pivot");
|
2776
|
+
/**
|
2777
|
+
* The field name that contains id of the parent model.
|
2778
|
+
*/
|
2779
|
+
__publicField$2(this, "morphId");
|
2780
|
+
/**
|
2781
|
+
* The field name that contains type of the parent model.
|
2782
|
+
*/
|
2783
|
+
__publicField$2(this, "morphType");
|
2784
|
+
/**
|
2785
|
+
* The associated key of the relation.
|
2786
|
+
*/
|
2787
|
+
__publicField$2(this, "relatedId");
|
2788
|
+
/**
|
2789
|
+
* The key name of the parent model.
|
2790
|
+
*/
|
2791
|
+
__publicField$2(this, "parentKey");
|
2792
|
+
/**
|
2793
|
+
* The key name of the related model.
|
2794
|
+
*/
|
2795
|
+
__publicField$2(this, "relatedKey");
|
2796
|
+
/**
|
2797
|
+
* The key name of the pivot data.
|
2798
|
+
*/
|
2799
|
+
__publicField$2(this, "pivotKey", "pivot");
|
2800
|
+
this.pivot = pivot;
|
2801
|
+
this.morphId = morphId;
|
2802
|
+
this.morphType = morphType;
|
2803
|
+
this.relatedId = relatedId;
|
2804
|
+
this.parentKey = parentKey;
|
2805
|
+
this.relatedKey = relatedKey;
|
2806
|
+
}
|
2807
|
+
/**
|
2808
|
+
* Get all related models for the relationship.
|
2809
|
+
*/
|
2810
|
+
getRelateds() {
|
2811
|
+
return [this.related, this.pivot];
|
2812
|
+
}
|
2813
|
+
/**
|
2814
|
+
* Define the normalizr schema for the relationship.
|
2815
|
+
*/
|
2816
|
+
define(schema) {
|
2817
|
+
return schema.many(this.related, this.parent);
|
2818
|
+
}
|
2819
|
+
/**
|
2820
|
+
* Attach the parent type and id to the given relation.
|
2821
|
+
*/
|
2822
|
+
attach(record, child) {
|
2823
|
+
const pivot = child.pivot ?? {};
|
2824
|
+
pivot[this.morphId] = record[this.parentKey];
|
2825
|
+
pivot[this.morphType] = this.parent.$entity();
|
2826
|
+
pivot[this.relatedId] = child[this.relatedKey];
|
2827
|
+
child[`pivot_${this.relatedId}_${this.pivot.$entity()}`] = pivot;
|
2828
|
+
}
|
2829
|
+
/**
|
2830
|
+
* Convert given value to the appropriate value for the attribute.
|
2831
|
+
*/
|
2832
|
+
make(elements) {
|
2833
|
+
return elements ? elements.map((element) => this.related.$newInstance(element)) : [];
|
2834
|
+
}
|
2835
|
+
/**
|
2836
|
+
* Match the eagerly loaded results to their parents.
|
2837
|
+
*/
|
2838
|
+
match(relation, models, query) {
|
2839
|
+
const relatedModels = query.get(false);
|
2840
|
+
const pivotModels = query.newQuery(this.pivot.$modelEntity()).whereIn(this.relatedId, this.getKeys(relatedModels, this.relatedKey)).whereIn(this.morphId, this.getKeys(models, this.parentKey)).groupBy(this.morphId, this.relatedId, this.morphType).get();
|
2841
|
+
models.forEach((parentModel) => {
|
2842
|
+
const relationResults = [];
|
2843
|
+
relatedModels.forEach((relatedModel) => {
|
2844
|
+
const pivot = pivotModels[`[${parentModel[this.parentKey]},${relatedModel[this.relatedKey]},${this.parent.$entity()}]`]?.[0] ?? null;
|
2845
|
+
const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
|
2846
|
+
relatedModelCopy.$setRelation("pivot", pivot);
|
2847
|
+
if (pivot) {
|
2848
|
+
relationResults.push(relatedModelCopy);
|
2849
|
+
}
|
2850
|
+
});
|
2851
|
+
parentModel.$setRelation(relation, relationResults);
|
2852
|
+
});
|
2853
|
+
}
|
2854
|
+
/**
|
2855
|
+
* Set the constraints for the related relation.
|
2856
|
+
*/
|
2857
|
+
addEagerConstraints(_query, _collection) {
|
2858
|
+
}
|
2859
|
+
}
|
2860
|
+
|
2760
2861
|
var __defProp$1 = Object.defineProperty;
|
2761
2862
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2762
2863
|
var __publicField$1 = (obj, key, value) => {
|
2763
2864
|
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2764
2865
|
return value;
|
2765
2866
|
};
|
2766
|
-
class
|
2867
|
+
class MorphedByMany extends Relation {
|
2767
2868
|
/**
|
2768
2869
|
* Create a new morph to many to instance.
|
2769
2870
|
*/
|
@@ -2820,10 +2921,10 @@ class MorphToMany extends Relation {
|
|
2820
2921
|
* Attach the parent type and id to the given relation.
|
2821
2922
|
*/
|
2822
2923
|
attach(record, child) {
|
2823
|
-
const pivot =
|
2824
|
-
pivot[this.morphId] =
|
2825
|
-
pivot[this.morphType] = this.
|
2826
|
-
pivot[this.relatedId] =
|
2924
|
+
const pivot = record.pivot ?? {};
|
2925
|
+
pivot[this.morphId] = child[this.relatedKey];
|
2926
|
+
pivot[this.morphType] = this.related.$entity();
|
2927
|
+
pivot[this.relatedId] = record[this.parentKey];
|
2827
2928
|
child[`pivot_${this.relatedId}_${this.pivot.$entity()}`] = pivot;
|
2828
2929
|
}
|
2829
2930
|
/**
|
@@ -2837,16 +2938,18 @@ class MorphToMany extends Relation {
|
|
2837
2938
|
*/
|
2838
2939
|
match(relation, models, query) {
|
2839
2940
|
const relatedModels = query.get(false);
|
2840
|
-
const pivotModels = query.newQuery(this.pivot.$modelEntity()).whereIn(this.relatedId, this.getKeys(
|
2941
|
+
const pivotModels = query.newQuery(this.pivot.$modelEntity()).whereIn(this.relatedId, this.getKeys(models, this.parentKey)).whereIn(this.morphId, this.getKeys(relatedModels, this.relatedKey)).groupBy(this.relatedId, this.morphType).get();
|
2841
2942
|
models.forEach((parentModel) => {
|
2842
2943
|
const relationResults = [];
|
2843
|
-
|
2844
|
-
|
2944
|
+
const resultModelIds = this.getKeys(pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? [], this.morphId);
|
2945
|
+
const relatedModelsFiltered = relatedModels.filter((filterdModel) => resultModelIds.includes(filterdModel[this.relatedKey]));
|
2946
|
+
relatedModelsFiltered.forEach((relatedModel) => {
|
2947
|
+
const pivot = (pivotModels[`[${parentModel[this.parentKey]},${this.related.$entity()}]`] ?? []).find((pivotModel) => pivotModel[this.morphId] === relatedModel[this.relatedKey]) ?? null;
|
2845
2948
|
const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson(), { operation: void 0 });
|
2846
|
-
relatedModelCopy.$setRelation("pivot", pivot);
|
2847
2949
|
if (pivot) {
|
2848
|
-
|
2950
|
+
relatedModelCopy.$setRelation("pivot", pivot);
|
2849
2951
|
}
|
2952
|
+
relationResults.push(relatedModelCopy);
|
2850
2953
|
});
|
2851
2954
|
parentModel.$setRelation(relation, relationResults);
|
2852
2955
|
});
|
@@ -3064,6 +3167,27 @@ class Model {
|
|
3064
3167
|
relatedKey
|
3065
3168
|
);
|
3066
3169
|
}
|
3170
|
+
/**
|
3171
|
+
* Create a new MorphedByMany relation instance.
|
3172
|
+
*/
|
3173
|
+
static morphedByMany(related, pivot, relatedId, id, type, parentKey, relatedKey) {
|
3174
|
+
const instance = related.newRawInstance();
|
3175
|
+
const model = this.newRawInstance();
|
3176
|
+
const pivotInstance = pivot.newRawInstance();
|
3177
|
+
parentKey = parentKey ?? model.$getLocalKey();
|
3178
|
+
relatedKey = relatedKey ?? instance.$getLocalKey();
|
3179
|
+
this.schemas[related.modelEntity()][`pivot_${relatedId}_${pivotInstance.$entity()}`] = new MorphOne(model, pivotInstance, id, type, relatedKey);
|
3180
|
+
return new MorphedByMany(
|
3181
|
+
model,
|
3182
|
+
instance,
|
3183
|
+
pivotInstance,
|
3184
|
+
relatedId,
|
3185
|
+
id,
|
3186
|
+
type,
|
3187
|
+
parentKey,
|
3188
|
+
relatedKey
|
3189
|
+
);
|
3190
|
+
}
|
3067
3191
|
/**
|
3068
3192
|
* Create a new HasMany relation instance.
|
3069
3193
|
*/
|