From 907cad805031e75161dd2dc83b1f962769208a84 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 21 Feb 2023 08:28:36 +0100 Subject: [PATCH] :bug: Improve bot libs mount in prod env --- apps/docs/openapi/chat/_spec_.json | 36 ++++++++++++------- packages/js/package.json | 5 ++- packages/js/src/components/Bot.tsx | 14 +++++--- .../ConversationContainer.tsx | 4 +-- .../bubble/components/BubbleButton.tsx | 3 +- .../src/features/popup/components/Popup.tsx | 3 +- packages/js/src/types.ts | 6 ++++ packages/react/package.json | 2 +- packages/react/src/Bubble.tsx | 31 ++++++++-------- packages/react/src/Popup.tsx | 28 ++++++++------- pnpm-lock.yaml | 17 +-------- 11 files changed, 78 insertions(+), 71 deletions(-) diff --git a/apps/docs/openapi/chat/_spec_.json b/apps/docs/openapi/chat/_spec_.json index d7be5cc50..14aaf2de5 100644 --- a/apps/docs/openapi/chat/_spec_.json +++ b/apps/docs/openapi/chat/_spec_.json @@ -335,7 +335,12 @@ "type": "string" }, "height": { - "type": "number" + "anyOf": [ + { + "type": "number" + }, + {} + ] } }, "required": [ @@ -3386,19 +3391,26 @@ ] }, "content": { - "type": "object", - "properties": { - "url": { - "type": "string" + "allOf": [ + { + "type": "object", + "properties": { + "url": { + "type": "string" + } + }, + "additionalProperties": false }, - "height": { - "type": "number" + { + "type": "object", + "properties": { + "height": { + "type": "number" + } + }, + "additionalProperties": false } - }, - "required": [ - "height" - ], - "additionalProperties": false + ] } }, "required": [ diff --git a/packages/js/package.json b/packages/js/package.json index e9cc032c9..45e0db4f7 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,13 +1,13 @@ { "name": "@typebot.io/js", - "version": "0.0.6", + "version": "0.0.7", "description": "Javascript library to display typebots on your website", "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { "dev": "rollup --watch --config rollup.config.js", - "build": "rollup --config rollup.config.js && rm -rf dist/dts", + "build": "rollup --config rollup.config.js", "lint": "eslint --fix \"src/**/*.ts*\"" }, "license": "MIT", @@ -31,7 +31,6 @@ "postcss": "8.4.21", "react": "18.2.0", "rollup": "3.12.0", - "rollup-plugin-dts": "5.1.1", "rollup-plugin-postcss": "4.0.2", "rollup-plugin-typescript-paths": "^1.4.0", "tailwindcss": "3.2.4", diff --git a/packages/js/src/components/Bot.tsx b/packages/js/src/components/Bot.tsx index 5f2294e36..a391ea0f4 100644 --- a/packages/js/src/components/Bot.tsx +++ b/packages/js/src/components/Bot.tsx @@ -3,9 +3,8 @@ import { createEffect, createSignal, onCleanup, onMount, Show } from 'solid-js' import { injectCustomHeadCode, isNotEmpty } from 'utils' import { getInitialChatReplyQuery } from '@/queries/getInitialChatReplyQuery' import { ConversationContainer } from './ConversationContainer' -import type { ChatReply, StartParams } from 'models' import { setIsMobile } from '@/utils/isMobileSignal' -import { BotContext, InitialChatReply } from '@/types' +import { BotContext, InitialChatReply, OutgoingLog } from '@/types' import { ErrorMessage } from './ErrorMessage' import { getExistingResultIdFromSession, @@ -13,13 +12,18 @@ import { } from '@/utils/sessionStorage' import { setCssVariablesValue } from '@/utils/setCssVariablesValue' -export type BotProps = StartParams & { +export type BotProps = { + typebot: string | any + isPreview?: boolean + resultId?: string + startGroupId?: string + prefilledVariables?: Record apiHost?: string onNewInputBlock?: (ids: { id: string; groupId: string }) => void onAnswer?: (answer: { message: string; blockId: string }) => void onInit?: () => void onEnd?: () => void - onNewLogs?: (logs: ChatReply['logs']) => void + onNewLogs?: (logs: OutgoingLog[]) => void } export const Bot = (props: BotProps & { class?: string }) => { @@ -138,7 +142,7 @@ type BotContentProps = { onNewInputBlock?: (block: { id: string; groupId: string }) => void onAnswer?: (answer: { message: string; blockId: string }) => void onEnd?: () => void - onNewLogs?: (logs: ChatReply['logs']) => void + onNewLogs?: (logs: OutgoingLog[]) => void } const BotContent = (props: BotContentProps) => { diff --git a/packages/js/src/components/ConversationContainer/ConversationContainer.tsx b/packages/js/src/components/ConversationContainer/ConversationContainer.tsx index 3768f5d8e..15b166c8b 100644 --- a/packages/js/src/components/ConversationContainer/ConversationContainer.tsx +++ b/packages/js/src/components/ConversationContainer/ConversationContainer.tsx @@ -2,7 +2,7 @@ import type { ChatReply, Theme } from 'models' import { createEffect, createSignal, For, Show } from 'solid-js' import { sendMessageQuery } from '@/queries/sendMessageQuery' import { ChatChunk } from './ChatChunk' -import { BotContext, InitialChatReply } from '@/types' +import { BotContext, InitialChatReply, OutgoingLog } from '@/types' import { isNotDefined } from 'utils' import { executeClientSideAction } from '@/utils/executeClientSideActions' import { LoadingChunk } from './LoadingChunk' @@ -38,7 +38,7 @@ type Props = { onNewInputBlock?: (ids: { id: string; groupId: string }) => void onAnswer?: (answer: { message: string; blockId: string }) => void onEnd?: () => void - onNewLogs?: (logs: ChatReply['logs']) => void + onNewLogs?: (logs: OutgoingLog[]) => void } export const ConversationContainer = (props: Props) => { diff --git a/packages/js/src/features/bubble/components/BubbleButton.tsx b/packages/js/src/features/bubble/components/BubbleButton.tsx index ef49be52c..e3a22f535 100644 --- a/packages/js/src/features/bubble/components/BubbleButton.tsx +++ b/packages/js/src/features/bubble/components/BubbleButton.tsx @@ -13,8 +13,7 @@ const defaultIconColor = 'white' export const BubbleButton = (props: Props) => { return (