@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.
Files changed (81) hide show
  1. package/CHANGELOG.md +54 -3
  2. package/_i18n/i18n.properties +4 -7
  3. package/eslint.config.mjs +1 -1
  4. package/lib/compile/etc/properties.js +2 -2
  5. package/lib/compile/for/java.js +15 -3
  6. package/lib/compile/for/lean_drafts.js +44 -34
  7. package/lib/compile/for/nodejs.js +19 -10
  8. package/lib/compile/minify.js +2 -4
  9. package/lib/compile/parse.js +106 -72
  10. package/lib/compile/to/edm.js +19 -9
  11. package/lib/compile/to/hana.js +25 -21
  12. package/lib/compile/to/sql.js +15 -8
  13. package/lib/core/linked-csn.js +10 -4
  14. package/lib/dbs/cds-deploy.js +2 -2
  15. package/lib/env/cds-env.js +76 -66
  16. package/lib/env/defaults.js +1 -0
  17. package/lib/i18n/bundles.js +2 -1
  18. package/lib/i18n/localize.js +2 -2
  19. package/lib/index.js +24 -18
  20. package/lib/ql/CREATE.js +11 -6
  21. package/lib/ql/DELETE.js +12 -9
  22. package/lib/ql/DROP.js +15 -8
  23. package/lib/ql/INSERT.js +19 -14
  24. package/lib/ql/SELECT.js +95 -168
  25. package/lib/ql/UPDATE.js +23 -14
  26. package/lib/ql/UPSERT.js +15 -2
  27. package/lib/ql/Whereable.js +44 -118
  28. package/lib/ql/cds-ql.js +222 -28
  29. package/lib/ql/{Query.js → cds.ql-Query.js} +52 -41
  30. package/lib/ql/cds.ql-predicates.js +133 -0
  31. package/lib/ql/cds.ql-projections.js +111 -0
  32. package/lib/ql/cqn.d.ts +146 -0
  33. package/lib/srv/cds-connect.js +3 -3
  34. package/lib/srv/cds-serve.js +2 -2
  35. package/lib/srv/cds.Service.js +132 -0
  36. package/lib/srv/{srv-api.js → cds.ServiceClient.js} +16 -71
  37. package/lib/srv/cds.ServiceProvider.js +20 -0
  38. package/lib/srv/factory.js +20 -8
  39. package/lib/srv/protocols/hcql.js +2 -3
  40. package/lib/srv/protocols/index.js +3 -3
  41. package/lib/srv/srv-dispatch.js +7 -6
  42. package/lib/srv/srv-handlers.js +103 -113
  43. package/lib/srv/srv-methods.js +14 -14
  44. package/lib/srv/srv-tx.js +5 -3
  45. package/lib/utils/cds-utils.js +2 -2
  46. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +3 -3
  47. package/libx/_runtime/cds.js +2 -1
  48. package/libx/_runtime/common/aspects/service.js +25 -0
  49. package/libx/_runtime/common/generic/auth/index.js +5 -0
  50. package/libx/_runtime/common/generic/auth/restrict.js +36 -14
  51. package/libx/_runtime/common/generic/auth/service.js +24 -0
  52. package/libx/_runtime/common/generic/auth/utils.js +14 -6
  53. package/libx/_runtime/common/generic/etag.js +1 -1
  54. package/libx/_runtime/common/utils/cqn.js +1 -2
  55. package/libx/_runtime/common/utils/cqn2cqn4sql.js +1 -1
  56. package/libx/_runtime/common/utils/generateOnCond.js +7 -3
  57. package/libx/_runtime/common/utils/postProcess.js +4 -1
  58. package/libx/_runtime/common/utils/restrictions.js +1 -0
  59. package/libx/_runtime/fiori/lean-draft.js +53 -42
  60. package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +1 -1
  61. package/libx/_runtime/remote/Service.js +2 -0
  62. package/libx/_runtime/remote/utils/client.js +12 -0
  63. package/libx/odata/ODataAdapter.js +2 -1
  64. package/libx/odata/index.js +5 -3
  65. package/libx/odata/middleware/batch.js +4 -0
  66. package/libx/odata/middleware/create.js +2 -2
  67. package/libx/odata/middleware/delete.js +2 -2
  68. package/libx/odata/middleware/operation.js +2 -2
  69. package/libx/odata/middleware/read.js +14 -12
  70. package/libx/odata/middleware/service-document.js +16 -8
  71. package/libx/odata/middleware/update.js +2 -2
  72. package/libx/odata/parse/afterburner.js +64 -30
  73. package/libx/odata/parse/grammar.peggy +95 -0
  74. package/libx/odata/parse/parser.js +1 -1
  75. package/libx/odata/utils/index.js +6 -1
  76. package/libx/odata/utils/metadata.js +69 -75
  77. package/libx/odata/utils/postProcess.js +24 -3
  78. package/package.json +1 -1
  79. package/server.js +1 -1
  80. package/lib/ql/parse.js +0 -36
  81. /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
- row.$etag = row[key].startsWith('W/') ? row[key] : `W/"${row[key]}"`
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "8.5.0",
3
+ "version": "8.6.0",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [
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) .then (cds.minify)
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