Erster Commit
This commit is contained in:
75
node_modules/ts-edifact/lib/tableBuilder.js
generated
vendored
Normal file
75
node_modules/ts-edifact/lib/tableBuilder.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"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.TableBuilder = exports.Suffix = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
var Suffix;
|
||||
(function (Suffix) {
|
||||
Suffix["Elements"] = "elements";
|
||||
Suffix["Segments"] = "segments";
|
||||
})(Suffix = exports.Suffix || (exports.Suffix = {}));
|
||||
class TableBuilder {
|
||||
constructor(type, suffix) {
|
||||
this.type = type;
|
||||
this.fileSuffix = suffix;
|
||||
}
|
||||
forVersion(version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
specLocation(location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
}
|
||||
getDefinitionFileLoc() {
|
||||
let defaultFilePath;
|
||||
if (this.location) {
|
||||
defaultFilePath = path.resolve("./", this.location);
|
||||
if (!defaultFilePath.endsWith("/")) {
|
||||
defaultFilePath += "/";
|
||||
}
|
||||
}
|
||||
else {
|
||||
defaultFilePath = "./";
|
||||
}
|
||||
const baseFileName = defaultFilePath + this.type.toUpperCase() + "." + this.fileSuffix + ".json";
|
||||
if (this.version) {
|
||||
const versionedFileName = defaultFilePath + this.version.toUpperCase() + "_" + this.type.toUpperCase() + "." + this.fileSuffix + ".json";
|
||||
if (fs.existsSync(versionedFileName)) {
|
||||
return versionedFileName;
|
||||
}
|
||||
else if (fs.existsSync(baseFileName)) {
|
||||
console.warn(`No ${this.fileSuffix} definition file found for message type ${this.type} of version ${this.version}. Falling back to default version`);
|
||||
return baseFileName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fs.existsSync(baseFileName)) {
|
||||
return baseFileName;
|
||||
}
|
||||
}
|
||||
console.error(`No ${this.fileSuffix} definition file found for message type ${this.type}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.TableBuilder = TableBuilder;
|
||||
//# sourceMappingURL=tableBuilder.js.map
|
||||
Reference in New Issue
Block a user