@aslaluroba/help-center 3.1.0 → 4.0.0

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 (59) hide show
  1. package/README.md +95 -126
  2. package/fesm2022/aslaluroba-help-center.mjs +2151 -1586
  3. package/fesm2022/aslaluroba-help-center.mjs.map +1 -1
  4. package/index.d.ts +595 -3
  5. package/package.json +1 -1
  6. package/public_api.d.ts +0 -12
  7. package/src/app/chat/chat.component.d.ts +0 -38
  8. package/src/app/chat/components/chat-avatar/chat-avatar.component.d.ts +0 -8
  9. package/src/app/chat/components/chat-input/chat-input.component.d.ts +0 -42
  10. package/src/app/chat/components/chat-message/chat-message.component.d.ts +0 -18
  11. package/src/app/chat/components/chat-separator/chat-separator.component.d.ts +0 -5
  12. package/src/app/chat/components/chat-typing-indicator/chat-typing-indicator.component.d.ts +0 -5
  13. package/src/app/chat/components/image-attachment/image-attachment.component.d.ts +0 -18
  14. package/src/app/chat/components/image-preview-dialog/image-preview-dialog.component.d.ts +0 -25
  15. package/src/app/help-center-widget/components/arrow-animation/arrow-animation.component.d.ts +0 -11
  16. package/src/app/help-center-widget/components/footer/footer.component.d.ts +0 -7
  17. package/src/app/help-center-widget/components/help-button/help-button.component.d.ts +0 -8
  18. package/src/app/help-center-widget/components/help-popup/help-popup.component.d.ts +0 -105
  19. package/src/app/help-center-widget/components/index.d.ts +0 -5
  20. package/src/app/help-center-widget/components/intro-section/intro-section.component.d.ts +0 -11
  21. package/src/app/help-center-widget/help-center-widget.component.d.ts +0 -134
  22. package/src/app/help-screen-data/help-screen-data.component.d.ts +0 -59
  23. package/src/app/language.service.d.ts +0 -11
  24. package/src/app/pipes/translate.pipe.d.ts +0 -9
  25. package/src/app/services/ably.service.d.ts +0 -13
  26. package/src/app/services/api.service.d.ts +0 -16
  27. package/src/app/services/file-upload.service.d.ts +0 -33
  28. package/src/app/services/help-center-config.service.d.ts +0 -12
  29. package/src/app/services/theme.service.d.ts +0 -40
  30. package/src/app/services/token.service.d.ts +0 -10
  31. package/src/app/services/translation.service.d.ts +0 -15
  32. package/src/app/shared/components/back-button/back-button.component.d.ts +0 -10
  33. package/src/app/shared/components/back-button/index.d.ts +0 -1
  34. package/src/app/shared/components/button/button.component.d.ts +0 -36
  35. package/src/app/shared/components/button/index.d.ts +0 -1
  36. package/src/app/shared/components/card/card.component.d.ts +0 -38
  37. package/src/app/shared/components/card/index.d.ts +0 -1
  38. package/src/app/shared/components/chat-header/chat-header.component.d.ts +0 -11
  39. package/src/app/shared/components/chat-header/index.d.ts +0 -1
  40. package/src/app/shared/components/close-button/close-button.component.d.ts +0 -9
  41. package/src/app/shared/components/close-button/index.d.ts +0 -1
  42. package/src/app/shared/components/confirmation-dialog/confirmation-dialog.component.d.ts +0 -12
  43. package/src/app/shared/components/confirmation-dialog/index.d.ts +0 -1
  44. package/src/app/shared/components/header/header.component.d.ts +0 -16
  45. package/src/app/shared/components/header/index.d.ts +0 -1
  46. package/src/app/shared/components/index.d.ts +0 -13
  47. package/src/app/shared/components/loading/index.d.ts +0 -1
  48. package/src/app/shared/components/loading/loading.component.d.ts +0 -6
  49. package/src/app/shared/components/logo/index.d.ts +0 -1
  50. package/src/app/shared/components/logo/logo.component.d.ts +0 -9
  51. package/src/app/shared/components/markdown-renderer/index.d.ts +0 -1
  52. package/src/app/shared/components/markdown-renderer/markdown-renderer.component.d.ts +0 -16
  53. package/src/app/shared/components/menu-dropdown/index.d.ts +0 -1
  54. package/src/app/shared/components/menu-dropdown/menu-dropdown.component.d.ts +0 -11
  55. package/src/app/shared/components/review-dialog/index.d.ts +0 -1
  56. package/src/app/shared/components/review-dialog/review-dialog.component.d.ts +0 -32
  57. package/src/app/shared/components/simple-close-button/index.d.ts +0 -1
  58. package/src/app/shared/components/simple-close-button/simple-close-button.component.d.ts +0 -7
  59. package/src/app/types.d.ts +0 -73
package/index.d.ts CHANGED
@@ -1,5 +1,597 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { OnInit, OnDestroy, ElementRef, PipeTransform } from '@angular/core';
3
+ import { Observable } from 'rxjs';
4
+
5
+ type Language = 'en' | 'ar';
6
+ interface TokenResponse {
7
+ token: string;
8
+ expiresIn: number;
9
+ }
10
+ interface Option {
11
+ id: string;
12
+ helpScreenId: string;
13
+ parentOptionId: string | null;
14
+ nestedOptions: Option[];
15
+ title: string;
16
+ paragraphs: string[];
17
+ chatWithUs: boolean;
18
+ assistantId?: string;
19
+ assistant?: {
20
+ id: string;
21
+ tenantId: string;
22
+ tenant: {
23
+ id: string;
24
+ name: string;
25
+ key: string;
26
+ };
27
+ name: string;
28
+ openAIAssistantId: string;
29
+ greeting: string;
30
+ closing: string;
31
+ };
32
+ hasNestedOptions: boolean;
33
+ order: number;
34
+ icon?: string;
35
+ }
36
+ interface Message$1 {
37
+ id: string | number;
38
+ sender: 'user' | 'assistant' | 'agent';
39
+ senderType: number;
40
+ messageContent: string;
41
+ sentAt: Date;
42
+ isSeen: boolean;
43
+ attachmentIds?: string[];
44
+ }
45
+ interface Tenant {
46
+ id: string;
47
+ name: string;
48
+ key: string;
49
+ }
50
+ interface Assistant {
51
+ id: string;
52
+ tenantId: string;
53
+ tenant: Tenant;
54
+ name: string;
55
+ openAIAssistantId: string;
56
+ greeting: string;
57
+ closing: string;
58
+ }
59
+ interface HelpScreenFile {
60
+ id: string;
61
+ name: string;
62
+ url: string;
63
+ type: string;
64
+ size?: number;
65
+ }
66
+ interface HelpScreenOption {
67
+ id: string;
68
+ helpScreenId: string;
69
+ parentOptionId: string | null;
70
+ nestedOptions: HelpScreenOption[];
71
+ title: string;
72
+ paragraphs: string[];
73
+ files: HelpScreenFile[];
74
+ chatWithUs: boolean;
75
+ assistantId?: string;
76
+ assistant?: Assistant;
77
+ hasNestedOptions: boolean;
78
+ order: number;
79
+ icon?: string;
80
+ }
81
+ interface HelpScreenData {
82
+ id: string;
83
+ tenantId: string;
84
+ tenant: Tenant;
85
+ title: string;
86
+ description: string;
87
+ options: HelpScreenOption[];
88
+ chatWithUs: boolean;
89
+ }
90
+ interface PresignUploadRequestDto {
91
+ name: string;
92
+ contentType: string;
93
+ sizeBytes: number;
94
+ pathData: {
95
+ type: number;
96
+ chatSessionId: string;
97
+ };
98
+ }
99
+ interface PresignUploadResponse {
100
+ id: string;
101
+ uploadUrl: string;
102
+ path: string;
103
+ expiresAt: string;
104
+ }
105
+ interface PresignDownloadResponse {
106
+ id: string;
107
+ name: string;
108
+ downloadUrl: string;
109
+ contentType: string;
110
+ expiresAt: string;
111
+ }
112
+ interface SelectedFileDto {
113
+ file: File;
114
+ previewUrl: string;
115
+ uploading: boolean;
116
+ uploadedId: string | null;
117
+ error: string | null;
118
+ }
119
+ interface UploadResult {
120
+ fileId: string;
121
+ success: boolean;
122
+ error?: string;
123
+ }
124
+
125
+ interface Message {
126
+ id: string | number;
127
+ sender: 'user' | 'assistant' | 'agent';
128
+ senderType: number;
129
+ messageContent: string;
130
+ sentAt: Date;
131
+ isSeen: boolean;
132
+ attachmentIds?: string[];
133
+ }
134
+ declare class HelpCenterWidgetComponent implements OnInit, OnDestroy {
135
+ getToken: _angular_core.InputSignal<() => Promise<string>>;
136
+ helpScreenId: _angular_core.InputSignal<string>;
137
+ showArrow: _angular_core.InputSignal<boolean>;
138
+ messageLabel: _angular_core.InputSignal<string>;
139
+ currentLang: _angular_core.InputSignal<string>;
140
+ isIntroScreenEnabled: _angular_core.InputSignal<boolean>;
141
+ primaryColor: _angular_core.InputSignal<string>;
142
+ logoUrl: _angular_core.InputSignal<string>;
143
+ chatMessagesContainer: ElementRef;
144
+ isRTL: _angular_core.Signal<boolean>;
145
+ isPopupOpen: _angular_core.WritableSignal<boolean>;
146
+ helpScreenData: _angular_core.WritableSignal<HelpScreenData>;
147
+ status: _angular_core.WritableSignal<"idle" | "failed" | "loading" | "succeeded">;
148
+ error: _angular_core.WritableSignal<string>;
149
+ showArrowAnimation: _angular_core.WritableSignal<boolean>;
150
+ showTooltip: _angular_core.WritableSignal<boolean>;
151
+ sessionId: _angular_core.WritableSignal<string>;
152
+ isAblyConnected: _angular_core.WritableSignal<boolean>;
153
+ isChatClosed: _angular_core.WritableSignal<boolean>;
154
+ showChat: _angular_core.WritableSignal<boolean>;
155
+ messageText: _angular_core.WritableSignal<string>;
156
+ isTyping: _angular_core.WritableSignal<boolean>;
157
+ messages: _angular_core.WritableSignal<Message[]>;
158
+ showHelpScreenData: _angular_core.WritableSignal<boolean>;
159
+ chatIsLoading: _angular_core.WritableSignal<boolean>;
160
+ ablyToken: _angular_core.WritableSignal<string>;
161
+ needsAgent: _angular_core.WritableSignal<boolean>;
162
+ assistantStatus: _angular_core.WritableSignal<"typing" | "idle">;
163
+ selectedOption: _angular_core.WritableSignal<Option>;
164
+ selectedNestedOption: _angular_core.WritableSignal<Option>;
165
+ showEndChatConfirmation: _angular_core.WritableSignal<boolean>;
166
+ showStartNewChatConfirmation: _angular_core.WritableSignal<boolean>;
167
+ showReviewDialog: _angular_core.WritableSignal<boolean>;
168
+ isSubmittingReview: _angular_core.WritableSignal<boolean>;
169
+ isStartingNewChat: _angular_core.WritableSignal<boolean>;
170
+ pendingNewChatOption: _angular_core.WritableSignal<Option>;
171
+ private apiService;
172
+ private translationService;
173
+ private themeService;
174
+ private chatSessionService;
175
+ private fileUploadService;
176
+ private destroyRef;
177
+ private themeEffectRef?;
178
+ private languageEffectRef?;
179
+ constructor();
180
+ ngOnInit(): void;
181
+ ngOnDestroy(): void;
182
+ handleTogglePopup(): Promise<void>;
183
+ private fetchHelpScreenData;
184
+ createChatSession(option?: Option): Promise<{
185
+ chatSession: {
186
+ id: string;
187
+ };
188
+ ablyToken: string;
189
+ }>;
190
+ sendMessage(event?: {
191
+ text: string;
192
+ attachmentIds: string[];
193
+ pendingFiles?: File[];
194
+ } | string): Promise<void>;
195
+ handleReceiveMessage(message: string | {
196
+ content: string;
197
+ attachments?: string[];
198
+ }, senderType: number, needsAgent: boolean): void;
199
+ private getSenderType;
200
+ private hasActiveChatSession;
201
+ private isWelcomeMessage;
202
+ handleStartNewChat(option: Option): Promise<void>;
203
+ private startNewChatSession;
204
+ handleStartChat(option: Option): Promise<void>;
205
+ handleEndChat(): Promise<void>;
206
+ confirmEndChat(): Promise<void>;
207
+ handleReviewSubmit(reviewData: {
208
+ rating: number;
209
+ comment: string;
210
+ }): Promise<void>;
211
+ handleReviewSkip(): Promise<void>;
212
+ private endChatSession;
213
+ cancelEndChat(): void;
214
+ confirmStartNewChat(): Promise<void>;
215
+ cancelStartNewChat(): void;
216
+ private clearCurrentChat;
217
+ private startNewChatWithOption;
218
+ /**
219
+ * Closes a chat session.
220
+ * @deprecated Use chatSessionService.closeSession() instead
221
+ * @private
222
+ */
223
+ private closeChatSession;
224
+ handleClosePopup(): void;
225
+ handleCloseArrowAnimation(): void;
226
+ handleBack(): void;
227
+ handleShowChat(): void;
228
+ selectOption(option: Option): void;
229
+ selectNestedOption(nestedOption: Option): void;
230
+ handleShowHelpScreenData(): void;
231
+ handleHideHelpScreenData(): void;
232
+ private scrollTimeout?;
233
+ private scrollToBottom;
234
+ getDirection(): "ltr" | "rtl";
235
+ get helpScreenDataList(): {
236
+ icon: string;
237
+ title: string;
238
+ description: string;
239
+ actionLabel: string;
240
+ action: () => Promise<void>;
241
+ }[];
242
+ navigateToUrl(url: string): void;
243
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HelpCenterWidgetComponent, never>;
244
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<HelpCenterWidgetComponent, "app-help-center-widget", never, { "getToken": { "alias": "getToken"; "required": true; "isSignal": true; }; "helpScreenId": { "alias": "helpScreenId"; "required": true; "isSignal": true; }; "showArrow": { "alias": "showArrow"; "required": false; "isSignal": true; }; "messageLabel": { "alias": "messageLabel"; "required": false; "isSignal": true; }; "currentLang": { "alias": "currentLang"; "required": false; "isSignal": true; }; "isIntroScreenEnabled": { "alias": "isIntroScreenEnabled"; "required": false; "isSignal": true; }; "primaryColor": { "alias": "primaryColor"; "required": false; "isSignal": true; }; "logoUrl": { "alias": "logoUrl"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
245
+ }
246
+
247
+ type GetTokenFn = () => Promise<string>;
1
248
  /**
2
- * Generated bundle index. Do not edit.
249
+ * Service for managing help center configuration.
250
+ *
251
+ * Stores configuration such as API base URL and token retrieval function.
252
+ * This service is used internally by other services to access configuration.
253
+ *
254
+ * @publicApi
3
255
  */
4
- /// <amd-module name="@aslaluroba/help-center" />
5
- export * from './public_api';
256
+ declare class HelpCenterConfigService {
257
+ private _apiBaseUrl;
258
+ private _getTokenFn?;
259
+ setApiBaseUrl(url: string): void;
260
+ getApiBaseUrl(): string;
261
+ setGetTokenFn(fn: GetTokenFn): void;
262
+ getTokenFn(): GetTokenFn | undefined;
263
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<HelpCenterConfigService, never>;
264
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<HelpCenterConfigService>;
265
+ }
266
+
267
+ /**
268
+ * Service for handling API requests with automatic authentication token management.
269
+ *
270
+ * Features:
271
+ * - Automatic token refresh on expiry
272
+ * - Token validation and format checking
273
+ * - Secure token storage using sessionStorage
274
+ * - Endpoint validation to prevent SSRF attacks
275
+ *
276
+ * @publicApi
277
+ */
278
+ declare class ApiService {
279
+ private getTokenFunction;
280
+ private baseUrl;
281
+ /**
282
+ * Initialize the API service with authentication configuration.
283
+ *
284
+ * This must be called before making any API requests. The service will use
285
+ * the provided token function to fetch and refresh tokens automatically.
286
+ *
287
+ * @param config Configuration object containing token function and optional base URL
288
+ * @throws Error if getToken function is not provided
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * apiService.initialize({
293
+ * getToken: async () => {
294
+ * const response = await fetch('/auth/token');
295
+ * const data = await response.json();
296
+ * return data.token;
297
+ * },
298
+ * baseUrl: 'https://api.example.com'
299
+ * });
300
+ * ```
301
+ */
302
+ initialize(config: ApiConfig): void;
303
+ /**
304
+ * Validate token format
305
+ * JWT tokens must have exactly 3 parts separated by dots (header.payload.signature)
306
+ */
307
+ private validateToken;
308
+ /**
309
+ * Retrieves a valid authentication token, fetching a new one if expired.
310
+ *
311
+ * Tokens are cached for 15 minutes. The service provides backward compatibility:
312
+ * - Checks localStorage first for existing tokens (backward compatibility)
313
+ * - Falls back to sessionStorage if no token found in localStorage
314
+ * - New tokens are stored in sessionStorage (preferred) or localStorage (fallback)
315
+ * - Automatically migrates tokens from localStorage to sessionStorage when found
316
+ *
317
+ * After expiry, a new token is automatically fetched using the configured getToken function.
318
+ *
319
+ * @param forceRefresh If true, forces a new token fetch even if current token is valid
320
+ * @returns Promise resolving to a valid authentication token
321
+ * @throws Error if API service is not initialized or token format is invalid
322
+ */
323
+ getValidToken(forceRefresh?: boolean): Promise<string>;
324
+ private fetchWithAuth;
325
+ /**
326
+ * Validate endpoint to prevent SSRF vulnerabilities
327
+ *
328
+ * Protects against:
329
+ * - Absolute URLs with any protocol (case-insensitive)
330
+ * - Protocol-relative URLs
331
+ * - Dangerous protocols (ftp, file, data, javascript, etc.)
332
+ * - URL-encoded path traversal
333
+ * - Double-encoded attacks
334
+ */
335
+ private validateEndpoint;
336
+ /**
337
+ * Makes an authenticated API request with automatic token management.
338
+ *
339
+ * This method automatically:
340
+ * - Validates the endpoint to prevent SSRF attacks
341
+ * - Adds authentication headers with a valid token
342
+ * - Retries with a fresh token if authentication fails
343
+ * - Handles errors and returns appropriate error messages
344
+ *
345
+ * @param endpoint API endpoint path (relative to baseUrl)
346
+ * @param method HTTP method (default: 'GET')
347
+ * @param body Request body object (will be JSON stringified)
348
+ * @param customHeaders Additional headers to include in the request
349
+ * @returns Promise resolving to the Response object
350
+ * @throws Error if endpoint validation fails, request fails, or authentication fails
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * // GET request
355
+ * const response = await apiService.apiRequest('client/help-screens/123');
356
+ * const data = await response.json();
357
+ *
358
+ * // POST request
359
+ * const response = await apiService.apiRequest(
360
+ * 'client/chat-sessions',
361
+ * 'POST',
362
+ * { helpScreenId: '123' }
363
+ * );
364
+ * ```
365
+ */
366
+ apiRequest<T = unknown>(endpoint: string, method?: string, body?: T | null, customHeaders?: Record<string, string>): Promise<Response>;
367
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ApiService, never>;
368
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ApiService>;
369
+ }
370
+
371
+ /**
372
+ * Service for retrieving authentication tokens from the configured token function.
373
+ *
374
+ * This service acts as a wrapper around the configured token retrieval function,
375
+ * providing a consistent interface for token management.
376
+ *
377
+ * @publicApi
378
+ */
379
+ declare class TokenService {
380
+ private config;
381
+ /**
382
+ * Retrieves an authentication token using the configured token function.
383
+ *
384
+ * @returns Promise resolving to a TokenResponse containing the token and expiry time
385
+ * @throws Error if no token function is configured
386
+ */
387
+ getToken(): Promise<TokenResponse>;
388
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TokenService, never>;
389
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<TokenService>;
390
+ }
391
+
392
+ type TranslationKey = 'ChatIntroMessage' | 'BabylaiTitle' | 'BabylaiDescription' | 'ChatNow' | 'TryBableAI' | 'ContactUs' | 'PickTopicTitle' | 'BabylAI' | 'ChatPlaceholder' | 'PoweredByBabylAI' | 'EndChat' | 'LeavingDialogTitle' | 'LeavingDialogBody' | 'StartNewChatDialogTitle' | 'StartNewChatDialogBody' | 'ReviewDialogTitle' | 'ReviewDialogDescription' | 'ReviewDialogRatingLabel' | 'ReviewDialogCommentLabel' | 'ReviewDialogCommentPlaceholder' | 'ReviewDialogSubmitButton' | 'ReviewDialogSkipButton' | 'Confirm' | 'Cancel' | 'Close' | 'Back' | 'title' | 'ErrorFetchingHelpScreen' | 'ErrorSendingMessage' | 'ErrorStartingChat' | 'ErrorEndingChat' | 'ErrorSubmittingReview' | 'ErrorClosingChat' | 'ErrorCreatingSession' | 'ErrorNetworkFailure' | 'ErrorUnknown' | 'ErrorMessageTooLong' | 'ErrorMessageEmpty';
393
+ /**
394
+ * Service for managing translations and language switching.
395
+ *
396
+ * Supports multiple languages (currently English and Arabic) with RTL support.
397
+ * Provides reactive language changes through Observable pattern.
398
+ *
399
+ * @publicApi
400
+ */
401
+ declare class TranslationService {
402
+ private translations;
403
+ private _currentLang;
404
+ readonly currentLang: Observable<Language>;
405
+ /**
406
+ * Translates a translation key to the current language.
407
+ *
408
+ * @param key Translation key to look up
409
+ * @returns Translated string in the current language, or the key itself if translation not found
410
+ *
411
+ * @example
412
+ * ```typescript
413
+ * const message = translationService.translate('ChatNow');
414
+ * // Returns 'Chat Now' in English or 'دردش الآن' in Arabic
415
+ * ```
416
+ */
417
+ translate(key: TranslationKey): string;
418
+ /**
419
+ * Sets the current language for translations.
420
+ *
421
+ * @param lang Language code ('en' or 'ar')
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * translationService.setLanguage('ar'); // Switch to Arabic
426
+ * ```
427
+ */
428
+ setLanguage(lang: Language): void;
429
+ /**
430
+ * Gets the current language code.
431
+ *
432
+ * @returns Current language code ('en' or 'ar')
433
+ */
434
+ getCurrentLang(): Language;
435
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TranslationService, never>;
436
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<TranslationService>;
437
+ }
438
+
439
+ /**
440
+ * Service for managing chat session lifecycle and operations.
441
+ *
442
+ * Handles:
443
+ * - Chat session creation and management
444
+ * - Ably connection management
445
+ * - Message sending operations
446
+ *
447
+ * @publicApi
448
+ */
449
+ declare class ChatSessionService {
450
+ private apiService;
451
+ /**
452
+ * Creates a new chat session with the specified option.
453
+ *
454
+ * @param option The help screen option to create a chat session for
455
+ * @param helpScreenId The help screen ID
456
+ * @param currentLang Current language code for API headers
457
+ * @returns Promise resolving to session data including sessionId and ablyToken
458
+ * @throws Error if session creation fails
459
+ */
460
+ createSession(option: Option, helpScreenId: string, currentLang: string): Promise<{
461
+ chatSession: {
462
+ id: string;
463
+ };
464
+ ablyToken: string;
465
+ }>;
466
+ /**
467
+ * Establishes Ably real-time connection for a chat session.
468
+ *
469
+ * @param sessionId The chat session ID
470
+ * @param ablyToken The Ably authentication token
471
+ * @param onMessageReceived Callback function for received messages
472
+ * @param tenantId The tenant ID for the connection
473
+ * @param option Optional option for token refresh (needed for token renewal)
474
+ * @param helpScreenId Optional help screen ID for token refresh
475
+ * @param currentLang Optional current language for token refresh
476
+ */
477
+ establishAblyConnection(sessionId: string, ablyToken: string, onMessageReceived: (message: string | {
478
+ content: string;
479
+ attachments?: string[];
480
+ }, senderType: number, needsAgent: boolean) => void, tenantId: string, option?: Option, helpScreenId?: string, currentLang?: string): Promise<void>;
481
+ /**
482
+ * Sends a message in an active chat session.
483
+ *
484
+ * @param sessionId The chat session ID
485
+ * @param messageContent The message content to send
486
+ * @param currentLang Current language code for API headers
487
+ * @throws Error if message sending fails
488
+ */
489
+ sendMessage(sessionId: string, messageContent: string, currentLang: string, attachmentIds?: string[]): Promise<void>;
490
+ /**
491
+ * Closes a chat session.
492
+ *
493
+ * @param sessionId The chat session ID to close
494
+ * @param currentLang Current language code for API headers
495
+ * @returns Promise resolving to the close response
496
+ * @throws Error if session closing fails
497
+ */
498
+ closeSession(sessionId: string, currentLang: string): Promise<unknown>;
499
+ /**
500
+ * Submits a review for a chat session.
501
+ *
502
+ * @param sessionId The chat session ID
503
+ * @param rating Rating value (1-5)
504
+ * @param comment Review comment (10-500 characters)
505
+ * @param currentLang Current language code for API headers
506
+ * @throws Error if review submission fails
507
+ */
508
+ submitReview(sessionId: string, rating: number, comment: string, currentLang: string): Promise<void>;
509
+ /**
510
+ * Stops the Ably connection.
511
+ */
512
+ stopConnection(): Promise<void>;
513
+ /**
514
+ * Checks if Ably connection is active.
515
+ *
516
+ * @returns True if connection is active, false otherwise
517
+ */
518
+ isConnectionActive(): boolean;
519
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatSessionService, never>;
520
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ChatSessionService>;
521
+ }
522
+
523
+ /**
524
+ * Service for managing language switching.
525
+ *
526
+ * Provides a simplified interface for switching between supported languages.
527
+ * This service wraps TranslationService for easier language management.
528
+ *
529
+ * @publicApi
530
+ */
531
+ declare class LanguageService {
532
+ private translationService;
533
+ /**
534
+ * Switches the application language.
535
+ *
536
+ * @param language Language code to switch to ('en' or 'ar')
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * languageService.switchLanguage('ar'); // Switch to Arabic
541
+ * ```
542
+ */
543
+ switchLanguage(language: Language): void;
544
+ /**
545
+ * Gets the current application language.
546
+ *
547
+ * @returns Current language code ('en' or 'ar')
548
+ */
549
+ getCurrentLang(): Language;
550
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<LanguageService, never>;
551
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<LanguageService>;
552
+ }
553
+
554
+ /**
555
+ * Angular pipe for translating keys in templates.
556
+ *
557
+ * Usage in templates:
558
+ * ```html
559
+ * {{ 'ChatNow' | translate }}
560
+ * ```
561
+ *
562
+ * @publicApi
563
+ */
564
+ declare class TranslatePipe implements PipeTransform {
565
+ private translationService;
566
+ /**
567
+ * Transforms a translation key into the translated string for the current language.
568
+ *
569
+ * @param key Translation key to look up
570
+ * @returns Translated string in the current language
571
+ */
572
+ transform(key: TranslationKey): string;
573
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TranslatePipe, never>;
574
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<TranslatePipe, "translate", true>;
575
+ }
576
+
577
+ /**
578
+ * Configuration interface for API service initialization
579
+ *
580
+ * @publicApi
581
+ */
582
+ interface ApiConfig {
583
+ /**
584
+ * Function that returns a promise resolving to an authentication token
585
+ * This function is called when tokens need to be refreshed
586
+ */
587
+ getToken: () => Promise<string>;
588
+ /**
589
+ * Optional base URL for API requests
590
+ * Defaults to 'https://babylai.net/api' if not provided
591
+ * Should use HTTPS in production environments
592
+ */
593
+ baseUrl?: string;
594
+ }
595
+
596
+ export { ApiService, ChatSessionService, HelpCenterConfigService, HelpCenterWidgetComponent, LanguageService, TokenService, TranslatePipe, TranslationService };
597
+ export type { ApiConfig, Assistant, GetTokenFn, HelpScreenData, HelpScreenFile, HelpScreenOption, Language, Message$1 as Message, Option, PresignDownloadResponse, PresignUploadRequestDto, PresignUploadResponse, SelectedFileDto, Tenant, TokenResponse, TranslationKey, UploadResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aslaluroba/help-center",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "peerDependencies": {
package/public_api.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export * from './src/app/types';
2
- export interface ApiConfig {
3
- getToken: () => Promise<string>;
4
- baseUrl?: string;
5
- }
6
- export * from './src/app/help-center-widget/help-center-widget.component';
7
- export * from './src/app/services/help-center-config.service';
8
- export * from './src/app/services/api.service';
9
- export * from './src/app/services/token.service';
10
- export * from './src/app/services/translation.service';
11
- export * from './src/app/language.service';
12
- export * from './src/app/pipes/translate.pipe';
@@ -1,38 +0,0 @@
1
- import { EventEmitter, ElementRef, OnInit, OnChanges, SimpleChanges } from '@angular/core';
2
- import { Message } from '../types';
3
- import 'prismjs';
4
- import 'prismjs/components/prism-typescript';
5
- import 'prismjs/components/prism-javascript';
6
- import 'prismjs/components/prism-css';
7
- import 'prismjs/components/prism-json';
8
- import * as i0 from "@angular/core";
9
- export declare class ChatComponent implements OnInit, OnChanges {
10
- messages: Message[];
11
- needsAgent: boolean;
12
- assistantStatus: string;
13
- isAblyConnected: boolean;
14
- isChatClosed: boolean;
15
- currentLang: string;
16
- loading: boolean;
17
- sessionId: string | null;
18
- sendMessageEvent: EventEmitter<{
19
- text: string;
20
- attachmentIds: string[];
21
- pendingFiles?: File[];
22
- }>;
23
- chatMessagesContainer: ElementRef;
24
- firstAgentMessageIndex: number;
25
- ngOnInit(): void;
26
- ngOnChanges(changes: SimpleChanges): void;
27
- findFirstAgentMessageIndex(): void;
28
- handleSendMessage(event: {
29
- text: string;
30
- attachmentIds: string[];
31
- pendingFiles?: File[];
32
- }): void;
33
- ngAfterViewChecked(): void;
34
- scrollToBottom(): void;
35
- hasAgentMessageBeenSent(messages: any[]): boolean;
36
- static ɵfac: i0.ɵɵFactoryDeclaration<ChatComponent, never>;
37
- static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "app-chat", never, { "messages": { "alias": "messages"; "required": false; }; "needsAgent": { "alias": "needsAgent"; "required": false; }; "assistantStatus": { "alias": "assistantStatus"; "required": false; }; "isAblyConnected": { "alias": "isAblyConnected"; "required": false; }; "isChatClosed": { "alias": "isChatClosed"; "required": false; }; "currentLang": { "alias": "currentLang"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "sessionId": { "alias": "sessionId"; "required": false; }; }, { "sendMessageEvent": "sendMessageEvent"; }, never, never, true, never>;
38
- }
@@ -1,8 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class ChatAvatarComponent {
3
- senderType: number;
4
- needsAgent: boolean;
5
- isHidden: boolean;
6
- static ɵfac: i0.ɵɵFactoryDeclaration<ChatAvatarComponent, never>;
7
- static ɵcmp: i0.ɵɵComponentDeclaration<ChatAvatarComponent, "app-chat-avatar", never, { "senderType": { "alias": "senderType"; "required": false; }; "needsAgent": { "alias": "needsAgent"; "required": false; }; "isHidden": { "alias": "isHidden"; "required": false; }; }, {}, never, never, true, never>;
8
- }