2
0

Introduce bot v2 in builder (#328)

Also, the new engine is the default for updated typebots for viewer

Closes #211
This commit is contained in:
Baptiste Arnaud
2023-02-21 15:25:14 +01:00
committed by GitHub
parent 527dc8a5b1
commit debdac12ff
208 changed files with 4462 additions and 5236 deletions

View File

@ -0,0 +1,32 @@
import { BotProps } from '@typebot.io/js'
import { isDefined } from 'utils'
export const parseStringParam = (fieldName: string, fieldValue?: string) =>
fieldValue ? `${fieldName}: "${fieldValue}",` : ``
export const parseNumberOrBoolParam = (
fieldName: string,
fieldValue?: number | boolean
) => (isDefined(fieldValue) ? `${fieldName}: ${fieldValue},` : ``)
export const parseBotProps = ({ typebot, apiHost }: BotProps) => {
const typebotLine = parseStringParam('typebot', typebot as string)
const apiHostLine = parseStringParam('apiHost', apiHost)
return `${typebotLine}${apiHostLine}`
}
export const parseReactStringParam = (fieldName: string, fieldValue?: string) =>
fieldValue ? `${fieldName}="${fieldValue}"` : ``
export const parseReactNumberOrBoolParam = (
fieldName: string,
fieldValue?: number | boolean
) => (isDefined(fieldValue) ? `${fieldName}={${fieldValue}}` : ``)
export const parseReactBotProps = ({ typebot, apiHost }: BotProps) => {
const typebotLine = parseReactStringParam('typebot', typebot as string)
const apiHostLine = parseReactStringParam('apiHost', apiHost)
return `${typebotLine} ${apiHostLine}`
}
export const typebotImportUrl = `https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0.9/dist/web.js`