v4.0.0-beta.9: fix() batch order ws api handling

This commit is contained in:
tiagosiebler
2025-03-03 10:45:28 +00:00
parent d638cf174a
commit f45018da88
4 changed files with 40 additions and 24 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "4.0.0-beta.8", "version": "4.0.0-beta.9",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "bybit-api", "name": "bybit-api",
"version": "4.0.0-beta.8", "version": "4.0.0-beta.9",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.7.9", "axios": "^1.7.9",

View File

@@ -1,6 +1,6 @@
{ {
"name": "bybit-api", "name": "bybit-api",
"version": "4.0.0-beta.8", "version": "4.0.0-beta.9",
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -78,16 +78,18 @@ export interface BatchCreateOrderResultV5 {
createAt: string; createAt: string;
} }
export interface BatchOrdersRetExtInfoV5 {
list: {
code: number;
msg: string;
}[];
}
export interface BatchOrdersResponseV5<T extends unknown[]> { export interface BatchOrdersResponseV5<T extends unknown[]> {
result: { result: {
list: T; list: T;
}; };
retExtInfo: { retExtInfo: BatchOrdersRetExtInfoV5;
list: {
code: number;
msg: string;
}[];
};
} }
export interface BatchAmendOrderResultV5 { export interface BatchAmendOrderResultV5 {

View File

@@ -12,10 +12,12 @@ import {
BatchCancelOrderResultV5, BatchCancelOrderResultV5,
BatchCreateOrderResultV5, BatchCreateOrderResultV5,
BatchOrdersResponseV5, BatchOrdersResponseV5,
BatchOrdersRetExtInfoV5,
OrderResultV5, OrderResultV5,
} from '../response'; } from '../response';
import { WsKey } from './ws-general'; import { WsKey } from './ws-general';
// When new WS API operations are added, make sure to also update WS_API_Operations[] below
export type WSAPIOperation = export type WSAPIOperation =
| 'order.create' | 'order.create'
| 'order.amend' | 'order.amend'
@@ -24,6 +26,15 @@ export type WSAPIOperation =
| 'order.amend-batch' | 'order.amend-batch'
| 'order.cancel-batch'; | 'order.cancel-batch';
export const WS_API_Operations: WSAPIOperation[] = [
'order.create',
'order.amend',
'order.cancel',
'order.create-batch',
'order.amend-batch',
'order.cancel-batch',
];
export type WsOperation = export type WsOperation =
| 'subscribe' | 'subscribe'
| 'unsubscribe' | 'unsubscribe'
@@ -31,12 +42,6 @@ export type WsOperation =
| 'ping' | 'ping'
| 'pong'; | 'pong';
export const WS_API_Operations: WSAPIOperation[] = [
'order.create',
'order.amend',
'order.cancel',
];
export interface WsRequestOperationBybit<TWSTopic extends string> { export interface WsRequestOperationBybit<TWSTopic extends string> {
req_id: string; req_id: string;
op: WsOperation; op: WsOperation;
@@ -100,17 +105,18 @@ export interface WsAPITopicRequestParamMap {
'order.create': OrderParamsV5; 'order.create': OrderParamsV5;
'order.amend': AmendOrderParamsV5; 'order.amend': AmendOrderParamsV5;
'order.cancel': CancelOrderParamsV5; 'order.cancel': CancelOrderParamsV5;
'order.create-batch': { 'order.create-batch': {
category: 'option' | 'linear'; category: 'option' | 'linear';
orders: BatchOrderParamsV5[]; request: BatchOrderParamsV5[];
}; };
'order.amend-batch': { 'order.amend-batch': {
category: 'option' | 'linear'; category: 'option' | 'linear';
orders: BatchAmendOrderParamsV5[]; request: BatchAmendOrderParamsV5[];
}; };
'order.cancel-batch': { 'order.cancel-batch': {
category: 'option' | 'linear'; category: 'option' | 'linear';
orders: BatchCancelOrderParamsV5[]; request: BatchCancelOrderParamsV5[];
}; };
} }
@@ -121,18 +127,26 @@ export interface WsAPIOperationResponseMap {
'order.create': WSAPIResponse<OrderResultV5, 'order.create'>; 'order.create': WSAPIResponse<OrderResultV5, 'order.create'>;
'order.amend': WSAPIResponse<OrderResultV5, 'order.amend'>; 'order.amend': WSAPIResponse<OrderResultV5, 'order.amend'>;
'order.cancel': WSAPIResponse<OrderResultV5, 'order.cancel'>; 'order.cancel': WSAPIResponse<OrderResultV5, 'order.cancel'>;
'order.create-batch': WSAPIResponse< 'order.create-batch': WSAPIResponse<
BatchOrdersResponseV5<BatchCreateOrderResultV5[]>, { list: BatchCreateOrderResultV5[] },
'order.create-batch' 'order.create-batch'
>; > & {
retExtInfo: BatchOrdersRetExtInfoV5;
};
'order.amend-batch': WSAPIResponse< 'order.amend-batch': WSAPIResponse<
BatchOrdersResponseV5<BatchAmendOrderResultV5[]>, { list: BatchAmendOrderResultV5[] },
'order.amend-batch' 'order.amend-batch'
>; > & {
retExtInfo: BatchOrdersRetExtInfoV5;
};
'order.cancel-batch': WSAPIResponse< 'order.cancel-batch': WSAPIResponse<
BatchOrdersResponseV5<BatchCancelOrderResultV5[]>, { list: BatchCancelOrderResultV5[] },
'order.cancel-batch' 'order.cancel-batch'
>; > & {
retExtInfo: BatchOrdersRetExtInfoV5;
};
ping: { ping: {
retCode: 0 | number; retCode: 0 | number;
retMsg: 'OK' | string; retMsg: 'OK' | string;