@onebullex-group/cli 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,13 +34,17 @@ var HttpClient = class {
34
34
  cfg;
35
35
  fetch;
36
36
  async getPublic(path, query) {
37
- return this.withRetry(() => this.send("GET", path, query, void 0, false));
37
+ return this.withRetry(
38
+ () => this.send("GET", path, query, void 0, false, false)
39
+ );
38
40
  }
39
- async getPrivate(path, query) {
40
- return this.withRetry(() => this.send("GET", path, query, void 0, true));
41
+ async getPrivate(path, query, opts) {
42
+ return this.withRetry(
43
+ () => this.send("GET", path, query, void 0, true, opts?.raw ?? false)
44
+ );
41
45
  }
42
46
  async postPrivate(path, body) {
43
- return this.send("POST", path, void 0, body, true);
47
+ return this.send("POST", path, void 0, body, true, false);
44
48
  }
45
49
  /**
46
50
  * GET 请求重试包装:网络错误最多重试 2 次(共 3 次尝试),延迟 300ms / 900ms。
@@ -61,7 +65,7 @@ var HttpClient = class {
61
65
  }
62
66
  throw lastErr;
63
67
  }
64
- async send(method, path, query, body, requireAuth) {
68
+ async send(method, path, query, body, requireAuth, raw) {
65
69
  const headers = {
66
70
  "Content-Type": "application/json",
67
71
  Accept: "application/json",
@@ -124,6 +128,9 @@ var HttpClient = class {
124
128
  if (this.cfg.debug) {
125
129
  console.error("[debug response]", JSON.stringify(redactObject(json)));
126
130
  }
131
+ if (raw) {
132
+ return json;
133
+ }
127
134
  const returnCode = json.code ?? json.returnCode;
128
135
  const msgInfo = json.msg ?? json.msgInfo ?? "";
129
136
  if (returnCode !== 0 && returnCode !== "0") {
@@ -332,6 +332,14 @@ var REGISTRY = [
332
332
  needsAuth: true,
333
333
  implFile: "src/commands/position/confs.ts"
334
334
  },
335
+ {
336
+ command: "position history",
337
+ method: "GET",
338
+ path: "/v2/position/history/detail",
339
+ isWrite: false,
340
+ needsAuth: true,
341
+ implFile: "src/commands/position/history.ts"
342
+ },
335
343
  // ───── Phase 2: write operations ─────
336
344
  {
337
345
  command: "order create",
@@ -16,7 +16,9 @@ declare class HttpClient {
16
16
  private readonly fetch;
17
17
  constructor(cfg: ResolvedConfig, fetchFn?: FetchFn);
18
18
  getPublic<T>(path: string, query?: Query): Promise<T>;
19
- getPrivate<T>(path: string, query?: Query): Promise<T>;
19
+ getPrivate<T>(path: string, query?: Query, opts?: {
20
+ raw?: boolean;
21
+ }): Promise<T>;
20
22
  postPrivate<T>(path: string, body?: Record<string, unknown>): Promise<T>;
21
23
  /**
22
24
  * GET 请求重试包装:网络错误最多重试 2 次(共 3 次尝试),延迟 300ms / 900ms。
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  HttpClient,
4
4
  flattenForSign
5
- } from "../chunk-CVOY2SOS.js";
5
+ } from "../chunk-NKWXNVLA.js";
6
6
  import "../chunk-JRUFIHU7.js";
7
7
  import "../chunk-OOLZIYXS.js";
8
8
  import "../chunk-ZYO5P4DH.js";
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-AKGCHJPQ.js";
14
14
  import {
15
15
  HttpClient
16
- } from "./chunk-CVOY2SOS.js";
16
+ } from "./chunk-NKWXNVLA.js";
17
17
  import {
18
18
  ConfigError,
19
19
  DryRunInterception,
@@ -922,6 +922,28 @@ function registerPositionConfs(parent, ctx) {
922
922
  });
923
923
  }
924
924
 
925
+ // src/commands/position/history.ts
926
+ function registerPositionHistory(parent, ctx) {
927
+ parent.command("history").description("Get historical position detail (GET /v2/position/history/detail)").requiredOption("--symbol <symbol>", "trading pair").requiredOption("--position-id <id>", "position id").action(async (opts) => {
928
+ const c = ctx.http({ requireAuth: true });
929
+ const data = await c.getPrivate(
930
+ "/v2/position/history/detail",
931
+ {
932
+ symbol: opts.symbol,
933
+ positionId: opts.positionId
934
+ },
935
+ { raw: true }
936
+ );
937
+ const { render: render2, effectiveFormat: effectiveFormat2 } = await import("./output-UIZGG7EU.js");
938
+ ctx.stdout(
939
+ render2(data, {
940
+ format: effectiveFormat2(ctx.outputFormat, ctx.isTTY),
941
+ isTTY: ctx.isTTY
942
+ })
943
+ );
944
+ });
945
+ }
946
+
925
947
  // src/commands/config/init.ts
926
948
  import * as readline from "readline/promises";
927
949
  var TEST_BASE_URL = "https://futures-openapi.1bullex.com";
@@ -1490,7 +1512,7 @@ function buildProgram(opts) {
1490
1512
  return new HttpClient(cfg, opts?.fetch);
1491
1513
  }
1492
1514
  };
1493
- const program = new Command("onebullex").version(true ? "1.2.0" : "0.0.0-dev").description("OneBullEx exchange CLI").option("-p, --profile <name>", "config profile to use").option("-o, --output <format>", "output format: table | json").option("--debug", "enable debug logging").option("--timeout <ms>", "request timeout in milliseconds", parseInt).option("--confirm", "confirm write operations (required for non-dry-run writes)").option("--base-url <url>", "override base URL").option("--api-key <key>", "override api key (env: ONEBULLEX_API_KEY)").option("--secret <s>", "override secret (env: ONEBULLEX_SECRET; CLI flag discouraged for security)").exitOverride();
1515
+ const program = new Command("onebullex").version(true ? "1.3.1" : "0.0.0-dev").description("OneBullEx exchange CLI").option("-p, --profile <name>", "config profile to use").option("-o, --output <format>", "output format: table | json").option("--debug", "enable debug logging").option("--timeout <ms>", "request timeout in milliseconds", parseInt).option("--confirm", "confirm write operations (required for non-dry-run writes)").option("--base-url <url>", "override base URL").option("--api-key <key>", "override api key (env: ONEBULLEX_API_KEY)").option("--secret <s>", "override secret (env: ONEBULLEX_SECRET; CLI flag discouraged for security)").exitOverride();
1494
1516
  program.hook("preAction", (thisCommand, _actionCommand) => {
1495
1517
  const flags = thisCommand.opts();
1496
1518
  if (flags.output === "table" || flags.output === "json") {
@@ -1580,6 +1602,7 @@ function buildProgram(opts) {
1580
1602
  const position = program.command("position").description("Positions");
1581
1603
  registerPositionList(position, ctx);
1582
1604
  registerPositionConfs(position, ctx);
1605
+ registerPositionHistory(position, ctx);
1583
1606
  registerPositionAdjustLeverage(position, ctx);
1584
1607
  registerPositionMargin(position, ctx);
1585
1608
  registerPositionAutoMargin(position, ctx);
package/dist/lint-api.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  REGISTRY
4
- } from "./chunk-YX4634ML.js";
4
+ } from "./chunk-PEVZEMJG.js";
5
5
 
6
6
  // scripts/check-cli-coverage.ts
7
7
  import { readFileSync } from "fs";
package/dist/registry.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  REGISTRY
4
- } from "./chunk-YX4634ML.js";
4
+ } from "./chunk-PEVZEMJG.js";
5
5
  export {
6
6
  REGISTRY
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onebullex-group/cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "OneBullEx Open API V2 command-line interface",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,16 +26,6 @@
26
26
  "engines": {
27
27
  "node": ">=18"
28
28
  },
29
- "scripts": {
30
- "build": "tsup",
31
- "dev": "tsx src/index.ts",
32
- "test": "vitest run",
33
- "test:e2e": "vitest run tests/e2e",
34
- "lint": "biome lint src tests",
35
- "format": "biome format --write src tests",
36
- "check-coverage": "tsx scripts/check-cli-coverage.ts",
37
- "typecheck": "tsc --noEmit"
38
- },
39
29
  "dependencies": {
40
30
  "cli-table3": "^0.6.5",
41
31
  "commander": "^12.1.0",
@@ -50,5 +40,15 @@
50
40
  "typescript": "^5.5.0",
51
41
  "undici": "^8.3.0",
52
42
  "vitest": "^2.1.0"
43
+ },
44
+ "scripts": {
45
+ "build": "tsup",
46
+ "dev": "tsx src/index.ts",
47
+ "test": "vitest run",
48
+ "test:e2e": "vitest run tests/e2e",
49
+ "lint": "biome lint src tests",
50
+ "format": "biome format --write src tests",
51
+ "check-coverage": "tsx scripts/check-cli-coverage.ts",
52
+ "typecheck": "tsc --noEmit"
53
53
  }
54
- }
54
+ }