"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MysqlSchemaPreprocessor_1 = require("../preprocesors/MysqlSchemaPreprocessor");
var RamlSchemaPreprocessor_1 = require("../preprocesors/RamlSchemaPreprocessor");
/**
* Base Handler.
*
* @export
* @class BaseHandler
*/
var BaseHandler = (function () {
function BaseHandler(driver) {
this.driver = driver;
}
/**
* Normalize column schema.
*
* @param {*} columnSchema sql column schema
* @returns {*} normalized column schema
*/
BaseHandler.prototype.normalizeColumnSchema = function (columnSchema) {
switch (this.driver) {
case 'mysql': {
return (new MysqlSchemaPreprocessor_1.default()).convertToStandardSchema(columnSchema);
}
case 'raml': {
return (new RamlSchemaPreprocessor_1.default()).convertToStandardSchema(columnSchema);
}
default: {
throw new Error('Input source not not supported.');
}
}
};
/**
* Normalize relations between tables inside the schema.
*
* @param {*} schema database schema
* @returns {*} normalized database schema
*/
BaseHandler.prototype.normalizeRelations = function (schema) {
switch (this.driver) {
case 'mysql': {
return (new MysqlSchemaPreprocessor_1.default()).normalizeSchemaRelations(schema);
}
case 'raml': {
return (new RamlSchemaPreprocessor_1.default()).normalizeSchemaRelations(schema);
}
default: {
throw new Error('Input source not not supported.');
}
}
};
return BaseHandler;
}());
exports.default = BaseHandler;
|