@sap/cds-compiler 3.3.2 → 3.4.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/bin/cdsc.js +3 -1
  3. package/doc/CHANGELOG_BETA.md +17 -0
  4. package/lib/api/main.js +147 -18
  5. package/lib/api/validate.js +8 -3
  6. package/lib/base/dictionaries.js +6 -6
  7. package/lib/base/keywords.js +104 -0
  8. package/lib/base/message-registry.js +136 -67
  9. package/lib/base/messages.js +59 -48
  10. package/lib/base/model.js +1 -0
  11. package/lib/checks/actionsFunctions.js +1 -1
  12. package/lib/checks/cdsPersistence.js +1 -1
  13. package/lib/checks/checkForTypes.js +13 -8
  14. package/lib/checks/defaultValues.js +3 -1
  15. package/lib/checks/elements.js +1 -1
  16. package/lib/checks/parameters.js +4 -2
  17. package/lib/checks/queryNoDbArtifacts.js +1 -1
  18. package/lib/checks/sql-snippets.js +12 -10
  19. package/lib/checks/validator.js +14 -4
  20. package/lib/compiler/assert-consistency.js +8 -7
  21. package/lib/compiler/checks.js +30 -20
  22. package/lib/compiler/define.js +89 -25
  23. package/lib/compiler/extend.js +21 -18
  24. package/lib/compiler/finalize-parse-cdl.js +14 -9
  25. package/lib/compiler/populate.js +30 -8
  26. package/lib/compiler/propagator.js +4 -2
  27. package/lib/compiler/resolve.js +11 -5
  28. package/lib/compiler/shared.js +66 -48
  29. package/lib/compiler/tweak-assocs.js +2 -3
  30. package/lib/compiler/utils.js +11 -0
  31. package/lib/edm/annotations/genericTranslation.js +7 -4
  32. package/lib/edm/csn2edm.js +1 -1
  33. package/lib/gen/language.checksum +1 -1
  34. package/lib/gen/language.interp +1 -1
  35. package/lib/gen/languageParser.js +3565 -3544
  36. package/lib/json/csnVersion.js +13 -13
  37. package/lib/json/from-csn.js +140 -158
  38. package/lib/json/to-csn.js +23 -5
  39. package/lib/language/.eslintrc.json +4 -0
  40. package/lib/language/antlrParser.js +7 -10
  41. package/lib/language/docCommentParser.js +1 -2
  42. package/lib/language/errorStrategy.js +54 -27
  43. package/lib/language/genericAntlrParser.js +115 -84
  44. package/lib/language/language.g4 +29 -25
  45. package/lib/language/multiLineStringParser.js +75 -63
  46. package/lib/main.js +1 -0
  47. package/lib/model/csnRefs.js +4 -3
  48. package/lib/model/csnUtils.js +39 -7
  49. package/lib/model/sortViews.js +7 -3
  50. package/lib/modelCompare/compare.js +49 -15
  51. package/lib/modelCompare/filter.js +83 -0
  52. package/lib/optionProcessor.js +5 -1
  53. package/lib/render/manageConstraints.js +9 -5
  54. package/lib/render/toCdl.js +120 -62
  55. package/lib/render/toHdbcds.js +1 -1
  56. package/lib/render/toSql.js +6 -2
  57. package/lib/render/utils/common.js +7 -0
  58. package/lib/sql-identifier.js +7 -0
  59. package/lib/transform/db/assertUnique.js +27 -38
  60. package/lib/transform/db/expansion.js +11 -4
  61. package/lib/transform/db/temporal.js +3 -1
  62. package/lib/transform/db/transformExists.js +7 -1
  63. package/lib/transform/db/views.js +42 -13
  64. package/lib/transform/draft/db.js +2 -2
  65. package/lib/transform/forRelationalDB.js +12 -6
  66. package/lib/transform/localized.js +1 -1
  67. package/lib/transform/odata/typesExposure.js +2 -1
  68. package/lib/transform/parseExpr.js +245 -0
  69. package/lib/transform/transformUtilsNew.js +23 -14
  70. package/lib/transform/translateAssocsToJoins.js +12 -12
  71. package/lib/utils/term.js +5 -5
  72. package/package.json +2 -2
  73. package/share/messages/message-explanations.json +1 -1
  74. package/share/messages/{syntax-expected-integer.md → syntax-expecting-integer.md} +1 -1
@@ -1,5 +1,6 @@
1
- // csn version functions
1
+ 'use strict';
2
2
 
3
+ // csn version functions
3
4
 
4
5
  // The CSN file format version produced by this compiler
5
6
  // (Note that all 0.x.x versions are floating targets, i.e. the format is frequently
@@ -18,15 +19,12 @@
18
19
  // Use literal version constants intentionally and not number intervals to
19
20
  // record all published version strings of the core compiler.
20
21
  const newCSNVersions = [ '0.1.99', '0.2', '0.2.0', '1.0', '2.0' ];
21
- // checks if new-csn is requested via the options of already specified in the CSN
22
- // default: old-style
22
+
23
+ // Check if new-style CSN is requested, i.e. versions >= 0.1.99
23
24
  function isNewCSN(csn, options) {
24
- if ( (options && options.newCsn === false) ||
25
+ return !( options?.newCsn === false ||
25
26
  (csn.version && !newCSNVersions.includes(csn.version.csn)) ||
26
- (csn.$version && !newCSNVersions.includes(csn.$version)))
27
- return false;
28
-
29
- return true;
27
+ (csn.$version && !newCSNVersions.includes(csn.$version)));
30
28
  }
31
29
 
32
30
  function checkCSNVersion(csn, options) {
@@ -35,11 +33,13 @@ function checkCSNVersion(csn, options) {
35
33
  const { makeMessageFunction } = require('../base/messages');
36
34
  const { error, throwWithAnyError } = makeMessageFunction(csn, options);
37
35
 
38
- let errStr = 'CSN Version not supported, version tag: "';
39
- errStr += `${ csn.version && csn.version.csn ? csn.version.csn : (csn.$version ? csn.$version : 'not available') }"`;
40
- errStr += (options.newCsn !== undefined) ? `, options.newCsn: ${ options.newCsn }` : '';
41
-
42
- error(null, null, {}, errStr);
36
+ const version = csn.version?.csn ? csn.version.csn : (csn.$version || 'unknown');
37
+ const variant = options.newCsn !== undefined ? 'newCsn' : 'std';
38
+ error('api-unsupported-csn-version', null,
39
+ { '#': variant, version, code: options.newCsn }, {
40
+ std: 'CSN version $(VERSION) not supported',
41
+ newCsn: 'CSN version $(VERSION) not supported; options.newCsn: $(CODE)',
42
+ });
43
43
  throwWithAnyError();
44
44
  }
45
45
  }