MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / normalizeDependencyEntry

Function normalizeDependencyEntry

src/utils/dependencyUtils.ts:32–55  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

30}
31
32export function normalizeDependencyEntry(value: unknown): TaskDependency | null {
33 if (typeof value === "string") {
34 const trimmed = value.trim();
35 if (!trimmed) return null;
36 return { uid: parseLinkToPath(trimmed), reltype: DEFAULT_DEPENDENCY_RELTYPE };
37 }
38
39 if (typeof value === "object" && value !== null) {
40 const raw = value as Record<string, unknown>;
41 const rawUid = typeof raw.uid === "string" ? raw.uid.trim() : "";
42 if (!rawUid) {
43 return null;
44 }
45 const normalizedUid = parseLinkToPath(rawUid);
46 const reltypeRaw = typeof raw.reltype === "string" ? raw.reltype.trim().toUpperCase() : "";
47 const reltype = isValidDependencyRelType(reltypeRaw)
48 ? (reltypeRaw)
49 : DEFAULT_DEPENDENCY_RELTYPE;
50 const gap = typeof raw.gap === "string" && raw.gap.trim().length > 0 ? raw.gap.trim() : undefined;
51 return gap ? { uid: normalizedUid, reltype, gap } : { uid: normalizedUid, reltype };
52 }
53
54 return null;
55}
56
57export function normalizeDependencyList(value: unknown): TaskDependency[] | undefined {
58 if (value === null || value === undefined) {

Calls 2

parseLinkToPathFunction · 0.90
isValidDependencyRelTypeFunction · 0.85

Tested by

no test coverage detected