@sap/cds-dk 4.5.2 → 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 (42) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/bin/bind.js +124 -8
  3. package/bin/cds-ts.js +1 -1
  4. package/bin/cds.js +1 -0
  5. package/bin/compile/index.js +2 -1
  6. package/bin/env.js +50 -9
  7. package/bin/help.js +1 -0
  8. package/bin/import.js +38 -18
  9. package/bin/repl.js +6 -2
  10. package/bin/watch.js +58 -13
  11. package/lib/bind/bindingResolver.js +138 -0
  12. package/lib/bind/cfKeyProvider.js +353 -0
  13. package/lib/bind/userCdsrcJsonStorageProvider.js +144 -0
  14. package/lib/client/auth_manager.js +4 -4
  15. package/lib/client/settings_manager.js +6 -5
  16. package/lib/import/common.js +10 -1
  17. package/lib/import/importapi.js +4 -3
  18. package/lib/import/index.js +34 -5
  19. package/lib/import/message.js +2 -1
  20. package/lib/import/utils/MetadataConverter.js +25 -4
  21. package/lib/import/utils/MetadataConverterFactory.js +1 -2
  22. package/lib/import/utils/MultiMap.js +26 -0
  23. package/lib/import/v2parser.js +131 -12
  24. package/lib/import/v4parser.js +214 -168
  25. package/lib/init/constants.js +1 -1
  26. package/lib/init/index.js +2 -0
  27. package/lib/init/template/lint/files/.eslint/rules/no-entity-moo.js +36 -52
  28. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/rule.test.js +15 -0
  29. package/lib/init/template/lint/index.js +19 -17
  30. package/lib/init/template/mta/files/mta.yaml.hbs +0 -7
  31. package/lib/init/template/mtx/files/xs-security.json.hbs +3 -1
  32. package/lib/init/template/mtx/package/dependencies.package.json +1 -1
  33. package/lib/init/template/nodejs/files/.gitignore.hbs +1 -0
  34. package/lib/init/util/commandUtil.js +5 -0
  35. package/lib/lint/Linter.js +17 -20
  36. package/lib/lint/generators.js +5 -4
  37. package/lib/lint/io.js +62 -36
  38. package/lib/util/term.js +2 -0
  39. package/lib/watch/node-watch.js +38 -19
  40. package/npm-shrinkwrap.json +1485 -1959
  41. package/package.json +3 -3
  42. package/lib/init/template/lint/files/.eslint/tests/no-entity-moo/test.js +0 -10
@@ -3,8 +3,8 @@
3
3
  * OData V4 to CSN parser
4
4
  */
5
5
 
6
- 'use strict';
7
6
 
7
+ 'use strict';
8
8
  let messages = require("./message").getMessages();
9
9
  let common = require("./common");
10
10
  let versionInfo = require('../../package.json').version;
@@ -24,7 +24,6 @@ let functionImportToFunctionMap = new Multimap();
24
24
  let validEdmDatatypes = ['Edm.DateTimeOffset'];
25
25
  let jsonEntityContainerName;
26
26
  const ignoreObjects = ['$Reference']; // add all the objects that needs to be ignored for parsing.
27
-
28
27
  const MetadataConverterFactory = require('../import/utils/MetadataConverterFactory');
29
28
  const edmxncdsdatatype = {
30
29
  'Edm.String': 'cds.LargeString',
@@ -117,11 +116,19 @@ function _validateJSON(jsonObj) {
117
116
  );
118
117
  }
119
118
 
119
+ function _includeExternalNamespaceAnnotation(source,target){
120
+ Object.entries(source).forEach(element =>{
121
+ if(element[0].startsWith('@')){
122
+ target[element[0]] = element[1];
123
+ }
124
+ });
125
+ }
120
126
  function generatePropertyCsn(propertyType, isPrimaryKey) {
121
127
  let property = {};
122
128
  if (isPrimaryKey) {
123
129
  property.key = true;
124
130
  }
131
+ _includeExternalNamespaceAnnotation(propertyType,property);
125
132
  // conditions have to be made
126
133
  if (propertyType.$MaxLength) {
127
134
  if (propertyType.$Type) {
@@ -141,7 +148,7 @@ function generatePropertyCsn(propertyType, isPrimaryKey) {
141
148
  }
142
149
  } else if (propertyType.$Type) {
143
150
  property.type = edmxncdsdatatype[propertyType.$Type];
144
- } else {
151
+ } else{
145
152
  property.type = 'cds.LargeString'; // if type is missing, then it is String type
146
153
  }
147
154
  return property;
@@ -218,10 +225,11 @@ function _parseAssociationProperty(foreignReference, associationNode, mockServer
218
225
  if (common.checkForEmptyKeys(associationProperty, "V4")) {
219
226
  associationProperty.keys = [];
220
227
  }
228
+ _includeExternalNamespaceAnnotation(associationNode,associationProperty);
221
229
  return associationProperty;
222
230
  }
223
231
 
224
- function _generateCSNForEntityType(entityTypes, mockServerUc) {
232
+ function _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServerUc) {
225
233
  let entityCsn = {};
226
234
  let keySet;
227
235
  let curKey;
@@ -235,6 +243,10 @@ function _generateCSNForEntityType(entityTypes, mockServerUc) {
235
243
  if (key) {
236
244
  entityCsn[key] = {};
237
245
  entityCsn[key].kind = 'entity';
246
+ if (!ignorePersistenceSkip) {
247
+ entityCsn[key]['@cds.persistence.skip'] = true;
248
+ }
249
+ _includeExternalNamespaceAnnotation(element[key],entityCsn[key]);
238
250
  // inheritance
239
251
  if (baseType) {
240
252
  entityCsn[key].includes = [];
@@ -326,7 +338,7 @@ function _generateEntityType(entityTypes, schemaData, mockServerUc) {
326
338
  });
327
339
  }
328
340
 
329
- function _parseEntityType(schemaDataList, mockServerUc) {
341
+ function _parseEntityType(schemaDataList, ignorePersistenceSkip, mockServerUc) {
330
342
  // collect entity types
331
343
  let entityTypes = [];
332
344
  let schemaData;
@@ -335,7 +347,7 @@ function _parseEntityType(schemaDataList, mockServerUc) {
335
347
  _generateEntityType(entityTypes, schemaData, mockServerUc);
336
348
  }
337
349
  // parse it
338
- return _generateCSNForEntityType(entityTypes, mockServerUc);
350
+ return _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServerUc);
339
351
  }
340
352
 
341
353
  function _generateEnumType(schemaData) {
@@ -420,8 +432,30 @@ function _collectBounded(schemaDataList, flag) {
420
432
  }
421
433
  }
422
434
 
435
+ function _getDatatype(datatype) {
436
+ let type = undefined;
437
+ if (datatype === undefined) {
438
+ type = "cds.LargeString"; //intentionally used LargeString
439
+ } else if (entitySetToEntityTypeMap.get(datatype) && entitySetToEntityTypeMap.get(datatype)[0]) {
440
+ //mapping to entity set if type is entity type
441
+ type = namespace + "." + entitySetToEntityTypeMap.get(datatype)[0];
442
+ } else if (complexTypes[datatype] || typeDefinitions[datatype] || enumTypes[datatype]) {
443
+ //if type is complex type, type definition or an enum type
444
+ type = datatype;
445
+ } else {
446
+ //checking if type is an entity set
447
+ for (const element of entitySetToEntityTypeMap.keys()) {
448
+ if (namespace + "." + entitySetToEntityTypeMap.get(element) === datatype)
449
+ type = datatype;
450
+ }
451
+ }
452
+
453
+ //will return undefined if type is not supported
454
+ return type;
455
+ }
456
+
423
457
  function _parseBounded(csnDefs, flag) {
424
- let boundedEdmxKind, boundedObj, boundedCsnKind, boundedEntityName, obj, paramType, paramName, paramObj, name, returnType;
458
+ let boundedEdmxKind, boundedObj, boundedCsnKind, boundedEntityName, obj, paramName, paramObj, name;
425
459
  if (flag == 0) {
426
460
  boundedEdmxKind = "Action";
427
461
  boundedCsnKind = "action";
@@ -446,6 +480,7 @@ function _parseBounded(csnDefs, flag) {
446
480
  if (csnDefs[boundedEntityName].actions === undefined)
447
481
  csnDefs[boundedEntityName].actions = {};
448
482
  csnDefs[boundedEntityName].actions[name] = {};
483
+ _includeExternalNamespaceAnnotation(obj[0],csnDefs[boundedEntityName].actions[name]);
449
484
  csnDefs[boundedEntityName].actions[name].kind = boundedCsnKind;
450
485
  // add params
451
486
  if (obj[j].$Parameter && obj[j].$Parameter.length >= 2) {
@@ -462,55 +497,56 @@ function _parseBounded(csnDefs, flag) {
462
497
  for (let i = 1; i < obj[j].$Parameter.length; i++) {
463
498
  paramObj = obj[j].$Parameter[i];
464
499
  paramName = obj[j].$Parameter[i].$Name;
465
- // check if the parameter type is pre-defined, undefined or custom defined
500
+ let paramType ={};
501
+ _includeExternalNamespaceAnnotation(paramObj,paramType);
502
+ //check if the parameter type is pre-defined, undefined or custom defined
466
503
  if (edmxncdsdatatype[paramObj.$Type])
467
504
  paramType = generatePropertyCsn(paramObj, false);
468
- else if (paramObj.$Type === undefined)
469
- paramType = { "type": "cds.LargeString" }; // intentionally used LargeString
470
505
  else {
471
- if (entitySetToEntityTypeMap.get(obj[j].$Parameter[i].$Type)) {
472
- let type = namespace + "." + entitySetToEntityTypeMap.get(obj[j].$Parameter[i].$Type)[0];
473
- paramType = { "type": type };
474
- }
475
- else {
476
- paramType = { "type": obj[j].$Parameter[i].$Type };
477
- }
506
+ let type = _getDatatype(paramObj.$Type);
507
+ if(type) paramType["type"] = type;
478
508
  }
479
- // check if parameter type is a collection
480
- if (paramObj.$Collection) {
481
- csnDefs[boundedEntityName].actions[name].params[paramName] = {};
482
- csnDefs[boundedEntityName].actions[name].params[paramName].items = paramType;
483
- } else
484
- csnDefs[boundedEntityName].actions[name].params[paramName] = paramType;
509
+ if (paramType) {
510
+ // check if parameter type is a collection
511
+ if (paramObj.$Collection) {
512
+ csnDefs[boundedEntityName].actions[name].params[paramName] = {};
513
+ csnDefs[boundedEntityName].actions[name].params[paramName].items = paramType;
514
+ } else
515
+ csnDefs[boundedEntityName].actions[name].params[paramName] = paramType;
516
+ }
517
+ }
518
+
485
519
  }
486
520
  }
521
+ //if parameters has no entries
522
+ if(csnDefs[boundedEntityName].actions[name].params && Object.keys(csnDefs[boundedEntityName].actions[name].params).length === 0)
523
+ {
524
+ delete csnDefs[boundedEntityName].actions[name].params;
525
+ }
487
526
  // add returns
488
527
  if (obj[j].$ReturnType) {
489
- csnDefs[boundedEntityName].actions[name].returns = {};
528
+ let returnType={};
490
529
  // check if the return type is pre-defined, undefined or custom defined
491
530
  if (edmxncdsdatatype[obj[j].$ReturnType.$Type])
492
531
  returnType = generatePropertyCsn(obj[j].$ReturnType, false);
493
- else if (obj[j].$ReturnType.$Type === undefined)
494
- returnType = { "type": "cds.LargeString" }; // intentionally used LargeString
495
532
  else {
496
- if (entitySetToEntityTypeMap.get(obj[j].$ReturnType.$Type) && entitySetToEntityTypeMap.get(obj[j].$ReturnType.$Type)[0]) {
497
- let type = namespace + "." + entitySetToEntityTypeMap.get(obj[j].$ReturnType.$Type)[0];
498
- returnType = { "type": type };
499
- }
500
- else {
501
- returnType = { "type": obj[j].$ReturnType.$Type };
502
- }
533
+ let type = _getDatatype(obj[j].$ReturnType.$Type);
534
+ _includeExternalNamespaceAnnotation(obj[j].$ReturnType,returnType);
535
+ if(type) returnType["type"] = type ;
536
+ }
537
+ if (returnType) {
538
+ csnDefs[boundedEntityName].actions[name].returns = {};
539
+ // check if return type is a collection
540
+ if (obj[j].$ReturnType.$Collection)
541
+ csnDefs[boundedEntityName].actions[name].returns.items = returnType;
542
+ else
543
+ csnDefs[boundedEntityName].actions[name].returns = returnType;
503
544
  }
504
- // check if return type is a collection
505
- if (obj[j].$ReturnType.$Collection)
506
- csnDefs[boundedEntityName].actions[name].returns.items = returnType;
507
- else
508
- csnDefs[boundedEntityName].actions[name].returns = returnType;
509
545
  }
510
546
  }
511
547
  }
512
548
  }
513
- });
549
+ );
514
550
  }
515
551
  }
516
552
 
@@ -556,13 +592,15 @@ function _generateCSNForComplexType(schemaData) {
556
592
  }
557
593
  Object.keys(cTypes[element]).forEach(property => { // cTypes[element][property].$Type.startsWith('Edm.')
558
594
  if (cTypes[element][property] instanceof Object) {
559
- if (!cTypes[element][property].$Type || edmxncdsdatatype[cTypes[element][property].$Type]) {
595
+ if (!cTypes[element][property].$Type || edmxncdsdatatype[cTypes[element][property].$Type] ) {
560
596
  propertyType = cTypes[element][property];
561
597
  complexCsn[element].elements[property] = generatePropertyCsn(propertyType, false);
562
598
  }
563
599
  } else if (complexTypes[cTypes[element][property].$Type]) {
564
600
  propertyType = cTypes[element][property];
565
601
  complexCsn[element].elements[property] = _generateComplexTypePropertyCsn(propertyType);
602
+ } else if(property.startsWith("@")){
603
+ complexCsn[element][property] = cTypes[element][property];
566
604
  }
567
605
  });
568
606
  });
@@ -599,64 +637,67 @@ function _parseUnbounded(schemaData, flag) {
599
637
  if (Object.keys(unbounded).length > 0) {
600
638
  Object.keys(unbounded).forEach(ub => {
601
639
  let obj = {};
602
- let objType = {}, objData = {}, temp;
603
- if (importToMap && importToMap.get(ub)) {
604
- temp = importToMap.get(ub)[0];
640
+ let objType = {}, objData = {}, temp = {};
641
+ if (importToMap && importToMap.get(ub)) {
642
+ temp = ub.split(".").pop();
605
643
  objType = namespace + "." + temp;
606
644
  objData = schemaData[0][temp][0];
607
645
  obj[objType] = {};
608
646
  obj[objType].kind = unboundedCsnKind;
647
+ _includeExternalNamespaceAnnotation(objData,obj[objType]);
609
648
  // add params
610
649
  if (objData.$Parameter && objData.$Parameter.length > 0) {
611
650
  obj[objType].params = {};
612
- let type;
651
+ let type = {};
613
652
  for (let i = 0; i < objData.$Parameter.length; i++) {
614
- obj[objType].params[objData.$Parameter[i].$Name] = {};
653
+ let typeProperties = {};
654
+ _includeExternalNamespaceAnnotation(objData.$Parameter[i],typeProperties);
615
655
  // check if the parameter type is pre-defined, undefined or custom defined
616
656
  if (edmxncdsdatatype[objData.$Parameter[i].$Type]) {
617
- type = (generatePropertyCsn(objData.$Parameter[i], false)).type;
618
- }
619
- else if (objData.$Parameter[i].$Type === undefined) {
620
- type = "cds.LargeString"; // intentionally used LargeString
657
+ const parameterProperties = generatePropertyCsn(objData.$Parameter[i], false);
658
+ ({type, ...typeProperties} = parameterProperties);
659
+ } else {
660
+ type = _getDatatype(objData.$Parameter[i].$Type);
621
661
  }
622
- else {
623
- if (entitySetToEntityTypeMap.get(objData.$Parameter[i].$Type))
624
- type = namespace + "." + entitySetToEntityTypeMap.get(objData.$Parameter[i].$Type)[0];
662
+ if (type) {
663
+
664
+ // Adds type properties like scale, precision, etc if any
665
+ const parameterObj = Object.keys(typeProperties).length > 0 ? { type, ...typeProperties } : { type };
666
+
667
+ // check if parameter type is a collection
668
+ if (objData.$Parameter[i].$Collection)
669
+ obj[objType].params[objData.$Parameter[i].$Name].items = parameterObj;
625
670
  else
626
- type = objData.$Parameter[i].$Type;
671
+ obj[objType].params[objData.$Parameter[i].$Name] = parameterObj;
672
+
627
673
  }
628
- // check if parameter type is a collection
629
- if (objData.$Parameter[i].$Collection)
630
- obj[objType].params[objData.$Parameter[i].$Name].items = { "type": type };
631
- else
632
- obj[objType].params[objData.$Parameter[i].$Name] = { "type": type };
633
674
  }
634
675
  }
676
+ //if parameters has no entries
677
+ if(obj[objType].params && Object.keys(obj[objType].params).length === 0)
678
+ {
679
+ delete obj[objType].params;
680
+ }
635
681
  // add returns
636
682
  if (objData.$ReturnType && Object.keys(objData.$ReturnType).length > 0 && obj) {
637
- obj[objType].returns = {};
638
- let returnValue;
683
+ let returnValue = {};
639
684
  // check if the return type is pre-defined, undefined or custom defined
640
685
  if (edmxncdsdatatype[objData.$ReturnType.$Type]) {
641
686
  returnValue = generatePropertyCsn(objData.$ReturnType, false);
687
+ } else {
688
+ let type = _getDatatype(objData.$ReturnType.$Type);
689
+ _includeExternalNamespaceAnnotation(objData.$ReturnType,returnValue);
690
+ if(type) returnValue["type"] = type;
642
691
  }
643
- else if (objData.$ReturnType.$Type === undefined) {
644
- returnValue = { "type": "cds.LargeString" }; // intentionally used LargeString
645
- }
646
- else {
647
- if (entitySetToEntityTypeMap.get(objData.$ReturnType.$Type) && entitySetToEntityTypeMap.get(objData.$ReturnType.$Type)[0]) {
648
- let type = namespace + "." + entitySetToEntityTypeMap.get(objData.$ReturnType.$Type)[0];
649
- returnValue = { "type": type };
650
- }
651
- else
652
- returnValue = { "type": objData.$ReturnType.$Type };
692
+ if (returnValue) {
693
+ obj[objType].returns = {};
694
+ // check if return type is a collection
695
+ if (objData.$ReturnType.$Collection) {
696
+ obj[objType].returns.items = {};
697
+ obj[objType].returns.items = returnValue;
698
+ } else
699
+ obj[objType].returns = returnValue;
653
700
  }
654
- // check if return type is a collection
655
- if (objData.$ReturnType.$Collection) {
656
- obj[objType].returns.items = {};
657
- obj[objType].returns.items = returnValue;
658
- } else
659
- obj[objType].returns = returnValue;
660
701
  }
661
702
  }
662
703
  unboundedObj = Object.assign(unboundedObj, obj);
@@ -665,8 +706,7 @@ function _parseUnbounded(schemaData, flag) {
665
706
  return unboundedObj;
666
707
  }
667
708
 
668
- function _generateCSN(edmxAsJson, mockServerUc) {
669
- let schemaCounter = 0;
709
+ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc) {
670
710
  let csn = {};
671
711
  let schemaData = [];
672
712
  unboundedActions = {};
@@ -677,6 +717,16 @@ function _generateCSN(edmxAsJson, mockServerUc) {
677
717
  csn.meta.creator = 'cds-dk ' + versionInfo;
678
718
  csn.$version = '2.0';
679
719
  csn.definitions = {};
720
+
721
+ Object.keys(edmxAsJson).forEach(data => {
722
+ if (ignoreObjects.indexOf(data) === -1 && edmxAsJson[data] instanceof Object) {
723
+ // replace the namespace alias value with original namespace value
724
+ if (edmxAsJson[data].$Alias)
725
+ edmxAsJson[data] = common.replaceAliasValue(JSON.stringify(edmxAsJson[data]), data, edmxAsJson[data].$Alias);
726
+ schemaData.push(edmxAsJson[data]);
727
+ }
728
+ });
729
+
680
730
  if (mockServerUc) {
681
731
  let entitySetData = edmxAsJson[namespace];
682
732
  let entityContainer;
@@ -702,19 +752,6 @@ function _generateCSN(edmxAsJson, mockServerUc) {
702
752
  }
703
753
  });
704
754
  }
705
- Object.keys(edmxAsJson).forEach(data => {
706
- if (ignoreObjects.indexOf(data) === -1 && edmxAsJson[data] instanceof Object) {
707
- schemaData.push(edmxAsJson[data]);
708
- schemaCounter += 1;
709
- }
710
- });
711
-
712
- // Multiple schema found and currently we don't support
713
- if (schemaCounter > 1) {
714
- let errorMsg = messages().MULTIPLE_SCHEMA_FOUND;
715
- errors.push(errorMsg);
716
- // throw errorMsg;
717
- }
718
755
 
719
756
  csn.definitions[namespace] = {};
720
757
  csn.definitions[namespace].kind = 'service';
@@ -733,7 +770,7 @@ function _generateCSN(edmxAsJson, mockServerUc) {
733
770
  csn.definitions = Object.assign(_parseUnbounded(schemaData, 0), csn.definitions);
734
771
  csn.definitions = Object.assign(_parseUnbounded(schemaData , 1), csn.definitions);
735
772
  // Step 4: get all entity type
736
- csn.definitions = Object.assign(_parseEntityType(schemaData, mockServerUc), csn.definitions);
773
+ csn.definitions = Object.assign(_parseEntityType(schemaData, ignorePersistenceSkip, mockServerUc), csn.definitions);
737
774
  // Step 5: get all bounded action & function
738
775
  _parseBounded(csn.definitions, 0);
739
776
  _parseBounded(csn.definitions, 1);
@@ -743,116 +780,125 @@ function _generateCSN(edmxAsJson, mockServerUc) {
743
780
  return JSON.stringify(csn, null, 4);
744
781
  }
745
782
 
746
- function _removeCarriageReturn(text) {
747
- return text.replace(/(?:\\[rn]|[\r\n]+)+/gm, "\n").replace(/\s+/g, ' ').trim();
783
+ function _replaceSpecialCharacters(text) {
784
+ return text.replace(/(?:\\[rn]|[\r\n]+)+/gm, "\n").replace(/\s+/g, ' ').replace(/"/g, "&quot;").trim();
785
+ }
786
+
787
+ function _checkAnnotatationTerm(annotation, path, no_of_terms, targetString){
788
+ if(path){
789
+ if(targetString === "@Core.Description"){
790
+ if(path.doc === undefined)
791
+ path.doc = _replaceSpecialCharacters(annotation[1]["@Core.Description"]);
792
+ else
793
+ path.doc += _replaceSpecialCharacters(annotation[1]["@Core.Description"]);
794
+ }
795
+ else if(targetString === "@Core.LongDescription"){
796
+ _generateLongDescription(annotation,path,no_of_terms);
797
+ }
798
+ }
799
+ }
800
+ function _checkAnnotationTarget(annotation, cdsDefs , str, no_of_terms){
801
+ if (annotation[0].indexOf('/') === -1 && annotation[0].indexOf('(') === -1) {
802
+ if (annotation[0].endsWith(".EntityContainer")) {
803
+ let path = annotation[0].split(".")[0];
804
+
805
+ _checkAnnotatationTerm(annotation,cdsDefs[path],no_of_terms,str);
806
+ }
807
+ if (cdsDefs[annotation[0]]) {
808
+ _checkAnnotatationTerm(annotation, cdsDefs[annotation[0]], no_of_terms , str);
809
+ }
810
+ } else if(annotation[0].indexOf('(') === -1 && !(annotation[0].indexOf('/') === -1)){
811
+ let path = annotation[0].split('/');
812
+ if(cdsDefs[path[0]]){
813
+ _checkAnnotatationTerm(annotation, cdsDefs[path[0]]["elements"][path[1]], no_of_terms, str);
814
+ }
815
+ } else{
816
+ let path = annotation[0].split('(');
817
+ if(cdsDefs[path[0]]== undefined){
818
+ let temp = path[1].split(')');
819
+ let path1 = temp[0].split(',');
820
+ let path2 = path[0].split('.');
821
+ if(cdsDefs[path1[0]]){
822
+ _checkAnnotatationTerm(annotation,cdsDefs[path1[0]]["actions"][path2[1]],no_of_terms,str);
823
+ }
824
+ } else{
825
+ if(path[1].indexOf('/') === -1){
826
+ _checkAnnotatationTerm(annotation,cdsDefs[path[0]],no_of_terms,str);
827
+ } else{
828
+ let path1 = path[1].split('/');
829
+ if(cdsDefs[path[0]]){
830
+ _checkAnnotatationTerm(annotation,cdsDefs[path[0]]["params"][path1[1]],no_of_terms,str);
831
+ }
832
+ }
833
+ }
834
+ }
748
835
  }
749
836
 
750
837
  function _generateDocumentation(schemaData, cdsDefs) {
751
838
  if (schemaData[0].$Annotations) {
752
839
  Object.entries(schemaData[0].$Annotations).map(annotation => {
753
- let flag;
840
+ let no_of_terms;
754
841
  // eslint-disable-next-line no-prototype-builtins
755
842
  if (annotation[1].hasOwnProperty('@Core.Description')) {
756
- flag = true;
757
- if (annotation[0].indexOf('/') === -1) {
758
- if (annotation[0].endsWith(".EntityContainer")) {
759
- let path = annotation[0].split(".")[0];
760
- cdsDefs[path].doc = _removeCarriageReturn(annotation[1]["@Core.Description"]);
761
- }
762
- if (cdsDefs[annotation[0]]) {
763
- cdsDefs[annotation[0]].doc = _removeCarriageReturn(annotation[1]["@Core.Description"]);
764
- }
765
- } else {
766
- let path = annotation[0].split('/');
767
- if (cdsDefs[path[0]]["elements"][path[1]]) {
768
- if (!cdsDefs[path[0]]["elements"][path[1]].doc) {
769
- cdsDefs[path[0]]["elements"][path[1]].doc = "";
770
- }
771
- cdsDefs[path[0]]["elements"][path[1]].doc += _removeCarriageReturn(annotation[1]["@Core.Description"]);
772
- }
773
- }
843
+
844
+ no_of_terms = true;
845
+ _checkAnnotationTarget(annotation,cdsDefs,"@Core.Description",no_of_terms);
774
846
  }
775
847
  // eslint-disable-next-line no-prototype-builtins
776
848
  if (annotation[1].hasOwnProperty('@Core.LongDescription')) {
777
- if (annotation[0].indexOf('/') === -1) {
778
- if (annotation[0].endsWith(".EntityContainer")) {
779
- let path = annotation[0].split(".")[0];
780
- if (flag === true) {
781
- cdsDefs[path].doc += "\n\n";
782
- } else {
783
- if (cdsDefs[path].doc){
784
- cdsDefs[path].doc += "";
785
- }
786
- else{
787
- cdsDefs[path].doc = "";
788
- }
789
- }
790
- cdsDefs[path].doc += _removeCarriageReturn(annotation[1]["@Core.LongDescription"]);
791
- }
792
- if (cdsDefs[annotation[0]]) {
793
- if (flag === true) {
794
- cdsDefs[annotation[0]].doc += "\n\n";
795
- } else {
796
- if (cdsDefs[annotation[0]].doc){
797
- cdsDefs[annotation[0]].doc += "";
798
- }
799
- else{
800
- cdsDefs[annotation[0]].doc = "";
801
- }
802
- }
803
- cdsDefs[annotation[0]].doc += _removeCarriageReturn(annotation[1]["@Core.LongDescription"]);
804
- }
805
- } else {
806
- let path = annotation[0].split('/');
807
- if (cdsDefs[path[0]]["elements"][path[1]]) {
808
- if (flag === true) {
809
- cdsDefs[path[0]]["elements"][path[1]].doc += "\n\n";
810
- } else {
811
- if (cdsDefs[path[0]]["elements"][path[1]].doc){
812
- cdsDefs[path[0]]["elements"][path[1]].doc += "";
813
- }
814
- else{
815
- cdsDefs[path[0]]["elements"][path[1]].doc = "";
849
+ _checkAnnotationTarget(annotation,cdsDefs,"@Core.LongDescription",no_of_terms);
850
+
816
851
  }
817
- }
818
- cdsDefs[path[0]]["elements"][path[1]].doc += _removeCarriageReturn(annotation[1]["@Core.LongDescription"]);
819
- }
820
- }
821
- }
822
852
  });
823
853
  }
824
854
  }
825
855
 
826
- function _generateEDMX2JSON(edmx) {
827
- return new Promise(function getJson(resolve, reject) {
828
- try {
856
+ function _generateLongDescription(annotation,path,no_of_terms){
857
+ if(path){
858
+ path.doc = no_of_terms ? (path.doc += "\n\n") : (path.doc ? (path.doc+="") : (path.doc=""));
859
+ path.doc += _replaceSpecialCharacters(annotation[1]["@Core.LongDescription"]);
860
+ return(path.doc);
861
+ }
862
+ }
863
+
864
+
865
+ function _generateEDMX2JSON(edmx, name_space) {
866
+ return new Promise(function getJson(resolve, reject) {
867
+ try {
829
868
  const inputBuffer = edmx;
830
869
  // create converter
831
- const v4Conv = MetadataConverterFactory.createEdmxV40XmlToV40Json();
832
- v4Conv.execute(inputBuffer, (error, json, missingReferencedDocuments) => {
870
+ const v4Conv = MetadataConverterFactory.createEdmxV40XmlToV40Json(name_space);
871
+ v4Conv.execute(inputBuffer, (error, json, missingReferencedDocuments) => {
833
872
  if (missingReferencedDocuments.length > 0) {
834
873
  console.log(missingReferencedDocuments); // eslint-disable-line no-console
835
874
  }
836
-
837
875
  if (_validateJSON(json)) {
838
876
  resolve(json);
839
877
  }
840
878
  });
841
- } catch (err) {
879
+ } catch (err) {
842
880
  reject(err);
843
881
  }
844
882
  });
845
883
  }
846
884
 
847
- function getEdmxv4CSN(edmx, mockServerUc) {
885
+ function getEdmxv4CSN(edmx, ignorePersistenceSkip, mockServerUc, context) {
848
886
  let csn;
849
887
  let edmjConverted;
888
+ let name_space = []
889
+ if(context.include_all_namespaces === true)
890
+ {
891
+ name_space.push(true);
892
+ }
893
+ else{
894
+ name_space = context.namespaces;
895
+ }
850
896
  if (_isJson(edmx)) {
851
897
  return new Promise(function getCsn(resolve, reject) {
852
898
  try {
853
899
  edmjConverted = JSON.parse(edmx);
854
900
  if (_validateJSON(edmjConverted)) {
855
- csn = _generateCSN(edmjConverted, mockServerUc);
901
+ csn = _generateCSN(edmjConverted, ignorePersistenceSkip, mockServerUc);
856
902
  if (csn) {
857
903
  resolve(csn);
858
904
  } else {
@@ -864,9 +910,9 @@ function getEdmxv4CSN(edmx, mockServerUc) {
864
910
  }
865
911
  });
866
912
  }
867
- return _generateEDMX2JSON(edmx).then(function getCsn(edmj) {
913
+ return _generateEDMX2JSON(edmx,name_space).then(function getCsn(edmj) {
868
914
  // now parsing logic
869
- return _generateCSN(edmj, mockServerUc);
915
+ return _generateCSN(edmj, ignorePersistenceSkip, mockServerUc);
870
916
  });
871
917
  }
872
918
 
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '1.19.0';
3
+ const MAVEN_ARCHETYPE_VERSION = '1.20.0';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
package/lib/init/index.js CHANGED
@@ -14,6 +14,8 @@ module.exports = class CDSGenerator {
14
14
  this.fsUtil = fsUtil || new FsUtil();
15
15
  this.logger = logger || defaultLogger;
16
16
 
17
+ this.cwd = process.cwd();
18
+
17
19
  this.uiConfig = [
18
20
  {
19
21
  title: `Project Name`,