@dbml/core 2.3.0 → 2.4.1

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 (52) hide show
  1. package/lib/export/DbmlExporter.js +17 -9
  2. package/lib/export/JsonExporter.js +1 -3
  3. package/lib/export/ModelExporter.js +1 -3
  4. package/lib/export/MysqlExporter.js +50 -42
  5. package/lib/export/PostgresExporter.js +64 -49
  6. package/lib/export/SqlServerExporter.js +52 -46
  7. package/lib/model_structure/database.js +73 -28
  8. package/lib/model_structure/dbState.js +1 -3
  9. package/lib/model_structure/element.js +13 -13
  10. package/lib/model_structure/endpoint.js +18 -14
  11. package/lib/model_structure/enum.js +18 -14
  12. package/lib/model_structure/enumValue.js +16 -12
  13. package/lib/model_structure/field.js +47 -13
  14. package/lib/model_structure/indexColumn.js +16 -12
  15. package/lib/model_structure/indexes.js +18 -14
  16. package/lib/model_structure/ref.js +19 -16
  17. package/lib/model_structure/schema.js +24 -36
  18. package/lib/model_structure/table.js +19 -15
  19. package/lib/model_structure/tableGroup.js +18 -14
  20. package/lib/model_structure/utils.js +5 -0
  21. package/lib/parse/Parser.js +2 -4
  22. package/lib/parse/buildParser.js +1 -3
  23. package/lib/parse/dbml/parser.pegjs +64 -20
  24. package/lib/parse/dbmlParser.js +1401 -899
  25. package/lib/parse/mssql/constraint_definition/actions.js +2 -2
  26. package/lib/parse/mssql/fk_definition/actions.js +10 -3
  27. package/lib/parse/mssql/keyword_parsers.js +12 -2
  28. package/lib/parse/mssql/statements/actions.js +37 -6
  29. package/lib/parse/mssql/statements/index.js +1 -1
  30. package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +11 -5
  31. package/lib/parse/mssql/statements/statement_types/comments/actions.js +57 -0
  32. package/lib/parse/mssql/statements/statement_types/comments/index.js +97 -0
  33. package/lib/parse/mssql/statements/statement_types/create_index/actions.js +6 -1
  34. package/lib/parse/mssql/statements/statement_types/create_table/actions.js +12 -10
  35. package/lib/parse/mssql/statements/statement_types/index.js +4 -1
  36. package/lib/parse/mssql/utils.js +16 -1
  37. package/lib/parse/mysql/parser.pegjs +66 -40
  38. package/lib/parse/mysqlParser.js +534 -359
  39. package/lib/parse/postgresParser.js +15 -13
  40. package/lib/parse/postgresql/Base_rules.pegjs +45 -10
  41. package/lib/parse/postgresql/Commands/Alter_table/Alter_table.pegjs +49 -4
  42. package/lib/parse/postgresql/Commands/Comment.pegjs +18 -6
  43. package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +5 -3
  44. package/lib/parse/postgresql/Commands/Create_table/Create_table_of.pegjs +1 -1
  45. package/lib/parse/postgresql/Commands/Create_table/Create_table_partition_of.pegjs +1 -1
  46. package/lib/parse/postgresql/Commands/Create_type/Create_type_enum.pegjs +2 -2
  47. package/lib/parse/postgresql/Commands/Ignore_syntax.pegjs +10 -1
  48. package/lib/parse/postgresql/InitializerUtils.pegjs +14 -2
  49. package/lib/parse/postgresql/Keywords.pegjs +5 -1
  50. package/lib/parse/postgresql/parser.pegjs +22 -8
  51. package/lib/parse/schemarbParser.js +3 -3
  52. package/package.json +2 -2
@@ -7,13 +7,15 @@ exports["default"] = void 0;
7
7
 
8
8
  var _element = _interopRequireDefault(require("./element"));
9
9
 
10
+ var _config = require("./config");
11
+
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
13
 
12
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13
15
 
14
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
17
 
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
19
 
18
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
21
 
@@ -23,21 +25,25 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
23
25
 
24
26
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25
27
 
28
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
29
+
30
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
31
+
32
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
33
+
26
34
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
27
35
 
28
36
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
37
 
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
-
32
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
38
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
33
39
 
34
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
40
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
41
 
36
- var Field =
37
- /*#__PURE__*/
38
- function (_Element) {
42
+ var Field = /*#__PURE__*/function (_Element) {
39
43
  _inherits(Field, _Element);
40
44
 
45
+ var _super = _createSuper(Field);
46
+
41
47
  function Field() {
42
48
  var _this;
43
49
 
@@ -56,7 +62,7 @@ function (_Element) {
56
62
 
57
63
  _classCallCheck(this, Field);
58
64
 
59
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Field).call(this, token));
65
+ _this = _super.call(this, token);
60
66
 
61
67
  if (!name) {
62
68
  _this.error('Field must have a name');
@@ -66,7 +72,7 @@ function (_Element) {
66
72
  _this.error('Field must have a type');
67
73
  }
68
74
 
69
- _this.name = name; // type : { type_name, value }
75
+ _this.name = name; // type : { type_name, value, schemaName }
70
76
 
71
77
  _this.type = type;
72
78
  _this.unique = unique;
@@ -81,6 +87,8 @@ function (_Element) {
81
87
 
82
88
  _this.generateId();
83
89
 
90
+ _this.bindType();
91
+
84
92
  return _this;
85
93
  }
86
94
 
@@ -89,6 +97,32 @@ function (_Element) {
89
97
  value: function generateId() {
90
98
  this.id = this.dbState.generateId('fieldId');
91
99
  }
100
+ }, {
101
+ key: "bindType",
102
+ value: function bindType() {
103
+ var typeName = this.type.type_name;
104
+ var typeSchemaName = this.type.schemaName || _config.DEFAULT_SCHEMA_NAME;
105
+
106
+ if (this.type.schemaName) {
107
+ var _enum = this.table.schema.database.findEnum(typeSchemaName, typeName);
108
+
109
+ if (!_enum) {
110
+ this.error("Cannot find type ".concat(typeSchemaName, " in schema ").concat(typeSchemaName));
111
+ return;
112
+ }
113
+
114
+ this._enum = _enum;
115
+
116
+ _enum.pushField(this);
117
+ } else {
118
+ var _enum2 = this.table.schema.database.findEnum(typeSchemaName, typeName);
119
+
120
+ if (!_enum2) return;
121
+ this._enum = _enum2;
122
+
123
+ _enum2.pushField(this);
124
+ }
125
+ }
92
126
  }, {
93
127
  key: "pushEndpoint",
94
128
  value: function pushEndpoint(endpoint) {
@@ -133,9 +167,9 @@ function (_Element) {
133
167
  }, {
134
168
  key: "normalize",
135
169
  value: function normalize(model) {
136
- model.fields = _objectSpread({}, model.fields, _defineProperty({}, this.id, _objectSpread({
170
+ model.fields = _objectSpread(_objectSpread({}, model.fields), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
137
171
  id: this.id
138
- }, this.shallowExport(), {}, this.exportChildIds(), {}, this.exportParentIds())));
172
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
139
173
  }
140
174
  }]);
141
175
 
@@ -9,11 +9,11 @@ var _element = _interopRequireDefault(require("./element"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
11
 
12
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13
13
 
14
14
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
15
 
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
17
 
18
18
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
19
 
@@ -23,21 +23,25 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
23
23
 
24
24
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25
25
 
26
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
+
28
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
+
30
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
31
+
26
32
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
27
33
 
28
34
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
29
35
 
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
36
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
31
37
 
32
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
33
-
34
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
38
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
39
 
36
- var IndexColumn =
37
- /*#__PURE__*/
38
- function (_Element) {
40
+ var IndexColumn = /*#__PURE__*/function (_Element) {
39
41
  _inherits(IndexColumn, _Element);
40
42
 
43
+ var _super = _createSuper(IndexColumn);
44
+
41
45
  function IndexColumn(_ref) {
42
46
  var _this;
43
47
 
@@ -47,7 +51,7 @@ function (_Element) {
47
51
 
48
52
  _classCallCheck(this, IndexColumn);
49
53
 
50
- _this = _possibleConstructorReturn(this, _getPrototypeOf(IndexColumn).call(this));
54
+ _this = _super.call(this);
51
55
  _this.type = type;
52
56
  _this.value = value;
53
57
  _this.index = index;
@@ -86,9 +90,9 @@ function (_Element) {
86
90
  }, {
87
91
  key: "normalize",
88
92
  value: function normalize(model) {
89
- model.indexColumns = _objectSpread({}, model.indexColumns, _defineProperty({}, this.id, _objectSpread({
93
+ model.indexColumns = _objectSpread(_objectSpread({}, model.indexColumns), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread({
90
94
  id: this.id
91
- }, this.shallowExport(), {}, this.exportParentIds())));
95
+ }, this.shallowExport()), this.exportParentIds())));
92
96
  }
93
97
  }]);
94
98
 
@@ -11,11 +11,11 @@ var _indexColumn = _interopRequireDefault(require("./indexColumn"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
13
 
14
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
14
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15
15
 
16
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
17
17
 
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
19
 
20
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
 
@@ -25,21 +25,25 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
25
25
 
26
26
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
27
27
 
28
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
29
+
30
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
31
+
32
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
33
+
28
34
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
29
35
 
30
36
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
31
37
 
32
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
38
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
33
39
 
34
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
-
36
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
40
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
37
41
 
38
- var Index =
39
- /*#__PURE__*/
40
- function (_Element) {
42
+ var Index = /*#__PURE__*/function (_Element) {
41
43
  _inherits(Index, _Element);
42
44
 
45
+ var _super = _createSuper(Index);
46
+
43
47
  function Index() {
44
48
  var _this;
45
49
 
@@ -56,7 +60,7 @@ function (_Element) {
56
60
 
57
61
  _classCallCheck(this, Index);
58
62
 
59
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Index).call(this, token));
63
+ _this = _super.call(this, token);
60
64
  _this.name = name;
61
65
  _this.type = type;
62
66
  _this.unique = unique;
@@ -84,7 +88,7 @@ function (_Element) {
84
88
  var _this2 = this;
85
89
 
86
90
  rawColumns.forEach(function (column) {
87
- _this2.pushIndexColumn(new _indexColumn["default"](_objectSpread({}, column, {
91
+ _this2.pushIndexColumn(new _indexColumn["default"](_objectSpread(_objectSpread({}, column), {}, {
88
92
  index: _this2
89
93
  })));
90
94
  });
@@ -107,7 +111,7 @@ function (_Element) {
107
111
  }, {
108
112
  key: "export",
109
113
  value: function _export() {
110
- return _objectSpread({}, this.shallowExport(), {}, this.exportChild());
114
+ return _objectSpread(_objectSpread({}, this.shallowExport()), this.exportChild());
111
115
  }
112
116
  }, {
113
117
  key: "exportChild",
@@ -148,9 +152,9 @@ function (_Element) {
148
152
  }, {
149
153
  key: "normalize",
150
154
  value: function normalize(model) {
151
- model.indexes = _objectSpread({}, model.indexes, _defineProperty({}, this.id, _objectSpread({
155
+ model.indexes = _objectSpread(_objectSpread({}, model.indexes), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
152
156
  id: this.id
153
- }, this.shallowExport(), {}, this.exportChildIds(), {}, this.exportParentIds())));
157
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
154
158
  this.columns.forEach(function (c) {
155
159
  return c.normalize(model);
156
160
  });
@@ -13,11 +13,11 @@ var _config = require("./config");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
15
 
16
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
17
17
 
18
18
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
19
19
 
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
21
 
22
22
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
23
 
@@ -27,15 +27,19 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
27
27
 
28
28
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
29
 
30
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
+
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
+
34
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
+
30
36
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
31
37
 
32
38
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
39
 
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
35
41
 
36
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
37
-
38
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
43
 
40
44
  /**
41
45
  * Compare two pairs of objects
@@ -47,11 +51,11 @@ function isEqualPair(pair1, pair2) {
47
51
  return pair1[0].equals(pair2[0]) && pair1[1].equals(pair2[1]);
48
52
  }
49
53
 
50
- var Ref =
51
- /*#__PURE__*/
52
- function (_Element) {
54
+ var Ref = /*#__PURE__*/function (_Element) {
53
55
  _inherits(Ref, _Element);
54
56
 
57
+ var _super = _createSuper(Ref);
58
+
55
59
  function Ref() {
56
60
  var _this;
57
61
 
@@ -66,7 +70,7 @@ function (_Element) {
66
70
 
67
71
  _classCallCheck(this, Ref);
68
72
 
69
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Ref).call(this, token));
73
+ _this = _super.call(this, token);
70
74
  _this.name = name;
71
75
  _this.onDelete = onDelete;
72
76
  _this.onUpdate = onUpdate;
@@ -92,12 +96,11 @@ function (_Element) {
92
96
  var _this2 = this;
93
97
 
94
98
  rawEndpoints.forEach(function (endpoint) {
95
- _this2.endpoints.push(new _endpoint["default"](_objectSpread({}, endpoint, {
99
+ _this2.endpoints.push(new _endpoint["default"](_objectSpread(_objectSpread({}, endpoint), {}, {
96
100
  ref: _this2
97
101
  })));
98
102
 
99
- if (endpoint.schemaName === _config.DEFAULT_SCHEMA_NAME) {
100
- _this2.database.hasDefaultSchema = true;
103
+ if (endpoint.schemaName === _config.DEFAULT_SCHEMA_NAME) {// this.schema.database.hasDefaultSchema = true;
101
104
  }
102
105
  });
103
106
 
@@ -118,7 +121,7 @@ function (_Element) {
118
121
  }, {
119
122
  key: "export",
120
123
  value: function _export() {
121
- return _objectSpread({}, this.shallowExport(), {}, this.exportChild());
124
+ return _objectSpread(_objectSpread({}, this.shallowExport()), this.exportChild());
122
125
  }
123
126
  }, {
124
127
  key: "shallowExport",
@@ -157,9 +160,9 @@ function (_Element) {
157
160
  }, {
158
161
  key: "normalize",
159
162
  value: function normalize(model) {
160
- model.refs = _objectSpread({}, model.refs, _defineProperty({}, this.id, _objectSpread({
163
+ model.refs = _objectSpread(_objectSpread({}, model.refs), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
161
164
  id: this.id
162
- }, this.shallowExport(), {}, this.exportChildIds(), {}, this.exportParentIds())));
165
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
163
166
  this.endpoints.forEach(function (endpoint) {
164
167
  return endpoint.normalize(model);
165
168
  });
@@ -21,11 +21,11 @@ var _ref2 = _interopRequireDefault(require("./ref"));
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
23
 
24
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
24
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
25
25
 
26
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
27
27
 
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
28
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
29
 
30
30
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
31
 
@@ -35,21 +35,25 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
35
35
 
36
36
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
37
37
 
38
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
+
40
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
+
42
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
43
+
38
44
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
39
45
 
40
46
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
47
 
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
-
44
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
48
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
45
49
 
46
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
50
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
51
 
48
- var Schema =
49
- /*#__PURE__*/
50
- function (_Element) {
52
+ var Schema = /*#__PURE__*/function (_Element) {
51
53
  _inherits(Schema, _Element);
52
54
 
55
+ var _super = _createSuper(Schema);
56
+
53
57
  function Schema() {
54
58
  var _this;
55
59
 
@@ -71,7 +75,7 @@ function (_Element) {
71
75
 
72
76
  _classCallCheck(this, Schema);
73
77
 
74
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Schema).call(this, token));
78
+ _this = _super.call(this, token);
75
79
  _this.tables = [];
76
80
  _this.enums = [];
77
81
  _this.tableGroups = [];
@@ -84,10 +88,10 @@ function (_Element) {
84
88
 
85
89
  _this.generateId();
86
90
 
87
- _this.processTables(tables);
88
-
89
91
  _this.processEnums(enums);
90
92
 
93
+ _this.processTables(tables);
94
+
91
95
  _this.processRefs(refs);
92
96
 
93
97
  _this.processTableGroups(tableGroups);
@@ -106,7 +110,7 @@ function (_Element) {
106
110
  var _this2 = this;
107
111
 
108
112
  rawTables.forEach(function (table) {
109
- _this2.pushTable(new _table["default"](_objectSpread({}, table, {
113
+ _this2.pushTable(new _table["default"](_objectSpread(_objectSpread({}, table), {}, {
110
114
  schema: _this2
111
115
  })));
112
116
  });
@@ -130,7 +134,7 @@ function (_Element) {
130
134
  key: "findTable",
131
135
  value: function findTable(tableName) {
132
136
  return this.tables.find(function (t) {
133
- return t.name === tableName || t.alias === tableName;
137
+ return t.name === tableName;
134
138
  });
135
139
  }
136
140
  }, {
@@ -139,7 +143,7 @@ function (_Element) {
139
143
  var _this3 = this;
140
144
 
141
145
  rawEnums.forEach(function (_enum) {
142
- _this3.pushEnum(new _enum2["default"](_objectSpread({}, _enum, {
146
+ _this3.pushEnum(new _enum2["default"](_objectSpread(_objectSpread({}, _enum), {}, {
143
147
  schema: _this3
144
148
  })));
145
149
  });
@@ -149,7 +153,6 @@ function (_Element) {
149
153
  value: function pushEnum(_enum) {
150
154
  this.checkEnum(_enum);
151
155
  this.enums.push(_enum);
152
- this.bindEnumToField(_enum);
153
156
  }
154
157
  }, {
155
158
  key: "checkEnum",
@@ -160,28 +163,13 @@ function (_Element) {
160
163
  _enum.error("Enum ".concat((0, _utils.shouldPrintSchema)(this) ? "\"".concat(this.name, "\".") : '', "\"").concat(_enum.name, "\" existed"));
161
164
  }
162
165
  }
163
- }, {
164
- key: "bindEnumToField",
165
- value: function bindEnumToField(_enum) {
166
- this.database.schemas.forEach(function (schema) {
167
- schema.tables.forEach(function (table) {
168
- table.fields.forEach(function (field) {
169
- if (_enum.name === field.type.type_name && (field.type.schemaName || _config.DEFAULT_SCHEMA_NAME) === schema.name) {
170
- field._enum = _enum;
171
-
172
- _enum.pushField(field);
173
- }
174
- });
175
- });
176
- });
177
- }
178
166
  }, {
179
167
  key: "processRefs",
180
168
  value: function processRefs(rawRefs) {
181
169
  var _this4 = this;
182
170
 
183
171
  rawRefs.forEach(function (ref) {
184
- _this4.pushRef(new _ref2["default"](_objectSpread({}, ref, {
172
+ _this4.pushRef(new _ref2["default"](_objectSpread(_objectSpread({}, ref), {}, {
185
173
  schema: _this4
186
174
  })));
187
175
  });
@@ -207,7 +195,7 @@ function (_Element) {
207
195
  var _this5 = this;
208
196
 
209
197
  rawTableGroups.forEach(function (tableGroup) {
210
- _this5.pushTableGroup(new _tableGroup["default"](_objectSpread({}, tableGroup, {
198
+ _this5.pushTableGroup(new _tableGroup["default"](_objectSpread(_objectSpread({}, tableGroup), {}, {
211
199
  schema: _this5
212
200
  })));
213
201
  });
@@ -235,7 +223,7 @@ function (_Element) {
235
223
  }, {
236
224
  key: "export",
237
225
  value: function _export() {
238
- return _objectSpread({}, this.shallowExport(), {}, this.exportChild());
226
+ return _objectSpread(_objectSpread({}, this.shallowExport()), this.exportChild());
239
227
  }
240
228
  }, {
241
229
  key: "exportChild",
@@ -292,9 +280,9 @@ function (_Element) {
292
280
  }, {
293
281
  key: "normalize",
294
282
  value: function normalize(model) {
295
- model.schemas = _objectSpread({}, model.schemas, _defineProperty({}, this.id, _objectSpread({
283
+ model.schemas = _objectSpread(_objectSpread({}, model.schemas), {}, _defineProperty({}, this.id, _objectSpread(_objectSpread(_objectSpread({
296
284
  id: this.id
297
- }, this.shallowExport(), {}, this.exportChildIds(), {}, this.exportParentIds())));
285
+ }, this.shallowExport()), this.exportChildIds()), this.exportParentIds())));
298
286
  this.tables.forEach(function (table) {
299
287
  return table.normalize(model);
300
288
  });