@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
|
@@ -4,32 +4,23 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
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.
|
|
13
|
+
exports.operationsByCursorCommand = void 0;
|
|
14
14
|
exports.createOperationsByCursorCommand = createOperationsByCursorCommand;
|
|
15
|
-
exports.createOperationsByCursorRequest = createOperationsByCursorRequest;
|
|
16
|
-
const operations_1 = require("../../../generated/operations");
|
|
17
|
-
const icore_1 = require("icore");
|
|
18
15
|
const contract_1 = require("../../cli/contract");
|
|
19
|
-
const
|
|
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 reporter_1 = require("./reporter");
|
|
23
|
-
|
|
20
|
+
const request_mapper_1 = require("./request.mapper");
|
|
24
21
|
const operationsByCursorCommandPath = ['operation', 'page'];
|
|
25
22
|
const defaultOperationsByCursorSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
26
|
-
const
|
|
27
|
-
unspecified: operations_1.OperationState.OPERATION_STATE_UNSPECIFIED,
|
|
28
|
-
executed: operations_1.OperationState.OPERATION_STATE_EXECUTED,
|
|
29
|
-
canceled: operations_1.OperationState.OPERATION_STATE_CANCELED,
|
|
30
|
-
progress: operations_1.OperationState.OPERATION_STATE_PROGRESS
|
|
31
|
-
};
|
|
32
|
-
const operationStateNames = Object.keys(operationStates);
|
|
23
|
+
const operationStateNames = ['unspecified', 'executed', 'canceled', 'progress'];
|
|
33
24
|
const operationsByCursorStateOptionsSchema = {
|
|
34
25
|
state: {
|
|
35
26
|
type: 'string',
|
|
@@ -88,32 +79,6 @@ const operationsByCursorFormatOptionsSchema = {
|
|
|
88
79
|
}
|
|
89
80
|
};
|
|
90
81
|
const operationsByCursorOptionsSchema = (0, command_options_1.withSdkOptions)(operationsByCursorRequestOptionsSchema, operationsByCursorFormatOptionsSchema);
|
|
91
|
-
function parseOperationsByCursorLimitOption(rawValue) {
|
|
92
|
-
if (rawValue === undefined) {
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
if (!/^\d+$/.test(rawValue)) {
|
|
96
|
-
throw new icore_1.CliUsageError("Expected '--limit' as integer from 1 to 1000");
|
|
97
|
-
}
|
|
98
|
-
const limit = Number(rawValue);
|
|
99
|
-
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 1000) {
|
|
100
|
-
throw new icore_1.CliUsageError("Expected '--limit' as integer from 1 to 1000");
|
|
101
|
-
}
|
|
102
|
-
return limit;
|
|
103
|
-
}
|
|
104
|
-
function parseOperationsByCursorOperationTypesOption(rawValue) {
|
|
105
|
-
if (rawValue === undefined) {
|
|
106
|
-
return [];
|
|
107
|
-
}
|
|
108
|
-
const operationTypes = (0, command_options_1.parseCommaSeparatedStringListOption)(rawValue, 'operation-type');
|
|
109
|
-
return operationTypes.map((value) => {
|
|
110
|
-
const operationType = (0, operations_1.operationTypeFromJSON)(value);
|
|
111
|
-
if (operationType === operations_1.OperationType.UNRECOGNIZED) {
|
|
112
|
-
throw new icore_1.CliUsageError("Expected '--operation-type' as generated OperationType name");
|
|
113
|
-
}
|
|
114
|
-
return operationType;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
82
|
function createOperationsByCursorCommand(createSdk = defaultOperationsByCursorSdkFactory) {
|
|
118
83
|
return contract_1.command.define({
|
|
119
84
|
path: operationsByCursorCommandPath,
|
|
@@ -125,40 +90,10 @@ function createOperationsByCursorCommand(createSdk = defaultOperationsByCursorSd
|
|
|
125
90
|
}
|
|
126
91
|
exports.operationsByCursorCommand = createOperationsByCursorCommand();
|
|
127
92
|
async function runOperationsByCursorCommand(options, createSdk) {
|
|
128
|
-
const request = createOperationsByCursorRequest(options);
|
|
93
|
+
const request = (0, request_mapper_1.createOperationsByCursorRequest)(options);
|
|
129
94
|
const { format } = options;
|
|
130
|
-
|
|
131
|
-
try {
|
|
95
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
132
96
|
const response = await sdk.operations.getOperationsByCursor(request);
|
|
133
97
|
return (0, reporter_1.formatOperationsByCursor)(response, format);
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
sdk.close();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function createOperationsByCursorRequest(options) {
|
|
140
|
-
const from = parseOptionalDateTimeOption(options.from, 'from');
|
|
141
|
-
const to = parseOptionalDateTimeOption(options.to, 'to');
|
|
142
|
-
if (from !== undefined && to !== undefined && from.getTime() > to.getTime()) {
|
|
143
|
-
throw new icore_1.CliUsageError("Expected '--from' to be earlier than or equal to '--to'");
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
accountId: options['account-id'],
|
|
147
|
-
instrumentId: options['instrument-id'] ?? '',
|
|
148
|
-
from,
|
|
149
|
-
to,
|
|
150
|
-
cursor: options.cursor ?? '',
|
|
151
|
-
limit: parseOperationsByCursorLimitOption(options.limit),
|
|
152
|
-
operationTypes: parseOperationsByCursorOperationTypesOption(options['operation-type']),
|
|
153
|
-
state: operationStates[options.state],
|
|
154
|
-
withoutCommissions: options['without-commissions'],
|
|
155
|
-
withoutTrades: options['without-trades'],
|
|
156
|
-
withoutOvernights: options['without-overnights']
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function parseOptionalDateTimeOption(value, name) {
|
|
160
|
-
if (value === undefined) {
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
return (0, command_options_1.parseDateTimeOption)(value, name);
|
|
98
|
+
});
|
|
164
99
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль хранит request mapping, общий для постраничных production и Sandbox operations.
|
|
3
|
+
*
|
|
4
|
+
* Здесь допустимы generated enum mapping, pagination и проверка диапазона.
|
|
5
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
6
|
+
*/
|
|
7
|
+
import { OperationState, type GetOperationsByCursorRequest } 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 OperationsByCursorRequestOptions {
|
|
15
|
+
readonly 'account-id': string;
|
|
16
|
+
readonly 'instrument-id'?: string | undefined;
|
|
17
|
+
readonly 'operation-type'?: string | undefined;
|
|
18
|
+
readonly 'without-commissions': boolean;
|
|
19
|
+
readonly 'without-trades': boolean;
|
|
20
|
+
readonly 'without-overnights': boolean;
|
|
21
|
+
readonly from?: string | undefined;
|
|
22
|
+
readonly to?: string | undefined;
|
|
23
|
+
readonly cursor?: string | undefined;
|
|
24
|
+
readonly limit?: string | undefined;
|
|
25
|
+
readonly state: keyof typeof operationStates;
|
|
26
|
+
}
|
|
27
|
+
export declare function createOperationsByCursorRequest(options: OperationsByCursorRequestOptions): GetOperationsByCursorRequest;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль хранит request mapping, общий для постраничных production и Sandbox operations.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы generated enum mapping, pagination и проверка диапазона.
|
|
6
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createOperationsByCursorRequest = createOperationsByCursorRequest;
|
|
10
|
+
const operations_1 = require("../../../generated/operations");
|
|
11
|
+
const icore_1 = require("icore");
|
|
12
|
+
const command_options_1 = require("../../args/command-options");
|
|
13
|
+
const operationStates = {
|
|
14
|
+
unspecified: operations_1.OperationState.OPERATION_STATE_UNSPECIFIED,
|
|
15
|
+
executed: operations_1.OperationState.OPERATION_STATE_EXECUTED,
|
|
16
|
+
canceled: operations_1.OperationState.OPERATION_STATE_CANCELED,
|
|
17
|
+
progress: operations_1.OperationState.OPERATION_STATE_PROGRESS
|
|
18
|
+
};
|
|
19
|
+
function createOperationsByCursorRequest(options) {
|
|
20
|
+
const from = parseOptionalDateTimeOption(options.from, 'from');
|
|
21
|
+
const to = parseOptionalDateTimeOption(options.to, 'to');
|
|
22
|
+
if (from !== undefined && to !== undefined && from.getTime() > to.getTime()) {
|
|
23
|
+
throw new icore_1.CliUsageError("Expected '--from' to be earlier than or equal to '--to'");
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
accountId: options['account-id'],
|
|
27
|
+
instrumentId: options['instrument-id'] ?? '',
|
|
28
|
+
from,
|
|
29
|
+
to,
|
|
30
|
+
cursor: options.cursor ?? '',
|
|
31
|
+
limit: parseOperationsByCursorLimitOption(options.limit),
|
|
32
|
+
operationTypes: parseOperationsByCursorOperationTypesOption(options['operation-type']),
|
|
33
|
+
state: operationStates[options.state],
|
|
34
|
+
withoutCommissions: options['without-commissions'],
|
|
35
|
+
withoutTrades: options['without-trades'],
|
|
36
|
+
withoutOvernights: options['without-overnights']
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function parseOperationsByCursorLimitOption(rawValue) {
|
|
40
|
+
if (rawValue === undefined) {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
if (!/^\d+$/.test(rawValue)) {
|
|
44
|
+
throw new icore_1.CliUsageError("Expected '--limit' as integer from 1 to 1000");
|
|
45
|
+
}
|
|
46
|
+
const limit = Number(rawValue);
|
|
47
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 1000) {
|
|
48
|
+
throw new icore_1.CliUsageError("Expected '--limit' as integer from 1 to 1000");
|
|
49
|
+
}
|
|
50
|
+
return limit;
|
|
51
|
+
}
|
|
52
|
+
function parseOperationsByCursorOperationTypesOption(rawValue) {
|
|
53
|
+
if (rawValue === undefined) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
const operationTypes = (0, command_options_1.parseCommaSeparatedStringListOption)(rawValue, 'operation-type');
|
|
57
|
+
return operationTypes.map((value) => {
|
|
58
|
+
const operationType = (0, operations_1.operationTypeFromJSON)(value);
|
|
59
|
+
if (operationType === operations_1.OperationType.UNRECOGNIZED) {
|
|
60
|
+
throw new icore_1.CliUsageError("Expected '--operation-type' as generated OperationType name");
|
|
61
|
+
}
|
|
62
|
+
return operationType;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function parseOptionalDateTimeOption(value, name) {
|
|
66
|
+
if (value === undefined) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return (0, command_options_1.parseDateTimeOption)(value, name);
|
|
70
|
+
}
|
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
* Здесь допустимы:
|
|
5
5
|
* - объявление command path и option schema;
|
|
6
6
|
* - преобразование CLI options в generated request;
|
|
7
|
-
* -
|
|
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, OptionResponse } from '../../../generated/instruments';
|
|
13
|
-
import { formatOption } from './reporter';
|
|
14
13
|
type OptionSdk = {
|
|
15
14
|
instruments: {
|
|
16
15
|
optionBy(request: InstrumentRequest): Promise<OptionResponse>;
|
|
@@ -80,4 +79,4 @@ export declare const optionCommand: Omit<import("icore").CommandDefinition<{
|
|
|
80
79
|
}, undefined, string, readonly ["instrument", "option", "show"], undefined, void, readonly []>, "metadata"> & {
|
|
81
80
|
metadata?: undefined;
|
|
82
81
|
};
|
|
83
|
-
export {
|
|
82
|
+
export {};
|
|
@@ -5,20 +5,19 @@
|
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
7
|
* - преобразование CLI options в generated request;
|
|
8
|
-
* -
|
|
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.
|
|
13
|
+
exports.optionCommand = void 0;
|
|
14
14
|
exports.createOptionCommand = createOptionCommand;
|
|
15
15
|
const contract_1 = require("../../cli/contract");
|
|
16
|
-
const
|
|
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, "formatOption", { enumerable: true, get: function () { return reporter_1.formatOption; } });
|
|
22
21
|
const optionCommandPath = ['instrument', 'option', 'show'];
|
|
23
22
|
const defaultOptionSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
24
23
|
const optionFormatOptionsSchema = {
|
|
@@ -42,12 +41,8 @@ exports.optionCommand = createOptionCommand();
|
|
|
42
41
|
async function runOptionCommand(options, createSdk) {
|
|
43
42
|
const { format } = options;
|
|
44
43
|
const request = (0, instruments_args_1.createInstrumentLookupRequestFromOptions)(options);
|
|
45
|
-
|
|
46
|
-
try {
|
|
44
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
47
45
|
const response = await sdk.instruments.optionBy(request);
|
|
48
46
|
return (0, reporter_1.formatOption)(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
|
-
* -
|
|
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 { FilterOptionsRequest, OptionsResponse } from '../../../generated/instruments';
|
|
13
13
|
import type { InferOptions } from 'icore';
|
|
14
14
|
import type { CommandRequestOptions } from '../../args/command-options';
|
|
15
|
-
import { formatOptionsBy } from './reporter';
|
|
16
15
|
type OptionsBySdk = {
|
|
17
16
|
instruments: {
|
|
18
17
|
optionsBy(request: FilterOptionsRequest): Promise<OptionsResponse>;
|
|
@@ -104,5 +103,5 @@ export declare const optionsByCommand: Omit<import("icore").CommandDefinition<{
|
|
|
104
103
|
}, undefined, string, readonly ["instrument", "option", "list"], undefined, void, readonly []>, "metadata"> & {
|
|
105
104
|
metadata?: undefined;
|
|
106
105
|
};
|
|
107
|
-
export { formatOptionsBy };
|
|
108
106
|
export declare function createOptionsByRequest(options: OptionsByRequestOptions): FilterOptionsRequest;
|
|
107
|
+
export {};
|
|
@@ -5,20 +5,19 @@
|
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
7
|
* - преобразование CLI options в generated request;
|
|
8
|
-
* -
|
|
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.
|
|
13
|
+
exports.optionsByCommand = void 0;
|
|
14
14
|
exports.createOptionsByCommand = createOptionsByCommand;
|
|
15
15
|
exports.createOptionsByRequest = createOptionsByRequest;
|
|
16
16
|
const contract_1 = require("../../cli/contract");
|
|
17
|
-
const
|
|
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, "formatOptionsBy", { enumerable: true, get: function () { return reporter_1.formatOptionsBy; } });
|
|
22
21
|
const optionsByCommandPath = ['instrument', 'option', 'list'];
|
|
23
22
|
const defaultOptionsBySdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
24
23
|
const optionsByRequestOptionsSchema = {
|
|
@@ -51,14 +50,10 @@ exports.optionsByCommand = createOptionsByCommand();
|
|
|
51
50
|
async function runOptionsByCommand(options, createSdk) {
|
|
52
51
|
const request = createOptionsByRequest(options);
|
|
53
52
|
const { format } = options;
|
|
54
|
-
|
|
55
|
-
try {
|
|
53
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
56
54
|
const response = await sdk.instruments.optionsBy(request);
|
|
57
55
|
return (0, reporter_1.formatOptionsBy)(response.instruments, format);
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
sdk.close();
|
|
61
|
-
}
|
|
56
|
+
});
|
|
62
57
|
}
|
|
63
58
|
function createOptionsByRequest(options) {
|
|
64
59
|
return {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Здесь допустимы:
|
|
5
5
|
* - объявление command path и option schema;
|
|
6
6
|
* - преобразование CLI options в generated request;
|
|
7
|
-
* -
|
|
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 { GetOrderBookRequest, type GetOrderBookResponse } from '../../../generated/marketdata';
|
|
13
13
|
import type { InferOptions } from 'icore';
|
|
14
14
|
import type { CommandRequestOptions } from '../../args/command-options';
|
|
15
|
-
import { formatOrderBook } from './reporter';
|
|
16
15
|
type OrderBookSdk = {
|
|
17
|
-
|
|
16
|
+
marketData: {
|
|
18
17
|
getOrderBook(request: GetOrderBookRequest): Promise<GetOrderBookResponse>;
|
|
19
18
|
};
|
|
20
19
|
close(): void;
|
|
@@ -116,5 +115,5 @@ export declare const orderBookCommand: Omit<import("icore").CommandDefinition<{
|
|
|
116
115
|
}, undefined, string, readonly ["market", "order-book"], undefined, void, readonly []>, "metadata"> & {
|
|
117
116
|
metadata?: undefined;
|
|
118
117
|
};
|
|
119
|
-
export { formatOrderBook };
|
|
120
118
|
export declare function createOrderBookRequest(options: OrderBookRequestOptions): GetOrderBookRequest;
|
|
119
|
+
export {};
|
|
@@ -5,21 +5,20 @@
|
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
7
|
* - преобразование CLI options в generated request;
|
|
8
|
-
* -
|
|
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.
|
|
13
|
+
exports.orderBookCommand = void 0;
|
|
14
14
|
exports.createOrderBookCommand = createOrderBookCommand;
|
|
15
15
|
exports.createOrderBookRequest = createOrderBookRequest;
|
|
16
16
|
const marketdata_1 = require("../../../generated/marketdata");
|
|
17
17
|
const contract_1 = require("../../cli/contract");
|
|
18
|
-
const
|
|
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, "formatOrderBook", { enumerable: true, get: function () { return reporter_1.formatOrderBook; } });
|
|
23
22
|
const orderBookCommandPath = ['market', 'order-book'];
|
|
24
23
|
const defaultOrderBookSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
25
24
|
const orderBookDepthOptionsSchema = {
|
|
@@ -56,14 +55,10 @@ exports.orderBookCommand = createOrderBookCommand();
|
|
|
56
55
|
async function runOrderBookCommand(options, createSdk) {
|
|
57
56
|
const request = createOrderBookRequest(options);
|
|
58
57
|
const { format } = options;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const response = await sdk.marketdata.getOrderBook(request);
|
|
58
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
59
|
+
const response = await sdk.marketData.getOrderBook(request);
|
|
62
60
|
return (0, reporter_1.formatOrderBook)(response, format);
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
sdk.close();
|
|
66
|
-
}
|
|
61
|
+
});
|
|
67
62
|
}
|
|
68
63
|
function createOrderBookRequest(options) {
|
|
69
64
|
return marketdata_1.GetOrderBookRequest.create({
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Здесь допустимы:
|
|
5
5
|
* - объявление command path и option schema;
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
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 { GetOrderStateRequest, OrderState } from '../../../generated/orders';
|
|
13
|
-
import type { InferOptions } from 'icore';
|
|
14
|
-
import type { CommandRequestOptions } from '../../args/command-options';
|
|
15
|
-
import { formatOrderState } from './reporter';
|
|
16
13
|
type OrderStateSdk = {
|
|
17
14
|
orders: {
|
|
18
15
|
getOrderState(request: GetOrderStateRequest): Promise<OrderState>;
|
|
@@ -20,35 +17,6 @@ type OrderStateSdk = {
|
|
|
20
17
|
close(): void;
|
|
21
18
|
};
|
|
22
19
|
type OrderStateSdkFactory = (options: TInvestOptions) => OrderStateSdk;
|
|
23
|
-
declare const orderStateOptionsSchema: {
|
|
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 'account-id': {
|
|
37
|
-
readonly type: 'string';
|
|
38
|
-
readonly required: true;
|
|
39
|
-
};
|
|
40
|
-
readonly 'order-id': {
|
|
41
|
-
readonly type: 'string';
|
|
42
|
-
readonly required: true;
|
|
43
|
-
};
|
|
44
|
-
readonly format: {
|
|
45
|
-
readonly type: 'string';
|
|
46
|
-
readonly choices: readonly ["json", "table"];
|
|
47
|
-
readonly default: 'table';
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
type OrderStateOptions = InferOptions<typeof orderStateOptionsSchema>;
|
|
51
|
-
type OrderStateRequestOptions = CommandRequestOptions<OrderStateOptions, 'account-id' | 'order-id'>;
|
|
52
20
|
export declare function createOrderStateCommand(createSdk?: OrderStateSdkFactory): Omit<import("icore").CommandDefinition<{
|
|
53
21
|
readonly token: {
|
|
54
22
|
readonly type: 'string';
|
|
@@ -107,5 +75,4 @@ export declare const orderStateCommand: Omit<import("icore").CommandDefinition<{
|
|
|
107
75
|
}, undefined, string, readonly ["order", "show"], undefined, void, readonly []>, "metadata"> & {
|
|
108
76
|
metadata?: undefined;
|
|
109
77
|
};
|
|
110
|
-
export {
|
|
111
|
-
export declare function createOrderStateRequest(options: OrderStateRequestOptions): GetOrderStateRequest;
|
|
78
|
+
export {};
|
|
@@ -4,22 +4,20 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
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.
|
|
13
|
+
exports.orderStateCommand = void 0;
|
|
14
14
|
exports.createOrderStateCommand = createOrderStateCommand;
|
|
15
|
-
exports.createOrderStateRequest = createOrderStateRequest;
|
|
16
|
-
const common_1 = require("../../../generated/common");
|
|
17
15
|
const contract_1 = require("../../cli/contract");
|
|
18
|
-
const
|
|
16
|
+
const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
|
|
19
17
|
const command_options_1 = require("../../args/command-options");
|
|
20
18
|
const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
|
|
21
19
|
const reporter_1 = require("./reporter");
|
|
22
|
-
|
|
20
|
+
const request_mapper_1 = require("./request.mapper");
|
|
23
21
|
const orderStateCommandPath = ['order', 'show'];
|
|
24
22
|
const defaultOrderStateSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
25
23
|
const orderStateRequestOptionsSchema = {
|
|
@@ -51,21 +49,10 @@ function createOrderStateCommand(createSdk = defaultOrderStateSdkFactory) {
|
|
|
51
49
|
}
|
|
52
50
|
exports.orderStateCommand = createOrderStateCommand();
|
|
53
51
|
async function runOrderStateCommand(options, createSdk) {
|
|
54
|
-
const request = createOrderStateRequest(options);
|
|
52
|
+
const request = (0, request_mapper_1.createOrderStateRequest)(options);
|
|
55
53
|
const { format } = options;
|
|
56
|
-
|
|
57
|
-
try {
|
|
54
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
58
55
|
const response = await sdk.orders.getOrderState(request);
|
|
59
56
|
return (0, reporter_1.formatOrderState)(response, format);
|
|
60
|
-
}
|
|
61
|
-
finally {
|
|
62
|
-
sdk.close();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function createOrderStateRequest(options) {
|
|
66
|
-
return {
|
|
67
|
-
accountId: options['account-id'],
|
|
68
|
-
orderId: options['order-id'],
|
|
69
|
-
priceType: common_1.PriceType.PRICE_TYPE_UNSPECIFIED
|
|
70
|
-
};
|
|
57
|
+
});
|
|
71
58
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль хранит request mapping, общий для production и Sandbox order state.
|
|
3
|
+
*
|
|
4
|
+
* Здесь допустимы generated defaults и преобразование typed command options.
|
|
5
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
6
|
+
*/
|
|
7
|
+
import type { GetOrderStateRequest } from '../../../generated/orders';
|
|
8
|
+
interface OrderStateRequestOptions {
|
|
9
|
+
readonly 'account-id': string;
|
|
10
|
+
readonly 'order-id': string;
|
|
11
|
+
}
|
|
12
|
+
export declare function createOrderStateRequest(options: OrderStateRequestOptions): GetOrderStateRequest;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль хранит request mapping, общий для production и Sandbox order state.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы generated defaults и преобразование typed command options.
|
|
6
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createOrderStateRequest = createOrderStateRequest;
|
|
10
|
+
const common_1 = require("../../../generated/common");
|
|
11
|
+
function createOrderStateRequest(options) {
|
|
12
|
+
return {
|
|
13
|
+
accountId: options['account-id'],
|
|
14
|
+
orderId: options['order-id'],
|
|
15
|
+
priceType: common_1.PriceType.PRICE_TYPE_UNSPECIFIED
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Здесь допустимы:
|
|
5
5
|
* - объявление command path и option schema;
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
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 { GetOrdersRequest, GetOrdersResponse } from '../../../generated/orders';
|
|
13
|
-
import type { InferOptions } from 'icore';
|
|
14
|
-
import type { CommandRequestOptions } from '../../args/command-options';
|
|
15
|
-
import { formatOrders } from './reporter';
|
|
16
13
|
type OrdersSdk = {
|
|
17
14
|
orders: {
|
|
18
15
|
getOrders(request: GetOrdersRequest): Promise<GetOrdersResponse>;
|
|
@@ -20,31 +17,6 @@ type OrdersSdk = {
|
|
|
20
17
|
close(): void;
|
|
21
18
|
};
|
|
22
19
|
type OrdersSdkFactory = (options: TInvestOptions) => OrdersSdk;
|
|
23
|
-
declare const ordersOptionsSchema: {
|
|
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 'account-id': {
|
|
37
|
-
readonly type: 'string';
|
|
38
|
-
readonly required: true;
|
|
39
|
-
};
|
|
40
|
-
readonly format: {
|
|
41
|
-
readonly type: 'string';
|
|
42
|
-
readonly choices: readonly ["json", "table"];
|
|
43
|
-
readonly default: 'table';
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
type OrdersOptions = InferOptions<typeof ordersOptionsSchema>;
|
|
47
|
-
type OrdersRequestOptions = CommandRequestOptions<OrdersOptions, 'account-id'>;
|
|
48
20
|
export declare function createOrdersCommand(createSdk?: OrdersSdkFactory): Omit<import("icore").CommandDefinition<{
|
|
49
21
|
readonly token: {
|
|
50
22
|
readonly type: 'string';
|
|
@@ -95,5 +67,4 @@ export declare const ordersCommand: Omit<import("icore").CommandDefinition<{
|
|
|
95
67
|
}, undefined, string, readonly ["order", "list"], undefined, void, readonly []>, "metadata"> & {
|
|
96
68
|
metadata?: undefined;
|
|
97
69
|
};
|
|
98
|
-
export {
|
|
99
|
-
export declare function createOrdersRequest(options: OrdersRequestOptions): GetOrdersRequest;
|
|
70
|
+
export {};
|