@sap/cds-compiler 3.4.4 → 3.5.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 +58 -0
- package/README.md +1 -0
- package/bin/cds_update_identifiers.js +5 -5
- package/bin/cdsc.js +12 -12
- package/doc/CHANGELOG_ARCHIVE.md +1 -1
- package/doc/CHANGELOG_BETA.md +9 -1
- package/doc/CHANGELOG_DEPRECATED.md +2 -0
- package/lib/api/main.js +58 -59
- package/lib/api/options.js +4 -2
- package/lib/api/validate.js +2 -2
- package/lib/base/cleanSymbols.js +2 -3
- package/lib/base/dictionaries.js +6 -6
- package/lib/base/error.js +2 -2
- package/lib/base/keywords.js +6 -6
- package/lib/base/location.js +11 -12
- package/lib/base/message-registry.js +124 -28
- package/lib/base/messages.js +247 -179
- package/lib/base/model.js +14 -11
- package/lib/base/node-helpers.js +9 -10
- package/lib/base/optionProcessorHelper.js +138 -129
- package/lib/checks/actionsFunctions.js +5 -5
- package/lib/checks/annotationsOData.js +4 -4
- package/lib/checks/arrayOfs.js +1 -1
- package/lib/checks/cdsPersistence.js +1 -1
- package/lib/checks/checkForTypes.js +3 -3
- package/lib/checks/defaultValues.js +3 -3
- package/lib/checks/elements.js +7 -7
- package/lib/checks/emptyOrOnlyVirtual.js +2 -2
- package/lib/checks/foreignKeys.js +1 -1
- package/lib/checks/invalidTarget.js +4 -4
- package/lib/checks/managedInType.js +1 -1
- package/lib/checks/managedWithoutKeys.js +1 -1
- package/lib/checks/nonexpandableStructured.js +5 -3
- package/lib/checks/nullableKeys.js +1 -1
- package/lib/checks/onConditions.js +5 -6
- package/lib/checks/parameters.js +1 -1
- package/lib/checks/queryNoDbArtifacts.js +2 -2
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +4 -4
- package/lib/checks/types.js +7 -7
- package/lib/checks/utils.js +4 -4
- package/lib/checks/validator.js +16 -13
- package/lib/compiler/.eslintrc.json +1 -1
- package/lib/compiler/assert-consistency.js +0 -1
- package/lib/compiler/builtins.js +1 -1
- package/lib/compiler/checks.js +73 -15
- package/lib/compiler/define.js +3 -7
- package/lib/compiler/extend.js +212 -32
- package/lib/compiler/finalize-parse-cdl.js +7 -2
- package/lib/compiler/index.js +17 -14
- package/lib/compiler/populate.js +2 -5
- package/lib/compiler/propagator.js +2 -0
- package/lib/compiler/shared.js +23 -12
- package/lib/compiler/tweak-assocs.js +5 -6
- package/lib/compiler/utils.js +6 -0
- package/lib/edm/annotations/genericTranslation.js +553 -319
- package/lib/edm/annotations/preprocessAnnotations.js +39 -35
- package/lib/edm/csn2edm.js +88 -75
- package/lib/edm/edm.js +17 -3
- package/lib/edm/edmAnnoPreprocessor.js +5 -5
- package/lib/edm/edmPreprocessor.js +106 -76
- package/lib/edm/edmUtils.js +41 -2
- package/lib/gen/Dictionary.json +34 -0
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +66 -63
- package/lib/gen/language.tokens +81 -81
- package/lib/gen/languageLexer.interp +4 -10
- package/lib/gen/languageLexer.js +854 -869
- package/lib/gen/languageLexer.tokens +79 -81
- package/lib/gen/languageParser.js +14360 -14146
- package/lib/inspect/inspectModelStatistics.js +2 -2
- package/lib/inspect/inspectPropagation.js +6 -6
- package/lib/inspect/inspectUtils.js +2 -2
- package/lib/json/from-csn.js +82 -40
- package/lib/json/to-csn.js +82 -157
- package/lib/language/.eslintrc.json +1 -4
- package/lib/language/genericAntlrParser.js +59 -38
- package/lib/language/language.g4 +1508 -1490
- package/lib/language/multiLineStringParser.js +1 -1
- package/lib/main.js +3 -3
- package/lib/model/csnUtils.js +130 -122
- package/lib/model/revealInternalProperties.js +1 -1
- package/lib/model/sortViews.js +4 -6
- package/lib/modelCompare/utils/filter.js +4 -3
- package/lib/optionProcessor.js +5 -0
- package/lib/render/DuplicateChecker.js +1 -1
- package/lib/render/manageConstraints.js +12 -12
- package/lib/render/toCdl.js +225 -159
- package/lib/render/toHdbcds.js +63 -63
- package/lib/render/toRename.js +5 -5
- package/lib/render/toSql.js +55 -65
- package/lib/render/utils/common.js +20 -37
- package/lib/render/utils/delta.js +3 -3
- package/lib/render/utils/sql.js +22 -6
- package/lib/render/utils/stringEscapes.js +3 -3
- package/lib/transform/db/applyTransformations.js +3 -3
- package/lib/transform/db/assertUnique.js +13 -12
- package/lib/transform/db/associations.js +5 -5
- package/lib/transform/db/cdsPersistence.js +10 -8
- package/lib/transform/db/constraints.js +14 -14
- package/lib/transform/db/expansion.js +20 -22
- package/lib/transform/db/flattening.js +24 -42
- package/lib/transform/db/groupByOrderBy.js +3 -3
- package/lib/transform/db/temporal.js +6 -6
- package/lib/transform/db/transformExists.js +23 -23
- package/lib/transform/db/views.js +16 -16
- package/lib/transform/draft/db.js +10 -10
- package/lib/transform/draft/odata.js +2 -2
- package/lib/transform/forOdataNew.js +12 -40
- package/lib/transform/forRelationalDB.js +17 -7
- package/lib/transform/localized.js +2 -2
- package/lib/transform/odata/toFinalBaseType.js +41 -27
- package/lib/transform/odata/typesExposure.js +106 -62
- package/lib/transform/parseExpr.js +209 -106
- package/lib/transform/transformUtilsNew.js +2 -2
- package/lib/transform/translateAssocsToJoins.js +24 -19
- package/lib/transform/universalCsn/coreComputed.js +10 -10
- package/lib/transform/universalCsn/universalCsnEnricher.js +26 -26
- package/lib/transform/universalCsn/utils.js +3 -3
- package/lib/utils/file.js +5 -5
- package/lib/utils/moduleResolve.js +13 -13
- package/lib/utils/objectUtils.js +6 -6
- package/lib/utils/term.js +5 -2
- package/lib/utils/timetrace.js +51 -24
- package/package.json +5 -7
- package/share/messages/check-proper-type-of.md +1 -1
- package/share/messages/message-explanations.json +1 -1
- package/share/messages/redirected-to-complex.md +4 -4
- package/share/messages/{syntax-expecting-integer.md → syntax-expecting-unsigned-int.md} +7 -4
package/lib/base/model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { forEach } = require(
|
|
3
|
+
const { forEach } = require('../utils/objectUtils');
|
|
4
4
|
|
|
5
5
|
const queryOps = {
|
|
6
6
|
query: 'select', // TODO: rename to SELECT
|
|
@@ -9,7 +9,7 @@ const queryOps = {
|
|
|
9
9
|
except: 'union',
|
|
10
10
|
minus: 'union',
|
|
11
11
|
subquery: 'union', // for (subquery) with ORDER BY or LIMIT/OFFSET
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Object of all available beta flags that will be enabled/disabled by `--beta-mode`
|
|
@@ -21,6 +21,7 @@ const queryOps = {
|
|
|
21
21
|
*/
|
|
22
22
|
const availableBetaFlags = {
|
|
23
23
|
// enabled by --beta-mode
|
|
24
|
+
calculatedElements: true,
|
|
24
25
|
toRename: true,
|
|
25
26
|
assocsWithParams: true,
|
|
26
27
|
hanaAssocRealCardinality: true,
|
|
@@ -29,10 +30,11 @@ const availableBetaFlags = {
|
|
|
29
30
|
enableUniversalCsn: true,
|
|
30
31
|
postgres: true,
|
|
31
32
|
aspectWithoutElements: true,
|
|
32
|
-
// disabled by --beta-mode
|
|
33
|
-
nestedServices: false,
|
|
34
33
|
odataOpenType: true,
|
|
34
|
+
odataTerms: true,
|
|
35
35
|
optionalActionFunctionParameters: true,
|
|
36
|
+
// disabled by --beta-mode
|
|
37
|
+
nestedServices: false,
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -107,7 +109,7 @@ function checkRemovedDeprecatedFlags( options, { error } ) {
|
|
|
107
109
|
forEach(options.deprecated, (key, val) => {
|
|
108
110
|
if (val && oldDeprecatedFlags_v2.includes(key)) {
|
|
109
111
|
error('api-invalid-deprecated', null, { name: key },
|
|
110
|
-
|
|
112
|
+
'Deprecated flag $(NAME) has been removed in CDS compiler v3');
|
|
111
113
|
}
|
|
112
114
|
});
|
|
113
115
|
}
|
|
@@ -134,7 +136,6 @@ function forEachMember( construct, callback, target ) {
|
|
|
134
136
|
forEachGeneric( construct, 'params', callback );
|
|
135
137
|
if (construct.returns)
|
|
136
138
|
callback( construct.returns, '', 'params' );
|
|
137
|
-
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
// Apply function `callback` to all objects in dictionary `dict`, including all
|
|
@@ -142,12 +143,12 @@ function forEachMember( construct, callback, target ) {
|
|
|
142
143
|
// the following arguments: the object, the name, and -if it is a duplicate-
|
|
143
144
|
// the array index and the array containing all duplicates.
|
|
144
145
|
function forEachGeneric( obj, prop, callback ) {
|
|
145
|
-
|
|
146
|
-
for (
|
|
146
|
+
const dict = obj[prop];
|
|
147
|
+
for (const name in dict) {
|
|
147
148
|
obj = dict[name];
|
|
148
149
|
callback( obj, name, prop );
|
|
149
150
|
if (Array.isArray(obj.$duplicates)) // redefinitions
|
|
150
|
-
obj.$duplicates.forEach( o => callback( o, name, prop ) )
|
|
151
|
+
obj.$duplicates.forEach( o => callback( o, name, prop ) );
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
|
|
@@ -162,8 +163,10 @@ const forEachInOrder = forEachGeneric;
|
|
|
162
163
|
* @param {string} prop
|
|
163
164
|
* @param {any} value
|
|
164
165
|
*/
|
|
165
|
-
function setProp
|
|
166
|
-
|
|
166
|
+
function setProp( obj, prop, value ) {
|
|
167
|
+
const descriptor = {
|
|
168
|
+
value, configurable: true, writable: true, enumerable: false,
|
|
169
|
+
};
|
|
167
170
|
Object.defineProperty( obj, prop, descriptor );
|
|
168
171
|
return value;
|
|
169
172
|
}
|
package/lib/base/node-helpers.js
CHANGED
|
@@ -12,18 +12,17 @@
|
|
|
12
12
|
// This function only works as intended if no promise in `promises` fulfill
|
|
13
13
|
// with a value which is an instance of Error.
|
|
14
14
|
//
|
|
15
|
-
function promiseAllDoNotRejectImmediately
|
|
15
|
+
function promiseAllDoNotRejectImmediately( promises ) {
|
|
16
16
|
return Promise.all( promises.map( p => p.catch(e => e) ) )
|
|
17
|
-
.then(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
17
|
+
.then( values => (values.some(e => e instanceof Error)
|
|
18
|
+
? Promise.reject( new PromiseAllError(
|
|
19
|
+
values, 'At least one promise has been rejected'
|
|
20
|
+
) )
|
|
21
|
+
: values));
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
class PromiseAllError extends Error {
|
|
26
|
-
constructor(subs
|
|
25
|
+
constructor(subs, ...args) {
|
|
27
26
|
super(...args);
|
|
28
27
|
this.valuesOrErrors = subs;
|
|
29
28
|
}
|
|
@@ -31,5 +30,5 @@ class PromiseAllError extends Error {
|
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
module.exports = {
|
|
34
|
-
promiseAllDoNotRejectImmediately
|
|
35
|
-
}
|
|
33
|
+
promiseAllDoNotRejectImmediately,
|
|
34
|
+
};
|