npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ediflow/core

v0.3.0

Published

Modern EDIFACT Parser, Validator & Builder - Core Library

Downloads

280

Readme

@ediflow/core

Modern EDI Parser, Validator & Builder — EDIFACT, X12, EANCOM & HIPAA

NPM Version License: MIT TypeScript Downloads

Clean ArchitectureType-SafeZero ConfigBattle-Tested


🆕 What's New in v0.3.0

  • X12 Support — Full ISA/GS/ST/SE/GE/IEA envelope parsing & validation (850, 810, 837, 856, ...)
  • Business Object MappingStructureMappingService.map() / unmap() with 5 key strategies
  • Schema ExportExportSchemaUseCase for JSON Schema + YAML via CLI
  • HIPAA@ediflow/hipaa-x12-005010 data package (14 transaction sets)
  • EANCOM@ediflow/eancom-2002 data package (50 message types)
  • 857 tests passing across all packages

📦 What is @ediflow/core?

@ediflow/core is the core engine for EDIFlow — a modern EDI library for EDIFACT, X12, EANCOM and HIPAA, built with Clean Architecture principles.

This package provides:

  • Parser - EDIFACT string → EDIMessage
  • Validator - 3-phase validation (Syntax → Structure → Business)
  • Builder - EDIMessage → EDIFACT string
  • Mapper - Auto-convert to/from business objects
  • Envelope Generator - UNH/UNT/UNB/UNZ support
  • CLI - Command-line tools
  • TypeScript - Full type safety

What this package does NOT include:

  • ❌ EDIFACT standard definitions (install separately)

🚀 Installation

# Always required
npm install @ediflow/core

# ── EDIFACT ──────────────────────────────────────────────────────────────────
npm install @ediflow/edifact            # EDIFACT parsers & builders
npm install @ediflow/edifact-d20b       # D.20B (2020) — 195 messages, latest
npm install @ediflow/edifact-d01b       # D.01B (2001) — 211 messages
npm install @ediflow/edifact-d12a       # D.12A (2012) — 196 messages
npm install @ediflow/edifact-d96a       # D.96A (1996) — 126 messages

# ── EANCOM (GS1 retail) ──────────────────────────────────────────────────────
npm install @ediflow/eancom-2002        # EANCOM 2002 — 49 messages

# ── X12 (USA / North America) ────────────────────────────────────────────────
npm install @ediflow/x12                # X12 parsers & validators
npm install @ediflow/x12-004010         # X12 004010 — 293 transaction sets
npm install @ediflow/x12-006040         # X12 006040 — 319 transaction sets (latest 2026)

# ── HIPAA (US healthcare) ─────────────────────────────────────────────────────
npm install @ediflow/hipaa-x12-005010   # HIPAA 005010 — 14 transaction sets

# ── Shared infrastructure (required for schema/mapping features) ──────────────
npm install @ediflow/infrastructure-shared

📖 Quick Start

Parse EDIFACT Message

import {
  EdifactMessageParser,
  EdifactDelimiterDetector,
  EdifactTokenizer,
  EdifactSegmentParser,
} from '@ediflow/edifact';

const parser = new EdifactMessageParser(
  new EdifactDelimiterDetector(),
  new EdifactTokenizer(),
  new EdifactSegmentParser(),
);

const message = parser.parse(edifactString);
console.log(message.standard);           // 'EDIFACT'
console.log(message.messageType.value);  // 'ORDERS'
console.log(message.version.value);      // 'D.96A'
console.log(message.segments.length);    // segment count

Map to Business Object

import { StructureMappingService } from '@ediflow/core';
import { FileBasedMessageStructureRepository } from '@ediflow/infrastructure-shared';

const repository = new FileBasedMessageStructureRepository('./node_modules');
const structure  = await repository.getMessageStructure('EDIFACT', 'D.96A', 'ORDERS');

const mapper = new StructureMappingService();
const order  = mapper.map(message, structure!, 'camelCase');
// order.beginningOfMessage.documentMessageNumber === 'PO-001'

Validate Message

import { EdifactValidationServiceBuilder } from '@ediflow/edifact';

const validator = EdifactValidationServiceBuilder.forEDIFACT();
const result    = validator.validate(message);

if (result.isValid) {
  console.log('✅ Valid!');
} else {
  result.errors.forEach(e => console.error(`❌ ${e.code}: ${e.message}`));
}

Build EDIFACT Message

import { EdifactMessageBuilder, EdifactEnvelopeBuilder } from '@ediflow/edifact';
import { EDIMessage, Standard, Version, MessageType, EDISegment, EDIElement } from '@ediflow/core';

const msg = new EDIMessage('1', Standard.EDIFACT, new Version(Standard.EDIFACT, 'D.20B'), new MessageType(Standard.EDIFACT, 'ORDERS'));
msg.addSegment(new EDISegment('BGM', [new EDIElement('220'), new EDIElement('PO-001'), new EDIElement('9')]));

const envelopeBuilder = new EdifactEnvelopeBuilder();
const wrapped         = envelopeBuilder.wrapMessage(msg, { messageRef: '1', messageType: msg.messageType, version: msg.version });

const builder    = new EdifactMessageBuilder();
const edifactStr = builder.build(wrapped);
console.log(edifactStr); // UNH+1+ORDERS:D:20B:UN'BGM+220+PO-001+9'UNT+2+1'

🎯 Features

Core Features

  • Parse - EDIFACT → EDIMessage (with envelope support)
  • Validate - 3-phase validation (Syntax, Structure, Business)
  • Build - EDIMessage → EDIFACT (with envelope generation)
  • Map - Business Objects ↔ EDIMessage
  • CLI - Command-line interface

Clean Architecture

  • Domain Layer - Pure business logic (zero dependencies)
  • Application Layer - Use Cases (ParseEDI, ValidateMessage, BuildEDI)
  • Infrastructure Layer - Parsers, Repositories
  • Presentation Layer - CLI, Future: REST API

TypeScript Support

  • Full TypeScript definitions
  • Advanced type inference
  • IntelliSense support
  • Strict type checking

Zero Config

  • Works out of the box
  • Sensible defaults
  • Easy to customize

📦 Related Packages

EDIFACT:

EANCOM (GS1 retail):

X12 (USA / North America):

HIPAA (US healthcare):

Shared Infrastructure:


🏗️ Architecture

┌─────────────────────────────────────┐
│      Presentation Layer             │  CLI
└──────────────┬──────────────────────┘
               │
┌──────────────▼──────────────────────┐
│      Application Layer              │  Use Cases
│  • ParseEDIUseCase                  │
│  • ValidateMessageUseCase           │
│  • BuildEDIUseCase                  │
└──────────────┬──────────────────────┘
               │
┌──────────────▼──────────────────────┐
│      Domain Layer                   │  Entities
│  • EDIMessage                       │
│  • EDISegment                       │
│  • EDIElement                       │
└──────────────┬──────────────────────┘
               │
┌──────────────▼──────────────────────┐
│      Infrastructure Layer           │  Parsers
│  • EdifactMessageParser             │
│  • FileBasedRepository              │
└─────────────────────────────────────┘

Read more: Architecture Documentation


📚 Documentation


🧪 Testing

Extensively tested with TDD:

  • 857 tests passing across all packages
  • Unit tests - Domain & Application layers
  • Integration tests - Cross-layer interactions
  • E2E tests - Complete roundtrip validation
npm test
npm run test:watch
npm run test:coverage

🤝 Contributing

We welcome contributions! See:


📄 License

MIT License - see LICENSE


🔗 Links


Made with ❤️ for the EDI community