@sap/cds 6.3.2 → 6.4.1

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 (128) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/apis/cds.d.ts +3 -1
  3. package/apis/core.d.ts +118 -90
  4. package/apis/cqn.d.ts +11 -2
  5. package/apis/internal/inference.d.ts +7 -2
  6. package/apis/ql.d.ts +49 -11
  7. package/apis/serve.d.ts +8 -1
  8. package/apis/services.d.ts +311 -305
  9. package/bin/build/buildTaskEngine.js +28 -36
  10. package/bin/build/buildTaskFactory.js +32 -81
  11. package/bin/build/buildTaskHandler.js +3 -2
  12. package/bin/build/buildTaskProvider.js +2 -2
  13. package/bin/build/buildTaskProviderFactory.js +5 -14
  14. package/bin/build/constants.js +0 -1
  15. package/bin/build/provider/buildTaskHandlerEdmx.js +7 -6
  16. package/bin/build/provider/buildTaskHandlerFeatureToggles.js +6 -5
  17. package/bin/build/provider/buildTaskHandlerInternal.js +9 -30
  18. package/bin/build/provider/buildTaskProviderInternal.js +70 -58
  19. package/bin/build/provider/fiori/index.js +6 -5
  20. package/bin/build/provider/hana/2migration.js +20 -3
  21. package/bin/build/provider/hana/2tabledata.js +1 -0
  22. package/bin/build/provider/hana/index.js +40 -17
  23. package/bin/build/provider/java/index.js +10 -10
  24. package/bin/build/provider/mtx/index.js +25 -16
  25. package/bin/build/provider/mtx/resourcesTarBuilder.js +22 -27
  26. package/bin/build/provider/mtx-extension/index.js +3 -2
  27. package/bin/build/provider/mtx-sidecar/index.js +16 -15
  28. package/bin/build/provider/nodejs/index.js +14 -56
  29. package/bin/build/util.js +56 -16
  30. package/bin/deploy/to-hana/cfUtil.js +2 -0
  31. package/bin/deploy/to-hana/gitUtil.js +1 -1
  32. package/bin/deploy/to-hana/hana.js +45 -38
  33. package/bin/deploy/to-hana/hdiDeployUtil.js +17 -12
  34. package/bin/deploy/to-hana/mtaUtil.js +13 -14
  35. package/bin/mtx/in-cds.js +3 -1
  36. package/bin/serve.js +1 -1
  37. package/bin/version.js +2 -1
  38. package/lib/auth/index.js +17 -15
  39. package/lib/compile/cds-compile.js +1 -0
  40. package/lib/compile/cdsc.js +1 -0
  41. package/lib/compile/etc/_localized.js +2 -2
  42. package/lib/compile/for/lean_drafts.js +83 -0
  43. package/lib/compile/for/nodejs.js +1 -0
  44. package/lib/compile/minify.js +2 -1
  45. package/lib/compile/to/gql.js +1 -1
  46. package/lib/compile/to/sql.js +11 -1
  47. package/lib/core/entities.js +1 -1
  48. package/lib/core/index.js +9 -9
  49. package/lib/core/infer.js +1 -0
  50. package/lib/dbs/cds-deploy.js +97 -41
  51. package/lib/env/cds-env.js +9 -10
  52. package/lib/env/cds-requires.js +8 -2
  53. package/lib/env/defaults.js +0 -4
  54. package/lib/env/schemas/cds-rc.json +38 -0
  55. package/lib/ql/SELECT.js +10 -4
  56. package/lib/srv/bindings.js +1 -1
  57. package/lib/srv/factory.js +1 -1
  58. package/lib/srv/middlewares/cds-context.js +0 -2
  59. package/lib/srv/middlewares/ctx-auth.js +11 -0
  60. package/lib/srv/middlewares/ctx-model.js +22 -20
  61. package/lib/srv/middlewares/index.js +7 -9
  62. package/lib/srv/protocols/_legacy.js +4 -0
  63. package/lib/srv/protocols/graphql.js +2 -2
  64. package/lib/srv/protocols/index.js +7 -3
  65. package/lib/srv/srv-api.js +1 -0
  66. package/lib/srv/srv-methods.js +1 -1
  67. package/lib/utils/cds-utils.js +11 -0
  68. package/lib/utils/data.js +2 -2
  69. package/lib/utils/inflect.js +13 -12
  70. package/lib/utils/tar.js +43 -13
  71. package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +2 -2
  72. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +1 -1
  73. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +1 -1
  74. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/delete.js +1 -1
  75. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +1 -15
  76. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +1 -1
  77. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +1 -1
  78. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/errors/UriSyntaxError.js +1 -1
  79. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js +6 -1
  80. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/BufferedWriter.js +1 -1
  81. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/ConditionalRequestValidator.js +0 -12
  82. package/libx/_runtime/cds-services/adapter/odata-v4/utils/oDataConfiguration.js +1 -7
  83. package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +4 -0
  84. package/libx/_runtime/cds-services/services/Service.js +23 -1
  85. package/libx/_runtime/cds-services/util/assert.js +0 -41
  86. package/libx/_runtime/common/composition/data.js +5 -1
  87. package/libx/_runtime/common/generic/auth/utils.js +3 -3
  88. package/libx/_runtime/common/generic/crud.js +1 -1
  89. package/libx/_runtime/common/generic/input.js +4 -24
  90. package/libx/_runtime/common/generic/paging.js +10 -9
  91. package/libx/_runtime/common/utils/cqn2cqn4sql.js +31 -0
  92. package/libx/_runtime/common/utils/csn.js +21 -15
  93. package/libx/_runtime/common/utils/draft.js +2 -1
  94. package/libx/_runtime/common/utils/resolveView.js +27 -4
  95. package/libx/_runtime/common/utils/rewriteAsterisks.js +3 -1
  96. package/libx/_runtime/common/utils/rowUUIDGenerator.js +21 -0
  97. package/libx/_runtime/common/utils/templateProcessor.js +12 -15
  98. package/libx/_runtime/common/utils/templateProcessorPathSerializer.js +23 -0
  99. package/libx/_runtime/db/expand/expandCQNToJoin.js +29 -12
  100. package/libx/_runtime/db/generic/input.js +7 -13
  101. package/libx/_runtime/db/sql-builder/InsertBuilder.js +5 -1
  102. package/libx/_runtime/db/sql-builder/UpsertBuilder.js +24 -0
  103. package/libx/_runtime/db/sql-builder/annotations.js +6 -3
  104. package/libx/_runtime/db/sql-builder/index.js +2 -0
  105. package/libx/_runtime/db/sql-builder/sqlFactory.js +9 -0
  106. package/libx/_runtime/db/utils/columns.js +4 -2
  107. package/libx/_runtime/fiori/generic/read.js +1 -12
  108. package/libx/_runtime/fiori/lean-draft.js +657 -0
  109. package/libx/_runtime/fiori/utils/handler.js +1 -1
  110. package/libx/_runtime/hana/Service.js +1 -1
  111. package/libx/_runtime/hana/execute.js +5 -5
  112. package/libx/_runtime/hana/pool.js +16 -1
  113. package/libx/_runtime/messaging/enterprise-messaging-utils/getTenantInfo.js +2 -1
  114. package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +1 -1
  115. package/libx/_runtime/messaging/enterprise-messaging.js +2 -3
  116. package/libx/_runtime/messaging/outbox/utils.js +109 -70
  117. package/libx/_runtime/messaging/service.js +16 -7
  118. package/libx/_runtime/remote/Service.js +15 -2
  119. package/libx/_runtime/remote/utils/client.js +41 -11
  120. package/libx/_runtime/sqlite/Service.js +4 -1
  121. package/libx/_runtime/sqlite/convertDraftAdminPathExpression.js +56 -0
  122. package/libx/_runtime/sqlite/customBuilder/CustomUpsertBuilder.js +41 -0
  123. package/libx/_runtime/sqlite/customBuilder/index.js +5 -0
  124. package/libx/_runtime/sqlite/execute.js +1 -1
  125. package/libx/_runtime/types/api.js +2 -2
  126. package/libx/rest/RestAdapter.js +15 -13
  127. package/package.json +1 -1
  128. package/server.js +2 -19
@@ -22,17 +22,6 @@ const RestAdapter = function (srv) {
22
22
 
23
23
  const router = express.Router()
24
24
 
25
- // -----------------------------------------------------------------------------------------
26
- // service root
27
- router.head('/', (_, res) => res.json({}))
28
- router.get('/', (_, res) =>
29
- res.json({
30
- entities: Object.keys(srv.entities).map(e => ({ name: e, url: e }))
31
- })
32
- )
33
-
34
- // -----------------------------------------------------------------------------------------
35
-
36
25
  // pass srv-related stuff to middlewares via req
37
26
  router.use((req, res, next) => {
38
27
  req._srv = srv // FIXME: That's only because of how we organized our rest adapater code into fragmented files -> don't do that
@@ -93,6 +82,15 @@ const RestAdapter = function (srv) {
93
82
  // REVISIT: security log?
94
83
  })
95
84
 
85
+ // -----------------------------------------------------------------------------------------
86
+ // service root
87
+ router.head('/', (_, res) => res.json({}))
88
+ router.get('/', (_, res) =>
89
+ res.json({
90
+ entities: Object.keys(srv.entities).map(e => ({ name: e, url: e }))
91
+ })
92
+ )
93
+
96
94
  // -----------------------------------------------------------------------------------------
97
95
  // parse / validate
98
96
 
@@ -132,8 +130,9 @@ const RestAdapter = function (srv) {
132
130
  // begin tx
133
131
  router.use((req, res, next) => {
134
132
  // REVISIT: -> move to actual handler(s)
133
+ const tenant = req.tenant || req.user?.tenant
135
134
  // create tx and set as cds.context
136
- cds.context = srv.tx(new cds.EventContext({ user: req.user, req, res }))
135
+ cds.context = srv.tx(new cds.EventContext({ user: req.user, req, res, tenant }))
137
136
  next()
138
137
  })
139
138
 
@@ -197,7 +196,10 @@ const RestAdapter = function (srv) {
197
196
 
198
197
  next(err)
199
198
  })
200
- router.use(error) // FIXME: nope -> call next()
199
+
200
+ if (!cds.env.features.rest_error_handler) {
201
+ router.use(error) // FIXME: nope -> call next()
202
+ }
201
203
 
202
204
  return router
203
205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "6.3.2",
3
+ "version": "6.4.1",
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
@@ -47,7 +47,6 @@ module.exports = async function cds_server (options) {
47
47
  if (cds.requires.messaging) await cds.connect.to ('messaging')
48
48
 
49
49
  // serve all services declared in models
50
- if (cds.requires.middlewares) cds.middlewares.bootstrap(); else if (o.correlate) app.use (o.correlate)
51
50
  await cds.serve (o.service,o) .in (app)
52
51
  await cds.emit ('served', cds.services) //> hook for listeners
53
52
 
@@ -71,7 +70,7 @@ module.exports = async function cds_server (options) {
71
70
  //
72
71
  const defaults = {
73
72
 
74
- cors, correlate,
73
+ cors,
75
74
 
76
75
  get static() { return cds.env.folders.app }, //> defaults to ./app
77
76
 
@@ -100,7 +99,7 @@ const _app_serve = function (endpoint) { return {
100
99
  }}
101
100
 
102
101
 
103
- function cors (req, res, next) {
102
+ function cors (req, res, next) { // REVISIT: should that move into middlewares?
104
103
  const { origin } = req.headers
105
104
  if (origin) res.set('access-control-allow-origin', origin)
106
105
  if (origin && req.method === 'OPTIONS')
@@ -108,22 +107,6 @@ function cors (req, res, next) {
108
107
  next()
109
108
  }
110
109
 
111
- function correlate (req, res, next) {
112
- // derive correlation id from req
113
- const id = req.headers['x-correlation-id'] || req.headers['x-correlationid']
114
- || req.headers['x-request-id'] || req.headers['x-vcap-request-id']
115
- || cds.utils.uuid()
116
- // new intermediate cds.context, if necessary
117
- if (!cds.context) cds.context = { id }
118
- // guarantee x-correlation-id going forward and set on res
119
- req.headers['x-correlation-id'] = id
120
- res.set('X-Correlation-ID', id)
121
- // guaranteed access to cds.context._.req -> REVISIT
122
- if (!cds.context._) cds.context._ = {}
123
- if (!cds.context._.req) cds.context._.req = req
124
- next()
125
- }
126
-
127
110
  function express_static (dir) {
128
111
  return express.static (path.resolve (cds.root,dir))
129
112
  }