@sap/cds-compiler
Advanced tools
Comparing version 2.15.2 to 2.15.4
@@ -161,8 +161,8 @@ // Central registry for messages. | ||
'odata-spec-violation-constraints': { severity: 'Info' }, // more than 30 chars | ||
'odata-spec-violation-id': { severity: 'Error' }, | ||
'odata-spec-violation-type': { severity: 'Error', configurableFor: [ 'to.edmx' ] }, | ||
'odata-spec-violation-id': { severity: 'Error', configurableFor: true }, | ||
'odata-spec-violation-type': { severity: 'Error', configurableFor: true }, | ||
'odata-spec-violation-type-unknown': { severity: 'Warning' }, | ||
'odata-spec-violation-no-key': { severity: 'Warning' }, | ||
'odata-spec-violation-key-array': { severity: 'Error' }, // more than 30 chars | ||
'odata-spec-violation-key-null': { severity: 'Error' }, // more than 30 chars | ||
'odata-spec-violation-key-array': { severity: 'Error', configurableFor: true }, // more than 30 chars | ||
'odata-spec-violation-key-null': { severity: 'Error', configurableFor: true }, // more than 30 chars | ||
'odata-spec-violation-key-type': { severity: 'Warning' }, // more than 30 chars | ||
@@ -169,0 +169,0 @@ 'odata-spec-violation-property-name': { severity: 'Warning' }, // more than 30 chars |
@@ -336,3 +336,3 @@ 'use strict'; | ||
Object.entries(elementsObj).forEach(([elemName, element]) => { | ||
if (Object.keys(element).filter( x => x.substr(0,1) === '@' ).filter(filterKnownVocabularies).length > 0) { | ||
if (Object.keys(element).filter( x => x[0] === '@' ).filter(filterKnownVocabularies).length > 0) { | ||
message(warning, null, `annotations at nested elements are not yet supported, object ${objname}, element ${baseElemName}.${elemName}`); | ||
@@ -441,7 +441,13 @@ } | ||
// Final filtering of all annotations is done in handleTerm | ||
const annoNames = Object.keys(carrier).filter( x => x.substr(0,1) === '@' ); | ||
let annoNames = Object.keys(carrier).filter( x => x[0] === '@' ); | ||
const nullWhitelist = [ '@Core.OperationAvailable' ]; | ||
const knownAnnos = annoNames.filter(filterKnownVocabularies).filter(x => carrier[x] !== null || nullWhitelist.includes(x)); | ||
let knownAnnos = annoNames.filter(filterKnownVocabularies).filter(x => carrier[x] !== null || nullWhitelist.includes(x)); | ||
if (knownAnnos.length === 0) return; | ||
if(rewriteInnerAnnotations()) { | ||
annoNames = Object.keys(carrier).filter( x => x[0] === '@' ); | ||
knownAnnos = annoNames.filter(filterKnownVocabularies).filter(x => carrier[x] !== null || nullWhitelist.includes(x)); | ||
if (knownAnnos.length === 0) return; | ||
} | ||
const prefixTree = createPrefixTree(); | ||
@@ -615,2 +621,47 @@ | ||
function rewriteInnerAnnotations() { | ||
let rc = false; | ||
for (let a of knownAnnos) { | ||
const [ prefix, innerAnnotation ] = a.split('.@'); | ||
/* | ||
New inner annotation (de-)structuring of the core compiler to make | ||
$value arrays extendable via ellipsis | ||
@anno: { $value: [ ... ], @innerAnno: ... } is now cracked up by | ||
the core compiler into: | ||
@anno: [ ...] | ||
@anno.@innerAnno: ... | ||
Conflict handling if $value is present: | ||
@anno | ||
@anno.$value | ||
@anno.@innerAnno | ||
@anno has precedence (as it was before this change) but now | ||
@anno.$value is overwritten with @anno and the inner annotations | ||
are applied. | ||
Trigger is always the inner annotation, if no inner annotation | ||
is available, @anno has precedence. | ||
Insert $value into $edmJson with inner annotation as well. | ||
*/ | ||
if(innerAnnotation) { | ||
if(carrier[prefix]) { | ||
const valPrefix = prefix + '.$value'; | ||
carrier[valPrefix] = carrier[prefix]; | ||
delete carrier[prefix]; | ||
rc = true; | ||
} | ||
const edmJsonPrefix = prefix + '.$edmJson'; | ||
if(carrier[edmJsonPrefix]) { | ||
const valPrefix = prefix + '.$value.$edmJson'; | ||
carrier[valPrefix] = carrier[edmJsonPrefix]; | ||
delete carrier[edmJsonPrefix]; | ||
rc = true; | ||
} | ||
} | ||
} | ||
return rc; | ||
} | ||
function createPrefixTree() { | ||
@@ -625,2 +676,3 @@ // in csn, all annotations are flattened | ||
const prefixTree = {}; | ||
for (let a of knownAnnos) { | ||
@@ -852,3 +904,3 @@ // remove leading @ and split at "." | ||
} | ||
else if ( Object.keys(cAnnoValue).filter( x => x.substr(0,1) !== '@' ).length === 0) { | ||
else if ( Object.keys(cAnnoValue).filter( x => x[0] !== '@' ).length === 0) { | ||
// object consists only of properties starting with "@" | ||
@@ -960,2 +1012,4 @@ message(warning, context, 'nested annotations without corresponding base annotation'); | ||
function handleSimpleValue(val, dTypeName, context) { | ||
// these types must be represented as "String" values in XML: | ||
const castToXmlString = [ 'Edm.PrimitiveType', 'Edm.Stream', 'Edm.Untyped' ]; | ||
// caller already made sure that val is neither object nor array | ||
@@ -998,3 +1052,3 @@ dTypeName = resolveType(dTypeName); | ||
} | ||
else if (dTypeName && dTypeName.startsWith('Edm.') && dTypeName !== 'Edm.PrimitiveType') { | ||
else if (dTypeName && dTypeName.startsWith('Edm.') && !castToXmlString.includes(dTypeName)) { | ||
// this covers also all paths | ||
@@ -1004,3 +1058,3 @@ typeName = dTypeName.substring(4); | ||
else { | ||
if(dTypeName == undefined || dTypeName === 'Edm.PrimitiveType') | ||
if(dTypeName == undefined || castToXmlString.some(t => t === dTypeName)) | ||
dTypeName = 'Edm.String'; | ||
@@ -1007,0 +1061,0 @@ // TODO |
@@ -17,3 +17,3 @@ 'use strict'; | ||
const { EdmTypeFacetMap, EdmTypeFacetNames, EdmPrimitiveTypeMap, getEdm } = require('./edm.js'); | ||
/* | ||
@@ -425,3 +425,3 @@ OData V2 spec 06/01/2017 PDF version is available from here: | ||
// FIXME: Rewrite signalIllegalIdentifier function to be more flexible | ||
error('odata-spec-violation-id', pLoc, | ||
message('odata-spec-violation-id', pLoc, | ||
{ prop: p._edmAttributes.Name[0], id: p._edmAttributes.Name, version: '2.0', '#': 'v2firstchar' }); | ||
@@ -626,5 +626,5 @@ } | ||
// only scalar or structured type in V2 (not entity) | ||
if(param._type && | ||
!param._type.startsWith('Edm.') && | ||
csn.definitions[param._type] && | ||
if(param._type && | ||
!param._type.startsWith('Edm.') && | ||
csn.definitions[param._type] && | ||
!edmUtils.isStructuredType(csn.definitions[param._type])) | ||
@@ -939,3 +939,3 @@ warning('odata-spec-violation-param', pLoc, { version: '2.0' }); | ||
function addAnnotations() { | ||
let { annos, usedVocabularies } = translate.csn2annotationEdm(csn, serviceCsn.name, Edm, options, messageFunctions); | ||
let { annos, usedVocabularies } = translate.csn2annotationEdm(reqDefs, serviceCsn.name, Edm, options, messageFunctions); | ||
// distribute edm:Annotations into the schemas | ||
@@ -997,3 +997,3 @@ // Distribute each anno into Schema | ||
else { | ||
message('odata-spec-violation-type-unknown', pLoc, | ||
message('odata-spec-violation-type-unknown', pLoc, | ||
{ type:edmType }); | ||
@@ -1000,0 +1000,0 @@ } |
@@ -57,3 +57,3 @@ 'use strict' | ||
'Edm.GeometryCollection': { v4: true, SRID: true, desc: 'Collection of arbitrary Geometry values' }, | ||
//'Edm.PrimitiveType': { v4: true, desc: 'Abstract meta type' }, | ||
'Edm.PrimitiveType': { v4: true, desc: 'Abstract meta type' }, | ||
//'Edm.Untyped': { v4: true, desc: 'Abstract void type' }, | ||
@@ -1227,5 +1227,11 @@ }; | ||
[ 'Edm.Binary', 'Edm.Boolean', 'Edm.Byte', 'Edm.Date', 'Edm.DateTimeOffset', 'Edm.Decimal', 'Edm.Double', 'Edm.Duration', 'Edm.Guid', | ||
'Edm.Int16', 'Edm.Int32', 'Edm.Int64', 'Edm.SByte','Edm.Single', /*'Edm.Stream',*/ 'Edm.String', 'Edm.TimeOfDay', | ||
'Edm.Int16', 'Edm.Int32', 'Edm.Int64', 'Edm.SByte','Edm.Single', 'Edm.Stream', 'Edm.String', 'Edm.TimeOfDay', | ||
// Edm.Geo* according to https://issues.oasis-open.org/browse/ODATA-1323 | ||
/* 'Edm.Geography', 'Edm.GeographyPoint', 'Edm.GeographyLineString', 'Edm.GeographyPolygon', 'Edm.GeographyMultiPoint', | ||
'Edm.GeographyMultiLineString', 'Edm.GeographyMultiPolygon', 'Edm.GeographyCollection', 'Edm.Geometry', 'Edm.GeometryPoint', | ||
'Edm.GeometryLineString', 'Edm.GeometryPolygon', 'Edm.GeometryMultiPoint', 'Edm.GeometryMultiLineString', 'Edm.GeometryMultiPolygon', | ||
'Edm.GeometryCollection', | ||
*/ | ||
/* UI.xml: defines Annotations with generic type 'Edm.PrimitiveType' */ | ||
'Edm.PrimitiveType', 'Bool', | ||
'Edm.PrimitiveType', 'Edm.Untyped', 'Bool', | ||
// Official JSON V4.01 Spec defines these paths as constant inline expression: | ||
@@ -1232,0 +1238,0 @@ 'AnnotationPath', 'ModelElementPath', 'NavigationPropertyPath', 'PropertyPath', |
@@ -151,3 +151,5 @@ 'use strict'; | ||
const finalType = csnUtils.getFinalTypeDef(node.type); | ||
if (finalType.items && isBuiltinType(finalType.items.type)) { | ||
if (finalType.items && | ||
(isBuiltinType(finalType.items.type) || isBuiltinType(csnUtils.getFinalBaseType(finalType.items.type)))) | ||
{ | ||
if (!isArtifactInService(node.type, currService) || !isV4) { | ||
@@ -154,0 +156,0 @@ node.items = finalType.items; |
{ | ||
"name": "@sap/cds-compiler", | ||
"version": "2.15.2", | ||
"version": "2.15.4", | ||
"description": "CDS (Core Data Services) compiler and backends", | ||
@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
4047957
80020