@sap/cds 5.7.5 → 5.8.2

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 (151) hide show
  1. package/CHANGELOG.md +97 -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/resolve.js +1 -1
  13. package/lib/compile/to/srvinfo.js +1 -1
  14. package/lib/core/classes.js +21 -1
  15. package/lib/env/index.js +3 -2
  16. package/lib/env/requires.js +4 -0
  17. package/lib/i18n/localize.js +5 -8
  18. package/lib/index.js +1 -0
  19. package/lib/log/errors.js +1 -1
  20. package/lib/log/format/kibana.js +3 -3
  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/ODataRequest.js +1 -3
  32. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +11 -32
  33. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +12 -5
  34. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/delete.js +7 -4
  35. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +24 -3
  36. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +43 -38
  37. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +1 -1
  38. package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +11 -5
  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 +1 -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 +17 -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/ResourcePathParser.js +23 -2
  47. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriHelper.js +7 -6
  48. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriTokenizer.js +2 -5
  49. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/PrimitiveValueDecoder.js +19 -47
  50. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/utils/ValueConverter.js +4 -11
  51. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js +7 -1
  52. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/CommandExecutor.js +0 -3
  53. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/ConditionalRequestControlCommand.js +0 -1
  54. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ContextURLFactory.js +2 -2
  55. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/ErrorJsonSerializer.js +2 -0
  56. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/serializer/TrustedResourceJsonSerializer.js +2 -5
  57. package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/validator/ConditionalRequestValidator.js +6 -6
  58. package/libx/_runtime/cds-services/adapter/odata-v4/to.js +1 -1
  59. package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +1 -4
  60. package/libx/_runtime/cds-services/adapter/odata-v4/utils/handlerUtils.js +41 -17
  61. package/libx/_runtime/cds-services/adapter/odata-v4/utils/request.js +1 -17
  62. package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +60 -18
  63. package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +47 -10
  64. package/libx/_runtime/cds-services/adapter/rest/Rest.js +22 -1
  65. package/libx/_runtime/cds-services/adapter/rest/handlers/read.js +8 -3
  66. package/libx/_runtime/cds-services/adapter/rest/utils/parse-url.js +3 -0
  67. package/libx/_runtime/cds-services/services/utils/columns.js +5 -1
  68. package/libx/_runtime/cds-services/services/utils/compareJson.js +15 -16
  69. package/libx/_runtime/cds-services/services/utils/differ.js +2 -8
  70. package/libx/_runtime/common/aspects/Association.js +16 -0
  71. package/libx/_runtime/common/composition/data.js +28 -37
  72. package/libx/_runtime/common/composition/delete.js +107 -58
  73. package/libx/_runtime/common/composition/index.js +3 -3
  74. package/libx/_runtime/common/composition/insert.js +14 -27
  75. package/libx/_runtime/common/composition/tree.js +1 -1
  76. package/libx/_runtime/common/composition/update.js +39 -34
  77. package/libx/_runtime/common/error/frontend.js +19 -5
  78. package/libx/_runtime/common/generic/auth.js +20 -85
  79. package/libx/_runtime/common/generic/crud.js +22 -1
  80. package/libx/_runtime/common/i18n/messages.properties +2 -1
  81. package/libx/_runtime/common/utils/cqn.js +2 -6
  82. package/libx/_runtime/common/utils/cqn2cqn4sql.js +95 -122
  83. package/libx/_runtime/common/utils/csn.js +29 -6
  84. package/libx/_runtime/common/utils/foreignKeyPropagations.js +21 -1
  85. package/libx/_runtime/common/utils/keys.js +2 -1
  86. package/libx/_runtime/common/utils/path.js +1 -1
  87. package/libx/_runtime/common/utils/resolveView.js +12 -4
  88. package/libx/_runtime/common/utils/rewriteAsterisks.js +27 -13
  89. package/libx/_runtime/common/utils/search2cqn4sql.js +11 -6
  90. package/libx/_runtime/common/utils/structured.js +10 -4
  91. package/libx/_runtime/common/utils/vcap.js +27 -10
  92. package/libx/_runtime/db/data-conversion/post-processing.js +20 -13
  93. package/libx/_runtime/db/expand/expand-v2.js +21 -12
  94. package/libx/_runtime/db/expand/expandCQNToJoin.js +67 -26
  95. package/libx/_runtime/db/expand/index.js +3 -0
  96. package/libx/_runtime/db/generic/create.js +0 -10
  97. package/libx/_runtime/db/generic/index.js +3 -0
  98. package/libx/_runtime/db/generic/read.js +2 -24
  99. package/libx/_runtime/db/generic/rewrite.js +1 -3
  100. package/libx/_runtime/db/generic/update.js +1 -1
  101. package/libx/_runtime/db/query/delete.js +10 -4
  102. package/libx/_runtime/db/query/insert.js +3 -4
  103. package/libx/_runtime/db/query/read.js +4 -1
  104. package/libx/_runtime/db/query/update.js +5 -5
  105. package/libx/_runtime/db/sql-builder/ExpressionBuilder.js +9 -2
  106. package/libx/_runtime/db/sql-builder/FunctionBuilder.js +3 -0
  107. package/libx/_runtime/db/sql-builder/SelectBuilder.js +7 -3
  108. package/libx/_runtime/db/sql-builder/index.js +3 -0
  109. package/libx/_runtime/db/utils/columns.js +5 -2
  110. package/libx/_runtime/db/utils/deep.js +16 -14
  111. package/libx/_runtime/db/utils/generateAliases.js +56 -6
  112. package/libx/_runtime/fiori/generic/before.js +73 -49
  113. package/libx/_runtime/fiori/generic/edit.js +14 -18
  114. package/libx/_runtime/fiori/generic/patch.js +8 -11
  115. package/libx/_runtime/fiori/generic/read.js +20 -19
  116. package/libx/_runtime/fiori/generic/readOverDraft.js +1 -4
  117. package/libx/_runtime/fiori/utils/handler.js +1 -11
  118. package/libx/_runtime/hana/Service.js +1 -1
  119. package/libx/_runtime/hana/conversion.js +12 -1
  120. package/libx/_runtime/hana/dynatrace.js +11 -5
  121. package/libx/_runtime/hana/execute.js +132 -19
  122. package/libx/_runtime/hana/search.js +3 -3
  123. package/libx/_runtime/hana/search2cqn4sql.js +23 -25
  124. package/libx/_runtime/hana/searchToContains.js +1 -1
  125. package/libx/_runtime/messaging/AMQPWebhookMessaging.js +1 -1
  126. package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +0 -1
  127. package/libx/_runtime/messaging/enterprise-messaging.js +1 -0
  128. package/libx/_runtime/messaging/file-based.js +3 -1
  129. package/libx/_runtime/messaging/service.js +4 -1
  130. package/libx/_runtime/remote/utils/client.js +41 -24
  131. package/libx/_runtime/remote/utils/data.js +54 -12
  132. package/libx/_runtime/sqlite/Service.js +1 -1
  133. package/libx/_runtime/sqlite/conversion.js +10 -0
  134. package/libx/_runtime/types/api.js +2 -2
  135. package/libx/gql/resolvers/crud/update.js +8 -5
  136. package/libx/gql/resolvers/parse/ast/enrich.js +1 -0
  137. package/libx/odata/afterburner.js +29 -6
  138. package/libx/odata/cqn2odata.js +9 -0
  139. package/libx/odata/grammar.pegjs +49 -21
  140. package/libx/odata/index.js +2 -2
  141. package/libx/odata/parser.js +1 -1
  142. package/libx/odata/utils.js +2 -2
  143. package/libx/rest/RestAdapter.js +29 -1
  144. package/libx/rest/middleware/auth.js +1 -3
  145. package/libx/rest/middleware/parse.js +1 -0
  146. package/package.json +1 -1
  147. package/server.js +1 -1
  148. package/bin/deploy/to-hana/logger.js +0 -27
  149. package/bin/deploy/to-hana/runCommand.js +0 -113
  150. package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/selectHelper.js +0 -37
  151. package/libx/_runtime/common/utils/auth.js +0 -16
@@ -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
- }