@sap/cds 5.7.2 → 5.8.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 (148) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/app/fiori/routes.js +1 -1
  3. package/bin/deploy/to-hana/cfUtil.js +251 -138
  4. package/bin/deploy/to-hana/gitUtil.js +55 -0
  5. package/bin/deploy/to-hana/hana.js +92 -93
  6. package/bin/deploy/to-hana/hdiDeployUtil.js +42 -27
  7. package/bin/deploy/to-hana/index.js +14 -13
  8. package/bin/mtx/in-cds.js +1 -0
  9. package/bin/serve.js +1 -1
  10. package/bin/version.js +1 -0
  11. package/lib/compile/cdsc.js +0 -6
  12. package/lib/compile/minify.js +1 -1
  13. package/lib/compile/resolve.js +1 -1
  14. package/lib/compile/to/srvinfo.js +1 -1
  15. package/lib/core/classes.js +21 -1
  16. package/lib/env/index.js +3 -2
  17. package/lib/env/requires.js +4 -0
  18. package/lib/i18n/localize.js +5 -8
  19. package/lib/index.js +1 -0
  20. package/lib/log/errors.js +1 -1
  21. package/lib/ql/SELECT.js +2 -2
  22. package/lib/req/cds-context.js +1 -1
  23. package/lib/req/context.js +1 -1
  24. package/lib/serve/Transaction.js +9 -5
  25. package/lib/serve/index.js +13 -21
  26. package/lib/utils/tests.js +90 -66
  27. package/libx/_runtime/audit/generic/personal/modification.js +0 -8
  28. package/libx/_runtime/auth/index.js +7 -6
  29. package/libx/_runtime/auth/strategies/dwc.js +43 -0
  30. package/libx/_runtime/auth/utils.js +24 -0
  31. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +11 -38
  32. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +12 -5
  33. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/delete.js +7 -4
  34. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +24 -3
  35. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +43 -42
  36. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +1 -1
  37. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +11 -5
  38. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +18 -8
  39. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/boundToCQN.js +1 -2
  40. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/deleteToCQN.js +0 -1
  41. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/expandToCQN.js +7 -2
  42. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/orderByToCQN.js +9 -0
  43. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +21 -30
  44. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/utils.js +12 -1
  45. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/edm/AbstractEdmStructuredType.js +2 -1
  46. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriHelper.js +7 -6
  47. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriTokenizer.js +5 -8
  48. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/PrimitiveValueDecoder.js +19 -47
  49. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/ValueConverter.js +4 -11
  50. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js +7 -1
  51. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/CommandExecutor.js +0 -3
  52. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ConditionalRequestControlCommand.js +0 -1
  53. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ContextURLFactory.js +1 -1
  54. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/TrustedResourceJsonSerializer.js +2 -5
  55. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/ConditionalRequestValidator.js +6 -6
  56. package/libx/_runtime/cds-services/adapter/odata-v4/to.js +1 -1
  57. package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +18 -5
  58. package/libx/_runtime/cds-services/adapter/odata-v4/utils/handlerUtils.js +41 -17
  59. package/libx/_runtime/cds-services/adapter/odata-v4/utils/request.js +1 -17
  60. package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +80 -21
  61. package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +7 -5
  62. package/libx/_runtime/cds-services/adapter/rest/Rest.js +22 -1
  63. package/libx/_runtime/cds-services/adapter/rest/handlers/read.js +8 -3
  64. package/libx/_runtime/cds-services/adapter/rest/utils/parse-url.js +3 -0
  65. package/libx/_runtime/cds-services/services/Service.js +1 -1
  66. package/libx/_runtime/cds-services/services/utils/columns.js +5 -1
  67. package/libx/_runtime/cds-services/services/utils/compareJson.js +15 -16
  68. package/libx/_runtime/cds-services/services/utils/differ.js +2 -8
  69. package/libx/_runtime/common/aspects/Association.js +16 -0
  70. package/libx/_runtime/common/composition/data.js +28 -37
  71. package/libx/_runtime/common/composition/delete.js +107 -58
  72. package/libx/_runtime/common/composition/index.js +2 -1
  73. package/libx/_runtime/common/composition/insert.js +13 -13
  74. package/libx/_runtime/common/composition/update.js +39 -34
  75. package/libx/_runtime/common/error/frontend.js +17 -2
  76. package/libx/_runtime/common/generic/auth.js +20 -85
  77. package/libx/_runtime/common/generic/crud.js +22 -1
  78. package/libx/_runtime/common/i18n/messages.properties +3 -0
  79. package/libx/_runtime/common/utils/cqn.js +2 -6
  80. package/libx/_runtime/common/utils/cqn2cqn4sql.js +97 -123
  81. package/libx/_runtime/common/utils/csn.js +14 -3
  82. package/libx/_runtime/common/utils/foreignKeyPropagations.js +18 -1
  83. package/libx/_runtime/common/utils/keys.js +2 -1
  84. package/libx/_runtime/common/utils/path.js +1 -1
  85. package/libx/_runtime/common/utils/resolveView.js +12 -4
  86. package/libx/_runtime/common/utils/rewriteAsterisks.js +27 -13
  87. package/libx/_runtime/common/utils/search2cqn4sql.js +11 -6
  88. package/libx/_runtime/common/utils/structured.js +1 -1
  89. package/libx/_runtime/common/utils/vcap.js +27 -10
  90. package/libx/_runtime/db/data-conversion/post-processing.js +42 -35
  91. package/libx/_runtime/db/expand/expand-v2.js +21 -12
  92. package/libx/_runtime/db/expand/expandCQNToJoin.js +27 -29
  93. package/libx/_runtime/db/expand/index.js +3 -0
  94. package/libx/_runtime/db/generic/create.js +0 -10
  95. package/libx/_runtime/db/generic/index.js +3 -0
  96. package/libx/_runtime/db/generic/read.js +2 -24
  97. package/libx/_runtime/db/generic/rewrite.js +1 -3
  98. package/libx/_runtime/db/generic/update.js +1 -1
  99. package/libx/_runtime/db/query/delete.js +10 -4
  100. package/libx/_runtime/db/query/insert.js +3 -3
  101. package/libx/_runtime/db/query/read.js +15 -8
  102. package/libx/_runtime/db/query/update.js +5 -5
  103. package/libx/_runtime/db/sql-builder/ExpressionBuilder.js +9 -2
  104. package/libx/_runtime/db/sql-builder/FunctionBuilder.js +3 -0
  105. package/libx/_runtime/db/sql-builder/index.js +3 -0
  106. package/libx/_runtime/db/utils/columns.js +5 -2
  107. package/libx/_runtime/db/utils/deep.js +6 -8
  108. package/libx/_runtime/db/utils/generateAliases.js +56 -6
  109. package/libx/_runtime/fiori/generic/before.js +73 -49
  110. package/libx/_runtime/fiori/generic/edit.js +14 -18
  111. package/libx/_runtime/fiori/generic/patch.js +8 -11
  112. package/libx/_runtime/fiori/generic/read.js +22 -17
  113. package/libx/_runtime/fiori/generic/readOverDraft.js +1 -4
  114. package/libx/_runtime/hana/Service.js +1 -1
  115. package/libx/_runtime/hana/conversion.js +10 -0
  116. package/libx/_runtime/hana/execute.js +33 -16
  117. package/libx/_runtime/hana/localized.js +1 -1
  118. package/libx/_runtime/hana/search.js +3 -3
  119. package/libx/_runtime/hana/search2cqn4sql.js +22 -21
  120. package/libx/_runtime/hana/searchToContains.js +1 -1
  121. package/libx/_runtime/messaging/AMQPWebhookMessaging.js +4 -2
  122. package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +0 -1
  123. package/libx/_runtime/messaging/enterprise-messaging.js +1 -0
  124. package/libx/_runtime/messaging/file-based.js +3 -1
  125. package/libx/_runtime/messaging/message-queuing-utils/options-messaging.js +1 -0
  126. package/libx/_runtime/messaging/service.js +16 -7
  127. package/libx/_runtime/remote/utils/client.js +33 -20
  128. package/libx/_runtime/remote/utils/data.js +53 -12
  129. package/libx/_runtime/sqlite/Service.js +1 -1
  130. package/libx/_runtime/sqlite/conversion.js +10 -0
  131. package/libx/_runtime/sqlite/localized.js +1 -1
  132. package/libx/_runtime/types/api.js +2 -2
  133. package/libx/gql/resolvers/parse/ast/enrich.js +1 -0
  134. package/libx/odata/afterburner.js +29 -6
  135. package/libx/odata/cqn2odata.js +9 -0
  136. package/libx/odata/grammar.pegjs +101 -45
  137. package/libx/odata/index.js +7 -1
  138. package/libx/odata/parser.js +1 -1
  139. package/libx/odata/utils.js +2 -2
  140. package/libx/rest/RestAdapter.js +29 -1
  141. package/libx/rest/middleware/auth.js +1 -3
  142. package/libx/rest/middleware/parse.js +1 -0
  143. package/package.json +1 -1
  144. package/server.js +1 -1
  145. package/bin/deploy/to-hana/logger.js +0 -27
  146. package/bin/deploy/to-hana/runCommand.js +0 -113
  147. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/selectHelper.js +0 -37
  148. package/libx/_runtime/common/utils/auth.js +0 -16
@@ -35,6 +35,7 @@ module.exports = (req, res, next) => {
35
35
 
36
36
  // query based on method
37
37
  switch (req.method) {
38
+ case 'HEAD':
38
39
  case 'GET':
39
40
  if (operation) {
40
41
  // function
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "5.7.2",
3
+ "version": "5.8.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
@@ -92,7 +92,7 @@ const defaults = {
92
92
  get logger() {
93
93
  const LOG = cds.log(), DEBUG = cds.debug('server')
94
94
  return (req,_,next) => {
95
- LOG && LOG (req.method, decodeURI(req.url))
95
+ LOG && LOG (req.method, decodeURI(req.url), req.body||'')
96
96
  if (/\$batch/.test(req.url)) req.on ('dispatch', (req) => {
97
97
  LOG && LOG ('>', req.event, decodeURI(req._path), req._query||'')
98
98
  if (DEBUG && req.query) DEBUG (req.query)
@@ -1,27 +0,0 @@
1
- module.exports = {
2
-
3
- defaultLogger: {
4
- ...console,
5
- isTTY: () => {
6
- return process.stdout.isTTY;
7
- },
8
- write: (message, clearLine) => {
9
- if (clearLine && process.stdout.isTTY) {
10
- process.stdout.clearLine(); // clear the line
11
- process.stdout.cursorTo(0); // move cursor to begin of line
12
- }
13
- process.stdout.write(message);
14
- }
15
- },
16
-
17
- nullLogger: {
18
- log: () => { },
19
- error: () => { },
20
- debug: () => { },
21
- warn: () => { },
22
- write: () => { },
23
- time: () => { },
24
- timeEnd: () => { },
25
- isTTY: () => { }
26
- }
27
- }
@@ -1,113 +0,0 @@
1
- module.exports = runCommand;
2
-
3
- const cp = require('child_process');
4
- const { nullLogger } = require('./logger');
5
- const term = require('../../utils/term');
6
-
7
- const IS_DEBUG = process.env.DEBUG;
8
- const TIMEOUT = 2 * 60 * 1000; // 2min
9
-
10
- function _removeColorCodes(chunk) {
11
- // eslint-disable-next-line no-control-regex
12
- return chunk.replace(/\x1b\[[;\d]*m/g, '');
13
- }
14
-
15
- // start kill timer, reset everytime a chunk arrives
16
- function _startTimer(oldTimer, spawnedProcess, timeOut) {
17
- clearTimeout(oldTimer);
18
-
19
- return setTimeout(() => {
20
- spawnedProcess.kill();
21
- }, timeOut);
22
- }
23
-
24
- function _getTimeKey(cmd, args = []) {
25
- return `[cds.deploy] - ${cmd} ${args.join(' ')}`;
26
- }
27
-
28
- function _validate(cmd, cmdArgs = []) {
29
- // validate input
30
- if (/[|&;]+/g.exec(cmd)) {
31
- throw new Error(`[cds.deploy] - Command ${cmd} contains at least one bad character (|, &, or ;) which might be used to concatenate commands.`);
32
- }
33
-
34
- cmdArgs.forEach((arg) => {
35
- if (/[|&;]+/g.exec(arg)) {
36
- throw new Error(`[cds.deploy] - Argument ${arg} contains at least one bad character (|, &, or ;) which might be used to concatenate commands.`);
37
- }
38
- });
39
- }
40
-
41
- function runCommand(cmd, cmdArgs = [], logger = nullLogger, options = {}, timeOut = TIMEOUT) {
42
-
43
- _validate(cmd, cmdArgs);
44
-
45
- return new Promise((resolve, reject) => {
46
-
47
- try {
48
-
49
- if (IS_DEBUG) {
50
- logger.time(_getTimeKey(cmd, cmdArgs));
51
- }
52
-
53
- logger.log();
54
- logger.log(`[cds.deploy] - Running '${term.as(term.codes.bold, cmd + ' ' + cmdArgs.join(' '))}' with options ${JSON.stringify(options)}`);
55
-
56
- const spawnOptions = { ...options, cwd: process.env._TEST_CWD || process.cwd() };
57
- spawnOptions.env = Object.assign (process.env, {CF_COLOR:logger.isTTY()}, options.env)
58
-
59
- const spawnedProcess = cp.spawn(cmd, cmdArgs, spawnOptions);
60
- let spawnTimer = _startTimer(null, spawnedProcess, timeOut);
61
-
62
- let stdout = '';
63
- let stderr = '';
64
-
65
- if (!options.stdio) {
66
- spawnedProcess.stdout.on('data', (data) => {
67
- spawnTimer = _startTimer(spawnTimer, spawnedProcess, timeOut);
68
- const chunk = data.toString();
69
- stdout = stdout + chunk;
70
- logger.write(chunk);
71
- });
72
-
73
- spawnedProcess.stderr.on('data', (data) => {
74
- spawnTimer = _startTimer(spawnTimer, spawnedProcess, timeOut);
75
- const chunk = data.toString();
76
- stderr = stderr + chunk;
77
- logger.write(chunk);
78
- });
79
- }
80
-
81
- spawnedProcess.on('error', (err) => {
82
- reject(err);
83
- });
84
-
85
- spawnedProcess.on('close', (code, signal) => {
86
- clearTimeout(spawnTimer);
87
-
88
- if (IS_DEBUG) {
89
- logger.timeEnd(_getTimeKey(cmd, cmdArgs));
90
- }
91
-
92
- if (!signal) {
93
- // exited normally
94
- stdout = _removeColorCodes(stdout);
95
- stderr = _removeColorCodes(stderr);
96
- resolve({ code, stdout, stderr });
97
- } else {
98
- // sigterm if timer kills spawned process
99
- const spawnError = new Error(`[cds.deploy] - Failed with signal '${signal}' and code ${code}`);
100
- spawnError.args = cmdArgs;
101
- spawnError.options = options;
102
- spawnError.stdout = stdout;
103
- spawnError.stderr = stderr;
104
- spawnError.signal = signal;
105
- reject(spawnError);
106
- }
107
- });
108
- } catch (err) {
109
- reject(err);
110
- }
111
-
112
- });
113
- }
@@ -1,37 +0,0 @@
1
- const { getFeatureNotSupportedError } = require('../../../util/errors')
2
- const { deepCopyArray } = require('../../../../common/utils/copy')
3
- const cds = require('../../../../cds')
4
- const { cqn2cqn4sql } = require('../../../../common/utils/cqn2cqn4sql')
5
-
6
- const isNavigation = pathSegments => {
7
- return pathSegments.length > 1 && pathSegments[1].getKind().startsWith('NAVIGATION')
8
- }
9
-
10
- const isViewWithParams = target => {
11
- return target.params && Object.keys(target.params).length > 0
12
- }
13
-
14
- const getValidationQuery = (ref, model) => {
15
- const refQuery = deepCopyArray(ref.slice(0, ref.length - 1))
16
- const cqn = cds.ql.SELECT.from({ ref: refQuery }).columns({
17
- val: 1,
18
- as: 'validationQuery'
19
- })
20
-
21
- return cqn2cqn4sql(cqn, model)
22
- }
23
-
24
- const isPathSupported = (supported, pathSegments) => {
25
- for (const segment of pathSegments) {
26
- if (!supported[segment.getKind()]) {
27
- throw getFeatureNotSupportedError(`Request parameter "${segment.getKind()}"`)
28
- }
29
- }
30
- }
31
-
32
- module.exports = {
33
- isNavigation,
34
- isViewWithParams,
35
- isPathSupported,
36
- getValidationQuery
37
- }
@@ -1,16 +0,0 @@
1
- const UNAUTHORIZED = { statusCode: 401, code: '401', message: 'Unauthorized' }
2
- const FORBIDDEN = { statusCode: 403, code: '403', message: 'Forbidden' }
3
-
4
- const getRequiresAsArray = definition => {
5
- if (!definition['@requires']) {
6
- return []
7
- }
8
-
9
- return Array.isArray(definition['@requires']) ? definition['@requires'] : [definition['@requires']]
10
- }
11
-
12
- module.exports = {
13
- UNAUTHORIZED,
14
- FORBIDDEN,
15
- getRequiresAsArray
16
- }