@botmock-api/flow
v0.8.0
Published
transform botmock api flow structure
Downloads
21
Readme
@botmock-api/flow
transform botmock api flow structure
Installation
npm i @botmock-api/flow
API
Simulator
Class that fosters flow generation. Exposes methods to ensure the generated flow has certain qualities.
import { Simulator } from "@botmock-api/flow";
let flow: any;
const generator = new Simulator().createConnectedFlowGenerator();
for (const [i] of new Array(100).entries()) {
flow = generator.next();
}
Methods
createConnectedFlowGenerator
Creates generator that can only ever produce connected flows
createCompleteFlowGenerator
Creates generator that can only ever produce complete flows
createDisconnectedFlowGenerator
Creates generator that can only ever produce disconnected flows
AbstractProject
Base class that provides abstractions of flow project structure through a variety of methods.
This class can be extended in the following way:
import { AbstractProject } from "@botmock-api/flow";
export default class FileWriter extends AbstractProject {
constructor(config) {
super({ projectData: config.projectData });
}
}
Methods
getMessage(messageId: string): flow.Message
Gets message from the board from messageId
getIntent(intentId: string): flow.Intent
Gets a full intent from intentId
gatherMessagesUpToNextIntent(message: flow.Message): flow.Message[]
Gathers all messages connected to message that are not separated by an intent in the flow
segmentizeBoardFromIntents(): Map<string, string[]>
Segmentizes board by relating intents to all messages they are connected to in the flow
segmentizeBoardFromMessages(): Map<string, string[]>
Segmentizes board by relating messages to the intents connected to them in the flow
representRequirementsForIntents(): Map<string, Slot>
Relates intent ids to the slots that are required on them
topoSort(): flow.Message[]
Topologically sorts messages on the board. If a message is connected to another message, it will appear before it in the sorted result.
representFlowAsAdjMatrix(): boolean[][]
Describes flow as an adjacency matrix. Each ij where there is a link between node i and node j in the original flow is truthy.