MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / parseCompactRows

Function parseCompactRows

graph-ui/src/provider/compact-rows.ts:230–341  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

228 * Kopf mehr oder weniger Zeilen ankuendigt, als dann kommen.
229 */
230export function parseCompactRows(text: string): CompactRows {
231 const lines = text.split('\n');
232 let i = 0;
233 while (i < lines.length && lines[i].trim().length === 0) {
234 i += 1;
235 }
236 if (i >= lines.length) {
237 throw new Error('kompakte Antwort war leer');
238 }
239
240 const directory = readReferences(lines, i, 'rows');
241 i = directory.next;
242 const head = ROWS_HEAD.exec(lines[i] ?? '');
243 if (head === null) {
244 throw new Error(
245 `unbekannter Kopf einer kompakten Antwort, erwartet "rows: N (cols: ...)": ` +
246 `${lines[i].trim()}`,
247 );
248 }
249 const declared = Number.parseInt(head[1], 10);
250 const columns = readColumns(head[2]);
251 i += 1;
252
253 const collected = collectRows(lines, i, columns, 'kompakte Antwort', directory.refs);
254 const rows = collected.rows;
255 i = collected.next;
256
257 if (rows.length !== declared) {
258 throw new Error(
259 `kompakte Antwort kuendigt rows: ${declared} an, geliefert wurden ${rows.length}`,
260 );
261 }
262
263 let total: number | undefined;
264 let hint: string | undefined;
265 let returned: number | undefined;
266 let totalRelation: string | undefined;
267 let hasMore: boolean | undefined;
268 let truncated: boolean | undefined;
269 const metadata: Pick<CompactRows, 'offset' | 'nextOffset' | 'nextCursor' | 'truncationReason' | 'warning'> = {};
270 for (; i < lines.length; i += 1) {
271 const line = lines[i];
272 if (line.trim().length === 0) {
273 continue;
274 }
275 const totalMatch = TOTAL_LINE.exec(line);
276 if (totalMatch !== null) {
277 total = Number.parseInt(totalMatch[1], 10);
278 continue;
279 }
280 const hintMatch = HINT_LINE.exec(line);
281 if (hintMatch !== null) {
282 hint = unquote(hintMatch[1]);
283 continue;
284 }
285 const returnedMatch = RETURNED_LINE.exec(line);
286 if (returnedMatch !== null) {
287 returned = Number.parseInt(returnedMatch[1], 10);

Callers 3

queryGraphMethod · 0.90

Calls 5

readReferencesFunction · 0.85
readColumnsFunction · 0.85
collectRowsFunction · 0.85
validateCountsFunction · 0.85
unquoteFunction · 0.70

Tested by

no test coverage detected