Type-safe business object mapping: EDIFACT segments → TypeScript objects (and back) #72
Answered
by
hello-ediflow
hello-ediflow
asked this question in
Q&A
-
|
Instead of manually parsing segments like |
Beta Was this translation helpful? Give feedback.
Answered by
hello-ediflow
May 10, 2026
Replies: 1 comment
-
|
EDIFlow's Business Object Mapping provides exactly this: import { BusinessObjectMapper } from '@ediflow/core';
// Parse EDIFACT → EDIMessage
const message = parser.parse(edifactString);
// Map to typed business object
const mapper = new BusinessObjectMapper(messageStructure, 'camelCase');
const order = mapper.mapToBusinessObject(message);
// Now you have IntelliSense and type safety!
console.log(order.documentNumber); // 'PO-001'
console.log(order.parties.buyer.id); // GLN
console.log(order.lineItems[0].productId); // EAN code
console.log(order.lineItems[0].quantity); // number
// Modify and map back
order.lineItems[0].quantity = 150;
const updatedMessage = mapper.mapFromBusinessObject(order, { /* options */ });5 mapping strategies available: This eliminates the "segment[2].elements[3]" pattern that makes EDI code unreadable. Your domain layer works with clean TypeScript objects, completely decoupled from the EDI wire format. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hello-ediflow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EDIFlow's Business Object Mapping provides exactly this: