@sap/cds-compiler 2.11.4 → 2.13.8
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 +159 -1
- package/bin/cds_update_identifiers.js +7 -7
- package/bin/cdsc.js +22 -23
- package/bin/cdsse.js +2 -2
- package/doc/CHANGELOG_ARCHIVE.md +1 -1
- package/doc/CHANGELOG_BETA.md +25 -6
- package/doc/CHANGELOG_DEPRECATED.md +22 -6
- package/doc/NameResolution.md +21 -16
- package/lib/api/main.js +30 -63
- package/lib/api/options.js +5 -5
- package/lib/api/validate.js +0 -5
- package/lib/backends.js +15 -23
- package/lib/base/dictionaries.js +0 -8
- package/lib/base/error.js +26 -0
- package/lib/base/keywords.js +7 -17
- package/lib/base/location.js +9 -4
- package/lib/base/message-registry.js +52 -2
- package/lib/base/messages.js +16 -26
- package/lib/base/model.js +2 -62
- package/lib/base/optionProcessorHelper.js +246 -183
- package/lib/checks/.eslintrc.json +2 -0
- package/lib/checks/actionsFunctions.js +2 -1
- package/lib/checks/annotationsOData.js +1 -1
- package/lib/checks/cdsPersistence.js +2 -1
- package/lib/checks/enricher.js +17 -1
- package/lib/checks/foreignKeys.js +4 -4
- package/lib/checks/invalidTarget.js +3 -1
- package/lib/checks/managedInType.js +4 -4
- package/lib/checks/managedWithoutKeys.js +3 -1
- package/lib/checks/queryNoDbArtifacts.js +1 -3
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +94 -0
- package/lib/checks/types.js +1 -1
- package/lib/checks/validator.js +12 -7
- package/lib/compiler/assert-consistency.js +10 -6
- package/lib/compiler/base.js +0 -1
- package/lib/compiler/builtins.js +8 -6
- package/lib/compiler/checks.js +46 -12
- package/lib/compiler/cycle-detector.js +1 -1
- package/lib/compiler/define.js +1103 -0
- package/lib/compiler/extend.js +983 -0
- package/lib/compiler/finalize-parse-cdl.js +231 -0
- package/lib/compiler/index.js +33 -14
- package/lib/compiler/kick-start.js +190 -0
- package/lib/compiler/moduleLayers.js +4 -4
- package/lib/compiler/populate.js +1226 -0
- package/lib/compiler/propagator.js +113 -47
- package/lib/compiler/resolve.js +1433 -0
- package/lib/compiler/shared.js +76 -38
- package/lib/compiler/tweak-assocs.js +529 -0
- package/lib/compiler/utils.js +204 -33
- package/lib/edm/.eslintrc.json +5 -0
- package/lib/edm/annotations/genericTranslation.js +38 -25
- package/lib/edm/annotations/preprocessAnnotations.js +3 -3
- package/lib/edm/csn2edm.js +10 -9
- package/lib/edm/edm.js +19 -20
- package/lib/edm/edmPreprocessor.js +166 -95
- package/lib/edm/edmUtils.js +127 -34
- package/lib/gen/Dictionary.json +92 -43
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +11 -1
- package/lib/gen/language.tokens +86 -82
- package/lib/gen/languageLexer.interp +18 -1
- package/lib/gen/languageLexer.js +925 -847
- package/lib/gen/languageLexer.tokens +78 -74
- package/lib/gen/languageParser.js +5434 -4298
- package/lib/json/from-csn.js +59 -17
- package/lib/json/to-csn.js +143 -71
- package/lib/language/antlrParser.js +3 -3
- package/lib/language/docCommentParser.js +3 -3
- package/lib/language/genericAntlrParser.js +144 -54
- package/lib/language/language.g4 +424 -203
- package/lib/language/multiLineStringParser.js +536 -0
- package/lib/main.d.ts +472 -61
- package/lib/main.js +38 -11
- package/lib/model/api.js +3 -1
- package/lib/model/csnRefs.js +321 -204
- package/lib/model/csnUtils.js +224 -263
- package/lib/model/enrichCsn.js +97 -40
- package/lib/model/revealInternalProperties.js +27 -6
- package/lib/model/sortViews.js +2 -1
- package/lib/modelCompare/compare.js +17 -12
- package/lib/optionProcessor.js +7 -6
- package/lib/render/DuplicateChecker.js +1 -1
- package/lib/render/manageConstraints.js +36 -33
- package/lib/render/toCdl.js +174 -275
- package/lib/render/toHdbcds.js +201 -115
- package/lib/render/toRename.js +7 -10
- package/lib/render/toSql.js +149 -75
- package/lib/render/utils/common.js +22 -8
- package/lib/render/utils/sql.js +10 -7
- package/lib/render/utils/stringEscapes.js +111 -0
- package/lib/sql-identifier.js +1 -1
- package/lib/transform/.eslintrc.json +5 -0
- package/lib/transform/braceExpression.js +4 -2
- package/lib/transform/db/.eslintrc.json +2 -0
- package/lib/transform/db/applyTransformations.js +35 -12
- package/lib/transform/db/assertUnique.js +1 -1
- package/lib/transform/db/associations.js +187 -0
- package/lib/transform/db/cdsPersistence.js +150 -0
- package/lib/transform/db/constraints.js +61 -56
- package/lib/transform/db/expansion.js +50 -29
- package/lib/transform/db/flattening.js +552 -105
- package/lib/transform/db/groupByOrderBy.js +3 -1
- package/lib/transform/db/temporal.js +236 -0
- package/lib/transform/db/transformExists.js +94 -28
- package/lib/transform/db/views.js +5 -4
- package/lib/transform/draft/.eslintrc.json +38 -0
- package/lib/transform/{db/draft.js → draft/db.js} +9 -7
- package/lib/transform/draft/odata.js +227 -0
- package/lib/transform/forHanaNew.js +94 -801
- package/lib/transform/forOdataNew.js +22 -175
- package/lib/transform/localized.js +36 -32
- package/lib/transform/odata/generateForeignKeyElements.js +3 -3
- package/lib/transform/odata/referenceFlattener.js +95 -89
- package/lib/transform/odata/structureFlattener.js +1 -1
- package/lib/transform/odata/toFinalBaseType.js +86 -12
- package/lib/transform/odata/typesExposure.js +5 -5
- package/lib/transform/odata/utils.js +2 -2
- package/lib/transform/transformUtilsNew.js +47 -33
- package/lib/transform/translateAssocsToJoins.js +10 -27
- package/lib/transform/universalCsn/.eslintrc.json +36 -0
- package/lib/transform/universalCsn/coreComputed.js +170 -0
- package/lib/transform/universalCsn/universalCsnEnricher.js +715 -0
- package/lib/transform/universalCsn/utils.js +63 -0
- package/lib/utils/file.js +2 -1
- package/lib/utils/objectUtils.js +30 -0
- package/lib/utils/timetrace.js +8 -2
- package/package.json +1 -1
- package/share/messages/README.md +26 -0
- package/lib/compiler/definer.js +0 -2340
- package/lib/compiler/resolver.js +0 -2988
- package/lib/transform/universalCsnEnricher.js +0 -67
package/lib/edm/edm.js
CHANGED
|
@@ -137,11 +137,11 @@ module.exports = function (options, error) {
|
|
|
137
137
|
let tmpStr = '';
|
|
138
138
|
edmUtils.forAll(this, (v, p) => {
|
|
139
139
|
if (typeof this[p] !== 'object')
|
|
140
|
-
tmpStr += ' ' + p + '="' + edmUtils.
|
|
140
|
+
tmpStr += ' ' + p + '="' + edmUtils.escapeStringForAttributeValue(v) + '"'
|
|
141
141
|
});
|
|
142
142
|
edmUtils.forAll(this._xmlOnlyAttributes, (v,p) => {
|
|
143
143
|
if (typeof v !== 'object')
|
|
144
|
-
tmpStr += ' ' + p + '="' + edmUtils.
|
|
144
|
+
tmpStr += ' ' + p + '="' + edmUtils.escapeStringForAttributeValue(v) + '"'
|
|
145
145
|
});
|
|
146
146
|
return tmpStr;
|
|
147
147
|
}
|
|
@@ -599,7 +599,7 @@ module.exports = function (options, error) {
|
|
|
599
599
|
// Complex/EntityType are derived from TypeBase
|
|
600
600
|
// but have no type attribute in their CSN
|
|
601
601
|
if(typecsn.type) { // this thing has a type
|
|
602
|
-
// check
|
|
602
|
+
// check whether this is a scalar type (or array of scalar type) or a named type
|
|
603
603
|
let scalarType = undefined;
|
|
604
604
|
if(typecsn.items && typecsn.items.type &&
|
|
605
605
|
isBuiltinType(typecsn.items.type)) {
|
|
@@ -665,7 +665,7 @@ module.exports = function (options, error) {
|
|
|
665
665
|
json['$'+this._typeName] = this._type;
|
|
666
666
|
|
|
667
667
|
edmUtils.forAll(this, (v,p) => {
|
|
668
|
-
if (p !== 'Name' && p
|
|
668
|
+
if (p !== 'Name' && p !== this._typeName
|
|
669
669
|
// remove this line if Nullable=true becomes default
|
|
670
670
|
&& !(p === 'Nullable' && v == false))
|
|
671
671
|
{
|
|
@@ -711,7 +711,7 @@ module.exports = function (options, error) {
|
|
|
711
711
|
if(alias.length > 28) {
|
|
712
712
|
alias = alias.substr(0, 13)+ '__' +alias.substr(alias.length-13, alias.length);
|
|
713
713
|
}
|
|
714
|
-
alias = alias+'_'+c.toString().padStart(3,0);
|
|
714
|
+
alias = alias+'_'+c.toString().padStart(3, '0');
|
|
715
715
|
}
|
|
716
716
|
else if(alias.length > 32) {
|
|
717
717
|
alias = alias.substr(0, 15)+ '__' +alias.substr(alias.length-15, alias.length);
|
|
@@ -835,7 +835,7 @@ module.exports = function (options, error) {
|
|
|
835
835
|
// Nullable=false is default for EDM JSON representation 4.01
|
|
836
836
|
// When a key explicitly (!) has 'notNull = false', it stays nullable
|
|
837
837
|
return (nodeCsn._NotNullCollection !== undefined ? nodeCsn._NotNullCollection :
|
|
838
|
-
(nodeCsn.key &&
|
|
838
|
+
(nodeCsn.key && nodeCsn.notNull !== false) || nodeCsn.notNull === true);
|
|
839
839
|
}
|
|
840
840
|
|
|
841
841
|
toJSONattributes(json)
|
|
@@ -879,11 +879,12 @@ module.exports = function (options, error) {
|
|
|
879
879
|
// the V2 metadata.xml
|
|
880
880
|
// @ts-ignore
|
|
881
881
|
Property.SAP_Annotation_Attribute_WhiteList = [
|
|
882
|
-
'@sap.hierarchy.node.for',
|
|
883
|
-
'@sap.hierarchy.parent.node.for', // ->
|
|
884
|
-
'@sap.hierarchy.level.for',
|
|
885
|
-
'@sap.hierarchy.drill.state.for', // ->
|
|
886
|
-
'@sap.hierarchy.node.descendant.count.for'
|
|
882
|
+
'@sap.hierarchy.node.for', // -> sap:hierarchy-node-for
|
|
883
|
+
'@sap.hierarchy.parent.node.for', // -> sap:hierarchy-parent-node-for
|
|
884
|
+
'@sap.hierarchy.level.for', // -> sap:hierarchy-level-for
|
|
885
|
+
'@sap.hierarchy.drill.state.for', // -> sap:hierarchy-drill-state-for
|
|
886
|
+
'@sap.hierarchy.node.descendant.count.for', // -> sap:hierarchy-node-descendant-count-for
|
|
887
|
+
'@sap.parameter'
|
|
887
888
|
];
|
|
888
889
|
|
|
889
890
|
super(v, attributes, csn);
|
|
@@ -927,9 +928,7 @@ module.exports = function (options, error) {
|
|
|
927
928
|
Additionally: The attribute is named 'Default' in V2 and 'DefaultValue' in V4
|
|
928
929
|
*/
|
|
929
930
|
if(this.v4)
|
|
930
|
-
this[`Default${this.v4 ? 'Value' : ''}`] =
|
|
931
|
-
? defVal
|
|
932
|
-
: edmUtils.escapeString(defVal);
|
|
931
|
+
this[`Default${this.v4 ? 'Value' : ''}`] = defVal;
|
|
933
932
|
}
|
|
934
933
|
}
|
|
935
934
|
}
|
|
@@ -1159,7 +1158,7 @@ module.exports = function (options, error) {
|
|
|
1159
1158
|
/* short notation for Edm.Boolean, Edm.String and Edm.Float, see internal project:
|
|
1160
1159
|
edmx2csn-npm/edm-converters/blob/835d92a1aa6b0be25c56cef85e260c9188187429/lib/edmxV40ToJsonV40/README.md
|
|
1161
1160
|
*/
|
|
1162
|
-
case 'Edm.Boolean':
|
|
1161
|
+
case 'Edm.Boolean':
|
|
1163
1162
|
v = (v=='true'?true:(v=='false'?false:v));
|
|
1164
1163
|
// eslint-no-fallthrough
|
|
1165
1164
|
case 'Edm.String':
|
|
@@ -1275,8 +1274,8 @@ module.exports = function (options, error) {
|
|
|
1275
1274
|
if(this.Type)
|
|
1276
1275
|
json['@type'] = this.Type;
|
|
1277
1276
|
let keys = Object.keys(this).filter(k => k !== 'Type');
|
|
1278
|
-
for(
|
|
1279
|
-
json['$'+
|
|
1277
|
+
for(const key of keys)
|
|
1278
|
+
json['$'+key] = this[key];
|
|
1280
1279
|
}
|
|
1281
1280
|
|
|
1282
1281
|
toJSONchildren(json)
|
|
@@ -1356,7 +1355,7 @@ module.exports = function (options, error) {
|
|
|
1356
1355
|
{
|
|
1357
1356
|
let kind = this.kind;
|
|
1358
1357
|
let xml = indent + '<' + kind + this.toXMLattributes();
|
|
1359
|
-
xml += (this._value !== undefined ? '>' + edmUtils.
|
|
1358
|
+
xml += (this._value !== undefined ? '>' + edmUtils.escapeStringForText(this._value) + '</' + kind + '>' : '/>');
|
|
1360
1359
|
return xml;
|
|
1361
1360
|
}
|
|
1362
1361
|
|
|
@@ -1377,7 +1376,7 @@ module.exports = function (options, error) {
|
|
|
1377
1376
|
}
|
|
1378
1377
|
|
|
1379
1378
|
toJSON()
|
|
1380
|
-
{
|
|
1379
|
+
{
|
|
1381
1380
|
// toJSON: depending on number of children unary or n-ary expr
|
|
1382
1381
|
const json = this.mergeJSONAnnotations();
|
|
1383
1382
|
const e = this._children.filter(c=>c.kind !== 'Annotation');
|
|
@@ -1459,7 +1458,7 @@ module.exports = function (options, error) {
|
|
|
1459
1458
|
return json;
|
|
1460
1459
|
}
|
|
1461
1460
|
}
|
|
1462
|
-
// LabeledElementReference is a
|
|
1461
|
+
// LabeledElementReference is a
|
|
1463
1462
|
class LabeledElementReference extends ValueThing {
|
|
1464
1463
|
constructor(v, val) {
|
|
1465
1464
|
super(v, 'LabeledElementReference', val);
|