@iblai/web-utils 0.3.0 → 1.1.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 (41) hide show
  1. package/README.md +504 -0
  2. package/dist/data-layer/src/features/chat-files/api-slice.d.ts +185 -0
  3. package/dist/data-layer/src/features/chat-files/types.d.ts +32 -0
  4. package/dist/data-layer/src/features/core/api-slice.d.ts +419 -61
  5. package/dist/data-layer/src/features/core/constants.d.ts +3 -0
  6. package/dist/data-layer/src/features/core/custom-api-slice.d.ts +50 -50
  7. package/dist/data-layer/src/features/core/custom-public-image-asset-api-slice.d.ts +333 -0
  8. package/dist/data-layer/src/features/core/types.d.ts +33 -0
  9. package/dist/data-layer/src/features/credentials/api-slice.d.ts +62 -39
  10. package/dist/data-layer/src/features/mentor/api-slice.d.ts +1028 -188
  11. package/dist/data-layer/src/features/notifications/constants.d.ts +6 -0
  12. package/dist/data-layer/src/features/notifications/custom-api-slice.d.ts +43 -43
  13. package/dist/data-layer/src/features/notifications/types.d.ts +25 -2
  14. package/dist/data-layer/src/features/stripe/api-slice.d.ts +22 -0
  15. package/dist/data-layer/src/index.d.ts +3 -0
  16. package/dist/index.d.ts +447 -83
  17. package/dist/index.esm.js +1137 -196
  18. package/dist/index.esm.js.map +1 -1
  19. package/dist/index.js +1167 -193
  20. package/dist/index.js.map +1 -1
  21. package/dist/package.json +4 -2
  22. package/dist/web-utils/src/constants/chat.d.ts +8 -0
  23. package/dist/web-utils/src/features/files/filesSlice.d.ts +20 -0
  24. package/dist/web-utils/src/features/index.d.ts +1 -0
  25. package/dist/web-utils/src/hooks/chat/use-advanced-chat.d.ts +6 -4
  26. package/dist/web-utils/src/hooks/chat/use-chat-v2.d.ts +11 -1
  27. package/dist/web-utils/src/hooks/use-mentor-settings.d.ts +18 -15
  28. package/dist/web-utils/src/index.d.ts +2 -0
  29. package/dist/web-utils/src/index.web.d.ts +14 -12
  30. package/dist/web-utils/src/providers/auth-provider.d.ts +9 -1
  31. package/dist/web-utils/src/providers/mentor-provider.d.ts +2 -1
  32. package/dist/web-utils/src/providers/tenant-provider.d.ts +3 -1
  33. package/dist/web-utils/src/services/__tests__/file-upload.test.d.ts +1 -0
  34. package/dist/web-utils/src/services/file-upload.d.ts +60 -0
  35. package/dist/web-utils/src/services/index.d.ts +1 -0
  36. package/dist/web-utils/src/types/file-upload.d.ts +62 -0
  37. package/dist/web-utils/src/types/index.d.ts +1 -0
  38. package/dist/web-utils/src/utils/auth.d.ts +180 -0
  39. package/dist/web-utils/src/utils/index.d.ts +1 -0
  40. package/package.json +12 -13
  41. package/dist/web-utils/tsconfig.tsbuildinfo +0 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FreeUsageCount, StripeCustomerPortalRequest } from '@iblai/iblai-api';
2
- import { StripeContextResponse, UploadProfileImageResponse, RemoveProfileImageResponse, StorageService, TokenResponse } from '@iblai/data-layer';
2
+ import { StripeContextResponse, UploadProfileImageResponse, RemoveProfileImageResponse, StorageService, TokenResponse, FileUploadURLResponse } from '@iblai/data-layer';
3
3
  import * as React$1 from 'react';
4
4
  import React__default from 'react';
5
5
  import { PricingModalData as PricingModalData$1 } from '@web-utils/types/subscription';
@@ -7,6 +7,7 @@ import { OpUnitType } from 'dayjs';
7
7
  import duration from 'dayjs/plugin/duration';
8
8
  import { ChatStatus as ChatStatus$1 } from '@web-utils/features';
9
9
  import * as _reduxjs_toolkit from '@reduxjs/toolkit';
10
+ import { Slice } from '@reduxjs/toolkit';
10
11
  import * as react_jsx_runtime from 'react/jsx-runtime';
11
12
  import { Tenant as Tenant$3 } from '@web-utils/types';
12
13
  import { z } from 'zod';
@@ -317,12 +318,82 @@ declare const advancedTabs: ("chat" | "summarize" | "translate" | "expand")[];
317
318
  type AdvancedTab = keyof typeof advancedTabsProperties;
318
319
  declare const translatePrompt: (language: string) => string;
319
320
 
321
+ /**
322
+ * File reference sent via WebSocket to backend
323
+ * Backend uses this to retrieve file from S3
324
+ */
325
+ interface FileReference {
326
+ /** Unique identifier for the ChatFile record */
327
+ file_id: string;
328
+ /** S3 object key for the uploaded file */
329
+ file_key: string;
330
+ /** Original filename */
331
+ file_name: string;
332
+ /** MIME type of the file */
333
+ content_type: string;
334
+ /** File size in bytes */
335
+ file_size: number;
336
+ /** Presigned URL for displaying the file (optional, for UI) */
337
+ upload_url?: string;
338
+ }
339
+ /**
340
+ * File upload state for UI tracking
341
+ */
342
+ interface FileUploadState {
343
+ /** Original File object */
344
+ file: File;
345
+ /** Upload/processing status */
346
+ status: "pending" | "uploading" | "processing" | "success" | "error";
347
+ /** Upload progress (0-100) */
348
+ progress: number;
349
+ /** File reference after successful upload */
350
+ fileReference?: FileReference;
351
+ /** Error message if upload failed */
352
+ error?: string;
353
+ }
354
+ /**
355
+ * File processing event from WebSocket
356
+ */
357
+ type FileProcessingEvent = {
358
+ type: "file_processing_progress";
359
+ file_name: string;
360
+ progress: string;
361
+ } | {
362
+ type: "file_processing_success";
363
+ file_name: string;
364
+ file_url: string;
365
+ } | {
366
+ type: "file_error";
367
+ file_name?: string;
368
+ error: string;
369
+ developer_error?: string;
370
+ };
371
+ /**
372
+ * Upload progress callback
373
+ */
374
+ type UploadProgressCallback = (progress: number) => void;
375
+ /**
376
+ * File info extracted from File object
377
+ */
378
+ interface FileInfo {
379
+ fileName: string;
380
+ contentType: string;
381
+ fileSize: number;
382
+ }
383
+
320
384
  type MessageActionTypes = "redirectToAuthSpaJoinTenant";
321
385
  interface MessageAction {
322
386
  text: string;
323
387
  type: "primary" | "danger";
324
388
  actionType: MessageActionTypes;
325
389
  }
390
+ interface FileAttachment {
391
+ fileName: string;
392
+ fileType: string;
393
+ fileSize: number;
394
+ uploadUrl?: string;
395
+ fileId?: string;
396
+ }
326
397
  interface Message {
327
398
  id: string;
328
399
  role: "user" | "assistant" | "system";
@@ -333,9 +404,11 @@ interface Message {
333
404
  contentType?: string;
334
405
  visible: boolean;
335
406
  actions?: MessageAction[];
407
+ fileAttachments?: FileAttachment[];
336
408
  }
337
409
  type SendMessageOptions = {
338
410
  visible?: boolean;
411
+ fileReferences?: FileReference[];
339
412
  } | undefined;
340
413
  interface UseChatProps {
341
414
  wsUrl: string;
@@ -353,7 +426,7 @@ interface UseChatProps {
353
426
  hapticFeedback?: {
354
427
  impactAsync: (style: any) => Promise<void>;
355
428
  };
356
- redirectToAuthSpa: () => void;
429
+ redirectToAuthSpa: (redirectTo?: string, platformKey?: string, logout?: boolean) => void;
357
430
  store?: {
358
431
  sendMessage?: (text: string) => Promise<void>;
359
432
  };
@@ -429,6 +502,187 @@ declare const addProtocolToUrl: (url: string) => string;
429
502
  declare function getTimeAgo(createdAt: string): string;
430
503
  declare const formatRelativeTime: (timestamp: string) => string;
431
504
 
505
+ /**
506
+ * Authentication and Authorization Utilities
507
+ *
508
+ * This module provides utility functions for handling authentication flows,
509
+ * including redirects to auth SPA, cookie management, and session handling.
510
+ */
511
+ /**
512
+ * Check if the current window is inside an iframe
513
+ * @returns {boolean} True if running in an iframe, false otherwise
514
+ */
515
+ declare function isInIframe(): boolean;
516
+ /**
517
+ * Send a message to the parent website (when in iframe)
518
+ * @param payload - The data to send to parent window
519
+ */
520
+ declare function sendMessageToParentWebsite(payload: unknown): void;
521
+ /**
522
+ * Delete a cookie with specific name, path, and domain
523
+ * @param name - Cookie name
524
+ * @param path - Cookie path
525
+ * @param domain - Cookie domain
526
+ */
527
+ declare function deleteCookie(name: string, path: string, domain: string): void;
528
+ /**
529
+ * Get all possible domain parts for cookie deletion
530
+ * @param domain - The domain to split
531
+ * @returns Array of domain parts
532
+ * @example
533
+ * getDomainParts('app.example.com') // returns ['app.example.com', 'example.com', 'com']
534
+ */
535
+ declare function getDomainParts(domain: string): string[];
536
+ /**
537
+ * Delete a cookie across all possible domain variations
538
+ * @param name - Cookie name to delete
539
+ * @param childDomain - The current domain
540
+ */
541
+ declare function deleteCookieOnAllDomains(name: string, childDomain: string): void;
542
+ /**
543
+ * Get the parent domain from a given domain
544
+ * @param domain - The domain to process
545
+ * @returns The parent domain (e.g., 'app.example.com' → '.example.com')
546
+ */
547
+ declare function getParentDomain(domain?: string): string;
548
+ /**
549
+ * Set a cookie for authentication with cross-domain support
550
+ * @param name - Cookie name
551
+ * @param value - Cookie value
552
+ * @param days - Number of days until expiration (default: 365)
553
+ */
554
+ declare function setCookieForAuth(name: string, value: string, days?: number): void;
555
+ /**
556
+ * Clear all cookies for the current domain
557
+ */
558
+ declare function clearCookies(): void;
559
+ /**
560
+ * Check if user is currently logged in
561
+ * @param tokenKey - The localStorage key for the auth token (default: 'axd_token')
562
+ * @returns True if logged in, false otherwise
563
+ */
564
+ declare function isLoggedIn(tokenKey?: string): boolean;
565
+ /**
566
+ * Extract platform/tenant key from URL
567
+ * @param url - The URL to parse
568
+ * @param pattern - RegExp pattern to match platform key (default matches /platform/[key]/...)
569
+ * @returns The platform key or null if not found
570
+ */
571
+ declare function getPlatformKey(url: string, pattern?: RegExp): string | null;
572
+ interface RedirectToAuthSpaOptions {
573
+ /** URL to redirect to after auth (defaults to current path + search) */
574
+ redirectTo?: string;
575
+ /** Platform/tenant key */
576
+ platformKey?: string;
577
+ /** Whether this is a logout action */
578
+ logout?: boolean;
579
+ /** Whether to save redirect path to localStorage (default: true) */
580
+ saveRedirect?: boolean;
581
+ /** Auth SPA base URL */
582
+ authUrl: string;
583
+ /** Current app/platform identifier (e.g., 'mentor', 'skills') */
584
+ appName: string;
585
+ /** Query param names */
586
+ queryParams?: {
587
+ app?: string;
588
+ redirectTo?: string;
589
+ tenant?: string;
590
+ };
591
+ /** localStorage key for saving redirect path */
592
+ redirectPathStorageKey?: string;
593
+ /** Cookie names for cross-SPA sync */
594
+ cookieNames?: {
595
+ currentTenant?: string;
596
+ userData?: string;
597
+ tenant?: string;
598
+ logoutTimestamp?: string;
599
+ };
600
+ }
601
+ /**
602
+ * Redirect to authentication SPA for login/logout
603
+ *
604
+ * This function handles the complete authentication flow:
605
+ * - Clears localStorage and cookies on logout
606
+ * - Saves redirect path for post-auth return
607
+ * - Handles iframe scenarios
608
+ * - Syncs logout across multiple SPAs via cookies
609
+ *
610
+ * @param options - Configuration options for the redirect
611
+ *
612
+ * @example
613
+ * ```tsx
614
+ * // Basic usage
615
+ * redirectToAuthSpa({
616
+ * authUrl: 'https://auth.example.com',
617
+ * appName: 'mentor',
618
+ * });
619
+ *
620
+ * // With logout
621
+ * redirectToAuthSpa({
622
+ * authUrl: 'https://auth.example.com',
623
+ * appName: 'mentor',
624
+ * logout: true,
625
+ * platformKey: 'my-tenant',
626
+ * });
627
+ *
628
+ * // With custom redirect
629
+ * redirectToAuthSpa({
630
+ * authUrl: 'https://auth.example.com',
631
+ * appName: 'mentor',
632
+ * redirectTo: '/dashboard',
633
+ * platformKey: 'my-tenant',
634
+ * });
635
+ * ```
636
+ */
637
+ declare function redirectToAuthSpa(options: RedirectToAuthSpaOptions): Promise<void>;
638
+ /**
639
+ * Get the URL for joining a tenant (sign up flow)
640
+ * @param authUrl - Auth SPA base URL
641
+ * @param tenantKey - Tenant to join
642
+ * @param redirectUrl - URL to redirect to after joining (defaults to current URL)
643
+ * @returns The join URL
644
+ */
645
+ declare function getAuthSpaJoinUrl(authUrl: string, tenantKey?: string, redirectUrl?: string): string;
646
+ /**
647
+ * Redirect to auth SPA's join/signup page for a specific tenant
648
+ * @param authUrl - Auth SPA base URL
649
+ * @param tenantKey - Tenant to join
650
+ * @param redirectUrl - URL to redirect to after joining (defaults to current URL)
651
+ */
652
+ declare function redirectToAuthSpaJoinTenant(authUrl: string, tenantKey?: string, redirectUrl?: string): void;
653
+ interface HandleLogoutOptions {
654
+ /** URL to redirect to after logout (defaults to current origin) */
655
+ redirectUrl?: string;
656
+ /** Auth SPA base URL */
657
+ authUrl: string;
658
+ /** localStorage key for tenant */
659
+ tenantStorageKey?: string;
660
+ /** Cookie name for logout timestamp */
661
+ logoutTimestampCookie?: string;
662
+ /** Callback to execute before logout */
663
+ callback?: () => void;
664
+ }
665
+ /**
666
+ * Handle user logout
667
+ *
668
+ * This function:
669
+ * - Clears localStorage (preserving tenant)
670
+ * - Sets logout timestamp cookie for cross-SPA sync
671
+ * - Clears all cookies
672
+ * - Redirects to auth SPA logout endpoint
673
+ *
674
+ * @param options - Logout configuration options
675
+ *
676
+ * @example
677
+ * ```tsx
678
+ * handleLogout({
679
+ * authUrl: 'https://auth.example.com',
680
+ * redirectUrl: 'https://app.example.com',
681
+ * });
682
+ * ```
683
+ */
684
+ declare function handleLogout(options: HandleLogoutOptions): void;
685
+
432
686
  type ChatState = Record<AdvancedTab, Message[]>;
433
687
  interface SessionIds extends Record<AdvancedTab, string> {
434
688
  }
@@ -530,6 +784,94 @@ declare const selectShowingSharedChat: (state: {
530
784
  chatSliceShared: ChatSliceState;
531
785
  }) => boolean;
532
786
 
787
+ interface TimeTrackerConfig {
788
+ intervalSeconds: number;
789
+ onTimeUpdate: (url: string, timeSpent: number) => void;
790
+ getCurrentUrl: () => string;
791
+ onRouteChange?: (callback: () => void) => () => void;
792
+ }
793
+ interface TimeTrackerState {
794
+ currentUrl: string;
795
+ startTime: number;
796
+ intervalId: number | null;
797
+ routeUnsubscribe: (() => void) | null;
798
+ }
799
+ declare class TimeTracker {
800
+ private state;
801
+ private config;
802
+ constructor(config: TimeTrackerConfig);
803
+ private initialize;
804
+ private startTracking;
805
+ private clearInterval;
806
+ private resetTimer;
807
+ private getTimeSpent;
808
+ private sendTimeUpdate;
809
+ private handleRouteChange;
810
+ pause(): void;
811
+ resume(): void;
812
+ destroy(): void;
813
+ getCurrentUrl(): string;
814
+ getTimeSpentSinceLastReset(): number;
815
+ }
816
+
817
+ interface UseTimeTrackerConfig {
818
+ intervalSeconds: number;
819
+ onTimeUpdate: (url: string, timeSpent: number) => void;
820
+ enabled?: boolean;
821
+ getCurrentUrl?: () => string;
822
+ onRouteChange?: (callback: () => void) => () => void;
823
+ }
824
+ interface UseTimeTrackerReturn {
825
+ pause: () => void;
826
+ resume: () => void;
827
+ getCurrentUrl: () => string;
828
+ getTimeSpentSinceLastReset: () => number;
829
+ }
830
+ declare function useTimeTracker(config: UseTimeTrackerConfig): UseTimeTrackerReturn;
831
+
832
+ interface UseTimeTrackerNativeConfig {
833
+ intervalSeconds: number;
834
+ onTimeUpdate: (url: string, timeSpent: number) => void;
835
+ getCurrentRoute: () => string;
836
+ onRouteChange?: (callback: () => void) => () => void;
837
+ enabled?: boolean;
838
+ }
839
+ interface UseTimeTrackerNativeReturn {
840
+ pause: () => void;
841
+ resume: () => void;
842
+ getCurrentUrl: () => string;
843
+ getTimeSpentSinceLastReset: () => number;
844
+ }
845
+ declare function useTimeTrackerNative(config: UseTimeTrackerNativeConfig): UseTimeTrackerNativeReturn;
846
+
847
+ interface AttachedFile {
848
+ id: string;
849
+ fileName: string;
850
+ fileType: string;
851
+ fileSize: number;
852
+ uploadUrl: string;
853
+ uploadProgress: number;
854
+ uploadStatus: "pending" | "uploading" | "processing" | "success" | "error";
855
+ fileKey?: string;
856
+ fileId?: string;
857
+ retryCount?: number;
858
+ fileUrl?: string;
859
+ }
860
+ interface FilesState {
861
+ attachedFiles: AttachedFile[];
862
+ }
863
+ declare const filesSlice: Slice<FilesState>;
864
+ declare const addFiles: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
865
+ declare const removeFile: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
866
+ declare const clearFiles: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
867
+ declare const updateFileProgress: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
868
+ declare const updateFileStatus: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
869
+ declare const updateFileUrl: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
870
+ declare const updateFileMetadata: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
871
+ declare const updateFileRetryCount: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
872
+ declare const updateFileUrlFromWebSocket: _reduxjs_toolkit.ActionCreatorWithoutPayload<`${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPayload<any, `${string}/${string}`> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, never, any> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, never> | _reduxjs_toolkit.ActionCreatorWithPreparedPayload<any[], any, `${string}/${string}`, any, any>;
873
+ declare const filesReducer: Reducer<State>;
874
+
533
875
  type ChatMode = "advanced" | "default";
534
876
 
535
877
  interface UseExternalPricingProps {
@@ -619,15 +961,17 @@ type Props$5 = {
619
961
  username: string;
620
962
  token: string;
621
963
  wsUrl: string;
622
- redirectToAuthSpa: () => void;
964
+ redirectToAuthSpa: (redirectTo?: string, platformKey?: string, logout?: boolean) => void;
623
965
  stopGenerationWsUrl: string;
624
966
  sendMessageToParentWebsite?: (payload: unknown) => void;
625
967
  errorHandler?: (message: string, error?: any) => void;
626
968
  isPreviewMode?: boolean;
627
969
  mentorShareableToken?: string | null;
628
970
  on402Error?: (message: Record<string, unknown>) => void;
971
+ cachedSessionId?: Record<string, string>;
972
+ onStartNewChat?: (sessionId: string) => void;
629
973
  };
630
- declare function useAdvancedChat({ tenantKey, mentorId, username, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, }: Props$5): {
974
+ declare function useAdvancedChat({ tenantKey, mentorId, username, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, cachedSessionId, onStartNewChat, }: Props$5): {
631
975
  messages: Message[];
632
976
  isStreaming: boolean;
633
977
  status: ChatStatus;
@@ -651,7 +995,7 @@ declare function useAdvancedChat({ tenantKey, mentorId, username, token, wsUrl,
651
995
  isConnected: React__default.MutableRefObject<boolean>;
652
996
  messageQueue: React__default.MutableRefObject<any[]>;
653
997
  sessionIds: SessionIds;
654
- enableSafetyDisclaimer: any;
998
+ enableSafetyDisclaimer: string | boolean;
655
999
  resetConnection: () => void;
656
1000
  };
657
1001
 
@@ -775,22 +1119,25 @@ type Props$3 = {
775
1119
  tenantKey: string;
776
1120
  username: string;
777
1121
  };
778
- declare function useMentorSettings({ mentorId, tenantKey, username }: Props$3): {
779
- data: {
780
- profileImage: string | null | undefined;
781
- greetingMethod: string | undefined;
782
- proactiveResponse: string | undefined;
783
- llmProvider: any;
784
- llmName: string | undefined;
785
- mentorUniqueId: string | undefined;
786
- mentorName: string | undefined;
787
- enableGuidedPrompts: boolean | undefined;
788
- mentorSlug: string | undefined;
789
- safetyDisclaimer: any;
790
- mentorTools: any;
791
- allowAnonymous: boolean | undefined;
792
- };
1122
+ type MentorSettingsData = {
1123
+ profileImage?: string | null;
1124
+ greetingMethod?: string | null;
1125
+ proactiveResponse?: string | null;
1126
+ llmProvider?: string | null;
1127
+ llmName?: string | null;
1128
+ mentorUniqueId?: string | null;
1129
+ mentorVisibility?: string | null | any;
1130
+ mentorName?: string | null;
1131
+ enableGuidedPrompts?: boolean | null;
1132
+ mentorSlug?: string | null;
1133
+ safetyDisclaimer?: string | null;
1134
+ mentorTools?: any[] | null;
1135
+ allowAnonymous?: boolean | null;
793
1136
  };
1137
+ type UseMentorSettingsReturn = {
1138
+ data: MentorSettingsData;
1139
+ };
1140
+ declare function useMentorSettings({ mentorId, tenantKey, username, }: Props$3): UseMentorSettingsReturn;
794
1141
 
795
1142
  /**
796
1143
  * Sync authentication state to cookies (web only)
@@ -798,6 +1145,12 @@ declare function useMentorSettings({ mentorId, tenantKey, username }: Props$3):
798
1145
  * On React Native, this is a no-op
799
1146
  */
800
1147
  declare function syncAuthToCookies(storageService: StorageService): Promise<void>;
1148
+ /**
1149
+ * Clear current tenant cookie only (web only)
1150
+ * Should be called before tenant switching
1151
+ * On React Native, this is a no-op
1152
+ */
1153
+ declare function clearCurrentTenantCookie(): void;
801
1154
  /**
802
1155
  * Clear all authentication cookies (web only)
803
1156
  * Should be called on logout
@@ -840,7 +1193,7 @@ type Props$2 = {
840
1193
  middleware?: Map<string | RegExp, () => Promise<boolean>>;
841
1194
  onAuthSuccess?: () => void;
842
1195
  onAuthFailure?: (reason: string) => void;
843
- redirectToAuthSpa: (redirectTo?: string, platformKey?: string, logout?: boolean) => void;
1196
+ redirectToAuthSpa: (redirectTo?: string, platformKey?: string, logout?: boolean, saveRedirect?: boolean) => void;
844
1197
  hasNonExpiredAuthToken: () => boolean;
845
1198
  username: string;
846
1199
  pathname: string;
@@ -890,6 +1243,7 @@ type Props$1 = {
890
1243
  requestedMentorId?: string;
891
1244
  handleMentorNotFound?: () => Promise<void>;
892
1245
  forceDetermineMentor?: boolean;
1246
+ onComplete?: () => void;
893
1247
  };
894
1248
  /**
895
1249
  * MentorProvider Component
@@ -900,7 +1254,7 @@ type Props$1 = {
900
1254
  * 3. Manages redirection based on mentor availability
901
1255
  * 4. Integrates with tenant context for access control
902
1256
  */
903
- declare function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redirectToAuthSpa, redirectToMentor, onLoadMentorsPermissions, redirectToNoMentorsPage, redirectToCreateMentor, username, isAdmin, mainTenantKey, requestedMentorId, handleMentorNotFound, forceDetermineMentor, }: Props$1): React__default.ReactNode;
1257
+ declare function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redirectToAuthSpa, redirectToMentor, onLoadMentorsPermissions, redirectToNoMentorsPage, redirectToCreateMentor, username, isAdmin, mainTenantKey, requestedMentorId, handleMentorNotFound, forceDetermineMentor, onComplete, }: Props$1): React__default.ReactNode;
904
1258
 
905
1259
  /**
906
1260
  * Type definition for the tenant context
@@ -944,6 +1298,8 @@ type Props = {
944
1298
  saveUserTokens?: (tokens: TokenResponse) => void;
945
1299
  saveTenant?: (tenant: string) => void;
946
1300
  onAutoJoinUserToTenant?: (platformName: string) => void;
1301
+ redirectToAuthSpa?: (redirectTo?: string, platformKey?: string, logout?: boolean, saveRedirect?: boolean) => void;
1302
+ username?: string;
947
1303
  };
948
1304
  /**
949
1305
  * TenantProvider Component
@@ -955,67 +1311,75 @@ type Props = {
955
1311
  * 4. Handles tenant-specific domain redirects
956
1312
  * 5. Maintains tenant access state
957
1313
  */
958
- declare function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, }: Props): string | number | bigint | boolean | Iterable<React__default.ReactNode> | Promise<string | number | bigint | boolean | React__default.ReactPortal | React__default.ReactElement<unknown, string | React__default.JSXElementConstructor<any>> | Iterable<React__default.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
959
-
960
- interface TimeTrackerConfig {
961
- intervalSeconds: number;
962
- onTimeUpdate: (url: string, timeSpent: number) => void;
963
- getCurrentUrl: () => string;
964
- onRouteChange?: (callback: () => void) => () => void;
965
- }
966
- interface TimeTrackerState {
967
- currentUrl: string;
968
- startTime: number;
969
- intervalId: number | null;
970
- routeUnsubscribe: (() => void) | null;
971
- }
972
- declare class TimeTracker {
973
- private state;
974
- private config;
975
- constructor(config: TimeTrackerConfig);
976
- private initialize;
977
- private startTracking;
978
- private clearInterval;
979
- private resetTimer;
980
- private getTimeSpent;
981
- private sendTimeUpdate;
982
- private handleRouteChange;
983
- pause(): void;
984
- resume(): void;
985
- destroy(): void;
986
- getCurrentUrl(): string;
987
- getTimeSpentSinceLastReset(): number;
988
- }
1314
+ declare function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, }: Props): string | number | bigint | boolean | Iterable<React__default.ReactNode> | Promise<string | number | bigint | boolean | React__default.ReactPortal | React__default.ReactElement<unknown, string | React__default.JSXElementConstructor<any>> | Iterable<React__default.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
989
1315
 
990
- interface UseTimeTrackerConfig {
991
- intervalSeconds: number;
992
- onTimeUpdate: (url: string, timeSpent: number) => void;
993
- enabled?: boolean;
994
- getCurrentUrl?: () => string;
995
- onRouteChange?: (callback: () => void) => () => void;
996
- }
997
- interface UseTimeTrackerReturn {
998
- pause: () => void;
999
- resume: () => void;
1000
- getCurrentUrl: () => string;
1001
- getTimeSpentSinceLastReset: () => number;
1002
- }
1003
- declare function useTimeTracker(config: UseTimeTrackerConfig): UseTimeTrackerReturn;
1316
+ /**
1317
+ * Chat area size constants
1318
+ */
1319
+ declare const CHAT_AREA_SIZE: {
1320
+ readonly DEFAULT: 672;
1321
+ readonly MIN: 672;
1322
+ readonly MAX: 1024;
1323
+ };
1004
1324
 
1005
- interface UseTimeTrackerNativeConfig {
1006
- intervalSeconds: number;
1007
- onTimeUpdate: (url: string, timeSpent: number) => void;
1008
- getCurrentRoute: () => string;
1009
- onRouteChange?: (callback: () => void) => () => void;
1010
- enabled?: boolean;
1011
- }
1012
- interface UseTimeTrackerNativeReturn {
1013
- pause: () => void;
1014
- resume: () => void;
1015
- getCurrentUrl: () => string;
1016
- getTimeSpentSinceLastReset: () => number;
1017
- }
1018
- declare function useTimeTrackerNative(config: UseTimeTrackerNativeConfig): UseTimeTrackerNativeReturn;
1325
+ /**
1326
+ * Extract file information from File object
1327
+ */
1328
+ declare function getFileInfo(file: File): FileInfo;
1329
+ /**
1330
+ * Request presigned S3 URL from backend
1331
+ * Note: This function should be called via the RTK Query mutation hook
1332
+ * This is a helper to show the data flow
1333
+ */
1334
+ declare function requestPresignedUrl(sessionId: string, file: File, getUploadUrlFn: (params: {
1335
+ org: string;
1336
+ userId: string;
1337
+ requestBody: {
1338
+ session_id: string;
1339
+ file_name: string;
1340
+ content_type: string;
1341
+ file_size: number;
1342
+ };
1343
+ }) => Promise<FileUploadURLResponse>, org: string, userId: string): Promise<FileUploadURLResponse>;
1344
+ /**
1345
+ * Upload file directly to S3 using presigned URL
1346
+ * Uses axios for cross-platform support (web + React Native)
1347
+ */
1348
+ declare function uploadToS3(presignedUrl: string, file: File, contentType: string, onProgress?: UploadProgressCallback): Promise<void>;
1349
+ /**
1350
+ * Complete file upload flow:
1351
+ * 1. Request presigned URL
1352
+ * 2. Upload to S3
1353
+ * 3. Return file reference
1354
+ */
1355
+ declare function createFileReference(file: File, sessionId: string, getUploadUrlFn: (params: {
1356
+ org: string;
1357
+ userId: string;
1358
+ requestBody: {
1359
+ session_id: string;
1360
+ file_name: string;
1361
+ content_type: string;
1362
+ file_size: number;
1363
+ };
1364
+ }) => Promise<FileUploadURLResponse>, org: string, userId: string, onProgress?: UploadProgressCallback): Promise<FileReference>;
1365
+ /**
1366
+ * Upload multiple files and return their references
1367
+ */
1368
+ declare function createMultipleFileReferences(files: File[], sessionId: string, getUploadUrlFn: (params: {
1369
+ org: string;
1370
+ userId: string;
1371
+ requestBody: {
1372
+ session_id: string;
1373
+ file_name: string;
1374
+ content_type: string;
1375
+ file_size: number;
1376
+ };
1377
+ }) => Promise<FileUploadURLResponse>, org: string, userId: string, onFileProgress?: (fileIndex: number, progress: number) => void): Promise<FileReference[]>;
1378
+ /**
1379
+ * Validate file before upload
1380
+ * Returns error message if invalid, null if valid
1381
+ */
1382
+ declare function validateFile(file: File, maxSizeBytes?: number, allowedTypes?: string[]): string | null;
1019
1383
 
1020
- export { ALPHANUMERIC_32_REGEX, ANONYMOUS_USERNAME, AuthContext, AuthContextProvider, AuthProvider, LOCAL_STORAGE_KEYS, MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS, MENTOR_CHAT_DOCUMENTS_EXTENSIONS, METADATAS, MentorProvider, SUBSCRIPTION_MESSAGES, SUBSCRIPTION_PACKAGES, SUBSCRIPTION_TRIGGERS, SUBSCRIPTION_V2_TRIGGERS, SubscriptionFlow, SubscriptionFlowV2, TOOLS, TenantContext, TenantContextProvider, TenantProvider, TimeTracker, addProtocolToUrl, advancedTabs, advancedTabsProperties, chatActions, chatSliceReducerShared, clearAuthCookies, defaultSessionIds, formatRelativeTime, getInitials, getTimeAgo, getUserName, isAlphaNumeric32, isJSON, loadMetadataConfig, selectActiveChatMessages, selectActiveTab, selectChats, selectCurrentStreamingMessage, selectDocumentFilter, selectIframeContext, selectIsError, selectIsPending, selectIsStopped, selectIsTyping, selectNumberOfActiveChatMessages, selectSessionId, selectSessionIds, selectShouldStartNewChat, selectShowingSharedChat, selectStatus, selectStreaming, selectToken, selectTokenEnabled, selectTools, syncAuthToCookies, tenantKeySchema, tenantSchema, translatePrompt, useAdvancedChat, useAuthContext, useAuthProvider, useChat, useDayJs, useExternalPricingPlan, useMentorSettings, useMentorTools, useProfileImageUpload, useSubscriptionHandler, useSubscriptionHandlerV2, useTenantContext, useTenantMetadata, useTimeTracker, useTimeTrackerNative, useUserProfileUpdate, userDataSchema };
1021
- export type { AdvancedTab, AuthContextType, ChatMode, ChatState, ChatStatus, CreateStripeCustomerPortalRequest, Message, MessageAction, PricingModalData, Prompt, SendMessageOptions, SessionIds, StreamingMessage, SubscriptionFlowConfig, SubscriptionFlowConfigV2, Tenant, TenantContextType, TenantKeyMentorIdParams, TenantMetadata, TimeTrackerConfig, TimeTrackerState, TopTrialBannerProps, UseChatProps, UseChatReturn, UseExternalPricingProps, UseProfileImageUploadOptions, UseProfileImageUploadReturn, UseTimeTrackerConfig, UseTimeTrackerNativeConfig, UseTimeTrackerNativeReturn, UseTimeTrackerReturn, UseUserProfileUpdateResult, UserProfileUpdateData };
1384
+ export { ALPHANUMERIC_32_REGEX, ANONYMOUS_USERNAME, AuthContext, AuthContextProvider, AuthProvider, CHAT_AREA_SIZE, LOCAL_STORAGE_KEYS, MAX_INITIAL_WEBSOCKET_CONNECTION_ATTEMPTS, MENTOR_CHAT_DOCUMENTS_EXTENSIONS, METADATAS, MentorProvider, SUBSCRIPTION_MESSAGES, SUBSCRIPTION_PACKAGES, SUBSCRIPTION_TRIGGERS, SUBSCRIPTION_V2_TRIGGERS, SubscriptionFlow, SubscriptionFlowV2, TOOLS, TenantContext, TenantContextProvider, TenantProvider, TimeTracker, addFiles, addProtocolToUrl, advancedTabs, advancedTabsProperties, chatActions, chatSliceReducerShared, clearAuthCookies, clearCookies, clearCurrentTenantCookie, clearFiles, createFileReference, createMultipleFileReferences, defaultSessionIds, deleteCookie, deleteCookieOnAllDomains, filesReducer, filesSlice, formatRelativeTime, getAuthSpaJoinUrl, getDomainParts, getFileInfo, getInitials, getParentDomain, getPlatformKey, getTimeAgo, getUserName, handleLogout, isAlphaNumeric32, isInIframe, isJSON, isLoggedIn, loadMetadataConfig, redirectToAuthSpa, redirectToAuthSpaJoinTenant, removeFile, requestPresignedUrl, selectActiveChatMessages, selectActiveTab, selectChats, selectCurrentStreamingMessage, selectDocumentFilter, selectIframeContext, selectIsError, selectIsPending, selectIsStopped, selectIsTyping, selectNumberOfActiveChatMessages, selectSessionId, selectSessionIds, selectShouldStartNewChat, selectShowingSharedChat, selectStatus, selectStreaming, selectToken, selectTokenEnabled, selectTools, sendMessageToParentWebsite, setCookieForAuth, syncAuthToCookies, tenantKeySchema, tenantSchema, translatePrompt, updateFileMetadata, updateFileProgress, updateFileRetryCount, updateFileStatus, updateFileUrl, updateFileUrlFromWebSocket, uploadToS3, useAdvancedChat, useAuthContext, useAuthProvider, useChat, useDayJs, useExternalPricingPlan, useMentorSettings, useMentorTools, useProfileImageUpload, useSubscriptionHandler, useSubscriptionHandlerV2, useTenantContext, useTenantMetadata, useTimeTracker, useTimeTrackerNative, useUserProfileUpdate, userDataSchema, validateFile };
1385
+ export type { AdvancedTab, AttachedFile, AuthContextType, ChatMode, ChatState, ChatStatus, CreateStripeCustomerPortalRequest, FileAttachment, FileInfo, FileProcessingEvent, FileReference, FileUploadState, FilesState, HandleLogoutOptions, Message, MessageAction, PricingModalData, Prompt, RedirectToAuthSpaOptions, SendMessageOptions, SessionIds, StreamingMessage, SubscriptionFlowConfig, SubscriptionFlowConfigV2, Tenant, TenantContextType, TenantKeyMentorIdParams, TenantMetadata, TimeTrackerConfig, TimeTrackerState, TopTrialBannerProps, UploadProgressCallback, UseChatProps, UseChatReturn, UseExternalPricingProps, UseProfileImageUploadOptions, UseProfileImageUploadReturn, UseTimeTrackerConfig, UseTimeTrackerNativeConfig, UseTimeTrackerNativeReturn, UseTimeTrackerReturn, UseUserProfileUpdateResult, UserProfileUpdateData };