Skip to content

Commit

Permalink
Handle more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Dec 20, 2024
1 parent 5a82c75 commit 5690e8c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/common/utils/flowVisualiser/flowParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Type: **${getFlowType(flowMap)}**
Status: **${flowMap['status']}**
`;
const variables = getVariablesMd(flowMap.variables) + "\n";
const variables = getVariablesMd(flowMap.variables || []) + "\n";
const textTemplates = getTemplatesMd(flowMap.textTemplates || []) + "\n";
const mdStart = "## Flow\n\n```mermaid\n";
const nodeDefStr = await getNodeDefStr(flowMap) + "\n\n";
Expand Down Expand Up @@ -316,23 +316,25 @@ async function getNodeDefStr(flowMap: FlowMap): Promise<string> {
}

function getVariablesMd(vars: any[]): string {
let vStr = "## Variables\n\n|Name|Datatype|Collection|Input|Output|objectType|\n|:-|:-:|:-:|:-:|:-:|:-|\n";
if (!vars) vars = [];
for (const v of vars) {
vStr += "|" + v.name + "|" + v.dataType + "|" + v.isCollection + "|" + v.isInput + "|" + v.isOutput + "|" + ((v.objectType) ? v.objectType : "") + "\n";
if (vars && vars.length > 0) {
let vStr = "## Variables\n\n|Name|Datatype|Collection|Input|Output|objectType|\n|:-|:-:|:-:|:-:|:-:|:-|\n";
for (const v of vars) {
vStr += "|" + v.name + "|" + v.dataType + "|" + v.isCollection + "|" + v.isInput + "|" + v.isOutput + "|" + ((v.objectType) ? v.objectType : "") + "\n";
}
return vStr;
}
return vStr;
return "";
}

function getTemplatesMd(textTemplates: any[]): string {
if (textTemplates.length === 0) {
return "";
}
let vStr = "## Text Templates\n\n|Name|Text|\n|:-|:-|\n";
for (const v of textTemplates) {
vStr += "|" + v.name + "|" + v.text + "|\n";
if (textTemplates && textTemplates.length > 0) {
let vStr = "## Text Templates\n\n|Name|Text|\n|:-|:-|\n";
for (const v of textTemplates) {
vStr += "|" + v.name + "|" + v.text + "|\n";
}
return vStr;
}
return vStr;
return "";
}

function getMermaidClasses(): string {
Expand Down

0 comments on commit 5690e8c

Please sign in to comment.