🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

@inferagraph/file-datasource

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inferagraph/file-datasource

File datasource for InferaGraph (CSV, TSV, Markdown folders)

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

@inferagraph/file-datasource

File-based datasource plugin for @inferagraph/core. Loads nodes from delimited files (CSV/TSV) or a folder of Markdown files with frontmatter.

Installation

pnpm add @inferagraph/file-datasource @inferagraph/core

Usage

CSV / TSV

import { FileDatasource } from '@inferagraph/file-datasource';

const datasource = new FileDatasource({
  type: 'csv',
  path: './data/nodes.csv',
  hasHeader: true,           // first row contains column names
  contentFields: ['summary'], // optional: surface columns via getContent
  edges: [
    {
      id: 'e1',
      sourceId: 'n1',
      targetId: 'n2',
      attributes: { type: 'related_to' },
    },
  ],
});

await datasource.connect();

const view = await datasource.getInitialView();
const node = await datasource.getNode('n1');
const neighbors = await datasource.getNeighbors('n1');
const results = await datasource.search('keyword');

await datasource.disconnect();

Markdown folder

import { FileDatasource } from '@inferagraph/file-datasource';

const datasource = new FileDatasource({
  type: 'markdown',
  path: './data/nodes',                          // folder containing .md files
  frontmatter: ['id', 'name', 'type'],           // required keys per file (exact match)
  edges: [],
});

await datasource.connect();

// Each .md file becomes a node with frontmatter as attributes;
// the body is exposed via getContent.
const content = await datasource.getContent('n1');
// { nodeId: 'n1', content: '<body markdown>', contentType: 'markdown' }

Configuration

Common options

OptionTypeDescription
type'csv' | 'tsv' | 'markdown'File format
pathstringFile path (csv/tsv) or folder path (markdown)
edgesEdgeData[]Host-supplied relationships
idFieldstringColumn / frontmatter key for the node id (default: 'id')

CSV / TSV options

OptionTypeDescription
hasHeaderbooleanFirst row is column names (default: true)
columnsstring[]Required when hasHeader=false. Length must match the parsed first row.
contentFieldsstring[]Columns surfaced via getContent as metadata. When unset, getContent returns undefined.

Markdown options

OptionTypeDescription
frontmatterstring[]Required keys. Each .md file must contain EXACTLY this set (extras and missing keys throw).

Behavior

  • connect() reads and parses every file up-front (deterministic, fail-fast).
  • disconnect() clears the parsed state.
  • All seven DataAdapter methods (getInitialView, getNode, getNeighbors, findPath, search, filter, getContent) require an active connection.
  • Edges supplied in config.edges are stored as-is and used for graph traversal.

License

MIT

FAQs

Package last updated on 05 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts