heyreach-cli 0.1.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/dist/mcp.js ADDED
@@ -0,0 +1,2359 @@
1
+ #!/usr/bin/env node
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __esm = (fn, res) => function __init() {
4
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
5
+ };
6
+
7
+ // node_modules/tsup/assets/esm_shims.js
8
+ import path from "path";
9
+ import { fileURLToPath } from "url";
10
+ var init_esm_shims = __esm({
11
+ "node_modules/tsup/assets/esm_shims.js"() {
12
+ "use strict";
13
+ }
14
+ });
15
+
16
+ // src/core/config.ts
17
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
18
+ import { homedir } from "os";
19
+ import { join } from "path";
20
+ function loadConfig() {
21
+ try {
22
+ if (!existsSync(CONFIG_FILE)) return {};
23
+ const raw = readFileSync(CONFIG_FILE, "utf-8");
24
+ return JSON.parse(raw);
25
+ } catch {
26
+ return {};
27
+ }
28
+ }
29
+ var CONFIG_DIR, CONFIG_FILE;
30
+ var init_config = __esm({
31
+ "src/core/config.ts"() {
32
+ "use strict";
33
+ init_esm_shims();
34
+ CONFIG_DIR = join(homedir(), ".heyreach");
35
+ CONFIG_FILE = join(CONFIG_DIR, "config.json");
36
+ }
37
+ });
38
+
39
+ // src/core/errors.ts
40
+ function classifyHttpError(status, body) {
41
+ const parsed = safeParse(body);
42
+ const message = parsed?.message ?? parsed?.error ?? body;
43
+ if (status === 401 || status === 403) return new AuthError(message);
44
+ if (status === 404) return new NotFoundError(message);
45
+ if (status === 422) return new ValidationError(message);
46
+ if (status === 429) return new RateLimitError(message);
47
+ if (status >= 500) return new ServerError(message);
48
+ return new HeyReachError(message, "HTTP_ERROR", status);
49
+ }
50
+ function safeParse(text) {
51
+ try {
52
+ return JSON.parse(text);
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+ function formatError(error) {
58
+ if (error instanceof HeyReachError) {
59
+ return { error: error.message, code: error.code };
60
+ }
61
+ if (error instanceof Error) {
62
+ return { error: error.message, code: "UNKNOWN_ERROR" };
63
+ }
64
+ return { error: String(error), code: "UNKNOWN_ERROR" };
65
+ }
66
+ var HeyReachError, AuthError, NotFoundError, ValidationError, RateLimitError, ServerError;
67
+ var init_errors = __esm({
68
+ "src/core/errors.ts"() {
69
+ "use strict";
70
+ init_esm_shims();
71
+ HeyReachError = class extends Error {
72
+ code;
73
+ statusCode;
74
+ constructor(message, code, statusCode) {
75
+ super(message);
76
+ this.name = "HeyReachError";
77
+ this.code = code;
78
+ this.statusCode = statusCode;
79
+ }
80
+ };
81
+ AuthError = class extends HeyReachError {
82
+ constructor(message = 'Authentication failed. Run "heyreach login" or set HEYREACH_API_KEY.') {
83
+ super(message, "AUTH_ERROR", 401);
84
+ this.name = "AuthError";
85
+ }
86
+ };
87
+ NotFoundError = class extends HeyReachError {
88
+ constructor(message = "Resource not found.") {
89
+ super(message, "NOT_FOUND", 404);
90
+ this.name = "NotFoundError";
91
+ }
92
+ };
93
+ ValidationError = class extends HeyReachError {
94
+ constructor(message = "Validation failed.") {
95
+ super(message, "VALIDATION_ERROR", 422);
96
+ this.name = "ValidationError";
97
+ }
98
+ };
99
+ RateLimitError = class extends HeyReachError {
100
+ retryAfter;
101
+ constructor(message = "Rate limit exceeded (300 req/min). Try again later.", retryAfter) {
102
+ super(message, "RATE_LIMIT", 429);
103
+ this.name = "RateLimitError";
104
+ this.retryAfter = retryAfter;
105
+ }
106
+ };
107
+ ServerError = class extends HeyReachError {
108
+ constructor(message = "Server error. Try again later.") {
109
+ super(message, "SERVER_ERROR", 500);
110
+ this.name = "ServerError";
111
+ }
112
+ };
113
+ }
114
+ });
115
+
116
+ // src/core/auth.ts
117
+ function resolveAuth(opts) {
118
+ const config = loadConfig();
119
+ const apiKey = opts?.apiKey ?? process.env.HEYREACH_API_KEY ?? config.api_key;
120
+ if (!apiKey) {
121
+ throw new AuthError(
122
+ 'No API key found. Run "heyreach login" or set HEYREACH_API_KEY.'
123
+ );
124
+ }
125
+ return { apiKey, baseUrl: BASE_URL };
126
+ }
127
+ var BASE_URL;
128
+ var init_auth = __esm({
129
+ "src/core/auth.ts"() {
130
+ "use strict";
131
+ init_esm_shims();
132
+ init_config();
133
+ init_errors();
134
+ BASE_URL = "https://api.heyreach.io/api/public";
135
+ }
136
+ });
137
+
138
+ // src/core/client.ts
139
+ function createClient(auth) {
140
+ async function request(opts) {
141
+ const url = buildUrl(auth.baseUrl, opts.path, opts.query);
142
+ const headers = {
143
+ "X-API-KEY": auth.apiKey,
144
+ Accept: "application/json"
145
+ };
146
+ let bodyStr;
147
+ if (opts.body && Object.keys(opts.body).length > 0) {
148
+ headers["Content-Type"] = "application/json";
149
+ bodyStr = JSON.stringify(opts.body);
150
+ }
151
+ let lastError;
152
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
153
+ try {
154
+ const controller = new AbortController();
155
+ const timeout = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT_MS);
156
+ const res = await fetch(url, {
157
+ method: opts.method,
158
+ headers,
159
+ body: bodyStr,
160
+ signal: controller.signal
161
+ });
162
+ clearTimeout(timeout);
163
+ if (res.ok) {
164
+ const text = await res.text();
165
+ if (!text) return { success: true };
166
+ try {
167
+ return JSON.parse(text);
168
+ } catch {
169
+ return { data: text };
170
+ }
171
+ }
172
+ const errorBody = await res.text();
173
+ if (res.status === 429 || res.status >= 500) {
174
+ lastError = classifyHttpError(res.status, errorBody);
175
+ if (attempt < MAX_RETRIES) {
176
+ const retryAfter = res.status === 429 ? parseRetryAfter(res.headers.get("Retry-After")) : void 0;
177
+ const backoff = retryAfter ?? INITIAL_BACKOFF_MS * Math.pow(2, attempt);
178
+ await sleep(backoff);
179
+ continue;
180
+ }
181
+ }
182
+ throw classifyHttpError(res.status, errorBody);
183
+ } catch (err) {
184
+ if (err instanceof RateLimitError && attempt < MAX_RETRIES) {
185
+ lastError = err;
186
+ await sleep(INITIAL_BACKOFF_MS * Math.pow(2, attempt));
187
+ continue;
188
+ }
189
+ if (err instanceof Error && err.name === "AbortError") {
190
+ lastError = new Error(`Request timed out after ${DEFAULT_TIMEOUT_MS}ms`);
191
+ if (attempt < MAX_RETRIES) {
192
+ await sleep(INITIAL_BACKOFF_MS * Math.pow(2, attempt));
193
+ continue;
194
+ }
195
+ }
196
+ throw err;
197
+ }
198
+ }
199
+ throw lastError ?? new Error("Request failed after retries");
200
+ }
201
+ async function paginate(opts, maxPages = 10) {
202
+ const allItems = [];
203
+ let offset = 0;
204
+ const limit = 100;
205
+ for (let i = 0; i < maxPages; i++) {
206
+ const body = { ...opts.body, offset, limit };
207
+ const result = await request({ ...opts, body });
208
+ const items = result?.items;
209
+ if (items) {
210
+ allItems.push(...items);
211
+ } else {
212
+ return result;
213
+ }
214
+ const totalCount = result?.totalCount;
215
+ if (!totalCount || allItems.length >= totalCount) break;
216
+ offset += limit;
217
+ }
218
+ return { totalCount: allItems.length, items: allItems };
219
+ }
220
+ return { request, paginate };
221
+ }
222
+ function buildUrl(baseUrl, path2, query) {
223
+ const url = new URL(path2, baseUrl.endsWith("/") ? baseUrl : baseUrl + "/");
224
+ if (query) {
225
+ for (const [key, value] of Object.entries(query)) {
226
+ if (value !== void 0 && value !== null) {
227
+ url.searchParams.set(key, String(value));
228
+ }
229
+ }
230
+ }
231
+ return url.toString();
232
+ }
233
+ function parseRetryAfter(header) {
234
+ if (!header) return void 0;
235
+ const seconds = parseInt(header, 10);
236
+ return isNaN(seconds) ? void 0 : seconds * 1e3;
237
+ }
238
+ function sleep(ms) {
239
+ return new Promise((resolve) => setTimeout(resolve, ms));
240
+ }
241
+ var DEFAULT_TIMEOUT_MS, MAX_RETRIES, INITIAL_BACKOFF_MS;
242
+ var init_client = __esm({
243
+ "src/core/client.ts"() {
244
+ "use strict";
245
+ init_esm_shims();
246
+ init_errors();
247
+ DEFAULT_TIMEOUT_MS = 3e4;
248
+ MAX_RETRIES = 3;
249
+ INITIAL_BACKOFF_MS = 1e3;
250
+ }
251
+ });
252
+
253
+ // src/core/output.ts
254
+ var init_output = __esm({
255
+ "src/core/output.ts"() {
256
+ "use strict";
257
+ init_esm_shims();
258
+ }
259
+ });
260
+
261
+ // src/commands/campaigns/list.ts
262
+ import { z } from "zod";
263
+ var campaignsListCommand;
264
+ var init_list = __esm({
265
+ "src/commands/campaigns/list.ts"() {
266
+ "use strict";
267
+ init_esm_shims();
268
+ campaignsListCommand = {
269
+ name: "campaigns_list",
270
+ group: "campaigns",
271
+ subcommand: "list",
272
+ description: "Get a paginated list of all campaigns. Up to 100 per request.",
273
+ examples: [
274
+ "heyreach campaigns list",
275
+ 'heyreach campaigns list --keyword "outbound" --pretty',
276
+ "heyreach campaigns list --statuses IN_PROGRESS,PAUSED"
277
+ ],
278
+ inputSchema: z.object({
279
+ offset: z.coerce.number().default(0).describe("Pagination offset"),
280
+ limit: z.coerce.number().min(1).max(100).default(100).describe("Items per page (max 100)"),
281
+ keyword: z.string().optional().describe("Filter by campaign name"),
282
+ statuses: z.string().optional().describe("Comma-separated statuses: DRAFT,IN_PROGRESS,PAUSED,FINISHED,CANCELED,FAILED,STARTING,SCHEDULED"),
283
+ accountIds: z.string().optional().describe("Comma-separated LinkedIn account IDs")
284
+ }),
285
+ cliMappings: {
286
+ options: [
287
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
288
+ { field: "limit", flags: "--limit <number>", description: "Items per page (max 100)" },
289
+ { field: "keyword", flags: "--keyword <text>", description: "Filter by campaign name" },
290
+ { field: "statuses", flags: "--statuses <list>", description: "Comma-separated statuses" },
291
+ { field: "accountIds", flags: "--account-ids <list>", description: "Comma-separated LinkedIn account IDs" }
292
+ ]
293
+ },
294
+ endpoint: { method: "POST", path: "/campaign/GetAll" },
295
+ fieldMappings: { offset: "body", limit: "body", keyword: "body", statuses: "body", accountIds: "body" },
296
+ handler: async (input, client) => {
297
+ const body = {
298
+ offset: input.offset,
299
+ limit: input.limit
300
+ };
301
+ if (input.keyword) body.keyword = input.keyword;
302
+ if (input.statuses) body.statuses = input.statuses.split(",").map((s) => s.trim());
303
+ if (input.accountIds) body.accountIds = input.accountIds.split(",").map((s) => Number(s.trim()));
304
+ return client.request({ method: "POST", path: "/campaign/GetAll", body });
305
+ }
306
+ };
307
+ }
308
+ });
309
+
310
+ // src/core/handler.ts
311
+ async function executeCommand(cmdDef, input, client) {
312
+ let path2 = cmdDef.endpoint.path;
313
+ const query = {};
314
+ const body = {};
315
+ for (const [field, location] of Object.entries(cmdDef.fieldMappings)) {
316
+ const value = input[field];
317
+ if (value === void 0 || value === null) continue;
318
+ switch (location) {
319
+ case "path":
320
+ path2 = path2.replace(`{${field}}`, encodeURIComponent(String(value)));
321
+ break;
322
+ case "query":
323
+ query[field] = value;
324
+ break;
325
+ case "body":
326
+ body[field] = value;
327
+ break;
328
+ }
329
+ }
330
+ return client.request({
331
+ method: cmdDef.endpoint.method,
332
+ path: path2,
333
+ query: Object.keys(query).length > 0 ? query : void 0,
334
+ body: Object.keys(body).length > 0 ? body : void 0
335
+ });
336
+ }
337
+ var init_handler = __esm({
338
+ "src/core/handler.ts"() {
339
+ "use strict";
340
+ init_esm_shims();
341
+ }
342
+ });
343
+
344
+ // src/commands/campaigns/get.ts
345
+ import { z as z2 } from "zod";
346
+ var campaignsGetCommand;
347
+ var init_get = __esm({
348
+ "src/commands/campaigns/get.ts"() {
349
+ "use strict";
350
+ init_esm_shims();
351
+ init_handler();
352
+ campaignsGetCommand = {
353
+ name: "campaigns_get",
354
+ group: "campaigns",
355
+ subcommand: "get",
356
+ description: "Get a campaign by ID.",
357
+ examples: ["heyreach campaigns get --campaign-id 12345 --pretty"],
358
+ inputSchema: z2.object({
359
+ campaignId: z2.coerce.number().describe("Campaign ID")
360
+ }),
361
+ cliMappings: {
362
+ options: [
363
+ { field: "campaignId", flags: "--campaign-id <id>", description: "Campaign ID" }
364
+ ]
365
+ },
366
+ endpoint: { method: "GET", path: "/campaign/GetById" },
367
+ fieldMappings: { campaignId: "query" },
368
+ handler: (input, client) => executeCommand(campaignsGetCommand, input, client)
369
+ };
370
+ }
371
+ });
372
+
373
+ // src/commands/campaigns/resume.ts
374
+ import { z as z3 } from "zod";
375
+ var campaignsResumeCommand;
376
+ var init_resume = __esm({
377
+ "src/commands/campaigns/resume.ts"() {
378
+ "use strict";
379
+ init_esm_shims();
380
+ init_handler();
381
+ campaignsResumeCommand = {
382
+ name: "campaigns_resume",
383
+ group: "campaigns",
384
+ subcommand: "resume",
385
+ description: "Resume a paused campaign.",
386
+ examples: ["heyreach campaigns resume --campaign-id 12345"],
387
+ inputSchema: z3.object({
388
+ campaignId: z3.coerce.number().describe("Campaign ID")
389
+ }),
390
+ cliMappings: {
391
+ options: [
392
+ { field: "campaignId", flags: "--campaign-id <id>", description: "Campaign ID" }
393
+ ]
394
+ },
395
+ endpoint: { method: "POST", path: "/campaign/Resume" },
396
+ fieldMappings: { campaignId: "query" },
397
+ handler: (input, client) => executeCommand(campaignsResumeCommand, input, client)
398
+ };
399
+ }
400
+ });
401
+
402
+ // src/commands/campaigns/pause.ts
403
+ import { z as z4 } from "zod";
404
+ var campaignsPauseCommand;
405
+ var init_pause = __esm({
406
+ "src/commands/campaigns/pause.ts"() {
407
+ "use strict";
408
+ init_esm_shims();
409
+ init_handler();
410
+ campaignsPauseCommand = {
411
+ name: "campaigns_pause",
412
+ group: "campaigns",
413
+ subcommand: "pause",
414
+ description: "Pause a running campaign.",
415
+ examples: ["heyreach campaigns pause --campaign-id 12345"],
416
+ inputSchema: z4.object({
417
+ campaignId: z4.coerce.number().describe("Campaign ID")
418
+ }),
419
+ cliMappings: {
420
+ options: [
421
+ { field: "campaignId", flags: "--campaign-id <id>", description: "Campaign ID" }
422
+ ]
423
+ },
424
+ endpoint: { method: "POST", path: "/campaign/Pause" },
425
+ fieldMappings: { campaignId: "query" },
426
+ handler: (input, client) => executeCommand(campaignsPauseCommand, input, client)
427
+ };
428
+ }
429
+ });
430
+
431
+ // src/commands/campaigns/add-leads.ts
432
+ import { z as z5 } from "zod";
433
+ var campaignsAddLeadsCommand;
434
+ var init_add_leads = __esm({
435
+ "src/commands/campaigns/add-leads.ts"() {
436
+ "use strict";
437
+ init_esm_shims();
438
+ campaignsAddLeadsCommand = {
439
+ name: "campaigns_add_leads",
440
+ group: "campaigns",
441
+ subcommand: "add-leads",
442
+ description: "Add leads to a campaign (V2 \u2014 returns detailed counts). Up to 100 leads per request. Accepts JSON array via --leads-json.",
443
+ examples: [
444
+ `heyreach campaigns add-leads --campaign-id 123 --leads-json '[{"lead":{"firstName":"Jane","lastName":"Doe","profileUrl":"https://linkedin.com/in/janedoe"}}]'`
445
+ ],
446
+ inputSchema: z5.object({
447
+ campaignId: z5.coerce.number().describe("Campaign ID"),
448
+ leadsJson: z5.string().describe("JSON array of accountLeadPairs"),
449
+ resumeFinishedCampaign: z5.coerce.boolean().optional().describe("Resume if campaign finished"),
450
+ resumePausedCampaign: z5.coerce.boolean().optional().describe("Resume if campaign paused")
451
+ }),
452
+ cliMappings: {
453
+ options: [
454
+ { field: "campaignId", flags: "--campaign-id <id>", description: "Campaign ID" },
455
+ { field: "leadsJson", flags: "--leads-json <json>", description: "JSON array of accountLeadPairs" },
456
+ { field: "resumeFinishedCampaign", flags: "--resume-finished", description: "Resume if campaign finished" },
457
+ { field: "resumePausedCampaign", flags: "--resume-paused", description: "Resume if campaign paused" }
458
+ ]
459
+ },
460
+ endpoint: { method: "POST", path: "/campaign/AddLeadsToCampaignV2" },
461
+ fieldMappings: { campaignId: "body", leadsJson: "body", resumeFinishedCampaign: "body", resumePausedCampaign: "body" },
462
+ handler: async (input, client) => {
463
+ const accountLeadPairs = JSON.parse(input.leadsJson);
464
+ const body = {
465
+ campaignId: input.campaignId,
466
+ accountLeadPairs
467
+ };
468
+ if (input.resumeFinishedCampaign !== void 0) body.resumeFinishedCampaign = input.resumeFinishedCampaign;
469
+ if (input.resumePausedCampaign !== void 0) body.resumePausedCampaign = input.resumePausedCampaign;
470
+ return client.request({ method: "POST", path: "/campaign/AddLeadsToCampaignV2", body });
471
+ }
472
+ };
473
+ }
474
+ });
475
+
476
+ // src/commands/campaigns/stop-lead.ts
477
+ import { z as z6 } from "zod";
478
+ var campaignsStopLeadCommand;
479
+ var init_stop_lead = __esm({
480
+ "src/commands/campaigns/stop-lead.ts"() {
481
+ "use strict";
482
+ init_esm_shims();
483
+ init_handler();
484
+ campaignsStopLeadCommand = {
485
+ name: "campaigns_stop_lead",
486
+ group: "campaigns",
487
+ subcommand: "stop-lead",
488
+ description: "Stop the progression of a lead in a campaign.",
489
+ examples: [
490
+ 'heyreach campaigns stop-lead --campaign-id 123 --lead-url "https://linkedin.com/in/janedoe"',
491
+ 'heyreach campaigns stop-lead --campaign-id 123 --lead-member-id "ABC123"'
492
+ ],
493
+ inputSchema: z6.object({
494
+ campaignId: z6.coerce.number().describe("Campaign ID"),
495
+ leadMemberId: z6.string().optional().describe("LinkedIn member ID"),
496
+ leadUrl: z6.string().optional().describe("LinkedIn profile URL")
497
+ }),
498
+ cliMappings: {
499
+ options: [
500
+ { field: "campaignId", flags: "--campaign-id <id>", description: "Campaign ID" },
501
+ { field: "leadMemberId", flags: "--lead-member-id <id>", description: "LinkedIn member ID" },
502
+ { field: "leadUrl", flags: "--lead-url <url>", description: "LinkedIn profile URL" }
503
+ ]
504
+ },
505
+ endpoint: { method: "POST", path: "/campaign/StopLeadInCampaign" },
506
+ fieldMappings: { campaignId: "body", leadMemberId: "body", leadUrl: "body" },
507
+ handler: (input, client) => executeCommand(campaignsStopLeadCommand, input, client)
508
+ };
509
+ }
510
+ });
511
+
512
+ // src/commands/campaigns/get-leads.ts
513
+ import { z as z7 } from "zod";
514
+ var campaignsGetLeadsCommand;
515
+ var init_get_leads = __esm({
516
+ "src/commands/campaigns/get-leads.ts"() {
517
+ "use strict";
518
+ init_esm_shims();
519
+ init_handler();
520
+ campaignsGetLeadsCommand = {
521
+ name: "campaigns_get_leads",
522
+ group: "campaigns",
523
+ subcommand: "get-leads",
524
+ description: "Get leads from a campaign (Lead Analytics). Shows pending leads about to start executing.",
525
+ examples: ["heyreach campaigns get-leads --campaign-id 123 --pretty"],
526
+ inputSchema: z7.object({
527
+ campaignId: z7.coerce.number().describe("Campaign ID"),
528
+ offset: z7.coerce.number().default(0).describe("Pagination offset"),
529
+ limit: z7.coerce.number().min(1).max(100).default(100).describe("Items per page"),
530
+ timeFrom: z7.string().optional().describe("Start time (ISO 8601)"),
531
+ timeTo: z7.string().optional().describe("End time (ISO 8601)"),
532
+ timeFilter: z7.string().optional().describe("Time filter: CreationTime|Everywhere|LastActionTakenTime|FailedTime|LastActionTakenOrFailedTime")
533
+ }),
534
+ cliMappings: {
535
+ options: [
536
+ { field: "campaignId", flags: "--campaign-id <id>", description: "Campaign ID" },
537
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
538
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
539
+ { field: "timeFrom", flags: "--time-from <iso>", description: "Start time (ISO 8601)" },
540
+ { field: "timeTo", flags: "--time-to <iso>", description: "End time (ISO 8601)" },
541
+ { field: "timeFilter", flags: "--time-filter <type>", description: "Time filter type" }
542
+ ]
543
+ },
544
+ endpoint: { method: "POST", path: "/campaign/GetLeadsFromCampaign" },
545
+ fieldMappings: { campaignId: "body", offset: "body", limit: "body", timeFrom: "body", timeTo: "body", timeFilter: "body" },
546
+ handler: (input, client) => executeCommand(campaignsGetLeadsCommand, input, client)
547
+ };
548
+ }
549
+ });
550
+
551
+ // src/commands/campaigns/get-for-lead.ts
552
+ import { z as z8 } from "zod";
553
+ var campaignsGetForLeadCommand;
554
+ var init_get_for_lead = __esm({
555
+ "src/commands/campaigns/get-for-lead.ts"() {
556
+ "use strict";
557
+ init_esm_shims();
558
+ init_handler();
559
+ campaignsGetForLeadCommand = {
560
+ name: "campaigns_get_for_lead",
561
+ group: "campaigns",
562
+ subcommand: "get-for-lead",
563
+ description: "Get campaigns where a specific lead is enrolled.",
564
+ examples: [
565
+ 'heyreach campaigns get-for-lead --profile-url "https://linkedin.com/in/janedoe" --pretty',
566
+ 'heyreach campaigns get-for-lead --email "jane@example.com"'
567
+ ],
568
+ inputSchema: z8.object({
569
+ offset: z8.coerce.number().default(0).describe("Pagination offset"),
570
+ limit: z8.coerce.number().min(1).max(100).default(100).describe("Items per page"),
571
+ email: z8.string().optional().describe("Lead email address"),
572
+ linkedinId: z8.string().optional().describe("Lead LinkedIn ID"),
573
+ profileUrl: z8.string().optional().describe("Lead LinkedIn profile URL")
574
+ }),
575
+ cliMappings: {
576
+ options: [
577
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
578
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
579
+ { field: "email", flags: "--email <email>", description: "Lead email address" },
580
+ { field: "linkedinId", flags: "--linkedin-id <id>", description: "Lead LinkedIn ID" },
581
+ { field: "profileUrl", flags: "--profile-url <url>", description: "Lead LinkedIn profile URL" }
582
+ ]
583
+ },
584
+ endpoint: { method: "POST", path: "/campaign/GetCampaignsForLead" },
585
+ fieldMappings: { offset: "body", limit: "body", email: "body", linkedinId: "body", profileUrl: "body" },
586
+ handler: (input, client) => executeCommand(campaignsGetForLeadCommand, input, client)
587
+ };
588
+ }
589
+ });
590
+
591
+ // src/commands/campaigns/index.ts
592
+ var campaignCommands;
593
+ var init_campaigns = __esm({
594
+ "src/commands/campaigns/index.ts"() {
595
+ "use strict";
596
+ init_esm_shims();
597
+ init_list();
598
+ init_get();
599
+ init_resume();
600
+ init_pause();
601
+ init_add_leads();
602
+ init_stop_lead();
603
+ init_get_leads();
604
+ init_get_for_lead();
605
+ campaignCommands = [
606
+ campaignsListCommand,
607
+ campaignsGetCommand,
608
+ campaignsResumeCommand,
609
+ campaignsPauseCommand,
610
+ campaignsAddLeadsCommand,
611
+ campaignsStopLeadCommand,
612
+ campaignsGetLeadsCommand,
613
+ campaignsGetForLeadCommand
614
+ ];
615
+ }
616
+ });
617
+
618
+ // src/commands/inbox/list.ts
619
+ import { z as z9 } from "zod";
620
+ var inboxListCommand;
621
+ var init_list2 = __esm({
622
+ "src/commands/inbox/list.ts"() {
623
+ "use strict";
624
+ init_esm_shims();
625
+ inboxListCommand = {
626
+ name: "inbox_list",
627
+ group: "inbox",
628
+ subcommand: "list",
629
+ description: "Get a paginated list of LinkedIn conversations. Up to 100 per request.",
630
+ examples: [
631
+ "heyreach inbox list --pretty",
632
+ 'heyreach inbox list --search "product demo" --seen false'
633
+ ],
634
+ inputSchema: z9.object({
635
+ offset: z9.coerce.number().default(0).describe("Pagination offset"),
636
+ limit: z9.coerce.number().min(1).max(100).default(100).describe("Items per page"),
637
+ linkedInAccountIds: z9.string().optional().describe("Comma-separated LinkedIn account IDs"),
638
+ campaignIds: z9.string().optional().describe("Comma-separated campaign IDs"),
639
+ searchString: z9.string().optional().describe("Search conversations"),
640
+ leadLinkedInId: z9.string().optional().describe("Filter by lead LinkedIn ID"),
641
+ leadProfileUrl: z9.string().optional().describe("Filter by lead profile URL"),
642
+ tags: z9.string().optional().describe("Comma-separated lead tags"),
643
+ seen: z9.string().optional().describe("Filter by seen status: true/false")
644
+ }),
645
+ cliMappings: {
646
+ options: [
647
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
648
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
649
+ { field: "linkedInAccountIds", flags: "--account-ids <list>", description: "Comma-separated LinkedIn account IDs" },
650
+ { field: "campaignIds", flags: "--campaign-ids <list>", description: "Comma-separated campaign IDs" },
651
+ { field: "searchString", flags: "--search <text>", description: "Search conversations" },
652
+ { field: "leadLinkedInId", flags: "--lead-linkedin-id <id>", description: "Filter by lead LinkedIn ID" },
653
+ { field: "leadProfileUrl", flags: "--lead-profile-url <url>", description: "Filter by lead profile URL" },
654
+ { field: "tags", flags: "--tags <list>", description: "Comma-separated lead tags" },
655
+ { field: "seen", flags: "--seen <bool>", description: "Filter by seen status" }
656
+ ]
657
+ },
658
+ endpoint: { method: "POST", path: "/inbox/GetConversationsV2" },
659
+ fieldMappings: {},
660
+ handler: async (input, client) => {
661
+ const filters = {};
662
+ if (input.linkedInAccountIds) filters.linkedInAccountIds = input.linkedInAccountIds.split(",").map((s) => Number(s.trim()));
663
+ if (input.campaignIds) filters.campaignIds = input.campaignIds.split(",").map((s) => Number(s.trim()));
664
+ if (input.searchString) filters.searchString = input.searchString;
665
+ if (input.leadLinkedInId) filters.leadLinkedInId = input.leadLinkedInId;
666
+ if (input.leadProfileUrl) filters.leadProfileUrl = input.leadProfileUrl;
667
+ if (input.tags) filters.tags = input.tags.split(",").map((s) => s.trim());
668
+ if (input.seen !== void 0) filters.seen = input.seen === "true";
669
+ return client.request({
670
+ method: "POST",
671
+ path: "/inbox/GetConversationsV2",
672
+ body: { offset: input.offset, limit: input.limit, filters }
673
+ });
674
+ }
675
+ };
676
+ }
677
+ });
678
+
679
+ // src/commands/inbox/get.ts
680
+ import { z as z10 } from "zod";
681
+ var inboxGetCommand;
682
+ var init_get2 = __esm({
683
+ "src/commands/inbox/get.ts"() {
684
+ "use strict";
685
+ init_esm_shims();
686
+ inboxGetCommand = {
687
+ name: "inbox_get",
688
+ group: "inbox",
689
+ subcommand: "get",
690
+ description: "Get a LinkedIn conversation with messages by account ID and conversation ID.",
691
+ examples: ['heyreach inbox get --account-id 123 --conversation-id "abc-def"'],
692
+ inputSchema: z10.object({
693
+ accountId: z10.coerce.number().describe("LinkedIn account ID"),
694
+ conversationId: z10.string().describe("Conversation ID")
695
+ }),
696
+ cliMappings: {
697
+ options: [
698
+ { field: "accountId", flags: "--account-id <id>", description: "LinkedIn account ID" },
699
+ { field: "conversationId", flags: "--conversation-id <id>", description: "Conversation ID" }
700
+ ]
701
+ },
702
+ endpoint: { method: "GET", path: "/inbox/GetChatroom/{accountId}/{conversationId}" },
703
+ fieldMappings: { accountId: "path", conversationId: "path" },
704
+ handler: async (input, client) => {
705
+ return client.request({
706
+ method: "GET",
707
+ path: `/inbox/GetChatroom/${encodeURIComponent(String(input.accountId))}/${encodeURIComponent(String(input.conversationId))}`
708
+ });
709
+ }
710
+ };
711
+ }
712
+ });
713
+
714
+ // src/commands/inbox/send.ts
715
+ import { z as z11 } from "zod";
716
+ var inboxSendCommand;
717
+ var init_send = __esm({
718
+ "src/commands/inbox/send.ts"() {
719
+ "use strict";
720
+ init_esm_shims();
721
+ init_handler();
722
+ inboxSendCommand = {
723
+ name: "inbox_send",
724
+ group: "inbox",
725
+ subcommand: "send",
726
+ description: "Send a message to a LinkedIn conversation.",
727
+ examples: ['heyreach inbox send --conversation-id "abc" --account-id 123 --message "Hello!"'],
728
+ inputSchema: z11.object({
729
+ message: z11.string().describe("Message text"),
730
+ conversationId: z11.string().describe("Conversation ID"),
731
+ linkedInAccountId: z11.coerce.number().describe("LinkedIn account ID"),
732
+ subject: z11.string().optional().describe("Message subject")
733
+ }),
734
+ cliMappings: {
735
+ options: [
736
+ { field: "message", flags: "--message <text>", description: "Message text" },
737
+ { field: "conversationId", flags: "--conversation-id <id>", description: "Conversation ID" },
738
+ { field: "linkedInAccountId", flags: "--account-id <id>", description: "LinkedIn account ID" },
739
+ { field: "subject", flags: "--subject <text>", description: "Message subject" }
740
+ ]
741
+ },
742
+ endpoint: { method: "POST", path: "/inbox/SendMessage" },
743
+ fieldMappings: { message: "body", conversationId: "body", linkedInAccountId: "body", subject: "body" },
744
+ handler: (input, client) => executeCommand(inboxSendCommand, input, client)
745
+ };
746
+ }
747
+ });
748
+
749
+ // src/commands/inbox/set-seen.ts
750
+ import { z as z12 } from "zod";
751
+ var inboxSetSeenCommand;
752
+ var init_set_seen = __esm({
753
+ "src/commands/inbox/set-seen.ts"() {
754
+ "use strict";
755
+ init_esm_shims();
756
+ init_handler();
757
+ inboxSetSeenCommand = {
758
+ name: "inbox_set_seen",
759
+ group: "inbox",
760
+ subcommand: "set-seen",
761
+ description: "Mark a conversation as seen or unseen.",
762
+ examples: ['heyreach inbox set-seen --conversation-id "abc" --account-id 123 --seen true'],
763
+ inputSchema: z12.object({
764
+ conversationId: z12.string().describe("Conversation ID"),
765
+ linkedInAccountId: z12.coerce.number().describe("LinkedIn account ID"),
766
+ seen: z12.coerce.boolean().describe("Mark as seen (true) or unseen (false)")
767
+ }),
768
+ cliMappings: {
769
+ options: [
770
+ { field: "conversationId", flags: "--conversation-id <id>", description: "Conversation ID" },
771
+ { field: "linkedInAccountId", flags: "--account-id <id>", description: "LinkedIn account ID" },
772
+ { field: "seen", flags: "--seen <bool>", description: "Seen status (true/false)" }
773
+ ]
774
+ },
775
+ endpoint: { method: "POST", path: "/inbox/SetSeenStatus" },
776
+ fieldMappings: { conversationId: "body", linkedInAccountId: "body", seen: "body" },
777
+ handler: (input, client) => executeCommand(inboxSetSeenCommand, input, client)
778
+ };
779
+ }
780
+ });
781
+
782
+ // src/commands/inbox/index.ts
783
+ var inboxCommands;
784
+ var init_inbox = __esm({
785
+ "src/commands/inbox/index.ts"() {
786
+ "use strict";
787
+ init_esm_shims();
788
+ init_list2();
789
+ init_get2();
790
+ init_send();
791
+ init_set_seen();
792
+ inboxCommands = [
793
+ inboxListCommand,
794
+ inboxGetCommand,
795
+ inboxSendCommand,
796
+ inboxSetSeenCommand
797
+ ];
798
+ }
799
+ });
800
+
801
+ // src/commands/accounts/list.ts
802
+ import { z as z13 } from "zod";
803
+ var accountsListCommand;
804
+ var init_list3 = __esm({
805
+ "src/commands/accounts/list.ts"() {
806
+ "use strict";
807
+ init_esm_shims();
808
+ init_handler();
809
+ accountsListCommand = {
810
+ name: "accounts_list",
811
+ group: "accounts",
812
+ subcommand: "list",
813
+ description: "Get a paginated list of all LinkedIn accounts. Up to 100 per request.",
814
+ examples: ["heyreach accounts list --pretty", 'heyreach accounts list --keyword "john"'],
815
+ inputSchema: z13.object({
816
+ offset: z13.coerce.number().default(0).describe("Pagination offset"),
817
+ limit: z13.coerce.number().min(1).max(100).default(100).describe("Items per page"),
818
+ keyword: z13.string().optional().describe("Search by account name")
819
+ }),
820
+ cliMappings: {
821
+ options: [
822
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
823
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
824
+ { field: "keyword", flags: "--keyword <text>", description: "Search by account name" }
825
+ ]
826
+ },
827
+ endpoint: { method: "POST", path: "/li_account/GetAll" },
828
+ fieldMappings: { offset: "body", limit: "body", keyword: "body" },
829
+ handler: (input, client) => executeCommand(accountsListCommand, input, client)
830
+ };
831
+ }
832
+ });
833
+
834
+ // src/commands/accounts/get.ts
835
+ import { z as z14 } from "zod";
836
+ var accountsGetCommand;
837
+ var init_get3 = __esm({
838
+ "src/commands/accounts/get.ts"() {
839
+ "use strict";
840
+ init_esm_shims();
841
+ init_handler();
842
+ accountsGetCommand = {
843
+ name: "accounts_get",
844
+ group: "accounts",
845
+ subcommand: "get",
846
+ description: "Get a LinkedIn account by ID.",
847
+ examples: ["heyreach accounts get --account-id 123 --pretty"],
848
+ inputSchema: z14.object({
849
+ accountId: z14.coerce.number().describe("LinkedIn account ID")
850
+ }),
851
+ cliMappings: {
852
+ options: [
853
+ { field: "accountId", flags: "--account-id <id>", description: "LinkedIn account ID" }
854
+ ]
855
+ },
856
+ endpoint: { method: "GET", path: "/li_account/GetById" },
857
+ fieldMappings: { accountId: "query" },
858
+ handler: (input, client) => executeCommand(accountsGetCommand, input, client)
859
+ };
860
+ }
861
+ });
862
+
863
+ // src/commands/accounts/index.ts
864
+ var accountCommands;
865
+ var init_accounts = __esm({
866
+ "src/commands/accounts/index.ts"() {
867
+ "use strict";
868
+ init_esm_shims();
869
+ init_list3();
870
+ init_get3();
871
+ accountCommands = [
872
+ accountsListCommand,
873
+ accountsGetCommand
874
+ ];
875
+ }
876
+ });
877
+
878
+ // src/commands/lists/get.ts
879
+ import { z as z15 } from "zod";
880
+ var listsGetCommand;
881
+ var init_get4 = __esm({
882
+ "src/commands/lists/get.ts"() {
883
+ "use strict";
884
+ init_esm_shims();
885
+ init_handler();
886
+ listsGetCommand = {
887
+ name: "lists_get",
888
+ group: "lists",
889
+ subcommand: "get",
890
+ description: "Get a lead or company list by ID.",
891
+ examples: ["heyreach lists get --list-id 456 --pretty"],
892
+ inputSchema: z15.object({
893
+ listId: z15.coerce.number().describe("List ID")
894
+ }),
895
+ cliMappings: {
896
+ options: [
897
+ { field: "listId", flags: "--list-id <id>", description: "List ID" }
898
+ ]
899
+ },
900
+ endpoint: { method: "GET", path: "/list/GetById" },
901
+ fieldMappings: { listId: "query" },
902
+ handler: (input, client) => executeCommand(listsGetCommand, input, client)
903
+ };
904
+ }
905
+ });
906
+
907
+ // src/commands/lists/list.ts
908
+ import { z as z16 } from "zod";
909
+ var listsListCommand;
910
+ var init_list4 = __esm({
911
+ "src/commands/lists/list.ts"() {
912
+ "use strict";
913
+ init_esm_shims();
914
+ listsListCommand = {
915
+ name: "lists_list",
916
+ group: "lists",
917
+ subcommand: "list",
918
+ description: "Get a paginated list of all lead and company lists. Up to 100 per request.",
919
+ examples: [
920
+ "heyreach lists list --pretty",
921
+ "heyreach lists list --list-type USER_LIST"
922
+ ],
923
+ inputSchema: z16.object({
924
+ offset: z16.coerce.number().default(0).describe("Pagination offset"),
925
+ limit: z16.coerce.number().min(1).max(100).default(100).describe("Items per page"),
926
+ keyword: z16.string().optional().describe("Search by list name"),
927
+ listType: z16.string().optional().describe("Filter by type: USER_LIST or COMPANY_LIST"),
928
+ campaignIds: z16.string().optional().describe("Comma-separated campaign IDs")
929
+ }),
930
+ cliMappings: {
931
+ options: [
932
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
933
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
934
+ { field: "keyword", flags: "--keyword <text>", description: "Search by list name" },
935
+ { field: "listType", flags: "--list-type <type>", description: "USER_LIST or COMPANY_LIST" },
936
+ { field: "campaignIds", flags: "--campaign-ids <list>", description: "Comma-separated campaign IDs" }
937
+ ]
938
+ },
939
+ endpoint: { method: "POST", path: "/list/GetAll" },
940
+ fieldMappings: {},
941
+ handler: async (input, client) => {
942
+ const body = { offset: input.offset, limit: input.limit };
943
+ if (input.keyword) body.keyword = input.keyword;
944
+ if (input.listType) body.listType = input.listType;
945
+ if (input.campaignIds) body.campaignIds = input.campaignIds.split(",").map((s) => Number(s.trim()));
946
+ return client.request({ method: "POST", path: "/list/GetAll", body });
947
+ }
948
+ };
949
+ }
950
+ });
951
+
952
+ // src/commands/lists/create.ts
953
+ import { z as z17 } from "zod";
954
+ var listsCreateCommand;
955
+ var init_create = __esm({
956
+ "src/commands/lists/create.ts"() {
957
+ "use strict";
958
+ init_esm_shims();
959
+ init_handler();
960
+ listsCreateCommand = {
961
+ name: "lists_create",
962
+ group: "lists",
963
+ subcommand: "create",
964
+ description: "Create an empty lead or company list.",
965
+ examples: [
966
+ 'heyreach lists create --name "Q1 Prospects"',
967
+ 'heyreach lists create --name "Target Companies" --type COMPANY_LIST'
968
+ ],
969
+ inputSchema: z17.object({
970
+ name: z17.string().describe("List name"),
971
+ type: z17.string().optional().describe("List type: USER_LIST (default) or COMPANY_LIST")
972
+ }),
973
+ cliMappings: {
974
+ options: [
975
+ { field: "name", flags: "--name <name>", description: "List name" },
976
+ { field: "type", flags: "--type <type>", description: "USER_LIST or COMPANY_LIST" }
977
+ ]
978
+ },
979
+ endpoint: { method: "POST", path: "/list/CreateEmptyList" },
980
+ fieldMappings: { name: "body", type: "body" },
981
+ handler: (input, client) => executeCommand(listsCreateCommand, input, client)
982
+ };
983
+ }
984
+ });
985
+
986
+ // src/commands/lists/get-leads.ts
987
+ import { z as z18 } from "zod";
988
+ var listsGetLeadsCommand;
989
+ var init_get_leads2 = __esm({
990
+ "src/commands/lists/get-leads.ts"() {
991
+ "use strict";
992
+ init_esm_shims();
993
+ init_handler();
994
+ listsGetLeadsCommand = {
995
+ name: "lists_get_leads",
996
+ group: "lists",
997
+ subcommand: "get-leads",
998
+ description: "Get a paginated list of leads from a lead list. Up to 1000 per request.",
999
+ examples: ["heyreach lists get-leads --list-id 456 --pretty"],
1000
+ inputSchema: z18.object({
1001
+ listId: z18.coerce.number().describe("List ID"),
1002
+ offset: z18.coerce.number().default(0).describe("Pagination offset"),
1003
+ limit: z18.coerce.number().min(1).max(1e3).default(100).describe("Items per page (max 1000)"),
1004
+ keyword: z18.string().optional().describe("Search leads"),
1005
+ leadProfileUrl: z18.string().optional().describe("Filter by profile URL"),
1006
+ leadLinkedInId: z18.string().optional().describe("Filter by LinkedIn ID"),
1007
+ createdFrom: z18.string().optional().describe("Created from (ISO 8601)"),
1008
+ createdTo: z18.string().optional().describe("Created to (ISO 8601)")
1009
+ }),
1010
+ cliMappings: {
1011
+ options: [
1012
+ { field: "listId", flags: "--list-id <id>", description: "List ID" },
1013
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
1014
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
1015
+ { field: "keyword", flags: "--keyword <text>", description: "Search leads" },
1016
+ { field: "leadProfileUrl", flags: "--profile-url <url>", description: "Filter by profile URL" },
1017
+ { field: "leadLinkedInId", flags: "--linkedin-id <id>", description: "Filter by LinkedIn ID" },
1018
+ { field: "createdFrom", flags: "--created-from <iso>", description: "Created from (ISO 8601)" },
1019
+ { field: "createdTo", flags: "--created-to <iso>", description: "Created to (ISO 8601)" }
1020
+ ]
1021
+ },
1022
+ endpoint: { method: "POST", path: "/list/GetLeadsFromList" },
1023
+ fieldMappings: { listId: "body", offset: "body", limit: "body", keyword: "body", leadProfileUrl: "body", leadLinkedInId: "body", createdFrom: "body", createdTo: "body" },
1024
+ handler: (input, client) => executeCommand(listsGetLeadsCommand, input, client)
1025
+ };
1026
+ }
1027
+ });
1028
+
1029
+ // src/commands/lists/add-leads.ts
1030
+ import { z as z19 } from "zod";
1031
+ var listsAddLeadsCommand;
1032
+ var init_add_leads2 = __esm({
1033
+ "src/commands/lists/add-leads.ts"() {
1034
+ "use strict";
1035
+ init_esm_shims();
1036
+ listsAddLeadsCommand = {
1037
+ name: "lists_add_leads",
1038
+ group: "lists",
1039
+ subcommand: "add-leads",
1040
+ description: "Add leads to a lead list (V2 \u2014 returns detailed counts). Up to 100 per request. Accepts JSON array via --leads-json.",
1041
+ examples: [
1042
+ `heyreach lists add-leads --list-id 456 --leads-json '[{"firstName":"Jane","lastName":"Doe","profileUrl":"https://linkedin.com/in/janedoe"}]'`
1043
+ ],
1044
+ inputSchema: z19.object({
1045
+ listId: z19.coerce.number().describe("List ID"),
1046
+ leadsJson: z19.string().describe("JSON array of lead objects")
1047
+ }),
1048
+ cliMappings: {
1049
+ options: [
1050
+ { field: "listId", flags: "--list-id <id>", description: "List ID" },
1051
+ { field: "leadsJson", flags: "--leads-json <json>", description: "JSON array of lead objects" }
1052
+ ]
1053
+ },
1054
+ endpoint: { method: "POST", path: "/list/AddLeadsToListV2" },
1055
+ fieldMappings: {},
1056
+ handler: async (input, client) => {
1057
+ const leads = JSON.parse(input.leadsJson);
1058
+ return client.request({
1059
+ method: "POST",
1060
+ path: "/list/AddLeadsToListV2",
1061
+ body: { listId: input.listId, leads }
1062
+ });
1063
+ }
1064
+ };
1065
+ }
1066
+ });
1067
+
1068
+ // src/commands/lists/delete-leads.ts
1069
+ import { z as z20 } from "zod";
1070
+ var listsDeleteLeadsCommand;
1071
+ var init_delete_leads = __esm({
1072
+ "src/commands/lists/delete-leads.ts"() {
1073
+ "use strict";
1074
+ init_esm_shims();
1075
+ listsDeleteLeadsCommand = {
1076
+ name: "lists_delete_leads",
1077
+ group: "lists",
1078
+ subcommand: "delete-leads",
1079
+ description: "Delete leads from a list by LinkedIn member IDs.",
1080
+ examples: ['heyreach lists delete-leads --list-id 456 --member-ids "id1,id2,id3"'],
1081
+ inputSchema: z20.object({
1082
+ listId: z20.coerce.number().describe("List ID"),
1083
+ memberIds: z20.string().describe("Comma-separated LinkedIn member IDs")
1084
+ }),
1085
+ cliMappings: {
1086
+ options: [
1087
+ { field: "listId", flags: "--list-id <id>", description: "List ID" },
1088
+ { field: "memberIds", flags: "--member-ids <list>", description: "Comma-separated LinkedIn member IDs" }
1089
+ ]
1090
+ },
1091
+ endpoint: { method: "DELETE", path: "/list/DeleteLeadsFromList" },
1092
+ fieldMappings: {},
1093
+ handler: async (input, client) => {
1094
+ const leadMemberIds = input.memberIds.split(",").map((s) => s.trim());
1095
+ return client.request({
1096
+ method: "DELETE",
1097
+ path: "/list/DeleteLeadsFromList",
1098
+ body: { listId: input.listId, leadMemberIds }
1099
+ });
1100
+ }
1101
+ };
1102
+ }
1103
+ });
1104
+
1105
+ // src/commands/lists/delete-leads-by-url.ts
1106
+ import { z as z21 } from "zod";
1107
+ var listsDeleteLeadsByUrlCommand;
1108
+ var init_delete_leads_by_url = __esm({
1109
+ "src/commands/lists/delete-leads-by-url.ts"() {
1110
+ "use strict";
1111
+ init_esm_shims();
1112
+ listsDeleteLeadsByUrlCommand = {
1113
+ name: "lists_delete_leads_by_url",
1114
+ group: "lists",
1115
+ subcommand: "delete-leads-by-url",
1116
+ description: "Delete leads from a list by LinkedIn profile URLs.",
1117
+ examples: ['heyreach lists delete-leads-by-url --list-id 456 --urls "https://linkedin.com/in/jane,https://linkedin.com/in/john"'],
1118
+ inputSchema: z21.object({
1119
+ listId: z21.coerce.number().describe("List ID"),
1120
+ urls: z21.string().describe("Comma-separated LinkedIn profile URLs")
1121
+ }),
1122
+ cliMappings: {
1123
+ options: [
1124
+ { field: "listId", flags: "--list-id <id>", description: "List ID" },
1125
+ { field: "urls", flags: "--urls <list>", description: "Comma-separated LinkedIn profile URLs" }
1126
+ ]
1127
+ },
1128
+ endpoint: { method: "DELETE", path: "/list/DeleteLeadsFromListByProfileUrl" },
1129
+ fieldMappings: {},
1130
+ handler: async (input, client) => {
1131
+ const profileUrls = input.urls.split(",").map((s) => s.trim());
1132
+ return client.request({
1133
+ method: "DELETE",
1134
+ path: "/list/DeleteLeadsFromListByProfileUrl",
1135
+ body: { listId: input.listId, profileUrls }
1136
+ });
1137
+ }
1138
+ };
1139
+ }
1140
+ });
1141
+
1142
+ // src/commands/lists/get-companies.ts
1143
+ import { z as z22 } from "zod";
1144
+ var listsGetCompaniesCommand;
1145
+ var init_get_companies = __esm({
1146
+ "src/commands/lists/get-companies.ts"() {
1147
+ "use strict";
1148
+ init_esm_shims();
1149
+ init_handler();
1150
+ listsGetCompaniesCommand = {
1151
+ name: "lists_get_companies",
1152
+ group: "lists",
1153
+ subcommand: "get-companies",
1154
+ description: "Get a paginated list of companies from a company list. Up to 1000 per request.",
1155
+ examples: ["heyreach lists get-companies --list-id 789 --pretty"],
1156
+ inputSchema: z22.object({
1157
+ listId: z22.coerce.number().describe("List ID"),
1158
+ offset: z22.coerce.number().default(0).describe("Pagination offset"),
1159
+ limit: z22.coerce.number().min(1).max(1e3).default(100).describe("Items per page (max 1000)"),
1160
+ keyword: z22.string().optional().describe("Search companies")
1161
+ }),
1162
+ cliMappings: {
1163
+ options: [
1164
+ { field: "listId", flags: "--list-id <id>", description: "List ID" },
1165
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
1166
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
1167
+ { field: "keyword", flags: "--keyword <text>", description: "Search companies" }
1168
+ ]
1169
+ },
1170
+ endpoint: { method: "POST", path: "/list/GetCompaniesFromList" },
1171
+ fieldMappings: { listId: "body", offset: "body", limit: "body", keyword: "body" },
1172
+ handler: (input, client) => executeCommand(listsGetCompaniesCommand, input, client)
1173
+ };
1174
+ }
1175
+ });
1176
+
1177
+ // src/commands/lists/get-for-lead.ts
1178
+ import { z as z23 } from "zod";
1179
+ var listsGetForLeadCommand;
1180
+ var init_get_for_lead2 = __esm({
1181
+ "src/commands/lists/get-for-lead.ts"() {
1182
+ "use strict";
1183
+ init_esm_shims();
1184
+ init_handler();
1185
+ listsGetForLeadCommand = {
1186
+ name: "lists_get_for_lead",
1187
+ group: "lists",
1188
+ subcommand: "get-for-lead",
1189
+ description: "Get lists associated with a specific lead.",
1190
+ examples: ['heyreach lists get-for-lead --profile-url "https://linkedin.com/in/janedoe"'],
1191
+ inputSchema: z23.object({
1192
+ offset: z23.coerce.number().default(0).describe("Pagination offset"),
1193
+ limit: z23.coerce.number().min(1).max(100).default(100).describe("Items per page"),
1194
+ email: z23.string().optional().describe("Lead email"),
1195
+ linkedinId: z23.string().optional().describe("Lead LinkedIn ID"),
1196
+ profileUrl: z23.string().optional().describe("Lead LinkedIn profile URL")
1197
+ }),
1198
+ cliMappings: {
1199
+ options: [
1200
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
1201
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
1202
+ { field: "email", flags: "--email <email>", description: "Lead email" },
1203
+ { field: "linkedinId", flags: "--linkedin-id <id>", description: "Lead LinkedIn ID" },
1204
+ { field: "profileUrl", flags: "--profile-url <url>", description: "Lead profile URL" }
1205
+ ]
1206
+ },
1207
+ endpoint: { method: "POST", path: "/list/GetListsForLead" },
1208
+ fieldMappings: { offset: "body", limit: "body", email: "body", linkedinId: "body", profileUrl: "body" },
1209
+ handler: (input, client) => executeCommand(listsGetForLeadCommand, input, client)
1210
+ };
1211
+ }
1212
+ });
1213
+
1214
+ // src/commands/lists/index.ts
1215
+ var listCommands;
1216
+ var init_lists = __esm({
1217
+ "src/commands/lists/index.ts"() {
1218
+ "use strict";
1219
+ init_esm_shims();
1220
+ init_get4();
1221
+ init_list4();
1222
+ init_create();
1223
+ init_get_leads2();
1224
+ init_add_leads2();
1225
+ init_delete_leads();
1226
+ init_delete_leads_by_url();
1227
+ init_get_companies();
1228
+ init_get_for_lead2();
1229
+ listCommands = [
1230
+ listsGetCommand,
1231
+ listsListCommand,
1232
+ listsCreateCommand,
1233
+ listsGetLeadsCommand,
1234
+ listsAddLeadsCommand,
1235
+ listsDeleteLeadsCommand,
1236
+ listsDeleteLeadsByUrlCommand,
1237
+ listsGetCompaniesCommand,
1238
+ listsGetForLeadCommand
1239
+ ];
1240
+ }
1241
+ });
1242
+
1243
+ // src/commands/stats/overview.ts
1244
+ import { z as z24 } from "zod";
1245
+ var statsOverviewCommand;
1246
+ var init_overview = __esm({
1247
+ "src/commands/stats/overview.ts"() {
1248
+ "use strict";
1249
+ init_esm_shims();
1250
+ statsOverviewCommand = {
1251
+ name: "stats_overview",
1252
+ group: "stats",
1253
+ subcommand: "overview",
1254
+ description: "Get overall stats with day-by-day breakdown for specified date range.",
1255
+ examples: [
1256
+ "heyreach stats overview --start-date 2025-01-01 --end-date 2025-01-31 --pretty",
1257
+ 'heyreach stats overview --start-date 2025-01-01 --end-date 2025-01-31 --campaign-ids "1,2,3"'
1258
+ ],
1259
+ inputSchema: z24.object({
1260
+ startDate: z24.string().describe("Start date (ISO 8601)"),
1261
+ endDate: z24.string().describe("End date (ISO 8601)"),
1262
+ accountIds: z24.string().optional().describe("Comma-separated LinkedIn account IDs (empty = all)"),
1263
+ campaignIds: z24.string().optional().describe("Comma-separated campaign IDs (empty = all)")
1264
+ }),
1265
+ cliMappings: {
1266
+ options: [
1267
+ { field: "startDate", flags: "--start-date <iso>", description: "Start date (ISO 8601)" },
1268
+ { field: "endDate", flags: "--end-date <iso>", description: "End date (ISO 8601)" },
1269
+ { field: "accountIds", flags: "--account-ids <list>", description: "Comma-separated LinkedIn account IDs" },
1270
+ { field: "campaignIds", flags: "--campaign-ids <list>", description: "Comma-separated campaign IDs" }
1271
+ ]
1272
+ },
1273
+ endpoint: { method: "POST", path: "/stats/GetOverallStats" },
1274
+ fieldMappings: {},
1275
+ handler: async (input, client) => {
1276
+ const body = {
1277
+ startDate: input.startDate,
1278
+ endDate: input.endDate
1279
+ };
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
+ return client.request({ method: "POST", path: "/stats/GetOverallStats", body });
1283
+ }
1284
+ };
1285
+ }
1286
+ });
1287
+
1288
+ // src/commands/stats/index.ts
1289
+ var statsCommands;
1290
+ var init_stats = __esm({
1291
+ "src/commands/stats/index.ts"() {
1292
+ "use strict";
1293
+ init_esm_shims();
1294
+ init_overview();
1295
+ statsCommands = [statsOverviewCommand];
1296
+ }
1297
+ });
1298
+
1299
+ // src/commands/leads/get.ts
1300
+ import { z as z25 } from "zod";
1301
+ var leadsGetCommand;
1302
+ var init_get5 = __esm({
1303
+ "src/commands/leads/get.ts"() {
1304
+ "use strict";
1305
+ init_esm_shims();
1306
+ init_handler();
1307
+ leadsGetCommand = {
1308
+ name: "leads_get",
1309
+ group: "leads",
1310
+ subcommand: "get",
1311
+ description: "Get lead details by LinkedIn profile URL.",
1312
+ examples: ['heyreach leads get --profile-url "https://linkedin.com/in/janedoe" --pretty'],
1313
+ inputSchema: z25.object({
1314
+ profileUrl: z25.string().describe("LinkedIn profile URL")
1315
+ }),
1316
+ cliMappings: {
1317
+ options: [
1318
+ { field: "profileUrl", flags: "--profile-url <url>", description: "LinkedIn profile URL" }
1319
+ ]
1320
+ },
1321
+ endpoint: { method: "POST", path: "/lead/GetLead" },
1322
+ fieldMappings: { profileUrl: "body" },
1323
+ handler: (input, client) => executeCommand(leadsGetCommand, input, client)
1324
+ };
1325
+ }
1326
+ });
1327
+
1328
+ // src/commands/leads/add-tags.ts
1329
+ import { z as z26 } from "zod";
1330
+ var leadsAddTagsCommand;
1331
+ var init_add_tags = __esm({
1332
+ "src/commands/leads/add-tags.ts"() {
1333
+ "use strict";
1334
+ init_esm_shims();
1335
+ leadsAddTagsCommand = {
1336
+ name: "leads_add_tags",
1337
+ group: "leads",
1338
+ subcommand: "add-tags",
1339
+ description: "Add tags to a lead. Existing tags unchanged.",
1340
+ examples: ['heyreach leads add-tags --profile-url "https://linkedin.com/in/jane" --tags "hot,priority" --create-if-missing'],
1341
+ inputSchema: z26.object({
1342
+ tags: z26.string().describe("Comma-separated tag names"),
1343
+ createTagIfNotExisting: z26.coerce.boolean().default(true).describe("Create tag if it does not exist"),
1344
+ leadProfileUrl: z26.string().optional().describe("Lead LinkedIn profile URL"),
1345
+ leadLinkedInId: z26.string().optional().describe("Lead LinkedIn member ID")
1346
+ }),
1347
+ cliMappings: {
1348
+ options: [
1349
+ { field: "tags", flags: "--tags <list>", description: "Comma-separated tag names" },
1350
+ { field: "createTagIfNotExisting", flags: "--create-if-missing", description: "Create tag if it does not exist" },
1351
+ { field: "leadProfileUrl", flags: "--profile-url <url>", description: "Lead LinkedIn profile URL" },
1352
+ { field: "leadLinkedInId", flags: "--linkedin-id <id>", description: "Lead LinkedIn member ID" }
1353
+ ]
1354
+ },
1355
+ endpoint: { method: "POST", path: "/lead/AddTags" },
1356
+ fieldMappings: {},
1357
+ handler: async (input, client) => {
1358
+ const tagList = input.tags.split(",").map((s) => s.trim());
1359
+ const body = {
1360
+ tags: tagList,
1361
+ createTagIfNotExisting: input.createTagIfNotExisting
1362
+ };
1363
+ if (input.leadProfileUrl) body.leadProfileUrl = input.leadProfileUrl;
1364
+ if (input.leadLinkedInId) body.leadLinkedInId = input.leadLinkedInId;
1365
+ return client.request({ method: "POST", path: "/lead/AddTags", body });
1366
+ }
1367
+ };
1368
+ }
1369
+ });
1370
+
1371
+ // src/commands/leads/get-tags.ts
1372
+ import { z as z27 } from "zod";
1373
+ var leadsGetTagsCommand;
1374
+ var init_get_tags = __esm({
1375
+ "src/commands/leads/get-tags.ts"() {
1376
+ "use strict";
1377
+ init_esm_shims();
1378
+ init_handler();
1379
+ leadsGetTagsCommand = {
1380
+ name: "leads_get_tags",
1381
+ group: "leads",
1382
+ subcommand: "get-tags",
1383
+ description: "Get tags for a lead, alphabetically sorted.",
1384
+ examples: ['heyreach leads get-tags --profile-url "https://linkedin.com/in/janedoe"'],
1385
+ inputSchema: z27.object({
1386
+ profileUrl: z27.string().describe("LinkedIn profile URL")
1387
+ }),
1388
+ cliMappings: {
1389
+ options: [
1390
+ { field: "profileUrl", flags: "--profile-url <url>", description: "LinkedIn profile URL" }
1391
+ ]
1392
+ },
1393
+ endpoint: { method: "POST", path: "/lead/GetTags" },
1394
+ fieldMappings: { profileUrl: "body" },
1395
+ handler: (input, client) => executeCommand(leadsGetTagsCommand, input, client)
1396
+ };
1397
+ }
1398
+ });
1399
+
1400
+ // src/commands/leads/replace-tags.ts
1401
+ import { z as z28 } from "zod";
1402
+ var leadsReplaceTagsCommand;
1403
+ var init_replace_tags = __esm({
1404
+ "src/commands/leads/replace-tags.ts"() {
1405
+ "use strict";
1406
+ init_esm_shims();
1407
+ leadsReplaceTagsCommand = {
1408
+ name: "leads_replace_tags",
1409
+ group: "leads",
1410
+ subcommand: "replace-tags",
1411
+ description: "Remove existing tags and replace with new tags.",
1412
+ examples: ['heyreach leads replace-tags --profile-url "https://linkedin.com/in/jane" --tags "vip,enterprise"'],
1413
+ inputSchema: z28.object({
1414
+ tags: z28.string().describe("Comma-separated tag names"),
1415
+ createTagIfNotExisting: z28.coerce.boolean().default(true).describe("Create tag if it does not exist"),
1416
+ leadProfileUrl: z28.string().optional().describe("Lead LinkedIn profile URL"),
1417
+ leadLinkedInId: z28.string().optional().describe("Lead LinkedIn member ID")
1418
+ }),
1419
+ cliMappings: {
1420
+ options: [
1421
+ { field: "tags", flags: "--tags <list>", description: "Comma-separated tag names" },
1422
+ { field: "createTagIfNotExisting", flags: "--create-if-missing", description: "Create tag if it does not exist" },
1423
+ { field: "leadProfileUrl", flags: "--profile-url <url>", description: "Lead LinkedIn profile URL" },
1424
+ { field: "leadLinkedInId", flags: "--linkedin-id <id>", description: "Lead LinkedIn member ID" }
1425
+ ]
1426
+ },
1427
+ endpoint: { method: "POST", path: "/lead/ReplaceTags" },
1428
+ fieldMappings: {},
1429
+ handler: async (input, client) => {
1430
+ const tagList = input.tags.split(",").map((s) => s.trim());
1431
+ const body = {
1432
+ tags: tagList,
1433
+ createTagIfNotExisting: input.createTagIfNotExisting
1434
+ };
1435
+ if (input.leadProfileUrl) body.leadProfileUrl = input.leadProfileUrl;
1436
+ if (input.leadLinkedInId) body.leadLinkedInId = input.leadLinkedInId;
1437
+ return client.request({ method: "POST", path: "/lead/ReplaceTags", body });
1438
+ }
1439
+ };
1440
+ }
1441
+ });
1442
+
1443
+ // src/commands/leads/index.ts
1444
+ var leadCommands;
1445
+ var init_leads = __esm({
1446
+ "src/commands/leads/index.ts"() {
1447
+ "use strict";
1448
+ init_esm_shims();
1449
+ init_get5();
1450
+ init_add_tags();
1451
+ init_get_tags();
1452
+ init_replace_tags();
1453
+ leadCommands = [
1454
+ leadsGetCommand,
1455
+ leadsAddTagsCommand,
1456
+ leadsGetTagsCommand,
1457
+ leadsReplaceTagsCommand
1458
+ ];
1459
+ }
1460
+ });
1461
+
1462
+ // src/commands/lead-tags/create.ts
1463
+ import { z as z29 } from "zod";
1464
+ var leadTagsCreateCommand;
1465
+ var init_create2 = __esm({
1466
+ "src/commands/lead-tags/create.ts"() {
1467
+ "use strict";
1468
+ init_esm_shims();
1469
+ leadTagsCreateCommand = {
1470
+ name: "lead_tags_create",
1471
+ group: "lead-tags",
1472
+ subcommand: "create",
1473
+ description: "Create one or multiple tags for your workspace. Colors: Blue, Green, Purple, Pink, Red, Cyan, Yellow, Orange.",
1474
+ examples: [`heyreach lead-tags create --tags-json '[{"displayName":"VIP","color":"Purple"}]'`],
1475
+ inputSchema: z29.object({
1476
+ tagsJson: z29.string().describe("JSON array of tag objects with displayName and color")
1477
+ }),
1478
+ cliMappings: {
1479
+ options: [
1480
+ { field: "tagsJson", flags: "--tags-json <json>", description: "JSON array of {displayName, color} objects" }
1481
+ ]
1482
+ },
1483
+ endpoint: { method: "POST", path: "/lead_tags/CreateTags" },
1484
+ fieldMappings: {},
1485
+ handler: async (input, client) => {
1486
+ const tags = JSON.parse(input.tagsJson);
1487
+ return client.request({
1488
+ method: "POST",
1489
+ path: "/lead_tags/CreateTags",
1490
+ body: { tags }
1491
+ });
1492
+ }
1493
+ };
1494
+ }
1495
+ });
1496
+
1497
+ // src/commands/lead-tags/index.ts
1498
+ var leadTagCommands;
1499
+ var init_lead_tags = __esm({
1500
+ "src/commands/lead-tags/index.ts"() {
1501
+ "use strict";
1502
+ init_esm_shims();
1503
+ init_create2();
1504
+ leadTagCommands = [leadTagsCreateCommand];
1505
+ }
1506
+ });
1507
+
1508
+ // src/commands/webhooks/create.ts
1509
+ import { z as z30 } from "zod";
1510
+ var webhooksCreateCommand;
1511
+ var init_create3 = __esm({
1512
+ "src/commands/webhooks/create.ts"() {
1513
+ "use strict";
1514
+ init_esm_shims();
1515
+ webhooksCreateCommand = {
1516
+ name: "webhooks_create",
1517
+ group: "webhooks",
1518
+ subcommand: "create",
1519
+ description: "Create a webhook. Event types: CONNECTION_REQUEST_SENT, CONNECTION_REQUEST_ACCEPTED, MESSAGE_SENT, MESSAGE_REPLY_RECEIVED, INMAIL_SENT, INMAIL_REPLY_RECEIVED, EVERY_MESSAGE_REPLY_RECEIVED, FOLLOW_SENT, LIKED_POST, VIEWED_PROFILE, CAMPAIGN_COMPLETED, LEAD_TAG_UPDATED.",
1520
+ examples: ['heyreach webhooks create --name "Replies" --url "https://example.com/hook" --event-type MESSAGE_REPLY_RECEIVED'],
1521
+ inputSchema: z30.object({
1522
+ webhookName: z30.string().describe("Webhook name"),
1523
+ webhookUrl: z30.string().describe("Webhook URL"),
1524
+ eventType: z30.string().describe("Event type"),
1525
+ campaignIds: z30.string().optional().describe("Comma-separated campaign IDs (empty = all)")
1526
+ }),
1527
+ cliMappings: {
1528
+ options: [
1529
+ { field: "webhookName", flags: "--name <name>", description: "Webhook name" },
1530
+ { field: "webhookUrl", flags: "--url <url>", description: "Webhook URL" },
1531
+ { field: "eventType", flags: "--event-type <type>", description: "Event type" },
1532
+ { field: "campaignIds", flags: "--campaign-ids <list>", description: "Comma-separated campaign IDs" }
1533
+ ]
1534
+ },
1535
+ endpoint: { method: "POST", path: "/webhooks/CreateWebhook" },
1536
+ fieldMappings: {},
1537
+ handler: async (input, client) => {
1538
+ const body = {
1539
+ webhookName: input.webhookName,
1540
+ webhookUrl: input.webhookUrl,
1541
+ eventType: input.eventType
1542
+ };
1543
+ if (input.campaignIds) body.campaignIds = input.campaignIds.split(",").map((s) => Number(s.trim()));
1544
+ return client.request({ method: "POST", path: "/webhooks/CreateWebhook", body });
1545
+ }
1546
+ };
1547
+ }
1548
+ });
1549
+
1550
+ // src/commands/webhooks/get.ts
1551
+ import { z as z31 } from "zod";
1552
+ var webhooksGetCommand;
1553
+ var init_get6 = __esm({
1554
+ "src/commands/webhooks/get.ts"() {
1555
+ "use strict";
1556
+ init_esm_shims();
1557
+ init_handler();
1558
+ webhooksGetCommand = {
1559
+ name: "webhooks_get",
1560
+ group: "webhooks",
1561
+ subcommand: "get",
1562
+ description: "Get a webhook by ID.",
1563
+ examples: ["heyreach webhooks get --webhook-id 123 --pretty"],
1564
+ inputSchema: z31.object({
1565
+ webhookId: z31.coerce.number().describe("Webhook ID")
1566
+ }),
1567
+ cliMappings: {
1568
+ options: [
1569
+ { field: "webhookId", flags: "--webhook-id <id>", description: "Webhook ID" }
1570
+ ]
1571
+ },
1572
+ endpoint: { method: "GET", path: "/webhooks/GetWebhookById" },
1573
+ fieldMappings: { webhookId: "query" },
1574
+ handler: (input, client) => executeCommand(webhooksGetCommand, input, client)
1575
+ };
1576
+ }
1577
+ });
1578
+
1579
+ // src/commands/webhooks/list.ts
1580
+ import { z as z32 } from "zod";
1581
+ var webhooksListCommand;
1582
+ var init_list5 = __esm({
1583
+ "src/commands/webhooks/list.ts"() {
1584
+ "use strict";
1585
+ init_esm_shims();
1586
+ init_handler();
1587
+ webhooksListCommand = {
1588
+ name: "webhooks_list",
1589
+ group: "webhooks",
1590
+ subcommand: "list",
1591
+ description: "Get all webhooks.",
1592
+ examples: ["heyreach webhooks list --pretty"],
1593
+ inputSchema: z32.object({
1594
+ offset: z32.coerce.number().default(0).describe("Pagination offset"),
1595
+ limit: z32.coerce.number().min(1).max(100).default(100).describe("Items per page")
1596
+ }),
1597
+ cliMappings: {
1598
+ options: [
1599
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
1600
+ { field: "limit", flags: "--limit <number>", description: "Items per page" }
1601
+ ]
1602
+ },
1603
+ endpoint: { method: "POST", path: "/webhooks/GetAllWebhooks" },
1604
+ fieldMappings: { offset: "body", limit: "body" },
1605
+ handler: (input, client) => executeCommand(webhooksListCommand, input, client)
1606
+ };
1607
+ }
1608
+ });
1609
+
1610
+ // src/commands/webhooks/update.ts
1611
+ import { z as z33 } from "zod";
1612
+ var webhooksUpdateCommand;
1613
+ var init_update = __esm({
1614
+ "src/commands/webhooks/update.ts"() {
1615
+ "use strict";
1616
+ init_esm_shims();
1617
+ webhooksUpdateCommand = {
1618
+ name: "webhooks_update",
1619
+ group: "webhooks",
1620
+ subcommand: "update",
1621
+ description: "Update an existing webhook. Only provided fields are changed.",
1622
+ examples: ['heyreach webhooks update --webhook-id 123 --name "Updated Name" --active false'],
1623
+ inputSchema: z33.object({
1624
+ webhookId: z33.coerce.number().describe("Webhook ID"),
1625
+ webhookName: z33.string().optional().describe("New webhook name"),
1626
+ webhookUrl: z33.string().optional().describe("New webhook URL"),
1627
+ eventType: z33.string().optional().describe("New event type"),
1628
+ campaignIds: z33.string().optional().describe("Comma-separated campaign IDs"),
1629
+ isActive: z33.string().optional().describe("Active status: true/false")
1630
+ }),
1631
+ cliMappings: {
1632
+ options: [
1633
+ { field: "webhookId", flags: "--webhook-id <id>", description: "Webhook ID" },
1634
+ { field: "webhookName", flags: "--name <name>", description: "New webhook name" },
1635
+ { field: "webhookUrl", flags: "--url <url>", description: "New webhook URL" },
1636
+ { field: "eventType", flags: "--event-type <type>", description: "New event type" },
1637
+ { field: "campaignIds", flags: "--campaign-ids <list>", description: "Comma-separated campaign IDs" },
1638
+ { field: "isActive", flags: "--active <bool>", description: "Active status (true/false)" }
1639
+ ]
1640
+ },
1641
+ endpoint: { method: "PATCH", path: "/webhooks/UpdateWebhook" },
1642
+ fieldMappings: {},
1643
+ handler: async (input, client) => {
1644
+ const body = {};
1645
+ if (input.webhookName !== void 0) body.webhookName = input.webhookName;
1646
+ if (input.webhookUrl !== void 0) body.webhookUrl = input.webhookUrl;
1647
+ if (input.eventType !== void 0) body.eventType = input.eventType;
1648
+ if (input.campaignIds !== void 0) body.campaignIds = input.campaignIds.split(",").map((s) => Number(s.trim()));
1649
+ if (input.isActive !== void 0) body.isActive = input.isActive === "true";
1650
+ return client.request({
1651
+ method: "PATCH",
1652
+ path: "/webhooks/UpdateWebhook",
1653
+ query: { webhookId: input.webhookId },
1654
+ body
1655
+ });
1656
+ }
1657
+ };
1658
+ }
1659
+ });
1660
+
1661
+ // src/commands/webhooks/delete.ts
1662
+ import { z as z34 } from "zod";
1663
+ var webhooksDeleteCommand;
1664
+ var init_delete = __esm({
1665
+ "src/commands/webhooks/delete.ts"() {
1666
+ "use strict";
1667
+ init_esm_shims();
1668
+ init_handler();
1669
+ webhooksDeleteCommand = {
1670
+ name: "webhooks_delete",
1671
+ group: "webhooks",
1672
+ subcommand: "delete",
1673
+ description: "Delete a webhook.",
1674
+ examples: ["heyreach webhooks delete --webhook-id 123"],
1675
+ inputSchema: z34.object({
1676
+ webhookId: z34.coerce.number().describe("Webhook ID")
1677
+ }),
1678
+ cliMappings: {
1679
+ options: [
1680
+ { field: "webhookId", flags: "--webhook-id <id>", description: "Webhook ID" }
1681
+ ]
1682
+ },
1683
+ endpoint: { method: "DELETE", path: "/webhooks/DeleteWebhook" },
1684
+ fieldMappings: { webhookId: "query" },
1685
+ handler: (input, client) => executeCommand(webhooksDeleteCommand, input, client)
1686
+ };
1687
+ }
1688
+ });
1689
+
1690
+ // src/commands/webhooks/index.ts
1691
+ var webhookCommands;
1692
+ var init_webhooks = __esm({
1693
+ "src/commands/webhooks/index.ts"() {
1694
+ "use strict";
1695
+ init_esm_shims();
1696
+ init_create3();
1697
+ init_get6();
1698
+ init_list5();
1699
+ init_update();
1700
+ init_delete();
1701
+ webhookCommands = [
1702
+ webhooksCreateCommand,
1703
+ webhooksGetCommand,
1704
+ webhooksListCommand,
1705
+ webhooksUpdateCommand,
1706
+ webhooksDeleteCommand
1707
+ ];
1708
+ }
1709
+ });
1710
+
1711
+ // src/commands/network/list.ts
1712
+ import { z as z35 } from "zod";
1713
+ var networkListCommand;
1714
+ var init_list6 = __esm({
1715
+ "src/commands/network/list.ts"() {
1716
+ "use strict";
1717
+ init_esm_shims();
1718
+ init_handler();
1719
+ networkListCommand = {
1720
+ name: "network_list",
1721
+ group: "network",
1722
+ subcommand: "list",
1723
+ description: "Get paginated network connections for a LinkedIn sender. Uses pageNumber/pageSize pagination.",
1724
+ examples: ["heyreach network list --sender-id 123 --pretty"],
1725
+ inputSchema: z35.object({
1726
+ senderId: z35.coerce.number().describe("LinkedIn sender account ID"),
1727
+ pageNumber: z35.coerce.number().default(1).describe("Page number (starts at 1)"),
1728
+ pageSize: z35.coerce.number().min(1).max(100).default(100).describe("Page size")
1729
+ }),
1730
+ cliMappings: {
1731
+ options: [
1732
+ { field: "senderId", flags: "--sender-id <id>", description: "LinkedIn sender account ID" },
1733
+ { field: "pageNumber", flags: "--page <number>", description: "Page number" },
1734
+ { field: "pageSize", flags: "--page-size <number>", description: "Page size" }
1735
+ ]
1736
+ },
1737
+ endpoint: { method: "POST", path: "/MyNetwork/GetMyNetworkForSender" },
1738
+ fieldMappings: { senderId: "body", pageNumber: "body", pageSize: "body" },
1739
+ handler: (input, client) => executeCommand(networkListCommand, input, client)
1740
+ };
1741
+ }
1742
+ });
1743
+
1744
+ // src/commands/network/check.ts
1745
+ import { z as z36 } from "zod";
1746
+ var networkCheckCommand;
1747
+ var init_check = __esm({
1748
+ "src/commands/network/check.ts"() {
1749
+ "use strict";
1750
+ init_esm_shims();
1751
+ networkCheckCommand = {
1752
+ name: "network_check",
1753
+ group: "network",
1754
+ subcommand: "check",
1755
+ description: "Check if a lead is a connection of a sender. Provide exactly one of --profile-url or --linkedin-id.",
1756
+ examples: [
1757
+ 'heyreach network check --sender-id 123 --profile-url "https://linkedin.com/in/janedoe"',
1758
+ 'heyreach network check --sender-id 123 --linkedin-id "ABC123"'
1759
+ ],
1760
+ inputSchema: z36.object({
1761
+ senderAccountId: z36.coerce.number().describe("LinkedIn sender account ID"),
1762
+ leadProfileUrl: z36.string().optional().describe("Lead LinkedIn profile URL"),
1763
+ leadLinkedInId: z36.string().optional().describe("Lead LinkedIn member ID")
1764
+ }),
1765
+ cliMappings: {
1766
+ options: [
1767
+ { field: "senderAccountId", flags: "--sender-id <id>", description: "LinkedIn sender account ID" },
1768
+ { field: "leadProfileUrl", flags: "--profile-url <url>", description: "Lead LinkedIn profile URL" },
1769
+ { field: "leadLinkedInId", flags: "--linkedin-id <id>", description: "Lead LinkedIn member ID" }
1770
+ ]
1771
+ },
1772
+ endpoint: { method: "POST", path: "/MyNetwork/IsConnection" },
1773
+ fieldMappings: { senderAccountId: "body", leadProfileUrl: "body", leadLinkedInId: "body" },
1774
+ handler: async (input, client) => {
1775
+ const body = { senderAccountId: input.senderAccountId };
1776
+ if (input.leadProfileUrl) body.leadProfileUrl = input.leadProfileUrl;
1777
+ if (input.leadLinkedInId) body.leadLinkedInId = input.leadLinkedInId;
1778
+ return client.request({ method: "POST", path: "/MyNetwork/IsConnection", body });
1779
+ }
1780
+ };
1781
+ }
1782
+ });
1783
+
1784
+ // src/commands/network/index.ts
1785
+ var networkCommands;
1786
+ var init_network = __esm({
1787
+ "src/commands/network/index.ts"() {
1788
+ "use strict";
1789
+ init_esm_shims();
1790
+ init_list6();
1791
+ init_check();
1792
+ networkCommands = [
1793
+ networkListCommand,
1794
+ networkCheckCommand
1795
+ ];
1796
+ }
1797
+ });
1798
+
1799
+ // src/commands/org/api-keys.ts
1800
+ import { z as z37 } from "zod";
1801
+ var orgApiKeysCommand;
1802
+ var init_api_keys = __esm({
1803
+ "src/commands/org/api-keys.ts"() {
1804
+ "use strict";
1805
+ init_esm_shims();
1806
+ orgApiKeysCommand = {
1807
+ name: "org_api_keys",
1808
+ group: "org",
1809
+ subcommand: "api-keys",
1810
+ description: "Get API/integration keys for a workspace (requires Organization API key).",
1811
+ examples: ["heyreach org api-keys --workspace-id 123 --pretty"],
1812
+ inputSchema: z37.object({
1813
+ workspaceId: z37.coerce.number().describe("Workspace ID")
1814
+ }),
1815
+ cliMappings: {
1816
+ options: [
1817
+ { field: "workspaceId", flags: "--workspace-id <id>", description: "Workspace ID" }
1818
+ ]
1819
+ },
1820
+ endpoint: { method: "GET", path: "/management/organizations/api-keys/workspaces/{workspaceId}" },
1821
+ fieldMappings: { workspaceId: "path" },
1822
+ handler: async (input, client) => {
1823
+ return client.request({
1824
+ method: "GET",
1825
+ path: `/management/organizations/api-keys/workspaces/${encodeURIComponent(String(input.workspaceId))}`
1826
+ });
1827
+ }
1828
+ };
1829
+ }
1830
+ });
1831
+
1832
+ // src/commands/org/create-api-key.ts
1833
+ import { z as z38 } from "zod";
1834
+ var orgCreateApiKeyCommand;
1835
+ var init_create_api_key = __esm({
1836
+ "src/commands/org/create-api-key.ts"() {
1837
+ "use strict";
1838
+ init_esm_shims();
1839
+ orgCreateApiKeyCommand = {
1840
+ name: "org_create_api_key",
1841
+ group: "org",
1842
+ subcommand: "create-api-key",
1843
+ description: "Generate a new API/integration key for a workspace. Types: PUBLIC, N8N, MAKE, ZAPIER, MCP.",
1844
+ examples: ["heyreach org create-api-key --workspace-id 123 --type PUBLIC"],
1845
+ inputSchema: z38.object({
1846
+ workspaceId: z38.coerce.number().describe("Workspace ID"),
1847
+ apiKeyType: z38.string().describe("Key type: PUBLIC, N8N, MAKE, ZAPIER, MCP")
1848
+ }),
1849
+ cliMappings: {
1850
+ options: [
1851
+ { field: "workspaceId", flags: "--workspace-id <id>", description: "Workspace ID" },
1852
+ { field: "apiKeyType", flags: "--type <type>", description: "Key type: PUBLIC, N8N, MAKE, ZAPIER, MCP" }
1853
+ ]
1854
+ },
1855
+ endpoint: { method: "POST", path: "/management/organizations/api-keys/workspaces/{workspaceId}" },
1856
+ fieldMappings: {},
1857
+ handler: async (input, client) => {
1858
+ return client.request({
1859
+ method: "POST",
1860
+ path: `/management/organizations/api-keys/workspaces/${encodeURIComponent(String(input.workspaceId))}`,
1861
+ body: { apiKeyType: input.apiKeyType }
1862
+ });
1863
+ }
1864
+ };
1865
+ }
1866
+ });
1867
+
1868
+ // src/commands/org/workspaces.ts
1869
+ import { z as z39 } from "zod";
1870
+ var orgWorkspacesCommand;
1871
+ var init_workspaces = __esm({
1872
+ "src/commands/org/workspaces.ts"() {
1873
+ "use strict";
1874
+ init_esm_shims();
1875
+ orgWorkspacesCommand = {
1876
+ name: "org_workspaces",
1877
+ group: "org",
1878
+ subcommand: "workspaces",
1879
+ description: "List all workspaces in your organization (requires Organization API key).",
1880
+ examples: ["heyreach org workspaces --pretty"],
1881
+ inputSchema: z39.object({
1882
+ Offset: z39.coerce.number().default(0).describe("Pagination offset"),
1883
+ Limit: z39.coerce.number().min(1).max(100).default(100).describe("Items per page")
1884
+ }),
1885
+ cliMappings: {
1886
+ options: [
1887
+ { field: "Offset", flags: "--offset <number>", description: "Pagination offset" },
1888
+ { field: "Limit", flags: "--limit <number>", description: "Items per page" }
1889
+ ]
1890
+ },
1891
+ endpoint: { method: "GET", path: "/management/organizations/workspaces" },
1892
+ fieldMappings: { Offset: "query", Limit: "query" },
1893
+ handler: async (input, client) => {
1894
+ return client.request({
1895
+ method: "GET",
1896
+ path: "/management/organizations/workspaces",
1897
+ query: { Offset: input.Offset, Limit: input.Limit }
1898
+ });
1899
+ }
1900
+ };
1901
+ }
1902
+ });
1903
+
1904
+ // src/commands/org/create-workspace.ts
1905
+ import { z as z40 } from "zod";
1906
+ var orgCreateWorkspaceCommand;
1907
+ var init_create_workspace = __esm({
1908
+ "src/commands/org/create-workspace.ts"() {
1909
+ "use strict";
1910
+ init_esm_shims();
1911
+ init_handler();
1912
+ orgCreateWorkspaceCommand = {
1913
+ name: "org_create_workspace",
1914
+ group: "org",
1915
+ subcommand: "create-workspace",
1916
+ description: "Create a new workspace in your organization.",
1917
+ examples: ['heyreach org create-workspace --name "Sales Team" --seats-limit 10'],
1918
+ inputSchema: z40.object({
1919
+ workspaceName: z40.string().describe("Workspace name"),
1920
+ seatsLimit: z40.coerce.number().optional().describe("Seat limit (null = unlimited)")
1921
+ }),
1922
+ cliMappings: {
1923
+ options: [
1924
+ { field: "workspaceName", flags: "--name <name>", description: "Workspace name" },
1925
+ { field: "seatsLimit", flags: "--seats-limit <number>", description: "Seat limit" }
1926
+ ]
1927
+ },
1928
+ endpoint: { method: "POST", path: "/management/organizations/workspaces" },
1929
+ fieldMappings: { workspaceName: "body", seatsLimit: "body" },
1930
+ handler: (input, client) => executeCommand(orgCreateWorkspaceCommand, input, client)
1931
+ };
1932
+ }
1933
+ });
1934
+
1935
+ // src/commands/org/update-workspace.ts
1936
+ import { z as z41 } from "zod";
1937
+ var orgUpdateWorkspaceCommand;
1938
+ var init_update_workspace = __esm({
1939
+ "src/commands/org/update-workspace.ts"() {
1940
+ "use strict";
1941
+ init_esm_shims();
1942
+ orgUpdateWorkspaceCommand = {
1943
+ name: "org_update_workspace",
1944
+ group: "org",
1945
+ subcommand: "update-workspace",
1946
+ description: "Update a workspace in your organization.",
1947
+ examples: ['heyreach org update-workspace --workspace-id 123 --name "New Name" --seats-limit 20'],
1948
+ inputSchema: z41.object({
1949
+ workspaceId: z41.coerce.number().describe("Workspace ID"),
1950
+ workspaceName: z41.string().optional().describe("New workspace name"),
1951
+ seatsLimit: z41.coerce.number().optional().describe("New seat limit")
1952
+ }),
1953
+ cliMappings: {
1954
+ options: [
1955
+ { field: "workspaceId", flags: "--workspace-id <id>", description: "Workspace ID" },
1956
+ { field: "workspaceName", flags: "--name <name>", description: "New workspace name" },
1957
+ { field: "seatsLimit", flags: "--seats-limit <number>", description: "New seat limit" }
1958
+ ]
1959
+ },
1960
+ endpoint: { method: "PATCH", path: "/management/organizations/workspaces/{workspaceId}" },
1961
+ fieldMappings: {},
1962
+ handler: async (input, client) => {
1963
+ const body = {};
1964
+ if (input.workspaceName !== void 0) body.workspaceName = input.workspaceName;
1965
+ if (input.seatsLimit !== void 0) body.seatsLimit = { value: input.seatsLimit };
1966
+ return client.request({
1967
+ method: "PATCH",
1968
+ path: `/management/organizations/workspaces/${encodeURIComponent(String(input.workspaceId))}`,
1969
+ body
1970
+ });
1971
+ }
1972
+ };
1973
+ }
1974
+ });
1975
+
1976
+ // src/commands/org/users.ts
1977
+ import { z as z42 } from "zod";
1978
+ var orgUsersCommand;
1979
+ var init_users = __esm({
1980
+ "src/commands/org/users.ts"() {
1981
+ "use strict";
1982
+ init_esm_shims();
1983
+ orgUsersCommand = {
1984
+ name: "org_users",
1985
+ group: "org",
1986
+ subcommand: "users",
1987
+ description: "Get all existing and invited users in your organization.",
1988
+ examples: ["heyreach org users --pretty", "heyreach org users --role Admin"],
1989
+ inputSchema: z42.object({
1990
+ offset: z42.coerce.number().default(0).describe("Pagination offset"),
1991
+ limit: z42.coerce.number().min(1).max(100).default(100).describe("Items per page"),
1992
+ role: z42.string().optional().describe("Filter by role: Admin, Member, Manager"),
1993
+ invitationStatus: z42.string().optional().describe("Comma-separated statuses: Accepted, Pending, Expired, Revoked")
1994
+ }),
1995
+ cliMappings: {
1996
+ options: [
1997
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
1998
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
1999
+ { field: "role", flags: "--role <role>", description: "Filter by role" },
2000
+ { field: "invitationStatus", flags: "--invitation-status <list>", description: "Comma-separated invitation statuses" }
2001
+ ]
2002
+ },
2003
+ endpoint: { method: "POST", path: "/management/organizations/users" },
2004
+ fieldMappings: {},
2005
+ handler: async (input, client) => {
2006
+ const body = { offset: input.offset, limit: input.limit };
2007
+ if (input.role) body.role = input.role;
2008
+ if (input.invitationStatus) body.invitationStatus = input.invitationStatus.split(",").map((s) => s.trim());
2009
+ return client.request({ method: "POST", path: "/management/organizations/users", body });
2010
+ }
2011
+ };
2012
+ }
2013
+ });
2014
+
2015
+ // src/commands/org/get-user.ts
2016
+ import { z as z43 } from "zod";
2017
+ var orgGetUserCommand;
2018
+ var init_get_user = __esm({
2019
+ "src/commands/org/get-user.ts"() {
2020
+ "use strict";
2021
+ init_esm_shims();
2022
+ orgGetUserCommand = {
2023
+ name: "org_get_user",
2024
+ group: "org",
2025
+ subcommand: "get-user",
2026
+ description: "Get information about a user by ID.",
2027
+ examples: ["heyreach org get-user --user-id 456 --pretty"],
2028
+ inputSchema: z43.object({
2029
+ userId: z43.coerce.number().describe("User ID")
2030
+ }),
2031
+ cliMappings: {
2032
+ options: [
2033
+ { field: "userId", flags: "--user-id <id>", description: "User ID" }
2034
+ ]
2035
+ },
2036
+ endpoint: { method: "GET", path: "/management/organizations/users/{userId}" },
2037
+ fieldMappings: { userId: "path" },
2038
+ handler: async (input, client) => {
2039
+ return client.request({
2040
+ method: "GET",
2041
+ path: `/management/organizations/users/${encodeURIComponent(String(input.userId))}`
2042
+ });
2043
+ }
2044
+ };
2045
+ }
2046
+ });
2047
+
2048
+ // src/commands/org/workspace-users.ts
2049
+ import { z as z44 } from "zod";
2050
+ var orgWorkspaceUsersCommand;
2051
+ var init_workspace_users = __esm({
2052
+ "src/commands/org/workspace-users.ts"() {
2053
+ "use strict";
2054
+ init_esm_shims();
2055
+ orgWorkspaceUsersCommand = {
2056
+ name: "org_workspace_users",
2057
+ group: "org",
2058
+ subcommand: "workspace-users",
2059
+ description: "Get all users in a given workspace with role and permissions.",
2060
+ examples: ["heyreach org workspace-users --workspace-id 123 --pretty"],
2061
+ inputSchema: z44.object({
2062
+ workspaceId: z44.coerce.number().describe("Workspace ID"),
2063
+ offset: z44.coerce.number().default(0).describe("Pagination offset"),
2064
+ limit: z44.coerce.number().min(1).max(100).default(100).describe("Items per page"),
2065
+ role: z44.string().optional().describe("Filter by role"),
2066
+ invitationStatus: z44.string().optional().describe("Comma-separated invitation statuses")
2067
+ }),
2068
+ cliMappings: {
2069
+ options: [
2070
+ { field: "workspaceId", flags: "--workspace-id <id>", description: "Workspace ID" },
2071
+ { field: "offset", flags: "--offset <number>", description: "Pagination offset" },
2072
+ { field: "limit", flags: "--limit <number>", description: "Items per page" },
2073
+ { field: "role", flags: "--role <role>", description: "Filter by role" },
2074
+ { field: "invitationStatus", flags: "--invitation-status <list>", description: "Comma-separated invitation statuses" }
2075
+ ]
2076
+ },
2077
+ endpoint: { method: "POST", path: "/management/organizations/users/workspaces/{workspaceId}" },
2078
+ fieldMappings: {},
2079
+ handler: async (input, client) => {
2080
+ const body = { offset: input.offset, limit: input.limit };
2081
+ if (input.role) body.role = input.role;
2082
+ if (input.invitationStatus) body.invitationStatus = input.invitationStatus.split(",").map((s) => s.trim());
2083
+ return client.request({
2084
+ method: "POST",
2085
+ path: `/management/organizations/users/workspaces/${encodeURIComponent(String(input.workspaceId))}`,
2086
+ body
2087
+ });
2088
+ }
2089
+ };
2090
+ }
2091
+ });
2092
+
2093
+ // src/commands/org/invite-admins.ts
2094
+ import { z as z45 } from "zod";
2095
+ var orgInviteAdminsCommand;
2096
+ var init_invite_admins = __esm({
2097
+ "src/commands/org/invite-admins.ts"() {
2098
+ "use strict";
2099
+ init_esm_shims();
2100
+ orgInviteAdminsCommand = {
2101
+ name: "org_invite_admins",
2102
+ group: "org",
2103
+ subcommand: "invite-admins",
2104
+ description: "Invite users as organization admins. Returns invitation URLs (no email sent).",
2105
+ examples: ['heyreach org invite-admins --inviter-email "admin@co.com" --emails "user1@co.com,user2@co.com"'],
2106
+ inputSchema: z45.object({
2107
+ inviterEmail: z45.string().describe("Email of the inviter"),
2108
+ emails: z45.string().describe("Comma-separated emails to invite")
2109
+ }),
2110
+ cliMappings: {
2111
+ options: [
2112
+ { field: "inviterEmail", flags: "--inviter-email <email>", description: "Inviter email" },
2113
+ { field: "emails", flags: "--emails <list>", description: "Comma-separated emails" }
2114
+ ]
2115
+ },
2116
+ endpoint: { method: "POST", path: "/management/organizations/users/invite/admins" },
2117
+ fieldMappings: {},
2118
+ handler: async (input, client) => {
2119
+ return client.request({
2120
+ method: "POST",
2121
+ path: "/management/organizations/users/invite/admins",
2122
+ body: {
2123
+ inviterEmail: input.inviterEmail,
2124
+ emails: input.emails.split(",").map((s) => s.trim())
2125
+ }
2126
+ });
2127
+ }
2128
+ };
2129
+ }
2130
+ });
2131
+
2132
+ // src/commands/org/invite-members.ts
2133
+ import { z as z46 } from "zod";
2134
+ var orgInviteMembersCommand;
2135
+ var init_invite_members = __esm({
2136
+ "src/commands/org/invite-members.ts"() {
2137
+ "use strict";
2138
+ init_esm_shims();
2139
+ orgInviteMembersCommand = {
2140
+ name: "org_invite_members",
2141
+ group: "org",
2142
+ subcommand: "invite-members",
2143
+ description: "Invite users as members with specified workspace permissions. Returns invitation URLs (no email sent).",
2144
+ examples: [`heyreach org invite-members --inviter-email "admin@co.com" --emails "user@co.com" --workspace-ids "1,2" --permissions-json '{"viewCampaigns":true}'`],
2145
+ inputSchema: z46.object({
2146
+ inviterEmail: z46.string().describe("Email of the inviter"),
2147
+ emails: z46.string().describe("Comma-separated emails to invite"),
2148
+ workspaceIds: z46.string().describe("Comma-separated workspace IDs"),
2149
+ permissionsJson: z46.string().describe("JSON object of permission booleans")
2150
+ }),
2151
+ cliMappings: {
2152
+ options: [
2153
+ { field: "inviterEmail", flags: "--inviter-email <email>", description: "Inviter email" },
2154
+ { field: "emails", flags: "--emails <list>", description: "Comma-separated emails" },
2155
+ { field: "workspaceIds", flags: "--workspace-ids <list>", description: "Comma-separated workspace IDs" },
2156
+ { field: "permissionsJson", flags: "--permissions-json <json>", description: "JSON permissions object" }
2157
+ ]
2158
+ },
2159
+ endpoint: { method: "POST", path: "/management/organizations/users/invite/members" },
2160
+ fieldMappings: {},
2161
+ handler: async (input, client) => {
2162
+ return client.request({
2163
+ method: "POST",
2164
+ path: "/management/organizations/users/invite/members",
2165
+ body: {
2166
+ inviterEmail: input.inviterEmail,
2167
+ emails: input.emails.split(",").map((s) => s.trim()),
2168
+ workspaceIds: input.workspaceIds.split(",").map((s) => Number(s.trim())),
2169
+ permissions: JSON.parse(input.permissionsJson)
2170
+ }
2171
+ });
2172
+ }
2173
+ };
2174
+ }
2175
+ });
2176
+
2177
+ // src/commands/org/invite-managers.ts
2178
+ import { z as z47 } from "zod";
2179
+ var orgInviteManagersCommand;
2180
+ var init_invite_managers = __esm({
2181
+ "src/commands/org/invite-managers.ts"() {
2182
+ "use strict";
2183
+ init_esm_shims();
2184
+ orgInviteManagersCommand = {
2185
+ name: "org_invite_managers",
2186
+ group: "org",
2187
+ subcommand: "invite-managers",
2188
+ description: "Invite users as managers (external users with workspace access, auto-added without registration).",
2189
+ examples: ['heyreach org invite-managers --inviter-email "admin@co.com" --emails "manager@co.com" --workspace-ids "1,2"'],
2190
+ inputSchema: z47.object({
2191
+ inviterEmail: z47.string().describe("Email of the inviter"),
2192
+ emails: z47.string().describe("Comma-separated emails to invite"),
2193
+ workspaceIds: z47.string().describe("Comma-separated workspace IDs")
2194
+ }),
2195
+ cliMappings: {
2196
+ options: [
2197
+ { field: "inviterEmail", flags: "--inviter-email <email>", description: "Inviter email" },
2198
+ { field: "emails", flags: "--emails <list>", description: "Comma-separated emails" },
2199
+ { field: "workspaceIds", flags: "--workspace-ids <list>", description: "Comma-separated workspace IDs" }
2200
+ ]
2201
+ },
2202
+ endpoint: { method: "POST", path: "/management/organizations/users/invite/managers" },
2203
+ fieldMappings: {},
2204
+ handler: async (input, client) => {
2205
+ return client.request({
2206
+ method: "POST",
2207
+ path: "/management/organizations/users/invite/managers",
2208
+ body: {
2209
+ inviterEmail: input.inviterEmail,
2210
+ emails: input.emails.split(",").map((s) => s.trim()),
2211
+ workspaceIds: input.workspaceIds.split(",").map((s) => Number(s.trim()))
2212
+ }
2213
+ });
2214
+ }
2215
+ };
2216
+ }
2217
+ });
2218
+
2219
+ // src/commands/org/index.ts
2220
+ var orgCommands;
2221
+ var init_org = __esm({
2222
+ "src/commands/org/index.ts"() {
2223
+ "use strict";
2224
+ init_esm_shims();
2225
+ init_api_keys();
2226
+ init_create_api_key();
2227
+ init_workspaces();
2228
+ init_create_workspace();
2229
+ init_update_workspace();
2230
+ init_users();
2231
+ init_get_user();
2232
+ init_workspace_users();
2233
+ init_invite_admins();
2234
+ init_invite_members();
2235
+ init_invite_managers();
2236
+ orgCommands = [
2237
+ orgApiKeysCommand,
2238
+ orgCreateApiKeyCommand,
2239
+ orgWorkspacesCommand,
2240
+ orgCreateWorkspaceCommand,
2241
+ orgUpdateWorkspaceCommand,
2242
+ orgUsersCommand,
2243
+ orgGetUserCommand,
2244
+ orgWorkspaceUsersCommand,
2245
+ orgInviteAdminsCommand,
2246
+ orgInviteMembersCommand,
2247
+ orgInviteManagersCommand
2248
+ ];
2249
+ }
2250
+ });
2251
+
2252
+ // src/commands/index.ts
2253
+ import { createInterface } from "readline/promises";
2254
+ var allCommands;
2255
+ var init_commands = __esm({
2256
+ "src/commands/index.ts"() {
2257
+ "use strict";
2258
+ init_esm_shims();
2259
+ init_auth();
2260
+ init_client();
2261
+ init_config();
2262
+ init_output();
2263
+ init_errors();
2264
+ init_campaigns();
2265
+ init_inbox();
2266
+ init_accounts();
2267
+ init_lists();
2268
+ init_stats();
2269
+ init_leads();
2270
+ init_lead_tags();
2271
+ init_webhooks();
2272
+ init_network();
2273
+ init_org();
2274
+ allCommands = [
2275
+ ...campaignCommands,
2276
+ ...inboxCommands,
2277
+ ...accountCommands,
2278
+ ...listCommands,
2279
+ ...statsCommands,
2280
+ ...leadCommands,
2281
+ ...leadTagCommands,
2282
+ ...webhookCommands,
2283
+ ...networkCommands,
2284
+ ...orgCommands
2285
+ ];
2286
+ }
2287
+ });
2288
+
2289
+ // src/mcp-entry.ts
2290
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2291
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
2292
+ async function startMcpFromCli() {
2293
+ const auth = resolveAuth();
2294
+ const client = createClient(auth);
2295
+ const server = new McpServer({
2296
+ name: "heyreach",
2297
+ version: "0.1.0"
2298
+ });
2299
+ for (const cmdDef of allCommands) {
2300
+ const zodShape = {};
2301
+ const shape = cmdDef.inputSchema.shape;
2302
+ for (const [key, val] of Object.entries(shape)) {
2303
+ zodShape[key] = val;
2304
+ }
2305
+ server.tool(
2306
+ cmdDef.name,
2307
+ cmdDef.description,
2308
+ zodShape,
2309
+ async (args) => {
2310
+ try {
2311
+ const parsed = cmdDef.inputSchema.safeParse(args);
2312
+ if (!parsed.success) {
2313
+ return {
2314
+ content: [
2315
+ {
2316
+ type: "text",
2317
+ text: JSON.stringify({ error: parsed.error.message, code: "VALIDATION_ERROR" })
2318
+ }
2319
+ ],
2320
+ isError: true
2321
+ };
2322
+ }
2323
+ const result = await cmdDef.handler(parsed.data, client);
2324
+ return {
2325
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
2326
+ };
2327
+ } catch (error) {
2328
+ return {
2329
+ content: [
2330
+ { type: "text", text: JSON.stringify(formatError(error)) }
2331
+ ],
2332
+ isError: true
2333
+ };
2334
+ }
2335
+ }
2336
+ );
2337
+ }
2338
+ const transport = new StdioServerTransport();
2339
+ await server.connect(transport);
2340
+ }
2341
+ var init_mcp_entry = __esm({
2342
+ "src/mcp-entry.ts"() {
2343
+ "use strict";
2344
+ init_esm_shims();
2345
+ init_commands();
2346
+ init_auth();
2347
+ init_client();
2348
+ init_errors();
2349
+ }
2350
+ });
2351
+
2352
+ // src/mcp.ts
2353
+ init_esm_shims();
2354
+ init_mcp_entry();
2355
+ startMcpFromCli().catch((err) => {
2356
+ console.error("Failed to start MCP server:", err);
2357
+ process.exit(1);
2358
+ });
2359
+ //# sourceMappingURL=mcp.js.map