@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.
- package/CHANGELOG.md +19 -0
- package/{THIRD_PARTY_NOTICES.md → LICENSE-APACHE-2.0} +1 -106
- package/NOTICE +98 -0
- package/dist/application/services/unary-limiter.js +9 -9
- package/dist/bootstrap/args/sdk-options.d.ts +1 -2
- package/dist/bootstrap/cli/help-catalog.d.ts +733 -0
- package/dist/bootstrap/cli/help-catalog.js +1649 -0
- package/dist/bootstrap/cli/help.d.ts +2 -730
- package/dist/bootstrap/cli/help.js +5 -1647
- package/dist/bootstrap/cli/registry.d.ts +6 -6
- package/dist/bootstrap/commands/accounts/cli.d.ts +2 -3
- package/dist/bootstrap/commands/accounts/cli.js +5 -10
- package/dist/bootstrap/commands/accrued-interests/cli.d.ts +2 -3
- package/dist/bootstrap/commands/accrued-interests/cli.js +5 -10
- package/dist/bootstrap/commands/asset/cli.d.ts +2 -3
- package/dist/bootstrap/commands/asset/cli.js +5 -10
- package/dist/bootstrap/commands/assets/cli.d.ts +2 -3
- package/dist/bootstrap/commands/assets/cli.js +5 -10
- package/dist/bootstrap/commands/bond/cli.d.ts +2 -3
- package/dist/bootstrap/commands/bond/cli.js +5 -10
- package/dist/bootstrap/commands/bond-coupons/cli.d.ts +2 -3
- package/dist/bootstrap/commands/bond-coupons/cli.js +5 -10
- package/dist/bootstrap/commands/bonds/cli.d.ts +2 -3
- package/dist/bootstrap/commands/bonds/cli.js +5 -10
- package/dist/bootstrap/commands/brand/cli.d.ts +2 -3
- package/dist/bootstrap/commands/brand/cli.js +5 -10
- package/dist/bootstrap/commands/brands/cli.d.ts +2 -3
- package/dist/bootstrap/commands/brands/cli.js +5 -10
- package/dist/bootstrap/commands/broker-report/cli.d.ts +2 -3
- package/dist/bootstrap/commands/broker-report/cli.js +5 -10
- package/dist/bootstrap/commands/cancel-order/cli.d.ts +3 -39
- package/dist/bootstrap/commands/cancel-order/cli.js +8 -19
- package/dist/bootstrap/commands/cancel-order/request.mapper.d.ts +7 -0
- package/dist/bootstrap/commands/cancel-order/request.mapper.js +9 -0
- package/dist/bootstrap/commands/cancel-stop-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/cancel-stop-order/cli.js +6 -11
- package/dist/bootstrap/commands/candles/cli.d.ts +3 -4
- package/dist/bootstrap/commands/candles/cli.js +6 -11
- package/dist/bootstrap/commands/close-prices/cli.d.ts +3 -4
- package/dist/bootstrap/commands/close-prices/cli.js +6 -11
- package/dist/bootstrap/commands/countries/cli.d.ts +2 -3
- package/dist/bootstrap/commands/countries/cli.js +5 -10
- package/dist/bootstrap/commands/currencies/cli.d.ts +2 -3
- package/dist/bootstrap/commands/currencies/cli.js +5 -10
- package/dist/bootstrap/commands/currency/cli.d.ts +2 -3
- package/dist/bootstrap/commands/currency/cli.js +5 -10
- package/dist/bootstrap/commands/dividends/cli.d.ts +2 -3
- package/dist/bootstrap/commands/dividends/cli.js +5 -10
- package/dist/bootstrap/commands/dividends-foreign-issuer/cli.d.ts +2 -3
- package/dist/bootstrap/commands/dividends-foreign-issuer/cli.js +5 -10
- package/dist/bootstrap/commands/edit-favorites/cli.d.ts +2 -3
- package/dist/bootstrap/commands/edit-favorites/cli.js +5 -10
- package/dist/bootstrap/commands/etf/cli.d.ts +2 -3
- package/dist/bootstrap/commands/etf/cli.js +5 -10
- package/dist/bootstrap/commands/etfs/cli.d.ts +2 -3
- package/dist/bootstrap/commands/etfs/cli.js +5 -10
- package/dist/bootstrap/commands/favorites/cli.d.ts +2 -3
- package/dist/bootstrap/commands/favorites/cli.js +5 -10
- package/dist/bootstrap/commands/find-instrument/cli.d.ts +2 -3
- package/dist/bootstrap/commands/find-instrument/cli.js +5 -10
- package/dist/bootstrap/commands/future/cli.d.ts +2 -3
- package/dist/bootstrap/commands/future/cli.js +5 -10
- package/dist/bootstrap/commands/futures/cli.d.ts +2 -3
- package/dist/bootstrap/commands/futures/cli.js +5 -10
- package/dist/bootstrap/commands/futures-margin/cli.d.ts +2 -3
- package/dist/bootstrap/commands/futures-margin/cli.js +5 -10
- package/dist/bootstrap/commands/instrument/cli.d.ts +2 -3
- package/dist/bootstrap/commands/instrument/cli.js +5 -10
- package/dist/bootstrap/commands/last-prices/cli.d.ts +3 -4
- package/dist/bootstrap/commands/last-prices/cli.js +6 -11
- package/dist/bootstrap/commands/last-trades/cli.d.ts +3 -4
- package/dist/bootstrap/commands/last-trades/cli.js +6 -11
- package/dist/bootstrap/commands/margin-attributes/cli.d.ts +2 -3
- package/dist/bootstrap/commands/margin-attributes/cli.js +5 -10
- package/dist/bootstrap/commands/operations/cli.d.ts +5 -53
- package/dist/bootstrap/commands/operations/cli.js +9 -36
- package/dist/bootstrap/commands/operations/request.mapper.d.ts +23 -0
- package/dist/bootstrap/commands/operations/request.mapper.js +33 -0
- package/dist/bootstrap/commands/operations-by-cursor/cli.d.ts +5 -69
- package/dist/bootstrap/commands/operations-by-cursor/cli.js +9 -74
- package/dist/bootstrap/commands/operations-by-cursor/request.mapper.d.ts +28 -0
- package/dist/bootstrap/commands/operations-by-cursor/request.mapper.js +70 -0
- package/dist/bootstrap/commands/option/cli.d.ts +2 -3
- package/dist/bootstrap/commands/option/cli.js +5 -10
- package/dist/bootstrap/commands/options-by/cli.d.ts +2 -3
- package/dist/bootstrap/commands/options-by/cli.js +5 -10
- package/dist/bootstrap/commands/order-book/cli.d.ts +3 -4
- package/dist/bootstrap/commands/order-book/cli.js +6 -11
- package/dist/bootstrap/commands/order-state/cli.d.ts +3 -36
- package/dist/bootstrap/commands/order-state/cli.js +8 -21
- package/dist/bootstrap/commands/order-state/request.mapper.d.ts +13 -0
- package/dist/bootstrap/commands/order-state/request.mapper.js +17 -0
- package/dist/bootstrap/commands/orders/cli.d.ts +3 -32
- package/dist/bootstrap/commands/orders/cli.js +8 -18
- package/dist/bootstrap/commands/orders/request.mapper.d.ts +6 -0
- package/dist/bootstrap/commands/orders/request.mapper.js +8 -0
- package/dist/bootstrap/commands/portfolio/cli.d.ts +6 -40
- package/dist/bootstrap/commands/portfolio/cli.js +9 -26
- package/dist/bootstrap/commands/portfolio/request.mapper.d.ts +18 -0
- package/dist/bootstrap/commands/portfolio/request.mapper.js +21 -0
- package/dist/bootstrap/commands/positions/cli.d.ts +3 -32
- package/dist/bootstrap/commands/positions/cli.js +8 -18
- package/dist/bootstrap/commands/positions/request.mapper.d.ts +6 -0
- package/dist/bootstrap/commands/positions/request.mapper.js +8 -0
- package/dist/bootstrap/commands/post-order/cli.d.ts +8 -68
- package/dist/bootstrap/commands/post-order/cli.js +9 -39
- package/dist/bootstrap/commands/post-order/request.mapper.d.ts +27 -0
- package/dist/bootstrap/commands/post-order/request.mapper.js +35 -0
- package/dist/bootstrap/commands/post-stop-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/post-stop-order/cli.js +6 -11
- package/dist/bootstrap/commands/replace-order/cli.d.ts +5 -61
- package/dist/bootstrap/commands/replace-order/cli.js +9 -30
- package/dist/bootstrap/commands/replace-order/request.mapper.d.ts +22 -0
- package/dist/bootstrap/commands/replace-order/request.mapper.js +26 -0
- package/dist/bootstrap/commands/sandbox-accounts/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-accounts/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-cancel-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-cancel-order/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-close-account/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-close-account/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-open-account/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-open-account/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-operations/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-operations/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-order-state/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-order-state/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-orders/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-orders/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-pay-in/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-pay-in/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-portfolio/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-portfolio/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-positions/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-positions/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-post-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-post-order/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-replace-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-replace-order/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.js +8 -13
- package/dist/bootstrap/commands/sdk-command-lifecycle.d.ts +15 -0
- package/dist/bootstrap/commands/sdk-command-lifecycle.js +21 -0
- package/dist/bootstrap/commands/share/cli.d.ts +2 -3
- package/dist/bootstrap/commands/share/cli.js +5 -10
- package/dist/bootstrap/commands/shares/cli.d.ts +2 -3
- package/dist/bootstrap/commands/shares/cli.js +5 -10
- package/dist/bootstrap/commands/stop-orders/cli.d.ts +3 -4
- package/dist/bootstrap/commands/stop-orders/cli.js +6 -11
- package/dist/bootstrap/commands/stream-run/cli.d.ts +2 -24
- package/dist/bootstrap/commands/stream-run/cli.js +7 -142
- package/dist/bootstrap/commands/stream-run/config.d.ts +7 -15
- package/dist/bootstrap/commands/stream-run/config.js +1 -101
- package/dist/bootstrap/commands/stream-run/request.mapper.d.ts +14 -0
- package/dist/bootstrap/commands/stream-run/request.mapper.js +111 -0
- package/dist/bootstrap/commands/stream-run/stream-session.d.ts +37 -0
- package/dist/bootstrap/commands/stream-run/stream-session.js +152 -0
- package/dist/bootstrap/commands/trading-schedules/cli.d.ts +2 -3
- package/dist/bootstrap/commands/trading-schedules/cli.js +5 -10
- package/dist/bootstrap/commands/trading-status/cli.d.ts +3 -4
- package/dist/bootstrap/commands/trading-status/cli.js +6 -11
- package/dist/bootstrap/commands/trading-statuses/cli.d.ts +3 -4
- package/dist/bootstrap/commands/trading-statuses/cli.js +6 -11
- package/dist/bootstrap/commands/user-info/cli.d.ts +2 -3
- package/dist/bootstrap/commands/user-info/cli.js +5 -10
- package/dist/bootstrap/commands/user-tariff/cli.d.ts +2 -3
- package/dist/bootstrap/commands/user-tariff/cli.js +5 -10
- package/dist/bootstrap/commands/withdraw-limits/cli.d.ts +3 -32
- package/dist/bootstrap/commands/withdraw-limits/cli.js +8 -18
- package/dist/bootstrap/commands/withdraw-limits/request.mapper.d.ts +6 -0
- package/dist/bootstrap/commands/withdraw-limits/request.mapper.js +8 -0
- package/dist/bootstrap/index.js +2 -2
- package/dist/bootstrap/proto/compile-proto.d.ts +1 -1
- package/dist/bootstrap/proto/compile-proto.js +28 -35
- package/dist/bootstrap/t-invest-node-sdk.d.ts +9 -9
- package/dist/bootstrap/t-invest-node-sdk.js +33 -18
- package/dist/bootstrap/unary-limit-config.js +4 -4
- package/dist/generated/common.js +1 -1
- package/dist/generated/google/api/field_behavior.js +1 -1
- package/dist/generated/google/protobuf/descriptor.js +1 -1
- package/dist/generated/google/protobuf/timestamp.js +1 -1
- package/dist/generated/instruments.js +1 -1
- package/dist/generated/marketdata.js +1 -1
- package/dist/generated/operations.js +1 -1
- package/dist/generated/orders.js +1 -1
- package/dist/generated/sandbox.js +1 -1
- package/dist/generated/signals.js +1 -1
- package/dist/generated/stoporders.js +1 -1
- package/dist/generated/users.js +1 -1
- package/dist/infrastructure/interceptor/warning-interceptor.d.ts +1 -1
- package/dist/infrastructure/interceptor/warning-interceptor.js +2 -2
- package/dist/infrastructure/transport/grpc/sdk-call-error.d.ts +12 -0
- package/dist/infrastructure/transport/grpc/sdk-call-error.js +180 -0
- package/dist/infrastructure/transport/grpc/sdk-client.d.ts +1 -1
- package/dist/infrastructure/transport/grpc/sdk-client.js +2 -2
- package/dist/infrastructure/transport/grpc/sdk-middleware.d.ts +1 -1
- package/dist/infrastructure/transport/grpc/sdk-middleware.js +8 -174
- package/dist/infrastructure/transport/grpc/unary-limit-resolver.d.ts +3 -1
- package/dist/infrastructure/transport/grpc/unary-limit-resolver.js +19 -18
- package/docs/architecture.md +44 -41
- package/docs/bundled-ca.md +12 -12
- package/docs/clean-architecture/adapters.md +15 -15
- package/docs/clean-architecture/api-commands.md +63 -52
- package/docs/clean-architecture/application.md +13 -13
- package/docs/clean-architecture/cli-output-boundaries.md +23 -23
- package/docs/clean-architecture/dto.md +9 -9
- package/docs/clean-architecture/index.md +13 -12
- package/docs/cli-stream-configuration.md +9 -9
- package/docs/cli-stream-reference.md +11 -11
- package/docs/guides/custom-unary-limiter.md +30 -30
- package/docs/guides/errors-and-lifecycle.md +10 -10
- package/docs/guides/getting-started.md +9 -9
- package/docs/guides/index.md +3 -3
- package/docs/guides/streams-and-cancellation.md +6 -6
- package/docs/guides/testing-with-service-definitions.md +4 -4
- package/docs/guides/unary-calls.md +8 -8
- package/docs/index.md +9 -9
- package/docs/limits-policy.md +10 -10
- package/docs/roadmap.md +12 -12
- package/docs/tls-policy.md +7 -7
- package/package.json +2 -1
- package/readme.md +42 -41
- package/dist/infrastructure/interceptor/index.d.ts +0 -1
- package/dist/infrastructure/interceptor/index.js +0 -17
- /package/dist/infrastructure/transport/grpc/{unary-limits.d.ts → unary-method-path.d.ts} +0 -0
- /package/dist/infrastructure/transport/grpc/{unary-limits.js → unary-method-path.js} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# API-команды
|
|
2
2
|
|
|
3
|
-
> Type: Design Note.
|
|
3
|
+
> Type: Design Note. Здесь описаны текущая структура CLI API-команд и риск разрастания `bootstrap`.
|
|
4
4
|
|
|
5
5
|
## Контекст
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
SDK публикует API-команды в виде preferred friendly path: `<domain> <resource/action>`.
|
|
8
8
|
|
|
9
9
|
Публичные domains:
|
|
10
10
|
|
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
- `stream`;
|
|
19
19
|
- `dev`.
|
|
20
20
|
|
|
21
|
-
Technical и legacy paths
|
|
21
|
+
Technical и legacy paths работают как compatibility aliases, но help и документация показывают только preferred paths. Registry хранит один canonical definition на команду и передаёт остальные пути через first-class aliases `icore`. В resolved command поля `name` и `path` содержат preferred identity, а `matchedPath` — введённый путь. Текущий CLI contract:
|
|
22
22
|
|
|
23
23
|
- `account list` -> `sdk.users.getAccounts` (`account get-accounts`, `users get-accounts`);
|
|
24
24
|
- `account info` -> `sdk.users.getInfo` (`account get-info`, `users get-info`);
|
|
25
25
|
- `account margin` -> `sdk.users.getMarginAttributes` (`account get-margin-attributes`, `users get-margin-attributes`);
|
|
26
26
|
- `account tariff` -> `sdk.users.getUserTariff` (`account get-user-tariff`, `users get-user-tariff`);
|
|
27
|
-
- `market candles` -> `sdk.
|
|
28
|
-
- `market close-prices` -> `sdk.
|
|
29
|
-
- `market last-prices` -> `sdk.
|
|
30
|
-
- `market trades` -> `sdk.
|
|
31
|
-
- `market order-book` -> `sdk.
|
|
32
|
-
- `market status` -> `sdk.
|
|
33
|
-
- `market statuses` -> `sdk.
|
|
27
|
+
- `market candles` -> `sdk.marketData.getCandles` (`market get-candles`, `marketdata get-candles`);
|
|
28
|
+
- `market close-prices` -> `sdk.marketData.getClosePrices` (`market get-close-prices`, `marketdata get-close-prices`);
|
|
29
|
+
- `market last-prices` -> `sdk.marketData.getLastPrices` (`market get-last-prices`, `marketdata get-last-prices`);
|
|
30
|
+
- `market trades` -> `sdk.marketData.getLastTrades` (`market get-last-trades`, `marketdata get-last-trades`);
|
|
31
|
+
- `market order-book` -> `sdk.marketData.getOrderBook` (`market get-order-book`, `marketdata get-order-book`);
|
|
32
|
+
- `market status` -> `sdk.marketData.getTradingStatus` (`market get-trading-status`, `marketdata get-trading-status`);
|
|
33
|
+
- `market statuses` -> `sdk.marketData.getTradingStatuses` (`market get-trading-statuses`, `marketdata get-trading-statuses`);
|
|
34
34
|
- `instrument search` -> `sdk.instruments.findInstrument` (`instrument find-instrument`, `instruments find-instrument`);
|
|
35
35
|
- `instrument show` -> `sdk.instruments.getInstrumentBy` (`instrument get-instrument-by`, `instruments get-instrument-by`);
|
|
36
36
|
- `instrument dividends` -> `sdk.instruments.getDividends` (`instrument get-dividends`, `instruments get-dividends`);
|
|
@@ -69,9 +69,9 @@ Technical и legacy paths остаются совместимыми aliases, н
|
|
|
69
69
|
- `operation portfolio` -> `sdk.operations.getPortfolio` (`operation get-portfolio`, `operations get-portfolio`);
|
|
70
70
|
- `operation positions` -> `sdk.operations.getPositions` (`operation get-positions`, `operations get-positions`);
|
|
71
71
|
- `operation withdraw-limits` -> `sdk.operations.getWithdrawLimits` (`operation get-withdraw-limits`, `operations get-withdraw-limits`);
|
|
72
|
-
- `stop-order list` -> `sdk.
|
|
73
|
-
- `stop-order place` -> `sdk.
|
|
74
|
-
- `stop-order cancel` -> `sdk.
|
|
72
|
+
- `stop-order list` -> `sdk.stopOrders.getStopOrders` (`stop-order get-stop-orders`, `stoporders get-stop-orders`);
|
|
73
|
+
- `stop-order place` -> `sdk.stopOrders.postStopOrder` (`stop-order post-stop-order`, `stoporders post-stop-order`);
|
|
74
|
+
- `stop-order cancel` -> `sdk.stopOrders.cancelStopOrder` (`stop-order cancel-stop-order`, `stoporders cancel-stop-order`);
|
|
75
75
|
- `sandbox account list` -> `sdk.sandbox.getSandboxAccounts` (`sandbox get-sandbox-accounts`);
|
|
76
76
|
- `sandbox account open` -> `sdk.sandbox.openSandboxAccount` (`sandbox open-sandbox-account`);
|
|
77
77
|
- `sandbox account close` -> `sdk.sandbox.closeSandboxAccount` (`sandbox close-sandbox-account`);
|
|
@@ -91,19 +91,19 @@ Technical и legacy paths остаются совместимыми aliases, н
|
|
|
91
91
|
- `help` -> встроенная справка по CLI, домену или команде;
|
|
92
92
|
- `version` -> версия пакета.
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
Добавляйте API-команды по одной, когда выбран конкретный SDK method и понятен CLI-контракт. Preferred path должен попасть в command definition и help, а technical/legacy aliases — только в единый alias layer, который передаёт их в native command definition `icore`.
|
|
95
95
|
|
|
96
96
|
## Отложенные расширения
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
Ниже перечислены возможности, которые не входят в текущий CLI-контракт и потребуют отдельного проектирования и обновления документации.
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
Действующие команды с side effects входят в текущий CLI-контракт и по умолчанию требуют явный `--confirm` через `defaultConfig.requireSideEffectConfirmation`. CLI не генерирует idempotency keys автоматически: `order place` принимает `--order-id`, а `order replace` — `--idempotency-key`.
|
|
101
101
|
|
|
102
|
-
`sandbox pay-in` принимает `--currency=rub|usd`.
|
|
102
|
+
`sandbox pay-in` принимает `--currency=rub|usd`. CLI parser отклоняет неизвестные currency values, а для явно неподдержанного provider-кейса `--currency=usd` команда возвращает ошибку.
|
|
103
103
|
|
|
104
|
-
Stream API
|
|
104
|
+
Для Stream API есть отдельная utility-команда `stream run --config=PATH`. Контракт долгоживущих подписок, завершения процесса и формата событий описан в [справочнике потокового CLI](../cli-stream-reference.md) и [справочнике его конфигурации](../cli-stream-configuration.md).
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
Сейчас CLI поддерживает server-side streams и статический initial request contract для bidirectional market data stream:
|
|
107
107
|
|
|
108
108
|
- `sdk.marketdataStream.marketDataStream`;
|
|
109
109
|
- `sdk.marketdataStream.marketDataServerSideStream`;
|
|
@@ -113,25 +113,25 @@ Stream API вводится отдельно от unary CLI-команд чер
|
|
|
113
113
|
|
|
114
114
|
Динамические bidirectional request sources остаются отложенным API-контрактом.
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
Публичный CLI не добавляет команды для deprecated generated methods:
|
|
117
117
|
|
|
118
118
|
- `sdk.instruments.options` - deprecated в generated contract; вместо него используется `instrument option list` / `sdk.instruments.optionsBy`.
|
|
119
119
|
|
|
120
|
-
Перед расширением stream command
|
|
120
|
+
Перед расширением stream command сверьте поведение с этими reference-документами и отдельно опишите любое изменение контракта.
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
В command flow участвуют несколько ответственностей:
|
|
123
123
|
|
|
124
124
|
1. runner и `icore` разбирают CLI args и валидируют primitive options по schema;
|
|
125
|
-
2. command handler выполняет API-specific validation и request mapping;
|
|
126
|
-
3.
|
|
125
|
+
2. command handler или его command-owned mapper выполняет API-specific validation и request mapping;
|
|
126
|
+
3. общий lifecycle helper создает `TInvestNodeSDK` для короткой команды;
|
|
127
127
|
4. command handler вызывает API method;
|
|
128
128
|
5. reporter преобразует unary response в stable report или stream event в локальный контракт вывода команды;
|
|
129
129
|
6. reporter выбирает command-specific output и использует generic render primitives, когда они подходят;
|
|
130
130
|
7. terminal app получает готовую строку или stream для вывода.
|
|
131
131
|
|
|
132
|
-
Если
|
|
132
|
+
Если снова собрать эти обязанности в одном command handler, command layer быстро начнёт принимать любую логику вокруг CLI.
|
|
133
133
|
|
|
134
|
-
## Текущая
|
|
134
|
+
## Текущая структура
|
|
135
135
|
|
|
136
136
|
```text
|
|
137
137
|
src/bootstrap
|
|
@@ -144,12 +144,21 @@ src/bootstrap
|
|
|
144
144
|
cli/
|
|
145
145
|
contract.ts
|
|
146
146
|
error.ts
|
|
147
|
+
help-catalog.ts
|
|
147
148
|
help.ts
|
|
148
149
|
registry.ts
|
|
149
150
|
runner.ts
|
|
150
151
|
commands/
|
|
152
|
+
sdk-command-lifecycle.ts
|
|
151
153
|
<command-adapter>/
|
|
152
154
|
cli.ts
|
|
155
|
+
request.mapper.ts # когда mapping разделяют production и Sandbox
|
|
156
|
+
reporter.ts
|
|
157
|
+
stream-run/
|
|
158
|
+
cli.ts
|
|
159
|
+
config.ts
|
|
160
|
+
request.mapper.ts
|
|
161
|
+
stream-session.ts
|
|
153
162
|
reporter.ts
|
|
154
163
|
|
|
155
164
|
src/infrastructure
|
|
@@ -164,16 +173,16 @@ external dependency
|
|
|
164
173
|
TerminalApp/Output
|
|
165
174
|
```
|
|
166
175
|
|
|
167
|
-
`cli.ts`
|
|
176
|
+
`cli.ts` отвечает за:
|
|
168
177
|
|
|
169
178
|
- объявление command path, declarative option schema и handler-а через локальный command facade над `icore`;
|
|
170
|
-
- mapping
|
|
179
|
+
- локальный request mapping или делегирование в `request.mapper.ts`, когда mapping разделяет несколько команд;
|
|
171
180
|
- API-specific validation, которая не выражается primitive schema;
|
|
172
|
-
-
|
|
181
|
+
- передачу короткого SDK lifecycle в `runSdkCommand()`;
|
|
173
182
|
- вызов API;
|
|
174
|
-
-
|
|
183
|
+
- выбор reporter-а для результата.
|
|
175
184
|
|
|
176
|
-
Логические CLI options используют синтаксис флагов `icore`: `--flag` и, если команда поддерживает отрицательное переопределение, `--no-flag`.
|
|
185
|
+
Логические CLI options используют синтаксис флагов `icore`: `--flag` и, если команда поддерживает отрицательное переопределение, `--no-flag`. Публичный CLI-контракт не принимает формы `--flag=true` и `--flag=false`.
|
|
177
186
|
|
|
178
187
|
Внутри command module нужно различать parsing и request mapping:
|
|
179
188
|
|
|
@@ -183,37 +192,37 @@ parse* -> typed primitive value -> project-specific value
|
|
|
183
192
|
create*Request -> typed command options -> generated request DTO
|
|
184
193
|
```
|
|
185
194
|
|
|
186
|
-
Command-local `parse*` helpers не должны повторно принимать raw option map: format, enum и primitive schema validation
|
|
195
|
+
Command-local `parse*` helpers не должны повторно принимать raw option map: `icore` отвечает за format, enum и primitive schema validation. Project-specific helper может преобразовать отдельное typed значение, например comma-separated список. `create*Request` получает не raw CLI args, а typed options после `icore`; он отвечает за форму generated request DTO и request-level validation, например date range или mutually exclusive modes.
|
|
187
196
|
|
|
188
|
-
`reporter.ts`
|
|
197
|
+
`reporter.ts` отвечает за:
|
|
189
198
|
|
|
190
199
|
- mapping unary response в application report или stream event в command-local output contract;
|
|
191
200
|
- выбор command-specific output contract;
|
|
192
201
|
- выбор полей, headers, порядка и подготовку значений для JSON/CSV/table output;
|
|
193
202
|
- вызов generic render primitives `icore`, когда они подходят формату.
|
|
194
203
|
|
|
195
|
-
`icore`
|
|
204
|
+
`icore` предоставляет:
|
|
196
205
|
|
|
197
206
|
- primitive option parsing, typed schema validation и command mechanics;
|
|
198
207
|
- технические детали JSON, plain-text table и CSV rendering;
|
|
199
208
|
- `TerminalApp`/`Output.write` для штатной записи готовой строки или stream в stdout;
|
|
200
209
|
- `Output.error` для warnings/errors в stderr.
|
|
201
210
|
|
|
202
|
-
Project CLI layer собирает terminal app, объявляет native short aliases,
|
|
211
|
+
Project CLI layer собирает terminal app, объявляет native short aliases, передаёт compatibility paths как first-class aliases canonical definitions и обслуживает help/version shortcuts и warnings. Project error policy задаёт текст ошибки и exit code.
|
|
203
212
|
|
|
204
|
-
Директории внутри `bootstrap/commands/*`
|
|
213
|
+
Директории внутри `bootstrap/commands/*` носят компактные имена adapter-модулей и не задают публичный CLI path. Контракт команды находится в `bootstrap/cli/registry.ts`, а статические данные справки — в `bootstrap/cli/help-catalog.ts`.
|
|
205
214
|
|
|
206
|
-
## Что
|
|
215
|
+
## Что уже хорошо
|
|
207
216
|
|
|
208
217
|
- primitive option validation выражена `icore` schemas, а reusable project-specific normalizers отделены в `bootstrap/args`;
|
|
209
218
|
- raw CLI parsing отделен от typed generated request mapping;
|
|
210
219
|
- stable unary output shape вынесен в `application/reports`, а stream contract зафиксирован отдельно;
|
|
211
|
-
-
|
|
220
|
+
- общий helper закрывает SDK коротких команд в `finally`, а stream session владеет собственным cleanup;
|
|
212
221
|
- formatting logic вынесена из `cli.ts`;
|
|
213
222
|
- JSON pretty-print, table alignment и CSV escaping не дублируются в command reporter-ах;
|
|
214
223
|
- `stdout`/`stderr` delivery отделен от построения JSON/CSV/table.
|
|
215
224
|
|
|
216
|
-
## Текущая
|
|
225
|
+
## Текущая проблема
|
|
217
226
|
|
|
218
227
|
`bootstrap` по смыслу должен быть composition/entrypoint layer:
|
|
219
228
|
|
|
@@ -221,7 +230,7 @@ Project CLI layer собирает terminal app, объявляет native short
|
|
|
221
230
|
parse entrypoint -> assemble dependencies -> call command -> return status/output
|
|
222
231
|
```
|
|
223
232
|
|
|
224
|
-
В `bootstrap`
|
|
233
|
+
В `bootstrap` остаётся command-specific presentation/adaptation logic:
|
|
225
234
|
|
|
226
235
|
```text
|
|
227
236
|
unary response -> stable report
|
|
@@ -229,11 +238,11 @@ stream event -> command-local output contract
|
|
|
229
238
|
report/event contract -> command-specific output values
|
|
230
239
|
```
|
|
231
240
|
|
|
232
|
-
Это осознанный компактный вариант, близкий к Inventory.
|
|
241
|
+
Это осознанный компактный вариант, близкий к Inventory. Проблема возникнет, если generic primitives начнут выбирать поля, выполнять redaction или normalization либо версионировать output конкретной команды. Другая крайность — дублировать механику JSON/CSV/table в reporter-ах или создавать forwarding wrappers над `icore` без собственного контракта.
|
|
233
242
|
|
|
234
|
-
Подробные правила разделения command-specific formatting, generic render primitives и stdout delivery
|
|
243
|
+
Подробные правила разделения command-specific formatting, generic render primitives и stdout delivery приведены в документе [«Разделение форматирования и вывода в CLI»](./cli-output-boundaries.md).
|
|
235
244
|
|
|
236
|
-
## Важное
|
|
245
|
+
## Важное разделение
|
|
237
246
|
|
|
238
247
|
Нужно различать три ответственности:
|
|
239
248
|
|
|
@@ -261,7 +270,7 @@ warnings/errors -> Output.error -> stderr
|
|
|
261
270
|
|
|
262
271
|
Output boundary не должен знать, как строить JSON, CSV или table.
|
|
263
272
|
|
|
264
|
-
## Принятое
|
|
273
|
+
## Принятое разделение
|
|
265
274
|
|
|
266
275
|
```text
|
|
267
276
|
src/bootstrap
|
|
@@ -292,16 +301,17 @@ external dependency
|
|
|
292
301
|
|
|
293
302
|
Граница:
|
|
294
303
|
|
|
295
|
-
- `bootstrap/commands/*/cli.ts` - command definition, API-specific
|
|
304
|
+
- `bootstrap/commands/*/cli.ts` - command definition, API-specific orchestration и вызов общего SDK lifecycle;
|
|
305
|
+
- `bootstrap/commands/*/request.mapper.ts` - shared production/Sandbox request mapping там, где он действительно переиспользуется;
|
|
296
306
|
- `bootstrap/commands/*/reporter.ts` - provider result -> stable report или локальный контракт события -> специализированный вывод CLI-команды;
|
|
297
307
|
- public render primitives `icore` - механика JSON/CSV-row/table rendering;
|
|
298
308
|
- `icore` `TerminalApp`/`Output.write`, собранные в `bootstrap/cli/runner.ts`, - штатная запись готовой строки или stream в stdout;
|
|
299
309
|
- `icore` `Output.error` - warnings/errors в stderr;
|
|
300
310
|
- `application/reports/**` - стабильные контракты вывода unary-команд.
|
|
301
311
|
|
|
302
|
-
## Когда
|
|
312
|
+
## Когда нужен use-case
|
|
303
313
|
|
|
304
|
-
Текущие API-команды тонкие: они вызывают один SDK method и форматируют результат.
|
|
314
|
+
Текущие API-команды тонкие: они вызывают один SDK method и форматируют результат. Отдельный use-case им не нужен.
|
|
305
315
|
|
|
306
316
|
Use-case стоит выделять, если появляется хотя бы одно:
|
|
307
317
|
|
|
@@ -312,7 +322,7 @@ Use-case стоит выделять, если появляется хотя б
|
|
|
312
322
|
- reuse того же сценария вне CLI;
|
|
313
323
|
- тесты начинают мокать слишком много деталей SDK.
|
|
314
324
|
|
|
315
|
-
## Правило
|
|
325
|
+
## Правило для новых команд
|
|
316
326
|
|
|
317
327
|
- не добавлять новую formatting logic в `cli.ts`;
|
|
318
328
|
- держать command handler тонким;
|
|
@@ -323,19 +333,20 @@ Use-case стоит выделять, если появляется хотя б
|
|
|
323
333
|
- регистрировать команду в `bootstrap/cli/registry.ts` в canonical форме `<domain> <command>`;
|
|
324
334
|
- добавлять technical/legacy paths только через project alias inventory; registry передаст их в `aliases` canonical definition;
|
|
325
335
|
- не добавлять short option aliases для API-команд;
|
|
326
|
-
- добавлять help metadata в `bootstrap/cli/help.ts`;
|
|
336
|
+
- добавлять help metadata в `bootstrap/cli/help-catalog.ts`;
|
|
327
337
|
- добавлять тесты рядом с конкретными файлами команды;
|
|
328
338
|
- не вводить общий command framework до появления реального повторения в нескольких командах;
|
|
329
339
|
- сверять новые output-решения с [Разделением форматирования и вывода в CLI](./cli-output-boundaries.md).
|
|
330
340
|
|
|
331
|
-
## Когда
|
|
341
|
+
## Когда обобщать commands
|
|
332
342
|
|
|
333
|
-
|
|
343
|
+
Обобщайте command lifecycle только после появления повторения с одинаковой ответственностью.
|
|
334
344
|
|
|
335
|
-
|
|
345
|
+
Каждая команда остаётся явной, а общий lifecycle коротких вызовов вынесен отдельно:
|
|
336
346
|
|
|
337
347
|
```text
|
|
338
348
|
bootstrap/commands/<command-adapter>/cli.ts
|
|
349
|
+
bootstrap/commands/sdk-command-lifecycle.ts
|
|
339
350
|
bootstrap/commands/<command-adapter>/reporter.ts
|
|
340
351
|
application/reports/<command-adapter>.report.ts
|
|
341
352
|
```
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Application-слой
|
|
2
2
|
|
|
3
|
-
> Type: Design Note.
|
|
3
|
+
> Type: Design Note. Здесь описана роль `application`-слоя в текущем SDK. Canonical-границы слоёв приведены в документе [«Архитектура SDK»](../architecture.md).
|
|
4
4
|
|
|
5
|
-
## Главная
|
|
5
|
+
## Главная идея
|
|
6
6
|
|
|
7
|
-
`application`
|
|
7
|
+
`application` не должен зависеть от runtime entrypoints и конкретных деталей transport/infrastructure.
|
|
8
8
|
|
|
9
9
|
В Inventory application уже содержит use-case-ы, ports, reports, services и pipeline orchestration. В текущем SDK этот слой меньше: есть только contracts и reusable правила, которые нужны SDK facade и CLI-командам.
|
|
10
10
|
|
|
11
|
-
## Что
|
|
11
|
+
## Что сейчас есть в `application`
|
|
12
12
|
|
|
13
13
|
```text
|
|
14
14
|
src/application
|
|
@@ -31,7 +31,7 @@ src/application
|
|
|
31
31
|
- `application/reports` - стабильные output/report contracts API-команд;
|
|
32
32
|
- `application/services` - application ports и reusable правила, например `TInvestUnaryLimiter` и его необязательная process-local реализация.
|
|
33
33
|
|
|
34
|
-
## Что
|
|
34
|
+
## Что допустимо в `application`
|
|
35
35
|
|
|
36
36
|
`application` может содержать:
|
|
37
37
|
|
|
@@ -68,13 +68,13 @@ icore TerminalApp/Output
|
|
|
68
68
|
warnings/errors -> Output.error -> stderr
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
Report contract не должен импортировать `bootstrap` или concrete infrastructure.
|
|
71
|
+
Report contract не должен импортировать `bootstrap` или concrete infrastructure. Его можно без изменения семантики использовать в CLI, тестах, будущем HTTP transport или file writer.
|
|
72
72
|
|
|
73
73
|
## Ошибки
|
|
74
74
|
|
|
75
|
-
`application/errors/sdk-error.ts`
|
|
75
|
+
`application/errors/sdk-error.ts` задаёт публичные `SdkError`, `SdkErrorCode`, `SdkErrorSource` и `isSdkError()` без импорта `nice-grpc`. Infrastructure преобразует известные gRPC failures в этот contract, а bootstrap facade создаёт lifecycle error после `close()`. Поле `cause` сохраняет исходную ошибку. Однозначные ошибки проверки TLS certificate chain и hostname получают source `tls` с прежним code `Unavailable`; обычные provider и network failures сохраняют source `grpc`.
|
|
76
76
|
|
|
77
|
-
Error code
|
|
77
|
+
Error code классифицирует ошибку, но не делает операцию retryable. Принимая решение о повторе, Consumer должен также учитывать idempotency, provider metadata и backoff policy.
|
|
78
78
|
|
|
79
79
|
## Сервисы
|
|
80
80
|
|
|
@@ -87,23 +87,23 @@ Error code предоставляет классификацию, но не об
|
|
|
87
87
|
|
|
88
88
|
`TInvestUnaryLimiter` получает готовые `path`, `bucket`, `maxRequests`, `windowMs` и `AbortSignal`. Сопоставление gRPC method path с service/method rule остаётся в transport adapter-е. Consumer может реализовать port без deep imports; SDK не владеет lifecycle переданного объекта.
|
|
89
89
|
|
|
90
|
-
`createInMemoryUnaryLimiter()`
|
|
90
|
+
`createInMemoryUnaryLimiter()` создаёт необязательную реализацию с отменяемой bucket queue. Она не знает, какой transport выполняет вызов, и не координирует другие процессы.
|
|
91
91
|
|
|
92
|
-
Если helper
|
|
92
|
+
Если helper нужен один раз и не выражает отдельное правило, оставьте его рядом с consumer-ом.
|
|
93
93
|
|
|
94
|
-
## Чего
|
|
94
|
+
## Чего сейчас нет
|
|
95
95
|
|
|
96
96
|
В текущем SDK пока нет:
|
|
97
97
|
|
|
98
98
|
- `application/use-cases`;
|
|
99
99
|
- `domain`.
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Не создавайте эти директории заранее. Они нужны только вместе с реальной ответственностью:
|
|
102
102
|
|
|
103
103
|
- use-case - если команда начинает координировать сценарий, а не просто вызывает один SDK method;
|
|
104
104
|
- domain - если появляются provider-neutral правила или модели.
|
|
105
105
|
|
|
106
|
-
## Короткие
|
|
106
|
+
## Короткие правила
|
|
107
107
|
|
|
108
108
|
- `application` описывает application-level контракт, а не формат пользовательского вывода.
|
|
109
109
|
- Provider/gRPC mapping не должен протекать в чистые application contracts.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# Разделение
|
|
1
|
+
# Разделение форматирования и вывода в CLI
|
|
2
2
|
|
|
3
|
-
> Type: Design Note.
|
|
3
|
+
> Type: Design Note. Здесь описана граница между command-specific CLI formatting, общей механикой JSON/CSV/table из `icore` и доставкой готового результата через `Output`.
|
|
4
4
|
|
|
5
5
|
## Контекст
|
|
6
6
|
|
|
7
7
|
CLI-команды живут в `bootstrap`, но не вся логика вокруг вывода имеет одну ответственность. Команда определяет смысл пользовательского представления; generic primitives сериализуют уже выбранные значения; terminal output доставляет готовую строку или stream.
|
|
8
8
|
|
|
9
|
-
`icore` предоставляет
|
|
9
|
+
`icore` предоставляет общую механику как внешняя зависимость. Это не слой проекта: application reports и output contract конкретной команды остаются в SDK.
|
|
10
10
|
|
|
11
11
|
Текущая структура:
|
|
12
12
|
|
|
@@ -38,7 +38,7 @@ external dependency
|
|
|
38
38
|
Output
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
## Основная
|
|
41
|
+
## Основная граница
|
|
42
42
|
|
|
43
43
|
Нужно разделять три операции:
|
|
44
44
|
|
|
@@ -46,19 +46,19 @@ external dependency
|
|
|
46
46
|
application report/command-local event -> command-specific output values
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
За это отвечает `bootstrap/commands/*/reporter.ts`.
|
|
50
50
|
|
|
51
51
|
```text
|
|
52
52
|
output values -> JSON / CSV document or row / table string
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
Для общей механики reporter использует публичные render primitives `icore`. Структура документа, headers и порядок rows остаются command-specific policy.
|
|
55
|
+
Для общей механики reporter использует публичные render primitives `icore`. Структура документа, headers и порядок rows остаются command-specific policy. Generic primitives добавляют trailing newline в JSON, CSV document и text table.
|
|
56
56
|
|
|
57
57
|
```text
|
|
58
58
|
string/AsyncIterable -> TerminalApp -> Output.write -> stdout
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
В штатном CLI flow
|
|
61
|
+
В штатном CLI flow готовый результат выводят `TerminalApp` и `Output` из `icore`, собранные в `bootstrap/cli/runner.ts`.
|
|
62
62
|
|
|
63
63
|
```text
|
|
64
64
|
warnings/errors -> Output.error -> stderr
|
|
@@ -66,7 +66,7 @@ warnings/errors -> Output.error -> stderr
|
|
|
66
66
|
|
|
67
67
|
Текст warnings определяет project CLI layer; текст errors и exit code - политика ошибок проекта.
|
|
68
68
|
|
|
69
|
-
## Поток
|
|
69
|
+
## Поток команды
|
|
70
70
|
|
|
71
71
|
```text
|
|
72
72
|
src/bootstrap/index.ts
|
|
@@ -94,11 +94,11 @@ icore TerminalApp -> Output.write
|
|
|
94
94
|
stdout
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
Runner отдельно
|
|
97
|
+
Runner отдельно управляет публичными short aliases, help/version shortcuts и command warnings. Он направляет help/version через lightweight terminal app, warnings — через command terminal app, а normal command result передаёт в `runPrepared`. Оба экземпляра используют один `Output` и одну error policy.
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
Штатный terminal flow идёт через `Output` из `icore`. Только крайний аварийный fallback в executable entrypoint пишет через `console.error`.
|
|
100
100
|
|
|
101
|
-
## Что
|
|
101
|
+
## Что остаётся в reporter команды
|
|
102
102
|
|
|
103
103
|
`bootstrap/commands/<command>/reporter.ts` отвечает за смысл пользовательского вывода:
|
|
104
104
|
|
|
@@ -113,7 +113,7 @@ Runner отдельно владеет публичными short aliases, help/
|
|
|
113
113
|
|
|
114
114
|
Reporter может импортировать `renderJson`, `renderCsv`, `renderCsvRow` и `renderTextTable` из `icore`, но generic primitive не должен определять поля или contract команды.
|
|
115
115
|
|
|
116
|
-
## Что
|
|
116
|
+
## Что предоставляют render primitives `icore`
|
|
117
117
|
|
|
118
118
|
Generic primitives отвечают только за механику текстового формата:
|
|
119
119
|
|
|
@@ -131,11 +131,11 @@ Generic primitives отвечают только за механику текс
|
|
|
131
131
|
- command-specific redaction или normalization;
|
|
132
132
|
- сборку CSV-документа конкретной команды.
|
|
133
133
|
|
|
134
|
-
Если общей primitive недостаточно, project-specific formatter
|
|
134
|
+
Если общей primitive недостаточно, оставьте project-specific formatter рядом с reporter-ом. Не создавайте forwarding wrapper, который только повторяет public API `icore`.
|
|
135
135
|
|
|
136
|
-
## Что
|
|
136
|
+
## Что предоставляют `TerminalApp` и `Output`
|
|
137
137
|
|
|
138
|
-
`bootstrap/cli/runner.ts`
|
|
138
|
+
`bootstrap/cli/runner.ts` создаёт default output через `createOutput` или принимает injected `Output`. Lightweight terminal app обслуживает shortcuts и external errors без загрузки command definitions; command terminal app создаётся после lazy import registry. Оба получают один `Output`.
|
|
139
139
|
|
|
140
140
|
Output boundary отвечает за:
|
|
141
141
|
|
|
@@ -152,13 +152,13 @@ Output boundary не должен знать:
|
|
|
152
152
|
- правила отображения значений;
|
|
153
153
|
- какие поля нужно скрыть или показать.
|
|
154
154
|
|
|
155
|
-
Project `terminalErrorPolicy`
|
|
155
|
+
Project `terminalErrorPolicy` задаёт текст ошибки и exit code, а terminal app из `icore` применяет policy и доставляет результат. Таким образом, error ownership остаётся разделённым и не переходит целиком внешней зависимости.
|
|
156
156
|
|
|
157
|
-
Command registry типизирует результаты публичным `TerminalCommandOutput` из `icore`.
|
|
157
|
+
Command registry типизирует результаты публичным `TerminalCommandOutput` из `icore`. SDK commands возвращают строки, async string streams или `undefined`. `TerminalApp.runPrepared()` сам выполняет runtime narrowing через публичный guard, поэтому локальная повторная проверка не нужна.
|
|
158
158
|
|
|
159
|
-
## Почему
|
|
159
|
+
## Почему не нужны локальные generic wrappers
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
Удалённые project-owned renderers и writers больше не служат архитектурными точками расширения. Wrapper без собственного контракта добавит второй source of truth, и документация снова сможет разойтись с runtime.
|
|
162
162
|
|
|
163
163
|
Локальный adapter оправдан, только если он добавляет самостоятельное project-specific поведение:
|
|
164
164
|
|
|
@@ -167,9 +167,9 @@ Command registry типизирует результаты публичным `T
|
|
|
167
167
|
- policy, которой нет в `icore`;
|
|
168
168
|
- изоляцию внешней зависимости, необходимую для наблюдаемого поведения.
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
Одного более короткого import или предположения о будущей замене зависимости недостаточно.
|
|
171
171
|
|
|
172
|
-
## Правило
|
|
172
|
+
## Правило для новых команд
|
|
173
173
|
|
|
174
174
|
При добавлении новой API-команды:
|
|
175
175
|
|
|
@@ -182,7 +182,7 @@ Command registry типизирует результаты публичным `T
|
|
|
182
182
|
- generated DTO не становится стабильным CLI output contract;
|
|
183
183
|
- output contract выбирается для конкретной команды, а не для будущего неизвестного списка команд.
|
|
184
184
|
|
|
185
|
-
## Признаки
|
|
185
|
+
## Признаки неверной границы
|
|
186
186
|
|
|
187
187
|
Command-specific policy утекла в generic mechanics, если код:
|
|
188
188
|
|
|
@@ -213,4 +213,4 @@ normal output -> `icore` TerminalApp -> Output.write -> stdout
|
|
|
213
213
|
diagnostics -> `icore` Output.error -> stderr
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
Так project-owned presentation policy не смешивается с
|
|
216
|
+
Так project-owned presentation policy не смешивается с общей сериализацией и технической доставкой результата.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DTO и отчёты
|
|
2
2
|
|
|
3
|
-
> Type: Design Note.
|
|
3
|
+
> Type: Design Note. Здесь описаны boundary contracts текущего SDK.
|
|
4
4
|
|
|
5
5
|
## Кратко
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## Сгенерированные DTO
|
|
15
15
|
|
|
16
|
-
Vendored T-Invest proto-файлы хранятся в плоской структуре `contracts/*.proto`.
|
|
16
|
+
Vendored T-Invest proto-файлы хранятся в плоской структуре `contracts/*.proto`. Генератор зеркально создаёт из этого layout файлы `src/generated/*.ts`. `contracts/upstream.json` указывает официальный upstream snapshot.
|
|
17
17
|
|
|
18
18
|
Это wire contracts внешнего API. Их нельзя редактировать вручную и нельзя использовать как место для project-specific правил.
|
|
19
19
|
|
|
@@ -30,7 +30,7 @@ Vendored T-Invest proto-файлы хранятся в плоской струк
|
|
|
30
30
|
- завязывать CLI output format на нестабильный generated JSON shape.
|
|
31
31
|
- экспортировать generated service clients как root public API.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Исключение — server-side generated `*ServiceDefinition` и `*ServiceImplementation`. Они входят в root public API, потому что пакет поддерживает nice-grpc server adapters у Consumers.
|
|
34
34
|
|
|
35
35
|
## DTO уровня application
|
|
36
36
|
|
|
@@ -46,11 +46,11 @@ CLI/env parsing -> TInvestOptions -> SDK facade/infrastructure
|
|
|
46
46
|
|
|
47
47
|
`application/dto` не должен читать env и не должен знать про CLI flags.
|
|
48
48
|
|
|
49
|
-
`src/application/dto/t-invest-services.ts` описывает публичные service interfaces SDK facade: `UsersService`, `OrdersService`, `MarketDataStreamService` и
|
|
49
|
+
`src/application/dto/t-invest-services.ts` описывает публичные service interfaces SDK facade: `UsersService`, `OrdersService`, `MarketDataStreamService` и другие. Эти interfaces сохраняют upstream method names и generated request/response DTO, но не раскрывают `nice-grpc` `*ServiceClient`, `*ServiceDefinition`, `CallOptions` или `CallContext`.
|
|
50
50
|
|
|
51
51
|
## Отчёты
|
|
52
52
|
|
|
53
|
-
`src/application/reports/**`
|
|
53
|
+
В `src/application/reports/**` находятся стабильные output contracts API-команд.
|
|
54
54
|
|
|
55
55
|
Reports отвечают на вопрос:
|
|
56
56
|
|
|
@@ -68,13 +68,13 @@ Reports отвечают на вопрос:
|
|
|
68
68
|
|
|
69
69
|
## Входные данные CLI
|
|
70
70
|
|
|
71
|
-
Raw `process.argv`
|
|
71
|
+
Raw `process.argv` остаётся на executable-границе `src/bootstrap/index.ts`. Затем `bootstrap/cli/runner.ts` передаёт argv в terminal app и command registry из `icore`:
|
|
72
72
|
|
|
73
73
|
```text
|
|
74
74
|
process.argv -> src/bootstrap/index.ts -> bootstrap/cli/runner.ts -> icore terminal app -> command registry -> typed command options -> command handler
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
Runner использует двухфазный flow `prepare -> runPrepared
|
|
77
|
+
Runner использует двухфазный flow `prepare -> runPrepared`, чтобы вывести warnings после command resolution без повторного разбора argv. Policy из `bootstrap/cli/error.ts` обрабатывает ошибки всех terminal-фаз. `isUsageError()` из `icore` распознаёт framework usage errors и публичный `CliUsageError` от project validators; для них exit code равен `2`. Runtime и command-definition errors получают exit code `1`.
|
|
78
78
|
|
|
79
79
|
Command-specific primitive options описываются декларативными `icore` schemas в `src/bootstrap/commands/**`. Общие SDK options нормализуются в `src/bootstrap/args/**`. Эти модули не должны создавать SDK clients, вызывать API или форматировать reports.
|
|
80
80
|
|
|
@@ -101,7 +101,7 @@ process.argv
|
|
|
101
101
|
| Mapping | Текущее место | Возможное целевое место |
|
|
102
102
|
| --- | --- | --- |
|
|
103
103
|
| typed command options -> `TInvestOptions` | `bootstrap/args` | без изменений |
|
|
104
|
-
| typed command options -> generated request DTO | `
|
|
104
|
+
| typed command options -> generated request DTO | command-local `cli.ts` или `request.mapper.ts`, `create*Request` | application use-case, если command перестает быть тонким adapter-ом |
|
|
105
105
|
| generated unary response -> application report | `bootstrap/commands/*/reporter.ts` | CLI adapter или application use-case, зависит от выбранной границы |
|
|
106
106
|
| stream event -> command-local event contract | `bootstrap/commands/stream-run/reporter.ts` | application report, если contract потребуется вне CLI |
|
|
107
107
|
| report/event contract -> command-specific output values | `bootstrap/commands/*/reporter.ts` | без изменений для компактного Inventory-style CLI |
|
|
@@ -109,7 +109,7 @@ process.argv
|
|
|
109
109
|
| string/stream -> stdout | `icore` `TerminalApp`/`Output.write`, собираемые в `bootstrap/cli/runner.ts` | штатный normal output wiring остается в runner-е |
|
|
110
110
|
| warning/error -> stderr | `icore` `Output.error`; project CLI/error policy владеет содержанием | без изменений |
|
|
111
111
|
|
|
112
|
-
## Типичные
|
|
112
|
+
## Типичные ошибки
|
|
113
113
|
|
|
114
114
|
- передавать raw CLI args глубже bootstrap boundary;
|
|
115
115
|
- смешивать raw CLI parsing и generated request DTO mapping в одной функции;
|