From 5afc7cd1822e22471c252d998fa832020bbc11be Mon Sep 17 00:00:00 2001 From: Arnaud Date: Fri, 10 Jul 2026 10:29:28 +0200 Subject: [PATCH] feat: shopping list rename/delete, item reorder+categories+search, ingredient-quantity parsing fix - Fixed a real i18n bug: the checked-count line called the wrong translation namespace and rendered the literal key on screen - Shopping lists can now be renamed and deleted from both the list index and detail pages (API already supported delete; rename was net new) - Root-caused "long list UI is off": meal-plan-generated lists never set an aisle, so every item fell into one undifferentiated "Other" bucket despite the grouping UI existing. Added a keyword-based aisle guesser wired into list generation (fallback only, never overrides an explicit aisle) plus a one-click "auto-categorize" for existing lists - Items can now be reordered by drag-and-drop within a category (dnd-kit), recategorized via a dropdown, deleted, searched, and sorted (category / alphabetical / unchecked-first); searching flattens the grouped view - Fixed a separate bug: AI-generated ingredients sometimes embedded the quantity/unit in the name itself (e.g. "2 cups flour" as one string). Added extractIngredientQuantity() as a Zod transform at both recipe create/update routes (the choke point every creation path funnels through) to split it back out, plus schema descriptions on the AI ingredient schemas as a prevention layer New migration 0028 (shopping_list_items.sort_order), left unapplied like the others. Verified with typecheck, lint, and a clean --no-cache docker build. Co-Authored-By: Claude Sonnet 5 --- .../app/(app)/shopping-lists/[id]/page.tsx | 7 +- apps/web/app/api/v1/recipes/[id]/route.ts | 4 + apps/web/app/api/v1/recipes/route.ts | 4 + .../[id]/items/[itemId]/route.ts | 37 +- .../api/v1/shopping-lists/[id]/items/route.ts | 45 +- .../app/api/v1/shopping-lists/[id]/route.ts | 13 +- apps/web/app/api/v1/shopping-lists/route.ts | 8 +- .../meal-plan/shopping-list-view.tsx | 513 +- .../shopping-list-actions-menu.tsx | 174 + .../shopping-lists-page-content.tsx | 25 +- .../web/lib/ai/features/generate-meal-plan.ts | 6 +- apps/web/lib/ai/features/recipe-schema.ts | 10 +- apps/web/lib/ai/features/scale-recipe.ts | 4 +- apps/web/lib/ai/features/translate-recipe.ts | 2 +- apps/web/lib/extract-ingredient-quantity.ts | 68 + apps/web/lib/grocery-categories.ts | 96 + apps/web/messages/en.json | 25 +- apps/web/messages/fr.json | 25 +- apps/web/package.json | 3 + .../migrations/0028_smiling_ezekiel_stane.sql | 1 + .../db/src/migrations/meta/0028_snapshot.json | 4491 +++++++++++++++++ packages/db/src/migrations/meta/_journal.json | 7 + packages/db/src/schema/meal-planning.ts | 1 + pnpm-lock.yaml | 56 + 24 files changed, 5549 insertions(+), 76 deletions(-) create mode 100644 apps/web/components/shopping-lists/shopping-list-actions-menu.tsx create mode 100644 apps/web/lib/extract-ingredient-quantity.ts create mode 100644 apps/web/lib/grocery-categories.ts create mode 100644 packages/db/src/migrations/0028_smiling_ezekiel_stane.sql create mode 100644 packages/db/src/migrations/meta/0028_snapshot.json diff --git a/apps/web/app/(app)/shopping-lists/[id]/page.tsx b/apps/web/app/(app)/shopping-lists/[id]/page.tsx index 2c2e363..4310f3a 100644 --- a/apps/web/app/(app)/shopping-lists/[id]/page.tsx +++ b/apps/web/app/(app)/shopping-lists/[id]/page.tsx @@ -8,6 +8,7 @@ import { db, shoppingLists, eq } from "@epicure/db"; import { ShoppingListView } from "@/components/meal-plan/shopping-list-view"; import { ShareShoppingListButton } from "@/components/shopping-lists/share-shopping-list-button"; import { GroceryExportButton } from "@/components/shopping-lists/grocery-export-button"; +import { ShoppingListActionsMenu } from "@/components/shopping-lists/shopping-list-actions-menu"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { getShoppingListAccess, canWriteShoppingList } from "@/lib/shopping-list-access"; @@ -30,7 +31,7 @@ export default async function ShoppingListPage({ params }: Params) { const list = await db.query.shoppingLists.findFirst({ where: eq(shoppingLists.id, id), - with: { items: { orderBy: (t, { asc }) => [asc(t.aisle), asc(t.rawName)] } }, + with: { items: { orderBy: (t, { asc }) => [asc(t.aisle), asc(t.sortOrder), asc(t.rawName)] } }, }); if (!list) notFound(); @@ -58,6 +59,9 @@ export default async function ShoppingListPage({ params }: Params) { markdown={shoppingListToMarkdown({ name: list.name, items: list.items })} filename={list.name} /> + {access.role === "owner" && ( + + )} diff --git a/apps/web/app/api/v1/recipes/[id]/route.ts b/apps/web/app/api/v1/recipes/[id]/route.ts index 863d7b7..05307d0 100644 --- a/apps/web/app/api/v1/recipes/[id]/route.ts +++ b/apps/web/app/api/v1/recipes/[id]/route.ts @@ -6,6 +6,7 @@ import { requireSessionOrApiKey } from "@/lib/api-auth"; import { deleteObject } from "@/lib/storage"; import { dispatchWebhook } from "@/lib/webhooks"; import { parseQuantity } from "@/lib/parse-quantity"; +import { extractIngredientQuantity } from "@/lib/extract-ingredient-quantity"; const UpdateRecipeSchema = z.object({ title: z.string().min(1).max(200).optional(), @@ -31,6 +32,9 @@ const UpdateRecipeSchema = z.object({ unit: z.string().max(50).optional(), note: z.string().max(500).optional(), order: z.number().int().default(0), + }).transform((ing) => { + const { rawName, quantity, unit } = extractIngredientQuantity(ing.rawName, ing.quantity, ing.unit); + return { ...ing, rawName, quantity, unit }; })).max(100).optional(), steps: z.array(z.object({ instruction: z.string().min(1).max(2000), diff --git a/apps/web/app/api/v1/recipes/route.ts b/apps/web/app/api/v1/recipes/route.ts index 38fc23c..0465ef3 100644 --- a/apps/web/app/api/v1/recipes/route.ts +++ b/apps/web/app/api/v1/recipes/route.ts @@ -6,6 +6,7 @@ import { requireSessionOrApiKey } from "@/lib/api-auth"; import { checkAndIncrementTierLimit, TierLimitError } from "@/lib/tiers"; import { dispatchWebhook } from "@/lib/webhooks"; import { parseQuantity } from "@/lib/parse-quantity"; +import { extractIngredientQuantity } from "@/lib/extract-ingredient-quantity"; const CreateRecipeSchema = z.object({ title: z.string().min(1).max(200), @@ -33,6 +34,9 @@ const CreateRecipeSchema = z.object({ unit: z.string().max(50).optional(), note: z.string().max(500).optional(), order: z.number().int().default(0), + }).transform((ing) => { + const { rawName, quantity, unit } = extractIngredientQuantity(ing.rawName, ing.quantity, ing.unit); + return { ...ing, rawName, quantity, unit }; })).max(100).default([]), steps: z.array(z.object({ instruction: z.string().min(1).max(2000), diff --git a/apps/web/app/api/v1/shopping-lists/[id]/items/[itemId]/route.ts b/apps/web/app/api/v1/shopping-lists/[id]/items/[itemId]/route.ts index b1df562..d37e741 100644 --- a/apps/web/app/api/v1/shopping-lists/[id]/items/[itemId]/route.ts +++ b/apps/web/app/api/v1/shopping-lists/[id]/items/[itemId]/route.ts @@ -8,6 +8,11 @@ type Params = { params: Promise<{ id: string; itemId: string }> }; const UpdateItemSchema = z.object({ checked: z.boolean().optional(), + rawName: z.string().min(1).optional(), + quantity: z.string().nullable().optional(), + unit: z.string().nullable().optional(), + aisle: z.string().nullable().optional(), + sortOrder: z.number().int().optional(), }); export async function PUT(req: NextRequest, { params }: Params) { @@ -24,9 +29,35 @@ export async function PUT(req: NextRequest, { params }: Params) { return NextResponse.json({ error: "Validation error", issues: parsed.error.issues }, { status: 400 }); } - await db.update(shoppingListItems) - .set({ checked: parsed.data.checked ?? false }) - .where(and(eq(shoppingListItems.id, itemId), eq(shoppingListItems.listId, id))); + const data = parsed.data; + const patch: Partial = {}; + if (data.checked !== undefined) patch.checked = data.checked; + if (data.rawName !== undefined) patch.rawName = data.rawName; + if (data.quantity !== undefined) patch.quantity = data.quantity; + if (data.unit !== undefined) patch.unit = data.unit; + if (data.aisle !== undefined) patch.aisle = data.aisle; + if (data.sortOrder !== undefined) patch.sortOrder = data.sortOrder; + + if (Object.keys(patch).length > 0) { + await db.update(shoppingListItems) + .set(patch) + .where(and(eq(shoppingListItems.id, itemId), eq(shoppingListItems.listId, id))); + } return NextResponse.json({ updated: true }); } + +export async function DELETE(_req: NextRequest, { params }: Params) { + const { session, response } = await requireSession(); + if (response) return response; + const { id, itemId } = await params; + + const access = await getShoppingListAccess(id, session!.user.id); + if (!access) return NextResponse.json({ error: "Not found" }, { status: 404 }); + if (!canWriteShoppingList(access.role)) return NextResponse.json({ error: "Forbidden" }, { status: 403 }); + + await db.delete(shoppingListItems) + .where(and(eq(shoppingListItems.id, itemId), eq(shoppingListItems.listId, id))); + + return NextResponse.json({ deleted: true }); +} diff --git a/apps/web/app/api/v1/shopping-lists/[id]/items/route.ts b/apps/web/app/api/v1/shopping-lists/[id]/items/route.ts index 75626e0..ccb87eb 100644 --- a/apps/web/app/api/v1/shopping-lists/[id]/items/route.ts +++ b/apps/web/app/api/v1/shopping-lists/[id]/items/route.ts @@ -1,8 +1,9 @@ import { NextRequest, NextResponse } from "next/server"; import { z } from "zod"; -import { db, shoppingListItems } from "@epicure/db"; +import { db, shoppingListItems, eq, and } from "@epicure/db"; import { requireSession } from "@/lib/api-auth"; import { getShoppingListAccess, canWriteShoppingList } from "@/lib/shopping-list-access"; +import { guessAisle } from "@/lib/grocery-categories"; const AddItemsSchema = z.object({ items: z.array(z.object({ @@ -13,6 +14,17 @@ const AddItemsSchema = z.object({ })).min(1), }); +// Bulk-update a set of existing items (sortOrder and/or aisle) in one request — +// used for drag-and-drop reordering (avoids one PUT per item on every drag) and +// for the "auto-categorize" action on lists whose items predate aisle-guessing. +const BulkUpdateSchema = z.object({ + items: z.array(z.object({ + id: z.string().min(1), + sortOrder: z.number().int().optional(), + aisle: z.string().nullable().optional(), + })).min(1), +}); + type Params = { params: Promise<{ id: string }> }; export async function POST(req: NextRequest, { params }: Params) { @@ -35,10 +47,39 @@ export async function POST(req: NextRequest, { params }: Params) { rawName: item.rawName, quantity: item.quantity, unit: item.unit, - aisle: item.aisle, + // Only guess when the caller didn't provide an explicit aisle — never override. + aisle: item.aisle ?? guessAisle(item.rawName) ?? undefined, checked: false, })) ); return NextResponse.json({ ok: true }, { status: 201 }); } + +export async function PATCH(req: NextRequest, { params }: Params) { + const { session, response } = await requireSession(); + if (response) return response; + const { id } = await params; + + const access = await getShoppingListAccess(id, session!.user.id); + if (!access) return NextResponse.json({ error: "Not found" }, { status: 404 }); + if (!canWriteShoppingList(access.role)) return NextResponse.json({ error: "Forbidden" }, { status: 403 }); + + const body = await req.json() as unknown; + const parsed = BulkUpdateSchema.safeParse(body); + if (!parsed.success) return NextResponse.json({ error: "Validation error" }, { status: 400 }); + + await Promise.all( + parsed.data.items.map((item) => { + const patch: Partial = {}; + if (item.sortOrder !== undefined) patch.sortOrder = item.sortOrder; + if (item.aisle !== undefined) patch.aisle = item.aisle; + if (Object.keys(patch).length === 0) return Promise.resolve(); + return db.update(shoppingListItems) + .set(patch) + .where(and(eq(shoppingListItems.id, item.id), eq(shoppingListItems.listId, id))); + }) + ); + + return NextResponse.json({ ok: true }); +} diff --git a/apps/web/app/api/v1/shopping-lists/[id]/route.ts b/apps/web/app/api/v1/shopping-lists/[id]/route.ts index 6455159..54f4cf8 100644 --- a/apps/web/app/api/v1/shopping-lists/[id]/route.ts +++ b/apps/web/app/api/v1/shopping-lists/[id]/route.ts @@ -23,7 +23,10 @@ export async function GET(_req: NextRequest, { params }: Params) { return NextResponse.json(list); } -const PatchSchema = z.object({ completed: z.boolean() }); +const PatchSchema = z.object({ + completed: z.boolean().optional(), + name: z.string().min(1).max(100).optional(), +}); export async function PATCH(req: NextRequest, { params }: Params) { const { session, response } = await requireSession(); @@ -32,12 +35,18 @@ export async function PATCH(req: NextRequest, { params }: Params) { const access = await getShoppingListAccess(id, session!.user.id); if (!access) return NextResponse.json({ error: "Not found" }, { status: 404 }); - if (!canWriteShoppingList(access.role)) return NextResponse.json({ error: "Forbidden" }, { status: 403 }); const body = PatchSchema.safeParse(await req.json()); if (!body.success) return NextResponse.json({ error: "Validation error" }, { status: 400 }); + if (body.data.name !== undefined) { + // Renaming is owner-only, same as delete + if (access.role !== "owner") return NextResponse.json({ error: "Forbidden" }, { status: 403 }); + await db.update(shoppingLists).set({ name: body.data.name }).where(eq(shoppingLists.id, id)); + } + if (body.data.completed) { + if (!canWriteShoppingList(access.role)) return NextResponse.json({ error: "Forbidden" }, { status: 403 }); // Mark all items as checked await db.update(shoppingListItems).set({ checked: true }).where(eq(shoppingListItems.listId, id)); void dispatchWebhook(session!.user.id, "shopping_list.completed", { id, name: access.list.name }); diff --git a/apps/web/app/api/v1/shopping-lists/route.ts b/apps/web/app/api/v1/shopping-lists/route.ts index 30e4615..c636197 100644 --- a/apps/web/app/api/v1/shopping-lists/route.ts +++ b/apps/web/app/api/v1/shopping-lists/route.ts @@ -3,6 +3,7 @@ import { z } from "zod"; import { db, shoppingLists, shoppingListItems, mealPlans, mealPlanEntries, recipeIngredients, pantryItems, eq, and, desc, inArray } from "@epicure/db"; import { requireSession } from "@/lib/api-auth"; import { applyPantryToItems, mergeIngredients } from "@/lib/pantry-shopping-match"; +import { guessAisle } from "@/lib/grocery-categories"; const CreateSchema = z.object({ name: z.string().min(1).max(100), @@ -77,15 +78,18 @@ export async function POST(req: NextRequest) { if (items.length > 0) { await db.insert(shoppingListItems).values( - items.map((item) => ({ + items.map((item, index) => ({ id: crypto.randomUUID(), listId, rawName: item.rawName, quantity: item.quantity, unit: item.unit, - aisle: item.aisle, + // Never override an explicit aisle — only guess one when the item doesn't have one + // (which today is every item coming from the meal-plan generation path). + aisle: item.aisle ?? guessAisle(item.rawName) ?? undefined, checked: item.inPantry === true && !item.quantity, inPantry: item.inPantry ?? false, + sortOrder: index, })) ); } diff --git a/apps/web/components/meal-plan/shopping-list-view.tsx b/apps/web/components/meal-plan/shopping-list-view.tsx index e1ba17a..e8a14a5 100644 --- a/apps/web/components/meal-plan/shopping-list-view.tsx +++ b/apps/web/components/meal-plan/shopping-list-view.tsx @@ -1,12 +1,56 @@ "use client"; -import { useState } from "react"; +import { useMemo, useState } from "react"; import { useTranslations } from "next-intl"; import { cn } from "@/lib/utils"; -import { Check, Package, Loader2 } from "lucide-react"; +import { Check, Package, Loader2, GripVertical, MoreVertical, Trash2, Search, Sparkles } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuTrigger, + DropdownMenuSeparator, +} from "@/components/ui/dropdown-menu"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; import { hasQuantity } from "@/lib/fractions"; +import { guessAisle, GROCERY_CATEGORIES } from "@/lib/grocery-categories"; +import { + DndContext, + DragEndEvent, + PointerSensor, + useSensor, + useSensors, + closestCenter, +} from "@dnd-kit/core"; +import { + SortableContext, + useSortable, + verticalListSortingStrategy, + arrayMove, +} from "@dnd-kit/sortable"; +import { CSS } from "@dnd-kit/utilities"; type Item = { id: string; @@ -16,8 +60,11 @@ type Item = { aisle: string | null; checked: boolean; inPantry?: boolean; + sortOrder?: number; }; +type SortMode = "category" | "alpha" | "unchecked"; + export function ShoppingListView({ listId, initialItems, @@ -32,8 +79,19 @@ export function ShoppingListView({ const tCommon = useTranslations("common"); const [items, setItems] = useState(initialItems); const [movingToPantry, setMovingToPantry] = useState(false); + const [query, setQuery] = useState(""); + const [sortMode, setSortMode] = useState("category"); + const [deleteTarget, setDeleteTarget] = useState(null); + const [deleting, setDeleting] = useState(false); + const [autoCategorizing, setAutoCategorizing] = useState(false); + + const categoryOptions = useMemo(() => [...GROCERY_CATEGORIES, t("aisleOther")], [t]); const checkedItems = items.filter((i) => i.checked); + const isSearching = query.trim().length > 0; + // Any item generated without an aisle (e.g. from an older list, before auto-categorization + // existed, or added manually without one) — offering a one-click fix for those. + const uncategorizedCount = items.filter((i) => !i.aisle).length; async function moveToPantry() { if (checkedItems.length === 0) return; @@ -74,11 +132,114 @@ export function ShoppingListView({ } } - const grouped = items.reduce>((acc, item) => { - const key = item.aisle ?? t("aisleOther"); - (acc[key] ??= []).push(item); - return acc; - }, {}); + async function changeCategory(item: Item, category: string) { + if (readOnly) return; + const nextAisle = category === t("aisleOther") ? null : category; + const prevAisle = item.aisle; + setItems((prev) => prev.map((i) => i.id === item.id ? { ...i, aisle: nextAisle } : i)); + try { + const res = await fetch(`/api/v1/shopping-lists/${listId}/items/${item.id}`, { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ aisle: nextAisle }), + }); + if (!res.ok) throw new Error(); + } catch { + setItems((prev) => prev.map((i) => i.id === item.id ? { ...i, aisle: prevAisle } : i)); + toast.error(tCommon("updateFailed")); + } + } + + async function deleteItem(item: Item) { + if (readOnly) return; + setDeleting(true); + const prevItems = items; + setItems((prev) => prev.filter((i) => i.id !== item.id)); + try { + const res = await fetch(`/api/v1/shopping-lists/${listId}/items/${item.id}`, { method: "DELETE" }); + if (!res.ok) throw new Error(); + setDeleteTarget(null); + } catch { + setItems(prevItems); + toast.error(t("removeFailed")); + } finally { + setDeleting(false); + } + } + + // One-click fix for lists whose items predate auto-categorization (or were added + // manually without a category) — guesses an aisle for every uncategorized item and + // persists all of them in a single batched request rather than one PUT per item. + async function autoCategorize() { + const targets = items.filter((i) => !i.aisle); + if (targets.length === 0) return; + setAutoCategorizing(true); + const updates = targets + .map((i) => ({ id: i.id, aisle: guessAisle(i.rawName) })) + .filter((u) => u.aisle !== null) as { id: string; aisle: string }[]; + + if (updates.length === 0) { + setAutoCategorizing(false); + toast.error(t("autoCategorizeNoneFound")); + return; + } + + const byId = new Map(updates.map((u) => [u.id, u.aisle])); + setItems((prev) => prev.map((i) => byId.has(i.id) ? { ...i, aisle: byId.get(i.id)! } : i)); + try { + const res = await fetch(`/api/v1/shopping-lists/${listId}/items`, { + method: "PATCH", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ items: updates }), + }); + if (!res.ok) throw new Error(); + toast.success(t("autoCategorizeSuccess", { count: updates.length })); + } catch { + toast.error(tCommon("updateFailed")); + } finally { + setAutoCategorizing(false); + } + } + + // Persists a new within-group order for a set of reordered items in a single batched + // request (rather than firing one PUT per dragged item). + async function persistOrder(reordered: Item[]) { + const updates = reordered.map((item, index) => ({ id: item.id, sortOrder: index })); + try { + const res = await fetch(`/api/v1/shopping-lists/${listId}/items`, { + method: "PATCH", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ items: updates }), + }); + if (!res.ok) throw new Error(); + } catch { + toast.error(tCommon("updateFailed")); + } + } + + function handleGroupDragEnd(groupItems: Item[], event: DragEndEvent) { + const { active, over } = event; + if (!over || active.id === over.id) return; + const oldIndex = groupItems.findIndex((i) => i.id === active.id); + const newIndex = groupItems.findIndex((i) => i.id === over.id); + if (oldIndex === -1 || newIndex === -1) return; + const reordered = arrayMove(groupItems, oldIndex, newIndex); + const reorderedIds = new Set(reordered.map((i) => i.id)); + + setItems((prev) => { + // Splice the reordered group items back into their original positions within + // the full list, leaving every other item untouched. + let cursor = 0; + return prev.map((i) => (reorderedIds.has(i.id) ? reordered[cursor++]! : i)); + }); + void persistOrder(reordered); + } + + const filtered = useMemo(() => { + const q = query.trim().toLowerCase(); + if (!q) return items; + return items.filter((i) => i.rawName.toLowerCase().includes(q)); + }, [items, query]); const checkedCount = items.filter((i) => i.checked).length; @@ -86,55 +247,309 @@ export function ShoppingListView({ return

{t("listEmptyState")}

; } + // Search flattens category grouping — when hunting for a specific item you want to + // find it regardless of which aisle it landed in, and headers-with-one-match reads + // worse than a simple flat result list. Outside of search, "category" sort mode keeps + // the grouped view (and is the only mode where drag-to-reorder applies, since + // "within category order" is the only ordering concept reordering makes sense for). + const showGroups = !isSearching && sortMode === "category"; + + let flatItems: Item[] = []; + if (!showGroups) { + flatItems = [...filtered]; + if (sortMode === "alpha" || isSearching) { + flatItems.sort((a, b) => a.rawName.localeCompare(b.rawName)); + } else if (sortMode === "unchecked") { + flatItems.sort((a, b) => { + if (a.checked !== b.checked) return a.checked ? 1 : -1; + return (a.sortOrder ?? 0) - (b.sortOrder ?? 0) || a.rawName.localeCompare(b.rawName); + }); + } + } + + const grouped = showGroups + ? filtered.reduce>((acc, item) => { + const key = item.aisle ?? t("aisleOther"); + (acc[key] ??= []).push(item); + return acc; + }, {}) + : {}; + return (
-

{tShopping("checkedCount", { checked: checkedCount, total: items.length })}

- {checkedCount > 0 && ( - - )} +

{t("checkedCount", { checked: checkedCount, total: items.length })}

+
+ {!readOnly && uncategorizedCount > 0 && ( + + )} + {checkedCount > 0 && ( + + )} +
- {Object.entries(grouped).sort(([a], [b]) => a.localeCompare(b)).map(([aisle, aisleItems]) => ( -
- {Object.keys(grouped).length > 1 && ( -

{aisle}

- )} -
- {aisleItems.map((item) => ( - - ))} -
+
+
+ + setQuery(e.target.value)} + placeholder={t("searchItemsPlaceholder")} + className="pl-8" + />
+ +
+ + {filtered.length === 0 ? ( +

{t("noSearchResults")}

+ ) : showGroups ? ( + Object.entries(grouped).sort(([a], [b]) => a.localeCompare(b)).map(([aisle, aisleItems]) => ( + 1} + readOnly={readOnly} + categoryOptions={categoryOptions} + tShopping={tShopping} + onToggle={toggleItem} + onChangeCategory={changeCategory} + onDeleteRequest={setDeleteTarget} + onDragEnd={(event) => handleGroupDragEnd(aisleItems, event)} + /> + )) + ) : ( + + )} + + !open && setDeleteTarget(null)}> + + + {t("removeItemConfirmTitle")} + + {deleteTarget ? t("removeItemConfirmDescription", { name: deleteTarget.rawName }) : ""} + + + + {tCommon("cancel")} + deleteTarget && deleteItem(deleteTarget)} + > + {deleting ? : tCommon("delete")} + + + + +
+ ); +} + +function ItemGroup({ + aisle, + items, + showHeader, + readOnly, + categoryOptions, + tShopping, + onToggle, + onChangeCategory, + onDeleteRequest, + onDragEnd, +}: { + aisle: string; + items: Item[]; + showHeader: boolean; + readOnly: boolean; + categoryOptions: string[]; + tShopping: ReturnType; + onToggle: (item: Item) => void; + onChangeCategory: (item: Item, category: string) => void; + onDeleteRequest: (item: Item) => void; + onDragEnd: (event: DragEndEvent) => void; +}) { + const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } })); + + return ( +
+ {showHeader && ( +

{aisle}

+ )} +
+ + i.id)} strategy={verticalListSortingStrategy}> + {items.map((item) => ( + + ))} + + +
+
+ ); +} + +function FlatItemList({ + items, + readOnly, + categoryOptions, + tShopping, + onToggle, + onChangeCategory, + onDeleteRequest, +}: { + items: Item[]; + readOnly: boolean; + categoryOptions: string[]; + tShopping: ReturnType; + onToggle: (item: Item) => void; + onChangeCategory: (item: Item, category: string) => void; + onDeleteRequest: (item: Item) => void; +}) { + return ( +
+ {items.map((item) => ( + ))}
); } + +function SortableItemRow(props: ItemRowProps & { draggable: boolean }) { + const { item, draggable } = props; + const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: item.id, disabled: !draggable }); + + const style = { + transform: CSS.Transform.toString(transform), + transition, + }; + + return ( +
+ + + + ) : null} + /> +
+ ); +} + +type ItemRowProps = { + item: Item; + readOnly: boolean; + categoryOptions: string[]; + tShopping: ReturnType; + onToggle: (item: Item) => void; + onChangeCategory: (item: Item, category: string) => void; + onDeleteRequest: (item: Item) => void; + dragHandle?: React.ReactNode; +}; + +function ItemRow({ item, readOnly, categoryOptions, tShopping, onToggle, onChangeCategory, onDeleteRequest, dragHandle }: ItemRowProps) { + return ( +
+ {dragHandle} + + {!readOnly && ( + + + + + + + {tShopping("changeCategory")} + + {categoryOptions.map((category) => ( + onChangeCategory(item, category)}> + {category} + + ))} + + + + onDeleteRequest(item)}> + + {tShopping("deleteItem")} + + + + )} +
+ ); +} diff --git a/apps/web/components/shopping-lists/shopping-list-actions-menu.tsx b/apps/web/components/shopping-lists/shopping-list-actions-menu.tsx new file mode 100644 index 0000000..79e7823 --- /dev/null +++ b/apps/web/components/shopping-lists/shopping-list-actions-menu.tsx @@ -0,0 +1,174 @@ +"use client"; + +import { useState } from "react"; +import { useRouter } from "next/navigation"; +import { useTranslations } from "next-intl"; +import { MoreVertical, Pencil, Trash2 } from "lucide-react"; +import { toast } from "sonner"; +import { Button, buttonVariants } from "@/components/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; +import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { cn } from "@/lib/utils"; + +type Props = { + listId: string; + name: string; + /** Called after a successful rename, so the caller can update its own state. If omitted, falls back to router.refresh(). */ + onRenamed?: (name: string) => void; + /** Called after a successful delete, so the caller can update its own state (e.g. remove the row). */ + onDeleted?: () => void; + /** Path to navigate to after deleting (e.g. back to the list index from the detail page). */ + redirectAfterDeleteTo?: string; + className?: string; +}; + +/** Owner-only rename/delete menu for a shopping list. Used on both the list index page and the list detail page. */ +export function ShoppingListActionsMenu({ listId, name, onRenamed, onDeleted, redirectAfterDeleteTo, className }: Props) { + const t = useTranslations("shoppingLists"); + const tCommon = useTranslations("common"); + const router = useRouter(); + const [renameOpen, setRenameOpen] = useState(false); + const [deleteOpen, setDeleteOpen] = useState(false); + const [newName, setNewName] = useState(name); + const [saving, setSaving] = useState(false); + const [deleting, setDeleting] = useState(false); + + function openRename() { + setNewName(name); + setRenameOpen(true); + } + + async function handleRename() { + const trimmed = newName.trim(); + if (!trimmed || trimmed === name) { + setRenameOpen(false); + return; + } + setSaving(true); + try { + const res = await fetch(`/api/v1/shopping-lists/${listId}`, { + method: "PATCH", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ name: trimmed }), + }); + if (!res.ok) throw new Error("failed"); + toast.success(t("listRenamed")); + setRenameOpen(false); + if (onRenamed) onRenamed(trimmed); + else router.refresh(); + } catch { + toast.error(t("listRenameFailed")); + } finally { + setSaving(false); + } + } + + async function handleDelete() { + setDeleting(true); + try { + const res = await fetch(`/api/v1/shopping-lists/${listId}`, { method: "DELETE" }); + if (!res.ok) throw new Error("failed"); + toast.success(t("listDeleted")); + setDeleteOpen(false); + onDeleted?.(); + if (redirectAfterDeleteTo) router.push(redirectAfterDeleteTo); + else router.refresh(); + } catch { + toast.error(t("listDeleteFailed")); + setDeleting(false); + } + } + + return ( + <> + + { + // Rows on the index page are wrapped in a Link — stop the click + // from bubbling to it and prevent the anchor's default navigation. + e.preventDefault(); + e.stopPropagation(); + }} + > + + + + + {t("rename")} + + setDeleteOpen(true)}> + {tCommon("delete")} + + + + + + + + {t("renameListTitle")} + +
+
+ + setNewName(e.target.value)} + onKeyDown={(e) => { + if (e.key === "Enter") void handleRename(); + }} + /> +
+
+ + +
+
+
+
+ + + + + {t("deleteListConfirmTitle")} + {t("deleteListConfirmDescription")} + + + {tCommon("cancel")} + { + void handleDelete(); + }} + disabled={deleting} + className="bg-destructive text-destructive-foreground hover:bg-destructive/90" + > + {tCommon("delete")} + + + + + + ); +} diff --git a/apps/web/components/shopping-lists/shopping-lists-page-content.tsx b/apps/web/components/shopping-lists/shopping-lists-page-content.tsx index 0d64610..718eb24 100644 --- a/apps/web/components/shopping-lists/shopping-lists-page-content.tsx +++ b/apps/web/components/shopping-lists/shopping-lists-page-content.tsx @@ -1,8 +1,10 @@ "use client"; +import { useState } from "react"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { ShoppingCart } from "lucide-react"; import { NewShoppingListButton } from "@/components/meal-plan/new-shopping-list-button"; +import { ShoppingListActionsMenu } from "@/components/shopping-lists/shopping-list-actions-menu"; type ShoppingListItem = { id: string; @@ -24,9 +26,10 @@ type Props = { sharedLists?: SharedListItem[]; }; -export function ShoppingListsPageContent({ lists, sharedLists = [] }: Props) { +export function ShoppingListsPageContent({ lists: initialLists, sharedLists = [] }: Props) { const t = useTranslations("shoppingLists"); const ts = useTranslations("shareDialog"); + const [lists, setLists] = useState(initialLists); return (
@@ -49,10 +52,10 @@ export function ShoppingListsPageContent({ lists, sharedLists = [] }: Props) { -
-

{list.name}

+
+

{list.name}

{list.totalItems === 0 ? t("listEmpty") @@ -60,8 +63,18 @@ export function ShoppingListsPageContent({ lists, sharedLists = [] }: Props) { {list.generatedAt && ` · ${t("generated")}`}

-
- {list.totalItems === 0 ? "—" : `${Math.round((list.checkedItems / list.totalItems) * 100)}%`} +
+
+ {list.totalItems === 0 ? "—" : `${Math.round((list.checkedItems / list.totalItems) * 100)}%`} +
+ + setLists((prev) => prev.map((l) => (l.id === list.id ? { ...l, name } : l))) + } + onDeleted={() => setLists((prev) => prev.filter((l) => l.id !== list.id))} + />
))} diff --git a/apps/web/lib/ai/features/generate-meal-plan.ts b/apps/web/lib/ai/features/generate-meal-plan.ts index 1c2e5b4..c5a3710 100644 --- a/apps/web/lib/ai/features/generate-meal-plan.ts +++ b/apps/web/lib/ai/features/generate-meal-plan.ts @@ -10,9 +10,9 @@ const MealPlanSchema = z.object({ title: z.string().max(150), description: z.string().max(300), ingredients: z.array(z.object({ - rawName: z.string(), - quantity: z.number().optional(), - unit: z.string().optional(), + rawName: z.string().describe("Ingredient name only, e.g. 'flour' — never include the quantity or unit here."), + quantity: z.number().optional().describe("A number only — never combined with the unit."), + unit: z.string().optional().describe("The unit only, e.g. 'cup', 'g' — never combined with the quantity or name."), })).max(20), steps: z.array(z.object({ instruction: z.string(), diff --git a/apps/web/lib/ai/features/recipe-schema.ts b/apps/web/lib/ai/features/recipe-schema.ts index c222187..c7cad55 100644 --- a/apps/web/lib/ai/features/recipe-schema.ts +++ b/apps/web/lib/ai/features/recipe-schema.ts @@ -17,9 +17,13 @@ export const stepSchema = z.object({ export function ingredientSchema(quantity: Q) { return z.object({ - rawName: z.string(), - quantity: quantity.optional(), - unit: z.string().optional(), + rawName: z.string().describe( + "The ingredient name ONLY — e.g. 'flour', 'egg', 'olive oil'. Never include the " + + "quantity or unit here (not '2 cups flour', not '3 eggs'); those go in the separate " + + "quantity and unit fields." + ), + quantity: quantity.optional().describe("A number only, e.g. 0.25, 1.5, 2 — never combined with the unit."), + unit: z.string().optional().describe("The unit only, e.g. 'cup', 'tbsp', 'g', 'ml' — never combined with the quantity or name."), note: z.string().optional(), }); } diff --git a/apps/web/lib/ai/features/scale-recipe.ts b/apps/web/lib/ai/features/scale-recipe.ts index c0028ec..cd1c240 100644 --- a/apps/web/lib/ai/features/scale-recipe.ts +++ b/apps/web/lib/ai/features/scale-recipe.ts @@ -5,8 +5,8 @@ import { resolveModel, type AiConfig } from "../factory"; const ScaledIngredientsSchema = z.object({ ingredients: z.array( z.object({ - rawName: z.string(), - quantity: z.string(), + rawName: z.string().describe("Ingredient name only, e.g. 'flour' — never include the scaled quantity or unit here."), + quantity: z.string().describe("The scaled quantity as a number only, e.g. '3' or '1.5'."), unit: z.string().nullable(), note: z.string().optional(), }) diff --git a/apps/web/lib/ai/features/translate-recipe.ts b/apps/web/lib/ai/features/translate-recipe.ts index 56a72a0..9de8356 100644 --- a/apps/web/lib/ai/features/translate-recipe.ts +++ b/apps/web/lib/ai/features/translate-recipe.ts @@ -6,7 +6,7 @@ const TranslationOutputSchema = z.object({ title: z.string(), description: z.string(), ingredients: z.array(z.object({ - rawName: z.string(), + rawName: z.string().describe("Translated ingredient name only — never add the quantity or unit, those are handled separately and unaffected by translation."), note: z.string().optional(), })), steps: z.array(z.object({ diff --git a/apps/web/lib/extract-ingredient-quantity.ts b/apps/web/lib/extract-ingredient-quantity.ts new file mode 100644 index 0000000..97f6909 --- /dev/null +++ b/apps/web/lib/extract-ingredient-quantity.ts @@ -0,0 +1,68 @@ +import { parseQuantity } from "./parse-quantity"; + +const KNOWN_UNITS = new Set([ + "cup", "cups", "c", + "tablespoon", "tablespoons", "tbsp", "tbsps", "tbs", + "teaspoon", "teaspoons", "tsp", "tsps", + "gram", "grams", "g", + "kilogram", "kilograms", "kg", + "ounce", "ounces", "oz", + "pound", "pounds", "lb", "lbs", + "milliliter", "milliliters", "millilitre", "millilitres", "ml", + "liter", "liters", "litre", "litres", "l", + "pinch", "pinches", "dash", "dashes", + "clove", "cloves", "slice", "slices", "piece", "pieces", + "can", "cans", "jar", "jars", "package", "packages", "pkg", + "bunch", "bunches", "sprig", "sprigs", "stick", "sticks", + "quart", "quarts", "qt", "pint", "pints", "pt", + "fl", // matches the first token of "fl oz" — handled below +]); + +// Leading numeric token: plain int/decimal, unicode fraction, mixed number ("1 1/2"), or +// simple fraction ("1/2") — mirrors what parseQuantity already knows how to parse. +const LEADING_NUMBER = + /^\s*(\d+\s+\d+\s*\/\s*\d+|\d+\s*\/\s*\d+|\d+(?:\.\d+)?|[¼½¾⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞])\s*/; + +/** + * Some AI-generated (or pasted/imported) ingredients arrive with the quantity baked into + * the name itself (e.g. rawName: "2 cups flour", quantity/unit left empty) instead of the + * expected separate fields. Detects a leading quantity (+ optional recognized unit) in + * rawName and pulls it out, so the ingredient name shown to the user is just "flour", not + * "2 cups flour". Never runs when an explicit quantity was already provided — an entry + * with real quantity/unit fields is trusted as-is, this is only a fallback for the case + * where the model (or a copy-pasted ingredient line) merged everything into the name. + */ +export function extractIngredientQuantity( + rawName: string, + quantity: string | undefined, + unit: string | undefined +): { rawName: string; quantity: string | undefined; unit: string | undefined } { + if (quantity !== undefined && quantity !== "") return { rawName, quantity, unit }; + + const match = rawName.match(LEADING_NUMBER); + if (!match) return { rawName, quantity, unit }; + + const numberToken = match[1]!.trim(); + const parsedQuantity = parseQuantity(numberToken); + if (parsedQuantity === undefined) return { rawName, quantity, unit }; + + let rest = rawName.slice(match[0].length).trim(); + if (!rest) return { rawName, quantity, unit }; // nothing left — not actually a name+quantity string + + let extractedUnit = unit; + const unitMatch = rest.match(/^([a-zA-Z.]+)\s+(.*)$/); + if (unitMatch && !extractedUnit) { + const candidate = unitMatch[1]!.replace(/\.$/, "").toLowerCase(); + if (candidate === "fl" && unitMatch[2]!.toLowerCase().startsWith("oz")) { + extractedUnit = "fl oz"; + rest = unitMatch[2]!.replace(/^oz\.?\s*/i, "").trim(); + } else if (KNOWN_UNITS.has(candidate)) { + extractedUnit = candidate; + rest = unitMatch[2]!.trim(); + } + } + + if (!rest) return { rawName, quantity, unit }; // stripping the unit ate the whole string — bail out + + return { rawName: rest, quantity: parsedQuantity, unit: extractedUnit }; +} diff --git a/apps/web/lib/grocery-categories.ts b/apps/web/lib/grocery-categories.ts new file mode 100644 index 0000000..595ec34 --- /dev/null +++ b/apps/web/lib/grocery-categories.ts @@ -0,0 +1,96 @@ +/** + * Lightweight keyword-based aisle guesser for shopping list items. + * + * This is intentionally NOT an exhaustive ingredient database — just a few dozen + * common keyword -> category mappings covering typical recipe ingredients, so + * items generated from a meal plan (which never have an explicit `aisle` set + * today) land in a reasonable category instead of an undifferentiated "Other" + * bucket. When nothing matches, returns `null` and the caller falls back to + * "Other" as before. + * + * Only ever used as a FALLBACK when an item doesn't already have an explicit + * `aisle` — never overrides a user- or API-provided value. + */ + +export const GROCERY_CATEGORIES = [ + "Produce", + "Dairy & Eggs", + "Meat & Seafood", + "Bakery", + "Frozen", + "Pantry", + "Spices & Condiments", + "Beverages", +] as const; + +export type GroceryCategory = (typeof GROCERY_CATEGORIES)[number]; + +// Ordered map of category -> keywords. Checked in order, first match wins, so +// more specific keywords should generally come before more generic ones. +const CATEGORY_KEYWORDS: [GroceryCategory, string[]][] = [ + ["Produce", [ + "lettuce", "spinach", "kale", "arugula", "cabbage", "carrot", "celery", "onion", + "garlic", "shallot", "scallion", "leek", "potato", "sweet potato", "tomato", + "cucumber", "zucchini", "squash", "pepper", "chili", "chile", "broccoli", + "cauliflower", "mushroom", "avocado", "lemon", "lime", "orange", "apple", + "banana", "berry", "berries", "grape", "melon", "peach", "pear", "plum", + "mango", "pineapple", "cilantro", "parsley", "basil", "mint", "dill", + "thyme", "rosemary", "ginger", "corn", "peas", "beans", "asparagus", + "radish", "beet", "fennel", "herb", "greens", + ]], + ["Dairy & Eggs", [ + "milk", "cream", "yogurt", "yoghurt", "butter", "cheese", "egg", "eggs", + "sour cream", "cottage cheese", "mascarpone", "ricotta", "buttermilk", + "half and half", "creme fraiche", + ]], + ["Meat & Seafood", [ + "chicken", "beef", "pork", "lamb", "turkey", "bacon", "sausage", "ham", + "steak", "ground beef", "mince", "salmon", "tuna", "shrimp", "prawn", + "cod", "tilapia", "fish", "crab", "lobster", "scallop", "mussel", "clam", + "chorizo", "prosciutto", "duck", + ]], + ["Bakery", [ + "bread", "baguette", "roll", "bun", "bagel", "tortilla", "pita", "naan", + "croissant", "muffin", "brioche", "loaf", + ]], + ["Frozen", [ + "frozen", "ice cream", "popsicle", "frozen peas", "frozen berries", + ]], + ["Beverages", [ + "juice", "soda", "water", "coffee", "tea", "wine", "beer", "sparkling", + "kombucha", "cider", + ]], + ["Spices & Condiments", [ + "salt", "pepper flakes", "cumin", "paprika", "cinnamon", "nutmeg", + "oregano", "turmeric", "cayenne", "curry powder", "chili powder", "spice", + "vanilla", "ketchup", "mustard", "mayo", "mayonnaise", "soy sauce", + "hot sauce", "vinegar", "olive oil", "vegetable oil", "sesame oil", + "honey", "maple syrup", "jam", "sauce", "dressing", "salsa", + ]], + ["Pantry", [ + "flour", "sugar", "rice", "pasta", "noodle", "spaghetti", "quinoa", + "oats", "oatmeal", "cereal", "beans", "lentil", "chickpea", "canned", + "stock", "broth", "bouillon", "yeast", "baking powder", "baking soda", + "cornstarch", "breadcrumb", "nut", "almond", "walnut", "peanut", "cashew", + "chocolate", "cocoa", "coconut milk", "tomato paste", "tomato sauce", + "crushed tomato", + ]], +]; + +/** + * Guesses a grocery aisle/category from a raw ingredient name via simple + * keyword matching. Returns `null` when nothing matches (caller should fall + * back to "Other"). + */ +export function guessAisle(rawName: string): GroceryCategory | null { + const name = rawName.toLowerCase().trim(); + if (!name) return null; + + for (const [category, keywords] of CATEGORY_KEYWORDS) { + for (const keyword of keywords) { + if (name.includes(keyword)) return category; + } + } + + return null; +} diff --git a/apps/web/messages/en.json b/apps/web/messages/en.json index 622567b..42747d6 100644 --- a/apps/web/messages/en.json +++ b/apps/web/messages/en.json @@ -654,6 +654,16 @@ "aisleOther": "Other", "listEmptyState": "This list is empty.", "checkedCount": "{checked}/{total} checked", + "searchItemsPlaceholder": "Search items…", + "sortByCategory": "By category", + "sortByAlpha": "Alphabetical", + "sortByUnchecked": "Unchecked first", + "noSearchResults": "No items match your search.", + "autoCategorize": "Auto-categorize", + "autoCategorizeSuccess": "{count, plural, one {1 item categorized} other {{count} items categorized}}", + "autoCategorizeNoneFound": "Couldn't guess a category for the remaining items", + "removeItemConfirmTitle": "Remove item?", + "removeItemConfirmDescription": "Remove \"{name}\" from this list?", "moveToPantry": "Move {count} to pantry", "listCreated": "List created", "days": { @@ -803,7 +813,20 @@ "ingredientsWillBeAdded": "{count, plural, one {1 ingredient will be added.} other {{count} ingredients will be added.}}", "adding": "Adding…", "addIngredients": "Add ingredients", - "addedCount": "{count} ingredients added to list" + "addedCount": "{count} ingredients added to list", + "actionsMenuLabel": "List actions", + "rename": "Rename", + "renameListTitle": "Rename list", + "renameListLabel": "List name", + "renaming": "Saving…", + "listRenamed": "List renamed", + "listRenameFailed": "Failed to rename list", + "deleteListConfirmTitle": "Delete list?", + "deleteListConfirmDescription": "This action cannot be undone. The list and all its items will be permanently deleted.", + "listDeleted": "List deleted", + "listDeleteFailed": "Failed to delete list", + "changeCategory": "Change category", + "deleteItem": "Delete item" }, "collections": { "title": "Collections", diff --git a/apps/web/messages/fr.json b/apps/web/messages/fr.json index 2c4133e..c6fa28f 100644 --- a/apps/web/messages/fr.json +++ b/apps/web/messages/fr.json @@ -642,6 +642,16 @@ "aisleOther": "Autre", "listEmptyState": "Cette liste est vide.", "checkedCount": "{checked}/{total} cochés", + "searchItemsPlaceholder": "Rechercher des articles…", + "sortByCategory": "Par catégorie", + "sortByAlpha": "Alphabétique", + "sortByUnchecked": "Non cochés d'abord", + "noSearchResults": "Aucun article ne correspond à votre recherche.", + "autoCategorize": "Catégoriser automatiquement", + "autoCategorizeSuccess": "{count, plural, one {1 article catégorisé} other {{count} articles catégorisés}}", + "autoCategorizeNoneFound": "Impossible de deviner une catégorie pour les articles restants", + "removeItemConfirmTitle": "Supprimer l'article ?", + "removeItemConfirmDescription": "Supprimer « {name} » de cette liste ?", "moveToPantry": "Déplacer {count} vers le garde-manger", "listCreated": "Liste créée", "days": { @@ -791,7 +801,20 @@ "ingredientsWillBeAdded": "{count, plural, one {1 ingrédient sera ajouté.} other {{count} ingrédients seront ajoutés.}}", "adding": "Ajout…", "addIngredients": "Ajouter les ingrédients", - "addedCount": "{count} ingrédients ajoutés à la liste" + "addedCount": "{count} ingrédients ajoutés à la liste", + "actionsMenuLabel": "Actions de la liste", + "rename": "Renommer", + "renameListTitle": "Renommer la liste", + "renameListLabel": "Nom de la liste", + "renaming": "Enregistrement…", + "listRenamed": "Liste renommée", + "listRenameFailed": "Échec du renommage de la liste", + "deleteListConfirmTitle": "Supprimer la liste ?", + "deleteListConfirmDescription": "Cette action est irréversible. La liste et tous ses articles seront définitivement supprimés.", + "listDeleted": "Liste supprimée", + "listDeleteFailed": "Échec de la suppression de la liste", + "changeCategory": "Changer de catégorie", + "deleteItem": "Supprimer l'article" }, "collections": { "title": "Collections", diff --git a/apps/web/package.json b/apps/web/package.json index 7835477..4156f75 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -19,6 +19,9 @@ "@aws-sdk/client-s3": "^3.1075.0", "@aws-sdk/s3-request-presigner": "^3.1075.0", "@base-ui/react": "^1.6.0", + "@dnd-kit/core": "^6.3.1", + "@dnd-kit/sortable": "^10.0.0", + "@dnd-kit/utilities": "^3.2.2", "@epicure/db": "workspace:*", "@hookform/resolvers": "^5.4.0", "@zxing/browser": "^0.2.1", diff --git a/packages/db/src/migrations/0028_smiling_ezekiel_stane.sql b/packages/db/src/migrations/0028_smiling_ezekiel_stane.sql new file mode 100644 index 0000000..bc13105 --- /dev/null +++ b/packages/db/src/migrations/0028_smiling_ezekiel_stane.sql @@ -0,0 +1 @@ +ALTER TABLE "shopping_list_items" ADD COLUMN "sort_order" integer DEFAULT 0 NOT NULL; \ No newline at end of file diff --git a/packages/db/src/migrations/meta/0028_snapshot.json b/packages/db/src/migrations/meta/0028_snapshot.json new file mode 100644 index 0000000..9623273 --- /dev/null +++ b/packages/db/src/migrations/meta/0028_snapshot.json @@ -0,0 +1,4491 @@ +{ + "id": "9c218727-7b9c-45cb-8f7a-48e95b341608", + "prevId": "40b6cd92-02f9-43e3-8842-8fb6febd44a6", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.accounts": { + "name": "accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "accounts_user_id_users_id_fk": { + "name": "accounts_user_id_users_id_fk", + "tableFrom": "accounts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "api_keys_user_id_users_id_fk": { + "name": "api_keys_user_id_users_id_fk", + "tableFrom": "api_keys", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_keys_key_hash_unique": { + "name": "api_keys_key_hash_unique", + "nullsNotDistinct": false, + "columns": [ + "key_hash" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "push_subscriptions_endpoint_unique": { + "name": "push_subscriptions_endpoint_unique", + "nullsNotDistinct": false, + "columns": [ + "endpoint" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "sessions_token_unique": { + "name": "sessions_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_ai_keys": { + "name": "user_ai_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_key": { + "name": "encrypted_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_ai_keys_user_id_users_id_fk": { + "name": "user_ai_keys_user_id_users_id_fk", + "tableFrom": "user_ai_keys", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_blocks": { + "name": "user_blocks", + "schema": "", + "columns": { + "blocker_id": { + "name": "blocker_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blocked_id": { + "name": "blocked_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_blocks_blocker_id_users_id_fk": { + "name": "user_blocks_blocker_id_users_id_fk", + "tableFrom": "user_blocks", + "tableTo": "users", + "columnsFrom": [ + "blocker_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_blocks_blocked_id_users_id_fk": { + "name": "user_blocks_blocked_id_users_id_fk", + "tableFrom": "user_blocks", + "tableTo": "users", + "columnsFrom": [ + "blocked_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_blocks_blocker_id_blocked_id_pk": { + "name": "user_blocks_blocker_id_blocked_id_pk", + "columns": [ + "blocker_id", + "blocked_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_follows": { + "name": "user_follows", + "schema": "", + "columns": { + "follower_id": { + "name": "follower_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "following_id": { + "name": "following_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_follows_follower_id_users_id_fk": { + "name": "user_follows_follower_id_users_id_fk", + "tableFrom": "user_follows", + "tableTo": "users", + "columnsFrom": [ + "follower_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_follows_following_id_users_id_fk": { + "name": "user_follows_following_id_users_id_fk", + "tableFrom": "user_follows", + "tableTo": "users", + "columnsFrom": [ + "following_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_follows_follower_id_following_id_pk": { + "name": "user_follows_follower_id_following_id_pk", + "columns": [ + "follower_id", + "following_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_model_prefs": { + "name": "user_model_prefs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text_provider": { + "name": "text_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text_model": { + "name": "text_model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vision_provider": { + "name": "vision_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "vision_model": { + "name": "vision_model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meal_plan_provider": { + "name": "meal_plan_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meal_plan_model": { + "name": "meal_plan_model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_model_prefs_user_id_users_id_fk": { + "name": "user_model_prefs_user_id_users_id_fk", + "tableFrom": "user_model_prefs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_model_prefs_user_id_unique": { + "name": "user_model_prefs_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_nutrition_goals": { + "name": "user_nutrition_goals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "calories_kcal": { + "name": "calories_kcal", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "protein_g": { + "name": "protein_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "carbs_g": { + "name": "carbs_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fat_g": { + "name": "fat_g", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_nutrition_goals_user_id_users_id_fk": { + "name": "user_nutrition_goals_user_id_users_id_fk", + "tableFrom": "user_nutrition_goals", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_nutrition_goals_user_id_unique": { + "name": "user_nutrition_goals_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bio": { + "name": "bio", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "private_bio": { + "name": "private_bio", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_private": { + "name": "is_private", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "user_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "tier": { + "name": "tier", + "type": "tier", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'free'" + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit_pref": { + "name": "unit_pref", + "type": "unit_pref", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'metric'" + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'en'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + }, + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + }, + "users_stripe_customer_id_unique": { + "name": "users_stripe_customer_id_unique", + "nullsNotDistinct": false, + "columns": [ + "stripe_customer_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verifications": { + "name": "verifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ingredients": { + "name": "ingredients", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "aliases": { + "name": "aliases", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "known_allergens": { + "name": "known_allergens", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "ingredients_name_unique": { + "name": "ingredients_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.recipe_ingredients": { + "name": "recipe_ingredients", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ingredient_id": { + "name": "ingredient_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw_name": { + "name": "raw_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "recipe_ingredients_recipe_idx": { + "name": "recipe_ingredients_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_ingredients_recipe_id_recipes_id_fk": { + "name": "recipe_ingredients_recipe_id_recipes_id_fk", + "tableFrom": "recipe_ingredients", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_ingredients_ingredient_id_ingredients_id_fk": { + "name": "recipe_ingredients_ingredient_id_ingredients_id_fk", + "tableFrom": "recipe_ingredients", + "tableTo": "ingredients", + "columnsFrom": [ + "ingredient_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.recipe_notes": { + "name": "recipe_notes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_notes_recipe_user_idx": { + "name": "recipe_notes_recipe_user_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_notes_recipe_id_recipes_id_fk": { + "name": "recipe_notes_recipe_id_recipes_id_fk", + "tableFrom": "recipe_notes", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_notes_user_id_users_id_fk": { + "name": "recipe_notes_user_id_users_id_fk", + "tableFrom": "recipe_notes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.recipe_photos": { + "name": "recipe_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_cover": { + "name": "is_cover", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "recipe_photos_recipe_id_recipes_id_fk": { + "name": "recipe_photos_recipe_id_recipes_id_fk", + "tableFrom": "recipe_photos", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.recipe_snapshots": { + "name": "recipe_snapshots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snapshot_data": { + "name": "snapshot_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipe_snapshots_recipe_idx": { + "name": "recipe_snapshots_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_snapshots_recipe_id_recipes_id_fk": { + "name": "recipe_snapshots_recipe_id_recipes_id_fk", + "tableFrom": "recipe_snapshots", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_snapshots_author_id_users_id_fk": { + "name": "recipe_snapshots_author_id_users_id_fk", + "tableFrom": "recipe_snapshots", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.recipe_steps": { + "name": "recipe_steps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "instruction": { + "name": "instruction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timer_seconds": { + "name": "timer_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "photo_url": { + "name": "photo_url", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "recipe_steps_recipe_idx": { + "name": "recipe_steps_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "recipe_steps_recipe_id_recipes_id_fk": { + "name": "recipe_steps_recipe_id_recipes_id_fk", + "tableFrom": "recipe_steps", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.recipe_variations": { + "name": "recipe_variations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "parent_recipe_id": { + "name": "parent_recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "child_recipe_id": { + "name": "child_recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ai_generated": { + "name": "ai_generated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "recipe_variations_parent_recipe_id_recipes_id_fk": { + "name": "recipe_variations_parent_recipe_id_recipes_id_fk", + "tableFrom": "recipe_variations", + "tableTo": "recipes", + "columnsFrom": [ + "parent_recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "recipe_variations_child_recipe_id_recipes_id_fk": { + "name": "recipe_variations_child_recipe_id_recipes_id_fk", + "tableFrom": "recipe_variations", + "tableTo": "recipes", + "columnsFrom": [ + "child_recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.recipes": { + "name": "recipes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "base_servings": { + "name": "base_servings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4 + }, + "visibility": { + "name": "visibility", + "type": "visibility", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'private'" + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ai_generated": { + "name": "ai_generated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "ai_model": { + "name": "ai_model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ai_prompt": { + "name": "ai_prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "dietary_tags": { + "name": "dietary_tags", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "dietary_verified": { + "name": "dietary_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "nutrition_data": { + "name": "nutrition_data", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "difficulty": { + "name": "difficulty", + "type": "difficulty", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "prep_mins": { + "name": "prep_mins", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "cook_mins": { + "name": "cook_mins", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "recipes_author_idx": { + "name": "recipes_author_idx", + "columns": [ + { + "expression": "author_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipes_visibility_idx": { + "name": "recipes_visibility_idx", + "columns": [ + { + "expression": "visibility", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "recipes_dietary_tags_gin": { + "name": "recipes_dietary_tags_gin", + "columns": [ + { + "expression": "dietary_tags", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "recipes_author_id_users_id_fk": { + "name": "recipes_author_id_users_id_fk", + "tableFrom": "recipes", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_allergens": { + "name": "user_allergens", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "allergen_tag": { + "name": "allergen_tag", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "user_allergens_user_id_users_id_fk": { + "name": "user_allergens_user_id_users_id_fk", + "tableFrom": "user_allergens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.collection_favorites": { + "name": "collection_favorites", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "collection_id": { + "name": "collection_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "collection_favorites_collection_idx": { + "name": "collection_favorites_collection_idx", + "columns": [ + { + "expression": "collection_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "collection_favorites_user_collection_idx": { + "name": "collection_favorites_user_collection_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "collection_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "collection_favorites_user_id_users_id_fk": { + "name": "collection_favorites_user_id_users_id_fk", + "tableFrom": "collection_favorites", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "collection_favorites_collection_id_collections_id_fk": { + "name": "collection_favorites_collection_id_collections_id_fk", + "tableFrom": "collection_favorites", + "tableTo": "collections", + "columnsFrom": [ + "collection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.collection_members": { + "name": "collection_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "collection_id": { + "name": "collection_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "collection_member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'viewer'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "collection_members_user_idx": { + "name": "collection_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "collection_members_collection_id_collections_id_fk": { + "name": "collection_members_collection_id_collections_id_fk", + "tableFrom": "collection_members", + "tableTo": "collections", + "columnsFrom": [ + "collection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "collection_members_user_id_users_id_fk": { + "name": "collection_members_user_id_users_id_fk", + "tableFrom": "collection_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.collection_recipes": { + "name": "collection_recipes", + "schema": "", + "columns": { + "collection_id": { + "name": "collection_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "collection_recipes_collection_id_collections_id_fk": { + "name": "collection_recipes_collection_id_collections_id_fk", + "tableFrom": "collection_recipes", + "tableTo": "collections", + "columnsFrom": [ + "collection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "collection_recipes_recipe_id_recipes_id_fk": { + "name": "collection_recipes_recipe_id_recipes_id_fk", + "tableFrom": "collection_recipes", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.collections": { + "name": "collections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "collections_user_idx": { + "name": "collections_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "collections_user_id_users_id_fk": { + "name": "collections_user_id_users_id_fk", + "tableFrom": "collections", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comment_reactions": { + "name": "comment_reactions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_id": { + "name": "comment_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "comment_reaction_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "comment_reactions_comment_idx": { + "name": "comment_reactions_comment_idx", + "columns": [ + { + "expression": "comment_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "comment_reactions_comment_id_comments_id_fk": { + "name": "comment_reactions_comment_id_comments_id_fk", + "tableFrom": "comment_reactions", + "tableTo": "comments", + "columnsFrom": [ + "comment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comment_reactions_user_id_users_id_fk": { + "name": "comment_reactions_user_id_users_id_fk", + "tableFrom": "comment_reactions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "comments_recipe_idx": { + "name": "comments_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "comments_recipe_id_recipes_id_fk": { + "name": "comments_recipe_id_recipes_id_fk", + "tableFrom": "comments", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comments_user_id_users_id_fk": { + "name": "comments_user_id_users_id_fk", + "tableFrom": "comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "comments_parent_id_comments_id_fk": { + "name": "comments_parent_id_comments_id_fk", + "tableFrom": "comments", + "tableTo": "comments", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cooking_history": { + "name": "cooking_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "cooked_at": { + "name": "cooked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "servings": { + "name": "servings", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "cooking_history_user_idx": { + "name": "cooking_history_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cooking_history_user_id_users_id_fk": { + "name": "cooking_history_user_id_users_id_fk", + "tableFrom": "cooking_history", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cooking_history_recipe_id_recipes_id_fk": { + "name": "cooking_history_recipe_id_recipes_id_fk", + "tableFrom": "cooking_history", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.favorites": { + "name": "favorites", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "favorites_user_idx": { + "name": "favorites_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "favorites_user_id_users_id_fk": { + "name": "favorites_user_id_users_id_fk", + "tableFrom": "favorites", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "favorites_recipe_id_recipes_id_fk": { + "name": "favorites_recipe_id_recipes_id_fk", + "tableFrom": "favorites", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "comment_id": { + "name": "comment_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "read": { + "name": "read", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_user_idx": { + "name": "notifications_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notifications_user_unread_idx": { + "name": "notifications_user_unread_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_user_id_users_id_fk": { + "name": "notifications_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_actor_id_users_id_fk": { + "name": "notifications_actor_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_recipe_id_recipes_id_fk": { + "name": "notifications_recipe_id_recipes_id_fk", + "tableFrom": "notifications", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_comment_id_comments_id_fk": { + "name": "notifications_comment_id_comments_id_fk", + "tableFrom": "notifications", + "tableTo": "comments", + "columnsFrom": [ + "comment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.ratings": { + "name": "ratings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "score": { + "name": "score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "review_text": { + "name": "review_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo_key": { + "name": "photo_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "ratings_user_idx": { + "name": "ratings_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "ratings_recipe_idx": { + "name": "ratings_recipe_idx", + "columns": [ + { + "expression": "recipe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "ratings_recipe_id_recipes_id_fk": { + "name": "ratings_recipe_id_recipes_id_fk", + "tableFrom": "ratings", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "ratings_user_id_users_id_fk": { + "name": "ratings_user_id_users_id_fk", + "tableFrom": "ratings", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.meal_plan_entries": { + "name": "meal_plan_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "meal_plan_id": { + "name": "meal_plan_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "weekday", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "meal_type": { + "name": "meal_type", + "type": "meal_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "recipe_id": { + "name": "recipe_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "servings": { + "name": "servings", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 2 + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "meal_plan_entries_plan_idx": { + "name": "meal_plan_entries_plan_idx", + "columns": [ + { + "expression": "meal_plan_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "meal_plan_entries_plan_day_meal_idx": { + "name": "meal_plan_entries_plan_day_meal_idx", + "columns": [ + { + "expression": "meal_plan_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "meal_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "meal_plan_entries_meal_plan_id_meal_plans_id_fk": { + "name": "meal_plan_entries_meal_plan_id_meal_plans_id_fk", + "tableFrom": "meal_plan_entries", + "tableTo": "meal_plans", + "columnsFrom": [ + "meal_plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "meal_plan_entries_recipe_id_recipes_id_fk": { + "name": "meal_plan_entries_recipe_id_recipes_id_fk", + "tableFrom": "meal_plan_entries", + "tableTo": "recipes", + "columnsFrom": [ + "recipe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.meal_plan_members": { + "name": "meal_plan_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "meal_plan_id": { + "name": "meal_plan_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "collection_member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'viewer'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "meal_plan_members_plan_idx": { + "name": "meal_plan_members_plan_idx", + "columns": [ + { + "expression": "meal_plan_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "meal_plan_members_user_idx": { + "name": "meal_plan_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "meal_plan_members_meal_plan_id_meal_plans_id_fk": { + "name": "meal_plan_members_meal_plan_id_meal_plans_id_fk", + "tableFrom": "meal_plan_members", + "tableTo": "meal_plans", + "columnsFrom": [ + "meal_plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "meal_plan_members_user_id_users_id_fk": { + "name": "meal_plan_members_user_id_users_id_fk", + "tableFrom": "meal_plan_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.meal_plans": { + "name": "meal_plans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "week_start": { + "name": "week_start", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "meal_plans_user_idx": { + "name": "meal_plans_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "meal_plans_user_week_idx": { + "name": "meal_plans_user_week_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "week_start", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "meal_plans_user_id_users_id_fk": { + "name": "meal_plans_user_id_users_id_fk", + "tableFrom": "meal_plans", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pantry_items": { + "name": "pantry_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ingredient_id": { + "name": "ingredient_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw_name": { + "name": "raw_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pantry_items_user_idx": { + "name": "pantry_items_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pantry_items_user_id_users_id_fk": { + "name": "pantry_items_user_id_users_id_fk", + "tableFrom": "pantry_items", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pantry_items_ingredient_id_ingredients_id_fk": { + "name": "pantry_items_ingredient_id_ingredients_id_fk", + "tableFrom": "pantry_items", + "tableTo": "ingredients", + "columnsFrom": [ + "ingredient_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shopping_list_items": { + "name": "shopping_list_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "list_id": { + "name": "list_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ingredient_id": { + "name": "ingredient_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw_name": { + "name": "raw_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "quantity": { + "name": "quantity", + "type": "numeric(10, 4)", + "primaryKey": false, + "notNull": false + }, + "unit": { + "name": "unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "aisle": { + "name": "aisle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "checked": { + "name": "checked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "in_pantry": { + "name": "in_pantry", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "shopping_list_items_list_id_shopping_lists_id_fk": { + "name": "shopping_list_items_list_id_shopping_lists_id_fk", + "tableFrom": "shopping_list_items", + "tableTo": "shopping_lists", + "columnsFrom": [ + "list_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shopping_list_items_ingredient_id_ingredients_id_fk": { + "name": "shopping_list_items_ingredient_id_ingredients_id_fk", + "tableFrom": "shopping_list_items", + "tableTo": "ingredients", + "columnsFrom": [ + "ingredient_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shopping_list_members": { + "name": "shopping_list_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "list_id": { + "name": "list_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "collection_member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'viewer'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shopping_list_members_list_idx": { + "name": "shopping_list_members_list_idx", + "columns": [ + { + "expression": "list_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shopping_list_members_user_idx": { + "name": "shopping_list_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shopping_list_members_list_id_shopping_lists_id_fk": { + "name": "shopping_list_members_list_id_shopping_lists_id_fk", + "tableFrom": "shopping_list_members", + "tableTo": "shopping_lists", + "columnsFrom": [ + "list_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shopping_list_members_user_id_users_id_fk": { + "name": "shopping_list_members_user_id_users_id_fk", + "tableFrom": "shopping_list_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shopping_lists": { + "name": "shopping_lists", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "generated_at": { + "name": "generated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "shopping_lists_user_id_users_id_fk": { + "name": "shopping_lists_user_id_users_id_fk", + "tableFrom": "shopping_lists", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_logs": { + "name": "audit_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_logs_created_idx": { + "name": "audit_logs_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_logs_user_id_users_id_fk": { + "name": "audit_logs_user_id_users_id_fk", + "tableFrom": "audit_logs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invites": { + "name": "invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "user_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'user'" + }, + "tier": { + "name": "tier", + "type": "tier", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'free'" + }, + "created_by_id": { + "name": "created_by_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "used_at": { + "name": "used_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "used_by_id": { + "name": "used_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "invites_created_by_id_users_id_fk": { + "name": "invites_created_by_id_users_id_fk", + "tableFrom": "invites", + "tableTo": "users", + "columnsFrom": [ + "created_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invites_used_by_id_users_id_fk": { + "name": "invites_used_by_id_users_id_fk", + "tableFrom": "invites", + "tableTo": "users", + "columnsFrom": [ + "used_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invites_token_uniq": { + "name": "invites_token_uniq", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reports": { + "name": "reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "reporter_id": { + "name": "reporter_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "report_target_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "report_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_by_id": { + "name": "reviewed_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "reports_status_idx": { + "name": "reports_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reports_reporter_id_users_id_fk": { + "name": "reports_reporter_id_users_id_fk", + "tableFrom": "reports", + "tableTo": "users", + "columnsFrom": [ + "reporter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reports_reviewed_by_id_users_id_fk": { + "name": "reports_reviewed_by_id_users_id_fk", + "tableFrom": "reports", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.site_settings": { + "name": "site_settings", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_secret": { + "name": "is_secret", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_by_id": { + "name": "updated_by_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "site_settings_updated_by_id_users_id_fk": { + "name": "site_settings_updated_by_id_users_id_fk", + "tableFrom": "site_settings", + "tableTo": "users", + "columnsFrom": [ + "updated_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tier_definitions": { + "name": "tier_definitions", + "schema": "", + "columns": { + "tier": { + "name": "tier", + "type": "tier", + "typeSchema": "public", + "primaryKey": true, + "notNull": true + }, + "max_recipes": { + "name": "max_recipes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "ai_calls_per_month": { + "name": "ai_calls_per_month", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "storage_mb": { + "name": "storage_mb", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "max_public_recipes": { + "name": "max_public_recipes", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_usage": { + "name": "user_usage", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "month": { + "name": "month", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ai_calls_used": { + "name": "ai_calls_used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "recipe_count": { + "name": "recipe_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "storage_used_mb": { + "name": "storage_used_mb", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "user_usage_user_month_idx": { + "name": "user_usage_user_month_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_usage_user_id_users_id_fk": { + "name": "user_usage_user_id_users_id_fk", + "tableFrom": "user_usage", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_usage_user_month_uniq": { + "name": "user_usage_user_month_uniq", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "month" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhook_deliveries": { + "name": "webhook_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "webhook_id": { + "name": "webhook_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event": { + "name": "event", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status_code": { + "name": "status_code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "success": { + "name": "success", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "webhook_deliveries_webhook_id_webhooks_id_fk": { + "name": "webhook_deliveries_webhook_id_webhooks_id_fk", + "tableFrom": "webhook_deliveries", + "tableTo": "webhooks", + "columnsFrom": [ + "webhook_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "webhooks_user_id_users_id_fk": { + "name": "webhooks_user_id_users_id_fk", + "tableFrom": "webhooks", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_reads": { + "name": "conversation_reads", + "schema": "", + "columns": { + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_read_at": { + "name": "last_read_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "conversation_reads_conversation_id_conversations_id_fk": { + "name": "conversation_reads_conversation_id_conversations_id_fk", + "tableFrom": "conversation_reads", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_reads_user_id_users_id_fk": { + "name": "conversation_reads_user_id_users_id_fk", + "tableFrom": "conversation_reads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversation_reads_conversation_id_user_id_pk": { + "name": "conversation_reads_conversation_id_user_id_pk", + "columns": [ + "conversation_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_a_id": { + "name": "user_a_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_b_id": { + "name": "user_b_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_message_at": { + "name": "last_message_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversations_last_message_idx": { + "name": "conversations_last_message_idx", + "columns": [ + { + "expression": "last_message_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_user_a_id_users_id_fk": { + "name": "conversations_user_a_id_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "user_a_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversations_user_b_id_users_id_fk": { + "name": "conversations_user_b_id_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "user_b_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "conversations_pair_uniq": { + "name": "conversations_pair_uniq", + "nullsNotDistinct": false, + "columns": [ + "user_a_id", + "user_b_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sender_id": { + "name": "sender_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "messages_conversation_idx": { + "name": "messages_conversation_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "messages_conversation_id_conversations_id_fk": { + "name": "messages_conversation_id_conversations_id_fk", + "tableFrom": "messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "messages_sender_id_users_id_fk": { + "name": "messages_sender_id_users_id_fk", + "tableFrom": "messages", + "tableTo": "users", + "columnsFrom": [ + "sender_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.processed_stripe_events": { + "name": "processed_stripe_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.tier": { + "name": "tier", + "schema": "public", + "values": [ + "free", + "pro" + ] + }, + "public.unit_pref": { + "name": "unit_pref", + "schema": "public", + "values": [ + "metric", + "imperial" + ] + }, + "public.user_role": { + "name": "user_role", + "schema": "public", + "values": [ + "user", + "moderator", + "admin" + ] + }, + "public.difficulty": { + "name": "difficulty", + "schema": "public", + "values": [ + "easy", + "medium", + "hard" + ] + }, + "public.visibility": { + "name": "visibility", + "schema": "public", + "values": [ + "private", + "unlisted", + "public" + ] + }, + "public.collection_member_role": { + "name": "collection_member_role", + "schema": "public", + "values": [ + "viewer", + "editor" + ] + }, + "public.comment_reaction_type": { + "name": "comment_reaction_type", + "schema": "public", + "values": [ + "like", + "love", + "laugh", + "wow", + "sad", + "fire" + ] + }, + "public.notification_type": { + "name": "notification_type", + "schema": "public", + "values": [ + "follow", + "comment", + "reply", + "reaction", + "rating", + "mention" + ] + }, + "public.meal_type": { + "name": "meal_type", + "schema": "public", + "values": [ + "breakfast", + "lunch", + "dinner", + "snack" + ] + }, + "public.weekday": { + "name": "weekday", + "schema": "public", + "values": [ + "mon", + "tue", + "wed", + "thu", + "fri", + "sat", + "sun" + ] + }, + "public.report_status": { + "name": "report_status", + "schema": "public", + "values": [ + "pending", + "reviewed", + "dismissed" + ] + }, + "public.report_target_type": { + "name": "report_target_type", + "schema": "public", + "values": [ + "recipe", + "comment", + "user" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/db/src/migrations/meta/_journal.json b/packages/db/src/migrations/meta/_journal.json index c199b93..e700441 100644 --- a/packages/db/src/migrations/meta/_journal.json +++ b/packages/db/src/migrations/meta/_journal.json @@ -197,6 +197,13 @@ "when": 1783667700330, "tag": "0027_special_siren", "breakpoints": true + }, + { + "idx": 28, + "version": "7", + "when": 1783671061049, + "tag": "0028_smiling_ezekiel_stane", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db/src/schema/meal-planning.ts b/packages/db/src/schema/meal-planning.ts index 6e09768..e0272de 100644 --- a/packages/db/src/schema/meal-planning.ts +++ b/packages/db/src/schema/meal-planning.ts @@ -73,6 +73,7 @@ export const shoppingListItems = pgTable("shopping_list_items", { aisle: text("aisle"), checked: boolean("checked").notNull().default(false), inPantry: boolean("in_pantry").notNull().default(false), + sortOrder: integer("sort_order").notNull().default(0), }); export const shoppingListMembers = pgTable("shopping_list_members", { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa6495a..d060d94 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,15 @@ importers: '@base-ui/react': specifier: ^1.6.0 version: 1.6.0(@types/react@19.2.17)(react-dom@19.2.4(react@19.2.4))(react@19.2.4) + '@dnd-kit/core': + specifier: ^6.3.1 + version: 6.3.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4) + '@dnd-kit/sortable': + specifier: ^10.0.0 + version: 10.0.0(@dnd-kit/core@6.3.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4) + '@dnd-kit/utilities': + specifier: ^3.2.2 + version: 3.2.2(react@19.2.4) '@epicure/db': specifier: workspace:* version: link:../../packages/db @@ -629,6 +638,28 @@ packages: resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==} engines: {node: '>=20.19.0'} + '@dnd-kit/accessibility@3.1.1': + resolution: {integrity: sha512-2P+YgaXF+gRsIihwwY1gCsQSYnu9Zyj2py8kY5fFvUM1qm2WA2u639R6YNVfU4GWr+ZM5mqEsfHZZLoRONbemw==} + peerDependencies: + react: '>=16.8.0' + + '@dnd-kit/core@6.3.1': + resolution: {integrity: sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==} + peerDependencies: + react: '>=16.8.0' + react-dom: '>=16.8.0' + + '@dnd-kit/sortable@10.0.0': + resolution: {integrity: sha512-+xqhmIIzvAYMGfBYYnbKuNicfSsk4RksY2XdmJhT+HAC01nix6fHCztU68jooFiMUB01Ky3F0FyOvhG/BZrWkg==} + peerDependencies: + '@dnd-kit/core': ^6.3.0 + react: '>=16.8.0' + + '@dnd-kit/utilities@3.2.2': + resolution: {integrity: sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg==} + peerDependencies: + react: '>=16.8.0' + '@dotenvx/dotenvx@1.75.1': resolution: {integrity: sha512-/BITOC9dmS/edY2zQwZNicQ059O6RKabtQfyEafV0nGtfYRNHYy1DIPiYVcov40+tob9hfmBnbR963dS+EQ1DQ==} hasBin: true @@ -6010,6 +6041,31 @@ snapshots: '@csstools/css-tokenizer@4.0.0': {} + '@dnd-kit/accessibility@3.1.1(react@19.2.4)': + dependencies: + react: 19.2.4 + tslib: 2.8.1 + + '@dnd-kit/core@6.3.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4)': + dependencies: + '@dnd-kit/accessibility': 3.1.1(react@19.2.4) + '@dnd-kit/utilities': 3.2.2(react@19.2.4) + react: 19.2.4 + react-dom: 19.2.4(react@19.2.4) + tslib: 2.8.1 + + '@dnd-kit/sortable@10.0.0(@dnd-kit/core@6.3.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react@19.2.4)': + dependencies: + '@dnd-kit/core': 6.3.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4) + '@dnd-kit/utilities': 3.2.2(react@19.2.4) + react: 19.2.4 + tslib: 2.8.1 + + '@dnd-kit/utilities@3.2.2(react@19.2.4)': + dependencies: + react: 19.2.4 + tslib: 2.8.1 + '@dotenvx/dotenvx@1.75.1': dependencies: '@dotenvx/primitives': 0.8.0