@dbml/parse 7.1.0-alpha.0 → 7.1.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/dist/dbml-parse.js +16 -13
- package/dist/dbml-parse.mjs +46 -8
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -8653,8 +8653,14 @@ function processColumnInDb(r) {
|
|
|
8653
8653
|
}
|
|
8654
8654
|
function expandDiagramViewWildcards(r) {
|
|
8655
8655
|
for (let j of r.diagramViews.values()) {
|
|
8656
|
-
let M = j.visibleEntities, N = r.diagramViewWildcards.get(j)
|
|
8657
|
-
|
|
8656
|
+
let M = j.visibleEntities, N = r.diagramViewWildcards.get(j);
|
|
8657
|
+
if (N) {
|
|
8658
|
+
if (N.has("tables") || N.has("schemas")) {
|
|
8659
|
+
M.tables = [], M.tableGroups = [], M.schemas = [];
|
|
8660
|
+
continue;
|
|
8661
|
+
}
|
|
8662
|
+
N.has("tableGroups") && M.tableGroups && M.tableGroups.length === 0 && (M.tableGroups = Array.from(r.tableGroups.values()).map((r) => ({ name: r.name })));
|
|
8663
|
+
}
|
|
8658
8664
|
}
|
|
8659
8665
|
}
|
|
8660
8666
|
function convertEnvToDb(r, j) {
|
|
@@ -10945,14 +10951,46 @@ function findDiagramViewBlocks(r) {
|
|
|
10945
10951
|
}
|
|
10946
10952
|
return j;
|
|
10947
10953
|
}
|
|
10954
|
+
function emitTablesBlock(r, j) {
|
|
10955
|
+
let M = j.map((r) => r.schemaName === "public" ? r.name : `${r.schemaName}.${r.name}`);
|
|
10956
|
+
r.push(" Tables {"), M.forEach((j) => r.push(` ${j}`)), r.push(" }");
|
|
10957
|
+
}
|
|
10958
|
+
function emitTableGroupsBlock(r, j) {
|
|
10959
|
+
r.push(" TableGroups {"), j.forEach((j) => r.push(` ${j.name}`)), r.push(" }");
|
|
10960
|
+
}
|
|
10961
|
+
function emitSchemasBlock(r, j) {
|
|
10962
|
+
r.push(" Schemas {"), j.forEach((j) => r.push(` ${j.name}`)), r.push(" }");
|
|
10963
|
+
}
|
|
10964
|
+
function emitNotesBlock(r, j) {
|
|
10965
|
+
r.push(" Notes {"), j.forEach((j) => r.push(` ${j.name}`)), r.push(" }");
|
|
10966
|
+
}
|
|
10948
10967
|
function generateDiagramViewBlock(r, j) {
|
|
10949
|
-
let M =
|
|
10950
|
-
if (j
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10968
|
+
let M = `DiagramView ${addDoubleQuoteIfNeeded(r)} {`;
|
|
10969
|
+
if (!j) return `${M}\n}`;
|
|
10970
|
+
let { tables: N, tableGroups: P, schemas: F, stickyNotes: I } = j, L = N === null, R = P === null, z = F === null;
|
|
10971
|
+
if (L && R && z && I === null) return `${M}\n}`;
|
|
10972
|
+
if (L || R || z) {
|
|
10973
|
+
let r = !L && N.length > 0, j = !R && P.length > 0, B = !z && F.length > 0;
|
|
10974
|
+
if (!(r || j || B)) {
|
|
10975
|
+
if (I && I.length > 0) {
|
|
10976
|
+
let r = [M];
|
|
10977
|
+
return emitNotesBlock(r, I), r.push("}"), r.join("\n");
|
|
10978
|
+
}
|
|
10979
|
+
return `${M}\n Notes { * }\n}`;
|
|
10980
|
+
}
|
|
10981
|
+
let V = [M];
|
|
10982
|
+
return r && emitTablesBlock(V, N), j && emitTableGroupsBlock(V, P), B && emitSchemasBlock(V, F), I && I.length > 0 && emitNotesBlock(V, I), V.push("}"), V.join("\n");
|
|
10983
|
+
}
|
|
10984
|
+
let B = N, V = P, H = F, U = B.length === 0 && V.length === 0 && H.length === 0, W = I != null && I.length > 0;
|
|
10985
|
+
if (U) {
|
|
10986
|
+
if (W) {
|
|
10987
|
+
let r = [M, " Tables { * }"];
|
|
10988
|
+
return emitNotesBlock(r, I), r.push("}"), r.join("\n");
|
|
10989
|
+
}
|
|
10990
|
+
return `${M}\n *\n}`;
|
|
10954
10991
|
}
|
|
10955
|
-
|
|
10992
|
+
let G = [M];
|
|
10993
|
+
return B.length > 0 && emitTablesBlock(G, B), V.length > 0 && emitTableGroupsBlock(G, V), H.length > 0 && emitSchemasBlock(G, H), W && emitNotesBlock(G, I), G.push("}"), G.join("\n");
|
|
10956
10994
|
}
|
|
10957
10995
|
function syncDiagramView(r, j, M) {
|
|
10958
10996
|
let N = M ?? findDiagramViewBlocks(r), P = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@dbml/parse",
|
|
4
|
-
"version": "7.1.0
|
|
4
|
+
"version": "7.1.0",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=18"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ff4e35e824dfebc5237678dc03c983b409fbddc9"
|
|
49
49
|
}
|