πŸš€ DAY 3 OF LAUNCH WEEK:Announcing Bun and vlt Support in Socket.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

nexus-dsm

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus-dsm

Modular toolkit for parsing, validating, and converting structured datasets (CSV ↔ JSON) with reviewer clarity.

Source
npmnpm
Version
1.5.0
Version published
Maintainers
1
Created
Source

🌐 Nexus DSM – Dataset Management Toolkit

MIT License Node.js CI CodeQL Build Status Modular DX Beginner Friendly Nexi Inside Parser Core: PapaParse DX Layer: nexus-dsm JSR npm version

Centralized tooling for parsing, validating, converting, and indexing structured datasets (CSV, JSON, and planned TSV). Built for modularity, clarity, and service-ready integration.

✨ Motivation: Building Trust in Your Data

Most data tools promise seamless automationβ€”but often operate as opaque black boxes. This obscures subtle quality issues and forces blind trust in processes that should be transparent. When working with critical datasets, that lack of visibility can lead to costly errors or endless manual review.

Nexus DSM takes a different approach:

Your data is yours. You deserve control, clarity, and confidence.

Instead of a β€œset-it-and-forget-it” pipeline, Nexus DSM offers a developer-assisted validation engine that flags syntax issues, highlights inconsistencies (like malformed rows or ambiguous headers), and guides you through every step. Whether you're ingesting raw CSVs or preparing JSON for an API, Nexus DSM ensures every byte meets your standardsβ€”with full visibility and explainable feedback.

πŸ“¦ Repo Scope

This repository contains the core logic for:

  • πŸ“₯ Parsing and syntax validation
  • βœ… Schema validation (via Zod or JSON Schema)
  • πŸ” Format conversion (CSV ↔ JSON)
  • 🧾 Metadata-driven eligibility checks
  • πŸ—‚ (Planned) Indexing for advanced dataset workflows

⚠️ Note: UI components, drag-and-drop tools, and frontend visualizations are maintained in a separate repository: nexus-dsm-ui

πŸ“š Project Documentation

For more detailed information about the project's direction, contribution guidelines, and version history, please see the following documents:

  • Project Roadmap - Our vision and development phases.
  • Changelog - A detailed log of all version changes.
  • Contribution Guide - How to get involved and contribute to the project.
  • Security Policy - Our policy for reporting security vulnerabilities.

πŸš€ Usage

Installation

npm install nexus-dsm # or pnpm add nexus-dsm

Parsing a CSV

The parseCSV function can process a CSV from a file path or a raw string. It returns a detailed response object with the parsed data and rich metadata.

import { parseCSV } from "nexus-dsm";

// From a file path
const response = await parseCSV(undefined, "./data/sample.csv");

if (response.success) {
    console.log("Parsed Data:", response.data);
    console.log(
        "Is eligible for conversion?",
        response.meta.eligibleForConversion
    );
} else {
    console.error("Parsing Failed:", response.message);
    console.log("Error Details:", response.meta.diagnostics);
}

Parsing a JSON

The parseJSON function handles JSON files with a root-level array of objects or a single root object.

import { parseJSON } from "nexus-dsm";

const jsonObject = [{ id: 1, name: "Alice" }];
const response = await parseJSON(jsonObject);

if (response.success) {
    console.log("Parsed Data:", response.data);
    console.log("Structure Type:", response.meta.structureType);
} else {
    console.error("Parsing Failed:", response.message);
}

πŸ” Converting Data

After parsing, you can convert between CSV and JSON formats using the conversion functions. The conversion functions take the entire successful response object from the parser.

JSON to CSV Conversion

The convertToCsv function can perform a "shallow" conversion (default) or a "deep" conversion.

import { parseJSON, convertToCsv } from "nexus-dsm";

const nestedJson = `[{"name":"Alice","profile":{"age":30},"tags":["dev"]}]`;
const jsonResponse = await parseJSON(nestedJson);

// Shallow conversion (default)
const shallow = convertToCsv(jsonResponse);
// shallow.content is: name,profile,tags\r\nAlice,"{""age"":30}","[""dev""]"

// Deep conversion
const deep = convertToCsv(jsonResponse, { flattening: 'deep' });
// deep.content is: name,profile.age,tags[0]\r\nAlice,30,dev

CSV to JSON Conversion

The convertToJson function automatically detects flattened headers (e.g., user.name) and reconstructs the nested JSON structure by default.

import { parseCSV, convertToJson } from "nexus-dsm";

const flatCsv = 'user.name,user.id\nAlice,1';
const csvResponse = await parseCSV(flatCsv);

// The function detects flattened headers and un-flattens by default.
const nestedJson = convertToJson(csvResponse);
// nestedJson.content is: '[{"user":{"name":"Alice","id":1}}]'

// To prevent this and get a flat JSON, pass `unflatten: false`.
const flatJson = convertToJson(csvResponse, { unflatten: false });
// flatJson.content is: '[{"user.name":"Alice","user.id":1}]'

🧠 API Reference

Primary API

These are the main functions intended for everyday use.

FunctionDescription
parseCSV(data?, filePath?)Parses a CSV or TSV string/file, validates its structure, and returns a detailed response object.
parseJSON(data, filePath?)Parses a JSON string or a pre-parsed object/array, analyzes its structure, and returns a detailed response object.
convertToCsv(response, options)Converts a parsed JSON response into a CSV string, with "shallow" (default) or "deep" flattening.
convertToJson(response, options)Converts a parsed CSV response into a JSON string, with automatic "un-flattening" of deep CSVs.

Advanced & Utility API

These functions and classes provide lower-level access for custom workflows and analysis.

Function/ClassDescription
convertCsvStructure(response)Normalizes a CsvResponse into a standard tabular payload, ready for transformation.
convertJsonStructure(data, meta)Normalizes a JsonResponse into a structure-aware payload with detailed metadata.
ParsedFileMetaBuilderA fluent builder class to programmatically construct metadata objects for testing or custom parsing.
calculateNestingDepth(obj)Computes the maximum nesting depth of a JSON object or array (e.g., a flat object is depth 1).
checkKeyConsistency(array)Verifies if all objects in an array share the same keys and returns a list of any inconsistent keys.

πŸ“Š Feature Comparison Table

LibraryBest ForDX SimplicityStreamingNested SupportMetadataValidationUI Pairing Potential
nexus-dsmDX-first conversion, contributor toolingβ­β­β­β­β­βœ… (planned)βœ… Deep + Shallowβœ… Richβœ… Detailedβœ… High
PapaParseBrowser-based parsing, quick CSV importβ­β­β­β­βœ… Step-wise❌ (flat only)⚠️ Minimal❌⚠️ Limited
csvtojsonQuick CLI conversions, Node pipelinesβ­β­β­βœ… Stream⚠️ Partial flattening⚠️ Basic⚠️ Basic❌
fast-csvHigh-performance streaming in Nodeβ­β­βœ… Stream❌❌❌❌
csv-parseConfigurable parsing, large datasetsβ­β­β­βœ… Stream⚠️ Manual flattening⚠️ Basic⚠️ Manual❌

βš™οΈ Workflow Overview

πŸ“₯ Input file (.csv/.json)
    ↓
πŸ” Parsing + Syntax Validation
    ↓
βœ… Schema Validation
    ↓
🧾 Metadata Creation (syntax tree + eligibility flags)
    ↓
πŸ” Conversion (CSV ↔ JSON, if eligible)
    ↓
πŸ“š Optional Indexing & downstream usage

πŸ“š Folder Structure

nexus-dsm/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ parsers/          # CSV and JSON parsing logic
β”‚   β”œβ”€β”€ converters/       # Format transformation modules
β”‚   β”œβ”€β”€ validators/       # Syntax, quote balance, header, and schema checks
β”‚   β”œβ”€β”€ schemas/          # Schema definitions
β”‚   β”œβ”€β”€ indexers/         # (Planned) indexing logic
β”‚   β”œβ”€β”€ constants/        # Shared constants
β”‚   β”œβ”€β”€ adapters/         # Environment or format adapters
β”‚   └── utils/            # Shared helpers
β”‚   └── index.ts          # Main export file
β”œβ”€β”€ __tests__/            # Unit and integration tests
β”œβ”€β”€ lib/                  # External libraries (e.g. papaparse.min.js)
β”œβ”€β”€ api/                  # Optional HTTP service layer (Phase 3)
β”œβ”€β”€ cli/                  # Optional CLI wrapper (Phase 4)
β”œβ”€β”€ docs/                 # Specs, architecture diagrams, usage notes
β”œβ”€β”€ vitest.config.ts      # Vitest test runner config
β”œβ”€β”€ tsconfig.json         # TypeScript configuration
β”œβ”€β”€ CONTRIBUTING.md       # Contribution guidelines
β”œβ”€β”€ LICENSE               # Project license
└── README.md             # This file

πŸ§ͺ Testing & Validation

Use __tests__ with fixtures to simulate:

  • CSV files with quote imbalances
  • JSON inputs with nested structures
  • Schema-conforming and non-conforming data
  • Metadata eligibility checks
  • Conversion edge cases

Built to support mock-driven unit tests and validation suites for CLI, API, or internal tooling.

🀝 Contribution

We welcome PRs, issues, and architectural suggestions. Whether you're extending validation stages, improving conversion logic, or building new adaptersβ€”your input helps make Nexus DSM more robust and accessible.

πŸ™ Acknowledgements

This toolkit's powerful and reliable CSV parsing capabilities are made possible by Papa Parse, the fastest in-browser CSV parser for JavaScript.

Parser Core: PapaParse

Modular, testable, and orchestration-ready. Built by Nexicore Digitals to empower developers with clarity and control.

Keywords

csv

FAQs

Package last updated on 29 Oct 2025

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