Merge branch 'worktree-agent-a7e6e4b2' into Develop

# Conflicts:
#	.planning/REQUIREMENTS.md
#	.planning/ROADMAP.md
#	.planning/STATE.md
#	drizzle/meta/_journal.json
#	src/db/schema.ts
#	src/db/seed.ts
#	src/shared/schemas.ts
#	src/shared/types.ts
This commit is contained in:
2026-04-05 13:13:26 +02:00
18 changed files with 1863 additions and 232 deletions

View File

@@ -0,0 +1,30 @@
import { Hono } from "hono";
import { parseId } from "../lib/params.ts";
import {
getGlobalItemWithOwnerCount,
searchGlobalItems,
} from "../services/global-item.service.ts";
type Env = { Variables: { db?: any } };
const app = new Hono<Env>();
app.get("/", (c) => {
const db = c.get("db");
const q = c.req.query("q");
const items = searchGlobalItems(db, q || undefined);
return c.json(items);
});
app.get("/:id", (c) => {
const db = c.get("db");
const id = parseId(c.req.param("id"));
if (!id) return c.json({ error: "Invalid global item ID" }, 400);
const item = getGlobalItemWithOwnerCount(db, id);
if (!item) return c.json({ error: "Global item not found" }, 404);
return c.json(item);
});
export { app as globalItemRoutes };

View File

@@ -1,8 +1,16 @@
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { createItemSchema, updateItemSchema } from "../../shared/schemas.ts";
import {
createItemSchema,
linkItemSchema,
updateItemSchema,
} from "../../shared/schemas.ts";
import { parseId } from "../lib/params.ts";
import { exportItemsCsv, importItemsCsv } from "../services/csv.service.ts";
import {
linkItemToGlobal,
unlinkItemFromGlobal,
} from "../services/global-item.service.ts";
import {
createItem,
deleteItem,
@@ -114,4 +122,32 @@ app.delete("/:id", async (c) => {
return c.json({ success: true });
});
app.post("/:id/link", zValidator("json", linkItemSchema), (c) => {
const db = c.get("db");
const id = parseId(c.req.param("id"));
if (!id) return c.json({ error: "Invalid item ID" }, 400);
const item = getItemById(db, id);
if (!item) return c.json({ error: "Item not found" }, 404);
try {
const link = linkItemToGlobal(db, id, c.req.valid("json").globalItemId);
return c.json(link, 201);
} catch {
return c.json({ error: "Item already linked to a global item" }, 409);
}
});
app.delete("/:id/link", (c) => {
const db = c.get("db");
const id = parseId(c.req.param("id"));
if (!id) return c.json({ error: "Invalid item ID" }, 400);
const item = getItemById(db, id);
if (!item) return c.json({ error: "Item not found" }, 404);
unlinkItemFromGlobal(db, id);
return c.json({ success: true });
});
export { app as itemRoutes };