import type * as Domain from "../../../domain"; import { Model } from "../../models"; import { Query } from "../../types"; import { BaseRepository } from "./BaseRepository"; /** * @class MapperRepository * * Extends {@link BaseRepository} to handle Store interactions * while mapping between a Domain class and a Model object */ export declare abstract class MapperRepository extends BaseRepository { /** * Map from a Model to the Domain class * * @param model the stored Model with a uuid * @returns Domain with uuid set */ abstract toDomain(model: T): D; /** * Map from a Domain class to a Model * @param domain may be missing uuid * @returns Model potentially without uuid */ abstract toModel(domain: D): T; /** * Search the Store, mapping any found to Domain * * @param selector either an object or array of objects with matchable properties * @returns {T[]} Array of matched Domain instances * @throws {@link StoreQueryFailed} if the query fails */ get(query?: Query): Promise; /** * Search for instances based on given values * * @param selector object with matchable properties * @returns all found Domain instances * @throws {@link StoreQueryFailed} if the query fails */ find(selector?: Partial): Promise; /** * Search for single instance based on given values * * @param selector object with matchable properties * @returns first found Domain instance or null * @throws {@link StoreQueryFailed} if the query fails */ findOne(selector?: Partial): Promise; /** * Utility fn for common use of find with uuid * * @param uuid * @returns first found Domain instance or undefined * @throws {@link StoreQueryFailed} if the query fails */ byUUID(uuid: string): Promise; /** * Persist the Domain instance in the Store. * * @param domain * * Will be mapped to relevant Model for persistance * @see {@link BaseRepository.insert} * @throws {@link StoreInsertError} if insert fails * @throws {@link StoreUUIDNotReturned} if UUID not returned */ save(domain: D): Promise; }