Comparing version 0.0.53 to 0.0.54
@@ -34,3 +34,3 @@ "use strict"; | ||
const participants = {}; | ||
nodes.filter(n => n.type == model_1.NodeType.Request).forEach((node, i) => { | ||
nodes.filter(n => n.type === model_1.NodeType.ResponseAsync || n.type === model_1.NodeType.Request).forEach((node, i) => { | ||
if (!participants[node.source]) { | ||
@@ -44,9 +44,15 @@ participants[node.source] = {}; | ||
participants[node.reciever][node.recMethod] = undefined; | ||
const path = `${node.modifier != model_1.Modifier.Public ? ("\n%%" + node.modifier + "") : ""}\n${node.srcMethod ? node.srcMethod : node.source}---->${node.recMethod ? node.recMethod : node.reciever}`; | ||
let path = ""; | ||
if (node.type === model_1.NodeType.ResponseAsync) { | ||
path = `${node.modifier != model_1.Modifier.Public ? ("\n%%" + node.modifier + "") : ""}\n${node.recMethod ? node.recMethod : node.reciever}-.o${node.srcMethod ? node.srcMethod : node.source}`; | ||
} | ||
else if (node.type === model_1.NodeType.Request) { | ||
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]) | ||
return; | ||
participants[path] = true; | ||
flow += path.replace(/---->/g, `--${Object.keys(participants).filter(p => p.includes("--")).length}-->`); | ||
flow += path.replace(/([-.=])([-.=])([o>])/g, `$1$2${Object.keys(participants).filter(p => p.includes("-")).length}$2$1$3`); | ||
}); | ||
Object.keys(participants).filter(p => !p.includes("-")).forEach((p) => { | ||
Object.keys(participants).filter(p => !(p.includes("-") || p.includes("="))).forEach((p) => { | ||
flow += `\nsubgraph ${p}[${(0, model_1.fntoReadable)((0, model_1.expand)(p))}]`; | ||
@@ -53,0 +59,0 @@ const methods = Object.keys(participants[p]); |
{ | ||
"name": "ts2uml", | ||
"version": "0.0.53", | ||
"version": "0.0.54", | ||
"description": "typescript workflow to uml sequence", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -102,3 +102,3 @@ "use strict"; | ||
catch (e) { | ||
console.error("****uml*****"); | ||
console.error("========****uml*****========="); | ||
} | ||
@@ -135,16 +135,22 @@ } | ||
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, modifier); | ||
try { | ||
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, modifier); | ||
nodes.push(newNode); | ||
model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; | ||
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, model_1.Modifier.Public); | ||
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, model_1.Modifier.Public); | ||
nodes.push(newNode); | ||
model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; | ||
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, model_1.Modifier.Public); | ||
nodes.push(newNode); | ||
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, model_1.Modifier.Public); | ||
nodes.push(newNode); | ||
model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; | ||
catch (e) { | ||
console.log("-----****uml****----"); | ||
} | ||
@@ -151,0 +157,0 @@ } |
49001
1039