@deepfrog/pangents-widget 2.1.3 → 2.1.5
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/App.d.ts +2 -0
- package/dist/Widget.d.ts +11 -0
- package/dist/components/ApiKeyError.d.ts +5 -0
- package/dist/components/CallDetailsPage.d.ts +8 -0
- package/dist/components/CallLogsPage.d.ts +1 -0
- package/dist/components/CallQueueCard.d.ts +8 -0
- package/dist/components/CarrierResultCard.d.ts +10 -0
- package/dist/components/ChatbotWidget.d.ts +19 -0
- package/dist/components/CompactApiKeyError.d.ts +8 -0
- package/dist/components/Empty.d.ts +1 -0
- package/dist/components/ErrorBoundary.d.ts +17 -0
- package/dist/components/HistoryScreen.d.ts +1 -0
- package/dist/components/LoginScreen.d.ts +5 -0
- package/dist/components/PoweredByFooter.d.ts +2 -0
- package/dist/components/SearchCarriersForm.d.ts +8 -0
- package/dist/components/SearchResults.d.ts +13 -0
- package/dist/components/SettingsScreen.d.ts +1 -0
- package/dist/components/WidgetBubble.d.ts +6 -0
- package/dist/components/WidgetPopup.d.ts +5 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/card.d.ts +8 -0
- package/dist/components/ui/confirmation-modal.d.ts +15 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/context/CarrierSearchContext.d.ts +20 -0
- package/dist/context/ChatContext.d.ts +40 -0
- package/dist/data/mockCallDetails.d.ts +5 -0
- package/dist/data/mockData.d.ts +8 -0
- package/dist/hooks/useInfiniteScroll.d.ts +24 -0
- package/dist/hooks/useTheme.d.ts +7 -0
- package/dist/index.cjs.js +10 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.es.js +83 -0
- package/dist/index.es.js.map +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/main.d.ts +1 -0
- package/dist/pages/CallDetailsPage.d.ts +1 -0
- package/dist/pages/EmailLeads/EmailLeadDetail.d.ts +1 -0
- package/dist/pages/EmailLeads/index.d.ts +1 -0
- package/dist/pages/Home.d.ts +1 -0
- package/dist/pages/SearchCarriersPage.d.ts +1 -0
- package/dist/pages/SearchResultsPage.d.ts +1 -0
- package/dist/pangents-widget.css +1 -0
- package/dist/routes/AppRouter.d.ts +1 -0
- package/dist/services/api/apiKeyValidation.d.ts +145 -0
- package/dist/services/api/authService.d.ts +39 -0
- package/dist/services/api/carrierService.d.ts +13 -0
- package/dist/services/api/client.d.ts +22 -0
- package/dist/services/api/dashboardService.d.ts +16 -0
- package/dist/services/api/emailLeadsService.d.ts +31 -0
- package/dist/services/api/interceptors.d.ts +4 -0
- package/dist/services/api/workflowService.d.ts +36 -0
- package/dist/services/auth/session.d.ts +44 -0
- package/dist/services/auth/tokens.d.ts +25 -0
- package/dist/services/cache/ApiKeyTracker.d.ts +78 -0
- package/dist/services/middleware/__tests__/enhancedErrorHandler.test.d.ts +1 -0
- package/dist/services/middleware/enhancedErrorHandler.d.ts +123 -0
- package/dist/services/middleware/errorHandler.d.ts +1 -0
- package/dist/services/middleware/responseFormatter.d.ts +61 -0
- package/dist/services/mock/config.d.ts +14 -0
- package/dist/services/mock/index.d.ts +7 -0
- package/dist/services/mock/mockApiKeyService.d.ts +49 -0
- package/dist/services/mock/mockAuthService.d.ts +12 -0
- package/dist/services/mock/mockData.d.ts +87 -0
- package/dist/services/queries/hooks.d.ts +64 -0
- package/dist/services/queries/mutations.d.ts +33 -0
- package/dist/services/queries/queryClient.d.ts +59 -0
- package/dist/stores/emailConversationStore.d.ts +16 -0
- package/dist/stores/emailLeadsStore.d.ts +55 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/types/carrier.d.ts +304 -0
- package/dist/types/email.d.ts +208 -0
- package/dist/types/index.d.ts +37 -0
- package/dist/types/searchHistory.d.ts +59 -0
- package/dist/utils/apiKeyValidation.d.ts +9 -0
- package/dist/utils/mockData.d.ts +5 -0
- package/dist/utils/storage.d.ts +23 -0
- package/dist/widget-embed-9DdEqVMP.cjs.js +46 -0
- package/dist/widget-embed-9DdEqVMP.cjs.js.map +1 -0
- package/dist/widget-embed-LzSoeVtX.es.js +29823 -0
- package/dist/widget-embed-LzSoeVtX.es.js.map +1 -0
- package/dist/widget-embed.cjs.js +10 -0
- package/dist/widget-embed.cjs.js.map +1 -0
- package/dist/widget-embed.d.ts +32 -0
- package/dist/widget-embed.es.js +15 -0
- package/dist/widget-embed.es.js.map +1 -0
- package/dist/widget.js +83 -22
- package/package.json +2 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface LoginCredentials {
|
|
2
|
+
email: string;
|
|
3
|
+
password: string;
|
|
4
|
+
}
|
|
5
|
+
export interface LoginResponse {
|
|
6
|
+
accessToken: string;
|
|
7
|
+
refreshToken: string;
|
|
8
|
+
user: User;
|
|
9
|
+
}
|
|
10
|
+
export interface User {
|
|
11
|
+
id: string;
|
|
12
|
+
email: string;
|
|
13
|
+
name: string;
|
|
14
|
+
role: string;
|
|
15
|
+
permissions: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface AuthState {
|
|
18
|
+
isAuthenticated: boolean;
|
|
19
|
+
user: User | null;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: string | null;
|
|
22
|
+
}
|
|
23
|
+
declare class AuthSession {
|
|
24
|
+
private state;
|
|
25
|
+
private listeners;
|
|
26
|
+
constructor();
|
|
27
|
+
private initializeSession;
|
|
28
|
+
login(credentials: LoginCredentials): Promise<void>;
|
|
29
|
+
logout(): void;
|
|
30
|
+
hasPermission(permission: string): boolean;
|
|
31
|
+
hasRole(role: string): boolean;
|
|
32
|
+
getState(): AuthState;
|
|
33
|
+
subscribe(listener: (state: AuthState) => void): () => void;
|
|
34
|
+
private setState;
|
|
35
|
+
private setupEventListeners;
|
|
36
|
+
}
|
|
37
|
+
export declare const authSession: AuthSession;
|
|
38
|
+
export declare const login: (credentials: LoginCredentials) => Promise<void>;
|
|
39
|
+
export declare const logout: () => void;
|
|
40
|
+
export declare const getAuthState: () => AuthState;
|
|
41
|
+
export declare const hasPermission: (permission: string) => boolean;
|
|
42
|
+
export declare const hasRole: (role: string) => boolean;
|
|
43
|
+
export declare const subscribeToAuth: (listener: (state: AuthState) => void) => () => void;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface JWTPayload {
|
|
2
|
+
exp: number;
|
|
3
|
+
iat: number;
|
|
4
|
+
sub: string;
|
|
5
|
+
scope?: string;
|
|
6
|
+
user_id?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export declare const getAccessToken: () => string | null;
|
|
10
|
+
export declare const getRefreshToken: () => string | null;
|
|
11
|
+
export declare const setTokens: (accessToken: string, refreshToken?: string) => void;
|
|
12
|
+
export declare const setAuthTokenFromResponse: (response: {
|
|
13
|
+
access_token: string;
|
|
14
|
+
token_type: string;
|
|
15
|
+
expires_in: number;
|
|
16
|
+
}) => void;
|
|
17
|
+
export declare const setBearerToken: (bearerToken: string) => void;
|
|
18
|
+
export declare const clearTokens: () => void;
|
|
19
|
+
export declare const isTokenExpired: (token?: string) => boolean;
|
|
20
|
+
export declare const getTokenExpiry: () => number | null;
|
|
21
|
+
export declare const getTokenPayload: (token?: string) => JWTPayload | null;
|
|
22
|
+
export declare const refreshAccessToken: () => Promise<string | null>;
|
|
23
|
+
export declare const setupAutoRefresh: () => void;
|
|
24
|
+
export declare const clearAutoRefresh: () => void;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Tracker Service
|
|
3
|
+
*
|
|
4
|
+
* This service tracks API key changes and manages cache invalidation
|
|
5
|
+
* when the API key changes between sessions or page reloads.
|
|
6
|
+
*/
|
|
7
|
+
export interface ApiKeyChangeEvent {
|
|
8
|
+
previousKey: string | null;
|
|
9
|
+
currentKey: string | null;
|
|
10
|
+
timestamp: number;
|
|
11
|
+
reason: 'initial_load' | 'key_change' | 'page_reload';
|
|
12
|
+
}
|
|
13
|
+
export type ApiKeyChangeListener = (event: ApiKeyChangeEvent) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Service to track API key changes and manage cache alignment
|
|
16
|
+
*/
|
|
17
|
+
export declare class ApiKeyTracker {
|
|
18
|
+
private static instance;
|
|
19
|
+
private currentApiKey;
|
|
20
|
+
private listeners;
|
|
21
|
+
private initialized;
|
|
22
|
+
private constructor();
|
|
23
|
+
/**
|
|
24
|
+
* Get singleton instance
|
|
25
|
+
*/
|
|
26
|
+
static getInstance(): ApiKeyTracker;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the tracker with the current API key
|
|
29
|
+
*/
|
|
30
|
+
initialize(apiKey: string | null): void;
|
|
31
|
+
/**
|
|
32
|
+
* Update the current API key and check for changes
|
|
33
|
+
*/
|
|
34
|
+
updateApiKey(newApiKey: string | null): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get the current API key
|
|
37
|
+
*/
|
|
38
|
+
getCurrentApiKey(): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Check if the API key has changed since last check
|
|
41
|
+
*/
|
|
42
|
+
hasApiKeyChanged(apiKey: string | null): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Subscribe to API key change events
|
|
45
|
+
*/
|
|
46
|
+
subscribe(listener: ApiKeyChangeListener): () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Get cache alignment information
|
|
49
|
+
*/
|
|
50
|
+
getCacheAlignment(): {
|
|
51
|
+
currentApiKey: string | null;
|
|
52
|
+
cacheApiKey: string | null;
|
|
53
|
+
isAligned: boolean;
|
|
54
|
+
lastUpdate: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Mark cache as aligned with current API key
|
|
58
|
+
*/
|
|
59
|
+
markCacheAligned(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Check if cache needs to be cleared due to API key mismatch
|
|
62
|
+
*/
|
|
63
|
+
shouldClearCache(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Reset the tracker (useful for testing)
|
|
66
|
+
*/
|
|
67
|
+
reset(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Private helper methods
|
|
70
|
+
*/
|
|
71
|
+
private getStoredApiKey;
|
|
72
|
+
private storeApiKey;
|
|
73
|
+
private getCacheAlignmentInfo;
|
|
74
|
+
private setCacheAlignmentInfo;
|
|
75
|
+
private notifyListeners;
|
|
76
|
+
private clearStoredData;
|
|
77
|
+
}
|
|
78
|
+
export declare const apiKeyTracker: ApiKeyTracker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ApiError } from '../types/api';
|
|
3
|
+
export interface ErrorContext {
|
|
4
|
+
component?: string;
|
|
5
|
+
action?: string;
|
|
6
|
+
userId?: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
userAgent: string;
|
|
9
|
+
url: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ErrorReport {
|
|
13
|
+
error: ApiError;
|
|
14
|
+
context: ErrorContext;
|
|
15
|
+
stack?: string;
|
|
16
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
17
|
+
}
|
|
18
|
+
declare class EnhancedErrorHandler {
|
|
19
|
+
private errorQueue;
|
|
20
|
+
private isOnline;
|
|
21
|
+
private maxQueueSize;
|
|
22
|
+
private retryAttempts;
|
|
23
|
+
private retryDelay;
|
|
24
|
+
private circuitBreaker;
|
|
25
|
+
private rateLimiter;
|
|
26
|
+
private reportingEnabled;
|
|
27
|
+
private duplicateErrorCache;
|
|
28
|
+
private readonly duplicateTimeWindow;
|
|
29
|
+
constructor();
|
|
30
|
+
private setupEventListeners;
|
|
31
|
+
private validateApiKeyBeforeRequest;
|
|
32
|
+
private generateErrorFingerprint;
|
|
33
|
+
private isDuplicateError;
|
|
34
|
+
handleApiError(error: any, context?: Partial<ErrorContext>): ApiError;
|
|
35
|
+
handleJavaScriptError(error: Error, context?: Partial<ErrorContext>): void;
|
|
36
|
+
private determineSeverity;
|
|
37
|
+
private reportError;
|
|
38
|
+
private flushErrorQueue;
|
|
39
|
+
private showUserNotification;
|
|
40
|
+
private canRetryError;
|
|
41
|
+
private getUserFriendlyMessage;
|
|
42
|
+
enableReporting(): void;
|
|
43
|
+
disableReporting(): void;
|
|
44
|
+
getQueueSize(): number;
|
|
45
|
+
getCircuitBreakerState(): string;
|
|
46
|
+
getRemainingRateLimit(): number;
|
|
47
|
+
clearQueue(): void;
|
|
48
|
+
forceFlush(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
declare const enhancedErrorHandler: EnhancedErrorHandler;
|
|
51
|
+
export declare const handleApiError: (error: any, context?: Partial<ErrorContext>) => ApiError;
|
|
52
|
+
export declare const handleJavaScriptError: (error: Error, context?: Partial<ErrorContext>) => void;
|
|
53
|
+
export declare const enableErrorReporting: () => void;
|
|
54
|
+
export declare const disableErrorReporting: () => void;
|
|
55
|
+
export declare const getErrorQueueSize: () => number;
|
|
56
|
+
export declare const getCircuitBreakerState: () => string;
|
|
57
|
+
export declare const getRemainingRateLimit: () => number;
|
|
58
|
+
export declare const clearErrorQueue: () => void;
|
|
59
|
+
export declare const forceFlushErrors: () => Promise<void>;
|
|
60
|
+
export declare const withErrorBoundary: (Component: React.ComponentType<any>, ErrorFallback?: React.ComponentType<any>) => {
|
|
61
|
+
new (props: any): {
|
|
62
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
63
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
context: unknown;
|
|
65
|
+
setState<K extends "error" | "hasError">(state: {
|
|
66
|
+
hasError: boolean;
|
|
67
|
+
error?: Error;
|
|
68
|
+
} | ((prevState: Readonly<{
|
|
69
|
+
hasError: boolean;
|
|
70
|
+
error?: Error;
|
|
71
|
+
}>, props: Readonly<any>) => {
|
|
72
|
+
hasError: boolean;
|
|
73
|
+
error?: Error;
|
|
74
|
+
} | Pick<{
|
|
75
|
+
hasError: boolean;
|
|
76
|
+
error?: Error;
|
|
77
|
+
}, K>) | Pick<{
|
|
78
|
+
hasError: boolean;
|
|
79
|
+
error?: Error;
|
|
80
|
+
}, K>, callback?: () => void): void;
|
|
81
|
+
forceUpdate(callback?: () => void): void;
|
|
82
|
+
readonly props: Readonly<any>;
|
|
83
|
+
state: Readonly<{
|
|
84
|
+
hasError: boolean;
|
|
85
|
+
error?: Error;
|
|
86
|
+
}>;
|
|
87
|
+
refs: {
|
|
88
|
+
[key: string]: React.ReactInstance;
|
|
89
|
+
};
|
|
90
|
+
componentDidMount?(): void;
|
|
91
|
+
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
|
|
92
|
+
hasError: boolean;
|
|
93
|
+
error?: Error;
|
|
94
|
+
}>, nextContext: any): boolean;
|
|
95
|
+
componentWillUnmount?(): void;
|
|
96
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<{
|
|
97
|
+
hasError: boolean;
|
|
98
|
+
error?: Error;
|
|
99
|
+
}>): any;
|
|
100
|
+
componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<{
|
|
101
|
+
hasError: boolean;
|
|
102
|
+
error?: Error;
|
|
103
|
+
}>, snapshot?: any): void;
|
|
104
|
+
componentWillMount?(): void;
|
|
105
|
+
UNSAFE_componentWillMount?(): void;
|
|
106
|
+
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
107
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
108
|
+
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
|
|
109
|
+
hasError: boolean;
|
|
110
|
+
error?: Error;
|
|
111
|
+
}>, nextContext: any): void;
|
|
112
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{
|
|
113
|
+
hasError: boolean;
|
|
114
|
+
error?: Error;
|
|
115
|
+
}>, nextContext: any): void;
|
|
116
|
+
};
|
|
117
|
+
getDerivedStateFromError(error: Error): {
|
|
118
|
+
hasError: boolean;
|
|
119
|
+
error: Error;
|
|
120
|
+
};
|
|
121
|
+
contextType?: React.Context<any> | undefined;
|
|
122
|
+
};
|
|
123
|
+
export default enhancedErrorHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handleApiError, handleJavaScriptError, enableErrorReporting, disableErrorReporting, getErrorQueueSize, getCircuitBreakerState, getRemainingRateLimit, clearErrorQueue, forceFlushErrors, withErrorBoundary, type ErrorContext, type ErrorReport, } from './enhancedErrorHandler';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ApiResponse, PaginatedResponse } from '../types/api';
|
|
2
|
+
declare class ResponseFormatter {
|
|
3
|
+
formatResponse<T>(data: any): ApiResponse<T>;
|
|
4
|
+
formatPaginatedResponse<T>(data: T[], pagination: {
|
|
5
|
+
page: number;
|
|
6
|
+
limit: number;
|
|
7
|
+
total: number;
|
|
8
|
+
totalPages?: number;
|
|
9
|
+
}): PaginatedResponse<T>;
|
|
10
|
+
formatErrorResponse(error: any): ApiResponse<null>;
|
|
11
|
+
transformResponseData<T>(data: any): T;
|
|
12
|
+
transformRequestData(data: any): any;
|
|
13
|
+
private toCamelCase;
|
|
14
|
+
private toSnakeCase;
|
|
15
|
+
validateResponse<T>(response: any): response is ApiResponse<T>;
|
|
16
|
+
validatePaginatedResponse<T>(response: any): response is PaginatedResponse<T>;
|
|
17
|
+
extractData<T>(response: ApiResponse<T>): T;
|
|
18
|
+
extractPaginatedData<T>(response: PaginatedResponse<T>): {
|
|
19
|
+
data: T[];
|
|
20
|
+
pagination: PaginatedResponse<T>['pagination'];
|
|
21
|
+
};
|
|
22
|
+
mergeResponses<T>(responses: ApiResponse<T>[]): ApiResponse<T[]>;
|
|
23
|
+
createResponseWithMetadata<T>(data: T, metadata?: Record<string, any>): ApiResponse<T> & {
|
|
24
|
+
metadata: Record<string, any>;
|
|
25
|
+
};
|
|
26
|
+
formatFileUploadResponse(file: File, uploadResult: any): ApiResponse<{
|
|
27
|
+
filename: string;
|
|
28
|
+
originalName: string;
|
|
29
|
+
size: number;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
id?: string;
|
|
33
|
+
}>;
|
|
34
|
+
formatSearchResponse<T>(data: T[], filters: Record<string, any>, pagination: {
|
|
35
|
+
page: number;
|
|
36
|
+
limit: number;
|
|
37
|
+
total: number;
|
|
38
|
+
}): PaginatedResponse<T> & {
|
|
39
|
+
filters: Record<string, any>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export declare const responseFormatter: ResponseFormatter;
|
|
43
|
+
export declare const formatResponse: <T>(data: any) => ApiResponse<T>;
|
|
44
|
+
export declare const formatPaginatedResponse: <T>(data: T[], pagination: {
|
|
45
|
+
page: number;
|
|
46
|
+
limit: number;
|
|
47
|
+
total: number;
|
|
48
|
+
totalPages?: number;
|
|
49
|
+
}) => PaginatedResponse<T>;
|
|
50
|
+
export declare const formatErrorResponse: (error: any) => ApiResponse<null>;
|
|
51
|
+
export declare const transformResponseData: <T>(data: any) => T;
|
|
52
|
+
export declare const transformRequestData: (data: any) => any;
|
|
53
|
+
export declare const validateResponse: <T>(response: any) => response is ApiResponse<T>;
|
|
54
|
+
export declare const extractData: <T>(response: ApiResponse<T>) => T;
|
|
55
|
+
export declare const extractPaginatedData: <T>(response: PaginatedResponse<T>) => {
|
|
56
|
+
data: T[];
|
|
57
|
+
pagination: PaginatedResponse<T_1>["pagination"];
|
|
58
|
+
};
|
|
59
|
+
export declare const responseInterceptor: (response: any) => any;
|
|
60
|
+
export declare const requestInterceptor: (config: any) => any;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const MOCK_CONFIG: {
|
|
2
|
+
USE_MOCK: boolean;
|
|
3
|
+
NETWORK_DELAY: number;
|
|
4
|
+
MOCK_USERS: {
|
|
5
|
+
email: string;
|
|
6
|
+
name: string;
|
|
7
|
+
otp: string;
|
|
8
|
+
}[];
|
|
9
|
+
MOCK_API_KEYS: string[];
|
|
10
|
+
OTP_EXPIRY: number;
|
|
11
|
+
TOKEN_EXPIRY: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const isMockEnabled: () => boolean;
|
|
14
|
+
export default MOCK_CONFIG;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { MOCK_CONFIG, isMockEnabled } from './config';
|
|
2
|
+
export { MockAuthService } from './mockAuthService';
|
|
3
|
+
export { MockApiKeyValidationService } from './mockApiKeyService';
|
|
4
|
+
export * from './mockData';
|
|
5
|
+
export { default as mockConfig } from './config';
|
|
6
|
+
export { default as mockAuthService } from './mockAuthService';
|
|
7
|
+
export { default as mockApiKeyService } from './mockApiKeyService';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ApiKeyValidationResponse } from '../api/apiKeyValidation';
|
|
2
|
+
import type { ApiResponse } from '../types/api.d.ts';
|
|
3
|
+
export declare class MockApiKeyValidationService {
|
|
4
|
+
/**
|
|
5
|
+
* Mock: Validate API key
|
|
6
|
+
*/
|
|
7
|
+
static validateApiKey(apiKey: string): Promise<{
|
|
8
|
+
isValid: boolean;
|
|
9
|
+
response?: ApiKeyValidationResponse;
|
|
10
|
+
error?: string;
|
|
11
|
+
fromCache?: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Mock: Make validation request (internal)
|
|
15
|
+
*/
|
|
16
|
+
static makeValidationRequest(apiKey: string): Promise<ApiResponse<ApiKeyValidationResponse>>;
|
|
17
|
+
static clearCache(): void;
|
|
18
|
+
static getCacheStats(): {
|
|
19
|
+
totalCached: number;
|
|
20
|
+
validCached: number;
|
|
21
|
+
expiredCached: number;
|
|
22
|
+
};
|
|
23
|
+
static getMetrics(): {
|
|
24
|
+
totalRequests: number;
|
|
25
|
+
cacheHits: number;
|
|
26
|
+
cacheMisses: number;
|
|
27
|
+
validationSuccesses: number;
|
|
28
|
+
validationFailures: number;
|
|
29
|
+
networkErrors: number;
|
|
30
|
+
averageResponseTime: number;
|
|
31
|
+
lastRequestTime: number;
|
|
32
|
+
cacheHitRate: number;
|
|
33
|
+
successRate: number;
|
|
34
|
+
rateLimitInfo: {
|
|
35
|
+
remainingRequests: number;
|
|
36
|
+
resetTime: number;
|
|
37
|
+
isLimited: boolean;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
static resetMetrics(): void;
|
|
41
|
+
static prevalidateApiKey(apiKey: string): Promise<void>;
|
|
42
|
+
static validateMultipleApiKeys(apiKeys: string[]): Promise<Array<{
|
|
43
|
+
apiKey: string;
|
|
44
|
+
isValid: boolean;
|
|
45
|
+
response?: ApiKeyValidationResponse;
|
|
46
|
+
error?: string;
|
|
47
|
+
}>>;
|
|
48
|
+
}
|
|
49
|
+
export default MockApiKeyValidationService;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Login2FAResponse, VerifyOtpResponse } from '../api/authService';
|
|
2
|
+
export declare class MockAuthService {
|
|
3
|
+
/**
|
|
4
|
+
* Mock: Send OTP to user's email for 2FA login
|
|
5
|
+
*/
|
|
6
|
+
static login2FA(username: string): Promise<Login2FAResponse>;
|
|
7
|
+
/**
|
|
8
|
+
* Mock: Verify OTP and get authentication token
|
|
9
|
+
*/
|
|
10
|
+
static verifyOTP(identifier: string, otp: string): Promise<VerifyOtpResponse>;
|
|
11
|
+
}
|
|
12
|
+
export default MockAuthService;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export declare const otpStore: Map<string, {
|
|
2
|
+
otp: string;
|
|
3
|
+
expiresAt: number;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const generateMockToken: (email: string) => string;
|
|
6
|
+
export declare const generateOTP: () => string;
|
|
7
|
+
export declare const getMockApiKeyValidationResponse: (apiKey: string, isValid: boolean) => {
|
|
8
|
+
success: boolean;
|
|
9
|
+
data: {
|
|
10
|
+
_id: string;
|
|
11
|
+
created_at: string;
|
|
12
|
+
updated_at: string;
|
|
13
|
+
status: boolean;
|
|
14
|
+
api_key_status: "active" | "inactive";
|
|
15
|
+
};
|
|
16
|
+
message: string;
|
|
17
|
+
status: number;
|
|
18
|
+
timestamp: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const getMockLogin2FAResponse: (email: string) => {
|
|
21
|
+
status: "otp_sent";
|
|
22
|
+
delivery: "email";
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const getMockVerifyOTPResponse: (email: string) => {
|
|
26
|
+
data: {
|
|
27
|
+
_id: string;
|
|
28
|
+
created_at: string;
|
|
29
|
+
updated_at: string;
|
|
30
|
+
access_token: string;
|
|
31
|
+
token_type: "bearer";
|
|
32
|
+
expires_in: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const findMockUser: (email: string) => {
|
|
36
|
+
email: string;
|
|
37
|
+
name: string;
|
|
38
|
+
otp: string;
|
|
39
|
+
};
|
|
40
|
+
export declare const isValidMockApiKey: (apiKey: string) => boolean;
|
|
41
|
+
export declare const storeOTP: (email: string, otp: string) => void;
|
|
42
|
+
export declare const verifyStoredOTP: (email: string, otp: string) => boolean;
|
|
43
|
+
declare const _default: {
|
|
44
|
+
otpStore: Map<string, {
|
|
45
|
+
otp: string;
|
|
46
|
+
expiresAt: number;
|
|
47
|
+
}>;
|
|
48
|
+
generateMockToken: (email: string) => string;
|
|
49
|
+
generateOTP: () => string;
|
|
50
|
+
getMockApiKeyValidationResponse: (apiKey: string, isValid: boolean) => {
|
|
51
|
+
success: boolean;
|
|
52
|
+
data: {
|
|
53
|
+
_id: string;
|
|
54
|
+
created_at: string;
|
|
55
|
+
updated_at: string;
|
|
56
|
+
status: boolean;
|
|
57
|
+
api_key_status: "active" | "inactive";
|
|
58
|
+
};
|
|
59
|
+
message: string;
|
|
60
|
+
status: number;
|
|
61
|
+
timestamp: string;
|
|
62
|
+
};
|
|
63
|
+
getMockLogin2FAResponse: (email: string) => {
|
|
64
|
+
status: "otp_sent";
|
|
65
|
+
delivery: "email";
|
|
66
|
+
message: string;
|
|
67
|
+
};
|
|
68
|
+
getMockVerifyOTPResponse: (email: string) => {
|
|
69
|
+
data: {
|
|
70
|
+
_id: string;
|
|
71
|
+
created_at: string;
|
|
72
|
+
updated_at: string;
|
|
73
|
+
access_token: string;
|
|
74
|
+
token_type: "bearer";
|
|
75
|
+
expires_in: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
findMockUser: (email: string) => {
|
|
79
|
+
email: string;
|
|
80
|
+
name: string;
|
|
81
|
+
otp: string;
|
|
82
|
+
};
|
|
83
|
+
isValidMockApiKey: (apiKey: string) => boolean;
|
|
84
|
+
storeOTP: (email: string, otp: string) => void;
|
|
85
|
+
verifyStoredOTP: (email: string, otp: string) => boolean;
|
|
86
|
+
};
|
|
87
|
+
export default _default;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { User, LoginCredentials, LoginResponse, CarrierSearchParams, CarrierSearchResult, CallLog, CallDetails, ChatMessage, Conversation } from '../types/api';
|
|
3
|
+
import type { SearchFormData, CarrierSearchResponse, WorkflowStatusResponse } from '../../types/carrier';
|
|
4
|
+
import type { DeleteWorkflowResponse } from '../../types/searchHistory';
|
|
5
|
+
import type { EmailLead, EmailConversation } from '../../types/email';
|
|
6
|
+
export declare const useAuth: () => import("@tanstack/react-query").UseQueryResult<User, Error>;
|
|
7
|
+
export declare const useLogin: (options?: UseMutationOptions<LoginResponse, Error, LoginCredentials>) => import("@tanstack/react-query").UseMutationResult<LoginResponse, Error, LoginCredentials, unknown>;
|
|
8
|
+
export declare const useLogout: (options?: UseMutationOptions<void, Error, void>) => import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
9
|
+
export declare const useCarrierSearch: (params: CarrierSearchParams, options?: UseQueryOptions<CarrierSearchResult[], Error>) => import("@tanstack/react-query").UseQueryResult<CarrierSearchResult[], Error>;
|
|
10
|
+
export declare const useCarrierDetails: (carrierId: string, options?: UseQueryOptions<CarrierSearchResult, Error>) => import("@tanstack/react-query").UseQueryResult<CarrierSearchResult, Error>;
|
|
11
|
+
export declare const useCarrierSearchMutation: (options?: UseMutationOptions<CarrierSearchResponse, Error, SearchFormData>) => import("@tanstack/react-query").UseMutationResult<CarrierSearchResponse, Error, SearchFormData, unknown>;
|
|
12
|
+
export declare const useCallLogs: (filters?: Record<string, any>, options?: UseQueryOptions<CallLog[], Error>) => import("@tanstack/react-query").UseQueryResult<CallLog[], Error>;
|
|
13
|
+
export declare const useCallDetails: (callId: string, options?: UseQueryOptions<CallDetails, Error>) => import("@tanstack/react-query").UseQueryResult<CallDetails, Error>;
|
|
14
|
+
export declare const useCallQueue: (options?: UseQueryOptions<CallLog[], Error>) => import("@tanstack/react-query").UseQueryResult<CallLog[], Error>;
|
|
15
|
+
export declare const useChatMessages: (conversationId: string, options?: UseQueryOptions<ChatMessage[], Error>) => import("@tanstack/react-query").UseQueryResult<ChatMessage[], Error>;
|
|
16
|
+
export declare const useSendMessage: (conversationId: string, options?: UseMutationOptions<ChatMessage, Error, {
|
|
17
|
+
content: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
}>) => import("@tanstack/react-query").UseMutationResult<ChatMessage, Error, {
|
|
20
|
+
content: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
}, unknown>;
|
|
23
|
+
export declare const useChatHistory: (options?: UseQueryOptions<Conversation[], Error>) => import("@tanstack/react-query").UseQueryResult<Conversation[], Error>;
|
|
24
|
+
export declare const useInfiniteList: <T>(queryKey: readonly unknown[], fetchFn: (pageParam: number) => Promise<{
|
|
25
|
+
data: T[];
|
|
26
|
+
nextPage?: number;
|
|
27
|
+
}>, options?: any) => import("@tanstack/react-query").DefinedUseQueryResult<unknown, Error>;
|
|
28
|
+
export declare const usePrefetchQueries: () => {
|
|
29
|
+
prefetchAuth: () => void;
|
|
30
|
+
prefetchCallQueue: () => void;
|
|
31
|
+
prefetchChatHistory: () => void;
|
|
32
|
+
};
|
|
33
|
+
export declare const useWorkflowList: () => {
|
|
34
|
+
fetchWorkflowPage: (page: number) => Promise<{
|
|
35
|
+
data: {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
origin: string;
|
|
39
|
+
destination: string;
|
|
40
|
+
cargoType: string;
|
|
41
|
+
weight: number;
|
|
42
|
+
volume: number;
|
|
43
|
+
pickupDate: string;
|
|
44
|
+
deliveryDate: string;
|
|
45
|
+
status: "failed" | "pending" | "processing" | "completed";
|
|
46
|
+
totalCarriers: number;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
completedAt: Date;
|
|
49
|
+
workflowId: string;
|
|
50
|
+
}[];
|
|
51
|
+
hasMore: boolean;
|
|
52
|
+
total: number;
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Hook for deleting a workflow with optimistic updates
|
|
57
|
+
*/
|
|
58
|
+
export declare const useDeleteWorkflow: (options?: UseMutationOptions<DeleteWorkflowResponse, Error, string>) => import("@tanstack/react-query").UseMutationResult<DeleteWorkflowResponse, Error, string, unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* Hook for fetching workflow status and results
|
|
61
|
+
*/
|
|
62
|
+
export declare const useWorkflowStatus: (workflowId: string, options?: UseQueryOptions<WorkflowStatusResponse, Error>) => import("@tanstack/react-query").UseQueryResult<WorkflowStatusResponse, Error>;
|
|
63
|
+
export declare const useEmailLeads: (filters?: Record<string, any>, options?: UseQueryOptions<EmailLead[], Error>) => import("@tanstack/react-query").UseQueryResult<EmailLead[], Error>;
|
|
64
|
+
export declare const useEmailConversation: (leadId: string, options?: UseQueryOptions<EmailConversation, Error>) => import("@tanstack/react-query").UseQueryResult<EmailConversation, Error>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { User, CarrierSearchResult, CallLog, CreateCallRequest, UpdateCallRequest } from '../types/api';
|
|
3
|
+
interface UpdateProfileContext {
|
|
4
|
+
previousUser?: User;
|
|
5
|
+
}
|
|
6
|
+
interface UpdateCallContext {
|
|
7
|
+
previousCall: CallLog;
|
|
8
|
+
}
|
|
9
|
+
export declare const useUpdateProfile: (options?: UseMutationOptions<User, Error, Partial<User>, UpdateProfileContext>) => import("@tanstack/react-query").UseMutationResult<User, Error, Partial<User>, UpdateProfileContext>;
|
|
10
|
+
export declare const useCreateCall: (options?: UseMutationOptions<CallLog, Error, CreateCallRequest>) => import("@tanstack/react-query").UseMutationResult<any, Error, CreateCallRequest, unknown>;
|
|
11
|
+
export declare const useUpdateCall: (options?: UseMutationOptions<CallLog, Error, {
|
|
12
|
+
id: string;
|
|
13
|
+
data: UpdateCallRequest;
|
|
14
|
+
}, UpdateCallContext>) => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
15
|
+
id: string;
|
|
16
|
+
data: UpdateCallRequest;
|
|
17
|
+
}, {
|
|
18
|
+
previousCall: CallLog;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const useDeleteCall: (options?: UseMutationOptions<void, Error, string>) => import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|
|
21
|
+
export declare const useSaveCarrierSearch: (options?: UseMutationOptions<CarrierSearchResult[], Error, any>) => import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
|
|
22
|
+
export declare const useBulkUpdateCalls: (options?: UseMutationOptions<CallLog[], Error, {
|
|
23
|
+
ids: string[];
|
|
24
|
+
data: Partial<CallLog>;
|
|
25
|
+
}>) => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
26
|
+
ids: string[];
|
|
27
|
+
data: Partial<CallLog>;
|
|
28
|
+
}, unknown>;
|
|
29
|
+
export declare const useOptimisticUpdate: <T>(queryKey: readonly unknown[]) => {
|
|
30
|
+
updateOptimistically: (updater: (old: T | undefined) => T) => void;
|
|
31
|
+
revertOptimisticUpdate: (previousData: T) => void;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
export declare const queryClient: QueryClient;
|
|
3
|
+
export declare const queryKeys: {
|
|
4
|
+
readonly auth: {
|
|
5
|
+
readonly me: () => readonly ["auth", "me"];
|
|
6
|
+
readonly permissions: () => readonly ["auth", "permissions"];
|
|
7
|
+
};
|
|
8
|
+
readonly users: {
|
|
9
|
+
readonly all: () => readonly ["users"];
|
|
10
|
+
readonly lists: () => readonly ["users", "list"];
|
|
11
|
+
readonly list: (filters: Record<string, any>) => readonly ["users", "list", Record<string, any>];
|
|
12
|
+
readonly details: () => readonly ["users", "detail"];
|
|
13
|
+
readonly detail: (id: string) => readonly ["users", "detail", string];
|
|
14
|
+
};
|
|
15
|
+
readonly carriers: {
|
|
16
|
+
readonly all: () => readonly ["carriers"];
|
|
17
|
+
readonly lists: () => readonly ["carriers", "list"];
|
|
18
|
+
readonly list: (filters: Record<string, any>) => readonly ["carriers", "list", Record<string, any>];
|
|
19
|
+
readonly details: () => readonly ["carriers", "detail"];
|
|
20
|
+
readonly detail: (id: string) => readonly ["carriers", "detail", string];
|
|
21
|
+
readonly search: (params: Record<string, any>) => readonly ["carriers", "search", Record<string, any>];
|
|
22
|
+
};
|
|
23
|
+
readonly calls: {
|
|
24
|
+
readonly all: () => readonly ["calls"];
|
|
25
|
+
readonly lists: () => readonly ["calls", "list"];
|
|
26
|
+
readonly list: (filters: Record<string, any>) => readonly ["calls", "list", Record<string, any>];
|
|
27
|
+
readonly details: () => readonly ["calls", "detail"];
|
|
28
|
+
readonly detail: (id: string) => readonly ["calls", "detail", string];
|
|
29
|
+
readonly logs: () => readonly ["calls", "logs"];
|
|
30
|
+
readonly queue: () => readonly ["calls", "queue"];
|
|
31
|
+
};
|
|
32
|
+
readonly chat: {
|
|
33
|
+
readonly all: () => readonly ["chat"];
|
|
34
|
+
readonly conversations: () => readonly ["chat", "conversations"];
|
|
35
|
+
readonly conversation: (id: string) => readonly ["chat", "conversations", string];
|
|
36
|
+
readonly messages: (conversationId: string) => readonly ["chat", "conversations", string, "messages"];
|
|
37
|
+
readonly history: () => readonly ["chat", "history"];
|
|
38
|
+
};
|
|
39
|
+
readonly emails: {
|
|
40
|
+
readonly all: () => readonly ["emails"];
|
|
41
|
+
readonly leads: () => readonly ["emails", "leads"];
|
|
42
|
+
readonly list: (filters: Record<string, any>) => readonly ["emails", "leads", Record<string, any>];
|
|
43
|
+
readonly details: () => readonly ["emails", "detail"];
|
|
44
|
+
readonly detail: (id: string) => readonly ["emails", "detail", string];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare const invalidateQueries: {
|
|
48
|
+
auth: () => Promise<void>;
|
|
49
|
+
users: () => Promise<void>;
|
|
50
|
+
carriers: () => Promise<void>;
|
|
51
|
+
calls: () => Promise<void>;
|
|
52
|
+
chat: () => Promise<void>;
|
|
53
|
+
all: () => Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
export declare const prefetchQueries: {
|
|
56
|
+
userProfile: () => Promise<void>;
|
|
57
|
+
callQueue: () => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
export declare const handleQueryError: (error: any) => void;
|