@dbml/parse 7.1.0-alpha.0 → 7.1.1

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.
@@ -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), P = r.diagramViewExplicitlySet.get(j);
8657
- !N || !P || N.has("tableGroups") && M.tableGroups && M.tableGroups.length === 0 && (P.has("tables") || P.has("schemas") || (M.tableGroups = Array.from(r.tableGroups.values()).map((r) => ({ name: r.name }))));
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,49 @@ function findDiagramViewBlocks(r) {
10945
10951
  }
10946
10952
  return j;
10947
10953
  }
10954
+ function emitTablesBlock(r, j) {
10955
+ let M = j.map((r) => {
10956
+ let j = addDoubleQuoteIfNeeded(r.name);
10957
+ return r.schemaName === "public" ? j : `${addDoubleQuoteIfNeeded(r.schemaName)}.${j}`;
10958
+ });
10959
+ r.push(" Tables {"), M.forEach((j) => r.push(` ${j}`)), r.push(" }");
10960
+ }
10961
+ function emitTableGroupsBlock(r, j) {
10962
+ r.push(" TableGroups {"), j.forEach((j) => r.push(` ${addDoubleQuoteIfNeeded(j.name)}`)), r.push(" }");
10963
+ }
10964
+ function emitSchemasBlock(r, j) {
10965
+ r.push(" Schemas {"), j.forEach((j) => r.push(` ${addDoubleQuoteIfNeeded(j.name)}`)), r.push(" }");
10966
+ }
10967
+ function emitNotesBlock(r, j) {
10968
+ r.push(" Notes {"), j.forEach((j) => r.push(` ${addDoubleQuoteIfNeeded(j.name)}`)), r.push(" }");
10969
+ }
10948
10970
  function generateDiagramViewBlock(r, j) {
10949
- let M = [`DiagramView ${addDoubleQuoteIfNeeded(r)} {`];
10950
- if (j?.tables !== void 0 && j.tables !== null) if (j.tables.length === 0) M.push(" Tables { * }");
10951
- else {
10952
- let r = j.tables.map((r) => r.schemaName === "public" ? r.name : `${r.schemaName}.${r.name}`);
10953
- M.push(" Tables {"), r.forEach((r) => M.push(` ${r}`)), M.push(" }");
10971
+ let M = `DiagramView ${addDoubleQuoteIfNeeded(r)} {`;
10972
+ if (!j) return `${M}\n}`;
10973
+ let { tables: N, tableGroups: P, schemas: F, stickyNotes: I } = j, L = N === null, R = P === null, z = F === null;
10974
+ if (L && R && z && I === null) return `${M}\n}`;
10975
+ if (L || R || z) {
10976
+ let r = !L && N.length > 0, j = !R && P.length > 0, B = !z && F.length > 0;
10977
+ if (!(r || j || B)) {
10978
+ if (I && I.length > 0) {
10979
+ let r = [M];
10980
+ return emitNotesBlock(r, I), r.push("}"), r.join("\n");
10981
+ }
10982
+ return `${M}\n Notes { * }\n}`;
10983
+ }
10984
+ let V = [M];
10985
+ 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");
10986
+ }
10987
+ let B = N, V = P, H = F, U = B.length === 0 && V.length === 0 && H.length === 0, W = I != null && I.length > 0;
10988
+ if (U) {
10989
+ if (W) {
10990
+ let r = [M, " Tables { * }"];
10991
+ return emitNotesBlock(r, I), r.push("}"), r.join("\n");
10992
+ }
10993
+ return `${M}\n *\n}`;
10954
10994
  }
10955
- return j?.stickyNotes !== void 0 && (j.stickyNotes === null || (j.stickyNotes.length === 0 ? M.push(" Notes { * }") : (M.push(" Notes {"), j.stickyNotes.forEach((r) => M.push(` ${r.name}`)), M.push(" }")))), j?.tableGroups !== void 0 && (j.tableGroups === null || (j.tableGroups.length === 0 ? M.push(" TableGroups { * }") : (M.push(" TableGroups {"), j.tableGroups.forEach((r) => M.push(` ${r.name}`)), M.push(" }")))), j?.schemas !== void 0 && (j.schemas === null || (j.schemas.length === 0 ? M.push(" Schemas { * }") : (M.push(" Schemas {"), j.schemas.forEach((r) => M.push(` ${r.name}`)), M.push(" }")))), M.push("}"), M.join("\n");
10995
+ let G = [M];
10996
+ 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
10997
  }
10957
10998
  function syncDiagramView(r, j, M) {
10958
10999
  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-alpha.0",
4
+ "version": "7.1.1",
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": "109c30cccebfcb36b793945798d40963fb24d08c"
48
+ "gitHead": "db3691bdada0e754afb76ed4c24c519a80fcddf9"
49
49
  }