@sap/cds-compiler 2.15.8 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +102 -1590
  2. package/bin/.eslintrc.json +2 -1
  3. package/bin/cdsc.js +61 -46
  4. package/doc/API.md +11 -0
  5. package/doc/CHANGELOG_ARCHIVE.md +1592 -0
  6. package/doc/CHANGELOG_BETA.md +26 -5
  7. package/doc/CHANGELOG_DEPRECATED.md +55 -1
  8. package/doc/{DeprecatedOptions.md → DeprecatedOptions_v2.md} +3 -1
  9. package/doc/Versioning.md +20 -1
  10. package/lib/api/.eslintrc.json +2 -2
  11. package/lib/api/main.js +282 -156
  12. package/lib/api/options.js +17 -88
  13. package/lib/api/validate.js +6 -10
  14. package/lib/base/keywords.js +280 -110
  15. package/lib/base/message-registry.js +85 -25
  16. package/lib/base/messages.js +119 -89
  17. package/lib/base/model.js +46 -2
  18. package/lib/base/optionProcessorHelper.js +53 -21
  19. package/lib/checks/actionsFunctions.js +15 -12
  20. package/lib/checks/annotationsOData.js +1 -1
  21. package/lib/checks/cdsPersistence.js +1 -0
  22. package/lib/checks/elements.js +6 -6
  23. package/lib/checks/invalidTarget.js +1 -1
  24. package/lib/checks/nonexpandableStructured.js +1 -1
  25. package/lib/checks/queryNoDbArtifacts.js +2 -1
  26. package/lib/checks/selectItems.js +101 -15
  27. package/lib/checks/types.js +7 -8
  28. package/lib/checks/utils.js +2 -2
  29. package/lib/checks/validator.js +3 -3
  30. package/lib/compiler/assert-consistency.js +78 -21
  31. package/lib/compiler/base.js +6 -4
  32. package/lib/compiler/builtins.js +177 -10
  33. package/lib/compiler/checks.js +1 -1
  34. package/lib/compiler/define.js +28 -23
  35. package/lib/compiler/extend.js +75 -18
  36. package/lib/compiler/finalize-parse-cdl.js +25 -18
  37. package/lib/compiler/index.js +27 -11
  38. package/lib/compiler/moduleLayers.js +7 -0
  39. package/lib/compiler/populate.js +26 -39
  40. package/lib/compiler/propagator.js +12 -7
  41. package/lib/compiler/resolve.js +207 -236
  42. package/lib/compiler/shared.js +100 -93
  43. package/lib/compiler/tweak-assocs.js +13 -20
  44. package/lib/compiler/utils.js +20 -6
  45. package/lib/edm/annotations/preprocessAnnotations.js +12 -13
  46. package/lib/edm/csn2edm.js +35 -37
  47. package/lib/edm/edm.js +22 -13
  48. package/lib/edm/edmAnnoPreprocessor.js +349 -0
  49. package/lib/edm/edmInboundChecks.js +85 -0
  50. package/lib/edm/edmPreprocessor.js +338 -689
  51. package/lib/edm/edmUtils.js +97 -67
  52. package/lib/gen/Dictionary.json +29 -9
  53. package/lib/gen/language.checksum +1 -1
  54. package/lib/gen/language.interp +8 -31
  55. package/lib/gen/language.tokens +105 -114
  56. package/lib/gen/languageLexer.interp +1 -34
  57. package/lib/gen/languageLexer.js +892 -1007
  58. package/lib/gen/languageLexer.tokens +95 -106
  59. package/lib/gen/languageParser.js +20629 -22474
  60. package/lib/inspect/.eslintrc.json +4 -0
  61. package/lib/inspect/index.js +14 -0
  62. package/lib/inspect/inspectModelStatistics.js +81 -0
  63. package/lib/inspect/inspectPropagation.js +189 -0
  64. package/lib/inspect/inspectUtils.js +44 -0
  65. package/lib/json/from-csn.js +74 -69
  66. package/lib/json/to-csn.js +17 -14
  67. package/lib/language/antlrParser.js +2 -2
  68. package/lib/language/docCommentParser.js +61 -38
  69. package/lib/language/errorStrategy.js +52 -40
  70. package/lib/language/genericAntlrParser.js +424 -292
  71. package/lib/language/language.g4 +604 -687
  72. package/lib/language/multiLineStringParser.js +14 -42
  73. package/lib/language/textUtils.js +44 -0
  74. package/lib/main.d.ts +28 -42
  75. package/lib/main.js +104 -81
  76. package/lib/model/api.js +1 -1
  77. package/lib/model/csnRefs.js +57 -30
  78. package/lib/model/csnUtils.js +189 -287
  79. package/lib/model/revealInternalProperties.js +32 -10
  80. package/lib/model/sortViews.js +32 -31
  81. package/lib/modelCompare/compare.js +3 -0
  82. package/lib/optionProcessor.js +91 -57
  83. package/lib/render/.eslintrc.json +1 -1
  84. package/lib/render/DuplicateChecker.js +4 -7
  85. package/lib/render/manageConstraints.js +70 -2
  86. package/lib/render/toCdl.js +387 -367
  87. package/lib/render/toHdbcds.js +20 -16
  88. package/lib/render/toRename.js +44 -22
  89. package/lib/render/toSql.js +81 -59
  90. package/lib/render/utils/common.js +16 -3
  91. package/lib/render/utils/sql.js +20 -19
  92. package/lib/sql-identifier.js +6 -0
  93. package/lib/transform/db/.eslintrc.json +3 -2
  94. package/lib/transform/db/associations.js +43 -35
  95. package/lib/transform/db/cdsPersistence.js +5 -16
  96. package/lib/transform/db/constraints.js +1 -1
  97. package/lib/transform/db/expansion.js +7 -6
  98. package/lib/transform/db/flattening.js +16 -18
  99. package/lib/transform/db/transformExists.js +7 -5
  100. package/lib/transform/db/views.js +3 -3
  101. package/lib/transform/draft/.eslintrc.json +2 -2
  102. package/lib/transform/draft/db.js +6 -6
  103. package/lib/transform/draft/odata.js +6 -7
  104. package/lib/transform/forHanaNew.js +30 -24
  105. package/lib/transform/forOdataNew.js +14 -16
  106. package/lib/transform/localized.js +35 -25
  107. package/lib/transform/odata/toFinalBaseType.js +10 -10
  108. package/lib/transform/odata/typesExposure.js +17 -8
  109. package/lib/transform/odata/utils.js +1 -38
  110. package/lib/transform/transformUtilsNew.js +63 -77
  111. package/lib/transform/translateAssocsToJoins.js +2 -2
  112. package/lib/transform/universalCsn/.eslintrc.json +2 -2
  113. package/lib/transform/universalCsn/coreComputed.js +11 -6
  114. package/lib/transform/universalCsn/universalCsnEnricher.js +33 -5
  115. package/lib/utils/file.js +31 -21
  116. package/lib/utils/moduleResolve.js +0 -1
  117. package/lib/utils/timetrace.js +20 -21
  118. package/package.json +34 -4
  119. package/share/messages/syntax-expected-integer.md +9 -8
  120. package/doc/ApiMigration.md +0 -237
  121. package/doc/CommandLineMigration.md +0 -58
  122. package/doc/ErrorMessages.md +0 -175
  123. package/doc/FioriAnnotations.md +0 -94
  124. package/doc/ODataTransformation.md +0 -273
  125. package/lib/backends.js +0 -529
  126. package/lib/checks/unknownMagic.js +0 -41
  127. package/lib/fix_antlr4-8_warning.js +0 -56
@@ -1,237 +0,0 @@
1
- # API Migration
2
-
3
- > Status Oct 2019: this document is still valid, but the recommended API will change (again) in the near future.
4
- > The future version of this document (renamed to `API.md`) will basically explain the recommended API,
5
- > the migration will only be a minor aspect and explained in a later section.
6
-
7
- <!-- The option handling might also change: -->
8
- <!-- the backend-specific structure is overly complex and not always appriopriate (e.g. naming mode). -->
9
-
10
- With revision 1.0.24, the CDS compiler offers new API backend functions, i.e. new functions for the
11
- generation of output from (augmented) CSN models. The new functions and their options are closely
12
- aligned with the new command line interface `cdsc`. The old backend functions are deprecated, will
13
- not be extended with new features, and will be removed in a subsequent release. Note that only these
14
- API functions from `lib/main.js` are supported - **all internal functions are subject to change without
15
- notice**.
16
-
17
- Please see the function headers in `lib/backends.js` for a description of the new API functions (for a
18
- snapshot of the current version, see below).
19
-
20
- ## Some helpful hints
21
-
22
- Please note the following general concepts regarding the new API functions:
23
- - The behavior of the compiler and of all backend API functions is controlled by a common `options` object,
24
- with subsections for each backend function, e.g. `options: {toHana: {src: true}, toOdata: {version: 'v2'}}`.
25
- - Options can either be specified with one of the `compile` functions (transported within the model to the
26
- backends), or explicitly at the invocation of a backend API function.
27
- - Options are merged, with precedence given to those specified explicitly at the backend API functions.
28
- - When invoking a backend function with options that all belong to this backend function, the subsection wrapper
29
- can be omitted, i.e. `toHana(model, {toHana: {src: true}})` is equivalent to `toHana(model, {src: true})`.
30
- - Most backend API functions have a combination of options controlling _what_ is generated
31
- (e.g. `toHana: {src: true}`) and options modifying _how_ things are generated (e.g. `toOdata: {version: 'v2'}`).
32
-
33
- ## Migration guide
34
-
35
- The following table shows replacements for the deprecated API functions (relying on default options where possible):
36
-
37
- | Deprecated function call | New function call |
38
- | -------------------------- | ------------------------------------------- |
39
- | `toHanaCdl(model)` | `toHana(model)`|
40
- | `forHana(model)` | `toHana(model, {csn: true})`|
41
- | `toOdataOutput(model, {oDataVersion: 'v2'}` | `toOdata(model, {version: 'v2', xml: true, json: true, separate: true, combined: true, csn: true})`|
42
- | `toSqlDdl(model)` | `toSql(model)`|
43
- | `compactJson(model)` | `toCsn(model)`|
44
-
45
- ## Changes in behavior
46
-
47
- The following changes have been made to the behavior of `toOdata` in comparison to `toOdataOutput`:
48
- - Output is now generated either for ODATA V2 or for V4. The old `toOdataOutput` function produced the `annotations` output with
49
- an extra invocation of the backend using `oDataVersion: 'v4'` even if the original invocation specified `oDataVersion: 'v2'`,
50
- resulting in slightly different output. The `combined` output always had the correct versioning.
51
- - The `metadata_json` output is now an object, not a string.
52
-
53
- ## Snapshot of backend API function documentation
54
-
55
- Note that these backend API functions are all exposed in `lib/main.js` (which is **the only external API**), but
56
- their documentation is currently located in `lib/backends.js` (this will likely change).
57
-
58
- ### `toHana(model, options)`
59
-
60
- ```
61
- // Transform an augmented CSN 'model' into HANA-compatible CDS source.
62
- // The following options control what is actually generated:
63
- // options : {
64
- // toHana.names : either 'plain' (generate uppercased flattened entity names with
65
- // underscores) or 'quoted' (default, generate entity names with nested
66
- // contexts as in CDL)
67
- // toHana.associations : either 'assocs' (default, keep associations as they are if possible)
68
- // or 'joins' (replace associations by joins)
69
- // toHana.src : if true, generate HANA CDS source files (default)
70
- // toHana.csn : if true, generate the transformed CSN model
71
- // }
72
- // Options provided here are merged with (and take precedence over) options from 'model'.
73
- // If 'toHana.names' is not provided, 'quoted' is used.
74
- // If 'toHana.associations' is not provided, 'assocs' is used.
75
- // If neither 'toHana.src' nor 'toHana.csn' are provided, the default is to generate only HANA CDS
76
- // source files.
77
- // If all provided options are part of 'toHana', the 'toHana' wrapper can be omitted.
78
- // The result object contains the generation results as follows (as enabled in 'options'):
79
- // result : {
80
- // csn : the (compact) transformed CSN model
81
- // _augmentedCsn : (subject to change): the augmented CSN model
82
- // hdbcds : a dictionary of top-level artifact names, containing for each name 'X':
83
- // <X> : the HANA CDS source string of the artifact 'X'. Please note that the
84
- // name of 'X' may contain characters that are not legal for filenames on
85
- // all operating systems (e.g. ':', '\' or '/').
86
- // messages : an array of strings with warnings (if any)
87
- // }
88
- function toHana(model, options) {
89
- ...
90
- }
91
- ```
92
-
93
- ### `toOdata(model, options)`
94
-
95
- ```
96
- // Generate ODATA for augmented CSN `model` using `options`.
97
- // Before anything is generated, the following transformations are applied to 'model':
98
- // FIXME: Verify that this is still correct
99
- // - Flatten structured elements (and foreign keys of managed associations pointing to
100
- // keys that are themselves managed associations).
101
- // - Generate foreign key fields for entities with managed associations (annotated with
102
- // '@odata.foreignKey4'). Propagate along projections accordingly. Names are built using
103
- // <assoc>_<key>, conflicts are checked.
104
- // - Complete the 'foreignKeys' property for all managed associations, so that there
105
- // is always a 'generatedFieldName' for the corresponding generated foreign key field.
106
- // - Implicitly redirect associations based on exposure
107
- // - Check that exposed associations do not point to non-exposed targets
108
- // - Unravel derived type chains, propagating annotations upwards.
109
- // - Rename annotations according to a fixed list of short-hands
110
- // The following options control what is actually generated:
111
- // options : {
112
- // toOdata.version : either 'v2' or 'v4' (default)
113
- // toOdata.xml : if true, generate XML output (default)
114
- // toOdata.json : if true, generate JSON output (not available for ODATA V2)
115
- // toOdata.separate : if true, generate XML 'metadata' and XML 'annotations' separately
116
- // toOdata.combined : if true, generate XML metadata and XML annotations together as
117
- // 'combined' (default)
118
- // toOdata.csn : if true, generate the transformed CSN model
119
- // }
120
- // Options provided here are merged with (and take precedence over) options from 'model'.
121
- // If 'toOdata.version' is not provided, 'v4' is used.
122
- // If neither 'toOdata.xml' nor 'toOdata.json' nor 'toOdata.csn' are provided, the default is
123
- // to generate only XML output. If neither 'toOdata.separate' nor 'toOdata.combined' are provided,
124
- // the default is to generate only combined XML output.
125
- // If all provided options are part of 'toOdata', the 'toOdata' wrapper can be omitted.
126
- //
127
- // The result object contains the generation results as follows (as enabled in 'options'):
128
- // result : {
129
- // csn : the (compact) transformed CSN model including all services
130
- // _augmentedCsn : (subject to change): the augmented CSN model including all services
131
- // services : a dictionary of service names, containing for each name:
132
- // <servicename> : {
133
- // annotations : an XML string with EDMX annotations for service 'svc'
134
- // metadata : an XML string with EDMX metadata for service 'svc'
135
- // combined : an XML string with both EDMX metadata and annotations for service 'svc'
136
- // metadata_json : a JSON object (not a string!) with EDM metadata for service 'svc'
137
- // }
138
- // messages : an array of strings with warnings (if any)
139
- // }
140
- // If 'model' does not contain any services, 'csn' will still contain the transformed model, but
141
- // 'services' will be an empty dictionary.
142
- //
143
- // Throws a CompilationError on errors.
144
- function toOdata(model, options) {
145
- ...
146
- }
147
- ```
148
-
149
- ### `toCdl(model, options)`
150
-
151
- ```
152
- // Generate CDS source text for augmented CSN model 'model'.
153
- // The following options control what is actually generated:
154
- // options : {
155
- // FIXME: This option should be removed and something like 'toCdl.dialect: 'hana' be
156
- // used instead.
157
- // hanaFlavor : if true, HANA-specific source dialect is generated (affects e.g. the
158
- // translation of '$self.foo' in paths and ::-ish namespace declarations)
159
- // }
160
- // One source is created per top-level artifact.
161
- // Return a dictionary of top-level artifacts
162
- // by their names, like this:
163
- // { "foo" : "using XY; context foo {...};",
164
- // "bar::wiz" : "namespace bar::; entity wiz {...};"
165
- // }
166
- // Throws a CompilationError on errors.
167
- function toCdl(model, options) {
168
- ...
169
- }
170
- ```
171
-
172
- ### `toSwagger(model, options)`
173
-
174
- ```
175
- // Generate OpenAPI JSON version 3 for the augmented CSN 'model'.
176
- // Return an object representing the Swagger JSON:
177
- // {
178
- // openapi: '3.0.0',
179
- // info: { ... },
180
- // paths: { ...},
181
- // components: {
182
- // schemas: { ... }
183
- // }
184
- // }
185
- //
186
- // Throws a CompilationError on errors.
187
- function toSwagger(model, options) {
188
- ...
189
- }
190
- ```
191
-
192
- ### `toSql(model, options)`
193
-
194
- ```
195
- // Generate SQL DDL statements for augmented CSN 'model'.
196
- // The following options control what is actually generated:
197
- // options : {
198
- // toSql.names : either 'plain' (generate uppercased flattened table/view names with
199
- // underscores) or 'quoted' (default, generate quoted table/view names
200
- // with dots as in CDL)
201
- // toSql.associations : either 'assocs' (default, keep associations as they are if possible)
202
- // or 'joins' (replace associations by joins)
203
- // toSql.src : if 'sql', generate SQL DDL source files (default)
204
- // toSql.csn : if true, generate the transformed CSN model
205
- // }
206
- // Options provided here are merged with (and take precedence over) options from 'model'.
207
- // If 'toSql.names' is not provided, 'quoted' is used.
208
- // If 'toSql.associations' is not provided, 'assocs' is used.
209
- // If neither 'toSql.src' nor 'toSql.csn' are provided, the default is to generate only SQL DDL
210
- // source files.
211
- // If all provided options are part of 'toSql', the 'toSql' wrapper can be omitted.
212
- // The result object contains the generation results as follows (as enabled in 'options'):
213
- // result : {
214
- // csn : the (compact) transformed CSN model
215
- // _augmentedCsn : (subject to change): the augmented CSN model
216
- // sql : a dictionary of top-level artifact names, containing for each name 'X':
217
- // <X> : a string with SQL DDL statements for artifact 'X', terminated with ';'.
218
- // Please note that the name of 'X' may contain characters that are not
219
- // legal for filenames on all operating systems (e.g. ':', '\' or '/').
220
- // messages : an array of strings with warnings (if any)
221
- // }
222
- // Throws a CompilationError on errors.
223
- ```
224
-
225
- ### `toCsn(model, options)`
226
-
227
- ```
228
- // Generate compact CSN for augmented CSN 'model'
229
- // The following options control what is actually generated:
230
- // options : {
231
- // testMode : if true, the result is extra-stable for automated tests (sorted, no 'version')
232
- // }
233
- // Options provided here are merged with (and take precedence over) options from 'model'.
234
- function toCsn(model, options) {
235
- ...
236
- }
237
- ```
@@ -1,58 +0,0 @@
1
- # Command Line Migration
2
-
3
- > Status Oct 2019: this document is still basically valid.
4
- > The future version of this document (renamed to `CommandLine.md`) will basically explain the recommended CLI options,
5
- > the migration will only be a minor aspect and explained in a later section.
6
-
7
- <!-- The option handling might also change: -->
8
- <!-- the backend-specific structure is overly complex and not always appriopriate (e.g. naming mode). -->
9
- <!-- The placement of options should not depend on a not always apparent distinction between command-specific and general options. -->
10
-
11
-
12
- With revision 1.5.1, the `cdsc` command line interface has been adapted to use commands with
13
- options.
14
-
15
- Usage is now `cdsc <command> [options] <files...>` instead of `cdsc [options] <file...>`.
16
-
17
- The generation options (`--toHana`, `--toSql`, ...) have been replaced by commands
18
- (`toHana`, `toSql`, ...). This allows for better per-command options, which can now be optional,
19
- can use more single-letter abbreviations, and now match those from the `options` object in the API.
20
-
21
- Some examples:
22
-
23
- | Old command line | New command line |
24
- | -------------------------- | --------------------------------------------- |
25
- | `cdsc --new-csn --toHana csn,plain foo.cds` | `cdsc --new-csn toHana --csn --names plain foo.cds` |
26
- | `cdsc -R --H csn,plain foo.cds` | `cdsc -R H -c -n plain foo.cds` |
27
- | `cdsc --toOdata xml,v2,separate foo.cds` | `cdsc toOdata --xml --version v2 --separate foo.cds` |
28
- | `cdsc --toSql src foo.cds` | `cdsc toSql foo.cds` |
29
- | `cdsc foo.cds` | `cdsc foo.cds` |
30
-
31
- List of commands (as of v1.5.1):
32
-
33
- ```
34
- Commands
35
- H, toHana [options] <files...> Generate HANA CDS source files
36
- O, toOdata [options] <files...> Generate ODATA metadata and annotations
37
- C, toCdl <files...> Generate CDS source files
38
- S, toSwagger [options] <files...> Generate Swagger (OpenAPI) JSON
39
- Q, toSql [options] <files...> Generate SQL DDL statements
40
- toCsn [options] <files...> (default) Generate original model as CSN
41
- toTntSpecificOutput <files...> (internal) Generate TNT-specific post-processed CSN
42
- toRename [options] <files...> (internal) Generate SQL DDL rename statements
43
- ```
44
-
45
- Please see `cdsc --help` for the list of commands and general options, or `cdsc <command> --help`
46
- for help regarding a specific command.
47
-
48
- ## Some helpful hints
49
-
50
- Please note the following general concepts regarding the new command line:
51
- - General options can be placed anywhere, command specific options must appear after the command.
52
- - In the unlikely case that a file name starts with `-`, please use `--` to indicate the end of options.
53
- - The `src` argument of `toHana`, `toCdl`, `toSql` is now optional (and it would now be `--src`).
54
- - If no command is specified, the default is `toCsn --flavor client` (as before).
55
- - When no `--out` option is provided or if `-` is specified as output directory , all output will
56
- go to `<stdout>` instead of being written to files (like before).
57
- - The `--raw-output` option also affects all commands where a CSN file is generated.
58
- Instead of `...csn.json`, a `...csn_raw.txt` will be produced (like before).
@@ -1,175 +0,0 @@
1
- # Error Messages Explained
2
-
3
- > Status Oct 2019: up-to-date
4
-
5
- This document tries to explain some of the less-obvious error messages.
6
-
7
- ## Common Compiler Messages (Independent From Backend)
8
-
9
- ### Duplicate definitions
10
-
11
- In most cases, you really have just used the same name twice when defining an artifact.
12
- This section is about a situation where you are pretty sure that you have not done that.
13
-
14
- ```
15
- node_modules/Base/index.cds:1:6-7: Error: Duplicate definition of artifact "T"
16
- node_modules/base/index.cds:1:6-7: Error: Duplicate definition of artifact "T"
17
- node_modules/dep/node_modules/model/index.cds:1:8-9: Error: Duplicate definition of artifact "E"
18
- node_modules/model/index.cds:1:8-9: Error: Duplicate definition of artifact "E"
19
- ```
20
-
21
- Here, the CDS Compiler considers `…/Base/index.cds` to be different to `…/base/index.cds`,
22
- and also considers the two `…/model/index.cds` files to be different files.
23
- Why is that the case? Consider the following "top-level" file
24
-
25
- ```
26
- using from 'Base'; // upper-case 'B'!
27
- using from 'model';
28
- using from 'dep';
29
- ```
30
-
31
- File node_modules/dep/index.cds` looks like:
32
-
33
- ```
34
- using from 'base'; // lower-case 'b'!
35
- using from 'model';
36
- ```
37
-
38
- `node_modules/Base/index.cds` is the same file as
39
- `node_modules/base/index.cds` on case-insensitive file systems (Windows, Mac):
40
-
41
- ```
42
- type T: Integer;
43
- ```
44
-
45
- We have `node_modules/model/index.cds` and a copy of it in
46
- `node_modules/dep/node_modules/model/index.cds`:
47
-
48
- ```
49
- entity E { i: Integer; }
50
- ```
51
-
52
- The technical explanation is that the CDS Compiler considers
53
- two file names pointing to the same file if their `fs.realpath` is equal.
54
- That means that we properly _recognize symlinks_ (Linux, Mac),
55
- but we do _not_ recognize two files to be equal if:
56
-
57
- * the same file is referred to with different name casing,
58
- which does not work on case-sensitive file systems (Linux) anyway
59
- (yes, we might issue a better message when `node v9.2` is widely adopted),
60
- * a file is _copied_ within the NPM package (or when _hardlinks_ are used).
61
-
62
- The CDL code/package can be corrected as follows:
63
-
64
- * Use __consistent casing__ when referring to file and modules in `using from`
65
- (if in doubt, please check the error output provided by the CDS compiler client tool).
66
- * __Clean up a dirty NPM installation__. Then, the file
67
- `node_modules/dep/node_modules/model/index.cds` should disappear
68
- (or be a symlink to `node_modules/model/index.cds`).
69
-
70
-
71
- ### Nested extensions
72
-
73
- If you use nested extensions, you might get messages like:
74
-
75
- ```
76
- nested-extensions.cds:3:20-26: Error: No `EXTEND artifact` within CONTEXT extensions
77
- nested-extensions.cds:4:20-28: Error: No `ANNOTATE artifact` within SERVICE extensions
78
- nested-extensions.cds:5:14-22: Error: Elements only exist in entities, types or typed constructs
79
- nested-extensions.cds:6:12-36: Error: Elements only exist in entities, types or typed constructs
80
- ```
81
-
82
- Artifacts (entities, types, …) should not be extended within other extensions –
83
- just elements (and other members) are to be extended within an artifact extension.
84
- The above messages are reported for the following CDL code:
85
-
86
- ```
87
- context C { entity E { d: Integer; } }
88
- service S { entity E { d: Integer; } }
89
- extend context C { extend C.E { e: Integer; } }
90
- extend service S { annotate S.E @Anno; }
91
- annotate C { E @Anno; }
92
- extend S { extend E { e: Integer; } }
93
- ```
94
-
95
- The reason for these messages is – if we would allow it:
96
-
97
- * If we follow the [normal name resolution rules](NameResolution.md),
98
- people would have to refer to the entity the same way
99
- as outside `extend context`/`extend service`.
100
- Most people would probably expect being able
101
- to write just `E` instead `C.E`/`S.E` in line 3 and 4,
102
- but this not only require special rules, but leads to other surprises – see below.
103
- * Using `{ … }` inside a plain `annotate` or `extend` statement
104
- is supposed to annotate/extend elements (or enums), not containing artifacts.
105
-
106
- The CDL code can be corrected as follows:
107
-
108
- ```
109
- context C { entity E { d: Integer; } }
110
- service S { entity E { d: Integer; } }
111
- extend C.E { e: Integer; }
112
- annotate S.E @Anno;
113
- annotate C.E @Anno;
114
- extend S.E { e: Integer; }
115
- ```
116
-
117
- Now consider that you could use the following to extend the entity `C.E`:
118
-
119
- ```
120
- context C { entity E { key d: Integer; } }
121
- entity E { key x: Integer; }
122
- extend context C {
123
- extend E { e: Integer; } // i.e. extend C.E
124
- }
125
- extend context C {
126
- entity F { a: association to E; } // target: E, not C.E (normal name resolution)
127
- }
128
- ```
129
-
130
- What about combining the two `extend context`:
131
-
132
- ```
133
- context C { entity E { key d: Integer; } }
134
- entity E { key x: Integer; }
135
- extend context C {
136
- extend E { e: Integer; } // i.e. extend C.E
137
- entity F { a: association to E; } // target: E or C.E ?
138
- }
139
- ```
140
-
141
- In summary, allowing artifact extensions inside `extend context`/`extend service`
142
- would provide little benefit, but would add complexity and confusion.
143
-
144
-
145
- ### Redirection issues
146
-
147
- The target `OrigTarget` of an existing association can only be redirected to another target `NewTarget`
148
- if the `NewTarget` is a direct or indirect projection of `OrigTarget`
149
- (complex views are questionable and lead to a Warning),
150
- or an entity definition which directly or indirectly includes `OrigTarget`.
151
-
152
- ```
153
- entity Base {
154
- key i: Integer;
155
- }
156
- entity Proj as projection on Base;
157
- entity NewTarget as projection on Intermediate;
158
- entity Intermediate as projection on Base;
159
-
160
- entity Assocs {
161
- base: association to Base;
162
- proj: association to Proj;
163
- }
164
- entity Redirect as projection on Assocs {
165
- base: redirected to NewTarget, // works
166
- proj: redirected to NewTarget // ERROR: does not originate from Proj
167
- }
168
- ```
169
-
170
- For the above CDS code, you get the following error message:
171
-
172
- ```
173
- redirect-to-unrelated.cds:16:25-34: Error: The redirected target does not originate from "Proj"
174
- (in entity:"Redirect"/element:"proj")
175
- ```
@@ -1,94 +0,0 @@
1
- # Translation of Fiori annotations
2
-
3
- > Status Oct 2019: too vague, old links, to be moved to internalDoc if we want to keep it.
4
-
5
- Fiori annotations are translated in a generic way. Essentially, write down in CDS precisely what you want to get in edmx.
6
-
7
- A more detailed description will follow soon, for the time being we hope the following example will give the idea:
8
-
9
- These CDS annotations
10
- ```
11
- @(
12
- UI.Chart : {
13
- ChartType: #Bullet,
14
- Measures: [ Revenue ],
15
- MeasureAttributes: [
16
- {
17
- Measure: Revenue,
18
- Role: #Axis1,
19
- DataPoint: '@UI.DataPoint#BulletChartDataPoint'
20
- }
21
- ]
22
- },
23
- UI.DataPoint#BulletChartDataPoint: {
24
- Title: 'Product',
25
- Value: Revenue,
26
- TargetValue: TargetRevenue,
27
- ForecastValue: ForecastRevenue,
28
- MinimumValue: MinValue,
29
- MaximumValue: MaxValue,
30
- CriticalityCalculation: {
31
- ImprovementDirection: #Target,
32
- ToleranceRangeLowValue: ToleranceRangeLow,
33
- ToleranceRangeHighValue: ToleranceRangeHigh,
34
- DeviationRangeLowValue: DeviationRangeLow,
35
- DeviationRangeHighValue: DeviationRangeHigh
36
- }
37
- }
38
- )
39
- Something ...;
40
- ```
41
- are translated into the following edmx:
42
- ```xml
43
- <Annotations Target="Something">
44
- <Annotation Term="UI.Chart">
45
- <Record>
46
- <PropertyValue EnumMember="UI.ChartType/Bullet"
47
- Property="ChartType" />
48
- <PropertyValue Property="Measures">
49
- <Collection>
50
- <PropertyPath>Revenue</PropertyPath>
51
- </Collection>
52
- </PropertyValue>
53
- <PropertyValue Property="MeasureAttributes">
54
- <Collection>
55
- <Record Type="UI.ChartMeasureAttributeType">
56
- <PropertyValue Property="Measure" PropertyPath="Revenue" />
57
- <PropertyValue Property="Role" EnumMember="UI.ChartMeasureRoleType/Axis1" />
58
- <PropertyValue Property="DataPoint" AnnotationPath="@UI.DataPoint#BulletChartDataPoint" />
59
- </Record>
60
- </Collection>
61
- </PropertyValue>
62
- </Record>
63
- </Annotation>
64
- <Annotation Term="UI.DataPoint" Qualifier="BulletChartDataPoint">
65
- <Record>
66
- <PropertyValue String="Product" Property="Title" />
67
- <PropertyValue Path="Revenue" Property="Value" />
68
- <PropertyValue Path="TargetRevenue" Property="TargetValue" />
69
- <PropertyValue Path="ForecastRevenue" Property="ForecastValue" />
70
- <PropertyValue Path="MinValue" Property="MinimumValue" />
71
- <PropertyValue Path="MaxValue" Property="MaximumValue" />
72
- <PropertyValue Property="CriticalityCalculation">
73
- <Record>
74
- <PropertyValue Property="ImprovementDirection" EnumMember="UI.ImprovementDirectionType/Target" />
75
- <PropertyValue Path="ToleranceRangeLow" Property="ToleranceRangeLowValue" />
76
- <PropertyValue Path="ToleranceRangeHigh" Property="ToleranceRangeHighValue" />
77
- <PropertyValue Path="DeviationRangeLow" Property="DeviationRangeLowValue" />
78
- <PropertyValue Path="DeviationRangeHigh" Property="DeviationRangeHighValue" />
79
- </Record>
80
- </PropertyValue>
81
- </Record>
82
- </Annotation>
83
- </Annotations>
84
- ```
85
-
86
-
87
- All suppoted Fiori annotations are defined in the following vocabularies:
88
- * [Core](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/vocabularies/Org.OData.Core.V1.xml)
89
- * [Measures](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/vocabularies/Org.OData.Measures.V1.xml)
90
- * [Capabilities](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/vocabularies/Org.OData.Capabilities.V1.xml)
91
- * [Aggregation](http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs02/vocabularies/Org.OData.Aggregation.V1.xml)
92
- * [Common](https://wiki.scn.sap.com/wiki/download/attachments/448470974/Common.xml?api=v2)
93
- * [Communication](https://wiki.scn.sap.com/wiki/download/attachments/448470971/Communication.xml?api=v2)
94
- * [UI](https://wiki.scn.sap.com/wiki/download/attachments/448470968/UI.xml?api=v2)