@woodger/t-invest-node-sdk 0.5.2 → 0.5.4

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 (229) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/{THIRD_PARTY_NOTICES.md → LICENSE-APACHE-2.0} +1 -106
  3. package/NOTICE +98 -0
  4. package/dist/application/services/unary-limiter.d.ts +10 -1
  5. package/dist/application/services/unary-limiter.js +35 -11
  6. package/dist/bootstrap/args/sdk-options.d.ts +1 -2
  7. package/dist/bootstrap/cli/help-catalog.d.ts +733 -0
  8. package/dist/bootstrap/cli/help-catalog.js +1649 -0
  9. package/dist/bootstrap/cli/help.d.ts +2 -730
  10. package/dist/bootstrap/cli/help.js +5 -1647
  11. package/dist/bootstrap/cli/registry.d.ts +6 -6
  12. package/dist/bootstrap/commands/accounts/cli.d.ts +2 -3
  13. package/dist/bootstrap/commands/accounts/cli.js +5 -10
  14. package/dist/bootstrap/commands/accrued-interests/cli.d.ts +2 -3
  15. package/dist/bootstrap/commands/accrued-interests/cli.js +5 -10
  16. package/dist/bootstrap/commands/asset/cli.d.ts +2 -3
  17. package/dist/bootstrap/commands/asset/cli.js +5 -10
  18. package/dist/bootstrap/commands/assets/cli.d.ts +2 -3
  19. package/dist/bootstrap/commands/assets/cli.js +5 -10
  20. package/dist/bootstrap/commands/bond/cli.d.ts +2 -3
  21. package/dist/bootstrap/commands/bond/cli.js +5 -10
  22. package/dist/bootstrap/commands/bond-coupons/cli.d.ts +2 -3
  23. package/dist/bootstrap/commands/bond-coupons/cli.js +5 -10
  24. package/dist/bootstrap/commands/bonds/cli.d.ts +2 -3
  25. package/dist/bootstrap/commands/bonds/cli.js +5 -10
  26. package/dist/bootstrap/commands/brand/cli.d.ts +2 -3
  27. package/dist/bootstrap/commands/brand/cli.js +5 -10
  28. package/dist/bootstrap/commands/brands/cli.d.ts +2 -3
  29. package/dist/bootstrap/commands/brands/cli.js +5 -10
  30. package/dist/bootstrap/commands/broker-report/cli.d.ts +2 -3
  31. package/dist/bootstrap/commands/broker-report/cli.js +5 -10
  32. package/dist/bootstrap/commands/cancel-order/cli.d.ts +3 -39
  33. package/dist/bootstrap/commands/cancel-order/cli.js +8 -19
  34. package/dist/bootstrap/commands/cancel-order/request.mapper.d.ts +7 -0
  35. package/dist/bootstrap/commands/cancel-order/request.mapper.js +9 -0
  36. package/dist/bootstrap/commands/cancel-stop-order/cli.d.ts +3 -4
  37. package/dist/bootstrap/commands/cancel-stop-order/cli.js +6 -11
  38. package/dist/bootstrap/commands/candles/cli.d.ts +3 -4
  39. package/dist/bootstrap/commands/candles/cli.js +6 -11
  40. package/dist/bootstrap/commands/close-prices/cli.d.ts +3 -4
  41. package/dist/bootstrap/commands/close-prices/cli.js +6 -11
  42. package/dist/bootstrap/commands/countries/cli.d.ts +2 -3
  43. package/dist/bootstrap/commands/countries/cli.js +5 -10
  44. package/dist/bootstrap/commands/currencies/cli.d.ts +2 -3
  45. package/dist/bootstrap/commands/currencies/cli.js +5 -10
  46. package/dist/bootstrap/commands/currency/cli.d.ts +2 -3
  47. package/dist/bootstrap/commands/currency/cli.js +5 -10
  48. package/dist/bootstrap/commands/dividends/cli.d.ts +2 -3
  49. package/dist/bootstrap/commands/dividends/cli.js +5 -10
  50. package/dist/bootstrap/commands/dividends-foreign-issuer/cli.d.ts +2 -3
  51. package/dist/bootstrap/commands/dividends-foreign-issuer/cli.js +5 -10
  52. package/dist/bootstrap/commands/edit-favorites/cli.d.ts +2 -3
  53. package/dist/bootstrap/commands/edit-favorites/cli.js +5 -10
  54. package/dist/bootstrap/commands/etf/cli.d.ts +2 -3
  55. package/dist/bootstrap/commands/etf/cli.js +5 -10
  56. package/dist/bootstrap/commands/etfs/cli.d.ts +2 -3
  57. package/dist/bootstrap/commands/etfs/cli.js +5 -10
  58. package/dist/bootstrap/commands/favorites/cli.d.ts +2 -3
  59. package/dist/bootstrap/commands/favorites/cli.js +5 -10
  60. package/dist/bootstrap/commands/find-instrument/cli.d.ts +2 -3
  61. package/dist/bootstrap/commands/find-instrument/cli.js +5 -10
  62. package/dist/bootstrap/commands/future/cli.d.ts +2 -3
  63. package/dist/bootstrap/commands/future/cli.js +5 -10
  64. package/dist/bootstrap/commands/futures/cli.d.ts +2 -3
  65. package/dist/bootstrap/commands/futures/cli.js +5 -10
  66. package/dist/bootstrap/commands/futures-margin/cli.d.ts +2 -3
  67. package/dist/bootstrap/commands/futures-margin/cli.js +5 -10
  68. package/dist/bootstrap/commands/instrument/cli.d.ts +2 -3
  69. package/dist/bootstrap/commands/instrument/cli.js +5 -10
  70. package/dist/bootstrap/commands/last-prices/cli.d.ts +3 -4
  71. package/dist/bootstrap/commands/last-prices/cli.js +6 -11
  72. package/dist/bootstrap/commands/last-trades/cli.d.ts +3 -4
  73. package/dist/bootstrap/commands/last-trades/cli.js +6 -11
  74. package/dist/bootstrap/commands/margin-attributes/cli.d.ts +2 -3
  75. package/dist/bootstrap/commands/margin-attributes/cli.js +5 -10
  76. package/dist/bootstrap/commands/operations/cli.d.ts +5 -53
  77. package/dist/bootstrap/commands/operations/cli.js +9 -36
  78. package/dist/bootstrap/commands/operations/request.mapper.d.ts +23 -0
  79. package/dist/bootstrap/commands/operations/request.mapper.js +33 -0
  80. package/dist/bootstrap/commands/operations-by-cursor/cli.d.ts +5 -69
  81. package/dist/bootstrap/commands/operations-by-cursor/cli.js +9 -74
  82. package/dist/bootstrap/commands/operations-by-cursor/request.mapper.d.ts +28 -0
  83. package/dist/bootstrap/commands/operations-by-cursor/request.mapper.js +70 -0
  84. package/dist/bootstrap/commands/option/cli.d.ts +2 -3
  85. package/dist/bootstrap/commands/option/cli.js +5 -10
  86. package/dist/bootstrap/commands/options-by/cli.d.ts +2 -3
  87. package/dist/bootstrap/commands/options-by/cli.js +5 -10
  88. package/dist/bootstrap/commands/order-book/cli.d.ts +3 -4
  89. package/dist/bootstrap/commands/order-book/cli.js +6 -11
  90. package/dist/bootstrap/commands/order-state/cli.d.ts +3 -36
  91. package/dist/bootstrap/commands/order-state/cli.js +8 -21
  92. package/dist/bootstrap/commands/order-state/request.mapper.d.ts +13 -0
  93. package/dist/bootstrap/commands/order-state/request.mapper.js +17 -0
  94. package/dist/bootstrap/commands/orders/cli.d.ts +3 -32
  95. package/dist/bootstrap/commands/orders/cli.js +8 -18
  96. package/dist/bootstrap/commands/orders/request.mapper.d.ts +6 -0
  97. package/dist/bootstrap/commands/orders/request.mapper.js +8 -0
  98. package/dist/bootstrap/commands/portfolio/cli.d.ts +6 -40
  99. package/dist/bootstrap/commands/portfolio/cli.js +9 -26
  100. package/dist/bootstrap/commands/portfolio/request.mapper.d.ts +18 -0
  101. package/dist/bootstrap/commands/portfolio/request.mapper.js +21 -0
  102. package/dist/bootstrap/commands/positions/cli.d.ts +3 -32
  103. package/dist/bootstrap/commands/positions/cli.js +8 -18
  104. package/dist/bootstrap/commands/positions/request.mapper.d.ts +6 -0
  105. package/dist/bootstrap/commands/positions/request.mapper.js +8 -0
  106. package/dist/bootstrap/commands/post-order/cli.d.ts +8 -68
  107. package/dist/bootstrap/commands/post-order/cli.js +9 -39
  108. package/dist/bootstrap/commands/post-order/request.mapper.d.ts +27 -0
  109. package/dist/bootstrap/commands/post-order/request.mapper.js +35 -0
  110. package/dist/bootstrap/commands/post-stop-order/cli.d.ts +3 -4
  111. package/dist/bootstrap/commands/post-stop-order/cli.js +6 -11
  112. package/dist/bootstrap/commands/replace-order/cli.d.ts +5 -61
  113. package/dist/bootstrap/commands/replace-order/cli.js +9 -30
  114. package/dist/bootstrap/commands/replace-order/request.mapper.d.ts +22 -0
  115. package/dist/bootstrap/commands/replace-order/request.mapper.js +26 -0
  116. package/dist/bootstrap/commands/sandbox-accounts/cli.d.ts +2 -3
  117. package/dist/bootstrap/commands/sandbox-accounts/cli.js +5 -10
  118. package/dist/bootstrap/commands/sandbox-cancel-order/cli.d.ts +3 -4
  119. package/dist/bootstrap/commands/sandbox-cancel-order/cli.js +8 -13
  120. package/dist/bootstrap/commands/sandbox-close-account/cli.d.ts +2 -3
  121. package/dist/bootstrap/commands/sandbox-close-account/cli.js +5 -10
  122. package/dist/bootstrap/commands/sandbox-open-account/cli.d.ts +2 -3
  123. package/dist/bootstrap/commands/sandbox-open-account/cli.js +5 -10
  124. package/dist/bootstrap/commands/sandbox-operations/cli.d.ts +3 -4
  125. package/dist/bootstrap/commands/sandbox-operations/cli.js +8 -13
  126. package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.d.ts +3 -4
  127. package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.js +8 -13
  128. package/dist/bootstrap/commands/sandbox-order-state/cli.d.ts +3 -4
  129. package/dist/bootstrap/commands/sandbox-order-state/cli.js +8 -13
  130. package/dist/bootstrap/commands/sandbox-orders/cli.d.ts +3 -4
  131. package/dist/bootstrap/commands/sandbox-orders/cli.js +8 -13
  132. package/dist/bootstrap/commands/sandbox-pay-in/cli.d.ts +2 -3
  133. package/dist/bootstrap/commands/sandbox-pay-in/cli.js +5 -10
  134. package/dist/bootstrap/commands/sandbox-portfolio/cli.d.ts +3 -4
  135. package/dist/bootstrap/commands/sandbox-portfolio/cli.js +8 -13
  136. package/dist/bootstrap/commands/sandbox-positions/cli.d.ts +3 -4
  137. package/dist/bootstrap/commands/sandbox-positions/cli.js +8 -13
  138. package/dist/bootstrap/commands/sandbox-post-order/cli.d.ts +3 -4
  139. package/dist/bootstrap/commands/sandbox-post-order/cli.js +8 -13
  140. package/dist/bootstrap/commands/sandbox-replace-order/cli.d.ts +3 -4
  141. package/dist/bootstrap/commands/sandbox-replace-order/cli.js +8 -13
  142. package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.d.ts +3 -4
  143. package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.js +8 -13
  144. package/dist/bootstrap/commands/sdk-command-lifecycle.d.ts +15 -0
  145. package/dist/bootstrap/commands/sdk-command-lifecycle.js +21 -0
  146. package/dist/bootstrap/commands/share/cli.d.ts +2 -3
  147. package/dist/bootstrap/commands/share/cli.js +5 -10
  148. package/dist/bootstrap/commands/shares/cli.d.ts +2 -3
  149. package/dist/bootstrap/commands/shares/cli.js +5 -10
  150. package/dist/bootstrap/commands/stop-orders/cli.d.ts +3 -4
  151. package/dist/bootstrap/commands/stop-orders/cli.js +6 -11
  152. package/dist/bootstrap/commands/stream-run/cli.d.ts +2 -24
  153. package/dist/bootstrap/commands/stream-run/cli.js +7 -142
  154. package/dist/bootstrap/commands/stream-run/config.d.ts +7 -15
  155. package/dist/bootstrap/commands/stream-run/config.js +1 -101
  156. package/dist/bootstrap/commands/stream-run/request.mapper.d.ts +14 -0
  157. package/dist/bootstrap/commands/stream-run/request.mapper.js +111 -0
  158. package/dist/bootstrap/commands/stream-run/stream-session.d.ts +37 -0
  159. package/dist/bootstrap/commands/stream-run/stream-session.js +152 -0
  160. package/dist/bootstrap/commands/trading-schedules/cli.d.ts +2 -3
  161. package/dist/bootstrap/commands/trading-schedules/cli.js +5 -10
  162. package/dist/bootstrap/commands/trading-status/cli.d.ts +3 -4
  163. package/dist/bootstrap/commands/trading-status/cli.js +6 -11
  164. package/dist/bootstrap/commands/trading-statuses/cli.d.ts +3 -4
  165. package/dist/bootstrap/commands/trading-statuses/cli.js +6 -11
  166. package/dist/bootstrap/commands/user-info/cli.d.ts +2 -3
  167. package/dist/bootstrap/commands/user-info/cli.js +5 -10
  168. package/dist/bootstrap/commands/user-tariff/cli.d.ts +2 -3
  169. package/dist/bootstrap/commands/user-tariff/cli.js +5 -10
  170. package/dist/bootstrap/commands/withdraw-limits/cli.d.ts +3 -32
  171. package/dist/bootstrap/commands/withdraw-limits/cli.js +8 -18
  172. package/dist/bootstrap/commands/withdraw-limits/request.mapper.d.ts +6 -0
  173. package/dist/bootstrap/commands/withdraw-limits/request.mapper.js +8 -0
  174. package/dist/bootstrap/index.js +2 -2
  175. package/dist/bootstrap/proto/compile-proto.d.ts +1 -1
  176. package/dist/bootstrap/proto/compile-proto.js +28 -35
  177. package/dist/bootstrap/t-invest-node-sdk.d.ts +9 -9
  178. package/dist/bootstrap/t-invest-node-sdk.js +33 -18
  179. package/dist/bootstrap/unary-limit-config.js +4 -4
  180. package/dist/generated/common.js +2 -2
  181. package/dist/generated/google/api/field_behavior.js +2 -2
  182. package/dist/generated/google/protobuf/descriptor.js +2 -2
  183. package/dist/generated/google/protobuf/timestamp.js +2 -2
  184. package/dist/generated/instruments.js +2 -2
  185. package/dist/generated/marketdata.js +2 -2
  186. package/dist/generated/operations.js +2 -2
  187. package/dist/generated/orders.js +2 -2
  188. package/dist/generated/sandbox.js +2 -2
  189. package/dist/generated/signals.js +2 -2
  190. package/dist/generated/stoporders.js +2 -2
  191. package/dist/generated/users.js +2 -2
  192. package/dist/index.d.ts +1 -1
  193. package/dist/infrastructure/interceptor/warning-interceptor.d.ts +1 -1
  194. package/dist/infrastructure/interceptor/warning-interceptor.js +2 -2
  195. package/dist/infrastructure/transport/grpc/sdk-call-error.d.ts +12 -0
  196. package/dist/infrastructure/transport/grpc/sdk-call-error.js +180 -0
  197. package/dist/infrastructure/transport/grpc/sdk-client.d.ts +1 -1
  198. package/dist/infrastructure/transport/grpc/sdk-client.js +2 -2
  199. package/dist/infrastructure/transport/grpc/sdk-middleware.d.ts +1 -1
  200. package/dist/infrastructure/transport/grpc/sdk-middleware.js +8 -174
  201. package/dist/infrastructure/transport/grpc/unary-limit-resolver.d.ts +3 -1
  202. package/dist/infrastructure/transport/grpc/unary-limit-resolver.js +19 -18
  203. package/docs/architecture.md +45 -42
  204. package/docs/bundled-ca.md +12 -12
  205. package/docs/clean-architecture/adapters.md +15 -15
  206. package/docs/clean-architecture/api-commands.md +63 -52
  207. package/docs/clean-architecture/application.md +13 -13
  208. package/docs/clean-architecture/cli-output-boundaries.md +23 -23
  209. package/docs/clean-architecture/dto.md +9 -9
  210. package/docs/clean-architecture/index.md +13 -12
  211. package/docs/cli-stream-configuration.md +9 -9
  212. package/docs/cli-stream-reference.md +11 -11
  213. package/docs/guides/custom-unary-limiter.md +44 -30
  214. package/docs/guides/errors-and-lifecycle.md +10 -10
  215. package/docs/guides/getting-started.md +9 -9
  216. package/docs/guides/index.md +3 -3
  217. package/docs/guides/streams-and-cancellation.md +6 -6
  218. package/docs/guides/testing-with-service-definitions.md +4 -4
  219. package/docs/guides/unary-calls.md +8 -8
  220. package/docs/index.md +14 -10
  221. package/docs/limits-policy.md +10 -10
  222. package/docs/roadmap.md +14 -14
  223. package/docs/tls-policy.md +7 -7
  224. package/package.json +6 -5
  225. package/readme.md +37 -85
  226. package/dist/infrastructure/interceptor/index.d.ts +0 -1
  227. package/dist/infrastructure/interceptor/index.js +0 -17
  228. /package/dist/infrastructure/transport/grpc/{unary-limits.d.ts → unary-method-path.d.ts} +0 -0
  229. /package/dist/infrastructure/transport/grpc/{unary-limits.js → unary-method-path.js} +0 -0
@@ -12,11 +12,7 @@
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.streamRunStreamNames = void 0;
14
14
  exports.parseStreamRunConfig = parseStreamRunConfig;
15
- exports.createMarketDataStreamRequests = createMarketDataStreamRequests;
16
- exports.createMarketDataServerSideStreamRequest = createMarketDataServerSideStreamRequest;
17
- exports.createPortfolioStreamRequest = createPortfolioStreamRequest;
18
- exports.createPositionsStreamRequest = createPositionsStreamRequest;
19
- exports.createTradesStreamRequest = createTradesStreamRequest;
15
+ exports.resolveCandlesWaitingClose = resolveCandlesWaitingClose;
20
16
  const marketdata_1 = require("../../../generated/marketdata");
21
17
  const icore_1 = require("icore");
22
18
  exports.streamRunStreamNames = [
@@ -105,102 +101,6 @@ function parseStreamRunConfig(json) {
105
101
  runtime
106
102
  };
107
103
  }
108
- function createMarketDataStreamRequests(config) {
109
- if (config.stream !== 'marketdata.marketDataStream') {
110
- throw new icore_1.CliUsageError(`Expected marketdata bidirectional stream config, got '${config.stream}'`);
111
- }
112
- return config.requests ?? [];
113
- }
114
- function createMarketDataServerSideStreamRequest(config) {
115
- if (config.stream !== 'marketdata.marketDataServerSideStream') {
116
- throw new icore_1.CliUsageError(`Expected marketdata server-side stream config, got '${config.stream}'`);
117
- }
118
- const subscriptions = config.subscriptions;
119
- if (!subscriptions) {
120
- throw new icore_1.CliUsageError("Expected 'subscriptions' for marketdata server-side stream config");
121
- }
122
- const candles = subscriptions.candles ?? [];
123
- const orderBooks = subscriptions.orderBooks ?? [];
124
- const trades = subscriptions.trades ?? [];
125
- const info = subscriptions.info ?? [];
126
- const lastPrices = subscriptions.lastPrices ?? [];
127
- return {
128
- subscribeCandlesRequest: candles.length > 0
129
- ? {
130
- subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
131
- instruments: candles.map((item) => marketdata_1.CandleInstrument.create({
132
- interval: item.interval,
133
- instrumentId: item.instrumentId
134
- })),
135
- waitingClose: resolveCandlesWaitingClose(candles)
136
- }
137
- : undefined,
138
- subscribeOrderBookRequest: orderBooks.length > 0
139
- ? {
140
- subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
141
- instruments: orderBooks.map((item) => marketdata_1.OrderBookInstrument.create({
142
- depth: item.depth,
143
- instrumentId: item.instrumentId,
144
- orderBookType: marketdata_1.OrderBookType.ORDERBOOK_TYPE_UNSPECIFIED
145
- }))
146
- }
147
- : undefined,
148
- subscribeTradesRequest: trades.length > 0
149
- ? {
150
- subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
151
- instruments: trades.map((item) => marketdata_1.TradeInstrument.create({
152
- instrumentId: item.instrumentId
153
- })),
154
- tradeSource: marketdata_1.TradeSourceType.TRADE_SOURCE_UNSPECIFIED,
155
- withOpenInterest: false
156
- }
157
- : undefined,
158
- subscribeInfoRequest: info.length > 0
159
- ? {
160
- subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
161
- instruments: info.map((item) => marketdata_1.InfoInstrument.create({
162
- instrumentId: item.instrumentId
163
- }))
164
- }
165
- : undefined,
166
- subscribeLastPriceRequest: lastPrices.length > 0
167
- ? {
168
- subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
169
- instruments: lastPrices.map((item) => marketdata_1.LastPriceInstrument.create({
170
- instrumentId: item.instrumentId
171
- }))
172
- }
173
- : undefined,
174
- pingSettings: undefined
175
- };
176
- }
177
- function createPortfolioStreamRequest(config) {
178
- if (config.stream !== 'operations.portfolioStream') {
179
- throw new icore_1.CliUsageError(`Expected portfolio stream config, got '${config.stream}'`);
180
- }
181
- return {
182
- accounts: config.accounts ?? [],
183
- pingSettings: undefined
184
- };
185
- }
186
- function createPositionsStreamRequest(config) {
187
- if (config.stream !== 'operations.positionsStream') {
188
- throw new icore_1.CliUsageError(`Expected positions stream config, got '${config.stream}'`);
189
- }
190
- return {
191
- accounts: config.accounts ?? [],
192
- withInitialPositions: false,
193
- pingSettings: undefined
194
- };
195
- }
196
- function createTradesStreamRequest(config) {
197
- if (config.stream !== 'orders.tradesStream') {
198
- throw new icore_1.CliUsageError(`Expected trades stream config, got '${config.stream}'`);
199
- }
200
- return {
201
- accounts: config.accounts ?? []
202
- };
203
- }
204
104
  function parseStreamName(value) {
205
105
  if (typeof value !== 'string') {
206
106
  throw new icore_1.CliUsageError("Expected 'stream' as string");
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Модуль преобразует проверенный stream config в generated requests.
3
+ *
4
+ * Здесь не должно быть чтения JSON, SDK calls или управления stream lifecycle.
5
+ */
6
+ import { type MarketDataRequest, type MarketDataServerSideStreamRequest } from '../../../generated/marketdata';
7
+ import type { PortfolioStreamRequest, PositionsStreamRequest } from '../../../generated/operations';
8
+ import type { TradesStreamRequest } from '../../../generated/orders';
9
+ import { type StreamRunConfig } from './config';
10
+ export declare function createMarketDataStreamRequests(config: StreamRunConfig): MarketDataRequest[];
11
+ export declare function createMarketDataServerSideStreamRequest(config: StreamRunConfig): MarketDataServerSideStreamRequest;
12
+ export declare function createPortfolioStreamRequest(config: StreamRunConfig): PortfolioStreamRequest;
13
+ export declare function createPositionsStreamRequest(config: StreamRunConfig): PositionsStreamRequest;
14
+ export declare function createTradesStreamRequest(config: StreamRunConfig): TradesStreamRequest;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /**
3
+ * Модуль преобразует проверенный stream config в generated requests.
4
+ *
5
+ * Здесь не должно быть чтения JSON, SDK calls или управления stream lifecycle.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.createMarketDataStreamRequests = createMarketDataStreamRequests;
9
+ exports.createMarketDataServerSideStreamRequest = createMarketDataServerSideStreamRequest;
10
+ exports.createPortfolioStreamRequest = createPortfolioStreamRequest;
11
+ exports.createPositionsStreamRequest = createPositionsStreamRequest;
12
+ exports.createTradesStreamRequest = createTradesStreamRequest;
13
+ const marketdata_1 = require("../../../generated/marketdata");
14
+ const icore_1 = require("icore");
15
+ const config_1 = require("./config");
16
+ function createMarketDataStreamRequests(config) {
17
+ if (config.stream !== 'marketdata.marketDataStream') {
18
+ throw new icore_1.CliUsageError(`Expected marketdata bidirectional stream config, got '${config.stream}'`);
19
+ }
20
+ return config.requests ?? [];
21
+ }
22
+ function createMarketDataServerSideStreamRequest(config) {
23
+ if (config.stream !== 'marketdata.marketDataServerSideStream') {
24
+ throw new icore_1.CliUsageError(`Expected marketdata server-side stream config, got '${config.stream}'`);
25
+ }
26
+ const subscriptions = config.subscriptions;
27
+ if (!subscriptions) {
28
+ throw new icore_1.CliUsageError("Expected 'subscriptions' for marketdata server-side stream config");
29
+ }
30
+ const candles = subscriptions.candles ?? [];
31
+ const orderBooks = subscriptions.orderBooks ?? [];
32
+ const trades = subscriptions.trades ?? [];
33
+ const info = subscriptions.info ?? [];
34
+ const lastPrices = subscriptions.lastPrices ?? [];
35
+ return {
36
+ subscribeCandlesRequest: candles.length > 0
37
+ ? {
38
+ subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
39
+ instruments: candles.map((item) => marketdata_1.CandleInstrument.create({
40
+ interval: item.interval,
41
+ instrumentId: item.instrumentId
42
+ })),
43
+ waitingClose: (0, config_1.resolveCandlesWaitingClose)(candles)
44
+ }
45
+ : undefined,
46
+ subscribeOrderBookRequest: orderBooks.length > 0
47
+ ? {
48
+ subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
49
+ instruments: orderBooks.map((item) => marketdata_1.OrderBookInstrument.create({
50
+ depth: item.depth,
51
+ instrumentId: item.instrumentId,
52
+ orderBookType: marketdata_1.OrderBookType.ORDERBOOK_TYPE_UNSPECIFIED
53
+ }))
54
+ }
55
+ : undefined,
56
+ subscribeTradesRequest: trades.length > 0
57
+ ? {
58
+ subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
59
+ instruments: trades.map((item) => marketdata_1.TradeInstrument.create({
60
+ instrumentId: item.instrumentId
61
+ })),
62
+ tradeSource: marketdata_1.TradeSourceType.TRADE_SOURCE_UNSPECIFIED,
63
+ withOpenInterest: false
64
+ }
65
+ : undefined,
66
+ subscribeInfoRequest: info.length > 0
67
+ ? {
68
+ subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
69
+ instruments: info.map((item) => marketdata_1.InfoInstrument.create({
70
+ instrumentId: item.instrumentId
71
+ }))
72
+ }
73
+ : undefined,
74
+ subscribeLastPriceRequest: lastPrices.length > 0
75
+ ? {
76
+ subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
77
+ instruments: lastPrices.map((item) => marketdata_1.LastPriceInstrument.create({
78
+ instrumentId: item.instrumentId
79
+ }))
80
+ }
81
+ : undefined,
82
+ pingSettings: undefined
83
+ };
84
+ }
85
+ function createPortfolioStreamRequest(config) {
86
+ if (config.stream !== 'operations.portfolioStream') {
87
+ throw new icore_1.CliUsageError(`Expected portfolio stream config, got '${config.stream}'`);
88
+ }
89
+ return {
90
+ accounts: config.accounts ?? [],
91
+ pingSettings: undefined
92
+ };
93
+ }
94
+ function createPositionsStreamRequest(config) {
95
+ if (config.stream !== 'operations.positionsStream') {
96
+ throw new icore_1.CliUsageError(`Expected positions stream config, got '${config.stream}'`);
97
+ }
98
+ return {
99
+ accounts: config.accounts ?? [],
100
+ withInitialPositions: false,
101
+ pingSettings: undefined
102
+ };
103
+ }
104
+ function createTradesStreamRequest(config) {
105
+ if (config.stream !== 'orders.tradesStream') {
106
+ throw new icore_1.CliUsageError(`Expected trades stream config, got '${config.stream}'`);
107
+ }
108
+ return {
109
+ accounts: config.accounts ?? []
110
+ };
111
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Модуль управляет lifecycle одной stream-сессии.
3
+ *
4
+ * Здесь допустимы выбор stream method, session-owned AbortController,
5
+ * ограничения по времени/числу событий и гарантированное закрытие SDK.
6
+ *
7
+ * Здесь не должно быть чтения config, CLI option schema или JSONL mapping.
8
+ */
9
+ import type { TInvestCallOptions } from '../../../application/dto/t-invest-services';
10
+ import type { TInvestOptions } from '../../../application/dto/t-invest-options';
11
+ import type { MarketDataRequest, MarketDataResponse, MarketDataServerSideStreamRequest } from '../../../generated/marketdata';
12
+ import type { PortfolioStreamRequest, PortfolioStreamResponse, PositionsStreamRequest, PositionsStreamResponse } from '../../../generated/operations';
13
+ import type { TradesStreamRequest, TradesStreamResponse } from '../../../generated/orders';
14
+ import type { StreamRunConfig, StreamRunRuntime } from './config';
15
+ export type StreamRunSdk = {
16
+ marketdataStream: {
17
+ marketDataStream(request: AsyncIterable<MarketDataRequest>, options?: TInvestCallOptions): AsyncIterable<MarketDataResponse>;
18
+ marketDataServerSideStream(request: MarketDataServerSideStreamRequest, options?: TInvestCallOptions): AsyncIterable<MarketDataResponse>;
19
+ };
20
+ operationsStream: {
21
+ portfolioStream(request: PortfolioStreamRequest, options?: TInvestCallOptions): AsyncIterable<PortfolioStreamResponse>;
22
+ positionsStream(request: PositionsStreamRequest, options?: TInvestCallOptions): AsyncIterable<PositionsStreamResponse>;
23
+ };
24
+ ordersStream: {
25
+ tradesStream(request: TradesStreamRequest, options?: TInvestCallOptions): AsyncIterable<TradesStreamResponse>;
26
+ };
27
+ close(): void;
28
+ };
29
+ export type StreamRunSdkFactory = (options: TInvestOptions) => StreamRunSdk;
30
+ export type StreamRunClock = () => Date;
31
+ export type StreamRunElapsedClock = () => number;
32
+ export interface StreamRunSessionDependencies {
33
+ readonly createSdk: StreamRunSdkFactory;
34
+ readonly now: StreamRunClock;
35
+ readonly elapsedNow: StreamRunElapsedClock;
36
+ }
37
+ export declare function runStreamRunSession(config: StreamRunConfig, runtime: StreamRunRuntime, sdkOptions: TInvestOptions, dependencies: StreamRunSessionDependencies): AsyncIterable<string>;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ /**
3
+ * Модуль управляет lifecycle одной stream-сессии.
4
+ *
5
+ * Здесь допустимы выбор stream method, session-owned AbortController,
6
+ * ограничения по времени/числу событий и гарантированное закрытие SDK.
7
+ *
8
+ * Здесь не должно быть чтения config, CLI option schema или JSONL mapping.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.runStreamRunSession = runStreamRunSession;
12
+ const request_mapper_1 = require("./request.mapper");
13
+ const reporter_1 = require("./reporter");
14
+ const maxTimerDelayMs = 2_147_483_647;
15
+ const streamReadTimedOut = Symbol('streamReadTimedOut');
16
+ function runStreamRunSession(config, runtime, sdkOptions, dependencies) {
17
+ return (async function* streamRunSession() {
18
+ const sdk = dependencies.createSdk(sdkOptions);
19
+ const controller = new AbortController();
20
+ try {
21
+ const responses = createStreamResponses(config, sdk, controller.signal);
22
+ yield* formatStreamRunResponses(config.stream, responses, runtime, dependencies.now, dependencies.elapsedNow, () => {
23
+ controller.abort();
24
+ });
25
+ }
26
+ finally {
27
+ controller.abort();
28
+ sdk.close();
29
+ }
30
+ })();
31
+ }
32
+ function createStreamResponses(config, sdk, signal) {
33
+ const callOptions = {
34
+ signal
35
+ };
36
+ switch (config.stream) {
37
+ case 'marketdata.marketDataStream':
38
+ return sdk.marketdataStream.marketDataStream(createInitialMarketDataRequestStream((0, request_mapper_1.createMarketDataStreamRequests)(config)), callOptions);
39
+ case 'marketdata.marketDataServerSideStream':
40
+ return sdk.marketdataStream.marketDataServerSideStream((0, request_mapper_1.createMarketDataServerSideStreamRequest)(config), callOptions);
41
+ case 'operations.portfolioStream':
42
+ return sdk.operationsStream.portfolioStream((0, request_mapper_1.createPortfolioStreamRequest)(config), callOptions);
43
+ case 'operations.positionsStream':
44
+ return sdk.operationsStream.positionsStream((0, request_mapper_1.createPositionsStreamRequest)(config), callOptions);
45
+ case 'orders.tradesStream':
46
+ return sdk.ordersStream.tradesStream((0, request_mapper_1.createTradesStreamRequest)(config), callOptions);
47
+ }
48
+ }
49
+ async function* createInitialMarketDataRequestStream(requests) {
50
+ for (const request of requests) {
51
+ yield request;
52
+ }
53
+ }
54
+ async function* formatStreamRunResponses(stream, responses, runtime, now, elapsedNow, cancelStream) {
55
+ const iterator = responses[Symbol.asyncIterator]();
56
+ const startedAt = elapsedNow();
57
+ let lastResponseAt = startedAt;
58
+ let sequence = 1;
59
+ let emittedEvents = 0;
60
+ let pendingRead;
61
+ try {
62
+ while (true) {
63
+ const timeoutMs = resolveNextTimeoutMs(startedAt, lastResponseAt, runtime, elapsedNow);
64
+ if (timeoutMs !== undefined && timeoutMs <= 0) {
65
+ break;
66
+ }
67
+ pendingRead = iterator.next();
68
+ const result = await readNextWithTimeout(pendingRead, timeoutMs, elapsedNow);
69
+ if (result === streamReadTimedOut) {
70
+ cancelStream();
71
+ await settleCancelledRead(pendingRead);
72
+ pendingRead = undefined;
73
+ break;
74
+ }
75
+ pendingRead = undefined;
76
+ if (result.done) {
77
+ break;
78
+ }
79
+ lastResponseAt = elapsedNow();
80
+ const line = (0, reporter_1.formatStreamRunResponse)(result.value, {
81
+ stream,
82
+ sequence,
83
+ receivedAt: now().toISOString(),
84
+ includePings: runtime.includePings,
85
+ includeSubscriptionEvents: runtime.includeSubscriptionEvents,
86
+ raw: runtime.raw
87
+ });
88
+ if (line === undefined) {
89
+ continue;
90
+ }
91
+ yield line;
92
+ sequence += 1;
93
+ emittedEvents += 1;
94
+ if (runtime.maxEvents !== undefined && emittedEvents >= runtime.maxEvents) {
95
+ break;
96
+ }
97
+ }
98
+ }
99
+ finally {
100
+ cancelStream();
101
+ if (pendingRead !== undefined) {
102
+ await settleCancelledRead(pendingRead);
103
+ }
104
+ await iterator.return?.();
105
+ }
106
+ }
107
+ function resolveNextTimeoutMs(startedAt, lastResponseAt, runtime, elapsedNow) {
108
+ const now = elapsedNow();
109
+ const remainingTimeouts = [
110
+ runtime.durationMs === undefined ? undefined : runtime.durationMs - (now - startedAt),
111
+ runtime.idleTimeoutMs === undefined ? undefined : runtime.idleTimeoutMs - (now - lastResponseAt)
112
+ ].filter((value) => value !== undefined);
113
+ if (remainingTimeouts.length === 0) {
114
+ return undefined;
115
+ }
116
+ return Math.min(...remainingTimeouts);
117
+ }
118
+ async function readNextWithTimeout(next, timeoutMs, elapsedNow) {
119
+ if (timeoutMs === undefined) {
120
+ return next;
121
+ }
122
+ const deadline = elapsedNow() + timeoutMs;
123
+ let timeout;
124
+ const timedOut = new Promise((resolve) => {
125
+ const schedule = () => {
126
+ const remaining = deadline - elapsedNow();
127
+ if (remaining <= 0) {
128
+ resolve(streamReadTimedOut);
129
+ return;
130
+ }
131
+ timeout = setTimeout(schedule, Math.min(remaining, maxTimerDelayMs));
132
+ };
133
+ schedule();
134
+ });
135
+ try {
136
+ return await Promise.race([next, timedOut]);
137
+ }
138
+ finally {
139
+ if (timeout !== undefined) {
140
+ clearTimeout(timeout);
141
+ }
142
+ }
143
+ }
144
+ async function settleCancelledRead(read) {
145
+ try {
146
+ await read;
147
+ }
148
+ catch {
149
+ // Основной результат чтения уже определён до cleanup; ошибка после отмены
150
+ // сессии не должна подменять timeout или ранее полученную provider error.
151
+ }
152
+ }
@@ -4,7 +4,7 @@
4
4
  * Здесь допустимы:
5
5
  * - объявление command path и option schema;
6
6
  * - преобразование CLI options в generated request;
7
- * - создание SDK через bootstrap factory и закрытие SDK resource;
7
+ * - выполнение короткого SDK lifecycle через общий bootstrap helper;
8
8
  *
9
9
  * Здесь не должно быть ручного table/json rendering или application report contracts.
10
10
  */
@@ -12,7 +12,6 @@ import type { TInvestOptions } from '../../../application/dto/t-invest-options';
12
12
  import type { TradingSchedulesRequest, TradingSchedulesResponse } from '../../../generated/instruments';
13
13
  import { type InferOptions } from 'icore';
14
14
  import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatTradingSchedules } from './reporter';
16
15
  type TradingSchedulesSdk = {
17
16
  instruments: {
18
17
  tradingSchedules(request: TradingSchedulesRequest): Promise<TradingSchedulesResponse>;
@@ -116,5 +115,5 @@ export declare const tradingSchedulesCommand: Omit<import("icore").CommandDefini
116
115
  }, undefined, string, readonly ["instrument", "schedules"], undefined, void, readonly []>, "metadata"> & {
117
116
  metadata?: undefined;
118
117
  };
119
- export { formatTradingSchedules };
120
118
  export declare function createTradingSchedulesRequest(options: TradingSchedulesRequestOptions): TradingSchedulesRequest;
119
+ export {};
@@ -5,21 +5,20 @@
5
5
  * Здесь допустимы:
6
6
  * - объявление command path и option schema;
7
7
  * - преобразование CLI options в generated request;
8
- * - создание SDK через bootstrap factory и закрытие SDK resource;
8
+ * - выполнение короткого SDK lifecycle через общий bootstrap helper;
9
9
  *
10
10
  * Здесь не должно быть ручного table/json rendering или application report contracts.
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.formatTradingSchedules = exports.tradingSchedulesCommand = void 0;
13
+ exports.tradingSchedulesCommand = void 0;
14
14
  exports.createTradingSchedulesCommand = createTradingSchedulesCommand;
15
15
  exports.createTradingSchedulesRequest = createTradingSchedulesRequest;
16
16
  const icore_1 = require("icore");
17
17
  const contract_1 = require("../../cli/contract");
18
- const args_1 = require("../../args");
18
+ const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
19
19
  const command_options_1 = require("../../args/command-options");
20
20
  const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
21
21
  const reporter_1 = require("./reporter");
22
- Object.defineProperty(exports, "formatTradingSchedules", { enumerable: true, get: function () { return reporter_1.formatTradingSchedules; } });
23
22
  const tradingSchedulesCommandPath = ['instrument', 'schedules'];
24
23
  const defaultTradingSchedulesSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
25
24
  const tradingSchedulesRequestOptionsSchema = {
@@ -56,14 +55,10 @@ exports.tradingSchedulesCommand = createTradingSchedulesCommand();
56
55
  async function runTradingSchedulesCommand(options, createSdk) {
57
56
  const request = createTradingSchedulesRequest(options);
58
57
  const { format } = options;
59
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
60
- try {
58
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
61
59
  const response = await sdk.instruments.tradingSchedules(request);
62
60
  return (0, reporter_1.formatTradingSchedules)(response.exchanges, format);
63
- }
64
- finally {
65
- sdk.close();
66
- }
61
+ });
67
62
  }
68
63
  function createTradingSchedulesRequest(options) {
69
64
  const from = (0, command_options_1.parseDateTimeOption)(options.from, 'from');
@@ -4,7 +4,7 @@
4
4
  * Здесь допустимы:
5
5
  * - объявление command path и option schema;
6
6
  * - преобразование CLI options в generated request;
7
- * - создание SDK через bootstrap factory и закрытие SDK resource;
7
+ * - выполнение короткого SDK lifecycle через общий bootstrap helper;
8
8
  *
9
9
  * Здесь не должно быть ручного table/json rendering или application report contracts.
10
10
  */
@@ -12,9 +12,8 @@ import type { TInvestOptions } from '../../../application/dto/t-invest-options';
12
12
  import { GetTradingStatusRequest, type GetTradingStatusResponse } from '../../../generated/marketdata';
13
13
  import type { InferOptions } from 'icore';
14
14
  import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatTradingStatus } from './reporter';
16
15
  type TradingStatusSdk = {
17
- marketdata: {
16
+ marketData: {
18
17
  getTradingStatus(request: GetTradingStatusRequest): Promise<GetTradingStatusResponse>;
19
18
  };
20
19
  close(): void;
@@ -95,5 +94,5 @@ export declare const tradingStatusCommand: Omit<import("icore").CommandDefinitio
95
94
  }, undefined, string, readonly ["market", "status"], undefined, void, readonly []>, "metadata"> & {
96
95
  metadata?: undefined;
97
96
  };
98
- export { formatTradingStatus };
99
97
  export declare function createTradingStatusRequest(options: TradingStatusRequestOptions): GetTradingStatusRequest;
98
+ export {};
@@ -5,21 +5,20 @@
5
5
  * Здесь допустимы:
6
6
  * - объявление command path и option schema;
7
7
  * - преобразование CLI options в generated request;
8
- * - создание SDK через bootstrap factory и закрытие SDK resource;
8
+ * - выполнение короткого SDK lifecycle через общий bootstrap helper;
9
9
  *
10
10
  * Здесь не должно быть ручного table/json rendering или application report contracts.
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.formatTradingStatus = exports.tradingStatusCommand = void 0;
13
+ exports.tradingStatusCommand = void 0;
14
14
  exports.createTradingStatusCommand = createTradingStatusCommand;
15
15
  exports.createTradingStatusRequest = createTradingStatusRequest;
16
16
  const marketdata_1 = require("../../../generated/marketdata");
17
17
  const contract_1 = require("../../cli/contract");
18
- const args_1 = require("../../args");
18
+ const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
19
19
  const command_options_1 = require("../../args/command-options");
20
20
  const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
21
21
  const reporter_1 = require("./reporter");
22
- Object.defineProperty(exports, "formatTradingStatus", { enumerable: true, get: function () { return reporter_1.formatTradingStatus; } });
23
22
  const tradingStatusCommandPath = ['market', 'status'];
24
23
  const defaultTradingStatusSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
25
24
  const tradingStatusRequestOptionsSchema = {
@@ -49,14 +48,10 @@ exports.tradingStatusCommand = createTradingStatusCommand();
49
48
  async function runTradingStatusCommand(options, createSdk) {
50
49
  const request = createTradingStatusRequest(options);
51
50
  const { format } = options;
52
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
53
- try {
54
- const response = await sdk.marketdata.getTradingStatus(request);
51
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
52
+ const response = await sdk.marketData.getTradingStatus(request);
55
53
  return (0, reporter_1.formatTradingStatus)(response, format);
56
- }
57
- finally {
58
- sdk.close();
59
- }
54
+ });
60
55
  }
61
56
  function createTradingStatusRequest(options) {
62
57
  return marketdata_1.GetTradingStatusRequest.create({
@@ -4,7 +4,7 @@
4
4
  * Здесь допустимы:
5
5
  * - объявление command path и option schema;
6
6
  * - преобразование CLI options в generated request;
7
- * - создание SDK через bootstrap factory и закрытие SDK resource;
7
+ * - выполнение короткого SDK lifecycle через общий bootstrap helper;
8
8
  *
9
9
  * Здесь не должно быть ручного table/json rendering или application report contracts.
10
10
  */
@@ -12,9 +12,8 @@ import type { TInvestOptions } from '../../../application/dto/t-invest-options';
12
12
  import type { GetTradingStatusesRequest, GetTradingStatusesResponse } from '../../../generated/marketdata';
13
13
  import type { InferOptions } from 'icore';
14
14
  import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatTradingStatuses } from './reporter';
16
15
  type TradingStatusesSdk = {
17
- marketdata: {
16
+ marketData: {
18
17
  getTradingStatuses(request: GetTradingStatusesRequest): Promise<GetTradingStatusesResponse>;
19
18
  };
20
19
  close(): void;
@@ -95,5 +94,5 @@ export declare const tradingStatusesCommand: Omit<import("icore").CommandDefinit
95
94
  }, undefined, string, readonly ["market", "statuses"], undefined, void, readonly []>, "metadata"> & {
96
95
  metadata?: undefined;
97
96
  };
98
- export { formatTradingStatuses };
99
97
  export declare function createTradingStatusesRequest(options: TradingStatusesRequestOptions): GetTradingStatusesRequest;
98
+ export {};
@@ -5,20 +5,19 @@
5
5
  * Здесь допустимы:
6
6
  * - объявление command path и option schema;
7
7
  * - преобразование CLI options в generated request;
8
- * - создание SDK через bootstrap factory и закрытие SDK resource;
8
+ * - выполнение короткого SDK lifecycle через общий bootstrap helper;
9
9
  *
10
10
  * Здесь не должно быть ручного table/json rendering или application report contracts.
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.formatTradingStatuses = exports.tradingStatusesCommand = void 0;
13
+ exports.tradingStatusesCommand = void 0;
14
14
  exports.createTradingStatusesCommand = createTradingStatusesCommand;
15
15
  exports.createTradingStatusesRequest = createTradingStatusesRequest;
16
16
  const contract_1 = require("../../cli/contract");
17
- const args_1 = require("../../args");
17
+ const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
18
18
  const command_options_1 = require("../../args/command-options");
19
19
  const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
20
20
  const reporter_1 = require("./reporter");
21
- Object.defineProperty(exports, "formatTradingStatuses", { enumerable: true, get: function () { return reporter_1.formatTradingStatuses; } });
22
21
  const tradingStatusesCommandPath = ['market', 'statuses'];
23
22
  const defaultTradingStatusesSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
24
23
  const tradingStatusesInstrumentIdsOptionsSchema = {
@@ -48,14 +47,10 @@ exports.tradingStatusesCommand = createTradingStatusesCommand();
48
47
  async function runTradingStatusesCommand(options, createSdk) {
49
48
  const request = createTradingStatusesRequest(options);
50
49
  const { format } = options;
51
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
52
- try {
53
- const response = await sdk.marketdata.getTradingStatuses(request);
50
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
51
+ const response = await sdk.marketData.getTradingStatuses(request);
54
52
  return (0, reporter_1.formatTradingStatuses)(response, format);
55
- }
56
- finally {
57
- sdk.close();
58
- }
53
+ });
59
54
  }
60
55
  function createTradingStatusesRequest(options) {
61
56
  return {
@@ -4,13 +4,12 @@
4
4
  * Здесь допустимы:
5
5
  * - объявление command path и option schema;
6
6
  * - преобразование CLI options в generated request;
7
- * - создание SDK через bootstrap factory и закрытие SDK resource;
7
+ * - выполнение короткого SDK lifecycle через общий bootstrap helper;
8
8
  *
9
9
  * Здесь не должно быть ручного table/json rendering или application report contracts.
10
10
  */
11
11
  import type { TInvestOptions } from '../../../application/dto/t-invest-options';
12
12
  import type { GetInfoResponse } from '../../../generated/users';
13
- import { formatUserInfo } from './reporter';
14
13
  type UserInfoSdk = {
15
14
  users: {
16
15
  getInfo(request: Record<string, never>): Promise<GetInfoResponse>;
@@ -60,4 +59,4 @@ export declare const userInfoCommand: Omit<import("icore").CommandDefinition<{
60
59
  }, undefined, string, readonly ["account", "info"], undefined, void, readonly []>, "metadata"> & {
61
60
  metadata?: undefined;
62
61
  };
63
- export { formatUserInfo };
62
+ export {};