@brokerize/client 1.3.5 → 1.3.7
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/apiCtx.js +7 -3
- package/dist/authorizedApiContext.d.ts +1 -0
- package/dist/authorizedApiContext.js +6 -0
- package/dist/client.d.ts +129 -3
- package/dist/modelExports.d.ts +3 -0
- package/dist/swagger/apis/DefaultApi.d.ts +13 -1
- package/dist/swagger/apis/DefaultApi.js +44 -1
- package/dist/swagger/models/GetPortfolioCalendarResponse.d.ts +28 -0
- package/dist/swagger/models/GetPortfolioCalendarResponse.js +38 -0
- package/dist/swagger/models/PortfolioCalendarDateRange.d.ts +35 -0
- package/dist/swagger/models/PortfolioCalendarDateRange.js +41 -0
- package/dist/swagger/models/PortfolioCalendarItem.d.ts +42 -0
- package/dist/swagger/models/PortfolioCalendarItem.js +42 -0
- package/dist/swagger/models/PreparedTrade.d.ts +9 -2
- package/dist/swagger/models/index.d.ts +3 -0
- package/dist/swagger/models/index.js +3 -0
- package/dist/websocketClient.d.ts +8 -0
- package/dist/websocketClient.js +48 -5
- package/package.json +1 -1
package/dist/apiCtx.js
CHANGED
|
@@ -18,10 +18,14 @@ export function createAuth({ authCfg, cfg, options, tokenRefreshCallback, }) {
|
|
|
18
18
|
return {
|
|
19
19
|
async getToken() {
|
|
20
20
|
if (guestAuthCfg.tokens) {
|
|
21
|
+
let expiresIn = guestAuthCfg.tokens.response.expiresIn;
|
|
22
|
+
if (expiresIn == null) {
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.log("[brokerize client] expiresIn is unexpectedly nullish. assuming 300 seconds");
|
|
25
|
+
expiresIn = 300;
|
|
26
|
+
}
|
|
21
27
|
/* modern tokens */
|
|
22
|
-
const tokenExpiresAt = guestAuthCfg.tokens.updatedAt +
|
|
23
|
-
guestAuthCfg.tokens.response.expiresIn * 1000 -
|
|
24
|
-
10000;
|
|
28
|
+
const tokenExpiresAt = guestAuthCfg.tokens.updatedAt + expiresIn * 1000 - 10000;
|
|
25
29
|
const needsRefresh = Date.now() > tokenExpiresAt;
|
|
26
30
|
if (needsRefresh && guestAuthCfg.tokens.response.refreshToken) {
|
|
27
31
|
if (!cfg.fetch) {
|
|
@@ -58,6 +58,7 @@ export declare class AuthorizedApiContext {
|
|
|
58
58
|
getPortfolioPositions(portfolioId: string): Promise<openApiClient.GetPortfolioPositionsResponse>;
|
|
59
59
|
getPortfolioOrders(req: openApiClient.GetPortfolioOrdersRequest): Promise<openApiClient.GetPortfolioOrdersResponse>;
|
|
60
60
|
getPortfolioTrades(req: openApiClient.GetPortfolioTradesRequest): Promise<openApiClient.GetPortfolioTradesResponse>;
|
|
61
|
+
getPortfolioCalendar(req: openApiClient.GetPortfolioCalendarRequest): Promise<openApiClient.GetPortfolioCalendarResponse>;
|
|
61
62
|
getPortfolioTradeWarnings(req: openApiClient.GetPortfolioTradeWarningsRequest): Promise<openApiClient.TradeWarning[]>;
|
|
62
63
|
getPortfolioTradeStatistics(req: openApiClient.GetPortfolioTradeStatisticsRequest): Promise<openApiClient.GetPortfolioTradeStatisticsResponse>;
|
|
63
64
|
getAuthInfo(portfolioId: string): Promise<openApiClient.GetAuthInfoResponse>;
|
|
@@ -53,6 +53,9 @@ export class AuthorizedApiContext {
|
|
|
53
53
|
}
|
|
54
54
|
this._abortController = cfg.createAbortController();
|
|
55
55
|
this._wsClient = wsClient || this._initInternalWebSocketClient();
|
|
56
|
+
if (this._wsClient._setAuthorizedApiContext) {
|
|
57
|
+
this._wsClient._setAuthorizedApiContext(this);
|
|
58
|
+
}
|
|
56
59
|
this._cache = {};
|
|
57
60
|
}
|
|
58
61
|
createChildContext() {
|
|
@@ -185,6 +188,9 @@ export class AuthorizedApiContext {
|
|
|
185
188
|
async getPortfolioTrades(req) {
|
|
186
189
|
return this._defaultApi.getPortfolioTrades(req, await this._initRequestInit());
|
|
187
190
|
}
|
|
191
|
+
async getPortfolioCalendar(req) {
|
|
192
|
+
return this._defaultApi.getPortfolioCalendar(req, await this._initRequestInit());
|
|
193
|
+
}
|
|
188
194
|
async getPortfolioTradeWarnings(req) {
|
|
189
195
|
return this._defaultApi.getPortfolioTradeWarnings(req, await this._initRequestInit());
|
|
190
196
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1130,6 +1130,7 @@ export declare class AuthorizedApiContext {
|
|
|
1130
1130
|
getPortfolioPositions(portfolioId: string): Promise<openApiClient.GetPortfolioPositionsResponse>;
|
|
1131
1131
|
getPortfolioOrders(req: openApiClient.GetPortfolioOrdersRequest): Promise<openApiClient.GetPortfolioOrdersResponse>;
|
|
1132
1132
|
getPortfolioTrades(req: openApiClient.GetPortfolioTradesRequest): Promise<openApiClient.GetPortfolioTradesResponse>;
|
|
1133
|
+
getPortfolioCalendar(req: openApiClient.GetPortfolioCalendarRequest): Promise<openApiClient.GetPortfolioCalendarResponse>;
|
|
1133
1134
|
getPortfolioTradeWarnings(req: openApiClient.GetPortfolioTradeWarningsRequest): Promise<openApiClient.TradeWarning[]>;
|
|
1134
1135
|
getPortfolioTradeStatistics(req: openApiClient.GetPortfolioTradeStatisticsRequest): Promise<openApiClient.GetPortfolioTradeStatisticsResponse>;
|
|
1135
1136
|
getAuthInfo(portfolioId: string): Promise<openApiClient.GetAuthInfoResponse>;
|
|
@@ -4096,6 +4097,14 @@ declare class DefaultApi extends runtime.BaseAPI {
|
|
|
4096
4097
|
/**
|
|
4097
4098
|
*/
|
|
4098
4099
|
getOrder(requestParameters: GetOrderRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<GetOrderResponse>;
|
|
4100
|
+
/**
|
|
4101
|
+
* Retrieve \"by-day\" aggregated values for the selected date ranges.
|
|
4102
|
+
*/
|
|
4103
|
+
getPortfolioCalendarRaw(requestParameters: GetPortfolioCalendarRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<runtime.ApiResponse<GetPortfolioCalendarResponse>>;
|
|
4104
|
+
/**
|
|
4105
|
+
* Retrieve \"by-day\" aggregated values for the selected date ranges.
|
|
4106
|
+
*/
|
|
4107
|
+
getPortfolioCalendar(requestParameters: GetPortfolioCalendarRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<GetPortfolioCalendarResponse>;
|
|
4099
4108
|
/**
|
|
4100
4109
|
*/
|
|
4101
4110
|
getPortfolioOrdersRaw(requestParameters: GetPortfolioOrdersRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<runtime.ApiResponse<GetPortfolioOrdersResponse>>;
|
|
@@ -6787,6 +6796,33 @@ declare interface GetPagesConfigurationRequest {
|
|
|
6787
6796
|
clientName?: string;
|
|
6788
6797
|
}
|
|
6789
6798
|
|
|
6799
|
+
declare interface GetPortfolioCalendarRequest {
|
|
6800
|
+
portfolioId: string;
|
|
6801
|
+
dateRanges: string;
|
|
6802
|
+
}
|
|
6803
|
+
|
|
6804
|
+
/**
|
|
6805
|
+
*
|
|
6806
|
+
* @export
|
|
6807
|
+
* @interface GetPortfolioCalendarResponse
|
|
6808
|
+
*/
|
|
6809
|
+
declare interface GetPortfolioCalendarResponse {
|
|
6810
|
+
/**
|
|
6811
|
+
*
|
|
6812
|
+
* @type {Array<PortfolioCalendarDateRange>}
|
|
6813
|
+
* @memberof GetPortfolioCalendarResponse
|
|
6814
|
+
*/
|
|
6815
|
+
data: Array<PortfolioCalendarDateRange>;
|
|
6816
|
+
}
|
|
6817
|
+
|
|
6818
|
+
declare function GetPortfolioCalendarResponseFromJSON(json: any): GetPortfolioCalendarResponse;
|
|
6819
|
+
|
|
6820
|
+
declare function GetPortfolioCalendarResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetPortfolioCalendarResponse;
|
|
6821
|
+
|
|
6822
|
+
declare function GetPortfolioCalendarResponseToJSON(value?: GetPortfolioCalendarResponse | null): any;
|
|
6823
|
+
|
|
6824
|
+
declare function GetPortfolioCalendarResponseToJSONRecursive(value?: GetPortfolioCalendarResponse | null, ignoreParent?: boolean): any;
|
|
6825
|
+
|
|
6790
6826
|
declare interface GetPortfolioOrdersRequest {
|
|
6791
6827
|
portfolioId: string;
|
|
6792
6828
|
take?: number;
|
|
@@ -7902,7 +7938,10 @@ declare namespace Models {
|
|
|
7902
7938
|
GetPortfolioTradesResponse,
|
|
7903
7939
|
GetPortfolioTradeStatisticsResponse,
|
|
7904
7940
|
TradeStatisticsItem,
|
|
7905
|
-
TradeStatistics
|
|
7941
|
+
TradeStatistics,
|
|
7942
|
+
GetPortfolioCalendarResponse,
|
|
7943
|
+
PortfolioCalendarDateRange,
|
|
7944
|
+
PortfolioCalendarItem
|
|
7906
7945
|
}
|
|
7907
7946
|
}
|
|
7908
7947
|
export { Models }
|
|
@@ -8088,6 +8127,7 @@ declare namespace openApiClient {
|
|
|
8088
8127
|
GetDecoupledOperationStatusRequest,
|
|
8089
8128
|
GetDecoupledOperationStatusLegacyRequest,
|
|
8090
8129
|
GetOrderRequest,
|
|
8130
|
+
GetPortfolioCalendarRequest,
|
|
8091
8131
|
GetPortfolioOrdersRequest,
|
|
8092
8132
|
GetPortfolioPositionsRequest,
|
|
8093
8133
|
GetPortfolioQuotesRequest,
|
|
@@ -8825,6 +8865,11 @@ declare namespace openApiClient {
|
|
|
8825
8865
|
GetOrderResponseToJSONRecursive,
|
|
8826
8866
|
GetOrderResponseToJSON,
|
|
8827
8867
|
GetOrderResponse,
|
|
8868
|
+
GetPortfolioCalendarResponseFromJSON,
|
|
8869
|
+
GetPortfolioCalendarResponseFromJSONTyped,
|
|
8870
|
+
GetPortfolioCalendarResponseToJSONRecursive,
|
|
8871
|
+
GetPortfolioCalendarResponseToJSON,
|
|
8872
|
+
GetPortfolioCalendarResponse,
|
|
8828
8873
|
GetPortfolioOrdersResponseFromJSON,
|
|
8829
8874
|
GetPortfolioOrdersResponseFromJSONTyped,
|
|
8830
8875
|
GetPortfolioOrdersResponseToJSONRecursive,
|
|
@@ -9020,6 +9065,16 @@ declare namespace openApiClient {
|
|
|
9020
9065
|
PortfolioToJSONRecursive,
|
|
9021
9066
|
PortfolioToJSON,
|
|
9022
9067
|
Portfolio,
|
|
9068
|
+
PortfolioCalendarDateRangeFromJSON,
|
|
9069
|
+
PortfolioCalendarDateRangeFromJSONTyped,
|
|
9070
|
+
PortfolioCalendarDateRangeToJSONRecursive,
|
|
9071
|
+
PortfolioCalendarDateRangeToJSON,
|
|
9072
|
+
PortfolioCalendarDateRange,
|
|
9073
|
+
PortfolioCalendarItemFromJSON,
|
|
9074
|
+
PortfolioCalendarItemFromJSONTyped,
|
|
9075
|
+
PortfolioCalendarItemToJSONRecursive,
|
|
9076
|
+
PortfolioCalendarItemToJSON,
|
|
9077
|
+
PortfolioCalendarItem,
|
|
9023
9078
|
PortfolioQuotesFromJSON,
|
|
9024
9079
|
PortfolioQuotesFromJSONTyped,
|
|
9025
9080
|
PortfolioQuotesToJSONRecursive,
|
|
@@ -10642,6 +10697,70 @@ declare interface Portfolio {
|
|
|
10642
10697
|
syncInfo: PortfolioSyncInfo;
|
|
10643
10698
|
}
|
|
10644
10699
|
|
|
10700
|
+
/**
|
|
10701
|
+
*
|
|
10702
|
+
* @export
|
|
10703
|
+
* @interface PortfolioCalendarDateRange
|
|
10704
|
+
*/
|
|
10705
|
+
declare interface PortfolioCalendarDateRange {
|
|
10706
|
+
/**
|
|
10707
|
+
*
|
|
10708
|
+
* @type {TradeStatisticsDateRange}
|
|
10709
|
+
* @memberof PortfolioCalendarDateRange
|
|
10710
|
+
*/
|
|
10711
|
+
dateRange: TradeStatisticsDateRange;
|
|
10712
|
+
/**
|
|
10713
|
+
*
|
|
10714
|
+
* @type {Array<PortfolioCalendarItem>}
|
|
10715
|
+
* @memberof PortfolioCalendarDateRange
|
|
10716
|
+
*/
|
|
10717
|
+
items: Array<PortfolioCalendarItem>;
|
|
10718
|
+
}
|
|
10719
|
+
|
|
10720
|
+
declare function PortfolioCalendarDateRangeFromJSON(json: any): PortfolioCalendarDateRange;
|
|
10721
|
+
|
|
10722
|
+
declare function PortfolioCalendarDateRangeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioCalendarDateRange;
|
|
10723
|
+
|
|
10724
|
+
declare function PortfolioCalendarDateRangeToJSON(value?: PortfolioCalendarDateRange | null): any;
|
|
10725
|
+
|
|
10726
|
+
declare function PortfolioCalendarDateRangeToJSONRecursive(value?: PortfolioCalendarDateRange | null, ignoreParent?: boolean): any;
|
|
10727
|
+
|
|
10728
|
+
/**
|
|
10729
|
+
*
|
|
10730
|
+
* @export
|
|
10731
|
+
* @interface PortfolioCalendarItem
|
|
10732
|
+
*/
|
|
10733
|
+
declare interface PortfolioCalendarItem {
|
|
10734
|
+
/**
|
|
10735
|
+
* A date string, formatted as YYYY-MM-DD.
|
|
10736
|
+
* Note that the date means that day in the timezone `Europe/Berlin`, so it aggregates orders for that
|
|
10737
|
+
* timezone.
|
|
10738
|
+
* @type {string}
|
|
10739
|
+
* @memberof PortfolioCalendarItem
|
|
10740
|
+
*/
|
|
10741
|
+
date: string;
|
|
10742
|
+
/**
|
|
10743
|
+
* How many order executions have been aggregated.
|
|
10744
|
+
* @type {number}
|
|
10745
|
+
* @memberof PortfolioCalendarItem
|
|
10746
|
+
*/
|
|
10747
|
+
executionCount: number;
|
|
10748
|
+
/**
|
|
10749
|
+
*
|
|
10750
|
+
* @type {Amount}
|
|
10751
|
+
* @memberof PortfolioCalendarItem
|
|
10752
|
+
*/
|
|
10753
|
+
transactionVolume: Amount;
|
|
10754
|
+
}
|
|
10755
|
+
|
|
10756
|
+
declare function PortfolioCalendarItemFromJSON(json: any): PortfolioCalendarItem;
|
|
10757
|
+
|
|
10758
|
+
declare function PortfolioCalendarItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioCalendarItem;
|
|
10759
|
+
|
|
10760
|
+
declare function PortfolioCalendarItemToJSON(value?: PortfolioCalendarItem | null): any;
|
|
10761
|
+
|
|
10762
|
+
declare function PortfolioCalendarItemToJSONRecursive(value?: PortfolioCalendarItem | null, ignoreParent?: boolean): any;
|
|
10763
|
+
|
|
10645
10764
|
declare function PortfolioFromJSON(json: any): Portfolio;
|
|
10646
10765
|
|
|
10647
10766
|
declare function PortfolioFromJSONTyped(json: any, ignoreDiscriminator: boolean): Portfolio;
|
|
@@ -11457,8 +11576,15 @@ declare interface PreparedTrade {
|
|
|
11457
11576
|
*/
|
|
11458
11577
|
costEstimationIsNotAvailable: boolean;
|
|
11459
11578
|
/**
|
|
11460
|
-
*
|
|
11461
|
-
*
|
|
11579
|
+
* Indicates that this cost estimation does not include summary fields
|
|
11580
|
+
* (e.g. `entryCosts`, `totalCosts`, etc.) and therefore cannot be rendered
|
|
11581
|
+
* inline within the order form. Instead, only a detailed representation is available.
|
|
11582
|
+
*
|
|
11583
|
+
* Historically, this implied that only `detailedTable` would be provided
|
|
11584
|
+
* (hence the flag name). However, in modern usage, `costDetailsLink` may be present instead.
|
|
11585
|
+
*
|
|
11586
|
+
* In that case, clients can render an action such as "Show detailed costs," which then loads the cost
|
|
11587
|
+
* estimartion and either displays the `detailedTable` or navigates to the `costDetailsLink` URL.
|
|
11462
11588
|
* @type {boolean}
|
|
11463
11589
|
* @memberof PreparedTrade
|
|
11464
11590
|
*/
|
package/dist/modelExports.d.ts
CHANGED
|
@@ -158,3 +158,6 @@ export { GetPortfolioTradesResponse } from "./swagger/models/GetPortfolioTradesR
|
|
|
158
158
|
export { GetPortfolioTradeStatisticsResponse } from "./swagger/models/GetPortfolioTradeStatisticsResponse";
|
|
159
159
|
export { TradeStatisticsItem } from "./swagger/models/TradeStatisticsItem";
|
|
160
160
|
export { TradeStatistics } from "./swagger/models/TradeStatistics";
|
|
161
|
+
export { GetPortfolioCalendarResponse } from "./swagger/models/GetPortfolioCalendarResponse";
|
|
162
|
+
export { PortfolioCalendarDateRange } from "./swagger/models/PortfolioCalendarDateRange";
|
|
163
|
+
export { PortfolioCalendarItem } from "./swagger/models/PortfolioCalendarItem";
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Do not edit the class manually.
|
|
10
10
|
*/
|
|
11
11
|
import * as runtime from "../runtime";
|
|
12
|
-
import { Challenge, CreateGuestUserResponse, CreateTanChallengeParams, DecoupledOperationStatus, EnableSessionTanParams, EnableSessionTanResponse, EndSessionTanResponse, GetAuthInfoResponse, GetOrderResponse, GetPortfolioOrdersResponse, GetPortfolioPositionsResponse, GetPortfolioQuotesResponse, GetPortfolioTradeStatisticsResponse, GetPortfolioTradesResponse, GetUserResponse, OkResponseBody, PortfoliosResponse, RenamePortfolioRequest, SessionResponse, TokenResponse, TradeWarning } from "../models";
|
|
12
|
+
import { Challenge, CreateGuestUserResponse, CreateTanChallengeParams, DecoupledOperationStatus, EnableSessionTanParams, EnableSessionTanResponse, EndSessionTanResponse, GetAuthInfoResponse, GetOrderResponse, GetPortfolioCalendarResponse, GetPortfolioOrdersResponse, GetPortfolioPositionsResponse, GetPortfolioQuotesResponse, GetPortfolioTradeStatisticsResponse, GetPortfolioTradesResponse, GetUserResponse, OkResponseBody, PortfoliosResponse, RenamePortfolioRequest, SessionResponse, TokenResponse, TradeWarning } from "../models";
|
|
13
13
|
export interface CancelDecoupledOperationRequest {
|
|
14
14
|
decoupledOperationId: string;
|
|
15
15
|
}
|
|
@@ -44,6 +44,10 @@ export interface GetDecoupledOperationStatusLegacyRequest {
|
|
|
44
44
|
export interface GetOrderRequest {
|
|
45
45
|
id: string;
|
|
46
46
|
}
|
|
47
|
+
export interface GetPortfolioCalendarRequest {
|
|
48
|
+
portfolioId: string;
|
|
49
|
+
dateRanges: string;
|
|
50
|
+
}
|
|
47
51
|
export interface GetPortfolioOrdersRequest {
|
|
48
52
|
portfolioId: string;
|
|
49
53
|
take?: number;
|
|
@@ -180,6 +184,14 @@ export declare class DefaultApi extends runtime.BaseAPI {
|
|
|
180
184
|
/**
|
|
181
185
|
*/
|
|
182
186
|
getOrder(requestParameters: GetOrderRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<GetOrderResponse>;
|
|
187
|
+
/**
|
|
188
|
+
* Retrieve \"by-day\" aggregated values for the selected date ranges.
|
|
189
|
+
*/
|
|
190
|
+
getPortfolioCalendarRaw(requestParameters: GetPortfolioCalendarRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<runtime.ApiResponse<GetPortfolioCalendarResponse>>;
|
|
191
|
+
/**
|
|
192
|
+
* Retrieve \"by-day\" aggregated values for the selected date ranges.
|
|
193
|
+
*/
|
|
194
|
+
getPortfolioCalendar(requestParameters: GetPortfolioCalendarRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<GetPortfolioCalendarResponse>;
|
|
183
195
|
/**
|
|
184
196
|
*/
|
|
185
197
|
getPortfolioOrdersRaw(requestParameters: GetPortfolioOrdersRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<runtime.ApiResponse<GetPortfolioOrdersResponse>>;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Do not edit the class manually.
|
|
12
12
|
*/
|
|
13
13
|
import * as runtime from "../runtime";
|
|
14
|
-
import { ChallengeFromJSON, CreateGuestUserResponseFromJSON, CreateTanChallengeParamsToJSON, DecoupledOperationStatusFromJSON, EnableSessionTanParamsToJSON, EnableSessionTanResponseFromJSON, EndSessionTanResponseFromJSON, GetAuthInfoResponseFromJSON, GetOrderResponseFromJSON, GetPortfolioOrdersResponseFromJSON, GetPortfolioPositionsResponseFromJSON, GetPortfolioQuotesResponseFromJSON, GetPortfolioTradeStatisticsResponseFromJSON, GetPortfolioTradesResponseFromJSON, GetUserResponseFromJSON, OkResponseBodyFromJSON, PortfoliosResponseFromJSON, RenamePortfolioRequestToJSON, SessionResponseFromJSON, TokenResponseFromJSON, TradeWarningFromJSON, } from "../models";
|
|
14
|
+
import { ChallengeFromJSON, CreateGuestUserResponseFromJSON, CreateTanChallengeParamsToJSON, DecoupledOperationStatusFromJSON, EnableSessionTanParamsToJSON, EnableSessionTanResponseFromJSON, EndSessionTanResponseFromJSON, GetAuthInfoResponseFromJSON, GetOrderResponseFromJSON, GetPortfolioCalendarResponseFromJSON, GetPortfolioOrdersResponseFromJSON, GetPortfolioPositionsResponseFromJSON, GetPortfolioQuotesResponseFromJSON, GetPortfolioTradeStatisticsResponseFromJSON, GetPortfolioTradesResponseFromJSON, GetUserResponseFromJSON, OkResponseBodyFromJSON, PortfoliosResponseFromJSON, RenamePortfolioRequestToJSON, SessionResponseFromJSON, TokenResponseFromJSON, TradeWarningFromJSON, } from "../models";
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
@@ -443,6 +443,49 @@ export class DefaultApi extends runtime.BaseAPI {
|
|
|
443
443
|
const response = await this.getOrderRaw(requestParameters, initOverrides);
|
|
444
444
|
return await response.value();
|
|
445
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Retrieve \"by-day\" aggregated values for the selected date ranges.
|
|
448
|
+
*/
|
|
449
|
+
async getPortfolioCalendarRaw(requestParameters, initOverrides) {
|
|
450
|
+
if (requestParameters.portfolioId === null ||
|
|
451
|
+
requestParameters.portfolioId === undefined) {
|
|
452
|
+
throw new runtime.RequiredError("portfolioId", "Required parameter requestParameters.portfolioId was null or undefined when calling getPortfolioCalendar.");
|
|
453
|
+
}
|
|
454
|
+
if (requestParameters.dateRanges === null ||
|
|
455
|
+
requestParameters.dateRanges === undefined) {
|
|
456
|
+
throw new runtime.RequiredError("dateRanges", "Required parameter requestParameters.dateRanges was null or undefined when calling getPortfolioCalendar.");
|
|
457
|
+
}
|
|
458
|
+
const queryParameters = {};
|
|
459
|
+
if (requestParameters.dateRanges !== undefined) {
|
|
460
|
+
queryParameters["dateRanges"] = requestParameters.dateRanges;
|
|
461
|
+
}
|
|
462
|
+
const headerParameters = {};
|
|
463
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
464
|
+
headerParameters["x-brkrz-client-id"] =
|
|
465
|
+
this.configuration.apiKey("x-brkrz-client-id"); // clientId authentication
|
|
466
|
+
}
|
|
467
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
468
|
+
const token = this.configuration.accessToken;
|
|
469
|
+
const tokenString = await token("idToken", []);
|
|
470
|
+
if (tokenString) {
|
|
471
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const response = await this.request({
|
|
475
|
+
path: `/portfolios/{portfolioId}/calendar`.replace(`{${"portfolioId"}}`, encodeURIComponent(String(requestParameters.portfolioId))),
|
|
476
|
+
method: "GET",
|
|
477
|
+
headers: headerParameters,
|
|
478
|
+
query: queryParameters,
|
|
479
|
+
}, initOverrides);
|
|
480
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => GetPortfolioCalendarResponseFromJSON(jsonValue));
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Retrieve \"by-day\" aggregated values for the selected date ranges.
|
|
484
|
+
*/
|
|
485
|
+
async getPortfolioCalendar(requestParameters, initOverrides) {
|
|
486
|
+
const response = await this.getPortfolioCalendarRaw(requestParameters, initOverrides);
|
|
487
|
+
return await response.value();
|
|
488
|
+
}
|
|
446
489
|
/**
|
|
447
490
|
*/
|
|
448
491
|
async getPortfolioOrdersRaw(requestParameters, initOverrides) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* brokerize
|
|
3
|
+
* The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
8
|
+
* https://openapi-generator.tech
|
|
9
|
+
* Do not edit the class manually.
|
|
10
|
+
*/
|
|
11
|
+
import { PortfolioCalendarDateRange } from "./PortfolioCalendarDateRange";
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @export
|
|
15
|
+
* @interface GetPortfolioCalendarResponse
|
|
16
|
+
*/
|
|
17
|
+
export interface GetPortfolioCalendarResponse {
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {Array<PortfolioCalendarDateRange>}
|
|
21
|
+
* @memberof GetPortfolioCalendarResponse
|
|
22
|
+
*/
|
|
23
|
+
data: Array<PortfolioCalendarDateRange>;
|
|
24
|
+
}
|
|
25
|
+
export declare function GetPortfolioCalendarResponseFromJSON(json: any): GetPortfolioCalendarResponse;
|
|
26
|
+
export declare function GetPortfolioCalendarResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetPortfolioCalendarResponse;
|
|
27
|
+
export declare function GetPortfolioCalendarResponseToJSONRecursive(value?: GetPortfolioCalendarResponse | null, ignoreParent?: boolean): any;
|
|
28
|
+
export declare function GetPortfolioCalendarResponseToJSON(value?: GetPortfolioCalendarResponse | null): any;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* brokerize
|
|
5
|
+
* The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
10
|
+
* https://openapi-generator.tech
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
import { PortfolioCalendarDateRangeFromJSON, PortfolioCalendarDateRangeToJSON, } from "./PortfolioCalendarDateRange";
|
|
14
|
+
export function GetPortfolioCalendarResponseFromJSON(json) {
|
|
15
|
+
return GetPortfolioCalendarResponseFromJSONTyped(json, false);
|
|
16
|
+
}
|
|
17
|
+
export function GetPortfolioCalendarResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
18
|
+
if (json === undefined || json === null) {
|
|
19
|
+
return json;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
data: json["data"].map(PortfolioCalendarDateRangeFromJSON),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function GetPortfolioCalendarResponseToJSONRecursive(value, ignoreParent = false) {
|
|
26
|
+
if (value === undefined) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (value === null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
data: value.data.map(PortfolioCalendarDateRangeToJSON),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function GetPortfolioCalendarResponseToJSON(value) {
|
|
37
|
+
return GetPortfolioCalendarResponseToJSONRecursive(value, false);
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* brokerize
|
|
3
|
+
* The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
8
|
+
* https://openapi-generator.tech
|
|
9
|
+
* Do not edit the class manually.
|
|
10
|
+
*/
|
|
11
|
+
import { PortfolioCalendarItem } from "./PortfolioCalendarItem";
|
|
12
|
+
import { TradeStatisticsDateRange } from "./TradeStatisticsDateRange";
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @interface PortfolioCalendarDateRange
|
|
17
|
+
*/
|
|
18
|
+
export interface PortfolioCalendarDateRange {
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {TradeStatisticsDateRange}
|
|
22
|
+
* @memberof PortfolioCalendarDateRange
|
|
23
|
+
*/
|
|
24
|
+
dateRange: TradeStatisticsDateRange;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {Array<PortfolioCalendarItem>}
|
|
28
|
+
* @memberof PortfolioCalendarDateRange
|
|
29
|
+
*/
|
|
30
|
+
items: Array<PortfolioCalendarItem>;
|
|
31
|
+
}
|
|
32
|
+
export declare function PortfolioCalendarDateRangeFromJSON(json: any): PortfolioCalendarDateRange;
|
|
33
|
+
export declare function PortfolioCalendarDateRangeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioCalendarDateRange;
|
|
34
|
+
export declare function PortfolioCalendarDateRangeToJSONRecursive(value?: PortfolioCalendarDateRange | null, ignoreParent?: boolean): any;
|
|
35
|
+
export declare function PortfolioCalendarDateRangeToJSON(value?: PortfolioCalendarDateRange | null): any;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* brokerize
|
|
5
|
+
* The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
10
|
+
* https://openapi-generator.tech
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
import { PortfolioCalendarItemFromJSON, PortfolioCalendarItemToJSON, } from "./PortfolioCalendarItem";
|
|
14
|
+
import { TradeStatisticsDateRangeFromJSON, TradeStatisticsDateRangeToJSON, } from "./TradeStatisticsDateRange";
|
|
15
|
+
export function PortfolioCalendarDateRangeFromJSON(json) {
|
|
16
|
+
return PortfolioCalendarDateRangeFromJSONTyped(json, false);
|
|
17
|
+
}
|
|
18
|
+
export function PortfolioCalendarDateRangeFromJSONTyped(json, ignoreDiscriminator) {
|
|
19
|
+
if (json === undefined || json === null) {
|
|
20
|
+
return json;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
dateRange: TradeStatisticsDateRangeFromJSON(json["dateRange"]),
|
|
24
|
+
items: json["items"].map(PortfolioCalendarItemFromJSON),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function PortfolioCalendarDateRangeToJSONRecursive(value, ignoreParent = false) {
|
|
28
|
+
if (value === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (value === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
dateRange: TradeStatisticsDateRangeToJSON(value.dateRange),
|
|
36
|
+
items: value.items.map(PortfolioCalendarItemToJSON),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function PortfolioCalendarDateRangeToJSON(value) {
|
|
40
|
+
return PortfolioCalendarDateRangeToJSONRecursive(value, false);
|
|
41
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* brokerize
|
|
3
|
+
* The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
8
|
+
* https://openapi-generator.tech
|
|
9
|
+
* Do not edit the class manually.
|
|
10
|
+
*/
|
|
11
|
+
import { Amount } from "./Amount";
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @export
|
|
15
|
+
* @interface PortfolioCalendarItem
|
|
16
|
+
*/
|
|
17
|
+
export interface PortfolioCalendarItem {
|
|
18
|
+
/**
|
|
19
|
+
* A date string, formatted as YYYY-MM-DD.
|
|
20
|
+
* Note that the date means that day in the timezone `Europe/Berlin`, so it aggregates orders for that
|
|
21
|
+
* timezone.
|
|
22
|
+
* @type {string}
|
|
23
|
+
* @memberof PortfolioCalendarItem
|
|
24
|
+
*/
|
|
25
|
+
date: string;
|
|
26
|
+
/**
|
|
27
|
+
* How many order executions have been aggregated.
|
|
28
|
+
* @type {number}
|
|
29
|
+
* @memberof PortfolioCalendarItem
|
|
30
|
+
*/
|
|
31
|
+
executionCount: number;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @type {Amount}
|
|
35
|
+
* @memberof PortfolioCalendarItem
|
|
36
|
+
*/
|
|
37
|
+
transactionVolume: Amount;
|
|
38
|
+
}
|
|
39
|
+
export declare function PortfolioCalendarItemFromJSON(json: any): PortfolioCalendarItem;
|
|
40
|
+
export declare function PortfolioCalendarItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioCalendarItem;
|
|
41
|
+
export declare function PortfolioCalendarItemToJSONRecursive(value?: PortfolioCalendarItem | null, ignoreParent?: boolean): any;
|
|
42
|
+
export declare function PortfolioCalendarItemToJSON(value?: PortfolioCalendarItem | null): any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* brokerize
|
|
5
|
+
* The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
10
|
+
* https://openapi-generator.tech
|
|
11
|
+
* Do not edit the class manually.
|
|
12
|
+
*/
|
|
13
|
+
import { AmountFromJSON, AmountToJSON, } from "./Amount";
|
|
14
|
+
export function PortfolioCalendarItemFromJSON(json) {
|
|
15
|
+
return PortfolioCalendarItemFromJSONTyped(json, false);
|
|
16
|
+
}
|
|
17
|
+
export function PortfolioCalendarItemFromJSONTyped(json, ignoreDiscriminator) {
|
|
18
|
+
if (json === undefined || json === null) {
|
|
19
|
+
return json;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
date: json["date"],
|
|
23
|
+
executionCount: json["executionCount"],
|
|
24
|
+
transactionVolume: AmountFromJSON(json["transactionVolume"]),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function PortfolioCalendarItemToJSONRecursive(value, ignoreParent = false) {
|
|
28
|
+
if (value === undefined) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (value === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
date: value.date,
|
|
36
|
+
executionCount: value.executionCount,
|
|
37
|
+
transactionVolume: AmountToJSON(value.transactionVolume),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function PortfolioCalendarItemToJSON(value) {
|
|
41
|
+
return PortfolioCalendarItemToJSONRecursive(value, false);
|
|
42
|
+
}
|
|
@@ -48,8 +48,15 @@ export interface PreparedTrade {
|
|
|
48
48
|
*/
|
|
49
49
|
costEstimationIsNotAvailable: boolean;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* Indicates that this cost estimation does not include summary fields
|
|
52
|
+
* (e.g. `entryCosts`, `totalCosts`, etc.) and therefore cannot be rendered
|
|
53
|
+
* inline within the order form. Instead, only a detailed representation is available.
|
|
54
|
+
*
|
|
55
|
+
* Historically, this implied that only `detailedTable` would be provided
|
|
56
|
+
* (hence the flag name). However, in modern usage, `costDetailsLink` may be present instead.
|
|
57
|
+
*
|
|
58
|
+
* In that case, clients can render an action such as "Show detailed costs," which then loads the cost
|
|
59
|
+
* estimartion and either displays the `detailedTable` or navigates to the `costDetailsLink` URL.
|
|
53
60
|
* @type {boolean}
|
|
54
61
|
* @memberof PreparedTrade
|
|
55
62
|
*/
|
|
@@ -133,6 +133,7 @@ export * from "./GetAuthInfoResponse";
|
|
|
133
133
|
export * from "./GetBrokersResponse";
|
|
134
134
|
export * from "./GetCostEstimationParams";
|
|
135
135
|
export * from "./GetOrderResponse";
|
|
136
|
+
export * from "./GetPortfolioCalendarResponse";
|
|
136
137
|
export * from "./GetPortfolioOrdersResponse";
|
|
137
138
|
export * from "./GetPortfolioPositionsResponse";
|
|
138
139
|
export * from "./GetPortfolioQuotesResponse";
|
|
@@ -172,6 +173,8 @@ export * from "./OrderValidityTypeByOrderModel";
|
|
|
172
173
|
export * from "./PageConfig";
|
|
173
174
|
export * from "./PagesConfigurationResponse";
|
|
174
175
|
export * from "./Portfolio";
|
|
176
|
+
export * from "./PortfolioCalendarDateRange";
|
|
177
|
+
export * from "./PortfolioCalendarItem";
|
|
175
178
|
export * from "./PortfolioQuotes";
|
|
176
179
|
export * from "./PortfolioSyncInfo";
|
|
177
180
|
export * from "./PortfolioSyncInfoComplete";
|
|
@@ -135,6 +135,7 @@ export * from "./GetAuthInfoResponse";
|
|
|
135
135
|
export * from "./GetBrokersResponse";
|
|
136
136
|
export * from "./GetCostEstimationParams";
|
|
137
137
|
export * from "./GetOrderResponse";
|
|
138
|
+
export * from "./GetPortfolioCalendarResponse";
|
|
138
139
|
export * from "./GetPortfolioOrdersResponse";
|
|
139
140
|
export * from "./GetPortfolioPositionsResponse";
|
|
140
141
|
export * from "./GetPortfolioQuotesResponse";
|
|
@@ -174,6 +175,8 @@ export * from "./OrderValidityTypeByOrderModel";
|
|
|
174
175
|
export * from "./PageConfig";
|
|
175
176
|
export * from "./PagesConfigurationResponse";
|
|
176
177
|
export * from "./Portfolio";
|
|
178
|
+
export * from "./PortfolioCalendarDateRange";
|
|
179
|
+
export * from "./PortfolioCalendarItem";
|
|
177
180
|
export * from "./PortfolioQuotes";
|
|
178
181
|
export * from "./PortfolioSyncInfo";
|
|
179
182
|
export * from "./PortfolioSyncInfoComplete";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Auth } from "./apiCtx";
|
|
2
|
+
import { AuthorizedApiContext } from "./authorizedApiContext";
|
|
2
3
|
import { WebSocket } from "./dependencyDefinitions/webSocket";
|
|
3
4
|
import type { SubscribeDecoupledOperation, SubscribeInvalidateDetails } from "./websocketTypes";
|
|
4
5
|
export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketClient {
|
|
@@ -16,6 +17,7 @@ export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketC
|
|
|
16
17
|
private _fatalError;
|
|
17
18
|
private _lastNonFatalError;
|
|
18
19
|
private _errorCount;
|
|
20
|
+
private _apiCtx;
|
|
19
21
|
constructor(websocketUrl: string, auth: Auth, createWebSocket: (url: string) => WebSocket);
|
|
20
22
|
private _updateReconnectInterval;
|
|
21
23
|
/**
|
|
@@ -27,7 +29,13 @@ export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketC
|
|
|
27
29
|
subscribeInvalidate(subscribe: SubscribeInvalidateDetails, callback: Callback): Subscription;
|
|
28
30
|
subscribeDecoupledOperation(subscribe: Pick<SubscribeDecoupledOperation, "sessionId" | "decoupledOperationId">, callback: Callback): Subscription;
|
|
29
31
|
private _startSubscription;
|
|
32
|
+
private _fillInMessagesAfterConnectionInterruption;
|
|
30
33
|
private _endSubscription;
|
|
34
|
+
/**
|
|
35
|
+
* Internal method for setting a related AuthorizedApiContext. This is used to retrieve
|
|
36
|
+
* decoupled operation status on interrupted connections.
|
|
37
|
+
*/
|
|
38
|
+
_setAuthorizedApiContext(ctx: AuthorizedApiContext): void;
|
|
31
39
|
_startOrStopDisconnectTimeout(): void;
|
|
32
40
|
private _sendWs;
|
|
33
41
|
private _connect;
|
package/dist/websocketClient.js
CHANGED
|
@@ -8,6 +8,7 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
8
8
|
this._fatalError = null;
|
|
9
9
|
this._lastNonFatalError = null;
|
|
10
10
|
this._errorCount = 0;
|
|
11
|
+
this._apiCtx = null;
|
|
11
12
|
this._url = websocketUrl;
|
|
12
13
|
this._id = 0;
|
|
13
14
|
this._socket = null;
|
|
@@ -26,7 +27,6 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
26
27
|
this._reconnectIntvl = setInterval(() => {
|
|
27
28
|
if (!this._socket && this._shouldConnect()) {
|
|
28
29
|
if (this._errorCount > 0) {
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
30
|
console.warn(LOG_PREFIX +
|
|
31
31
|
"reconnecting. current error count is " +
|
|
32
32
|
this._errorCount +
|
|
@@ -76,6 +76,7 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
76
76
|
this._map[key] = {
|
|
77
77
|
callbacks: [wrappedCb],
|
|
78
78
|
idOnSocket: null,
|
|
79
|
+
interrupted: false,
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
else {
|
|
@@ -121,11 +122,47 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
121
122
|
const cmd = JSON.parse(key);
|
|
122
123
|
cmd.subscriptionId = this._id;
|
|
123
124
|
this._sendWs(cmd, true);
|
|
125
|
+
if (this._map[key].interrupted) {
|
|
126
|
+
this._map[key].interrupted = false;
|
|
127
|
+
this._fillInMessagesAfterConnectionInterruption(cmd, this._map[key].callbacks);
|
|
128
|
+
}
|
|
124
129
|
}
|
|
125
130
|
else if (!this._socket) {
|
|
126
131
|
this._connect();
|
|
127
132
|
}
|
|
128
133
|
}
|
|
134
|
+
_fillInMessagesAfterConnectionInterruption(cmd, callbacks) {
|
|
135
|
+
if (cmd.type == "invalidate") {
|
|
136
|
+
const assumedInvalidate = {
|
|
137
|
+
cmd: "invalidate",
|
|
138
|
+
subscriptionId: cmd.subscriptionId,
|
|
139
|
+
}; // minimal invalidate
|
|
140
|
+
console.log(LOG_PREFIX +
|
|
141
|
+
"connection was interrupted. filling in assumed invalidates that may have happened while socket was not available.");
|
|
142
|
+
callbacks.forEach((cb) => cb(null, assumedInvalidate));
|
|
143
|
+
}
|
|
144
|
+
else if (cmd.type == "decoupledOperationStatus") {
|
|
145
|
+
if (this._apiCtx) {
|
|
146
|
+
this._apiCtx
|
|
147
|
+
.getDecoupledOperationStatus({
|
|
148
|
+
decoupledOperationId: cmd.decoupledOperationId,
|
|
149
|
+
})
|
|
150
|
+
.then((status) => {
|
|
151
|
+
const invMsg = {
|
|
152
|
+
cmd: "updateDecoupledOperationStatus",
|
|
153
|
+
status: status,
|
|
154
|
+
subscriptionId: cmd.subscriptionId,
|
|
155
|
+
};
|
|
156
|
+
console.log(LOG_PREFIX +
|
|
157
|
+
"sending virtual decoupled operation status updates to subscribers due to connection interruption.");
|
|
158
|
+
callbacks.forEach((cb) => cb(null, invMsg));
|
|
159
|
+
}, (err) => {
|
|
160
|
+
console.log(err, LOG_PREFIX +
|
|
161
|
+
"could not retrieve status of decoupledOperation. ignoring it.");
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
129
166
|
_endSubscription(key) {
|
|
130
167
|
if (this._map[key].idOnSocket != null) {
|
|
131
168
|
this._sendWs({
|
|
@@ -135,6 +172,13 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
135
172
|
this._map[key].idOnSocket = null;
|
|
136
173
|
}
|
|
137
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Internal method for setting a related AuthorizedApiContext. This is used to retrieve
|
|
177
|
+
* decoupled operation status on interrupted connections.
|
|
178
|
+
*/
|
|
179
|
+
_setAuthorizedApiContext(ctx) {
|
|
180
|
+
this._apiCtx = ctx;
|
|
181
|
+
}
|
|
138
182
|
_startOrStopDisconnectTimeout() {
|
|
139
183
|
if (this._shouldConnect()) {
|
|
140
184
|
if (this._disconnectTimeout) {
|
|
@@ -163,7 +207,6 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
163
207
|
(_b = this._socket) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify(data));
|
|
164
208
|
}
|
|
165
209
|
else {
|
|
166
|
-
// eslint-disable-next-line no-console
|
|
167
210
|
console.log(LOG_PREFIX + "socket not ready, not sending message.", this._lastNonFatalError, this._fatalError);
|
|
168
211
|
}
|
|
169
212
|
}
|
|
@@ -237,15 +280,16 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
237
280
|
_authCb();
|
|
238
281
|
}
|
|
239
282
|
}, (err) => {
|
|
240
|
-
// eslint-disable-next-line no-console
|
|
241
283
|
console.error(LOG_PREFIX + " connection failed", err);
|
|
242
284
|
});
|
|
243
285
|
};
|
|
244
286
|
this._socket.onclose = () => {
|
|
245
|
-
|
|
287
|
+
// mark all subscriptions interrupted so they can issue synthetic messages on reconnect
|
|
246
288
|
for (const k in this._map) {
|
|
289
|
+
this._map[k].interrupted = true;
|
|
247
290
|
this._endSubscription(k);
|
|
248
291
|
}
|
|
292
|
+
this._socket = null;
|
|
249
293
|
};
|
|
250
294
|
this._pingIntvl && clearInterval(this._pingIntvl);
|
|
251
295
|
this._pingIntvl = setInterval(() => {
|
|
@@ -292,7 +336,6 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
292
336
|
cb(this._fatalError, null);
|
|
293
337
|
}
|
|
294
338
|
catch (err) {
|
|
295
|
-
// eslint-disable-next-line no-console
|
|
296
339
|
console.warn(LOG_PREFIX + "error in callback", err);
|
|
297
340
|
}
|
|
298
341
|
});
|