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:
@@ -16,6 +16,7 @@ export function getAllItems(db: Db = prodDb) {
|
||||
notes: items.notes,
|
||||
productUrl: items.productUrl,
|
||||
imageFilename: items.imageFilename,
|
||||
imageSourceUrl: items.imageSourceUrl,
|
||||
createdAt: items.createdAt,
|
||||
updatedAt: items.updatedAt,
|
||||
categoryName: categories.name,
|
||||
@@ -38,6 +39,7 @@ export function getItemById(db: Db = prodDb, id: number) {
|
||||
notes: items.notes,
|
||||
productUrl: items.productUrl,
|
||||
imageFilename: items.imageFilename,
|
||||
imageSourceUrl: items.imageSourceUrl,
|
||||
createdAt: items.createdAt,
|
||||
updatedAt: items.updatedAt,
|
||||
})
|
||||
@@ -65,6 +67,7 @@ export function createItem(
|
||||
notes: data.notes ?? null,
|
||||
productUrl: data.productUrl ?? null,
|
||||
imageFilename: data.imageFilename ?? null,
|
||||
imageSourceUrl: data.imageSourceUrl ?? null,
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
@@ -81,6 +84,7 @@ export function updateItem(
|
||||
notes: string;
|
||||
productUrl: string;
|
||||
imageFilename: string;
|
||||
imageSourceUrl: string;
|
||||
}>,
|
||||
) {
|
||||
// Check if item exists first
|
||||
|
||||
@@ -76,6 +76,7 @@ export function getThreadWithCandidates(db: Db = prodDb, threadId: number) {
|
||||
notes: threadCandidates.notes,
|
||||
productUrl: threadCandidates.productUrl,
|
||||
imageFilename: threadCandidates.imageFilename,
|
||||
imageSourceUrl: threadCandidates.imageSourceUrl,
|
||||
status: threadCandidates.status,
|
||||
pros: threadCandidates.pros,
|
||||
cons: threadCandidates.cons,
|
||||
@@ -144,6 +145,7 @@ export function createCandidate(
|
||||
name: string;
|
||||
categoryId: number;
|
||||
imageFilename?: string;
|
||||
imageSourceUrl?: string;
|
||||
},
|
||||
) {
|
||||
const maxRow = db
|
||||
@@ -165,6 +167,7 @@ export function createCandidate(
|
||||
notes: data.notes ?? null,
|
||||
productUrl: data.productUrl ?? null,
|
||||
imageFilename: data.imageFilename ?? null,
|
||||
imageSourceUrl: data.imageSourceUrl ?? null,
|
||||
status: data.status ?? "researching",
|
||||
pros: data.pros ?? null,
|
||||
cons: data.cons ?? null,
|
||||
@@ -185,6 +188,7 @@ export function updateCandidate(
|
||||
notes: string;
|
||||
productUrl: string;
|
||||
imageFilename: string;
|
||||
imageSourceUrl: string;
|
||||
status: "researching" | "ordered" | "arrived";
|
||||
pros: string;
|
||||
cons: string;
|
||||
@@ -294,6 +298,7 @@ export function resolveThread(
|
||||
notes: candidate.notes,
|
||||
productUrl: candidate.productUrl,
|
||||
imageFilename: candidate.imageFilename,
|
||||
imageSourceUrl: candidate.imageSourceUrl,
|
||||
})
|
||||
.returning()
|
||||
.get();
|
||||
|
||||
@@ -8,6 +8,7 @@ export const createItemSchema = z.object({
|
||||
notes: z.string().optional(),
|
||||
productUrl: z.string().url().optional().or(z.literal("")),
|
||||
imageFilename: z.string().optional(),
|
||||
imageSourceUrl: z.string().url().optional().or(z.literal("")),
|
||||
});
|
||||
|
||||
export const updateItemSchema = createItemSchema.partial().extend({
|
||||
@@ -52,6 +53,7 @@ export const createCandidateSchema = z.object({
|
||||
notes: z.string().optional(),
|
||||
productUrl: z.string().url().optional().or(z.literal("")),
|
||||
imageFilename: z.string().optional(),
|
||||
imageSourceUrl: z.string().url().optional().or(z.literal("")),
|
||||
status: candidateStatusSchema.optional(),
|
||||
pros: z.string().optional(),
|
||||
cons: z.string().optional(),
|
||||
|
||||
Reference in New Issue
Block a user