@sap/cds-dk 4.5.4 → 4.6.0
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 +20 -0
- package/bin/bind.js +124 -8
- package/bin/cds-ts.js +1 -1
- package/bin/cds.js +1 -0
- package/bin/env.js +50 -9
- package/bin/help.js +1 -0
- package/bin/import.js +34 -14
- package/bin/watch.js +25 -4
- package/lib/bind/bindingResolver.js +138 -0
- package/lib/bind/cfKeyProvider.js +353 -0
- package/lib/bind/userCdsrcJsonStorageProvider.js +144 -0
- package/lib/client/auth_manager.js +4 -4
- package/lib/client/settings_manager.js +1 -1
- package/lib/import/common.js +10 -1
- package/lib/import/importapi.js +4 -3
- package/lib/import/index.js +34 -5
- package/lib/import/message.js +1 -0
- package/lib/import/utils/MetadataConverter.js +25 -4
- package/lib/import/utils/MetadataConverterFactory.js +1 -2
- package/lib/import/utils/MultiMap.js +26 -0
- package/lib/import/v2parser.js +131 -12
- package/lib/import/v4parser.js +212 -172
- package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +36 -52
- package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/rule.test.js +15 -0
- package/lib/init/template/lint/index.js +14 -6
- package/lib/init/template/mta/files/mta.yaml.hbs +0 -7
- package/lib/init/template/mtx/files/xs-security.json.hbs +3 -1
- package/lib/init/template/mtx/package/dependencies.package.json +1 -1
- package/lib/init/template/nodejs/files/.gitignore.hbs +3 -0
- package/lib/init/util/commandUtil.js +5 -0
- package/lib/lint/Linter.js +31 -20
- package/lib/lint/checks.js +5 -1
- package/lib/lint/io.js +59 -35
- package/lib/util/term.js +2 -0
- package/lib/watch/node-watch.js +38 -19
- package/npm-shrinkwrap.json +1782 -1138
- package/package.json +3 -3
- package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/test.js +0 -10
|
@@ -396,7 +396,7 @@ class Expression {
|
|
|
396
396
|
const target = this.getTarget();
|
|
397
397
|
const element = this.getElement();
|
|
398
398
|
const attribs = element.attributes;
|
|
399
|
-
|
|
399
|
+
let custom_namespace = MetadataConverter.custom_namespace;
|
|
400
400
|
if (attribs == null) return;
|
|
401
401
|
let realType = attribs.Type || attribs.EntityType || attribs.UnderlyingType;
|
|
402
402
|
const propertyName = attribs.UnderlyingType == null ? '$Type' : '$UnderlyingType';
|
|
@@ -574,9 +574,29 @@ class Expression {
|
|
|
574
574
|
!(target.$Kind === 'NavigationProperty' && target.$Collection === true)) {
|
|
575
575
|
target.$Nullable = true;
|
|
576
576
|
}
|
|
577
|
+
const nonStdAttributes = this.getNonStdAttributes(element.attributes);
|
|
578
|
+
for (let i = 0; i < nonStdAttributes.length; i++) {
|
|
579
|
+
let attr = nonStdAttributes[i];
|
|
580
|
+
let [prefix, attrName] = attr.split(':');
|
|
581
|
+
if(attrName)
|
|
582
|
+
attrName = attrName.replace(/-/g,'.');
|
|
583
|
+
let attribute;
|
|
584
|
+
if ((custom_namespace.includes(prefix) && attrName !== undefined) || custom_namespace.includes(true))
|
|
585
|
+
attribute = "@" + prefix + "." + attrName;
|
|
586
|
+
else if (attrName === undefined)
|
|
587
|
+
attribute = "$" + prefix;
|
|
588
|
+
if (attribute !== undefined)
|
|
589
|
+
target[attribute] = element.attributes[attr];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
getNonStdAttributes(attributes) {
|
|
593
|
+
const attributeList = [];
|
|
594
|
+
const standardArrtibutes = ['MaxLength', 'Precision', 'Scale', 'Nullable', 'DefaultValue',
|
|
595
|
+
'Name', 'Type', 'HasStream', 'IsFlags', 'Alias', 'Namespace', 'BaseType', 'Partner',
|
|
596
|
+
'IsComposable', 'ContainsTarget', 'IsBound', 'EntitySet', 'EntitySetPath', 'EntityType'];
|
|
597
|
+
attributeList.push(...Object.keys(attributes).filter(attribute => standardArrtibutes.indexOf(attribute) === -1));
|
|
598
|
+
return attributeList;
|
|
577
599
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
600
|
}
|
|
581
601
|
|
|
582
602
|
class EdmPrimitiveType {
|
|
@@ -2361,7 +2381,8 @@ class OnDeleteExpression extends Expression {
|
|
|
2361
2381
|
}
|
|
2362
2382
|
|
|
2363
2383
|
|
|
2364
|
-
MetadataConverter.createOdataV4MetadataXmlToOdataV4CsdlStrategy = () => {
|
|
2384
|
+
MetadataConverter.createOdataV4MetadataXmlToOdataV4CsdlStrategy = (name_space) => {
|
|
2385
|
+
MetadataConverter.custom_namespace = name_space;
|
|
2365
2386
|
return new MetadataConverter.DefaultXmlStrategy()
|
|
2366
2387
|
.use('http://docs.oasis-open.org/odata/ns/edmx:Edmx', (element, parentExpression, context) => {
|
|
2367
2388
|
return new EdmxRootExpression(element, null, context);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
2
|
const xmljs = require('xml-js');
|
|
4
3
|
const MetadataConverterV4 = require('../utils/MetadataConverter');
|
|
5
4
|
|
|
@@ -61,7 +60,7 @@ class MetadataConverterFactory {
|
|
|
61
60
|
*
|
|
62
61
|
*/
|
|
63
62
|
static createEdmxV40XmlToV40Json(options = {}) {
|
|
64
|
-
const defaultStrategy = MetadataConverterV4.createOdataV4MetadataXmlToOdataV4CsdlStrategy();
|
|
63
|
+
const defaultStrategy = MetadataConverterV4.createOdataV4MetadataXmlToOdataV4CsdlStrategy(options);
|
|
65
64
|
|
|
66
65
|
if (options.astFactory) {
|
|
67
66
|
defaultStrategy.setASTFactory(options.astFactory);
|
|
@@ -67,6 +67,32 @@ var Multimap = (function () {
|
|
|
67
67
|
return this;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* @return {Array} all the keys in the map
|
|
72
|
+
*/
|
|
73
|
+
Multimap.prototype.keys = function () {
|
|
74
|
+
if (this._map)
|
|
75
|
+
return makeIterator(this._.keys());
|
|
76
|
+
|
|
77
|
+
return makeIterator(Object.keys(this._));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
function makeIterator(iterator) {
|
|
81
|
+
if (Array.isArray(iterator)) {
|
|
82
|
+
var nextIndex = 0;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
next: function () {
|
|
86
|
+
return nextIndex < iterator.length ?
|
|
87
|
+
{ value: iterator[nextIndex++], done: false } :
|
|
88
|
+
{ done: true };
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return iterator;
|
|
94
|
+
}
|
|
95
|
+
|
|
70
96
|
return Multimap;
|
|
71
97
|
})();
|
|
72
98
|
|
package/lib/import/v2parser.js
CHANGED
|
@@ -15,7 +15,10 @@ let allAssociations = {};
|
|
|
15
15
|
let allAssociationSets = {};
|
|
16
16
|
let allComplexTypes = {};
|
|
17
17
|
let allComplexTypeDocs = {};
|
|
18
|
+
let allComplexTypeNamespaces = {};
|
|
18
19
|
let allInheritedComplexTypes = {};
|
|
20
|
+
let allowedNamespaces = [];
|
|
21
|
+
let allowAllNamespaces = false;
|
|
19
22
|
let messages = require("./message").getMessages();
|
|
20
23
|
let common = require("./common");
|
|
21
24
|
let versionInfo = require('../../package.json').version;
|
|
@@ -57,9 +60,49 @@ function _initialize() {
|
|
|
57
60
|
allAssociationSets = {};
|
|
58
61
|
allComplexTypes = {};
|
|
59
62
|
allComplexTypeDocs = {};
|
|
63
|
+
allComplexTypeNamespaces = {};
|
|
60
64
|
allInheritedComplexTypes = {};
|
|
65
|
+
allowedNamespaces = [];
|
|
66
|
+
allowAllNamespaces = false;
|
|
61
67
|
}
|
|
62
68
|
|
|
69
|
+
// Function to extract allowed namespace attributes from given set of attributes
|
|
70
|
+
function namespaceAttributeFilter(attributes) {
|
|
71
|
+
let namespaceAttributes = allowAllNamespaces
|
|
72
|
+
? Object.keys(attributes).filter((attr) => attr.includes(':'))
|
|
73
|
+
: Object.keys(attributes).filter(
|
|
74
|
+
(attr) =>
|
|
75
|
+
attr.includes(':') &&
|
|
76
|
+
allowedNamespaces.includes(attr.split(':')[0]));
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
namespaceAttributes = namespaceAttributes.map(attribute => {
|
|
80
|
+
const index = attribute.indexOf(':');
|
|
81
|
+
let namespace = attribute.slice(0, index);
|
|
82
|
+
let name = attribute.slice(index + 1);
|
|
83
|
+
|
|
84
|
+
name = name.replace(/-/g, '.');
|
|
85
|
+
|
|
86
|
+
let formattedAttribute = {};
|
|
87
|
+
formattedAttribute[`${namespace}.${name}`] = _replaceSpecialCharacters(attributes[attribute]);
|
|
88
|
+
return formattedAttribute;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return namespaceAttributes;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//Function to generate CSN for namespace attributes
|
|
95
|
+
function _generateNamespaceAttributes(attributes, isBefore) {
|
|
96
|
+
let csn = "";
|
|
97
|
+
attributes.forEach((attr) => {
|
|
98
|
+
let key = Object.keys(attr)[0];
|
|
99
|
+
if (isBefore) csn = csn + ',\n';
|
|
100
|
+
csn = csn + `"@${key}":"${attr[key]}"`;
|
|
101
|
+
if (!isBefore) csn = csn + ',\n';
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return csn;
|
|
105
|
+
}
|
|
63
106
|
function _isValidEDMX(jsonObj) {
|
|
64
107
|
let isValid = false;
|
|
65
108
|
let edmx;
|
|
@@ -300,20 +343,20 @@ function _extractAllFunctionImports(functionImports, serviceNamespaceParam)
|
|
|
300
343
|
}
|
|
301
344
|
}
|
|
302
345
|
|
|
303
|
-
function
|
|
304
|
-
return text.replace(/(?:\\[rn]|[\r\n]+)+/gm, "\\n").replace(/\s+/g, ' ').trim();
|
|
346
|
+
function _replaceSpecialCharacters(text) {
|
|
347
|
+
return text.replace(/(?:\\[rn]|[\r\n]+)+/gm, "\\n").replace(/\s+/g, ' ').replace(/"/g, """).trim();
|
|
305
348
|
}
|
|
306
349
|
|
|
307
350
|
// to parse the documentation tag
|
|
308
351
|
function _parseDocumentationTag(documentedContent) {
|
|
309
352
|
let documentation = "";
|
|
310
353
|
if (documentedContent.Summary && documentedContent.Summary._text) {
|
|
311
|
-
documentation =
|
|
354
|
+
documentation = _replaceSpecialCharacters(documentedContent.Summary._text);
|
|
312
355
|
}
|
|
313
356
|
if (documentedContent.LongDescription && documentedContent.LongDescription._text) {
|
|
314
357
|
if (documentedContent.Summary)
|
|
315
358
|
documentation += "\\n\\n";
|
|
316
|
-
documentation +=
|
|
359
|
+
documentation += _replaceSpecialCharacters(documentedContent.LongDescription._text);
|
|
317
360
|
}
|
|
318
361
|
return documentation;
|
|
319
362
|
}
|
|
@@ -322,10 +365,12 @@ function _extractComplexType(complexType, serviceNamespaceParam) {
|
|
|
322
365
|
let complexTypeKey = "";
|
|
323
366
|
let baseType = "";
|
|
324
367
|
let properties;
|
|
368
|
+
let namespaceAttributes = {};
|
|
325
369
|
Object.keys(complexType).forEach((key) => {
|
|
326
370
|
if (key === "_attributes") {
|
|
327
371
|
complexTypeKey =
|
|
328
372
|
serviceNamespaceParam + "." + complexType[key].Name;
|
|
373
|
+
namespaceAttributes = namespaceAttributeFilter(complexType[key]);
|
|
329
374
|
baseType = complexType[key].BaseType;
|
|
330
375
|
} else if (key === "Property") {
|
|
331
376
|
properties = complexType.Property;
|
|
@@ -337,6 +382,9 @@ function _extractComplexType(complexType, serviceNamespaceParam) {
|
|
|
337
382
|
if (complexTypeKey && baseType) {
|
|
338
383
|
allInheritedComplexTypes[complexTypeKey] = baseType;
|
|
339
384
|
}
|
|
385
|
+
if (namespaceAttributes.length) {
|
|
386
|
+
allComplexTypeNamespaces[complexTypeKey] = namespaceAttributes;
|
|
387
|
+
}
|
|
340
388
|
}
|
|
341
389
|
|
|
342
390
|
function _extractAllComplexTypes(complexTypes, serviceNamespaceParam) {
|
|
@@ -361,7 +409,8 @@ function _getServiceEntityProperty(
|
|
|
361
409
|
displayFormat,
|
|
362
410
|
isKey,
|
|
363
411
|
documentation,
|
|
364
|
-
isCollection
|
|
412
|
+
isCollection,
|
|
413
|
+
allowedNamespaceAttributes = -1
|
|
365
414
|
) {
|
|
366
415
|
let cdsDataType = null;
|
|
367
416
|
let hasInvalidPrecision = false;
|
|
@@ -427,6 +476,10 @@ function _getServiceEntityProperty(
|
|
|
427
476
|
propertyJson = propertyJson + ',\n"doc":"' + documentation + '"';
|
|
428
477
|
}
|
|
429
478
|
|
|
479
|
+
if (allowedNamespaceAttributes !== -1) {
|
|
480
|
+
propertyJson += _generateNamespaceAttributes(allowedNamespaceAttributes, true);
|
|
481
|
+
}
|
|
482
|
+
|
|
430
483
|
if(propertyName)
|
|
431
484
|
propertyJson = propertyJson + "\n}";
|
|
432
485
|
return propertyJson;
|
|
@@ -437,6 +490,9 @@ function _getServiceComplexType(complexTypeKey, complexType) {
|
|
|
437
490
|
let complexTypeProperty;
|
|
438
491
|
let i;
|
|
439
492
|
complexTypeCSN = complexTypeCSN + '"kind": "type",\n';
|
|
493
|
+
if(allComplexTypeNamespaces[complexTypeKey]) {
|
|
494
|
+
complexTypeCSN += _generateNamespaceAttributes(allComplexTypeNamespaces[complexTypeKey], false);
|
|
495
|
+
}
|
|
440
496
|
if (allComplexTypeDocs[complexTypeKey])
|
|
441
497
|
complexTypeCSN = complexTypeCSN + '"doc":' + `"${allComplexTypeDocs[complexTypeKey]}",` + "\n";
|
|
442
498
|
complexTypeCSN = complexTypeCSN + '"elements": {\n';
|
|
@@ -447,6 +503,10 @@ function _getServiceComplexType(complexTypeKey, complexType) {
|
|
|
447
503
|
complexTypeProperty = complexType[i]._attributes;
|
|
448
504
|
if(complexType[i].Documentation)
|
|
449
505
|
complexTypeProperty.doc = _parseDocumentationTag(complexType[i].Documentation);
|
|
506
|
+
|
|
507
|
+
let namespaceAttributes = namespaceAttributeFilter(complexTypeProperty)
|
|
508
|
+
const complexTypePropertyNamespace = namespaceAttributes.length ? namespaceAttributes : -1
|
|
509
|
+
|
|
450
510
|
complexTypeCSN =
|
|
451
511
|
complexTypeCSN +
|
|
452
512
|
_getServiceEntityProperty(
|
|
@@ -458,7 +518,8 @@ function _getServiceComplexType(complexTypeKey, complexType) {
|
|
|
458
518
|
complexTypeProperty["sap:display-format"],
|
|
459
519
|
false,
|
|
460
520
|
complexTypeProperty.doc,
|
|
461
|
-
-1
|
|
521
|
+
-1,
|
|
522
|
+
complexTypePropertyNamespace
|
|
462
523
|
);
|
|
463
524
|
if (i !== complexType.length - 1) {
|
|
464
525
|
complexTypeCSN = complexTypeCSN + ",\n";
|
|
@@ -471,6 +532,10 @@ function _getServiceComplexType(complexTypeKey, complexType) {
|
|
|
471
532
|
complexTypeProperty = complexType._attributes;
|
|
472
533
|
if(complexType.Documentation)
|
|
473
534
|
complexTypeProperty.doc = _parseDocumentationTag(complexType.Documentation);
|
|
535
|
+
|
|
536
|
+
let namespaceAttributes = namespaceAttributeFilter(complexTypeProperty);
|
|
537
|
+
const complexTypePropertyNamespace = namespaceAttributes.length ? namespaceAttributes : -1;
|
|
538
|
+
|
|
474
539
|
complexTypeCSN =
|
|
475
540
|
complexTypeCSN +
|
|
476
541
|
_getServiceEntityProperty(
|
|
@@ -482,7 +547,8 @@ function _getServiceComplexType(complexTypeKey, complexType) {
|
|
|
482
547
|
complexTypeProperty["sap:display-format"],
|
|
483
548
|
false,
|
|
484
549
|
complexTypeProperty.doc,
|
|
485
|
-
-1
|
|
550
|
+
-1,
|
|
551
|
+
complexTypePropertyNamespace
|
|
486
552
|
);
|
|
487
553
|
}
|
|
488
554
|
}
|
|
@@ -527,6 +593,10 @@ function _parseParameter(parameter)
|
|
|
527
593
|
let isCollection = -1;
|
|
528
594
|
if(parameter.Documentation)
|
|
529
595
|
doc = _parseDocumentationTag(parameter.Documentation);
|
|
596
|
+
|
|
597
|
+
let namespaceAttributes = namespaceAttributeFilter(parameter._attributes);
|
|
598
|
+
const parameterNamespaceAttributes = namespaceAttributes.length ? namespaceAttributes : -1;
|
|
599
|
+
|
|
530
600
|
let type = parameter["_attributes"].Type;
|
|
531
601
|
if(type.substring(0,10) === 'Collection')
|
|
532
602
|
{
|
|
@@ -541,7 +611,8 @@ function _parseParameter(parameter)
|
|
|
541
611
|
parameter["_attributes"]["sap:display-format"],
|
|
542
612
|
false,
|
|
543
613
|
doc,
|
|
544
|
-
isCollection
|
|
614
|
+
isCollection,
|
|
615
|
+
parameterNamespaceAttributes);
|
|
545
616
|
return csn;
|
|
546
617
|
}
|
|
547
618
|
|
|
@@ -605,7 +676,7 @@ function _getFunctionImport(functionImport,isBounded) {
|
|
|
605
676
|
}
|
|
606
677
|
if(functionImport[4] !== -1)
|
|
607
678
|
{
|
|
608
|
-
csn = csn + ',\n "doc": "' + functionImport[4] + '"';
|
|
679
|
+
csn = csn + ',\n "doc": "' + _replaceSpecialCharacters(functionImport[4]) + '"';
|
|
609
680
|
}
|
|
610
681
|
|
|
611
682
|
csn = csn + "\n }";
|
|
@@ -640,6 +711,8 @@ function _parseEntityAttributes(attributes) {
|
|
|
640
711
|
entityAttributes.Name = attributes.Name;
|
|
641
712
|
entityAttributes.BaseType = attributes.BaseType;
|
|
642
713
|
entityAttributes.Abstract = attributes.Abstract;
|
|
714
|
+
entityAttributes.allowedNamespaceAttributes = namespaceAttributeFilter(attributes);
|
|
715
|
+
|
|
643
716
|
return entityAttributes;
|
|
644
717
|
}
|
|
645
718
|
|
|
@@ -661,6 +734,9 @@ function _parseEntityKeys(keys) {
|
|
|
661
734
|
|
|
662
735
|
function _getPropertyAttributes(propAttributes) {
|
|
663
736
|
let propOthers = [];
|
|
737
|
+
|
|
738
|
+
let namespaceAttributes = namespaceAttributeFilter(propAttributes)
|
|
739
|
+
|
|
664
740
|
propOthers.push(propAttributes.Type);
|
|
665
741
|
if (propAttributes.MaxLength) {
|
|
666
742
|
propOthers.push(propAttributes.MaxLength);
|
|
@@ -690,6 +766,13 @@ function _getPropertyAttributes(propAttributes) {
|
|
|
690
766
|
}else{
|
|
691
767
|
propOthers.push(-1);
|
|
692
768
|
}
|
|
769
|
+
|
|
770
|
+
if (namespaceAttributes.length) {
|
|
771
|
+
propOthers.push(namespaceAttributes);
|
|
772
|
+
} else {
|
|
773
|
+
propOthers.push(-1);
|
|
774
|
+
}
|
|
775
|
+
|
|
693
776
|
return propOthers;
|
|
694
777
|
}
|
|
695
778
|
|
|
@@ -758,7 +841,8 @@ function _generateCSNEntityKeys(entityKeysList, entityPropertiesMap) {
|
|
|
758
841
|
propAttributes[4],
|
|
759
842
|
true,
|
|
760
843
|
propAttributes[5],
|
|
761
|
-
-1
|
|
844
|
+
-1,
|
|
845
|
+
propAttributes[6]
|
|
762
846
|
);
|
|
763
847
|
if (i !== entityKeysList.length - 1) {
|
|
764
848
|
csnEntity = csnEntity + ",\n";
|
|
@@ -796,7 +880,8 @@ function _generateCSNEntityProperties(entityKeysList, entityPropertiesMap) {
|
|
|
796
880
|
propAttributes[4],
|
|
797
881
|
false,
|
|
798
882
|
propAttributes[5],
|
|
799
|
-
-1
|
|
883
|
+
-1,
|
|
884
|
+
propAttributes[6]
|
|
800
885
|
);
|
|
801
886
|
if (i !== entityProperties.length - 1) {
|
|
802
887
|
csnEntity = csnEntity + ",\n";
|
|
@@ -1078,6 +1163,7 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc) {
|
|
|
1078
1163
|
let navPropName;
|
|
1079
1164
|
let relationshipName;
|
|
1080
1165
|
let navPropDoc;
|
|
1166
|
+
let allowedNamespaceAttributes = namespaceAttributeFilter(navPropAttributes);
|
|
1081
1167
|
// var fromRole;
|
|
1082
1168
|
let toRole;
|
|
1083
1169
|
if (!navPropAttributes) {
|
|
@@ -1090,6 +1176,9 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc) {
|
|
|
1090
1176
|
navPropDoc = navPropAttributes.doc;
|
|
1091
1177
|
|
|
1092
1178
|
csn = csn + '"' + navPropName + '": {\n';
|
|
1179
|
+
if(allowedNamespaceAttributes.length) {
|
|
1180
|
+
csn += _generateNamespaceAttributes(allowedNamespaceAttributes, false);
|
|
1181
|
+
}
|
|
1093
1182
|
// if documentatin exists for navigation property
|
|
1094
1183
|
if (navPropDoc) {
|
|
1095
1184
|
csn = csn + '"doc":' + `"Please add an ON condition\\n${navPropDoc}",\n`;
|
|
@@ -1156,6 +1245,7 @@ function _constructServiceEntity(
|
|
|
1156
1245
|
entityPropertiesMap,
|
|
1157
1246
|
entityNavigationPropertiesMap,
|
|
1158
1247
|
entityAttributes,
|
|
1248
|
+
ignorePersistenceSkip,
|
|
1159
1249
|
mockServerUc,
|
|
1160
1250
|
documentation
|
|
1161
1251
|
) {
|
|
@@ -1165,12 +1255,20 @@ function _constructServiceEntity(
|
|
|
1165
1255
|
let csnProperties;
|
|
1166
1256
|
let hasProperties;
|
|
1167
1257
|
csnEntity = csnEntity + '"kind": "entity",\n';
|
|
1258
|
+
if (ignorePersistenceSkip === false) {
|
|
1259
|
+
csnEntity = csnEntity + '"@cds.persistence.skip": true,\n';
|
|
1260
|
+
}
|
|
1168
1261
|
if (
|
|
1169
1262
|
entityAttributes.Abstract &&
|
|
1170
1263
|
entityAttributes.Abstract.toUpperCase() === "TRUE"
|
|
1171
1264
|
) {
|
|
1172
1265
|
csnEntity = csnEntity + '"abstract": true,\n';
|
|
1173
1266
|
}
|
|
1267
|
+
|
|
1268
|
+
if(entityAttributes.allowedNamespaceAttributes.length)
|
|
1269
|
+
{
|
|
1270
|
+
csnEntity += _generateNamespaceAttributes(entityAttributes.allowedNamespaceAttributes, false);
|
|
1271
|
+
}
|
|
1174
1272
|
// if documentation exists for the entity
|
|
1175
1273
|
if (documentation) {
|
|
1176
1274
|
csnEntity = csnEntity + `"doc": "${documentation}",` + '\n';
|
|
@@ -1230,6 +1328,7 @@ function _parseServiceEntity(
|
|
|
1230
1328
|
serviceNamespaceParam,
|
|
1231
1329
|
entityName,
|
|
1232
1330
|
entity,
|
|
1331
|
+
ignorePersistenceSkip,
|
|
1233
1332
|
mockServerUc
|
|
1234
1333
|
) {
|
|
1235
1334
|
let entityAttributes;
|
|
@@ -1278,6 +1377,7 @@ function _parseServiceEntity(
|
|
|
1278
1377
|
entityPropertiesMap,
|
|
1279
1378
|
entityNavigationPropertiesMap,
|
|
1280
1379
|
entityAttributes,
|
|
1380
|
+
ignorePersistenceSkip,
|
|
1281
1381
|
mockServerUc,
|
|
1282
1382
|
documentation
|
|
1283
1383
|
);
|
|
@@ -1318,6 +1418,7 @@ function _getEntitesWithNamesFromEntitySets(
|
|
|
1318
1418
|
function _getServiceEntitites(
|
|
1319
1419
|
serviceNamespaceParam,
|
|
1320
1420
|
entityJson = [],
|
|
1421
|
+
ignorePersistenceSkip,
|
|
1321
1422
|
mockServerUc
|
|
1322
1423
|
) {
|
|
1323
1424
|
const entities = Array.isArray(entityJson) ? entityJson : [entityJson];
|
|
@@ -1335,6 +1436,7 @@ function _getServiceEntitites(
|
|
|
1335
1436
|
serviceNamespaceParam,
|
|
1336
1437
|
entityName,
|
|
1337
1438
|
entityWithName.entity,
|
|
1439
|
+
ignorePersistenceSkip,
|
|
1338
1440
|
mockServerUc
|
|
1339
1441
|
)
|
|
1340
1442
|
)
|
|
@@ -1348,6 +1450,7 @@ function _getServiceEntitites(
|
|
|
1348
1450
|
function _generateEDMXJSON2CSN(
|
|
1349
1451
|
jsonObj,
|
|
1350
1452
|
serviceNamespaceParam,
|
|
1453
|
+
ignorePersistenceSkip,
|
|
1351
1454
|
mockServerUc
|
|
1352
1455
|
) {
|
|
1353
1456
|
const csn = {};
|
|
@@ -1422,6 +1525,7 @@ function _generateEDMXJSON2CSN(
|
|
|
1422
1525
|
_getServiceEntitites(
|
|
1423
1526
|
serviceNamespaceParam,
|
|
1424
1527
|
entityJson,
|
|
1528
|
+
ignorePersistenceSkip,
|
|
1425
1529
|
mockServerUc
|
|
1426
1530
|
)
|
|
1427
1531
|
);
|
|
@@ -1437,17 +1541,32 @@ function _generateEDMXJSON2CSN(
|
|
|
1437
1541
|
|
|
1438
1542
|
function getEdmxv2CSN(
|
|
1439
1543
|
edmx2jsonModel,
|
|
1440
|
-
|
|
1544
|
+
ignorePersistenceSkip,
|
|
1545
|
+
mockServerUc,
|
|
1546
|
+
context
|
|
1441
1547
|
) {
|
|
1442
1548
|
let csnDataModel;
|
|
1443
1549
|
let isValid;
|
|
1444
1550
|
_initialize();
|
|
1551
|
+
if (!context.include_all_namespaces && context.namespaces.length) {
|
|
1552
|
+
allowedNamespaces = allowedNamespaces.concat(context.namespaces)
|
|
1553
|
+
}
|
|
1554
|
+
else if(context.include_all_namespaces) {
|
|
1555
|
+
allowAllNamespaces = true;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1445
1558
|
isValid = _validateEDMX(edmx2jsonModel);
|
|
1446
1559
|
if (isValid) {
|
|
1447
1560
|
serviceNamespace = _getServiceNameSpace(edmx2jsonModel);
|
|
1561
|
+
let namespaceAlias = edmx2jsonModel["edmx:Edmx"]["edmx:DataServices"].Schema._attributes.Alias;
|
|
1562
|
+
// replace the namespace alias value with original namespace value
|
|
1563
|
+
if (namespaceAlias) {
|
|
1564
|
+
edmx2jsonModel = common.replaceAliasValue(JSON.stringify(edmx2jsonModel), serviceNamespace, namespaceAlias);
|
|
1565
|
+
}
|
|
1448
1566
|
csnDataModel = _generateEDMXJSON2CSN(
|
|
1449
1567
|
edmx2jsonModel,
|
|
1450
1568
|
serviceNamespace,
|
|
1569
|
+
ignorePersistenceSkip,
|
|
1451
1570
|
mockServerUc
|
|
1452
1571
|
);
|
|
1453
1572
|
}
|