@sap/cds-compiler 5.5.2 → 5.7.0
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 +43 -1
- package/bin/cdsse.js +4 -0
- package/bin/cdsv2m.js +2 -1
- package/doc/Versioning.md +4 -4
- package/lib/api/options.js +1 -0
- package/lib/base/builtins.js +2 -2
- package/lib/base/dictionaries.js +1 -2
- package/lib/base/keywords.js +3 -1
- package/lib/base/lazyload.js +1 -1
- package/lib/base/message-registry.js +170 -143
- package/lib/base/messages.js +69 -59
- package/lib/base/model.js +3 -3
- package/lib/base/node-helpers.js +17 -16
- package/lib/base/optionProcessorHelper.js +13 -14
- package/lib/base/shuffle.js +4 -1
- package/lib/checks/structuredAnnoExpressions.js +1 -1
- package/lib/compiler/assert-consistency.js +1 -1
- package/lib/compiler/builtins.js +4 -1
- package/lib/compiler/extend.js +20 -5
- package/lib/compiler/resolve.js +45 -9
- package/lib/compiler/shared.js +1 -0
- package/lib/edm/annotations/edmJson.js +3 -3
- package/lib/edm/annotations/genericTranslation.js +5 -1
- package/lib/edm/annotations/vocabularyDefinitions.js +8 -2
- package/lib/edm/edmUtils.js +2 -1
- package/lib/gen/BaseParser.js +142 -103
- package/lib/gen/CdlParser.js +2240 -2201
- package/lib/gen/Dictionary.json +185 -6
- package/lib/json/from-csn.js +2 -0
- package/lib/json/to-csn.js +13 -4
- package/lib/language/docCommentParser.js +11 -5
- package/lib/language/errorStrategy.js +3 -3
- package/lib/language/genericAntlrParser.js +2 -0
- package/lib/model/csnUtils.js +6 -1
- package/lib/optionProcessor.js +5 -1
- package/lib/parsers/AstBuildingParser.js +200 -86
- package/lib/parsers/CdlGrammar.g4 +142 -86
- package/lib/parsers/Lexer.js +5 -3
- package/lib/parsers/index.js +1 -1
- package/lib/render/toCdl.js +6 -5
- package/lib/render/toHdbcds.js +1 -1
- package/lib/render/toSql.js +5 -3
- package/lib/render/utils/common.js +19 -6
- package/lib/render/utils/standardDatabaseFunctions.js +576 -0
- package/lib/transform/addTenantFields.js +2 -1
- package/lib/transform/db/expansion.js +3 -0
- package/lib/transform/db/flattening.js +18 -77
- package/lib/transform/db/groupByOrderBy.js +2 -2
- package/lib/transform/db/rewriteCalculatedElements.js +14 -19
- package/lib/transform/db/temporal.js +2 -1
- package/lib/transform/forOdata.js +1 -1
- package/lib/transform/odata/adaptAnnotationRefs.js +79 -0
- package/lib/transform/odata/createForeignKeys.js +25 -9
- package/lib/transform/odata/flattening.js +11 -1
- package/lib/transform/transformUtils.js +20 -85
- package/package.json +2 -1
- package/bin/cds_update_annotations.js +0 -180
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,48 @@
|
|
|
7
7
|
Note: `beta` fixes, changes and features are usually not listed in this ChangeLog but [here](doc/CHANGELOG_BETA.md).
|
|
8
8
|
The compiler behavior concerning `beta` features can change at any time without notice.
|
|
9
9
|
|
|
10
|
+
## Version 5.7.0 - 2025-01-24
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Analyze enum symbols like `#ENUM_SYMB`; support starts at the following places:
|
|
15
|
+
+ used as sole `default` value or `select` column expression
|
|
16
|
+
if the element/column has a specified enum type, or
|
|
17
|
+
+ used as sole value (in parentheses) of an annotation assignment
|
|
18
|
+
if there is a definition for that annotation having an enum type;
|
|
19
|
+
+ effects in compiler: complain if enum symbol is undefined
|
|
20
|
+
+ effects in the IDE with an upcoming version of cds-lsp when compiler option `newParser` is set:
|
|
21
|
+
offer code completion and hover information,
|
|
22
|
+
+ effects in backends like `to.sql` (and potentially runtimes): enum symbol
|
|
23
|
+
is replaced by corresponding string/integer value when appropriate.
|
|
24
|
+
- for.seal: Process foreign key annotations similar to to.edm(x)
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- CDL parser: it is now recommended to set the option `newParser` to make the compiler
|
|
29
|
+
use a CDL parser with a significantly smaller footprint (among other things).
|
|
30
|
+
New features might only work if this option is set, see above.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- CDL parser: doc comment parser was susceptible to ReDos
|
|
35
|
+
- to.sql/hdi: Paths inside calculated elements that are simple functions were not properly rewritten.
|
|
36
|
+
- for.odata: Re-add foreign keys in property `targetAspect` in the OData CSN.
|
|
37
|
+
- to.edm(x): In annotation translation, by default map `SemanticObjectMappingAbstract` to `SemanticObjectMappingType` to avoid regreessions.
|
|
38
|
+
- to.cdl: Fix quoting of identifier `many` in `Composition of`/`Association to`
|
|
39
|
+
- for.seal: Allow annotation paths to end in `many`-elements, not just scalar, liek we allow in for.odata
|
|
40
|
+
|
|
41
|
+
## Version 5.6.0 - 2024-12-12
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- Allow to refer to draft state element `HasActiveEntity` and `HasDraftEntity` via variable `$draft` in annotation path expressions.
|
|
46
|
+
- for.odata|to.edm(x): Introduce annotating the generated foreign keys
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Update OData vocabularies: 'Common', 'EntityRelationship', 'UI'
|
|
51
|
+
|
|
10
52
|
## Version 5.5.2 - 2024-12-02
|
|
11
53
|
|
|
12
54
|
### Fixed
|
|
@@ -131,7 +173,7 @@ The compiler behavior concerning `beta` features can change at any time without
|
|
|
131
173
|
### Added
|
|
132
174
|
|
|
133
175
|
- cdsc: Option `--stdin` was added to support input via standard input, e.g. `cat file.cds | cdsc --stdin`
|
|
134
|
-
- Allow to refer to draft state element `IsActiveEntity` via
|
|
176
|
+
- Allow to refer to draft state element `IsActiveEntity` via variable `$draft.IsActiveEntity` in annotation path expressions.
|
|
135
177
|
+ for.odata: During draft augmentation `$draft.IsActiveEntity` is rewritten to `$self.IsActiveEntity` for all draft enabled
|
|
136
178
|
entities (root and sub nodes but not for named types or entity parameters).
|
|
137
179
|
+ to.edm(x): (V4 only) Allow to refer to an entity element in a bound action via `$self` and not only via explicit binding parameter
|
package/bin/cdsse.js
CHANGED
|
@@ -158,6 +158,9 @@ function tokensAt( buf, _offset, col, symbol ) {
|
|
|
158
158
|
else if (/^[A-Z_]+$/.test( n )) {
|
|
159
159
|
console.log( n.toLowerCase(), 'keyword' );
|
|
160
160
|
}
|
|
161
|
+
else if (n === 'Boolean') {
|
|
162
|
+
console.log( 'true keyword\nfalse keyword' );
|
|
163
|
+
}
|
|
161
164
|
else if (n !== 'Identifier') {
|
|
162
165
|
console.log( n, 'unknown' );
|
|
163
166
|
}
|
|
@@ -185,6 +188,7 @@ function offset( buf, alsoSuffix ) { // for line and column
|
|
|
185
188
|
return false;
|
|
186
189
|
}
|
|
187
190
|
let cursor = pos + column - 1;
|
|
191
|
+
// eslint-disable-next-line sonarjs/slow-regex
|
|
188
192
|
const prefix = /[a-z_0-9$]*$/i.exec( buf.substring( pos, cursor ) ).index + pos;
|
|
189
193
|
const col = column + prefix - cursor;
|
|
190
194
|
if (alsoSuffix)
|
package/bin/cdsv2m.js
CHANGED
|
@@ -37,7 +37,8 @@ function ria() {
|
|
|
37
37
|
// 'Choose via $(ANNO) one of $(SORTED_ARTS) as redirection target for $(TARGET) in … $(ART) otherwise'
|
|
38
38
|
// NOTE: regex match on message text not for productive code!
|
|
39
39
|
for (const msgObj of msgs) {
|
|
40
|
-
|
|
40
|
+
// eslint-disable-next-line sonarjs/slow-regex
|
|
41
|
+
const matches = msgObj.message.match( /["“][^"”]+["”]/ug );
|
|
41
42
|
matches.slice( 1, -2 ).forEach( (name) => {
|
|
42
43
|
annotates[name.slice( 1, -1 )] = true;
|
|
43
44
|
} );
|
package/doc/Versioning.md
CHANGED
|
@@ -19,9 +19,9 @@ expect from version updates.
|
|
|
19
19
|
## Public API
|
|
20
20
|
|
|
21
21
|
According to [§1] of SemVer, a public API must be made available. Our public
|
|
22
|
-
API is available through `lib/main.js` which can be used
|
|
23
|
-
`const compiler = require('@sap/cds-compiler');` in
|
|
24
|
-
ES modules,
|
|
22
|
+
API is available through `lib/main.js` which can be used via
|
|
23
|
+
`const compiler = require('@sap/cds-compiler');` in Node.js or, if you use
|
|
24
|
+
ES modules, via `import compiler from "@sap/cds-compiler";`
|
|
25
25
|
|
|
26
26
|
Furthermore, any exported property in `lib/main.js` whose name starts with `$`
|
|
27
27
|
is _not_ part of the public API.
|
|
@@ -48,7 +48,7 @@ only later upgraded to errors.
|
|
|
48
48
|
“patch versions” can be applied.
|
|
49
49
|
|
|
50
50
|
We may introduce new compiler-checks that might make your compilation fail if
|
|
51
|
-
we detect invalid CDS code.
|
|
51
|
+
we detect invalid CDS code. OData vocabularies may be updated.
|
|
52
52
|
|
|
53
53
|
## Beta Flags
|
|
54
54
|
|
package/lib/api/options.js
CHANGED
package/lib/base/builtins.js
CHANGED
|
@@ -29,7 +29,7 @@ const propagationRules = {
|
|
|
29
29
|
'@sql.append': 'never',
|
|
30
30
|
'@sql.prepend': 'never',
|
|
31
31
|
'@sql.replace': 'never',
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Checks whether the given absolute path is inside a reserved namespace.
|
|
@@ -105,4 +105,4 @@ module.exports = {
|
|
|
105
105
|
isBuiltinType,
|
|
106
106
|
isMagicVariable,
|
|
107
107
|
isAnnotationExpression,
|
|
108
|
-
}
|
|
108
|
+
};
|
package/lib/base/dictionaries.js
CHANGED
package/lib/base/keywords.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/* eslint @stylistic/js/no-multi-spaces: 0 */
|
|
4
|
+
|
|
3
5
|
const { functionsWithoutParentheses, cdlKeywords } = require('../parsers/identifiers');
|
|
4
6
|
|
|
5
7
|
module.exports = {
|
|
@@ -713,7 +715,7 @@ module.exports = {
|
|
|
713
715
|
'SYSTIME', 'SYSTIMESTAMP', 'SYSUUID',
|
|
714
716
|
'TOP', 'TRAILING', 'UNION',
|
|
715
717
|
'USING', 'VALUES', 'WHEN',
|
|
716
|
-
'WHERE', 'WHILE', 'WITH'
|
|
718
|
+
'WHERE', 'WHILE', 'WITH',
|
|
717
719
|
],
|
|
718
720
|
// Postgres keywords, used for smart quoting in to-sql.plain.postgres
|
|
719
721
|
// Taken from https://www.postgresql.org/docs/current/sql-keywords-appendix.html
|