@sap-ux/fe-mockserver-core
Advanced tools
Comparing version 1.1.38 to 1.1.39
@@ -11,2 +11,3 @@ import type { Action, ComplexType, EntityType, Property, TypeDefinition } from '@sap-ux/vocabularies-types'; | ||
constructor(mockData: any[], entityType: EntityType, mockDataEntitySet: EntitySetInterface, contextId: string); | ||
private validateProperties; | ||
addEntry(mockEntry: any, _odataRequest: ODataRequest): Promise<void>; | ||
@@ -13,0 +14,0 @@ updateEntry(keyValues: KeyDefinitions, updatedData: object, _patchData: object, _odataRequest: ODataRequest): Promise<void>; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const common_1 = require("../data/common"); | ||
const annotation_converter_1 = require("@sap-ux/annotation-converter"); | ||
function performSimpleComparison(operator, mockValue, targetLiteral) { | ||
@@ -48,13 +49,3 @@ let isValid = true; | ||
// We need to ensure that complex types are at least partially created | ||
this._entityType.entityProperties.forEach((prop) => { | ||
if (prop.targetType && prop.targetType._type === 'ComplexType' && !mockLine[prop.name]) { | ||
mockLine[prop.name] = {}; | ||
prop.targetType.properties.forEach((subProp) => { | ||
mockLine[prop.name][subProp.name] = this.getDefaultValueFromType(subProp.type, subProp.targetType, subProp.defaultValue); | ||
}); | ||
} | ||
if (!prop.nullable && !mockLine.hasOwnProperty(prop.name)) { | ||
mockLine[prop.name] = this.getDefaultValueFromType(prop.type, prop.targetType, prop.defaultValue); | ||
} | ||
}); | ||
this.validateProperties(mockLine, this._entityType.entityProperties); | ||
}); | ||
@@ -64,2 +55,13 @@ } | ||
} | ||
validateProperties(mockEntry, properties) { | ||
properties.forEach((prop) => { | ||
if (!prop.nullable && !mockEntry.hasOwnProperty(prop.name)) { | ||
mockEntry[prop.name] = this.getDefaultValueFromType(prop.type, prop.targetType, prop.defaultValue); | ||
} | ||
else if (mockEntry.hasOwnProperty(prop.name) && (0, annotation_converter_1.isComplexTypeDefinition)(prop.targetType)) { | ||
// If the property is defined from a complex type we should validate the property of the complex type | ||
this.validateProperties(mockEntry[prop.name], prop.targetType.properties); | ||
} | ||
}); | ||
} | ||
async addEntry(mockEntry, _odataRequest) { | ||
@@ -66,0 +68,0 @@ this._mockData.push(mockEntry); |
{ | ||
"name": "@sap-ux/fe-mockserver-core", | ||
"version": "1.1.38", | ||
"version": "1.1.39", | ||
"description": "SAP Fiori OData - Fiori elements mock server core", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5042
431675