@finatic/client 0.0.142 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +39 -0
- package/README.md +54 -425
- package/dist/index.d.ts +7329 -1579
- package/dist/index.js +8110 -6114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8047 -6085
- package/dist/index.mjs.map +1 -1
- package/package.json +77 -33
- package/dist/types/core/client/ApiClient.d.ts +0 -270
- package/dist/types/core/client/FinaticConnect.d.ts +0 -332
- package/dist/types/core/portal/PortalUI.d.ts +0 -37
- package/dist/types/index.d.ts +0 -12
- package/dist/types/lib/logger/index.d.ts +0 -2
- package/dist/types/lib/logger/logger.d.ts +0 -4
- package/dist/types/lib/logger/logger.types.d.ts +0 -28
- package/dist/types/mocks/MockApiClient.d.ts +0 -171
- package/dist/types/mocks/MockDataProvider.d.ts +0 -139
- package/dist/types/mocks/MockFactory.d.ts +0 -53
- package/dist/types/mocks/utils.d.ts +0 -24
- package/dist/types/themes/portalPresets.d.ts +0 -9
- package/dist/types/types/api/auth.d.ts +0 -93
- package/dist/types/types/api/broker.d.ts +0 -421
- package/dist/types/types/api/core.d.ts +0 -46
- package/dist/types/types/api/errors.d.ts +0 -31
- package/dist/types/types/api/orders.d.ts +0 -39
- package/dist/types/types/api/portfolio.d.ts +0 -55
- package/dist/types/types/common/pagination.d.ts +0 -33
- package/dist/types/types/connect.d.ts +0 -58
- package/dist/types/types/index.d.ts +0 -13
- package/dist/types/types/portal.d.ts +0 -204
- package/dist/types/types/ui/theme.d.ts +0 -104
- package/dist/types/utils/brokerUtils.d.ts +0 -30
- package/dist/types/utils/errors.d.ts +0 -45
- package/dist/types/utils/events.d.ts +0 -12
- package/dist/types/utils/themeUtils.d.ts +0 -34
- package/src/core/client/ApiClient.ts +0 -2004
- package/src/core/client/FinaticConnect.ts +0 -1606
- package/src/core/portal/PortalUI.ts +0 -335
- package/src/index.d.ts +0 -23
- package/src/index.ts +0 -100
- package/src/lib/logger/index.ts +0 -3
- package/src/lib/logger/logger.ts +0 -332
- package/src/lib/logger/logger.types.ts +0 -34
- package/src/mocks/MockApiClient.ts +0 -1058
- package/src/mocks/MockDataProvider.ts +0 -986
- package/src/mocks/MockFactory.ts +0 -97
- package/src/mocks/utils.ts +0 -133
- package/src/themes/portalPresets.ts +0 -1307
- package/src/types/api/auth.ts +0 -112
- package/src/types/api/broker.ts +0 -461
- package/src/types/api/core.ts +0 -53
- package/src/types/api/errors.ts +0 -35
- package/src/types/api/orders.ts +0 -45
- package/src/types/api/portfolio.ts +0 -59
- package/src/types/common/pagination.ts +0 -164
- package/src/types/connect.ts +0 -56
- package/src/types/index.ts +0 -25
- package/src/types/portal.ts +0 -214
- package/src/types/ui/theme.ts +0 -105
- package/src/utils/brokerUtils.ts +0 -104
- package/src/utils/errors.ts +0 -104
- package/src/utils/events.ts +0 -66
- package/src/utils/themeUtils.ts +0 -165
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { Order, OrderResponse } from '../types/api/orders';
|
|
2
|
-
import { BrokerInfo, BrokerAccount, BrokerBalance, BrokerConnection, OrdersFilter, PositionsFilter, AccountsFilter, BalancesFilter, BrokerDataOrder, BrokerDataPosition, BrokerOrderParams, DisconnectCompanyResponse } from '../types/api/broker';
|
|
3
|
-
import { SessionResponse, OtpRequestResponse, OtpVerifyResponse, SessionValidationResponse, SessionAuthenticateResponse, UserToken, RefreshTokenResponse } from '../types/api/auth';
|
|
4
|
-
import { PortalUrlResponse } from '../types/api/core';
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for mock behavior
|
|
7
|
-
*/
|
|
8
|
-
export interface MockConfig {
|
|
9
|
-
delay?: number;
|
|
10
|
-
scenario?: MockScenario;
|
|
11
|
-
customData?: Record<string, any>;
|
|
12
|
-
mockApiOnly?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Different mock scenarios for testing
|
|
16
|
-
*/
|
|
17
|
-
export type MockScenario = 'success' | 'error' | 'network_error' | 'rate_limit' | 'auth_failure';
|
|
18
|
-
/**
|
|
19
|
-
* Mock data provider for Finatic API endpoints
|
|
20
|
-
*/
|
|
21
|
-
export declare class MockDataProvider {
|
|
22
|
-
private config;
|
|
23
|
-
private sessionData;
|
|
24
|
-
private userTokens;
|
|
25
|
-
constructor(config?: MockConfig);
|
|
26
|
-
/**
|
|
27
|
-
* Get a random delay between min and max milliseconds
|
|
28
|
-
*/
|
|
29
|
-
private getRandomDelay;
|
|
30
|
-
/**
|
|
31
|
-
* Simulate network delay
|
|
32
|
-
*/
|
|
33
|
-
simulateDelay(): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Generate a realistic session ID
|
|
36
|
-
*/
|
|
37
|
-
private generateSessionId;
|
|
38
|
-
/**
|
|
39
|
-
* Generate a realistic user ID
|
|
40
|
-
*/
|
|
41
|
-
private generateUserId;
|
|
42
|
-
/**
|
|
43
|
-
* Generate a realistic company ID
|
|
44
|
-
*/
|
|
45
|
-
private generateCompanyId;
|
|
46
|
-
/**
|
|
47
|
-
* Generate mock tokens
|
|
48
|
-
*/
|
|
49
|
-
private generateTokens;
|
|
50
|
-
mockStartSession(token: string, userId?: string): Promise<SessionResponse>;
|
|
51
|
-
mockRequestOtp(sessionId: string, email: string): Promise<OtpRequestResponse>;
|
|
52
|
-
mockVerifyOtp(sessionId: string, otp: string): Promise<OtpVerifyResponse>;
|
|
53
|
-
mockAuthenticateDirectly(sessionId: string, userId: string): Promise<SessionAuthenticateResponse>;
|
|
54
|
-
mockGetPortalUrl(sessionId: string): Promise<PortalUrlResponse>;
|
|
55
|
-
mockValidatePortalSession(sessionId: string, signature: string): Promise<SessionValidationResponse>;
|
|
56
|
-
mockCompletePortalSession(sessionId: string): Promise<PortalUrlResponse>;
|
|
57
|
-
mockRefreshToken(refreshToken: string): Promise<RefreshTokenResponse>;
|
|
58
|
-
mockGetBrokerList(): Promise<{
|
|
59
|
-
_id: string;
|
|
60
|
-
response_data: BrokerInfo[];
|
|
61
|
-
message: string;
|
|
62
|
-
status_code: number;
|
|
63
|
-
warnings: null;
|
|
64
|
-
errors: null;
|
|
65
|
-
}>;
|
|
66
|
-
mockGetBrokerAccounts(): Promise<{
|
|
67
|
-
_id: string;
|
|
68
|
-
response_data: BrokerAccount[];
|
|
69
|
-
message: string;
|
|
70
|
-
status_code: number;
|
|
71
|
-
warnings: null;
|
|
72
|
-
errors: null;
|
|
73
|
-
}>;
|
|
74
|
-
mockGetBrokerConnections(): Promise<{
|
|
75
|
-
_id: string;
|
|
76
|
-
response_data: BrokerConnection[];
|
|
77
|
-
message: string;
|
|
78
|
-
status_code: number;
|
|
79
|
-
warnings: null;
|
|
80
|
-
errors: null;
|
|
81
|
-
}>;
|
|
82
|
-
mockGetOrders(filter?: OrdersFilter): Promise<{
|
|
83
|
-
data: Order[];
|
|
84
|
-
}>;
|
|
85
|
-
mockGetBrokerOrders(filter?: OrdersFilter): Promise<{
|
|
86
|
-
data: BrokerDataOrder[];
|
|
87
|
-
}>;
|
|
88
|
-
mockGetBrokerPositions(filter?: PositionsFilter): Promise<{
|
|
89
|
-
data: BrokerDataPosition[];
|
|
90
|
-
}>;
|
|
91
|
-
mockGetBrokerBalances(filter?: BalancesFilter): Promise<{
|
|
92
|
-
data: BrokerBalance[];
|
|
93
|
-
}>;
|
|
94
|
-
mockGetBrokerDataAccounts(filter?: AccountsFilter): Promise<{
|
|
95
|
-
data: BrokerAccount[];
|
|
96
|
-
}>;
|
|
97
|
-
mockPlaceOrder(order: BrokerOrderParams): Promise<OrderResponse>;
|
|
98
|
-
/**
|
|
99
|
-
* Get stored session data
|
|
100
|
-
*/
|
|
101
|
-
getSessionData(sessionId: string): any;
|
|
102
|
-
/**
|
|
103
|
-
* Get stored user token
|
|
104
|
-
*/
|
|
105
|
-
getUserToken(sessionId: string): UserToken | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* Clear all stored data
|
|
108
|
-
*/
|
|
109
|
-
clearData(): void;
|
|
110
|
-
/**
|
|
111
|
-
* Update configuration
|
|
112
|
-
*/
|
|
113
|
-
updateConfig(config: Partial<MockConfig>): void;
|
|
114
|
-
setScenario(scenario: MockScenario): void;
|
|
115
|
-
getScenario(): MockScenario;
|
|
116
|
-
private applyOrderFilters;
|
|
117
|
-
private applyBrokerOrderFilters;
|
|
118
|
-
private applyBrokerPositionFilters;
|
|
119
|
-
private applyBrokerAccountFilters;
|
|
120
|
-
private applyBrokerBalanceFilters;
|
|
121
|
-
/**
|
|
122
|
-
* Generate mock orders with diverse data
|
|
123
|
-
*/
|
|
124
|
-
private generateMockOrders;
|
|
125
|
-
/**
|
|
126
|
-
* Generate mock positions with diverse data
|
|
127
|
-
*/
|
|
128
|
-
private generateMockPositions;
|
|
129
|
-
/**
|
|
130
|
-
* Generate mock accounts with diverse data
|
|
131
|
-
*/
|
|
132
|
-
private generateMockAccounts;
|
|
133
|
-
/**
|
|
134
|
-
* Mock disconnect company method
|
|
135
|
-
* @param connectionId - The connection ID to disconnect
|
|
136
|
-
* @returns Promise with mock disconnect response
|
|
137
|
-
*/
|
|
138
|
-
mockDisconnectCompany(connectionId: string): Promise<DisconnectCompanyResponse>;
|
|
139
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { ApiClient } from '../core/client/ApiClient';
|
|
2
|
-
import { MockApiClient } from './MockApiClient';
|
|
3
|
-
import { MockConfig } from './MockDataProvider';
|
|
4
|
-
import { DeviceInfo } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Factory class for creating API clients (real or mock)
|
|
7
|
-
*/
|
|
8
|
-
export declare class MockFactory {
|
|
9
|
-
/**
|
|
10
|
-
* Create an API client based on environment configuration
|
|
11
|
-
* @param baseUrl - The base URL for the API
|
|
12
|
-
* @param deviceInfo - Optional device information
|
|
13
|
-
* @param mockConfig - Optional mock configuration (only used if mocks are enabled)
|
|
14
|
-
* @returns ApiClient or MockApiClient instance
|
|
15
|
-
*/
|
|
16
|
-
static createApiClient(baseUrl: string, deviceInfo?: DeviceInfo, mockConfig?: MockConfig): ApiClient | MockApiClient;
|
|
17
|
-
/**
|
|
18
|
-
* Force create a mock API client regardless of environment settings
|
|
19
|
-
* @param baseUrl - The base URL for the API
|
|
20
|
-
* @param deviceInfo - Optional device information
|
|
21
|
-
* @param mockConfig - Optional mock configuration
|
|
22
|
-
* @returns MockApiClient instance
|
|
23
|
-
*/
|
|
24
|
-
static createMockApiClient(baseUrl: string, deviceInfo?: DeviceInfo, mockConfig?: MockConfig): MockApiClient;
|
|
25
|
-
/**
|
|
26
|
-
* Force create a real API client regardless of environment settings
|
|
27
|
-
* @param baseUrl - The base URL for the API
|
|
28
|
-
* @param deviceInfo - Optional device information
|
|
29
|
-
* @returns ApiClient instance
|
|
30
|
-
*/
|
|
31
|
-
static createRealApiClient(baseUrl: string, deviceInfo?: DeviceInfo): ApiClient;
|
|
32
|
-
/**
|
|
33
|
-
* Check if mocks are currently enabled
|
|
34
|
-
* @returns boolean indicating if mocks are enabled
|
|
35
|
-
*/
|
|
36
|
-
static isMockMode(): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Get current mock configuration
|
|
39
|
-
* @returns Mock configuration object
|
|
40
|
-
*/
|
|
41
|
-
static getMockConfig(): {
|
|
42
|
-
enabled: boolean;
|
|
43
|
-
delay?: number;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Convenience function to create an API client
|
|
48
|
-
* @param baseUrl - The base URL for the API
|
|
49
|
-
* @param deviceInfo - Optional device information
|
|
50
|
-
* @param mockConfig - Optional mock configuration
|
|
51
|
-
* @returns ApiClient or MockApiClient instance
|
|
52
|
-
*/
|
|
53
|
-
export declare function createMockApiClient(baseUrl: string, deviceInfo?: DeviceInfo, mockConfig?: MockConfig): ApiClient | MockApiClient;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for mock system environment detection
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Check if mocks should be used based on environment variables
|
|
6
|
-
* Supports both browser and Node.js environments
|
|
7
|
-
*/
|
|
8
|
-
export declare function shouldUseMocks(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Set mock mode in the current environment
|
|
11
|
-
*/
|
|
12
|
-
export declare function setMockMode(enabled: boolean): void;
|
|
13
|
-
/**
|
|
14
|
-
* Check if only API should be mocked (but portal should use real URL)
|
|
15
|
-
*/
|
|
16
|
-
export declare function shouldMockApiOnly(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Get mock configuration from environment
|
|
19
|
-
*/
|
|
20
|
-
export declare function getMockConfig(): {
|
|
21
|
-
enabled: boolean;
|
|
22
|
-
delay?: number;
|
|
23
|
-
mockApiOnly?: boolean;
|
|
24
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PortalThemeConfig } from '../types/portal';
|
|
2
|
-
export declare const darkTheme: PortalThemeConfig;
|
|
3
|
-
export declare const lightTheme: PortalThemeConfig;
|
|
4
|
-
export declare const corporateBlueTheme: PortalThemeConfig;
|
|
5
|
-
export declare const purpleTheme: PortalThemeConfig;
|
|
6
|
-
export declare const greenTheme: PortalThemeConfig;
|
|
7
|
-
export declare const orangeTheme: PortalThemeConfig;
|
|
8
|
-
export declare const stockAlgosTheme: PortalThemeConfig;
|
|
9
|
-
export declare const portalThemePresets: Record<string, PortalThemeConfig>;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication-related types
|
|
3
|
-
*/
|
|
4
|
-
export interface SessionInitResponse {
|
|
5
|
-
success: boolean;
|
|
6
|
-
message: string;
|
|
7
|
-
data: {
|
|
8
|
-
one_time_token: string;
|
|
9
|
-
expires_at: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export interface OtpRequestResponse {
|
|
13
|
-
success: boolean;
|
|
14
|
-
message: string;
|
|
15
|
-
data: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface OtpVerifyResponse {
|
|
18
|
-
success: boolean;
|
|
19
|
-
message: string;
|
|
20
|
-
data: {
|
|
21
|
-
access_token: string;
|
|
22
|
-
refresh_token: string;
|
|
23
|
-
user_id: string;
|
|
24
|
-
expires_in: number;
|
|
25
|
-
scope: string;
|
|
26
|
-
token_type: 'Bearer';
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface UserToken {
|
|
30
|
-
user_id: string;
|
|
31
|
-
}
|
|
32
|
-
export interface SessionValidationResponse {
|
|
33
|
-
valid: boolean;
|
|
34
|
-
company_id: string;
|
|
35
|
-
status: string;
|
|
36
|
-
is_sandbox: boolean;
|
|
37
|
-
environment: string;
|
|
38
|
-
}
|
|
39
|
-
export interface SessionAuthenticateResponse {
|
|
40
|
-
success: boolean;
|
|
41
|
-
message: string;
|
|
42
|
-
data: {
|
|
43
|
-
access_token: string;
|
|
44
|
-
refresh_token: string;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export interface RefreshTokenRequest {
|
|
48
|
-
refresh_token: string;
|
|
49
|
-
}
|
|
50
|
-
export interface RefreshTokenResponse {
|
|
51
|
-
success: boolean;
|
|
52
|
-
response_data: {
|
|
53
|
-
access_token: string;
|
|
54
|
-
refresh_token: string;
|
|
55
|
-
expires_at: string;
|
|
56
|
-
company_id: string;
|
|
57
|
-
company_name: string;
|
|
58
|
-
email_verified: boolean;
|
|
59
|
-
};
|
|
60
|
-
message: string;
|
|
61
|
-
}
|
|
62
|
-
export interface TokenInfo {
|
|
63
|
-
accessToken: string;
|
|
64
|
-
refreshToken: string;
|
|
65
|
-
expiresAt: string;
|
|
66
|
-
userId?: string;
|
|
67
|
-
}
|
|
68
|
-
export interface SessionResponseData {
|
|
69
|
-
session_id: string;
|
|
70
|
-
company_id: string;
|
|
71
|
-
status: string;
|
|
72
|
-
expires_at: string;
|
|
73
|
-
user_id?: string | null;
|
|
74
|
-
auto_login?: boolean;
|
|
75
|
-
}
|
|
76
|
-
export interface SessionResponse {
|
|
77
|
-
success: boolean;
|
|
78
|
-
message: string;
|
|
79
|
-
data: SessionResponseData;
|
|
80
|
-
}
|
|
81
|
-
export declare enum SessionState {
|
|
82
|
-
PENDING = "PENDING",
|
|
83
|
-
AUTHENTICATING = "AUTHENTICATING",
|
|
84
|
-
ACTIVE = "ACTIVE",
|
|
85
|
-
COMPLETED = "COMPLETED",
|
|
86
|
-
EXPIRED = "EXPIRED"
|
|
87
|
-
}
|
|
88
|
-
export type SessionStatus = SessionState;
|
|
89
|
-
export interface DeviceInfo {
|
|
90
|
-
ip_address: string;
|
|
91
|
-
user_agent: string;
|
|
92
|
-
fingerprint: string;
|
|
93
|
-
}
|