@sap/cds-compiler 2.13.8 → 2.15.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +109 -4
  2. package/bin/cdsc.js +112 -37
  3. package/lib/api/main.js +20 -22
  4. package/lib/api/options.js +2 -3
  5. package/lib/api/validate.js +6 -6
  6. package/lib/base/message-registry.js +89 -14
  7. package/lib/base/messages.js +85 -64
  8. package/lib/base/optionProcessorHelper.js +19 -0
  9. package/lib/checks/annotationsOData.js +11 -32
  10. package/lib/checks/arrayOfs.js +1 -34
  11. package/lib/checks/validator.js +2 -4
  12. package/lib/compiler/assert-consistency.js +1 -0
  13. package/lib/compiler/base.js +1 -0
  14. package/lib/compiler/builtins.js +11 -0
  15. package/lib/compiler/checks.js +22 -70
  16. package/lib/compiler/define.js +59 -11
  17. package/lib/compiler/extend.js +20 -3
  18. package/lib/compiler/finalize-parse-cdl.js +26 -20
  19. package/lib/compiler/index.js +75 -26
  20. package/lib/compiler/populate.js +6 -5
  21. package/lib/compiler/propagator.js +4 -1
  22. package/lib/compiler/resolve.js +104 -16
  23. package/lib/compiler/shared.js +61 -27
  24. package/lib/compiler/tweak-assocs.js +7 -1
  25. package/lib/edm/annotations/genericTranslation.js +33 -15
  26. package/lib/edm/csn2edm.js +216 -98
  27. package/lib/edm/edm.js +298 -225
  28. package/lib/edm/edmPreprocessor.js +486 -415
  29. package/lib/edm/edmUtils.js +22 -22
  30. package/lib/gen/Dictionary.json +90 -16
  31. package/lib/gen/language.checksum +1 -1
  32. package/lib/gen/language.interp +3 -1
  33. package/lib/gen/languageParser.js +4636 -4368
  34. package/lib/json/csnVersion.js +10 -11
  35. package/lib/json/from-csn.js +3 -2
  36. package/lib/json/to-csn.js +0 -2
  37. package/lib/language/docCommentParser.js +2 -2
  38. package/lib/language/genericAntlrParser.js +47 -2
  39. package/lib/language/language.g4 +59 -27
  40. package/lib/main.d.ts +19 -1
  41. package/lib/main.js +6 -0
  42. package/lib/model/csnRefs.js +33 -6
  43. package/lib/model/csnUtils.js +193 -75
  44. package/lib/model/enrichCsn.js +1 -0
  45. package/lib/model/revealInternalProperties.js +2 -2
  46. package/lib/modelCompare/compare.js +6 -6
  47. package/lib/optionProcessor.js +62 -26
  48. package/lib/render/toCdl.js +844 -679
  49. package/lib/render/toHdbcds.js +189 -243
  50. package/lib/render/toSql.js +180 -198
  51. package/lib/render/utils/common.js +131 -15
  52. package/lib/transform/db/.eslintrc.json +1 -1
  53. package/lib/transform/db/associations.js +2 -2
  54. package/lib/transform/db/constraints.js +3 -1
  55. package/lib/transform/db/expansion.js +15 -10
  56. package/lib/transform/db/flattening.js +94 -64
  57. package/lib/transform/db/transformExists.js +7 -7
  58. package/lib/transform/db/views.js +6 -3
  59. package/lib/transform/forHanaNew.js +43 -26
  60. package/lib/transform/forOdataNew.js +43 -42
  61. package/lib/transform/localized.js +12 -7
  62. package/lib/transform/odata/toFinalBaseType.js +5 -5
  63. package/lib/transform/odata/typesExposure.js +145 -197
  64. package/lib/transform/transformUtilsNew.js +9 -12
  65. package/lib/transform/translateAssocsToJoins.js +1 -1
  66. package/lib/transform/universalCsn/coreComputed.js +5 -3
  67. package/lib/transform/universalCsn/universalCsnEnricher.js +27 -5
  68. package/lib/utils/moduleResolve.js +13 -6
  69. package/package.json +1 -1
  70. package/share/messages/message-explanations.json +2 -1
  71. package/share/messages/syntax-expected-integer.md +37 -0
  72. package/lib/transform/odata/attachPath.js +0 -96
  73. package/lib/transform/odata/expandStructKeysInAssociations.js +0 -59
  74. package/lib/transform/odata/generateForeignKeyElements.js +0 -261
  75. package/lib/transform/odata/referenceFlattener.js +0 -296
  76. package/lib/transform/odata/sortByAssociationDependency.js +0 -105
  77. package/lib/transform/odata/structuralPath.js +0 -72
  78. package/lib/transform/odata/structureFlattener.js +0 -171
@@ -11,7 +11,9 @@ const optionProcessor = createOptionProcessor();
11
11
  optionProcessor
12
12
  .option('-h, --help')
13
13
  .option('-v, --version')
14
+ .option(' --options <file>')
14
15
  .option('-w, --warning <level>', ['0', '1', '2', '3'])
16
+ .option(' --quiet')
15
17
  .option(' --show-message-id')
16
18
  .option(' --no-message-context')
17
19
  .option(' --color <mode>', ['auto', 'always', 'never'])
@@ -22,16 +24,15 @@ optionProcessor
22
24
  .option(' --trace-parser')
23
25
  .option(' --trace-parser-amb')
24
26
  .option(' --trace-fs')
27
+ .option(' --error <id-list>')
28
+ .option(' --warn <id-list>')
29
+ .option(' --info <id-list>')
30
+ .option(' --debug <id-list>')
25
31
  .option('-E, --enrich-csn')
26
32
  .option('-R, --raw-output <name>')
27
33
  .option(' --internal-msg')
28
34
  .option(' --beta-mode')
29
35
  .option(' --beta <list>')
30
- .option(' --integrity-not-validated')
31
- .option(' --integrity-not-enforced')
32
- .option(' --assert-integrity <mode>', [ 'true', 'false', 'individual' ])
33
- .option(' --assert-integrity-type <type>', [ 'RT', 'DB' ], { ignoreCase: true })
34
- .option(' --constraints-in-create-table')
35
36
  .option(' --deprecated <list>')
36
37
  .option(' --hana-flavor')
37
38
  .option(' --direct-backend')
@@ -59,17 +60,21 @@ optionProcessor
59
60
  General options
60
61
  -h, --help Show this help text
61
62
  -v, --version Display version number and exit
63
+ --quiet Don't emit anything, neither results nor messages.
62
64
  -w, --warning <level> Show messages up to <level>
63
65
  0: Error
64
66
  1: Warnings
65
67
  2: (default) Info
66
68
  3: Debug
69
+ --options <file> Use the given JSON file as input options.
70
+ The key 'cdsc' of 'cds' is used. If not present 'cdsc' is used.
71
+ Otherwise, the JSON as-is is used as options.
67
72
  --show-message-id Show message ID in error, warning and info messages
68
73
  --no-message-context Print messages as single lines without code context (useful for
69
- redirecting output to other processes). Default is to print human
74
+ redirecting output to other processes). Default is to print human-
70
75
  readable text similar to Rust's compiler with a code excerpt.
71
76
  --color <mode> Use colors for warnings. Modes are:
72
- auto: (default) Detect color support of the tty.
77
+ auto: (default) Detect color support of the TTY.
73
78
  always:
74
79
  never:
75
80
  -o, --out <dir> Place generated files in directory <dir>, default is "-" for <stdout>
@@ -87,6 +92,13 @@ optionProcessor
87
92
  --trace-parser-amb Trace parser ambiguities
88
93
  --trace-fs Trace file system access caused by "using from"
89
94
 
95
+ Severity options
96
+ Use these options to reclassify messages. Option argument is a comma separated list of message IDs.
97
+ --error <id-list> IDs that should be reclassified to errors.
98
+ --warn <id-list> IDs that should be reclassified to warnings.
99
+ --info <id-list> IDs that should be reclassified to info messages.
100
+ --debug <id-list> IDs that should be reclassified to debug messages.
101
+
90
102
  Internal options (for testing only, may be changed/removed at any time)
91
103
  -E, --enrich-csn Show non-enumerable CSN properties and locations of references
92
104
  -R, --raw-output <name> Write XSN for definition "name" and error output to <stdout>,
@@ -99,22 +111,6 @@ optionProcessor
99
111
  hanaAssocRealCardinality
100
112
  mapAssocToJoinCardinality
101
113
  ignoreAssocPublishingInUnion
102
- --integrity-not-enforced If this option is supplied, referential constraints are NOT ENFORCED.
103
- This option is also applied to result of "cdsc manageConstraints"
104
- --integrity-not-validated If this option is supplied, referential constraints are NOT VALIDATED.
105
- This option is also applied to result of "cdsc manageConstraints"
106
- --assert-integrity <mode> Turn DB constraints on/off:
107
- true : (default) Constraints will be generated for all associations if
108
- the assert-integrity-type is set to DB
109
- false : No constraints will be generated
110
- individual : Constraints will be generated for selected associations
111
- --assert-integrity-type <type> Specifies how the referential integrity checks should be performed:
112
- RT : (default) No database constraint for an association
113
- if not explicitly demanded via annotation
114
- DB : Create database constraints for associations
115
- --constraints-in-create-table If set, the foreign key constraints will be rendered as
116
- part of the "CREATE TABLE" statements rather than as separate
117
- "ALTER TABLE ADD CONSTRAINT" statements
118
114
  --deprecated <list> Comma separated list of deprecated options.
119
115
  Valid values are:
120
116
  noElementsExpansion
@@ -169,6 +165,10 @@ optionProcessor.command('H, toHana')
169
165
  .option('-u, --user <user>')
170
166
  .option('-s, --src')
171
167
  .option('-c, --csn')
168
+ .option(' --integrity-not-validated')
169
+ .option(' --integrity-not-enforced')
170
+ .option(' --assert-integrity <mode>', ['true', 'false', 'individual'])
171
+ .option(' --assert-integrity-type <type>', ['RT', 'DB'], { ignoreCase: true })
172
172
  .help(`
173
173
  Usage: cdsc toHana [options] <files...>
174
174
 
@@ -192,6 +192,17 @@ optionProcessor.command('H, toHana')
192
192
  -u, --user <user> Value for the "$user" variable
193
193
  -s, --src (default) Generate HANA CDS source files "<artifact>.hdbcds"
194
194
  -c, --csn Generate "hana_csn.json" with HANA-preprocessed model
195
+ --integrity-not-enforced If this option is supplied, referential constraints are NOT ENFORCED.
196
+ --integrity-not-validated If this option is supplied, referential constraints are NOT VALIDATED.
197
+ --assert-integrity <mode> Turn DB constraints on/off:
198
+ true : (default) Constraints will be generated for all associations if
199
+ the assert-integrity-type is set to DB
200
+ false : No constraints will be generated
201
+ individual : Constraints will be generated for selected associations
202
+ --assert-integrity-type <type> Specifies how the referential integrity checks should be performed:
203
+ RT : (default) No database constraint for an association
204
+ if not explicitly demanded via annotation
205
+ DB : Create database constraints for associations
195
206
  `);
196
207
 
197
208
  optionProcessor.command('O, toOdata')
@@ -207,6 +218,7 @@ optionProcessor.command('O, toOdata')
207
218
  .option('-c, --csn')
208
219
  .option('-f, --odata-format <format>', ['flat', 'structured'])
209
220
  .option('-n, --names <style>', ['plain', 'quoted', 'hdbcds'])
221
+ .option('-s, --service-names <list>')
210
222
  .help(`
211
223
  Usage: cdsc toOdata [options] <files...>
212
224
 
@@ -237,6 +249,8 @@ optionProcessor.command('O, toOdata')
237
249
  but element names flattened with underscores
238
250
  hdbcds : Names as HANA CDS would generate them from the same CDS
239
251
  source (like "quoted", but using element names with dots)
252
+ -s, --service-names <list> List of comma-separated service names to be rendered
253
+ (default) empty, all services are rendered
240
254
  `);
241
255
 
242
256
  optionProcessor.command('C, toCdl')
@@ -260,6 +274,11 @@ optionProcessor.command('Q, toSql')
260
274
  .option('-l, --locale <locale>')
261
275
  .option('-s, --src <style>', ['sql', 'hdi'])
262
276
  .option('-c, --csn')
277
+ .option(' --integrity-not-validated')
278
+ .option(' --integrity-not-enforced')
279
+ .option(' --assert-integrity <mode>', ['true', 'false', 'individual'])
280
+ .option(' --assert-integrity-type <type>', ['RT', 'DB'], { ignoreCase: true })
281
+ .option(' --constraints-in-create-table')
263
282
  .help(`
264
283
  Usage: cdsc toSql [options] <files...>
265
284
 
@@ -292,6 +311,20 @@ optionProcessor.command('Q, toSql')
292
311
  the HDI plugin name. Can only be used in combination with
293
312
  "hana" dialect.
294
313
  -c, --csn Generate "sql_csn.json" with SQL-preprocessed model
314
+ --integrity-not-enforced If this option is supplied, referential constraints are NOT ENFORCED.
315
+ --integrity-not-validated If this option is supplied, referential constraints are NOT VALIDATED.
316
+ --assert-integrity <mode> Turn DB constraints on/off:
317
+ true : (default) Constraints will be generated for all associations if
318
+ the assert-integrity-type is set to DB
319
+ false : No constraints will be generated
320
+ individual : Constraints will be generated for selected associations
321
+ --assert-integrity-type <type> Specifies how the referential integrity checks should be performed:
322
+ RT : (default) No database constraint for an association
323
+ if not explicitly demanded via annotation
324
+ DB : Create database constraints for associations
325
+ --constraints-in-create-table If set, the foreign key constraints will be rendered as
326
+ part of the "CREATE TABLE" statements rather than as separate
327
+ "ALTER TABLE ADD CONSTRAINT" statements
295
328
  `);
296
329
 
297
330
  optionProcessor.command('toRename')
@@ -322,13 +355,14 @@ optionProcessor.command('manageConstraints')
322
355
  .option(' --drop')
323
356
  .option(' --alter')
324
357
  .option(' --violations')
358
+ .option(' --integrity-not-validated')
359
+ .option(' --integrity-not-enforced')
325
360
  .help(`
326
361
  Usage: cdsc manageConstraints [options] <files...>
327
362
 
328
363
  (internal, subject to change): Generate SQL DDL ALTER TABLE statements to add / modify
329
- referential constraints on an existing model.
330
- Combine with options "--integrity-not-enforced" and "--integrity-not-validated"
331
- to switch off foreign key constraint enforcement / validation.
364
+ referential constraints on an existing model. This can also be used to
365
+ generate SELECT statements which list all referential integrity violations.
332
366
 
333
367
  Options
334
368
  -h, --help Display this help text
@@ -348,6 +382,8 @@ optionProcessor.command('manageConstraints')
348
382
  --alter Generate "ALTER TABLE <table> ALTER CONSTRAINT <constraint>" statements
349
383
  --violations Generates SELECT statements which can be used to list
350
384
  referential integrity violations on the existing data
385
+ --integrity-not-enforced If this option is supplied, referential constraints are NOT ENFORCED.
386
+ --integrity-not-validated If this option is supplied, referential constraints are NOT VALIDATED.
351
387
  `);
352
388
 
353
389
  optionProcessor.command('toCsn')