UNPKG

sql-ddl-to-json-schema

Version:

Parse and convert SQL DDL statements to a JSON Schema.

21 lines (20 loc) 692 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.format = void 0; const database_1 = require("./models/database"); /** * Formats given JSON parsed from SQL to a compact * format containing array of tables. * * @param json Parsed JSON format. */ const format = (json) => { if (json.id === 'MAIN') { const database = new database_1.Database(); database.parseDdsCollection(json.def); return database.getTables().map((t) => t.toJSON()); } throw new TypeError('Invalid JSON format provided for CompactFormatter. ' + 'Please provide JSON from root element, containing { id: MAIN }.'); }; exports.format = format;