@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,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iblai/web-utils",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"module": "./dist/index.esm.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"watch": "rollup -c -w",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"test:watch": "jest --watch",
|
|
15
|
+
"test:coverage": "jest --coverage"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"description": "IBL Web Utils",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
23
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
24
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
25
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
26
|
+
"@testing-library/react": "16.3.0",
|
|
27
|
+
"@types/jest": "29.5.14",
|
|
28
|
+
"@types/node": "^22.15.20",
|
|
29
|
+
"@types/react": "^19.0.10",
|
|
30
|
+
"autoprefixer": "^10.4.21",
|
|
31
|
+
"jest": "29.7.0",
|
|
32
|
+
"jest-environment-jsdom": "29.7.0",
|
|
33
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
34
|
+
"rollup-plugin-strip-code": "^0.2.8",
|
|
35
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
36
|
+
"ts-jest": "29.3.2",
|
|
37
|
+
"typescript": "^5.8.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@iblai/data-layer": "workspace:*",
|
|
41
|
+
"@reduxjs/toolkit": "^2.8.2",
|
|
42
|
+
"dayjs": "^1.11.13",
|
|
43
|
+
"rollup": "^4.41.0",
|
|
44
|
+
"zod": "3.24.2",
|
|
45
|
+
"react-redux": "^9.2.0",
|
|
46
|
+
"rollup-plugin-copy": "^3.5.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@iblai/iblai-api": "4.11.1-ai",
|
|
50
|
+
"react": "19.0.0"
|
|
51
|
+
},
|
|
52
|
+
"packageManager": "pnpm@10.11.0"
|
|
53
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthProvider Component
|
|
3
|
+
*
|
|
4
|
+
* Provider that handles authentication state and route protection.
|
|
5
|
+
* It manages authentication checks, public route access, and redirects to auth SPA when needed.
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { StorageService } from "@iblai/data-layer";
|
|
9
|
+
export declare function getUserName(storageService: StorageService): Promise<any>;
|
|
10
|
+
export declare function useAuthProvider({ middleware, onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname, storageService, skipAuthCheck, }: Props): {
|
|
11
|
+
isAuthenticating: boolean;
|
|
12
|
+
userIsAccessingPublicRoute: boolean;
|
|
13
|
+
setUserIsAccessingPublicRoute: React.Dispatch<React.SetStateAction<boolean>>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Type definition for the authentication context
|
|
17
|
+
* Tracks whether the user is accessing a public route and provides a setter
|
|
18
|
+
*/
|
|
19
|
+
export type AuthContextType = {
|
|
20
|
+
userIsAccessingPublicRoute: boolean;
|
|
21
|
+
setUserIsAccessingPublicRoute: (iuserIsAccessingPublicRoute: boolean) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const AuthContext: React.Context<AuthContextType | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Hook to access the auth context
|
|
26
|
+
* @throws Error if used outside of AuthContextProvider
|
|
27
|
+
*/
|
|
28
|
+
export declare const useAuthContext: () => AuthContextType;
|
|
29
|
+
/**
|
|
30
|
+
* Context Provider component that wraps children with auth context
|
|
31
|
+
*/
|
|
32
|
+
export declare const AuthContextProvider: ({ value, children, }: {
|
|
33
|
+
value: AuthContextType;
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
/**
|
|
37
|
+
* Props for the AuthProvider component
|
|
38
|
+
*/
|
|
39
|
+
type Props = {
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
fallback?: React.ReactNode;
|
|
42
|
+
middleware?: Map<string | RegExp, () => Promise<boolean>>;
|
|
43
|
+
onAuthSuccess?: () => void;
|
|
44
|
+
onAuthFailure?: (reason: string) => void;
|
|
45
|
+
redirectToAuthSpa: () => void;
|
|
46
|
+
hasNonExpiredAuthToken: () => boolean;
|
|
47
|
+
username: string;
|
|
48
|
+
pathname: string;
|
|
49
|
+
skipAuthCheck?: boolean;
|
|
50
|
+
storageService?: StorageService;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* AuthProvider Component
|
|
54
|
+
*
|
|
55
|
+
* Main authentication provider that:
|
|
56
|
+
* 1. Checks if the current route requires authentication
|
|
57
|
+
* 2. Validates the auth token
|
|
58
|
+
* 3. Fetches user metadata to verify authentication
|
|
59
|
+
* 4. Handles redirects to auth SPA when needed
|
|
60
|
+
* 5. Manages public route access state
|
|
61
|
+
*/
|
|
62
|
+
export declare function AuthProvider({ children, fallback, middleware, onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname, skipAuthCheck, storageService, }: Props): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MentorProvider Component
|
|
3
|
+
*
|
|
4
|
+
* Provider that manages AI mentor selection and redirection logic.
|
|
5
|
+
* It handles:
|
|
6
|
+
* - Mentor selection based on user preferences and history
|
|
7
|
+
* - Mentor seeding for new tenants
|
|
8
|
+
* - Redirection to appropriate mentor or creation flow
|
|
9
|
+
* - Integration with tenant context for access control
|
|
10
|
+
*/
|
|
11
|
+
import React from "react";
|
|
12
|
+
/**
|
|
13
|
+
* Props for the MentorProvider component
|
|
14
|
+
*/
|
|
15
|
+
type Props = {
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
fallback?: React.ReactNode;
|
|
18
|
+
onAuthSuccess?: () => void;
|
|
19
|
+
onAuthFailure?: (reason: string) => void;
|
|
20
|
+
redirectToAuthSpa: () => void;
|
|
21
|
+
redirectToMentor: (tenantKey: string, mentorId: string) => void;
|
|
22
|
+
redirectToNoMentorsPage: () => void;
|
|
23
|
+
redirectToCreateMentor: () => void;
|
|
24
|
+
username: string;
|
|
25
|
+
tenantKey: string;
|
|
26
|
+
isAdmin: boolean;
|
|
27
|
+
isMainTenant: boolean;
|
|
28
|
+
requestedMentorId?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* MentorProvider Component
|
|
32
|
+
*
|
|
33
|
+
* Main mentor provider that:
|
|
34
|
+
* 1. Determines the most appropriate mentor for the user
|
|
35
|
+
* 2. Handles mentor seeding for new tenants
|
|
36
|
+
* 3. Manages redirection based on mentor availability
|
|
37
|
+
* 4. Integrates with tenant context for access control
|
|
38
|
+
*/
|
|
39
|
+
export declare function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redirectToAuthSpa, redirectToMentor, redirectToNoMentorsPage, redirectToCreateMentor, username, tenantKey, isAdmin, isMainTenant, requestedMentorId, }: Props): React.ReactNode;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TenantProvider
|
|
3
|
+
*
|
|
4
|
+
* Provider that manages tenant-related state and access control.
|
|
5
|
+
* It handles:
|
|
6
|
+
* - Tenant validation and access control
|
|
7
|
+
* - Tenant switching logic
|
|
8
|
+
* - Tenant metadata retrieval
|
|
9
|
+
* - User-tenant relationship verification
|
|
10
|
+
*/
|
|
11
|
+
import React from "react";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { tenantSchema } from "@web-utils/types";
|
|
14
|
+
/**
|
|
15
|
+
* Type definition for the tenant context
|
|
16
|
+
* Tracks whether the user's path needs to be determined and provides a setter
|
|
17
|
+
*/
|
|
18
|
+
export type TenantContextType = {
|
|
19
|
+
determineUserPath: boolean;
|
|
20
|
+
setDetermineUserPath: (value: boolean) => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const TenantContext: React.Context<TenantContextType | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Context Provider component that wraps children with tenant context
|
|
25
|
+
*/
|
|
26
|
+
export declare const TenantContextProvider: React.FC<{
|
|
27
|
+
value: TenantContextType;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Hook to access the tenant context
|
|
32
|
+
* @returns TenantContextType
|
|
33
|
+
*/
|
|
34
|
+
export declare const useTenantContext: () => TenantContextType;
|
|
35
|
+
/**
|
|
36
|
+
* Props for the TenantProvider component
|
|
37
|
+
*/
|
|
38
|
+
type Props = {
|
|
39
|
+
children?: React.ReactNode;
|
|
40
|
+
fallback?: React.ReactNode;
|
|
41
|
+
onAuthSuccess?: () => void;
|
|
42
|
+
onAuthFailure?: (reason: string) => void;
|
|
43
|
+
currentTenant: string;
|
|
44
|
+
requestedTenant: string;
|
|
45
|
+
handleTenantSwitch: (tenant: string, saveRedirect: boolean) => void;
|
|
46
|
+
saveCurrentTenant: (tenant: z.infer<typeof tenantSchema>) => void;
|
|
47
|
+
saveUserTenants: (tenants: z.infer<typeof tenantSchema>[]) => void;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* TenantProvider Component
|
|
51
|
+
*
|
|
52
|
+
* Main tenant provider that:
|
|
53
|
+
* 1. Validates user's access to requested tenant
|
|
54
|
+
* 2. Manages tenant switching
|
|
55
|
+
* 3. Retrieves and validates tenant metadata
|
|
56
|
+
* 4. Handles tenant-specific domain redirects
|
|
57
|
+
* 5. Maintains tenant access state
|
|
58
|
+
*/
|
|
59
|
+
export declare function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, }: Props): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ChatMode = "advanced" | "default";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const userDataSchema: z.ZodObject<{
|
|
3
|
+
user_display_name: z.ZodString;
|
|
4
|
+
user_email: z.ZodString;
|
|
5
|
+
user_fullname: z.ZodString;
|
|
6
|
+
user_id: z.ZodNumber;
|
|
7
|
+
user_nicename: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
user_display_name: string;
|
|
10
|
+
user_email: string;
|
|
11
|
+
user_fullname: string;
|
|
12
|
+
user_id: number;
|
|
13
|
+
user_nicename: string;
|
|
14
|
+
}, {
|
|
15
|
+
user_display_name: string;
|
|
16
|
+
user_email: string;
|
|
17
|
+
user_fullname: string;
|
|
18
|
+
user_id: number;
|
|
19
|
+
user_nicename: string;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const tenantSchema: z.ZodObject<{
|
|
22
|
+
key: z.ZodString;
|
|
23
|
+
is_admin: z.ZodBoolean;
|
|
24
|
+
org: z.ZodString;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
key: string;
|
|
27
|
+
is_admin: boolean;
|
|
28
|
+
org: string;
|
|
29
|
+
}, {
|
|
30
|
+
key: string;
|
|
31
|
+
is_admin: boolean;
|
|
32
|
+
org: string;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const tenantKeySchema: z.ZodString;
|
|
35
|
+
export type TenantKeyMentorIdParams = {
|
|
36
|
+
tenantKey: string;
|
|
37
|
+
mentorId: string;
|
|
38
|
+
};
|
|
39
|
+
export interface TopTrialBannerProps {
|
|
40
|
+
parentContainer: string;
|
|
41
|
+
bannerText?: string;
|
|
42
|
+
onUpgrade?: string;
|
|
43
|
+
loading?: boolean;
|
|
44
|
+
tooltipText?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface Prompt {
|
|
47
|
+
type: "static" | "human" | "ai";
|
|
48
|
+
icon?: string;
|
|
49
|
+
summary?: string;
|
|
50
|
+
content?: string;
|
|
51
|
+
proactive?: boolean;
|
|
52
|
+
hide?: boolean;
|
|
53
|
+
tag?: string;
|
|
54
|
+
}
|
|
55
|
+
export * from "./chat";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StripeCustomerPortalRequest } from "@iblai/iblai-api";
|
|
2
|
+
export interface UseExternalPricingProps {
|
|
3
|
+
referenceId: string;
|
|
4
|
+
customerEmail: string;
|
|
5
|
+
publishableKey: string;
|
|
6
|
+
pricingId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PricingModalData {
|
|
9
|
+
referenceId: string;
|
|
10
|
+
customerEmail: string;
|
|
11
|
+
publishableKey: string;
|
|
12
|
+
pricingTableId: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CreateStripeCustomerPortalRequest {
|
|
15
|
+
org: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
requestBody: StripeCustomerPortalRequest;
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const MENTOR_CHAT_DOCUMENTS_EXTENSIONS: string[];
|
|
2
|
+
export declare const ANONYMOUS_USERNAME = "anonymous";
|
|
3
|
+
export declare const LOCAL_STORAGE_KEYS: {
|
|
4
|
+
CURRENT_TENANT: string;
|
|
5
|
+
TENANTS: string;
|
|
6
|
+
REDIRECT_TO: string;
|
|
7
|
+
AUTH_TOKEN: string;
|
|
8
|
+
TOKEN_EXPIRY: string;
|
|
9
|
+
USER_DATA: string;
|
|
10
|
+
USER_TENANTS: string;
|
|
11
|
+
EDX_TOKEN_KEY: string;
|
|
12
|
+
DM_TOKEN_KEY: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const advancedTabsProperties: {
|
|
2
|
+
chat: {
|
|
3
|
+
display: string;
|
|
4
|
+
name: string;
|
|
5
|
+
tag: string;
|
|
6
|
+
showHeader: boolean;
|
|
7
|
+
prompts: {
|
|
8
|
+
type: string;
|
|
9
|
+
icon: string;
|
|
10
|
+
summary: string;
|
|
11
|
+
content: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
summarize: {
|
|
15
|
+
display: string;
|
|
16
|
+
showHeader: boolean;
|
|
17
|
+
name: string;
|
|
18
|
+
tag: string;
|
|
19
|
+
prompts: {
|
|
20
|
+
type: string;
|
|
21
|
+
proactive: boolean;
|
|
22
|
+
hide: boolean;
|
|
23
|
+
content: string;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
translate: {
|
|
27
|
+
display: string;
|
|
28
|
+
showHeader: boolean;
|
|
29
|
+
name: string;
|
|
30
|
+
tag: string;
|
|
31
|
+
description: string;
|
|
32
|
+
metaDescription: string;
|
|
33
|
+
prompts: ({
|
|
34
|
+
type: string;
|
|
35
|
+
hide: boolean;
|
|
36
|
+
tag: string;
|
|
37
|
+
summary: string;
|
|
38
|
+
content: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: string;
|
|
41
|
+
summary: string;
|
|
42
|
+
content: string;
|
|
43
|
+
hide?: undefined;
|
|
44
|
+
tag?: undefined;
|
|
45
|
+
})[];
|
|
46
|
+
};
|
|
47
|
+
expand: {
|
|
48
|
+
display: string;
|
|
49
|
+
showHeader: boolean;
|
|
50
|
+
name: string;
|
|
51
|
+
tag: string;
|
|
52
|
+
prompts: {
|
|
53
|
+
type: string;
|
|
54
|
+
proactive: boolean;
|
|
55
|
+
hide: boolean;
|
|
56
|
+
content: string;
|
|
57
|
+
}[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare const advancedTabs: ("chat" | "summarize" | "translate" | "expand")[];
|
|
61
|
+
export type AdvancedTab = keyof typeof advancedTabsProperties;
|
|
62
|
+
export declare const translatePrompt: (language: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isJSON: (text: string) => boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
export type ChatStatus = "idle" | "pending" | "streaming" | "stopped" | "error";
|
|
12
|
+
type ChatSliceState = {
|
|
13
|
+
chats: ChatState;
|
|
14
|
+
isTyping: boolean;
|
|
15
|
+
streaming: boolean;
|
|
16
|
+
currentStreamingMessage: StreamingMessage;
|
|
17
|
+
activeTab: AdvancedTab;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
sessionIds: SessionIds;
|
|
20
|
+
status: ChatStatus;
|
|
21
|
+
tools: string[];
|
|
22
|
+
token: string | null;
|
|
23
|
+
iframeContext: {
|
|
24
|
+
hostInfo: {
|
|
25
|
+
title: string;
|
|
26
|
+
href: string;
|
|
27
|
+
};
|
|
28
|
+
pageContent: string;
|
|
29
|
+
};
|
|
30
|
+
documentFilter: Record<string, unknown> | null;
|
|
31
|
+
};
|
|
32
|
+
export declare const chatActions: import("@reduxjs/toolkit").CaseReducerActions<import("@reduxjs/toolkit").SliceCaseReducers<ChatSliceState>, string>;
|
|
33
|
+
export declare const chatSliceReducerShared: import("@reduxjs/toolkit").Reducer<ChatSliceState>;
|
|
34
|
+
export declare const selectChats: (state: {
|
|
35
|
+
chatSliceShared: ChatSliceState;
|
|
36
|
+
}) => ChatState;
|
|
37
|
+
export declare const selectIsTyping: (state: {
|
|
38
|
+
chatSliceShared: ChatSliceState;
|
|
39
|
+
}) => boolean;
|
|
40
|
+
export declare const selectStreaming: (state: {
|
|
41
|
+
chatSliceShared: ChatSliceState;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
export declare const selectStatus: (state: {
|
|
44
|
+
chatSliceShared: ChatSliceState;
|
|
45
|
+
}) => ChatStatus;
|
|
46
|
+
export declare const selectIsPending: (state: {
|
|
47
|
+
chatSliceShared: ChatSliceState;
|
|
48
|
+
}) => boolean;
|
|
49
|
+
export declare const selectIsStopped: (state: {
|
|
50
|
+
chatSliceShared: ChatSliceState;
|
|
51
|
+
}) => boolean;
|
|
52
|
+
export declare const selectIsError: (state: {
|
|
53
|
+
chatSliceShared: ChatSliceState;
|
|
54
|
+
}) => boolean;
|
|
55
|
+
export declare const selectCurrentStreamingMessage: (state: {
|
|
56
|
+
chatSliceShared: ChatSliceState;
|
|
57
|
+
}) => StreamingMessage;
|
|
58
|
+
export declare const selectActiveTab: (state: {
|
|
59
|
+
chatSliceShared: ChatSliceState;
|
|
60
|
+
}) => "chat" | "summarize" | "translate" | "expand";
|
|
61
|
+
export declare const selectSessionId: (state: {
|
|
62
|
+
chatSliceShared: ChatSliceState;
|
|
63
|
+
}) => string;
|
|
64
|
+
export declare const selectSessionIds: (state: {
|
|
65
|
+
chatSliceShared: ChatSliceState;
|
|
66
|
+
}) => SessionIds;
|
|
67
|
+
export declare const selectIframeContext: (state: {
|
|
68
|
+
chatSliceShared: ChatSliceState;
|
|
69
|
+
}) => {
|
|
70
|
+
hostInfo: {
|
|
71
|
+
title: string;
|
|
72
|
+
href: string;
|
|
73
|
+
};
|
|
74
|
+
pageContent: string;
|
|
75
|
+
};
|
|
76
|
+
export declare const selectDocumentFilter: (state: {
|
|
77
|
+
chatSliceShared: ChatSliceState;
|
|
78
|
+
}) => Record<string, unknown> | null;
|
|
79
|
+
export declare const selectTools: (state: {
|
|
80
|
+
chatSliceShared: ChatSliceState;
|
|
81
|
+
}) => string[];
|
|
82
|
+
export declare const selectToken: (state: {
|
|
83
|
+
chatSliceShared: ChatSliceState;
|
|
84
|
+
}) => string | null;
|
|
85
|
+
export declare const selectActiveChatMessages: (state: {
|
|
86
|
+
chatSliceShared: ChatSliceState;
|
|
87
|
+
}) => Message[];
|
|
88
|
+
export declare const selectNumberOfActiveChatMessages: (state: {
|
|
89
|
+
chatSliceShared: ChatSliceState;
|
|
90
|
+
}) => number;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./chat/slice";
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
import { ChatStatus } from "../../features/chat/slice";
|
|
6
|
+
type Props = {
|
|
7
|
+
mode: ChatMode;
|
|
8
|
+
tenantKey: string;
|
|
9
|
+
mentorId: string;
|
|
10
|
+
username: string;
|
|
11
|
+
token: string;
|
|
12
|
+
wsUrl: string;
|
|
13
|
+
redirectToAuthSpa: () => void;
|
|
14
|
+
stopGenerationWsUrl: string;
|
|
15
|
+
sendMessageToParentWebsite?: (payload: unknown) => void;
|
|
16
|
+
errorHandler?: (message: string, error?: any) => void;
|
|
17
|
+
isPreviewMode?: boolean;
|
|
18
|
+
mentorShareableToken?: string | null;
|
|
19
|
+
on402Error?: (message: Record<string, unknown>) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function useAdvancedChat({ mode, tenantKey, mentorId, username, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, }: Props): {
|
|
22
|
+
messages: Message[];
|
|
23
|
+
isStreaming: boolean;
|
|
24
|
+
status: ChatStatus;
|
|
25
|
+
isPending: boolean;
|
|
26
|
+
isStopped: boolean;
|
|
27
|
+
isError: boolean;
|
|
28
|
+
currentStreamingMessage: import("../../features/chat/slice").StreamingMessage;
|
|
29
|
+
activeTab: "chat" | "summarize" | "translate" | "expand";
|
|
30
|
+
uniqueMentorId: string;
|
|
31
|
+
mentorName: string;
|
|
32
|
+
profileImage: string;
|
|
33
|
+
enabledGuidedPrompts: boolean;
|
|
34
|
+
sendMessage: (tab: AdvancedTab, text: string, options?: import("./use-chat-v2").SendMessageOptions) => Promise<void>;
|
|
35
|
+
stopGenerating: () => void;
|
|
36
|
+
setMessage: (message: Message) => void;
|
|
37
|
+
changeTab: (tab: AdvancedTab) => Promise<void>;
|
|
38
|
+
sessionId: string;
|
|
39
|
+
startNewChat: () => Promise<void>;
|
|
40
|
+
isLoadingSessionIds: boolean;
|
|
41
|
+
ws: React.MutableRefObject<WebSocket | null>;
|
|
42
|
+
isConnected: React.MutableRefObject<boolean>;
|
|
43
|
+
messageQueue: React.MutableRefObject<any[]>;
|
|
44
|
+
sessionIds: import("../../features/chat/slice").SessionIds;
|
|
45
|
+
enableSafetyDisclaimer: any;
|
|
46
|
+
resetConnection: () => void;
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AdvancedTab } from "../../utils/data/advanced-tab";
|
|
2
|
+
import { ChatStatus } from "@web-utils/features";
|
|
3
|
+
export interface Message {
|
|
4
|
+
id: string;
|
|
5
|
+
role: "user" | "assistant" | "system";
|
|
6
|
+
content: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
fileType?: string;
|
|
10
|
+
contentType?: string;
|
|
11
|
+
visible: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type SendMessageOptions = {
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
} | undefined;
|
|
16
|
+
export interface UseChatProps {
|
|
17
|
+
wsUrl: string;
|
|
18
|
+
wsToken: string;
|
|
19
|
+
flowConfig: {
|
|
20
|
+
name: string;
|
|
21
|
+
tenant: string;
|
|
22
|
+
username: string;
|
|
23
|
+
pathway: string;
|
|
24
|
+
};
|
|
25
|
+
sessionId: string;
|
|
26
|
+
stopGenerationWsUrl: string;
|
|
27
|
+
activeTab: AdvancedTab;
|
|
28
|
+
enableHaptics?: boolean;
|
|
29
|
+
hapticFeedback?: {
|
|
30
|
+
impactAsync: (style: any) => Promise<void>;
|
|
31
|
+
};
|
|
32
|
+
redirectToAuthSpa: () => void;
|
|
33
|
+
store?: {
|
|
34
|
+
sendMessage?: (text: string) => Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
WebSocketImpl?: typeof WebSocket;
|
|
37
|
+
errorHandler?: (message: string, error?: any) => void;
|
|
38
|
+
onStatusChange: (status: ChatStatus) => void;
|
|
39
|
+
onStreamingChange: (streaming: boolean) => void;
|
|
40
|
+
onStreamingMessageUpdate: (message: {
|
|
41
|
+
id: string | null;
|
|
42
|
+
content: string;
|
|
43
|
+
}) => void;
|
|
44
|
+
onAddUserMessage?: (activeTab: AdvancedTab, message: Message) => void;
|
|
45
|
+
sendMessageToParentWebsite?: (payload: unknown) => void;
|
|
46
|
+
on402Error?: (message: Record<string, unknown>) => void;
|
|
47
|
+
}
|
|
48
|
+
export interface UseChatReturn {
|
|
49
|
+
sendMessage: (tab: AdvancedTab, text: string, options?: SendMessageOptions) => Promise<void>;
|
|
50
|
+
ws: React.MutableRefObject<WebSocket | null>;
|
|
51
|
+
isConnected: React.MutableRefObject<boolean>;
|
|
52
|
+
messageQueue: React.MutableRefObject<any[]>;
|
|
53
|
+
stopGenerating: () => void;
|
|
54
|
+
resetConnection: () => void;
|
|
55
|
+
}
|
|
56
|
+
export declare const useChat: ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, activeTab, enableHaptics, hapticFeedback, store, errorHandler, onStatusChange, onStreamingChange, onStreamingMessageUpdate, onAddUserMessage, WebSocketImpl, redirectToAuthSpa, sendMessageToParentWebsite, on402Error, }: 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,18 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
tenantKey: string;
|
|
3
|
+
mentorId: string;
|
|
4
|
+
username: string;
|
|
5
|
+
errorHandler?: (message: string, error?: any) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function useMentorTools({ tenantKey, mentorId, username, errorHandler, }: Props): {
|
|
8
|
+
tools: any;
|
|
9
|
+
activeTools: string[];
|
|
10
|
+
updateSessionTools: (tool: string) => Promise<void>;
|
|
11
|
+
enableWebBrowsing: boolean;
|
|
12
|
+
screenSharing: boolean;
|
|
13
|
+
deepResearch: boolean;
|
|
14
|
+
imageGeneration: boolean;
|
|
15
|
+
codeInterpreter: boolean;
|
|
16
|
+
promptsIsEnabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
export {};
|