@sap/cds 8.5.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -3
- package/_i18n/i18n.properties +4 -7
- package/eslint.config.mjs +1 -1
- package/lib/compile/etc/properties.js +2 -2
- package/lib/compile/for/java.js +15 -3
- package/lib/compile/for/lean_drafts.js +44 -34
- package/lib/compile/for/nodejs.js +19 -10
- package/lib/compile/minify.js +2 -4
- package/lib/compile/parse.js +106 -72
- package/lib/compile/to/edm.js +19 -9
- package/lib/compile/to/hana.js +25 -21
- package/lib/compile/to/sql.js +15 -8
- package/lib/core/linked-csn.js +10 -4
- package/lib/dbs/cds-deploy.js +2 -2
- package/lib/env/cds-env.js +76 -66
- package/lib/env/defaults.js +1 -0
- package/lib/i18n/bundles.js +2 -1
- package/lib/i18n/localize.js +2 -2
- package/lib/index.js +24 -18
- package/lib/ql/CREATE.js +11 -6
- package/lib/ql/DELETE.js +12 -9
- package/lib/ql/DROP.js +15 -8
- package/lib/ql/INSERT.js +19 -14
- package/lib/ql/SELECT.js +95 -168
- package/lib/ql/UPDATE.js +23 -14
- package/lib/ql/UPSERT.js +15 -2
- package/lib/ql/Whereable.js +44 -118
- package/lib/ql/cds-ql.js +222 -28
- package/lib/ql/{Query.js → cds.ql-Query.js} +52 -41
- package/lib/ql/cds.ql-predicates.js +133 -0
- package/lib/ql/cds.ql-projections.js +111 -0
- package/lib/ql/cqn.d.ts +146 -0
- package/lib/srv/cds-connect.js +3 -3
- package/lib/srv/cds-serve.js +2 -2
- package/lib/srv/cds.Service.js +132 -0
- package/lib/srv/{srv-api.js → cds.ServiceClient.js} +16 -71
- package/lib/srv/cds.ServiceProvider.js +20 -0
- package/lib/srv/factory.js +20 -8
- package/lib/srv/protocols/hcql.js +2 -3
- package/lib/srv/protocols/index.js +3 -3
- package/lib/srv/srv-dispatch.js +7 -6
- package/lib/srv/srv-handlers.js +103 -113
- package/lib/srv/srv-methods.js +14 -14
- package/lib/srv/srv-tx.js +5 -3
- package/lib/utils/cds-utils.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +3 -3
- package/libx/_runtime/cds.js +2 -1
- package/libx/_runtime/common/aspects/service.js +25 -0
- package/libx/_runtime/common/generic/auth/index.js +5 -0
- package/libx/_runtime/common/generic/auth/restrict.js +36 -14
- package/libx/_runtime/common/generic/auth/service.js +24 -0
- package/libx/_runtime/common/generic/auth/utils.js +14 -6
- package/libx/_runtime/common/generic/etag.js +1 -1
- package/libx/_runtime/common/utils/cqn.js +1 -2
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +1 -1
- package/libx/_runtime/common/utils/generateOnCond.js +7 -3
- package/libx/_runtime/common/utils/postProcess.js +4 -1
- package/libx/_runtime/common/utils/restrictions.js +1 -0
- package/libx/_runtime/fiori/lean-draft.js +53 -42
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +1 -1
- package/libx/_runtime/remote/Service.js +2 -0
- package/libx/_runtime/remote/utils/client.js +12 -0
- package/libx/odata/ODataAdapter.js +2 -1
- package/libx/odata/index.js +5 -3
- package/libx/odata/middleware/batch.js +4 -0
- package/libx/odata/middleware/create.js +2 -2
- package/libx/odata/middleware/delete.js +2 -2
- package/libx/odata/middleware/operation.js +2 -2
- package/libx/odata/middleware/read.js +14 -12
- package/libx/odata/middleware/service-document.js +16 -8
- package/libx/odata/middleware/update.js +2 -2
- package/libx/odata/parse/afterburner.js +64 -30
- package/libx/odata/parse/grammar.peggy +95 -0
- package/libx/odata/parse/parser.js +1 -1
- package/libx/odata/utils/index.js +6 -1
- package/libx/odata/utils/metadata.js +69 -75
- package/libx/odata/utils/postProcess.js +24 -3
- package/package.json +1 -1
- package/server.js +1 -1
- package/lib/ql/parse.js +0 -36
- /package/lib/ql/{infer.js → cds.ql-infer.js} +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
const cds = require('../../../lib')
|
|
2
|
+
|
|
1
3
|
const getTemplate = require('../../_runtime/common/utils/template')
|
|
2
4
|
const { toBase64url } = require('../../_runtime/common/utils/binary')
|
|
3
5
|
|
|
4
6
|
const _addEtags = (row, key) => {
|
|
5
7
|
if (!row[key]) return
|
|
6
|
-
|
|
8
|
+
// if provided as js date, take the iso string
|
|
9
|
+
const value = row[key] instanceof Date ? row[key].toISOString() : row[key]
|
|
10
|
+
row.$etag = value.startsWith?.('W/') ? value : `W/"${value}"`
|
|
7
11
|
}
|
|
8
|
-
|
|
9
12
|
const _processorFn = elementInfo => {
|
|
10
13
|
const { row, plain } = elementInfo
|
|
11
14
|
if (typeof row !== 'object') return
|
|
@@ -29,7 +32,10 @@ const _processorFn = elementInfo => {
|
|
|
29
32
|
}
|
|
30
33
|
break
|
|
31
34
|
case 'array':
|
|
32
|
-
row[key]
|
|
35
|
+
if (row[key] === null) row[key] = []
|
|
36
|
+
break
|
|
37
|
+
case '@cleanup':
|
|
38
|
+
if (key !== 'DraftAdministrativeData_DraftUUID') delete row[key]
|
|
33
39
|
break
|
|
34
40
|
// no default
|
|
35
41
|
}
|
|
@@ -42,6 +48,21 @@ const _pick = element => {
|
|
|
42
48
|
if (element['@cds.api.ignore'] && !element.isAssociation) categories.push('@cds.api.ignore')
|
|
43
49
|
if (element._type === 'cds.Binary') categories.push('binary')
|
|
44
50
|
if (element.items) categories.push('array')
|
|
51
|
+
|
|
52
|
+
// in case of containment managed composition (& assoc backlinks) keys are not exposed and have to be removed from the result
|
|
53
|
+
if (cds.env.effective.odata.containment) {
|
|
54
|
+
const _isContainedOrBackLink = element =>
|
|
55
|
+
element &&
|
|
56
|
+
element.isAssociation &&
|
|
57
|
+
element.keys &&
|
|
58
|
+
(element._isContained || (element._anchor && element._anchor._isContained))
|
|
59
|
+
|
|
60
|
+
const assocName = element._foreignKey4
|
|
61
|
+
const assoc = assocName && element.parent.elements[assocName]
|
|
62
|
+
|
|
63
|
+
if (_isContainedOrBackLink(assoc)) categories.push('@cleanup')
|
|
64
|
+
}
|
|
65
|
+
|
|
45
66
|
if (categories.length) return { categories }
|
|
46
67
|
}
|
|
47
68
|
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -46,7 +46,7 @@ module.exports = async function cds_server (options) {
|
|
|
46
46
|
if (o.index) app.get ('/',o.index) //> if none in ./app
|
|
47
47
|
|
|
48
48
|
// load and prepare models
|
|
49
|
-
const csn = await cds.load(o.from||'*',o)
|
|
49
|
+
const csn = await cds.load(o.from||'*',o)
|
|
50
50
|
cds.edmxs = cds.compile.to.edmx.files (csn)
|
|
51
51
|
cds.model = cds.compile.for.nodejs (csn)
|
|
52
52
|
|
package/lib/ql/parse.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// please keep all comments!
|
|
2
|
-
|
|
3
|
-
const cds = require('../index')
|
|
4
|
-
module.exports = {
|
|
5
|
-
column:(x) => _simple(x) /* || _parse('column',x) */ || cds.parse.column(x),
|
|
6
|
-
expr:(x) => _simple(x) /* || _parse('expr',x) */ || cds.parse.expr(x),
|
|
7
|
-
CQL: (..._) => cds.parse.CQL (..._),
|
|
8
|
-
CXL: (..._) => cds.parse.CXL (..._),
|
|
9
|
-
cql: (..._) => cds.parse.cql (..._),
|
|
10
|
-
path: (..._) => cds.parse.path (..._),
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const _simple = (x) => {
|
|
14
|
-
if (typeof x !== 'string') return {val:x}
|
|
15
|
-
const t = /^\s*([\w.'?]+)(?:\s*([!?\\/:=\-+<~>]+|like)\s*([\w.'?]+))?\s*$/.exec(x); if (!t) return
|
|
16
|
-
const [,lhs,op,rhs] = t
|
|
17
|
-
return op ? {xpr:[_rv(lhs),op,_rv(rhs)]} : _rv(lhs)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const _rv = (x) => {
|
|
21
|
-
if (x[0] === '?') return { param: true, ref: x }
|
|
22
|
-
if (x[0] === "'") return { val: x.slice(1,-1).replace(/''/g, "'") }
|
|
23
|
-
if (x === 'null') return { val: null }
|
|
24
|
-
if (x === 'true') return { val: true }
|
|
25
|
-
if (x === 'false') return { val: false }
|
|
26
|
-
if (!isNaN(x)) return { val: Number(x) }
|
|
27
|
-
else return { ref: x.split('.') }
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// const _parse = (startRule,x) => {
|
|
31
|
-
// try {
|
|
32
|
-
// return parser.parse(x,{startRule})
|
|
33
|
-
// // } catch (e) { e.message += ' in: \n' + x; throw e }
|
|
34
|
-
// } catch {/* ignored */}
|
|
35
|
-
// }
|
|
36
|
-
// const parser = require('./parser')
|
|
File without changes
|