@sap/xsodata 8.0.2 → 8.1.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.
- package/CHANGELOG.md +12 -0
- package/README.md +13 -11
- package/documentation/aggregations.md +46 -0
- package/documentation/annotations.md +401 -0
- package/documentation/authorization.md +94 -0
- package/documentation/calcviewSample.md +17 -0
- package/documentation/code_samples_pure_node/direct_use__multi_services/index.js +49 -0
- package/documentation/code_samples_pure_node/direct_use__multi_services/package.json +8 -0
- package/documentation/code_samples_pure_node/direct_use__multi_services/services/demo.xsodata +7 -0
- package/documentation/code_samples_pure_node/direct_use__multi_services/services/demo_nav.xsodata +47 -0
- package/documentation/code_samples_pure_node/direct_use__single_service/index.js +48 -0
- package/documentation/code_samples_pure_node/direct_use__single_service/package.json +8 -0
- package/documentation/code_samples_pure_node/direct_use__single_service/services/demo.xsodata +7 -0
- package/documentation/code_samples_pure_node/expressjs__multi_services/index.js +53 -0
- package/documentation/code_samples_pure_node/expressjs__multi_services/package.json +11 -0
- package/documentation/code_samples_pure_node/expressjs__multi_services/public/index.html +27 -0
- package/documentation/code_samples_pure_node/expressjs__multi_services/services/demo.xsodata +7 -0
- package/documentation/code_samples_pure_node/expressjs__multi_services/services/demo_nav.xsodata +47 -0
- package/documentation/code_samples_pure_node/expressjs__single_service/index.js +52 -0
- package/documentation/code_samples_pure_node/expressjs__single_service/package.json +11 -0
- package/documentation/code_samples_pure_node/expressjs__single_service/public/index.html +18 -0
- package/documentation/code_samples_pure_node/expressjs__single_service/services/demo.xsodata +7 -0
- package/documentation/code_samples_pure_node/readme.md +32 -0
- package/documentation/customExits.md +270 -0
- package/documentation/db.md +35 -0
- package/documentation/debugView.md +13 -0
- package/documentation/generatedKeys.md +58 -0
- package/documentation/limitations.md +20 -0
- package/documentation/modes.md +48 -0
- package/documentation/readme.md +83 -0
- package/documentation/supportedMethods.md +28 -0
- package/documentation/supportedSystemQueryOptions.md +75 -0
- package/documentation/typemapping.md +32 -0
- package/documentation/xsodataEbnf.md +88 -0
- package/documentation/xsodataSettings.md +97 -0
- package/lib/db/dbSegment.js +1 -1
- package/package.json +20 -17
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
|
8
8
|
|
|
9
9
|
## Unreleased
|
|
10
10
|
|
|
11
|
+
## [8.1.1] - 2023-11-30
|
|
12
|
+
|
|
13
|
+
* Add support for node 20
|
|
14
|
+
* Remove support for node 14
|
|
15
|
+
* Remove support for node 16
|
|
16
|
+
* Update dependencies
|
|
17
|
+
* Security fix - update @sap/xssec library to version 3.6.0
|
|
18
|
+
|
|
19
|
+
## [8.1.0] - 2023-02-20
|
|
20
|
+
* Add support Node.js 18
|
|
21
|
+
* Update node module dependencies
|
|
22
|
+
|
|
11
23
|
## [8.0.2] - 2023-01-30
|
|
12
24
|
|
|
13
25
|
* Security fix - update @sap/xssec library to version 3.2.17.
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@ XSODATA
|
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
4
|
Expose data from HANA database artifacts like tables or views as OData V2 service with the help of .xsodata service definition files.
|
|
5
|
+
Starting from version 8.1.1 - XSODATA is supported only with @sap/async-xsjs library. @sap/xsjs is deprecated and no new versions will be
|
|
6
|
+
released. [see CHANGELOG](./CHANGELOG.md)
|
|
5
7
|
|
|
6
8
|
Note: XSOData was developed to provide XS Classic users using XSOData the possibility to migrate to XS Advanced on node.js.
|
|
7
9
|
This library contains nearly the same feature set as XSOData provided on SAP HANA XS Classic. This module is already
|
|
@@ -14,19 +16,19 @@ Note: XSOData was developed to provide XS Classic users using XSOData the possib
|
|
|
14
16
|
For node.js we also provide an OData V4 solution. The development of the OData V4 node.js Library already started in 2016.
|
|
15
17
|
It is also planned that a generic CDS-Odata provider will be deliverd.
|
|
16
18
|
|
|
17
|
-
If you are developing an OData service for SAP Business Technology Platform, it is recommended to move to the SAP Cloud Application Programming Model (
|
|
18
|
-
The XSODATA solution supports HANA as a service,
|
|
19
|
+
If you are developing an OData service for SAP Business Technology Platform, it is recommended to move to the SAP Cloud Application Programming Model (CAP).
|
|
20
|
+
The XSODATA solution supports HANA as a service, also support was introduced for SAP HANA Cloud Services from XSODATA v8.0.0 and above.
|
|
19
21
|
|
|
20
22
|
## Usage
|
|
21
23
|
|
|
22
|
-
* This module is used in the XSJS shim for SAP HANA XSC Engine applications to
|
|
24
|
+
* This module is used in the XSJS/ASYNC-XSJS shim for SAP HANA XSC Engine applications to
|
|
23
25
|
allow the reuse of .xsodata files from XSC applications on SAP HANA XSA.
|
|
24
26
|
|
|
25
27
|
* It can also be used directly in your own nodejs server application. Be aware that you use the same version of the hdb and winston node module version in your application.
|
|
26
28
|
|
|
27
29
|
## Documentation
|
|
28
30
|
|
|
29
|
-
[For documentation see here](./documentation
|
|
31
|
+
[For documentation see here](./documentation)
|
|
30
32
|
|
|
31
33
|
## Warning
|
|
32
34
|
|
|
@@ -49,7 +51,7 @@ Note: XSOData was developed to provide XS Classic users using XSOData the possib
|
|
|
49
51
|
* Calculation view support
|
|
50
52
|
* Batch handling
|
|
51
53
|
* Logging:
|
|
52
|
-
When the xsjs application log is enabled then xsodata also writes log information.
|
|
54
|
+
When the xsjs/async-xsjs application log is enabled then xsodata also writes log information.
|
|
53
55
|
If, in addition, the environment variable XSODATA_LOG_MEMORY_CONSUMPTION is set to 'true'
|
|
54
56
|
xsodata writes also memory consumption information to the logs
|
|
55
57
|
|
|
@@ -96,28 +98,28 @@ CreateUpdateDelete Requests:
|
|
|
96
98
|
* Create/update/delete restrictions of OData requests
|
|
97
99
|
* Exposure of table and views (including calculation views) as EntitySet
|
|
98
100
|
* Property Projection: Expose a subset of the table columns as properties of an OData EntityType
|
|
99
|
-
* [Automatic OData key generation]
|
|
101
|
+
* [Automatic OData key generation](/documentation/generatedKeys.md), e.g. required for aggregated views
|
|
100
102
|
* Simple and complex associations
|
|
101
|
-
* [Data aggregation]
|
|
103
|
+
* [Data aggregation](/documentation/aggregations.md)
|
|
102
104
|
* Parameter EntitySets for calculation views
|
|
103
105
|
* ETAG handling
|
|
104
106
|
* Nullable properties
|
|
105
107
|
* Cache Control via cache header
|
|
106
|
-
* [Custom exits]
|
|
108
|
+
* [Custom exits](/documentation/customExits.md) (JavaScript and SQL Script) for modification and validation requests
|
|
107
109
|
* Custom exits in batch requests
|
|
108
110
|
* Uses only UTF-8
|
|
109
111
|
* Uses "content-type: application/json" for CREATE, UPDATE, DELETE
|
|
110
112
|
* Expose data only via JSON format (ATOM format is not supported)
|
|
111
113
|
* Supported types and type mapping [see here](/documentation/typemapping.md)
|
|
112
|
-
* [Supported XSOData features by OSDL]
|
|
114
|
+
* [Supported XSOData features by OSDL](/documentation/xsodataEbnf.md)
|
|
113
115
|
|
|
114
116
|
|
|
115
117
|
Note:
|
|
116
118
|
|
|
117
119
|
* XS1 applications using analytical views, attribute views or calculation views <= SAP HANA SPS 10 have to migrate first their views to the new calculation views of SPS 11.
|
|
118
120
|
* Authentication/Authorisation is not handled by XSOData node module and has to be done by the application using the node module.
|
|
119
|
-
* [The module can be used in development mode and productive mode]
|
|
120
|
-
* [Debug View is available when using the module in development mode]
|
|
121
|
+
* [The module can be used in development mode and productive mode](/documentation/modes.md)
|
|
122
|
+
* [Debug View is available when using the module in development mode](/documentation/debugView.md)
|
|
121
123
|
|
|
122
124
|
## Features per HANA DB Artifact
|
|
123
125
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
OData Aggregations
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
XS Classic SPS10
|
|
5
|
+
----------------
|
|
6
|
+
|
|
7
|
+
Documentation Chapter 7.1.6.7 p. 488
|
|
8
|
+
|
|
9
|
+
The results of aggregations on columns change dynamically depending on the grouping conditions. This means that aggregation cannot be performed in SQL views; it needs to be specified in the OData service definition itself. Depending on the type of object to expose, you need to explicitly specify the columns to aggregate and the function to use or derived them from metadata in the database.
|
|
10
|
+
In general, aggregations do not have consequences for the metadata document. It just effects the semantics of the concerning properties during runtime. The grouping condition for the aggregation contain all selected non-aggregated properties. Furthermore, aggregated columns cannot be used in $filter, and aggregation is only possible with generated keys.
|
|
11
|
+
p. 488
|
|
12
|
+
|
|
13
|
+
XSOData
|
|
14
|
+
-------
|
|
15
|
+
|
|
16
|
+
In xsodata two types of aggregations are supported, implicit or derived aggregations and explicit aggregations. Both aggregations have to be defined in the OData service definition in the *.xsodata* file.
|
|
17
|
+
|
|
18
|
+
### Explicit Aggregations
|
|
19
|
+
|
|
20
|
+
For explicit aggregations the aggregate columns have to be made explicit in the service definition:
|
|
21
|
+
|
|
22
|
+
```xsodata
|
|
23
|
+
service {
|
|
24
|
+
"package::revenues" as "Revenues"
|
|
25
|
+
keys generate local "ID"
|
|
26
|
+
aggregates always (SUM of "Amount");
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Supported aggregations are: **SUM**, **MIN**, **MAX**, **AVG**
|
|
31
|
+
Supported db artifacts: **Tables**, **Views**
|
|
32
|
+
|
|
33
|
+
### Implicit/derived Aggregations
|
|
34
|
+
|
|
35
|
+
Supported only for **CalculationView** db artifacts which define the aggregations intrinsic.
|
|
36
|
+
|
|
37
|
+
Assuming PLANNED_ACTUAL_SALES is a calculation view, the service definition would look like:
|
|
38
|
+
|
|
39
|
+
```xsodata
|
|
40
|
+
service {
|
|
41
|
+
"package::PLANNED_ACTUAL_SALES " as "PlannedvsActualCalcView"
|
|
42
|
+
keys generate local "ID"
|
|
43
|
+
aggregates always
|
|
44
|
+
parameters via entity "InputParams";
|
|
45
|
+
}
|
|
46
|
+
```
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
# SAP OData Annotations
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
The second version of the OData protocol allows usage of annotations in the $metadata document. The purpose of the
|
|
5
|
+
annotations is to add a documentation or/and hints to the EDM elements. The added information can be used by the service
|
|
6
|
+
clients (e.g. SAPUI5 application) to better represent the service entities. The annotations are divided into annotation
|
|
7
|
+
elements and annotation attributes, represented as XML elements and XML attributes respectively.
|
|
8
|
+
|
|
9
|
+
The OData protocol defines the concept of the annotations without adding any concrency concerning the particular names
|
|
10
|
+
and values, which can / should be used for them. SAP defines its own specific set of annotations documented at
|
|
11
|
+
https://scn.sap.com/docs/DOC-44986. Only some of them are supported in XSOData XS2.
|
|
12
|
+
|
|
13
|
+
By default, the annotations will not be serialized in the $metadata document of an XSOData service. In order to enable
|
|
14
|
+
the annotations for a particular XSOData service, the following configuration has to be specified in the .xsodata file:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
annotations {
|
|
18
|
+
enable OData4SAP;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The configuration has to be specified right after the service element, for example:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
service ... {
|
|
26
|
+
...
|
|
27
|
+
}
|
|
28
|
+
annotations {
|
|
29
|
+
enable OData4SAP;
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If the annotations are enabled for an XSOData service, the following XML namespace will be added for the Edmx element
|
|
34
|
+
of the $metadata document:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
xmlns:sap="http://www.sap.com/Protocols/SAPData"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The sections below describe the annotations (annotation attributes), which are supported by the XSOData XS2. Only the
|
|
41
|
+
values, which are mentioned in the sections below, are supported for the annotations. Mostly only subset of all the
|
|
42
|
+
possible annotation values is supported. Each section describes the annotations, which are supported for a particular
|
|
43
|
+
EDM element. For each of the annotations a default value is defined according to https://scn.sap.com/docs/DOC-44986.
|
|
44
|
+
An annotation is added to the $metadata document only if its value differs from the default one.
|
|
45
|
+
|
|
46
|
+
## Entity Set Annotations
|
|
47
|
+
|
|
48
|
+
### sap:addressable
|
|
49
|
+
|
|
50
|
+
**Description**
|
|
51
|
+
|
|
52
|
+
Indicates, whether direct access to the entity set is supported.
|
|
53
|
+
|
|
54
|
+
**Default value**
|
|
55
|
+
|
|
56
|
+
"true"
|
|
57
|
+
|
|
58
|
+
**Supported values (other than the default value)**
|
|
59
|
+
|
|
60
|
+
"false": if the entity set represents either a calculation view or input parameters for a calculation view
|
|
61
|
+
|
|
62
|
+
### sap:creatable
|
|
63
|
+
|
|
64
|
+
**Description**
|
|
65
|
+
|
|
66
|
+
Indicates, whether new entities can be created in this entity set
|
|
67
|
+
|
|
68
|
+
**Default value**
|
|
69
|
+
|
|
70
|
+
"true"
|
|
71
|
+
|
|
72
|
+
**Supported values (other than the default value)**
|
|
73
|
+
|
|
74
|
+
"false" in one of the following cases:
|
|
75
|
+
* "create forbidden" setting is defined for the entity set in .xsodata file
|
|
76
|
+
* entity set represents a database view (e.g. table or calculation view)
|
|
77
|
+
* entity set represents input parameters for a calculation view
|
|
78
|
+
* aggregation is defined for the entity set using "aggregates" expression in .xsodata file
|
|
79
|
+
|
|
80
|
+
### sap:updatable
|
|
81
|
+
|
|
82
|
+
**Description**
|
|
83
|
+
|
|
84
|
+
Indicates, whether entities in this entity set can be updated
|
|
85
|
+
|
|
86
|
+
**Default value**
|
|
87
|
+
|
|
88
|
+
"true"
|
|
89
|
+
|
|
90
|
+
**Supported values (other than the default value)**
|
|
91
|
+
|
|
92
|
+
"false" in one of the following cases:
|
|
93
|
+
* "update forbidden" setting is defined for the entity set in .xsodata file
|
|
94
|
+
* entity set represents a database view (e.g. table or calculation view)
|
|
95
|
+
* entity set represents input parameters for a calculation view
|
|
96
|
+
* aggregation is defined for the entity set using "aggregates" expression in .xsodata file
|
|
97
|
+
* generated key is defined for the entity set
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### sap:deletable
|
|
101
|
+
|
|
102
|
+
**Description**
|
|
103
|
+
|
|
104
|
+
Indicates, whether entities can be deleted from this entity set
|
|
105
|
+
|
|
106
|
+
**Default value**
|
|
107
|
+
|
|
108
|
+
"true"
|
|
109
|
+
|
|
110
|
+
**Supported values (other than the default value)**
|
|
111
|
+
|
|
112
|
+
"false" in one of the following cases:
|
|
113
|
+
* "delete forbidden" setting is defined for the entity set in .xsodata file
|
|
114
|
+
* entity set represents a database view (e.g. table or calculation view)
|
|
115
|
+
* entity set represents input parameters for a calculation view
|
|
116
|
+
* aggregation is defined for the entity set using "aggregates" expression in .xsodata file
|
|
117
|
+
* generated key is defined for the entity set
|
|
118
|
+
|
|
119
|
+
## Entity Type Annotations
|
|
120
|
+
|
|
121
|
+
### sap:semantics
|
|
122
|
+
|
|
123
|
+
**Description**
|
|
124
|
+
|
|
125
|
+
Semantic of the entity type
|
|
126
|
+
|
|
127
|
+
**Default value**
|
|
128
|
+
|
|
129
|
+
undefined
|
|
130
|
+
|
|
131
|
+
**Supported values (other than the default value)**
|
|
132
|
+
|
|
133
|
+
"aggregate" value in one of the following cases:
|
|
134
|
+
* aggregation is defined for the entity set of the entity type using "aggregates" expression in .xsodata file
|
|
135
|
+
* entity type represents a calculation view, which has a measure attribute
|
|
136
|
+
|
|
137
|
+
"parameters" value if the entity type represents input parameters for a calculation view
|
|
138
|
+
|
|
139
|
+
## Annotations for entity type properties
|
|
140
|
+
|
|
141
|
+
### sap:semantics
|
|
142
|
+
|
|
143
|
+
**Description**
|
|
144
|
+
|
|
145
|
+
Semantic of the property
|
|
146
|
+
|
|
147
|
+
**Default value**
|
|
148
|
+
|
|
149
|
+
undefined
|
|
150
|
+
|
|
151
|
+
**Supported values (other than the default value)**
|
|
152
|
+
|
|
153
|
+
The annotation is added only for the properties representing calculated attributes or input parameters of a
|
|
154
|
+
calculation view. The annotation value corresponds to the semantic type of a calculated attribute or an input
|
|
155
|
+
parameter.
|
|
156
|
+
|
|
157
|
+
Semantic type of an input parameter is specified as a value of "type" attribute of "valueDomain" element, defined in
|
|
158
|
+
.hdbcalculationview file. For example:
|
|
159
|
+
|
|
160
|
+
```xml
|
|
161
|
+
<variable id="parameterID" parameter="true">
|
|
162
|
+
<variableProperties datatype="VARCHAR" mandatory="true">
|
|
163
|
+
<valueDomain type="Currency"/>
|
|
164
|
+
...
|
|
165
|
+
</variableProperties>
|
|
166
|
+
</variable>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Semantic type of a calculated attribute is specified as a value of "semanticType" attribute of "calculatedAttribute"
|
|
170
|
+
element, defined in .hdbcalculationview file. For example:
|
|
171
|
+
|
|
172
|
+
```xml
|
|
173
|
+
<calculatedAttribute id="attributeID" semanticType="currencyCode">
|
|
174
|
+
...
|
|
175
|
+
</calculatedAttribute>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The following table shows the mapping from the semantic type values of calculated attributes and input parameters to the
|
|
179
|
+
values of sap:semantics annotation:
|
|
180
|
+
|
|
181
|
+
| Calculated attribute semantic type | Input parameter semantic type | sap:semantics value |
|
|
182
|
+
|------------------------------------|-------------------------------|---------------------|
|
|
183
|
+
| currencyCode | Currency | currency-code |
|
|
184
|
+
| unitOfMeasure | UnitOfMeasure | unit-of-measure |
|
|
185
|
+
| date.businessDateFrom | - | dtstart |
|
|
186
|
+
| date.businessDateTo | - | dtend |
|
|
187
|
+
|
|
188
|
+
Only the values from the table are supported.
|
|
189
|
+
|
|
190
|
+
### sap:parameter
|
|
191
|
+
|
|
192
|
+
**Description**
|
|
193
|
+
|
|
194
|
+
A property is annotated with this annotation, if it represents a parameter.
|
|
195
|
+
|
|
196
|
+
**Default value**
|
|
197
|
+
|
|
198
|
+
undefined
|
|
199
|
+
|
|
200
|
+
**Supported values (other than the default value)**
|
|
201
|
+
|
|
202
|
+
The annotation is added only to the properties representing input parameters of a calculation view. The annotation value
|
|
203
|
+
corresponds to the value of "mandatory" attribute in the input parameter definition, defined in .hdbcalculationview file.
|
|
204
|
+
|
|
205
|
+
```xml
|
|
206
|
+
<variable id="inputParameterId" parameter="true">
|
|
207
|
+
<variableProperties datatype="INTEGER" mandatory="true">
|
|
208
|
+
</variable>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Mapping of "mandatory" attribute values to the values of sap:parameter annotation:
|
|
212
|
+
|
|
213
|
+
"mandatory" attribute value | sap:parameter value
|
|
214
|
+
--------------------------- | -------------------
|
|
215
|
+
true | mandatory
|
|
216
|
+
false | optional
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
### sap:label
|
|
220
|
+
|
|
221
|
+
**Description**
|
|
222
|
+
|
|
223
|
+
A short, human-readable text suitable for labels and captions in UIs
|
|
224
|
+
|
|
225
|
+
**Default value**
|
|
226
|
+
|
|
227
|
+
undefined
|
|
228
|
+
|
|
229
|
+
**Supported values (other than the default value)**
|
|
230
|
+
|
|
231
|
+
The annotation is added only for the properties representing calculated attributes or input parameters of a
|
|
232
|
+
calculation view. The annotation value corresponds to the "defaultDescription" attribute in the definition of an input
|
|
233
|
+
parameter or a calculated attribute in .hdbcalculationview file.
|
|
234
|
+
|
|
235
|
+
```xml
|
|
236
|
+
<variable id="inputParameterId" parameter="true">
|
|
237
|
+
<descriptions defaultDescription="Input parameter label"/>
|
|
238
|
+
</variable>
|
|
239
|
+
|
|
240
|
+
<calculatedAttribute id="calcAttributeId">
|
|
241
|
+
<descriptions defaultDescription="Calculated attribute label"/>
|
|
242
|
+
</calculatedAttribute>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### sap:filterable
|
|
246
|
+
|
|
247
|
+
**Description**
|
|
248
|
+
|
|
249
|
+
Indicates, whether the property can be used in $filter system query option.
|
|
250
|
+
|
|
251
|
+
**Default value**
|
|
252
|
+
|
|
253
|
+
"true"
|
|
254
|
+
|
|
255
|
+
**Supported values (other than the default value)**
|
|
256
|
+
|
|
257
|
+
The annotation is added with the "false" value if the property satisfies one of the following conditions:
|
|
258
|
+
* The property represents a generated key
|
|
259
|
+
* The property represents a measure attribute of a calculation view
|
|
260
|
+
* The property is used in the aggregation, defined as the "aggregates" expression in .xsodata file
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
### sap:display-format
|
|
264
|
+
|
|
265
|
+
**Description**
|
|
266
|
+
|
|
267
|
+
Format, which can be used to display the property
|
|
268
|
+
|
|
269
|
+
**Default value**
|
|
270
|
+
|
|
271
|
+
undefined
|
|
272
|
+
|
|
273
|
+
**Supported values (other than the default value)**
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
"Date" value, if SQL DATE type is used for the property on the database side.
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
### sap:aggregation-role
|
|
280
|
+
|
|
281
|
+
**Description**
|
|
282
|
+
|
|
283
|
+
Aggregation role of the property
|
|
284
|
+
|
|
285
|
+
**Default value**
|
|
286
|
+
|
|
287
|
+
undefined
|
|
288
|
+
|
|
289
|
+
**Supported values (other than the default value)**
|
|
290
|
+
|
|
291
|
+
"measure" value, if the property represents a measure attribute of a calculation view or is used in the aggregation,
|
|
292
|
+
defined as the "aggregates" expression in .xsodata file
|
|
293
|
+
|
|
294
|
+
### sap:unit
|
|
295
|
+
|
|
296
|
+
**Description**
|
|
297
|
+
|
|
298
|
+
Name of a property in the context of the entity type containing the currency code or unit of measure for a numeric value of the current property.
|
|
299
|
+
|
|
300
|
+
**Default value**
|
|
301
|
+
|
|
302
|
+
undefined
|
|
303
|
+
|
|
304
|
+
**Supported values (other than the default value)**
|
|
305
|
+
|
|
306
|
+
The annotation is added only for the properties representing calculated attributes of a calculation view. The annotation
|
|
307
|
+
value corresponds to the value of "attributeName" attribute of "unitCurrencyAttribute" element of the calculated attribute
|
|
308
|
+
definition in .hdbcalculationview file.
|
|
309
|
+
|
|
310
|
+
```xml
|
|
311
|
+
<calculatedAttribute id="attributeId">
|
|
312
|
+
<unitCurrencyAttribute attributeName="currencyCodeAttribute"/>
|
|
313
|
+
</calculatedAttribute>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
For the aforementioned example the annotation value will be "currencyCodeAttribute".
|
|
317
|
+
|
|
318
|
+
### sap:filter-restriction
|
|
319
|
+
|
|
320
|
+
**Description**
|
|
321
|
+
|
|
322
|
+
Describes filter restriction for the property, if the one exists.
|
|
323
|
+
|
|
324
|
+
**Default value**
|
|
325
|
+
|
|
326
|
+
undefined
|
|
327
|
+
|
|
328
|
+
**Supported values (other than the default value)**
|
|
329
|
+
|
|
330
|
+
The annotation is added only for the properties representing input parameters of a calculation view. The annotation
|
|
331
|
+
value corresponds to the values of "multiLine" and "type" attributes of "selection" element of the input parameter
|
|
332
|
+
definition in .hdbcalculationview file.
|
|
333
|
+
|
|
334
|
+
```xml
|
|
335
|
+
<variable id="parameterId" parameter="true">
|
|
336
|
+
<variableProperties datatype="INTEGER">
|
|
337
|
+
<selection multiLine="false" type="SingleValue"/>
|
|
338
|
+
</variableProperties>
|
|
339
|
+
</variable>
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
The table below shows the mapping from "multiLine" and "type" attribute values to the value of sap:filter-restriction
|
|
343
|
+
annotation.
|
|
344
|
+
|
|
345
|
+
multiLine | type | sap:filter-restriction
|
|
346
|
+
--------- | ----------- | ----------------------
|
|
347
|
+
false | SingleValue | single-value
|
|
348
|
+
true | SingleValue | multi-value
|
|
349
|
+
false | Interval | interval
|
|
350
|
+
|
|
351
|
+
Only the values from the table are supported.
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
## Navigation Property Annotations
|
|
355
|
+
|
|
356
|
+
### sap:creatable
|
|
357
|
+
|
|
358
|
+
**Description**
|
|
359
|
+
|
|
360
|
+
Indicates, whether new related entities can be created.
|
|
361
|
+
|
|
362
|
+
**Default value**
|
|
363
|
+
|
|
364
|
+
"true"
|
|
365
|
+
|
|
366
|
+
**Supported values (other than the default value)**
|
|
367
|
+
|
|
368
|
+
The annotation value is always "false" because neither "deep insert" (i.e. POST request payload having data for the both,
|
|
369
|
+
parent and related entity) nor POST request for .../EntitySet(key)/navPropertyName URL is supported in XSOData XS2.
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
### sap:filterable
|
|
373
|
+
|
|
374
|
+
**Description**
|
|
375
|
+
|
|
376
|
+
Indicates, whether navigation property can be used in $filter system query option.
|
|
377
|
+
|
|
378
|
+
**Default value**
|
|
379
|
+
|
|
380
|
+
"true"
|
|
381
|
+
|
|
382
|
+
**Supported values (other than the default value)**
|
|
383
|
+
|
|
384
|
+
The annotation value is always "false" because navigation properties cannot be used in $filter system query option in
|
|
385
|
+
XSOData XS2.
|
|
386
|
+
|
|
387
|
+
## Association Set Annotations
|
|
388
|
+
|
|
389
|
+
### sap:creatable / sap:updatable / sap:deletable
|
|
390
|
+
|
|
391
|
+
**Description**
|
|
392
|
+
|
|
393
|
+
Indicates, whether relations, represented by the association set, can be created / updated / deleted.
|
|
394
|
+
|
|
395
|
+
**Default value**
|
|
396
|
+
|
|
397
|
+
"true"
|
|
398
|
+
|
|
399
|
+
**Supported values (other than the default value)**
|
|
400
|
+
|
|
401
|
+
"false": if the association set connects entity sets for calculation view results and calculation view input parameters.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Authorization scopes in XSOData Service Definition
|
|
2
|
+
### Overview
|
|
3
|
+
As XSA provides the possibility to define coarse-grained authorization checks via scopes that are defined in the security configuration file (xs-security.json), the OData service provider is also enabled to use the defined authorization scopes in the XSOData service definition, in order to control access on different levels:
|
|
4
|
+
|
|
5
|
+
* Service-level
|
|
6
|
+
* EntitySet-level
|
|
7
|
+
* (CRUD) Operation-level
|
|
8
|
+
|
|
9
|
+
### Definition Rules
|
|
10
|
+
For the definition of scopes in the XSOData service definition, the following rules must be taken into account:
|
|
11
|
+
|
|
12
|
+
1. It is possible to **not** define any scopes in the xsodata service definition file. Then no
|
|
13
|
+
authorization process will be invoked, and all requests are allowed.
|
|
14
|
+
2. Once scopes are defined, scopes on Service-level for all CRUD operations **MUST** be provided
|
|
15
|
+
a. Any missing operation-scope will lead to an xsodata-parse-error
|
|
16
|
+
b. To restrict any of the operations, a scope with an “unused-value” is given
|
|
17
|
+
3. On EntitySet-level, scopes are inherited from the Service-level
|
|
18
|
+
4. On EntitySet-level, further scopes for any subset of CRUD operations could be given
|
|
19
|
+
a. Then, for the corresponding entitySet, both scopes (from Service, and the extra from entitySet) must be validated. See below examples# 2, 3, 5.
|
|
20
|
+
5. scopes for a given operation request are checked independently from scopes of other operations.
|
|
21
|
+
6. On Service- and EntitySet-level, **ONLY ONE** scope can be set per operation
|
|
22
|
+
7. Even with defined scopes, the following requests are excluded from the authorization, and processed as allowed:
|
|
23
|
+
a. $metadata
|
|
24
|
+
b. Service document
|
|
25
|
+
|
|
26
|
+
### Syntax- An Example XSOData service definition
|
|
27
|
+
```
|
|
28
|
+
service {
|
|
29
|
+
scopes (
|
|
30
|
+
create ( "unused-scope" ),
|
|
31
|
+
read ( "scope_R0" ),
|
|
32
|
+
update ( "unused-scope" ),
|
|
33
|
+
delete ( "scope_D0" )
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
entitySet E1 (
|
|
37
|
+
navigates (
|
|
38
|
+
...
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
entitySet E2 (
|
|
43
|
+
navigates (
|
|
44
|
+
...
|
|
45
|
+
)
|
|
46
|
+
scopes (
|
|
47
|
+
read ( "scope_R2" ),
|
|
48
|
+
delete ("scope_D2" )
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
entitySet E3 (
|
|
53
|
+
scopes (
|
|
54
|
+
read ( "scope_R3" )
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### The special case of $links:
|
|
62
|
+
For $links requests like `service.xsodata/entitySet1(key)/$links/navProp`, there are 2 entity sets, one of them (named ‘target’) is to update its foreign key with the key that is read from the other entity set (named ‘source’).
|
|
63
|
+
Therefore, the target must have scopes for the corresponding operation (Create, Update, Delete), and the source must have read scopes. These scopes are inherited from service-level, and (as before) can be extended at the entitySet-level.
|
|
64
|
+
|
|
65
|
+
### Debug View
|
|
66
|
+
The debug view is callable, if the request has the parameter `sap-ds-debug = json | html`. The debug view is protected by default (as long as the authorization process in invoked by given scopes), unless a certain corresponding scope is defined on the service-level and this scope passes the secrity check.
|
|
67
|
+
The debug scope looks similar to the scopes of other operations, except that it is optionally defined:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
service {
|
|
71
|
+
scopes (
|
|
72
|
+
...
|
|
73
|
+
debug ( "scope_name" )
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
...
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Example Requests:
|
|
82
|
+
|
|
83
|
+
| Nr. | Request | Expected scopes from user |
|
|
84
|
+
|-----|-------------------------|-----------------------------------|
|
|
85
|
+
| 1 | Read on E1 | R0 |
|
|
86
|
+
| 2 | Read on E2 | R0, R2 |
|
|
87
|
+
| 3 | Read on E3 | R0, R3 |
|
|
88
|
+
| 4 | Delete on E1 | D0 |
|
|
89
|
+
| 5 | Delete on E2 | D0, D2 |
|
|
90
|
+
| 6 | Delete on E3 | D0 |
|
|
91
|
+
| 7 | Create on any entitySet | Request denied on Service-level |
|
|
92
|
+
| 8 | Update on any entitySet | Request denied on Service-level |
|
|
93
|
+
| 9 | Read on E1/$links/E3 | R0, R3 |
|
|
94
|
+
| 10 | Delete on E2/$links/E3 | D2, R0, R3 |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Sample for calculation views
|
|
2
|
+
============================
|
|
3
|
+
|
|
4
|
+
### Exposition of calculation view PlannedvsActualCalcView in an xsodata file:
|
|
5
|
+
|
|
6
|
+
```xsodata
|
|
7
|
+
service {
|
|
8
|
+
"package::PLANNED_ACTUAL_SALES " as "PlannedvsActualCalcView"
|
|
9
|
+
keys generate local "ID"
|
|
10
|
+
aggregates always
|
|
11
|
+
parameters via entity "InputParams";
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Sample URL
|
|
16
|
+
|
|
17
|
+
http://server:port/copaxs/odata/PlannedvsActualCalcView.xsodata/InputParams(ip_discount=’.20’,ip_region=’NW’)/Results?$select=salesorg,material,anetrevn&$filter=startswith(material,'DPC')&$format=json
|