@iblai/web-utils 0.2.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 (127) hide show
  1. package/dist/data-layer/src/config.d.ts +7 -0
  2. package/dist/data-layer/src/constants.d.ts +30 -0
  3. package/dist/data-layer/src/core/index.d.ts +4 -0
  4. package/dist/data-layer/src/features/analytics/api-slice.d.ts +1600 -0
  5. package/dist/data-layer/src/features/analytics/constants.d.ts +66 -0
  6. package/dist/data-layer/src/features/analytics/types.d.ts +100 -0
  7. package/dist/data-layer/src/features/api-keys/api-slice.d.ts +665 -0
  8. package/dist/data-layer/src/features/apps/api-slice.d.ts +683 -0
  9. package/dist/data-layer/src/features/auth/api-slice.d.ts +137 -0
  10. package/dist/data-layer/src/features/auth/constants.d.ts +8 -0
  11. package/dist/data-layer/src/features/auth/types.d.ts +13 -0
  12. package/dist/data-layer/src/features/billing/api-slice.d.ts +349 -0
  13. package/dist/data-layer/src/features/career/api-slice.d.ts +687 -0
  14. package/dist/data-layer/src/features/catalog/api-slice.d.ts +6602 -0
  15. package/dist/data-layer/src/features/chat/api-slice.d.ts +1832 -0
  16. package/dist/data-layer/src/features/chat-history/api-slice.d.ts +1386 -0
  17. package/dist/data-layer/src/features/constants.d.ts +3 -0
  18. package/dist/data-layer/src/features/core/api-slice.d.ts +653 -0
  19. package/dist/data-layer/src/features/core/constants.d.ts +4 -0
  20. package/dist/data-layer/src/features/credentials/api-slice.d.ts +2129 -0
  21. package/dist/data-layer/src/features/credentials/constants.d.ts +28 -0
  22. package/dist/data-layer/src/features/credentials/custom-api-slice.d.ts +1284 -0
  23. package/dist/data-layer/src/features/credentials/types.d.ts +16 -0
  24. package/dist/data-layer/src/features/datasets/api-slice.d.ts +576 -0
  25. package/dist/data-layer/src/features/llms/api-slice.d.ts +333 -0
  26. package/dist/data-layer/src/features/mentor/api-slice.d.ts +4298 -0
  27. package/dist/data-layer/src/features/mentor/constants.d.ts +31 -0
  28. package/dist/data-layer/src/features/mentor/custom-api-slice.d.ts +268 -0
  29. package/dist/data-layer/src/features/mentor/types.d.ts +38 -0
  30. package/dist/data-layer/src/features/mentor-categories/api-slice.d.ts +311 -0
  31. package/dist/data-layer/src/features/notifications/api-slice.d.ts +946 -0
  32. package/dist/data-layer/src/features/per-learner/api-slice.d.ts +1213 -0
  33. package/dist/data-layer/src/features/platform/api-slice.d.ts +1124 -0
  34. package/dist/data-layer/src/features/prompts/api-slice.d.ts +2276 -0
  35. package/dist/data-layer/src/features/search/api-slice.d.ts +1939 -0
  36. package/dist/data-layer/src/features/sessions/api-slice.d.ts +705 -0
  37. package/dist/data-layer/src/features/skills/api-slice.d.ts +1235 -0
  38. package/dist/data-layer/src/features/stripe/api-slice.d.ts +620 -0
  39. package/dist/data-layer/src/features/stripe/constants.d.ts +15 -0
  40. package/dist/data-layer/src/features/stripe/types.d.ts +9 -0
  41. package/dist/data-layer/src/features/tenant/api-slice.d.ts +759 -0
  42. package/dist/data-layer/src/features/tenant/constants.d.ts +11 -0
  43. package/dist/data-layer/src/features/tenant/types.d.ts +18 -0
  44. package/dist/data-layer/src/features/tenant-logo/api-slice.d.ts +349 -0
  45. package/dist/data-layer/src/features/tenant-logo/constants.d.ts +24 -0
  46. package/dist/data-layer/src/features/tools/api-slice.d.ts +333 -0
  47. package/dist/data-layer/src/features/training-documents/api-slice.d.ts +922 -0
  48. package/dist/data-layer/src/features/user/api-slice.d.ts +1703 -0
  49. package/dist/data-layer/src/features/user/constants.d.ts +40 -0
  50. package/dist/data-layer/src/features/user/types.d.ts +107 -0
  51. package/dist/data-layer/src/features/user-invitations/api-slice.d.ts +718 -0
  52. package/dist/data-layer/src/features/utils.d.ts +66 -0
  53. package/dist/data-layer/src/index.d.ts +47 -0
  54. package/dist/data-layer/src/reducers/index.d.ts +2 -0
  55. package/dist/data-layer/src/reducers/mentor.d.ts +2 -0
  56. package/dist/data-layer/src/reducers/skills.d.ts +1148 -0
  57. package/dist/data-layer/src/services/StorageService.d.ts +5 -0
  58. package/dist/data-layer/src/utils/index.d.ts +2 -0
  59. package/dist/features/chat/slice.d.ts +59 -0
  60. package/dist/features/index.d.ts +1 -0
  61. package/dist/hooks/chat/use-advanced-chat.d.ts +41 -0
  62. package/dist/hooks/chat/use-chat-v2.d.ts +53 -0
  63. package/dist/hooks/chat/use-chat.d.ts +52 -0
  64. package/dist/hooks/chat/use-get-chat-details.d.ts +13 -0
  65. package/dist/hooks/index.d.ts +10 -0
  66. package/dist/hooks/subscription/class-subscription-flow.d.ts +70 -0
  67. package/dist/hooks/subscription/constants.d.ts +4 -0
  68. package/dist/hooks/subscription/use-subscription-handler.d.ts +11 -0
  69. package/dist/hooks/subscription-v2/class-subscription-flow.d.ts +62 -0
  70. package/dist/hooks/subscription-v2/constants.d.ts +5 -0
  71. package/dist/hooks/subscription-v2/use-external-pricing-plan.d.ts +7 -0
  72. package/dist/hooks/subscription-v2/use-subscription-handler.d.ts +12 -0
  73. package/dist/hooks/use-day-js.d.ts +7 -0
  74. package/dist/index.d.ts +5 -0
  75. package/dist/index.esm.js +15076 -0
  76. package/dist/index.esm.js.map +1 -0
  77. package/dist/index.js +15160 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/package.json +53 -0
  80. package/dist/providers/auth-provider.d.ts +63 -0
  81. package/dist/providers/index.d.ts +3 -0
  82. package/dist/providers/mentor-provider.d.ts +40 -0
  83. package/dist/providers/tenant-provider.d.ts +60 -0
  84. package/dist/types/chat.d.ts +1 -0
  85. package/dist/types/index.d.ts +55 -0
  86. package/dist/types/subscription.d.ts +18 -0
  87. package/dist/utils/constants.d.ts +13 -0
  88. package/dist/utils/data/advanced-tab.d.ts +62 -0
  89. package/dist/utils/helpers.d.ts +1 -0
  90. package/dist/utils/index.d.ts +3 -0
  91. package/dist/web-utils/src/features/chat/slice.d.ts +91 -0
  92. package/dist/web-utils/src/features/index.d.ts +1 -0
  93. package/dist/web-utils/src/hooks/chat/use-advanced-chat.d.ts +48 -0
  94. package/dist/web-utils/src/hooks/chat/use-chat-v2.d.ts +56 -0
  95. package/dist/web-utils/src/hooks/chat/use-chat.d.ts +52 -0
  96. package/dist/web-utils/src/hooks/chat/use-get-chat-details.d.ts +13 -0
  97. package/dist/web-utils/src/hooks/chat/use-mentor-tools.d.ts +18 -0
  98. package/dist/web-utils/src/hooks/index.d.ts +15 -0
  99. package/dist/web-utils/src/hooks/profile/use-profile-image-upload.d.ts +13 -0
  100. package/dist/web-utils/src/hooks/profile/use-user-profile-update.d.ts +28 -0
  101. package/dist/web-utils/src/hooks/subscription/class-subscription-flow.d.ts +70 -0
  102. package/dist/web-utils/src/hooks/subscription/constants.d.ts +4 -0
  103. package/dist/web-utils/src/hooks/subscription/use-subscription-handler.d.ts +11 -0
  104. package/dist/web-utils/src/hooks/subscription-v2/class-subscription-flow.d.ts +77 -0
  105. package/dist/web-utils/src/hooks/subscription-v2/constants.d.ts +51 -0
  106. package/dist/web-utils/src/hooks/subscription-v2/use-external-pricing-plan.d.ts +7 -0
  107. package/dist/web-utils/src/hooks/subscription-v2/use-subscription-handler.d.ts +16 -0
  108. package/dist/web-utils/src/hooks/tenant-metadata/config-loader.d.ts +41 -0
  109. package/dist/web-utils/src/hooks/tenant-metadata/constants.d.ts +9 -0
  110. package/dist/web-utils/src/hooks/tenant-metadata/index.d.ts +5 -0
  111. package/dist/web-utils/src/hooks/tenant-metadata/types.d.ts +9 -0
  112. package/dist/web-utils/src/hooks/tenant-metadata/use-tenant-metadata.d.ts +24 -0
  113. package/dist/web-utils/src/hooks/use-day-js.d.ts +7 -0
  114. package/dist/web-utils/src/hooks/use-mentor-settings.d.ts +21 -0
  115. package/dist/web-utils/src/index.d.ts +5 -0
  116. package/dist/web-utils/src/providers/auth-provider.d.ts +64 -0
  117. package/dist/web-utils/src/providers/index.d.ts +3 -0
  118. package/dist/web-utils/src/providers/mentor-provider.d.ts +40 -0
  119. package/dist/web-utils/src/providers/tenant-provider.d.ts +63 -0
  120. package/dist/web-utils/src/types/chat.d.ts +1 -0
  121. package/dist/web-utils/src/types/index.d.ts +55 -0
  122. package/dist/web-utils/src/types/subscription.d.ts +18 -0
  123. package/dist/web-utils/src/utils/constants.d.ts +37 -0
  124. package/dist/web-utils/src/utils/data/advanced-tab.d.ts +62 -0
  125. package/dist/web-utils/src/utils/helpers.d.ts +6 -0
  126. package/dist/web-utils/src/utils/index.d.ts +3 -0
  127. package/package.json +56 -0
@@ -0,0 +1,5 @@
1
+ export interface StorageService {
2
+ getItem<T>(key: string): Promise<T | null>;
3
+ setItem<T>(key: string, item: T): Promise<void>;
4
+ removeItem<T>(key: string): Promise<void>;
5
+ }
@@ -0,0 +1,2 @@
1
+ import { StorageService } from "@data-layer/services/StorageService";
2
+ export declare const initializeDataLayer: (dmUrl: string, lmsUrl: string, storageService: StorageService, httpErrorHandler?: Record<number, () => void>) => void;
@@ -0,0 +1,59 @@
1
+ import type { AdvancedTab } from "../../utils";
2
+ import type { Message } from "../../hooks/chat/use-chat-v2";
3
+ export type ChatState = Record<AdvancedTab, Message[]>;
4
+ export interface SessionIds extends Record<AdvancedTab, string> {
5
+ }
6
+ export type StreamingMessage = {
7
+ id: string;
8
+ content: string;
9
+ };
10
+ export declare const defaultSessionIds: SessionIds;
11
+ type ChatSliceState = {
12
+ chats: ChatState;
13
+ isTyping: boolean;
14
+ streaming: boolean;
15
+ currentStreamingMessage: StreamingMessage;
16
+ activeTab: AdvancedTab;
17
+ sessionId: string;
18
+ sessionIds: SessionIds;
19
+ iframeContext: {
20
+ hostInfo: {
21
+ title: string;
22
+ href: string;
23
+ };
24
+ pageContent: string;
25
+ };
26
+ };
27
+ export declare const chatActions: import("@reduxjs/toolkit").CaseReducerActions<import("@reduxjs/toolkit").SliceCaseReducers<ChatSliceState>, string>;
28
+ export declare const chatSliceReducerShared: import("@reduxjs/toolkit").Reducer<ChatSliceState>;
29
+ export declare const selectChats: (state: {
30
+ chatSliceShared: ChatSliceState;
31
+ }) => ChatState;
32
+ export declare const selectIsTyping: (state: {
33
+ chatSliceShared: ChatSliceState;
34
+ }) => boolean;
35
+ export declare const selectStreaming: (state: {
36
+ chatSliceShared: ChatSliceState;
37
+ }) => boolean;
38
+ export declare const selectCurrentStreamingMessage: (state: {
39
+ chatSliceShared: ChatSliceState;
40
+ }) => StreamingMessage;
41
+ export declare const selectActiveTab: (state: {
42
+ chatSliceShared: ChatSliceState;
43
+ }) => "chat" | "summarize" | "translate" | "expand";
44
+ export declare const selectSessionId: (state: {
45
+ chatSliceShared: ChatSliceState;
46
+ }) => string;
47
+ export declare const selectSessionIds: (state: {
48
+ chatSliceShared: ChatSliceState;
49
+ }) => SessionIds;
50
+ export declare const selectIframeContext: (state: {
51
+ chatSliceShared: ChatSliceState;
52
+ }) => {
53
+ hostInfo: {
54
+ title: string;
55
+ href: string;
56
+ };
57
+ pageContent: string;
58
+ };
59
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./chat/slice";
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import type { ChatMode } from "../../types";
3
+ import { type AdvancedTab } from "../../utils";
4
+ import { Message } from "./use-chat-v2";
5
+ type Props = {
6
+ mode: ChatMode;
7
+ tenantKey: string;
8
+ mentorId: string;
9
+ username: string;
10
+ token: string;
11
+ wsUrl: string;
12
+ redirectToAuthSpa: () => void;
13
+ stopGenerationWsUrl: string;
14
+ sendMessageToParentWebsite?: (payload: unknown) => void;
15
+ errorHandler?: (error: string) => void;
16
+ isPreviewMode?: boolean;
17
+ };
18
+ export declare function useAdvancedChat({ mode, tenantKey, mentorId, username, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, }: Props): {
19
+ messages: Message[];
20
+ isStreaming: boolean;
21
+ currentStreamingMessage: import("../../features/chat/slice").StreamingMessage;
22
+ activeTab: "chat" | "summarize" | "translate" | "expand";
23
+ uniqueMentorId: string;
24
+ mentorName: string;
25
+ profileImage: string;
26
+ enabledGuidedPrompts: boolean;
27
+ sendMessage: (tab: AdvancedTab, text: string, options?: import("./use-chat-v2").SendMessageOptions) => Promise<void>;
28
+ stopGenerating: () => void;
29
+ setMessages: (messages: Message[]) => void;
30
+ changeTab: (tab: AdvancedTab) => Promise<void>;
31
+ sessionId: string;
32
+ startNewChat: () => Promise<void>;
33
+ isLoadingSessionIds: boolean;
34
+ ws: React.MutableRefObject<WebSocket | null>;
35
+ isConnected: React.MutableRefObject<boolean>;
36
+ messageQueue: React.MutableRefObject<any[]>;
37
+ enableWebBrowsing: boolean;
38
+ sessionIds: import("../../features/chat/slice").SessionIds;
39
+ enableSafetyDisclaimer: any;
40
+ };
41
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { AdvancedTab } from "../../utils/data/advanced-tab";
2
+ export interface Message {
3
+ id: string;
4
+ role: "user" | "assistant" | "system";
5
+ content: string;
6
+ timestamp: string;
7
+ url?: string;
8
+ fileType?: string;
9
+ contentType?: string;
10
+ visible: boolean;
11
+ }
12
+ export type SendMessageOptions = {
13
+ visible?: boolean;
14
+ } | undefined;
15
+ export interface UseChatProps {
16
+ wsUrl: string;
17
+ wsToken: string;
18
+ flowConfig: {
19
+ name: string;
20
+ tenant: string;
21
+ username: string;
22
+ pathway: string;
23
+ };
24
+ sessionId: string;
25
+ stopGenerationWsUrl: string;
26
+ activeTab: AdvancedTab;
27
+ enableHaptics?: boolean;
28
+ hapticFeedback?: {
29
+ impactAsync: (style: any) => Promise<void>;
30
+ };
31
+ redirectToAuthSpa: () => void;
32
+ store?: {
33
+ sendMessage?: (text: string) => Promise<void>;
34
+ };
35
+ WebSocketImpl?: typeof WebSocket;
36
+ errorHandler?: (error: string) => void;
37
+ onStreamingChange: (streaming: boolean) => void;
38
+ onStreamingMessageUpdate: (message: {
39
+ id: string | null;
40
+ content: string;
41
+ }) => void;
42
+ onAddUserMessage?: (activeTab: AdvancedTab, message: Message) => void;
43
+ sendMessageToParentWebsite?: (payload: unknown) => void;
44
+ }
45
+ export interface UseChatReturn {
46
+ sendMessage: (tab: AdvancedTab, text: string, options?: SendMessageOptions) => Promise<void>;
47
+ ws: React.MutableRefObject<WebSocket | null>;
48
+ isConnected: React.MutableRefObject<boolean>;
49
+ messageQueue: React.MutableRefObject<any[]>;
50
+ stopGenerating: () => void;
51
+ resetConnection: () => void;
52
+ }
53
+ export declare const useChat: ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, activeTab, enableHaptics, hapticFeedback, store, errorHandler, onStreamingChange, onStreamingMessageUpdate, onAddUserMessage, WebSocketImpl, redirectToAuthSpa, sendMessageToParentWebsite, }: UseChatProps) => UseChatReturn;
@@ -0,0 +1,52 @@
1
+ import type { AdvancedTab } from "../../utils/data/advanced-tab";
2
+ export interface Message {
3
+ id: string;
4
+ role: "user" | "assistant" | "system";
5
+ content: string;
6
+ timestamp: string;
7
+ url?: string;
8
+ fileType?: string;
9
+ contentType?: string;
10
+ visible?: boolean;
11
+ }
12
+ export type SendMessageOptions = {
13
+ visible?: boolean;
14
+ };
15
+ export interface UseChatProps {
16
+ wsUrl: string;
17
+ wsToken: string;
18
+ flowConfig: {
19
+ name: string;
20
+ tenant: string;
21
+ username: string;
22
+ pathway: string;
23
+ };
24
+ sessionId: string;
25
+ stopGenerationWsUrl: string;
26
+ activeTab: AdvancedTab;
27
+ enableHaptics?: boolean;
28
+ hapticFeedback?: {
29
+ impactAsync: (style: any) => Promise<void>;
30
+ };
31
+ store?: {
32
+ sendMessage?: (text: string) => Promise<void>;
33
+ };
34
+ WebSocketImpl?: typeof WebSocket;
35
+ errorHandler?: (error: string) => void;
36
+ }
37
+ export interface UseChatReturn {
38
+ messages: Message[];
39
+ isTyping: boolean;
40
+ sendMessage: (text: string, options?: SendMessageOptions) => Promise<void>;
41
+ currentStreamingMessage: {
42
+ id: string | null;
43
+ content: string;
44
+ };
45
+ ws: React.MutableRefObject<WebSocket | null>;
46
+ isConnected: React.MutableRefObject<boolean>;
47
+ messageQueue: React.MutableRefObject<any[]>;
48
+ stopGenerating: () => void;
49
+ streaming: boolean;
50
+ setMessages: (messages: Message[]) => void;
51
+ }
52
+ export declare const useChat: ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, activeTab, enableHaptics, hapticFeedback, store, errorHandler, WebSocketImpl, }: UseChatProps) => UseChatReturn;
@@ -0,0 +1,13 @@
1
+ import type { ChatMode } from "../../types";
2
+ type Props = {
3
+ mode: ChatMode;
4
+ tenantKey: string;
5
+ mentorId: string;
6
+ username: string;
7
+ errorHandler?: (error: string) => void;
8
+ };
9
+ export declare function useGetChatDetails({ mode, tenantKey, mentorId, username, errorHandler, }: Props): {
10
+ isLoadingSessionIds: boolean;
11
+ refetchSessionIds: () => Promise<void>;
12
+ };
13
+ export {};
@@ -0,0 +1,10 @@
1
+ export * from "./subscription/use-subscription-handler";
2
+ export * from "./subscription/constants";
3
+ export * from "./subscription/class-subscription-flow";
4
+ export * from "./subscription-v2/use-subscription-handler";
5
+ export * from "./subscription-v2/class-subscription-flow";
6
+ export * from "./subscription-v2/use-external-pricing-plan";
7
+ export * from "./subscription-v2/constants";
8
+ export * from "./use-day-js";
9
+ export * from "./chat/use-chat";
10
+ export * from "./chat/use-advanced-chat";
@@ -0,0 +1,70 @@
1
+ import { FreeUsageCount } from "@iblai/iblai-api";
2
+ interface Tenant {
3
+ key: string;
4
+ is_admin: boolean;
5
+ org: string;
6
+ }
7
+ export interface SubscriptionFlowConfig {
8
+ platformName: string;
9
+ currentTenantKey: string;
10
+ username: string;
11
+ currentTenantOrg: string;
12
+ userTenants: Tenant[];
13
+ isAdmin: boolean;
14
+ mainTenantKey: string;
15
+ }
16
+ /**
17
+ * SubscriptionFlow class manages all subscription-related flows and user interactions
18
+ * Handles free trial, usage limits, and subscription management
19
+ */
20
+ export declare class SubscriptionFlow {
21
+ protected platformName: string;
22
+ protected currentTenantKey: string;
23
+ protected username: string;
24
+ protected currentTenantOrg: string;
25
+ protected userTenants: Tenant[];
26
+ protected isAdmin: boolean;
27
+ protected mainTenantKey: string;
28
+ constructor(config: SubscriptionFlowConfig);
29
+ getPlatformName(): string;
30
+ getCurrentTenantKey(): string;
31
+ getUsername(): string;
32
+ getCurrentTenantOrg(): string;
33
+ getUserTenants(): Tenant[];
34
+ isUserAdmin(): boolean;
35
+ /**
36
+ * Handles the flow when user reaches their free usage limit
37
+ * Updates banner with appropriate message based on remaining usage count
38
+ */
39
+ handleFreeUsageCountFlow(freeUsageCount: FreeUsageCount): void;
40
+ /**
41
+ * Handles the flow when user's free trial period has ended
42
+ * Updates banner and clears any existing trial interval
43
+ */
44
+ handleTrialEndedFlow(freeTrialIntervalID?: number): void;
45
+ /**
46
+ * Handles the flow for ongoing subscription period
47
+ * Updates banner with remaining trial time and subscription options
48
+ */
49
+ handleSubscriptionOnGoingFlow(timeRemainingInString: string): void;
50
+ /**
51
+ * Handles redirection to external URLs with optional toast notification
52
+ */
53
+ handleRedirectToURLFlow(redirectUrl: string, toastMessage?: string): void;
54
+ /**
55
+ * Displays the pricing modal for subscription options
56
+ */
57
+ handlePricingPageDisplayFlow(): void;
58
+ /**
59
+ * Handles the pre-subscription state
60
+ * Updates banner to show loading state
61
+ */
62
+ handleBeforeSubscribeUserTriggerFlow(): void;
63
+ /**
64
+ * Handles successful subscription completion
65
+ * Shows success message and disables subscription banner
66
+ */
67
+ handleSuccessfullySubscribedFlow(message?: string): void;
68
+ getMainTenantKey(): string;
69
+ }
70
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const SUBSCRIPTION_TRIGGERS: {
2
+ PRICING_MODAL: string;
3
+ SUBSCRIBE_USER: string;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { SubscriptionFlow } from "./class-subscription-flow";
2
+ /**
3
+ * Hook to handle subscription logic
4
+ * @param subscriptionFlow Instance of SubscriptionFlow that manages different subscription states and actions
5
+ */
6
+ export declare const useSubscriptionHandler: (subscriptionFlow: SubscriptionFlow) => {
7
+ handleSubscriptionCheck: () => Promise<void>;
8
+ handleIntervalSubscriptionCheck: () => (() => void) | undefined;
9
+ trialCounterStarted: boolean;
10
+ bannerButtonTriggerCallback: (trigger: string) => () => void;
11
+ };
@@ -0,0 +1,62 @@
1
+ import { StripeContextResponse } from "@iblai/data-layer";
2
+ interface Tenant {
3
+ key: string;
4
+ is_admin: boolean;
5
+ org: string;
6
+ }
7
+ export interface SubscriptionFlowConfigV2 {
8
+ platformName: string;
9
+ currentTenantKey: string;
10
+ username: string;
11
+ currentTenantOrg: string;
12
+ userTenants: Tenant[];
13
+ isAdmin: boolean;
14
+ mainTenantKey: string;
15
+ userEmail: string;
16
+ mentorUrl: string;
17
+ }
18
+ /**
19
+ * SubscriptionFlow class manages all subscription-related flows and user interactions
20
+ * Handles free trial, usage limits, and subscription management
21
+ */
22
+ export declare class SubscriptionFlowV2 {
23
+ protected platformName: string;
24
+ protected currentTenantKey: string;
25
+ protected username: string;
26
+ protected currentTenantOrg: string;
27
+ protected userTenants: Tenant[];
28
+ protected isAdmin: boolean;
29
+ protected mainTenantKey: string;
30
+ protected userEmail: string;
31
+ protected mentorUrl: string;
32
+ constructor(config: SubscriptionFlowConfigV2);
33
+ getPlatformName(): string;
34
+ getCurrentTenantKey(): string;
35
+ getUsername(): string;
36
+ getCurrentTenantOrg(): string;
37
+ getUserTenants(): Tenant[];
38
+ isUserAdmin(): boolean;
39
+ getUserEmail(): string;
40
+ getMainTenantKey(): string;
41
+ getMentorUrl(): string;
42
+ handleRedirectToBillingPageFlow(billingUrl: string): void;
43
+ handleBeforeTopUpCreditTriggerFlow(): void;
44
+ /**
45
+ * Handles the flow when user reaches their free usage limit
46
+ * Updates banner with appropriate message based on remaining usage count
47
+ */
48
+ handleFreeUsageCountFlow(hasCredits: boolean, appExists: boolean): void;
49
+ /**
50
+ * Displays the pricing modal for subscription options
51
+ */
52
+ handlePricingPageDisplayFlow(stripeContext: StripeContextResponse): void;
53
+ /**
54
+ * Displays error notification when payment flow fails
55
+ */
56
+ handleFailureOnPaymentFlow(): void;
57
+ handleBeforePricingPageDisplayFlow(): void;
58
+ handleFailureOnTopUpCreditTriggerFlow(): void;
59
+ handleCreditExhaustedFlow(isTenantOwnerAdmin: boolean): void;
60
+ handleOpenContactAdminFlow(adminEmail: string): void;
61
+ }
62
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const SUBSCRIPTION_V2_TRIGGERS: {
2
+ PRICING_MODAL: string;
3
+ TOP_UP_CREDIT: string;
4
+ CONTACT_ADMIN: string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import { PricingModalData } from "@web-utils/types/subscription";
2
+ export declare const useExternalPricingPlan: ({ pricingModalData, userEmail }: {
3
+ pricingModalData: PricingModalData;
4
+ userEmail: string;
5
+ }) => {
6
+ pricingBoxIframeRef: import("react").RefObject<null>;
7
+ };
@@ -0,0 +1,12 @@
1
+ import { SubscriptionFlowV2 } from "./class-subscription-flow";
2
+ /**
3
+ * Hook to handle subscription logic
4
+ * @param subscriptionFlow Instance of SubscriptionFlow that manages different subscription states and actions
5
+ */
6
+ export declare const useSubscriptionHandlerV2: (subscriptionFlow: SubscriptionFlowV2) => {
7
+ handleSubscriptionCheck: () => Promise<void>;
8
+ bannerButtonTriggerCallback: (trigger: string) => () => void;
9
+ CREDIT_INTERVAL_CHECK_COUNTER: number;
10
+ getBillingURL: (returnURL?: string) => Promise<string | null | undefined>;
11
+ getTopUpURL: () => Promise<string | null>;
12
+ };
@@ -0,0 +1,7 @@
1
+ import type { OpUnitType } from "dayjs";
2
+ import duration from "dayjs/plugin/duration";
3
+ export declare const useDayJs: () => {
4
+ getTimeDifferenceBetweenTwoDates: (futureDate: string, pastDate: string, format?: OpUnitType) => number;
5
+ getDayJSDurationObjFromSeconds: (seconds: number) => duration.Duration;
6
+ generateFutureDateForNMinutes: (minute?: number) => string;
7
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./hooks";
2
+ export * from "./providers";
3
+ export * from "./utils";
4
+ export * from "./types";
5
+ export * from "./features";