@sap/cds-compiler 6.9.2 → 7.0.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 (69) hide show
  1. package/CHANGELOG.md +86 -2
  2. package/bin/cdsc.js +4 -33
  3. package/doc/IncompatibleChanges_v7.md +639 -0
  4. package/lib/api/main.js +4 -56
  5. package/lib/api/options.js +6 -15
  6. package/lib/api/validate.js +1 -0
  7. package/lib/base/builtins.js +1 -2
  8. package/lib/base/csnRefs.js +2 -6
  9. package/lib/base/message-registry.js +82 -76
  10. package/lib/base/messages.js +23 -4
  11. package/lib/base/optionProcessor.js +2 -72
  12. package/lib/base/specialOptions.js +20 -17
  13. package/lib/checks/defaultValues.js +1 -39
  14. package/lib/checks/hasPersistedElements.js +19 -3
  15. package/lib/checks/parameters.js +0 -34
  16. package/lib/checks/selectItems.js +2 -38
  17. package/lib/checks/typeParameters.js +162 -0
  18. package/lib/checks/validator.js +5 -8
  19. package/lib/compiler/assert-consistency.js +19 -5
  20. package/lib/compiler/checks.js +47 -43
  21. package/lib/compiler/define.js +6 -6
  22. package/lib/compiler/extend.js +102 -111
  23. package/lib/compiler/generate.js +4 -8
  24. package/lib/compiler/populate.js +4 -7
  25. package/lib/compiler/propagator.js +9 -9
  26. package/lib/compiler/resolve.js +205 -7
  27. package/lib/compiler/shared.js +76 -82
  28. package/lib/compiler/tweak-assocs.js +102 -22
  29. package/lib/compiler/utils.js +57 -12
  30. package/lib/compiler/xpr-rewrite.js +2 -15
  31. package/lib/edm/annotations/edmJson.js +14 -10
  32. package/lib/edm/annotations/genericTranslation.js +3 -1
  33. package/lib/edm/annotations/preprocessAnnotations.js +9 -26
  34. package/lib/edm/csn2edm.js +27 -20
  35. package/lib/edm/edmUtils.js +25 -0
  36. package/lib/gen/CdlGrammar.checksum +1 -1
  37. package/lib/gen/CdlParser.js +2237 -2241
  38. package/lib/gen/Dictionary.json +17 -2
  39. package/lib/json/from-csn.js +67 -52
  40. package/lib/json/to-csn.js +28 -25
  41. package/lib/language/textUtils.js +0 -13
  42. package/lib/main.d.ts +34 -59
  43. package/lib/main.js +1 -1
  44. package/lib/model/csnUtils.js +9 -8
  45. package/lib/parsers/AstBuildingParser.js +45 -55
  46. package/lib/parsers/Lexer.js +2 -0
  47. package/lib/parsers/identifiers.js +0 -9
  48. package/lib/render/toCdl.js +41 -40
  49. package/lib/render/toSql.js +8 -1
  50. package/lib/render/utils/common.js +1 -1
  51. package/lib/render/utils/sql.js +2 -3
  52. package/lib/tool-lib/enrichCsn.js +1 -2
  53. package/lib/transform/db/applyTransformations.js +7 -5
  54. package/lib/transform/db/assertUnique.js +8 -51
  55. package/lib/transform/db/associations.js +1 -1
  56. package/lib/transform/db/cdsPersistence.js +1 -15
  57. package/lib/transform/db/expansion.js +9 -12
  58. package/lib/transform/db/flattening.js +1 -1
  59. package/lib/transform/db/groupByOrderBy.js +0 -16
  60. package/lib/transform/db/views.js +57 -161
  61. package/lib/transform/draft/db.js +2 -2
  62. package/lib/transform/forOdata.js +25 -14
  63. package/lib/transform/forRelationalDB.js +93 -301
  64. package/lib/transform/localized.js +33 -102
  65. package/lib/transform/odata/flattening.js +11 -2
  66. package/lib/transform/transformUtils.js +25 -3
  67. package/lib/transform/universalCsn/universalCsnEnricher.js +1 -2
  68. package/package.json +2 -2
  69. package/lib/render/toHdbcds.js +0 -1810
@@ -639,6 +639,30 @@ function isODataSimpleIdentifier( identifier ) {
639
639
  return identifier && identifier.match(regex);
640
640
  }
641
641
 
642
+ /**
643
+ * An OData V2 simple identifier is a Unicode character sequence with the following restrictions:
644
+ * - The first character MUST be any character in the Unicode category “Letter (L)” or “Letter number (Nl)”
645
+ * (underscore is NOT allowed as the first character, unlike V4)
646
+ * - The remaining characters MUST be any character in the Unicode category:
647
+ * “Letter (L)”,
648
+ * “Letter number (Nl)”,
649
+ * “Decimal number (Nd)”,
650
+ * “Non-spacing mark (Mn)”,
651
+ * “Combining spacing mark (Mc)”,
652
+ * “Connector punctuation (Pc)” (includes underscore U+005F),
653
+ * “Other, format (Cf)”
654
+ * - Maximum length is 480 characters
655
+ * source: CSDL 2.0 XML schema (TSimpleIdentifier pattern)
656
+ * https://learn.microsoft.com/en-us/openspecs/windows_protocols/mc-csdl/59d51c80-0cb7-4d18-80cb-ee2c3a4dcdf3
657
+ *
658
+ * @param {string} identifier
659
+ */
660
+ function isODataV2SimpleIdentifier( identifier ) {
661
+ // this regular expression reflects the specification from above
662
+ const regex = /^[\p{Letter}\p{Nl}][\p{Letter}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,479}$/gu;
663
+ return identifier && identifier.match(regex);
664
+ }
665
+
642
666
  /**
643
667
  * Escape the given string for attribute values. We follow the spec as
644
668
  * described in §2.3 <https://www.w3.org/TR/xml/#NT-AttValue>:
@@ -916,6 +940,7 @@ module.exports = {
916
940
  mapCdsToEdmType,
917
941
  addTypeFacets,
918
942
  isODataSimpleIdentifier,
943
+ isODataV2SimpleIdentifier,
919
944
  escapeStringForAttributeValue,
920
945
  escapeStringForText,
921
946
  getSchemaPrefix,
@@ -1 +1 @@
1
- 43e8ba55fd2a4f645dcbc0928d83528b
1
+ 230b7681d344570b9cdb67a5c9bb0f86