Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): Remove unused code from experimental 1.0 version #2812

Merged
merged 8 commits into from
May 6, 2024
Prev Previous commit
Next Next commit
chore(core): remove all logic related to botonic 1.0
vanbasten17 committed May 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 8f71792fed839326624aeb0984540bd663891cc2
8,082 changes: 2,532 additions & 5,550 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions packages/botonic-core/package.json
Original file line number Diff line number Diff line change
@@ -30,13 +30,8 @@
],
"dependencies": {
"@babel/plugin-transform-runtime": "^7.23.9",
"aws-sdk": "^2.1404.0",
"axios": "^1.6.8",
"decode": "^0.3.0",
"dynamodb-toolbox": "^0.3.4",
"fast-xml-parser": "3.19.0",
"html-entities": "^2.4.0",
"node-json-db": "^1.6.0",
"pako": "^2.1.0",
"process": "^0.11.10",
"pusher-js": "^5.1.1",
58 changes: 2 additions & 56 deletions packages/botonic-core/src/core-bot.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import { ulid } from 'ulid'

import { Inspector } from './debug'
import { getString } from './i18n'
import {
BotonicEvent,
BotRequest,
BotResponse,
INPUT,
Locales,
MessageEventAck,
MessageEventFrom,
ResolvedPlugins,
Route,
Routes,
Session,
} from './models'
import { BotonicOutputParser } from './output-parser'
import { loadPlugins, runPlugins } from './plugins'
import { getComputedRoutes, Router } from './routing'

@@ -44,7 +38,6 @@ export class CoreBot {
router: Router | null
routes: Routes
theme?: any
botonicOutputParser = new BotonicOutputParser()

constructor({
// TODO: Receives dataProvider
@@ -96,7 +89,6 @@ export class CoreBot {
input,
session,
lastRoutePath,
dataProvider,
}: BotRequest): Promise<BotResponse> {
session = session || {}
if (!session.__locale) session.__locale = 'en'
@@ -106,37 +98,18 @@ export class CoreBot {
input,
session,
lastRoutePath,
dataProvider,
response: [],
messageEvents: null,
}
}

const parsedUserEvent = this.botonicOutputParser.parseFromUserInput(input)
const userId = session.user.id
if (dataProvider) {
// TODO: Next iterations. Review cycle of commited events to DB when messages change their ACK
// @ts-ignore
const userEvent = await dataProvider.saveEvent({
...parsedUserEvent,
userId,
eventId: ulid(),
createdAt: new Date().toISOString(),
from: MessageEventFrom.USER,
ack: MessageEventAck.RECEIVED,
})
}

if (this.plugins) {
await runPlugins(
this.plugins,
'pre',
input,
session,
lastRoutePath,
undefined,
undefined,
dataProvider
undefined
)
}

@@ -169,20 +142,12 @@ export class CoreBot {
defaultTyping: this.defaultTyping,
defaultDelay: this.defaultDelay,
lastRoutePath,
dataProvider,
}

const response = await this.renderer({
request,
actions: [output.fallbackAction, output.action, output.emptyAction],
})
let messageEvents: Partial<BotonicEvent>[] = []
try {
messageEvents = this.botonicOutputParser.xmlToMessageEvents(response)
} catch (e) {
// Disabling Botonic 1.0 error log for LTS version:
// console.error(e)
}

lastRoutePath = output.lastRoutePath
if (this.plugins) {
@@ -192,35 +157,16 @@ export class CoreBot {
input,
session,
lastRoutePath,
response,
messageEvents,
dataProvider
response
)
}

if (dataProvider) {
// TODO: save bot responses to db and update user with new session and new params
for (const messageEvent of messageEvents) {
// @ts-ignore
const botEvent = await dataProvider.saveEvent({
...messageEvent,
userId,
eventId: ulid(),
createdAt: new Date().toISOString(),
from: MessageEventFrom.BOT,
ack: MessageEventAck.SENT,
})
}
}

session.is_first_interaction = false
return {
input,
response,
messageEvents,
session,
lastRoutePath,
dataProvider,
}
}
}
105 changes: 0 additions & 105 deletions packages/botonic-core/src/data-provider/dynamodb-data-provider.ts

This file was deleted.

Loading