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

Botonic: upgrade typescript to 5.5.3 #2874

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,696 changes: 6,630 additions & 4,066 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"ts-mockito": "^2.6.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^4.9.5"
"typescript": "^5.5.3"
},
"eslintConfig": {
"env": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class MessageContentInverseTraverser {
return this.referencesTo.size > 0
}

async messageContentTypes(): Promise<MessageContentType[]> {
async messageContentTypes() {
return andArrays(MESSAGE_CONTENT_TYPES, await this.info.contentTypes())
}

Expand Down
1,180 changes: 0 additions & 1,180 deletions packages/botonic-plugin-flow-builder/package-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/botonic-plugin-flow-builder/src/action/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {

const handoffContent = contents.find(
content => content instanceof FlowHandoff
) as FlowHandoff
)
if (handoffContent) {
await handoffContent.doHandoff(request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function getContentsByKnowledgeBase({

const knowledgeBaseContent = contents.find(
content => content instanceof FlowKnowledgeBase
) as FlowKnowledgeBase
)

if (!knowledgeBaseContent) {
return contents
Expand Down
17 changes: 7 additions & 10 deletions packages/botonic-plugin-flow-builder/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from './constants'
import {
HtBotActionNode,
HtFallbackNode,
HtFlowBuilderData,
HtGoToFlow,
HtIntentNode,
Expand All @@ -21,7 +20,7 @@ import {
HtPayloadNode,
} from './content-fields/hubtype-fields'
import { HtSmartIntentNode } from './content-fields/hubtype-fields/smart-intent'
import { FlowBuilderApiOptions } from './types'
import { FlowBuilderApiOptions, KnowledgeBaseConfig } from './types'

export class FlowBuilderApi {
url: string
Expand Down Expand Up @@ -79,7 +78,7 @@ export class FlowBuilderApi {
getFallbackNode(alternate: boolean): HtNodeWithContent {
const fallbackNode = this.flow.nodes.find(
node => node.type === HtNodeWithContentType.FALLBACK
) as HtFallbackNode | undefined
)
if (!fallbackNode) {
throw new Error('Fallback node must be defined')
}
Expand All @@ -96,12 +95,10 @@ export class FlowBuilderApi {
: this.getNodeById(fallbackSecondMessage.id)
}

getKnowledgeBaseConfig():
| { followup?: HtNodeLink; isActive: boolean }
| undefined {
getKnowledgeBaseConfig(): KnowledgeBaseConfig | undefined {
const fallbackNode = this.flow.nodes.find(
node => node.type === HtNodeWithContentType.FALLBACK
) as HtFallbackNode | undefined
)

return fallbackNode
? {
Expand All @@ -115,7 +112,7 @@ export class FlowBuilderApi {
try {
const intentsNodes = this.flow.nodes.filter(
node => node.type === HtNodeWithContentType.INTENT
) as HtIntentNode[]
)
const inputIntent = input.intent
if (inputIntent) {
return intentsNodes.find(
Expand All @@ -133,7 +130,7 @@ export class FlowBuilderApi {
getSmartIntentNodes(): HtSmartIntentNode[] {
return this.flow.nodes.filter(
node => node.type === HtNodeWithContentType.SMART_INTENT
) as HtSmartIntentNode[]
)
}

private nodeContainsIntent(
Expand All @@ -157,7 +154,7 @@ export class FlowBuilderApi {
getKeywordNodes(): HtKeywordNode[] {
return this.flow.nodes.filter(
node => node.type === HtNodeWithContentType.KEYWORD
) as HtKeywordNode[]
)
}

getPayload(target?: HtNodeLink): string | undefined {
Expand Down
4 changes: 3 additions & 1 deletion packages/botonic-plugin-flow-builder/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PluginPreRequest, Session } from '@botonic/core'
import { ActionRequest } from '@botonic/react'

import { HtFlowBuilderData } from './content-fields/hubtype-fields'
import { HtFlowBuilderData, HtNodeLink } from './content-fields/hubtype-fields'

export interface BotonicPluginFlowBuilderOptions {
apiUrl?: string
Expand All @@ -21,6 +21,8 @@ export type TrackEventFunction = (
args?: Record<string, any>
) => Promise<void>

export type KnowledgeBaseConfig = { followup?: HtNodeLink; isActive: boolean }

export type KnowledgeBaseFunction = (
request: ActionRequest,
userInput: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ export function useWebviewContents<T extends MapContentsType>({

const textResponseContents = response.data.webview_contents.filter(
webviewContent => webviewContent.type === WebviewContentType.TEXT
) as WebviewTextContent[]
)
setTextContents(textResponseContents)

const imageResponseContents = response.data.webview_contents.filter(
webviewContent => webviewContent.type === WebviewContentType.IMAGE
) as WebviewImageContent[]
)
setImageContents(imageResponseContents)
} catch (error) {
console.error('Error fetching webview contents:', error)
Expand Down
Loading
Loading