Comparing version 0.0.29 to 0.0.30
@@ -22,2 +22,3 @@ export declare enum NodeType { | ||
requestId: string; | ||
staticMethods: {}; | ||
_getRequestId(): string; | ||
@@ -24,0 +25,0 @@ _setRequestId(requestId: any): void; |
@@ -50,2 +50,3 @@ "use strict"; | ||
this.requestId = ""; | ||
this.staticMethods = {}; | ||
this.graphs = {}; | ||
@@ -52,0 +53,0 @@ this.classStack = []; |
{ | ||
"name": "ts2uml", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "typescript workflow to uml sequence", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -122,4 +122,4 @@ "use strict"; | ||
}); | ||
chunk(sequenceArray, 20).forEach((seq) => { | ||
const write = seq.join(""); | ||
chunk(sequenceArray, 20).forEach((seqArray) => { | ||
const write = seqArray.join(""); | ||
writeStream.write(write); | ||
@@ -146,8 +146,6 @@ sequence += write; | ||
if (!participants.includes(node.source)) { | ||
sequence += "\nParticipant " + node.source + " as " + actorSrc; | ||
participants.push(node.source); | ||
sequence = handleParticipant(node.source, actorSrc, sequence, sequenceArray, participants); | ||
} | ||
if (!participants.includes(node.reciever)) { | ||
sequence += "\nParticipant " + node.reciever + " as " + actorDest; | ||
participants.push(node.reciever); | ||
sequence = handleParticipant(node.reciever, actorDest, sequence, sequenceArray, participants); | ||
} | ||
@@ -159,2 +157,11 @@ let seq = parseSequence(node); | ||
} | ||
function handleParticipant(actorAbbr, actor, sequence, sequenceArray, participants) { | ||
const participant = addParticipant(actorAbbr, actor); | ||
sequenceArray.push(participant); | ||
participants.push(actorAbbr); | ||
return sequence; | ||
} | ||
function addParticipant(actorAbbr, actor) { | ||
return "\nParticipant " + actorAbbr + " as " + actor; | ||
} | ||
function calculateMean(participants, sequenceArray, seq, node) { | ||
@@ -161,0 +168,0 @@ //get hash the of seq |
@@ -7,3 +7,3 @@ "use strict"; | ||
const flow_diagram_1 = require("./flow-diagram"); | ||
const defaultFn = ["constructor", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"]; | ||
const defaultFn = ["constructor", "length", "name", "prototype", "__defineGetter__", "__defineSetter__", "hasOwnProperty", "__lookupGetter__", "__lookupSetter__", "isPrototypeOf", "propertyIsEnumerable", "toString", "valueOf", "__proto__", "toLocaleString"]; | ||
/** | ||
@@ -17,9 +17,9 @@ * This decorator function modifies the original method to apply a graph sequence. | ||
function uml() { | ||
return function (method, caller, d) { | ||
return function (classMethod, caller, d) { | ||
var _a, _b; | ||
if ((caller && (caller === null || caller === void 0 ? void 0 : caller.kind) === "class") || ((method === null || method === void 0 ? void 0 : method.prototype) && ((_b = (_a = method === null || method === void 0 ? void 0 : method.prototype) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) === (method === null || method === void 0 ? void 0 : method.name))) { | ||
return handleClass(d, method); | ||
if ((caller && (caller === null || caller === void 0 ? void 0 : caller.kind) === "class") || ((classMethod === null || classMethod === void 0 ? void 0 : classMethod.prototype) && ((_b = (_a = classMethod === null || classMethod === void 0 ? void 0 : classMethod.prototype) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) === (classMethod === null || classMethod === void 0 ? void 0 : classMethod.name))) { | ||
return handleClass(d, classMethod); | ||
} | ||
else { | ||
return handleFn(d, method); | ||
return handleFn(d, classMethod); | ||
} | ||
@@ -37,4 +37,17 @@ }; | ||
} | ||
function isStaticMethod(_class, methodName) { | ||
return typeof methodName === 'string' && typeof _class[methodName] === 'function'; | ||
} | ||
function handleClass(d, _class) { | ||
let classes = {}; | ||
const classes = new Set(); | ||
let keys = Reflect.ownKeys(_class).filter(f => typeof f === 'string'); | ||
keys.filter(f => !defaultFn.includes(f.toString() + "") && isStaticMethod(_class, f)).forEach((k) => classes[k] = _class[k]); | ||
const simpeTest = createClass(_class); | ||
Object.keys(classes).forEach((key) => { | ||
simpeTest[key.toString()] = handleFn(undefined, simpeTest[key.toString()]); | ||
model_1._graphs.staticMethods[key.toString()] = _class.name; | ||
}); | ||
return simpeTest; | ||
} | ||
function createClass(_class) { | ||
return class extends _class { | ||
@@ -55,4 +68,7 @@ constructor(...args) { | ||
d = d || { value: method }; | ||
return d.value = function (...args) { | ||
this.name = method.name; | ||
d.value = overrideFn(originalMethod); | ||
return d.value; | ||
} | ||
function overrideFn(originalMethod) { | ||
return function (...args) { | ||
let error = new Error(); | ||
@@ -131,8 +147,12 @@ const result = _applyGraph.call(this, originalMethod, args, error); | ||
let method = classMethod[1]; | ||
let className = classMethod[0]; | ||
if (line.includes("as ")) { | ||
method = line.replace(/.*\[as (.*?)\].*/, "$1"); | ||
} | ||
return { className: classMethod[0], method: method }; | ||
if (className.includes("Function")) { | ||
className = model_1._graphs.staticMethods[method]; | ||
} | ||
return { className, method }; | ||
} | ||
} | ||
} |
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
30685
651