@sap/cds-compiler 4.5.0 → 4.6.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 (65) hide show
  1. package/CHANGELOG.md +50 -7
  2. package/bin/cdsc.js +13 -11
  3. package/doc/CHANGELOG_BETA.md +6 -0
  4. package/lib/api/main.js +256 -115
  5. package/lib/api/options.js +8 -0
  6. package/lib/base/message-registry.js +17 -4
  7. package/lib/base/messages.js +15 -3
  8. package/lib/base/model.js +1 -0
  9. package/lib/base/optionProcessorHelper.js +45 -176
  10. package/lib/checks/elements.js +32 -34
  11. package/lib/checks/enricher.js +39 -3
  12. package/lib/checks/validator.js +2 -3
  13. package/lib/compiler/assert-consistency.js +2 -1
  14. package/lib/compiler/builtins.js +20 -4
  15. package/lib/compiler/checks.js +30 -6
  16. package/lib/compiler/define.js +31 -9
  17. package/lib/compiler/populate.js +5 -1
  18. package/lib/compiler/resolve.js +26 -21
  19. package/lib/compiler/shared.js +19 -9
  20. package/lib/compiler/tweak-assocs.js +82 -107
  21. package/lib/compiler/utils.js +2 -1
  22. package/lib/edm/annotations/edmJson.js +23 -22
  23. package/lib/edm/annotations/genericTranslation.js +14 -4
  24. package/lib/edm/csn2edm.js +24 -10
  25. package/lib/edm/edmInboundChecks.js +1 -2
  26. package/lib/edm/edmPreprocessor.js +11 -9
  27. package/lib/edm/edmUtils.js +5 -2
  28. package/lib/gen/Dictionary.json +3 -1
  29. package/lib/gen/language.checksum +1 -1
  30. package/lib/gen/language.interp +4 -1
  31. package/lib/gen/language.tokens +1 -0
  32. package/lib/gen/languageParser.js +5253 -5214
  33. package/lib/json/to-csn.js +7 -1
  34. package/lib/language/antlrParser.js +19 -1
  35. package/lib/language/errorStrategy.js +21 -4
  36. package/lib/language/genericAntlrParser.js +9 -11
  37. package/lib/main.d.ts +28 -3
  38. package/lib/main.js +3 -0
  39. package/lib/model/csnRefs.js +4 -1
  40. package/lib/model/csnUtils.js +12 -7
  41. package/lib/optionProcessor.js +21 -19
  42. package/lib/render/manageConstraints.js +13 -29
  43. package/lib/render/toCdl.js +18 -15
  44. package/lib/render/toHdbcds.js +59 -28
  45. package/lib/render/toRename.js +6 -10
  46. package/lib/render/toSql.js +57 -82
  47. package/lib/render/utils/common.js +17 -0
  48. package/lib/transform/.eslintrc.json +9 -1
  49. package/lib/transform/addTenantFields.js +228 -0
  50. package/lib/transform/db/applyTransformations.js +27 -31
  51. package/lib/transform/db/assertUnique.js +4 -4
  52. package/lib/transform/db/cdsPersistence.js +1 -1
  53. package/lib/transform/db/flattening.js +68 -69
  54. package/lib/transform/db/temporal.js +1 -1
  55. package/lib/transform/draft/db.js +2 -16
  56. package/lib/transform/draft/odata.js +3 -3
  57. package/lib/transform/effective/associations.js +3 -5
  58. package/lib/transform/effective/main.js +6 -9
  59. package/lib/transform/forOdata.js +13 -9
  60. package/lib/transform/forRelationalDB.js +36 -17
  61. package/lib/transform/odata/toFinalBaseType.js +3 -3
  62. package/lib/transform/odata/typesExposure.js +14 -5
  63. package/lib/transform/transformUtils.js +47 -34
  64. package/lib/transform/translateAssocsToJoins.js +33 -8
  65. package/package.json +2 -2
@@ -5,7 +5,7 @@ const { setProp, isDeprecatedEnabled, isBetaEnabled } = require('../base/model')
5
5
  const {
6
6
  forEachDefinition, forEachGeneric, forEachMemberRecursively,
7
7
  isEdmPropertyRendered, getUtils, cloneCsnNonDict,
8
- isBuiltinType, applyTransformations, cloneAnnotationValue, cardinality2str,
8
+ isBuiltinType, applyTransformations, cloneAnnotationValue, cardinality2str, isAnnotationExpression,
9
9
  } = require('../model/csnUtils');
10
10
  const edmUtils = require('./edmUtils.js');
11
11
  const edmAnnoPreproc = require('./edmAnnoPreprocessor.js');
@@ -97,7 +97,7 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
97
97
  */
98
98
  if (csn.meta && csn.meta.options && csn.meta.options.odataVersion === 'v4' && options.isV2()) {
99
99
  // eslint-disable-next-line global-require
100
- const { toFinalBaseType } = require('../transform/transformUtils').getTransformers(csn, options);
100
+ const { toFinalBaseType } = require('../transform/transformUtils').getTransformers(csn, options, messageFunctions);
101
101
  expandCSNToFinalBaseType(csn, { toFinalBaseType }, csnUtils, serviceRootNames, options);
102
102
  }
103
103
 
@@ -721,11 +721,11 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
721
721
  // FK creation.
722
722
  // The FK creation already propagates the annotations from the association
723
723
  const elements = construct.items && construct.items.elements || construct.elements;
724
- const fk = elements[element['@odata.foreignKey4']];
725
- for (const attrName in fk) {
726
- const attr = fk[attrName];
727
- if (attrName[0] === '@')
728
- edmUtils.assignAnnotation(element, attrName, attr);
724
+ const assoc = elements[element['@odata.foreignKey4']];
725
+ if (assoc) {
726
+ Object.keys(assoc).filter(pn => pn[0] === '@' && !isAnnotationExpression(assoc[pn])).forEach((pn) => {
727
+ edmUtils.assignAnnotation(element, pn, assoc[pn]);
728
+ });
729
729
  }
730
730
  // and eventually remove some afterwards
731
731
  if (options.isV2())
@@ -1074,8 +1074,10 @@ function initializeModel( csn, _options, messageFunctions, requestedServiceNames
1074
1074
 
1075
1075
  function muteNavProp( elt, msg = 'std' ) {
1076
1076
  edmUtils.assignAnnotation(elt, '@odata.navigable', false);
1077
- warning('odata-navigation', [ 'definitions', struct.name, 'elements', elt.name ],
1078
- { target: elt._target.name, service: globalSchemaPrefix, '#': msg });
1077
+ if (elt._target['@cds.autoexpose'] !== false) {
1078
+ warning('odata-navigation', [ 'definitions', struct.name, 'elements', elt.name ],
1079
+ { target: elt._target.name, service: globalSchemaPrefix, '#': msg });
1080
+ }
1079
1081
  }
1080
1082
 
1081
1083
  function createSchemaRefFor( targetSchemaName ) {
@@ -551,8 +551,11 @@ function mapCdsToEdmType( csn, messageFunctions, isV2 = false, isMediaType = fal
551
551
  Edm.GeometryCollection
552
552
  */
553
553
  }[cdsType];
554
- if (!edmType)
555
- error(null, location, { type: cdsType }, 'No EDM type available for $(TYPE)');
554
+ if (!edmType) {
555
+ error('ref-unsupported-type', location, { type: cdsType, '#': 'odata' });
556
+ edmType = 'Edm.PrimitiveType';
557
+ }
558
+
556
559
 
557
560
  if (isV2) {
558
561
  if (edmType === 'Edm.Date')
@@ -2076,6 +2076,8 @@
2076
2076
  "Type": "Validation.ConstraintType",
2077
2077
  "AppliesTo": [
2078
2078
  "Property",
2079
+ "NavigationProperty",
2080
+ "Parameter",
2079
2081
  "EntityType",
2080
2082
  "ComplexType"
2081
2083
  ]
@@ -2688,7 +2690,7 @@
2688
2690
  "Capabilities.PermissionType": {
2689
2691
  "$kind": "ComplexType",
2690
2692
  "Properties": {
2691
- "SchemeName": "Auth.SchemeName",
2693
+ "SchemeName": "Authorization.SchemeName",
2692
2694
  "Scopes": "Collection(Capabilities.ScopeType)"
2693
2695
  }
2694
2696
  },
@@ -1 +1 @@
1
- 942cce045e6fb6ecaf7cbf3039001aa9
1
+ 99b88c455f59a02a22d3d2ee662b8136