Classes

X12Element
X12FatInterchange
X12FunctionalGroup
X12Generator
X12Interchange
X12Parser
X12QueryEngine
X12Segment
X12SerializationOptions

Class instance wrapper for serialization options.

X12Transaction
X12TransactionMap

Members

X12SerializationOptions ⇒ X12SerializationOptions

Set default values for any missing X12SerializationOptions in an options object.

Typedefs

X12QueryResult : object

A result as resolved by the query engine.

X12Element

Kind: global class

new X12Element(value)

Create an element.

Param Type Description
value string <p>A value for this element.</p>

X12FatInterchange

Kind: global class

new X12FatInterchange([items], [options])

Create a fat interchange.

Param Type Description
[items] Array.<X12Interchange> | X12SerializationOptions <p>The items for this array or options for this interchange.</p>
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12FatInterchange.toString([options]) ⇒ string

Serialize fat interchange to EDI string.

Kind: instance method of X12FatInterchange
Returns: string - <p>This fat interchange converted to EDI string.</p>

Param Type Description
[options] X12SerializationOptions <p>Options to override serializing back to EDI.</p>

x12FatInterchange.toJSEDINotation() ⇒ Array.<JSEDINotation>

Serialize interchange to JS EDI Notation object.

Kind: instance method of X12FatInterchange
Returns: Array.<JSEDINotation> - <p>This fat interchange converted to an array of JS EDI notation.</p>

x12FatInterchange.toJSON() ⇒ Array.<object>

Serialize interchange to JSON object.

Kind: instance method of X12FatInterchange
Returns: Array.<object> - <p>This fat interchange converted to an array of objects.</p>

X12FunctionalGroup

Kind: global class

new X12FunctionalGroup([options])

Create a functional group.

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12FunctionalGroup.setHeader(elements)

Set a GS header on this functional group.

Kind: instance method of X12FunctionalGroup

Param Type Description
elements Array.<string> <p>An array of elements for a GS header.</p>

x12FunctionalGroup.addTransaction() ⇒ X12Transaction

Add a transaction set to this functional group.

Kind: instance method of X12FunctionalGroup
Returns: X12Transaction - <p>The transaction which was added to this functional group.</p>

x12FunctionalGroup.toString([options]) ⇒ string

Serialize functional group to EDI string.

Kind: instance method of X12FunctionalGroup
Returns: string - <p>This functional group converted to EDI string.</p>

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12FunctionalGroup.toJSON() ⇒ object

Serialize functional group to JSON object.

Kind: instance method of X12FunctionalGroup
Returns: object - <p>This functional group converted to an object.</p>

X12Generator

Kind: global class

new X12Generator([jsen], [options])

Factory for generating EDI from JS EDI Notation.

Param Type Description
[jsen] JSEDINotation <p>Javascript EDI Notation object to serialize.</p>
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Generator.setJSEDINotation([jsen])

Set the JS EDI Notation for this instance.

Kind: instance method of X12Generator

Param Type Description
[jsen] JSEDINotation <p>Javascript EDI Notation object to serialize.</p>

x12Generator.getJSEDINotation() ⇒ JSEDINotation

Get the JS EDI Notation for this instance.

Kind: instance method of X12Generator
Returns: JSEDINotation - <p>The JS EDI Notation for this instance.</p>

x12Generator.setOptions([options])

Set the serialization options for this instance.

Kind: instance method of X12Generator

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Generator.getOptions() ⇒ X12SerializationOptions

Get the serialization options for this instance.

Kind: instance method of X12Generator
Returns: X12SerializationOptions - <p>The serialization options for this instance.</p>

x12Generator.validate() ⇒ X12Interchange

Validate the EDI in this instance.

Kind: instance method of X12Generator
Returns: X12Interchange - <p>This instance converted to an interchange.</p>

x12Generator.toString() ⇒ string

Serialize the EDI in this instance.

Kind: instance method of X12Generator
Returns: string - <p>This instance converted to an EDI string.</p>

X12Interchange

Kind: global class

new X12Interchange([segmentTerminator], [elementDelimiter], [options])

Create an interchange.

Param Type Description
[segmentTerminator] string | X12SerializationOptions <p>A character to terminate segments when serializing; or an instance of X12SerializationOptions.</p>
[elementDelimiter] string <p>A character to separate elements when serializing; only required when segmentTerminator is a character.</p>
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Interchange.setHeader(elements)

Set an ISA header on this interchange.

Kind: instance method of X12Interchange

Param Type Description
elements Array.<string> <p>An array of elements for an ISA header.</p>

x12Interchange.addFunctionalGroup([options]) ⇒ X12FunctionalGroup

Add a functional group to this interchange.

Kind: instance method of X12Interchange
Returns: X12FunctionalGroup - <p>The functional group added to this interchange.</p>

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Interchange.toString([options]) ⇒ string

Serialize interchange to EDI string.

Kind: instance method of X12Interchange
Returns: string - <p>This interchange converted to an EDI string.</p>

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Interchange.toJSEDINotation() ⇒ JSEDINotation

Serialize interchange to JS EDI Notation object.

Kind: instance method of X12Interchange
Returns: JSEDINotation - <p>This interchange converted to JS EDI Notation object.</p>

x12Interchange.toJSON() ⇒ object

Serialize interchange to JSON object.

Kind: instance method of X12Interchange
Returns: object - <p>This interchange converted to an object.</p>

X12Parser

Kind: global class

new X12Parser([strict], [encoding], [options])

Factory for parsing EDI into interchange object.

Param Type Description
[strict] boolean | X12SerializationOptions <p>Set true to strictly follow the EDI spec; defaults to false.</p>
[encoding] string | X12SerializationOptions <p>The encoding to use for this instance when parsing a stream; defaults to UTF-8.</p>
[options] X12SerializationOptions <p>The options to use when parsing a stream.</p>

x12Parser.parse(edi, [options]) ⇒ X12Interchange | X12FatInterchange

Parse an EDI document.

Kind: instance method of X12Parser
Returns: X12Interchange | X12FatInterchange - <p>An interchange or fat interchange.</p>

Param Type Description
edi string <p>An ASCII or UTF8 string of EDI to parse.</p>
[options] X12SerializationOptions <p>Options for serializing from EDI.</p>

x12Parser.getInterchangeFromSegments(segments, [options]) ⇒ X12Interchange | X12FatInterchange

Method for processing an array of segments into the node-x12 object model; typically used with the finished output of a stream.

Kind: instance method of X12Parser
Returns: X12Interchange | X12FatInterchange - <p>An interchange or fat interchange.</p>

Param Type Description
segments Array.<X12Segment> <p>An array of X12Segment objects.</p>
[options] X12SerializationOptions <p>Options for serializing from EDI.</p>

x12Parser._flush(callback)

Flush method for Node API Transform stream.

Kind: instance method of X12Parser

Param Type Description
callback function <p>Callback to execute when finished.</p>

x12Parser._transform(chunk, encoding, callback)

Transform method for Node API Transform stream.

Kind: instance method of X12Parser

Param Type Description
chunk object <p>A chunk of data from the read stream.</p>
encoding string <p>Chunk enoding.</p>
callback function <p>Callback signalling chunk is processed and instance is ready for next chunk.</p>

X12QueryEngine

Kind: global class

new X12QueryEngine([parser])

Factory for querying EDI using the node-x12 object model.

Param Type Default Description
[parser] X12Parser | boolean true <p>Pass an external parser or set the strictness of the internal parser.</p>

x12QueryEngine.query(rawEdi, reference, [defaultValue]) ⇒ Array.<X12QueryResult>

Query all references in an EDI document.

Kind: instance method of X12QueryEngine
Returns: Array.<X12QueryResult> - <p>An array of results from the EDI document.</p>

Param Type Default Description
rawEdi string | X12Interchange   <p>An ASCII or UTF8 string of EDI to parse, or an interchange.</p>
reference string   <p>The query string to resolve.</p>
[defaultValue] string null <p>A default value to return if result not found.</p>

x12QueryEngine.querySingle(rawEdi, reference, [defaultValue]) ⇒ X12QueryResult

Query all references in an EDI document and return the first result.

Kind: instance method of X12QueryEngine
Returns: X12QueryResult - <p>A result from the EDI document.</p>

Param Type Default Description
rawEdi string | X12Interchange   <p>An ASCII or UTF8 string of EDI to parse, or an interchange.</p>
reference string   <p>The query string to resolve.</p>
[defaultValue] string null <p>A default value to return if result not found.</p>

X12Segment

Kind: global class

new X12Segment(tag, [options])

Create a segment.

Param Type Description
tag string <p>The tag for this segment.</p>
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Segment.setTag(tag)

Set the tag name for the segment if not provided when constructed.

Kind: instance method of X12Segment

Param Type Description
tag string <p>The tag for this segment.</p>

x12Segment.setElements(values) ⇒ this

Set the elements of this segment.

Kind: instance method of X12Segment
Returns: this - <p>The current instance of X12Segment.</p>

Param Type Description
values Array.<string> <p>An array of element values.</p>

x12Segment.addElement(value) ⇒ X12Element

Add an element to this segment.

Kind: instance method of X12Segment
Returns: X12Element - <p>The element that was added to this segment.</p>

Param Type Description
value string <p>A string value.</p>

x12Segment.replaceElement(value, segmentPosition) ⇒ X12Element

Replace an element at a position in the segment.

Kind: instance method of X12Segment
Returns: X12Element - <p>The new element if successful, or a null if failed.</p>

Param Type Description
value string <p>A string value.</p>
segmentPosition number <p>A 1-based number indicating the position in the segment.</p>

x12Segment.insertElement(value, segmentPosition) ⇒ X12Element

Insert an element at a position in the segment.

Kind: instance method of X12Segment
Returns: X12Element - <p>The new element if successful, or a null if failed.</p>

Param Type Default Description
value string   <p>A string value.</p>
segmentPosition number 1 <p>A 1-based number indicating the position in the segment.</p>

x12Segment.removeElement(segmentPosition) ⇒ boolean

Remove an element at a position in the segment.

Kind: instance method of X12Segment
Returns: boolean - <p>True if successful.</p>

Param Type Description
segmentPosition number <p>A 1-based number indicating the position in the segment.</p>

x12Segment.valueOf(segmentPosition, [defaultValue]) ⇒ string

Get the value of an element in this segment.

Kind: instance method of X12Segment
Returns: string - <p>If no element is at this position, null or the default value will be returned.</p>

Param Type Description
segmentPosition number <p>A 1-based number indicating the position in the segment.</p>
[defaultValue] string <p>A default value to return if there is no element found.</p>

x12Segment.toString([options]) ⇒ string

Serialize segment to EDI string.

Kind: instance method of X12Segment
Returns: string - <p>This segment converted to an EDI string.</p>

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Segment.toJSON() ⇒ object

Serialize transaction set to JSON object.

Kind: instance method of X12Segment
Returns: object - <p>This segment converted to an object.</p>

X12SerializationOptions

Class instance wrapper for serialization options.

Kind: global class

X12Transaction

Kind: global class

new X12Transaction([options])

Create a transaction set.

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Transaction.setHeader(elements)

Set a ST header on this transaction set.

Kind: instance method of X12Transaction

Param Type Description
elements Array.<string> <p>An array of elements for a ST header.</p>

x12Transaction.addSegment(tag, elements) ⇒ X12Segment

Add a segment to this transaction set.

Kind: instance method of X12Transaction
Returns: X12Segment - <p>The segment added to this transaction set.</p>

Param Type Description
tag string <p>The tag for this segment.</p>
elements Array.<string> <p>An array of elements for this segment.</p>

x12Transaction.fromObject(input, map, [macro])

Map data from a javascript object to this transaction set. Will use the txEngine property for Liquid support from this.options if available.

Kind: instance method of X12Transaction

Param Type Description
input object <p>The input object to create the transaction from.</p>
map object <p>The javascript object containing keys and querys to resolve.</p>
[macro] object <p>A macro object to add or override methods for the macro directive; properties ‘header’ and ‘segments’ are reserved words.</p>

x12Transaction.toObject(map, helper) ⇒ object

Map data from a transaction set to a javascript object.

Kind: instance method of X12Transaction
Returns: object - <p>An object containing resolved values mapped to object keys.</p>

Param Type Description
map object <p>The javascript object containing keys and querys to resolve.</p>
helper function <p>A helper function which will be executed on every resolved query value.</p>

x12Transaction.toString([options]) ⇒ string

Serialize transaction set to EDI string.

Kind: instance method of X12Transaction
Returns: string - <p>This transaction set converted to an EDI string.</p>

Param Type Description
[options] X12SerializationOptions <p>Options for serializing back to EDI.</p>

x12Transaction.toJSON() ⇒ object

Serialize transaction set to JSON object.

Kind: instance method of X12Transaction
Returns: object - <p>This transaction set converted to an object.</p>

X12TransactionMap

Kind: global class

new X12TransactionMap(map, [transaction], [helper], [txEngine])

Factory for mapping transaction set data to javascript object map.

Param Type Description
map object <p>The javascript object containing keys and querys to resolve.</p>
[transaction] X12Transaction <p>A transaction set to map.</p>
[helper] function | 'liquidjs' | 'internal' <p>A helper function which will be executed on every resolved query value, or a macro engine.</p>
[txEngine] 'liquidjs' | 'internal' <p>A macro engine to use; either ‘internal’ or ‘liquidjs’; defaults to internal for backwords compatibility.</p>

x12TransactionMap.setTransaction(transaction, helper)

Set the transaction set to map and optionally a helper function.

Kind: instance method of X12TransactionMap

Param Type Description
transaction X12Transaction <p>A transaction set to map.</p>
helper function <p>A helper function which will be executed on every resolved query value.</p>

x12TransactionMap.getTransaction() ⇒ X12Transaction

Set the transaction set to map and optionally a helper function.

Kind: instance method of X12TransactionMap
Returns: X12Transaction - <p>The transaction from this instance.</p>

x12TransactionMap.toObject([map], [callback]) ⇒ object | Array.<object>

Map data from the transaction set to a javascript object.

Kind: instance method of X12TransactionMap
Returns: object | Array.<object> - <p>The transaction set mapped to an object or an array of objects.</p>

Param Type Description
[map] object <p>The javascript object containing keys and querys to resolve.</p>
[callback] function <p>A callback function which will be passed to the helper function.</p>

x12TransactionMap.fromObject(input, [map], [macroObj]) ⇒ X12Transaction

Map data from a javascript object to the transaction set.

Kind: instance method of X12TransactionMap
Returns: X12Transaction - <p>The transaction created from the object values.</p>

Param Type Default Description
input object   <p>The input object to create the transaction from.</p>
[map] object   <p>The map to associate values from the input to the transaction, or a macro object.</p>
[macroObj] object {} <p>A macro object to add or override methods for the macro directive; properties ‘header’ and ‘segments’ are reserved words.</p>

X12SerializationOptions ⇒ X12SerializationOptions

Set default values for any missing X12SerializationOptions in an options object.

Kind: global variable
Returns: X12SerializationOptions - <p>Serialization options with defaults filled in.</p>

Param Type Description
[options] X12SerializationOptions <p>Options for serializing to and from EDI.</p>

X12QueryResult : object

A result as resolved by the query engine.

Kind: global typedef
Properties

Name Type Default
interchange X12Interchange  
functionalGroup X12FunctionalGroup  
transaction X12Transaction  
segment X12Segment  
element X12Element  
[value] string null
[values] Array.<(string\|Array.<string>)> []