Optional, dependency-free CSV/TSV parsing and explicit table-to-graph mapping.
Only the public @graphora/core package is required; no browser, engine or
spreadsheet runtime is imported.
import { parseCsvGraph } from '@graphora/adapter-csv'
const result = parseCsvGraph({
nodes: {
text: 'service,title\n001,API\n002,Worker',
columns: { id: 'service', label: 'title' }
},
edges: {
text: 'from,to\n001,002',
columns: { source: 'from', target: 'to' }
}
})
if (result.ok) {
// Pass result.graph to an engine/store, or transform the RawGraph first.
} else {
// result.issues contains table, physical record line and column when known.
}
parseCsvTable(text, options?) exposes frozen columns and rows for mapping
previews. parseCsvGraph(input, options?) validates both tables and the complete
graph before returning a RawGraph. Failures never contain a partial graph or
table. The adapter itself never mutates an existing graph.
Values remain strings, including leading zeros and whitespace. Column names
are exact and case-sensitive. All original cells are retained in frozen data
records. The returned RawGraph follows the existing mutable interchange
contract; validate it again on publication if you transform it.
Use { delimiter: '\t' } for TSV. Quoted delimiters/newlines, doubled quotes,
CRLF/LF/CR and an initial BOM are supported. Only physically empty records are
skipped. Duplicate/empty headers, wrong row widths and malformed quoting fail.
Node IDs and edge endpoints must be nonblank. Optional blank edge IDs use core's
existing generated-ID policy. Core errors retain their codes; errors that cannot
be attributed to a single row do not invent one.
Per-table defaults: 10,000,000 UTF-16 code units (maxCharacters), 100,000 data
rows (maxRows), 256 columns (maxColumns), 100 diagnostics (maxIssues).
issuesTruncated reports known omitted diagnostics. Parsing is synchronous and
bounded; applications choose smaller budgets for interactive input.
This package accepts delimited text, including spreadsheet CSV exports. Native XLSX workbooks, file fetching, streaming, automatic type inference and graph reconciliation are separate concerns.