This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from mobilejazz/feature/repurpose-interfaces
Repurpose `Repository` & `DataSource` to express the combination of get/put/delete types
- Loading branch information
Showing
13 changed files
with
32 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { Query } from '..'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface DataSource {} | ||
|
||
export interface GetDataSource<T> extends DataSource { | ||
export interface GetDataSource<T> { | ||
get: (query: Query) => Promise<T>; | ||
getAll: (query: Query) => Promise<T[]>; | ||
} | ||
|
||
export interface PutDataSource<T> extends DataSource { | ||
export interface PutDataSource<T> { | ||
put: (value: T | undefined, query: Query) => Promise<T>; | ||
putAll: (values: T[] | undefined, query: Query) => Promise<T[]>; | ||
} | ||
|
||
export interface DeleteDataSource extends DataSource { | ||
export interface DeleteDataSource { | ||
delete: (query: Query) => Promise<void>; | ||
} | ||
|
||
export type DataSource<T> = GetDataSource<T> & PutDataSource<T> & DeleteDataSource; |
6 changes: 2 additions & 4 deletions
6
packages/core/src/repository/data-source/in-memory.data-source.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import { Operation } from './operation/operation'; | ||
import { Query } from './query/query'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface Repository {} | ||
|
||
export interface GetRepository<T> extends Repository { | ||
export interface GetRepository<T> { | ||
get: (query: Query, operation: Operation) => Promise<T>; | ||
getAll: (query: Query, operation: Operation) => Promise<T[]>; | ||
} | ||
|
||
export interface PutRepository<T> extends Repository { | ||
export interface PutRepository<T> { | ||
put: (value: T | undefined, query: Query, operation: Operation) => Promise<T>; | ||
putAll: (values: T[] | undefined, query: Query, operation: Operation) => Promise<T[]>; | ||
} | ||
|
||
export interface DeleteRepository extends Repository { | ||
export interface DeleteRepository { | ||
delete: (query: Query, operation: Operation) => Promise<void>; | ||
} | ||
|
||
export type Repository<T> = GetRepository<T> & PutRepository<T> & DeleteRepository; |
4 changes: 2 additions & 2 deletions
4
packages/core/src/repository/single-data-source.repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters