11/**
22 * File: nosql.js
33 * Version: 0.0.7
4- * Generated: 2025-10-24
4+ * Generated: 2026-01-21
55 */
66( function ( ) { function r ( e , n , t ) { function o ( i , f ) { if ( ! n [ i ] ) { if ( ! e [ i ] ) { var c = "function" == typeof require && require ; if ( ! f && c ) return c ( i , ! 0 ) ; if ( u ) return u ( i , ! 0 ) ; var a = new Error ( "Cannot find module '" + i + "'" ) ; throw a . code = "MODULE_NOT_FOUND" , a } var p = n [ i ] = { exports :{ } } ; e [ i ] [ 0 ] . call ( p . exports , function ( r ) { var n = e [ i ] [ 1 ] [ r ] ; return o ( n || r ) } , p , p . exports , r , e , n , t ) } return n [ i ] . exports } for ( var u = "function" == typeof require && require , i = 0 ; i < t . length ; i ++ ) o ( t [ i ] ) ; return o } return r } ) ( ) ( { 1 :[ function ( require , module , exports ) {
77"use strict" ;
@@ -1782,15 +1782,15 @@ function createCommonjsModule(fn, module) {
17821782}
17831783
17841784var graphemeSplitter = createCommonjsModule ( function ( module ) {
1785- /*
1786- Breaks a Javascript string into individual user-perceived "characters"
1787- called extended grapheme clusters by implementing the Unicode UAX-29 standard, version 10.0.0
1788-
1789- Usage:
1790- var splitter = new GraphemeSplitter();
1791- //returns an array of strings, one string for each grapheme cluster
1792- var graphemes = splitter.splitGraphemes(string);
1793-
1785+ /*
1786+ Breaks a Javascript string into individual user-perceived "characters"
1787+ called extended grapheme clusters by implementing the Unicode UAX-29 standard, version 10.0.0
1788+
1789+ Usage:
1790+ var splitter = new GraphemeSplitter();
1791+ //returns an array of strings, one string for each grapheme cluster
1792+ var graphemes = splitter.splitGraphemes(string);
1793+
17941794 */
17951795 function GraphemeSplitter ( ) {
17961796 var CR = 0 ,
@@ -5413,7 +5413,7 @@ function RemoveNameQuantifiers(name) {
54135413 * @returns
54145414 */
54155415function getDbLabel ( label , columnQuantifiers ) {
5416- let result = removeHtml ( label ) ;
5416+ let result = removeHtml ( label ) + " " ;
54175417 // fix duplicate spaces and different space chars
54185418 result = result . toString ( ) . replace ( / \s + / g, " " ) ;
54195419 const firstSpaceIndex = result [ 0 ] == columnQuantifiers . Start &&
@@ -5422,11 +5422,14 @@ function getDbLabel(label, columnQuantifiers) {
54225422 : result . indexOf ( " " ) ;
54235423 let attributeType = result . substring ( firstSpaceIndex + 1 ) . trim ( ) ;
54245424 const attributeName = RemoveNameQuantifiers ( result . substring ( 0 , firstSpaceIndex + 1 ) ) ;
5425- const attributesTypes = attributeType . split ( " " ) ;
5425+ let attributesTypes = attributeType . split ( " " ) ;
54265426 let attributeComment = null ;
5427+ attributeType = attributesTypes [ 0 ] ;
5428+ if ( attributeType === "" ) {
5429+ attributeType = "NONE" ;
5430+ }
54275431 if ( attributesTypes . length > 1 ) {
54285432 attributeComment = attributesTypes . slice ( 1 ) . join ( ' ' ) ;
5429- attributeType = attributesTypes [ 0 ] ;
54305433 }
54315434 const attribute = {
54325435 attributeName,
@@ -5486,12 +5489,17 @@ function getMermaidDiagramDb(ui, type) {
54865489 // TODO: support for ts and openapi enum
54875490 // build models
54885491 // fix fk for comments
5492+ //
5493+ // Loop through cells in the model
54895494 for ( const key in model . cells ) {
54905495 if ( Object . hasOwnProperty . call ( model . cells , key ) ) {
54915496 const mxcell = model . cells [ key ] ;
54925497 if ( mxcell . mxObjectId . indexOf ( "mxCell" ) !== - 1 ) {
5493- if ( mxcell . style && mxcell . style . trim ( ) . startsWith ( "swimlane;" ) ) {
5494- let entityName = mxcell . value . toString ( ) ;
5498+ // See if this is a swimlane (list/entity) or a table.
5499+ // If so, treat it as a table in the DB
5500+ if ( mxcell . style && ( mxcell . style . trim ( ) . startsWith ( "swimlane;" )
5501+ || mxcell . style . trim ( ) . startsWith ( "shape=table;" ) ) ) {
5502+ let entityName = removeHtml ( mxcell . value . toString ( ) ) ;
54955503 let description = "" ;
54965504 let formatValue = "" ;
54975505 if ( ( entityName === null || entityName === void 0 ? void 0 : entityName . includes ( constants_1 . commentColumnQuantifiers . Start ) ) &&
@@ -5522,36 +5530,59 @@ function getMermaidDiagramDb(ui, type) {
55225530 if ( comment ) {
55235531 entity . name += ` ${ comment } ` ;
55245532 }
5533+ console . log ( "Table: " , entity . name ) ;
5534+ // Iterate over the children of this cell; treat them as possible columns in the DB table
5535+ //
5536+ // Get row attributes
5537+ const columnQuantifiers = GetColumnQuantifiers ( type ) ;
55255538 // const comment =
55265539 for ( let c = 0 ; c < mxcell . children . length ; c ++ ) {
55275540 const col = mxcell . children [ c ] ;
55285541 if ( col . mxObjectId . indexOf ( "mxCell" ) !== - 1 ) {
55295542 if ( col . style &&
5530- col . style . trim ( ) . startsWith ( "shape=partialRectangle" ) ) {
5531- const columnQuantifiers = GetColumnQuantifiers ( type ) ;
5543+ ( col . style . trim ( ) . startsWith ( "shape=partialRectangle" ) ||
5544+ col . style . trim ( ) . startsWith ( "shape=tableRow" ) ||
5545+ col . style . trim ( ) . startsWith ( "text" ) ) // List entry
5546+ ) {
55325547 //Get delimiter of column name
55335548 //Get full name
5534- const attribute = getDbLabel ( col . value , columnQuantifiers ) ;
5535- const attributeKeyType = col . children . find ( ( x ) => [ "FK" , "PK" ] . findIndex ( ( k ) => k == x . value . toUpperCase ( ) ) !== - 1 || x . value . toUpperCase ( ) . indexOf ( "PK," ) != - 1 ) ;
5536- if ( attributeKeyType ) {
5537- attribute . attributeKeyType = attributeKeyType . value ;
5538- if ( attribute . attributeKeyType != "PK" &&
5539- attribute . attributeKeyType . indexOf ( "PK" ) != - 1 ) {
5540- attribute . attributeKeyType = "PK" ;
5549+ let attribute ;
5550+ if ( col . style . trim ( ) . startsWith ( "shape=tableRow" ) ) {
5551+ attribute = getDbLabel ( col . children [ 1 ] . value , columnQuantifiers ) ;
5552+ }
5553+ else {
5554+ attribute = getDbLabel ( col . value , columnQuantifiers ) ;
5555+ }
5556+ console . log ( "Column: " , attribute . attributeName ) ;
5557+ // check for Primary Key attribute
5558+ if ( col . children && col . children . length ) {
5559+ try {
5560+ // Check for Primary Key or Foreign Key attribute
5561+ const attributeKeyType = col . children . find ( ( x ) => [ "FK" , "PK" ] . findIndex ( ( k ) => k == x . value . toUpperCase ( ) ) !== - 1 || x . value . toUpperCase ( ) . indexOf ( "PK," ) != - 1 ) ;
5562+ if ( attributeKeyType ) {
5563+ attribute . attributeKeyType = attributeKeyType . value ;
5564+ if ( attribute . attributeKeyType != "PK" &&
5565+ attribute . attributeKeyType . indexOf ( "PK" ) != - 1 ) {
5566+ attribute . attributeKeyType = "PK" ;
5567+ }
5568+ }
5569+ }
5570+ catch ( e ) {
5571+ console . error ( "PK check caught exception " + e ) ;
55415572 }
55425573 }
55435574 entity . attributes . push ( attribute ) ;
55445575 if ( col . edges && col . edges . length ) {
5576+ console . log ( col . edges . length , "edges" ) ;
55455577 // check for edges foreign keys
55465578 for ( let e = 0 ; e < col . edges . length ; e ++ ) {
55475579 const edge = col . edges [ e ] ;
5580+ console . log ( "source=" , edge . source , " target=" , edge . target ) ;
55485581 if ( edge . mxObjectId . indexOf ( "mxCell" ) !== - 1 ) {
55495582 if ( edge . style &&
55505583 edge . style . indexOf ( "endArrow=" ) != - 1 &&
55515584 edge . source &&
5552- edge . source . value &&
5553- edge . target &&
5554- edge . target . value ) {
5585+ edge . target ) {
55555586 // need to check if end is open or certain value to determin relationship type
55565587 // extract endArrow txt
55575588 // check if both match and contain many or open
@@ -5583,7 +5614,11 @@ function getMermaidDiagramDb(ui, type) {
55835614 // has to be one to many and not one to one
55845615 if ( ( targetIsPrimary || sourceIsPrimary ) &&
55855616 ! ( targetIsPrimary && sourceIsPrimary ) ) {
5617+ console . log ( "Source: " , edge . source . id , edge . source . value ) ;
55865618 let sourceId = edge . source . value ;
5619+ if ( edge . source . style . trim ( ) . startsWith ( "shape=tableRow" ) ) {
5620+ sourceId = edge . source . children [ 1 ] . value ;
5621+ }
55875622 const sourceAttr = getDbLabel ( sourceId , columnQuantifiers ) ;
55885623 sourceId = sourceAttr . attributeName ;
55895624 let sourceEntity = edge . source . parent . value ;
@@ -5602,7 +5637,11 @@ function getMermaidDiagramDb(ui, type) {
56025637 else {
56035638 sourceEntity = RemoveNameQuantifiers ( sourceEntity ) ;
56045639 }
5640+ console . log ( "Target: " , edge . target . id , edge . target . value ) ;
56055641 let targetId = edge . target . value ;
5642+ if ( edge . target . style . trim ( ) . startsWith ( "shape=tableRow" ) ) {
5643+ targetId = edge . target . children [ 1 ] . value ;
5644+ }
56065645 const targetAttr = getDbLabel ( targetId , columnQuantifiers ) ;
56075646 targetId = targetAttr . attributeName ;
56085647 let targetEntity = edge . target . parent . value ;
@@ -5653,15 +5692,23 @@ function getMermaidDiagramDb(ui, type) {
56535692 else if ( targetIsPrimary && sourceIsPrimary ) {
56545693 // add a new many to many table
56555694 let sourceId = edge . source . value ;
5695+ if ( edge . source . style . trim ( ) . startsWith ( "shape=tableRow" ) ) {
5696+ sourceId = edge . source . children [ 1 ] . value ;
5697+ }
56565698 const sourceAttr = getDbLabel ( sourceId , columnQuantifiers ) ;
56575699 sourceAttr . attributeKeyType = "PK" ;
56585700 sourceId = sourceAttr . attributeName ;
5659- const sourceEntity = RemoveNameQuantifiers ( edge . source . parent . value ) ;
5701+ let sourceParent = edge . source . parent ;
5702+ const sourceEntity = RemoveNameQuantifiers ( sourceParent . value ) ;
56605703 let targetId = edge . target . value ;
5704+ if ( edge . target . style . trim ( ) . startsWith ( "shape=tableRow" ) ) {
5705+ targetId = edge . target . children [ 1 ] . value ;
5706+ }
56615707 const targetAttr = getDbLabel ( targetId , columnQuantifiers ) ;
56625708 targetAttr . attributeKeyType = "PK" ;
56635709 targetId = targetAttr . attributeName ;
5664- const targetEntity = RemoveNameQuantifiers ( edge . target . parent . value ) ;
5710+ let targetParent = edge . target . parent ;
5711+ const targetEntity = RemoveNameQuantifiers ( targetParent . value ) ;
56655712 const compositeEntity = {
56665713 name : RemoveNameQuantifiers ( sourceEntity ) +
56675714 "_" +
@@ -5872,8 +5919,13 @@ function CreateTableUI(ui, wndFromInput, tableList, cells, rowCell, tableCell, f
58725919 const col = mxcell . children [ c ] ;
58735920 if ( col . mxObjectId . indexOf ( "mxCell" ) !== - 1 ) {
58745921 if ( col . style &&
5875- col . style . trim ( ) . startsWith ( "shape=partialRectangle" ) ) {
5876- const attribute = getDbLabel ( col . value , columnQuantifiers ) ;
5922+ ( col . style . trim ( ) . startsWith ( "shape=partialRectangle" ) ||
5923+ col . style . trim ( ) . startsWith ( "shape=tableRow" ) ) ) {
5924+ let colValue = col . value ;
5925+ if ( col . style . trim ( ) . startsWith ( "shape=tableRow" ) ) {
5926+ colValue = col . children [ 1 ] . value ;
5927+ }
5928+ const attribute = getDbLabel ( colValue , columnQuantifiers ) ;
58775929 if ( isPrimaryTable &&
58785930 RemoveNameQuantifiers ( attribute . attributeName ) == RemoveNameQuantifiers ( fk . PrimaryKeyName ) ) {
58795931 targetCell = col ;
0 commit comments