@sap/cds-compiler 2.13.8 → 2.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -4
- package/bin/cdsc.js +112 -37
- package/lib/api/main.js +20 -22
- package/lib/api/options.js +2 -3
- package/lib/api/validate.js +6 -6
- package/lib/base/message-registry.js +89 -14
- package/lib/base/messages.js +85 -64
- package/lib/base/optionProcessorHelper.js +19 -0
- package/lib/checks/annotationsOData.js +11 -32
- package/lib/checks/arrayOfs.js +1 -34
- package/lib/checks/validator.js +2 -4
- package/lib/compiler/assert-consistency.js +1 -0
- package/lib/compiler/base.js +1 -0
- package/lib/compiler/builtins.js +11 -0
- package/lib/compiler/checks.js +22 -70
- package/lib/compiler/define.js +59 -11
- package/lib/compiler/extend.js +20 -3
- package/lib/compiler/finalize-parse-cdl.js +26 -20
- package/lib/compiler/index.js +75 -26
- package/lib/compiler/populate.js +6 -5
- package/lib/compiler/propagator.js +4 -1
- package/lib/compiler/resolve.js +104 -16
- package/lib/compiler/shared.js +61 -27
- package/lib/compiler/tweak-assocs.js +7 -1
- package/lib/edm/annotations/genericTranslation.js +33 -15
- package/lib/edm/csn2edm.js +216 -98
- package/lib/edm/edm.js +298 -225
- package/lib/edm/edmPreprocessor.js +486 -415
- package/lib/edm/edmUtils.js +22 -22
- package/lib/gen/Dictionary.json +90 -16
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +3 -1
- package/lib/gen/languageParser.js +4636 -4368
- package/lib/json/csnVersion.js +10 -11
- package/lib/json/from-csn.js +3 -2
- package/lib/json/to-csn.js +0 -2
- package/lib/language/docCommentParser.js +2 -2
- package/lib/language/genericAntlrParser.js +47 -2
- package/lib/language/language.g4 +59 -27
- package/lib/main.d.ts +19 -1
- package/lib/main.js +6 -0
- package/lib/model/csnRefs.js +33 -6
- package/lib/model/csnUtils.js +193 -75
- package/lib/model/enrichCsn.js +1 -0
- package/lib/model/revealInternalProperties.js +2 -2
- package/lib/modelCompare/compare.js +6 -6
- package/lib/optionProcessor.js +62 -26
- package/lib/render/toCdl.js +844 -679
- package/lib/render/toHdbcds.js +189 -243
- package/lib/render/toSql.js +180 -198
- package/lib/render/utils/common.js +131 -15
- package/lib/transform/db/.eslintrc.json +1 -1
- package/lib/transform/db/associations.js +2 -2
- package/lib/transform/db/constraints.js +3 -1
- package/lib/transform/db/expansion.js +15 -10
- package/lib/transform/db/flattening.js +94 -64
- package/lib/transform/db/transformExists.js +7 -7
- package/lib/transform/db/views.js +6 -3
- package/lib/transform/forHanaNew.js +43 -26
- package/lib/transform/forOdataNew.js +43 -42
- package/lib/transform/localized.js +12 -7
- package/lib/transform/odata/toFinalBaseType.js +5 -5
- package/lib/transform/odata/typesExposure.js +145 -197
- package/lib/transform/transformUtilsNew.js +9 -12
- package/lib/transform/translateAssocsToJoins.js +1 -1
- package/lib/transform/universalCsn/coreComputed.js +5 -3
- package/lib/transform/universalCsn/universalCsnEnricher.js +27 -5
- package/lib/utils/moduleResolve.js +13 -6
- package/package.json +1 -1
- package/share/messages/message-explanations.json +2 -1
- package/share/messages/syntax-expected-integer.md +37 -0
- package/lib/transform/odata/attachPath.js +0 -96
- package/lib/transform/odata/expandStructKeysInAssociations.js +0 -59
- package/lib/transform/odata/generateForeignKeyElements.js +0 -261
- package/lib/transform/odata/referenceFlattener.js +0 -296
- package/lib/transform/odata/sortByAssociationDependency.js +0 -105
- package/lib/transform/odata/structuralPath.js +0 -72
- package/lib/transform/odata/structureFlattener.js +0 -171
package/lib/edm/edmUtils.js
CHANGED
|
@@ -401,7 +401,7 @@ function finalizeReferentialConstraints(csn, assocCsn, options, info)
|
|
|
401
401
|
if(options.isV2() && intersect(renderedKeys, remainingPrincipalRefs).length !== renderedKeys.length)
|
|
402
402
|
if(options.odataV2PartialConstr) {
|
|
403
403
|
info('odata-spec-violation-constraints',
|
|
404
|
-
['definitions', assocCsn._parent.name, 'elements', assocCsn.name], {
|
|
404
|
+
['definitions', assocCsn._parent.name, 'elements', assocCsn.name], { version: '2.0' });
|
|
405
405
|
}
|
|
406
406
|
else {
|
|
407
407
|
assocCsn._constraints.constraints = {};
|
|
@@ -439,7 +439,7 @@ function finalizeReferentialConstraints(csn, assocCsn, options, info)
|
|
|
439
439
|
if(options.isV2() && intersect(renderedKeys, remainingPrincipalRefs).length !== renderedKeys.length) {
|
|
440
440
|
if(options.odataV2PartialConstr) {
|
|
441
441
|
info('odata-spec-violation-constraints',
|
|
442
|
-
['definitions', assocCsn._parent.name, 'elements', assocCsn.name], {
|
|
442
|
+
['definitions', assocCsn._parent.name, 'elements', assocCsn.name], { version: '2.0' } );
|
|
443
443
|
}
|
|
444
444
|
else {
|
|
445
445
|
assocCsn._constraints.constraints = {};
|
|
@@ -467,7 +467,7 @@ function finalizeReferentialConstraints(csn, assocCsn, options, info)
|
|
|
467
467
|
return (elt &&
|
|
468
468
|
elt.type &&
|
|
469
469
|
(!options.isFlatFormat || options.isFlatFormat && isBuiltinType(elt.type)) &&
|
|
470
|
-
!
|
|
470
|
+
!(elt.type === 'cds.Association' || elt.type === 'cds.Composition') &&
|
|
471
471
|
isEdmPropertyRendered(elt, options));
|
|
472
472
|
}
|
|
473
473
|
}
|
|
@@ -522,12 +522,14 @@ function determineMultiplicity(csn)
|
|
|
522
522
|
return [srcCardinality, tgtCardinality];
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
function mapCdsToEdmType(csn, messageFunctions, isV2=false, isMediaType=false)
|
|
525
|
+
function mapCdsToEdmType(csn, messageFunctions, isV2=false, isMediaType=false, location=undefined)
|
|
526
526
|
{
|
|
527
|
+
if(location === undefined)
|
|
528
|
+
location = csn.$path;
|
|
527
529
|
const { error } = messageFunctions || { error: ()=>true };
|
|
528
530
|
let cdsType = csn.type;
|
|
529
531
|
if(cdsType === undefined) {
|
|
530
|
-
error(null,
|
|
532
|
+
error(null, location, `no type found`);
|
|
531
533
|
return '<NOTYPE>';
|
|
532
534
|
}
|
|
533
535
|
if(!isBuiltinType(cdsType))
|
|
@@ -582,7 +584,7 @@ function mapCdsToEdmType(csn, messageFunctions, isV2=false, isMediaType=false)
|
|
|
582
584
|
*/
|
|
583
585
|
}[cdsType];
|
|
584
586
|
if (edmType == undefined) {
|
|
585
|
-
error(null,
|
|
587
|
+
error(null, location, { type: cdsType }, `No EDM type available for $(TYPE)`);
|
|
586
588
|
}
|
|
587
589
|
if(isV2)
|
|
588
590
|
{
|
|
@@ -590,9 +592,6 @@ function mapCdsToEdmType(csn, messageFunctions, isV2=false, isMediaType=false)
|
|
|
590
592
|
edmType = 'Edm.DateTime';
|
|
591
593
|
if (edmType === 'Edm.TimeOfDay')
|
|
592
594
|
edmType = 'Edm.Time';
|
|
593
|
-
if(['cds.hana.ST_POINT', 'cds.hana.ST_GEOMETRY'].includes(cdsType)) {
|
|
594
|
-
error(null, csn.$path, { type: cdsType }, `OData V2 does not support Geometry data types, $(TYPE) can't be mapped`);
|
|
595
|
-
}
|
|
596
595
|
}
|
|
597
596
|
else // isV4
|
|
598
597
|
{
|
|
@@ -606,31 +605,32 @@ function mapCdsToEdmType(csn, messageFunctions, isV2=false, isMediaType=false)
|
|
|
606
605
|
function addTypeFacets(node, csn)
|
|
607
606
|
{
|
|
608
607
|
const isV2 = node.v2;
|
|
608
|
+
const decimalTypes = {'cds.Decimal':1, 'cds.DecimalFloat':1, 'cds.hana.SMALLDECIMAL':1};
|
|
609
609
|
if (csn.length != null)
|
|
610
|
-
node.MaxLength
|
|
610
|
+
node.setEdmAttribute('MaxLength', csn.length);
|
|
611
611
|
if (csn.scale !== undefined)
|
|
612
|
-
node.Scale
|
|
612
|
+
node.setEdmAttribute('Scale', csn.scale);
|
|
613
613
|
// else if (csn.type === 'cds.hana.SMALLDECIMAL' && !isV2)
|
|
614
|
-
// node.Scale = 'floating';
|
|
614
|
+
// node._edmAttributes.Scale = 'floating';
|
|
615
615
|
|
|
616
616
|
if (csn.precision != null)
|
|
617
|
-
node.Precision
|
|
617
|
+
node.setEdmAttribute('Precision', csn.precision);
|
|
618
618
|
// else if (csn.type === 'cds.hana.SMALLDECIMAL' && !isV2)
|
|
619
619
|
// node.Precision = 16;
|
|
620
|
-
else if (csn.type === 'cds.Timestamp' && node.Type === 'Edm.DateTimeOffset')
|
|
621
|
-
node.Precision
|
|
622
|
-
if(
|
|
620
|
+
else if (csn.type === 'cds.Timestamp' && node._edmAttributes.Type === 'Edm.DateTimeOffset')
|
|
621
|
+
node.setEdmAttribute('Precision', 7);
|
|
622
|
+
if(csn.type in decimalTypes) {
|
|
623
623
|
if(isV2) {
|
|
624
624
|
// no prec/scale or scale is 'floating'/'variable'
|
|
625
|
-
if(!(csn.precision || csn.scale) ||
|
|
625
|
+
if(!(csn.precision || csn.scale) || (csn.scale === 'floating' || csn.scale === 'variable')) {
|
|
626
626
|
node.setXml( { 'sap:variable-scale': true } );
|
|
627
|
-
|
|
627
|
+
node.removeEdmAttribute('Scale');
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
else {
|
|
631
631
|
// map both floating and variable to => variable
|
|
632
|
-
if(node.Scale === 'floating')
|
|
633
|
-
node.Scale
|
|
632
|
+
if(node._edmAttributes.Scale === 'floating')
|
|
633
|
+
node.setEdmAttribute('Scale', 'variable');
|
|
634
634
|
if(!csn.precision && !csn.scale)
|
|
635
635
|
// if Decimal has no p, s set scale 'variable'
|
|
636
636
|
node.setXml( { Scale: 'variable' } ); // floating is V4.01
|
|
@@ -638,9 +638,9 @@ function addTypeFacets(node, csn)
|
|
|
638
638
|
}
|
|
639
639
|
// Unicode unused today
|
|
640
640
|
if(csn.unicode)
|
|
641
|
-
node.Unicode
|
|
641
|
+
node.setEdmAttribute('Unicode', csn.unicode);
|
|
642
642
|
if(csn.srid)
|
|
643
|
-
node.SRID
|
|
643
|
+
node.setEdmAttribute('SRID', csn.srid);
|
|
644
644
|
}
|
|
645
645
|
|
|
646
646
|
|
package/lib/gen/Dictionary.json
CHANGED
|
@@ -1026,7 +1026,9 @@
|
|
|
1026
1026
|
]
|
|
1027
1027
|
},
|
|
1028
1028
|
"Common.RecursiveHierarchy": {
|
|
1029
|
-
"Type": "Common.RecursiveHierarchyType"
|
|
1029
|
+
"Type": "Common.RecursiveHierarchyType",
|
|
1030
|
+
"$deprecated": true,
|
|
1031
|
+
"$deprecationText": "Use terms [Aggregation.RecursiveHierarchy](https://github.com/oasis-tcs/odata-vocabularies/blob/main/vocabularies/Org.OData.Aggregation.V1.md#RecursiveHierarchy) and [Hierarchy.RecursiveHierarchy](https://github.com/SAP/odata-vocabularies/blob/main/vocabularies/Hierarchy.md#RecursiveHierarchy) instead"
|
|
1030
1032
|
},
|
|
1031
1033
|
"Common.CreatedAt": {
|
|
1032
1034
|
"Type": "Edm.DateTimeOffset",
|
|
@@ -1380,8 +1382,49 @@
|
|
|
1380
1382
|
"Core.GeometryFeature": {
|
|
1381
1383
|
"Type": "Core.GeometryFeatureType"
|
|
1382
1384
|
},
|
|
1383
|
-
"
|
|
1384
|
-
"Type": "
|
|
1385
|
+
"DataIntegration.Extractable": {
|
|
1386
|
+
"Type": "Edm.Boolean",
|
|
1387
|
+
"AppliesTo": [
|
|
1388
|
+
"EntitySet"
|
|
1389
|
+
]
|
|
1390
|
+
},
|
|
1391
|
+
"DataIntegration.OriginalDataType": {
|
|
1392
|
+
"Type": "Edm.String",
|
|
1393
|
+
"AppliesTo": [
|
|
1394
|
+
"Property"
|
|
1395
|
+
]
|
|
1396
|
+
},
|
|
1397
|
+
"DataIntegration.OriginalName": {
|
|
1398
|
+
"Type": "Edm.String"
|
|
1399
|
+
},
|
|
1400
|
+
"DataIntegration.ConversionExit": {
|
|
1401
|
+
"Type": "Edm.String",
|
|
1402
|
+
"AppliesTo": [
|
|
1403
|
+
"Property"
|
|
1404
|
+
]
|
|
1405
|
+
},
|
|
1406
|
+
"DataIntegration.SourceSystem": {
|
|
1407
|
+
"Type": "Edm.String",
|
|
1408
|
+
"AppliesTo": [
|
|
1409
|
+
"Container"
|
|
1410
|
+
]
|
|
1411
|
+
},
|
|
1412
|
+
"DataIntegration.DeltaMethod": {
|
|
1413
|
+
"Type": "DataIntegration.DeltaMethodType",
|
|
1414
|
+
"AppliesTo": [
|
|
1415
|
+
"EntitySet"
|
|
1416
|
+
]
|
|
1417
|
+
},
|
|
1418
|
+
"Graph.traceId": {
|
|
1419
|
+
"Type": "Edm.String",
|
|
1420
|
+
"$experimental": true
|
|
1421
|
+
},
|
|
1422
|
+
"Graph.Details": {
|
|
1423
|
+
"Type": "Graph.DetailsType",
|
|
1424
|
+
"$experimental": true
|
|
1425
|
+
},
|
|
1426
|
+
"Hierarchy.RecursiveHierarchy": {
|
|
1427
|
+
"Type": "Hierarchy.RecursiveHierarchyType",
|
|
1385
1428
|
"AppliesTo": [
|
|
1386
1429
|
"EntityType"
|
|
1387
1430
|
],
|
|
@@ -1393,6 +1436,17 @@
|
|
|
1393
1436
|
"Record"
|
|
1394
1437
|
]
|
|
1395
1438
|
},
|
|
1439
|
+
"JSON.Schema": {
|
|
1440
|
+
"Type": "JSON.JSON",
|
|
1441
|
+
"AppliesTo": [
|
|
1442
|
+
"EntityType",
|
|
1443
|
+
"Parameter",
|
|
1444
|
+
"Property",
|
|
1445
|
+
"ReturnType",
|
|
1446
|
+
"Term",
|
|
1447
|
+
"TypeDefinition"
|
|
1448
|
+
]
|
|
1449
|
+
},
|
|
1396
1450
|
"Measures.ISOCurrency": {
|
|
1397
1451
|
"Type": "Edm.String",
|
|
1398
1452
|
"AppliesTo": [
|
|
@@ -1713,7 +1767,8 @@
|
|
|
1713
1767
|
"Type": "Core.Tag",
|
|
1714
1768
|
"AppliesTo": [
|
|
1715
1769
|
"Property",
|
|
1716
|
-
"PropertyValue"
|
|
1770
|
+
"PropertyValue",
|
|
1771
|
+
"Parameter"
|
|
1717
1772
|
]
|
|
1718
1773
|
},
|
|
1719
1774
|
"UI.Placeholder": {
|
|
@@ -1898,14 +1953,14 @@
|
|
|
1898
1953
|
]
|
|
1899
1954
|
},
|
|
1900
1955
|
"Validation.OpenPropertyTypeConstraint": {
|
|
1901
|
-
"Type": "Collection(
|
|
1956
|
+
"Type": "Collection(Validation.SingleOrCollectionType)",
|
|
1902
1957
|
"AppliesTo": [
|
|
1903
1958
|
"ComplexType",
|
|
1904
1959
|
"EntityType"
|
|
1905
1960
|
]
|
|
1906
1961
|
},
|
|
1907
1962
|
"Validation.DerivedTypeConstraint": {
|
|
1908
|
-
"Type": "Collection(
|
|
1963
|
+
"Type": "Collection(Validation.SingleOrCollectionType)",
|
|
1909
1964
|
"AppliesTo": [
|
|
1910
1965
|
"EntitySet",
|
|
1911
1966
|
"Singleton",
|
|
@@ -2740,7 +2795,9 @@
|
|
|
2740
2795
|
"ExternalNodeKeyProperty": "Edm.PropertyPath",
|
|
2741
2796
|
"NodeDescendantCountProperty": "Edm.PropertyPath",
|
|
2742
2797
|
"NodeDrillStateProperty": "Edm.PropertyPath"
|
|
2743
|
-
}
|
|
2798
|
+
},
|
|
2799
|
+
"$deprecated": true,
|
|
2800
|
+
"$deprecationText": "Use terms [Aggregation.RecursiveHierarchy](https://github.com/oasis-tcs/odata-vocabularies/blob/main/vocabularies/Org.OData.Aggregation.V1.md#RecursiveHierarchy) and [Hierarchy.RecursiveHierarchy](https://github.com/SAP/odata-vocabularies/blob/main/vocabularies/Hierarchy.md#RecursiveHierarchy) instead"
|
|
2744
2801
|
},
|
|
2745
2802
|
"Common.NumericMessageSeverityType": {
|
|
2746
2803
|
"$kind": "TypeDefinition",
|
|
@@ -3122,22 +3179,31 @@
|
|
|
3122
3179
|
"UnderlyingType": "Edm.String",
|
|
3123
3180
|
"MaxLength": "128"
|
|
3124
3181
|
},
|
|
3125
|
-
"
|
|
3182
|
+
"DataIntegration.DeltaMethodType": {
|
|
3183
|
+
"$kind": "EnumType",
|
|
3184
|
+
"IsFlags": "true",
|
|
3185
|
+
"Members": [
|
|
3186
|
+
"INSERT",
|
|
3187
|
+
"UPDATE",
|
|
3188
|
+
"DELETE"
|
|
3189
|
+
]
|
|
3190
|
+
},
|
|
3191
|
+
"Graph.DetailsType": {
|
|
3126
3192
|
"$kind": "ComplexType",
|
|
3127
3193
|
"Properties": {
|
|
3128
|
-
"
|
|
3129
|
-
"
|
|
3130
|
-
"target": "Edm.String",
|
|
3131
|
-
"parameters": "Collection(Graph.binding)",
|
|
3132
|
-
"filter": "Collection(Graph.binding)"
|
|
3194
|
+
"url": "Edm.String",
|
|
3195
|
+
"body": "JSON.JSON"
|
|
3133
3196
|
},
|
|
3134
3197
|
"$experimental": true
|
|
3135
3198
|
},
|
|
3136
|
-
"
|
|
3199
|
+
"Hierarchy.RecursiveHierarchyType": {
|
|
3137
3200
|
"$kind": "ComplexType",
|
|
3138
3201
|
"Properties": {
|
|
3139
|
-
"
|
|
3140
|
-
"
|
|
3202
|
+
"ExternalKeyProperty": "Edm.PropertyPath",
|
|
3203
|
+
"DescendantCountProperty": "Edm.PropertyPath",
|
|
3204
|
+
"DrillStateProperty": "Edm.PropertyPath",
|
|
3205
|
+
"SiblingRankProperty": "Edm.PropertyPath",
|
|
3206
|
+
"PreorderRankProperty": "Edm.PropertyPath"
|
|
3141
3207
|
},
|
|
3142
3208
|
"$experimental": true
|
|
3143
3209
|
},
|
|
@@ -3147,6 +3213,10 @@
|
|
|
3147
3213
|
"width": "Edm.String"
|
|
3148
3214
|
}
|
|
3149
3215
|
},
|
|
3216
|
+
"JSON.JSON": {
|
|
3217
|
+
"$kind": "TypeDefinition",
|
|
3218
|
+
"UnderlyingType": "Edm.Stream"
|
|
3219
|
+
},
|
|
3150
3220
|
"Measures.DurationGranularityType": {
|
|
3151
3221
|
"$kind": "TypeDefinition",
|
|
3152
3222
|
"UnderlyingType": "Edm.String"
|
|
@@ -3901,6 +3971,10 @@
|
|
|
3901
3971
|
"path": "Edm.NavigationPropertyPath",
|
|
3902
3972
|
"target": "Edm.NavigationPropertyPath"
|
|
3903
3973
|
}
|
|
3974
|
+
},
|
|
3975
|
+
"Validation.SingleOrCollectionType": {
|
|
3976
|
+
"$kind": "TypeDefinition",
|
|
3977
|
+
"UnderlyingType": "Edm.String"
|
|
3904
3978
|
}
|
|
3905
3979
|
}
|
|
3906
3980
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
351a6ed427f91f2eef4d8e9a2e11dd17
|