@sap/cds-compiler 4.1.2 → 4.2.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 +101 -1
- package/bin/cdsc.js +6 -3
- package/doc/CHANGELOG_BETA.md +5 -0
- package/doc/CHANGELOG_DEPRECATED.md +15 -0
- package/lib/api/main.js +2 -2
- package/lib/api/options.js +2 -2
- package/lib/api/validate.js +24 -24
- package/lib/base/message-registry.js +41 -6
- package/lib/base/messages.js +7 -0
- package/lib/base/model.js +37 -8
- package/lib/checks/elements.js +11 -10
- package/lib/checks/manyNavigations.js +33 -0
- package/lib/checks/onConditions.js +5 -2
- package/lib/checks/queryNoDbArtifacts.js +2 -3
- package/lib/checks/selectItems.js +4 -55
- package/lib/checks/utils.js +3 -2
- package/lib/checks/validator.js +3 -1
- package/lib/compiler/.eslintrc.json +2 -1
- package/lib/compiler/assert-consistency.js +27 -24
- package/lib/compiler/base.js +6 -2
- package/lib/compiler/builtins.js +34 -34
- package/lib/compiler/checks.js +179 -208
- package/lib/compiler/classes.js +2 -2
- package/lib/compiler/cycle-detector.js +6 -6
- package/lib/compiler/define.js +66 -45
- package/lib/compiler/extend.js +81 -72
- package/lib/compiler/finalize-parse-cdl.js +26 -26
- package/lib/compiler/generate.js +61 -45
- package/lib/compiler/index.js +47 -49
- package/lib/compiler/kick-start.js +8 -7
- package/lib/compiler/moduleLayers.js +1 -1
- package/lib/compiler/populate.js +42 -35
- package/lib/compiler/propagator.js +6 -6
- package/lib/compiler/resolve.js +170 -126
- package/lib/compiler/shared.js +122 -45
- package/lib/compiler/tweak-assocs.js +93 -40
- package/lib/compiler/utils.js +15 -12
- package/lib/edm/.eslintrc.json +40 -1
- package/lib/edm/annotations/genericTranslation.js +721 -707
- package/lib/edm/annotations/preprocessAnnotations.js +88 -77
- package/lib/edm/csn2edm.js +389 -378
- package/lib/edm/edm.js +678 -772
- package/lib/edm/edmAnnoPreprocessor.js +132 -146
- package/lib/edm/edmInboundChecks.js +29 -27
- package/lib/edm/edmPreprocessor.js +686 -646
- package/lib/edm/edmUtils.js +277 -296
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +1 -1
- package/lib/gen/languageParser.js +1253 -1276
- package/lib/json/from-csn.js +34 -4
- package/lib/json/to-csn.js +4 -4
- package/lib/language/language.g4 +2 -5
- package/lib/main.d.ts +61 -1
- package/lib/model/csnUtils.js +31 -2
- package/lib/model/revealInternalProperties.js +1 -1
- package/lib/modelCompare/compare.js +37 -2
- package/lib/modelCompare/utils/filter.js +1 -1
- package/lib/optionProcessor.js +15 -3
- package/lib/render/toCdl.js +30 -4
- package/lib/render/toSql.js +5 -9
- package/lib/render/utils/common.js +8 -6
- package/lib/transform/db/applyTransformations.js +1 -1
- package/lib/transform/db/cdsPersistence.js +1 -1
- package/lib/transform/db/constraints.js +47 -17
- package/lib/transform/db/expansion.js +121 -47
- package/lib/transform/db/flattening.js +75 -7
- package/lib/transform/forOdata.js +4 -1
- package/lib/transform/forRelationalDB.js +80 -62
- package/lib/transform/localized.js +91 -54
- package/lib/transform/transformUtils.js +9 -10
- package/lib/utils/file.js +7 -7
- package/lib/utils/moduleResolve.js +210 -121
- package/lib/utils/objectUtils.js +1 -1
- package/package.json +5 -5
package/lib/compiler/utils.js
CHANGED
|
@@ -14,7 +14,7 @@ const { dictAdd, pushToDict, dictFirst } = require('../base/dictionaries');
|
|
|
14
14
|
const { kindProperties } = require('./base');
|
|
15
15
|
const { XsnName, XsnArtifact, CsnLocation } = require('./classes');
|
|
16
16
|
|
|
17
|
-
const $inferred = Symbol.for('cds.$inferred');
|
|
17
|
+
const $inferred = Symbol.for( 'cds.$inferred' );
|
|
18
18
|
|
|
19
19
|
// for links, i.e., properties starting with an underscore '_':
|
|
20
20
|
|
|
@@ -109,7 +109,7 @@ function linkToOrigin( origin, name, parent, prop, location, silentDep ) {
|
|
|
109
109
|
return elem;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function proxyCopyMembers( art, dictProp, originDict, location, kind ) {
|
|
112
|
+
function proxyCopyMembers( art, dictProp, originDict, location, kind, tmpDeprecated ) {
|
|
113
113
|
art[dictProp] = Object.create( null );
|
|
114
114
|
// TODO: set $inferred ? for dict?
|
|
115
115
|
for (const name in originDict) {
|
|
@@ -118,8 +118,11 @@ function proxyCopyMembers( art, dictProp, originDict, location, kind ) {
|
|
|
118
118
|
const member = linkToOrigin( origin, name, art, dictProp,
|
|
119
119
|
location || origin.location, true );
|
|
120
120
|
member.$inferred = 'expanded';
|
|
121
|
+
// TODO throughout the compiler: do not set art.‹prop›.$inferred if art.$inferred
|
|
121
122
|
if (kind)
|
|
122
123
|
member.kind = kind;
|
|
124
|
+
else if (origin.key && !tmpDeprecated) // TODO(v5/v6): remove tmpDeprecated
|
|
125
|
+
member.key = Object.assign( { $inferred: 'expanded' }, origin.key );
|
|
123
126
|
if (kind && origin.masked) // TODO: remove!
|
|
124
127
|
member.masked = Object.assign( { $inferred: 'nav' }, origin.masked );
|
|
125
128
|
}
|
|
@@ -139,7 +142,7 @@ function setMemberParent( elem, name, parent, prop ) {
|
|
|
139
142
|
// TODO: consider nested ARRAY OF and RETURNS, COMPOSITION OF type
|
|
140
143
|
const p = parent.items || parent.targetAspect || parent;
|
|
141
144
|
if (p[prop] === undefined)
|
|
142
|
-
p[prop] = Object.create(null);
|
|
145
|
+
p[prop] = Object.create( null );
|
|
143
146
|
dictAdd( p[prop], name, elem );
|
|
144
147
|
}
|
|
145
148
|
if (parent._outer && parent._outer.items) // TODO: remove for items, too
|
|
@@ -161,7 +164,7 @@ function setMemberParent( elem, name, parent, prop ) {
|
|
|
161
164
|
|
|
162
165
|
else
|
|
163
166
|
delete elem.name[kind];
|
|
164
|
-
});
|
|
167
|
+
} );
|
|
165
168
|
// try { throw new CompilerAssertion('Foo') } catch (e) { elem.name.stack = e; };
|
|
166
169
|
}
|
|
167
170
|
|
|
@@ -207,7 +210,7 @@ function storeExtension( elem, name, prop, parent, block ) {
|
|
|
207
210
|
// return;
|
|
208
211
|
// }
|
|
209
212
|
if (!parent[kind][prop])
|
|
210
|
-
parent[kind][prop] = Object.create(null);
|
|
213
|
+
parent[kind][prop] = Object.create( null );
|
|
211
214
|
pushToDict( parent[kind][prop], name, elem );
|
|
212
215
|
}
|
|
213
216
|
|
|
@@ -233,7 +236,7 @@ function withAssociation( ref, test = testFunctionPlaceholder, alsoTestLast = fa
|
|
|
233
236
|
* @param {XSN.Path} path
|
|
234
237
|
*/
|
|
235
238
|
function pathName( path ) {
|
|
236
|
-
return (path && !path.broken) ? path.map( id => id.id ).join('.') : '';
|
|
239
|
+
return (path && !path.broken) ? path.map( id => id.id ).join( '.' ) : '';
|
|
237
240
|
}
|
|
238
241
|
|
|
239
242
|
/**
|
|
@@ -245,7 +248,7 @@ function pathName( path ) {
|
|
|
245
248
|
* @returns {XSN.Path}
|
|
246
249
|
*/
|
|
247
250
|
function splitIntoPath( location, name ) {
|
|
248
|
-
return name.split('.').map( id => ({ id, location }) );
|
|
251
|
+
return name.split( '.' ).map( id => ({ id, location }) );
|
|
249
252
|
}
|
|
250
253
|
|
|
251
254
|
/**
|
|
@@ -259,7 +262,7 @@ function augmentPath( location, ...args ) {
|
|
|
259
262
|
function copyExpr( expr, location, skipUnderscored, rewritePath ) {
|
|
260
263
|
if (!expr || typeof expr !== 'object')
|
|
261
264
|
return expr;
|
|
262
|
-
else if (Array.isArray(expr))
|
|
265
|
+
else if (Array.isArray( expr ))
|
|
263
266
|
return expr.map( e => copyExpr( e, location, skipUnderscored, rewritePath ) );
|
|
264
267
|
|
|
265
268
|
const proto = Object.getPrototypeOf( expr );
|
|
@@ -296,7 +299,7 @@ function testExpr( expr, pathTest, queryTest, user ) {
|
|
|
296
299
|
if (!expr || typeof expr === 'string') { // parse error or keywords in {xpr:...}
|
|
297
300
|
return false;
|
|
298
301
|
}
|
|
299
|
-
else if (Array.isArray(expr)) {
|
|
302
|
+
else if (Array.isArray( expr )) {
|
|
300
303
|
return expr.some( e => testExpr( e, pathTest, queryTest, user ) );
|
|
301
304
|
}
|
|
302
305
|
else if (expr.path) {
|
|
@@ -307,10 +310,10 @@ function testExpr( expr, pathTest, queryTest, user ) {
|
|
|
307
310
|
}
|
|
308
311
|
else if (expr.op && expr.args) {
|
|
309
312
|
// unnamed args => array
|
|
310
|
-
if (Array.isArray(expr.args))
|
|
313
|
+
if (Array.isArray( expr.args ))
|
|
311
314
|
return expr.args.some( e => testExpr( e, pathTest, queryTest, user ) );
|
|
312
315
|
// named args => dictionary
|
|
313
|
-
for (const namedArg of Object.keys(expr.args)) {
|
|
316
|
+
for (const namedArg of Object.keys( expr.args )) {
|
|
314
317
|
if (testExpr( expr.args[namedArg], pathTest, queryTest, user ))
|
|
315
318
|
return true;
|
|
316
319
|
}
|
|
@@ -403,7 +406,7 @@ function forEachUserDict( art, prop, callback ) {
|
|
|
403
406
|
if (obj.$inferred)
|
|
404
407
|
continue;
|
|
405
408
|
callback( obj, name, prop );
|
|
406
|
-
if (Array.isArray(obj.$duplicates)) // redefinitions
|
|
409
|
+
if (Array.isArray( obj.$duplicates )) // redefinitions
|
|
407
410
|
obj.$duplicates.forEach( o => callback( o, name, prop ) );
|
|
408
411
|
}
|
|
409
412
|
}
|
package/lib/edm/.eslintrc.json
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
+
"root": true,
|
|
3
|
+
//"plugins": ["sonarjs", "jsdoc"],
|
|
4
|
+
//"extends": ["plugin:jsdoc/recommended", "../../../.eslintrc-ydkjsi.json", "plugin:sonarjs/recommended"],
|
|
5
|
+
"plugins": ["sonarjs"],
|
|
6
|
+
"extends": ["../../.eslintrc-ydkjsi.json", "plugin:sonarjs/recommended"],
|
|
2
7
|
"rules": {
|
|
3
|
-
"
|
|
8
|
+
"prefer-const": "error",
|
|
9
|
+
"quotes": ["error", "single", "avoid-escape"],
|
|
10
|
+
"prefer-template": "error",
|
|
11
|
+
"no-trailing-spaces": "error",
|
|
12
|
+
"template-curly-spacing":["error", "never"],
|
|
13
|
+
"complexity": ["warn", 50],
|
|
14
|
+
"max-len": "off",
|
|
15
|
+
// there seem to be false positives
|
|
16
|
+
"jsdoc/require-returns-check": "off",
|
|
17
|
+
// Don't enforce stupid descriptions
|
|
18
|
+
"jsdoc/require-param-description": "off",
|
|
19
|
+
"jsdoc/require-returns-description": "off",
|
|
20
|
+
// Sometimes if-else's are more specific
|
|
21
|
+
"sonarjs/prefer-single-boolean-return": "off",
|
|
22
|
+
// Very whiny and nitpicky
|
|
23
|
+
"sonarjs/cognitive-complexity": "off",
|
|
24
|
+
"sonarjs/no-duplicate-string": "off",
|
|
25
|
+
// Does not recognize TS types
|
|
26
|
+
"jsdoc/no-undefined-types": "off",
|
|
27
|
+
"jsdoc/tag-lines": "off",
|
|
28
|
+
"no-nested-ternary": "off",
|
|
29
|
+
"sonarjs/no-nested-template-literals": "off"
|
|
30
|
+
},
|
|
31
|
+
"parserOptions": {
|
|
32
|
+
"ecmaVersion": 2022,
|
|
33
|
+
"sourceType": "script"
|
|
34
|
+
},
|
|
35
|
+
"env": {
|
|
36
|
+
"es2022": true,
|
|
37
|
+
"node": true
|
|
38
|
+
},
|
|
39
|
+
"settings": {
|
|
40
|
+
"jsdoc": {
|
|
41
|
+
"mode": "typescript"
|
|
42
|
+
}
|
|
4
43
|
}
|
|
5
44
|
}
|