MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / oneRowPerRoute

Function oneRowPerRoute

src/ui-server/api/routes.ts:111–142  ·  view source on GitHub ↗

* The manifest's rows folded to one per route, in its order: the row naming * the route's root (the handler a resolver bound, or the component a screen * renders), else the route's first row. A route whose root is its own inline * body is that route, labelled as an inline handler — not whichever

(cg: CodeGraph, entries: readonly ManifestRow[])

Source from the content-addressed store, hash-verified

109 * the manifest leaves out test handlers.
110 */
111function oneRowPerRoute(cg: CodeGraph, entries: readonly ManifestRow[]): Array<ManifestRow & { inline: boolean }> {
112 const byRoute = new Map<string, ManifestRow[]>();
113 for (const entry of entries) {
114 const list = byRoute.get(entry.routeId);
115 if (list) list.push(entry);
116 else byRoute.set(entry.routeId, [entry]);
117 }
118 const routes = [...cg.getNodesByIds([...byRoute.keys()]).values()];
119 const roots = routeRoots(cg, routes);
120 const out: Array<ManifestRow & { inline: boolean }> = [];
121 for (const [routeId, list] of byRoute) {
122 const root = roots.get(routeId);
123 if (root?.inline) {
124 const first = list[0]!;
125 if (isTestFile(first.routeFile)) continue;
126 out.push({
127 ...first,
128 handler: 'inline handler',
129 handlerKind: 'route',
130 handlerFile: first.routeFile,
131 handlerLine: first.routeLine,
132 inline: true,
133 });
134 continue;
135 }
136 const named = root
137 ? list.find((e) => e.handlerFile === root.node.filePath && e.handlerLine === root.node.startLine && e.handler === root.node.name)
138 : undefined;
139 out.push({ ...(named ?? list[0]!), inline: false });
140 }
141 return out;
142}
143
144export function buildRoutes(cg: CodeGraph, query: URLSearchParams): WireRoutes {
145 const limit = intParam(query, 'limit', { min: MIN_LIMIT, max: 500, default: 200 });

Callers 1

buildRoutesFunction · 0.85

Calls 6

routeRootsFunction · 0.90
isTestFileFunction · 0.90
pushMethod · 0.80
getMethod · 0.65
setMethod · 0.45
getNodesByIdsMethod · 0.45

Tested by

no test coverage detected