[fabric/domain] Add assertNone method and AlreadyExistsError class to StoreQuery interfaces
This commit is contained in:
parent
ae61c03bb9
commit
60c7bacfb5
@ -28,6 +28,8 @@ export interface StoreQuery<T> {
|
||||
selectOneOrFail<K extends Keyof<T>>(
|
||||
keys: K[],
|
||||
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||
|
||||
assertNone(): AsyncResult<void, StoreQueryError | AlreadyExistsError>;
|
||||
}
|
||||
|
||||
export interface StoreSortableQuery<T> {
|
||||
@ -48,6 +50,8 @@ export interface StoreSortableQuery<T> {
|
||||
selectOneOrFail<K extends Keyof<T>>(
|
||||
keys: K[],
|
||||
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||
|
||||
assertNone(): AsyncResult<void, StoreQueryError | AlreadyExistsError>;
|
||||
}
|
||||
|
||||
export interface StoreLimitableQuery<T> {
|
||||
@ -67,6 +71,8 @@ export interface StoreLimitableQuery<T> {
|
||||
selectOneOrFail<K extends Keyof<T>>(
|
||||
keys: K[],
|
||||
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||
|
||||
assertNone(): AsyncResult<void, StoreQueryError | AlreadyExistsError>;
|
||||
}
|
||||
|
||||
export interface SelectableQuery<T> {
|
||||
@ -84,6 +90,8 @@ export interface SelectableQuery<T> {
|
||||
selectOneOrFail<K extends Keyof<T>>(
|
||||
keys: K[],
|
||||
): AsyncResult<Pick<T, K>, StoreQueryError | NotFoundError>;
|
||||
|
||||
assertNone(): AsyncResult<void, StoreQueryError | AlreadyExistsError>;
|
||||
}
|
||||
|
||||
export interface StoreQueryDefinition<K extends string = string> {
|
||||
@ -100,3 +108,9 @@ export class NotFoundError extends TaggedError<"NotFoundError"> {
|
||||
super("NotFoundError");
|
||||
}
|
||||
}
|
||||
|
||||
export class AlreadyExistsError extends TaggedError<"AlreadyExistsError"> {
|
||||
constructor() {
|
||||
super("AlreadyExistsError");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user