@brokerize/client 1.11.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +45 -0
  2. package/dist/apiCtx.d.ts +10 -2
  3. package/dist/apiCtx.js +4 -4
  4. package/dist/authorizedApiContext.d.ts +20 -0
  5. package/dist/authorizedApiContext.js +47 -5
  6. package/dist/cjs/apiCtx.d.ts +10 -2
  7. package/dist/cjs/apiCtx.js +4 -4
  8. package/dist/cjs/authorizedApiContext.d.ts +20 -0
  9. package/dist/cjs/authorizedApiContext.js +46 -4
  10. package/dist/cjs/errors.d.ts +60 -0
  11. package/dist/cjs/errors.js +48 -1
  12. package/dist/cjs/index.d.ts +4 -4
  13. package/dist/cjs/index.js +4 -1
  14. package/dist/cjs/modelExports.d.ts +2 -0
  15. package/dist/cjs/modelExports.js +3 -1
  16. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfo.d.ts +60 -0
  17. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfo.js +51 -0
  18. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfoStatus.d.ts +22 -0
  19. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfoStatus.js +35 -0
  20. package/dist/cjs/swagger/models/PortfolioSyncInfoComplete.d.ts +7 -0
  21. package/dist/cjs/swagger/models/PortfolioSyncInfoComplete.js +6 -0
  22. package/dist/cjs/swagger/models/PortfolioSyncInfoCompleteSpecifics.d.ts +7 -0
  23. package/dist/cjs/swagger/models/PortfolioSyncInfoCompleteSpecifics.js +5 -0
  24. package/dist/cjs/swagger/models/PortfolioSyncInfoIncomplete.d.ts +7 -0
  25. package/dist/cjs/swagger/models/PortfolioSyncInfoIncomplete.js +6 -0
  26. package/dist/cjs/swagger/models/PortfolioSyncInfoIncompleteSpecifics.d.ts +7 -0
  27. package/dist/cjs/swagger/models/PortfolioSyncInfoIncompleteSpecifics.js +5 -0
  28. package/dist/cjs/swagger/models/TradeWarningReason.d.ts +1 -0
  29. package/dist/cjs/swagger/models/TradeWarningReason.js +1 -0
  30. package/dist/cjs/swagger/models/index.d.ts +2 -0
  31. package/dist/cjs/swagger/models/index.js +2 -0
  32. package/dist/cjs/websocketClient.d.ts +118 -3
  33. package/dist/cjs/websocketClient.js +426 -74
  34. package/dist/cjs/websocketTypes.d.ts +10 -0
  35. package/dist/client.d.ts +262 -46
  36. package/dist/errors.d.ts +60 -0
  37. package/dist/errors.js +44 -0
  38. package/dist/index.d.ts +4 -4
  39. package/dist/index.js +2 -2
  40. package/dist/modelExports.d.ts +2 -0
  41. package/dist/modelExports.js +1 -0
  42. package/dist/swagger/models/PortfolioOrderDetailsSyncInfo.d.ts +60 -0
  43. package/dist/swagger/models/PortfolioOrderDetailsSyncInfo.js +45 -0
  44. package/dist/swagger/models/PortfolioOrderDetailsSyncInfoStatus.d.ts +22 -0
  45. package/dist/swagger/models/PortfolioOrderDetailsSyncInfoStatus.js +29 -0
  46. package/dist/swagger/models/PortfolioSyncInfoComplete.d.ts +7 -0
  47. package/dist/swagger/models/PortfolioSyncInfoComplete.js +6 -0
  48. package/dist/swagger/models/PortfolioSyncInfoCompleteSpecifics.d.ts +7 -0
  49. package/dist/swagger/models/PortfolioSyncInfoCompleteSpecifics.js +5 -0
  50. package/dist/swagger/models/PortfolioSyncInfoIncomplete.d.ts +7 -0
  51. package/dist/swagger/models/PortfolioSyncInfoIncomplete.js +6 -0
  52. package/dist/swagger/models/PortfolioSyncInfoIncompleteSpecifics.d.ts +7 -0
  53. package/dist/swagger/models/PortfolioSyncInfoIncompleteSpecifics.js +5 -0
  54. package/dist/swagger/models/TradeWarningReason.d.ts +1 -0
  55. package/dist/swagger/models/TradeWarningReason.js +1 -0
  56. package/dist/swagger/models/index.d.ts +2 -0
  57. package/dist/swagger/models/index.js +2 -0
  58. package/dist/tsdoc-metadata.json +1 -1
  59. package/dist/websocketClient.d.ts +118 -3
  60. package/dist/websocketClient.js +426 -74
  61. package/dist/websocketTypes.d.ts +10 -0
  62. package/package.json +10 -9
@@ -0,0 +1,60 @@
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 { PortfolioOrderDetailsSyncInfoStatus } from "./PortfolioOrderDetailsSyncInfoStatus";
12
+ /**
13
+ * Whether the *details* of the synced orders are already known — the executions, and with them the
14
+ * execution prices and the fees.
15
+ *
16
+ * This is a second, independent axis next to the sync status: a portfolio counts as `COMPLETE` as
17
+ * soon as every order has been loaded, but some brokers (flatex) report an order's executions only
18
+ * when that single order is fetched individually, which happens during the sync for recent orders
19
+ * only. The remaining ones are fetched in the background afterwards.
20
+ *
21
+ * It matters because every evaluation that reconstructs the past — the trade list, the trade
22
+ * statistics, the value history — is built from executions alone. An order whose details are still
23
+ * missing contributes nothing at all to them.
24
+ *
25
+ * Not reported on every endpoint; absent means "no statement", not "complete".
26
+ * @export
27
+ * @interface PortfolioOrderDetailsSyncInfo
28
+ */
29
+ export interface PortfolioOrderDetailsSyncInfo {
30
+ /**
31
+ * Set while `status` is `PENDING`, absent once it is `COMPLETE`.
32
+ *
33
+ * Evaluations are complete for everything that happened after this point in time; before it,
34
+ * executions may still be missing. It is the timestamp of the newest order whose details are
35
+ * still outstanding — and it is that order, not the oldest one, because the reconstruction is
36
+ * anchored at the current holdings and works backwards: a gap only affects what lies before it.
37
+ *
38
+ * The boundary moves backwards as the background fetch works through the backlog, newest first.
39
+ * It is not a progress bar for the *amount* that is still missing: details fetched out of order
40
+ * (a user opening an old order in the app fetches it right away) close a gap behind the
41
+ * boundary and leave it where it is.
42
+ *
43
+ * Caveat: for an order whose details are missing, the broker has usually only told us when it
44
+ * was *created*, not when it executed — an order that executed considerably later than it was
45
+ * created can therefore sit slightly after this boundary.
46
+ * @type {Date}
47
+ * @memberof PortfolioOrderDetailsSyncInfo
48
+ */
49
+ completeFrom?: Date;
50
+ /**
51
+ *
52
+ * @type {PortfolioOrderDetailsSyncInfoStatus}
53
+ * @memberof PortfolioOrderDetailsSyncInfo
54
+ */
55
+ status: PortfolioOrderDetailsSyncInfoStatus;
56
+ }
57
+ export declare function PortfolioOrderDetailsSyncInfoFromJSON(json: any): PortfolioOrderDetailsSyncInfo;
58
+ export declare function PortfolioOrderDetailsSyncInfoFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioOrderDetailsSyncInfo;
59
+ export declare function PortfolioOrderDetailsSyncInfoToJSONRecursive(value?: PortfolioOrderDetailsSyncInfo | null, ignoreParent?: boolean): any;
60
+ export declare function PortfolioOrderDetailsSyncInfoToJSON(value?: PortfolioOrderDetailsSyncInfo | null): any;
@@ -0,0 +1,45 @@
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 { exists } from "../runtime.js";
14
+ import { PortfolioOrderDetailsSyncInfoStatusFromJSON, PortfolioOrderDetailsSyncInfoStatusToJSON, } from "./PortfolioOrderDetailsSyncInfoStatus.js";
15
+ export function PortfolioOrderDetailsSyncInfoFromJSON(json) {
16
+ return PortfolioOrderDetailsSyncInfoFromJSONTyped(json, false);
17
+ }
18
+ export function PortfolioOrderDetailsSyncInfoFromJSONTyped(json, ignoreDiscriminator) {
19
+ if (json === undefined || json === null) {
20
+ return json;
21
+ }
22
+ return {
23
+ completeFrom: !exists(json, "completeFrom")
24
+ ? undefined
25
+ : new Date(json["completeFrom"]),
26
+ status: PortfolioOrderDetailsSyncInfoStatusFromJSON(json["status"]),
27
+ };
28
+ }
29
+ export function PortfolioOrderDetailsSyncInfoToJSONRecursive(value, ignoreParent = false) {
30
+ if (value === undefined) {
31
+ return undefined;
32
+ }
33
+ if (value === null) {
34
+ return null;
35
+ }
36
+ return {
37
+ completeFrom: value.completeFrom === undefined
38
+ ? undefined
39
+ : value.completeFrom.toISOString(),
40
+ status: PortfolioOrderDetailsSyncInfoStatusToJSON(value.status),
41
+ };
42
+ }
43
+ export function PortfolioOrderDetailsSyncInfoToJSON(value) {
44
+ return PortfolioOrderDetailsSyncInfoToJSONRecursive(value, false);
45
+ }
@@ -0,0 +1,22 @@
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
+ /**
12
+ *
13
+ * @export
14
+ */
15
+ export declare const PortfolioOrderDetailsSyncInfoStatus: {
16
+ readonly Complete: "COMPLETE";
17
+ readonly Pending: "PENDING";
18
+ };
19
+ export type PortfolioOrderDetailsSyncInfoStatus = (typeof PortfolioOrderDetailsSyncInfoStatus)[keyof typeof PortfolioOrderDetailsSyncInfoStatus];
20
+ export declare function PortfolioOrderDetailsSyncInfoStatusFromJSON(json: any): PortfolioOrderDetailsSyncInfoStatus;
21
+ export declare function PortfolioOrderDetailsSyncInfoStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioOrderDetailsSyncInfoStatus;
22
+ export declare function PortfolioOrderDetailsSyncInfoStatusToJSON(value?: PortfolioOrderDetailsSyncInfoStatus | null): any;
@@ -0,0 +1,29 @@
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
+ /**
14
+ *
15
+ * @export
16
+ */
17
+ export const PortfolioOrderDetailsSyncInfoStatus = {
18
+ Complete: "COMPLETE",
19
+ Pending: "PENDING",
20
+ };
21
+ export function PortfolioOrderDetailsSyncInfoStatusFromJSON(json) {
22
+ return PortfolioOrderDetailsSyncInfoStatusFromJSONTyped(json, false);
23
+ }
24
+ export function PortfolioOrderDetailsSyncInfoStatusFromJSONTyped(json, ignoreDiscriminator) {
25
+ return json;
26
+ }
27
+ export function PortfolioOrderDetailsSyncInfoStatusToJSON(value) {
28
+ return value;
29
+ }
@@ -8,6 +8,7 @@
8
8
  * https://openapi-generator.tech
9
9
  * Do not edit the class manually.
10
10
  */
11
+ import { PortfolioOrderDetailsSyncInfo } from "./PortfolioOrderDetailsSyncInfo";
11
12
  /**
12
13
  *
13
14
  * @export
@@ -26,6 +27,12 @@ export interface PortfolioSyncInfoComplete {
26
27
  * @memberof PortfolioSyncInfoComplete
27
28
  */
28
29
  lastSync: Date;
30
+ /**
31
+ *
32
+ * @type {PortfolioOrderDetailsSyncInfo}
33
+ * @memberof PortfolioSyncInfoComplete
34
+ */
35
+ orderDetails?: PortfolioOrderDetailsSyncInfo;
29
36
  }
30
37
  /**
31
38
  * @export
@@ -10,6 +10,8 @@
10
10
  * https://openapi-generator.tech
11
11
  * Do not edit the class manually.
12
12
  */
13
+ import { exists } from "../runtime.js";
14
+ import { PortfolioOrderDetailsSyncInfoFromJSON, PortfolioOrderDetailsSyncInfoToJSON, } from "./PortfolioOrderDetailsSyncInfo.js";
13
15
  /**
14
16
  * @export
15
17
  */
@@ -26,6 +28,9 @@ export function PortfolioSyncInfoCompleteFromJSONTyped(json, ignoreDiscriminator
26
28
  return {
27
29
  status: json["status"],
28
30
  lastSync: new Date(json["lastSync"]),
31
+ orderDetails: !exists(json, "orderDetails")
32
+ ? undefined
33
+ : PortfolioOrderDetailsSyncInfoFromJSON(json["orderDetails"]),
29
34
  };
30
35
  }
31
36
  export function PortfolioSyncInfoCompleteToJSONRecursive(value, ignoreParent = false) {
@@ -38,6 +43,7 @@ export function PortfolioSyncInfoCompleteToJSONRecursive(value, ignoreParent = f
38
43
  return {
39
44
  status: value.status,
40
45
  lastSync: value.lastSync.toISOString(),
46
+ orderDetails: PortfolioOrderDetailsSyncInfoToJSON(value.orderDetails),
41
47
  };
42
48
  }
43
49
  export function PortfolioSyncInfoCompleteToJSON(value) {
@@ -8,6 +8,7 @@
8
8
  * https://openapi-generator.tech
9
9
  * Do not edit the class manually.
10
10
  */
11
+ import { PortfolioOrderDetailsSyncInfo } from "./PortfolioOrderDetailsSyncInfo";
11
12
  /**
12
13
  *
13
14
  * @export
@@ -20,6 +21,12 @@ export interface PortfolioSyncInfoCompleteSpecifics {
20
21
  * @memberof PortfolioSyncInfoCompleteSpecifics
21
22
  */
22
23
  lastSync?: Date;
24
+ /**
25
+ *
26
+ * @type {PortfolioOrderDetailsSyncInfo}
27
+ * @memberof PortfolioSyncInfoCompleteSpecifics
28
+ */
29
+ orderDetails?: PortfolioOrderDetailsSyncInfo;
23
30
  }
24
31
  export declare function PortfolioSyncInfoCompleteSpecificsFromJSON(json: any): PortfolioSyncInfoCompleteSpecifics;
25
32
  export declare function PortfolioSyncInfoCompleteSpecificsFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioSyncInfoCompleteSpecifics;
@@ -11,6 +11,7 @@
11
11
  * Do not edit the class manually.
12
12
  */
13
13
  import { exists } from "../runtime.js";
14
+ import { PortfolioOrderDetailsSyncInfoFromJSON, PortfolioOrderDetailsSyncInfoToJSON, } from "./PortfolioOrderDetailsSyncInfo.js";
14
15
  export function PortfolioSyncInfoCompleteSpecificsFromJSON(json) {
15
16
  return PortfolioSyncInfoCompleteSpecificsFromJSONTyped(json, false);
16
17
  }
@@ -22,6 +23,9 @@ export function PortfolioSyncInfoCompleteSpecificsFromJSONTyped(json, ignoreDisc
22
23
  lastSync: !exists(json, "lastSync")
23
24
  ? undefined
24
25
  : new Date(json["lastSync"]),
26
+ orderDetails: !exists(json, "orderDetails")
27
+ ? undefined
28
+ : PortfolioOrderDetailsSyncInfoFromJSON(json["orderDetails"]),
25
29
  };
26
30
  }
27
31
  export function PortfolioSyncInfoCompleteSpecificsToJSONRecursive(value, ignoreParent = false) {
@@ -33,6 +37,7 @@ export function PortfolioSyncInfoCompleteSpecificsToJSONRecursive(value, ignoreP
33
37
  }
34
38
  return {
35
39
  lastSync: value.lastSync === undefined ? undefined : value.lastSync.toISOString(),
40
+ orderDetails: PortfolioOrderDetailsSyncInfoToJSON(value.orderDetails),
36
41
  };
37
42
  }
38
43
  export function PortfolioSyncInfoCompleteSpecificsToJSON(value) {
@@ -8,6 +8,7 @@
8
8
  * https://openapi-generator.tech
9
9
  * Do not edit the class manually.
10
10
  */
11
+ import { PortfolioOrderDetailsSyncInfo } from "./PortfolioOrderDetailsSyncInfo";
11
12
  /**
12
13
  *
13
14
  * @export
@@ -26,6 +27,12 @@ export interface PortfolioSyncInfoIncomplete {
26
27
  * @memberof PortfolioSyncInfoIncomplete
27
28
  */
28
29
  lastSync: Date;
30
+ /**
31
+ *
32
+ * @type {PortfolioOrderDetailsSyncInfo}
33
+ * @memberof PortfolioSyncInfoIncomplete
34
+ */
35
+ orderDetails?: PortfolioOrderDetailsSyncInfo;
29
36
  }
30
37
  /**
31
38
  * @export
@@ -10,6 +10,8 @@
10
10
  * https://openapi-generator.tech
11
11
  * Do not edit the class manually.
12
12
  */
13
+ import { exists } from "../runtime.js";
14
+ import { PortfolioOrderDetailsSyncInfoFromJSON, PortfolioOrderDetailsSyncInfoToJSON, } from "./PortfolioOrderDetailsSyncInfo.js";
13
15
  /**
14
16
  * @export
15
17
  */
@@ -26,6 +28,9 @@ export function PortfolioSyncInfoIncompleteFromJSONTyped(json, ignoreDiscriminat
26
28
  return {
27
29
  status: json["status"],
28
30
  lastSync: new Date(json["lastSync"]),
31
+ orderDetails: !exists(json, "orderDetails")
32
+ ? undefined
33
+ : PortfolioOrderDetailsSyncInfoFromJSON(json["orderDetails"]),
29
34
  };
30
35
  }
31
36
  export function PortfolioSyncInfoIncompleteToJSONRecursive(value, ignoreParent = false) {
@@ -38,6 +43,7 @@ export function PortfolioSyncInfoIncompleteToJSONRecursive(value, ignoreParent =
38
43
  return {
39
44
  status: value.status,
40
45
  lastSync: value.lastSync.toISOString(),
46
+ orderDetails: PortfolioOrderDetailsSyncInfoToJSON(value.orderDetails),
41
47
  };
42
48
  }
43
49
  export function PortfolioSyncInfoIncompleteToJSON(value) {
@@ -8,6 +8,7 @@
8
8
  * https://openapi-generator.tech
9
9
  * Do not edit the class manually.
10
10
  */
11
+ import { PortfolioOrderDetailsSyncInfo } from "./PortfolioOrderDetailsSyncInfo";
11
12
  /**
12
13
  *
13
14
  * @export
@@ -20,6 +21,12 @@ export interface PortfolioSyncInfoIncompleteSpecifics {
20
21
  * @memberof PortfolioSyncInfoIncompleteSpecifics
21
22
  */
22
23
  lastSync?: Date;
24
+ /**
25
+ *
26
+ * @type {PortfolioOrderDetailsSyncInfo}
27
+ * @memberof PortfolioSyncInfoIncompleteSpecifics
28
+ */
29
+ orderDetails?: PortfolioOrderDetailsSyncInfo;
23
30
  }
24
31
  export declare function PortfolioSyncInfoIncompleteSpecificsFromJSON(json: any): PortfolioSyncInfoIncompleteSpecifics;
25
32
  export declare function PortfolioSyncInfoIncompleteSpecificsFromJSONTyped(json: any, ignoreDiscriminator: boolean): PortfolioSyncInfoIncompleteSpecifics;
@@ -11,6 +11,7 @@
11
11
  * Do not edit the class manually.
12
12
  */
13
13
  import { exists } from "../runtime.js";
14
+ import { PortfolioOrderDetailsSyncInfoFromJSON, PortfolioOrderDetailsSyncInfoToJSON, } from "./PortfolioOrderDetailsSyncInfo.js";
14
15
  export function PortfolioSyncInfoIncompleteSpecificsFromJSON(json) {
15
16
  return PortfolioSyncInfoIncompleteSpecificsFromJSONTyped(json, false);
16
17
  }
@@ -22,6 +23,9 @@ export function PortfolioSyncInfoIncompleteSpecificsFromJSONTyped(json, ignoreDi
22
23
  lastSync: !exists(json, "lastSync")
23
24
  ? undefined
24
25
  : new Date(json["lastSync"]),
26
+ orderDetails: !exists(json, "orderDetails")
27
+ ? undefined
28
+ : PortfolioOrderDetailsSyncInfoFromJSON(json["orderDetails"]),
25
29
  };
26
30
  }
27
31
  export function PortfolioSyncInfoIncompleteSpecificsToJSONRecursive(value, ignoreParent = false) {
@@ -33,6 +37,7 @@ export function PortfolioSyncInfoIncompleteSpecificsToJSONRecursive(value, ignor
33
37
  }
34
38
  return {
35
39
  lastSync: value.lastSync === undefined ? undefined : value.lastSync.toISOString(),
40
+ orderDetails: PortfolioOrderDetailsSyncInfoToJSON(value.orderDetails),
36
41
  };
37
42
  }
38
43
  export function PortfolioSyncInfoIncompleteSpecificsToJSON(value) {
@@ -33,6 +33,7 @@
33
33
  export declare const TradeWarningReason: {
34
34
  readonly ExecutionsWithoutTimestamp: "executionsWithoutTimestamp";
35
35
  readonly InconsistentOrderHistory: "inconsistentOrderHistory";
36
+ readonly OrderDetailsIncomplete: "orderDetailsIncomplete";
36
37
  readonly PositionNotFullyExplained: "positionNotFullyExplained";
37
38
  readonly MissingEodPrice: "missingEodPrice";
38
39
  readonly MissingFxRate: "missingFxRate";
@@ -35,6 +35,7 @@
35
35
  export const TradeWarningReason = {
36
36
  ExecutionsWithoutTimestamp: "executionsWithoutTimestamp",
37
37
  InconsistentOrderHistory: "inconsistentOrderHistory",
38
+ OrderDetailsIncomplete: "orderDetailsIncomplete",
38
39
  PositionNotFullyExplained: "positionNotFullyExplained",
39
40
  MissingEodPrice: "missingEodPrice",
40
41
  MissingFxRate: "missingFxRate",
@@ -183,6 +183,8 @@ export * from "./PagesConfigurationResponse";
183
183
  export * from "./Portfolio";
184
184
  export * from "./PortfolioCalendarDateRange";
185
185
  export * from "./PortfolioCalendarItem";
186
+ export * from "./PortfolioOrderDetailsSyncInfo";
187
+ export * from "./PortfolioOrderDetailsSyncInfoStatus";
186
188
  export * from "./PortfolioQuotes";
187
189
  export * from "./PortfolioSyncInfo";
188
190
  export * from "./PortfolioSyncInfoComplete";
@@ -185,6 +185,8 @@ export * from "./PagesConfigurationResponse.js";
185
185
  export * from "./Portfolio.js";
186
186
  export * from "./PortfolioCalendarDateRange.js";
187
187
  export * from "./PortfolioCalendarItem.js";
188
+ export * from "./PortfolioOrderDetailsSyncInfo.js";
189
+ export * from "./PortfolioOrderDetailsSyncInfoStatus.js";
188
190
  export * from "./PortfolioQuotes.js";
189
191
  export * from "./PortfolioSyncInfo.js";
190
192
  export * from "./PortfolioSyncInfoComplete.js";
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.11"
8
+ "packageVersion": "7.60.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -1,6 +1,7 @@
1
1
  import { Auth } from "./apiCtx";
2
2
  import { AuthorizedApiContext } from "./authorizedApiContext";
3
3
  import { WebSocket } from "./dependencyDefinitions/webSocket";
4
+ import { BrokerizeWebSocketError } from "./errors";
4
5
  import type { SubscribeDecoupledOperation, SubscribeInvalidateDetails } from "./websocketTypes";
5
6
  export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketClient {
6
7
  private _url;
@@ -18,35 +19,108 @@ export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketC
18
19
  private _lastNonFatalError;
19
20
  private _errorCount;
20
21
  private _apiCtx;
21
- constructor(websocketUrl: string, auth: Auth, createWebSocket: (url: string) => WebSocket);
22
+ /**
23
+ * How often the server rejected our token in a row. Every retry forces a token refresh, and
24
+ * only `_maxConsecutiveAuthFailures` of them in a row are fatal. Reset on every successful
25
+ * authentication.
26
+ */
27
+ private _authFailureCount;
28
+ private _maxConsecutiveAuthFailures;
29
+ private _forceTokenRefresh;
30
+ private _destroyed;
31
+ private _connectionState;
32
+ private _connectionStateCallbacks;
33
+ constructor(websocketUrl: string, auth: Auth, createWebSocket: (url: string) => WebSocket, options?: BrokerizeWebSocketClientOptions);
22
34
  private _updateReconnectInterval;
23
35
  /**
24
36
  * Simple backoff behavior: first retry is fast (100ms), next 9 retries 1s, after that we only reconnect every 10s.
25
37
  * Jitter is added to avoid a thundering herd when many clients reconnect simultaneously (e.g. after a server-side disconnect).
26
38
  * The first retry uses a wider jitter window (~1s) because that's the scenario most prone to bursts of TLS handshakes.
39
+ *
40
+ * A token that keeps being rejected is retried far more slowly (`AUTH_RETRY_INTERVAL`), because
41
+ * every one of those attempts refreshes the token and a rejection is not something that tends to
42
+ * resolve within a second.
27
43
  */
28
44
  private _computeReconnectIntervalInMilliseconds;
29
45
  private _shouldConnect;
46
+ /**
47
+ * Invoke a subscriber callback. A callback that throws must not prevent the remaining
48
+ * subscribers from being notified, so everything is contained here.
49
+ */
50
+ private _invokeCallback;
30
51
  private subscribe;
31
52
  subscribeInvalidate(subscribe: SubscribeInvalidateDetails, callback: Callback): Subscription;
32
53
  subscribeDecoupledOperation(subscribe: Pick<SubscribeDecoupledOperation, "sessionId" | "decoupledOperationId">, callback: Callback): Subscription;
54
+ /**
55
+ * The current connection state. See `subscribeConnectionState`.
56
+ */
57
+ getConnectionState(): WebSocketConnectionState;
58
+ /**
59
+ * Observe the state of the underlying websocket connection. The callback is invoked immediately
60
+ * with the current state and afterwards on every change.
61
+ *
62
+ * This is the only place where non-terminal errors are reported: the client recovers from them
63
+ * on its own, so they are not passed to the subscription callbacks, which would force
64
+ * applications to tear down subscriptions on every connection hiccup. Use this to show that
65
+ * live updates are currently unavailable.
66
+ */
67
+ subscribeConnectionState(callback: ConnectionStateCallback): Subscription;
68
+ /**
69
+ * Recover from a fatal error (see `WebSocketConnectionState`). The client drops the fatal error
70
+ * state and connects again, retrieving a fresh token. Existing subscriptions were already
71
+ * terminated when the fatal error occurred, so applications have to subscribe again.
72
+ *
73
+ * Calling this without a fatal error forces a reconnect of the current connection.
74
+ */
75
+ reconnect(): void;
76
+ /**
77
+ * Release all resources: close the connection, drop all subscriptions and stop the reconnect and
78
+ * ping timers. A destroyed client cannot be revived with `reconnect()`.
79
+ *
80
+ * This is called by `AuthorizedApiContext.destroy()` for the client it created itself. A client
81
+ * that was passed in from outside is owned by the application and is not destroyed with the
82
+ * context.
83
+ */
84
+ destroy(): void;
85
+ private _setConnectionState;
33
86
  private _startSubscription;
34
87
  private _fillInMessagesAfterConnectionInterruption;
35
88
  private _endSubscription;
36
89
  /**
37
90
  * Internal method for setting a related AuthorizedApiContext. This is used to retrieve
38
91
  * decoupled operation status on interrupted connections.
92
+ *
93
+ * `null` detaches the current one, which a context does when it is destroyed: a destroyed
94
+ * context cannot perform that request, so holding on to it would be worse than holding none.
95
+ */
96
+ _setAuthorizedApiContext(ctx: AuthorizedApiContext | null): void;
97
+ /**
98
+ * Internal counterpart of `_setAuthorizedApiContext`, so that a context can tell whether the
99
+ * client is already attached to one - and whether that one is itself.
39
100
  */
40
- _setAuthorizedApiContext(ctx: AuthorizedApiContext): void;
101
+ _getAuthorizedApiContext(): AuthorizedApiContext | null;
41
102
  _startOrStopDisconnectTimeout(): void;
42
103
  private _sendWs;
104
+ /**
105
+ * Close the current socket, if any, and detach its handlers so that a late `close` event of an
106
+ * outdated socket cannot interfere with a connection established in the meantime.
107
+ */
108
+ private _closeSocket;
43
109
  private _connect;
110
+ private _handleMessage;
111
+ /**
112
+ * The server rejected our token. The usual cause is an id token that expired between retrieving
113
+ * it and the server validating it, which a fresh token fixes, so retry once before giving up on
114
+ * this client.
115
+ */
116
+ private _handleAuthenticationFailure;
44
117
  /**
45
118
  * Error happend when trying to connect, but it may be solved by trying a reconnect later.
46
119
  */
47
120
  private _handleNonFatalError;
48
121
  /**
49
- * Fatal error: this means the client is unusable from now on and must be recreated.
122
+ * Fatal error: this means the client is unusable from now on and must be recreated or revived
123
+ * with `reconnect()`.
50
124
  */
51
125
  private _handleFatalError;
52
126
  /**
@@ -59,10 +133,51 @@ export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketC
59
133
  private _resetErrorState;
60
134
  private _findSubscriptionEntry;
61
135
  }
136
+ /**
137
+ * Optional behavior of `BrokerizeWebSocketClientImpl`. The defaults are what an application
138
+ * wants; this exists for the rare case that they have to be tightened.
139
+ */
140
+ export type BrokerizeWebSocketClientOptions = {
141
+ /**
142
+ * How often in a row the server may reject our token before the client gives up and goes
143
+ * `fatal`. Defaults to 10, which together with the backoff spans several minutes. Mainly here so
144
+ * that tests do not have to wait that long.
145
+ */
146
+ maxConsecutiveAuthFailures?: number;
147
+ };
62
148
  export interface BrokerizeWebSocketClient {
63
149
  subscribeInvalidate: (subscribe: SubscribeInvalidateDetails, callback: Callback) => Subscription;
64
150
  subscribeDecoupledOperation: (subscribe: Pick<SubscribeDecoupledOperation, "sessionId" | "decoupledOperationId">, callback: Callback) => Subscription;
151
+ subscribeConnectionState: (callback: ConnectionStateCallback) => Subscription;
152
+ getConnectionState: () => WebSocketConnectionState;
153
+ reconnect: () => void;
65
154
  }
155
+ /**
156
+ * - `closed`: not connected, because nothing is subscribed.
157
+ * - `connecting`: the first connection attempt is in progress.
158
+ * - `open`: connected and authenticated, live updates are being delivered.
159
+ * - `reconnecting`: the connection failed or was lost and the client is retrying. `error` holds
160
+ * the error that caused it. Subscriptions stay alive and receive a synthetic invalidate once
161
+ * the connection is back.
162
+ *
163
+ * A rejected token lands here too, so an application can show that live updates are currently
164
+ * unavailable - and why - while the client works on getting back in, instead of having to
165
+ * rebuild everything over a token that expired in flight.
166
+ * - `fatal`: the client gave up and is unusable. All subscriptions were terminated with `error`.
167
+ * This only happens after the token has been rejected over and over for several minutes, i.e.
168
+ * when the session is gone rather than stale. Call `reconnect()` or create a new client.
169
+ */
170
+ export type WebSocketConnectionStatus = "closed" | "connecting" | "open" | "reconnecting" | "fatal";
171
+ export type WebSocketConnectionState = {
172
+ status: WebSocketConnectionStatus;
173
+ error?: BrokerizeWebSocketError;
174
+ };
175
+ export type ConnectionStateCallback = (state: WebSocketConnectionState) => void;
176
+ /**
177
+ * Callback of a subscription. `err` is always a `BrokerizeWebSocketError` with
178
+ * `terminal === true`: the subscription is over and will not receive any further data. Errors the
179
+ * client recovers from on its own are reported via `subscribeConnectionState` instead.
180
+ */
66
181
  export type Callback<T = any> = (err: any, data: T) => void;
67
182
  export type Subscription = {
68
183
  unsubscribe: () => void;