@sap/cds 9.4.4 → 9.5.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 (56) hide show
  1. package/CHANGELOG.md +81 -1
  2. package/_i18n/messages_en_US_saptrc.properties +1 -1
  3. package/common.cds +5 -2
  4. package/lib/compile/cds-compile.js +1 -0
  5. package/lib/compile/for/assert.js +64 -0
  6. package/lib/compile/for/flows.js +194 -58
  7. package/lib/compile/for/lean_drafts.js +75 -7
  8. package/lib/compile/parse.js +1 -1
  9. package/lib/compile/to/csn.js +6 -2
  10. package/lib/compile/to/edm.js +1 -1
  11. package/lib/compile/to/yaml.js +8 -1
  12. package/lib/dbs/cds-deploy.js +2 -2
  13. package/lib/env/cds-env.js +14 -4
  14. package/lib/env/defaults.js +6 -1
  15. package/lib/i18n/localize.js +1 -1
  16. package/lib/index.js +7 -7
  17. package/lib/req/event.js +4 -0
  18. package/lib/req/validate.js +4 -1
  19. package/lib/srv/cds.Service.js +2 -1
  20. package/lib/srv/middlewares/auth/ias-auth.js +5 -7
  21. package/lib/srv/middlewares/auth/index.js +1 -1
  22. package/lib/srv/protocols/index.js +7 -6
  23. package/lib/srv/srv-handlers.js +7 -0
  24. package/libx/_runtime/common/Service.js +5 -1
  25. package/libx/_runtime/common/constants/events.js +1 -0
  26. package/libx/_runtime/common/generic/assert.js +220 -0
  27. package/libx/_runtime/common/generic/flows.js +168 -108
  28. package/libx/_runtime/common/generic/input.js +6 -4
  29. package/libx/_runtime/common/utils/cqn.js +0 -24
  30. package/libx/_runtime/common/utils/normalizeTimestamp.js +2 -2
  31. package/libx/_runtime/common/utils/resolveView.js +8 -2
  32. package/libx/_runtime/common/utils/templateProcessor.js +10 -1
  33. package/libx/_runtime/common/utils/templateProcessorPathSerializer.js +21 -9
  34. package/libx/_runtime/fiori/lean-draft.js +511 -379
  35. package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +39 -35
  36. package/libx/_runtime/messaging/enterprise-messaging.js +2 -2
  37. package/libx/_runtime/remote/Service.js +4 -5
  38. package/libx/_runtime/ucl/Service.js +111 -15
  39. package/libx/common/utils/streaming.js +1 -1
  40. package/libx/odata/middleware/batch.js +8 -6
  41. package/libx/odata/middleware/create.js +2 -2
  42. package/libx/odata/middleware/delete.js +2 -2
  43. package/libx/odata/middleware/metadata.js +18 -11
  44. package/libx/odata/middleware/read.js +2 -2
  45. package/libx/odata/middleware/service-document.js +1 -1
  46. package/libx/odata/middleware/update.js +1 -1
  47. package/libx/odata/parse/afterburner.js +46 -36
  48. package/libx/odata/parse/cqn2odata.js +2 -6
  49. package/libx/odata/parse/grammar.peggy +91 -13
  50. package/libx/odata/parse/parser.js +1 -1
  51. package/libx/odata/utils/index.js +2 -2
  52. package/libx/odata/utils/readAfterWrite.js +2 -0
  53. package/libx/queue/TaskRunner.js +26 -1
  54. package/libx/queue/index.js +11 -1
  55. package/package.json +1 -1
  56. package/srv/ucl-service.cds +2 -0
@@ -45,14 +45,23 @@ const _processComplex = (processFn, row, template, key, pathOptions) => {
45
45
  if (rows.length === 0) return
46
46
  const keyNames = pathOptions.includeKeyValues && _getTargetKeyNames(template.target)
47
47
 
48
+ let rowIndex = -1
48
49
  for (const row of rows) {
50
+ rowIndex++
49
51
  if (row == null) continue
50
52
  const args = { processFn, data: row, template, isRoot: false, pathOptions }
51
53
 
52
54
  let pathSegmentInfo
53
55
  if (pathOptions.includeKeyValues) {
54
56
  pathOptions.rowUUIDGenerator?.(keyNames, row, template)
55
- pathSegmentInfo = { key, keyNames, row, elements: template.target.elements, draftKeys: pathOptions.draftKeys }
57
+ pathSegmentInfo = {
58
+ key,
59
+ keyNames,
60
+ row,
61
+ rowIndex,
62
+ elements: template.target.elements,
63
+ draftKeys: pathOptions.draftKeys
64
+ }
56
65
  }
57
66
 
58
67
  if (pathOptions.pathSegmentsInfo) pathOptions.pathSegmentsInfo.push(pathSegmentInfo || key)
@@ -1,24 +1,30 @@
1
- const segmentSerializer = pathSegmentInfo => {
1
+ const segmentKeySerializer = pathSegmentInfo => {
2
2
  const { key: tKey, row, elements, draftKeys } = pathSegmentInfo
3
3
  let keyNames = pathSegmentInfo.keyNames
4
4
 
5
5
  const keyValuePairs = keyNames
6
6
  .map(key => {
7
- let quote
7
+ const keyValue = row[key] ?? draftKeys?.[key]
8
+ if (keyValue == null) return
9
+
10
+ let formattedValue
8
11
 
9
12
  switch (elements[key].type) {
10
13
  case 'cds.String':
11
- quote = "'"
14
+ formattedValue = `'${keyValue}'`
15
+ break
16
+
17
+ case 'cds.Binary':
18
+ if (Buffer.isBuffer(keyValue)) formattedValue = keyValue.toString('base64')
19
+ formattedValue = `binary'${formattedValue}'`
12
20
  break
13
21
 
14
22
  default:
15
- quote = ''
23
+ formattedValue = keyValue
16
24
  break
17
25
  }
18
26
 
19
- const keyValue = row[key] ?? draftKeys?.[key]
20
- if (keyValue == null) return
21
- return `${key}=${quote}${keyValue}${quote}`
27
+ return `${key}=${formattedValue}`
22
28
  })
23
29
  .filter(c => c)
24
30
 
@@ -27,10 +33,16 @@ const segmentSerializer = pathSegmentInfo => {
27
33
  return pathSegment
28
34
  }
29
35
 
30
- const templatePathSerializer = (elementName, pathSegmentsInfo) => {
36
+ const segmentIndexSerializer = pathSegmentInfo => {
37
+ const { key: tKey, rowIndex } = pathSegmentInfo
38
+ return `${tKey}[${rowIndex}]`
39
+ }
40
+
41
+ const templatePathSerializer = (elementName, pathSegmentsInfo, serializeWithIndices = false) => {
31
42
  const pathSegments = pathSegmentsInfo.map(pathSegmentInfo => {
32
43
  if (typeof pathSegmentInfo === 'string') return pathSegmentInfo
33
- return segmentSerializer(pathSegmentInfo)
44
+ if (serializeWithIndices) return segmentIndexSerializer(pathSegmentInfo)
45
+ return segmentKeySerializer(pathSegmentInfo)
34
46
  })
35
47
  const path = `${pathSegments.join('/')}${pathSegments.length ? '/' : ''}${elementName}`
36
48
  return path