
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
edifact-serializer
Advanced tools
Create EDIFACT segment definitions, validate data based on the segment and render the data in the EDI format
👩🏻💻 Developer Ready: A comprehensive template. Works out of the box for most Node.js projects.
This project is intended to be used with the latest Active LTS release of Node.js.
To clone the repository, use the following commands:
git clone https://github.com/bloodred17/edifact-serializer.git
cd edifact-serializer
npm install
The following example demonstrates the creation of a Segment definition:
export const interchangeTrailerSegment = new EdifactSegment({
name: 'interchange_trailer',
tag: 'UNZ',
elements: [
// Elements and Compund Element definition
],
});
The following example demonstrates the creation of a single EDIFACT message Element:
const interchangeControlCount = new EdifactElement({
name: 'interchange_control_count',
tag: '0036',
status: UseStatus.M,
_format: 'n..6'
})
The following example demonstrates the creation of a EDIFACT Composite message element:
const documentMesageIdentification = new EdifactCompositeElement({
name: 'document_message_identification',
tag: 'C106',
status: UseStatus.C,
elements: [
// Single message elements
]
})
The following example demonstrates a CUSDEC BGM segment definition:
import { EdifactCompositeElement, EdifactElement, EdifactSegment, UseStatus } from 'edifact-serializer';
export const beginningOfMessageSegment = new EdifactSegment({
name: 'beginning_of_message',
tag: 'BGM',
counter: '0020',
number: 3,
level: 0,
elements: [
new EdifactCompositeElement({
name: 'document_message_name',
tag: 'C002',
status: UseStatus.C,
elements: [
new EdifactElement({
name: 'document_message_name_coded',
tag: '1001',
status: UseStatus.C,
_format: 'an..3'
}),
new EdifactElement({
name: 'code_list_qualifier',
tag: '1131',
status: UseStatus.C,
_format: 'an..3'
}),
new EdifactElement({
name: 'code_list_responsible_agency',
tag: '3055',
status: UseStatus.C,
_format: 'an..3'
}),
new EdifactElement({
name: 'document_message_name',
tag: '1000',
status: UseStatus.C,
_format: 'an..3'
}),
],
}),
new EdifactCompositeElement({
name: 'document_message_identification',
tag: 'C106',
status: UseStatus.C,
elements: [
new EdifactElement({
name: 'document_message_number',
tag: '1004',
status: UseStatus.C,
_format: 'an..35'
}),
new EdifactElement({
name: 'version',
tag: '1056',
status: UseStatus.C,
_format: 'an..9'
}),
new EdifactElement({
name: 'revision_number',
tag: '1060',
status: UseStatus.C,
_format: 'an..6',
}),
]
}),
new EdifactElement({
name: 'message_function_coded',
tag: '1225',
status: UseStatus.C,
_format: 'an..3'
}),
],
});
Using the serializer:
const interchangeHeaderData = {
syntax_identifier: 'UNOB',
syntax_version_number: '4',
interchange_sender_identification: '12345678ABC',
interchange_code_qualifier: '',
interchange_sender_internal_identification: 'ABCDEFGHIJKLMNOP',
interchange_sender_internal_sub_identification: 'SPCAS2',
interchange_recipient_identification: 'SARSDEC',
date_of_preparation: '20190501',
time_of_preparation: '1327',
interchange_control_reference: '1234567890',
recipient_reference_password: '',
application_reference: 'CUSDEC',
processing_priority_code: '',
acknowledgement_request: '1',
interchange_agreement_identifier: '',
test_indicator: '1'
};
const messageHeaderData = {
message_reference_number: '00000000155033',
message_type_identifier: 'CUSDEC',
message_type_version_number: 'D',
message_type_release_number: '96B',
controlling_agency: 'UN',
association_assigned_code: 'ZZZ01',
};
const beginningOfMessageData = {
document_message_name_coded: '929',
code_list_qualifier: '',
code_list_responsible_agency: '',
document_message_name: 'RCD',
document_message_number: '12345678ABC20190228654321',
version: '012345',
revision_number: '00001',
message_function_coded: '9'
};
const interchangeMessage = await renderInterchangeMessage([
{ segment: unbSegment, data: interchangeHeaderData },
{ segment: unhSegment, data: messageHeaderData },
{ segment: beginningOfMessageSegment, data: beginningOfMessageData },
//...other segments following...
]);
renderInterchangeMessageRenders EDIFACT message for a segment() function accepts array of type Message and outputs serialized data.
Message is an interface of segment {EdifactSegment} and data {any}
data is a map of edifact element identifier (name) and value. Refer to the example of 'beginningOfMessageData' and 'beginningOfMessageSegment' above.
renderSegment Renders EDIFACT message for a input segment and data.
validateValue Validates the value based on the EdifactElement definition.
getElementFormat Parses the EDIFACT data format string to useful values that can be used to validate the value
These functions are subject to change. Refer to the internal JSDoc definition for usage.
The definitions are validated using the class-validator package and the data is validated on the basis of the specified format (specified using the _format property).
Add new issues here.
Licensed under the APLv2. See the LICENSE file for details.
FAQs
Create EDIFACT segment definitions, validate data based on the segment and render the data in the EDI format
We found that edifact-serializer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.