@dbml/core 2.5.1 → 2.5.3

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 (63) hide show
  1. package/lib/export/DbmlExporter.js +9 -64
  2. package/lib/export/JsonExporter.js +5 -11
  3. package/lib/export/ModelExporter.js +5 -22
  4. package/lib/export/MysqlExporter.js +10 -71
  5. package/lib/export/PostgresExporter.js +11 -80
  6. package/lib/export/SqlServerExporter.js +10 -71
  7. package/lib/export/index.js +0 -6
  8. package/lib/export/utils.js +2 -12
  9. package/lib/import/index.js +0 -7
  10. package/lib/index.js +4 -9
  11. package/lib/model_structure/config.js +1 -1
  12. package/lib/model_structure/database.js +32 -83
  13. package/lib/model_structure/dbState.js +5 -10
  14. package/lib/model_structure/element.js +13 -38
  15. package/lib/model_structure/endpoint.js +22 -68
  16. package/lib/model_structure/enum.js +18 -49
  17. package/lib/model_structure/enumValue.js +17 -44
  18. package/lib/model_structure/field.js +26 -62
  19. package/lib/model_structure/indexColumn.js +15 -40
  20. package/lib/model_structure/indexes.js +22 -50
  21. package/lib/model_structure/ref.js +24 -56
  22. package/lib/model_structure/schema.js +27 -65
  23. package/lib/model_structure/table.js +24 -59
  24. package/lib/model_structure/tableGroup.js +18 -49
  25. package/lib/model_structure/utils.js +0 -3
  26. package/lib/parse/Parser.js +5 -27
  27. package/lib/parse/buildParser.js +11 -23
  28. package/lib/parse/dbmlParser.js +863 -2131
  29. package/lib/parse/mssql/base_parsers.js +2 -11
  30. package/lib/parse/mssql/column_definition/actions.js +0 -3
  31. package/lib/parse/mssql/column_definition/index.js +9 -17
  32. package/lib/parse/mssql/constraint_definition/actions.js +6 -12
  33. package/lib/parse/mssql/constraint_definition/index.js +10 -18
  34. package/lib/parse/mssql/expression.js +6 -16
  35. package/lib/parse/mssql/fk_definition/actions.js +1 -12
  36. package/lib/parse/mssql/fk_definition/index.js +5 -10
  37. package/lib/parse/mssql/index.js +2 -4
  38. package/lib/parse/mssql/index_definition/actions.js +0 -6
  39. package/lib/parse/mssql/index_definition/index.js +8 -13
  40. package/lib/parse/mssql/keyword_parsers.js +2 -3
  41. package/lib/parse/mssql/keyword_utils.js +0 -4
  42. package/lib/parse/mssql/statements/actions.js +0 -24
  43. package/lib/parse/mssql/statements/index.js +1 -7
  44. package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +3 -10
  45. package/lib/parse/mssql/statements/statement_types/alter_table/add/actions.js +2 -6
  46. package/lib/parse/mssql/statements/statement_types/alter_table/add/index.js +9 -18
  47. package/lib/parse/mssql/statements/statement_types/alter_table/index.js +2 -7
  48. package/lib/parse/mssql/statements/statement_types/comments/actions.js +3 -11
  49. package/lib/parse/mssql/statements/statement_types/comments/index.js +3 -13
  50. package/lib/parse/mssql/statements/statement_types/create_index/actions.js +1 -3
  51. package/lib/parse/mssql/statements/statement_types/create_index/index.js +9 -15
  52. package/lib/parse/mssql/statements/statement_types/create_table/actions.js +7 -18
  53. package/lib/parse/mssql/statements/statement_types/create_table/index.js +8 -16
  54. package/lib/parse/mssql/statements/statement_types/index.js +0 -4
  55. package/lib/parse/mssql/utils.js +4 -14
  56. package/lib/parse/mssql/whitespaces.js +0 -1
  57. package/lib/parse/mssqlParser.js +0 -3
  58. package/lib/parse/mysqlParser.js +822 -2395
  59. package/lib/parse/postgresParser.js +3 -3
  60. package/lib/parse/postgresql/get_parser.js +6 -9
  61. package/lib/parse/schemarbParser.js +219 -714
  62. package/package.json +10 -11
  63. package/types/.DS_Store +0 -0
@@ -1,109 +1,74 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports["default"] = void 0;
7
-
8
8
  var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
9
  var _schema = _interopRequireDefault(require("./schema"));
11
-
12
10
  var _ref2 = _interopRequireDefault(require("./ref"));
13
-
14
11
  var _enum2 = _interopRequireDefault(require("./enum"));
15
-
16
12
  var _tableGroup = _interopRequireDefault(require("./tableGroup"));
17
-
18
13
  var _table = _interopRequireDefault(require("./table"));
19
-
20
14
  var _element = _interopRequireDefault(require("./element"));
21
-
22
15
  var _config = require("./config");
23
-
24
16
  var _dbState = _interopRequireDefault(require("./dbState"));
25
-
26
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
-
28
- 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); }
29
-
30
- 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; }
31
-
32
- 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; }
33
-
34
- 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; }
35
-
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
36
21
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
-
38
- 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); } }
39
-
40
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
41
-
42
- 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); }
43
-
44
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
45
-
22
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
23
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
24
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
25
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
46
28
  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); }; }
47
-
48
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
49
-
29
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
50
30
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
51
-
52
- 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; } }
53
-
54
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
55
-
31
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
32
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
56
33
  var Database = /*#__PURE__*/function (_Element) {
57
34
  _inherits(Database, _Element);
58
-
59
35
  var _super = _createSuper(Database);
60
-
61
36
  function Database(_ref) {
62
37
  var _this;
63
-
64
38
  var _ref$schemas = _ref.schemas,
65
- schemas = _ref$schemas === void 0 ? [] : _ref$schemas,
66
- _ref$tables = _ref.tables,
67
- tables = _ref$tables === void 0 ? [] : _ref$tables,
68
- _ref$enums = _ref.enums,
69
- enums = _ref$enums === void 0 ? [] : _ref$enums,
70
- _ref$refs = _ref.refs,
71
- refs = _ref$refs === void 0 ? [] : _ref$refs,
72
- _ref$tableGroups = _ref.tableGroups,
73
- tableGroups = _ref$tableGroups === void 0 ? [] : _ref$tableGroups,
74
- _ref$project = _ref.project,
75
- project = _ref$project === void 0 ? {} : _ref$project,
76
- _ref$aliases = _ref.aliases,
77
- aliases = _ref$aliases === void 0 ? [] : _ref$aliases;
78
-
39
+ schemas = _ref$schemas === void 0 ? [] : _ref$schemas,
40
+ _ref$tables = _ref.tables,
41
+ tables = _ref$tables === void 0 ? [] : _ref$tables,
42
+ _ref$enums = _ref.enums,
43
+ enums = _ref$enums === void 0 ? [] : _ref$enums,
44
+ _ref$refs = _ref.refs,
45
+ refs = _ref$refs === void 0 ? [] : _ref$refs,
46
+ _ref$tableGroups = _ref.tableGroups,
47
+ tableGroups = _ref$tableGroups === void 0 ? [] : _ref$tableGroups,
48
+ _ref$project = _ref.project,
49
+ project = _ref$project === void 0 ? {} : _ref$project,
50
+ _ref$aliases = _ref.aliases,
51
+ aliases = _ref$aliases === void 0 ? [] : _ref$aliases;
79
52
  _classCallCheck(this, Database);
80
-
81
53
  _this = _super.call(this);
82
54
  _this.dbState = new _dbState["default"]();
83
-
84
55
  _this.generateId();
85
-
86
56
  _this.hasDefaultSchema = false;
87
57
  _this.schemas = [];
88
58
  _this.note = project.note ? project.note.value : null;
89
59
  _this.noteToken = project.note ? project.note.token : null;
90
60
  _this.databaseType = project.database_type;
91
61
  _this.name = project.name;
92
- _this.aliases = aliases; // The process order is important. Do not change !
62
+ _this.aliases = aliases;
93
63
 
64
+ // The process order is important. Do not change !
94
65
  _this.processSchemas(schemas);
95
-
96
66
  _this.processSchemaElements(enums, _config.ENUM);
97
-
98
67
  _this.processSchemaElements(tables, _config.TABLE);
99
-
100
68
  _this.processSchemaElements(refs, _config.REF);
101
-
102
69
  _this.processSchemaElements(tableGroups, _config.TABLE_GROUP);
103
-
104
70
  return _this;
105
71
  }
106
-
107
72
  _createClass(Database, [{
108
73
  key: "generateId",
109
74
  value: function generateId() {
@@ -113,7 +78,6 @@ var Database = /*#__PURE__*/function (_Element) {
113
78
  key: "processSchemas",
114
79
  value: function processSchemas(rawSchemas) {
115
80
  var _this2 = this;
116
-
117
81
  rawSchemas.forEach(function (schema) {
118
82
  _this2.pushSchema(new _schema["default"](_objectSpread(_objectSpread({}, schema), {}, {
119
83
  database: _this2
@@ -139,43 +103,37 @@ var Database = /*#__PURE__*/function (_Element) {
139
103
  key: "processSchemaElements",
140
104
  value: function processSchemaElements(elements, elementType) {
141
105
  var _this3 = this;
142
-
143
106
  var schema;
144
107
  elements.forEach(function (element) {
145
108
  if (element.schemaName) {
146
109
  schema = _this3.findOrCreateSchema(element.schemaName);
147
-
148
- if (element.schemaName === _config.DEFAULT_SCHEMA_NAME) {// this.hasDefaultSchema = true;
110
+ if (element.schemaName === _config.DEFAULT_SCHEMA_NAME) {
111
+ // this.hasDefaultSchema = true;
149
112
  }
150
113
  } else {
151
114
  schema = _this3.findOrCreateSchema(_config.DEFAULT_SCHEMA_NAME);
152
115
  }
153
-
154
116
  switch (elementType) {
155
117
  case _config.TABLE:
156
118
  schema.pushTable(new _table["default"](_objectSpread(_objectSpread({}, element), {}, {
157
119
  schema: schema
158
120
  })));
159
121
  break;
160
-
161
122
  case _config.ENUM:
162
123
  schema.pushEnum(new _enum2["default"](_objectSpread(_objectSpread({}, element), {}, {
163
124
  schema: schema
164
125
  })));
165
126
  break;
166
-
167
127
  case _config.TABLE_GROUP:
168
128
  schema.pushTableGroup(new _tableGroup["default"](_objectSpread(_objectSpread({}, element), {}, {
169
129
  schema: schema
170
130
  })));
171
131
  break;
172
-
173
132
  case _config.REF:
174
133
  schema.pushRef(new _ref2["default"](_objectSpread(_objectSpread({}, element), {}, {
175
134
  schema: schema
176
135
  })));
177
136
  break;
178
-
179
137
  default:
180
138
  break;
181
139
  }
@@ -186,8 +144,8 @@ var Database = /*#__PURE__*/function (_Element) {
186
144
  value: function findOrCreateSchema(schemaName) {
187
145
  var schema = this.schemas.find(function (s) {
188
146
  return s.name === schemaName || s.alias === schemaName;
189
- }); // create new schema if schema not found
190
-
147
+ });
148
+ // create new schema if schema not found
191
149
  if (!schema) {
192
150
  schema = new _schema["default"]({
193
151
  name: schemaName,
@@ -198,7 +156,6 @@ var Database = /*#__PURE__*/function (_Element) {
198
156
  });
199
157
  this.pushSchema(schema);
200
158
  }
201
-
202
159
  return schema;
203
160
  }
204
161
  }, {
@@ -223,18 +180,14 @@ var Database = /*#__PURE__*/function (_Element) {
223
180
  key: "findTable",
224
181
  value: function findTable(schemaName, tableName) {
225
182
  var table = null;
226
-
227
183
  if (!schemaName) {
228
184
  table = this.findTableAlias(tableName);
229
185
  if (table) return table;
230
186
  }
231
-
232
187
  var schema = this.findOrCreateSchema(schemaName || _config.DEFAULT_SCHEMA_NAME);
233
-
234
188
  if (!schema) {
235
189
  this.error("Schema ".concat(schemaName || _config.DEFAULT_SCHEMA_NAME, " don't exist"));
236
190
  }
237
-
238
191
  return schema.findTable(tableName);
239
192
  }
240
193
  }, {
@@ -244,11 +197,9 @@ var Database = /*#__PURE__*/function (_Element) {
244
197
  return s.name === schemaName || s.alias === schemaName;
245
198
  });
246
199
  if (!schema) return null;
247
-
248
200
  var _enum = schema.enums.find(function (e) {
249
201
  return e.name === name;
250
202
  });
251
-
252
203
  return _enum;
253
204
  }
254
205
  }, {
@@ -308,9 +259,7 @@ var Database = /*#__PURE__*/function (_Element) {
308
259
  return normalizedModel;
309
260
  }
310
261
  }]);
311
-
312
262
  return Database;
313
263
  }(_element["default"]);
314
-
315
264
  var _default = Database;
316
265
  exports["default"] = _default;
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
-
7
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
8
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
-
10
- 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); } }
11
-
12
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13
-
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
13
  var DbState = /*#__PURE__*/function () {
15
14
  function DbState() {
16
15
  _classCallCheck(this, DbState);
17
-
18
16
  this.dbId = 1;
19
17
  this.schemaId = 1;
20
18
  this.enumId = 1;
@@ -27,7 +25,6 @@ var DbState = /*#__PURE__*/function () {
27
25
  this.fieldId = 1;
28
26
  this.indexColumnId = 1;
29
27
  }
30
-
31
28
  _createClass(DbState, [{
32
29
  key: "generateId",
33
30
  value: function generateId(el) {
@@ -36,8 +33,6 @@ var DbState = /*#__PURE__*/function () {
36
33
  return id;
37
34
  }
38
35
  }]);
39
-
40
36
  return DbState;
41
37
  }();
42
-
43
38
  exports["default"] = DbState;
@@ -1,71 +1,49 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.default = void 0;
7
-
8
- 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); } }
9
-
10
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11
-
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
-
7
+ exports["default"] = void 0;
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
12
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
-
16
- 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); }
17
-
13
+ 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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
18
14
  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); }; }
19
-
20
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
21
-
15
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
22
16
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
23
-
24
17
  function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
25
-
26
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
27
-
28
- 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; } }
29
-
18
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
19
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
30
20
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
-
21
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
36
23
  /* eslint-disable */
37
24
  var ElementError = /*#__PURE__*/function (_Error) {
38
25
  _inherits(ElementError, _Error);
39
-
40
26
  var _super = _createSuper(ElementError);
41
-
42
27
  function ElementError(message) {
43
28
  var _this;
44
-
45
29
  var location = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
46
30
  start: {
47
31
  line: 1,
48
32
  column: 1
49
33
  }
50
34
  };
51
-
52
35
  _classCallCheck(this, ElementError);
53
-
54
36
  _this = _super.call(this, message);
55
37
  _this.location = location;
56
38
  return _this;
57
39
  }
58
-
59
- return ElementError;
40
+ return _createClass(ElementError);
60
41
  }( /*#__PURE__*/_wrapNativeSuper(Error));
61
-
62
42
  var Element = /*#__PURE__*/function () {
63
43
  function Element(token) {
64
44
  _classCallCheck(this, Element);
65
-
66
45
  this.token = token;
67
46
  }
68
-
69
47
  _createClass(Element, [{
70
48
  key: "bind",
71
49
  value: function bind(selection) {
@@ -77,11 +55,8 @@ var Element = /*#__PURE__*/function () {
77
55
  throw new ElementError(message, this.token);
78
56
  }
79
57
  }]);
80
-
81
58
  return Element;
82
59
  }();
83
-
84
60
  var _default = Element;
85
61
  /* eslint-enable */
86
-
87
62
  exports["default"] = _default;
@@ -1,75 +1,47 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports["default"] = void 0;
7
-
8
8
  var _element = _interopRequireDefault(require("./element"));
9
-
10
9
  var _config = require("./config");
11
-
12
10
  var _utils = require("./utils");
13
-
14
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
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
-
18
12
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
19
-
20
13
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
21
-
22
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
-
24
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
25
-
15
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
26
16
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
27
-
28
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
29
-
30
- 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; }
31
-
32
- 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; }
33
-
34
- 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; }
35
-
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
36
21
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
-
38
- 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); } }
39
-
40
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
41
-
42
- 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); }
43
-
44
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
45
-
22
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
23
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
24
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
25
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
46
28
  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); }; }
47
-
48
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
49
-
29
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
50
30
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
51
-
52
- 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; } }
53
-
54
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
55
-
31
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
32
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
56
33
  var Endpoint = /*#__PURE__*/function (_Element) {
57
34
  _inherits(Endpoint, _Element);
58
-
59
35
  var _super = _createSuper(Endpoint);
60
-
61
36
  function Endpoint(_ref) {
62
37
  var _this;
63
-
64
38
  var tableName = _ref.tableName,
65
- schemaName = _ref.schemaName,
66
- fieldNames = _ref.fieldNames,
67
- relation = _ref.relation,
68
- token = _ref.token,
69
- ref = _ref.ref;
70
-
39
+ schemaName = _ref.schemaName,
40
+ fieldNames = _ref.fieldNames,
41
+ relation = _ref.relation,
42
+ token = _ref.token,
43
+ ref = _ref.ref;
71
44
  _classCallCheck(this, Endpoint);
72
-
73
45
  _this = _super.call(this, token);
74
46
  _this.relation = relation;
75
47
  _this.schemaName = schemaName;
@@ -78,23 +50,17 @@ var Endpoint = /*#__PURE__*/function (_Element) {
78
50
  _this.fields = [];
79
51
  _this.ref = ref;
80
52
  _this.dbState = _this.ref.dbState;
81
-
82
- _this.generateId(); // Use name of schema,table and field object
53
+ _this.generateId();
54
+ // Use name of schema,table and field object
83
55
  // Name in constructor could be alias
84
-
85
-
86
56
  var schema = ref.schema.database.findOrCreateSchema(schemaName || _config.DEFAULT_SCHEMA_NAME);
87
57
  var table = schema.database.findTable(schemaName, tableName);
88
-
89
58
  if (!table) {
90
59
  _this.error("Can't find table ".concat((0, _utils.shouldPrintSchemaName)(schemaName) ? "\"".concat(schemaName, "\".") : '', "\"").concat(tableName, "\""));
91
60
  }
92
-
93
61
  _this.setFields(fieldNames, table);
94
-
95
62
  return _this;
96
63
  }
97
-
98
64
  _createClass(Endpoint, [{
99
65
  key: "generateId",
100
66
  value: function generateId() {
@@ -115,11 +81,9 @@ var Endpoint = /*#__PURE__*/function (_Element) {
115
81
  var sortedEndpointFieldIds = endpoint.fields.map(function (field) {
116
82
  return field.id;
117
83
  }).sort();
118
-
119
84
  for (var i = 0; i < sortedThisFieldIds.length; i += 1) {
120
85
  if (sortedThisFieldIds[i] !== sortedEndpointFieldIds[i]) return false;
121
86
  }
122
-
123
87
  return true;
124
88
  }
125
89
  }, {
@@ -151,21 +115,17 @@ var Endpoint = /*#__PURE__*/function (_Element) {
151
115
  key: "setFields",
152
116
  value: function setFields(fieldNames, table) {
153
117
  var _this2 = this;
154
-
155
118
  var newFieldNames = fieldNames && fieldNames.length ? _toConsumableArray(fieldNames) : [];
156
-
157
119
  if (!newFieldNames.length) {
158
120
  var fieldHasPK = table.fields.find(function (field) {
159
121
  return field.pk;
160
122
  });
161
-
162
123
  if (fieldHasPK) {
163
124
  newFieldNames.push(fieldHasPK.name);
164
125
  } else {
165
126
  var indexHasPK = table.indexes.find(function (index) {
166
127
  return index.pk;
167
128
  });
168
-
169
129
  if (indexHasPK) {
170
130
  newFieldNames = indexHasPK.columns.map(function (column) {
171
131
  return column.value;
@@ -175,16 +135,12 @@ var Endpoint = /*#__PURE__*/function (_Element) {
175
135
  }
176
136
  }
177
137
  }
178
-
179
138
  newFieldNames.forEach(function (fieldName) {
180
139
  var field = table.findField(fieldName);
181
-
182
140
  if (!field) {
183
141
  _this2.error("Can't find field ".concat((0, _utils.shouldPrintSchema)(table.schema) ? "\"".concat(table.schema.name, "\".") : '', "\"").concat(fieldName, "\" in table \"").concat(table.name, "\""));
184
142
  }
185
-
186
143
  _this2.fields.push(field);
187
-
188
144
  field.pushEndpoint(_this2);
189
145
  });
190
146
  }
@@ -196,9 +152,7 @@ var Endpoint = /*#__PURE__*/function (_Element) {
196
152
  }, this.shallowExport()), this.exportParentIds())));
197
153
  }
198
154
  }]);
199
-
200
155
  return Endpoint;
201
156
  }(_element["default"]);
202
-
203
157
  var _default = Endpoint;
204
158
  exports["default"] = _default;