@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,102 +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 Endpoint =
31
- /*#__PURE__*/
32
- function (_Element) {
33
- _inherits(Endpoint, _Element);
34
-
35
- function Endpoint(_ref, schema) {
36
- var _this;
37
-
38
- var tableName = _ref.tableName,
39
- fieldName = _ref.fieldName,
40
- relation = _ref.relation,
41
- token = _ref.token;
42
-
43
- _classCallCheck(this, Endpoint);
44
-
45
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Endpoint).call(this, token));
46
- _this.relation = relation;
47
- _this.tableName = tableName;
48
- _this.fieldName = fieldName; // Use name of table and field object
49
- // Name in constructor could be alias
50
-
51
- var table = schema.findTable(tableName);
52
-
53
- _this.setTable(table);
54
-
55
- var field = table.findField(fieldName);
56
-
57
- _this.setField(field);
58
-
59
- return _this;
60
- }
61
-
62
- _createClass(Endpoint, [{
63
- key: "equals",
64
- value: function equals(endpoint) {
65
- return this.tableName === endpoint.tableName && this.fieldName === endpoint.fieldName;
66
- }
67
- }, {
68
- key: "export",
69
- value: function _export() {
70
- return {
71
- tableName: this.tableName,
72
- fieldName: this.fieldName,
73
- relation: this.relation
74
- };
75
- }
76
- }, {
77
- key: "setField",
78
- value: function setField(field) {
79
- if (!field) {
80
- this.error("Can't find field ".concat(this.fieldName, " in table ").concat(this.tableName));
81
- }
82
-
83
- this.field = field;
84
- this.fieldName = field.name;
85
- }
86
- }, {
87
- key: "setTable",
88
- value: function setTable(table) {
89
- if (!table) {
90
- this.error("Can't find table ".concat(this.tableName, " in schema"));
91
- }
92
-
93
- this.table = table;
94
- this.tableName = table.name;
95
- }
96
- }]);
97
-
98
- return Endpoint;
99
- }(_element["default"]);
100
-
101
- var _default = Endpoint;
102
- exports["default"] = _default;
@@ -1,102 +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 _enumValue = _interopRequireDefault(require("./enumValue"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
15
-
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
- 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); } }
19
-
20
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
21
-
22
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23
-
24
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
-
26
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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
- var Enum =
33
- /*#__PURE__*/
34
- function (_Element) {
35
- _inherits(Enum, _Element);
36
-
37
- function Enum() {
38
- var _this;
39
-
40
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
41
- name = _ref.name,
42
- token = _ref.token,
43
- values = _ref.values;
44
-
45
- _classCallCheck(this, Enum);
46
-
47
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Enum).call(this, token));
48
-
49
- if (!name) {
50
- _this.error('Enum must have a name');
51
- }
52
-
53
- _this.name = name;
54
- _this.values = [];
55
-
56
- _this.processValues(values);
57
-
58
- return _this;
59
- }
60
-
61
- _createClass(Enum, [{
62
- key: "processValues",
63
- value: function processValues(rawValues) {
64
- var _this2 = this;
65
-
66
- rawValues.forEach(function (value) {
67
- _this2.pushValue(new _enumValue["default"](value));
68
- });
69
- }
70
- }, {
71
- key: "pushValue",
72
- value: function pushValue(value) {
73
- this.checkValue(value);
74
- this.values.push(value);
75
- value.enumRef = this;
76
- }
77
- }, {
78
- key: "checkValue",
79
- value: function checkValue(value) {
80
- if (this.values.some(function (v) {
81
- return v.name === value.name;
82
- })) {
83
- value.error("Enum value ".concat(value.name, " existed in enum ").concat(this.name));
84
- }
85
- }
86
- }, {
87
- key: "export",
88
- value: function _export() {
89
- return {
90
- name: this.name,
91
- values: this.values.map(function (value) {
92
- return value["export"]();
93
- })
94
- };
95
- }
96
- }]);
97
-
98
- return Enum;
99
- }(_element["default"]);
100
-
101
- var _default = Enum;
102
- exports["default"] = _default;
@@ -1,70 +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 EnumValue =
31
- /*#__PURE__*/
32
- function (_Element) {
33
- _inherits(EnumValue, _Element);
34
-
35
- function EnumValue() {
36
- var _this;
37
-
38
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
39
- name = _ref.name,
40
- token = _ref.token,
41
- note = _ref.note;
42
-
43
- _classCallCheck(this, EnumValue);
44
-
45
- _this = _possibleConstructorReturn(this, _getPrototypeOf(EnumValue).call(this, token));
46
-
47
- if (!name) {
48
- _this.error('Enum value must have a name');
49
- }
50
-
51
- _this.name = name;
52
- _this.note = note;
53
- return _this;
54
- }
55
-
56
- _createClass(EnumValue, [{
57
- key: "export",
58
- value: function _export() {
59
- return {
60
- name: this.name,
61
- note: this.note
62
- };
63
- }
64
- }]);
65
-
66
- return EnumValue;
67
- }(_element["default"]);
68
-
69
- var _default = EnumValue;
70
- exports["default"] = _default;
@@ -1,104 +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 Field =
31
- /*#__PURE__*/
32
- function (_Element) {
33
- _inherits(Field, _Element);
34
-
35
- function Field() {
36
- var _this;
37
-
38
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
39
- name = _ref.name,
40
- type = _ref.type,
41
- unique = _ref.unique,
42
- pk = _ref.pk,
43
- token = _ref.token,
44
- not_null = _ref.not_null,
45
- note = _ref.note,
46
- inline_refs = _ref.inline_refs,
47
- dbdefault = _ref.dbdefault,
48
- increment = _ref.increment;
49
-
50
- _classCallCheck(this, Field);
51
-
52
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Field).call(this, token));
53
-
54
- if (!name) {
55
- _this.error('Field must have a name');
56
- }
57
-
58
- if (!type) {
59
- _this.error('Field must have a type');
60
- }
61
-
62
- _this.name = name; // type : { type_name, value }
63
-
64
- _this.type = type;
65
- _this.unique = unique;
66
- _this.pk = pk;
67
- _this.isConnected = false;
68
- _this.not_null = not_null;
69
- _this.note = note;
70
- _this.inline_refs = inline_refs;
71
- _this.dbdefault = dbdefault;
72
- _this.increment = increment; // this.settings = settings; // debugging purpose
73
- // this.enumRef = null;
74
-
75
- return _this;
76
- }
77
-
78
- _createClass(Field, [{
79
- key: "connect",
80
- value: function connect() {
81
- this.isConnected = true;
82
- }
83
- }, {
84
- key: "export",
85
- value: function _export() {
86
- return {
87
- name: this.name,
88
- type: this.type,
89
- unique: this.unique,
90
- pk: this.pk,
91
- not_null: this.not_null,
92
- note: this.note,
93
- dbdefault: this.dbdefault,
94
- increment: this.increment // settings: this.settings, // debugging purpose
95
-
96
- };
97
- }
98
- }]);
99
-
100
- return Field;
101
- }(_element["default"]);
102
-
103
- var _default = Field;
104
- exports["default"] = _default;
@@ -1,74 +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 Index =
31
- /*#__PURE__*/
32
- function (_Element) {
33
- _inherits(Index, _Element);
34
-
35
- function Index() {
36
- var _this;
37
-
38
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
39
- columns = _ref.columns,
40
- type = _ref.type,
41
- unique = _ref.unique,
42
- pk = _ref.pk,
43
- token = _ref.token,
44
- name = _ref.name;
45
-
46
- _classCallCheck(this, Index);
47
-
48
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Index).call(this, token));
49
- _this.columns = columns;
50
- _this.name = name;
51
- _this.type = type;
52
- _this.unique = unique;
53
- _this.pk = pk;
54
- return _this;
55
- }
56
-
57
- _createClass(Index, [{
58
- key: "export",
59
- value: function _export() {
60
- return {
61
- name: this.name,
62
- columns: this.columns,
63
- type: this.type,
64
- unique: this.unique,
65
- pk: this.pk
66
- };
67
- }
68
- }]);
69
-
70
- return Index;
71
- }(_element["default"]);
72
-
73
- var _default = Index;
74
- exports["default"] = _default;
package/lib/schema/ref.js DELETED
@@ -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
- /**
31
- * Compare two pairs of objects
32
- * @param {Array} pair1
33
- * @param {Array} pair2
34
- * @returns {Boolean}
35
- */
36
- function isEqualPair(pair1, pair2) {
37
- return pair1[0].equals(pair2[0]) && pair1[1].equals(pair2[1]);
38
- }
39
-
40
- var Ref =
41
- /*#__PURE__*/
42
- function (_Element) {
43
- _inherits(Ref, _Element);
44
-
45
- function Ref() {
46
- var _this;
47
-
48
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
49
- name = _ref.name,
50
- endpoints = _ref.endpoints,
51
- token = _ref.token,
52
- onUpdate = _ref.onUpdate,
53
- onDelete = _ref.onDelete;
54
-
55
- _classCallCheck(this, Ref);
56
-
57
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Ref).call(this, token));
58
- _this.name = name;
59
- _this.endpoints = endpoints;
60
- _this.onUpdate = onUpdate;
61
- _this.onDelete = onDelete;
62
-
63
- if (_this.endpoints[0].equals(_this.endpoints[1])) {
64
- _this.error('Two endpoints are the same');
65
- }
66
-
67
- return _this;
68
- }
69
-
70
- _createClass(Ref, [{
71
- key: "equals",
72
- value: function equals(ref) {
73
- return isEqualPair(this.endpoints, ref.endpoints) || isEqualPair(this.endpoints, ref.endpoints.slice().reverse());
74
- }
75
- }, {
76
- key: "export",
77
- value: function _export() {
78
- return {
79
- name: this.name,
80
- endpoints: this.endpoints.map(function (e) {
81
- return e["export"]();
82
- }),
83
- onUpdate: this.onUpdate,
84
- onDelete: this.onDelete
85
- };
86
- }
87
- }]);
88
-
89
- return Ref;
90
- }(_element["default"]);
91
-
92
- var _default = Ref;
93
- exports["default"] = _default;