@sap-ux/annotation-converter
Advanced tools
Comparing version 0.10.1 to 0.10.2
# @sap-ux/annotation-converter | ||
## 0.10.2 | ||
### Patch Changes | ||
- ca0aa14: "Flag" enum are now properly converted back to single value instead of a collection | ||
## 0.10.1 | ||
@@ -4,0 +10,0 @@ |
@@ -16,6 +16,23 @@ "use strict"; | ||
if (Array.isArray(value)) { | ||
result = { | ||
type: 'Collection', | ||
Collection: value.map((anno) => revertCollectionItemToRawType(references, anno)) | ||
}; | ||
// Special case of flag enum type | ||
const firstValue = value[0]; | ||
let isEnumFlags = false; | ||
if (firstValue && typeof firstValue === 'string') { | ||
const valueMatches = firstValue.valueOf().split('.'); | ||
if (valueMatches.length > 1 && references.find((ref) => ref.alias === valueMatches[0])) { | ||
isEnumFlags = utils_1.EnumIsFlag[(0, utils_1.substringBeforeFirst)(firstValue, '/')]; | ||
} | ||
} | ||
if (isEnumFlags) { | ||
result = { | ||
type: 'EnumMember', | ||
EnumMember: value.map((val) => val.valueOf()).join(' ') | ||
}; | ||
} | ||
else { | ||
result = { | ||
type: 'Collection', | ||
Collection: value.map((anno) => revertCollectionItemToRawType(references, anno)) | ||
}; | ||
} | ||
} | ||
@@ -22,0 +39,0 @@ else if ((_a = value.isDecimal) === null || _a === void 0 ? void 0 : _a.call(value)) { |
{ | ||
"name": "@sap-ux/annotation-converter", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "SAP Fiori OData - Annotation converter", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -13,3 +13,3 @@ import type { | ||
} from '@sap-ux/vocabularies-types'; | ||
import { unalias } from './utils'; | ||
import { EnumIsFlag, substringBeforeFirst, unalias } from './utils'; | ||
@@ -26,6 +26,22 @@ /** | ||
if (Array.isArray(value)) { | ||
result = { | ||
type: 'Collection', | ||
Collection: value.map((anno) => revertCollectionItemToRawType(references, anno)) as any[] | ||
}; | ||
// Special case of flag enum type | ||
const firstValue = value[0]; | ||
let isEnumFlags = false; | ||
if (firstValue && typeof firstValue === 'string') { | ||
const valueMatches = firstValue.valueOf().split('.'); | ||
if (valueMatches.length > 1 && references.find((ref) => ref.alias === valueMatches[0])) { | ||
isEnumFlags = EnumIsFlag[substringBeforeFirst(firstValue, '/')]; | ||
} | ||
} | ||
if (isEnumFlags) { | ||
result = { | ||
type: 'EnumMember', | ||
EnumMember: value.map((val) => val.valueOf()).join(' ') | ||
}; | ||
} else { | ||
result = { | ||
type: 'Collection', | ||
Collection: value.map((anno) => revertCollectionItemToRawType(references, anno)) as any[] | ||
}; | ||
} | ||
} else if (value.isDecimal?.()) { | ||
@@ -32,0 +48,0 @@ result = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
237586
3808