@sap-ux/fe-mockserver-core
Advanced tools
Comparing version 1.1.54 to 1.1.55
@@ -7,2 +7,6 @@ import type { Action, EntitySet, EntityType, Property } from '@sap-ux/vocabularies-types'; | ||
import type { IFileLoader } from '../index'; | ||
export type PartialReferentialConstraint = { | ||
sourceProperty: string; | ||
targetProperty: string; | ||
}; | ||
export interface EntitySetInterface { | ||
@@ -24,3 +28,3 @@ checkKeyValue(mockData: object, keyValues: object, keyName: string, keyProp?: Property): boolean; | ||
isV4(): boolean; | ||
getNavigationPropertyKeys(data: any, navPropDetail: any, currentEntityType: EntityType, currentEntitySet: EntitySet | undefined, currentKeys: Record<string, string>, forCreate?: boolean): Record<string, string>; | ||
getNavigationPropertyKeys(data: any, navPropDetail: any, currentEntityType: EntityType, currentEntitySet: EntitySet | undefined, currentKeys: Record<string, string>, tenantId: string, forCreate?: boolean): Promise<Record<string, string>>; | ||
getMockEntitySet(entityTypeName: string, generateMockData?: boolean, containedEntityType?: EntityType, containedData?: any): Promise<EntitySetInterface>; | ||
@@ -27,0 +31,0 @@ getData(odataRequest: ODataRequest): Promise<any>; |
@@ -33,3 +33,3 @@ import type { ODataMetadata } from './metadata'; | ||
performAction(odataRequest: ODataRequest, actionData?: object): Promise<any>; | ||
getNavigationPropertyKeys(data: any, navPropDetail: any, currentEntityType: EntityType, currentEntitySet: EntitySet | Singleton | undefined, currentKeys: Record<string, string>, forCreate?: boolean): Record<string, string>; | ||
getNavigationPropertyKeys(data: any, navPropDetail: any, currentEntityType: EntityType, currentEntitySet: EntitySet | Singleton | undefined, currentKeys: Record<string, string>, tenantId: string, forCreate?: boolean): Promise<Record<string, string>>; | ||
getExpandData(currentEntitySet: EntitySet | Singleton | undefined, entityType: EntityType, expandNavProp: string, data: any, requestExpandObject: Record<string, ExpandDefinition>, tenantId: string, previousEntitySet: EntitySet | Singleton | undefined, visitedPaths: string[], odataRequest: ODataRequest): Promise<any>; | ||
@@ -36,0 +36,0 @@ getMetadata(): ODataMetadata; |
@@ -169,8 +169,13 @@ "use strict"; | ||
} | ||
getNavigationPropertyKeys(data, navPropDetail, currentEntityType, currentEntitySet, currentKeys, forCreate = false) { | ||
if (navPropDetail.referentialConstraint && navPropDetail.referentialConstraint.length > 0) { | ||
async getNavigationPropertyKeys(data, navPropDetail, currentEntityType, currentEntitySet, currentKeys, tenantId, forCreate = false) { | ||
const mockEntitySet = await this.getMockEntitySet(currentEntityType.name); | ||
let referentialConstraints = await mockEntitySet.getMockData(tenantId).getReferentialConstraints(navPropDetail); | ||
if (!referentialConstraints) { | ||
referentialConstraints = navPropDetail.referentialConstraint; | ||
} | ||
if (referentialConstraints && referentialConstraints.length > 0) { | ||
const dataArray = Array.isArray(data) ? data : [data]; | ||
dataArray.forEach((navigationData) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
navPropDetail.referentialConstraint.forEach((refConstr) => { | ||
referentialConstraints.forEach((refConstr) => { | ||
currentKeys[refConstr.targetProperty] = navigationData[refConstr.sourceProperty]; | ||
@@ -263,3 +268,3 @@ }); | ||
for (const dataLine of dataArray) { | ||
const currentKeys = this.getNavigationPropertyKeys(dataLine, navProp, entityType, targetEntitySet, {}); | ||
const currentKeys = await this.getNavigationPropertyKeys(dataLine, navProp, entityType, targetEntitySet, {}, odataRequest.tenantId); | ||
if (navProp && !navProp.containsTarget) { | ||
@@ -400,3 +405,3 @@ let expandData = dataLine[expandNavProp]; | ||
if (asArray) { | ||
currentKeys = this.getNavigationPropertyKeys(innerData, navPropDetail, currentEntityType, currentEntitySet, currentKeys); | ||
currentKeys = await this.getNavigationPropertyKeys(innerData, navPropDetail, currentEntityType, currentEntitySet, currentKeys, odataRequest.tenantId); | ||
} | ||
@@ -726,3 +731,3 @@ const hasOnlyDraftKeyOrNoKeys = Object.keys(currentKeys).length === 0 || | ||
}); | ||
const currentKeys = this.getNavigationPropertyKeys(data, navPropDetail, entitySet.entityType, entitySet, providedKeys, true); | ||
const currentKeys = await this.getNavigationPropertyKeys(data, navPropDetail, entitySet.entityType, entitySet, providedKeys, odataRequest.tenantId, true); | ||
if (data.DraftAdministrativeData !== null && data.DraftAdministrativeData !== undefined) { | ||
@@ -729,0 +734,0 @@ data.DraftAdministrativeData.LastChangeDateTime = (0, common_1._getDateTimeOffset)(this.isV4()); |
@@ -28,2 +28,3 @@ import { MockDataEntitySet } from './entitySet'; | ||
checkKeyValue(mockData: any, keyValues: any, keyName: string, property?: Property): boolean; | ||
private getNavigationPropertyDetails; | ||
private createInactiveVersionForNavigations; | ||
@@ -30,0 +31,0 @@ draftActivate(keyValues: KeyDefinitions, tenantId: string, odataRequest: ODataRequest): Promise<DraftElement | undefined>; |
@@ -43,2 +43,9 @@ "use strict"; | ||
} | ||
async getNavigationPropertyDetails(navPropName, data, tenantId) { | ||
// For all the draft node data duplicate them | ||
const navPropDetail = this.entityTypeDefinition.navigationProperties.find((navProp) => navProp.name === navPropName); | ||
const subKeys = await this.dataAccess.getNavigationPropertyKeys(data, navPropDetail, this.entitySetDefinition.entityType, this.entitySetDefinition, {}, tenantId); | ||
const navPropEntity = (await this.dataAccess.getMockEntitySet(this.entitySetDefinition.navigationPropertyBinding[navPropName].name)); | ||
return { navPropEntity, subKeys }; | ||
} | ||
async createInactiveVersionForNavigations(data, tenantId, odataRequest) { | ||
@@ -50,5 +57,3 @@ var _a, _b; | ||
// For all the draft node data duplicate them | ||
const navPropDetail = this.entityTypeDefinition.navigationProperties.find((navProp) => navProp.name === navPropName); | ||
const subKeys = this.dataAccess.getNavigationPropertyKeys(data, navPropDetail, this.entitySetDefinition.entityType, this.entitySetDefinition, {}); | ||
const navPropEntity = (await this.dataAccess.getMockEntitySet(this.entitySetDefinition.navigationPropertyBinding[navPropName].name)); | ||
const { navPropEntity, subKeys } = await this.getNavigationPropertyDetails(navPropName, data, tenantId); | ||
if (navPropEntity === null || navPropEntity === void 0 ? void 0 : navPropEntity.draftEdit) { | ||
@@ -110,5 +115,3 @@ await navPropEntity.draftEdit(subKeys, tenantId, odataRequest); | ||
// For all the draft node data duplicate them | ||
const navPropDetail = this.entityTypeDefinition.navigationProperties.find((navProp) => navProp.name === navPropName); | ||
const subKeys = this.dataAccess.getNavigationPropertyKeys(draftData, navPropDetail, this.entitySetDefinition.entityType, this.entitySetDefinition, {}); | ||
const navPropEntity = (await this.dataAccess.getMockEntitySet(this.entitySetDefinition.navigationPropertyBinding[navPropName].name)); | ||
const { navPropEntity, subKeys } = await this.getNavigationPropertyDetails(navPropName, draftData, tenantId); | ||
if (navPropEntity && navPropEntity.draftActivate) { | ||
@@ -156,5 +159,3 @@ await navPropEntity.draftActivate(subKeys, tenantId, odataRequest); | ||
// For all the draft node data duplicate them | ||
const navPropDetail = this.entityTypeDefinition.navigationProperties.find((navProp) => navProp.name === navPropName); | ||
const subKeys = this.dataAccess.getNavigationPropertyKeys(data, navPropDetail, this.entitySetDefinition.entityType, this.entitySetDefinition, {}); | ||
const navPropEntity = (await this.dataAccess.getMockEntitySet(this.entitySetDefinition.navigationPropertyBinding[navPropName].name)); | ||
const { navPropEntity, subKeys } = await this.getNavigationPropertyDetails(navPropName, data, tenantId); | ||
if (navPropEntity && navPropEntity.draftDiscard) { | ||
@@ -161,0 +162,0 @@ await navPropEntity.draftDiscard(subKeys, tenantId, odataRequest); |
@@ -1,3 +0,3 @@ | ||
import type { Action, ComplexType, EntityType, Property, TypeDefinition } from '@sap-ux/vocabularies-types'; | ||
import type { EntitySetInterface } from '../data/common'; | ||
import type { Action, ComplexType, EntityType, NavigationProperty, Property, TypeDefinition } from '@sap-ux/vocabularies-types'; | ||
import type { EntitySetInterface, PartialReferentialConstraint } from '../data/common'; | ||
import type ODataRequest from '../request/odataRequest'; | ||
@@ -64,3 +64,4 @@ export type KeyDefinitions = Record<string, number | boolean | string>; | ||
checkFilterValue(comparisonType: string, mockValue: any, literal: any, operator: string, _odataRequest: ODataRequest): boolean; | ||
getReferentialConstraints(_navigationProperty: NavigationProperty): Promise<PartialReferentialConstraint[] | undefined>; | ||
} | ||
//# sourceMappingURL=fileBasedMockData.d.ts.map |
@@ -385,4 +385,7 @@ "use strict"; | ||
} | ||
async getReferentialConstraints(_navigationProperty) { | ||
return undefined; | ||
} | ||
} | ||
exports.FileBasedMockData = FileBasedMockData; | ||
//# sourceMappingURL=fileBasedMockData.js.map |
import type { KeyDefinitions } from './fileBasedMockData'; | ||
import { FileBasedMockData } from './fileBasedMockData'; | ||
import type { Action, EntityType, Property } from '@sap-ux/vocabularies-types'; | ||
import type { EntitySetInterface } from '../data/common'; | ||
import type { Action, EntityType, Property, NavigationProperty } from '@sap-ux/vocabularies-types'; | ||
import type { EntitySetInterface, PartialReferentialConstraint } from '../data/common'; | ||
import type ODataRequest from '../request/odataRequest'; | ||
@@ -17,2 +17,3 @@ export type MockDataContributor = { | ||
getDefaultElement?: (odataRequest: ODataRequest) => object; | ||
getReferentialConstraints?: (_navigationProperty: NavigationProperty) => Promise<PartialReferentialConstraint[] | undefined>; | ||
generateKey?: (property: Property, lineIndex: number, odataRequest: ODataRequest) => any; | ||
@@ -72,3 +73,4 @@ checkSearchQuery?: (mockData: any, searchQuery: string, odataRequest: ODataRequest) => boolean; | ||
checkFilterValue(comparisonType: string, mockValue: any, literal: any, operator: string, odataRequest: ODataRequest): boolean; | ||
getReferentialConstraints(_navigationProperty: NavigationProperty): Promise<PartialReferentialConstraint[] | undefined>; | ||
} | ||
//# sourceMappingURL=functionBasedMockData.d.ts.map |
@@ -211,4 +211,13 @@ "use strict"; | ||
} | ||
async getReferentialConstraints(_navigationProperty) { | ||
var _a; | ||
if ((_a = this._mockDataFn) === null || _a === void 0 ? void 0 : _a.getReferentialConstraints) { | ||
return this._mockDataFn.getReferentialConstraints(_navigationProperty); | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
} | ||
exports.FunctionBasedMockData = FunctionBasedMockData; | ||
//# sourceMappingURL=functionBasedMockData.js.map |
{ | ||
"name": "@sap-ux/fe-mockserver-core", | ||
"version": "1.1.54", | ||
"version": "1.1.55", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
437413
5131