/
index.ts
40 lines (32 loc) · 952 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as sdk from 'botpress/sdk'
import { Config } from '../config'
import api from './api'
import Editor from './editor'
import { EditorByBot } from './typings'
const editorByBot: EditorByBot = {}
const onServerStarted = async (bp: typeof sdk) => {}
const onServerReady = async (bp: typeof sdk) => {
await api(bp, editorByBot)
}
const onBotMount = async (bp: typeof sdk, botId: string) => {
const config = (await bp.config.getModuleConfig('code-editor')) as Config
editorByBot[botId] = new Editor(bp, botId, config)
}
const onBotUnmount = async (bp: typeof sdk, botId: string) => {
delete editorByBot[botId]
}
const entryPoint: sdk.ModuleEntryPoint = {
onServerStarted,
onServerReady,
onBotMount,
onBotUnmount,
definition: {
name: 'code-editor',
menuIcon: 'code',
menuText: 'Code Editor',
noInterface: false,
fullName: 'Code Editor',
homepage: 'https://botpress.io'
}
}
export default entryPoint