- Add threads and threadCandidates tables to Drizzle schema - Add Zod schemas for thread/candidate/resolve validation - Add Thread/ThreadCandidate types to shared types - Update test helper with threads and thread_candidates tables - Write comprehensive failing tests for thread service Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const createItemSchema = z.object({
|
|
name: z.string().min(1, "Name is required"),
|
|
weightGrams: z.number().nonnegative().optional(),
|
|
priceCents: z.number().int().nonnegative().optional(),
|
|
categoryId: z.number().int().positive(),
|
|
notes: z.string().optional(),
|
|
productUrl: z.string().url().optional().or(z.literal("")),
|
|
});
|
|
|
|
export const updateItemSchema = createItemSchema.partial().extend({
|
|
id: z.number().int().positive(),
|
|
});
|
|
|
|
export const createCategorySchema = z.object({
|
|
name: z.string().min(1, "Category name is required"),
|
|
emoji: z.string().min(1).max(4).default("\u{1F4E6}"),
|
|
});
|
|
|
|
export const updateCategorySchema = z.object({
|
|
id: z.number().int().positive(),
|
|
name: z.string().min(1).optional(),
|
|
emoji: z.string().min(1).max(4).optional(),
|
|
});
|
|
|
|
// Thread schemas
|
|
export const createThreadSchema = z.object({
|
|
name: z.string().min(1, "Thread name is required"),
|
|
});
|
|
|
|
export const updateThreadSchema = z.object({
|
|
name: z.string().min(1).optional(),
|
|
});
|
|
|
|
// Candidate schemas (same fields as items)
|
|
export const createCandidateSchema = z.object({
|
|
name: z.string().min(1, "Name is required"),
|
|
weightGrams: z.number().nonnegative().optional(),
|
|
priceCents: z.number().int().nonnegative().optional(),
|
|
categoryId: z.number().int().positive(),
|
|
notes: z.string().optional(),
|
|
productUrl: z.string().url().optional().or(z.literal("")),
|
|
});
|
|
|
|
export const updateCandidateSchema = createCandidateSchema.partial();
|
|
|
|
export const resolveThreadSchema = z.object({
|
|
candidateId: z.number().int().positive(),
|
|
});
|