2023-01-21 17:11:55 +01:00
|
|
|
import { APIKeyEntity } from '@app/infra/db/entities';
|
2023-01-18 15:40:15 +01:00
|
|
|
|
|
|
|
export const IKeyRepository = 'IKeyRepository';
|
|
|
|
|
|
|
|
export interface IKeyRepository {
|
|
|
|
create(dto: Partial<APIKeyEntity>): Promise<APIKeyEntity>;
|
2023-02-18 21:58:55 +01:00
|
|
|
update(userId: string, id: string, dto: Partial<APIKeyEntity>): Promise<APIKeyEntity>;
|
|
|
|
delete(userId: string, id: string): Promise<void>;
|
2023-02-25 15:12:03 +01:00
|
|
|
deleteAll(userId: string): Promise<void>;
|
2023-01-18 15:40:15 +01:00
|
|
|
/**
|
|
|
|
* Includes the hashed `key` for verification
|
|
|
|
* @param id
|
|
|
|
*/
|
2023-01-27 21:50:07 +01:00
|
|
|
getKey(hashedToken: string): Promise<APIKeyEntity | null>;
|
2023-02-18 21:58:55 +01:00
|
|
|
getById(userId: string, id: string): Promise<APIKeyEntity | null>;
|
2023-01-18 15:40:15 +01:00
|
|
|
getByUserId(userId: string): Promise<APIKeyEntity[]>;
|
|
|
|
}
|