@sap/cds-compiler 3.1.0 → 3.3.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 (100) hide show
  1. package/CHANGELOG.md +90 -3
  2. package/bin/cdsc.js +1 -1
  3. package/doc/CHANGELOG_BETA.md +18 -0
  4. package/lib/api/main.js +8 -13
  5. package/lib/base/error.js +2 -2
  6. package/lib/base/keywords.js +2 -24
  7. package/lib/base/message-registry.js +43 -14
  8. package/lib/base/messages.js +20 -10
  9. package/lib/base/model.js +1 -1
  10. package/lib/checks/actionsFunctions.js +1 -1
  11. package/lib/checks/annotationsOData.js +2 -2
  12. package/lib/checks/arrayOfs.js +15 -7
  13. package/lib/checks/cdsPersistence.js +1 -1
  14. package/lib/checks/checkForTypes.js +48 -0
  15. package/lib/checks/defaultValues.js +2 -2
  16. package/lib/checks/elements.js +81 -6
  17. package/lib/checks/foreignKeys.js +12 -13
  18. package/lib/checks/invalidTarget.js +10 -11
  19. package/lib/checks/managedInType.js +21 -15
  20. package/lib/checks/nullableKeys.js +1 -1
  21. package/lib/checks/onConditions.js +9 -9
  22. package/lib/checks/parameters.js +21 -0
  23. package/lib/checks/selectItems.js +1 -1
  24. package/lib/checks/types.js +2 -2
  25. package/lib/checks/utils.js +17 -7
  26. package/lib/checks/validator.js +26 -14
  27. package/lib/compiler/assert-consistency.js +13 -6
  28. package/lib/compiler/builtins.js +8 -0
  29. package/lib/compiler/checks.js +40 -33
  30. package/lib/compiler/define.js +50 -44
  31. package/lib/compiler/extend.js +303 -37
  32. package/lib/compiler/kick-start.js +2 -35
  33. package/lib/compiler/populate.js +83 -62
  34. package/lib/compiler/propagator.js +1 -1
  35. package/lib/compiler/resolve.js +61 -104
  36. package/lib/compiler/shared.js +16 -6
  37. package/lib/compiler/tweak-assocs.js +25 -12
  38. package/lib/compiler/utils.js +2 -2
  39. package/lib/edm/annotations/genericTranslation.js +15 -5
  40. package/lib/edm/csn2edm.js +10 -10
  41. package/lib/edm/edm.js +17 -9
  42. package/lib/edm/edmPreprocessor.js +82 -42
  43. package/lib/edm/edmUtils.js +18 -16
  44. package/lib/gen/Dictionary.json +14 -0
  45. package/lib/gen/language.checksum +1 -1
  46. package/lib/gen/language.interp +3 -2
  47. package/lib/gen/languageParser.js +4205 -4100
  48. package/lib/inspect/inspectModelStatistics.js +1 -1
  49. package/lib/inspect/inspectPropagation.js +23 -9
  50. package/lib/json/csnVersion.js +1 -1
  51. package/lib/json/from-csn.js +26 -19
  52. package/lib/json/to-csn.js +47 -5
  53. package/lib/language/antlrParser.js +1 -1
  54. package/lib/language/genericAntlrParser.js +29 -13
  55. package/lib/language/language.g4 +28 -8
  56. package/lib/main.d.ts +3 -6
  57. package/lib/model/.eslintrc.json +13 -0
  58. package/lib/model/api.js +4 -2
  59. package/lib/model/csnRefs.js +74 -47
  60. package/lib/model/csnUtils.js +236 -218
  61. package/lib/model/enrichCsn.js +41 -31
  62. package/lib/model/revealInternalProperties.js +61 -57
  63. package/lib/model/sortViews.js +31 -31
  64. package/lib/modelCompare/compare.js +6 -6
  65. package/lib/optionProcessor.js +5 -0
  66. package/lib/render/manageConstraints.js +2 -2
  67. package/lib/render/toCdl.js +31 -44
  68. package/lib/render/toHdbcds.js +7 -5
  69. package/lib/render/toRename.js +4 -4
  70. package/lib/render/toSql.js +11 -5
  71. package/lib/render/utils/common.js +20 -9
  72. package/lib/render/utils/sql.js +5 -5
  73. package/lib/transform/db/applyTransformations.js +32 -3
  74. package/lib/transform/db/expansion.js +81 -37
  75. package/lib/transform/db/flattening.js +1 -1
  76. package/lib/transform/db/temporal.js +1 -1
  77. package/lib/transform/db/transformExists.js +1 -1
  78. package/lib/transform/forOdataNew.js +10 -7
  79. package/lib/transform/{forHanaNew.js → forRelationalDB.js} +7 -7
  80. package/lib/transform/localized.js +28 -19
  81. package/lib/transform/odata/toFinalBaseType.js +8 -11
  82. package/lib/transform/odata/typesExposure.js +1 -1
  83. package/lib/transform/transformUtilsNew.js +101 -39
  84. package/lib/transform/translateAssocsToJoins.js +5 -4
  85. package/lib/utils/moduleResolve.js +5 -5
  86. package/lib/utils/objectUtils.js +3 -3
  87. package/package.json +2 -2
  88. package/share/messages/anno-duplicate-unrelated-layer.md +6 -6
  89. package/share/messages/check-proper-type-of.md +4 -4
  90. package/share/messages/check-proper-type.md +2 -2
  91. package/share/messages/duplicate-autoexposed.md +4 -4
  92. package/share/messages/extend-repeated-intralayer.md +4 -5
  93. package/share/messages/extend-unrelated-layer.md +4 -4
  94. package/share/messages/message-explanations.json +3 -1
  95. package/share/messages/redirected-to-ambiguous.md +7 -6
  96. package/share/messages/redirected-to-complex.md +63 -0
  97. package/share/messages/redirected-to-unrelated.md +6 -5
  98. package/share/messages/rewrite-not-supported.md +4 -4
  99. package/share/messages/syntax-expected-integer.md +3 -3
  100. package/share/messages/wildcard-excluding-one.md +37 -0
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  const { setProp } = require('../base/model');
3
- const { isBuiltinType, isEdmPropertyRendered } = require('../model/csnUtils');
3
+ const { isBuiltinType, isEdmPropertyRendered, applyTransformations, cloneAnnotationValue } = require('../model/csnUtils');
4
4
  const { escapeString, hasControlCharacters, hasUnpairedUnicodeSurrogate } = require("../render/utils/stringEscapes");
5
5
 
6
6
  /* eslint max-statements-per-line:off */
@@ -508,6 +508,10 @@ function mapCdsToEdmType(csn, messageFunctions, isV2=false, isMediaType=false, l
508
508
  'cds.hana.SMALLDECIMAL': 'Edm.Decimal', // V4: Scale="floating" Precision="16"
509
509
  'cds.Integer64': 'Edm.Int64',
510
510
  'cds.Integer': 'Edm.Int32',
511
+ 'cds.Int64': 'Edm.Int64',
512
+ 'cds.Int32': 'Edm.Int32',
513
+ 'cds.Int16': 'Edm.Int16',
514
+ 'cds.UInt8': 'Edm.Byte',
511
515
  'cds.hana.SMALLINT': 'Edm.Int16',
512
516
  'cds.hana.TINYINT': 'Edm.Byte',
513
517
  'cds.Double': 'Edm.Double',
@@ -753,24 +757,24 @@ function resolveOriginAssoc(csn, env, path) {
753
757
  return env;
754
758
  }
755
759
 
756
- function mergeIntoNavPropRestrictions(annoPrefix, assocPath, props, navPropRestrictions) {
757
- let navPropEntry;
758
- let hasEntry = false;
760
+ function mergeIntoNavPropEntry(annoPrefix, navPropEntry, prefix, props) {
759
761
  let newEntry = false;
760
- hasEntry = !!(navPropEntry = navPropRestrictions.find(p =>
761
- p.NavigationProperty && p.NavigationProperty['='] === assocPath));
762
762
 
763
- if(!hasEntry) {
764
- navPropEntry = { NavigationProperty: { '=': assocPath } };
765
- }
766
-
767
- const prop = annoPrefix.split('.')[1];
768
763
  // Filter properties with prefix and reduce them into a new dictionary
769
764
  const o = props.filter(p => p[0].startsWith(annoPrefix+'.')).reduce((a,c) => {
770
- a[c[0].replace(annoPrefix+'.', '')] = c[1];
765
+ // clone the annotation value to avoid side effects with rewritten paths
766
+ a[c[0].replace(annoPrefix+'.', '')] = cloneAnnotationValue(c[1]);
771
767
  return a;
772
768
  }, { });
769
+
770
+ // BEFORE merging found capabilities, prefix the paths
771
+ applyTransformations({ definitions: { o }}, {
772
+ "=": (parent, prop, value) => {
773
+ parent[prop] = prefix.concat(value).join('.');
774
+ }
775
+ });
773
776
  // don't overwrite existing restrictions
777
+ const prop = annoPrefix.split('.')[1];
774
778
  if(!navPropEntry[prop]) {
775
779
  // if dictionary has entries, add them to navPropEnty
776
780
  if(Object.keys(o).length) {
@@ -807,9 +811,7 @@ function mergeIntoNavPropRestrictions(annoPrefix, assocPath, props, navPropRestr
807
811
  navPropEntry[prop][k] = v;
808
812
  });
809
813
  }
810
- if(newEntry && !hasEntry) {
811
- navPropRestrictions.push(navPropEntry);
812
- }
814
+ return newEntry;
813
815
  }
814
816
 
815
817
  // Assign but not overwrite annotation
@@ -854,5 +856,5 @@ module.exports = {
854
856
  escapeStringForText,
855
857
  getSchemaPrefix,
856
858
  getBaseName,
857
- mergeIntoNavPropRestrictions
859
+ mergeIntoNavPropEntry
858
860
  }
@@ -1808,6 +1808,13 @@
1808
1808
  "Parameter"
1809
1809
  ]
1810
1810
  },
1811
+ "UI.IsCopyAction": {
1812
+ "Type": "Core.Tag",
1813
+ "AppliesTo": [
1814
+ "Record"
1815
+ ],
1816
+ "$experimental": true
1817
+ },
1811
1818
  "UI.CreateHidden": {
1812
1819
  "Type": "Core.Tag",
1813
1820
  "AppliesTo": [
@@ -1897,6 +1904,13 @@
1897
1904
  ],
1898
1905
  "$experimental": true
1899
1906
  },
1907
+ "UI.LeadingEntitySet": {
1908
+ "Type": "Edm.String",
1909
+ "AppliesTo": [
1910
+ "EntityContainer"
1911
+ ],
1912
+ "$experimental": true
1913
+ },
1900
1914
  "Validation.Pattern": {
1901
1915
  "Type": "Edm.String",
1902
1916
  "AppliesTo": [
@@ -1 +1 @@
1
- 2067e213918678e2d85713a46e69d9cc
1
+ d054015b5c1bda3f92422cb3f44733bb