@sap/cds-compiler 2.12.0 → 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 (128) hide show
  1. package/CHANGELOG.md +221 -15
  2. package/bin/cdsc.js +125 -50
  3. package/bin/cdsse.js +2 -2
  4. package/doc/CHANGELOG_BETA.md +13 -6
  5. package/doc/CHANGELOG_DEPRECATED.md +22 -6
  6. package/doc/NameResolution.md +21 -16
  7. package/lib/api/main.js +47 -84
  8. package/lib/api/options.js +5 -6
  9. package/lib/api/validate.js +6 -11
  10. package/lib/backends.js +15 -23
  11. package/lib/base/dictionaries.js +0 -8
  12. package/lib/base/error.js +26 -0
  13. package/lib/base/keywords.js +7 -17
  14. package/lib/base/location.js +9 -4
  15. package/lib/base/message-registry.js +114 -18
  16. package/lib/base/messages.js +101 -90
  17. package/lib/base/model.js +2 -63
  18. package/lib/base/optionProcessorHelper.js +177 -123
  19. package/lib/checks/annotationsOData.js +12 -33
  20. package/lib/checks/arrayOfs.js +1 -34
  21. package/lib/checks/cdsPersistence.js +2 -1
  22. package/lib/checks/enricher.js +17 -1
  23. package/lib/checks/invalidTarget.js +3 -1
  24. package/lib/checks/managedWithoutKeys.js +3 -1
  25. package/lib/checks/selectItems.js +4 -4
  26. package/lib/checks/sql-snippets.js +27 -26
  27. package/lib/checks/types.js +1 -1
  28. package/lib/checks/validator.js +6 -11
  29. package/lib/compiler/assert-consistency.js +6 -3
  30. package/lib/compiler/base.js +1 -0
  31. package/lib/compiler/builtins.js +19 -6
  32. package/lib/compiler/checks.js +23 -60
  33. package/lib/compiler/cycle-detector.js +1 -1
  34. package/lib/compiler/define.js +1151 -0
  35. package/lib/compiler/extend.js +1000 -0
  36. package/lib/compiler/finalize-parse-cdl.js +237 -0
  37. package/lib/compiler/index.js +107 -39
  38. package/lib/compiler/kick-start.js +190 -0
  39. package/lib/compiler/moduleLayers.js +4 -4
  40. package/lib/compiler/populate.js +1227 -0
  41. package/lib/compiler/propagator.js +114 -46
  42. package/lib/compiler/resolve.js +1521 -0
  43. package/lib/compiler/shared.js +126 -65
  44. package/lib/compiler/tweak-assocs.js +535 -0
  45. package/lib/compiler/utils.js +197 -33
  46. package/lib/edm/.eslintrc.json +5 -0
  47. package/lib/edm/annotations/genericTranslation.js +38 -24
  48. package/lib/edm/annotations/preprocessAnnotations.js +2 -2
  49. package/lib/edm/csn2edm.js +219 -100
  50. package/lib/edm/edm.js +302 -230
  51. package/lib/edm/edmPreprocessor.js +554 -419
  52. package/lib/edm/edmUtils.js +138 -44
  53. package/lib/gen/Dictionary.json +100 -19
  54. package/lib/gen/language.checksum +1 -1
  55. package/lib/gen/language.interp +11 -1
  56. package/lib/gen/language.tokens +86 -83
  57. package/lib/gen/languageLexer.interp +10 -1
  58. package/lib/gen/languageLexer.js +860 -833
  59. package/lib/gen/languageLexer.tokens +78 -75
  60. package/lib/gen/languageParser.js +5765 -4480
  61. package/lib/json/csnVersion.js +10 -11
  62. package/lib/json/from-csn.js +15 -3
  63. package/lib/json/to-csn.js +126 -68
  64. package/lib/language/docCommentParser.js +4 -4
  65. package/lib/language/genericAntlrParser.js +123 -5
  66. package/lib/language/language.g4 +355 -156
  67. package/lib/language/multiLineStringParser.js +5 -5
  68. package/lib/main.d.ts +486 -59
  69. package/lib/main.js +41 -9
  70. package/lib/model/api.js +3 -1
  71. package/lib/model/csnRefs.js +252 -156
  72. package/lib/model/csnUtils.js +384 -297
  73. package/lib/model/enrichCsn.js +71 -29
  74. package/lib/model/revealInternalProperties.js +29 -8
  75. package/lib/model/sortViews.js +2 -1
  76. package/lib/modelCompare/compare.js +23 -18
  77. package/lib/optionProcessor.js +63 -26
  78. package/lib/render/manageConstraints.js +35 -32
  79. package/lib/render/toCdl.js +897 -947
  80. package/lib/render/toHdbcds.js +205 -257
  81. package/lib/render/toSql.js +264 -225
  82. package/lib/render/utils/common.js +136 -25
  83. package/lib/render/utils/sql.js +4 -3
  84. package/lib/render/utils/stringEscapes.js +111 -0
  85. package/lib/sql-identifier.js +1 -1
  86. package/lib/transform/.eslintrc.json +5 -0
  87. package/lib/transform/db/.eslintrc.json +3 -1
  88. package/lib/transform/db/applyTransformations.js +35 -12
  89. package/lib/transform/db/assertUnique.js +1 -1
  90. package/lib/transform/db/associations.js +104 -306
  91. package/lib/transform/db/cdsPersistence.js +2 -2
  92. package/lib/transform/db/constraints.js +58 -53
  93. package/lib/transform/db/expansion.js +60 -33
  94. package/lib/transform/db/flattening.js +582 -104
  95. package/lib/transform/db/groupByOrderBy.js +3 -1
  96. package/lib/transform/db/transformExists.js +66 -13
  97. package/lib/transform/db/views.js +11 -7
  98. package/lib/transform/draft/.eslintrc.json +38 -0
  99. package/lib/transform/{db/draft.js → draft/db.js} +6 -5
  100. package/lib/transform/draft/odata.js +227 -0
  101. package/lib/transform/forHanaNew.js +109 -208
  102. package/lib/transform/forOdataNew.js +59 -212
  103. package/lib/transform/localized.js +46 -26
  104. package/lib/transform/odata/toFinalBaseType.js +85 -11
  105. package/lib/transform/odata/typesExposure.js +147 -199
  106. package/lib/transform/odata/utils.js +2 -2
  107. package/lib/transform/transformUtilsNew.js +44 -33
  108. package/lib/transform/translateAssocsToJoins.js +3 -20
  109. package/lib/transform/universalCsn/.eslintrc.json +36 -0
  110. package/lib/transform/universalCsn/coreComputed.js +172 -0
  111. package/lib/transform/universalCsn/universalCsnEnricher.js +737 -0
  112. package/lib/transform/universalCsn/utils.js +63 -0
  113. package/lib/utils/moduleResolve.js +13 -6
  114. package/lib/utils/objectUtils.js +30 -0
  115. package/package.json +1 -1
  116. package/share/messages/README.md +26 -0
  117. package/share/messages/message-explanations.json +2 -1
  118. package/share/messages/syntax-expected-integer.md +37 -0
  119. package/lib/compiler/definer.js +0 -2361
  120. package/lib/compiler/resolver.js +0 -3079
  121. package/lib/transform/odata/attachPath.js +0 -96
  122. package/lib/transform/odata/expandStructKeysInAssociations.js +0 -59
  123. package/lib/transform/odata/generateForeignKeyElements.js +0 -261
  124. package/lib/transform/odata/referenceFlattener.js +0 -290
  125. package/lib/transform/odata/sortByAssociationDependency.js +0 -105
  126. package/lib/transform/odata/structuralPath.js +0 -72
  127. package/lib/transform/odata/structureFlattener.js +0 -171
  128. package/lib/transform/universalCsnEnricher.js +0 -237
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ const { functionsWithoutParens } = require("../compiler/builtins");
4
+
1
5
  module.exports = {
2
6
  // CDL reserved keywords, used for automatic quoting in 'toCdl' renderer
3
7
  // Keep in sync with reserved keywords in language.g4
@@ -30,21 +34,7 @@ module.exports = {
30
34
  ],
31
35
  // CDL functions, used for automatic quoting in 'toCdl' renderer,
32
36
  // only relevant for element references of path length 1.
33
- cdl_functions: [
34
- 'CURRENT_CONNECTION',
35
- 'CURRENT_DATE',
36
- 'CURRENT_SCHEMA',
37
- 'CURRENT_TIME',
38
- 'CURRENT_TIMESTAMP',
39
- 'CURRENT_TRANSACTION_ISOLATION_LEVEL',
40
- 'CURRENT_USER',
41
- 'CURRENT_UTCDATE',
42
- 'CURRENT_UTCTIME',
43
- 'CURRENT_UTCTIMESTAMP',
44
- 'SESSION_USER',
45
- 'SYSTEM_USER',
46
- 'SYSUUID',
47
- ],
37
+ cdl_functions: functionsWithoutParens,
48
38
  // SQLite keywords, used to warn in 'toSql' renderer with dialect 'sqlite'
49
39
  // Taken from http://www.sqlite.org/draft/lang_keywords.html
50
40
  // Better use keywords in tool/mkkeywordhash.c of a sqlite distribution.
@@ -195,7 +185,7 @@ module.exports = {
195
185
  'OTHERS',
196
186
  'TIES',
197
187
  ],
198
- // HANA keywords, used for smart quoting in to-hdi.plain
188
+ // SAP HANA keywords, used for smart quoting in to-hdi.plain
199
189
  // Taken from https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/28bcd6af3eb6437892719f7c27a8a285.html
200
190
  // Better use keywords in ptime/query/parser/syntax/qp_keyword.cc minus those
201
191
  // in rule unreserved_keyword_column (=…_common - "CONSTRAINT") in
@@ -675,7 +665,7 @@ module.exports = {
675
665
  'XMLTABLE',
676
666
  'YEAR'
677
667
  ],
678
- // HANA CDS keywords, used for smart quoting in to-hdbcds.plain
668
+ // SAP HANA CDS keywords, used for smart quoting in to-hdbcds.plain
679
669
  hdbcds: [
680
670
  'ALL', 'ALTER', 'AS',
681
671
  'BEFORE', 'BEGIN', 'BOTH',
@@ -12,6 +12,9 @@ const { copyPropIfExist } = require('../utils/objectUtils');
12
12
  * @param {XSN.WithLocation} start
13
13
  * @param {XSN.WithLocation} end
14
14
  * @returns {CSN.Location}
15
+ *
16
+ * TODO: make this function a CDL parser-only function (i.e. there should be
17
+ * no need to use it outside), it is XSN-only anyway already now
15
18
  */
16
19
  function combinedLocation( start, end ) {
17
20
  if (!start || !start.location)
@@ -33,6 +36,8 @@ function combinedLocation( start, end ) {
33
36
  *
34
37
  * @param {string} filename
35
38
  * @returns {CSN.Location}
39
+ *
40
+ * TODO: make this function redundant (XSN sparse locations project)
36
41
  */
37
42
  function emptyLocation(filename) {
38
43
  return {
@@ -50,6 +55,8 @@ function emptyLocation(filename) {
50
55
  *
51
56
  * @param {string} filename
52
57
  * @returns {CSN.Location}
58
+ *
59
+ * TODO: make this function redundant (XSN sparse locations project)
53
60
  */
54
61
  function emptyWeakLocation(filename) {
55
62
  return {
@@ -63,6 +70,8 @@ function emptyWeakLocation(filename) {
63
70
  * Returns a dummy location for built-in definitions.
64
71
  *
65
72
  * @returns {CSN.Location}
73
+ *
74
+ * TODO: make this function redundant (XSN sparse locations project)
66
75
  */
67
76
  function builtinLocation() {
68
77
  return emptyLocation('<built-in>');
@@ -140,10 +149,6 @@ function dictLocation( dict, extraLocation ) {
140
149
  endCol: max.endCol,
141
150
  };
142
151
  }
143
- dictLocation.end = (dict) => {
144
- const loc = dictLocation( dict );
145
- return loc && { file: loc.file, line: loc.endLine, col: loc.endCol };
146
- };
147
152
 
148
153
  function _objLocations( obj ) {
149
154
  return Array.isArray(obj) ? obj.map( o => o.location ) : [ obj.location ];
@@ -30,6 +30,9 @@
30
30
 
31
31
  'use strict';
32
32
 
33
+ const { CompilerAssertion } = require("./error");
34
+ const { createDict } = require("../utils/objectUtils");
35
+
33
36
  /**
34
37
  * Central register of messages and their configuration.
35
38
  * Group by id-category.
@@ -42,15 +45,17 @@ const centralMessages = {
42
45
  'anno-definition': { severity: 'Warning' },
43
46
  'anno-duplicate': { severity: 'Error', configurableFor: true }, // does not hurt us
44
47
  'anno-duplicate-unrelated-layer': { severity: 'Error', configurableFor: true }, // does not hurt us
45
- 'anno-invalid-sql-element': { severity: 'Error'}, // @sql.prepend/append
46
- 'anno-invalid-sql-struct': { severity: 'Error'}, // @sql.prepend/append
47
- 'anno-invalid-sql-view': { severity: 'Error' }, // @sql.prepend/append
48
- 'anno-invalid-sql-view-element': { severity: 'Error'}, // @sql.prepend/append
48
+ 'anno-invalid-sql-element': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
49
+ 'anno-invalid-sql-struct': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
50
+ 'anno-invalid-sql-kind': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
51
+ 'anno-invalid-sql-view': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
52
+ 'anno-invalid-sql-view-element': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
49
53
  'anno-undefined-action': { severity: 'Info' },
50
54
  'anno-undefined-art': { severity: 'Info' }, // for annotate statement (for CDL path root)
51
55
  'anno-undefined-def': { severity: 'Info' }, // for annotate statement (for CSN or CDL path cont)
52
56
  'anno-undefined-element': { severity: 'Info' },
53
57
  'anno-undefined-param': { severity: 'Info' },
58
+ 'anno-unexpected-ellipsis-layers': { severity: 'Error', configurableFor: true }, // TODO(v3): Merge with anno-unexpected-ellipsis and make non-configurable
54
59
 
55
60
  'args-expected-named': { severity: 'Error', configurableFor: 'deprecated' }, // future --sloppy
56
61
  'args-no-params': { severity: 'Error', configurableFor: 'deprecated' }, // future --sloppy
@@ -58,7 +63,9 @@ const centralMessages = {
58
63
 
59
64
  'assoc-in-array': { severity: 'Error', configurableFor: 'deprecated' }, // not supported yet
60
65
  'assoc-as-type': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: allow more, but not all
61
-
66
+ 'def-unexpected-paramview-assoc': { severity: 'Error' },
67
+ 'def-unexpected-calcview-assoc': { severity: 'Error' },
68
+ 'chained-array-of': { severity: 'Error' },
62
69
  'check-proper-type': { severity: 'Error', configurableFor: [ 'compile' ] },
63
70
  'check-proper-type-of': { severity: 'Info', errorFor: [ 'for.odata', 'to.edmx', 'to.hdbcds', 'to.sql', 'to.rename' ] },
64
71
 
@@ -73,6 +80,7 @@ const centralMessages = {
73
80
  'expected-type': { severity: 'Error' },
74
81
  'ref-sloppy-type': { severity: 'Error' },
75
82
  'type-unexpected-typeof': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: make it non-config
83
+ 'type-expected-builtin': { severity: 'Error', configurableFor: true },
76
84
  'expected-actionparam-type': { severity: 'Error' },
77
85
  'ref-sloppy-actionparam-type': { severity: 'Error' },
78
86
  'expected-event-type': { severity: 'Error' },
@@ -93,6 +101,7 @@ const centralMessages = {
93
101
  'query-unexpected-assoc-hdbcds': { severity: 'Error' },
94
102
  'query-unexpected-structure-hdbcds': { severity: 'Error' },
95
103
  'query-ignoring-param-nullability': { severity: 'Info' },
104
+ 'query-expected-identifier': { severity: 'Error' },
96
105
 
97
106
  'recalculated-localized': { severity: 'Info' }, // KEEP: Downgrade in lib/transform/translateAssocsToJoins.js
98
107
  'redirected-implicitly-ambiguous': { severity: 'Error', configurableFor: true }, // does not hurt us - TODO: ref-ambiguous-target
@@ -131,11 +140,15 @@ const centralMessages = {
131
140
  'syntax-fragile-alias': { severity: 'Error', configurableFor: true },
132
141
  'syntax-fragile-ident': { severity: 'Error', configurableFor: true },
133
142
 
143
+ 'syntax-invalid-extend': { severity: 'Error' },
144
+
134
145
  'syntax-invalid-text-block' : { severity: 'Error' },
135
146
  'syntax-unknown-escape': { severity: 'Error', configurableFor: true },
136
147
  'syntax-invalid-escape': { severity: 'Error' },
137
148
  'syntax-missing-escape': { severity: 'Error' },
138
149
 
150
+ 'syntax-expected-integer': { severity: 'Error' },
151
+
139
152
  'type-managed-composition': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: non-config
140
153
 
141
154
  'def-missing-element': { severity: 'Error' },
@@ -145,20 +158,46 @@ const centralMessages = {
145
158
  'composition-as-key': { severity: 'Error', configurableFor: 'deprecated' }, // is confusing and not supported
146
159
  'odata-spec-violation-array': { severity: 'Warning' }, // more than 30 chars
147
160
  'odata-spec-violation-constraints': { severity: 'Info' }, // more than 30 chars
161
+ 'odata-spec-violation-id': { severity: 'Error' },
148
162
  'odata-spec-violation-type': { severity: 'Error', configurableFor: [ 'to.edmx' ] },
163
+ 'odata-spec-violation-type-unknown': { severity: 'Warning' },
149
164
  'odata-spec-violation-no-key': { severity: 'Warning' },
150
165
  'odata-spec-violation-key-array': { severity: 'Error' }, // more than 30 chars
151
166
  'odata-spec-violation-key-null': { severity: 'Error' }, // more than 30 chars
152
167
  'odata-spec-violation-key-type': { severity: 'Warning' }, // more than 30 chars
153
168
  'odata-spec-violation-property-name': { severity: 'Warning' }, // more than 30 chars
154
- 'odata-spec-violation-namespace-name': { severity: 'Warning' }, // more than 30 chars
155
169
  };
156
170
 
171
+ // Old/Deprecated message IDs that we only still use for backwards-compatibility.
172
+ // We keep them in a separate array for easier access. No need to go through all
173
+ // existing messages and search for the old one in `oldNames` property.
174
+ // The keys will be added to `oldNames` of the new message, which is used for reclassification.
175
+ const oldMessageIds = createDict({
176
+ 'old-anno-duplicate': 'anno-duplicate', // Example
177
+ });
178
+
179
+ // Set up the old-to-new message ID mapping in the message registry.
180
+ for (const oldName in oldMessageIds) {
181
+ const newName = oldMessageIds[oldName];
182
+ if (centralMessages[oldName])
183
+ throw new CompilerAssertion(`Mapping from ${oldName} not possible: ID is still used in message registry.`);
184
+ if (!centralMessages[newName])
185
+ throw new CompilerAssertion(`Mapping from ${oldName} to new message ID ${newName} does not exist!`);
186
+
187
+ if (!centralMessages[newName].oldNames)
188
+ centralMessages[newName].oldNames = [ oldName ];
189
+ else
190
+ centralMessages[newName].oldNames.push(oldName);
191
+ }
192
+
193
+
157
194
  // For messageIds, where no text has been provided via code (central def)
158
195
  const centralMessageTexts = {
196
+ 'anno-duplicate': 'Duplicate assignment with $(ANNO)',
159
197
  'anno-mismatched-ellipsis': 'An array with $(CODE) can only be used if there is an assignment below with an array value',
160
198
  'anno-unexpected-ellipsis': 'No base annotation available to apply $(CODE)',
161
- 'missing-type-parameter': 'Missing value for type parameter $(NAME) in reference to type $(ID)',
199
+ 'anno-unexpected-ellipsis-layers': 'No base annotation available to apply $(CODE)',
200
+ 'chained-array-of': '"Array of"/"many" must not be chained with another "array of"/"many" inside a service',
162
201
  'syntax-csn-expected-object': 'Expected object for property $(PROP)',
163
202
  'syntax-csn-expected-column': 'Expected object or string \'*\' for property $(PROP)',
164
203
  'syntax-csn-expected-natnum': 'Expected non-negative number for property $(PROP)',
@@ -179,6 +218,7 @@ const centralMessageTexts = {
179
218
  one: 'Expected array in $(PROP) to have at least one item',
180
219
  suffix: 'With sibling property $(OTHERPROP), expected array in $(PROP) to have at least one item',
181
220
  },
221
+ 'syntax-invalid-extend': 'Can\'t extend an element with $(KIND)',
182
222
  'syntax-invalid-text-block': 'Missing newline in text block',
183
223
  'syntax-unknown-escape': 'Unknown escape sequence $(CODE)',
184
224
  'syntax-invalid-escape': {
@@ -195,6 +235,16 @@ const centralMessageTexts = {
195
235
  std: 'Missing escape. Replace $(CODE) with $(NEWCODE)',
196
236
  placeholder: 'Placeholders are not supported. Replace $(CODE) with $(NEWCODE)',
197
237
  },
238
+ 'syntax-expected-integer': {
239
+ std: 'A safe integer is expected here',
240
+ normal: 'An integer number is expected here',
241
+ unsafe: 'The provided integer is too large',
242
+ },
243
+ 'syntax-duplicate-argument': {
244
+ std: 'Unexpected argument $(CODE)',
245
+ unknown: 'Unknown argument $(CODE)',
246
+ duplicate: 'Duplicate argument $(CODE)',
247
+ },
198
248
  'ref-undefined-def': {
199
249
  std: 'Artifact $(ART) has not been found',
200
250
  // TODO: proposal 'No definition of $(NAME) found',
@@ -204,11 +254,13 @@ const centralMessageTexts = {
204
254
  // TODO: proposal 'No definition found for $(NAME)',
205
255
  'ref-undefined-element': {
206
256
  std: 'Element $(ART) has not been found',
207
- element: 'Artifact $(ART) has no element $(MEMBER)'
257
+ element: 'Artifact $(ART) has no element $(MEMBER)',
258
+ aspect: 'Element $(ID) has not been found in the anonymous target aspect'
208
259
  },
209
260
  'ref-unknown-var': {
210
261
  std: 'Replacement $(ID) not found'
211
262
  },
263
+ 'ref-unexpected-draft-enabled': 'Composition in draft-enabled entity can\'t lead to another entity with $(ANNO)',
212
264
  'ref-rejected-on': {
213
265
  std: 'Do not refer to a artefact like $(ID) in the explicit ON of a redirection', // Not used
214
266
  mixin: 'Do not refer to a mixin like $(ID) in the explicit ON of a redirection',
@@ -221,6 +273,19 @@ const centralMessageTexts = {
221
273
  param: 'Unexpected $(KEYWORD) for the type of a parameter definition',
222
274
  select: 'Unexpected $(KEYWORD) for type references in queries',
223
275
  },
276
+
277
+ 'type-missing-argument': 'Missing value for argument $(NAME) in reference to type $(ID)',
278
+ 'type-ignoring-argument': 'Too many arguments for type $(ART)',
279
+ 'type-unexpected-argument': {
280
+ std: 'Too many arguments for type $(ART)',
281
+ type: 'Unexpected argument $(PROP) for type $(ART) with base type $(TYPE)',
282
+ builtin: 'Unexpected argument $(PROP) for type $(ART)',
283
+ 'non-scalar': 'Only scalar types can have arguments',
284
+ max: 'Expecting argument $(PROP) for type $(TYPE) to not exceed $(NUMBER)',
285
+ min: 'Expecting argument $(PROP) for type $(TYPE) to be greater than or equal to $(NUMBER)',
286
+ 'incorrect-type': 'Expected $(NAMES) for argument $(PROP), but found $(CODE)',
287
+ },
288
+
224
289
  'anno-builtin': 'Builtin types should not be annotated. Use custom type instead',
225
290
  'anno-undefined-def': 'Artifact $(ART) has not been found',
226
291
  'anno-undefined-art': 'No artifact has been found with name $(NAME)',
@@ -238,6 +303,17 @@ const centralMessageTexts = {
238
303
  param: 'Artifact $(ART) has no parameter $(MEMBER)'
239
304
  },
240
305
 
306
+ 'def-unexpected-paramview-assoc': {
307
+ std: 'SAP HANA does no support associations in/to parameterized entities',
308
+ view: 'SAP HANA does no support associations in parameterized entities',
309
+ target: 'SAP HANA does no support associations to parameterized entities',
310
+ },
311
+ 'def-unexpected-calcview-assoc': {
312
+ std: 'SAP HANA does not allow associations in/to entities annotated with $(ANNO)',
313
+ 'entity-persistence': 'SAP HANA does not allow associations in entities annotated with $(ANNO)',
314
+ 'target-persistence': 'SAP HANA does not allow associations pointing to entities annotated with $(ANNO)',
315
+ },
316
+
241
317
  'def-missing-element': {
242
318
  std: 'Expecting entity to have at least one non-virtual element',
243
319
  view: 'Expecting view to have at least one non-virtual element'
@@ -275,6 +351,10 @@ const centralMessageTexts = {
275
351
  std: 'Ignoring nullability constraint on parameter when generating SAP HANA CDS view',
276
352
  sql: 'Ignoring nullability constraint on parameter when generating SQL view'
277
353
  },
354
+ 'query-expected-identifier': {
355
+ std: 'Expected identifier for select item',
356
+ assoc: 'Expected identifier as the association\'s name',
357
+ },
278
358
 
279
359
  'ref-sloppy-type': 'A type or an element is expected here',
280
360
  'ref-sloppy-actionparam-type': 'A type, an element, or a service entity is expected here',
@@ -291,11 +371,16 @@ const centralMessageTexts = {
291
371
  'i18n-different-value': 'Different translation for key $(PROP) of language $(OTHERPROP) in unrelated layers',
292
372
 
293
373
  // OData version dependent messages
294
- 'odata-spec-violation-array': 'Unexpected array type for $(API)',
295
- 'odata-spec-violation-param' : 'Expected parameter to be typed with either scalar or structured type for $(API)',
296
- 'odata-spec-violation-returns': 'Expected $(KIND) to return one or many values of scalar, complex, entity or view type for $(API)',
297
- 'odata-spec-violation-assoc': 'Unexpected association in structured type for $(API)',
298
- 'odata-spec-violation-constraints': 'Partial referential constraints produced for $(API)',
374
+ 'odata-spec-violation-array': 'Unexpected array type for OData $(VERSION)',
375
+ 'odata-spec-violation-param' : 'Expected parameter to be typed with either scalar or structured type for OData $(VERSION)',
376
+ 'odata-spec-violation-returns': 'Expected $(KIND) to return one or many values of scalar, complex, entity or view type for OData $(VERSION)',
377
+ 'odata-spec-violation-assoc': 'Unexpected association in structured type for OData $(VERSION)',
378
+ 'odata-spec-violation-constraints': 'Partial referential constraints produced for OData $(VERSION)',
379
+ 'odata-spec-violation-id': {
380
+ std: 'Expected EDM name $(ID) to start with a letter or underscore, followed by at most 127 letters, underscores or digits',
381
+ 'v2firstchar': 'Unexpected first character $(PROP) of EDM Name $(ID) for OData $(VERSION)',
382
+ 'qualifier': 'Expected annotation qualifier $(ID) to start with a letter or underscore, followed by at most 127 letters, underscores or digits'
383
+ },
299
384
  // version independent messages
300
385
  'odata-spec-violation-key-array': {
301
386
  std: 'Unexpected array type for element $(NAME)',
@@ -310,21 +395,30 @@ const centralMessageTexts = {
310
395
  scalar: 'Unexpected $(TYPE) mapped to $(ID) as type for key element' // flat
311
396
  },
312
397
  'odata-spec-violation-no-key': 'Expected entity to have a primary key',
313
- 'odata-spec-violation-type': 'Expected element to have a type',
398
+ 'odata-spec-violation-type-unknown': 'Unknown Edm Type $(TYPE)',
399
+ 'odata-spec-violation-type': {
400
+ std: 'Expected element to have a type',
401
+ incompatible: 'Unexpected EDM Type $(TYPE) for OData $(VERSION)',
402
+ facet: 'Unexpected EDM Type facet $(NAME) of type $(TYPE) for OData $(VERSION)',
403
+ },
314
404
  'odata-spec-violation-property-name': 'Expected element name to be different from declaring $(KIND)',
315
- 'odata-spec-violation-namespace': 'Expected service name not to be one of the reserved names $(NAMES)',
405
+ 'odata-spec-violation-namespace': {
406
+ std: 'Expected service name not to be one of the reserved names $(NAMES)',
407
+ length: 'Expected service name not to exceed 511 characters',
408
+ },
316
409
  // Other odata/edm errors
317
410
  'odata-definition-exists': {
318
411
  std: 'Entity can\'t be created due to name collision with existing definition $(NAME)',
319
412
  proxy: 'No proxy entity created due to name collision with existing definition $(NAME) of kind $(KIND)'
320
- }
413
+ },
414
+ 'odata-navigation': 'No OData navigation property generated, target $(TARGET) is outside of service $(SERVICE)'
321
415
  }
322
416
 
323
417
  /**
324
418
  * Configuration for a message in the central message register.
325
419
  *
326
420
  * @typedef {object} MessageConfig
327
- * @property {CSN.MessageSeverity} severity Default severity for the message.
421
+ * @property {MessageSeverity} severity Default severity for the message.
328
422
  * @property {string[]|'deprecated'|true} [configurableFor]
329
423
  * Whether the error can be reclassified to a warning or lower.
330
424
  * If not `true` then an array is expected with specified modules in which the error is downgradable.
@@ -335,6 +429,8 @@ const centralMessageTexts = {
335
429
  * @property {boolean} [throughMessageCall]
336
430
  * If set, it means that a message-id was added to the registry in test-mode through a `message.<severity>()`
337
431
  * call. Used for ensuring that all calls with the same message-id have the same severity.
432
+ * @property {string[]} [oldNames] Aliases for the message id. Used for reclassification as well as "explain" messages.
433
+ * Don't set this property directly! Append to object oldMessageIds instead!
338
434
  */
339
435
 
340
- module.exports = { centralMessages, centralMessageTexts };
436
+ module.exports = { centralMessages, centralMessageTexts, oldMessageIds };