@debales/ai 1.1.13 → 1.1.14-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/browser/ai-browser.js +791 -437
  2. package/dist/module/ai.js +32520 -27333
  3. package/dist/module/ai.umd.js +525 -505
  4. package/package.json +1 -1
  5. package/dist/browser/adapter/BaseCartAdapter.d.ts +0 -17
  6. package/dist/browser/adapter/CartAdapterFactory.d.ts +0 -10
  7. package/dist/browser/adapter/DefaultCartAdapter.d.ts +0 -15
  8. package/dist/browser/adapter/MagentoCartAdapter.d.ts +0 -27
  9. package/dist/browser/adapter/ShopifyCartAdapter.d.ts +0 -20
  10. package/dist/browser/browser.d.ts +0 -9
  11. package/dist/browser/components/ChatbotComponent.d.ts +0 -17
  12. package/dist/browser/components/ChatbotComponent1.d.ts +0 -17
  13. package/dist/browser/components/ChatbotComponent2.d.ts +0 -17
  14. package/dist/browser/components/ChatbotComponent3.d.ts +0 -17
  15. package/dist/browser/components/Chatbotshow.d.ts +0 -2
  16. package/dist/browser/components/common/AddBulkItemsButton.d.ts +0 -1
  17. package/dist/browser/components/common/Button.d.ts +0 -2
  18. package/dist/browser/components/common/CheckoutButton.d.ts +0 -1
  19. package/dist/browser/components/common/CollectionSlider.d.ts +0 -11
  20. package/dist/browser/components/common/DiscountModel.d.ts +0 -8
  21. package/dist/browser/components/common/DiscountPanel.d.ts +0 -8
  22. package/dist/browser/components/common/DownArrow.d.ts +0 -5
  23. package/dist/browser/components/common/DynamicSuggestedQuestion.d.ts +0 -15
  24. package/dist/browser/components/common/DynamicSuggestedQuestion1.d.ts +0 -17
  25. package/dist/browser/components/common/DynamicSuggestedQuestion2.d.ts +0 -15
  26. package/dist/browser/components/common/DynamicSuggestedQuestion3.d.ts +0 -15
  27. package/dist/browser/components/common/ExitModal.d.ts +0 -8
  28. package/dist/browser/components/common/FormField.d.ts +0 -11
  29. package/dist/browser/components/common/Input.d.ts +0 -11
  30. package/dist/browser/components/common/LoadingAnimation.d.ts +0 -7
  31. package/dist/browser/components/common/NormalizePrice.d.ts +0 -13
  32. package/dist/browser/components/common/PhoneInput.d.ts +0 -12
  33. package/dist/browser/components/common/ProductSlider.d.ts +0 -16
  34. package/dist/browser/components/common/SelectLanguage.d.ts +0 -7
  35. package/dist/browser/components/common/SuggestedQuestion.d.ts +0 -19
  36. package/dist/browser/components/common/UserInfoModel.d.ts +0 -14
  37. package/dist/browser/components/common/VariantSelectionModel.d.ts +0 -18
  38. package/dist/browser/components/common/loading-dots.d.ts +0 -4
  39. package/dist/browser/components/common/pop-up.d.ts +0 -2
  40. package/dist/browser/components/common/shadowWrapper.d.ts +0 -10
  41. package/dist/browser/components/footer/ChatInputBox.d.ts +0 -4
  42. package/dist/browser/components/icons/index.d.ts +0 -19
  43. package/dist/browser/constants/dom.d.ts +0 -2
  44. package/dist/browser/constants/events.d.ts +0 -30
  45. package/dist/browser/constants/index.d.ts +0 -7
  46. package/dist/browser/constants/storage-key.d.ts +0 -12
  47. package/dist/browser/context/CartContext.d.ts +0 -3
  48. package/dist/browser/context/ShadowDomContext.d.ts +0 -3
  49. package/dist/browser/hooks/useDebales.d.ts +0 -3
  50. package/dist/browser/index.d.ts +0 -3
  51. package/dist/browser/lib/debalesAnalytics.d.ts +0 -37
  52. package/dist/browser/lib/debalesGlobalObject.d.ts +0 -2
  53. package/dist/browser/lib/platformDetection.d.ts +0 -4
  54. package/dist/browser/lib/platfromValidator.d.ts +0 -2
  55. package/dist/browser/lib/socket.d.ts +0 -19
  56. package/dist/browser/lib/urlHelper.d.ts +0 -18
  57. package/dist/browser/lib/util.d.ts +0 -74
  58. package/dist/browser/main.d.ts +0 -1
  59. package/dist/browser/provider/CartProvider.d.ts +0 -8
  60. package/dist/browser/provider/DebalesProvider.d.ts +0 -7
  61. package/dist/browser/provider/index.d.ts +0 -5
  62. package/dist/browser/types/cart.d.ts +0 -49
  63. package/dist/browser/types/debales.d.ts +0 -54
  64. package/dist/browser/types/index.d.ts +0 -146
  65. package/dist/browser/types/magento.d.ts +0 -37
  66. package/dist/browser/types/shopify.d.ts +0 -22
@@ -1,2 +0,0 @@
1
- declare const initGlobalChat: (projectId: string) => void;
2
- export { initGlobalChat };
@@ -1,4 +0,0 @@
1
- import { EcommercePlatform } from '../types/index';
2
- export declare class PlatformDetector {
3
- static detect(): EcommercePlatform;
4
- }
@@ -1,2 +0,0 @@
1
- import { CartPlatformAdapter } from '../types/cart';
2
- export declare const createPlatformValidator: <T extends CartPlatformAdapter>(adapter: T) => T;
@@ -1,19 +0,0 @@
1
- import { Socket } from 'socket.io-client';
2
- declare class SocketManager {
3
- private static instance;
4
- private socket;
5
- private isConnected;
6
- private eventListeners;
7
- private constructor();
8
- static getInstance(): SocketManager;
9
- connect(namespace: string): Socket;
10
- disconnect(): void;
11
- getSocket(): Socket | null;
12
- getIsConnected(): boolean;
13
- on(event: string, callback: (...args: any[]) => void): void;
14
- off(event: string, callback: (...args: any[]) => void): void;
15
- emit(event: string, ...args: any[]): void;
16
- private emitEvent;
17
- }
18
- export declare const socketManager: SocketManager;
19
- export {};
@@ -1,18 +0,0 @@
1
- interface UTMParams {
2
- source?: string;
3
- medium?: string;
4
- campaign?: string;
5
- term?: string;
6
- content?: string;
7
- sessionId?: string;
8
- messageId?: string;
9
- }
10
- export declare const addUtmParams: (url: string | URL, params?: UTMParams) => string;
11
- export declare function parseURL(url: string): {
12
- isValid: true;
13
- url: URL;
14
- } | {
15
- isValid: false;
16
- error: string;
17
- };
18
- export {};
@@ -1,74 +0,0 @@
1
- import { DefaultTheme } from 'styled-components';
2
- import { SuggestedQuestionAnswer, UiData } from '../types';
3
- export declare const getTheme: (data: UiData) => DefaultTheme;
4
- export declare function getSessionId(): string;
5
- export declare function getMessageId(): string | null;
6
- export declare function setSessionId(sessionId: string): void;
7
- export declare function getIsFormClosedByUser(): boolean;
8
- export declare function setIsFormClosedByUser(value: boolean): void;
9
- export declare function getUserInfo(): {
10
- name?: string;
11
- email: string;
12
- phone?: string;
13
- } | null;
14
- export declare function setUserInfo(userInfo: {
15
- name?: string;
16
- email?: string;
17
- phone?: string;
18
- }): void;
19
- export declare function scrollToBottom(containerRef: React.RefObject<HTMLElement>): void;
20
- export declare function getCurrentPath(): string;
21
- export declare function isTestingUser(): boolean;
22
- /**
23
- * Gets suggested questions for the current path from an array of SuggestedQuestionAnswer objects
24
- *
25
- * @param {SuggestedQuestionAnswer[]} questions - Array of all suggested questions
26
- * @returns {SuggestedQuestionAnswer[]} - Filtered questions for the current path
27
- */
28
- export declare function getQuestionsForCurrentPath(questions: SuggestedQuestionAnswer[]): SuggestedQuestionAnswer[];
29
- export declare const asyncWait: (ms: number) => Promise<unknown>;
30
- interface trackCheckoutOptions {
31
- projectName: string;
32
- /**
33
- * conversationId should be combination of sessionId and projectName
34
- * @example conversationId = sessionId + projectName
35
- */
36
- conversationId: string;
37
- cartValue: number;
38
- /**
39
- * createdAt should in a ISO format
40
- */
41
- createdAt?: string;
42
- /**
43
- * updatedAt should in a ISO format
44
- */
45
- updatedAt?: string;
46
- userName?: string;
47
- userPhone?: string;
48
- userEmail?: string;
49
- anonymousUserId?: string;
50
- distinctId?: string;
51
- }
52
- export declare const trackCheckout: (options: trackCheckoutOptions) => Promise<boolean>;
53
- export declare const initializeMixpanel: (projectName: string) => import('mixpanel-browser').OverridedMixpanel | null;
54
- export declare const trackEventMixpanel: (eventName: string, data: Record<string, any>) => Promise<void>;
55
- export declare const getMixpanelDistintId: (botId: string) => any;
56
- export declare const generateUniqueId: () => string;
57
- export declare const clearanonymousUserId: () => void;
58
- export declare function splitMessageIntoParagraphs(markdownText: string): string[];
59
- export declare const isAthflex: (botId: string) => botId is "athflex" | "athflex-2";
60
- export declare const isGaiabay: (botId: string) => boolean;
61
- export declare const splitQuestionsIntoGroups: (questions: SuggestedQuestionAnswer[]) => (SuggestedQuestionAnswer | SuggestedQuestionAnswer[])[];
62
- /**
63
- * Creates a storage key with optional botId scoping
64
- *
65
- * @param {string} purpose - The purpose identifier for the storage key
66
- * @param {object} options - Optional configuration
67
- * @param {string} options.botId - Bot ID for project-specific storage (optional)
68
- * @param {boolean} options.shared - Whether this is shared across all instances (optional)
69
- * @return {string} The generated storage key
70
- */
71
- export declare function createStorageKey(purpose: string, options?: {
72
- botId?: string;
73
- }): string;
74
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { CartPlatformAdapter } from '../types/cart';
2
- interface CartProviderProps {
3
- adapter: CartPlatformAdapter;
4
- children: React.ReactNode;
5
- autoFetch?: boolean;
6
- }
7
- export declare const CartProvider: React.FC<CartProviderProps>;
8
- export {};
@@ -1,7 +0,0 @@
1
- import { default as React, ReactNode } from 'react';
2
- interface DebalesProviderProps {
3
- children: ReactNode;
4
- nameSpace: string;
5
- }
6
- export declare const DebalesProvider: React.FC<DebalesProviderProps>;
7
- export {};
@@ -1,5 +0,0 @@
1
- declare function Provider(props: {
2
- children: React.ReactNode;
3
- botId: string;
4
- }): import("react/jsx-runtime").JSX.Element;
5
- export default Provider;
@@ -1,49 +0,0 @@
1
- import { EcommercePlatform, Product } from '.';
2
- export interface CartItem {
3
- id: number;
4
- quantity: number;
5
- properties?: Record<string, string>;
6
- title: string;
7
- price: number;
8
- variant_id: number;
9
- }
10
- export interface CartState {
11
- items: CartItem[];
12
- total: number;
13
- itemCount: number;
14
- currency: string;
15
- token: string;
16
- }
17
- export interface CartPlatformAdapter {
18
- readonly platform: EcommercePlatform;
19
- isSupported(): boolean;
20
- fetchCart(): Promise<CartOperationResult<CartState>>;
21
- addToCart(variantId: string, quantity?: number, properties?: Record<string, string>): Promise<CartOperationResult<void>>;
22
- removeFromCart(itemId: number): Promise<CartOperationResult<void>>;
23
- updateQuantity(cartItem: CartItem): Promise<CartOperationResult<void>>;
24
- clearCart(): Promise<CartOperationResult<void>>;
25
- generateCartUrl(domain: string): string;
26
- generateProductUrl(domain: string, product: Product): string;
27
- addCartAttributes(attributes?: Record<string, string>): Promise<CartOperationResult<void>>;
28
- }
29
- export type CartOperationResult<T> = {
30
- success: true;
31
- data: T;
32
- message?: string;
33
- } | {
34
- success: false;
35
- error: string;
36
- };
37
- export interface CartContextValue {
38
- isLoading: boolean;
39
- error: string | null;
40
- cart: CartState | null;
41
- fetchCart: () => Promise<void>;
42
- addToCart: (variantId: string, quantity?: number, properties?: Record<string, string>) => Promise<CartOperationResult<void>>;
43
- removeFromCart: (itemId: number) => Promise<CartOperationResult<void>>;
44
- updateQuantity: (cartItem: CartItem) => Promise<CartOperationResult<void>>;
45
- clearCart: () => Promise<CartOperationResult<void>>;
46
- generateCartUrl: (domain: string) => string;
47
- generateProductUrl: (domain: string, product: Product) => string;
48
- addCartAttributes: (attributes?: Record<string, string>) => Promise<CartOperationResult<void>>;
49
- }
@@ -1,54 +0,0 @@
1
- import { EventType, LeadingQueries, MessageEvent, MessageRole, UserInfo } from '@debales/shared';
2
- import { DisplayMode, Product, ShopifyStoreMeta, SuggestedQuestionAnswer, UiData, VariantQuantity, Message } from '.';
3
- export interface DebalesContextType {
4
- messages: Message[];
5
- isLoading: boolean;
6
- isMessageLoading: boolean;
7
- sessionId: string;
8
- isKlaviyoMessage: boolean;
9
- showUserInfoModel: boolean;
10
- pendingBulkItems: VariantQuantity[];
11
- lastedBotmessageId: string | null;
12
- uiData: UiData | null;
13
- storeMetaData: ShopifyStoreMeta | null;
14
- suggestedQuestions: SuggestedQuestionAnswer[];
15
- isUserInfoNeeded: boolean;
16
- userInfo: UserInfo | null;
17
- input: string;
18
- pendingQuestion: SuggestedQuestionAnswer | null;
19
- isFormClosedByUser: boolean;
20
- onSendMessage: (message: string, answer?: string, products?: Product[], fromKlaviyo?: boolean, leading_queries?: string[], followUpQuestion?: string) => Promise<void>;
21
- setIsKlaviyoMessage: React.Dispatch<React.SetStateAction<boolean>>;
22
- setShowUserInfoModel: React.Dispatch<React.SetStateAction<boolean>>;
23
- setPendingBulkItems: React.Dispatch<React.SetStateAction<VariantQuantity[]>>;
24
- setLastedBotmessageId: React.Dispatch<React.SetStateAction<string | null>>;
25
- fetchUiInfo: () => Promise<void>;
26
- setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
27
- setIsMessageLoading: React.Dispatch<React.SetStateAction<boolean>>;
28
- setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
29
- changeDisplayModel: (displayMode: DisplayMode) => void;
30
- saveConversation: (messages: Message[]) => void;
31
- loadConversation: () => Message[];
32
- setSuggestedQuestions: React.Dispatch<React.SetStateAction<SuggestedQuestionAnswer[]>>;
33
- setInput: React.Dispatch<React.SetStateAction<string>>;
34
- setPendingQuestion: React.Dispatch<React.SetStateAction<SuggestedQuestionAnswer | null>>;
35
- setUserInfo: React.Dispatch<React.SetStateAction<UserInfo>>;
36
- setIsFormClosedByUser: React.Dispatch<React.SetStateAction<boolean>>;
37
- }
38
- export interface WebsocketMessageEvent extends MessageEvent {
39
- type: typeof EventType.MESSAGE | typeof EventType.USER_ACTION;
40
- role: (typeof MessageRole)[keyof typeof MessageRole];
41
- query: string;
42
- nameSpace: string;
43
- conversationId?: string;
44
- userInfo?: UserInfo;
45
- anonymousUserId?: string;
46
- distinctId?: string;
47
- timeZone?: string;
48
- sessionId: string;
49
- timestamp?: string;
50
- leadingQueries?: LeadingQueries;
51
- answer?: string;
52
- products?: Product[];
53
- followUpQuestion?: string;
54
- }
@@ -1,146 +0,0 @@
1
- interface ChatBoxProps {
2
- botId: string;
3
- botName?: string;
4
- }
5
- export interface PluginCofig {
6
- collectedUserInfo: {
7
- modelHeading: string;
8
- name: boolean;
9
- email: boolean;
10
- phone: boolean;
11
- isOptional: boolean;
12
- discount?: string;
13
- };
14
- }
15
- interface CollectedUserInfo {
16
- modelHeading: string;
17
- name: boolean;
18
- email: boolean;
19
- phone: boolean;
20
- isOptional: boolean;
21
- discount?: string;
22
- }
23
- export type DisplayMode = "normal" | "half-screen" | "full-screen";
24
- export type HeightOption = "Normal" | "Higher" | "Highest";
25
- export type ChatButtonBackgroundAnimationType = "Ping" | "Glow" | string;
26
- interface UiData {
27
- bot_logo?: string;
28
- backgroundColor: string;
29
- botBackgroundColor?: string;
30
- botMessageColor?: string;
31
- botFontColor?: string;
32
- fontColor?: string;
33
- headerFontColor?: string;
34
- callToActionBackgroundColor?: string;
35
- callToActionFontColor?: string;
36
- footerBackgroundColor?: string;
37
- fonterInputBorderColor?: string;
38
- initialMessage?: string;
39
- userMessageColor?: string;
40
- userFontColor?: string;
41
- suggestedQuestionsFontColor?: string;
42
- suggestedQuestionsBackgroundColor?: string;
43
- suggestedQuestionsHoverColor?: string;
44
- suggestedQuestionsCrossButtonColor?: string;
45
- suggestedQuestionsCrossButtonBackgroundColor?: string;
46
- suggestedQuestionsHighlightColor?: string;
47
- supportButtonBackgroundColor?: string;
48
- chatButtonBackgroundAnimationColor?: string;
49
- inputPlaceholder?: string[];
50
- userMessage_logo?: string;
51
- suggestedQuestions: SuggestedQuestionAnswer[];
52
- pluginConfig: PluginCofig;
53
- shopifyShopDomain?: string;
54
- chatbotName?: string;
55
- isLeft?: boolean;
56
- heightOption?: HeightOption;
57
- show_bot?: boolean;
58
- debales_branding?: boolean;
59
- fullScreenOnMobile?: boolean;
60
- mobileDisplayMode?: DisplayMode;
61
- KlaviyoIntegration?: boolean;
62
- KlaviyoFormIntegration?: boolean;
63
- enableChatButtonBackgroundAnimation?: boolean;
64
- chatButtonBackgroundAnimationType?: ChatButtonBackgroundAnimationType;
65
- removeLogoBackground?: boolean;
66
- collectedUserInfo: CollectedUserInfo;
67
- countryCode?: string;
68
- zIndex: number;
69
- }
70
- export interface Product {
71
- name: string;
72
- price?: string | null;
73
- image: [string];
74
- link: string;
75
- product_id: string;
76
- compare_at_price?: string;
77
- handle?: string;
78
- }
79
- export interface SuggestedQuestionAnswer {
80
- question: string;
81
- answer?: string;
82
- products?: Product[];
83
- path: string;
84
- nameSpace: string;
85
- sortOrder?: number;
86
- isHighlighted?: boolean;
87
- enable?: boolean;
88
- leading_queries?: string[];
89
- type?: "static" | "dynamic";
90
- Follow_up_Question?: string;
91
- }
92
- export interface Message {
93
- text: string;
94
- leading_queries?: string[];
95
- collections?: [
96
- {
97
- image: string;
98
- name: string;
99
- }
100
- ];
101
- products?: Product[];
102
- variants?: [
103
- {
104
- id: string;
105
- name: string;
106
- price: string;
107
- }
108
- ];
109
- totalprice?: string;
110
- show_checkout?: boolean;
111
- rating?: "liked" | "disliked" | "neutral";
112
- conversationId?: string;
113
- shop?: string;
114
- Variants_quantity?: string;
115
- monthlyChatLimitReached?: boolean | undefined;
116
- isBot?: boolean;
117
- hideConfirmation?: boolean;
118
- }
119
- export type { ChatBoxProps, UiData };
120
- export interface ShopifyStoreMeta {
121
- currency: string;
122
- money_format: string;
123
- name: string;
124
- domain: string;
125
- }
126
- export interface VariantQuantity {
127
- id: string;
128
- productName: string;
129
- variantName: string;
130
- quantity: number;
131
- price?: string;
132
- productLink?: string;
133
- }
134
- export declare enum EcommercePlatform {
135
- DEFAULT = "DEFAULT",
136
- SHOPIFY = "SHOPIFY",
137
- WOOCOMMERCE = "WOOCOMMERCE",
138
- MAGENTO = "MAGENTO",
139
- UNKNOWN = "UNKNOWN"
140
- }
141
- export interface ShadowDOMRef {
142
- shadowRoot: ShadowRoot;
143
- container: HTMLElement;
144
- querySelector: (selector: string) => Element | null;
145
- querySelectorAll: (selector: string) => NodeListOf<Element> | null;
146
- }
@@ -1,37 +0,0 @@
1
- export interface MagentoCartItem {
2
- product_type: string;
3
- options: unknown[];
4
- qty: number;
5
- item_id: string;
6
- configure_url: string;
7
- is_visible_in_site_visibility: boolean;
8
- product_id: string;
9
- product_name: string;
10
- product_sku: string;
11
- product_url: string;
12
- product_has_url: boolean;
13
- product_price: string;
14
- product_price_value: number;
15
- product_image: {
16
- src: string;
17
- alt: string;
18
- width: number;
19
- height: number;
20
- };
21
- canApplyMsrp: boolean;
22
- message: string;
23
- }
24
- export interface MagentoCart {
25
- summary_count: number;
26
- subtotalAmount: string;
27
- subtotal: string;
28
- possible_onepage_checkout: boolean;
29
- items: MagentoCartItem[];
30
- extra_actions: string;
31
- isGuestCheckoutAllowed: boolean;
32
- website_id: string;
33
- storeId: string;
34
- subtotal_incl_tax: string;
35
- subtotal_excl_tax: string;
36
- data_id: number;
37
- }
@@ -1,22 +0,0 @@
1
- export interface ShopifyCartResponse {
2
- token: string;
3
- note: string | null;
4
- attributes: Record<string, string>;
5
- total_price: number;
6
- total_weight: number;
7
- item_count: number;
8
- items: Array<{
9
- id: number;
10
- quantity: number;
11
- variant_id: number;
12
- title: string;
13
- price: number;
14
- properties: Record<string, string>;
15
- }>;
16
- currency: string;
17
- }
18
- export interface ShopifyErrorResponse {
19
- status: number;
20
- message: string;
21
- description?: string;
22
- }