@nuelink/nuelink-cli 1.3.9 → 1.4.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/package.json +1 -1
- package/src/http.js +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuelink/nuelink-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "The official Nuelink CLI for automating social media workflows from your terminal. Schedule posts, upload media, manage brands, and integrate Nuelink into scripts, CI/CD pipelines, and AI agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nuelink",
|
package/src/http.js
CHANGED
|
@@ -5,7 +5,7 @@ import { printApiResponse } from "./output.js";
|
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
6
|
const { version: cliVersion } = require("../package.json");
|
|
7
7
|
|
|
8
|
-
const API_BASE_URL = process.env.NUELINK_BASE_URL || "https://nuelink.com/api/public/v1";
|
|
8
|
+
const API_BASE_URL = process.env.NUELINK_BASE_URL || "https://app.nuelink.com/api/public/v1";
|
|
9
9
|
const REQUEST_TIMEOUT_MS = Number(process.env.NUELINK_TIMEOUT_MS || 30000);
|
|
10
10
|
const MAX_GET_RETRIES = Number(process.env.NUELINK_GET_RETRIES || 2);
|
|
11
11
|
const RETRY_BASE_DELAY_MS = Number(process.env.NUELINK_RETRY_BASE_MS || 500);
|
|
@@ -37,24 +37,24 @@ function shouldRetryRequest(method, statusCode, attempt) {
|
|
|
37
37
|
return method === "GET" && attempt < MAX_GET_RETRIES && (statusCode === 429 || statusCode >= 500);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function parseRetryAfterMs(headers, attempt) {
|
|
40
|
+
function parseRetryAfterMs(headers, attempt) {
|
|
41
41
|
const retryAfter = headers.get("retry-after");
|
|
42
42
|
|
|
43
43
|
if (retryAfter) {
|
|
44
44
|
const seconds = Number(retryAfter);
|
|
45
45
|
|
|
46
46
|
if (!Number.isNaN(seconds)) {
|
|
47
|
-
return Math.max(seconds * 1000, 0);
|
|
47
|
+
return Math.max(seconds * 1000, 0);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const dateDelay = Date.parse(retryAfter) - Date.now();
|
|
51
51
|
if (!Number.isNaN(dateDelay)) {
|
|
52
|
-
return Math.max(dateDelay, 0);
|
|
52
|
+
return Math.max(dateDelay, 0);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const exponentialDelay = Math.min(RETRY_BASE_DELAY_MS * (2 ** attempt), RETRY_MAX_DELAY_MS);
|
|
57
|
-
return Math.floor(Math.random() * (exponentialDelay + 1));
|
|
56
|
+
const exponentialDelay = Math.min(RETRY_BASE_DELAY_MS * (2 ** attempt), RETRY_MAX_DELAY_MS);
|
|
57
|
+
return Math.floor(Math.random() * (exponentialDelay + 1));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async function sleep(ms) {
|
|
@@ -138,11 +138,11 @@ async function nuelinkRequest({ apiKey, method = "GET", endpoint, query, body, m
|
|
|
138
138
|
if (text) {
|
|
139
139
|
try {
|
|
140
140
|
data = JSON.parse(text);
|
|
141
|
-
} catch {
|
|
142
|
-
if (response.ok) {
|
|
143
|
-
throw new Error(`Protocol error: expected a JSON response (HTTP ${response.status}).`);
|
|
144
|
-
}
|
|
145
|
-
data = { raw: text };
|
|
141
|
+
} catch {
|
|
142
|
+
if (response.ok) {
|
|
143
|
+
throw new Error(`Protocol error: expected a JSON response (HTTP ${response.status}).`);
|
|
144
|
+
}
|
|
145
|
+
data = { raw: text };
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|