@uigraph/sdk 1.2.7 → 1.2.8
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 +1 -1
- package/dist/{__index.BVDt3Nmx.d.cts → __index.B1JSpBNJ.d.cts} +4 -0
- package/dist/{__index.BQQp_uAt.d.mts → __index.BjLNt7Hi.d.mts} +4 -0
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.mts +1 -1
- package/dist/index.cjs +289 -82
- package/dist/index.d.cts +20 -15
- package/dist/index.d.mts +20 -15
- package/dist/index.mjs +287 -83
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -2558,6 +2558,7 @@ function convertC4ToReactFlow(data) {
|
|
|
2558
2558
|
},
|
|
2559
2559
|
data: {
|
|
2560
2560
|
source: "mermaid",
|
|
2561
|
+
c4DiagramType: data.type,
|
|
2561
2562
|
c4BoundaryKind: boundary.kind,
|
|
2562
2563
|
boundaryType: boundary.type,
|
|
2563
2564
|
description: boundary.description,
|
|
@@ -2597,6 +2598,7 @@ function convertC4ToReactFlow(data) {
|
|
|
2597
2598
|
source: "mermaid",
|
|
2598
2599
|
diagramId: element.subDiagramId,
|
|
2599
2600
|
diagramName: element.label,
|
|
2601
|
+
c4DiagramType: data.type,
|
|
2600
2602
|
c4Kind: element.kind,
|
|
2601
2603
|
c4Shape: element.shape,
|
|
2602
2604
|
isExternal: element.isExternal,
|
|
@@ -2660,6 +2662,9 @@ function convertC4ToReactFlow(data) {
|
|
|
2660
2662
|
},
|
|
2661
2663
|
data: {
|
|
2662
2664
|
source: "mermaid",
|
|
2665
|
+
c4RelDirection: rel.direction,
|
|
2666
|
+
c4RelTechnology: rel.technology,
|
|
2667
|
+
c4RelDescription: rel.description,
|
|
2663
2668
|
labelColor: style === null || style === void 0 ? void 0 : style.textColor,
|
|
2664
2669
|
labelOffsetX: style === null || style === void 0 ? void 0 : style.offsetX,
|
|
2665
2670
|
labelOffsetY: style === null || style === void 0 ? void 0 : style.offsetY
|
|
@@ -5192,31 +5197,6 @@ function _convertMermaidToReactFlow() {
|
|
|
5192
5197
|
});
|
|
5193
5198
|
return _convertMermaidToReactFlow.apply(this, arguments);
|
|
5194
5199
|
}
|
|
5195
|
-
function sanitizeMermaidLabels(src) {
|
|
5196
|
-
if (!src) return src;
|
|
5197
|
-
const subgraphFixed = src.replace(/([A-Za-z0-9_]+)\[((?:(?![\"']).)*?)\]/g, (m, id, label) => {
|
|
5198
|
-
if (/^[\"']/.test(label)) return m;
|
|
5199
|
-
if (/[()\"\[\],:;]/.test(label)) return `${id}[\"${String(label).replace(/\\/g, "\\\\").replace(/\"/g, "\\\"")}\"]`;
|
|
5200
|
-
return m;
|
|
5201
|
-
}).replace(/^([ \t]*subgraph\s+)([^\n\r]+)(\|[^\n\r]*)?$/gim, (m, pre, title, rest) => {
|
|
5202
|
-
const t = String(title).trim();
|
|
5203
|
-
if (/^[\"']/.test(t)) return m;
|
|
5204
|
-
if (/[()\"\[\],:;]/.test(t)) return `${pre}\"${t.replace(/\\/g, "\\\\").replace(/\"/g, "\\\"")}\"${rest || ""}`;
|
|
5205
|
-
return m;
|
|
5206
|
-
});
|
|
5207
|
-
const diagRegex = /\b(graph|flowchart|sequenceDiagram|stateDiagram|classDiagram|gantt|journey|erDiagram|gitGraph|pie|timeline|infoDiagram)\b/i;
|
|
5208
|
-
const allStarts = [];
|
|
5209
|
-
let mm;
|
|
5210
|
-
const globalRegex = new RegExp(diagRegex.source, "gim");
|
|
5211
|
-
while ((mm = globalRegex.exec(subgraphFixed)) !== null) {
|
|
5212
|
-
allStarts.push(mm.index);
|
|
5213
|
-
if (globalRegex.lastIndex === mm.index) globalRegex.lastIndex++;
|
|
5214
|
-
}
|
|
5215
|
-
if (allStarts.length <= 1) return subgraphFixed;
|
|
5216
|
-
const first = allStarts[0];
|
|
5217
|
-
const second = allStarts[1];
|
|
5218
|
-
return subgraphFixed.slice(first, second).trim();
|
|
5219
|
-
}
|
|
5220
5200
|
const CONTEXT_SHAPES = new Set([
|
|
5221
5201
|
"rectangle",
|
|
5222
5202
|
"rounded-rect",
|
|
@@ -5351,11 +5331,15 @@ function toComponentFields(value) {
|
|
|
5351
5331
|
}
|
|
5352
5332
|
function buildContextEdges(edges, nodeIdMap) {
|
|
5353
5333
|
const contextEdges = {};
|
|
5334
|
+
const ordinals = /* @__PURE__ */ new Map();
|
|
5354
5335
|
for (const edge of edges) {
|
|
5355
|
-
var _toRecord, _toRecord2;
|
|
5336
|
+
var _ordinals$get, _toRecord, _toRecord2;
|
|
5356
5337
|
const source = nodeIdMap.get(edge.source);
|
|
5357
5338
|
const target = nodeIdMap.get(edge.target);
|
|
5358
5339
|
if (!source || !target) continue;
|
|
5340
|
+
const pair = `${source}-${target}`;
|
|
5341
|
+
const ordinal = (_ordinals$get = ordinals.get(pair)) !== null && _ordinals$get !== void 0 ? _ordinals$get : 0;
|
|
5342
|
+
ordinals.set(pair, ordinal + 1);
|
|
5359
5343
|
const edgeContext = {};
|
|
5360
5344
|
const edgeType = pickString(edge.type);
|
|
5361
5345
|
if (edgeType) edgeContext.type = edgeType;
|
|
@@ -5378,9 +5362,10 @@ function buildContextEdges(edges, nodeIdMap) {
|
|
|
5378
5362
|
if (markerStart) edgeContext.markerStart = markerStart;
|
|
5379
5363
|
const markerEnd = normalizeMarker(edge.markerEnd);
|
|
5380
5364
|
if (markerEnd) edgeContext.markerEnd = markerEnd;
|
|
5381
|
-
const edgeData = (_toRecord2 = toRecord(edge.data)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
5382
|
-
if (Object.keys(edgeData).length > 0) edgeContext.___internal = edgeData;
|
|
5383
|
-
if (Object.keys(edgeContext).length > 0) contextEdges[
|
|
5365
|
+
const edgeData$1 = (_toRecord2 = toRecord(edge.data)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
5366
|
+
if (Object.keys(edgeData$1).length > 0) edgeContext.___internal = edgeData$1;
|
|
5367
|
+
if (Object.keys(edgeContext).length > 0) if (ordinal === 0) contextEdges[pair] = edgeContext;
|
|
5368
|
+
else contextEdges[`${pair}#${ordinal}`] = edgeContext;
|
|
5384
5369
|
}
|
|
5385
5370
|
return contextEdges;
|
|
5386
5371
|
}
|
|
@@ -5405,9 +5390,9 @@ function buildContextNodes(graphNodes, nodeIdMap) {
|
|
|
5405
5390
|
var _toRecord, _toRecord2, _pickString, _pickString2;
|
|
5406
5391
|
const mappedNodeId = nodeIdMap.get(node.id);
|
|
5407
5392
|
if (!mappedNodeId) continue;
|
|
5408
|
-
const nodeData = (_toRecord = toRecord(node.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5393
|
+
const nodeData$1 = (_toRecord = toRecord(node.data)) !== null && _toRecord !== void 0 ? _toRecord : {};
|
|
5409
5394
|
const nodeStyle = (_toRecord2 = toRecord(node.style)) !== null && _toRecord2 !== void 0 ? _toRecord2 : {};
|
|
5410
|
-
const componentFields = Array.isArray(nodeData.componentFields) ? nodeData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
5395
|
+
const componentFields = Array.isArray(nodeData$1.componentFields) ? nodeData$1.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
5411
5396
|
const nodeContext = {};
|
|
5412
5397
|
const nodeType = pickString(node.type);
|
|
5413
5398
|
if (nodeType) nodeContext.type = nodeType;
|
|
@@ -5427,47 +5412,47 @@ function buildContextNodes(graphNodes, nodeIdMap) {
|
|
|
5427
5412
|
if (nodeType === "code") {
|
|
5428
5413
|
if (codeValue) nodeContext.value = codeValue;
|
|
5429
5414
|
}
|
|
5430
|
-
const src = pickString(nodeData.src);
|
|
5415
|
+
const src = pickString(nodeData$1.src);
|
|
5431
5416
|
if (src) nodeContext.src = src;
|
|
5432
|
-
const animatedIcon = pickString(nodeData.animatedIcon);
|
|
5417
|
+
const animatedIcon = pickString(nodeData$1.animatedIcon);
|
|
5433
5418
|
if (animatedIcon) nodeContext.animatedIcon = animatedIcon;
|
|
5434
|
-
const cloud = pickString(nodeData.cloud);
|
|
5419
|
+
const cloud = pickString(nodeData$1.cloud);
|
|
5435
5420
|
if (cloud) nodeContext.cloud = cloud;
|
|
5436
|
-
const service = pickString(nodeData.service);
|
|
5421
|
+
const service = pickString(nodeData$1.service);
|
|
5437
5422
|
if (service) nodeContext.service = service;
|
|
5438
|
-
const componentId = pickString(nodeData.componentId);
|
|
5423
|
+
const componentId = pickString(nodeData$1.componentId);
|
|
5439
5424
|
if (componentId) nodeContext.componentId = componentId;
|
|
5440
|
-
const shape = pickString(nodeData.shape);
|
|
5425
|
+
const shape = pickString(nodeData$1.shape);
|
|
5441
5426
|
if (shape && CONTEXT_SHAPES.has(shape)) nodeContext.shape = shape;
|
|
5442
5427
|
const style = {};
|
|
5443
5428
|
const width = typeof node.width === "number" ? node.width : typeof nodeStyle.width === "number" ? nodeStyle.width : void 0;
|
|
5444
5429
|
if (typeof width === "number") style.width = width;
|
|
5445
5430
|
const height = typeof node.height === "number" ? node.height : typeof nodeStyle.height === "number" ? nodeStyle.height : void 0;
|
|
5446
5431
|
if (typeof height === "number") style.height = height;
|
|
5447
|
-
const fill = (_pickString = pickString(nodeData.fill)) !== null && _pickString !== void 0 ? _pickString : pickString(nodeStyle.fill);
|
|
5432
|
+
const fill = (_pickString = pickString(nodeData$1.fill)) !== null && _pickString !== void 0 ? _pickString : pickString(nodeStyle.fill);
|
|
5448
5433
|
if (fill) style.fill = fill;
|
|
5449
|
-
const stroke = (_pickString2 = pickString(nodeData.stroke)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(nodeStyle.stroke);
|
|
5434
|
+
const stroke = (_pickString2 = pickString(nodeData$1.stroke)) !== null && _pickString2 !== void 0 ? _pickString2 : pickString(nodeStyle.stroke);
|
|
5450
5435
|
if (stroke) style.stroke = stroke;
|
|
5451
|
-
const strokeWidth = typeof nodeData.strokeWidth === "number" ? nodeData.strokeWidth : typeof nodeStyle.strokeWidth === "number" ? nodeStyle.strokeWidth : void 0;
|
|
5436
|
+
const strokeWidth = typeof nodeData$1.strokeWidth === "number" ? nodeData$1.strokeWidth : typeof nodeStyle.strokeWidth === "number" ? nodeStyle.strokeWidth : void 0;
|
|
5452
5437
|
if (typeof strokeWidth === "number") style.strokeWidth = strokeWidth;
|
|
5453
|
-
const borderRadius = typeof nodeData.borderRadius === "number" ? nodeData.borderRadius : typeof nodeStyle.borderRadius === "number" ? nodeStyle.borderRadius : void 0;
|
|
5438
|
+
const borderRadius = typeof nodeData$1.borderRadius === "number" ? nodeData$1.borderRadius : typeof nodeStyle.borderRadius === "number" ? nodeStyle.borderRadius : void 0;
|
|
5454
5439
|
if (typeof borderRadius === "number") style.borderRadius = borderRadius;
|
|
5455
|
-
const strokeStyleFromData = pickString(nodeData.strokeStyle);
|
|
5440
|
+
const strokeStyleFromData = pickString(nodeData$1.strokeStyle);
|
|
5456
5441
|
if (strokeStyleFromData === "solid" || strokeStyleFromData === "dashed" || strokeStyleFromData === "dotted") style.strokeStyle = strokeStyleFromData;
|
|
5457
5442
|
else {
|
|
5458
5443
|
const strokeStyleFromDash = parseStrokeStyle(nodeStyle.strokeDasharray);
|
|
5459
5444
|
if (strokeStyleFromDash) style.strokeStyle = strokeStyleFromDash;
|
|
5460
5445
|
}
|
|
5461
|
-
const borderAnimationEnabled = typeof nodeData.borderAnimationEnabled === "boolean" ? nodeData.borderAnimationEnabled : nodeData.strokeAnimation === "dash" ? true : void 0;
|
|
5446
|
+
const borderAnimationEnabled = typeof nodeData$1.borderAnimationEnabled === "boolean" ? nodeData$1.borderAnimationEnabled : nodeData$1.strokeAnimation === "dash" ? true : void 0;
|
|
5462
5447
|
if (typeof borderAnimationEnabled === "boolean") style.borderAnimationEnabled = borderAnimationEnabled;
|
|
5463
5448
|
if (Object.keys(style).length > 0) nodeContext.style = style;
|
|
5464
|
-
const tableColumns = Array.isArray(nodeData.columns) ? nodeData.columns.filter((value) => typeof value === "string") : void 0;
|
|
5465
|
-
const tableRows = Array.isArray(nodeData.rows) ? nodeData.rows.map((row) => Array.isArray(row) ? row.filter((value) => typeof value === "string") : void 0).filter((row) => row !== void 0) : void 0;
|
|
5449
|
+
const tableColumns = Array.isArray(nodeData$1.columns) ? nodeData$1.columns.filter((value) => typeof value === "string") : void 0;
|
|
5450
|
+
const tableRows = Array.isArray(nodeData$1.rows) ? nodeData$1.rows.map((row) => Array.isArray(row) ? row.filter((value) => typeof value === "string") : void 0).filter((row) => row !== void 0) : void 0;
|
|
5466
5451
|
if (tableColumns || tableRows) nodeContext.table = {
|
|
5467
5452
|
columns: tableColumns !== null && tableColumns !== void 0 ? tableColumns : [],
|
|
5468
5453
|
rows: tableRows !== null && tableRows !== void 0 ? tableRows : []
|
|
5469
5454
|
};
|
|
5470
|
-
const serviceTable = toRecord(nodeData.serviceTable);
|
|
5455
|
+
const serviceTable = toRecord(nodeData$1.serviceTable);
|
|
5471
5456
|
const serviceName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.serviceName);
|
|
5472
5457
|
const databaseName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.databaseName);
|
|
5473
5458
|
const tableName = pickString(serviceTable === null || serviceTable === void 0 ? void 0 : serviceTable.tableName);
|
|
@@ -5529,17 +5514,17 @@ function buildContextNodes(graphNodes, nodeIdMap) {
|
|
|
5529
5514
|
if (Object.keys(dynamicData).length > 0) nodeContext.data = dynamicData;
|
|
5530
5515
|
const position = pickPosition(node.position);
|
|
5531
5516
|
if (position) nodeContext.___position = position;
|
|
5532
|
-
const internalData = Object.entries(nodeData).reduce((acc, [key, value]) => {
|
|
5517
|
+
const internalData = Object.entries(nodeData$1).reduce((acc, [key, value]) => {
|
|
5533
5518
|
if (KNOWN_NODE_DATA_KEYS.has(key)) return acc;
|
|
5534
5519
|
acc[key] = value;
|
|
5535
5520
|
return acc;
|
|
5536
5521
|
}, {});
|
|
5537
|
-
if (nodeType === "builder" && Array.isArray(nodeData.componentFields)) internalData.componentFields = nodeData.componentFields;
|
|
5538
|
-
const iconSrc = pickString(nodeData.iconSrc);
|
|
5522
|
+
if (nodeType === "builder" && Array.isArray(nodeData$1.componentFields)) internalData.componentFields = nodeData$1.componentFields;
|
|
5523
|
+
const iconSrc = pickString(nodeData$1.iconSrc);
|
|
5539
5524
|
if (iconSrc) internalData.iconSrc = iconSrc;
|
|
5540
|
-
const label = pickString(nodeData.label);
|
|
5525
|
+
const label = pickString(nodeData$1.label);
|
|
5541
5526
|
if (label) internalData.label = label;
|
|
5542
|
-
const internalCloud = pickString(nodeData.cloud);
|
|
5527
|
+
const internalCloud = pickString(nodeData$1.cloud);
|
|
5543
5528
|
if (internalCloud) internalData.cloud = internalCloud;
|
|
5544
5529
|
if (Object.keys(internalData).length > 0) nodeContext.___internal = internalData;
|
|
5545
5530
|
if (Object.keys(nodeContext).length > 0) contextNodes[mappedNodeId] = nodeContext;
|
|
@@ -5556,6 +5541,205 @@ function buildValidatedContext(graphNodes, edges, groupNodes, nodeIdMap) {
|
|
|
5556
5541
|
if (Object.keys(contextGroups).length > 0) context.groups = contextGroups;
|
|
5557
5542
|
return contextSchema.parse(context);
|
|
5558
5543
|
}
|
|
5544
|
+
function nodeData(node) {
|
|
5545
|
+
var _node$data;
|
|
5546
|
+
return (_node$data = node.data) !== null && _node$data !== void 0 ? _node$data : {};
|
|
5547
|
+
}
|
|
5548
|
+
function edgeData(edge) {
|
|
5549
|
+
var _edge$data;
|
|
5550
|
+
return (_edge$data = edge.data) !== null && _edge$data !== void 0 ? _edge$data : {};
|
|
5551
|
+
}
|
|
5552
|
+
function isC4ReactFlowDiagram(nodes) {
|
|
5553
|
+
return nodes.some((node) => node.type === "c4" || node.type === "c4Boundary");
|
|
5554
|
+
}
|
|
5555
|
+
function isC4Element(node) {
|
|
5556
|
+
if (node.type !== "c4" && node.type !== "subDiagram") return false;
|
|
5557
|
+
const kind = nodeData(node).c4Kind;
|
|
5558
|
+
return kind === "person" || kind === "system" || kind === "container" || kind === "component";
|
|
5559
|
+
}
|
|
5560
|
+
function isC4Boundary(node) {
|
|
5561
|
+
return node.type === "c4Boundary";
|
|
5562
|
+
}
|
|
5563
|
+
function quoteC4Value(value) {
|
|
5564
|
+
return `"${value.replace(/"/g, "\\\"").replace(/\r\n?/g, "\n").replace(/\n/g, "<br/>").trim()}"`;
|
|
5565
|
+
}
|
|
5566
|
+
function nodeName(node) {
|
|
5567
|
+
var _node$data2;
|
|
5568
|
+
const fields = (_node$data2 = node.data) === null || _node$data2 === void 0 ? void 0 : _node$data2.componentFields;
|
|
5569
|
+
if (Array.isArray(fields)) {
|
|
5570
|
+
var _field$data;
|
|
5571
|
+
const field = fields.find((candidate) => (candidate === null || candidate === void 0 ? void 0 : candidate.componentFieldId) === "name");
|
|
5572
|
+
const value = field === null || field === void 0 || (_field$data = field.data) === null || _field$data === void 0 || (_field$data = _field$data[0]) === null || _field$data === void 0 ? void 0 : _field$data.value;
|
|
5573
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
5574
|
+
}
|
|
5575
|
+
const diagramName = nodeData(node).diagramName;
|
|
5576
|
+
if (typeof diagramName === "string" && diagramName) return diagramName;
|
|
5577
|
+
return node.id;
|
|
5578
|
+
}
|
|
5579
|
+
function c4ElementKeyword(kind, shape, isExternal) {
|
|
5580
|
+
let keyword;
|
|
5581
|
+
if (kind === "person") keyword = "Person";
|
|
5582
|
+
else if (kind === "system") keyword = "System";
|
|
5583
|
+
else if (kind === "container") keyword = "Container";
|
|
5584
|
+
else if (kind === "component") keyword = "Component";
|
|
5585
|
+
else throw new Error(`Unsupported C4 element kind: ${String(kind)}`);
|
|
5586
|
+
if (shape === "db") keyword += "Db";
|
|
5587
|
+
if (shape === "queue") keyword += "Queue";
|
|
5588
|
+
if (isExternal) keyword += "_Ext";
|
|
5589
|
+
return keyword;
|
|
5590
|
+
}
|
|
5591
|
+
function c4BoundaryKeyword(kind, nodeType) {
|
|
5592
|
+
if (kind === "enterprise") return "Enterprise_Boundary";
|
|
5593
|
+
if (kind === "system") return "System_Boundary";
|
|
5594
|
+
if (kind === "container") return "Container_Boundary";
|
|
5595
|
+
if (kind === "node") {
|
|
5596
|
+
if (nodeType === "nodeL") return "Node_L";
|
|
5597
|
+
if (nodeType === "nodeR") return "Node_R";
|
|
5598
|
+
return "Deployment_Node";
|
|
5599
|
+
}
|
|
5600
|
+
return "Boundary";
|
|
5601
|
+
}
|
|
5602
|
+
function c4RelationshipKeyword(direction) {
|
|
5603
|
+
if (direction === "default") return "Rel";
|
|
5604
|
+
if (direction === "bi") return "BiRel";
|
|
5605
|
+
if (direction === "back") return "Rel_Back";
|
|
5606
|
+
if (direction === "up") return "Rel_U";
|
|
5607
|
+
if (direction === "down") return "Rel_D";
|
|
5608
|
+
if (direction === "left") return "Rel_L";
|
|
5609
|
+
if (direction === "right") return "Rel_R";
|
|
5610
|
+
throw new Error(`Unsupported C4 relationship direction: ${String(direction)}`);
|
|
5611
|
+
}
|
|
5612
|
+
function resolveRelDirection(edge) {
|
|
5613
|
+
const stored = edgeData(edge).c4RelDirection;
|
|
5614
|
+
if (stored) return stored;
|
|
5615
|
+
if (edge.markerStart) return "bi";
|
|
5616
|
+
if (edge.sourceHandle === "source-top") return "up";
|
|
5617
|
+
if (edge.sourceHandle === "source-bottom") return "down";
|
|
5618
|
+
if (edge.sourceHandle === "source-left") return "left";
|
|
5619
|
+
if (edge.sourceHandle === "source-right") return "right";
|
|
5620
|
+
return "default";
|
|
5621
|
+
}
|
|
5622
|
+
function relationshipLabel(edge, technology) {
|
|
5623
|
+
const label = typeof edge.label === "string" ? edge.label : "";
|
|
5624
|
+
if (!technology) return label;
|
|
5625
|
+
const suffix = ` [${technology}]`;
|
|
5626
|
+
if (label.endsWith(suffix)) return label.slice(0, -suffix.length);
|
|
5627
|
+
return label;
|
|
5628
|
+
}
|
|
5629
|
+
function resolveDiagramType(c4Nodes) {
|
|
5630
|
+
for (const node of c4Nodes) {
|
|
5631
|
+
const stored = nodeData(node).c4DiagramType;
|
|
5632
|
+
if (stored) return stored;
|
|
5633
|
+
}
|
|
5634
|
+
if (c4Nodes.some((node) => nodeData(node).c4Kind === "component")) return "C4Component";
|
|
5635
|
+
if (c4Nodes.some((node) => nodeData(node).c4Kind === "container")) return "C4Container";
|
|
5636
|
+
return "C4Context";
|
|
5637
|
+
}
|
|
5638
|
+
function trimTrailingSlots(values, keep) {
|
|
5639
|
+
const trimmed = [...values];
|
|
5640
|
+
while (trimmed.length > keep && trimmed[trimmed.length - 1] === "") trimmed.pop();
|
|
5641
|
+
return trimmed;
|
|
5642
|
+
}
|
|
5643
|
+
function emitC4Mermaid(nodes, edges) {
|
|
5644
|
+
const c4Nodes = nodes.filter((node) => isC4Element(node) || isC4Boundary(node));
|
|
5645
|
+
const c4NodeIds = new Set(c4Nodes.map((node) => node.id));
|
|
5646
|
+
const boundaryIds = new Set(c4Nodes.filter((node) => isC4Boundary(node)).map((node) => node.id));
|
|
5647
|
+
function parentOf(node) {
|
|
5648
|
+
if (node.parentId && boundaryIds.has(node.parentId)) return node.parentId;
|
|
5649
|
+
}
|
|
5650
|
+
function renderNode(node, indentation) {
|
|
5651
|
+
const data = nodeData(node);
|
|
5652
|
+
const name = quoteC4Value(nodeName(node));
|
|
5653
|
+
if (isC4Element(node)) {
|
|
5654
|
+
const values$1 = [node.id, name];
|
|
5655
|
+
if (data.c4Kind === "container" || data.c4Kind === "component") values$1.push(data.technology ? quoteC4Value(data.technology) : "");
|
|
5656
|
+
values$1.push(data.description ? quoteC4Value(data.description) : "");
|
|
5657
|
+
const trimmed$1 = trimTrailingSlots(values$1, 2);
|
|
5658
|
+
const link = data.diagramId ? `uig:${data.diagramId}` : data.link;
|
|
5659
|
+
if (link) trimmed$1.push(`$link=${quoteC4Value(link)}`);
|
|
5660
|
+
return `${indentation}${c4ElementKeyword(data.c4Kind, data.c4Shape, data.isExternal === true)}(${trimmed$1.join(", ")})`;
|
|
5661
|
+
}
|
|
5662
|
+
const keyword = c4BoundaryKeyword(data.c4BoundaryKind, data.c4NodeType);
|
|
5663
|
+
const values = [node.id, name];
|
|
5664
|
+
if (keyword === "Boundary" && data.boundaryType) values.push(quoteC4Value(data.boundaryType));
|
|
5665
|
+
if (data.c4BoundaryKind === "node") {
|
|
5666
|
+
values.push(data.boundaryType ? quoteC4Value(data.boundaryType) : "\"node\"");
|
|
5667
|
+
values.push(data.description ? quoteC4Value(data.description) : "");
|
|
5668
|
+
}
|
|
5669
|
+
const trimmed = trimTrailingSlots(values, 2);
|
|
5670
|
+
if (data.link) trimmed.push(`$link=${quoteC4Value(data.link)}`);
|
|
5671
|
+
return `${indentation}${keyword}(${trimmed.join(", ")}) {`;
|
|
5672
|
+
}
|
|
5673
|
+
function renderChildren(parentId, indentation) {
|
|
5674
|
+
const lines = [];
|
|
5675
|
+
for (const node of c4Nodes) {
|
|
5676
|
+
if (parentOf(node) !== parentId) continue;
|
|
5677
|
+
lines.push(renderNode(node, indentation));
|
|
5678
|
+
if (isC4Boundary(node)) {
|
|
5679
|
+
lines.push(...renderChildren(node.id, `${indentation} `));
|
|
5680
|
+
lines.push(`${indentation}}`);
|
|
5681
|
+
}
|
|
5682
|
+
}
|
|
5683
|
+
return lines;
|
|
5684
|
+
}
|
|
5685
|
+
const relationships = edges.flatMap((edge) => {
|
|
5686
|
+
if (!c4NodeIds.has(edge.source) || !c4NodeIds.has(edge.target)) return [];
|
|
5687
|
+
const data = edgeData(edge);
|
|
5688
|
+
const direction = resolveRelDirection(edge);
|
|
5689
|
+
const isBack = direction === "back";
|
|
5690
|
+
const values = [
|
|
5691
|
+
isBack ? edge.target : edge.source,
|
|
5692
|
+
isBack ? edge.source : edge.target,
|
|
5693
|
+
quoteC4Value(relationshipLabel(edge, data.c4RelTechnology)),
|
|
5694
|
+
data.c4RelTechnology ? quoteC4Value(data.c4RelTechnology) : "",
|
|
5695
|
+
data.c4RelDescription ? quoteC4Value(data.c4RelDescription) : ""
|
|
5696
|
+
];
|
|
5697
|
+
return `${c4RelationshipKeyword(direction)}(${trimTrailingSlots(values, 3).join(", ")})`;
|
|
5698
|
+
});
|
|
5699
|
+
return {
|
|
5700
|
+
mermaid: [
|
|
5701
|
+
resolveDiagramType(c4Nodes),
|
|
5702
|
+
...renderChildren(void 0, ""),
|
|
5703
|
+
...relationships
|
|
5704
|
+
].join("\n"),
|
|
5705
|
+
nodeIdMap: new Map(c4Nodes.map((node) => [node.id, node.id]))
|
|
5706
|
+
};
|
|
5707
|
+
}
|
|
5708
|
+
function convertReactFlowToC4Mermaid(nodes, edges) {
|
|
5709
|
+
return emitC4Mermaid(nodes, edges).mermaid;
|
|
5710
|
+
}
|
|
5711
|
+
function convertReactFlowToC4UiGraph(nodes, edges) {
|
|
5712
|
+
const { mermaid: mermaid$1, nodeIdMap } = emitC4Mermaid(nodes, edges);
|
|
5713
|
+
return {
|
|
5714
|
+
mermaid: mermaid$1,
|
|
5715
|
+
context: buildValidatedContext(nodes, edges, [], nodeIdMap)
|
|
5716
|
+
};
|
|
5717
|
+
}
|
|
5718
|
+
function sanitizeMermaidLabels(src) {
|
|
5719
|
+
if (!src) return src;
|
|
5720
|
+
const subgraphFixed = src.replace(/([A-Za-z0-9_]+)\[((?:(?![\"']).)*?)\]/g, (m, id, label) => {
|
|
5721
|
+
if (/^[\"']/.test(label)) return m;
|
|
5722
|
+
if (/[()\"\[\],:;]/.test(label)) return `${id}[\"${String(label).replace(/\\/g, "\\\\").replace(/\"/g, "\\\"")}\"]`;
|
|
5723
|
+
return m;
|
|
5724
|
+
}).replace(/^([ \t]*subgraph\s+)([^\n\r]+)(\|[^\n\r]*)?$/gim, (m, pre, title, rest) => {
|
|
5725
|
+
const t = String(title).trim();
|
|
5726
|
+
if (/^[\"']/.test(t)) return m;
|
|
5727
|
+
if (/[()\"\[\],:;]/.test(t)) return `${pre}\"${t.replace(/\\/g, "\\\\").replace(/\"/g, "\\\"")}\"${rest || ""}`;
|
|
5728
|
+
return m;
|
|
5729
|
+
});
|
|
5730
|
+
const diagRegex = /\b(graph|flowchart|sequenceDiagram|stateDiagram|classDiagram|gantt|journey|erDiagram|gitGraph|pie|timeline|infoDiagram)\b/i;
|
|
5731
|
+
const allStarts = [];
|
|
5732
|
+
let mm;
|
|
5733
|
+
const globalRegex = new RegExp(diagRegex.source, "gim");
|
|
5734
|
+
while ((mm = globalRegex.exec(subgraphFixed)) !== null) {
|
|
5735
|
+
allStarts.push(mm.index);
|
|
5736
|
+
if (globalRegex.lastIndex === mm.index) globalRegex.lastIndex++;
|
|
5737
|
+
}
|
|
5738
|
+
if (allStarts.length <= 1) return subgraphFixed;
|
|
5739
|
+
const first = allStarts[0];
|
|
5740
|
+
const second = allStarts[1];
|
|
5741
|
+
return subgraphFixed.slice(first, second).trim();
|
|
5742
|
+
}
|
|
5559
5743
|
function isSequenceDiagram(nodes) {
|
|
5560
5744
|
return nodes.some((node) => node.type === "sequenceParticipant");
|
|
5561
5745
|
}
|
|
@@ -6090,7 +6274,7 @@ function normalizeContextMarker(marker) {
|
|
|
6090
6274
|
};
|
|
6091
6275
|
return { type };
|
|
6092
6276
|
}
|
|
6093
|
-
function convertMermaidToReactFlowWithContext(
|
|
6277
|
+
function convertMermaidToReactFlowWithContext(_x4, _x5, _x6) {
|
|
6094
6278
|
return _convertMermaidToReactFlowWithContext.apply(this, arguments);
|
|
6095
6279
|
}
|
|
6096
6280
|
function _convertMermaidToReactFlowWithContext() {
|
|
@@ -6225,10 +6409,26 @@ function _convertMermaidToReactFlowWithContext() {
|
|
|
6225
6409
|
const childNodes = arrayNonNullable(((_groupCtx$nodes = groupCtx.nodes) !== null && _groupCtx$nodes !== void 0 ? _groupCtx$nodes : []).map((nodeId$1) => resolvedNodes.find((n) => n.id === nodeId$1)));
|
|
6226
6410
|
return generateGroupNodeFromNodes(nodeId, (_groupCtx$name = groupCtx.name) !== null && _groupCtx$name !== void 0 ? _groupCtx$name : "Group", childNodes);
|
|
6227
6411
|
});
|
|
6412
|
+
const edgeOrdinals = /* @__PURE__ */ new Map();
|
|
6413
|
+
const edgeContextKeys = reactFlowData.edges.map((edge) => {
|
|
6414
|
+
var _edgeOrdinals$get;
|
|
6415
|
+
const pair = `${edge.source}-${edge.target}`;
|
|
6416
|
+
const ordinal = (_edgeOrdinals$get = edgeOrdinals.get(pair)) !== null && _edgeOrdinals$get !== void 0 ? _edgeOrdinals$get : 0;
|
|
6417
|
+
edgeOrdinals.set(pair, ordinal + 1);
|
|
6418
|
+
if (ordinal === 0) return {
|
|
6419
|
+
pair,
|
|
6420
|
+
key: pair
|
|
6421
|
+
};
|
|
6422
|
+
return {
|
|
6423
|
+
pair,
|
|
6424
|
+
key: `${pair}#${ordinal}`
|
|
6425
|
+
};
|
|
6426
|
+
});
|
|
6228
6427
|
const rfEdgesPromises = reactFlowData.edges.map(function() {
|
|
6229
|
-
var
|
|
6230
|
-
var _validatedContext$edg, _ctx$type, _ctx$sourceHandle, _ctx$targetHandle, _normalizeContextMark, _normalizeContextMark2, _ctx$label, _ctx$style$borderAnim, _ctx$style5, _ctx$style$stroke, _ctx$style6, _edge$style, _ctx$style$strokeWidt, _ctx$style7, _edge$style2, _ctx$style8, _ctx$style9, _ctx$style10, _edge$style3;
|
|
6231
|
-
const
|
|
6428
|
+
var _ref3 = _asyncToGenerator(function* (edge, index) {
|
|
6429
|
+
var _ref2, _validatedContext$edg, _validatedContext$edg2, _validatedContext$edg3, _ctx$type, _ctx$sourceHandle, _ctx$targetHandle, _normalizeContextMark, _normalizeContextMark2, _ctx$label, _ctx$style$borderAnim, _ctx$style5, _ctx$style$stroke, _ctx$style6, _edge$style, _ctx$style$strokeWidt, _ctx$style7, _edge$style2, _ctx$style8, _ctx$style9, _ctx$style10, _edge$style3;
|
|
6430
|
+
const { pair, key } = edgeContextKeys[index];
|
|
6431
|
+
const ctx = (_ref2 = (_validatedContext$edg = (_validatedContext$edg2 = validatedContext.edges) === null || _validatedContext$edg2 === void 0 ? void 0 : _validatedContext$edg2[key]) !== null && _validatedContext$edg !== void 0 ? _validatedContext$edg : (_validatedContext$edg3 = validatedContext.edges) === null || _validatedContext$edg3 === void 0 ? void 0 : _validatedContext$edg3[pair]) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
6232
6432
|
if (!ctx) return edge;
|
|
6233
6433
|
return _objectSpread2(_objectSpread2({}, edge), {}, {
|
|
6234
6434
|
type: (_ctx$type = ctx.type) !== null && _ctx$type !== void 0 ? _ctx$type : edge.type,
|
|
@@ -6246,8 +6446,8 @@ function _convertMermaidToReactFlowWithContext() {
|
|
|
6246
6446
|
})
|
|
6247
6447
|
});
|
|
6248
6448
|
});
|
|
6249
|
-
return function(_x2) {
|
|
6250
|
-
return
|
|
6449
|
+
return function(_x2, _x3) {
|
|
6450
|
+
return _ref3.apply(this, arguments);
|
|
6251
6451
|
};
|
|
6252
6452
|
}());
|
|
6253
6453
|
const resolvedEdges = yield Promise.all(rfEdgesPromises);
|
|
@@ -6263,6 +6463,10 @@ function _convertMermaidToReactFlowWithContext() {
|
|
|
6263
6463
|
edges: resolvedEdges,
|
|
6264
6464
|
nodes: combinedNodes
|
|
6265
6465
|
};
|
|
6466
|
+
if (isC4ReactFlowDiagram(combinedNodes)) return {
|
|
6467
|
+
edges: resolvedEdges,
|
|
6468
|
+
nodes: combinedNodes
|
|
6469
|
+
};
|
|
6266
6470
|
return {
|
|
6267
6471
|
edges: resolvedEdges,
|
|
6268
6472
|
nodes: (options === null || options === void 0 ? void 0 : options.repositionNodes) ? resizeNodesLayouts(combinedNodes) : combinedNodes
|
|
@@ -6323,8 +6527,8 @@ function buildNodeIdMap(graphNodes) {
|
|
|
6323
6527
|
}
|
|
6324
6528
|
function resolveMermaidNodeLabel(node) {
|
|
6325
6529
|
const nodeType = node.type;
|
|
6326
|
-
const nodeData = toRecord(node.data);
|
|
6327
|
-
const componentFields = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.componentFields) ? nodeData.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
6530
|
+
const nodeData$1 = toRecord(node.data);
|
|
6531
|
+
const componentFields = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.componentFields) ? nodeData$1.componentFields.map((field) => toRecord(field)).filter((field) => field !== void 0) : [];
|
|
6328
6532
|
const name = getFieldString(componentFields, "Name");
|
|
6329
6533
|
if (nodeType === "text") return getFieldString(componentFields, "Text");
|
|
6330
6534
|
if (nodeType === "code") return getFieldString(componentFields, "Code");
|
|
@@ -6420,9 +6624,9 @@ function formatDetailValue(value) {
|
|
|
6420
6624
|
return entries.join(",");
|
|
6421
6625
|
}
|
|
6422
6626
|
}
|
|
6423
|
-
function getNodeName(nodeData, componentFields) {
|
|
6627
|
+
function getNodeName(nodeData$1, componentFields) {
|
|
6424
6628
|
var _getFieldString;
|
|
6425
|
-
return (_getFieldString = getFieldString(componentFields, "Name")) !== null && _getFieldString !== void 0 ? _getFieldString : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.name);
|
|
6629
|
+
return (_getFieldString = getFieldString(componentFields, "Name")) !== null && _getFieldString !== void 0 ? _getFieldString : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.name);
|
|
6426
6630
|
}
|
|
6427
6631
|
function buildFieldLines(componentFields, excludedLabels) {
|
|
6428
6632
|
const lines = [];
|
|
@@ -6454,25 +6658,25 @@ function buildDetailedLabel(lines) {
|
|
|
6454
6658
|
}
|
|
6455
6659
|
function resolveMermaidDetailedNodeLabel(node) {
|
|
6456
6660
|
const nodeType = pickString(node.type);
|
|
6457
|
-
const nodeData = toRecord(node.data);
|
|
6458
|
-
const componentFields = toComponentFields(nodeData === null || nodeData === void 0 ? void 0 : nodeData.componentFields);
|
|
6459
|
-
const name = getNodeName(nodeData, componentFields);
|
|
6661
|
+
const nodeData$1 = toRecord(node.data);
|
|
6662
|
+
const componentFields = toComponentFields(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.componentFields);
|
|
6663
|
+
const name = getNodeName(nodeData$1, componentFields);
|
|
6460
6664
|
if (nodeType === "text") {
|
|
6461
6665
|
var _getFieldString2;
|
|
6462
|
-
const text = (_getFieldString2 = getFieldString(componentFields, "Text")) !== null && _getFieldString2 !== void 0 ? _getFieldString2 : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.value);
|
|
6666
|
+
const text = (_getFieldString2 = getFieldString(componentFields, "Text")) !== null && _getFieldString2 !== void 0 ? _getFieldString2 : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.value);
|
|
6463
6667
|
return buildDetailedLabel([text ? `Text: ${text}` : "Text", ...buildFieldLines(componentFields, new Set(["name", "text"]))]);
|
|
6464
6668
|
}
|
|
6465
6669
|
if (nodeType === "code") {
|
|
6466
6670
|
var _getFieldString3, _code$split$;
|
|
6467
|
-
const code = (_getFieldString3 = getFieldString(componentFields, "Code")) !== null && _getFieldString3 !== void 0 ? _getFieldString3 : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.value);
|
|
6671
|
+
const code = (_getFieldString3 = getFieldString(componentFields, "Code")) !== null && _getFieldString3 !== void 0 ? _getFieldString3 : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.value);
|
|
6468
6672
|
const firstLine = code === null || code === void 0 || (_code$split$ = code.split(/\r?\n/)[0]) === null || _code$split$ === void 0 ? void 0 : _code$split$.trim();
|
|
6469
6673
|
return buildDetailedLabel([firstLine ? `Code: ${firstLine}` : "Code", ...buildFieldLines(componentFields, new Set(["name", "code"]))]);
|
|
6470
6674
|
}
|
|
6471
6675
|
if (nodeType === "data-source" || nodeType === "databaseTableSQL") {
|
|
6472
6676
|
var _pickString, _pickString2, _pickString3;
|
|
6473
6677
|
const lines = [];
|
|
6474
|
-
const serviceTable = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.serviceTable);
|
|
6475
|
-
const dbConfig = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.dbConfig);
|
|
6678
|
+
const serviceTable = toRecord(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.serviceTable);
|
|
6679
|
+
const dbConfig = toRecord(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.dbConfig);
|
|
6476
6680
|
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);
|
|
6477
6681
|
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);
|
|
6478
6682
|
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);
|
|
@@ -6486,9 +6690,9 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6486
6690
|
if (nodeType === "cloud") {
|
|
6487
6691
|
const lines = [];
|
|
6488
6692
|
lines.push(name ? `Cloud: ${name}` : "Cloud");
|
|
6489
|
-
const cloud = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.cloud);
|
|
6693
|
+
const cloud = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.cloud);
|
|
6490
6694
|
if (cloud) lines.push(`provider: ${cloud}`);
|
|
6491
|
-
const service = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.service);
|
|
6695
|
+
const service = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.service);
|
|
6492
6696
|
if (service) lines.push(`service: ${service}`);
|
|
6493
6697
|
lines.push(...buildFieldLines(componentFields, new Set(["name"])));
|
|
6494
6698
|
return buildDetailedLabel(lines);
|
|
@@ -6496,11 +6700,11 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6496
6700
|
if (nodeType === "table" || nodeType === "dataTableInterface") {
|
|
6497
6701
|
var _pickString4;
|
|
6498
6702
|
const lines = [];
|
|
6499
|
-
const table = toRecord(nodeData === null || nodeData === void 0 ? void 0 : nodeData.table);
|
|
6703
|
+
const table = toRecord(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.table);
|
|
6500
6704
|
const tableName = (_pickString4 = pickString(table === null || table === void 0 ? void 0 : table.name)) !== null && _pickString4 !== void 0 ? _pickString4 : name;
|
|
6501
6705
|
lines.push(tableName ? `Table: ${tableName}` : "Table");
|
|
6502
|
-
const columns = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.columns) ? nodeData.columns.filter((value) => typeof value === "string").length : Array.isArray(table === null || table === void 0 ? void 0 : table.columns) ? table.columns.length : 0;
|
|
6503
|
-
const rows = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.rows) ? nodeData.rows.filter((value) => Array.isArray(value)).length : Array.isArray(table === null || table === void 0 ? void 0 : table.rows) ? table.rows.length : 0;
|
|
6706
|
+
const columns = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.columns) ? nodeData$1.columns.filter((value) => typeof value === "string").length : Array.isArray(table === null || table === void 0 ? void 0 : table.columns) ? table.columns.length : 0;
|
|
6707
|
+
const rows = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.rows) ? nodeData$1.rows.filter((value) => Array.isArray(value)).length : Array.isArray(table === null || table === void 0 ? void 0 : table.rows) ? table.rows.length : 0;
|
|
6504
6708
|
lines.push(`columns: ${columns}`);
|
|
6505
6709
|
lines.push(`rows: ${rows}`);
|
|
6506
6710
|
lines.push(...buildFieldLines(componentFields, new Set(["name"])));
|
|
@@ -6513,7 +6717,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6513
6717
|
return;
|
|
6514
6718
|
}
|
|
6515
6719
|
if (nodeType === "gif") {
|
|
6516
|
-
const src = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.src);
|
|
6720
|
+
const src = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.src);
|
|
6517
6721
|
return buildDetailedLabel([
|
|
6518
6722
|
name ? `Gif: ${name}` : src ? `Gif: ${src}` : "Gif",
|
|
6519
6723
|
...src ? [`src: ${src}`] : [],
|
|
@@ -6521,7 +6725,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6521
6725
|
]);
|
|
6522
6726
|
}
|
|
6523
6727
|
if (nodeType === "image") {
|
|
6524
|
-
const src = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.src);
|
|
6728
|
+
const src = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.src);
|
|
6525
6729
|
return buildDetailedLabel([
|
|
6526
6730
|
name ? `Image: ${name}` : src ? `Image: ${src}` : "Image",
|
|
6527
6731
|
...src ? [`src: ${src}`] : [],
|
|
@@ -6529,7 +6733,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6529
6733
|
]);
|
|
6530
6734
|
}
|
|
6531
6735
|
if (nodeType === "group") {
|
|
6532
|
-
const childCount = Array.isArray(nodeData === null || nodeData === void 0 ? void 0 : nodeData.childNodes) ? nodeData.childNodes.length : 0;
|
|
6736
|
+
const childCount = Array.isArray(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.childNodes) ? nodeData$1.childNodes.length : 0;
|
|
6533
6737
|
return buildDetailedLabel([
|
|
6534
6738
|
name ? `Group: ${name}` : "Group",
|
|
6535
6739
|
`children: ${childCount}`,
|
|
@@ -6538,10 +6742,10 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6538
6742
|
}
|
|
6539
6743
|
if (nodeType === "sequenceParticipant") {
|
|
6540
6744
|
var _getFieldString4;
|
|
6541
|
-
const label = (_getFieldString4 = getFieldString(componentFields, "Label")) !== null && _getFieldString4 !== void 0 ? _getFieldString4 : pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.label);
|
|
6745
|
+
const label = (_getFieldString4 = getFieldString(componentFields, "Label")) !== null && _getFieldString4 !== void 0 ? _getFieldString4 : pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.label);
|
|
6542
6746
|
const participantName = name !== null && name !== void 0 ? name : label;
|
|
6543
|
-
const rowCount = typeof (nodeData === null || nodeData === void 0 ? void 0 : nodeData.rowCount) === "number" ? nodeData.rowCount : void 0;
|
|
6544
|
-
const color = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.color);
|
|
6747
|
+
const rowCount = typeof (nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.rowCount) === "number" ? nodeData$1.rowCount : void 0;
|
|
6748
|
+
const color = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.color);
|
|
6545
6749
|
return buildDetailedLabel([
|
|
6546
6750
|
participantName ? `SequenceParticipant: ${participantName}` : "SequenceParticipant",
|
|
6547
6751
|
...typeof rowCount === "number" ? [`rows: ${rowCount}`] : [],
|
|
@@ -6549,9 +6753,9 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6549
6753
|
...buildFieldLines(componentFields, new Set(["name", "label"]))
|
|
6550
6754
|
]);
|
|
6551
6755
|
}
|
|
6552
|
-
if (nodeType === "comment") return buildDetailedLabel([`Comment: ${(typeof (nodeData === null || nodeData === void 0 ? void 0 : nodeData.isResolved) === "boolean" ? nodeData.isResolved : void 0) ? "Resolved" : "Open"}`, ...buildFieldLines(componentFields, new Set(["name"]))]);
|
|
6756
|
+
if (nodeType === "comment") return buildDetailedLabel([`Comment: ${(typeof (nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.isResolved) === "boolean" ? nodeData$1.isResolved : void 0) ? "Resolved" : "Open"}`, ...buildFieldLines(componentFields, new Set(["name"]))]);
|
|
6553
6757
|
if (nodeType === "builder") {
|
|
6554
|
-
const componentId = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.componentId);
|
|
6758
|
+
const componentId = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.componentId);
|
|
6555
6759
|
return buildDetailedLabel([
|
|
6556
6760
|
name ? `Builder: ${name}` : "Builder",
|
|
6557
6761
|
...componentId ? [`componentId: ${componentId}`] : [],
|
|
@@ -6568,7 +6772,7 @@ function resolveMermaidDetailedNodeLabel(node) {
|
|
|
6568
6772
|
])));
|
|
6569
6773
|
return buildDetailedLabel(lines);
|
|
6570
6774
|
}
|
|
6571
|
-
const fallbackLabel = pickString(nodeData === null || nodeData === void 0 ? void 0 : nodeData.label);
|
|
6775
|
+
const fallbackLabel = pickString(nodeData$1 === null || nodeData$1 === void 0 ? void 0 : nodeData$1.label);
|
|
6572
6776
|
if (fallbackLabel) return `${nodeType ? nodeType.charAt(0).toUpperCase() + nodeType.slice(1) : "Node"}: ${fallbackLabel}`;
|
|
6573
6777
|
}
|
|
6574
6778
|
function escapeMermaidEdgeLabelText(value) {
|
|
@@ -6626,4 +6830,4 @@ function convertUiGraphToMermaid(input, options) {
|
|
|
6626
6830
|
context
|
|
6627
6831
|
};
|
|
6628
6832
|
}
|
|
6629
|
-
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, convertReactFlowToSequenceMermaid, convertReactFlowToSequenceUiGraph, convertUiGraphToMermaid, estimateSequenceMessageBoxSize, flattenMetaData, generateTableNodeId, generateUUID, getC4ElementColors, isC4Diagram, isSequenceDiagram, parseC4Diagram, sanitizeMermaidLabels, syncBaseData };
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uigraph/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"repository": {
|
|
@@ -111,13 +111,14 @@
|
|
|
111
111
|
},
|
|
112
112
|
"scripts": {
|
|
113
113
|
"test": "vitest --run",
|
|
114
|
+
"test:watch": "vitest --watch",
|
|
114
115
|
"typecheck": "tsc --noEmit",
|
|
115
116
|
"typecheck:watch": "tsc --noEmit --watch",
|
|
116
117
|
"lint": "tsc --noEmit && eslint .",
|
|
117
118
|
"lint:fix": "eslint . --fix",
|
|
118
119
|
"exports": "tsx ./write-exports.ts",
|
|
119
120
|
"build": "tsdown --config ./tsdown.config.ts",
|
|
120
|
-
"dev": "
|
|
121
|
+
"dev": "tsdown --config ./tsdown.config.ts --watch",
|
|
121
122
|
"start": "bun run --watch ./src/__lab__/index.ts"
|
|
122
123
|
}
|
|
123
124
|
}
|