@sap/cds-compiler 3.1.0 → 3.3.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 +90 -3
- package/bin/cdsc.js +1 -1
- package/doc/CHANGELOG_BETA.md +18 -0
- package/lib/api/main.js +8 -13
- package/lib/base/error.js +2 -2
- package/lib/base/keywords.js +2 -24
- package/lib/base/message-registry.js +43 -14
- package/lib/base/messages.js +20 -10
- package/lib/base/model.js +1 -1
- package/lib/checks/actionsFunctions.js +1 -1
- package/lib/checks/annotationsOData.js +2 -2
- package/lib/checks/arrayOfs.js +15 -7
- package/lib/checks/cdsPersistence.js +1 -1
- package/lib/checks/checkForTypes.js +48 -0
- package/lib/checks/defaultValues.js +2 -2
- package/lib/checks/elements.js +81 -6
- package/lib/checks/foreignKeys.js +12 -13
- package/lib/checks/invalidTarget.js +10 -11
- package/lib/checks/managedInType.js +21 -15
- package/lib/checks/nullableKeys.js +1 -1
- package/lib/checks/onConditions.js +9 -9
- package/lib/checks/parameters.js +21 -0
- package/lib/checks/selectItems.js +1 -1
- package/lib/checks/types.js +2 -2
- package/lib/checks/utils.js +17 -7
- package/lib/checks/validator.js +26 -14
- package/lib/compiler/assert-consistency.js +13 -6
- package/lib/compiler/builtins.js +8 -0
- package/lib/compiler/checks.js +40 -33
- package/lib/compiler/define.js +50 -44
- package/lib/compiler/extend.js +303 -37
- package/lib/compiler/kick-start.js +2 -35
- package/lib/compiler/populate.js +83 -62
- package/lib/compiler/propagator.js +1 -1
- package/lib/compiler/resolve.js +61 -104
- package/lib/compiler/shared.js +16 -6
- package/lib/compiler/tweak-assocs.js +25 -12
- package/lib/compiler/utils.js +2 -2
- package/lib/edm/annotations/genericTranslation.js +15 -5
- package/lib/edm/csn2edm.js +10 -10
- package/lib/edm/edm.js +17 -9
- package/lib/edm/edmPreprocessor.js +82 -42
- package/lib/edm/edmUtils.js +18 -16
- package/lib/gen/Dictionary.json +14 -0
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +3 -2
- package/lib/gen/languageParser.js +4205 -4100
- package/lib/inspect/inspectModelStatistics.js +1 -1
- package/lib/inspect/inspectPropagation.js +23 -9
- package/lib/json/csnVersion.js +1 -1
- package/lib/json/from-csn.js +26 -19
- package/lib/json/to-csn.js +47 -5
- package/lib/language/antlrParser.js +1 -1
- package/lib/language/genericAntlrParser.js +29 -13
- package/lib/language/language.g4 +28 -8
- package/lib/main.d.ts +3 -6
- package/lib/model/.eslintrc.json +13 -0
- package/lib/model/api.js +4 -2
- package/lib/model/csnRefs.js +74 -47
- package/lib/model/csnUtils.js +236 -218
- package/lib/model/enrichCsn.js +41 -31
- package/lib/model/revealInternalProperties.js +61 -57
- package/lib/model/sortViews.js +31 -31
- package/lib/modelCompare/compare.js +6 -6
- package/lib/optionProcessor.js +5 -0
- package/lib/render/manageConstraints.js +2 -2
- package/lib/render/toCdl.js +31 -44
- package/lib/render/toHdbcds.js +7 -5
- package/lib/render/toRename.js +4 -4
- package/lib/render/toSql.js +11 -5
- package/lib/render/utils/common.js +20 -9
- package/lib/render/utils/sql.js +5 -5
- package/lib/transform/db/applyTransformations.js +32 -3
- package/lib/transform/db/expansion.js +81 -37
- package/lib/transform/db/flattening.js +1 -1
- package/lib/transform/db/temporal.js +1 -1
- package/lib/transform/db/transformExists.js +1 -1
- package/lib/transform/forOdataNew.js +10 -7
- package/lib/transform/{forHanaNew.js → forRelationalDB.js} +7 -7
- package/lib/transform/localized.js +28 -19
- package/lib/transform/odata/toFinalBaseType.js +8 -11
- package/lib/transform/odata/typesExposure.js +1 -1
- package/lib/transform/transformUtilsNew.js +101 -39
- package/lib/transform/translateAssocsToJoins.js +5 -4
- package/lib/utils/moduleResolve.js +5 -5
- package/lib/utils/objectUtils.js +3 -3
- package/package.json +2 -2
- package/share/messages/anno-duplicate-unrelated-layer.md +6 -6
- package/share/messages/check-proper-type-of.md +4 -4
- package/share/messages/check-proper-type.md +2 -2
- package/share/messages/duplicate-autoexposed.md +4 -4
- package/share/messages/extend-repeated-intralayer.md +4 -5
- package/share/messages/extend-unrelated-layer.md +4 -4
- package/share/messages/message-explanations.json +3 -1
- package/share/messages/redirected-to-ambiguous.md +7 -6
- package/share/messages/redirected-to-complex.md +63 -0
- package/share/messages/redirected-to-unrelated.md +6 -5
- package/share/messages/rewrite-not-supported.md +4 -4
- package/share/messages/syntax-expected-integer.md +3 -3
- package/share/messages/wildcard-excluding-one.md +37 -0
package/lib/edm/edmUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const { setProp } = require('../base/model');
|
|
3
|
-
const { isBuiltinType, isEdmPropertyRendered } = require('../model/csnUtils');
|
|
3
|
+
const { isBuiltinType, isEdmPropertyRendered, applyTransformations, cloneAnnotationValue } = require('../model/csnUtils');
|
|
4
4
|
const { escapeString, hasControlCharacters, hasUnpairedUnicodeSurrogate } = require("../render/utils/stringEscapes");
|
|
5
5
|
|
|
6
6
|
/* eslint max-statements-per-line:off */
|
|
@@ -508,6 +508,10 @@ function mapCdsToEdmType(csn, messageFunctions, isV2=false, isMediaType=false, l
|
|
|
508
508
|
'cds.hana.SMALLDECIMAL': 'Edm.Decimal', // V4: Scale="floating" Precision="16"
|
|
509
509
|
'cds.Integer64': 'Edm.Int64',
|
|
510
510
|
'cds.Integer': 'Edm.Int32',
|
|
511
|
+
'cds.Int64': 'Edm.Int64',
|
|
512
|
+
'cds.Int32': 'Edm.Int32',
|
|
513
|
+
'cds.Int16': 'Edm.Int16',
|
|
514
|
+
'cds.UInt8': 'Edm.Byte',
|
|
511
515
|
'cds.hana.SMALLINT': 'Edm.Int16',
|
|
512
516
|
'cds.hana.TINYINT': 'Edm.Byte',
|
|
513
517
|
'cds.Double': 'Edm.Double',
|
|
@@ -753,24 +757,24 @@ function resolveOriginAssoc(csn, env, path) {
|
|
|
753
757
|
return env;
|
|
754
758
|
}
|
|
755
759
|
|
|
756
|
-
function
|
|
757
|
-
let navPropEntry;
|
|
758
|
-
let hasEntry = false;
|
|
760
|
+
function mergeIntoNavPropEntry(annoPrefix, navPropEntry, prefix, props) {
|
|
759
761
|
let newEntry = false;
|
|
760
|
-
hasEntry = !!(navPropEntry = navPropRestrictions.find(p =>
|
|
761
|
-
p.NavigationProperty && p.NavigationProperty['='] === assocPath));
|
|
762
762
|
|
|
763
|
-
if(!hasEntry) {
|
|
764
|
-
navPropEntry = { NavigationProperty: { '=': assocPath } };
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
const prop = annoPrefix.split('.')[1];
|
|
768
763
|
// Filter properties with prefix and reduce them into a new dictionary
|
|
769
764
|
const o = props.filter(p => p[0].startsWith(annoPrefix+'.')).reduce((a,c) => {
|
|
770
|
-
|
|
765
|
+
// clone the annotation value to avoid side effects with rewritten paths
|
|
766
|
+
a[c[0].replace(annoPrefix+'.', '')] = cloneAnnotationValue(c[1]);
|
|
771
767
|
return a;
|
|
772
768
|
}, { });
|
|
769
|
+
|
|
770
|
+
// BEFORE merging found capabilities, prefix the paths
|
|
771
|
+
applyTransformations({ definitions: { o }}, {
|
|
772
|
+
"=": (parent, prop, value) => {
|
|
773
|
+
parent[prop] = prefix.concat(value).join('.');
|
|
774
|
+
}
|
|
775
|
+
});
|
|
773
776
|
// don't overwrite existing restrictions
|
|
777
|
+
const prop = annoPrefix.split('.')[1];
|
|
774
778
|
if(!navPropEntry[prop]) {
|
|
775
779
|
// if dictionary has entries, add them to navPropEnty
|
|
776
780
|
if(Object.keys(o).length) {
|
|
@@ -807,9 +811,7 @@ function mergeIntoNavPropRestrictions(annoPrefix, assocPath, props, navPropRestr
|
|
|
807
811
|
navPropEntry[prop][k] = v;
|
|
808
812
|
});
|
|
809
813
|
}
|
|
810
|
-
|
|
811
|
-
navPropRestrictions.push(navPropEntry);
|
|
812
|
-
}
|
|
814
|
+
return newEntry;
|
|
813
815
|
}
|
|
814
816
|
|
|
815
817
|
// Assign but not overwrite annotation
|
|
@@ -854,5 +856,5 @@ module.exports = {
|
|
|
854
856
|
escapeStringForText,
|
|
855
857
|
getSchemaPrefix,
|
|
856
858
|
getBaseName,
|
|
857
|
-
|
|
859
|
+
mergeIntoNavPropEntry
|
|
858
860
|
}
|
package/lib/gen/Dictionary.json
CHANGED
|
@@ -1808,6 +1808,13 @@
|
|
|
1808
1808
|
"Parameter"
|
|
1809
1809
|
]
|
|
1810
1810
|
},
|
|
1811
|
+
"UI.IsCopyAction": {
|
|
1812
|
+
"Type": "Core.Tag",
|
|
1813
|
+
"AppliesTo": [
|
|
1814
|
+
"Record"
|
|
1815
|
+
],
|
|
1816
|
+
"$experimental": true
|
|
1817
|
+
},
|
|
1811
1818
|
"UI.CreateHidden": {
|
|
1812
1819
|
"Type": "Core.Tag",
|
|
1813
1820
|
"AppliesTo": [
|
|
@@ -1897,6 +1904,13 @@
|
|
|
1897
1904
|
],
|
|
1898
1905
|
"$experimental": true
|
|
1899
1906
|
},
|
|
1907
|
+
"UI.LeadingEntitySet": {
|
|
1908
|
+
"Type": "Edm.String",
|
|
1909
|
+
"AppliesTo": [
|
|
1910
|
+
"EntityContainer"
|
|
1911
|
+
],
|
|
1912
|
+
"$experimental": true
|
|
1913
|
+
},
|
|
1900
1914
|
"Validation.Pattern": {
|
|
1901
1915
|
"Type": "Edm.String",
|
|
1902
1916
|
"AppliesTo": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d054015b5c1bda3f92422cb3f44733bb
|