@dbml/core 2.2.0 → 2.4.0

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 (93) hide show
  1. package/lib/export/DbmlExporter.js +15 -4
  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 +0 -1
  28. package/lib/parse/mssql/statements/actions.js +9 -6
  29. package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +11 -5
  30. package/lib/parse/mssql/statements/statement_types/create_index/actions.js +6 -1
  31. package/lib/parse/mssql/statements/statement_types/create_table/actions.js +12 -10
  32. package/lib/parse/mssql/utils.js +16 -1
  33. package/lib/parse/mysql/parser.pegjs +57 -34
  34. package/lib/parse/mysqlParser.js +270 -218
  35. package/lib/parse/postgresParser.js +12 -10
  36. package/lib/parse/postgresql/Base_rules.pegjs +45 -10
  37. package/lib/parse/postgresql/Commands/Alter_table/Alter_table.pegjs +2 -1
  38. package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +5 -3
  39. package/lib/parse/postgresql/Commands/Create_table/Create_table_of.pegjs +1 -1
  40. package/lib/parse/postgresql/Commands/Create_table/Create_table_partition_of.pegjs +1 -1
  41. package/lib/parse/postgresql/Commands/Create_type/Create_type_enum.pegjs +2 -2
  42. package/lib/parse/postgresql/InitializerUtils.pegjs +10 -0
  43. package/lib/parse/postgresql/parser.pegjs +2 -1
  44. package/lib/parse/schemarbParser.js +3 -3
  45. package/package.json +5 -3
  46. package/types/export/ModelExporter.d.ts +5 -0
  47. package/types/export/index.d.ts +5 -0
  48. package/types/import/index.d.ts +5 -0
  49. package/types/index.d.ts +5 -0
  50. package/types/model_structure/database.d.ts +195 -0
  51. package/types/model_structure/dbState.d.ts +14 -0
  52. package/types/model_structure/element.d.ts +21 -0
  53. package/types/model_structure/endpoint.d.ts +55 -0
  54. package/types/model_structure/enum.d.ts +67 -0
  55. package/types/model_structure/enumValue.d.ts +39 -0
  56. package/types/model_structure/field.d.ts +77 -0
  57. package/types/model_structure/indexColumn.d.ts +37 -0
  58. package/types/model_structure/indexes.d.ts +74 -0
  59. package/types/model_structure/ref.d.ts +66 -0
  60. package/types/model_structure/schema.d.ts +188 -0
  61. package/types/model_structure/table.d.ts +118 -0
  62. package/types/model_structure/tableGroup.d.ts +54 -0
  63. package/types/parse/Parser.d.ts +11 -0
  64. package/lib/export/Exporter.js +0 -80
  65. package/lib/export/SchemaExporter.js +0 -99
  66. package/lib/parse/dbml/multiline_content.txt +0 -7
  67. package/lib/parse/dbml/multiline_string.pegjs +0 -17
  68. package/lib/parse/dbml/parser1.json +0 -219
  69. package/lib/parse/dbml/parser1.pegjs +0 -702
  70. package/lib/parse/dbml/parser1_content.txt +0 -29
  71. package/lib/parse/dbml/test_multiline.js +0 -53
  72. package/lib/parse/dbml/test_parser1.js +0 -16
  73. package/lib/parse/mssql/base_utils.js +0 -28
  74. package/lib/parse/mssql/composite_parsers.js +0 -109
  75. package/lib/parse/mssql/statement_types/alter_table/actions.js +0 -29
  76. package/lib/parse/mssql/statement_types/alter_table/add/actions.js +0 -8
  77. package/lib/parse/mssql/statement_types/alter_table/add/index.js +0 -58
  78. package/lib/parse/mssql/statement_types/alter_table/index.js +0 -32
  79. package/lib/parse/mssql/statement_types/create_index/actions.js +0 -25
  80. package/lib/parse/mssql/statement_types/create_index/index.js +0 -50
  81. package/lib/parse/mssql/statement_types/create_table/actions.js +0 -95
  82. package/lib/parse/mssql/statement_types/create_table/index.js +0 -50
  83. package/lib/parse/mssql/statement_types/index.js +0 -13
  84. package/lib/schema/element.js +0 -84
  85. package/lib/schema/endpoint.js +0 -102
  86. package/lib/schema/enum.js +0 -102
  87. package/lib/schema/enumValue.js +0 -70
  88. package/lib/schema/field.js +0 -104
  89. package/lib/schema/indexes.js +0 -74
  90. package/lib/schema/ref.js +0 -93
  91. package/lib/schema/schema.js +0 -245
  92. package/lib/schema/table.js +0 -163
  93. package/lib/schema/tableGroup.js +0 -93
@@ -1,245 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
- var _endpoint = _interopRequireDefault(require("./endpoint"));
11
-
12
- var _ref2 = _interopRequireDefault(require("./ref"));
13
-
14
- var _table = _interopRequireDefault(require("./table"));
15
-
16
- var _enum2 = _interopRequireDefault(require("./enum"));
17
-
18
- var _tableGroup = _interopRequireDefault(require("./tableGroup"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
23
-
24
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
25
-
26
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
27
-
28
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
29
-
30
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
-
32
- 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, descriptor.key, descriptor); } }
33
-
34
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
35
-
36
- var Schema =
37
- /*#__PURE__*/
38
- function () {
39
- function Schema() {
40
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
41
- _ref$tables = _ref.tables,
42
- tables = _ref$tables === void 0 ? [] : _ref$tables,
43
- _ref$enums = _ref.enums,
44
- enums = _ref$enums === void 0 ? [] : _ref$enums,
45
- _ref$refs = _ref.refs,
46
- refs = _ref$refs === void 0 ? [] : _ref$refs,
47
- _ref$tableGroups = _ref.tableGroups,
48
- tableGroups = _ref$tableGroups === void 0 ? [] : _ref$tableGroups;
49
-
50
- _classCallCheck(this, Schema);
51
-
52
- this.refs = [];
53
- this.tables = [];
54
- this.enums = [];
55
- this.tableGroups = []; // The process order is important. Do not change !
56
-
57
- this.processTables(tables);
58
- this.processRefs(refs);
59
- this.processEnums(enums);
60
- this.processTableGroups(tableGroups);
61
- }
62
-
63
- _createClass(Schema, [{
64
- key: "processTables",
65
- value: function processTables(rawTables) {
66
- var _this = this;
67
-
68
- rawTables.forEach(function (table) {
69
- _this.pushTable(new _table["default"](table));
70
- });
71
- }
72
- }, {
73
- key: "processRefs",
74
- value: function processRefs(rawRefs) {
75
- var _this2 = this;
76
-
77
- rawRefs.forEach(function (r) {
78
- var ref = {
79
- name: r.name,
80
- token: r.token,
81
- endpoints: r.endpoints.map(function (e) {
82
- return new _endpoint["default"](e, _this2);
83
- }),
84
- onUpdate: r.onUpdate,
85
- onDelete: r.onDelete
86
- };
87
-
88
- _this2.pushRef(new _ref2["default"](ref));
89
- });
90
- }
91
- }, {
92
- key: "processEnums",
93
- value: function processEnums(rawEnums) {
94
- var _this3 = this;
95
-
96
- rawEnums.forEach(function (_enum) {
97
- _this3.pushEnum(new _enum2["default"](_enum));
98
- });
99
- this.bindEnumRefToFields();
100
- }
101
- }, {
102
- key: "processTableGroups",
103
- value: function processTableGroups(rawTableGroups) {
104
- var _this4 = this;
105
-
106
- rawTableGroups.forEach(function (tableGroup) {
107
- _this4.pushTableGroup(new _tableGroup["default"](tableGroup));
108
- });
109
- }
110
- }, {
111
- key: "bindEnumRefToFields",
112
- value: function bindEnumRefToFields() {
113
- var _this5 = this;
114
-
115
- var keywordString = "by|bool|boolean|bit|blob|decimal|double|enum|float|long\n |longblob|longtext|medium|mediumblob|mediumint|mediumtext|time|timestamp|tinyblob\n |tinyint|tinytext|text|bigint|int|int1|int2|int3|int4|int8|integer|float|float4\n |float8|double|char|varbinary|varchar|varcharacter|precision|date|datetime|year\n |unsigned|signed|numeric|ucase|lcase|mid|len|round|rank|now|format|coalesce|ifnull|isnull|nvl";
116
- var keywords = keywordString.split('|');
117
- this.tables.forEach(function (table) {
118
- table.fields.forEach(function (field) {
119
- if (!keywords.some(function (e) {
120
- return e === field.type;
121
- })) {
122
- var _enum = _lodash["default"].find(_this5.enums, function (e) {
123
- return e.name === field.type.type_name;
124
- });
125
-
126
- if (_enum) {
127
- field.enumRef = _enum;
128
- }
129
- }
130
- });
131
- });
132
- }
133
- }, {
134
- key: "pushTable",
135
- value: function pushTable(table) {
136
- this.checkTable(table);
137
- this.tables.push(table);
138
- }
139
- }, {
140
- key: "pushEnum",
141
- value: function pushEnum(_enum) {
142
- this.checkEnum(_enum);
143
- this.enums.push(_enum);
144
- }
145
- }, {
146
- key: "pushRef",
147
- value: function pushRef(ref) {
148
- this.checkRef(ref);
149
- this.refs.push(ref);
150
- ref.endpoints.forEach(function (endpoint) {
151
- endpoint.table.pushRef(ref);
152
- endpoint.field.connect();
153
- });
154
- }
155
- }, {
156
- key: "pushTableGroup",
157
- value: function pushTableGroup(tableGroup) {
158
- this.checkTableGroup(tableGroup);
159
- tableGroup.processTableNames(this);
160
- this.tableGroups.push(tableGroup);
161
- }
162
- }, {
163
- key: "checkEnum",
164
- value: function checkEnum(_enum) {
165
- if (this.enums.some(function (e) {
166
- return e.name === _enum.name;
167
- })) {
168
- _enum.error("Enum ".concat(_enum.name, " existed"));
169
- }
170
- }
171
- }, {
172
- key: "checkTable",
173
- value: function checkTable(table) {
174
- if (this.tables.some(function (t) {
175
- return t.name === table.name;
176
- })) {
177
- table.error("Table ".concat(table.name, " existed"));
178
- }
179
- }
180
- }, {
181
- key: "checkRef",
182
- value: function checkRef(ref) {
183
- if (this.refs.some(function (r) {
184
- return r.equals(ref);
185
- })) {
186
- ref.error('Reference with same endpoints existed');
187
- }
188
- }
189
- }, {
190
- key: "checkTableGroup",
191
- value: function checkTableGroup(tableGroup) {
192
- if (this.tableGroups.some(function (tg) {
193
- return tg.name === tableGroup.name;
194
- })) {
195
- tableGroup.error("Table Group named ".concat(tableGroup.name, " existed"));
196
- }
197
- }
198
- }, {
199
- key: "findTable",
200
- value: function findTable(tableName) {
201
- return this.tables.find(function (t) {
202
- return t.name === tableName || t.alias === tableName;
203
- });
204
- }
205
- }, {
206
- key: "export",
207
- value: function _export() {
208
- return {
209
- tables: this.tables.map(function (t) {
210
- return t["export"]();
211
- }),
212
- refs: this.refs.map(function (r) {
213
- return r["export"]();
214
- }),
215
- enums: this.enums.map(function (_enum) {
216
- return _enum["export"]();
217
- })
218
- };
219
- }
220
- }, {
221
- key: "update",
222
- value: function update() {
223
- var _this$tables, _this$refs, _this$enums;
224
-
225
- var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
226
- var _schema$tables = schema.tables,
227
- tables = _schema$tables === void 0 ? [] : _schema$tables,
228
- _schema$refs = schema.refs,
229
- refs = _schema$refs === void 0 ? [] : _schema$refs,
230
- _schema$enums = schema.enums,
231
- enums = _schema$enums === void 0 ? [] : _schema$enums;
232
-
233
- (_this$tables = this.tables).splice.apply(_this$tables, [0, this.tables.length].concat(_toConsumableArray(tables)));
234
-
235
- (_this$refs = this.refs).splice.apply(_this$refs, [0, this.refs.length].concat(_toConsumableArray(refs)));
236
-
237
- (_this$enums = this.enums).splice.apply(_this$enums, [0, this.enums.length].concat(_toConsumableArray(enums)));
238
- }
239
- }]);
240
-
241
- return Schema;
242
- }();
243
-
244
- var _default = Schema;
245
- exports["default"] = _default;
@@ -1,163 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _element = _interopRequireDefault(require("./element"));
9
-
10
- var _field = _interopRequireDefault(require("./field"));
11
-
12
- var _indexes = _interopRequireDefault(require("./indexes"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
17
-
18
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
-
20
- 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, descriptor.key, descriptor); } }
21
-
22
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
23
-
24
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
25
-
26
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
27
-
28
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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
- var Table =
35
- /*#__PURE__*/
36
- function (_Element) {
37
- _inherits(Table, _Element);
38
-
39
- function Table() {
40
- var _this;
41
-
42
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
43
- name = _ref.name,
44
- alias = _ref.alias,
45
- _ref$fields = _ref.fields,
46
- fields = _ref$fields === void 0 ? [] : _ref$fields,
47
- token = _ref.token,
48
- _ref$indexes = _ref.indexes,
49
- indexes = _ref$indexes === void 0 ? [] : _ref$indexes,
50
- headerColor = _ref.headerColor;
51
-
52
- _classCallCheck(this, Table);
53
-
54
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Table).call(this, token));
55
- _this.name = name;
56
- _this.alias = alias;
57
- _this.headerColor = headerColor;
58
- _this.fields = [];
59
- _this.indexes = []; // Connected ref
60
-
61
- _this.refs = [];
62
-
63
- _this.processFields(fields);
64
-
65
- _this.processIndexes(indexes);
66
-
67
- return _this;
68
- }
69
-
70
- _createClass(Table, [{
71
- key: "processFields",
72
- value: function processFields(rawFields) {
73
- var _this2 = this;
74
-
75
- if (rawFields.length === 0) {
76
- this.error('Table must have at least one field');
77
- }
78
-
79
- rawFields.forEach(function (field) {
80
- _this2.pushField(new _field["default"](field));
81
- });
82
- }
83
- }, {
84
- key: "processIndexes",
85
- value: function processIndexes(rawIndexes) {
86
- var _this3 = this;
87
-
88
- rawIndexes.forEach(function (index) {
89
- _this3.pushIndex(new _indexes["default"](index));
90
- });
91
- }
92
- }, {
93
- key: "pushField",
94
- value: function pushField(field) {
95
- this.checkField(field);
96
- this.fields.push(field);
97
- field.table = this;
98
- }
99
- }, {
100
- key: "checkField",
101
- value: function checkField(field) {
102
- if (this.fields.some(function (f) {
103
- return f.name === field.name;
104
- })) {
105
- field.error("Field ".concat(field.name, " existed in table ").concat(this.name));
106
- }
107
- }
108
- }, {
109
- key: "pushIndex",
110
- value: function pushIndex(index) {
111
- this.checkIndex(index);
112
- this.indexes.push(index);
113
- index.table = this;
114
- }
115
- }, {
116
- key: "checkIndex",
117
- value: function checkIndex(index) {
118
- var _this4 = this;
119
-
120
- index.columns.forEach(function (column) {
121
- if (column.type === 'column' && !_this4.findField(column.value)) {
122
- index.error("Column ".concat(column.value, " do not exist in table ").concat(_this4.name));
123
- }
124
- });
125
- }
126
- }, {
127
- key: "findField",
128
- value: function findField(fieldName) {
129
- return this.fields.find(function (f) {
130
- return f.name === fieldName;
131
- });
132
- }
133
- }, {
134
- key: "pushRef",
135
- value: function pushRef(ref) {
136
- this.refs.push(ref);
137
- }
138
- }, {
139
- key: "checkSameId",
140
- value: function checkSameId(table) {
141
- return this.name === table.name || this.alias === table.name || this.name === table.alias || this.alias && this.alias === table.alias;
142
- }
143
- }, {
144
- key: "export",
145
- value: function _export() {
146
- return {
147
- name: this.name,
148
- alias: this.alias,
149
- fields: this.fields.map(function (f) {
150
- return f["export"]();
151
- }),
152
- indexes: this.indexes.map(function (f) {
153
- return f["export"]();
154
- })
155
- };
156
- }
157
- }]);
158
-
159
- return Table;
160
- }(_element["default"]);
161
-
162
- var _default = Table;
163
- exports["default"] = _default;
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _element = _interopRequireDefault(require("./element"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
13
-
14
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
-
16
- 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, descriptor.key, descriptor); } }
17
-
18
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19
-
20
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
21
-
22
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23
-
24
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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
- var TableGroup =
31
- /*#__PURE__*/
32
- function (_Element) {
33
- _inherits(TableGroup, _Element);
34
-
35
- function TableGroup(_ref) {
36
- var _this;
37
-
38
- var name = _ref.name,
39
- token = _ref.token,
40
- _ref$tableNames = _ref.tableNames,
41
- tableNames = _ref$tableNames === void 0 ? [] : _ref$tableNames;
42
-
43
- _classCallCheck(this, TableGroup);
44
-
45
- _this = _possibleConstructorReturn(this, _getPrototypeOf(TableGroup).call(this, token));
46
- _this.name = name;
47
- _this.tableNames = tableNames;
48
- _this.tables = [];
49
- return _this;
50
- }
51
-
52
- _createClass(TableGroup, [{
53
- key: "pushTable",
54
- value: function pushTable(table) {
55
- this.checkNewTable(table);
56
- this.tables.push(table);
57
- table.group = this;
58
- }
59
- }, {
60
- key: "checkNewTable",
61
- value: function checkNewTable(table) {
62
- if (this.tables.some(function (t) {
63
- return t.checkSameId(table);
64
- })) {
65
- this.error("Table ".concat(table.name, " is already in the group"));
66
- }
67
-
68
- if (table.group) {
69
- this.error("Table ".concat(table.name, " is already in a group"));
70
- }
71
- }
72
- }, {
73
- key: "processTableNames",
74
- value: function processTableNames(schema) {
75
- var _this2 = this;
76
-
77
- this.tableNames.forEach(function (tn) {
78
- var table = schema.findTable(tn);
79
-
80
- if (!table) {
81
- _this2.error("Table ".concat(tn, " don't exist"));
82
- }
83
-
84
- _this2.pushTable(table);
85
- });
86
- }
87
- }]);
88
-
89
- return TableGroup;
90
- }(_element["default"]);
91
-
92
- var _default = TableGroup;
93
- exports["default"] = _default;