diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a18826..c72c761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,99 +1,6 @@ -# Kite v4 +# Kite v5 ### Breaking changes -- Upgrade deps and set minimum nodejs version to 8.0.0+ -- Return promise instead of throwing error on generateSession and renewAccessToken -- Handle gtt payload validation and throw proper error -- Change ticker response attributes naming as per [kite connect doc](https://kite.trade/docs/connect/v3/websocket/#quote-packet-structure) - -### New features -- Order margin call : [orderMargins](https://github.com/zerodha/kiteconnectjs/blob/master/lib/connect.js#L704) -- Basket order margin call : [orderBasketMargins](https://github.com/zerodha/kiteconnectjs/blob/master/lib/connect.js#L727) -- Add OI param to `getHistoricalData` -- Add global constant for postion types `POSITION_TYPE_DAY`, `POSITION_TYPE_OVERNIGHT` and `EXCHANGE_BCD` - -### Fixes -- Remove `order_id` param from complete tradebook fetch `getTrades` -- Fix `cancelMF` order_id param struct -- Handle price conversion for BCD segment in ticker -- Remove un-used `headers` param for `parseHistorical` -- Update comment block for `getQuote, getOHLC, getLTP, placeOrder and placeMFOrder` - - -# Kite v3 - -### New features -- method: `getProfile` -- method: `getOHLC` -- method: `getLTP` -- method: `getInstrumentsMargins` -- Added MF API calls -- method: `getMFOrders` -- method: `getMFHoldings` -- method: `placeMFOrder` -- method: `cancelMFOrder` -- method: `getMFSIPS` -- method: `placeMFSIP` -- method: `modifyMFSIP` -- method: `cancelMFSIP` -- method: `getMFInstruments` -- method: `exitOrder` -- method: `renewAccessToken` -- method: `invalidateRefreshToken` -- constants for products, order type, transaction type, variety, validity, exchanges and margin segments - -### API method name changes - -| v2 | v3 | -| ------------------------- | ------------------------- | -| requestAccessToken | generateSession | -| invalidateToken | invalidateAccessToken | -| setSessionHook | setSessionExpiryHook | -| loginUrl | getLoginURL | -| margins | getMargins | -| orderPlace | placeOrder | -| orderModify | modifyOrder | -| orderCancel | cancelOrder | -| orders | getOrders | -| orders(order_id) | getOrderHistory | -| trades | getTrades | -| trades(order_id) | getOrderTrades | -| holdings | getHoldings | -| positions | getPositions | -| productModify | convertPosition | -| instruments | getInstruments | -| historical | getHistoricalData | -| triggerRange | getTriggerRange | - -### Params and other changes -- `KiteConnect` takes all the params as object including `api_key` -- `convertPosition` method takes all the params as object -- All success response returns only `data` field in response instead with envelope -- All error thrown are in the format of `{"message": "Unknown error", "error_type": "GeneralException", "data": null}` -- [Changes in `generateSession` response structure](https://kite.trade/docs/connect/v3/user/#response-attributes) -- [Changes in `getPositions` response structure](https://kite.trade/docs/connect/v3/portfolio/#response-attributes_1) -- [Changes in `getQuote` response structure](https://kite.trade/docs/connect/v3/market-quotes/#retrieving-full-market-quotes) -- [Changes in `placeOrder` params](https://kite.trade/docs/connect/v3/orders/#bracket-order-bo-parameters) -- Changes in `getHistoricalData` params -- All datetime string fields has been converted to `Date` object. - - `getOrders`, `getOrderHistory`, `getTrades`, `getOrderTrades`, `getMFOrders` responses fields `order_timestamp`, `exchange_timestamp`, `fill_timestamp` - - `getMFSIPS` fields `created`, `last_instalment` - - `generateSession` field `login_time` - - `getQuote` fields `timestamp`, `last_trade_time` - - `getInstruments` field `expiry` - - `getMFInstruments` field `last_price_date` - -### KiteTicker changes -- `KiteTicker` receives param `access_token` instead of `public_token` -- New params addedd to `KiteTicker` initializer - - `reconnect` - Toggle auto reconnect on/off - - `max_retry` - Max retry count for auto reconnect - - `max_delay` - Max delay between subsequent retries - - Auto reconnect is enabled by default -- Renamed callback `reconnecting` to `reconnect` -- Added new callbacks - - `error` - when socket connection is closed with error. Error is received as a first param - - `close` - when socket connection is closed cleanly - - `order_update` - When order update (postback) is received for the connected user (Data object is received as first argument) - +- Upgrade deps and set minimum nodejs version to 18.0.0+ +- New ts lib ## To-do: Add all changes diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9dcdb2f --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2024 Zerodha Technology Pvt. Ltd. (India) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index e2617a2..b559310 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -# The Kite Connect API Javascript client - v5 +# The Kite Connect API JavaScript/TypeScript Client -The official Javascript node client for communicating with the [Kite Connect API](https://kite.trade). +The official JavaScript/TypeScript for communicating with the [Kite Connect API](https://kite.trade). Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more, with the simple HTTP API collection. -[Zerodha Technology](http://zerodha.com) (c) 2018. Licensed under the MIT License. +[Zerodha Technology](http://zerodha.com) (c) 2024. Licensed under the MIT License. ## Documentation -- [Javascript client documentation](https://kite.trade/docs/kiteconnectjs/v3) +- [Typescript client documentation](https://kite.trade/docs/kiteconnectjs/v3) - [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v3) ## Requirements @@ -25,93 +25,103 @@ Or via [yarn](https://yarnpkg.com/package/kiteconnect) yarn add kiteconnect -## Breaking changes - v5 - -`v5` is a **breaking** major release with multiple internal modification including for typescript.
+## Getting started with API -Below are the breaking changes: +```typescript +import { KiteConnect } from "kiteconnect"; -- Upgrade deps and set minimum nodejs version to 8.0.0+ -- Return promise instead of throwing error on generateSession and renewAccessToken -- Handle gtt payload validation and throw proper error -- Change ticker response attributes naming as per [kite connect doc](https://kite.trade/docs/connect/v3/websocket/#quote-packet-structure) +const apiKey = "your_api_key"; +const apiSecret = "your_api_secret"; +const requestToken = "your_request_token"; -## Getting started with API +const kc = new KiteConnect({ api_key: apiKey }); -```javascript -var KiteConnect = require("kiteconnect").KiteConnect; +async function init() { + try { + await generateSession(); + await getProfile(); + } catch (err) { + console.error(err); + } +} -var kc = new KiteConnect({ - api_key: "your_api_key", -}); +async function generateSession() { + try { + const response = await kc.generateSession(requestToken, apiSecret); + kc.setAccessToken(response.access_token); + console.log("Session generated:", response); + } catch (err) { + console.error("Error generating session:", err); + } +} -kc.generateSession("request_token", "api_secret") - .then(function (response) { - init(); - }) - .catch(function (err) { - console.log(err); - }); - -function init() { - // Fetch equity margins. - // You can have other api calls here. - kc.getMargins() - .then(function (response) { - // You got user's margin details. - }) - .catch(function (err) { - // Something went wrong. - }); +async function getProfile() { + try { + const profile = await kc.getProfile(); + console.log("Profile:", profile); + } catch (err) { + console.error("Error getting profile:", err); + } } +// Initialize the API calls +init(); ``` -## API promises - -All API calls returns a promise which you can use to call methods like `.then(...)` and `.catch(...)`. +## Getting started WebSocket client -```javascript -kiteConnectApiCall - .then(function (v) { - // On success - }) - .catch(function (e) { - // On rejected - }); -``` +```typescript +import { KiteTicker } from "kiteconnect"; -## Getting started WebSocket client +const apiKey = "your_api_key"; +const accessToken = "generated_access_token"; -```javascript -var KiteTicker = require("kiteconnect").KiteTicker; -var ticker = new KiteTicker({ - api_key: "api_key", - access_token: "access_token", +const ticker = new KiteTicker({ + api_key: apiKey, + access_token: accessToken, }); ticker.connect(); ticker.on("ticks", onTicks); ticker.on("connect", subscribe); +ticker.on("disconnect", onDisconnect); +ticker.on("error", onError); +ticker.on("close", onClose); +ticker.on("order_update", onTrade); -function onTicks(ticks) { +function onTicks(ticks: any[]): void { console.log("Ticks", ticks); } -function subscribe() { - var items = [738561]; - ticker.subscribe(items); - ticker.setMode(ticker.modeFull, items); +function subscribe(): void { + const tokens = [738561, 256265]; + ticker.subscribe(tokens); + ticker.setMode(ticker.modeFull, tokens); +} + +function onDisconnect(error: Error): void { + console.log("Closed connection on disconnect", error); +} + +function onError(error: Error): void { + console.log("Closed connection on error", error); +} + +function onClose(reason: string): void { + console.log("Closed connection on close", reason); +} + +function onTrade(order: any): void { + console.log("Order update", order); } ``` ## Auto re-connect WebSocket client -Optionally you can enable client side auto re-connection to automatically reconnect if the connection is dropped. -It is very useful at times when client side network is unreliable and patchy. +Optionally, you can enable client-side auto re-connection to automatically reconnect if the connection is dropped. It is very useful when the client-side network is unreliable and patchy. -All you need to do is enable auto re-connection with preferred interval and time. For example +Enable auto re-connection with a preferred interval and time. For example: -```javascript +```typescript // Enable auto reconnect with 5 second interval and retry for maximum of 20 times. ticker.autoReconnect(true, 20, 5); @@ -127,38 +137,37 @@ ticker.autoReconnect(true, -1, 5); Here is an example demonstrating auto reconnection. -```javascript -var KiteTicker = require("kiteconnect").KiteTicker; -var ticker = new KiteTicker({ +```typescript +import { KiteTicker } from "kiteconnect"; + +const apiKey = "your_api_key"; +const accessToken = "generated_access_token"; +const ticker = new KiteTicker({ api_key: "api_key", access_token: "access_token", }); - -// set autoreconnect with 10 maximum reconnections and 5 second interval ticker.autoReconnect(true, 10, 5); ticker.connect(); ticker.on("ticks", onTicks); ticker.on("connect", subscribe); - -ticker.on("noreconnect", function () { +ticker.on("noreconnect", () => { console.log("noreconnect"); }); - -ticker.on("reconnecting", function (reconnect_interval, reconnections) { +ticker.on("reconnect", (reconnect_count: any, reconnect_interval: any) => { console.log( "Reconnecting: attempt - ", - reconnections, - " innterval - ", + reconnect_count, + " interval - ", reconnect_interval ); }); -function onTicks(ticks) { +function onTicks(ticks: any[]) { console.log("Ticks", ticks); } function subscribe() { - var items = [738561]; + const items = [738561]; ticker.subscribe(items); ticker.setMode(ticker.modeFull, items); } @@ -173,8 +182,7 @@ npm run test ## Generate documentation ``` -$ npm install -g jsdoc -$ jsdoc -r ./lib -d ./docs +$ npx typedoc --out ./docs ``` ## Changelog diff --git a/examples/kiteconnect.ts b/examples/kiteconnect.ts new file mode 100644 index 0000000..6c6c384 --- /dev/null +++ b/examples/kiteconnect.ts @@ -0,0 +1,420 @@ +import { KiteConnect } from 'kiteconnect'; + +const apiKey = 'your_api_key'; +const apiSecret = 'your_api_secret'; +const requestToken = 'your_request_token'; + +const kc = new KiteConnect({ api_key: apiKey }); + +async function init() { + try { + await generateSession(); + await getProfile(); + await getMargins(); + await getMargins("equity"); + await getPositions(); + await convertPosition(); + await getHoldings(); + await getOrderHistory(240611801793632); + await getTrades(); + await getOrderTrades(240611801793632); + await getInstruments(); + await getInstrumentsNFO("NFO"); + await getQuote(['NSE:RELIANCE', 'NSE:SBIN', 'BSE:ONGC']); + await getOHLC(['NSE:RELIANCE', 'NSE:SBIN', 'BSE:ONGC']); + await getLTP(['NSE:RELIANCE', 'NSE:SBIN', 'BSE:ONGC']); + await getHistoricalData(16320514, "day", "2024-05-11 00:00:00", "2024-06-12 00:00:00", true, true); + await placeRegularOrder(); + await placeIcebergOrder(); + await modifyRegularOrder(240611801793632); + await cancelRegularOrder(240611801793632); + await getGTTs(); + await getGTT(216313963); + await placeGTT(); + await modifyGTT(219118727); + await deleteGTT(219118727); + await getOrderMargins(); + await getOrderBasketMargins(); + await getvirtualContractNote(); + } catch (err) { + console.error(err); + } +} + +async function generateSession() { + try { + const response = await kc.generateSession(requestToken, apiSecret); + kc.setAccessToken(response.access_token); + console.log('Session generated:', response); + } catch (err) { + console.error('Error generating session:', err); + } +} + +async function getProfile() { + try { + const profile = await kc.getProfile(); + console.log('Profile:', profile); + } catch (err) { + console.error('Error getting profile:', err); + } +} + +async function getMargins(segment?: 'equity' | 'commodity') { + try { + const margins = await kc.getMargins(segment); + console.log('Margins:', margins); + } catch (err) { + console.error('Error getting margins:', err); + } +} + +async function getPositions() { + try { + const positions = await kc.getPositions(); + console.log('Positions:', positions); + } catch (err) { + console.error('Error getting positions:', err); + } +} + +async function convertPosition() { + try { + const convertPosition = await kc.convertPosition({ + exchange: kc.EXCHANGE_NSE, + tradingsymbol: "SBIN", + transaction_type: "BUY", + position_type: "day", + quantity: 4, + old_product: "MIS", + new_product: "CNC" + }); + console.log('Convert Position:', convertPosition); + } catch (err) { + console.error('Error converting position:', err); + } +} + +async function getHoldings() { + try { + const holdings = await kc.getHoldings(); + console.log('Holdings:', holdings); + } catch (err) { + console.error('Error getting holdings:', err); + } +} + +async function getOrderHistory(orderId: number | string) { + try { + const orderHistory = await kc.getOrderHistory(orderId); + console.log('Order History:', orderHistory); + } catch (err) { + console.error('Error getting order history:', err); + } +} + +async function getTrades() { + try { + const trades = await kc.getTrades(); + console.log('Trades:', trades); + } catch (err) { + console.error('Error getting trades:', err); + } +} + +async function getOrderTrades(orderId: number | string) { + try { + const orderTrades = await kc.getOrderTrades(orderId); + console.log('Order Trades:', orderTrades); + } catch (err) { + console.error('Error getting order trades:', err); + } +} + +async function getInstruments() { + try { + const instruments = await kc.getInstruments(); + console.log('Instruments:', instruments); + } catch (err) { + console.error('Error getting instruments:', err); + } +} + +async function getInstrumentsNFO(segment: string) { + try { + const instruments = await kc.getInstruments(segment); + console.log('Instruments:', instruments); + } catch (err) { + console.error('Error getting instruments:', err); + } +} + +async function getQuote(instruments: string[]) { + try { + const quotes = await kc.getQuote(instruments); + console.log('Quotes:', quotes); + } catch (err) { + console.error('Error getting quotes:', err); + } +} + +async function getOHLC(instruments: string[]) { + try { + const ohlc = await kc.getOHLC(instruments); + console.log('OHLC:', ohlc); + } catch (err) { + console.error('Error getting OHLC:', err); + } +} + +async function getLTP(instruments: string[]) { + try { + const ltp = await kc.getLTP(instruments); + console.log('LTP:', ltp); + } catch (err) { + console.error('Error getting LTP:', err); + } +} + +async function getHistoricalData(instrumentToken: number, interval: string, from: string, to: string, continuous: boolean, oi: boolean) { + try { + const historicalData = await kc.getHistoricalData(instrumentToken, interval, from, to, continuous, oi); + console.log('Historical Data:', historicalData); + } catch (err) { + console.error('Error getting historical data:', err); + } +} + +async function placeRegularOrder() { + try { + const order = await kc.placeOrder(kc.VARIETY_REGULAR, { + exchange: kc.EXCHANGE_NSE, + tradingsymbol: "SBIN", + transaction_type: kc.TRANSACTION_TYPE_BUY, + quantity: 1, + product: kc.PRODUCT_CNC, + order_type: kc.ORDER_TYPE_LIMIT, + price: 830 + }); + console.log('Regular Order Placed:', order); + } catch (err) { + console.error('Error placing regular order:', err); + } +} + +async function placeIcebergOrder() { + try { + const order = await kc.placeOrder(kc.VARIETY_REGULAR, { + exchange: kc.EXCHANGE_NSE, + tradingsymbol: "SBIN", + transaction_type: "BUY", + quantity: 1000, + product: "CNC", + order_type: "LIMIT", + validity: "TTL", + price: 830, + validity_ttl: 10, + iceberg_legs: 5, + iceberg_quantity: 200 + }); + console.log('Iceberg Order Placed:', order); + } catch (err) { + console.error('Error placing iceberg order:', err); + } +} + +async function modifyRegularOrder(orderId: number) { + try { + const order = await kc.modifyOrder(kc.VARIETY_REGULAR, orderId, { + price: 818 + }); + console.log('Regular Order Modified:', order); + } catch (err) { + console.error('Error modifying regular order:', err); + } +} + +async function cancelRegularOrder(orderId: number) { + try { + const order = await kc.cancelOrder(kc.VARIETY_REGULAR, orderId); + console.log('Regular Order Cancelled:', order); + } catch (err) { + console.error('Error cancelling regular order:', err); + } +} + +async function getGTTs() { + try { + const gtts = await kc.getGTTs(); + console.log('GTTs:', gtts); + } catch (err) { + console.error('Error getting GTTs:', err); + } +} + +async function getGTT(gttId: number) { + try { + const gtt = await kc.getGTT(gttId); + console.log('GTT:', gtt); + } catch (err) { + console.error('Error getting GTT:', err); + } +} + +async function placeGTT() { + try { + const gtt = await kc.placeGTT({ + trigger_type: kc.GTT_TYPE_OCO, + tradingsymbol: "SBIN", + exchange: "NSE", + trigger_values: [800, 840], + last_price: 835, + orders: [{ + transaction_type: kc.TRANSACTION_TYPE_SELL, + quantity: 1, + product: kc.PRODUCT_CNC, + order_type: kc.ORDER_TYPE_LIMIT, + price: 840 + }, { + transaction_type: kc.TRANSACTION_TYPE_SELL, + quantity: 1, + product: kc.PRODUCT_CNC, + order_type: kc.ORDER_TYPE_LIMIT, + price: 800 + }] + }); + console.log('GTT Placed:', gtt); + } catch (err) { + console.error('Error placing GTT:', err); + } +} + +async function modifyGTT(gttId: number) { + try { + const gtt = await kc.modifyGTT(gttId, { + trigger_type: kc.GTT_TYPE_OCO, + tradingsymbol: "SBIN", + exchange: "NSE", + trigger_values: [800, 860], + last_price: 837, + orders: [{ + transaction_type: kc.TRANSACTION_TYPE_SELL, + quantity: 1, + product: kc.PRODUCT_CNC, + order_type: kc.ORDER_TYPE_LIMIT, + price: 860 + }, { + transaction_type: kc.TRANSACTION_TYPE_SELL, + quantity: 1, + product: kc.PRODUCT_CNC, + order_type: kc.ORDER_TYPE_LIMIT, + price: 800 + }] + }); + console.log('GTT Modified:', gtt); + } catch (err) { + console.error('Error modifying GTT:', err); + } +} + +async function deleteGTT(gttId: number) { + try { + const gtt = await kc.deleteGTT(gttId); + console.log('GTT Deleted:', gtt); + } catch (err) { + console.error('Error deleting GTT:', err); + } +} + +async function getOrderMargins() { + try { + const margins = await kc.orderMargins([{ + exchange: "NFO", + tradingsymbol: "NIFTY24JUL23000CE", + transaction_type: "BUY", + variety: "regular", + product: "MIS", + order_type: "MARKET", + quantity: 75, + price: 0, + trigger_price: 0 + }, + { + exchange: "NFO", + tradingsymbol: "NIFTY24JUL25000CE", + transaction_type: "SELL", + variety: "regular", + product: "MIS", + order_type: "MARKET", + quantity: 150, + price: 0, + trigger_price: 0 + }], "compact"); + console.log('Order Margins:', margins); + } catch (err) { + console.error('Error getting order margins:', err); + } +} + +async function getOrderBasketMargins() { + try { + const basketMargins = await kc.orderBasketMargins([{ + exchange: "NFO", + tradingsymbol: "NIFTY24JUL23000CE", + transaction_type: "BUY", + variety: "regular", + product: "MIS", + order_type: "MARKET", + quantity: 75, + price: 0, + trigger_price: 0 + }, + { + exchange: "NFO", + tradingsymbol: "NIFTY24JUL25000CE", + transaction_type: "SELL", + variety: "regular", + product: "MIS", + order_type: "MARKET", + quantity: 150, + price: 0, + trigger_price: 0 + }], true, "compact"); + console.log('Order Basket Margins:', basketMargins); + } catch (err) { + console.error('Error getting order basket margins:', err); + } +} + +async function getvirtualContractNote() { + try { + const getvirtualContractNote = await kc.getvirtualContractNote([{ + order_id: '111111111', + exchange: "NFO", + tradingsymbol: "NIFTY24JUL23000CE", + transaction_type: "BUY", + variety: "regular", + product: "MIS", + order_type: "MARKET", + quantity: 75, + average_price: 560 + }, + { + order_id: '22222222', + exchange: "NFO", + tradingsymbol: "NIFTY24JUL25000CE", + transaction_type: "SELL", + variety: "regular", + product: "MIS", + order_type: "MARKET", + quantity: 150, + average_price: 600 + }]); + console.log('Virtual contract Note:', getvirtualContractNote); + } catch (err) { + console.error('Error getting virtual contract note:', err); + } +} + +// Initialize the API calls +init(); diff --git a/examples/kiteticker.ts b/examples/kiteticker.ts new file mode 100644 index 0000000..7481dee --- /dev/null +++ b/examples/kiteticker.ts @@ -0,0 +1,43 @@ +import { KiteTicker } from "kiteconnect"; + +const apiKey = 'your_api_key'; +const accessToken = 'generated_access_token'; + +const ticker = new KiteTicker({ + api_key: apiKey, + access_token: accessToken +}); + +ticker.connect(); +ticker.on('ticks', onTicks); +ticker.on('connect', subscribe); +ticker.on('disconnect', onDisconnect); +ticker.on('error', onError); +ticker.on('close', onClose); +ticker.on('order_update', onTrade); + +function onTicks(ticks: any[]): void { + console.log("Ticks", ticks); +} + +function subscribe(): void { + const tokens = [738561, 256265]; + ticker.subscribe(tokens); + ticker.setMode(ticker.modeFull, tokens); +} + +function onDisconnect(error: Error): void { + console.log("Closed connection on disconnect", error); +} + +function onError(error: Error): void { + console.log("Closed connection on error", error); +} + +function onClose(reason: string): void { + console.log("Closed connection on close", reason); +} + +function onTrade(order: any): void { + console.log("Order update", order); +} diff --git a/interfaces/connect.ts b/interfaces/connect.ts index 5f87d4e..bf6f10b 100644 --- a/interfaces/connect.ts +++ b/interfaces/connect.ts @@ -107,7 +107,7 @@ export interface KiteConnectParams { /** * Kite connect login url * - * Defaults to 'https?://kite.trade/connect/login' + * Defaults to 'https://kite.zerodha.com/connect/login' */ login_uri?: string; /** @@ -122,13 +122,6 @@ export interface KiteConnectParams { * Defaults to `7000` */ timeout?: number; - /* - * Default url for which user will be redirected to login page - */ - /** - * @type {?string} - */ - default_login_uri?: string; }; /** @@ -143,7 +136,7 @@ export interface KiteConnectInterface extends KiteConnectParams { * @public * @enum {string} */ -export enum ExchangeTypes { +export enum Exchanges { NSE = 'NSE', BSE = 'BSE', NFO = 'NFO', @@ -245,9 +238,9 @@ export interface ExitOrderParams { */ export interface ConvertPositionParams { /** - * @type {string} + * @type {Exchanges} */ - exchange: string; + exchange: Exchanges; /** * @type {string} */ @@ -299,9 +292,9 @@ export interface Order { */ order_type?: OrderTypes; /** - * @type {?ExchangeTypes} + * @type {?Exchanges} */ - exchange?: ExchangeTypes; + exchange?: Exchanges; /** * @type {?string} */ @@ -444,9 +437,9 @@ export interface ModifyGTTParams { */ tradingsymbol: string; /** - * @type {ExchangeTypes} + * @type {Exchanges} */ - exchange: ExchangeTypes; + exchange: Exchanges; /** * @type {Array} */ @@ -651,9 +644,9 @@ export interface PlaceGTTParams { */ tradingsymbol: string; /** - * @type {ExchangeTypes} + * @type {Exchanges} */ - exchange: ExchangeTypes; + exchange: Exchanges; /** * @type {Array} */ @@ -703,9 +696,9 @@ export interface PlaceOrderParams { */ tradingsymbol: string; /** - * @type {ExchangeTypes} + * @type {Exchanges} */ - exchange: ExchangeTypes; + exchange: Exchanges; /** * @type {TransactionTypes} */ @@ -734,4 +727,103 @@ export interface PlaceOrderParams { * @type {?string} */ tag?: string; -}; \ No newline at end of file +}; + + +/** + * Represents parameters for order margin. + * + * @remarks + * This interface defines the order parameters required to fetch order margins. + * + * @public + * @name MarginOrder + */ + +export type MarginOrder = { + /** + * Name of the exchange(eg. NSE, BSE, NFO, CDS, MCX) + */ + exchange: Exchanges; + /** + * Trading symbol of the instrument + */ + tradingsymbol: string; + /** + * eg. BUY, SELL + */ + transaction_type: TransactionTypes; + /** + * Order variety (regular, amo, bo, co etc.) + */ + variety: Varieties; + /** + * Margin product to use for the order + */ + product: Products; + /** + * Order type (MARKET, LIMIT etc.) + */ + order_type: OrderTypes; + /** + * Quantity of the order + */ + quantity: number; + /** + * Price at which the order is going to be placed (LIMIT orders) + */ + price: number; + /** + * Trigger price (for SL, SL-M, CO orders) + */ + trigger_price: number; + }; + +/** + * Represents parameters for virtual contract margin. + * + * @remarks + * This interface defines the order parameters required to fetch virtual contract margin. + * + * @public + * @name VirtualContractParam + */ + + export type VirtualContractParam = { + /** + * Unique order ID (It can be any random string to calculate charges for an imaginary order) + */ + order_id: number | string; + /** + * Name of the exchange(eg. NSE, BSE, NFO, CDS, MCX) + */ + exchange: Exchanges; + /** + * Trading symbol of the instrument + */ + tradingsymbol: string; + /** + * eg. BUY, SELL + */ + transaction_type: TransactionTypes; + /** + * Order variety (regular, amo, bo, co etc.) + */ + variety: Varieties; + /** + * Margin product to use for the order + */ + product: Products; + /** + * Order type (MARKET, LIMIT etc.) + */ + order_type: OrderTypes; + /** + * Quantity of the order + */ + quantity: number; + /** + * Average price at which the order was executed (Note: Should be non-zero). + */ + average_price: number; + }; \ No newline at end of file diff --git a/interfaces/ticker.ts b/interfaces/ticker.ts index 2193d67..029ca83 100644 --- a/interfaces/ticker.ts +++ b/interfaces/ticker.ts @@ -47,18 +47,92 @@ export interface KiteTickerInterface extends KiteTickerParams { } + /** - * Represents the tick response for the Last Traded Price (LTP) mode. * * @remarks - * This interface defines the structure of a tick response in LTP mode, + * This interface defines the structure of a tick response * * @public - * @name TickLTP + * @name BaseTick */ - export interface TickLTP { - mode: string; +export interface BaseTick { tradable: boolean; + mode: string; instrument_token: number; last_price: number; } + +/** + * + * @remarks + * This interface defines the structure of a tick response in the LTP mode. + * + * @public + * @name LTPTick + */ +export interface LTPTick extends BaseTick { + mode: string; +} + +/** + * + * @remarks + * This interface defines the structure of a tick response in the Quote mode. + * + * @public + * @name QuoteTick + */ +export interface QuoteTick extends BaseTick { + mode: string; + ohlc: { + high: number; + low: number; + open: number; + close: number; + }; + change: number; + exchange_timestamp?: Date | null; +} + +/** + * + * @remarks + * This interface defines the structure of a tick response in the Full mode. + * + * @public + * @name FullTick + */ +export interface FullTick extends BaseTick { + mode: string; + last_traded_quantity: number; + average_traded_price: number; + volume_traded: number; + total_buy_quantity: number; + total_sell_quantity: number; + ohlc: { + high: number; + low: number; + open: number; + close: number; + }; + change: number; + exchange_timestamp?: Date | null; + last_trade_time?: Date | null; + oi?: number; + oi_day_high?: number; + oi_day_low?: number; + depth?: { + buy: Depth[]; + sell: Depth[]; + }; +} + +export interface Depth { + quantity: number; + price: number; + orders: number; +} + +// Combined type for all tick modes +export type Tick = LTPTick | QuoteTick | FullTick; diff --git a/lib/connect.ts b/lib/connect.ts index bbb62a5..356ce35 100644 --- a/lib/connect.ts +++ b/lib/connect.ts @@ -3,9 +3,9 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosTransformer, Method } from 'axios'; import csvParse from 'papaparse'; import sha256 from 'crypto-js/sha256'; -import querystring from 'querystring'; +import qs from 'qs'; import utils from './utils'; -import { KiteConnectParams, Varieties, GTTStatusTypes, AnyObject, Order, TransactionTypes, KiteConnectInterface, CancelOrderParams, ExitOrderParams, ModifyGTTParams, ModifyOrderParams, PlaceGTTParams, PlaceMFOrderParams, PlaceOrderParams } from '../interfaces'; +import { KiteConnectParams, Varieties, GTTStatusTypes, AnyObject, Order, MarginOrder, VirtualContractParam, TransactionTypes, KiteConnectInterface, CancelOrderParams, ExitOrderParams, ModifyGTTParams, ModifyOrderParams, PlaceGTTParams, PlaceMFOrderParams, PlaceOrderParams, ConvertPositionParams, Exchanges } from '../interfaces'; import { DEFAULTS, ROUTES } from '../constants'; @@ -20,43 +20,56 @@ import { DEFAULTS, ROUTES } from '../constants'; * ------------------------ * ~~~~ * - * const KiteConnect = require('kiteconnect').KiteConnect; - * - * const kc = new KiteConnect({api_key: 'your_api_key'}); - * - * kc.generateSession('request_token', 'api_secret') - * .then(function(response) { - * init(); - * }) - * .catch(function(err) { - * console.log(err); - * }) - * - * function init() { - * // Fetch equity margins. - * // You can have other api calls here. - * - * kc.getMargins() - * .then(function(response) { - * // You got user's margin details. - * }).catch(function(err) { - * // Something went wrong. - * }); - * } + * import { KiteConnect } from 'kiteconnect'; + * + * const apiKey = 'your_api_key' + * const apiSecret = 'your_api_secret' + * const requestToken = 'your_request_token' + * + * const kc = new KiteConnect({ api_key: apiKey }) + * + * async function init() { + * try { + * await generateSession() + * await getProfile() + * } catch (err) { + * console.error(err) + * } + * } + * + * async function generateSession() { + * try { + * const response = await kc.generateSession(requestToken, apiSecret) + * kc.setAccessToken(response.access_token) + * console.log('Session generated:', response) + * } catch (err) { + * console.error('Error generating session:', err) + * } + * } + * + * async function getProfile() { + * try { + * const profile = await kc.getProfile() + * console.log('Profile:', profile) + * } catch (err) { + * console.error('Error getting profile:', err) + * } + * } + * // Initialize the API calls + * init(); * ~~~~ * * API promises * ------------- - * All API calls returns a promise which you can use to call methods like `.then(...)` and `.catch(...)`. - * + * All API calls return a promise which you can `await` to handle asynchronously. + * * ~~~~ - * kiteConnectApiCall - * .then(function(v) { - * // On success - * }) - * .catch(function(e) { - * // On rejected - * }); + * try { + * const result = await kiteConnectApiCall; + * // On success + * } catch (error) { + * // On rejection + * } * ~~~~ * * @constructor @@ -76,7 +89,7 @@ import { DEFAULTS, ROUTES } from '../constants'; * for a request to complete before it fails. * * @example Initialize KiteConnect object - * const kc = KiteConnect('my_api_key', {timeout: 10, debug: false}) + * const kc = new KiteConnect({ api_key: apiKey }) */ @@ -107,13 +120,9 @@ export class KiteConnect implements KiteConnectInterface { */ timeout?: number; /** - * @type {?string} - */ - default_connect_uri?: string; - /** - * @type {?(string | null)} + * @type {?(function | null)} */ - session_expiry_hook?: string | null; + session_expiry_hook?: (() => void) | null; /** * @type {?string} */ @@ -124,6 +133,68 @@ export class KiteConnect implements KiteConnectInterface { */ private requestInstance: AxiosInstance; + // Constants + readonly PRODUCT_MIS: string = 'MIS'; + readonly PRODUCT_CNC: string = 'CNC'; + readonly PRODUCT_NRML: string = 'NRML'; + + // Order types + readonly ORDER_TYPE_MARKET: string = 'MARKET'; + readonly ORDER_TYPE_LIMIT: string = 'LIMIT'; + readonly ORDER_TYPE_SLM: string = 'SL-M'; + readonly ORDER_TYPE_SL: string ='SL'; + + // Varieties + readonly VARIETY_REGULAR: string = 'regular'; + readonly VARIETY_CO: string = 'co'; + readonly VARIETY_AMO: string = 'amo'; + readonly VARIETY_ICEBERG: string = 'iceberg'; + readonly VARIETY_AUCTION: string = 'auction'; + + // Transaction types + readonly TRANSACTION_TYPE_BUY: string = 'BUY'; + readonly TRANSACTION_TYPE_SELL: string = 'SELL'; + + // Validities + readonly VALIDITY_DAY: string = 'DAY'; + readonly VALIDITY_IOC: string = 'IOC'; + readonly VALIDITY_TTL: string = 'TTL'; + + // Exchanges + readonly EXCHANGE_NSE: string = 'NSE'; + readonly EXCHANGE_BSE: string = 'BSE'; + readonly EXCHANGE_NFO: string = 'NFO'; + readonly EXCHANGE_CDS: string = 'CDS'; + readonly EXCHANGE_BCD: string = 'BCD'; + readonly EXCHANGE_BFO: string = 'BFO'; + readonly EXCHANGE_MCX: string = 'MCX'; + + // Margins segments + readonly MARGIN_EQUITY: string = 'equity'; + readonly MARGIN_COMMODITY: string = 'commodity'; + + // Statuses + readonly STATUS_CANCELLED: string = 'CANCELLED'; + readonly STATUS_REJECTED: string = 'REJECTED'; + readonly STATUS_COMPLETE: string = 'COMPLETE'; + + // GTT types + readonly GTT_TYPE_OCO: string = 'two-leg'; + readonly GTT_TYPE_SINGLE: string = 'single'; + + // GTT statuses + readonly GTT_STATUS_ACTIVE: string = 'active'; + readonly GTT_STATUS_TRIGGERED: string = 'triggered'; + readonly GTT_STATUS_DISABLED: string = 'disabled'; + readonly GTT_STATUS_EXPIRED: string = 'expired'; + readonly GTT_STATUS_CANCELLED: string = 'cancelled'; + readonly GTT_STATUS_REJECTED: string = 'rejected'; + readonly GTT_STATUS_DELETED: string = 'deleted'; + + // Position types + readonly POSITION_TYPE_DAY: string = 'day'; + readonly POSITION_TYPE_OVERNIGHT: string = 'overnight'; + /** * Creates an instance of KiteConnect. * @@ -136,7 +207,7 @@ export class KiteConnect implements KiteConnectInterface { this.timeout = params.timeout || DEFAULTS.timeout; this.debug = params.debug || DEFAULTS.debug; this.access_token = params.access_token || null; - this.default_connect_uri = DEFAULTS.login; + this.default_login_uri = DEFAULTS.login; this.session_expiry_hook = null; this.requestInstance = this.createAxiosInstance(); } @@ -158,7 +229,18 @@ export class KiteConnect implements KiteConnectInterface { 'User-Agent': userAgent }, paramsSerializer(params) { - return querystring.stringify(params); + const searchParams = new URLSearchParams(); + for (const key in params) { + if (params.hasOwnProperty(key)) { + const value = params[key]; + if (Array.isArray(value)) { + value.forEach(val => searchParams.append(key, val)); + } else { + searchParams.append(key, value); + } + } + } + return searchParams.toString(); } }); @@ -188,7 +270,7 @@ export class KiteConnect implements KiteConnectInterface { 'message': 'Unknown content type (' + contentType + ') with response: (' + response.data + ')' }; } - }, function (error) { + }, (error) => { let resp = { 'message': 'Unknown error', 'error_type': 'GeneralException', @@ -200,7 +282,7 @@ export class KiteConnect implements KiteConnectInterface { // that falls out of the range of 2xx if (error.response.data && error.response.data.error_type) { if (error.response.data.error_type === 'TokenException' && this.session_expiry_hook) { - this.session_expiry_hook() + this.session_expiry_hook(); } resp = error.response.data; @@ -268,7 +350,7 @@ export class KiteConnect implements KiteConnectInterface { * @returns {Promise} A promise that resolves when the session generation is successful and rejects if an error occurs. */ generateSession(request_token: string, api_secret: string): Promise { - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { const checksum = sha256(this.api_key + request_token + api_secret).toString(); const p = this._post('api.token', { api_key: this.api_key, @@ -276,7 +358,7 @@ export class KiteConnect implements KiteConnectInterface { checksum: checksum }, null, formatGenerateSession); - p.then(function (resp: any) { + p.then((resp: any) => { // Set access token. if (resp && resp.access_token) { this.setAccessToken(resp.access_token); @@ -296,7 +378,7 @@ export class KiteConnect implements KiteConnectInterface { * If no access token is provided, the method uses the default access token associated with the instance. * * @param {string} [access_token] - The access token to invalidate. If not provided, the default access token is used. - * @returns {Promise} A promise that resolves when the DELETE request is complete. + * @returns {Promise} A promise that resolves when the DELETE request is complete. */ invalidateAccessToken(access_token?: string): Promise { return this._delete('api.token.invalidate', { @@ -306,18 +388,18 @@ export class KiteConnect implements KiteConnectInterface { }; /** - * Renews the access token using the provided refresh token and API secret. - * - * @remarks - * This method sends a request to renew the access token using the given refresh token - * and API secret. If the renewal is successful, the promise resolves to the renewed - * access token. If the renewal fails, the promise is rejected with an error message. - * - * @param {string} refresh_token - The refresh token used for renewing the access token. - * @param {string} api_secret - The API secret required for the renewal process. - * @returns {Promise} A promise that resolves to the renewed access token if successful. - * If the renewal fails, the promise is rejected with an error message. - */ + * Renews the access token using the provided refresh token and API secret. + * + * @remarks + * This method sends a request to renew the access token using the given refresh token + * and API secret. If the renewal is successful, the promise resolves to the renewed + * access token. If the renewal fails, the promise is rejected with an error message. + * + * @param {string} refresh_token - The refresh token used for renewing the access token. + * @param {string} api_secret - The API secret required for the renewal process. + * @returns {Promise} A promise that resolves to the renewed access token if successful. + * If the renewal fails, the promise is rejected with an error message. + */ renewAccessToken(refresh_token: string, api_secret: string): Promise { return new Promise((resolve, reject) => { const checksum = sha256(this.api_key + refresh_token + api_secret).toString(); @@ -328,7 +410,7 @@ export class KiteConnect implements KiteConnectInterface { checksum: checksum }); - p.then(function (resp: any) { + p.then((resp: any) => { if (resp && resp.access_token) { this.setAccessToken(resp.access_token); } @@ -472,11 +554,11 @@ export class KiteConnect implements KiteConnectInterface { /** * Calculates margins for the specified orders. * - * @param {Order[]} orders - The array of orders for which margins are to be calculated. - * @param {*} [mode=null] - The mode for margin calculation (optional). + * @param {MarginOrder[]} orders - The array of orders for which margins are to be calculated. + * @param {string} [mode='compact'] - The mode for margin calculation (optional). * @returns {Promise} - A Promise that resolves with the calculated margins. */ - orderMargins(orders: Order[], mode = null): Promise { + orderMargins(orders: MarginOrder[], mode: string = 'compact'): Promise { return this._post('order.margins', orders, null, undefined, true, { 'mode': mode }); }; @@ -484,10 +566,10 @@ export class KiteConnect implements KiteConnectInterface { /** * Retrieves the virtual contract note for the specified orders. * - * @param {Order[]} orders - The array of orders for which to retrieve the virtual contract note. + * @param {VirtualContractParam[]} orders - The array of orders for which to retrieve the virtual contract note. * @returns {Promise} A Promise that resolves with the virtual contract note. */ - getvirtualContractNote(orders: Order[]): Promise { + getvirtualContractNote(orders: VirtualContractParam[]): Promise { return this._post('order.contract_note', orders, null, undefined, true, null); }; @@ -496,10 +578,10 @@ export class KiteConnect implements KiteConnectInterface { * * @param {Order[]} orders - The array of orders for which to retrieve margin information. * @param {boolean} [consider_positions=true] - Flag indicating whether to consider existing positions. - * @param {*} [mode=null] - The mode of operation. Default is null. + * @param {*} [mode='compact'] - The mode of operation. Default is compact. * @returns {Promise} - A Promise that resolves to margin information for the basket of orders. */ - orderBasketMargins(orders: Order[], consider_positions = true, mode = null): Promise { + orderBasketMargins(orders: Order[], consider_positions: boolean = true, mode: string = 'compact'): Promise { return this._post('order.margins.basket', orders, null, undefined, true, { 'consider_positions': consider_positions, 'mode': mode }); }; @@ -537,21 +619,21 @@ export class KiteConnect implements KiteConnectInterface { /** * Converts a position based on the provided parameters. * - * @param params - The parameters for converting the position. + * @param {ConvertPositionParams} params - The parameters for converting the position. * @returns {Promise} A Promise that resolves with the result of the conversion. - * The resolved value type depends on the implementation. + * */ - convertPosition(params: Order): Promise { + convertPosition(params: ConvertPositionParams): Promise { return this._put('portfolio.positions.convert', params); }; /** * Retrieves instruments based on the provided exchange. * - * @param {boolean} exchange - A boolean indicating whether to fetch instruments for the exchange. + * @param {Exchanges} exchange - Exchange name * @returns {Promise} - A Promise resolving to the fetched instruments. */ - getInstruments(exchange: boolean): Promise { + getInstruments(exchange: Exchanges): Promise { if (exchange) { return this._get('market.instruments', { 'exchange': exchange @@ -562,23 +644,23 @@ export class KiteConnect implements KiteConnectInterface { }; /** - * Retrieves OHLC (Open, High, Low, Close) data for the specified instruments. + * Retrieves Quote data for the specified instruments. * - * @param {(string[] | string)} instruments - An array of instrument tokens or a single instrument token as a string. + * @param {(string | string[])} instruments - An array of exchange:tradingsymbol * @returns {Promise} A promise that resolves with the quote data for the specified instruments. */ - getQuote(instruments: string[] | string): Promise { - return this._get('market.quote', { 'i': instruments }, null, formatQuoteResponse); + getQuote(instruments: string | string[]): Promise { + return this._get('market.quote', {"i": instruments}, null, formatQuoteResponse); }; /** * Retrieves OHLC (Open, High, Low, Close) data for the specified instruments. * - * @param {(string[] | string)} instruments - An array of instrument tokens or a single instrument token as a string. + * @param {(string | string[])} instruments - An array of exchange:tradingsymbol. * @returns {Promise} A promise that resolves with the OHLC data for the specified instruments. */ - getOHLC(instruments: string[] | string): Promise { - return this._get('market.quote.ohlc', { 'i': instruments }); + getOHLC(instruments: string | string[]): Promise { + return this._get('market.quote.ohlc', {"i": instruments}); }; /** @@ -587,11 +669,11 @@ export class KiteConnect implements KiteConnectInterface { * @remarks * This method fetches the last traded price (LTP) for the provided instruments. * - * @param {(string[] | string)} instruments - An array of instrument tokens or a single instrument token. + * @param {(string | string[])} instruments - An array of exchange:tradingsymbol * @returns {Promise} The last traded price (LTP) of the specified instruments as a Promise. */ - getLTP(instruments: string[] | string): Promise{ - return this._get('market.quote.ltp', { 'i': instruments }); + getLTP(instruments: string | string[]): Promise{ + return this._get('market.quote.ltp', {"i": instruments}); }; /** @@ -607,7 +689,7 @@ export class KiteConnect implements KiteConnectInterface { * volume: 22589681 * }, ....] * ~~~~ - * @param {(string | number)} instrument_token + * @param {(number | string)} instrument_token * @param {string} interval * @param {(string | Date)} from_date * @param {(string | Date)} to_date @@ -615,7 +697,7 @@ export class KiteConnect implements KiteConnectInterface { * @param {(number | boolean)} [oi=false] * @returns {Promise} */ - getHistoricalData(instrument_token: string | number, interval: string, from_date: string | Date, to_date: string | Date, continuous: number | boolean = false, oi: number | boolean = false) { + getHistoricalData(instrument_token: number | string, interval: string, from_date: string | Date, to_date: string | Date, continuous: number | boolean = false, oi: number | boolean = false) { continuous = continuous ? 1 : 0; oi = oi ? 1 : 0; if (typeof to_date === 'object') to_date = _getDateTimeString(to_date) @@ -750,7 +832,7 @@ export class KiteConnect implements KiteConnectInterface { * Get API params from user defined GTT params * * @param {PlaceGTTParams} params - * @returns {{ condition: { exchange: ExchangeTypes; tradingsymbol: string; trigger_values: {}; last_price: any; }; orders: {}; }} + * @returns {{ condition: { exchange: Exchanges; tradingsymbol: string; trigger_values: {}; last_price: any; }; orders: {}; }} */ private _getGTTPayload(params: PlaceGTTParams) { if (params.trigger_type !== GTTStatusTypes.GTT_TYPE_OCO && params.trigger_type !== GTTStatusTypes.GTT_TYPE_SINGLE) { @@ -849,7 +931,6 @@ export class KiteConnect implements KiteConnectInterface { } /** - * * * @private * @param {string} route @@ -947,7 +1028,7 @@ export class KiteConnect implements KiteConnectInterface { payload = JSON.stringify(params); } else { // post url encoded payload - payload = querystring.stringify(params); + payload = qs.stringify(params); } } @@ -976,7 +1057,6 @@ export class KiteConnect implements KiteConnectInterface { if (responseTransformer) { options.transformResponse = (axios.defaults.transformResponse as any).concat(responseTransformer); } - return this.requestInstance.request(options); } @@ -1086,7 +1166,6 @@ export class KiteConnect implements KiteConnectInterface { } /** - * * @param {AnyObject} data * @returns {AnyObject} @@ -1102,7 +1181,6 @@ function formatGenerateSession(data: AnyObject) { } /** - * * @param {AnyObject} data * @returns {AnyObject} @@ -1125,7 +1203,6 @@ function formatQuoteResponse(data: AnyObject) { // Format response ex. datetime string to date /** - * * @param {*} data * @param {AnyObject} headers diff --git a/lib/ticker.ts b/lib/ticker.ts index 18ce619..20e7cd6 100644 --- a/lib/ticker.ts +++ b/lib/ticker.ts @@ -1,5 +1,5 @@ import WebSocket from 'ws'; -import { AnyObject, KiteTickerInterface, KiteTickerParams } from '../interfaces'; +import { AnyObject, KiteTickerInterface, KiteTickerParams, Tick, LTPTick, QuoteTick, FullTick } from '../interfaces'; import utils from './utils'; @@ -142,95 +142,82 @@ const NseCM = 1, * --------------------------- * * ~~~~ - * const KiteTicker = require('kiteconnect').KiteTicker; + * import { KiteTicker } from "kiteconnect"; + * + * const apiKey = 'your_api_key'; + * const accessToken = 'generated_access_token'; + * * const ticker = new KiteTicker({ - * api_key: 'api_key', - * access_token: 'access_token' - * }); + * api_key: apiKey, + * access_token: accessToken + * }); + * * ticker.connect(); * ticker.on('ticks', onTicks); * ticker.on('connect', subscribe); - * function onTicks(ticks) { - * console.log('Ticks', ticks); + * ticker.on('disconnect', onDisconnect); + * ticker.on('error', onError); + * ticker.on('close', onClose); + * ticker.on('order_update', onTrade); + * + * function onTicks(ticks: any[]): void { + * console.log("Ticks", ticks); * } - * function subscribe() { - * const items = [738561]; - * ticker.subscribe(items); - * ticker.setMode(ticker.modeFull, items); + * + * function subscribe(): void { + * const tokens = [738561, 256265]; + * ticker.subscribe(tokens); + * ticker.setMode(ticker.modeFull, tokens); + * } + * + * function onDisconnect(error: Error): void { + * console.log("Closed connection on disconnect", error); + * } + * + * function onError(error: Error): void { + * console.log("Closed connection on error", error); + * } + * + * function onClose(reason: string): void { + * console.log("Closed connection on close", reason); + * } + * + * function onTrade(order: any): void { + * console.log("Order update", order); * } * ~~~~ * * ------------- * ~~~~ - * [{ tradable: true, - * mode: 'full', - * instrument_token: 208947, - * last_price: 3939, - * last_quantity: 1, - * average_price: 3944.77, - * volume: 28940, - * buy_quantity: 4492, - * sell_quantity: 4704, - * ohlc: { open: 3927, high: 3955, low: 3927, close: 3906 }, - * change: 0.8448540706605223, - * last_trade_time: 1515491369, - * timestamp: 1515491373, - * oi: 24355, - * oi_day_high: 0, - * oi_day_low: 0, - * depth: - * buy: [{ - * quantity: 59, - * price: 3223, - * orders: 5 - * }, - * { - * quantity: 164, - * price: 3222, - * orders: 15 - * }, - * { - * quantity: 123, - * price: 3221, - * orders: 7 - * }, - * { - * quantity: 48, - * price: 3220, - * orders: 7 - * }, - * { - * quantity: 33, - * price: 3219, - * orders: 5 - * }], - * sell: [{ - * quantity: 115, - * price: 3224, - * orders: 15 - * }, - * { - * quantity: 50, - * price: 3225, - * orders: 5 - * }, - * { - * quantity: 175, - * price: 3226, - * orders: 14 - * }, - * { - * quantity: 49, - * price: 3227, - * orders: 10 - * }, - * { - * quantity: 106, - * price: 3228, - * orders: 13 - * }] - * } - * }, ...] + * [{ + * tradable: true, + * mode: 'full', + * instrument_token: 738561, + * last_price: 2940.7, + * last_traded_quantity: 1, + * average_traded_price: 2933.55, + * volume_traded: 2827705, + * total_buy_quantity: 213779, + * total_sell_quantity: 425119, + * ohlc: { open: 2915, high: 2949, low: 2910.35, close: 2913.35 }, + * change: 0.9387818147493404, + * last_trade_time: 2024-06-12T07:16:09.000Z, + * exchange_timestamp: 2024-06-12T07:16:09.000Z, + * oi: 0, + * oi_day_high: 0, + * oi_day_low: 0, + * depth: { buy: [Array], sell: [Array] } + * }, + * { + * tradable: false, + * mode: 'full', + * instrument_token: 256265, + * last_price: 23406.85, + * ohlc: { high: 23441.95, low: 23295.95, open: 23344.45, close: 23264.85 }, + * change: 0.6103628435171514, + * exchange_timestamp: 2024-06-12T07:16:09.000Z + * } + * ] * ~~~~ * * Auto reconnection is enabled by default and it can be disabled by passing `reconnect` param while initialising `KiteTicker`. Auto reonnection mechanism is based on [Exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) algorithm in which @@ -246,34 +233,33 @@ const NseCM = 1, * Here is an example demonstrating auto reconnection. * ------------- * ~~~~ - * const KiteTicker = require('kiteconnect').KiteTicker; + * import { KiteTicker } from "kiteconnect"; + * + * const apiKey = 'your_api_key'; + * const accessToken = 'generated_access_token'; * const ticker = new KiteTicker({ - * api_key: 'api_key', - * access_token: 'access_token' - * }); - * - * // set autoreconnect with 10 maximum reconnections and 5 second interval - * ticker.autoReconnect(true, 10, 5) + * api_key: 'api_key', + * access_token: 'access_token' + * }) + * ticker.autoReconnect(true, 10, 5); * ticker.connect(); * ticker.on('ticks', onTicks); - * ticker.on('connect', subscribe); - * ticker.on('noreconnect', function() { - * console.log('noreconnect'); - * }); - * ticker.on('reconnect', function(reconnect_count, reconnect_interval) { - * console.log('Reconnecting: attempt - ', reconnect_count, ' interval - ', reconnect_interval); - * }); - * ticker.on('message', function(binary_msg){ - * console.log('Binary message', binary_msg); - * }); - * - * function onTicks(ticks) { - * console.log('Ticks', ticks); + * ticker.on('connect', subscribe); + * ticker.on('noreconnect', () => { + * console.log('noreconnect') + * }) + * ticker.on('reconnect', (reconnect_count:any, reconnect_interval:any) => { + * console.log('Reconnecting: attempt - ', reconnect_count, ' interval - ', reconnect_interval) + * }) + * + * function onTicks(ticks: any[]) { + * console.log('Ticks', ticks) * } + * * function subscribe() { - * const items = [738561]; - * ticker.subscribe(items); - * ticker.setMode(ticker.modeFull, items); + * const items = [738561] + * ticker.subscribe(items) + * ticker.setMode(ticker.modeFull, items) * } * ~~~~ * @@ -324,6 +310,7 @@ export class KiteTicker implements KiteTickerInterface { * @type {string} */ root: string; + /** * Creates an instance of KiteTicker. * @@ -435,20 +422,17 @@ export class KiteTicker implements KiteTickerInterface { if (this && this.readyState == this.OPEN) this.close(); }; - ws.onclose = function (e) { + ws.onclose = (e) => { trigger('close', [e]); // the ws id doesn't match the current global id, // meaning it's a ghost close event. just ignore. - if (current_ws_url && (this.url != current_ws_url)) return; + if (current_ws_url && (url != current_ws_url)) return; this.triggerDisconnect(e); }; } - /** - * - */ attemptReconnection() { // Try reconnecting only so many times. if (current_reconnection_count > reconnect_max_tries) { @@ -499,7 +483,6 @@ export class KiteTicker implements KiteTickerInterface { /** * - * * @param {string} e * @param {Function} callback */ @@ -507,14 +490,10 @@ export class KiteTicker implements KiteTickerInterface { if (triggers.hasOwnProperty(e)) { (triggers as AnyObject)[e].push(callback); } - }/** - * - */ - ; + }; /** * - * * @param {(string[] | number[])} tokens * @returns {{}} */ @@ -523,14 +502,10 @@ export class KiteTicker implements KiteTickerInterface { send({ 'a': mSubscribe, 'v': tokens }); } return tokens; - }/** - * - */ - ; + }; /** * - * * @param {(string[] | number[])} tokens * @returns {{}} */ @@ -539,13 +514,9 @@ export class KiteTicker implements KiteTickerInterface { send({ 'a': mUnSubscribe, 'v': tokens }); } return tokens; - }/** - * - */ - ; + }; /** - * * * @param {string} mode * @param {(string[] | number[])} tokens @@ -556,10 +527,7 @@ export class KiteTicker implements KiteTickerInterface { send({ 'a': mSetMode, 'v': [mode, tokens] }); } return tokens; - }/** - * - */ - ; + }; /** * @@ -628,7 +596,7 @@ function parseTextMessage(data: string | AnyObject) { */ function parseBinary(binpacks: ArrayBuffer) { const packets = splitPackets(binpacks), - ticks: any[] = []; + ticks: Tick[] = []; for (let n = 0; n < packets.length; n++) { const bin: any = packets[n], @@ -654,13 +622,13 @@ function parseBinary(binpacks: ArrayBuffer) { mode: modeLTP, instrument_token, last_price: buf2long(bin.slice(4, 8)) / divisor - }); + } as LTPTick); // Parse indices quote and full mode } else if (bin.byteLength === 28 || bin.byteLength === 32) { let mode = modeQuote; if (bin.byteLength === 32) mode = modeFull; - const tick: AnyObject = { + const tick: QuoteTick = { tradable, mode, instrument_token, @@ -691,7 +659,7 @@ function parseBinary(binpacks: ArrayBuffer) { let mode = modeQuote; if (bin.byteLength === 184) mode = modeFull; - const tick = { + const tick: FullTick = { tradable, mode, instrument_token, @@ -706,8 +674,10 @@ function parseBinary(binpacks: ArrayBuffer) { high: buf2long(bin.slice(32, 36)) / divisor, low: buf2long(bin.slice(36, 40)) / divisor, close: buf2long(bin.slice(40, 44)) / divisor - } - } as AnyObject; + }, + // To be computed later + change: 0 + }; // Compute the change price using close price and last price if (tick.ohlc.close != 0) { diff --git a/package-lock.json b/package-lock.json index f941b22..e271452 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "kiteconnect", + "name": "kiteconnect-ts-test", "version": "5.0.0", "lockfileVersion": 3, "requires": true, @@ -16,9 +16,8 @@ "mocha": "^10.0.0", "nock": "^13.2.4", "papaparse": "^5.3.1", - "querystring": "^0.2.1", + "qs": "^6.12.1", "rimraf": "^3.0.2", - "taffydb": "^2.7.3", "ws": "^6.2.2" }, "devDependencies": { @@ -27,11 +26,10 @@ "@types/mocha": "^10.0.1", "@types/node": "^18.11.18", "@types/papaparse": "^5.3.14", + "@types/qs": "^6.9.15", "@types/ws": "^8.5.4", "eslint": "^8.57.0", "eslint-plugin-tsdoc": "^0.2.17", - "jsdoc": "^4.0.2", - "minami": "^1.1.1", "typedoc": "^0.25.13", "typescript": "^4.9.5", "typescript-eslint": "^7.5.0" @@ -49,18 +47,6 @@ "node": ">=0.10.0" } }, - "node_modules/@babel/parser": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz", - "integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==", - "dev": true, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -194,18 +180,6 @@ "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, - "node_modules/@jsdoc/salty": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.5.tgz", - "integrity": "sha512-TfRP53RqunNe2HBobVBJ0VLhK1HbfvBYeTC1ahnN64PWvyYyGebmMiPkuwvD9fpw2ZbkoPb8Q7mwy0aR8Z9rvw==", - "dev": true, - "dependencies": { - "lodash": "^4.17.21" - }, - "engines": { - "node": ">=v12.0.0" - } - }, "node_modules/@microsoft/tsdoc": { "version": "0.15.0", "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.15.0.tgz", @@ -282,28 +256,6 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, - "node_modules/@types/linkify-it": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", - "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", - "dev": true - }, - "node_modules/@types/markdown-it": { - "version": "12.2.3", - "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", - "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", - "dev": true, - "dependencies": { - "@types/linkify-it": "*", - "@types/mdurl": "*" - } - }, - "node_modules/@types/mdurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", - "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", - "dev": true - }, "node_modules/@types/mocha": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz", @@ -325,6 +277,12 @@ "@types/node": "*" } }, + "node_modules/@types/qs": { + "version": "6.9.15", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", + "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==", + "dev": true + }, "node_modules/@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", @@ -689,12 +647,6 @@ "node": ">=8" } }, - "node_modules/bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", - "dev": true - }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -719,6 +671,24 @@ "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -739,18 +709,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/catharsis": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", - "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", - "dev": true, - "dependencies": { - "lodash": "^4.17.15" - }, - "engines": { - "node": ">= 10" - } - }, "node_modules/chai": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", @@ -927,6 +885,22 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -964,13 +938,23 @@ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, - "node_modules/entities": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", - "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", - "dev": true, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" } }, "node_modules/escalade": { @@ -981,15 +965,6 @@ "node": ">=6" } }, - "node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/eslint": { "version": "8.57.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", @@ -1343,7 +1318,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -1364,6 +1338,24 @@ "node": "*" } }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -1449,11 +1441,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/graphemer": { "version": "1.4.0", @@ -1469,11 +1466,43 @@ "node": ">=8" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, "dependencies": { "function-bind": "^1.1.2" }, @@ -1646,44 +1675,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/js2xmlparser": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz", - "integrity": "sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==", - "dev": true, - "dependencies": { - "xmlcreate": "^2.0.4" - } - }, - "node_modules/jsdoc": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.2.tgz", - "integrity": "sha512-e8cIg2z62InH7azBBi3EsSEqrKx+nUtAS5bBcYTSpZFA+vhNPyhv8PTFZ0WsjOPDj04/dOLlm08EDcQJDqaGQg==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.20.15", - "@jsdoc/salty": "^0.2.1", - "@types/markdown-it": "^12.2.3", - "bluebird": "^3.7.2", - "catharsis": "^0.9.0", - "escape-string-regexp": "^2.0.0", - "js2xmlparser": "^4.0.2", - "klaw": "^3.0.0", - "markdown-it": "^12.3.2", - "markdown-it-anchor": "^8.4.1", - "marked": "^4.0.10", - "mkdirp": "^1.0.4", - "requizzle": "^0.2.3", - "strip-json-comments": "^3.1.0", - "underscore": "~1.13.2" - }, - "bin": { - "jsdoc": "jsdoc.js" - }, - "engines": { - "node": ">=12.0.0" - } - }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -1707,15 +1698,6 @@ "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==", "dev": true }, - "node_modules/klaw": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", - "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.9" - } - }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -1729,15 +1711,6 @@ "node": ">= 0.8.0" } }, - "node_modules/linkify-it": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", - "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", - "dev": true, - "dependencies": { - "uc.micro": "^1.0.1" - } - }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -1752,12 +1725,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -1805,32 +1772,6 @@ "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", "dev": true }, - "node_modules/markdown-it": { - "version": "12.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", - "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", - "dev": true, - "dependencies": { - "argparse": "^2.0.1", - "entities": "~2.1.0", - "linkify-it": "^3.0.1", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.5" - }, - "bin": { - "markdown-it": "bin/markdown-it.js" - } - }, - "node_modules/markdown-it-anchor": { - "version": "8.6.7", - "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", - "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", - "dev": true, - "peerDependencies": { - "@types/markdown-it": "*", - "markdown-it": "*" - } - }, "node_modules/marked": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", @@ -1843,12 +1784,6 @@ "node": ">= 12" } }, - "node_modules/mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", - "dev": true - }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -1871,12 +1806,6 @@ "node": ">=8.6" } }, - "node_modules/minami": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/minami/-/minami-1.2.3.tgz", - "integrity": "sha1-mbbc37LwpU2hycj3qjoyd4eq+fg= sha512-3f2QqqbUC1usVux0FkQMFYB73yd9JIxmHSn1dWQacizL6hOUaNu6mA3KxZ9SfiCc4qgcgq+5XP59+hP7URa1Dw==", - "dev": true - }, "node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -1888,18 +1817,6 @@ "node": ">=10" } }, - "node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true, - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/mocha": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.0.0.tgz", @@ -1994,6 +1911,14 @@ "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2149,6 +2074,20 @@ "node": ">=6" } }, + "node_modules/qs": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz", + "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/querystring": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz", @@ -2205,15 +2144,6 @@ "node": ">=0.10.0" } }, - "node_modules/requizzle": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", - "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", - "dev": true, - "dependencies": { - "lodash": "^4.17.14" - } - }, "node_modules/resolve": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", @@ -2325,6 +2255,22 @@ "randombytes": "^2.1.0" } }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -2358,6 +2304,23 @@ "vscode-textmate": "^8.0.0" } }, + "node_modules/side-channel": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", + "dependencies": { + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -2557,18 +2520,6 @@ } } }, - "node_modules/uc.micro": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", - "dev": true - }, - "node_modules/underscore": { - "version": "1.13.6", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", - "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==", - "dev": true - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -2639,12 +2590,6 @@ "async-limiter": "~1.0.0" } }, - "node_modules/xmlcreate": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", - "integrity": "sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg==", - "dev": true - }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index 0bf3b50..914f4ff 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "kiteconnect-ts", - "version": "5.0.0", + "version": "0.1.0", "description": "The official typescript client for the Kite Connect trading APIs", - "main": "./dist", + "main": "./dist/lib/index.js", "types": "./types/index.d.ts", "scripts": { "generate-docs": "npx typedoc --out ./docs", @@ -11,9 +11,16 @@ "eslint:fix": "eslint", "test": "npm run build && npm run build-test && mocha --allowJs test/**/*.js && rimraf **/*.js" }, + "files": [ + "dist", + "types", + "package.json", + "README.md", + "LICENSE" + ], "repository": { "type": "git", - "url": "git+https://github.com/zerodhatech/kiteconnectjs.git" + "url": "git+https://github.com/ranjanrak/kiteconnectjs/tree/feat-ts-refactor.git" }, "keywords": [ "kiteconnect", @@ -24,14 +31,15 @@ "api", "stock", "market", + "javascript", "typescript" ], "author": "Rakesh Ranjan", "license": "MIT", "bugs": { - "url": "https://github.com/zerodhatech/kiteconnectjs/issues" + "url": "https://github.com/ranjanrak/kiteconnectjs/issues" }, - "homepage": "https://github.com/zerodhatech/kiteconnectjs#readme", + "homepage": "https://github.com/ranjanrak/kiteconnectjs/tree/feat-ts-refactor#readme", "dependencies": { "@microsoft/tsdoc": "^0.15.0", "axios": "^0.21.2", @@ -40,9 +48,8 @@ "mocha": "^10.0.0", "nock": "^13.2.4", "papaparse": "^5.3.1", - "querystring": "^0.2.1", + "qs": "^6.12.1", "rimraf": "^3.0.2", - "taffydb": "^2.7.3", "ws": "^6.2.2" }, "devDependencies": { @@ -51,6 +58,7 @@ "@types/mocha": "^10.0.1", "@types/node": "^18.11.18", "@types/papaparse": "^5.3.14", + "@types/qs": "^6.9.15", "@types/ws": "^8.5.4", "eslint": "^8.57.0", "eslint-plugin-tsdoc": "^0.2.17", diff --git a/test/test.ts b/test/test.ts index 5d15ed6..d5382dc 100644 --- a/test/test.ts +++ b/test/test.ts @@ -7,7 +7,7 @@ import * as fs from 'fs'; //@ts-ignore import { KiteConnect } from '../lib/connect'; import { AnyObject } from '../interfaces/any-object.js'; -import { ExchangeTypes, GTTStatusTypes, OrderTypes, PositionTypes, Products, TransactionTypes, Varieties } from '../interfaces'; +import { Exchanges, GTTStatusTypes, OrderTypes, PositionTypes, Products, TransactionTypes, Varieties } from '../interfaces'; const mockDir = './kiteconnect-mocks'; @@ -177,7 +177,7 @@ function testSuite(){ // orderMargins .post('/margins/orders') - .query({ mode: null }) + .query({mode: 'compact'}) .reply(200, parseJson('order_margins.json')) // getvirtualContractNote @@ -221,7 +221,7 @@ function testSuite(){ describe('placeOrder', function() { it('Place market order', (done) => { kc.placeOrder(Varieties.TEST, { - 'exchange': ExchangeTypes.NSE, + 'exchange': Exchanges.NSE, 'tradingsymbol': 'SBIN', 'transaction_type': TransactionTypes.BUY, 'quantity': 1, @@ -352,7 +352,7 @@ function testSuite(){ it('convert existing position', (done) => { kc.convertPosition ({ 'tradingsymbol': 'SBIN', - 'exchange': ExchangeTypes.NSE, + 'exchange': Exchanges.NSE, 'transaction_type': TransactionTypes.BUY, 'position_type': PositionTypes.POSITION_TYPE_DAY, 'quantity':1, @@ -558,7 +558,7 @@ function testSuite(){ kc.placeGTT({ trigger_type: GTTStatusTypes.GTT_TYPE_OCO, tradingsymbol: 'SBIN', - exchange: ExchangeTypes.NSE, + exchange: Exchanges.NSE, trigger_values: [350, 450], last_price: 400, orders: [{ @@ -621,7 +621,7 @@ function testSuite(){ kc.modifyGTT(100, { trigger_type: GTTStatusTypes.GTT_TYPE_OCO, tradingsymbol: 'SBIN', - exchange: ExchangeTypes.NSE, + exchange: Exchanges.NSE, trigger_values: [358, 458], last_price: 400, orders: [{ @@ -665,15 +665,17 @@ function testSuite(){ it('Fetch order margin detail', (done) => { kc.orderMargins([ { - 'exchange': ExchangeTypes.NSE, + 'exchange': Exchanges.NSE, 'tradingsymbol': 'SBIN', 'transaction_type': TransactionTypes.BUY, 'variety': Varieties.VARIETY_REGULAR, 'product': Products.MIS, 'order_type': OrderTypes.MARKET, - 'quantity': 1 + 'quantity': 1, + 'price': 0, + 'trigger_price':0 } - ]) + ], 'compact') .then(function(response: AnyObject) { expect(response).to.have.nested.property('[0].type'); expect(response).to.have.nested.property('[0].var'); @@ -694,7 +696,7 @@ function testSuite(){ kc.getvirtualContractNote([ { 'order_id': '111111111', - 'exchange': ExchangeTypes.NSE, + 'exchange': Exchanges.NSE, 'tradingsymbol': 'SBIN', 'transaction_type': TransactionTypes.BUY, 'variety': Varieties.VARIETY_REGULAR, diff --git a/types/connect.d.ts b/types/connect.d.ts index 5f98c0b..de52a53 100644 --- a/types/connect.d.ts +++ b/types/connect.d.ts @@ -1,4 +1,4 @@ -type Exchange = +type Exchanges = | Connect['EXCHANGE_NSE'] | Connect['EXCHANGE_BSE'] | Connect['EXCHANGE_NFO'] @@ -11,6 +11,10 @@ type TransactionType = | Connect['TRANSACTION_TYPE_BUY'] | Connect['TRANSACTION_TYPE_SELL']; +type PositionTypes = + | Connect['POSITION_TYPE_DAY'] + | Connect['POSITION_TYPE_OVERNIGHT']; + type Product = | Connect['PRODUCT_NRML'] | Connect['PRODUCT_MIS'] @@ -25,7 +29,6 @@ type OrderType = type Variety = | Connect['VARIETY_AMO'] | Connect['VARIETY_AUCTION'] - | Connect['VARIETY_BO'] | Connect['VARIETY_CO'] | Connect['VARIETY_ICEBERG'] | Connect['VARIETY_REGULAR']; @@ -302,7 +305,7 @@ type Instrument = { /** * Exchange */ - exchange: Exchange; + exchange: Exchanges; }; type UserMargin = { @@ -1067,7 +1070,7 @@ type MarginOrder = { /** * Name of the exchange(eg. NSE, BSE, NFO, CDS, MCX) */ - exchange: Exchange; + exchange: Exchanges; /** * Trading symbol of the instrument */ @@ -1102,6 +1105,134 @@ type MarginOrder = { trigger_price: number; }; +type VirtualContractParam = { + /** + * Unique order ID (It can be any random string to calculate charges for an imaginary order) + */ + order_id: number | string; + /** + * Name of the exchange(eg. NSE, BSE, NFO, CDS, MCX) + */ + exchange: Exchanges; + /** + * Trading symbol of the instrument + */ + tradingsymbol: string; + /** + * eg. BUY, SELL + */ + transaction_type: TransactionType; + /** + * Order variety (regular, amo, bo, co etc.) + */ + variety: Variety; + /** + * Margin product to use for the order + */ + product: Product; + /** + * Order type (MARKET, LIMIT etc.) + */ + order_type: OrderType; + /** + * Quantity of the order + */ + quantity: number; + /** + * Average price at which the order was executed (Note: Should be non-zero). + */ + average_price: number; +}; + +type VirtualContractResponse = { + /** + * Transaction type of the order (e.g., BUY, SELL) + */ + transaction_type: string; + /** + * Symbol of the instrument + */ + tradingsymbol: string; + /** + * Exchange on which the order was placed + */ + exchange: string; + /** + * Type of order variety (e.g., regular) + */ + variety: string; + /** + * Type of product (e.g., CNC) + */ + product: string; + /** + * Type of order placed (e.g., MARKET) + */ + order_type: string; + /** + * Quantity of the order + */ + quantity: number; + /** + * Price at which the order was placed + */ + price: number; + /** + * Details of charges incurred for the order + */ + charges: { + /** + * Transaction tax amount + */ + transaction_tax: number; + /** + * Type of transaction tax (e.g., STT) + */ + transaction_tax_type: string; + /** + * Exchange turnover charge + */ + exchange_turnover_charge: number; + /** + * SEBI turnover charge + */ + sebi_turnover_charge: number; + /** + * Brokerage charge + */ + brokerage: number; + /** + * Stamp duty charge + */ + stamp_duty: number; + /** + * GST charges + */ + gst: { + /** + * Integrated GST amount + */ + igst: number; + /** + * Central GST amount + */ + cgst: number; + /** + * State GST amount + */ + sgst: number; + /** + * Total GST amount + */ + total: number; + }; + /** + * Total charges incurred for the order + */ + total: number; + }; +} + type GTTParams = { /** * GTT type, its either self.GTT_TYPE_OCO or self.GTT_TYPE_SINGLE. @@ -1114,7 +1245,7 @@ type GTTParams = { /** * Exchange in which instrument is listed (NSE, BSE, NFO, BFO, CDS, MCX). */ - exchange: Exchange; + exchange: Exchanges; /** * List of trigger values, number of items depends on trigger type. */ @@ -1147,7 +1278,7 @@ type GTTParams = { }[]; }; -type KiteConnectParams = { +export type KiteConnectParams = { /** * API key issued to you. */ @@ -1204,7 +1335,6 @@ type Connect = { // Varieties VARIETY_REGULAR: 'regular'; - VARIETY_BO: 'bo'; VARIETY_CO: 'co'; VARIETY_AMO: 'amo'; VARIETY_ICEBERG: 'iceberg'; @@ -1276,7 +1406,7 @@ type Connect = { */ cancelOrder: ( variety: 'regular' | 'bo' | 'co' | 'amo' | 'iceberg' | 'auction', - order_id: string, + order_id: number | string, params?: { /** * Parent order id incase of multilegged orders. @@ -1293,7 +1423,7 @@ type Connect = { /** * Exchange in which instrument is listed (NSE, BSE, NFO, BFO, CDS, MCX). */ - exchange: Exchange; + exchange: Exchanges; /** * Tradingsymbol of the instrument (ex. RELIANCE, INFY). */ @@ -1305,11 +1435,11 @@ type Connect = { /** * Position type (overnight, day). */ - position_type: 'overnight' | 'day'; + position_type: PositionTypes; /** * Position quantity */ - quantity: string; + quantity: string | number; /** * Current product code (NRML, MIS, CNC). */ @@ -1324,7 +1454,7 @@ type Connect = { * Get list of order history. * @param trigger_id GTT ID */ - deleteGTT: (trigger_id: string) => Promise<{ trigger_id: number }>; + deleteGTT: (trigger_id: number | string) => Promise<{ trigger_id: number }>; /** * Exit an order @@ -1359,7 +1489,7 @@ type Connect = { * Get list of order history. * @param trigger_id GTT trigger ID */ - getGTT: (trigger_id: string) => Promise; + getGTT: (trigger_id: number | string) => Promise; /** * Get GTTs list @@ -1391,7 +1521,7 @@ type Connect = { * @param oi is a bool flag to include OI data for futures and options instruments. Defaults to false. */ getHistoricalData: ( - instrument_token: string, + instrument_token: number | string, interval: | 'minute' | 'day' @@ -1443,7 +1573,7 @@ type Connect = { * * @param exchange Filter instruments based on exchange (NSE, BSE, NFO, BFO, CDS, MCX). If no `segment` is specified, all instruments are returned. */ - getInstruments: (exchange?: Exchange[]) => Promise; + getInstruments: (exchange?: Exchanges) => Promise; /** * Get the remote login url to which a user should be redirected to initiate the login flow. @@ -1455,7 +1585,7 @@ type Connect = { * @param instruments is a list of instruments, Instrument are in the format of `exchange:tradingsymbol`. * For example NSE:INFY and for list of instruments ['NSE:RELIANCE', 'NSE:SBIN', ..] */ - getLTP: (instruments: string[]) => Promise< + getLTP: (instruments: string | string[]) => Promise< Record< string, { @@ -1509,7 +1639,7 @@ type Connect = { * @param instruments is a list of instruments, Instrument are in the format of `exchange:tradingsymbol`. * For example NSE:INFY and for list of instruments ['NSE:RELIANCE', 'NSE:SBIN', ..] */ - getOHLC: (instruments: string[]) => Promise< + getOHLC: (instruments: string | string[]) => Promise< Record< string, { @@ -1547,7 +1677,7 @@ type Connect = { * Get list of order history. * @param order_id ID of the order whose order details to be retrieved. */ - getOrderHistory: (order_id: string) => Promise; + getOrderHistory: (order_id: number | string) => Promise; /** * Get list of orders. @@ -1560,7 +1690,7 @@ type Connect = { * These trades are individually recorded under an order. * @param order_id ID of the order whose trades are to be retrieved. */ - getOrderTrades: (order_id: string) => Promise; + getOrderTrades: (order_id: number | string) => Promise; /** * Retrieve positions. @@ -1627,7 +1757,7 @@ type Connect = { * @param instruments is a list of instruments, Instrument are in the format of `exchange:tradingsymbol`. * For example NSE:INFY and for list of instruments ['NSE:RELIANCE', 'NSE:SBIN', ..] */ - getQuote: (instruments: string[]) => Promise< + getQuote: (instruments: string | string[]) => Promise< Record< string, { @@ -1760,7 +1890,7 @@ type Connect = { * @param transaction_type Transaction type (BUY or SELL). */ getTriggerRange: ( - exchange: Exchange, + exchange: Exchanges, tradingsymbol: string, transaction_type: TransactionType ) => Promise; @@ -1784,7 +1914,7 @@ type Connect = { * @param params Modify params */ modifyGTT: ( - trigger_id: string, + trigger_id: number | string, params: GTTParams ) => Promise<{ trigger_id: number }>; @@ -1824,7 +1954,7 @@ type Connect = { */ modifyOrder: ( variety: Variety, - order_id: string, + order_id: number | string, params: { /** * Order quantity @@ -1866,7 +1996,7 @@ type Connect = { orderBasketMargins: ( orders: MarginOrder[], consider_positions?: boolean, - mode?: 'compact' + mode?: string ) => Promise<{ initial: Margin; final: Margin; @@ -1875,10 +2005,18 @@ type Connect = { /** * Fetch required margin for order/list of orders - * @param orders Margin fetch orders. + * @param MarginOrder Margin fetch orders. * @param mode (optional) Compact mode will only give the total margins */ - orderMargins: (orders: MarginOrder[], mode?: 'compact') => Promise; + orderMargins: (orders: MarginOrder[], mode?:string) => Promise; + + /** + * Retrieves the virtual contract note for the specified orders. + * + * @param {Order[]} VirtualContractParam - The array of orders for which to retrieve the virtual contract note. + * @returns {Promise} A Promise that resolves with the virtual contract note. + */ + getvirtualContractNote: (orders: VirtualContractParam[]) => Promise; /** * Place GTT. @@ -1960,7 +2098,7 @@ type Connect = { /** * Exchange in which instrument is listed (NSE, BSE, NFO, BFO, CDS, MCX). */ - exchange: Exchange; + exchange: Exchanges; /** * Tradingsymbol of the instrument (ex. RELIANCE, INFY). */ @@ -2091,47 +2229,47 @@ type KiteConnect = { * ------------------------ * ~~~~ * - * var KiteConnect = require('kiteconnect').KiteConnect; - * - * var kc = new KiteConnect({api_key: 'your_api_key'}); - * - * kc.generateSession('request_token', 'api_secret') - * .then(function(response) { - * init(); - * }) - * .catch(function(err) { - * console.log(err); - * }) - * - * function init() { - * // Fetch equity margins. - * // You can have other api calls here. - * - * kc.getMargins() - * .then(function(response) { - * // You got user's margin details. - * }).catch(function(err) { - * // Something went wrong. - * }); - * } - * ~~~~ - * - * API promises - * ------------- - * All API calls returns a promise which you can use to call methods like `.then(...)` and `.catch(...)`. - * - * ~~~~ - * kiteConnectApiCall - * .then(function(v) { - * // On success - * }) - * .catch(function(e) { - * // On rejected - * }); + * import { KiteConnect } from 'kiteconnect'; + * + * const apiKey = 'your_api_key' + * const apiSecret = 'your_api_secret' + * const requestToken = 'your_request_token' + * + * const kc = new KiteConnect({ api_key: apiKey }) + * + * async function init() { + * try { + * await generateSession() + * await getProfile() + * } catch (err) { + * console.error(err) + * } + * } + * + * async function generateSession() { + * try { + * const response = await kc.generateSession(requestToken, apiSecret) + * kc.setAccessToken(response.access_token) + * console.log('Session generated:', response) + * } catch (err) { + * console.error('Error generating session:', err) + * } + * } + * + * async function getProfile() { + * try { + * const profile = await kc.getProfile() + * console.log('Profile:', profile) + * } catch (err) { + * console.error('Error getting profile:', err) + * } + * } + * // Initialize the API calls + * init(); * ~~~~ * * @example Initialize KiteConnect object - * var kc = KiteConnect('my_api_key', {timeout: 10, debug: false}) + * const kc = new KiteConnect({ api_key: apiKey })}) */ new (params: KiteConnectParams): Connect; }; diff --git a/types/ticker.d.ts b/types/ticker.d.ts index 293e1f9..045cad1 100644 --- a/types/ticker.d.ts +++ b/types/ticker.d.ts @@ -1,275 +1,253 @@ type KiteTickerParams = { - /** - * API key issued you. - */ - api_key: string; - /** - * Access token obtained after successful login flow. - */ - access_token: string; - /** - * Enable/Disable auto reconnect. Enabled by default. - */ - reconnect?: boolean; - /** - * is maximum number re-connection attempts. Defaults to 50 attempts and maximum up to 300 attempts. - */ - max_retry?: number; - /** - * in seconds is the maximum delay after which subsequent re-connection interval will become constant. Defaults to 60s and minimum acceptable value is 5s. - */ - max_delay?: number; - }; + /** + * API key issued you. + */ + api_key: string; + /** + * Access token obtained after successful login flow. + */ + access_token: string; + /** + * Enable/Disable auto reconnect. Enabled by default. + */ + reconnect?: boolean; + /** + * is maximum number re-connection attempts. Defaults to 50 attempts and maximum up to 300 attempts. + */ + max_retry?: number; + /** + * in seconds is the maximum delay after which subsequent re-connection interval will become constant. Defaults to 60s and minimum acceptable value is 5s. + */ + max_delay?: number; +}; - type Ticker = { - /** - * Set mode full - */ - modeFull: 'full'; - /** - * this.modeLTP - */ - modeLTP: 'ltp'; - /** - * this.modeQuote - */ - modeQuote: 'quote'; +export type Ticker = { + /** + * Set mode full + */ + modeFull: 'full'; + /** + * this.modeLTP + */ + modeLTP: 'ltp'; + /** + * this.modeQuote + */ + modeQuote: 'quote'; + + /** + * Auto reconnect settings + * @param Enable or disable auto disconnect, defaults to false + * @param max_retry is maximum number re-connection attempts. Defaults to 50 attempts and maximum up to 300 attempts. + * @param max_delay in seconds is the maximum delay after which subsequent re-connection interval will become constant. Defaults to 60s and minimum acceptable value is 5s. + * @returns + */ + autoReconnect: ( + Enable: boolean, + max_retry?: number, + max_delay?: number + ) => void; + /** + * Initiate a websocket connection + */ + connect: () => void; + /** + * Check if the ticker is connected + */ + connected: () => boolean; + /** + * Check if the ticker is connected + */ + disconnect: () => boolean; + /** + * Register websocket event callbacks + * Available events + * ~~~~ + * connect - when connection is successfully established. + * ticks - when ticks are available (Arrays of `ticks` object as the first argument). + * disconnect - when socket connection is disconnected. Error is received as a first param. + * error - when socket connection is closed with error. Error is received as a first param. + * close - when socket connection is closed cleanly. + * reconnect - When reconnecting (current re-connection count and reconnect interval as arguments respectively). + * noreconnect - When re-connection fails after n number times. + * order_update - When order update (postback) is received for the connected user (Data object is received as first argument). + * message - when binary message is received from the server. + * ~~~~ + * + * @example + * ticker.on('ticks', callback); + * ticker.on('connect', callback); + * ticker.on('disconnect', callback); + */ + on: ( + event: + | 'connect' + | 'ticks' + | 'disconnect' + | 'error' + | 'close' + | 'reconnect' + | 'noreconnect' + | 'order_update', + callback: Function + ) => void; + /** + * Set modes to array of tokens + * @param mode mode to set + * @param tokens Array of tokens to be subscribed + * + * @example + * ticker.setMode(ticker.modeFull, [738561]); + */ + setMode: (mode: 'ltp' | 'quote' | 'full', tokens: number[]) => number[]; + /** + * Subscribe to array of tokens + * @param tokens Array of tokens to be subscribed + * + * @example + * ticker.subscribe([738561]); + */ + subscribe: (tokens: number[]) => number[]; + /** + * Unsubscribe to array of tokens + * @param tokens Array of tokens to be unsubscribed + * + * @example + * ticker.unsubscribe([738561]); + */ + unsubscribe: (tokens: number[]) => number[]; +}; - /** - * Auto reconnect settings - * @param Enable or disable auto disconnect, defaults to false - * @param max_retry is maximum number re-connection attempts. Defaults to 50 attempts and maximum up to 300 attempts. - * @param max_delay in seconds is the maximum delay after which subsequent re-connection interval will become constant. Defaults to 60s and minimum acceptable value is 5s. - * @returns - */ - autoReconnect: ( - Enable: boolean, - max_retry?: number, - max_delay?: number - ) => void; - /** - * Initiate a websocket connection - */ - connect: () => void; - /** - * Check if the ticker is connected - */ - connected: () => boolean; - /** - * Check if the ticker is connected - */ - disconnect: () => boolean; - /** - * Register websocket event callbacks - * Available events - * ~~~~ - * connect - when connection is successfully established. - * ticks - when ticks are available (Arrays of `ticks` object as the first argument). - * disconnect - when socket connection is disconnected. Error is received as a first param. - * error - when socket connection is closed with error. Error is received as a first param. - * close - when socket connection is closed cleanly. - * reconnect - When reconnecting (current re-connection count and reconnect interval as arguments respectively). - * noreconnect - When re-connection fails after n number times. - * order_update - When order update (postback) is received for the connected user (Data object is received as first argument). - * message - when binary message is received from the server. - * ~~~~ - * - * @example - * ticker.on('ticks', callback); - * ticker.on('connect', callback); - * ticker.on('disconnect', callback); - */ - on: ( - event: - | 'connect' - | 'ticks' - | 'disconnect' - | 'error' - | 'close' - | 'reconnect' - | 'noreconnect' - | 'order_update', - callback: Function - ) => void; - /** - * Set modes to array of tokens - * @param mode mode to set - * @param tokens Array of tokens to be subscribed - * - * @example - * ticker.setMode(ticker.modeFull, [738561]); - */ - setMode: (mode: 'ltp' | 'quote' | 'full', tokens: number[]) => number[]; - /** - * Subscribe to array of tokens - * @param tokens Array of tokens to be subscribed - * - * @example - * ticker.subscribe([738561]); - */ - subscribe: (tokens: number[]) => number[]; - /** - * Unsubscribe to array of tokens - * @param tokens Array of tokens to be unsubscribed - * - * @example - * ticker.unsubscribe([738561]); - */ - unsubscribe: (tokens: number[]) => number[]; - }; +export type KiteTicker = { + /** + * The WebSocket client for connecting to Kite connect streaming quotes service. + * + * Getting started: + * --------------- + * + * import { KiteTicker } from "kiteconnect"; + * + * const apiKey = 'your_api_key'; + * const accessToken = 'generated_access_token'; + * + * const ticker = new KiteTicker({ + * api_key: apiKey, + * access_token: accessToken + * }); + * + * ticker.connect(); + * ticker.on('ticks', onTicks); + * ticker.on('connect', subscribe); + * ticker.on('disconnect', onDisconnect); + * ticker.on('error', onError); + * ticker.on('close', onClose);` + * ticker.on('order_update', onTrade); + * + * function onTicks(ticks: any[]): void { + * console.log("Ticks", ticks); + * } + * + * function subscribe(): void { + * const tokens = [738561, 256265]; + * ticker.subscribe(tokens); + * ticker.setMode(ticker.modeFull, tokens); + * } + * + * function onDisconnect(error: Error): void { + * console.log("Closed connection on disconnect", error); + * } + * + * function onError(error: Error): void { + * console.log("Closed connection on error", error); + * } + * + * function onClose(reason: string): void { + * console.log("Closed connection on close", reason); + * } + * + * function onTrade(order: any): void { + * console.log("Order update", order); + * } + * + * Tick structure (passed to the tick callback you assign): + * --------------------------- + * [{ + * tradable: true, + * mode: 'full', + * instrument_token: 738561, + * last_price: 2940.7, + * last_traded_quantity: 1, + * average_traded_price: 2933.55, + * volume_traded: 2827705, + * total_buy_quantity: 213779, + * total_sell_quantity: 425119, + * ohlc: { open: 2915, high: 2949, low: 2910.35, close: 2913.35 }, + * change: 0.9387818147493404, + * last_trade_time: 2024-06-12T07:16:09.000Z, + * exchange_timestamp: 2024-06-12T07:16:09.000Z, + * oi: 0, + * oi_day_high: 0, + * oi_day_low: 0, + * depth: { buy: [Array], sell: [Array] } + * }, + * { + * tradable: false, + * mode: 'full', + * instrument_token: 256265, + * last_price: 23406.85, + * ohlc: { high: 23441.95, low: 23295.95, open: 23344.45, close: 23264.85 }, + * change: 0.6103628435171514, + * exchange_timestamp: 2024-06-12T07:16:09.000Z + * } + * ] + * + * Auto reconnection + * ----------------- + * Auto reonnection is enabled by default and it can be disabled by passing `reconnect` param while initialising `KiteTicker`. + * + * Auto reonnection mechanism is based on [Exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) algorithm in which + * next retry interval will be increased exponentially. `max_delay` and `max_tries` params can be used to tweak + * the alogrithm where `max_delay` is the maximum delay after which subsequent reconnection interval will become constant and + * `max_tries` is maximum number of retries before it quits reconnection. + * For example if `max_delay` is 60 seconds and `max_tries` is 50 then the first reconnection interval starts from + * minimum interval which is 2 seconds and keep increasing up to 60 seconds after which it becomes constant and when reconnection attempt + * is reached upto 50 then it stops reconnecting. + * Callback `reconnect` will be called with current reconnect attempt and next reconnect interval and + * `on_noreconnect` is called when reconnection attempts reaches max retries. + * + * Here is an example demonstrating auto reconnection. + * + * import { KiteTicker } from "kiteconnect"; + * + * const apiKey = 'your_api_key'; + * const accessToken = 'generated_access_token'; + * const ticker = new KiteTicker({ + * api_key: 'api_key', + * access_token: 'access_token' + * }) + * ticker.autoReconnect(true, 10, 5); + * ticker.connect(); + * ticker.on('ticks', onTicks); + * ticker.on('connect', subscribe); + * ticker.on('noreconnect', () => { + * console.log('noreconnect') + * }) + * ticker.on('reconnect', (reconnect_count:any, reconnect_interval:any) => { + * console.log('Reconnecting: attempt - ', reconnect_count, ' interval - ', reconnect_interval) + * }) + * + * function onTicks(ticks: any[]) { + * console.log('Ticks', ticks) + * } + * + * function subscribe() { + * const items = [738561] + * ticker.subscribe(items) + * ticker.setMode(ticker.modeFull, items) + * } + */ + new (params: KiteTickerParams): Ticker; +}; - type KiteTicker = { - /** - * The WebSocket client for connecting to Kite connect streaming quotes service. - * - * Getting started: - * --------------- - * - * import { KiteTicker } from 'kiteconnect'; - * const ticker = new KiteTicker({ - * api_key: 'api_key', - * access_token: 'access_token' - * }); - * - * ticker.connect(); - * ticker.on('ticks', onTicks); - * ticker.on('connect', subscribe); - * - * function onTicks(ticks) { - * console.log('Ticks', ticks); - * } - * - * function subscribe() { - * const items = [738561]; - * ticker.subscribe(items); - * ticker.setMode(ticker.modeFull, items); - * } - * - * Tick structure (passed to the tick callback you assign): - * --------------------------- - * [{ tradable: true, - * mode: 'full', - * instrument_token: 208947, - * last_price: 3939, - * last_quantity: 1, - * average_price: 3944.77, - * volume: 28940, - * buy_quantity: 4492, - * sell_quantity: 4704, - * ohlc: { open: 3927, high: 3955, low: 3927, close: 3906 }, - * change: 0.8448540706605223, - * last_trade_time: 1515491369, - * timestamp: 1515491373, - * oi: 24355, - * oi_day_high: 0, - * oi_day_low: 0, - * depth: - * buy: [{ - * quantity: 59, - * price: 3223, - * orders: 5 - * }, - * { - * quantity: 164, - * price: 3222, - * orders: 15 - * }, - * { - * quantity: 123, - * price: 3221, - * orders: 7 - * }, - * { - * quantity: 48, - * price: 3220, - * orders: 7 - * }, - * { - * quantity: 33, - * price: 3219, - * orders: 5 - * }], - * sell: [{ - * quantity: 115, - * price: 3224, - * orders: 15 - * }, - * { - * quantity: 50, - * price: 3225, - * orders: 5 - * }, - * { - * quantity: 175, - * price: 3226, - * orders: 14 - * }, - * { - * quantity: 49, - * price: 3227, - * orders: 10 - * }, - * { - * quantity: 106, - * price: 3228, - * orders: 13 - * }] - * } - * }, ...] - * - * Auto reconnection - * ----------------- - * Auto reonnection is enabled by default and it can be disabled by passing `reconnect` param while initialising `KiteTicker`. - * - * Auto reonnection mechanism is based on [Exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) algorithm in which - * next retry interval will be increased exponentially. `max_delay` and `max_tries` params can be used to tweak - * the alogrithm where `max_delay` is the maximum delay after which subsequent reconnection interval will become constant and - * `max_tries` is maximum number of retries before it quits reconnection. - * For example if `max_delay` is 60 seconds and `max_tries` is 50 then the first reconnection interval starts from - * minimum interval which is 2 seconds and keep increasing up to 60 seconds after which it becomes constant and when reconnection attempt - * is reached upto 50 then it stops reconnecting. - * Callback `reconnect` will be called with current reconnect attempt and next reconnect interval and - * `on_noreconnect` is called when reconnection attempts reaches max retries. - * - * Here is an example demonstrating auto reconnection. - * - * import { KiteTicker } from 'kiteconnect'; - * const ticker = new KiteTicker({ - * api_key: 'api_key', - * access_token: 'access_token' - * }); - * - * // set autoreconnect with 10 maximum reconnections and 5 second interval - * ticker.autoReconnect(true, 10, 5) - * ticker.connect(); - * ticker.on('ticks', onTicks); - * ticker.on('connect', subscribe); - * - * ticker.on('noreconnect', function() { - * console.log('noreconnect'); - * }); - * - * ticker.on('reconnect', function(reconnect_count, reconnect_interval) { - * console.log('Reconnecting: attempt - ', reconnect_count, ' interval - ', reconnect_interval); - * }); - * - * ticker.on('message', function(binary_msg){ - * console.log('Binary message', binary_msg); - * }); - * - * function onTicks(ticks) { - * console.log('Ticks', ticks); - * } - * - * function subscribe() { - * const items = [738561]; - * ticker.subscribe(items); - * ticker.setMode(ticker.modeFull, items); - * } - * - */ - new (params: KiteTickerParams): Ticker; - }; - - declare const KiteTicker: KiteTicker; - export default KiteTicker; \ No newline at end of file +declare const KiteTicker: KiteTicker; +export default KiteTicker; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 2050361..5cb62f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,11 +7,6 @@ resolved "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz" integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== -"@babel/parser@^7.20.15": - version "7.21.4" - resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz" - integrity sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw== - "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz" @@ -63,13 +58,6 @@ resolved "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz" integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== -"@jsdoc/salty@^0.2.1": - version "0.2.5" - resolved "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.5.tgz" - integrity sha512-TfRP53RqunNe2HBobVBJ0VLhK1HbfvBYeTC1ahnN64PWvyYyGebmMiPkuwvD9fpw2ZbkoPb8Q7mwy0aR8Z9rvw== - dependencies: - lodash "^4.17.21" - "@microsoft/tsdoc-config@0.16.2": version "0.16.2" resolved "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.16.2.tgz" @@ -126,24 +114,6 @@ resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== -"@types/linkify-it@*": - version "3.0.2" - resolved "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz" - integrity sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA== - -"@types/markdown-it@*", "@types/markdown-it@^12.2.3": - version "12.2.3" - resolved "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz" - integrity sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ== - dependencies: - "@types/linkify-it" "*" - "@types/mdurl" "*" - -"@types/mdurl@*": - version "1.0.2" - resolved "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz" - integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA== - "@types/mocha@^10.0.1": version "10.0.1" resolved "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz" @@ -161,6 +131,11 @@ dependencies: "@types/node" "*" +"@types/qs@^6.9.15": + version "6.9.15" + resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz" + integrity sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg== + "@types/semver@^7.5.0": version "7.5.8" resolved "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz" @@ -356,11 +331,6 @@ binary-extensions@^2.0.0: resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -bluebird@^3.7.2: - version "3.7.2" - resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" - integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" @@ -388,6 +358,17 @@ browser-stdout@1.3.1: resolved "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + callsites@^3.0.0: version "3.1.0" resolved "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz" @@ -398,13 +379,6 @@ camelcase@^6.0.0: resolved "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -catharsis@^0.9.0: - version "0.9.0" - resolved "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz" - integrity sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A== - dependencies: - lodash "^4.17.15" - chai@^4.3.6: version "4.3.6" resolved "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz" @@ -510,6 +484,15 @@ deep-is@^0.1.3: resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + diff@5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz" @@ -534,21 +517,23 @@ emoji-regex@^8.0.0: resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -entities@~2.1.0: - version "2.1.0" - resolved "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz" - integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== escalade@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== -escape-string-regexp@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz" - integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== - escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" @@ -755,6 +740,17 @@ get-func-name@^2.0.0: resolved "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz" integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== +get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" @@ -800,10 +796,12 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" -graceful-fs@^4.1.9: - version "4.2.11" - resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz" - integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" graphemer@^1.4.0: version "1.4.0" @@ -815,6 +813,23 @@ has-flag@^4.0.0: resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.0.1: + version "1.0.3" + resolved "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz" + integrity sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + hasown@^2.0.0: version "2.0.2" resolved "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz" @@ -926,34 +941,6 @@ js-yaml@^4.1.0, js-yaml@4.1.0: dependencies: argparse "^2.0.1" -js2xmlparser@^4.0.2: - version "4.0.2" - resolved "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz" - integrity sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA== - dependencies: - xmlcreate "^2.0.4" - -jsdoc@^4.0.2: - version "4.0.2" - resolved "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.2.tgz" - integrity sha512-e8cIg2z62InH7azBBi3EsSEqrKx+nUtAS5bBcYTSpZFA+vhNPyhv8PTFZ0WsjOPDj04/dOLlm08EDcQJDqaGQg== - dependencies: - "@babel/parser" "^7.20.15" - "@jsdoc/salty" "^0.2.1" - "@types/markdown-it" "^12.2.3" - bluebird "^3.7.2" - catharsis "^0.9.0" - escape-string-regexp "^2.0.0" - js2xmlparser "^4.0.2" - klaw "^3.0.0" - markdown-it "^12.3.2" - markdown-it-anchor "^8.4.1" - marked "^4.0.10" - mkdirp "^1.0.4" - requizzle "^0.2.3" - strip-json-comments "^3.1.0" - underscore "~1.13.2" - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" @@ -974,13 +961,6 @@ jsonc-parser@^3.2.0: resolved "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz" integrity sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA== -klaw@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz" - integrity sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g== - dependencies: - graceful-fs "^4.1.9" - levn@^0.4.1: version "0.4.1" resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz" @@ -989,13 +969,6 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -linkify-it@^3.0.1: - version "3.0.3" - resolved "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz" - integrity sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ== - dependencies: - uc.micro "^1.0.1" - locate-path@^6.0.0: version "6.0.0" resolved "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz" @@ -1008,11 +981,6 @@ lodash.merge@^4.6.2: resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - log-symbols@4.1.0: version "4.1.0" resolved "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz" @@ -1040,32 +1008,11 @@ lunr@^2.3.9: resolved "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz" integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow== -markdown-it-anchor@^8.4.1: - version "8.6.7" - resolved "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz" - integrity sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA== - -markdown-it@*, markdown-it@^12.3.2: - version "12.3.2" - resolved "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz" - integrity sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg== - dependencies: - argparse "^2.0.1" - entities "~2.1.0" - linkify-it "^3.0.1" - mdurl "^1.0.1" - uc.micro "^1.0.5" - -marked@^4.0.10, marked@^4.3.0: +marked@^4.3.0: version "4.3.0" resolved "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz" integrity sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A== -mdurl@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz" - integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== - merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz" @@ -1079,11 +1026,6 @@ micromatch@^4.0.4: braces "^3.0.2" picomatch "^2.3.1" -minami@^1.1.1: - version "1.2.3" - resolved "https://registry.npmjs.org/minami/-/minami-1.2.3.tgz" - integrity sha1-mbbc37LwpU2hycj3qjoyd4eq+fg= sha512-3f2QqqbUC1usVux0FkQMFYB73yd9JIxmHSn1dWQacizL6hOUaNu6mA3KxZ9SfiCc4qgcgq+5XP59+hP7URa1Dw== - minimatch@^3.0.4: version "3.1.2" resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" @@ -1126,11 +1068,6 @@ minimatch@9.0.3: dependencies: brace-expansion "^2.0.1" -mkdirp@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" - integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== - mocha@^10.0.0: version "10.0.0" resolved "https://registry.npmjs.org/mocha/-/mocha-10.0.0.tgz" @@ -1193,6 +1130,11 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== +object-inspect@^1.13.1: + version "1.13.1" + resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz" + integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== + once@^1.3.0: version "1.4.0" resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz" @@ -1288,6 +1230,13 @@ punycode@^2.1.0: resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== +qs@^6.12.1: + version "6.12.1" + resolved "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz" + integrity sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ== + dependencies: + side-channel "^1.0.6" + querystring@^0.2.1: version "0.2.1" resolved "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz" @@ -1317,13 +1266,6 @@ require-directory@^2.1.1: resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== -requizzle@^0.2.3: - version "0.2.3" - resolved "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz" - integrity sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ== - dependencies: - lodash "^4.17.14" - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz" @@ -1375,6 +1317,18 @@ serialize-javascript@6.0.0: dependencies: randombytes "^2.1.0" +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" @@ -1397,6 +1351,16 @@ shiki@^0.14.7: vscode-oniguruma "^1.7.0" vscode-textmate "^8.0.0" +side-channel@^1.0.6: + version "1.0.6" + resolved "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + slash@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz" @@ -1418,7 +1382,7 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1, strip-json-comments@3.1.1: +strip-json-comments@^3.1.1, strip-json-comments@3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -1500,16 +1464,6 @@ typescript@^4.9.5, typescript@>=4.2.0, "typescript@4.6.x || 4.7.x || 4.8.x || 4. resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== -uc.micro@^1.0.1, uc.micro@^1.0.5: - version "1.0.6" - resolved "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz" - integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== - -underscore@~1.13.2: - version "1.13.6" - resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz" - integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A== - uri-js@^4.2.2: version "4.4.1" resolved "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz" @@ -1560,11 +1514,6 @@ ws@^6.2.2: dependencies: async-limiter "~1.0.0" -xmlcreate@^2.0.4: - version "2.0.4" - resolved "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz" - integrity sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg== - y18n@^5.0.5: version "5.0.8" resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz"