import type { LuciaErrorConstructor } from "../index.js"; import type { UserSchema, SessionSchema, KeySchema } from "./schema.js"; export type AdapterFunction = (E: LuciaErrorConstructor) => T; export type Adapter = Readonly<{ getSessionAndUserBySessionId?: (sessionId: string) => Promise<{ user: UserSchema; session: SessionSchema; } | null>; } & SessionAdapter & UserAdapter>; export type UserAdapter = Readonly<{ getUser: (userId: string) => Promise; setUser: (userId: string, userAttributes: Record, key: KeySchema | null) => Promise; deleteUser: (userId: string) => Promise; updateUserAttributes: (userId: string, attributes: Record) => Promise; setKey: (key: KeySchema) => Promise; deleteNonPrimaryKey: (keyId: string) => Promise; deleteKeysByUserId: (userId: string) => Promise; updateKeyPassword: (keyId: string, hashedPassword: string | null) => Promise; getKey: (keyId: string, shouldDataBeDeleted: (key: KeySchema) => Promise) => Promise; getKeysByUserId: (userId: string) => Promise; }>; export type SessionAdapter = Readonly<{ getSession: (sessionId: string) => Promise; getSessionsByUserId: (userId: string) => Promise; setSession: (session: SessionSchema) => Promise; deleteSession: (sessionId: string) => Promise; deleteSessionsByUserId: (userId: string) => Promise; }>;