UNPKG

@ima/plugin-rest-client

Version:

Generic REST API client plugin for the IMA application framework.

66 lines 3.05 kB
/** * A typed representation of a data field mapper for declarative mapping of raw * data to entity properties. */ export default class AbstractDataFieldMapper { /** * This setter is used for compatibility with the Public Class Fields ES * proposal (at stage 2 at the moment of writing this). * * See the related getter for more details about this property. * * @param {?string} dataFieldName The name of the raw data property to map * to an entity property using this mapper. */ static set dataFieldName(dataFieldName: string | null); /** * Returns the name of the property in the raw data that should be mapped * to the entity property with which is this mapper associated. * * The property of the raw data of the same name as the target entity * property will be used if this property returns {@code null}. * * @returns {?string} The name of the property in the raw data that should * be mapped to the entity property with which is this mapper * associated. */ static get dataFieldName(): string | null; /** * Deserializes the provided raw value obtained from the REST API to * format that is used in the entity's target property. * * @param {*} value The raw value to deserialize, as provided by the REST * API. * @param {AbstractEntity} entity The entity of which's property value is * being deserialized. * @returns {*} The deserialized value that should be set to the entity's * property. */ static deserialize(value: any, entity: AbstractEntity): any; /** * Serializes the provided entity's property value to format that is safe * to send to the REST API. * * @param {*} value The entity's property value. * @param {AbstractEntity} entity The entity of which's property value is * being serialized. * @returns {*} The serialized value. */ static serialize(value: any, entity: AbstractEntity): any; /** * Generates a new data field mapper using the provided data field name, * serialization callback and deserialization callback. * * @param {?string} dataFieldName The name of the raw data field being * mapped, or {@code null} if it is the same as the name of the * entity property being mapped. * @param {function(*, AbstractEntity): *} deserialize The callback to use * for deserialization of a raw value. * @param {function(*, AbstractEntity): *} serialize The callback to use * for serializing the entity's property value. * @returns {function(new: AbstractDataFieldMapper)} The generated data * field mapper. */ static makeMapper(dataFieldName: string | null, deserialize: (arg0: any, arg1: AbstractEntity) => any, serialize: (arg0: any, arg1: AbstractEntity) => any): new () => AbstractDataFieldMapper; } //# sourceMappingURL=AbstractDataFieldMapper.d.ts.map