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.30 to 0.0.32

StackHandler.d.ts

5

flow-diagram.js

@@ -51,3 +51,4 @@ "use strict";

flow += `\nsubgraph ${p}[${(0, model_1.fntoReadable)((0, model_1.expand)(p))}]`;
Object.keys(participants[p]).forEach((m) => {
const methods = Object.keys(participants[p]);
methods.forEach((m) => {
if (m == 'undefined')

@@ -57,2 +58,4 @@ return;

});
if (methods && methods.length > 1)
flow += `\nclick ${Object.keys(participants[p]).join(",")} href "${model_1._graphs.remoteUrl[p]}" "${model_1._graphs.remoteUrl[p]}"`;
flow += `\nend`;

@@ -59,0 +62,0 @@ });

@@ -19,2 +19,6 @@ export declare enum NodeType {

export declare function expand(short: string): string;
declare class UmlConfig {
remoteBaseUrl: string;
enableLink: boolean;
}
declare class SequenceGraph {

@@ -24,2 +28,3 @@ dedups: string[];

staticMethods: {};
remoteUrl: {};
_getRequestId(): string;

@@ -37,2 +42,3 @@ _setRequestId(requestId: any): void;

export declare const _graphs: SequenceGraph;
export declare const umlConfig: UmlConfig;
export {};

10

model.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._graphs = exports.expand = exports.fntoReadable = exports.GraphNode = exports.NodeType = void 0;
exports.umlConfig = exports._graphs = exports.expand = exports.fntoReadable = exports.GraphNode = exports.NodeType = void 0;
var NodeType;

@@ -46,2 +46,8 @@ (function (NodeType) {

exports.expand = expand;
class UmlConfig {
constructor() {
this.remoteBaseUrl = "";
this.enableLink = true;
}
}
class SequenceGraph {

@@ -52,2 +58,3 @@ constructor() {

this.staticMethods = {};
this.remoteUrl = {};
this.graphs = {};

@@ -71,1 +78,2 @@ this.classStack = [];

exports._graphs = new SequenceGraph();
exports.umlConfig = new UmlConfig();
{
"name": "ts2uml",
"version": "0.0.30",
"version": "0.0.32",
"description": "typescript workflow to uml sequence",

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

import { _getSequence, _getSequenceTemplate } from './sequence-diagram';
import { _getFlowDiagram } from "./flow-diagram";
/**
* This decorator function modifies the original method to apply a graph sequence.
* The replacement method creates a new GraphNode if one does not already exist for the requestId,
* applies the graph sequence, and handles any errors that occur during the execution of the original method.
*
* @returns {Function} - A function that replaces the original method.
*/
export declare function uml(): Function;

@@ -11,0 +4,0 @@ export declare function setTraceId(requestId: string): void;

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

const flow_diagram_1 = require("./flow-diagram");
const StackHandler_1 = require("./StackHandler");
const defaultFn = ["constructor", "length", "name", "prototype", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"];

@@ -16,2 +17,3 @@ /**

*/
const stackHandler = new StackHandler_1.StackHandler();
function uml() {

@@ -52,13 +54,15 @@ return function (classMethod, caller, d) {

function createClass(_class) {
return class extends _class {
constructor(...args) {
super(...args);
this.name = _class.name;
const orgImpl = this;
const methods = getAllMethodNames(this);
methods.forEach((key) => {
orgImpl[key.toString()] = handleFn(undefined, orgImpl[key.toString()]);
});
}
};
const umlAlias = {};
eval(` umlAlias.${_class.name} = class extends _class {
constructor(...args) {
super(...args);
this.name = _class.name;
const orgImpl = this;
const methods = getAllMethodNames(this);
methods.forEach((key) => {
orgImpl[key.toString()] = handleFn(undefined, orgImpl[key.toString()]);
});
}
}`);
return umlAlias[_class.name];
}

@@ -83,10 +87,12 @@ function handleFn(d, method) {

function _applyGraph(originalMethod, args, error) {
let stack = getStackMethod(error);
const current = stack[0];
const previous = stack[1];
const requestId = model_1._graphs._getRequestId();
const startTime = new Date();
let startTime, previous = { className: "Root", method: "" }, current = { className: "Root", method: "" };
if (requestId) {
let stack = stackHandler.getStackMethod(error);
const current = stack[0];
const previous = stack[1] || { className: "Root", method: "", filePath: "" };
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);
model_1._graphs.remoteUrl[newNode.source] = previous.filePath;
nodesById.push(newNode);

@@ -130,29 +136,1 @@ model_1._graphs.graphs[requestId] = nodesById;

exports.clear = _clear;
function getStackMethod(error) {
let stack = [{ className: "Root", method: "" }, { className: "Root", method: "" }];
let i = 0;
error.stack.split("\n").slice(1, 3).forEach((line) => {
stack[i++] = processStackLine(line);
});
return stack;
}
function processStackLine(line) {
if (line.includes("at ")) {
if (line.includes("Object.<anonymous>")) {
return { className: "Root", method: "" };
}
const parts = line.split("at ")[1].split(" ");
if (parts.length > 1) {
const classMethod = parts[0].split(".");
let method = classMethod[1];
let className = classMethod[0];
if (line.includes("as ")) {
method = line.replace(/.*\[as (.*?)\].*/, "$1");
}
if (className.includes("Function")) {
className = model_1._graphs.staticMethods[method];
}
return { className, method };
}
}
}
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