@sap/cds-compiler 3.1.2 → 3.4.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 +101 -3
- package/bin/cdsc.js +4 -2
- package/doc/CHANGELOG_BETA.md +35 -0
- package/lib/api/main.js +153 -29
- package/lib/api/validate.js +8 -3
- package/lib/base/dictionaries.js +6 -6
- package/lib/base/error.js +2 -2
- package/lib/base/keywords.js +106 -24
- package/lib/base/message-registry.js +177 -79
- package/lib/base/messages.js +78 -57
- package/lib/base/model.js +2 -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 +53 -0
- package/lib/checks/defaultValues.js +4 -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 +23 -0
- package/lib/checks/queryNoDbArtifacts.js +1 -1
- package/lib/checks/selectItems.js +1 -1
- package/lib/checks/sql-snippets.js +12 -10
- package/lib/checks/types.js +2 -2
- package/lib/checks/utils.js +17 -7
- package/lib/checks/validator.js +36 -14
- package/lib/compiler/assert-consistency.js +21 -13
- package/lib/compiler/builtins.js +8 -0
- package/lib/compiler/checks.js +57 -40
- package/lib/compiler/define.js +139 -69
- package/lib/compiler/extend.js +319 -50
- package/lib/compiler/finalize-parse-cdl.js +14 -9
- package/lib/compiler/kick-start.js +2 -35
- package/lib/compiler/populate.js +111 -68
- package/lib/compiler/propagator.js +5 -3
- package/lib/compiler/resolve.js +71 -108
- package/lib/compiler/shared.js +82 -54
- package/lib/compiler/tweak-assocs.js +26 -14
- package/lib/compiler/utils.js +13 -2
- package/lib/edm/annotations/genericTranslation.js +10 -7
- package/lib/edm/csn2edm.js +11 -11
- package/lib/edm/edm.js +17 -9
- package/lib/edm/edmPreprocessor.js +53 -30
- package/lib/edm/edmUtils.js +7 -2
- 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 +4312 -4186
- package/lib/inspect/inspectModelStatistics.js +1 -1
- package/lib/inspect/inspectPropagation.js +23 -9
- package/lib/json/csnVersion.js +13 -13
- package/lib/json/from-csn.js +161 -172
- package/lib/json/to-csn.js +70 -10
- package/lib/language/.eslintrc.json +4 -0
- package/lib/language/antlrParser.js +8 -11
- package/lib/language/docCommentParser.js +1 -2
- package/lib/language/errorStrategy.js +54 -27
- package/lib/language/genericAntlrParser.js +140 -93
- package/lib/language/language.g4 +57 -33
- package/lib/language/multiLineStringParser.js +75 -63
- package/lib/main.d.ts +3 -6
- package/lib/main.js +1 -0
- package/lib/model/.eslintrc.json +13 -0
- package/lib/model/api.js +4 -2
- package/lib/model/csnRefs.js +78 -50
- package/lib/model/csnUtils.js +272 -222
- package/lib/model/enrichCsn.js +41 -31
- package/lib/model/revealInternalProperties.js +61 -57
- package/lib/model/sortViews.js +35 -31
- package/lib/modelCompare/compare.js +52 -18
- package/lib/modelCompare/filter.js +83 -0
- package/lib/optionProcessor.js +10 -1
- package/lib/render/manageConstraints.js +11 -7
- package/lib/render/toCdl.js +151 -106
- package/lib/render/toHdbcds.js +8 -6
- package/lib/render/toRename.js +4 -4
- package/lib/render/toSql.js +17 -7
- package/lib/render/utils/common.js +27 -9
- package/lib/render/utils/sql.js +5 -5
- package/lib/sql-identifier.js +7 -0
- package/lib/transform/db/applyTransformations.js +32 -3
- package/lib/transform/db/assertUnique.js +27 -38
- package/lib/transform/db/expansion.js +92 -41
- package/lib/transform/db/flattening.js +1 -1
- package/lib/transform/db/temporal.js +3 -1
- package/lib/transform/db/transformExists.js +8 -2
- package/lib/transform/db/views.js +42 -13
- package/lib/transform/draft/db.js +2 -2
- package/lib/transform/forOdataNew.js +10 -7
- package/lib/transform/{forHanaNew.js → forRelationalDB.js} +18 -12
- package/lib/transform/localized.js +29 -20
- package/lib/transform/odata/toFinalBaseType.js +8 -11
- package/lib/transform/odata/typesExposure.js +2 -1
- package/lib/transform/parseExpr.js +245 -0
- package/lib/transform/transformUtilsNew.js +122 -51
- package/lib/transform/translateAssocsToJoins.js +17 -16
- package/lib/utils/moduleResolve.js +5 -5
- package/lib/utils/objectUtils.js +3 -3
- package/lib/utils/term.js +5 -5
- 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 → syntax-expecting-integer.md} +4 -4
- package/share/messages/wildcard-excluding-one.md +37 -0
|
@@ -14,7 +14,7 @@ function inspectModelStatistics(xsn, options) {
|
|
|
14
14
|
let result = '';
|
|
15
15
|
|
|
16
16
|
// Default color mode is 'auto'
|
|
17
|
-
const color = term(options.color
|
|
17
|
+
const color = term(options.color !== undefined ? options.color : 'auto');
|
|
18
18
|
|
|
19
19
|
const defCount = countDefinitionKinds(xsn);
|
|
20
20
|
const sources = {
|
|
@@ -16,7 +16,7 @@ function inspectPropagation(xsn, options, artifactName) {
|
|
|
16
16
|
const result = [];
|
|
17
17
|
|
|
18
18
|
// Default color mode is 'auto'
|
|
19
|
-
const color = term(options.color
|
|
19
|
+
const color = term(options.color !== undefined ? options.color : 'auto');
|
|
20
20
|
|
|
21
21
|
const path = stringRefToPath(artifactName);
|
|
22
22
|
if (!path) {
|
|
@@ -121,19 +121,28 @@ function _inspectElements(artifactXsn) {
|
|
|
121
121
|
const result = [];
|
|
122
122
|
const elements = Object.keys(artifactXsn.elements);
|
|
123
123
|
|
|
124
|
-
let maxElemLength = 12;
|
|
125
|
-
|
|
126
124
|
const inferredNiceOutput = {
|
|
127
125
|
'*': 'wildcard',
|
|
128
|
-
'expand-element': 'expanded',
|
|
129
|
-
'expand-param': 'expanded',
|
|
130
126
|
'aspect-composition': 'composition',
|
|
131
127
|
};
|
|
132
128
|
|
|
129
|
+
let maxElemLength = 12;
|
|
130
|
+
let maxOriginLength = 6;
|
|
131
|
+
|
|
132
|
+
// type: assume max length 11 of 'composition'
|
|
133
|
+
// element: assume average length of 30, chosen randomly
|
|
134
|
+
result.push([
|
|
135
|
+
'type'.padStart(11),
|
|
136
|
+
'element'.padEnd(maxElemLength),
|
|
137
|
+
'origin'.padEnd(maxOriginLength),
|
|
138
|
+
'location (definition)',
|
|
139
|
+
].join(' | '));
|
|
140
|
+
|
|
133
141
|
for (const element of elements) {
|
|
134
142
|
const elementXsn = artifactXsn.elements[element];
|
|
135
143
|
const loc = locationString(_origin(elementXsn).name.location);
|
|
136
144
|
let origin;
|
|
145
|
+
const originName = elementXsn._origin?.name?.absolute || '';
|
|
137
146
|
|
|
138
147
|
if (elementXsn.$inferred) {
|
|
139
148
|
// Use nice(r) output for known $inferred
|
|
@@ -151,11 +160,16 @@ function _inspectElements(artifactXsn) {
|
|
|
151
160
|
}
|
|
152
161
|
|
|
153
162
|
maxElemLength = Math.max(maxElemLength, element.length);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
maxOriginLength = Math.max(maxOriginLength, originName.length);
|
|
164
|
+
|
|
165
|
+
result.push([
|
|
166
|
+
origin.padStart(11),
|
|
167
|
+
element.padEnd(maxElemLength),
|
|
168
|
+
originName.padEnd(maxOriginLength),
|
|
169
|
+
loc,
|
|
170
|
+
].join(' | '));
|
|
158
171
|
}
|
|
172
|
+
|
|
159
173
|
return result;
|
|
160
174
|
}
|
|
161
175
|
|
package/lib/json/csnVersion.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
// csn version functions
|
|
3
4
|
|
|
4
5
|
// The CSN file format version produced by this compiler
|
|
5
6
|
// (Note that all 0.x.x versions are floating targets, i.e. the format is frequently
|
|
@@ -18,15 +19,12 @@
|
|
|
18
19
|
// Use literal version constants intentionally and not number intervals to
|
|
19
20
|
// record all published version strings of the core compiler.
|
|
20
21
|
const newCSNVersions = [ '0.1.99', '0.2', '0.2.0', '1.0', '2.0' ];
|
|
21
|
-
|
|
22
|
-
//
|
|
22
|
+
|
|
23
|
+
// Check if new-style CSN is requested, i.e. versions >= 0.1.99
|
|
23
24
|
function isNewCSN(csn, options) {
|
|
24
|
-
|
|
25
|
+
return !( options?.newCsn === false ||
|
|
25
26
|
(csn.version && !newCSNVersions.includes(csn.version.csn)) ||
|
|
26
|
-
(csn.$version && !newCSNVersions.includes(csn.$version)))
|
|
27
|
-
return false;
|
|
28
|
-
|
|
29
|
-
return true;
|
|
27
|
+
(csn.$version && !newCSNVersions.includes(csn.$version)));
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
function checkCSNVersion(csn, options) {
|
|
@@ -35,11 +33,13 @@ function checkCSNVersion(csn, options) {
|
|
|
35
33
|
const { makeMessageFunction } = require('../base/messages');
|
|
36
34
|
const { error, throwWithAnyError } = makeMessageFunction(csn, options);
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
const version = csn.version?.csn ? csn.version.csn : (csn.$version || 'unknown');
|
|
37
|
+
const variant = options.newCsn !== undefined ? 'newCsn' : 'std';
|
|
38
|
+
error('api-unsupported-csn-version', null,
|
|
39
|
+
{ '#': variant, version, code: options.newCsn }, {
|
|
40
|
+
std: 'CSN version $(VERSION) not supported',
|
|
41
|
+
newCsn: 'CSN version $(VERSION) not supported; options.newCsn: $(CODE)',
|
|
42
|
+
});
|
|
43
43
|
throwWithAnyError();
|
|
44
44
|
}
|
|
45
45
|
}
|