@sap/cds-compiler 3.1.2 → 3.4.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.
- package/CHANGELOG.md +101 -3
- package/bin/cdsc.js +4 -2
- package/doc/CHANGELOG_BETA.md +35 -0
- package/lib/api/main.js +153 -29
- package/lib/api/validate.js +8 -3
- package/lib/base/dictionaries.js +6 -6
- package/lib/base/error.js +2 -2
- package/lib/base/keywords.js +106 -24
- package/lib/base/message-registry.js +177 -79
- package/lib/base/messages.js +78 -57
- package/lib/base/model.js +2 -1
- package/lib/checks/actionsFunctions.js +1 -1
- package/lib/checks/annotationsOData.js +2 -2
- package/lib/checks/arrayOfs.js +15 -7
- package/lib/checks/cdsPersistence.js +1 -1
- package/lib/checks/checkForTypes.js +53 -0
- package/lib/checks/defaultValues.js +4 -2
- package/lib/checks/elements.js +81 -6
- package/lib/checks/foreignKeys.js +12 -13
- package/lib/checks/invalidTarget.js +10 -11
- package/lib/checks/managedInType.js +21 -15
- package/lib/checks/nullableKeys.js +1 -1
- package/lib/checks/onConditions.js +9 -9
- package/lib/checks/parameters.js +23 -0
- package/lib/checks/queryNoDbArtifacts.js +1 -1
- package/lib/checks/selectItems.js +1 -1
- package/lib/checks/sql-snippets.js +12 -10
- package/lib/checks/types.js +2 -2
- package/lib/checks/utils.js +17 -7
- package/lib/checks/validator.js +36 -14
- package/lib/compiler/assert-consistency.js +21 -13
- package/lib/compiler/builtins.js +8 -0
- package/lib/compiler/checks.js +57 -40
- package/lib/compiler/define.js +139 -69
- package/lib/compiler/extend.js +319 -50
- package/lib/compiler/finalize-parse-cdl.js +14 -9
- package/lib/compiler/kick-start.js +2 -35
- package/lib/compiler/populate.js +111 -68
- package/lib/compiler/propagator.js +5 -3
- package/lib/compiler/resolve.js +71 -108
- package/lib/compiler/shared.js +82 -54
- package/lib/compiler/tweak-assocs.js +26 -14
- package/lib/compiler/utils.js +13 -2
- package/lib/edm/annotations/genericTranslation.js +10 -7
- package/lib/edm/csn2edm.js +11 -11
- package/lib/edm/edm.js +17 -9
- package/lib/edm/edmPreprocessor.js +53 -30
- package/lib/edm/edmUtils.js +7 -2
- package/lib/gen/Dictionary.json +14 -0
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +3 -2
- package/lib/gen/languageParser.js +4312 -4186
- package/lib/inspect/inspectModelStatistics.js +1 -1
- package/lib/inspect/inspectPropagation.js +23 -9
- package/lib/json/csnVersion.js +13 -13
- package/lib/json/from-csn.js +161 -172
- package/lib/json/to-csn.js +70 -10
- package/lib/language/.eslintrc.json +4 -0
- package/lib/language/antlrParser.js +8 -11
- package/lib/language/docCommentParser.js +1 -2
- package/lib/language/errorStrategy.js +54 -27
- package/lib/language/genericAntlrParser.js +140 -93
- package/lib/language/language.g4 +57 -33
- package/lib/language/multiLineStringParser.js +75 -63
- package/lib/main.d.ts +3 -6
- package/lib/main.js +1 -0
- package/lib/model/.eslintrc.json +13 -0
- package/lib/model/api.js +4 -2
- package/lib/model/csnRefs.js +78 -50
- package/lib/model/csnUtils.js +272 -222
- package/lib/model/enrichCsn.js +41 -31
- package/lib/model/revealInternalProperties.js +61 -57
- package/lib/model/sortViews.js +35 -31
- package/lib/modelCompare/compare.js +52 -18
- package/lib/modelCompare/filter.js +83 -0
- package/lib/optionProcessor.js +10 -1
- package/lib/render/manageConstraints.js +11 -7
- package/lib/render/toCdl.js +151 -106
- package/lib/render/toHdbcds.js +8 -6
- package/lib/render/toRename.js +4 -4
- package/lib/render/toSql.js +17 -7
- package/lib/render/utils/common.js +27 -9
- package/lib/render/utils/sql.js +5 -5
- package/lib/sql-identifier.js +7 -0
- package/lib/transform/db/applyTransformations.js +32 -3
- package/lib/transform/db/assertUnique.js +27 -38
- package/lib/transform/db/expansion.js +92 -41
- package/lib/transform/db/flattening.js +1 -1
- package/lib/transform/db/temporal.js +3 -1
- package/lib/transform/db/transformExists.js +8 -2
- package/lib/transform/db/views.js +42 -13
- package/lib/transform/draft/db.js +2 -2
- package/lib/transform/forOdataNew.js +10 -7
- package/lib/transform/{forHanaNew.js → forRelationalDB.js} +18 -12
- package/lib/transform/localized.js +29 -20
- package/lib/transform/odata/toFinalBaseType.js +8 -11
- package/lib/transform/odata/typesExposure.js +2 -1
- package/lib/transform/parseExpr.js +245 -0
- package/lib/transform/transformUtilsNew.js +122 -51
- package/lib/transform/translateAssocsToJoins.js +17 -16
- package/lib/utils/moduleResolve.js +5 -5
- package/lib/utils/objectUtils.js +3 -3
- package/lib/utils/term.js +5 -5
- package/package.json +2 -2
- package/share/messages/anno-duplicate-unrelated-layer.md +6 -6
- package/share/messages/check-proper-type-of.md +4 -4
- package/share/messages/check-proper-type.md +2 -2
- package/share/messages/duplicate-autoexposed.md +4 -4
- package/share/messages/extend-repeated-intralayer.md +4 -5
- package/share/messages/extend-unrelated-layer.md +4 -4
- package/share/messages/message-explanations.json +3 -1
- package/share/messages/redirected-to-ambiguous.md +7 -6
- package/share/messages/redirected-to-complex.md +63 -0
- package/share/messages/redirected-to-unrelated.md +6 -5
- package/share/messages/rewrite-not-supported.md +4 -4
- package/share/messages/{syntax-expected-integer.md → syntax-expecting-integer.md} +4 -4
- package/share/messages/wildcard-excluding-one.md +37 -0
package/lib/base/keywords.js
CHANGED
|
@@ -188,10 +188,7 @@ module.exports = {
|
|
|
188
188
|
'WITHOUT'
|
|
189
189
|
],
|
|
190
190
|
// SAP HANA keywords, used for smart quoting in to-hdi.plain
|
|
191
|
-
//
|
|
192
|
-
// Better use keywords in ptime/query/parser/syntax/qp_keyword.cc minus those
|
|
193
|
-
// in rule unreserved_keyword_column (=…_common - 'CONSTRAINT') in
|
|
194
|
-
// ptime/query/parser/syntax/qp_gram.y of the HANA sources.
|
|
191
|
+
// See './scripts/keywords/hana/generateSqlKeywords.js'
|
|
195
192
|
hana: [
|
|
196
193
|
'ABAPITAB',
|
|
197
194
|
'ABAPSTRUCT',
|
|
@@ -215,12 +212,10 @@ module.exports = {
|
|
|
215
212
|
'ADD_MONTHS',
|
|
216
213
|
'ADD_SECONDS',
|
|
217
214
|
'ADD_YEARS',
|
|
218
|
-
'ADJACENCY',
|
|
219
215
|
'ADOPT',
|
|
220
216
|
'ALL',
|
|
221
217
|
'ALPHANUM',
|
|
222
218
|
'ALTER',
|
|
223
|
-
'ANALYTIC',
|
|
224
219
|
'ANY',
|
|
225
220
|
'APPLY_FILTER',
|
|
226
221
|
'ARRAY',
|
|
@@ -397,7 +392,6 @@ module.exports = {
|
|
|
397
392
|
'DISTANCE',
|
|
398
393
|
'DISTINCT',
|
|
399
394
|
'DOUBLE',
|
|
400
|
-
'DW_OPTIMIZED',
|
|
401
395
|
'ELSE',
|
|
402
396
|
'ELSEIF',
|
|
403
397
|
'EMPTY',
|
|
@@ -411,12 +405,9 @@ module.exports = {
|
|
|
411
405
|
'FALSE',
|
|
412
406
|
'FILTER',
|
|
413
407
|
'FIRST_VALUE',
|
|
414
|
-
'FLATTEN',
|
|
415
408
|
'FLOAT',
|
|
416
409
|
'FLOOR',
|
|
417
410
|
'FOR',
|
|
418
|
-
'FORCE_FIRST_PASSWORD_CHANGE',
|
|
419
|
-
'FREESTYLESEARCHATTRIBUTE',
|
|
420
411
|
'FROM',
|
|
421
412
|
'FULL',
|
|
422
413
|
'GET_NUM_SERVERS',
|
|
@@ -515,7 +506,6 @@ module.exports = {
|
|
|
515
506
|
'NUMBER',
|
|
516
507
|
'NUMERIC',
|
|
517
508
|
'NVARCHAR',
|
|
518
|
-
'OBJECT',
|
|
519
509
|
'OCCURRENCES_REGEXPR',
|
|
520
510
|
'OF',
|
|
521
511
|
'OLYMP',
|
|
@@ -640,16 +630,11 @@ module.exports = {
|
|
|
640
630
|
'SYSTEM_TIME',
|
|
641
631
|
'SYSUUID',
|
|
642
632
|
'TABLE',
|
|
643
|
-
'TABLES',
|
|
644
633
|
'TABLESAMPLE',
|
|
645
634
|
'TAN',
|
|
646
635
|
'TANH',
|
|
647
|
-
'TARGET',
|
|
648
|
-
'TEMPORARY',
|
|
649
636
|
'TEXT',
|
|
650
637
|
'TEXT_FILTER',
|
|
651
|
-
'THEN',
|
|
652
|
-
'THREAD',
|
|
653
638
|
'TIME',
|
|
654
639
|
'TIMELINE',
|
|
655
640
|
'TIMESTAMP',
|
|
@@ -662,11 +647,8 @@ module.exports = {
|
|
|
662
647
|
'TM_GET_RELEVANT_DOCUMENTS',
|
|
663
648
|
'TM_GET_RELEVANT_TERMS',
|
|
664
649
|
'TM_GET_SUGGESTED_TERMS',
|
|
665
|
-
'
|
|
666
|
-
'TOOLOPTION',
|
|
650
|
+
'TO',
|
|
667
651
|
'TOP',
|
|
668
|
-
'TOPK',
|
|
669
|
-
'TOTAL',
|
|
670
652
|
'TO_BIGINT',
|
|
671
653
|
'TO_BINARY',
|
|
672
654
|
'TO_BLOB',
|
|
@@ -694,11 +676,7 @@ module.exports = {
|
|
|
694
676
|
'TO_VARBINARY',
|
|
695
677
|
'TO_VARCHAR',
|
|
696
678
|
'TRACE',
|
|
697
|
-
'TRACEPROFILE',
|
|
698
|
-
'TRACES',
|
|
699
679
|
'TRAILING',
|
|
700
|
-
'TRANSACTION',
|
|
701
|
-
'TREE',
|
|
702
680
|
'TRIGGER_UPDATE_COLUMN',
|
|
703
681
|
'TRIM',
|
|
704
682
|
'TRUE',
|
|
@@ -864,5 +842,109 @@ module.exports = {
|
|
|
864
842
|
'WHERE',
|
|
865
843
|
'WINDOW',
|
|
866
844
|
'WITH'
|
|
845
|
+
],
|
|
846
|
+
// H2 keywords, used for smart quoting in to-sql.plain.postgres
|
|
847
|
+
// Taken from http://www.h2database.com/html/advanced.html#keywords
|
|
848
|
+
h2: [
|
|
849
|
+
'ALL',
|
|
850
|
+
'AND',
|
|
851
|
+
'ANY',
|
|
852
|
+
'ARRAY',
|
|
853
|
+
'AS',
|
|
854
|
+
'ASYMMETRIC',
|
|
855
|
+
'AUTHORIZATION',
|
|
856
|
+
'BETWEEN',
|
|
857
|
+
'BOTH',
|
|
858
|
+
'CASE',
|
|
859
|
+
'CAST',
|
|
860
|
+
'CHECK',
|
|
861
|
+
'CONSTRAINT',
|
|
862
|
+
'CROSS',
|
|
863
|
+
'CURRENT_CATALOG',
|
|
864
|
+
'CURRENT_DATE',
|
|
865
|
+
'CURRENT_PATH',
|
|
866
|
+
'CURRENT_ROLE',
|
|
867
|
+
'CURRENT_SCHEMA',
|
|
868
|
+
'CURRENT_TIME',
|
|
869
|
+
'CURRENT_TIMESTAMP',
|
|
870
|
+
'CURRENT_USER',
|
|
871
|
+
'DAY',
|
|
872
|
+
'DEFAULT',
|
|
873
|
+
'DISTINCT',
|
|
874
|
+
'ELSE',
|
|
875
|
+
'END',
|
|
876
|
+
'EXCEPT',
|
|
877
|
+
'EXISTS',
|
|
878
|
+
'FALSE',
|
|
879
|
+
'FETCH',
|
|
880
|
+
'FOR',
|
|
881
|
+
'FOREIGN',
|
|
882
|
+
'FROM',
|
|
883
|
+
'FULL',
|
|
884
|
+
'GROUP',
|
|
885
|
+
'GROUPS',
|
|
886
|
+
'HAVING',
|
|
887
|
+
'HOUR',
|
|
888
|
+
'IF',
|
|
889
|
+
'ILIKE',
|
|
890
|
+
'IN',
|
|
891
|
+
'INNER',
|
|
892
|
+
'INTERSECT',
|
|
893
|
+
'INTERVAL',
|
|
894
|
+
'IS',
|
|
895
|
+
'JOIN',
|
|
896
|
+
'KEY',
|
|
897
|
+
'LEADING',
|
|
898
|
+
'LEFT',
|
|
899
|
+
'LIKE',
|
|
900
|
+
'LIMIT',
|
|
901
|
+
'LOCALTIME',
|
|
902
|
+
'LOCALTIMESTAMP',
|
|
903
|
+
'MINUS',
|
|
904
|
+
'MINUTE',
|
|
905
|
+
'MONTH',
|
|
906
|
+
'NATURAL',
|
|
907
|
+
'NOT',
|
|
908
|
+
'NULL',
|
|
909
|
+
'OFFSET',
|
|
910
|
+
'ON',
|
|
911
|
+
'OR',
|
|
912
|
+
'ORDER',
|
|
913
|
+
'OVER',
|
|
914
|
+
'PARTITION',
|
|
915
|
+
'PRIMARY',
|
|
916
|
+
'QUALIFY',
|
|
917
|
+
'RANGE',
|
|
918
|
+
'REGEXP',
|
|
919
|
+
'RIGHT',
|
|
920
|
+
'ROW',
|
|
921
|
+
'ROWNUM',
|
|
922
|
+
'ROWS',
|
|
923
|
+
'SECOND',
|
|
924
|
+
'SELECT',
|
|
925
|
+
'SESSION_USER',
|
|
926
|
+
'SET',
|
|
927
|
+
'SOME',
|
|
928
|
+
'SYMMETRIC',
|
|
929
|
+
'SYSTEM_USER',
|
|
930
|
+
'TABLE',
|
|
931
|
+
'TO',
|
|
932
|
+
'TOP',
|
|
933
|
+
'TRAILING',
|
|
934
|
+
'TRUE',
|
|
935
|
+
'UESCAPE',
|
|
936
|
+
'UNION',
|
|
937
|
+
'UNIQUE',
|
|
938
|
+
'UNKNOWN',
|
|
939
|
+
'USER',
|
|
940
|
+
'USING',
|
|
941
|
+
'VALUE',
|
|
942
|
+
'VALUES',
|
|
943
|
+
'WHEN',
|
|
944
|
+
'WHERE',
|
|
945
|
+
'WINDOW',
|
|
946
|
+
'WITH',
|
|
947
|
+
'YEAR',
|
|
948
|
+
'_ROWID_'
|
|
867
949
|
]
|
|
868
950
|
}
|
|
@@ -37,7 +37,11 @@ const { createDict } = require("../utils/objectUtils");
|
|
|
37
37
|
* Central register of messages and their configuration.
|
|
38
38
|
* Group by id-category.
|
|
39
39
|
*
|
|
40
|
-
* configurableFor:
|
|
40
|
+
* configurableFor: truthy = error can be downgraded in certain situations
|
|
41
|
+
* - true = can always be downgraded, we do not really care
|
|
42
|
+
* - [‹module›, …] = can be downgraded in compiler function ‹module›
|
|
43
|
+
* - 'deprecated' = severity can only be changed with deprecated.downgradableErrors
|
|
44
|
+
* - 'v3' = currently like true, but should be 'deprecated' in v4
|
|
41
45
|
*
|
|
42
46
|
* @type {Object<string, MessageConfig>}
|
|
43
47
|
*/
|
|
@@ -74,12 +78,11 @@ const centralMessages = {
|
|
|
74
78
|
|
|
75
79
|
'empty-type': { severity: 'Info' }, // only still an error in old transformers
|
|
76
80
|
|
|
77
|
-
// Structured types were warned about but made CSN un-recompilable.
|
|
78
|
-
'enum-invalid-type': { severity: 'Error', configurableFor: 'deprecated' },
|
|
79
|
-
|
|
80
81
|
// TODO: rename to ref-expected-XYZ
|
|
81
82
|
'expected-type': { severity: 'Error' },
|
|
82
83
|
'ref-sloppy-type': { severity: 'Error' },
|
|
84
|
+
'ref-unexpected-self': { severity: 'Error' },
|
|
85
|
+
'ref-expecting-bare-aspect': { severity: 'Error' },
|
|
83
86
|
'type-unexpected-typeof': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: make it non-config
|
|
84
87
|
'type-ignoring-argument': { severity: 'Error', configurableFor: true },
|
|
85
88
|
'type-expected-builtin': { severity: 'Error', configurableFor: true },
|
|
@@ -97,6 +100,9 @@ const centralMessages = {
|
|
|
97
100
|
'extend-repeated-intralayer': { severity: 'Warning' },
|
|
98
101
|
'extend-unrelated-layer': { severity: 'Warning' },
|
|
99
102
|
|
|
103
|
+
'ext-duplicate-extend-type': { severity: 'Error' },
|
|
104
|
+
'ext-duplicate-extend-type-unrelated-layer': { severity: 'Error', configurableFor: true },
|
|
105
|
+
|
|
100
106
|
'param-default': { severity: 'Error', configurableFor: 'deprecated' }, // not supported yet
|
|
101
107
|
|
|
102
108
|
'query-undefined-element': { severity: 'Error' },
|
|
@@ -115,44 +121,33 @@ const centralMessages = {
|
|
|
115
121
|
'ref-undefined-var': { severity: 'Error' },
|
|
116
122
|
'ref-undefined-element': { severity: 'Error' },
|
|
117
123
|
'ref-unknown-var': { severity: 'Info', errorFor: [ 'to.hdbcds', 'to.sql', 'to.hdi', 'to.rename' ] },
|
|
118
|
-
'ref-obsolete-parameters': { severity: 'Error', configurableFor: true },
|
|
124
|
+
'ref-obsolete-parameters': { severity: 'Error', configurableFor: true },
|
|
125
|
+
// does not hurt us, but makes it tedious to detect parameter refs
|
|
119
126
|
'ref-undefined-param': { severity: 'Error' },
|
|
120
127
|
'ref-rejected-on': { severity: 'Error' },
|
|
121
128
|
'ref-expected-element': { severity: 'Error' },
|
|
122
129
|
|
|
123
|
-
'rewrite-key-not-covered-explicit': { severity: 'Error'
|
|
124
|
-
'rewrite-key-not-covered-implicit': { severity: 'Error'
|
|
125
|
-
'rewrite-key-not-matched-explicit': { severity: 'Error'
|
|
126
|
-
'rewrite-key-not-matched-implicit': { severity: 'Error'
|
|
127
|
-
'rewrite-key-for-unmanaged': { severity: 'Error', configurableFor: 'deprecated' },
|
|
128
|
-
'rewrite-not-supported': { severity: 'Error' },
|
|
129
|
-
'rewrite-on-for-managed': { severity: 'Error', configurableFor: 'deprecated' },
|
|
130
|
+
'rewrite-key-not-covered-explicit': { severity: 'Error' },
|
|
131
|
+
'rewrite-key-not-covered-implicit': { severity: 'Error' },
|
|
132
|
+
'rewrite-key-not-matched-explicit': { severity: 'Error' },
|
|
133
|
+
'rewrite-key-not-matched-implicit': { severity: 'Error' },
|
|
130
134
|
|
|
131
135
|
'service-nested-context': { severity: 'Error', configurableFor: true }, // does not hurt compile, TODO
|
|
132
136
|
'service-nested-service': { severity: 'Error', configurableFor: 'deprecated' }, // not supported yet
|
|
133
137
|
|
|
138
|
+
'expr-unexpected-operator': { severity: 'Error', configurableFor: true },
|
|
139
|
+
|
|
134
140
|
// 'syntax-duplicate-annotate' came late with v3 - make it configurable as
|
|
135
141
|
// fallback, but then parse.cdl is not supposed to work correctly (it can
|
|
136
142
|
// then either issue an error or produce a CSN missing some annotations):
|
|
137
143
|
'syntax-duplicate-annotate': { severity: 'Error', configurableFor: true },
|
|
138
|
-
'syntax-
|
|
139
|
-
'syntax-expected-length': { severity: 'Error' },
|
|
140
|
-
'syntax-expected-translation': { severity: 'Error' },
|
|
141
|
-
'syntax-required-subproperty': { severity: 'Error' },
|
|
142
|
-
'syntax-unexpected-property': { severity: 'Error', configurableFor: true }, // is the removed
|
|
144
|
+
'syntax-unexpected-property': { severity: 'Error' },
|
|
143
145
|
'syntax-deprecated-ident': { severity: 'Error', configurableFor: true },
|
|
144
146
|
'syntax-fragile-alias': { severity: 'Error', configurableFor: true },
|
|
145
147
|
'syntax-fragile-ident': { severity: 'Error', configurableFor: true },
|
|
146
|
-
|
|
147
|
-
'syntax-invalid-extend': { severity: 'Error' },
|
|
148
|
-
|
|
149
|
-
'syntax-invalid-text-block' : { severity: 'Error' },
|
|
150
148
|
'syntax-unknown-escape': { severity: 'Error', configurableFor: true },
|
|
151
|
-
'syntax-invalid-escape': { severity: 'Error' },
|
|
152
|
-
'syntax-missing-escape': { severity: 'Error' },
|
|
153
149
|
|
|
154
|
-
'syntax-
|
|
155
|
-
'syntax-invalid-masked': { severity: 'Error', configurableFor: true },
|
|
150
|
+
'syntax-unsupported-masked': { severity: 'Error', configurableFor: 'v3' },
|
|
156
151
|
'syntax-unexpected-null': { severity: 'Error', configurableFor: true },
|
|
157
152
|
|
|
158
153
|
'type-managed-composition': { severity: 'Error', configurableFor: 'deprecated' }, // TODO: non-config
|
|
@@ -162,9 +157,18 @@ const centralMessages = {
|
|
|
162
157
|
'unexpected-keys-for-composition': { severity: 'Error' }, // TODO: more than 30 chars
|
|
163
158
|
'unmanaged-as-key': { severity: 'Error', configurableFor: 'deprecated' }, // is confusing
|
|
164
159
|
'composition-as-key': { severity: 'Error', configurableFor: 'deprecated' }, // is confusing and not supported
|
|
165
|
-
|
|
160
|
+
// Published! Used in @sap/cds-odata-v2-adapter-proxy; if renamed, add to oldMessageIds
|
|
161
|
+
'odata-spec-violation-array': { severity: 'Warning' }, // more than 30 chars
|
|
162
|
+
// Published! Used in @sap/cds-odata-v2-adapter-proxy; if renamed, add to oldMessageIds
|
|
163
|
+
'odata-spec-violation-assoc': { severity: 'Warning' }, // more than 30 chars
|
|
164
|
+
// Published! Used in @sap/cds-odata-v2-adapter-proxy; if renamed, add to oldMessageIds
|
|
166
165
|
'odata-spec-violation-constraints': { severity: 'Info' }, // more than 30 chars
|
|
167
166
|
'odata-spec-violation-id': { severity: 'Error', configurableFor: true },
|
|
167
|
+
'odata-spec-violation-namespace': { severity: 'Warning' }, // more than 30 chars
|
|
168
|
+
// Published! Used in @sap/cds-odata-v2-adapter-proxy; if renamed, add to oldMessageIds
|
|
169
|
+
'odata-spec-violation-param': { severity: 'Warning' }, // more than 30 chars
|
|
170
|
+
// Published! Used in @sap/cds-odata-v2-adapter-proxy; if renamed, add to oldMessageIds
|
|
171
|
+
'odata-spec-violation-returns': { severity: 'Warning' }, // more than 30 chars
|
|
168
172
|
'odata-spec-violation-type': { severity: 'Error', configurableFor: true },
|
|
169
173
|
'odata-spec-violation-type-unknown': { severity: 'Warning' },
|
|
170
174
|
'odata-spec-violation-no-key': { severity: 'Warning' },
|
|
@@ -180,15 +184,6 @@ const centralMessages = {
|
|
|
180
184
|
// The keys will be added to `oldNames` of the new message, which is used for reclassification.
|
|
181
185
|
const oldMessageIds = createDict({
|
|
182
186
|
'old-anno-duplicate': 'anno-duplicate', // Example
|
|
183
|
-
|
|
184
|
-
// These IDs are used by large stakeholders. If we change them, we should
|
|
185
|
-
// be backward-compatible.
|
|
186
|
-
// 'redirected-to-complex': 'TODO',
|
|
187
|
-
// 'wildcard-excluding-one': 'TODO',
|
|
188
|
-
// 'wildcard-excluding-many': 'TODO',
|
|
189
|
-
// 'assoc-outside-service': 'TODO',
|
|
190
|
-
// 'redirected-to-same': 'TODO',
|
|
191
|
-
// 'query-navigate-many': 'TODO',
|
|
192
187
|
});
|
|
193
188
|
|
|
194
189
|
// Set up the old-to-new message ID mapping in the message registry.
|
|
@@ -206,9 +201,14 @@ for (const oldName in oldMessageIds) {
|
|
|
206
201
|
}
|
|
207
202
|
|
|
208
203
|
|
|
209
|
-
// For messageIds, where no text has been provided via code (central def)
|
|
204
|
+
// For messageIds, where no text has been provided via code (central def).
|
|
205
|
+
// DO NOT CHANGE THE VARIABLE NAME!
|
|
206
|
+
// If you change it, keep in sync with scripts/eslint/rules/message-text.js
|
|
207
|
+
|
|
210
208
|
const centralMessageTexts = {
|
|
211
209
|
'api-invalid-option': {
|
|
210
|
+
// TODO: too many different error situations for one message id,
|
|
211
|
+
// TODO: use message parameter - do not use quotes in message texts
|
|
212
212
|
std: 'Option $(NAME) is no longer supported! Use SNAPI options instead',
|
|
213
213
|
magicVars: 'Option “magicVars” is no longer supported! Use “variableReplacements” instead. See <https://cap.cloud.sap/docs/guides/databases#configuring-variables> for details',
|
|
214
214
|
user: 'Option “variableReplacements” expects “$user” instead of “user”. See <https://cap.cloud.sap/docs/guides/databases#configuring-variables> for details',
|
|
@@ -231,42 +231,118 @@ const centralMessageTexts = {
|
|
|
231
231
|
'flatten-fkey-gen': 'Duplicate definition of foreign key element $(NAME) for association $(ART)',
|
|
232
232
|
'flatten-fkey-exists': 'Generated foreign key element $(NAME) for association $(ART) conflicts with existing element',
|
|
233
233
|
},
|
|
234
|
-
|
|
235
|
-
|
|
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',
|
|
238
|
+
$tableAlias: 'A table alias name starting with $(NAME) might shadow a special variable - replace by another name',
|
|
239
|
+
$tableImplicit: 'The resulting table alias starts with $(NAME) and might shadow a special variable - specify another name with $(KEYWORD)',
|
|
240
|
+
mixin: 'A mixin name starting with $(NAME) might shadow a special variable - replace by another name',
|
|
241
|
+
},
|
|
242
|
+
// 'syntax-duplicate-excluding' (TODO: also CDL)
|
|
243
|
+
'syntax-ignoring-anno': {
|
|
236
244
|
std: 'Annotations can\'t be used at prefix references',
|
|
237
245
|
doc: 'Doc comments can\'t be used at prefix references',
|
|
238
246
|
},
|
|
247
|
+
'syntax-invalid-name': {
|
|
248
|
+
std: 'Identifier for name must not be empty', // TODO: use
|
|
249
|
+
csn: 'Property name in dictionary $(PARENTPROP) must not be empty',
|
|
250
|
+
},
|
|
251
|
+
'syntax-invalid-literal': { // TODO: write texts less CDL specific
|
|
252
|
+
'std': 'Invalid literal',
|
|
253
|
+
'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)',
|
|
258
|
+
},
|
|
259
|
+
'syntax-missing-ellipsis': 'Expecting an array item $(NEWCODE) after an item with $(CODE)',
|
|
239
260
|
'syntax-unexpected-ellipsis': {
|
|
240
|
-
std: '
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
'syntax-expected-column': 'Expected object or string \'*\' for property $(PROP)',
|
|
245
|
-
'syntax-expected-natnum': 'Expected non-negative number for property $(PROP)',
|
|
246
|
-
'syntax-expected-cardinality': 'Expected non-negative number or string \'*\' for property $(PROP)',
|
|
247
|
-
'syntax-expected-reference': 'Expected non-empty string or object for property $(PROP)',
|
|
248
|
-
'syntax-expected-term': 'Expected non-empty string or object for property $(PROP)',
|
|
249
|
-
'syntax-dollar-ident': {
|
|
250
|
-
std: 'An artifact starting with $(NAME) might shadow a special variable - replace by another name',
|
|
251
|
-
$tableAlias: 'A table alias name starting with $(NAME) might shadow a special variable - replace by another name',
|
|
252
|
-
$tableImplicit: 'The resulting table alias starts with $(NAME) and might shadow a special variable - specify another name with $(KEYWORD)',
|
|
253
|
-
mixin: 'A mixin name starting with $(NAME) might shadow a special variable - replace by another name' ,
|
|
261
|
+
std: 'Unexpected array item $(CODE)',
|
|
262
|
+
duplicate: 'Unexpected array item $(CODE) after previous $(CODE) without $(KEYWORD)',
|
|
263
|
+
'csn-duplicate': 'Unexpected object with property $(PROP) after previous array item $(CODE)',
|
|
264
|
+
'csn-nested': 'Unexpected object with property $(PROP) in nested array',
|
|
254
265
|
},
|
|
255
|
-
'syntax-
|
|
256
|
-
std: '
|
|
257
|
-
|
|
258
|
-
|
|
266
|
+
'syntax-unsupported-masked': { // configurable Error
|
|
267
|
+
std: 'The keyword $(KEYWORD) is not supported',
|
|
268
|
+
csn: 'The property $(PROP) is not supported',
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
// Syntax messages, CDL parser - default: Error ------------------------------
|
|
272
|
+
'syntax-duplicate-annotate': 'You can\'t refer to $(NAME) repeatedly with property $(PROP) in the same annotate statement',
|
|
273
|
+
'syntax-duplicate-extend': {
|
|
274
|
+
std: 'You can\'t define and refer to $(NAME) repeatedly in the same extend statement',
|
|
275
|
+
define: 'You can\'t refer to $(NAME) in the same extend statement where it was defined',
|
|
276
|
+
extend: 'You can\'t refer to $(NAME) repeatedly in the same extend statement',
|
|
259
277
|
},
|
|
260
278
|
'syntax-invalid-extend': 'Can\'t extend an element with $(KIND)',
|
|
261
279
|
'syntax-invalid-text-block': 'Missing newline in text block',
|
|
280
|
+
'syntax-unsupported-param': {
|
|
281
|
+
std: 'Parameter not supported', // unused
|
|
282
|
+
dynamic: 'Dynamic parameter $(NAME) is not supported',
|
|
283
|
+
positional: 'Positional parameter $(NAME) is not supported',
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
// Syntax messages, CSN parser - default: Error ------------------------------
|
|
287
|
+
// TODO: use one id with text variants instead of several message ids
|
|
288
|
+
'syntax-deprecated-property': { // Warning
|
|
289
|
+
std: 'Deprecated property $(PROP)', // unused
|
|
290
|
+
'zero': 'Deprecated CSN v0.1.0 property $(PROP) is ignored',
|
|
291
|
+
'zero-replace': 'Replace CSN v0.1.0 property $(PROP) by $(OTHERPROP)',
|
|
292
|
+
},
|
|
293
|
+
'syntax-deprecated-value': { // Warning
|
|
294
|
+
std: 'Deprecated representation of the value in property $(PROP)',
|
|
295
|
+
replace: 'Replace value in $(PROP) by $(VALUE)',
|
|
296
|
+
'zero-parens': 'Deprecated CSN v.0.1.0 representation of expressions in parentheses',
|
|
297
|
+
'zero-replace': 'Replace CSN v0.1.0 value in $(PROP) by $(VALUE)',
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
'syntax-expecting-object': 'Expecting object for property $(PROP)',
|
|
301
|
+
'syntax-expecting-column': 'Expecting object or string \'*\' for property $(PROP)',
|
|
302
|
+
'syntax-expecting-natnum': 'Expecting non-negative number for property $(PROP)',
|
|
303
|
+
'syntax-expecting-cardinality': 'Expecting non-negative number or string \'*\' for property $(PROP)',
|
|
304
|
+
'syntax-expecting-reference': 'Expecting non-empty string or object for property $(PROP)',
|
|
305
|
+
'syntax-expecting-term': 'Expecting non-empty string or object for property $(PROP)',
|
|
306
|
+
// 'syntax-expecting-string', 'syntax-expecting-boolean' (Warning), 'syntax-expecting-scalar',
|
|
307
|
+
// 'syntax-expecting-args', 'syntax-expecting-translation', 'syntax-expecting-array'
|
|
308
|
+
'syntax-incomplete-array': { // location at ']'
|
|
309
|
+
std: 'Expecting array in $(PROP) to have at least $(N) items',
|
|
310
|
+
one: 'Expecting array in $(PROP) to have at least one item',
|
|
311
|
+
suffix: 'With sibling property $(SIBLINGPROP), expecting array in $(PROP) to have at least one item',
|
|
312
|
+
},
|
|
313
|
+
'syntax-incomplete-object': { // location at '}'
|
|
314
|
+
std: 'Object in $(PROP) must have at least one valid CSN property',
|
|
315
|
+
as: 'Object in $(PROP) must have at least one valid CSN property other than $(OTHERPROP)',
|
|
316
|
+
},
|
|
317
|
+
// 'syntax-invalid-ref' (Warning?), 'syntax-invalid-kind', 'syntax-invalid-literal' (Warning)
|
|
318
|
+
'syntax-invalid-string': {
|
|
319
|
+
std: 'Invalid string value in property $(PROP)',
|
|
320
|
+
},
|
|
321
|
+
'syntax-missing-property': { // location at sibling or '}' otherwise
|
|
322
|
+
std: 'Object in $(PARENTPROP) must have the property $(PROP)',
|
|
323
|
+
sibling: 'Object with property $(SIBLINGPROP) must also have a property $(PROP)',
|
|
324
|
+
columns: 'Object in $(PARENTPROP) must have an expression property like $(PROP)',
|
|
325
|
+
extensions: 'Object in $(PARENTPROP) must have the property $(PROP) or $(OTHERPROP)',
|
|
326
|
+
},
|
|
327
|
+
'syntax-unexpected-property': {
|
|
328
|
+
std: 'Unexpected CSN property $(PROP)',
|
|
329
|
+
sibling: 'CSN property $(PROP) is not expected in an object with property $(SIBLINGPROP)',
|
|
330
|
+
prop: 'CSN property $(PROP) is not expected in $(PARENTPROP)',
|
|
331
|
+
top: 'CSN property $(PROP) is not expected top-level',
|
|
332
|
+
kind: 'CSN property $(PROP) is not expected by a definition of kind $(KIND)',
|
|
333
|
+
extend: 'CSN property $(PROP) is not expected by an extend in $(PARENTPROP)',
|
|
334
|
+
annotate: 'CSN property $(PROP) is not expected by an annotate in $(PARENTPROP)',
|
|
335
|
+
},
|
|
336
|
+
// 'syntax-unknown-property' (Warning? Better configurable Error)
|
|
337
|
+
|
|
262
338
|
'syntax-unknown-escape': 'Unknown escape sequence $(CODE)',
|
|
263
339
|
'syntax-invalid-escape': {
|
|
264
340
|
std: 'Invalid escape sequence $(CODE)',
|
|
265
341
|
octal: 'Octal escape sequences are not supported. Use unicode escapes instead',
|
|
266
342
|
whitespace: 'Unknown escape sequence: Can\'t escape whitespace',
|
|
267
343
|
codepoint: 'Undefined code-point for $(CODE)',
|
|
268
|
-
'unicode-hex': '
|
|
269
|
-
'hex-count': '
|
|
344
|
+
'unicode-hex': 'Expecting hexadecimal numbers for unicode escape but found $(CODE)',
|
|
345
|
+
'hex-count': 'Expecting $(NUMBER) hexadecimal numbers for escape sequence but found $(CODE)',
|
|
270
346
|
'unicode-brace': 'Missing closing brace for unicode escape sequence',
|
|
271
347
|
'language-identifier': 'Escape sequences in text-block\'s language identifier are not allowed',
|
|
272
348
|
},
|
|
@@ -274,41 +350,34 @@ const centralMessageTexts = {
|
|
|
274
350
|
std: 'Missing escape. Replace $(CODE) with $(NEWCODE)',
|
|
275
351
|
placeholder: 'Placeholders are not supported. Replace $(CODE) with $(NEWCODE)',
|
|
276
352
|
},
|
|
277
|
-
'syntax-
|
|
353
|
+
'syntax-expecting-integer': {
|
|
278
354
|
std: 'A safe integer is expected here',
|
|
279
355
|
normal: 'An integer number is expected here',
|
|
280
356
|
unsafe: 'The provided integer is too large',
|
|
281
357
|
},
|
|
282
|
-
'syntax-duplicate-argument': {
|
|
358
|
+
'syntax-duplicate-argument': { // TODO: also CDL
|
|
283
359
|
std: 'Unexpected argument $(CODE)',
|
|
284
|
-
unknown: 'Unknown argument $(CODE)',
|
|
360
|
+
unknown: 'Unknown argument $(CODE)', // huh?
|
|
285
361
|
duplicate: 'Duplicate argument $(CODE)',
|
|
286
362
|
},
|
|
287
|
-
'syntax-duplicate-annotate': 'You can\'t refer to $(NAME) repeatedly with property $(PROP) in the same annotate statement',
|
|
288
|
-
'syntax-duplicate-extend': {
|
|
289
|
-
std: 'You can\'t define and refer to $(NAME) repeatedly in the same extend statement',
|
|
290
|
-
define: 'You can\'t refer to $(NAME) in the same extend statement where it was defined',
|
|
291
|
-
extend: 'You can\'t refer to $(NAME) repeatedly in the same extend statement',
|
|
292
|
-
},
|
|
293
|
-
'syntax-invalid-literal': {
|
|
294
|
-
'std': 'Invalid literal',
|
|
295
|
-
'uneven-hex': 'A binary literal must have an even number of characters',
|
|
296
|
-
'invalid-hex': 'A binary literal must only contain characters 0-9, a-f and A-F',
|
|
297
|
-
'time': 'Expected time\'hh:mm:ss\' where hh, mm and the optional ss are numbers',
|
|
298
|
-
'date': 'Expected date\'YYYY-MM-DD\' where YYYY, MM and DD are numbers',
|
|
299
|
-
'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)',
|
|
300
|
-
},
|
|
301
363
|
'syntax-unexpected-null': 'Keyword $(KEYWORD) must appear after the enum definition and not before',
|
|
302
364
|
'syntax-unexpected-vocabulary': {
|
|
303
365
|
std: 'Annotations can\'t be defined inside contexts or services',
|
|
304
366
|
service: 'Annotations can\'t be defined inside services',
|
|
305
367
|
context: 'Annotations can\'t be defined inside contexts',
|
|
306
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
|
+
|
|
372
|
+
// Syntax messages for errorneous references ----------------------------------
|
|
373
|
+
// location at errorneous reference (if possible)
|
|
374
|
+
'ref-unexpected-self': 'Unexpected $(ID) reference; is valid only in ON-conditions',
|
|
307
375
|
'ref-undefined-def': {
|
|
308
376
|
std: 'Artifact $(ART) has not been found',
|
|
309
377
|
// TODO: proposal 'No definition of $(NAME) found',
|
|
310
|
-
element: 'Artifact $(ART) has no element $(MEMBER)'
|
|
378
|
+
element: 'Artifact $(ART) has no element $(MEMBER)',
|
|
311
379
|
},
|
|
380
|
+
'ref-undefined-param': 'Entity $(ART) has no parameter $(ID)',
|
|
312
381
|
'ref-undefined-art': 'No artifact has been found with name $(NAME)',
|
|
313
382
|
// TODO: proposal 'No definition found for $(NAME)',
|
|
314
383
|
'ref-undefined-element': {
|
|
@@ -316,6 +385,7 @@ const centralMessageTexts = {
|
|
|
316
385
|
element: 'Artifact $(ART) has no element $(MEMBER)',
|
|
317
386
|
aspect: 'Element $(ID) has not been found in the anonymous target aspect'
|
|
318
387
|
},
|
|
388
|
+
'ref-undefined-var': 'Element or variable $(ID) has not been found',
|
|
319
389
|
'ref-unknown-var': {
|
|
320
390
|
std: 'No replacement found for special variable $(ID)'
|
|
321
391
|
},
|
|
@@ -403,12 +473,37 @@ const centralMessageTexts = {
|
|
|
403
473
|
'expected-entity': 'An entity, projection or view is expected here',
|
|
404
474
|
'expected-struct': 'A type, entity, aspect or event with direct elements is expected here',
|
|
405
475
|
'expected-type': 'A type or an element is expected here',
|
|
406
|
-
//
|
|
476
|
+
// TODO: text variant if the association does not start an entity
|
|
407
477
|
'expected-source': 'A query source must be an entity or an association',
|
|
408
478
|
'expected-target': 'An entity or an aspect is expected here',
|
|
409
479
|
'extend-columns': 'Artifact $(ART) can\'t be extended with columns, only projections can',
|
|
410
480
|
'extend-repeated-intralayer': 'Unstable element order due to repeated extensions in same layer',
|
|
411
|
-
|
|
481
|
+
'extend-unexpected-include': 'Can\'t extend $(KIND) with includes',
|
|
482
|
+
'ref-expecting-bare-aspect': 'An aspect without elements is expected here',
|
|
483
|
+
|
|
484
|
+
'ext-duplicate-extend-type': 'Duplicate type extension for type $(TYPE)',
|
|
485
|
+
'ext-duplicate-extend-type-unrelated-layer': 'Duplicate type extension for type $(TYPE)',
|
|
486
|
+
'ext-invalid-type-property': {
|
|
487
|
+
std: 'Property $(PROP) can only be extended',
|
|
488
|
+
'new-prop': 'Property $(PROP) can only be extended, not added',
|
|
489
|
+
// eslint-disable-next-line max-len
|
|
490
|
+
smaller: 'Property $(PROP) can only be extended, but $(VALUE) is smaller than $(NUMBER) of type definition',
|
|
491
|
+
// eslint-disable-next-line max-len
|
|
492
|
+
'ext-smaller': 'Property $(PROP) can only be extended, but extended value $(VALUE) is smaller than $(NUMBER) from previous type extension',
|
|
493
|
+
prop: 'Type property $(PROP) can\'t be extended',
|
|
494
|
+
scale: 'If property $(PROP) is increased, then so must $(OTHERPROP)',
|
|
495
|
+
string: 'Only numerical properties can be extended, but found string for $(PROP)',
|
|
496
|
+
},
|
|
497
|
+
'ref-expected-scalar-type': {
|
|
498
|
+
std: 'Only scalar type definitions can be extended with type properties',
|
|
499
|
+
unsupported: 'Only integer-, decimal-, binary-, and string-types can be extended but found $(PROP)',
|
|
500
|
+
inferred: 'Only direct types can be extended',
|
|
501
|
+
},
|
|
502
|
+
|
|
503
|
+
'query-undefined-element': {
|
|
504
|
+
std: 'Element $(ID) has not been found in the elements of the query',
|
|
505
|
+
redirected: 'Element $(ID) has not been found in the elements of the query; please use REDIRECTED TO with an explicit ON-condition',
|
|
506
|
+
},
|
|
412
507
|
'query-unexpected-assoc-hdbcds': 'Publishing a managed association in a view is not possible for “hdbcds” naming mode',
|
|
413
508
|
'query-unexpected-structure-hdbcds': 'Publishing a structured element in a view is not possible for “hdbcds” naming mode',
|
|
414
509
|
'query-ignoring-param-nullability': {
|
|
@@ -477,9 +572,10 @@ const centralMessageTexts = {
|
|
|
477
572
|
},
|
|
478
573
|
'odata-navigation': {
|
|
479
574
|
std: 'No OData navigation property generated, target $(TARGET) is outside of service $(SERVICE)',
|
|
480
|
-
oncond: 'No OData navigation property generated for association with arbitrary ON
|
|
575
|
+
oncond: 'No OData navigation property generated for association with arbitrary ON-condition and target $(TARGET) outside of service $(SERVICE)'
|
|
481
576
|
},
|
|
482
577
|
'odata-parameter-order': 'Unexpected mandatory after optional parameter',
|
|
578
|
+
'odata-key-recursive': 'Unexpected recursive key $(NAME)',
|
|
483
579
|
}
|
|
484
580
|
|
|
485
581
|
/**
|
|
@@ -501,4 +597,6 @@ const centralMessageTexts = {
|
|
|
501
597
|
* Don't set this property directly! Append to object oldMessageIds instead!
|
|
502
598
|
*/
|
|
503
599
|
|
|
600
|
+
//console.log('FOO')
|
|
601
|
+
|
|
504
602
|
module.exports = { centralMessages, centralMessageTexts, oldMessageIds };
|