Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts2uml

Package Overview
Dependencies
Maintainers
0
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts2uml - npm Package Compare versions

Comparing version 0.0.54 to 0.0.55

1

flow-diagram.d.ts
export declare function _getFlowDiagram(): string;
export declare function getMasterFlowDiagram(): void;

@@ -7,2 +7,3 @@ "use strict";

exports._getFlowDiagram = _getFlowDiagram;
exports.getMasterFlowDiagram = getMasterFlowDiagram;
const model_1 = require("./model");

@@ -70,1 +71,70 @@ const fs_1 = __importDefault(require("fs"));

}
function getMasterFlowDiagram() {
const root = "./.ts2uml/";
if (fs_1.default.existsSync(root)) {
const files = fs_1.default.readdirSync(root);
const flows = files.filter(f => f.startsWith("flowchart_")).map(f => root + f);
mergeMermaidFiles(flows, root + "Master_flowchart.md");
}
}
async function readMermaidContent(filePath) {
const content = await fs_1.default.readFileSync(filePath, { encoding: 'utf8' });
const start = content.indexOf('```mermaid') + '```mermaid'.length;
const end = content.indexOf('```', start);
return content.substring(start, end).trim();
}
async function mergeFlowcharts(contents) {
// First, normalize line styles and prepare contents by removing flowchart declarations after the first content
const preparedContents = contents.map((content, index) => {
let modifiedContent = content.replace(/--\d+--/g, '--').replace(/-.\d+.-/g, '-.-');
if (index > 0) {
modifiedContent = modifiedContent.replace(/flowchart (TD|LR|RL|BT|TB).*\n/, '');
}
return modifiedContent;
});
// Assuming subgraphs are well-formed and consistently named across contents
// Merge subgraphs by title
const subgraphMap = new Map();
const arrowMap = ['flowchart LR'];
preparedContents.forEach(content => {
const arrowRegex = /^(.*?(--|-\.-).*?)$/gm;
let match;
while ((match = arrowRegex.exec(content)) !== null) {
const arrow = match[1];
if (!arrowMap.includes(arrow)) {
arrowMap.push(arrow);
}
}
const subgraphRegex = /subgraph (\w+\[.*?\])[\s\S]*?end/g;
while ((match = subgraphRegex.exec(content)) !== null) {
const title = match[1];
const subgraphContent = match[0];
if (!subgraphMap.has(title)) {
subgraphMap.set(title, []);
}
subgraphMap.get(title).push(subgraphContent.replace(/subgraph \w+\[.*?\]|end/g, '').trim());
}
});
// Build merged subgraphs
const mergedSubgraphs = Array.from(subgraphMap.entries()).map(([title, contents]) => {
return `subgraph ${title}\n${contents.join('\n')}\nend`;
});
arrowMap.push(...mergedSubgraphs);
// Join all merged subgraphs with two newlines
return arrowMap.join('\n');
}
function writeMergedContent(filePath, content) {
const mermaidContent = '```mermaid\n' + content + '\n```';
fs_1.default.writeFileSync(filePath, mermaidContent, { encoding: 'utf8' });
}
async function mergeMermaidFiles(filePaths, outputFile) {
try {
const contents = await Promise.all(filePaths.map(filePath => readMermaidContent(filePath)));
const mergedContent = await mergeFlowcharts(contents);
writeMergedContent(outputFile, mergedContent);
console.log('Mermaid files merged successfully.');
}
catch (error) {
console.error('Error merging Mermaid files:', error);
}
}

3

model.d.ts

@@ -28,4 +28,5 @@ export declare enum NodeType {

readonly srcMethod: string;
constructor(source: string, srcMethod: string, reciever: string, method: string, args: string, timestamp: number, type: NodeType, modifier?: Modifier);
constructor(source: string, srcMethod: string, reciever: string, recMethod: string, args: string, timestamp: number, type: NodeType, modifier?: Modifier);
}
export declare function abbreviate(name: string): any;
export declare function fntoReadable(params: string): string;

@@ -32,0 +33,0 @@ export declare function expand(short: string): string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.umlConfig = exports._graphs = exports.Method = exports.Clazz = exports.SourceData = exports.GraphNode = exports.Modifier = exports.StackInfo = exports.NodeType = void 0;
exports.abbreviate = abbreviate;
exports.fntoReadable = fntoReadable;

@@ -27,3 +28,3 @@ exports.expand = expand;

class GraphNode {
constructor(source, srcMethod, reciever, method, args, timestamp, type, modifier = Modifier.Public) {
constructor(source, srcMethod, reciever, recMethod, args, timestamp, type, modifier = Modifier.Public) {
this.args = args;

@@ -34,3 +35,3 @@ this.timestamp = timestamp;

this.source = source && abbreviate(source);
this.recMethod = method && abbreviate(method);
this.recMethod = recMethod && abbreviate(recMethod);
this.srcMethod = srcMethod && abbreviate(srcMethod);

@@ -37,0 +38,0 @@ this.reciever = reciever && abbreviate(reciever);

{
"name": "ts2uml",
"version": "0.0.54",
"version": "0.0.55",
"description": "typescript workflow to uml sequence",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,23 +7,13 @@ "use strict";

const files = ['uml-sprinkler', 'uml-sprinkler.bat'];
const dest = (0, path_1.join)(__dirname, './../../');
const local = (0, path_1.join)(__dirname, './../../node_modules/.bin');
const destDir = (0, path_1.join)(__dirname, './../../');
const localDir = (0, path_1.join)(__dirname, './../../node_modules/.bin');
files.forEach(file => {
const src = (0, path_1.join)(__dirname, file);
try {
if ((0, fs_1.existsSync)(src)) {
if ((0, fs_1.existsSync)(local)) {
console.log(`copying ${src} to ${local}`);
(0, fs_1.copyFileSync)(src, local);
}
else {
console.log(`copying ${src} to ${dest}`);
(0, fs_1.copyFileSync)(src, dest);
}
}
else {
console.log(`file ${src} does not exist`);
}
if ((0, fs_1.existsSync)(src)) {
const destPath = (0, fs_1.existsSync)(localDir) ? (0, path_1.join)(localDir, file) : (0, path_1.join)(destDir, file);
console.log(`Copying ${src} to ${destPath}`);
(0, fs_1.copyFileSync)(src, destPath);
}
catch (e) {
console.log(e);
else {
console.log(`File ${src} does not exist`);
}

@@ -34,3 +24,3 @@ });

// Step 2: Define the path to the package.json file
const packageJsonPath = (0, path_1.join)(dest, 'package.json');
const packageJsonPath = (0, path_1.join)(destDir, 'package.json');
// Step 3: Read the package.json file into a variable

@@ -37,0 +27,0 @@ if ((0, fs_1.existsSync)(packageJsonPath)) {

@@ -1,2 +0,2 @@

import { Modifier, StackInfo } from './model';
import { Modifier, StackInfo, GraphNode } from './model';
export declare class StackHandler {

@@ -10,2 +10,8 @@ readonly excludeList: string[];

getStackMethod(error: Error): StackInfo[];
findIfStackInstanceExistInNodes(stackInstance: {
className: string;
method: string;
filePath: string;
modifier: Modifier;
}, nodes: GraphNode[]): GraphNode | undefined;
private parseRemoteUrl;

@@ -12,0 +18,0 @@ private findOverlap;

@@ -45,3 +45,2 @@ "use strict";

if (currentMethodName) {
console.log(`---------------------------------------------------------------------------- trip saved`);
return { className: currentClassName, method: currentMethodName, modifier };

@@ -109,7 +108,21 @@ }

let i = 0;
error.stack.split("\n").slice(1, 5).forEach((line) => {
stack[i++] = this.processStackLine(line.replace(/umlAlias\./g, ""));
const nodes = model_1._graphs.graphs[model_1._graphs._getRequestId()] || [];
error.stack.split("\n").slice(1, 16).forEach((line, i) => {
const stackInstance = this.processStackLine(line.replace(/umlAlias\./g, ""));
if (stack.length < 3 && stackInstance && (nodes.length < 5 || (i < 1 || this.findIfStackInstanceExistInNodes(stackInstance, nodes)))) {
stack[i++] = stackInstance;
}
});
return stack.slice(0, 2);
}
findIfStackInstanceExistInNodes(stackInstance, nodes) {
//iterate over the nodes in reverse order and find the first node that matches the stack instance
for (let i = nodes.length - 1; i >= 0; i--) {
const node = nodes[i];
if (!(stackInstance === null || stackInstance === void 0 ? void 0 : stackInstance.method) || node.recMethod === (0, model_1.abbreviate)(stackInstance === null || stackInstance === void 0 ? void 0 : stackInstance.method)) {
return node;
}
}
console.log("Stack instance not found in nodes", stackInstance);
}
parseRemoteUrl(remote, local) {

@@ -146,3 +159,4 @@ let overlapString = this.findOverlap(remote, local);

processStackLine(line) {
if (line.includes("at ")) {
line = line.replace("async ", "");
if (line.replace("async ", "").includes("at ")) {
for (const exclude of this.excludeList) {

@@ -169,3 +183,3 @@ if (line.includes(exclude)) {

}
return { className, method, filePath };
return { className, method, filePath, modifier: model_1.Modifier.Public };
}

@@ -172,0 +186,0 @@ else {

@@ -90,2 +90,3 @@ "use strict";

try {
startTime = new Date();
let stack = stackHandler.getStackMethod(error);

@@ -95,5 +96,4 @@ current = stack[0];

modifier = previous.modifier;
startTime = new Date();
const nodesById = model_1._graphs.graphs[requestId] || [];
const newNode = new model_1.GraphNode(previous.className, previous.method, current.className, current.method, args && Object.keys(args).length ? JSON.stringify(args) : "", startTime.getTime(), model_1.NodeType.Request, modifier);
const newNode = new model_1.GraphNode(previous === null || previous === void 0 ? void 0 : previous.className, previous === null || previous === void 0 ? void 0 : previous.method, current === null || current === void 0 ? void 0 : current.className, current === null || current === void 0 ? void 0 : current.method, args && Object.keys(args).length ? JSON.stringify(args) : "", startTime.getTime(), model_1.NodeType.Request, modifier);
model_1._graphs.remoteUrl[newNode.source] = previous.filePath;

@@ -100,0 +100,0 @@ nodesById.push(newNode);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc