@sap/cds-compiler 3.9.4 → 4.0.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 +107 -4
- package/README.md +0 -1
- package/bin/cdsc.js +11 -23
- package/bin/cdsse.js +3 -3
- package/doc/API.md +5 -0
- package/doc/CHANGELOG_ARCHIVE.md +1 -1
- package/doc/CHANGELOG_BETA.md +17 -1
- package/doc/CHANGELOG_DEPRECATED.md +28 -0
- package/lib/api/.eslintrc.json +1 -1
- package/lib/api/main.js +55 -9
- package/lib/api/options.js +2 -0
- package/lib/base/error.js +2 -0
- package/lib/base/message-registry.js +143 -64
- package/lib/base/messages.js +213 -107
- package/lib/base/model.js +11 -11
- package/lib/checks/.eslintrc.json +1 -1
- package/lib/checks/annotationsOData.js +2 -2
- package/lib/checks/elements.js +1 -1
- package/lib/checks/enricher.js +26 -3
- package/lib/checks/onConditions.js +67 -12
- package/lib/checks/queryNoDbArtifacts.js +106 -105
- package/lib/checks/sql-snippets.js +2 -0
- package/lib/checks/types.js +12 -6
- package/lib/checks/validator.js +2 -2
- package/lib/compiler/assert-consistency.js +10 -8
- package/lib/compiler/builtins.js +8 -2
- package/lib/compiler/checks.js +52 -35
- package/lib/compiler/define.js +31 -26
- package/lib/compiler/extend.js +120 -65
- package/lib/compiler/finalize-parse-cdl.js +12 -43
- package/lib/compiler/generate.js +16 -5
- package/lib/compiler/index.js +8 -5
- package/lib/compiler/kick-start.js +4 -3
- package/lib/compiler/populate.js +96 -95
- package/lib/compiler/propagator.js +7 -8
- package/lib/compiler/resolve.js +377 -103
- package/lib/compiler/shared.js +794 -517
- package/lib/compiler/tweak-assocs.js +8 -6
- package/lib/compiler/utils.js +44 -0
- package/lib/edm/annotations/genericTranslation.js +41 -5
- package/lib/edm/csn2edm.js +34 -32
- package/lib/edm/edm.js +34 -31
- package/lib/edm/edmAnnoPreprocessor.js +0 -23
- package/lib/edm/edmInboundChecks.js +7 -2
- package/lib/edm/edmPreprocessor.js +25 -18
- package/lib/edm/edmUtils.js +8 -4
- package/lib/gen/Dictionary.json +18 -0
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +4 -2
- package/lib/gen/languageParser.js +5006 -4582
- package/lib/json/from-csn.js +157 -112
- package/lib/json/to-csn.js +60 -89
- package/lib/language/antlrParser.js +17 -13
- package/lib/language/docCommentParser.js +11 -1
- package/lib/language/genericAntlrParser.js +13 -10
- package/lib/language/language.g4 +168 -97
- package/lib/main.d.ts +128 -36
- package/lib/main.js +1 -1
- package/lib/model/csnRefs.js +24 -5
- package/lib/model/csnUtils.js +9 -8
- package/lib/model/revealInternalProperties.js +7 -12
- package/lib/model/sortViews.js +4 -2
- package/lib/modelCompare/compare.js +1 -1
- package/lib/modelCompare/utils/filter.js +40 -2
- package/lib/optionProcessor.js +0 -3
- package/lib/render/toCdl.js +247 -214
- package/lib/render/toHdbcds.js +197 -181
- package/lib/render/toSql.js +325 -289
- package/lib/render/utils/common.js +42 -4
- package/lib/render/utils/delta.js +1 -1
- package/lib/render/utils/sql.js +3 -3
- package/lib/transform/braceExpression.js +2 -2
- package/lib/transform/db/.eslintrc.json +1 -1
- package/lib/transform/db/applyTransformations.js +3 -3
- package/lib/transform/db/associations.js +24 -12
- package/lib/transform/db/expansion.js +17 -18
- package/lib/transform/db/flattening.js +17 -21
- package/lib/transform/db/rewriteCalculatedElements.js +171 -64
- package/lib/transform/db/views.js +3 -4
- package/lib/transform/draft/db.js +21 -12
- package/lib/transform/draft/odata.js +4 -0
- package/lib/transform/forOdataNew.js +62 -47
- package/lib/transform/forRelationalDB.js +12 -7
- package/lib/transform/localized.js +4 -2
- package/lib/transform/odata/toFinalBaseType.js +5 -5
- package/lib/transform/odata/typesExposure.js +3 -3
- package/lib/transform/parseExpr.js +3 -0
- package/lib/transform/transformUtilsNew.js +43 -23
- package/lib/transform/translateAssocsToJoins.js +7 -6
- package/lib/transform/universalCsn/.eslintrc.json +1 -1
- package/lib/transform/universalCsn/coreComputed.js +7 -5
- package/lib/transform/universalCsn/universalCsnEnricher.js +12 -12
- package/package.json +2 -2
- package/share/messages/{duplicate-autoexposed.md → def-duplicate-autoexposed.md} +5 -1
- package/share/messages/message-explanations.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { setProp
|
|
3
|
+
const { setProp } = require('../../base/model');
|
|
4
4
|
const shuffleGen = require('../../base/shuffle');
|
|
5
5
|
const { setAnnotationIfNotDefined, makeClientCompatible } = require('./utils');
|
|
6
6
|
const {
|
|
@@ -23,7 +23,6 @@ const { setCoreComputedOnViewsAndCalculatedElements } = require('./coreComputed'
|
|
|
23
23
|
* @param {CSN.Options} options
|
|
24
24
|
*/
|
|
25
25
|
module.exports = (csn, options) => {
|
|
26
|
-
const propagateToReturns = isBetaEnabled( options, 'v4preview' );
|
|
27
26
|
const csnUtils = getUtils(csn, 'init-all');
|
|
28
27
|
const {
|
|
29
28
|
initDefinition, getOrigin, getQueryPrimarySource, artifactRef, getColumn,
|
|
@@ -116,7 +115,7 @@ module.exports = (csn, options) => {
|
|
|
116
115
|
// The $origin properties need to be removed separately
|
|
117
116
|
// as the values are used in csnRef::getOrigin that is used during
|
|
118
117
|
// the propagation above.
|
|
119
|
-
// Currently testMode-only for comparison against client CSN.
|
|
118
|
+
// Currently, testMode-only for comparison against client CSN.
|
|
120
119
|
if (options.testMode)
|
|
121
120
|
makeClientCompatible(csn);
|
|
122
121
|
|
|
@@ -174,10 +173,7 @@ module.exports = (csn, options) => {
|
|
|
174
173
|
|
|
175
174
|
setTargetAspectIfRequired(parent);
|
|
176
175
|
},
|
|
177
|
-
type: ( parent, prop, type
|
|
178
|
-
// annos are not propagated to `returns` (<=v3) and `items`
|
|
179
|
-
if (parentProp === 'returns' && !propagateToReturns)
|
|
180
|
-
return;
|
|
176
|
+
type: ( parent, prop, type ) => {
|
|
181
177
|
const annotationsForBuiltinType = extensions[type];
|
|
182
178
|
Object.assign( parent, annotationsForBuiltinType );
|
|
183
179
|
},
|
|
@@ -288,13 +284,17 @@ module.exports = (csn, options) => {
|
|
|
288
284
|
},
|
|
289
285
|
params: (parent, prop, params) => {
|
|
290
286
|
forEachValue(params, (param) => {
|
|
287
|
+
const propagateToParams = typeof param.type === 'string' ? csn.definitions[param.type]?.kind !== 'entity' : true;
|
|
291
288
|
propagateMemberPropsFromOrigin(param, {
|
|
292
|
-
items: true, elements: true, enum: true, virtual: true,
|
|
289
|
+
'@': !propagateToParams, items: true, elements: true, enum: true, virtual: true,
|
|
293
290
|
});
|
|
294
291
|
});
|
|
295
292
|
},
|
|
296
293
|
returns: (parent, prop, returns) => {
|
|
297
|
-
|
|
294
|
+
// Only propagate to `returns` (return parameter) if return type is not an entity.
|
|
295
|
+
// If returns.type is an array, it is an element ref. If it's not found, it's likely builtin.
|
|
296
|
+
const propagateToParams = typeof returns.type === 'string' ? csn.definitions[returns.type]?.kind !== 'entity' : true;
|
|
297
|
+
propagateMemberPropsFromOrigin(returns, { '@': !propagateToParams, items: true, elements: true });
|
|
298
298
|
if (returns.target)
|
|
299
299
|
calculateForeignKeys(returns);
|
|
300
300
|
},
|
|
@@ -368,7 +368,7 @@ module.exports = (csn, options) => {
|
|
|
368
368
|
* @todo check if still necessary
|
|
369
369
|
*/
|
|
370
370
|
function skipMemberPropagation( origin ) {
|
|
371
|
-
|
|
371
|
+
// For empty members (`{}`), the origin was set in a previous call to `getOrigin(definition)`.
|
|
372
372
|
return !origin;
|
|
373
373
|
}
|
|
374
374
|
}
|
|
@@ -519,7 +519,7 @@ module.exports = (csn, options) => {
|
|
|
519
519
|
forEachValue(elements, (element) => {
|
|
520
520
|
if (element.target) {
|
|
521
521
|
const column = getColumn(element);
|
|
522
|
-
if (column) {
|
|
522
|
+
if (column?.ref) {
|
|
523
523
|
const mixin = query.SELECT.mixin[implicitAs(column.ref)] || {};
|
|
524
524
|
copyProperties(mixin, element, getMemberPropagationRuleFor);
|
|
525
525
|
}
|
|
@@ -552,7 +552,7 @@ module.exports = (csn, options) => {
|
|
|
552
552
|
if (!target.kind)
|
|
553
553
|
return;
|
|
554
554
|
const primarySourceRef = getQueryPrimarySource(target.query || target.projection);
|
|
555
|
-
const artRef = primarySourceRef ? artifactRef(primarySourceRef) : source;
|
|
555
|
+
const artRef = primarySourceRef ? artifactRef.from(primarySourceRef) : source;
|
|
556
556
|
if (!artRef.target)
|
|
557
557
|
target[prop] = source[prop];
|
|
558
558
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap/cds-compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "CDS (Core Data Services) compiler and backends",
|
|
5
5
|
"homepage": "https://cap.cloud.sap/",
|
|
6
6
|
"author": "SAP SE (https://www.sap.com)",
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
"LICENSE"
|
|
60
60
|
],
|
|
61
61
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
62
|
+
"node": ">=16"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# duplicate-autoexposed
|
|
1
|
+
# def-duplicate-autoexposed
|
|
2
2
|
|
|
3
3
|
Two or more entities with the same name can’t be auto-exposed in the same
|
|
4
4
|
service.
|
|
@@ -76,3 +76,7 @@ auto-exposing entities. The reason is that the resulting auto-exposed names
|
|
|
76
76
|
could become _long_ names that don’t seem natural nor intuitive. We chose to
|
|
77
77
|
expose the entity name because that’s what most developers want to do when
|
|
78
78
|
they manually expose entities.
|
|
79
|
+
|
|
80
|
+
## Other Notes
|
|
81
|
+
|
|
82
|
+
This message was called `duplicate-autoexposed` in cds-compiler v3 and earlier.
|