Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34,324 changes: 19,871 additions & 14,453 deletions dist/nosql-ts.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/nosql-ts.min.js

Large diffs are not rendered by default.

114 changes: 83 additions & 31 deletions dist/nosql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* File: nosql.js
* Version: 0.0.7
* Generated: 2025-10-24
* Generated: 2026-01-21
*/
(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){
"use strict";
Expand Down Expand Up @@ -1782,15 +1782,15 @@ function createCommonjsModule(fn, module) {
}

var graphemeSplitter = createCommonjsModule(function (module) {
/*
Breaks a Javascript string into individual user-perceived "characters"
called extended grapheme clusters by implementing the Unicode UAX-29 standard, version 10.0.0

Usage:
var splitter = new GraphemeSplitter();
//returns an array of strings, one string for each grapheme cluster
var graphemes = splitter.splitGraphemes(string);

/*
Breaks a Javascript string into individual user-perceived "characters"
called extended grapheme clusters by implementing the Unicode UAX-29 standard, version 10.0.0
Usage:
var splitter = new GraphemeSplitter();
//returns an array of strings, one string for each grapheme cluster
var graphemes = splitter.splitGraphemes(string);
*/
function GraphemeSplitter() {
var CR = 0,
Expand Down Expand Up @@ -5413,7 +5413,7 @@ function RemoveNameQuantifiers(name) {
* @returns
*/
function getDbLabel(label, columnQuantifiers) {
let result = removeHtml(label);
let result = removeHtml(label) + " ";
// fix duplicate spaces and different space chars
result = result.toString().replace(/\s+/g, " ");
const firstSpaceIndex = result[0] == columnQuantifiers.Start &&
Expand All @@ -5422,11 +5422,14 @@ function getDbLabel(label, columnQuantifiers) {
: result.indexOf(" ");
let attributeType = result.substring(firstSpaceIndex + 1).trim();
const attributeName = RemoveNameQuantifiers(result.substring(0, firstSpaceIndex + 1));
const attributesTypes = attributeType.split(" ");
let attributesTypes = attributeType.split(" ");
let attributeComment = null;
attributeType = attributesTypes[0];
if (attributeType === "") {
attributeType = "NONE";
}
if (attributesTypes.length > 1) {
attributeComment = attributesTypes.slice(1).join(' ');
attributeType = attributesTypes[0];
}
const attribute = {
attributeName,
Expand Down Expand Up @@ -5486,12 +5489,17 @@ function getMermaidDiagramDb(ui, type) {
// TODO: support for ts and openapi enum
// build models
// fix fk for comments
//
// Loop through cells in the model
for (const key in model.cells) {
if (Object.hasOwnProperty.call(model.cells, key)) {
const mxcell = model.cells[key];
if (mxcell.mxObjectId.indexOf("mxCell") !== -1) {
if (mxcell.style && mxcell.style.trim().startsWith("swimlane;")) {
let entityName = mxcell.value.toString();
// See if this is a swimlane (list/entity) or a table.
// If so, treat it as a table in the DB
if (mxcell.style && (mxcell.style.trim().startsWith("swimlane;")
|| mxcell.style.trim().startsWith("shape=table;"))) {
let entityName = removeHtml(mxcell.value.toString());
let description = "";
let formatValue = "";
if ((entityName === null || entityName === void 0 ? void 0 : entityName.includes(constants_1.commentColumnQuantifiers.Start)) &&
Expand Down Expand Up @@ -5522,36 +5530,59 @@ function getMermaidDiagramDb(ui, type) {
if (comment) {
entity.name += ` ${comment}`;
}
console.log("Table: ", entity.name);
// Iterate over the children of this cell; treat them as possible columns in the DB table
//
// Get row attributes
const columnQuantifiers = GetColumnQuantifiers(type);
// const comment =
for (let c = 0; c < mxcell.children.length; c++) {
const col = mxcell.children[c];
if (col.mxObjectId.indexOf("mxCell") !== -1) {
if (col.style &&
col.style.trim().startsWith("shape=partialRectangle")) {
const columnQuantifiers = GetColumnQuantifiers(type);
(col.style.trim().startsWith("shape=partialRectangle") ||
col.style.trim().startsWith("shape=tableRow") ||
col.style.trim().startsWith("text")) // List entry
) {
//Get delimiter of column name
//Get full name
const attribute = getDbLabel(col.value, columnQuantifiers);
const attributeKeyType = col.children.find((x) => ["FK", "PK"].findIndex((k) => k == x.value.toUpperCase()) !== -1 || x.value.toUpperCase().indexOf("PK,") != -1);
if (attributeKeyType) {
attribute.attributeKeyType = attributeKeyType.value;
if (attribute.attributeKeyType != "PK" &&
attribute.attributeKeyType.indexOf("PK") != -1) {
attribute.attributeKeyType = "PK";
let attribute;
if (col.style.trim().startsWith("shape=tableRow")) {
attribute = getDbLabel(col.children[1].value, columnQuantifiers);
}
else {
attribute = getDbLabel(col.value, columnQuantifiers);
}
console.log("Column: ", attribute.attributeName);
// check for Primary Key attribute
if (col.children && col.children.length) {
try {
// Check for Primary Key or Foreign Key attribute
const attributeKeyType = col.children.find((x) => ["FK", "PK"].findIndex((k) => k == x.value.toUpperCase()) !== -1 || x.value.toUpperCase().indexOf("PK,") != -1);
if (attributeKeyType) {
attribute.attributeKeyType = attributeKeyType.value;
if (attribute.attributeKeyType != "PK" &&
attribute.attributeKeyType.indexOf("PK") != -1) {
attribute.attributeKeyType = "PK";
}
}
}
catch (e) {
console.error("PK check caught exception " + e);
}
}
entity.attributes.push(attribute);
if (col.edges && col.edges.length) {
console.log(col.edges.length, "edges");
// check for edges foreign keys
for (let e = 0; e < col.edges.length; e++) {
const edge = col.edges[e];
console.log("source=", edge.source, " target=", edge.target);
if (edge.mxObjectId.indexOf("mxCell") !== -1) {
if (edge.style &&
edge.style.indexOf("endArrow=") != -1 &&
edge.source &&
edge.source.value &&
edge.target &&
edge.target.value) {
edge.target) {
// need to check if end is open or certain value to determin relationship type
// extract endArrow txt
// check if both match and contain many or open
Expand Down Expand Up @@ -5583,7 +5614,11 @@ function getMermaidDiagramDb(ui, type) {
// has to be one to many and not one to one
if ((targetIsPrimary || sourceIsPrimary) &&
!(targetIsPrimary && sourceIsPrimary)) {
console.log("Source: ", edge.source.id, edge.source.value);
let sourceId = edge.source.value;
if (edge.source.style.trim().startsWith("shape=tableRow")) {
sourceId = edge.source.children[1].value;
}
const sourceAttr = getDbLabel(sourceId, columnQuantifiers);
sourceId = sourceAttr.attributeName;
let sourceEntity = edge.source.parent.value;
Expand All @@ -5602,7 +5637,11 @@ function getMermaidDiagramDb(ui, type) {
else {
sourceEntity = RemoveNameQuantifiers(sourceEntity);
}
console.log("Target: ", edge.target.id, edge.target.value);
let targetId = edge.target.value;
if (edge.target.style.trim().startsWith("shape=tableRow")) {
targetId = edge.target.children[1].value;
}
const targetAttr = getDbLabel(targetId, columnQuantifiers);
targetId = targetAttr.attributeName;
let targetEntity = edge.target.parent.value;
Expand Down Expand Up @@ -5653,15 +5692,23 @@ function getMermaidDiagramDb(ui, type) {
else if (targetIsPrimary && sourceIsPrimary) {
// add a new many to many table
let sourceId = edge.source.value;
if (edge.source.style.trim().startsWith("shape=tableRow")) {
sourceId = edge.source.children[1].value;
}
const sourceAttr = getDbLabel(sourceId, columnQuantifiers);
sourceAttr.attributeKeyType = "PK";
sourceId = sourceAttr.attributeName;
const sourceEntity = RemoveNameQuantifiers(edge.source.parent.value);
let sourceParent = edge.source.parent;
const sourceEntity = RemoveNameQuantifiers(sourceParent.value);
let targetId = edge.target.value;
if (edge.target.style.trim().startsWith("shape=tableRow")) {
targetId = edge.target.children[1].value;
}
const targetAttr = getDbLabel(targetId, columnQuantifiers);
targetAttr.attributeKeyType = "PK";
targetId = targetAttr.attributeName;
const targetEntity = RemoveNameQuantifiers(edge.target.parent.value);
let targetParent = edge.target.parent;
const targetEntity = RemoveNameQuantifiers(targetParent.value);
const compositeEntity = {
name: RemoveNameQuantifiers(sourceEntity) +
"_" +
Expand Down Expand Up @@ -5872,8 +5919,13 @@ function CreateTableUI(ui, wndFromInput, tableList, cells, rowCell, tableCell, f
const col = mxcell.children[c];
if (col.mxObjectId.indexOf("mxCell") !== -1) {
if (col.style &&
col.style.trim().startsWith("shape=partialRectangle")) {
const attribute = getDbLabel(col.value, columnQuantifiers);
(col.style.trim().startsWith("shape=partialRectangle") ||
col.style.trim().startsWith("shape=tableRow"))) {
let colValue = col.value;
if (col.style.trim().startsWith("shape=tableRow")) {
colValue = col.children[1].value;
}
const attribute = getDbLabel(colValue, columnQuantifiers);
if (isPrimaryTable &&
RemoveNameQuantifiers(attribute.attributeName) == RemoveNameQuantifiers(fk.PrimaryKeyName)) {
targetCell = col;
Expand Down
4 changes: 2 additions & 2 deletions dist/nosql.min.js

Large diffs are not rendered by default.

Loading