diff --git a/README.md b/README.md index 4e26431..e177939 100644 --- a/README.md +++ b/README.md @@ -264,17 +264,15 @@ allow users to perform write operations on an object collection. * @template Q - Parsed URL query object * * @extends IAbstractMangoFinder + * @extends IAbstractMangoRepositoryBase */ export interface IAbstractMangoRepository< E extends ObjectPlain = ObjectUnknown, U extends string = DUID, P extends MangoSearchParams = MangoSearchParams, Q extends MangoParsedUrlQuery = MangoParsedUrlQuery -> extends IAbstractMangoFinder { - readonly cache: MangoCacheRepo - readonly options: MangoRepoOptions - readonly validator: IMangoValidator - +> extends Omit, 'cache' | 'options'>, + IAbstractMangoRepositoryBase { clear(): OrPromise create(dto: CreateEntityDTO): OrPromise delete(uid?: OneOrMany, should_exist?: boolean): OrPromise @@ -282,6 +280,26 @@ export interface IAbstractMangoRepository< setCache(collection?: E[]): OrPromise> save(dto?: OneOrMany>): OrPromise } + +/** + * Base `AbstractMangoRepository` class interface. + * + * Used to define properties of `MangoRepository`, `MangoRepositoryAsync`, + * and possible derivatives. + * + * @template E - Entity + * @template U - Name of entity uid field + * + * @extends IAbstractMangoFinderBase + */ +export interface IAbstractMangoRepositoryBase< + E extends ObjectPlain = ObjectUnknown, + U extends string = DUID +> extends IAbstractMangoFinderBase { + readonly cache: MangoCacheRepo + readonly options: MangoRepoOptions + readonly validator: IMangoValidator +} ``` #### Modeling Entities diff --git a/src/interfaces/abstract-mango-repo-base.interface.ts b/src/interfaces/abstract-mango-repo-base.interface.ts new file mode 100644 index 0000000..222d5e0 --- /dev/null +++ b/src/interfaces/abstract-mango-repo-base.interface.ts @@ -0,0 +1,31 @@ +import type { DUID } from '@/types' +import type { ObjectPlain, ObjectUnknown } from '@flex-development/tutils' +import type { IAbstractMangoFinderBase } from './abstract-mango-finder-base.interface' +import type { MangoCacheRepo } from './mango-cache-repo.interface' +import type { MangoRepoOptions } from './mango-repo-options.interface' +import type { IMangoValidator } from './mango-validator.interface' + +/** + * @file Interface - IAbstractMangoRepositoryBase + * @module interfaces/AbstractMangoRepositoryBase + */ + +/** + * Base `AbstractMangoRepository` class interface. + * + * Used to define properties of `MangoRepository`, `MangoRepositoryAsync`, + * and possible derivatives. + * + * @template E - Entity + * @template U - Name of entity uid field + * + * @extends IAbstractMangoFinderBase + */ +export interface IAbstractMangoRepositoryBase< + E extends ObjectPlain = ObjectUnknown, + U extends string = DUID +> extends IAbstractMangoFinderBase { + readonly cache: MangoCacheRepo + readonly options: MangoRepoOptions + readonly validator: IMangoValidator +} diff --git a/src/interfaces/abstract-mango-repo.interface.ts b/src/interfaces/abstract-mango-repo.interface.ts index 543aa71..e6f4c41 100644 --- a/src/interfaces/abstract-mango-repo.interface.ts +++ b/src/interfaces/abstract-mango-repo.interface.ts @@ -7,9 +7,8 @@ import type { OrPromise } from '@flex-development/tutils' import type { IAbstractMangoFinder } from './abstract-mango-finder.interface' +import type { IAbstractMangoRepositoryBase } from './abstract-mango-repo-base.interface' import type { MangoCacheRepo } from './mango-cache-repo.interface' -import type { MangoRepoOptions } from './mango-repo-options.interface' -import type { IMangoValidator } from './mango-validator.interface' /** * @file Interface - IAbstractMangoRepository @@ -28,17 +27,15 @@ import type { IMangoValidator } from './mango-validator.interface' * @template Q - Parsed URL query object * * @extends IAbstractMangoFinder + * @extends IAbstractMangoRepositoryBase */ export interface IAbstractMangoRepository< E extends ObjectPlain = ObjectUnknown, U extends string = DUID, P extends MangoSearchParams = MangoSearchParams, Q extends MangoParsedUrlQuery = MangoParsedUrlQuery -> extends IAbstractMangoFinder { - readonly cache: MangoCacheRepo - readonly options: MangoRepoOptions - readonly validator: IMangoValidator - +> extends Omit, 'cache' | 'options'>, + IAbstractMangoRepositoryBase { clear(): OrPromise create(dto: CreateEntityDTO): OrPromise delete(uid?: OneOrMany, should_exist?: boolean): OrPromise diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 3d618f6..fd6bbc4 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -5,6 +5,7 @@ export type { IAbstractMangoFinderBase } from './abstract-mango-finder-base.interface' export type { IAbstractMangoFinder } from './abstract-mango-finder.interface' +export type { IAbstractMangoRepositoryBase } from './abstract-mango-repo-base.interface' export type { IAbstractMangoRepository } from './abstract-mango-repo.interface' export type { AccumulatorOperators } from './accumulator-operators.interface' export type { AggregationOperators } from './aggregation-operators.interface' diff --git a/src/interfaces/mango-repo-async.interface.ts b/src/interfaces/mango-repo-async.interface.ts index 6e85304..0c30d2e 100644 --- a/src/interfaces/mango-repo-async.interface.ts +++ b/src/interfaces/mango-repo-async.interface.ts @@ -5,6 +5,7 @@ import type { ObjectUnknown, OneOrMany } from '@flex-development/tutils' +import { IAbstractMangoRepositoryBase } from './abstract-mango-repo-base.interface' import type { MangoCacheRepo } from './mango-cache-repo.interface' import type { IMangoFinderAsync } from './mango-finder-async.interface' @@ -24,13 +25,15 @@ import type { IMangoFinderAsync } from './mango-finder-async.interface' * @template Q - Parsed URL query object * * @extends IMangoFinderAsync + * @extends IAbstractMangoRepositoryBase */ export interface IMangoRepositoryAsync< E extends ObjectPlain = ObjectUnknown, U extends string = DUID, P extends MangoSearchParams = MangoSearchParams, Q extends MangoParsedUrlQuery = MangoParsedUrlQuery -> extends IMangoFinderAsync { +> extends Omit, 'cache' | 'options'>, + IAbstractMangoRepositoryBase { clear(): Promise create(dto: CreateEntityDTO): Promise delete(uid?: OneOrMany, should_exist?: boolean): Promise diff --git a/src/interfaces/mango-repo.interface.ts b/src/interfaces/mango-repo.interface.ts index ad3cc0f..6381161 100644 --- a/src/interfaces/mango-repo.interface.ts +++ b/src/interfaces/mango-repo.interface.ts @@ -5,6 +5,7 @@ import type { ObjectUnknown, OneOrMany } from '@flex-development/tutils' +import type { IAbstractMangoRepositoryBase } from './abstract-mango-repo-base.interface' import type { MangoCacheRepo } from './mango-cache-repo.interface' import type { IMangoFinder } from './mango-finder.interface' @@ -24,13 +25,15 @@ import type { IMangoFinder } from './mango-finder.interface' * @template Q - Parsed URL query object * * @extends IMangoFinder + * @extends IAbstractMangoRepositoryBase */ export interface IMangoRepository< E extends ObjectPlain = ObjectUnknown, U extends string = DUID, P extends MangoSearchParams = MangoSearchParams, Q extends MangoParsedUrlQuery = MangoParsedUrlQuery -> extends IMangoFinder { +> extends Omit, 'cache' | 'options'>, + IAbstractMangoRepositoryBase { clear(): boolean create(dto: CreateEntityDTO): E delete(uid?: OneOrMany, should_exist?: boolean): UID[]