tsx runs tests without type checking and tsconfig.json covers only src, so 71 type errors had accumulated unnoticed. tsconfig.tests.json now checks every test and helper, and npm run typecheck includes it. Fixtures gain the fields the DTOs have grown since they were written (manualQuantity, circuit apparent power/cos phi, downstream board loads, section totals, building, cover and board info fields). Repository lookups that return "row ?? null" now declare the null in their type, which their callers already handle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
769 B
TypeScript
22 lines
769 B
TypeScript
import { and, eq } from "drizzle-orm";
|
|
import type { AppDatabase } from "../database-context.js";
|
|
import { circuitLists } from "../schema/circuit-lists.js";
|
|
|
|
export class CircuitListRepository {
|
|
constructor(private readonly database: AppDatabase) {}
|
|
|
|
async listByProject(projectId: string) {
|
|
const db = this.database;
|
|
return db.select().from(circuitLists).where(eq(circuitLists.projectId, projectId));
|
|
}
|
|
|
|
async findById(projectId: string, circuitListId: string): Promise<typeof circuitLists.$inferSelect | null> {
|
|
const db = this.database;
|
|
const [row] = await db
|
|
.select()
|
|
.from(circuitLists)
|
|
.where(and(eq(circuitLists.projectId, projectId), eq(circuitLists.id, circuitListId)))
|
|
.limit(1);
|
|
return row ?? null;
|
|
}
|
|
}
|