@sap/cds-compiler 4.9.2 → 5.0.6
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 +74 -0
- package/bin/cds_remove_invalid_whitespace.js +2 -1
- package/bin/cdsc.js +15 -11
- package/bin/cdshi.js +1 -0
- package/doc/CHANGELOG_BETA.md +7 -0
- package/lib/api/main.js +7 -19
- package/lib/api/options.js +5 -11
- package/lib/api/trace.js +0 -1
- package/lib/base/builtins.js +1 -0
- package/lib/base/location.js +4 -1
- package/lib/base/message-registry.js +29 -29
- package/lib/base/messages.js +22 -26
- package/lib/base/model.js +0 -2
- package/lib/base/node-helpers.js +0 -1
- package/lib/checks/enricher.js +1 -5
- package/lib/checks/structuredAnnoExpressions.js +30 -0
- package/lib/checks/validator.js +8 -0
- package/lib/compiler/assert-consistency.js +4 -1
- package/lib/compiler/base.js +1 -1
- package/lib/compiler/builtins.js +18 -2
- package/lib/compiler/checks.js +2 -5
- package/lib/compiler/define.js +7 -7
- package/lib/compiler/extend.js +68 -33
- package/lib/compiler/generate.js +1 -1
- package/lib/compiler/index.js +23 -6
- package/lib/compiler/lsp-api.js +501 -2
- package/lib/compiler/populate.js +2 -2
- package/lib/compiler/propagator.js +1 -4
- package/lib/compiler/resolve.js +2 -15
- package/lib/compiler/shared.js +112 -31
- package/lib/compiler/tweak-assocs.js +2 -16
- package/lib/compiler/utils.js +2 -1
- package/lib/compiler/xsn-model.js +4 -0
- package/lib/edm/annotations/genericTranslation.js +95 -42
- package/lib/edm/csn2edm.js +16 -4
- package/lib/edm/edm.js +2 -3
- package/lib/edm/edmAnnoPreprocessor.js +1 -2
- package/lib/edm/edmPreprocessor.js +1 -7
- package/lib/gen/Dictionary.json +29 -2
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +2 -1
- package/lib/gen/languageParser.js +4995 -4817
- package/lib/json/csnVersion.js +1 -1
- package/lib/json/from-csn.js +4 -7
- package/lib/json/to-csn.js +23 -12
- package/lib/language/antlrParser.js +2 -2
- package/lib/language/errorStrategy.js +0 -1
- package/lib/language/genericAntlrParser.js +35 -12
- package/lib/language/multiLineStringParser.js +3 -2
- package/lib/language/textUtils.js +1 -0
- package/lib/main.d.ts +28 -9
- package/lib/main.js +7 -4
- package/lib/model/csnRefs.js +20 -4
- package/lib/model/csnUtils.js +0 -2
- package/lib/model/revealInternalProperties.js +1 -1
- package/lib/modelCompare/compare.js +1 -1
- package/lib/optionProcessor.js +28 -9
- package/lib/render/manageConstraints.js +1 -1
- package/lib/render/toCdl.js +36 -7
- package/lib/render/toSql.js +1 -0
- package/lib/render/utils/common.js +12 -9
- package/lib/render/utils/stringEscapes.js +1 -0
- package/lib/transform/db/applyTransformations.js +13 -8
- package/lib/transform/db/associations.js +62 -54
- package/lib/transform/db/constraints.js +23 -25
- package/lib/transform/db/expansion.js +1 -6
- package/lib/transform/db/flattening.js +89 -111
- package/lib/transform/db/temporal.js +3 -4
- package/lib/transform/db/views.js +0 -1
- package/lib/transform/draft/odata.js +51 -3
- package/lib/transform/effective/annotations.js +3 -2
- package/lib/transform/effective/flattening.js +135 -0
- package/lib/transform/effective/main.js +6 -6
- package/lib/transform/effective/types.js +13 -9
- package/lib/transform/forOdata.js +0 -2
- package/lib/transform/forRelationalDB.js +0 -19
- package/lib/transform/localized.js +7 -8
- package/lib/transform/odata/flattening.js +39 -31
- package/lib/transform/odata/typesExposure.js +5 -17
- package/lib/transform/transformUtils.js +1 -1
- package/lib/transform/translateAssocsToJoins.js +21 -3
- package/lib/utils/file.js +13 -7
- package/lib/utils/moduleResolve.js +59 -8
- package/lib/utils/term.js +3 -2
- package/package.json +7 -3
- package/share/messages/message-explanations.json +2 -0
- package/share/messages/type-unexpected-foreign-keys.md +52 -0
- package/share/messages/type-unexpected-on-condition.md +52 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,80 @@
|
|
|
7
7
|
Note: `beta` fixes, changes and features are usually not listed in this ChangeLog but [here](doc/CHANGELOG_BETA.md).
|
|
8
8
|
The compiler behavior concerning `beta` features can change at any time without notice.
|
|
9
9
|
|
|
10
|
+
## Version 5.0.6 - 2024-07-10
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- for.seal: Don't generate DRAFT artifacts.
|
|
15
|
+
|
|
16
|
+
## Version 5.0.4 - 2024-06-26
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- CDL parser: an `extend entity` and `extend aspect` with an extensions for the
|
|
21
|
+
same element now correctly leads to an error, because it resulted in part of the
|
|
22
|
+
extension being simply dropped. Remark: an `extend type` and the recommended
|
|
23
|
+
plain `extend` led to an error in that situation already before.
|
|
24
|
+
- to.sql: Conditions inside filters in combination with foreign key aliases were
|
|
25
|
+
not properly translated in rare cases.
|
|
26
|
+
- Update OData Vocabularies: 'PDF', 'UI'.
|
|
27
|
+
|
|
28
|
+
## Version 5.0.2 - 2024-06-14
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- API `CompilationError` will serialize the first compiler error in `e.message`
|
|
33
|
+
- cdsc: `--without-hana-associations` is changed to `--with-hana-associations`
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- to.edm(x):
|
|
38
|
+
+ Respect `AppliesTo` specification in term definitions for actions and functions.
|
|
39
|
+
+ Make message `odata-spec-violation-namespace` a warning again.
|
|
40
|
+
|
|
41
|
+
## Version 5.0.0 - Pre-release version - 2024-05-29
|
|
42
|
+
|
|
43
|
+
This is a preview version for the major release and contains breaking changes. It should not be used for production.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- Node 18 is now the minimum required version.
|
|
48
|
+
- API `CompilationError`s will no longer serialize all compiler messages into `e.message`.
|
|
49
|
+
Use `e.messages[]` instead or `e.toString()` to serialize errors into a string.
|
|
50
|
+
- CDL parser: Annotations that can't be applied are now rejected.
|
|
51
|
+
- compiler:
|
|
52
|
+
+ `extend` statements on "namespaces" (paths that are not definitions) are now always errors.
|
|
53
|
+
+ non-structured events are rejected
|
|
54
|
+
+ `$self` references in JOINs are rejected if they could lead to issues in SQL rendering.
|
|
55
|
+
+ non-string enum definitions must have a value.
|
|
56
|
+
+ A top-level definition `$self` is rejected. `$self` is considered a reserved name.
|
|
57
|
+
+ `$at.from`/`$at.to` are deprecated; use `$valid.from`/`$valid.to` instead.
|
|
58
|
+
- to.hdbcds: The HDBCDS backend is now considered deprecated.
|
|
59
|
+
- to.edm(x):
|
|
60
|
+
+ Set default nullability to `true` for collection like properties (was `false` before).
|
|
61
|
+
+ Raise message ids `odata-spec-violation-namespace`, `odata-spec-violation-no-key` from warning to error.
|
|
62
|
+
- to.sql:
|
|
63
|
+
+ `@cds.persistence.exists` is _not_ propagated to generated localization views (`localized.*`)
|
|
64
|
+
+ Option `fewerLocalizedViews` is now enabled by default.
|
|
65
|
+
+ Option `betterSqliteSessionVariables` is now enabled by default.
|
|
66
|
+
|
|
67
|
+
### Fixed
|
|
68
|
+
|
|
69
|
+
- for.odata: Propagate all `@odata { Type, MaxLength, Precision, Scale, SRID }` to generated foreign keys.
|
|
70
|
+
|
|
71
|
+
### Removed
|
|
72
|
+
|
|
73
|
+
- API: Deprecated functions `preparedCsnToEdmx` and `preparedCsnToEdm` were removed.
|
|
74
|
+
Use `to.edm(x)` instead.
|
|
75
|
+
|
|
76
|
+
## Version 4.9.4 - 2024-05-21
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- to.sql:
|
|
81
|
+
+ always include `tenant` column in foreign key references.
|
|
82
|
+
+ reject `tenantDiscriminator` option only if sql dialect is `hana` and if `withHanaAssociations` option is set.
|
|
83
|
+
|
|
10
84
|
## Version 4.9.2 - 2024-05-13
|
|
11
85
|
|
|
12
86
|
### Fixed
|
|
@@ -64,7 +64,8 @@ function modernizeWhitespace( source, filename ) {
|
|
|
64
64
|
|
|
65
65
|
// To avoid spam, only report errors.
|
|
66
66
|
// Users should use the compiler to get all messages.
|
|
67
|
-
const errors = options.messages
|
|
67
|
+
const errors = options.messages
|
|
68
|
+
.filter(msg => (msg.severity === 'Error' && msg.messageId !== 'syntax-invalid-space'));
|
|
68
69
|
if (errors.length > 0) {
|
|
69
70
|
errors.forEach((msg) => {
|
|
70
71
|
console.error(msg.toString());
|
package/bin/cdsc.js
CHANGED
|
@@ -145,6 +145,7 @@ function cdsc_main() {
|
|
|
145
145
|
// Internally, parseCdl/parseOnly are options, so we map the command to it.
|
|
146
146
|
if (cmdLine.command === 'parseCdl') {
|
|
147
147
|
cmdLine.command = 'toCsn';
|
|
148
|
+
cmdLine.options.toCsn = cmdLine.options.parseCdl;
|
|
148
149
|
cmdLine.options.parseCdl = true;
|
|
149
150
|
cmdLine.args.files = [ cmdLine.args.file ];
|
|
150
151
|
}
|
|
@@ -169,12 +170,20 @@ function cdsc_main() {
|
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
const to = cmdLine.options.toSql ? 'toSql' : 'toHana';
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
if (cmdLine.options[to]) {
|
|
174
|
+
// remap string values in options to boolean
|
|
175
|
+
if (cmdLine.options[to].assertIntegrity &&
|
|
176
|
+
(cmdLine.options[to].assertIntegrity === 'true' ||
|
|
177
|
+
cmdLine.options[to].assertIntegrity === 'false')
|
|
178
|
+
)
|
|
179
|
+
cmdLine.options[to].assertIntegrity = cmdLine.options[to].assertIntegrity === 'true';
|
|
180
|
+
|
|
181
|
+
if (cmdLine.options[to].withHanaAssociations)
|
|
182
|
+
cmdLine.options[to].withHanaAssociations = cmdLine.options[to].withHanaAssociations !== 'false';
|
|
183
|
+
|
|
184
|
+
if (cmdLine.options[to].betterSqliteSessionVariables)
|
|
185
|
+
cmdLine.options[to].betterSqliteSessionVariables = cmdLine.options[to].betterSqliteSessionVariables === 'true';
|
|
186
|
+
}
|
|
178
187
|
|
|
179
188
|
// Enable all beta-flags if betaMode is set to true
|
|
180
189
|
if (cmdLine.options.betaMode)
|
|
@@ -446,11 +455,6 @@ function executeCommandLine( command, options, args ) {
|
|
|
446
455
|
// Execute the command line option '--to-sql' and display the results.
|
|
447
456
|
// Return the original model (for chaining)
|
|
448
457
|
function toSql( model ) {
|
|
449
|
-
if (options.withoutHanaAssociations) {
|
|
450
|
-
options.withHanaAssociations = false;
|
|
451
|
-
delete options.withoutHanaAssociations;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
458
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
455
459
|
if (options.src === 'hdi') {
|
|
456
460
|
if (options.csn) {
|
package/bin/cdshi.js
CHANGED
|
@@ -34,6 +34,7 @@ const categoryChars = { // default: first char of category name
|
|
|
34
34
|
ExtBoundAction: 'B', // highlight like bound action definition
|
|
35
35
|
ExtParam: 'P', // highlight like entity/action parameter definition
|
|
36
36
|
Event: 'Y',
|
|
37
|
+
KeyImplicit: 'r', // handle as normal ref
|
|
37
38
|
// Remark: do not use `x`/`X` (hex literal `x'1e3d'`)
|
|
38
39
|
};
|
|
39
40
|
|
package/doc/CHANGELOG_BETA.md
CHANGED
|
@@ -8,6 +8,13 @@ Note: `beta` fixes, changes and features are listed in this ChangeLog just for i
|
|
|
8
8
|
The compiler behavior concerning `beta` features can change at any time without notice.
|
|
9
9
|
**Don't use `beta` fixes, changes and features in productive mode.**
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
## Version 5.0.0 - 2024-05-29
|
|
13
|
+
|
|
14
|
+
## Removed `v5preview`
|
|
15
|
+
|
|
16
|
+
It is now enabled by default.
|
|
17
|
+
|
|
11
18
|
## Version 4.9.0 - 2024-04-25
|
|
12
19
|
|
|
13
20
|
## Removed `odataAnnotationExpressions`
|
package/lib/api/main.js
CHANGED
|
@@ -712,9 +712,9 @@ function hdbcds( csn, options, messageFunctions ) {
|
|
|
712
712
|
internalOptions.transformation = 'hdbcds';
|
|
713
713
|
messageFunctions.setOptions( internalOptions );
|
|
714
714
|
|
|
715
|
-
//
|
|
716
|
-
|
|
717
|
-
|
|
715
|
+
// Since v5, the HDBCDS backend is considered deprecated.
|
|
716
|
+
// TODO(v6): Make this a configurable error
|
|
717
|
+
messageFunctions.warning('api-deprecated-v5', null, null);
|
|
718
718
|
|
|
719
719
|
if (options.tenantDiscriminator) {
|
|
720
720
|
messageFunctions.error('api-invalid-option', null, {
|
|
@@ -741,7 +741,6 @@ function hdbcds( csn, options, messageFunctions ) {
|
|
|
741
741
|
function edm( csn, options, messageFunctions ) {
|
|
742
742
|
// If not provided at all, set service to 'undefined' to trigger validation
|
|
743
743
|
const internalOptions = prepareOptions.to.edm(
|
|
744
|
-
// eslint-disable-next-line comma-dangle
|
|
745
744
|
options.service ? options : Object.assign({ service: undefined }, options)
|
|
746
745
|
);
|
|
747
746
|
messageFunctions.setOptions( internalOptions );
|
|
@@ -810,7 +809,6 @@ function edmall( csn, options, messageFunctions ) {
|
|
|
810
809
|
function edmx( csn, options, messageFunctions ) {
|
|
811
810
|
// If not provided at all, set service to 'undefined' to trigger validation
|
|
812
811
|
const internalOptions = prepareOptions.to.edmx(
|
|
813
|
-
// eslint-disable-next-line comma-dangle
|
|
814
812
|
options.service ? options : Object.assign({ service: undefined }, options)
|
|
815
813
|
);
|
|
816
814
|
messageFunctions.setOptions( internalOptions );
|
|
@@ -880,9 +878,8 @@ function edmxall( csn, options, messageFunctions ) {
|
|
|
880
878
|
*/
|
|
881
879
|
// @ts-ignore
|
|
882
880
|
function odata2( csn, options, messageFunctions ) {
|
|
883
|
-
// If not provided at all, set service to undefined to trigger validation
|
|
881
|
+
// If not provided at all, set service to 'undefined' to trigger validation
|
|
884
882
|
const internalOptions = prepareOptions.to.odata(
|
|
885
|
-
// eslint-disable-next-line comma-dangle
|
|
886
883
|
options.service ? options : Object.assign({ service: undefined }, options)
|
|
887
884
|
);
|
|
888
885
|
messageFunctions.setOptions( internalOptions );
|
|
@@ -1074,15 +1071,6 @@ module.exports = {
|
|
|
1074
1071
|
for_hdbcds: publishCsnProcessor(forHdbcds, 'for.hdbcds'),
|
|
1075
1072
|
for_effective: publishCsnProcessor(forEffective, 'for.effective'),
|
|
1076
1073
|
for_seal: publishCsnProcessor(forSeal, 'for.seal'),
|
|
1077
|
-
|
|
1078
|
-
/* Deprecated, will be removed in cds-compiler@v5 */ // TODO(v5): Remove
|
|
1079
|
-
preparedCsnToEdmx(csn, service, options) {
|
|
1080
|
-
preparedCsnToEdmx(csn, service, options, messages.makeMessageFunction( csn, options, 'to.edmx' ));
|
|
1081
|
-
},
|
|
1082
|
-
/* Deprecated, will be removed in cds-compiler@v5 */ // TODO(v5): Remove
|
|
1083
|
-
preparedCsnToEdm(csn, service, options) {
|
|
1084
|
-
preparedCsnToEdm(csn, service, options, messages.makeMessageFunction( csn, options, 'to.edm' ));
|
|
1085
|
-
},
|
|
1086
1074
|
};
|
|
1087
1075
|
|
|
1088
1076
|
|
|
@@ -1266,7 +1254,7 @@ function ensureClientCsn( csn, options, messageFunctions, module ) {
|
|
|
1266
1254
|
function lazyload( moduleName ) {
|
|
1267
1255
|
let module;
|
|
1268
1256
|
return new Proxy(((...args) => {
|
|
1269
|
-
if (!module)
|
|
1257
|
+
if (!module)
|
|
1270
1258
|
module = require(moduleName);
|
|
1271
1259
|
|
|
1272
1260
|
if (module.apply && typeof module.apply === 'function')
|
|
@@ -1274,7 +1262,7 @@ function lazyload( moduleName ) {
|
|
|
1274
1262
|
return module; // for destructured calls
|
|
1275
1263
|
}), {
|
|
1276
1264
|
get(target, name) {
|
|
1277
|
-
if (!module)
|
|
1265
|
+
if (!module)
|
|
1278
1266
|
module = require(moduleName);
|
|
1279
1267
|
|
|
1280
1268
|
return module[name];
|
|
@@ -1293,7 +1281,7 @@ function lazyload( moduleName ) {
|
|
|
1293
1281
|
* @param {object} messageFunctions Message functions
|
|
1294
1282
|
*/
|
|
1295
1283
|
function handleTenantDiscriminator( options, internalOptions, messageFunctions ) {
|
|
1296
|
-
if (options.tenantDiscriminator && options.withHanaAssociations) {
|
|
1284
|
+
if (options.tenantDiscriminator && options.withHanaAssociations && internalOptions.sqlDialect === 'hana') {
|
|
1297
1285
|
messageFunctions.error('api-invalid-combination', null, {
|
|
1298
1286
|
option: 'tenantDiscriminator',
|
|
1299
1287
|
prop: 'withHanaAssociations',
|
package/lib/api/options.js
CHANGED
|
@@ -75,7 +75,7 @@ const privateOptions = [
|
|
|
75
75
|
'internalMsg',
|
|
76
76
|
'disableHanaComments', // in case of issues with hana comment rendering
|
|
77
77
|
'tenantDiscriminator', // not published yet
|
|
78
|
-
'localizedWithoutCoalesce', // deprecated version of 'localizedLanguageFallback', TODO(
|
|
78
|
+
'localizedWithoutCoalesce', // deprecated version of 'localizedLanguageFallback', TODO(v6): Remove option
|
|
79
79
|
];
|
|
80
80
|
|
|
81
81
|
const overallOptions = publicOptionsNewAPI.concat(privateOptions);
|
|
@@ -145,15 +145,7 @@ function reclassifyErrorsForOpenApi( options ) {
|
|
|
145
145
|
// shallow clone, so that we can modify severities without changing the user's.
|
|
146
146
|
options.severities = Object.assign({}, options.severities ?? {});
|
|
147
147
|
|
|
148
|
-
options.severities['odata-spec-violation-array'] = 'Warning';
|
|
149
|
-
options.severities['odata-spec-violation-assoc'] = 'Warning';
|
|
150
|
-
options.severities['odata-spec-violation-namespace'] = 'Warning';
|
|
151
|
-
options.severities['odata-spec-violation-param'] = 'Warning';
|
|
152
|
-
options.severities['odata-spec-violation-returns'] = 'Warning';
|
|
153
|
-
options.severities['odata-spec-violation-type-unknown'] = 'Warning';
|
|
154
148
|
options.severities['odata-spec-violation-no-key'] = 'Warning';
|
|
155
|
-
options.severities['odata-spec-violation-key-type'] = 'Warning';
|
|
156
|
-
options.severities['odata-spec-violation-property-name'] = 'Warning';
|
|
157
149
|
}
|
|
158
150
|
}
|
|
159
151
|
|
|
@@ -172,6 +164,7 @@ module.exports = {
|
|
|
172
164
|
},
|
|
173
165
|
hdi: (options) => {
|
|
174
166
|
const hardOptions = { src: 'hdi', toSql: true, forHana: true };
|
|
167
|
+
// TODO: sqlDialect should be a hard option!
|
|
175
168
|
const defaultOptions = {
|
|
176
169
|
sqlMapping: 'plain', sqlDialect: 'hana', generatedByComment: false, withHanaAssociations: true,
|
|
177
170
|
};
|
|
@@ -179,6 +172,7 @@ module.exports = {
|
|
|
179
172
|
},
|
|
180
173
|
hdbcds: (options) => {
|
|
181
174
|
const hardOptions = { forHana: true };
|
|
175
|
+
// TODO: sqlDialect should be a hard option!
|
|
182
176
|
const defaultOptions = { sqlMapping: 'plain', sqlDialect: 'hana' };
|
|
183
177
|
return translateOptions(options, defaultOptions, hardOptions, { sqlDialect: generateStringValidator([ 'hana' ]) }, undefined, 'to.hdbcds');
|
|
184
178
|
},
|
|
@@ -214,7 +208,7 @@ module.exports = {
|
|
|
214
208
|
return translateOptions(options, defaultOptions, hardOptions, undefined, undefined, 'for.hana');
|
|
215
209
|
},
|
|
216
210
|
effective: (options) => {
|
|
217
|
-
const hardOptions = {};
|
|
211
|
+
const hardOptions = { addCdsPersistenceName: false };
|
|
218
212
|
const defaultOptions = {
|
|
219
213
|
sqlMapping: 'plain', resolveSimpleTypes: true, resolveProjections: true, remapOdataAnnotations: false, keepLocalized: false,
|
|
220
214
|
};
|
|
@@ -224,7 +218,7 @@ module.exports = {
|
|
|
224
218
|
},
|
|
225
219
|
seal: (options) => {
|
|
226
220
|
const hardOptions = {
|
|
227
|
-
sqlMapping: 'plain', resolveSimpleTypes: true, resolveProjections: true, keepLocalized: false,
|
|
221
|
+
sqlMapping: 'plain', resolveSimpleTypes: true, resolveProjections: true, keepLocalized: false, addCdsPersistenceName: true,
|
|
228
222
|
};
|
|
229
223
|
const defaultOptions = { remapOdataAnnotations: true };
|
|
230
224
|
const processed = translateOptions(options, defaultOptions, hardOptions, null, [ 'sql-dialect-and-naming' ], 'for.effective');
|
package/lib/api/trace.js
CHANGED
|
@@ -27,7 +27,6 @@ function traceApi( apiName, options, ...args ) {
|
|
|
27
27
|
const argsStr = args.map(val => JSON.stringify(val)).join(', ');
|
|
28
28
|
const rest = args.length > 0 ? ` | ${ argsStr }` : '';
|
|
29
29
|
// Local require: Only load on-demand, not when tracing is disabled.
|
|
30
|
-
// eslint-disable-next-line global-require
|
|
31
30
|
const { version } = require('../../package.json');
|
|
32
31
|
// eslint-disable-next-line no-console
|
|
33
32
|
console.error( `CDSC_TRACE_API | ${ version } | ${ apiName }(…) | options: ${ optStr }${ rest }`);
|
package/lib/base/builtins.js
CHANGED
package/lib/base/location.js
CHANGED
|
@@ -11,13 +11,16 @@ class Location {
|
|
|
11
11
|
col;
|
|
12
12
|
endLine;
|
|
13
13
|
endCol;
|
|
14
|
-
constructor(file, line, col, endLine, endCol) {
|
|
14
|
+
constructor( file, line, col, endLine, endCol ) {
|
|
15
15
|
this.file = file;
|
|
16
16
|
this.line = line;
|
|
17
17
|
this.col = col;
|
|
18
18
|
this.endLine = endLine;
|
|
19
19
|
this.endCol = endCol;
|
|
20
20
|
}
|
|
21
|
+
toString() {
|
|
22
|
+
return locationString( this );
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
class SemanticLocation {
|
|
@@ -41,7 +41,6 @@ const { createDict } = require('../utils/objectUtils');
|
|
|
41
41
|
* - true = can always be downgraded, we do not really care
|
|
42
42
|
* - [‹module›, …] = can be downgraded in compiler function ‹module›
|
|
43
43
|
* - 'deprecated' = severity can only be changed with deprecated.downgradableErrors
|
|
44
|
-
* - 'v4' = currently like true, but should be 'deprecated' in v5
|
|
45
44
|
*
|
|
46
45
|
* @type {Object<string, MessageConfig>}
|
|
47
46
|
*/
|
|
@@ -61,13 +60,13 @@ const centralMessages = {
|
|
|
61
60
|
'ext-undefined-art': { severity: 'Warning' }, // for annotate statement (for CDL path root)
|
|
62
61
|
'ext-undefined-def': { severity: 'Warning' }, // for annotate statement (for CSN or CDL path cont)
|
|
63
62
|
'ext-undefined-element': { severity: 'Warning' },
|
|
63
|
+
'ext-undefined-key': { severity: 'Warning' },
|
|
64
64
|
'ext-undefined-param': { severity: 'Warning' },
|
|
65
65
|
'anno-unexpected-ellipsis': { severity: 'Error', configurableFor: 'deprecated' },
|
|
66
66
|
'anno-unexpected-localized-skip': { severity: 'Error', configurableFor: true },
|
|
67
|
-
'anno-unexpected-mixin': { severity: 'Warning', errorFor: [ 'v5' ] },
|
|
68
67
|
|
|
69
68
|
'name-invalid-dollar-alias': { severity: 'Error', configurableFor: true },
|
|
70
|
-
'name-deprecated-$self': { severity: '
|
|
69
|
+
'name-deprecated-$self': { severity: 'Error', configurableFor: true },
|
|
71
70
|
|
|
72
71
|
'type-invalid-items': { severity: 'Error' }, // not supported yet
|
|
73
72
|
'assoc-as-type': { severity: 'Error' }, // TODO: allow more, but not all
|
|
@@ -86,7 +85,7 @@ const centralMessages = {
|
|
|
86
85
|
'empty-type': { severity: 'Info' }, // only still an error in old transformers
|
|
87
86
|
|
|
88
87
|
'ref-deprecated-orderby': { severity: 'Error', configurableFor: true },
|
|
89
|
-
'ref-deprecated-self-element': { severity: '
|
|
88
|
+
'ref-deprecated-self-element': { severity: 'Error', configurableFor: true },
|
|
90
89
|
'ref-invalid-type': { severity: 'Error' },
|
|
91
90
|
'ref-unexpected-self': { severity: 'Error' },
|
|
92
91
|
'ref-invalid-include': { severity: 'Error' },
|
|
@@ -152,7 +151,7 @@ const centralMessages = {
|
|
|
152
151
|
// 'syntax-duplicate-annotate' came late with v3 - make it configurable as
|
|
153
152
|
// fallback, but then parse.cdl is not supposed to work correctly (it can
|
|
154
153
|
// then either issue an error or produce a CSN missing some annotations):
|
|
155
|
-
'syntax-duplicate-annotate': { severity: 'Error'
|
|
154
|
+
'syntax-duplicate-annotate': { severity: 'Error' },
|
|
156
155
|
'syntax-duplicate-clause': { severity: 'Error', configurableFor: true },
|
|
157
156
|
'syntax-duplicate-equal-clause': { severity: 'Warning' },
|
|
158
157
|
'syntax-invalid-name': { severity: 'Error', configurableFor: 'deprecated' },
|
|
@@ -162,36 +161,38 @@ const centralMessages = {
|
|
|
162
161
|
'syntax-unknown-escape': { severity: 'Error', configurableFor: true },
|
|
163
162
|
'syntax-unsupported-masked': { severity: 'Error', configurableFor: 'deprecated' },
|
|
164
163
|
'syntax-unexpected-sql-clause': { severity: 'Error' }, // TODO: configurableFor:'tests'?
|
|
165
|
-
'syntax-
|
|
164
|
+
'syntax-invalid-space': { severity: 'Error', configurableFor: 'test' },
|
|
165
|
+
'syntax-expecting-space': { severity: 'Error' },
|
|
166
|
+
'syntax-unexpected-anno': { severity: 'Error' },
|
|
166
167
|
|
|
167
168
|
'type-unsupported-precision-change': { severity: 'Error' },
|
|
168
169
|
'type-unsupported-key-change': { severity: 'Error', configurableFor: true },
|
|
169
|
-
'type-missing-enum-value': { severity: '
|
|
170
|
+
'type-missing-enum-value': { severity: 'Error', configurableFor: 'test' },
|
|
170
171
|
|
|
171
172
|
'def-missing-element': { severity: 'Error' },
|
|
172
|
-
'def-expected-structured': { severity: '
|
|
173
|
+
'def-expected-structured': { severity: 'Error', configurableFor: true },
|
|
173
174
|
'def-unsupported-calc-elem': { severity: 'Error', configurableFor: true },
|
|
174
175
|
|
|
175
176
|
'def-invalid-key-cardinality': { severity: 'Error' },
|
|
176
177
|
// Published! Used in @cap-js-community/odata-v2-adapter; if renamed, add to oldMessageIds
|
|
177
|
-
'odata-spec-violation-array': { severity: 'Warning'
|
|
178
|
+
'odata-spec-violation-array': { severity: 'Warning' }, // more than 30 chars
|
|
178
179
|
// Published! Used in @cap-js-community/odata-v2-adapter; if renamed, add to oldMessageIds
|
|
179
|
-
'odata-spec-violation-assoc': { severity: 'Warning'
|
|
180
|
+
'odata-spec-violation-assoc': { severity: 'Warning' }, // more than 30 chars
|
|
180
181
|
// Published! Used in @cap-js-community/odata-v2-adapter; if renamed, add to oldMessageIds
|
|
181
182
|
'odata-spec-violation-constraints': { severity: 'Info' }, // more than 30 chars
|
|
182
183
|
'odata-spec-violation-id': { severity: 'Error', configurableFor: true },
|
|
183
|
-
'odata-spec-violation-namespace': { severity: 'Warning'
|
|
184
|
+
'odata-spec-violation-namespace': { severity: 'Warning' }, // more than 30 chars
|
|
184
185
|
// Published! Used in @cap-js-community/odata-v2-adapter; if renamed, add to oldMessageIds
|
|
185
|
-
'odata-spec-violation-param': { severity: 'Warning'
|
|
186
|
+
'odata-spec-violation-param': { severity: 'Warning' }, // more than 30 chars
|
|
186
187
|
// Published! Used in @cap-js-community/odata-v2-adapter; if renamed, add to oldMessageIds
|
|
187
|
-
'odata-spec-violation-returns': { severity: 'Warning'
|
|
188
|
+
'odata-spec-violation-returns': { severity: 'Warning' }, // more than 30 chars
|
|
188
189
|
'odata-spec-violation-type': { severity: 'Error', configurableFor: true },
|
|
189
|
-
'odata-spec-violation-type-unknown': { severity: '
|
|
190
|
-
'odata-spec-violation-no-key': { severity: '
|
|
190
|
+
'odata-spec-violation-type-unknown': { severity: 'Error', configurableFor: true },
|
|
191
|
+
'odata-spec-violation-no-key': { severity: 'Error', configurableFor: true },
|
|
191
192
|
'odata-spec-violation-key-array': { severity: 'Error', configurableFor: true }, // more than 30 chars
|
|
192
193
|
'odata-spec-violation-key-null': { severity: 'Error', configurableFor: true }, // more than 30 chars
|
|
193
|
-
'odata-spec-violation-key-type': { severity: 'Warning'
|
|
194
|
-
'odata-spec-violation-property-name': { severity: 'Warning'
|
|
194
|
+
'odata-spec-violation-key-type': { severity: 'Warning' }, // more than 30 chars
|
|
195
|
+
'odata-spec-violation-property-name': { severity: 'Warning' }, // more than 30 chars
|
|
195
196
|
'odata-anno-preproc': { severity: 'Warning' },
|
|
196
197
|
'odata-anno-dict': { severity: 'Warning' },
|
|
197
198
|
'odata-anno-vocref': { severity: 'Warning' },
|
|
@@ -290,7 +291,6 @@ const centralMessageTexts = {
|
|
|
290
291
|
'anno-unstable-array': 'Unstable order of array items due to repeated assignments for $(ANNO)',
|
|
291
292
|
'anno-mismatched-ellipsis': 'An array with $(CODE) can only be used if there is an assignment below with an array value',
|
|
292
293
|
'anno-unexpected-ellipsis': 'No base annotation available to apply $(CODE)',
|
|
293
|
-
'anno-unexpected-mixin': 'Unexpected annotation on mixin definition',
|
|
294
294
|
|
|
295
295
|
'anno-unexpected-localized-skip': {
|
|
296
296
|
std: 'Compiler generated entity $(NAME) must not be annotated with $(ANNO) if $(ART) is not skipped',
|
|
@@ -351,7 +351,7 @@ const centralMessageTexts = {
|
|
|
351
351
|
'syntax-ignoring-decimal': {
|
|
352
352
|
std: 'Ignoring decimal places, because an integer was expected'
|
|
353
353
|
},
|
|
354
|
-
'syntax-
|
|
354
|
+
'syntax-unexpected-anno': {
|
|
355
355
|
std: 'Annotations can\'t be used in a column with $(CODE)',
|
|
356
356
|
doc: 'Doc comments can\'t be used in a column with $(CODE)',
|
|
357
357
|
},
|
|
@@ -435,7 +435,6 @@ const centralMessageTexts = {
|
|
|
435
435
|
service: 'Annotations can\'t be defined inside services',
|
|
436
436
|
context: 'Annotations can\'t be defined inside contexts',
|
|
437
437
|
},
|
|
438
|
-
// 'syntax-unexpected-space' (TODO: also use for :param, #variant, @(…) and @Begin),
|
|
439
438
|
// 'syntax-unexpected-alias' (is 'syntax-unexpected-property' in CSN)
|
|
440
439
|
'syntax-unsupported-param': {
|
|
441
440
|
std: 'Parameter not supported', // unused
|
|
@@ -642,6 +641,8 @@ const centralMessageTexts = {
|
|
|
642
641
|
std: 'Unexpected reference to association $(NAME)', // "std" currently unused
|
|
643
642
|
unmanaged: 'Unexpected reference to an unmanaged association',
|
|
644
643
|
'self-unmanaged': 'Unexpected column reference starting with $(ALIAS) to an unmanaged association',
|
|
644
|
+
'with-filter': 'Unexpected reference to an association with filter',
|
|
645
|
+
'self-with-filter': 'Unexpected column reference starting with $(ALIAS) to an association with filter',
|
|
645
646
|
self: 'A reference to an unmanaged association is only valid when compared via $(CODE)',
|
|
646
647
|
expr: 'Associations can\'t be used as values in expressions',
|
|
647
648
|
'expr-comp': 'Compositions can\'t be used as values in expressions',
|
|
@@ -683,6 +684,10 @@ const centralMessageTexts = {
|
|
|
683
684
|
hdbcds:'Type $(TYPE) is not supported in HDBCDS',
|
|
684
685
|
odata: 'Type $(TYPE) is not supported for OData'
|
|
685
686
|
},
|
|
687
|
+
'ref-unexpected-var': {
|
|
688
|
+
std: 'Variable $(NAME) can\'t be used here',
|
|
689
|
+
'annotation': 'Variable $(NAME) can only be used in annotation values',
|
|
690
|
+
},
|
|
686
691
|
|
|
687
692
|
// TODO: Better text ?
|
|
688
693
|
'rewrite-not-supported': 'The ON-condition is not rewritten here - provide an explicit ON-condition',
|
|
@@ -746,6 +751,7 @@ const centralMessageTexts = {
|
|
|
746
751
|
returns: 'Return value of $(ART) has no element $(NAME)',
|
|
747
752
|
'enum-returns': 'Return value of $(ART) has no enum $(NAME)',
|
|
748
753
|
},
|
|
754
|
+
'ext-undefined-key': 'Foreign key $(NAME) has not been found',
|
|
749
755
|
'ext-undefined-action': {
|
|
750
756
|
std: 'Action $(ART) has not been found',
|
|
751
757
|
action: 'Artifact $(ART) has no action $(NAME)'
|
|
@@ -837,12 +843,6 @@ const centralMessageTexts = {
|
|
|
837
843
|
'include-elements': 'Duplicate element $(NAME) through multiple includes $(SORTED_ARTS)',
|
|
838
844
|
'include-actions': 'Duplicate action or function $(NAME) through multiple includes $(SORTED_ARTS)',
|
|
839
845
|
},
|
|
840
|
-
// TODO: Remove in v5, use duplicate-definition (or another ID?)
|
|
841
|
-
'ref-duplicate-include-member': {
|
|
842
|
-
std: 'Duplicate member $(NAME) through multiple includes $(SORTED_ARTS)',
|
|
843
|
-
elements: 'Duplicate element $(NAME) through multiple includes $(SORTED_ARTS)',
|
|
844
|
-
actions: 'Duplicate action or function $(NAME) through multiple includes $(SORTED_ARTS)',
|
|
845
|
-
},
|
|
846
846
|
'ref-invalid-element': {
|
|
847
847
|
std: 'Invalid element reference',
|
|
848
848
|
$tableAlias: 'Can\'t refer to source elements of table alias $(ID)',
|
|
@@ -859,6 +859,7 @@ const centralMessageTexts = {
|
|
|
859
859
|
'old-not-target': 'Expected element $(NAME) not to be an association, because it overrides the included element from $(ART)',
|
|
860
860
|
},
|
|
861
861
|
|
|
862
|
+
'ref-expecting-$self': 'Use $(NEWCODE) instead of $(CODE) here or remove $(CODE) altogether if possible; the compiler has rewritten it to $(NEWCODE) in CSN',
|
|
862
863
|
'ref-expecting-assoc': 'Expecting path $(ELEMREF) following “EXISTS” predicate to end with association/composition, found $(TYPE)',
|
|
863
864
|
'ref-expecting-const': 'A constant expression or variable is expected here',
|
|
864
865
|
'ref-expecting-foreign-key': 'Expecting foreign key access after managed association $(NAME) in filter expression of $(ID), but found $(ALIAS)',
|
|
@@ -908,9 +909,7 @@ const centralMessageTexts = {
|
|
|
908
909
|
'indirect': 'Type property $(PROP) can only be extended if directly provided at the definition',
|
|
909
910
|
'new-prop': 'Type property $(PROP) can only be extended, not added',
|
|
910
911
|
string: 'Only numerical properties can be extended, but found string for $(PROP)',
|
|
911
|
-
// eslint-disable-next-line max-len
|
|
912
912
|
number: 'Value of type property $(PROP) must be $(NUMBER) or higher, it can\'t be smaller than originally provided',
|
|
913
|
-
// eslint-disable-next-line max-len
|
|
914
913
|
scale: 'With the extension for type property $(OTHERPROP), the value of $(PROP) must be $(NUMBER) or higher',
|
|
915
914
|
},
|
|
916
915
|
'ext-missing-type-property': 'Type extension with property $(PROP) must also have property $(OTHERPROP) because $(ART) has both',
|
|
@@ -1193,7 +1192,8 @@ const centralMessageTexts = {
|
|
|
1193
1192
|
'notaneelement': 'EDM Parameter path $(ELEMREF) can\'t be used in $(ANNO) which is applied to a type entity',
|
|
1194
1193
|
'notrendered': 'EDM Path step $(COUNT) of $(ELEMREF) in $(ANNO) refers to an unrendered property in the OData API',
|
|
1195
1194
|
'magic': 'Unexpected magic variable $(ELEMREF) in $(ANNO)',
|
|
1196
|
-
'
|
|
1195
|
+
'bparam_v2_expl': 'Unexpected explicit binding parameter path $(ELEMREF) for OData $(VERSION) in $(ANNO)',
|
|
1196
|
+
'bparam_v2_impl': 'Unexpected implicit binding parameter path $(ELEMREF) for OData $(VERSION) in $(ANNO)',
|
|
1197
1197
|
},
|
|
1198
1198
|
// -----------------------------------------------------------------------------------
|
|
1199
1199
|
// OData Message section ends here, no messages below this line
|