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