{"_id":"@adeloi/edi-fixtures","name":"@adeloi/edi-fixtures","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@adeloi/edi-fixtures","version":"1.0.0","description":"Realistic X12 EDI test documents for integration testing — including the ways they break in production.","keywords":["edi","x12","testing","fixtures","supply-chain","850","856","810","997"],"homepage":"https://github.com/Adeloi-Official/edi-fixtures","bugs":{"url":"https://github.com/Adeloi-Official/edi-fixtures/issues"},"repository":{"type":"git","url":"git+https://github.com/Adeloi-Official/edi-fixtures.git"},"license":"Apache-2.0","author":{"name":"Olevis LLC"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"build":"tsc -p tsconfig.build.json","test":"vitest run","test:watch":"vitest","typecheck":"tsc --noEmit","prepublishOnly":"npm run typecheck && npm run test && npm run build"},"devDependencies":{"@types/node":"^22.10.0","node-x12":"^1.7.1","typescript":"^5.7.2","vitest":"^4.1.10"},"_id":"@adeloi/edi-fixtures@1.0.0","gitHead":"7d4c65447c9fec75d71af17639363abac873534f","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-0hRjL7g6Ee/OMt1gaEiO+FBQiLZbxWDDgcvlaV9co4GknZlFLjTmdN9/DEx46+wA4GkyfKYV9NBbbfXgImFNoA==","shasum":"c6d4fcbe2991a7dec0dbbf70cc184040a3d22eb0","tarball":"https://registry.npmjs.org/@adeloi/edi-fixtures/-/edi-fixtures-1.0.0.tgz","fileCount":46,"unpackedSize":91933,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCKAd3q9i94yf+3XSGPly6wLihSc82sTdDhP+8tzRrylwIhAMTMxzPjgWCRL8fXWEiYZYI2anNRE96Sy7/pahz09wB+"}]},"_npmUser":{"name":"adeloi","email":"info@adeloi.com"},"directories":{},"maintainers":[{"name":"adeloi","email":"info@adeloi.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/edi-fixtures_1.0.0_1786653190043_0.442493978681604"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-13T20:33:09.905Z","1.0.0":"2026-08-13T20:33:10.211Z","modified":"2026-08-13T20:33:10.557Z"},"maintainers":[{"name":"adeloi","email":"info@adeloi.com"}],"description":"Realistic X12 EDI test documents for integration testing — including the ways they break in production.","homepage":"https://github.com/Adeloi-Official/edi-fixtures","keywords":["edi","x12","testing","fixtures","supply-chain","850","856","810","997"],"repository":{"type":"git","url":"git+https://github.com/Adeloi-Official/edi-fixtures.git"},"author":{"name":"Olevis LLC"},"bugs":{"url":"https://github.com/Adeloi-Official/edi-fixtures/issues"},"license":"Apache-2.0","readme":"# edi-fixtures\n\nRealistic X12 test documents for integration testing — including the ways\nthey break in production.\n\nReal EDI files are confidential. Spec examples are sterile: one line item,\nround numbers, every segment present. This library generates deterministic,\nrealistic 850/855/856/810/997 documents — and lets you inject the 18 failure\nmodes we keep seeing in real trading-partner relationships: nonstandard\nUOMs, missing partner-required REFs, duplicate control numbers, orphaned HL\nloops, 997s that never arrive.\n\nBuilt by [Adeloi](https://adeloi.com), an engineering partner for industrial\nsuppliers and manufacturers.\n\n[![CI](https://github.com/Adeloi-Official/edi-fixtures/actions/workflows/ci.yml/badge.svg)](https://github.com/Adeloi-Official/edi-fixtures/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/%40adeloi%2Fedi-fixtures)](https://www.npmjs.com/package/@adeloi/edi-fixtures)\n[![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](./LICENSE)\n\n**Status: Stable. Feature-complete for the 004010 order-to-invoice flow.**\n\n---\n\n### See it in action\n\n```ts\npo850({ seed: 42, lines: 2 }).build();\n```\n\n```\nISA*00*          *00*          *ZZ*SENDERID       *ZZ*RECEIVERID     *240404*0538*U*00401*530335606*0*P*:~\nGS*PO*SENDERID*RECEIVERID*20240404*0518*27124*X*004010~\nST*850*0001~\nBEG*00*NE*PO173006**20240404~\nREF*DP*809~\nDTM*002*20240412~\nN1*ST*Vantage Supply Co*92*LOC4005~\nN3*6007 Industrial Pkwy~\nN4*Ontario*CA*91761~\nPO1*1*228*EA*220.64*PE*BP*AX-31566~\nPID*F****Hex Bolt 3/8-16 x 2in Zinc~\nPO1*2*5*CS*209.50*PE*BP*SKU-50201~\nPID*F****Shop Towel Roll Blue~\nCTT*2~\nSE*13*0001~\nGE*1*27124~\nIEA*1*530335606~\n```\n\nNow the same seed with two faults from the catalog applied:\n\n```ts\npo850({ seed: 42, lines: 2 })\n  .with(faults.uomNonstandard())\n  .with(faults.missingRef(\"DP\"))\n  .build();\n```\n\n```diff\n ISA*00*          *00*          *ZZ*SENDERID       *ZZ*RECEIVERID     *240404*0538*U*00401*530335606*0*P*:~\n GS*PO*SENDERID*RECEIVERID*20240404*0518*27124*X*004010~\n ST*850*0001~\n BEG*00*NE*PO173006**20240404~\n-REF*DP*809~\n DTM*002*20240412~\n N1*ST*Vantage Supply Co*92*LOC4005~\n N3*6007 Industrial Pkwy~\n N4*Ontario*CA*91761~\n-PO1*1*228*EA*220.64*PE*BP*AX-31566~\n+PO1*1*228*EACH*220.64*PE*BP*AX-31566~\n PID*F****Hex Bolt 3/8-16 x 2in Zinc~\n-PO1*2*5*CS*209.50*PE*BP*SKU-50201~\n+PO1*2*5*CASE*209.50*PE*BP*SKU-50201~\n PID*F****Shop Towel Roll Blue~\n CTT*2~\n-SE*13*0001~\n+SE*12*0001~\n GE*1*27124~\n IEA*1*530335606~\n```\n\nSame envelope, same control numbers, same line data — just the department\nREF gone (and SE01 correctly recounted to 12, not left stale at 13 — removing\na segment is only ever *that* fault, never an accidental second one) and two\nUOM codes swapped for the nonstandard synonyms partners actually send.\nThat's the whole idea: a document that's wrong in one specific, realistic\nway instead of unrecognizable.\n\n## Contents\n\n- [Install](#install)\n- [Quickstart](#quickstart)\n- [What this is](#what-this-is)\n- [What this is NOT](#what-this-is-not)\n- [Document types](#document-types)\n- [The fault catalog](#the-fault-catalog)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\n```sh\nnpm install --save-dev @adeloi/edi-fixtures\n```\n\nZero runtime dependencies. Works in Node ≥20, Bun, Deno, and the browser —\nit's pure string generation in, string out.\n\n## Quickstart\n\n```ts\nimport { po850, scenario, faults, definePartner } from \"@adeloi/edi-fixtures\";\n\n// 1. A valid document, deterministic — same seed, byte-identical output, forever.\nconst doc = po850({ seed: 42, lines: 5 }).build();\n\n// 2. A deliberately broken document — the core of this library.\nconst broken = po850({ seed: 42 })\n  .with(faults.uomNonstandard())   // \"EACH\" instead of \"EA\" in PO1-03\n  .with(faults.missingRef(\"DP\"))   // a partner-required REF is missing\n  .build();\n\n// 3. A consistent chain of documents across an order-to-invoice flow.\nconst flow = scenario.orderToInvoice({ seed: 7, lines: 3 }).build();\n// -> { po, ack, asn, invoice, fa }\n// Same PO number and line items end to end; each doc keeps its own\n// interchange control numbers, exactly as five real transmissions would.\n\n// 4. A chain with a realistic production fault injected.\nconst messy = scenario\n  .orderToInvoice({ seed: 7 })\n  .with(faults.asnQtyMismatch())   // the 856 reports more than the 850 ordered\n  .with(faults.fa997Missing())     // and the 997 never arrives\n  .build();\n\n// 5. Parametrize for a trading partner, without pretending to be their real implementation guide.\nconst partner = definePartner({\n  isaQualifier: \"ZZ\",\n  requiredRefs: [\"DP\", \"IA\"],\n  uomWhitelist: [\"EA\", \"CS\"],\n});\nconst forPartner = po850({ seed: 1, partner }).build();\n```\n\n## What this is\n\nDeterministic, realistic X12 test documents for integration testing — plus a\ncurated catalog of the failures that actually show up in real\ntrading-partner relationships, each one composable onto an otherwise-valid\ndocument.\n\n- **Deterministic.** Same seed → byte-identical document, today and five\n  years from now. Fixtures belong in snapshot tests and CI, and\n  non-determinism there is poison. Seeded PRNG, not `Math.random()`; dates\n  derived from the seed, not the system clock. See [`docs/design.md`](./docs/design.md).\n- **Realistic.** Plausible part numbers, mixed UOMs, crooked quantities and\n  prices, a correct fixed-width ISA envelope, consistent control numbers\n  across ISA/GS/ST/SE/GE/IEA, valid GS1 SSCC-18 check digits.\n- **Fault injection.** Every fault in the catalog is a pure, composable\n  function applied on top of an otherwise-valid document.\n- **Scenario presets.** `scenario.orderToInvoice(...)` produces a consistent\n  document chain — same PO number, same line items — across the full\n  order-to-invoice flow.\n- **Zero dependencies.** Pure strings in, pure strings out. No parser\n  lock-in, no framework assumptions.\n\n## What this is NOT\n\n- **Not a parser or validator.** This library only generates documents. For\n  parsing/validating incoming X12, see [node-x12](https://github.com/aaronhuggins/node-x12)\n  or the [Stedi](https://www.stedi.com/) EDI ecosystem.\n- **Not a mapper or translator.**\n- **Not a source of trading-partner implementation guides.** Guides for\n  specific partners (Walmart, Grainger, etc.) are proprietary. `definePartner()`\n  gives you a generic, configurable partner profile instead.\n- **Not EDIFACT, TRADACOMS, or HIPAA transactions** (270/271/837/...).\n- **Not an AS2/SFTP/VAN transport client.**\n- **Not a UI.**\n\n## Document types\n\nX12 Release 004010 — the de facto standard in US retail/industrial EDI.\n\n| Type | Name | Role in the flow |\n|---|---|---|\n| 850 | Purchase Order | Buyer places an order |\n| 855 | PO Acknowledgment | Seller confirms/changes it |\n| 856 | Advance Ship Notice | Shipment notice, with a full HL hierarchy (Shipment → Order → Pack → Item) |\n| 810 | Invoice | Seller bills for it |\n| 997 | Functional Acknowledgment | Receipt confirmation at the functional-group level |\n\nTogether these cover the complete **order-to-invoice flow** of a\ndistributor or manufacturer. 860/865 (Change Orders) are on the roadmap, not\nin v1.0.\n\n## The fault catalog\n\n18 faults across 4 categories. Each one exists as code (`faults.*`), as a\ndocumented entry in [`docs/faults.md`](./docs/faults.md) — what happens, why\nit happens in production, and what it costs — and as a test case.\n\n| Category | Faults |\n|---|---|\n| **A — Structure/Envelope** | `isaTruncated` · `seCountWrong` · `controlNumberMismatch` · `duplicateIsaControl` · `nonstandardSeparators` |\n| **B — Semantics/Content** | `uomNonstandard` · `impliedDecimals` · `dateFormatShort` · `cttMismatch` · `missingRef` |\n| **C — Sequence/Acknowledgment** | `fa997Missing` · `fa997Rejected` · `fa997UnknownGroup` · `outOfOrderInterchange` |\n| **D — 856-specific** | `hlOrphan` · `ssccInvalid` · `asnQtyMismatch` · `asnAfterDelivery` |\n\nFaults in categories A, B, and most of D operate on a single document via\n`.with(...)`. Faults in category C, plus `asnQtyMismatch`, need more than one\ndocument (or the absence of one) to mean anything, so they apply to a\n`scenario.orderToInvoice(...)` chain instead. See\n[`docs/faults.md`](./docs/faults.md) for the full writeup of each one.\n\n## API\n\n```ts\npo850(options): DocBuilder\nack855(options): DocBuilder\nasn856(options): DocBuilder\ninvoice810(options): DocBuilder\nfa997(options): DocBuilder    // options.target identifies what's being acknowledged\n\ninterface DocBuilder {\n  with(fault: Fault): DocBuilder;   // composable, chainable\n  build(): string;                  // the final ISA...IEA string\n  buildDocument(): EdiDocument;     // pre-serialization model, for assertions\n}\n\nscenario.orderToInvoice(options): ScenarioBuilder\ninterface ScenarioBuilder {\n  with(fault: ScenarioFault): ScenarioBuilder;\n  build(): { po: string; ack: string; asn: string; invoice: string; fa: string | null };\n}\n\ndefinePartner(overrides: Partial<PartnerProfile>): PartnerProfile\n```\n\nEvery document builder shares an options shape along the lines of:\n\n```ts\ninterface DocOptions {\n  seed: number;\n  lines?: number;          // default 3\n  poNumber?: string;       // auto-generated from the seed if omitted\n  partner?: PartnerProfile;\n  referenceDate?: Date;\n}\n```\n\nSee [`docs/design.md`](./docs/design.md) for the determinism guarantees and\nwhy this library has zero runtime dependencies.\n\n## Contributing\n\nIssues and PRs welcome — especially new faults backed by something you've\nactually seen in production. Run `npm test` before opening a PR; every\ndocument type and every fault has test coverage, including a cross-check\nagainst an independent X12 parser (`node-x12`, dev-only) in\n`test/spec-conformance.test.ts`.\n\n## License\n\n[Apache License 2.0](./LICENSE). Copyright 2026 Olevis LLC.\n","readmeFilename":"README.md","_rev":"1-31d7ae8082b5aba6be1af80361815414"}