/// import { Cell, computed, Default, NAME, pattern, UI } from "commontools"; /** Wrap all fields of T in Cell<> for write access */ type Cellify = { [K in keyof T]: Cell }; export type ItemType = "book" | "article" | "paper" | "video"; export type ItemStatus = "want" | "reading" | "finished" | "abandoned"; /** Raw data shape - use in collection patterns */ export interface ReadingItem { title: string; author: Default; url: Default; type: Default; status: Default; rating: Default; notes: Default; addedAt: number; finishedAt: Default; } interface Input { item: Cellify; } /** #book #article #reading */ interface Output { item: ReadingItem; } export default pattern(({ item }) => { return { [NAME]: computed(() => `Reading: ${item.title}`), [UI]: ( {item.title || "New Item"} ), item, }; });