refactor: migrate sessions repository to kysely (#15268)

* wip: search

* wip: getByToken

* wip: getByToken

* wip: getByUserId

* wip: create/update/delete

* remove unused code

* clean up and pr feedback

* fix: test

* fix: e2e test

* pr feedback
This commit is contained in:
Alex 2025-01-13 19:45:52 -06:00 committed by GitHub
parent 36eef9807b
commit 79726acc72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 185 additions and 96 deletions

View file

@ -1,3 +1,5 @@
import { Insertable, Updateable } from 'kysely';
import { Sessions } from 'src/db';
import { SessionEntity } from 'src/entities/session.entity';
export const ISessionRepository = 'ISessionRepository';
@ -7,9 +9,9 @@ export type SessionSearchOptions = { updatedBefore: Date };
export interface ISessionRepository {
search(options: SessionSearchOptions): Promise<SessionEntity[]>;
create<T extends Partial<E>>(dto: T): Promise<T>;
update<T extends Partial<E>>(dto: T): Promise<T>;
create(dto: Insertable<Sessions>): Promise<SessionEntity>;
update(id: string, dto: Updateable<Sessions>): Promise<SessionEntity>;
delete(id: string): Promise<void>;
getByToken(token: string): Promise<E | null>;
getByToken(token: string): Promise<E | undefined>;
getByUserId(userId: string): Promise<E[]>;
}