import { type User, type InsertUser, type Label, type InsertLabel, type Task, type InsertTask, type XpEvent, type InsertXpEvent, type Goal, type InsertGoal, xpEvents, goals, type Reward, type InsertReward, type UserReward, type InsertUserReward, rewards, userRewards, systemSettings, type SystemSettings, type InsertSystemSettings, type SharedTask, type InsertSharedTask, type UserTaskAccess, type InsertUserTaskAccess, sharedTasks, userTaskAccess } from "../shared/schema.js"; import { randomUUID } from "crypto"; import session from "express-session"; import createMemoryStore from "memorystore"; import connectPg from "connect-pg-simple"; import { pool } from "./db"; const MemoryStore = createMemoryStore(session); const PostgresStore = connectPg(session); export interface IStorage { sessionStore: session.Store; getUser(id: string): Promise; getUserByUsername(username: string): Promise; getUserByEmail(email: string): Promise; createUser(user: InsertUser & { role?: string; isActive?: boolean }): Promise; updateUser(id: string, updates: Partial): Promise; getAllUsers(): Promise; updateUserXP(id: string, xp: number): Promise; // Social & Leaderboard getLeaderboard(): Promise; searchUsers(query: string): Promise; shareTask(sharedTask: InsertSharedTask): Promise; shareAllTasks(access: InsertUserTaskAccess): Promise; createSharedTask(sharedTask: InsertSharedTask): Promise; // Alias for shareTask standard naming createUserTaskAccess(access: InsertUserTaskAccess): Promise; // Alias getSharedTasks(userId: string): Promise; // Tasks shared WITH user getUserTaskAccess(viewerId: string): Promise; // Access Viewer has to Owners // System Settings (Admin) getSystemSettings(key: string): Promise; setSystemSettings(key: string, value: string): Promise; hasAdminUser(): Promise; // Labels getAllLabels(): Promise; getLabel(id: string): Promise