@sap/cds-compiler 3.9.4 → 4.0.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 (95) hide show
  1. package/CHANGELOG.md +107 -4
  2. package/README.md +0 -1
  3. package/bin/cdsc.js +11 -23
  4. package/bin/cdsse.js +3 -3
  5. package/doc/API.md +5 -0
  6. package/doc/CHANGELOG_ARCHIVE.md +1 -1
  7. package/doc/CHANGELOG_BETA.md +17 -1
  8. package/doc/CHANGELOG_DEPRECATED.md +28 -0
  9. package/lib/api/.eslintrc.json +1 -1
  10. package/lib/api/main.js +55 -9
  11. package/lib/api/options.js +2 -0
  12. package/lib/base/error.js +2 -0
  13. package/lib/base/message-registry.js +143 -64
  14. package/lib/base/messages.js +213 -107
  15. package/lib/base/model.js +11 -11
  16. package/lib/checks/.eslintrc.json +1 -1
  17. package/lib/checks/annotationsOData.js +2 -2
  18. package/lib/checks/elements.js +1 -1
  19. package/lib/checks/enricher.js +26 -3
  20. package/lib/checks/onConditions.js +67 -12
  21. package/lib/checks/queryNoDbArtifacts.js +106 -105
  22. package/lib/checks/sql-snippets.js +2 -0
  23. package/lib/checks/types.js +12 -6
  24. package/lib/checks/validator.js +2 -2
  25. package/lib/compiler/assert-consistency.js +10 -8
  26. package/lib/compiler/builtins.js +8 -2
  27. package/lib/compiler/checks.js +52 -35
  28. package/lib/compiler/define.js +31 -26
  29. package/lib/compiler/extend.js +120 -65
  30. package/lib/compiler/finalize-parse-cdl.js +12 -43
  31. package/lib/compiler/generate.js +16 -5
  32. package/lib/compiler/index.js +8 -5
  33. package/lib/compiler/kick-start.js +4 -3
  34. package/lib/compiler/populate.js +96 -95
  35. package/lib/compiler/propagator.js +7 -8
  36. package/lib/compiler/resolve.js +377 -103
  37. package/lib/compiler/shared.js +794 -517
  38. package/lib/compiler/tweak-assocs.js +8 -6
  39. package/lib/compiler/utils.js +44 -0
  40. package/lib/edm/annotations/genericTranslation.js +41 -5
  41. package/lib/edm/csn2edm.js +34 -32
  42. package/lib/edm/edm.js +34 -31
  43. package/lib/edm/edmAnnoPreprocessor.js +0 -23
  44. package/lib/edm/edmInboundChecks.js +7 -2
  45. package/lib/edm/edmPreprocessor.js +25 -18
  46. package/lib/edm/edmUtils.js +8 -4
  47. package/lib/gen/Dictionary.json +18 -0
  48. package/lib/gen/language.checksum +1 -1
  49. package/lib/gen/language.interp +4 -2
  50. package/lib/gen/languageParser.js +5006 -4582
  51. package/lib/json/from-csn.js +157 -112
  52. package/lib/json/to-csn.js +60 -89
  53. package/lib/language/antlrParser.js +17 -13
  54. package/lib/language/docCommentParser.js +11 -1
  55. package/lib/language/genericAntlrParser.js +13 -10
  56. package/lib/language/language.g4 +168 -97
  57. package/lib/main.d.ts +128 -36
  58. package/lib/main.js +1 -1
  59. package/lib/model/csnRefs.js +24 -5
  60. package/lib/model/csnUtils.js +9 -8
  61. package/lib/model/revealInternalProperties.js +7 -12
  62. package/lib/model/sortViews.js +4 -2
  63. package/lib/modelCompare/compare.js +1 -1
  64. package/lib/modelCompare/utils/filter.js +40 -2
  65. package/lib/optionProcessor.js +0 -3
  66. package/lib/render/toCdl.js +247 -214
  67. package/lib/render/toHdbcds.js +197 -181
  68. package/lib/render/toSql.js +325 -289
  69. package/lib/render/utils/common.js +42 -4
  70. package/lib/render/utils/delta.js +1 -1
  71. package/lib/render/utils/sql.js +3 -3
  72. package/lib/transform/braceExpression.js +2 -2
  73. package/lib/transform/db/.eslintrc.json +1 -1
  74. package/lib/transform/db/applyTransformations.js +3 -3
  75. package/lib/transform/db/associations.js +24 -12
  76. package/lib/transform/db/expansion.js +17 -18
  77. package/lib/transform/db/flattening.js +17 -21
  78. package/lib/transform/db/rewriteCalculatedElements.js +171 -64
  79. package/lib/transform/db/views.js +3 -4
  80. package/lib/transform/draft/db.js +21 -12
  81. package/lib/transform/draft/odata.js +4 -0
  82. package/lib/transform/forOdataNew.js +62 -47
  83. package/lib/transform/forRelationalDB.js +12 -7
  84. package/lib/transform/localized.js +4 -2
  85. package/lib/transform/odata/toFinalBaseType.js +5 -5
  86. package/lib/transform/odata/typesExposure.js +3 -3
  87. package/lib/transform/parseExpr.js +3 -0
  88. package/lib/transform/transformUtilsNew.js +43 -23
  89. package/lib/transform/translateAssocsToJoins.js +7 -6
  90. package/lib/transform/universalCsn/.eslintrc.json +1 -1
  91. package/lib/transform/universalCsn/coreComputed.js +7 -5
  92. package/lib/transform/universalCsn/universalCsnEnricher.js +12 -12
  93. package/package.json +2 -2
  94. package/share/messages/{duplicate-autoexposed.md → def-duplicate-autoexposed.md} +5 -1
  95. package/share/messages/message-explanations.json +1 -1
@@ -41,7 +41,7 @@ const { createDict } = require('../utils/objectUtils');
41
41
  * - true = can always be downgraded, we do not really care
42
42
  * - [‹module›, …] = can be downgraded in compiler function ‹module›
43
43
  * - 'deprecated' = severity can only be changed with deprecated.downgradableErrors
44
- * - 'v3' = currently like true, but should be 'deprecated' in v4
44
+ * - 'v4' = currently like true, but should be 'deprecated' in v5
45
45
  *
46
46
  * @type {Object<string, MessageConfig>}
47
47
  */
@@ -52,6 +52,7 @@ const centralMessages = {
52
52
  'anno-unstable-array': { severity: 'Warning' },
53
53
  'anno-invalid-sql-element': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
54
54
  'anno-invalid-sql-struct': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
55
+ 'anno-invalid-sql-calc': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
55
56
  'anno-invalid-sql-kind': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
56
57
  'anno-invalid-sql-view': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
57
58
  'anno-invalid-sql-view-element': { severity: 'Error', configurableFor: true }, // @sql.prepend/append - configurable for "I know what I'm doing"
@@ -60,41 +61,47 @@ const centralMessages = {
60
61
  'anno-undefined-def': { severity: 'Warning' }, // for annotate statement (for CSN or CDL path cont)
61
62
  'anno-undefined-element': { severity: 'Warning' },
62
63
  'anno-undefined-param': { severity: 'Warning' },
63
- 'anno-unexpected-ellipsis': { severity: 'Error', configurableFor: 'v3' },
64
+ 'anno-unexpected-ellipsis': { severity: 'Error', configurableFor: 'deprecated' },
64
65
 
65
- 'args-expected-named': { severity: 'Error', configurableFor: 'deprecated' }, // future --sloppy
66
- 'args-no-params': { severity: 'Error', configurableFor: 'deprecated' }, // future --sloppy
67
- 'args-undefined-param': { severity: 'Error', configurableFor: 'deprecated' }, // future --sloppy
66
+ 'args-expecting-named': { severity: 'Error' },
67
+ 'args-no-params': { severity: 'Error' },
68
+ 'args-undefined-param': { severity: 'Error' },
68
69
 
69
- 'assoc-in-array': { severity: 'Error', configurableFor: 'deprecated' }, // not supported yet
70
- 'assoc-as-type': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: allow more, but not all
70
+ 'name-invalid-dollar-alias': { severity: 'Error', configurableFor: true },
71
+
72
+ 'type-invalid-items': { severity: 'Error' }, // not supported yet
73
+ 'assoc-as-type': { severity: 'Error' }, // TODO: allow more, but not all
71
74
  'def-unexpected-paramview-assoc': { severity: 'Error' },
72
75
  'def-unexpected-calcview-assoc': { severity: 'Error' },
73
76
  'chained-array-of': { severity: 'Error' },
74
77
  'check-proper-type': { severity: 'Error', configurableFor: [ 'compile' ] },
75
78
  'check-proper-type-of': { severity: 'Info', errorFor: [ 'for.odata', 'to.edmx', 'to.hdbcds', 'to.sql', 'to.hdi', 'to.rename' ] },
76
79
 
77
- 'expr-no-filter': { severity: 'Error', configurableFor: 'deprecated' },
80
+ 'def-duplicate-autoexposed': { severity: 'Error' },
81
+ 'def-unexpected-default': { severity: 'Error', configurableFor: 'test' },
82
+
83
+ 'expr-no-filter': { severity: 'Error' },
78
84
 
79
85
  'empty-type': { severity: 'Info' }, // only still an error in old transformers
80
86
 
81
- // TODO: rename to ref-expected-XYZ
82
- 'expected-type': { severity: 'Error' },
87
+ 'ref-deprecated-orderby': { severity: 'Error', configurableFor: true },
88
+ 'ref-expecting-type': { severity: 'Error' },
83
89
  'ref-sloppy-type': { severity: 'Error' },
84
90
  'ref-unexpected-self': { severity: 'Error' },
85
91
  'ref-expecting-bare-aspect': { severity: 'Error' },
86
- 'type-unexpected-typeof': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: make it non-config
92
+ 'type-unexpected-typeof': { severity: 'Error' },
87
93
  'type-ignoring-argument': { severity: 'Error', configurableFor: true },
88
94
  'type-expected-builtin': { severity: 'Error', configurableFor: true },
89
- 'expected-actionparam-type': { severity: 'Error' },
95
+ 'type-expecting-service-target': { severity: 'Error', configurableFor: true },
96
+ 'ref-expecting-action-param-type': { severity: 'Error' },
90
97
  'ref-sloppy-actionparam-type': { severity: 'Error' },
91
- 'expected-event-type': { severity: 'Error' },
98
+ 'ref-expecting-event-type': { severity: 'Error' }, // TODO: Test coverage
92
99
  'ref-sloppy-event-type': { severity: 'Error' },
93
- 'expected-struct': { severity: 'Error' },
94
- 'expected-const': { severity: 'Error' },
95
- 'expected-entity': { severity: 'Error' },
96
- 'expected-source': { severity: 'Error' },
97
- 'expected-target': { severity: 'Error' },
100
+ 'ref-expecting-struct': { severity: 'Error' },
101
+ 'ref-expecting-const': { severity: 'Error' },
102
+ 'ref-expecting-entity': { severity: 'Error' },
103
+ 'ref-expecting-source': { severity: 'Error' },
104
+ 'ref-expecting-target': { severity: 'Error' },
98
105
  'ref-sloppy-target': { severity: 'Warning' },
99
106
 
100
107
  'extend-repeated-intralayer': { severity: 'Warning' },
@@ -103,7 +110,7 @@ const centralMessages = {
103
110
  'ext-duplicate-extend-type': { severity: 'Error' },
104
111
  'ext-duplicate-extend-type-unrelated-layer': { severity: 'Error', configurableFor: true },
105
112
 
106
- 'param-default': { severity: 'Error', configurableFor: 'deprecated' }, // not supported yet
113
+ 'param-default': { severity: 'Error' }, // not supported yet
107
114
 
108
115
  'query-undefined-element': { severity: 'Error' },
109
116
  'query-unexpected-assoc-hdbcds': { severity: 'Error' },
@@ -115,14 +122,14 @@ const centralMessages = {
115
122
  'redirected-implicitly-ambiguous': { severity: 'Error', configurableFor: true }, // does not hurt us - TODO: ref-ambiguous-target
116
123
  'type-ambiguous-target': { severity: 'Warning' },
117
124
 
118
- 'ref-autoexposed': { severity: 'Error', configurableFor: 'deprecated' },
125
+ 'ref-unexpected-autoexposed': { severity: 'Error' },
119
126
  // Published! Used in @sap/cds-lsp; if renamed, add to oldMessageIds and contact colleagues
120
127
  'ref-undefined-art': { severity: 'Error' },
121
128
  'ref-undefined-def': { severity: 'Error' },
122
129
  'ref-undefined-var': { severity: 'Error' },
123
130
  'ref-undefined-element': { severity: 'Error' },
124
131
  'ref-unknown-var': { severity: 'Info', errorFor: [ 'to.hdbcds', 'to.sql', 'to.hdi', 'to.rename' ] },
125
- 'ref-obsolete-parameters': { severity: 'Error', configurableFor: true },
132
+ 'ref-obsolete-parameters': { severity: 'Error', configurableFor: 'v4' },
126
133
  // does not hurt us, but makes it tedious to detect parameter refs
127
134
  'ref-undefined-param': { severity: 'Error' },
128
135
  'ref-rejected-on': { severity: 'Error' },
@@ -134,27 +141,31 @@ const centralMessages = {
134
141
  'rewrite-key-not-matched-implicit': { severity: 'Error' },
135
142
 
136
143
  'service-nested-context': { severity: 'Error', configurableFor: true }, // does not hurt compile, TODO
137
- 'service-nested-service': { severity: 'Error', configurableFor: 'deprecated' }, // not supported yet
144
+ 'service-nested-service': { severity: 'Error' }, // not supported yet; TODO: configurableFor:'test'?
138
145
 
139
146
  'expr-unexpected-operator': { severity: 'Error', configurableFor: true },
140
147
 
148
+ 'syntax-deprecated-auto-union': { severity: 'Error', configurableFor: 'v4' },
141
149
  // Published! Used in @sap/cds-lsp; if renamed, add to oldMessageIds and contact colleagues
142
150
  // Also used by other projects that rely on double-quotes for delimited identifiers.
143
151
  'syntax-deprecated-ident': { severity: 'Error', configurableFor: true },
152
+ 'syntax-deprecated-property': { severity: 'Error', configurableFor: 'v4' }, // v0 prop
153
+ 'syntax-deprecated-value': { severity: 'Error', configurableFor: 'v4' }, // v0 prop
144
154
  // 'syntax-duplicate-annotate' came late with v3 - make it configurable as
145
155
  // fallback, but then parse.cdl is not supposed to work correctly (it can
146
156
  // then either issue an error or produce a CSN missing some annotations):
147
- 'syntax-duplicate-annotate': { severity: 'Error', configurableFor: 'v3' },
157
+ 'syntax-duplicate-annotate': { severity: 'Error', configurableFor: 'deprecated' },
148
158
  'syntax-duplicate-clause': { severity: 'Error', configurableFor: true },
149
159
  'syntax-duplicate-equal-clause': { severity: 'Warning' },
150
- 'syntax-invalid-name': { severity: 'Error', configurableFor: 'v3' },
160
+ 'syntax-invalid-name': { severity: 'Error', configurableFor: 'deprecated' },
151
161
  'syntax-missing-as': { severity: 'Error', configurableFor: true },
152
162
  'syntax-unexpected-null': { severity: 'Error', configurableFor: true },
153
163
  'syntax-unexpected-reserved-word': { severity: 'Error', configurableFor: true },
154
164
  'syntax-unknown-escape': { severity: 'Error', configurableFor: true },
155
- 'syntax-unsupported-masked': { severity: 'Error', configurableFor: 'v3' },
165
+ 'syntax-unsupported-masked': { severity: 'Error', configurableFor: 'deprecated' },
166
+ 'syntax-unexpected-sql-clause': { severity: 'Error' }, // TODO: configurableFor:'tests'?
156
167
 
157
- 'type-managed-composition': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: non-config
168
+ 'type-managed-composition': { severity: 'Error' },
158
169
  'type-unsupported-precision-change': { severity: 'Error'},
159
170
 
160
171
  'def-missing-element': { severity: 'Error' },
@@ -162,8 +173,8 @@ const centralMessages = {
162
173
  'def-unsupported-calc-elem': { severity: 'Error', configurableFor: true },
163
174
 
164
175
  'unexpected-keys-for-composition': { severity: 'Error' }, // TODO: more than 30 chars
165
- 'unmanaged-as-key': { severity: 'Error', configurableFor: 'deprecated' }, // is confusing
166
- 'composition-as-key': { severity: 'Error', configurableFor: 'deprecated' }, // is confusing and not supported
176
+ 'unmanaged-as-key': { severity: 'Error' }, // is confusing
177
+ 'composition-as-key': { severity: 'Error' }, // is confusing and not supported
167
178
  'def-invalid-key-cardinality': { severity: 'Error' },
168
179
  // Published! Used in @cap-js-community/odata-v2-adapter; if renamed, add to oldMessageIds
169
180
  'odata-spec-violation-array': { severity: 'Warning' }, // more than 30 chars
@@ -191,6 +202,7 @@ const centralMessages = {
191
202
  'odata-anno-value': { severity: 'Warning', configurableFor: true },
192
203
  'odata-anno-type': { severity: 'Warning', configurableFor: true },
193
204
  'odata-anno-def': { severity: 'Info', configurableFor: true },
205
+ 'query-ignoring-assoc-in-union': { severity: 'Info' }
194
206
  };
195
207
 
196
208
  // Old/Deprecated message IDs that we only still use for backwards-compatibility.
@@ -199,6 +211,8 @@ const centralMessages = {
199
211
  // The keys will be added to `oldNames` of the new message, which is used for reclassification.
200
212
  const oldMessageIds = createDict({
201
213
  'old-anno-duplicate': 'anno-duplicate', // Example
214
+ 'assoc-in-array': 'type-invalid-items',
215
+ 'duplicate-autoexposed': 'def-duplicate-autoexposed',
202
216
  });
203
217
 
204
218
  // Set up the old-to-new message ID mapping in the message registry.
@@ -265,11 +279,11 @@ const centralMessageTexts = {
265
279
  'flatten-fkey-gen': 'Duplicate definition of foreign key element $(NAME) for association $(ART)',
266
280
  'flatten-fkey-exists': 'Generated foreign key element $(NAME) for association $(ART) conflicts with existing element',
267
281
  },
268
- 'name-invalid-dollar-alias': { // Warning
269
- std: 'An alias name starting with $(NAME) might shadow a special variable - replace by another name',
270
- $tableAlias: 'A table alias name starting with $(NAME) might shadow a special variable - replace by another name',
271
- $tableImplicit: 'The resulting table alias starts with $(NAME) and might shadow a special variable - specify another name with $(KEYWORD)',
272
- mixin: 'A mixin name starting with $(NAME) might shadow a special variable - replace by another name',
282
+ 'name-invalid-dollar-alias': {
283
+ std: 'An alias name starting with $(NAME) might shadow a special variable; replace by another name',
284
+ $tableAlias: 'A table alias name must not start with $(NAME); choose another name',
285
+ $tableImplicit: 'The resulting table alias starts with $(NAME); choose another name with $(KEYWORD)',
286
+ mixin: 'A mixin name starting with $(NAME) might shadow a special variable; replace by another name',
273
287
  },
274
288
 
275
289
  'name-missing-alias': {
@@ -317,6 +331,10 @@ const centralMessageTexts = {
317
331
  'expecting': 'Expecting literal type $(OP) for the value in property $(OTHERPROP)',
318
332
  'typeof': 'String $(RAWVALUE) is no valid literal type for the string value in property $(OTHERPROP)',
319
333
  },
334
+ 'syntax-invalid-source': {
335
+ std: 'The given source is invalid', // unused
336
+ 'cdl-stackoverflow': 'The parser ran into a stack overflow. Does your CDS file contain too many nested artifacts?'
337
+ },
320
338
  'syntax-missing-ellipsis': 'Expecting an array item $(NEWCODE) after an item with $(CODE)',
321
339
  'syntax-unexpected-ellipsis': {
322
340
  std: 'Unexpected array item $(CODE)',
@@ -353,6 +371,11 @@ const centralMessageTexts = {
353
371
  },
354
372
  // 'syntax-duplicate-anno', 'syntax-duplicate-doc-comment', 'syntax-duplicate-property',
355
373
  // 'syntax-duplicate-wildcard'
374
+ 'syntax-invalid-path-separator': {
375
+ std: 'Invalid reference path separator', // unused
376
+ dot: 'Use a $(NEWCODE), not a $(CODE) after the arguments or filter on an entity',
377
+ colon: 'Use a $(NEWCODE), not a $(CODE) between the element names in a reference',
378
+ },
356
379
  // 'syntax-ignoring-doc-comment' (Info)
357
380
  'syntax-unexpected-reserved-word': '$(CODE) is a reserved word - write $(DELIMITED) instead if you want to use it as name',
358
381
  'syntax-invalid-text-block': 'Missing newline in text block',
@@ -376,6 +399,9 @@ const centralMessageTexts = {
376
399
  dynamic: 'Dynamic parameter $(CODE) is not supported',
377
400
  positional: 'Positional parameter $(CODE) is not supported',
378
401
  },
402
+ 'syntax-unexpected-sql-clause': {
403
+ std: 'Unexpected $(KEYWORD) clause for path filter',
404
+ },
379
405
 
380
406
  // Syntax messages, CSN parser - default: Error ------------------------------
381
407
  'syntax-deprecated-dollar-syntax': {
@@ -383,14 +409,13 @@ const centralMessageTexts = {
383
409
  projection: 'The property $(PROP) is deprecated; use property $(SIBLINGPROP) instead of $(OTHERPROP) for the query',
384
410
  aspect: 'The property $(PROP) is deprecated; change the kind of the current definition to $(KIND) instead',
385
411
  },
386
- 'syntax-deprecated-property': { // Warning
412
+ 'syntax-deprecated-property': { // Configurable error
387
413
  std: 'Deprecated property $(PROP)', // unused
388
414
  'zero': 'Deprecated CSN v0.1.0 property $(PROP) is ignored',
389
415
  'zero-replace': 'Replace CSN v0.1.0 property $(PROP) by $(OTHERPROP)',
390
416
  },
391
- 'syntax-deprecated-value': { // Warning
417
+ 'syntax-deprecated-value': { // Configurable error
392
418
  std: 'Deprecated representation of the value in property $(PROP)',
393
- replace: 'Replace value in $(PROP) by $(VALUE)',
394
419
  'zero-parens': 'Deprecated CSN v0.1.0 representation of expressions in parentheses',
395
420
  'zero-replace': 'Replace CSN v0.1.0 value in $(PROP) by $(VALUE)',
396
421
  },
@@ -454,9 +479,9 @@ const centralMessageTexts = {
454
479
  },
455
480
  'ref-invalid-calc-elem': {
456
481
  std: 'Can\'t include artifact with calculated element',
457
- event: 'An event can\'t include an entity with calculated elements',
458
- type: 'A type can\'t include an entity with calculated elements',
459
- annotation: 'An annotation can\'t include an entity with calculated elements',
482
+ event: 'An event can\'t include an artifact with calculated elements',
483
+ type: 'A type can\'t include an artifact with calculated elements',
484
+ annotation: 'An annotation can\'t include an artifact with calculated elements',
460
485
  },
461
486
  'def-unsupported-calc-elem': {
462
487
  std: 'Calculated elements are not supported, yet',
@@ -485,6 +510,7 @@ const centralMessageTexts = {
485
510
 
486
511
  // Messages for erroneous references -----------------------------------------
487
512
  // location at erroneous reference (if possible)
513
+ 'ref-deprecated-orderby': 'Replace source element reference $(ID) by $(NEWCODE); auto-corrected',
488
514
  'ref-unexpected-self': 'Unexpected $(ID) reference; is valid only in ON-conditions',
489
515
  'ref-undefined-def': {
490
516
  std: 'Artifact $(ART) has not been found',
@@ -492,23 +518,26 @@ const centralMessageTexts = {
492
518
  element: 'Artifact $(ART) has no element $(MEMBER)',
493
519
  },
494
520
  'ref-undefined-param': 'Entity $(ART) has no parameter $(ID)',
495
- 'ref-undefined-art': 'No artifact has been found with name $(NAME)',
521
+ 'ref-undefined-art': 'No artifact has been found with name $(ART)',
496
522
  // TODO: proposal 'No definition found for $(NAME)',
497
523
  'ref-undefined-element': {
498
524
  std: 'Element $(ART) has not been found',
499
525
  element: 'Artifact $(ART) has no element $(MEMBER)',
526
+ target: 'Target entity $(ART) has no element $(ID)',
500
527
  aspect: 'Element $(ID) has not been found in the anonymous target aspect',
528
+ query: 'The current query has no element $(ART)',
501
529
  virtual: 'Element $(ART) has not been found. Use $(CODE) to add virtual elements in queries'
502
530
  },
503
531
  'ref-undefined-var': {
504
532
  std: 'Variable $(ID) has not been found',
505
533
  alias: 'Variable $(ID) has not been found. Use table alias $(ALIAS) to refer an element with the same name',
534
+ self: 'Variable $(ID) has not been found. Use $(ALIAS) to refer an element with the same name',
506
535
  },
507
536
  'ref-unknown-var': {
508
537
  std: 'No replacement found for special variable $(ID)'
509
538
  },
510
539
  'ref-unexpected-draft-enabled': 'Composition in draft-enabled entity can\'t lead to another entity with $(ANNO)',
511
- 'ref-rejected-on': {
540
+ 'ref-rejected-on': { // TODO: currently not used - just remove?
512
541
  std: 'Do not refer to a artefact like $(ID) in the explicit ON of a redirection', // Not used
513
542
  mixin: 'Do not refer to a mixin like $(ID) in the explicit ON of a redirection',
514
543
  alias: 'Do not refer to a source element (via table alias $(ID)) in the explicit ON of a redirection',
@@ -541,20 +570,35 @@ const centralMessageTexts = {
541
570
  },
542
571
  'ref-unexpected-calculated': {
543
572
  std: 'Unexpected reference to calculated element',
544
- on: 'Calculated elements can\'t be used in ON-conditions of unmanaged associations',
545
- fkey: 'Calculated elements can\'t be used as foreign keys for managed associations',
573
+ on: 'Calculated elements (on-read) can\'t be used in ON-conditions of unmanaged associations',
574
+ fkey: 'Calculated elements (on-read) can\'t be used as foreign keys for managed associations',
575
+ },
576
+ 'ref-unexpected-localized': {
577
+ std: 'Unexpected reference to localized element $(NAME)', // "std" currently unused
578
+ calc: 'Calculated elements can\'t refer to localized elements',
546
579
  },
547
580
 
548
581
  'ref-unexpected-navigation': {
549
- std: 'Can\'t follow association $(ID) of path $(ELEMREF) in an ON-condition; only foreign keys can be referred to, but not $(NAME)',
550
- unmanaged: 'Can\'t follow unmanaged association $(ID) of path $(ELEMREF) in an ON-condition; only foreign keys can be referred to',
551
- unmanagedleaf: 'Unexpected unmanged association as final path step of $(ELEMREF) in an ON-condition',
582
+ std: 'Can\'t follow association $(ID) in path $(ELEMREF) in an ON-condition; only foreign keys can be referred to, but not $(NAME)',
583
+ unmanaged: 'Can\'t follow unmanaged association $(ID) in path $(ELEMREF) in an ON-condition',
584
+ unmanagedleaf: 'Unexpected unmanaged association as final path step of $(ELEMREF) in an ON-condition',
585
+ 'calc-non-fk': 'Can\'t follow association $(ID) in path $(ELEMREF) in a stored calculated element; only foreign keys can be referred to, but not $(NAME)',
586
+ 'calc-unmanaged': 'Can\'t follow unmanaged association $(ID) in path $(ELEMREF) in a stored calculated element',
587
+ },
588
+ 'ref-unexpected-filter': {
589
+ std: 'Unexpected filter in path $(ELEMREF)', // unused
590
+ 'on-condition': 'ON-conditions must not contain filters, step $(ID) of path $(ELEMREF)',
591
+ calc: 'Unexpected filter in path $(ELEMREF) of stored calculated element; only simple paths can be used here'
592
+ },
593
+ 'ref-unexpected-args': {
594
+ std: 'Unexpected arguments in path $(ELEMREF)', // unused
595
+ 'on-condition': 'ON-conditions must not contain parameters, step $(ID) of path $(ELEMREF)',
596
+ calc: 'Unexpected arguments in path $(ELEMREF) of stored calculated element; only simple paths can be used here'
552
597
  },
553
598
 
554
599
  'type-unexpected-typeof': {
555
600
  std: 'Unexpected $(KEYWORD) for the type reference here',
556
- type: 'Unexpected $(KEYWORD) in type of a type definition',
557
- event: 'Unexpected $(KEYWORD) for the type of an event',
601
+ type: 'Unexpected $(KEYWORD) for the type of a type definition',
558
602
  param: 'Unexpected $(KEYWORD) for the type of a parameter definition',
559
603
  select: 'Unexpected $(KEYWORD) for type references in queries',
560
604
  annotation: '$(KEYWORD) can\'t be used in annotation definitions',
@@ -563,18 +607,26 @@ const centralMessageTexts = {
563
607
  'type-missing-argument': 'Missing value for argument $(NAME) in reference to type $(ID)',
564
608
  'type-ignoring-argument': 'Too many arguments for type $(ART)',
565
609
  'type-unexpected-argument': {
566
- std: 'Too many arguments for type $(ART)',
610
+ std: 'Too many arguments for type $(ART)', // we use config 'type-ignoring-argument' instead
567
611
  type: 'Unexpected argument $(PROP) for type $(ART) with base type $(TYPE)',
568
612
  builtin: 'Unexpected argument $(PROP) for type $(ART)',
569
613
  'non-scalar': 'Only scalar types can have arguments',
614
+ // TODO: the following variants look like for an upcoming type-invalid-argument:
570
615
  max: 'Expecting argument $(PROP) for type $(TYPE) to not exceed $(NUMBER)',
571
616
  min: 'Expecting argument $(PROP) for type $(TYPE) to be greater than or equal to $(NUMBER)',
572
617
  'incorrect-type': 'Expected $(NAMES) for argument $(PROP), but found $(CODE)',
573
618
  },
574
619
 
620
+ 'type-invalid-items': {
621
+ std: 'Unexpected $(PROP)', // unused
622
+ nested: 'Unexpected $(PROP) inside $(PROP)',
623
+ assoc: 'Unexpected association inside $(PROP)',
624
+ comp: 'Unexpected composition inside $(PROP)',
625
+ },
626
+
575
627
  'anno-builtin': 'Builtin types should not be annotated. Use custom type instead',
576
- 'anno-undefined-def': 'Artifact $(ART) has not been found',
577
- 'anno-undefined-art': 'No artifact has been found with name $(NAME)',
628
+ 'anno-undefined-def': 'Artifact $(ART) has not been found', // TODO: ext-
629
+ 'anno-undefined-art': 'No artifact has been found with name $(ART)',
578
630
  'anno-undefined-element': {
579
631
  std: 'Element $(NAME) has not been found',
580
632
  element: 'Artifact $(ART) has no element $(NAME)',
@@ -623,6 +675,12 @@ const centralMessageTexts = {
623
675
  std: 'Unexpected structured type', // unused variant
624
676
  calc: 'A structured type can\'t be used for calculated elements',
625
677
  },
678
+ 'type-unexpected-many': {
679
+ std: 'Unexpected arrayed type', // unused variant
680
+ calc: 'An arrayed type can\'t be used for calculated elements',
681
+ 'calc-implicit': 'An arrayed type can\'t be used for calculated elements (due to direct reference $(ELEMREF))',
682
+ 'calc-cast': 'An arrayed type can\'t be used for calculated elements (via cast)',
683
+ },
626
684
 
627
685
  'def-missing-element': {
628
686
  std: 'Expecting entity to have at least one element which is neither virtual nor calculated',
@@ -667,17 +725,15 @@ const centralMessageTexts = {
667
725
  missing: 'Expected element $(ID) to have at least all the same sub-elements as included artifacts, but it is missing $(NAME)'
668
726
  },
669
727
 
670
- // TODO: rename to ref-expected-XYZ
671
- 'expected-actionparam-type': 'A type, an element, or a service entity is expected here',
672
- 'expected-const': 'A constant value is expected here',
673
- 'expected-context': 'A context or service is expected here',
674
- 'expected-event-type': 'A type, an element, an event, or a service entity is expected here',
675
- 'expected-entity': 'An entity, projection or view is expected here',
676
- 'expected-struct': 'A type, entity, aspect or event with direct elements is expected here',
677
- 'expected-type': 'A type or an element is expected here',
728
+ 'ref-expecting-action-param-type': 'A type, an element, or a service entity is expected here',
729
+ 'ref-expecting-const': 'A constant value is expected here',
730
+ 'ref-expecting-event-type': 'A type, an element, an event, or a service entity is expected here',
731
+ 'ref-expecting-entity': 'An entity, projection or view is expected here',
732
+ 'ref-expecting-struct': 'A type, entity, aspect or event with direct elements is expected here',
733
+ 'ref-expecting-type': 'A type or an element is expected here',
678
734
  // TODO: text variant if the association does not start an entity
679
- 'expected-source': 'A query source must be an entity or an association',
680
- 'expected-target': 'An entity or an aspect is expected here',
735
+ 'ref-expecting-source': 'A query source must be an entity or an association',
736
+ 'ref-expecting-target': 'An entity or an aspect is expected here', // TODO: coverage
681
737
  'extend-columns': 'Artifact $(ART) can\'t be extended with columns, only projections can',
682
738
  'extend-repeated-intralayer': 'Unstable element order due to repeated extensions in same layer',
683
739
  'extend-unexpected-include': 'Can\'t extend $(META) with includes',
@@ -696,6 +752,8 @@ const centralMessageTexts = {
696
752
  // eslint-disable-next-line max-len
697
753
  scale: 'With the extension for type property $(OTHERPROP), the value of $(PROP) must be $(NUMBER) or higher',
698
754
  },
755
+ 'ext-missing-type-property': 'Type extension with property $(PROP) must also have property $(OTHERPROP) because $(ART) has both',
756
+
699
757
  'ref-expected-scalar-type': {
700
758
  std: 'Only scalar type definitions can be extended with type properties',
701
759
  unsupported: 'Only integer-, decimal-, binary-, and string-types can be extended but found $(PROP)',
@@ -720,6 +778,22 @@ const centralMessageTexts = {
720
778
  std: 'Using nested projections next to calculated elements is not supported, yet',
721
779
  inside: 'Using calculated elements in nested projections is not supported, yet'
722
780
  },
781
+ 'query-mismatched-element': {
782
+ std: 'Specified element $(NAME) differs from inferred element in property $(PROP)',
783
+ type: 'Expected type of specified element $(NAME) to be the same as the inferred element\'s type',
784
+ typeName: 'Expected type $(TYPE) of specified element $(NAME) to be the same as the inferred element\'s type $(OTHERTYPE)',
785
+ missing: 'Specified element $(NAME) differs from inferred element: it is missing property $(PROP)',
786
+ extra: 'Specified element $(NAME) differs from inferred element: it has an additional property $(PROP)',
787
+ target: 'Expected target $(TARGET) of specified element $(NAME) to be the same as the inferred element\'s target $(ART)',
788
+ foreignKeys: 'Expected foreign keys of specified element $(NAME) to be the same as the inferred element\'s foreign keys',
789
+ prop: 'Value for $(PROP) of the specified element $(NAME) does not match the inferred element\'s value',
790
+ },
791
+
792
+ 'query-unexpected-property': {
793
+ std: 'Unexpected property $(PROP) in the specified element $(NAME)',
794
+ calculatedElement: 'Unexpected property $(PROP) in the specified element $(NAME); calculated elements are not supported in queries',
795
+ },
796
+
723
797
  'ref-sloppy-type': 'A type or an element is expected here',
724
798
  'ref-sloppy-actionparam-type': 'A type, an element, or a service entity is expected here',
725
799
  'ref-sloppy-target': 'An entity or an aspect (not type) is expected here',
@@ -841,7 +915,7 @@ const centralMessageTexts = {
841
915
  'odata-anno-value': {
842
916
  'nested': 'Missing $(STR) annotation for $(ANNO)',
843
917
  // -----------------------------------------------------------------------------------
844
- // All mesages of odata-anno-value below here MUST have $(ANNO) filled with msgctx.anno
918
+ // All messages of odata-anno-value below here MUST have $(ANNO) filled with msgctx.anno
845
919
  // -----------------------------------------------------------------------------------
846
920
  'enum': 'Value $(VALUE) is not one out of $(RAWVALUES) for $(ANNO) of type $(TYPE)',
847
921
  'std': 'Unexpected value $(VALUE) for $(ANNO) of type $(TYPE)',
@@ -862,6 +936,11 @@ const centralMessageTexts = {
862
936
  'deprecated': '$(ANNO) is deprecated. $(DEPR)',
863
937
  'notapplied': '$(ANNO) is not applied (AppliesTo: $(RAWVALUES))',
864
938
  },
939
+ 'query-ignoring-assoc-in-union': {
940
+ 'managed': 'Ignoring managed association $(NAME) that is published in a UNION',
941
+ 'std': 'Ignoring association $(NAME) that is published in a UNION'
942
+ }
943
+
865
944
  }
866
945
 
867
946
  /**
@@ -869,11 +948,11 @@ const centralMessageTexts = {
869
948
  *
870
949
  * @typedef {object} MessageConfig
871
950
  * @property {MessageSeverity} severity Default severity for the message.
872
- * @property {string[]|'deprecated'|'v3'|true} [configurableFor]
951
+ * @property {string[]|'deprecated'|'v4'|true} [configurableFor]
873
952
  * Whether the error can be reclassified to a warning or lower.
874
953
  * If not `true` then an array is expected with specified modules in which the error is downgradable.
875
954
  * Only has an effect if default severity is 'Error'.
876
- * 'deprecated': severity can only be changed with deprecated._downgradableErrors.
955
+ * 'deprecated': severity can only be changed with deprecated.downgradableErrors.
877
956
  * TODO: Value `true` is temporary. Use an array instead.
878
957
  * @property {string[]} [errorFor] Array of module names where the message shall be reclassified to an error.
879
958
  * @property {boolean} [throughMessageCall]