@aakash58/chatbot 1.0.47 → 1.0.49

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.
package/index.d.ts CHANGED
@@ -1,24 +1,37 @@
1
- import * as _aakash58_chatbot from '@aakash58/chatbot';
2
- import * as _angular_core from '@angular/core';
3
- import { RendererFactory2, InjectionToken, OnDestroy, ElementRef, Renderer2, SimpleChanges } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { RendererFactory2, OnDestroy, ElementRef, Renderer2, SimpleChanges } from '@angular/core';
4
3
  import { OverlayContainer } from '@angular/cdk/overlay';
5
- import * as rxjs from 'rxjs';
6
4
  import { Observable } from 'rxjs';
5
+ import { HttpClient } from '@angular/common/http';
6
+ import { JwtHelperService } from '@auth0/angular-jwt';
7
+ import { Router } from '@angular/router';
8
+
9
+ interface Message {
10
+ id: string;
11
+ sender: 'user' | 'bot';
12
+ senderName?: string;
13
+ text: string;
14
+ timestamp?: Date;
15
+ showSuggestions?: boolean;
16
+ platformTenant?: string;
17
+ subTenant?: string;
18
+ agent?: string;
19
+ }
7
20
 
8
21
  type ThemeMode = 'light' | 'dark' | 'system';
9
22
  declare class ThemeService {
10
23
  private overlay;
11
24
  private renderer;
12
25
  private _theme;
13
- theme: _angular_core.Signal<ThemeMode>;
26
+ theme: i0.Signal<ThemeMode>;
14
27
  private _activeTheme;
15
- activeTheme: _angular_core.Signal<"light-theme" | "dark-theme">;
28
+ activeTheme: i0.Signal<"light-theme" | "dark-theme">;
16
29
  constructor(rendererFactory: RendererFactory2, overlay: OverlayContainer);
17
30
  setTheme(mode: ThemeMode): void;
18
31
  private updateActiveTheme;
19
32
  private applyThemeToGlobal;
20
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<ThemeService, never>;
21
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<ThemeService>;
33
+ static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
34
+ static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
22
35
  }
23
36
 
24
37
  declare class DoohbotInput {
@@ -93,14 +106,82 @@ interface DoohbotApiConfig {
93
106
  */
94
107
  retryDelay?: number;
95
108
  }
96
- /**
97
- * Injection token for providing Doohbot API configuration
98
- */
99
- declare const DOOHBOT_API_CONFIG: InjectionToken<DoohbotApiConfig>;
109
+
110
+ declare class HttpService {
111
+ private http;
112
+ apiUrl: string;
113
+ constructor(http: HttpClient);
114
+ get(url: string, param?: object, nestedParam?: boolean, showLoader?: boolean, refresh?: boolean): Observable<any>;
115
+ private buildHttpParams;
116
+ post(url: string, param?: object, showLoader?: boolean): Observable<any>;
117
+ private returnResponse;
118
+ static ɵfac: i0.ɵɵFactoryDeclaration<HttpService, never>;
119
+ static ɵprov: i0.ɵɵInjectableDeclaration<HttpService>;
120
+ }
121
+
122
+ declare class AuthResult {
123
+ access_token: string;
124
+ refresh_token: string;
125
+ }
126
+
127
+ declare class ApiResponse<T> {
128
+ success: boolean;
129
+ message: string;
130
+ data?: T;
131
+ constructor(success: boolean, message: string, data?: T);
132
+ }
133
+
134
+ declare class LoginRequest {
135
+ username: string;
136
+ password: string;
137
+ }
138
+
139
+ declare class AccountService {
140
+ private http;
141
+ constructor(http: HttpService);
142
+ login(param?: LoginRequest, showLoader?: boolean): Observable<ApiResponse<AuthResult>>;
143
+ static ɵfac: i0.ɵɵFactoryDeclaration<AccountService, never>;
144
+ static ɵprov: i0.ɵɵInjectableDeclaration<AccountService>;
145
+ }
146
+
147
+ declare global {
148
+ interface Window {
149
+ storageEventAdded?: boolean;
150
+ tabCLoseEventAdded?: boolean;
151
+ }
152
+ }
153
+ declare class AuthService {
154
+ private router;
155
+ private http;
156
+ apiUrl: string;
157
+ storageKey: string;
158
+ secretKey: string;
159
+ companyCode: string;
160
+ jwtHelper: JwtHelperService;
161
+ constructor(router: Router, http: HttpClient);
162
+ logout(): Observable<boolean>;
163
+ setSession(session: AuthResult): void;
164
+ setLocalStorage(key: string, value: any): void;
165
+ getLocalStorage(key: string): any;
166
+ isAuthenticated(): boolean;
167
+ isTokenExpired(): boolean;
168
+ encrypt(value: string): any;
169
+ decrypt(value: string): string | null;
170
+ clearAuth(): void;
171
+ clearSession(): void;
172
+ clearTabInfo(): void;
173
+ clearStorage(): void;
174
+ clearCache(): void;
175
+ getUserId(): any;
176
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
177
+ static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
178
+ }
100
179
 
101
180
  declare class Doohbot extends DoohbotInput implements OnDestroy {
102
181
  private elementRef;
103
182
  private renderer;
183
+ private accountService;
184
+ private authService;
104
185
  config: DoohbotInput;
105
186
  platformTenant: string;
106
187
  subTenant: string;
@@ -111,24 +192,25 @@ declare class Doohbot extends DoohbotInput implements OnDestroy {
111
192
  primaryColor: string | undefined;
112
193
  apiConfig?: DoohbotApiConfig;
113
194
  isFullScreen: boolean;
114
- isChatOpen: _angular_core.WritableSignal<boolean>;
115
- isBotTyping: _angular_core.WritableSignal<boolean>;
195
+ isChatOpen: i0.WritableSignal<boolean>;
196
+ isBotTyping: i0.WritableSignal<boolean>;
116
197
  private messageService;
117
- messages: _angular_core.WritableSignal<_aakash58_chatbot.Message[]>;
198
+ messages: i0.WritableSignal<Message[]>;
118
199
  private lastReadMessageId;
119
200
  themeService: ThemeService;
120
201
  private tenantContextService;
121
202
  private contextSubscription?;
122
203
  maxMessageLength: number;
123
- messageError: _angular_core.WritableSignal<string | null>;
204
+ messageError: i0.WritableSignal<string | null>;
124
205
  dismissTimeout: number | null;
125
206
  predefinedMessages: string[];
126
207
  trackByMessageId(index: number, item: any): string;
127
208
  chatWindowRef: ElementRef;
128
- constructor(elementRef: ElementRef, renderer: Renderer2);
209
+ constructor(elementRef: ElementRef, renderer: Renderer2, accountService: AccountService, authService: AuthService);
129
210
  ngOnChanges(changes: SimpleChanges): void;
130
211
  ngOnInit(): void;
131
212
  ngOnDestroy(): void;
213
+ private loginUser;
132
214
  private updateCssVariables;
133
215
  /**
134
216
  * Update context when tenant or agent inputs change
@@ -142,9 +224,9 @@ declare class Doohbot extends DoohbotInput implements OnDestroy {
142
224
  clearChat(): void;
143
225
  sendMessage(text: string): Promise<void>;
144
226
  clearMessageError(): void;
145
- showSuggestionChips: _angular_core.Signal<boolean>;
146
- markAsReadEffect: _angular_core.EffectRef;
147
- unreadCount: _angular_core.Signal<number>;
227
+ showSuggestionChips: i0.Signal<boolean>;
228
+ markAsReadEffect: i0.EffectRef;
229
+ unreadCount: i0.Signal<number>;
148
230
  preFullscreenState: {
149
231
  width: string;
150
232
  height: string;
@@ -152,301 +234,8 @@ declare class Doohbot extends DoohbotInput implements OnDestroy {
152
234
  top: string;
153
235
  } | null;
154
236
  toggleFullScreen(): void;
155
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<Doohbot, never>;
156
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<Doohbot, "app-doohbot", never, { "config": { "alias": "config"; "required": false; }; "platformTenant": { "alias": "platformTenant"; "required": false; }; "subTenant": { "alias": "subTenant"; "required": false; }; "agent": { "alias": "agent"; "required": false; }; "buttonStyle": { "alias": "buttonStyle"; "required": false; }; "enableDrag": { "alias": "enableDrag"; "required": false; }; "enableResize": { "alias": "enableResize"; "required": false; }; "primaryColor": { "alias": "primaryColor"; "required": false; }; "apiConfig": { "alias": "apiConfig"; "required": false; }; }, {}, never, never, true, never>;
157
- }
158
-
159
- interface ChatContext$1 {
160
- platformTenant: string;
161
- subTenant: string;
162
- agent: string;
163
- }
164
- interface Message {
165
- id: string;
166
- sender: 'user' | 'bot';
167
- senderName?: string;
168
- text: string;
169
- timestamp?: Date;
170
- showSuggestions?: boolean;
171
- platformTenant?: string;
172
- subTenant?: string;
173
- agent?: string;
174
- }
175
- interface ChatIntent {
176
- patterns: string[];
177
- response: string;
178
- }
179
-
180
- /**
181
- * Request payload for chat API
182
- */
183
- interface ChatApiRequest {
184
- /**
185
- * User's message text
186
- */
187
- message: string;
188
- /**
189
- * Platform tenant identifier
190
- */
191
- platformTenant: string;
192
- /**
193
- * Sub-tenant or organization identifier
194
- */
195
- subTenant: string;
196
- /**
197
- * Agent or user identifier
198
- */
199
- agent: string;
200
- /**
201
- * Optional message history for context
202
- */
203
- history?: Message[];
204
- /**
205
- * Optional metadata
206
- */
207
- metadata?: Record<string, any>;
208
- /**
209
- * Timestamp of the request
210
- */
211
- timestamp?: string;
212
- }
213
- /**
214
- * Response from chat API
215
- */
216
- interface ChatApiResponse {
217
- /**
218
- * Bot's reply message
219
- */
220
- reply: string;
221
- /**
222
- * Optional confidence score (0-1)
223
- */
224
- confidence?: number;
225
- /**
226
- * Whether to show suggestion chips
227
- */
228
- showSuggestions?: boolean;
229
- /**
230
- * Optional suggested responses
231
- */
232
- suggestions?: string[];
233
- /**
234
- * Optional metadata from the API
235
- */
236
- metadata?: Record<string, any>;
237
- /**
238
- * Optional message ID from the backend
239
- */
240
- messageId?: string;
241
- }
242
- /**
243
- * Error response from chat API
244
- */
245
- interface ChatApiError {
246
- /**
247
- * Error message
248
- */
249
- message: string;
250
- /**
251
- * Error code
252
- */
253
- code?: string;
254
- /**
255
- * HTTP status code
256
- */
257
- statusCode?: number;
258
- /**
259
- * Additional error details
260
- */
261
- details?: any;
262
- }
263
- /**
264
- * API request state
265
- */
266
- declare enum ApiRequestState {
267
- IDLE = "idle",
268
- LOADING = "loading",
269
- SUCCESS = "success",
270
- ERROR = "error"
271
- }
272
-
273
- declare class MessageService {
274
- private messageStore;
275
- private currentContextKey;
276
- messages: _angular_core.WritableSignal<Message[]>;
277
- audioUnlocked: boolean;
278
- private enablePersistence;
279
- private readonly STORAGE_PREFIX;
280
- private apiService;
281
- isLoadingApi: _angular_core.WritableSignal<boolean>;
282
- apiError: _angular_core.WritableSignal<ChatApiError | null>;
283
- constructor();
284
- /**
285
- * Switch to a new context
286
- */
287
- switchContext(contextKey: string): void;
288
- /**
289
- * Get current context key
290
- */
291
- getCurrentContextKey(): string;
292
- /**
293
- * Clear messages for current context
294
- */
295
- clearMessages(): void;
296
- /**
297
- * Clear all messages across all contexts
298
- */
299
- clearAllMessages(): void;
300
- /**
301
- * Add message to current context
302
- */
303
- addMessage(message: Message): void;
304
- /**
305
- * Get messages for a specific context
306
- */
307
- getMessagesForContext(contextKey: string): Message[];
308
- /**
309
- * Get all context keys that have messages
310
- */
311
- getAllContextKeys(): string[];
312
- /**
313
- * Get bot reply - supports both API and local modes
314
- * @param userText User's message
315
- * @returns Promise with bot reply
316
- */
317
- getBotReply(userText: string): Promise<string>;
318
- /**
319
- * Get bot reply from API
320
- */
321
- private getBotReplyFromApi;
322
- /**
323
- * Get bot reply using local intent matching
324
- */
325
- private getBotReplyLocal;
326
- getFallbackReply(): string;
327
- isFallbackIntent(userText: string): boolean;
328
- unlockAudio(): void;
329
- playBotSound(): void;
330
- /**
331
- * Enable or disable localStorage persistence
332
- */
333
- setPersistence(enabled: boolean): void;
334
- /**
335
- * Private: Save context messages to store and persist
336
- */
337
- private saveContextMessages;
338
- /**
339
- * Private: Persist messages to localStorage
340
- */
341
- private persistMessages;
342
- /**
343
- * Private: Load all persisted messages from localStorage
344
- */
345
- private loadPersistedMessages;
346
- /**
347
- * Private: Clear all persisted messages from localStorage
348
- */
349
- private clearAllPersistedMessages;
350
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<MessageService, never>;
351
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<MessageService>;
352
- }
353
-
354
- declare class ChatbotApiService {
355
- private http;
356
- private tenantContext;
357
- private config;
358
- /**
359
- * Send a chat message to the API
360
- * @param message User's message text
361
- * @param history Optional message history for context
362
- * @returns Observable of the API response
363
- */
364
- sendMessage(message: string, history?: Message[]): Observable<ChatApiResponse>;
365
- /**
366
- * Build request payload with current tenant context
367
- */
368
- private buildRequest;
369
- /**
370
- * Build HTTP headers
371
- */
372
- private buildHeaders;
373
- /**
374
- * Apply retry strategy based on configuration
375
- */
376
- private applyRetryStrategy;
377
- /**
378
- * Determine if error should trigger a retry
379
- */
380
- private shouldRetry;
381
- /**
382
- * Validate API response
383
- */
384
- private validateResponse;
385
- /**
386
- * Handle API errors
387
- */
388
- private handleError;
389
- /**
390
- * Check if API is enabled
391
- */
392
- isApiEnabled(): boolean;
393
- /**
394
- * Get current API configuration
395
- */
396
- getConfig(): DoohbotApiConfig;
397
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatbotApiService, never>;
398
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<ChatbotApiService>;
399
- }
400
-
401
- interface ChatContext {
402
- platformTenant: string;
403
- subTenant: string;
404
- agent: string;
405
- }
406
- interface ContextChangeEvent {
407
- previous: ChatContext | null;
408
- current: ChatContext;
409
- contextKey: string;
410
- }
411
- declare class TenantContextService {
412
- private platformTenant;
413
- private subTenant;
414
- private agent;
415
- currentContext: _angular_core.Signal<ChatContext>;
416
- contextKey: _angular_core.Signal<string>;
417
- private contextChangeSubject;
418
- contextChange$: rxjs.Observable<ContextChangeEvent>;
419
- private previousContext;
420
- constructor();
421
- /**
422
- * Update the complete context
423
- */
424
- setContext(context: Partial<ChatContext>): void;
425
- /**
426
- * Update individual context properties
427
- */
428
- setPlatformTenant(platformTenant: string): void;
429
- setSubTenant(subTenant: string): void;
430
- setAgent(agent: string): void;
431
- /**
432
- * Get current context values
433
- */
434
- getPlatformTenant(): string;
435
- getSubTenant(): string;
436
- getAgent(): string;
437
- getContextKey(): string;
438
- getContext(): ChatContext;
439
- /**
440
- * Check if context has changed
441
- */
442
- private hasContextChanged;
443
- /**
444
- * Reset context to default
445
- */
446
- resetContext(): void;
447
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<TenantContextService, never>;
448
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<TenantContextService>;
237
+ static ɵfac: i0.ɵɵFactoryDeclaration<Doohbot, never>;
238
+ static ɵcmp: i0.ɵɵComponentDeclaration<Doohbot, "app-doohbot", never, { "config": { "alias": "config"; "required": false; }; "platformTenant": { "alias": "platformTenant"; "required": false; }; "subTenant": { "alias": "subTenant"; "required": false; }; "agent": { "alias": "agent"; "required": false; }; "buttonStyle": { "alias": "buttonStyle"; "required": false; }; "enableDrag": { "alias": "enableDrag"; "required": false; }; "enableResize": { "alias": "enableResize"; "required": false; }; "primaryColor": { "alias": "primaryColor"; "required": false; }; "apiConfig": { "alias": "apiConfig"; "required": false; }; }, {}, never, never, true, never>;
449
239
  }
450
240
 
451
- export { ApiRequestState, ChatbotApiService, DOOHBOT_API_CONFIG, Doohbot, DoohbotInput, MessageService, TenantContextService, ThemeService };
452
- export type { ChatApiError, ChatApiRequest, ChatApiResponse, ChatContext$1 as ChatContext, ChatIntent, ContextChangeEvent, DoohbotApiConfig, Message, ThemeMode };
241
+ export { Doohbot };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aakash58/chatbot",
3
- "version": "1.0.47",
3
+ "version": "1.0.49",
4
4
  "description": "Auth configuration",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^20.3.0",
@@ -0,0 +1,8 @@
1
+ {
2
+ "environment": "Dev",
3
+ "apiBaseUrl": "http://localhost:4000/",
4
+ "apiSegment": "api/",
5
+ "apiKey": "api/v1/",
6
+ "secretKey": "Nz3eQWWXAU",
7
+ "storageKey": "doohbot_storage"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "environment": "Prod",
3
+ "apiBaseUrl": "http://localhost:5200/",
4
+ "apiSegment": "api/v1/",
5
+ "apiKey": "api/v1/",
6
+ "secretKey": "Nz3eQWWXAU",
7
+ "storageKey": "doohbot_storage"
8
+ }