MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / resolveDependencyEntry

Function resolveDependencyEntry

src/utils/dependencyUtils.ts:130–169  ·  view source on GitHub ↗
(
	app: App,
	sourcePath: string,
	entry: TaskDependency | string
)

Source from the content-addressed store, hash-verified

128}
129
130export function resolveDependencyEntry(
131 app: App,
132 sourcePath: string,
133 entry: TaskDependency | string
134): DependencyResolution | null {
135 const rawUid = extractDependencyUid(entry);
136 if (!rawUid) {
137 return null;
138 }
139
140 const target = parseLinkToPath(rawUid);
141
142 if (!target) {
143 return null;
144 }
145
146 // Try multiple candidate targets to tolerate .md suffix and parsed linktext variants
147 const candidates = new Set<string>();
148 candidates.add(target);
149 if (target.endsWith(".md")) {
150 candidates.add(target.replace(/\.md$/i, ""));
151 }
152 const parsed = parseLinktext(target);
153 if (parsed.path && parsed.path !== target) {
154 candidates.add(parsed.path);
155 }
156
157 for (const candidate of candidates) {
158 const resolved = app.metadataCache.getFirstLinkpathDest(candidate, sourcePath);
159 if (resolved instanceof TFile) {
160 return { path: resolved.path, file: resolved };
161 }
162 const fallback = app.vault.getAbstractFileByPath(candidate);
163 if (fallback instanceof TFile) {
164 return { path: fallback.path, file: fallback };
165 }
166 }
167
168 return null;
169}
170
171export function formatDependencyLink(app: App, sourcePath: string, targetPath: string, useMarkdownLinks?: boolean): string {
172 const target = app.vault.getAbstractFileByPath(targetPath);

Callers 6

indexTaskFileMethod · 0.90
getBlockedByTaskPathsFunction · 0.90
getDependencyDisplayLinkFunction · 0.90

Calls 4

parseLinkToPathFunction · 0.90
parseLinktextFunction · 0.90
extractDependencyUidFunction · 0.85
getAbstractFileByPathMethod · 0.80

Tested by

no test coverage detected