@sap/cds-compiler 2.13.8 → 3.0.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 +155 -1594
  2. package/bin/cdsc.js +144 -66
  3. package/doc/CHANGELOG_ARCHIVE.md +1592 -0
  4. package/doc/CHANGELOG_BETA.md +3 -4
  5. package/doc/CHANGELOG_DEPRECATED.md +35 -1
  6. package/doc/{DeprecatedOptions.md → DeprecatedOptions_v2.md} +3 -1
  7. package/doc/Versioning.md +20 -1
  8. package/lib/api/.eslintrc.json +2 -2
  9. package/lib/api/main.js +237 -122
  10. package/lib/api/options.js +17 -88
  11. package/lib/api/validate.js +12 -16
  12. package/lib/base/keywords.js +216 -109
  13. package/lib/base/message-registry.js +152 -37
  14. package/lib/base/messages.js +145 -83
  15. package/lib/base/model.js +44 -2
  16. package/lib/base/optionProcessorHelper.js +19 -0
  17. package/lib/checks/actionsFunctions.js +7 -5
  18. package/lib/checks/annotationsOData.js +11 -32
  19. package/lib/checks/arrayOfs.js +1 -34
  20. package/lib/checks/cdsPersistence.js +1 -0
  21. package/lib/checks/elements.js +6 -6
  22. package/lib/checks/invalidTarget.js +1 -1
  23. package/lib/checks/nonexpandableStructured.js +1 -1
  24. package/lib/checks/queryNoDbArtifacts.js +2 -1
  25. package/lib/checks/selectItems.js +5 -1
  26. package/lib/checks/types.js +4 -2
  27. package/lib/checks/utils.js +2 -2
  28. package/lib/checks/validator.js +4 -5
  29. package/lib/compiler/assert-consistency.js +16 -10
  30. package/lib/compiler/base.js +1 -0
  31. package/lib/compiler/builtins.js +98 -9
  32. package/lib/compiler/checks.js +22 -70
  33. package/lib/compiler/define.js +61 -13
  34. package/lib/compiler/extend.js +79 -14
  35. package/lib/compiler/finalize-parse-cdl.js +46 -29
  36. package/lib/compiler/index.js +100 -37
  37. package/lib/compiler/moduleLayers.js +7 -0
  38. package/lib/compiler/populate.js +19 -18
  39. package/lib/compiler/propagator.js +7 -4
  40. package/lib/compiler/resolve.js +297 -234
  41. package/lib/compiler/shared.js +107 -102
  42. package/lib/compiler/tweak-assocs.js +16 -11
  43. package/lib/compiler/utils.js +5 -0
  44. package/lib/edm/annotations/genericTranslation.js +93 -21
  45. package/lib/edm/csn2edm.js +230 -115
  46. package/lib/edm/edm.js +305 -226
  47. package/lib/edm/edmPreprocessor.js +509 -438
  48. package/lib/edm/edmUtils.js +31 -45
  49. package/lib/gen/Dictionary.json +98 -22
  50. package/lib/gen/language.checksum +1 -1
  51. package/lib/gen/language.interp +10 -30
  52. package/lib/gen/language.tokens +105 -114
  53. package/lib/gen/languageLexer.interp +1 -34
  54. package/lib/gen/languageLexer.js +889 -1007
  55. package/lib/gen/languageLexer.tokens +95 -106
  56. package/lib/gen/languageParser.js +20786 -22199
  57. package/lib/json/csnVersion.js +10 -11
  58. package/lib/json/from-csn.js +59 -51
  59. package/lib/json/to-csn.js +10 -10
  60. package/lib/language/antlrParser.js +2 -2
  61. package/lib/language/docCommentParser.js +62 -39
  62. package/lib/language/errorStrategy.js +52 -40
  63. package/lib/language/genericAntlrParser.js +348 -229
  64. package/lib/language/language.g4 +629 -653
  65. package/lib/language/multiLineStringParser.js +14 -42
  66. package/lib/language/textUtils.js +44 -0
  67. package/lib/main.d.ts +46 -43
  68. package/lib/main.js +108 -79
  69. package/lib/model/csnRefs.js +34 -7
  70. package/lib/model/csnUtils.js +337 -332
  71. package/lib/model/enrichCsn.js +1 -0
  72. package/lib/model/revealInternalProperties.js +30 -10
  73. package/lib/model/sortViews.js +32 -31
  74. package/lib/modelCompare/compare.js +6 -6
  75. package/lib/optionProcessor.js +73 -46
  76. package/lib/render/.eslintrc.json +1 -1
  77. package/lib/render/DuplicateChecker.js +4 -7
  78. package/lib/render/manageConstraints.js +70 -2
  79. package/lib/render/toCdl.js +1042 -882
  80. package/lib/render/toHdbcds.js +195 -245
  81. package/lib/render/toRename.js +44 -22
  82. package/lib/render/toSql.js +225 -241
  83. package/lib/render/utils/common.js +145 -15
  84. package/lib/render/utils/sql.js +20 -19
  85. package/lib/sql-identifier.js +6 -0
  86. package/lib/transform/db/.eslintrc.json +4 -3
  87. package/lib/transform/db/associations.js +2 -2
  88. package/lib/transform/db/cdsPersistence.js +5 -15
  89. package/lib/transform/db/constraints.js +4 -2
  90. package/lib/transform/db/expansion.js +22 -16
  91. package/lib/transform/db/flattening.js +109 -80
  92. package/lib/transform/db/transformExists.js +7 -7
  93. package/lib/transform/db/views.js +9 -6
  94. package/lib/transform/draft/.eslintrc.json +2 -2
  95. package/lib/transform/draft/db.js +6 -6
  96. package/lib/transform/draft/odata.js +6 -7
  97. package/lib/transform/forHanaNew.js +62 -48
  98. package/lib/transform/forOdataNew.js +49 -50
  99. package/lib/transform/localized.js +31 -20
  100. package/lib/transform/odata/toFinalBaseType.js +16 -14
  101. package/lib/transform/odata/typesExposure.js +146 -198
  102. package/lib/transform/odata/utils.js +1 -38
  103. package/lib/transform/transformUtilsNew.js +67 -84
  104. package/lib/transform/translateAssocsToJoins.js +7 -3
  105. package/lib/transform/universalCsn/.eslintrc.json +2 -2
  106. package/lib/transform/universalCsn/coreComputed.js +16 -9
  107. package/lib/transform/universalCsn/universalCsnEnricher.js +60 -10
  108. package/lib/utils/file.js +3 -3
  109. package/lib/utils/moduleResolve.js +13 -6
  110. package/lib/utils/timetrace.js +20 -21
  111. package/package.json +35 -4
  112. package/share/messages/message-explanations.json +2 -1
  113. package/share/messages/syntax-expected-integer.md +37 -0
  114. package/doc/ApiMigration.md +0 -237
  115. package/doc/CommandLineMigration.md +0 -58
  116. package/doc/ErrorMessages.md +0 -175
  117. package/doc/FioriAnnotations.md +0 -94
  118. package/doc/ODataTransformation.md +0 -273
  119. package/lib/backends.js +0 -529
  120. package/lib/fix_antlr4-8_warning.js +0 -56
  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 -296
  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
@@ -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,6 +45,7 @@ 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
48
+ 'anno-unstable-array': { severity: 'Warning' },
45
49
  'anno-invalid-sql-element': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
46
50
  'anno-invalid-sql-struct': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
47
51
  'anno-invalid-sql-kind': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
@@ -62,9 +66,9 @@ const centralMessages = {
62
66
  'assoc-as-type': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: allow more, but not all
63
67
  'def-unexpected-paramview-assoc': { severity: 'Error' },
64
68
  'def-unexpected-calcview-assoc': { severity: 'Error' },
65
-
69
+ 'chained-array-of': { severity: 'Error' },
66
70
  'check-proper-type': { severity: 'Error', configurableFor: [ 'compile' ] },
67
- 'check-proper-type-of': { severity: 'Info', errorFor: [ 'for.odata', 'to.edmx', 'to.hdbcds', 'to.sql', 'to.rename' ] },
71
+ 'check-proper-type-of': { severity: 'Info', errorFor: [ 'for.odata', 'to.edmx', 'to.hdbcds', 'to.sql', 'to.hdi', 'to.rename' ] },
68
72
 
69
73
  'expr-no-filter': { severity: 'Error', configurableFor: 'deprecated' },
70
74
 
@@ -77,6 +81,8 @@ const centralMessages = {
77
81
  'expected-type': { severity: 'Error' },
78
82
  'ref-sloppy-type': { severity: 'Error' },
79
83
  'type-unexpected-typeof': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: make it non-config
84
+ 'type-ignoring-argument': { severity: 'Error', configurableFor: true },
85
+ 'type-expected-builtin': { severity: 'Error', configurableFor: true },
80
86
  'expected-actionparam-type': { severity: 'Error' },
81
87
  'ref-sloppy-actionparam-type': { severity: 'Error' },
82
88
  'expected-event-type': { severity: 'Error' },
@@ -97,6 +103,7 @@ const centralMessages = {
97
103
  'query-unexpected-assoc-hdbcds': { severity: 'Error' },
98
104
  'query-unexpected-structure-hdbcds': { severity: 'Error' },
99
105
  'query-ignoring-param-nullability': { severity: 'Info' },
106
+ 'query-expected-identifier': { severity: 'Error' },
100
107
 
101
108
  'recalculated-localized': { severity: 'Info' }, // KEEP: Downgrade in lib/transform/translateAssocsToJoins.js
102
109
  'redirected-implicitly-ambiguous': { severity: 'Error', configurableFor: true }, // does not hurt us - TODO: ref-ambiguous-target
@@ -111,6 +118,7 @@ const centralMessages = {
111
118
  'ref-obsolete-parameters': { severity: 'Error', configurableFor: true }, // does not hurt us
112
119
  'ref-undefined-param': { severity: 'Error' },
113
120
  'ref-rejected-on': { severity: 'Error' },
121
+ 'ref-expected-element': { severity: 'Error' },
114
122
 
115
123
  'rewrite-key-not-covered-explicit': { severity: 'Error', configurableFor: 'deprecated' },
116
124
  'rewrite-key-not-covered-implicit': { severity: 'Error', configurableFor: 'deprecated' },
@@ -123,14 +131,11 @@ const centralMessages = {
123
131
  'service-nested-context': { severity: 'Error', configurableFor: true }, // does not hurt compile, TODO
124
132
  'service-nested-service': { severity: 'Error', configurableFor: 'deprecated' }, // not supported yet
125
133
 
126
- 'syntax-anno-after-enum': { severity: 'Error', configurableFor: true }, // does not hurt
127
- 'syntax-anno-after-params': { severity: 'Error', configurableFor: true }, // does not hurt
128
- 'syntax-anno-after-struct': { severity: 'Error', configurableFor: true }, // does not hurt
129
- 'syntax-csn-expected-cardinality': { severity: 'Error' }, // TODO: more than 30 chars
130
- 'syntax-csn-expected-length': { severity: 'Error' },
131
- 'syntax-csn-expected-translation': { severity: 'Error' }, // TODO: more than 30 chars
132
- 'syntax-csn-required-subproperty': { severity: 'Error' }, // TODO: more than 30 chars
133
- 'syntax-csn-unexpected-property': { severity: 'Error', configurableFor: true }, // is the removed
134
+ 'syntax-expected-cardinality': { severity: 'Error' },
135
+ 'syntax-expected-length': { severity: 'Error' },
136
+ 'syntax-expected-translation': { severity: 'Error' },
137
+ 'syntax-required-subproperty': { severity: 'Error' },
138
+ 'syntax-unexpected-property': { severity: 'Error', configurableFor: true }, // is the removed
134
139
  'syntax-deprecated-ident': { severity: 'Error', configurableFor: true },
135
140
  'syntax-fragile-alias': { severity: 'Error', configurableFor: true },
136
141
  'syntax-fragile-ident': { severity: 'Error', configurableFor: true },
@@ -142,6 +147,10 @@ const centralMessages = {
142
147
  'syntax-invalid-escape': { severity: 'Error' },
143
148
  'syntax-missing-escape': { severity: 'Error' },
144
149
 
150
+ 'syntax-expected-integer': { severity: 'Error' },
151
+ 'syntax-invalid-masked': { severity: 'Error', configurableFor: true },
152
+ 'syntax-unexpected-null': { severity: 'Error', configurableFor: true },
153
+
145
154
  'type-managed-composition': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: non-config
146
155
 
147
156
  'def-missing-element': { severity: 'Error' },
@@ -151,38 +160,82 @@ const centralMessages = {
151
160
  'composition-as-key': { severity: 'Error', configurableFor: 'deprecated' }, // is confusing and not supported
152
161
  'odata-spec-violation-array': { severity: 'Warning' }, // more than 30 chars
153
162
  'odata-spec-violation-constraints': { severity: 'Info' }, // more than 30 chars
154
- 'odata-spec-violation-type': { severity: 'Error', configurableFor: [ 'to.edmx' ] },
163
+ 'odata-spec-violation-id': { severity: 'Error', configurableFor: true },
164
+ 'odata-spec-violation-type': { severity: 'Error', configurableFor: true },
165
+ 'odata-spec-violation-type-unknown': { severity: 'Warning' },
155
166
  'odata-spec-violation-no-key': { severity: 'Warning' },
156
- 'odata-spec-violation-key-array': { severity: 'Error' }, // more than 30 chars
157
- 'odata-spec-violation-key-null': { severity: 'Error' }, // more than 30 chars
167
+ 'odata-spec-violation-key-array': { severity: 'Error', configurableFor: true }, // more than 30 chars
168
+ 'odata-spec-violation-key-null': { severity: 'Error', configurableFor: true }, // more than 30 chars
158
169
  'odata-spec-violation-key-type': { severity: 'Warning' }, // more than 30 chars
159
170
  'odata-spec-violation-property-name': { severity: 'Warning' }, // more than 30 chars
160
- 'odata-spec-violation-namespace-name': { severity: 'Warning' }, // more than 30 chars
161
171
  };
162
172
 
173
+ // Old/Deprecated message IDs that we only still use for backwards-compatibility.
174
+ // We keep them in a separate array for easier access. No need to go through all
175
+ // existing messages and search for the old one in `oldNames` property.
176
+ // The keys will be added to `oldNames` of the new message, which is used for reclassification.
177
+ const oldMessageIds = createDict({
178
+ 'old-anno-duplicate': 'anno-duplicate', // Example
179
+ });
180
+
181
+ // Set up the old-to-new message ID mapping in the message registry.
182
+ for (const oldName in oldMessageIds) {
183
+ const newName = oldMessageIds[oldName];
184
+ if (centralMessages[oldName])
185
+ throw new CompilerAssertion(`Mapping from ${oldName} not possible: ID is still used in message registry.`);
186
+ if (!centralMessages[newName])
187
+ throw new CompilerAssertion(`Mapping from ${oldName} to new message ID ${newName} does not exist!`);
188
+
189
+ if (!centralMessages[newName].oldNames)
190
+ centralMessages[newName].oldNames = [ oldName ];
191
+ else
192
+ centralMessages[newName].oldNames.push(oldName);
193
+ }
194
+
195
+
163
196
  // For messageIds, where no text has been provided via code (central def)
164
197
  const centralMessageTexts = {
198
+ 'api-invalid-option': {
199
+ std: 'Option $(NAME) is deprecated! Use SNAPI options instead',
200
+ magicVars: 'Option “magicVars” is deprecated! Use “variableReplacements” instead. See <https://cap.cloud.sap/docs/guides/databases#configuring-variables> for details',
201
+ user: 'Option “variableReplacements” expects “$user” instead of “user”. See <https://cap.cloud.sap/docs/guides/databases#configuring-variables> for details',
202
+ locale: 'Option “variableReplacements” expects “$user.locale” instead of “locale”. See <https://cap.cloud.sap/docs/guides/databases#configuring-variables> for details',
203
+ 'noDollar': 'Option “variableReplacements” does not know $(NAME). Did you forget a leading “$”?'
204
+ },
205
+
165
206
  'anno-duplicate': 'Duplicate assignment with $(ANNO)',
207
+ 'anno-duplicate-unrelated-layer': 'Duplicate assignment with $(ANNO)',
208
+ 'anno-unstable-array': 'Unstable order of array items due to repeated assignments for $(ANNO) in unrelated layers',
166
209
  'anno-mismatched-ellipsis': 'An array with $(CODE) can only be used if there is an assignment below with an array value',
167
210
  'anno-unexpected-ellipsis': 'No base annotation available to apply $(CODE)',
168
211
  'anno-unexpected-ellipsis-layers': 'No base annotation available to apply $(CODE)',
169
- 'missing-type-parameter': 'Missing value for type parameter $(NAME) in reference to type $(ID)',
170
- 'syntax-csn-expected-object': 'Expected object for property $(PROP)',
171
- 'syntax-csn-expected-column': 'Expected object or string \'*\' for property $(PROP)',
172
- 'syntax-csn-expected-natnum': 'Expected non-negative number for property $(PROP)',
173
- 'syntax-csn-expected-cardinality': 'Expected non-negative number or string \'*\' for property $(PROP)',
174
- 'syntax-csn-expected-reference': 'Expected non-empty string or object for property $(PROP)',
175
- 'syntax-csn-expected-term': 'Expected non-empty string or object for property $(PROP)',
176
- 'syntax-anno-after-struct': 'Avoid annotation assignments after structure definitions',
177
- 'syntax-anno-after-enum': 'Avoid annotation assignments after enum definitions',
178
- 'syntax-anno-after-params': 'Avoid annotation assignments after parameters',
212
+ 'chained-array-of': '"Array of"/"many" must not be chained with another "array of"/"many" inside a service',
213
+
214
+ 'name-duplicate-element': {
215
+ 'std': 'Generated element $(NAME) conflicts with another element',
216
+ 'flatten-element-gen': 'Generated element $(NAME) conflicts with other generated element',
217
+ 'flatten-element-exist': 'Flattened name of structured element conflicts with existing element $(NAME)',
218
+ 'flatten-fkey-gen': 'Duplicate definition of foreign key element $(NAME) for association $(ART)',
219
+ 'flatten-fkey-exists': 'Generated foreign key element $(NAME) for association $(ART) conflicts with existing element',
220
+ },
221
+
222
+ 'syntax-unexpected-ellipsis': {
223
+ std: 'Expected no more than one $(CODE)',
224
+ 'nested-array': 'Unexpected $(CODE) in nested array'
225
+ },
226
+ 'syntax-expected-object': 'Expected object for property $(PROP)',
227
+ 'syntax-expected-column': 'Expected object or string \'*\' for property $(PROP)',
228
+ 'syntax-expected-natnum': 'Expected non-negative number for property $(PROP)',
229
+ 'syntax-expected-cardinality': 'Expected non-negative number or string \'*\' for property $(PROP)',
230
+ 'syntax-expected-reference': 'Expected non-empty string or object for property $(PROP)',
231
+ 'syntax-expected-term': 'Expected non-empty string or object for property $(PROP)',
179
232
  'syntax-dollar-ident': {
180
233
  std: 'An artifact starting with $(NAME) might shadow a special variable - replace by another name',
181
234
  $tableAlias: 'A table alias name starting with $(NAME) might shadow a special variable - replace by another name',
182
235
  $tableImplicit: 'The resulting table alias starts with $(NAME) and might shadow a special variable - specify another name with $(KEYWORD)',
183
236
  mixin: 'A mixin name starting with $(NAME) might shadow a special variable - replace by another name' ,
184
237
  },
185
- 'syntax-csn-expected-length': {
238
+ 'syntax-expected-length': {
186
239
  std: 'Expected array in $(PROP) to have at least $(N) items',
187
240
  one: 'Expected array in $(PROP) to have at least one item',
188
241
  suffix: 'With sibling property $(OTHERPROP), expected array in $(PROP) to have at least one item',
@@ -204,6 +257,30 @@ const centralMessageTexts = {
204
257
  std: 'Missing escape. Replace $(CODE) with $(NEWCODE)',
205
258
  placeholder: 'Placeholders are not supported. Replace $(CODE) with $(NEWCODE)',
206
259
  },
260
+ 'syntax-expected-integer': {
261
+ std: 'A safe integer is expected here',
262
+ normal: 'An integer number is expected here',
263
+ unsafe: 'The provided integer is too large',
264
+ },
265
+ 'syntax-duplicate-argument': {
266
+ std: 'Unexpected argument $(CODE)',
267
+ unknown: 'Unknown argument $(CODE)',
268
+ duplicate: 'Duplicate argument $(CODE)',
269
+ },
270
+ 'syntax-invalid-literal': {
271
+ 'std': 'Invalid literal',
272
+ 'uneven-hex': 'A binary literal must have an even number of characters',
273
+ 'invalid-hex': 'A binary literal must only contain characters 0-9, a-f and A-F',
274
+ 'time': 'Expected time\'hh:mm:ss\' where hh, mm and the optional ss are numbers',
275
+ 'date': 'Expected date\'YYYY-MM-DD\' where YYYY, MM and DD are numbers',
276
+ 'timestamp': 'Expected timestamp\'YYYY-MM-DD hh:mm:ss.u…u\' where YYYY, MM, DD, hh, mm, ss and u are numbers (optional 1-7×u)',
277
+ },
278
+ 'syntax-unexpected-null': 'Keyword $(KEYWORD) must appear after the enum definition and not before',
279
+ 'syntax-unexpected-vocabulary': {
280
+ std: 'Annotations can\'t be defined inside contexts or services',
281
+ service: 'Annotations can\'t be defined inside services',
282
+ context: 'Annotations can\'t be defined inside contexts',
283
+ },
207
284
  'ref-undefined-def': {
208
285
  std: 'Artifact $(ART) has not been found',
209
286
  // TODO: proposal 'No definition of $(NAME) found',
@@ -213,7 +290,8 @@ const centralMessageTexts = {
213
290
  // TODO: proposal 'No definition found for $(NAME)',
214
291
  'ref-undefined-element': {
215
292
  std: 'Element $(ART) has not been found',
216
- element: 'Artifact $(ART) has no element $(MEMBER)'
293
+ element: 'Artifact $(ART) has no element $(MEMBER)',
294
+ aspect: 'Element $(ID) has not been found in the anonymous target aspect'
217
295
  },
218
296
  'ref-unknown-var': {
219
297
  std: 'Replacement $(ID) not found'
@@ -224,6 +302,10 @@ const centralMessageTexts = {
224
302
  mixin: 'Do not refer to a mixin like $(ID) in the explicit ON of a redirection',
225
303
  alias: 'Do not refer to a source element (via table alias $(ID)) in the explicit ON of a redirection',
226
304
  },
305
+ 'ref-expected-element': {
306
+ std: 'Expected element reference',
307
+ magicVar: 'Only elements of magic variable $(ID) can be selected',
308
+ },
227
309
  'type-unexpected-typeof': {
228
310
  std: 'Unexpected $(KEYWORD) for the type reference here',
229
311
  type: 'Unexpected $(KEYWORD) in type of a type definition',
@@ -231,6 +313,19 @@ const centralMessageTexts = {
231
313
  param: 'Unexpected $(KEYWORD) for the type of a parameter definition',
232
314
  select: 'Unexpected $(KEYWORD) for type references in queries',
233
315
  },
316
+
317
+ 'type-missing-argument': 'Missing value for argument $(NAME) in reference to type $(ID)',
318
+ 'type-ignoring-argument': 'Too many arguments for type $(ART)',
319
+ 'type-unexpected-argument': {
320
+ std: 'Too many arguments for type $(ART)',
321
+ type: 'Unexpected argument $(PROP) for type $(ART) with base type $(TYPE)',
322
+ builtin: 'Unexpected argument $(PROP) for type $(ART)',
323
+ 'non-scalar': 'Only scalar types can have arguments',
324
+ max: 'Expecting argument $(PROP) for type $(TYPE) to not exceed $(NUMBER)',
325
+ min: 'Expecting argument $(PROP) for type $(TYPE) to be greater than or equal to $(NUMBER)',
326
+ 'incorrect-type': 'Expected $(NAMES) for argument $(PROP), but found $(CODE)',
327
+ },
328
+
234
329
  'anno-builtin': 'Builtin types should not be annotated. Use custom type instead',
235
330
  'anno-undefined-def': 'Artifact $(ART) has not been found',
236
331
  'anno-undefined-art': 'No artifact has been found with name $(NAME)',
@@ -296,6 +391,10 @@ const centralMessageTexts = {
296
391
  std: 'Ignoring nullability constraint on parameter when generating SAP HANA CDS view',
297
392
  sql: 'Ignoring nullability constraint on parameter when generating SQL view'
298
393
  },
394
+ 'query-expected-identifier': {
395
+ std: 'Expected identifier for select item',
396
+ assoc: 'Expected identifier as the association\'s name',
397
+ },
299
398
 
300
399
  'ref-sloppy-type': 'A type or an element is expected here',
301
400
  'ref-sloppy-actionparam-type': 'A type, an element, or a service entity is expected here',
@@ -312,11 +411,16 @@ const centralMessageTexts = {
312
411
  'i18n-different-value': 'Different translation for key $(PROP) of language $(OTHERPROP) in unrelated layers',
313
412
 
314
413
  // OData version dependent messages
315
- 'odata-spec-violation-array': 'Unexpected array type for $(API)',
316
- 'odata-spec-violation-param' : 'Expected parameter to be typed with either scalar or structured type for $(API)',
317
- 'odata-spec-violation-returns': 'Expected $(KIND) to return one or many values of scalar, complex, entity or view type for $(API)',
318
- 'odata-spec-violation-assoc': 'Unexpected association in structured type for $(API)',
319
- 'odata-spec-violation-constraints': 'Partial referential constraints produced for $(API)',
414
+ 'odata-spec-violation-array': 'Unexpected array type for OData $(VERSION)',
415
+ 'odata-spec-violation-param' : 'Expected parameter to be typed with either scalar or structured type for OData $(VERSION)',
416
+ 'odata-spec-violation-returns': 'Expected $(KIND) to return one or many values of scalar, complex, entity or view type for OData $(VERSION)',
417
+ 'odata-spec-violation-assoc': 'Unexpected association in structured type for OData $(VERSION)',
418
+ 'odata-spec-violation-constraints': 'Partial referential constraints produced for OData $(VERSION)',
419
+ 'odata-spec-violation-id': {
420
+ std: 'Expected EDM name $(ID) to start with a letter or underscore, followed by at most 127 letters, underscores or digits',
421
+ 'v2firstchar': 'Unexpected first character $(PROP) of EDM Name $(ID) for OData $(VERSION)',
422
+ 'qualifier': 'Expected annotation qualifier $(ID) to start with a letter or underscore, followed by at most 127 letters, underscores or digits'
423
+ },
320
424
  // version independent messages
321
425
  'odata-spec-violation-key-array': {
322
426
  std: 'Unexpected array type for element $(NAME)',
@@ -331,31 +435,42 @@ const centralMessageTexts = {
331
435
  scalar: 'Unexpected $(TYPE) mapped to $(ID) as type for key element' // flat
332
436
  },
333
437
  'odata-spec-violation-no-key': 'Expected entity to have a primary key',
334
- 'odata-spec-violation-type': 'Expected element to have a type',
438
+ 'odata-spec-violation-type-unknown': 'Unknown Edm Type $(TYPE)',
439
+ 'odata-spec-violation-type': {
440
+ std: 'Expected element to have a type',
441
+ incompatible: 'Unexpected EDM Type $(TYPE) for OData $(VERSION)',
442
+ facet: 'Unexpected EDM Type facet $(NAME) of type $(TYPE) for OData $(VERSION)',
443
+ },
335
444
  'odata-spec-violation-property-name': 'Expected element name to be different from declaring $(KIND)',
336
- 'odata-spec-violation-namespace': 'Expected service name not to be one of the reserved names $(NAMES)',
445
+ 'odata-spec-violation-namespace': {
446
+ std: 'Expected service name not to be one of the reserved names $(NAMES)',
447
+ length: 'Expected service name not to exceed 511 characters',
448
+ },
337
449
  // Other odata/edm errors
338
450
  'odata-definition-exists': {
339
451
  std: 'Entity can\'t be created due to name collision with existing definition $(NAME)',
340
452
  proxy: 'No proxy entity created due to name collision with existing definition $(NAME) of kind $(KIND)'
341
- }
453
+ },
454
+ 'odata-navigation': 'No OData navigation property generated, target $(TARGET) is outside of service $(SERVICE)'
342
455
  }
343
456
 
344
457
  /**
345
458
  * Configuration for a message in the central message register.
346
459
  *
347
460
  * @typedef {object} MessageConfig
348
- * @property {CSN.MessageSeverity} severity Default severity for the message.
461
+ * @property {MessageSeverity} severity Default severity for the message.
349
462
  * @property {string[]|'deprecated'|true} [configurableFor]
350
463
  * Whether the error can be reclassified to a warning or lower.
351
464
  * If not `true` then an array is expected with specified modules in which the error is downgradable.
352
465
  * Only has an effect if default severity is 'Error'.
353
- * 'deprecated': severity can only be changed with deprecated.downgradableErrors.
466
+ * 'deprecated': severity can only be changed with deprecated._downgradableErrors.
354
467
  * TODO: Value `true` is temporary. Use an array instead.
355
468
  * @property {string[]} [errorFor] Array of module names where the message shall be reclassified to an error.
356
469
  * @property {boolean} [throughMessageCall]
357
470
  * If set, it means that a message-id was added to the registry in test-mode through a `message.<severity>()`
358
471
  * call. Used for ensuring that all calls with the same message-id have the same severity.
472
+ * @property {string[]} [oldNames] Aliases for the message id. Used for reclassification as well as "explain" messages.
473
+ * Don't set this property directly! Append to object oldMessageIds instead!
359
474
  */
360
475
 
361
- module.exports = { centralMessages, centralMessageTexts };
476
+ module.exports = { centralMessages, centralMessageTexts, oldMessageIds };