@makakwastaken/ts-edifact
Version:
Edifact parser library
102 lines • 3.88 kB
TypeScript
/**
* @author Roman Vottner
* @copyright 2020 Roman Vottner
* @license Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { Separators } from './edi/separators';
import { type MessageHeader, type Segment } from './edifact';
import type { ResultType } from './reader';
import type { ElementEntry } from './validator';
export declare class Group {
name: string;
parent: Message | Group;
data: (Group | Segment)[];
constructor(name: string, parent: Message | Group);
addSegment(segment: Segment): void;
addGroup(group: Group): void;
groupCount(): number;
containsGroup(groupName: string): boolean;
groupByName(groupName: string): Group | undefined;
}
export declare class Message {
messageHeader: MessageHeader;
header: (Group | Segment)[];
detail: (Group | Segment)[];
summary: (Group | Segment)[];
constructor(data: ResultType);
addSegment(segment: Segment, sectionName: string): void;
addGroup(group: Group, sectionName: string): void;
private section;
groupCount(sectionName?: string): number;
containsGroup(groupName: string, sectionName?: string): boolean;
groupByName(groupName: string, sectionName?: string): Group | undefined;
}
export interface SyntaxIdentifier {
syntaxIdentifer: string;
syntaxVersionNumber: string;
serviceCodeListDirectoryVersionNumber: string | undefined;
charEncoding: string | undefined;
}
export interface Participant {
id: string;
codeQualifier: string | undefined;
internalId: string | undefined;
internalSubId: string | undefined;
}
export interface RecipientsRef {
password: string;
passwordQualifier: string | undefined;
}
export declare class Edifact {
syntaxIdentifier: SyntaxIdentifier;
sender: Participant;
receiver: Participant;
date: string;
time: string;
interchangeNumber: string;
recipientsRef: RecipientsRef | undefined;
applicationRef: string | undefined;
processingPriorityCode: string | undefined;
ackRequest: number | undefined;
agreementId: string | undefined;
testIndicator: number;
messages: Message[];
constructor(elements: ElementEntry[]);
addMessage(message: Message): void;
}
export declare class InterchangeBuilder {
interchange: Edifact;
private stack;
private curSection;
/**
* Uses the provided parsing result to create an Edifact interchange structure. This
* process will validate the order of the parsed segment definitions against available
* Edifact message structure definition files, which are determined by the respective
* version defined in the UNH segments of the parsing result.
*
* This process will fail if mandatory segments are missing of if any unexpected
* segments, not defined in the message structure definition file, are found.
*
* @param parsingResult The actual result of the Edifact document parsing process.
* @param basePath The base location the Edifact message structure definition files
* in JSON format can be found
*/
constructor(parsingResult: ResultType[], separators: Separators, basePath: string);
private reset;
private accept;
private getMessageStructureDefForMessage;
private readFileAsMessageStructure;
}
//# sourceMappingURL=interchangeBuilder.d.ts.map