@botmock/export
Advanced tools
Comparing version 0.7.1 to 0.8.0
@@ -72,2 +72,9 @@ "use strict"; | ||
_transformMd.set(this, (data, options) => { | ||
let LG; | ||
(function (LG) { | ||
LG["OPEN_BRACE"] = "["; | ||
LG["CLOSE_BRACE"] = "]"; | ||
LG["IF"] = "IF"; | ||
LG["ELSE_IF"] = "ELSEIF"; | ||
})(LG || (LG = {})); | ||
let MD; | ||
@@ -86,2 +93,19 @@ (function (MD) { | ||
} | ||
else if (values.hasOwnProperty("brace")) { | ||
const [firstKey] = Object.keys(values.brace); | ||
values = `${LG.OPEN_BRACE}${firstKey}\n\tAttachments = \${${values[firstKey]}()}${LG.CLOSE_BRACE}${os_1.EOL}`; | ||
} | ||
else if (values.hasOwnProperty("conditions")) { | ||
values = values.conditions.reduce((str, conditionTuple, i) => { | ||
let conditionType; | ||
if (i === 0) { | ||
conditionType = LG.IF; | ||
} | ||
else { | ||
conditionType = LG.ELSE_IF; | ||
} | ||
const [condition, response] = conditionTuple; | ||
return `${str}- ${conditionType}: ${condition}${os_1.EOL}\t- ${response}${os_1.EOL}`; | ||
}, ""); | ||
} | ||
else { | ||
@@ -88,0 +112,0 @@ const keys = Object.keys(values); |
{ | ||
"name": "@botmock/export", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "", | ||
@@ -49,3 +49,3 @@ "contributors": [ | ||
"devDependencies": { | ||
"@types/jest": "25.2.3", | ||
"@types/jest": "26.0.3", | ||
"jest": "26.1.0", | ||
@@ -52,0 +52,0 @@ "pascal-case": "3.1.1", |
@@ -139,3 +139,9 @@ import { stringify } from "yaml"; | ||
*/ | ||
#transformMd = <T = LowLevelAsset<any>["data"]>(data: T, options?: { shouldUseH1: boolean; }): string => { | ||
#transformMd = <T = LowLevelAsset<any>["data"]>(data: T, options?: { shouldUseH1?: boolean; }): string => { | ||
enum LG { | ||
OPEN_BRACE = "[", | ||
CLOSE_BRACE = "]", | ||
IF = "IF", | ||
ELSE_IF = "ELSEIF", | ||
} | ||
enum MD { | ||
@@ -149,5 +155,21 @@ H1 = "#", | ||
return Object.keys(object).reduce((str, key) => { | ||
let values: unknown = object[key]; | ||
let values: any = object[key]; | ||
if (Array.isArray(values)) { | ||
values = values.map(value => ` ${MD.L2} ${value}`).join(EOL); | ||
} else if (values.hasOwnProperty("brace")) { | ||
const [firstKey] = Object.keys(values.brace); | ||
values = `${LG.OPEN_BRACE}${firstKey}\n\tAttachments = \${${values[firstKey]}()}${LG.CLOSE_BRACE}${EOL}`; | ||
} else if (values.hasOwnProperty("conditions")) { | ||
// @ts-ignore | ||
values = values.conditions.reduce((str: string, conditionTuple: [string, string], i) => { | ||
let conditionType: LG; | ||
if (i === 0) { | ||
conditionType = LG.IF; | ||
} else { | ||
conditionType = LG.ELSE_IF; | ||
} | ||
const [condition, response] = conditionTuple; | ||
return `${str}- ${conditionType}: ${condition}${EOL}\t- ${response}${EOL}`; | ||
}, ""); | ||
} else { | ||
@@ -169,2 +191,5 @@ const keys = Object.keys(values as object); | ||
#transformLg = <T = LowLevelAsset<any>["data"]>(data: T): string => { | ||
// const braces = Object.keys(data).reduce((dataset, key) => { | ||
// return {} | ||
// }, {}) | ||
const raw = this.#transformMd(data, { shouldUseH1: true }); | ||
@@ -171,0 +196,0 @@ return raw; |
Sorry, the diff of this file is not supported yet
346908
6363