heyreach-cli 0.1.2 → 0.1.4
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.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +16 -1
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -64,7 +64,9 @@ var init_config = __esm({
|
|
|
64
64
|
// src/core/errors.ts
|
|
65
65
|
function classifyHttpError(status, body) {
|
|
66
66
|
const parsed = safeParse(body);
|
|
67
|
-
const
|
|
67
|
+
const rawVal = parsed?.message || parsed?.error || body || `HTTP ${status} error`;
|
|
68
|
+
const raw = typeof rawVal === "string" ? rawVal : JSON.stringify(rawVal);
|
|
69
|
+
const message = extractMessage(raw);
|
|
68
70
|
if (status === 401 || status === 403) return new AuthError(message);
|
|
69
71
|
if (status === 404) return new NotFoundError(message);
|
|
70
72
|
if (status === 422) return new ValidationError(message);
|
|
@@ -72,6 +74,19 @@ function classifyHttpError(status, body) {
|
|
|
72
74
|
if (status >= 500) return new ServerError(message);
|
|
73
75
|
return new HeyReachError(message, "HTTP_ERROR", status);
|
|
74
76
|
}
|
|
77
|
+
function extractMessage(raw) {
|
|
78
|
+
const nested = safeParse(raw);
|
|
79
|
+
if (nested?.errors && typeof nested.errors === "object") {
|
|
80
|
+
const parts = [];
|
|
81
|
+
for (const [field, msgs] of Object.entries(nested.errors)) {
|
|
82
|
+
const msgList = Array.isArray(msgs) ? msgs.join("; ") : String(msgs);
|
|
83
|
+
parts.push(`${field}: ${msgList}`);
|
|
84
|
+
}
|
|
85
|
+
if (parts.length > 0) return parts.join(". ");
|
|
86
|
+
}
|
|
87
|
+
if (nested?.errorMessage) return String(nested.errorMessage);
|
|
88
|
+
return raw;
|
|
89
|
+
}
|
|
75
90
|
function safeParse(text) {
|
|
76
91
|
try {
|
|
77
92
|
return JSON.parse(text);
|
|
@@ -2632,7 +2647,7 @@ import { Command } from "commander";
|
|
|
2632
2647
|
var program = new Command();
|
|
2633
2648
|
program.name("heyreach").description(
|
|
2634
2649
|
"HeyReach CLI \u2014 manage LinkedIn campaigns, leads, lists, inbox, webhooks, and more from your terminal."
|
|
2635
|
-
).version("0.1.
|
|
2650
|
+
).version("0.1.4").option("--pretty", "Pretty-print JSON output").option("--quiet", "Suppress output, exit codes only").option("--fields <fields>", "Comma-separated fields to include in output").option("--api-key <key>", "HeyReach workspace API key").option("--org-key <key>", "HeyReach Organization API key");
|
|
2636
2651
|
registerAllCommands(program);
|
|
2637
2652
|
program.parse();
|
|
2638
2653
|
//# sourceMappingURL=index.js.map
|