@sap/cds 5.8.0 → 5.8.3
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 +61 -4
- package/app/fiori/routes.js +3 -0
- package/bin/cds.js +7 -3
- package/bin/serve.js +2 -2
- package/lib/deploy.js +1 -1
- package/lib/log/format/kibana.js +3 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +1 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +13 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ResourcePathParser.js +23 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriHelper.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js +5 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ContextURLFactory.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ErrorJsonSerializer.js +2 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/UriHelper.js +4 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +40 -5
- package/libx/_runtime/common/composition/index.js +1 -2
- package/libx/_runtime/common/composition/insert.js +3 -16
- package/libx/_runtime/common/composition/tree.js +1 -1
- package/libx/_runtime/common/error/frontend.js +2 -3
- package/libx/_runtime/common/i18n/index.js +2 -31
- package/libx/_runtime/common/utils/csn.js +15 -3
- package/libx/_runtime/common/utils/foreignKeyPropagations.js +9 -6
- package/libx/_runtime/common/utils/generateOnCond.js +5 -5
- package/libx/_runtime/common/utils/structured.js +10 -4
- package/libx/_runtime/db/expand/expandCQNToJoin.js +59 -20
- package/libx/_runtime/db/query/insert.js +1 -2
- package/libx/_runtime/db/sql-builder/SelectBuilder.js +7 -3
- package/libx/_runtime/db/utils/deep.js +10 -6
- package/libx/_runtime/fiori/generic/read.js +1 -3
- package/libx/_runtime/fiori/utils/handler.js +1 -11
- package/libx/_runtime/hana/conversion.js +2 -1
- package/libx/_runtime/hana/customBuilder/CustomSelectBuilder.js +1 -1
- package/libx/_runtime/hana/dynatrace.js +11 -5
- package/libx/_runtime/hana/execute.js +105 -8
- package/libx/_runtime/hana/search2cqn4sql.js +1 -4
- package/libx/_runtime/remote/utils/client.js +13 -4
- package/libx/_runtime/remote/utils/data.js +2 -1
- package/libx/gql/resolvers/crud/create.js +6 -1
- package/libx/gql/resolvers/crud/delete.js +6 -1
- package/libx/gql/resolvers/crud/read.js +6 -1
- package/libx/gql/resolvers/crud/update.js +11 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,65 @@
|
|
|
4
4
|
- The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
5
5
|
- This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## Version 5.8.3 - 2022-03-01
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `queries` property for application defined destinations of remote services
|
|
12
|
+
- `cds serve --watch` no longer fails if `@sap/cds-dk` is installed only globally
|
|
13
|
+
- `cds serve` during development longer redirects URLs with similar path segments from different services, like `/service/one` and `/service`
|
|
14
|
+
- `cds deploy --to sqlite` now ignores a `_texts.csv` file again if there is a language-specific file like `_texts_en.csv` present
|
|
15
|
+
- Using logical blocks (surrounded with `(` and `)`) in ON-conditions of unmanaged associations and compositions
|
|
16
|
+
- Skip "with parameters" clause if no order by clause or all columns in the order by clause are not strings when using parametrized views on hana
|
|
17
|
+
- Limited support for binary data in OData
|
|
18
|
+
+ Using of `base64` string values in `WHERE IN` on hana
|
|
19
|
+
+ `base64url` values in `@odata.context` annotation
|
|
20
|
+
- `cds.context` is set in GraphQL adapter
|
|
21
|
+
- Using payloads with `@odata.type` annotating primitive properties no longer crashes the application. `#` in type value may be ommitted. Example:
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"ID": 201,
|
|
25
|
+
"title@odata.type": "#String",
|
|
26
|
+
"title": "Wuthering Heights",
|
|
27
|
+
"stock@odata.type": "Int32",
|
|
28
|
+
"stock": 12
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
- Unicode support for i18n bundles
|
|
32
|
+
|
|
33
|
+
## Version 5.8.2 - 2022-02-22
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Crash if error does not have a stack in kibana logging
|
|
38
|
+
- Allow short names for bound operations in odata-server
|
|
39
|
+
- Performance issue during deep operations
|
|
40
|
+
- Resolving views with parameters
|
|
41
|
+
- Expanding association-to-many within draft union scenario
|
|
42
|
+
- Erroneous invalidation of deep `INSERT|UPDATE|DELETE` operations if root entity has managed to-one association to non-writable view
|
|
43
|
+
- Handling of falsy results when sending requests to remote services
|
|
44
|
+
- Resolving foreign key propagations for views with union
|
|
45
|
+
|
|
46
|
+
## Version 5.8.1 - 2022-02-11
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- Use single transaction for update mutations in GraphQL adapter
|
|
51
|
+
- ODATA to CQN parser returned not selected keys in `@odata.context`
|
|
52
|
+
- Draft: `$expand` with special draft columns in `$orderBy` for active entities
|
|
53
|
+
- Reading distinct values of draft enabled entity
|
|
54
|
+
- Handling of LOB data on HANA
|
|
55
|
+
- Fix streaming draft by navigation
|
|
56
|
+
- Empty to-many arrays are not removed from req.data for inserts
|
|
57
|
+
- `$filter` query option in structured mode (OData flavors `w4` and `x4`)
|
|
58
|
+
+ Using JSON-stringified objects no longer occasionally crashes an application
|
|
59
|
+
+ Filtering on a structured element with `ne null` condition also selects data having some `null` properties within
|
|
60
|
+
|
|
7
61
|
## Version 5.8.0 - 2022-01-27
|
|
8
62
|
|
|
9
63
|
### Added
|
|
10
64
|
|
|
11
|
-
- Custom `server.js` don't have to export `cds.server` anymore -> we use that by default now.
|
|
65
|
+
- Custom `server.js` don't have to export `cds.server` anymore -> we use that by default now.
|
|
12
66
|
- In `cds.requires`: Support to replace primitive values with objects
|
|
13
67
|
- Support filter functions on renamed properties from external service
|
|
14
68
|
- Results of database queries use `big.js` for values of type `cds.Decimal` and `cds.Integer64` if enabled via `cds.env.features.bigjs`
|
|
@@ -21,9 +75,6 @@
|
|
|
21
75
|
- Restrict access to all services via `cds.env.requires.auth.restrict_all_services = true`
|
|
22
76
|
+ That is, all unrestricted services (i.e., w/o own `@requires`) are treated as having `@requires: 'authenticated-user'`
|
|
23
77
|
- Threshold for automatically sending GET requests as `$batch` (beta, cf. @sap/cds@5.6.0) can be configured per remote service via `cds.env.requires.<srv>.max_get_url_length` (if not configured on service, the global config applies)
|
|
24
|
-
- Alpha out-of-the-box support for DwC
|
|
25
|
-
+ Authentication based on headers set by Jupiter router via `cds.env.requires.auth.kind = 'dwc-auth'`
|
|
26
|
-
+ All DwC headers are forwarded to remote service via `cds.env.requires.<srv>.forward_dwc_headers = true`
|
|
27
78
|
- Limited support for binary data in OData
|
|
28
79
|
+ In payloads, the binary data must be a base64 encoded string
|
|
29
80
|
+ In URLs, the binary data must have the following format: `binary'<url-safe base64 encoded>'`, e.g., `$filter=ID eq binary'Q0FQIE5vZGUuanM='`
|
|
@@ -76,6 +127,12 @@
|
|
|
76
127
|
+ Request data properties of types `cds.Date`, `cds.DateTime` and `cds.Timestamp` are converted accordingly to OData V2 specification
|
|
77
128
|
+ Response data properties of types `cds.Decimal`, `cds.DecimalFloat` (deprecated) and `cds.Integer64` are handled properly when using `Accept` header with `IEEE754Compatible=true/false` and `ExponentialDecimals=true/false` format parameters
|
|
78
129
|
|
|
130
|
+
## Version 5.7.6 - 2022-02-23
|
|
131
|
+
|
|
132
|
+
### Fixed
|
|
133
|
+
|
|
134
|
+
- `draftActivate` action does not return children if not requested
|
|
135
|
+
|
|
79
136
|
## Version 5.7.5 - 2022-01-14
|
|
80
137
|
|
|
81
138
|
### Fixed
|
package/app/fiori/routes.js
CHANGED
|
@@ -15,6 +15,9 @@ cds.on ('bootstrap', app => {
|
|
|
15
15
|
app.use('*/'+uri, ({originalUrl}, res, next)=> { // */browse/webapp[/prefix]/browse/
|
|
16
16
|
// any of our special URLs ($fiori-, $api-docs) ? -> next
|
|
17
17
|
if (originalUrl.startsWith('/$')) return next()
|
|
18
|
+
// is there a service starting with the URL? -> next
|
|
19
|
+
if (cds.service.providers.find (srv => originalUrl.startsWith(srv.path))) return next()
|
|
20
|
+
|
|
18
21
|
// is there a service for '[prefix]/browse' ?
|
|
19
22
|
const srv = serviceForUri[uri] || (serviceForUri[uri] =
|
|
20
23
|
cds.service.providers.find (srv => ('/'+uri).lastIndexOf(srv.path) >=0))
|
package/bin/cds.js
CHANGED
|
@@ -15,13 +15,17 @@ const cli = { //NOSONAR
|
|
|
15
15
|
if (!argv.length) argv = process.argv.slice(3)
|
|
16
16
|
if (cmd in this.Shortcuts) cmd = process.argv[2] = this.Shortcuts[cmd]
|
|
17
17
|
if (process.env.NODE_ENV !== 'test') this.errorHandlers()
|
|
18
|
-
const task =
|
|
19
|
-
|| _require ('@sap/cds-dk/bin/'+cmd) // if dk is in installed modules
|
|
20
|
-
|| _require (_npmGlobalModules()+'/@sap/cds-dk/bin/'+cmd) // needed for running cds in npm scripts
|
|
18
|
+
const task = this.load(cmd)
|
|
21
19
|
if (!task) return _requires_cdsdk (cmd)
|
|
22
20
|
return task.apply (this, this.args(task,argv))
|
|
23
21
|
},
|
|
24
22
|
|
|
23
|
+
load (cmd) {
|
|
24
|
+
return _require ('./'+cmd)
|
|
25
|
+
|| _require ('@sap/cds-dk/bin/'+cmd) // if dk is in installed modules
|
|
26
|
+
|| _require (_npmGlobalModules()+'/@sap/cds-dk/bin/'+cmd) // needed for running cds in npm scripts
|
|
27
|
+
},
|
|
28
|
+
|
|
25
29
|
args (task, argv) {
|
|
26
30
|
|
|
27
31
|
const { options:o=[], flags:f=[], shortcuts:s=[] } = task
|
package/bin/serve.js
CHANGED
|
@@ -143,7 +143,7 @@ async function serve (all=[], o={}) { // NOSONAR
|
|
|
143
143
|
|
|
144
144
|
// IMPORTANT: never load any @sap/cds modules before the chdir above happened!
|
|
145
145
|
// handle --watch and --project
|
|
146
|
-
if (o.watch) return _watch
|
|
146
|
+
if (o.watch) return _watch.call(this, o.project,o) // cds serve --watch <project>
|
|
147
147
|
if (o.project) _chdir_to (o.project) // cds run --project <project>
|
|
148
148
|
if (!o.silent) _prepare_logging ()
|
|
149
149
|
|
|
@@ -240,7 +240,7 @@ function _prepare_logging () { // NOSONAR
|
|
|
240
240
|
/** handles --watch option */
|
|
241
241
|
function _watch (project,o) {
|
|
242
242
|
o.args = process.argv.slice(2) .filter (a => a !== '--watch' && a !== '-w')
|
|
243
|
-
return
|
|
243
|
+
return this.load('watch')([project],o)
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
|
package/lib/deploy.js
CHANGED
|
@@ -152,7 +152,7 @@ function init_from_json (db, csn, SILENT) {
|
|
|
152
152
|
*/
|
|
153
153
|
function prefer_translated_texts (file, all) {
|
|
154
154
|
if (/[._]texts\.(json|csv)$/.test (file)) {
|
|
155
|
-
const pattern = new RegExp('^'+ path.
|
|
155
|
+
const pattern = new RegExp('^'+ path.parse(file).name +'_')
|
|
156
156
|
const translated = all.filter (f => pattern.test(f))
|
|
157
157
|
if (translated.length > 0) {
|
|
158
158
|
DEBUG && DEBUG (`ignoring '${file}' in favor of [${translated}]`) // eslint-disable-line
|
package/lib/log/format/kibana.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const cds = require
|
|
1
|
+
const cds = require('../../')
|
|
2
2
|
const util = require('util')
|
|
3
3
|
|
|
4
4
|
const _l2l = { 1: 'error', 2: 'warn', 3: 'info', 4: 'debug', 5: 'trace' }
|
|
@@ -8,7 +8,7 @@ const _l2l = { 1: 'error', 2: 'warn', 3: 'info', 4: 'debug', 5: 'trace' }
|
|
|
8
8
|
*/
|
|
9
9
|
module.exports = (module, level, ...args) => {
|
|
10
10
|
// config
|
|
11
|
-
const { user: log_user
|
|
11
|
+
const { user: log_user, kibana_custom_fields } = cds.env.log
|
|
12
12
|
|
|
13
13
|
// build the object to log
|
|
14
14
|
const toLog = {
|
|
@@ -36,7 +36,7 @@ module.exports = (module, level, ...args) => {
|
|
|
36
36
|
if (args.length && typeof args[0] === 'object' && args[0].message) {
|
|
37
37
|
const err = args.shift()
|
|
38
38
|
toLog.msg = err.message
|
|
39
|
-
if (err
|
|
39
|
+
if (typeof err.stack === 'string') toLog.stacktrace = err.stack.split(/\s*\r?\n\s*/)
|
|
40
40
|
Object.assign(toLog, err, { level: toLog.level })
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -45,9 +45,7 @@ function _getTarget(service, segments) {
|
|
|
45
45
|
: last.getEdmType().csdlStructuredType.name
|
|
46
46
|
|
|
47
47
|
// autoexposed entities now used . in csn and _ in edm
|
|
48
|
-
const target =
|
|
49
|
-
findCsnTargetFor(name, service.model, namespace) ||
|
|
50
|
-
(name.endsWith('Parameters') && service.model.definitions[namespace + '.' + name.replace(/Parameters$/, '')])
|
|
48
|
+
const target = findCsnTargetFor(name, service.model, namespace)
|
|
51
49
|
|
|
52
50
|
if (target && target.kind === 'entity') {
|
|
53
51
|
return target
|
|
@@ -14,6 +14,12 @@ const { setStatusCodeAndHeader, getKeyProperty } = require('../../../../fiori/ut
|
|
|
14
14
|
const { toODataResult, postProcess } = require('../utils/result')
|
|
15
15
|
const { mergeJson } = require('../../../services/utils/compareJson')
|
|
16
16
|
|
|
17
|
+
const _isAssocOrCompNotLocalized = (reqTarget, el) => {
|
|
18
|
+
return (
|
|
19
|
+
reqTarget.elements[el].isAssociation && (!reqTarget.texts || reqTarget.elements[el].target !== reqTarget.texts.name)
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
const _postProcessDraftActivate = async (req, result, service) => {
|
|
18
24
|
// update req.data (keys needed in readAfterWrite)
|
|
19
25
|
req.data = result
|
|
@@ -25,6 +31,13 @@ const _postProcessDraftActivate = async (req, result, service) => {
|
|
|
25
31
|
result.HasActiveEntity = false
|
|
26
32
|
result.HasDraftEntity = false
|
|
27
33
|
|
|
34
|
+
// remove children from result, excluding localized composition 'text'
|
|
35
|
+
if (!cds.env.effective.odata.structs) {
|
|
36
|
+
for (const k in req.target.elements) {
|
|
37
|
+
if (_isAssocOrCompNotLocalized(req.target, k)) delete result[k]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
return result
|
|
29
42
|
}
|
|
30
43
|
|
package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ResourcePathParser.js
CHANGED
|
@@ -396,7 +396,18 @@ class ResourcePathParser {
|
|
|
396
396
|
throw new UriSyntaxError(UriSyntaxError.Message.PREVIOUS_TYPE_HAS_NO_MEDIA, currentType.getName())
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
let uriResources
|
|
400
|
+
try {
|
|
401
|
+
uriResources = this._parsePropertyPath(uriPathSegments, currentResource, tokenizer)
|
|
402
|
+
} catch (e) {
|
|
403
|
+
try {
|
|
404
|
+
uriResources = this._parseBoundOperation(uriPathSegments, currentResource, tokenizer)
|
|
405
|
+
} catch (e1) {
|
|
406
|
+
// throw first error
|
|
407
|
+
throw e
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
400
411
|
return result.concat(uriResources)
|
|
401
412
|
}
|
|
402
413
|
|
|
@@ -409,7 +420,17 @@ class ResourcePathParser {
|
|
|
409
420
|
* @private
|
|
410
421
|
*/
|
|
411
422
|
_parseBoundOperation (uriPathSegments, currentResource, tokenizer) {
|
|
412
|
-
|
|
423
|
+
// allow short names for bound operations
|
|
424
|
+
let name = tokenizer.getText()
|
|
425
|
+
if (typeof name === 'string' && !name.match(/\./)) {
|
|
426
|
+
const namespace = currentResource._entitySet &&
|
|
427
|
+
currentResource._entitySet._target &&
|
|
428
|
+
currentResource._entitySet._target.type &&
|
|
429
|
+
currentResource._entitySet._target.type.namespace
|
|
430
|
+
if (namespace) name = namespace + '.' + name
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const fqn = FullQualifiedName.createFromNameSpaceAndName(name)
|
|
413
434
|
const bindingParamTypeFqn = currentResource.getEdmType().getFullQualifiedName()
|
|
414
435
|
|
|
415
436
|
// parse bound action
|
|
@@ -50,7 +50,7 @@ class UriHelper {
|
|
|
50
50
|
if (value === null) return 'null'
|
|
51
51
|
if (edmType === EdmPrimitiveTypeKind.String) return "'" + value.replace(REGEXP_SINGLE_QUOTE, "''") + "'"
|
|
52
52
|
if (edmType === EdmPrimitiveTypeKind.Duration) return "duration'" + value + "'"
|
|
53
|
-
if (edmType === EdmPrimitiveTypeKind.Binary) return "binary'" + value + "'"
|
|
53
|
+
if (edmType === EdmPrimitiveTypeKind.Binary) return "binary'" + value.replace(/\//g, '_').replace(/\+/g, '-') + "'"
|
|
54
54
|
if (edmType.getKind() === EdmTypeKind.DEFINITION) {
|
|
55
55
|
return UriHelper.toUriLiteral(value, edmType.getUnderlyingType())
|
|
56
56
|
}
|
|
@@ -347,12 +347,9 @@ class ResourceJsonDeserializer {
|
|
|
347
347
|
}
|
|
348
348
|
const expectedTypeName =
|
|
349
349
|
expectedType.getKind() === EdmTypeKind.PRIMITIVE ? expectedType.getName() : expectedType.getFullQualifiedName()
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
value.endsWith(isCollection ? ')' : '')
|
|
354
|
-
? value.substring(isCollection ? 12 : 1, value.length - (isCollection ? 1 : 0))
|
|
355
|
-
: null
|
|
350
|
+
const typeNameRegex = isCollection ? /^#?Collection\((.*)\)$/ : /^#?(.*)$/
|
|
351
|
+
const matchedTypeName = typeof value === 'string' && value.match(typeNameRegex)
|
|
352
|
+
const typeName = matchedTypeName && matchedTypeName[1]
|
|
356
353
|
// The type name could be an alias-qualified name; for that case we have to do an EDM look-up.
|
|
357
354
|
const fullQualifiedName =
|
|
358
355
|
typeName && typeName.indexOf('.') > 0 && typeName.lastIndexOf('.') < typeName.length - 1
|
|
@@ -369,6 +366,8 @@ class ResourceJsonDeserializer {
|
|
|
369
366
|
throw new DeserializationError(
|
|
370
367
|
"The value of '" + name + "' must describe correctly the type '" + expectedType.getFullQualifiedName() + "'."
|
|
371
368
|
)
|
|
369
|
+
} else {
|
|
370
|
+
delete structureValue[name]
|
|
372
371
|
}
|
|
373
372
|
} else if (name.endsWith(JsonAnnotations.BIND) && !isDelta) {
|
|
374
373
|
const navigationPropertyName = name.substring(0, name.length - JsonAnnotations.BIND.length)
|
|
@@ -281,7 +281,7 @@ class ContextURLFactory {
|
|
|
281
281
|
// If there is one '*' selected, the context URL contains only '*'.
|
|
282
282
|
if (isAll) {
|
|
283
283
|
value = ['*']
|
|
284
|
-
} else if (type && type.getKind() === EdmTypeKind.ENTITY && isKeyRequired) {
|
|
284
|
+
} else if (type && type.getKind() === EdmTypeKind.ENTITY && isKeyRequired && !cds.env.features.odata_new_parser) {
|
|
285
285
|
for (const keyName of type.getKeyPropertyRefs().keys()) {
|
|
286
286
|
if (!value.includes(keyName)) value.push(keyName)
|
|
287
287
|
}
|
|
@@ -6,6 +6,7 @@ const AbstractError = commons.errors.AbstractError
|
|
|
6
6
|
const UriSyntaxError = commons.errors.UriSyntaxError
|
|
7
7
|
const IllegalArgumentError = commons.errors.IllegalArgumentError
|
|
8
8
|
const NotImplementedError = commons.errors.NotImplementedError
|
|
9
|
+
const EdmPrimitiveTypeKind = require('../../odata-commons/edm/EdmPrimitiveTypeKind')
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* UriHelper has utility methods for reading and constructing URIs.
|
|
@@ -103,7 +104,9 @@ class UriHelper {
|
|
|
103
104
|
for (const key of keys) {
|
|
104
105
|
url = url ? url + ',' : ''
|
|
105
106
|
if (keys.length > 1) url += encodeURIComponent(key.name) + '='
|
|
106
|
-
url +=
|
|
107
|
+
url += key.type === EdmPrimitiveTypeKind.Binary
|
|
108
|
+
? CommonsUriHelper.toUriLiteral(key.value, key.type)
|
|
109
|
+
: encodeURIComponent(CommonsUriHelper.toUriLiteral(key.value, key.type))
|
|
107
110
|
}
|
|
108
111
|
return '(' + url + ')'
|
|
109
112
|
}
|
|
@@ -5,6 +5,9 @@ const { SELECT } = cds.ql
|
|
|
5
5
|
|
|
6
6
|
const { targetFromPath, isPathToDraft } = require('../../../../common/utils/cqn')
|
|
7
7
|
const { deepCopyArray } = require('../../../../common/utils/copy')
|
|
8
|
+
const { cqn2cqn4sql } = require('../../../../common/utils/cqn2cqn4sql')
|
|
9
|
+
const { ensureDraftsSuffix } = require('../../../../fiori/utils/handler')
|
|
10
|
+
const { removeIsActiveEntityRecursively, isActiveEntityRequested } = require('../../../../fiori/utils/where')
|
|
8
11
|
|
|
9
12
|
const isStreaming = segments => {
|
|
10
13
|
const lastSegment = segments[segments.length - 1]
|
|
@@ -15,6 +18,34 @@ const isStreaming = segments => {
|
|
|
15
18
|
)
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
const _adaptSubSelectsDraft = select => {
|
|
22
|
+
if (select.SELECT.from.ref) {
|
|
23
|
+
const index = select.SELECT.from.ref.length - 1
|
|
24
|
+
select.SELECT.from.ref[index] = ensureDraftsSuffix(select.SELECT.from.ref[index])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (select.SELECT.where) {
|
|
28
|
+
for (let i = 0; i < select.SELECT.where.length; i++) {
|
|
29
|
+
const element = select.SELECT.where[i]
|
|
30
|
+
if (element.SELECT) {
|
|
31
|
+
_adaptSubSelectsDraft(element)
|
|
32
|
+
} else if (element.xpr) {
|
|
33
|
+
for (const ele of element.xpr.filter(e => e.SELECT)) {
|
|
34
|
+
_adaptSubSelectsDraft(ele)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const adaptStreamCQN = (cqn, isDraft = false) => {
|
|
42
|
+
if (isDraft || !isActiveEntityRequested(cqn.SELECT.where)) {
|
|
43
|
+
_adaptSubSelectsDraft(cqn)
|
|
44
|
+
} else {
|
|
45
|
+
cqn.SELECT.where = removeIsActiveEntityRecursively(cqn.SELECT.where)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
18
49
|
const getStreamProperties = (req, model) => {
|
|
19
50
|
const mediaTypeProperty = Object.values(req.target.elements).find(val => val['@Core.MediaType'])
|
|
20
51
|
|
|
@@ -56,14 +87,17 @@ const getStreamProperties = (req, model) => {
|
|
|
56
87
|
|
|
57
88
|
if (columns.length && cds.db && !req.target._hasPersistenceSkip) {
|
|
58
89
|
// used cloned path
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (req.target._isDraftEnabled && isPathToDraft(select.SELECT.from.ref, model))
|
|
62
|
-
select.SELECT.from.ref[0].id = select.SELECT.from.ref[0].id + '_drafts'
|
|
90
|
+
let select = SELECT.one.from({ ref: deepCopyArray(req.query.SELECT.from.ref) }).columns(columns)
|
|
63
91
|
|
|
64
92
|
// new parser has media property as last ref element -> remove
|
|
65
93
|
if (targetFromPath(select.SELECT.from.ref, model).kind === 'element') select.SELECT.from.ref.pop()
|
|
66
94
|
|
|
95
|
+
const pathToDraft = isPathToDraft(select.SELECT.from.ref, model)
|
|
96
|
+
if (req.target._isDraftEnabled && pathToDraft) {
|
|
97
|
+
select = cqn2cqn4sql(select, model)
|
|
98
|
+
adaptStreamCQN(select, pathToDraft)
|
|
99
|
+
}
|
|
100
|
+
|
|
67
101
|
return cds
|
|
68
102
|
.tx(req)
|
|
69
103
|
.run(select)
|
|
@@ -79,5 +113,6 @@ const getStreamProperties = (req, model) => {
|
|
|
79
113
|
|
|
80
114
|
module.exports = {
|
|
81
115
|
isStreaming,
|
|
82
|
-
getStreamProperties
|
|
116
|
+
getStreamProperties,
|
|
117
|
+
adaptStreamCQN
|
|
83
118
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { getCompositionTree, getCompositionRoot } = require('./tree')
|
|
2
|
-
const { hasDeepInsert, getDeepInsertCQNs
|
|
2
|
+
const { hasDeepInsert, getDeepInsertCQNs } = require('./insert')
|
|
3
3
|
const { hasDeepUpdate, getDeepUpdateCQNs } = require('./update')
|
|
4
4
|
const { hasDeepDelete, getDeepDeleteCQNs, getSetNullParentForeignKeyCQNs } = require('./delete')
|
|
5
5
|
const { selectDeepUpdateData } = require('./data')
|
|
@@ -11,7 +11,6 @@ module.exports = {
|
|
|
11
11
|
// insert
|
|
12
12
|
hasDeepInsert,
|
|
13
13
|
getDeepInsertCQNs,
|
|
14
|
-
cleanEmptyCompositionsOfMany,
|
|
15
14
|
// update
|
|
16
15
|
hasDeepUpdate,
|
|
17
16
|
getDeepUpdateCQNs,
|
|
@@ -10,9 +10,9 @@ const { deepCopyArray } = require('../utils/copy')
|
|
|
10
10
|
* own utils
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function _hasCompOrAssoc(entity, k) {
|
|
14
14
|
// TODO once REST also uses same logic as odata structured check if we can omit 'entity.elements[k] &&'
|
|
15
|
-
return entity.elements[k] && (entity.elements[k].is2one ||
|
|
15
|
+
return entity.elements[k] && (entity.elements[k].is2one || entity.elements[k].is2many)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const _addSubDeepInsertCQN = (model, compositionTree, data, cqns, draft) => {
|
|
@@ -60,25 +60,13 @@ const _entityFromINSERT = (model, INSERT) => {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const cleanEmptyCompositionsOfMany = (model, cqn) => {
|
|
64
|
-
const entity = _entityFromINSERT(model, cqn.INSERT)
|
|
65
|
-
if (!entity) return
|
|
66
|
-
for (const entry of cqn.INSERT.entries || []) {
|
|
67
|
-
for (const elName in entry || {}) {
|
|
68
|
-
const el = entity.elements[elName]
|
|
69
|
-
if (!el) continue
|
|
70
|
-
if (el.is2many && !entry[elName].length) delete entry[elName]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
63
|
const hasDeepInsert = (model, cqn) => {
|
|
76
64
|
if (cqn.INSERT.entries) {
|
|
77
65
|
const entity = _entityFromINSERT(model, cqn.INSERT)
|
|
78
66
|
if (entity) {
|
|
79
67
|
return !!cqn.INSERT.entries.find(entry => {
|
|
80
68
|
return !!Object.keys(entry || {}).find(k => {
|
|
81
|
-
return
|
|
69
|
+
return _hasCompOrAssoc(entity, k)
|
|
82
70
|
})
|
|
83
71
|
})
|
|
84
72
|
}
|
|
@@ -111,7 +99,6 @@ const getDeepInsertCQNs = (model, cqn) => {
|
|
|
111
99
|
}
|
|
112
100
|
|
|
113
101
|
module.exports = {
|
|
114
|
-
cleanEmptyCompositionsOfMany,
|
|
115
102
|
hasDeepInsert,
|
|
116
103
|
getDeepInsertCQNs
|
|
117
104
|
}
|
|
@@ -38,7 +38,7 @@ const _foreignKeysToLinks = (element, inverse) =>
|
|
|
38
38
|
const _resolvedElement = (element, service) => {
|
|
39
39
|
if (!element.target) return element
|
|
40
40
|
// skip forbidden view check if association to view with foreign key in target
|
|
41
|
-
const skipForbiddenViewCheck = element._isAssociationStrict &&
|
|
41
|
+
const skipForbiddenViewCheck = element._isAssociationStrict && !element['@odata.contained']
|
|
42
42
|
const { target, mapping } = getTransition(element._target, service, skipForbiddenViewCheck)
|
|
43
43
|
const newElement = { target: target.name, _target: target }
|
|
44
44
|
Object.setPrototypeOf(newElement, element)
|
|
@@ -30,9 +30,8 @@ const _getFiltered = err => {
|
|
|
30
30
|
Object.keys(err)
|
|
31
31
|
.concat(['message'])
|
|
32
32
|
.forEach(k => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
33
|
+
// REVISIT: do not remove innererror with cds^6
|
|
34
|
+
if (k === 'innererror' && process.env.NODE_ENV === 'production' && !err[SKIP_SANITIZATION]) return
|
|
36
35
|
if (ALLOWED_PROPERTIES.includes(k) || k.startsWith('@')) {
|
|
37
36
|
error[k] = err[k]
|
|
38
37
|
} else if (k === 'numericSeverity') {
|
|
@@ -2,7 +2,6 @@ const fs = require('fs')
|
|
|
2
2
|
const path = require('path')
|
|
3
3
|
|
|
4
4
|
const cds = require('../../cds')
|
|
5
|
-
const LOG = cds.log('app')
|
|
6
5
|
|
|
7
6
|
const dirs = (cds.env.i18n && cds.env.i18n.folders) || []
|
|
8
7
|
|
|
@@ -50,36 +49,8 @@ function init(locale, file) {
|
|
|
50
49
|
if (!file) file = findFile(locale)
|
|
51
50
|
if (!file) return
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
raw = fs.readFileSync(file, 'utf-8')
|
|
56
|
-
} catch (e) {
|
|
57
|
-
if (LOG._warn) {
|
|
58
|
-
e.message = `Unable to load file "${file}" for locale "${locale}" due to error: ` + e.message
|
|
59
|
-
LOG.warn(e)
|
|
60
|
-
}
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
const pairs = raw
|
|
66
|
-
.replace(/\r/g, '')
|
|
67
|
-
.split(/\n/)
|
|
68
|
-
.map(ele => ele.trim())
|
|
69
|
-
.filter(ele => ele && !ele.startsWith('#'))
|
|
70
|
-
.map(ele => {
|
|
71
|
-
const del = ele.indexOf('=')
|
|
72
|
-
return [ele.slice(0, del), ele.slice(del + 1)].map(ele => ele.trim())
|
|
73
|
-
})
|
|
74
|
-
for (const [key, value] of pairs) {
|
|
75
|
-
i18ns[locale][key] = value
|
|
76
|
-
}
|
|
77
|
-
} catch (e) {
|
|
78
|
-
if (LOG._warn) {
|
|
79
|
-
e.message = `Unable to process file "${file}" for locale "${locale}" due to error: ` + e.message
|
|
80
|
-
LOG.warn(e)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
52
|
+
const props = cds.load.properties(file)
|
|
53
|
+
i18ns[locale] = props
|
|
83
54
|
}
|
|
84
55
|
|
|
85
56
|
init('default', path.join(__dirname, 'messages.properties'))
|
|
@@ -50,7 +50,7 @@ const _getDataSubjectUp = (role, model, entity, prev, next, result) => {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const _getDataSubjectDown = (role, entity, prev, next) => {
|
|
53
|
-
const associations = Object.values(entity.associations).filter(e => !e._isBacklink)
|
|
53
|
+
const associations = Object.values(entity.associations || {}).filter(e => !e._isBacklink)
|
|
54
54
|
for (const element of associations) {
|
|
55
55
|
const me = { entity, relative: entity, element }
|
|
56
56
|
if (_ifDataSubject(element._target, role)) {
|
|
@@ -79,8 +79,20 @@ const getDataSubject = (entity, model, role) => {
|
|
|
79
79
|
return entity.set(hash, dataSubject)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const
|
|
83
|
-
model.entities(namespace)[name] || model.definitions[`${namespace}.${name}`]
|
|
82
|
+
const _findInModel = (name, model, namespace) => {
|
|
83
|
+
return model.entities(namespace)[name] || model.definitions[`${namespace}.${name}`]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const _resolve = (name, model, namespace) => {
|
|
87
|
+
const resolved = _findInModel(name, model, namespace)
|
|
88
|
+
// the edm name has an additional suffix 'Parameters' in case of views with parameters
|
|
89
|
+
if (!resolved && name.endsWith('Parameters')) {
|
|
90
|
+
const viewWithParam = _findInModel(name.replace(/Parameters$/, ''), model, namespace)
|
|
91
|
+
if (!viewWithParam || !viewWithParam.params) return
|
|
92
|
+
return viewWithParam
|
|
93
|
+
}
|
|
94
|
+
return resolved
|
|
95
|
+
}
|
|
84
96
|
|
|
85
97
|
const _findRootEntity = (model, edmName, namespace) => {
|
|
86
98
|
const parts = edmName.split('_')
|
|
@@ -178,6 +178,12 @@ const _resolveTargetForeignKey = targetKey => {
|
|
|
178
178
|
return { targetName, propagation }
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
const _resolveColumnsFromQuery = query => {
|
|
182
|
+
if (query && query.SET) return _resolveColumnsFromQuery(query.SET.args[0])
|
|
183
|
+
if (query && query.SELECT && query.SELECT.columns) return query.SELECT.columns
|
|
184
|
+
return []
|
|
185
|
+
}
|
|
186
|
+
|
|
181
187
|
const _resolvedKeys = (foreignKeys, targetKeys, fillChild) => {
|
|
182
188
|
const foreignKeyPropagations = []
|
|
183
189
|
|
|
@@ -191,12 +197,9 @@ const _resolvedKeys = (foreignKeys, targetKeys, fillChild) => {
|
|
|
191
197
|
* Once you have the full path, you can find it in the target entity.
|
|
192
198
|
* NOTE: There can be projections upon projections and renamings in every projection. -> not yet covered!!!
|
|
193
199
|
*/
|
|
194
|
-
const tkCol =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
targetKeys[i].parent.query.SELECT.columns.find(
|
|
198
|
-
c => c.ref && `${fk['@odata.foreignKey4']}_${c.ref.join('_')}` === fk.name
|
|
199
|
-
)
|
|
200
|
+
const tkCol = _resolveColumnsFromQuery(targetKeys[i].parent.query).find(
|
|
201
|
+
c => c.ref && `${fk['@odata.foreignKey4']}_${c.ref.join('_')}` === fk.name
|
|
202
|
+
)
|
|
200
203
|
tk = tkCol && targetKeys.find(tk => tk.name === (tkCol.as ? tkCol.as : tkCol.ref.join('_')))
|
|
201
204
|
// with composition of aspects, the lookup fails -> we need this final fallback
|
|
202
205
|
if (!tk) tk = targetKeys[i]
|
|
@@ -4,9 +4,8 @@ const _toRef = (alias, column) => {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
const _adaptRefs = (onCond, path, { select, join }) => {
|
|
7
|
-
const
|
|
7
|
+
const _adaptEl = el => {
|
|
8
8
|
const ref = el.ref
|
|
9
|
-
|
|
10
9
|
if (ref) {
|
|
11
10
|
if (ref[0] === path.join('_') && ref[1]) {
|
|
12
11
|
return _toRef(select, ref.slice(1))
|
|
@@ -18,12 +17,13 @@ const _adaptRefs = (onCond, path, { select, join }) => {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
return _toRef(join, ref.slice(0))
|
|
20
|
+
} else if (el.xpr) {
|
|
21
|
+
el.xpr = el.xpr.map(_adaptEl)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
return el
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return adaptedOnCondition
|
|
25
|
+
}
|
|
26
|
+
return onCond.map(_adaptEl)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const _args = (csnElement, path, aliases) => {
|