@sap-ux/edmx-parser
Advanced tools
Comparing version 0.5.9 to 0.5.10
# @sap-ux/edmx-parser | ||
## 0.5.10 | ||
### Patch Changes | ||
- dde9115: Improve singleton support | ||
## 0.5.9 | ||
@@ -4,0 +10,0 @@ |
@@ -333,2 +333,38 @@ "use strict"; | ||
} | ||
function resolveNavigationPropertyBindings(entitySets, singletons, outEntitySets, outSingletons) { | ||
entitySets.forEach((entitySet) => { | ||
const currentOutEntitySet = outEntitySets.find((outEntitySet) => outEntitySet.name === entitySet._attributes.Name); | ||
if (currentOutEntitySet) { | ||
(0, utils_1.ensureArray)(entitySet.NavigationPropertyBinding).forEach((navPropertyBinding) => { | ||
const currentTargetEntitySet = outEntitySets.find((entitySet) => entitySet.name === navPropertyBinding._attributes.Target); | ||
if (currentTargetEntitySet) { | ||
currentOutEntitySet.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetEntitySet; | ||
} | ||
const currentTargetSingleton = outSingletons.find((singleton) => singleton.name === navPropertyBinding._attributes.Target); | ||
if (currentTargetSingleton) { | ||
currentOutEntitySet.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetSingleton; | ||
} | ||
}); | ||
} | ||
}); | ||
singletons.forEach((singleton) => { | ||
const currentOutSingleton = outSingletons.find((outSingleton) => outSingleton.name === singleton._attributes.Name); | ||
if (currentOutSingleton) { | ||
(0, utils_1.ensureArray)(singleton.NavigationPropertyBinding).forEach((navPropertyBinding) => { | ||
const currentTargetEntitySet = outEntitySets.find((entitySet) => entitySet.name === navPropertyBinding._attributes.Target); | ||
if (currentTargetEntitySet) { | ||
currentOutSingleton.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetEntitySet; | ||
} | ||
const currentTargetSingleton = outSingletons.find((singleton) => singleton.name === navPropertyBinding._attributes.Target); | ||
if (currentTargetSingleton) { | ||
currentOutSingleton.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetSingleton; | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
function parseActions(actions, namespace, isFunction = false) { | ||
@@ -729,2 +765,3 @@ return actions.map((action) => { | ||
singletons = parseSingletons((0, utils_1.ensureArray)(edmSchema.EntityContainer.Singleton), namespace, edmSchema.EntityContainer._attributes.Name, annotations); | ||
resolveNavigationPropertyBindings((0, utils_1.ensureArray)(edmSchema.EntityContainer.EntitySet), (0, utils_1.ensureArray)(edmSchema.EntityContainer.Singleton), entitySets, singletons); | ||
associationSets = parseAssociationSets((0, utils_1.ensureArray)(edmSchema.EntityContainer.AssociationSet), namespace); | ||
@@ -731,0 +768,0 @@ entityContainer = { |
{ | ||
"name": "@sap-ux/edmx-parser", | ||
"version": "0.5.9", | ||
"version": "0.5.10", | ||
"description": "SAP Fiori OData - EDMX File parser", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
"devDependencies": { | ||
"@sap-ux/vocabularies-types": "0.6.3" | ||
"@sap-ux/vocabularies-types": "0.6.4" | ||
}, | ||
@@ -23,0 +23,0 @@ "scripts": { |
@@ -496,2 +496,56 @@ // eslint-disable-next-line @typescript-eslint/triple-slash-reference | ||
function resolveNavigationPropertyBindings( | ||
entitySets: EDMX.EntitySet[], | ||
singletons: EDMX.Singleton[], | ||
outEntitySets: RawEntitySet[], | ||
outSingletons: RawSingleton[] | ||
): void { | ||
entitySets.forEach((entitySet) => { | ||
const currentOutEntitySet = outEntitySets.find( | ||
(outEntitySet) => outEntitySet.name === entitySet._attributes.Name | ||
); | ||
if (currentOutEntitySet) { | ||
ensureArray(entitySet.NavigationPropertyBinding).forEach((navPropertyBinding) => { | ||
const currentTargetEntitySet = outEntitySets.find( | ||
(entitySet) => entitySet.name === navPropertyBinding._attributes.Target | ||
); | ||
if (currentTargetEntitySet) { | ||
currentOutEntitySet.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetEntitySet; | ||
} | ||
const currentTargetSingleton = outSingletons.find( | ||
(singleton) => singleton.name === navPropertyBinding._attributes.Target | ||
); | ||
if (currentTargetSingleton) { | ||
currentOutEntitySet.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetSingleton; | ||
} | ||
}); | ||
} | ||
}); | ||
singletons.forEach((singleton) => { | ||
const currentOutSingleton = outSingletons.find( | ||
(outSingleton) => outSingleton.name === singleton._attributes.Name | ||
); | ||
if (currentOutSingleton) { | ||
ensureArray(singleton.NavigationPropertyBinding).forEach((navPropertyBinding) => { | ||
const currentTargetEntitySet = outEntitySets.find( | ||
(entitySet) => entitySet.name === navPropertyBinding._attributes.Target | ||
); | ||
if (currentTargetEntitySet) { | ||
currentOutSingleton.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetEntitySet; | ||
} | ||
const currentTargetSingleton = outSingletons.find( | ||
(singleton) => singleton.name === navPropertyBinding._attributes.Target | ||
); | ||
if (currentTargetSingleton) { | ||
currentOutSingleton.navigationPropertyBinding[navPropertyBinding._attributes.Path] = | ||
currentTargetSingleton; | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
function parseActions( | ||
@@ -996,2 +1050,8 @@ actions: (EDMX.Action | EDMX.Function)[], | ||
); | ||
resolveNavigationPropertyBindings( | ||
ensureArray(edmSchema.EntityContainer.EntitySet), | ||
ensureArray(edmSchema.EntityContainer.Singleton), | ||
entitySets, | ||
singletons | ||
); | ||
associationSets = parseAssociationSets(ensureArray(edmSchema.EntityContainer.AssociationSet), namespace); | ||
@@ -998,0 +1058,0 @@ entityContainer = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
242809
4427