@sap/cds-compiler 3.4.2 → 3.5.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 (143) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +1 -0
  3. package/bin/cds_update_identifiers.js +5 -5
  4. package/bin/cdsc.js +15 -16
  5. package/bin/cdshi.js +19 -6
  6. package/doc/CHANGELOG_ARCHIVE.md +2 -2
  7. package/doc/CHANGELOG_BETA.md +9 -1
  8. package/doc/CHANGELOG_DEPRECATED.md +2 -0
  9. package/lib/api/main.js +61 -59
  10. package/lib/api/options.js +4 -2
  11. package/lib/api/validate.js +2 -2
  12. package/lib/base/cleanSymbols.js +2 -3
  13. package/lib/base/dictionaries.js +6 -6
  14. package/lib/base/error.js +2 -2
  15. package/lib/base/keywords.js +6 -6
  16. package/lib/base/location.js +11 -12
  17. package/lib/base/message-registry.js +177 -58
  18. package/lib/base/messages.js +252 -180
  19. package/lib/base/model.js +14 -11
  20. package/lib/base/node-helpers.js +9 -10
  21. package/lib/base/optionProcessorHelper.js +138 -129
  22. package/lib/checks/.eslintrc.json +2 -0
  23. package/lib/checks/actionsFunctions.js +5 -5
  24. package/lib/checks/annotationsOData.js +4 -4
  25. package/lib/checks/arrayOfs.js +1 -1
  26. package/lib/checks/cdsPersistence.js +1 -1
  27. package/lib/checks/checkForTypes.js +3 -3
  28. package/lib/checks/defaultValues.js +3 -3
  29. package/lib/checks/elements.js +7 -7
  30. package/lib/checks/emptyOrOnlyVirtual.js +2 -2
  31. package/lib/checks/foreignKeys.js +1 -1
  32. package/lib/checks/invalidTarget.js +4 -4
  33. package/lib/checks/managedInType.js +1 -1
  34. package/lib/checks/managedWithoutKeys.js +1 -1
  35. package/lib/checks/nonexpandableStructured.js +5 -3
  36. package/lib/checks/nullableKeys.js +1 -1
  37. package/lib/checks/onConditions.js +5 -6
  38. package/lib/checks/parameters.js +1 -1
  39. package/lib/checks/queryNoDbArtifacts.js +2 -2
  40. package/lib/checks/selectItems.js +4 -4
  41. package/lib/checks/sql-snippets.js +4 -4
  42. package/lib/checks/types.js +7 -7
  43. package/lib/checks/utils.js +4 -4
  44. package/lib/checks/validator.js +16 -13
  45. package/lib/compiler/.eslintrc.json +4 -1
  46. package/lib/compiler/assert-consistency.js +8 -7
  47. package/lib/compiler/builtins.js +14 -14
  48. package/lib/compiler/checks.js +123 -48
  49. package/lib/compiler/define.js +12 -13
  50. package/lib/compiler/extend.js +266 -60
  51. package/lib/compiler/finalize-parse-cdl.js +10 -5
  52. package/lib/compiler/index.js +17 -14
  53. package/lib/compiler/populate.js +14 -6
  54. package/lib/compiler/propagator.js +2 -0
  55. package/lib/compiler/resolve.js +2 -15
  56. package/lib/compiler/shared.js +27 -16
  57. package/lib/compiler/tweak-assocs.js +5 -6
  58. package/lib/compiler/utils.js +20 -0
  59. package/lib/edm/annotations/genericTranslation.js +604 -358
  60. package/lib/edm/annotations/preprocessAnnotations.js +39 -35
  61. package/lib/edm/csn2edm.js +275 -222
  62. package/lib/edm/edm.js +17 -3
  63. package/lib/edm/edmAnnoPreprocessor.js +6 -6
  64. package/lib/edm/edmInboundChecks.js +2 -2
  65. package/lib/edm/edmPreprocessor.js +107 -77
  66. package/lib/edm/edmUtils.js +44 -5
  67. package/lib/gen/Dictionary.json +210 -8
  68. package/lib/gen/language.checksum +1 -1
  69. package/lib/gen/language.interp +67 -63
  70. package/lib/gen/language.tokens +81 -81
  71. package/lib/gen/languageLexer.interp +4 -10
  72. package/lib/gen/languageLexer.js +854 -869
  73. package/lib/gen/languageLexer.tokens +79 -81
  74. package/lib/gen/languageParser.js +14309 -13832
  75. package/lib/inspect/inspectModelStatistics.js +2 -2
  76. package/lib/inspect/inspectPropagation.js +6 -6
  77. package/lib/inspect/inspectUtils.js +2 -2
  78. package/lib/json/from-csn.js +102 -55
  79. package/lib/json/to-csn.js +119 -198
  80. package/lib/language/antlrParser.js +5 -2
  81. package/lib/language/docCommentParser.js +6 -6
  82. package/lib/language/errorStrategy.js +43 -23
  83. package/lib/language/genericAntlrParser.js +113 -133
  84. package/lib/language/language.g4 +1550 -1506
  85. package/lib/language/multiLineStringParser.js +3 -3
  86. package/lib/language/textUtils.js +2 -2
  87. package/lib/main.js +3 -3
  88. package/lib/model/csnRefs.js +5 -0
  89. package/lib/model/csnUtils.js +130 -122
  90. package/lib/model/revealInternalProperties.js +1 -1
  91. package/lib/model/sortViews.js +4 -6
  92. package/lib/modelCompare/compare.js +2 -2
  93. package/lib/modelCompare/utils/.eslintrc.json +22 -0
  94. package/lib/modelCompare/utils/filter.js +100 -0
  95. package/lib/optionProcessor.js +5 -0
  96. package/lib/render/.eslintrc.json +1 -0
  97. package/lib/render/DuplicateChecker.js +1 -1
  98. package/lib/render/manageConstraints.js +12 -12
  99. package/lib/render/toCdl.js +311 -276
  100. package/lib/render/toHdbcds.js +97 -94
  101. package/lib/render/toRename.js +5 -5
  102. package/lib/render/toSql.js +127 -223
  103. package/lib/render/utils/common.js +141 -108
  104. package/lib/render/utils/delta.js +227 -0
  105. package/lib/render/utils/sql.js +22 -6
  106. package/lib/render/utils/stringEscapes.js +3 -3
  107. package/lib/transform/db/.eslintrc.json +2 -0
  108. package/lib/transform/db/applyTransformations.js +3 -3
  109. package/lib/transform/db/assertUnique.js +13 -12
  110. package/lib/transform/db/associations.js +5 -5
  111. package/lib/transform/db/cdsPersistence.js +10 -8
  112. package/lib/transform/db/constraints.js +14 -14
  113. package/lib/transform/db/expansion.js +20 -22
  114. package/lib/transform/db/flattening.js +24 -42
  115. package/lib/transform/db/groupByOrderBy.js +3 -3
  116. package/lib/transform/db/temporal.js +6 -6
  117. package/lib/transform/db/transformExists.js +23 -23
  118. package/lib/transform/db/views.js +16 -16
  119. package/lib/transform/draft/.eslintrc.json +1 -35
  120. package/lib/transform/draft/db.js +10 -10
  121. package/lib/transform/draft/odata.js +2 -2
  122. package/lib/transform/forOdataNew.js +8 -29
  123. package/lib/transform/forRelationalDB.js +16 -6
  124. package/lib/transform/localized.js +11 -10
  125. package/lib/transform/odata/toFinalBaseType.js +41 -27
  126. package/lib/transform/odata/typesExposure.js +113 -47
  127. package/lib/transform/parseExpr.js +209 -106
  128. package/lib/transform/transformUtilsNew.js +17 -10
  129. package/lib/transform/translateAssocsToJoins.js +24 -19
  130. package/lib/transform/universalCsn/coreComputed.js +10 -10
  131. package/lib/transform/universalCsn/universalCsnEnricher.js +26 -26
  132. package/lib/transform/universalCsn/utils.js +3 -3
  133. package/lib/utils/file.js +5 -5
  134. package/lib/utils/moduleResolve.js +13 -13
  135. package/lib/utils/objectUtils.js +6 -6
  136. package/lib/utils/term.js +5 -2
  137. package/lib/utils/timetrace.js +51 -24
  138. package/package.json +5 -8
  139. package/share/messages/check-proper-type-of.md +1 -1
  140. package/share/messages/message-explanations.json +1 -1
  141. package/share/messages/redirected-to-complex.md +4 -4
  142. package/share/messages/{syntax-expecting-integer.md → syntax-expecting-unsigned-int.md} +7 -4
  143. package/lib/modelCompare/filter.js +0 -83
@@ -30,8 +30,8 @@
30
30
 
31
31
  'use strict';
32
32
 
33
- const { CompilerAssertion } = require("./error");
34
- const { createDict } = require("../utils/objectUtils");
33
+ const { CompilerAssertion } = require('./error');
34
+ const { createDict } = require('../utils/objectUtils');
35
35
 
36
36
  /**
37
37
  * Central register of messages and their configuration.
@@ -116,6 +116,7 @@ const centralMessages = {
116
116
  'type-ambiguous-target': { severity: 'Warning' },
117
117
 
118
118
  'ref-autoexposed': { severity: 'Error', configurableFor: 'deprecated' },
119
+ // Published! Used in @sap/cds-lsp; if renamed, add to oldMessageIds and contact colleagues
119
120
  'ref-undefined-art': { severity: 'Error' },
120
121
  'ref-undefined-def': { severity: 'Error' },
121
122
  'ref-undefined-var': { severity: 'Error' },
@@ -137,20 +138,22 @@ const centralMessages = {
137
138
 
138
139
  'expr-unexpected-operator': { severity: 'Error', configurableFor: true },
139
140
 
141
+ // Published! Used in @sap/cds-lsp; if renamed, add to oldMessageIds and contact colleagues
142
+ // Also used by other projects that rely on double-quotes for delimited identifiers.
143
+ 'syntax-deprecated-ident': { severity: 'Error', configurableFor: true },
140
144
  // 'syntax-duplicate-annotate' came late with v3 - make it configurable as
141
145
  // fallback, but then parse.cdl is not supposed to work correctly (it can
142
146
  // then either issue an error or produce a CSN missing some annotations):
143
- 'syntax-duplicate-annotate': { severity: 'Error', configurableFor: true },
144
- 'syntax-unexpected-property': { severity: 'Error' },
145
- 'syntax-deprecated-ident': { severity: 'Error', configurableFor: true },
146
- 'syntax-fragile-alias': { severity: 'Error', configurableFor: true },
147
- 'syntax-fragile-ident': { severity: 'Error', configurableFor: true },
147
+ 'syntax-duplicate-annotate': { severity: 'Error', configurableFor: 'v3' },
148
+ 'syntax-invalid-name': { severity: 'Error', configurableFor: 'v3' },
149
+ 'syntax-missing-as': { severity: 'Error', configurableFor: true },
150
+ 'syntax-unexpected-null': { severity: 'Error', configurableFor: true },
151
+ 'syntax-unexpected-reserved-word': { severity: 'Error', configurableFor: true },
148
152
  'syntax-unknown-escape': { severity: 'Error', configurableFor: true },
149
-
150
153
  'syntax-unsupported-masked': { severity: 'Error', configurableFor: 'v3' },
151
- 'syntax-unexpected-null': { severity: 'Error', configurableFor: true },
152
154
 
153
155
  'type-managed-composition': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: non-config
156
+ 'type-unsupported-precision-change': { severity: 'Error'},
154
157
 
155
158
  'def-missing-element': { severity: 'Error' },
156
159
 
@@ -176,6 +179,12 @@ const centralMessages = {
176
179
  'odata-spec-violation-key-null': { severity: 'Error', configurableFor: true }, // more than 30 chars
177
180
  'odata-spec-violation-key-type': { severity: 'Warning' }, // more than 30 chars
178
181
  'odata-spec-violation-property-name': { severity: 'Warning' }, // more than 30 chars
182
+ 'odata-anno-preproc': { severity: 'Warning', configurableFor: true },
183
+ 'odata-anno-dict': { severity: 'Warning', configurableFor: true },
184
+ 'odata-anno-dict-enum': { severity: 'Error' },
185
+ 'odata-anno-value': { severity: 'Warning', configurableFor: true },
186
+ 'odata-anno-type': { severity: 'Warning', configurableFor: true },
187
+ 'odata-anno-def': { severity: 'Info', configurableFor: true },
179
188
  };
180
189
 
181
190
  // Old/Deprecated message IDs that we only still use for backwards-compatibility.
@@ -190,9 +199,9 @@ const oldMessageIds = createDict({
190
199
  for (const oldName in oldMessageIds) {
191
200
  const newName = oldMessageIds[oldName];
192
201
  if (centralMessages[oldName])
193
- throw new CompilerAssertion(`Mapping from ${oldName} not possible: ID is still used in message registry.`);
202
+ throw new CompilerAssertion(`Mapping from ${ oldName } not possible: ID is still used in message registry.`);
194
203
  if (!centralMessages[newName])
195
- throw new CompilerAssertion(`Mapping from ${oldName} to new message ID ${newName} does not exist!`);
204
+ throw new CompilerAssertion(`Mapping from ${ oldName } to new message ID ${ newName } does not exist!`);
196
205
 
197
206
  if (!centralMessages[newName].oldNames)
198
207
  centralMessages[newName].oldNames = [ oldName ];
@@ -231,30 +240,44 @@ const centralMessageTexts = {
231
240
  'flatten-fkey-gen': 'Duplicate definition of foreign key element $(NAME) for association $(ART)',
232
241
  'flatten-fkey-exists': 'Generated foreign key element $(NAME) for association $(ART) conflicts with existing element',
233
242
  },
234
-
235
- // Syntax messages, both CDL and CSN parser: ----------------------------------
236
- 'syntax-dollar-ident': { // Warning, TODO: make it name-invalid-alias
237
- std: 'An artifact starting with $(NAME) might shadow a special variable - replace by another name',
243
+ 'name-invalid-dollar-alias': { // Warning
244
+ std: 'An alias name starting with $(NAME) might shadow a special variable - replace by another name',
238
245
  $tableAlias: 'A table alias name starting with $(NAME) might shadow a special variable - replace by another name',
239
246
  $tableImplicit: 'The resulting table alias starts with $(NAME) and might shadow a special variable - specify another name with $(KEYWORD)',
240
247
  mixin: 'A mixin name starting with $(NAME) might shadow a special variable - replace by another name',
241
248
  },
242
- // 'syntax-duplicate-excluding' (TODO: also CDL)
249
+
250
+ // Syntax messages, both CDL and CSN parser: ----------------------------------
251
+ 'syntax-deprecated-abstract': {
252
+ std: 'Abstract entity definitions are deprecated; use aspect definitions instead',
253
+ 'strange-kind': 'The property $(PROP) is deprecated; expecting it only with kind $(KIND) to define an aspect',
254
+ },
255
+ 'syntax-duplicate-excluding': {
256
+ std: 'Duplicate $(NAME) in the $(KEYWORD) clause',
257
+ csn: 'Duplicate $(NAME) in property $(PROP)',
258
+ },
259
+ 'syntax-expecting-unsigned-int': { // TODO: test all in SyntaxOnly/
260
+ std: 'A safe non-negative integer is expected here',
261
+ normal: 'A non-negative integer number is expected here',
262
+ unsafe: 'The provided integer is too large',
263
+ csn: 'Expecting a non-negative integer for property $(PROP)'
264
+ },
243
265
  'syntax-ignoring-anno': {
244
- std: 'Annotations can\'t be used at prefix references',
245
- doc: 'Doc comments can\'t be used at prefix references',
266
+ std: 'Annotations can\'t be used in a column with $(CODE)',
267
+ doc: 'Doc comments can\'t be used in a column with $(CODE)',
246
268
  },
247
269
  'syntax-invalid-name': {
248
- std: 'Identifier for name must not be empty', // TODO: use
270
+ std: 'Identifier must consist of at least one character',
249
271
  csn: 'Property name in dictionary $(PARENTPROP) must not be empty',
272
+ as: 'String in property $(PROP) must not be empty', // TODO: use
250
273
  },
251
- 'syntax-invalid-literal': { // TODO: write texts less CDL specific
252
- 'std': 'Invalid literal',
274
+ 'syntax-invalid-literal': {
275
+ 'std': 'Invalid literal value',
253
276
  'uneven-hex': 'A binary literal must have an even number of characters',
254
- 'invalid-hex': 'A binary literal must only contain characters 0-9, a-f and A-F',
255
- 'time': 'Expecting time\'hh:mm:ss\' where hh, mm and the optional ss are numbers',
256
- 'date': 'Expecting date\'YYYY-MM-DD\' where YYYY, MM and DD are numbers',
257
- 'timestamp': 'Expecting 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
+ 'invalid-hex': 'A binary literal must only contain characters 0-9›, a-f and A-F',
278
+ 'time': 'A time literal must look like ‹hh:mm:ss or hh:mm where each letter represents a digit',
279
+ 'date': 'A date literal must look like ‹YYYY-MM-DD where each letter represents a digit',
280
+ 'timestamp': 'A timestamp literal must look like ‹YYYY-MM-DD hh:mm:ss.u…u or YYYY-MM-DD hh:mm where each letter represents a digit, ‹u…u› represents 1 to 7 digits',
258
281
  },
259
282
  'syntax-missing-ellipsis': 'Expecting an array item $(NEWCODE) after an item with $(CODE)',
260
283
  'syntax-unexpected-ellipsis': {
@@ -268,23 +291,52 @@ const centralMessageTexts = {
268
291
  csn: 'The property $(PROP) is not supported',
269
292
  },
270
293
 
271
- // Syntax messages, CDL parser - default: Error ------------------------------
294
+ // Syntax messages, CDL parser -----------------------------------------------
295
+ // 'syntax-deprecated-auto-as', 'syntax-deprecated-ident'
272
296
  'syntax-duplicate-annotate': 'You can\'t refer to $(NAME) repeatedly with property $(PROP) in the same annotate statement',
297
+ 'syntax-duplicate-argument': {
298
+ std: 'Duplicate value for parameter $(NAME)',
299
+ type: 'Duplicate value for type parameter $(NAME)',
300
+ },
273
301
  'syntax-duplicate-extend': {
274
302
  std: 'You can\'t define and refer to $(NAME) repeatedly in the same extend statement',
275
303
  define: 'You can\'t refer to $(NAME) in the same extend statement where it was defined',
276
304
  extend: 'You can\'t refer to $(NAME) repeatedly in the same extend statement',
277
305
  },
278
- 'syntax-invalid-extend': 'Can\'t extend an element with $(KIND)',
306
+ // 'syntax-duplicate-anno', 'syntax-duplicate-doc-comment', 'syntax-duplicate-cardinality',
307
+ // 'syntax-duplicate-property'
308
+ 'syntax-unexpected-reserved-word': '$(CODE) is a reserved word - write $(DELIMITED) instead if you want to use it as name',
279
309
  'syntax-invalid-text-block': 'Missing newline in text block',
310
+ // 'syntax-missing-newline' (Warning), 'syntax-missing-as',
311
+ // 'syntax-missing-token'
312
+ 'syntax-unexpected-null': 'Keyword $(KEYWORD) must appear after the enum definition and not before',
313
+ 'syntax-unexpected-token': {
314
+ std: 'Mismatched $(OFFENDING), expecting $(EXPECTING)',
315
+ unwanted: 'Extraneous $(OFFENDING), expecting $(EXPECTING)'
316
+ },
317
+ 'syntax-unexpected-vocabulary': {
318
+ std: 'Annotations can\'t be defined inside contexts or services', // not used
319
+ service: 'Annotations can\'t be defined inside services',
320
+ context: 'Annotations can\'t be defined inside contexts',
321
+ },
322
+ // 'syntax-unexpected-space', 'syntax-unexpected-doc-comment' (TODO is: -ignoring-, Info)
323
+ // 'syntax-unexpected-alias' (is 'syntax-unexpected-property' in CSN),
324
+ // 'syntax-unexpected-right-paren'
325
+ 'syntax-unsupported-calc-elem': 'Calculated elements are not supported',
280
326
  'syntax-unsupported-param': {
281
327
  std: 'Parameter not supported', // unused
282
- dynamic: 'Dynamic parameter $(NAME) is not supported',
283
- positional: 'Positional parameter $(NAME) is not supported',
328
+ dynamic: 'Dynamic parameter $(CODE) is not supported',
329
+ positional: 'Positional parameter $(CODE) is not supported',
284
330
  },
331
+ // 'syntax-unsupported-method', 'syntax-unsupported-new'
285
332
 
286
333
  // Syntax messages, CSN parser - default: Error ------------------------------
287
334
  // TODO: use one id with text variants instead of several message ids
335
+ 'syntax-deprecated-dollar-syntax': {
336
+ std: 'The property $(PROP) is deprecated; its value is ignored',
337
+ projection: 'The property $(PROP) is deprecated; use property $(SIBLINGPROP) instead of $(OTHERPROP) for the query',
338
+ aspect: 'The property $(PROP) is deprecated; change the kind of the current definition to $(KIND) instead',
339
+ },
288
340
  'syntax-deprecated-property': { // Warning
289
341
  std: 'Deprecated property $(PROP)', // unused
290
342
  'zero': 'Deprecated CSN v0.1.0 property $(PROP) is ignored',
@@ -299,7 +351,6 @@ const centralMessageTexts = {
299
351
 
300
352
  'syntax-expecting-object': 'Expecting object for property $(PROP)',
301
353
  'syntax-expecting-column': 'Expecting object or string \'*\' for property $(PROP)',
302
- 'syntax-expecting-natnum': 'Expecting non-negative number for property $(PROP)',
303
354
  'syntax-expecting-cardinality': 'Expecting non-negative number or string \'*\' for property $(PROP)',
304
355
  'syntax-expecting-reference': 'Expecting non-empty string or object for property $(PROP)',
305
356
  'syntax-expecting-term': 'Expecting non-empty string or object for property $(PROP)',
@@ -314,10 +365,10 @@ const centralMessageTexts = {
314
365
  std: 'Object in $(PROP) must have at least one valid CSN property',
315
366
  as: 'Object in $(PROP) must have at least one valid CSN property other than $(OTHERPROP)',
316
367
  },
317
- // 'syntax-invalid-ref' (Warning?), 'syntax-invalid-kind', 'syntax-invalid-literal' (Warning)
318
368
  'syntax-invalid-string': {
319
369
  std: 'Invalid string value in property $(PROP)',
320
370
  },
371
+ // 'syntax-invalid-ref' (Warning?), 'syntax-invalid-kind', 'syntax-invalid-literal' (Warning)
321
372
  'syntax-missing-property': { // location at sibling or '}' otherwise
322
373
  std: 'Object in $(PARENTPROP) must have the property $(PROP)',
323
374
  sibling: 'Object with property $(SIBLINGPROP) must also have a property $(PROP)',
@@ -335,6 +386,7 @@ const centralMessageTexts = {
335
386
  },
336
387
  // 'syntax-unknown-property' (Warning? Better configurable Error)
337
388
 
389
+ // multi-line strings: --------------------------------------------------------
338
390
  'syntax-unknown-escape': 'Unknown escape sequence $(CODE)',
339
391
  'syntax-invalid-escape': {
340
392
  std: 'Invalid escape sequence $(CODE)',
@@ -342,7 +394,7 @@ const centralMessageTexts = {
342
394
  whitespace: 'Unknown escape sequence: Can\'t escape whitespace',
343
395
  codepoint: 'Undefined code-point for $(CODE)',
344
396
  'unicode-hex': 'Expecting hexadecimal numbers for unicode escape but found $(CODE)',
345
- 'hex-count': 'Expecting $(NUMBER) hexadecimal numbers for escape sequence but found $(CODE)',
397
+ 'hex-count': 'Expecting $(COUNT) hexadecimal numbers for escape sequence but found $(CODE)',
346
398
  'unicode-brace': 'Missing closing brace for unicode escape sequence',
347
399
  'language-identifier': 'Escape sequences in text-block\'s language identifier are not allowed',
348
400
  },
@@ -350,26 +402,8 @@ const centralMessageTexts = {
350
402
  std: 'Missing escape. Replace $(CODE) with $(NEWCODE)',
351
403
  placeholder: 'Placeholders are not supported. Replace $(CODE) with $(NEWCODE)',
352
404
  },
353
- 'syntax-expecting-integer': {
354
- std: 'A safe integer is expected here',
355
- normal: 'An integer number is expected here',
356
- unsafe: 'The provided integer is too large',
357
- },
358
- 'syntax-duplicate-argument': { // TODO: also CDL
359
- std: 'Unexpected argument $(CODE)',
360
- unknown: 'Unknown argument $(CODE)', // huh?
361
- duplicate: 'Duplicate argument $(CODE)',
362
- },
363
- 'syntax-unexpected-null': 'Keyword $(KEYWORD) must appear after the enum definition and not before',
364
- 'syntax-unexpected-vocabulary': {
365
- std: 'Annotations can\'t be defined inside contexts or services',
366
- service: 'Annotations can\'t be defined inside services',
367
- context: 'Annotations can\'t be defined inside contexts',
368
- },
369
- 'syntax-fragile-ident': '$(ID) is a reserved name here - write $(DELIMITED) instead if you want to use it',
370
- 'syntax-unsupported-field': 'Calculated fields are not supported, yet',
371
405
 
372
- // Syntax messages for errorneous references ----------------------------------
406
+ // Messages for errorneous references -----------------------------------------
373
407
  // location at errorneous reference (if possible)
374
408
  'ref-unexpected-self': 'Unexpected $(ID) reference; is valid only in ON-conditions',
375
409
  'ref-undefined-def': {
@@ -385,7 +419,10 @@ const centralMessageTexts = {
385
419
  element: 'Artifact $(ART) has no element $(MEMBER)',
386
420
  aspect: 'Element $(ID) has not been found in the anonymous target aspect'
387
421
  },
388
- 'ref-undefined-var': 'Element or variable $(ID) has not been found',
422
+ 'ref-undefined-var': {
423
+ std: 'Variable $(ID) has not been found',
424
+ alias: 'Variable $(ID) has not been found. Use table alias $(ALIAS) to refer an element with the same name',
425
+ },
389
426
  'ref-unknown-var': {
390
427
  std: 'No replacement found for special variable $(ID)'
391
428
  },
@@ -447,12 +484,34 @@ const centralMessageTexts = {
447
484
  'entity-persistence': 'SAP HANA does not allow associations in entities annotated with $(ANNO)',
448
485
  'target-persistence': 'SAP HANA does not allow associations pointing to entities annotated with $(ANNO)',
449
486
  },
487
+ 'def-unexpected-key': {
488
+ std: '$(ART) can\'t have additional keys',
489
+ // TODO: Better message?
490
+ include: '$(ART) can\'t have additional keys (through include)'
491
+ },
492
+ 'def-unexpected-localized': {
493
+ std: '$(ART) can\'t have localized elements',
494
+ // TODO: Better message?
495
+ include: '$(ART) can\'t have localized elements (through include)',
496
+ },
450
497
 
451
498
  'def-missing-element': {
452
499
  std: 'Expecting entity to have at least one non-virtual element',
453
500
  view: 'Expecting view to have at least one non-virtual element'
454
501
  },
455
502
 
503
+ 'def-invalid-texts-aspect': {
504
+ std: '$(ART) is not valid', // unused
505
+ 'no-aspect': '$(ART) must be an aspect',
506
+ key: '$(ART) must be a key',
507
+ 'no-key': '$(ART) must not be key',
508
+ 'missing': '$(ART) must have an element $(NAME)',
509
+ },
510
+ 'def-invalid-element-type': {
511
+ std: 'Element $(ELEMREF) of $(ART) must be of type $(TYPE)',
512
+ 'texts-aspect-locale': 'Element $(ELEMREF) of $(ART) must be of type $(TYPE) or $(OTHERTYPE)',
513
+ },
514
+
456
515
  'duplicate-definition': {
457
516
  std: 'Duplicate definition of $(NAME)',
458
517
  absolute: 'Duplicate definition of artifact $(NAME)',
@@ -478,7 +537,7 @@ const centralMessageTexts = {
478
537
  'expected-target': 'An entity or an aspect is expected here',
479
538
  'extend-columns': 'Artifact $(ART) can\'t be extended with columns, only projections can',
480
539
  'extend-repeated-intralayer': 'Unstable element order due to repeated extensions in same layer',
481
- 'extend-unexpected-include': 'Can\'t extend $(KIND) with includes',
540
+ 'extend-unexpected-include': 'Can\'t extend $(META) with includes',
482
541
  'ref-expecting-bare-aspect': 'An aspect without elements is expected here',
483
542
 
484
543
  'ext-duplicate-extend-type': 'Duplicate type extension for type $(TYPE)',
@@ -543,7 +602,7 @@ const centralMessageTexts = {
543
602
  // version independent messages
544
603
  'odata-spec-violation-key-array': {
545
604
  std: 'Unexpected array type for element $(NAME)',
546
- scalar: 'Unexpected array type'
605
+ scalar: 'Unexpected array type',
547
606
  },
548
607
  'odata-spec-violation-key-null': {
549
608
  std: 'Expected key element $(NAME) to be not nullable', // structured
@@ -559,8 +618,9 @@ const centralMessageTexts = {
559
618
  std: 'Expected element to have a type',
560
619
  incompatible: 'Unexpected EDM Type $(TYPE) for OData $(VERSION)',
561
620
  facet: 'Unexpected EDM Type facet $(NAME) of type $(TYPE) for OData $(VERSION)',
621
+ external: 'Referenced type $(TYPE) marked as $(ANNO) can\'t be rendered as $(CODE) in service $(NAME) for OData $(VERSION)',
562
622
  },
563
- 'odata-spec-violation-property-name': 'Expected element name to be different from declaring $(KIND)',
623
+ 'odata-spec-violation-property-name': 'Expected element name to be different from declaring $(META)',
564
624
  'odata-spec-violation-namespace': {
565
625
  std: 'Expected service name not to be one of the reserved names $(NAMES)',
566
626
  length: 'Expected service name not to exceed 511 characters',
@@ -568,7 +628,9 @@ const centralMessageTexts = {
568
628
  // Other odata/edm errors
569
629
  'odata-definition-exists': {
570
630
  std: 'Entity can\'t be created due to name collision with existing definition $(NAME)',
571
- proxy: 'No proxy entity created due to name collision with existing definition $(NAME) of kind $(KIND)'
631
+ proxy: 'No proxy entity created due to name collision with existing definition $(NAME) of kind $(KIND)',
632
+ anno: 'Name of annotation definition $(ANNO) conflicts with existing service definition',
633
+ termredef: 'Unexpected redefinition of annotation $(ANNO)',
572
634
  },
573
635
  'odata-navigation': {
574
636
  std: 'No OData navigation property generated, target $(TARGET) is outside of service $(SERVICE)',
@@ -576,6 +638,63 @@ const centralMessageTexts = {
576
638
  },
577
639
  'odata-parameter-order': 'Unexpected mandatory after optional parameter',
578
640
  'odata-key-recursive': 'Unexpected recursive key $(NAME)',
641
+ // -----------------------------------------------------------------------------------
642
+ // All odata-anno MUST have a '$(ANNO)' parameter to indicate error location
643
+ // -----------------------------------------------------------------------------------
644
+ // Annotation Preprocessing:
645
+ // -----------------------------------------------------------------------------------
646
+ 'odata-anno-preproc': {
647
+ 'std': 'unused message text',
648
+ 'nokey': 'Expected target $(NAME) to have a key element for $(ANNO)',
649
+ 'multkeys': 'Expected target $(NAME) to have only one key element',
650
+ 'vhlnokey': 'Expected value help list entity $(NAME) to have a key element for $(ANNO)',
651
+ 'vhlmultkeys': 'Expected value help list entity $(NAME) to have only one key element for $(ANNO)',
652
+ 'notforentity': 'Unexpected usage of $(ANNO) for an entity',
653
+ 'viaassoc': 'Expected value to be a path for $(ANNO)',
654
+ 'noassoc': 'Expected association $(ID) to exist for $(ANNO)',
655
+ 'vallistignored': '$(NAME) is ignored for $(ANNO) as $(CODE) is present',
656
+ 'notastring': 'Expected value to be a string for $(ANNO)',
657
+ 'notexist': 'Expect entity $(ID) to exist for $(ANNO)',
658
+ 'txtarr': 'Expect $(ANNO) shortcut to have a $(NAME) annotation'
659
+ },
660
+ // -----------------------------------------------------------------------------------
661
+ // GenericTranslation:
662
+ // -----------------------------------------------------------------------------------
663
+ 'odata-anno-dict': {
664
+ // ANNO w/o sub elements, term qualifiers and context stack
665
+ 'std': 'Vocabulary dictionary inconsistency: Type $(TYPE) not found for $(ANNO)',
666
+ 'experimental': '$(ANNO) is experimental and can be changed or removed at any time, do not use productively!',
667
+ 'redefinition': '$(ANNO) is an official OASIS/SAP annotation and can\'t be redefined'
668
+ },
669
+ 'odata-anno-dict-enum': {
670
+ 'std' : 'Unexpected annotation definition $(NAME) with many enum type',
671
+ 'type': 'Unexpected annotation definition $(NAME) with many enum type $(TYPE)',
672
+ 'value': 'Expected all enum elements of type $(TYPE) to have a value in annotation definition $(NAME)'
673
+ },
674
+ 'odata-anno-value': {
675
+ 'nested': 'Missing $(STR) annotation for $(ANNO)',
676
+ // -----------------------------------------------------------------------------------
677
+ // All mesages of odata-anno-value below here MUST have $(ANNO) filled with msgctx.anno
678
+ // -----------------------------------------------------------------------------------
679
+ 'enum': 'Value $(VALUE) is not one out of $(RAWVALUES) for $(ANNO) of type $(TYPE)',
680
+ 'std': 'Unexpected value $(VALUE) for $(ANNO) of type $(TYPE)',
681
+ 'struct': 'Unexpected $(STR) value for $(ANNO) of type $(TYPE)',
682
+ 'nestedcollection': 'Nested collections are not supported for $(ANNO)',
683
+ 'enumincollection': 'Enum inside collection is not supported for $(ANNO)',
684
+ 'multexpr': 'EDM JSON code contains more than one dynamic expression: $(RAWVALUES) for $(ANNO)',
685
+ },
686
+ 'odata-anno-type': {
687
+ 'std': '$(NAME) is not a known property for $(ANNO) of type $(TYPE)',
688
+ 'unknown': '$(TYPE) is not a known vocabulary type for $(ANNO)',
689
+ 'abstract': 'Unexpected abstract type $(TYPE) for $(ANNO)',
690
+ 'derived': 'Expected specified $(TYPE) to be derived from $(NAME) for $(ANNO)',
691
+ },
692
+ 'odata-anno-def': {
693
+ // All $(ANNO) w/o sub elements, term qualifiers and context stack
694
+ 'std': '$(ANNO) is not a known annotation in an official OASIS/SAP namespace',
695
+ 'deprecated': '$(ANNO) is deprecated. $(DEPR)',
696
+ 'notapplied': '$(ANNO) is not applied (AppliesTo: $(RAWVALUES))',
697
+ },
579
698
  }
580
699
 
581
700
  /**
@@ -583,7 +702,7 @@ const centralMessageTexts = {
583
702
  *
584
703
  * @typedef {object} MessageConfig
585
704
  * @property {MessageSeverity} severity Default severity for the message.
586
- * @property {string[]|'deprecated'|true} [configurableFor]
705
+ * @property {string[]|'deprecated'|'v3'|true} [configurableFor]
587
706
  * Whether the error can be reclassified to a warning or lower.
588
707
  * If not `true` then an array is expected with specified modules in which the error is downgradable.
589
708
  * Only has an effect if default severity is 'Error'.
@@ -597,6 +716,6 @@ const centralMessageTexts = {
597
716
  * Don't set this property directly! Append to object oldMessageIds instead!
598
717
  */
599
718
 
600
- //console.log('FOO')
719
+ // console.log('FOO')
601
720
 
602
721
  module.exports = { centralMessages, centralMessageTexts, oldMessageIds };