wealth-alpha-chat-widget 1.0.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.
@@ -0,0 +1,219 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface Chip$1 {
4
+ id: string;
5
+ label: string;
6
+ icon?: string;
7
+ apiPath?: string;
8
+ }
9
+ interface Message {
10
+ id: string;
11
+ role: "user" | "bot";
12
+ content: string;
13
+ chips?: Chip$1[];
14
+ chipsActive?: boolean;
15
+ timestamp: number;
16
+ }
17
+ interface WACUser {
18
+ userId: string;
19
+ name?: string;
20
+ email?: string;
21
+ plan?: string;
22
+ rootChips?: Chip$1[];
23
+ welcomeMessage?: string;
24
+ }
25
+ interface WACSession {
26
+ token: string;
27
+ userId: string;
28
+ sessionId: string;
29
+ expiresAt: number;
30
+ lastActive: number;
31
+ history: Message[];
32
+ bootSource?: "fallback";
33
+ }
34
+ interface BotResponse {
35
+ message: string;
36
+ chips: Chip$1[];
37
+ sessionId: string;
38
+ endOfFlow: boolean;
39
+ metadata?: {
40
+ service?: string;
41
+ subService?: string;
42
+ ticker?: string;
43
+ [key: string]: unknown;
44
+ };
45
+ }
46
+ type ChatPosition = "bottom-right" | "bottom-left";
47
+ interface WealthChatProps {
48
+ apiBase: string;
49
+ authCheck?: string;
50
+ loginUrl: string;
51
+ sessionTTL?: number;
52
+ welcomeMessage?: string;
53
+ brandName?: string;
54
+ brandColor?: string;
55
+ position?: ChatPosition;
56
+ defaultOpen?: boolean;
57
+ showCountdown?: boolean;
58
+ onLogin?: () => void;
59
+ onLogout?: () => void;
60
+ onSessionExpire?: () => void;
61
+ onError?: (err: Error) => void;
62
+ }
63
+ type ChatStatus = "idle" | "sending" | "error";
64
+ interface ChatState {
65
+ messages: Message[];
66
+ isTyping: boolean;
67
+ status: ChatStatus;
68
+ error: string | null;
69
+ }
70
+
71
+ declare function WealthChat(props: WealthChatProps): react_jsx_runtime.JSX.Element | null;
72
+
73
+ interface ChatHeaderProps {
74
+ brandName: string;
75
+ remainingMs: number;
76
+ showCountdown: boolean;
77
+ onClose: () => void;
78
+ onClear?: () => void;
79
+ }
80
+ declare function ChatHeader({ brandName, remainingMs, showCountdown, onClose, onClear, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
81
+
82
+ interface ChatBodyProps {
83
+ isLoggedIn: boolean;
84
+ loading: boolean;
85
+ messages: Message[];
86
+ isTyping: boolean;
87
+ brandName: string;
88
+ loginUrl: string;
89
+ error: string | null;
90
+ onChipClick: (chip: Chip$1) => void;
91
+ onLoginClick?: () => void;
92
+ }
93
+ declare function ChatBody({ isLoggedIn, loading, messages, isTyping, brandName, loginUrl, error, onChipClick, onLoginClick, }: ChatBodyProps): react_jsx_runtime.JSX.Element;
94
+
95
+ interface ChatInputProps {
96
+ disabled?: boolean;
97
+ placeholder?: string;
98
+ onSend: (text: string) => void;
99
+ }
100
+ declare function ChatInput({ disabled, placeholder, onSend }: ChatInputProps): react_jsx_runtime.JSX.Element;
101
+
102
+ interface MessageBubbleProps {
103
+ message: Message;
104
+ onChipClick: (chip: Chip$1) => void;
105
+ }
106
+ declare function MessageBubble({ message, onChipClick }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
107
+
108
+ interface ChipProps {
109
+ chip: Chip$1;
110
+ disabled?: boolean;
111
+ active?: boolean;
112
+ onClick: (chip: Chip$1) => void;
113
+ }
114
+ declare function Chip({ chip, disabled, active, onClick }: ChipProps): react_jsx_runtime.JSX.Element;
115
+
116
+ interface ChipRowProps {
117
+ chips: Chip$1[];
118
+ disabled?: boolean;
119
+ onClick: (chip: Chip$1) => void;
120
+ }
121
+ declare function ChipRow({ chips, disabled, onClick }: ChipRowProps): react_jsx_runtime.JSX.Element | null;
122
+
123
+ interface AuthGateProps {
124
+ brandName: string;
125
+ loginUrl: string;
126
+ onLoginClick?: () => void;
127
+ }
128
+ declare function AuthGate({ brandName, loginUrl, onLoginClick }: AuthGateProps): react_jsx_runtime.JSX.Element;
129
+
130
+ declare function TypingIndicator(): react_jsx_runtime.JSX.Element;
131
+
132
+ interface FloatingButtonProps {
133
+ position: ChatPosition;
134
+ onClick: () => void;
135
+ brandColor?: string;
136
+ }
137
+ declare function FloatingButton({ position, onClick, brandColor }: FloatingButtonProps): react_jsx_runtime.JSX.Element;
138
+
139
+ interface UseSessionOptions {
140
+ ttlSeconds?: number;
141
+ onExpire?: () => void;
142
+ }
143
+ interface UseSessionReturn {
144
+ session: WACSession | null;
145
+ remainingMs: number;
146
+ setToken: (token: string, userId: string) => void;
147
+ setHistory: (history: Message[]) => void;
148
+ touch: () => void;
149
+ clear: () => void;
150
+ }
151
+ declare function useSession(opts?: UseSessionOptions): UseSessionReturn;
152
+
153
+ interface UseAuthOptions {
154
+ apiBase: string;
155
+ authCheck: string;
156
+ enabled?: boolean;
157
+ onError?: (err: Error) => void;
158
+ }
159
+ interface UseAuthReturn {
160
+ isLoggedIn: boolean;
161
+ user: WACUser | null;
162
+ loading: boolean;
163
+ error: Error | null;
164
+ refresh: () => void;
165
+ }
166
+ declare function useAuth(opts: UseAuthOptions): UseAuthReturn;
167
+
168
+ interface UseChatOptions {
169
+ apiBase: string;
170
+ sessionId: string | null;
171
+ initialMessages?: Message[];
172
+ onHistoryChange?: (history: Message[]) => void;
173
+ onError?: (err: Error) => void;
174
+ onAuthExpired?: () => void;
175
+ }
176
+ interface UseChatReturn {
177
+ state: ChatState;
178
+ sendText: (text: string) => Promise<void>;
179
+ appendBotResponse: (resp: BotResponse) => void;
180
+ appendUserMessage: (content: string) => Message;
181
+ deactivatePriorChips: (keepId?: string) => void;
182
+ setTyping: (value: boolean) => void;
183
+ clear: () => void;
184
+ loadHistory: (history: Message[]) => void;
185
+ }
186
+ declare function useChat(opts: UseChatOptions): UseChatReturn;
187
+
188
+ interface UseChipOptions {
189
+ apiBase: string;
190
+ sessionId: string | null;
191
+ onAuthExpired?: () => void;
192
+ onError?: (err: Error) => void;
193
+ }
194
+ interface UseChipReturn {
195
+ callChip: (chip: Chip$1) => Promise<BotResponse | null>;
196
+ }
197
+ declare function useChip(opts: UseChipOptions): UseChipReturn;
198
+
199
+ declare const SESSION_KEY = "wac_session";
200
+ declare const DEFAULT_SESSION_TTL_SECONDS = 1800;
201
+ declare function readSession(): WACSession | null;
202
+ declare function writeSession(data: Partial<WACSession>, ttlSeconds?: number): WACSession | null;
203
+ declare function clearSession(): void;
204
+ declare function touchSession(ttlSeconds?: number): WACSession | null;
205
+
206
+ declare class ApiError extends Error {
207
+ status: number;
208
+ requestId: string;
209
+ constructor(message: string, status: number, requestId: string);
210
+ }
211
+ declare class AuthExpiredError extends ApiError {
212
+ constructor(requestId: string);
213
+ }
214
+ declare function checkAuth(apiBase: string, authCheck: string, signal?: AbortSignal): Promise<WACUser>;
215
+ declare function sendChip(apiBase: string, chip: Chip$1, sessionId: string, signal?: AbortSignal): Promise<BotResponse>;
216
+ declare function sendMessage(apiBase: string, message: string, sessionId: string, context: Message[], signal?: AbortSignal): Promise<BotResponse>;
217
+ declare function logout(apiBase: string, signal?: AbortSignal): Promise<void>;
218
+
219
+ export { ApiError, AuthExpiredError, AuthGate, type BotResponse, ChatBody, ChatHeader, ChatInput, type ChatPosition, type ChatState, type ChatStatus, Chip, ChipRow, type Chip$1 as ChipType, DEFAULT_SESSION_TTL_SECONDS, FloatingButton, type Message, MessageBubble, SESSION_KEY, TypingIndicator, type WACSession, type WACUser, WealthChat, type WealthChatProps, checkAuth, clearSession, logout, readSession, sendChip, sendMessage, touchSession, useAuth, useChat, useChip, useSession, writeSession };
@@ -0,0 +1,219 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface Chip$1 {
4
+ id: string;
5
+ label: string;
6
+ icon?: string;
7
+ apiPath?: string;
8
+ }
9
+ interface Message {
10
+ id: string;
11
+ role: "user" | "bot";
12
+ content: string;
13
+ chips?: Chip$1[];
14
+ chipsActive?: boolean;
15
+ timestamp: number;
16
+ }
17
+ interface WACUser {
18
+ userId: string;
19
+ name?: string;
20
+ email?: string;
21
+ plan?: string;
22
+ rootChips?: Chip$1[];
23
+ welcomeMessage?: string;
24
+ }
25
+ interface WACSession {
26
+ token: string;
27
+ userId: string;
28
+ sessionId: string;
29
+ expiresAt: number;
30
+ lastActive: number;
31
+ history: Message[];
32
+ bootSource?: "fallback";
33
+ }
34
+ interface BotResponse {
35
+ message: string;
36
+ chips: Chip$1[];
37
+ sessionId: string;
38
+ endOfFlow: boolean;
39
+ metadata?: {
40
+ service?: string;
41
+ subService?: string;
42
+ ticker?: string;
43
+ [key: string]: unknown;
44
+ };
45
+ }
46
+ type ChatPosition = "bottom-right" | "bottom-left";
47
+ interface WealthChatProps {
48
+ apiBase: string;
49
+ authCheck?: string;
50
+ loginUrl: string;
51
+ sessionTTL?: number;
52
+ welcomeMessage?: string;
53
+ brandName?: string;
54
+ brandColor?: string;
55
+ position?: ChatPosition;
56
+ defaultOpen?: boolean;
57
+ showCountdown?: boolean;
58
+ onLogin?: () => void;
59
+ onLogout?: () => void;
60
+ onSessionExpire?: () => void;
61
+ onError?: (err: Error) => void;
62
+ }
63
+ type ChatStatus = "idle" | "sending" | "error";
64
+ interface ChatState {
65
+ messages: Message[];
66
+ isTyping: boolean;
67
+ status: ChatStatus;
68
+ error: string | null;
69
+ }
70
+
71
+ declare function WealthChat(props: WealthChatProps): react_jsx_runtime.JSX.Element | null;
72
+
73
+ interface ChatHeaderProps {
74
+ brandName: string;
75
+ remainingMs: number;
76
+ showCountdown: boolean;
77
+ onClose: () => void;
78
+ onClear?: () => void;
79
+ }
80
+ declare function ChatHeader({ brandName, remainingMs, showCountdown, onClose, onClear, }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
81
+
82
+ interface ChatBodyProps {
83
+ isLoggedIn: boolean;
84
+ loading: boolean;
85
+ messages: Message[];
86
+ isTyping: boolean;
87
+ brandName: string;
88
+ loginUrl: string;
89
+ error: string | null;
90
+ onChipClick: (chip: Chip$1) => void;
91
+ onLoginClick?: () => void;
92
+ }
93
+ declare function ChatBody({ isLoggedIn, loading, messages, isTyping, brandName, loginUrl, error, onChipClick, onLoginClick, }: ChatBodyProps): react_jsx_runtime.JSX.Element;
94
+
95
+ interface ChatInputProps {
96
+ disabled?: boolean;
97
+ placeholder?: string;
98
+ onSend: (text: string) => void;
99
+ }
100
+ declare function ChatInput({ disabled, placeholder, onSend }: ChatInputProps): react_jsx_runtime.JSX.Element;
101
+
102
+ interface MessageBubbleProps {
103
+ message: Message;
104
+ onChipClick: (chip: Chip$1) => void;
105
+ }
106
+ declare function MessageBubble({ message, onChipClick }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
107
+
108
+ interface ChipProps {
109
+ chip: Chip$1;
110
+ disabled?: boolean;
111
+ active?: boolean;
112
+ onClick: (chip: Chip$1) => void;
113
+ }
114
+ declare function Chip({ chip, disabled, active, onClick }: ChipProps): react_jsx_runtime.JSX.Element;
115
+
116
+ interface ChipRowProps {
117
+ chips: Chip$1[];
118
+ disabled?: boolean;
119
+ onClick: (chip: Chip$1) => void;
120
+ }
121
+ declare function ChipRow({ chips, disabled, onClick }: ChipRowProps): react_jsx_runtime.JSX.Element | null;
122
+
123
+ interface AuthGateProps {
124
+ brandName: string;
125
+ loginUrl: string;
126
+ onLoginClick?: () => void;
127
+ }
128
+ declare function AuthGate({ brandName, loginUrl, onLoginClick }: AuthGateProps): react_jsx_runtime.JSX.Element;
129
+
130
+ declare function TypingIndicator(): react_jsx_runtime.JSX.Element;
131
+
132
+ interface FloatingButtonProps {
133
+ position: ChatPosition;
134
+ onClick: () => void;
135
+ brandColor?: string;
136
+ }
137
+ declare function FloatingButton({ position, onClick, brandColor }: FloatingButtonProps): react_jsx_runtime.JSX.Element;
138
+
139
+ interface UseSessionOptions {
140
+ ttlSeconds?: number;
141
+ onExpire?: () => void;
142
+ }
143
+ interface UseSessionReturn {
144
+ session: WACSession | null;
145
+ remainingMs: number;
146
+ setToken: (token: string, userId: string) => void;
147
+ setHistory: (history: Message[]) => void;
148
+ touch: () => void;
149
+ clear: () => void;
150
+ }
151
+ declare function useSession(opts?: UseSessionOptions): UseSessionReturn;
152
+
153
+ interface UseAuthOptions {
154
+ apiBase: string;
155
+ authCheck: string;
156
+ enabled?: boolean;
157
+ onError?: (err: Error) => void;
158
+ }
159
+ interface UseAuthReturn {
160
+ isLoggedIn: boolean;
161
+ user: WACUser | null;
162
+ loading: boolean;
163
+ error: Error | null;
164
+ refresh: () => void;
165
+ }
166
+ declare function useAuth(opts: UseAuthOptions): UseAuthReturn;
167
+
168
+ interface UseChatOptions {
169
+ apiBase: string;
170
+ sessionId: string | null;
171
+ initialMessages?: Message[];
172
+ onHistoryChange?: (history: Message[]) => void;
173
+ onError?: (err: Error) => void;
174
+ onAuthExpired?: () => void;
175
+ }
176
+ interface UseChatReturn {
177
+ state: ChatState;
178
+ sendText: (text: string) => Promise<void>;
179
+ appendBotResponse: (resp: BotResponse) => void;
180
+ appendUserMessage: (content: string) => Message;
181
+ deactivatePriorChips: (keepId?: string) => void;
182
+ setTyping: (value: boolean) => void;
183
+ clear: () => void;
184
+ loadHistory: (history: Message[]) => void;
185
+ }
186
+ declare function useChat(opts: UseChatOptions): UseChatReturn;
187
+
188
+ interface UseChipOptions {
189
+ apiBase: string;
190
+ sessionId: string | null;
191
+ onAuthExpired?: () => void;
192
+ onError?: (err: Error) => void;
193
+ }
194
+ interface UseChipReturn {
195
+ callChip: (chip: Chip$1) => Promise<BotResponse | null>;
196
+ }
197
+ declare function useChip(opts: UseChipOptions): UseChipReturn;
198
+
199
+ declare const SESSION_KEY = "wac_session";
200
+ declare const DEFAULT_SESSION_TTL_SECONDS = 1800;
201
+ declare function readSession(): WACSession | null;
202
+ declare function writeSession(data: Partial<WACSession>, ttlSeconds?: number): WACSession | null;
203
+ declare function clearSession(): void;
204
+ declare function touchSession(ttlSeconds?: number): WACSession | null;
205
+
206
+ declare class ApiError extends Error {
207
+ status: number;
208
+ requestId: string;
209
+ constructor(message: string, status: number, requestId: string);
210
+ }
211
+ declare class AuthExpiredError extends ApiError {
212
+ constructor(requestId: string);
213
+ }
214
+ declare function checkAuth(apiBase: string, authCheck: string, signal?: AbortSignal): Promise<WACUser>;
215
+ declare function sendChip(apiBase: string, chip: Chip$1, sessionId: string, signal?: AbortSignal): Promise<BotResponse>;
216
+ declare function sendMessage(apiBase: string, message: string, sessionId: string, context: Message[], signal?: AbortSignal): Promise<BotResponse>;
217
+ declare function logout(apiBase: string, signal?: AbortSignal): Promise<void>;
218
+
219
+ export { ApiError, AuthExpiredError, AuthGate, type BotResponse, ChatBody, ChatHeader, ChatInput, type ChatPosition, type ChatState, type ChatStatus, Chip, ChipRow, type Chip$1 as ChipType, DEFAULT_SESSION_TTL_SECONDS, FloatingButton, type Message, MessageBubble, SESSION_KEY, TypingIndicator, type WACSession, type WACUser, WealthChat, type WealthChatProps, checkAuth, clearSession, logout, readSession, sendChip, sendMessage, touchSession, useAuth, useChat, useChip, useSession, writeSession };