@uigraph/sdk 1.2.9 → 1.2.11
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/index.cjs +84 -25
- package/dist/index.d.cts +7 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.mjs +84 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1779,6 +1779,88 @@ function syncBaseData(prev, next, options) {
|
|
|
1779
1779
|
}
|
|
1780
1780
|
return updated;
|
|
1781
1781
|
}
|
|
1782
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
1783
|
+
try {
|
|
1784
|
+
var i = n[a](c), u = i.value;
|
|
1785
|
+
} catch (n$1) {
|
|
1786
|
+
e(n$1);
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
1790
|
+
}
|
|
1791
|
+
function _asyncToGenerator(n) {
|
|
1792
|
+
return function() {
|
|
1793
|
+
var t = this, e = arguments;
|
|
1794
|
+
return new Promise(function(r, o) {
|
|
1795
|
+
var a = n.apply(t, e);
|
|
1796
|
+
function _next(n$1) {
|
|
1797
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n$1);
|
|
1798
|
+
}
|
|
1799
|
+
function _throw(n$1) {
|
|
1800
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n$1);
|
|
1801
|
+
}
|
|
1802
|
+
_next(void 0);
|
|
1803
|
+
});
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
const TRANSIENT_NODE_KEYS = new Set([
|
|
1807
|
+
"selected",
|
|
1808
|
+
"dragging",
|
|
1809
|
+
"resizing",
|
|
1810
|
+
"positionAbsolute",
|
|
1811
|
+
"measured",
|
|
1812
|
+
"internals",
|
|
1813
|
+
"handleBounds",
|
|
1814
|
+
"childNodes"
|
|
1815
|
+
]);
|
|
1816
|
+
const TRANSIENT_EDGE_KEYS = new Set(["selected"]);
|
|
1817
|
+
function cleanNodeForSync(node) {
|
|
1818
|
+
const cleaned = {};
|
|
1819
|
+
for (const [key, value] of Object.entries(node)) if (!TRANSIENT_NODE_KEYS.has(key) && value !== void 0) cleaned[key] = value;
|
|
1820
|
+
return cleaned;
|
|
1821
|
+
}
|
|
1822
|
+
function cleanEdgeForSync(edge) {
|
|
1823
|
+
const cleaned = {};
|
|
1824
|
+
for (const [key, value] of Object.entries(edge)) if (!TRANSIENT_EDGE_KEYS.has(key) && value !== void 0) cleaned[key] = value;
|
|
1825
|
+
return cleaned;
|
|
1826
|
+
}
|
|
1827
|
+
function canonicalizeValue(val) {
|
|
1828
|
+
if (val === null || typeof val !== "object") return val;
|
|
1829
|
+
if (Array.isArray(val)) return val.map(canonicalizeValue);
|
|
1830
|
+
const obj = val;
|
|
1831
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
1832
|
+
const result = {};
|
|
1833
|
+
for (const key of sortedKeys) {
|
|
1834
|
+
const value = obj[key];
|
|
1835
|
+
if (value !== void 0) result[key] = canonicalizeValue(value);
|
|
1836
|
+
}
|
|
1837
|
+
return result;
|
|
1838
|
+
}
|
|
1839
|
+
function computeCanonicalSyncPayload(diagram) {
|
|
1840
|
+
const nodes = Array.isArray(diagram.nodes) ? diagram.nodes : [];
|
|
1841
|
+
const edges = Array.isArray(diagram.edges) ? diagram.edges : [];
|
|
1842
|
+
const cleanedNodes = nodes.map((node) => node !== null && typeof node === "object" ? cleanNodeForSync(node) : node);
|
|
1843
|
+
const cleanedEdges = edges.map((edge) => edge !== null && typeof edge === "object" ? cleanEdgeForSync(edge) : edge);
|
|
1844
|
+
const serialized = JSON.parse(JSON.stringify({
|
|
1845
|
+
edges: cleanedEdges,
|
|
1846
|
+
nodes: cleanedNodes
|
|
1847
|
+
}));
|
|
1848
|
+
return `uigraph-sync-v1:${JSON.stringify(canonicalizeValue(serialized))}`;
|
|
1849
|
+
}
|
|
1850
|
+
function computeDiagramSyncHash(_x) {
|
|
1851
|
+
return _computeDiagramSyncHash.apply(this, arguments);
|
|
1852
|
+
}
|
|
1853
|
+
function _computeDiagramSyncHash() {
|
|
1854
|
+
_computeDiagramSyncHash = _asyncToGenerator(function* (diagram) {
|
|
1855
|
+
var _globalThis$crypto;
|
|
1856
|
+
const subtle = (_globalThis$crypto = globalThis.crypto) === null || _globalThis$crypto === void 0 ? void 0 : _globalThis$crypto.subtle;
|
|
1857
|
+
if (subtle === void 0) throw new Error("computeDiagramSyncHash requires SubtleCrypto, which is only available in a secure context (https or localhost)");
|
|
1858
|
+
const payload = computeCanonicalSyncPayload(diagram);
|
|
1859
|
+
const digest = yield subtle.digest("SHA-256", new TextEncoder().encode(payload));
|
|
1860
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1861
|
+
});
|
|
1862
|
+
return _computeDiagramSyncHash.apply(this, arguments);
|
|
1863
|
+
}
|
|
1782
1864
|
function flattenMetaData(fields, fieldsValues) {
|
|
1783
1865
|
const output = {};
|
|
1784
1866
|
fields.forEach((field) => {
|
|
@@ -2351,7 +2433,7 @@ const C4_LAYOUT = {
|
|
|
2351
2433
|
SHAPE_PADDING: 24,
|
|
2352
2434
|
BOUNDARY_HEADER: 72,
|
|
2353
2435
|
BOUNDARY_PADDING: 48,
|
|
2354
|
-
BOUNDARY_MARGIN:
|
|
2436
|
+
BOUNDARY_MARGIN: 120,
|
|
2355
2437
|
DIAGRAM_MARGIN_X: 60,
|
|
2356
2438
|
DIAGRAM_MARGIN_Y: 40
|
|
2357
2439
|
};
|
|
@@ -3220,30 +3302,6 @@ function parseMermaidCode(code) {
|
|
|
3220
3302
|
direction
|
|
3221
3303
|
};
|
|
3222
3304
|
}
|
|
3223
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3224
|
-
try {
|
|
3225
|
-
var i = n[a](c), u = i.value;
|
|
3226
|
-
} catch (n$1) {
|
|
3227
|
-
e(n$1);
|
|
3228
|
-
return;
|
|
3229
|
-
}
|
|
3230
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
3231
|
-
}
|
|
3232
|
-
function _asyncToGenerator(n) {
|
|
3233
|
-
return function() {
|
|
3234
|
-
var t = this, e = arguments;
|
|
3235
|
-
return new Promise(function(r, o) {
|
|
3236
|
-
var a = n.apply(t, e);
|
|
3237
|
-
function _next(n$1) {
|
|
3238
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n$1);
|
|
3239
|
-
}
|
|
3240
|
-
function _throw(n$1) {
|
|
3241
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n$1);
|
|
3242
|
-
}
|
|
3243
|
-
_next(void 0);
|
|
3244
|
-
});
|
|
3245
|
-
};
|
|
3246
|
-
}
|
|
3247
3305
|
const MERMAID_TO_PORTAL_SHAPE = {
|
|
3248
3306
|
rect: "rectangle",
|
|
3249
3307
|
round: "rounded-rect",
|
|
@@ -6861,6 +6919,7 @@ exports.NoSqlFieldSchema = NoSqlFieldSchema;
|
|
|
6861
6919
|
exports.SEQUENCE_LAYOUT = SEQUENCE_LAYOUT;
|
|
6862
6920
|
exports.SqlToAstParser = SqlToAstParser;
|
|
6863
6921
|
exports.buildMetaData = buildMetaData;
|
|
6922
|
+
exports.computeDiagramSyncHash = computeDiagramSyncHash;
|
|
6864
6923
|
exports.contextSchema = require_headless.contextSchema;
|
|
6865
6924
|
exports.convertC4MermaidToReactFlow = convertC4MermaidToReactFlow;
|
|
6866
6925
|
exports.convertC4ToReactFlow = convertC4ToReactFlow;
|
package/dist/index.d.cts
CHANGED
|
@@ -732,6 +732,12 @@ type Options = {
|
|
|
732
732
|
};
|
|
733
733
|
declare function syncBaseData(prev: ReactFlowData, next: ReactFlowData, options?: Options): ReactFlowData;
|
|
734
734
|
//#endregion
|
|
735
|
+
//#region src/sync-hash/index.d.ts
|
|
736
|
+
declare function computeDiagramSyncHash(diagram: {
|
|
737
|
+
nodes?: unknown[];
|
|
738
|
+
edges?: unknown[];
|
|
739
|
+
}): Promise<string>;
|
|
740
|
+
//#endregion
|
|
735
741
|
//#region src/mermaid-converter/index.d.ts
|
|
736
742
|
declare function convertMermaidToReactFlow(mermaidCode: string): Promise<ReactFlowData>;
|
|
737
743
|
//#endregion
|
|
@@ -908,4 +914,4 @@ declare function convertMermaidToReactFlowWithContext(mermaidCode: string, conte
|
|
|
908
914
|
//#region src/uig-converter/index.d.ts
|
|
909
915
|
declare function convertUiGraphToMermaid(input: UiGraphInput, options?: UiGraphOptions): UigOutput;
|
|
910
916
|
//#endregion
|
|
911
|
-
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4Boundary, C4BoundaryKind, C4DiagramData, C4DiagramType, C4Direction, C4Element, C4ElementKind, C4ElementShape, C4ElementStyle, C4LayoutConfig, C4NodeType, C4RelDirection, C4RelStyle, C4Relationship, C4_COLORS, C4_LAYOUT, CheckConstraintAST, ColumnAST, ComponentInputType, ConstraintAST, CustomData, DataTypeAST, DefaultValueAST, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, ForeignKeyConstraintAST, IndexAST, IndexColumnAST, IndexMethodAST, JsonEditorSchema, LinkOrFileValue, MermaidEdge, MermaidNode, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, PrimaryKeyConstraintAST, RFComponentField, ReactFlowData, ReferentialActionAST, SEQUENCE_LAYOUT, SchemaAST, SchemaDialect, SchemaUIRepresentation, SequenceActivation, SequenceArrowHead, SequenceAutonumber, SequenceBlock, SequenceBlockSection, SequenceBlockType, SequenceBox, SequenceDiagramData, SequenceMessage, SequenceNote, SequenceParticipant, SequenceParticipantLink, SequenceParticipantType, ServerComponentField, ServerComponentFieldInput, SqlToAstParser, SubgraphInfo, SubgraphLayout, TParsedColumn, TParsedForeignKey, TParsedIndex, TParsedSchema, TParsedTable, TableAST, TableOptionsAST, UniqueConstraintAST, buildMetaData, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToC4Mermaid, convertReactFlowToC4UiGraph, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isC4ReactFlowDiagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|
|
917
|
+
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4Boundary, C4BoundaryKind, C4DiagramData, C4DiagramType, C4Direction, C4Element, C4ElementKind, C4ElementShape, C4ElementStyle, C4LayoutConfig, C4NodeType, C4RelDirection, C4RelStyle, C4Relationship, C4_COLORS, C4_LAYOUT, CheckConstraintAST, ColumnAST, ComponentInputType, ConstraintAST, CustomData, DataTypeAST, DefaultValueAST, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, ForeignKeyConstraintAST, IndexAST, IndexColumnAST, IndexMethodAST, JsonEditorSchema, LinkOrFileValue, MermaidEdge, MermaidNode, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, PrimaryKeyConstraintAST, RFComponentField, ReactFlowData, ReferentialActionAST, SEQUENCE_LAYOUT, SchemaAST, SchemaDialect, SchemaUIRepresentation, SequenceActivation, SequenceArrowHead, SequenceAutonumber, SequenceBlock, SequenceBlockSection, SequenceBlockType, SequenceBox, SequenceDiagramData, SequenceMessage, SequenceNote, SequenceParticipant, SequenceParticipantLink, SequenceParticipantType, ServerComponentField, ServerComponentFieldInput, SqlToAstParser, SubgraphInfo, SubgraphLayout, TParsedColumn, TParsedForeignKey, TParsedIndex, TParsedSchema, TParsedTable, TableAST, TableOptionsAST, UniqueConstraintAST, buildMetaData, computeDiagramSyncHash, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToC4Mermaid, convertReactFlowToC4UiGraph, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isC4ReactFlowDiagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|
package/dist/index.d.mts
CHANGED
|
@@ -732,6 +732,12 @@ type Options = {
|
|
|
732
732
|
};
|
|
733
733
|
declare function syncBaseData(prev: ReactFlowData, next: ReactFlowData, options?: Options): ReactFlowData;
|
|
734
734
|
//#endregion
|
|
735
|
+
//#region src/sync-hash/index.d.ts
|
|
736
|
+
declare function computeDiagramSyncHash(diagram: {
|
|
737
|
+
nodes?: unknown[];
|
|
738
|
+
edges?: unknown[];
|
|
739
|
+
}): Promise<string>;
|
|
740
|
+
//#endregion
|
|
735
741
|
//#region src/mermaid-converter/index.d.ts
|
|
736
742
|
declare function convertMermaidToReactFlow(mermaidCode: string): Promise<ReactFlowData>;
|
|
737
743
|
//#endregion
|
|
@@ -908,4 +914,4 @@ declare function convertMermaidToReactFlowWithContext(mermaidCode: string, conte
|
|
|
908
914
|
//#region src/uig-converter/index.d.ts
|
|
909
915
|
declare function convertUiGraphToMermaid(input: UiGraphInput, options?: UiGraphOptions): UigOutput;
|
|
910
916
|
//#endregion
|
|
911
|
-
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4Boundary, C4BoundaryKind, C4DiagramData, C4DiagramType, C4Direction, C4Element, C4ElementKind, C4ElementShape, C4ElementStyle, C4LayoutConfig, C4NodeType, C4RelDirection, C4RelStyle, C4Relationship, C4_COLORS, C4_LAYOUT, CheckConstraintAST, ColumnAST, ComponentInputType, ConstraintAST, CustomData, DataTypeAST, DefaultValueAST, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, ForeignKeyConstraintAST, IndexAST, IndexColumnAST, IndexMethodAST, JsonEditorSchema, LinkOrFileValue, MermaidEdge, MermaidNode, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, PrimaryKeyConstraintAST, RFComponentField, ReactFlowData, ReferentialActionAST, SEQUENCE_LAYOUT, SchemaAST, SchemaDialect, SchemaUIRepresentation, SequenceActivation, SequenceArrowHead, SequenceAutonumber, SequenceBlock, SequenceBlockSection, SequenceBlockType, SequenceBox, SequenceDiagramData, SequenceMessage, SequenceNote, SequenceParticipant, SequenceParticipantLink, SequenceParticipantType, ServerComponentField, ServerComponentFieldInput, SqlToAstParser, SubgraphInfo, SubgraphLayout, TParsedColumn, TParsedForeignKey, TParsedIndex, TParsedSchema, TParsedTable, TableAST, TableOptionsAST, UniqueConstraintAST, buildMetaData, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToC4Mermaid, convertReactFlowToC4UiGraph, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isC4ReactFlowDiagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|
|
917
|
+
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4Boundary, C4BoundaryKind, C4DiagramData, C4DiagramType, C4Direction, C4Element, C4ElementKind, C4ElementShape, C4ElementStyle, C4LayoutConfig, C4NodeType, C4RelDirection, C4RelStyle, C4Relationship, C4_COLORS, C4_LAYOUT, CheckConstraintAST, ColumnAST, ComponentInputType, ConstraintAST, CustomData, DataTypeAST, DefaultValueAST, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, ForeignKeyConstraintAST, IndexAST, IndexColumnAST, IndexMethodAST, JsonEditorSchema, LinkOrFileValue, MermaidEdge, MermaidNode, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, PrimaryKeyConstraintAST, RFComponentField, ReactFlowData, ReferentialActionAST, SEQUENCE_LAYOUT, SchemaAST, SchemaDialect, SchemaUIRepresentation, SequenceActivation, SequenceArrowHead, SequenceAutonumber, SequenceBlock, SequenceBlockSection, SequenceBlockType, SequenceBox, SequenceDiagramData, SequenceMessage, SequenceNote, SequenceParticipant, SequenceParticipantLink, SequenceParticipantType, ServerComponentField, ServerComponentFieldInput, SqlToAstParser, SubgraphInfo, SubgraphLayout, TParsedColumn, TParsedForeignKey, TParsedIndex, TParsedSchema, TParsedTable, TableAST, TableOptionsAST, UniqueConstraintAST, buildMetaData, computeDiagramSyncHash, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToC4Mermaid, convertReactFlowToC4UiGraph, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isC4ReactFlowDiagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|
package/dist/index.mjs
CHANGED
|
@@ -1773,6 +1773,88 @@ function syncBaseData(prev, next, options) {
|
|
|
1773
1773
|
}
|
|
1774
1774
|
return updated;
|
|
1775
1775
|
}
|
|
1776
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
1777
|
+
try {
|
|
1778
|
+
var i = n[a](c), u = i.value;
|
|
1779
|
+
} catch (n$1) {
|
|
1780
|
+
e(n$1);
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
1784
|
+
}
|
|
1785
|
+
function _asyncToGenerator(n) {
|
|
1786
|
+
return function() {
|
|
1787
|
+
var t = this, e = arguments;
|
|
1788
|
+
return new Promise(function(r, o) {
|
|
1789
|
+
var a = n.apply(t, e);
|
|
1790
|
+
function _next(n$1) {
|
|
1791
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n$1);
|
|
1792
|
+
}
|
|
1793
|
+
function _throw(n$1) {
|
|
1794
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n$1);
|
|
1795
|
+
}
|
|
1796
|
+
_next(void 0);
|
|
1797
|
+
});
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
const TRANSIENT_NODE_KEYS = new Set([
|
|
1801
|
+
"selected",
|
|
1802
|
+
"dragging",
|
|
1803
|
+
"resizing",
|
|
1804
|
+
"positionAbsolute",
|
|
1805
|
+
"measured",
|
|
1806
|
+
"internals",
|
|
1807
|
+
"handleBounds",
|
|
1808
|
+
"childNodes"
|
|
1809
|
+
]);
|
|
1810
|
+
const TRANSIENT_EDGE_KEYS = new Set(["selected"]);
|
|
1811
|
+
function cleanNodeForSync(node) {
|
|
1812
|
+
const cleaned = {};
|
|
1813
|
+
for (const [key, value] of Object.entries(node)) if (!TRANSIENT_NODE_KEYS.has(key) && value !== void 0) cleaned[key] = value;
|
|
1814
|
+
return cleaned;
|
|
1815
|
+
}
|
|
1816
|
+
function cleanEdgeForSync(edge) {
|
|
1817
|
+
const cleaned = {};
|
|
1818
|
+
for (const [key, value] of Object.entries(edge)) if (!TRANSIENT_EDGE_KEYS.has(key) && value !== void 0) cleaned[key] = value;
|
|
1819
|
+
return cleaned;
|
|
1820
|
+
}
|
|
1821
|
+
function canonicalizeValue(val) {
|
|
1822
|
+
if (val === null || typeof val !== "object") return val;
|
|
1823
|
+
if (Array.isArray(val)) return val.map(canonicalizeValue);
|
|
1824
|
+
const obj = val;
|
|
1825
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
1826
|
+
const result = {};
|
|
1827
|
+
for (const key of sortedKeys) {
|
|
1828
|
+
const value = obj[key];
|
|
1829
|
+
if (value !== void 0) result[key] = canonicalizeValue(value);
|
|
1830
|
+
}
|
|
1831
|
+
return result;
|
|
1832
|
+
}
|
|
1833
|
+
function computeCanonicalSyncPayload(diagram) {
|
|
1834
|
+
const nodes = Array.isArray(diagram.nodes) ? diagram.nodes : [];
|
|
1835
|
+
const edges = Array.isArray(diagram.edges) ? diagram.edges : [];
|
|
1836
|
+
const cleanedNodes = nodes.map((node) => node !== null && typeof node === "object" ? cleanNodeForSync(node) : node);
|
|
1837
|
+
const cleanedEdges = edges.map((edge) => edge !== null && typeof edge === "object" ? cleanEdgeForSync(edge) : edge);
|
|
1838
|
+
const serialized = JSON.parse(JSON.stringify({
|
|
1839
|
+
edges: cleanedEdges,
|
|
1840
|
+
nodes: cleanedNodes
|
|
1841
|
+
}));
|
|
1842
|
+
return `uigraph-sync-v1:${JSON.stringify(canonicalizeValue(serialized))}`;
|
|
1843
|
+
}
|
|
1844
|
+
function computeDiagramSyncHash(_x) {
|
|
1845
|
+
return _computeDiagramSyncHash.apply(this, arguments);
|
|
1846
|
+
}
|
|
1847
|
+
function _computeDiagramSyncHash() {
|
|
1848
|
+
_computeDiagramSyncHash = _asyncToGenerator(function* (diagram) {
|
|
1849
|
+
var _globalThis$crypto;
|
|
1850
|
+
const subtle = (_globalThis$crypto = globalThis.crypto) === null || _globalThis$crypto === void 0 ? void 0 : _globalThis$crypto.subtle;
|
|
1851
|
+
if (subtle === void 0) throw new Error("computeDiagramSyncHash requires SubtleCrypto, which is only available in a secure context (https or localhost)");
|
|
1852
|
+
const payload = computeCanonicalSyncPayload(diagram);
|
|
1853
|
+
const digest = yield subtle.digest("SHA-256", new TextEncoder().encode(payload));
|
|
1854
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1855
|
+
});
|
|
1856
|
+
return _computeDiagramSyncHash.apply(this, arguments);
|
|
1857
|
+
}
|
|
1776
1858
|
function flattenMetaData(fields, fieldsValues) {
|
|
1777
1859
|
const output = {};
|
|
1778
1860
|
fields.forEach((field) => {
|
|
@@ -2345,7 +2427,7 @@ const C4_LAYOUT = {
|
|
|
2345
2427
|
SHAPE_PADDING: 24,
|
|
2346
2428
|
BOUNDARY_HEADER: 72,
|
|
2347
2429
|
BOUNDARY_PADDING: 48,
|
|
2348
|
-
BOUNDARY_MARGIN:
|
|
2430
|
+
BOUNDARY_MARGIN: 120,
|
|
2349
2431
|
DIAGRAM_MARGIN_X: 60,
|
|
2350
2432
|
DIAGRAM_MARGIN_Y: 40
|
|
2351
2433
|
};
|
|
@@ -3213,30 +3295,6 @@ function parseMermaidCode(code) {
|
|
|
3213
3295
|
direction
|
|
3214
3296
|
};
|
|
3215
3297
|
}
|
|
3216
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3217
|
-
try {
|
|
3218
|
-
var i = n[a](c), u = i.value;
|
|
3219
|
-
} catch (n$1) {
|
|
3220
|
-
e(n$1);
|
|
3221
|
-
return;
|
|
3222
|
-
}
|
|
3223
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
3224
|
-
}
|
|
3225
|
-
function _asyncToGenerator(n) {
|
|
3226
|
-
return function() {
|
|
3227
|
-
var t = this, e = arguments;
|
|
3228
|
-
return new Promise(function(r, o) {
|
|
3229
|
-
var a = n.apply(t, e);
|
|
3230
|
-
function _next(n$1) {
|
|
3231
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n$1);
|
|
3232
|
-
}
|
|
3233
|
-
function _throw(n$1) {
|
|
3234
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n$1);
|
|
3235
|
-
}
|
|
3236
|
-
_next(void 0);
|
|
3237
|
-
});
|
|
3238
|
-
};
|
|
3239
|
-
}
|
|
3240
3298
|
const MERMAID_TO_PORTAL_SHAPE = {
|
|
3241
3299
|
rect: "rectangle",
|
|
3242
3300
|
round: "rounded-rect",
|
|
@@ -6830,4 +6888,4 @@ function convertUiGraphToMermaid(input, options) {
|
|
|
6830
6888
|
context
|
|
6831
6889
|
};
|
|
6832
6890
|
}
|
|
6833
|
-
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4_COLORS, C4_LAYOUT, ComponentInputType, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, JsonEditorSchema, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, SEQUENCE_LAYOUT, SqlToAstParser, buildMetaData, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToC4Mermaid, convertReactFlowToC4UiGraph, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isC4ReactFlowDiagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|
|
6891
|
+
export { AstToSqlGenerator, AstToUiConverter, BasicDetailsSchema, C4_COLORS, C4_LAYOUT, ComponentInputType, DialectIdSchema, DocumentCollectionSchema, DocumentIndexSchema, DynamoAttributeSchema, DynamoEditorSchema, DynamoGsiSchema, EditorSupportedDialectSchema, JsonEditorSchema, MongoCollectionSchema, MongoEditorSchema, MongoIndexFieldSchema, MongoIndexSchema, MongoNestedFieldSchema, NestedFieldSchema, NoSqlFieldSchema, SEQUENCE_LAYOUT, SqlToAstParser, buildMetaData, computeDiagramSyncHash, contextSchema, convertC4MermaidToReactFlow, convertC4ToReactFlow, convertDynamoSchemaToAst, convertJsonSchemaToAst, convertMermaidToReactFlow, convertMermaidToReactFlowWithContext, convertMongoSchemaToAst, convertNoSQLToAst, convertReactFlowToC4Mermaid, convertReactFlowToC4UiGraph, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isC4ReactFlowDiagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|