@botmock/export
Advanced tools
Comparing version 0.10.1 to 0.11.0
@@ -11,4 +11,5 @@ import { Client } from "@botmock/client"; | ||
constructor(config: Config); | ||
protected replaceEntityCharacters: (input: string, left?: string, right?: string) => string; | ||
abstract dataTransformations: DataTransformations<any>; | ||
exportProjectUnderDataTransformations(reference: ExportReference): Promise<Output<LowLevelAsset<any>, D>>; | ||
} |
@@ -15,2 +15,20 @@ "use strict"; | ||
this.config = config; | ||
this.replaceEntityCharacters = (input, left = "{", right = "}") => { | ||
const processedInput = input.split(""); | ||
let numCaptured = 0; | ||
let i = 0; | ||
for (const char of processedInput) { | ||
if (char === "%") { | ||
if (numCaptured % 2 === 0) { | ||
processedInput[i] = left; | ||
} | ||
else { | ||
processedInput[i] = right; | ||
} | ||
numCaptured += 1; | ||
} | ||
i += 1; | ||
} | ||
return processedInput.join(""); | ||
}; | ||
_multiChannelProjectName.set(this, "multi-channel"); | ||
@@ -17,0 +35,0 @@ _getResources.set(this, async (projectReference) => { |
@@ -1,2 +0,2 @@ | ||
import { DataTransformation } from "../types"; | ||
import { Resources, DataTransformation } from "../types"; | ||
import BaseExporter from '../base-exporter'; | ||
@@ -8,4 +8,4 @@ declare enum Dirpaths { | ||
#private; | ||
dataTransformations: Map<Dirpaths, (resources: import("@botmock/client").JSONResponse<any>) => DataTransformation<any>>; | ||
dataTransformations: Map<Dirpaths, (resources: Resources) => DataTransformation>; | ||
} | ||
export {}; |
@@ -11,4 +11,5 @@ "use strict"; | ||
}; | ||
var _adaptiveCardJSONMap, _schemaMap, _replaceHyphenWithUnderscore, _createSchemaForContent, _replaceEntityCharacters, _createTemplatesFromProjectResourcesAndSchemaAssociations, _generateSchemaAssociations, _rootTransformation; | ||
var _adaptiveCardJSONMap, _schemaMap, _replaceHyphenWithUnderscore, _createSchemaForContent, _createTemplatesFromProjectResourcesAndSchemaAssociations, _generateSchemaAssociations, _rootTransformation; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BotFrameworkExporter = void 0; | ||
const types_1 = require("../types"); | ||
@@ -58,20 +59,2 @@ const uuid_1 = require("uuid"); | ||
}); | ||
_replaceEntityCharacters.set(this, (input) => { | ||
const processedInput = input.split(""); | ||
let numCaptured = 0; | ||
let i = 0; | ||
for (const char of processedInput) { | ||
if (char === "%") { | ||
if (numCaptured % 2 === 0) { | ||
processedInput[i] = "${"; | ||
} | ||
else { | ||
processedInput[i] = "}"; | ||
} | ||
numCaptured += 1; | ||
} | ||
i += 1; | ||
} | ||
return processedInput.join(""); | ||
}); | ||
_createTemplatesFromProjectResourcesAndSchemaAssociations.set(this, (resources, schemaAssociations) => { | ||
@@ -82,3 +65,3 @@ const unwrapValuesFromPayload = (payload) => { | ||
.filter(input => typeof input === "string") | ||
.map(input => __classPrivateFieldGet(this, _replaceEntityCharacters).call(this, input))))); | ||
.map(input => this.replaceEntityCharacters(input, "${"))))); | ||
}; | ||
@@ -144,3 +127,3 @@ return resources.board.board.messages.reduce((obj, message) => { | ||
exports.BotFrameworkExporter = BotFrameworkExporter; | ||
_adaptiveCardJSONMap = new WeakMap(), _schemaMap = new WeakMap(), _replaceHyphenWithUnderscore = new WeakMap(), _createSchemaForContent = new WeakMap(), _replaceEntityCharacters = new WeakMap(), _createTemplatesFromProjectResourcesAndSchemaAssociations = new WeakMap(), _generateSchemaAssociations = new WeakMap(), _rootTransformation = new WeakMap(); | ||
_adaptiveCardJSONMap = new WeakMap(), _schemaMap = new WeakMap(), _replaceHyphenWithUnderscore = new WeakMap(), _createSchemaForContent = new WeakMap(), _createTemplatesFromProjectResourcesAndSchemaAssociations = new WeakMap(), _generateSchemaAssociations = new WeakMap(), _rootTransformation = new WeakMap(); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dsn = void 0; | ||
exports.dsn = "https://c68c3811fed847f79754c59baea69430@o405248.ingest.sentry.io/5270570"; | ||
//# sourceMappingURL=index.js.map |
import BaseExporter from '../base-exporter'; | ||
import { DataTransformation } from "../types"; | ||
import { Resources, DataTransformation } from "../types"; | ||
declare enum Dirpaths { | ||
@@ -11,4 +11,4 @@ ROOT = "./", | ||
protected generateInputContexts(responseBlockId: string): IterableIterator<string | void>; | ||
dataTransformations: Map<Dirpaths, (resources: import("@botmock/client").JSONResponse<any>) => DataTransformation<any>>; | ||
dataTransformations: Map<Dirpaths, (resources: Resources) => DataTransformation>; | ||
} | ||
export {}; |
@@ -20,2 +20,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DialogflowExporter = void 0; | ||
const assert_1 = require("assert"); | ||
@@ -22,0 +23,0 @@ const uuid_1 = require("uuid"); |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -16,13 +28,13 @@ const Sentry = __importStar(require("@sentry/node")); | ||
Sentry.init({ dsn: constants_1.dsn }); | ||
__export(require("./types")); | ||
__export(require("./write")); | ||
__export(require("./bot-framework")); | ||
__export(require("./dialogflow")); | ||
__export(require("./luis")); | ||
__export(require("./lex")); | ||
__export(require("./skills-kit")); | ||
__export(require("./watson")); | ||
__export(require("./rasa")); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./write"), exports); | ||
__exportStar(require("./bot-framework"), exports); | ||
__exportStar(require("./dialogflow"), exports); | ||
__exportStar(require("./luis"), exports); | ||
__exportStar(require("./lex"), exports); | ||
__exportStar(require("./skills-kit"), exports); | ||
__exportStar(require("./watson"), exports); | ||
__exportStar(require("./rasa"), exports); | ||
var base_exporter_1 = require("./base-exporter"); | ||
exports.BaseExporter = base_exporter_1.default; | ||
Object.defineProperty(exports, "BaseExporter", { enumerable: true, get: function () { return base_exporter_1.default; } }); | ||
//# sourceMappingURL=index.js.map |
import Exporter from '../base-exporter'; | ||
import { DataTransformation } from "../types"; | ||
import { DataTransformation, Resources } from "../types"; | ||
declare enum Dirpaths { | ||
@@ -8,4 +8,4 @@ ROOT = "./" | ||
#private; | ||
dataTransformations: Map<Dirpaths, (resources: import("@botmock/client").JSONResponse<any>) => DataTransformation<any>>; | ||
dataTransformations: Map<Dirpaths, (resources: Resources) => DataTransformation>; | ||
} | ||
export {}; |
@@ -20,2 +20,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LexExporter = void 0; | ||
const uuid_1 = require("uuid"); | ||
@@ -22,0 +23,0 @@ const base_exporter_1 = __importDefault(require("../base-exporter")); |
import Exporter from '../base-exporter'; | ||
import { DataTransformation } from "../types"; | ||
import { Resources, DataTransformation } from "../types"; | ||
declare enum Dirpaths { | ||
@@ -8,4 +8,4 @@ ROOT = "./" | ||
#private; | ||
dataTransformations: Map<Dirpaths, (resources: import("@botmock/client").JSONResponse<any>) => DataTransformation<any>>; | ||
dataTransformations: Map<Dirpaths, (resources: Resources) => DataTransformation>; | ||
} | ||
export {}; |
@@ -13,2 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LuisExporter = void 0; | ||
const base_exporter_1 = __importDefault(require("../base-exporter")); | ||
@@ -15,0 +16,0 @@ var Dirpaths; |
import Exporter from '../base-exporter'; | ||
import { Botmock, DataTransformation } from "../types"; | ||
import { Botmock, Resources, DataTransformation } from "../types"; | ||
declare enum Dirpaths { | ||
@@ -7,8 +7,8 @@ ROOT = "./", | ||
} | ||
export declare class RasaExporter<D> extends Exporter<D> { | ||
export declare class RasaExporter extends Exporter { | ||
#private; | ||
protected representRequirementsForIntents(intents: Botmock.Intent[]): Map<string, Botmock.Slot>; | ||
private representRequiredSlots; | ||
dataTransformations: Map<Dirpaths, (resources: import("@botmock/client").JSONResponse<any>) => DataTransformation<any>>; | ||
dataTransformations: Map<Dirpaths, (resources: Resources) => DataTransformation>; | ||
} | ||
export {}; |
@@ -17,4 +17,4 @@ "use strict"; | ||
}; | ||
var _generateStories, _generateIntentGroupings, _unpackTemplatesInBlock, _dataTransformation, _rootTransformation; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RasaExporter = void 0; | ||
const base_exporter_1 = __importDefault(require("../base-exporter")); | ||
@@ -29,146 +29,149 @@ const types_1 = require("../types"); | ||
})(Dirpaths || (Dirpaths = {})); | ||
let RasaExporter = class RasaExporter extends base_exporter_1.default { | ||
constructor() { | ||
super(...arguments); | ||
_generateStories.set(this, (intents, blocks) => { | ||
return [ | ||
{ | ||
[`path_${uuid_1.v4()}`]: intents.reduce((intentList, intent) => { | ||
var _a, _b; | ||
const idOfBlockConnectedToIntent = (_a = blocks | ||
.flatMap(block => block.next_message_ids) | ||
.find(next => next.intent.value === intent.id)) === null || _a === void 0 ? void 0 : _a.message_id; | ||
if (!idOfBlockConnectedToIntent) { | ||
return intentList; | ||
} | ||
const nodeName = (_b = blocks.find(block => block.message_id === idOfBlockConnectedToIntent)) === null || _b === void 0 ? void 0 : _b.node_name; | ||
return Object.assign(Object.assign({}, intentList), { [intent.name]: [`utter_${nodeName === null || nodeName === void 0 ? void 0 : nodeName.toLowerCase().replace(/\s/g, "_")}`] }); | ||
}, {}) | ||
} | ||
]; | ||
}); | ||
_generateIntentGroupings.set(this, (intents) => { | ||
return intents.reduce((structure, intent) => { | ||
const intentName = `intent:${intent.name}`; | ||
const utterancesUnderIntent = Object | ||
.values(intent.utterances) | ||
.reduce((utterances, value) => { | ||
return [...utterances, ...value.map(v => v.text)]; | ||
}, []); | ||
return Object.assign(Object.assign({}, structure), { [intentName]: utterancesUnderIntent }); | ||
let RasaExporter = (() => { | ||
var _generateStories, _generateIntentGroupings, _unpackTemplatesInBlock, _dataTransformation, _rootTransformation; | ||
let RasaExporter = class RasaExporter extends base_exporter_1.default { | ||
constructor() { | ||
super(...arguments); | ||
_generateStories.set(this, (intents, blocks) => { | ||
return [ | ||
{ | ||
[`path_${uuid_1.v4()}`]: intents.reduce((intentList, intent) => { | ||
var _a, _b; | ||
const idOfBlockConnectedToIntent = (_a = blocks | ||
.flatMap(block => block.next_message_ids) | ||
.find(next => next.intent.value === intent.id)) === null || _a === void 0 ? void 0 : _a.message_id; | ||
if (!idOfBlockConnectedToIntent) { | ||
return intentList; | ||
} | ||
const nodeName = (_b = blocks.find(block => block.message_id === idOfBlockConnectedToIntent)) === null || _b === void 0 ? void 0 : _b.node_name; | ||
return Object.assign(Object.assign({}, intentList), { [intent.name]: [`utter_${nodeName === null || nodeName === void 0 ? void 0 : nodeName.toLowerCase().replace(/\s/g, "_")}`] }); | ||
}, {}) | ||
} | ||
]; | ||
}); | ||
_generateIntentGroupings.set(this, (intents) => { | ||
return intents.reduce((structure, intent) => { | ||
const intentName = `intent:${intent.name}`; | ||
const utterancesUnderIntent = Object | ||
.values(intent.utterances) | ||
.reduce((utterances, value) => { | ||
return [...utterances, ...value.map(v => v.text)]; | ||
}, []); | ||
return Object.assign(Object.assign({}, structure), { [intentName]: utterancesUnderIntent }); | ||
}, {}); | ||
}); | ||
_unpackTemplatesInBlock.set(this, (block) => { | ||
const platformsPerLang = Object.values(block.payload); | ||
const unionOfAllResponses = Object.values(platformsPerLang) | ||
.flatMap(group => Object.values(group).flatMap(data => data.blocks)) | ||
.filter(block => typeof block !== "undefined") | ||
.reduce((responses, response) => { | ||
var _a, _b; | ||
let key = ""; | ||
let value = ""; | ||
switch (response.component_type) { | ||
case types_1.Botmock.Component.text: | ||
[key, value] = [types_1.Rasa.TemplateTypes.TEXT, this.replaceEntityCharacters(response.text)]; | ||
break; | ||
case types_1.Botmock.Component.image: | ||
[key, value] = [types_1.Rasa.TemplateTypes.IMAGE, response.image_url]; | ||
break; | ||
case types_1.Botmock.Component.button: | ||
[key, value] = [ | ||
types_1.Rasa.TemplateTypes.BUTTONS, | ||
(_a = response.buttons) === null || _a === void 0 ? void 0 : _a.map(button => ({ | ||
title: button.title, | ||
payload: button.title.trim(), | ||
})), | ||
]; | ||
break; | ||
case types_1.Botmock.Component.quick_replies: | ||
[key, value] = [ | ||
types_1.Rasa.TemplateTypes.BUTTONS, | ||
(_b = response.quick_replies) === null || _b === void 0 ? void 0 : _b.map(reply => ({ | ||
title: reply.title, | ||
payload: reply.title.trim(), | ||
})), | ||
]; | ||
break; | ||
default: | ||
[key, value] = [types_1.Rasa.TemplateTypes.TEXT, response.nodeName]; | ||
break; | ||
} | ||
return Object.assign(Object.assign({}, responses), { [key]: value }); | ||
}, {}); | ||
return unionOfAllResponses; | ||
}); | ||
_dataTransformation.set(this, (resources) => { | ||
return { | ||
filenames: ["nlu.md", "stories.md"], | ||
data: [ | ||
__classPrivateFieldGet(this, _generateIntentGroupings).call(this, resources.intents), | ||
__classPrivateFieldGet(this, _generateStories).call(this, resources.intents, resources.board.board.messages), | ||
], | ||
}; | ||
}); | ||
_rootTransformation.set(this, (resources) => { | ||
const templates = resources.board.board.messages | ||
.reduce((templatesForActions, block) => { | ||
if (block.is_root) { | ||
return templatesForActions; | ||
} | ||
else if (typeof block.node_name === "undefined") { | ||
return templatesForActions; | ||
} | ||
const templates = __classPrivateFieldGet(this, _unpackTemplatesInBlock).call(this, block); | ||
if (Object.keys(templates).length <= 0) { | ||
return templatesForActions; | ||
} | ||
return Object.assign(Object.assign({}, templatesForActions), { [`utter_${block.message_id}`]: templates }); | ||
}, {}); | ||
return { | ||
filename: "domain.yml", | ||
data: { | ||
intents: resources.intents.map(intent => intent.name), | ||
actions: Object.keys(templates), | ||
entities: resources.variables.map(variable => variable.name.replace(/\s/, "")), | ||
slots: this.representRequiredSlots(resources.intents, resources.variables), | ||
templates, | ||
}, | ||
}; | ||
}); | ||
this.dataTransformations = new Map([ | ||
[Dirpaths.ROOT, __classPrivateFieldGet(this, _rootTransformation)], | ||
[Dirpaths.DATA, __classPrivateFieldGet(this, _dataTransformation)], | ||
]); | ||
} | ||
representRequirementsForIntents(intents) { | ||
return new Map(intents.reduce((acc, intent) => { | ||
const requiredSlots = (intent.slots || []).filter(slot => slot.is_required); | ||
return [ | ||
...acc, | ||
[intent.id, requiredSlots] | ||
]; | ||
}, [])); | ||
} | ||
representRequiredSlots(intents, variables) { | ||
const uniqueNamesOfRequiredSlots = Array.from(this.representRequirementsForIntents(intents)) | ||
.reduce((acc, pair) => { | ||
const [, requiredSlots] = pair; | ||
return Object.assign(Object.assign({}, acc), requiredSlots.reduce((accu, slot) => { | ||
const variable = variables.find((variable) => variable.id === slot.variable_id); | ||
if (!variable) { | ||
return accu; | ||
} | ||
return Object.assign(Object.assign({}, accu), { [variable.name]: variable.default_value || void 0 }); | ||
}, {})); | ||
}, {}); | ||
}); | ||
_unpackTemplatesInBlock.set(this, (block) => { | ||
const platformsPerLang = Object.values(block.payload); | ||
const unionOfAllResponses = Object.values(platformsPerLang) | ||
.flatMap(group => Object.values(group).flatMap(data => data.blocks)) | ||
.filter(block => typeof block !== "undefined") | ||
.reduce((responses, response) => { | ||
var _a, _b; | ||
let key = ""; | ||
let value = ""; | ||
switch (response.component_type) { | ||
case types_1.Botmock.Component.text: | ||
[key, value] = [types_1.Rasa.TemplateTypes.TEXT, response.text]; | ||
break; | ||
case types_1.Botmock.Component.image: | ||
[key, value] = [types_1.Rasa.TemplateTypes.IMAGE, response.image_url]; | ||
break; | ||
case types_1.Botmock.Component.button: | ||
[key, value] = [ | ||
types_1.Rasa.TemplateTypes.BUTTONS, | ||
(_a = response.buttons) === null || _a === void 0 ? void 0 : _a.map(button => ({ | ||
title: button.title, | ||
payload: button.title.trim(), | ||
})), | ||
]; | ||
break; | ||
case types_1.Botmock.Component.quick_replies: | ||
[key, value] = [ | ||
types_1.Rasa.TemplateTypes.BUTTONS, | ||
(_b = response.quick_replies) === null || _b === void 0 ? void 0 : _b.map(reply => ({ | ||
title: reply.title, | ||
payload: reply.title.trim(), | ||
})), | ||
]; | ||
break; | ||
default: | ||
[key, value] = [types_1.Rasa.TemplateTypes.TEXT, response.nodeName]; | ||
break; | ||
} | ||
return Object.assign(Object.assign({}, responses), { [key]: value }); | ||
}, {}); | ||
return unionOfAllResponses; | ||
}); | ||
_dataTransformation.set(this, (resources) => { | ||
return { | ||
filenames: ["nlu.md", "stories.md"], | ||
data: [ | ||
__classPrivateFieldGet(this, _generateIntentGroupings).call(this, resources.intents), | ||
__classPrivateFieldGet(this, _generateStories).call(this, resources.intents, resources.board.board.messages), | ||
], | ||
}; | ||
}); | ||
_rootTransformation.set(this, (resources) => { | ||
const templates = resources.board.board.messages | ||
.reduce((templatesForActions, block) => { | ||
if (block.is_root) { | ||
return templatesForActions; | ||
} | ||
const templates = __classPrivateFieldGet(this, _unpackTemplatesInBlock).call(this, block); | ||
if (Object.keys(templates).length <= 0) { | ||
return templatesForActions; | ||
} | ||
if (typeof block.node_name === "undefined") { | ||
return templatesForActions; | ||
} | ||
const actionName = `utter_${block.node_name.toLowerCase().replace(/\s/g, "_")}`; | ||
return Object.assign(Object.assign({}, templatesForActions), { [actionName]: templates }); | ||
}, {}); | ||
return { | ||
filename: "domain.yml", | ||
data: { | ||
intents: resources.intents.map(intent => intent.name), | ||
actions: Object.keys(templates), | ||
entities: resources.variables.map(variable => variable.name.replace(/\s/, "")), | ||
slots: this.representRequiredSlots(resources.intents, resources.variables), | ||
templates, | ||
}, | ||
}; | ||
}); | ||
this.dataTransformations = new Map([ | ||
[Dirpaths.ROOT, __classPrivateFieldGet(this, _rootTransformation)], | ||
[Dirpaths.DATA, __classPrivateFieldGet(this, _dataTransformation)], | ||
]); | ||
} | ||
representRequirementsForIntents(intents) { | ||
return new Map(intents.reduce((acc, intent) => { | ||
const requiredSlots = (intent.slots || []).filter(slot => slot.is_required); | ||
return [ | ||
...acc, | ||
[intent.id, requiredSlots] | ||
]; | ||
}, [])); | ||
} | ||
representRequiredSlots(intents, variables) { | ||
const uniqueNamesOfRequiredSlots = Array.from(this.representRequirementsForIntents(intents)) | ||
.reduce((acc, pair) => { | ||
const [, requiredSlots] = pair; | ||
return Object.assign(Object.assign({}, acc), requiredSlots.reduce((accu, slot) => { | ||
const variable = variables.find((variable) => variable.id === slot.variable_id); | ||
if (!variable) { | ||
return accu; | ||
} | ||
return Object.assign(Object.assign({}, accu), { [variable.name]: variable.default_value || void 0 }); | ||
}, {})); | ||
}, {}); | ||
return Object.entries(uniqueNamesOfRequiredSlots) | ||
.map(([slotName, defaultValue]) => ({ [slotName]: { type: 'text', initial_value: defaultValue } })); | ||
} | ||
}; | ||
_generateStories = new WeakMap(), _generateIntentGroupings = new WeakMap(), _unpackTemplatesInBlock = new WeakMap(), _dataTransformation = new WeakMap(), _rootTransformation = new WeakMap(); | ||
RasaExporter = __decorate([ | ||
util_1.sealed | ||
], RasaExporter); | ||
return Object.entries(uniqueNamesOfRequiredSlots) | ||
.map(([slotName, defaultValue]) => ({ [slotName]: { type: 'text', initial_value: defaultValue } })); | ||
} | ||
}; | ||
_generateStories = new WeakMap(), _generateIntentGroupings = new WeakMap(), _unpackTemplatesInBlock = new WeakMap(), _dataTransformation = new WeakMap(), _rootTransformation = new WeakMap(); | ||
RasaExporter = __decorate([ | ||
util_1.sealed | ||
], RasaExporter); | ||
return RasaExporter; | ||
})(); | ||
exports.RasaExporter = RasaExporter; | ||
//# sourceMappingURL=index.js.map |
import Exporter from '../base-exporter'; | ||
import { DataTransformation } from "../types"; | ||
import { Resources, DataTransformation } from "../types"; | ||
declare enum Dirpaths { | ||
@@ -8,4 +8,4 @@ ROOT = "./" | ||
#private; | ||
dataTransformations: Map<Dirpaths, (resources: import("@botmock/client").JSONResponse<any>) => DataTransformation<any>>; | ||
dataTransformations: Map<Dirpaths, (resources: Resources) => DataTransformation>; | ||
} | ||
export {}; |
@@ -20,2 +20,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SkillsKitExporter = void 0; | ||
const uuid_1 = require("uuid"); | ||
@@ -22,0 +23,0 @@ const base_exporter_1 = __importDefault(require("../base-exporter")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BodyTypes = void 0; | ||
var BodyTypes; | ||
@@ -4,0 +5,0 @@ (function (BodyTypes) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DataTypes = exports.SystemEntity = exports.Event = void 0; | ||
var Event; | ||
@@ -4,0 +5,0 @@ (function (Event) { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Botmock = exports.Platform = exports.Kind = exports.Dirname = exports.Ext = void 0; | ||
exports.BotFramework = __importStar(require("./bot-framework")); | ||
@@ -11,0 +24,0 @@ exports.Dialogflow = __importStar(require("./dialogflow")); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SystemEntities = exports.FulfillmentActivityTypes = exports.ValueSelectionStrategies = exports.SlotConstraints = exports.ObfuscationSettings = exports.ContentTypes = void 0; | ||
var ContentTypes; | ||
@@ -4,0 +5,0 @@ (function (ContentTypes) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TemplateTypes = void 0; | ||
var TemplateTypes; | ||
@@ -4,0 +5,0 @@ (function (TemplateTypes) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VariationTypes = exports.DelegationStrategies = void 0; | ||
var DelegationStrategies; | ||
@@ -4,0 +5,0 @@ (function (DelegationStrategies) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SystemEntity = exports.EntityValueType = exports.Response = exports.Platform = exports.Type = void 0; | ||
var Type; | ||
@@ -4,0 +5,0 @@ (function (Type) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.wrapEntitiesWithChar = exports.sealed = void 0; | ||
function sealed(construct) { | ||
@@ -4,0 +5,0 @@ Object.seal(construct); |
import Exporter from '../base-exporter'; | ||
import { DataTransformation } from "../types"; | ||
import { Resources, DataTransformation } from "../types"; | ||
declare enum Dirpaths { | ||
@@ -8,4 +8,4 @@ ROOT = "./" | ||
#private; | ||
dataTransformations: Map<Dirpaths, (resources: import("@botmock/client").JSONResponse<any>) => DataTransformation<any>>; | ||
dataTransformations: Map<Dirpaths, (resources: Resources) => DataTransformation>; | ||
} | ||
export {}; |
@@ -24,4 +24,4 @@ "use strict"; | ||
}; | ||
var _intents, _blockMap, _entityMap, _findConditionsOfBlockId, _transformOutputStructure, _generateDialogNodes, _generateEntities, _generateIntents, _rootTransformation; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WatsonExporter = void 0; | ||
const base_exporter_1 = __importDefault(require("../base-exporter")); | ||
@@ -34,191 +34,195 @@ const types_1 = require("../types"); | ||
})(Dirpaths || (Dirpaths = {})); | ||
let WatsonExporter = class WatsonExporter extends base_exporter_1.default { | ||
constructor() { | ||
super(...arguments); | ||
_intents.set(this, void 0); | ||
_blockMap.set(this, new Map([ | ||
[types_1.Botmock.Component.text, types_1.Watson.Response.TEXT], | ||
[types_1.Botmock.Component.button, types_1.Watson.Response.OPTION], | ||
[types_1.Botmock.Component.quick_replies, types_1.Watson.Response.OPTION], | ||
[types_1.Botmock.Component.image, types_1.Watson.Response.IMAGE], | ||
])); | ||
_entityMap.set(this, new Map([ | ||
[types_1.Botmock.SystemEntity.NUMBER, types_1.Watson.SystemEntity.NUMBER], | ||
[types_1.Botmock.SystemEntity.ORDINAL, types_1.Watson.SystemEntity.PERCENTAGE], | ||
[types_1.Botmock.SystemEntity.CURRENCY, types_1.Watson.SystemEntity.CURRENCY], | ||
[types_1.Botmock.SystemEntity.DATE, types_1.Watson.SystemEntity.DATE], | ||
[types_1.Botmock.SystemEntity.DURATION, types_1.Watson.SystemEntity.TIME], | ||
[types_1.Botmock.SystemEntity.COUNTRY, types_1.Watson.SystemEntity.LOCATION], | ||
[types_1.Botmock.SystemEntity.NAME, types_1.Watson.SystemEntity.PERSON], | ||
])); | ||
_findConditionsOfBlockId.set(this, (id, blocks) => { | ||
var _a; | ||
const [intentId] = blocks | ||
.flatMap(block => block.next_message_ids.filter(next => next.message_id === id)) | ||
.filter(next => next.intent.value) | ||
.map(next => next.intent.value); | ||
return (_a = __classPrivateFieldGet(this, _intents).find(intent => intent.id === intentId)) === null || _a === void 0 ? void 0 : _a.name; | ||
}); | ||
_transformOutputStructure.set(this, (block) => { | ||
var _a, _b, _c, _d; | ||
const content = {}; | ||
switch (block.component_type) { | ||
case types_1.Botmock.Component.text: | ||
content.response_type = types_1.Watson.Response.TEXT; | ||
content.values = [ | ||
block.text, | ||
...((_a = block.alternate_replies) !== null && _a !== void 0 ? _a : []) | ||
].map(text => ({ text: text })); | ||
break; | ||
case types_1.Botmock.Component.quick_replies: | ||
case types_1.Botmock.Component.button: | ||
content.title = (_b = block.text) !== null && _b !== void 0 ? _b : ""; | ||
content.response_type = types_1.Watson.Response.OPTION; | ||
content.options = (_d = ((_c = block.buttons) !== null && _c !== void 0 ? _c : block.quick_replies)) === null || _d === void 0 ? void 0 : _d.map(button => ({ | ||
label: button.title, | ||
value: { | ||
input: { | ||
text: button.title, | ||
let WatsonExporter = (() => { | ||
var _intents, _blockMap, _entityMap, _findConditionsOfBlockId, _transformOutputStructure, _generateDialogNodes, _generateEntities, _generateIntents, _rootTransformation; | ||
let WatsonExporter = class WatsonExporter extends base_exporter_1.default { | ||
constructor() { | ||
super(...arguments); | ||
_intents.set(this, void 0); | ||
_blockMap.set(this, new Map([ | ||
[types_1.Botmock.Component.text, types_1.Watson.Response.TEXT], | ||
[types_1.Botmock.Component.button, types_1.Watson.Response.OPTION], | ||
[types_1.Botmock.Component.quick_replies, types_1.Watson.Response.OPTION], | ||
[types_1.Botmock.Component.image, types_1.Watson.Response.IMAGE], | ||
])); | ||
_entityMap.set(this, new Map([ | ||
[types_1.Botmock.SystemEntity.NUMBER, types_1.Watson.SystemEntity.NUMBER], | ||
[types_1.Botmock.SystemEntity.ORDINAL, types_1.Watson.SystemEntity.PERCENTAGE], | ||
[types_1.Botmock.SystemEntity.CURRENCY, types_1.Watson.SystemEntity.CURRENCY], | ||
[types_1.Botmock.SystemEntity.DATE, types_1.Watson.SystemEntity.DATE], | ||
[types_1.Botmock.SystemEntity.DURATION, types_1.Watson.SystemEntity.TIME], | ||
[types_1.Botmock.SystemEntity.COUNTRY, types_1.Watson.SystemEntity.LOCATION], | ||
[types_1.Botmock.SystemEntity.NAME, types_1.Watson.SystemEntity.PERSON], | ||
])); | ||
_findConditionsOfBlockId.set(this, (id, blocks) => { | ||
var _a; | ||
const [intentId] = blocks | ||
.flatMap(block => block.next_message_ids.filter(next => next.message_id === id)) | ||
.filter(next => next.intent.value) | ||
.map(next => next.intent.value); | ||
return (_a = __classPrivateFieldGet(this, _intents).find(intent => intent.id === intentId)) === null || _a === void 0 ? void 0 : _a.name; | ||
}); | ||
_transformOutputStructure.set(this, (block) => { | ||
var _a, _b, _c, _d; | ||
const content = {}; | ||
switch (block.component_type) { | ||
case types_1.Botmock.Component.text: | ||
content.response_type = types_1.Watson.Response.TEXT; | ||
content.values = [ | ||
block.text, | ||
...((_a = block.alternate_replies) !== null && _a !== void 0 ? _a : []) | ||
].map(text => ({ text: text })); | ||
break; | ||
case types_1.Botmock.Component.quick_replies: | ||
case types_1.Botmock.Component.button: | ||
content.title = (_b = block.text) !== null && _b !== void 0 ? _b : ""; | ||
content.response_type = types_1.Watson.Response.OPTION; | ||
content.options = (_d = ((_c = block.buttons) !== null && _c !== void 0 ? _c : block.quick_replies)) === null || _d === void 0 ? void 0 : _d.map(button => ({ | ||
label: button.title, | ||
value: { | ||
input: { | ||
text: button.title, | ||
} | ||
} | ||
})); | ||
break; | ||
case types_1.Botmock.Component.image: | ||
content.title = block.title; | ||
content.source = block.image_url; | ||
content.description = block.title; | ||
content.response_type = types_1.Watson.Response.IMAGE; | ||
break; | ||
} | ||
return content; | ||
}); | ||
_generateDialogNodes.set(this, (projectBlocks) => { | ||
return projectBlocks.reduce((outerDialogNodes, outerBlock) => { | ||
const unionOfBlockContent = Object | ||
.values(outerBlock.payload) | ||
.reduce((dialogNodes, block) => { | ||
var _a, _b, _c; | ||
const isInvalid = Array.isArray(block) || Object.values(block).every(value => typeof value === "string"); | ||
if (isInvalid) { | ||
return dialogNodes; | ||
} | ||
})); | ||
break; | ||
case types_1.Botmock.Component.image: | ||
content.title = block.title; | ||
content.source = block.image_url; | ||
content.description = block.title; | ||
content.response_type = types_1.Watson.Response.IMAGE; | ||
break; | ||
} | ||
return content; | ||
}); | ||
_generateDialogNodes.set(this, (projectBlocks) => { | ||
return projectBlocks.reduce((outerDialogNodes, outerBlock) => { | ||
const unionOfBlockContent = Object | ||
.values(outerBlock.payload) | ||
.reduce((dialogNodes, block) => { | ||
var _a, _b, _c; | ||
const isInvalid = Array.isArray(block) || Object.values(block).every(value => typeof value === "string"); | ||
if (isInvalid) { | ||
return dialogNodes; | ||
} | ||
const unionOfGenericBlocks = block.generic.blocks | ||
.filter(block => __classPrivateFieldGet(this, _blockMap).get(block.component_type)) | ||
.map(innerBlock => __classPrivateFieldGet(this, _transformOutputStructure).call(this, innerBlock)); | ||
if (unionOfGenericBlocks.length <= 0) { | ||
return dialogNodes; | ||
} | ||
const parent = (_a = projectBlocks | ||
.filter(block => !block.is_root) | ||
.find(block => block.next_message_ids.map(next => next.message_id).includes(outerBlock.message_id))) === null || _a === void 0 ? void 0 : _a.message_id; | ||
let previousSibling; | ||
const nodeWithSameParent = (_b = outerDialogNodes.find(node => node.parent === parent)) === null || _b === void 0 ? void 0 : _b.dialog_node; | ||
if (parent && nodeWithSameParent) { | ||
previousSibling = nodeWithSameParent; | ||
} | ||
const unionOfGenericBlocks = block.generic.blocks | ||
.filter(block => __classPrivateFieldGet(this, _blockMap).get(block.component_type)) | ||
.map(innerBlock => __classPrivateFieldGet(this, _transformOutputStructure).call(this, innerBlock)); | ||
if (unionOfGenericBlocks.length <= 0) { | ||
return dialogNodes; | ||
} | ||
const parent = (_a = projectBlocks | ||
.filter(block => !block.is_root) | ||
.find(block => block.next_message_ids.map(next => next.message_id).includes(outerBlock.message_id))) === null || _a === void 0 ? void 0 : _a.message_id; | ||
let previousSibling; | ||
const nodeWithSameParent = (_b = outerDialogNodes.find(node => node.parent === parent)) === null || _b === void 0 ? void 0 : _b.dialog_node; | ||
if (parent && nodeWithSameParent) { | ||
previousSibling = nodeWithSameParent; | ||
} | ||
return [ | ||
...dialogNodes, | ||
{ | ||
type: types_1.Watson.Type.STANDARD, | ||
output: { | ||
generic: unionOfGenericBlocks | ||
}, | ||
previous_sibling: previousSibling, | ||
parent, | ||
context: {}, | ||
metadata: {}, | ||
conditions: (_c = __classPrivateFieldGet(this, _findConditionsOfBlockId).call(this, outerBlock.message_id, projectBlocks)) !== null && _c !== void 0 ? _c : "", | ||
dialog_node: outerBlock.message_id, | ||
} | ||
]; | ||
}, []); | ||
return [ | ||
...dialogNodes, | ||
{ | ||
type: types_1.Watson.Type.STANDARD, | ||
output: { | ||
generic: unionOfGenericBlocks | ||
}, | ||
previous_sibling: previousSibling, | ||
parent, | ||
context: {}, | ||
metadata: {}, | ||
conditions: (_c = __classPrivateFieldGet(this, _findConditionsOfBlockId).call(this, outerBlock.message_id, projectBlocks)) !== null && _c !== void 0 ? _c : "", | ||
dialog_node: outerBlock.message_id, | ||
} | ||
...outerDialogNodes, | ||
...unionOfBlockContent, | ||
]; | ||
}, []); | ||
return [ | ||
...outerDialogNodes, | ||
...unionOfBlockContent, | ||
]; | ||
}, []); | ||
}); | ||
_generateEntities.set(this, (entities) => { | ||
return entities.map(entity => { | ||
var _a; | ||
const unionOfValuesAcrossLangs = Object.values(entity.data).flatMap(value => value); | ||
return ({ | ||
entity: (_a = __classPrivateFieldGet(this, _entityMap).get(entity.name)) !== null && _a !== void 0 ? _a : entity.name, | ||
values: unionOfValuesAcrossLangs.map(datapoint => { | ||
var _a, _b; | ||
return ({ | ||
type: types_1.Watson.EntityValueType.SYNONYMS, | ||
value: (_a = datapoint.value) !== null && _a !== void 0 ? _a : entity.name.toUpperCase(), | ||
synonyms: ((_b = datapoint.synonyms) !== null && _b !== void 0 ? _b : []).map(synonym => synonym) | ||
}); | ||
}) | ||
}); | ||
_generateEntities.set(this, (entities) => { | ||
return entities.map(entity => { | ||
var _a; | ||
const unionOfValuesAcrossLangs = Object.values(entity.data).flatMap(value => value); | ||
return ({ | ||
entity: (_a = __classPrivateFieldGet(this, _entityMap).get(entity.name)) !== null && _a !== void 0 ? _a : entity.name, | ||
values: unionOfValuesAcrossLangs.map(datapoint => { | ||
var _a, _b; | ||
return ({ | ||
type: types_1.Watson.EntityValueType.SYNONYMS, | ||
value: (_a = datapoint.value) !== null && _a !== void 0 ? _a : entity.name.toUpperCase(), | ||
synonyms: ((_b = datapoint.synonyms) !== null && _b !== void 0 ? _b : []).map(synonym => synonym) | ||
}); | ||
}) | ||
}); | ||
}); | ||
}); | ||
}); | ||
_generateIntents.set(this, (intents) => { | ||
return intents.map(intent => ({ | ||
intent: intent.name, | ||
examples: Object | ||
.entries(intent.utterances) | ||
.reduce((utterances, entry) => { | ||
const [, values] = entry; | ||
return [ | ||
...utterances, | ||
...values.map(value => ({ text: value.text })), | ||
]; | ||
}, []), | ||
description: intent.created_at.date, | ||
})); | ||
}); | ||
_rootTransformation.set(this, (resources) => { | ||
__classPrivateFieldSet(this, _intents, resources.intents); | ||
return { | ||
filename: `${resources.project.name}.json`, | ||
data: { | ||
intents: __classPrivateFieldGet(this, _generateIntents).call(this, resources.intents), | ||
entities: __classPrivateFieldGet(this, _generateEntities).call(this, resources.entities), | ||
metadata: { | ||
apiVersion: { | ||
majorVersion: "v2", | ||
minorVersion: "2018-11-08", | ||
} | ||
}, | ||
dialog_nodes: __classPrivateFieldGet(this, _generateDialogNodes).call(this, resources.board.board.messages), | ||
counterexamples: [], | ||
system_settings: { | ||
tooling: { | ||
store_generic_responses: true, | ||
off_topic: { | ||
enabled: true, | ||
}, | ||
disambiguation: { | ||
prompt: "Did you mean:", | ||
enabled: true, | ||
randomize: true, | ||
max_suggestions: 5, | ||
suggestion_text_policy: "title", | ||
none_of_the_above_prompt: "None of the above." | ||
}, | ||
system_entities: { | ||
enabled: true, | ||
}, | ||
spelling_auto_correct: true, | ||
} | ||
}, | ||
learning_opt_out: false, | ||
name: resources.project.name, | ||
language: "en", | ||
} | ||
}; | ||
}); | ||
this.dataTransformations = new Map([ | ||
[Dirpaths.ROOT, __classPrivateFieldGet(this, _rootTransformation)] | ||
]); | ||
} | ||
}; | ||
_intents = new WeakMap(), _blockMap = new WeakMap(), _entityMap = new WeakMap(), _findConditionsOfBlockId = new WeakMap(), _transformOutputStructure = new WeakMap(), _generateDialogNodes = new WeakMap(), _generateEntities = new WeakMap(), _generateIntents = new WeakMap(), _rootTransformation = new WeakMap(); | ||
WatsonExporter = __decorate([ | ||
util_1.sealed | ||
], WatsonExporter); | ||
_generateIntents.set(this, (intents) => { | ||
return intents.map(intent => ({ | ||
intent: intent.name, | ||
examples: Object | ||
.entries(intent.utterances) | ||
.reduce((utterances, entry) => { | ||
const [, values] = entry; | ||
return [ | ||
...utterances, | ||
...values.map(value => ({ text: value.text })), | ||
]; | ||
}, []), | ||
description: intent.created_at.date, | ||
})); | ||
}); | ||
_rootTransformation.set(this, (resources) => { | ||
__classPrivateFieldSet(this, _intents, resources.intents); | ||
return { | ||
filename: `${resources.project.name}.json`, | ||
data: { | ||
intents: __classPrivateFieldGet(this, _generateIntents).call(this, resources.intents), | ||
entities: __classPrivateFieldGet(this, _generateEntities).call(this, resources.entities), | ||
metadata: { | ||
apiVersion: { | ||
majorVersion: "v2", | ||
minorVersion: "2018-11-08", | ||
} | ||
}, | ||
dialog_nodes: __classPrivateFieldGet(this, _generateDialogNodes).call(this, resources.board.board.messages), | ||
counterexamples: [], | ||
system_settings: { | ||
tooling: { | ||
store_generic_responses: true, | ||
off_topic: { | ||
enabled: true, | ||
}, | ||
disambiguation: { | ||
prompt: "Did you mean:", | ||
enabled: true, | ||
randomize: true, | ||
max_suggestions: 5, | ||
suggestion_text_policy: "title", | ||
none_of_the_above_prompt: "None of the above." | ||
}, | ||
system_entities: { | ||
enabled: true, | ||
}, | ||
spelling_auto_correct: true, | ||
} | ||
}, | ||
learning_opt_out: false, | ||
name: resources.project.name, | ||
language: "en", | ||
} | ||
}; | ||
}); | ||
this.dataTransformations = new Map([ | ||
[Dirpaths.ROOT, __classPrivateFieldGet(this, _rootTransformation)] | ||
]); | ||
} | ||
}; | ||
_intents = new WeakMap(), _blockMap = new WeakMap(), _entityMap = new WeakMap(), _findConditionsOfBlockId = new WeakMap(), _transformOutputStructure = new WeakMap(), _generateDialogNodes = new WeakMap(), _generateEntities = new WeakMap(), _generateIntents = new WeakMap(), _rootTransformation = new WeakMap(); | ||
WatsonExporter = __decorate([ | ||
util_1.sealed | ||
], WatsonExporter); | ||
return WatsonExporter; | ||
})(); | ||
exports.WatsonExporter = WatsonExporter; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { | ||
@@ -15,11 +34,5 @@ if (!privateMap.has(receiver)) { | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var _jsonWriteOptions, _directoryRoot, _createWriteResult, _transformMd, _transformLg, _transformYml, _unpackResource; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FileWriter = void 0; | ||
const yaml_1 = require("yaml"); | ||
@@ -32,3 +45,3 @@ const fs = __importStar(require("fs")); | ||
var types_2 = require("../types"); | ||
exports.Kind = types_2.Kind; | ||
Object.defineProperty(exports, "Kind", { enumerable: true, get: function () { return types_2.Kind; } }); | ||
function Ok(value) { | ||
@@ -35,0 +48,0 @@ return { |
{ | ||
"name": "@botmock/export", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -24,2 +24,19 @@ import { Client, Resource, JSONResponse } from "@botmock/client"; | ||
} | ||
protected replaceEntityCharacters = (input: string, left: string = "{", right: string = "}"): string => { | ||
const processedInput = input.split(""); | ||
let numCaptured = 0; | ||
let i = 0; | ||
for (const char of processedInput) { | ||
if (char === "%") { | ||
if (numCaptured % 2 === 0) { | ||
processedInput[i] = left; | ||
} else { | ||
processedInput[i] = right; | ||
} | ||
numCaptured += 1; | ||
} | ||
i += 1; | ||
} | ||
return processedInput.join(""); | ||
}; | ||
#multiChannelProjectName = "multi-channel"; | ||
@@ -26,0 +43,0 @@ #getResources = async (projectReference: ExportReference["projectReference"]) => { |
@@ -49,19 +49,2 @@ import { | ||
}; | ||
#replaceEntityCharacters = (input: string): string => { | ||
const processedInput = input.split(""); | ||
let numCaptured = 0; | ||
let i = 0; | ||
for (const char of processedInput) { | ||
if (char === "%") { | ||
if (numCaptured % 2 === 0) { | ||
processedInput[i] = "${"; | ||
} else { | ||
processedInput[i] = "}"; | ||
} | ||
numCaptured += 1; | ||
} | ||
i += 1; | ||
} | ||
return processedInput.join(""); | ||
}; | ||
#createTemplatesFromProjectResourcesAndSchemaAssociations = (resources: Resources, schemaAssociations: {}) => { | ||
@@ -74,3 +57,3 @@ const unwrapValuesFromPayload = (payload: Botmock.Message["payload"]) => { | ||
.filter(input => typeof input === "string") | ||
.map(input => this.#replaceEntityCharacters(input as string))) | ||
.map(input => this.replaceEntityCharacters(input as string, "${"))) | ||
) | ||
@@ -77,0 +60,0 @@ ); |
@@ -17,5 +17,5 @@ import Exporter from '../base-exporter'; | ||
@sealed | ||
export class RasaExporter<D> extends Exporter<D> { | ||
export class RasaExporter extends Exporter { | ||
/** | ||
* Generate structure of path name -> list of intents -> list of connected actions | ||
* Generate structure of path name -> list of intents -> list of connected actions. | ||
* @param intents {@link Botmock.Intent[]} | ||
@@ -44,3 +44,3 @@ * @param blocks {@link Botmock.Message[]} | ||
/** | ||
* Generates structure of intent name -> list of utterances | ||
* Generates structure of intent name -> list of utterances. | ||
* @param intents {@link Botmock.Intent[]} | ||
@@ -63,3 +63,3 @@ */ | ||
/** | ||
* Unpacks the templates hiding in a response block | ||
* Unpacks the templates hiding in a response block. | ||
* @param block {@link Botmock.Message} | ||
@@ -78,3 +78,3 @@ * @returns Template intermediate representation | ||
case Botmock.Component.text: | ||
[key, value] = [Rasa.TemplateTypes.TEXT, response.text as string]; | ||
[key, value] = [Rasa.TemplateTypes.TEXT, this.replaceEntityCharacters(response.text as string)]; | ||
break; | ||
@@ -163,2 +163,4 @@ case Botmock.Component.image: | ||
return templatesForActions; | ||
} else if (typeof block.node_name === "undefined") { | ||
return templatesForActions; | ||
} | ||
@@ -169,9 +171,5 @@ const templates: void | Rasa.Template<unknown> = this.#unpackTemplatesInBlock(block); | ||
} | ||
if (typeof block.node_name === "undefined") { | ||
return templatesForActions; | ||
} | ||
const actionName = `utter_${block.node_name.toLowerCase().replace(/\s/g, "_")}`; | ||
return { | ||
...templatesForActions, | ||
[actionName]: templates, | ||
[`utter_${block.message_id}`]: templates, | ||
}; | ||
@@ -178,0 +176,0 @@ }, {}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
331685
6773