MCPcopy
hub / github.com/opentrace/opentrace / generateTypedNodeCSV

Function generateTypedNodeCSV

ui/src/store/ladybugStore.ts:182–208  ·  view source on GitHub ↗

* Generate CSV for a typed node table using the proto-defined column schema. * Each node type has its own set of columns (e.g. File has path, extension, language, etc.) * instead of a single JSON properties column.

(
  nodeType: string,
  nodes: ImportBatchRequest['nodes'],
)

Source from the content-addressed store, hash-verified

180 * instead of a single JSON properties column.
181 */
182function generateTypedNodeCSV(
183 nodeType: string,
184 nodes: ImportBatchRequest['nodes'],
185): string {
186 const columns = NODE_COLUMNS[nodeType as NodeType];
187 if (!columns) {
188 // Fallback for unknown types — shouldn't happen with proto-driven schema
189 const lines = ['id,name'];
190 for (const node of nodes) {
191 lines.push([node.id, node.name].map(csvEscape).join(','));
192 }
193 return lines.join('\n');
194 }
195
196 const header = columns.map((c) => c.name).join(',');
197 const lines = [header];
198 for (const node of nodes) {
199 const props = node.properties ?? {};
200 const values = columns.map((col) => {
201 if (col.name === 'id') return csvEscape(node.id);
202 if (col.name === 'name') return csvEscape(node.name);
203 return csvFormatValue(props[col.name], col.type);
204 });
205 lines.push(values.join(','));
206 }
207 return lines.join('\n');
208}
209
210/** Max file content stored in the SourceText table for FTS indexing. */
211const MAX_SOURCE_TEXT_CHARS = 10_000;

Callers 2

importDatabaseMethod · 0.85
flushMethod · 0.85

Calls 3

csvFormatValueFunction · 0.85
pushMethod · 0.80
csvEscapeFunction · 0.70

Tested by

no test coverage detected