@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.
- package/dist/data-layer/src/config.d.ts +7 -0
- package/dist/data-layer/src/constants.d.ts +30 -0
- package/dist/data-layer/src/core/index.d.ts +4 -0
- package/dist/data-layer/src/features/analytics/api-slice.d.ts +1600 -0
- package/dist/data-layer/src/features/analytics/constants.d.ts +66 -0
- package/dist/data-layer/src/features/analytics/types.d.ts +100 -0
- package/dist/data-layer/src/features/api-keys/api-slice.d.ts +665 -0
- package/dist/data-layer/src/features/apps/api-slice.d.ts +683 -0
- package/dist/data-layer/src/features/auth/api-slice.d.ts +137 -0
- package/dist/data-layer/src/features/auth/constants.d.ts +8 -0
- package/dist/data-layer/src/features/auth/types.d.ts +13 -0
- package/dist/data-layer/src/features/billing/api-slice.d.ts +349 -0
- package/dist/data-layer/src/features/career/api-slice.d.ts +687 -0
- package/dist/data-layer/src/features/catalog/api-slice.d.ts +6602 -0
- package/dist/data-layer/src/features/chat/api-slice.d.ts +1832 -0
- package/dist/data-layer/src/features/chat-history/api-slice.d.ts +1386 -0
- package/dist/data-layer/src/features/constants.d.ts +3 -0
- package/dist/data-layer/src/features/core/api-slice.d.ts +653 -0
- package/dist/data-layer/src/features/core/constants.d.ts +4 -0
- package/dist/data-layer/src/features/credentials/api-slice.d.ts +2129 -0
- package/dist/data-layer/src/features/credentials/constants.d.ts +28 -0
- package/dist/data-layer/src/features/credentials/custom-api-slice.d.ts +1284 -0
- package/dist/data-layer/src/features/credentials/types.d.ts +16 -0
- package/dist/data-layer/src/features/datasets/api-slice.d.ts +576 -0
- package/dist/data-layer/src/features/llms/api-slice.d.ts +333 -0
- package/dist/data-layer/src/features/mentor/api-slice.d.ts +4298 -0
- package/dist/data-layer/src/features/mentor/constants.d.ts +31 -0
- package/dist/data-layer/src/features/mentor/custom-api-slice.d.ts +268 -0
- package/dist/data-layer/src/features/mentor/types.d.ts +38 -0
- package/dist/data-layer/src/features/mentor-categories/api-slice.d.ts +311 -0
- package/dist/data-layer/src/features/notifications/api-slice.d.ts +946 -0
- package/dist/data-layer/src/features/per-learner/api-slice.d.ts +1213 -0
- package/dist/data-layer/src/features/platform/api-slice.d.ts +1124 -0
- package/dist/data-layer/src/features/prompts/api-slice.d.ts +2276 -0
- package/dist/data-layer/src/features/search/api-slice.d.ts +1939 -0
- package/dist/data-layer/src/features/sessions/api-slice.d.ts +705 -0
- package/dist/data-layer/src/features/skills/api-slice.d.ts +1235 -0
- package/dist/data-layer/src/features/stripe/api-slice.d.ts +620 -0
- package/dist/data-layer/src/features/stripe/constants.d.ts +15 -0
- package/dist/data-layer/src/features/stripe/types.d.ts +9 -0
- package/dist/data-layer/src/features/tenant/api-slice.d.ts +759 -0
- package/dist/data-layer/src/features/tenant/constants.d.ts +11 -0
- package/dist/data-layer/src/features/tenant/types.d.ts +18 -0
- package/dist/data-layer/src/features/tenant-logo/api-slice.d.ts +349 -0
- package/dist/data-layer/src/features/tenant-logo/constants.d.ts +24 -0
- package/dist/data-layer/src/features/tools/api-slice.d.ts +333 -0
- package/dist/data-layer/src/features/training-documents/api-slice.d.ts +922 -0
- package/dist/data-layer/src/features/user/api-slice.d.ts +1703 -0
- package/dist/data-layer/src/features/user/constants.d.ts +40 -0
- package/dist/data-layer/src/features/user/types.d.ts +107 -0
- package/dist/data-layer/src/features/user-invitations/api-slice.d.ts +718 -0
- package/dist/data-layer/src/features/utils.d.ts +66 -0
- package/dist/data-layer/src/index.d.ts +47 -0
- package/dist/data-layer/src/reducers/index.d.ts +2 -0
- package/dist/data-layer/src/reducers/mentor.d.ts +2 -0
- package/dist/data-layer/src/reducers/skills.d.ts +1148 -0
- package/dist/data-layer/src/services/StorageService.d.ts +5 -0
- package/dist/data-layer/src/utils/index.d.ts +2 -0
- package/dist/features/chat/slice.d.ts +59 -0
- package/dist/features/index.d.ts +1 -0
- package/dist/hooks/chat/use-advanced-chat.d.ts +41 -0
- package/dist/hooks/chat/use-chat-v2.d.ts +53 -0
- package/dist/hooks/chat/use-chat.d.ts +52 -0
- package/dist/hooks/chat/use-get-chat-details.d.ts +13 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/subscription/class-subscription-flow.d.ts +70 -0
- package/dist/hooks/subscription/constants.d.ts +4 -0
- package/dist/hooks/subscription/use-subscription-handler.d.ts +11 -0
- package/dist/hooks/subscription-v2/class-subscription-flow.d.ts +62 -0
- package/dist/hooks/subscription-v2/constants.d.ts +5 -0
- package/dist/hooks/subscription-v2/use-external-pricing-plan.d.ts +7 -0
- package/dist/hooks/subscription-v2/use-subscription-handler.d.ts +12 -0
- package/dist/hooks/use-day-js.d.ts +7 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.esm.js +15076 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +15160 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +53 -0
- package/dist/providers/auth-provider.d.ts +63 -0
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/mentor-provider.d.ts +40 -0
- package/dist/providers/tenant-provider.d.ts +60 -0
- package/dist/types/chat.d.ts +1 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/subscription.d.ts +18 -0
- package/dist/utils/constants.d.ts +13 -0
- package/dist/utils/data/advanced-tab.d.ts +62 -0
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/web-utils/src/features/chat/slice.d.ts +91 -0
- package/dist/web-utils/src/features/index.d.ts +1 -0
- package/dist/web-utils/src/hooks/chat/use-advanced-chat.d.ts +48 -0
- package/dist/web-utils/src/hooks/chat/use-chat-v2.d.ts +56 -0
- package/dist/web-utils/src/hooks/chat/use-chat.d.ts +52 -0
- package/dist/web-utils/src/hooks/chat/use-get-chat-details.d.ts +13 -0
- package/dist/web-utils/src/hooks/chat/use-mentor-tools.d.ts +18 -0
- package/dist/web-utils/src/hooks/index.d.ts +15 -0
- package/dist/web-utils/src/hooks/profile/use-profile-image-upload.d.ts +13 -0
- package/dist/web-utils/src/hooks/profile/use-user-profile-update.d.ts +28 -0
- package/dist/web-utils/src/hooks/subscription/class-subscription-flow.d.ts +70 -0
- package/dist/web-utils/src/hooks/subscription/constants.d.ts +4 -0
- package/dist/web-utils/src/hooks/subscription/use-subscription-handler.d.ts +11 -0
- package/dist/web-utils/src/hooks/subscription-v2/class-subscription-flow.d.ts +77 -0
- package/dist/web-utils/src/hooks/subscription-v2/constants.d.ts +51 -0
- package/dist/web-utils/src/hooks/subscription-v2/use-external-pricing-plan.d.ts +7 -0
- package/dist/web-utils/src/hooks/subscription-v2/use-subscription-handler.d.ts +16 -0
- package/dist/web-utils/src/hooks/tenant-metadata/config-loader.d.ts +41 -0
- package/dist/web-utils/src/hooks/tenant-metadata/constants.d.ts +9 -0
- package/dist/web-utils/src/hooks/tenant-metadata/index.d.ts +5 -0
- package/dist/web-utils/src/hooks/tenant-metadata/types.d.ts +9 -0
- package/dist/web-utils/src/hooks/tenant-metadata/use-tenant-metadata.d.ts +24 -0
- package/dist/web-utils/src/hooks/use-day-js.d.ts +7 -0
- package/dist/web-utils/src/hooks/use-mentor-settings.d.ts +21 -0
- package/dist/web-utils/src/index.d.ts +5 -0
- package/dist/web-utils/src/providers/auth-provider.d.ts +64 -0
- package/dist/web-utils/src/providers/index.d.ts +3 -0
- package/dist/web-utils/src/providers/mentor-provider.d.ts +40 -0
- package/dist/web-utils/src/providers/tenant-provider.d.ts +63 -0
- package/dist/web-utils/src/types/chat.d.ts +1 -0
- package/dist/web-utils/src/types/index.d.ts +55 -0
- package/dist/web-utils/src/types/subscription.d.ts +18 -0
- package/dist/web-utils/src/utils/constants.d.ts +37 -0
- package/dist/web-utils/src/utils/data/advanced-tab.d.ts +62 -0
- package/dist/web-utils/src/utils/helpers.d.ts +6 -0
- package/dist/web-utils/src/utils/index.d.ts +3 -0
- package/package.json +56 -0
|
@@ -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,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,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
|
+
};
|