@sap/cds 5.6.3 → 5.7.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 +135 -0
- package/_i18n/i18n_fr.properties +4 -4
- package/apis/cds.d.ts +7 -10
- package/apis/connect.d.ts +3 -3
- package/apis/core.d.ts +2 -4
- package/apis/models.d.ts +2 -3
- package/apis/ql.d.ts +0 -1
- package/apis/services.d.ts +3 -3
- package/bin/build/buildTaskFactory.js +16 -10
- package/bin/build/buildTaskProviderFactory.js +3 -3
- package/bin/build/constants.js +2 -1
- package/bin/build/provider/buildTaskProviderInternal.js +14 -14
- package/bin/build/provider/hana/2migration.js +2 -3
- package/bin/build/provider/hana/index.js +34 -0
- package/bin/build/provider/hana/migrationtable.js +90 -22
- package/bin/build/provider/hana/template/undeploy.json +5 -0
- package/bin/build/provider/node-cf/index.js +9 -2
- package/bin/serve.js +16 -18
- package/lib/compile/cdsc.js +15 -5
- package/lib/compile/etc/_localized.js +4 -4
- package/lib/compile/extend.js +8 -0
- package/lib/compile/index.js +3 -1
- package/lib/compile/minify.js +61 -0
- package/lib/compile/resolve.js +4 -1
- package/lib/compile/to/gql.js +9 -0
- package/lib/compile/to/sql.js +26 -30
- package/lib/connect/index.js +1 -1
- package/lib/core/entities.js +0 -3
- package/lib/core/infer.js +1 -0
- package/lib/core/reflect.js +0 -34
- package/lib/deploy.js +25 -17
- package/lib/env/defaults.js +3 -1
- package/lib/env/index.js +8 -3
- package/lib/env/presets.js +38 -0
- package/lib/env/requires.js +16 -11
- package/lib/index.js +13 -11
- package/lib/log/format/kibana.js +4 -2
- package/lib/log/index.js +2 -2
- package/lib/ql/Whereable.js +1 -0
- package/lib/req/cds-context.js +79 -0
- package/lib/req/context.js +5 -77
- package/lib/req/request.js +1 -1
- package/lib/serve/Service-api.js +8 -4
- package/lib/serve/Service-dispatch.js +0 -7
- package/lib/serve/Service-methods.js +6 -8
- package/lib/serve/Transaction.js +35 -30
- package/lib/serve/adapters.js +1 -4
- package/lib/utils/axios.js +1 -1
- package/libx/_runtime/audit/Service.js +44 -20
- package/libx/_runtime/audit/generic/personal/access.js +16 -11
- package/libx/_runtime/audit/generic/personal/modification.js +5 -5
- package/libx/_runtime/audit/generic/personal/utils.js +46 -37
- package/libx/_runtime/{common/auth → auth}/index.js +21 -7
- package/libx/_runtime/{common/auth → auth}/strategies/JWT.js +2 -2
- package/libx/_runtime/{common/auth → auth}/strategies/basic.js +2 -2
- package/libx/_runtime/{common/auth → auth}/strategies/dummy.js +1 -1
- package/libx/_runtime/{common/auth → auth}/strategies/mock.js +2 -2
- package/libx/_runtime/{common/auth → auth}/strategies/utils/uaa.js +1 -1
- package/libx/_runtime/{common/auth → auth}/strategies/utils/xssec.js +0 -0
- package/libx/_runtime/{common/auth → auth}/strategies/xsuaa.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/Dispatcher.js +7 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +0 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +0 -8
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +3 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +6 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/delete.js +3 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +2 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +16 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +26 -69
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +0 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +3 -66
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +29 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/expandToCQN.js +7 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +9 -5
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/utils.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js +13 -10
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ConditionalRequestControlCommand.js +0 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/ConditionalRequestValidator.js +0 -8
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +54 -76
- package/libx/_runtime/cds-services/adapter/rest/RestRequest.js +0 -7
- package/libx/_runtime/cds-services/adapter/rest/handlers/create.js +3 -6
- package/libx/_runtime/cds-services/adapter/rest/handlers/delete.js +3 -6
- package/libx/_runtime/cds-services/adapter/rest/handlers/operation.js +3 -6
- package/libx/_runtime/cds-services/adapter/rest/handlers/read.js +3 -6
- package/libx/_runtime/cds-services/adapter/rest/handlers/update.js +3 -6
- package/libx/_runtime/cds-services/adapter/rest/rest-to-cqn/index.js +2 -2
- package/libx/_runtime/cds-services/adapter/rest/utils/parse-url.js +8 -4
- package/libx/_runtime/cds-services/services/Service.js +0 -6
- package/libx/_runtime/cds-services/services/utils/columns.js +10 -3
- package/libx/_runtime/cds-services/services/utils/compareJson.js +4 -7
- package/libx/_runtime/cds-services/services/utils/differ.js +4 -1
- package/libx/_runtime/cds-services/services/utils/handlerUtils.js +1 -41
- package/libx/_runtime/cds-services/util/assert.js +1 -262
- package/libx/_runtime/cds.js +6 -9
- package/libx/_runtime/common/aspects/entity.js +1 -1
- package/libx/_runtime/common/composition/delete.js +4 -2
- package/libx/_runtime/common/composition/update.js +22 -38
- package/libx/_runtime/common/composition/utils.js +3 -7
- package/libx/_runtime/common/error/standardError.js +11 -0
- package/libx/_runtime/common/generic/auth.js +63 -33
- package/libx/_runtime/common/generic/crud.js +11 -23
- package/libx/_runtime/common/generic/input.js +20 -0
- package/libx/_runtime/common/generic/paging.js +2 -2
- package/libx/_runtime/common/generic/put.js +4 -10
- package/libx/_runtime/common/generic/sorting.js +12 -30
- package/libx/_runtime/common/i18n/messages.properties +2 -0
- package/libx/_runtime/common/perf/index.js +24 -0
- package/libx/_runtime/common/utils/cqn.js +58 -1
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +298 -121
- package/libx/_runtime/common/utils/csn.js +38 -56
- package/libx/_runtime/common/utils/entityFromCqn.js +6 -6
- package/libx/_runtime/common/utils/resolveView.js +4 -5
- package/libx/_runtime/common/utils/rewriteAsterisks.js +46 -5
- package/libx/_runtime/common/utils/search2cqn4sql.js +21 -9
- package/libx/_runtime/common/utils/structured.js +35 -25
- package/libx/_runtime/db/Service.js +0 -6
- package/libx/_runtime/db/expand/expand-v2.js +130 -0
- package/libx/_runtime/db/expand/expandCQNToJoin.js +38 -52
- package/libx/_runtime/db/expand/index.js +3 -1
- package/libx/_runtime/db/generic/arrayed.js +3 -1
- package/libx/_runtime/db/generic/input.js +52 -10
- package/libx/_runtime/db/generic/integrity.js +367 -26
- package/libx/_runtime/db/generic/virtual.js +51 -13
- package/libx/_runtime/db/query/read.js +12 -8
- package/libx/_runtime/db/query/update.js +9 -3
- package/libx/_runtime/db/sql-builder/ExpressionBuilder.js +8 -9
- package/libx/_runtime/{common → db}/utils/propagateForeignKeys.js +11 -14
- package/libx/_runtime/fiori/generic/activate.js +1 -0
- package/libx/_runtime/fiori/generic/before.js +2 -1
- package/libx/_runtime/fiori/generic/edit.js +1 -0
- package/libx/_runtime/fiori/generic/patch.js +1 -1
- package/libx/_runtime/fiori/generic/read.js +128 -57
- package/libx/_runtime/fiori/uiflex/handler/transformRESULT.js +0 -4
- package/libx/_runtime/fiori/uiflex/index.js +1 -1
- package/libx/_runtime/fiori/uiflex/{extensibility/index.js → service.js} +6 -4
- package/libx/_runtime/fiori/utils/delete.js +7 -1
- package/libx/_runtime/hana/Service.js +1 -8
- package/libx/_runtime/hana/customBuilder/CustomSelectBuilder.js +5 -14
- package/libx/_runtime/hana/execute.js +10 -4
- package/libx/_runtime/hana/pool.js +55 -45
- package/libx/_runtime/hana/search.js +7 -6
- package/libx/_runtime/hana/search2cqn4sql.js +8 -5
- package/libx/_runtime/hana/searchToContains.js +3 -1
- package/libx/_runtime/index.js +5 -5
- package/libx/_runtime/messaging/AMQPWebhookMessaging.js +3 -3
- package/libx/_runtime/messaging/Outbox.js +53 -0
- package/libx/_runtime/messaging/common-utils/AMQPClient.js +17 -10
- package/libx/_runtime/messaging/common-utils/connections.js +14 -9
- package/libx/_runtime/messaging/common-utils/waitingTime.js +2 -0
- package/libx/_runtime/messaging/enterprise-messaging-shared.js +2 -3
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +2 -2
- package/libx/_runtime/messaging/enterprise-messaging.js +21 -15
- package/libx/_runtime/messaging/file-based.js +5 -5
- package/libx/_runtime/messaging/message-queuing-utils/options-messaging.js +1 -0
- package/libx/_runtime/messaging/message-queuing.js +2 -3
- package/libx/_runtime/messaging/outbox/OutboxRunner.js +75 -0
- package/libx/_runtime/messaging/outbox/utils.js +192 -0
- package/libx/_runtime/messaging/service.js +16 -30
- package/libx/_runtime/remote/Service.js +15 -0
- package/libx/_runtime/remote/utils/client.js +15 -3
- package/libx/_runtime/remote/utils/{dataConversion.js → data.js} +12 -2
- package/libx/_runtime/sqlite/Service.js +7 -10
- package/libx/_runtime/sqlite/customBuilder/CustomExpressionBuilder.js +19 -0
- package/libx/_runtime/sqlite/execute.js +18 -12
- package/libx/_runtime/types/api.js +2 -1
- package/libx/gql/resolvers/parse/ast2cqn/columns.js +1 -1
- package/libx/odata/{odata2cqn/afterburner.js → afterburner.js} +28 -16
- package/libx/odata/{cqn2odata/index.js → cqn2odata.js} +1 -1
- package/libx/odata/{odata2cqn/grammar.pegjs → grammar.pegjs} +222 -130
- package/libx/odata/index.js +23 -14
- package/libx/odata/parser.js +1 -0
- package/libx/odata/utils.js +57 -0
- package/libx/rest/RestAdapter.js +2 -6
- package/libx/rest/utils/data.js +1 -6
- package/package.json +4 -3
- package/server.js +4 -5
- package/srv/audit-log.cds +87 -0
- package/{libx/_runtime/fiori/uiflex/extensibility/index.cds → srv/flex.cds} +0 -0
- package/srv/flex.js +1 -0
- package/srv/outbox.cds +11 -0
- package/srv/outbox.js +0 -0
- package/libx/_runtime/cds-services/adapter/perf/performance.js +0 -104
- package/libx/_runtime/cds-services/adapter/perf/performanceMeasurement.js +0 -33
- package/libx/odata/odata2cqn/index.js +0 -3
- package/libx/odata/odata2cqn/parser.js +0 -1
- package/libx/odata/readme.md +0 -1
- package/libx/odata/utils/index.js +0 -64
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const cds = require('
|
|
1
|
+
const cds = require('../_runtime/cds')
|
|
2
2
|
|
|
3
|
-
const { where2obj } = require('
|
|
4
|
-
const { findCsnTargetFor } = require('
|
|
3
|
+
const { where2obj } = require('../_runtime/common/utils/cqn')
|
|
4
|
+
const { findCsnTargetFor } = require('../_runtime/common/utils/csn')
|
|
5
5
|
|
|
6
6
|
function _keysOf(entity) {
|
|
7
7
|
return entity && entity.keys
|
|
@@ -11,11 +11,11 @@ function _keysOf(entity) {
|
|
|
11
11
|
: []
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function _getDefinition(definition, name) {
|
|
14
|
+
function _getDefinition(definition, name, namespace) {
|
|
15
15
|
return (
|
|
16
16
|
(definition.definitions && definition.definitions[name]) ||
|
|
17
17
|
(definition.elements && definition.elements[name]) ||
|
|
18
|
-
(definition.actions && definition.actions[name]) ||
|
|
18
|
+
(definition.actions && (definition.actions[name] || definition.actions[name.replace(namespace + '.', '')])) ||
|
|
19
19
|
definition[name]
|
|
20
20
|
)
|
|
21
21
|
}
|
|
@@ -29,7 +29,7 @@ function _resolveAliasInWhere(where, entity) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// case: single key without name, e.g., Foo(1)
|
|
32
|
-
function
|
|
32
|
+
function addRefToWhereIfNecessary(where, entity) {
|
|
33
33
|
if (!where || where.length !== 1) return 0
|
|
34
34
|
const keys = _keysOf(entity)
|
|
35
35
|
if (keys.length !== 1) return 0
|
|
@@ -37,8 +37,9 @@ function _addRefToWhereIfNecessary(where, entity) {
|
|
|
37
37
|
return 1
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function _processSegments(cqn, model) {
|
|
41
|
-
const
|
|
40
|
+
function _processSegments(cqn, model, namespace) {
|
|
41
|
+
const from = _resolveFrom(cqn.SELECT.from)
|
|
42
|
+
const ref = from.ref
|
|
42
43
|
|
|
43
44
|
let current = model
|
|
44
45
|
let path
|
|
@@ -59,7 +60,15 @@ function _processSegments(cqn, model) {
|
|
|
59
60
|
let base = ref[i - keyCount]
|
|
60
61
|
if (!base.id) base = { id: base, where: [] }
|
|
61
62
|
if (base.where.length) base.where.push('and')
|
|
62
|
-
|
|
63
|
+
if (ref[i].id) {
|
|
64
|
+
// > fix case key value parsed to collection with filter
|
|
65
|
+
const val = `${ref[i].id}(${Object.keys(params)
|
|
66
|
+
.map(k => `${k}='${params[k]}'`)
|
|
67
|
+
.join(',')})`
|
|
68
|
+
base.where.push({ ref: [key] }, '=', { val })
|
|
69
|
+
} else {
|
|
70
|
+
base.where.push({ ref: [key] }, '=', { val: element.type === 'cds.Integer' ? Number(seg) : seg })
|
|
71
|
+
}
|
|
63
72
|
ref[i] = null
|
|
64
73
|
ref[i - keyCount] = base
|
|
65
74
|
incompleteKeys = keyCount < keys.length
|
|
@@ -71,7 +80,7 @@ function _processSegments(cqn, model) {
|
|
|
71
80
|
|
|
72
81
|
path = path ? path + `${path.match(/:/) ? '.' : ':'}${seg}` : seg
|
|
73
82
|
// REVISIT: replace use case: <namespace>.<entity>_history is at <namespace>.<entity>.history
|
|
74
|
-
current = _getDefinition(current, seg) || _getDefinition(current, seg.replace(/_/g, '.'))
|
|
83
|
+
current = _getDefinition(current, seg, namespace) || _getDefinition(current, seg.replace(/_/g, '.'), namespace)
|
|
75
84
|
// REVISIT: 404 or 400?
|
|
76
85
|
if (!current) cds.error(`Invalid resource path "${path}"`, { code: 404 })
|
|
77
86
|
|
|
@@ -80,7 +89,7 @@ function _processSegments(cqn, model) {
|
|
|
80
89
|
one = !!(ref[i].where || current._isSingleton)
|
|
81
90
|
incompleteKeys = ref[i].where ? false : i === ref.length - 1 || one ? false : true
|
|
82
91
|
if (ref[i].where) {
|
|
83
|
-
keyCount +=
|
|
92
|
+
keyCount += addRefToWhereIfNecessary(ref[i].where, current)
|
|
84
93
|
_resolveAliasInWhere(ref[i].where, current)
|
|
85
94
|
}
|
|
86
95
|
} else if ({ action: 1, function: 1 }[current.kind]) {
|
|
@@ -98,7 +107,7 @@ function _processSegments(cqn, model) {
|
|
|
98
107
|
incompleteKeys = one || i === ref.length - 1 ? false : true
|
|
99
108
|
current = model.definitions[current.target]
|
|
100
109
|
if (ref[i].where) {
|
|
101
|
-
keyCount +=
|
|
110
|
+
keyCount += addRefToWhereIfNecessary(ref[i].where, current)
|
|
102
111
|
_resolveAliasInWhere(ref[i].where, current)
|
|
103
112
|
}
|
|
104
113
|
} else if (current._isStructured) {
|
|
@@ -125,7 +134,7 @@ function _processSegments(cqn, model) {
|
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
// remove all nulled refs
|
|
128
|
-
|
|
137
|
+
from.ref = ref.filter(r => r)
|
|
129
138
|
|
|
130
139
|
// one?
|
|
131
140
|
if (one) cqn.SELECT.one = true
|
|
@@ -135,11 +144,13 @@ function _processSegments(cqn, model) {
|
|
|
135
144
|
cqn.__target = current
|
|
136
145
|
}
|
|
137
146
|
|
|
147
|
+
const _resolveFrom = from => (from.SELECT ? _resolveFrom(from.SELECT.from) : from)
|
|
148
|
+
|
|
138
149
|
function _4service(service) {
|
|
139
150
|
const { namespace, model } = service
|
|
140
151
|
|
|
141
152
|
return cqn => {
|
|
142
|
-
const { ref } = cqn.SELECT.from
|
|
153
|
+
const { ref } = _resolveFrom(cqn.SELECT.from)
|
|
143
154
|
|
|
144
155
|
// REVISIT: shouldn't be necessary
|
|
145
156
|
/*
|
|
@@ -154,7 +165,7 @@ function _4service(service) {
|
|
|
154
165
|
/*
|
|
155
166
|
* key vs. path segments (/Books/1/author/books/2/...) and more
|
|
156
167
|
*/
|
|
157
|
-
_processSegments(cqn, model)
|
|
168
|
+
_processSegments(cqn, model, namespace)
|
|
158
169
|
|
|
159
170
|
return cqn
|
|
160
171
|
}
|
|
@@ -166,5 +177,6 @@ module.exports = {
|
|
|
166
177
|
for: service => {
|
|
167
178
|
if (!cache.has(service)) cache.set(service, _4service(service))
|
|
168
179
|
return cache.get(service)
|
|
169
|
-
}
|
|
180
|
+
},
|
|
181
|
+
addRefToWhereIfNecessary
|
|
170
182
|
}
|