Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "vf-to-ubf", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Convert Voiceflow (.vf) diagram into a universal format!", | ||
@@ -5,0 +5,0 @@ "main": "voiceflowToBotFormat.js", |
@@ -13,9 +13,11 @@ # What is this? | ||
``` | ||
import {voiceflowToBotFormat} from 'vf-to-ubf'; | ||
import {voiceflowToBotFormat, voiceflowToBot} from 'vf-to-ubf'; | ||
universal_format = voiceflowToBotFormat(diagram) | ||
bot_definition = voiceflowToBot(diagram) | ||
``` | ||
Where `diagram` is your Voiceflow file. | ||
Where `diagram` is your Voiceflow file in JSON format. | ||
@@ -22,0 +24,0 @@ # Format Example |
@@ -0,1 +1,4 @@ | ||
const validate = require("./lib/validate.js") | ||
const Bot = require("./lib/Bot.js") | ||
/** | ||
@@ -73,5 +76,17 @@ * Returns all the nodes found under the root diagram id. | ||
* | ||
* @param {Object} diagram - Voiceflow diagram. | ||
* @param {Object} - Voiceflow diagram. `null` on error | ||
*/ | ||
async function voiceflowToBotFormat(diagram){ | ||
try{ | ||
if ((await validate.validateDiagram(diagram)) === false){ | ||
return null | ||
} | ||
if ((await validate.validateDiagramWithSchema(diagram)) === false){ | ||
return null | ||
} | ||
} catch (e){ | ||
return null | ||
} | ||
var botFormat = {"project": {"nodes": {}}} | ||
@@ -101,2 +116,26 @@ botFormat["project"]["name"] = diagram["project"]["name"] | ||
module.exports = {voiceflowToBotFormat} | ||
/** | ||
* Takes a Voiceflow diagram and returns it in a | ||
* Bot definition. | ||
* | ||
* @param {Object} - Initialised bot without number or id. | ||
*/ | ||
async function voiceflowToBot(diagram){ | ||
var bot = new Bot() | ||
var botDiagram = await voiceflowToBotFormat(diagram) | ||
if(botDiagram == null){ | ||
return null | ||
} | ||
bot.name = botDiagram["project"]["name"] | ||
bot.timestamp = new Date().getTime() | ||
bot.diagram = botDiagram | ||
console.log(bot) | ||
return bot | ||
} | ||
module.exports = {voiceflowToBotFormat, voiceflowToBot} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
23620
6
797
59
1