@uigraph/sdk 1.1.35 → 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/LICENSE ADDED
@@ -0,0 +1,101 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ Parameters
7
+
8
+ Licensor: UiGraph, Inc.
9
+ Licensed Work: The software made available under this License in this
10
+ repository (the "Licensed Work"). The Licensed Work is
11
+ (c) UiGraph, Inc.
12
+ Additional Use Grant: You may make non-production use of the Licensed Work
13
+ free of charge, including for development, testing,
14
+ evaluation, and internal proof-of-concept purposes.
15
+
16
+ Any production use of the Licensed Work requires a
17
+ commercial license from Licensor. "Production use"
18
+ means any use that supports the ongoing operation of
19
+ your business or organization, including but not
20
+ limited to deploying the Licensed Work to serve
21
+ employees, customers, or end users.
22
+
23
+ This Additional Use Grant does not authorize offering
24
+ the Licensed Work, or any product incorporating it, to
25
+ third parties on a hosted, managed, or embedded basis
26
+ in competition with Licensor's commercial offerings.
27
+ Change Date: Four years from the date the specific version of the
28
+ Licensed Work is published.
29
+ Change License: Apache License 2.0
30
+
31
+ Notice
32
+
33
+ The Business Source License (this document, or the "License") is not an Open
34
+ Source license. However, the Licensed Work will eventually be made available
35
+ under an Open Source License, as stated in this License.
36
+
37
+ Terms
38
+
39
+ The Licensor hereby grants you the right to copy, modify, create derivative
40
+ works, redistribute, and make non-production use of the Licensed Work. The
41
+ Licensor may make an Additional Use Grant, above, permitting limited production use.
42
+
43
+ Effective on the Change Date, or the fourth anniversary of the first publicly
44
+ available distribution of a specific version of the Licensed Work under this
45
+ License, whichever comes first, the Licensor hereby grants you rights under
46
+ the terms of the Change License, and the rights granted in the paragraph
47
+ above terminate.
48
+
49
+ If your use of the Licensed Work does not comply with the requirements
50
+ currently in effect as described in this License, you must purchase a
51
+ commercial license from the Licensor, its affiliated entities, or authorized
52
+ resellers, or you must refrain from using the Licensed Work.
53
+
54
+ All copies of the original and modified Licensed Work, and derivative works
55
+ of the Licensed Work, are subject to this License. This License applies
56
+ separately for each version of the Licensed Work and the Change Date may vary
57
+ for each version of the Licensed Work released by Licensor.
58
+
59
+ You must conspicuously display this License on each original or modified copy
60
+ of the Licensed Work. If you receive the Licensed Work in original or
61
+ modified form from a third party, the terms and conditions set forth in this
62
+ License apply to your use of that work.
63
+
64
+ Any use of the Licensed Work in violation of this License will automatically
65
+ terminate your rights under this License for the current and all other
66
+ versions of the Licensed Work.
67
+
68
+ This License does not grant you any right in any trademark or logo of
69
+ Licensor or its affiliates (provided that you may use a trademark or logo of
70
+ Licensor as expressly required by this License).
71
+
72
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
73
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
74
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
75
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
76
+ TITLE.
77
+
78
+ MariaDB hereby grants you permission to use this License's text to license
79
+ your works, and to refer to it using the trademark "Business Source License",
80
+ as long as you comply with the Covenants of Licensor below.
81
+
82
+ Covenants of Licensor
83
+
84
+ In consideration of the right to use this License's text and the "Business
85
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
86
+ other recipients of the licensed work to be provided by Licensor:
87
+
88
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
89
+ or a license that is compatible with GPL Version 2.0 or a later version,
90
+ where "compatible" means that software provided under the Change License can
91
+ be included in a program with software provided under GPL Version 2.0 or a
92
+ later version. Licensor may specify additional Change Licenses without
93
+ limitation.
94
+
95
+ 2. To either: (a) specify an additional grant of rights to use that does not
96
+ impose any additional restriction on the right granted in this License, as
97
+ the Additional Use Grant; or (b) insert the text "None".
98
+
99
+ 3. To specify a Change Date.
100
+
101
+ 4. Not to modify this License in any other way.
package/README.md CHANGED
@@ -1,7 +1,114 @@
1
+ # @uigraph/sdk
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@uigraph/sdk)](https://www.npmjs.com/package/@uigraph/sdk)
4
+ [![license](https://img.shields.io/badge/license-BUSL--1.1-blue)](LICENSE)
5
+
6
+ Official TypeScript SDK for [UiGraph](https://github.com/uigraph-oss). Parse SQL and NoSQL schemas, convert Mermaid diagrams, and produce [React Flow](https://reactflow.dev/) node and edge data for architecture and data-model diagrams.
7
+
8
+ ## Features
9
+
10
+ - **Mermaid → React Flow** — flowcharts, sequence diagrams, and more
11
+ - **Context-aware conversion** — apply node, edge, and group overrides after parsing
12
+ - **SQL parsing** — MySQL, PostgreSQL, SQLite with dialect auto-detection
13
+ - **Schema → diagram** — convert SQL AST into diagram-ready structures
14
+ - **NoSQL schemas** — MongoDB, DynamoDB, and JSON schema support
15
+ - **Icon packs** — AWS, Azure, and animated node icon lists
16
+ - **Multiple runtimes** — full, browser, and headless entry points
17
+
18
+ ## Install
19
+
1
20
  ```sh
2
- pnpm install
21
+ npm install @uigraph/sdk
3
22
  ```
4
23
 
24
+ Peer dependencies (install if you do not already have them):
25
+
5
26
  ```sh
6
- ./npm-auth.sh
27
+ npm install @xyflow/react zod quill
28
+ ```
29
+
30
+ ## Quick start
31
+
32
+ Convert Mermaid source into React Flow data:
33
+
34
+ ```ts
35
+ import { convertMermaidToReactFlow } from '@uigraph/sdk'
36
+
37
+ const mermaid = `flowchart TD
38
+ A[Start] --> B{Decision}
39
+ B -->|Yes| C[Done]
40
+ B -->|No| D[Retry]
41
+ `
42
+
43
+ const { nodes, edges } = await convertMermaidToReactFlow(mermaid)
44
+ ```
45
+
46
+ Parse SQL and work with the schema AST:
47
+
48
+ ```ts
49
+ import { SqlToAstParser } from '@uigraph/sdk'
50
+
51
+ const dialect = SqlToAstParser.detectDialect(sql)
52
+ const ast = new SqlToAstParser(dialect).parse(sql)
7
53
  ```
54
+
55
+ ## Package entry points
56
+
57
+ | Import | Use when |
58
+ |--------|----------|
59
+ | `@uigraph/sdk` | Full SDK (Node.js or bundlers) |
60
+ | `@uigraph/sdk/browser` | Browser environments |
61
+ | `@uigraph/sdk/headless` | Server-side conversion without DOM APIs |
62
+ | `@uigraph/sdk/aws-icons` | AWS icon metadata |
63
+ | `@uigraph/sdk/azure-icons` | Azure icon metadata |
64
+ | `@uigraph/sdk/animated-nodes` | Animated node icon metadata |
65
+
66
+ ```ts
67
+ import { convertMermaidToReactFlow } from '@uigraph/sdk/browser'
68
+ import { awsIcons } from '@uigraph/sdk/aws-icons'
69
+ ```
70
+
71
+ ## Documentation
72
+
73
+ - [Mermaid conversion guide](docs/mermaid.md)
74
+ - [SQL parsing guide](docs/sql.md)
75
+
76
+ ## Development
77
+
78
+ Requires Node.js 20+ and [pnpm](https://pnpm.io/).
79
+
80
+ ```sh
81
+ pnpm install
82
+ pnpm dev # watch build, typecheck, and tests
83
+ pnpm test
84
+ pnpm lint
85
+ pnpm run build
86
+ ```
87
+
88
+ ### Publishing a release
89
+
90
+ 1. Bump the version in `package.json` and merge to `main`.
91
+ 2. Create a [GitHub Release](https://github.com/uigraph-oss/uigraph-sdk/releases) with tag `vX.Y.Z` matching that version.
92
+ 3. CI publishes to [npm](https://www.npmjs.com/package/@uigraph/sdk).
93
+
94
+ The repo needs an `NPM_TOKEN` secret (npm Automation token) configured before the first publish.
95
+
96
+ ## License
97
+
98
+ This project is licensed under the [Business Source License 1.1](LICENSE) (BUSL-1.1).
99
+
100
+ - **Source available today** — you can read, modify, and redistribute the code under the terms of the license.
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.
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.
104
+
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.
106
+
107
+ ## Related projects
108
+
109
+ - [uigraph-ui](https://github.com/uigraph-oss/uigraph-ui) — web application
110
+ - [uigraph-api](https://github.com/uigraph-oss/uigraph-api) — backend API
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
- service: z$1.ZodString;
83
- database: z$1.ZodString;
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
- service: zod.default.string(),
62
- database: zod.default.string(),
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
- service: z$1.ZodString;
83
- database: z$1.ZodString;
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
- service: z$1.string(),
61
- database: z$1.string(),
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({
@@ -94,8 +94,8 @@ type CustomData = {
94
94
  componentFields?: RFComponentField[];
95
95
  shape?: string;
96
96
  serviceTable?: {
97
- serviceId: string;
98
- serviceDbId: string;
97
+ serviceName: string;
98
+ databaseName: string;
99
99
  tableName: string;
100
100
  };
101
101
  title?: string;
@@ -94,8 +94,8 @@ type CustomData = {
94
94
  componentFields?: RFComponentField[];
95
95
  shape?: string;
96
96
  serviceTable?: {
97
- serviceId: string;
98
- serviceDbId: string;
97
+ serviceName: string;
98
+ databaseName: string;
99
99
  tableName: string;
100
100
  };
101
101
  title?: string;
@@ -1,4 +1,4 @@
1
- import { d as ServerComponentField } from "./__index.Ci2jxLwq.cjs";
1
+ import { d as ServerComponentField } from "./__index.CTSMJl1o.cjs";
2
2
  import "./__component-type.tW2Xh7Xk.cjs";
3
3
  import { z } from "zod";
4
4
 
@@ -1,4 +1,4 @@
1
- import { d as ServerComponentField } from "./__index.BwoDgQJ5.mjs";
1
+ import { d as ServerComponentField } from "./__index.BxD_9h1c.mjs";
2
2
  import "./__component-type.CO8FgnQE.mjs";
3
3
  import { z } from "zod";
4
4
 
package/dist/headless.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  require("./__component-type.69UkUMKl.cjs");
2
- const require_headless = require("./__headless.AhKww75N.cjs");
2
+ const require_headless = require("./__headless.DGmyg-me.cjs");
3
3
  exports.contextSchema = require_headless.contextSchema;
@@ -1,3 +1,3 @@
1
1
  import "./__component-type.tW2Xh7Xk.cjs";
2
- import { t as contextSchema } from "./__headless.B7jwmaZK.cjs";
2
+ import { t as contextSchema } from "./__headless.DfSqiw4X.cjs";
3
3
  export { contextSchema };
@@ -1,3 +1,3 @@
1
1
  import "./__component-type.CO8FgnQE.mjs";
2
- import { t as contextSchema } from "./__headless.DiJZCsKx.mjs";
2
+ import { t as contextSchema } from "./__headless.BLqB7VsJ.mjs";
3
3
  export { contextSchema };
package/dist/headless.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./__component-type.CYmD-KIu.mjs";
2
- import { t as contextSchema } from "./__headless.CP3up7Jj.mjs";
2
+ import { t as contextSchema } from "./__headless.DpdtlCFx.mjs";
3
3
  export { contextSchema };
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.AhKww75N.cjs");
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, sourceId, oldDataSources }) {
781
+ static updateReactFlow({ nodes, edges, schema, sourceName, oldDataSources }) {
782
782
  console.log("UPDATE:", {
783
783
  nodes,
784
784
  edges,
785
785
  schema,
786
- sourceId,
786
+ sourceName,
787
787
  oldDataSources
788
788
  });
789
- const oldSource = oldDataSources.find((s) => s.id === sourceId);
790
- const sourceNodePrefix = `${sourceId}-table-`;
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.id === ((_localTable = node.data.localTable) === null || _localTable === void 0 ? void 0 : _localTable.tableId);
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(sourceId, table, position, tableNames);
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.id === ((_localTable2 = node.data.localTable) === null || _localTable2 === void 0 ? void 0 : _localTable2.tableId);
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(sourceId, table, schema.tables).filter((edge) => validNodeIds.has(edge.source) && validNodeIds.has(edge.target)));
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, sourceId) {
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(sourceId, table, position, tableNames);
841
+ const node = this.tableAstToNode(sourceName, table, position, tableNames);
842
842
  nodes.push(node);
843
- const tableEdges = this.createEdgesFromTable(sourceId, table, schema.tables);
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(sourceId, table, position, _validTableNames) {
941
+ static tableAstToNode(sourceName, table, position, _validTableNames) {
942
942
  return {
943
- id: generateTableNodeId(sourceId, table.id),
943
+ id: generateTableNodeId(sourceName, table.name),
944
944
  type: "databaseTableSQL",
945
945
  width: DEFAULT_NODE_WIDTH,
946
946
  position,
947
947
  data: { localTable: {
948
- baseId: sourceId,
949
- tableId: table.id
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(baseId, sourceTable, validTables) {
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(baseId, sourceTable.id);
975
- const targetNodeId = generateTableNodeId(baseId, targetTable.id);
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 edgeColors = [
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",
@@ -3826,8 +3811,8 @@ function _convertMermaidToReactFlowWithContext() {
3826
3811
  }
3827
3812
  }
3828
3813
  if (ctx.dbConfig) clonedNode.data.serviceTable = {
3829
- serviceId: ctx.dbConfig.service,
3830
- serviceDbId: ctx.dbConfig.database,
3814
+ serviceName: ctx.dbConfig.serviceName,
3815
+ databaseName: ctx.dbConfig.databaseName,
3831
3816
  tableName: ctx.dbConfig.tableName
3832
3817
  };
3833
3818
  if ((_ctx$style = ctx.style) === null || _ctx$style === void 0 ? void 0 : _ctx$style.height) clonedNode.height = ctx.style.height;
@@ -4147,12 +4132,12 @@ function buildContextNodes(graphNodes, nodeIdMap) {
4147
4132
  rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
4148
4133
  };
4149
4134
  const serviceTable = toRecord(nodeData.serviceTable);
4150
- const serviceId = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceId);
4151
- const serviceDbId = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceDbId);
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);
4152
4137
  const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
4153
- if (serviceId && serviceDbId && tableName) nodeContext.dbConfig = {
4154
- service: serviceId,
4155
- database: serviceDbId,
4138
+ if (serviceName && databaseName && tableName) nodeContext.dbConfig = {
4139
+ serviceName,
4140
+ databaseName,
4156
4141
  tableName
4157
4142
  };
4158
4143
  const dynamicData = {};
@@ -4438,9 +4423,9 @@ function resolveMermaidDetailedNodeLabel(node) {
4438
4423
  const lines = [];
4439
4424
  const serviceTable = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.serviceTable);
4440
4425
  const dbConfig = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.dbConfig);
4441
- const database = (_pickString = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceDbId)) !== null && _pickString !== void 0 ? _pickString : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.database);
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);
4442
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);
4443
- const dbService = (_pickString3 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceId)) !== null && _pickString3 !== void 0 ? _pickString3 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.service);
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);
4444
4429
  const dataSourceName = name !== null && name !== void 0 ? name : tableName;
4445
4430
  lines.push(dataSourceName ? `DataSource: ${dataSourceName}` : "DataSource");
4446
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.Ci2jxLwq.cjs";
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.B7jwmaZK.cjs";
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
- baseId: string;
135
- tableId: string;
134
+ databaseName: string;
135
+ tableName: string;
136
136
  };
137
137
  serviceTable?: {
138
- serviceId: string;
139
- serviceDbId: string;
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
- sourceId,
308
+ sourceName,
309
309
  oldDataSources
310
310
  }: {
311
311
  nodes: Node[];
312
312
  edges: Edge[];
313
- sourceId: string;
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, sourceId: string): {
320
+ static toReactFlow(schema: SchemaAST, sourceName: string): {
321
321
  nodes: Node<DatabaseTableSQLNodeData>[];
322
322
  edges: Edge[];
323
323
  };
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.BwoDgQJ5.mjs";
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.DiJZCsKx.mjs";
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
- baseId: string;
135
- tableId: string;
134
+ databaseName: string;
135
+ tableName: string;
136
136
  };
137
137
  serviceTable?: {
138
- serviceId: string;
139
- serviceDbId: string;
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
- sourceId,
308
+ sourceName,
309
309
  oldDataSources
310
310
  }: {
311
311
  nodes: Node[];
312
312
  edges: Edge[];
313
- sourceId: string;
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, sourceId: string): {
320
+ static toReactFlow(schema: SchemaAST, sourceName: string): {
321
321
  nodes: Node<DatabaseTableSQLNodeData>[];
322
322
  edges: Edge[];
323
323
  };
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.CP3up7Jj.mjs";
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, sourceId, oldDataSources }) {
775
+ static updateReactFlow({ nodes, edges, schema, sourceName, oldDataSources }) {
776
776
  console.log("UPDATE:", {
777
777
  nodes,
778
778
  edges,
779
779
  schema,
780
- sourceId,
780
+ sourceName,
781
781
  oldDataSources
782
782
  });
783
- const oldSource = oldDataSources.find((s) => s.id === sourceId);
784
- const sourceNodePrefix = `${sourceId}-table-`;
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.id === ((_localTable = node.data.localTable) === null || _localTable === void 0 ? void 0 : _localTable.tableId);
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(sourceId, table, position, tableNames);
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.id === ((_localTable2 = node.data.localTable) === null || _localTable2 === void 0 ? void 0 : _localTable2.tableId);
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(sourceId, table, schema.tables).filter((edge) => validNodeIds.has(edge.source) && validNodeIds.has(edge.target)));
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, sourceId) {
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(sourceId, table, position, tableNames);
835
+ const node = this.tableAstToNode(sourceName, table, position, tableNames);
836
836
  nodes.push(node);
837
- const tableEdges = this.createEdgesFromTable(sourceId, table, schema.tables);
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(sourceId, table, position, _validTableNames) {
935
+ static tableAstToNode(sourceName, table, position, _validTableNames) {
936
936
  return {
937
- id: generateTableNodeId(sourceId, table.id),
937
+ id: generateTableNodeId(sourceName, table.name),
938
938
  type: "databaseTableSQL",
939
939
  width: DEFAULT_NODE_WIDTH,
940
940
  position,
941
941
  data: { localTable: {
942
- baseId: sourceId,
943
- tableId: table.id
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(baseId, sourceTable, validTables) {
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(baseId, sourceTable.id);
969
- const targetNodeId = generateTableNodeId(baseId, targetTable.id);
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 edgeColors = [
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",
@@ -3819,8 +3804,8 @@ function _convertMermaidToReactFlowWithContext() {
3819
3804
  }
3820
3805
  }
3821
3806
  if (ctx.dbConfig) clonedNode.data.serviceTable = {
3822
- serviceId: ctx.dbConfig.service,
3823
- serviceDbId: ctx.dbConfig.database,
3807
+ serviceName: ctx.dbConfig.serviceName,
3808
+ databaseName: ctx.dbConfig.databaseName,
3824
3809
  tableName: ctx.dbConfig.tableName
3825
3810
  };
3826
3811
  if ((_ctx$style = ctx.style) === null || _ctx$style === void 0 ? void 0 : _ctx$style.height) clonedNode.height = ctx.style.height;
@@ -4140,12 +4125,12 @@ function buildContextNodes(graphNodes, nodeIdMap) {
4140
4125
  rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
4141
4126
  };
4142
4127
  const serviceTable = toRecord(nodeData.serviceTable);
4143
- const serviceId = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceId);
4144
- const serviceDbId = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceDbId);
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);
4145
4130
  const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
4146
- if (serviceId && serviceDbId && tableName) nodeContext.dbConfig = {
4147
- service: serviceId,
4148
- database: serviceDbId,
4131
+ if (serviceName && databaseName && tableName) nodeContext.dbConfig = {
4132
+ serviceName,
4133
+ databaseName,
4149
4134
  tableName
4150
4135
  };
4151
4136
  const dynamicData = {};
@@ -4431,9 +4416,9 @@ function resolveMermaidDetailedNodeLabel(node) {
4431
4416
  const lines = [];
4432
4417
  const serviceTable = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.serviceTable);
4433
4418
  const dbConfig = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.dbConfig);
4434
- const database = (_pickString = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceDbId)) !== null && _pickString !== void 0 ? _pickString : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.database);
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);
4435
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);
4436
- const dbService = (_pickString3 = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceId)) !== null && _pickString3 !== void 0 ? _pickString3 : pickString(dbConfig === null || dbConfig === void 0 ? void 0 : dbConfig.service);
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);
4437
4422
  const dataSourceName = name !== null && name !== void 0 ? name : tableName;
4438
4423
  lines.push(dataSourceName ? `DataSource: ${dataSourceName}` : "DataSource");
4439
4424
  if (database && tableName) lines.push(`db: ${database}.${tableName}`);
package/package.json CHANGED
@@ -1,7 +1,21 @@
1
1
  {
2
2
  "name": "@uigraph/sdk",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "type": "module",
5
+ "license": "BUSL-1.1",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/uigraph-oss/uigraph-sdk.git"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "registry": "https://registry.npmjs.org/"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
5
19
  "scripts": {
6
20
  "prepare": "husky",
7
21
  "test": "vitest --run",