@sap/cds 5.5.5 → 5.6.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 +139 -1
- package/apis/services.d.ts +31 -1
- package/app/index.js +22 -11
- package/bin/build/buildTaskFactory.js +1 -1
- package/bin/build/provider/buildTaskProviderInternal.js +1 -1
- package/bin/build/provider/fiori/index.js +1 -1
- package/bin/build/provider/hana/2migration.js +8 -7
- package/bin/build/provider/java-cf/index.js +1 -1
- package/bin/deploy/to-hana/hana.js +1 -17
- package/common.cds +8 -0
- package/lib/compile/to/sql.js +22 -2
- package/lib/connect/bindings.js +2 -1
- package/lib/core/reflect.js +4 -1
- package/lib/env/index.js +180 -42
- package/lib/env/requires.js +16 -1
- package/lib/i18n/localize.js +33 -5
- package/lib/index.js +3 -3
- package/lib/log/format/kibana.js +6 -2
- package/lib/ql/Query.js +1 -0
- package/lib/ql/SELECT.js +15 -8
- package/lib/ql/Whereable.js +5 -0
- package/lib/req/context.js +13 -5
- package/lib/serve/Service-dispatch.js +8 -1
- package/lib/utils/axios.js +7 -0
- package/lib/utils/data.js +1 -1
- package/lib/utils/tests.js +1 -1
- package/libx/_runtime/audit/Service.js +18 -18
- package/libx/_runtime/audit/generic/personal/access.js +1 -1
- package/libx/_runtime/audit/generic/personal/modification.js +3 -2
- package/libx/_runtime/audit/generic/personal/utils.js +23 -63
- package/libx/_runtime/cds-services/adapter/odata-v4/Dispatcher.js +4 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +37 -35
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +3 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +5 -5
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +13 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +84 -34
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +12 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/applyToCQN.js +9 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/expandToCQN.js +8 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/index.js +1 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +13 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/selectHelper.js +11 -95
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ResourcePathParser.js +17 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js +2 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/SetResponseHeadersCommand.js +1 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/to.js +6 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +3 -34
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/handlerUtils.js +3 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +64 -31
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +10 -5
- package/libx/_runtime/cds-services/adapter/rest/handlers/operation.js +1 -1
- package/libx/_runtime/cds-services/adapter/rest/handlers/update.js +1 -1
- package/libx/_runtime/cds-services/adapter/rest/rest-to-cqn/index.js +1 -3
- package/libx/_runtime/cds-services/adapter/rest/utils/validation-checks.js +20 -21
- package/libx/_runtime/cds-services/services/utils/columns.js +6 -1
- package/libx/_runtime/cds-services/services/utils/compareJson.js +1 -8
- package/libx/_runtime/cds-services/services/utils/differ.js +7 -26
- package/libx/_runtime/cds-services/services/utils/handlerUtils.js +2 -4
- package/libx/_runtime/cds-services/util/assert.js +29 -13
- package/libx/_runtime/cds.js +2 -1
- package/libx/_runtime/common/aspects/Association.js +72 -0
- package/libx/_runtime/common/aspects/any.js +8 -45
- package/libx/_runtime/common/aspects/entity.js +0 -1
- package/libx/_runtime/common/aspects/relation.js +40 -0
- package/libx/_runtime/common/aspects/utils.js +73 -1
- package/libx/_runtime/common/auth/strategies/utils/uaa.js +10 -14
- package/libx/_runtime/common/composition/data.js +3 -2
- package/libx/_runtime/common/composition/delete.js +3 -1
- package/libx/_runtime/common/composition/tree.js +23 -18
- package/libx/_runtime/common/composition/update.js +9 -1
- package/libx/_runtime/common/composition/utils.js +34 -8
- package/libx/_runtime/common/error/frontend.js +6 -1
- package/libx/_runtime/common/generic/auth.js +5 -9
- package/libx/_runtime/common/generic/crud.js +2 -2
- package/libx/_runtime/common/generic/etag.js +11 -8
- package/libx/_runtime/common/generic/input.js +3 -3
- package/libx/_runtime/common/generic/paging.js +9 -5
- package/libx/_runtime/common/generic/put.js +3 -2
- package/libx/_runtime/common/generic/sorting.js +3 -3
- package/libx/_runtime/common/generic/temporal.js +3 -3
- package/libx/_runtime/common/utils/cqn.js +20 -1
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +125 -139
- package/libx/_runtime/common/utils/csn.js +50 -52
- package/libx/_runtime/common/utils/foreignKeyPropagations.js +41 -176
- package/libx/_runtime/common/utils/generateOnCond.js +40 -70
- package/libx/_runtime/common/utils/{enrichWithKeysFromWhere.js → keys.js} +29 -28
- package/libx/_runtime/common/utils/postProcessing.js +3 -0
- package/libx/_runtime/common/utils/propagateForeignKeys.js +84 -0
- package/libx/_runtime/common/utils/resolveStructured.js +1 -1
- package/libx/_runtime/common/utils/resolveView.js +7 -5
- package/libx/_runtime/common/utils/rewriteAsterisks.js +94 -0
- package/libx/_runtime/common/utils/search2cqn4sql.js +9 -8
- package/libx/_runtime/common/utils/template.js +54 -46
- package/libx/_runtime/db/Service.js +9 -2
- package/libx/_runtime/db/expand/expandCQNToJoin.js +54 -33
- package/libx/_runtime/db/expand/rawToExpanded.js +2 -1
- package/libx/_runtime/db/generic/arrayed.js +13 -28
- package/libx/_runtime/db/generic/create.js +1 -0
- package/libx/_runtime/db/generic/input.js +7 -11
- package/libx/_runtime/db/generic/integrity.js +2 -2
- package/libx/_runtime/db/generic/rewrite.js +2 -5
- package/libx/_runtime/db/generic/update.js +1 -0
- package/libx/_runtime/db/query/read.js +9 -4
- package/libx/_runtime/db/sql-builder/SelectBuilder.js +7 -2
- package/libx/_runtime/db/sql-builder/annotations.js +1 -0
- package/libx/_runtime/db/utils/columns.js +14 -43
- package/libx/_runtime/fiori/generic/activate.js +3 -2
- package/libx/_runtime/fiori/generic/before.js +2 -2
- package/libx/_runtime/fiori/generic/cancel.js +3 -2
- package/libx/_runtime/fiori/generic/delete.js +3 -2
- package/libx/_runtime/fiori/generic/edit.js +3 -3
- package/libx/_runtime/fiori/generic/new.js +2 -2
- package/libx/_runtime/fiori/generic/patch.js +2 -2
- package/libx/_runtime/fiori/generic/prepare.js +2 -2
- package/libx/_runtime/fiori/generic/read.js +45 -63
- package/libx/_runtime/fiori/generic/readOverDraft.js +4 -4
- package/libx/_runtime/fiori/uiflex/extensibility/index.cds +15 -0
- package/libx/_runtime/fiori/uiflex/extensibility/index.js +148 -0
- package/libx/_runtime/fiori/uiflex/handler/transformREAD.js +119 -0
- package/libx/_runtime/fiori/uiflex/handler/transformRESULT.js +43 -0
- package/libx/_runtime/fiori/uiflex/handler/transformWRITE.js +62 -0
- package/libx/_runtime/fiori/uiflex/index.js +35 -0
- package/libx/_runtime/fiori/uiflex/utils.js +78 -0
- package/libx/_runtime/fiori/utils/handler.js +3 -13
- package/libx/_runtime/fiori/utils/where.js +6 -1
- package/libx/_runtime/hana/pool.js +12 -11
- package/libx/_runtime/hana/search2cqn4sql.js +34 -43
- package/libx/_runtime/hana/searchToContains.js +3 -3
- package/libx/_runtime/index.js +5 -2
- package/libx/_runtime/messaging/AMQPWebhookMessaging.js +1 -1
- package/libx/_runtime/messaging/common-utils/AMQPClient.js +16 -3
- package/libx/_runtime/messaging/common-utils/connections.js +11 -14
- package/libx/_runtime/messaging/common-utils/naming-conventions.js +1 -1
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +2 -1
- package/libx/_runtime/messaging/message-queuing.js +18 -0
- package/libx/_runtime/remote/Service.js +20 -4
- package/libx/_runtime/remote/utils/client-types.d.ts +7 -0
- package/libx/_runtime/remote/utils/client.js +117 -23
- package/libx/_runtime/sqlite/Service.js +2 -2
- package/libx/_runtime/sqlite/convertAssocToOneManaged.js +1 -3
- package/libx/gql/GraphQLAdapter.js +33 -0
- package/libx/gql/constants/adapter.js +69 -0
- package/libx/gql/constants/cds.js +18 -0
- package/libx/gql/constants/graphql.js +33 -0
- package/libx/gql/resolvers/crud/create.js +15 -0
- package/libx/gql/resolvers/crud/delete.js +24 -0
- package/libx/gql/resolvers/crud/index.js +6 -0
- package/libx/gql/resolvers/crud/read.js +25 -0
- package/libx/gql/resolvers/crud/update.js +31 -0
- package/libx/gql/resolvers/crud/utils/index.js +36 -0
- package/libx/gql/resolvers/field.js +5 -0
- package/libx/gql/resolvers/index.js +7 -0
- package/libx/gql/resolvers/mutation.js +23 -0
- package/libx/gql/resolvers/parse/ast/enrich.js +51 -0
- package/libx/gql/resolvers/parse/ast/fragment.js +11 -0
- package/libx/gql/resolvers/parse/ast/fromObject.js +39 -0
- package/libx/gql/resolvers/parse/ast/index.js +3 -0
- package/libx/gql/resolvers/parse/ast/meta.js +4 -0
- package/libx/gql/resolvers/parse/ast/variable.js +7 -0
- package/libx/gql/resolvers/parse/ast2cqn/columns.js +42 -0
- package/libx/gql/resolvers/parse/ast2cqn/entries.js +31 -0
- package/libx/gql/resolvers/parse/ast2cqn/index.js +8 -0
- package/libx/gql/resolvers/parse/ast2cqn/limit.js +6 -0
- package/libx/gql/resolvers/parse/ast2cqn/orderBy.js +24 -0
- package/libx/gql/resolvers/parse/ast2cqn/utils/index.js +3 -0
- package/libx/gql/resolvers/parse/ast2cqn/where.js +70 -0
- package/libx/gql/resolvers/parse/utils/index.js +8 -0
- package/libx/gql/resolvers/query.js +13 -0
- package/libx/gql/resolvers/root.js +34 -0
- package/libx/gql/schema/generate.js +18 -0
- package/libx/gql/schema/index.js +5 -0
- package/libx/gql/schema/mutation.js +76 -0
- package/libx/gql/schema/query.js +108 -0
- package/libx/gql/schema/typeDefMap.js +45 -0
- package/libx/gql/schema/utils/index.js +54 -0
- package/libx/gql/utils/index.js +12 -0
- package/libx/{_runtime/odata/cqn2odata.js → odata/cqn2odata/index.js} +39 -100
- package/libx/odata/index.js +80 -0
- package/libx/odata/odata2cqn/afterburner.js +170 -0
- package/libx/{_runtime/odata/odata2cqn.pegjs → odata/odata2cqn/grammar.pegjs} +102 -123
- package/libx/odata/odata2cqn/index.js +3 -0
- package/libx/odata/odata2cqn/parser.js +1 -0
- package/libx/odata/utils/index.js +64 -0
- package/libx/rest/RestAdapter.js +101 -0
- package/libx/rest/RestRequest.js +30 -0
- package/libx/rest/index.js +3 -0
- package/libx/rest/middleware/auth.js +22 -0
- package/libx/rest/middleware/content.js +15 -0
- package/libx/rest/middleware/create.js +40 -0
- package/libx/rest/middleware/delete.js +20 -0
- package/libx/rest/middleware/error.js +56 -0
- package/libx/rest/middleware/operation.js +39 -0
- package/libx/rest/middleware/parse.js +90 -0
- package/libx/rest/middleware/read.js +29 -0
- package/libx/rest/middleware/update.js +42 -0
- package/libx/rest/utils/data.js +65 -0
- package/package.json +4 -1
- package/server.js +29 -7
- package/libx/_runtime/cds-services/services/utils/diff.js +0 -53
- package/libx/_runtime/cds-services/util/auditlog.js +0 -247
- package/libx/_runtime/cds-services/util/xsenv.js +0 -51
- package/libx/_runtime/common/utils/backlinks.js +0 -83
- package/libx/_runtime/common/utils/rewriteAsterisk.js +0 -72
- package/libx/_runtime/odata/index.js +0 -55
- package/libx/_runtime/odata/odata2cqn.js +0 -1
- package/libx/_runtime/odata/readToCqn.js +0 -129
- package/libx/_runtime/remote/cqn2odata/index.js +0 -2
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const cds = require('../cds')
|
|
2
|
-
const { SELECT } = cds.ql
|
|
3
|
-
|
|
4
|
-
const getError = require('../common/error')
|
|
5
|
-
const { findCsnTargetFor } = require('../common/utils/csn')
|
|
6
|
-
const { getAllKeys } = require('../cds-services/adapter/odata-v4/odata-to-cqn/utils')
|
|
7
|
-
const rewriteAsterisk = require('../common/utils/rewriteAsterisk')
|
|
8
|
-
const { getMaxPageSize } = require('../common/utils/page')
|
|
9
|
-
|
|
10
|
-
const _hasAllEntityKeysInWhere = (keys, where) => {
|
|
11
|
-
if (!(where && keys && keys.length)) return
|
|
12
|
-
keys = keys.map(key => (Array.isArray(key) ? key.join('_') : key))
|
|
13
|
-
for (const part of where) {
|
|
14
|
-
if (part.ref && keys.indexOf(part.ref.join('_')) > -1) {
|
|
15
|
-
keys.splice(keys.indexOf(part.ref.join('_')))
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return keys.length === 0
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const _setLimits = (cqn, parsed, target) => {
|
|
23
|
-
// adjust SELECT.limit based on @cds.query.limit annotations
|
|
24
|
-
const rows = parsed.SELECT.limit.rows ? parsed.SELECT.limit.rows.val : Number.MAX_SAFE_INTEGER
|
|
25
|
-
const offset = parsed.SELECT.limit.offset ? parsed.SELECT.limit.offset.val : 0
|
|
26
|
-
cqn.limit(Math.min(rows, getMaxPageSize(target)), offset)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const _setRootInFrom = (cqn, target, model, namespace) => {
|
|
30
|
-
const root = _findRoot(cqn, target, model, namespace)
|
|
31
|
-
const from = cqn.SELECT.from
|
|
32
|
-
if (from.ref[0].id) from.ref[0].id = root.name
|
|
33
|
-
else from.ref[0] = root.name
|
|
34
|
-
return cqn
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const _findRoot = (cqn, target, model, namespace) => {
|
|
38
|
-
const parsedTargetName = cqn.SELECT.from.ref[0].id || cqn.SELECT.from.ref[0]
|
|
39
|
-
return target.name === parsedTargetName ? target : findCsnTargetFor(parsedTargetName, model, namespace)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const _resolveRef = (ref, model, parent) => {
|
|
43
|
-
ref = ref.id || ref
|
|
44
|
-
const element = parent && parent.elements && parent.elements[ref]
|
|
45
|
-
let target = element || parent || model.definitions[ref]
|
|
46
|
-
let aspect
|
|
47
|
-
if (target && !target.elements) {
|
|
48
|
-
if (target.target) {
|
|
49
|
-
if (target.targetAspect) aspect = model.definitions[target.targetAspect]
|
|
50
|
-
target = model.definitions[target.target]
|
|
51
|
-
} else if (target.kind === 'type') {
|
|
52
|
-
target = model.definitions[target.type]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const keys = getAllKeys(aspect || target, false)
|
|
56
|
-
return { target, keys, element }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const _resolveStructKeys = (where, keys) => {
|
|
60
|
-
for (const el of where) {
|
|
61
|
-
if (!el.ref) continue
|
|
62
|
-
const keyIdx = keys.findIndex(key => Array.isArray(key) && key[key.length - 1] === el.ref[0])
|
|
63
|
-
if (keyIdx > -1) {
|
|
64
|
-
el.ref = [keys[keyIdx].join('_')]
|
|
65
|
-
keys.splice(keyIdx, 1)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const _postProcess = (cqn, target, model, namespace) => {
|
|
71
|
-
_setRootInFrom(cqn, target, model, namespace)
|
|
72
|
-
let prev
|
|
73
|
-
for (let i = 0; i < cqn.SELECT.from.ref.length; i++) {
|
|
74
|
-
const ref = cqn.SELECT.from.ref[i]
|
|
75
|
-
const { target, keys, element } = _resolveRef(ref, model, prev)
|
|
76
|
-
if (ref.where) {
|
|
77
|
-
// cases like `GET /Foo(1)/bar(2)` => `where` contains single `val`s
|
|
78
|
-
if (ref.where.length === 1 && keys.length === 1) {
|
|
79
|
-
ref.where = [{ ref: [Array.isArray(keys[0]) ? keys[0].join('_') : keys[0]] }, '=', ref.where[0]]
|
|
80
|
-
} else {
|
|
81
|
-
_resolveStructKeys(ref.where, keys)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// $value never comes, $count is 2many, $ref is to be checked
|
|
85
|
-
if (i === cqn.SELECT.from.ref.length - 1) {
|
|
86
|
-
if (target && !target.elements) delete cqn.SELECT.columns
|
|
87
|
-
if ((element && element.is2one) || (target && target._isSingleton) || _hasAllEntityKeysInWhere(keys, ref.where)) {
|
|
88
|
-
cqn.SELECT.one = true
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
prev = target
|
|
92
|
-
}
|
|
93
|
-
return cqn
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/*
|
|
97
|
-
* uses new odata2cqn
|
|
98
|
-
*/
|
|
99
|
-
const _newReadToCQN = ({ model, namespace }, target, req) => {
|
|
100
|
-
let parsed
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
parsed = cds.odata.parse.url(req.url || req._inRequestUrl)
|
|
104
|
-
} catch (err) {
|
|
105
|
-
throw getError(400, err.message)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
_postProcess(parsed, target, model, namespace)
|
|
109
|
-
|
|
110
|
-
const cqn = SELECT.from(parsed.SELECT.from, parsed.SELECT.columns)
|
|
111
|
-
if (parsed.SELECT.search) cqn.SELECT.search = parsed.SELECT.search
|
|
112
|
-
if (parsed.SELECT.where) cqn.SELECT.where = parsed.SELECT.where
|
|
113
|
-
if (parsed.SELECT.orderBy) cqn.SELECT.orderBy = parsed.SELECT.orderBy
|
|
114
|
-
if (parsed.SELECT.groupBy) cqn.SELECT.groupBy = parsed.SELECT.groupBy
|
|
115
|
-
if (parsed.SELECT.count) cqn.SELECT.count = parsed.SELECT.count
|
|
116
|
-
if (parsed.SELECT.one) {
|
|
117
|
-
cqn.SELECT.one = parsed.SELECT.one
|
|
118
|
-
} else if (parsed.SELECT.limit) {
|
|
119
|
-
_setLimits(cqn, parsed, target, model)
|
|
120
|
-
}
|
|
121
|
-
if (!cds.env.features.rest_new_parser) {
|
|
122
|
-
// REVISIT not needed for rest parser?
|
|
123
|
-
rewriteAsterisk({ query: cqn, target })
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return cqn
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = { _newReadToCQN }
|