@dbml/core 3.6.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/lib/connector/index.js +40 -0
  4. package/lib/export/DbmlExporter.js +0 -0
  5. package/lib/export/JsonExporter.js +0 -0
  6. package/lib/export/ModelExporter.js +0 -0
  7. package/lib/export/MysqlExporter.js +0 -0
  8. package/lib/export/OracleExporter.js +0 -0
  9. package/lib/export/PostgresExporter.js +0 -0
  10. package/lib/export/README.md +0 -0
  11. package/lib/export/SqlServerExporter.js +0 -0
  12. package/lib/export/index.js +0 -0
  13. package/lib/export/utils.js +0 -0
  14. package/lib/import/index.js +0 -0
  15. package/lib/index.js +0 -0
  16. package/lib/model_structure/config.js +0 -0
  17. package/lib/model_structure/database.js +0 -0
  18. package/lib/model_structure/dbState.js +0 -0
  19. package/lib/model_structure/element.js +0 -0
  20. package/lib/model_structure/endpoint.js +2 -2
  21. package/lib/model_structure/enum.js +2 -2
  22. package/lib/model_structure/enumValue.js +2 -2
  23. package/lib/model_structure/field.js +2 -2
  24. package/lib/model_structure/indexColumn.js +2 -2
  25. package/lib/model_structure/indexes.js +2 -2
  26. package/lib/model_structure/ref.js +2 -2
  27. package/lib/model_structure/schema.js +2 -2
  28. package/lib/model_structure/stickyNote.js +2 -2
  29. package/lib/model_structure/table.js +2 -2
  30. package/lib/model_structure/tableGroup.js +2 -2
  31. package/lib/model_structure/utils.js +0 -0
  32. package/lib/parse/ANTLR/ASTGeneration/AST.js +0 -0
  33. package/lib/parse/ANTLR/ASTGeneration/ParserErrorListener.js +0 -0
  34. package/lib/parse/ANTLR/ASTGeneration/SyntaxError.js +0 -0
  35. package/lib/parse/ANTLR/ASTGeneration/constants.js +0 -0
  36. package/lib/parse/ANTLR/ASTGeneration/helpers.js +0 -0
  37. package/lib/parse/ANTLR/ASTGeneration/index.js +0 -0
  38. package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js +0 -0
  39. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLLexerBase.js +0 -0
  40. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLParserBase.js +0 -0
  41. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.js +0 -0
  42. package/lib/parse/ANTLR/ASTGeneration/snowflake/SnowflakeASTGen.js +0 -0
  43. package/lib/parse/ANTLR/README.md +0 -0
  44. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.g4 +0 -0
  45. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.interp +0 -0
  46. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.js +0 -0
  47. package/lib/parse/ANTLR/parsers/mysql/MySqlLexer.tokens +0 -0
  48. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.g4 +0 -0
  49. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.interp +0 -0
  50. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.js +0 -0
  51. package/lib/parse/ANTLR/parsers/mysql/MySqlParser.tokens +0 -0
  52. package/lib/parse/ANTLR/parsers/mysql/MySqlParserVisitor.js +0 -0
  53. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.g4 +0 -0
  54. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.interp +0 -0
  55. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.js +0 -0
  56. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.tokens +0 -0
  57. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.g4 +0 -0
  58. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.interp +0 -0
  59. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.js +0 -0
  60. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.tokens +0 -0
  61. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserVisitor.js +0 -0
  62. package/lib/parse/ANTLR/parsers/postgresql/README.md +0 -0
  63. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.g4 +0 -0
  64. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.interp +0 -0
  65. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.js +0 -0
  66. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeLexer.tokens +0 -0
  67. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.g4 +0 -0
  68. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.interp +0 -0
  69. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.js +0 -0
  70. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParser.tokens +0 -0
  71. package/lib/parse/ANTLR/parsers/snowflake/SnowflakeParserVisitor.js +0 -0
  72. package/lib/parse/DatabaseConnector.js +87 -0
  73. package/lib/parse/Parser.js +0 -0
  74. package/lib/parse/buildParser.js +0 -0
  75. package/lib/parse/connection/ConnectionASTGeneration.js +21 -0
  76. package/lib/parse/connection/postgres/PostgresConnectionASTGen.js +63 -0
  77. package/lib/parse/connection/postgres/utils.js +462 -0
  78. package/lib/parse/dbml/parser.pegjs +0 -0
  79. package/lib/parse/dbmlParser.js +0 -0
  80. package/lib/parse/error.js +0 -0
  81. package/lib/parse/mssql/base_parsers.js +0 -0
  82. package/lib/parse/mssql/column_definition/actions.js +0 -0
  83. package/lib/parse/mssql/column_definition/index.js +0 -0
  84. package/lib/parse/mssql/constraint_definition/actions.js +0 -0
  85. package/lib/parse/mssql/constraint_definition/index.js +0 -0
  86. package/lib/parse/mssql/expression.js +0 -0
  87. package/lib/parse/mssql/fk_definition/actions.js +0 -0
  88. package/lib/parse/mssql/fk_definition/index.js +0 -0
  89. package/lib/parse/mssql/index.js +0 -0
  90. package/lib/parse/mssql/index_definition/actions.js +0 -0
  91. package/lib/parse/mssql/index_definition/index.js +0 -0
  92. package/lib/parse/mssql/keyword_parsers.js +0 -0
  93. package/lib/parse/mssql/keyword_utils.js +0 -0
  94. package/lib/parse/mssql/statements/actions.js +0 -0
  95. package/lib/parse/mssql/statements/index.js +0 -0
  96. package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +0 -0
  97. package/lib/parse/mssql/statements/statement_types/alter_table/add/actions.js +0 -0
  98. package/lib/parse/mssql/statements/statement_types/alter_table/add/index.js +0 -0
  99. package/lib/parse/mssql/statements/statement_types/alter_table/index.js +0 -0
  100. package/lib/parse/mssql/statements/statement_types/comments/actions.js +0 -0
  101. package/lib/parse/mssql/statements/statement_types/comments/index.js +0 -0
  102. package/lib/parse/mssql/statements/statement_types/create_index/actions.js +0 -0
  103. package/lib/parse/mssql/statements/statement_types/create_index/index.js +0 -0
  104. package/lib/parse/mssql/statements/statement_types/create_table/actions.js +0 -0
  105. package/lib/parse/mssql/statements/statement_types/create_table/index.js +0 -0
  106. package/lib/parse/mssql/statements/statement_types/index.js +0 -0
  107. package/lib/parse/mssql/utils.js +0 -0
  108. package/lib/parse/mssql/whitespaces.js +0 -0
  109. package/lib/parse/mssqlParser.js +0 -0
  110. package/lib/parse/mysql/parser.pegjs +0 -0
  111. package/lib/parse/mysqlParser.js +0 -0
  112. package/lib/parse/postgresParser.js +0 -0
  113. package/lib/parse/postgresql/Base_rules.pegjs +0 -0
  114. package/lib/parse/postgresql/Commands/Alter_table/Alter_table.pegjs +0 -0
  115. package/lib/parse/postgresql/Commands/Commands.pegjs +0 -0
  116. package/lib/parse/postgresql/Commands/Comment.pegjs +0 -0
  117. package/lib/parse/postgresql/Commands/Create_index.pegjs +0 -0
  118. package/lib/parse/postgresql/Commands/Create_table/Create_table.pegjs +0 -0
  119. package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +0 -0
  120. package/lib/parse/postgresql/Commands/Create_table/Create_table_of.pegjs +0 -0
  121. package/lib/parse/postgresql/Commands/Create_table/Create_table_partition_of.pegjs +0 -0
  122. package/lib/parse/postgresql/Commands/Create_type/Create_type.pegjs +0 -0
  123. package/lib/parse/postgresql/Commands/Create_type/Create_type_enum.pegjs +0 -0
  124. package/lib/parse/postgresql/Commands/Create_type/Create_type_range.pegjs +0 -0
  125. package/lib/parse/postgresql/Commands/Ignore_syntax.pegjs +0 -0
  126. package/lib/parse/postgresql/Expression.pegjs +0 -0
  127. package/lib/parse/postgresql/InitializerUtils.pegjs +0 -0
  128. package/lib/parse/postgresql/Keywords.pegjs +0 -0
  129. package/lib/parse/postgresql/get_parser.js +0 -0
  130. package/lib/parse/postgresql/parser.pegjs +0 -0
  131. package/lib/parse/schemarb/parser.pegjs +0 -0
  132. package/lib/parse/schemarbParser.js +0 -0
  133. package/lib/utils/version.js +0 -0
  134. package/package.json +3 -3
  135. package/types/export/ModelExporter.d.ts +0 -0
  136. package/types/export/index.d.ts +0 -0
  137. package/types/import/index.d.ts +0 -0
  138. package/types/index.d.ts +0 -0
  139. package/types/model_structure/database.d.ts +0 -0
  140. package/types/model_structure/dbState.d.ts +0 -0
  141. package/types/model_structure/element.d.ts +0 -0
  142. package/types/model_structure/endpoint.d.ts +0 -0
  143. package/types/model_structure/enum.d.ts +0 -0
  144. package/types/model_structure/enumValue.d.ts +0 -0
  145. package/types/model_structure/field.d.ts +0 -0
  146. package/types/model_structure/indexColumn.d.ts +0 -0
  147. package/types/model_structure/indexes.d.ts +0 -0
  148. package/types/model_structure/ref.d.ts +0 -0
  149. package/types/model_structure/schema.d.ts +0 -0
  150. package/types/model_structure/stickyNote.d.ts +0 -0
  151. package/types/model_structure/table.d.ts +0 -0
  152. package/types/model_structure/tableGroup.d.ts +0 -0
  153. package/types/parse/Parser.d.ts +0 -0
  154. package/types/parse/error.d.ts +0 -0
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _DatabaseConnector = _interopRequireDefault(require("../parse/DatabaseConnector"));
8
+ var _ModelExporter = _interopRequireDefault(require("../export/ModelExporter"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
11
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
12
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
+ function _fetch(_x, _x2) {
15
+ return _fetch2.apply(this, arguments);
16
+ }
17
+ function _fetch2() {
18
+ _fetch2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(connection, format) {
19
+ var database, dbml;
20
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ _context.next = 2;
24
+ return new _DatabaseConnector["default"](connection).fetch(format);
25
+ case 2:
26
+ database = _context.sent;
27
+ dbml = _ModelExporter["default"]["export"](database.normalize(), 'dbml');
28
+ return _context.abrupt("return", dbml);
29
+ case 5:
30
+ case "end":
31
+ return _context.stop();
32
+ }
33
+ }, _callee);
34
+ }));
35
+ return _fetch2.apply(this, arguments);
36
+ }
37
+ var _default = {
38
+ fetch: _fetch
39
+ };
40
+ exports["default"] = _default;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/lib/index.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -147,9 +147,9 @@ var Endpoint = /*#__PURE__*/function (_Element) {
147
147
  }, {
148
148
  key: "normalize",
149
149
  value: function normalize(model) {
150
- model.endpoints = _objectSpread(_objectSpread({}, model.endpoints), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread({
150
+ model.endpoints[this.id] = _objectSpread(_objectSpread({
151
151
  id: this.id
152
- }, this.shallowExport()), this.exportParentIds())));
152
+ }, this.shallowExport()), this.exportParentIds());
153
153
  }
154
154
  }]);
155
155
  return Endpoint;
@@ -143,9 +143,9 @@ var Enum = /*#__PURE__*/function (_Element) {
143
143
  }, {
144
144
  key: "normalize",
145
145
  value: function normalize(model) {
146
- model.enums = _objectSpread(_objectSpread({}, model.enums), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
146
+ model.enums[this.id] = _objectSpread(_objectSpread(_objectSpread({
147
147
  id: this.id
148
- }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
148
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds());
149
149
  this.values.forEach(function (v) {
150
150
  return v.normalize(model);
151
151
  });
@@ -76,9 +76,9 @@ var EnumValue = /*#__PURE__*/function (_Element) {
76
76
  }, {
77
77
  key: "normalize",
78
78
  value: function normalize(model) {
79
- model.enumValues = _objectSpread(_objectSpread({}, model.enumValues), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread({
79
+ model.enumValues[this.id] = _objectSpread(_objectSpread({
80
80
  id: this.id
81
- }, this.shallowExport()), this.exportParentIds())));
81
+ }, this.shallowExport()), this.exportParentIds());
82
82
  }
83
83
  }]);
84
84
  return EnumValue;
@@ -139,9 +139,9 @@ var Field = /*#__PURE__*/function (_Element) {
139
139
  }, {
140
140
  key: "normalize",
141
141
  value: function normalize(model) {
142
- model.fields = _objectSpread(_objectSpread({}, model.fields), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
142
+ model.fields[this.id] = _objectSpread(_objectSpread(_objectSpread({
143
143
  id: this.id
144
- }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
144
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds());
145
145
  }
146
146
  }]);
147
147
  return Field;
@@ -69,9 +69,9 @@ var IndexColumn = /*#__PURE__*/function (_Element) {
69
69
  }, {
70
70
  key: "normalize",
71
71
  value: function normalize(model) {
72
- model.indexColumns = _objectSpread(_objectSpread({}, model.indexColumns), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread({
72
+ model.indexColumns[this.id] = _objectSpread(_objectSpread({
73
73
  id: this.id
74
- }, this.shallowExport()), this.exportParentIds())));
74
+ }, this.shallowExport()), this.exportParentIds());
75
75
  }
76
76
  }]);
77
77
  return IndexColumn;
@@ -127,9 +127,9 @@ var Index = /*#__PURE__*/function (_Element) {
127
127
  }, {
128
128
  key: "normalize",
129
129
  value: function normalize(model) {
130
- model.indexes = _objectSpread(_objectSpread({}, model.indexes), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
130
+ model.indexes[this.id] = _objectSpread(_objectSpread(_objectSpread({
131
131
  id: this.id
132
- }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
132
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds());
133
133
  this.columns.forEach(function (c) {
134
134
  return c.normalize(model);
135
135
  });
@@ -130,9 +130,9 @@ var Ref = /*#__PURE__*/function (_Element) {
130
130
  }, {
131
131
  key: "normalize",
132
132
  value: function normalize(model) {
133
- model.refs = _objectSpread(_objectSpread({}, model.refs), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
133
+ model.refs[this.id] = _objectSpread(_objectSpread(_objectSpread({
134
134
  id: this.id
135
- }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
135
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds());
136
136
  this.endpoints.forEach(function (endpoint) {
137
137
  return endpoint.normalize(model);
138
138
  });
@@ -252,9 +252,9 @@ var Schema = /*#__PURE__*/function (_Element) {
252
252
  }, {
253
253
  key: "normalize",
254
254
  value: function normalize(model) {
255
- model.schemas = _objectSpread(_objectSpread({}, model.schemas), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
255
+ model.schemas[this.id] = _objectSpread(_objectSpread(_objectSpread({
256
256
  id: this.id
257
- }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
257
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds());
258
258
  this.tables.forEach(function (table) {
259
259
  return table.normalize(model);
260
260
  });
@@ -61,9 +61,9 @@ var StickyNote = /*#__PURE__*/function (_Element) {
61
61
  }, {
62
62
  key: "normalize",
63
63
  value: function normalize(model) {
64
- model.notes = _objectSpread(_objectSpread({}, model.notes), {}, _defineProperty({}, this.id, _objectSpread({
64
+ model.notes[this.id] = _objectSpread({
65
65
  id: this.id
66
- }, this["export"]())));
66
+ }, this["export"]());
67
67
  }
68
68
  }]);
69
69
  return StickyNote;
@@ -183,9 +183,9 @@ var Table = /*#__PURE__*/function (_Element) {
183
183
  }, {
184
184
  key: "normalize",
185
185
  value: function normalize(model) {
186
- model.tables = _objectSpread(_objectSpread({}, model.tables), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
186
+ model.tables[this.id] = _objectSpread(_objectSpread(_objectSpread({
187
187
  id: this.id
188
- }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
188
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds());
189
189
  this.fields.forEach(function (field) {
190
190
  return field.normalize(model);
191
191
  });
@@ -123,9 +123,9 @@ var TableGroup = /*#__PURE__*/function (_Element) {
123
123
  }, {
124
124
  key: "normalize",
125
125
  value: function normalize(model) {
126
- model.tableGroups = _objectSpread(_objectSpread({}, model.tableGroups), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
126
+ model.tableGroups[this.id] = _objectSpread(_objectSpread(_objectSpread({
127
127
  id: this.id
128
- }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
128
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds());
129
129
  }
130
130
  }]);
131
131
  return TableGroup;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _database = _interopRequireDefault(require("../model_structure/database"));
8
+ var _ConnectionASTGeneration = require("./connection/ConnectionASTGeneration");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
11
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
12
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
18
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
+ var DatabaseConnector = /*#__PURE__*/function () {
20
+ function DatabaseConnector(connection) {
21
+ _classCallCheck(this, DatabaseConnector);
22
+ this.connection = connection;
23
+ }
24
+ _createClass(DatabaseConnector, [{
25
+ key: "fetch",
26
+ value: function () {
27
+ var _fetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(format) {
28
+ var rawDatabase, schema;
29
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
30
+ while (1) switch (_context.prev = _context.next) {
31
+ case 0:
32
+ rawDatabase = {};
33
+ _context.t0 = format;
34
+ _context.next = _context.t0 === 'postgres' ? 4 : 8;
35
+ break;
36
+ case 4:
37
+ _context.next = 6;
38
+ return DatabaseConnector.fetchPostgresToJSON(this.connection);
39
+ case 6:
40
+ rawDatabase = _context.sent;
41
+ return _context.abrupt("break", 9);
42
+ case 8:
43
+ return _context.abrupt("break", 9);
44
+ case 9:
45
+ schema = DatabaseConnector.parseJSONToDatabase(rawDatabase);
46
+ return _context.abrupt("return", schema);
47
+ case 11:
48
+ case "end":
49
+ return _context.stop();
50
+ }
51
+ }, _callee, this);
52
+ }));
53
+ function fetch(_x) {
54
+ return _fetch.apply(this, arguments);
55
+ }
56
+ return fetch;
57
+ }()
58
+ }], [{
59
+ key: "parseJSONToDatabase",
60
+ value: function parseJSONToDatabase(rawDatabase) {
61
+ var database = new _database["default"](rawDatabase);
62
+ return database;
63
+ }
64
+ }, {
65
+ key: "fetchPostgresToJSON",
66
+ value: function () {
67
+ var _fetchPostgresToJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(connection) {
68
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
69
+ while (1) switch (_context2.prev = _context2.next) {
70
+ case 0:
71
+ return _context2.abrupt("return", (0, _ConnectionASTGeneration.fetch)(connection, 'postgres'));
72
+ case 1:
73
+ case "end":
74
+ return _context2.stop();
75
+ }
76
+ }, _callee2);
77
+ }));
78
+ function fetchPostgresToJSON(_x2) {
79
+ return _fetchPostgresToJSON.apply(this, arguments);
80
+ }
81
+ return fetchPostgresToJSON;
82
+ }()
83
+ }]);
84
+ return DatabaseConnector;
85
+ }();
86
+ var _default = DatabaseConnector;
87
+ exports["default"] = _default;
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetch = fetch;
7
+ var _PostgresConnectionASTGen = _interopRequireDefault(require("./postgres/PostgresConnectionASTGen"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9
+ function fetch(connection, format) {
10
+ var database = null;
11
+ switch (format) {
12
+ case 'postgres':
13
+ {
14
+ database = new _PostgresConnectionASTGen["default"]().fetch(connection);
15
+ break;
16
+ }
17
+ default:
18
+ throw new Error("Format not supported: ".concat(format));
19
+ }
20
+ return database;
21
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _utils = require("./utils");
8
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
16
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
+ var PostgresConnectionASTGen = /*#__PURE__*/function () {
18
+ function PostgresConnectionASTGen() {
19
+ _classCallCheck(this, PostgresConnectionASTGen);
20
+ this.data = {
21
+ schemas: [],
22
+ tables: [],
23
+ refs: [],
24
+ enums: [],
25
+ tableGroups: [],
26
+ aliases: [],
27
+ project: {}
28
+ };
29
+ }
30
+ _createClass(PostgresConnectionASTGen, [{
31
+ key: "fetch",
32
+ value: function () {
33
+ var _fetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(connection) {
34
+ var _yield$generateRawDb, tables, refs, enums;
35
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
36
+ while (1) switch (_context.prev = _context.next) {
37
+ case 0:
38
+ _context.next = 2;
39
+ return (0, _utils.generateRawDb)(connection);
40
+ case 2:
41
+ _yield$generateRawDb = _context.sent;
42
+ tables = _yield$generateRawDb.tables;
43
+ refs = _yield$generateRawDb.refs;
44
+ enums = _yield$generateRawDb.enums;
45
+ this.data.tables = tables;
46
+ this.data.refs = refs;
47
+ this.data.enums = enums;
48
+ return _context.abrupt("return", this.data);
49
+ case 10:
50
+ case "end":
51
+ return _context.stop();
52
+ }
53
+ }, _callee, this);
54
+ }));
55
+ function fetch(_x) {
56
+ return _fetch.apply(this, arguments);
57
+ }
58
+ return fetch;
59
+ }()
60
+ }]);
61
+ return PostgresConnectionASTGen;
62
+ }();
63
+ exports["default"] = PostgresConnectionASTGen;