test(03-01): add failing tests for setup backend
- Add setups and setupItems tables to DB schema - Add Zod schemas for setup create/update/sync - Add Setup/SetupItem types to shared types - Add setup tables to test helper - Write service and route tests (RED - no implementation yet) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,27 @@ export const threadCandidates = sqliteTable("thread_candidates", {
|
||||
.$defaultFn(() => new Date()),
|
||||
});
|
||||
|
||||
export const setups = sqliteTable("setups", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
name: text("name").notNull(),
|
||||
createdAt: integer("created_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date()),
|
||||
updatedAt: integer("updated_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date()),
|
||||
});
|
||||
|
||||
export const setupItems = sqliteTable("setup_items", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
setupId: integer("setup_id")
|
||||
.notNull()
|
||||
.references(() => setups.id, { onDelete: "cascade" }),
|
||||
itemId: integer("item_id")
|
||||
.notNull()
|
||||
.references(() => items.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const settings = sqliteTable("settings", {
|
||||
key: text("key").primaryKey(),
|
||||
value: text("value").notNull(),
|
||||
|
||||
@@ -48,3 +48,16 @@ export const updateCandidateSchema = createCandidateSchema.partial();
|
||||
export const resolveThreadSchema = z.object({
|
||||
candidateId: z.number().int().positive(),
|
||||
});
|
||||
|
||||
// Setup schemas
|
||||
export const createSetupSchema = z.object({
|
||||
name: z.string().min(1, "Setup name is required"),
|
||||
});
|
||||
|
||||
export const updateSetupSchema = z.object({
|
||||
name: z.string().min(1, "Setup name is required"),
|
||||
});
|
||||
|
||||
export const syncSetupItemsSchema = z.object({
|
||||
itemIds: z.array(z.number().int().positive()),
|
||||
});
|
||||
|
||||
@@ -9,8 +9,11 @@ import type {
|
||||
createCandidateSchema,
|
||||
updateCandidateSchema,
|
||||
resolveThreadSchema,
|
||||
createSetupSchema,
|
||||
updateSetupSchema,
|
||||
syncSetupItemsSchema,
|
||||
} from "./schemas.ts";
|
||||
import type { items, categories, threads, threadCandidates } from "../db/schema.ts";
|
||||
import type { items, categories, threads, threadCandidates, setups, setupItems } from "../db/schema.ts";
|
||||
|
||||
// Types inferred from Zod schemas
|
||||
export type CreateItem = z.infer<typeof createItemSchema>;
|
||||
@@ -23,8 +26,15 @@ export type CreateCandidate = z.infer<typeof createCandidateSchema>;
|
||||
export type UpdateCandidate = z.infer<typeof updateCandidateSchema>;
|
||||
export type ResolveThread = z.infer<typeof resolveThreadSchema>;
|
||||
|
||||
// Setup types
|
||||
export type CreateSetup = z.infer<typeof createSetupSchema>;
|
||||
export type UpdateSetup = z.infer<typeof updateSetupSchema>;
|
||||
export type SyncSetupItems = z.infer<typeof syncSetupItemsSchema>;
|
||||
|
||||
// Types inferred from Drizzle schema
|
||||
export type Item = typeof items.$inferSelect;
|
||||
export type Category = typeof categories.$inferSelect;
|
||||
export type Thread = typeof threads.$inferSelect;
|
||||
export type ThreadCandidate = typeof threadCandidates.$inferSelect;
|
||||
export type Setup = typeof setups.$inferSelect;
|
||||
export type SetupItem = typeof setupItems.$inferSelect;
|
||||
|
||||
Reference in New Issue
Block a user