@dbml/core 7.0.0-alpha.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/lib/index.cjs +29 -29
- package/lib/index.mjs +30 -30
- package/package.json +3 -3
- package/types/export/DbmlExporter.d.ts +0 -0
- package/types/export/JsonExporter.d.ts +0 -0
- package/types/export/ModelExporter.d.ts +0 -0
- package/types/export/index.d.ts +0 -0
- package/types/import/index.d.ts +0 -0
- package/types/index.d.ts +0 -0
- package/types/model_structure/check.d.ts +0 -0
- package/types/model_structure/database.d.ts +1 -0
- package/types/model_structure/dbState.d.ts +0 -0
- package/types/model_structure/element.d.ts +0 -0
- package/types/model_structure/endpoint.d.ts +0 -0
- package/types/model_structure/enum.d.ts +0 -0
- package/types/model_structure/enumValue.d.ts +0 -0
- package/types/model_structure/field.d.ts +0 -0
- package/types/model_structure/index.d.ts +0 -0
- package/types/model_structure/indexColumn.d.ts +0 -0
- package/types/model_structure/indexes.d.ts +0 -0
- package/types/model_structure/ref.d.ts +0 -0
- package/types/model_structure/schema.d.ts +0 -0
- package/types/model_structure/stickyNote.d.ts +0 -0
- package/types/model_structure/table.d.ts +0 -0
- package/types/model_structure/tableGroup.d.ts +0 -0
- package/types/model_structure/tablePartial.d.ts +0 -0
- package/types/parse/Parser.d.ts +0 -0
- package/types/parse/error.d.ts +0 -0
- package/types/transform/index.d.ts +0 -0
package/lib/index.mjs
CHANGED
|
@@ -10289,7 +10289,7 @@ function createConstraintErrors(_, HY, P) {
|
|
|
10289
10289
|
}
|
|
10290
10290
|
var getConstraintType$1 = (_) => _ > 1 ? "Composite PK" : "PK";
|
|
10291
10291
|
function validatePrimaryKey(_) {
|
|
10292
|
-
return flatMap_default(Array.from(_.records), ([HY, P]) => {
|
|
10292
|
+
return flatMap_default(Array.from(_.records), ([HY, { rows: P }]) => {
|
|
10293
10293
|
if (isEmpty_default$1(P)) return [];
|
|
10294
10294
|
_.cachedMergedTables.has(HY) || _.cachedMergedTables.set(HY, mergeTableAndPartials(HY, _));
|
|
10295
10295
|
let UY = _.cachedMergedTables.get(HY), WY = collectPkConstraints(UY), GY = collectAvailableColumns(P), KY = keyBy_default(UY.fields, "name");
|
|
@@ -10332,7 +10332,7 @@ function checkMissingPkColumns(_, HY, P, UY, WY) {
|
|
|
10332
10332
|
}
|
|
10333
10333
|
var getConstraintType = (_) => _ > 1 ? "Composite UNIQUE" : "UNIQUE";
|
|
10334
10334
|
function validateUnique(_) {
|
|
10335
|
-
return flatMap_default(Array.from(_.records), ([HY, P]) => {
|
|
10335
|
+
return flatMap_default(Array.from(_.records), ([HY, { rows: P }]) => {
|
|
10336
10336
|
_.cachedMergedTables.has(HY) || _.cachedMergedTables.set(HY, mergeTableAndPartials(HY, _));
|
|
10337
10337
|
let UY = _.cachedMergedTables.get(HY);
|
|
10338
10338
|
if (isEmpty_default$1(P)) return [];
|
|
@@ -10356,7 +10356,7 @@ function validateForeignKeys(_) {
|
|
|
10356
10356
|
function buildTableInfoMap(_) {
|
|
10357
10357
|
let HY = /* @__PURE__ */ new Map();
|
|
10358
10358
|
for (let P of _.tables.values()) {
|
|
10359
|
-
let UY = makeTableKey(P.schemaName, P.name), WY = _.records.get(P) || [];
|
|
10359
|
+
let UY = makeTableKey(P.schemaName, P.name), WY = _.records.get(P)?.rows || [];
|
|
10360
10360
|
_.cachedMergedTables.has(P) || _.cachedMergedTables.set(P, mergeTableAndPartials(P, _));
|
|
10361
10361
|
let GY = _.cachedMergedTables.get(P);
|
|
10362
10362
|
HY.set(UY, {
|
|
@@ -10401,16 +10401,20 @@ var RecordsInterpreter = class {
|
|
|
10401
10401
|
HY.push(new CompileError(CompileErrorCode.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${_.name}' - A Table can only have one Records block`, GY)), HY.push(new CompileError(CompileErrorCode.DUPLICATE_RECORDS_FOR_TABLE, `Duplicate Records blocks for the same Table '${_.name}' - A Table can only have one Records block`, UY));
|
|
10402
10402
|
continue;
|
|
10403
10403
|
}
|
|
10404
|
-
this.tableToRecordMap.set(_, UY)
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10404
|
+
this.tableToRecordMap.set(_, UY), this.env.records.has(_) || this.env.records.set(_, {
|
|
10405
|
+
element: UY,
|
|
10406
|
+
rows: []
|
|
10407
|
+
});
|
|
10408
|
+
let KY = this.env.records.get(_);
|
|
10409
|
+
for (let _ of UY.body.body) {
|
|
10410
|
+
let UY = _, GY = extractDataFromRow(UY, WY, this.env);
|
|
10411
|
+
HY.push(...GY.getErrors()), P.push(...GY.getWarnings());
|
|
10412
|
+
let qY = GY.getValue();
|
|
10413
|
+
qY.row && KY.rows.push({
|
|
10410
10414
|
values: qY.row,
|
|
10411
10415
|
node: UY,
|
|
10412
10416
|
columnNodes: qY.columnNodes
|
|
10413
|
-
})
|
|
10417
|
+
});
|
|
10414
10418
|
}
|
|
10415
10419
|
}
|
|
10416
10420
|
let UY = this.validateConstraints();
|
|
@@ -10581,14 +10585,15 @@ function expandDiagramViewWildcards(_) {
|
|
|
10581
10585
|
}
|
|
10582
10586
|
function convertEnvToDb(_) {
|
|
10583
10587
|
let HY = [];
|
|
10584
|
-
for (let [P, UY] of _.records) {
|
|
10585
|
-
if (!
|
|
10586
|
-
let _ = Object.keys(
|
|
10588
|
+
for (let [P, { element: UY, rows: WY }] of _.records) {
|
|
10589
|
+
if (!WY.length) continue;
|
|
10590
|
+
let _ = Object.keys(WY[0].columnNodes);
|
|
10587
10591
|
HY.push({
|
|
10588
10592
|
schemaName: P.schemaName || void 0,
|
|
10589
10593
|
tableName: P.name,
|
|
10590
10594
|
columns: _,
|
|
10591
|
-
|
|
10595
|
+
token: getTokenPosition(UY),
|
|
10596
|
+
values: WY.map((HY) => _.map((_) => {
|
|
10592
10597
|
let P = HY.values[_];
|
|
10593
10598
|
return P ? {
|
|
10594
10599
|
value: P.value,
|
|
@@ -11531,7 +11536,7 @@ var DBMLDefinitionProvider = class {
|
|
|
11531
11536
|
"notes",
|
|
11532
11537
|
"schemas"
|
|
11533
11538
|
],
|
|
11534
|
-
symbols: /[
|
|
11539
|
+
symbols: /[=><!~?:&|+\-/^%]+/,
|
|
11535
11540
|
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
11536
11541
|
newline: /[\r\n]/,
|
|
11537
11542
|
digits: /\d+(_+\d+)*/,
|
|
@@ -11540,7 +11545,7 @@ var DBMLDefinitionProvider = class {
|
|
|
11540
11545
|
unicode: !0,
|
|
11541
11546
|
tokenizer: {
|
|
11542
11547
|
root: [
|
|
11543
|
-
[/[{}
|
|
11548
|
+
[/[{}[\]()]/, "@bracket"],
|
|
11544
11549
|
[/[,.:]/, "delimiter"],
|
|
11545
11550
|
{ include: "@numbers" },
|
|
11546
11551
|
{ include: "common" }
|
|
@@ -11605,7 +11610,7 @@ var DBMLDefinitionProvider = class {
|
|
|
11605
11610
|
numbers: [
|
|
11606
11611
|
[/0[xX][0-9a-fA-F]*/, "number"],
|
|
11607
11612
|
[/[$][+-]*\d*(\.\d*)?/, "number"],
|
|
11608
|
-
[/((\d+(\.\d*)?)|(\.\d+))([eE][
|
|
11613
|
+
[/((\d+(\.\d*)?)|(\.\d+))([eE][-+]?\d+)?/, "number"],
|
|
11609
11614
|
[/#([0-9A-F]{3}){1,2}/, "number.hex"]
|
|
11610
11615
|
],
|
|
11611
11616
|
string_double: [
|
|
@@ -11662,13 +11667,13 @@ var DBMLDefinitionProvider = class {
|
|
|
11662
11667
|
]
|
|
11663
11668
|
],
|
|
11664
11669
|
comment: [
|
|
11665
|
-
[/[
|
|
11670
|
+
[/[^/*]+/, "comment"],
|
|
11666
11671
|
[
|
|
11667
11672
|
/\*\//,
|
|
11668
11673
|
"comment",
|
|
11669
11674
|
"@pop"
|
|
11670
11675
|
],
|
|
11671
|
-
[/[
|
|
11676
|
+
[/[/*]/, "comment"]
|
|
11672
11677
|
]
|
|
11673
11678
|
}
|
|
11674
11679
|
};
|
|
@@ -11918,7 +11923,7 @@ function findDiagramViewBlocks$1(_) {
|
|
|
11918
11923
|
let UY = new Parser$1(_, P.getValue(), new SyntaxNodeIdGenerator()).parse();
|
|
11919
11924
|
if (UY.getErrors().length > 0) return HY;
|
|
11920
11925
|
let WY = UY.getValue().ast;
|
|
11921
|
-
for (let _ of WY.body) if (_.type?.value ===
|
|
11926
|
+
for (let _ of WY.body) if (_.type?.value.toLowerCase() === ElementKind.DiagramView) {
|
|
11922
11927
|
let P = _.name ? destructureComplexVariable(_.name).unwrap_or([]) : [], UY = P.length > 0 ? P[P.length - 1] : "";
|
|
11923
11928
|
HY.push({
|
|
11924
11929
|
name: UY,
|
|
@@ -11928,14 +11933,8 @@ function findDiagramViewBlocks$1(_) {
|
|
|
11928
11933
|
}
|
|
11929
11934
|
return HY;
|
|
11930
11935
|
}
|
|
11931
|
-
function needsQuoting(_) {
|
|
11932
|
-
return !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_);
|
|
11933
|
-
}
|
|
11934
|
-
function quoteName(_) {
|
|
11935
|
-
return needsQuoting(_) ? `"${_.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"` : _;
|
|
11936
|
-
}
|
|
11937
11936
|
function generateDiagramViewBlock(_, HY) {
|
|
11938
|
-
let P = [`DiagramView ${
|
|
11937
|
+
let P = [`DiagramView ${addDoubleQuoteIfNeeded(_)} {`];
|
|
11939
11938
|
if (HY?.tables !== void 0 && HY.tables !== null) if (HY.tables.length === 0) P.push(" Tables { * }");
|
|
11940
11939
|
else {
|
|
11941
11940
|
let _ = HY.tables.map((_) => _.schemaName === "public" ? _.name : `${_.schemaName}.${_.name}`);
|
|
@@ -16819,13 +16818,14 @@ var database_default = class extends element_default {
|
|
|
16819
16818
|
});
|
|
16820
16819
|
}
|
|
16821
16820
|
processRecords(_) {
|
|
16822
|
-
_.forEach(({ schemaName: _, tableName: HY, columns: P, values: UY }) => {
|
|
16821
|
+
_.forEach(({ schemaName: _, tableName: HY, columns: P, values: UY, token: WY }) => {
|
|
16823
16822
|
this.records.push({
|
|
16824
16823
|
id: this.dbState.generateId("recordId"),
|
|
16825
16824
|
schemaName: _,
|
|
16826
16825
|
tableName: HY,
|
|
16827
16826
|
columns: P,
|
|
16828
|
-
values: UY
|
|
16827
|
+
values: UY,
|
|
16828
|
+
token: WY
|
|
16829
16829
|
});
|
|
16830
16830
|
});
|
|
16831
16831
|
}
|
|
@@ -1821809,5 +1821809,5 @@ function findDiagramViewBlocks(_) {
|
|
|
1821809
1821809
|
let HY = new Compiler();
|
|
1821810
1821810
|
return HY.setSource(_), HY.findDiagramViewBlocks();
|
|
1821811
1821811
|
}
|
|
1821812
|
-
const VERSION = "7.0.0
|
|
1821812
|
+
const VERSION = "7.0.0";
|
|
1821813
1821813
|
export { CompilerError, ModelExporter_default as ModelExporter, Parser_default as Parser, VERSION, addDoubleQuoteIfNeeded, dbmlMonarchTokensProvider, export_default as exporter, findDiagramViewBlocks, formatRecordValue, import_default as importer, isBinaryType, isBooleanType, isDateTimeType, isFloatType, isIntegerType, isNumericType, isSerialType, isStringType, renameTable, syncDiagramView, tryExtractBoolean, tryExtractDateTime, tryExtractEnum, tryExtractInteger, tryExtractNumeric, tryExtractString };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@dbml/core",
|
|
4
|
-
"version": "7.0.0
|
|
4
|
+
"version": "7.0.0",
|
|
5
5
|
"description": "> TODO: description",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lint:fix": "eslint --fix ."
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@dbml/parse": "^7.0.0
|
|
49
|
+
"@dbml/parse": "^7.0.0",
|
|
50
50
|
"antlr4": "^4.13.1",
|
|
51
51
|
"lodash": "^4.17.15",
|
|
52
52
|
"lodash-es": "^4.17.15",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"bluebird": "^3.5.5"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "d9579d7cf95b7cafa9f083529393f0206c0acc98",
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=16"
|
|
63
63
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/types/export/index.d.ts
CHANGED
|
File without changes
|
package/types/import/index.d.ts
CHANGED
|
File without changes
|
package/types/index.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/types/parse/Parser.d.ts
CHANGED
|
File without changes
|
package/types/parse/error.d.ts
CHANGED
|
File without changes
|
|
File without changes
|