management: produce catalog v3 — columns, form fields, export mapping #42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Producer side of #41.
apps/management/lib/db/schema.tsinventoryalready hasbrand,part_number,category,weight_grams,shippable,install_service(migrationdrizzle/0010_new_frog_thor.sql), so this adds the four remaining pieces and rewires the export.Schema
Generated, committed migration adding to
inventory, all nullable or defaulted so existing rows are safe:oem_numbers text[] not null default '{}'— mirror the existingimagescolumn pattern.fitment text[] not null default '{}'.price_updated_at timestamp— set it inupdateInventorywheneversellPricechanges, so the storefront date is real rather than operator-maintained.habisandreadyalready fall out ofstock > 0.indentis the new information, so addallow_indent boolean not null default falsemeaning "orderable when out of stock". Export then mapsstock > 0 ? "ready" : allowIndent ? "indent" : "habis". One boolean column, no dual source of truth againststock, and no way for availability to contradict the stock ledger.Wiring
lib/db/validators.ts—InventoryItemSchema,CreateInventorySchema,UpdateInventorySchema.lib/catalog.ts#getPublicCatalog— select and map the new columns, emitavailabilityper the rule above, dropinStock.buyPrice,avgCost, suppliers and the rawstocknumber stay out of the payload.lib/store/deploy.ts— add the new columns toSTOREFRONT_COLUMNSso edits actually trigger a republish.app/(dashboard)/stok/add-inventory-modal.tsxandinventory-edit-form.tsx— repeatable-row inputs forfitmentandoemNumbers(same shape as the existingimagesURL rows) and anallow_indentcheckbox. Read-only display ininventory-details-sheet.tsx.lib/mcp/tools/inventory.tscreate/update mirror the new fields.Acceptance
pnpm --filter garage testpasses withlib/catalog.test.tsextended:stock: 0+allowIndent: true→"indent";stock: 0+ false →"habis";stock > 0→"ready"regardless of the flag;price_updated_atis emitted as an ISO date and is null whensell_priceis 0;oem_numbers/fitmentround-trip and default to[].lib/store/deploy.test.tsasserts the new columns are storefront-affecting. Ship together with #41 — the strict contract means a half-landed bump breaks the store build.