@finatic/client 0.0.133 → 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 -0
  2. package/dist/index.d.ts +471 -730
  3. package/dist/index.js +847 -734
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +848 -732
  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 -13
  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,9 +0,0 @@
1
- import { ApiService } from './api';
2
- import { UserToken, PortalResponse } from '../types/api';
3
- export declare class AuthService {
4
- private api;
5
- constructor(api: ApiService);
6
- getPortalToken(companyId: string): Promise<PortalResponse>;
7
- getUserToken(token: string, companyId: string, userId: string): Promise<UserToken>;
8
- revokeToken(accessToken: string): Promise<void>;
9
- }
@@ -1,4 +0,0 @@
1
- export * from './api';
2
- export * from './auth';
3
- export * from './portfolio';
4
- export * from './PortalService';
@@ -1,10 +0,0 @@
1
- import { ApiService } from './api';
2
- import { Holding, Portfolio, PortfolioSnapshot, PerformanceMetrics } from '../types/api';
3
- export declare class PortfolioService {
4
- private api;
5
- constructor(api: ApiService);
6
- getHoldings(accessToken: string): Promise<Holding[]>;
7
- getPortfolio(accessToken: string): Promise<Portfolio>;
8
- getPortfolioSnapshot(accessToken: string): Promise<PortfolioSnapshot>;
9
- getPerformanceMetrics(accessToken: string): Promise<PerformanceMetrics>;
10
- }
@@ -1,10 +0,0 @@
1
- import { ApiService } from './api';
2
- import { Order, OptionsOrder } from '../types/api';
3
- export declare class TradingService {
4
- private api;
5
- constructor(api: ApiService);
6
- placeOrder(accessToken: string, order: Order): Promise<void>;
7
- placeOptionsOrder(accessToken: string, order: OptionsOrder): Promise<void>;
8
- cancelOrder(accessToken: string, orderId: string): Promise<void>;
9
- getOrders(accessToken: string): Promise<Order[]>;
10
- }
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './themes';
@@ -1,2 +0,0 @@
1
- export * from './presets';
2
- export * from './system';
@@ -1,3 +0,0 @@
1
- import { Theme } from '../types';
2
- export declare const lightTheme: Theme;
3
- export declare const darkTheme: Theme;
@@ -1,2 +0,0 @@
1
- import { Theme } from '../types';
2
- export declare const systemTheme: Theme;
@@ -1,110 +0,0 @@
1
- export interface BrokerAccount {
2
- id: string;
3
- name: string;
4
- type: string;
5
- status: 'active' | 'inactive' | 'pending';
6
- balance?: {
7
- total: number;
8
- available: number;
9
- currency: string;
10
- };
11
- }
12
- export interface Theme {
13
- colors: {
14
- primary: string;
15
- secondary: string;
16
- background: {
17
- primary: string;
18
- secondary: string;
19
- tertiary: string;
20
- };
21
- text: {
22
- primary: string;
23
- secondary: string;
24
- disabled: string;
25
- error: string;
26
- success: string;
27
- warning: string;
28
- };
29
- border: {
30
- light: string;
31
- medium: string;
32
- dark: string;
33
- };
34
- status: {
35
- active: string;
36
- inactive: string;
37
- pending: string;
38
- error: string;
39
- success: string;
40
- };
41
- };
42
- typography: {
43
- fontFamily: string;
44
- fontSize: {
45
- xs: string;
46
- sm: string;
47
- base: string;
48
- lg: string;
49
- xl: string;
50
- '2xl': string;
51
- };
52
- fontWeight: {
53
- light: number;
54
- normal: number;
55
- medium: number;
56
- semibold: number;
57
- bold: number;
58
- };
59
- lineHeight: {
60
- none: number;
61
- tight: number;
62
- normal: number;
63
- relaxed: number;
64
- };
65
- };
66
- spacing: {
67
- xs: string;
68
- sm: string;
69
- md: string;
70
- lg: string;
71
- xl: string;
72
- '2xl': string;
73
- };
74
- animation: {
75
- duration: {
76
- fast: string;
77
- normal: string;
78
- slow: string;
79
- };
80
- easing: {
81
- linear: string;
82
- easeIn: string;
83
- easeOut: string;
84
- easeInOut: string;
85
- };
86
- };
87
- components: {
88
- button: {
89
- borderRadius: string;
90
- padding: string;
91
- fontSize: string;
92
- fontWeight: number;
93
- };
94
- input: {
95
- borderRadius: string;
96
- padding: string;
97
- fontSize: string;
98
- };
99
- card: {
100
- borderRadius: string;
101
- padding: string;
102
- shadow: string;
103
- };
104
- modal: {
105
- borderRadius: string;
106
- padding: string;
107
- backdrop: string;
108
- };
109
- };
110
- }
@@ -1,12 +0,0 @@
1
- import { Theme } from './theme';
2
- export interface SDKConfig {
3
- token: string;
4
- theme?: Theme;
5
- sandbox?: boolean;
6
- }
7
- export declare const DEFAULT_THEME: Theme;
8
- export declare const DEFAULT_CONFIG: SDKConfig;
9
- export interface PortalConfig {
10
- companyId: string;
11
- theme?: Theme;
12
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * Error-related types for Finatic Connect SDK
3
- */
4
- export interface BaseError {
5
- code: string;
6
- message: string;
7
- details?: Record<string, any>;
8
- }
9
- export interface ApiError extends BaseError {
10
- status: number;
11
- headers?: Record<string, string>;
12
- }
13
- export interface SessionError extends BaseError {
14
- sessionId?: string;
15
- status?: string;
16
- }
17
- export interface AuthenticationError extends BaseError {
18
- userId?: string;
19
- tokenType?: string;
20
- }
21
- export interface AuthorizationError extends BaseError {
22
- resource?: string;
23
- permission?: string;
24
- }
25
- export interface RateLimitError extends BaseError {
26
- retryAfter?: number;
27
- limit?: number;
28
- remaining?: number;
29
- }
30
- export interface TokenError extends BaseError {
31
- tokenType?: string;
32
- expiresAt?: string;
33
- }
34
- export interface ValidationError extends BaseError {
35
- field?: string;
36
- value?: any;
37
- constraints?: string[];
38
- }
39
- export interface NetworkError extends BaseError {
40
- url?: string;
41
- method?: string;
42
- status?: number;
43
- }
44
- export interface SecurityError extends BaseError {
45
- securityContext?: Record<string, any>;
46
- validationResult?: Record<string, any>;
47
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * Security-related types for Finatic Connect SDK
3
- */
4
- export interface DeviceFingerprint {
5
- userAgent: string;
6
- language: string;
7
- platform: string;
8
- screenResolution: string;
9
- timezone: string;
10
- }
11
- export interface SecurityHeaders {
12
- 'X-Request-ID': string;
13
- 'X-Request-Timestamp': string;
14
- 'X-Request-Signature': string;
15
- 'X-Device-Fingerprint': string;
16
- 'User-Agent': string;
17
- }
18
- export interface SecurityConfig {
19
- requestTimeout: number;
20
- maxRetries: number;
21
- retryDelay: number;
22
- validateDeviceFingerprint: boolean;
23
- validateRequestSignature: boolean;
24
- }
25
- export interface SecurityContext {
26
- deviceFingerprint: string | null;
27
- userAgent: string | null;
28
- lastRequestTimestamp: number;
29
- requestCount: number;
30
- }
31
- export interface SecurityValidationResult {
32
- isValid: boolean;
33
- error?: string;
34
- details?: Record<string, any>;
35
- }
@@ -1,157 +0,0 @@
1
- /**
2
- * Core types for Finatic Connect SDK
3
- */
4
- export interface Balance {
5
- cash: number;
6
- buyingPower: number;
7
- equity: number;
8
- longMarketValue: number;
9
- shortMarketValue: number;
10
- initialMargin: number;
11
- maintenanceMargin: number;
12
- lastEquity: number;
13
- }
14
- export interface Account {
15
- id: string;
16
- name: string;
17
- type_: string;
18
- status: string;
19
- balance: Balance | null;
20
- }
21
- export interface Holding {
22
- symbol: string;
23
- quantity: number;
24
- averagePrice: number;
25
- currentPrice: number;
26
- marketValue: number;
27
- unrealizedPnl: number;
28
- }
29
- export interface Order {
30
- symbol: string;
31
- quantity: number;
32
- side: 'buy' | 'sell';
33
- type_: 'market' | 'limit' | 'stop' | 'stop_limit';
34
- timeInForce: 'day' | 'gtc' | 'opg' | 'cls' | 'ioc' | 'fok';
35
- price?: number;
36
- stopPrice?: number;
37
- }
38
- export interface Portfolio {
39
- totalValue: number;
40
- cash: number;
41
- equity: number;
42
- positions: Holding[];
43
- }
44
- export interface Performance {
45
- totalReturn: number;
46
- dailyReturn: number;
47
- weeklyReturn: number;
48
- monthlyReturn: number;
49
- yearlyReturn: number;
50
- maxDrawdown: number;
51
- sharpeRatio: number;
52
- beta: number;
53
- alpha: number;
54
- }
55
- export interface Event {
56
- id: string;
57
- type_: string;
58
- timestamp: string;
59
- data: string;
60
- }
61
- export interface AnalyticsRequest {
62
- startDate: string;
63
- endDate: string;
64
- metrics: string[];
65
- groupBy?: string;
66
- }
67
- export interface AnalyticsResponse {
68
- data: Record<string, any>;
69
- metadata: {
70
- startDate: string;
71
- endDate: string;
72
- metrics: string[];
73
- groupBy?: string;
74
- };
75
- }
76
- export interface ErrorResponse {
77
- code: string;
78
- message: string;
79
- details?: Record<string, any>;
80
- }
81
- export interface PaginationParams {
82
- page?: number;
83
- limit?: number;
84
- sortBy?: string;
85
- sortOrder?: 'asc' | 'desc';
86
- }
87
- export interface PaginatedResponse<T> {
88
- data: T[];
89
- metadata: {
90
- total: number;
91
- page: number;
92
- limit: number;
93
- totalPages: number;
94
- };
95
- }
96
- export interface ApiPaginationInfo {
97
- has_more: boolean;
98
- next_offset: number;
99
- current_offset: number;
100
- limit: number;
101
- }
102
- export interface ApiResponse<T> {
103
- success: boolean;
104
- response_data: T;
105
- message: string;
106
- status_code: number;
107
- pagination?: ApiPaginationInfo;
108
- }
109
- export interface PaginationMetadata {
110
- hasMore: boolean;
111
- nextOffset: number;
112
- currentOffset: number;
113
- limit: number;
114
- currentPage: number;
115
- hasNext: boolean;
116
- hasPrevious: boolean;
117
- }
118
- export declare class PaginatedResult<T> {
119
- readonly data: T;
120
- readonly metadata: PaginationMetadata;
121
- private navigationCallback?;
122
- constructor(data: T, paginationInfo: ApiPaginationInfo, navigationCallback?: (offset: number, limit: number) => Promise<PaginatedResult<T>>);
123
- get hasNext(): boolean;
124
- get hasPrevious(): boolean;
125
- get currentPage(): number;
126
- /**
127
- * Navigate to the next page
128
- * @returns Promise<PaginatedResult<T> | null> - Next page result or null if no next page
129
- */
130
- nextPage(): Promise<PaginatedResult<T> | null>;
131
- /**
132
- * Navigate to the previous page
133
- * @returns Promise<PaginatedResult<T> | null> - Previous page result or null if no previous page
134
- */
135
- previousPage(): Promise<PaginatedResult<T> | null>;
136
- /**
137
- * Navigate to a specific page
138
- * @param pageNumber - The page number to navigate to (1-based)
139
- * @returns Promise<PaginatedResult<T> | null> - Page result or null if page doesn't exist
140
- */
141
- goToPage(pageNumber: number): Promise<PaginatedResult<T> | null>;
142
- /**
143
- * Get the first page
144
- * @returns Promise<PaginatedResult<T> | null> - First page result or null if error
145
- */
146
- firstPage(): Promise<PaginatedResult<T> | null>;
147
- /**
148
- * Get the last page (this is a best effort - we don't know the total count)
149
- * @returns Promise<PaginatedResult<T> | null> - Last page result or null if error
150
- */
151
- lastPage(): Promise<PaginatedResult<T> | null>;
152
- /**
153
- * Get pagination info as a string
154
- * @returns string - Human readable pagination info
155
- */
156
- getPaginationInfo(): string;
157
- }