@sap/cds-compiler 3.4.2 → 3.5.0
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 +80 -0
- package/README.md +1 -0
- package/bin/cds_update_identifiers.js +5 -5
- package/bin/cdsc.js +15 -16
- package/bin/cdshi.js +19 -6
- package/doc/CHANGELOG_ARCHIVE.md +2 -2
- package/doc/CHANGELOG_BETA.md +9 -1
- package/doc/CHANGELOG_DEPRECATED.md +2 -0
- package/lib/api/main.js +61 -59
- package/lib/api/options.js +4 -2
- package/lib/api/validate.js +2 -2
- package/lib/base/cleanSymbols.js +2 -3
- package/lib/base/dictionaries.js +6 -6
- package/lib/base/error.js +2 -2
- package/lib/base/keywords.js +6 -6
- package/lib/base/location.js +11 -12
- package/lib/base/message-registry.js +177 -58
- package/lib/base/messages.js +252 -180
- package/lib/base/model.js +14 -11
- package/lib/base/node-helpers.js +9 -10
- package/lib/base/optionProcessorHelper.js +138 -129
- package/lib/checks/.eslintrc.json +2 -0
- package/lib/checks/actionsFunctions.js +5 -5
- package/lib/checks/annotationsOData.js +4 -4
- package/lib/checks/arrayOfs.js +1 -1
- package/lib/checks/cdsPersistence.js +1 -1
- package/lib/checks/checkForTypes.js +3 -3
- package/lib/checks/defaultValues.js +3 -3
- package/lib/checks/elements.js +7 -7
- package/lib/checks/emptyOrOnlyVirtual.js +2 -2
- package/lib/checks/foreignKeys.js +1 -1
- package/lib/checks/invalidTarget.js +4 -4
- package/lib/checks/managedInType.js +1 -1
- package/lib/checks/managedWithoutKeys.js +1 -1
- package/lib/checks/nonexpandableStructured.js +5 -3
- package/lib/checks/nullableKeys.js +1 -1
- package/lib/checks/onConditions.js +5 -6
- package/lib/checks/parameters.js +1 -1
- package/lib/checks/queryNoDbArtifacts.js +2 -2
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +4 -4
- package/lib/checks/types.js +7 -7
- package/lib/checks/utils.js +4 -4
- package/lib/checks/validator.js +16 -13
- package/lib/compiler/.eslintrc.json +4 -1
- package/lib/compiler/assert-consistency.js +8 -7
- package/lib/compiler/builtins.js +14 -14
- package/lib/compiler/checks.js +123 -48
- package/lib/compiler/define.js +12 -13
- package/lib/compiler/extend.js +266 -60
- package/lib/compiler/finalize-parse-cdl.js +10 -5
- package/lib/compiler/index.js +17 -14
- package/lib/compiler/populate.js +14 -6
- package/lib/compiler/propagator.js +2 -0
- package/lib/compiler/resolve.js +2 -15
- package/lib/compiler/shared.js +27 -16
- package/lib/compiler/tweak-assocs.js +5 -6
- package/lib/compiler/utils.js +20 -0
- package/lib/edm/annotations/genericTranslation.js +604 -358
- package/lib/edm/annotations/preprocessAnnotations.js +39 -35
- package/lib/edm/csn2edm.js +275 -222
- package/lib/edm/edm.js +17 -3
- package/lib/edm/edmAnnoPreprocessor.js +6 -6
- package/lib/edm/edmInboundChecks.js +2 -2
- package/lib/edm/edmPreprocessor.js +107 -77
- package/lib/edm/edmUtils.js +44 -5
- package/lib/gen/Dictionary.json +210 -8
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +67 -63
- package/lib/gen/language.tokens +81 -81
- package/lib/gen/languageLexer.interp +4 -10
- package/lib/gen/languageLexer.js +854 -869
- package/lib/gen/languageLexer.tokens +79 -81
- package/lib/gen/languageParser.js +14309 -13832
- package/lib/inspect/inspectModelStatistics.js +2 -2
- package/lib/inspect/inspectPropagation.js +6 -6
- package/lib/inspect/inspectUtils.js +2 -2
- package/lib/json/from-csn.js +102 -55
- package/lib/json/to-csn.js +119 -198
- package/lib/language/antlrParser.js +5 -2
- package/lib/language/docCommentParser.js +6 -6
- package/lib/language/errorStrategy.js +43 -23
- package/lib/language/genericAntlrParser.js +113 -133
- package/lib/language/language.g4 +1550 -1506
- package/lib/language/multiLineStringParser.js +3 -3
- package/lib/language/textUtils.js +2 -2
- package/lib/main.js +3 -3
- package/lib/model/csnRefs.js +5 -0
- package/lib/model/csnUtils.js +130 -122
- package/lib/model/revealInternalProperties.js +1 -1
- package/lib/model/sortViews.js +4 -6
- package/lib/modelCompare/compare.js +2 -2
- package/lib/modelCompare/utils/.eslintrc.json +22 -0
- package/lib/modelCompare/utils/filter.js +100 -0
- package/lib/optionProcessor.js +5 -0
- package/lib/render/.eslintrc.json +1 -0
- package/lib/render/DuplicateChecker.js +1 -1
- package/lib/render/manageConstraints.js +12 -12
- package/lib/render/toCdl.js +311 -276
- package/lib/render/toHdbcds.js +97 -94
- package/lib/render/toRename.js +5 -5
- package/lib/render/toSql.js +127 -223
- package/lib/render/utils/common.js +141 -108
- package/lib/render/utils/delta.js +227 -0
- package/lib/render/utils/sql.js +22 -6
- package/lib/render/utils/stringEscapes.js +3 -3
- package/lib/transform/db/.eslintrc.json +2 -0
- package/lib/transform/db/applyTransformations.js +3 -3
- package/lib/transform/db/assertUnique.js +13 -12
- package/lib/transform/db/associations.js +5 -5
- package/lib/transform/db/cdsPersistence.js +10 -8
- package/lib/transform/db/constraints.js +14 -14
- package/lib/transform/db/expansion.js +20 -22
- package/lib/transform/db/flattening.js +24 -42
- package/lib/transform/db/groupByOrderBy.js +3 -3
- package/lib/transform/db/temporal.js +6 -6
- package/lib/transform/db/transformExists.js +23 -23
- package/lib/transform/db/views.js +16 -16
- package/lib/transform/draft/.eslintrc.json +1 -35
- package/lib/transform/draft/db.js +10 -10
- package/lib/transform/draft/odata.js +2 -2
- package/lib/transform/forOdataNew.js +8 -29
- package/lib/transform/forRelationalDB.js +16 -6
- package/lib/transform/localized.js +11 -10
- package/lib/transform/odata/toFinalBaseType.js +41 -27
- package/lib/transform/odata/typesExposure.js +113 -47
- package/lib/transform/parseExpr.js +209 -106
- package/lib/transform/transformUtilsNew.js +17 -10
- package/lib/transform/translateAssocsToJoins.js +24 -19
- package/lib/transform/universalCsn/coreComputed.js +10 -10
- package/lib/transform/universalCsn/universalCsnEnricher.js +26 -26
- package/lib/transform/universalCsn/utils.js +3 -3
- package/lib/utils/file.js +5 -5
- package/lib/utils/moduleResolve.js +13 -13
- package/lib/utils/objectUtils.js +6 -6
- package/lib/utils/term.js +5 -2
- package/lib/utils/timetrace.js +51 -24
- package/package.json +5 -8
- package/share/messages/check-proper-type-of.md +1 -1
- package/share/messages/message-explanations.json +1 -1
- package/share/messages/redirected-to-complex.md +4 -4
- package/share/messages/{syntax-expecting-integer.md → syntax-expecting-unsigned-int.md} +7 -4
- package/lib/modelCompare/filter.js +0 -83
|
@@ -24,7 +24,7 @@ const {
|
|
|
24
24
|
* @returns {[string, number]} The indentation-stripped string and the number
|
|
25
25
|
* of whitespace characters removed.
|
|
26
26
|
*/
|
|
27
|
-
function stripIndentation(str) {
|
|
27
|
+
function stripIndentation( str ) {
|
|
28
28
|
if (str === '')
|
|
29
29
|
return [ '', 0 ];
|
|
30
30
|
|
|
@@ -290,7 +290,7 @@ class MultiLineStringParser {
|
|
|
290
290
|
const loc = this._locationForCharacters(this.i + 1, 1);
|
|
291
291
|
const code = this._eos(this.i + 1) ? `\\${ mode }${ codePoint }` : `\\${ mode }${ codePoint }${ this._lookahead() }`;
|
|
292
292
|
this.parser.error('syntax-invalid-escape', loc,
|
|
293
|
-
{ '#': 'hex-count',
|
|
293
|
+
{ '#': 'hex-count', count, code: this._makeCode(code) });
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
|
@@ -510,7 +510,7 @@ class MultiLineStringParser {
|
|
|
510
510
|
*
|
|
511
511
|
* @param {object} token
|
|
512
512
|
*/
|
|
513
|
-
function parseMultiLineStringLiteral(token) {
|
|
513
|
+
function parseMultiLineStringLiteral( token ) {
|
|
514
514
|
const p = new MultiLineStringParser(this, token);
|
|
515
515
|
return p.parse();
|
|
516
516
|
}
|
|
@@ -11,7 +11,7 @@ const cdlNewLineRegEx = /\r\n?|\n|\u2028|\u2029/u;
|
|
|
11
11
|
* @param {string} str
|
|
12
12
|
* @returns {boolean}
|
|
13
13
|
*/
|
|
14
|
-
function isWhitespaceOrNewLineOnly(str) {
|
|
14
|
+
function isWhitespaceOrNewLineOnly( str ) {
|
|
15
15
|
return /^\s*$/.test(str);
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -33,7 +33,7 @@ function isWhitespaceOrNewLineOnly(str) {
|
|
|
33
33
|
* @param char
|
|
34
34
|
* @returns {boolean}
|
|
35
35
|
*/
|
|
36
|
-
function isWhitespaceCharacterNoNewline(char) {
|
|
36
|
+
function isWhitespaceCharacterNoNewline( char ) {
|
|
37
37
|
return whitespaceRegEx.test(char);
|
|
38
38
|
}
|
|
39
39
|
|
package/lib/main.js
CHANGED
|
@@ -24,7 +24,7 @@ const parseLanguage = lazyload('./language/antlrParser');
|
|
|
24
24
|
const compiler = lazyload('./compiler');
|
|
25
25
|
const shared = lazyload('./compiler/shared');
|
|
26
26
|
const define = lazyload('./compiler/define');
|
|
27
|
-
const builtins = lazyload(
|
|
27
|
+
const builtins = lazyload('./compiler/builtins');
|
|
28
28
|
const finalizeParseCdl = lazyload('./compiler/finalize-parse-cdl');
|
|
29
29
|
|
|
30
30
|
// The compiler version (taken from package.json)
|
|
@@ -78,7 +78,7 @@ module.exports = {
|
|
|
78
78
|
compileSources: (sourcesDict, options) => toCsn.compactModel( compiler.compileSourcesX(sourcesDict, options) ), // main function
|
|
79
79
|
compactModel: csn => csn, // for easy v2 migration
|
|
80
80
|
get CompilationError() {
|
|
81
|
-
Object.defineProperty(this,
|
|
81
|
+
Object.defineProperty(this, 'CompilationError', {
|
|
82
82
|
value: messages.CompilationError,
|
|
83
83
|
writable: false,
|
|
84
84
|
configurable: false,
|
|
@@ -95,7 +95,7 @@ module.exports = {
|
|
|
95
95
|
explainMessage: (...args) => messages.explainMessage(...args),
|
|
96
96
|
hasMessageExplanation: (...args) => messages.hasMessageExplanation(...args),
|
|
97
97
|
get InvocationError() {
|
|
98
|
-
Object.defineProperty(this,
|
|
98
|
+
Object.defineProperty(this, 'InvocationError', {
|
|
99
99
|
value: compiler.InvocationError,
|
|
100
100
|
writable: false,
|
|
101
101
|
configurable: false,
|
package/lib/model/csnRefs.js
CHANGED
|
@@ -204,6 +204,7 @@ const artifactProperties = [ 'elements', 'columns', 'keys', 'mixin', 'enum',
|
|
|
204
204
|
// * 'target': always follow target, including last ref item
|
|
205
205
|
// * other (& not provided) = follow target if not last ref item
|
|
206
206
|
const referenceSemantics = {
|
|
207
|
+
$init: { $initOnly: true },
|
|
207
208
|
type: { lexical: false, dynamic: 'global' }, // TODO: assoc: 'static', see Issue #8458
|
|
208
209
|
includes: { lexical: false, dynamic: 'global', assoc: 'static' }, // no elem ref anyway
|
|
209
210
|
target: { lexical: false, dynamic: 'global', assoc: 'static' }, // no elem ref anyway
|
|
@@ -532,6 +533,8 @@ function csnRefs( csn, universalReady ) {
|
|
|
532
533
|
return resolvePath( path, main.params[head], main, 'param' );
|
|
533
534
|
|
|
534
535
|
const semantics = referenceSemantics[refCtx] || {};
|
|
536
|
+
if (semantics.$initOnly)
|
|
537
|
+
return undefined;
|
|
535
538
|
if (semantics.dynamic === 'global' || ref.global)
|
|
536
539
|
return resolvePath( path, csn.definitions[head], null, 'global', semantics.assoc );
|
|
537
540
|
|
|
@@ -979,6 +982,8 @@ function analyseCsnPath( csnPath, csn, resolve ) {
|
|
|
979
982
|
else if (artifactProperties.includes( String(prop) )) {
|
|
980
983
|
if (refCtx === 'target' || refCtx === 'targetAspect') { // with 'elements'
|
|
981
984
|
// $self refers to the anonymous aspect
|
|
985
|
+
if (resolve)
|
|
986
|
+
resolve( '', '$init', main );
|
|
982
987
|
main = obj;
|
|
983
988
|
art = obj;
|
|
984
989
|
parent = null;
|