import { recordInfo } from "./record-info.js";
import { RepositoryBase } from "./base.js";
import { Flavor, UUID } from "../helpers";
import { UserId } from "./user.js";

export type SessionId = Flavor<UUID, "Session Id">;

export interface UnsavedSession {
  userId: UserId;
  expires: Date;
  sessionToken: string;
  accessToken: string;
}

export interface SavedSession extends UnsavedSession {
  id: SessionId;
  createdAt: Date;
  updatedAt: Date;
}

export const SessionRecord = recordInfo<UnsavedSession, SavedSession>(
  "app_private",
  "sessions"
);

export class SessionRecordRepository extends RepositoryBase(SessionRecord) {}
