From eac80419350b66bf6aa5809eaa91b810115016cc Mon Sep 17 00:00:00 2001 From: Lucas De Morais Date: Mon, 25 Nov 2024 16:51:06 +0100 Subject: [PATCH] Feat: supports OSS Chat with Orama Switch --- apps/demo-react/package.json | 3 +- apps/demo-react/src/App.tsx | 1 + apps/storybook/package.json | 2 +- apps/storybook/stories/config.ts | 19 +- .../public/orama-search-box.stories.tsx | 5 +- packages/ui-stencil/package.json | 3 +- packages/ui-stencil/src/components.d.ts | 1967 +++++++++-------- .../orama-chat-box/orama-chat-box.tsx | 8 +- .../src/components/orama-chat-box/readme.md | 2 - .../orama-search-box/orama-search-box.tsx | 13 +- .../ui-stencil/src/services/ChatService.ts | 29 +- .../ui-stencil/src/services/SearchService.ts | 12 +- packages/ui-stencil/src/utils/utils.ts | 12 +- pnpm-lock.yaml | 127 +- 14 files changed, 1189 insertions(+), 1014 deletions(-) diff --git a/apps/demo-react/package.json b/apps/demo-react/package.json index b6b354cb..afdb7efa 100644 --- a/apps/demo-react/package.json +++ b/apps/demo-react/package.json @@ -13,7 +13,8 @@ "dependencies": { "react": "^18.3.1", "react-dom": "^18.3.1", - "@orama/react-components": "workspace:*" + "@orama/react-components": "workspace:*", + "@oramacloud/client": "^2.1.4" }, "devDependencies": { "@types/react": "^18.3.3", diff --git a/apps/demo-react/src/App.tsx b/apps/demo-react/src/App.tsx index 0433d455..0837744f 100644 --- a/apps/demo-react/src/App.tsx +++ b/apps/demo-react/src/App.tsx @@ -1,5 +1,6 @@ import { OramaChatBox, OramaSearchBox, OramaSearchButton } from '@orama/react-components' import './App.css' +import { OramaClient } from "@oramacloud/client" function App() { return ( diff --git a/apps/storybook/package.json b/apps/storybook/package.json index fbb63786..a82c63c9 100644 --- a/apps/storybook/package.json +++ b/apps/storybook/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@orama/wc-components": "workspace:*", - "@oramacloud/client": "1.3.15", + "@oramacloud/client": "^2.1.0", "@storybook/preview-api": "^8.2.9", "@storybook/web-components": "^8.2.3" }, diff --git a/apps/storybook/stories/config.ts b/apps/storybook/stories/config.ts index f566f7ca..1d31e4b3 100644 --- a/apps/storybook/stories/config.ts +++ b/apps/storybook/stories/config.ts @@ -6,15 +6,15 @@ export type DemoIndexConfig = Record const demoIndexes: DemoIndexConfig = { orama: { open: true, - index: { - api_key: 'LerNlbp6379jVKaPs4wt2nZT4MJZbU1J', - endpoint: 'https://cloud.orama.run/v1/indexes/docs-orama-b3f5xd', - }, - // Uncomment this line to use the OramaClient instance and comment the index prop - // clientInstance: new OramaClient({ + // index: { // api_key: 'LerNlbp6379jVKaPs4wt2nZT4MJZbU1J', // endpoint: 'https://cloud.orama.run/v1/indexes/docs-orama-b3f5xd', - // }), + // }, + // Uncomment this line to use the OramaClient instance and comment the index prop + clientInstance: new OramaClient({ + api_key: 'LerNlbp6379jVKaPs4wt2nZT4MJZbU1J', + endpoint: 'https://cloud.orama.run/v1/indexes/docs-orama-b3f5xd', + }), placeholder: 'What do you want to learn about Orama?', sourceBaseUrl: 'https://docs.orama.com', sourcesMap: { @@ -28,11 +28,6 @@ const demoIndexes: DemoIndexConfig = { description: 'content', section: 'category', }, - highlight: { - caseSensitive: false, - HTMLTag: 'b', - CSSClass: 'font-bold', - }, }, recipes: { open: true, diff --git a/apps/storybook/stories/public/orama-search-box.stories.tsx b/apps/storybook/stories/public/orama-search-box.stories.tsx index da01214e..826d03ad 100644 --- a/apps/storybook/stories/public/orama-search-box.stories.tsx +++ b/apps/storybook/stories/public/orama-search-box.stories.tsx @@ -77,9 +77,9 @@ const Template = ({ facetProperty, themeConfig, index, + clientInstance, sourceBaseUrl, sourcesMap, - highlight, resultMap, }) => { return html`
@@ -93,6 +93,7 @@ const Template = ({ .colorScheme=${colorScheme} .themeConfig=${themeConfig || preset.themeConfig} .index=${index || preset.index} + .clientInstance=${clientInstance || preset.clientInstance} .instance=${preset.instance} .suggestions=${suggestions || preset?.suggestions} .sourceBaseUrl=${sourceBaseUrl || preset?.sourceBaseUrl} @@ -119,6 +120,7 @@ const TemplateAsEmbed = ({ resultMap, themeConfig, index, + clientInstance, sourceBaseURL, suggestions, sourcesMap, @@ -132,6 +134,7 @@ const TemplateAsEmbed = ({ .colorScheme=${colorScheme} .themeConfig=${themeConfig || preset.themeConfig} .index=${index || preset.index} + .clientInstance=${clientInstance || preset.clientInstance} .instance=${preset.instance} .suggestions=${suggestions || preset?.suggestions} .sourceBaseUrl=${sourceBaseURL || preset?.sourceBaseUrl} diff --git a/packages/ui-stencil/package.json b/packages/ui-stencil/package.json index 5ff9c961..0d8ba04b 100644 --- a/packages/ui-stencil/package.json +++ b/packages/ui-stencil/package.json @@ -26,7 +26,8 @@ "types": "dist/types/index.d.ts", "dependencies": { "@orama/highlight": "^0.1.6", - "@orama/orama": "^2.0.23", + "@orama/orama": "^3.0.0", + "@orama/switch": "^3.0.0", "@oramacloud/client": "^2.1.0", "@phosphor-icons/webcomponents": "^2.1.5", "@stencil/core": "^4.19.0", diff --git a/packages/ui-stencil/src/components.d.ts b/packages/ui-stencil/src/components.d.ts index 8aed7a12..8375cd5d 100644 --- a/packages/ui-stencil/src/components.d.ts +++ b/packages/ui-stencil/src/components.d.ts @@ -4,901 +4,1128 @@ * This is an autogenerated file created by the Stencil compiler. * It contains typing information for all components that exist in this project. */ -import { HTMLStencilElement, JSXBase } from "@stencil/core/internal"; -import { ButtonProps } from "./components/internal/orama-button/orama-button"; -import { ChatMarkdownLinkHref, ChatMarkdownLinkTarget, ChatMarkdownLinkTitle, CloudIndexConfig, ColorScheme, Facet, OnAnswerGeneratedCallbackProps, OnAnswerSourceClickCallbackProps, OnChatMarkdownLinkClickedCallbackProps, OnSearchCompletedCallbackProps, OnSearchResultClickCallbackProps, ResultMap, SearchResult, SearchResultBySection, SourcesMap } from "./types/index"; -import { TChatInteraction } from "./context/chatContext"; -import { OramaClient } from "@oramacloud/client"; -import { InputProps } from "./components/internal/orama-input/orama-input"; -import { ModalStatus } from "./components/internal/orama-modal/orama-modal"; -import { HighlightOptions } from "@orama/highlight"; -import { TThemeOverrides } from "./config/theme"; -import { AnyOrama, Orama, SearchParams } from "@orama/orama"; -import { TThemeOverrides as TThemeOverrides1 } from "./components.d"; -import { SearchResultsProps } from "./components/internal/orama-search-results/orama-search-results"; -import { TextProps } from "./components/internal/orama-text/orama-text"; -export { ButtonProps } from "./components/internal/orama-button/orama-button"; -export { ChatMarkdownLinkHref, ChatMarkdownLinkTarget, ChatMarkdownLinkTitle, CloudIndexConfig, ColorScheme, Facet, OnAnswerGeneratedCallbackProps, OnAnswerSourceClickCallbackProps, OnChatMarkdownLinkClickedCallbackProps, OnSearchCompletedCallbackProps, OnSearchResultClickCallbackProps, ResultMap, SearchResult, SearchResultBySection, SourcesMap } from "./types/index"; -export { TChatInteraction } from "./context/chatContext"; -export { OramaClient } from "@oramacloud/client"; -export { InputProps } from "./components/internal/orama-input/orama-input"; -export { ModalStatus } from "./components/internal/orama-modal/orama-modal"; -export { HighlightOptions } from "@orama/highlight"; -export { TThemeOverrides } from "./config/theme"; -export { AnyOrama, Orama, SearchParams } from "@orama/orama"; -export { TThemeOverrides as TThemeOverrides1 } from "./components.d"; -export { SearchResultsProps } from "./components/internal/orama-search-results/orama-search-results"; -export { TextProps } from "./components/internal/orama-text/orama-text"; +import { HTMLStencilElement, JSXBase } from "@stencil/core/internal" +import { ButtonProps } from "./components/internal/orama-button/orama-button" +import { + ChatMarkdownLinkHref, + ChatMarkdownLinkTarget, + ChatMarkdownLinkTitle, + CloudIndexConfig, + ColorScheme, + Facet, + OnAnswerGeneratedCallbackProps, + OnAnswerSourceClickCallbackProps, + OnChatMarkdownLinkClickedCallbackProps, + OnSearchCompletedCallbackProps, + OnSearchResultClickCallbackProps, + ResultMap, + SearchResult, + SearchResultBySection, + SourcesMap +} from "./types/index" +import { TChatInteraction } from "./context/chatContext" +import { OramaClient } from "@oramacloud/client" +import { InputProps } from "./components/internal/orama-input/orama-input" +import { ModalStatus } from "./components/internal/orama-modal/orama-modal" +import { HighlightOptions } from "@orama/highlight" +import { TThemeOverrides } from "./config/theme" +import { AnyOrama, Orama, SearchParams } from "@orama/orama" +import { TThemeOverrides as TThemeOverrides1 } from "./components.d" +import { SearchResultsProps } from "./components/internal/orama-search-results/orama-search-results" +import { TextProps } from "./components/internal/orama-text/orama-text" + +export { ButtonProps } from "./components/internal/orama-button/orama-button" +export { + ChatMarkdownLinkHref, + ChatMarkdownLinkTarget, + ChatMarkdownLinkTitle, + CloudIndexConfig, + ColorScheme, + Facet, + OnAnswerGeneratedCallbackProps, + OnAnswerSourceClickCallbackProps, + OnChatMarkdownLinkClickedCallbackProps, + OnSearchCompletedCallbackProps, + OnSearchResultClickCallbackProps, + ResultMap, + SearchResult, + SearchResultBySection, + SourcesMap +} from "./types/index" +export { TChatInteraction } from "./context/chatContext" +export { OramaClient } from "@oramacloud/client" +export { InputProps } from "./components/internal/orama-input/orama-input" +export { ModalStatus } from "./components/internal/orama-modal/orama-modal" +export { HighlightOptions } from "@orama/highlight" +export { TThemeOverrides } from "./config/theme" +export { AnyOrama, Orama, SearchParams } from "@orama/orama" +export { TThemeOverrides as TThemeOverrides1 } from "./components.d" +export { SearchResultsProps } from "./components/internal/orama-search-results/orama-search-results" +export { TextProps } from "./components/internal/orama-text/orama-text" export namespace Components { - interface OramaButton { - "as"?: ButtonProps['as']; - "class"?: string; - "disabled"?: boolean; - "size": 'small' | 'medium' | 'large'; - "type"?: ButtonProps['type']; - "variant"?: ButtonProps['variant']; - "withTooltip"?: string; - } - interface OramaChat { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "defaultTerm"?: string; - "focusInput"?: boolean; - "linksRel"?: string; - "linksTarget"?: string; - "placeholder"?: string; - "showClearChat"?: boolean; - "sourceBaseUrl"?: string; - "sourcesMap"?: SourcesMap; - "suggestions"?: string[]; - "systemPrompts"?: string[]; - } - interface OramaChatAssistentMessage { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "interaction": TChatInteraction; - } - interface OramaChatBox { - "autoFocus": boolean; - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "clientInstance"?: OramaClient; - "index"?: CloudIndexConfig; - "linksRel"?: string; - "linksTarget"?: string; - "placeholder"?: string; - "sourceBaseUrl"?: string; - "sourcesMap"?: SourcesMap; - "suggestions"?: string[]; - "systemPrompts"?: string[]; - } - interface OramaChatButton { - "active"?: boolean; - "class"?: string; - "highlight"?: boolean; - "label": string; - } - interface OramaChatMessagesContainer { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "interactions": TChatInteraction[]; - } - interface OramaChatUserMessage { - "interaction": TChatInteraction; - } - interface OramaDotsLoader { - } - interface OramaEmbed { - } - interface OramaFacets { - "facetClicked": (facetName: string) => void; - "facets": Facet[]; - "selectedFacet": string; - } - interface OramaFooter { - "class"?: string; - "colorScheme"?: Omit; - } - interface OramaInput { - "autoFocus"?: boolean; - "defaultValue": InputProps['defaultValue']; - "label"?: InputProps['label']; - "labelForScreenReaders"?: InputProps['labelForScreenReaders']; - "name": InputProps['name']; - "placeholder"?: InputProps['placeholder']; - "size"?: InputProps['size']; - "type"?: InputProps['type']; - } - interface OramaLogoIcon { - "size": number; - } - interface OramaMarkdown { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "content": string; - } - interface OramaModal { - "closeOnEscape": boolean; - "closeOnOutsideClick": boolean; - "mainTitle": string; - "open": boolean; - } - interface OramaNavigationBar { - "handleClose": () => void; - "showBackButton": boolean; - "showChatActions": boolean; - } - interface OramaSearch { - "disableChat"?: boolean; - "focusInput"?: boolean; - "highlightDescription"?: HighlightOptions | false; - "highlightTitle"?: HighlightOptions | false; - "linksRel"?: string; - "linksTarget"?: string; - "placeholder"?: string; - "sourceBaseUrl"?: string; - "suggestions"?: string[]; - } - interface OramaSearchBox { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "chatPlaceholder"?: string; - "clientInstance"?: OramaClient; - "colorScheme"?: ColorScheme; - "disableChat"?: boolean; - "facetProperty"?: string; - "highlightDescription"?: HighlightOptions | false; - "highlightTitle"?: HighlightOptions | false; - "index"?: CloudIndexConfig; - "layout"?: 'modal' | 'embed'; - "linksRel"?: string; - "linksTarget"?: string; - "open": boolean; - "placeholder"?: string; - "resultMap"?: Partial; - "searchParams"?: SearchParams>; - "searchPlaceholder"?: string; - "sourceBaseUrl"?: string; - "sourcesMap"?: SourcesMap; - "suggestions"?: string[]; - "themeConfig"?: Partial; - } - interface OramaSearchButton { - "colorScheme"?: ColorScheme; - "size": 'small' | 'medium' | 'large'; - "themeConfig"?: Partial; - } - interface OramaSearchResults { - "error": boolean; - "highlightDescription"?: HighlightOptions | false; - "highlightTitle"?: HighlightOptions | false; - "linksRel"?: string; - "linksTarget"?: string; - "loading": boolean; - "searchTerm": SearchResultsProps['searchTerm']; - "sections": SearchResultBySection[]; - "setChatTerm": (term: string) => void; - "sourceBaseUrl"?: string; - "suggestions"?: string[]; - } - interface OramaSlidingPanel { - "backdrop": boolean; - "closed": () => void; - "open": boolean; - } - interface OramaSources { - "linksRel"?: string; - "linksTarget"?: string; - "sourceBaseURL"?: string; - "sources": any; - "sourcesMap"?: SourcesMap; - } - interface OramaSuggestions { - "as": 'chips' | 'list'; - "icon"?: Node; - "suggestionClicked": (suggestion: string) => void; - "suggestions": string[]; - } - interface OramaText { - /** - * optionally change text alignment - */ - "align"?: TextProps['align']; - /** - * it defines the HTML tag to be used - */ - "as"?: TextProps['as']; - "bold"?: boolean; - /** - * the optional class name - */ - "class"?: string; - /** - * show as inactive - */ - "inactive"?: TextProps['inactive']; - /** - * it defines how it should look like - */ - "styledAs"?: TextProps['styledAs']; - /** - * optionally change variant style - default is primary - */ - "variant": TextProps['variant']; - } - interface OramaTextarea { - "autoFocus": boolean; - "maxRows": number | string; - "minRows": number | string; - "placeholder": string; - "value": string | null; - } - interface OramaToggler { - "performInitialAnimation": boolean; - } + interface OramaButton { + "as"?: ButtonProps["as"]; + "class"?: string; + "disabled"?: boolean; + "size": "small" | "medium" | "large"; + "type"?: ButtonProps["type"]; + "variant"?: ButtonProps["variant"]; + "withTooltip"?: string; + } + + interface OramaChat { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "defaultTerm"?: string; + "focusInput"?: boolean; + "linksRel"?: string; + "linksTarget"?: string; + "placeholder"?: string; + "showClearChat"?: boolean; + "sourceBaseUrl"?: string; + "sourcesMap"?: SourcesMap; + "suggestions"?: string[]; + "systemPrompts"?: string[]; + } + + interface OramaChatAssistentMessage { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "interaction": TChatInteraction; + } + + interface OramaChatBox { + "autoFocus": boolean; + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "clientInstance"?: OramaClient | AnyOrama; + "index"?: CloudIndexConfig; + "linksRel"?: string; + "linksTarget"?: string; + "placeholder"?: string; + "sourceBaseUrl"?: string; + "sourcesMap"?: SourcesMap; + "suggestions"?: string[]; + "systemPrompts"?: string[]; + } + + interface OramaChatButton { + "active"?: boolean; + "class"?: string; + "highlight"?: boolean; + "label": string; + } + + interface OramaChatMessagesContainer { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "interactions": TChatInteraction[]; + } + + interface OramaChatUserMessage { + "interaction": TChatInteraction; + } + + interface OramaDotsLoader { + } + + interface OramaEmbed { + } + + interface OramaFacets { + "facetClicked": (facetName: string) => void; + "facets": Facet[]; + "selectedFacet": string; + } + + interface OramaFooter { + "class"?: string; + "colorScheme"?: Omit; + } + + interface OramaInput { + "autoFocus"?: boolean; + "defaultValue": InputProps["defaultValue"]; + "label"?: InputProps["label"]; + "labelForScreenReaders"?: InputProps["labelForScreenReaders"]; + "name": InputProps["name"]; + "placeholder"?: InputProps["placeholder"]; + "size"?: InputProps["size"]; + "type"?: InputProps["type"]; + } + + interface OramaLogoIcon { + "size": number; + } + + interface OramaMarkdown { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "content": string; + } + + interface OramaModal { + "closeOnEscape": boolean; + "closeOnOutsideClick": boolean; + "mainTitle": string; + "open": boolean; + } + + interface OramaNavigationBar { + "handleClose": () => void; + "showBackButton": boolean; + "showChatActions": boolean; + } + + interface OramaSearch { + "disableChat"?: boolean; + "focusInput"?: boolean; + "highlightDescription"?: HighlightOptions | false; + "highlightTitle"?: HighlightOptions | false; + "linksRel"?: string; + "linksTarget"?: string; + "placeholder"?: string; + "sourceBaseUrl"?: string; + "suggestions"?: string[]; + } + + interface OramaSearchBox { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "chatPlaceholder"?: string; + "clientInstance"?: OramaClient | AnyOrama; + "colorScheme"?: ColorScheme; + "disableChat"?: boolean; + "facetProperty"?: string; + "highlightDescription"?: HighlightOptions | false; + "highlightTitle"?: HighlightOptions | false; + "index"?: CloudIndexConfig; + "layout"?: "modal" | "embed"; + "linksRel"?: string; + "linksTarget"?: string; + "open": boolean; + "placeholder"?: string; + "resultMap"?: Partial; + "searchParams"?: SearchParams>; + "searchPlaceholder"?: string; + "sourceBaseUrl"?: string; + "sourcesMap"?: SourcesMap; + "suggestions"?: string[]; + "themeConfig"?: Partial; + } + + interface OramaSearchButton { + "colorScheme"?: ColorScheme; + "size": "small" | "medium" | "large"; + "themeConfig"?: Partial; + } + + interface OramaSearchResults { + "error": boolean; + "highlightDescription"?: HighlightOptions | false; + "highlightTitle"?: HighlightOptions | false; + "linksRel"?: string; + "linksTarget"?: string; + "loading": boolean; + "searchTerm": SearchResultsProps["searchTerm"]; + "sections": SearchResultBySection[]; + "setChatTerm": (term: string) => void; + "sourceBaseUrl"?: string; + "suggestions"?: string[]; + } + + interface OramaSlidingPanel { + "backdrop": boolean; + "closed": () => void; + "open": boolean; + } + + interface OramaSources { + "linksRel"?: string; + "linksTarget"?: string; + "sourceBaseURL"?: string; + "sources": any; + "sourcesMap"?: SourcesMap; + } + + interface OramaSuggestions { + "as": "chips" | "list"; + "icon"?: Node; + "suggestionClicked": (suggestion: string) => void; + "suggestions": string[]; + } + + interface OramaText { + /** + * optionally change text alignment + */ + "align"?: TextProps["align"]; + /** + * it defines the HTML tag to be used + */ + "as"?: TextProps["as"]; + "bold"?: boolean; + /** + * the optional class name + */ + "class"?: string; + /** + * show as inactive + */ + "inactive"?: TextProps["inactive"]; + /** + * it defines how it should look like + */ + "styledAs"?: TextProps["styledAs"]; + /** + * optionally change variant style - default is primary + */ + "variant": TextProps["variant"]; + } + + interface OramaTextarea { + "autoFocus": boolean; + "maxRows": number | string; + "minRows": number | string; + "placeholder": string; + "value": string | null; + } + + interface OramaToggler { + "performInitialAnimation": boolean; + } } + export interface OramaChatCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaChatElement; + detail: T; + target: HTMLOramaChatElement; } + export interface OramaChatBoxCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaChatBoxElement; + detail: T; + target: HTMLOramaChatBoxElement; } + export interface OramaChatMessagesContainerCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaChatMessagesContainerElement; + detail: T; + target: HTMLOramaChatMessagesContainerElement; } + export interface OramaInputCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaInputElement; + detail: T; + target: HTMLOramaInputElement; } + export interface OramaMarkdownCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaMarkdownElement; + detail: T; + target: HTMLOramaMarkdownElement; } + export interface OramaModalCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaModalElement; + detail: T; + target: HTMLOramaModalElement; } + export interface OramaSearchCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaSearchElement; + detail: T; + target: HTMLOramaSearchElement; } + export interface OramaSearchBoxCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaSearchBoxElement; + detail: T; + target: HTMLOramaSearchBoxElement; } + export interface OramaSearchResultsCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaSearchResultsElement; + detail: T; + target: HTMLOramaSearchResultsElement; } + export interface OramaSourcesCustomEvent extends CustomEvent { - detail: T; - target: HTMLOramaSourcesElement; + detail: T; + target: HTMLOramaSourcesElement; } + declare global { - interface HTMLOramaButtonElement extends Components.OramaButton, HTMLStencilElement { - } - var HTMLOramaButtonElement: { - prototype: HTMLOramaButtonElement; - new (): HTMLOramaButtonElement; - }; - interface HTMLOramaChatElementEventMap { - "answerGenerated": OnAnswerGeneratedCallbackProps; - } - interface HTMLOramaChatElement extends Components.OramaChat, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaChatElement, ev: OramaChatCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaChatElement, ev: OramaChatCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaChatElement: { - prototype: HTMLOramaChatElement; - new (): HTMLOramaChatElement; - }; - interface HTMLOramaChatAssistentMessageElement extends Components.OramaChatAssistentMessage, HTMLStencilElement { - } - var HTMLOramaChatAssistentMessageElement: { - prototype: HTMLOramaChatAssistentMessageElement; - new (): HTMLOramaChatAssistentMessageElement; - }; - interface HTMLOramaChatBoxElementEventMap { - "answerGenerated": OnAnswerGeneratedCallbackProps; - "answerSourceClick": OnAnswerSourceClickCallbackProps; - "chatMarkdownLinkClicked": OnChatMarkdownLinkClickedCallbackProps; - } - interface HTMLOramaChatBoxElement extends Components.OramaChatBox, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaChatBoxElement, ev: OramaChatBoxCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaChatBoxElement, ev: OramaChatBoxCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaChatBoxElement: { - prototype: HTMLOramaChatBoxElement; - new (): HTMLOramaChatBoxElement; - }; - interface HTMLOramaChatButtonElement extends Components.OramaChatButton, HTMLStencilElement { - } - var HTMLOramaChatButtonElement: { - prototype: HTMLOramaChatButtonElement; - new (): HTMLOramaChatButtonElement; - }; - interface HTMLOramaChatMessagesContainerElementEventMap { - "answerGenerated": OnAnswerGeneratedCallbackProps; - } - interface HTMLOramaChatMessagesContainerElement extends Components.OramaChatMessagesContainer, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaChatMessagesContainerElement, ev: OramaChatMessagesContainerCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaChatMessagesContainerElement, ev: OramaChatMessagesContainerCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaChatMessagesContainerElement: { - prototype: HTMLOramaChatMessagesContainerElement; - new (): HTMLOramaChatMessagesContainerElement; - }; - interface HTMLOramaChatUserMessageElement extends Components.OramaChatUserMessage, HTMLStencilElement { - } - var HTMLOramaChatUserMessageElement: { - prototype: HTMLOramaChatUserMessageElement; - new (): HTMLOramaChatUserMessageElement; - }; - interface HTMLOramaDotsLoaderElement extends Components.OramaDotsLoader, HTMLStencilElement { - } - var HTMLOramaDotsLoaderElement: { - prototype: HTMLOramaDotsLoaderElement; - new (): HTMLOramaDotsLoaderElement; - }; - interface HTMLOramaEmbedElement extends Components.OramaEmbed, HTMLStencilElement { - } - var HTMLOramaEmbedElement: { - prototype: HTMLOramaEmbedElement; - new (): HTMLOramaEmbedElement; - }; - interface HTMLOramaFacetsElement extends Components.OramaFacets, HTMLStencilElement { - } - var HTMLOramaFacetsElement: { - prototype: HTMLOramaFacetsElement; - new (): HTMLOramaFacetsElement; - }; - interface HTMLOramaFooterElement extends Components.OramaFooter, HTMLStencilElement { - } - var HTMLOramaFooterElement: { - prototype: HTMLOramaFooterElement; - new (): HTMLOramaFooterElement; - }; - interface HTMLOramaInputElementEventMap { - "resetValue": void; - } - interface HTMLOramaInputElement extends Components.OramaInput, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaInputElement, ev: OramaInputCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaInputElement, ev: OramaInputCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaInputElement: { - prototype: HTMLOramaInputElement; - new (): HTMLOramaInputElement; - }; - interface HTMLOramaLogoIconElement extends Components.OramaLogoIcon, HTMLStencilElement { - } - var HTMLOramaLogoIconElement: { - prototype: HTMLOramaLogoIconElement; - new (): HTMLOramaLogoIconElement; - }; - interface HTMLOramaMarkdownElementEventMap { - "chatMarkdownLinkClicked": OnChatMarkdownLinkClickedCallbackProps; - } - interface HTMLOramaMarkdownElement extends Components.OramaMarkdown, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaMarkdownElement, ev: OramaMarkdownCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaMarkdownElement, ev: OramaMarkdownCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaMarkdownElement: { - prototype: HTMLOramaMarkdownElement; - new (): HTMLOramaMarkdownElement; - }; - interface HTMLOramaModalElementEventMap { - "modalStatusChanged": ModalStatus; - } - interface HTMLOramaModalElement extends Components.OramaModal, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaModalElement, ev: OramaModalCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaModalElement, ev: OramaModalCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaModalElement: { - prototype: HTMLOramaModalElement; - new (): HTMLOramaModalElement; - }; - interface HTMLOramaNavigationBarElement extends Components.OramaNavigationBar, HTMLStencilElement { - } - var HTMLOramaNavigationBarElement: { - prototype: HTMLOramaNavigationBarElement; - new (): HTMLOramaNavigationBarElement; - }; - interface HTMLOramaSearchElementEventMap { - "searchCompleted": OnSearchCompletedCallbackProps; - "answerGenerated": OnAnswerGeneratedCallbackProps; - } - interface HTMLOramaSearchElement extends Components.OramaSearch, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaSearchElement, ev: OramaSearchCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaSearchElement, ev: OramaSearchCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaSearchElement: { - prototype: HTMLOramaSearchElement; - new (): HTMLOramaSearchElement; - }; - interface HTMLOramaSearchBoxElementEventMap { - "searchCompleted": OnSearchCompletedCallbackProps; - "searchResultClick": OnSearchResultClickCallbackProps; - "answerGenerated": OnAnswerGeneratedCallbackProps; - "answerSourceClick": OnAnswerSourceClickCallbackProps; - "chatMarkdownLinkClicked": OnChatMarkdownLinkClickedCallbackProps; - } - interface HTMLOramaSearchBoxElement extends Components.OramaSearchBox, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaSearchBoxElement, ev: OramaSearchBoxCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaSearchBoxElement, ev: OramaSearchBoxCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaSearchBoxElement: { - prototype: HTMLOramaSearchBoxElement; - new (): HTMLOramaSearchBoxElement; - }; - interface HTMLOramaSearchButtonElement extends Components.OramaSearchButton, HTMLStencilElement { - } - var HTMLOramaSearchButtonElement: { - prototype: HTMLOramaSearchButtonElement; - new (): HTMLOramaSearchButtonElement; - }; - interface HTMLOramaSearchResultsElementEventMap { - "searchResultClick": SearchResult; - } - interface HTMLOramaSearchResultsElement extends Components.OramaSearchResults, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaSearchResultsElement, ev: OramaSearchResultsCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaSearchResultsElement, ev: OramaSearchResultsCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaSearchResultsElement: { - prototype: HTMLOramaSearchResultsElement; - new (): HTMLOramaSearchResultsElement; - }; - interface HTMLOramaSlidingPanelElement extends Components.OramaSlidingPanel, HTMLStencilElement { - } - var HTMLOramaSlidingPanelElement: { - prototype: HTMLOramaSlidingPanelElement; - new (): HTMLOramaSlidingPanelElement; - }; - interface HTMLOramaSourcesElementEventMap { - "answerSourceClick": SearchResult; - } - interface HTMLOramaSourcesElement extends Components.OramaSources, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLOramaSourcesElement, ev: OramaSourcesCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLOramaSourcesElement, ev: OramaSourcesCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLOramaSourcesElement: { - prototype: HTMLOramaSourcesElement; - new (): HTMLOramaSourcesElement; - }; - interface HTMLOramaSuggestionsElement extends Components.OramaSuggestions, HTMLStencilElement { - } - var HTMLOramaSuggestionsElement: { - prototype: HTMLOramaSuggestionsElement; - new (): HTMLOramaSuggestionsElement; - }; - interface HTMLOramaTextElement extends Components.OramaText, HTMLStencilElement { - } - var HTMLOramaTextElement: { - prototype: HTMLOramaTextElement; - new (): HTMLOramaTextElement; - }; - interface HTMLOramaTextareaElement extends Components.OramaTextarea, HTMLStencilElement { - } - var HTMLOramaTextareaElement: { - prototype: HTMLOramaTextareaElement; - new (): HTMLOramaTextareaElement; - }; - interface HTMLOramaTogglerElement extends Components.OramaToggler, HTMLStencilElement { - } - var HTMLOramaTogglerElement: { - prototype: HTMLOramaTogglerElement; - new (): HTMLOramaTogglerElement; - }; - interface HTMLElementTagNameMap { - "orama-button": HTMLOramaButtonElement; - "orama-chat": HTMLOramaChatElement; - "orama-chat-assistent-message": HTMLOramaChatAssistentMessageElement; - "orama-chat-box": HTMLOramaChatBoxElement; - "orama-chat-button": HTMLOramaChatButtonElement; - "orama-chat-messages-container": HTMLOramaChatMessagesContainerElement; - "orama-chat-user-message": HTMLOramaChatUserMessageElement; - "orama-dots-loader": HTMLOramaDotsLoaderElement; - "orama-embed": HTMLOramaEmbedElement; - "orama-facets": HTMLOramaFacetsElement; - "orama-footer": HTMLOramaFooterElement; - "orama-input": HTMLOramaInputElement; - "orama-logo-icon": HTMLOramaLogoIconElement; - "orama-markdown": HTMLOramaMarkdownElement; - "orama-modal": HTMLOramaModalElement; - "orama-navigation-bar": HTMLOramaNavigationBarElement; - "orama-search": HTMLOramaSearchElement; - "orama-search-box": HTMLOramaSearchBoxElement; - "orama-search-button": HTMLOramaSearchButtonElement; - "orama-search-results": HTMLOramaSearchResultsElement; - "orama-sliding-panel": HTMLOramaSlidingPanelElement; - "orama-sources": HTMLOramaSourcesElement; - "orama-suggestions": HTMLOramaSuggestionsElement; - "orama-text": HTMLOramaTextElement; - "orama-textarea": HTMLOramaTextareaElement; - "orama-toggler": HTMLOramaTogglerElement; - } + interface HTMLOramaButtonElement extends Components.OramaButton, HTMLStencilElement { + } + + var HTMLOramaButtonElement: { + prototype: HTMLOramaButtonElement; + new(): HTMLOramaButtonElement; + } + + interface HTMLOramaChatElementEventMap { + "answerGenerated": OnAnswerGeneratedCallbackProps; + } + + interface HTMLOramaChatElement extends Components.OramaChat, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaChatElement, ev: OramaChatCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaChatElement, ev: OramaChatCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaChatElement: { + prototype: HTMLOramaChatElement; + new(): HTMLOramaChatElement; + } + + interface HTMLOramaChatAssistentMessageElement extends Components.OramaChatAssistentMessage, HTMLStencilElement { + } + + var HTMLOramaChatAssistentMessageElement: { + prototype: HTMLOramaChatAssistentMessageElement; + new(): HTMLOramaChatAssistentMessageElement; + } + + interface HTMLOramaChatBoxElementEventMap { + "answerGenerated": OnAnswerGeneratedCallbackProps; + "answerSourceClick": OnAnswerSourceClickCallbackProps; + "chatMarkdownLinkClicked": OnChatMarkdownLinkClickedCallbackProps; + } + + interface HTMLOramaChatBoxElement extends Components.OramaChatBox, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaChatBoxElement, ev: OramaChatBoxCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaChatBoxElement, ev: OramaChatBoxCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaChatBoxElement: { + prototype: HTMLOramaChatBoxElement; + new(): HTMLOramaChatBoxElement; + } + + interface HTMLOramaChatButtonElement extends Components.OramaChatButton, HTMLStencilElement { + } + + var HTMLOramaChatButtonElement: { + prototype: HTMLOramaChatButtonElement; + new(): HTMLOramaChatButtonElement; + } + + interface HTMLOramaChatMessagesContainerElementEventMap { + "answerGenerated": OnAnswerGeneratedCallbackProps; + } + + interface HTMLOramaChatMessagesContainerElement extends Components.OramaChatMessagesContainer, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaChatMessagesContainerElement, ev: OramaChatMessagesContainerCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaChatMessagesContainerElement, ev: OramaChatMessagesContainerCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaChatMessagesContainerElement: { + prototype: HTMLOramaChatMessagesContainerElement; + new(): HTMLOramaChatMessagesContainerElement; + } + + interface HTMLOramaChatUserMessageElement extends Components.OramaChatUserMessage, HTMLStencilElement { + } + + var HTMLOramaChatUserMessageElement: { + prototype: HTMLOramaChatUserMessageElement; + new(): HTMLOramaChatUserMessageElement; + } + + interface HTMLOramaDotsLoaderElement extends Components.OramaDotsLoader, HTMLStencilElement { + } + + var HTMLOramaDotsLoaderElement: { + prototype: HTMLOramaDotsLoaderElement; + new(): HTMLOramaDotsLoaderElement; + } + + interface HTMLOramaEmbedElement extends Components.OramaEmbed, HTMLStencilElement { + } + + var HTMLOramaEmbedElement: { + prototype: HTMLOramaEmbedElement; + new(): HTMLOramaEmbedElement; + } + + interface HTMLOramaFacetsElement extends Components.OramaFacets, HTMLStencilElement { + } + + var HTMLOramaFacetsElement: { + prototype: HTMLOramaFacetsElement; + new(): HTMLOramaFacetsElement; + } + + interface HTMLOramaFooterElement extends Components.OramaFooter, HTMLStencilElement { + } + + var HTMLOramaFooterElement: { + prototype: HTMLOramaFooterElement; + new(): HTMLOramaFooterElement; + } + + interface HTMLOramaInputElementEventMap { + "resetValue": void; + } + + interface HTMLOramaInputElement extends Components.OramaInput, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaInputElement, ev: OramaInputCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaInputElement, ev: OramaInputCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaInputElement: { + prototype: HTMLOramaInputElement; + new(): HTMLOramaInputElement; + } + + interface HTMLOramaLogoIconElement extends Components.OramaLogoIcon, HTMLStencilElement { + } + + var HTMLOramaLogoIconElement: { + prototype: HTMLOramaLogoIconElement; + new(): HTMLOramaLogoIconElement; + } + + interface HTMLOramaMarkdownElementEventMap { + "chatMarkdownLinkClicked": OnChatMarkdownLinkClickedCallbackProps; + } + + interface HTMLOramaMarkdownElement extends Components.OramaMarkdown, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaMarkdownElement, ev: OramaMarkdownCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaMarkdownElement, ev: OramaMarkdownCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaMarkdownElement: { + prototype: HTMLOramaMarkdownElement; + new(): HTMLOramaMarkdownElement; + } + + interface HTMLOramaModalElementEventMap { + "modalStatusChanged": ModalStatus; + } + + interface HTMLOramaModalElement extends Components.OramaModal, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaModalElement, ev: OramaModalCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaModalElement, ev: OramaModalCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaModalElement: { + prototype: HTMLOramaModalElement; + new(): HTMLOramaModalElement; + } + + interface HTMLOramaNavigationBarElement extends Components.OramaNavigationBar, HTMLStencilElement { + } + + var HTMLOramaNavigationBarElement: { + prototype: HTMLOramaNavigationBarElement; + new(): HTMLOramaNavigationBarElement; + } + + interface HTMLOramaSearchElementEventMap { + "searchCompleted": OnSearchCompletedCallbackProps; + "answerGenerated": OnAnswerGeneratedCallbackProps; + } + + interface HTMLOramaSearchElement extends Components.OramaSearch, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaSearchElement, ev: OramaSearchCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaSearchElement, ev: OramaSearchCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaSearchElement: { + prototype: HTMLOramaSearchElement; + new(): HTMLOramaSearchElement; + } + + interface HTMLOramaSearchBoxElementEventMap { + "searchCompleted": OnSearchCompletedCallbackProps; + "searchResultClick": OnSearchResultClickCallbackProps; + "answerGenerated": OnAnswerGeneratedCallbackProps; + "answerSourceClick": OnAnswerSourceClickCallbackProps; + "chatMarkdownLinkClicked": OnChatMarkdownLinkClickedCallbackProps; + } + + interface HTMLOramaSearchBoxElement extends Components.OramaSearchBox, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaSearchBoxElement, ev: OramaSearchBoxCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaSearchBoxElement, ev: OramaSearchBoxCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaSearchBoxElement: { + prototype: HTMLOramaSearchBoxElement; + new(): HTMLOramaSearchBoxElement; + } + + interface HTMLOramaSearchButtonElement extends Components.OramaSearchButton, HTMLStencilElement { + } + + var HTMLOramaSearchButtonElement: { + prototype: HTMLOramaSearchButtonElement; + new(): HTMLOramaSearchButtonElement; + } + + interface HTMLOramaSearchResultsElementEventMap { + "searchResultClick": SearchResult; + } + + interface HTMLOramaSearchResultsElement extends Components.OramaSearchResults, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaSearchResultsElement, ev: OramaSearchResultsCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaSearchResultsElement, ev: OramaSearchResultsCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaSearchResultsElement: { + prototype: HTMLOramaSearchResultsElement; + new(): HTMLOramaSearchResultsElement; + } + + interface HTMLOramaSlidingPanelElement extends Components.OramaSlidingPanel, HTMLStencilElement { + } + + var HTMLOramaSlidingPanelElement: { + prototype: HTMLOramaSlidingPanelElement; + new(): HTMLOramaSlidingPanelElement; + } + + interface HTMLOramaSourcesElementEventMap { + "answerSourceClick": SearchResult; + } + + interface HTMLOramaSourcesElement extends Components.OramaSources, HTMLStencilElement { + addEventListener(type: K, listener: (this: HTMLOramaSourcesElement, ev: OramaSourcesCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLOramaSourcesElement, ev: OramaSourcesCustomEvent) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + } + + var HTMLOramaSourcesElement: { + prototype: HTMLOramaSourcesElement; + new(): HTMLOramaSourcesElement; + } + + interface HTMLOramaSuggestionsElement extends Components.OramaSuggestions, HTMLStencilElement { + } + + var HTMLOramaSuggestionsElement: { + prototype: HTMLOramaSuggestionsElement; + new(): HTMLOramaSuggestionsElement; + } + + interface HTMLOramaTextElement extends Components.OramaText, HTMLStencilElement { + } + + var HTMLOramaTextElement: { + prototype: HTMLOramaTextElement; + new(): HTMLOramaTextElement; + } + + interface HTMLOramaTextareaElement extends Components.OramaTextarea, HTMLStencilElement { + } + + var HTMLOramaTextareaElement: { + prototype: HTMLOramaTextareaElement; + new(): HTMLOramaTextareaElement; + } + + interface HTMLOramaTogglerElement extends Components.OramaToggler, HTMLStencilElement { + } + + var HTMLOramaTogglerElement: { + prototype: HTMLOramaTogglerElement; + new(): HTMLOramaTogglerElement; + } + + interface HTMLElementTagNameMap { + "orama-button": HTMLOramaButtonElement; + "orama-chat": HTMLOramaChatElement; + "orama-chat-assistent-message": HTMLOramaChatAssistentMessageElement; + "orama-chat-box": HTMLOramaChatBoxElement; + "orama-chat-button": HTMLOramaChatButtonElement; + "orama-chat-messages-container": HTMLOramaChatMessagesContainerElement; + "orama-chat-user-message": HTMLOramaChatUserMessageElement; + "orama-dots-loader": HTMLOramaDotsLoaderElement; + "orama-embed": HTMLOramaEmbedElement; + "orama-facets": HTMLOramaFacetsElement; + "orama-footer": HTMLOramaFooterElement; + "orama-input": HTMLOramaInputElement; + "orama-logo-icon": HTMLOramaLogoIconElement; + "orama-markdown": HTMLOramaMarkdownElement; + "orama-modal": HTMLOramaModalElement; + "orama-navigation-bar": HTMLOramaNavigationBarElement; + "orama-search": HTMLOramaSearchElement; + "orama-search-box": HTMLOramaSearchBoxElement; + "orama-search-button": HTMLOramaSearchButtonElement; + "orama-search-results": HTMLOramaSearchResultsElement; + "orama-sliding-panel": HTMLOramaSlidingPanelElement; + "orama-sources": HTMLOramaSourcesElement; + "orama-suggestions": HTMLOramaSuggestionsElement; + "orama-text": HTMLOramaTextElement; + "orama-textarea": HTMLOramaTextareaElement; + "orama-toggler": HTMLOramaTogglerElement; + } } declare namespace LocalJSX { - interface OramaButton { - "as"?: ButtonProps['as']; - "class"?: string; - "disabled"?: boolean; - "size"?: 'small' | 'medium' | 'large'; - "type"?: ButtonProps['type']; - "variant"?: ButtonProps['variant']; - "withTooltip"?: string; - } - interface OramaChat { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "defaultTerm"?: string; - "focusInput"?: boolean; - "linksRel"?: string; - "linksTarget"?: string; - "onAnswerGenerated"?: (event: OramaChatCustomEvent) => void; - "placeholder"?: string; - "showClearChat"?: boolean; - "sourceBaseUrl"?: string; - "sourcesMap"?: SourcesMap; - "suggestions"?: string[]; - "systemPrompts"?: string[]; - } - interface OramaChatAssistentMessage { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "interaction"?: TChatInteraction; - } - interface OramaChatBox { - "autoFocus"?: boolean; - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "clientInstance"?: OramaClient; - "index"?: CloudIndexConfig; - "linksRel"?: string; - "linksTarget"?: string; - /** - * Fired when answer generation is successfully completed - */ - "onAnswerGenerated"?: (event: OramaChatBoxCustomEvent) => void; - /** - * Fired when user clicks on answer source - */ - "onAnswerSourceClick"?: (event: OramaChatBoxCustomEvent) => void; - /** - * Fired when user clicks on chat markdown link - */ - "onChatMarkdownLinkClicked"?: (event: OramaChatBoxCustomEvent) => void; - "placeholder"?: string; - "sourceBaseUrl"?: string; - "sourcesMap"?: SourcesMap; - "suggestions"?: string[]; - "systemPrompts"?: string[]; - } - interface OramaChatButton { - "active"?: boolean; - "class"?: string; - "highlight"?: boolean; - "label"?: string; - } - interface OramaChatMessagesContainer { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "interactions"?: TChatInteraction[]; - "onAnswerGenerated"?: (event: OramaChatMessagesContainerCustomEvent) => void; - } - interface OramaChatUserMessage { - "interaction"?: TChatInteraction; - } - interface OramaDotsLoader { - } - interface OramaEmbed { - } - interface OramaFacets { - "facetClicked"?: (facetName: string) => void; - "facets"?: Facet[]; - "selectedFacet"?: string; - } - interface OramaFooter { - "class"?: string; - "colorScheme"?: Omit; - } - interface OramaInput { - "autoFocus"?: boolean; - "defaultValue"?: InputProps['defaultValue']; - "label"?: InputProps['label']; - "labelForScreenReaders"?: InputProps['labelForScreenReaders']; - "name"?: InputProps['name']; - "onResetValue"?: (event: OramaInputCustomEvent) => void; - "placeholder"?: InputProps['placeholder']; - "size"?: InputProps['size']; - "type"?: InputProps['type']; - } - interface OramaLogoIcon { - "size"?: number; - } - interface OramaMarkdown { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "content"?: string; - "onChatMarkdownLinkClicked"?: (event: OramaMarkdownCustomEvent) => void; - } - interface OramaModal { - "closeOnEscape"?: boolean; - "closeOnOutsideClick"?: boolean; - "mainTitle"?: string; - "onModalStatusChanged"?: (event: OramaModalCustomEvent) => void; - "open"?: boolean; - } - interface OramaNavigationBar { - "handleClose"?: () => void; - "showBackButton"?: boolean; - "showChatActions"?: boolean; - } - interface OramaSearch { - "disableChat"?: boolean; - "focusInput"?: boolean; - "highlightDescription"?: HighlightOptions | false; - "highlightTitle"?: HighlightOptions | false; - "linksRel"?: string; - "linksTarget"?: string; - "onAnswerGenerated"?: (event: OramaSearchCustomEvent) => void; - "onSearchCompleted"?: (event: OramaSearchCustomEvent) => void; - "placeholder"?: string; - "sourceBaseUrl"?: string; - "suggestions"?: string[]; - } - interface OramaSearchBox { - "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; - "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; - "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; - "chatPlaceholder"?: string; - "clientInstance"?: OramaClient; - "colorScheme"?: ColorScheme; - "disableChat"?: boolean; - "facetProperty"?: string; - "highlightDescription"?: HighlightOptions | false; - "highlightTitle"?: HighlightOptions | false; - "index"?: CloudIndexConfig; - "layout"?: 'modal' | 'embed'; - "linksRel"?: string; - "linksTarget"?: string; - /** - * Fired when answer generation is successfully completed - */ - "onAnswerGenerated"?: (event: OramaSearchBoxCustomEvent) => void; - /** - * Fired when user clicks on answer source - */ - "onAnswerSourceClick"?: (event: OramaSearchBoxCustomEvent) => void; - /** - * Fired when user clicks on chat markdown link - */ - "onChatMarkdownLinkClicked"?: (event: OramaSearchBoxCustomEvent) => void; - /** - * Fired when search successfully resolves - */ - "onSearchCompleted"?: (event: OramaSearchBoxCustomEvent) => void; - /** - * Fired when user clicks on search result - */ - "onSearchResultClick"?: (event: OramaSearchBoxCustomEvent) => void; - "open"?: boolean; - "placeholder"?: string; - "resultMap"?: Partial; - "searchParams"?: SearchParams>; - "searchPlaceholder"?: string; - "sourceBaseUrl"?: string; - "sourcesMap"?: SourcesMap; - "suggestions"?: string[]; - "themeConfig"?: Partial; - } - interface OramaSearchButton { - "colorScheme"?: ColorScheme; - "size"?: 'small' | 'medium' | 'large'; - "themeConfig"?: Partial; - } - interface OramaSearchResults { - "error"?: boolean; - "highlightDescription"?: HighlightOptions | false; - "highlightTitle"?: HighlightOptions | false; - "linksRel"?: string; - "linksTarget"?: string; - "loading"?: boolean; - "onSearchResultClick"?: (event: OramaSearchResultsCustomEvent) => void; - "searchTerm"?: SearchResultsProps['searchTerm']; - "sections"?: SearchResultBySection[]; - "setChatTerm"?: (term: string) => void; - "sourceBaseUrl"?: string; - "suggestions"?: string[]; - } - interface OramaSlidingPanel { - "backdrop"?: boolean; - "closed"?: () => void; - "open"?: boolean; - } - interface OramaSources { - "linksRel"?: string; - "linksTarget"?: string; - "onAnswerSourceClick"?: (event: OramaSourcesCustomEvent) => void; - "sourceBaseURL"?: string; - "sources"?: any; - "sourcesMap"?: SourcesMap; - } - interface OramaSuggestions { - "as"?: 'chips' | 'list'; - "icon"?: Node; - "suggestionClicked"?: (suggestion: string) => void; - "suggestions"?: string[]; - } - interface OramaText { - /** - * optionally change text alignment - */ - "align"?: TextProps['align']; - /** - * it defines the HTML tag to be used - */ - "as"?: TextProps['as']; - "bold"?: boolean; - /** - * the optional class name - */ - "class"?: string; - /** - * show as inactive - */ - "inactive"?: TextProps['inactive']; - /** - * it defines how it should look like - */ - "styledAs"?: TextProps['styledAs']; - /** - * optionally change variant style - default is primary - */ - "variant"?: TextProps['variant']; - } - interface OramaTextarea { - "autoFocus"?: boolean; - "maxRows"?: number | string; - "minRows"?: number | string; - "placeholder"?: string; - "value"?: string | null; - } - interface OramaToggler { - "performInitialAnimation"?: boolean; - } - interface IntrinsicElements { - "orama-button": OramaButton; - "orama-chat": OramaChat; - "orama-chat-assistent-message": OramaChatAssistentMessage; - "orama-chat-box": OramaChatBox; - "orama-chat-button": OramaChatButton; - "orama-chat-messages-container": OramaChatMessagesContainer; - "orama-chat-user-message": OramaChatUserMessage; - "orama-dots-loader": OramaDotsLoader; - "orama-embed": OramaEmbed; - "orama-facets": OramaFacets; - "orama-footer": OramaFooter; - "orama-input": OramaInput; - "orama-logo-icon": OramaLogoIcon; - "orama-markdown": OramaMarkdown; - "orama-modal": OramaModal; - "orama-navigation-bar": OramaNavigationBar; - "orama-search": OramaSearch; - "orama-search-box": OramaSearchBox; - "orama-search-button": OramaSearchButton; - "orama-search-results": OramaSearchResults; - "orama-sliding-panel": OramaSlidingPanel; - "orama-sources": OramaSources; - "orama-suggestions": OramaSuggestions; - "orama-text": OramaText; - "orama-textarea": OramaTextarea; - "orama-toggler": OramaToggler; - } + interface OramaButton { + "as"?: ButtonProps["as"]; + "class"?: string; + "disabled"?: boolean; + "size"?: "small" | "medium" | "large"; + "type"?: ButtonProps["type"]; + "variant"?: ButtonProps["variant"]; + "withTooltip"?: string; + } + + interface OramaChat { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "defaultTerm"?: string; + "focusInput"?: boolean; + "linksRel"?: string; + "linksTarget"?: string; + "onAnswerGenerated"?: (event: OramaChatCustomEvent) => void; + "placeholder"?: string; + "showClearChat"?: boolean; + "sourceBaseUrl"?: string; + "sourcesMap"?: SourcesMap; + "suggestions"?: string[]; + "systemPrompts"?: string[]; + } + + interface OramaChatAssistentMessage { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "interaction"?: TChatInteraction; + } + + interface OramaChatBox { + "autoFocus"?: boolean; + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "clientInstance"?: OramaClient | AnyOrama; + "index"?: CloudIndexConfig; + "linksRel"?: string; + "linksTarget"?: string; + /** + * Fired when answer generation is successfully completed + */ + "onAnswerGenerated"?: (event: OramaChatBoxCustomEvent) => void; + /** + * Fired when user clicks on answer source + */ + "onAnswerSourceClick"?: (event: OramaChatBoxCustomEvent) => void; + /** + * Fired when user clicks on chat markdown link + */ + "onChatMarkdownLinkClicked"?: (event: OramaChatBoxCustomEvent) => void; + "placeholder"?: string; + "sourceBaseUrl"?: string; + "sourcesMap"?: SourcesMap; + "suggestions"?: string[]; + "systemPrompts"?: string[]; + } + + interface OramaChatButton { + "active"?: boolean; + "class"?: string; + "highlight"?: boolean; + "label"?: string; + } + + interface OramaChatMessagesContainer { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "interactions"?: TChatInteraction[]; + "onAnswerGenerated"?: (event: OramaChatMessagesContainerCustomEvent) => void; + } + + interface OramaChatUserMessage { + "interaction"?: TChatInteraction; + } + + interface OramaDotsLoader { + } + + interface OramaEmbed { + } + + interface OramaFacets { + "facetClicked"?: (facetName: string) => void; + "facets"?: Facet[]; + "selectedFacet"?: string; + } + + interface OramaFooter { + "class"?: string; + "colorScheme"?: Omit; + } + + interface OramaInput { + "autoFocus"?: boolean; + "defaultValue"?: InputProps["defaultValue"]; + "label"?: InputProps["label"]; + "labelForScreenReaders"?: InputProps["labelForScreenReaders"]; + "name"?: InputProps["name"]; + "onResetValue"?: (event: OramaInputCustomEvent) => void; + "placeholder"?: InputProps["placeholder"]; + "size"?: InputProps["size"]; + "type"?: InputProps["type"]; + } + + interface OramaLogoIcon { + "size"?: number; + } + + interface OramaMarkdown { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "content"?: string; + "onChatMarkdownLinkClicked"?: (event: OramaMarkdownCustomEvent) => void; + } + + interface OramaModal { + "closeOnEscape"?: boolean; + "closeOnOutsideClick"?: boolean; + "mainTitle"?: string; + "onModalStatusChanged"?: (event: OramaModalCustomEvent) => void; + "open"?: boolean; + } + + interface OramaNavigationBar { + "handleClose"?: () => void; + "showBackButton"?: boolean; + "showChatActions"?: boolean; + } + + interface OramaSearch { + "disableChat"?: boolean; + "focusInput"?: boolean; + "highlightDescription"?: HighlightOptions | false; + "highlightTitle"?: HighlightOptions | false; + "linksRel"?: string; + "linksTarget"?: string; + "onAnswerGenerated"?: (event: OramaSearchCustomEvent) => void; + "onSearchCompleted"?: (event: OramaSearchCustomEvent) => void; + "placeholder"?: string; + "sourceBaseUrl"?: string; + "suggestions"?: string[]; + } + + interface OramaSearchBox { + "chatMarkdownLinkHref"?: ChatMarkdownLinkHref; + "chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget; + "chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle; + "chatPlaceholder"?: string; + "clientInstance"?: OramaClient | AnyOrama; + "colorScheme"?: ColorScheme; + "disableChat"?: boolean; + "facetProperty"?: string; + "highlightDescription"?: HighlightOptions | false; + "highlightTitle"?: HighlightOptions | false; + "index"?: CloudIndexConfig; + "layout"?: "modal" | "embed"; + "linksRel"?: string; + "linksTarget"?: string; + /** + * Fired when answer generation is successfully completed + */ + "onAnswerGenerated"?: (event: OramaSearchBoxCustomEvent) => void; + /** + * Fired when user clicks on answer source + */ + "onAnswerSourceClick"?: (event: OramaSearchBoxCustomEvent) => void; + /** + * Fired when user clicks on chat markdown link + */ + "onChatMarkdownLinkClicked"?: (event: OramaSearchBoxCustomEvent) => void; + /** + * Fired when search successfully resolves + */ + "onSearchCompleted"?: (event: OramaSearchBoxCustomEvent) => void; + /** + * Fired when user clicks on search result + */ + "onSearchResultClick"?: (event: OramaSearchBoxCustomEvent) => void; + "open"?: boolean; + "placeholder"?: string; + "resultMap"?: Partial; + "searchParams"?: SearchParams>; + "searchPlaceholder"?: string; + "sourceBaseUrl"?: string; + "sourcesMap"?: SourcesMap; + "suggestions"?: string[]; + "themeConfig"?: Partial; + } + + interface OramaSearchButton { + "colorScheme"?: ColorScheme; + "size"?: "small" | "medium" | "large"; + "themeConfig"?: Partial; + } + + interface OramaSearchResults { + "error"?: boolean; + "highlightDescription"?: HighlightOptions | false; + "highlightTitle"?: HighlightOptions | false; + "linksRel"?: string; + "linksTarget"?: string; + "loading"?: boolean; + "onSearchResultClick"?: (event: OramaSearchResultsCustomEvent) => void; + "searchTerm"?: SearchResultsProps["searchTerm"]; + "sections"?: SearchResultBySection[]; + "setChatTerm"?: (term: string) => void; + "sourceBaseUrl"?: string; + "suggestions"?: string[]; + } + + interface OramaSlidingPanel { + "backdrop"?: boolean; + "closed"?: () => void; + "open"?: boolean; + } + + interface OramaSources { + "linksRel"?: string; + "linksTarget"?: string; + "onAnswerSourceClick"?: (event: OramaSourcesCustomEvent) => void; + "sourceBaseURL"?: string; + "sources"?: any; + "sourcesMap"?: SourcesMap; + } + + interface OramaSuggestions { + "as"?: "chips" | "list"; + "icon"?: Node; + "suggestionClicked"?: (suggestion: string) => void; + "suggestions"?: string[]; + } + + interface OramaText { + /** + * optionally change text alignment + */ + "align"?: TextProps["align"]; + /** + * it defines the HTML tag to be used + */ + "as"?: TextProps["as"]; + "bold"?: boolean; + /** + * the optional class name + */ + "class"?: string; + /** + * show as inactive + */ + "inactive"?: TextProps["inactive"]; + /** + * it defines how it should look like + */ + "styledAs"?: TextProps["styledAs"]; + /** + * optionally change variant style - default is primary + */ + "variant"?: TextProps["variant"]; + } + + interface OramaTextarea { + "autoFocus"?: boolean; + "maxRows"?: number | string; + "minRows"?: number | string; + "placeholder"?: string; + "value"?: string | null; + } + + interface OramaToggler { + "performInitialAnimation"?: boolean; + } + + interface IntrinsicElements { + "orama-button": OramaButton; + "orama-chat": OramaChat; + "orama-chat-assistent-message": OramaChatAssistentMessage; + "orama-chat-box": OramaChatBox; + "orama-chat-button": OramaChatButton; + "orama-chat-messages-container": OramaChatMessagesContainer; + "orama-chat-user-message": OramaChatUserMessage; + "orama-dots-loader": OramaDotsLoader; + "orama-embed": OramaEmbed; + "orama-facets": OramaFacets; + "orama-footer": OramaFooter; + "orama-input": OramaInput; + "orama-logo-icon": OramaLogoIcon; + "orama-markdown": OramaMarkdown; + "orama-modal": OramaModal; + "orama-navigation-bar": OramaNavigationBar; + "orama-search": OramaSearch; + "orama-search-box": OramaSearchBox; + "orama-search-button": OramaSearchButton; + "orama-search-results": OramaSearchResults; + "orama-sliding-panel": OramaSlidingPanel; + "orama-sources": OramaSources; + "orama-suggestions": OramaSuggestions; + "orama-text": OramaText; + "orama-textarea": OramaTextarea; + "orama-toggler": OramaToggler; + } } -export { LocalJSX as JSX }; +export { LocalJSX as JSX } declare module "@stencil/core" { - export namespace JSX { - interface IntrinsicElements { - "orama-button": LocalJSX.OramaButton & JSXBase.HTMLAttributes; - "orama-chat": LocalJSX.OramaChat & JSXBase.HTMLAttributes; - "orama-chat-assistent-message": LocalJSX.OramaChatAssistentMessage & JSXBase.HTMLAttributes; - "orama-chat-box": LocalJSX.OramaChatBox & JSXBase.HTMLAttributes; - "orama-chat-button": LocalJSX.OramaChatButton & JSXBase.HTMLAttributes; - "orama-chat-messages-container": LocalJSX.OramaChatMessagesContainer & JSXBase.HTMLAttributes; - "orama-chat-user-message": LocalJSX.OramaChatUserMessage & JSXBase.HTMLAttributes; - "orama-dots-loader": LocalJSX.OramaDotsLoader & JSXBase.HTMLAttributes; - "orama-embed": LocalJSX.OramaEmbed & JSXBase.HTMLAttributes; - "orama-facets": LocalJSX.OramaFacets & JSXBase.HTMLAttributes; - "orama-footer": LocalJSX.OramaFooter & JSXBase.HTMLAttributes; - "orama-input": LocalJSX.OramaInput & JSXBase.HTMLAttributes; - "orama-logo-icon": LocalJSX.OramaLogoIcon & JSXBase.HTMLAttributes; - "orama-markdown": LocalJSX.OramaMarkdown & JSXBase.HTMLAttributes; - "orama-modal": LocalJSX.OramaModal & JSXBase.HTMLAttributes; - "orama-navigation-bar": LocalJSX.OramaNavigationBar & JSXBase.HTMLAttributes; - "orama-search": LocalJSX.OramaSearch & JSXBase.HTMLAttributes; - "orama-search-box": LocalJSX.OramaSearchBox & JSXBase.HTMLAttributes; - "orama-search-button": LocalJSX.OramaSearchButton & JSXBase.HTMLAttributes; - "orama-search-results": LocalJSX.OramaSearchResults & JSXBase.HTMLAttributes; - "orama-sliding-panel": LocalJSX.OramaSlidingPanel & JSXBase.HTMLAttributes; - "orama-sources": LocalJSX.OramaSources & JSXBase.HTMLAttributes; - "orama-suggestions": LocalJSX.OramaSuggestions & JSXBase.HTMLAttributes; - "orama-text": LocalJSX.OramaText & JSXBase.HTMLAttributes; - "orama-textarea": LocalJSX.OramaTextarea & JSXBase.HTMLAttributes; - "orama-toggler": LocalJSX.OramaToggler & JSXBase.HTMLAttributes; - } - } + export namespace JSX { + interface IntrinsicElements { + "orama-button": LocalJSX.OramaButton & JSXBase.HTMLAttributes; + "orama-chat": LocalJSX.OramaChat & JSXBase.HTMLAttributes; + "orama-chat-assistent-message": LocalJSX.OramaChatAssistentMessage & JSXBase.HTMLAttributes; + "orama-chat-box": LocalJSX.OramaChatBox & JSXBase.HTMLAttributes; + "orama-chat-button": LocalJSX.OramaChatButton & JSXBase.HTMLAttributes; + "orama-chat-messages-container": LocalJSX.OramaChatMessagesContainer & JSXBase.HTMLAttributes; + "orama-chat-user-message": LocalJSX.OramaChatUserMessage & JSXBase.HTMLAttributes; + "orama-dots-loader": LocalJSX.OramaDotsLoader & JSXBase.HTMLAttributes; + "orama-embed": LocalJSX.OramaEmbed & JSXBase.HTMLAttributes; + "orama-facets": LocalJSX.OramaFacets & JSXBase.HTMLAttributes; + "orama-footer": LocalJSX.OramaFooter & JSXBase.HTMLAttributes; + "orama-input": LocalJSX.OramaInput & JSXBase.HTMLAttributes; + "orama-logo-icon": LocalJSX.OramaLogoIcon & JSXBase.HTMLAttributes; + "orama-markdown": LocalJSX.OramaMarkdown & JSXBase.HTMLAttributes; + "orama-modal": LocalJSX.OramaModal & JSXBase.HTMLAttributes; + "orama-navigation-bar": LocalJSX.OramaNavigationBar & JSXBase.HTMLAttributes; + "orama-search": LocalJSX.OramaSearch & JSXBase.HTMLAttributes; + "orama-search-box": LocalJSX.OramaSearchBox & JSXBase.HTMLAttributes; + "orama-search-button": LocalJSX.OramaSearchButton & JSXBase.HTMLAttributes; + "orama-search-results": LocalJSX.OramaSearchResults & JSXBase.HTMLAttributes; + "orama-sliding-panel": LocalJSX.OramaSlidingPanel & JSXBase.HTMLAttributes; + "orama-sources": LocalJSX.OramaSources & JSXBase.HTMLAttributes; + "orama-suggestions": LocalJSX.OramaSuggestions & JSXBase.HTMLAttributes; + "orama-text": LocalJSX.OramaText & JSXBase.HTMLAttributes; + "orama-textarea": LocalJSX.OramaTextarea & JSXBase.HTMLAttributes; + "orama-toggler": LocalJSX.OramaToggler & JSXBase.HTMLAttributes; + } + } } diff --git a/packages/ui-stencil/src/components/orama-chat-box/orama-chat-box.tsx b/packages/ui-stencil/src/components/orama-chat-box/orama-chat-box.tsx index 13bd8144..eea83778 100644 --- a/packages/ui-stencil/src/components/orama-chat-box/orama-chat-box.tsx +++ b/packages/ui-stencil/src/components/orama-chat-box/orama-chat-box.tsx @@ -14,6 +14,7 @@ import type { } from '@/types' import type { OramaClient } from '@oramacloud/client' import '@phosphor-icons/webcomponents/dist/icons/PhArrowClockwise.mjs' +import type { AnyOrama, Orama } from "@orama/orama" @Component({ tag: 'orama-chat-box', @@ -23,7 +24,7 @@ import '@phosphor-icons/webcomponents/dist/icons/PhArrowClockwise.mjs' export class ChatBox { @Element() el: HTMLElement @Prop() index?: CloudIndexConfig - @Prop() clientInstance?: OramaClient + @Prop() clientInstance?: OramaClient | AnyOrama @Prop() sourceBaseUrl?: string @Prop() linksTarget?: string @Prop() linksRel?: string @@ -36,7 +37,6 @@ export class ChatBox { @Prop() chatMarkdownLinkHref?: ChatMarkdownLinkHref @Prop() chatMarkdownLinkTarget?: ChatMarkdownLinkTarget - @State() oramaClient: OramaClient @State() componentID = generateRandomID('chat-box') /** @@ -66,9 +66,9 @@ export class ChatBox { startChatService() { validateCloudIndexConfig(this.el, this.index, this.clientInstance) - this.oramaClient = this.clientInstance || initOramaClient(this.index) + const oramaClient = this.clientInstance || initOramaClient(this.index) - chatContext.chatService = new ChatService(this.oramaClient) + chatContext.chatService = new ChatService(oramaClient) } render() { diff --git a/packages/ui-stencil/src/components/orama-chat-box/readme.md b/packages/ui-stencil/src/components/orama-chat-box/readme.md index 23a29821..63d74d0f 100644 --- a/packages/ui-stencil/src/components/orama-chat-box/readme.md +++ b/packages/ui-stencil/src/components/orama-chat-box/readme.md @@ -1,7 +1,5 @@ # orama-chat-box - - diff --git a/packages/ui-stencil/src/components/orama-search-box/orama-search-box.tsx b/packages/ui-stencil/src/components/orama-search-box/orama-search-box.tsx index 9582daf4..027a728f 100644 --- a/packages/ui-stencil/src/components/orama-search-box/orama-search-box.tsx +++ b/packages/ui-stencil/src/components/orama-search-box/orama-search-box.tsx @@ -25,6 +25,9 @@ import type { } from '@/types' import type { TThemeOverrides } from '@/config/theme' +// TODO: AI components should be lazyly loaded. In case of Disable AI flag, it should not be loaded at all +// https://linear.app/oramasearch/issue/ORM-1824/ai-components-should-be-lazyly-loaded-in-case-of-disable-ai-flag-they + @Component({ tag: 'orama-search-box', styleUrl: 'orama-search-box.scss', @@ -36,7 +39,7 @@ export class SearchBox { @Prop() themeConfig?: Partial @Prop() colorScheme?: ColorScheme = 'light' @Prop() index?: CloudIndexConfig - @Prop() clientInstance?: OramaClient + @Prop() clientInstance?: OramaClient | AnyOrama @Prop({ mutable: true }) open = false @Prop() facetProperty?: string @Prop() resultMap?: Partial = {} @@ -59,7 +62,6 @@ export class SearchBox { @Prop() chatMarkdownLinkHref?: ChatMarkdownLinkHref @Prop() chatMarkdownLinkTarget?: ChatMarkdownLinkTarget - @State() oramaClient: OramaClient @State() componentID = generateRandomID('search-box') @State() systemScheme: Omit = 'light' @State() windowWidth: number @@ -93,6 +95,7 @@ export class SearchBox { schemaQuery: MediaQueryList @Watch('index') + @Watch('clientInstance') indexChanged() { this.startServices() } @@ -171,10 +174,10 @@ export class SearchBox { startServices() { validateCloudIndexConfig(this.htmlElement, this.index, this.clientInstance) - this.oramaClient = this.clientInstance ? this.clientInstance : initOramaClient(this.index) + const oramaClient = this.clientInstance ? this.clientInstance : initOramaClient(this.index) - searchState.searchService = new SearchService(this.oramaClient) - chatContext.chatService = new ChatService(this.oramaClient) + searchState.searchService = new SearchService(oramaClient) + chatContext.chatService = new ChatService(oramaClient) } componentWillLoad() { diff --git a/packages/ui-stencil/src/services/ChatService.ts b/packages/ui-stencil/src/services/ChatService.ts index e0b6b734..da063708 100644 --- a/packages/ui-stencil/src/services/ChatService.ts +++ b/packages/ui-stencil/src/services/ChatService.ts @@ -1,14 +1,18 @@ -import type { OramaClient, AnswerSession, AskParams } from '@oramacloud/client' +import type { AskParams } from '@oramacloud/client' +import type { AnswerSession as OSSAnswerSession } from '@orama/orama' +import type { AnswerSession as CloudAnswerSession } from '@oramacloud/client' +import type { OramaSwitchClient } from '@orama/switch' +import { Switch } from '@orama/switch' import { OramaClientNotInitializedError } from '@/erros/OramaClientNotInitialized' import { chatContext, TAnswerStatus } from '@/context/chatContext' import type { OnAnswerGeneratedCallbackProps } from '@/types' export class ChatService { - oramaClient: OramaClient - answerSession: AnswerSession + oramaClient: Switch + answerSession: CloudAnswerSession | OSSAnswerSession - constructor(oramaClient: OramaClient) { - this.oramaClient = oramaClient + constructor(oramaClient: OramaSwitchClient) { + this.oramaClient = new Switch(oramaClient) } sendQuestion = ( @@ -45,6 +49,7 @@ export class ChatService { chatContext.interactions = normalizedState.map((interaction, index) => { const isLatest = state.length - 1 === index let answerStatus = TAnswerStatus.loading + let sources = [] if (interaction.aborted) { answerStatus = TAnswerStatus.aborted @@ -57,7 +62,15 @@ export class ChatService { } // biome-ignore lint/suspicious/noExplicitAny: Client should expose this type - const sources = (interaction.sources as any)?.map((source) => source.document) + /** + * we usually expected to receive interaction.sources as an array, but sometimes it comes as an object. + * need to check OSS Orama and fix it if it's a bug. + **/ + if (interaction.sources) { + sources = Array.isArray(interaction.sources) ? + (interaction.sources as any)?.map((source) => source.document) : + (interaction.sources.hits as any)?.map((source) => source.document) + } if (isLatest && answerStatus === TAnswerStatus.done) { callbacks?.onAnswerGeneratedCallback?.({ @@ -84,8 +97,8 @@ export class ChatService { }, }) - if (systemPrompts) { - this.answerSession.setSystemPromptConfiguration({ systemPrompts }) + if (this.oramaClient.clientType === 'cloud' && systemPrompts) { + (this.answerSession as CloudAnswerSession).setSystemPromptConfiguration({ systemPrompts }) } } diff --git a/packages/ui-stencil/src/services/SearchService.ts b/packages/ui-stencil/src/services/SearchService.ts index 88ab352f..cbbff5b0 100644 --- a/packages/ui-stencil/src/services/SearchService.ts +++ b/packages/ui-stencil/src/services/SearchService.ts @@ -1,6 +1,7 @@ -import type { OramaClient, ClientSearchParams } from '@oramacloud/client' +import type { ClientSearchParams } from '@oramacloud/client' import { OramaClientNotInitializedError } from '@/erros/OramaClientNotInitialized' import { searchState } from '@/context/searchContext' +import { Switch, type OramaSwitchClient } from '@orama/switch' import type { OnSearchCompletedCallbackProps, ResultMap, @@ -13,14 +14,15 @@ import type { const LIMIT_RESULTS = 10 // TODO: Orama Client should expose Result type -type OramaHit = { id: string; score: number; document: { title: string; description: string; path: string } } +// biome-ignore lint/suspicious/noExplicitAny: There is not way to type document as we only know what it is in runtime +type OramaHit = { id: string; score: number; document: any } export class SearchService { private abortController: AbortController - private oramaClient: OramaClient + private oramaClient: Switch - constructor(oramaClient: OramaClient) { - this.oramaClient = oramaClient + constructor(oramaClient: OramaSwitchClient) { + this.oramaClient = new Switch(oramaClient) this.abortController = new AbortController() } diff --git a/packages/ui-stencil/src/utils/utils.ts b/packages/ui-stencil/src/utils/utils.ts index 829cc85d..3fdead52 100644 --- a/packages/ui-stencil/src/utils/utils.ts +++ b/packages/ui-stencil/src/utils/utils.ts @@ -1,4 +1,6 @@ import type { CloudIndexConfig } from '@/types' +import type { AnyOrama, Orama } from '@orama/orama' +import { Switch } from '@orama/switch' import { OramaClient } from '@oramacloud/client' /** @@ -72,7 +74,11 @@ export function getNonExplicitAttributes(element: HTMLElement, explicitProps: st }, {}) } -export function validateCloudIndexConfig(el: HTMLElement, index?: CloudIndexConfig, instance?: OramaClient): void { +export function validateCloudIndexConfig( + el: HTMLElement, + index?: CloudIndexConfig, + instance?: OramaClient | AnyOrama, +): void { const componentDetails = ` Component: ${el.tagName.toLowerCase()} Id: ${el.id} @@ -85,8 +91,10 @@ export function validateCloudIndexConfig(el: HTMLElement, index?: CloudIndexConf } if (instance && !index) { + const oramaInstance = new Switch(instance) + // TODO: maybe add a validate method to the client? - instance + oramaInstance .search({ term: 'test', }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 44555ef9..dc3b1ac1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,6 +111,9 @@ importers: '@orama/react-components': specifier: workspace:* version: link:../../packages/ui-stencil-react + '@oramacloud/client': + specifier: ^2.1.4 + version: 2.1.4 react: specifier: ^18.3.1 version: 18.3.1 @@ -177,8 +180,8 @@ importers: specifier: workspace:* version: link:../../packages/ui-stencil '@oramacloud/client': - specifier: 1.3.15 - version: 1.3.15(encoding@0.1.13)(typescript@5.5.2) + specifier: ^2.1.0 + version: 2.1.4 '@storybook/preview-api': specifier: ^8.2.9 version: 8.2.9(storybook@8.2.4(@babel/preset-env@7.24.7(@babel/core@7.24.7))) @@ -282,11 +285,14 @@ importers: specifier: ^0.1.6 version: 0.1.6 '@orama/orama': - specifier: ^2.0.23 - version: 2.0.23 + specifier: ^3.0.0 + version: 3.0.1 + '@orama/switch': + specifier: ^3.0.0 + version: 3.0.2(@orama/orama@3.0.1)(@oramacloud/client@2.1.4) '@oramacloud/client': specifier: ^2.1.0 - version: 2.1.0 + version: 2.1.4 '@phosphor-icons/webcomponents': specifier: ^2.1.5 version: 2.1.5 @@ -2903,14 +2909,14 @@ packages: resolution: {integrity: sha512-18hl0MiCLmumODHjrLzSdTb1Ny3Dh8tn44jwgx0LksCdvVAsr3jQvfr+hwrE7bVkap0wPELb/dnuJjvupKxheQ==} engines: {node: '>= 16.0.0'} - '@oramacloud/client@1.3.15': - resolution: {integrity: sha512-QBgQrK0WA9pPzeVh/E6p44erwL0IJaHB3TrbEAsrduqbj38xY06jjpYsn//2fJt34jEnIBjOwPkjZ3OJEJlR4A==} - - '@oramacloud/client@2.1.0': - resolution: {integrity: sha512-P8vi8E3e/lkt9pVPbHkM7gK9l3/iB5BpQqpio0Ej3LMxNTv5SNsByThM+gMzfPsCsczva6WK6FN2wOtyzqVSfw==} + '@orama/switch@3.0.2': + resolution: {integrity: sha512-ui59rKC67rqF5rg6ncQhHCl11LDw4WZJfhsqJ2UHxxsh3S5F7LsT3a8/5MZDGKkFtj3IVqIRKF+pi0flMJxuTQ==} + peerDependencies: + '@orama/orama': 3.0.2 + '@oramacloud/client': ^2.1.1 - '@paralleldrive/cuid2@2.2.2': - resolution: {integrity: sha512-ZOBkgDwEdoYVlSeRbYYXs0S9MejQofiVYoTbKzy/6GQa39/q5tQU2IX46+shYnUkpEl3wc+J6wRlar7r2EK2xA==} + '@oramacloud/client@2.1.4': + resolution: {integrity: sha512-uNPFs4wq/iOPbggCwTkVNbIr64Vfd7ZS/h+cricXVnzXWocjDTfJ3wLL4lr0qiSu41g8z+eCAGBqJ30RO2O4AA==} '@phosphor-icons/webcomponents@2.1.5': resolution: {integrity: sha512-JcvQkZxvcX2jK+QCclm8+e8HXqtdFW9xV4/kk2aL9Y3dJA2oQVt+pzbv1orkumz3rfx4K9mn9fDoMr1He1yr7Q==} @@ -3802,9 +3808,6 @@ packages: '@types/minimatch@5.1.2': resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} - '@types/node-fetch@2.6.11': - resolution: {integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==} - '@types/node-forge@1.3.11': resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} @@ -4197,10 +4200,6 @@ packages: resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} engines: {node: '>= 14'} - agentkeepalive@4.5.0: - resolution: {integrity: sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==} - engines: {node: '>= 8.0.0'} - aggregate-error@3.1.0: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} engines: {node: '>=8'} @@ -5956,17 +5955,10 @@ packages: typescript: '>3.6.0' webpack: ^5.11.0 - form-data-encoder@1.7.2: - resolution: {integrity: sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==} - form-data@4.0.0: resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} engines: {node: '>= 6'} - formdata-node@4.4.1: - resolution: {integrity: sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==} - engines: {node: '>= 12.20'} - forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -6340,9 +6332,6 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} - humanize-ms@1.2.1: - resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} - hyperdyperid@1.2.0: resolution: {integrity: sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A==} engines: {node: '>=10.18'} @@ -7609,10 +7598,6 @@ packages: resolution: {integrity: sha512-tmPX422rYgofd4epzrNoOXiE8XFZYOcCq1vD7MAXCDO+O+zndlA2ztdKKMa+EeuBG5tHETpr4ml4RGgpqDCCAg==} engines: {node: '>= 0.10.5'} - node-domexception@1.0.0: - resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} - engines: {node: '>=10.5.0'} - node-fetch-native@1.6.4: resolution: {integrity: sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==} @@ -7819,10 +7804,6 @@ packages: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} - openai@4.52.3: - resolution: {integrity: sha512-IyQLYKGYoEEkUCEm2frPzwHDJ3Ym663KtivnY6pWCzuoi6/HgSIMMxpcuTRS81GH6tiULPYGmTxIvzXdmPIWOw==} - hasBin: true - optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -10255,14 +10236,6 @@ packages: weak-lru-cache@1.2.2: resolution: {integrity: sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw==} - web-streams-polyfill@3.3.3: - resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} - engines: {node: '>= 8'} - - web-streams-polyfill@4.0.0-beta.3: - resolution: {integrity: sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==} - engines: {node: '>= 14'} - webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -13665,28 +13638,17 @@ snapshots: '@orama/orama@3.0.1': {} - '@oramacloud/client@1.3.15(encoding@0.1.13)(typescript@5.5.2)': + '@orama/switch@3.0.2(@orama/orama@3.0.1)(@oramacloud/client@2.1.4)': dependencies: - '@orama/orama': 2.0.23 - '@paralleldrive/cuid2': 2.2.2 - lodash: 4.17.21 - openai: 4.52.3(encoding@0.1.13) - react: 18.3.1 - vue: 3.4.30(typescript@5.5.2) - transitivePeerDependencies: - - encoding - - typescript + '@orama/orama': 3.0.1 + '@oramacloud/client': 2.1.4 - '@oramacloud/client@2.1.0': + '@oramacloud/client@2.1.4': dependencies: '@orama/cuid2': 2.2.3 '@orama/orama': 3.0.1 lodash: 4.17.21 - '@paralleldrive/cuid2@2.2.2': - dependencies: - '@noble/hashes': 1.4.0 - '@phosphor-icons/webcomponents@2.1.5': dependencies: lit: 3.1.4 @@ -14883,11 +14845,6 @@ snapshots: '@types/minimatch@5.1.2': {} - '@types/node-fetch@2.6.11': - dependencies: - '@types/node': 20.14.9 - form-data: 4.0.0 - '@types/node-forge@1.3.11': dependencies: '@types/node': 20.14.9 @@ -15397,10 +15354,6 @@ snapshots: transitivePeerDependencies: - supports-color - agentkeepalive@4.5.0: - dependencies: - humanize-ms: 1.2.1 - aggregate-error@3.1.0: dependencies: clean-stack: 2.2.0 @@ -17242,7 +17195,7 @@ snapshots: debug: 4.3.5 enhanced-resolve: 5.17.0 eslint: 9.5.0 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@9.5.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@9.5.0))(eslint@9.5.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-typescript@3.6.1)(eslint@9.5.0) fast-glob: 3.3.2 get-tsconfig: 4.7.5 @@ -17254,7 +17207,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@9.5.0): + eslint-module-utils@2.8.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@9.5.0))(eslint@9.5.0): dependencies: debug: 3.2.7 optionalDependencies: @@ -17279,7 +17232,7 @@ snapshots: doctrine: 2.1.0 eslint: 9.5.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@9.5.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@9.5.0)(typescript@5.5.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@9.5.0))(eslint@9.5.0) hasown: 2.0.2 is-core-module: 2.14.0 is-glob: 4.0.3 @@ -17738,19 +17691,12 @@ snapshots: typescript: 5.5.2 webpack: 5.92.1(@swc/core@1.6.5(@swc/helpers@0.5.5))(esbuild@0.21.5) - form-data-encoder@1.7.2: {} - form-data@4.0.0: dependencies: asynckit: 0.4.0 combined-stream: 1.0.8 mime-types: 2.1.35 - formdata-node@4.4.1: - dependencies: - node-domexception: 1.0.0 - web-streams-polyfill: 4.0.0-beta.3 - forwarded@0.2.0: {} fraction.js@4.3.7: {} @@ -18225,10 +18171,6 @@ snapshots: human-signals@5.0.0: {} - humanize-ms@1.2.1: - dependencies: - ms: 2.1.3 - hyperdyperid@1.2.0: {} iconv-lite@0.4.24: @@ -19826,8 +19768,6 @@ snapshots: dependencies: minimatch: 3.1.2 - node-domexception@1.0.0: {} - node-fetch-native@1.6.4: {} node-fetch@2.7.0(encoding@0.1.13): @@ -20118,19 +20058,6 @@ snapshots: is-docker: 2.2.1 is-wsl: 2.2.0 - openai@4.52.3(encoding@0.1.13): - dependencies: - '@types/node': 18.19.39 - '@types/node-fetch': 2.6.11 - abort-controller: 3.0.0 - agentkeepalive: 4.5.0 - form-data-encoder: 1.7.2 - formdata-node: 4.4.1 - node-fetch: 2.7.0(encoding@0.1.13) - web-streams-polyfill: 3.3.3 - transitivePeerDependencies: - - encoding - optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -22927,10 +22854,6 @@ snapshots: weak-lru-cache@1.2.2: {} - web-streams-polyfill@3.3.3: {} - - web-streams-polyfill@4.0.0-beta.3: {} - webidl-conversions@3.0.1: {} webidl-conversions@4.0.2: {}