@dbml/core 2.5.2 → 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.
- package/lib/export/DbmlExporter.js +9 -64
- package/lib/export/JsonExporter.js +5 -11
- package/lib/export/ModelExporter.js +5 -22
- package/lib/export/MysqlExporter.js +8 -70
- package/lib/export/PostgresExporter.js +11 -80
- package/lib/export/SqlServerExporter.js +10 -71
- package/lib/export/index.js +0 -6
- package/lib/export/utils.js +2 -12
- package/lib/import/index.js +0 -7
- package/lib/index.js +4 -9
- package/lib/model_structure/config.js +1 -1
- package/lib/model_structure/database.js +32 -83
- package/lib/model_structure/dbState.js +5 -10
- package/lib/model_structure/element.js +13 -38
- package/lib/model_structure/endpoint.js +22 -68
- package/lib/model_structure/enum.js +18 -49
- package/lib/model_structure/enumValue.js +17 -44
- package/lib/model_structure/field.js +26 -62
- package/lib/model_structure/indexColumn.js +15 -40
- package/lib/model_structure/indexes.js +22 -50
- package/lib/model_structure/ref.js +24 -56
- package/lib/model_structure/schema.js +27 -65
- package/lib/model_structure/table.js +24 -59
- package/lib/model_structure/tableGroup.js +18 -49
- package/lib/model_structure/utils.js +0 -3
- package/lib/parse/Parser.js +5 -27
- package/lib/parse/buildParser.js +11 -23
- package/lib/parse/dbmlParser.js +863 -2131
- package/lib/parse/mssql/base_parsers.js +2 -11
- package/lib/parse/mssql/column_definition/actions.js +0 -3
- package/lib/parse/mssql/column_definition/index.js +9 -17
- package/lib/parse/mssql/constraint_definition/actions.js +6 -12
- package/lib/parse/mssql/constraint_definition/index.js +10 -18
- package/lib/parse/mssql/expression.js +6 -16
- package/lib/parse/mssql/fk_definition/actions.js +1 -12
- package/lib/parse/mssql/fk_definition/index.js +5 -10
- package/lib/parse/mssql/index.js +2 -4
- package/lib/parse/mssql/index_definition/actions.js +0 -6
- package/lib/parse/mssql/index_definition/index.js +8 -13
- package/lib/parse/mssql/keyword_parsers.js +2 -3
- package/lib/parse/mssql/keyword_utils.js +0 -4
- package/lib/parse/mssql/statements/actions.js +0 -24
- package/lib/parse/mssql/statements/index.js +1 -7
- package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +3 -10
- package/lib/parse/mssql/statements/statement_types/alter_table/add/actions.js +2 -6
- package/lib/parse/mssql/statements/statement_types/alter_table/add/index.js +9 -18
- package/lib/parse/mssql/statements/statement_types/alter_table/index.js +2 -7
- package/lib/parse/mssql/statements/statement_types/comments/actions.js +3 -11
- package/lib/parse/mssql/statements/statement_types/comments/index.js +3 -13
- package/lib/parse/mssql/statements/statement_types/create_index/actions.js +1 -3
- package/lib/parse/mssql/statements/statement_types/create_index/index.js +9 -15
- package/lib/parse/mssql/statements/statement_types/create_table/actions.js +7 -18
- package/lib/parse/mssql/statements/statement_types/create_table/index.js +8 -16
- package/lib/parse/mssql/statements/statement_types/index.js +0 -4
- package/lib/parse/mssql/utils.js +4 -14
- package/lib/parse/mssql/whitespaces.js +0 -1
- package/lib/parse/mssqlParser.js +0 -3
- package/lib/parse/mysqlParser.js +822 -2395
- package/lib/parse/postgresParser.js +3 -3
- package/lib/parse/postgresql/get_parser.js +6 -9
- package/lib/parse/schemarbParser.js +219 -714
- package/package.json +10 -11
- package/types/.DS_Store +0 -0
|
@@ -4,26 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
|
|
10
8
|
var _utils = require("./utils");
|
|
11
|
-
|
|
12
9
|
var _config = require("../model_structure/config");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
11
|
+
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); }
|
|
16
12
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
13
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
17
|
var DbmlExporter = /*#__PURE__*/function () {
|
|
23
18
|
function DbmlExporter() {
|
|
24
19
|
_classCallCheck(this, DbmlExporter);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
_createClass(DbmlExporter, null, [{
|
|
28
22
|
key: "hasWhiteSpace",
|
|
29
23
|
value: function hasWhiteSpace(str) {
|
|
@@ -58,62 +52,47 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
58
52
|
var lines = table.fieldIds.map(function (fieldId) {
|
|
59
53
|
var field = model.fields[fieldId];
|
|
60
54
|
var schemaName = '';
|
|
61
|
-
|
|
62
55
|
if (field.type.schemaName && field.type.schemaName !== _config.DEFAULT_SCHEMA_NAME) {
|
|
63
56
|
schemaName = DbmlExporter.hasWhiteSpace(field.type.schemaName) ? "\"".concat(field.type.schemaName, "\".") : "".concat(field.type.schemaName, ".");
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
var line = "\"".concat(field.name, "\" ").concat(schemaName).concat(DbmlExporter.hasWhiteSpace(field.type.type_name) || DbmlExporter.hasSquareBracket(field.type.type_name) ? "\"".concat(field.type.type_name, "\"") : field.type.type_name);
|
|
67
59
|
var constraints = [];
|
|
68
|
-
|
|
69
60
|
if (field.unique) {
|
|
70
61
|
constraints.push('unique');
|
|
71
62
|
}
|
|
72
|
-
|
|
73
63
|
if (field.pk) {
|
|
74
64
|
constraints.push('pk');
|
|
75
65
|
}
|
|
76
|
-
|
|
77
66
|
if (field.not_null) {
|
|
78
67
|
constraints.push('not null');
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
if (field.increment) {
|
|
82
70
|
constraints.push('increment');
|
|
83
71
|
}
|
|
84
|
-
|
|
85
72
|
if (field.dbdefault) {
|
|
86
73
|
var value = 'default: ';
|
|
87
|
-
|
|
88
74
|
switch (field.dbdefault.type) {
|
|
89
75
|
case 'boolean':
|
|
90
76
|
case 'number':
|
|
91
77
|
value += "".concat(field.dbdefault.value);
|
|
92
78
|
break;
|
|
93
|
-
|
|
94
79
|
case 'string':
|
|
95
80
|
value += "\"".concat(field.dbdefault.value, "\"");
|
|
96
81
|
break;
|
|
97
|
-
|
|
98
82
|
case 'expression':
|
|
99
83
|
value += "`".concat(field.dbdefault.value, "`");
|
|
100
84
|
break;
|
|
101
|
-
|
|
102
85
|
default:
|
|
103
86
|
break;
|
|
104
87
|
}
|
|
105
|
-
|
|
106
88
|
constraints.push(value);
|
|
107
89
|
}
|
|
108
|
-
|
|
109
90
|
if (field.note) {
|
|
110
91
|
constraints.push("note: '".concat(field.note, "'"));
|
|
111
92
|
}
|
|
112
|
-
|
|
113
93
|
if (constraints.length > 0) {
|
|
114
94
|
line += " [".concat(constraints.join(', '), "]");
|
|
115
95
|
}
|
|
116
|
-
|
|
117
96
|
return line;
|
|
118
97
|
});
|
|
119
98
|
return lines;
|
|
@@ -125,46 +104,36 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
125
104
|
var lines = table.indexIds.map(function (indexId) {
|
|
126
105
|
var line = '';
|
|
127
106
|
var index = model.indexes[indexId];
|
|
128
|
-
|
|
129
107
|
if (index.columnIds.length > 1) {
|
|
130
108
|
line = "(".concat(index.columnIds.map(function (columnId) {
|
|
131
109
|
var column = model.indexColumns[columnId];
|
|
132
|
-
|
|
133
110
|
if (column.type === 'expression') {
|
|
134
111
|
return "`".concat(column.value, "`");
|
|
135
112
|
}
|
|
136
|
-
|
|
137
113
|
return column.value;
|
|
138
114
|
}).join(', '), ")");
|
|
139
115
|
} else if (index.columnIds.length === 1) {
|
|
140
116
|
var column = model.indexColumns[index.columnIds[0]];
|
|
141
117
|
line = column.type === 'expression' ? "`".concat(column.value, "`") : column.value;
|
|
142
118
|
}
|
|
143
|
-
|
|
144
119
|
var indexSettings = [];
|
|
145
|
-
|
|
146
120
|
if (index.pk) {
|
|
147
121
|
indexSettings.push('pk');
|
|
148
122
|
}
|
|
149
|
-
|
|
150
123
|
if (index.type) {
|
|
151
124
|
indexSettings.push("type: ".concat(index.type.toLowerCase()));
|
|
152
125
|
}
|
|
153
|
-
|
|
154
126
|
if (index.unique) {
|
|
155
127
|
indexSettings.push('unique');
|
|
156
128
|
}
|
|
157
|
-
|
|
158
129
|
if (index.name) {
|
|
159
130
|
indexSettings.push("name: \"".concat(index.name, "\""));
|
|
160
131
|
}
|
|
161
|
-
|
|
162
132
|
if (indexSettings.length > 1) {
|
|
163
133
|
line += " [".concat(indexSettings.join(', '), "]");
|
|
164
134
|
} else if (indexSettings.length === 1) {
|
|
165
135
|
line += " [".concat(indexSettings[0], "]");
|
|
166
136
|
}
|
|
167
|
-
|
|
168
137
|
return line;
|
|
169
138
|
});
|
|
170
139
|
return lines;
|
|
@@ -188,37 +157,29 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
188
157
|
value: function getTableSettings(table) {
|
|
189
158
|
var settingStr = '';
|
|
190
159
|
var settingSep = ', ';
|
|
191
|
-
|
|
192
160
|
if (table.headerColor) {
|
|
193
161
|
settingStr += "headerColor: ".concat(table.headerColor).concat(settingSep);
|
|
194
162
|
}
|
|
195
|
-
|
|
196
163
|
if (settingStr.endsWith(', ')) {
|
|
197
164
|
settingStr = settingStr.replace(/,\s$/, '');
|
|
198
165
|
}
|
|
199
|
-
|
|
200
166
|
return settingStr ? " [".concat(settingStr, "]") : '';
|
|
201
167
|
}
|
|
202
168
|
}, {
|
|
203
169
|
key: "exportTables",
|
|
204
170
|
value: function exportTables(tableIds, model) {
|
|
205
171
|
var _this = this;
|
|
206
|
-
|
|
207
172
|
var tableContentArr = DbmlExporter.getTableContentArr(tableIds, model);
|
|
208
173
|
var tableStrs = tableContentArr.map(function (tableContent) {
|
|
209
174
|
var table = model.tables[tableContent.tableId];
|
|
210
175
|
var schema = model.schemas[table.schemaId];
|
|
211
|
-
|
|
212
176
|
var tableSettingStr = _this.getTableSettings(table);
|
|
213
|
-
|
|
214
177
|
var indexStr = '';
|
|
215
|
-
|
|
216
178
|
if (!_lodash["default"].isEmpty(tableContent.indexContents)) {
|
|
217
179
|
indexStr = "\nIndexes {\n".concat(tableContent.indexContents.map(function (indexLine) {
|
|
218
180
|
return " ".concat(indexLine);
|
|
219
181
|
}).join('\n'), "\n}");
|
|
220
182
|
}
|
|
221
|
-
|
|
222
183
|
var tableNote = table.note ? " Note: '".concat(table.note, "'\n") : '';
|
|
223
184
|
var tableStr = "Table ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(table.name, "\"").concat(tableSettingStr, " {\n").concat(tableContent.fieldContents.map(function (line) {
|
|
224
185
|
return " ".concat(line);
|
|
@@ -239,7 +200,6 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
239
200
|
key: "exportRefs",
|
|
240
201
|
value: function exportRefs(refIds, model) {
|
|
241
202
|
var _this2 = this;
|
|
242
|
-
|
|
243
203
|
var strArr = refIds.map(function (refId) {
|
|
244
204
|
var ref = model.refs[refId];
|
|
245
205
|
var refEndpointIndex = ref.endpointIds.findIndex(function (endpointId) {
|
|
@@ -253,37 +213,28 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
253
213
|
var refEndpointField = model.fields[refEndpoint.fieldIds[0]];
|
|
254
214
|
var refEndpointTable = model.tables[refEndpointField.tableId];
|
|
255
215
|
var refEndpointSchema = model.schemas[refEndpointTable.schemaId];
|
|
256
|
-
|
|
257
216
|
var refEndpointFieldName = _this2.buildFieldName(refEndpoint.fieldIds, model, 'dbml');
|
|
258
|
-
|
|
259
217
|
if (ref.name) {
|
|
260
218
|
line += " ".concat((0, _utils.shouldPrintSchema)(model.schemas[ref.schemaId], model) ? "\"".concat(model.schemas[ref.schemaId].name, "\".") : '', "\"").concat(ref.name, "\"");
|
|
261
219
|
}
|
|
262
|
-
|
|
263
220
|
line += ':';
|
|
264
221
|
line += "".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "\"".concat(refEndpointSchema.name, "\".") : '', "\"").concat(refEndpointTable.name, "\".").concat(refEndpointFieldName, " ");
|
|
265
222
|
var foreignEndpointField = model.fields[foreignEndpoint.fieldIds[0]];
|
|
266
223
|
var foreignEndpointTable = model.tables[foreignEndpointField.tableId];
|
|
267
224
|
var foreignEndpointSchema = model.schemas[foreignEndpointTable.schemaId];
|
|
268
|
-
|
|
269
225
|
var foreignEndpointFieldName = _this2.buildFieldName(foreignEndpoint.fieldIds, model, 'dbml');
|
|
270
|
-
|
|
271
226
|
if (foreignEndpoint.relation === '1') line += '- ';else line += '< ';
|
|
272
227
|
line += "".concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "\"".concat(foreignEndpointSchema.name, "\".") : '', "\"").concat(foreignEndpointTable.name, "\".").concat(foreignEndpointFieldName);
|
|
273
228
|
var refActions = [];
|
|
274
|
-
|
|
275
229
|
if (ref.onUpdate) {
|
|
276
230
|
refActions.push("update: ".concat(ref.onUpdate.toLowerCase()));
|
|
277
231
|
}
|
|
278
|
-
|
|
279
232
|
if (ref.onDelete) {
|
|
280
233
|
refActions.push("delete: ".concat(ref.onDelete.toLowerCase()));
|
|
281
234
|
}
|
|
282
|
-
|
|
283
235
|
if (refActions.length > 0) {
|
|
284
236
|
line += " [".concat(refActions.join(', '), "]");
|
|
285
237
|
}
|
|
286
|
-
|
|
287
238
|
line += '\n';
|
|
288
239
|
return line;
|
|
289
240
|
});
|
|
@@ -311,29 +262,25 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
311
262
|
var database = model.database['1'];
|
|
312
263
|
database.schemaIds.forEach(function (schemaId) {
|
|
313
264
|
var _model$schemas$schema = model.schemas[schemaId],
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
265
|
+
enumIds = _model$schemas$schema.enumIds,
|
|
266
|
+
tableIds = _model$schemas$schema.tableIds,
|
|
267
|
+
tableGroupIds = _model$schemas$schema.tableGroupIds,
|
|
268
|
+
refIds = _model$schemas$schema.refIds;
|
|
319
269
|
if (!_lodash["default"].isEmpty(enumIds)) {
|
|
320
270
|
if (hasBlockAbove) res += '\n';
|
|
321
271
|
res += DbmlExporter.exportEnums(enumIds, model);
|
|
322
272
|
hasBlockAbove = true;
|
|
323
273
|
}
|
|
324
|
-
|
|
325
274
|
if (!_lodash["default"].isEmpty(tableIds)) {
|
|
326
275
|
if (hasBlockAbove) res += '\n';
|
|
327
276
|
res += DbmlExporter.exportTables(tableIds, model);
|
|
328
277
|
hasBlockAbove = true;
|
|
329
278
|
}
|
|
330
|
-
|
|
331
279
|
if (!_lodash["default"].isEmpty(tableGroupIds)) {
|
|
332
280
|
if (hasBlockAbove) res += '\n';
|
|
333
281
|
res += DbmlExporter.exportTableGroups(tableGroupIds, model);
|
|
334
282
|
hasBlockAbove = true;
|
|
335
283
|
}
|
|
336
|
-
|
|
337
284
|
if (!_lodash["default"].isEmpty(refIds)) {
|
|
338
285
|
if (hasBlockAbove) res += '\n';
|
|
339
286
|
res += DbmlExporter.exportRefs(refIds, model);
|
|
@@ -343,9 +290,7 @@ var DbmlExporter = /*#__PURE__*/function () {
|
|
|
343
290
|
return res;
|
|
344
291
|
}
|
|
345
292
|
}]);
|
|
346
|
-
|
|
347
293
|
return DbmlExporter;
|
|
348
294
|
}();
|
|
349
|
-
|
|
350
295
|
var _default = DbmlExporter;
|
|
351
296
|
exports["default"] = _default;
|
|
@@ -4,33 +4,27 @@ 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
|
|
11
|
-
|
|
12
|
-
function
|
|
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 JsonExporter = /*#__PURE__*/function () {
|
|
15
14
|
function JsonExporter() {
|
|
16
15
|
_classCallCheck(this, JsonExporter);
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
_createClass(JsonExporter, null, [{
|
|
20
18
|
key: "export",
|
|
21
19
|
value: function _export(model) {
|
|
22
20
|
var isNormalized = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
23
|
-
|
|
24
21
|
if (!isNormalized) {
|
|
25
22
|
return JSON.stringify(model["export"](), null, 2);
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return JSON.stringify(model, null, 2);
|
|
29
25
|
}
|
|
30
26
|
}]);
|
|
31
|
-
|
|
32
27
|
return JsonExporter;
|
|
33
28
|
}();
|
|
34
|
-
|
|
35
29
|
var _default = JsonExporter;
|
|
36
30
|
exports["default"] = _default;
|
|
@@ -4,30 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _DbmlExporter = _interopRequireDefault(require("./DbmlExporter"));
|
|
9
|
-
|
|
10
8
|
var _MysqlExporter = _interopRequireDefault(require("./MysqlExporter"));
|
|
11
|
-
|
|
12
9
|
var _PostgresExporter = _interopRequireDefault(require("./PostgresExporter"));
|
|
13
|
-
|
|
14
10
|
var _JsonExporter = _interopRequireDefault(require("./JsonExporter"));
|
|
15
|
-
|
|
16
11
|
var _SqlServerExporter = _interopRequireDefault(require("./SqlServerExporter"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
13
|
+
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); }
|
|
20
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
15
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
26
19
|
var ModelExporter = /*#__PURE__*/function () {
|
|
27
20
|
function ModelExporter() {
|
|
28
21
|
_classCallCheck(this, ModelExporter);
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
_createClass(ModelExporter, null, [{
|
|
32
24
|
key: "export",
|
|
33
25
|
value: function _export() {
|
|
@@ -36,38 +28,29 @@ var ModelExporter = /*#__PURE__*/function () {
|
|
|
36
28
|
var isNormalized = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
37
29
|
var res = '';
|
|
38
30
|
var normalizedModel = isNormalized ? model : model.normalize();
|
|
39
|
-
|
|
40
31
|
switch (format) {
|
|
41
32
|
case 'dbml':
|
|
42
33
|
res = _DbmlExporter["default"]["export"](normalizedModel);
|
|
43
34
|
break;
|
|
44
|
-
|
|
45
35
|
case 'mysql':
|
|
46
36
|
res = _MysqlExporter["default"]["export"](normalizedModel);
|
|
47
37
|
break;
|
|
48
|
-
|
|
49
38
|
case 'postgres':
|
|
50
39
|
res = _PostgresExporter["default"]["export"](normalizedModel);
|
|
51
40
|
break;
|
|
52
|
-
|
|
53
41
|
case 'json':
|
|
54
42
|
res = _JsonExporter["default"]["export"](model, isNormalized);
|
|
55
43
|
break;
|
|
56
|
-
|
|
57
44
|
case 'mssql':
|
|
58
45
|
res = _SqlServerExporter["default"]["export"](normalizedModel);
|
|
59
46
|
break;
|
|
60
|
-
|
|
61
47
|
default:
|
|
62
48
|
break;
|
|
63
49
|
}
|
|
64
|
-
|
|
65
50
|
return res;
|
|
66
51
|
}
|
|
67
52
|
}]);
|
|
68
|
-
|
|
69
53
|
return ModelExporter;
|
|
70
54
|
}();
|
|
71
|
-
|
|
72
55
|
var _default = ModelExporter;
|
|
73
56
|
exports["default"] = _default;
|