heyreach-cli 0.1.1 → 0.1.2

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/mcp.js CHANGED
@@ -39,7 +39,7 @@ var init_config = __esm({
39
39
  // src/core/errors.ts
40
40
  function classifyHttpError(status, body) {
41
41
  const parsed = safeParse(body);
42
- const message = parsed?.message ?? parsed?.error ?? body;
42
+ const message = parsed?.message || parsed?.error || body || `HTTP ${status} error`;
43
43
  if (status === 401 || status === 403) return new AuthError(message);
44
44
  if (status === 404) return new NotFoundError(message);
45
45
  if (status === 422) return new ValidationError(message);
@@ -220,7 +220,9 @@ function createClient(auth) {
220
220
  return { request, paginate };
221
221
  }
222
222
  function buildUrl(baseUrl, path2, query) {
223
- const url = new URL(path2, baseUrl.endsWith("/") ? baseUrl : baseUrl + "/");
223
+ const base = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
224
+ const cleanPath = path2.startsWith("/") ? path2.slice(1) : path2;
225
+ const url = new URL(cleanPath, base);
224
226
  if (query) {
225
227
  for (const [key, value] of Object.entries(query)) {
226
228
  if (value !== void 0 && value !== null) {
@@ -556,6 +558,7 @@ var init_get_for_lead = __esm({
556
558
  "use strict";
557
559
  init_esm_shims();
558
560
  init_handler();
561
+ init_errors();
559
562
  campaignsGetForLeadCommand = {
560
563
  name: "campaigns_get_for_lead",
561
564
  group: "campaigns",
@@ -583,7 +586,12 @@ var init_get_for_lead = __esm({
583
586
  },
584
587
  endpoint: { method: "POST", path: "/campaign/GetCampaignsForLead" },
585
588
  fieldMappings: { offset: "body", limit: "body", email: "body", linkedinId: "body", profileUrl: "body" },
586
- handler: (input, client) => executeCommand(campaignsGetForLeadCommand, input, client)
589
+ handler: (input, client) => {
590
+ if (!input.email && !input.linkedinId && !input.profileUrl) {
591
+ throw new ValidationError("At least one of --email, --linkedin-id, or --profile-url is required.");
592
+ }
593
+ return executeCommand(campaignsGetForLeadCommand, input, client);
594
+ }
587
595
  };
588
596
  }
589
597
  });
@@ -1182,6 +1190,7 @@ var init_get_for_lead2 = __esm({
1182
1190
  "use strict";
1183
1191
  init_esm_shims();
1184
1192
  init_handler();
1193
+ init_errors();
1185
1194
  listsGetForLeadCommand = {
1186
1195
  name: "lists_get_for_lead",
1187
1196
  group: "lists",
@@ -1206,7 +1215,12 @@ var init_get_for_lead2 = __esm({
1206
1215
  },
1207
1216
  endpoint: { method: "POST", path: "/list/GetListsForLead" },
1208
1217
  fieldMappings: { offset: "body", limit: "body", email: "body", linkedinId: "body", profileUrl: "body" },
1209
- handler: (input, client) => executeCommand(listsGetForLeadCommand, input, client)
1218
+ handler: (input, client) => {
1219
+ if (!input.email && !input.linkedinId && !input.profileUrl) {
1220
+ throw new ValidationError("At least one of --email, --linkedin-id, or --profile-url is required.");
1221
+ }
1222
+ return executeCommand(listsGetForLeadCommand, input, client);
1223
+ }
1210
1224
  };
1211
1225
  }
1212
1226
  });
@@ -1257,8 +1271,8 @@ var init_overview = __esm({
1257
1271
  'heyreach stats overview --start-date 2025-01-01 --end-date 2025-01-31 --campaign-ids "1,2,3"'
1258
1272
  ],
1259
1273
  inputSchema: z24.object({
1260
- startDate: z24.string().describe("Start date (ISO 8601)"),
1261
- endDate: z24.string().describe("End date (ISO 8601)"),
1274
+ startDate: z24.string().optional().describe("Start date (ISO 8601). Defaults to 30 days ago."),
1275
+ endDate: z24.string().optional().describe("End date (ISO 8601). Defaults to today."),
1262
1276
  accountIds: z24.string().optional().describe("Comma-separated LinkedIn account IDs (empty = all)"),
1263
1277
  campaignIds: z24.string().optional().describe("Comma-separated campaign IDs (empty = all)")
1264
1278
  }),
@@ -1273,12 +1287,14 @@ var init_overview = __esm({
1273
1287
  endpoint: { method: "POST", path: "/stats/GetOverallStats" },
1274
1288
  fieldMappings: {},
1275
1289
  handler: async (input, client) => {
1290
+ const now = /* @__PURE__ */ new Date();
1291
+ const thirtyDaysAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3);
1276
1292
  const body = {
1277
- startDate: input.startDate,
1278
- endDate: input.endDate
1293
+ startDate: input.startDate ?? thirtyDaysAgo.toISOString(),
1294
+ endDate: input.endDate ?? now.toISOString(),
1295
+ accountIds: input.accountIds ? input.accountIds.split(",").map((s) => Number(s.trim())) : [],
1296
+ campaignIds: input.campaignIds ? input.campaignIds.split(",").map((s) => Number(s.trim())) : []
1279
1297
  };
1280
- if (input.accountIds) body.accountIds = input.accountIds.split(",").map((s) => Number(s.trim()));
1281
- if (input.campaignIds) body.campaignIds = input.campaignIds.split(",").map((s) => Number(s.trim()));
1282
1298
  return client.request({ method: "POST", path: "/stats/GetOverallStats", body });
1283
1299
  }
1284
1300
  };