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