utils
npm i @botmock-api/utils
utilities for handling data from the Botmock API
API
import * as utils from '@botmock-api/utils';
Flow Operations
enumeratePaths
utils.enumeratePaths(messages: Message[]): Set<Array<string>>
Function that returns a Set
which contains arrays with the message ids of each possible journey in the provided messages
createIntentMap
utils.createIntentMap(messages: []): Map<messageId: string, intentIds: string[]>
Function that returns a Map
which associates message ids with the list of intent ids connected to them
createNodeCollector
utils.createNodeCollector(map: Map, get: (id: string) => ({}): (arr: string[]) => string[]
Creates function that turns next_messages
into a collection of all reachable
messages that are not connected by an intent
Async Operations
await utils.checkEnvVars(n: ?number): Promise<void>
Checks that there exist at least n
BOTMOCK_
-prefixed environment variables defined in a local .env
file;
throws if this is not the case
await utils.doesHaveGlobalPackages(packages: string[]): Promise<boolean>
Determines if all packages
are installed globally. Returns false if not.