MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / parseNote

Function parseNote

integrations/raycast/src/lib/zen.ts:83–109  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

81}
82
83export function parseNote(value: unknown): ZenNote | null {
84 if (!isRecord(value)) return null;
85 if (typeof value.path !== "string" || !value.path.trim()) return null;
86
87 const title =
88 typeof value.title === "string" && value.title.trim()
89 ? value.title
90 : titleFromPath(value.path);
91 const folder = parseFolder(value.folder);
92 const updatedAt =
93 typeof value.updatedAt === "number" && Number.isFinite(value.updatedAt)
94 ? value.updatedAt
95 : 0;
96 const tags = Array.isArray(value.tags)
97 ? value.tags.filter((tag): tag is string => typeof tag === "string")
98 : [];
99
100 return {
101 path: value.path,
102 title,
103 folder,
104 updatedAt,
105 tags,
106 hasAttachments: value.hasAttachments === true,
107 excerpt: typeof value.excerpt === "string" ? value.excerpt : "",
108 };
109}
110
111export async function loadVaultRoot(): Promise<string | null> {
112 const { stdout } = await execZen(["vault", "info", "--json"]);

Callers 1

updateNoteArchiveStateFunction · 0.90

Calls 3

parseFolderFunction · 0.85
isRecordFunction · 0.70
titleFromPathFunction · 0.70

Tested by

no test coverage detected