@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.
- package/CHANGELOG.md +241 -1
- package/bin/.eslintrc.json +17 -0
- package/bin/cds_update_identifiers.js +8 -7
- package/bin/cdsc.js +180 -132
- package/bin/cdshi.js +18 -11
- package/bin/cdsse.js +38 -32
- package/bin/cdsv2m.js +8 -7
- package/doc/CHANGELOG_BETA.md +36 -1
- package/lib/api/main.js +81 -100
- package/lib/api/options.js +17 -11
- package/lib/api/validate.js +12 -8
- package/lib/backends.js +0 -81
- package/lib/base/keywords.js +32 -2
- package/lib/base/location.js +2 -2
- package/lib/base/message-registry.js +66 -4
- package/lib/base/messages.js +84 -27
- package/lib/base/model.js +2 -61
- package/lib/checks/arrayOfs.js +0 -1
- package/lib/checks/defaultValues.js +27 -2
- package/lib/checks/elements.js +1 -6
- package/lib/checks/enricher.js +8 -2
- package/lib/checks/foreignKeys.js +0 -6
- package/lib/checks/managedWithoutKeys.js +17 -0
- package/lib/checks/nonexpandableStructured.js +38 -0
- package/lib/checks/onConditions.js +9 -45
- package/lib/checks/queryNoDbArtifacts.js +27 -9
- package/lib/checks/selectItems.js +25 -2
- package/lib/checks/types.js +26 -2
- package/lib/checks/unknownMagic.js +38 -0
- package/lib/checks/utils.js +61 -0
- package/lib/checks/validator.js +66 -13
- package/lib/compiler/assert-consistency.js +24 -12
- package/lib/compiler/builtins.js +2 -0
- package/lib/compiler/checks.js +6 -4
- package/lib/compiler/definer.js +101 -39
- package/lib/compiler/index.js +88 -59
- package/lib/compiler/resolver.js +455 -209
- package/lib/compiler/shared.js +57 -33
- package/lib/edm/annotations/genericTranslation.js +183 -187
- package/lib/edm/csn2edm.js +128 -99
- package/lib/edm/edm.js +18 -21
- package/lib/edm/edmPreprocessor.js +361 -127
- package/lib/edm/edmUtils.js +103 -33
- package/lib/gen/Dictionary.json +74 -28
- package/lib/gen/language.checksum +1 -1
- package/lib/gen/language.interp +18 -4
- package/lib/gen/language.tokens +124 -118
- package/lib/gen/languageLexer.interp +13 -1
- package/lib/gen/languageLexer.js +870 -839
- package/lib/gen/languageLexer.tokens +116 -111
- package/lib/gen/languageParser.js +5894 -5614
- package/lib/json/from-csn.js +152 -67
- package/lib/json/to-csn.js +334 -135
- package/lib/language/antlrParser.js +4 -3
- package/lib/language/errorStrategy.js +1 -0
- package/lib/language/genericAntlrParser.js +24 -14
- package/lib/language/language.g4 +188 -128
- package/lib/main.d.ts +435 -0
- package/lib/main.js +31 -7
- package/lib/model/api.js +78 -0
- package/lib/model/csnRefs.js +463 -187
- package/lib/model/csnUtils.js +280 -136
- package/lib/model/enrichCsn.js +75 -4
- package/lib/model/revealInternalProperties.js +2 -1
- package/lib/modelCompare/compare.js +70 -25
- package/lib/optionProcessor.js +13 -10
- package/lib/render/.eslintrc.json +4 -1
- package/lib/render/DuplicateChecker.js +8 -5
- package/lib/render/toCdl.js +123 -40
- package/lib/render/toHdbcds.js +156 -65
- package/lib/render/toSql.js +87 -11
- package/lib/render/utils/common.js +55 -9
- package/lib/render/utils/sql.js +3 -3
- package/lib/sql-identifier.js +6 -1
- package/lib/transform/{sql → db}/.eslintrc.json +0 -0
- package/lib/transform/{sql → db}/assertUnique.js +7 -8
- package/lib/transform/{sql → db}/constraints.js +35 -20
- package/lib/transform/db/draft.js +353 -0
- package/lib/transform/db/expansion.js +582 -0
- package/lib/transform/db/flattening.js +325 -0
- package/lib/transform/{sql → db}/groupByOrderBy.js +8 -16
- package/lib/transform/{sql → db}/helpers.js +0 -0
- package/lib/transform/{sql → db}/transformExists.js +256 -60
- package/lib/transform/forHanaNew.js +216 -765
- package/lib/transform/forOdataNew.js +60 -56
- package/lib/transform/localized.js +48 -26
- package/lib/transform/odata/attachPath.js +19 -4
- package/lib/transform/odata/expandStructKeysInAssociations.js +2 -2
- package/lib/transform/odata/generateForeignKeyElements.js +13 -12
- package/lib/transform/odata/referenceFlattener.js +60 -36
- package/lib/transform/odata/sortByAssociationDependency.js +4 -4
- package/lib/transform/odata/structuralPath.js +76 -0
- package/lib/transform/odata/structureFlattener.js +21 -22
- package/lib/transform/odata/toFinalBaseType.js +5 -5
- package/lib/transform/odata/typesExposure.js +27 -17
- package/lib/transform/odata/utils.js +2 -2
- package/lib/transform/transformUtilsNew.js +141 -77
- package/lib/transform/translateAssocsToJoins.js +17 -14
- package/lib/transform/universalCsnEnricher.js +67 -0
- package/lib/utils/file.js +0 -11
- package/lib/utils/moduleResolve.js +6 -8
- package/lib/utils/timetrace.js +6 -1
- package/package.json +2 -1
- package/lib/base/deepCopy.js +0 -66
- package/lib/json/walker.js +0 -26
- package/lib/utils/string.js +0 -17
package/lib/base/deepCopy.js
DELETED
|
@@ -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;
|
package/lib/json/walker.js
DELETED
|
@@ -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
|
-
}
|
package/lib/utils/string.js
DELETED
|
@@ -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
|
-
};
|