@sap-ux/annotation-converter
Advanced tools
Comparing version 0.6.3 to 0.6.4
# @sap-ux/annotation-converter | ||
## 0.6.4 | ||
### Patch Changes | ||
- 7230a33: feat: allow to resolve entity type by their fqdn | ||
## 0.6.3 | ||
@@ -4,0 +10,0 @@ |
@@ -32,3 +32,3 @@ "use strict"; | ||
function resolveTarget(converter, startElement, path, annotationsTerm) { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
// absolute paths always start at the entity container | ||
@@ -54,3 +54,12 @@ if (path.startsWith('/')) { | ||
// no starting point given: start at the entity container | ||
startElement = converter.getConvertedEntityContainer(); | ||
if (pathSegments[0].startsWith(converter.rawSchema.namespace) && | ||
pathSegments[0] !== ((_a = converter.getConvertedEntityContainer()) === null || _a === void 0 ? void 0 : _a.fullyQualifiedName)) { | ||
// We have a fully qualified name in the path that is not the entity container. | ||
startElement = | ||
(_c = (_b = converter.getConvertedEntityType(pathSegments[0])) !== null && _b !== void 0 ? _b : converter.getConvertedComplexType(pathSegments[0])) !== null && _c !== void 0 ? _c : converter.getConvertedAction(pathSegments[0]); | ||
pathSegments.shift(); // Let's remove the first path element | ||
} | ||
else { | ||
startElement = converter.getConvertedEntityContainer(); | ||
} | ||
} | ||
@@ -65,3 +74,3 @@ else if (startElement[ANNOTATION_TARGET] !== undefined) { | ||
startElement = | ||
(_a = converter.getConvertedEntityType(parentElementFQN)) !== null && _a !== void 0 ? _a : converter.getConvertedComplexType(parentElementFQN); | ||
(_d = converter.getConvertedEntityType(parentElementFQN)) !== null && _d !== void 0 ? _d : converter.getConvertedComplexType(parentElementFQN); | ||
} | ||
@@ -112,2 +121,5 @@ const result = pathSegments.reduce((current, segment) => { | ||
switch ((_b = current.target) === null || _b === void 0 ? void 0 : _b._type) { | ||
case 'Schema': | ||
// next element: EntityType, ComplexType, Action, EntityContainer ? | ||
break; | ||
case 'EntityContainer': | ||
@@ -545,9 +557,15 @@ { | ||
return collectionDefinition.map((navPropertyPath, navPropIdx) => { | ||
var _a; | ||
const navigationPropertyPath = (_a = navPropertyPath.NavigationPropertyPath) !== null && _a !== void 0 ? _a : ''; | ||
const result = { | ||
type: 'NavigationPropertyPath', | ||
value: navPropertyPath.NavigationPropertyPath, | ||
value: navigationPropertyPath, | ||
fullyQualifiedName: `${parentFQN}/${navPropIdx}` | ||
}; | ||
(0, utils_1.lazy)(result, '$target', () => resolveTarget(converter, currentTarget, navPropertyPath.NavigationPropertyPath, currentTerm) | ||
.target); | ||
if (navigationPropertyPath === '') { | ||
result.$target = undefined; | ||
} | ||
else { | ||
(0, utils_1.lazy)(result, '$target', () => resolveTarget(converter, currentTarget, navigationPropertyPath, currentTerm).target); | ||
} | ||
return result; | ||
@@ -554,0 +572,0 @@ }); |
{ | ||
"name": "@sap-ux/annotation-converter", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "SAP Fiori OData - Annotation converter", | ||
@@ -17,3 +17,3 @@ "repository": { | ||
"devDependencies": { | ||
"@sap-ux/vocabularies-types": "0.7.0", | ||
"@sap-ux/vocabularies-types": "0.7.2", | ||
"@sap-ux/edmx-parser": "0.5.13" | ||
@@ -20,0 +20,0 @@ }, |
@@ -111,3 +111,15 @@ import type { | ||
// no starting point given: start at the entity container | ||
startElement = converter.getConvertedEntityContainer(); | ||
if ( | ||
pathSegments[0].startsWith(converter.rawSchema.namespace) && | ||
pathSegments[0] !== converter.getConvertedEntityContainer()?.fullyQualifiedName | ||
) { | ||
// We have a fully qualified name in the path that is not the entity container. | ||
startElement = | ||
converter.getConvertedEntityType(pathSegments[0]) ?? | ||
converter.getConvertedComplexType(pathSegments[0]) ?? | ||
converter.getConvertedAction(pathSegments[0]); | ||
pathSegments.shift(); // Let's remove the first path element | ||
} else { | ||
startElement = converter.getConvertedEntityContainer(); | ||
} | ||
} else if (startElement[ANNOTATION_TARGET] !== undefined) { | ||
@@ -178,2 +190,6 @@ // annotation: start at the annotation target | ||
switch (current.target?._type) { | ||
case 'Schema': | ||
// next element: EntityType, ComplexType, Action, EntityContainer ? | ||
break; | ||
case 'EntityContainer': | ||
@@ -770,15 +786,18 @@ { | ||
return collectionDefinition.map((navPropertyPath, navPropIdx) => { | ||
const navigationPropertyPath = navPropertyPath.NavigationPropertyPath ?? ''; | ||
const result = { | ||
type: 'NavigationPropertyPath', | ||
value: navPropertyPath.NavigationPropertyPath, | ||
value: navigationPropertyPath, | ||
fullyQualifiedName: `${parentFQN}/${navPropIdx}` | ||
} as any; | ||
lazy( | ||
result, | ||
'$target', | ||
() => | ||
resolveTarget(converter, currentTarget, navPropertyPath.NavigationPropertyPath, currentTerm) | ||
.target | ||
); | ||
if (navigationPropertyPath === '') { | ||
result.$target = undefined; | ||
} else { | ||
lazy( | ||
result, | ||
'$target', | ||
() => resolveTarget(converter, currentTarget, navigationPropertyPath, currentTerm).target | ||
); | ||
} | ||
@@ -785,0 +804,0 @@ return result; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
307657
4539