2025-01-10 14:02:12 -05:00
|
|
|
import { Insertable } from 'kysely';
|
|
|
|
|
import { ApiKeys } from 'src/db';
|
2024-03-20 16:02:51 -05:00
|
|
|
import { APIKeyEntity } from 'src/entities/api-key.entity';
|
2025-01-10 14:02:12 -05:00
|
|
|
import { AuthApiKey } from 'src/types';
|
2023-01-18 09:40:15 -05:00
|
|
|
|
|
|
|
|
export const IKeyRepository = 'IKeyRepository';
|
|
|
|
|
|
|
|
|
|
export interface IKeyRepository {
|
2025-01-10 14:02:12 -05:00
|
|
|
create(dto: Insertable<ApiKeys>): Promise<APIKeyEntity>;
|
2023-02-18 20:58:55 +00:00
|
|
|
update(userId: string, id: string, dto: Partial<APIKeyEntity>): Promise<APIKeyEntity>;
|
|
|
|
|
delete(userId: string, id: string): Promise<void>;
|
2023-01-18 09:40:15 -05:00
|
|
|
/**
|
|
|
|
|
* Includes the hashed `key` for verification
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
2025-01-10 14:02:12 -05:00
|
|
|
getKey(hashedToken: string): Promise<AuthApiKey | undefined>;
|
2023-02-18 20:58:55 +00:00
|
|
|
getById(userId: string, id: string): Promise<APIKeyEntity | null>;
|
2023-01-18 09:40:15 -05:00
|
|
|
getByUserId(userId: string): Promise<APIKeyEntity[]>;
|
|
|
|
|
}
|