@finatic/client 0.0.136 → 0.0.138

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/README.md CHANGED
@@ -13,6 +13,7 @@ yarn add @finatic/client
13
13
  ## Basic Usage
14
14
 
15
15
  ### Simple Initialization
16
+
16
17
  ```typescript
17
18
  import { FinaticConnect } from '@finatic/client';
18
19
 
@@ -21,30 +22,32 @@ const finatic = await FinaticConnect.init('your-one-time-token');
21
22
  ```
22
23
 
23
24
  ### With User ID (for returning users)
25
+
24
26
  ```typescript
25
27
  // Pass token and user ID from previous session
26
28
  const finatic = await FinaticConnect.init('your-one-time-token', 'user-123');
27
29
  ```
28
30
 
29
31
  ### With Custom Configuration
32
+
30
33
  ```typescript
31
34
  // Pass token, user ID, and custom API URL
32
35
  const finatic = await FinaticConnect.init('your-one-time-token', 'user-123', {
33
- baseUrl: 'https://api.finatic.dev'
36
+ baseUrl: 'https://api.finatic.dev',
34
37
  });
35
38
  ```
36
39
 
37
40
  // Open the portal
38
41
  await finatic.openPortal({
39
- onSuccess: (userId) => {
40
- console.log('Authentication successful:', userId);
41
- },
42
- onError: (error) => {
43
- console.error('Authentication failed:', error);
44
- },
45
- onClose: () => {
46
- console.log('Portal closed');
47
- }
42
+ onSuccess: (userId) => {
43
+ console.log('Authentication successful:', userId);
44
+ },
45
+ onError: (error) => {
46
+ console.error('Authentication failed:', error);
47
+ },
48
+ onClose: () => {
49
+ console.log('Portal closed');
50
+ }
48
51
  });
49
52
 
50
53
  // After successful authentication, you can use these methods:
@@ -54,8 +57,8 @@ const brokers = await finatic.getBrokerList();
54
57
 
55
58
  // Get broker accounts with pagination
56
59
  const accountsPage = await finatic.getAccounts({
57
- page: 1,
58
- perPage: 100
60
+ page: 1,
61
+ perPage: 100
59
62
  });
60
63
 
61
64
  // Navigate through pages
@@ -67,29 +70,29 @@ const allAccounts = await finatic.getAllAccounts();
67
70
 
68
71
  // Get orders with filtering
69
72
  const ordersPage = await finatic.getOrders({
70
- page: 1,
71
- perPage: 50,
72
- filter: { status: 'filled', symbol: 'AAPL' }
73
+ page: 1,
74
+ perPage: 50,
75
+ filter: { status: 'filled', symbol: 'AAPL' }
73
76
  });
74
77
 
75
78
  // Get positions
76
79
  const positionsPage = await finatic.getPositions({
77
- page: 1,
78
- perPage: 100
80
+ page: 1,
81
+ perPage: 100
79
82
  });
80
83
 
81
84
  // Place orders
82
85
  await finatic.placeOrder({
83
- symbol: 'AAPL',
84
- side: 'buy',
85
- quantity: 10,
86
- type: 'market',
87
- timeInForce: 'day'
86
+ symbol: 'AAPL',
87
+ side: 'buy',
88
+ quantity: 10,
89
+ type: 'market',
90
+ timeInForce: 'day'
88
91
  });
89
92
 
90
93
  // Open portal with broker filtering
91
94
  await finatic.openPortal({
92
- brokers: ['alpaca', 'robinhood'] // Only show these brokers
95
+ brokers: ['alpaca', 'robinhood'] // Only show these brokers
93
96
  });
94
97
 
95
98
  // Disconnect a company from a broker connection
@@ -98,7 +101,8 @@ console.log('Disconnect action:', disconnectResponse.response_data.action);
98
101
 
99
102
  // Close the portal when done
100
103
  finatic.closePortal();
101
- ```
104
+
105
+ ````
102
106
 
103
107
  ## API Reference
104
108
 
@@ -148,7 +152,7 @@ await finatic.openPortal({
148
152
  });
149
153
 
150
154
  // Available presets: 'dark', 'light', 'corporateBlue', 'purple', 'green', 'orange'
151
- ```
155
+ ````
152
156
 
153
157
  #### Using Custom Themes
154
158
 
@@ -162,7 +166,7 @@ const customTheme = {
162
166
  secondary: '#2a2a2a',
163
167
  tertiary: '#3a3a3a',
164
168
  accent: 'rgba(59, 130, 246, 0.1)',
165
- glass: 'rgba(255, 255, 255, 0.05)'
169
+ glass: 'rgba(255, 255, 255, 0.05)',
166
170
  },
167
171
  status: {
168
172
  connected: '#10B981',
@@ -170,68 +174,70 @@ const customTheme = {
170
174
  warning: '#F59E0B',
171
175
  pending: '#8B5CF6',
172
176
  error: '#EF4444',
173
- success: '#10B981'
177
+ success: '#10B981',
174
178
  },
175
179
  text: {
176
180
  primary: '#F8FAFC',
177
181
  secondary: '#CBD5E1',
178
182
  muted: '#94A3B8',
179
- inverse: '#1a1a1a'
183
+ inverse: '#1a1a1a',
180
184
  },
181
185
  border: {
182
186
  primary: 'rgba(59, 130, 246, 0.2)',
183
187
  secondary: 'rgba(255, 255, 255, 0.1)',
184
188
  hover: 'rgba(59, 130, 246, 0.4)',
185
189
  focus: 'rgba(59, 130, 246, 0.6)',
186
- accent: '#3B82F6'
190
+ accent: '#3B82F6',
187
191
  },
188
192
  input: {
189
193
  background: '#334155',
190
194
  border: 'rgba(59, 130, 246, 0.2)',
191
195
  borderFocus: '#3B82F6',
192
196
  text: '#F8FAFC',
193
- placeholder: '#94A3B8'
197
+ placeholder: '#94A3B8',
194
198
  },
195
199
  button: {
196
200
  primary: {
197
201
  background: '#3B82F6',
198
202
  text: '#FFFFFF',
199
203
  hover: '#2563EB',
200
- active: '#1D4ED8'
204
+ active: '#1D4ED8',
201
205
  },
202
206
  secondary: {
203
207
  background: 'transparent',
204
208
  text: '#3B82F6',
205
209
  border: '#3B82F6',
206
210
  hover: 'rgba(59, 130, 246, 0.1)',
207
- active: 'rgba(59, 130, 246, 0.2)'
208
- }
209
- }
211
+ active: 'rgba(59, 130, 246, 0.2)',
212
+ },
213
+ },
210
214
  },
211
215
  branding: {
212
- primaryColor: '#3B82F6'
213
- }
216
+ primaryColor: '#3B82F6',
217
+ },
214
218
  };
215
219
 
216
220
  await finatic.openPortal({
217
- theme: { custom: customTheme }
221
+ theme: { custom: customTheme },
218
222
  });
219
223
  ```
220
224
 
221
225
  #### Theme Utilities
222
226
 
223
227
  ```javascript
224
- import {
225
- generatePortalThemeURL,
226
- appendThemeToURL,
227
- getThemePreset,
228
+ import {
229
+ generatePortalThemeURL,
230
+ appendThemeToURL,
231
+ getThemePreset,
228
232
  validateCustomTheme,
229
233
  createCustomThemeFromPreset,
230
- portalThemePresets
234
+ portalThemePresets,
231
235
  } from 'finatic-sdk';
232
236
 
233
237
  // Generate a themed portal URL
234
- const themedUrl = generatePortalThemeURL('http://localhost:5173/companies', { preset: 'corporateBlue' });
238
+ const themedUrl = generatePortalThemeURL('http://localhost:5173/companies', {
239
+ preset: 'corporateBlue',
240
+ });
235
241
 
236
242
  // Get a theme preset
237
243
  const darkTheme = getThemePreset('dark');
@@ -243,9 +249,9 @@ const isValid = validateCustomTheme(customTheme);
243
249
  const modifiedTheme = createCustomThemeFromPreset('dark', {
244
250
  colors: {
245
251
  background: {
246
- primary: '#000000'
247
- }
248
- }
252
+ primary: '#000000',
253
+ },
254
+ },
249
255
  });
250
256
  ```
251
257
 
@@ -256,6 +262,7 @@ The Finatic Portal supports broker filtering via URL parameters. You can restric
256
262
  #### Supported Brokers
257
263
 
258
264
  The following broker names are supported:
265
+
259
266
  - `alpaca` - Alpaca Markets
260
267
  - `robinhood` - Robinhood
261
268
  - `tasty_trade` - TastyTrade
@@ -266,18 +273,18 @@ The following broker names are supported:
266
273
  ```javascript
267
274
  // Show only specific brokers
268
275
  await finatic.openPortal({
269
- brokers: ['alpaca', 'robinhood']
276
+ brokers: ['alpaca', 'robinhood'],
270
277
  });
271
278
 
272
279
  // Show only one broker
273
280
  await finatic.openPortal({
274
- brokers: ['tasty_trade']
281
+ brokers: ['tasty_trade'],
275
282
  });
276
283
 
277
284
  // Combine with theme
278
285
  await finatic.openPortal({
279
286
  theme: { preset: 'dark' },
280
- brokers: ['alpaca', 'ninja_trader']
287
+ brokers: ['alpaca', 'ninja_trader'],
281
288
  });
282
289
  ```
283
290
 
@@ -288,18 +295,18 @@ If you pass an unsupported broker name, it will be logged as a warning to the co
288
295
  ```javascript
289
296
  // This will log a warning for 'unsupported_broker' but continue with 'alpaca'
290
297
  await finatic.openPortal({
291
- brokers: ['alpaca', 'unsupported_broker']
298
+ brokers: ['alpaca', 'unsupported_broker'],
292
299
  });
293
300
  ```
294
301
 
295
302
  #### Broker Filtering Utilities
296
303
 
297
304
  ```javascript
298
- import {
299
- convertBrokerNamesToIds,
300
- appendBrokerFilterToURL,
305
+ import {
306
+ convertBrokerNamesToIds,
307
+ appendBrokerFilterToURL,
301
308
  getSupportedBrokerNames,
302
- isBrokerSupported
309
+ isBrokerSupported,
303
310
  } from 'finatic-sdk';
304
311
 
305
312
  // Convert broker names to IDs
@@ -454,6 +461,7 @@ Disconnects a company from a broker connection.
454
461
  Returns: Promise<DisconnectCompanyResponse>
455
462
 
456
463
  The response includes:
464
+
457
465
  - `success` (boolean): Whether the operation was successful
458
466
  - `response_data.action` (string): Either 'company_access_removed' or 'connection_deleted'
459
467
  - `response_data.remaining_companies` (number, optional): Number of remaining companies if connection still exists
@@ -499,10 +507,6 @@ Returns true if the user is fully authenticated (has userId, access token, and r
499
507
 
500
508
  Returns the current user ID, or `null` if not authenticated.
501
509
 
502
- #### `revokeToken()`
503
-
504
- Revokes the current access token.
505
-
506
510
  ### Pagination Navigation
507
511
 
508
512
  The `PaginatedResult` object returned by paginated methods includes navigation methods:
@@ -538,13 +542,13 @@ Returns: Promise<PaginatedResult<T> | null>
538
542
  The SDK throws specific error types for different scenarios:
539
543
 
540
544
  ```typescript
541
- import {
542
- ApiError,
543
- SessionError,
544
- AuthenticationError,
545
+ import {
546
+ ApiError,
547
+ SessionError,
548
+ AuthenticationError,
545
549
  AuthorizationError,
546
550
  RateLimitError,
547
- CompanyAccessError
551
+ CompanyAccessError,
548
552
  } from '@finatic/client';
549
553
 
550
554
  try {
@@ -569,4 +573,4 @@ This SDK is designed for modern browsers and requires:
569
573
 
570
574
  ## License
571
575
 
572
- MIT
576
+ MIT