Compare commits
4 Commits
e34a2cad11
...
v1.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f434f39bf | |||
| 6ae41c4ffa | |||
| be168c8329 | |||
| 9191f0fe24 |
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": false,
|
||||
"includes": ["**", "!src/client/routeTree.gen.ts"]
|
||||
"includes": ["**", "!src/client/routeTree.gen.ts", "!drizzle", "!.planning"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
|
||||
7
bun.lock
7
bun.lock
@@ -12,6 +12,7 @@
|
||||
"@tanstack/react-router": "^1.167.0",
|
||||
"clsx": "^2.1.1",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"framer-motion": "^12.38.0",
|
||||
"hono": "^4.12.8",
|
||||
"lucide-react": "^0.577.0",
|
||||
"react": "^19.2.4",
|
||||
@@ -502,6 +503,8 @@
|
||||
|
||||
"forwarded": ["forwarded@0.2.0", "", {}, "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="],
|
||||
|
||||
"framer-motion": ["framer-motion@12.38.0", "", { "dependencies": { "motion-dom": "^12.38.0", "motion-utils": "^12.36.0", "tslib": "^2.4.0" }, "peerDependencies": { "@emotion/is-prop-valid": "*", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["@emotion/is-prop-valid", "react", "react-dom"] }, "sha512-rFYkY/pigbcswl1XQSb7q424kSTQ8q6eAC+YUsSKooHQYuLdzdHjrt6uxUC+PRAO++q5IS7+TamgIw1AphxR+g=="],
|
||||
|
||||
"fresh": ["fresh@2.0.0", "", {}, "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A=="],
|
||||
|
||||
"fs-constants": ["fs-constants@1.0.0", "", {}, "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="],
|
||||
@@ -632,6 +635,10 @@
|
||||
|
||||
"mkdirp-classic": ["mkdirp-classic@0.5.3", "", {}, "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="],
|
||||
|
||||
"motion-dom": ["motion-dom@12.38.0", "", { "dependencies": { "motion-utils": "^12.36.0" } }, "sha512-pdkHLD8QYRp8VfiNLb8xIBJis1byQ9gPT3Jnh2jqfFtAsWUA3dEepDlsWe/xMpO8McV+VdpKVcp+E+TGJEtOoA=="],
|
||||
|
||||
"motion-utils": ["motion-utils@12.36.0", "", {}, "sha512-eHWisygbiwVvf6PZ1vhaHCLamvkSbPIeAYxWUuL3a2PD/TROgE7FvfHWTIH4vMl798QLfMw15nRqIaRDXTlYRg=="],
|
||||
|
||||
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
|
||||
"nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||
|
||||
99
package.json
99
package.json
@@ -1,51 +1,52 @@
|
||||
{
|
||||
"name": "gearbox",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "concurrently -k -c \"blue,green\" -n \"server,client\" \"bun run dev:server\" \"bun run dev:client\"",
|
||||
"dev:client": "vite",
|
||||
"dev:server": "bun --hot src/server/index.ts",
|
||||
"build": "vite build",
|
||||
"db:generate": "bunx drizzle-kit generate",
|
||||
"db:push": "bunx drizzle-kit push",
|
||||
"test": "bun test",
|
||||
"lint": "bunx @biomejs/biome check ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.4.7",
|
||||
"@tanstack/react-query-devtools": "^5.91.3",
|
||||
"@tanstack/react-router-devtools": "^1.166.7",
|
||||
"@tanstack/router-plugin": "^1.166.9",
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"@types/bun": "latest",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"better-sqlite3": "^12.8.0",
|
||||
"concurrently": "^9.1.2",
|
||||
"drizzle-kit": "^0.31.9",
|
||||
"vite": "^8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/zod-validator": "^0.7.6",
|
||||
"@modelcontextprotocol/sdk": "^1.29.0",
|
||||
"@tailwindcss/vite": "^4.2.1",
|
||||
"@tanstack/react-query": "^5.90.21",
|
||||
"@tanstack/react-router": "^1.167.0",
|
||||
"clsx": "^2.1.1",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"hono": "^4.12.8",
|
||||
"lucide-react": "^0.577.0",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
"recharts": "^3.8.0",
|
||||
"tailwindcss": "^4.2.1",
|
||||
"zod": "^4.3.6",
|
||||
"zustand": "^5.0.11"
|
||||
}
|
||||
"name": "gearbox",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "concurrently -k -c \"blue,green\" -n \"server,client\" \"bun run dev:server\" \"bun run dev:client\"",
|
||||
"dev:client": "vite",
|
||||
"dev:server": "bun --hot src/server/index.ts",
|
||||
"build": "vite build",
|
||||
"db:generate": "bunx drizzle-kit generate",
|
||||
"db:push": "bunx drizzle-kit push",
|
||||
"test": "bun test",
|
||||
"lint": "bunx @biomejs/biome check ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.4.7",
|
||||
"@tanstack/react-query-devtools": "^5.91.3",
|
||||
"@tanstack/react-router-devtools": "^1.166.7",
|
||||
"@tanstack/router-plugin": "^1.166.9",
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"@types/bun": "latest",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"better-sqlite3": "^12.8.0",
|
||||
"concurrently": "^9.1.2",
|
||||
"drizzle-kit": "^0.31.9",
|
||||
"vite": "^8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/zod-validator": "^0.7.6",
|
||||
"@modelcontextprotocol/sdk": "^1.29.0",
|
||||
"@tailwindcss/vite": "^4.2.1",
|
||||
"@tanstack/react-query": "^5.90.21",
|
||||
"@tanstack/react-router": "^1.167.0",
|
||||
"clsx": "^2.1.1",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"framer-motion": "^12.38.0",
|
||||
"hono": "^4.12.8",
|
||||
"lucide-react": "^0.577.0",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
"recharts": "^3.8.0",
|
||||
"tailwindcss": "^4.2.1",
|
||||
"zod": "^4.3.6",
|
||||
"zustand": "^5.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,12 +264,20 @@ export function WeightSummaryCard({ items }: WeightSummaryCardProps) {
|
||||
label="Consumable"
|
||||
weight={consumableWeight}
|
||||
unit={unit}
|
||||
percent={totalWeight > 0 ? consumableWeight / totalWeight : undefined}
|
||||
percent={
|
||||
totalWeight > 0 ? consumableWeight / totalWeight : undefined
|
||||
}
|
||||
/>
|
||||
<div className="border-t border-gray-200 mt-1.5 pt-1.5">
|
||||
<div className="flex items-center gap-3 py-1.5">
|
||||
<LucideIcon name="sigma" size={10} className="text-gray-400 shrink-0 ml-0.5" />
|
||||
<span className="text-sm font-medium text-gray-700 flex-1">Total</span>
|
||||
<LucideIcon
|
||||
name="sigma"
|
||||
size={10}
|
||||
className="text-gray-400 shrink-0 ml-0.5"
|
||||
/>
|
||||
<span className="text-sm font-medium text-gray-700 flex-1">
|
||||
Total
|
||||
</span>
|
||||
<span className="text-sm font-bold text-gray-900 tabular-nums">
|
||||
{formatWeight(totalWeight, unit)}
|
||||
</span>
|
||||
|
||||
@@ -113,7 +113,10 @@ export function useUpdateItemClassification(setupId: number) {
|
||||
mutationFn: ({
|
||||
itemId,
|
||||
classification,
|
||||
}: { itemId: number; classification: string }) =>
|
||||
}: {
|
||||
itemId: number;
|
||||
classification: string;
|
||||
}) =>
|
||||
apiPatch<{ success: boolean }>(
|
||||
`/api/setups/${setupId}/items/${itemId}/classification`,
|
||||
{ classification },
|
||||
|
||||
@@ -59,7 +59,10 @@ function RootLayout() {
|
||||
|
||||
// Don't show onboarding wizard until user has created an account
|
||||
const showWizard =
|
||||
!onboardingLoading && onboardingComplete !== "true" && !wizardDismissed && isAuthenticated;
|
||||
!onboardingLoading &&
|
||||
onboardingComplete !== "true" &&
|
||||
!wizardDismissed &&
|
||||
isAuthenticated;
|
||||
|
||||
const isItemPanelOpen = panelMode !== "closed";
|
||||
const isCandidatePanelOpen = candidatePanelMode !== "closed";
|
||||
|
||||
@@ -9,11 +9,11 @@ import { ItemCard } from "../../components/ItemCard";
|
||||
import { SetupCard } from "../../components/SetupCard";
|
||||
import { ThreadCard } from "../../components/ThreadCard";
|
||||
import { useCategories } from "../../hooks/useCategories";
|
||||
import { useCurrency } from "../../hooks/useCurrency";
|
||||
import { useItems } from "../../hooks/useItems";
|
||||
import { useCreateSetup, useSetups } from "../../hooks/useSetups";
|
||||
import { useThreads } from "../../hooks/useThreads";
|
||||
import { useTotals } from "../../hooks/useTotals";
|
||||
import { useCurrency } from "../../hooks/useCurrency";
|
||||
import { useWeightUnit } from "../../hooks/useWeightUnit";
|
||||
import { formatPrice, formatWeight } from "../../lib/formatters";
|
||||
import { LucideIcon } from "../../lib/iconData";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { DashboardCard } from "../components/DashboardCard";
|
||||
import { useCurrency } from "../hooks/useCurrency";
|
||||
import { useSetups } from "../hooks/useSetups";
|
||||
import { useThreads } from "../hooks/useThreads";
|
||||
import { useTotals } from "../hooks/useTotals";
|
||||
import { useWeightUnit } from "../hooks/useWeightUnit";
|
||||
import { useCurrency } from "../hooks/useCurrency";
|
||||
import { formatPrice, formatWeight } from "../lib/formatters";
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
@@ -35,7 +35,10 @@ function DashboardPage() {
|
||||
label: "Weight",
|
||||
value: formatWeight(global?.totalWeight ?? null, unit),
|
||||
},
|
||||
{ label: "Cost", value: formatPrice(global?.totalCost ?? null, currency) },
|
||||
{
|
||||
label: "Cost",
|
||||
value: formatPrice(global?.totalCost ?? null, currency),
|
||||
},
|
||||
]}
|
||||
emptyText="Get started"
|
||||
/>
|
||||
|
||||
@@ -4,13 +4,13 @@ import { CategoryHeader } from "../../components/CategoryHeader";
|
||||
import { ItemCard } from "../../components/ItemCard";
|
||||
import { ItemPicker } from "../../components/ItemPicker";
|
||||
import { WeightSummaryCard } from "../../components/WeightSummaryCard";
|
||||
import { useCurrency } from "../../hooks/useCurrency";
|
||||
import {
|
||||
useDeleteSetup,
|
||||
useRemoveSetupItem,
|
||||
useSetup,
|
||||
useUpdateItemClassification,
|
||||
} from "../../hooks/useSetups";
|
||||
import { useCurrency } from "../../hooks/useCurrency";
|
||||
import { useWeightUnit } from "../../hooks/useWeightUnit";
|
||||
import { formatPrice, formatWeight } from "../../lib/formatters";
|
||||
import { LucideIcon } from "../../lib/iconData";
|
||||
|
||||
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
||||
import { Hono } from "hono";
|
||||
import { db as prodDb } from "@/db/index.ts";
|
||||
import { db as prodDb } from "../../db/index.ts";
|
||||
import { getUserCount, verifyApiKey } from "../services/auth.service.ts";
|
||||
import { getCollectionSummary } from "./resources/collection.ts";
|
||||
import {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { db as prodDb } from "@/db/index.ts";
|
||||
import type { db as prodDb } from "../../../db/index.ts";
|
||||
import { getAllCategories } from "../../services/category.service.ts";
|
||||
import { getAllItems } from "../../services/item.service.ts";
|
||||
import { getAllSetups } from "../../services/setup.service.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { db as prodDb } from "@/db/index.ts";
|
||||
import type { db as prodDb } from "../../../db/index.ts";
|
||||
import {
|
||||
createCategory,
|
||||
getAllCategories,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { db as prodDb } from "@/db/index.ts";
|
||||
import type { db as prodDb } from "../../../db/index.ts";
|
||||
import {
|
||||
createItem,
|
||||
deleteItem,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { db as prodDb } from "@/db/index.ts";
|
||||
import type { db as prodDb } from "../../../db/index.ts";
|
||||
import {
|
||||
createSetup,
|
||||
getAllSetups,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { db as prodDb } from "@/db/index.ts";
|
||||
import type { db as prodDb } from "../../../db/index.ts";
|
||||
import {
|
||||
createCandidate,
|
||||
createThread,
|
||||
|
||||
@@ -1,9 +1,48 @@
|
||||
import { afterEach, describe, expect, it } from "bun:test";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "bun:test";
|
||||
import { existsSync, rmSync } from "node:fs";
|
||||
import type { Server } from "bun";
|
||||
import { fetchImageFromUrl } from "../../src/server/services/image.service.ts";
|
||||
|
||||
const TEST_UPLOADS_DIR = "test-uploads";
|
||||
|
||||
// 1x1 transparent PNG (smallest valid PNG)
|
||||
const TINY_PNG = new Uint8Array([
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
|
||||
0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06,
|
||||
0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44,
|
||||
0x41, 0x54, 0x78, 0x9c, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xe2, 0x21,
|
||||
0xbc, 0x33, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
|
||||
0x82,
|
||||
]);
|
||||
|
||||
let server: Server;
|
||||
let baseUrl: string;
|
||||
|
||||
beforeAll(() => {
|
||||
server = Bun.serve({
|
||||
port: 0,
|
||||
fetch(req) {
|
||||
const url = new URL(req.url);
|
||||
if (url.pathname === "/image.png") {
|
||||
return new Response(TINY_PNG, {
|
||||
headers: { "Content-Type": "image/png" },
|
||||
});
|
||||
}
|
||||
if (url.pathname === "/page.html") {
|
||||
return new Response("<html></html>", {
|
||||
headers: { "Content-Type": "text/html" },
|
||||
});
|
||||
}
|
||||
return new Response("Not found", { status: 404 });
|
||||
},
|
||||
});
|
||||
baseUrl = `http://localhost:${server.port}`;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
server.stop(true);
|
||||
});
|
||||
|
||||
describe("Image Service", () => {
|
||||
afterEach(() => {
|
||||
if (existsSync(TEST_UPLOADS_DIR)) {
|
||||
@@ -13,8 +52,7 @@ describe("Image Service", () => {
|
||||
|
||||
describe("fetchImageFromUrl", () => {
|
||||
it("fetches a valid image URL and saves to disk", async () => {
|
||||
const imageUrl =
|
||||
"https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png";
|
||||
const imageUrl = `${baseUrl}/image.png`;
|
||||
const result = await fetchImageFromUrl(imageUrl, TEST_UPLOADS_DIR);
|
||||
|
||||
expect(result.filename).toMatch(/^\d+-[\w-]+\.png$/);
|
||||
@@ -26,7 +64,7 @@ describe("Image Service", () => {
|
||||
|
||||
it("rejects non-image content type", async () => {
|
||||
await expect(
|
||||
fetchImageFromUrl("https://example.com/", TEST_UPLOADS_DIR),
|
||||
fetchImageFromUrl(`${baseUrl}/page.html`, TEST_UPLOADS_DIR),
|
||||
).rejects.toThrow("Invalid content type");
|
||||
});
|
||||
|
||||
@@ -41,5 +79,11 @@ describe("Image Service", () => {
|
||||
fetchImageFromUrl("ftp://example.com/image.png", TEST_UPLOADS_DIR),
|
||||
).rejects.toThrow("URL must use HTTP or HTTPS");
|
||||
});
|
||||
|
||||
it("rejects 404 responses", async () => {
|
||||
await expect(
|
||||
fetchImageFromUrl(`${baseUrl}/missing.jpg`, TEST_UPLOADS_DIR),
|
||||
).rejects.toThrow("HTTP 404");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -434,7 +434,10 @@ describe("Thread Service", () => {
|
||||
});
|
||||
|
||||
it("returns { success: false, error } when thread status is 'resolved'", () => {
|
||||
const thread = createThread(db, { name: "Resolved Thread", categoryId: 1 });
|
||||
const thread = createThread(db, {
|
||||
name: "Resolved Thread",
|
||||
categoryId: 1,
|
||||
});
|
||||
const candidate = createCandidate(db, thread.id, {
|
||||
name: "Winner",
|
||||
categoryId: 1,
|
||||
|
||||
Reference in New Issue
Block a user