@sap/cds-compiler 2.4.4 → 2.10.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 (106) hide show
  1. package/CHANGELOG.md +241 -1
  2. package/bin/.eslintrc.json +17 -0
  3. package/bin/cds_update_identifiers.js +8 -7
  4. package/bin/cdsc.js +180 -132
  5. package/bin/cdshi.js +18 -11
  6. package/bin/cdsse.js +38 -32
  7. package/bin/cdsv2m.js +8 -7
  8. package/doc/CHANGELOG_BETA.md +36 -1
  9. package/lib/api/main.js +81 -100
  10. package/lib/api/options.js +17 -11
  11. package/lib/api/validate.js +12 -8
  12. package/lib/backends.js +0 -81
  13. package/lib/base/keywords.js +32 -2
  14. package/lib/base/location.js +2 -2
  15. package/lib/base/message-registry.js +66 -4
  16. package/lib/base/messages.js +84 -27
  17. package/lib/base/model.js +2 -61
  18. package/lib/checks/arrayOfs.js +0 -1
  19. package/lib/checks/defaultValues.js +27 -2
  20. package/lib/checks/elements.js +1 -6
  21. package/lib/checks/enricher.js +8 -2
  22. package/lib/checks/foreignKeys.js +0 -6
  23. package/lib/checks/managedWithoutKeys.js +17 -0
  24. package/lib/checks/nonexpandableStructured.js +38 -0
  25. package/lib/checks/onConditions.js +9 -45
  26. package/lib/checks/queryNoDbArtifacts.js +27 -9
  27. package/lib/checks/selectItems.js +25 -2
  28. package/lib/checks/types.js +26 -2
  29. package/lib/checks/unknownMagic.js +38 -0
  30. package/lib/checks/utils.js +61 -0
  31. package/lib/checks/validator.js +66 -13
  32. package/lib/compiler/assert-consistency.js +24 -12
  33. package/lib/compiler/builtins.js +2 -0
  34. package/lib/compiler/checks.js +6 -4
  35. package/lib/compiler/definer.js +101 -39
  36. package/lib/compiler/index.js +88 -59
  37. package/lib/compiler/resolver.js +455 -209
  38. package/lib/compiler/shared.js +57 -33
  39. package/lib/edm/annotations/genericTranslation.js +183 -187
  40. package/lib/edm/csn2edm.js +128 -99
  41. package/lib/edm/edm.js +18 -21
  42. package/lib/edm/edmPreprocessor.js +361 -127
  43. package/lib/edm/edmUtils.js +103 -33
  44. package/lib/gen/Dictionary.json +74 -28
  45. package/lib/gen/language.checksum +1 -1
  46. package/lib/gen/language.interp +18 -4
  47. package/lib/gen/language.tokens +124 -118
  48. package/lib/gen/languageLexer.interp +13 -1
  49. package/lib/gen/languageLexer.js +870 -839
  50. package/lib/gen/languageLexer.tokens +116 -111
  51. package/lib/gen/languageParser.js +5894 -5614
  52. package/lib/json/from-csn.js +152 -67
  53. package/lib/json/to-csn.js +334 -135
  54. package/lib/language/antlrParser.js +4 -3
  55. package/lib/language/errorStrategy.js +1 -0
  56. package/lib/language/genericAntlrParser.js +24 -14
  57. package/lib/language/language.g4 +188 -128
  58. package/lib/main.d.ts +435 -0
  59. package/lib/main.js +31 -7
  60. package/lib/model/api.js +78 -0
  61. package/lib/model/csnRefs.js +463 -187
  62. package/lib/model/csnUtils.js +280 -136
  63. package/lib/model/enrichCsn.js +75 -4
  64. package/lib/model/revealInternalProperties.js +2 -1
  65. package/lib/modelCompare/compare.js +70 -25
  66. package/lib/optionProcessor.js +13 -10
  67. package/lib/render/.eslintrc.json +4 -1
  68. package/lib/render/DuplicateChecker.js +8 -5
  69. package/lib/render/toCdl.js +123 -40
  70. package/lib/render/toHdbcds.js +156 -65
  71. package/lib/render/toSql.js +87 -11
  72. package/lib/render/utils/common.js +55 -9
  73. package/lib/render/utils/sql.js +3 -3
  74. package/lib/sql-identifier.js +6 -1
  75. package/lib/transform/{sql → db}/.eslintrc.json +0 -0
  76. package/lib/transform/{sql → db}/assertUnique.js +7 -8
  77. package/lib/transform/{sql → db}/constraints.js +35 -20
  78. package/lib/transform/db/draft.js +353 -0
  79. package/lib/transform/db/expansion.js +582 -0
  80. package/lib/transform/db/flattening.js +325 -0
  81. package/lib/transform/{sql → db}/groupByOrderBy.js +8 -16
  82. package/lib/transform/{sql → db}/helpers.js +0 -0
  83. package/lib/transform/{sql → db}/transformExists.js +256 -60
  84. package/lib/transform/forHanaNew.js +216 -765
  85. package/lib/transform/forOdataNew.js +60 -56
  86. package/lib/transform/localized.js +48 -26
  87. package/lib/transform/odata/attachPath.js +19 -4
  88. package/lib/transform/odata/expandStructKeysInAssociations.js +2 -2
  89. package/lib/transform/odata/generateForeignKeyElements.js +13 -12
  90. package/lib/transform/odata/referenceFlattener.js +60 -36
  91. package/lib/transform/odata/sortByAssociationDependency.js +4 -4
  92. package/lib/transform/odata/structuralPath.js +76 -0
  93. package/lib/transform/odata/structureFlattener.js +21 -22
  94. package/lib/transform/odata/toFinalBaseType.js +5 -5
  95. package/lib/transform/odata/typesExposure.js +27 -17
  96. package/lib/transform/odata/utils.js +2 -2
  97. package/lib/transform/transformUtilsNew.js +141 -77
  98. package/lib/transform/translateAssocsToJoins.js +17 -14
  99. package/lib/transform/universalCsnEnricher.js +67 -0
  100. package/lib/utils/file.js +0 -11
  101. package/lib/utils/moduleResolve.js +6 -8
  102. package/lib/utils/timetrace.js +6 -1
  103. package/package.json +2 -1
  104. package/lib/base/deepCopy.js +0 -66
  105. package/lib/json/walker.js +0 -26
  106. package/lib/utils/string.js +0 -17
@@ -1,66 +0,0 @@
1
- // Deep copy an object structure
2
- // This makes a deep copy of the transitive closure of an object. It works on any objects and properties,
3
- // enumerable or not. Be careful with functions that contain state, since there will be no clone of the
4
- // internal state of a function.
5
- // An example is the alert property of a model. It may be instantiated with an array of alert messages
6
- // kept in the model itself, so after cloning the model you will have two alert message arrays, but alert still
7
- // points to the alert messages in the original model. You have to re-instantiate alert in the clone to refer
8
- // to the cloned messages.
9
- // In order not to forget such functions that would still alter the original model it's advised to freeze the
10
- // original model (see deepFreeze)
11
-
12
- function deepCopy(obj) {
13
- let map = new WeakMap();
14
- let copyStack = [];
15
- let result = copy(obj);
16
-
17
- while (copyStack.length) {
18
- let entry = copyStack.pop();
19
- let {src, target, prop} = entry;
20
- // copy element
21
- let newObj = copy(src[prop]);
22
-
23
- // store reference to copy in target property
24
- let desc = (src && typeof src === 'object') ? Object.getOwnPropertyDescriptor(src, prop) : null;
25
- if (desc && desc.enumerable === false && desc.get === undefined && desc.set === undefined) {
26
- desc.value = newObj;
27
- if (!(prop in target)) // shudder, also used for arrays
28
- Object.defineProperty(target, prop, desc);
29
- } else {
30
- target[prop] = newObj;
31
- }
32
- }
33
- return result;
34
-
35
- function copy(obj) {
36
- let newObj;
37
- if (typeof obj !== 'object' || obj === null) // return primitive type, note that typeof null === 'object'
38
- return obj;
39
- if (map.has(obj))
40
- return map.get(obj);
41
- if (Array.isArray(obj))
42
- newObj = [];
43
- else if (obj.constructor) // important for classes, else prototype chain for inheritance will not be correct
44
- newObj = new obj.constructor()
45
- else if (!Object.getPrototypeOf(obj))
46
- newObj = Object.create(null); // dictionary
47
- else
48
- newObj = {};
49
- map.set(obj, newObj);
50
- // loop over all properties and add them to copyStack
51
- // in reverse order to keep same order in copied object
52
- let propertiesToPush = [];
53
- for (let propName of Object.getOwnPropertyNames(obj)) { // we clone only own properties, not inherited one's
54
- if (propName === 'location' && Object.getPrototypeOf(obj)) {
55
- // performance optimization: only link location instead of copying the object
56
- newObj.location = obj.location;
57
- } else {
58
- propertiesToPush.push({ src: obj, prop: propName, target: newObj });
59
- }
60
- }
61
- copyStack.push(...propertiesToPush.reverse());
62
- return newObj;
63
- }
64
- }
65
-
66
- module.exports = deepCopy;
@@ -1,26 +0,0 @@
1
- /**
2
- * Walker module provides non-recursive tree walkers with different flavours
3
- * @module json/walker
4
- */
5
-
6
- /**
7
- * Callback of the forEach function called for each node it walks
8
- * @callback forEachCallback
9
- * @param {string} name of the node
10
- * @param {object} node
11
- */
12
-
13
- /**
14
- * Loops over all elements in an object and calls the specified callback(key,obj)
15
- * @param {object} obj
16
- * @param {forEachCallback} callback
17
- */
18
- function forEach(obj, callback) {
19
- for(var key in obj) {
20
- callback(key, obj[key]);
21
- }
22
- }
23
-
24
- module.exports = {
25
- forEach,
26
- }
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- // String utils
4
-
5
- /**
6
- * Removes duplicate entries from the given string array.
7
- *
8
- * @param {string[]} strings Array of strings with duplicates
9
- * @returns {string[]} strings New array with unique strings
10
- */
11
- function uniqueStrings(strings) {
12
- return [ ...new Set(strings) ];
13
- }
14
-
15
- module.exports = {
16
- uniqueStrings,
17
- };