@sap/cds-compiler 2.15.8 → 3.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.
Files changed (127) hide show
  1. package/CHANGELOG.md +102 -1590
  2. package/bin/.eslintrc.json +2 -1
  3. package/bin/cdsc.js +61 -46
  4. package/doc/API.md +11 -0
  5. package/doc/CHANGELOG_ARCHIVE.md +1592 -0
  6. package/doc/CHANGELOG_BETA.md +26 -5
  7. package/doc/CHANGELOG_DEPRECATED.md +55 -1
  8. package/doc/{DeprecatedOptions.md → DeprecatedOptions_v2.md} +3 -1
  9. package/doc/Versioning.md +20 -1
  10. package/lib/api/.eslintrc.json +2 -2
  11. package/lib/api/main.js +282 -156
  12. package/lib/api/options.js +17 -88
  13. package/lib/api/validate.js +6 -10
  14. package/lib/base/keywords.js +280 -110
  15. package/lib/base/message-registry.js +85 -25
  16. package/lib/base/messages.js +119 -89
  17. package/lib/base/model.js +46 -2
  18. package/lib/base/optionProcessorHelper.js +53 -21
  19. package/lib/checks/actionsFunctions.js +15 -12
  20. package/lib/checks/annotationsOData.js +1 -1
  21. package/lib/checks/cdsPersistence.js +1 -0
  22. package/lib/checks/elements.js +6 -6
  23. package/lib/checks/invalidTarget.js +1 -1
  24. package/lib/checks/nonexpandableStructured.js +1 -1
  25. package/lib/checks/queryNoDbArtifacts.js +2 -1
  26. package/lib/checks/selectItems.js +101 -15
  27. package/lib/checks/types.js +7 -8
  28. package/lib/checks/utils.js +2 -2
  29. package/lib/checks/validator.js +3 -3
  30. package/lib/compiler/assert-consistency.js +78 -21
  31. package/lib/compiler/base.js +6 -4
  32. package/lib/compiler/builtins.js +177 -10
  33. package/lib/compiler/checks.js +1 -1
  34. package/lib/compiler/define.js +28 -23
  35. package/lib/compiler/extend.js +75 -18
  36. package/lib/compiler/finalize-parse-cdl.js +25 -18
  37. package/lib/compiler/index.js +27 -11
  38. package/lib/compiler/moduleLayers.js +7 -0
  39. package/lib/compiler/populate.js +26 -39
  40. package/lib/compiler/propagator.js +12 -7
  41. package/lib/compiler/resolve.js +207 -236
  42. package/lib/compiler/shared.js +100 -93
  43. package/lib/compiler/tweak-assocs.js +13 -20
  44. package/lib/compiler/utils.js +20 -6
  45. package/lib/edm/annotations/preprocessAnnotations.js +12 -13
  46. package/lib/edm/csn2edm.js +35 -37
  47. package/lib/edm/edm.js +22 -13
  48. package/lib/edm/edmAnnoPreprocessor.js +349 -0
  49. package/lib/edm/edmInboundChecks.js +85 -0
  50. package/lib/edm/edmPreprocessor.js +338 -689
  51. package/lib/edm/edmUtils.js +97 -67
  52. package/lib/gen/Dictionary.json +29 -9
  53. package/lib/gen/language.checksum +1 -1
  54. package/lib/gen/language.interp +8 -31
  55. package/lib/gen/language.tokens +105 -114
  56. package/lib/gen/languageLexer.interp +1 -34
  57. package/lib/gen/languageLexer.js +892 -1007
  58. package/lib/gen/languageLexer.tokens +95 -106
  59. package/lib/gen/languageParser.js +20629 -22474
  60. package/lib/inspect/.eslintrc.json +4 -0
  61. package/lib/inspect/index.js +14 -0
  62. package/lib/inspect/inspectModelStatistics.js +81 -0
  63. package/lib/inspect/inspectPropagation.js +189 -0
  64. package/lib/inspect/inspectUtils.js +44 -0
  65. package/lib/json/from-csn.js +74 -69
  66. package/lib/json/to-csn.js +17 -14
  67. package/lib/language/antlrParser.js +2 -2
  68. package/lib/language/docCommentParser.js +61 -38
  69. package/lib/language/errorStrategy.js +52 -40
  70. package/lib/language/genericAntlrParser.js +424 -292
  71. package/lib/language/language.g4 +604 -687
  72. package/lib/language/multiLineStringParser.js +14 -42
  73. package/lib/language/textUtils.js +44 -0
  74. package/lib/main.d.ts +28 -42
  75. package/lib/main.js +104 -81
  76. package/lib/model/api.js +1 -1
  77. package/lib/model/csnRefs.js +57 -30
  78. package/lib/model/csnUtils.js +189 -287
  79. package/lib/model/revealInternalProperties.js +32 -10
  80. package/lib/model/sortViews.js +32 -31
  81. package/lib/modelCompare/compare.js +3 -0
  82. package/lib/optionProcessor.js +91 -57
  83. package/lib/render/.eslintrc.json +1 -1
  84. package/lib/render/DuplicateChecker.js +4 -7
  85. package/lib/render/manageConstraints.js +70 -2
  86. package/lib/render/toCdl.js +387 -367
  87. package/lib/render/toHdbcds.js +20 -16
  88. package/lib/render/toRename.js +44 -22
  89. package/lib/render/toSql.js +81 -59
  90. package/lib/render/utils/common.js +16 -3
  91. package/lib/render/utils/sql.js +20 -19
  92. package/lib/sql-identifier.js +6 -0
  93. package/lib/transform/db/.eslintrc.json +3 -2
  94. package/lib/transform/db/associations.js +43 -35
  95. package/lib/transform/db/cdsPersistence.js +5 -16
  96. package/lib/transform/db/constraints.js +1 -1
  97. package/lib/transform/db/expansion.js +7 -6
  98. package/lib/transform/db/flattening.js +16 -18
  99. package/lib/transform/db/transformExists.js +7 -5
  100. package/lib/transform/db/views.js +3 -3
  101. package/lib/transform/draft/.eslintrc.json +2 -2
  102. package/lib/transform/draft/db.js +6 -6
  103. package/lib/transform/draft/odata.js +6 -7
  104. package/lib/transform/forHanaNew.js +30 -24
  105. package/lib/transform/forOdataNew.js +14 -16
  106. package/lib/transform/localized.js +35 -25
  107. package/lib/transform/odata/toFinalBaseType.js +10 -10
  108. package/lib/transform/odata/typesExposure.js +17 -8
  109. package/lib/transform/odata/utils.js +1 -38
  110. package/lib/transform/transformUtilsNew.js +63 -77
  111. package/lib/transform/translateAssocsToJoins.js +2 -2
  112. package/lib/transform/universalCsn/.eslintrc.json +2 -2
  113. package/lib/transform/universalCsn/coreComputed.js +11 -6
  114. package/lib/transform/universalCsn/universalCsnEnricher.js +33 -5
  115. package/lib/utils/file.js +31 -21
  116. package/lib/utils/moduleResolve.js +0 -1
  117. package/lib/utils/timetrace.js +20 -21
  118. package/package.json +34 -4
  119. package/share/messages/syntax-expected-integer.md +9 -8
  120. package/doc/ApiMigration.md +0 -237
  121. package/doc/CommandLineMigration.md +0 -58
  122. package/doc/ErrorMessages.md +0 -175
  123. package/doc/FioriAnnotations.md +0 -94
  124. package/doc/ODataTransformation.md +0 -273
  125. package/lib/backends.js +0 -529
  126. package/lib/checks/unknownMagic.js +0 -41
  127. package/lib/fix_antlr4-8_warning.js +0 -56
@@ -8,12 +8,33 @@ 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
- ## Version 2.XX.YY
11
+ ## Version 3.1.0 - 2022-08-04
12
12
 
13
- ### Removed `assocsWithParams`
13
+ ### Added `optionalActionFunctionParameters`
14
14
 
15
- Instead, of using the beta flag `assocsWithParams`, you can change the severity of the messages
16
- `def-unexpected-paramview-assoc` and `def-unexpected-calcview-assoc`.
15
+ - to.edm(x): Annotate optional function/action parameters with `@Core.OptionalParameter` for OData V4.
16
+ An action/function parameter is optional if
17
+ 1) it is already annotated with `@Core.OptionalParameter` regardless of its definition.
18
+ 2) it has a default value (including null), regardless of it's nullability
19
+ 3) it has NO default value but is nullable (the implicit default value is null)
20
+
21
+ If a mandatory parameter (not null and no default value) appears after an optional
22
+ parameter, a warning is raised, Core.OptionalParameter requires that all optional
23
+ parameters appear rightmost.
24
+
25
+ ### Added `odataOpenType`
26
+
27
+ - to.edm(x): Support annotation `@open` on entity and structured type level to declare the corresponding entity/complex type to
28
+ be `OpenType=true`. If an open structured type is declared closed (with a falsy annotation value), the corresponding EDM type
29
+ is closed as well and suffixed with `_closed` (or `_open` vice versa).
30
+ No further checks are performed on possibly open foreign or primary key types nor on eventually bucket elements to store the
31
+ additional data.
32
+
33
+ ## Version 3.0.0 - 2022-06-23
34
+
35
+ ### Removed `addTextsLanguageAssoc`
36
+
37
+ Instead, use the option `addTextsLanguageAssoc`, which is available since v2.8.0.
17
38
 
18
39
  ## Version 2.12.0 - 2022-01-25
19
40
 
@@ -135,7 +156,7 @@ When the beta option `subElemRedirections` is set to true,
135
156
  _all_ array (new!) and structure types are expanded when referenced:
136
157
  managed associations (and compositions to entities) in that array are
137
158
  implicitly redirected when necessary.
138
- See [below for details](#version-1300---20200612).
159
+ See [below for details](#version-1300---2020-06-12).
139
160
 
140
161
  Nested array types (without intermediate structure types) are not supported.
141
162
 
@@ -11,7 +11,61 @@ Note: `deprecated` features are listed in this ChangeLog just for information.
11
11
  **When the `deprecated` option is set, the `beta` option is ignored,
12
12
  and several new features are not available.**
13
13
 
14
- ## Version 2.XX.YY - 2022-MM-DD
14
+ ## Version 3.1.0 - 2022-08-04
15
+
16
+ ### Added `autoCorrectOrderBySourceRefs`
17
+
18
+ When this option is set, calling `compile` auto-corrects direct `order by`
19
+ source element references without table alias for SELECT queries by adding the
20
+ table alias to the `ref`.
21
+
22
+ Using this option might lead to surprising results when elements are added to
23
+ existing models: `order by` specifications might change their semantics without
24
+ any extra messages.
25
+
26
+ ## Version 3.0.0 - 2022-06-23
27
+
28
+ Version 3 of the cds-compiler removes all v2 deprecated flags.
29
+
30
+ ### Add `eagerPersistenceForGeneratedEntities`
31
+
32
+ If enabled, the old behavior regarding `@cds.persistence.skip` and `@cds.persistence.exists`
33
+ is restored, i.e. these annotations are not copied from parent to generated child entities, nor
34
+ is `@cds.persistence.exists` copied to localized convenience views.
35
+
36
+ ### Removed `createLocalizedViews`
37
+
38
+ ### Removed `downgradableErrors`
39
+
40
+ ### Removed `generatedEntityNameWithUnderscore`
41
+
42
+ ### Removed `longAutoexposed`
43
+
44
+ ### Removed `noElementsExpansion`
45
+
46
+ <!-- fully removed with 3.1.0 -->
47
+
48
+ ### Removed `noInheritedAutoexposeViaComposition`
49
+
50
+ ### Removed `noScopedRedirections`
51
+
52
+ ### Removed `oldVirtualNotNullPropagation`
53
+
54
+ ### Removed `parensAsStrings`
55
+
56
+ ### Removed `projectionAsQuery`
57
+
58
+ ### Removed `redirectInSubQueries`
59
+
60
+ ### Removed `renderVirtualElements`
61
+
62
+ ### Removed `shortAutoexposed`
63
+
64
+ ### Removed `unmanagedUpInComponent`
65
+
66
+ ### Removed `v1KeysForTemporal`
67
+
68
+ ## Version 2.13.0 - 2022-03-22
15
69
 
16
70
  ### Added `redirectInSubQueries`
17
71
 
@@ -1,8 +1,10 @@
1
1
  # Deprecated Options and How to Avoid Them
2
2
 
3
+ __Important__: With compiler v3, these deprecated options were removed!
4
+
3
5
  To ease the migration to CDS Compiler Version 2,
4
6
  the compiler can be called with an option `deprecated`
5
- which make the compiler behave more like Compiler Version 1 for certain features.
7
+ which makes the compiler behave more like Compiler Version 1 for certain features.
6
8
 
7
9
  As the name suggest, this option should be used only for a limited time.
8
10
  The support for certain v1 features might also be dropped after a while
package/doc/Versioning.md CHANGED
@@ -5,6 +5,17 @@ The cds-compiler uses [Semantic Versioning][SemVer] for its version numbers.
5
5
  This document clarifies how we use [SemVer] and what you can and what you can‘t
6
6
  expect from version updates.
7
7
 
8
+ <!-- toc: start -->
9
+
10
+ 1. [Public API](#public-api)
11
+ 2. [Patch Versions](#patch-versions)
12
+ 3. [Minor Versions](#minor-versions)
13
+ 4. [Beta Flags](#beta-flags)
14
+ 5. [Deprecated Flags](#deprecated-flags)
15
+ 6. [Command Line Tool `cdsc`](#command-line-tool-cdsc)
16
+
17
+ <!-- toc: end -->
18
+
8
19
  ## Public API
9
20
 
10
21
  According to [§1] of SemVer, a public API must be made available. Our public
@@ -41,7 +52,7 @@ we detect invalid CDS code.
41
52
 
42
53
  ## Beta Flags
43
54
 
44
- The compiler provides so called “beta flags” that enable or disable certain
55
+ The compiler provides so-called “beta flags” that enable or disable certain
45
56
  features. We do not guarantee that any such flags stay consistent between
46
57
  patch versions! Beta flags may change any time.
47
58
 
@@ -57,6 +68,14 @@ period.
57
68
  Refer to [CHANGELOG_DEPRECATED.md](./CHANGELOG_DEPRECATED.md) for changes
58
69
  to deprecated flags.
59
70
 
71
+ ## Command Line Tool `cdsc`
72
+
73
+ `bin/cdsc.js` as well as all other command line tools do _not_ guarantee any
74
+ stability. It is considered a compiler internal tool that only serves for
75
+ debugging. The official command line tool `cds` of the `@sap/cds` and
76
+ `@sap/cds-dk` packages are to be used by users. That means commands and
77
+ options may change any time without prior notice. Changes may still be listed
78
+ in [CHANGELOG.md](../CHANGELOG.md).
60
79
 
61
80
  [SemVer]: https://semver.org/
62
81
  [§1]: https://semver.org/#spec-item-1
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "root": true,
3
3
  "env": {
4
- "es6": true,
4
+ "es2020": true,
5
5
  "node": true
6
6
  },
7
7
  // we actually do not extend airbnb-base, as it weakens some eslint:recommended rules
8
8
  "extends": ["../../.eslintrc-ydkjsi.json", "plugin:jsdoc/recommended"],
9
9
  "parserOptions": {
10
- "ecmaVersion": 2018,
10
+ "ecmaVersion": 2020,
11
11
  "sourceType": "script"
12
12
  },
13
13
  "plugins": [