@dbml/core
Advanced tools
Comparing version 3.1.4-alpha.0 to 3.1.4
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.TABLE_GROUP = exports.TABLE = exports.REF = exports.NOTE = exports.ENUM = 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'; | ||
@@ -12,4 +12,2 @@ exports.DEFAULT_SCHEMA_NAME = DEFAULT_SCHEMA_NAME; | ||
exports.TABLE = TABLE; | ||
var NOTE = 'note'; | ||
exports.NOTE = NOTE; | ||
var ENUM = 'enum'; | ||
@@ -16,0 +14,0 @@ exports.ENUM = ENUM; |
@@ -14,3 +14,2 @@ "use strict"; | ||
var _table = _interopRequireDefault(require("./table")); | ||
var _note = _interopRequireDefault(require("./note")); | ||
var _element = _interopRequireDefault(require("./element")); | ||
@@ -46,4 +45,2 @@ var _config = require("./config"); | ||
tables = _ref$tables === void 0 ? [] : _ref$tables, | ||
_ref$notes = _ref.notes, | ||
notes = _ref$notes === void 0 ? [] : _ref$notes, | ||
_ref$enums = _ref.enums, | ||
@@ -65,3 +62,2 @@ enums = _ref$enums === void 0 ? [] : _ref$enums, | ||
_this.schemas = []; | ||
_this.notes = []; | ||
_this.note = project.note ? (0, _lodash.get)(project, 'note.value', project.note) : null; | ||
@@ -72,3 +68,3 @@ _this.noteToken = project.note ? (0, _lodash.get)(project, 'note.token', project.noteToken) : null; | ||
_this.aliases = aliases; | ||
_this.processNotes(notes); | ||
// The process order is important. Do not change ! | ||
@@ -78,3 +74,2 @@ _this.processSchemas(schemas); | ||
_this.processSchemaElements(tables, _config.TABLE); | ||
_this.processSchemaElements(notes, _config.NOTE); | ||
_this.processSchemaElements(refs, _config.REF); | ||
@@ -90,33 +85,8 @@ _this.processSchemaElements(tableGroups, _config.TABLE_GROUP); | ||
}, { | ||
key: "processNotes", | ||
value: function processNotes(rawNotes) { | ||
var _this2 = this; | ||
rawNotes.forEach(function (note) { | ||
_this2.pushNote(new _note["default"](_objectSpread(_objectSpread({}, note), {}, { | ||
database: _this2 | ||
}))); | ||
}); | ||
} | ||
}, { | ||
key: "pushNote", | ||
value: function pushNote(note) { | ||
this.checkNote(note); | ||
this.notes.push(note); | ||
} | ||
}, { | ||
key: "checkNote", | ||
value: function checkNote(note) { | ||
if (this.notes.some(function (n) { | ||
return n.name === note.name; | ||
})) { | ||
note.error("Notes ".concat(note.name, " existed")); | ||
} | ||
} | ||
}, { | ||
key: "processSchemas", | ||
value: function processSchemas(rawSchemas) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
rawSchemas.forEach(function (schema) { | ||
_this3.pushSchema(new _schema["default"](_objectSpread(_objectSpread({}, schema), {}, { | ||
database: _this3 | ||
_this2.pushSchema(new _schema["default"](_objectSpread(_objectSpread({}, schema), {}, { | ||
database: _this2 | ||
}))); | ||
@@ -143,7 +113,7 @@ }); | ||
value: function processSchemaElements(elements, elementType) { | ||
var _this4 = this; | ||
var _this3 = this; | ||
var schema; | ||
elements.forEach(function (element) { | ||
if (element.schemaName) { | ||
schema = _this4.findOrCreateSchema(element.schemaName); | ||
schema = _this3.findOrCreateSchema(element.schemaName); | ||
if (element.schemaName === _config.DEFAULT_SCHEMA_NAME) { | ||
@@ -153,3 +123,3 @@ // this.hasDefaultSchema = true; | ||
} else { | ||
schema = _this4.findOrCreateSchema(_config.DEFAULT_SCHEMA_NAME); | ||
schema = _this3.findOrCreateSchema(_config.DEFAULT_SCHEMA_NAME); | ||
} | ||
@@ -266,5 +236,2 @@ switch (elementType) { | ||
return s["export"](); | ||
}), | ||
notes: this.notes.map(function (n) { | ||
return n["export"](); | ||
}) | ||
@@ -279,5 +246,2 @@ }; | ||
return s.id; | ||
}), | ||
noteIds: this.notes.map(function (n) { | ||
return n.id; | ||
}) | ||
@@ -294,3 +258,2 @@ }; | ||
schemas: {}, | ||
notes: {}, | ||
refs: {}, | ||
@@ -309,5 +272,2 @@ enums: {}, | ||
}); | ||
this.notes.forEach(function (note) { | ||
return note.normalize(normalizedModel); | ||
}); | ||
return normalizedModel; | ||
@@ -314,0 +274,0 @@ } |
@@ -22,3 +22,2 @@ "use strict"; | ||
this.tableId = 1; | ||
this.noteId = 1; | ||
this.enumValueId = 1; | ||
@@ -25,0 +24,0 @@ this.endpointId = 1; |
@@ -132,7 +132,2 @@ "use strict"; | ||
} | ||
}, { | ||
key: "parse", | ||
value: function parse(str, format) { | ||
return new Parser().parse(str, format); | ||
} | ||
}]); | ||
@@ -139,0 +134,0 @@ return Parser; |
{ | ||
"name": "@dbml/core", | ||
"version": "3.1.4-alpha.0", | ||
"version": "3.1.4", | ||
"description": "> TODO: description", | ||
@@ -35,3 +35,3 @@ "author": "Holistics <dev@holistics.io>", | ||
"dependencies": { | ||
"@dbml/parse": "^3.1.4-alpha.0", | ||
"@dbml/parse": "^3.1.4", | ||
"antlr4": "^4.13.1", | ||
@@ -63,3 +63,3 @@ "lodash": "^4.17.15", | ||
}, | ||
"gitHead": "87fd767cda6a44999c2616085e859a413554488a" | ||
"gitHead": "5d1db8fcffda24f8bae4476a72025215fb6335b4" | ||
} |
@@ -6,3 +6,2 @@ import Schema, { NormalizedSchema, RawSchema } from './schema'; | ||
import Table, { NormalizedTable } from './table'; | ||
import Note, { NormalizedNote } from './note'; | ||
import Element, { RawNote, Token } from './element'; | ||
@@ -23,3 +22,2 @@ import DbState from './dbState'; | ||
tables: Table[]; | ||
notes: Note[]; | ||
enums: Enum[]; | ||
@@ -34,3 +32,2 @@ refs: Ref[]; | ||
schemas: Schema[]; | ||
notes: Note[]; | ||
note: string; | ||
@@ -108,8 +105,2 @@ noteToken: Token; | ||
}[]; | ||
notes: { | ||
id: number; | ||
name: string; | ||
content: string; | ||
headerColor: string; | ||
}[]; | ||
}; | ||
@@ -181,12 +172,5 @@ shallowExport(): { | ||
}[]; | ||
notes: { | ||
id: number; | ||
name: string; | ||
content: string; | ||
headerColor: string; | ||
}[]; | ||
}; | ||
exportChildIds(): { | ||
schemaIds: number[]; | ||
noteIds: number[]; | ||
}; | ||
@@ -204,7 +188,5 @@ normalize(): NormalizedDatabase; | ||
schemaIds: number[]; | ||
noteIds: number[]; | ||
}; | ||
}; | ||
schemas: NormalizedSchema; | ||
notes: NormalizedNote; | ||
refs: NormalizedRef; | ||
@@ -211,0 +193,0 @@ enums: NormalizedEnum; |
@@ -8,3 +8,2 @@ export default class DbState { | ||
tableId: number; | ||
noteId: number; | ||
enumValueId: number; | ||
@@ -11,0 +10,0 @@ endpointId: number; |
@@ -162,3 +162,2 @@ import Table from './table'; | ||
tableIds: number[]; | ||
noteIds: number[]; | ||
enumIds: number[]; | ||
@@ -185,3 +184,2 @@ tableGroupIds: number[]; | ||
tableIds: number[]; | ||
noteIds: number[]; | ||
enumIds: number[]; | ||
@@ -188,0 +186,0 @@ tableGroupIds: number[]; |
import { Compiler } from '@dbml/parse'; | ||
import Database, { RawDatabase } from '../model_structure/database'; | ||
declare class Parser { | ||
constructor(DBMLCompiler?: Compiler); | ||
constructor(DBMLCompiler: Compiler?); | ||
static parseJSONToDatabase(rawDatabase: RawDatabase): Database; | ||
@@ -12,8 +12,4 @@ static parseMySQLToJSON(str: string): RawDatabase; | ||
static parseMSSQLToJSON(str: string): RawDatabase; | ||
/** | ||
* Should use parse() instance method instead of this static method whenever possible | ||
*/ | ||
static parse(str: string, format: 'mysql' | 'postgres' | 'dbml' | 'dbmlv2' | 'schemarb' | 'mssql' | 'json'): Database; | ||
parse(str: string, format: 'mysql' | 'postgres' | 'dbml' | 'dbmlv2' | 'schemarb' | 'mssql' | 'json'): Database; | ||
} | ||
export default Parser; |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
9266531
132
41361
Updated@dbml/parse@^3.1.4