@finatic/client 0.0.132 → 0.0.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +87 -4
  2. package/dist/index.d.ts +471 -735
  3. package/dist/index.js +862 -756
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +863 -754
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/types/core/client/ApiClient.d.ts +206 -0
  8. package/dist/types/{client → core/client}/FinaticConnect.d.ts +54 -18
  9. package/dist/types/{portal → core/portal}/PortalUI.d.ts +1 -1
  10. package/dist/types/index.d.ts +6 -11
  11. package/dist/types/mocks/MockApiClient.d.ts +36 -90
  12. package/dist/types/mocks/MockDataProvider.d.ts +13 -3
  13. package/dist/types/mocks/MockFactory.d.ts +2 -2
  14. package/dist/types/{shared/themes → themes}/portalPresets.d.ts +1 -1
  15. package/dist/types/types/api/auth.d.ts +111 -0
  16. package/dist/types/types/{api.d.ts → api/broker.d.ts} +56 -284
  17. package/dist/types/types/api/core.d.ts +46 -0
  18. package/dist/types/types/api/errors.d.ts +23 -0
  19. package/dist/types/types/api/orders.d.ts +39 -0
  20. package/dist/types/types/{shared.d.ts → api/portfolio.d.ts} +26 -21
  21. package/dist/types/types/common/pagination.d.ts +33 -0
  22. package/dist/types/types/connect.d.ts +4 -2
  23. package/dist/types/types/index.d.ts +13 -0
  24. package/dist/types/types/{theme.d.ts → ui/theme.d.ts} +3 -0
  25. package/dist/types/utils/brokerUtils.d.ts +30 -0
  26. package/package.json +4 -3
  27. package/dist/types/client/ApiClient.d.ts +0 -234
  28. package/dist/types/mocks/index.d.ts +0 -5
  29. package/dist/types/security/ApiSecurity.d.ts +0 -24
  30. package/dist/types/security/RuntimeSecurity.d.ts +0 -28
  31. package/dist/types/security/SecurityUtils.d.ts +0 -21
  32. package/dist/types/security/index.d.ts +0 -2
  33. package/dist/types/services/AnalyticsService.d.ts +0 -18
  34. package/dist/types/services/ApiClient.d.ts +0 -121
  35. package/dist/types/services/PortalService.d.ts +0 -24
  36. package/dist/types/services/TradingService.d.ts +0 -55
  37. package/dist/types/services/api.d.ts +0 -23
  38. package/dist/types/services/auth.d.ts +0 -9
  39. package/dist/types/services/index.d.ts +0 -4
  40. package/dist/types/services/portfolio.d.ts +0 -10
  41. package/dist/types/services/trading.d.ts +0 -10
  42. package/dist/types/shared/index.d.ts +0 -2
  43. package/dist/types/shared/themes/index.d.ts +0 -2
  44. package/dist/types/shared/themes/presets.d.ts +0 -3
  45. package/dist/types/shared/themes/system.d.ts +0 -2
  46. package/dist/types/shared/types/index.d.ts +0 -110
  47. package/dist/types/types/config.d.ts +0 -12
  48. package/dist/types/types/errors.d.ts +0 -47
  49. package/dist/types/types/security.d.ts +0 -35
  50. package/dist/types/types.d.ts +0 -157
@@ -1,5 +1,5 @@
1
- import { Theme } from './theme';
2
- import { UserToken } from './api';
1
+ import { Theme } from './ui/theme';
2
+ import { UserToken } from './api/auth';
3
3
  import { PortalTheme } from './portal';
4
4
  export interface FinaticConnectOptions {
5
5
  /** The portal token from your backend */
@@ -48,4 +48,6 @@ export interface PortalOptions {
48
48
  onEvent?: (type: string, data: any) => void;
49
49
  /** Optional theme configuration for the portal */
50
50
  theme?: PortalTheme;
51
+ /** Optional list of broker names to filter by (only these brokers will be shown) */
52
+ brokers?: string[];
51
53
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Main types barrel export
3
+ */
4
+ export * from './api/core';
5
+ export * from './api/auth';
6
+ export * from './api/broker';
7
+ export * from './api/orders';
8
+ export * from './api/portfolio';
9
+ export * from './ui/theme';
10
+ export * from './common/pagination';
11
+ export * from './connect';
12
+ export type { DeviceInfo } from './api/auth';
13
+ export type { SessionResponse } from './api/auth';
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Theme-related types
3
+ */
1
4
  export interface Theme {
2
5
  mode: 'light' | 'dark';
3
6
  primaryColor: string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Broker filtering utility functions
3
+ */
4
+ /**
5
+ * Convert broker names to broker IDs, filtering out unsupported ones
6
+ * @param brokerNames Array of broker names to convert
7
+ * @returns Object containing valid broker IDs and any warnings about unsupported names
8
+ */
9
+ export declare function convertBrokerNamesToIds(brokerNames: string[]): {
10
+ brokerIds: string[];
11
+ warnings: string[];
12
+ };
13
+ /**
14
+ * Append broker filter parameters to a portal URL
15
+ * @param baseUrl The base portal URL (may already have query parameters)
16
+ * @param brokerNames Array of broker names to filter by
17
+ * @returns The portal URL with broker filter parameters appended
18
+ */
19
+ export declare function appendBrokerFilterToURL(baseUrl: string, brokerNames?: string[]): string;
20
+ /**
21
+ * Get list of supported broker names
22
+ * @returns Array of supported broker names
23
+ */
24
+ export declare function getSupportedBrokerNames(): string[];
25
+ /**
26
+ * Check if a broker name is supported
27
+ * @param brokerName The broker name to check
28
+ * @returns True if the broker is supported, false otherwise
29
+ */
30
+ export declare function isBrokerSupported(brokerName: string): boolean;
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@finatic/client",
3
- "version": "0.0.132",
3
+ "version": "0.0.134",
4
4
  "description": "Finatic Client SDK for browser integration",
5
5
  "type": "module",
6
- "private": false,
7
6
  "publishConfig": {
8
7
  "access": "public"
9
8
  },
@@ -25,6 +24,7 @@
25
24
  ],
26
25
  "scripts": {
27
26
  "build": "rollup -c",
27
+ "watch": "rollup -c -w",
28
28
  "clean": "rimraf dist",
29
29
  "lint": "eslint src --ext .ts,.tsx",
30
30
  "format": "prettier --write src/**/*.{ts,tsx}"
@@ -55,5 +55,6 @@
55
55
  "peerDependencies": {
56
56
  "react": ">=16.8.0",
57
57
  "react-dom": ">=16.8.0"
58
- }
58
+ },
59
+ "packageManager": "yarn@4.9.4+sha512.7b1cb0b62abba6a537b3a2ce00811a843bea02bcf53138581a6ae5b1bf563f734872bd47de49ce32a9ca9dcaff995aa789577ffb16811da7c603dcf69e73750b"
59
60
  }
@@ -1,234 +0,0 @@
1
- import { SessionResponse, OtpRequestResponse, OtpVerifyResponse, PortalUrlResponse, SessionValidationResponse, SessionAuthenticateResponse, UserToken, Holding, Order, Portfolio, BrokerInfo, BrokerAccount, BrokerOrder, BrokerPosition, BrokerDataOptions, SessionState, BrokerOrderParams, BrokerExtras, CryptoOrderOptions, OptionsOrderOptions, OrderResponse, TradingContext, BrokerConnection, TokenInfo, OrdersFilter, PositionsFilter, AccountsFilter } from '../types/api';
2
- import { PaginatedResult } from '../types';
3
- import { DeviceInfo } from '../types/api';
4
- import { ApiError } from '../utils/errors';
5
- export declare class ApiClient {
6
- private readonly baseUrl;
7
- protected readonly deviceInfo?: DeviceInfo;
8
- protected currentSessionState: SessionState | null;
9
- protected currentSessionId: string | null;
10
- private tradingContext;
11
- private tokenInfo;
12
- private refreshPromise;
13
- private readonly REFRESH_BUFFER_MINUTES;
14
- private companyId;
15
- private csrfToken;
16
- constructor(baseUrl: string, deviceInfo?: DeviceInfo);
17
- /**
18
- * Set session context (session ID, company ID, CSRF token)
19
- */
20
- setSessionContext(sessionId: string, companyId: string, csrfToken?: string): void;
21
- /**
22
- * Get the current session ID
23
- */
24
- getCurrentSessionId(): string | null;
25
- /**
26
- * Get the current company ID
27
- */
28
- getCurrentCompanyId(): string | null;
29
- /**
30
- * Get the current CSRF token
31
- */
32
- getCurrentCsrfToken(): string | null;
33
- /**
34
- * Store tokens after successful authentication
35
- */
36
- setTokens(accessToken: string, refreshToken: string, expiresAt: string, userId?: string): void;
37
- /**
38
- * Get the current access token, refreshing if necessary
39
- */
40
- getValidAccessToken(): Promise<string>;
41
- /**
42
- * Check if the current token is expired or about to expire
43
- */
44
- private isTokenExpired;
45
- /**
46
- * Refresh the access token using the refresh token
47
- */
48
- private refreshTokens;
49
- /**
50
- * Perform the actual token refresh request
51
- */
52
- private performTokenRefresh;
53
- /**
54
- * Clear stored tokens (useful for logout)
55
- */
56
- clearTokens(): void;
57
- /**
58
- * Get current token info (for debugging/testing)
59
- */
60
- getTokenInfo(): TokenInfo | null;
61
- /**
62
- * Make a request to the API.
63
- */
64
- protected request<T>(path: string, options: {
65
- method: string;
66
- headers?: Record<string, string>;
67
- body?: any;
68
- params?: Record<string, string>;
69
- }): Promise<T>;
70
- /**
71
- * Handle API errors. This method can be overridden by language-specific implementations.
72
- */
73
- protected handleError(status: number, error: any): ApiError;
74
- startSession(token: string, userId?: string): Promise<SessionResponse>;
75
- requestOtp(sessionId: string, email: string): Promise<OtpRequestResponse>;
76
- verifyOtp(sessionId: string, otp: string): Promise<OtpVerifyResponse>;
77
- authenticateDirectly(sessionId: string, userId: string): Promise<SessionAuthenticateResponse>;
78
- /**
79
- * Get the portal URL for an active session
80
- * @param sessionId The session identifier
81
- * @returns Portal URL response
82
- * @throws SessionError if session is not in ACTIVE state
83
- */
84
- getPortalUrl(sessionId: string): Promise<PortalUrlResponse>;
85
- validatePortalSession(sessionId: string, signature: string): Promise<SessionValidationResponse>;
86
- completePortalSession(sessionId: string): Promise<PortalUrlResponse>;
87
- getHoldings(accessToken: string): Promise<{
88
- data: Holding[];
89
- }>;
90
- getOrders(accessToken: string): Promise<{
91
- data: Order[];
92
- }>;
93
- getPortfolio(accessToken: string): Promise<{
94
- data: Portfolio;
95
- }>;
96
- placeOrder(accessToken: string, order: Order): Promise<void>;
97
- getHoldingsAuto(): Promise<{
98
- data: Holding[];
99
- }>;
100
- getOrdersAuto(): Promise<{
101
- data: Order[];
102
- }>;
103
- getPortfolioAuto(): Promise<{
104
- data: Portfolio;
105
- }>;
106
- placeOrderAuto(order: Order): Promise<void>;
107
- placeBrokerOrder(accessToken: string, params: Partial<BrokerOrderParams> & {
108
- symbol: string;
109
- orderQty: number;
110
- action: 'Buy' | 'Sell';
111
- orderType: 'Market' | 'Limit' | 'Stop' | 'TrailingStop';
112
- assetType: 'Stock' | 'Option' | 'Crypto' | 'Futures';
113
- }, extras?: BrokerExtras): Promise<OrderResponse>;
114
- cancelBrokerOrder(orderId: string, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any): Promise<OrderResponse>;
115
- modifyBrokerOrder(orderId: string, params: Partial<BrokerOrderParams>, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', extras?: any): Promise<OrderResponse>;
116
- setBroker(broker: 'robinhood' | 'tasty_trade' | 'ninja_trader'): void;
117
- setAccount(accountNumber: string, accountId?: string): void;
118
- getTradingContext(): TradingContext;
119
- clearTradingContext(): void;
120
- placeStockMarketOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
121
- placeStockLimitOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
122
- placeStockStopOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', stopPrice: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
123
- placeCryptoMarketOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', options?: CryptoOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
124
- placeCryptoLimitOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', options?: CryptoOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
125
- placeOptionsMarketOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', options: OptionsOrderOptions, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
126
- placeOptionsLimitOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, options: OptionsOrderOptions, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
127
- placeFuturesMarketOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
128
- placeFuturesLimitOrder(accessToken: string, symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
129
- private buildOrderRequestBody;
130
- private buildModifyRequestBody;
131
- private applyBrokerDefaults;
132
- revokeToken(accessToken: string): Promise<void>;
133
- getUserToken(userId: string): Promise<UserToken>;
134
- getCurrentSessionState(): SessionState | null;
135
- getBrokerList(accessToken: string): Promise<{
136
- _id: string;
137
- response_data: BrokerInfo[];
138
- message: string;
139
- status_code: number;
140
- warnings: null;
141
- errors: null;
142
- }>;
143
- getBrokerAccounts(accessToken: string, options?: BrokerDataOptions): Promise<{
144
- _id: string;
145
- response_data: BrokerAccount[];
146
- message: string;
147
- status_code: number;
148
- warnings: null;
149
- errors: null;
150
- }>;
151
- getBrokerOrders(accessToken: string, options?: BrokerDataOptions): Promise<{
152
- _id: string;
153
- response_data: BrokerOrder[];
154
- message: string;
155
- status_code: number;
156
- warnings: null;
157
- errors: null;
158
- }>;
159
- getBrokerPositions(accessToken: string, options?: BrokerDataOptions): Promise<{
160
- _id: string;
161
- response_data: BrokerPosition[];
162
- message: string;
163
- status_code: number;
164
- warnings: null;
165
- errors: null;
166
- }>;
167
- getBrokerConnections(accessToken: string): Promise<{
168
- _id: string;
169
- response_data: BrokerConnection[];
170
- message: string;
171
- status_code: number;
172
- warnings: null;
173
- errors: null;
174
- }>;
175
- getBrokerListAuto(): Promise<{
176
- _id: string;
177
- response_data: BrokerInfo[];
178
- message: string;
179
- status_code: number;
180
- warnings: null;
181
- errors: null;
182
- }>;
183
- getBrokerAccountsAuto(options?: BrokerDataOptions): Promise<{
184
- _id: string;
185
- response_data: BrokerAccount[];
186
- message: string;
187
- status_code: number;
188
- warnings: null;
189
- errors: null;
190
- }>;
191
- getBrokerOrdersAuto(options?: BrokerDataOptions): Promise<{
192
- _id: string;
193
- response_data: BrokerOrder[];
194
- message: string;
195
- status_code: number;
196
- warnings: null;
197
- errors: null;
198
- }>;
199
- getBrokerPositionsAuto(options?: BrokerDataOptions): Promise<{
200
- _id: string;
201
- response_data: BrokerPosition[];
202
- message: string;
203
- status_code: number;
204
- warnings: null;
205
- errors: null;
206
- }>;
207
- getBrokerConnectionsAuto(): Promise<{
208
- _id: string;
209
- response_data: BrokerConnection[];
210
- message: string;
211
- status_code: number;
212
- warnings: null;
213
- errors: null;
214
- }>;
215
- placeBrokerOrderAuto(params: Partial<BrokerOrderParams> & {
216
- symbol: string;
217
- orderQty: number;
218
- action: 'Buy' | 'Sell';
219
- orderType: 'Market' | 'Limit' | 'Stop' | 'TrailingStop';
220
- assetType: 'Stock' | 'Option' | 'Crypto' | 'Futures';
221
- }, extras?: BrokerExtras): Promise<OrderResponse>;
222
- placeStockMarketOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
223
- placeStockLimitOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', price: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
224
- placeStockStopOrderAuto(symbol: string, orderQty: number, action: 'Buy' | 'Sell', stopPrice: number, timeInForce?: 'day' | 'gtc', broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', accountNumber?: string, extras?: BrokerExtras): Promise<OrderResponse>;
225
- getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<BrokerOrder[]>>;
226
- getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<BrokerAccount[]>>;
227
- getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<BrokerPosition[]>>;
228
- getNextPage<T>(previousResult: PaginatedResult<T>, fetchFunction: (offset: number, limit: number) => Promise<PaginatedResult<T>>): Promise<PaginatedResult<T> | null>;
229
- /**
230
- * Check if this is a mock client
231
- * @returns false for real API client
232
- */
233
- isMockClient(): boolean;
234
- }
@@ -1,5 +0,0 @@
1
- export { MockApiClient } from './MockApiClient';
2
- export { MockDataProvider } from './MockDataProvider';
3
- export { MockFactory, createMockApiClient } from './MockFactory';
4
- export type { MockConfig, MockScenario } from './MockDataProvider';
5
- export { shouldUseMocks, setMockMode, getMockConfig } from './utils';
@@ -1,24 +0,0 @@
1
- export interface SecurityHeaders {
2
- 'X-Request-ID': string;
3
- 'X-Request-Timestamp': string;
4
- 'X-Request-Signature': string;
5
- 'X-Device-Fingerprint': string;
6
- 'User-Agent': string;
7
- }
8
- export declare class ApiSecurity {
9
- private static instance;
10
- private readonly runtimeSecurity;
11
- private readonly requestTimeout;
12
- private deviceFingerprint;
13
- private userAgent;
14
- private constructor();
15
- static getInstance(): ApiSecurity;
16
- generateRequestHeaders(): SecurityHeaders;
17
- setDeviceFingerprint(fingerprint: string): void;
18
- private generateDeviceFingerprint;
19
- private generateRequestSignature;
20
- validateResponse(): boolean;
21
- isRequestValid(headers: SecurityHeaders): boolean;
22
- private validateDeviceFingerprint;
23
- private validateRequestSignature;
24
- }
@@ -1,28 +0,0 @@
1
- export interface IRuntimeSecurity {
2
- isSecure(): boolean;
3
- validateEnvironment(): boolean;
4
- getEnvironmentInfo(): Record<string, any>;
5
- getClientIp(): string;
6
- generateFingerprint(): string;
7
- }
8
- export declare class RuntimeSecurity implements IRuntimeSecurity {
9
- private static instance;
10
- private readonly runtimeKey;
11
- private readonly integrityChecks;
12
- private isDebuggerAttached;
13
- private constructor();
14
- static getInstance(): RuntimeSecurity;
15
- private setupAntiDebugging;
16
- private setupIntegrityChecks;
17
- addIntegrityCheck(name: string, check: () => boolean): void;
18
- verifyIntegrity(): boolean;
19
- signRequest(data: any): string;
20
- validateEnvironment(): boolean;
21
- private handleSecurityViolation;
22
- private clearSensitiveData;
23
- private reportSecurityViolation;
24
- isSecure(): boolean;
25
- getClientIp(): string;
26
- generateFingerprint(): string;
27
- getEnvironmentInfo(): Record<string, any>;
28
- }
@@ -1,21 +0,0 @@
1
- export interface DeviceFingerprint {
2
- userAgent: string;
3
- ip: string;
4
- screenResolution: string;
5
- timezone: string;
6
- language: string;
7
- platform: string;
8
- }
9
- export declare class SecurityUtils {
10
- private static readonly TOKEN_REGEX;
11
- static generateDeviceFingerprint(): DeviceFingerprint;
12
- static validateToken(token: string): boolean;
13
- static validateDeviceFingerprint(fingerprint: string): boolean;
14
- static generateRequestSignature(): string;
15
- static validateResponseSignature(): boolean;
16
- static secureStorage: {
17
- set(key: string, value: string): void;
18
- get(key: string): string | null;
19
- remove(key: string): void;
20
- };
21
- }
@@ -1,2 +0,0 @@
1
- export { RuntimeSecurity } from './RuntimeSecurity';
2
- export type { IRuntimeSecurity } from './RuntimeSecurity';
@@ -1,18 +0,0 @@
1
- import { ApiClient } from './ApiClient';
2
- import { PerformanceMetrics, PortfolioSnapshot } from '../types/api';
3
- export interface IAnalyticsService {
4
- getPerformance(): Promise<PerformanceMetrics>;
5
- getDailyHistory(): Promise<any[]>;
6
- getWeeklySnapshots(): Promise<PortfolioSnapshot[]>;
7
- getPortfolioDeltas(): Promise<any[]>;
8
- getUserLogs(userId: string): Promise<any[]>;
9
- }
10
- export declare class CoreAnalyticsService implements IAnalyticsService {
11
- private apiClient;
12
- constructor(apiClient: ApiClient);
13
- getPerformance(): Promise<PerformanceMetrics>;
14
- getDailyHistory(): Promise<any[]>;
15
- getWeeklySnapshots(): Promise<PortfolioSnapshot[]>;
16
- getPortfolioDeltas(): Promise<any[]>;
17
- getUserLogs(userId: string): Promise<any[]>;
18
- }
@@ -1,121 +0,0 @@
1
- import { ApiConfig, ApiResponse, OrdersFilter, PositionsFilter, AccountsFilter, FilteredOrdersResponse, FilteredPositionsResponse, FilteredAccountsResponse } from '../types/api';
2
- import { PaginatedResult } from '../types';
3
- export declare class ApiClient {
4
- private baseUrl;
5
- private apiKey;
6
- private accessToken?;
7
- private refreshToken?;
8
- private isSandbox;
9
- constructor(config: ApiConfig);
10
- private getBaseUrl;
11
- private request;
12
- getPortalContent(): Promise<ApiResponse<{
13
- content: string;
14
- }>>;
15
- getInitToken(): Promise<ApiResponse<{
16
- token: string;
17
- }>>;
18
- login(otp: string): Promise<ApiResponse<{
19
- success: boolean;
20
- }>>;
21
- verifyOTP(otp: string): Promise<ApiResponse<{
22
- userId: string;
23
- connectionIds: string[];
24
- }>>;
25
- getUserProfile(): Promise<ApiResponse<{
26
- profile: any;
27
- brokers: any[];
28
- }>>;
29
- getConnectionComplete(): Promise<ApiResponse<{
30
- userId: string;
31
- connectionIds: string[];
32
- }>>;
33
- getUserToken(userId: string): Promise<ApiResponse<{
34
- accessToken: string;
35
- refreshToken: string;
36
- }>>;
37
- refreshAccessToken(): Promise<ApiResponse<{
38
- accessToken: string;
39
- refreshToken: string;
40
- }>>;
41
- revokeTokens(): Promise<ApiResponse<{
42
- success: boolean;
43
- }>>;
44
- connectBroker(brokerId: string): Promise<ApiResponse<{
45
- success: boolean;
46
- }>>;
47
- disconnectBroker(brokerId: string): Promise<ApiResponse<{
48
- success: boolean;
49
- }>>;
50
- getBrokerAccounts(): Promise<ApiResponse<{
51
- accounts: any[];
52
- }>>;
53
- getConnections(): Promise<ApiResponse<{
54
- connections: any[];
55
- }>>;
56
- getConnectionDetails(connectionId: string): Promise<ApiResponse<{
57
- connection: any;
58
- }>>;
59
- getAccounts(filter?: AccountsFilter): Promise<ApiResponse<{
60
- accounts: any[];
61
- }>>;
62
- getHoldings(): Promise<ApiResponse<{
63
- holdings: any[];
64
- }>>;
65
- getBalances(): Promise<ApiResponse<{
66
- balances: any;
67
- }>>;
68
- getTransactions(): Promise<ApiResponse<{
69
- transactions: any[];
70
- }>>;
71
- getPerformance(): Promise<ApiResponse<{
72
- performance: any;
73
- }>>;
74
- getOrders(filter?: OrdersFilter): Promise<ApiResponse<{
75
- orders: any[];
76
- }>>;
77
- getTrades(): Promise<ApiResponse<{
78
- trades: any[];
79
- }>>;
80
- placeOrder(order: any): Promise<ApiResponse<{
81
- orderId: string;
82
- }>>;
83
- cancelOrder(orderId: string): Promise<ApiResponse<{
84
- success: boolean;
85
- }>>;
86
- getOrderStatus(orderId: string): Promise<ApiResponse<{
87
- status: string;
88
- }>>;
89
- getOptionsChain(symbol: string): Promise<ApiResponse<{
90
- chain: any[];
91
- }>>;
92
- getOptionQuote(symbol: string, strike: number, expiry: string): Promise<ApiResponse<{
93
- quote: any;
94
- }>>;
95
- placeOptionsOrder(order: any): Promise<ApiResponse<{
96
- orderId: string;
97
- }>>;
98
- getDailyHistory(): Promise<ApiResponse<{
99
- history: any[];
100
- }>>;
101
- getWeeklySnapshots(): Promise<ApiResponse<{
102
- snapshots: any[];
103
- }>>;
104
- getPortfolioDeltas(): Promise<ApiResponse<{
105
- deltas: any[];
106
- }>>;
107
- getUserLogs(userId: string): Promise<ApiResponse<{
108
- logs: any[];
109
- }>>;
110
- getBrokerOrders(filter?: OrdersFilter): Promise<ApiResponse<FilteredOrdersResponse>>;
111
- getBrokerPositions(filter?: PositionsFilter): Promise<ApiResponse<FilteredPositionsResponse>>;
112
- getBrokerDataAccounts(filter?: AccountsFilter): Promise<ApiResponse<FilteredAccountsResponse>>;
113
- testWebhook(): Promise<ApiResponse<{
114
- success: boolean;
115
- }>>;
116
- private buildQueryParams;
117
- getBrokerOrdersPage(page?: number, perPage?: number, filters?: OrdersFilter): Promise<PaginatedResult<any[]>>;
118
- getBrokerAccountsPage(page?: number, perPage?: number, filters?: AccountsFilter): Promise<PaginatedResult<any[]>>;
119
- getBrokerPositionsPage(page?: number, perPage?: number, filters?: PositionsFilter): Promise<PaginatedResult<any[]>>;
120
- getNextPage<T>(previousResult: PaginatedResult<T>, fetchFunction: (offset: number, limit: number) => Promise<PaginatedResult<T>>): Promise<PaginatedResult<T> | null>;
121
- }
@@ -1,24 +0,0 @@
1
- import { ApiClient } from './ApiClient';
2
- import { PortalConfig } from '../types/portal';
3
- import { Theme } from '../types/theme';
4
- export interface IPortalService {
5
- createPortal(config: PortalConfig): Promise<void>;
6
- closePortal(): Promise<void>;
7
- updateTheme(theme: Theme): Promise<void>;
8
- getBrokerAccounts(): Promise<any[]>;
9
- linkBrokerAccount(brokerId: string): Promise<void>;
10
- unlinkBrokerAccount(brokerId: string): Promise<void>;
11
- }
12
- export declare class CorePortalService implements IPortalService {
13
- private apiClient;
14
- private iframe;
15
- constructor(apiClient: ApiClient);
16
- createPortal(config: PortalConfig): Promise<void>;
17
- closePortal(): Promise<void>;
18
- updateTheme(theme: Theme): Promise<void>;
19
- getBrokerAccounts(): Promise<any[]>;
20
- linkBrokerAccount(brokerId: string): Promise<void>;
21
- unlinkBrokerAccount(brokerId: string): Promise<void>;
22
- private positionIframe;
23
- private styleIframe;
24
- }
@@ -1,55 +0,0 @@
1
- import { ApiClient } from './ApiClient';
2
- import { Order, OptionsOrder, OrdersFilter, PositionsFilter, AccountsFilter, BrokerDataOrder, BrokerDataPosition, BrokerDataAccount } from '../types/api';
3
- import { PaginatedResult } from '../types';
4
- export interface ITradingService {
5
- getAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
6
- getOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
7
- getPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
8
- placeOrder(order: Order): Promise<string>;
9
- cancelOrder(orderId: string): Promise<boolean>;
10
- placeOptionsOrder(order: OptionsOrder): Promise<string>;
11
- getAccountsPage(page?: number, perPage?: number, filter?: AccountsFilter): Promise<PaginatedResult<BrokerDataAccount[]>>;
12
- getOrdersPage(page?: number, perPage?: number, filter?: OrdersFilter): Promise<PaginatedResult<BrokerDataOrder[]>>;
13
- getPositionsPage(page?: number, perPage?: number, filter?: PositionsFilter): Promise<PaginatedResult<BrokerDataPosition[]>>;
14
- getNextAccountsPage(previousResult: PaginatedResult<BrokerDataAccount[]>): Promise<PaginatedResult<BrokerDataAccount[]> | null>;
15
- getNextOrdersPage(previousResult: PaginatedResult<BrokerDataOrder[]>): Promise<PaginatedResult<BrokerDataOrder[]> | null>;
16
- getNextPositionsPage(previousResult: PaginatedResult<BrokerDataPosition[]>): Promise<PaginatedResult<BrokerDataPosition[]> | null>;
17
- getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
18
- getAllOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
19
- getAllPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
20
- getOpenPositions(): Promise<BrokerDataPosition[]>;
21
- getFilledOrders(): Promise<BrokerDataOrder[]>;
22
- getPendingOrders(): Promise<BrokerDataOrder[]>;
23
- getActiveAccounts(): Promise<BrokerDataAccount[]>;
24
- getOrdersBySymbol(symbol: string): Promise<BrokerDataOrder[]>;
25
- getPositionsBySymbol(symbol: string): Promise<BrokerDataPosition[]>;
26
- getOrdersByBroker(brokerId: string): Promise<BrokerDataOrder[]>;
27
- getPositionsByBroker(brokerId: string): Promise<BrokerDataPosition[]>;
28
- }
29
- export declare class CoreTradingService implements ITradingService {
30
- private apiClient;
31
- constructor(apiClient: ApiClient);
32
- getAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
33
- getOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
34
- getPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
35
- placeOrder(order: Order): Promise<string>;
36
- cancelOrder(orderId: string): Promise<boolean>;
37
- placeOptionsOrder(order: OptionsOrder): Promise<string>;
38
- getAccountsPage(page?: number, perPage?: number, filter?: AccountsFilter): Promise<PaginatedResult<BrokerDataAccount[]>>;
39
- getOrdersPage(page?: number, perPage?: number, filter?: OrdersFilter): Promise<PaginatedResult<BrokerDataOrder[]>>;
40
- getPositionsPage(page?: number, perPage?: number, filter?: PositionsFilter): Promise<PaginatedResult<BrokerDataPosition[]>>;
41
- getNextAccountsPage(previousResult: PaginatedResult<BrokerDataAccount[]>): Promise<PaginatedResult<BrokerDataAccount[]> | null>;
42
- getNextOrdersPage(previousResult: PaginatedResult<BrokerDataOrder[]>): Promise<PaginatedResult<BrokerDataOrder[]> | null>;
43
- getNextPositionsPage(previousResult: PaginatedResult<BrokerDataPosition[]>): Promise<PaginatedResult<BrokerDataPosition[]> | null>;
44
- getAllAccounts(filter?: AccountsFilter): Promise<BrokerDataAccount[]>;
45
- getAllOrders(filter?: OrdersFilter): Promise<BrokerDataOrder[]>;
46
- getAllPositions(filter?: PositionsFilter): Promise<BrokerDataPosition[]>;
47
- getOpenPositions(): Promise<BrokerDataPosition[]>;
48
- getFilledOrders(): Promise<BrokerDataOrder[]>;
49
- getPendingOrders(): Promise<BrokerDataOrder[]>;
50
- getActiveAccounts(): Promise<BrokerDataAccount[]>;
51
- getOrdersBySymbol(symbol: string): Promise<BrokerDataOrder[]>;
52
- getPositionsBySymbol(symbol: string): Promise<BrokerDataPosition[]>;
53
- getOrdersByBroker(brokerId: string): Promise<BrokerDataOrder[]>;
54
- getPositionsByBroker(brokerId: string): Promise<BrokerDataPosition[]>;
55
- }
@@ -1,23 +0,0 @@
1
- import { ApiConfig, ApiResponse } from '../types/api';
2
- export declare class ApiService {
3
- private config;
4
- private accessToken?;
5
- private deviceInfo?;
6
- constructor(config: ApiConfig);
7
- setAccessToken(token: string): void;
8
- setDeviceInfo(deviceInfo: string): void;
9
- private request;
10
- get<T>(path: string, options?: {
11
- headers?: Record<string, string>;
12
- params?: Record<string, string>;
13
- }): Promise<ApiResponse<T>>;
14
- post<T>(path: string, body: any, options?: {
15
- headers?: Record<string, string>;
16
- }): Promise<ApiResponse<T>>;
17
- put<T>(path: string, body: any, options?: {
18
- headers?: Record<string, string>;
19
- }): Promise<ApiResponse<T>>;
20
- delete<T>(path: string, options?: {
21
- headers?: Record<string, string>;
22
- }): Promise<ApiResponse<T>>;
23
- }