Comparing version 0.0.36 to 0.0.37
@@ -44,3 +44,3 @@ "use strict"; | ||
participants[node.reciever][node.recMethod] = undefined; | ||
const path = `\n${node.srcMethod ? node.srcMethod : node.source}---->${node.recMethod ? node.recMethod : node.reciever}`; | ||
const path = `${node.modifier != model_1.Modifier.Public ? ("\n%%" + node.modifier + "") : ""}\n${node.srcMethod ? node.srcMethod : node.source}---->${node.recMethod ? node.recMethod : node.reciever}`; | ||
if (participants[path]) | ||
@@ -47,0 +47,0 @@ return; |
@@ -8,2 +8,7 @@ export declare enum NodeType { | ||
} | ||
export declare enum Modifier { | ||
Public = "public", | ||
Private = "private", | ||
Protected = "protected" | ||
} | ||
export declare class GraphNode { | ||
@@ -13,2 +18,3 @@ readonly args: string; | ||
type: NodeType; | ||
modifier: Modifier; | ||
readonly source: string; | ||
@@ -18,3 +24,3 @@ readonly recMethod: string; | ||
readonly srcMethod: string; | ||
constructor(source: string, srcMethod: string, reciever: string, method: string, args: string, timestamp: number, type: NodeType); | ||
constructor(source: string, srcMethod: string, reciever: string, method: string, args: string, timestamp: number, type: NodeType, modifier: Modifier); | ||
} | ||
@@ -21,0 +27,0 @@ export declare function fntoReadable(params: string): string; |
11
model.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.umlConfig = exports._graphs = exports.expand = exports.fntoReadable = exports.GraphNode = exports.NodeType = void 0; | ||
exports.umlConfig = exports._graphs = exports.expand = exports.fntoReadable = exports.GraphNode = exports.Modifier = exports.NodeType = void 0; | ||
var NodeType; | ||
@@ -12,7 +12,14 @@ (function (NodeType) { | ||
})(NodeType || (exports.NodeType = NodeType = {})); | ||
var Modifier; | ||
(function (Modifier) { | ||
Modifier["Public"] = "public"; | ||
Modifier["Private"] = "private"; | ||
Modifier["Protected"] = "protected"; | ||
})(Modifier || (exports.Modifier = Modifier = {})); | ||
class GraphNode { | ||
constructor(source, srcMethod, reciever, method, args, timestamp, type) { | ||
constructor(source, srcMethod, reciever, method, args, timestamp, type, modifier) { | ||
this.args = args; | ||
this.timestamp = timestamp; | ||
this.type = type; | ||
this.modifier = modifier; | ||
this.source = source && abbreviate(source); | ||
@@ -19,0 +26,0 @@ this.recMethod = method && abbreviate(method); |
{ | ||
"name": "ts2uml", | ||
"version": "0.0.36", | ||
"version": "0.0.37", | ||
"description": "typescript workflow to uml sequence", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// copy the uml-sprinkler files to the node_modules.bin or ./../../ | ||
// copy the uml-sprinkler files to the node_modules/.bin or ./../../ | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const files = ['uml-sprinkler', 'uml-sprinkler.bat']; | ||
const dest = (0, path_1.join)(__dirname, './../../'); | ||
const local = (0, path_1.join)(__dirname, './../../node_modules/.bin'); | ||
files.forEach(file => { | ||
const src = (0, path_1.join)(__dirname, file); | ||
const dest = (0, path_1.join)(__dirname, './../../'); | ||
const local = (0, path_1.join)(__dirname, './../../node_modules/.bin'); | ||
try { | ||
@@ -25,2 +25,3 @@ if ((0, fs_1.existsSync)(src)) { | ||
} | ||
handlePackageJson(); | ||
} | ||
@@ -31,1 +32,32 @@ catch (e) { | ||
}); | ||
function handlePackageJson() { | ||
// Step 2: Define the path to the package.json file | ||
const packageJsonPath = (0, path_1.join)(__dirname, 'package.json'); | ||
// Step 3: Read the package.json file into a variable | ||
if ((0, fs_1.existsSync)(packageJsonPath)) { | ||
const packageJsonContent = (0, fs_1.readFileSync)(packageJsonPath, 'utf8'); | ||
// Step 4: Parse the JSON content of the file | ||
const packageJson = JSON.parse(packageJsonContent); | ||
// Step 5: Check if the `scripts` section exists, if not, create it | ||
if (!packageJson.scripts) { | ||
packageJson.scripts = {}; | ||
} | ||
// Step 6: Check if the `uml-sprinkler` script exists | ||
if (!packageJson.scripts['uml-sprinkler']) { | ||
// If it does not exist, add it | ||
packageJson.scripts['uml-sprinkler'] = 'uml-sprinkler src'; | ||
// Step 7: Convert the modified JSON object back to a string | ||
const updatedPackageJsonContent = JSON.stringify(packageJson, null, 2); | ||
// Step 8: Write the modified JSON string back to the package.json file | ||
(0, fs_1.writeFileSync)(packageJsonPath, updatedPackageJsonContent, 'utf8'); | ||
// Step 9: Log a success message | ||
console.log('Added "uml-sprinkler" script to package.json'); | ||
} | ||
else { | ||
console.log('"uml-sprinkler" script already exists in package.json'); | ||
} | ||
} | ||
else { | ||
console.log('package.json does not exist in the specified path'); | ||
} | ||
} |
@@ -85,6 +85,19 @@ "use strict"; | ||
exports.setTraceId = setTraceId; | ||
function findModifier(originalMethod) { | ||
const impl = originalMethod.toString(); | ||
if (impl.indexOf("private") > -1) { | ||
return model_1.Modifier.Private; | ||
} | ||
else if (impl.indexOf("protected") > -1) { | ||
return model_1.Modifier.Protected; | ||
} | ||
else { | ||
return model_1.Modifier.Public; | ||
} | ||
} | ||
function _applyGraph(originalMethod, args, error) { | ||
const requestId = model_1._graphs._getRequestId(); | ||
let startTime, previous = { className: "Root", method: "", filePath: "" }, current = { className: "Root", method: "", filePath: "" }; | ||
let startTime, modifier, previous = { className: "Root", method: "", filePath: "" }, current = { className: "Root", method: "", filePath: "" }; | ||
if (requestId) { | ||
modifier = findModifier(originalMethod); | ||
let stack = stackHandler.getStackMethod(error); | ||
@@ -95,3 +108,3 @@ current = stack[0]; | ||
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); | ||
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); | ||
model_1._graphs.remoteUrl[newNode.source] = previous.filePath; | ||
@@ -104,3 +117,3 @@ nodesById.push(newNode); | ||
if (requestId) { | ||
handleResponse(result, previous.className, previous.method, current.className, current.method, startTime); | ||
handleResponse(result, previous.className, previous.method, current.className, current.method, startTime, modifier); | ||
} | ||
@@ -111,3 +124,3 @@ return result; | ||
if (requestId) { | ||
handleResponse(e, previous.className, previous.method, current.className, current.method, startTime); | ||
handleResponse(e, previous.className, previous.method, current.className, current.method, startTime, modifier); | ||
(0, sequence_diagram_1._getSequence)(); | ||
@@ -118,11 +131,11 @@ } | ||
} | ||
function handleResponse(result, prevClassName, prevMethod, className, method, startTime) { | ||
function handleResponse(result, prevClassName, prevMethod, className, method, startTime, modifier) { | ||
const nodes = model_1._graphs.graphs[model_1._graphs._getRequestId()] || []; | ||
if (result instanceof Promise) { | ||
result.then((res) => { | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, res && Object.keys(res).length ? JSON.stringify(res) : "", new Date().getTime() - startTime.getTime(), model_1.NodeType.ResponseAsync); | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, res && Object.keys(res).length ? JSON.stringify(res) : "", new Date().getTime() - startTime.getTime(), model_1.NodeType.ResponseAsync, modifier); | ||
nodes.push(newNode); | ||
return res; | ||
}); | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, result && Object.keys(result).length ? JSON.stringify(result) : "", new Date().getTime() - startTime.getTime(), model_1.NodeType.AsyncReturn); | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, result && Object.keys(result).length ? JSON.stringify(result) : "", new Date().getTime() - startTime.getTime(), model_1.NodeType.AsyncReturn, model_1.Modifier.Public); | ||
nodes.push(newNode); | ||
@@ -132,3 +145,3 @@ model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; | ||
else { | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, result && Object.keys(result).length ? JSON.stringify(result) : result, new Date().getTime() - startTime.getTime(), result instanceof Boolean ? model_1.NodeType.Boolean : model_1.NodeType.Response); | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, result && Object.keys(result).length ? JSON.stringify(result) : result, new Date().getTime() - startTime.getTime(), result instanceof Boolean ? model_1.NodeType.Boolean : model_1.NodeType.Response, model_1.Modifier.Public); | ||
nodes.push(newNode); | ||
@@ -135,0 +148,0 @@ model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43822
28
916