@sap/cds-compiler 4.9.6 → 5.1.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 +92 -0
- package/bin/cds_remove_invalid_whitespace.js +2 -1
- package/bin/cdsc.js +49 -19
- package/bin/cdshi.js +3 -1
- package/doc/CHANGELOG_BETA.md +7 -0
- package/lib/api/main.js +16 -19
- package/lib/api/options.js +5 -14
- package/lib/api/trace.js +0 -1
- package/lib/base/builtins.js +1 -0
- package/lib/base/location.js +4 -1
- package/lib/base/message-registry.js +43 -29
- package/lib/base/messages.js +23 -26
- package/lib/base/meta.js +10 -0
- package/lib/base/model.js +0 -2
- package/lib/base/node-helpers.js +0 -1
- package/lib/base/optionProcessorHelper.js +11 -0
- package/lib/checks/dbFeatureFlags.js +5 -0
- package/lib/checks/enricher.js +1 -5
- package/lib/checks/structuredAnnoExpressions.js +30 -0
- package/lib/checks/validator.js +8 -0
- package/lib/compiler/assert-consistency.js +5 -1
- package/lib/compiler/base.js +1 -1
- package/lib/compiler/builtins.js +18 -2
- package/lib/compiler/checks.js +2 -5
- package/lib/compiler/define.js +8 -8
- package/lib/compiler/extend.js +108 -37
- package/lib/compiler/generate.js +1 -1
- package/lib/compiler/index.js +27 -10
- package/lib/compiler/lsp-api.js +501 -2
- package/lib/compiler/populate.js +60 -13
- package/lib/compiler/propagator.js +10 -8
- package/lib/compiler/resolve.js +117 -94
- package/lib/compiler/shared.js +114 -32
- package/lib/compiler/tweak-assocs.js +31 -21
- package/lib/compiler/utils.js +2 -1
- package/lib/compiler/xsn-model.js +4 -0
- package/lib/edm/annotations/genericTranslation.js +69 -35
- package/lib/edm/csn2edm.js +16 -4
- package/lib/edm/edm.js +10 -3
- package/lib/edm/edmAnnoPreprocessor.js +1 -2
- package/lib/edm/edmPreprocessor.js +8 -10
- package/lib/gen/Dictionary.json +66 -2
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +2 -1
- package/lib/gen/languageParser.js +4995 -4817
- package/lib/json/csnVersion.js +1 -1
- package/lib/json/from-csn.js +4 -7
- package/lib/json/to-csn.js +25 -12
- package/lib/language/antlrParser.js +2 -2
- package/lib/language/errorStrategy.js +0 -1
- package/lib/language/genericAntlrParser.js +35 -12
- package/lib/language/multiLineStringParser.js +3 -2
- package/lib/language/textUtils.js +1 -0
- package/lib/main.d.ts +28 -9
- package/lib/main.js +9 -9
- package/lib/model/cloneCsn.js +1 -0
- package/lib/model/csnRefs.js +22 -5
- package/lib/model/csnUtils.js +0 -14
- package/lib/model/revealInternalProperties.js +1 -2
- package/lib/modelCompare/compare.js +13 -11
- package/lib/optionProcessor.js +30 -9
- package/lib/render/manageConstraints.js +1 -1
- package/lib/render/toCdl.js +44 -14
- package/lib/render/toHdbcds.js +1 -2
- package/lib/render/toSql.js +45 -8
- package/lib/render/utils/common.js +12 -9
- package/lib/render/utils/stringEscapes.js +1 -0
- package/lib/transform/db/applyTransformations.js +13 -8
- package/lib/transform/db/associations.js +62 -54
- package/lib/transform/db/backlinks.js +20 -5
- package/lib/transform/db/expansion.js +1 -6
- package/lib/transform/db/flattening.js +86 -109
- package/lib/transform/db/killAnnotations.js +3 -0
- package/lib/transform/db/processSqlServices.js +63 -0
- package/lib/transform/db/temporal.js +3 -4
- package/lib/transform/db/views.js +0 -1
- package/lib/transform/draft/odata.js +56 -3
- package/lib/transform/effective/annotations.js +3 -2
- package/lib/transform/effective/flattening.js +135 -0
- package/lib/transform/effective/main.js +6 -4
- package/lib/transform/effective/types.js +13 -9
- package/lib/transform/forOdata.js +0 -2
- package/lib/transform/forRelationalDB.js +9 -19
- package/lib/transform/localized.js +7 -8
- package/lib/transform/odata/flattening.js +39 -31
- package/lib/transform/odata/typesExposure.js +5 -17
- package/lib/transform/transformUtils.js +1 -1
- package/lib/transform/translateAssocsToJoins.js +0 -1
- package/lib/utils/file.js +87 -8
- package/lib/utils/moduleResolve.js +59 -8
- package/lib/utils/term.js +3 -2
- package/package.json +7 -3
- package/share/messages/message-explanations.json +2 -0
- package/share/messages/type-unexpected-foreign-keys.md +52 -0
- package/share/messages/type-unexpected-on-condition.md +52 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,98 @@
|
|
|
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.1.0 - 2024-07-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- cdsc: Option `--stdin` was added to support input via standard input, e.g. `cat file.cds | cdsc --stdin`
|
|
15
|
+
- Allow to refer to draft state element `IsActiveEntity` via magic variable `$draft.IsActiveEntity` in annotation path expressions.
|
|
16
|
+
+ for.odata: During draft augmentation `$draft.IsActiveEntity` is rewritten to `$self.IsActiveEntity` for all draft enabled
|
|
17
|
+
entities (root and sub nodes but not for named types or entity parameters).
|
|
18
|
+
+ 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
|
|
19
|
+
in an annotation path expression. The API generator will prefix the path with the actual binding parameter name (explicit, annotation or
|
|
20
|
+
default).
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Update OData vocabularies: 'Common', 'Core', 'HTML5', 'UI'.
|
|
25
|
+
- to.cdl|hdbcds|hdi|sql: Remove `generated by` comment.
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- compiler: checks for associations now work for nested projections of the form `association.{ id }`
|
|
30
|
+
- to.edm(x): No `Nullable` attribute for `$ReturnType` of `Collection(<entity type>)` [OData V4 CSDL, section 12.8 Return Type](https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html#sec_ReturnType)
|
|
31
|
+
- to.sql|hdi|hdbcds: Detect and error on "cross-eyed" backlinks, where we cannot construct a valid on-condition.
|
|
32
|
+
- to.sql|hdi.migration: Correctly detect that a view was dropped - this was previously just silently ignored.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Version 5.0.6 - 2024-07-10
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- for.seal: Don't generate DRAFT artifacts.
|
|
40
|
+
|
|
41
|
+
## Version 5.0.4 - 2024-06-26
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- CDL parser: an `extend entity` and `extend aspect` with an extensions for the
|
|
46
|
+
same element now correctly leads to an error, because it resulted in part of the
|
|
47
|
+
extension being simply dropped. Remark: an `extend type` and the recommended
|
|
48
|
+
plain `extend` led to an error in that situation already before.
|
|
49
|
+
- to.sql: Conditions inside filters in combination with foreign key aliases were
|
|
50
|
+
not properly translated in rare cases.
|
|
51
|
+
- Update OData Vocabularies: 'PDF', 'UI'.
|
|
52
|
+
|
|
53
|
+
## Version 5.0.2 - 2024-06-14
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- API `CompilationError` will serialize the first compiler error in `e.message`
|
|
58
|
+
- cdsc: `--without-hana-associations` is changed to `--with-hana-associations`
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- to.edm(x):
|
|
63
|
+
+ Respect `AppliesTo` specification in term definitions for actions and functions.
|
|
64
|
+
+ Make message `odata-spec-violation-namespace` a warning again.
|
|
65
|
+
|
|
66
|
+
## Version 5.0.0 - Pre-release version - 2024-05-29
|
|
67
|
+
|
|
68
|
+
This is a preview version for the major release and contains breaking changes. It should not be used for production.
|
|
69
|
+
|
|
70
|
+
### Changed
|
|
71
|
+
|
|
72
|
+
- Node 18 is now the minimum required version.
|
|
73
|
+
- API `CompilationError`s will no longer serialize all compiler messages into `e.message`.
|
|
74
|
+
Use `e.messages[]` instead or `e.toString()` to serialize errors into a string.
|
|
75
|
+
- CDL parser: Annotations that can't be applied are now rejected.
|
|
76
|
+
- compiler:
|
|
77
|
+
+ `extend` statements on "namespaces" (paths that are not definitions) are now always errors.
|
|
78
|
+
+ non-structured events are rejected
|
|
79
|
+
+ `$self` references in JOINs are rejected if they could lead to issues in SQL rendering.
|
|
80
|
+
+ non-string enum definitions must have a value.
|
|
81
|
+
+ A top-level definition `$self` is rejected. `$self` is considered a reserved name.
|
|
82
|
+
+ `$at.from`/`$at.to` are deprecated; use `$valid.from`/`$valid.to` instead.
|
|
83
|
+
- to.hdbcds: The HDBCDS backend is now considered deprecated.
|
|
84
|
+
- to.edm(x):
|
|
85
|
+
+ Set default nullability to `true` for collection like properties (was `false` before).
|
|
86
|
+
+ Raise message ids `odata-spec-violation-namespace`, `odata-spec-violation-no-key` from warning to error.
|
|
87
|
+
- to.sql:
|
|
88
|
+
+ `@cds.persistence.exists` is _not_ propagated to generated localization views (`localized.*`)
|
|
89
|
+
+ Option `fewerLocalizedViews` is now enabled by default.
|
|
90
|
+
+ Option `betterSqliteSessionVariables` is now enabled by default.
|
|
91
|
+
|
|
92
|
+
### Fixed
|
|
93
|
+
|
|
94
|
+
- for.odata: Propagate all `@odata { Type, MaxLength, Precision, Scale, SRID }` to generated foreign keys.
|
|
95
|
+
|
|
96
|
+
### Removed
|
|
97
|
+
|
|
98
|
+
- API: Deprecated functions `preparedCsnToEdmx` and `preparedCsnToEdm` were removed.
|
|
99
|
+
Use `to.edm(x)` instead.
|
|
100
|
+
|
|
101
|
+
|
|
10
102
|
## Version 4.9.6 - 2024-07-15
|
|
11
103
|
|
|
12
104
|
### Fixed
|
|
@@ -64,7 +64,8 @@ function modernizeWhitespace( source, filename ) {
|
|
|
64
64
|
|
|
65
65
|
// To avoid spam, only report errors.
|
|
66
66
|
// Users should use the compiler to get all messages.
|
|
67
|
-
const errors = options.messages
|
|
67
|
+
const errors = options.messages
|
|
68
|
+
.filter(msg => (msg.severity === 'Error' && msg.messageId !== 'syntax-invalid-space'));
|
|
68
69
|
if (errors.length > 0) {
|
|
69
70
|
errors.forEach((msg) => {
|
|
70
71
|
console.error(msg.toString());
|
package/bin/cdsc.js
CHANGED
|
@@ -35,6 +35,7 @@ const { addLocalizationViews } = require('../lib/transform/localized');
|
|
|
35
35
|
const { addTenantFields } = require('../lib/transform/addTenantFields');
|
|
36
36
|
const { availableBetaFlags } = require('../lib/base/model');
|
|
37
37
|
const { alterConstraintsWithCsn } = require('../lib/render/manageConstraints');
|
|
38
|
+
const { tmpFilePath, readStream } = require('../lib/utils/file');
|
|
38
39
|
|
|
39
40
|
// Note: Instead of throwing ProcessExitError, we would rather just call process.exit(exitCode),
|
|
40
41
|
// but that might truncate the output of stdout and stderr, both of which are async (or rather,
|
|
@@ -85,9 +86,12 @@ function remapCmdOptions( options, command ) {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
function cdsc_main() {
|
|
88
|
-
|
|
89
|
+
if (process.argv.some(arg => arg === '-i' || arg === '--stdin'))
|
|
90
|
+
optionProcessor.makePositionalArgumentsOptional();
|
|
89
91
|
|
|
92
|
+
// Parse the command line and translate it into options
|
|
90
93
|
const cmdLine = optionProcessor.processCmdLine(process.argv);
|
|
94
|
+
|
|
91
95
|
// Deal with '--version' explicitly
|
|
92
96
|
if (cmdLine.options.version) {
|
|
93
97
|
process.stdout.write(`${main.version()}\n`);
|
|
@@ -145,6 +149,7 @@ function cdsc_main() {
|
|
|
145
149
|
// Internally, parseCdl/parseOnly are options, so we map the command to it.
|
|
146
150
|
if (cmdLine.command === 'parseCdl') {
|
|
147
151
|
cmdLine.command = 'toCsn';
|
|
152
|
+
cmdLine.options.toCsn = cmdLine.options.parseCdl;
|
|
148
153
|
cmdLine.options.parseCdl = true;
|
|
149
154
|
cmdLine.args.files = [ cmdLine.args.file ];
|
|
150
155
|
}
|
|
@@ -169,12 +174,20 @@ function cdsc_main() {
|
|
|
169
174
|
}
|
|
170
175
|
|
|
171
176
|
const to = cmdLine.options.toSql ? 'toSql' : 'toHana';
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
if (cmdLine.options[to]) {
|
|
178
|
+
// remap string values in options to boolean
|
|
179
|
+
if (cmdLine.options[to].assertIntegrity &&
|
|
180
|
+
(cmdLine.options[to].assertIntegrity === 'true' ||
|
|
181
|
+
cmdLine.options[to].assertIntegrity === 'false')
|
|
182
|
+
)
|
|
183
|
+
cmdLine.options[to].assertIntegrity = cmdLine.options[to].assertIntegrity === 'true';
|
|
184
|
+
|
|
185
|
+
if (cmdLine.options[to].withHanaAssociations)
|
|
186
|
+
cmdLine.options[to].withHanaAssociations = cmdLine.options[to].withHanaAssociations !== 'false';
|
|
187
|
+
|
|
188
|
+
if (cmdLine.options[to].betterSqliteSessionVariables)
|
|
189
|
+
cmdLine.options[to].betterSqliteSessionVariables = cmdLine.options[to].betterSqliteSessionVariables === 'true';
|
|
190
|
+
}
|
|
178
191
|
|
|
179
192
|
// Enable all beta-flags if betaMode is set to true
|
|
180
193
|
if (cmdLine.options.betaMode)
|
|
@@ -201,6 +214,9 @@ function cdsc_main() {
|
|
|
201
214
|
if (typeof cmdLine.options.moduleLookupDirectories === 'string')
|
|
202
215
|
cmdLine.options.moduleLookupDirectories = cmdLine.options.moduleLookupDirectories.split(',');
|
|
203
216
|
|
|
217
|
+
if (cmdLine.options.stdin)
|
|
218
|
+
cmdLine.options.fallbackParser ??= 'auto!';
|
|
219
|
+
|
|
204
220
|
parseSeverityOptions(cmdLine);
|
|
205
221
|
|
|
206
222
|
// Do the work for the selected command
|
|
@@ -221,12 +237,12 @@ function validateDirectBackendOption( command, options, args ) {
|
|
|
221
237
|
displayUsage(`Option '--direct-backend' can't be used with command '${command}'`,
|
|
222
238
|
optionProcessor.helpText, 2);
|
|
223
239
|
}
|
|
224
|
-
if (!args.files || args.files.length !== 1) {
|
|
225
|
-
displayUsage(`Option '--direct-backend' expects exactly one JSON file, but ${args.files
|
|
240
|
+
if (!options.stdin && (!args.files || args.files.length !== 1)) {
|
|
241
|
+
displayUsage(`Option '--direct-backend' expects exactly one JSON file, but ${args.files?.length || 'none'} given`,
|
|
226
242
|
optionProcessor.helpText, 2);
|
|
227
243
|
}
|
|
228
|
-
const filename = args.files[0];
|
|
229
|
-
if (!filename.endsWith('.csn') && !filename.endsWith('.json')) {
|
|
244
|
+
const filename = args.files?.[0];
|
|
245
|
+
if (filename && !filename.endsWith('.csn') && !filename.endsWith('.json')) {
|
|
230
246
|
displayUsage('Option \'--direct-backend\' expects a filename with a *.csn or *.json suffix',
|
|
231
247
|
optionProcessor.helpText, 2);
|
|
232
248
|
}
|
|
@@ -250,8 +266,21 @@ function displayUsage( error, helpText, code ) {
|
|
|
250
266
|
throw new ProcessExitError(code);
|
|
251
267
|
}
|
|
252
268
|
|
|
269
|
+
/**
|
|
270
|
+
* As the compiler is file-based and will always at least try to call `realpath()` on a file,
|
|
271
|
+
* we fake a "stdin" file for it.
|
|
272
|
+
*
|
|
273
|
+
* @returns {Promise<string>}
|
|
274
|
+
*/
|
|
275
|
+
async function createTemporaryFileFromStdin() {
|
|
276
|
+
const contents = await readStream(process.stdin);
|
|
277
|
+
const file = tmpFilePath('cds-compiler-stdin', 'cds');
|
|
278
|
+
await fs.promises.writeFile(file, contents);
|
|
279
|
+
return file;
|
|
280
|
+
}
|
|
281
|
+
|
|
253
282
|
// Executes a command line that has been translated to 'command' (what to do), 'options' (how) and 'args' (which files)
|
|
254
|
-
function executeCommandLine( command, options, args ) {
|
|
283
|
+
async function executeCommandLine( command, options, args ) {
|
|
255
284
|
const normalizeFilename = options.testMode && process.platform === 'win32';
|
|
256
285
|
const messageLevels = {
|
|
257
286
|
Error: 0, Warning: 1, Info: 2, Debug: 3,
|
|
@@ -295,17 +324,22 @@ function executeCommandLine( command, options, args ) {
|
|
|
295
324
|
}
|
|
296
325
|
|
|
297
326
|
options.messages = [];
|
|
327
|
+
args.files ??= [];
|
|
328
|
+
|
|
329
|
+
// Load a file from stdin if no explicit file is given and stdin is not a TTY.
|
|
330
|
+
if (options.stdin)
|
|
331
|
+
args.files.push(await createTemporaryFileFromStdin());
|
|
298
332
|
|
|
299
333
|
const fileCache = Object.create(null);
|
|
300
334
|
const compiled = options.directBackend
|
|
301
335
|
? util.promisify(fs.readFile)( args.files[0], 'utf-8' ).then(str => JSON.parse( str ))
|
|
302
336
|
: compiler.compileX( args.files, undefined, options, fileCache );
|
|
303
337
|
|
|
304
|
-
compiled.then( commands[command] )
|
|
338
|
+
await compiled.then( commands[command] )
|
|
305
339
|
.then( displayMessages, displayErrors )
|
|
306
340
|
.catch( catchErrors );
|
|
307
341
|
|
|
308
|
-
|
|
342
|
+
// below are only command implementations.
|
|
309
343
|
|
|
310
344
|
// Execute the command line option '--to-cdl' and display the results.
|
|
311
345
|
// Return the original model (for chaining)
|
|
@@ -446,11 +480,6 @@ function executeCommandLine( command, options, args ) {
|
|
|
446
480
|
// Execute the command line option '--to-sql' and display the results.
|
|
447
481
|
// Return the original model (for chaining)
|
|
448
482
|
function toSql( model ) {
|
|
449
|
-
if (options.withoutHanaAssociations) {
|
|
450
|
-
options.withHanaAssociations = false;
|
|
451
|
-
delete options.withoutHanaAssociations;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
483
|
const csn = options.directBackend ? model : compactModel(model, options);
|
|
455
484
|
if (options.src === 'hdi') {
|
|
456
485
|
if (options.csn) {
|
|
@@ -720,3 +749,4 @@ function parseSeverityOptions({ options }) {
|
|
|
720
749
|
}
|
|
721
750
|
}
|
|
722
751
|
}
|
|
752
|
+
|
package/bin/cdshi.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
const compiler = require('../lib/compiler');
|
|
15
15
|
const fs = require('fs');
|
|
16
|
-
|
|
16
|
+
const stdinFd = 0;
|
|
17
|
+
fs.readFile( stdinFd, 'utf8', highlight );
|
|
17
18
|
|
|
18
19
|
const categoryChars = { // default: first char of category name
|
|
19
20
|
// first char lowercase = reference other than via extend/annotate:
|
|
@@ -34,6 +35,7 @@ const categoryChars = { // default: first char of category name
|
|
|
34
35
|
ExtBoundAction: 'B', // highlight like bound action definition
|
|
35
36
|
ExtParam: 'P', // highlight like entity/action parameter definition
|
|
36
37
|
Event: 'Y',
|
|
38
|
+
KeyImplicit: 'r', // handle as normal ref
|
|
37
39
|
// Remark: do not use `x`/`X` (hex literal `x'1e3d'`)
|
|
38
40
|
};
|
|
39
41
|
|
package/doc/CHANGELOG_BETA.md
CHANGED
|
@@ -8,6 +8,13 @@ Note: `beta` fixes, changes and features are listed in this ChangeLog just for i
|
|
|
8
8
|
The compiler behavior concerning `beta` features can change at any time without notice.
|
|
9
9
|
**Don't use `beta` fixes, changes and features in productive mode.**
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
## Version 5.0.0 - 2024-05-29
|
|
13
|
+
|
|
14
|
+
## Removed `v5preview`
|
|
15
|
+
|
|
16
|
+
It is now enabled by default.
|
|
17
|
+
|
|
11
18
|
## Version 4.9.0 - 2024-04-25
|
|
12
19
|
|
|
13
20
|
## Removed `odataAnnotationExpressions`
|
package/lib/api/main.js
CHANGED
|
@@ -596,6 +596,15 @@ function sqlMigration( csn, options, messageFunctions, beforeImage ) {
|
|
|
596
596
|
if (constraintDeletions)
|
|
597
597
|
Object.values(constraintDeletions).forEach(constraint => dropSqls.push(constraint));
|
|
598
598
|
|
|
599
|
+
if (Object.keys(drops.final).length > 0) {
|
|
600
|
+
const order = sortViews({ sql: {}, csn: beforeImage });
|
|
601
|
+
|
|
602
|
+
for (const { name } of order) {
|
|
603
|
+
if (drops.final[name])
|
|
604
|
+
dropSqls.push(drops.final[name]);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
599
608
|
// We need to drop the things without dependants first - so inversely sorted
|
|
600
609
|
dropSqls.reverse();
|
|
601
610
|
|
|
@@ -679,7 +688,7 @@ function createSqlDefinitions( hdbkinds, afterImage ) {
|
|
|
679
688
|
*/
|
|
680
689
|
function createSqlDeletions( deletions, beforeImage ) {
|
|
681
690
|
const result = [];
|
|
682
|
-
objectUtils.forEach(deletions, name => result.push({ name: getFileName(name, beforeImage), suffix: '.hdbtable' }));
|
|
691
|
+
objectUtils.forEach(deletions, name => result.push({ name: getFileName(name, beforeImage), suffix: beforeImage.definitions[name].query ? '.hdbview' : '.hdbtable' }));
|
|
683
692
|
return result;
|
|
684
693
|
}
|
|
685
694
|
/**
|
|
@@ -712,9 +721,9 @@ function hdbcds( csn, options, messageFunctions ) {
|
|
|
712
721
|
internalOptions.transformation = 'hdbcds';
|
|
713
722
|
messageFunctions.setOptions( internalOptions );
|
|
714
723
|
|
|
715
|
-
//
|
|
716
|
-
|
|
717
|
-
|
|
724
|
+
// Since v5, the HDBCDS backend is considered deprecated.
|
|
725
|
+
// TODO(v6): Make this a configurable error
|
|
726
|
+
messageFunctions.warning('api-deprecated-v5', null, null);
|
|
718
727
|
|
|
719
728
|
if (options.tenantDiscriminator) {
|
|
720
729
|
messageFunctions.error('api-invalid-option', null, {
|
|
@@ -741,7 +750,6 @@ function hdbcds( csn, options, messageFunctions ) {
|
|
|
741
750
|
function edm( csn, options, messageFunctions ) {
|
|
742
751
|
// If not provided at all, set service to 'undefined' to trigger validation
|
|
743
752
|
const internalOptions = prepareOptions.to.edm(
|
|
744
|
-
// eslint-disable-next-line comma-dangle
|
|
745
753
|
options.service ? options : Object.assign({ service: undefined }, options)
|
|
746
754
|
);
|
|
747
755
|
messageFunctions.setOptions( internalOptions );
|
|
@@ -810,7 +818,6 @@ function edmall( csn, options, messageFunctions ) {
|
|
|
810
818
|
function edmx( csn, options, messageFunctions ) {
|
|
811
819
|
// If not provided at all, set service to 'undefined' to trigger validation
|
|
812
820
|
const internalOptions = prepareOptions.to.edmx(
|
|
813
|
-
// eslint-disable-next-line comma-dangle
|
|
814
821
|
options.service ? options : Object.assign({ service: undefined }, options)
|
|
815
822
|
);
|
|
816
823
|
messageFunctions.setOptions( internalOptions );
|
|
@@ -880,9 +887,8 @@ function edmxall( csn, options, messageFunctions ) {
|
|
|
880
887
|
*/
|
|
881
888
|
// @ts-ignore
|
|
882
889
|
function odata2( csn, options, messageFunctions ) {
|
|
883
|
-
// If not provided at all, set service to undefined to trigger validation
|
|
890
|
+
// If not provided at all, set service to 'undefined' to trigger validation
|
|
884
891
|
const internalOptions = prepareOptions.to.odata(
|
|
885
|
-
// eslint-disable-next-line comma-dangle
|
|
886
892
|
options.service ? options : Object.assign({ service: undefined }, options)
|
|
887
893
|
);
|
|
888
894
|
messageFunctions.setOptions( internalOptions );
|
|
@@ -1074,15 +1080,6 @@ module.exports = {
|
|
|
1074
1080
|
for_hdbcds: publishCsnProcessor(forHdbcds, 'for.hdbcds'),
|
|
1075
1081
|
for_effective: publishCsnProcessor(forEffective, 'for.effective'),
|
|
1076
1082
|
for_seal: publishCsnProcessor(forSeal, 'for.seal'),
|
|
1077
|
-
|
|
1078
|
-
/* Deprecated, will be removed in cds-compiler@v5 */ // TODO(v5): Remove
|
|
1079
|
-
preparedCsnToEdmx(csn, service, options) {
|
|
1080
|
-
preparedCsnToEdmx(csn, service, options, messages.makeMessageFunction( csn, options, 'to.edmx' ));
|
|
1081
|
-
},
|
|
1082
|
-
/* Deprecated, will be removed in cds-compiler@v5 */ // TODO(v5): Remove
|
|
1083
|
-
preparedCsnToEdm(csn, service, options) {
|
|
1084
|
-
preparedCsnToEdm(csn, service, options, messages.makeMessageFunction( csn, options, 'to.edm' ));
|
|
1085
|
-
},
|
|
1086
1083
|
};
|
|
1087
1084
|
|
|
1088
1085
|
|
|
@@ -1266,7 +1263,7 @@ function ensureClientCsn( csn, options, messageFunctions, module ) {
|
|
|
1266
1263
|
function lazyload( moduleName ) {
|
|
1267
1264
|
let module;
|
|
1268
1265
|
return new Proxy(((...args) => {
|
|
1269
|
-
if (!module)
|
|
1266
|
+
if (!module)
|
|
1270
1267
|
module = require(moduleName);
|
|
1271
1268
|
|
|
1272
1269
|
if (module.apply && typeof module.apply === 'function')
|
|
@@ -1274,7 +1271,7 @@ function lazyload( moduleName ) {
|
|
|
1274
1271
|
return module; // for destructured calls
|
|
1275
1272
|
}), {
|
|
1276
1273
|
get(target, name) {
|
|
1277
|
-
if (!module)
|
|
1274
|
+
if (!module)
|
|
1278
1275
|
module = require(moduleName);
|
|
1279
1276
|
|
|
1280
1277
|
return module[name];
|
package/lib/api/options.js
CHANGED
|
@@ -29,7 +29,6 @@ const publicOptionsNewAPI = [
|
|
|
29
29
|
'magicVars', // deprecated, not removed in v3 as we have specific error messages for it
|
|
30
30
|
'variableReplacements',
|
|
31
31
|
'pre2134ReferentialConstraintNames',
|
|
32
|
-
'generatedByComment',
|
|
33
32
|
'betterSqliteSessionVariables',
|
|
34
33
|
'fewerLocalizedViews',
|
|
35
34
|
'withHanaAssociations',
|
|
@@ -75,7 +74,7 @@ const privateOptions = [
|
|
|
75
74
|
'internalMsg',
|
|
76
75
|
'disableHanaComments', // in case of issues with hana comment rendering
|
|
77
76
|
'tenantDiscriminator', // not published yet
|
|
78
|
-
'localizedWithoutCoalesce', // deprecated version of 'localizedLanguageFallback', TODO(
|
|
77
|
+
'localizedWithoutCoalesce', // deprecated version of 'localizedLanguageFallback', TODO(v6): Remove option
|
|
79
78
|
];
|
|
80
79
|
|
|
81
80
|
const overallOptions = publicOptionsNewAPI.concat(privateOptions);
|
|
@@ -145,15 +144,7 @@ function reclassifyErrorsForOpenApi( options ) {
|
|
|
145
144
|
// shallow clone, so that we can modify severities without changing the user's.
|
|
146
145
|
options.severities = Object.assign({}, options.severities ?? {});
|
|
147
146
|
|
|
148
|
-
options.severities['odata-spec-violation-array'] = 'Warning';
|
|
149
|
-
options.severities['odata-spec-violation-assoc'] = 'Warning';
|
|
150
|
-
options.severities['odata-spec-violation-namespace'] = 'Warning';
|
|
151
|
-
options.severities['odata-spec-violation-param'] = 'Warning';
|
|
152
|
-
options.severities['odata-spec-violation-returns'] = 'Warning';
|
|
153
|
-
options.severities['odata-spec-violation-type-unknown'] = 'Warning';
|
|
154
147
|
options.severities['odata-spec-violation-no-key'] = 'Warning';
|
|
155
|
-
options.severities['odata-spec-violation-key-type'] = 'Warning';
|
|
156
|
-
options.severities['odata-spec-violation-property-name'] = 'Warning';
|
|
157
148
|
}
|
|
158
149
|
}
|
|
159
150
|
|
|
@@ -164,7 +155,7 @@ module.exports = {
|
|
|
164
155
|
sql: (options) => {
|
|
165
156
|
const hardOptions = { src: 'sql', toSql: true, forHana: true };
|
|
166
157
|
const defaultOptions = {
|
|
167
|
-
sqlMapping: 'plain', sqlDialect: 'plain',
|
|
158
|
+
sqlMapping: 'plain', sqlDialect: 'plain', withHanaAssociations: true,
|
|
168
159
|
};
|
|
169
160
|
const processed = translateOptions(options, defaultOptions, hardOptions, undefined, [ 'sql-dialect-and-naming' ], 'to.sql');
|
|
170
161
|
|
|
@@ -174,7 +165,7 @@ module.exports = {
|
|
|
174
165
|
const hardOptions = { src: 'hdi', toSql: true, forHana: true };
|
|
175
166
|
// TODO: sqlDialect should be a hard option!
|
|
176
167
|
const defaultOptions = {
|
|
177
|
-
sqlMapping: 'plain', sqlDialect: 'hana',
|
|
168
|
+
sqlMapping: 'plain', sqlDialect: 'hana', withHanaAssociations: true,
|
|
178
169
|
};
|
|
179
170
|
return translateOptions(options, defaultOptions, hardOptions, { sqlDialect: generateStringValidator([ 'hana' ]) }, undefined, 'to.hdi');
|
|
180
171
|
},
|
|
@@ -216,7 +207,7 @@ module.exports = {
|
|
|
216
207
|
return translateOptions(options, defaultOptions, hardOptions, undefined, undefined, 'for.hana');
|
|
217
208
|
},
|
|
218
209
|
effective: (options) => {
|
|
219
|
-
const hardOptions = {};
|
|
210
|
+
const hardOptions = { addCdsPersistenceName: false };
|
|
220
211
|
const defaultOptions = {
|
|
221
212
|
sqlMapping: 'plain', resolveSimpleTypes: true, resolveProjections: true, remapOdataAnnotations: false, keepLocalized: false,
|
|
222
213
|
};
|
|
@@ -226,7 +217,7 @@ module.exports = {
|
|
|
226
217
|
},
|
|
227
218
|
seal: (options) => {
|
|
228
219
|
const hardOptions = {
|
|
229
|
-
sqlMapping: 'plain', resolveSimpleTypes: true, resolveProjections: true, keepLocalized: false,
|
|
220
|
+
sqlMapping: 'plain', resolveSimpleTypes: true, resolveProjections: true, keepLocalized: false, addCdsPersistenceName: true,
|
|
230
221
|
};
|
|
231
222
|
const defaultOptions = { remapOdataAnnotations: true };
|
|
232
223
|
const processed = translateOptions(options, defaultOptions, hardOptions, null, [ 'sql-dialect-and-naming' ], 'for.effective');
|
package/lib/api/trace.js
CHANGED
|
@@ -27,7 +27,6 @@ function traceApi( apiName, options, ...args ) {
|
|
|
27
27
|
const argsStr = args.map(val => JSON.stringify(val)).join(', ');
|
|
28
28
|
const rest = args.length > 0 ? ` | ${ argsStr }` : '';
|
|
29
29
|
// Local require: Only load on-demand, not when tracing is disabled.
|
|
30
|
-
// eslint-disable-next-line global-require
|
|
31
30
|
const { version } = require('../../package.json');
|
|
32
31
|
// eslint-disable-next-line no-console
|
|
33
32
|
console.error( `CDSC_TRACE_API | ${ version } | ${ apiName }(…) | options: ${ optStr }${ rest }`);
|
package/lib/base/builtins.js
CHANGED
package/lib/base/location.js
CHANGED
|
@@ -11,13 +11,16 @@ class Location {
|
|
|
11
11
|
col;
|
|
12
12
|
endLine;
|
|
13
13
|
endCol;
|
|
14
|
-
constructor(file, line, col, endLine, endCol) {
|
|
14
|
+
constructor( file, line, col, endLine, endCol ) {
|
|
15
15
|
this.file = file;
|
|
16
16
|
this.line = line;
|
|
17
17
|
this.col = col;
|
|
18
18
|
this.endLine = endLine;
|
|
19
19
|
this.endCol = endCol;
|
|
20
20
|
}
|
|
21
|
+
toString() {
|
|
22
|
+
return locationString( this );
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
class SemanticLocation {
|