/** * Data related to a service update. */ export interface ServiceUpdate { /** * The updated service. */ service: I; /** * The previous service. */ previousService: I; /** * The previously mapped service. */ previousMappedService: O; } /** * Mapper that support both creation and updating of services. */ export interface AdvancedMapper { create: Mapper; update?: (update: ServiceUpdate) => Promise | O | null; destroy?: (service: O) => Promise | void; } /** * Function that can be used to check if something can be assumed to be an * advanced mapper. * * @param o */ export function isAdvancedMapper(o: any): o is AdvancedMapper { return typeof o === 'object' && typeof o.create === 'function'; } /** * Mapper function, maps from an input to an input either synchronously or * asynchronously. */ export type Mapper = (service: I) => Promise | O | null;