@dbml/core
Advanced tools
Comparing version 2.5.2 to 2.5.3
@@ -7,17 +7,12 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _utils = require("./utils"); | ||
var _config = require("../model_structure/config"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var DbmlExporter = /*#__PURE__*/function () { | ||
@@ -27,3 +22,2 @@ function DbmlExporter() { | ||
} | ||
_createClass(DbmlExporter, null, [{ | ||
@@ -63,29 +57,21 @@ key: "hasWhiteSpace", | ||
var schemaName = ''; | ||
if (field.type.schemaName && field.type.schemaName !== _config.DEFAULT_SCHEMA_NAME) { | ||
schemaName = DbmlExporter.hasWhiteSpace(field.type.schemaName) ? "\"".concat(field.type.schemaName, "\".") : "".concat(field.type.schemaName, "."); | ||
} | ||
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); | ||
var constraints = []; | ||
if (field.unique) { | ||
constraints.push('unique'); | ||
} | ||
if (field.pk) { | ||
constraints.push('pk'); | ||
} | ||
if (field.not_null) { | ||
constraints.push('not null'); | ||
} | ||
if (field.increment) { | ||
constraints.push('increment'); | ||
} | ||
if (field.dbdefault) { | ||
var value = 'default: '; | ||
switch (field.dbdefault.type) { | ||
@@ -96,26 +82,19 @@ case 'boolean': | ||
break; | ||
case 'string': | ||
value += "\"".concat(field.dbdefault.value, "\""); | ||
break; | ||
case 'expression': | ||
value += "`".concat(field.dbdefault.value, "`"); | ||
break; | ||
default: | ||
break; | ||
} | ||
constraints.push(value); | ||
} | ||
if (field.note) { | ||
constraints.push("note: '".concat(field.note, "'")); | ||
} | ||
if (constraints.length > 0) { | ||
line += " [".concat(constraints.join(', '), "]"); | ||
} | ||
return line; | ||
@@ -132,11 +111,8 @@ }); | ||
var index = model.indexes[indexId]; | ||
if (index.columnIds.length > 1) { | ||
line = "(".concat(index.columnIds.map(function (columnId) { | ||
var column = model.indexColumns[columnId]; | ||
if (column.type === 'expression') { | ||
return "`".concat(column.value, "`"); | ||
} | ||
return column.value; | ||
@@ -148,21 +124,15 @@ }).join(', '), ")"); | ||
} | ||
var indexSettings = []; | ||
if (index.pk) { | ||
indexSettings.push('pk'); | ||
} | ||
if (index.type) { | ||
indexSettings.push("type: ".concat(index.type.toLowerCase())); | ||
} | ||
if (index.unique) { | ||
indexSettings.push('unique'); | ||
} | ||
if (index.name) { | ||
indexSettings.push("name: \"".concat(index.name, "\"")); | ||
} | ||
if (indexSettings.length > 1) { | ||
@@ -173,3 +143,2 @@ line += " [".concat(indexSettings.join(', '), "]"); | ||
} | ||
return line; | ||
@@ -198,11 +167,8 @@ }); | ||
var settingSep = ', '; | ||
if (table.headerColor) { | ||
settingStr += "headerColor: ".concat(table.headerColor).concat(settingSep); | ||
} | ||
if (settingStr.endsWith(', ')) { | ||
settingStr = settingStr.replace(/,\s$/, ''); | ||
} | ||
return settingStr ? " [".concat(settingStr, "]") : ''; | ||
@@ -214,3 +180,2 @@ } | ||
var _this = this; | ||
var tableContentArr = DbmlExporter.getTableContentArr(tableIds, model); | ||
@@ -220,7 +185,4 @@ var tableStrs = tableContentArr.map(function (tableContent) { | ||
var schema = model.schemas[table.schemaId]; | ||
var tableSettingStr = _this.getTableSettings(table); | ||
var indexStr = ''; | ||
if (!_lodash["default"].isEmpty(tableContent.indexContents)) { | ||
@@ -231,3 +193,2 @@ indexStr = "\nIndexes {\n".concat(tableContent.indexContents.map(function (indexLine) { | ||
} | ||
var tableNote = table.note ? " Note: '".concat(table.note, "'\n") : ''; | ||
@@ -253,3 +214,2 @@ var tableStr = "Table ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(table.name, "\"").concat(tableSettingStr, " {\n").concat(tableContent.fieldContents.map(function (line) { | ||
var _this2 = this; | ||
var strArr = refIds.map(function (refId) { | ||
@@ -268,9 +228,6 @@ var ref = model.refs[refId]; | ||
var refEndpointSchema = model.schemas[refEndpointTable.schemaId]; | ||
var refEndpointFieldName = _this2.buildFieldName(refEndpoint.fieldIds, model, 'dbml'); | ||
if (ref.name) { | ||
line += " ".concat((0, _utils.shouldPrintSchema)(model.schemas[ref.schemaId], model) ? "\"".concat(model.schemas[ref.schemaId].name, "\".") : '', "\"").concat(ref.name, "\""); | ||
} | ||
line += ':'; | ||
@@ -281,21 +238,15 @@ line += "".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "\"".concat(refEndpointSchema.name, "\".") : '', "\"").concat(refEndpointTable.name, "\".").concat(refEndpointFieldName, " "); | ||
var foreignEndpointSchema = model.schemas[foreignEndpointTable.schemaId]; | ||
var foreignEndpointFieldName = _this2.buildFieldName(foreignEndpoint.fieldIds, model, 'dbml'); | ||
if (foreignEndpoint.relation === '1') line += '- ';else line += '< '; | ||
line += "".concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "\"".concat(foreignEndpointSchema.name, "\".") : '', "\"").concat(foreignEndpointTable.name, "\".").concat(foreignEndpointFieldName); | ||
var refActions = []; | ||
if (ref.onUpdate) { | ||
refActions.push("update: ".concat(ref.onUpdate.toLowerCase())); | ||
} | ||
if (ref.onDelete) { | ||
refActions.push("delete: ".concat(ref.onDelete.toLowerCase())); | ||
} | ||
if (refActions.length > 0) { | ||
line += " [".concat(refActions.join(', '), "]"); | ||
} | ||
line += '\n'; | ||
@@ -328,7 +279,6 @@ return line; | ||
var _model$schemas$schema = model.schemas[schemaId], | ||
enumIds = _model$schemas$schema.enumIds, | ||
tableIds = _model$schemas$schema.tableIds, | ||
tableGroupIds = _model$schemas$schema.tableGroupIds, | ||
refIds = _model$schemas$schema.refIds; | ||
enumIds = _model$schemas$schema.enumIds, | ||
tableIds = _model$schemas$schema.tableIds, | ||
tableGroupIds = _model$schemas$schema.tableGroupIds, | ||
refIds = _model$schemas$schema.refIds; | ||
if (!_lodash["default"].isEmpty(enumIds)) { | ||
@@ -339,3 +289,2 @@ if (hasBlockAbove) res += '\n'; | ||
} | ||
if (!_lodash["default"].isEmpty(tableIds)) { | ||
@@ -346,3 +295,2 @@ if (hasBlockAbove) res += '\n'; | ||
} | ||
if (!_lodash["default"].isEmpty(tableGroupIds)) { | ||
@@ -353,3 +301,2 @@ if (hasBlockAbove) res += '\n'; | ||
} | ||
if (!_lodash["default"].isEmpty(refIds)) { | ||
@@ -364,7 +311,5 @@ if (hasBlockAbove) res += '\n'; | ||
}]); | ||
return DbmlExporter; | ||
}(); | ||
var _default = DbmlExporter; | ||
exports["default"] = _default; |
@@ -7,15 +7,9 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _ModelExporter = _interopRequireDefault(require("./ModelExporter")); | ||
var _Parser = _interopRequireDefault(require("../parse/Parser")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _export(str, format) { | ||
var database = _Parser["default"].parse(str, 'dbml'); | ||
return _ModelExporter["default"]["export"](database.normalize(), format); | ||
} | ||
var _default = { | ||
@@ -22,0 +16,0 @@ "export": _export |
@@ -7,9 +7,8 @@ "use strict"; | ||
exports["default"] = void 0; | ||
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); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var JsonExporter = /*#__PURE__*/function () { | ||
@@ -19,3 +18,2 @@ function JsonExporter() { | ||
} | ||
_createClass(JsonExporter, null, [{ | ||
@@ -25,15 +23,11 @@ key: "export", | ||
var isNormalized = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
if (!isNormalized) { | ||
return JSON.stringify(model["export"](), null, 2); | ||
} | ||
return JSON.stringify(model, null, 2); | ||
} | ||
}]); | ||
return JsonExporter; | ||
}(); | ||
var _default = JsonExporter; | ||
exports["default"] = _default; |
@@ -7,21 +7,14 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _DbmlExporter = _interopRequireDefault(require("./DbmlExporter")); | ||
var _MysqlExporter = _interopRequireDefault(require("./MysqlExporter")); | ||
var _PostgresExporter = _interopRequireDefault(require("./PostgresExporter")); | ||
var _JsonExporter = _interopRequireDefault(require("./JsonExporter")); | ||
var _SqlServerExporter = _interopRequireDefault(require("./SqlServerExporter")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var ModelExporter = /*#__PURE__*/function () { | ||
@@ -31,3 +24,2 @@ function ModelExporter() { | ||
} | ||
_createClass(ModelExporter, null, [{ | ||
@@ -41,3 +33,2 @@ key: "export", | ||
var normalizedModel = isNormalized ? model : model.normalize(); | ||
switch (format) { | ||
@@ -47,31 +38,23 @@ case 'dbml': | ||
break; | ||
case 'mysql': | ||
res = _MysqlExporter["default"]["export"](normalizedModel); | ||
break; | ||
case 'postgres': | ||
res = _PostgresExporter["default"]["export"](normalizedModel); | ||
break; | ||
case 'json': | ||
res = _JsonExporter["default"]["export"](model, isNormalized); | ||
break; | ||
case 'mssql': | ||
res = _SqlServerExporter["default"]["export"](normalizedModel); | ||
break; | ||
default: | ||
break; | ||
} | ||
return res; | ||
} | ||
}]); | ||
return ModelExporter; | ||
}(); | ||
var _default = ModelExporter; | ||
exports["default"] = _default; |
@@ -7,27 +7,17 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var MySQLExporter = /*#__PURE__*/function () { | ||
@@ -37,3 +27,2 @@ function MySQLExporter() { | ||
} | ||
_createClass(MySQLExporter, null, [{ | ||
@@ -46,11 +35,8 @@ key: "getFieldLines", | ||
var line = ''; | ||
if (field.enumId) { | ||
var _enum = model.enums[field.enumId]; | ||
line = "`".concat(field.name, "` ENUM ("); | ||
var enumValues = _enum.valueIds.map(function (valueId) { | ||
return "'".concat(model.enumValues[valueId].name, "'"); | ||
}); | ||
line += "".concat(enumValues.join(', '), ")"); | ||
@@ -60,19 +46,14 @@ } else { | ||
} | ||
if (field.unique) { | ||
line += ' UNIQUE'; | ||
} | ||
if (field.pk) { | ||
line += ' PRIMARY KEY'; | ||
} | ||
if (field.not_null) { | ||
line += ' NOT NULL'; | ||
} | ||
if (field.increment) { | ||
line += ' AUTO_INCREMENT'; | ||
} | ||
if (field.dbdefault) { | ||
@@ -87,7 +68,5 @@ if (field.dbdefault.type === 'expression') { | ||
} | ||
if (field.note) { | ||
line += " COMMENT '".concat(field.note.replace(/'/g, "\\'"), "'"); | ||
} | ||
return line; | ||
@@ -111,3 +90,2 @@ }); | ||
var columnStr = ''; | ||
if (column.type === 'expression') { | ||
@@ -118,3 +96,2 @@ columnStr = "(".concat(column.value, ")"); | ||
} | ||
columnArr.push(columnStr); | ||
@@ -168,7 +145,4 @@ }); | ||
var line = "CREATE TABLE ".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "`".concat(refEndpointSchema.name, "`.") : '', "`").concat(tableName, "` (\n"); | ||
var key1s = _toConsumableArray(firstTableFieldsMap.keys()).join('`, `'); | ||
var key2s = _toConsumableArray(secondTableFieldsMap.keys()).join('`, `'); | ||
firstTableFieldsMap.forEach(function (fieldType, fieldName) { | ||
@@ -188,3 +162,2 @@ line += " `".concat(fieldName, "` ").concat(fieldType, ",\n"); | ||
var refEndpointFields = _toConsumableArray(fieldsMap.keys()).join('`, `'); | ||
var line = "ALTER TABLE ".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "`".concat(refEndpointSchema.name, "`.") : '', "`").concat(refEndpointTableName, "` ADD FOREIGN KEY (`").concat(refEndpointFields, "`) REFERENCES ").concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "`".concat(foreignEndpointSchema.name, "`.") : '', "`").concat(foreignEndpointTableName, "` ").concat(foreignEndpointFields, ";\n\n"); | ||
@@ -197,3 +170,2 @@ return line; | ||
var _this = this; | ||
var strArr = refIds.map(function (refId) { | ||
@@ -213,11 +185,7 @@ var line = ''; | ||
var refEndpointSchema = model.schemas[refEndpointTable.schemaId]; | ||
var refEndpointFieldName = _this.buildFieldName(refEndpoint.fieldIds, model, 'mysql'); | ||
var foreignEndpointField = model.fields[foreignEndpoint.fieldIds[0]]; | ||
var foreignEndpointTable = model.tables[foreignEndpointField.tableId]; | ||
var foreignEndpointSchema = model.schemas[foreignEndpointTable.schemaId]; | ||
var foreignEndpointFieldName = _this.buildFieldName(foreignEndpoint.fieldIds, model, 'mysql'); | ||
if (refOneIndex === -1) { | ||
@@ -232,20 +200,14 @@ var firstTableFieldsMap = (0, _utils.buildJunctionFields1)(refEndpoint.fieldIds, model); | ||
line = "ALTER TABLE ".concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "`".concat(foreignEndpointSchema.name, "`.") : '', "`").concat(foreignEndpointTable.name, "` ADD "); | ||
if (ref.name) { | ||
line += "CONSTRAINT `".concat(ref.name, "` "); | ||
} | ||
line += "FOREIGN KEY ".concat(foreignEndpointFieldName, " REFERENCES ").concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "`".concat(refEndpointSchema.name, "`.") : '', "`").concat(refEndpointTable.name, "` ").concat(refEndpointFieldName); | ||
if (ref.onDelete) { | ||
line += " ON DELETE ".concat(ref.onDelete.toUpperCase()); | ||
} | ||
if (ref.onUpdate) { | ||
line += " ON UPDATE ".concat(ref.onUpdate.toUpperCase()); | ||
} | ||
line += ';\n'; | ||
} | ||
return line; | ||
@@ -266,7 +228,5 @@ }); | ||
var line = 'CREATE'; | ||
if (index.unique) { | ||
line += ' UNIQUE'; | ||
} | ||
var indexName = index.name ? "`".concat(index.name, "`") : "`".concat((0, _utils.shouldPrintSchema)(schema, model) ? "`".concat(schema.name, "`.") : '').concat(table.name, "_index_").concat(i, "`"); | ||
@@ -278,3 +238,2 @@ line += " INDEX ".concat(indexName, " ON ").concat((0, _utils.shouldPrintSchema)(schema, model) ? "`".concat(schema.name, "`.") : '', "`").concat(table.name, "`"); | ||
var columnStr = ''; | ||
if (column.type === 'expression') { | ||
@@ -285,11 +244,8 @@ columnStr = "(".concat(column.value, ")"); | ||
} | ||
columnArr.push(columnStr); | ||
}); | ||
line += " (".concat(columnArr.join(', '), ")"); | ||
if (index.type) { | ||
line += " USING ".concat(index.type.toUpperCase()); | ||
} | ||
line += ';\n'; | ||
@@ -305,3 +261,2 @@ return line; | ||
var line = ''; | ||
if (comment.type === 'table') { | ||
@@ -312,3 +267,2 @@ var table = model.tables[comment.tableId]; | ||
} | ||
line += ';\n'; | ||
@@ -329,24 +283,17 @@ return line; | ||
var tableIds = schema.tableIds, | ||
refIds = schema.refIds; | ||
refIds = schema.refIds; | ||
if ((0, _utils.shouldPrintSchema)(schema, model)) { | ||
prevStatements.schemas.push("CREATE SCHEMA `".concat(schema.name, "`;\n")); | ||
} | ||
if (!_lodash["default"].isEmpty(tableIds)) { | ||
var _prevStatements$table; | ||
(_prevStatements$table = prevStatements.tables).push.apply(_prevStatements$table, _toConsumableArray(MySQLExporter.exportTables(tableIds, model))); | ||
} | ||
var indexIds = _lodash["default"].flatten(tableIds.map(function (tableId) { | ||
return model.tables[tableId].indexIds; | ||
})); | ||
if (!_lodash["default"].isEmpty(indexIds)) { | ||
var _prevStatements$index; | ||
(_prevStatements$index = prevStatements.indexes).push.apply(_prevStatements$index, _toConsumableArray(MySQLExporter.exportIndexes(indexIds, model))); | ||
} | ||
var commentNodes = _lodash["default"].flatten(tableIds.map(function (tableId) { | ||
@@ -359,15 +306,10 @@ var note = model.tables[tableId].note; | ||
})); | ||
if (!_lodash["default"].isEmpty(commentNodes)) { | ||
var _prevStatements$comme; | ||
(_prevStatements$comme = prevStatements.comments).push.apply(_prevStatements$comme, _toConsumableArray(MySQLExporter.exportComments(commentNodes, model))); | ||
} | ||
if (!_lodash["default"].isEmpty(refIds)) { | ||
var _prevStatements$refs; | ||
(_prevStatements$refs = prevStatements.refs).push.apply(_prevStatements$refs, _toConsumableArray(MySQLExporter.exportRefs(refIds, model, usedTableNames))); | ||
} | ||
return prevStatements; | ||
@@ -382,13 +324,9 @@ }, { | ||
}); | ||
var res = _lodash["default"].concat(statements.schemas, statements.enums, statements.tables, statements.indexes, statements.comments, statements.refs).join('\n'); | ||
return res; | ||
} | ||
}]); | ||
return MySQLExporter; | ||
}(); | ||
var _default = MySQLExporter; | ||
exports["default"] = _default; |
@@ -7,29 +7,18 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _utils = require("./utils"); | ||
var _config = require("../model_structure/config"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var PostgresExporter = /*#__PURE__*/function () { | ||
@@ -39,3 +28,2 @@ function PostgresExporter() { | ||
} | ||
_createClass(PostgresExporter, null, [{ | ||
@@ -47,3 +35,2 @@ key: "exportEnums", | ||
var schema = model.schemas[_enum.schemaId]; | ||
var enumValueArr = _enum.valueIds.map(function (valueId) { | ||
@@ -53,3 +40,2 @@ var value = model.enumValues[valueId]; | ||
}); | ||
var enumValueStr = enumValueArr.join(',\n'); | ||
@@ -68,3 +54,2 @@ var line = "CREATE TYPE ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(_enum.name, "\" AS ENUM (\n").concat(enumValueStr, "\n);\n"); | ||
var line = ''; | ||
if (field.increment) { | ||
@@ -79,23 +64,17 @@ var typicalIntergers = new Set(['BIGINT', 'INT', 'INTEGER', 'SMALLINT']); | ||
var schemaName = ''; | ||
if (field.type.schemaName && field.type.schemaName !== _config.DEFAULT_SCHEMA_NAME) { | ||
schemaName = (0, _utils.hasWhiteSpace)(field.type.schemaName) ? "\"".concat(field.type.schemaName, "\".") : "".concat(field.type.schemaName, "."); | ||
} | ||
var typeName = (0, _utils.hasWhiteSpace)(field.type.type_name) ? "\"".concat(field.type.type_name, "\"") : field.type.type_name; | ||
line = "\"".concat(field.name, "\" ").concat(schemaName).concat(typeName); | ||
} | ||
if (field.unique) { | ||
line += ' UNIQUE'; | ||
} | ||
if (field.pk) { | ||
line += ' PRIMARY KEY'; | ||
} | ||
if (field.not_null) { | ||
line += ' NOT NULL'; | ||
} | ||
if (field.dbdefault) { | ||
@@ -110,3 +89,2 @@ if (field.dbdefault.type === 'expression') { | ||
} | ||
return line; | ||
@@ -130,3 +108,2 @@ }); | ||
var columnStr = ''; | ||
if (column.type === 'expression') { | ||
@@ -137,3 +114,2 @@ columnStr = "(".concat(column.value, ")"); | ||
} | ||
columnArr.push(columnStr); | ||
@@ -187,7 +163,4 @@ }); | ||
var line = "CREATE TABLE ".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "\"".concat(refEndpointSchema.name, "\".") : '', "\"").concat(tableName, "\" (\n"); | ||
var key1s = _toConsumableArray(firstTableFieldsMap.keys()).join('", "'); | ||
var key2s = _toConsumableArray(secondTableFieldsMap.keys()).join('", "'); | ||
firstTableFieldsMap.forEach(function (fieldType, fieldName) { | ||
@@ -207,3 +180,2 @@ line += " \"".concat(fieldName, "\" ").concat(fieldType, ",\n"); | ||
var refEndpointFields = _toConsumableArray(fieldsMap.keys()).join('", "'); | ||
var line = "ALTER TABLE ".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "\"".concat(refEndpointSchema.name, "\".") : '', "\"").concat(refEndpointTableName, "\" ADD FOREIGN KEY (\"").concat(refEndpointFields, "\") REFERENCES ").concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "\"".concat(foreignEndpointSchema.name, "\".") : '', "\"").concat(foreignEndpointTableName, "\" ").concat(foreignEndpointFields, ";\n\n"); | ||
@@ -216,3 +188,2 @@ return line; | ||
var _this = this; | ||
var strArr = refIds.map(function (refId) { | ||
@@ -232,11 +203,7 @@ var line = ''; | ||
var refEndpointSchema = model.schemas[refEndpointTable.schemaId]; | ||
var refEndpointFieldName = _this.buildFieldName(refEndpoint.fieldIds, model, 'postgres'); | ||
var foreignEndpointField = model.fields[foreignEndpoint.fieldIds[0]]; | ||
var foreignEndpointTable = model.tables[foreignEndpointField.tableId]; | ||
var foreignEndpointSchema = model.schemas[foreignEndpointTable.schemaId]; | ||
var foreignEndpointFieldName = _this.buildFieldName(foreignEndpoint.fieldIds, model, 'postgres'); | ||
if (refOneIndex === -1) { | ||
@@ -252,20 +219,14 @@ // many to many relationship | ||
line = "ALTER TABLE ".concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "\"".concat(foreignEndpointSchema.name, "\".") : '', "\"").concat(foreignEndpointTable.name, "\" ADD "); | ||
if (ref.name) { | ||
line += "CONSTRAINT \"".concat(ref.name, "\" "); | ||
} | ||
line += "FOREIGN KEY ".concat(foreignEndpointFieldName, " REFERENCES ").concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "\"".concat(refEndpointSchema.name, "\".") : '', "\"").concat(refEndpointTable.name, "\" ").concat(refEndpointFieldName); | ||
if (ref.onDelete) { | ||
line += " ON DELETE ".concat(ref.onDelete.toUpperCase()); | ||
} | ||
if (ref.onUpdate) { | ||
line += " ON UPDATE ".concat(ref.onUpdate.toUpperCase()); | ||
} | ||
line += ';\n'; | ||
} | ||
return line; | ||
@@ -286,20 +247,14 @@ }); | ||
var line = 'CREATE'; | ||
if (index.unique) { | ||
line += ' UNIQUE'; | ||
} | ||
var indexName = index.name ? "\"".concat(index.name, "\"") : ''; | ||
line += ' INDEX'; | ||
if (indexName) { | ||
line += " ".concat(indexName); | ||
} | ||
line += " ON ".concat((0, _utils.shouldPrintSchema)(schema, model) ? "\"".concat(schema.name, "\".") : '', "\"").concat(table.name, "\""); | ||
if (index.type) { | ||
line += " USING ".concat(index.type.toUpperCase()); | ||
} | ||
var columnArr = []; | ||
@@ -309,3 +264,2 @@ index.columnIds.forEach(function (columnId) { | ||
var columnStr = ''; | ||
if (column.type === 'expression') { | ||
@@ -316,3 +270,2 @@ columnStr = "(".concat(column.value, ")"); | ||
} | ||
columnArr.push(columnStr); | ||
@@ -333,3 +286,2 @@ }); | ||
var schema = model.schemas[table.schemaId]; | ||
switch (comment.type) { | ||
@@ -341,3 +293,2 @@ case 'table': | ||
} | ||
case 'column': | ||
@@ -349,7 +300,5 @@ { | ||
} | ||
default: | ||
break; | ||
} | ||
line += ';\n'; | ||
@@ -370,35 +319,26 @@ return line; | ||
var tableIds = schema.tableIds, | ||
enumIds = schema.enumIds, | ||
refIds = schema.refIds; | ||
enumIds = schema.enumIds, | ||
refIds = schema.refIds; | ||
if ((0, _utils.shouldPrintSchema)(schema, model)) { | ||
prevStatements.schemas.push("CREATE SCHEMA \"".concat(schema.name, "\";\n")); | ||
} | ||
if (!_lodash["default"].isEmpty(enumIds)) { | ||
var _prevStatements$enums; | ||
(_prevStatements$enums = prevStatements.enums).push.apply(_prevStatements$enums, _toConsumableArray(PostgresExporter.exportEnums(enumIds, model))); | ||
} | ||
if (!_lodash["default"].isEmpty(tableIds)) { | ||
var _prevStatements$table; | ||
(_prevStatements$table = prevStatements.tables).push.apply(_prevStatements$table, _toConsumableArray(PostgresExporter.exportTables(tableIds, model))); | ||
} | ||
var indexIds = _lodash["default"].flatten(tableIds.map(function (tableId) { | ||
return model.tables[tableId].indexIds; | ||
})); | ||
if (!_lodash["default"].isEmpty(indexIds)) { | ||
var _prevStatements$index; | ||
(_prevStatements$index = prevStatements.indexes).push.apply(_prevStatements$index, _toConsumableArray(PostgresExporter.exportIndexes(indexIds, model))); | ||
} | ||
var commentNodes = _lodash["default"].flatten(tableIds.map(function (tableId) { | ||
var _model$tables$tableId = model.tables[tableId], | ||
fieldIds = _model$tables$tableId.fieldIds, | ||
note = _model$tables$tableId.note; | ||
fieldIds = _model$tables$tableId.fieldIds, | ||
note = _model$tables$tableId.note; | ||
var fieldObjects = fieldIds.filter(function (fieldId) { | ||
@@ -418,15 +358,10 @@ return model.fields[fieldId].note; | ||
})); | ||
if (!_lodash["default"].isEmpty(commentNodes)) { | ||
var _prevStatements$comme; | ||
(_prevStatements$comme = prevStatements.comments).push.apply(_prevStatements$comme, _toConsumableArray(PostgresExporter.exportComments(commentNodes, model))); | ||
} | ||
if (!_lodash["default"].isEmpty(refIds)) { | ||
var _prevStatements$refs; | ||
(_prevStatements$refs = prevStatements.refs).push.apply(_prevStatements$refs, _toConsumableArray(PostgresExporter.exportRefs(refIds, model, usedTableNames))); | ||
} | ||
return prevStatements; | ||
@@ -441,13 +376,9 @@ }, { | ||
}); | ||
var res = _lodash["default"].concat(statements.schemas, statements.enums, statements.tables, statements.indexes, statements.comments, statements.refs).join('\n'); | ||
return res; | ||
} | ||
}]); | ||
return PostgresExporter; | ||
}(); | ||
var _default = PostgresExporter; | ||
exports["default"] = _default; |
@@ -7,27 +7,17 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var SqlServerExporter = /*#__PURE__*/function () { | ||
@@ -37,3 +27,2 @@ function SqlServerExporter() { | ||
} | ||
_createClass(SqlServerExporter, null, [{ | ||
@@ -46,7 +35,5 @@ key: "getFieldLines", | ||
var line = ''; | ||
if (field.enumId) { | ||
var _enum = model.enums[field.enumId]; | ||
line = "[".concat(field.name, "] nvarchar(255) NOT NULL CHECK ([").concat(field.name, "] IN ("); | ||
var enumValues = _enum.valueIds.map(function (valueId) { | ||
@@ -56,3 +43,2 @@ var value = model.enumValues[valueId]; | ||
}); | ||
line += "".concat(enumValues.join(', '), "))"); | ||
@@ -62,19 +48,14 @@ } else { | ||
} | ||
if (field.unique) { | ||
line += ' UNIQUE'; | ||
} | ||
if (field.pk) { | ||
line += ' PRIMARY KEY'; | ||
} | ||
if (field.not_null) { | ||
line += ' NOT NULL'; | ||
} | ||
if (field.increment) { | ||
line += ' IDENTITY(1, 1)'; | ||
} | ||
if (field.dbdefault) { | ||
@@ -89,3 +70,2 @@ if (field.dbdefault.type === 'expression') { | ||
} | ||
return line; | ||
@@ -109,3 +89,2 @@ }); | ||
var columnStr = ''; | ||
if (column.type === 'expression') { | ||
@@ -116,3 +95,2 @@ columnStr = "(".concat(column.value, ")"); | ||
} | ||
columnArr.push(columnStr); | ||
@@ -158,7 +136,4 @@ }); | ||
var line = "CREATE TABLE ".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "[".concat(refEndpointSchema.name, "].") : '', "[").concat(tableName, "] (\n"); | ||
var key1s = _toConsumableArray(firstTableFieldsMap.keys()).join('], ['); | ||
var key2s = _toConsumableArray(secondTableFieldsMap.keys()).join('], ['); | ||
firstTableFieldsMap.forEach(function (fieldType, fieldName) { | ||
@@ -178,3 +153,2 @@ line += " [".concat(fieldName, "] ").concat(fieldType, ",\n"); | ||
var refEndpointFields = _toConsumableArray(fieldsMap.keys()).join('], ['); | ||
var line = "ALTER TABLE ".concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "[".concat(refEndpointSchema.name, "].") : '', "[").concat(refEndpointTableName, "] ADD FOREIGN KEY ([").concat(refEndpointFields, "]) REFERENCES ").concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "[".concat(foreignEndpointSchema.name, "].") : '', "[").concat(foreignEndpointTableName, "] ").concat(foreignEndpointFields, ";\nGO\n\n"); | ||
@@ -195,3 +169,2 @@ return line; | ||
var _this = this; | ||
var strArr = refIds.map(function (refId) { | ||
@@ -211,11 +184,7 @@ var line = ''; | ||
var refEndpointSchema = model.schemas[refEndpointTable.schemaId]; | ||
var refEndpointFieldName = _this.buildFieldName(refEndpoint.fieldIds, model, 'mssql'); | ||
var foreignEndpointField = model.fields[foreignEndpoint.fieldIds[0]]; | ||
var foreignEndpointTable = model.tables[foreignEndpointField.tableId]; | ||
var foreignEndpointSchema = model.schemas[foreignEndpointTable.schemaId]; | ||
var foreignEndpointFieldName = _this.buildFieldName(foreignEndpoint.fieldIds, model, 'mssql'); | ||
if (refOneIndex === -1) { | ||
@@ -231,20 +200,14 @@ // many to many relationship | ||
line = "ALTER TABLE ".concat((0, _utils.shouldPrintSchema)(foreignEndpointSchema, model) ? "[".concat(foreignEndpointSchema.name, "].") : '', "[").concat(foreignEndpointTable.name, "] ADD "); | ||
if (ref.name) { | ||
line += "CONSTRAINT [".concat(ref.name, "] "); | ||
} | ||
line += "FOREIGN KEY ".concat(foreignEndpointFieldName, " REFERENCES ").concat((0, _utils.shouldPrintSchema)(refEndpointSchema, model) ? "[".concat(refEndpointSchema.name, "].") : '', "[").concat(refEndpointTable.name, "] ").concat(refEndpointFieldName); | ||
if (ref.onDelete) { | ||
line += " ON DELETE ".concat(ref.onDelete.toUpperCase()); | ||
} | ||
if (ref.onUpdate) { | ||
line += " ON UPDATE ".concat(ref.onUpdate.toUpperCase()); | ||
} | ||
line += '\nGO\n'; | ||
} | ||
return line; | ||
@@ -265,7 +228,5 @@ }); | ||
var line = 'CREATE'; | ||
if (index.unique) { | ||
line += ' UNIQUE'; | ||
} | ||
var indexName = index.name ? "[".concat(index.name, "]") : "".concat((0, _utils.shouldPrintSchema)(schema, model) ? "[".concat(schema.name, "].") : '', "[").concat(table.name, "_index_").concat(i, "]"); | ||
@@ -277,3 +238,2 @@ line += " INDEX ".concat(indexName, " ON ").concat((0, _utils.shouldPrintSchema)(schema, model) ? "[".concat(schema.name, "].") : '', "[").concat(table.name, "]"); | ||
var columnStr = ''; | ||
if (column.type === 'expression') { | ||
@@ -284,3 +244,2 @@ columnStr = "(".concat(column.value, ")"); | ||
} | ||
columnArr.push(columnStr); | ||
@@ -302,3 +261,2 @@ }); | ||
line = 'EXEC sp_addextendedproperty\n'; | ||
switch (comment.type) { | ||
@@ -313,3 +271,2 @@ case 'table': | ||
} | ||
case 'column': | ||
@@ -325,7 +282,5 @@ { | ||
} | ||
default: | ||
break; | ||
} | ||
line += 'GO\n'; | ||
@@ -346,28 +301,21 @@ return line; | ||
var tableIds = schema.tableIds, | ||
refIds = schema.refIds; | ||
refIds = schema.refIds; | ||
if ((0, _utils.shouldPrintSchema)(schema, model)) { | ||
prevStatements.schemas.push("CREATE SCHEMA [".concat(schema.name, "]\nGO\n")); | ||
} | ||
if (!_lodash["default"].isEmpty(tableIds)) { | ||
var _prevStatements$table; | ||
(_prevStatements$table = prevStatements.tables).push.apply(_prevStatements$table, _toConsumableArray(SqlServerExporter.exportTables(tableIds, model))); | ||
} | ||
var indexIds = _lodash["default"].flatten(tableIds.map(function (tableId) { | ||
return model.tables[tableId].indexIds; | ||
})); | ||
if (!_lodash["default"].isEmpty(indexIds)) { | ||
var _prevStatements$index; | ||
(_prevStatements$index = prevStatements.indexes).push.apply(_prevStatements$index, _toConsumableArray(SqlServerExporter.exportIndexes(indexIds, model))); | ||
} | ||
var commentNodes = _lodash["default"].flatten(tableIds.map(function (tableId) { | ||
var _model$tables$tableId = model.tables[tableId], | ||
fieldIds = _model$tables$tableId.fieldIds, | ||
note = _model$tables$tableId.note; | ||
fieldIds = _model$tables$tableId.fieldIds, | ||
note = _model$tables$tableId.note; | ||
var fieldObjects = fieldIds.filter(function (fieldId) { | ||
@@ -387,15 +335,10 @@ return model.fields[fieldId].note; | ||
})); | ||
if (!_lodash["default"].isEmpty(commentNodes)) { | ||
var _prevStatements$comme; | ||
(_prevStatements$comme = prevStatements.comments).push.apply(_prevStatements$comme, _toConsumableArray(SqlServerExporter.exportComments(commentNodes, model))); | ||
} | ||
if (!_lodash["default"].isEmpty(refIds)) { | ||
var _prevStatements$refs; | ||
(_prevStatements$refs = prevStatements.refs).push.apply(_prevStatements$refs, _toConsumableArray(SqlServerExporter.exportRefs(refIds, model, usedTableNames))); | ||
} | ||
return prevStatements; | ||
@@ -410,13 +353,9 @@ }, { | ||
}); | ||
var res = _lodash["default"].concat(statements.schemas, statements.enums, statements.tables, statements.indexes, statements.comments, statements.refs).join('\n'); | ||
return res; | ||
} | ||
}]); | ||
return SqlServerExporter; | ||
}(); | ||
var _default = SqlServerExporter; | ||
exports["default"] = _default; |
@@ -6,18 +6,14 @@ "use strict"; | ||
}); | ||
exports.hasWhiteSpace = hasWhiteSpace; | ||
exports.shouldPrintSchema = shouldPrintSchema; | ||
exports.buildJunctionFields1 = buildJunctionFields1; | ||
exports.buildJunctionFields2 = buildJunctionFields2; | ||
exports.buildNewTableName = buildNewTableName; | ||
exports.hasWhiteSpace = hasWhiteSpace; | ||
exports.shouldPrintSchema = shouldPrintSchema; | ||
var _config = require("../model_structure/config"); | ||
function hasWhiteSpace(s) { | ||
return /\s/g.test(s); | ||
} | ||
function shouldPrintSchema(schema, model) { | ||
return schema.name !== _config.DEFAULT_SCHEMA_NAME || schema.name === _config.DEFAULT_SCHEMA_NAME && model.database['1'].hasDefaultSchema; | ||
} | ||
function buildJunctionFields1(fieldIds, model) { | ||
@@ -30,3 +26,2 @@ var fieldsMap = new Map(); | ||
} | ||
function buildJunctionFields2(fieldIds, model, firstTableFieldsMap) { | ||
@@ -37,3 +32,2 @@ var fieldsMap = new Map(); | ||
var count = 1; | ||
while (firstTableFieldsMap.has(fieldName)) { | ||
@@ -43,3 +37,2 @@ fieldName = "".concat(model.tables[model.fields[fieldId].tableId].name, "_").concat(model.fields[fieldId].name, "(").concat(count, ")"); | ||
} | ||
fieldsMap.set(fieldName, model.fields[fieldId].type.type_name); | ||
@@ -49,7 +42,5 @@ }); | ||
} | ||
function buildNewTableName(firstTable, secondTable, usedTableNames) { | ||
var newTableName = "".concat(firstTable, "_").concat(secondTable); | ||
var count = 1; | ||
while (usedTableNames.has(newTableName)) { | ||
@@ -59,5 +50,4 @@ newTableName = "".concat(firstTable, "_").concat(secondTable, "(").concat(count, ")"); | ||
} | ||
usedTableNames.add(newTableName); | ||
return newTableName; | ||
} |
@@ -7,17 +7,10 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _Parser = _interopRequireDefault(require("../parse/Parser")); | ||
var _ModelExporter = _interopRequireDefault(require("../export/ModelExporter")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _import(str, format) { | ||
var database = _Parser["default"].parse(str, format); | ||
var dbml = _ModelExporter["default"]["export"](database.normalize(), 'dbml'); | ||
return dbml; | ||
} | ||
var _default = { | ||
@@ -24,0 +17,0 @@ "import": _import |
@@ -18,23 +18,18 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "importer", { | ||
Object.defineProperty(exports, "exporter", { | ||
enumerable: true, | ||
get: function get() { | ||
return _import["default"]; | ||
return _export["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "exporter", { | ||
Object.defineProperty(exports, "importer", { | ||
enumerable: true, | ||
get: function get() { | ||
return _export["default"]; | ||
return _import["default"]; | ||
} | ||
}); | ||
var _ModelExporter = _interopRequireDefault(require("./export/ModelExporter")); | ||
var _Parser = _interopRequireDefault(require("./parse/Parser")); | ||
var _import = _interopRequireDefault(require("./import")); | ||
var _export = _interopRequireDefault(require("./export")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.TABLE_GROUP = exports.REF = exports.ENUM = exports.TABLE = exports.DEFAULT_SCHEMA_NAME = void 0; | ||
exports.TABLE_GROUP = exports.TABLE = exports.REF = exports.ENUM = exports.DEFAULT_SCHEMA_NAME = void 0; | ||
var DEFAULT_SCHEMA_NAME = 'public'; | ||
@@ -9,0 +9,0 @@ exports.DEFAULT_SCHEMA_NAME = DEFAULT_SCHEMA_NAME; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,81 +8,50 @@ value: true | ||
exports["default"] = void 0; | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _schema = _interopRequireDefault(require("./schema")); | ||
var _ref2 = _interopRequireDefault(require("./ref")); | ||
var _enum2 = _interopRequireDefault(require("./enum")); | ||
var _tableGroup = _interopRequireDefault(require("./tableGroup")); | ||
var _table = _interopRequireDefault(require("./table")); | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _config = require("./config"); | ||
var _dbState = _interopRequireDefault(require("./dbState")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Database = /*#__PURE__*/function (_Element) { | ||
_inherits(Database, _Element); | ||
var _super = _createSuper(Database); | ||
function Database(_ref) { | ||
var _this; | ||
var _ref$schemas = _ref.schemas, | ||
schemas = _ref$schemas === void 0 ? [] : _ref$schemas, | ||
_ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$enums = _ref.enums, | ||
enums = _ref$enums === void 0 ? [] : _ref$enums, | ||
_ref$refs = _ref.refs, | ||
refs = _ref$refs === void 0 ? [] : _ref$refs, | ||
_ref$tableGroups = _ref.tableGroups, | ||
tableGroups = _ref$tableGroups === void 0 ? [] : _ref$tableGroups, | ||
_ref$project = _ref.project, | ||
project = _ref$project === void 0 ? {} : _ref$project, | ||
_ref$aliases = _ref.aliases, | ||
aliases = _ref$aliases === void 0 ? [] : _ref$aliases; | ||
schemas = _ref$schemas === void 0 ? [] : _ref$schemas, | ||
_ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$enums = _ref.enums, | ||
enums = _ref$enums === void 0 ? [] : _ref$enums, | ||
_ref$refs = _ref.refs, | ||
refs = _ref$refs === void 0 ? [] : _ref$refs, | ||
_ref$tableGroups = _ref.tableGroups, | ||
tableGroups = _ref$tableGroups === void 0 ? [] : _ref$tableGroups, | ||
_ref$project = _ref.project, | ||
project = _ref$project === void 0 ? {} : _ref$project, | ||
_ref$aliases = _ref.aliases, | ||
aliases = _ref$aliases === void 0 ? [] : _ref$aliases; | ||
_classCallCheck(this, Database); | ||
_this = _super.call(this); | ||
_this.dbState = new _dbState["default"](); | ||
_this.generateId(); | ||
_this.hasDefaultSchema = false; | ||
@@ -93,17 +63,12 @@ _this.schemas = []; | ||
_this.name = project.name; | ||
_this.aliases = aliases; // The process order is important. Do not change ! | ||
_this.aliases = aliases; | ||
// The process order is important. Do not change ! | ||
_this.processSchemas(schemas); | ||
_this.processSchemaElements(enums, _config.ENUM); | ||
_this.processSchemaElements(tables, _config.TABLE); | ||
_this.processSchemaElements(refs, _config.REF); | ||
_this.processSchemaElements(tableGroups, _config.TABLE_GROUP); | ||
return _this; | ||
} | ||
_createClass(Database, [{ | ||
@@ -118,3 +83,2 @@ key: "generateId", | ||
var _this2 = this; | ||
rawSchemas.forEach(function (schema) { | ||
@@ -145,3 +109,2 @@ _this2.pushSchema(new _schema["default"](_objectSpread(_objectSpread({}, schema), {}, { | ||
var _this3 = this; | ||
var schema; | ||
@@ -151,4 +114,4 @@ elements.forEach(function (element) { | ||
schema = _this3.findOrCreateSchema(element.schemaName); | ||
if (element.schemaName === _config.DEFAULT_SCHEMA_NAME) {// this.hasDefaultSchema = true; | ||
if (element.schemaName === _config.DEFAULT_SCHEMA_NAME) { | ||
// this.hasDefaultSchema = true; | ||
} | ||
@@ -158,3 +121,2 @@ } else { | ||
} | ||
switch (elementType) { | ||
@@ -166,3 +128,2 @@ case _config.TABLE: | ||
break; | ||
case _config.ENUM: | ||
@@ -173,3 +134,2 @@ schema.pushEnum(new _enum2["default"](_objectSpread(_objectSpread({}, element), {}, { | ||
break; | ||
case _config.TABLE_GROUP: | ||
@@ -180,3 +140,2 @@ schema.pushTableGroup(new _tableGroup["default"](_objectSpread(_objectSpread({}, element), {}, { | ||
break; | ||
case _config.REF: | ||
@@ -187,3 +146,2 @@ schema.pushRef(new _ref2["default"](_objectSpread(_objectSpread({}, element), {}, { | ||
break; | ||
default: | ||
@@ -199,4 +157,4 @@ break; | ||
return s.name === schemaName || s.alias === schemaName; | ||
}); // create new schema if schema not found | ||
}); | ||
// create new schema if schema not found | ||
if (!schema) { | ||
@@ -212,3 +170,2 @@ schema = new _schema["default"]({ | ||
} | ||
return schema; | ||
@@ -238,3 +195,2 @@ } | ||
var table = null; | ||
if (!schemaName) { | ||
@@ -244,9 +200,6 @@ table = this.findTableAlias(tableName); | ||
} | ||
var schema = this.findOrCreateSchema(schemaName || _config.DEFAULT_SCHEMA_NAME); | ||
if (!schema) { | ||
this.error("Schema ".concat(schemaName || _config.DEFAULT_SCHEMA_NAME, " don't exist")); | ||
} | ||
return schema.findTable(tableName); | ||
@@ -261,7 +214,5 @@ } | ||
if (!schema) return null; | ||
var _enum = schema.enums.find(function (e) { | ||
return e.name === name; | ||
}); | ||
return _enum; | ||
@@ -326,7 +277,5 @@ } | ||
}]); | ||
return Database; | ||
}(_element["default"]); | ||
var _default = Database; | ||
exports["default"] = _default; |
@@ -7,13 +7,11 @@ "use strict"; | ||
exports["default"] = void 0; | ||
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); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var DbState = /*#__PURE__*/function () { | ||
function DbState() { | ||
_classCallCheck(this, DbState); | ||
this.dbId = 1; | ||
@@ -31,3 +29,2 @@ this.schemaId = 1; | ||
} | ||
_createClass(DbState, [{ | ||
@@ -41,6 +38,4 @@ key: "generateId", | ||
}]); | ||
return DbState; | ||
}(); | ||
exports["default"] = DbState; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
exports["default"] = void 0; | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } | ||
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); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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); } | ||
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); } | ||
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; } } | ||
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); } | ||
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; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
/* eslint-disable */ | ||
var ElementError = /*#__PURE__*/function (_Error) { | ||
_inherits(ElementError, _Error); | ||
var _super = _createSuper(ElementError); | ||
function ElementError(message) { | ||
var _this; | ||
var location = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { | ||
@@ -51,5 +35,3 @@ start: { | ||
}; | ||
_classCallCheck(this, ElementError); | ||
_this = _super.call(this, message); | ||
@@ -59,13 +41,9 @@ _this.location = location; | ||
} | ||
return ElementError; | ||
return _createClass(ElementError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
var Element = /*#__PURE__*/function () { | ||
function Element(token) { | ||
_classCallCheck(this, Element); | ||
this.token = token; | ||
} | ||
_createClass(Element, [{ | ||
@@ -82,9 +60,6 @@ key: "bind", | ||
}]); | ||
return Element; | ||
}(); | ||
var _default = Element; | ||
/* eslint-enable */ | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,68 +8,39 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _config = require("./config"); | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Endpoint = /*#__PURE__*/function (_Element) { | ||
_inherits(Endpoint, _Element); | ||
var _super = _createSuper(Endpoint); | ||
function Endpoint(_ref) { | ||
var _this; | ||
var tableName = _ref.tableName, | ||
schemaName = _ref.schemaName, | ||
fieldNames = _ref.fieldNames, | ||
relation = _ref.relation, | ||
token = _ref.token, | ||
ref = _ref.ref; | ||
schemaName = _ref.schemaName, | ||
fieldNames = _ref.fieldNames, | ||
relation = _ref.relation, | ||
token = _ref.token, | ||
ref = _ref.ref; | ||
_classCallCheck(this, Endpoint); | ||
_this = _super.call(this, token); | ||
@@ -82,19 +54,13 @@ _this.relation = relation; | ||
_this.dbState = _this.ref.dbState; | ||
_this.generateId(); // Use name of schema,table and field object | ||
_this.generateId(); | ||
// Use name of schema,table and field object | ||
// Name in constructor could be alias | ||
var schema = ref.schema.database.findOrCreateSchema(schemaName || _config.DEFAULT_SCHEMA_NAME); | ||
var table = schema.database.findTable(schemaName, tableName); | ||
if (!table) { | ||
_this.error("Can't find table ".concat((0, _utils.shouldPrintSchemaName)(schemaName) ? "\"".concat(schemaName, "\".") : '', "\"").concat(tableName, "\"")); | ||
} | ||
_this.setFields(fieldNames, table); | ||
return _this; | ||
} | ||
_createClass(Endpoint, [{ | ||
@@ -120,7 +86,5 @@ key: "generateId", | ||
}).sort(); | ||
for (var i = 0; i < sortedThisFieldIds.length; i += 1) { | ||
if (sortedThisFieldIds[i] !== sortedEndpointFieldIds[i]) return false; | ||
} | ||
return true; | ||
@@ -157,5 +121,3 @@ } | ||
var _this2 = this; | ||
var newFieldNames = fieldNames && fieldNames.length ? _toConsumableArray(fieldNames) : []; | ||
if (!newFieldNames.length) { | ||
@@ -165,3 +127,2 @@ var fieldHasPK = table.fields.find(function (field) { | ||
}); | ||
if (fieldHasPK) { | ||
@@ -173,3 +134,2 @@ newFieldNames.push(fieldHasPK.name); | ||
}); | ||
if (indexHasPK) { | ||
@@ -184,12 +144,8 @@ newFieldNames = indexHasPK.columns.map(function (column) { | ||
} | ||
newFieldNames.forEach(function (fieldName) { | ||
var field = table.findField(fieldName); | ||
if (!field) { | ||
_this2.error("Can't find field ".concat((0, _utils.shouldPrintSchema)(table.schema) ? "\"".concat(table.schema.name, "\".") : '', "\"").concat(fieldName, "\" in table \"").concat(table.name, "\"")); | ||
} | ||
_this2.fields.push(field); | ||
field.pushEndpoint(_this2); | ||
@@ -206,7 +162,5 @@ }); | ||
}]); | ||
return Endpoint; | ||
}(_element["default"]); | ||
var _default = Endpoint; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,62 +8,37 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _enumValue = _interopRequireDefault(require("./enumValue")); | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Enum = /*#__PURE__*/function (_Element) { | ||
_inherits(Enum, _Element); | ||
var _super = _createSuper(Enum); | ||
function Enum() { | ||
var _this; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
name = _ref.name, | ||
token = _ref.token, | ||
values = _ref.values, | ||
note = _ref.note, | ||
schema = _ref.schema; | ||
name = _ref.name, | ||
token = _ref.token, | ||
values = _ref.values, | ||
note = _ref.note, | ||
schema = _ref.schema; | ||
_classCallCheck(this, Enum); | ||
_this = _super.call(this, token); | ||
if (!name) { | ||
_this.error('Enum must have a name'); | ||
} | ||
_this.name = name; | ||
@@ -75,10 +51,6 @@ _this.note = note ? note.value : null; | ||
_this.dbState = _this.schema.dbState; | ||
_this.generateId(); | ||
_this.processValues(values); | ||
return _this; | ||
} | ||
_createClass(Enum, [{ | ||
@@ -93,3 +65,2 @@ key: "generateId", | ||
var _this2 = this; | ||
rawValues.forEach(function (value) { | ||
@@ -183,7 +154,5 @@ _this2.pushValue(new _enumValue["default"](_objectSpread(_objectSpread({}, value), {}, { | ||
}]); | ||
return Enum; | ||
}(_element["default"]); | ||
var _default = Enum; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,57 +8,34 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var EnumValue = /*#__PURE__*/function (_Element) { | ||
_inherits(EnumValue, _Element); | ||
var _super = _createSuper(EnumValue); | ||
function EnumValue() { | ||
var _this; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
name = _ref.name, | ||
token = _ref.token, | ||
note = _ref.note, | ||
_enum = _ref._enum; | ||
name = _ref.name, | ||
token = _ref.token, | ||
note = _ref.note, | ||
_enum = _ref._enum; | ||
_classCallCheck(this, EnumValue); | ||
_this = _super.call(this, token); | ||
if (!name) { | ||
_this.error('Enum value must have a name'); | ||
} | ||
_this.name = name; | ||
@@ -68,8 +46,5 @@ _this.note = note ? note.value : null; | ||
_this.dbState = _this._enum.dbState; | ||
_this.generateId(); | ||
return _this; | ||
} | ||
_createClass(EnumValue, [{ | ||
@@ -108,7 +83,5 @@ key: "generateId", | ||
}]); | ||
return EnumValue; | ||
}(_element["default"]); | ||
var _default = EnumValue; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,72 +8,47 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _config = require("./config"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Field = /*#__PURE__*/function (_Element) { | ||
_inherits(Field, _Element); | ||
var _super = _createSuper(Field); | ||
function Field() { | ||
var _this; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
name = _ref.name, | ||
type = _ref.type, | ||
unique = _ref.unique, | ||
pk = _ref.pk, | ||
token = _ref.token, | ||
notNull = _ref.not_null, | ||
note = _ref.note, | ||
dbdefault = _ref.dbdefault, | ||
increment = _ref.increment, | ||
_ref$table = _ref.table, | ||
table = _ref$table === void 0 ? {} : _ref$table; | ||
name = _ref.name, | ||
type = _ref.type, | ||
unique = _ref.unique, | ||
pk = _ref.pk, | ||
token = _ref.token, | ||
notNull = _ref.not_null, | ||
note = _ref.note, | ||
dbdefault = _ref.dbdefault, | ||
increment = _ref.increment, | ||
_ref$table = _ref.table, | ||
table = _ref$table === void 0 ? {} : _ref$table; | ||
_classCallCheck(this, Field); | ||
_this = _super.call(this, token); | ||
if (!name) { | ||
_this.error('Field must have a name'); | ||
} | ||
if (!type) { | ||
_this.error('Field must have a type'); | ||
} | ||
_this.name = name; // type : { type_name, value, schemaName } | ||
_this.name = name; | ||
// type : { type_name, value, schemaName } | ||
_this.type = type; | ||
@@ -89,10 +65,6 @@ _this.unique = unique; | ||
_this.dbState = _this.table.dbState; | ||
_this.generateId(); | ||
_this.bindType(); | ||
return _this; | ||
} | ||
_createClass(Field, [{ | ||
@@ -108,6 +80,4 @@ key: "generateId", | ||
var typeSchemaName = this.type.schemaName || _config.DEFAULT_SCHEMA_NAME; | ||
if (this.type.schemaName) { | ||
var _enum = this.table.schema.database.findEnum(typeSchemaName, typeName); | ||
if (!_enum) { | ||
@@ -117,12 +87,8 @@ this.error("Cannot find type ".concat(typeSchemaName, " in schema ").concat(typeSchemaName)); | ||
} | ||
this._enum = _enum; | ||
_enum.pushField(this); | ||
} else { | ||
var _enum2 = this.table.schema.database.findEnum(typeSchemaName, typeName); | ||
if (!_enum2) return; | ||
this._enum = _enum2; | ||
_enum2.pushField(this); | ||
@@ -180,7 +146,5 @@ } | ||
}]); | ||
return Field; | ||
}(_element["default"]); | ||
var _default = Field; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,49 +8,28 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var IndexColumn = /*#__PURE__*/function (_Element) { | ||
_inherits(IndexColumn, _Element); | ||
var _super = _createSuper(IndexColumn); | ||
function IndexColumn(_ref) { | ||
var _this; | ||
var type = _ref.type, | ||
value = _ref.value, | ||
index = _ref.index; | ||
value = _ref.value, | ||
index = _ref.index; | ||
_classCallCheck(this, IndexColumn); | ||
_this = _super.call(this); | ||
@@ -60,8 +40,5 @@ _this.type = type; | ||
_this.dbState = _this.index.dbState; | ||
_this.generateId(); | ||
return _this; | ||
} | ||
_createClass(IndexColumn, [{ | ||
@@ -100,7 +77,5 @@ key: "generateId", | ||
}]); | ||
return IndexColumn; | ||
}(_element["default"]); | ||
var _default = IndexColumn; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,58 +8,36 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _indexColumn = _interopRequireDefault(require("./indexColumn")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Index = /*#__PURE__*/function (_Element) { | ||
_inherits(Index, _Element); | ||
var _super = _createSuper(Index); | ||
function Index() { | ||
var _this; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
columns = _ref.columns, | ||
type = _ref.type, | ||
unique = _ref.unique, | ||
pk = _ref.pk, | ||
token = _ref.token, | ||
name = _ref.name, | ||
note = _ref.note, | ||
_ref$table = _ref.table, | ||
table = _ref$table === void 0 ? {} : _ref$table; | ||
columns = _ref.columns, | ||
type = _ref.type, | ||
unique = _ref.unique, | ||
pk = _ref.pk, | ||
token = _ref.token, | ||
name = _ref.name, | ||
note = _ref.note, | ||
_ref$table = _ref.table, | ||
table = _ref$table === void 0 ? {} : _ref$table; | ||
_classCallCheck(this, Index); | ||
_this = _super.call(this, token); | ||
@@ -74,10 +53,6 @@ _this.name = name; | ||
_this.dbState = _this.table.dbState; | ||
_this.generateId(); | ||
_this.processIndexColumns(columns); | ||
return _this; | ||
} | ||
_createClass(Index, [{ | ||
@@ -92,3 +67,2 @@ key: "generateId", | ||
var _this2 = this; | ||
rawColumns.forEach(function (column) { | ||
@@ -167,7 +141,5 @@ _this2.pushIndexColumn(new _indexColumn["default"](_objectSpread(_objectSpread({}, column), {}, { | ||
}]); | ||
return Index; | ||
}(_element["default"]); | ||
var _default = Index; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,39 +8,21 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _endpoint = _interopRequireDefault(require("./endpoint")); | ||
var _config = require("./config"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
/** | ||
@@ -54,22 +37,16 @@ * Compare two pairs of objects | ||
} | ||
var Ref = /*#__PURE__*/function (_Element) { | ||
_inherits(Ref, _Element); | ||
var _super = _createSuper(Ref); | ||
function Ref() { | ||
var _this; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
name = _ref.name, | ||
endpoints = _ref.endpoints, | ||
onDelete = _ref.onDelete, | ||
onUpdate = _ref.onUpdate, | ||
token = _ref.token, | ||
_ref$schema = _ref.schema, | ||
schema = _ref$schema === void 0 ? {} : _ref$schema; | ||
name = _ref.name, | ||
endpoints = _ref.endpoints, | ||
onDelete = _ref.onDelete, | ||
onUpdate = _ref.onUpdate, | ||
token = _ref.token, | ||
_ref$schema = _ref.schema, | ||
schema = _ref$schema === void 0 ? {} : _ref$schema; | ||
_classCallCheck(this, Ref); | ||
_this = _super.call(this, token); | ||
@@ -82,10 +59,6 @@ _this.name = name; | ||
_this.dbState = _this.schema.dbState; | ||
_this.generateId(); | ||
_this.processEndpoints(endpoints); | ||
return _this; | ||
} | ||
_createClass(Ref, [{ | ||
@@ -100,3 +73,2 @@ key: "generateId", | ||
var _this2 = this; | ||
rawEndpoints.forEach(function (endpoint) { | ||
@@ -106,15 +78,13 @@ _this2.endpoints.push(new _endpoint["default"](_objectSpread(_objectSpread({}, endpoint), {}, { | ||
}))); | ||
if (endpoint.schemaName === _config.DEFAULT_SCHEMA_NAME) {// this.schema.database.hasDefaultSchema = true; | ||
if (endpoint.schemaName === _config.DEFAULT_SCHEMA_NAME) { | ||
// this.schema.database.hasDefaultSchema = true; | ||
} | ||
}); | ||
if (this.endpoints[0].equals(this.endpoints[1])) { | ||
this.error('Two endpoints are the same'); | ||
} | ||
if (this.endpoints[0].fields.length !== this.endpoints[1].fields.length) { | ||
this.error('Two endpoints have unequal number of fields'); | ||
} // TODO: Handle Error with different number of fields | ||
} | ||
// TODO: Handle Error with different number of fields | ||
} | ||
@@ -176,7 +146,5 @@ }, { | ||
}]); | ||
return Ref; | ||
}(_element["default"]); | ||
var _default = Ref; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,71 +8,45 @@ value: true | ||
exports["default"] = void 0; | ||
var _table = _interopRequireDefault(require("./table")); | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _enum2 = _interopRequireDefault(require("./enum")); | ||
var _utils = require("./utils"); | ||
var _tableGroup = _interopRequireDefault(require("./tableGroup")); | ||
var _ref2 = _interopRequireDefault(require("./ref")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Schema = /*#__PURE__*/function (_Element) { | ||
_inherits(Schema, _Element); | ||
var _super = _createSuper(Schema); | ||
function Schema() { | ||
var _this; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
name = _ref.name, | ||
alias = _ref.alias, | ||
note = _ref.note, | ||
_ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$refs = _ref.refs, | ||
refs = _ref$refs === void 0 ? [] : _ref$refs, | ||
_ref$enums = _ref.enums, | ||
enums = _ref$enums === void 0 ? [] : _ref$enums, | ||
_ref$tableGroups = _ref.tableGroups, | ||
tableGroups = _ref$tableGroups === void 0 ? [] : _ref$tableGroups, | ||
token = _ref.token, | ||
_ref$database = _ref.database, | ||
database = _ref$database === void 0 ? {} : _ref$database; | ||
name = _ref.name, | ||
alias = _ref.alias, | ||
note = _ref.note, | ||
_ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$refs = _ref.refs, | ||
refs = _ref$refs === void 0 ? [] : _ref$refs, | ||
_ref$enums = _ref.enums, | ||
enums = _ref$enums === void 0 ? [] : _ref$enums, | ||
_ref$tableGroups = _ref.tableGroups, | ||
tableGroups = _ref$tableGroups === void 0 ? [] : _ref$tableGroups, | ||
token = _ref.token, | ||
_ref$database = _ref.database, | ||
database = _ref$database === void 0 ? {} : _ref$database; | ||
_classCallCheck(this, Schema); | ||
_this = _super.call(this, token); | ||
@@ -88,16 +63,9 @@ _this.tables = []; | ||
_this.dbState = _this.database.dbState; | ||
_this.generateId(); | ||
_this.processEnums(enums); | ||
_this.processTables(tables); | ||
_this.processRefs(refs); | ||
_this.processTableGroups(tableGroups); | ||
return _this; | ||
} | ||
_createClass(Schema, [{ | ||
@@ -112,3 +80,2 @@ key: "generateId", | ||
var _this2 = this; | ||
rawTables.forEach(function (table) { | ||
@@ -146,3 +113,2 @@ _this2.pushTable(new _table["default"](_objectSpread(_objectSpread({}, table), {}, { | ||
var _this3 = this; | ||
rawEnums.forEach(function (_enum) { | ||
@@ -173,3 +139,2 @@ _this3.pushEnum(new _enum2["default"](_objectSpread(_objectSpread({}, _enum), {}, { | ||
var _this4 = this; | ||
rawRefs.forEach(function (ref) { | ||
@@ -206,3 +171,2 @@ _this4.pushRef(new _ref2["default"](_objectSpread(_objectSpread({}, ref), {}, { | ||
var _this5 = this; | ||
rawTableGroups.forEach(function (tableGroup) { | ||
@@ -311,7 +275,5 @@ _this5.pushTableGroup(new _tableGroup["default"](_objectSpread(_objectSpread({}, tableGroup), {}, { | ||
}]); | ||
return Schema; | ||
}(_element["default"]); | ||
var _default = Schema; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,66 +8,41 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _field = _interopRequireDefault(require("./field")); | ||
var _indexes = _interopRequireDefault(require("./indexes")); | ||
var _config = require("./config"); | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var Table = /*#__PURE__*/function (_Element) { | ||
_inherits(Table, _Element); | ||
var _super = _createSuper(Table); | ||
function Table() { | ||
var _this; | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
name = _ref.name, | ||
alias = _ref.alias, | ||
note = _ref.note, | ||
_ref$fields = _ref.fields, | ||
fields = _ref$fields === void 0 ? [] : _ref$fields, | ||
_ref$indexes = _ref.indexes, | ||
indexes = _ref$indexes === void 0 ? [] : _ref$indexes, | ||
_ref$schema = _ref.schema, | ||
schema = _ref$schema === void 0 ? {} : _ref$schema, | ||
token = _ref.token, | ||
headerColor = _ref.headerColor; | ||
name = _ref.name, | ||
alias = _ref.alias, | ||
note = _ref.note, | ||
_ref$fields = _ref.fields, | ||
fields = _ref$fields === void 0 ? [] : _ref$fields, | ||
_ref$indexes = _ref.indexes, | ||
indexes = _ref$indexes === void 0 ? [] : _ref$indexes, | ||
_ref$schema = _ref.schema, | ||
schema = _ref$schema === void 0 ? {} : _ref$schema, | ||
token = _ref.token, | ||
headerColor = _ref.headerColor; | ||
_classCallCheck(this, Table); | ||
_this = _super.call(this, token); | ||
@@ -82,12 +58,7 @@ _this.name = name; | ||
_this.dbState = _this.schema.dbState; | ||
_this.generateId(); | ||
_this.processFields(fields); | ||
_this.processIndexes(indexes); | ||
return _this; | ||
} | ||
_createClass(Table, [{ | ||
@@ -102,7 +73,5 @@ key: "generateId", | ||
var _this2 = this; | ||
if (rawFields.length === 0) { | ||
this.error('Table must have at least one field'); | ||
} | ||
rawFields.forEach(function (field) { | ||
@@ -133,3 +102,2 @@ _this2.pushField(new _field["default"](_objectSpread(_objectSpread({}, field), {}, { | ||
var _this3 = this; | ||
rawIndexes.forEach(function (index) { | ||
@@ -151,3 +119,2 @@ _this3.pushIndex(new _indexes["default"](_objectSpread(_objectSpread({}, index), {}, { | ||
var _this4 = this; | ||
index.columns.forEach(function (column) { | ||
@@ -232,7 +199,5 @@ if (column.type === 'column' && !_this4.findField(column.value)) { | ||
}]); | ||
return Table; | ||
}(_element["default"]); | ||
var _default = Table; | ||
exports["default"] = _default; |
"use strict"; | ||
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); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,54 +8,32 @@ value: true | ||
exports["default"] = void 0; | ||
var _element = _interopRequireDefault(require("./element")); | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
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; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
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); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
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); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
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); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
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; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var TableGroup = /*#__PURE__*/function (_Element) { | ||
_inherits(TableGroup, _Element); | ||
var _super = _createSuper(TableGroup); | ||
function TableGroup(_ref) { | ||
var _this; | ||
var name = _ref.name, | ||
token = _ref.token, | ||
_ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$schema = _ref.schema, | ||
schema = _ref$schema === void 0 ? {} : _ref$schema; | ||
token = _ref.token, | ||
_ref$tables = _ref.tables, | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$schema = _ref.schema, | ||
schema = _ref$schema === void 0 ? {} : _ref$schema; | ||
_classCallCheck(this, TableGroup); | ||
_this = _super.call(this, token); | ||
@@ -65,10 +44,6 @@ _this.name = name; | ||
_this.dbState = _this.schema.dbState; | ||
_this.generateId(); | ||
_this.processTables(tables); | ||
return _this; | ||
} | ||
_createClass(TableGroup, [{ | ||
@@ -83,10 +58,7 @@ key: "generateId", | ||
var _this2 = this; | ||
rawTables.forEach(function (rawTable) { | ||
var table = _this2.schema.database.findTable(rawTable.schemaName, rawTable.name); | ||
if (!table) { | ||
_this2.error("Table ".concat(rawTable.schemaName ? "\"".concat(rawTable.schemaName, "\".") : '').concat(rawTable.name, " don't exist")); | ||
} | ||
_this2.pushTable(table); | ||
@@ -110,3 +82,2 @@ }); | ||
} | ||
if (table.group) { | ||
@@ -164,7 +135,5 @@ this.error("Table ".concat((0, _utils.shouldPrintSchema)(table.schema) ? "\"".concat(table.schema.name, "\".") : '', ".").concat(table.name, " is already in group ").concat((0, _utils.shouldPrintSchema)(table.group.schema) ? "\"".concat(table.group.schema.name, "\".") : '').concat(table.group.name)); | ||
}]); | ||
return TableGroup; | ||
}(_element["default"]); | ||
var _default = TableGroup; | ||
exports["default"] = _default; |
@@ -8,11 +8,8 @@ "use strict"; | ||
exports.shouldPrintSchemaName = shouldPrintSchemaName; | ||
var _config = require("./config"); | ||
function shouldPrintSchema(schema) { | ||
return schema.name !== _config.DEFAULT_SCHEMA_NAME || schema.name === _config.DEFAULT_SCHEMA_NAME && schema.database.hasDefaultSchema; | ||
} | ||
function shouldPrintSchemaName(schemaName) { | ||
return schemaName !== _config.DEFAULT_SCHEMA_NAME; | ||
} |
"use strict"; | ||
var _pegjsRequireImport = _interopRequireDefault(require("pegjs-require-import")); | ||
var _bluebird = _interopRequireDefault(require("bluebird")); | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _path = _interopRequireDefault(require("path")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /* eslint-disable */ /* eslint-enable */ | ||
_bluebird["default"].promisifyAll(_fs["default"]); | ||
function buildParserFile(_x, _x2) { | ||
return _buildParserFile.apply(this, arguments); | ||
} | ||
function _buildParserFile() { | ||
_buildParserFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(source, fileName) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", _fs["default"].writeFileAsync(_path["default"].resolve(__dirname, fileName), source)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
_buildParserFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(source, fileName) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", _fs["default"].writeFileAsync(_path["default"].resolve(__dirname, fileName), source)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
@@ -40,3 +30,2 @@ }, _callee); | ||
} | ||
var options = { | ||
@@ -54,3 +43,2 @@ format: 'commonjs', | ||
var schemarbParserSource = (0, _pegjsRequireImport["default"])('./schemarb/parser.pegjs', options); | ||
_bluebird["default"].all([buildParserFile(mysqlParserSource, 'mysqlParser.js'), buildParserFile(postgresParserSource, 'postgresParser.js'), buildParserFile(dbmlParserSource, 'dbmlParser.js'), buildParserFile(schemarbParserSource, 'schemarbParser.js')]).then(function () { | ||
@@ -57,0 +45,0 @@ console.log('Build parsers completed!'); |
"use strict"; | ||
var P = require('parsimmon'); | ||
var _require = require('./utils'), | ||
makeList = _require.makeList, | ||
streamline = _require.streamline; | ||
makeList = _require.makeList, | ||
streamline = _require.streamline; | ||
var KP = require('./keyword_parsers'); | ||
var wss = require('./whitespaces'); | ||
var _pIgnore = P(function (input, i) { | ||
@@ -17,3 +13,2 @@ var j = i; | ||
var encloseChar = ''; | ||
while (j < input.length && (isEnclosed || !input.slice(j, j + 2).match(/GO|;/i))) { | ||
@@ -27,5 +22,3 @@ if (isEnclosed && input[j].match(/\]|'|"/i) && input[j] === encloseChar) { | ||
} | ||
if (!input[j].match(/\s/)) j += 1; | ||
while (j < input.length && input[j].match(/\s/)) { | ||
@@ -35,7 +28,5 @@ j += 1; | ||
} | ||
if (input.slice(j, j + 2).match(/GO/i)) j -= 1; | ||
return P.makeSuccess(j + 1, ''); | ||
}); | ||
var Lang = P.createLanguage({ | ||
@@ -42,0 +33,0 @@ pIgnore: function pIgnore() { |
"use strict"; | ||
var _ = require('lodash'); | ||
function makeDataType(typeName, args) { | ||
@@ -16,3 +15,2 @@ var argsString = args ? args.join(',') : null; | ||
} | ||
function makeColumn(fieldName, dataType, fieldSettings) { | ||
@@ -31,3 +29,2 @@ var value = {}; | ||
} | ||
module.exports = { | ||
@@ -34,0 +31,0 @@ makeColumn: makeColumn, |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../keyword_parsers'); | ||
var _require = require('../base_parsers'), | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pIdentifier = _require.pIdentifier, | ||
pNumberList = _require.pNumberList, | ||
pOptionList = _require.pOptionList; | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pIdentifier = _require.pIdentifier, | ||
pNumberList = _require.pNumberList, | ||
pOptionList = _require.pOptionList; | ||
var _require2 = require('../utils'), | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList, | ||
streamline = _require2.streamline; | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList, | ||
streamline = _require2.streamline; | ||
var _require3 = require('../index_definition'), | ||
pColumnIndex = _require3.pColumnIndex; | ||
pColumnIndex = _require3.pColumnIndex; | ||
var _require4 = require('../constraint_definition'), | ||
pColumnConstraint = _require4.pColumnConstraint; | ||
pColumnConstraint = _require4.pColumnConstraint; | ||
var pExpression = require('../expression'); | ||
var A = require('./actions'); | ||
var Lang = P.createLanguage({ | ||
@@ -29,0 +21,0 @@ ColumnsDefinition: function ColumnsDefinition(r) { |
"use strict"; | ||
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; } | ||
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; } | ||
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; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
function makeDefaultConstraint(_keyword, constExpression) { | ||
var value = {}; | ||
if (constExpression.type) { | ||
@@ -19,3 +18,2 @@ switch (constExpression.type) { | ||
break; | ||
default: | ||
@@ -28,3 +26,2 @@ value.type = 'expression'; | ||
} | ||
value.value = constExpression.value; | ||
@@ -36,3 +33,2 @@ return { | ||
} | ||
function makeConstraintCheckEnum(fieldName, _ununsed, values) { | ||
@@ -52,3 +48,2 @@ var valuesProp = []; | ||
fieldName: fieldName // for alter table add enum | ||
} | ||
@@ -67,3 +62,2 @@ }; | ||
} | ||
module.exports = { | ||
@@ -70,0 +64,0 @@ makeConstraintCheckEnum: makeConstraintCheckEnum, |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../keyword_parsers'); | ||
var pExpression = require('../expression'); | ||
var _require = require('../base_parsers'), | ||
pIdentifier = _require.pIdentifier, | ||
pConst = _require.pConst, | ||
pFunction = _require.pFunction; | ||
pIdentifier = _require.pIdentifier, | ||
pConst = _require.pConst, | ||
pFunction = _require.pFunction; | ||
var _require2 = require('../utils'), | ||
makeList = _require2.makeList, | ||
streamline = _require2.streamline, | ||
makeNode = _require2.makeNode; | ||
makeList = _require2.makeList, | ||
streamline = _require2.streamline, | ||
makeNode = _require2.makeNode; | ||
var _require3 = require('../fk_definition'), | ||
pColumnConstraintFK = _require3.pColumnConstraintFK, | ||
pTableConstraintFK = _require3.pTableConstraintFK; | ||
pColumnConstraintFK = _require3.pColumnConstraintFK, | ||
pTableConstraintFK = _require3.pTableConstraintFK; | ||
var _require4 = require('../index_definition'), | ||
pColumnConstraintIndex = _require4.pColumnConstraintIndex, | ||
pTableConstraintIndex = _require4.pTableConstraintIndex; | ||
pColumnConstraintIndex = _require4.pColumnConstraintIndex, | ||
pTableConstraintIndex = _require4.pTableConstraintIndex; | ||
var A = require('./actions'); | ||
var Lang = P.createLanguage({ | ||
@@ -30,0 +22,0 @@ TableConstraint: function TableConstraint(r) { |
"use strict"; | ||
var P = require('parsimmon'); | ||
var _ = require('lodash'); | ||
var _require = require('./base_parsers'), | ||
pFunction = _require.pFunction, | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pConst = _require.pConst; | ||
pFunction = _require.pFunction, | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pConst = _require.pConst; | ||
var _require2 = require('./keyword_parsers'), | ||
LParen = _require2.LParen, | ||
RParen = _require2.RParen; | ||
LParen = _require2.LParen, | ||
RParen = _require2.RParen; | ||
var wss = require('./whitespaces'); | ||
var _require3 = require('./utils'), | ||
streamline = _require3.streamline; | ||
streamline = _require3.streamline; | ||
function tokenizeParen(parser) { | ||
@@ -26,3 +20,2 @@ return parser.many().map(function (value) { | ||
} | ||
function enclose(parser) { | ||
@@ -33,7 +26,5 @@ var ManyRParen = RParen.thru(tokenizeParen); | ||
} | ||
function enclosedOrNot(parser) { | ||
return P.alt(enclose(parser), parser); | ||
} | ||
var Lang = P.createLanguage({ | ||
@@ -43,3 +34,2 @@ ExpressionFinal: function ExpressionFinal(r) { | ||
var flattened = _.flattenDeep(values); | ||
return flattened.map(function (value) { | ||
@@ -46,0 +36,0 @@ return value ? value.value : ''; |
"use strict"; | ||
var _ = require('lodash'); | ||
var _require = require('../utils'), | ||
getFullTableName = _require.getFullTableName; | ||
getFullTableName = _require.getFullTableName; | ||
function makeEndPoint(tableName, columnName, relation) { | ||
@@ -16,3 +14,2 @@ return { | ||
} | ||
function setOption(value, fkOptions) { | ||
@@ -23,3 +20,2 @@ fkOptions.forEach(function (option) { | ||
} | ||
if (option.type.match(/ON[^\S\r\n]UPDATE/i)) { | ||
@@ -30,3 +26,2 @@ value.onUpdate = option.setting; | ||
} | ||
function makeColumnConstraintFK(_unused, tableName, columnName, fkOptions) { | ||
@@ -42,3 +37,2 @@ var value = {}; | ||
} | ||
function makeTableEndpoint(columnNames) { | ||
@@ -52,7 +46,5 @@ return { | ||
} | ||
function makeTableConstraintFK(_keyword1, endpoint1, _keyword2, tableName, endpoint2, fkOptions) { | ||
var value = {}; | ||
var fullTableName = getFullTableName(tableName); | ||
if (!endpoint2) { | ||
@@ -68,3 +60,2 @@ // Omits columns list, see: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-ver16#foreign-key-constraints | ||
} | ||
endpoint1.value.relation = '*'; | ||
@@ -81,3 +72,2 @@ endpoint2.value.relation = '1'; | ||
} | ||
function makeOnSetting(type, setting) { | ||
@@ -89,3 +79,2 @@ return { | ||
} | ||
module.exports = { | ||
@@ -92,0 +81,0 @@ makeOnSetting: makeOnSetting, |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../keyword_parsers'); | ||
var _require = require('../base_parsers'), | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pIdentifier = _require.pIdentifier, | ||
pColumnNames = _require.pColumnNames; | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pIdentifier = _require.pIdentifier, | ||
pColumnNames = _require.pColumnNames; | ||
var _require2 = require('../utils'), | ||
makeList = _require2.makeList, | ||
makeNode = _require2.makeNode; | ||
makeList = _require2.makeList, | ||
makeNode = _require2.makeNode; | ||
var A = require('./actions'); | ||
var Lang = P.createLanguage({ | ||
@@ -19,0 +14,0 @@ TableConstraintFK: function TableConstraintFK(r) { |
@@ -22,3 +22,2 @@ "use strict"; | ||
} | ||
function makeColumnIndex(_keyword, indexName) { | ||
@@ -33,11 +32,8 @@ return { | ||
} | ||
function makeTableIndex(_keyword, indexName, isUnique, _clustered, _columnstore, columnNames) { | ||
return makeIndex(columnNames, isUnique, null, indexName); | ||
} | ||
function makeTableConstraintIndex(keyword, _keyword, columnNames) { | ||
var isPk = null; | ||
var isUnique = null; | ||
if (keyword.type === 'pk') { | ||
@@ -48,6 +44,4 @@ isPk = true; | ||
} | ||
return makeIndex(columnNames, isUnique, isPk); | ||
} | ||
module.exports = { | ||
@@ -54,0 +48,0 @@ makeTableIndex: makeTableIndex, |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../keyword_parsers'); | ||
var _require = require('../base_parsers'), | ||
pIdentifier = _require.pIdentifier, | ||
pKeywordClusteredOrNon = _require.pKeywordClusteredOrNon, | ||
pFunction = _require.pFunction, | ||
pOptionList = _require.pOptionList, | ||
pColumnNames = _require.pColumnNames, | ||
pKeywordPKOrUnique = _require.pKeywordPKOrUnique, | ||
pOption = _require.pOption; | ||
pIdentifier = _require.pIdentifier, | ||
pKeywordClusteredOrNon = _require.pKeywordClusteredOrNon, | ||
pFunction = _require.pFunction, | ||
pOptionList = _require.pOptionList, | ||
pColumnNames = _require.pColumnNames, | ||
pKeywordPKOrUnique = _require.pKeywordPKOrUnique, | ||
pOption = _require.pOption; | ||
var _require2 = require('../utils'), | ||
makeNode = _require2.makeNode; | ||
makeNode = _require2.makeNode; | ||
var A = require('./actions'); | ||
var Lang = P.createLanguage({ | ||
@@ -22,0 +17,0 @@ TableIndex: function TableIndex(r) { |
"use strict"; | ||
var mssqlParser = require('./statements'); | ||
mssqlParser.parseWithPegError = function (input) { | ||
@@ -18,8 +17,7 @@ try { | ||
var expectedString = "".concat(err.result.expected.join(', '), ", or ").concat(lastExpected); | ||
pegJSError.message = "Expected ".concat(expectedString, " but \"").concat(pegJSError.found, "\" found."); // eslint-disable-next-line no-console | ||
pegJSError.message = "Expected ".concat(expectedString, " but \"").concat(pegJSError.found, "\" found."); | ||
// eslint-disable-next-line no-console | ||
throw pegJSError; | ||
} | ||
}; | ||
module.exports = mssqlParser; |
"use strict"; | ||
var _require = require('./keyword_utils'), | ||
keyword = _require.keyword, | ||
word = _require.word; | ||
keyword = _require.keyword, | ||
word = _require.word; | ||
exports.KeywordIdentity = keyword(/IDENTITY/i); | ||
@@ -8,0 +7,0 @@ exports.KeywordIndex = keyword(/INDEX/i); |
"use strict"; | ||
var P = require('parsimmon'); | ||
var wss = require('./whitespaces'); | ||
exports.word = function (string) { | ||
return P.string(string).skip(wss).desc("\"".concat(string, "\"")); | ||
}; | ||
function replaceWhitespaceWithRegexp(regexp) { | ||
@@ -17,3 +14,2 @@ var string = String(regexp); | ||
} | ||
exports.keyword = function (regexp) { | ||
@@ -20,0 +16,0 @@ var newRegexp = regexp; |
"use strict"; | ||
var _ = require('lodash'); | ||
function findTable(ast, tableName, schemaName) { | ||
@@ -13,3 +12,2 @@ var realSchemaName = schemaName || 'public'; | ||
} | ||
function findField(table, fieldName) { | ||
@@ -20,3 +18,2 @@ return table.fields.find(function (_field) { | ||
} | ||
function handleIndexes(index, ast) { | ||
@@ -27,3 +24,2 @@ var table = findTable(ast, index.tableName, index.schemaName); | ||
} | ||
function pushOut(values, astProp) { | ||
@@ -34,3 +30,2 @@ values.forEach(function (value) { | ||
} | ||
function handleTable(table, ast) { | ||
@@ -45,3 +40,2 @@ pushOut(table.enums, ast.enums); | ||
} | ||
function handleDefaults(dbdefault, ast) { | ||
@@ -54,3 +48,2 @@ var table = findTable(ast, dbdefault.tableName, dbdefault.schemaName); | ||
} | ||
function handleEnums(_enum, ast) { | ||
@@ -67,7 +60,5 @@ var table = findTable(ast, _enum.tableName, _enum.schemaName); | ||
} | ||
function handleTableNote(comment, ast) { | ||
var schemaName = comment.schemaName; | ||
if (schemaName === 'dbo') schemaName = null; // treat `dbo` as public schema | ||
var foundTable = findTable(ast, comment.tableName, schemaName); | ||
@@ -78,9 +69,6 @@ if (foundTable) foundTable.note = comment.note ? { | ||
} | ||
function handleFieldNote(comment, ast) { | ||
var schemaName = comment.schemaName; | ||
if (schemaName === 'dbo') schemaName = null; // treat `dbo` as public schema | ||
var foundTable = findTable(ast, comment.tableName, schemaName); | ||
if (foundTable) { | ||
@@ -93,7 +81,5 @@ var foundField = findField(foundTable, comment.columnName); | ||
} | ||
function handleComment(comment, ast) { | ||
if (comment.type === 'table') handleTableNote(comment, ast);else if (comment.type === 'column') handleFieldNote(comment, ast); | ||
} | ||
function handleStatement(_statements) { | ||
@@ -106,8 +92,5 @@ var ast = { | ||
}; | ||
var statements = _.flatten(_statements); | ||
statements.forEach(function (statement) { | ||
if (!statement) return; | ||
switch (statement.type) { | ||
@@ -118,23 +101,17 @@ case 'tables': | ||
// from alter table add | ||
case 'indexes': | ||
handleIndexes(statement.value, ast); | ||
break; | ||
case 'dbdefault': | ||
handleDefaults(statement.value, ast); | ||
break; | ||
case 'enums': | ||
handleEnums(statement.value, ast); | ||
break; | ||
case 'comment': | ||
handleComment(statement.value, ast); | ||
break; | ||
default: | ||
break; | ||
} | ||
if (statement.type && ast[statement.type]) ast[statement.type].push(statement.value); | ||
@@ -145,5 +122,4 @@ }); | ||
} | ||
module.exports = { | ||
handleStatement: handleStatement | ||
}; |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../keyword_parsers'); | ||
var S = require('./statement_types'); | ||
var wss = require('../whitespaces'); | ||
var A = require('./actions'); | ||
var _require = require('../base_parsers'), | ||
pIgnore = _require.pIgnore; | ||
pIgnore = _require.pIgnore; | ||
var Lang = P.createLanguage({ | ||
@@ -17,0 +11,0 @@ Statements: function Statements(r) { |
"use strict"; | ||
var _ = require('lodash'); | ||
var _require = require('../../../utils'), | ||
getFullTableName = _require.getFullTableName; | ||
getFullTableName = _require.getFullTableName; | ||
function handleRef(tableName, result) { | ||
@@ -15,3 +13,2 @@ var endpointWithNoTableName = result.value.endpoints.find(function (ele) { | ||
} | ||
function addTableName(tableName, result) { | ||
@@ -21,7 +18,6 @@ result.value.tableName = tableName.name; | ||
} | ||
function handleAlterTableResult(_keyword, tableName, results) { | ||
if (!results) return null; | ||
var fullName = getFullTableName(tableName); // eslint-disable-next-line consistent-return | ||
var fullName = getFullTableName(tableName); | ||
// eslint-disable-next-line consistent-return | ||
results.forEach(function (result) { | ||
@@ -33,3 +29,2 @@ if (result) { | ||
break; | ||
case 'indexes': | ||
@@ -40,3 +35,2 @@ case 'dbdefault': | ||
break; | ||
default: | ||
@@ -49,5 +43,4 @@ break; | ||
} | ||
module.exports = { | ||
handleAlterTableResult: handleAlterTableResult | ||
}; |
"use strict"; | ||
var _require = require('../../../../constraint_definition'), | ||
makeTableConstraint = _require.makeTableConstraint; // eslint-disable-next-line no-unused-vars | ||
makeTableConstraint = _require.makeTableConstraint; | ||
// eslint-disable-next-line no-unused-vars | ||
function makeDefault(_keyword, constExpression, _for, fieldName, _withValues) { | ||
var value = {}; | ||
if (constExpression.type) { | ||
@@ -17,3 +16,2 @@ switch (constExpression.type) { | ||
break; | ||
default: | ||
@@ -26,3 +24,2 @@ value.type = 'expression'; | ||
} | ||
value.value = constExpression.value; | ||
@@ -35,3 +32,2 @@ value.fieldName = fieldName; | ||
} | ||
module.exports = { | ||
@@ -38,0 +34,0 @@ makeTableConstraint: makeTableConstraint, |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../../../../keyword_parsers'); | ||
var _require = require('../../../../base_parsers'), | ||
pIdentifier = _require.pIdentifier; | ||
pIdentifier = _require.pIdentifier; | ||
var _require2 = require('../../../../utils'), | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList; | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList; | ||
var A = require('./actions'); | ||
var _require3 = require('../../../../fk_definition'), | ||
pTableConstraintFK = _require3.pTableConstraintFK; | ||
pTableConstraintFK = _require3.pTableConstraintFK; | ||
var _require4 = require('../../../../index_definition'), | ||
pTableConstraintIndex = _require4.pTableConstraintIndex; | ||
pTableConstraintIndex = _require4.pTableConstraintIndex; | ||
var _require5 = require('../../../../constraint_definition'), | ||
pConstraintCheck = _require5.pConstraintCheck, | ||
pConstExpr = _require5.pConstExpr, | ||
pConstraintName = _require5.pConstraintName; | ||
pConstraintCheck = _require5.pConstraintCheck, | ||
pConstExpr = _require5.pConstExpr, | ||
pConstraintName = _require5.pConstraintName; | ||
var _require6 = require('../../../../column_definition'), | ||
pColumnsDefinition = _require6.pColumnsDefinition; | ||
pColumnsDefinition = _require6.pColumnsDefinition; | ||
var Lang = P.createLanguage({ | ||
@@ -31,0 +22,0 @@ AddAction: function AddAction(r) { |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../../../keyword_parsers'); | ||
var _require = require('../../../base_parsers'), | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pIgnore = _require.pIgnore; | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pIgnore = _require.pIgnore; | ||
var A = require('./actions'); | ||
var pAddAction = require('./add'); | ||
var Lang = P.createLanguage({ | ||
@@ -16,0 +11,0 @@ AlterTable: function AlterTable(r) { |
@@ -6,22 +6,17 @@ "use strict"; | ||
}; | ||
var isTable = function isTable(type) { | ||
return type.toLowerCase() === 'table'; | ||
}; | ||
var isColumn = function isColumn(type) { | ||
return type.toLowerCase() === 'column'; | ||
}; | ||
var isValidTableNote = function isValidTableNote(level) { | ||
return level.length === 2 && isSchema(level[0].type) && isTable(level[1].type); | ||
}; | ||
var isValidColumnNote = function isValidColumnNote(level) { | ||
return level.length === 3 && isSchema(level[0].type) && isTable(level[1].type) && isColumn(level[2].type); | ||
}; | ||
function handleComment(_ref) { | ||
var note = _ref.note, | ||
level = _ref.level; | ||
level = _ref.level; | ||
var type = 'unsupported'; | ||
@@ -31,7 +26,6 @@ var schemaName = null; | ||
var columnName = null; | ||
if (isValidTableNote(level)) { | ||
schemaName = level[0].name; | ||
tableName = level[1].name; // Table Comment | ||
tableName = level[1].name; | ||
// Table Comment | ||
type = 'table'; | ||
@@ -44,3 +38,2 @@ } else if (isValidColumnNote(level)) { | ||
} | ||
return { | ||
@@ -57,5 +50,4 @@ type: 'comment', | ||
} | ||
module.exports = { | ||
handleComment: handleComment | ||
}; |
"use strict"; | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
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); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
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; } | ||
var P = require('parsimmon'); | ||
var KP = require('../../../keyword_parsers'); | ||
var A = require('./actions'); | ||
var _require = require('../../../utils'), | ||
makeNode = _require.makeNode; | ||
makeNode = _require.makeNode; | ||
var Lang = P.createLanguage({ | ||
@@ -25,0 +15,0 @@ StartComment: function StartComment() { |
"use strict"; | ||
var _require = require('../../../utils'), | ||
getFullTableName = _require.getFullTableName; | ||
getFullTableName = _require.getFullTableName; | ||
function makeIndex(_create, isUnique, _clustered, _index, indexName, _on, tableName, columnNames) { | ||
@@ -26,5 +25,4 @@ var fullTableName = getFullTableName(tableName); | ||
} | ||
module.exports = { | ||
makeIndex: makeIndex | ||
}; |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../../../keyword_parsers'); | ||
var _require = require('../../../base_parsers'), | ||
pIdentifier = _require.pIdentifier, | ||
pKeywordClusteredOrNon = _require.pKeywordClusteredOrNon, | ||
pConst = _require.pConst, | ||
pColumnNames = _require.pColumnNames, | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pComparsionOp = _require.pComparsionOp; | ||
pIdentifier = _require.pIdentifier, | ||
pKeywordClusteredOrNon = _require.pKeywordClusteredOrNon, | ||
pConst = _require.pConst, | ||
pColumnNames = _require.pColumnNames, | ||
pDotDelimitedName = _require.pDotDelimitedName, | ||
pComparsionOp = _require.pComparsionOp; | ||
var _require2 = require('../../../utils'), | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList; | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList; | ||
var A = require('./actions'); | ||
var _require3 = require('../../../index_definition'), | ||
pIgnoredIndexOption = _require3.pIgnoredIndexOption; | ||
pIgnoredIndexOption = _require3.pIgnoredIndexOption; | ||
var Lang = P.createLanguage({ | ||
@@ -25,0 +19,0 @@ CreateIndex: function CreateIndex(r) { |
"use strict"; | ||
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; } | ||
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; } | ||
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; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var _ = require('lodash'); | ||
var _require = require('../../../utils'), | ||
getFullTableName = _require.getFullTableName; | ||
getFullTableName = _require.getFullTableName; | ||
function createRefFromInlineRef(linesRefs, inlineRefs, fieldName, tableName) { | ||
@@ -27,11 +25,8 @@ if (!inlineRefs || inlineRefs.length === 0) return; | ||
}); | ||
if (!inlineRef.endpoint.fieldNames) { | ||
inlineRef.endpoint.fieldNames = newRef.endpoints[0].fieldNames; | ||
} | ||
newRef.endpoints.push(inlineRef.endpoint); | ||
linesRefs.push(newRef); | ||
} | ||
function pushOutEnum(linesEnums, fieldValue, tableName) { | ||
@@ -50,3 +45,2 @@ if (fieldValue.enums) { | ||
} | ||
function pushOutIndex(linesIndexes, fieldValue) { | ||
@@ -62,3 +56,2 @@ if (fieldValue.indexes) { | ||
} | ||
function getLinesValue(lines, tableName) { | ||
@@ -78,3 +71,2 @@ var value = { | ||
} | ||
if (line.type === 'refs') { | ||
@@ -85,3 +77,2 @@ var ref = line.value; | ||
} | ||
value[line.type].push(line.value); | ||
@@ -95,3 +86,2 @@ } | ||
} | ||
function makeTable(_keyword, tableName, _keyword2, lines) { | ||
@@ -105,5 +95,4 @@ var fullName = getFullTableName(tableName); | ||
} | ||
module.exports = { | ||
makeTable: makeTable | ||
}; |
"use strict"; | ||
var P = require('parsimmon'); | ||
var KP = require('../../../keyword_parsers'); | ||
var _require = require('../../../base_parsers'), | ||
pIdentifier = _require.pIdentifier, | ||
pDotDelimitedName = _require.pDotDelimitedName; | ||
pIdentifier = _require.pIdentifier, | ||
pDotDelimitedName = _require.pDotDelimitedName; | ||
var _require2 = require('../../../utils'), | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList; | ||
makeNode = _require2.makeNode, | ||
makeList = _require2.makeList; | ||
var _require3 = require('../../../constraint_definition'), | ||
pTableConstraint = _require3.pTableConstraint; | ||
pTableConstraint = _require3.pTableConstraint; | ||
var _require4 = require('../../../index_definition'), | ||
pTableIndex = _require4.pTableIndex, | ||
pIgnoredIndexOption = _require4.pIgnoredIndexOption; | ||
pTableIndex = _require4.pTableIndex, | ||
pIgnoredIndexOption = _require4.pIgnoredIndexOption; | ||
var _require5 = require('../../../column_definition'), | ||
pColumnsDefinition = _require5.pColumnsDefinition; | ||
pColumnsDefinition = _require5.pColumnsDefinition; | ||
var A = require('./actions'); | ||
var Lang = P.createLanguage({ | ||
@@ -28,0 +20,0 @@ CreateTable: function CreateTable(r) { |
"use strict"; | ||
var pAlterTable = require('./alter_table'); | ||
var pCreateIndex = require('./create_index/index'); | ||
var pCreateTable = require('./create_table'); | ||
var pCommentSyntax = require('./comments'); | ||
module.exports = { | ||
@@ -12,0 +8,0 @@ pAlterTable: pAlterTable, |
"use strict"; | ||
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); } | ||
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); } | ||
var P = require('parsimmon'); | ||
var _ = require('lodash'); | ||
var _require = require('./keyword_parsers'), | ||
LParen = _require.LParen, | ||
RParen = _require.RParen, | ||
Comma = _require.Comma; | ||
LParen = _require.LParen, | ||
RParen = _require.RParen, | ||
Comma = _require.Comma; | ||
var wss = require('./whitespaces'); | ||
exports.makeNode = function () { | ||
@@ -31,3 +26,2 @@ return function (parser) { | ||
}; | ||
exports.makeList = function (parser) { | ||
@@ -41,3 +35,2 @@ var isZero = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
}; | ||
exports.streamline = function (type) { | ||
@@ -55,10 +48,7 @@ return function (parser) { | ||
}; | ||
exports.getFullTableName = function (nameList) { | ||
var schemaName = null; | ||
if (nameList.length > 1) { | ||
schemaName = nameList[nameList.length - 2]; | ||
} | ||
return { | ||
@@ -65,0 +55,0 @@ name: _.last(nameList), |
"use strict"; | ||
var P = require('parsimmon'); | ||
var Lang = P.createLanguage({ | ||
@@ -6,0 +5,0 @@ WhiteSpaces: function WhiteSpaces(r) { |
@@ -7,8 +7,5 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _mssql = _interopRequireDefault(require("./mssql")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _default = _mssql["default"]; | ||
exports["default"] = _default; |
@@ -7,25 +7,15 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _database = _interopRequireDefault(require("../model_structure/database")); | ||
var _mysqlParser = _interopRequireDefault(require("./mysqlParser")); | ||
var _postgresParser = _interopRequireDefault(require("./postgresParser")); | ||
var _dbmlParser = _interopRequireDefault(require("./dbmlParser")); | ||
var _schemarbParser = _interopRequireDefault(require("./schemarbParser")); | ||
var _mssqlParser = _interopRequireDefault(require("./mssqlParser")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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); } | ||
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); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
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); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var Parser = /*#__PURE__*/function () { | ||
@@ -35,3 +25,2 @@ function Parser() { | ||
} | ||
_createClass(Parser, null, [{ | ||
@@ -72,3 +61,2 @@ key: "parseJSONToDatabase", | ||
var rawDatabase = {}; | ||
switch (format) { | ||
@@ -78,19 +66,14 @@ case 'mysql': | ||
break; | ||
case 'postgres': | ||
rawDatabase = Parser.parsePostgresToJSON(str); | ||
break; | ||
case 'dbml': | ||
rawDatabase = Parser.parseDBMLToJSON(str); | ||
break; | ||
case 'schemarb': | ||
rawDatabase = Parser.parseSchemaRbToJSON(str); | ||
break; | ||
case 'mssql': | ||
rawDatabase = Parser.parseMSSQLToJSON(str); | ||
break; | ||
case 'json': | ||
@@ -102,9 +85,6 @@ if (_typeof(str) === 'object') { | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
var schema = Parser.parseJSONToDatabase(rawDatabase); | ||
@@ -114,7 +94,5 @@ return schema; | ||
}]); | ||
return Parser; | ||
}(); | ||
var _default = Parser; | ||
exports["default"] = _default; |
"use strict"; | ||
var _pegjsRequireImport = _interopRequireDefault(require("pegjs-require-import")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _pegjsRequire = (0, _pegjsRequireImport["default"])('./parser.pegjs', { | ||
format: 'commonjs', | ||
dependencies: { | ||
_: 'lodash' | ||
} | ||
}), | ||
sourceCode = _pegjsRequire.sourceCode; | ||
format: 'commonjs', | ||
dependencies: { | ||
_: 'lodash' | ||
} | ||
}), | ||
sourceCode = _pegjsRequire.sourceCode; | ||
console.log(sourceCode); |
@@ -6,13 +6,13 @@ /* | ||
*/ | ||
"use strict"; | ||
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; } | ||
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; } | ||
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; } | ||
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); } | ||
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; } | ||
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; } | ||
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; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
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); } | ||
var _ = require("lodash"), | ||
pluralize = require("pluralize"); | ||
pluralize = require("pluralize"); | ||
function peg$subclass(child, parent) { | ||
@@ -22,7 +22,5 @@ function ctor() { | ||
} | ||
ctor.prototype = parent.prototype; | ||
child.prototype = new ctor(); | ||
} | ||
function peg$SyntaxError(message, expected, found, location) { | ||
@@ -34,3 +32,2 @@ this.message = message; | ||
this.name = "SyntaxError"; | ||
if (typeof Error.captureStackTrace === "function") { | ||
@@ -40,5 +37,3 @@ Error.captureStackTrace(this, peg$SyntaxError); | ||
} | ||
peg$subclass(peg$SyntaxError, Error); | ||
peg$SyntaxError.buildMessage = function (expected, found) { | ||
@@ -51,8 +46,6 @@ var DESCRIBE_EXPECTATION_FNS = { | ||
var escapedParts = "", | ||
i; | ||
i; | ||
for (i = 0; i < expectation.parts.length; i++) { | ||
escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); | ||
} | ||
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; | ||
@@ -70,7 +63,5 @@ }, | ||
}; | ||
function hex(ch) { | ||
return ch.charCodeAt(0).toString(16).toUpperCase(); | ||
} | ||
function literalEscape(s) { | ||
@@ -83,3 +74,2 @@ return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) { | ||
} | ||
function classEscape(s) { | ||
@@ -92,18 +82,13 @@ return s.replace(/\\/g, '\\\\').replace(/\]/g, '\\]').replace(/\^/g, '\\^').replace(/-/g, '\\-').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) { | ||
} | ||
function describeExpectation(expectation) { | ||
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); | ||
} | ||
function describeExpected(expected) { | ||
var descriptions = new Array(expected.length), | ||
i, | ||
j; | ||
i, | ||
j; | ||
for (i = 0; i < expected.length; i++) { | ||
descriptions[i] = describeExpectation(expected[i]); | ||
} | ||
descriptions.sort(); | ||
if (descriptions.length > 0) { | ||
@@ -116,13 +101,9 @@ for (i = 1, j = 1; i < descriptions.length; i++) { | ||
} | ||
descriptions.length = j; | ||
} | ||
switch (descriptions.length) { | ||
case 1: | ||
return descriptions[0]; | ||
case 2: | ||
return descriptions[0] + " or " + descriptions[1]; | ||
default: | ||
@@ -132,216 +113,211 @@ return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; | ||
} | ||
function describeFound(found) { | ||
return found ? "\"" + literalEscape(found) + "\"" : "end of input"; | ||
} | ||
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; | ||
}; | ||
function peg$parse(input, options) { | ||
options = options !== void 0 ? options : {}; | ||
var peg$FAILED = {}, | ||
peg$startRuleFunctions = { | ||
schema: peg$parseschema | ||
}, | ||
peg$startRuleFunction = peg$parseschema, | ||
peg$c0 = function peg$c0() { | ||
return implicityRef(data); | ||
}, | ||
peg$c1 = function peg$c1(tableData) { | ||
var table = tableData.table, | ||
peg$startRuleFunctions = { | ||
schema: peg$parseschema | ||
}, | ||
peg$startRuleFunction = peg$parseschema, | ||
peg$c0 = function peg$c0() { | ||
return implicityRef(data); | ||
}, | ||
peg$c1 = function peg$c1(tableData) { | ||
var table = tableData.table, | ||
refs = tableData.refs; | ||
pushTable(table); | ||
pushRefs(refs); | ||
}, | ||
peg$c2 = function peg$c2(r) { | ||
pushRef(r); | ||
}, | ||
peg$c3 = ",", | ||
peg$c4 = peg$literalExpectation(",", false), | ||
peg$c5 = function peg$c5(fromTable, toTable, props) { | ||
var foreign = refactorForeign(createForeign(fromTable, toTable, props)); | ||
return foreign; | ||
}, | ||
peg$c6 = ":", | ||
peg$c7 = peg$literalExpectation(":", false), | ||
peg$c8 = function peg$c8(columnName) { | ||
return { | ||
columnName: columnName | ||
}; | ||
}, | ||
peg$c9 = function peg$c9(primaryKey) { | ||
return { | ||
primaryKey: primaryKey | ||
}; | ||
}, | ||
peg$c10 = function peg$c10(r, value) { | ||
switch (r.toLowerCase()) { | ||
case 'on_delete': | ||
return { | ||
onDelete: value.split('_').join(' ') | ||
}; | ||
case 'on_update': | ||
return { | ||
onUpdate: value.split('_').join(' ') | ||
}; | ||
} | ||
}, | ||
peg$c11 = function peg$c11(name, body) { | ||
var table = { | ||
name: name, | ||
fields: addPrimaryKey(body.fields) // index: _.union(...body.index) | ||
}; | ||
return { | ||
table: table, | ||
refs: createRefFromTableWithReference(table, body.references) | ||
}; | ||
}, | ||
peg$c12 = function peg$c12(fields) { | ||
return { | ||
fields: fields.filter(function (field) { | ||
return field.isField; | ||
}).map(function (field) { | ||
return field.field; | ||
}), | ||
index: fields.filter(function (field) { | ||
return field.isIndex; | ||
}).map(function (field) { | ||
return field.index; | ||
}), | ||
references: fields.filter(function (field) { | ||
return field.isReferences; | ||
}).map(function (field) { | ||
return field.reference; | ||
}) | ||
}; | ||
}, | ||
peg$c13 = function peg$c13(field) { | ||
return field; | ||
}, | ||
peg$c14 = function peg$c14(reference) { | ||
return { | ||
reference: reference, | ||
isReferences: true | ||
}; | ||
}, | ||
peg$c15 = function peg$c15(field) { | ||
return { | ||
field: field, | ||
isField: true | ||
}; | ||
}, | ||
peg$c16 = function peg$c16(reference) { | ||
return reference; | ||
}, | ||
peg$c17 = function peg$c17(type, name) { | ||
return { | ||
name: name, | ||
type: { | ||
type_name: type | ||
pushTable(table); | ||
pushRefs(refs); | ||
}, | ||
peg$c2 = function peg$c2(r) { | ||
pushRef(r); | ||
}, | ||
peg$c3 = ",", | ||
peg$c4 = peg$literalExpectation(",", false), | ||
peg$c5 = function peg$c5(fromTable, toTable, props) { | ||
var foreign = refactorForeign(createForeign(fromTable, toTable, props)); | ||
return foreign; | ||
}, | ||
peg$c6 = ":", | ||
peg$c7 = peg$literalExpectation(":", false), | ||
peg$c8 = function peg$c8(columnName) { | ||
return { | ||
columnName: columnName | ||
}; | ||
}, | ||
peg$c9 = function peg$c9(primaryKey) { | ||
return { | ||
primaryKey: primaryKey | ||
}; | ||
}, | ||
peg$c10 = function peg$c10(r, value) { | ||
switch (r.toLowerCase()) { | ||
case 'on_delete': | ||
return { | ||
onDelete: value.split('_').join(' ') | ||
}; | ||
case 'on_update': | ||
return { | ||
onUpdate: value.split('_').join(' ') | ||
}; | ||
} | ||
}; | ||
}, | ||
peg$c18 = function peg$c18(reference) { | ||
return reference; | ||
}, | ||
peg$c19 = "on_delete", | ||
peg$c20 = peg$literalExpectation("on_delete", true), | ||
peg$c21 = "on_update", | ||
peg$c22 = peg$literalExpectation("on_update", true), | ||
peg$c23 = peg$otherExpectation("add index"), | ||
peg$c24 = "add_index", | ||
peg$c25 = peg$literalExpectation("add_index", false), | ||
peg$c26 = peg$otherExpectation("schema define"), | ||
peg$c27 = "ActiveRecord::Schema.define", | ||
peg$c28 = peg$literalExpectation("ActiveRecord::Schema.define", false), | ||
peg$c29 = peg$otherExpectation("create table"), | ||
peg$c30 = "create_table", | ||
peg$c31 = peg$literalExpectation("create_table", true), | ||
peg$c32 = peg$otherExpectation("do |t|"), | ||
peg$c33 = peg$otherExpectation("index"), | ||
peg$c34 = ".index", | ||
peg$c35 = peg$literalExpectation(".index", false), | ||
peg$c36 = peg$otherExpectation("references"), | ||
peg$c37 = ".references", | ||
peg$c38 = peg$literalExpectation(".references", false), | ||
peg$c39 = peg$otherExpectation("add foreign key"), | ||
peg$c40 = "add_foreign_key", | ||
peg$c41 = peg$literalExpectation("add_foreign_key", true), | ||
peg$c42 = peg$otherExpectation("column"), | ||
peg$c43 = "column", | ||
peg$c44 = peg$literalExpectation("column", false), | ||
peg$c45 = peg$otherExpectation("primary key"), | ||
peg$c46 = "primary_key", | ||
peg$c47 = peg$literalExpectation("primary_key", false), | ||
peg$c48 = "version", | ||
peg$c49 = peg$literalExpectation("version", false), | ||
peg$c50 = "do", | ||
peg$c51 = peg$literalExpectation("do", false), | ||
peg$c52 = "end", | ||
peg$c53 = peg$literalExpectation("end", false), | ||
peg$c54 = peg$otherExpectation("lambda function"), | ||
peg$c55 = "=>", | ||
peg$c56 = peg$literalExpectation("=>", false), | ||
peg$c57 = "->", | ||
peg$c58 = peg$literalExpectation("->", false), | ||
peg$c59 = /^[^"\n]/, | ||
peg$c60 = peg$classExpectation(["\"", "\n"], true, false), | ||
peg$c61 = function peg$c61(c) { | ||
return c.join(""); | ||
}, | ||
peg$c62 = /^[^'\n]/, | ||
peg$c63 = peg$classExpectation(["'", "\n"], true, false), | ||
peg$c64 = ".", | ||
peg$c65 = peg$literalExpectation(".", false), | ||
peg$c66 = peg$anyExpectation(), | ||
peg$c67 = function peg$c67() { | ||
return text(); | ||
}, | ||
peg$c68 = /^[0-9]/i, | ||
peg$c69 = peg$classExpectation([["0", "9"]], false, true), | ||
peg$c70 = peg$otherExpectation("letter, number or underscore"), | ||
peg$c71 = /^[a-z0-9_.]/i, | ||
peg$c72 = peg$classExpectation([["a", "z"], ["0", "9"], "_", "."], false, true), | ||
peg$c73 = peg$otherExpectation("comment line"), | ||
peg$c74 = "#", | ||
peg$c75 = peg$literalExpectation("#", false), | ||
peg$c76 = peg$otherExpectation("whatever"), | ||
peg$c77 = /^[^\t\r\n]/, | ||
peg$c78 = peg$classExpectation(["\t", "\r", "\n"], true, false), | ||
peg$c79 = "'", | ||
peg$c80 = peg$literalExpectation("'", false), | ||
peg$c81 = "\"", | ||
peg$c82 = peg$literalExpectation("\"", false), | ||
peg$c83 = "|", | ||
peg$c84 = peg$literalExpectation("|", false), | ||
peg$c85 = peg$otherExpectation("comment"), | ||
peg$c86 = "//", | ||
peg$c87 = peg$literalExpectation("//", false), | ||
peg$c88 = /^[^\n]/, | ||
peg$c89 = peg$classExpectation(["\n"], true, false), | ||
peg$c90 = peg$otherExpectation("newline"), | ||
peg$c91 = "\r\n", | ||
peg$c92 = peg$literalExpectation("\r\n", false), | ||
peg$c93 = "\n", | ||
peg$c94 = peg$literalExpectation("\n", false), | ||
peg$c95 = peg$otherExpectation("whitespace"), | ||
peg$c96 = /^[ \t\r\n\r]/, | ||
peg$c97 = peg$classExpectation([" ", "\t", "\r", "\n", "\r"], false, false), | ||
peg$c98 = " ", | ||
peg$c99 = peg$literalExpectation(" ", false), | ||
peg$currPos = 0, | ||
peg$savedPos = 0, | ||
peg$posDetailsCache = [{ | ||
line: 1, | ||
column: 1 | ||
}], | ||
peg$maxFailPos = 0, | ||
peg$maxFailExpected = [], | ||
peg$silentFails = 0, | ||
peg$result; | ||
}, | ||
peg$c11 = function peg$c11(name, body) { | ||
var table = { | ||
name: name, | ||
fields: addPrimaryKey(body.fields) | ||
// index: _.union(...body.index) | ||
}; | ||
return { | ||
table: table, | ||
refs: createRefFromTableWithReference(table, body.references) | ||
}; | ||
}, | ||
peg$c12 = function peg$c12(fields) { | ||
return { | ||
fields: fields.filter(function (field) { | ||
return field.isField; | ||
}).map(function (field) { | ||
return field.field; | ||
}), | ||
index: fields.filter(function (field) { | ||
return field.isIndex; | ||
}).map(function (field) { | ||
return field.index; | ||
}), | ||
references: fields.filter(function (field) { | ||
return field.isReferences; | ||
}).map(function (field) { | ||
return field.reference; | ||
}) | ||
}; | ||
}, | ||
peg$c13 = function peg$c13(field) { | ||
return field; | ||
}, | ||
peg$c14 = function peg$c14(reference) { | ||
return { | ||
reference: reference, | ||
isReferences: true | ||
}; | ||
}, | ||
peg$c15 = function peg$c15(field) { | ||
return { | ||
field: field, | ||
isField: true | ||
}; | ||
}, | ||
peg$c16 = function peg$c16(reference) { | ||
return reference; | ||
}, | ||
peg$c17 = function peg$c17(type, name) { | ||
return { | ||
name: name, | ||
type: { | ||
type_name: type | ||
} | ||
}; | ||
}, | ||
peg$c18 = function peg$c18(reference) { | ||
return reference; | ||
}, | ||
peg$c19 = "on_delete", | ||
peg$c20 = peg$literalExpectation("on_delete", true), | ||
peg$c21 = "on_update", | ||
peg$c22 = peg$literalExpectation("on_update", true), | ||
peg$c23 = peg$otherExpectation("add index"), | ||
peg$c24 = "add_index", | ||
peg$c25 = peg$literalExpectation("add_index", false), | ||
peg$c26 = peg$otherExpectation("schema define"), | ||
peg$c27 = "ActiveRecord::Schema.define", | ||
peg$c28 = peg$literalExpectation("ActiveRecord::Schema.define", false), | ||
peg$c29 = peg$otherExpectation("create table"), | ||
peg$c30 = "create_table", | ||
peg$c31 = peg$literalExpectation("create_table", true), | ||
peg$c32 = peg$otherExpectation("do |t|"), | ||
peg$c33 = peg$otherExpectation("index"), | ||
peg$c34 = ".index", | ||
peg$c35 = peg$literalExpectation(".index", false), | ||
peg$c36 = peg$otherExpectation("references"), | ||
peg$c37 = ".references", | ||
peg$c38 = peg$literalExpectation(".references", false), | ||
peg$c39 = peg$otherExpectation("add foreign key"), | ||
peg$c40 = "add_foreign_key", | ||
peg$c41 = peg$literalExpectation("add_foreign_key", true), | ||
peg$c42 = peg$otherExpectation("column"), | ||
peg$c43 = "column", | ||
peg$c44 = peg$literalExpectation("column", false), | ||
peg$c45 = peg$otherExpectation("primary key"), | ||
peg$c46 = "primary_key", | ||
peg$c47 = peg$literalExpectation("primary_key", false), | ||
peg$c48 = "version", | ||
peg$c49 = peg$literalExpectation("version", false), | ||
peg$c50 = "do", | ||
peg$c51 = peg$literalExpectation("do", false), | ||
peg$c52 = "end", | ||
peg$c53 = peg$literalExpectation("end", false), | ||
peg$c54 = peg$otherExpectation("lambda function"), | ||
peg$c55 = "=>", | ||
peg$c56 = peg$literalExpectation("=>", false), | ||
peg$c57 = "->", | ||
peg$c58 = peg$literalExpectation("->", false), | ||
peg$c59 = /^[^"\n]/, | ||
peg$c60 = peg$classExpectation(["\"", "\n"], true, false), | ||
peg$c61 = function peg$c61(c) { | ||
return c.join(""); | ||
}, | ||
peg$c62 = /^[^'\n]/, | ||
peg$c63 = peg$classExpectation(["'", "\n"], true, false), | ||
peg$c64 = ".", | ||
peg$c65 = peg$literalExpectation(".", false), | ||
peg$c66 = peg$anyExpectation(), | ||
peg$c67 = function peg$c67() { | ||
return text(); | ||
}, | ||
peg$c68 = /^[0-9]/i, | ||
peg$c69 = peg$classExpectation([["0", "9"]], false, true), | ||
peg$c70 = peg$otherExpectation("letter, number or underscore"), | ||
peg$c71 = /^[a-z0-9_.]/i, | ||
peg$c72 = peg$classExpectation([["a", "z"], ["0", "9"], "_", "."], false, true), | ||
peg$c73 = peg$otherExpectation("comment line"), | ||
peg$c74 = "#", | ||
peg$c75 = peg$literalExpectation("#", false), | ||
peg$c76 = peg$otherExpectation("whatever"), | ||
peg$c77 = /^[^\t\r\n]/, | ||
peg$c78 = peg$classExpectation(["\t", "\r", "\n"], true, false), | ||
peg$c79 = "'", | ||
peg$c80 = peg$literalExpectation("'", false), | ||
peg$c81 = "\"", | ||
peg$c82 = peg$literalExpectation("\"", false), | ||
peg$c83 = "|", | ||
peg$c84 = peg$literalExpectation("|", false), | ||
peg$c85 = peg$otherExpectation("comment"), | ||
peg$c86 = "//", | ||
peg$c87 = peg$literalExpectation("//", false), | ||
peg$c88 = /^[^\n]/, | ||
peg$c89 = peg$classExpectation(["\n"], true, false), | ||
peg$c90 = peg$otherExpectation("newline"), | ||
peg$c91 = "\r\n", | ||
peg$c92 = peg$literalExpectation("\r\n", false), | ||
peg$c93 = "\n", | ||
peg$c94 = peg$literalExpectation("\n", false), | ||
peg$c95 = peg$otherExpectation("whitespace"), | ||
peg$c96 = /^[ \t\r\n\r]/, | ||
peg$c97 = peg$classExpectation([" ", "\t", "\r", "\n", "\r"], false, false), | ||
peg$c98 = " ", | ||
peg$c99 = peg$literalExpectation(" ", false), | ||
peg$currPos = 0, | ||
peg$savedPos = 0, | ||
peg$posDetailsCache = [{ | ||
line: 1, | ||
column: 1 | ||
}], | ||
peg$maxFailPos = 0, | ||
peg$maxFailExpected = [], | ||
peg$silentFails = 0, | ||
peg$result; | ||
if ("startRule" in options) { | ||
@@ -351,14 +327,10 @@ if (!(options.startRule in peg$startRuleFunctions)) { | ||
} | ||
peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; | ||
} | ||
function text() { | ||
return input.substring(peg$savedPos, peg$currPos); | ||
} | ||
function location() { | ||
return peg$computeLocation(peg$savedPos, peg$currPos); | ||
} | ||
function expected(description, location) { | ||
@@ -368,3 +340,2 @@ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); | ||
} | ||
function error(message, location) { | ||
@@ -374,3 +345,2 @@ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); | ||
} | ||
function peg$literalExpectation(text, ignoreCase) { | ||
@@ -383,3 +353,2 @@ return { | ||
} | ||
function peg$classExpectation(parts, inverted, ignoreCase) { | ||
@@ -393,3 +362,2 @@ return { | ||
} | ||
function peg$anyExpectation() { | ||
@@ -400,3 +368,2 @@ return { | ||
} | ||
function peg$endExpectation() { | ||
@@ -407,3 +374,2 @@ return { | ||
} | ||
function peg$otherExpectation(description) { | ||
@@ -415,7 +381,5 @@ return { | ||
} | ||
function peg$computePosDetails(pos) { | ||
var details = peg$posDetailsCache[pos], | ||
p; | ||
p; | ||
if (details) { | ||
@@ -425,7 +389,5 @@ return details; | ||
p = pos - 1; | ||
while (!peg$posDetailsCache[p]) { | ||
p--; | ||
} | ||
details = peg$posDetailsCache[p]; | ||
@@ -436,3 +398,2 @@ details = { | ||
}; | ||
while (p < pos) { | ||
@@ -445,6 +406,4 @@ if (input.charCodeAt(p) === 10) { | ||
} | ||
p++; | ||
} | ||
peg$posDetailsCache[pos] = details; | ||
@@ -454,6 +413,5 @@ return details; | ||
} | ||
function peg$computeLocation(startPos, endPos) { | ||
var startPosDetails = peg$computePosDetails(startPos), | ||
endPosDetails = peg$computePosDetails(endPos); | ||
endPosDetails = peg$computePosDetails(endPos); | ||
return { | ||
@@ -472,3 +430,2 @@ start: { | ||
} | ||
function peg$fail(expected) { | ||
@@ -478,3 +435,2 @@ if (peg$currPos < peg$maxFailPos) { | ||
} | ||
if (peg$currPos > peg$maxFailPos) { | ||
@@ -484,14 +440,10 @@ peg$maxFailPos = peg$currPos; | ||
} | ||
peg$maxFailExpected.push(expected); | ||
} | ||
function peg$buildSimpleError(message, location) { | ||
return new peg$SyntaxError(message, null, null, location); | ||
} | ||
function peg$buildStructuredError(expected, found, location) { | ||
return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location); | ||
} | ||
function peg$parseschema() { | ||
@@ -502,3 +454,2 @@ var s0, s1, s2; | ||
s2 = peg$parseline_rule(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -508,3 +459,2 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
@@ -514,7 +464,5 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parseline_rule() { | ||
@@ -525,3 +473,2 @@ var s0, s1, s2; | ||
s2 = peg$parsewhitespace(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -531,6 +478,4 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parserule(); | ||
if (s2 !== peg$FAILED) { | ||
@@ -547,9 +492,6 @@ s1 = [s1, s2]; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsecomment_line(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parseend_line(); | ||
if (s0 === peg$FAILED) { | ||
@@ -560,6 +502,4 @@ s0 = peg$parse__(); | ||
} | ||
return s0; | ||
} | ||
function peg$parserule() { | ||
@@ -569,3 +509,2 @@ var s0, s1; | ||
s1 = peg$parsecreate_table_syntax(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -575,9 +514,6 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parseadd_foreign_key_syntax(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -587,5 +523,3 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
@@ -595,6 +529,4 @@ s0 = peg$parseother_class_prop(); | ||
} | ||
return s0; | ||
} | ||
function peg$parseadd_foreign_key_syntax() { | ||
@@ -605,3 +537,2 @@ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; | ||
s2 = peg$parsesp(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -611,10 +542,7 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseadd_foreign_key(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$parsesp(); | ||
while (s4 !== peg$FAILED) { | ||
@@ -624,6 +552,4 @@ s3.push(s4); | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsename(); | ||
if (s4 !== peg$FAILED) { | ||
@@ -635,3 +561,2 @@ if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -641,7 +566,5 @@ peg$fail(peg$c4); | ||
} | ||
if (s5 !== peg$FAILED) { | ||
s6 = []; | ||
s7 = peg$parsesp(); | ||
while (s7 !== peg$FAILED) { | ||
@@ -651,10 +574,7 @@ s6.push(s7); | ||
} | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parsename(); | ||
if (s7 !== peg$FAILED) { | ||
s8 = []; | ||
s9 = peg$parseadd_foreign_key_props_syntax(); | ||
while (s9 !== peg$FAILED) { | ||
@@ -664,3 +584,2 @@ s8.push(s9); | ||
} | ||
if (s8 !== peg$FAILED) { | ||
@@ -702,10 +621,7 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parseadd_foreign_key_props_syntax() { | ||
var s0, s1, s2, s3, s4, s5, s6; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
@@ -716,3 +632,2 @@ s1 = peg$c3; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -722,7 +637,5 @@ peg$fail(peg$c4); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
while (s3 !== peg$FAILED) { | ||
@@ -732,6 +645,4 @@ s2.push(s3); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsecolumn(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -743,3 +654,2 @@ if (input.charCodeAt(peg$currPos) === 58) { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -749,7 +659,5 @@ peg$fail(peg$c7); | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = []; | ||
s6 = peg$parsesp(); | ||
while (s6 !== peg$FAILED) { | ||
@@ -759,6 +667,4 @@ s5.push(s6); | ||
} | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parsename(); | ||
if (s6 !== peg$FAILED) { | ||
@@ -792,6 +698,4 @@ peg$savedPos = s0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
@@ -802,3 +706,2 @@ s1 = peg$c3; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -808,7 +711,5 @@ peg$fail(peg$c4); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
while (s3 !== peg$FAILED) { | ||
@@ -818,6 +719,4 @@ s2.push(s3); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseprimary_key(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -829,3 +728,2 @@ if (input.charCodeAt(peg$currPos) === 58) { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -835,7 +733,5 @@ peg$fail(peg$c7); | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = []; | ||
s6 = peg$parsesp(); | ||
while (s6 !== peg$FAILED) { | ||
@@ -845,6 +741,4 @@ s5.push(s6); | ||
} | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parsename(); | ||
if (s6 !== peg$FAILED) { | ||
@@ -878,6 +772,4 @@ peg$savedPos = s0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
@@ -888,3 +780,2 @@ s1 = peg$c3; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -894,7 +785,5 @@ peg$fail(peg$c4); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
while (s3 !== peg$FAILED) { | ||
@@ -904,6 +793,4 @@ s2.push(s3); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsereferential_actions(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -915,3 +802,2 @@ if (input.charCodeAt(peg$currPos) === 58) { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -921,7 +807,5 @@ peg$fail(peg$c7); | ||
} | ||
if (s4 !== peg$FAILED) { | ||
s5 = []; | ||
s6 = peg$parsesp(); | ||
while (s6 !== peg$FAILED) { | ||
@@ -931,6 +815,4 @@ s5.push(s6); | ||
} | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parsesymbol(); | ||
if (s6 !== peg$FAILED) { | ||
@@ -966,6 +848,4 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsecreate_table_syntax() { | ||
@@ -975,7 +855,5 @@ var s0, s1, s2, s3, s4, s5, s6, s7; | ||
s1 = peg$parsecreate_table(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
while (s3 !== peg$FAILED) { | ||
@@ -985,18 +863,12 @@ s2.push(s3); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsename(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsewhateters(); | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parseendline(); | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parsetable_body(); | ||
if (s6 !== peg$FAILED) { | ||
s7 = peg$parseend_line(); | ||
if (s7 !== peg$FAILED) { | ||
@@ -1034,6 +906,4 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsetable_body() { | ||
@@ -1044,3 +914,2 @@ var s0, s1, s2; | ||
s2 = peg$parsefield(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -1050,3 +919,2 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
@@ -1056,7 +924,5 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsefield() { | ||
@@ -1067,3 +933,2 @@ var s0, s1, s2, s3, s4; | ||
s2 = peg$parsewhitespace(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -1073,10 +938,7 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsetable_field_syntax(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$parsewhatever(); | ||
while (s4 !== peg$FAILED) { | ||
@@ -1086,6 +948,4 @@ s3.push(s4); | ||
} | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parseendline(); | ||
if (s4 !== peg$FAILED) { | ||
@@ -1111,14 +971,10 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsetable_field_syntax() { | ||
var s0, s1; | ||
s0 = peg$parsefield_index_syntax(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsefield_reference_syntax(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -1128,9 +984,6 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsefield_type_syntax(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -1140,10 +993,7 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
} | ||
} | ||
return s0; | ||
} | ||
function peg$parsefield_index_syntax() { | ||
@@ -1153,7 +1003,5 @@ var s0, s1, s2, s3; | ||
s1 = peg$parseindex(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1167,6 +1015,4 @@ while (s3 !== peg$FAILED) { | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsewhateters(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1187,6 +1033,4 @@ s1 = [s1, s2, s3]; | ||
} | ||
return s0; | ||
} | ||
function peg$parsefield_reference_syntax() { | ||
@@ -1196,7 +1040,5 @@ var s0, s1, s2, s3; | ||
s1 = peg$parsereferences(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1210,6 +1052,4 @@ while (s3 !== peg$FAILED) { | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsereference_value(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1231,6 +1071,4 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsefield_type_syntax() { | ||
@@ -1240,7 +1078,5 @@ var s0, s1, s2, s3; | ||
s1 = peg$parsefield_type(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1254,6 +1090,4 @@ while (s3 !== peg$FAILED) { | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsename(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1275,10 +1109,7 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsereference_value() { | ||
var s0, s1, s2; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 58) { | ||
@@ -1289,3 +1120,2 @@ s1 = peg$c6; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1295,6 +1125,4 @@ peg$fail(peg$c7); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsevariable(); | ||
if (s2 !== peg$FAILED) { | ||
@@ -1312,7 +1140,5 @@ peg$savedPos = s0; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
s1 = peg$parsename(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -1322,12 +1148,8 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
} | ||
return s0; | ||
} | ||
function peg$parsereferential_actions() { | ||
var s0; | ||
if (input.substr(peg$currPos, 9).toLowerCase() === peg$c19) { | ||
@@ -1338,3 +1160,2 @@ s0 = input.substr(peg$currPos, 9); | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1344,3 +1165,2 @@ peg$fail(peg$c20); | ||
} | ||
if (s0 === peg$FAILED) { | ||
@@ -1352,3 +1172,2 @@ if (input.substr(peg$currPos, 9).toLowerCase() === peg$c21) { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1359,10 +1178,7 @@ peg$fail(peg$c22); | ||
} | ||
return s0; | ||
} | ||
function peg$parseadd_index() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 9) === peg$c24) { | ||
@@ -1373,3 +1189,2 @@ s0 = peg$c24; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1379,8 +1194,5 @@ peg$fail(peg$c25); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1390,10 +1202,7 @@ peg$fail(peg$c23); | ||
} | ||
return s0; | ||
} | ||
function peg$parseschema_define() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 27) === peg$c27) { | ||
@@ -1404,3 +1213,2 @@ s0 = peg$c27; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1410,8 +1218,5 @@ peg$fail(peg$c28); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1421,10 +1226,7 @@ peg$fail(peg$c26); | ||
} | ||
return s0; | ||
} | ||
function peg$parsecreate_table() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 12).toLowerCase() === peg$c30) { | ||
@@ -1435,3 +1237,2 @@ s0 = input.substr(peg$currPos, 12); | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1441,8 +1242,5 @@ peg$fail(peg$c31); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1452,6 +1250,4 @@ peg$fail(peg$c29); | ||
} | ||
return s0; | ||
} | ||
function peg$parseend_create_table() { | ||
@@ -1462,7 +1258,5 @@ var s0, s1, s2, s3, s4, s5, s6; | ||
s1 = peg$parsedo(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsesp(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1476,15 +1270,10 @@ while (s3 !== peg$FAILED) { | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseabs(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parsecharacter(); | ||
if (s4 !== peg$FAILED) { | ||
s5 = peg$parseabs(); | ||
if (s5 !== peg$FAILED) { | ||
s6 = peg$parseendline(); | ||
if (s6 !== peg$FAILED) { | ||
@@ -1517,8 +1306,5 @@ s1 = [s1, s2, s3, s4, s5, s6]; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1528,6 +1314,4 @@ peg$fail(peg$c32); | ||
} | ||
return s0; | ||
} | ||
function peg$parseindex() { | ||
@@ -1538,3 +1322,2 @@ var s0, s1, s2; | ||
s1 = peg$parsecharacter(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -1546,3 +1329,2 @@ if (input.substr(peg$currPos, 6) === peg$c34) { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1552,3 +1334,2 @@ peg$fail(peg$c35); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
@@ -1565,8 +1346,5 @@ s1 = [s1, s2]; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1576,6 +1354,4 @@ peg$fail(peg$c33); | ||
} | ||
return s0; | ||
} | ||
function peg$parsereferences() { | ||
@@ -1586,3 +1362,2 @@ var s0, s1, s2; | ||
s1 = peg$parsecharacter(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -1594,3 +1369,2 @@ if (input.substr(peg$currPos, 11) === peg$c37) { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1600,3 +1374,2 @@ peg$fail(peg$c38); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
@@ -1613,8 +1386,5 @@ s1 = [s1, s2]; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1624,10 +1394,7 @@ peg$fail(peg$c36); | ||
} | ||
return s0; | ||
} | ||
function peg$parseadd_foreign_key() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 15).toLowerCase() === peg$c40) { | ||
@@ -1638,3 +1405,2 @@ s0 = input.substr(peg$currPos, 15); | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1644,8 +1410,5 @@ peg$fail(peg$c41); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1655,10 +1418,7 @@ peg$fail(peg$c39); | ||
} | ||
return s0; | ||
} | ||
function peg$parsecolumn() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 6) === peg$c43) { | ||
@@ -1669,3 +1429,2 @@ s0 = peg$c43; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1675,8 +1434,5 @@ peg$fail(peg$c44); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1686,10 +1442,7 @@ peg$fail(peg$c42); | ||
} | ||
return s0; | ||
} | ||
function peg$parseprimary_key() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 11) === peg$c46) { | ||
@@ -1700,3 +1453,2 @@ s0 = peg$c46; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1706,8 +1458,5 @@ peg$fail(peg$c47); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1717,9 +1466,6 @@ peg$fail(peg$c45); | ||
} | ||
return s0; | ||
} | ||
function peg$parseversion() { | ||
var s0; | ||
if (input.substr(peg$currPos, 7) === peg$c48) { | ||
@@ -1730,3 +1476,2 @@ s0 = peg$c48; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1736,9 +1481,6 @@ peg$fail(peg$c49); | ||
} | ||
return s0; | ||
} | ||
function peg$parsedo() { | ||
var s0; | ||
if (input.substr(peg$currPos, 2) === peg$c50) { | ||
@@ -1749,3 +1491,2 @@ s0 = peg$c50; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1755,9 +1496,6 @@ peg$fail(peg$c51); | ||
} | ||
return s0; | ||
} | ||
function peg$parseend() { | ||
var s0; | ||
if (input.substr(peg$currPos, 3) === peg$c52) { | ||
@@ -1768,3 +1506,2 @@ s0 = peg$c52; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1774,10 +1511,7 @@ peg$fail(peg$c53); | ||
} | ||
return s0; | ||
} | ||
function peg$parselambda_function() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 2) === peg$c55) { | ||
@@ -1788,3 +1522,2 @@ s0 = peg$c55; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1794,3 +1527,2 @@ peg$fail(peg$c56); | ||
} | ||
if (s0 === peg$FAILED) { | ||
@@ -1802,3 +1534,2 @@ if (input.substr(peg$currPos, 2) === peg$c57) { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1809,8 +1540,5 @@ peg$fail(peg$c58); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1820,6 +1548,4 @@ peg$fail(peg$c54); | ||
} | ||
return s0; | ||
} | ||
function peg$parseother_class_prop() { | ||
@@ -1829,13 +1555,9 @@ var s0, s1, s2, s3; | ||
s1 = peg$parsevariable(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsewhateters(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseendline(); | ||
if (s3 === peg$FAILED) { | ||
s3 = null; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
@@ -1856,17 +1578,12 @@ s1 = [s1, s2, s3]; | ||
} | ||
return s0; | ||
} | ||
function peg$parsename() { | ||
var s0; | ||
s0 = peg$parsedouble_quote_name(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsesingle_quote_name(); | ||
} | ||
return s0; | ||
} | ||
function peg$parsedouble_quote_name() { | ||
@@ -1876,6 +1593,4 @@ var s0, s1, s2, s3; | ||
s1 = peg$parsedouble_quote(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
if (peg$c59.test(input.charAt(peg$currPos))) { | ||
@@ -1886,3 +1601,2 @@ s3 = input.charAt(peg$currPos); | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1892,6 +1606,4 @@ peg$fail(peg$c60); | ||
} | ||
while (s3 !== peg$FAILED) { | ||
s2.push(s3); | ||
if (peg$c59.test(input.charAt(peg$currPos))) { | ||
@@ -1902,3 +1614,2 @@ s3 = input.charAt(peg$currPos); | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1909,6 +1620,4 @@ peg$fail(peg$c60); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsedouble_quote(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1930,6 +1639,4 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsesingle_quote_name() { | ||
@@ -1939,6 +1646,4 @@ var s0, s1, s2, s3; | ||
s1 = peg$parsesingle_quote(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
if (peg$c62.test(input.charAt(peg$currPos))) { | ||
@@ -1949,3 +1654,2 @@ s3 = input.charAt(peg$currPos); | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1955,6 +1659,4 @@ peg$fail(peg$c63); | ||
} | ||
while (s3 !== peg$FAILED) { | ||
s2.push(s3); | ||
if (peg$c62.test(input.charAt(peg$currPos))) { | ||
@@ -1965,3 +1667,2 @@ s3 = input.charAt(peg$currPos); | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -1972,6 +1673,4 @@ peg$fail(peg$c63); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsesingle_quote(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -1993,10 +1692,7 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsesymbol() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 58) { | ||
@@ -2007,3 +1703,2 @@ s1 = peg$c6; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2013,7 +1708,5 @@ peg$fail(peg$c7); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = []; | ||
s3 = peg$parsecharacter(); | ||
while (s3 !== peg$FAILED) { | ||
@@ -2023,3 +1716,2 @@ s2.push(s3); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
@@ -2037,6 +1729,4 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsevariable() { | ||
@@ -2047,3 +1737,2 @@ var s0, s1, s2; | ||
s2 = peg$parsecharacter(); | ||
if (s2 !== peg$FAILED) { | ||
@@ -2057,3 +1746,2 @@ while (s2 !== peg$FAILED) { | ||
} | ||
if (s1 !== peg$FAILED) { | ||
@@ -2063,7 +1751,5 @@ peg$savedPos = s0; | ||
} | ||
s0 = s1; | ||
return s0; | ||
} | ||
function peg$parsefield_type() { | ||
@@ -2073,3 +1759,2 @@ var s0, s1, s2, s3, s4; | ||
s1 = peg$parsecharacter(); | ||
if (s1 !== peg$FAILED) { | ||
@@ -2081,3 +1766,2 @@ if (input.charCodeAt(peg$currPos) === 46) { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2087,7 +1771,5 @@ peg$fail(peg$c65); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = []; | ||
s4 = peg$parsecharacter(); | ||
if (s4 !== peg$FAILED) { | ||
@@ -2101,3 +1783,2 @@ while (s4 !== peg$FAILED) { | ||
} | ||
if (s3 !== peg$FAILED) { | ||
@@ -2119,6 +1800,4 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsenot_whitespace() { | ||
@@ -2131,3 +1810,2 @@ var s0, s1, s2; | ||
peg$silentFails--; | ||
if (s2 === peg$FAILED) { | ||
@@ -2139,3 +1817,2 @@ s1 = void 0; | ||
} | ||
if (s1 !== peg$FAILED) { | ||
@@ -2147,3 +1824,2 @@ if (input.length > peg$currPos) { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2153,3 +1829,2 @@ peg$fail(peg$c66); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
@@ -2167,9 +1842,6 @@ peg$savedPos = s0; | ||
} | ||
return s0; | ||
} | ||
function peg$parsenumber() { | ||
var s0; | ||
if (peg$c68.test(input.charAt(peg$currPos))) { | ||
@@ -2180,3 +1852,2 @@ s0 = input.charAt(peg$currPos); | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2186,10 +1857,7 @@ peg$fail(peg$c69); | ||
} | ||
return s0; | ||
} | ||
function peg$parsecharacter() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (peg$c71.test(input.charAt(peg$currPos))) { | ||
@@ -2200,3 +1868,2 @@ s0 = input.charAt(peg$currPos); | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2206,8 +1873,5 @@ peg$fail(peg$c72); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2217,6 +1881,4 @@ peg$fail(peg$c70); | ||
} | ||
return s0; | ||
} | ||
function peg$parseend_line() { | ||
@@ -2227,3 +1889,2 @@ var s0, s1, s2, s3; | ||
s2 = peg$parsewhitespace(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -2233,13 +1894,9 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseend(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseendline(); | ||
if (s3 === peg$FAILED) { | ||
s3 = null; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
@@ -2260,6 +1917,4 @@ s1 = [s1, s2, s3]; | ||
} | ||
return s0; | ||
} | ||
function peg$parsewhatever_line() { | ||
@@ -2270,3 +1925,2 @@ var s0, s1, s2, s3, s4, s5; | ||
s2 = peg$parsewhitespace(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -2276,7 +1930,5 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$currPos; | ||
s3 = peg$parsewhateters(); | ||
if (s3 !== peg$FAILED) { | ||
@@ -2287,3 +1939,2 @@ s4 = peg$currPos; | ||
peg$silentFails--; | ||
if (s5 === peg$FAILED) { | ||
@@ -2295,3 +1946,2 @@ s4 = void 0; | ||
} | ||
if (s4 !== peg$FAILED) { | ||
@@ -2308,10 +1958,7 @@ s3 = [s3, s4]; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseendline(); | ||
if (s3 === peg$FAILED) { | ||
s3 = null; | ||
} | ||
if (s3 !== peg$FAILED) { | ||
@@ -2332,6 +1979,4 @@ s1 = [s1, s2, s3]; | ||
} | ||
return s0; | ||
} | ||
function peg$parsecomment_line() { | ||
@@ -2343,3 +1988,2 @@ var s0, s1, s2, s3, s4; | ||
s2 = peg$parsewhitespace(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -2349,3 +1993,2 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
@@ -2357,3 +2000,2 @@ if (input.charCodeAt(peg$currPos) === 35) { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2363,13 +2005,9 @@ peg$fail(peg$c75); | ||
} | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parsewhateters(); | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parseendline(); | ||
if (s4 === peg$FAILED) { | ||
s4 = null; | ||
} | ||
if (s4 !== peg$FAILED) { | ||
@@ -2394,8 +2032,5 @@ s1 = [s1, s2, s3, s4]; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2405,6 +2040,4 @@ peg$fail(peg$c73); | ||
} | ||
return s0; | ||
} | ||
function peg$parsewhateters() { | ||
@@ -2414,3 +2047,2 @@ var s0, s1; | ||
s0 = []; | ||
if (peg$c77.test(input.charAt(peg$currPos))) { | ||
@@ -2421,3 +2053,2 @@ s1 = input.charAt(peg$currPos); | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2427,6 +2058,4 @@ peg$fail(peg$c78); | ||
} | ||
while (s1 !== peg$FAILED) { | ||
s0.push(s1); | ||
if (peg$c77.test(input.charAt(peg$currPos))) { | ||
@@ -2437,3 +2066,2 @@ s1 = input.charAt(peg$currPos); | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2444,8 +2072,5 @@ peg$fail(peg$c78); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2455,9 +2080,6 @@ peg$fail(peg$c76); | ||
} | ||
return s0; | ||
} | ||
function peg$parsewhatever() { | ||
var s0; | ||
if (peg$c77.test(input.charAt(peg$currPos))) { | ||
@@ -2468,3 +2090,2 @@ s0 = input.charAt(peg$currPos); | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2474,9 +2095,6 @@ peg$fail(peg$c78); | ||
} | ||
return s0; | ||
} | ||
function peg$parsesingle_quote() { | ||
var s0; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
@@ -2487,3 +2105,2 @@ s0 = peg$c79; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2493,9 +2110,6 @@ peg$fail(peg$c80); | ||
} | ||
return s0; | ||
} | ||
function peg$parsedouble_quote() { | ||
var s0; | ||
if (input.charCodeAt(peg$currPos) === 34) { | ||
@@ -2506,3 +2120,2 @@ s0 = peg$c81; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2512,6 +2125,4 @@ peg$fail(peg$c82); | ||
} | ||
return s0; | ||
} | ||
function peg$parse_() { | ||
@@ -2521,11 +2132,8 @@ var s0, s1; | ||
s1 = peg$parsecomment(); | ||
if (s1 === peg$FAILED) { | ||
s1 = peg$parsewhitespace(); | ||
} | ||
while (s1 !== peg$FAILED) { | ||
s0.push(s1); | ||
s1 = peg$parsecomment(); | ||
if (s1 === peg$FAILED) { | ||
@@ -2535,6 +2143,4 @@ s1 = peg$parsewhitespace(); | ||
} | ||
return s0; | ||
} | ||
function peg$parse__() { | ||
@@ -2544,7 +2150,5 @@ var s0, s1; | ||
s1 = peg$parsecomment(); | ||
if (s1 === peg$FAILED) { | ||
s1 = peg$parsewhitespace(); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
@@ -2554,3 +2158,2 @@ while (s1 !== peg$FAILED) { | ||
s1 = peg$parsecomment(); | ||
if (s1 === peg$FAILED) { | ||
@@ -2563,9 +2166,6 @@ s1 = peg$parsewhitespace(); | ||
} | ||
return s0; | ||
} | ||
function peg$parseabs() { | ||
var s0; | ||
if (input.charCodeAt(peg$currPos) === 124) { | ||
@@ -2576,3 +2176,2 @@ s0 = peg$c83; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2582,6 +2181,4 @@ peg$fail(peg$c84); | ||
} | ||
return s0; | ||
} | ||
function peg$parseendline() { | ||
@@ -2592,3 +2189,2 @@ var s0, s1, s2; | ||
s2 = peg$parsesp(); | ||
while (s2 !== peg$FAILED) { | ||
@@ -2598,6 +2194,4 @@ s1.push(s2); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parsenewline(); | ||
if (s2 !== peg$FAILED) { | ||
@@ -2614,6 +2208,4 @@ s1 = [s1, s2]; | ||
} | ||
return s0; | ||
} | ||
function peg$parsecomment() { | ||
@@ -2623,3 +2215,2 @@ var s0, s1, s2; | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c86) { | ||
@@ -2630,3 +2221,2 @@ s1 = peg$c86; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2636,3 +2226,2 @@ peg$fail(peg$c87); | ||
} | ||
if (s1 !== peg$FAILED) { | ||
@@ -2644,3 +2233,2 @@ if (peg$c88.test(input.charAt(peg$currPos))) { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2650,7 +2238,5 @@ peg$fail(peg$c89); | ||
} | ||
if (s2 === peg$FAILED) { | ||
s2 = null; | ||
} | ||
if (s2 !== peg$FAILED) { | ||
@@ -2667,8 +2253,5 @@ s1 = [s1, s2]; | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2678,10 +2261,7 @@ peg$fail(peg$c85); | ||
} | ||
return s0; | ||
} | ||
function peg$parsenewline() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (input.substr(peg$currPos, 2) === peg$c91) { | ||
@@ -2692,3 +2272,2 @@ s0 = peg$c91; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2698,3 +2277,2 @@ peg$fail(peg$c92); | ||
} | ||
if (s0 === peg$FAILED) { | ||
@@ -2706,3 +2284,2 @@ if (input.charCodeAt(peg$currPos) === 10) { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2713,8 +2290,5 @@ peg$fail(peg$c94); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2724,10 +2298,7 @@ peg$fail(peg$c90); | ||
} | ||
return s0; | ||
} | ||
function peg$parsewhitespace() { | ||
var s0, s1; | ||
peg$silentFails++; | ||
if (peg$c96.test(input.charAt(peg$currPos))) { | ||
@@ -2738,3 +2309,2 @@ s0 = input.charAt(peg$currPos); | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2744,8 +2314,5 @@ peg$fail(peg$c97); | ||
} | ||
peg$silentFails--; | ||
if (s0 === peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2755,9 +2322,6 @@ peg$fail(peg$c95); | ||
} | ||
return s0; | ||
} | ||
function peg$parsesp() { | ||
var s0; | ||
if (input.charCodeAt(peg$currPos) === 32) { | ||
@@ -2768,3 +2332,2 @@ s0 = peg$c98; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
@@ -2774,10 +2337,6 @@ peg$fail(peg$c99); | ||
} | ||
return s0; | ||
} | ||
var pluralize = require('pluralize'); | ||
var lodash = require('lodash'); | ||
var data = { | ||
@@ -2787,3 +2346,2 @@ tables: [], | ||
}; | ||
function pushTable(table) { | ||
@@ -2798,3 +2356,2 @@ if (data.tables.find(function (t) { | ||
}); | ||
if (!idField) { | ||
@@ -2808,7 +2365,5 @@ table.fields.unshift({ | ||
} | ||
data.tables.push(table); | ||
} | ||
} | ||
function addPrimaryKey() { | ||
@@ -2821,3 +2376,2 @@ var fields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (!primaryKey) return fields; | ||
if (fields.find(function (key) { | ||
@@ -2828,3 +2382,3 @@ return key.name === primaryKey.value; | ||
var name = _ref.name, | ||
type = _ref.type; | ||
type = _ref.type; | ||
return { | ||
@@ -2837,3 +2391,2 @@ name: name, | ||
} | ||
var newFields = [{ | ||
@@ -2848,3 +2401,2 @@ name: primaryKey.value, | ||
} | ||
function findTableByNameOrAlias(name) { | ||
@@ -2854,25 +2406,18 @@ var table = data.tables.find(function (t) { | ||
}); | ||
if (table === undefined) { | ||
error("Table " + name + " not found"); | ||
} | ||
return table; | ||
} | ||
function isSameEndpoints(endpoint1, endpoint2) { | ||
return endpoint1.tableName == endpoint2.tableName && lodash.isEqual(lodash.sortBy(endpoint1.fieldNames), lodash.sortBy(endpoint2.fieldNames)); | ||
} | ||
function isSameEndpointsPairs(endpointsPair1, endpointsPair2) { | ||
return isSameEndpoints(endpointsPair1[0], endpointsPair2[0]) && isSameEndpoints(endpointsPair1[1], endpointsPair2[1]); | ||
} | ||
function isSameEndpointsRefs(ref1, ref2) { | ||
return isSameEndpointsPairs(ref1.endpoints, ref2.endpoints) || isSameEndpointsPairs(ref1.endpoints, ref2.endpoints.slice().reverse()); | ||
} | ||
function pushRef(ref) { | ||
if (!ref) return; | ||
if (data.refs.find(function (p) { | ||
@@ -2883,10 +2428,7 @@ return isSameEndpointsRefs(p, ref); | ||
} | ||
data.refs.push(ref); | ||
} | ||
function pushRefs() { | ||
var refs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (!refs || refs.length === 0) return; | ||
for (var i = 0; i < refs.length; i += 1) { | ||
@@ -2896,3 +2438,2 @@ pushRef(refs[i]); | ||
} | ||
function refactorForeign(ref) { | ||
@@ -2905,3 +2446,2 @@ // add relation | ||
}); | ||
if (!fromTable) { | ||
@@ -2915,7 +2455,5 @@ // TODO: handle error | ||
} | ||
var toTable = tables.find(function (table) { | ||
return table.name === endpoints[1].tableName; | ||
}); | ||
if (!toTable) { | ||
@@ -2929,3 +2467,2 @@ // TODO: handle error | ||
} | ||
if (!endpoints[0].fieldNames) { | ||
@@ -2938,3 +2475,2 @@ var singleNameOfPrimaryTable = pluralize.singular(endpoints[1].tableName); | ||
}); | ||
if (!columnField) { | ||
@@ -2948,6 +2484,4 @@ // TODO: handle erro | ||
} | ||
endpoints[0].fieldNames = [columnName]; | ||
} | ||
if (!endpoints[1].fieldNames) { | ||
@@ -2957,6 +2491,4 @@ var primaryKey = 'id'; | ||
} | ||
return ref; | ||
} | ||
function createForeign(fromTable, toTable, props) { | ||
@@ -2971,14 +2503,10 @@ var endpoints = [{ | ||
var refProp = {}; | ||
for (var i = 0; i < props.length; i += 1) { | ||
var currentProp = props[i]; | ||
if (currentProp.columnName) { | ||
endpoints[0].fieldNames = [currentProp.columnName]; | ||
} | ||
if (currentProp.primaryKey) { | ||
endpoints[1].fieldNames = [currentProp.primaryKey]; | ||
} | ||
if (currentProp.onDelete) { | ||
@@ -2989,3 +2517,2 @@ refProp = _objectSpread(_objectSpread({}, refProp), {}, { | ||
} | ||
if (currentProp.onUpdate) { | ||
@@ -2997,3 +2524,2 @@ refProp = _objectSpread(_objectSpread({}, refProp), {}, { | ||
} | ||
return _objectSpread({ | ||
@@ -3004,3 +2530,2 @@ name: "fk_rails_".concat(fromTable, "_").concat(toTable), | ||
} | ||
function createRefFromTableWithReference(table, references) { | ||
@@ -3010,6 +2535,4 @@ if (!references || references.length === 0) { | ||
} | ||
var refs = []; | ||
var _loop = function _loop(i) { | ||
var _loop = function _loop() { | ||
var reference = references[i]; | ||
@@ -3021,9 +2544,7 @@ var referenceTable = pluralize.plural(reference); | ||
}); | ||
if (!toTable) { | ||
return "continue"; | ||
} // add field to table if not exists (`${reference}_id`) | ||
} | ||
// add field to table if not exists (`${reference}_id`) | ||
// auto add type of new field to be varchar if primaryKey not found | ||
var columnName = "".concat(reference, "_id"); | ||
@@ -3037,3 +2558,2 @@ var primaryKeyName = 'id'; | ||
}); | ||
if (!column) { | ||
@@ -3047,3 +2567,2 @@ table.fields.push({ | ||
} | ||
refs.push({ | ||
@@ -3062,15 +2581,11 @@ name: "fk_rails_".concat(table.name, "_").concat(referenceTable), | ||
}; | ||
for (var i = 0; i < references.length; i += 1) { | ||
var _ret = _loop(i); | ||
var _ret = _loop(); | ||
if (_ret === "continue") continue; | ||
} | ||
return refs; | ||
} | ||
function implicityRef(data) { | ||
var tables = data.tables, | ||
refs = data.refs; | ||
refs = data.refs; | ||
var tableWithFieldName = tables.map(function (table) { | ||
@@ -3084,8 +2599,6 @@ var name = table.name; | ||
}); | ||
for (var i = 0; i < tables.length; i += 1) { | ||
var table = tables[i]; | ||
var fields = table.fields; | ||
var _loop2 = function _loop2(j) { | ||
var _loop2 = function _loop2() { | ||
var field = fields[j]; | ||
@@ -3095,3 +2608,2 @@ var refWithTable = tableWithFieldName.find(function (table) { | ||
}); | ||
if (refWithTable) { | ||
@@ -3113,3 +2625,2 @@ var newRef = { | ||
}); | ||
if (!duplicateRef) { | ||
@@ -3120,13 +2631,9 @@ refs.push(newRef); | ||
}; | ||
for (var j = 0; j < fields.length; j += 1) { | ||
_loop2(j); | ||
_loop2(); | ||
} | ||
} | ||
return data; | ||
} | ||
peg$result = peg$startRuleFunction(); | ||
if (peg$result !== peg$FAILED && peg$currPos === input.length) { | ||
@@ -3138,7 +2645,5 @@ return peg$result; | ||
} | ||
throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)); | ||
} | ||
} | ||
module.exports = { | ||
@@ -3145,0 +2650,0 @@ SyntaxError: peg$SyntaxError, |
{ | ||
"name": "@dbml/core", | ||
"version": "2.5.2", | ||
"version": "2.5.3", | ||
"description": "> TODO: description", | ||
@@ -39,11 +39,10 @@ "author": "Holistics <dev@holistics.io>", | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/node": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"babel-jest": "^24.8.0", | ||
"@babel/cli": "^7.21.0", | ||
"@babel/core": "^7.21.4", | ||
"@babel/node": "^7.20.7", | ||
"@babel/preset-env": "^7.21.4", | ||
"@glen/jest-raw-loader": "^2.0.0", | ||
"babel-jest": "^29.5.0", | ||
"bluebird": "^3.5.5", | ||
"expect": "^24.8.0", | ||
"jest": "^24.8.0", | ||
"jest-raw-loader": "^1.0.1", | ||
"jest": "^29.5.0", | ||
"pegjs-require-import": "0.0.6" | ||
@@ -57,6 +56,6 @@ }, | ||
"^.+\\.js$": "babel-jest", | ||
"\\.(?!json$)[^.]*$": "jest-raw-loader" | ||
"\\.(?!json$)[^.]*$": "@glen/jest-raw-loader" | ||
} | ||
}, | ||
"gitHead": "42b0d7cb1c3deeeb0507ad5d779d9eb1ef94e6ff" | ||
"gitHead": "ce84c21ed6e4c1ef17d3e6a87df98600baf079ab" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1158612
9
25368
102