@uigraph/sdk 1.1.36 → 1.1.37
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/README.md +6 -2
- package/dist/{__headless.DiJZCsKx.d.mts → __headless.BLqB7VsJ.d.mts} +2 -2
- package/dist/{__headless.AhKww75N.cjs → __headless.DGmyg-me.cjs} +2 -2
- package/dist/{__headless.B7jwmaZK.d.cts → __headless.DfSqiw4X.d.cts} +2 -2
- package/dist/{__headless.CP3up7Jj.mjs → __headless.DpdtlCFx.mjs} +2 -2
- package/dist/{__index.BwoDgQJ5.d.mts → __index.BxD_9h1c.d.mts} +2 -2
- package/dist/{__index.Ci2jxLwq.d.cts → __index.CTSMJl1o.d.cts} +2 -2
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.mts +1 -1
- package/dist/headless.cjs +1 -1
- package/dist/headless.d.cts +1 -1
- package/dist/headless.d.mts +1 -1
- package/dist/headless.mjs +1 -1
- package/dist/index.cjs +34 -53
- package/dist/index.d.cts +9 -13
- package/dist/index.d.mts +9 -13
- package/dist/index.mjs +34 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,13 +98,17 @@ The repo needs an `NPM_TOKEN` secret (npm Automation token) configured before th
|
|
|
98
98
|
This project is licensed under the [Business Source License 1.1](LICENSE) (BUSL-1.1).
|
|
99
99
|
|
|
100
100
|
- **Source available today** — you can read, modify, and redistribute the code under the terms of the license.
|
|
101
|
-
- **
|
|
101
|
+
- **Non-production use** — free for development, testing, evaluation, and internal proof-of-concept.
|
|
102
|
+
- **Production use** — requires a commercial license from UiGraph. Production use means any use that supports the ongoing operation of your business or organization.
|
|
102
103
|
- **Future open source** — each version automatically converts to [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) four years after it is first published under BUSL.
|
|
103
104
|
|
|
104
|
-
BUSL is not an OSI-approved open source license during the initial term. For
|
|
105
|
+
BUSL is not an OSI-approved open source license during the initial term. For commercial licensing questions, open an issue or contact the maintainers.
|
|
105
106
|
|
|
106
107
|
## Related projects
|
|
107
108
|
|
|
108
109
|
- [uigraph-ui](https://github.com/uigraph-oss/uigraph-ui) — web application
|
|
109
110
|
- [uigraph-api](https://github.com/uigraph-oss/uigraph-api) — backend API
|
|
110
111
|
- [uigraph-graphql](https://github.com/uigraph-oss/uigraph-graphql) — GraphQL BFF
|
|
112
|
+
- [uigraph-gateway](https://github.com/uigraph-oss/uigraph-gateway) — CLI sync API
|
|
113
|
+
- [uigraph-mcp](https://github.com/uigraph-oss/uigraph-mcp) — MCP server for AI assistants
|
|
114
|
+
- [uigraph-deploy](https://github.com/uigraph-oss/uigraph-deploy) — self-hosted deployment
|
|
@@ -79,8 +79,8 @@ declare const contextSchema: z$1.ZodObject<{
|
|
|
79
79
|
borderAnimationEnabled: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
80
80
|
}, z$1.core.$strip>>;
|
|
81
81
|
dbConfig: z$1.ZodOptional<z$1.ZodObject<{
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
serviceName: z$1.ZodString;
|
|
83
|
+
databaseName: z$1.ZodString;
|
|
84
84
|
tableName: z$1.ZodString;
|
|
85
85
|
}, z$1.core.$strip>>;
|
|
86
86
|
table: z$1.ZodOptional<z$1.ZodObject<{
|
|
@@ -58,8 +58,8 @@ const contextSchema = zod.default.object({
|
|
|
58
58
|
borderAnimationEnabled: zod.default.boolean().optional()
|
|
59
59
|
}).optional(),
|
|
60
60
|
dbConfig: zod.default.object({
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
serviceName: zod.default.string(),
|
|
62
|
+
databaseName: zod.default.string(),
|
|
63
63
|
tableName: zod.default.string()
|
|
64
64
|
}).optional(),
|
|
65
65
|
table: zod.default.object({
|
|
@@ -79,8 +79,8 @@ declare const contextSchema: z$1.ZodObject<{
|
|
|
79
79
|
borderAnimationEnabled: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
80
80
|
}, z$1.core.$strip>>;
|
|
81
81
|
dbConfig: z$1.ZodOptional<z$1.ZodObject<{
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
serviceName: z$1.ZodString;
|
|
83
|
+
databaseName: z$1.ZodString;
|
|
84
84
|
tableName: z$1.ZodString;
|
|
85
85
|
}, z$1.core.$strip>>;
|
|
86
86
|
table: z$1.ZodOptional<z$1.ZodObject<{
|
|
@@ -57,8 +57,8 @@ const contextSchema = z$1.object({
|
|
|
57
57
|
borderAnimationEnabled: z$1.boolean().optional()
|
|
58
58
|
}).optional(),
|
|
59
59
|
dbConfig: z$1.object({
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
serviceName: z$1.string(),
|
|
61
|
+
databaseName: z$1.string(),
|
|
62
62
|
tableName: z$1.string()
|
|
63
63
|
}).optional(),
|
|
64
64
|
table: z$1.object({
|
package/dist/browser.d.cts
CHANGED
package/dist/browser.d.mts
CHANGED
package/dist/headless.cjs
CHANGED
package/dist/headless.d.cts
CHANGED
package/dist/headless.d.mts
CHANGED
package/dist/headless.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_component_type = require("./__component-type.69UkUMKl.cjs");
|
|
2
|
-
const require_headless = require("./__headless.
|
|
2
|
+
const require_headless = require("./__headless.DGmyg-me.cjs");
|
|
3
3
|
let daily_code = require("daily-code");
|
|
4
4
|
daily_code = require_component_type.__toESM(daily_code);
|
|
5
5
|
let zod = require("zod");
|
|
@@ -778,22 +778,22 @@ function generateUUID() {
|
|
|
778
778
|
});
|
|
779
779
|
}
|
|
780
780
|
var AstToUiConverter = class {
|
|
781
|
-
static updateReactFlow({ nodes, edges, schema,
|
|
781
|
+
static updateReactFlow({ nodes, edges, schema, sourceName, oldDataSources }) {
|
|
782
782
|
console.log("UPDATE:", {
|
|
783
783
|
nodes,
|
|
784
784
|
edges,
|
|
785
785
|
schema,
|
|
786
|
-
|
|
786
|
+
sourceName,
|
|
787
787
|
oldDataSources
|
|
788
788
|
});
|
|
789
|
-
const oldSource = oldDataSources.find((s) => s.
|
|
790
|
-
const sourceNodePrefix = `${
|
|
789
|
+
const oldSource = oldDataSources.find((s) => s.name === sourceName);
|
|
790
|
+
const sourceNodePrefix = `${sourceName}-table-`;
|
|
791
791
|
const positions = this.calculateSmartLayout(schema);
|
|
792
792
|
const nodeTableMap = new Map(nodes.map((node) => {
|
|
793
793
|
var _oldSource$schemaAst$;
|
|
794
794
|
return [oldSource === null || oldSource === void 0 || (_oldSource$schemaAst$ = oldSource.schemaAst.tables.find((t) => {
|
|
795
795
|
var _localTable;
|
|
796
|
-
return t.
|
|
796
|
+
return t.name === ((_localTable = node.data.localTable) === null || _localTable === void 0 ? void 0 : _localTable.tableName);
|
|
797
797
|
})) === null || _oldSource$schemaAst$ === void 0 ? void 0 : _oldSource$schemaAst$.name, node];
|
|
798
798
|
}));
|
|
799
799
|
console.log("Old node table map:", nodeTableMap);
|
|
@@ -805,7 +805,7 @@ var AstToUiConverter = class {
|
|
|
805
805
|
x: 100,
|
|
806
806
|
y: 100 + index * 210
|
|
807
807
|
};
|
|
808
|
-
const baseNode = this.tableAstToNode(
|
|
808
|
+
const baseNode = this.tableAstToNode(sourceName, table, position, tableNames);
|
|
809
809
|
if (!prevNode) return baseNode;
|
|
810
810
|
const mergedNode = _objectSpread2(_objectSpread2(_objectSpread2({}, prevNode), baseNode), {}, { data: _objectSpread2(_objectSpread2(_objectSpread2({}, (_prevNode$data = prevNode.data) !== null && _prevNode$data !== void 0 ? _prevNode$data : {}), baseNode.data), {}, { style: (_prevNode$data$style = (_prevNode$data2 = prevNode.data) === null || _prevNode$data2 === void 0 ? void 0 : _prevNode$data2.style) !== null && _prevNode$data$style !== void 0 ? _prevNode$data$style : (_baseNode$data = baseNode.data) === null || _baseNode$data === void 0 ? void 0 : _baseNode$data.style }) });
|
|
811
811
|
if (prevNode.style) mergedNode.style = prevNode.style;
|
|
@@ -816,11 +816,11 @@ var AstToUiConverter = class {
|
|
|
816
816
|
var _schema$tables$find;
|
|
817
817
|
return nodeTableMap.has((_schema$tables$find = schema.tables.find((t) => {
|
|
818
818
|
var _localTable2;
|
|
819
|
-
return t.
|
|
819
|
+
return t.name === ((_localTable2 = node.data.localTable) === null || _localTable2 === void 0 ? void 0 : _localTable2.tableName);
|
|
820
820
|
})) === null || _schema$tables$find === void 0 ? void 0 : _schema$tables$find.name);
|
|
821
821
|
});
|
|
822
822
|
const validNodeIds = new Set(sourceNodes.map((node) => node.id));
|
|
823
|
-
const sourceEdges = schema.tables.flatMap((table) => this.createEdgesFromTable(
|
|
823
|
+
const sourceEdges = schema.tables.flatMap((table) => this.createEdgesFromTable(sourceName, table, schema.tables).filter((edge) => validNodeIds.has(edge.source) && validNodeIds.has(edge.target)));
|
|
824
824
|
const preservedNodes = nodes.filter((node) => !node.id.startsWith(sourceNodePrefix));
|
|
825
825
|
const preservedEdges = edges.filter((edge) => !edge.id.startsWith(sourceNodePrefix));
|
|
826
826
|
return {
|
|
@@ -828,7 +828,7 @@ var AstToUiConverter = class {
|
|
|
828
828
|
edges: [...preservedEdges, ...sourceEdges]
|
|
829
829
|
};
|
|
830
830
|
}
|
|
831
|
-
static toReactFlow(schema,
|
|
831
|
+
static toReactFlow(schema, sourceName) {
|
|
832
832
|
const nodes = [];
|
|
833
833
|
const edges = [];
|
|
834
834
|
const tableNames = new Set(schema.tables.map((table) => table.name));
|
|
@@ -838,9 +838,9 @@ var AstToUiConverter = class {
|
|
|
838
838
|
x: 100,
|
|
839
839
|
y: 100 + index * 210
|
|
840
840
|
};
|
|
841
|
-
const node = this.tableAstToNode(
|
|
841
|
+
const node = this.tableAstToNode(sourceName, table, position, tableNames);
|
|
842
842
|
nodes.push(node);
|
|
843
|
-
const tableEdges = this.createEdgesFromTable(
|
|
843
|
+
const tableEdges = this.createEdgesFromTable(sourceName, table, schema.tables);
|
|
844
844
|
edges.push(...tableEdges);
|
|
845
845
|
});
|
|
846
846
|
return {
|
|
@@ -938,15 +938,15 @@ var AstToUiConverter = class {
|
|
|
938
938
|
startX
|
|
939
939
|
}).positions;
|
|
940
940
|
}
|
|
941
|
-
static tableAstToNode(
|
|
941
|
+
static tableAstToNode(sourceName, table, position, _validTableNames) {
|
|
942
942
|
return {
|
|
943
|
-
id: generateTableNodeId(
|
|
943
|
+
id: generateTableNodeId(sourceName, table.name),
|
|
944
944
|
type: "databaseTableSQL",
|
|
945
945
|
width: DEFAULT_NODE_WIDTH,
|
|
946
946
|
position,
|
|
947
947
|
data: { localTable: {
|
|
948
|
-
|
|
949
|
-
|
|
948
|
+
databaseName: sourceName,
|
|
949
|
+
tableName: table.name
|
|
950
950
|
} }
|
|
951
951
|
};
|
|
952
952
|
}
|
|
@@ -966,13 +966,13 @@ var AstToUiConverter = class {
|
|
|
966
966
|
if (dataType.timezone) formatted += " WITH TIME ZONE";
|
|
967
967
|
return formatted;
|
|
968
968
|
}
|
|
969
|
-
static createEdgesFromTable(
|
|
969
|
+
static createEdgesFromTable(sourceName, sourceTable, validTables) {
|
|
970
970
|
const edges = [];
|
|
971
971
|
this.extractForeignKeys(sourceTable).forEach((fk, index) => {
|
|
972
972
|
const targetTable = validTables.find((t) => t.id === fk.referencedTable || t.name === fk.referencedTable);
|
|
973
973
|
if (!targetTable) return;
|
|
974
|
-
const sourceNodeId = generateTableNodeId(
|
|
975
|
-
const targetNodeId = generateTableNodeId(
|
|
974
|
+
const sourceNodeId = generateTableNodeId(sourceName, sourceTable.name);
|
|
975
|
+
const targetNodeId = generateTableNodeId(sourceName, targetTable.name);
|
|
976
976
|
const edgeId = `${sourceNodeId}-fk-${index}`;
|
|
977
977
|
const fkCols = fk.columns;
|
|
978
978
|
const allNotNull = fkCols.every((cn) => {
|
|
@@ -3288,18 +3288,7 @@ function createReactFlowElements(nodes, edges, subgraphs, subgraphLayouts, subgr
|
|
|
3288
3288
|
return {
|
|
3289
3289
|
nodes: reactFlowNodes,
|
|
3290
3290
|
edges: edges.map((edge, index) => {
|
|
3291
|
-
const
|
|
3292
|
-
"#1976D2",
|
|
3293
|
-
"#388E3C",
|
|
3294
|
-
"#F57C00",
|
|
3295
|
-
"#7B1FA2",
|
|
3296
|
-
"#C2185B"
|
|
3297
|
-
];
|
|
3298
|
-
const edgeColor = edgeColors[index % edgeColors.length];
|
|
3299
|
-
const edgeStyle = {
|
|
3300
|
-
stroke: edgeColor,
|
|
3301
|
-
strokeWidth: 2.5
|
|
3302
|
-
};
|
|
3291
|
+
const edgeStyle = { strokeWidth: 2.5 };
|
|
3303
3292
|
const edgeType = "default";
|
|
3304
3293
|
const animated = true;
|
|
3305
3294
|
switch (edge.type) {
|
|
@@ -3329,17 +3318,13 @@ function createReactFlowElements(nodes, edges, subgraphs, subgraphLayouts, subgr
|
|
|
3329
3318
|
labelStyle: {
|
|
3330
3319
|
fontSize: "12px",
|
|
3331
3320
|
fontWeight: "500",
|
|
3332
|
-
color: edgeColor,
|
|
3333
3321
|
backgroundColor: "white",
|
|
3334
|
-
padding: "2px 6px"
|
|
3335
|
-
borderRadius: "4px",
|
|
3336
|
-
border: `1px solid ${edgeColor}`
|
|
3322
|
+
padding: "2px 6px"
|
|
3337
3323
|
},
|
|
3338
3324
|
markerEnd: {
|
|
3339
3325
|
type: __xyflow_react.MarkerType.ArrowClosed,
|
|
3340
3326
|
width: 20,
|
|
3341
|
-
height: 20
|
|
3342
|
-
color: edgeColor
|
|
3327
|
+
height: 20
|
|
3343
3328
|
},
|
|
3344
3329
|
sourceHandle: direction === "LR" || direction === "RL" ? "source-right" : "source-bottom",
|
|
3345
3330
|
targetHandle: direction === "LR" || direction === "RL" ? "target-left" : "target-top",
|
|
@@ -3825,15 +3810,11 @@ function _convertMermaidToReactFlowWithContext() {
|
|
|
3825
3810
|
componentField.data = newComponentField.data;
|
|
3826
3811
|
}
|
|
3827
3812
|
}
|
|
3828
|
-
if (ctx.dbConfig) {
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
serviceDbId: (_resolved$serviceDbId = resolved === null || resolved === void 0 ? void 0 : resolved.serviceDbId) !== null && _resolved$serviceDbId !== void 0 ? _resolved$serviceDbId : ctx.dbConfig.database,
|
|
3834
|
-
tableName: ctx.dbConfig.tableName
|
|
3835
|
-
};
|
|
3836
|
-
}
|
|
3813
|
+
if (ctx.dbConfig) clonedNode.data.serviceTable = {
|
|
3814
|
+
serviceName: ctx.dbConfig.serviceName,
|
|
3815
|
+
databaseName: ctx.dbConfig.databaseName,
|
|
3816
|
+
tableName: ctx.dbConfig.tableName
|
|
3817
|
+
};
|
|
3837
3818
|
if ((_ctx$style = ctx.style) === null || _ctx$style === void 0 ? void 0 : _ctx$style.height) clonedNode.height = ctx.style.height;
|
|
3838
3819
|
if ((_ctx$style2 = ctx.style) === null || _ctx$style2 === void 0 ? void 0 : _ctx$style2.width) clonedNode.width = ctx.style.width;
|
|
3839
3820
|
clonedNode.data = _objectSpread2(_objectSpread2(_objectSpread2({}, clonedNode.data), (0, daily_code.objectPick)((_ctx$style3 = ctx.style) !== null && _ctx$style3 !== void 0 ? _ctx$style3 : {}, [
|
|
@@ -4151,12 +4132,12 @@ function buildContextNodes(graphNodes, nodeIdMap) {
|
|
|
4151
4132
|
rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
|
|
4152
4133
|
};
|
|
4153
4134
|
const serviceTable = toRecord(nodeData.serviceTable);
|
|
4154
|
-
const
|
|
4155
|
-
const
|
|
4135
|
+
const serviceName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName);
|
|
4136
|
+
const databaseName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName);
|
|
4156
4137
|
const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
|
|
4157
|
-
if (
|
|
4158
|
-
|
|
4159
|
-
|
|
4138
|
+
if (serviceName && databaseName && tableName) nodeContext.dbConfig = {
|
|
4139
|
+
serviceName,
|
|
4140
|
+
databaseName,
|
|
4160
4141
|
tableName
|
|
4161
4142
|
};
|
|
4162
4143
|
const dynamicData = {};
|
|
@@ -4442,9 +4423,9 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
4442
4423
|
const lines = [];
|
|
4443
4424
|
const serviceTable = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.serviceTable);
|
|
4444
4425
|
const dbConfig = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.dbConfig);
|
|
4445
|
-
const database = (_pickString = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.
|
|
4426
|
+
const database = (_pickString = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName)) !== null && _pickString !== void 0 ? _pickString : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.databaseName);
|
|
4446
4427
|
const tableName = (_pickString2 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.tableName);
|
|
4447
|
-
const dbService = (_pickString3 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.
|
|
4428
|
+
const dbService = (_pickString3 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName)) !== null && _pickString3 !== void 0 ? _pickString3 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.serviceName);
|
|
4448
4429
|
const dataSourceName = name !== null && name !== void 0 ? name : tableName;
|
|
4449
4430
|
lines.push(dataSourceName ? `DataSource: ${dataSourceName}` : "DataSource");
|
|
4450
4431
|
if (database && tableName) lines.push(`db: ${database}.${tableName}`);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as MermaidNode, c as SequenceParticipant, d as ServerComponentField, f as ServerComponentFieldInput, i as MermaidEdge, l as SubgraphInfo, n as RFComponentField, o as SequenceDiagramData, r as ReactFlowData, s as SequenceMessage, t as CustomData, u as SubgraphLayout } from "./__index.
|
|
1
|
+
import { a as MermaidNode, c as SequenceParticipant, d as ServerComponentField, f as ServerComponentFieldInput, i as MermaidEdge, l as SubgraphInfo, n as RFComponentField, o as SequenceDiagramData, r as ReactFlowData, s as SequenceMessage, t as CustomData, u as SubgraphLayout } from "./__index.CTSMJl1o.cjs";
|
|
2
2
|
import { t as ComponentInputType } from "./__component-type.tW2Xh7Xk.cjs";
|
|
3
|
-
import { t as contextSchema } from "./__headless.
|
|
3
|
+
import { t as contextSchema } from "./__headless.DfSqiw4X.cjs";
|
|
4
4
|
import z$1, { z } from "zod";
|
|
5
5
|
import { Edge, Node } from "@xyflow/react";
|
|
6
6
|
|
|
@@ -131,12 +131,12 @@ interface DatabaseTableSQLNodeData extends Record<string, unknown> {
|
|
|
131
131
|
};
|
|
132
132
|
isForcedOpen?: boolean;
|
|
133
133
|
localTable?: {
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
databaseName: string;
|
|
135
|
+
tableName: string;
|
|
136
136
|
};
|
|
137
137
|
serviceTable?: {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
serviceName: string;
|
|
139
|
+
databaseName: string;
|
|
140
140
|
tableName: string;
|
|
141
141
|
};
|
|
142
142
|
}
|
|
@@ -305,19 +305,19 @@ declare class AstToUiConverter {
|
|
|
305
305
|
nodes,
|
|
306
306
|
edges,
|
|
307
307
|
schema,
|
|
308
|
-
|
|
308
|
+
sourceName,
|
|
309
309
|
oldDataSources
|
|
310
310
|
}: {
|
|
311
311
|
nodes: Node[];
|
|
312
312
|
edges: Edge[];
|
|
313
|
-
|
|
313
|
+
sourceName: string;
|
|
314
314
|
schema: SchemaAST;
|
|
315
315
|
oldDataSources: DataSource[];
|
|
316
316
|
}): {
|
|
317
317
|
nodes: Node[];
|
|
318
318
|
edges: Edge[];
|
|
319
319
|
};
|
|
320
|
-
static toReactFlow(schema: SchemaAST,
|
|
320
|
+
static toReactFlow(schema: SchemaAST, sourceName: string): {
|
|
321
321
|
nodes: Node<DatabaseTableSQLNodeData>[];
|
|
322
322
|
edges: Edge[];
|
|
323
323
|
};
|
|
@@ -745,10 +745,6 @@ declare function buildMetaData(fields: ServerComponentField[], data: Record<stri
|
|
|
745
745
|
type ResolverOptions = {
|
|
746
746
|
repositionNodes?: boolean;
|
|
747
747
|
resolveCloudIcon?: (cloud: string | undefined, service: string) => Promise<string | undefined | null>;
|
|
748
|
-
resolveDbConfig?: (service: string, database: string) => Promise<{
|
|
749
|
-
serviceId?: string;
|
|
750
|
-
serviceDbId?: string;
|
|
751
|
-
} | undefined>;
|
|
752
748
|
};
|
|
753
749
|
declare function convertMermaidToReactFlowWithContext(mermaidCode: string, context: z$1.infer<typeof contextSchema>, options?: ResolverOptions): Promise<ReactFlowData>;
|
|
754
750
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as MermaidNode, c as SequenceParticipant, d as ServerComponentField, f as ServerComponentFieldInput, i as MermaidEdge, l as SubgraphInfo, n as RFComponentField, o as SequenceDiagramData, r as ReactFlowData, s as SequenceMessage, t as CustomData, u as SubgraphLayout } from "./__index.
|
|
1
|
+
import { a as MermaidNode, c as SequenceParticipant, d as ServerComponentField, f as ServerComponentFieldInput, i as MermaidEdge, l as SubgraphInfo, n as RFComponentField, o as SequenceDiagramData, r as ReactFlowData, s as SequenceMessage, t as CustomData, u as SubgraphLayout } from "./__index.BxD_9h1c.mjs";
|
|
2
2
|
import { t as ComponentInputType } from "./__component-type.CO8FgnQE.mjs";
|
|
3
|
-
import { t as contextSchema } from "./__headless.
|
|
3
|
+
import { t as contextSchema } from "./__headless.BLqB7VsJ.mjs";
|
|
4
4
|
import z$1, { z } from "zod";
|
|
5
5
|
import { Edge, Node } from "@xyflow/react";
|
|
6
6
|
|
|
@@ -131,12 +131,12 @@ interface DatabaseTableSQLNodeData extends Record<string, unknown> {
|
|
|
131
131
|
};
|
|
132
132
|
isForcedOpen?: boolean;
|
|
133
133
|
localTable?: {
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
databaseName: string;
|
|
135
|
+
tableName: string;
|
|
136
136
|
};
|
|
137
137
|
serviceTable?: {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
serviceName: string;
|
|
139
|
+
databaseName: string;
|
|
140
140
|
tableName: string;
|
|
141
141
|
};
|
|
142
142
|
}
|
|
@@ -305,19 +305,19 @@ declare class AstToUiConverter {
|
|
|
305
305
|
nodes,
|
|
306
306
|
edges,
|
|
307
307
|
schema,
|
|
308
|
-
|
|
308
|
+
sourceName,
|
|
309
309
|
oldDataSources
|
|
310
310
|
}: {
|
|
311
311
|
nodes: Node[];
|
|
312
312
|
edges: Edge[];
|
|
313
|
-
|
|
313
|
+
sourceName: string;
|
|
314
314
|
schema: SchemaAST;
|
|
315
315
|
oldDataSources: DataSource[];
|
|
316
316
|
}): {
|
|
317
317
|
nodes: Node[];
|
|
318
318
|
edges: Edge[];
|
|
319
319
|
};
|
|
320
|
-
static toReactFlow(schema: SchemaAST,
|
|
320
|
+
static toReactFlow(schema: SchemaAST, sourceName: string): {
|
|
321
321
|
nodes: Node<DatabaseTableSQLNodeData>[];
|
|
322
322
|
edges: Edge[];
|
|
323
323
|
};
|
|
@@ -745,10 +745,6 @@ declare function buildMetaData(fields: ServerComponentField[], data: Record<stri
|
|
|
745
745
|
type ResolverOptions = {
|
|
746
746
|
repositionNodes?: boolean;
|
|
747
747
|
resolveCloudIcon?: (cloud: string | undefined, service: string) => Promise<string | undefined | null>;
|
|
748
|
-
resolveDbConfig?: (service: string, database: string) => Promise<{
|
|
749
|
-
serviceId?: string;
|
|
750
|
-
serviceDbId?: string;
|
|
751
|
-
} | undefined>;
|
|
752
748
|
};
|
|
753
749
|
declare function convertMermaidToReactFlowWithContext(mermaidCode: string, context: z$1.infer<typeof contextSchema>, options?: ResolverOptions): Promise<ReactFlowData>;
|
|
754
750
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ComponentInputType } from "./__component-type.CYmD-KIu.mjs";
|
|
2
|
-
import { t as contextSchema } from "./__headless.
|
|
2
|
+
import { t as contextSchema } from "./__headless.DpdtlCFx.mjs";
|
|
3
3
|
import { arrayNonNullable, generateUUID as generateUUID$1, objectPick } from "daily-code";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { MarkerType, Position } from "@xyflow/react";
|
|
@@ -772,22 +772,22 @@ function generateUUID() {
|
|
|
772
772
|
});
|
|
773
773
|
}
|
|
774
774
|
var AstToUiConverter = class {
|
|
775
|
-
static updateReactFlow({ nodes, edges, schema,
|
|
775
|
+
static updateReactFlow({ nodes, edges, schema, sourceName, oldDataSources }) {
|
|
776
776
|
console.log("UPDATE:", {
|
|
777
777
|
nodes,
|
|
778
778
|
edges,
|
|
779
779
|
schema,
|
|
780
|
-
|
|
780
|
+
sourceName,
|
|
781
781
|
oldDataSources
|
|
782
782
|
});
|
|
783
|
-
const oldSource = oldDataSources.find((s) => s.
|
|
784
|
-
const sourceNodePrefix = `${
|
|
783
|
+
const oldSource = oldDataSources.find((s) => s.name === sourceName);
|
|
784
|
+
const sourceNodePrefix = `${sourceName}-table-`;
|
|
785
785
|
const positions = this.calculateSmartLayout(schema);
|
|
786
786
|
const nodeTableMap = new Map(nodes.map((node) => {
|
|
787
787
|
var _oldSource$schemaAst$;
|
|
788
788
|
return [oldSource === null || oldSource === void 0 || (_oldSource$schemaAst$ = oldSource.schemaAst.tables.find((t) => {
|
|
789
789
|
var _localTable;
|
|
790
|
-
return t.
|
|
790
|
+
return t.name === ((_localTable = node.data.localTable) === null || _localTable === void 0 ? void 0 : _localTable.tableName);
|
|
791
791
|
})) === null || _oldSource$schemaAst$ === void 0 ? void 0 : _oldSource$schemaAst$.name, node];
|
|
792
792
|
}));
|
|
793
793
|
console.log("Old node table map:", nodeTableMap);
|
|
@@ -799,7 +799,7 @@ var AstToUiConverter = class {
|
|
|
799
799
|
x: 100,
|
|
800
800
|
y: 100 + index * 210
|
|
801
801
|
};
|
|
802
|
-
const baseNode = this.tableAstToNode(
|
|
802
|
+
const baseNode = this.tableAstToNode(sourceName, table, position, tableNames);
|
|
803
803
|
if (!prevNode) return baseNode;
|
|
804
804
|
const mergedNode = _objectSpread2(_objectSpread2(_objectSpread2({}, prevNode), baseNode), {}, { data: _objectSpread2(_objectSpread2(_objectSpread2({}, (_prevNode$data = prevNode.data) !== null && _prevNode$data !== void 0 ? _prevNode$data : {}), baseNode.data), {}, { style: (_prevNode$data$style = (_prevNode$data2 = prevNode.data) === null || _prevNode$data2 === void 0 ? void 0 : _prevNode$data2.style) !== null && _prevNode$data$style !== void 0 ? _prevNode$data$style : (_baseNode$data = baseNode.data) === null || _baseNode$data === void 0 ? void 0 : _baseNode$data.style }) });
|
|
805
805
|
if (prevNode.style) mergedNode.style = prevNode.style;
|
|
@@ -810,11 +810,11 @@ var AstToUiConverter = class {
|
|
|
810
810
|
var _schema$tables$find;
|
|
811
811
|
return nodeTableMap.has((_schema$tables$find = schema.tables.find((t) => {
|
|
812
812
|
var _localTable2;
|
|
813
|
-
return t.
|
|
813
|
+
return t.name === ((_localTable2 = node.data.localTable) === null || _localTable2 === void 0 ? void 0 : _localTable2.tableName);
|
|
814
814
|
})) === null || _schema$tables$find === void 0 ? void 0 : _schema$tables$find.name);
|
|
815
815
|
});
|
|
816
816
|
const validNodeIds = new Set(sourceNodes.map((node) => node.id));
|
|
817
|
-
const sourceEdges = schema.tables.flatMap((table) => this.createEdgesFromTable(
|
|
817
|
+
const sourceEdges = schema.tables.flatMap((table) => this.createEdgesFromTable(sourceName, table, schema.tables).filter((edge) => validNodeIds.has(edge.source) && validNodeIds.has(edge.target)));
|
|
818
818
|
const preservedNodes = nodes.filter((node) => !node.id.startsWith(sourceNodePrefix));
|
|
819
819
|
const preservedEdges = edges.filter((edge) => !edge.id.startsWith(sourceNodePrefix));
|
|
820
820
|
return {
|
|
@@ -822,7 +822,7 @@ var AstToUiConverter = class {
|
|
|
822
822
|
edges: [...preservedEdges, ...sourceEdges]
|
|
823
823
|
};
|
|
824
824
|
}
|
|
825
|
-
static toReactFlow(schema,
|
|
825
|
+
static toReactFlow(schema, sourceName) {
|
|
826
826
|
const nodes = [];
|
|
827
827
|
const edges = [];
|
|
828
828
|
const tableNames = new Set(schema.tables.map((table) => table.name));
|
|
@@ -832,9 +832,9 @@ var AstToUiConverter = class {
|
|
|
832
832
|
x: 100,
|
|
833
833
|
y: 100 + index * 210
|
|
834
834
|
};
|
|
835
|
-
const node = this.tableAstToNode(
|
|
835
|
+
const node = this.tableAstToNode(sourceName, table, position, tableNames);
|
|
836
836
|
nodes.push(node);
|
|
837
|
-
const tableEdges = this.createEdgesFromTable(
|
|
837
|
+
const tableEdges = this.createEdgesFromTable(sourceName, table, schema.tables);
|
|
838
838
|
edges.push(...tableEdges);
|
|
839
839
|
});
|
|
840
840
|
return {
|
|
@@ -932,15 +932,15 @@ var AstToUiConverter = class {
|
|
|
932
932
|
startX
|
|
933
933
|
}).positions;
|
|
934
934
|
}
|
|
935
|
-
static tableAstToNode(
|
|
935
|
+
static tableAstToNode(sourceName, table, position, _validTableNames) {
|
|
936
936
|
return {
|
|
937
|
-
id: generateTableNodeId(
|
|
937
|
+
id: generateTableNodeId(sourceName, table.name),
|
|
938
938
|
type: "databaseTableSQL",
|
|
939
939
|
width: DEFAULT_NODE_WIDTH,
|
|
940
940
|
position,
|
|
941
941
|
data: { localTable: {
|
|
942
|
-
|
|
943
|
-
|
|
942
|
+
databaseName: sourceName,
|
|
943
|
+
tableName: table.name
|
|
944
944
|
} }
|
|
945
945
|
};
|
|
946
946
|
}
|
|
@@ -960,13 +960,13 @@ var AstToUiConverter = class {
|
|
|
960
960
|
if (dataType.timezone) formatted += " WITH TIME ZONE";
|
|
961
961
|
return formatted;
|
|
962
962
|
}
|
|
963
|
-
static createEdgesFromTable(
|
|
963
|
+
static createEdgesFromTable(sourceName, sourceTable, validTables) {
|
|
964
964
|
const edges = [];
|
|
965
965
|
this.extractForeignKeys(sourceTable).forEach((fk, index) => {
|
|
966
966
|
const targetTable = validTables.find((t) => t.id === fk.referencedTable || t.name === fk.referencedTable);
|
|
967
967
|
if (!targetTable) return;
|
|
968
|
-
const sourceNodeId = generateTableNodeId(
|
|
969
|
-
const targetNodeId = generateTableNodeId(
|
|
968
|
+
const sourceNodeId = generateTableNodeId(sourceName, sourceTable.name);
|
|
969
|
+
const targetNodeId = generateTableNodeId(sourceName, targetTable.name);
|
|
970
970
|
const edgeId = `${sourceNodeId}-fk-${index}`;
|
|
971
971
|
const fkCols = fk.columns;
|
|
972
972
|
const allNotNull = fkCols.every((cn) => {
|
|
@@ -3281,18 +3281,7 @@ function createReactFlowElements(nodes, edges, subgraphs, subgraphLayouts, subgr
|
|
|
3281
3281
|
return {
|
|
3282
3282
|
nodes: reactFlowNodes,
|
|
3283
3283
|
edges: edges.map((edge, index) => {
|
|
3284
|
-
const
|
|
3285
|
-
"#1976D2",
|
|
3286
|
-
"#388E3C",
|
|
3287
|
-
"#F57C00",
|
|
3288
|
-
"#7B1FA2",
|
|
3289
|
-
"#C2185B"
|
|
3290
|
-
];
|
|
3291
|
-
const edgeColor = edgeColors[index % edgeColors.length];
|
|
3292
|
-
const edgeStyle = {
|
|
3293
|
-
stroke: edgeColor,
|
|
3294
|
-
strokeWidth: 2.5
|
|
3295
|
-
};
|
|
3284
|
+
const edgeStyle = { strokeWidth: 2.5 };
|
|
3296
3285
|
const edgeType = "default";
|
|
3297
3286
|
const animated = true;
|
|
3298
3287
|
switch (edge.type) {
|
|
@@ -3322,17 +3311,13 @@ function createReactFlowElements(nodes, edges, subgraphs, subgraphLayouts, subgr
|
|
|
3322
3311
|
labelStyle: {
|
|
3323
3312
|
fontSize: "12px",
|
|
3324
3313
|
fontWeight: "500",
|
|
3325
|
-
color: edgeColor,
|
|
3326
3314
|
backgroundColor: "white",
|
|
3327
|
-
padding: "2px 6px"
|
|
3328
|
-
borderRadius: "4px",
|
|
3329
|
-
border: `1px solid ${edgeColor}`
|
|
3315
|
+
padding: "2px 6px"
|
|
3330
3316
|
},
|
|
3331
3317
|
markerEnd: {
|
|
3332
3318
|
type: MarkerType.ArrowClosed,
|
|
3333
3319
|
width: 20,
|
|
3334
|
-
height: 20
|
|
3335
|
-
color: edgeColor
|
|
3320
|
+
height: 20
|
|
3336
3321
|
},
|
|
3337
3322
|
sourceHandle: direction === "LR" || direction === "RL" ? "source-right" : "source-bottom",
|
|
3338
3323
|
targetHandle: direction === "LR" || direction === "RL" ? "target-left" : "target-top",
|
|
@@ -3818,15 +3803,11 @@ function _convertMermaidToReactFlowWithContext() {
|
|
|
3818
3803
|
componentField.data = newComponentField.data;
|
|
3819
3804
|
}
|
|
3820
3805
|
}
|
|
3821
|
-
if (ctx.dbConfig) {
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
serviceDbId: (_resolved$serviceDbId = resolved === null || resolved === void 0 ? void 0 : resolved.serviceDbId) !== null && _resolved$serviceDbId !== void 0 ? _resolved$serviceDbId : ctx.dbConfig.database,
|
|
3827
|
-
tableName: ctx.dbConfig.tableName
|
|
3828
|
-
};
|
|
3829
|
-
}
|
|
3806
|
+
if (ctx.dbConfig) clonedNode.data.serviceTable = {
|
|
3807
|
+
serviceName: ctx.dbConfig.serviceName,
|
|
3808
|
+
databaseName: ctx.dbConfig.databaseName,
|
|
3809
|
+
tableName: ctx.dbConfig.tableName
|
|
3810
|
+
};
|
|
3830
3811
|
if ((_ctx$style = ctx.style) === null || _ctx$style === void 0 ? void 0 : _ctx$style.height) clonedNode.height = ctx.style.height;
|
|
3831
3812
|
if ((_ctx$style2 = ctx.style) === null || _ctx$style2 === void 0 ? void 0 : _ctx$style2.width) clonedNode.width = ctx.style.width;
|
|
3832
3813
|
clonedNode.data = _objectSpread2(_objectSpread2(_objectSpread2({}, clonedNode.data), objectPick((_ctx$style3 = ctx.style) !== null && _ctx$style3 !== void 0 ? _ctx$style3 : {}, [
|
|
@@ -4144,12 +4125,12 @@ function buildContextNodes(graphNodes, nodeIdMap) {
|
|
|
4144
4125
|
rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
|
|
4145
4126
|
};
|
|
4146
4127
|
const serviceTable = toRecord(nodeData.serviceTable);
|
|
4147
|
-
const
|
|
4148
|
-
const
|
|
4128
|
+
const serviceName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName);
|
|
4129
|
+
const databaseName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName);
|
|
4149
4130
|
const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
|
|
4150
|
-
if (
|
|
4151
|
-
|
|
4152
|
-
|
|
4131
|
+
if (serviceName && databaseName && tableName) nodeContext.dbConfig = {
|
|
4132
|
+
serviceName,
|
|
4133
|
+
databaseName,
|
|
4153
4134
|
tableName
|
|
4154
4135
|
};
|
|
4155
4136
|
const dynamicData = {};
|
|
@@ -4435,9 +4416,9 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
4435
4416
|
const lines = [];
|
|
4436
4417
|
const serviceTable = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.serviceTable);
|
|
4437
4418
|
const dbConfig = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.dbConfig);
|
|
4438
|
-
const database = (_pickString = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.
|
|
4419
|
+
const database = (_pickString = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName)) !== null && _pickString !== void 0 ? _pickString : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.databaseName);
|
|
4439
4420
|
const tableName = (_pickString2 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.tableName);
|
|
4440
|
-
const dbService = (_pickString3 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.
|
|
4421
|
+
const dbService = (_pickString3 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName)) !== null && _pickString3 !== void 0 ? _pickString3 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.serviceName);
|
|
4441
4422
|
const dataSourceName = name !== null && name !== void 0 ? name : tableName;
|
|
4442
4423
|
lines.push(dataSourceName ? `DataSource: ${dataSourceName}` : "DataSource");
|
|
4443
4424
|
if (database && tableName) lines.push(`db: ${database}.${tableName}`);
|