@sap/cds-dk 7.0.2 → 7.1.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/bin/add.js +2 -2
- package/bin/bind.js +5 -7
- package/bin/build.js +2 -7
- package/bin/cds.js +6 -8
- package/bin/deploy/to-hana.js +1 -1
- package/bin/init.js +2 -2
- package/bin/subscribe.js +4 -4
- package/bin/unsubscribe.js +4 -4
- package/bin/upgrade.js +4 -4
- package/lib/bind/cfKeyProvider.js +10 -10
- package/lib/bind/index.js +4 -3
- package/lib/bind/userCdsrcJsonStorageProvider.js +2 -10
- package/lib/build/buildTaskEngine.js +9 -22
- package/lib/build/buildTaskFactory.js +18 -27
- package/lib/build/constants.js +16 -14
- package/lib/build/index.js +12 -3
- package/lib/build/provider/buildTaskProviderInternal.js +23 -15
- package/lib/build/provider/mtx/index.js +8 -2
- package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -6
- package/lib/build/provider/mtx-sidecar/index.js +13 -8
- package/lib/build/util.js +13 -0
- package/lib/client/activate.js +7 -7
- package/lib/client/auth_manager.js +5 -5
- package/lib/client/base_command.js +7 -10
- package/lib/client/extend.js +2 -2
- package/lib/client/helper/logging.js +7 -2
- package/lib/client/params.js +2 -3
- package/lib/client/pull.js +3 -3
- package/lib/client/push.js +3 -3
- package/lib/client/settings_manager.js +7 -8
- package/lib/client/tenant_action.js +3 -3
- package/lib/compile/asyncapi/components/messages/index.js +41 -18
- package/lib/compile/asyncapi/index.js +23 -2
- package/lib/deploy/to-hana/hana.js +1 -2
- package/lib/import/common.js +3 -0
- package/lib/import/message.js +2 -1
- package/lib/import/odata/metadataconverter/MetadataConverter.js +1 -0
- package/lib/import/odata/v4parser.js +85 -95
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +78 -73
- package/lib/init/template/approuter/index.js +3 -4
- package/lib/init/template/auditlog/index.js +3 -4
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +15 -23
- package/lib/init/template/cf-manifest/files/services-manifest.yml.hbs +22 -17
- package/lib/init/template/cf-manifest/index.js +2 -2
- package/lib/init/template/connectivity/index.js +2 -3
- package/lib/init/template/data/index.js +7 -8
- package/lib/init/template/destination/index.js +3 -5
- package/lib/init/template/enterprise-messaging/index.js +4 -5
- package/lib/init/template/enterprise-messaging-shared/index.js +3 -4
- package/lib/init/template/extensibility/index.js +2 -3
- package/lib/init/template/file-based-messaging/index.js +2 -2
- package/lib/init/template/hana/files/mta.yaml.hbs +1 -1
- package/lib/init/template/hana/index.js +39 -63
- package/lib/init/template/helm/index.js +15 -14
- package/lib/init/template/html5-repo/index.js +3 -7
- package/lib/init/template/java/index.js +3 -3
- package/lib/init/template/kibana/index.js +3 -4
- package/lib/init/template/lint/index.js +13 -13
- package/lib/init/template/mta/index.js +3 -2
- package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +1 -1
- package/lib/init/template/multitenancy/index.js +16 -37
- package/lib/init/template/nodejs/index.js +4 -6
- package/lib/init/template/pipeline/index.js +3 -4
- package/lib/init/template/redis-messaging/index.js +3 -4
- package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +1 -1
- package/lib/init/template/sample/files/app/browse/webapp/manifest.json +1 -1
- package/lib/init/template/sample/files/srv/admin-service.cds +1 -1
- package/lib/init/template/sample/files/srv/cat-service.cds +1 -1
- package/lib/init/template/sample/index.js +6 -5
- package/lib/init/template/sqlite/index.js +1 -1
- package/lib/init/template/templateBase.js +9 -19
- package/lib/init/template/tiny-sample/index.js +5 -5
- package/lib/init/template/toggles/index.js +1 -2
- package/lib/init/template/typer/files/xsconfig.json +0 -1
- package/lib/init/template/typer/index.js +1 -1
- package/lib/init/template/xsuaa/index.js +3 -4
- package/lib/init/util/indent.js +57 -0
- package/lib/init/util/merge.js +72 -16
- package/lib/init/util/mvn.js +40 -31
- package/lib/init/util/projectReader.js +52 -168
- package/lib/init/util/template.js +12 -11
- package/lib/init/util/xml.js +6 -6
- package/lib/util/cfUtil.js +1 -2
- package/lib/util/pruneAxiosErrors.js +22 -0
- package/lib/watch/open.js +6 -3
- package/npm-shrinkwrap.json +356 -309
- package/package.json +1 -2
- package/lib/client/helper/errors.js +0 -26
- package/lib/util/version.js +0 -27
|
@@ -82,7 +82,7 @@ const known_vocabularies = {
|
|
|
82
82
|
'com.sap.vocabularies.UI.v1': 'UI',
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
function _initialize(parserContext) {
|
|
85
|
+
function _initialize(parserContext, mockServerUc) {
|
|
86
86
|
parserContext.unboundedActions = {};
|
|
87
87
|
parserContext.unboundedFunctions = {};
|
|
88
88
|
parserContext.entityTypes = [];
|
|
@@ -103,8 +103,8 @@ function _initialize(parserContext) {
|
|
|
103
103
|
parserContext.entityToBoundedActions = {};
|
|
104
104
|
parserContext.entityToBoundedFunctions = {};
|
|
105
105
|
parserContext.entityContainerAnnotations = {};
|
|
106
|
+
parserContext.mockServerUc = mockServerUc;
|
|
106
107
|
}
|
|
107
|
-
|
|
108
108
|
function _isJson(edmx) {
|
|
109
109
|
let isJson = false;
|
|
110
110
|
try {
|
|
@@ -124,8 +124,8 @@ function _extractSchemaNameAndElementName(name) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* @param {String} fqName
|
|
128
|
-
* @param {String} schemaName
|
|
127
|
+
* @param {String} fqName
|
|
128
|
+
* @param {String} schemaName
|
|
129
129
|
* @param {Object} parserContext
|
|
130
130
|
* @returns index of schemaName in the schemaDataList
|
|
131
131
|
*/
|
|
@@ -155,31 +155,16 @@ function _resolveAliasedElementName(fqName, parserContext) {
|
|
|
155
155
|
return schemaName + '.' + elementName;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
function _collectPrimarySchemaContext(jsonObj, parserContext, importerContext) {
|
|
159
|
+
let jsonObjEntityContainer = jsonObj.$EntityContainer;
|
|
160
|
+
if (jsonObjEntityContainer) {
|
|
161
|
+
// scenario: Schema Namespace="A.B.C.D" & jsonObjEntityContainer is "A.B.C.D.EntityContainerName"
|
|
162
|
+
[parserContext.primarySchema, parserContext.entityContainerName] = _extractSchemaNameAndElementName(jsonObjEntityContainer);
|
|
163
|
+
// required for `--keep-namespace` scenario
|
|
164
|
+
importerContext.schemaNamespace = parserContext.primarySchema;
|
|
161
165
|
}
|
|
162
166
|
else {
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function _hasEntityContainer(jsonObj, parserContext, context) {
|
|
168
|
-
let jsonObjEntityContainer = jsonObj.$EntityContainer;
|
|
169
|
-
try {
|
|
170
|
-
if (jsonObjEntityContainer) {
|
|
171
|
-
// scenario: Schema Namespace="A.B.C.D" & jsonObjEntityContainer is "A.B.C.D.EntityContainerName"
|
|
172
|
-
[parserContext.primarySchema, parserContext.entityContainerName] = _extractSchemaNameAndElementName(jsonObjEntityContainer);
|
|
173
|
-
// required for `--keep-namespace` scenario
|
|
174
|
-
context.schemaNamespace = parserContext.primarySchema;
|
|
175
|
-
}
|
|
176
|
-
if (jsonObj[parserContext.primarySchema][parserContext.entityContainerName] &&
|
|
177
|
-
jsonObj[parserContext.primarySchema][parserContext.entityContainerName] instanceof Object
|
|
178
|
-
) {
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
} catch (err) {
|
|
182
|
-
throw new Error(messages.MISSING_ENTITY_CONTAINER);
|
|
167
|
+
parserContext.mockServerUc = false;
|
|
183
168
|
}
|
|
184
169
|
}
|
|
185
170
|
|
|
@@ -213,7 +198,7 @@ function _updateElementObjectForDefaultValue(dataTypeObj, defaultvalue) {
|
|
|
213
198
|
}
|
|
214
199
|
|
|
215
200
|
function _updateDataTypeObjectForMaxLength(dataTypeObj, propertyDataType, maxLength) {
|
|
216
|
-
const mappedValue = edmToCdsTypeMappingWithMaxLength[propertyDataType];
|
|
201
|
+
const mappedValue = edmToCdsTypeMappingWithMaxLength[propertyDataType];
|
|
217
202
|
|
|
218
203
|
if (mappedValue) {
|
|
219
204
|
dataTypeObj.type = mappedValue
|
|
@@ -301,7 +286,7 @@ function _resolveCoreTerm(annotationTerm, annotationTermObject, csnDefsTargetObj
|
|
|
301
286
|
if (annotationTerm === "@Core.Description" || annotationTerm === "@Core.LongDescription") {
|
|
302
287
|
// we don't capture `null` value for doc
|
|
303
288
|
if (annotationTermObject === null) return;
|
|
304
|
-
|
|
289
|
+
|
|
305
290
|
annotationTermObject = _replaceSpecialCharacters(annotationTermObject);
|
|
306
291
|
|
|
307
292
|
if (csnDefsTargetObject.doc) {
|
|
@@ -372,7 +357,7 @@ function _parseCapabilitiesTerm(annotationTerm, annotationTermObject, csnDefsTar
|
|
|
372
357
|
* For entries like:
|
|
373
358
|
* <Annotation Term="Capabilities.FilterFunctions"> <Collection> <String>eq</String> <String>ne</String> </Collection> </Annotation>
|
|
374
359
|
* <Annotation Term="Capabilities.DeleteRestrictions.Deletable" Bool="true"/>
|
|
375
|
-
*
|
|
360
|
+
*
|
|
376
361
|
* simply preserve the value as it is
|
|
377
362
|
*/
|
|
378
363
|
if (annotationTermObject instanceof Array || !(annotationTermObject instanceof Object)) {
|
|
@@ -433,8 +418,8 @@ function _parseAnnotationTerms(annotationTerm, annotationTermObject, csnDefsTarg
|
|
|
433
418
|
function _resolveAnotationTerm(schemaDataAnnotation, parserContext) {
|
|
434
419
|
// Case 1: We have the Namespace and Alias for the vocabulary
|
|
435
420
|
for (const [alias, namespace] of Object.entries(parserContext.vocabAliasToNamespace)) {
|
|
436
|
-
if (schemaDataAnnotation.includes(alias)) {
|
|
437
|
-
schemaDataAnnotation = schemaDataAnnotation.split(alias).join(known_vocabularies[namespace]);
|
|
421
|
+
if (schemaDataAnnotation.includes('@' + alias)) {
|
|
422
|
+
schemaDataAnnotation = schemaDataAnnotation.split('@' + alias).join('@' + known_vocabularies[namespace]);
|
|
438
423
|
}
|
|
439
424
|
}
|
|
440
425
|
/**
|
|
@@ -452,10 +437,10 @@ function _resolveAnotationTerm(schemaDataAnnotation, parserContext) {
|
|
|
452
437
|
|
|
453
438
|
/**
|
|
454
439
|
* Capture all the annotation cases withtin an Element
|
|
455
|
-
*
|
|
440
|
+
*
|
|
456
441
|
* UnKnown term: <Annotation Term="Org.OData.ASDF.V1.qwe"/>
|
|
457
442
|
* Known term: <Annotation Term="Org.OData.Measures.V1.Unit" String="Centimeters"/>
|
|
458
|
-
*
|
|
443
|
+
*
|
|
459
444
|
* if "--include-namespaces *" then we also capture for ABS and QWE
|
|
460
445
|
* <TypeDefinition Name="TD_2" UnderlyingType="Edm.Int32" ABS:asdf="testing" QWE:qwe="testing"/>
|
|
461
446
|
*/
|
|
@@ -536,7 +521,7 @@ function _getEntityTypeMappedName(entityType, parserContext) {
|
|
|
536
521
|
}
|
|
537
522
|
}
|
|
538
523
|
|
|
539
|
-
function _generateStructuredDataTypeCsn(dataType, propertyObject, isPrimaryKey, dataTypeKind, elementKind,
|
|
524
|
+
function _generateStructuredDataTypeCsn(dataType, propertyObject, isPrimaryKey, dataTypeKind, elementKind, parserContext) {
|
|
540
525
|
const dataTypeObj = {};
|
|
541
526
|
const isCollection = propertyObject.$Collection;
|
|
542
527
|
const nullable = propertyObject.$Nullable;
|
|
@@ -558,7 +543,7 @@ function _generateStructuredDataTypeCsn(dataType, propertyObject, isPrimaryKey,
|
|
|
558
543
|
}
|
|
559
544
|
|
|
560
545
|
// if dataTypeKind is EntityType, also check for mapped entity name
|
|
561
|
-
if (mockServerUc && dataTypeKind === 'EntityType') {
|
|
546
|
+
if (parserContext.mockServerUc && dataTypeKind === 'EntityType') {
|
|
562
547
|
// propertyDataType is resolved fully qualified name
|
|
563
548
|
if (parserContext.entityToEntitySetMap?.get(propertyDataType)) {
|
|
564
549
|
propertyDataType = _getEntityTypeMappedName(propertyDataType, parserContext);
|
|
@@ -578,9 +563,9 @@ function _generateStructuredDataTypeCsn(dataType, propertyObject, isPrimaryKey,
|
|
|
578
563
|
}
|
|
579
564
|
/**
|
|
580
565
|
* only Primitive type and EnumType can have DefaultValue facet as per documentation
|
|
581
|
-
* but compiler accepts it for TypeDefintion and ComplexType as well,
|
|
566
|
+
* but compiler accepts it for TypeDefintion and ComplexType as well,
|
|
582
567
|
* do we also need to handle it for TypeDefintion and ComplexType?
|
|
583
|
-
*
|
|
568
|
+
*
|
|
584
569
|
* For parameters, default value is added via OptionalParamter Annotation
|
|
585
570
|
*/
|
|
586
571
|
if (defaultvalue && dataTypeKind === 'EnumType' && elementKind === 'property') {
|
|
@@ -594,7 +579,7 @@ function _generateStructuredDataTypeCsn(dataType, propertyObject, isPrimaryKey,
|
|
|
594
579
|
return dataTypeObj;
|
|
595
580
|
}
|
|
596
581
|
|
|
597
|
-
function _parseAssociationProperty(foreignReference, associationNode,
|
|
582
|
+
function _parseAssociationProperty(foreignReference, associationNode, parserContext) {
|
|
598
583
|
const associationProperty = {};
|
|
599
584
|
let foreignKeys;
|
|
600
585
|
// var foreignReference = associationNode.$Type;
|
|
@@ -626,7 +611,7 @@ function _parseAssociationProperty(foreignReference, associationNode, mockServer
|
|
|
626
611
|
);
|
|
627
612
|
}
|
|
628
613
|
|
|
629
|
-
if (mockServerUc && entityTypeMapping) {
|
|
614
|
+
if (parserContext.mockServerUc && entityTypeMapping) {
|
|
630
615
|
if (entityTypeMapping.length > 1) {
|
|
631
616
|
for (let j = 0; j < entityTypeMapping.length; j++) {
|
|
632
617
|
if (entityTypeMapping[j] === foreignReference) {
|
|
@@ -712,7 +697,7 @@ function _checkIsStructureTypeAndReturnDataKind(dataType, contentObject, element
|
|
|
712
697
|
* @param {Object} elementObj
|
|
713
698
|
* @param {Object} parserContext
|
|
714
699
|
*/
|
|
715
|
-
function _parsePropertyContent(csnObj, elementObj,
|
|
700
|
+
function _parsePropertyContent(csnObj, elementObj, parserContext) {
|
|
716
701
|
let contentObj = {};
|
|
717
702
|
const isPrimaryKey = true;
|
|
718
703
|
let dataType, isPrimitiveType, keySet = [];
|
|
@@ -748,17 +733,17 @@ function _parsePropertyContent(csnObj, elementObj, mockServerUc, parserContext)
|
|
|
748
733
|
if (['EnumType', 'TypeDefinition'].includes(dataKind)) {
|
|
749
734
|
csnObj.elements[objKey] = _generateStructuredDataTypeCsn(dataType, contentObj,
|
|
750
735
|
(keySet.includes(dataType) ? isPrimaryKey : !isPrimaryKey),
|
|
751
|
-
dataKind, 'property',
|
|
736
|
+
dataKind, 'property', parserContext
|
|
752
737
|
);
|
|
753
738
|
}
|
|
754
739
|
else {
|
|
755
740
|
csnObj.elements[objKey] = _generateStructuredDataTypeCsn(dataType, contentObj,
|
|
756
|
-
!isPrimaryKey, dataKind, 'property',
|
|
741
|
+
!isPrimaryKey, dataKind, 'property', parserContext
|
|
757
742
|
);
|
|
758
743
|
}
|
|
759
744
|
}
|
|
760
745
|
else if (contentKind === 'NavigationProperty') {
|
|
761
|
-
csnObj.elements[objKey] = _parseAssociationProperty(objKey, elementObj[objKey],
|
|
746
|
+
csnObj.elements[objKey] = _parseAssociationProperty(objKey, elementObj[objKey], parserContext);
|
|
762
747
|
}
|
|
763
748
|
}
|
|
764
749
|
}
|
|
@@ -837,7 +822,7 @@ function _captureOpenTypes(fqName, csnObj, elementObj, isEntity, mockServerUc, p
|
|
|
837
822
|
}
|
|
838
823
|
}
|
|
839
824
|
|
|
840
|
-
function _generateCSNForEntityType(ignorePersistenceSkip,
|
|
825
|
+
function _generateCSNForEntityType(ignorePersistenceSkip, entityList, parserContext) {
|
|
841
826
|
const csnEntity = {};
|
|
842
827
|
let isEntity = true;
|
|
843
828
|
entityList.forEach(entityElement => {
|
|
@@ -851,12 +836,12 @@ function _generateCSNForEntityType(ignorePersistenceSkip, mockServerUc, entityLi
|
|
|
851
836
|
csnEntity[entityName]['@cds.persistence.skip'] = true;
|
|
852
837
|
}
|
|
853
838
|
|
|
854
|
-
_captureOpenTypes(entityName, csnEntity[entityName], entityElement[entityName], isEntity, mockServerUc, parserContext);
|
|
839
|
+
_captureOpenTypes(entityName, csnEntity[entityName], entityElement[entityName], isEntity, parserContext.mockServerUc, parserContext);
|
|
855
840
|
_captureAnnotationWithinElement(entityElement[entityName], csnEntity[entityName], parserContext);
|
|
856
841
|
|
|
857
842
|
csnEntity[entityName].elements = {};
|
|
858
843
|
|
|
859
|
-
_parsePropertyContent(csnEntity[entityName], entityElement[entityName],
|
|
844
|
+
_parsePropertyContent(csnEntity[entityName], entityElement[entityName], parserContext);
|
|
860
845
|
|
|
861
846
|
// needs to be checked if this is necessary
|
|
862
847
|
if (entityElement[entityName].$HasStream) {
|
|
@@ -871,7 +856,7 @@ function _generateCSNForEntityType(ignorePersistenceSkip, mockServerUc, entityLi
|
|
|
871
856
|
return csnEntity;
|
|
872
857
|
}
|
|
873
858
|
|
|
874
|
-
function _parseCSNForEntityType(schemaData, ignorePersistenceSkip,
|
|
859
|
+
function _parseCSNForEntityType(schemaData, ignorePersistenceSkip, parserContext) {
|
|
875
860
|
let entitiesList = [];
|
|
876
861
|
for (let fqName of parserContext.entityTypes) {
|
|
877
862
|
let entity = {};
|
|
@@ -884,10 +869,10 @@ function _parseCSNForEntityType(schemaData, ignorePersistenceSkip, mockServerUc,
|
|
|
884
869
|
}
|
|
885
870
|
}
|
|
886
871
|
|
|
887
|
-
return _generateCSNForEntityType(ignorePersistenceSkip,
|
|
872
|
+
return _generateCSNForEntityType(ignorePersistenceSkip, entitiesList, parserContext);
|
|
888
873
|
}
|
|
889
874
|
|
|
890
|
-
function _parseParameterAndReturnTypeContent(elementObject,
|
|
875
|
+
function _parseParameterAndReturnTypeContent(elementObject, parserContext) {
|
|
891
876
|
let dataType = elementObject.$Type;
|
|
892
877
|
const isPrimitiveType = dataType.startsWith('Edm') ? true : false;
|
|
893
878
|
const isPrimaryKey = true;
|
|
@@ -904,11 +889,11 @@ function _parseParameterAndReturnTypeContent(elementObject, mockServerUc, parser
|
|
|
904
889
|
// structured type
|
|
905
890
|
else {
|
|
906
891
|
const dataKind = _checkIsStructureTypeAndReturnDataKind(dataType, elementObject, 'parameter', parserContext);
|
|
907
|
-
return _generateStructuredDataTypeCsn(dataType, elementObject, !isPrimaryKey, dataKind, 'parameter',
|
|
892
|
+
return _generateStructuredDataTypeCsn(dataType, elementObject, !isPrimaryKey, dataKind, 'parameter', parserContext);
|
|
908
893
|
}
|
|
909
894
|
}
|
|
910
895
|
|
|
911
|
-
function _generateCSNForBoundedActionFunction(actionFunctionObject, kind,
|
|
896
|
+
function _generateCSNForBoundedActionFunction(actionFunctionObject, kind, parserContext) {
|
|
912
897
|
const csnObj = {};
|
|
913
898
|
const isBounded = actionFunctionObject.$IsBound;
|
|
914
899
|
const parameters = actionFunctionObject.$Parameter;
|
|
@@ -922,7 +907,7 @@ function _generateCSNForBoundedActionFunction(actionFunctionObject, kind, mockSe
|
|
|
922
907
|
|
|
923
908
|
for (let index = 0; index < parameters.length; index++) {
|
|
924
909
|
let isCollection = parameters[index].$Collection;
|
|
925
|
-
csnObj.params[parameters[index].$Name] = _parseParameterAndReturnTypeContent(parameters[index],
|
|
910
|
+
csnObj.params[parameters[index].$Name] = _parseParameterAndReturnTypeContent(parameters[index], parserContext);
|
|
926
911
|
/**
|
|
927
912
|
* binding parameter handling - only first parameter will contain the binding
|
|
928
913
|
* parameter information, so only make change to the first parameter information.
|
|
@@ -940,13 +925,13 @@ function _generateCSNForBoundedActionFunction(actionFunctionObject, kind, mockSe
|
|
|
940
925
|
}
|
|
941
926
|
}
|
|
942
927
|
if (returnType) {
|
|
943
|
-
csnObj.returns = _parseParameterAndReturnTypeContent(returnType,
|
|
928
|
+
csnObj.returns = _parseParameterAndReturnTypeContent(returnType, parserContext);
|
|
944
929
|
}
|
|
945
930
|
|
|
946
931
|
return csnObj;
|
|
947
932
|
}
|
|
948
933
|
|
|
949
|
-
function _parseBoundedActionFunction(schemaData, csnObj, kind,
|
|
934
|
+
function _parseBoundedActionFunction(schemaData, csnObj, kind, parserContext) {
|
|
950
935
|
const boundedObject = (kind === 'action') ? parserContext.entityToBoundedActions : parserContext.entityToBoundedFunctions;
|
|
951
936
|
|
|
952
937
|
Object.keys(boundedObject).forEach(fqEntityName => {
|
|
@@ -960,14 +945,14 @@ function _parseBoundedActionFunction(schemaData, csnObj, kind, mockServerUc, par
|
|
|
960
945
|
}
|
|
961
946
|
Object.keys(actionFunctionObjectList).forEach(actionFunctionName => {
|
|
962
947
|
csnObj[fqEntityName].actions[actionFunctionName] = _generateCSNForBoundedActionFunction(
|
|
963
|
-
actionFunctionObjectList[actionFunctionName], kind,
|
|
948
|
+
actionFunctionObjectList[actionFunctionName], kind, parserContext
|
|
964
949
|
);
|
|
965
950
|
});
|
|
966
951
|
}
|
|
967
952
|
});
|
|
968
953
|
}
|
|
969
954
|
|
|
970
|
-
function _parseUnBoundedActionFunction(schemaData, kind,
|
|
955
|
+
function _parseUnBoundedActionFunction(schemaData, kind, parserContext) {
|
|
971
956
|
const unBoundedObject = (kind === 'action') ? parserContext.unboundedActions : parserContext.unboundedFunctions;
|
|
972
957
|
const csnObj = {};
|
|
973
958
|
|
|
@@ -988,11 +973,11 @@ function _parseUnBoundedActionFunction(schemaData, kind, mockServerUc, parserCon
|
|
|
988
973
|
csnObj[fqName].params = {};
|
|
989
974
|
|
|
990
975
|
for (let paramObj of parameters) {
|
|
991
|
-
csnObj[fqName].params[paramObj.$Name] = _parseParameterAndReturnTypeContent(paramObj,
|
|
976
|
+
csnObj[fqName].params[paramObj.$Name] = _parseParameterAndReturnTypeContent(paramObj, parserContext);
|
|
992
977
|
}
|
|
993
978
|
}
|
|
994
979
|
if (returnType) {
|
|
995
|
-
csnObj[fqName].returns = _parseParameterAndReturnTypeContent(returnType,
|
|
980
|
+
csnObj[fqName].returns = _parseParameterAndReturnTypeContent(returnType, parserContext);
|
|
996
981
|
}
|
|
997
982
|
}
|
|
998
983
|
});
|
|
@@ -1000,7 +985,7 @@ function _parseUnBoundedActionFunction(schemaData, kind, mockServerUc, parserCon
|
|
|
1000
985
|
return csnObj;
|
|
1001
986
|
}
|
|
1002
987
|
|
|
1003
|
-
function _parserCSNForComplexType(schemaData,
|
|
988
|
+
function _parserCSNForComplexType(schemaData, parserContext) {
|
|
1004
989
|
const complexCsn = {};
|
|
1005
990
|
const isEntity = true;
|
|
1006
991
|
|
|
@@ -1014,9 +999,9 @@ function _parserCSNForComplexType(schemaData, mockServerUc, parserContext) {
|
|
|
1014
999
|
complexCsn[fqName]['@cds.external'] = true;
|
|
1015
1000
|
complexCsn[fqName].elements = {};
|
|
1016
1001
|
// inheritance handling
|
|
1017
|
-
_captureOpenTypes(fqName, complexCsn[fqName], complexObj, !isEntity, !mockServerUc, parserContext);
|
|
1002
|
+
_captureOpenTypes(fqName, complexCsn[fqName], complexObj, !isEntity, !parserContext.mockServerUc, parserContext);
|
|
1018
1003
|
_captureAnnotationWithinElement(complexObj, complexCsn[fqName], parserContext);
|
|
1019
|
-
_parsePropertyContent(complexCsn[fqName], complexObj,
|
|
1004
|
+
_parsePropertyContent(complexCsn[fqName], complexObj, parserContext);
|
|
1020
1005
|
}
|
|
1021
1006
|
}
|
|
1022
1007
|
// add @open annotations
|
|
@@ -1102,7 +1087,7 @@ function _resolveEntityContainerAnnotationTarget(targetPath, csnDefs, hasPropert
|
|
|
1102
1087
|
/**
|
|
1103
1088
|
* format: <schemaName_or_Alias><EntityContainerName>/<ContainerElement>
|
|
1104
1089
|
* <schemaName_or_Alias><EntityContainerName>/<ContainerElement>/...
|
|
1105
|
-
*
|
|
1090
|
+
*
|
|
1106
1091
|
* needs to be handled without 'EntityContainerName'
|
|
1107
1092
|
*/
|
|
1108
1093
|
if (hasProperty) {
|
|
@@ -1167,7 +1152,7 @@ function _resolveAnnotationTarget(targetPath, csnDefs, parserContext) {
|
|
|
1167
1152
|
const indexOfOpenBrace = targetPath.indexOf('(');
|
|
1168
1153
|
const hasPropOrParam = (indexOfSlash > 0);
|
|
1169
1154
|
let elemNameList, fqName;
|
|
1170
|
-
|
|
1155
|
+
|
|
1171
1156
|
// Case 1: Direct path
|
|
1172
1157
|
if (indexOfOpenBrace === -1 && indexOfSlash === -1) {
|
|
1173
1158
|
fqName = _resolveAliasedElementName(targetPath, parserContext);
|
|
@@ -1224,7 +1209,7 @@ function _parseEntityContainer(csnDefs, entityContainerElements, parserContext)
|
|
|
1224
1209
|
entityContainerElementNames.forEach(ecElement => {
|
|
1225
1210
|
if (entityContainerElements[ecElement] instanceof Object) {
|
|
1226
1211
|
let definitionRefName, kind;
|
|
1227
|
-
|
|
1212
|
+
|
|
1228
1213
|
if (entityContainerElements[ecElement].$Action) {
|
|
1229
1214
|
definitionRefName = entityContainerElements[ecElement].$Action;
|
|
1230
1215
|
kind = 'action';
|
|
@@ -1245,7 +1230,7 @@ function _parseEntityContainer(csnDefs, entityContainerElements, parserContext)
|
|
|
1245
1230
|
/**
|
|
1246
1231
|
* For now we don't support the collision between entitycontainer element name
|
|
1247
1232
|
* and any of the schema elemetents like entitytype, complextype, etc.
|
|
1248
|
-
* TODO: In future we might have to support it.
|
|
1233
|
+
* TODO: In future we might have to support it.
|
|
1249
1234
|
*/
|
|
1250
1235
|
if (csnDefs[fqElementName] && csnDefs[fqElementName].kind !== kind) {
|
|
1251
1236
|
throw new Error(messages.ELEMENT_NAME_COLLISION + ecElement);
|
|
@@ -1315,7 +1300,7 @@ function _collectAllParameters(dataObjList) {
|
|
|
1315
1300
|
* @param {String} fqName, fully qualified name
|
|
1316
1301
|
* @param {List<Object>} schemaDataList
|
|
1317
1302
|
* @param {Object} parserContext
|
|
1318
|
-
*
|
|
1303
|
+
*
|
|
1319
1304
|
* Scenarios:
|
|
1320
1305
|
* 1. UnBounded Actions can't have collision. Action name must be unique.
|
|
1321
1306
|
* 2. UnBounded Functions can have collision; capture the max number of parameters.
|
|
@@ -1366,7 +1351,7 @@ function _collectUnboundedActionFunction(schemaDataList, parserContext) {
|
|
|
1366
1351
|
* @param {String} elementName
|
|
1367
1352
|
* @param {List<Object>} elementDataList, bounded action/function details
|
|
1368
1353
|
* @param {Object} parserContext
|
|
1369
|
-
*
|
|
1354
|
+
*
|
|
1370
1355
|
* Scenarios for bounded actions, functions:
|
|
1371
1356
|
* 1. Actions with same name and binding parameter type can't have collision.
|
|
1372
1357
|
* 2. Functions can have collision and we will capture the max number of parameters.
|
|
@@ -1472,7 +1457,7 @@ function _collectSchemaElements(edmxAsJson, schemaDataList, parserContext) {
|
|
|
1472
1457
|
* we only have a single entity container
|
|
1473
1458
|
*/
|
|
1474
1459
|
if (currNamespace === parserContext.primarySchema) {
|
|
1475
|
-
Object.keys(schemaData.$Annotations).forEach(annotationTarget => {
|
|
1460
|
+
Object.keys(schemaData.$Annotations).forEach(annotationTarget => {
|
|
1476
1461
|
if (annotationTarget.includes(parserContext.entityContainerName)) {
|
|
1477
1462
|
parserContext.entityContainerAnnotations[annotationTarget] = schemaData.$Annotations[annotationTarget];
|
|
1478
1463
|
/**
|
|
@@ -1489,7 +1474,8 @@ function _collectSchemaElements(edmxAsJson, schemaDataList, parserContext) {
|
|
|
1489
1474
|
}
|
|
1490
1475
|
}
|
|
1491
1476
|
|
|
1492
|
-
function _preProcess(edmxAsJson,
|
|
1477
|
+
function _preProcess(edmxAsJson, parserContext, importerContext) {
|
|
1478
|
+
_collectPrimarySchemaContext(edmxAsJson, parserContext, importerContext);
|
|
1493
1479
|
let schemaDataList = [], indexOfSchema = 0;
|
|
1494
1480
|
|
|
1495
1481
|
Object.keys(edmxAsJson).forEach(schemaName => {
|
|
@@ -1505,7 +1491,7 @@ function _preProcess(edmxAsJson, mockServerUc, parserContext) {
|
|
|
1505
1491
|
indexOfSchema++;
|
|
1506
1492
|
}
|
|
1507
1493
|
// if mock server use case & traversing primary schema, collect relevant mappings
|
|
1508
|
-
if (mockServerUc && schemaName === parserContext.primarySchema) {
|
|
1494
|
+
if (parserContext.mockServerUc && schemaName === parserContext.primarySchema) {
|
|
1509
1495
|
let entityContainerData = schemaData[parserContext.entityContainerName];
|
|
1510
1496
|
Object.keys(entityContainerData).forEach(elementName => {
|
|
1511
1497
|
let elementObj = entityContainerData[elementName];
|
|
@@ -1531,18 +1517,27 @@ function _preProcess(edmxAsJson, mockServerUc, parserContext) {
|
|
|
1531
1517
|
}
|
|
1532
1518
|
});
|
|
1533
1519
|
|
|
1520
|
+
// if mockServerUc='true' and EntityContainer has no content, we set the value to false
|
|
1521
|
+
if (parserContext.mockServerUc &&
|
|
1522
|
+
parserContext.entityToEntitySetMap._.size === 0 &&
|
|
1523
|
+
parserContext.entityToSingletonMap._.size === 0 &&
|
|
1524
|
+
parserContext.actionToActionImportMap._.size === 0 &&
|
|
1525
|
+
parserContext.functionToFunctionImportMap._.size === 0) {
|
|
1526
|
+
parserContext.mockServerUc = false;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1534
1529
|
_collectSchemaElements(edmxAsJson, schemaDataList, parserContext);
|
|
1535
1530
|
|
|
1536
1531
|
return schemaDataList;
|
|
1537
1532
|
}
|
|
1538
1533
|
|
|
1539
|
-
function _generateCSN(edmxAsJson, ignorePersistenceSkip,
|
|
1534
|
+
function _generateCSN(edmxAsJson, ignorePersistenceSkip, parserContext, importerContext) {
|
|
1540
1535
|
let csn = {};
|
|
1541
1536
|
csn.meta = {};
|
|
1542
1537
|
csn.meta.creator = 'cds-dk ' + versionInfo;
|
|
1543
1538
|
csn.$version = '2.0';
|
|
1544
1539
|
csn.definitions = {};
|
|
1545
|
-
let schemaDataList = _preProcess(edmxAsJson,
|
|
1540
|
+
let schemaDataList = _preProcess(edmxAsJson, parserContext, importerContext);
|
|
1546
1541
|
|
|
1547
1542
|
for (let schemaData of schemaDataList) {
|
|
1548
1543
|
// Step 1: parse all type definition
|
|
@@ -1550,15 +1545,15 @@ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc, parserCon
|
|
|
1550
1545
|
// Step 2: parse all enum types
|
|
1551
1546
|
csn.definitions = Object.assign(_parseCSNForEnumType(schemaData, parserContext), csn.definitions);
|
|
1552
1547
|
// Step 3: parse all complex types
|
|
1553
|
-
csn.definitions = Object.assign(_parserCSNForComplexType(schemaData,
|
|
1548
|
+
csn.definitions = Object.assign(_parserCSNForComplexType(schemaData, parserContext), csn.definitions);
|
|
1554
1549
|
// Step 4: parse all entity type
|
|
1555
|
-
csn.definitions = Object.assign(_parseCSNForEntityType(schemaData, ignorePersistenceSkip,
|
|
1550
|
+
csn.definitions = Object.assign(_parseCSNForEntityType(schemaData, ignorePersistenceSkip, parserContext), csn.definitions);
|
|
1556
1551
|
// Step 5: parse all bounded action & function
|
|
1557
|
-
_parseBoundedActionFunction(schemaData, csn.definitions, 'action',
|
|
1558
|
-
_parseBoundedActionFunction(schemaData, csn.definitions, 'function',
|
|
1552
|
+
_parseBoundedActionFunction(schemaData, csn.definitions, 'action', parserContext);
|
|
1553
|
+
_parseBoundedActionFunction(schemaData, csn.definitions, 'function', parserContext);
|
|
1559
1554
|
// Step 6: parse all unbounded action & function
|
|
1560
|
-
csn.definitions = Object.assign(_parseUnBoundedActionFunction(schemaData, 'action',
|
|
1561
|
-
csn.definitions = Object.assign(_parseUnBoundedActionFunction(schemaData, 'function',
|
|
1555
|
+
csn.definitions = Object.assign(_parseUnBoundedActionFunction(schemaData, 'action', parserContext), csn.definitions);
|
|
1556
|
+
csn.definitions = Object.assign(_parseUnBoundedActionFunction(schemaData, 'function', parserContext), csn.definitions);
|
|
1562
1557
|
// Step 7: parse all annotations
|
|
1563
1558
|
if (schemaData.$Annotations) {
|
|
1564
1559
|
_parseAnnotations(schemaData.$Annotations, csn.definitions, parserContext);
|
|
@@ -1566,7 +1561,7 @@ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc, parserCon
|
|
|
1566
1561
|
}
|
|
1567
1562
|
|
|
1568
1563
|
// add Service object and EntityContainer items only if it is mock server use case
|
|
1569
|
-
if (mockServerUc) {
|
|
1564
|
+
if (parserContext.mockServerUc) {
|
|
1570
1565
|
csn.definitions[parserContext.primarySchema] = {};
|
|
1571
1566
|
csn.definitions[parserContext.primarySchema].kind = 'service';
|
|
1572
1567
|
csn.definitions[parserContext.primarySchema]['@cds.external'] = true;
|
|
@@ -1580,7 +1575,7 @@ function _generateCSN(edmxAsJson, ignorePersistenceSkip, mockServerUc, parserCon
|
|
|
1580
1575
|
return JSON.stringify(csn, null, 4);
|
|
1581
1576
|
}
|
|
1582
1577
|
|
|
1583
|
-
function _generateEDMX2JSON(edmx, name_space
|
|
1578
|
+
function _generateEDMX2JSON(edmx, name_space) {
|
|
1584
1579
|
return new Promise(function getJson(resolve, reject) {
|
|
1585
1580
|
try {
|
|
1586
1581
|
const inputBuffer = edmx;
|
|
@@ -1590,9 +1585,7 @@ function _generateEDMX2JSON(edmx, name_space, parserContext, context) {
|
|
|
1590
1585
|
if (missingReferencedDocuments?.length > 0) {
|
|
1591
1586
|
console.log(missingReferencedDocuments); // eslint-disable-line no-console
|
|
1592
1587
|
}
|
|
1593
|
-
|
|
1594
|
-
resolve(json);
|
|
1595
|
-
}
|
|
1588
|
+
resolve(json);
|
|
1596
1589
|
});
|
|
1597
1590
|
} catch (err) {
|
|
1598
1591
|
reject(err);
|
|
@@ -1600,37 +1593,34 @@ function _generateEDMX2JSON(edmx, name_space, parserContext, context) {
|
|
|
1600
1593
|
});
|
|
1601
1594
|
}
|
|
1602
1595
|
|
|
1603
|
-
async function getEdmxv4CSN(edmx, ignorePersistenceSkip, mockServerUc,
|
|
1596
|
+
async function getEdmxv4CSN(edmx, ignorePersistenceSkip, mockServerUc, importerContext) {
|
|
1604
1597
|
let csn;
|
|
1605
1598
|
let edmjConverted;
|
|
1606
1599
|
let name_space = [];
|
|
1607
1600
|
|
|
1608
1601
|
const parserContext = {};
|
|
1609
|
-
_initialize(parserContext);
|
|
1602
|
+
_initialize(parserContext, mockServerUc);
|
|
1610
1603
|
|
|
1611
|
-
if (
|
|
1604
|
+
if (importerContext.include_all_namespaces) {
|
|
1612
1605
|
name_space.push(true);
|
|
1613
1606
|
}
|
|
1614
1607
|
else {
|
|
1615
|
-
name_space =
|
|
1608
|
+
name_space = importerContext.namespaces;
|
|
1616
1609
|
}
|
|
1617
1610
|
|
|
1618
1611
|
if (_isJson(edmx)) {
|
|
1619
1612
|
return new Promise(function getCsn(resolve, reject) {
|
|
1620
1613
|
try {
|
|
1621
1614
|
edmjConverted = JSON.parse(edmx);
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
if (csn) resolve(csn);
|
|
1625
|
-
}
|
|
1615
|
+
csn = _generateCSN(edmjConverted, ignorePersistenceSkip, parserContext, importerContext);
|
|
1616
|
+
if (csn) resolve(csn);
|
|
1626
1617
|
} catch (err) {
|
|
1627
1618
|
reject(err);
|
|
1628
1619
|
}
|
|
1629
1620
|
});
|
|
1630
1621
|
}
|
|
1631
|
-
const edmj = await _generateEDMX2JSON(edmx, name_space
|
|
1632
|
-
|
|
1633
|
-
return _generateCSN(edmj, ignorePersistenceSkip, mockServerUc, parserContext);
|
|
1622
|
+
const edmj = await _generateEDMX2JSON(edmx, name_space);
|
|
1623
|
+
return _generateCSN(edmj, ignorePersistenceSkip, parserContext, importerContext);
|
|
1634
1624
|
}
|
|
1635
1625
|
|
|
1636
1626
|
module.exports = {
|