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

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 (227) hide show
  1. package/CHANGELOG.md +19 -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.js +9 -9
  5. package/dist/bootstrap/args/sdk-options.d.ts +1 -2
  6. package/dist/bootstrap/cli/help-catalog.d.ts +733 -0
  7. package/dist/bootstrap/cli/help-catalog.js +1649 -0
  8. package/dist/bootstrap/cli/help.d.ts +2 -730
  9. package/dist/bootstrap/cli/help.js +5 -1647
  10. package/dist/bootstrap/cli/registry.d.ts +6 -6
  11. package/dist/bootstrap/commands/accounts/cli.d.ts +2 -3
  12. package/dist/bootstrap/commands/accounts/cli.js +5 -10
  13. package/dist/bootstrap/commands/accrued-interests/cli.d.ts +2 -3
  14. package/dist/bootstrap/commands/accrued-interests/cli.js +5 -10
  15. package/dist/bootstrap/commands/asset/cli.d.ts +2 -3
  16. package/dist/bootstrap/commands/asset/cli.js +5 -10
  17. package/dist/bootstrap/commands/assets/cli.d.ts +2 -3
  18. package/dist/bootstrap/commands/assets/cli.js +5 -10
  19. package/dist/bootstrap/commands/bond/cli.d.ts +2 -3
  20. package/dist/bootstrap/commands/bond/cli.js +5 -10
  21. package/dist/bootstrap/commands/bond-coupons/cli.d.ts +2 -3
  22. package/dist/bootstrap/commands/bond-coupons/cli.js +5 -10
  23. package/dist/bootstrap/commands/bonds/cli.d.ts +2 -3
  24. package/dist/bootstrap/commands/bonds/cli.js +5 -10
  25. package/dist/bootstrap/commands/brand/cli.d.ts +2 -3
  26. package/dist/bootstrap/commands/brand/cli.js +5 -10
  27. package/dist/bootstrap/commands/brands/cli.d.ts +2 -3
  28. package/dist/bootstrap/commands/brands/cli.js +5 -10
  29. package/dist/bootstrap/commands/broker-report/cli.d.ts +2 -3
  30. package/dist/bootstrap/commands/broker-report/cli.js +5 -10
  31. package/dist/bootstrap/commands/cancel-order/cli.d.ts +3 -39
  32. package/dist/bootstrap/commands/cancel-order/cli.js +8 -19
  33. package/dist/bootstrap/commands/cancel-order/request.mapper.d.ts +7 -0
  34. package/dist/bootstrap/commands/cancel-order/request.mapper.js +9 -0
  35. package/dist/bootstrap/commands/cancel-stop-order/cli.d.ts +3 -4
  36. package/dist/bootstrap/commands/cancel-stop-order/cli.js +6 -11
  37. package/dist/bootstrap/commands/candles/cli.d.ts +3 -4
  38. package/dist/bootstrap/commands/candles/cli.js +6 -11
  39. package/dist/bootstrap/commands/close-prices/cli.d.ts +3 -4
  40. package/dist/bootstrap/commands/close-prices/cli.js +6 -11
  41. package/dist/bootstrap/commands/countries/cli.d.ts +2 -3
  42. package/dist/bootstrap/commands/countries/cli.js +5 -10
  43. package/dist/bootstrap/commands/currencies/cli.d.ts +2 -3
  44. package/dist/bootstrap/commands/currencies/cli.js +5 -10
  45. package/dist/bootstrap/commands/currency/cli.d.ts +2 -3
  46. package/dist/bootstrap/commands/currency/cli.js +5 -10
  47. package/dist/bootstrap/commands/dividends/cli.d.ts +2 -3
  48. package/dist/bootstrap/commands/dividends/cli.js +5 -10
  49. package/dist/bootstrap/commands/dividends-foreign-issuer/cli.d.ts +2 -3
  50. package/dist/bootstrap/commands/dividends-foreign-issuer/cli.js +5 -10
  51. package/dist/bootstrap/commands/edit-favorites/cli.d.ts +2 -3
  52. package/dist/bootstrap/commands/edit-favorites/cli.js +5 -10
  53. package/dist/bootstrap/commands/etf/cli.d.ts +2 -3
  54. package/dist/bootstrap/commands/etf/cli.js +5 -10
  55. package/dist/bootstrap/commands/etfs/cli.d.ts +2 -3
  56. package/dist/bootstrap/commands/etfs/cli.js +5 -10
  57. package/dist/bootstrap/commands/favorites/cli.d.ts +2 -3
  58. package/dist/bootstrap/commands/favorites/cli.js +5 -10
  59. package/dist/bootstrap/commands/find-instrument/cli.d.ts +2 -3
  60. package/dist/bootstrap/commands/find-instrument/cli.js +5 -10
  61. package/dist/bootstrap/commands/future/cli.d.ts +2 -3
  62. package/dist/bootstrap/commands/future/cli.js +5 -10
  63. package/dist/bootstrap/commands/futures/cli.d.ts +2 -3
  64. package/dist/bootstrap/commands/futures/cli.js +5 -10
  65. package/dist/bootstrap/commands/futures-margin/cli.d.ts +2 -3
  66. package/dist/bootstrap/commands/futures-margin/cli.js +5 -10
  67. package/dist/bootstrap/commands/instrument/cli.d.ts +2 -3
  68. package/dist/bootstrap/commands/instrument/cli.js +5 -10
  69. package/dist/bootstrap/commands/last-prices/cli.d.ts +3 -4
  70. package/dist/bootstrap/commands/last-prices/cli.js +6 -11
  71. package/dist/bootstrap/commands/last-trades/cli.d.ts +3 -4
  72. package/dist/bootstrap/commands/last-trades/cli.js +6 -11
  73. package/dist/bootstrap/commands/margin-attributes/cli.d.ts +2 -3
  74. package/dist/bootstrap/commands/margin-attributes/cli.js +5 -10
  75. package/dist/bootstrap/commands/operations/cli.d.ts +5 -53
  76. package/dist/bootstrap/commands/operations/cli.js +9 -36
  77. package/dist/bootstrap/commands/operations/request.mapper.d.ts +23 -0
  78. package/dist/bootstrap/commands/operations/request.mapper.js +33 -0
  79. package/dist/bootstrap/commands/operations-by-cursor/cli.d.ts +5 -69
  80. package/dist/bootstrap/commands/operations-by-cursor/cli.js +9 -74
  81. package/dist/bootstrap/commands/operations-by-cursor/request.mapper.d.ts +28 -0
  82. package/dist/bootstrap/commands/operations-by-cursor/request.mapper.js +70 -0
  83. package/dist/bootstrap/commands/option/cli.d.ts +2 -3
  84. package/dist/bootstrap/commands/option/cli.js +5 -10
  85. package/dist/bootstrap/commands/options-by/cli.d.ts +2 -3
  86. package/dist/bootstrap/commands/options-by/cli.js +5 -10
  87. package/dist/bootstrap/commands/order-book/cli.d.ts +3 -4
  88. package/dist/bootstrap/commands/order-book/cli.js +6 -11
  89. package/dist/bootstrap/commands/order-state/cli.d.ts +3 -36
  90. package/dist/bootstrap/commands/order-state/cli.js +8 -21
  91. package/dist/bootstrap/commands/order-state/request.mapper.d.ts +13 -0
  92. package/dist/bootstrap/commands/order-state/request.mapper.js +17 -0
  93. package/dist/bootstrap/commands/orders/cli.d.ts +3 -32
  94. package/dist/bootstrap/commands/orders/cli.js +8 -18
  95. package/dist/bootstrap/commands/orders/request.mapper.d.ts +6 -0
  96. package/dist/bootstrap/commands/orders/request.mapper.js +8 -0
  97. package/dist/bootstrap/commands/portfolio/cli.d.ts +6 -40
  98. package/dist/bootstrap/commands/portfolio/cli.js +9 -26
  99. package/dist/bootstrap/commands/portfolio/request.mapper.d.ts +18 -0
  100. package/dist/bootstrap/commands/portfolio/request.mapper.js +21 -0
  101. package/dist/bootstrap/commands/positions/cli.d.ts +3 -32
  102. package/dist/bootstrap/commands/positions/cli.js +8 -18
  103. package/dist/bootstrap/commands/positions/request.mapper.d.ts +6 -0
  104. package/dist/bootstrap/commands/positions/request.mapper.js +8 -0
  105. package/dist/bootstrap/commands/post-order/cli.d.ts +8 -68
  106. package/dist/bootstrap/commands/post-order/cli.js +9 -39
  107. package/dist/bootstrap/commands/post-order/request.mapper.d.ts +27 -0
  108. package/dist/bootstrap/commands/post-order/request.mapper.js +35 -0
  109. package/dist/bootstrap/commands/post-stop-order/cli.d.ts +3 -4
  110. package/dist/bootstrap/commands/post-stop-order/cli.js +6 -11
  111. package/dist/bootstrap/commands/replace-order/cli.d.ts +5 -61
  112. package/dist/bootstrap/commands/replace-order/cli.js +9 -30
  113. package/dist/bootstrap/commands/replace-order/request.mapper.d.ts +22 -0
  114. package/dist/bootstrap/commands/replace-order/request.mapper.js +26 -0
  115. package/dist/bootstrap/commands/sandbox-accounts/cli.d.ts +2 -3
  116. package/dist/bootstrap/commands/sandbox-accounts/cli.js +5 -10
  117. package/dist/bootstrap/commands/sandbox-cancel-order/cli.d.ts +3 -4
  118. package/dist/bootstrap/commands/sandbox-cancel-order/cli.js +8 -13
  119. package/dist/bootstrap/commands/sandbox-close-account/cli.d.ts +2 -3
  120. package/dist/bootstrap/commands/sandbox-close-account/cli.js +5 -10
  121. package/dist/bootstrap/commands/sandbox-open-account/cli.d.ts +2 -3
  122. package/dist/bootstrap/commands/sandbox-open-account/cli.js +5 -10
  123. package/dist/bootstrap/commands/sandbox-operations/cli.d.ts +3 -4
  124. package/dist/bootstrap/commands/sandbox-operations/cli.js +8 -13
  125. package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.d.ts +3 -4
  126. package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.js +8 -13
  127. package/dist/bootstrap/commands/sandbox-order-state/cli.d.ts +3 -4
  128. package/dist/bootstrap/commands/sandbox-order-state/cli.js +8 -13
  129. package/dist/bootstrap/commands/sandbox-orders/cli.d.ts +3 -4
  130. package/dist/bootstrap/commands/sandbox-orders/cli.js +8 -13
  131. package/dist/bootstrap/commands/sandbox-pay-in/cli.d.ts +2 -3
  132. package/dist/bootstrap/commands/sandbox-pay-in/cli.js +5 -10
  133. package/dist/bootstrap/commands/sandbox-portfolio/cli.d.ts +3 -4
  134. package/dist/bootstrap/commands/sandbox-portfolio/cli.js +8 -13
  135. package/dist/bootstrap/commands/sandbox-positions/cli.d.ts +3 -4
  136. package/dist/bootstrap/commands/sandbox-positions/cli.js +8 -13
  137. package/dist/bootstrap/commands/sandbox-post-order/cli.d.ts +3 -4
  138. package/dist/bootstrap/commands/sandbox-post-order/cli.js +8 -13
  139. package/dist/bootstrap/commands/sandbox-replace-order/cli.d.ts +3 -4
  140. package/dist/bootstrap/commands/sandbox-replace-order/cli.js +8 -13
  141. package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.d.ts +3 -4
  142. package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.js +8 -13
  143. package/dist/bootstrap/commands/sdk-command-lifecycle.d.ts +15 -0
  144. package/dist/bootstrap/commands/sdk-command-lifecycle.js +21 -0
  145. package/dist/bootstrap/commands/share/cli.d.ts +2 -3
  146. package/dist/bootstrap/commands/share/cli.js +5 -10
  147. package/dist/bootstrap/commands/shares/cli.d.ts +2 -3
  148. package/dist/bootstrap/commands/shares/cli.js +5 -10
  149. package/dist/bootstrap/commands/stop-orders/cli.d.ts +3 -4
  150. package/dist/bootstrap/commands/stop-orders/cli.js +6 -11
  151. package/dist/bootstrap/commands/stream-run/cli.d.ts +2 -24
  152. package/dist/bootstrap/commands/stream-run/cli.js +7 -142
  153. package/dist/bootstrap/commands/stream-run/config.d.ts +7 -15
  154. package/dist/bootstrap/commands/stream-run/config.js +1 -101
  155. package/dist/bootstrap/commands/stream-run/request.mapper.d.ts +14 -0
  156. package/dist/bootstrap/commands/stream-run/request.mapper.js +111 -0
  157. package/dist/bootstrap/commands/stream-run/stream-session.d.ts +37 -0
  158. package/dist/bootstrap/commands/stream-run/stream-session.js +152 -0
  159. package/dist/bootstrap/commands/trading-schedules/cli.d.ts +2 -3
  160. package/dist/bootstrap/commands/trading-schedules/cli.js +5 -10
  161. package/dist/bootstrap/commands/trading-status/cli.d.ts +3 -4
  162. package/dist/bootstrap/commands/trading-status/cli.js +6 -11
  163. package/dist/bootstrap/commands/trading-statuses/cli.d.ts +3 -4
  164. package/dist/bootstrap/commands/trading-statuses/cli.js +6 -11
  165. package/dist/bootstrap/commands/user-info/cli.d.ts +2 -3
  166. package/dist/bootstrap/commands/user-info/cli.js +5 -10
  167. package/dist/bootstrap/commands/user-tariff/cli.d.ts +2 -3
  168. package/dist/bootstrap/commands/user-tariff/cli.js +5 -10
  169. package/dist/bootstrap/commands/withdraw-limits/cli.d.ts +3 -32
  170. package/dist/bootstrap/commands/withdraw-limits/cli.js +8 -18
  171. package/dist/bootstrap/commands/withdraw-limits/request.mapper.d.ts +6 -0
  172. package/dist/bootstrap/commands/withdraw-limits/request.mapper.js +8 -0
  173. package/dist/bootstrap/index.js +2 -2
  174. package/dist/bootstrap/proto/compile-proto.d.ts +1 -1
  175. package/dist/bootstrap/proto/compile-proto.js +28 -35
  176. package/dist/bootstrap/t-invest-node-sdk.d.ts +9 -9
  177. package/dist/bootstrap/t-invest-node-sdk.js +33 -18
  178. package/dist/bootstrap/unary-limit-config.js +4 -4
  179. package/dist/generated/common.js +1 -1
  180. package/dist/generated/google/api/field_behavior.js +1 -1
  181. package/dist/generated/google/protobuf/descriptor.js +1 -1
  182. package/dist/generated/google/protobuf/timestamp.js +1 -1
  183. package/dist/generated/instruments.js +1 -1
  184. package/dist/generated/marketdata.js +1 -1
  185. package/dist/generated/operations.js +1 -1
  186. package/dist/generated/orders.js +1 -1
  187. package/dist/generated/sandbox.js +1 -1
  188. package/dist/generated/signals.js +1 -1
  189. package/dist/generated/stoporders.js +1 -1
  190. package/dist/generated/users.js +1 -1
  191. package/dist/infrastructure/interceptor/warning-interceptor.d.ts +1 -1
  192. package/dist/infrastructure/interceptor/warning-interceptor.js +2 -2
  193. package/dist/infrastructure/transport/grpc/sdk-call-error.d.ts +12 -0
  194. package/dist/infrastructure/transport/grpc/sdk-call-error.js +180 -0
  195. package/dist/infrastructure/transport/grpc/sdk-client.d.ts +1 -1
  196. package/dist/infrastructure/transport/grpc/sdk-client.js +2 -2
  197. package/dist/infrastructure/transport/grpc/sdk-middleware.d.ts +1 -1
  198. package/dist/infrastructure/transport/grpc/sdk-middleware.js +8 -174
  199. package/dist/infrastructure/transport/grpc/unary-limit-resolver.d.ts +3 -1
  200. package/dist/infrastructure/transport/grpc/unary-limit-resolver.js +19 -18
  201. package/docs/architecture.md +44 -41
  202. package/docs/bundled-ca.md +12 -12
  203. package/docs/clean-architecture/adapters.md +15 -15
  204. package/docs/clean-architecture/api-commands.md +63 -52
  205. package/docs/clean-architecture/application.md +13 -13
  206. package/docs/clean-architecture/cli-output-boundaries.md +23 -23
  207. package/docs/clean-architecture/dto.md +9 -9
  208. package/docs/clean-architecture/index.md +13 -12
  209. package/docs/cli-stream-configuration.md +9 -9
  210. package/docs/cli-stream-reference.md +11 -11
  211. package/docs/guides/custom-unary-limiter.md +30 -30
  212. package/docs/guides/errors-and-lifecycle.md +10 -10
  213. package/docs/guides/getting-started.md +9 -9
  214. package/docs/guides/index.md +3 -3
  215. package/docs/guides/streams-and-cancellation.md +6 -6
  216. package/docs/guides/testing-with-service-definitions.md +4 -4
  217. package/docs/guides/unary-calls.md +8 -8
  218. package/docs/index.md +9 -9
  219. package/docs/limits-policy.md +10 -10
  220. package/docs/roadmap.md +12 -12
  221. package/docs/tls-policy.md +7 -7
  222. package/package.json +2 -1
  223. package/readme.md +42 -41
  224. package/dist/infrastructure/interceptor/index.d.ts +0 -1
  225. package/dist/infrastructure/interceptor/index.js +0 -17
  226. /package/dist/infrastructure/transport/grpc/{unary-limits.d.ts → unary-method-path.d.ts} +0 -0
  227. /package/dist/infrastructure/transport/grpc/{unary-limits.js → unary-method-path.js} +0 -0
@@ -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 InstrumentRequest, type InstrumentResponse } from '../../../generated/instruments';
13
- import { formatInstrument } from './reporter';
14
13
  type InstrumentSdk = {
15
14
  instruments: {
16
15
  getInstrumentBy(request: InstrumentRequest): Promise<InstrumentResponse>;
@@ -80,4 +79,4 @@ export declare const instrumentCommand: Omit<import("icore").CommandDefinition<{
80
79
  }, undefined, string, readonly ["instrument", "show"], undefined, void, readonly []>, "metadata"> & {
81
80
  metadata?: undefined;
82
81
  };
83
- export { formatInstrument };
82
+ 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.formatInstrument = exports.instrumentCommand = void 0;
13
+ exports.instrumentCommand = void 0;
14
14
  exports.createInstrumentCommand = createInstrumentCommand;
15
15
  const contract_1 = require("../../cli/contract");
16
- const args_1 = require("../../args");
16
+ const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
17
17
  const command_options_1 = require("../../args/command-options");
18
18
  const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
19
19
  const instruments_args_1 = require("../../args/instruments-args");
20
20
  const reporter_1 = require("./reporter");
21
- Object.defineProperty(exports, "formatInstrument", { enumerable: true, get: function () { return reporter_1.formatInstrument; } });
22
21
  const instrumentCommandPath = ['instrument', 'show'];
23
22
  const defaultInstrumentSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
24
23
  const instrumentFormatOptionsSchema = {
@@ -42,12 +41,8 @@ exports.instrumentCommand = createInstrumentCommand();
42
41
  async function runInstrumentCommand(options, createSdk) {
43
42
  const { format } = options;
44
43
  const request = (0, instruments_args_1.createInstrumentLookupRequestFromOptions)(options);
45
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
46
- try {
44
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
47
45
  const response = await sdk.instruments.getInstrumentBy(request);
48
46
  return (0, reporter_1.formatInstrument)(response, format);
49
- }
50
- finally {
51
- sdk.close();
52
- }
47
+ });
53
48
  }
@@ -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 { GetLastPricesRequest, type GetLastPricesResponse } from '../../../generated/marketdata';
13
13
  import type { InferOptions } from 'icore';
14
14
  import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatLastPrices } from './reporter';
16
15
  type LastPricesSdk = {
17
- marketdata: {
16
+ marketData: {
18
17
  getLastPrices(request: GetLastPricesRequest): Promise<GetLastPricesResponse>;
19
18
  };
20
19
  close(): void;
@@ -95,5 +94,5 @@ export declare const lastPricesCommand: Omit<import("icore").CommandDefinition<{
95
94
  }, undefined, string, readonly ["market", "last-prices"], undefined, void, readonly []>, "metadata"> & {
96
95
  metadata?: undefined;
97
96
  };
98
- export { formatLastPrices };
99
97
  export declare function createLastPricesRequest(options: LastPricesRequestOptions): GetLastPricesRequest;
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.formatLastPrices = exports.lastPricesCommand = void 0;
13
+ exports.lastPricesCommand = void 0;
14
14
  exports.createLastPricesCommand = createLastPricesCommand;
15
15
  exports.createLastPricesRequest = createLastPricesRequest;
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, "formatLastPrices", { enumerable: true, get: function () { return reporter_1.formatLastPrices; } });
23
22
  const lastPricesCommandPath = ['market', 'last-prices'];
24
23
  const defaultLastPricesSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
25
24
  const lastPricesInstrumentIdsOptionsSchema = {
@@ -49,14 +48,10 @@ exports.lastPricesCommand = createLastPricesCommand();
49
48
  async function runLastPricesCommand(options, createSdk) {
50
49
  const request = createLastPricesRequest(options);
51
50
  const { format } = options;
52
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
53
- try {
54
- const response = await sdk.marketdata.getLastPrices(request);
51
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
52
+ const response = await sdk.marketData.getLastPrices(request);
55
53
  return (0, reporter_1.formatLastPrices)(response.lastPrices, format);
56
- }
57
- finally {
58
- sdk.close();
59
- }
54
+ });
60
55
  }
61
56
  function createLastPricesRequest(options) {
62
57
  return marketdata_1.GetLastPricesRequest.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 { GetLastTradesRequest, type GetLastTradesResponse } from '../../../generated/marketdata';
13
13
  import { type InferOptions } from 'icore';
14
14
  import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatLastTrades } from './reporter';
16
15
  type LastTradesSdk = {
17
- marketdata: {
16
+ marketData: {
18
17
  getLastTrades(request: GetLastTradesRequest): Promise<GetLastTradesResponse>;
19
18
  };
20
19
  close(): void;
@@ -119,5 +118,5 @@ export declare const lastTradesCommand: Omit<import("icore").CommandDefinition<{
119
118
  }, undefined, string, readonly ["market", "trades"], undefined, void, readonly []>, "metadata"> & {
120
119
  metadata?: undefined;
121
120
  };
122
- export { formatLastTrades };
123
121
  export declare function createLastTradesRequest(options: LastTradesRequestOptions): GetLastTradesRequest;
122
+ export {};
@@ -5,22 +5,21 @@
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.formatLastTrades = exports.lastTradesCommand = void 0;
13
+ exports.lastTradesCommand = void 0;
14
14
  exports.createLastTradesCommand = createLastTradesCommand;
15
15
  exports.createLastTradesRequest = createLastTradesRequest;
16
16
  const marketdata_1 = require("../../../generated/marketdata");
17
17
  const icore_1 = require("icore");
18
18
  const contract_1 = require("../../cli/contract");
19
- const args_1 = require("../../args");
19
+ const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
20
20
  const command_options_1 = require("../../args/command-options");
21
21
  const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
22
22
  const reporter_1 = require("./reporter");
23
- Object.defineProperty(exports, "formatLastTrades", { enumerable: true, get: function () { return reporter_1.formatLastTrades; } });
24
23
  const lastTradesCommandPath = ['market', 'trades'];
25
24
  const defaultLastTradesSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
26
25
  const lastTradesRequestOptionsSchema = {
@@ -58,14 +57,10 @@ exports.lastTradesCommand = createLastTradesCommand();
58
57
  async function runLastTradesCommand(options, createSdk) {
59
58
  const request = createLastTradesRequest(options);
60
59
  const { format } = options;
61
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
62
- try {
63
- const response = await sdk.marketdata.getLastTrades(request);
60
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
61
+ const response = await sdk.marketData.getLastTrades(request);
64
62
  return (0, reporter_1.formatLastTrades)(response.trades, format);
65
- }
66
- finally {
67
- sdk.close();
68
- }
63
+ });
69
64
  }
70
65
  function createLastTradesRequest(options) {
71
66
  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,7 +12,6 @@ import type { TInvestOptions } from '../../../application/dto/t-invest-options';
12
12
  import type { GetMarginAttributesRequest, GetMarginAttributesResponse } from '../../../generated/users';
13
13
  import type { InferOptions } from 'icore';
14
14
  import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatMarginAttributes } from './reporter';
16
15
  type MarginAttributesSdk = {
17
16
  users: {
18
17
  getMarginAttributes(request: GetMarginAttributesRequest): Promise<GetMarginAttributesResponse>;
@@ -95,5 +94,5 @@ export declare const marginAttributesCommand: Omit<import("icore").CommandDefini
95
94
  }, undefined, string, readonly ["account", "margin"], undefined, void, readonly []>, "metadata"> & {
96
95
  metadata?: undefined;
97
96
  };
98
- export { formatMarginAttributes };
99
97
  export declare function createMarginAttributesRequest(options: MarginAttributesRequestOptions): GetMarginAttributesRequest;
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.formatMarginAttributes = exports.marginAttributesCommand = void 0;
13
+ exports.marginAttributesCommand = void 0;
14
14
  exports.createMarginAttributesCommand = createMarginAttributesCommand;
15
15
  exports.createMarginAttributesRequest = createMarginAttributesRequest;
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, "formatMarginAttributes", { enumerable: true, get: function () { return reporter_1.formatMarginAttributes; } });
22
21
  const marginAttributesCommandPath = ['account', 'margin'];
23
22
  const defaultMarginAttributesSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
24
23
  const marginAttributesRequestOptionsSchema = {
@@ -48,14 +47,10 @@ exports.marginAttributesCommand = createMarginAttributesCommand();
48
47
  async function runMarginAttributesCommand(options, createSdk) {
49
48
  const request = createMarginAttributesRequest(options);
50
49
  const { format } = options;
51
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
52
- try {
50
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
53
51
  const response = await sdk.users.getMarginAttributes(request);
54
52
  return (0, reporter_1.formatMarginAttributes)(response, format);
55
- }
56
- finally {
57
- sdk.close();
58
- }
53
+ });
59
54
  }
60
55
  function createMarginAttributesRequest(options) {
61
56
  return {
@@ -3,16 +3,13 @@
3
3
  *
4
4
  * Здесь допустимы:
5
5
  * - объявление command path и option schema;
6
- * - преобразование CLI options в generated request;
7
- * - создание SDK через bootstrap factory и закрытие SDK resource;
6
+ * - делегирование request mapping в command-owned mapper;
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 OperationsRequest, type OperationsResponse } from '../../../generated/operations';
13
- import { type InferOptions } from 'icore';
14
- import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatOperations } from './reporter';
16
13
  type OperationsSdk = {
17
14
  operations: {
18
15
  getOperations(request: OperationsRequest): Promise<OperationsResponse>;
@@ -20,50 +17,6 @@ type OperationsSdk = {
20
17
  close(): void;
21
18
  };
22
19
  type OperationsSdkFactory = (options: TInvestOptions) => OperationsSdk;
23
- declare const operationsOptionsSchema: {
24
- readonly token: {
25
- readonly type: 'string';
26
- };
27
- readonly endpoint: {
28
- readonly type: 'string';
29
- };
30
- readonly 'app-name': {
31
- readonly type: 'string';
32
- };
33
- readonly insecure: {
34
- readonly type: 'boolean';
35
- };
36
- readonly 'instrument-id': {
37
- readonly type: 'string';
38
- };
39
- readonly figi: {
40
- readonly type: 'string';
41
- };
42
- readonly state: {
43
- readonly type: 'string';
44
- readonly choices: ("canceled" | "executed" | "progress" | "unspecified")[];
45
- readonly default: 'unspecified';
46
- };
47
- readonly 'account-id': {
48
- readonly type: 'string';
49
- readonly required: true;
50
- };
51
- readonly from: {
52
- readonly type: 'string';
53
- readonly required: true;
54
- };
55
- readonly to: {
56
- readonly type: 'string';
57
- readonly required: true;
58
- };
59
- readonly format: {
60
- readonly type: 'string';
61
- readonly choices: readonly ["json", "table"];
62
- readonly default: 'table';
63
- };
64
- };
65
- type OperationsOptions = InferOptions<typeof operationsOptionsSchema>;
66
- type OperationsRequestOptions = CommandRequestOptions<OperationsOptions, 'account-id' | 'from' | 'to' | 'state' | 'instrument-id' | 'figi'>;
67
20
  export declare function createOperationsCommand(createSdk?: OperationsSdkFactory): Omit<import("icore").CommandDefinition<{
68
21
  readonly token: {
69
22
  readonly type: 'string';
@@ -85,7 +38,7 @@ export declare function createOperationsCommand(createSdk?: OperationsSdkFactory
85
38
  };
86
39
  readonly state: {
87
40
  readonly type: 'string';
88
- readonly choices: ("canceled" | "executed" | "progress" | "unspecified")[];
41
+ readonly choices: readonly ["unspecified", "executed", "canceled", "progress"];
89
42
  readonly default: 'unspecified';
90
43
  };
91
44
  readonly 'account-id': {
@@ -129,7 +82,7 @@ export declare const operationsCommand: Omit<import("icore").CommandDefinition<{
129
82
  };
130
83
  readonly state: {
131
84
  readonly type: 'string';
132
- readonly choices: ("canceled" | "executed" | "progress" | "unspecified")[];
85
+ readonly choices: readonly ["unspecified", "executed", "canceled", "progress"];
133
86
  readonly default: 'unspecified';
134
87
  };
135
88
  readonly 'account-id': {
@@ -152,5 +105,4 @@ export declare const operationsCommand: Omit<import("icore").CommandDefinition<{
152
105
  }, undefined, string, readonly ["operation", "list"], undefined, void, readonly []>, "metadata"> & {
153
106
  metadata?: undefined;
154
107
  };
155
- export { formatOperations };
156
- export declare function createOperationsRequest(options: OperationsRequestOptions): OperationsRequest;
108
+ export {};
@@ -4,33 +4,24 @@
4
4
  *
5
5
  * Здесь допустимы:
6
6
  * - объявление command path и option schema;
7
- * - преобразование CLI options в generated request;
8
- * - создание SDK через bootstrap factory и закрытие SDK resource;
7
+ * - делегирование request mapping в command-owned mapper;
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.formatOperations = exports.operationsCommand = void 0;
13
+ exports.operationsCommand = void 0;
14
14
  exports.createOperationsCommand = createOperationsCommand;
15
- exports.createOperationsRequest = createOperationsRequest;
16
- const operations_1 = require("../../../generated/operations");
17
- const icore_1 = require("icore");
18
15
  const contract_1 = require("../../cli/contract");
19
- const args_1 = require("../../args");
16
+ const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
20
17
  const command_options_1 = require("../../args/command-options");
21
18
  const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
22
19
  const instrument_id_options_1 = require("../../args/instrument-id-options");
23
20
  const reporter_1 = require("./reporter");
24
- Object.defineProperty(exports, "formatOperations", { enumerable: true, get: function () { return reporter_1.formatOperations; } });
21
+ const request_mapper_1 = require("./request.mapper");
25
22
  const operationsCommandPath = ['operation', 'list'];
26
23
  const defaultOperationsSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
27
- const operationStates = {
28
- unspecified: operations_1.OperationState.OPERATION_STATE_UNSPECIFIED,
29
- executed: operations_1.OperationState.OPERATION_STATE_EXECUTED,
30
- canceled: operations_1.OperationState.OPERATION_STATE_CANCELED,
31
- progress: operations_1.OperationState.OPERATION_STATE_PROGRESS
32
- };
33
- const operationStateNames = Object.keys(operationStates);
24
+ const operationStateNames = ['unspecified', 'executed', 'canceled', 'progress'];
34
25
  const operationsStateOptionsSchema = {
35
26
  state: {
36
27
  type: 'string',
@@ -72,28 +63,10 @@ function createOperationsCommand(createSdk = defaultOperationsSdkFactory) {
72
63
  }
73
64
  exports.operationsCommand = createOperationsCommand();
74
65
  async function runOperationsCommand(options, createSdk) {
75
- const request = createOperationsRequest(options);
66
+ const request = (0, request_mapper_1.createOperationsRequest)(options);
76
67
  const { format } = options;
77
- const sdk = createSdk((0, args_1.resolveSdkOptionsFromCommandOptions)(options));
78
- try {
68
+ return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
79
69
  const response = await sdk.operations.getOperations(request);
80
70
  return (0, reporter_1.formatOperations)(response.operations, format);
81
- }
82
- finally {
83
- sdk.close();
84
- }
85
- }
86
- function createOperationsRequest(options) {
87
- const from = (0, command_options_1.parseDateTimeOption)(options.from, 'from');
88
- const to = (0, command_options_1.parseDateTimeOption)(options.to, 'to');
89
- if (from.getTime() > to.getTime()) {
90
- throw new icore_1.CliUsageError("Expected '--from' to be earlier than or equal to '--to'");
91
- }
92
- return {
93
- accountId: options['account-id'],
94
- from,
95
- to,
96
- state: operationStates[options.state],
97
- figi: (0, instrument_id_options_1.resolveOptionalInstrumentIdOption)(options) ?? ''
98
- };
71
+ });
99
72
  }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Модуль хранит request mapping, общий для production и Sandbox operations.
3
+ *
4
+ * Здесь допустимы generated enum mapping и request-level проверка диапазона.
5
+ * Здесь не должно быть command schema, SDK calls или rendering.
6
+ */
7
+ import { OperationState, type OperationsRequest } from '../../../generated/operations';
8
+ declare const operationStates: {
9
+ readonly unspecified: OperationState.OPERATION_STATE_UNSPECIFIED;
10
+ readonly executed: OperationState.OPERATION_STATE_EXECUTED;
11
+ readonly canceled: OperationState.OPERATION_STATE_CANCELED;
12
+ readonly progress: OperationState.OPERATION_STATE_PROGRESS;
13
+ };
14
+ interface OperationsRequestOptions {
15
+ readonly 'account-id': string;
16
+ readonly from: string;
17
+ readonly to: string;
18
+ readonly state: keyof typeof operationStates;
19
+ readonly 'instrument-id'?: string | undefined;
20
+ readonly figi?: string | undefined;
21
+ }
22
+ export declare function createOperationsRequest(options: OperationsRequestOptions): OperationsRequest;
23
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * Модуль хранит request mapping, общий для production и Sandbox operations.
4
+ *
5
+ * Здесь допустимы generated enum mapping и request-level проверка диапазона.
6
+ * Здесь не должно быть command schema, SDK calls или rendering.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createOperationsRequest = createOperationsRequest;
10
+ const operations_1 = require("../../../generated/operations");
11
+ const icore_1 = require("icore");
12
+ const command_options_1 = require("../../args/command-options");
13
+ const instrument_id_options_1 = require("../../args/instrument-id-options");
14
+ const operationStates = {
15
+ unspecified: operations_1.OperationState.OPERATION_STATE_UNSPECIFIED,
16
+ executed: operations_1.OperationState.OPERATION_STATE_EXECUTED,
17
+ canceled: operations_1.OperationState.OPERATION_STATE_CANCELED,
18
+ progress: operations_1.OperationState.OPERATION_STATE_PROGRESS
19
+ };
20
+ function createOperationsRequest(options) {
21
+ const from = (0, command_options_1.parseDateTimeOption)(options.from, 'from');
22
+ const to = (0, command_options_1.parseDateTimeOption)(options.to, 'to');
23
+ if (from.getTime() > to.getTime()) {
24
+ throw new icore_1.CliUsageError("Expected '--from' to be earlier than or equal to '--to'");
25
+ }
26
+ return {
27
+ accountId: options['account-id'],
28
+ from,
29
+ to,
30
+ state: operationStates[options.state],
31
+ figi: (0, instrument_id_options_1.resolveOptionalInstrumentIdOption)(options) ?? ''
32
+ };
33
+ }
@@ -3,16 +3,13 @@
3
3
  *
4
4
  * Здесь допустимы:
5
5
  * - объявление command path и option schema;
6
- * - преобразование CLI options в generated request;
7
- * - создание SDK через bootstrap factory и закрытие SDK resource;
6
+ * - делегирование request mapping в command-owned mapper;
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 GetOperationsByCursorRequest, type GetOperationsByCursorResponse } from '../../../generated/operations';
13
- import { type InferOptions } from 'icore';
14
- import type { CommandRequestOptions } from '../../args/command-options';
15
- import { formatOperationsByCursor } from './reporter';
16
13
  type OperationsByCursorSdk = {
17
14
  operations: {
18
15
  getOperationsByCursor(request: GetOperationsByCursorRequest): Promise<GetOperationsByCursorResponse>;
@@ -20,66 +17,6 @@ type OperationsByCursorSdk = {
20
17
  close(): void;
21
18
  };
22
19
  type OperationsByCursorSdkFactory = (options: TInvestOptions) => OperationsByCursorSdk;
23
- declare const operationsByCursorOptionsSchema: {
24
- readonly token: {
25
- readonly type: 'string';
26
- };
27
- readonly endpoint: {
28
- readonly type: 'string';
29
- };
30
- readonly 'app-name': {
31
- readonly type: 'string';
32
- };
33
- readonly insecure: {
34
- readonly type: 'boolean';
35
- };
36
- readonly state: {
37
- readonly type: 'string';
38
- readonly choices: ("canceled" | "executed" | "progress" | "unspecified")[];
39
- readonly default: 'unspecified';
40
- };
41
- readonly limit: {
42
- readonly type: 'string';
43
- };
44
- readonly 'operation-type': {
45
- readonly type: 'string';
46
- };
47
- readonly 'account-id': {
48
- readonly type: 'string';
49
- readonly required: true;
50
- };
51
- readonly 'instrument-id': {
52
- readonly type: 'string';
53
- };
54
- readonly from: {
55
- readonly type: 'string';
56
- };
57
- readonly to: {
58
- readonly type: 'string';
59
- };
60
- readonly cursor: {
61
- readonly type: 'string';
62
- };
63
- readonly 'without-commissions': {
64
- readonly type: 'boolean';
65
- readonly default: false;
66
- };
67
- readonly 'without-trades': {
68
- readonly type: 'boolean';
69
- readonly default: false;
70
- };
71
- readonly 'without-overnights': {
72
- readonly type: 'boolean';
73
- readonly default: false;
74
- };
75
- readonly format: {
76
- readonly type: 'string';
77
- readonly choices: readonly ["json", "table"];
78
- readonly default: 'table';
79
- };
80
- };
81
- type OperationsByCursorOptions = InferOptions<typeof operationsByCursorOptionsSchema>;
82
- type OperationsByCursorRequestOptions = CommandRequestOptions<OperationsByCursorOptions, 'account-id' | 'instrument-id' | 'operation-type' | 'without-commissions' | 'without-trades' | 'without-overnights' | 'from' | 'to' | 'cursor' | 'limit' | 'state'>;
83
20
  export declare function createOperationsByCursorCommand(createSdk?: OperationsByCursorSdkFactory): Omit<import("icore").CommandDefinition<{
84
21
  readonly token: {
85
22
  readonly type: 'string';
@@ -95,7 +32,7 @@ export declare function createOperationsByCursorCommand(createSdk?: OperationsBy
95
32
  };
96
33
  readonly state: {
97
34
  readonly type: 'string';
98
- readonly choices: ("canceled" | "executed" | "progress" | "unspecified")[];
35
+ readonly choices: readonly ["unspecified", "executed", "canceled", "progress"];
99
36
  readonly default: 'unspecified';
100
37
  };
101
38
  readonly limit: {
@@ -155,7 +92,7 @@ export declare const operationsByCursorCommand: Omit<import("icore").CommandDefi
155
92
  };
156
93
  readonly state: {
157
94
  readonly type: 'string';
158
- readonly choices: ("canceled" | "executed" | "progress" | "unspecified")[];
95
+ readonly choices: readonly ["unspecified", "executed", "canceled", "progress"];
159
96
  readonly default: 'unspecified';
160
97
  };
161
98
  readonly limit: {
@@ -200,5 +137,4 @@ export declare const operationsByCursorCommand: Omit<import("icore").CommandDefi
200
137
  }, undefined, string, readonly ["operation", "page"], undefined, void, readonly []>, "metadata"> & {
201
138
  metadata?: undefined;
202
139
  };
203
- export { formatOperationsByCursor };
204
- export declare function createOperationsByCursorRequest(options: OperationsByCursorRequestOptions): GetOperationsByCursorRequest;
140
+ export {};