@sap/cds-dk 4.8.2 → 4.9.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.
- package/CHANGELOG.md +54 -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/extend.js +5 -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/{package.json → db/package.json} +0 -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 +60 -86
- 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 +170 -148
- 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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const csdl2openapi = require('./csdl2openapi');
|
|
2
2
|
const cds = require('@sap/cds');
|
|
3
|
-
const { path4 } = cds.serve
|
|
4
3
|
|
|
5
4
|
module.exports = function processor(csn, options = {}) {
|
|
6
5
|
|
|
@@ -55,6 +54,6 @@ function servicePath(csdl, csn) {
|
|
|
55
54
|
if (csdl.$EntityContainer) {
|
|
56
55
|
const serviceName = csdl.$EntityContainer.replace(/\.[^.]+$/, '')
|
|
57
56
|
const service = csn.definitions[serviceName]
|
|
58
|
-
return path4(service)
|
|
57
|
+
return cds.service.path4 ? cds.service.path4(service) : cds.serve.path4(service)
|
|
59
58
|
}
|
|
60
59
|
}
|
package/lib/compile/to-xsuaa.js
CHANGED
|
@@ -3,7 +3,7 @@ const fs = require('fs')
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
5
5
|
const hardcoded = {
|
|
6
|
-
Scopes: ['system-user', 'authenticated-user', 'registered-user', 'identified-user', 'any'],
|
|
6
|
+
Scopes: ['system-user', 'authenticated-user', 'registered-user', 'identified-user', 'internal-user', 'any'],
|
|
7
7
|
Attributes: ['id', 'tenant', 'ext_attr']
|
|
8
8
|
}
|
|
9
9
|
|
package/lib/import/index.js
CHANGED
|
@@ -130,25 +130,32 @@ function _convertEDMXWithMultipleSchemas(edmx, multipleSchemas, namespace) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
async function edmx2csn(edmx, filename, context) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const namespace = (index > 0
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
const result = edmx.match(/EntityType="([^"]+)/);
|
|
134
|
+
const multipleSchemas = /(\s*<\/Schema>\s*<Schema [^>]*>)\s*/m;
|
|
135
|
+
if (!result) {
|
|
136
|
+
throw new Error(messages.MISSING_ENTITIES);
|
|
137
|
+
}
|
|
138
|
+
const index = result[1].lastIndexOf(".");
|
|
139
|
+
const namespace = (index > 0) ? result[1].substring(0, index) : result[1];
|
|
140
|
+
|
|
141
|
+
if (multipleSchemas.test(edmx)) {
|
|
142
|
+
edmx = _convertEDMXWithMultipleSchemas(edmx, multipleSchemas, namespace);
|
|
143
|
+
}
|
|
144
144
|
let csn = await generateCSN(edmx, false, true, context);
|
|
145
|
+
const regex = /^[\p{Letter}\p{Nl}_]{1}[_\p{Letter}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,127}$/gu
|
|
146
|
+
// Regex checks for this condition “A-B” must start with a letter or underscore, followed by at most 127 letters, underscores or digits in the fileName
|
|
145
147
|
if (filename) {
|
|
146
148
|
// Replace namespace by given filename in the csn file instead of edmx file
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
const re = RegExp(`([("/])${namespace}([/").])`, 'g');
|
|
150
|
+
let name = path.parse(filename).name;
|
|
151
|
+
if (!(name.match(regex))) { // check if the filename is in the right format with the regex if not replace unaccepted characters with underscore (_)
|
|
152
|
+
name = name.replace(/^[^a-z\p{Nl}_]/gui, '_');
|
|
153
|
+
name = name.replace(/[^a-z0-9_\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]/gui, '_');
|
|
154
|
+
}
|
|
155
|
+
const fn = `$1${name}$2`;
|
|
149
156
|
csn = csn.replace(re, fn);
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
}
|
|
158
|
+
return JSON.parse(csn);
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
async function _generateEDMX2JSON(edmx) {
|
package/lib/import/message.js
CHANGED
|
@@ -13,7 +13,9 @@ const messages = {
|
|
|
13
13
|
OUTPUT_FILE_MISMATCH: 'Specify the file extension that --as option supports.',
|
|
14
14
|
INVALID_AS_OPTION: 'For --as option, please specify one of these output file format [cds, csn, json].',
|
|
15
15
|
INCORRECT_EXTENSION: 'If --as option is not provided, then please provide either .json or .csn output file extension.',
|
|
16
|
-
INCORRECT_INPUT_NAMESPACES: 'Invalid value for --include-namespaces option. Specify namespaces as comma-separated list or "*"'
|
|
16
|
+
INCORRECT_INPUT_NAMESPACES: 'Invalid value for --include-namespaces option. Specify namespaces as comma-separated list or "*"',
|
|
17
|
+
MISSING_ASSOCIATION_SETS: 'Input file provided has missing Association Sets. Please check the edmx file.',
|
|
18
|
+
COLLECTION_IN_KEY: 'Key Property of an Entity cannot be of the type Collection.'
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
function getMessages() {
|
|
@@ -583,7 +583,7 @@ class Expression {
|
|
|
583
583
|
if(attrName)
|
|
584
584
|
attrName = attrName.replace(/-/g,'.');
|
|
585
585
|
let attribute;
|
|
586
|
-
if ((MetadataConverter.custom_namespace.includes(prefix)
|
|
586
|
+
if ((MetadataConverter.custom_namespace.includes(prefix) || MetadataConverter.custom_namespace.includes(true)) && attrName !== undefined)
|
|
587
587
|
attribute = "@" + prefix + "." + attrName;
|
|
588
588
|
else if (attrName === undefined)
|
|
589
589
|
attribute = "$" + prefix;
|
package/lib/import/v2parser.js
CHANGED
|
@@ -231,6 +231,8 @@ function _extractAllAssociations(associations) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
function _extractEntityFromNamespace(entityName) {
|
|
234
|
+
if (!entityName)
|
|
235
|
+
return;
|
|
234
236
|
let entityId = "";
|
|
235
237
|
let pos = entityName.lastIndexOf(".");
|
|
236
238
|
if (pos < 0) {
|
|
@@ -428,6 +430,11 @@ function _getServiceEntityProperty(
|
|
|
428
430
|
isCollection = 1;
|
|
429
431
|
}
|
|
430
432
|
|
|
433
|
+
//if primary key is of type Collection, an error is thrown
|
|
434
|
+
if (isKey && isCollection === 1) {
|
|
435
|
+
throw new Error(messages.COLLECTION_IN_KEY);
|
|
436
|
+
}
|
|
437
|
+
|
|
431
438
|
let cdsDataType = null;
|
|
432
439
|
let hasInvalidPrecision = false;
|
|
433
440
|
let propertyJson='';
|
|
@@ -657,24 +664,38 @@ function _parseParameter(parameter)
|
|
|
657
664
|
return csn;
|
|
658
665
|
}
|
|
659
666
|
|
|
660
|
-
function
|
|
667
|
+
function _checkParameterKey(parameter, entityKeysList){
|
|
668
|
+
if ( entityKeysList && (Object.values(entityKeysList).indexOf(parameter._attributes.Name) > -1)){
|
|
669
|
+
return true;
|
|
670
|
+
}
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
function _parseParametersFunctionImport(parameters, isBounded, entityKeysList) {
|
|
661
675
|
let csn = "";
|
|
662
676
|
let parameterCsn = "";
|
|
663
|
-
let i =
|
|
677
|
+
let i = 0;
|
|
664
678
|
if(parameters.length)
|
|
665
679
|
{
|
|
666
|
-
for(i;i<parameters.length;i++)
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
if(
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
680
|
+
for (i; i < parameters.length; i++) {
|
|
681
|
+
// check if the parameter is a key of the entity type or not
|
|
682
|
+
// If yes then that paramater is ignored in CSN
|
|
683
|
+
let isKey = _checkParameterKey(parameters[i], entityKeysList);
|
|
684
|
+
if (isKey == false) {
|
|
685
|
+
parameterCsn = _parseParameter(parameters[i]);
|
|
686
|
+
csn = csn + parameterCsn;
|
|
687
|
+
if (i !== parameters.length - 1 && parameterCsn != "") {
|
|
688
|
+
csn = csn + ",\n";
|
|
689
|
+
} else {
|
|
690
|
+
csn = csn + "\n";
|
|
691
|
+
}
|
|
674
692
|
}
|
|
675
693
|
}
|
|
676
694
|
} else {
|
|
677
|
-
|
|
695
|
+
let isKey = _checkParameterKey(parameters);
|
|
696
|
+
if (isKey === false) {
|
|
697
|
+
csn = csn + _parseParameter(parameters);
|
|
698
|
+
}
|
|
678
699
|
}
|
|
679
700
|
|
|
680
701
|
if (csn && (csn.endsWith(",\n") || csn.endsWith(",\n\n"))) {
|
|
@@ -683,7 +704,7 @@ function _parseParametersFunctionImport(parameters, isBounded) {
|
|
|
683
704
|
return csn;
|
|
684
705
|
}
|
|
685
706
|
|
|
686
|
-
function _getFunctionImport(functionImport,isBounded) {
|
|
707
|
+
function _getFunctionImport(functionImport,isBounded,entityKeysList) {
|
|
687
708
|
let noValue;
|
|
688
709
|
let csn = "";
|
|
689
710
|
csn = csn + '"' + functionImport[0] + '": { \n';
|
|
@@ -704,12 +725,12 @@ function _getFunctionImport(functionImport,isBounded) {
|
|
|
704
725
|
{
|
|
705
726
|
if(isBounded === 0 || (isBounded === 1 && functionImport[3] instanceof Array ))
|
|
706
727
|
{
|
|
707
|
-
let parametersCsn = _parseParametersFunctionImport(functionImport[3],isBounded);
|
|
728
|
+
let parametersCsn = _parseParametersFunctionImport(functionImport[3],isBounded,entityKeysList);
|
|
708
729
|
if(parametersCsn != "")
|
|
709
730
|
{
|
|
710
731
|
csn = csn + ", \n";
|
|
711
732
|
csn = csn + '"params": { \n';
|
|
712
|
-
csn = csn +
|
|
733
|
+
csn = csn + parametersCsn;
|
|
713
734
|
csn = csn + '\n }';
|
|
714
735
|
}
|
|
715
736
|
}
|
|
@@ -735,13 +756,13 @@ function _getFunctionImport(functionImport,isBounded) {
|
|
|
735
756
|
return csn;
|
|
736
757
|
}
|
|
737
758
|
|
|
738
|
-
function _getAllFunctionImports(functionImports,isBounded) {
|
|
759
|
+
function _getAllFunctionImports(functionImports,isBounded,entityKeysList) {
|
|
739
760
|
let functionImportsCSN = "";
|
|
740
761
|
let i;
|
|
741
762
|
let functionImportCSN = "";
|
|
742
763
|
for(i=0; i<functionImports.length;i++)
|
|
743
764
|
{
|
|
744
|
-
functionImportCSN = _getFunctionImport(functionImports[i],isBounded);
|
|
765
|
+
functionImportCSN = _getFunctionImport(functionImports[i],isBounded, entityKeysList);
|
|
745
766
|
functionImportsCSN = functionImportsCSN + functionImportCSN;
|
|
746
767
|
if(i!== functionImports.length - 1 && functionImportCSN !== "" ) {
|
|
747
768
|
functionImportsCSN = functionImportsCSN + ",\n";
|
|
@@ -1187,6 +1208,9 @@ function _getCSNAssociatedEntitySet(
|
|
|
1187
1208
|
mockServerUc
|
|
1188
1209
|
) {
|
|
1189
1210
|
let associationSet = allAssociationSets[relationshipName];
|
|
1211
|
+
if(associationSet === undefined) {
|
|
1212
|
+
throw new Error(messages.MISSING_ASSOCIATION_SETS);
|
|
1213
|
+
}
|
|
1190
1214
|
let associationName = associationSet.Name;
|
|
1191
1215
|
let entityName = _getAssociatedEntity(
|
|
1192
1216
|
associationSet.End,
|
|
@@ -1296,6 +1320,16 @@ function _generateCSNEntityNavigationProperties(
|
|
|
1296
1320
|
return csn;
|
|
1297
1321
|
}
|
|
1298
1322
|
|
|
1323
|
+
function _getBaseTypeEntityName(entityName, serviceNamespaceParam) {
|
|
1324
|
+
let baseTypeName;
|
|
1325
|
+
// if one entity type has mapping to multiple entity sets, use the first entity set
|
|
1326
|
+
if (allEntitySetMapMC[entityName]) {
|
|
1327
|
+
baseTypeName = serviceNamespaceParam + "." + allEntitySetMapMC[entityName][0];
|
|
1328
|
+
return baseTypeName;
|
|
1329
|
+
}
|
|
1330
|
+
return entityName;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1299
1333
|
function _constructServiceEntity(
|
|
1300
1334
|
serviceNamespaceParam,
|
|
1301
1335
|
entityName,
|
|
@@ -1318,10 +1352,7 @@ function _constructServiceEntity(
|
|
|
1318
1352
|
if (ignorePersistenceSkip === false) {
|
|
1319
1353
|
csnEntity = csnEntity + '"@cds.persistence.skip": true,\n';
|
|
1320
1354
|
}
|
|
1321
|
-
if (
|
|
1322
|
-
entityAttributes.Abstract &&
|
|
1323
|
-
entityAttributes.Abstract.toUpperCase() === "TRUE"
|
|
1324
|
-
) {
|
|
1355
|
+
if (entityAttributes.Abstract && entityAttributes.Abstract.toUpperCase() === "TRUE") {
|
|
1325
1356
|
csnEntity = csnEntity + '"abstract": true,\n';
|
|
1326
1357
|
}
|
|
1327
1358
|
|
|
@@ -1386,22 +1417,22 @@ function _constructServiceEntity(
|
|
|
1386
1417
|
csnEntity = csnEntity + "}\n";
|
|
1387
1418
|
|
|
1388
1419
|
if (entityAttributes.BaseType) {
|
|
1420
|
+
let baseTypeName = _getBaseTypeEntityName(entityAttributes.BaseType, serviceNamespaceParam);
|
|
1389
1421
|
csnEntity = csnEntity + ",\n";
|
|
1390
|
-
csnEntity =
|
|
1391
|
-
csnEntity + '"includes": ["' + entityAttributes.BaseType + '"]\n';
|
|
1422
|
+
csnEntity = csnEntity + '"includes": ["' + baseTypeName + '"]\n';
|
|
1392
1423
|
}
|
|
1393
1424
|
|
|
1394
1425
|
//if the function import is bounded to entitySet
|
|
1395
1426
|
if (allFunctionImportsMap[entityName])
|
|
1396
1427
|
{
|
|
1397
1428
|
csnEntity = csnEntity + ', \n "actions": {\n';
|
|
1398
|
-
csnEntity = csnEntity + _getAllFunctionImports(allFunctionImportsMap[entityName],1);
|
|
1429
|
+
csnEntity = csnEntity + _getAllFunctionImports(allFunctionImportsMap[entityName],1,entityKeysList);
|
|
1399
1430
|
csnEntity = csnEntity + "}";
|
|
1400
1431
|
}
|
|
1401
1432
|
else if (allFunctionImportsMap[_extractEntityFromNamespace(allEntitySetMap[entityName])]) //if the function import is bounded to entityType
|
|
1402
1433
|
{
|
|
1403
1434
|
csnEntity = csnEntity + ', \n "actions": {\n';
|
|
1404
|
-
csnEntity = csnEntity + _getAllFunctionImports(allFunctionImportsMap[_extractEntityFromNamespace(allEntitySetMap[entityName])],1);
|
|
1435
|
+
csnEntity = csnEntity + _getAllFunctionImports(allFunctionImportsMap[_extractEntityFromNamespace(allEntitySetMap[entityName])],1,entityKeysList);
|
|
1405
1436
|
csnEntity = csnEntity + "}";
|
|
1406
1437
|
}
|
|
1407
1438
|
|
|
@@ -1442,10 +1473,7 @@ function _parseServiceEntity(
|
|
|
1442
1473
|
entityPropertiesMap = [];
|
|
1443
1474
|
}
|
|
1444
1475
|
// No navigation properties in entity
|
|
1445
|
-
if (
|
|
1446
|
-
entityNavigationPropertiesMap === undefined ||
|
|
1447
|
-
entityNavigationPropertiesMap == null
|
|
1448
|
-
) {
|
|
1476
|
+
if (entityNavigationPropertiesMap === undefined || entityNavigationPropertiesMap == null) {
|
|
1449
1477
|
entityNavigationPropertiesMap = [];
|
|
1450
1478
|
}
|
|
1451
1479
|
// If inherited entity found
|
|
@@ -1467,16 +1495,9 @@ function _parseServiceEntity(
|
|
|
1467
1495
|
);
|
|
1468
1496
|
}
|
|
1469
1497
|
|
|
1470
|
-
function _getEntitesWithNamesFromEntitySets(
|
|
1471
|
-
serviceNamespaceParam,
|
|
1472
|
-
entityJson,
|
|
1473
|
-
mockServerUc
|
|
1474
|
-
) {
|
|
1498
|
+
function _getEntitesWithNamesFromEntitySets(serviceNamespaceParam, entityJson, mockServerUc) {
|
|
1475
1499
|
const getEntityName = mockServerUc
|
|
1476
|
-
? (entity) =>
|
|
1477
|
-
allEntitySetMapMC[
|
|
1478
|
-
serviceNamespaceParam + "." + _getEntityName(entity)
|
|
1479
|
-
]
|
|
1500
|
+
? (entity) => allEntitySetMapMC[serviceNamespaceParam + "." + _getEntityName(entity)]
|
|
1480
1501
|
: (entity) => [_getEntityName(entity)];
|
|
1481
1502
|
|
|
1482
1503
|
const isNameInEntitySet = mockServerUc
|
|
@@ -1495,27 +1516,36 @@ function _getEntitesWithNamesFromEntitySets(
|
|
|
1495
1516
|
return entityJson
|
|
1496
1517
|
.map((entity) => ({
|
|
1497
1518
|
entity,
|
|
1498
|
-
name: getEntityName(entity)
|
|
1519
|
+
name: getEntityName(entity)
|
|
1499
1520
|
}))
|
|
1500
1521
|
.filter((entityWithName) => getEntitySetNames(entityWithName));
|
|
1501
1522
|
}
|
|
1502
1523
|
|
|
1503
|
-
function
|
|
1524
|
+
function _getEntitesWithNamesFromEntityTypes(serviceNamespaceParam, entityJson) {
|
|
1525
|
+
let entities = [];
|
|
1526
|
+
// we are not making any decision here on the basis of mockserverUc variable as of now
|
|
1527
|
+
for (let i = 0; i < entityJson.length; i++) {
|
|
1528
|
+
let entity = _getEntityName(entityJson[i]);
|
|
1529
|
+
// if entity doesn't have any mapping with entity set,
|
|
1530
|
+
// then collect those entityType
|
|
1531
|
+
if (!allEntitySetMapMC[serviceNamespaceParam + "." + entity]) {
|
|
1532
|
+
entities.push( {
|
|
1533
|
+
entity: entityJson[i],
|
|
1534
|
+
name: [entity]
|
|
1535
|
+
} );
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
return entities;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
function _parsingServiceEntities(
|
|
1543
|
+
entitiesWithNames,
|
|
1504
1544
|
serviceNamespaceParam,
|
|
1505
|
-
entityJson = [],
|
|
1506
1545
|
ignorePersistenceSkip,
|
|
1507
1546
|
mockServerUc
|
|
1508
|
-
)
|
|
1509
|
-
|
|
1510
|
-
const entitiesWithNames = _getEntitesWithNamesFromEntitySets(
|
|
1511
|
-
serviceNamespaceParam,
|
|
1512
|
-
entities,
|
|
1513
|
-
mockServerUc
|
|
1514
|
-
);
|
|
1515
|
-
|
|
1516
|
-
if (entitiesWithNames.length) {
|
|
1517
|
-
return (
|
|
1518
|
-
entitiesWithNames.map((entityWithName) =>
|
|
1547
|
+
){
|
|
1548
|
+
return entitiesWithNames.map((entityWithName) =>
|
|
1519
1549
|
entityWithName.name.map((entityName) =>
|
|
1520
1550
|
_parseServiceEntity(
|
|
1521
1551
|
serviceNamespaceParam,
|
|
@@ -1524,11 +1554,37 @@ function _getServiceEntitites(
|
|
|
1524
1554
|
ignorePersistenceSkip,
|
|
1525
1555
|
mockServerUc
|
|
1526
1556
|
)
|
|
1527
|
-
)
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1557
|
+
).join("},") + "}"
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
function _getServiceEntitites(
|
|
1562
|
+
serviceNamespaceParam,
|
|
1563
|
+
entityJson = [],
|
|
1564
|
+
ignorePersistenceSkip,
|
|
1565
|
+
mockServerUc
|
|
1566
|
+
) {
|
|
1567
|
+
const entities = Array.isArray(entityJson) ? entityJson : [entityJson];
|
|
1568
|
+
let entitiesWithNames = []; // [0]-> entity set, [1]-> entity type
|
|
1569
|
+
let parsedEntities = []; // [0]-> entity set, [1]-> entity type
|
|
1570
|
+
|
|
1571
|
+
entitiesWithNames[0] = _getEntitesWithNamesFromEntitySets(serviceNamespaceParam, entities, mockServerUc);
|
|
1572
|
+
entitiesWithNames[1] = _getEntitesWithNamesFromEntityTypes(serviceNamespaceParam, entities);
|
|
1573
|
+
|
|
1574
|
+
for (let i = 0; i < 2; i++) {
|
|
1575
|
+
if (entitiesWithNames[i].length) {
|
|
1576
|
+
parsedEntities[i] = _parsingServiceEntities(entitiesWithNames[i],
|
|
1577
|
+
serviceNamespaceParam, ignorePersistenceSkip, mockServerUc);
|
|
1578
|
+
}
|
|
1531
1579
|
}
|
|
1580
|
+
// if entities from entity set and entity type both are parsed
|
|
1581
|
+
if (parsedEntities[0] && parsedEntities[1])
|
|
1582
|
+
return parsedEntities[0].concat(parsedEntities[1]);
|
|
1583
|
+
else if (parsedEntities[0] && !parsedEntities[1])
|
|
1584
|
+
return parsedEntities[0];
|
|
1585
|
+
else if (!parsedEntities[0] && parsedEntities[1])
|
|
1586
|
+
return parsedEntities[1];
|
|
1587
|
+
|
|
1532
1588
|
return "";
|
|
1533
1589
|
}
|
|
1534
1590
|
|
|
@@ -1606,7 +1662,7 @@ function _generateEDMXJSON2CSN(
|
|
|
1606
1662
|
//if there are unbounded function imports
|
|
1607
1663
|
if(Object.keys(allFunctionImports).length > 0)
|
|
1608
1664
|
{
|
|
1609
|
-
definitions.push(_getAllFunctionImports(allFunctionImports,0)); //passing 0 for unbounded actions/functions
|
|
1665
|
+
definitions.push(_getAllFunctionImports(allFunctionImports,0,0)); //passing 0 for unbounded actions/functions and 0 for entityKeysList
|
|
1610
1666
|
}
|
|
1611
1667
|
|
|
1612
1668
|
if (entityJson) {
|