Rust workspace for parsing, validating, and transforming UN/EDIFACT EDI (EANCOM-first) into a schema-aware Intermediate Representation (IR). The current MVP focuses on ORDERS (EANCOM D96A) with runtime-loaded schemas and a YAML mapping DSL.
- MVP focus: ORDERS (EANCOM D96A) parse, validate, map to IR/JSON.
- CLI supports
transform,validate, andgeneratesubcommands with functionalrsedi.yamlconfig profiles viaedi initandedi config check. - CSV adapter and pipeline logic exist as building blocks; DB adapter types are present but not wired to a driver.
- Streaming at message boundaries is a design goal; current CLI reads full input files into memory.
Schema Registry (EDIFACT -> EANCOM -> Partner)
|
v
Validation Engine <-> Mapping Engine (DSL)
| |
v v
Intermediate Representation (IR)
|
v
Adapters (EDIFACT | CSV | DB)
|
v
Transport (FS | DB)
crates/edi-ir: IR node model, metadata, traversal utilities.crates/edi-schema: Schema model, loader, inheritance/merge logic.crates/edi-validation: Validation engine and reporter for schema-driven rules.crates/edi-mapping: YAML mapping DSL parser, runtime, and transforms.crates/edi-adapter-edifact: EDIFACT parser, syntax handling, envelopes.crates/edi-adapter-csv: CSV schema, reader, writer utilities.crates/edi-adapter-db: DB schema mapping types and stubs for future integration.crates/edi-pipeline: Pipeline policies, batching, quarantine flows.crates/edi-cli: CLI entrypoint used for quickstart commands.
Build the workspace:
cargo build --workspaceRun an ORDERS transform to JSON IR output:
cargo run -p edi-cli -- transform testdata/edi/valid_orders_d96a_minimal.edi /tmp/orders.json -m testdata/mappings/orders_to_json.yaml
cat /tmp/orders.jsonValidate a valid ORDERS message:
cargo run -p edi-cli -- validate testdata/edi/valid_orders_d96a_minimal.edi -s testdata/schemas/eancom_orders_d96a.yamlValidate an invalid ORDERS message (missing BGM):
cargo run -p edi-cli -- validate testdata/edi/invalid_orders_missing_bgm.edi -s testdata/schemas/eancom_orders_d96a.yamlBinary name: edi
Transform an EDI file into JSON IR:
edi transform <input.edi> <output.json> -m <mapping.yaml> [-s <schema.yaml>]Validate an EDI file against a schema:
edi validate <input.edi> -s <schema.yaml>Generate EDI from CSV/JSON input using a mapping:
edi generate <input.{csv|json}> <output.edi> -m <mapping.yaml> [--input-format csv|json]Process a directory of EDI files without stopping on the first bad file:
edi batch validate input/ --schema schemas/eancom_orders_d96a.yaml \
--quarantine-dir quarantine/ --format json
edi batch transform input/ output/ --mapping mappings/orders_to_json.yaml \
--quarantine-dir quarantine/
edi quarantine list quarantine/ --format json
edi quarantine show quarantine/ <id>
edi quarantine retry quarantine/ <id> --schema schemas/eancom_orders_d96a.yaml
edi quarantine export quarantine/ <id> recovered.ediBatch commands walk .edi files recursively and process each file as an independent
message boundary, so a failed partner file can be quarantined while later files
continue unless --strict is set. JSON summaries include processed, failed,
warning, output, and quarantined counts for CI use.
Project config workflow:
edi init --profile orders
edi config check --profile orders
edi --profile orders validate
edi --profile orders transformedi init creates rsedi.yaml plus starter directories (schemas/, mappings/,
input/, output/, quarantine/). Profiles can store common input, output,
schema, mapping, quarantine, progress, and color defaults so repeated partner or
environment workflows do not need long flag lists. Explicit CLI arguments still
override profile values.
Example rsedi.yaml:
progress: true
progress_threshold_bytes: 1048576
color: auto
profiles:
orders:
input: input/orders.edi
output: output/orders.json
schema: schemas/eancom_orders_d96a.yaml
mapping: mappings/orders_to_json.yaml
quarantine: quarantine
output_format: jsonLegacy config paths such as edi-cli.yaml are still discovered, but new projects
should prefer rsedi.yaml.
0: no warnings or errors1: warnings only2: validation errors
Schema and mapping examples live in testdata/.
- Schema files:
testdata/schemas/ - Mapping DSL examples:
testdata/mappings/ - EDI samples:
testdata/edi/
Mapping DSL notes and examples:
testdata/mappings/README.md
Sample EDIFACT files and their expected behavior are documented in:
testdata/edi/README.md
Formatting, linting, and tests:
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-targets --all-featuresedi transformignores the optional schema flag for now.- CLI runs on full in-memory files rather than streaming chunks.
product_specification.mdAGENTS.md