@sap/cds-compiler 2.11.2 → 2.13.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 +175 -2
- package/bin/.eslintrc.json +1 -2
- package/bin/cds_update_identifiers.js +10 -8
- package/bin/cdsc.js +23 -17
- package/bin/cdsse.js +2 -2
- package/bin/cdsv2m.js +3 -2
- package/doc/CHANGELOG_ARCHIVE.md +1 -1
- package/doc/CHANGELOG_BETA.md +25 -6
- package/doc/CHANGELOG_DEPRECATED.md +22 -6
- package/doc/NameResolution.md +21 -16
- package/lib/api/main.js +32 -79
- package/lib/api/options.js +3 -2
- package/lib/api/validate.js +2 -1
- package/lib/backends.js +16 -26
- package/lib/base/dictionaries.js +0 -8
- package/lib/base/error.js +26 -0
- package/lib/base/keywords.js +10 -19
- package/lib/base/location.js +9 -4
- package/lib/base/message-registry.js +75 -9
- package/lib/base/messages.js +31 -35
- package/lib/base/model.js +2 -62
- package/lib/base/optionProcessorHelper.js +246 -183
- package/lib/checks/.eslintrc.json +2 -0
- package/lib/checks/actionsFunctions.js +2 -1
- package/lib/checks/annotationsOData.js +1 -1
- package/lib/checks/cdsPersistence.js +2 -1
- package/lib/checks/emptyOrOnlyVirtual.js +2 -2
- package/lib/checks/enricher.js +17 -1
- package/lib/checks/foreignKeys.js +4 -4
- package/lib/checks/invalidTarget.js +3 -1
- package/lib/checks/managedInType.js +4 -4
- package/lib/checks/managedWithoutKeys.js +3 -1
- package/lib/checks/queryNoDbArtifacts.js +1 -3
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +94 -0
- package/lib/checks/types.js +1 -1
- package/lib/checks/unknownMagic.js +1 -1
- package/lib/checks/validator.js +12 -7
- package/lib/compiler/assert-consistency.js +12 -8
- package/lib/compiler/base.js +0 -1
- package/lib/compiler/builtins.js +42 -21
- package/lib/compiler/checks.js +46 -12
- package/lib/compiler/cycle-detector.js +1 -1
- package/lib/compiler/define.js +1103 -0
- package/lib/compiler/extend.js +983 -0
- package/lib/compiler/finalize-parse-cdl.js +231 -0
- package/lib/compiler/index.js +46 -39
- package/lib/compiler/kick-start.js +190 -0
- package/lib/compiler/moduleLayers.js +4 -4
- package/lib/compiler/populate.js +1226 -0
- package/lib/compiler/propagator.js +113 -47
- package/lib/compiler/resolve.js +1433 -0
- package/lib/compiler/shared.js +100 -65
- package/lib/compiler/tweak-assocs.js +529 -0
- package/lib/compiler/utils.js +215 -33
- package/lib/edm/.eslintrc.json +5 -0
- package/lib/edm/annotations/genericTranslation.js +38 -25
- package/lib/edm/annotations/preprocessAnnotations.js +3 -3
- package/lib/edm/csn2edm.js +10 -9
- package/lib/edm/edm.js +19 -20
- package/lib/edm/edmPreprocessor.js +166 -95
- package/lib/edm/edmUtils.js +127 -34
- package/lib/gen/Dictionary.json +92 -43
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +11 -1
- package/lib/gen/language.tokens +86 -82
- package/lib/gen/languageLexer.interp +18 -1
- package/lib/gen/languageLexer.js +925 -847
- package/lib/gen/languageLexer.tokens +78 -74
- package/lib/gen/languageParser.js +5434 -4298
- package/lib/json/from-csn.js +59 -17
- package/lib/json/to-csn.js +189 -71
- package/lib/language/antlrParser.js +3 -3
- package/lib/language/docCommentParser.js +3 -3
- package/lib/language/errorStrategy.js +26 -8
- package/lib/language/genericAntlrParser.js +144 -53
- package/lib/language/language.g4 +424 -200
- package/lib/language/multiLineStringParser.js +536 -0
- package/lib/main.d.ts +550 -61
- package/lib/main.js +38 -11
- package/lib/model/api.js +3 -1
- package/lib/model/csnRefs.js +322 -198
- package/lib/model/csnUtils.js +226 -370
- package/lib/model/enrichCsn.js +124 -69
- package/lib/model/revealInternalProperties.js +29 -7
- package/lib/model/sortViews.js +10 -2
- package/lib/modelCompare/compare.js +17 -12
- package/lib/optionProcessor.js +8 -3
- package/lib/render/.eslintrc.json +1 -2
- package/lib/render/DuplicateChecker.js +1 -1
- package/lib/render/manageConstraints.js +36 -33
- package/lib/render/toCdl.js +174 -275
- package/lib/render/toHdbcds.js +203 -122
- package/lib/render/toRename.js +7 -10
- package/lib/render/toSql.js +161 -82
- package/lib/render/utils/common.js +22 -8
- package/lib/render/utils/sql.js +10 -7
- package/lib/render/utils/stringEscapes.js +111 -0
- package/lib/sql-identifier.js +1 -1
- package/lib/transform/.eslintrc.json +5 -0
- package/lib/transform/braceExpression.js +4 -2
- package/lib/transform/db/.eslintrc.json +2 -0
- package/lib/transform/db/applyTransformations.js +212 -0
- package/lib/transform/db/assertUnique.js +1 -1
- package/lib/transform/db/associations.js +187 -0
- package/lib/transform/db/cdsPersistence.js +150 -0
- package/lib/transform/db/constraints.js +61 -56
- package/lib/transform/db/expansion.js +50 -29
- package/lib/transform/db/flattening.js +556 -106
- package/lib/transform/db/groupByOrderBy.js +3 -1
- package/lib/transform/db/temporal.js +236 -0
- package/lib/transform/db/transformExists.js +103 -28
- package/lib/transform/db/views.js +92 -44
- package/lib/transform/draft/.eslintrc.json +38 -0
- package/lib/transform/{db/draft.js → draft/db.js} +9 -7
- package/lib/transform/draft/odata.js +227 -0
- package/lib/transform/forHanaNew.js +98 -783
- package/lib/transform/forOdataNew.js +22 -175
- package/lib/transform/localized.js +36 -32
- package/lib/transform/odata/generateForeignKeyElements.js +3 -3
- package/lib/transform/odata/referenceFlattener.js +95 -89
- package/lib/transform/odata/structureFlattener.js +1 -1
- package/lib/transform/odata/toFinalBaseType.js +86 -12
- package/lib/transform/odata/typesExposure.js +5 -5
- package/lib/transform/odata/utils.js +2 -2
- package/lib/transform/transformUtilsNew.js +47 -33
- package/lib/transform/translateAssocsToJoins.js +13 -30
- package/lib/transform/universalCsn/.eslintrc.json +36 -0
- package/lib/transform/universalCsn/coreComputed.js +170 -0
- package/lib/transform/universalCsn/universalCsnEnricher.js +715 -0
- package/lib/transform/universalCsn/utils.js +63 -0
- package/lib/utils/file.js +8 -3
- package/lib/utils/objectUtils.js +30 -0
- package/lib/utils/timetrace.js +8 -2
- package/package.json +1 -1
- package/share/messages/README.md +26 -0
- package/lib/compiler/definer.js +0 -2349
- package/lib/compiler/resolver.js +0 -2922
- package/lib/transform/db/helpers.js +0 -58
- package/lib/transform/universalCsnEnricher.js +0 -67
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* If a mixin association is published, return the mixin association.
|
|
5
|
-
*
|
|
6
|
-
* @param {CSN.Query} query Query of the artifact to check
|
|
7
|
-
* @param {object} association Association (Element) published by the view
|
|
8
|
-
* @param {string} associationName
|
|
9
|
-
* @returns {object} The mixin association
|
|
10
|
-
*/
|
|
11
|
-
function getMixinAssocOfQueryIfPublished(query, association, associationName) {
|
|
12
|
-
if (query && query.SELECT && query.SELECT.mixin) {
|
|
13
|
-
const aliasedColumnsMap = Object.create(null);
|
|
14
|
-
if (query.SELECT.columns) {
|
|
15
|
-
for (const column of query.SELECT.columns) {
|
|
16
|
-
if (column.as && column.ref && column.ref.length === 1)
|
|
17
|
-
aliasedColumnsMap[column.as] = column;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
for (const elem of Object.keys(query.SELECT.mixin)) {
|
|
22
|
-
const mixinElement = query.SELECT.mixin[elem];
|
|
23
|
-
let originalName = associationName;
|
|
24
|
-
if (aliasedColumnsMap[associationName])
|
|
25
|
-
originalName = aliasedColumnsMap[associationName].ref[0];
|
|
26
|
-
|
|
27
|
-
if (elem === originalName)
|
|
28
|
-
return { mixinElement, mixinName: originalName };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return {};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Check wether the given artifact uses the given mixin association.
|
|
36
|
-
*
|
|
37
|
-
* @param {CSN.Query} query Query of the artifact to check
|
|
38
|
-
* @param {object} association Mixin association (Element) to check for
|
|
39
|
-
* @param {string} associationName
|
|
40
|
-
* @returns {boolean} True if used
|
|
41
|
-
*/
|
|
42
|
-
function usesMixinAssociation(query, association, associationName) {
|
|
43
|
-
if (query && query.SELECT && query.SELECT.columns) {
|
|
44
|
-
for (const column of query.SELECT.columns) {
|
|
45
|
-
if (typeof column === 'object' && column.ref && column.ref.length > 1 && (column.ref[0] === associationName || column.ref[0].id === associationName)) {
|
|
46
|
-
// FIXME: This is not necessarily correct: the assoc name needs not be the first component, as e.g. $projection.assoc
|
|
47
|
-
// would be also valid. Check other paths like $self.assoc ....
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = {
|
|
56
|
-
usesMixinAssociation,
|
|
57
|
-
getMixinAssocOfQueryIfPublished,
|
|
58
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { forEachDefinition } = require('../base/model');
|
|
4
|
-
const {
|
|
5
|
-
applyTransformations,
|
|
6
|
-
cloneCsn,
|
|
7
|
-
getUtils,
|
|
8
|
-
isBuiltinType,
|
|
9
|
-
} = require('../model/csnUtils');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Loop through a universal CSN and enrich it with the properties
|
|
13
|
-
* from the source definition - modifies the input model in-place
|
|
14
|
-
*
|
|
15
|
-
* @param {CSN.Model} csn
|
|
16
|
-
* @param {CSN.Options} options
|
|
17
|
-
*/
|
|
18
|
-
module.exports = function(csn, options) {
|
|
19
|
-
let { getOrigin, getFinalType, getFinalTypeDef } = getUtils(csn);
|
|
20
|
-
// User-defined structured types do not have the elements propagated any longer
|
|
21
|
-
// if there is no association among the elements. For that reason,
|
|
22
|
-
// as a first step propagate the elements of these
|
|
23
|
-
forEachDefinition(csn, (def) => {
|
|
24
|
-
if (def.kind === 'type' && def.type && !def.elements) {
|
|
25
|
-
const finalType = getFinalType(def.type);
|
|
26
|
-
if (isBuiltinType(finalType)) return;
|
|
27
|
-
const finalTypeDef = getFinalTypeDef(def.type);
|
|
28
|
-
if (finalTypeDef.elements)
|
|
29
|
-
def.elements = cloneCsn(finalTypeDef.elements, options);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// as a second step, loop through all the $origin properties in the model
|
|
34
|
-
// and propagate the properties from the origin definition
|
|
35
|
-
applyTransformations(csn, {
|
|
36
|
-
'$origin': (node, _$orign, $originValue, _path, parent, propName) => {
|
|
37
|
-
if (!node.kind) { // we do not want to replace whole definitions
|
|
38
|
-
if (Array.isArray($originValue))
|
|
39
|
-
propagatePropsFromOrigin(node, propName, parent);
|
|
40
|
-
else if ($originValue.$origin && Array.isArray($originValue.$origin)) {
|
|
41
|
-
// cover the case of query entity elements where we have own and ihnerited attributes/annotations
|
|
42
|
-
propagatePropsFromOrigin($originValue, propName, parent);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}, undefined, undefined, options);
|
|
48
|
-
|
|
49
|
-
function propagatePropsFromOrigin(member, memberName, construct) {
|
|
50
|
-
// TODO: shall the $origin be kept as part of the element?
|
|
51
|
-
const origin = getOrigin(member);
|
|
52
|
-
if (origin.kind) return;
|
|
53
|
-
if (member.elements && origin.type) {
|
|
54
|
-
delete member.$origin;
|
|
55
|
-
member.type = origin.type;
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
let newMember = cloneCsn(origin, options);
|
|
59
|
-
// keep targets and keys of assoc, if it was redirected
|
|
60
|
-
if (origin.type === 'cds.Association') {
|
|
61
|
-
newMember.target = member.target || newMember.target;
|
|
62
|
-
newMember.keys = member.keys || newMember.keys;
|
|
63
|
-
}
|
|
64
|
-
// TODO: check if this works fine for items/returns/actions
|
|
65
|
-
construct[memberName] = newMember;
|
|
66
|
-
}
|
|
67
|
-
}
|