@makakwastaken/ts-edifact
Version:
Edifact parser library
72 lines • 3.09 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 { HttpClient } from '../httpClient';
import type { MessageType } from '../tracker';
import { type ComponentValueEntry, Dictionary, type ElementEntry, type SegmentEntry } from '../validator';
export interface EdifactMessageSpecification {
readonly messageType: string;
readonly version: string;
readonly release: string;
readonly controllingAgency: string;
readonly componentValueTable: Dictionary<ComponentValueEntry>;
/**
* Contains the available segments as key and the respective elements
* a segment contains as well as the mandatory count as value
*/
readonly segmentTable: Dictionary<SegmentEntry>;
/**
* Contains the actual message structure generatedby this parser
*/
readonly messageStructureDefinition: MessageType[];
type(): string;
versionAbbr(): string;
}
export declare class EdifactMessageSpecificationImpl implements EdifactMessageSpecification {
messageType: string;
version: string;
release: string;
controllingAgency: string;
segmentTable: Dictionary<SegmentEntry>;
elementTable: Dictionary<ElementEntry>;
componentValueTable: Dictionary<ComponentValueEntry>;
messageStructureDefinition: MessageType[];
constructor(messageType: string, version: string, release: string, controllingAgency: string);
type(): string;
versionAbbr(): string;
}
export type ParsingResultType = {
specObj: EdifactMessageSpecification;
promises: Promise<EdifactMessageSpecification>[];
};
export interface MessageStructureParser {
loadTypeSpec(): Promise<EdifactMessageSpecification>;
}
export declare class UNECEMessageStructureParser implements MessageStructureParser {
readonly version: string;
readonly type: string;
readonly httpClient: HttpClient;
constructor(version: string, type: string);
private extractTextValue;
protected loadPage(page: string): Promise<string>;
protected formatComponentName(name?: string): string | undefined;
protected parseComponentDefinitionPage(component: string, page: string, definition: EdifactMessageSpecification): Promise<EdifactMessageSpecification>;
protected parseSegmentDefinitionPage(segment: string, page: string, definition: EdifactMessageSpecification): Promise<EdifactMessageSpecification>;
private parseMessagePage;
loadTypeSpec(): Promise<EdifactMessageSpecification>;
}
//# sourceMappingURL=messageStructureParser.d.ts.map