@finatic/client 0.9.3 → 0.9.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/index.mjs CHANGED
@@ -42,6 +42,13 @@ async function retryApiCall(fn, options = {}, config) {
42
42
  retryOnNetworkError: config?.retryOnNetworkError ?? options.retryOnNetworkError ?? true,
43
43
  onFailedAttempt: options.onFailedAttempt,
44
44
  };
45
+ const pRetryOptions = {
46
+ retries: opts.maxRetries,
47
+ minTimeout: opts.retryDelay,
48
+ maxTimeout: opts.retryMaxDelay,
49
+ factor: opts.retryMultiplier,
50
+ ...(opts.onFailedAttempt && { onFailedAttempt: opts.onFailedAttempt }),
51
+ };
45
52
  return await pRetry(async () => {
46
53
  try {
47
54
  return await fn();
@@ -60,13 +67,7 @@ async function retryApiCall(fn, options = {}, config) {
60
67
  // Re-throw to trigger retry
61
68
  throw error;
62
69
  }
63
- }, {
64
- retries: opts.maxRetries,
65
- minTimeout: opts.retryDelay,
66
- maxTimeout: opts.retryMaxDelay,
67
- factor: opts.retryMultiplier,
68
- onFailedAttempt: opts.onFailedAttempt,
69
- });
70
+ }, pRetryOptions);
70
71
  }
71
72
 
72
73
  /**
@@ -616,7 +617,11 @@ function coerceEnumValue(input, EnumObj, enumName) {
616
617
  // Direct match by value (case-insensitive)
617
618
  const valueMatch = values.find(v => v.toLowerCase() === normalized.toLowerCase());
618
619
  if (valueMatch) {
619
- return valueMatch;
620
+ // Find the enum key that has this value
621
+ const matchingKey = Object.keys(EnumObj).find(k => EnumObj[k] === valueMatch);
622
+ if (matchingKey) {
623
+ return EnumObj[matchingKey]; // Returns enum member (e.g., BrokerDataOrderStatusEnum.Filled)
624
+ }
620
625
  }
621
626
  // Match by key name (case-insensitive)
622
627
  const keyMatch = Object.keys(EnumObj).find(k => String(k).toLowerCase() === normalized.toLowerCase());
@@ -764,34 +769,6 @@ var BrokerDataOrderSideEnum;
764
769
  BrokerDataOrderSideEnum["Sell"] = "sell";
765
770
  })(BrokerDataOrderSideEnum || (BrokerDataOrderSideEnum = {}));
766
771
 
767
- /* tslint:disable */
768
- /* eslint-disable */
769
- /**
770
- * Finatic FastAPI Backend
771
- * FinaticAPI REST API
772
- *
773
- * The version of the OpenAPI document: 1.0.0
774
- *
775
- *
776
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
777
- * https://openapi-generator.tech
778
- * Do not edit the class manually.
779
- */
780
- var BrokerDataOrderStatusEnum;
781
- (function (BrokerDataOrderStatusEnum) {
782
- BrokerDataOrderStatusEnum["Submitted"] = "submitted";
783
- BrokerDataOrderStatusEnum["New"] = "new";
784
- BrokerDataOrderStatusEnum["PartiallyFilled"] = "partially_filled";
785
- BrokerDataOrderStatusEnum["Filled"] = "filled";
786
- BrokerDataOrderStatusEnum["PendingCancel"] = "pending_cancel";
787
- BrokerDataOrderStatusEnum["Cancelled"] = "cancelled";
788
- BrokerDataOrderStatusEnum["Rejected"] = "rejected";
789
- BrokerDataOrderStatusEnum["Expired"] = "expired";
790
- BrokerDataOrderStatusEnum["Created"] = "created";
791
- BrokerDataOrderStatusEnum["Received"] = "received";
792
- BrokerDataOrderStatusEnum["Queued"] = "queued";
793
- })(BrokerDataOrderStatusEnum || (BrokerDataOrderStatusEnum = {}));
794
-
795
772
  /* tslint:disable */
796
773
  /* eslint-disable */
797
774
  /**
@@ -1375,6 +1352,23 @@ class PaginatedData {
1375
1352
  toLocaleString() {
1376
1353
  return this.items.toLocaleString();
1377
1354
  }
1355
+ /**
1356
+ * Convert to JSON - returns just the items array for serialization.
1357
+ * This allows clean serialization without exposing internal methods.
1358
+ *
1359
+ * @returns The items array
1360
+ *
1361
+ * @example
1362
+ * ```typescript
1363
+ * const orders = await sdk.getOrders();
1364
+ * console.log(orders); // Shows full PaginatedData with methods
1365
+ * console.log(orders.toJSON()); // Shows just the items array
1366
+ * JSON.stringify(orders); // Automatically uses toJSON()
1367
+ * ```
1368
+ */
1369
+ toJSON() {
1370
+ return this.items;
1371
+ }
1378
1372
  /**
1379
1373
  * Get the next page of data.
1380
1374
  * @returns Promise<PaginatedData<T>> - The next page (not wrapped in FinaticResponse)
@@ -1857,7 +1851,7 @@ class BrokersWrapper {
1857
1851
  });
1858
1852
  try {
1859
1853
  const response = await retryApiCall(async () => {
1860
- const apiResponse = await this.api.disconnectCompanyFromBrokerApiV1BrokersDisconnectCompanyConnectionIdDelete({ connectionId: resolvedParams.connectionId }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
1854
+ const apiResponse = await this.api.disconnectCompanyFromBrokerApiV1BrokersDisconnectCompanyConnectionIdDelete({ connectionId: resolvedParams.connectionId ?? null }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
1861
1855
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
1862
1856
  }, {}, this.sdkConfig);
1863
1857
  // Unwrap axios response immediately - get FinaticResponse object
@@ -1961,9 +1955,9 @@ class BrokersWrapper {
1961
1955
  * Returns orders from connections the company has read access to.
1962
1956
  * @param params.brokerId {string} (optional) Filter by broker ID
1963
1957
  * @param params.connectionId {string} (optional) Filter by connection ID
1964
- * @param params.accountId {string} (optional) Filter by broker provided account ID
1958
+ * @param params.accountId {string} (optional) Filter by broker provided account ID or internal account UUID
1965
1959
  * @param params.symbol {string} (optional) Filter by symbol
1966
- * @param params.orderStatus {BrokerDataOrderStatusEnum} (optional) Filter by order status (e.g., 'filled', 'pending_new', 'cancelled')
1960
+ * @param params.orderStatus {string} (optional) Filter by order status (e.g., 'filled', 'pending_new', 'cancelled')
1967
1961
  * @param params.side {BrokerDataOrderSideEnum} (optional) Filter by order side (e.g., 'buy', 'sell')
1968
1962
  * @param params.assetType {BrokerDataAssetTypeEnum} (optional) Filter by asset type (e.g., 'stock', 'option', 'crypto', 'future')
1969
1963
  * @param params.limit {number} (optional) Maximum number of orders to return
@@ -2009,14 +2003,17 @@ class BrokersWrapper {
2009
2003
  async getOrders(params) {
2010
2004
  // Use params object (with default empty object)
2011
2005
  const resolvedParams = params || {};
2012
- if (params?.orderStatus !== undefined) {
2013
- params.orderStatus = coerceEnumValue(params.orderStatus, BrokerDataOrderStatusEnum, 'orderStatus');
2014
- }
2015
2006
  if (params?.side !== undefined) {
2016
- params.side = coerceEnumValue(params.side, BrokerDataOrderSideEnum, 'side');
2007
+ const coerced = coerceEnumValue(params.side, BrokerDataOrderSideEnum, 'side');
2008
+ if (coerced !== undefined) {
2009
+ params.side = coerced;
2010
+ }
2017
2011
  }
2018
2012
  if (params?.assetType !== undefined) {
2019
- params.assetType = coerceEnumValue(params.assetType, BrokerDataAssetTypeEnum, 'assetType');
2013
+ const coerced = coerceEnumValue(params.assetType, BrokerDataAssetTypeEnum, 'assetType');
2014
+ if (coerced !== undefined) {
2015
+ params.assetType = coerced;
2016
+ }
2020
2017
  } // Authentication check
2021
2018
  if (!this.sessionId || !this.companyId) {
2022
2019
  throw new Error('Session not initialized. Call startSession() first.');
@@ -2046,7 +2043,7 @@ class BrokersWrapper {
2046
2043
  });
2047
2044
  try {
2048
2045
  const response = await retryApiCall(async () => {
2049
- const apiResponse = await this.api.getOrdersApiV1BrokersDataOrdersGet({ brokerId: resolvedParams.brokerId, connectionId: resolvedParams.connectionId, accountId: resolvedParams.accountId, symbol: resolvedParams.symbol, orderStatus: resolvedParams.orderStatus, side: resolvedParams.side, assetType: resolvedParams.assetType, limit: resolvedParams.limit, offset: resolvedParams.offset, createdAfter: resolvedParams.createdAfter, createdBefore: resolvedParams.createdBefore, includeMetadata: resolvedParams.includeMetadata }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2046
+ const apiResponse = await this.api.getOrdersApiV1BrokersDataOrdersGet({ ...(resolvedParams.brokerId !== undefined ? { brokerId: resolvedParams.brokerId } : {}), ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.accountId !== undefined ? { accountId: resolvedParams.accountId } : {}), ...(resolvedParams.symbol !== undefined ? { symbol: resolvedParams.symbol } : {}), ...(resolvedParams.orderStatus !== undefined ? { orderStatus: resolvedParams.orderStatus } : {}), ...(resolvedParams.side !== undefined ? { side: resolvedParams.side } : {}), ...(resolvedParams.assetType !== undefined ? { assetType: resolvedParams.assetType } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}), ...(resolvedParams.createdAfter !== undefined ? { createdAfter: resolvedParams.createdAfter } : {}), ...(resolvedParams.createdBefore !== undefined ? { createdBefore: resolvedParams.createdBefore } : {}), ...(resolvedParams.includeMetadata !== undefined ? { includeMetadata: resolvedParams.includeMetadata } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2050
2047
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
2051
2048
  }, {}, this.sdkConfig);
2052
2049
  // Unwrap axios response immediately - get FinaticResponse object
@@ -2162,7 +2159,7 @@ class BrokersWrapper {
2162
2159
  * Returns positions from connections the company has read access to.
2163
2160
  * @param params.brokerId {string} (optional) Filter by broker ID
2164
2161
  * @param params.connectionId {string} (optional) Filter by connection ID
2165
- * @param params.accountId {string} (optional) Filter by broker provided account ID
2162
+ * @param params.accountId {string} (optional) Filter by broker provided account ID or internal account UUID
2166
2163
  * @param params.symbol {string} (optional) Filter by symbol
2167
2164
  * @param params.side {BrokerDataOrderSideEnum} (optional) Filter by position side (e.g., 'long', 'short')
2168
2165
  * @param params.assetType {BrokerDataAssetTypeEnum} (optional) Filter by asset type (e.g., 'stock', 'option', 'crypto', 'future')
@@ -2211,13 +2208,22 @@ class BrokersWrapper {
2211
2208
  // Use params object (with default empty object)
2212
2209
  const resolvedParams = params || {};
2213
2210
  if (params?.side !== undefined) {
2214
- params.side = coerceEnumValue(params.side, BrokerDataOrderSideEnum, 'side');
2211
+ const coerced = coerceEnumValue(params.side, BrokerDataOrderSideEnum, 'side');
2212
+ if (coerced !== undefined) {
2213
+ params.side = coerced;
2214
+ }
2215
2215
  }
2216
2216
  if (params?.assetType !== undefined) {
2217
- params.assetType = coerceEnumValue(params.assetType, BrokerDataAssetTypeEnum, 'assetType');
2217
+ const coerced = coerceEnumValue(params.assetType, BrokerDataAssetTypeEnum, 'assetType');
2218
+ if (coerced !== undefined) {
2219
+ params.assetType = coerced;
2220
+ }
2218
2221
  }
2219
2222
  if (params?.positionStatus !== undefined) {
2220
- params.positionStatus = coerceEnumValue(params.positionStatus, BrokerDataPositionStatusEnum, 'positionStatus');
2223
+ const coerced = coerceEnumValue(params.positionStatus, BrokerDataPositionStatusEnum, 'positionStatus');
2224
+ if (coerced !== undefined) {
2225
+ params.positionStatus = coerced;
2226
+ }
2221
2227
  } // Authentication check
2222
2228
  if (!this.sessionId || !this.companyId) {
2223
2229
  throw new Error('Session not initialized. Call startSession() first.');
@@ -2247,7 +2253,7 @@ class BrokersWrapper {
2247
2253
  });
2248
2254
  try {
2249
2255
  const response = await retryApiCall(async () => {
2250
- const apiResponse = await this.api.getPositionsApiV1BrokersDataPositionsGet({ brokerId: resolvedParams.brokerId, connectionId: resolvedParams.connectionId, accountId: resolvedParams.accountId, symbol: resolvedParams.symbol, side: resolvedParams.side, assetType: resolvedParams.assetType, positionStatus: resolvedParams.positionStatus, limit: resolvedParams.limit, offset: resolvedParams.offset, updatedAfter: resolvedParams.updatedAfter, updatedBefore: resolvedParams.updatedBefore, includeMetadata: resolvedParams.includeMetadata }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2256
+ const apiResponse = await this.api.getPositionsApiV1BrokersDataPositionsGet({ ...(resolvedParams.brokerId !== undefined ? { brokerId: resolvedParams.brokerId } : {}), ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.accountId !== undefined ? { accountId: resolvedParams.accountId } : {}), ...(resolvedParams.symbol !== undefined ? { symbol: resolvedParams.symbol } : {}), ...(resolvedParams.side !== undefined ? { side: resolvedParams.side } : {}), ...(resolvedParams.assetType !== undefined ? { assetType: resolvedParams.assetType } : {}), ...(resolvedParams.positionStatus !== undefined ? { positionStatus: resolvedParams.positionStatus } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}), ...(resolvedParams.updatedAfter !== undefined ? { updatedAfter: resolvedParams.updatedAfter } : {}), ...(resolvedParams.updatedBefore !== undefined ? { updatedBefore: resolvedParams.updatedBefore } : {}), ...(resolvedParams.includeMetadata !== undefined ? { includeMetadata: resolvedParams.includeMetadata } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2251
2257
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
2252
2258
  }, {}, this.sdkConfig);
2253
2259
  // Unwrap axios response immediately - get FinaticResponse object
@@ -2363,7 +2369,7 @@ class BrokersWrapper {
2363
2369
  * Returns balances from connections the company has read access to.
2364
2370
  * @param params.brokerId {string} (optional) Filter by broker ID
2365
2371
  * @param params.connectionId {string} (optional) Filter by connection ID
2366
- * @param params.accountId {string} (optional) Filter by broker provided account ID
2372
+ * @param params.accountId {string} (optional) Filter by broker provided account ID or internal account UUID
2367
2373
  * @param params.isEndOfDaySnapshot {boolean} (optional) Filter by end-of-day snapshot status (true/false)
2368
2374
  * @param params.limit {number} (optional) Maximum number of balances to return
2369
2375
  * @param params.offset {number} (optional) Number of balances to skip for pagination
@@ -2436,7 +2442,7 @@ class BrokersWrapper {
2436
2442
  });
2437
2443
  try {
2438
2444
  const response = await retryApiCall(async () => {
2439
- const apiResponse = await this.api.getBalancesApiV1BrokersDataBalancesGet({ brokerId: resolvedParams.brokerId, connectionId: resolvedParams.connectionId, accountId: resolvedParams.accountId, isEndOfDaySnapshot: resolvedParams.isEndOfDaySnapshot, limit: resolvedParams.limit, offset: resolvedParams.offset, balanceCreatedAfter: resolvedParams.balanceCreatedAfter, balanceCreatedBefore: resolvedParams.balanceCreatedBefore, includeMetadata: resolvedParams.includeMetadata }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2445
+ const apiResponse = await this.api.getBalancesApiV1BrokersDataBalancesGet({ ...(resolvedParams.brokerId !== undefined ? { brokerId: resolvedParams.brokerId } : {}), ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.accountId !== undefined ? { accountId: resolvedParams.accountId } : {}), ...(resolvedParams.isEndOfDaySnapshot !== undefined ? { isEndOfDaySnapshot: resolvedParams.isEndOfDaySnapshot } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}), ...(resolvedParams.balanceCreatedAfter !== undefined ? { balanceCreatedAfter: resolvedParams.balanceCreatedAfter } : {}), ...(resolvedParams.balanceCreatedBefore !== undefined ? { balanceCreatedBefore: resolvedParams.balanceCreatedBefore } : {}), ...(resolvedParams.includeMetadata !== undefined ? { includeMetadata: resolvedParams.includeMetadata } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2440
2446
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
2441
2447
  }, {}, this.sdkConfig);
2442
2448
  // Unwrap axios response immediately - get FinaticResponse object
@@ -2597,7 +2603,10 @@ class BrokersWrapper {
2597
2603
  // Use params object (with default empty object)
2598
2604
  const resolvedParams = params || {};
2599
2605
  if (params?.accountType !== undefined) {
2600
- params.accountType = coerceEnumValue(params.accountType, BrokerDataAccountTypeEnum, 'accountType');
2606
+ const coerced = coerceEnumValue(params.accountType, BrokerDataAccountTypeEnum, 'accountType');
2607
+ if (coerced !== undefined) {
2608
+ params.accountType = coerced;
2609
+ }
2601
2610
  } // Authentication check
2602
2611
  if (!this.sessionId || !this.companyId) {
2603
2612
  throw new Error('Session not initialized. Call startSession() first.');
@@ -2627,7 +2636,7 @@ class BrokersWrapper {
2627
2636
  });
2628
2637
  try {
2629
2638
  const response = await retryApiCall(async () => {
2630
- const apiResponse = await this.api.getAccountsApiV1BrokersDataAccountsGet({ brokerId: resolvedParams.brokerId, connectionId: resolvedParams.connectionId, accountType: resolvedParams.accountType, status: resolvedParams.status, currency: resolvedParams.currency, limit: resolvedParams.limit, offset: resolvedParams.offset, includeMetadata: resolvedParams.includeMetadata }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2639
+ const apiResponse = await this.api.getAccountsApiV1BrokersDataAccountsGet({ ...(resolvedParams.brokerId !== undefined ? { brokerId: resolvedParams.brokerId } : {}), ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.accountType !== undefined ? { accountType: resolvedParams.accountType } : {}), ...(resolvedParams.status !== undefined ? { status: resolvedParams.status } : {}), ...(resolvedParams.currency !== undefined ? { currency: resolvedParams.currency } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}), ...(resolvedParams.includeMetadata !== undefined ? { includeMetadata: resolvedParams.includeMetadata } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2631
2640
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
2632
2641
  }, {}, this.sdkConfig);
2633
2642
  // Unwrap axios response immediately - get FinaticResponse object
@@ -2816,7 +2825,7 @@ class BrokersWrapper {
2816
2825
  });
2817
2826
  try {
2818
2827
  const response = await retryApiCall(async () => {
2819
- const apiResponse = await this.api.getOrderFillsApiV1BrokersDataOrdersOrderIdFillsGet({ orderId: resolvedParams.orderId, connectionId: resolvedParams.connectionId, limit: resolvedParams.limit, offset: resolvedParams.offset, includeMetadata: resolvedParams.includeMetadata }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2828
+ const apiResponse = await this.api.getOrderFillsApiV1BrokersDataOrdersOrderIdFillsGet({ orderId: resolvedParams.orderId ?? null, ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}), ...(resolvedParams.includeMetadata !== undefined ? { includeMetadata: resolvedParams.includeMetadata } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
2820
2829
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
2821
2830
  }, {}, this.sdkConfig);
2822
2831
  // Unwrap axios response immediately - get FinaticResponse object
@@ -3005,7 +3014,7 @@ class BrokersWrapper {
3005
3014
  });
3006
3015
  try {
3007
3016
  const response = await retryApiCall(async () => {
3008
- const apiResponse = await this.api.getOrderEventsApiV1BrokersDataOrdersOrderIdEventsGet({ orderId: resolvedParams.orderId, connectionId: resolvedParams.connectionId, limit: resolvedParams.limit, offset: resolvedParams.offset, includeMetadata: resolvedParams.includeMetadata }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3017
+ const apiResponse = await this.api.getOrderEventsApiV1BrokersDataOrdersOrderIdEventsGet({ orderId: resolvedParams.orderId ?? null, ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}), ...(resolvedParams.includeMetadata !== undefined ? { includeMetadata: resolvedParams.includeMetadata } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3009
3018
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
3010
3019
  }, {}, this.sdkConfig);
3011
3020
  // Unwrap axios response immediately - get FinaticResponse object
@@ -3191,7 +3200,7 @@ class BrokersWrapper {
3191
3200
  });
3192
3201
  try {
3193
3202
  const response = await retryApiCall(async () => {
3194
- const apiResponse = await this.api.getOrderGroupsApiV1BrokersDataOrdersGroupsGet({ brokerId: resolvedParams.brokerId, connectionId: resolvedParams.connectionId, limit: resolvedParams.limit, offset: resolvedParams.offset, createdAfter: resolvedParams.createdAfter, createdBefore: resolvedParams.createdBefore, includeMetadata: resolvedParams.includeMetadata }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3203
+ const apiResponse = await this.api.getOrderGroupsApiV1BrokersDataOrdersGroupsGet({ ...(resolvedParams.brokerId !== undefined ? { brokerId: resolvedParams.brokerId } : {}), ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}), ...(resolvedParams.createdAfter !== undefined ? { createdAfter: resolvedParams.createdAfter } : {}), ...(resolvedParams.createdBefore !== undefined ? { createdBefore: resolvedParams.createdBefore } : {}), ...(resolvedParams.includeMetadata !== undefined ? { includeMetadata: resolvedParams.includeMetadata } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3195
3204
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
3196
3205
  }, {}, this.sdkConfig);
3197
3206
  // Unwrap axios response immediately - get FinaticResponse object
@@ -3378,7 +3387,7 @@ class BrokersWrapper {
3378
3387
  });
3379
3388
  try {
3380
3389
  const response = await retryApiCall(async () => {
3381
- const apiResponse = await this.api.getPositionLotsApiV1BrokersDataPositionsLotsGet({ brokerId: resolvedParams.brokerId, connectionId: resolvedParams.connectionId, accountId: resolvedParams.accountId, symbol: resolvedParams.symbol, positionId: resolvedParams.positionId, limit: resolvedParams.limit, offset: resolvedParams.offset }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3390
+ const apiResponse = await this.api.getPositionLotsApiV1BrokersDataPositionsLotsGet({ ...(resolvedParams.brokerId !== undefined ? { brokerId: resolvedParams.brokerId } : {}), ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.accountId !== undefined ? { accountId: resolvedParams.accountId } : {}), ...(resolvedParams.symbol !== undefined ? { symbol: resolvedParams.symbol } : {}), ...(resolvedParams.positionId !== undefined ? { positionId: resolvedParams.positionId } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3382
3391
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
3383
3392
  }, {}, this.sdkConfig);
3384
3393
  // Unwrap axios response immediately - get FinaticResponse object
@@ -3566,7 +3575,7 @@ class BrokersWrapper {
3566
3575
  });
3567
3576
  try {
3568
3577
  const response = await retryApiCall(async () => {
3569
- const apiResponse = await this.api.getPositionLotFillsApiV1BrokersDataPositionsLotsLotIdFillsGet({ lotId: resolvedParams.lotId, connectionId: resolvedParams.connectionId, limit: resolvedParams.limit, offset: resolvedParams.offset }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3578
+ const apiResponse = await this.api.getPositionLotFillsApiV1BrokersDataPositionsLotsLotIdFillsGet({ lotId: resolvedParams.lotId ?? null, ...(resolvedParams.connectionId !== undefined ? { connectionId: resolvedParams.connectionId } : {}), ...(resolvedParams.limit !== undefined ? { limit: resolvedParams.limit } : {}), ...(resolvedParams.offset !== undefined ? { offset: resolvedParams.offset } : {}) }, { headers: { 'x-request-id': requestId, ...(this.sessionId && this.companyId ? { 'x-session-id': this.sessionId, 'x-company-id': this.companyId, ...(this.csrfToken ? { 'x-csrf-token': this.csrfToken } : {}) } : {}) } });
3570
3579
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
3571
3580
  }, {}, this.sdkConfig);
3572
3581
  // Unwrap axios response immediately - get FinaticResponse object
@@ -3764,7 +3773,7 @@ class CompanyWrapper {
3764
3773
  });
3765
3774
  try {
3766
3775
  const response = await retryApiCall(async () => {
3767
- const apiResponse = await this.api.getCompanyApiV1CompanyCompanyIdGet({ companyId: resolvedParams.companyId }, { headers: { 'x-request-id': requestId } });
3776
+ const apiResponse = await this.api.getCompanyApiV1CompanyCompanyIdGet({ companyId: resolvedParams.companyId ?? null }, { headers: { 'x-request-id': requestId } });
3768
3777
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
3769
3778
  }, {}, this.sdkConfig);
3770
3779
  // Unwrap axios response immediately - get FinaticResponse object
@@ -3946,7 +3955,7 @@ class SessionWrapper {
3946
3955
  });
3947
3956
  try {
3948
3957
  const response = await retryApiCall(async () => {
3949
- const apiResponse = await this.api.initSessionApiV1SessionInitPost({ xApiKey: resolvedParams.xApiKey }, { headers: { 'x-request-id': requestId } });
3958
+ const apiResponse = await this.api.initSessionApiV1SessionInitPost({ xApiKey: resolvedParams.xApiKey ?? null }, { headers: { 'x-request-id': requestId } });
3950
3959
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
3951
3960
  }, {}, this.sdkConfig);
3952
3961
  // Unwrap axios response immediately - get FinaticResponse object
@@ -4090,7 +4099,7 @@ class SessionWrapper {
4090
4099
  });
4091
4100
  try {
4092
4101
  const response = await retryApiCall(async () => {
4093
- const apiResponse = await this.api.startSessionApiV1SessionStartPost({ oneTimeToken: resolvedParams.OneTimeToken, sessionStartRequest: resolvedParams.body }, { headers: { 'x-request-id': requestId } });
4102
+ const apiResponse = await this.api.startSessionApiV1SessionStartPost({ oneTimeToken: resolvedParams.OneTimeToken ?? null, sessionStartRequest: resolvedParams.body ?? null }, { headers: { 'x-request-id': requestId } });
4094
4103
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
4095
4104
  }, {}, this.sdkConfig);
4096
4105
  // Unwrap axios response immediately - get FinaticResponse object
@@ -4402,7 +4411,7 @@ class SessionWrapper {
4402
4411
  });
4403
4412
  try {
4404
4413
  const response = await retryApiCall(async () => {
4405
- const apiResponse = await this.api.getSessionUserApiV1SessionSessionIdUserGet({ sessionId: resolvedParams.sessionId, xSessionId: resolvedParams.sessionId }, { headers: { 'x-request-id': requestId } });
4414
+ const apiResponse = await this.api.getSessionUserApiV1SessionSessionIdUserGet({ sessionId: resolvedParams.sessionId ?? null, xSessionId: resolvedParams.sessionId ?? null }, { headers: { 'x-request-id': requestId } });
4406
4415
  return await applyResponseInterceptors(apiResponse, this.sdkConfig);
4407
4416
  }, {}, this.sdkConfig);
4408
4417
  // Unwrap axios response immediately - get FinaticResponse object
@@ -4516,7 +4525,7 @@ function validateParams(schema, params, config) {
4516
4525
  }
4517
4526
  catch (error) {
4518
4527
  if (error instanceof z.ZodError) {
4519
- const message = `Validation failed: ${error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}`;
4528
+ const message = `Validation failed: ${error.issues.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}`;
4520
4529
  if (config?.validationStrict) {
4521
4530
  throw new ValidationError(message);
4522
4531
  }
@@ -5476,7 +5485,7 @@ const BrokersApiAxiosParamCreator = function (configuration) {
5476
5485
  * @summary Get Balances
5477
5486
  * @param {string | null} [brokerId] Filter by broker ID
5478
5487
  * @param {string | null} [connectionId] Filter by connection ID
5479
- * @param {string | null} [accountId] Filter by broker provided account ID
5488
+ * @param {string | null} [accountId] Filter by broker provided account ID or internal account UUID
5480
5489
  * @param {boolean | null} [isEndOfDaySnapshot] Filter by end-of-day snapshot status (true/false)
5481
5490
  * @param {number} [limit] Maximum number of balances to return
5482
5491
  * @param {number} [offset] Number of balances to skip for pagination
@@ -5713,9 +5722,9 @@ const BrokersApiAxiosParamCreator = function (configuration) {
5713
5722
  * @summary Get Orders
5714
5723
  * @param {string | null} [brokerId] Filter by broker ID
5715
5724
  * @param {string | null} [connectionId] Filter by connection ID
5716
- * @param {string | null} [accountId] Filter by broker provided account ID
5725
+ * @param {string | null} [accountId] Filter by broker provided account ID or internal account UUID
5717
5726
  * @param {string | null} [symbol] Filter by symbol
5718
- * @param {BrokerDataOrderStatusEnum | null} [orderStatus] Filter by order status (e.g., \&#39;filled\&#39;, \&#39;pending_new\&#39;, \&#39;cancelled\&#39;)
5727
+ * @param {string | null} [orderStatus] Filter by order status (e.g., \&#39;filled\&#39;, \&#39;pending_new\&#39;, \&#39;cancelled\&#39;)
5719
5728
  * @param {BrokerDataOrderSideEnum | null} [side] Filter by order side (e.g., \&#39;buy\&#39;, \&#39;sell\&#39;)
5720
5729
  * @param {BrokerDataAssetTypeEnum | null} [assetType] Filter by asset type (e.g., \&#39;stock\&#39;, \&#39;option\&#39;, \&#39;crypto\&#39;, \&#39;future\&#39;)
5721
5730
  * @param {number} [limit] Maximum number of orders to return
@@ -5884,7 +5893,7 @@ const BrokersApiAxiosParamCreator = function (configuration) {
5884
5893
  * @summary Get Positions
5885
5894
  * @param {string | null} [brokerId] Filter by broker ID
5886
5895
  * @param {string | null} [connectionId] Filter by connection ID
5887
- * @param {string | null} [accountId] Filter by broker provided account ID
5896
+ * @param {string | null} [accountId] Filter by broker provided account ID or internal account UUID
5888
5897
  * @param {string | null} [symbol] Filter by symbol
5889
5898
  * @param {BrokerDataOrderSideEnum | null} [side] Filter by position side (e.g., \&#39;long\&#39;, \&#39;short\&#39;)
5890
5899
  * @param {BrokerDataAssetTypeEnum | null} [assetType] Filter by asset type (e.g., \&#39;stock\&#39;, \&#39;option\&#39;, \&#39;crypto\&#39;, \&#39;future\&#39;)
@@ -6027,7 +6036,7 @@ const BrokersApiFp = function (configuration) {
6027
6036
  * @summary Get Balances
6028
6037
  * @param {string | null} [brokerId] Filter by broker ID
6029
6038
  * @param {string | null} [connectionId] Filter by connection ID
6030
- * @param {string | null} [accountId] Filter by broker provided account ID
6039
+ * @param {string | null} [accountId] Filter by broker provided account ID or internal account UUID
6031
6040
  * @param {boolean | null} [isEndOfDaySnapshot] Filter by end-of-day snapshot status (true/false)
6032
6041
  * @param {number} [limit] Maximum number of balances to return
6033
6042
  * @param {number} [offset] Number of balances to skip for pagination
@@ -6113,9 +6122,9 @@ const BrokersApiFp = function (configuration) {
6113
6122
  * @summary Get Orders
6114
6123
  * @param {string | null} [brokerId] Filter by broker ID
6115
6124
  * @param {string | null} [connectionId] Filter by connection ID
6116
- * @param {string | null} [accountId] Filter by broker provided account ID
6125
+ * @param {string | null} [accountId] Filter by broker provided account ID or internal account UUID
6117
6126
  * @param {string | null} [symbol] Filter by symbol
6118
- * @param {BrokerDataOrderStatusEnum | null} [orderStatus] Filter by order status (e.g., \&#39;filled\&#39;, \&#39;pending_new\&#39;, \&#39;cancelled\&#39;)
6127
+ * @param {string | null} [orderStatus] Filter by order status (e.g., \&#39;filled\&#39;, \&#39;pending_new\&#39;, \&#39;cancelled\&#39;)
6119
6128
  * @param {BrokerDataOrderSideEnum | null} [side] Filter by order side (e.g., \&#39;buy\&#39;, \&#39;sell\&#39;)
6120
6129
  * @param {BrokerDataAssetTypeEnum | null} [assetType] Filter by asset type (e.g., \&#39;stock\&#39;, \&#39;option\&#39;, \&#39;crypto\&#39;, \&#39;future\&#39;)
6121
6130
  * @param {number} [limit] Maximum number of orders to return
@@ -6172,7 +6181,7 @@ const BrokersApiFp = function (configuration) {
6172
6181
  * @summary Get Positions
6173
6182
  * @param {string | null} [brokerId] Filter by broker ID
6174
6183
  * @param {string | null} [connectionId] Filter by connection ID
6175
- * @param {string | null} [accountId] Filter by broker provided account ID
6184
+ * @param {string | null} [accountId] Filter by broker provided account ID or internal account UUID
6176
6185
  * @param {string | null} [symbol] Filter by symbol
6177
6186
  * @param {BrokerDataOrderSideEnum | null} [side] Filter by position side (e.g., \&#39;long\&#39;, \&#39;short\&#39;)
6178
6187
  * @param {BrokerDataAssetTypeEnum | null} [assetType] Filter by asset type (e.g., \&#39;stock\&#39;, \&#39;option\&#39;, \&#39;crypto\&#39;, \&#39;future\&#39;)
@@ -6692,7 +6701,7 @@ let FinaticConnect$1 = class FinaticConnect extends EventEmitter {
6692
6701
  logger.debug?.('Creating new FinaticConnect instance');
6693
6702
  const connectOptions = {
6694
6703
  token,
6695
- sdkConfig: sdkConfig,
6704
+ ...(sdkConfig !== undefined && { sdkConfig }),
6696
6705
  };
6697
6706
  instance = new FinaticConnect(connectOptions);
6698
6707
  baseClass.instance = instance;
@@ -9074,5 +9083,5 @@ class FinaticConnect extends FinaticConnect$1 {
9074
9083
  // Marker to verify custom class is being used
9075
9084
  FinaticConnect.__CUSTOM_CLASS__ = true;
9076
9085
 
9077
- export { AccountStatus, ApiError, BrokerDataAccountTypeEnum, BrokerDataAssetTypeEnum, BrokerDataOrderSideEnum, BrokerDataOrderStatusEnum, BrokerDataPositionStatusEnum, BrokersApi, BrokersApiAxiosParamCreator, BrokersApiFactory, BrokersApiFp, BrokersWrapper, CompanyApi, CompanyApiAxiosParamCreator, CompanyApiFactory, CompanyApiFp, CompanyWrapper, Configuration, EventEmitter, FDXAccountStatus, FDXAccountType, FDXAssetType, FDXBalanceType, FDXOrderClass, FDXOrderEventType, FDXOrderGroupType, FDXOrderSide, FDXOrderStatus, FDXOrderType, FDXPositionSide, FDXPositionStatus, FDXSecurityIdType, FDXTimeInForce, FinaticConnect, FinaticError, PaginatedData, SessionApi, SessionApiAxiosParamCreator, SessionApiFactory, SessionApiFp, SessionStatus, SessionWrapper, ValidationError, addErrorInterceptor, addRequestInterceptor, addResponseInterceptor, appendBrokerFilterToURL, appendThemeToURL, applyErrorInterceptors, applyRequestInterceptors, applyResponseInterceptors, coerceEnumValue, convertToPlainObject, defaultConfig, generateCacheKey, generateRequestId, getCache, getConfig, getLogger, handleError, numberSchema, retryApiCall, stringSchema, unwrapAxiosResponse, validateParams };
9086
+ export { AccountStatus, ApiError, BrokerDataAccountTypeEnum, BrokerDataAssetTypeEnum, BrokerDataOrderSideEnum, BrokerDataPositionStatusEnum, BrokersApi, BrokersApiAxiosParamCreator, BrokersApiFactory, BrokersApiFp, BrokersWrapper, CompanyApi, CompanyApiAxiosParamCreator, CompanyApiFactory, CompanyApiFp, CompanyWrapper, Configuration, EventEmitter, FDXAccountStatus, FDXAccountType, FDXAssetType, FDXBalanceType, FDXOrderClass, FDXOrderEventType, FDXOrderGroupType, FDXOrderSide, FDXOrderStatus, FDXOrderType, FDXPositionSide, FDXPositionStatus, FDXSecurityIdType, FDXTimeInForce, FinaticConnect, FinaticError, PaginatedData, SessionApi, SessionApiAxiosParamCreator, SessionApiFactory, SessionApiFp, SessionStatus, SessionWrapper, ValidationError, addErrorInterceptor, addRequestInterceptor, addResponseInterceptor, appendBrokerFilterToURL, appendThemeToURL, applyErrorInterceptors, applyRequestInterceptors, applyResponseInterceptors, coerceEnumValue, convertToPlainObject, defaultConfig, generateCacheKey, generateRequestId, getCache, getConfig, getLogger, handleError, numberSchema, retryApiCall, stringSchema, unwrapAxiosResponse, validateParams };
9078
9087
  //# sourceMappingURL=index.mjs.map