@brokerize/client 1.10.0 → 1.12.0

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 (94) 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 +5 -0
  5. package/dist/authorizedApiContext.js +12 -4
  6. package/dist/cjs/apiCtx.d.ts +10 -2
  7. package/dist/cjs/apiCtx.js +4 -4
  8. package/dist/cjs/authorizedApiContext.d.ts +5 -0
  9. package/dist/cjs/authorizedApiContext.js +11 -3
  10. package/dist/cjs/errors.d.ts +74 -0
  11. package/dist/cjs/errors.js +95 -1
  12. package/dist/cjs/index.d.ts +4 -4
  13. package/dist/cjs/index.js +6 -4
  14. package/dist/cjs/modelExports.d.ts +3 -0
  15. package/dist/cjs/modelExports.js +5 -1
  16. package/dist/cjs/swagger/models/BrokerClientCfg.d.ts +7 -0
  17. package/dist/cjs/swagger/models/BrokerClientCfg.js +5 -0
  18. package/dist/cjs/swagger/models/BrokerMeta.d.ts +15 -0
  19. package/dist/cjs/swagger/models/BrokerMeta.js +2 -0
  20. package/dist/cjs/swagger/models/ClientConfigUpdateOAuthLoginForm.d.ts +12 -1
  21. package/dist/cjs/swagger/models/ClientConfigUpdateOAuthLoginForm.js +2 -0
  22. package/dist/cjs/swagger/models/OAuthLoginFormConfig.d.ts +12 -1
  23. package/dist/cjs/swagger/models/OAuthLoginFormConfig.js +2 -0
  24. package/dist/cjs/swagger/models/Order.d.ts +9 -1
  25. package/dist/cjs/swagger/models/OrderCreate.d.ts +2 -1
  26. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfo.d.ts +60 -0
  27. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfo.js +51 -0
  28. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfoStatus.d.ts +22 -0
  29. package/dist/cjs/swagger/models/PortfolioOrderDetailsSyncInfoStatus.js +35 -0
  30. package/dist/cjs/swagger/models/PortfolioSyncInfoComplete.d.ts +7 -0
  31. package/dist/cjs/swagger/models/PortfolioSyncInfoComplete.js +6 -0
  32. package/dist/cjs/swagger/models/PortfolioSyncInfoCompleteSpecifics.d.ts +7 -0
  33. package/dist/cjs/swagger/models/PortfolioSyncInfoCompleteSpecifics.js +5 -0
  34. package/dist/cjs/swagger/models/PortfolioSyncInfoIncomplete.d.ts +7 -0
  35. package/dist/cjs/swagger/models/PortfolioSyncInfoIncomplete.js +6 -0
  36. package/dist/cjs/swagger/models/PortfolioSyncInfoIncompleteSpecifics.d.ts +7 -0
  37. package/dist/cjs/swagger/models/PortfolioSyncInfoIncompleteSpecifics.js +5 -0
  38. package/dist/cjs/swagger/models/SmartbrokerClientCfg.d.ts +27 -0
  39. package/dist/cjs/swagger/models/SmartbrokerClientCfg.js +46 -0
  40. package/dist/cjs/swagger/models/SummarizedTrade.d.ts +14 -0
  41. package/dist/cjs/swagger/models/SummarizedTrade.js +4 -0
  42. package/dist/cjs/swagger/models/TradeWarning.d.ts +31 -1
  43. package/dist/cjs/swagger/models/TradeWarning.js +13 -0
  44. package/dist/cjs/swagger/models/TradeWarningReason.d.ts +46 -0
  45. package/dist/cjs/swagger/models/TradeWarningReason.js +59 -0
  46. package/dist/cjs/swagger/models/index.d.ts +4 -0
  47. package/dist/cjs/swagger/models/index.js +4 -0
  48. package/dist/cjs/websocketClient.d.ts +109 -2
  49. package/dist/cjs/websocketClient.js +416 -74
  50. package/dist/cjs/websocketTypes.d.ts +10 -0
  51. package/dist/client.d.ts +437 -61
  52. package/dist/errors.d.ts +74 -0
  53. package/dist/errors.js +89 -0
  54. package/dist/index.d.ts +4 -4
  55. package/dist/index.js +3 -5
  56. package/dist/modelExports.d.ts +3 -0
  57. package/dist/modelExports.js +2 -0
  58. package/dist/swagger/models/BrokerClientCfg.d.ts +7 -0
  59. package/dist/swagger/models/BrokerClientCfg.js +5 -0
  60. package/dist/swagger/models/BrokerMeta.d.ts +15 -0
  61. package/dist/swagger/models/BrokerMeta.js +2 -0
  62. package/dist/swagger/models/ClientConfigUpdateOAuthLoginForm.d.ts +12 -1
  63. package/dist/swagger/models/ClientConfigUpdateOAuthLoginForm.js +2 -0
  64. package/dist/swagger/models/OAuthLoginFormConfig.d.ts +12 -1
  65. package/dist/swagger/models/OAuthLoginFormConfig.js +2 -0
  66. package/dist/swagger/models/Order.d.ts +9 -1
  67. package/dist/swagger/models/OrderCreate.d.ts +2 -1
  68. package/dist/swagger/models/PortfolioOrderDetailsSyncInfo.d.ts +60 -0
  69. package/dist/swagger/models/PortfolioOrderDetailsSyncInfo.js +45 -0
  70. package/dist/swagger/models/PortfolioOrderDetailsSyncInfoStatus.d.ts +22 -0
  71. package/dist/swagger/models/PortfolioOrderDetailsSyncInfoStatus.js +29 -0
  72. package/dist/swagger/models/PortfolioSyncInfoComplete.d.ts +7 -0
  73. package/dist/swagger/models/PortfolioSyncInfoComplete.js +6 -0
  74. package/dist/swagger/models/PortfolioSyncInfoCompleteSpecifics.d.ts +7 -0
  75. package/dist/swagger/models/PortfolioSyncInfoCompleteSpecifics.js +5 -0
  76. package/dist/swagger/models/PortfolioSyncInfoIncomplete.d.ts +7 -0
  77. package/dist/swagger/models/PortfolioSyncInfoIncomplete.js +6 -0
  78. package/dist/swagger/models/PortfolioSyncInfoIncompleteSpecifics.d.ts +7 -0
  79. package/dist/swagger/models/PortfolioSyncInfoIncompleteSpecifics.js +5 -0
  80. package/dist/swagger/models/SmartbrokerClientCfg.d.ts +27 -0
  81. package/dist/swagger/models/SmartbrokerClientCfg.js +40 -0
  82. package/dist/swagger/models/SummarizedTrade.d.ts +14 -0
  83. package/dist/swagger/models/SummarizedTrade.js +4 -0
  84. package/dist/swagger/models/TradeWarning.d.ts +31 -1
  85. package/dist/swagger/models/TradeWarning.js +13 -0
  86. package/dist/swagger/models/TradeWarningReason.d.ts +46 -0
  87. package/dist/swagger/models/TradeWarningReason.js +53 -0
  88. package/dist/swagger/models/index.d.ts +4 -0
  89. package/dist/swagger/models/index.js +4 -0
  90. package/dist/tsdoc-metadata.json +1 -1
  91. package/dist/websocketClient.d.ts +109 -2
  92. package/dist/websocketClient.js +416 -74
  93. package/dist/websocketTypes.d.ts +10 -0
  94. package/package.json +11 -10
package/dist/errors.d.ts CHANGED
@@ -65,3 +65,77 @@ export declare class BrokerizeError extends Error {
65
65
  httpStatusCode: number;
66
66
  constructor(statusCode: number, body: ErrorResponse);
67
67
  }
68
+ /**
69
+ * Thrown if a request to the brokerize API timed out (HTTP status 504). This is typically sent by
70
+ * a load balancer or gateway in front of the API, so the response body usually is not a regular
71
+ * `ErrorResponse`.
72
+ */
73
+ export declare class BrokerizeTimeoutError extends BrokerizeError {
74
+ constructor(body: ErrorResponse);
75
+ }
76
+ /**
77
+ * Create the error for a failed (status >= 400) API response. If the body is not a valid `ErrorResponse`
78
+ * (e.g. an HTML error page from a load balancer), a generic error body is used instead of failing with a
79
+ * JSON parse error.
80
+ */
81
+ export declare function createErrorFromResponse(response: Response): Promise<BrokerizeError>;
82
+ /**
83
+ * Error codes used by {@link BrokerizeWebSocketError}.
84
+ *
85
+ * - `AUTH`: the websocket connection could not be authenticated. Same code as a failed token
86
+ * refresh on the REST API, so applications can treat both identically.
87
+ * - `WEBSOCKET_CONNECTION_FAILED`: the connection could not be established or was lost
88
+ * (network error, failed handshake, closed socket). The client retries these automatically.
89
+ * - `WEBSOCKET_PROTOCOL_ERROR`: a message from the server could not be parsed.
90
+ * - `WEBSOCKET_ERROR`: any other error reported by the server.
91
+ */
92
+ export type BrokerizeWebSocketErrorCode = "AUTH" | "WEBSOCKET_CONNECTION_FAILED" | "WEBSOCKET_PROTOCOL_ERROR" | "WEBSOCKET_ERROR";
93
+ export type BrokerizeWebSocketErrorParams = {
94
+ msg: string;
95
+ code: BrokerizeWebSocketErrorCode;
96
+ httpStatusCode?: number;
97
+ /**
98
+ * See {@link BrokerizeWebSocketError.terminal}.
99
+ */
100
+ terminal?: boolean;
101
+ /**
102
+ * The underlying error or event, if any (e.g. the rejection of `Auth.getToken` or the
103
+ * `error` event of the websocket).
104
+ */
105
+ cause?: unknown;
106
+ };
107
+ /**
108
+ * Every error reported by the websocket client is an instance of this class, so applications can
109
+ * handle it like any other error (`instanceof Error`, `err.message`, stack trace) and can use the
110
+ * same error handling as for the REST API, which reports `BrokerizeError`.
111
+ */
112
+ export declare class BrokerizeWebSocketError extends BrokerizeError {
113
+ /**
114
+ * If `true`, the affected subscription is over and will not receive any further data. Errors
115
+ * that are passed to a subscription callback are always terminal; non-terminal errors are only
116
+ * reported via `BrokerizeWebSocketClient.subscribeConnectionState`, because the client
117
+ * recovers from them on its own.
118
+ */
119
+ readonly terminal: boolean;
120
+ /**
121
+ * The underlying error or event, if any.
122
+ */
123
+ readonly cause?: unknown;
124
+ constructor({ msg, code, httpStatusCode, terminal, cause, }: BrokerizeWebSocketErrorParams);
125
+ }
126
+ /**
127
+ * Check whether the given value is a `BrokerizeWebSocketError`. Prefer this over `instanceof`,
128
+ * which fails if more than one copy of this package ends up in a dependency tree.
129
+ */
130
+ export declare function isBrokerizeWebSocketError(x: unknown): x is BrokerizeWebSocketError;
131
+ /**
132
+ * Thrown when a request is made on an `AuthorizedApiContext` that was already destroyed.
133
+ *
134
+ * `destroy()` aborts the context's `AbortController`, so a request that is already in flight
135
+ * rejects with a `DOMException` named `AbortError`. This error carries the same `name`, so that
136
+ * both cases can be handled with a single check (`err.name === "AbortError"`), the way `fetch`
137
+ * itself rejects when handed an already-aborted signal.
138
+ */
139
+ export declare class BrokerizeAbortError extends Error {
140
+ constructor(msg: string);
141
+ }
package/dist/errors.js CHANGED
@@ -23,3 +23,92 @@ export class BrokerizeError extends Error {
23
23
  this.msgBrokerName = body.msgBrokerName;
24
24
  }
25
25
  }
26
+ /**
27
+ * Thrown if a request to the brokerize API timed out (HTTP status 504). This is typically sent by
28
+ * a load balancer or gateway in front of the API, so the response body usually is not a regular
29
+ * `ErrorResponse`.
30
+ */
31
+ export class BrokerizeTimeoutError extends BrokerizeError {
32
+ constructor(body) {
33
+ super(504, body);
34
+ this.name = "BrokerizeTimeoutError";
35
+ }
36
+ }
37
+ function isErrorResponse(x) {
38
+ return (!!x &&
39
+ typeof x === "object" &&
40
+ typeof x.msg === "string" &&
41
+ typeof x.code === "string");
42
+ }
43
+ /**
44
+ * Create the error for a failed (status >= 400) API response. If the body is not a valid `ErrorResponse`
45
+ * (e.g. an HTML error page from a load balancer), a generic error body is used instead of failing with a
46
+ * JSON parse error.
47
+ */
48
+ export async function createErrorFromResponse(response) {
49
+ const statusCode = response.status;
50
+ let body;
51
+ try {
52
+ const parsed = JSON.parse(await response.text());
53
+ if (isErrorResponse(parsed)) {
54
+ body = parsed;
55
+ }
56
+ }
57
+ catch (_a) {
58
+ /* not JSON, use the fallback below */
59
+ }
60
+ if (statusCode == 504) {
61
+ return new BrokerizeTimeoutError(body || {
62
+ msg: "The request timed out. Please try again.",
63
+ code: "TIMEOUT",
64
+ });
65
+ }
66
+ return new BrokerizeError(statusCode, body || {
67
+ msg: "The request failed with status " + statusCode + ".",
68
+ code: "INTERNAL_SERVER_ERROR",
69
+ });
70
+ }
71
+ const DEFAULT_STATUS_CODES = {
72
+ AUTH: 401,
73
+ WEBSOCKET_CONNECTION_FAILED: 503,
74
+ WEBSOCKET_PROTOCOL_ERROR: 500,
75
+ WEBSOCKET_ERROR: 500,
76
+ };
77
+ /**
78
+ * Every error reported by the websocket client is an instance of this class, so applications can
79
+ * handle it like any other error (`instanceof Error`, `err.message`, stack trace) and can use the
80
+ * same error handling as for the REST API, which reports `BrokerizeError`.
81
+ */
82
+ export class BrokerizeWebSocketError extends BrokerizeError {
83
+ constructor({ msg, code, httpStatusCode, terminal, cause, }) {
84
+ super(httpStatusCode !== null && httpStatusCode !== void 0 ? httpStatusCode : DEFAULT_STATUS_CODES[code], { msg, code });
85
+ Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain (https://stackoverflow.com/questions/41102060/typescript-extending-error-class)
86
+ this.name = "BrokerizeWebSocketError";
87
+ this.terminal = terminal !== null && terminal !== void 0 ? terminal : false;
88
+ this.cause = cause;
89
+ }
90
+ }
91
+ /**
92
+ * Check whether the given value is a `BrokerizeWebSocketError`. Prefer this over `instanceof`,
93
+ * which fails if more than one copy of this package ends up in a dependency tree.
94
+ */
95
+ export function isBrokerizeWebSocketError(x) {
96
+ return (!!x &&
97
+ typeof x === "object" &&
98
+ x.name === "BrokerizeWebSocketError");
99
+ }
100
+ /**
101
+ * Thrown when a request is made on an `AuthorizedApiContext` that was already destroyed.
102
+ *
103
+ * `destroy()` aborts the context's `AbortController`, so a request that is already in flight
104
+ * rejects with a `DOMException` named `AbortError`. This error carries the same `name`, so that
105
+ * both cases can be handled with a single check (`err.name === "AbortError"`), the way `fetch`
106
+ * itself rejects when handed an already-aborted signal.
107
+ */
108
+ export class BrokerizeAbortError extends Error {
109
+ constructor(msg) {
110
+ super(msg);
111
+ Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain (https://stackoverflow.com/questions/41102060/typescript-extending-error-class)
112
+ this.name = "AbortError";
113
+ }
114
+ }
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Auth, AuthContextConfiguration, BrokerizeConfig, CognitoConfig, CognitoFacade, CognitoPoolConfig, GuestAuthContextConfiguration, RegisteredUserAuthContextConfiguration, TokenSet } from "./apiCtx";
1
+ import { Auth, AuthContextConfiguration, BrokerizeConfig, CognitoConfig, CognitoFacade, CognitoPoolConfig, GetTokenOptions, GuestAuthContextConfiguration, RegisteredUserAuthContextConfiguration, TokenSet } from "./apiCtx";
2
2
  import { AuthorizedApiContext } from "./authorizedApiContext";
3
- import { BrokerizeError } from "./errors";
3
+ import { BrokerizeAbortError, BrokerizeError, BrokerizeTimeoutError, BrokerizeWebSocketError, BrokerizeWebSocketErrorCode, BrokerizeWebSocketErrorParams, isBrokerizeWebSocketError } from "./errors";
4
4
  import * as openApiClient from "./swagger";
5
5
  import * as Models from "./modelExports";
6
- import { BrokerizeWebSocketClient, Callback, Subscription } from "./websocketClient";
6
+ import { BrokerizeWebSocketClient, BrokerizeWebSocketClientOptions, Callback, ConnectionStateCallback, Subscription, WebSocketConnectionState, WebSocketConnectionStatus } from "./websocketClient";
7
7
  import * as WebSocketTypes from "./websocketTypes";
8
8
  import * as Utils from "./utils";
9
- export { BrokerizeConfig, AuthContextConfiguration, AuthorizedApiContext, BrokerizeWebSocketClient, Models, WebSocketTypes, Subscription, Callback, Utils, BrokerizeError, Auth, TokenSet, };
9
+ export { BrokerizeConfig, AuthContextConfiguration, AuthorizedApiContext, BrokerizeWebSocketClient, Models, WebSocketTypes, Subscription, Callback, Utils, BrokerizeError, BrokerizeTimeoutError, BrokerizeWebSocketError, BrokerizeWebSocketErrorCode, BrokerizeWebSocketErrorParams, BrokerizeAbortError, GetTokenOptions, isBrokerizeWebSocketError, ConnectionStateCallback, BrokerizeWebSocketClientOptions, WebSocketConnectionState, WebSocketConnectionStatus, Auth, TokenSet, };
10
10
  export { CognitoPoolConfig, RegisteredUserAuthContextConfiguration };
11
11
  export { CognitoConfig, CognitoFacade };
12
12
  export declare class Brokerize {
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@
2
2
  but reduced to the parts actually used by bg-trading. */
3
3
  import { createAuth, createConfiguration, withAcceptLanguage, } from "./apiCtx.js";
4
4
  import { AuthorizedApiContext, getWebSocketURLByBasePath, } from "./authorizedApiContext.js";
5
- import { BrokerizeError } from "./errors.js";
5
+ import { BrokerizeAbortError, BrokerizeError, BrokerizeTimeoutError, BrokerizeWebSocketError, createErrorFromResponse, isBrokerizeWebSocketError, } from "./errors.js";
6
6
  import * as openApiClient from "./swagger/index.js";
7
7
  import * as Models from "./modelExports.js";
8
8
  import { BrokerizeWebSocketClientImpl, } from "./websocketClient.js";
9
9
  import * as WebSocketTypes from "./websocketTypes.js";
10
10
  import * as Utils from "./utils.js";
11
- export { AuthorizedApiContext, Models, WebSocketTypes, Utils, BrokerizeError, };
11
+ export { AuthorizedApiContext, Models, WebSocketTypes, Utils, BrokerizeError, BrokerizeTimeoutError, BrokerizeWebSocketError, BrokerizeAbortError, isBrokerizeWebSocketError, };
12
12
  export class Brokerize {
13
13
  constructor(cfg) {
14
14
  if (!cfg.fetch) {
@@ -38,9 +38,7 @@ export class Brokerize {
38
38
  const postMiddleware = async (r) => {
39
39
  const statusCode = r.response.status;
40
40
  if (statusCode >= 400) {
41
- const decJson = (await r.response.json());
42
- const err = new BrokerizeError(statusCode, decJson);
43
- throw err;
41
+ throw await createErrorFromResponse(r.response);
44
42
  }
45
43
  };
46
44
  this._userApi = new openApiClient.UserApi(createConfiguration(cfg)).withPostMiddleware(postMiddleware);
@@ -86,6 +86,8 @@ export { GetBrokersResponse } from "./swagger/models/GetBrokersResponse";
86
86
  export { GetCostEstimationParams } from "./swagger/models/GetCostEstimationParams";
87
87
  export { GetOrderResponse } from "./swagger/models/GetOrderResponse";
88
88
  export { GetPortfolioOrdersResponse } from "./swagger/models/GetPortfolioOrdersResponse";
89
+ export { PortfolioOrderDetailsSyncInfo } from "./swagger/models/PortfolioOrderDetailsSyncInfo";
90
+ export { PortfolioOrderDetailsSyncInfoStatus } from "./swagger/models/PortfolioOrderDetailsSyncInfoStatus";
89
91
  export { GetPortfolioPositionsResponse } from "./swagger/models/GetPortfolioPositionsResponse";
90
92
  export { GetPortfolioQuotesResponse } from "./swagger/models/GetPortfolioQuotesResponse";
91
93
  export { GetQuoteParams } from "./swagger/models/GetQuoteParams";
@@ -157,6 +159,7 @@ export { OrderIntent } from "./swagger/models/OrderIntent";
157
159
  export { OrderIntentAvailability } from "./swagger/models/OrderIntentAvailability";
158
160
  export { SummarizedTrade } from "./swagger/models/SummarizedTrade";
159
161
  export { TradeWarning } from "./swagger/models/TradeWarning";
162
+ export { TradeWarningReason } from "./swagger/models/TradeWarningReason";
160
163
  export { GetPortfolioTradesResponse } from "./swagger/models/GetPortfolioTradesResponse";
161
164
  export { GetPortfolioTradeStatisticsResponse } from "./swagger/models/GetPortfolioTradeStatisticsResponse";
162
165
  export { TradeStatisticsItem } from "./swagger/models/TradeStatisticsItem";
@@ -9,6 +9,7 @@ export { EnableSessionTanParamsKind } from "./swagger/models/EnableSessionTanPar
9
9
  export { GenericTableRowType } from "./swagger/models/GenericTableRowType.js";
10
10
  export { GenericTableRowValueLinkValueType } from "./swagger/models/GenericTableRowValueLinkValueType.js";
11
11
  export { GenericTableRowValueType } from "./swagger/models/GenericTableRowValueType.js";
12
+ export { PortfolioOrderDetailsSyncInfoStatus } from "./swagger/models/PortfolioOrderDetailsSyncInfoStatus.js";
12
13
  export { LoginResponseState } from "./swagger/models/LoginResponseState.js";
13
14
  export { OrderExtension } from "./swagger/models/OrderExtension.js";
14
15
  export { OrderModel } from "./swagger/models/OrderModel.js";
@@ -19,3 +20,4 @@ export { PrepareOAuthRedirectParamsAppearanceEnum } from "./swagger/models/Prepa
19
20
  export { SessionSyncInfoStatus } from "./swagger/models/SessionSyncInfoStatus.js";
20
21
  export { TrailingDistanceModeEnum, } from "./swagger/models/TrailingDistance.js";
21
22
  export { OrderIntent } from "./swagger/models/OrderIntent.js";
23
+ export { TradeWarningReason } from "./swagger/models/TradeWarningReason.js";
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { BitpandaClientCfg } from "./BitpandaClientCfg";
12
12
  import { CoinbaseClientCfg } from "./CoinbaseClientCfg";
13
+ import { SmartbrokerClientCfg } from "./SmartbrokerClientCfg";
13
14
  /**
14
15
  *
15
16
  * @export
@@ -28,6 +29,12 @@ export interface BrokerClientCfg {
28
29
  * @memberof BrokerClientCfg
29
30
  */
30
31
  coinbase?: CoinbaseClientCfg;
32
+ /**
33
+ *
34
+ * @type {SmartbrokerClientCfg}
35
+ * @memberof BrokerClientCfg
36
+ */
37
+ smartbroker?: SmartbrokerClientCfg;
31
38
  }
32
39
  export declare function BrokerClientCfgFromJSON(json: any): BrokerClientCfg;
33
40
  export declare function BrokerClientCfgFromJSONTyped(json: any, ignoreDiscriminator: boolean): BrokerClientCfg;
@@ -13,6 +13,7 @@
13
13
  import { exists } from "../runtime.js";
14
14
  import { BitpandaClientCfgFromJSON, BitpandaClientCfgToJSON, } from "./BitpandaClientCfg.js";
15
15
  import { CoinbaseClientCfgFromJSON, CoinbaseClientCfgToJSON, } from "./CoinbaseClientCfg.js";
16
+ import { SmartbrokerClientCfgFromJSON, SmartbrokerClientCfgToJSON, } from "./SmartbrokerClientCfg.js";
16
17
  export function BrokerClientCfgFromJSON(json) {
17
18
  return BrokerClientCfgFromJSONTyped(json, false);
18
19
  }
@@ -27,6 +28,9 @@ export function BrokerClientCfgFromJSONTyped(json, ignoreDiscriminator) {
27
28
  coinbase: !exists(json, "coinbase")
28
29
  ? undefined
29
30
  : CoinbaseClientCfgFromJSON(json["coinbase"]),
31
+ smartbroker: !exists(json, "smartbroker")
32
+ ? undefined
33
+ : SmartbrokerClientCfgFromJSON(json["smartbroker"]),
30
34
  };
31
35
  }
32
36
  export function BrokerClientCfgToJSONRecursive(value, ignoreParent = false) {
@@ -39,6 +43,7 @@ export function BrokerClientCfgToJSONRecursive(value, ignoreParent = false) {
39
43
  return {
40
44
  bitpanda: BitpandaClientCfgToJSON(value.bitpanda),
41
45
  coinbase: CoinbaseClientCfgToJSON(value.coinbase),
46
+ smartbroker: SmartbrokerClientCfgToJSON(value.smartbroker),
42
47
  };
43
48
  }
44
49
  export function BrokerClientCfgToJSON(value) {
@@ -61,6 +61,21 @@ export interface BrokerMeta {
61
61
  * @memberof BrokerMeta
62
62
  */
63
63
  loginForm?: BrokerLoginForm;
64
+ /**
65
+ * All brokerize exchange ids this broker's exchanges are mapped to, ascending. Use it to tell
66
+ * upfront which brokers may be relevant for a given exchange, e.g. to preselect brokers for a
67
+ * security that is traded there.
68
+ *
69
+ * This is a static, broker-wide list: it means that brokerize knows how to translate between
70
+ * this broker's exchanges and the listed ids, not that every security can be traded at every
71
+ * one of them. The authoritative, security-specific list of tradable exchanges remains the
72
+ * `exchanges` field of a prepared trade.
73
+ *
74
+ * Every id is contained in the `GetExchanges` response, so it can always be resolved to a name.
75
+ * @type {Array<number>}
76
+ * @memberof BrokerMeta
77
+ */
78
+ supportedExchangeIds: Array<number>;
64
79
  /**
65
80
  * If true, the user can login at the broker via OAuth (this involves browser redirects). Use `prepareOAuthRedirect` to obtain a URL to redirect to.
66
81
  * @type {boolean}
@@ -32,6 +32,7 @@ export function BrokerMetaFromJSONTyped(json, ignoreDiscriminator) {
32
32
  loginForm: !exists(json, "loginForm")
33
33
  ? undefined
34
34
  : BrokerLoginFormFromJSON(json["loginForm"]),
35
+ supportedExchangeIds: json["supportedExchangeIds"],
35
36
  supportsOAuthLogin: !exists(json, "supportsOAuthLogin")
36
37
  ? undefined
37
38
  : json["supportsOAuthLogin"],
@@ -52,6 +53,7 @@ export function BrokerMetaToJSONRecursive(value, ignoreParent = false) {
52
53
  features: BrokerMetaFeaturesToJSON(value.features),
53
54
  images: BrokerMetaImagesToJSON(value.images),
54
55
  loginForm: BrokerLoginFormToJSON(value.loginForm),
56
+ supportedExchangeIds: value.supportedExchangeIds,
55
57
  supportsOAuthLogin: value.supportsOAuthLogin,
56
58
  };
57
59
  }
@@ -33,13 +33,22 @@ export interface ClientConfigUpdateOAuthLoginForm {
33
33
  */
34
34
  logoUrlLight?: string;
35
35
  /**
36
+ * How the browser is sent back to the `returnTo` URL after a successful broker login.
36
37
  *
38
+ * `meta`, `js` and `link` render the interstitial callback screen and redirect from there (via a
39
+ * meta refresh, via JavaScript, or by revealing a link the user clicks). `http` skips the screen
40
+ * and answers the callback with a plain HTTP 302 instead.
41
+ *
42
+ * `http` only applies to `http`/`https` `returnTo` URLs. A `returnTo` in a custom app scheme
43
+ * still gets the interstitial, because browsers handle a 302 into an app scheme inconsistently.
44
+ *
45
+ * Default is `meta`.
37
46
  * @type {string}
38
47
  * @memberof ClientConfigUpdateOAuthLoginForm
39
48
  */
40
49
  redirectStyle?: ClientConfigUpdateOAuthLoginFormRedirectStyleEnum;
41
50
  /**
42
- *
51
+ * Overrides `redirectStyle` for logins at bitpanda.
43
52
  * @type {string}
44
53
  * @memberof ClientConfigUpdateOAuthLoginForm
45
54
  */
@@ -52,6 +61,7 @@ export declare const ClientConfigUpdateOAuthLoginFormRedirectStyleEnum: {
52
61
  readonly Meta: "meta";
53
62
  readonly Js: "js";
54
63
  readonly Link: "link";
64
+ readonly Http: "http";
55
65
  };
56
66
  export type ClientConfigUpdateOAuthLoginFormRedirectStyleEnum = (typeof ClientConfigUpdateOAuthLoginFormRedirectStyleEnum)[keyof typeof ClientConfigUpdateOAuthLoginFormRedirectStyleEnum];
57
67
  /**
@@ -61,6 +71,7 @@ export declare const ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum:
61
71
  readonly Meta: "meta";
62
72
  readonly Js: "js";
63
73
  readonly Link: "link";
74
+ readonly Http: "http";
64
75
  };
65
76
  export type ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum = (typeof ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum)[keyof typeof ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum];
66
77
  export declare function ClientConfigUpdateOAuthLoginFormFromJSON(json: any): ClientConfigUpdateOAuthLoginForm;
@@ -18,6 +18,7 @@ export const ClientConfigUpdateOAuthLoginFormRedirectStyleEnum = {
18
18
  Meta: "meta",
19
19
  Js: "js",
20
20
  Link: "link",
21
+ Http: "http",
21
22
  };
22
23
  /**
23
24
  * @export
@@ -26,6 +27,7 @@ export const ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum = {
26
27
  Meta: "meta",
27
28
  Js: "js",
28
29
  Link: "link",
30
+ Http: "http",
29
31
  };
30
32
  export function ClientConfigUpdateOAuthLoginFormFromJSON(json) {
31
33
  return ClientConfigUpdateOAuthLoginFormFromJSONTyped(json, false);
@@ -33,13 +33,22 @@ export interface OAuthLoginFormConfig {
33
33
  */
34
34
  logoUrlLight?: string;
35
35
  /**
36
+ * How the browser is sent back to the `returnTo` URL after a successful broker login.
36
37
  *
38
+ * `meta`, `js` and `link` render the interstitial callback screen and redirect from there (via a
39
+ * meta refresh, via JavaScript, or by revealing a link the user clicks). `http` skips the screen
40
+ * and answers the callback with a plain HTTP 302 instead.
41
+ *
42
+ * `http` only applies to `http`/`https` `returnTo` URLs. A `returnTo` in a custom app scheme
43
+ * still gets the interstitial, because browsers handle a 302 into an app scheme inconsistently.
44
+ *
45
+ * Default is `meta`.
37
46
  * @type {string}
38
47
  * @memberof OAuthLoginFormConfig
39
48
  */
40
49
  redirectStyle?: OAuthLoginFormConfigRedirectStyleEnum;
41
50
  /**
42
- *
51
+ * Overrides `redirectStyle` for logins at bitpanda.
43
52
  * @type {string}
44
53
  * @memberof OAuthLoginFormConfig
45
54
  */
@@ -52,6 +61,7 @@ export declare const OAuthLoginFormConfigRedirectStyleEnum: {
52
61
  readonly Meta: "meta";
53
62
  readonly Js: "js";
54
63
  readonly Link: "link";
64
+ readonly Http: "http";
55
65
  };
56
66
  export type OAuthLoginFormConfigRedirectStyleEnum = (typeof OAuthLoginFormConfigRedirectStyleEnum)[keyof typeof OAuthLoginFormConfigRedirectStyleEnum];
57
67
  /**
@@ -61,6 +71,7 @@ export declare const OAuthLoginFormConfigRedirectStyleBitpandaEnum: {
61
71
  readonly Meta: "meta";
62
72
  readonly Js: "js";
63
73
  readonly Link: "link";
74
+ readonly Http: "http";
64
75
  };
65
76
  export type OAuthLoginFormConfigRedirectStyleBitpandaEnum = (typeof OAuthLoginFormConfigRedirectStyleBitpandaEnum)[keyof typeof OAuthLoginFormConfigRedirectStyleBitpandaEnum];
66
77
  export declare function OAuthLoginFormConfigFromJSON(json: any): OAuthLoginFormConfig;
@@ -18,6 +18,7 @@ export const OAuthLoginFormConfigRedirectStyleEnum = {
18
18
  Meta: "meta",
19
19
  Js: "js",
20
20
  Link: "link",
21
+ Http: "http",
21
22
  };
22
23
  /**
23
24
  * @export
@@ -26,6 +27,7 @@ export const OAuthLoginFormConfigRedirectStyleBitpandaEnum = {
26
27
  Meta: "meta",
27
28
  Js: "js",
28
29
  Link: "link",
30
+ Http: "http",
29
31
  };
30
32
  export function OAuthLoginFormConfigFromJSON(json) {
31
33
  return OAuthLoginFormConfigFromJSONTyped(json, false);
@@ -92,7 +92,14 @@ export interface Order {
92
92
  */
93
93
  bondCurrencyIso?: string;
94
94
  /**
95
+ * The id of the exchange, as defined by the *broker*.
95
96
  *
97
+ * When reading an order this **can be an empty string**: not every order is traded on an exchange -- a securities
98
+ * account transfer, for example, is booked into or out of the custody account and has no trading venue, so the
99
+ * broker reports no exchange for it. Clients must handle the empty string.
100
+ *
101
+ * Note that this field will become optional in a future version of the API, so clients should not rely on it
102
+ * being present at all. For creating an order it stays required, see `OrderCreate`.
96
103
  * @type {string}
97
104
  * @memberof Order
98
105
  */
@@ -176,7 +183,8 @@ export interface Order {
176
183
  */
177
184
  exchangeName?: string;
178
185
  /**
179
- * For fully executed orders: the timestamp of the *latest* execution.
186
+ * For orders with at least one execution (`executed`, `open_executed`, `canceled_executed`):
187
+ * the timestamp of the *latest* execution.
180
188
  * @type {Date}
181
189
  * @memberof Order
182
190
  */
@@ -21,7 +21,8 @@ import { TrailingDistance } from "./TrailingDistance";
21
21
  */
22
22
  export interface OrderCreate {
23
23
  /**
24
- *
24
+ * The id of the exchange, as defined by the *broker*. Always required to create an order, and never empty --
25
+ * unlike when reading an order, where the broker may report no exchange (see `OrderBase.brokerExchangeId`).
25
26
  * @type {string}
26
27
  * @memberof OrderCreate
27
28
  */
@@ -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
+ }