@finatic/client 0.9.4 → 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.d.ts +37 -10
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { AxiosInstance, RawAxiosRequestConfig, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
3
|
+
import { RetryContext } from 'p-retry';
|
|
3
4
|
import * as z from 'zod';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -4565,7 +4566,7 @@ interface FinaticResponse$2<T> {
|
|
|
4565
4566
|
[key: string]: any;
|
|
4566
4567
|
}> | null;
|
|
4567
4568
|
}
|
|
4568
|
-
interface DisconnectCompanyFromBrokerParams
|
|
4569
|
+
interface DisconnectCompanyFromBrokerParams {
|
|
4569
4570
|
/** Connection ID */
|
|
4570
4571
|
connectionId: string;
|
|
4571
4572
|
}
|
|
@@ -4826,7 +4827,7 @@ declare class BrokersWrapper {
|
|
|
4826
4827
|
* }
|
|
4827
4828
|
* ```
|
|
4828
4829
|
*/
|
|
4829
|
-
disconnectCompanyFromBroker(params: DisconnectCompanyFromBrokerParams
|
|
4830
|
+
disconnectCompanyFromBroker(params: DisconnectCompanyFromBrokerParams): Promise<FinaticResponse$2<DisconnectActionResult>>;
|
|
4830
4831
|
/**
|
|
4831
4832
|
* Get Orders
|
|
4832
4833
|
*
|
|
@@ -5450,7 +5451,7 @@ interface FinaticResponse$1<T> {
|
|
|
5450
5451
|
[key: string]: any;
|
|
5451
5452
|
}> | null;
|
|
5452
5453
|
}
|
|
5453
|
-
interface GetCompanyParams
|
|
5454
|
+
interface GetCompanyParams {
|
|
5454
5455
|
/** Company ID */
|
|
5455
5456
|
companyId: string;
|
|
5456
5457
|
}
|
|
@@ -5496,7 +5497,7 @@ declare class CompanyWrapper {
|
|
|
5496
5497
|
* }
|
|
5497
5498
|
* ```
|
|
5498
5499
|
*/
|
|
5499
|
-
getCompany(params: GetCompanyParams
|
|
5500
|
+
getCompany(params: GetCompanyParams): Promise<FinaticResponse$1<CompanyResponse>>;
|
|
5500
5501
|
}
|
|
5501
5502
|
|
|
5502
5503
|
/**
|
|
@@ -5926,7 +5927,7 @@ interface RetryOptions {
|
|
|
5926
5927
|
retryMultiplier?: number;
|
|
5927
5928
|
retryOnStatus?: number[];
|
|
5928
5929
|
retryOnNetworkError?: boolean;
|
|
5929
|
-
onFailedAttempt?: (
|
|
5930
|
+
onFailedAttempt?: (context: RetryContext) => void | Promise<void>;
|
|
5930
5931
|
}
|
|
5931
5932
|
/**
|
|
5932
5933
|
* Retry an async function with exponential backoff using p-retry.
|
|
@@ -5950,17 +5951,17 @@ interface ParsedFinaticError {
|
|
|
5950
5951
|
code?: string;
|
|
5951
5952
|
}>;
|
|
5952
5953
|
}
|
|
5953
|
-
declare class FinaticError extends Error {
|
|
5954
|
+
declare class FinaticError$1 extends Error {
|
|
5954
5955
|
statusCode?: number | undefined;
|
|
5955
5956
|
requestId?: string | undefined;
|
|
5956
5957
|
originalError?: any | undefined;
|
|
5957
5958
|
finatic?: ParsedFinaticError | undefined;
|
|
5958
5959
|
constructor(message: string, statusCode?: number | undefined, requestId?: string | undefined, originalError?: any | undefined, finatic?: ParsedFinaticError | undefined);
|
|
5959
5960
|
}
|
|
5960
|
-
declare class ApiError extends FinaticError {
|
|
5961
|
+
declare class ApiError extends FinaticError$1 {
|
|
5961
5962
|
constructor(message: string, statusCode: number, requestId?: string, originalError?: any, finatic?: ParsedFinaticError);
|
|
5962
5963
|
}
|
|
5963
|
-
declare class ValidationError extends FinaticError {
|
|
5964
|
+
declare class ValidationError extends FinaticError$1 {
|
|
5964
5965
|
constructor(message: string, requestId?: string, originalError?: any, finatic?: ParsedFinaticError);
|
|
5965
5966
|
}
|
|
5966
5967
|
/**
|
|
@@ -7851,5 +7852,31 @@ declare class FinaticConnect extends FinaticConnect$1 {
|
|
|
7851
7852
|
static readonly __CUSTOM_CLASS__ = true;
|
|
7852
7853
|
}
|
|
7853
7854
|
|
|
7854
|
-
|
|
7855
|
-
|
|
7855
|
+
/**
|
|
7856
|
+
* Finatic FastAPI Backend
|
|
7857
|
+
* FinaticAPI REST API
|
|
7858
|
+
*
|
|
7859
|
+
* The version of the OpenAPI document: 1.0.0
|
|
7860
|
+
*
|
|
7861
|
+
*
|
|
7862
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
7863
|
+
* https://openapi-generator.tech
|
|
7864
|
+
* Do not edit the class manually.
|
|
7865
|
+
*/
|
|
7866
|
+
/**
|
|
7867
|
+
* Standard error response envelope for API non-2xx responses.
|
|
7868
|
+
*/
|
|
7869
|
+
interface FinaticError {
|
|
7870
|
+
/**
|
|
7871
|
+
* Error details including type, code, message, and trace_id. Shape: { type: FinaticErrorType, code: string, message: string, trace_id: string, details?: any, fields?: FinaticErrorField[] }
|
|
7872
|
+
*/
|
|
7873
|
+
'error': {
|
|
7874
|
+
[key: string]: any;
|
|
7875
|
+
};
|
|
7876
|
+
'meta'?: {
|
|
7877
|
+
[key: string]: any;
|
|
7878
|
+
} | null;
|
|
7879
|
+
}
|
|
7880
|
+
|
|
7881
|
+
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$1 as 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 };
|
|
7882
|
+
export type { Accounttype, ValidationError$1 as ApiValidationError, Assettype, Availablebalance, Availabletowithdraw, Averagebuyprice, Averagefillprice, Averagesellprice, Balancetype, BrokerInfo, BrokersApiDisconnectCompanyFromBrokerApiV1BrokersDisconnectCompanyConnectionIdDeleteRequest, BrokersApiGetAccountsApiV1BrokersDataAccountsGetRequest, BrokersApiGetBalancesApiV1BrokersDataBalancesGetRequest, BrokersApiGetOrderEventsApiV1BrokersDataOrdersOrderIdEventsGetRequest, BrokersApiGetOrderFillsApiV1BrokersDataOrdersOrderIdFillsGetRequest, BrokersApiGetOrderGroupsApiV1BrokersDataOrdersGroupsGetRequest, BrokersApiGetOrdersApiV1BrokersDataOrdersGetRequest, BrokersApiGetPositionLotFillsApiV1BrokersDataPositionsLotsLotIdFillsGetRequest, BrokersApiGetPositionLotsApiV1BrokersDataPositionsLotsGetRequest, BrokersApiGetPositionsApiV1BrokersDataPositionsGetRequest, BrokersApiInterface, Buyingpower, Cashbalance, Closedquantity, Closepriceavg, Commission, Commissionshare, CompanyApiGetCompanyApiV1CompanyCompanyIdGet0Request, CompanyApiGetCompanyApiV1CompanyCompanyIdGetRequest, CompanyApiInterface, CompanyResponse, ConfigurationParameters, Costbasis, Costbasis1, Costbasiswithcommission, Costbasiswithcommission1, Currentbalance, Currentprice, DisconnectActionResult, ErrorInterceptor, Eventtype, FDXBrokerAccount, FDXBrokerBalance, FDXBrokerOrder, FDXBrokerOrderEvent, FDXBrokerOrderFill, FDXBrokerOrderGroup, FDXBrokerPosition, FDXBrokerPositionLot, FDXBrokerPositionLotFill, FDXOrderGroupOrder, FDXOrderLeg, Filledquantity, Fillprice, Fillquantity, FinaticConnectOptions, FinaticError as FinaticErrorInterface, FinaticResponse$3 as FinaticResponse, FinaticResponseCompanyResponse, FinaticResponseDisconnectActionResult, FinaticResponseListBrokerInfo, FinaticResponseListFDXBrokerAccount, FinaticResponseListFDXBrokerBalance, FinaticResponseListFDXBrokerOrder, FinaticResponseListFDXBrokerOrderEvent, FinaticResponseListFDXBrokerOrderFill, FinaticResponseListFDXBrokerOrderGroup, FinaticResponseListFDXBrokerPosition, FinaticResponseListFDXBrokerPositionLot, FinaticResponseListFDXBrokerPositionLotFill, FinaticResponseListUserBrokerConnectionWithPermissions, FinaticResponsePortalUrlResponse, FinaticResponseSessionResponseData, FinaticResponseSessionUserResponse, FinaticResponseTokenResponseData, Futureunderlyingassettype, Grouptype, HTTPValidationError, Initialmargin, InterceptorChain, Limitprice, LogLevel, Logger, Maintenancemargin, Marketvalue, Netliquidationvalue, Openprice, Openquantity, Orderclass, Orderstatus, Ordertype, PaginationMeta, ParsedFinaticError, Pendingbalance, PortalUrlResponse, Previousstatus, Price, Quantity, Quantity1, Quantity2, Realizedprofitloss, Realizedprofitloss1, Realizedprofitlosspercent, Realizedprofitlosswithcommission, Realizedprofitlosswithcommission1, Remainingquantity, Remainingquantity1, RequestInterceptor, ResponseInterceptor, RetryOptions, SdkConfig, Securityidtype, SessionApiGetPortalUrlApiV1SessionPortalGetRequest, SessionApiGetSessionUserApiV1SessionSessionIdUserGetRequest, SessionApiInitSessionApiV1SessionInitPostRequest, SessionApiInterface, SessionApiStartSessionApiV1SessionStartPostRequest, SessionResponseData, SessionStartRequest, SessionUserResponse, Side, Side1, Side2, Side3, Status, Status1, Stopprice, Strikeprice, SuccessPayloadCompanyResponse, SuccessPayloadDisconnectActionResult, SuccessPayloadListBrokerInfo, SuccessPayloadListFDXBrokerAccount, SuccessPayloadListFDXBrokerBalance, SuccessPayloadListFDXBrokerOrder, SuccessPayloadListFDXBrokerOrderEvent, SuccessPayloadListFDXBrokerOrderFill, SuccessPayloadListFDXBrokerOrderGroup, SuccessPayloadListFDXBrokerPosition, SuccessPayloadListFDXBrokerPositionLot, SuccessPayloadListFDXBrokerPositionLotFill, SuccessPayloadListUserBrokerConnectionWithPermissions, SuccessPayloadPortalUrlResponse, SuccessPayloadSessionResponseData, SuccessPayloadSessionUserResponse, SuccessPayloadTokenResponseData, Timeinforce, TokenResponseData, Totalcashvalue, Totalrealizedpnl, Units, Unrealizedprofitloss, Unrealizedprofitlosspercent, UserBrokerConnectionWithPermissions, ValidationErrorLocInner };
|
package/dist/index.js
CHANGED
|
@@ -63,6 +63,13 @@ async function retryApiCall(fn, options = {}, config) {
|
|
|
63
63
|
retryOnNetworkError: config?.retryOnNetworkError ?? options.retryOnNetworkError ?? true,
|
|
64
64
|
onFailedAttempt: options.onFailedAttempt,
|
|
65
65
|
};
|
|
66
|
+
const pRetryOptions = {
|
|
67
|
+
retries: opts.maxRetries,
|
|
68
|
+
minTimeout: opts.retryDelay,
|
|
69
|
+
maxTimeout: opts.retryMaxDelay,
|
|
70
|
+
factor: opts.retryMultiplier,
|
|
71
|
+
...(opts.onFailedAttempt && { onFailedAttempt: opts.onFailedAttempt }),
|
|
72
|
+
};
|
|
66
73
|
return await pRetry(async () => {
|
|
67
74
|
try {
|
|
68
75
|
return await fn();
|
|
@@ -81,13 +88,7 @@ async function retryApiCall(fn, options = {}, config) {
|
|
|
81
88
|
// Re-throw to trigger retry
|
|
82
89
|
throw error;
|
|
83
90
|
}
|
|
84
|
-
},
|
|
85
|
-
retries: opts.maxRetries,
|
|
86
|
-
minTimeout: opts.retryDelay,
|
|
87
|
-
maxTimeout: opts.retryMaxDelay,
|
|
88
|
-
factor: opts.retryMultiplier,
|
|
89
|
-
onFailedAttempt: opts.onFailedAttempt,
|
|
90
|
-
});
|
|
91
|
+
}, pRetryOptions);
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
/**
|
|
@@ -4545,7 +4546,7 @@ function validateParams(schema, params, config) {
|
|
|
4545
4546
|
}
|
|
4546
4547
|
catch (error) {
|
|
4547
4548
|
if (error instanceof z__namespace.ZodError) {
|
|
4548
|
-
const message = `Validation failed: ${error.
|
|
4549
|
+
const message = `Validation failed: ${error.issues.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}`;
|
|
4549
4550
|
if (config?.validationStrict) {
|
|
4550
4551
|
throw new ValidationError(message);
|
|
4551
4552
|
}
|
|
@@ -6721,7 +6722,7 @@ let FinaticConnect$1 = class FinaticConnect extends EventEmitter {
|
|
|
6721
6722
|
logger.debug?.('Creating new FinaticConnect instance');
|
|
6722
6723
|
const connectOptions = {
|
|
6723
6724
|
token,
|
|
6724
|
-
sdkConfig
|
|
6725
|
+
...(sdkConfig !== undefined && { sdkConfig }),
|
|
6725
6726
|
};
|
|
6726
6727
|
instance = new FinaticConnect(connectOptions);
|
|
6727
6728
|
baseClass.instance = instance;
|