diff --git a/src/mapper/Mapper.ts b/src/mapper/Mapper.ts index e87fd16..90ca4f2 100644 --- a/src/mapper/Mapper.ts +++ b/src/mapper/Mapper.ts @@ -1,9 +1,7 @@ -import { Either } from '@rimo/monad' - /** * An interface for mappers functions that converts a source type `S` to target type `T`. * * @typeParam S the source type * @typeParam T the target type */ -export type Mapper = (source: S) => Either +export type Mapper = (source: S) => T diff --git a/src/repository/CrudRepository.ts b/src/repository/CrudRepository.ts index 5e5c216..f780106 100644 --- a/src/repository/CrudRepository.ts +++ b/src/repository/CrudRepository.ts @@ -1,5 +1,4 @@ import { Entity, EntityId } from '@rimo/core' -import { Either } from '@rimo/monad' import { Repository } from './Repository' /** @@ -20,7 +19,7 @@ export interface CrudRepository, ID extends EntityId> * @param entity to save. * @return the saved entity. */ - save: (entity: S) => Promise> + save: (entity: S) => Promise /** * Saves all given entities. @@ -28,7 +27,7 @@ export interface CrudRepository, ID extends EntityId> * @param entities to save. * @return the saved entities. */ - saveAll: (entities: S[]) => Promise> + saveAll: (entities: S[]) => Promise /** * Retrieves an entity by its ID. @@ -36,7 +35,7 @@ export interface CrudRepository, ID extends EntityId> * @param id of the entity. * @return the entity with the given ID or `undefined` if none found. */ - findById: (id: ID) => Promise> + findById: (id: ID) => Promise /** * Returns whether an entity with the given ID exists. @@ -44,14 +43,14 @@ export interface CrudRepository, ID extends EntityId> * @param id of the entity. * @return `true` if an entity with the given id exists, `false` otherwise. */ - existsById: (id: ID) => Promise> + existsById: (id: ID) => Promise /** * Returns all instances of the type. * * @return all entities */ - findAll: () => Promise> + findAll: () => Promise /** * Returns all instances of the type `T` with the given IDs. @@ -63,33 +62,33 @@ export interface CrudRepository, ID extends EntityId> * @param ids of entities to be retuned. * @return the entities. */ - findAllById: (ids: ID[]) => Promise> + findAllById: (ids: ID[]) => Promise /** * Returns the number of entities. * * @return the number of entities. */ - count: () => Promise> + count: () => Promise /** * Deletes the entity with the given id. * * @param id of entity to delete. */ - deleteById: (id: ID) => Promise> + deleteById: (id: ID) => Promise /** * Deletes a given entity. * * @param entity to delete. */ - delete: (entity: T) => Promise> + delete: (entity: T) => Promise /** * Deletes the given entities, or all when no arguments are provided. * * @param entities to delete or `undefined` to delete all. */ - deleteAll: (entities?: T[]) => Promise> + deleteAll: (entities?: T[]) => Promise }