@woodger/t-invest-node-sdk 0.5.4 → 0.5.5
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 +26 -0
- package/dist/application/services/unary-limiter.js +35 -8
- package/dist/bootstrap/args/command-options.d.ts +7 -1
- package/dist/bootstrap/args/command-options.js +10 -3
- package/dist/bootstrap/cli/help-catalog.d.ts +7 -7
- package/dist/bootstrap/cli/help-catalog.js +20 -26
- package/dist/bootstrap/cli/registry.d.ts +1 -1
- package/dist/bootstrap/commands/broker-report/cli.js +1 -1
- package/dist/bootstrap/commands/dividends-foreign-issuer/cli.js +1 -1
- package/dist/bootstrap/commands/order-book/cli.d.ts +3 -3
- package/dist/bootstrap/commands/order-book/cli.js +1 -1
- package/dist/bootstrap/commands/stream-run/config.d.ts +29 -6
- package/dist/bootstrap/commands/stream-run/config.js +17 -54
- package/dist/bootstrap/commands/stream-run/reporter.js +2 -0
- package/dist/bootstrap/commands/stream-run/request.mapper.js +70 -40
- package/dist/bootstrap/commands/stream-run/stream-session.js +7 -2
- package/dist/bootstrap/t-invest-node-sdk.js +13 -11
- package/dist/generated/common.js +2 -2
- package/dist/generated/google/api/field_behavior.js +2 -2
- package/dist/generated/google/protobuf/descriptor.js +2 -2
- package/dist/generated/google/protobuf/timestamp.js +2 -2
- package/dist/generated/instruments.js +2 -2
- package/dist/generated/marketdata.js +2 -2
- package/dist/generated/operations.js +2 -2
- package/dist/generated/orders.js +2 -2
- package/dist/generated/sandbox.js +2 -2
- package/dist/generated/signals.js +2 -2
- package/dist/generated/stoporders.js +2 -2
- package/dist/generated/users.js +2 -2
- package/dist/infrastructure/transport/grpc/sdk-call-error.js +5 -6
- package/dist/infrastructure/transport/grpc/sdk-client.d.ts +2 -2
- package/docs/architecture.md +4 -2
- package/docs/clean-architecture/adapters.md +7 -124
- package/docs/clean-architecture/api-commands.md +6 -160
- package/docs/clean-architecture/application.md +101 -1
- package/docs/clean-architecture/cli-output-boundaries.md +72 -29
- package/docs/clean-architecture/dto.md +9 -100
- package/docs/clean-architecture/index.md +6 -44
- package/docs/cli-reference.md +132 -0
- package/docs/cli-stream-configuration.md +5 -3
- package/docs/cli-stream-reference.md +5 -2
- package/docs/guides/custom-unary-limiter.md +11 -7
- package/docs/guides/errors-and-lifecycle.md +21 -0
- package/docs/index.md +2 -3
- package/docs/roadmap.md +1 -28
- package/package.json +9 -8
- package/readme.md +5 -41
|
@@ -17,7 +17,22 @@ function createMarketDataStreamRequests(config) {
|
|
|
17
17
|
if (config.stream !== 'marketdata.marketDataStream') {
|
|
18
18
|
throw new icore_1.CliUsageError(`Expected marketdata bidirectional stream config, got '${config.stream}'`);
|
|
19
19
|
}
|
|
20
|
-
return config.requests
|
|
20
|
+
return config.requests.map((request) => {
|
|
21
|
+
switch (request.type) {
|
|
22
|
+
case 'subscribeCandles':
|
|
23
|
+
return { subscribeCandlesRequest: createSubscribeCandlesRequest(request.instruments) };
|
|
24
|
+
case 'subscribeOrderBook':
|
|
25
|
+
return { subscribeOrderBookRequest: createSubscribeOrderBookRequest(request.instruments) };
|
|
26
|
+
case 'subscribeTrades':
|
|
27
|
+
return { subscribeTradesRequest: createSubscribeTradesRequest(request.instruments) };
|
|
28
|
+
case 'subscribeInfo':
|
|
29
|
+
return { subscribeInfoRequest: createSubscribeInfoRequest(request.instruments) };
|
|
30
|
+
case 'subscribeLastPrice':
|
|
31
|
+
return { subscribeLastPriceRequest: createSubscribeLastPriceRequest(request.instruments) };
|
|
32
|
+
case 'getMySubscriptions':
|
|
33
|
+
return { getMySubscriptions: {} };
|
|
34
|
+
}
|
|
35
|
+
});
|
|
21
36
|
}
|
|
22
37
|
function createMarketDataServerSideStreamRequest(config) {
|
|
23
38
|
if (config.stream !== 'marketdata.marketDataServerSideStream') {
|
|
@@ -34,50 +49,19 @@ function createMarketDataServerSideStreamRequest(config) {
|
|
|
34
49
|
const lastPrices = subscriptions.lastPrices ?? [];
|
|
35
50
|
return {
|
|
36
51
|
subscribeCandlesRequest: candles.length > 0
|
|
37
|
-
?
|
|
38
|
-
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
39
|
-
instruments: candles.map((item) => marketdata_1.CandleInstrument.create({
|
|
40
|
-
interval: item.interval,
|
|
41
|
-
instrumentId: item.instrumentId
|
|
42
|
-
})),
|
|
43
|
-
waitingClose: (0, config_1.resolveCandlesWaitingClose)(candles)
|
|
44
|
-
}
|
|
52
|
+
? createSubscribeCandlesRequest(candles)
|
|
45
53
|
: undefined,
|
|
46
54
|
subscribeOrderBookRequest: orderBooks.length > 0
|
|
47
|
-
?
|
|
48
|
-
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
49
|
-
instruments: orderBooks.map((item) => marketdata_1.OrderBookInstrument.create({
|
|
50
|
-
depth: item.depth,
|
|
51
|
-
instrumentId: item.instrumentId,
|
|
52
|
-
orderBookType: marketdata_1.OrderBookType.ORDERBOOK_TYPE_UNSPECIFIED
|
|
53
|
-
}))
|
|
54
|
-
}
|
|
55
|
+
? createSubscribeOrderBookRequest(orderBooks)
|
|
55
56
|
: undefined,
|
|
56
57
|
subscribeTradesRequest: trades.length > 0
|
|
57
|
-
?
|
|
58
|
-
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
59
|
-
instruments: trades.map((item) => marketdata_1.TradeInstrument.create({
|
|
60
|
-
instrumentId: item.instrumentId
|
|
61
|
-
})),
|
|
62
|
-
tradeSource: marketdata_1.TradeSourceType.TRADE_SOURCE_UNSPECIFIED,
|
|
63
|
-
withOpenInterest: false
|
|
64
|
-
}
|
|
58
|
+
? createSubscribeTradesRequest(trades)
|
|
65
59
|
: undefined,
|
|
66
60
|
subscribeInfoRequest: info.length > 0
|
|
67
|
-
?
|
|
68
|
-
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
69
|
-
instruments: info.map((item) => marketdata_1.InfoInstrument.create({
|
|
70
|
-
instrumentId: item.instrumentId
|
|
71
|
-
}))
|
|
72
|
-
}
|
|
61
|
+
? createSubscribeInfoRequest(info)
|
|
73
62
|
: undefined,
|
|
74
63
|
subscribeLastPriceRequest: lastPrices.length > 0
|
|
75
|
-
?
|
|
76
|
-
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
77
|
-
instruments: lastPrices.map((item) => marketdata_1.LastPriceInstrument.create({
|
|
78
|
-
instrumentId: item.instrumentId
|
|
79
|
-
}))
|
|
80
|
-
}
|
|
64
|
+
? createSubscribeLastPriceRequest(lastPrices)
|
|
81
65
|
: undefined,
|
|
82
66
|
pingSettings: undefined
|
|
83
67
|
};
|
|
@@ -87,7 +71,7 @@ function createPortfolioStreamRequest(config) {
|
|
|
87
71
|
throw new icore_1.CliUsageError(`Expected portfolio stream config, got '${config.stream}'`);
|
|
88
72
|
}
|
|
89
73
|
return {
|
|
90
|
-
accounts: config.accounts
|
|
74
|
+
accounts: config.accounts,
|
|
91
75
|
pingSettings: undefined
|
|
92
76
|
};
|
|
93
77
|
}
|
|
@@ -96,7 +80,7 @@ function createPositionsStreamRequest(config) {
|
|
|
96
80
|
throw new icore_1.CliUsageError(`Expected positions stream config, got '${config.stream}'`);
|
|
97
81
|
}
|
|
98
82
|
return {
|
|
99
|
-
accounts: config.accounts
|
|
83
|
+
accounts: config.accounts,
|
|
100
84
|
withInitialPositions: false,
|
|
101
85
|
pingSettings: undefined
|
|
102
86
|
};
|
|
@@ -106,6 +90,52 @@ function createTradesStreamRequest(config) {
|
|
|
106
90
|
throw new icore_1.CliUsageError(`Expected trades stream config, got '${config.stream}'`);
|
|
107
91
|
}
|
|
108
92
|
return {
|
|
109
|
-
accounts: config.accounts
|
|
93
|
+
accounts: config.accounts
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function createSubscribeCandlesRequest(instruments) {
|
|
97
|
+
return {
|
|
98
|
+
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
99
|
+
instruments: instruments.map((item) => marketdata_1.CandleInstrument.create({
|
|
100
|
+
interval: item.interval,
|
|
101
|
+
instrumentId: item.instrumentId
|
|
102
|
+
})),
|
|
103
|
+
waitingClose: (0, config_1.resolveCandlesWaitingClose)(instruments)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function createSubscribeOrderBookRequest(instruments) {
|
|
107
|
+
return {
|
|
108
|
+
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
109
|
+
instruments: instruments.map((item) => marketdata_1.OrderBookInstrument.create({
|
|
110
|
+
depth: item.depth,
|
|
111
|
+
instrumentId: item.instrumentId,
|
|
112
|
+
orderBookType: marketdata_1.OrderBookType.ORDERBOOK_TYPE_UNSPECIFIED
|
|
113
|
+
}))
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function createSubscribeTradesRequest(instruments) {
|
|
117
|
+
return {
|
|
118
|
+
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
119
|
+
instruments: instruments.map((item) => marketdata_1.TradeInstrument.create({
|
|
120
|
+
instrumentId: item.instrumentId
|
|
121
|
+
})),
|
|
122
|
+
tradeSource: marketdata_1.TradeSourceType.TRADE_SOURCE_UNSPECIFIED,
|
|
123
|
+
withOpenInterest: false
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function createSubscribeInfoRequest(instruments) {
|
|
127
|
+
return {
|
|
128
|
+
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
129
|
+
instruments: instruments.map((item) => marketdata_1.InfoInstrument.create({
|
|
130
|
+
instrumentId: item.instrumentId
|
|
131
|
+
}))
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function createSubscribeLastPriceRequest(instruments) {
|
|
135
|
+
return {
|
|
136
|
+
subscriptionAction: marketdata_1.SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
|
137
|
+
instruments: instruments.map((item) => marketdata_1.LastPriceInstrument.create({
|
|
138
|
+
instrumentId: item.instrumentId
|
|
139
|
+
}))
|
|
110
140
|
};
|
|
111
141
|
}
|
|
@@ -97,11 +97,16 @@ async function* formatStreamRunResponses(stream, responses, runtime, now, elapse
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
finally {
|
|
100
|
-
cancelStream();
|
|
101
100
|
if (pendingRead !== undefined) {
|
|
101
|
+
cancelStream();
|
|
102
102
|
await settleCancelledRead(pendingRead);
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
try {
|
|
105
|
+
await iterator.return?.();
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
cancelStream();
|
|
109
|
+
}
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
function resolveNextTimeoutMs(startedAt, lastResponseAt, runtime, elapsedNow) {
|
|
@@ -87,18 +87,20 @@ class TInvestNodeSDK {
|
|
|
87
87
|
}
|
|
88
88
|
getOrCreateServiceClient(serviceDefinition) {
|
|
89
89
|
this.assertOpen();
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
maxReceiveMessageLength: this.maxReceiveMessageLength,
|
|
95
|
-
signal: this.lifecycleController.signal,
|
|
96
|
-
assertOpen: () => {
|
|
97
|
-
this.assertOpen();
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
this.clientsByServiceDefinition.set(serviceDefinition, client);
|
|
90
|
+
const cachedClient = this.clientsByServiceDefinition.get(serviceDefinition);
|
|
91
|
+
if (cachedClient !== undefined) {
|
|
92
|
+
// Кэш заполняется только клиентами, созданными для этого definition.
|
|
93
|
+
return cachedClient;
|
|
101
94
|
}
|
|
95
|
+
const client = (0, grpc_1.createSdkClient)(serviceDefinition, this.channel, this.metadata, this.options.unaryLimiter, this.unaryLimitResolver, {
|
|
96
|
+
useSsl: this.options.useSsl,
|
|
97
|
+
maxReceiveMessageLength: this.maxReceiveMessageLength,
|
|
98
|
+
signal: this.lifecycleController.signal,
|
|
99
|
+
assertOpen: () => {
|
|
100
|
+
this.assertOpen();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
this.clientsByServiceDefinition.set(serviceDefinition, client);
|
|
102
104
|
return client;
|
|
103
105
|
}
|
|
104
106
|
assertOpen() {
|
package/dist/generated/common.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: common.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.ErrorDetail = exports.BrandData = exports.ResponseMetadata = exports.PageResponse = exports.Page = exports.Ping = exports.PingDelaySettings = exports.PingRequest = exports.Quotation = exports.MoneyValue = exports.RealExchange = exports.ResultSubscriptionStatus = exports.PriceType = exports.SecurityTradingStatus = exports.InstrumentStatus = exports.InstrumentType = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: google/api/field_behavior.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.FieldBehavior = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: google/protobuf/descriptor.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.FeatureSetDefaults = exports.FeatureSet_VisibilityFeature = exports.FeatureSet = exports.UninterpretedOption_NamePart = exports.UninterpretedOption = exports.MethodOptions = exports.ServiceOptions = exports.EnumValueOptions = exports.EnumOptions = exports.OneofOptions = exports.FieldOptions_FeatureSupport = exports.FieldOptions_EditionDefault = exports.FieldOptions = exports.MessageOptions = exports.FileOptions = exports.MethodDescriptorProto = exports.ServiceDescriptorProto = exports.EnumValueDescriptorProto = exports.EnumDescriptorProto_EnumReservedRange = exports.EnumDescriptorProto = exports.OneofDescriptorProto = exports.FieldDescriptorProto = exports.ExtensionRangeOptions_Declaration = exports.ExtensionRangeOptions = exports.DescriptorProto_ReservedRange = exports.DescriptorProto_ExtensionRange = exports.DescriptorProto = exports.FileDescriptorProto = exports.FileDescriptorSet = exports.GeneratedCodeInfo_Annotation_Semantic = exports.FeatureSet_VisibilityFeature_DefaultSymbolVisibility = exports.FeatureSet_EnforceNamingStyle = exports.FeatureSet_JsonFormat = exports.FeatureSet_MessageEncoding = exports.FeatureSet_Utf8Validation = exports.FeatureSet_RepeatedFieldEncoding = exports.FeatureSet_EnumType = exports.FeatureSet_FieldPresence = exports.MethodOptions_IdempotencyLevel = exports.FieldOptions_OptionTargetType = exports.FieldOptions_OptionRetention = exports.FieldOptions_JSType = exports.FieldOptions_CType = exports.FileOptions_OptimizeMode = exports.FieldDescriptorProto_Label = exports.FieldDescriptorProto_Type = exports.ExtensionRangeOptions_VerificationState = exports.SymbolVisibility = exports.Edition = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: google/protobuf/timestamp.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.Timestamp = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: instruments.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.StructuredNotesResponse = exports.StructuredNoteResponse = exports.SharesResponse = exports.ShareResponse = exports.Option = exports.OptionsResponse = exports.OptionResponse = exports.FuturesResponse = exports.FutureResponse = exports.EtfsResponse = exports.EtfResponse = exports.CurrenciesResponse = exports.CurrencyResponse = exports.Coupon = exports.GetBondEventsResponse_BondEvent = exports.GetBondEventsResponse = exports.GetBondEventsRequest = exports.GetBondCouponsResponse = exports.GetBondCouponsRequest = exports.BondsResponse = exports.BondResponse = exports.NewsRequest = exports.FilterOptionsRequest = exports.InstrumentsRequest = exports.InstrumentRequest = exports.TradingDay = exports.TradingSchedule = exports.TradingSchedulesResponse = exports.TradingSchedulesRequest = exports.GetInsiderDealsResponse_TradeDirection = exports.GetAssetReportsResponse_AssetReportPeriodType = exports.StructuredNote_YieldType = exports.StructuredNote_ObservationPrinciple = exports.StructuredNote_LogicPortfolio = exports.GetBondEventsRequest_EventType = exports.InstrumentExchangeType = exports.BondType = exports.RiskLevel = exports.Recommendation = exports.EditFavoritesActionType = exports.StructuredProductType = exports.AssetType = exports.ShareType = exports.InstrumentIdType = exports.OptionSettlementType = exports.OptionStyle = exports.OptionPaymentType = exports.OptionDirection = exports.CouponType = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: marketdata.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.OpenInterest = exports.LastPrice = exports.GetLastPricesResponse = exports.GetLastPricesRequest = exports.HistoricCandle = exports.GetCandlesResponse = exports.GetCandlesRequest = exports.TradingStatus = exports.Trade = exports.Order = exports.OrderBook = exports.Candle = exports.LastPriceSubscription = exports.SubscribeLastPriceResponse = exports.LastPriceInstrument = exports.SubscribeLastPriceRequest = exports.InfoSubscription = exports.SubscribeInfoResponse = exports.InfoInstrument = exports.SubscribeInfoRequest = exports.TradeSubscription = exports.SubscribeTradesResponse = exports.TradeInstrument = exports.SubscribeTradesRequest = exports.OrderBookSubscription = exports.SubscribeOrderBookResponse = exports.OrderBookInstrument = exports.SubscribeOrderBookRequest = exports.CandleSubscription = exports.SubscribeCandlesResponse = exports.CandleInstrument = exports.SubscribeCandlesRequest = exports.MarketDataResponse = exports.MarketDataServerSideStreamRequest = exports.MarketDataRequest = exports.GetTechAnalysisRequest_IndicatorType = exports.GetTechAnalysisRequest_TypeOfPrice = exports.GetTechAnalysisRequest_IndicatorInterval = exports.GetCandlesRequest_CandleSource = exports.LastPriceType = exports.OrderBookType = exports.MarketValueType = exports.CandleSource = exports.CandleInterval = exports.TradeDirection = exports.TradeSourceType = exports.SubscriptionStatus = exports.SubscriptionInterval = exports.SubscriptionAction = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: operations.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.PositionData = exports.PositionsSubscriptionStatus = exports.PositionsSubscriptionResult = exports.PositionsStreamResponse = exports.PositionsStreamRequest = exports.OperationItemTrade = exports.OperationItemTrades = exports.OperationItem = exports.GetOperationsByCursorResponse = exports.GetOperationsByCursorRequest = exports.AccountSubscriptionStatus = exports.PortfolioSubscriptionResult = exports.PortfolioStreamResponse = exports.PortfolioStreamRequest = exports.DividendsForeignIssuerReport = exports.GetDividendsForeignIssuerReportResponse = exports.GenerateDividendsForeignIssuerReportResponse = exports.GetDividendsForeignIssuerReportRequest = exports.GenerateDividendsForeignIssuerReportRequest = exports.GetDividendsForeignIssuerResponse = exports.GetDividendsForeignIssuerRequest = exports.BrokerReport = exports.GetBrokerReportResponse = exports.GetBrokerReportRequest = exports.GenerateBrokerReportResponse = exports.GenerateBrokerReportRequest = exports.BrokerReportResponse = exports.BrokerReportRequest = exports.PositionsOptions = exports.PositionsFutures = exports.PositionsSecurities = exports.VirtualPortfolioPosition = exports.PortfolioPosition = exports.WithdrawLimitsResponse = exports.WithdrawLimitsRequest = exports.PositionsResponse = exports.PositionsRequest = exports.PortfolioResponse = exports.PortfolioRequest = exports.OperationTrade = exports.Operation = exports.OperationsResponse = exports.OperationsRequest = exports.PortfolioRequest_CurrencyRequest = exports.OperationsAccountSubscriptionStatus = exports.PositionsAccountSubscriptionStatus = exports.PortfolioSubscriptionStatus = exports.OperationType = exports.OperationState = exports.protobufPackage = void 0;
|
package/dist/generated/orders.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: orders.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.OrdersServiceDefinition = exports.OrdersStreamServiceDefinition = exports.OrderStateStreamResponse_StopOrderState = exports.OrderStateStreamResponse_OrderState = exports.OrderStateStreamResponse = exports.SubscriptionResponse = exports.OrderStateStreamRequest = exports.GetOrderPriceResponse_ExtraFuture = exports.GetOrderPriceResponse_ExtraBond = exports.GetOrderPriceResponse = exports.GetOrderPriceRequest = exports.GetMaxLotsResponse_SellLimitsView = exports.GetMaxLotsResponse_BuyLimitsView = exports.GetMaxLotsResponse = exports.GetMaxLotsRequest = exports.ReplaceOrderRequest = exports.OrderStage = exports.OrderState = exports.GetOrdersResponse = exports.GetOrdersRequest_GetOrdersRequestFilters = exports.GetOrdersRequest = exports.GetOrderStateRequest = exports.CancelOrderResponse = exports.CancelOrderRequest = exports.PostOrderAsyncResponse = exports.PostOrderAsyncRequest = exports.PostOrderResponse = exports.PostOrderRequest = exports.OrderTrade = exports.OrderTrades = exports.TradesStreamResponse = exports.TradesStreamRequest = exports.OrderStateStreamResponse_StatusCauseInfo = exports.OrderStateStreamResponse_MarkerType = exports.OrderIdType = exports.TimeInForceType = exports.OrderExecutionReportStatus = exports.OrderType = exports.OrderDirection = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: sandbox.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.SandboxServiceDefinition = exports.SandboxPayInResponse = exports.SandboxPayInRequest = exports.CloseSandboxAccountResponse = exports.CloseSandboxAccountRequest = exports.OpenSandboxAccountResponse = exports.OpenSandboxAccountRequest = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: signals.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.SignalServiceDefinition = exports.Signal = exports.GetSignalsResponse = exports.GetSignalsRequest = exports.Strategy = exports.GetStrategiesResponse = exports.GetStrategiesRequest = exports.SignalState = exports.SignalDirection = exports.StrategyType = exports.protobufPackage = void 0;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: stoporders.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.StopOrdersServiceDefinition = exports.StopOrder_TrailingData = exports.StopOrder = exports.CancelStopOrderResponse = exports.CancelStopOrderRequest = exports.GetStopOrdersResponse = exports.GetStopOrdersRequest = exports.PostStopOrderResponse = exports.PostStopOrderRequest_TrailingData = exports.PostStopOrderRequest = exports.TrailingStopStatus = exports.TrailingValueType = exports.TakeProfitType = exports.ExchangeOrderType = exports.StopOrderStatusOption = exports.StopOrderType = exports.StopOrderExpirationType = exports.StopOrderDirection = exports.protobufPackage = void 0;
|
package/dist/generated/users.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.12.
|
|
5
|
-
// protoc v7.36.
|
|
4
|
+
// protoc-gen-ts_proto v2.12.4
|
|
5
|
+
// protoc v7.36.2
|
|
6
6
|
// source: users.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.UsersServiceDefinition = exports.InstrumentParameter = exports.AccountValuesWithParameters = exports.GetAccountValuesResponse = exports.GetAccountValuesRequest = exports.PayInResponse = exports.PayInRequest = exports.CurrencyTransferResponse = exports.CurrencyTransferRequest = exports.BankAccount = exports.GetBankAccountsResponse = exports.GetBankAccountsRequest = exports.GetInfoResponse = exports.GetInfoRequest = exports.StreamLimit = exports.UnaryLimit = exports.GetUserTariffResponse = exports.GetUserTariffRequest = exports.GetMarginAttributesResponse = exports.GetMarginAttributesRequest = exports.Account = exports.GetAccountsResponse = exports.GetAccountsRequest = exports.AccountValue = exports.AccessLevel = exports.AccountStatus = exports.AccountType = exports.protobufPackage = void 0;
|
|
@@ -163,13 +163,12 @@ function isTlsCertificateError(error, useSsl) {
|
|
|
163
163
|
return false;
|
|
164
164
|
}
|
|
165
165
|
const normalizedDetails = error.details.toLowerCase();
|
|
166
|
-
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
166
|
+
const hasCertificateErrorCode = tlsCertificateErrorCodes.some((code) => error.details.includes(code));
|
|
169
167
|
const hasCertificateErrorMessage = tlsCertificateErrorMessages.some((message) => normalizedDetails.includes(message));
|
|
170
|
-
return
|
|
171
|
-
&& (
|
|
172
|
-
|
|
168
|
+
return (normalizedDetails.includes(grpcConnectionErrorMarker)
|
|
169
|
+
&& (hasCertificateErrorCode || hasCertificateErrorMessage))
|
|
170
|
+
|| tlsCertificateErrorCodes.includes(error.details.trim())
|
|
171
|
+
|| standaloneTlsCertificateErrorMessages.has(normalizedDetails.trim());
|
|
173
172
|
}
|
|
174
173
|
function errorName(error) {
|
|
175
174
|
if (typeof error !== 'object' || error === null) {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Здесь не должно быть SDK lifecycle ownership или API request mapping.
|
|
10
10
|
*/
|
|
11
|
-
import type { Channel } from 'nice-grpc';
|
|
11
|
+
import type { Channel, CompatServiceDefinition } from 'nice-grpc';
|
|
12
12
|
import type { TInvestUnaryLimiter } from '../../../application/services/unary-limiter';
|
|
13
13
|
import { Metadata } from 'nice-grpc';
|
|
14
14
|
import type { SdkCallRuntime } from './sdk-middleware';
|
|
15
15
|
import type { UnaryLimitResolver } from './unary-limit-resolver';
|
|
16
|
-
export declare function createSdkClient<
|
|
16
|
+
export declare function createSdkClient<Service extends CompatServiceDefinition>(serviceDefinition: Service, channel: Channel, metadata: Metadata, unaryLimiter: TInvestUnaryLimiter | undefined, unaryLimitResolver: UnaryLimitResolver, runtime: SdkCallRuntime): import("nice-grpc").RawClient<import("nice-grpc").NormalizedServiceDefinition<Service>, {}>;
|
package/docs/architecture.md
CHANGED
|
@@ -48,6 +48,8 @@ src/generated
|
|
|
48
48
|
|
|
49
49
|
Здесь допустимы imports из `nice-grpc`, generated service definitions и application services. Application не должен импортировать concrete infrastructure modules.
|
|
50
50
|
|
|
51
|
+
Фабрика `createSdkClient()` выводит тип клиента из переданного service definition. SDK facade сохраняет package-owned public service interfaces; единственное приведение типа для heterogeneous cache локализовано при чтении клиента по его definition.
|
|
52
|
+
|
|
51
53
|
## `bootstrap`
|
|
52
54
|
|
|
53
55
|
Runtime entrypoints разделены на публичные package entrypoints и внутреннюю bootstrap-механику.
|
|
@@ -62,7 +64,7 @@ Runtime entrypoints разделены на публичные package entrypoin
|
|
|
62
64
|
- `bootstrap/cli` - CLI contract, registry, rendering help, декларативный `help-catalog.ts`, version, terminal error policy и runner layer;
|
|
63
65
|
- `bootstrap/commands` - handlers CLI-команд и общий `sdk-command-lifecycle.ts` для коротких SDK-вызовов;
|
|
64
66
|
- `bootstrap/commands/*/request.mapper.ts` - request mapping, который разделяют production и Sandbox варианты одной операции;
|
|
65
|
-
- `bootstrap/commands/stream-run` -
|
|
67
|
+
- `bootstrap/commands/stream-run` - config parser возвращает проверенную конфигурацию с вариантами по `stream`; request mapper создаёт initial bidirectional и server-side generated requests через общие subscription builders. Stream session lifecycle и reporter выделены отдельно;
|
|
66
68
|
- `bootstrap/commands/*/reporter.ts` - command-specific mapping и presentation formatting. Unary reporter-ы обычно строят `application/reports`, а специализированный stream reporter может владеть локальным event contract.
|
|
67
69
|
|
|
68
70
|
Внешняя зависимость `icore` предоставляет общую механику options и commands, примитивы JSON/CSV-row/table и default terminal output facade. Это не отдельный слой проекта: integration wiring остаётся в `bootstrap`, а project-specific adapters и policies — в своих файлах-владельцах.
|
|
@@ -204,4 +206,4 @@ T-Invest proto-файлы копируются в `contracts/*.proto` с исх
|
|
|
204
206
|
4. при изменении вспомогательных contracts получить их из точного выпуска и обновить соответствующую запись `supportingSources`;
|
|
205
207
|
5. выполнить `local.generationCommand`, затем `npm run build`, `npm run lint` и `npm test`.
|
|
206
208
|
|
|
207
|
-
Proto generation читает только vendored snapshot и не обращается к сети. Compiler `protoc` и plugin `ts-proto` закреплены в dev-зависимостях, а команда запускает их из локального `node_modules`; системный `protoc` не нужен. Текущий generated snapshot создан с `protoc 36.
|
|
209
|
+
Proto generation читает только vendored snapshot и не обращается к сети. Compiler `protoc` и plugin `ts-proto` закреплены в dev-зависимостях, а команда запускает их из локального `node_modules`; системный `protoc` не нужен. Текущий generated snapshot создан с `protoc 36.2`.
|
|
@@ -1,144 +1,27 @@
|
|
|
1
1
|
# Адаптеры
|
|
2
2
|
|
|
3
|
-
> Type:
|
|
3
|
+
> Type: Navigation. Материал объединён с описанием форматирования и вывода CLI. Прежние разделы ведут к соответствующим частям общего документа.
|
|
4
4
|
|
|
5
5
|
## Контекст
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
В SDK command-specific CLI adapter-ы находятся рядом с командами в `bootstrap`. `icore` предоставляет общую механику options и commands, JSON/CSV-row/table rendering и terminal output. Это внешняя зависимость, а не новый project layer или директория внутри `infrastructure`.
|
|
10
|
-
|
|
11
|
-
Правила форматирования и штатной записи в stdout/stderr описаны в документе [«Разделение форматирования и вывода в CLI»](./cli-output-boundaries.md).
|
|
7
|
+
[Контекст](./cli-output-boundaries.md#контекст).
|
|
12
8
|
|
|
13
9
|
## Текущее состояние
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
src/application
|
|
17
|
-
reports/
|
|
18
|
-
|
|
19
|
-
src/infrastructure
|
|
20
|
-
interceptor/
|
|
21
|
-
report-values.ts
|
|
22
|
-
transport/
|
|
23
|
-
grpc/
|
|
24
|
-
|
|
25
|
-
src/bootstrap
|
|
26
|
-
cli/
|
|
27
|
-
contract.ts
|
|
28
|
-
error.ts
|
|
29
|
-
runner.ts
|
|
30
|
-
commands/*/
|
|
31
|
-
cli.ts
|
|
32
|
-
reporter.ts
|
|
33
|
-
|
|
34
|
-
external dependency
|
|
35
|
-
icore
|
|
36
|
-
option/command mechanics
|
|
37
|
-
renderJson/renderCsv/renderCsvRow/renderTextTable
|
|
38
|
-
TerminalApp/Output
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`infrastructure/transport/grpc` - технический adapter к `nice-grpc`:
|
|
42
|
-
|
|
43
|
-
- channel;
|
|
44
|
-
- metadata;
|
|
45
|
-
- middleware;
|
|
46
|
-
- typed clients;
|
|
47
|
-
- mapping gRPC method path в transport-neutral `TInvestUnaryQuota`;
|
|
48
|
-
- mapping `nice-grpc` client failures в transport-neutral `SdkError`.
|
|
49
|
-
|
|
50
|
-
`unary-limit-resolver.ts` выбирает method rule или service fallback и разрешает quota bucket. Middleware передаёт Consumer-owned limiter-у полный `path`, `bucket`, `maxRequests`, `windowMs` и `AbortSignal`. Application port не разбирает gRPC path и не владеет transport lifecycle.
|
|
51
|
-
|
|
52
|
-
`infrastructure/interceptor` содержит технический process hook для известных warnings. Обычный вывод команд проходит через terminal app.
|
|
53
|
-
|
|
54
|
-
`infrastructure/report-values.ts` - принадлежащий проекту адаптер скалярных значений:
|
|
55
|
-
|
|
56
|
-
- преобразует повторяющиеся provider scalar DTO values в reusable report values;
|
|
57
|
-
- сохраняет `MoneyValue` в JSON как структурный `ReportMoney`;
|
|
58
|
-
- предоставляет text helper для table cells вида `"amount currency"`;
|
|
59
|
-
- не знает command names, report shapes, columns, generic renderers или output delivery.
|
|
60
|
-
|
|
61
|
-
`bootstrap/commands/*/reporter.ts` служит command-specific CLI adapter-ом:
|
|
62
|
-
|
|
63
|
-
- принимает generated response или stream event;
|
|
64
|
-
- строит application report, если команда использует такой контракт;
|
|
65
|
-
- выбирает поля, порядок, headers и пользовательское представление;
|
|
66
|
-
- вызывает generic render primitives `icore`, когда они подходят формату;
|
|
67
|
-
- оставляет project-specific rendering, например JSONL event shape, у команды.
|
|
68
|
-
|
|
69
|
-
`bootstrap/cli/runner.ts` связывает компоненты CLI:
|
|
70
|
-
|
|
71
|
-
- создает default `Output` или принимает injected `Output`;
|
|
72
|
-
- собирает lightweight `TerminalApp` для shortcuts и external errors;
|
|
73
|
-
- лениво загружает command registry и собирает command `TerminalApp`;
|
|
74
|
-
- направляет help, version и warnings через output facade;
|
|
75
|
-
- передаёт prepared command в terminal app, который выполняет её и записывает результат.
|
|
11
|
+
[Текущее состояние](./cli-output-boundaries.md#адаптеры-проекта).
|
|
76
12
|
|
|
77
13
|
## Адаптер и вывод
|
|
78
14
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```text
|
|
82
|
-
CLI adapter:
|
|
83
|
-
provider response/event
|
|
84
|
-
-> application report или command-local event contract
|
|
85
|
-
-> command-specific output values
|
|
86
|
-
-> string через generic primitive или project-specific formatter
|
|
87
|
-
|
|
88
|
-
normal output:
|
|
89
|
-
string/AsyncIterable -> TerminalApp -> Output.write -> stdout
|
|
90
|
-
|
|
91
|
-
diagnostics:
|
|
92
|
-
warnings/errors -> Output.error -> stderr
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Reporter знает смысл команды и её output contract. Render primitives из `icore` отвечают только за общую механику формата: JSON serialization, CSV escaping/document joining и выравнивание plain-text table. `Output` из `icore` отвечает только за доставку готового результата или diagnostics с учётом backpressure.
|
|
96
|
-
|
|
97
|
-
Локальные wrappers над этими primitives не нужны, пока у проекта нет самостоятельного поведения или контракта поверх generic API.
|
|
15
|
+
[Адаптер и вывод](./cli-output-boundaries.md#основная-граница).
|
|
98
16
|
|
|
99
17
|
## Направление зависимостей
|
|
100
18
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```text
|
|
104
|
-
bootstrap/commands/*/reporter.ts -> application/reports
|
|
105
|
-
bootstrap/commands/*/reporter.ts -> infrastructure/report-values.ts
|
|
106
|
-
bootstrap/commands/*/reporter.ts -> icore presentation primitives
|
|
107
|
-
bootstrap/cli/runner.ts -> icore TerminalApp/Output
|
|
108
|
-
infrastructure/report-values.ts -> application/reports
|
|
109
|
-
infrastructure/transport/grpc -> application services/contracts
|
|
110
|
-
infrastructure/unary resolver -> application TInvestUnaryQuota
|
|
111
|
-
infrastructure/grpc middleware -> application TInvestUnaryLimiter
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Недопустимо:
|
|
115
|
-
|
|
116
|
-
```text
|
|
117
|
-
application -> bootstrap/commands/*/reporter.ts
|
|
118
|
-
application -> icore CLI/presentation mechanics
|
|
119
|
-
infrastructure/report-values.ts -> command-specific report formatting
|
|
120
|
-
generic output facade -> выбор полей или JSON contract команды
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Прямой import `icore` из `bootstrap` не меняет направление project layers: bootstrap остаётся внешним composition/presentation слоем и связывает external mechanics с локальными contracts.
|
|
19
|
+
[Направление зависимостей](./cli-output-boundaries.md#направление-зависимостей).
|
|
124
20
|
|
|
125
21
|
## История перехода
|
|
126
22
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
1. Project-owned generic renderers и stdout/stderr writers удалены.
|
|
130
|
-
2. Reporter-ы вызывают публичные `icore` render primitives напрямую, без локальных forwarding wrappers.
|
|
131
|
-
3. Bootstrap CLI собирает `TerminalApp` и `Output`, но сохраняет project-owned alias inventory, help/version shortcuts, warnings и error policy; command aliases передаются в canonical definitions и разрешаются самим `icore`.
|
|
132
|
-
4. `application/reports`, command-specific presentation и `infrastructure/report-values.ts` остались project-owned contracts.
|
|
133
|
-
|
|
134
|
-
Отдельный use-case слой понадобится, только если command перестанет быть простой обёрткой над одним SDK call.
|
|
23
|
+
[История перехода](./cli-output-boundaries.md#история-перехода).
|
|
135
24
|
|
|
136
25
|
## Короткое правило
|
|
137
26
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
Если код отвечает на вопрос "как механически сериализовать выбранные значения", используйте подходящий public primitive `icore`.
|
|
141
|
-
|
|
142
|
-
Если код отвечает на вопрос "как доставить готовый результат", это `TerminalApp`/`Output`, собранные в CLI runner-е.
|
|
143
|
-
|
|
144
|
-
Если код отвечает на вопрос "какой сценарий выполнить", это application use-case.
|
|
27
|
+
[Короткое правило](./cli-output-boundaries.md#короткое-правило).
|