@medievalrain/binance-ts 0.5.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,51 @@
1
1
  import z$1, { z } from "zod";
2
2
  import { Client, WebSocket } from "undici";
3
3
  import * as z4 from "zod/v4/core";
4
+ import { CallbackOptions } from "@medievalrain/emitter";
4
5
 
6
+ //#region src/shared/base-rest-client.d.ts
7
+ type RawSearchParams = Record<string, string | undefined | null | string[] | number | boolean>;
8
+ declare class BaseRestClient {
9
+ private httpCleint;
10
+ private apiKey?;
11
+ private apiSecret?;
12
+ constructor({
13
+ baseUrl,
14
+ apiKey,
15
+ apiSecret,
16
+ httpOptions
17
+ }: {
18
+ baseUrl: string;
19
+ apiKey?: string;
20
+ apiSecret?: string;
21
+ httpOptions?: Client.Options;
22
+ });
23
+ private toSearchParams;
24
+ private parseErrorResponse;
25
+ private parseResponse;
26
+ protected publicRequest<T extends z4.$ZodType>({
27
+ endpoint,
28
+ params,
29
+ schema
30
+ }: {
31
+ endpoint: string;
32
+ params?: RawSearchParams;
33
+ schema: T;
34
+ }): Promise<z4.output<T>>;
35
+ protected privateRequest<T extends z4.$ZodType>({
36
+ endpoint,
37
+ params,
38
+ schema,
39
+ method
40
+ }: {
41
+ endpoint: string;
42
+ params?: RawSearchParams;
43
+ method: "GET" | "POST" | "DELETE";
44
+ schema: T;
45
+ }): Promise<z4.output<T>>;
46
+ private sign;
47
+ }
48
+ //#endregion
5
49
  //#region src/rest/futures/schema.d.ts
6
50
  declare const FuturesTestConnectivitySchema: z.ZodObject<{}, z.core.$strip>;
7
51
  declare const FuturesCheckServerTimeSchema: z.ZodObject<{
@@ -784,49 +828,6 @@ declare const FuturesNewOrderSchema: z.ZodObject<{
784
828
  goodTillDate: z.ZodOptional<z.ZodNumber>;
785
829
  }, z.core.$strip>;
786
830
  //#endregion
787
- //#region src/shared/base-rest-client.d.ts
788
- type RawSearchParams = Record<string, string | undefined | null | string[] | number | boolean>;
789
- declare class BaseRestClient {
790
- private httpCleint;
791
- private apiKey?;
792
- private apiSecret?;
793
- constructor({
794
- baseUrl,
795
- apiKey,
796
- apiSecret,
797
- httpOptions
798
- }: {
799
- baseUrl: string;
800
- apiKey?: string;
801
- apiSecret?: string;
802
- httpOptions?: Client.Options;
803
- });
804
- private toSearchParams;
805
- private parseErrorResponse;
806
- private parseResponse;
807
- protected publicRequest<T extends z4.$ZodType>({
808
- endpoint,
809
- params,
810
- schema
811
- }: {
812
- endpoint: string;
813
- params?: RawSearchParams;
814
- schema: T;
815
- }): Promise<z4.output<T>>;
816
- protected privateRequest<T extends z4.$ZodType>({
817
- endpoint,
818
- params,
819
- schema,
820
- method
821
- }: {
822
- endpoint: string;
823
- params?: RawSearchParams;
824
- method: "GET" | "POST" | "DELETE";
825
- schema: T;
826
- }): Promise<z4.output<T>>;
827
- private sign;
828
- }
829
- //#endregion
830
831
  //#region src/rest/futures/types.d.ts
831
832
  type FuturesKlineInterval = "1s" | "1m" | "3m" | "5m" | "30m" | "1h" | "2h" | "6h" | "8h" | "12h" | "3d" | "1M";
832
833
  type FuturesContractType = z$1.infer<typeof FuturesContractTypeSchema>;
@@ -1317,7 +1318,7 @@ declare class FuturesRestClient extends BaseRestClient {
1317
1318
  }>;
1318
1319
  incomeHistory(params?: {
1319
1320
  symbol?: string;
1320
- incomeType?: z$1.infer<typeof FuturesIncomeTypeSchema>;
1321
+ incomeType?: FuturesIncomeType;
1321
1322
  startTime?: number;
1322
1323
  endTime?: number;
1323
1324
  page?: number;
@@ -1491,7 +1492,8 @@ type OptArgs<CM extends ChannelsMap, K extends keyof CM> = CM[K]["subscriptionOp
1491
1492
  type WebsocketClient<CM extends ChannelsMap> = { [K in keyof CM]: {
1492
1493
  subscribe: (symbols: string[], ...args: OptArgs<CM, K>) => Promise<void>;
1493
1494
  unsubscribe: (symbols: string[], ...args: OptArgs<CM, K>) => Promise<void>;
1494
- addEventListener: (cb: (data: CM[K]["messageSchema"]) => void, options?: AddEventListenerOptions) => void;
1495
+ on: (cb: (data: CM[K]["messageSchema"]) => void, options?: CallbackOptions) => void;
1496
+ off: (cb: (data: CM[K]["messageSchema"]) => void) => void;
1495
1497
  } };
1496
1498
  //#endregion
1497
1499
  //#region src/websocket/futures/types.d.ts
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import z$1, { z } from "zod";
2
2
  import { Client, WebSocket } from "undici";
3
3
  import * as z4 from "zod/v4/core";
4
4
  import { createHmac } from "node:crypto";
5
+ import { createEmitter } from "@medievalrain/emitter";
5
6
 
6
7
  //#region src/rest/futures/schema.ts
7
8
  const FuturesTestConnectivitySchema = z.object({});
@@ -1035,23 +1036,6 @@ var BinanceRestClient = class {
1035
1036
  }
1036
1037
  };
1037
1038
 
1038
- //#endregion
1039
- //#region src/websocket/base/typed-event-emitter.ts
1040
- const createEmitter = () => {
1041
- const eventTarget = new EventTarget();
1042
- const addEventListener = (event, callback, options) => {
1043
- eventTarget.addEventListener(event, (event$1) => callback(...event$1.detail), options);
1044
- };
1045
- const emit = (event, ...data) => {
1046
- eventTarget.dispatchEvent(new CustomEvent(event, { detail: data }));
1047
- };
1048
- return {
1049
- addEventListener,
1050
- removeEventListener,
1051
- emit
1052
- };
1053
- };
1054
-
1055
1039
  //#endregion
1056
1040
  //#region src/websocket/base/client.ts
1057
1041
  const makeSection = (baseUrl) => {
@@ -1124,7 +1108,7 @@ const makeSection = (baseUrl) => {
1124
1108
  return resolve();
1125
1109
  }
1126
1110
  };
1127
- emitter.addEventListener("connectionMessage", handleSubscription, { signal: controller.signal });
1111
+ emitter.on("connectionMessage", handleSubscription, { signal: controller.signal });
1128
1112
  });
1129
1113
  if (delayed.length) return subscribe(delayed);
1130
1114
  };
@@ -1160,18 +1144,22 @@ const makeSection = (baseUrl) => {
1160
1144
  return resolve();
1161
1145
  }
1162
1146
  };
1163
- emitter.addEventListener("connectionMessage", handleSubscription, { signal: controller.signal });
1147
+ emitter.on("connectionMessage", handleSubscription, { signal: controller.signal });
1164
1148
  });
1165
1149
  if (delayed.length) return unsubscribe(delayed);
1166
1150
  };
1167
- const addMarketEventListener = (callback, options) => {
1168
- emitter.addEventListener("marketMessage", callback, options);
1151
+ const onMarketEvent = (callback, options) => {
1152
+ emitter.on("marketMessage", callback, options);
1153
+ };
1154
+ const offMarketEvent = (callback, options) => {
1155
+ emitter.on("marketMessage", callback, options);
1169
1156
  };
1170
1157
  return {
1171
1158
  socket,
1172
1159
  subscriptions,
1173
1160
  connectionId,
1174
- addEventListener: addMarketEventListener,
1161
+ on: onMarketEvent,
1162
+ off: offMarketEvent,
1175
1163
  subscribe,
1176
1164
  unsubscribe
1177
1165
  };
@@ -1195,7 +1183,8 @@ const createWebsocketClient = (baseUrl, symbolConverter$1) => {
1195
1183
  unsubscribe: (symbols, ...args) => {
1196
1184
  return section.unsubscribe(symbols.map((s) => converter(s, ...args)));
1197
1185
  },
1198
- addEventListener: section.addEventListener
1186
+ on: section.on,
1187
+ off: section.off
1199
1188
  });
1200
1189
  } });
1201
1190
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medievalrain/binance-ts",
3
- "version": "0.5.4",
3
+ "version": "0.7.0",
4
4
  "description": "Binance API SDK",
5
5
  "access": "public",
6
6
  "type": "module",
@@ -21,19 +21,20 @@
21
21
  "test": "vitest"
22
22
  },
23
23
  "devDependencies": {
24
+ "@types/node": "24.5.2",
24
25
  "date-fns": "4.1.0",
25
26
  "dotenv": "17.2.2",
26
- "oxlint": "1.15.0",
27
+ "oxlint": "1.17.0",
27
28
  "prettier": "3.6.2",
28
- "tsdown": "0.15.1",
29
+ "tsdown": "0.15.4",
29
30
  "typescript": "5.9.2",
30
- "vitest": "4.0.0-beta.11",
31
- "@types/node": "24.4.0"
31
+ "vitest": "4.0.0-beta.11"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "zod": "^4"
35
35
  },
36
36
  "dependencies": {
37
+ "@medievalrain/emitter": "0.2.16",
37
38
  "undici": "7.16.0"
38
39
  },
39
40
  "repository": {
@@ -43,5 +44,5 @@
43
44
  "engines": {
44
45
  "node": ">=22.19.0"
45
46
  },
46
- "packageManager": "pnpm@10.16.1"
47
+ "packageManager": "pnpm@10.17.1"
47
48
  }