@onebullex-group/cli 1.3.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(
|
|
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(
|
|
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") {
|
|
@@ -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
|
|
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。
|
package/dist/core/http-client.js
CHANGED
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-
|
|
16
|
+
} from "./chunk-NKWXNVLA.js";
|
|
17
17
|
import {
|
|
18
18
|
ConfigError,
|
|
19
19
|
DryRunInterception,
|
|
@@ -926,10 +926,14 @@ function registerPositionConfs(parent, ctx) {
|
|
|
926
926
|
function registerPositionHistory(parent, ctx) {
|
|
927
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
928
|
const c = ctx.http({ requireAuth: true });
|
|
929
|
-
const data = await c.getPrivate(
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
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
|
+
);
|
|
933
937
|
const { render: render2, effectiveFormat: effectiveFormat2 } = await import("./output-UIZGG7EU.js");
|
|
934
938
|
ctx.stdout(
|
|
935
939
|
render2(data, {
|
|
@@ -1508,7 +1512,7 @@ function buildProgram(opts) {
|
|
|
1508
1512
|
return new HttpClient(cfg, opts?.fetch);
|
|
1509
1513
|
}
|
|
1510
1514
|
};
|
|
1511
|
-
const program = new Command("onebullex").version(true ? "1.3.
|
|
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();
|
|
1512
1516
|
program.hook("preAction", (thisCommand, _actionCommand) => {
|
|
1513
1517
|
const flags = thisCommand.opts();
|
|
1514
1518
|
if (flags.output === "table" || flags.output === "json") {
|