@sap/cds-dk 4.6.4 → 4.8.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 (74) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/bin/activate.js +5 -1
  3. package/bin/add.js +2 -1
  4. package/bin/bind.js +121 -48
  5. package/bin/cds.js +8 -0
  6. package/bin/env.js +0 -2
  7. package/bin/repl.js +5 -2
  8. package/bin/watch.js +10 -7
  9. package/lib/bind/bindingResolver.js +26 -14
  10. package/lib/bind/bindingUtil.js +144 -0
  11. package/lib/bind/cfKeyProvider.js +2 -80
  12. package/lib/bind/kubernetesCredentialsProvider.js +157 -0
  13. package/lib/bind/userCdsrcJsonStorageProvider.js +7 -7
  14. package/lib/client/activate.js +16 -13
  15. package/lib/client/base_command.js +5 -1
  16. package/lib/client/helper/cf_helper.js +5 -2
  17. package/lib/client/params.js +16 -2
  18. package/lib/client/settings_manager.js +15 -8
  19. package/lib/compile/openapi/csdl2openapi.js +6 -8
  20. package/lib/compile/to-xsuaa.js +0 -14
  21. package/lib/import/utils/MetadataConverter.js +6 -4
  22. package/lib/import/utils/MultiMap.js +1 -0
  23. package/lib/import/v2parser.js +150 -64
  24. package/lib/import/v4parser.js +118 -56
  25. package/lib/index.js +6 -5
  26. package/lib/init/constants.js +11 -5
  27. package/lib/init/index.js +14 -7
  28. package/lib/init/template/_merging/existences.js +161 -0
  29. package/lib/init/template/approuter/files/default-env.json +9 -0
  30. package/lib/init/template/approuter/files/mta.yaml.hbs +48 -0
  31. package/lib/init/template/approuter/files/package.json +9 -0
  32. package/lib/init/template/approuter/files/xs-app.json +8 -0
  33. package/lib/init/template/approuter/index.js +66 -0
  34. package/lib/init/template/auditlog/files/dependencies.package.json +5 -0
  35. package/lib/init/template/auditlog/files/mta.yaml.hbs +13 -0
  36. package/lib/init/template/auditlog/index.js +38 -0
  37. package/lib/init/template/cf-manifest/index.js +1 -1
  38. package/lib/init/template/data/index.js +18 -6
  39. package/lib/init/template/hana/files/common/undeploy.json +5 -0
  40. package/lib/init/template/hana/files/java/package.json +3 -0
  41. package/lib/init/template/hana/files/mta.yaml.hbs +42 -0
  42. package/lib/init/template/hana/files/nodejs/dependencies.package.json +5 -0
  43. package/lib/init/template/hana/index.js +53 -24
  44. package/lib/init/template/java/index.js +1 -5
  45. package/lib/init/template/lint/index.js +17 -1
  46. package/lib/init/template/mta/files/mta.yaml.hbs +27 -216
  47. package/lib/init/template/mta/index.js +25 -17
  48. package/lib/init/template/mtx/files/cds.package.json +24 -0
  49. package/lib/init/template/mtx/files/dependencies.package.json +5 -0
  50. package/lib/init/template/mtx/files/mta.yaml.hbs +74 -0
  51. package/lib/init/template/mtx/files/xs-security.json.hbs +23 -9
  52. package/lib/init/template/mtx/index.js +126 -29
  53. package/lib/init/template/templateBase.js +14 -0
  54. package/lib/init/template/xsuaa/files/cds.package.json +9 -0
  55. package/lib/init/template/xsuaa/files/dependencies.package.json +6 -0
  56. package/lib/init/template/xsuaa/files/mta.yaml.hbs +17 -0
  57. package/lib/init/template/xsuaa/index.js +75 -0
  58. package/lib/init/util/fsUtil.js +18 -4
  59. package/lib/init/util/logger.js +3 -1
  60. package/lib/init/util/mvnArchetypeUtil.js +3 -1
  61. package/lib/init/{template/mta → util}/projectReader.js +26 -11
  62. package/lib/init/util/templateUtil.js +267 -3
  63. package/lib/lint/Linter.js +1 -2
  64. package/lib/lint/io.js +3 -12
  65. package/lib/util/exec.d.ts +54 -0
  66. package/lib/util/exec.js +210 -0
  67. package/lib/watch/livereload-server.js +43 -31
  68. package/lib/watch/node-watch.js +46 -20
  69. package/lib/watch/open.js +1 -1
  70. package/npm-shrinkwrap.json +3382 -9106
  71. package/package.json +8 -9
  72. package/readme.md +1 -1
  73. package/lib/init/template/mtx/package/cds.package.json +0 -29
  74. package/lib/init/template/mtx/package/dependencies.package.json +0 -9
@@ -24,6 +24,8 @@ 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
+ const { warn } = require('@sap/cds/bin/utils/term');
28
+
27
29
  const MetadataConverterFactory = require('../import/utils/MetadataConverterFactory');
28
30
  const edmxncdsdatatype = {
29
31
  'Edm.String': 'cds.LargeString',
@@ -32,7 +34,7 @@ const edmxncdsdatatype = {
32
34
  'Edm.Int32': 'cds.Integer',
33
35
  'Edm.Int64': 'cds.Integer64',
34
36
  'Edm.Decimal': 'cds.DecimalFloat',
35
- 'Edm.DateTimeOffset': 'cds.Timestamp',
37
+ 'Edm.DateTimeOffset': 'cds.DateTime',
36
38
  'Edm.TimeOfDay': 'cds.Time',
37
39
  'Edm.Date': 'cds.Date',
38
40
  'Edm.Binary': 'cds.LargeBinary',
@@ -40,16 +42,18 @@ const edmxncdsdatatype = {
40
42
  'Edm.Byte': 'cds.Integer',
41
43
  'Edm.SByte': 'cds.Integer',
42
44
  'Edm.Double': 'cds.Double',
43
- 'Edm.Single': 'cds.DecimalFloat',
44
45
  // Special handling of data types
45
46
  'Edm.String_m': 'cds.String', // Max length
46
47
  'Edm.Decimal_p': 'cds.Decimal', // Precision, scale
47
- 'Edm.DateTime_f': 'cds.Date', // sap:display-format="Date"
48
- 'Edm.DateTimeOffset_f': 'cds.Date', // sap:display-format="Date"
48
+ //'Edm.DateTime_f': 'cds.Date', // sap:display-format="Date"
49
+ //'Edm.DateTimeOffset_f': 'cds.Date', // sap:display-format="Date"
49
50
  'Edm.Binary_m': 'cds.Binary', // Max Length
50
51
  'Edm.Byte_m': 'cds.Integer', // Max Length
51
- 'Edm.Double_p': 'cds.Double' // Precision, scale
52
-
52
+ 'Edm.Double_p': 'cds.Double', // Precision, scale
53
+ // Special handling with annotations
54
+ "Edm.Single_a": "cds.Double",
55
+ "Edm.Stream_a" : "cds.LargeBinary",
56
+ "Edm.DateTimeOffset_a" : "cds.Timestamp"
53
57
  };
54
58
 
55
59
  function _isJson(edmx) {
@@ -117,12 +121,19 @@ function _validateJSON(jsonObj) {
117
121
  }
118
122
 
119
123
  function _includeExternalNamespaceAnnotation(source,target){
120
- Object.entries(source).forEach(element =>{
121
- if(element[0].startsWith('@')){
124
+ Object.entries(source).forEach(element => {
125
+ if (element[0].startsWith('@')) {
122
126
  target[element[0]] = element[1];
123
- }
127
+ }
124
128
  });
125
129
  }
130
+
131
+ function _propertyWithItems(property) {
132
+ let items = {};
133
+ items["items"] = property;
134
+ return items;
135
+ }
136
+
126
137
  function generatePropertyCsn(propertyType, isPrimaryKey) {
127
138
  let property = {};
128
139
  if (isPrimaryKey) {
@@ -137,6 +148,15 @@ function generatePropertyCsn(propertyType, isPrimaryKey) {
137
148
  property.type = 'cds.String'; // if type is missing, then it is String type
138
149
  }
139
150
  property.length = propertyType.$MaxLength;
151
+ } else if(_isValidDataType(propertyType.$Type)) {
152
+ if(propertyType.$Precision && propertyType.$Precision > 0)
153
+ {
154
+ property.type = edmxncdsdatatype[propertyType.$Type + '_a'];
155
+ property["@odata.precision"] = propertyType.$Precision;
156
+ } else {
157
+ property.type = edmxncdsdatatype[propertyType.$Type];
158
+ property["@odata.precision"] = 0;
159
+ }
140
160
  } else if (propertyType.$Precision && !_isValidDataType(propertyType.$Type)) {
141
161
  property.type = edmxncdsdatatype[propertyType.$Type + '_p'];
142
162
  property.precision = propertyType.$Precision;
@@ -146,23 +166,40 @@ function generatePropertyCsn(propertyType, isPrimaryKey) {
146
166
  } else {
147
167
  property.scale = propertyType.$Scale;
148
168
  }
169
+ } else if (edmxncdsdatatype[propertyType.$Type + "_a"]) {
170
+ property.type = edmxncdsdatatype[propertyType.$Type + "_a"];
149
171
  } else if (propertyType.$Type) {
150
172
  property.type = edmxncdsdatatype[propertyType.$Type];
151
173
  } else{
152
174
  property.type = 'cds.LargeString'; // if type is missing, then it is String type
153
175
  }
176
+
177
+ if (edmxncdsdatatype[propertyType.$Type + '_a']) {
178
+ property["@odata.type"] = propertyType.$Type;
179
+ }
180
+
181
+ if (propertyType.$Collection == true) {
182
+ return _propertyWithItems(property);
183
+ }
184
+
154
185
  return property;
155
186
  }
156
187
 
157
188
  function _generateComplexTypePropertyCsn(propertyType) {
158
189
  let property = {};
159
190
  property.type = propertyType.$Type;
191
+ if (propertyType.$Collection == true) {
192
+ return _propertyWithItems(property);
193
+ }
160
194
  return property;
161
195
  }
162
196
 
163
197
  function _generateTypeDefinitionPropertyCsn(propertyType) {
164
198
  let property = {};
165
199
  property.type = propertyType.$Type;
200
+ if (propertyType.$Collection == true) {
201
+ return _propertyWithItems(property);
202
+ }
166
203
  return property;
167
204
  }
168
205
 
@@ -175,7 +212,8 @@ function _parseAssociationProperty(foreignReference, associationNode, mockServer
175
212
  let data;
176
213
  let ref;
177
214
  associationProperty.type = 'cds.Association';
178
- associationProperty.doc = 'Please add an ON condition\n';
215
+ // annotation for ON condition
216
+ associationProperty["@cds.ambiguous"] = 'missing on condition?';
179
217
  // associationProperty.target = associationNode.$Type;
180
218
  if (mockServerUc && entitySetToEntityTypeMap && entitySetToEntityTypeMap.get(associationNode.$Type)) {
181
219
  if (entitySetToEntityTypeMap.get(associationNode.$Type).length > 1) {
@@ -267,7 +305,7 @@ function _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServe
267
305
  for (j = 0; j < curKey.length; j++) {
268
306
  keySet.push(curKey[j]);
269
307
  }
270
- } else if (!element[key][property].$Type || edmxncdsdatatype[element[key][property].$Type]) {
308
+ } else if (!element[key][property].$Type || edmxncdsdatatype[element[key][property].$Type] || edmxncdsdatatype[element[key][property].$Type + "_a"]) {
271
309
  propertyType = element[key][property];
272
310
  if (keySet.includes(property)) {
273
311
  entityCsn[key].elements[property] = generatePropertyCsn(propertyType, true);
@@ -291,6 +329,9 @@ function _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServe
291
329
  // for TypeDefinitions
292
330
  propertyType = element[key][property];
293
331
  entityCsn[key].elements[property] = _generateTypeDefinitionPropertyCsn(propertyType);
332
+ } else {
333
+ let message = '"' + element[key][property].$Type + '" is not supported (in element:"' + property + '")';
334
+ console.log(warn(message));
294
335
  }
295
336
  }
296
337
  }
@@ -346,10 +387,18 @@ function _parseEntityType(schemaDataList, ignorePersistenceSkip, mockServerUc) {
346
387
  schemaData = schemaDataList[i];
347
388
  _generateEntityType(entityTypes, schemaData, mockServerUc);
348
389
  }
349
- // parse it
350
390
  return _generateCSNForEntityType(entityTypes, ignorePersistenceSkip, mockServerUc);
351
391
  }
352
-
392
+ function _parseEntityContainer(entityCSN, schemaData){
393
+ Object.entries(schemaData[0]['EntityContainer']).forEach(entry => {
394
+ if(entityCSN[namespace + '.' + entry[0]])
395
+ _includeExternalNamespaceAnnotation(entry[1],entityCSN[namespace + '.' + entry[0]]);
396
+ if(entry[0].startsWith('@')){
397
+ entityCSN[namespace][entry[0]]= entry[1];
398
+ }
399
+ });
400
+ return entityCSN;
401
+ }
353
402
  function _generateEnumType(schemaData) {
354
403
  let enumTypeDict = {};
355
404
  let temp;
@@ -500,53 +549,56 @@ function _parseBounded(csnDefs, flag) {
500
549
  let paramType ={};
501
550
  _includeExternalNamespaceAnnotation(paramObj,paramType);
502
551
  //check if the parameter type is pre-defined, undefined or custom defined
503
- if (edmxncdsdatatype[paramObj.$Type])
552
+ if (edmxncdsdatatype[paramObj.$Type] || edmxncdsdatatype[paramObj.$Type + "_a"])
504
553
  paramType = generatePropertyCsn(paramObj, false);
505
554
  else {
506
555
  let type = _getDatatype(paramObj.$Type);
507
556
  if(type) paramType["type"] = type;
508
557
  }
509
- if (paramType) {
558
+ if (paramType.type || paramType.items.type) {
510
559
  // check if parameter type is a collection
511
- if (paramObj.$Collection) {
560
+ if (paramObj.$Collection && !paramType.items) {
512
561
  csnDefs[boundedEntityName].actions[name].params[paramName] = {};
513
562
  csnDefs[boundedEntityName].actions[name].params[paramName].items = paramType;
514
563
  } else
515
564
  csnDefs[boundedEntityName].actions[name].params[paramName] = paramType;
565
+ } else {
566
+ let message = '"' + paramObj.$Type + '" is not supported (in element:"' + name + '")';
567
+ console.log(warn(message));
516
568
  }
517
- }
518
-
519
- }
569
+ }
520
570
  }
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;
571
+ }
572
+ //if parameters has no entries
573
+ if (csnDefs[boundedEntityName].actions[name].params && Object.keys(csnDefs[boundedEntityName].actions[name].params).length === 0) {
574
+ delete csnDefs[boundedEntityName].actions[name].params;
575
+ }
576
+ // add returns
577
+ if (obj[j].$ReturnType) {
578
+ let returnType={};
579
+ // check if the return type is pre-defined, undefined or custom defined
580
+ if (edmxncdsdatatype[obj[j].$ReturnType.$Type] || edmxncdsdatatype[obj[j].$ReturnType.$Type + "_a"])
581
+ returnType = generatePropertyCsn(obj[j].$ReturnType, false);
582
+ else {
583
+ let type = _getDatatype(obj[j].$ReturnType.$Type);
584
+ _includeExternalNamespaceAnnotation(obj[j].$ReturnType,returnType);
585
+ if(type) returnType["type"] = type ;
525
586
  }
526
- // add returns
527
- if (obj[j].$ReturnType) {
528
- let returnType={};
529
- // check if the return type is pre-defined, undefined or custom defined
530
- if (edmxncdsdatatype[obj[j].$ReturnType.$Type])
531
- returnType = generatePropertyCsn(obj[j].$ReturnType, false);
532
- else {
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;
544
- }
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 {
595
+ let message = '"' + obj[j].$ReturnType.$Type + '" is not supported (in return type)';
596
+ console.log(warn(message));
545
597
  }
546
598
  }
547
599
  }
548
600
  }
549
- );
601
+ });
550
602
  }
551
603
  }
552
604
 
@@ -592,9 +644,12 @@ function _generateCSNForComplexType(schemaData) {
592
644
  }
593
645
  Object.keys(cTypes[element]).forEach(property => { // cTypes[element][property].$Type.startsWith('Edm.')
594
646
  if (cTypes[element][property] instanceof Object) {
595
- if (!cTypes[element][property].$Type || edmxncdsdatatype[cTypes[element][property].$Type] ) {
647
+ if (!cTypes[element][property].$Type || edmxncdsdatatype[cTypes[element][property].$Type] || edmxncdsdatatype[cTypes[element][property].$Type + "_a"]) {
596
648
  propertyType = cTypes[element][property];
597
649
  complexCsn[element].elements[property] = generatePropertyCsn(propertyType, false);
650
+ } else {
651
+ let message = '"' + cTypes[element][property].$Type + '" is not supported (in element:"' + property + '")';
652
+ console.log(warn(message));
598
653
  }
599
654
  } else if (complexTypes[cTypes[element][property].$Type]) {
600
655
  propertyType = cTypes[element][property];
@@ -653,50 +708,55 @@ function _parseUnbounded(schemaData, flag) {
653
708
  let typeProperties = {};
654
709
  _includeExternalNamespaceAnnotation(objData.$Parameter[i],typeProperties);
655
710
  // check if the parameter type is pre-defined, undefined or custom defined
656
- if (edmxncdsdatatype[objData.$Parameter[i].$Type]) {
711
+ if (edmxncdsdatatype[objData.$Parameter[i].$Type] || edmxncdsdatatype[objData.$Parameter[i].$Type + "_a"]) {
657
712
  const parameterProperties = generatePropertyCsn(objData.$Parameter[i], false);
658
713
  ({type, ...typeProperties} = parameterProperties);
659
714
  } else {
660
715
  type = _getDatatype(objData.$Parameter[i].$Type);
661
716
  }
662
717
  if (type) {
663
-
664
718
  // Adds type properties like scale, precision, etc if any
665
719
  const parameterObj = Object.keys(typeProperties).length > 0 ? { type, ...typeProperties } : { type };
666
720
 
667
721
  // check if parameter type is a collection
668
- if (objData.$Parameter[i].$Collection)
722
+ if (objData.$Parameter[i].$Collection && !parameterObj.items) {
723
+ obj[objType].params[objData.$Parameter[i].$Name] = {};
669
724
  obj[objType].params[objData.$Parameter[i].$Name].items = parameterObj;
670
- else
725
+ } else
671
726
  obj[objType].params[objData.$Parameter[i].$Name] = parameterObj;
672
727
 
728
+ } else {
729
+ let message = '"' + objData.$Parameter[i].$Type + '" is not supported (in element:"' + temp + '")';
730
+ console.log(warn(message));
673
731
  }
674
732
  }
675
733
  }
676
734
  //if parameters has no entries
677
- if(obj[objType].params && Object.keys(obj[objType].params).length === 0)
678
- {
735
+ if (obj[objType].params && Object.keys(obj[objType].params).length === 0) {
679
736
  delete obj[objType].params;
680
737
  }
681
738
  // add returns
682
739
  if (objData.$ReturnType && Object.keys(objData.$ReturnType).length > 0 && obj) {
683
740
  let returnValue = {};
684
741
  // check if the return type is pre-defined, undefined or custom defined
685
- if (edmxncdsdatatype[objData.$ReturnType.$Type]) {
742
+ if (edmxncdsdatatype[objData.$ReturnType.$Type] || edmxncdsdatatype[objData.$ReturnType.$Type + "_a"]) {
686
743
  returnValue = generatePropertyCsn(objData.$ReturnType, false);
687
744
  } else {
688
745
  let type = _getDatatype(objData.$ReturnType.$Type);
689
746
  _includeExternalNamespaceAnnotation(objData.$ReturnType,returnValue);
690
747
  if(type) returnValue["type"] = type;
691
748
  }
692
- if (returnValue) {
749
+ if (returnValue.type || returnValue.items.type) {
693
750
  obj[objType].returns = {};
694
751
  // check if return type is a collection
695
- if (objData.$ReturnType.$Collection) {
752
+ if (objData.$ReturnType.$Collection && !returnValue.items) {
696
753
  obj[objType].returns.items = {};
697
754
  obj[objType].returns.items = returnValue;
698
755
  } else
699
756
  obj[objType].returns = returnValue;
757
+ } else {
758
+ let message = '"' + objData.$ReturnType.$Type + '" is not supported (in return type of' + temp + ')';
759
+ console.log(warn(message));
700
760
  }
701
761
  }
702
762
  }
@@ -771,10 +831,12 @@ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc) {
771
831
  csn.definitions = Object.assign(_parseUnbounded(schemaData , 1), csn.definitions);
772
832
  // Step 4: get all entity type
773
833
  csn.definitions = Object.assign(_parseEntityType(schemaData, ignorePersistenceSkip, mockServerUc), csn.definitions);
774
- // Step 5: get all bounded action & function
834
+ // Step 5: add entity container properties
835
+ csn.definitions = Object.assign(_parseEntityContainer(csn.definitions,schemaData),csn.definitions);
836
+ // Step 6: get all bounded action & function
775
837
  _parseBounded(csn.definitions, 0);
776
838
  _parseBounded(csn.definitions, 1);
777
- // Step 6: get all annotations
839
+ // Step 7: get all annotations
778
840
  _generateDocumentation(schemaData, csn.definitions);
779
841
 
780
842
  return JSON.stringify(csn, null, 4);
@@ -826,7 +888,7 @@ function _checkAnnotationTarget(annotation, cdsDefs , str, no_of_terms){
826
888
  _checkAnnotatationTerm(annotation,cdsDefs[path[0]],no_of_terms,str);
827
889
  } else{
828
890
  let path1 = path[1].split('/');
829
- if(cdsDefs[path[0]]){
891
+ if(cdsDefs[path[0]] && cdsDefs[path[0]]["params"]){
830
892
  _checkAnnotatationTerm(annotation,cdsDefs[path[0]]["params"][path1[1]],no_of_terms,str);
831
893
  }
832
894
  }
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const cds = require ('@sap/cds')
2
- const get_compile = Reflect.getOwnPropertyDescriptor(cds,'compile').get
2
+ const compile_desc = Reflect.getOwnPropertyDescriptor(cds,'compile')
3
3
 
4
4
  // extending cds to lazy-load additional submodules provided by cds-dk
5
5
  module.exports = Object.defineProperties (cds, {
@@ -9,10 +9,11 @@ module.exports = Object.defineProperties (cds, {
9
9
  compile: {enumerable:true, get:()=> {
10
10
  // lazy-extending cds.compile.to only when cds.compile getter is invoked
11
11
  // otherwise we might cause cds.env being invoked too early.
12
- const compile = get_compile.call(cds)
13
- Object.defineProperties (compile.to, {
14
- openapi: {enumerable:true, get:()=> require('./compile/openapi')}
15
- })
12
+ const compile = compile_desc.value || compile_desc.get.call(cds)
13
+ if (!Reflect.getOwnPropertyDescriptor(compile.to, 'openapi'))
14
+ Object.defineProperties (compile.to, {
15
+ openapi: {enumerable:true, get:()=> require('./compile/openapi')}
16
+ })
16
17
  return compile
17
18
  }},
18
19
  })
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const MAVEN_ARCHETYPE_VERSION = '1.20.3';
3
+ const MAVEN_ARCHETYPE_VERSION = '1.21.0';
4
4
 
5
5
  const constants = {
6
6
  IS_WIN: (os.platform() === 'win32'),
@@ -13,8 +13,11 @@ const constants = {
13
13
  OPTION_NODEJS: 'nodejs',
14
14
  OPTION_JAVA: 'java',
15
15
  OPTION_HANA: 'hana',
16
+ OPTION_XSUAA: 'xsuaa',
16
17
  OPTION_MTA: 'mta',
17
18
  OPTION_MTX: 'mtx',
19
+ OPTION_AUDITLOG: 'auditlog',
20
+ OPTION_APPROUTER: 'approuter',
18
21
  OPTION_CF_MANIFEST: 'cf-manifest',
19
22
  OPTION_PIPELINE: 'pipeline',
20
23
  OPTION_SAMPLES: 'samples',
@@ -41,7 +44,7 @@ const constants = {
41
44
  MAVEN_ARCHETYPE_HELP: `https://cap.cloud.sap/docs/java/development/#the-maven-archetype`,
42
45
  MAVEN_INSTALL_HELP: `https://maven.apache.org/install.html`,
43
46
  PYTHON: 'https://www.python.org/downloads/',
44
- PYTHON_PIP: 'https://packaging.python.org/guides/',
47
+ PYTHON_PIP: 'https://packaging.python.org/en/latest/guides/',
45
48
  VSCODE: 'https://code.visualstudio.com/',
46
49
  VSCODE_NBVIEWER: 'https://marketplace.visualstudio.com/items?itemName=ms-python.python',
47
50
  VSCODE_ESLINT: 'https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint'
@@ -56,11 +59,14 @@ const constants = {
56
59
  constants.OPTIONS_PRIORITY = [
57
60
  constants.OPTION_JAVA,
58
61
  constants.OPTION_NODEJS,
59
- constants.OPTION_HANA,
60
62
  constants.OPTION_PIPELINE,
61
- constants.OPTION_MTX,
62
- constants.OPTION_CF_MANIFEST,
63
63
  constants.OPTION_MTA,
64
+ constants.OPTION_CF_MANIFEST,
65
+ constants.OPTION_HANA,
66
+ constants.OPTION_XSUAA,
67
+ constants.OPTION_MTX,
68
+ constants.OPTION_AUDITLOG,
69
+ constants.OPTION_APPROUTER,
64
70
  constants.OPTION_SAMPLES,
65
71
  constants.OPTION_NOTEBOOK,
66
72
  constants.OPTION_LINT,
package/lib/init/index.js CHANGED
@@ -6,7 +6,9 @@ const term = require('../util/term');
6
6
  const Spinner = require('./util/spinner');
7
7
 
8
8
  const { OPTIONS_PRIORITY, COMMAND_ADD, COMMAND_INIT,
9
- OPTION_HANA, OPTION_JAVA, OPTION_MTA, OPTION_MTX, OPTION_NODEJS,
9
+ // eslint-disable-next-line no-unused-vars
10
+ OPTION_XSUAA, OPTION_AUDITLOG, OPTION_HANA, OPTION_MTA, OPTION_MTX, OPTION_APPROUTER,
11
+ OPTION_NODEJS, OPTION_JAVA,
10
12
  OPTION_PIPELINE, OPTION_SAMPLES, OPTION_CF_MANIFEST, PROJECT_FILES, REGEX_PROJECT_NAME } = require('./constants');
11
13
 
12
14
  module.exports = class CDSGenerator {
@@ -99,6 +101,7 @@ module.exports = class CDSGenerator {
99
101
  choices: [
100
102
  OPTION_JAVA,
101
103
  OPTION_HANA,
104
+ OPTION_XSUAA,
102
105
  OPTION_PIPELINE,
103
106
  OPTION_CF_MANIFEST,
104
107
  OPTION_MTA,
@@ -179,20 +182,22 @@ module.exports = class CDSGenerator {
179
182
  case COMMAND_INIT: {
180
183
  const relativeProjectPath = path.relative(this.cwd, this.projectPath);
181
184
  const folderName = (relativeProjectPath ? `.${path.sep}${relativeProjectPath}` : 'current folder');
182
- this.logger.log(`creating new project in ${folderName}`);
185
+ this.logger.log(`Creating new cap project in ${folderName}`);
183
186
  break;
184
187
  }
185
188
 
186
189
  case COMMAND_ADD:
187
- this.logger.log(`adding feature(s) to project in current folder`);
190
+ this.logger.log(`Adding feature(s) to project in current folder`);
188
191
  break;
189
192
 
190
193
  default:
191
194
  }
192
195
 
193
196
  if (this.options.force) {
194
- this.logger.log(`using '--force' ... existing files will be overwritten...!`);
197
+ this.logger.log(`Using '--force' ... existing files will be overwritten...!`);
195
198
  }
199
+
200
+ this.logger.log();
196
201
  }
197
202
 
198
203
  async _process() {
@@ -202,7 +207,7 @@ module.exports = class CDSGenerator {
202
207
  await this._fillTemplateList();
203
208
 
204
209
  for (const template of this.templateList) {
205
- const msg = `adding feature '${template.name}'...`;
210
+ const msg = `Adding feature '${template.name}'...`;
206
211
  if (this.logger.isDebug) {
207
212
  this.logger.log(msg);
208
213
  await template.run();
@@ -214,7 +219,7 @@ module.exports = class CDSGenerator {
214
219
  }
215
220
  }
216
221
 
217
- this.logger.log(`done.`);
222
+ this.logger.log(`Done adding features`);
218
223
  this.logger.log();
219
224
  }
220
225
 
@@ -264,12 +269,14 @@ module.exports = class CDSGenerator {
264
269
  for (const template of this.templateList) {
265
270
  await template.finalize();
266
271
  }
272
+
273
+ this.logger.log();
267
274
  }
268
275
 
269
276
  _showFiles() {
270
277
  const files = this.fsUtil.getTouchedFiles();
271
278
  if (files && files.length > 0) {
272
- this.logger.log(`added / changed files`);
279
+ this.logger.log(`Added / changed files`);
273
280
  for (const file of files) {
274
281
  this.logger.log(file);
275
282
  }
@@ -0,0 +1,161 @@
1
+ // This file describes so-called "modules" and "resources" commonly
2
+ // found in mta.yaml files.
3
+ // The following matchers contain the *required* constraints to
4
+ // identify a YAML node as a semantic equivalent of the matcher.
5
+
6
+ const srvNode = {
7
+ ref: "srv",
8
+ keyPath: ["modules"],
9
+ constraints: [{
10
+ comparisonKeyPath: ["type"],
11
+ value: "nodejs"
12
+ }],
13
+ }
14
+
15
+ const srvJava = {
16
+ ref: "srv",
17
+ keyPath: ["modules"],
18
+ constraints: [{
19
+ comparisonKeyPath: ["type"],
20
+ value: "java"
21
+ }],
22
+ }
23
+
24
+ const approuter = {
25
+ ref: "approuter",
26
+ keyPath: ["modules"],
27
+ constraints: [{
28
+ comparisonKeyPath: ["type"],
29
+ value: "approuter.nodejs"
30
+ }],
31
+ spaceBefore: true
32
+ }
33
+
34
+ const xsuaa = {
35
+ ref: "uaa-resource",
36
+ keyPath: ["resources"],
37
+ constraints: [{
38
+ comparisonKeyPath: ["type"],
39
+ value: "org.cloudfoundry.managed-service",
40
+ }, {
41
+ comparisonKeyPath: ["parameters", "service"],
42
+ value: "xsuaa",
43
+ }, {
44
+ comparisonKeyPath: ["parameters", "service-plan"],
45
+ value: "application"
46
+ }],
47
+ spaceBefore: true
48
+ }
49
+
50
+ const auditlog = {
51
+ ref: "auditlog-resource",
52
+ keyPath: ["resources"],
53
+ constraints: [{
54
+ comparisonKeyPath: ["type"],
55
+ value: "org.cloudfoundry.managed-service",
56
+ }, {
57
+ comparisonKeyPath: ["parameters", "service"],
58
+ value: "auditlog-api",
59
+ }],
60
+ spaceBefore: true
61
+ }
62
+
63
+ const hdbDeployer = {
64
+ ref: "deployer",
65
+ keyPath: ["modules"],
66
+ constraints: [{
67
+ comparisonKeyPath: ["type"],
68
+ value: "hdb"
69
+ }],
70
+ spaceBefore: true
71
+ }
72
+
73
+ const hdiContainer = {
74
+ ref: "db-resource",
75
+ keyPath: ["resources"],
76
+ constraints: [{
77
+ comparisonKeyPath: ["type"],
78
+ value: "com.sap.xs.hdi-container",
79
+ }],
80
+ spaceBefore: true
81
+ }
82
+
83
+ const serviceManager = {
84
+ ref: "db-resource",
85
+ keyPath: ["resources"],
86
+ constraints: [{
87
+ comparisonKeyPath: ["type"],
88
+ value: "org.cloudfoundry.managed-service",
89
+ }, {
90
+ comparisonKeyPath: ["parameters", "service"],
91
+ value: "service-manager",
92
+ }, {
93
+ comparisonKeyPath: ["parameters", "service-plan"],
94
+ value: "container"
95
+ }],
96
+ spaceBefore: true
97
+ }
98
+
99
+ const saasRegistry = {
100
+ ref: "registry-resource",
101
+ keyPath: ["resources"],
102
+ constraints: [{
103
+ comparisonKeyPath: ["type"],
104
+ value: "org.cloudfoundry.managed-service",
105
+ }, {
106
+ comparisonKeyPath: ["parameters", "service"],
107
+ value: "saas-registry",
108
+ }, {
109
+ comparisonKeyPath: ["parameters", "service-plan"],
110
+ value: "application"
111
+ }],
112
+ spaceBefore: true
113
+ }
114
+
115
+ const srvAPI = {
116
+ ref: "srvAPI",
117
+ keyPath: ["provides"],
118
+ constraints: [{
119
+ comparisonKeyPath: ["name"],
120
+ value: "srv-api"
121
+ }, {
122
+ comparisonKeyPath: ["properties", "srv-url"],
123
+ value: "${default-url}"
124
+ }]
125
+ }
126
+
127
+ const mtxSidecar = {
128
+ ref: "sidecar",
129
+ keyPath: ["modules"],
130
+ constraints: [{
131
+ comparisonKeyPath: ["type"],
132
+ value: `nodejs`
133
+ }],
134
+ }
135
+
136
+ const mtxAPI = {
137
+ ref: "provided-mtx-api",
138
+ keyPath: ["provides"],
139
+ constraints: [{
140
+ comparisonKeyPath: ["name"],
141
+ value: "mtx-api"
142
+ }, {
143
+ comparisonKeyPath: ["properties", "mtx-url"],
144
+ value: "${default-url}"
145
+ }]
146
+ }
147
+
148
+ module.exports = {
149
+ srvNode,
150
+ srvJava,
151
+ approuter,
152
+ xsuaa,
153
+ auditlog,
154
+ hdbDeployer,
155
+ hdiContainer,
156
+ serviceManager,
157
+ saasRegistry,
158
+ srvAPI,
159
+ mtxSidecar,
160
+ mtxAPI
161
+ }