(value: unknown)
| 30 | } |
| 31 | |
| 32 | export 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 | |
| 57 | export function normalizeDependencyList(value: unknown): TaskDependency[] | undefined { |
| 58 | if (value === null || value === undefined) { |
no test coverage detected