53 lines
2.3 KiB
JavaScript
53 lines
2.3 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.SegmentTableBuilder = void 0;
|
|
const validator_1 = require("./validator");
|
|
const tableBuilder_1 = require("./tableBuilder");
|
|
const fs = __importStar(require("fs"));
|
|
class SegmentTableBuilder extends tableBuilder_1.TableBuilder {
|
|
constructor(type) {
|
|
super(type, tableBuilder_1.Suffix.Segments);
|
|
}
|
|
static enrichWithDefaultSegments(data) {
|
|
data.add("UNB", { requires: 5, elements: ["S001", "S002", "S003", "S004", "0020", "S005", "0026", "0029", "0031", "0032", "0035"] });
|
|
data.add("UNH", { requires: 2, elements: ["0062", "S009", "0068", "S010", "S016", "S017", "S018"] });
|
|
data.add("UNS", { requires: 1, elements: ["0081"] });
|
|
data.add("UNT", { requires: 2, elements: ["0074", "0062"] });
|
|
data.add("UNZ", { requires: 2, elements: ["0036", "0020"] });
|
|
return data;
|
|
}
|
|
build() {
|
|
const fileLoc = this.getDefinitionFileLoc();
|
|
let dict;
|
|
if (fileLoc) {
|
|
const sData = fs.readFileSync(fileLoc, { encoding: "utf-8" });
|
|
const data = JSON.parse(sData);
|
|
dict = new validator_1.Dictionary(data);
|
|
}
|
|
else {
|
|
dict = new validator_1.Dictionary();
|
|
}
|
|
return SegmentTableBuilder.enrichWithDefaultSegments(dict);
|
|
}
|
|
}
|
|
exports.SegmentTableBuilder = SegmentTableBuilder;
|
|
//# sourceMappingURL=segments.js.map
|