Comparing version 0.0.8 to 0.0.9
@@ -43,10 +43,13 @@ "use strict"; | ||
} | ||
function fntoReadable(params) { | ||
return params.replace(/([A-Z])/g, " $1").replace(/^./, function (str) { return str.toUpperCase(); }); | ||
} | ||
function getSequenceFromNode(node, dedups = []) { | ||
let sequence = ""; | ||
if (node.parent) { | ||
!dedups.includes(node.parent.actor) && (sequence += `participant ${abbreviate(node.parent.actor, dedups)} as ${node.parent.actor} \n`); | ||
!dedups.includes(node.actor) && (sequence += `participant ${abbreviate(node.actor, dedups)} as ${node.actor} \n`); | ||
!dedups.includes(node.parent.actor) && (sequence += `participant ${abbreviate(node.parent.actor, dedups)} as ${fntoReadable(node.parent.actor)} \n`); | ||
!dedups.includes(node.actor) && (sequence += `participant ${abbreviate(node.actor, dedups)} as ${fntoReadable(node.actor)} \n`); | ||
const actorSrc = abbreviate(node.parent.actor, dedups); | ||
const actorDest = abbreviate(node.actor, dedups); | ||
sequence += `${actorSrc} ->>+ ${actorDest}: ${node.type}`; | ||
sequence += `${actorSrc} ->>+ ${actorDest}: ${fntoReadable(node.type)}`; | ||
dedups.includes(node.timestamp) || (sequence += `\nNote left of ${actorSrc}:${node.timestamp}`) && dedups.push(node.timestamp); | ||
@@ -53,0 +56,0 @@ node.method && (sequence += `\nNote over ${actorSrc},${actorDest}:` + node.method); |
{ | ||
"name": "ts2uml", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "typescript workflow to uml sequence", | ||
@@ -18,6 +18,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"jest": "^29.7.0", | ||
"terser": "^5.31.0" | ||
} | ||
} |
@@ -52,3 +52,3 @@ # ts2uml | ||
 | ||
 | ||
@@ -55,0 +55,0 @@ 3. The sequence decorator will modify the original method to apply a graph sequence. It 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. |
@@ -9,4 +9,4 @@ import { _getSequence } from "./graph-node-parser"; | ||
*/ | ||
export declare function uml(obj: any): Function; | ||
export declare function setSequenceId(obj: any, requestId: string): void; | ||
export declare function uml(): Function; | ||
export declare function setSequenceId(requestId: string): void; | ||
export declare const getSequence: typeof _getSequence; |
29
uml.js
@@ -14,3 +14,3 @@ "use strict"; | ||
*/ | ||
function uml(obj) { | ||
function uml() { | ||
return function (method, caller, d) { | ||
@@ -50,12 +50,4 @@ var _a, _b; | ||
const overidden = function (...args) { | ||
try { | ||
method; | ||
d; | ||
const result = _applyGraph.call(this, originalMethod, args); | ||
return result; | ||
} | ||
catch (e) { | ||
console.log("Error in method " + originalMethod.name); | ||
throw e; | ||
} | ||
const result = _applyGraph.call(this, originalMethod, args); | ||
return result; | ||
}; | ||
@@ -69,3 +61,3 @@ if (d) { | ||
} | ||
function setSequenceId(obj, requestId) { | ||
function setSequenceId(requestId) { | ||
model_1._graphs._setRequestId(requestId); | ||
@@ -91,6 +83,13 @@ } | ||
} | ||
const result = originalMethod.call(this, ...args); | ||
requestId && (model_1._graphs.graphs[requestId] = oldNode) && result && (oldNode.response = JSON.stringify(result)); | ||
return result; | ||
try { | ||
const result = originalMethod.call(this, ...args); | ||
requestId && (model_1._graphs.graphs[requestId] = oldNode) && result && (oldNode.response = JSON.stringify(result)); | ||
return result; | ||
} | ||
catch (e) { | ||
requestId && (model_1._graphs.graphs[requestId] = oldNode) && e && (oldNode.response = JSON.stringify(e.message)); | ||
(0, graph_node_parser_1._getSequence)(); | ||
throw e; | ||
} | ||
} | ||
exports.getSequence = graph_node_parser_1._getSequence; |
28410
1
383