@woodger/t-invest-node-sdk 0.5.1
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 +611 -0
- package/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.md +307 -0
- package/certificates/russian-trusted-root-ca.pem +33 -0
- package/dist/application/dto/t-invest-options.d.ts +30 -0
- package/dist/application/dto/t-invest-options.js +11 -0
- package/dist/application/dto/t-invest-services.d.ts +168 -0
- package/dist/application/dto/t-invest-services.js +12 -0
- package/dist/application/errors/sdk-error.d.ts +47 -0
- package/dist/application/errors/sdk-error.js +84 -0
- package/dist/application/reports/accounts.report.d.ts +26 -0
- package/dist/application/reports/accounts.report.js +11 -0
- package/dist/application/reports/accrued-interests.report.d.ts +22 -0
- package/dist/application/reports/accrued-interests.report.js +11 -0
- package/dist/application/reports/asset.report.d.ts +72 -0
- package/dist/application/reports/asset.report.js +11 -0
- package/dist/application/reports/bond-coupons.report.d.ts +31 -0
- package/dist/application/reports/bond-coupons.report.js +11 -0
- package/dist/application/reports/bond.report.d.ts +82 -0
- package/dist/application/reports/bond.report.js +11 -0
- package/dist/application/reports/brands.report.d.ts +24 -0
- package/dist/application/reports/brands.report.js +11 -0
- package/dist/application/reports/broker-report.report.d.ts +74 -0
- package/dist/application/reports/broker-report.report.js +11 -0
- package/dist/application/reports/cancel-order.report.d.ts +14 -0
- package/dist/application/reports/cancel-order.report.js +11 -0
- package/dist/application/reports/cancel-stop-order.report.d.ts +14 -0
- package/dist/application/reports/cancel-stop-order.report.js +11 -0
- package/dist/application/reports/candles.report.d.ts +26 -0
- package/dist/application/reports/candles.report.js +11 -0
- package/dist/application/reports/close-prices.report.d.ts +20 -0
- package/dist/application/reports/close-prices.report.js +11 -0
- package/dist/application/reports/countries.report.d.ts +20 -0
- package/dist/application/reports/countries.report.js +11 -0
- package/dist/application/reports/currency.report.d.ts +58 -0
- package/dist/application/reports/currency.report.js +11 -0
- package/dist/application/reports/dividends-foreign-issuer.report.d.ts +51 -0
- package/dist/application/reports/dividends-foreign-issuer.report.js +11 -0
- package/dist/application/reports/dividends.report.d.ts +33 -0
- package/dist/application/reports/dividends.report.js +11 -0
- package/dist/application/reports/etf.report.d.ts +62 -0
- package/dist/application/reports/etf.report.js +11 -0
- package/dist/application/reports/favorites.report.d.ts +24 -0
- package/dist/application/reports/favorites.report.js +11 -0
- package/dist/application/reports/find-instrument.report.d.ts +34 -0
- package/dist/application/reports/find-instrument.report.js +11 -0
- package/dist/application/reports/future.report.d.ts +66 -0
- package/dist/application/reports/future.report.js +11 -0
- package/dist/application/reports/futures-margin.report.d.ts +21 -0
- package/dist/application/reports/futures-margin.report.js +11 -0
- package/dist/application/reports/index.d.ts +50 -0
- package/dist/application/reports/index.js +66 -0
- package/dist/application/reports/instrument.report.d.ts +47 -0
- package/dist/application/reports/instrument.report.js +11 -0
- package/dist/application/reports/last-prices.report.d.ts +20 -0
- package/dist/application/reports/last-prices.report.js +11 -0
- package/dist/application/reports/last-trades.report.d.ts +24 -0
- package/dist/application/reports/last-trades.report.js +11 -0
- package/dist/application/reports/margin-attributes.report.d.ts +25 -0
- package/dist/application/reports/margin-attributes.report.js +11 -0
- package/dist/application/reports/money.report.d.ts +15 -0
- package/dist/application/reports/money.report.js +11 -0
- package/dist/application/reports/operations-by-cursor.report.d.ts +65 -0
- package/dist/application/reports/operations-by-cursor.report.js +11 -0
- package/dist/application/reports/operations.report.d.ts +40 -0
- package/dist/application/reports/operations.report.js +11 -0
- package/dist/application/reports/option.report.d.ts +76 -0
- package/dist/application/reports/option.report.js +11 -0
- package/dist/application/reports/order-book.report.d.ts +38 -0
- package/dist/application/reports/order-book.report.js +11 -0
- package/dist/application/reports/order-mutation.report.d.ts +45 -0
- package/dist/application/reports/order-mutation.report.js +11 -0
- package/dist/application/reports/order-state.report.d.ts +12 -0
- package/dist/application/reports/order-state.report.js +11 -0
- package/dist/application/reports/orders.report.d.ts +53 -0
- package/dist/application/reports/orders.report.js +11 -0
- package/dist/application/reports/portfolio.report.d.ts +54 -0
- package/dist/application/reports/portfolio.report.js +11 -0
- package/dist/application/reports/positions.report.d.ts +45 -0
- package/dist/application/reports/positions.report.js +11 -0
- package/dist/application/reports/post-stop-order.report.d.ts +14 -0
- package/dist/application/reports/post-stop-order.report.js +11 -0
- package/dist/application/reports/sandbox-account.report.d.ts +20 -0
- package/dist/application/reports/sandbox-account.report.js +11 -0
- package/dist/application/reports/share.report.d.ts +66 -0
- package/dist/application/reports/share.report.js +11 -0
- package/dist/application/reports/stop-orders.report.d.ts +34 -0
- package/dist/application/reports/stop-orders.report.js +11 -0
- package/dist/application/reports/trading-schedules.report.d.ts +44 -0
- package/dist/application/reports/trading-schedules.report.js +11 -0
- package/dist/application/reports/trading-status.report.d.ts +19 -0
- package/dist/application/reports/trading-status.report.js +11 -0
- package/dist/application/reports/trading-statuses.report.d.ts +12 -0
- package/dist/application/reports/trading-statuses.report.js +11 -0
- package/dist/application/reports/user-info.report.d.ts +16 -0
- package/dist/application/reports/user-info.report.js +11 -0
- package/dist/application/reports/user-tariff.report.d.ts +28 -0
- package/dist/application/reports/user-tariff.report.js +11 -0
- package/dist/application/reports/withdraw-limits.report.d.ts +16 -0
- package/dist/application/reports/withdraw-limits.report.js +11 -0
- package/dist/application/services/unary-limiter.d.ts +44 -0
- package/dist/application/services/unary-limiter.js +138 -0
- package/dist/bootstrap/args/command-options.d.ts +43 -0
- package/dist/bootstrap/args/command-options.js +125 -0
- package/dist/bootstrap/args/index.d.ts +1 -0
- package/dist/bootstrap/args/index.js +5 -0
- package/dist/bootstrap/args/instrument-id-options.d.ts +24 -0
- package/dist/bootstrap/args/instrument-id-options.js +47 -0
- package/dist/bootstrap/args/instruments-args.d.ts +49 -0
- package/dist/bootstrap/args/instruments-args.js +89 -0
- package/dist/bootstrap/args/sdk-options.d.ts +19 -0
- package/dist/bootstrap/args/sdk-options.js +40 -0
- package/dist/bootstrap/args/side-effect-args.d.ts +20 -0
- package/dist/bootstrap/args/side-effect-args.js +50 -0
- package/dist/bootstrap/cli/contract.d.ts +16 -0
- package/dist/bootstrap/cli/contract.js +15 -0
- package/dist/bootstrap/cli/domains.d.ts +260 -0
- package/dist/bootstrap/cli/domains.js +631 -0
- package/dist/bootstrap/cli/error.d.ts +15 -0
- package/dist/bootstrap/cli/error.js +40 -0
- package/dist/bootstrap/cli/help.d.ts +751 -0
- package/dist/bootstrap/cli/help.js +1789 -0
- package/dist/bootstrap/cli/registry.d.ts +2102 -0
- package/dist/bootstrap/cli/registry.js +186 -0
- package/dist/bootstrap/cli/runner.d.ts +10 -0
- package/dist/bootstrap/cli/runner.js +151 -0
- package/dist/bootstrap/cli/version.d.ts +17 -0
- package/dist/bootstrap/cli/version.js +26 -0
- package/dist/bootstrap/commands/accounts/cli.d.ts +63 -0
- package/dist/bootstrap/commands/accounts/cli.js +50 -0
- package/dist/bootstrap/commands/accounts/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/accounts/reporter.js +50 -0
- package/dist/bootstrap/commands/accrued-interests/cli.d.ts +129 -0
- package/dist/bootstrap/commands/accrued-interests/cli.js +80 -0
- package/dist/bootstrap/commands/accrued-interests/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/accrued-interests/reporter.js +43 -0
- package/dist/bootstrap/commands/asset/cli.d.ts +99 -0
- package/dist/bootstrap/commands/asset/cli.js +64 -0
- package/dist/bootstrap/commands/asset/reporter.d.ts +16 -0
- package/dist/bootstrap/commands/asset/reporter.js +122 -0
- package/dist/bootstrap/commands/assets/cli.d.ts +102 -0
- package/dist/bootstrap/commands/assets/cli.js +78 -0
- package/dist/bootstrap/commands/assets/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/assets/reporter.js +27 -0
- package/dist/bootstrap/commands/bond/cli.d.ts +83 -0
- package/dist/bootstrap/commands/bond/cli.js +53 -0
- package/dist/bootstrap/commands/bond/reporter.d.ts +15 -0
- package/dist/bootstrap/commands/bond/reporter.js +123 -0
- package/dist/bootstrap/commands/bond-coupons/cli.d.ts +129 -0
- package/dist/bootstrap/commands/bond-coupons/cli.js +80 -0
- package/dist/bootstrap/commands/bond-coupons/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/bond-coupons/reporter.js +64 -0
- package/dist/bootstrap/commands/bonds/cli.d.ts +73 -0
- package/dist/bootstrap/commands/bonds/cli.js +53 -0
- package/dist/bootstrap/commands/bonds/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/bonds/reporter.js +27 -0
- package/dist/bootstrap/commands/brand/cli.d.ts +99 -0
- package/dist/bootstrap/commands/brand/cli.js +64 -0
- package/dist/bootstrap/commands/brand/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/brand/reporter.js +37 -0
- package/dist/bootstrap/commands/brands/cli.d.ts +63 -0
- package/dist/bootstrap/commands/brands/cli.js +50 -0
- package/dist/bootstrap/commands/brands/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/brands/reporter.js +49 -0
- package/dist/bootstrap/commands/broker-report/cli.d.ts +132 -0
- package/dist/bootstrap/commands/broker-report/cli.js +105 -0
- package/dist/bootstrap/commands/broker-report/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/broker-report/reporter.js +123 -0
- package/dist/bootstrap/commands/cancel-order/cli.d.ts +120 -0
- package/dist/bootstrap/commands/cancel-order/cli.js +71 -0
- package/dist/bootstrap/commands/cancel-order/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/cancel-order/reporter.js +32 -0
- package/dist/bootstrap/commands/cancel-stop-order/cli.d.ts +120 -0
- package/dist/bootstrap/commands/cancel-stop-order/cli.js +71 -0
- package/dist/bootstrap/commands/cancel-stop-order/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/cancel-stop-order/reporter.js +32 -0
- package/dist/bootstrap/commands/candles/cli.d.ts +138 -0
- package/dist/bootstrap/commands/candles/cli.js +104 -0
- package/dist/bootstrap/commands/candles/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/candles/reporter.js +49 -0
- package/dist/bootstrap/commands/close-prices/cli.d.ts +99 -0
- package/dist/bootstrap/commands/close-prices/cli.js +66 -0
- package/dist/bootstrap/commands/close-prices/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/close-prices/reporter.js +43 -0
- package/dist/bootstrap/commands/compile-proto/cli.d.ts +12 -0
- package/dist/bootstrap/commands/compile-proto/cli.js +22 -0
- package/dist/bootstrap/commands/countries/cli.d.ts +63 -0
- package/dist/bootstrap/commands/countries/cli.js +50 -0
- package/dist/bootstrap/commands/countries/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/countries/reporter.js +42 -0
- package/dist/bootstrap/commands/currencies/cli.d.ts +73 -0
- package/dist/bootstrap/commands/currencies/cli.js +53 -0
- package/dist/bootstrap/commands/currencies/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/currencies/reporter.js +27 -0
- package/dist/bootstrap/commands/currency/cli.d.ts +83 -0
- package/dist/bootstrap/commands/currency/cli.js +53 -0
- package/dist/bootstrap/commands/currency/reporter.d.ts +15 -0
- package/dist/bootstrap/commands/currency/reporter.js +104 -0
- package/dist/bootstrap/commands/dividends/cli.d.ts +129 -0
- package/dist/bootstrap/commands/dividends/cli.js +80 -0
- package/dist/bootstrap/commands/dividends/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/dividends/reporter.js +62 -0
- package/dist/bootstrap/commands/dividends-foreign-issuer/cli.d.ts +132 -0
- package/dist/bootstrap/commands/dividends-foreign-issuer/cli.js +105 -0
- package/dist/bootstrap/commands/dividends-foreign-issuer/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/dividends-foreign-issuer/reporter.js +108 -0
- package/dist/bootstrap/commands/edit-favorites/cli.d.ts +129 -0
- package/dist/bootstrap/commands/edit-favorites/cli.js +78 -0
- package/dist/bootstrap/commands/edit-favorites/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/edit-favorites/reporter.js +23 -0
- package/dist/bootstrap/commands/etf/cli.d.ts +83 -0
- package/dist/bootstrap/commands/etf/cli.js +53 -0
- package/dist/bootstrap/commands/etf/reporter.d.ts +15 -0
- package/dist/bootstrap/commands/etf/reporter.js +109 -0
- package/dist/bootstrap/commands/etfs/cli.d.ts +73 -0
- package/dist/bootstrap/commands/etfs/cli.js +53 -0
- package/dist/bootstrap/commands/etfs/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/etfs/reporter.js +27 -0
- package/dist/bootstrap/commands/favorites/cli.d.ts +63 -0
- package/dist/bootstrap/commands/favorites/cli.js +50 -0
- package/dist/bootstrap/commands/favorites/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/favorites/reporter.js +60 -0
- package/dist/bootstrap/commands/find-instrument/cli.d.ts +126 -0
- package/dist/bootstrap/commands/find-instrument/cli.js +88 -0
- package/dist/bootstrap/commands/find-instrument/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/find-instrument/reporter.js +71 -0
- package/dist/bootstrap/commands/future/cli.d.ts +83 -0
- package/dist/bootstrap/commands/future/cli.js +53 -0
- package/dist/bootstrap/commands/future/reporter.d.ts +15 -0
- package/dist/bootstrap/commands/future/reporter.js +116 -0
- package/dist/bootstrap/commands/futures/cli.d.ts +73 -0
- package/dist/bootstrap/commands/futures/cli.js +53 -0
- package/dist/bootstrap/commands/futures/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/futures/reporter.js +27 -0
- package/dist/bootstrap/commands/futures-margin/cli.d.ts +105 -0
- package/dist/bootstrap/commands/futures-margin/cli.js +64 -0
- package/dist/bootstrap/commands/futures-margin/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/futures-margin/reporter.js +40 -0
- package/dist/bootstrap/commands/help/cli.d.ts +13 -0
- package/dist/bootstrap/commands/help/cli.js +26 -0
- package/dist/bootstrap/commands/instrument/cli.d.ts +83 -0
- package/dist/bootstrap/commands/instrument/cli.js +53 -0
- package/dist/bootstrap/commands/instrument/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/instrument/reporter.js +91 -0
- package/dist/bootstrap/commands/last-prices/cli.d.ts +99 -0
- package/dist/bootstrap/commands/last-prices/cli.js +66 -0
- package/dist/bootstrap/commands/last-prices/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/last-prices/reporter.js +43 -0
- package/dist/bootstrap/commands/last-trades/cli.d.ts +123 -0
- package/dist/bootstrap/commands/last-trades/cli.js +82 -0
- package/dist/bootstrap/commands/last-trades/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/last-trades/reporter.js +48 -0
- package/dist/bootstrap/commands/margin-attributes/cli.d.ts +99 -0
- package/dist/bootstrap/commands/margin-attributes/cli.js +64 -0
- package/dist/bootstrap/commands/margin-attributes/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/margin-attributes/reporter.js +51 -0
- package/dist/bootstrap/commands/operations/cli.d.ts +156 -0
- package/dist/bootstrap/commands/operations/cli.js +99 -0
- package/dist/bootstrap/commands/operations/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/operations/reporter.js +78 -0
- package/dist/bootstrap/commands/operations-by-cursor/cli.d.ts +204 -0
- package/dist/bootstrap/commands/operations-by-cursor/cli.js +164 -0
- package/dist/bootstrap/commands/operations-by-cursor/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/operations-by-cursor/reporter.js +107 -0
- package/dist/bootstrap/commands/option/cli.d.ts +83 -0
- package/dist/bootstrap/commands/option/cli.js +53 -0
- package/dist/bootstrap/commands/option/reporter.d.ts +15 -0
- package/dist/bootstrap/commands/option/reporter.js +125 -0
- package/dist/bootstrap/commands/options-by/cli.d.ts +108 -0
- package/dist/bootstrap/commands/options-by/cli.js +68 -0
- package/dist/bootstrap/commands/options-by/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/options-by/reporter.js +27 -0
- package/dist/bootstrap/commands/order-book/cli.d.ts +120 -0
- package/dist/bootstrap/commands/order-book/cli.js +73 -0
- package/dist/bootstrap/commands/order-book/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/order-book/reporter.js +60 -0
- package/dist/bootstrap/commands/order-state/cli.d.ts +111 -0
- package/dist/bootstrap/commands/order-state/cli.js +71 -0
- package/dist/bootstrap/commands/order-state/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/order-state/reporter.js +57 -0
- package/dist/bootstrap/commands/orders/cli.d.ts +99 -0
- package/dist/bootstrap/commands/orders/cli.js +64 -0
- package/dist/bootstrap/commands/orders/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/orders/reporter.js +88 -0
- package/dist/bootstrap/commands/portfolio/cli.d.ts +114 -0
- package/dist/bootstrap/commands/portfolio/cli.js +77 -0
- package/dist/bootstrap/commands/portfolio/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/portfolio/reporter.js +95 -0
- package/dist/bootstrap/commands/positions/cli.d.ts +99 -0
- package/dist/bootstrap/commands/positions/cli.js +64 -0
- package/dist/bootstrap/commands/positions/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/positions/reporter.js +116 -0
- package/dist/bootstrap/commands/post-order/cli.d.ts +192 -0
- package/dist/bootstrap/commands/post-order/cli.js +113 -0
- package/dist/bootstrap/commands/post-order/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/post-order/reporter.js +77 -0
- package/dist/bootstrap/commands/post-stop-order/cli.d.ts +216 -0
- package/dist/bootstrap/commands/post-stop-order/cli.js +145 -0
- package/dist/bootstrap/commands/post-stop-order/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/post-stop-order/reporter.js +31 -0
- package/dist/bootstrap/commands/replace-order/cli.d.ts +180 -0
- package/dist/bootstrap/commands/replace-order/cli.js +99 -0
- package/dist/bootstrap/commands/replace-order/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/replace-order/reporter.js +17 -0
- package/dist/bootstrap/commands/sandbox-accounts/cli.d.ts +64 -0
- package/dist/bootstrap/commands/sandbox-accounts/cli.js +54 -0
- package/dist/bootstrap/commands/sandbox-cancel-order/cli.d.ts +120 -0
- package/dist/bootstrap/commands/sandbox-cancel-order/cli.js +69 -0
- package/dist/bootstrap/commands/sandbox-close-account/cli.d.ts +108 -0
- package/dist/bootstrap/commands/sandbox-close-account/cli.js +66 -0
- package/dist/bootstrap/commands/sandbox-close-account/reporter.d.ts +12 -0
- package/dist/bootstrap/commands/sandbox-close-account/reporter.js +32 -0
- package/dist/bootstrap/commands/sandbox-open-account/cli.d.ts +70 -0
- package/dist/bootstrap/commands/sandbox-open-account/cli.js +57 -0
- package/dist/bootstrap/commands/sandbox-open-account/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/sandbox-open-account/reporter.js +31 -0
- package/dist/bootstrap/commands/sandbox-operations/cli.d.ts +156 -0
- package/dist/bootstrap/commands/sandbox-operations/cli.js +78 -0
- package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.d.ts +204 -0
- package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.js +98 -0
- package/dist/bootstrap/commands/sandbox-order-state/cli.d.ts +111 -0
- package/dist/bootstrap/commands/sandbox-order-state/cli.js +67 -0
- package/dist/bootstrap/commands/sandbox-orders/cli.d.ts +99 -0
- package/dist/bootstrap/commands/sandbox-orders/cli.js +63 -0
- package/dist/bootstrap/commands/sandbox-pay-in/cli.d.ts +135 -0
- package/dist/bootstrap/commands/sandbox-pay-in/cli.js +86 -0
- package/dist/bootstrap/commands/sandbox-pay-in/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/sandbox-pay-in/reporter.js +32 -0
- package/dist/bootstrap/commands/sandbox-portfolio/cli.d.ts +114 -0
- package/dist/bootstrap/commands/sandbox-portfolio/cli.js +68 -0
- package/dist/bootstrap/commands/sandbox-positions/cli.d.ts +99 -0
- package/dist/bootstrap/commands/sandbox-positions/cli.js +63 -0
- package/dist/bootstrap/commands/sandbox-post-order/cli.d.ts +192 -0
- package/dist/bootstrap/commands/sandbox-post-order/cli.js +90 -0
- package/dist/bootstrap/commands/sandbox-replace-order/cli.d.ts +180 -0
- package/dist/bootstrap/commands/sandbox-replace-order/cli.js +86 -0
- package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.d.ts +99 -0
- package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.js +63 -0
- package/dist/bootstrap/commands/share/cli.d.ts +83 -0
- package/dist/bootstrap/commands/share/cli.js +53 -0
- package/dist/bootstrap/commands/share/reporter.d.ts +15 -0
- package/dist/bootstrap/commands/share/reporter.js +111 -0
- package/dist/bootstrap/commands/shares/cli.d.ts +73 -0
- package/dist/bootstrap/commands/shares/cli.js +53 -0
- package/dist/bootstrap/commands/shares/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/shares/reporter.js +27 -0
- package/dist/bootstrap/commands/stop-orders/cli.d.ts +99 -0
- package/dist/bootstrap/commands/stop-orders/cli.js +68 -0
- package/dist/bootstrap/commands/stop-orders/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/stop-orders/reporter.js +69 -0
- package/dist/bootstrap/commands/stream-run/cli.d.ts +138 -0
- package/dist/bootstrap/commands/stream-run/cli.js +229 -0
- package/dist/bootstrap/commands/stream-run/config.d.ts +56 -0
- package/dist/bootstrap/commands/stream-run/config.js +468 -0
- package/dist/bootstrap/commands/stream-run/reporter.d.ts +30 -0
- package/dist/bootstrap/commands/stream-run/reporter.js +76 -0
- package/dist/bootstrap/commands/trading-schedules/cli.d.ts +120 -0
- package/dist/bootstrap/commands/trading-schedules/cli.js +79 -0
- package/dist/bootstrap/commands/trading-schedules/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/trading-schedules/reporter.js +58 -0
- package/dist/bootstrap/commands/trading-status/cli.d.ts +99 -0
- package/dist/bootstrap/commands/trading-status/cli.js +65 -0
- package/dist/bootstrap/commands/trading-status/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/trading-status/reporter.js +51 -0
- package/dist/bootstrap/commands/trading-statuses/cli.d.ts +99 -0
- package/dist/bootstrap/commands/trading-statuses/cli.js +64 -0
- package/dist/bootstrap/commands/trading-statuses/reporter.d.ts +14 -0
- package/dist/bootstrap/commands/trading-statuses/reporter.js +44 -0
- package/dist/bootstrap/commands/user-info/cli.d.ts +63 -0
- package/dist/bootstrap/commands/user-info/cli.js +50 -0
- package/dist/bootstrap/commands/user-info/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/user-info/reporter.js +39 -0
- package/dist/bootstrap/commands/user-tariff/cli.d.ts +63 -0
- package/dist/bootstrap/commands/user-tariff/cli.js +50 -0
- package/dist/bootstrap/commands/user-tariff/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/user-tariff/reporter.js +50 -0
- package/dist/bootstrap/commands/version/cli.d.ts +13 -0
- package/dist/bootstrap/commands/version/cli.js +22 -0
- package/dist/bootstrap/commands/withdraw-limits/cli.d.ts +99 -0
- package/dist/bootstrap/commands/withdraw-limits/cli.js +64 -0
- package/dist/bootstrap/commands/withdraw-limits/reporter.d.ts +13 -0
- package/dist/bootstrap/commands/withdraw-limits/reporter.js +59 -0
- package/dist/bootstrap/generated-exports.d.ts +29 -0
- package/dist/bootstrap/generated-exports.js +590 -0
- package/dist/bootstrap/index.d.ts +6 -0
- package/dist/bootstrap/index.js +22 -0
- package/dist/bootstrap/proto/compile-proto.d.ts +18 -0
- package/dist/bootstrap/proto/compile-proto.js +122 -0
- package/dist/bootstrap/sdk-config.d.ts +21 -0
- package/dist/bootstrap/sdk-config.js +152 -0
- package/dist/bootstrap/t-invest-node-sdk.d.ts +42 -0
- package/dist/bootstrap/t-invest-node-sdk.js +115 -0
- package/dist/bootstrap/unary-limit-config.d.ts +38 -0
- package/dist/bootstrap/unary-limit-config.js +130 -0
- package/dist/config.d.ts +160 -0
- package/dist/config.js +173 -0
- package/dist/config.types.d.ts +89 -0
- package/dist/config.types.js +13 -0
- package/dist/generated/common.d.ts +214 -0
- package/dist/generated/common.js +1336 -0
- package/dist/generated/google/api/field_behavior.d.ts +61 -0
- package/dist/generated/google/api/field_behavior.js +126 -0
- package/dist/generated/google/protobuf/descriptor.d.ts +1330 -0
- package/dist/generated/google/protobuf/descriptor.js +5984 -0
- package/dist/generated/google/protobuf/timestamp.d.ts +122 -0
- package/dist/generated/google/protobuf/timestamp.js +102 -0
- package/dist/generated/instruments.d.ts +3230 -0
- package/dist/generated/instruments.js +24246 -0
- package/dist/generated/marketdata.d.ts +1268 -0
- package/dist/generated/marketdata.js +8922 -0
- package/dist/generated/operations.d.ts +1165 -0
- package/dist/generated/operations.js +8625 -0
- package/dist/generated/orders.d.ts +806 -0
- package/dist/generated/orders.js +5639 -0
- package/dist/generated/sandbox.d.ts +356 -0
- package/dist/generated/sandbox.js +603 -0
- package/dist/generated/signals.d.ts +196 -0
- package/dist/generated/signals.js +1261 -0
- package/dist/generated/stoporders.d.ts +328 -0
- package/dist/generated/stoporders.js +1990 -0
- package/dist/generated/users.d.ts +453 -0
- package/dist/generated/users.js +2334 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +30 -0
- package/dist/infrastructure/interceptor/index.d.ts +1 -0
- package/dist/infrastructure/interceptor/index.js +17 -0
- package/dist/infrastructure/interceptor/warning-interceptor.d.ts +23 -0
- package/dist/infrastructure/interceptor/warning-interceptor.js +38 -0
- package/dist/infrastructure/report-values.d.ts +19 -0
- package/dist/infrastructure/report-values.js +50 -0
- package/dist/infrastructure/transport/grpc/index.d.ts +5 -0
- package/dist/infrastructure/transport/grpc/index.js +13 -0
- package/dist/infrastructure/transport/grpc/sdk-channel.d.ts +12 -0
- package/dist/infrastructure/transport/grpc/sdk-channel.js +23 -0
- package/dist/infrastructure/transport/grpc/sdk-client.d.ts +16 -0
- package/dist/infrastructure/transport/grpc/sdk-client.js +33 -0
- package/dist/infrastructure/transport/grpc/sdk-metadata.d.ts +12 -0
- package/dist/infrastructure/transport/grpc/sdk-metadata.js +22 -0
- package/dist/infrastructure/transport/grpc/sdk-middleware.d.ts +22 -0
- package/dist/infrastructure/transport/grpc/sdk-middleware.js +312 -0
- package/dist/infrastructure/transport/grpc/tls-root-certificates.d.ts +10 -0
- package/dist/infrastructure/transport/grpc/tls-root-certificates.js +20 -0
- package/dist/infrastructure/transport/grpc/unary-limit-resolver.d.ts +22 -0
- package/dist/infrastructure/transport/grpc/unary-limit-resolver.js +60 -0
- package/dist/infrastructure/transport/grpc/unary-limits.d.ts +1 -0
- package/dist/infrastructure/transport/grpc/unary-limits.js +7 -0
- package/docs/architecture.md +378 -0
- package/docs/bundled-ca.md +157 -0
- package/docs/clean-architecture/adapters.md +173 -0
- package/docs/clean-architecture/api-commands.md +487 -0
- package/docs/clean-architecture/application.md +137 -0
- package/docs/clean-architecture/cli-output-boundaries.md +256 -0
- package/docs/clean-architecture/dto.md +153 -0
- package/docs/clean-architecture/index.md +89 -0
- package/docs/cli-stream-configuration.md +305 -0
- package/docs/cli-stream-reference.md +195 -0
- package/docs/guides/custom-unary-limiter.md +552 -0
- package/docs/guides/errors-and-lifecycle.md +196 -0
- package/docs/guides/getting-started.md +100 -0
- package/docs/guides/index.md +43 -0
- package/docs/guides/streams-and-cancellation.md +177 -0
- package/docs/guides/testing-with-service-definitions.md +110 -0
- package/docs/guides/unary-calls.md +216 -0
- package/docs/index.md +86 -0
- package/docs/limits-policy.md +201 -0
- package/docs/roadmap.md +204 -0
- package/docs/tls-policy.md +62 -0
- package/package.json +62 -0
- package/readme.md +472 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Исполняемая точка входа CLI сохраняет package binary в
|
|
5
|
+
* `dist/bootstrap/index.js` и делегирует bootstrap-механику CLI runner-у.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const runner_1 = require("./cli/runner");
|
|
9
|
+
const interceptor_1 = require("../infrastructure/interceptor");
|
|
10
|
+
(0, interceptor_1.warningInterceptor)({
|
|
11
|
+
rules: [
|
|
12
|
+
{ messageIncludes: 'client.query() when the client is already executing' }
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
void (0, runner_1.runCli)(process.argv.slice(2))
|
|
16
|
+
.then((exitCode) => {
|
|
17
|
+
process.exitCode = exitCode;
|
|
18
|
+
})
|
|
19
|
+
.catch((error) => {
|
|
20
|
+
console.error(error);
|
|
21
|
+
process.exitCode = 1;
|
|
22
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль proto compiler запускает генерацию TypeScript contracts из локальных proto-файлов.
|
|
3
|
+
*
|
|
4
|
+
* Здесь допустимы:
|
|
5
|
+
* - чтение локальных generation paths из proto upstream manifest;
|
|
6
|
+
* - поиск vendored proto-файлов в contracts directory;
|
|
7
|
+
* - вызов системного `protoc` с текущими ts-proto options;
|
|
8
|
+
* - проверка обязательных tool/runtime prerequisites перед генерацией;
|
|
9
|
+
*
|
|
10
|
+
* Здесь не должно быть post-processing generated sources или SDK runtime wiring.
|
|
11
|
+
*/
|
|
12
|
+
type ProtoGenerationPaths = {
|
|
13
|
+
contractsDir: string;
|
|
14
|
+
generatedDir: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function compileProtoContracts(): void;
|
|
17
|
+
export declare function loadProtoGenerationPaths(projectRoot?: string): ProtoGenerationPaths;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль proto compiler запускает генерацию TypeScript contracts из локальных proto-файлов.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы:
|
|
6
|
+
* - чтение локальных generation paths из proto upstream manifest;
|
|
7
|
+
* - поиск vendored proto-файлов в contracts directory;
|
|
8
|
+
* - вызов системного `protoc` с текущими ts-proto options;
|
|
9
|
+
* - проверка обязательных tool/runtime prerequisites перед генерацией;
|
|
10
|
+
*
|
|
11
|
+
* Здесь не должно быть post-processing generated sources или SDK runtime wiring.
|
|
12
|
+
*/
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.compileProtoContracts = compileProtoContracts;
|
|
18
|
+
exports.loadProtoGenerationPaths = loadProtoGenerationPaths;
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
const node_child_process_1 = require("node:child_process");
|
|
21
|
+
const pwd_fs_1 = require("pwd-fs");
|
|
22
|
+
const compilerCommand = 'protoc';
|
|
23
|
+
const pluginPath = node_path_1.default.join(pwd_fs_1.pfs.pwd, 'node_modules', '.bin', 'protoc-gen-ts_proto');
|
|
24
|
+
function compileProtoContracts() {
|
|
25
|
+
const paths = loadProtoGenerationPaths();
|
|
26
|
+
assertProtoCompilerReady(paths.contractsDir);
|
|
27
|
+
const protoFiles = collectProtoFiles(paths.contractsDir);
|
|
28
|
+
if (!protoFiles.length) {
|
|
29
|
+
throw new Error(`No proto files found in ${paths.contractsDir}`);
|
|
30
|
+
}
|
|
31
|
+
runProtoCompiler(protoFiles, paths);
|
|
32
|
+
}
|
|
33
|
+
function loadProtoGenerationPaths(projectRoot = pwd_fs_1.pfs.pwd) {
|
|
34
|
+
const manifestPath = node_path_1.default.join(projectRoot, 'contracts', 'upstream.json');
|
|
35
|
+
let manifestSource;
|
|
36
|
+
try {
|
|
37
|
+
manifestSource = pwd_fs_1.pfs.read(manifestPath, {
|
|
38
|
+
sync: true,
|
|
39
|
+
encoding: 'utf8'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new Error(`Unable to read proto upstream manifest at ${manifestPath}`, { cause: error });
|
|
44
|
+
}
|
|
45
|
+
let manifest;
|
|
46
|
+
try {
|
|
47
|
+
manifest = JSON.parse(manifestSource);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new Error(`Invalid JSON in proto upstream manifest at ${manifestPath}`, { cause: error });
|
|
51
|
+
}
|
|
52
|
+
if (!isRecord(manifest) || !isRecord(manifest['local'])) {
|
|
53
|
+
throw new Error(`Expected 'local' object in proto upstream manifest at ${manifestPath}`);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
contractsDir: node_path_1.default.resolve(projectRoot, requireManifestPath(manifest['local'], 'rawContractsPath', manifestPath)),
|
|
57
|
+
generatedDir: node_path_1.default.resolve(projectRoot, requireManifestPath(manifest['local'], 'generatedPath', manifestPath))
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function collectProtoFiles(dir) {
|
|
61
|
+
return pwd_fs_1.pfs.readdir(dir, { sync: true })
|
|
62
|
+
.sort()
|
|
63
|
+
.flatMap((entryName) => {
|
|
64
|
+
const entryPath = node_path_1.default.join(dir, entryName);
|
|
65
|
+
if (pwd_fs_1.pfs.stat(entryPath, { sync: true }).isDirectory()) {
|
|
66
|
+
return collectProtoFiles(entryPath);
|
|
67
|
+
}
|
|
68
|
+
return entryName.endsWith('.proto') ? [entryPath] : [];
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function assertProtoCompilerReady(contractsDir) {
|
|
72
|
+
if (!pwd_fs_1.pfs.test(contractsDir, { sync: true })) {
|
|
73
|
+
throw new Error(`Missing contracts directory at ${contractsDir}`);
|
|
74
|
+
}
|
|
75
|
+
if (!pwd_fs_1.pfs.test(pluginPath, { sync: true })) {
|
|
76
|
+
throw new Error(`Missing ts-proto plugin at ${pluginPath}`);
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
(0, node_child_process_1.execFileSync)(compilerCommand, ['--version'], {
|
|
80
|
+
cwd: pwd_fs_1.pfs.pwd,
|
|
81
|
+
stdio: 'ignore',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
handleMissingProtoCompiler(error);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function runProtoCompiler(protoFiles, paths) {
|
|
89
|
+
try {
|
|
90
|
+
(0, node_child_process_1.execFileSync)(compilerCommand, [
|
|
91
|
+
`--plugin=protoc-gen-ts_proto=${pluginPath}`,
|
|
92
|
+
`--proto_path=${paths.contractsDir}`,
|
|
93
|
+
`--ts_proto_out=${paths.generatedDir}`,
|
|
94
|
+
'--ts_proto_opt=outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false',
|
|
95
|
+
'--ts_proto_opt=env=node',
|
|
96
|
+
'--ts_proto_opt=esModuleInterop=true',
|
|
97
|
+
...protoFiles,
|
|
98
|
+
], {
|
|
99
|
+
cwd: pwd_fs_1.pfs.pwd,
|
|
100
|
+
stdio: 'inherit',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
handleMissingProtoCompiler(error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function requireManifestPath(local, name, manifestPath) {
|
|
108
|
+
const value = local[name];
|
|
109
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
110
|
+
throw new Error(`Expected 'local.${name}' as non-empty string in ${manifestPath}`);
|
|
111
|
+
}
|
|
112
|
+
return value.trim();
|
|
113
|
+
}
|
|
114
|
+
function isRecord(value) {
|
|
115
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
function handleMissingProtoCompiler(error) {
|
|
118
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
119
|
+
throw new Error('System protoc compiler is not installed or is not available in PATH', { cause: error });
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль bootstrap config adapter собирает runtime policy для SDK instances.
|
|
3
|
+
*
|
|
4
|
+
* Здесь допустимы:
|
|
5
|
+
* - компиляция package defaults в public flat config;
|
|
6
|
+
* - разрешение per-instance unary limit overrides;
|
|
7
|
+
* - согласование overrides с package quota groups;
|
|
8
|
+
* - проверка инвариантов итогового instance snapshot;
|
|
9
|
+
*
|
|
10
|
+
* Здесь не должно быть transport initialization, provider tariff refresh или
|
|
11
|
+
* limiter state.
|
|
12
|
+
*/
|
|
13
|
+
import type { TInvestOptions } from '../application/dto/t-invest-options';
|
|
14
|
+
import type { TInvestNodeSDKConfig, UnaryLimits } from '../config.types';
|
|
15
|
+
import type { UnaryLimitConfig } from './unary-limit-config';
|
|
16
|
+
export type ResolvedTInvestOptions = Omit<TInvestOptions, 'useSsl'> & {
|
|
17
|
+
useSsl: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const defaultConfig: TInvestNodeSDKConfig;
|
|
20
|
+
export declare function resolveSdkInstanceOptions(options: TInvestOptions): ResolvedTInvestOptions;
|
|
21
|
+
export declare function resolveUnaryLimitConfig(overrides?: UnaryLimits): UnaryLimitConfig;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль bootstrap config adapter собирает runtime policy для SDK instances.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы:
|
|
6
|
+
* - компиляция package defaults в public flat config;
|
|
7
|
+
* - разрешение per-instance unary limit overrides;
|
|
8
|
+
* - согласование overrides с package quota groups;
|
|
9
|
+
* - проверка инвариантов итогового instance snapshot;
|
|
10
|
+
*
|
|
11
|
+
* Здесь не должно быть transport initialization, provider tariff refresh или
|
|
12
|
+
* limiter state.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.defaultConfig = void 0;
|
|
16
|
+
exports.resolveSdkInstanceOptions = resolveSdkInstanceOptions;
|
|
17
|
+
exports.resolveUnaryLimitConfig = resolveUnaryLimitConfig;
|
|
18
|
+
const sdk_error_1 = require("../application/errors/sdk-error");
|
|
19
|
+
const config_1 = require("../config");
|
|
20
|
+
const instruments_1 = require("../generated/instruments");
|
|
21
|
+
const marketdata_1 = require("../generated/marketdata");
|
|
22
|
+
const operations_1 = require("../generated/operations");
|
|
23
|
+
const orders_1 = require("../generated/orders");
|
|
24
|
+
const sandbox_1 = require("../generated/sandbox");
|
|
25
|
+
const signals_1 = require("../generated/signals");
|
|
26
|
+
const stoporders_1 = require("../generated/stoporders");
|
|
27
|
+
const users_1 = require("../generated/users");
|
|
28
|
+
const unary_limit_config_1 = require("./unary-limit-config");
|
|
29
|
+
const packageUnaryLimits = (0, unary_limit_config_1.compileUnaryLimits)(config_1.packageConfig.unaryLimits);
|
|
30
|
+
const unaryServiceDefinitions = [
|
|
31
|
+
instruments_1.InstrumentsServiceDefinition,
|
|
32
|
+
marketdata_1.MarketDataServiceDefinition,
|
|
33
|
+
operations_1.OperationsServiceDefinition,
|
|
34
|
+
orders_1.OrdersServiceDefinition,
|
|
35
|
+
sandbox_1.SandboxServiceDefinition,
|
|
36
|
+
signals_1.SignalServiceDefinition,
|
|
37
|
+
stoporders_1.StopOrdersServiceDefinition,
|
|
38
|
+
users_1.UsersServiceDefinition
|
|
39
|
+
];
|
|
40
|
+
const knownUnaryLimitRules = new Set(unaryServiceDefinitions.flatMap((definition) => [
|
|
41
|
+
definition.name,
|
|
42
|
+
...Object.values(definition.methods)
|
|
43
|
+
.filter((method) => !method.requestStream && !method.responseStream)
|
|
44
|
+
.map((method) => `/${definition.fullName}/${method.name}`)
|
|
45
|
+
]));
|
|
46
|
+
exports.defaultConfig = {
|
|
47
|
+
unaryLimits: (0, unary_limit_config_1.cloneUnaryLimits)(packageUnaryLimits.limits),
|
|
48
|
+
requireSideEffectConfirmation: config_1.packageConfig.requireSideEffectConfirmation
|
|
49
|
+
};
|
|
50
|
+
function resolveSdkInstanceOptions(options) {
|
|
51
|
+
assertRemovedTrackLimitsOption(options);
|
|
52
|
+
assertNonBlankSdkOption(options.token, 'token');
|
|
53
|
+
assertNonBlankSdkOption(options.endpoint, 'endpoint');
|
|
54
|
+
assertGrpcMetadataValue(options.token, 'token');
|
|
55
|
+
if (options.appName !== undefined && options.appName !== '') {
|
|
56
|
+
assertGrpcMetadataValue(options.appName, 'appName');
|
|
57
|
+
}
|
|
58
|
+
assertUnaryLimiter(options.unaryLimiter);
|
|
59
|
+
return {
|
|
60
|
+
...options,
|
|
61
|
+
useSsl: options.useSsl ?? config_1.packageConfig.sdk.useSsl
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function resolveUnaryLimitConfig(overrides) {
|
|
65
|
+
try {
|
|
66
|
+
const buckets = {
|
|
67
|
+
...packageUnaryLimits.buckets
|
|
68
|
+
};
|
|
69
|
+
const limits = (0, unary_limit_config_1.cloneUnaryLimits)({
|
|
70
|
+
...exports.defaultConfig.unaryLimits,
|
|
71
|
+
...overrides
|
|
72
|
+
});
|
|
73
|
+
const limitsByBucket = new Map();
|
|
74
|
+
for (const [key, bucket] of Object.entries(buckets)) {
|
|
75
|
+
const limit = limits[key];
|
|
76
|
+
const bucketLimits = limitsByBucket.get(bucket) ?? [];
|
|
77
|
+
bucketLimits.push(limit);
|
|
78
|
+
limitsByBucket.set(bucket, bucketLimits);
|
|
79
|
+
}
|
|
80
|
+
// Измененный method limit отсоединяется, только если иначе группа получила
|
|
81
|
+
// бы разные значения. Согласованный override всей группы сохраняет bucket.
|
|
82
|
+
for (const [key, bucket] of Object.entries(buckets)) {
|
|
83
|
+
const bucketLimits = limitsByBucket.get(bucket);
|
|
84
|
+
const firstLimit = bucketLimits?.[0];
|
|
85
|
+
const hasOneDefinedLimit = firstLimit !== undefined
|
|
86
|
+
&& bucketLimits?.every((limit) => (0, unary_limit_config_1.sameUnaryLimit)(firstLimit, limit)) === true;
|
|
87
|
+
if (!hasOneDefinedLimit
|
|
88
|
+
&& !(0, unary_limit_config_1.sameUnaryLimit)(packageUnaryLimits.limits[key], limits[key])) {
|
|
89
|
+
delete buckets[key];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const resolvedConfig = {
|
|
93
|
+
buckets,
|
|
94
|
+
limits
|
|
95
|
+
};
|
|
96
|
+
assertKnownUnaryLimitRules(resolvedConfig.limits);
|
|
97
|
+
(0, unary_limit_config_1.assertUnaryLimitConfig)(resolvedConfig);
|
|
98
|
+
return resolvedConfig;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
throw new sdk_error_1.SdkError(sdk_error_1.SdkErrorCode.InvalidArgument, errorMessage(error, 'TInvestOptions.unaryLimits is invalid'), {
|
|
102
|
+
source: 'sdk',
|
|
103
|
+
cause: error
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function assertRemovedTrackLimitsOption(options) {
|
|
108
|
+
if (Object.hasOwn(options, 'trackLimits')) {
|
|
109
|
+
throw new sdk_error_1.SdkError(sdk_error_1.SdkErrorCode.InvalidArgument, 'TInvestOptions.trackLimits is not supported; configure unaryLimiter explicitly', {
|
|
110
|
+
source: 'sdk'
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function assertUnaryLimiter(limiter) {
|
|
115
|
+
if (limiter !== undefined
|
|
116
|
+
&& ((typeof limiter !== 'object' && typeof limiter !== 'function')
|
|
117
|
+
|| limiter === null
|
|
118
|
+
|| typeof limiter.acquire !== 'function')) {
|
|
119
|
+
throw new sdk_error_1.SdkError(sdk_error_1.SdkErrorCode.InvalidArgument, 'TInvestOptions.unaryLimiter must provide an acquire function', {
|
|
120
|
+
source: 'sdk'
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function assertKnownUnaryLimitRules(limits) {
|
|
125
|
+
for (const rule of Object.keys(limits)) {
|
|
126
|
+
if (!knownUnaryLimitRules.has(rule)) {
|
|
127
|
+
throw new Error(`Unknown unary limit rule ${rule}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const grpcMetadataValuePattern = /^[ -~]*$/;
|
|
132
|
+
function assertGrpcMetadataValue(value, name) {
|
|
133
|
+
if (typeof value !== 'string' || !grpcMetadataValuePattern.test(value)) {
|
|
134
|
+
throw new sdk_error_1.SdkError(sdk_error_1.SdkErrorCode.InvalidArgument, `TInvestOptions.${name} contains characters unsupported by gRPC metadata`, {
|
|
135
|
+
source: 'sdk'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function assertNonBlankSdkOption(value, name) {
|
|
140
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
141
|
+
throw new sdk_error_1.SdkError(sdk_error_1.SdkErrorCode.InvalidArgument, `TInvestOptions.${name} must be a non-empty string`, {
|
|
142
|
+
source: 'sdk'
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function errorMessage(error, fallback) {
|
|
147
|
+
if (typeof error !== 'object' || error === null) {
|
|
148
|
+
return fallback;
|
|
149
|
+
}
|
|
150
|
+
const message = error['message'];
|
|
151
|
+
return typeof message === 'string' ? message : fallback;
|
|
152
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль bootstrap SDK facade собирает публичный `TInvestNodeSDK` runtime.
|
|
3
|
+
*
|
|
4
|
+
* Здесь допустимы:
|
|
5
|
+
* - lazy creation generated service clients;
|
|
6
|
+
* - владение shared gRPC channel и metadata;
|
|
7
|
+
* - подключение Consumer-owned unary limiter-а к transport adapters;
|
|
8
|
+
*
|
|
9
|
+
* Здесь не должно быть CLI command logic или generated DTO mapping.
|
|
10
|
+
*/
|
|
11
|
+
import type { TInvestOptions } from '../application/dto/t-invest-options';
|
|
12
|
+
import type { InstrumentsService, MarketDataService, MarketDataStreamService, OperationsService, OperationsStreamService, OrdersService, OrdersStreamService, SandboxService, SignalService, StopOrdersService, UsersService } from '../application/dto/t-invest-services';
|
|
13
|
+
export declare class TInvestNodeSDK {
|
|
14
|
+
private options;
|
|
15
|
+
private storage;
|
|
16
|
+
private channel;
|
|
17
|
+
private metadata;
|
|
18
|
+
private unaryLimitResolver;
|
|
19
|
+
private readonly maxReceiveMessageLength;
|
|
20
|
+
private closed;
|
|
21
|
+
private lifecycleController;
|
|
22
|
+
constructor(options: TInvestOptions);
|
|
23
|
+
get instruments(): InstrumentsService;
|
|
24
|
+
get marketdata(): MarketDataService;
|
|
25
|
+
get marketdataStream(): MarketDataStreamService;
|
|
26
|
+
get operations(): OperationsService;
|
|
27
|
+
get operationsStream(): OperationsStreamService;
|
|
28
|
+
get orders(): OrdersService;
|
|
29
|
+
get ordersStream(): OrdersStreamService;
|
|
30
|
+
get sandbox(): SandboxService;
|
|
31
|
+
get signals(): SignalService;
|
|
32
|
+
get stoporders(): StopOrdersService;
|
|
33
|
+
get users(): UsersService;
|
|
34
|
+
/**
|
|
35
|
+
* Идемпотентно закрывает shared channel и запрещает новые SDK-вызовы.
|
|
36
|
+
* Уже переданные transport-у операции нужно завершать их собственным AbortSignal.
|
|
37
|
+
*/
|
|
38
|
+
close(): void;
|
|
39
|
+
private useServiceAsClient;
|
|
40
|
+
private assertOpen;
|
|
41
|
+
private createClosedError;
|
|
42
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль bootstrap SDK facade собирает публичный `TInvestNodeSDK` runtime.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы:
|
|
6
|
+
* - lazy creation generated service clients;
|
|
7
|
+
* - владение shared gRPC channel и metadata;
|
|
8
|
+
* - подключение Consumer-owned unary limiter-а к transport adapters;
|
|
9
|
+
*
|
|
10
|
+
* Здесь не должно быть CLI command logic или generated DTO mapping.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.TInvestNodeSDK = void 0;
|
|
14
|
+
const config_1 = require("../config");
|
|
15
|
+
const instruments_1 = require("../generated/instruments");
|
|
16
|
+
const marketdata_1 = require("../generated/marketdata");
|
|
17
|
+
const operations_1 = require("../generated/operations");
|
|
18
|
+
const orders_1 = require("../generated/orders");
|
|
19
|
+
const sandbox_1 = require("../generated/sandbox");
|
|
20
|
+
const signals_1 = require("../generated/signals");
|
|
21
|
+
const stoporders_1 = require("../generated/stoporders");
|
|
22
|
+
const users_1 = require("../generated/users");
|
|
23
|
+
const sdk_error_1 = require("../application/errors/sdk-error");
|
|
24
|
+
const grpc_1 = require("../infrastructure/transport/grpc");
|
|
25
|
+
const sdk_config_1 = require("./sdk-config");
|
|
26
|
+
class TInvestNodeSDK {
|
|
27
|
+
options;
|
|
28
|
+
storage = new Map();
|
|
29
|
+
channel;
|
|
30
|
+
metadata;
|
|
31
|
+
unaryLimitResolver;
|
|
32
|
+
maxReceiveMessageLength;
|
|
33
|
+
closed = false;
|
|
34
|
+
lifecycleController = new AbortController();
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.options = (0, sdk_config_1.resolveSdkInstanceOptions)(options);
|
|
37
|
+
this.maxReceiveMessageLength = config_1.packageConfig.grpc.maxReceiveMessageLength;
|
|
38
|
+
const unaryLimitConfig = (0, sdk_config_1.resolveUnaryLimitConfig)(this.options.unaryLimits);
|
|
39
|
+
this.unaryLimitResolver = new grpc_1.UnaryLimitResolver(unaryLimitConfig.limits, unaryLimitConfig.buckets);
|
|
40
|
+
this.channel = (0, grpc_1.createSdkChannel)(this.options, this.maxReceiveMessageLength);
|
|
41
|
+
this.metadata = (0, grpc_1.createSdkMetadata)(this.options);
|
|
42
|
+
}
|
|
43
|
+
get instruments() {
|
|
44
|
+
return this.useServiceAsClient(instruments_1.InstrumentsServiceDefinition);
|
|
45
|
+
}
|
|
46
|
+
get marketdata() {
|
|
47
|
+
return this.useServiceAsClient(marketdata_1.MarketDataServiceDefinition);
|
|
48
|
+
}
|
|
49
|
+
get marketdataStream() {
|
|
50
|
+
return this.useServiceAsClient(marketdata_1.MarketDataStreamServiceDefinition);
|
|
51
|
+
}
|
|
52
|
+
get operations() {
|
|
53
|
+
return this.useServiceAsClient(operations_1.OperationsServiceDefinition);
|
|
54
|
+
}
|
|
55
|
+
get operationsStream() {
|
|
56
|
+
return this.useServiceAsClient(operations_1.OperationsStreamServiceDefinition);
|
|
57
|
+
}
|
|
58
|
+
get orders() {
|
|
59
|
+
return this.useServiceAsClient(orders_1.OrdersServiceDefinition);
|
|
60
|
+
}
|
|
61
|
+
get ordersStream() {
|
|
62
|
+
return this.useServiceAsClient(orders_1.OrdersStreamServiceDefinition);
|
|
63
|
+
}
|
|
64
|
+
get sandbox() {
|
|
65
|
+
return this.useServiceAsClient(sandbox_1.SandboxServiceDefinition);
|
|
66
|
+
}
|
|
67
|
+
get signals() {
|
|
68
|
+
return this.useServiceAsClient(signals_1.SignalServiceDefinition);
|
|
69
|
+
}
|
|
70
|
+
get stoporders() {
|
|
71
|
+
return this.useServiceAsClient(stoporders_1.StopOrdersServiceDefinition);
|
|
72
|
+
}
|
|
73
|
+
get users() {
|
|
74
|
+
return this.useServiceAsClient(users_1.UsersServiceDefinition);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Идемпотентно закрывает shared channel и запрещает новые SDK-вызовы.
|
|
78
|
+
* Уже переданные transport-у операции нужно завершать их собственным AbortSignal.
|
|
79
|
+
*/
|
|
80
|
+
close() {
|
|
81
|
+
if (this.closed) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.closed = true;
|
|
85
|
+
this.lifecycleController.abort(this.createClosedError());
|
|
86
|
+
this.channel.close();
|
|
87
|
+
}
|
|
88
|
+
useServiceAsClient(service) {
|
|
89
|
+
this.assertOpen();
|
|
90
|
+
let client = this.storage.get(service);
|
|
91
|
+
if (!client) {
|
|
92
|
+
client = (0, grpc_1.createSdkClient)(service, this.channel, this.metadata, this.options.unaryLimiter, this.unaryLimitResolver, {
|
|
93
|
+
useSsl: this.options.useSsl,
|
|
94
|
+
maxReceiveMessageLength: this.maxReceiveMessageLength,
|
|
95
|
+
signal: this.lifecycleController.signal,
|
|
96
|
+
assertOpen: () => {
|
|
97
|
+
this.assertOpen();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
this.storage.set(service, client);
|
|
101
|
+
}
|
|
102
|
+
return client;
|
|
103
|
+
}
|
|
104
|
+
assertOpen() {
|
|
105
|
+
if (this.closed) {
|
|
106
|
+
throw this.createClosedError();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
createClosedError() {
|
|
110
|
+
return new sdk_error_1.SdkError(sdk_error_1.SdkErrorCode.SdkClosed, 'TInvestNodeSDK is closed', {
|
|
111
|
+
source: 'lifecycle'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.TInvestNodeSDK = TInvestNodeSDK;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль bootstrap config compiler преобразует декларативную unary policy в
|
|
3
|
+
* runtime-квоты для Consumer-owned limiter-а.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы:
|
|
6
|
+
* - построение полных gRPC paths для method rules;
|
|
7
|
+
* - сборка quota buckets и проверка инвариантов декларации;
|
|
8
|
+
* - проверка инвариантов итогового runtime snapshot;
|
|
9
|
+
* - public mapping читаемых per-instance overrides в flat UnaryLimits.
|
|
10
|
+
*
|
|
11
|
+
* Здесь не должно быть package defaults, limiter state или provider tariff
|
|
12
|
+
* refresh.
|
|
13
|
+
*/
|
|
14
|
+
import type { TInvestUnaryLimit } from '../application/services/unary-limiter';
|
|
15
|
+
import type { UnaryLimits, UnaryLimitsConfig, UnaryLimitsDefinition } from '../config.types';
|
|
16
|
+
/** Path-keyed runtime policy, которую принимает transport resolver. */
|
|
17
|
+
export interface UnaryLimitConfig {
|
|
18
|
+
buckets: Record<string, string>;
|
|
19
|
+
limits: UnaryLimits;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Service defaults сохраняются как короткие keys, а method limits получают
|
|
23
|
+
* полные gRPC paths. Package defaults не подмешиваются, quota groups не
|
|
24
|
+
* создаются.
|
|
25
|
+
*/
|
|
26
|
+
export declare function defineUnaryLimits(definition: UnaryLimitsDefinition): UnaryLimits;
|
|
27
|
+
/**
|
|
28
|
+
* Отклоняет повторное объявление RPC, а также неположительные и неконечные
|
|
29
|
+
* значения квот до создания SDK instance.
|
|
30
|
+
*/
|
|
31
|
+
export declare function compileUnaryLimits(definition: UnaryLimitsConfig): UnaryLimitConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Проверяет limits и quota groups после применения public defaults и
|
|
34
|
+
* per-instance overrides, до создания transport resolver.
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertUnaryLimitConfig(config: UnaryLimitConfig): void;
|
|
37
|
+
export declare function cloneUnaryLimits(limits: UnaryLimits): UnaryLimits;
|
|
38
|
+
export declare function sameUnaryLimit(first: TInvestUnaryLimit | undefined, second: TInvestUnaryLimit | undefined): boolean;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль bootstrap config compiler преобразует декларативную unary policy в
|
|
4
|
+
* runtime-квоты для Consumer-owned limiter-а.
|
|
5
|
+
*
|
|
6
|
+
* Здесь допустимы:
|
|
7
|
+
* - построение полных gRPC paths для method rules;
|
|
8
|
+
* - сборка quota buckets и проверка инвариантов декларации;
|
|
9
|
+
* - проверка инвариантов итогового runtime snapshot;
|
|
10
|
+
* - public mapping читаемых per-instance overrides в flat UnaryLimits.
|
|
11
|
+
*
|
|
12
|
+
* Здесь не должно быть package defaults, limiter state или provider tariff
|
|
13
|
+
* refresh.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.defineUnaryLimits = defineUnaryLimits;
|
|
17
|
+
exports.compileUnaryLimits = compileUnaryLimits;
|
|
18
|
+
exports.assertUnaryLimitConfig = assertUnaryLimitConfig;
|
|
19
|
+
exports.cloneUnaryLimits = cloneUnaryLimits;
|
|
20
|
+
exports.sameUnaryLimit = sameUnaryLimit;
|
|
21
|
+
const unary_limits_1 = require("../infrastructure/transport/grpc/unary-limits");
|
|
22
|
+
/**
|
|
23
|
+
* Service defaults сохраняются как короткие keys, а method limits получают
|
|
24
|
+
* полные gRPC paths. Package defaults не подмешиваются, quota groups не
|
|
25
|
+
* создаются.
|
|
26
|
+
*/
|
|
27
|
+
function defineUnaryLimits(definition) {
|
|
28
|
+
const limits = {};
|
|
29
|
+
for (const [service, serviceLimits] of Object.entries(definition)) {
|
|
30
|
+
if (serviceLimits.default !== undefined) {
|
|
31
|
+
limits[service] = cloneUnaryLimit(serviceLimits.default);
|
|
32
|
+
}
|
|
33
|
+
for (const [method, limit] of Object.entries(serviceLimits.methods ?? {})) {
|
|
34
|
+
if (limit !== undefined) {
|
|
35
|
+
limits[(0, unary_limits_1.unaryMethodPath)(service, method)] = cloneUnaryLimit(limit);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return limits;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Отклоняет повторное объявление RPC, а также неположительные и неконечные
|
|
43
|
+
* значения квот до создания SDK instance.
|
|
44
|
+
*/
|
|
45
|
+
function compileUnaryLimits(definition) {
|
|
46
|
+
const buckets = {};
|
|
47
|
+
const limits = {};
|
|
48
|
+
for (const [service, serviceLimits] of Object.entries(definition)) {
|
|
49
|
+
const assignedMethods = new Set();
|
|
50
|
+
assertUnaryLimit(serviceLimits.default, service);
|
|
51
|
+
limits[service] = cloneUnaryLimit(serviceLimits.default);
|
|
52
|
+
for (const [method, limit] of Object.entries(serviceLimits.methods ?? {})) {
|
|
53
|
+
if (limit === undefined) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
assertUnaryLimit(limit, `${service}/${method}`);
|
|
57
|
+
assignedMethods.add(method);
|
|
58
|
+
limits[(0, unary_limits_1.unaryMethodPath)(service, method)] = cloneUnaryLimit(limit);
|
|
59
|
+
}
|
|
60
|
+
for (const [groupName, group] of Object.entries(serviceLimits.groups ?? {})) {
|
|
61
|
+
const bucket = `${service}:${groupName}`;
|
|
62
|
+
assertUnaryLimit(group.limit, bucket);
|
|
63
|
+
for (const method of group.methods) {
|
|
64
|
+
if (assignedMethods.has(method)) {
|
|
65
|
+
throw new Error(`Unary limit method ${service}/${method} is declared more than once`);
|
|
66
|
+
}
|
|
67
|
+
assignedMethods.add(method);
|
|
68
|
+
const path = (0, unary_limits_1.unaryMethodPath)(service, method);
|
|
69
|
+
limits[path] = cloneUnaryLimit(group.limit);
|
|
70
|
+
buckets[path] = bucket;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const compiled = {
|
|
75
|
+
buckets,
|
|
76
|
+
limits
|
|
77
|
+
};
|
|
78
|
+
assertUnaryLimitConfig(compiled);
|
|
79
|
+
return compiled;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Проверяет limits и quota groups после применения public defaults и
|
|
83
|
+
* per-instance overrides, до создания transport resolver.
|
|
84
|
+
*/
|
|
85
|
+
function assertUnaryLimitConfig(config) {
|
|
86
|
+
const limitsByBucket = new Map();
|
|
87
|
+
for (const [rule, limit] of Object.entries(config.limits)) {
|
|
88
|
+
assertUnaryLimit(limit, rule);
|
|
89
|
+
}
|
|
90
|
+
for (const [rule, bucket] of Object.entries(config.buckets)) {
|
|
91
|
+
const limit = config.limits[rule];
|
|
92
|
+
if (limit === undefined) {
|
|
93
|
+
throw new Error(`Unary quota group ${bucket} references unknown rule ${rule}`);
|
|
94
|
+
}
|
|
95
|
+
const bucketLimit = limitsByBucket.get(bucket);
|
|
96
|
+
if (bucketLimit !== undefined && !sameUnaryLimit(bucketLimit, limit)) {
|
|
97
|
+
throw new Error(`Unary quota group ${bucket} contains inconsistent limits`);
|
|
98
|
+
}
|
|
99
|
+
limitsByBucket.set(bucket, limit);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function cloneUnaryLimits(limits) {
|
|
103
|
+
return Object.fromEntries(Object.entries(limits).map(([rule, limit]) => [
|
|
104
|
+
rule,
|
|
105
|
+
cloneUnaryLimit(limit)
|
|
106
|
+
]));
|
|
107
|
+
}
|
|
108
|
+
function sameUnaryLimit(first, second) {
|
|
109
|
+
return first !== undefined
|
|
110
|
+
&& second !== undefined
|
|
111
|
+
&& first.maxRequests === second.maxRequests
|
|
112
|
+
&& first.windowMs === second.windowMs;
|
|
113
|
+
}
|
|
114
|
+
function cloneUnaryLimit(limit) {
|
|
115
|
+
return {
|
|
116
|
+
maxRequests: limit.maxRequests,
|
|
117
|
+
windowMs: limit.windowMs
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function assertUnaryLimit(limit, rule) {
|
|
121
|
+
if (typeof limit !== 'object'
|
|
122
|
+
|| limit === null
|
|
123
|
+
|| !Number.isFinite(limit.maxRequests)
|
|
124
|
+
|| limit.maxRequests <= 0) {
|
|
125
|
+
throw new Error(`Unary limit ${rule}.maxRequests must be a finite positive number`);
|
|
126
|
+
}
|
|
127
|
+
if (!Number.isFinite(limit.windowMs) || limit.windowMs <= 0) {
|
|
128
|
+
throw new Error(`Unary limit ${rule}.windowMs must be a finite positive number`);
|
|
129
|
+
}
|
|
130
|
+
}
|