feat: add imageSourceUrl to Zod schemas and service functions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 13:14:13 +02:00
parent 1eb4a786ce
commit d104e9788f
3 changed files with 11 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ export function getAllItems(db: Db = prodDb) {
notes: items.notes, notes: items.notes,
productUrl: items.productUrl, productUrl: items.productUrl,
imageFilename: items.imageFilename, imageFilename: items.imageFilename,
imageSourceUrl: items.imageSourceUrl,
createdAt: items.createdAt, createdAt: items.createdAt,
updatedAt: items.updatedAt, updatedAt: items.updatedAt,
categoryName: categories.name, categoryName: categories.name,
@@ -38,6 +39,7 @@ export function getItemById(db: Db = prodDb, id: number) {
notes: items.notes, notes: items.notes,
productUrl: items.productUrl, productUrl: items.productUrl,
imageFilename: items.imageFilename, imageFilename: items.imageFilename,
imageSourceUrl: items.imageSourceUrl,
createdAt: items.createdAt, createdAt: items.createdAt,
updatedAt: items.updatedAt, updatedAt: items.updatedAt,
}) })
@@ -65,6 +67,7 @@ export function createItem(
notes: data.notes ?? null, notes: data.notes ?? null,
productUrl: data.productUrl ?? null, productUrl: data.productUrl ?? null,
imageFilename: data.imageFilename ?? null, imageFilename: data.imageFilename ?? null,
imageSourceUrl: data.imageSourceUrl ?? null,
}) })
.returning() .returning()
.get(); .get();
@@ -81,6 +84,7 @@ export function updateItem(
notes: string; notes: string;
productUrl: string; productUrl: string;
imageFilename: string; imageFilename: string;
imageSourceUrl: string;
}>, }>,
) { ) {
// Check if item exists first // Check if item exists first

View File

@@ -76,6 +76,7 @@ export function getThreadWithCandidates(db: Db = prodDb, threadId: number) {
notes: threadCandidates.notes, notes: threadCandidates.notes,
productUrl: threadCandidates.productUrl, productUrl: threadCandidates.productUrl,
imageFilename: threadCandidates.imageFilename, imageFilename: threadCandidates.imageFilename,
imageSourceUrl: threadCandidates.imageSourceUrl,
status: threadCandidates.status, status: threadCandidates.status,
pros: threadCandidates.pros, pros: threadCandidates.pros,
cons: threadCandidates.cons, cons: threadCandidates.cons,
@@ -144,6 +145,7 @@ export function createCandidate(
name: string; name: string;
categoryId: number; categoryId: number;
imageFilename?: string; imageFilename?: string;
imageSourceUrl?: string;
}, },
) { ) {
const maxRow = db const maxRow = db
@@ -165,6 +167,7 @@ export function createCandidate(
notes: data.notes ?? null, notes: data.notes ?? null,
productUrl: data.productUrl ?? null, productUrl: data.productUrl ?? null,
imageFilename: data.imageFilename ?? null, imageFilename: data.imageFilename ?? null,
imageSourceUrl: data.imageSourceUrl ?? null,
status: data.status ?? "researching", status: data.status ?? "researching",
pros: data.pros ?? null, pros: data.pros ?? null,
cons: data.cons ?? null, cons: data.cons ?? null,
@@ -185,6 +188,7 @@ export function updateCandidate(
notes: string; notes: string;
productUrl: string; productUrl: string;
imageFilename: string; imageFilename: string;
imageSourceUrl: string;
status: "researching" | "ordered" | "arrived"; status: "researching" | "ordered" | "arrived";
pros: string; pros: string;
cons: string; cons: string;
@@ -294,6 +298,7 @@ export function resolveThread(
notes: candidate.notes, notes: candidate.notes,
productUrl: candidate.productUrl, productUrl: candidate.productUrl,
imageFilename: candidate.imageFilename, imageFilename: candidate.imageFilename,
imageSourceUrl: candidate.imageSourceUrl,
}) })
.returning() .returning()
.get(); .get();

View File

@@ -8,6 +8,7 @@ export const createItemSchema = z.object({
notes: z.string().optional(), notes: z.string().optional(),
productUrl: z.string().url().optional().or(z.literal("")), productUrl: z.string().url().optional().or(z.literal("")),
imageFilename: z.string().optional(), imageFilename: z.string().optional(),
imageSourceUrl: z.string().url().optional().or(z.literal("")),
}); });
export const updateItemSchema = createItemSchema.partial().extend({ export const updateItemSchema = createItemSchema.partial().extend({
@@ -52,6 +53,7 @@ export const createCandidateSchema = z.object({
notes: z.string().optional(), notes: z.string().optional(),
productUrl: z.string().url().optional().or(z.literal("")), productUrl: z.string().url().optional().or(z.literal("")),
imageFilename: z.string().optional(), imageFilename: z.string().optional(),
imageSourceUrl: z.string().url().optional().or(z.literal("")),
status: candidateStatusSchema.optional(), status: candidateStatusSchema.optional(),
pros: z.string().optional(), pros: z.string().optional(),
cons: z.string().optional(), cons: z.string().optional(),