@sap/cds-dk 6.7.1 → 6.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 (123) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/bin/deploy/index.js +1 -1
  3. package/bin/import.js +5 -3
  4. package/bin/login.js +29 -9
  5. package/bin/migrate.js +6 -2
  6. package/bin/watch.js +16 -0
  7. package/lib/bind/bindingUtil.js +2 -2
  8. package/lib/bind/userCdsrcJsonStorageProvider.js +1 -1
  9. package/lib/client/auth_manager.js +3 -1
  10. package/lib/client/helper/errors.js +6 -1
  11. package/lib/client/params.js +22 -20
  12. package/lib/client/settings_manager.js +17 -3
  13. package/lib/compile/openapi/csdl2openapi.js +4 -1
  14. package/lib/import/asyncapi/importAsyncAPI.js +32 -0
  15. package/lib/import/asyncapi/index.js +15 -0
  16. package/lib/import/asyncapi/parserContext.js +351 -0
  17. package/lib/import/asyncapi/utils.js +18 -0
  18. package/lib/import/common.js +21 -67
  19. package/lib/import/importapi.js +23 -2
  20. package/lib/import/message.js +11 -1
  21. package/lib/import/odata/index.js +14 -11
  22. package/lib/import/odata/metadataconverter/MetadataConverter.js +35 -35
  23. package/lib/import/odata/util/MultiMap.js +5 -5
  24. package/lib/import/odata/v2parser.js +1 -0
  25. package/lib/import/odata/v4parser.js +1281 -1139
  26. package/lib/init/constants.js +10 -3
  27. package/lib/init/template/_merging/registry-mta.js +33 -36
  28. package/lib/init/template/approuter/files/mtxs-configmap-java.yaml +20 -0
  29. package/lib/init/template/approuter/files/mtxs-configmap-nodejs.yaml +12 -0
  30. package/lib/init/template/approuter/index.js +24 -33
  31. package/lib/init/template/auditlog/files/package.json.hbs +27 -0
  32. package/lib/init/template/auditlog/index.js +12 -6
  33. package/lib/init/template/cf-manifest/index.js +1 -1
  34. package/lib/init/template/connectivity/index.js +1 -1
  35. package/lib/init/template/destinations/index.js +4 -2
  36. package/lib/init/template/enterprise-messaging/files/package.json.hbs +19 -0
  37. package/lib/init/template/enterprise-messaging/index.js +15 -13
  38. package/lib/init/template/enterprise-messaging-shared/files/event-mesh.json.hbs +31 -0
  39. package/lib/init/template/enterprise-messaging-shared/files/mta.yaml.hbs +15 -0
  40. package/lib/init/template/enterprise-messaging-shared/files/package.json.hbs +22 -0
  41. package/lib/init/template/enterprise-messaging-shared/files/values.yaml +7 -0
  42. package/lib/init/template/enterprise-messaging-shared/index.js +51 -0
  43. package/lib/init/template/extensibility/files/package.json.hbs +20 -0
  44. package/lib/init/template/extensibility/index.js +4 -16
  45. package/lib/init/template/file-based-messaging/files/package.json.hbs +19 -0
  46. package/lib/init/template/file-based-messaging/index.js +25 -0
  47. package/lib/init/template/hana/files/package.json.hbs +33 -0
  48. package/lib/init/template/hana/index.js +38 -65
  49. package/lib/init/template/helm/chart/templates/_deployment_helpers.tpl +0 -12
  50. package/lib/init/template/helm/chart/templates/_helpers.tpl +1 -121
  51. package/lib/init/template/helm/index.js +1 -1
  52. package/lib/init/template/html5-repo/index.js +1 -1
  53. package/lib/init/template/java/index.js +2 -2
  54. package/lib/init/template/kibana-logging/files/package.json.hbs +17 -0
  55. package/lib/init/template/kibana-logging/index.js +6 -19
  56. package/lib/init/template/lint/index.js +1 -1
  57. package/lib/init/template/mta/index.js +2 -2
  58. package/lib/init/template/multitenancy/files/mtxs-configmap-java.yaml +3 -5
  59. package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs.yaml +3 -10
  60. package/lib/init/template/multitenancy/files/package.json.hbs +5 -4
  61. package/lib/init/template/multitenancy/index.js +22 -19
  62. package/lib/init/template/nodejs/files/.vscode/launch.json +11 -3
  63. package/lib/init/template/nodejs/index.js +1 -1
  64. package/lib/init/template/pipeline/index.js +1 -1
  65. package/lib/init/template/redis-messaging/files/mta.yaml.hbs +14 -0
  66. package/lib/init/template/redis-messaging/files/package.json.hbs +22 -0
  67. package/lib/init/template/redis-messaging/index.js +50 -0
  68. package/lib/init/template/samples/index.js +3 -3
  69. package/lib/init/template/sqlite/files/package.json.hbs +12 -4
  70. package/lib/init/template/sqlite/index.js +5 -1
  71. package/lib/init/template/toggles/files/package.json.hbs +20 -0
  72. package/lib/init/template/toggles/index.js +3 -9
  73. package/lib/init/template/xsuaa/files/package.json.hbs +28 -0
  74. package/lib/init/template/xsuaa/index.js +8 -23
  75. package/lib/init/util/{md5Tracking.js → md5.js} +1 -1
  76. package/lib/init/util/merge.js +4 -9
  77. package/lib/init/util/{mvnArchetypeUtil.js → mvn.js} +3 -0
  78. package/lib/init/util/projectReader.js +25 -107
  79. package/lib/init/util/xml.js +56 -0
  80. package/lib/lint/checks.js +1 -1
  81. package/lib/lint/io.js +1 -1
  82. package/lib/{init/util/commandUtil.js → util/command.js} +4 -2
  83. package/lib/{init/util/fsUtil.js → util/fs.js} +2 -2
  84. package/npm-shrinkwrap.json +335 -2212
  85. package/package.json +5 -4
  86. package/lib/init/template/approuter/files/cds.cdsrc.json +0 -7
  87. package/lib/init/template/approuter/files/cds.cdsrc.json.hbs +0 -9
  88. package/lib/init/template/approuter/files/cds.package.json +0 -9
  89. package/lib/init/template/approuter/files/cds.package.json.hbs +0 -11
  90. package/lib/init/template/auditlog/files/dependencies.package.json +0 -5
  91. package/lib/init/template/enterprise-messaging/files/cds.package.json +0 -9
  92. package/lib/init/template/enterprise-messaging/files/cds.profile.package.json.hbs +0 -11
  93. package/lib/init/template/enterprise-messaging/files/cdsrc.json +0 -7
  94. package/lib/init/template/enterprise-messaging/files/cdsrc.json.hbs +0 -9
  95. package/lib/init/template/extensibility/files/cds.package.json +0 -7
  96. package/lib/init/template/extensibility/files/cds.package.json.hbs +0 -9
  97. package/lib/init/template/extensibility/files/cdsrc.json +0 -5
  98. package/lib/init/template/extensibility/files/cdsrc.json.hbs +0 -7
  99. package/lib/init/template/hana/files/java/cds.json.hbs +0 -7
  100. package/lib/init/template/hana/files/java/cds.profile.json.hbs +0 -12
  101. package/lib/init/template/hana/files/java/cds.shortcut.json.hbs +0 -5
  102. package/lib/init/template/hana/files/java/cds.shortcut.profile.json.hbs +0 -8
  103. package/lib/init/template/hana/files/nodejs/cds.json.hbs +0 -9
  104. package/lib/init/template/hana/files/nodejs/cds.profile.json.hbs +0 -14
  105. package/lib/init/template/hana/files/nodejs/cds.shortcut.json.hbs +0 -7
  106. package/lib/init/template/hana/files/nodejs/cds.shortcut.profile.json.hbs +0 -10
  107. package/lib/init/template/hana/files/nodejs/dependencies.package.json +0 -5
  108. package/lib/init/template/helm/chart/templates/_sapcp_helpers.tpl +0 -103
  109. package/lib/init/template/kibana-logging/files/cds.profile.package.json.hbs +0 -9
  110. package/lib/init/template/toggles/files/cds.package.json +0 -7
  111. package/lib/init/template/toggles/files/cds.package.json.hbs +0 -9
  112. package/lib/init/template/toggles/files/cdsrc.json +0 -5
  113. package/lib/init/template/toggles/files/cdsrc.json.hbs +0 -7
  114. package/lib/init/template/xsuaa/files/cds.cdsrc.json +0 -7
  115. package/lib/init/template/xsuaa/files/cds.cdsrc.json.hbs +0 -9
  116. package/lib/init/template/xsuaa/files/cds.package.json +0 -9
  117. package/lib/init/template/xsuaa/files/cds.package.json.hbs +0 -11
  118. package/lib/init/template/xsuaa/files/dependencies.package.json +0 -6
  119. package/lib/init/util/versionCompare.js +0 -73
  120. /package/lib/init/template/hana/files/{java/db → db}/package.json +0 -0
  121. /package/lib/init/template/hana/files/{common/src → src}/.hdiconfig +0 -0
  122. /package/lib/init/template/hana/files/{common/undeploy.json → undeploy.json} +0 -0
  123. /package/lib/init/util/{templateUtil.js → template.js} +0 -0
@@ -25,13 +25,9 @@ class MetadataConverter {
25
25
  * @param {Object} options the options object
26
26
  * @memberof MetadataConverter
27
27
  */
28
- constructor(options = { omit$TypeOnEdmString: true }) {
28
+ // constructor(options = { omit$TypeOnEdmString: true }) {
29
+ constructor(options = {}) {
29
30
  this._options = options;
30
- if (options.omit$TypeOnEdmString === undefined) {
31
- // eslint-disable-next-line no-param-reassign
32
- options.omit$TypeOnEdmString = true;
33
- }
34
-
35
31
  this._conversion = {};
36
32
  }
37
33
 
@@ -114,14 +110,6 @@ class MetadataConverter {
114
110
  const strategy = this._conversion.strategy[index];
115
111
  if (strategy == null) {
116
112
  let result = input;
117
- if (this._options.omit$TypeOnEdmString === true) {
118
- result = this._filterProperties(
119
- input,
120
- (key, inputNode) => {
121
- return !(key === '$Type' && inputNode[key] === 'Edm.String' && inputNode.$Cast === undefined);
122
- }
123
- );
124
- }
125
113
  return callback(null, result, []);
126
114
  }
127
115
 
@@ -287,8 +275,12 @@ class Expression {
287
275
  if (attr.NavigationPropertyPath) {
288
276
  return { $NavigationPropertyPath: attr.NavigationPropertyPath };
289
277
  }
278
+ /**
279
+ * For entries like:
280
+ * <PropertyValue Property="Rollup" EnumMember="SAP__aggregation.RollupType/None"/>
281
+ */
290
282
  if (attr.EnumMember) {
291
- return this.convertEnumMemberExpression(attr.EnumMember);
283
+ return { "#" : this.convertEnumMemberExpression(attr.EnumMember) };
292
284
  }
293
285
  } else {
294
286
  if (attr.AnnotationPath) {
@@ -298,7 +290,7 @@ class Expression {
298
290
  if (attr.ModelElementPath) return attr.ModelElementPath;
299
291
  if (attr.NavigationPropertyPath) return attr.NavigationPropertyPath;
300
292
  if (attr.EnumMember) {
301
- return this.convertEnumMemberExpression(attr.EnumMember);
293
+ return { "#" : this.convertEnumMemberExpression(attr.EnumMember) };
302
294
  }
303
295
  }
304
296
 
@@ -579,7 +571,6 @@ class Expression {
579
571
  const nonStdAttributes = this.getNonStdAttributes(element.attributes);
580
572
  for (let i = 0; i < nonStdAttributes.length; i++) {
581
573
  let attr = nonStdAttributes[i];
582
- let check = 0;
583
574
  let [prefix, attrName] = attr.split(':');
584
575
  if (attrName)
585
576
  attrName = attrName.replace(/-/g, '.');
@@ -588,24 +579,17 @@ class Expression {
588
579
  attribute = "@" + prefix + "." + attrName;
589
580
  else if (attrName === undefined)
590
581
  attribute = "$" + prefix;
591
- if (attribute !== undefined && attribute.startsWith('$') === false) {
592
- Object.entries(target).forEach(a => {
593
- if (Object.keys(a[1]).length === 0 && typeof (a[1]) != 'boolean') {
594
- a[1][attribute] = element.attributes[attr];
595
- check = 1;
596
- }
597
- });
598
- if (check == 0)
599
- target[attribute] = element.attributes[attr];
582
+ if (attribute !== undefined && !attribute.startsWith('$')) {
583
+ target[attribute] = element.attributes[attr];
600
584
  }
601
585
  }
602
586
  }
603
587
 
604
588
  getNonStdAttributes(attributes) {
605
589
  const attributeList = [];
606
- const standardArrtibutes = ['MaxLength', 'Precision', 'Scale', 'Nullable', 'DefaultValue',
607
- 'Name', 'Type', 'HasStream', 'IsFlags', 'Alias', 'Namespace', 'BaseType', 'Partner',
608
- 'IsComposable', 'ContainsTarget', 'IsBound', 'EntitySet', 'EntitySetPath', 'EntityType'];
590
+ const standardArrtibutes = ['MaxLength', 'Precision', 'Scale', 'Nullable', 'DefaultValue', 'Name',
591
+ 'Type', 'HasStream', 'IsFlags', 'Alias', 'Namespace', 'BaseType', 'Partner', 'IsComposable',
592
+ 'ContainsTarget', 'IsBound', 'EntitySet', 'EntitySetPath', 'EntityType', 'UnderlyingType'];
609
593
  attributeList.push(...Object.keys(attributes).filter(attribute => standardArrtibutes.indexOf(attribute) === -1));
610
594
  return attributeList;
611
595
  }
@@ -960,9 +944,8 @@ class Context extends Emitter {
960
944
  if (typeof metadata === 'string') {
961
945
  metadataAst = this._strategy.getASTFactory()(metadata);
962
946
  }
963
- return new MetadataConverter({
964
- omit$TypeOnEdmString: false
965
- }).addConversion([
947
+
948
+ return new MetadataConverter({}).addConversion([
966
949
  MetadataConverter.createOdataV4MetadataXmlToOdataV4CsdlStrategy()
967
950
  .setASTFactory(this._strategy.getASTFactory())
968
951
  .setXmlNodeFactory(this._strategy.getXmlNodeFactory())
@@ -1378,7 +1361,11 @@ class FloatExpression extends Expression {
1378
1361
  class EnumMemberExpression extends Expression {
1379
1362
  constructor(element, expression, context) { super(element, expression, context); }
1380
1363
  interpret() {
1381
- const target = this.convertEnumMemberExpression(this.getElement().elements[0].text);
1364
+ /**
1365
+ * For entries like:
1366
+ * <EnumMember>Org.OData.Core.V1.RevisionKind/Deprecated</EnumMember>
1367
+ */
1368
+ const target = { "#" : this.convertEnumMemberExpression(this.getElement().elements[0].text) };
1382
1369
  this.setTarget(target);
1383
1370
  super.interpret();
1384
1371
  return target;
@@ -1540,7 +1527,8 @@ class CollectionExpression extends Expression {
1540
1527
  .forEach((result) => {
1541
1528
  target.push(result);
1542
1529
  });
1543
-
1530
+ // we might have to revisit this scenario when records/collection are empty
1531
+ // return (target.length === 0) ? null : target;
1544
1532
  return target;
1545
1533
  }
1546
1534
  }
@@ -1661,7 +1649,8 @@ class RecordExpression extends Expression {
1661
1649
  Object.assign(target, interpretation);
1662
1650
  }
1663
1651
  });
1664
-
1652
+ // we might have to revisit this scenario when records/collection are empty
1653
+ // return (Object.keys(target).length === 0) ? null : target;
1665
1654
  return target;
1666
1655
  }
1667
1656
  }
@@ -1688,9 +1677,20 @@ class PropertyValueExpression extends Expression {
1688
1677
  */
1689
1678
  if (element.attributes.Int) target[name] = Number(element.attributes.Int);
1690
1679
  if (element.attributes.Bool) target[name] = element.attributes.Bool === 'true';
1680
+ /**
1681
+ * If the property valus is of type `Date`, import it as a string itself
1682
+ * <PropertyValue Property="Date" Date="2021-08-24" />
1683
+ * We might have to have a strict check in the futore.. 'YYYY-MM_DD`
1684
+ */
1685
+ if (element.attributes.Date) target[name] = element.attributes.Date;
1691
1686
 
1692
1687
  this.getStack().forEach((expr) => {
1693
1688
  const result = expr.interpret();
1689
+ // we might have to revisit this scenario when records/collection are empty
1690
+ // if (result === null) {
1691
+ // delete target[name];
1692
+ // return;
1693
+ // }
1694
1694
  if (expr.getType() === 'CollectionExpression') {
1695
1695
  target[name] = result;
1696
1696
  } else if (typeof result === 'object') {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- /*
4
- Library for handling multiple values for same key
5
- */
3
+ /**
4
+ * Library for handling multiple values for same key
5
+ */
6
6
  var Multimap = (function () {
7
7
  var mapCtor;
8
8
  if (typeof Map !== 'undefined') {
@@ -69,8 +69,8 @@ var Multimap = (function () {
69
69
  };
70
70
 
71
71
  /**
72
- * @return {Array} all the keys in the map
73
- */
72
+ * @return {Array} all the keys in the map
73
+ */
74
74
  Multimap.prototype.keys = function () {
75
75
  if (this._map)
76
76
  return makeIterator(this._.keys());
@@ -1843,6 +1843,7 @@ function getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, conte
1843
1843
  isValid = _validateEDMX(edmx2jsonModel);
1844
1844
  if (isValid) {
1845
1845
  parserContext.serviceNamespace = _getServiceNameSpace(edmx2jsonModel);
1846
+ context.schemaNamespace = parserContext.serviceNamespace; // required for `--keep-namespace` scenario
1846
1847
  let namespaceAlias = edmx2jsonModel["edmx:Edmx"]["edmx:DataServices"].Schema._attributes.Alias;
1847
1848
  // replace the namespace alias value with original namespace value
1848
1849
  if (namespaceAlias) {