Implement lists module and dev login setup

This commit is contained in:
ginnoir
2026-05-06 03:49:03 -05:00
parent 744c1119a9
commit 7e3ae6eb04
31 changed files with 1525 additions and 63 deletions
+92
View File
@@ -0,0 +1,92 @@
import type { ModuleManifest } from "../_core/module";
import { z } from "zod";
import { addItemToDefaultList } from "./server/actions";
import { listLists, searchItems, searchLists } from "./server/queries";
const listIdsSchema = z.union([z.literal("all"), z.array(z.string().uuid())]);
const manifest: ModuleManifest = {
id: "lists",
name: "Lists",
nav: { href: "/lists", label: "Lists", icon: "list" },
entities: [
{
type: "lists.list",
label: { singular: "List", plural: "Lists" },
share: { canShare: true, defaultCapabilities: ["read", "write"] },
search: { search: searchLists },
resolveUrl: (id) => `/lists/${id}`,
},
{
type: "lists.item",
label: { singular: "List item", plural: "List items" },
share: { canShare: false },
search: { search: searchItems },
resolveUrl: (id) => `/lists/items/${id}`,
},
],
dashboardWidgets: [
{
id: "lists.list",
title: "List items",
description: "Open or completed items from selected lists.",
category: "Lists",
defaultSize: { w: 4, h: 3 },
minSize: { w: 3, h: 2 },
defaultPriority: 30,
configSchema: z.object({
listIds: listIdsSchema,
showCompleted: z.boolean(),
limit: z.number().int().min(1).max(50).optional(),
}),
defaultConfig: { listIds: "all", showCompleted: false },
resolveConfigOptions: async () => ({
lists: (await listLists()).map((list) => ({
id: list.id,
type: list.type,
name: list.name,
})),
}),
render: ({ config }) => {
const parsed = z
.object({
listIds: listIdsSchema,
showCompleted: z.boolean(),
limit: z.number().int().min(1).max(50).optional(),
})
.parse(config);
return (
<div className="text-sm text-muted-foreground">
{parsed.showCompleted ? "List items" : "Open list items"}
</div>
);
},
},
],
quickAdds: [
{
id: "lists.add-shopping",
label: "Add to shopping",
icon: "shopping-cart",
action: async () => {
await addItemToDefaultList({ type: "shopping", text: "New item" });
},
},
{
id: "lists.add-task",
label: "Add to tasks",
icon: "list-checks",
action: async () => {
await addItemToDefaultList({ type: "task", text: "New task" });
},
},
{
id: "lists.new-list",
label: "New list",
icon: "list-plus",
action: () => undefined,
},
],
};
export default manifest;