Generated page. Written from IdaMilk/Suntado_EDI at commit 57b2e4f on 2026-07-28, version 1.4.2. There is no README, but EDI_INTEGRATION_SPECS.txt and NETSUITE_INTEGRATION.md document the system well.
Suntado EDI
What is it?
The service that speaks X12 EDI with trading partners. It parses inbound documents, generates outbound ones, manages the interchange control numbers that keep both sides in sync, and moves files over whichever transport a given partner uses.
Purpose
Retail and distribution partners exchange business documents as X12 EDI — a fixed, decades-old format with strict envelope and sequencing rules. Getting it wrong means rejected documents and, downstream, missed shipments.
This service concentrates that correctness in one place, so the rest of the platform deals in ordinary JSON and never has to think about segment terminators or control number sequencing.
How it Works
Two registries drive everything, which is what makes onboarding a new partner a configuration change rather than a code change.
partnerRegistry.js holds one entry per trading partner: which inbound transaction sets they send and which parser handles each, which outbound sets Suntado sends them and which generator builds each, and the ISA/GS envelope identifiers and qualifiers for both sides. Each partner also carries an active flag, and the registry ships a SENDERID template entry (inactive) to be copied when adding a partner.
transactionRegistry.js maps transaction set numbers to their handlers.
An inbound document arrives, is parsed by lib/x12/ into segments, dispatched by partner and transaction set to the right parser in edi/mappers/inbound/, and turned into a business object the rest of the platform understands. Outbound runs the same path in reverse through edi/mappers/outbound/, with lib/x12/envelope.js and generator.js assembling the ISA/GS/ST envelope and controlNumberService allocating the next control number.
Control numbers are the part that must not go wrong: X12 requires monotonically increasing interchange numbers per partner, and a duplicate or gap causes rejections. EDIControlNumber persists them in SQL Server rather than holding them in memory, so a restart cannot reissue a number.
pollingService and EDIPartnerPolling handle partners whose documents must be collected rather than pushed — polling their SFTP endpoint on a per-partner schedule.
Version 2.0 of the architecture is transport-agnostic. SFTP, API and AS2 are selectable per partner from configuration, with one generalised endpoint for all partners rather than one per partner. The v1.0 partner-specific endpoints still work for backward compatibility.
Supported transaction sets
| Set | Direction | Document |
|---|---|---|
| 846 | outbound | Inventory Inquiry / Advice |
| 856 | outbound | Advance Ship Notice (ASN) |
| 940 | both | Warehouse Shipping Order |
| 943 | inbound | Warehouse Stock Transfer Shipment Advice |
| 944 | inbound | Warehouse Stock Transfer Receipt Advice |
| 945 | both | Warehouse Shipping Advice |
| 947 | outbound | Warehouse Inventory Adjustment Advice |
| 824 | outbound | Application Advice |
| 997 | both | Functional Acknowledgement |
The 940/943/944/945/947 cluster is third-party-logistics traffic — Suntado instructs a warehouse to ship, the warehouse reports back what moved. 846 publishes inventory availability to partners.
API
| Mount | Purpose |
|---|---|
GET /health | Liveness check |
/edi/* | EDI protocol operations — receive, send, generate |
/api/edi/* | Business-facing operations used by the rest of the platform |
NETSUITE_INTEGRATION.md documents the inventory flow: a caller posts inventory data with SKU, UPC/GTIN, and available quantities in cases and pallets; the service generates an 846 and transmits it to the partner.
Data model
| Model | Holds |
|---|---|
EDITransmission | Every document sent or received, with batch id |
EDIControlNumber | Per-partner interchange control number sequences |
EDIPartnerPolling | Per-partner polling schedule and state |
Schema changes are tracked as SQL files in db/sql/ and applied deliberately, rather than through a boot-time migration — a different and arguably safer choice than the sibling services make.
Tech Stack
| Technology | Version | Purpose |
|---|---|---|
| Express | 5.2.1 | HTTP framework |
| node-x12 | 1.7.1 | X12 parsing and generation |
| ssh2-sftp-client | 12.1.1 | SFTP transport |
| Sequelize | 6.37.8 | ORM |
| tedious | 19.2.1 | SQL Server driver |
| pino | 10.3.1 | Structured logging |
| pino-pretty | 13.1.3 | Development log formatting |
| axios | 1.16.1 | Outbound HTTP |
| dotenv | 17.4.2 | Configuration |
pino rather than morgan makes this the only service in the platform emitting structured JSON logs — genuinely useful when tracing one document through a batch.
Interfaces
| System | Direction | Purpose |
|---|---|---|
| Trading partners | both | Document exchange over SFTP, AS2 or API |
| Suntado OpenAS2 | outbound | AS2 transport |
| SunApps Gateway | inbound | Proxies /api/edi here |
| NetSuite | both | Orders, shipments and inventory, via the Core API |
| SQL Server | outbound | Transmission log and control numbers |
Operations
Deployed by GitHub Actions — development, production and tagging workflows — and run under a process supervisor via ecosystem.config.js. Default port 4200.
When a partner reports a rejected document, the useful order is: EDITransmission for what was actually sent, then the 997 acknowledgement for what the partner objected to, then EDIControlNumber to confirm sequencing did not break.
Two operational notes:
lib/x12.old.jsis still present alongside the currentlib/x12/module. Confirm which one a given path actually uses before editing.- Partner envelope identifiers live in source, not configuration —
partnerRegistry.jscarries ISA/GS sender and receiver ids per partner. Onboarding a partner is a code change and a deploy, not a config update.
Repository
| Repository | IdaMilk/Suntado_EDI |
| Version | 1.4.2 |
| Primary language | JavaScript (Node, CommonJS) |
| Files | 124 |
| Last activity | 2026-06-02 |
| Status | Active |
| README | None — but EDI_INTEGRATION_SPECS.txt (v2.0, January 2026) is a thorough technical spec, and NETSUITE_INTEGRATION.md covers the inventory flow |
Note the package name is sunapps_edi while the repository is Suntado_EDI, and a separate, dormant SunApps_EDI repository also exists. This is the live one.