@sap/cds-dk 4.8.2 → 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.
- package/CHANGELOG.md +37 -0
- package/bin/activate.js +8 -7
- package/bin/bind.js +12 -12
- package/bin/build/all.js +3 -5
- package/bin/build/index.js +1 -1
- package/bin/cds.js +1 -1
- package/bin/deploy/index.js +7 -1
- package/bin/deploy/to-hana.js +5 -4
- package/bin/deploy/to-sqlite.js +2 -1
- package/bin/extend.js +5 -5
- package/bin/help.js +1 -0
- package/bin/import.js +45 -31
- package/bin/login.js +5 -6
- package/bin/logout.js +2 -2
- package/bin/parse.js +19 -0
- package/lib/bind/bindingUtil.js +41 -49
- package/lib/bind/cfKeyProvider.js +9 -17
- package/lib/bind/userCdsrcJsonStorageProvider.js +1 -0
- package/lib/client/activate.js +3 -2
- package/lib/client/auth_manager.js +1 -0
- package/lib/client/extend.js +6 -6
- package/lib/client/helper/fs_helper.js +8 -8
- package/lib/client/settings_manager.js +12 -9
- package/lib/compile/openapi/csdl2openapi.js +213 -165
- package/lib/compile/openapi/index.js +1 -2
- package/lib/compile/to-xsuaa.js +1 -1
- package/lib/import/index.js +22 -15
- package/lib/import/message.js +3 -1
- package/lib/import/utils/MetadataConverter.js +1 -1
- package/lib/import/v2parser.js +112 -56
- package/lib/import/v4parser.js +149 -98
- package/lib/init/constants.js +6 -2
- package/lib/init/index.js +3 -2
- package/lib/init/template/_merging/existences.js +80 -4
- package/lib/init/template/approuter/files/cds.cdsrc.json +7 -0
- package/lib/init/template/approuter/files/cds.cdsrc.json.hbs +9 -0
- package/lib/init/template/approuter/files/cds.package.json +9 -0
- package/lib/init/template/approuter/files/cds.package.json.hbs +11 -0
- package/lib/init/template/approuter/files/index.html +1 -0
- package/lib/init/template/approuter/files/mta.yaml.hbs +35 -21
- package/lib/init/template/approuter/files/package.json +3 -0
- package/lib/init/template/approuter/files/xs-app.json.hbs +19 -0
- package/lib/init/template/approuter/index.js +47 -18
- package/lib/init/template/auditlog/index.js +5 -5
- package/lib/init/template/hana/files/java/cdsrc.json.hbs +7 -0
- package/lib/init/template/hana/files/java/profile.cdsrc.json.hbs +12 -0
- package/lib/init/template/hana/files/mta.yaml.hbs +10 -17
- package/lib/init/template/hana/files/nodejs/cds.package.json.hbs +9 -0
- package/lib/init/template/hana/files/nodejs/cds.profile.package.json.hbs +14 -0
- package/lib/init/template/hana/files/nodejs/dependencies.package.json +1 -1
- package/lib/init/template/hana/index.js +59 -85
- package/lib/init/template/java/index.js +5 -2
- package/lib/init/template/kibana-logging/files/cds.package.json +7 -0
- package/lib/init/template/kibana-logging/files/cds.profile.package.json.hbs +9 -0
- package/lib/init/template/kibana-logging/files/mta.yaml.hbs +13 -0
- package/lib/init/template/kibana-logging/index.js +64 -0
- package/lib/init/template/mta/files/mta.yaml.hbs +3 -8
- package/lib/init/template/mta/index.js +8 -2
- package/lib/init/template/mtx/files/cds.package.json +0 -12
- package/lib/init/template/mtx/files/cds.package.json.hbs +14 -0
- package/lib/init/template/mtx/files/java/.cdsrc.json +17 -0
- package/lib/init/template/mtx/files/java/package.json +43 -0
- package/lib/init/template/mtx/files/java/server.js +30 -0
- package/lib/init/template/mtx/files/mta.yaml.hbs +6 -6
- package/lib/init/template/mtx/index.js +41 -22
- package/lib/init/template/templateBase.js +4 -1
- package/lib/init/template/xsuaa/files/cds.cdsrc.json +7 -0
- package/lib/init/template/xsuaa/files/cds.cdsrc.json.hbs +9 -0
- package/lib/init/template/xsuaa/files/cds.package.json +1 -1
- package/lib/init/template/xsuaa/files/cds.package.json.hbs +11 -0
- package/lib/init/template/xsuaa/files/mta.yaml.hbs +2 -2
- package/lib/init/template/xsuaa/index.js +43 -27
- package/lib/init/types.d.ts +43 -19
- package/lib/init/util/fsUtil.js +15 -4
- package/lib/init/util/projectReader.js +21 -18
- package/lib/init/util/templateUtil.js +78 -28
- package/lib/util/exec.js +2 -2
- package/lib/watch/livereload-server.js +3 -0
- package/lib/watch/node-watch.js +8 -1
- package/npm-shrinkwrap.json +88 -82
- package/package.json +3 -3
- package/lib/init/template/approuter/files/xs-app.json +0 -8
- package/lib/init/template/nodejs/files/.vscode/settings.json +0 -7
package/lib/import/v4parser.js
CHANGED
|
@@ -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
|
|
132
|
-
|
|
133
|
-
items
|
|
134
|
-
|
|
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
|
-
|
|
167
|
+
typeProperties.type = edmxncdsdatatype[propertyType.$Type + '_m'];
|
|
147
168
|
} else {
|
|
148
|
-
|
|
169
|
+
typeProperties.type = 'cds.String'; // if type is missing, then it is String type
|
|
149
170
|
}
|
|
150
|
-
|
|
171
|
+
typeProperties.length = propertyType.$MaxLength;
|
|
151
172
|
} else if(_isValidDataType(propertyType.$Type)) {
|
|
152
173
|
if(propertyType.$Precision && propertyType.$Precision > 0)
|
|
153
174
|
{
|
|
154
|
-
|
|
155
|
-
|
|
175
|
+
typeProperties.type = edmxncdsdatatype[propertyType.$Type + '_a'];
|
|
176
|
+
typeProperties["@odata.precision"] = propertyType.$Precision;
|
|
156
177
|
} else {
|
|
157
|
-
|
|
158
|
-
|
|
178
|
+
typeProperties.type = edmxncdsdatatype[propertyType.$Type];
|
|
179
|
+
typeProperties["@odata.precision"] = 0;
|
|
159
180
|
}
|
|
160
181
|
} else if (propertyType.$Precision && !_isValidDataType(propertyType.$Type)) {
|
|
161
|
-
|
|
162
|
-
|
|
182
|
+
typeProperties.type = edmxncdsdatatype[propertyType.$Type + '_p'];
|
|
183
|
+
typeProperties.precision = propertyType.$Precision;
|
|
163
184
|
if (propertyType.$Scale && propertyType.$Scale == 'variable') {
|
|
164
|
-
|
|
165
|
-
|
|
185
|
+
typeProperties.scale = propertyType.$Precision;
|
|
186
|
+
typeProperties.precision = propertyType.$Precision * 2;
|
|
166
187
|
} else {
|
|
167
|
-
|
|
188
|
+
typeProperties.scale = propertyType.$Scale;
|
|
168
189
|
}
|
|
169
190
|
} else if (edmxncdsdatatype[propertyType.$Type + "_a"]) {
|
|
170
|
-
|
|
191
|
+
typeProperties.type = edmxncdsdatatype[propertyType.$Type + "_a"];
|
|
171
192
|
} else if (propertyType.$Type) {
|
|
172
|
-
|
|
193
|
+
typeProperties.type = edmxncdsdatatype[propertyType.$Type];
|
|
173
194
|
} else{
|
|
174
|
-
|
|
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
|
-
|
|
199
|
+
typeProperties["@odata.type"] = propertyType.$Type;
|
|
179
200
|
}
|
|
180
201
|
|
|
181
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
|
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(
|
|
377
|
+
function _generateEntityType(schemaData, mockServerUc) {
|
|
345
378
|
let entity = {};
|
|
346
379
|
let temp;
|
|
347
380
|
Object.keys(schemaData).forEach(entityType => {
|
|
@@ -381,13 +414,12 @@ 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(
|
|
420
|
+
_generateEntityType(schemaData, mockServerUc);
|
|
389
421
|
}
|
|
390
|
-
return _generateCSNForEntityType(
|
|
422
|
+
return _generateCSNForEntityType(ignorePersistenceSkip, mockServerUc);
|
|
391
423
|
}
|
|
392
424
|
function _parseEntityContainer(entityCSN, schemaData){
|
|
393
425
|
Object.entries(schemaData[0][jsonEntityContainerName]).forEach(entry => {
|
|
@@ -499,6 +531,10 @@ function _getDatatype(datatype) {
|
|
|
499
531
|
if (namespace + "." + entitySetToEntityTypeMap.get(element) === datatype)
|
|
500
532
|
type = datatype;
|
|
501
533
|
}
|
|
534
|
+
entityTypes.forEach(entity =>{
|
|
535
|
+
if(entity[datatype])
|
|
536
|
+
type = datatype;
|
|
537
|
+
})
|
|
502
538
|
}
|
|
503
539
|
|
|
504
540
|
//will return undefined if type is not supported
|
|
@@ -548,8 +584,9 @@ function _parseBounded(csnDefs, flag) {
|
|
|
548
584
|
for (let i = 1; i < obj[j].$Parameter.length; i++) {
|
|
549
585
|
paramObj = obj[j].$Parameter[i];
|
|
550
586
|
paramName = obj[j].$Parameter[i].$Name;
|
|
551
|
-
let paramType ={};
|
|
552
|
-
|
|
587
|
+
let paramType = {};
|
|
588
|
+
let annotations = {};
|
|
589
|
+
_includeExternalNamespaceAnnotation(paramObj,annotations);
|
|
553
590
|
//check if the parameter type is pre-defined, undefined or custom defined
|
|
554
591
|
if (edmxncdsdatatype[paramObj.$Type] || edmxncdsdatatype[paramObj.$Type + "_a"])
|
|
555
592
|
paramType = generatePropertyCsn(paramObj, false);
|
|
@@ -557,17 +594,23 @@ function _parseBounded(csnDefs, flag) {
|
|
|
557
594
|
let type = _getDatatype(paramObj.$Type);
|
|
558
595
|
if(type) paramType["type"] = type;
|
|
559
596
|
}
|
|
560
|
-
if
|
|
561
|
-
|
|
562
|
-
if (
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
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 {
|
|
568
609
|
let message = '"' + paramObj.$Type + '" is not supported (in element:"' + name + '")';
|
|
569
610
|
console.log(warn(message));
|
|
570
611
|
}
|
|
612
|
+
if(csnDefs[boundedEntityName].actions[name].params[paramName])
|
|
613
|
+
Object.assign(csnDefs[boundedEntityName].actions[name].params[paramName], annotations);
|
|
571
614
|
}
|
|
572
615
|
}
|
|
573
616
|
}
|
|
@@ -577,26 +620,31 @@ function _parseBounded(csnDefs, flag) {
|
|
|
577
620
|
}
|
|
578
621
|
// add returns
|
|
579
622
|
if (obj[j].$ReturnType) {
|
|
580
|
-
let returnType={};
|
|
623
|
+
let returnType = {};
|
|
624
|
+
let annotations = {};
|
|
581
625
|
// check if the return type is pre-defined, undefined or custom defined
|
|
582
626
|
if (edmxncdsdatatype[obj[j].$ReturnType.$Type] || edmxncdsdatatype[obj[j].$ReturnType.$Type + "_a"])
|
|
583
627
|
returnType = generatePropertyCsn(obj[j].$ReturnType, false);
|
|
584
628
|
else {
|
|
585
629
|
let type = _getDatatype(obj[j].$ReturnType.$Type);
|
|
586
|
-
_includeExternalNamespaceAnnotation(obj[j].$ReturnType,
|
|
630
|
+
_includeExternalNamespaceAnnotation(obj[j].$ReturnType,annotations);
|
|
587
631
|
if(type) returnType["type"] = type ;
|
|
588
632
|
}
|
|
589
|
-
if
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
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 {
|
|
597
643
|
let message = '"' + obj[j].$ReturnType.$Type + '" is not supported (in return type)';
|
|
598
644
|
console.log(warn(message));
|
|
599
645
|
}
|
|
646
|
+
if(csnDefs[boundedEntityName].actions[name].returns)
|
|
647
|
+
Object.assign(csnDefs[boundedEntityName].actions[name].returns, annotations)
|
|
600
648
|
}
|
|
601
649
|
}
|
|
602
650
|
}
|
|
@@ -649,14 +697,14 @@ function _generateCSNForComplexType(schemaData) {
|
|
|
649
697
|
if (!cTypes[element][property].$Type || edmxncdsdatatype[cTypes[element][property].$Type] || edmxncdsdatatype[cTypes[element][property].$Type + "_a"]) {
|
|
650
698
|
propertyType = cTypes[element][property];
|
|
651
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);
|
|
652
703
|
} else {
|
|
653
|
-
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 + '")';
|
|
654
705
|
console.log(warn(message));
|
|
655
706
|
}
|
|
656
|
-
} else if (
|
|
657
|
-
propertyType = cTypes[element][property];
|
|
658
|
-
complexCsn[element].elements[property] = _generateComplexTypePropertyCsn(propertyType);
|
|
659
|
-
} else if(property.startsWith("@")){
|
|
707
|
+
} else if (property.startsWith("@")) {
|
|
660
708
|
complexCsn[element][property] = cTypes[element][property];
|
|
661
709
|
}
|
|
662
710
|
});
|
|
@@ -704,33 +752,33 @@ function _parseUnbounded(schemaData, flag) {
|
|
|
704
752
|
_includeExternalNamespaceAnnotation(objData,obj[objType]);
|
|
705
753
|
// add params
|
|
706
754
|
if (objData.$Parameter && objData.$Parameter.length > 0) {
|
|
707
|
-
obj[objType].params = {};
|
|
708
|
-
let type = {};
|
|
755
|
+
obj[objType].params = {};
|
|
709
756
|
for (let i = 0; i < objData.$Parameter.length; i++) {
|
|
710
|
-
let
|
|
711
|
-
|
|
757
|
+
let paramType = {};
|
|
758
|
+
let annotations = {};
|
|
759
|
+
_includeExternalNamespaceAnnotation(objData.$Parameter[i], annotations);
|
|
712
760
|
// check if the parameter type is pre-defined, undefined or custom defined
|
|
713
761
|
if (edmxncdsdatatype[objData.$Parameter[i].$Type] || edmxncdsdatatype[objData.$Parameter[i].$Type + "_a"]) {
|
|
714
|
-
|
|
715
|
-
({type, ...typeProperties} = parameterProperties);
|
|
762
|
+
paramType = generatePropertyCsn(objData.$Parameter[i],false)
|
|
716
763
|
} else {
|
|
717
|
-
type = _getDatatype(objData.$Parameter[i].$Type);
|
|
764
|
+
let type = _getDatatype(objData.$Parameter[i].$Type);
|
|
765
|
+
if(type) paramType["type"] = type;
|
|
718
766
|
}
|
|
719
|
-
if
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
} 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 {
|
|
731
777
|
let message = '"' + objData.$Parameter[i].$Type + '" is not supported (in element:"' + temp + '")';
|
|
732
778
|
console.log(warn(message));
|
|
733
779
|
}
|
|
780
|
+
if(obj[objType].params[objData.$Parameter[i].$Name])
|
|
781
|
+
Object.assign(obj[objType].params[objData.$Parameter[i].$Name], annotations)
|
|
734
782
|
}
|
|
735
783
|
}
|
|
736
784
|
//if parameters has no entries
|
|
@@ -740,26 +788,32 @@ function _parseUnbounded(schemaData, flag) {
|
|
|
740
788
|
// add returns
|
|
741
789
|
if (objData.$ReturnType && Object.keys(objData.$ReturnType).length > 0 && obj) {
|
|
742
790
|
let returnValue = {};
|
|
791
|
+
let annotations = {};
|
|
743
792
|
// check if the return type is pre-defined, undefined or custom defined
|
|
744
793
|
if (edmxncdsdatatype[objData.$ReturnType.$Type] || edmxncdsdatatype[objData.$ReturnType.$Type + "_a"]) {
|
|
745
794
|
returnValue = generatePropertyCsn(objData.$ReturnType, false);
|
|
746
795
|
} else {
|
|
747
796
|
let type = _getDatatype(objData.$ReturnType.$Type);
|
|
748
|
-
_includeExternalNamespaceAnnotation(objData.$ReturnType,
|
|
797
|
+
_includeExternalNamespaceAnnotation(objData.$ReturnType,annotations);
|
|
749
798
|
if(type) returnValue["type"] = type;
|
|
750
799
|
}
|
|
751
|
-
if
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
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 {
|
|
760
812
|
let message = '"' + objData.$ReturnType.$Type + '" is not supported (in return type of' + temp + ')';
|
|
761
813
|
console.log(warn(message));
|
|
762
814
|
}
|
|
815
|
+
if(obj[objType].returns)
|
|
816
|
+
Object.assign(obj[objType].returns, annotations);
|
|
763
817
|
}
|
|
764
818
|
}
|
|
765
819
|
unboundedObj = Object.assign(unboundedObj, obj);
|
|
@@ -771,10 +825,6 @@ function _parseUnbounded(schemaData, flag) {
|
|
|
771
825
|
function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc) {
|
|
772
826
|
let csn = {};
|
|
773
827
|
let schemaData = [];
|
|
774
|
-
unboundedActions = {};
|
|
775
|
-
boundedActions = {};
|
|
776
|
-
unboundedFunctions = {};
|
|
777
|
-
boundedFunctions = {};
|
|
778
828
|
csn.meta = {};
|
|
779
829
|
csn.meta.creator = 'cds-dk ' + versionInfo;
|
|
780
830
|
csn.$version = '2.0';
|
|
@@ -827,12 +877,12 @@ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc) {
|
|
|
827
877
|
// Step 1: get all complex types.
|
|
828
878
|
csn.definitions = Object.assign(_generateCSNForComplexType(schemaData), csn.definitions);
|
|
829
879
|
// Step 2: get all type definition
|
|
830
|
-
csn.definitions = Object.assign(_parseTypeDefinition(), csn.definitions);
|
|
831
|
-
// Step 3: get all
|
|
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
|
|
832
884
|
csn.definitions = Object.assign(_parseUnbounded(schemaData, 0), csn.definitions);
|
|
833
885
|
csn.definitions = Object.assign(_parseUnbounded(schemaData , 1), csn.definitions);
|
|
834
|
-
// Step 4: get all entity type
|
|
835
|
-
csn.definitions = Object.assign(_parseEntityType(schemaData, ignorePersistenceSkip, mockServerUc), csn.definitions);
|
|
836
886
|
// Step 5: add entity container properties
|
|
837
887
|
csn.definitions = Object.assign(_parseEntityContainer(csn.definitions,schemaData),csn.definitions);
|
|
838
888
|
// Step 6: get all bounded action & function
|
|
@@ -950,6 +1000,7 @@ function getEdmxv4CSN(edmx, ignorePersistenceSkip, mockServerUc, context) {
|
|
|
950
1000
|
let csn;
|
|
951
1001
|
let edmjConverted;
|
|
952
1002
|
let name_space = []
|
|
1003
|
+
_initialize();
|
|
953
1004
|
if(context.include_all_namespaces === true)
|
|
954
1005
|
{
|
|
955
1006
|
name_space.push(true);
|
package/lib/init/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
|
|
3
|
-
const MAVEN_ARCHETYPE_VERSION = '1.22.
|
|
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: "
|
|
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: "
|
|
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
|
|
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
|
-
|
|
230
|
+
providedMtxAPI,
|
|
231
|
+
requiredMtxAPI,
|
|
232
|
+
providedMtxSidecarAPI,
|
|
233
|
+
requiredMtxSidecarAPI,
|
|
234
|
+
requiredJavaApprouterAPI,
|
|
235
|
+
providedJavaApprouterAPI,
|
|
236
|
+
kibanaLogging
|
|
161
237
|
}
|