@warp-drive/core 5.8.0-alpha.19 → 5.8.0-alpha.21
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.
|
@@ -75,10 +75,15 @@ export declare function temporaryConvertToLegacy(field: ResourceField | Collecti
|
|
|
75
75
|
export interface UpgradedMeta {
|
|
76
76
|
kind: "implicit" | RelationshipFieldKind;
|
|
77
77
|
/**
|
|
78
|
-
* The field
|
|
78
|
+
* The field sourceKey on `this` record,
|
|
79
|
+
* name if sourceKey is not set.
|
|
79
80
|
*/
|
|
80
81
|
key: string;
|
|
81
82
|
/**
|
|
83
|
+
* The field name on `this` record
|
|
84
|
+
*/
|
|
85
|
+
name: string;
|
|
86
|
+
/**
|
|
82
87
|
* The `type` of the related record
|
|
83
88
|
*
|
|
84
89
|
*/
|
|
@@ -91,10 +96,15 @@ export interface UpgradedMeta {
|
|
|
91
96
|
isLinksMode: boolean;
|
|
92
97
|
inverseKind: "implicit" | RelationshipFieldKind;
|
|
93
98
|
/**
|
|
94
|
-
* The field
|
|
99
|
+
* The field sourceKey on the opposing record,
|
|
100
|
+
* name if sourceKey is not set.
|
|
95
101
|
*/
|
|
96
102
|
inverseKey: string;
|
|
97
103
|
/**
|
|
104
|
+
* The field name on the opposing record,
|
|
105
|
+
*/
|
|
106
|
+
inverseName: string;
|
|
107
|
+
/**
|
|
98
108
|
* The `type` of `this` record
|
|
99
109
|
*/
|
|
100
110
|
inverseType: string;
|
|
@@ -1285,6 +1285,9 @@ export interface LegacyBelongsToField {
|
|
|
1285
1285
|
*
|
|
1286
1286
|
* If null, the relationship is unidirectional.
|
|
1287
1287
|
*
|
|
1288
|
+
* If the inverse field definition uses a sourceKey,
|
|
1289
|
+
* this should still be the name of the field, not the sourceKey.
|
|
1290
|
+
*
|
|
1288
1291
|
* @public
|
|
1289
1292
|
*/
|
|
1290
1293
|
inverse: string | null;
|
|
@@ -1433,6 +1436,9 @@ export interface LinksModeBelongsToField {
|
|
|
1433
1436
|
*
|
|
1434
1437
|
* If null, the relationship is unidirectional.
|
|
1435
1438
|
*
|
|
1439
|
+
* If the inverse field definition uses a sourceKey,
|
|
1440
|
+
* this should still be the name of the field, not the sourceKey.
|
|
1441
|
+
*
|
|
1436
1442
|
* @public
|
|
1437
1443
|
*/
|
|
1438
1444
|
inverse: string | null;
|
|
@@ -1604,6 +1610,9 @@ export interface LegacyHasManyField {
|
|
|
1604
1610
|
*
|
|
1605
1611
|
* If null, the relationship is unidirectional.
|
|
1606
1612
|
*
|
|
1613
|
+
* If the inverse field definition uses a sourceKey,
|
|
1614
|
+
* this should still be the name of the field, not the sourceKey.
|
|
1615
|
+
*
|
|
1607
1616
|
* @public
|
|
1608
1617
|
*/
|
|
1609
1618
|
inverse: string | null;
|
|
@@ -1777,6 +1786,9 @@ export interface LinksModeHasManyField {
|
|
|
1777
1786
|
*
|
|
1778
1787
|
* If null, the relationship is unidirectional.
|
|
1779
1788
|
*
|
|
1789
|
+
* If the inverse field definition uses a sourceKey,
|
|
1790
|
+
* this should still be the name of the field, not the sourceKey.
|
|
1791
|
+
*
|
|
1780
1792
|
* @public
|
|
1781
1793
|
*/
|
|
1782
1794
|
inverse: string | null;
|
package/dist/graph/-private.js
CHANGED
|
@@ -349,6 +349,7 @@ function implicitKeyFor(type, key) {
|
|
|
349
349
|
function syncMeta(definition, inverseDefinition) {
|
|
350
350
|
definition.inverseKind = inverseDefinition.kind;
|
|
351
351
|
definition.inverseKey = inverseDefinition.key;
|
|
352
|
+
definition.inverseName = inverseDefinition.name;
|
|
352
353
|
definition.inverseType = inverseDefinition.type;
|
|
353
354
|
definition.inverseIsAsync = inverseDefinition.isAsync;
|
|
354
355
|
definition.inverseIsCollection = inverseDefinition.isCollection;
|
|
@@ -366,7 +367,8 @@ function upgradeMeta(meta) {
|
|
|
366
367
|
const niceMeta = {};
|
|
367
368
|
const options = meta.options;
|
|
368
369
|
niceMeta.kind = meta.kind;
|
|
369
|
-
niceMeta.key = meta.name;
|
|
370
|
+
niceMeta.key = meta.sourceKey ?? meta.name;
|
|
371
|
+
niceMeta.name = meta.name;
|
|
370
372
|
niceMeta.type = meta.type;
|
|
371
373
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
372
374
|
if (!test) {
|
|
@@ -379,6 +381,7 @@ function upgradeMeta(meta) {
|
|
|
379
381
|
niceMeta.isPolymorphic = options && !!options.polymorphic;
|
|
380
382
|
niceMeta.isLinksMode = options.linksMode ?? false;
|
|
381
383
|
niceMeta.inverseKey = options && options.inverse || STR_LATER;
|
|
384
|
+
niceMeta.inverseName = options && options.inverse || STR_LATER;
|
|
382
385
|
niceMeta.inverseType = STR_LATER;
|
|
383
386
|
niceMeta.inverseIsAsync = BOOL_LATER;
|
|
384
387
|
niceMeta.inverseIsImplicit = options && options.inverse === null || BOOL_LATER;
|
|
@@ -502,12 +505,13 @@ function upgradeDefinition(graph, key, propertyName, isImplicit = false) {
|
|
|
502
505
|
}
|
|
503
506
|
})(!isImplicit) : {};
|
|
504
507
|
const relationships = storeWrapper.schema.fields(key);
|
|
508
|
+
const relationshipsBySourceKey = storeWrapper.schema.cacheFields?.(key) ?? relationships;
|
|
505
509
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
506
510
|
if (!test) {
|
|
507
511
|
throw new Error(`Expected to have a relationship definition for ${type} but none was found.`);
|
|
508
512
|
}
|
|
509
513
|
})(relationships) : {};
|
|
510
|
-
const meta =
|
|
514
|
+
const meta = relationshipsBySourceKey.get(propertyName);
|
|
511
515
|
if (!meta) {
|
|
512
516
|
// TODO potentially we should just be permissive here since this is an implicit relationship
|
|
513
517
|
// and not require the lookup table to be populated
|
|
@@ -564,6 +568,7 @@ function upgradeDefinition(graph, key, propertyName, isImplicit = false) {
|
|
|
564
568
|
kind: 'belongsTo',
|
|
565
569
|
// this must be updated when we find the first belongsTo or hasMany definition that matches
|
|
566
570
|
key: definition.inverseKey,
|
|
571
|
+
name: definition.inverseName,
|
|
567
572
|
type: type,
|
|
568
573
|
isAsync: false,
|
|
569
574
|
// this must be updated when we find the first belongsTo or hasMany definition that matches
|
|
@@ -578,6 +583,7 @@ function upgradeDefinition(graph, key, propertyName, isImplicit = false) {
|
|
|
578
583
|
inverseDefinition = null;
|
|
579
584
|
} else {
|
|
580
585
|
// CASE: We have an explicit inverse or were able to resolve one
|
|
586
|
+
// for the inverse we use "name" for lookup not "sourceKey"
|
|
581
587
|
const inverseDefinitions = storeWrapper.schema.fields({
|
|
582
588
|
type: inverseType
|
|
583
589
|
});
|
|
@@ -710,7 +716,8 @@ function upgradeDefinition(graph, key, propertyName, isImplicit = false) {
|
|
|
710
716
|
return info;
|
|
711
717
|
}
|
|
712
718
|
function inverseForRelationship(store, resourceKey, key) {
|
|
713
|
-
const
|
|
719
|
+
const fields = store.schema.fields(resourceKey);
|
|
720
|
+
const definition = fields.get(key);
|
|
714
721
|
if (!definition) {
|
|
715
722
|
return null;
|
|
716
723
|
}
|
package/dist/types/-private.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
2
|
const name = "@warp-drive/core";
|
|
3
|
-
const version = "5.8.0-alpha.
|
|
3
|
+
const version = "5.8.0-alpha.21";
|
|
4
4
|
|
|
5
5
|
// in testing mode, we utilize globals to ensure only one copy exists of
|
|
6
6
|
// these maps, due to bugs in ember-auto-import
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/core",
|
|
3
|
-
"version": "5.8.0-alpha.
|
|
3
|
+
"version": "5.8.0-alpha.21",
|
|
4
4
|
"description": "Core package for WarpDrive | All the Universal Basics",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@embroider/macros": "^1.18.1",
|
|
40
|
-
"@warp-drive/build-config": "5.8.0-alpha.
|
|
40
|
+
"@warp-drive/build-config": "5.8.0-alpha.21"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/core": "^7.28.3",
|
|
44
44
|
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
45
45
|
"@babel/preset-typescript": "^7.27.1",
|
|
46
|
-
"@warp-drive/internal-config": "5.8.0-alpha.
|
|
46
|
+
"@warp-drive/internal-config": "5.8.0-alpha.21",
|
|
47
47
|
"decorator-transforms": "^2.3.0",
|
|
48
48
|
"ember-source": "~6.6.0",
|
|
49
49
|
"expect-type": "^1.2.2",
|