@sap-ux/annotation-converter
Advanced tools
Comparing version 0.6.5 to 0.6.6
# @sap-ux/annotation-converter | ||
## 0.6.6 | ||
### Patch Changes | ||
- 9be80ce: Consider the alias when converting annotations | ||
## 0.6.5 | ||
@@ -4,0 +10,0 @@ |
@@ -318,8 +318,7 @@ "use strict"; | ||
case 'EnumMember': | ||
const aliasedEnum = converter.alias(propertyValue.EnumMember); | ||
const splitEnum = aliasedEnum.split(' '); | ||
if (splitEnum[0] && utils_1.EnumIsFlag[(0, utils_1.substringBeforeFirst)(splitEnum[0], '/')]) { | ||
const splitEnum = propertyValue.EnumMember.split(' ').map((enumValue) => converter.toDefaultAlias(enumValue)); | ||
if (splitEnum[0] !== undefined && utils_1.EnumIsFlag[(0, utils_1.substringBeforeFirst)(splitEnum[0], '/')]) { | ||
return splitEnum; | ||
} | ||
return aliasedEnum; | ||
return splitEnum[0]; | ||
case 'PropertyPath': | ||
@@ -606,12 +605,2 @@ return { | ||
} | ||
/** | ||
* Split the alias from the term value. | ||
* | ||
* @param references the current set of references | ||
* @param termValue the value of the term | ||
* @returns the term alias and the actual term value | ||
*/ | ||
function splitTerm(references, termValue) { | ||
return (0, utils_1.splitAtLast)((0, utils_1.alias)(references, termValue), '.'); | ||
} | ||
function convertAnnotation(converter, target, rawAnnotation) { | ||
@@ -807,7 +796,16 @@ var _a; | ||
} | ||
/** | ||
* Split the alias from the term value. | ||
* | ||
* @param term the value of the term | ||
* @returns the term alias and the actual term value | ||
*/ | ||
splitTerm(term) { | ||
return splitTerm(this.rawMetadata.references, term); | ||
const aliased = (0, utils_1.alias)(VocabularyReferences_1.VocabularyReferences, term); | ||
return (0, utils_1.splitAtLast)(aliased, '.'); | ||
} | ||
alias(value) { | ||
return (0, utils_1.alias)(this.rawMetadata.references, value); | ||
toDefaultAlias(value) { | ||
var _a; | ||
const unaliased = (_a = (0, utils_1.unalias)(this.rawMetadata.references, value)) !== null && _a !== void 0 ? _a : ''; | ||
return (0, utils_1.alias)(VocabularyReferences_1.VocabularyReferences, unaliased); | ||
} | ||
@@ -814,0 +812,0 @@ unalias(value) { |
{ | ||
"name": "@sap-ux/annotation-converter", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"description": "SAP Fiori OData - Annotation converter", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -40,3 +40,2 @@ import type { | ||
} from '@sap-ux/vocabularies-types'; | ||
import type { ReferencesWithMap } from './utils'; | ||
import { | ||
@@ -442,8 +441,9 @@ addGetByValue, | ||
case 'EnumMember': | ||
const aliasedEnum = converter.alias(propertyValue.EnumMember); | ||
const splitEnum = aliasedEnum.split(' '); | ||
if (splitEnum[0] && EnumIsFlag[substringBeforeFirst(splitEnum[0], '/')]) { | ||
const splitEnum = propertyValue.EnumMember.split(' ').map((enumValue) => | ||
converter.toDefaultAlias(enumValue) | ||
); | ||
if (splitEnum[0] !== undefined && EnumIsFlag[substringBeforeFirst(splitEnum[0], '/')]) { | ||
return splitEnum; | ||
} | ||
return aliasedEnum; | ||
return splitEnum[0]; | ||
@@ -856,13 +856,2 @@ case 'PropertyPath': | ||
/** | ||
* Split the alias from the term value. | ||
* | ||
* @param references the current set of references | ||
* @param termValue the value of the term | ||
* @returns the term alias and the actual term value | ||
*/ | ||
function splitTerm(references: ReferencesWithMap, termValue: string) { | ||
return splitAtLast(alias(references, termValue), '.'); | ||
} | ||
function convertAnnotation(converter: Converter, target: any, rawAnnotation: RawAnnotation): Annotation { | ||
@@ -1139,8 +1128,16 @@ let annotation: any; | ||
/** | ||
* Split the alias from the term value. | ||
* | ||
* @param term the value of the term | ||
* @returns the term alias and the actual term value | ||
*/ | ||
splitTerm(term: string) { | ||
return splitTerm(this.rawMetadata.references, term); | ||
const aliased = alias(VocabularyReferences, term); | ||
return splitAtLast(aliased, '.'); | ||
} | ||
alias(value: string) { | ||
return alias(this.rawMetadata.references, value); | ||
toDefaultAlias(value: string) { | ||
const unaliased = unalias(this.rawMetadata.references, value) ?? ''; | ||
return alias(VocabularyReferences, unaliased); | ||
} | ||
@@ -1147,0 +1144,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
305503
4510