@sap/cds-compiler 2.12.0 → 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 +110 -15
- package/bin/cdsc.js +13 -13
- package/bin/cdsse.js +2 -2
- package/doc/CHANGELOG_BETA.md +13 -6
- package/doc/CHANGELOG_DEPRECATED.md +22 -6
- package/doc/NameResolution.md +21 -16
- package/lib/api/main.js +28 -63
- package/lib/api/options.js +3 -3
- package/lib/api/validate.js +0 -5
- package/lib/backends.js +15 -23
- package/lib/base/dictionaries.js +0 -8
- package/lib/base/error.js +26 -0
- package/lib/base/keywords.js +7 -17
- package/lib/base/location.js +9 -4
- package/lib/base/message-registry.js +25 -4
- package/lib/base/messages.js +16 -26
- package/lib/base/model.js +2 -63
- package/lib/base/optionProcessorHelper.js +158 -123
- package/lib/checks/annotationsOData.js +1 -1
- package/lib/checks/cdsPersistence.js +2 -1
- package/lib/checks/enricher.js +17 -1
- package/lib/checks/invalidTarget.js +3 -1
- package/lib/checks/managedWithoutKeys.js +3 -1
- package/lib/checks/selectItems.js +4 -4
- package/lib/checks/sql-snippets.js +27 -26
- package/lib/checks/types.js +1 -1
- package/lib/checks/validator.js +4 -7
- package/lib/compiler/assert-consistency.js +5 -3
- package/lib/compiler/builtins.js +8 -6
- package/lib/compiler/checks.js +14 -3
- 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 +32 -13
- 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 +111 -46
- package/lib/compiler/resolve.js +1433 -0
- package/lib/compiler/shared.js +64 -37
- package/lib/compiler/tweak-assocs.js +529 -0
- package/lib/compiler/utils.js +197 -33
- package/lib/edm/.eslintrc.json +5 -0
- package/lib/edm/annotations/genericTranslation.js +5 -9
- package/lib/edm/annotations/preprocessAnnotations.js +2 -2
- package/lib/edm/csn2edm.js +9 -8
- package/lib/edm/edm.js +11 -12
- package/lib/edm/edmPreprocessor.js +137 -73
- package/lib/edm/edmUtils.js +116 -22
- package/lib/gen/Dictionary.json +10 -3
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +9 -1
- package/lib/gen/language.tokens +86 -83
- package/lib/gen/languageLexer.interp +10 -1
- package/lib/gen/languageLexer.js +860 -833
- package/lib/gen/languageLexer.tokens +78 -75
- package/lib/gen/languageParser.js +5282 -4265
- package/lib/json/from-csn.js +12 -1
- package/lib/json/to-csn.js +126 -66
- package/lib/language/docCommentParser.js +2 -2
- package/lib/language/genericAntlrParser.js +76 -3
- package/lib/language/language.g4 +297 -130
- package/lib/language/multiLineStringParser.js +5 -5
- package/lib/main.d.ts +468 -59
- package/lib/main.js +35 -9
- package/lib/model/api.js +3 -1
- package/lib/model/csnRefs.js +225 -156
- package/lib/model/csnUtils.js +192 -223
- package/lib/model/enrichCsn.js +70 -29
- package/lib/model/revealInternalProperties.js +27 -6
- package/lib/model/sortViews.js +2 -1
- package/lib/modelCompare/compare.js +17 -12
- package/lib/optionProcessor.js +5 -4
- package/lib/render/manageConstraints.js +35 -32
- package/lib/render/toCdl.js +73 -288
- package/lib/render/toHdbcds.js +25 -23
- package/lib/render/toSql.js +98 -41
- package/lib/render/utils/common.js +5 -10
- package/lib/render/utils/sql.js +4 -3
- 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/db/.eslintrc.json +2 -0
- package/lib/transform/db/applyTransformations.js +35 -12
- package/lib/transform/db/assertUnique.js +1 -1
- package/lib/transform/db/associations.js +103 -305
- package/lib/transform/db/cdsPersistence.js +2 -2
- package/lib/transform/db/constraints.js +55 -52
- package/lib/transform/db/expansion.js +46 -24
- package/lib/transform/db/flattening.js +553 -102
- package/lib/transform/db/groupByOrderBy.js +3 -1
- package/lib/transform/db/transformExists.js +59 -6
- package/lib/transform/db/views.js +5 -4
- package/lib/transform/draft/.eslintrc.json +38 -0
- package/lib/transform/{db/draft.js → draft/db.js} +6 -5
- package/lib/transform/draft/odata.js +227 -0
- package/lib/transform/forHanaNew.js +67 -183
- package/lib/transform/forOdataNew.js +17 -171
- package/lib/transform/localized.js +34 -19
- package/lib/transform/odata/generateForeignKeyElements.js +1 -1
- 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 +36 -22
- package/lib/transform/translateAssocsToJoins.js +2 -19
- 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/objectUtils.js +30 -0
- package/package.json +1 -1
- package/share/messages/README.md +26 -0
- package/lib/compiler/definer.js +0 -2361
- package/lib/compiler/resolver.js +0 -3079
- package/lib/transform/universalCsnEnricher.js +0 -237
|
@@ -298,6 +298,7 @@ function assertConsistency( model, stage ) {
|
|
|
298
298
|
},
|
|
299
299
|
expand: { kind: [ 'element' ], inherits: 'columns' },
|
|
300
300
|
inline: { kind: [ 'element' ], inherits: 'columns' },
|
|
301
|
+
$noOrigin: { kind: [ 'element' ], test: TODO },
|
|
301
302
|
excludingDict: {
|
|
302
303
|
kind: 'element',
|
|
303
304
|
test: isDictionary( definition ), // definition since redef
|
|
@@ -325,8 +326,8 @@ function assertConsistency( model, stage ) {
|
|
|
325
326
|
kind: true,
|
|
326
327
|
requires: [ 'location' ],
|
|
327
328
|
optional: [
|
|
328
|
-
'path', 'elements', '_outer',
|
|
329
|
-
'scope', '_artifact', '$inferred', '$expand',
|
|
329
|
+
'path', 'elements', '_outer', '_parent', '_main', '_block', 'kind',
|
|
330
|
+
'scope', '_artifact', '$inferred', '$expand', '$tableAliases', '_$next',
|
|
330
331
|
'_effectiveType', // by propagation
|
|
331
332
|
],
|
|
332
333
|
},
|
|
@@ -641,7 +642,8 @@ function assertConsistency( model, stage ) {
|
|
|
641
642
|
* and `localized` namespaces.
|
|
642
643
|
*/
|
|
643
644
|
function builtin( node, parent, prop, spec, name ) {
|
|
644
|
-
|
|
645
|
+
const type = typeof node;
|
|
646
|
+
if (type !== 'string' && type !== 'boolean')
|
|
645
647
|
throw new Error(`Property '${ prop }' must be a boolean or string but was '${ typeof node }'${ at( [ node, parent ], prop, name ) }` );
|
|
646
648
|
|
|
647
649
|
if (parent.kind !== 'namespace')
|
package/lib/compiler/builtins.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// The builtin artifacts of CDS
|
|
2
2
|
|
|
3
|
+
// TODO: split this file
|
|
4
|
+
// - in base/: common definitions
|
|
5
|
+
// - in compiler/: XSN-specific
|
|
6
|
+
// - in ?: CSN-specific
|
|
7
|
+
|
|
3
8
|
'use strict';
|
|
4
9
|
|
|
5
10
|
const { builtinLocation } = require('../base/location');
|
|
6
|
-
const { setProp } = require('./utils');
|
|
11
|
+
const { setLink: setProp } = require('./utils');
|
|
7
12
|
|
|
8
13
|
const core = {
|
|
9
14
|
String: { parameters: [ 'length' ], category: 'string' },
|
|
@@ -56,7 +61,6 @@ const coreHana = {
|
|
|
56
61
|
* (do not add more - make it part of the SQL renderer to remove parentheses for
|
|
57
62
|
* other funny SQL functions like CURRENT_UTCTIMESTAMP).
|
|
58
63
|
*/
|
|
59
|
-
|
|
60
64
|
const functionsWithoutParens = [
|
|
61
65
|
'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP',
|
|
62
66
|
'CURRENT_USER', 'SESSION_USER', 'SYSTEM_USER',
|
|
@@ -176,7 +180,8 @@ function isRelationTypeName(typeName) {
|
|
|
176
180
|
function isInReservedNamespace(absolute) {
|
|
177
181
|
return absolute.startsWith( 'cds.') &&
|
|
178
182
|
!absolute.match(/^cds\.foundation(\.|$)/) &&
|
|
179
|
-
!absolute.match(/^cds\.outbox(\.|$)/)
|
|
183
|
+
!absolute.match(/^cds\.outbox(\.|$)/) && // Requested by Node runtime
|
|
184
|
+
!absolute.match(/^cds\.xt(\.|$)/); // Requested by Mtx
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
/**
|
|
@@ -214,9 +219,6 @@ function initBuiltins( model ) {
|
|
|
214
219
|
model.$builtins.hana = hana;
|
|
215
220
|
cds._subArtifacts.hana = hana;
|
|
216
221
|
env( coreHana, 'cds.hana.', hana );
|
|
217
|
-
// namespace:"localized" stores localized convenience views ---
|
|
218
|
-
const localized = createNamespace( 'localized', true );
|
|
219
|
-
model.definitions.localized = localized;
|
|
220
222
|
model.$internal = { $frontend: '$internal' };
|
|
221
223
|
return;
|
|
222
224
|
|
package/lib/compiler/checks.js
CHANGED
|
@@ -459,6 +459,10 @@ function check( model ) { // = XSN
|
|
|
459
459
|
* Check whether the argument count of the given path expression matches its artifact.
|
|
460
460
|
* If there is a mismatch, an error is issued.
|
|
461
461
|
*
|
|
462
|
+
* TODO: remove this function - it also checks for parameter in type
|
|
463
|
+
* references. We could have a warning, see also configurable errors
|
|
464
|
+
* 'args-no-params', 'args-undefined-param'.
|
|
465
|
+
*
|
|
462
466
|
* @param {object} pathStep The expression to check
|
|
463
467
|
*/
|
|
464
468
|
function checkPathForMissingArguments(pathStep) {
|
|
@@ -494,8 +498,15 @@ function check( model ) { // = XSN
|
|
|
494
498
|
|
|
495
499
|
const missingArgs = [];
|
|
496
500
|
for (const fAName in formalArgs) {
|
|
497
|
-
if (!actualArgs[fAName]
|
|
498
|
-
|
|
501
|
+
if (!actualArgs[fAName]) {
|
|
502
|
+
// Note: _effectiveType points to cds.String for `type T : DefaultString`.
|
|
503
|
+
// And `default` may appear at any `type` in the hierarchy.
|
|
504
|
+
let fArg = formalArgs[fAName];
|
|
505
|
+
while (fArg.type && !fArg.default)
|
|
506
|
+
fArg = fArg.type._artifact;
|
|
507
|
+
if (!fArg.default)
|
|
508
|
+
missingArgs.push(fAName);
|
|
509
|
+
}
|
|
499
510
|
}
|
|
500
511
|
|
|
501
512
|
if (missingArgs.length) {
|
|
@@ -635,7 +646,7 @@ function check( model ) { // = XSN
|
|
|
635
646
|
return checkTreeLikeExpression(xpr, allowAssocTail);
|
|
636
647
|
}
|
|
637
648
|
/**
|
|
638
|
-
* Check
|
|
649
|
+
* Check whether the supplied argument is a virtual element
|
|
639
650
|
*
|
|
640
651
|
* TO CLARIFY: do we want the "no virtual element" check for virtual elements/columns, too?
|
|
641
652
|
*
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
'use strict';
|
|
18
18
|
|
|
19
|
-
const { setProp } = require('
|
|
19
|
+
const { setLink: setProp } = require('./utils'); // check enum/non-enum
|
|
20
20
|
|
|
21
21
|
// Detect cyclic dependencies between all nodes reachable from `definitions`.
|
|
22
22
|
// If such a dependency is found, call `reportCycle` with arguments `dep.art`
|