UNPKG

@sap-cloud-sdk/odata-common

Version:

SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.

21 lines 792 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getEntityKeys = getEntityKeys; const util_1 = require("@sap-cloud-sdk/util"); /** * Helper function that maps an entity to its keys map with their original names. * @param entity - Entity to map. * @param entityApi - Entity API of the entity to get keys for. * @returns object that includes all keys that represent given entity * @internal */ function getEntityKeys(entity, entityApi) { if (!entity) { throw new Error('getEntityKeys() cannot extract keys from an undefined or null object.'); } return entityApi.entityConstructor._keys.reduce((prev, curr) => ({ ...prev, [curr]: entity[(0, util_1.camelCase)(curr)] }), {}); } //# sourceMappingURL=get-keys.js.map