@sap/cds-dk 4.8.0 → 4.9.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/bin/activate.js +8 -7
  3. package/bin/bind.js +12 -12
  4. package/bin/build/all.js +3 -5
  5. package/bin/build/index.js +1 -1
  6. package/bin/cds.js +1 -1
  7. package/bin/deploy/index.js +7 -1
  8. package/bin/deploy/to-hana.js +5 -4
  9. package/bin/deploy/to-sqlite.js +2 -1
  10. package/bin/extend.js +5 -5
  11. package/bin/help.js +1 -0
  12. package/bin/import.js +45 -31
  13. package/bin/login.js +5 -6
  14. package/bin/logout.js +2 -2
  15. package/bin/parse.js +19 -0
  16. package/lib/bind/bindingUtil.js +47 -50
  17. package/lib/bind/cfKeyProvider.js +9 -17
  18. package/lib/bind/userCdsrcJsonStorageProvider.js +1 -0
  19. package/lib/client/activate.js +3 -2
  20. package/lib/client/auth_manager.js +1 -0
  21. package/lib/client/extend.js +6 -6
  22. package/lib/client/helper/fs_helper.js +8 -8
  23. package/lib/client/settings_manager.js +12 -9
  24. package/lib/compile/openapi/csdl2openapi.js +213 -165
  25. package/lib/compile/openapi/index.js +1 -2
  26. package/lib/compile/to-xsuaa.js +1 -1
  27. package/lib/import/index.js +22 -15
  28. package/lib/import/message.js +3 -1
  29. package/lib/import/utils/MetadataConverter.js +1 -1
  30. package/lib/import/v2parser.js +112 -56
  31. package/lib/import/v4parser.js +152 -99
  32. package/lib/init/constants.js +6 -2
  33. package/lib/init/index.js +3 -2
  34. package/lib/init/template/_merging/existences.js +80 -4
  35. package/lib/init/template/approuter/files/cds.cdsrc.json +7 -0
  36. package/lib/init/template/approuter/files/cds.cdsrc.json.hbs +9 -0
  37. package/lib/init/template/approuter/files/cds.package.json +9 -0
  38. package/lib/init/template/approuter/files/cds.package.json.hbs +11 -0
  39. package/lib/init/template/approuter/files/index.html +1 -0
  40. package/lib/init/template/approuter/files/mta.yaml.hbs +35 -21
  41. package/lib/init/template/approuter/files/package.json +3 -0
  42. package/lib/init/template/approuter/files/xs-app.json.hbs +19 -0
  43. package/lib/init/template/approuter/index.js +47 -18
  44. package/lib/init/template/auditlog/index.js +5 -5
  45. package/lib/init/template/hana/files/java/cdsrc.json.hbs +7 -0
  46. package/lib/init/template/hana/files/java/profile.cdsrc.json.hbs +12 -0
  47. package/lib/init/template/hana/files/mta.yaml.hbs +10 -17
  48. package/lib/init/template/hana/files/nodejs/cds.package.json.hbs +9 -0
  49. package/lib/init/template/hana/files/nodejs/cds.profile.package.json.hbs +14 -0
  50. package/lib/init/template/hana/files/nodejs/dependencies.package.json +1 -1
  51. package/lib/init/template/hana/index.js +59 -85
  52. package/lib/init/template/java/index.js +5 -2
  53. package/lib/init/template/kibana-logging/files/cds.package.json +7 -0
  54. package/lib/init/template/kibana-logging/files/cds.profile.package.json.hbs +9 -0
  55. package/lib/init/template/kibana-logging/files/mta.yaml.hbs +13 -0
  56. package/lib/init/template/kibana-logging/index.js +64 -0
  57. package/lib/init/template/mta/files/mta.yaml.hbs +3 -8
  58. package/lib/init/template/mta/index.js +8 -2
  59. package/lib/init/template/mtx/files/cds.package.json +0 -12
  60. package/lib/init/template/mtx/files/cds.package.json.hbs +14 -0
  61. package/lib/init/template/mtx/files/java/.cdsrc.json +17 -0
  62. package/lib/init/template/mtx/files/java/package.json +43 -0
  63. package/lib/init/template/mtx/files/java/server.js +30 -0
  64. package/lib/init/template/mtx/files/mta.yaml.hbs +6 -6
  65. package/lib/init/template/mtx/index.js +41 -22
  66. package/lib/init/template/templateBase.js +4 -1
  67. package/lib/init/template/xsuaa/files/cds.cdsrc.json +7 -0
  68. package/lib/init/template/xsuaa/files/cds.cdsrc.json.hbs +9 -0
  69. package/lib/init/template/xsuaa/files/cds.package.json +1 -1
  70. package/lib/init/template/xsuaa/files/cds.package.json.hbs +11 -0
  71. package/lib/init/template/xsuaa/files/mta.yaml.hbs +2 -2
  72. package/lib/init/template/xsuaa/index.js +43 -27
  73. package/lib/init/types.d.ts +43 -19
  74. package/lib/init/util/fsUtil.js +15 -4
  75. package/lib/init/util/projectReader.js +21 -18
  76. package/lib/init/util/templateUtil.js +78 -28
  77. package/lib/util/exec.js +2 -2
  78. package/lib/watch/livereload-server.js +3 -0
  79. package/lib/watch/node-watch.js +8 -1
  80. package/npm-shrinkwrap.json +942 -1259
  81. package/package.json +3 -3
  82. package/lib/init/template/approuter/files/xs-app.json +0 -8
  83. package/lib/init/template/nodejs/files/.vscode/settings.json +0 -7
@@ -23,6 +23,7 @@ let actionImportToActionMap = new Multimap();
23
23
  let functionImportToFunctionMap = new Multimap();
24
24
  let validEdmDatatypes = ['Edm.DateTimeOffset'];
25
25
  let jsonEntityContainerName;
26
+ let entityTypes = [];
26
27
  const ignoreObjects = ['$Reference']; // add all the objects that needs to be ignored for parsing.
27
28
  const { warn } = require('@sap/cds/bin/utils/term');
28
29
 
@@ -56,6 +57,20 @@ const edmxncdsdatatype = {
56
57
  "Edm.DateTimeOffset_a" : "cds.Timestamp"
57
58
  };
58
59
 
60
+ function _initialize() {
61
+ unboundedActions = {};
62
+ boundedActions = {};
63
+ unboundedFunctions = {};
64
+ boundedFunctions = {};
65
+ entityTypes = [];
66
+ namespace = "";
67
+ complexTypes = {};
68
+ enumTypes = {};
69
+ typeDefinitions = {};
70
+ jsonEntityContainerName = "";
71
+
72
+ }
73
+
59
74
  function _isJson(edmx) {
60
75
  let isJson = false;
61
76
  try {
@@ -128,78 +143,82 @@ function _includeExternalNamespaceAnnotation(source,target){
128
143
  });
129
144
  }
130
145
 
131
- function _propertyWithItems(property) {
132
- let items = {};
133
- items["items"] = property;
134
- return items;
146
+ function _typeWithCollections(property, type, isCollection) {
147
+ if (isCollection === true) {
148
+ property.items = type;
149
+ } else {
150
+ Object.assign(property, type);
151
+ }
135
152
  }
136
153
 
137
154
  function generatePropertyCsn(propertyType, isPrimaryKey) {
138
155
  let property = {};
156
+ let typeProperties = {};
139
157
  if (isPrimaryKey) {
140
158
  property.key = true;
159
+ // primary key cannot be of type Collection
160
+ if (propertyType.$Collection)
161
+ throw new Error(messages.COLLECTION_IN_KEY);
141
162
  }
142
163
  _includeExternalNamespaceAnnotation(propertyType,property);
143
164
  // conditions have to be made
144
165
  if (propertyType.$MaxLength) {
145
166
  if (propertyType.$Type) {
146
- property.type = edmxncdsdatatype[propertyType.$Type + '_m'];
167
+ typeProperties.type = edmxncdsdatatype[propertyType.$Type + '_m'];
147
168
  } else {
148
- property.type = 'cds.String'; // if type is missing, then it is String type
169
+ typeProperties.type = 'cds.String'; // if type is missing, then it is String type
149
170
  }
150
- property.length = propertyType.$MaxLength;
171
+ typeProperties.length = propertyType.$MaxLength;
151
172
  } else if(_isValidDataType(propertyType.$Type)) {
152
173
  if(propertyType.$Precision && propertyType.$Precision > 0)
153
174
  {
154
- property.type = edmxncdsdatatype[propertyType.$Type + '_a'];
155
- property["@odata.precision"] = propertyType.$Precision;
175
+ typeProperties.type = edmxncdsdatatype[propertyType.$Type + '_a'];
176
+ typeProperties["@odata.precision"] = propertyType.$Precision;
156
177
  } else {
157
- property.type = edmxncdsdatatype[propertyType.$Type];
158
- property["@odata.precision"] = 0;
178
+ typeProperties.type = edmxncdsdatatype[propertyType.$Type];
179
+ typeProperties["@odata.precision"] = 0;
159
180
  }
160
181
  } else if (propertyType.$Precision && !_isValidDataType(propertyType.$Type)) {
161
- property.type = edmxncdsdatatype[propertyType.$Type + '_p'];
162
- property.precision = propertyType.$Precision;
182
+ typeProperties.type = edmxncdsdatatype[propertyType.$Type + '_p'];
183
+ typeProperties.precision = propertyType.$Precision;
163
184
  if (propertyType.$Scale && propertyType.$Scale == 'variable') {
164
- property.scale = propertyType.$Precision;
165
- property.precision = propertyType.$Precision * 2;
185
+ typeProperties.scale = propertyType.$Precision;
186
+ typeProperties.precision = propertyType.$Precision * 2;
166
187
  } else {
167
- property.scale = propertyType.$Scale;
188
+ typeProperties.scale = propertyType.$Scale;
168
189
  }
169
190
  } else if (edmxncdsdatatype[propertyType.$Type + "_a"]) {
170
- property.type = edmxncdsdatatype[propertyType.$Type + "_a"];
191
+ typeProperties.type = edmxncdsdatatype[propertyType.$Type + "_a"];
171
192
  } else if (propertyType.$Type) {
172
- property.type = edmxncdsdatatype[propertyType.$Type];
193
+ typeProperties.type = edmxncdsdatatype[propertyType.$Type];
173
194
  } else{
174
- property.type = 'cds.LargeString'; // if type is missing, then it is String type
195
+ typeProperties.type = 'cds.LargeString'; // if type is missing, then it is String type
175
196
  }
176
197
 
177
198
  if (edmxncdsdatatype[propertyType.$Type + '_a']) {
178
- property["@odata.type"] = propertyType.$Type;
199
+ typeProperties["@odata.type"] = propertyType.$Type;
179
200
  }
180
201
 
181
- if (propertyType.$Collection == true) {
182
- return _propertyWithItems(property);
183
- }
202
+ _typeWithCollections(property, typeProperties, propertyType.$Collection);
184
203
 
185
204
  return property;
186
205
  }
187
206
 
188
207
  function _generateComplexTypePropertyCsn(propertyType) {
189
208
  let property = {};
190
- property.type = propertyType.$Type;
191
- if (propertyType.$Collection == true) {
192
- return _propertyWithItems(property);
193
- }
209
+ let type = {type : propertyType.$Type}
210
+ _typeWithCollections(property, type, propertyType.$Collection);
211
+
194
212
  return property;
195
213
  }
196
214
 
197
215
  function _generateTypeDefinitionPropertyCsn(propertyType) {
198
216
  let property = {};
199
- property.type = propertyType.$Type;
200
- if (propertyType.$Collection == true) {
201
- return _propertyWithItems(property);
202
- }
217
+ let type = {type : propertyType.$Type}
218
+
219
+ _includeExternalNamespaceAnnotation(propertyType,property);
220
+ _typeWithCollections(property, type, propertyType.$Collection);
221
+
203
222
  return property;
204
223
  }
205
224
 
@@ -267,7 +286,17 @@ function _parseAssociationProperty(foreignReference, associationNode, mockServer
267
286
  return associationProperty;
268
287
  }
269
288
 
270
- function _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServerUc) {
289
+ function _getBaseTypeEntityName(baseType) {
290
+ const mappedResult = entitySetToEntityTypeMap.get(baseType);
291
+ // if one entity type has mapping to multiple entity sets, use the first entity set
292
+ if (mappedResult.length > 1) {
293
+ return namespace + '.' + mappedResult[0];
294
+ } else {
295
+ return namespace + '.' + mappedResult;
296
+ }
297
+ }
298
+
299
+ function _generateCSNForEntityType(ignorePersistenceSkip, mockServerUc) {
271
300
  let entityCsn = {};
272
301
  let keySet;
273
302
  let curKey;
@@ -288,6 +317,10 @@ function _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServe
288
317
  // inheritance
289
318
  if (baseType) {
290
319
  entityCsn[key].includes = [];
320
+ // if the baseType has a mapping to an entity set use that
321
+ if (entitySetToEntityTypeMap && entitySetToEntityTypeMap.get(baseType)) {
322
+ baseType = _getBaseTypeEntityName(baseType);
323
+ }
291
324
  entityCsn[key].includes.push(baseType);
292
325
  }
293
326
  if (isAbstract) {
@@ -341,7 +374,7 @@ function _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServe
341
374
  return entityCsn;
342
375
  }
343
376
 
344
- function _generateEntityType(entityTypes, schemaData, mockServerUc) {
377
+ function _generateEntityType(schemaData, mockServerUc) {
345
378
  let entity = {};
346
379
  let temp;
347
380
  Object.keys(schemaData).forEach(entityType => {
@@ -381,19 +414,20 @@ function _generateEntityType(entityTypes, schemaData, mockServerUc) {
381
414
 
382
415
  function _parseEntityType(schemaDataList, ignorePersistenceSkip, mockServerUc) {
383
416
  // collect entity types
384
- let entityTypes = [];
385
417
  let schemaData;
386
418
  for (let i = 0; i < schemaDataList.length; i++) {
387
419
  schemaData = schemaDataList[i];
388
- _generateEntityType(entityTypes, schemaData, mockServerUc);
420
+ _generateEntityType(schemaData, mockServerUc);
389
421
  }
390
- return _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServerUc);
422
+ return _generateCSNForEntityType(ignorePersistenceSkip, mockServerUc);
391
423
  }
392
424
  function _parseEntityContainer(entityCSN, schemaData){
393
- Object.entries(schemaData[0]['EntityContainer']).forEach(entry => {
425
+ Object.entries(schemaData[0][jsonEntityContainerName]).forEach(entry => {
394
426
  if(entityCSN[namespace + '.' + entry[0]])
427
+ //Captured the annotations at entity set and entity type name level
395
428
  _includeExternalNamespaceAnnotation(entry[1],entityCSN[namespace + '.' + entry[0]]);
396
429
  if(entry[0].startsWith('@')){
430
+ //Captured the annotations at entity container name level
397
431
  entityCSN[namespace][entry[0]]= entry[1];
398
432
  }
399
433
  });
@@ -497,6 +531,10 @@ function _getDatatype(datatype) {
497
531
  if (namespace + "." + entitySetToEntityTypeMap.get(element) === datatype)
498
532
  type = datatype;
499
533
  }
534
+ entityTypes.forEach(entity =>{
535
+ if(entity[datatype])
536
+ type = datatype;
537
+ })
500
538
  }
501
539
 
502
540
  //will return undefined if type is not supported
@@ -546,8 +584,9 @@ function _parseBounded(csnDefs, flag) {
546
584
  for (let i = 1; i < obj[j].$Parameter.length; i++) {
547
585
  paramObj = obj[j].$Parameter[i];
548
586
  paramName = obj[j].$Parameter[i].$Name;
549
- let paramType ={};
550
- _includeExternalNamespaceAnnotation(paramObj,paramType);
587
+ let paramType = {};
588
+ let annotations = {};
589
+ _includeExternalNamespaceAnnotation(paramObj,annotations);
551
590
  //check if the parameter type is pre-defined, undefined or custom defined
552
591
  if (edmxncdsdatatype[paramObj.$Type] || edmxncdsdatatype[paramObj.$Type + "_a"])
553
592
  paramType = generatePropertyCsn(paramObj, false);
@@ -555,17 +594,23 @@ function _parseBounded(csnDefs, flag) {
555
594
  let type = _getDatatype(paramObj.$Type);
556
595
  if(type) paramType["type"] = type;
557
596
  }
558
- if (paramType.type || paramType.items.type) {
559
- // check if parameter type is a collection
560
- if (paramObj.$Collection && !paramType.items) {
561
- csnDefs[boundedEntityName].actions[name].params[paramName] = {};
562
- csnDefs[boundedEntityName].actions[name].params[paramName].items = paramType;
563
- } else
564
- csnDefs[boundedEntityName].actions[name].params[paramName] = paramType;
565
- } else {
597
+ if(Object.keys(paramType).length > 0)
598
+ {
599
+ if (paramType.type || paramType.items.type) {
600
+ // check if parameter type is a collection
601
+ if (paramObj.$Collection && !paramType.items) {
602
+ csnDefs[boundedEntityName].actions[name].params[paramName] = {};
603
+ csnDefs[boundedEntityName].actions[name].params[paramName].items = paramType;
604
+ } else
605
+ csnDefs[boundedEntityName].actions[name].params[paramName] = paramType;
606
+ }
607
+ }
608
+ else {
566
609
  let message = '"' + paramObj.$Type + '" is not supported (in element:"' + name + '")';
567
610
  console.log(warn(message));
568
611
  }
612
+ if(csnDefs[boundedEntityName].actions[name].params[paramName])
613
+ Object.assign(csnDefs[boundedEntityName].actions[name].params[paramName], annotations);
569
614
  }
570
615
  }
571
616
  }
@@ -575,26 +620,31 @@ function _parseBounded(csnDefs, flag) {
575
620
  }
576
621
  // add returns
577
622
  if (obj[j].$ReturnType) {
578
- let returnType={};
623
+ let returnType = {};
624
+ let annotations = {};
579
625
  // check if the return type is pre-defined, undefined or custom defined
580
626
  if (edmxncdsdatatype[obj[j].$ReturnType.$Type] || edmxncdsdatatype[obj[j].$ReturnType.$Type + "_a"])
581
627
  returnType = generatePropertyCsn(obj[j].$ReturnType, false);
582
628
  else {
583
629
  let type = _getDatatype(obj[j].$ReturnType.$Type);
584
- _includeExternalNamespaceAnnotation(obj[j].$ReturnType,returnType);
630
+ _includeExternalNamespaceAnnotation(obj[j].$ReturnType,annotations);
585
631
  if(type) returnType["type"] = type ;
586
632
  }
587
- if (returnType.type || returnType.items.type) {
588
- csnDefs[boundedEntityName].actions[name].returns = {};
589
- // check if return type is a collection
590
- if (obj[j].$ReturnType.$Collection && !returnType.items)
591
- csnDefs[boundedEntityName].actions[name].returns.items = returnType;
592
- else
593
- csnDefs[boundedEntityName].actions[name].returns = returnType;
594
- } else {
633
+ if(Object.keys(returnType).length > 0){
634
+ if (returnType.type || returnType.items.type) {
635
+ csnDefs[boundedEntityName].actions[name].returns = {};
636
+ // check if return type is a collection
637
+ if (obj[j].$ReturnType.$Collection && !returnType.items)
638
+ csnDefs[boundedEntityName].actions[name].returns.items = returnType;
639
+ else
640
+ csnDefs[boundedEntityName].actions[name].returns = returnType;
641
+ }
642
+ } else {
595
643
  let message = '"' + obj[j].$ReturnType.$Type + '" is not supported (in return type)';
596
644
  console.log(warn(message));
597
645
  }
646
+ if(csnDefs[boundedEntityName].actions[name].returns)
647
+ Object.assign(csnDefs[boundedEntityName].actions[name].returns, annotations)
598
648
  }
599
649
  }
600
650
  }
@@ -647,14 +697,14 @@ function _generateCSNForComplexType(schemaData) {
647
697
  if (!cTypes[element][property].$Type || edmxncdsdatatype[cTypes[element][property].$Type] || edmxncdsdatatype[cTypes[element][property].$Type + "_a"]) {
648
698
  propertyType = cTypes[element][property];
649
699
  complexCsn[element].elements[property] = generatePropertyCsn(propertyType, false);
700
+ } else if (complexTypes[cTypes[element][property].$Type]) {
701
+ propertyType = cTypes[element][property];
702
+ complexCsn[element].elements[property] = _generateComplexTypePropertyCsn(propertyType);
650
703
  } else {
651
- let message = '"' + cTypes[element][property].$Type + '" is not supported (in element:"' + property + '")';
704
+ let message = '"' + cTypes[element][property].$Type + '" is not supported (in element:"' + property + '")';
652
705
  console.log(warn(message));
653
706
  }
654
- } else if (complexTypes[cTypes[element][property].$Type]) {
655
- propertyType = cTypes[element][property];
656
- complexCsn[element].elements[property] = _generateComplexTypePropertyCsn(propertyType);
657
- } else if(property.startsWith("@")){
707
+ } else if (property.startsWith("@")) {
658
708
  complexCsn[element][property] = cTypes[element][property];
659
709
  }
660
710
  });
@@ -702,33 +752,33 @@ function _parseUnbounded(schemaData, flag) {
702
752
  _includeExternalNamespaceAnnotation(objData,obj[objType]);
703
753
  // add params
704
754
  if (objData.$Parameter && objData.$Parameter.length > 0) {
705
- obj[objType].params = {};
706
- let type = {};
755
+ obj[objType].params = {};
707
756
  for (let i = 0; i < objData.$Parameter.length; i++) {
708
- let typeProperties = {};
709
- _includeExternalNamespaceAnnotation(objData.$Parameter[i],typeProperties);
757
+ let paramType = {};
758
+ let annotations = {};
759
+ _includeExternalNamespaceAnnotation(objData.$Parameter[i], annotations);
710
760
  // check if the parameter type is pre-defined, undefined or custom defined
711
761
  if (edmxncdsdatatype[objData.$Parameter[i].$Type] || edmxncdsdatatype[objData.$Parameter[i].$Type + "_a"]) {
712
- const parameterProperties = generatePropertyCsn(objData.$Parameter[i], false);
713
- ({type, ...typeProperties} = parameterProperties);
762
+ paramType = generatePropertyCsn(objData.$Parameter[i],false)
714
763
  } else {
715
- type = _getDatatype(objData.$Parameter[i].$Type);
764
+ let type = _getDatatype(objData.$Parameter[i].$Type);
765
+ if(type) paramType["type"] = type;
716
766
  }
717
- if (type) {
718
- // Adds type properties like scale, precision, etc if any
719
- const parameterObj = Object.keys(typeProperties).length > 0 ? { type, ...typeProperties } : { type };
720
-
721
- // check if parameter type is a collection
722
- if (objData.$Parameter[i].$Collection && !parameterObj.items) {
723
- obj[objType].params[objData.$Parameter[i].$Name] = {};
724
- obj[objType].params[objData.$Parameter[i].$Name].items = parameterObj;
725
- } else
726
- obj[objType].params[objData.$Parameter[i].$Name] = parameterObj;
727
-
728
- } else {
767
+ if(Object.keys(paramType).length > 0){
768
+ if (paramType.type || paramType.items.type) {
769
+ // check if parameter type is a collection
770
+ if (objData.$Parameter[i].$Collection && !paramType.items) {
771
+ obj[objType].params[objData.$Parameter[i].$Name] = {};
772
+ obj[objType].params[objData.$Parameter[i].$Name].items = paramType;
773
+ } else
774
+ obj[objType].params[objData.$Parameter[i].$Name] = paramType;
775
+ }
776
+ }else {
729
777
  let message = '"' + objData.$Parameter[i].$Type + '" is not supported (in element:"' + temp + '")';
730
778
  console.log(warn(message));
731
779
  }
780
+ if(obj[objType].params[objData.$Parameter[i].$Name])
781
+ Object.assign(obj[objType].params[objData.$Parameter[i].$Name], annotations)
732
782
  }
733
783
  }
734
784
  //if parameters has no entries
@@ -738,26 +788,32 @@ function _parseUnbounded(schemaData, flag) {
738
788
  // add returns
739
789
  if (objData.$ReturnType && Object.keys(objData.$ReturnType).length > 0 && obj) {
740
790
  let returnValue = {};
791
+ let annotations = {};
741
792
  // check if the return type is pre-defined, undefined or custom defined
742
793
  if (edmxncdsdatatype[objData.$ReturnType.$Type] || edmxncdsdatatype[objData.$ReturnType.$Type + "_a"]) {
743
794
  returnValue = generatePropertyCsn(objData.$ReturnType, false);
744
795
  } else {
745
796
  let type = _getDatatype(objData.$ReturnType.$Type);
746
- _includeExternalNamespaceAnnotation(objData.$ReturnType,returnValue);
797
+ _includeExternalNamespaceAnnotation(objData.$ReturnType,annotations);
747
798
  if(type) returnValue["type"] = type;
748
799
  }
749
- if (returnValue.type || returnValue.items.type) {
750
- obj[objType].returns = {};
751
- // check if return type is a collection
752
- if (objData.$ReturnType.$Collection && !returnValue.items) {
753
- obj[objType].returns.items = {};
754
- obj[objType].returns.items = returnValue;
755
- } else
756
- obj[objType].returns = returnValue;
757
- } else {
800
+ if(Object.keys(returnValue).length > 0){
801
+ if (returnValue.type || returnValue.items.type) {
802
+ obj[objType].returns = {};
803
+ // check if return type is a collection
804
+ if (objData.$ReturnType.$Collection && !returnValue.items) {
805
+ obj[objType].returns.items = {};
806
+ obj[objType].returns.items = returnValue;
807
+ } else
808
+ obj[objType].returns = returnValue;
809
+ }
810
+ }
811
+ else {
758
812
  let message = '"' + objData.$ReturnType.$Type + '" is not supported (in return type of' + temp + ')';
759
813
  console.log(warn(message));
760
814
  }
815
+ if(obj[objType].returns)
816
+ Object.assign(obj[objType].returns, annotations);
761
817
  }
762
818
  }
763
819
  unboundedObj = Object.assign(unboundedObj, obj);
@@ -769,10 +825,6 @@ function _parseUnbounded(schemaData, flag) {
769
825
  function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc) {
770
826
  let csn = {};
771
827
  let schemaData = [];
772
- unboundedActions = {};
773
- boundedActions = {};
774
- unboundedFunctions = {};
775
- boundedFunctions = {};
776
828
  csn.meta = {};
777
829
  csn.meta.creator = 'cds-dk ' + versionInfo;
778
830
  csn.$version = '2.0';
@@ -825,12 +877,12 @@ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc) {
825
877
  // Step 1: get all complex types.
826
878
  csn.definitions = Object.assign(_generateCSNForComplexType(schemaData), csn.definitions);
827
879
  // Step 2: get all type definition
828
- csn.definitions = Object.assign(_parseTypeDefinition(), csn.definitions);
829
- // Step 3: get all unbounded action & function
880
+ csn.definitions = Object.assign(_parseTypeDefinition(), csn.definitions);
881
+ // Step 3: get all entity type
882
+ csn.definitions = Object.assign(_parseEntityType(schemaData, ignorePersistenceSkip, mockServerUc), csn.definitions);
883
+ // Step 4: get all unbounded action & function
830
884
  csn.definitions = Object.assign(_parseUnbounded(schemaData, 0), csn.definitions);
831
885
  csn.definitions = Object.assign(_parseUnbounded(schemaData , 1), csn.definitions);
832
- // Step 4: get all entity type
833
- csn.definitions = Object.assign(_parseEntityType(schemaData, ignorePersistenceSkip, mockServerUc), csn.definitions);
834
886
  // Step 5: add entity container properties
835
887
  csn.definitions = Object.assign(_parseEntityContainer(csn.definitions,schemaData),csn.definitions);
836
888
  // Step 6: get all bounded action & function
@@ -948,6 +1000,7 @@ function getEdmxv4CSN(edmx, ignorePersistenceSkip, mockServerUc, context) {
948
1000
  let csn;
949
1001
  let edmjConverted;
950
1002
  let name_space = []
1003
+ _initialize();
951
1004
  if(context.include_all_namespaces === true)
952
1005
  {
953
1006
  name_space.push(true);
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '1.21.0';
3
+ const MAVEN_ARCHETYPE_VERSION = '1.22.2';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
@@ -18,6 +18,7 @@ const constants = {
18
18
  OPTION_MTX: 'mtx',
19
19
  OPTION_AUDITLOG: 'auditlog',
20
20
  OPTION_APPROUTER: 'approuter',
21
+ OPTION_KIBANA_LOGGING: 'kibana-logging',
21
22
  OPTION_CF_MANIFEST: 'cf-manifest',
22
23
  OPTION_PIPELINE: 'pipeline',
23
24
  OPTION_SAMPLES: 'samples',
@@ -53,7 +54,9 @@ const constants = {
53
54
  PROJECT_FILES: ['package.json', 'pom.xml', '.cdsrc.json'],
54
55
 
55
56
  KIND_SQL: 'sql',
56
- KIND_HANA: 'hana'
57
+ KIND_HANA: 'hana',
58
+ KIND_HANA_CLOUD: 'hana-cloud',
59
+ KIND_HANA_MT: 'hana-mt'
57
60
  }
58
61
 
59
62
  constants.OPTIONS_PRIORITY = [
@@ -68,6 +71,7 @@ constants.OPTIONS_PRIORITY = [
68
71
  constants.OPTION_AUDITLOG,
69
72
  constants.OPTION_APPROUTER,
70
73
  constants.OPTION_SAMPLES,
74
+ constants.OPTION_KIBANA_LOGGING,
71
75
  constants.OPTION_NOTEBOOK,
72
76
  constants.OPTION_LINT,
73
77
  constants.OPTION_LINT_CUSTOM,
package/lib/init/index.js CHANGED
@@ -7,7 +7,7 @@ const Spinner = require('./util/spinner');
7
7
 
8
8
  const { OPTIONS_PRIORITY, COMMAND_ADD, COMMAND_INIT,
9
9
  // eslint-disable-next-line no-unused-vars
10
- OPTION_XSUAA, OPTION_AUDITLOG, OPTION_HANA, OPTION_MTA, OPTION_MTX, OPTION_APPROUTER,
10
+ OPTION_XSUAA, OPTION_AUDITLOG, OPTION_HANA, OPTION_MTA, OPTION_MTX, OPTION_APPROUTER, OPTION_KIBANA_LOGGING,
11
11
  OPTION_NODEJS, OPTION_JAVA,
12
12
  OPTION_PIPELINE, OPTION_SAMPLES, OPTION_CF_MANIFEST, PROJECT_FILES, REGEX_PROJECT_NAME } = require('./constants');
13
13
 
@@ -105,7 +105,8 @@ module.exports = class CDSGenerator {
105
105
  OPTION_PIPELINE,
106
106
  OPTION_CF_MANIFEST,
107
107
  OPTION_MTA,
108
- OPTION_SAMPLES
108
+ OPTION_SAMPLES,
109
+ OPTION_KIBANA_LOGGING
109
110
  ],
110
111
  multiple: true,
111
112
  promptOrder: 10 // used to identify ui prompts
@@ -60,6 +60,22 @@ const auditlog = {
60
60
  spaceBefore: true
61
61
  }
62
62
 
63
+ const kibanaLogging = {
64
+ ref: "cf-logging",
65
+ keyPath: ["resources"],
66
+ constraints: [{
67
+ comparisonKeyPath: ["type"],
68
+ value: "org.cloudfoundry.managed-service",
69
+ }, {
70
+ comparisonKeyPath: ["parameters", "service"],
71
+ value: "application-logs",
72
+ }, {
73
+ comparisonKeyPath: ["parameters", "service-plan"],
74
+ value: "lite",
75
+ }],
76
+ spaceBefore: true
77
+ }
78
+
63
79
  const hdbDeployer = {
64
80
  ref: "deployer",
65
81
  keyPath: ["modules"],
@@ -71,7 +87,7 @@ const hdbDeployer = {
71
87
  }
72
88
 
73
89
  const hdiContainer = {
74
- ref: "db-resource",
90
+ ref: "hdi-container-resource",
75
91
  keyPath: ["resources"],
76
92
  constraints: [{
77
93
  comparisonKeyPath: ["type"],
@@ -81,7 +97,7 @@ const hdiContainer = {
81
97
  }
82
98
 
83
99
  const serviceManager = {
84
- ref: "db-resource",
100
+ ref: "service-manager-resource",
85
101
  keyPath: ["resources"],
86
102
  constraints: [{
87
103
  comparisonKeyPath: ["type"],
@@ -131,9 +147,10 @@ const mtxSidecar = {
131
147
  comparisonKeyPath: ["type"],
132
148
  value: `nodejs`
133
149
  }],
150
+ spaceBefore: true
134
151
  }
135
152
 
136
- const mtxAPI = {
153
+ const providedMtxAPI = {
137
154
  ref: "provided-mtx-api",
138
155
  keyPath: ["provides"],
139
156
  constraints: [{
@@ -145,6 +162,59 @@ const mtxAPI = {
145
162
  }]
146
163
  }
147
164
 
165
+ const requiredMtxAPI = {
166
+ ref: "required-mtx-api",
167
+ in: approuter,
168
+ keyPath: ["requires"],
169
+ constraints: [{
170
+ comparisonKeyPath: ["properties", "name"],
171
+ value: "mtx-api"
172
+ }, {
173
+ comparisonKeyPath: ["properties", "url"],
174
+ value: "~{mtx-url}"
175
+ }]
176
+ }
177
+
178
+ const providedMtxSidecarAPI = {
179
+ ref: "provided-mtx-sidecar-api",
180
+ in: mtxSidecar,
181
+ keyPath: ["requires"],
182
+ constraints: [{
183
+ comparisonKeyPath: ["properties", "url"],
184
+ value: "${default-url}"
185
+ }]
186
+ }
187
+
188
+ const requiredMtxSidecarAPI = {
189
+ ref: "required-mtx-sidecar-api",
190
+ in: srvJava,
191
+ keyPath: ["requires"],
192
+ constraints: [{
193
+ comparisonKeyPath: ["properties", "CDS_MULTITENANCY_SIDECAR_URL"],
194
+ value: "~{url}"
195
+ }]
196
+ }
197
+
198
+ const requiredJavaApprouterAPI = {
199
+ ref: "required-java-approuter-api",
200
+ in: srvJava,
201
+ keyPath: ["requires"],
202
+ constraints: [{
203
+ comparisonKeyPath: ["properties", "CDS_MULTITENANCY_APPUI_URL"],
204
+ value: "~{url}"
205
+ }]
206
+ }
207
+
208
+ const providedJavaApprouterAPI = {
209
+ ref: "provided-java-approuter-api",
210
+ in: approuter,
211
+ keyPath: ["requires"],
212
+ constraints: [{
213
+ comparisonKeyPath: ["properties", "url"],
214
+ value: "${default-url}"
215
+ }]
216
+ }
217
+
148
218
  module.exports = {
149
219
  srvNode,
150
220
  srvJava,
@@ -157,5 +227,11 @@ module.exports = {
157
227
  saasRegistry,
158
228
  srvAPI,
159
229
  mtxSidecar,
160
- mtxAPI
230
+ providedMtxAPI,
231
+ requiredMtxAPI,
232
+ providedMtxSidecarAPI,
233
+ requiredMtxSidecarAPI,
234
+ requiredJavaApprouterAPI,
235
+ providedJavaApprouterAPI,
236
+ kibanaLogging
161
237
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "requires": {
3
+ "approuter": {
4
+ "kind": "cloudfoundry"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "requires": {
3
+ "[{{cap.for}}]": {
4
+ "approuter": {
5
+ "kind": "cloudfoundry"
6
+ }
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "cds": {
3
+ "requires": {
4
+ "approuter": {
5
+ "kind": "cloudfoundry"
6
+ }
7
+ }
8
+ }
9
+ }