consulti 0.0.1 → 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/errors.js ADDED
@@ -0,0 +1,35 @@
1
+ import { EXIT } from "./exit-codes.js";
2
+ /** Every failure path throws this; the top level prints it as one JSON object on stderr. */
3
+ export class CliError extends Error {
4
+ exit;
5
+ code;
6
+ status;
7
+ retryAfter;
8
+ creditsUsed;
9
+ hint;
10
+ extra;
11
+ constructor(init) {
12
+ super(init.error);
13
+ this.exit = init.exit;
14
+ this.code = init.code ?? null;
15
+ this.status = init.status ?? null;
16
+ this.retryAfter = init.retryAfter ?? null;
17
+ this.creditsUsed = init.creditsUsed ?? null;
18
+ this.hint = init.hint ?? null;
19
+ this.extra = init.extra ?? {};
20
+ }
21
+ toJSON() {
22
+ return {
23
+ error: this.message,
24
+ code: this.code,
25
+ status: this.status,
26
+ retry_after: this.retryAfter,
27
+ credits_used: this.creditsUsed,
28
+ hint: this.hint,
29
+ ...this.extra,
30
+ };
31
+ }
32
+ }
33
+ export function usageError(message, code = "usage", hint) {
34
+ return new CliError({ exit: EXIT.usage, error: message, code, hint });
35
+ }
@@ -0,0 +1,31 @@
1
+ export const EXIT = {
2
+ ok: 0,
3
+ unexpected: 1,
4
+ usage: 2,
5
+ auth: 3,
6
+ plan: 4,
7
+ unavailable: 5,
8
+ network: 6,
9
+ };
10
+ // Canonical text: .omc/team/consulti-cli/exit-table.md. The README carries the same wording.
11
+ export const EXIT_TABLE = [
12
+ [0, "Success."],
13
+ [1, "Unexpected error, including HTTP 404 and any 5xx other than 502, 503 and 504. On a billable command, run consulti credits before retrying."],
14
+ [2, "Usage or validation: a missing or bad flag, a bad path argument, or HTTP 400 or 422 from the API."],
15
+ [3, "Auth: no key, a malformed key (code invalid_key_format, from CONSULTI_API_KEY, the saved file or consulti login), or HTTP 401."],
16
+ [4, "Plan or credits: HTTP 402, or a 403 with a JSON body."],
17
+ [5, "Rate limited, unavailable or blocked: HTTP 429 or 503 (retry_after is set when the server sends one), or a 403 or 429 with a non-JSON body, which means the request was blocked before it reached the API (code blocked)."],
18
+ [6, "Network error or timeout, including a 502 or 504 with a non-JSON body (code gateway_timeout). On a billable command, run consulti credits before retrying."],
19
+ ];
20
+ /** Maps an HTTP error status to a CLI exit code. */
21
+ export function exitForStatus(status) {
22
+ if (status === 400 || status === 422)
23
+ return EXIT.usage;
24
+ if (status === 401)
25
+ return EXIT.auth;
26
+ if (status === 402 || status === 403)
27
+ return EXIT.plan;
28
+ if (status === 429 || status === 503)
29
+ return EXIT.unavailable;
30
+ return EXIT.unexpected;
31
+ }
package/dist/flags.js ADDED
@@ -0,0 +1,53 @@
1
+ import { InvalidArgumentError, Option } from "commander";
2
+ /** `businessIds` and `linkedin_url` become `--business-ids` and `--linkedin-url`. */
3
+ export function flagName(name) {
4
+ return name
5
+ .replace(/_/g, "-")
6
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
7
+ .toLowerCase();
8
+ }
9
+ function toNumber(value) {
10
+ const trimmed = value.trim();
11
+ const n = Number(trimmed);
12
+ if (!/^-?\d+(\.\d+)?$/.test(trimmed) || !Number.isFinite(n)) {
13
+ throw new InvalidArgumentError(`"${value}" is not a number.`);
14
+ }
15
+ return n;
16
+ }
17
+ function collect(convert) {
18
+ return (value, previous) => {
19
+ const parts = value
20
+ .split(",")
21
+ .map((part) => part.trim())
22
+ .filter((part) => part !== "");
23
+ if (parts.length === 0)
24
+ throw new InvalidArgumentError("expected at least one value.");
25
+ return [...(previous ?? []), ...parts.map(convert)];
26
+ };
27
+ }
28
+ function describe(p) {
29
+ const text = p.desc.replace(/\s+/g, " ").trim();
30
+ const note = p.type.endsWith("[]") ? "; repeat the flag or use commas, and use --body for values that contain commas" : "";
31
+ return `${text} [${p.type}${p.required ? ", required" : ""}${note}]`;
32
+ }
33
+ /** Commander options for one param. Booleans get `--flag` and `--no-flag`. */
34
+ export function optionsFor(p) {
35
+ const flag = `--${flagName(p.name)}`;
36
+ const desc = describe(p);
37
+ switch (p.type) {
38
+ case "string":
39
+ return [new Option(`${flag} <value>`, desc)];
40
+ case "number":
41
+ return [new Option(`${flag} <number>`, desc).argParser(toNumber)];
42
+ case "string[]":
43
+ return [new Option(`${flag} <values>`, desc).argParser(collect((v) => v))];
44
+ case "number[]":
45
+ return [new Option(`${flag} <numbers>`, desc).argParser(collect(toNumber))];
46
+ case "boolean":
47
+ return [new Option(flag, desc), new Option(`--no-${flagName(p.name)}`, `Same as ${flag} false.`)];
48
+ }
49
+ }
50
+ /** The attribute commander stores a param's value under. */
51
+ export function attributeFor(p) {
52
+ return optionsFor(p)[0].attributeName();
53
+ }
@@ -0,0 +1,465 @@
1
+ {
2
+ "source": "lib/api/endpoints-data.ts",
3
+ "endpoints": [
4
+ {
5
+ "id": "verify",
6
+ "method": "POST",
7
+ "path": "/verify",
8
+ "title": "Verify email",
9
+ "description": "Verify whether an email address is valid and deliverable. Uses SMTP checks.",
10
+ "tier": "any",
11
+ "credits": "Only successful verifications are billed — 1 verification credit each. Requests that fail validation (400) or auth (401), or hit insufficient credits (402), are never billed and return credits_used: 0. Results served from our cache cost the same as fresh ones. When the verifier does not answer in time or is temporarily unavailable, the call returns 503 with code verifier_unavailable, credits_used: 0 and a Retry-After header in seconds. The 503 is sent only after the reserved credit is confirmed refunded. Retry after Retry-After only when credits_used: 0 is present. If the refund cannot be confirmed, the call returns 500 with code refund_unconfirmed and no Retry-After. Reconcile with GET /credits before retrying, because a retry reserves another credit.",
12
+ "noAuth": false,
13
+ "billable": true,
14
+ "inMcp": true,
15
+ "pathParams": [],
16
+ "params": [
17
+ {
18
+ "name": "email",
19
+ "type": "string",
20
+ "required": true,
21
+ "desc": "Email address to verify. Leading/trailing whitespace is trimmed automatically before validation."
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "id": "verify-catchall",
27
+ "method": "POST",
28
+ "path": "/verify/catchall",
29
+ "title": "Verify catch-all mailbox",
30
+ "description": "Resolve whether a specific mailbox on a catch-all domain actually exists. Unlike /verify (SMTP), this uses Consulti’s ESP verification engine to probe mailbox existence, with an automatic fallback for providers the engine doesn’t cover. Use it on addresses that /verify reports as is_catch_all=true.",
31
+ "tier": "pro+",
32
+ "credits": "Only successful verifications are billed — 5 verification credits each. Requests that fail validation (400) or auth (401), or hit insufficient credits (402), are never billed and return credits_used: 0. That includes an address that passes the format check but is rejected as malformed during verification: it returns 400 \"Invalid email address.\" and the reserved credits are refunded. Results served from our cache cost the same as fresh ones. When the verification engine does not return a verdict in time, the call returns 503 with code verifier_unavailable and a Retry-After header in seconds. The reserved credits are refunded, but this 503 carries no credits_used, so check GET /credits before you retry.",
33
+ "noAuth": false,
34
+ "billable": true,
35
+ "inMcp": true,
36
+ "pathParams": [],
37
+ "params": [
38
+ {
39
+ "name": "email",
40
+ "type": "string",
41
+ "required": true,
42
+ "desc": "Email address on a catch-all domain to resolve. Leading/trailing whitespace is trimmed automatically before validation."
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "id": "credits",
48
+ "method": "GET",
49
+ "path": "/credits",
50
+ "title": "Get current credit balance",
51
+ "description": "Return the authenticated API user’s current lead and verification credit balances. Useful as a pre-flight check before running a large search/enrich batch.",
52
+ "tier": "any",
53
+ "credits": "Free — no deduction.",
54
+ "noAuth": false,
55
+ "billable": false,
56
+ "inMcp": true,
57
+ "pathParams": [],
58
+ "params": []
59
+ },
60
+ {
61
+ "id": "meta-filter",
62
+ "method": "GET",
63
+ "path": "/meta/{filter}",
64
+ "title": "Get canonical values for a filter",
65
+ "description": "Return the canonical list of values accepted by a given enum filter. No auth required. Snapshot-first with a 1-hour edge cache that revalidates against the live database. Use slug \"_all\" to fetch every filter in one snapshot-only payload.",
66
+ "tier": "any",
67
+ "credits": "Free. No auth required.",
68
+ "noAuth": true,
69
+ "billable": false,
70
+ "inMcp": false,
71
+ "pathParams": [
72
+ "filter"
73
+ ],
74
+ "params": []
75
+ },
76
+ {
77
+ "id": "enrich",
78
+ "method": "POST",
79
+ "path": "/leads/enrich",
80
+ "title": "Enrich lead by email",
81
+ "description": "Given an email address, return the full enriched B2B lead profile, including a company object (funding, traffic, HQ, followers, specialties) when the lead is linked to a company.",
82
+ "tier": "pro+",
83
+ "credits": "1 lead credit — only deducted on a successful match.",
84
+ "noAuth": false,
85
+ "billable": true,
86
+ "inMcp": true,
87
+ "pathParams": [],
88
+ "params": [
89
+ {
90
+ "name": "email",
91
+ "type": "string",
92
+ "required": true,
93
+ "desc": "Work email address"
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ "id": "enrich-linkedin",
99
+ "method": "POST",
100
+ "path": "/enrich/linkedin",
101
+ "title": "Enrich by LinkedIn URL (live)",
102
+ "description": "Enrich a person by their LinkedIn profile URL → a verified work email plus their US mobile phone as a free add-on. Cache-first: served instantly from our database when we already hold a verified email for that profile, otherwise enriched live via the provider and cached for next time.",
103
+ "tier": "pro+",
104
+ "credits": "1 lead credit — charged only when an email is returned. Phone is a free add-on; phone-only or no-email responses are free.",
105
+ "noAuth": false,
106
+ "billable": true,
107
+ "inMcp": true,
108
+ "pathParams": [],
109
+ "params": [
110
+ {
111
+ "name": "linkedin_url",
112
+ "type": "string",
113
+ "required": true,
114
+ "desc": "LinkedIn profile URL (e.g. https://linkedin.com/in/johndoe)"
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ "id": "leads-search",
120
+ "method": "POST",
121
+ "path": "/leads/search",
122
+ "title": "Search B2B leads",
123
+ "description": "Search the B2B lead database with filters on title, industry, location, company size, and more. Results are always restricted to leads carrying our verified email label — there is no option to include unverified leads.",
124
+ "tier": "pro+",
125
+ "credits": "1 lead credit per result returned. Reserved up to `size`, then refunded down to the actual row count. 0 results = 0 credits. A retried request is a new billable search. An `Idempotency-Key` header is accepted but has no effect at present, so de-duplicate on your side rather than relying on replay. A 503 means the search could not run right now: code search_unavailable when the database was busy or a connection dropped, and code search_timeout when the query ran too long, so narrow the filters. Both carry a Retry-After header in seconds. The reserved credits are refunded, but the body has no credits_used, so check GET /credits before you retry.",
126
+ "noAuth": false,
127
+ "billable": true,
128
+ "inMcp": true,
129
+ "pathParams": [],
130
+ "params": [
131
+ {
132
+ "name": "q",
133
+ "type": "string",
134
+ "required": false,
135
+ "desc": "Free-text search across job title, company name, and industry only. Does not match person names; use POST /leads/find-by-name for that (Beta, REST-only)."
136
+ },
137
+ {
138
+ "name": "titles",
139
+ "type": "string[]",
140
+ "required": false,
141
+ "desc": "Job titles to match (e.g. [\"CEO\", \"CTO\"])"
142
+ },
143
+ {
144
+ "name": "industries",
145
+ "type": "string[]",
146
+ "required": false,
147
+ "desc": "Industries (case-sensitive exact match). See GET /api/v1/meta/industries for the full canonical list."
148
+ },
149
+ {
150
+ "name": "technologies",
151
+ "type": "string[]",
152
+ "required": false,
153
+ "desc": "Technologies the company’s website uses, exact Wappalyzer-style names (e.g. [\"Shopify\", \"HubSpot\"]). OR-matched: a lead matches if it uses any listed technology. Max 25. See GET /api/v1/meta/technologies for the canonical list."
154
+ },
155
+ {
156
+ "name": "excludeTechnologies",
157
+ "type": "string[]",
158
+ "required": false,
159
+ "desc": "Technologies to exclude, same Wappalyzer-style names. A lead is dropped if its company uses any listed technology; leads with no technology data are kept. Max 25."
160
+ },
161
+ {
162
+ "name": "countries",
163
+ "type": "string[]",
164
+ "required": false,
165
+ "desc": "Countries. Alias-group members are equivalent (e.g. \"United States\" and \"US\"). See GET /api/v1/meta/countries."
166
+ },
167
+ {
168
+ "name": "states",
169
+ "type": "string[]",
170
+ "required": false,
171
+ "desc": "States/regions. Alias-group members are equivalent (e.g. \"Ontario\" and \"ON\"). See GET /api/v1/meta/states."
172
+ },
173
+ {
174
+ "name": "cities",
175
+ "type": "string[]",
176
+ "required": false,
177
+ "desc": "Cities to match"
178
+ },
179
+ {
180
+ "name": "company",
181
+ "type": "string",
182
+ "required": false,
183
+ "desc": "Company name substring"
184
+ },
185
+ {
186
+ "name": "empMin",
187
+ "type": "number",
188
+ "required": false,
189
+ "desc": "Minimum employee count"
190
+ },
191
+ {
192
+ "name": "empMax",
193
+ "type": "number",
194
+ "required": false,
195
+ "desc": "Maximum employee count"
196
+ },
197
+ {
198
+ "name": "revenueMin",
199
+ "type": "number",
200
+ "required": false,
201
+ "desc": "Minimum annual revenue in USD, whole dollars. Leads with no revenue data on file are excluded when either bound is set. Must be less than or equal to revenueMax when both are set."
202
+ },
203
+ {
204
+ "name": "revenueMax",
205
+ "type": "number",
206
+ "required": false,
207
+ "desc": "Maximum annual revenue in USD, whole dollars. Leads with no revenue data on file are excluded when either bound is set. Must be greater than or equal to revenueMin when both are set."
208
+ },
209
+ {
210
+ "name": "excludeTitles",
211
+ "type": "string[]",
212
+ "required": false,
213
+ "desc": "Job titles to exclude. A lead is dropped if its job title matches any listed value. Max 25."
214
+ },
215
+ {
216
+ "name": "excludeListId",
217
+ "type": "string",
218
+ "required": false,
219
+ "desc": "UUID of a saved list you own, and it must be a LEAD list (the kind created by POST /lists with kind \"lead\"). Business, podcast, YouTube and Instagram lists hold no lead emails; passing one returns 400 rather than silently excluding nothing. GET /lists reports the kind of each list. Leads whose email is on that list are removed from the result set before billing, so excluded leads never cost credits. Because exclusion is applied in the query, request `page: 1` on every call and add each batch you receive to the list with POST /lists/{id}/add-leads — paging forward while excluding skips leads. Returns 400 if the list does not exist or is not owned by the API key holder."
220
+ },
221
+ {
222
+ "name": "page",
223
+ "type": "number",
224
+ "required": false,
225
+ "desc": "Page number (default: 1). When using excludeListId, keep this at 1 and grow the list instead."
226
+ },
227
+ {
228
+ "name": "size",
229
+ "type": "number",
230
+ "required": false,
231
+ "desc": "Results per page, max 100 (default: 25)"
232
+ }
233
+ ]
234
+ },
235
+ {
236
+ "id": "instagram-search",
237
+ "method": "POST",
238
+ "path": "/instagram/search",
239
+ "title": "Search Instagram profiles",
240
+ "description": "Search a database of Instagram profiles with filters on follower count, category, location, account type, and email data quality. Results can be filtered by verification status; all listed filters are optional. Pagination depth is capped at 100,000 results to prevent deep-offset performance issues.",
241
+ "tier": "pro+",
242
+ "credits": "1 lead credit per result returned. Reserved up to `size`, then refunded down to the actual row count. 0 results = 0 credits.",
243
+ "noAuth": false,
244
+ "billable": true,
245
+ "inMcp": true,
246
+ "pathParams": [],
247
+ "params": [
248
+ {
249
+ "name": "q",
250
+ "type": "string",
251
+ "required": false,
252
+ "desc": "Free-text search across username and bio"
253
+ },
254
+ {
255
+ "name": "bioKeywords",
256
+ "type": "string[]",
257
+ "required": false,
258
+ "desc": "Keywords to search for in profile bios"
259
+ },
260
+ {
261
+ "name": "excludeKeywords",
262
+ "type": "string[]",
263
+ "required": false,
264
+ "desc": "Exclude profiles whose bio contains any of these keywords"
265
+ },
266
+ {
267
+ "name": "excludeAdultContent",
268
+ "type": "boolean",
269
+ "required": false,
270
+ "desc": "Exclude profiles with adult/sexual content terms in their bio"
271
+ },
272
+ {
273
+ "name": "followerMin",
274
+ "type": "number",
275
+ "required": false,
276
+ "desc": "Minimum follower count"
277
+ },
278
+ {
279
+ "name": "followerMax",
280
+ "type": "number",
281
+ "required": false,
282
+ "desc": "Maximum follower count"
283
+ },
284
+ {
285
+ "name": "followingMin",
286
+ "type": "number",
287
+ "required": false,
288
+ "desc": "Minimum following count"
289
+ },
290
+ {
291
+ "name": "followingMax",
292
+ "type": "number",
293
+ "required": false,
294
+ "desc": "Maximum following count"
295
+ },
296
+ {
297
+ "name": "postsMin",
298
+ "type": "number",
299
+ "required": false,
300
+ "desc": "Minimum post count"
301
+ },
302
+ {
303
+ "name": "postsMax",
304
+ "type": "number",
305
+ "required": false,
306
+ "desc": "Maximum post count"
307
+ },
308
+ {
309
+ "name": "categories",
310
+ "type": "string[]",
311
+ "required": false,
312
+ "desc": "Categories to filter by. See GET /api/v1/meta/instagram-categories for the canonical list."
313
+ },
314
+ {
315
+ "name": "countries",
316
+ "type": "string[]",
317
+ "required": false,
318
+ "desc": "Countries to filter by (exact match). See GET /api/v1/meta/instagram-countries for the canonical list."
319
+ },
320
+ {
321
+ "name": "accountTypes",
322
+ "type": "string[]",
323
+ "required": false,
324
+ "desc": "Account types to filter by (e.g. [\"business\", \"personal\"]). See GET /api/v1/meta/instagram-account-types for valid values."
325
+ },
326
+ {
327
+ "name": "emailStatus",
328
+ "type": "string[]",
329
+ "required": false,
330
+ "desc": "Email verification status to filter by (e.g. [\"good\", \"risky\", \"bad\", \"catch_all\"]). See GET /api/v1/meta/instagram-email-statuses for valid values."
331
+ },
332
+ {
333
+ "name": "verified",
334
+ "type": "boolean",
335
+ "required": false,
336
+ "desc": "Filter to only verified accounts"
337
+ },
338
+ {
339
+ "name": "hasEmail",
340
+ "type": "boolean",
341
+ "required": false,
342
+ "desc": "Filter to only accounts with an email on file. Use emailStatus to filter by verification quality."
343
+ },
344
+ {
345
+ "name": "hasPhone",
346
+ "type": "boolean",
347
+ "required": false,
348
+ "desc": "Filter to only accounts with a phone number"
349
+ },
350
+ {
351
+ "name": "hasWebsite",
352
+ "type": "boolean",
353
+ "required": false,
354
+ "desc": "Filter to only accounts with a website"
355
+ },
356
+ {
357
+ "name": "excludeListId",
358
+ "type": "string",
359
+ "required": false,
360
+ "desc": "UUID of a saved list you own, and it must be an Instagram list (kind \"instagram\"). GET /lists reports the kind of each list. Profiles on that list are removed from the result set before billing, so excluded rows never cost credits. A blank or malformed id, a list that does not exist or is not yours, and a list of another kind each return 400. A list with more than 100,000 members returns 422 (code exclusion_too_large), and a temporary lookup failure returns 503 (code list_resolution_unavailable). All of these are returned before anything is reserved, with credits_used: 0."
361
+ },
362
+ {
363
+ "name": "sortBy",
364
+ "type": "string",
365
+ "required": false,
366
+ "desc": "Field to sort by (followers, posts, engagement, username)"
367
+ },
368
+ {
369
+ "name": "sortOrder",
370
+ "type": "string",
371
+ "required": false,
372
+ "desc": "Sort order (asc or desc)"
373
+ },
374
+ {
375
+ "name": "page",
376
+ "type": "number",
377
+ "required": false,
378
+ "desc": "Page number (default: 1). Keep (page - 1) * size ≤ 100,000 to avoid deep-offset performance issues."
379
+ },
380
+ {
381
+ "name": "size",
382
+ "type": "number",
383
+ "required": false,
384
+ "desc": "Results per page, max 100 (default: 25)"
385
+ }
386
+ ]
387
+ },
388
+ {
389
+ "id": "lists-get",
390
+ "method": "GET",
391
+ "path": "/lists",
392
+ "title": "Get saved lists",
393
+ "description": "Return all saved lead lists owned by the authenticated API user, with member counts.",
394
+ "tier": "pro+",
395
+ "credits": "Free.",
396
+ "noAuth": false,
397
+ "billable": false,
398
+ "inMcp": true,
399
+ "pathParams": [],
400
+ "params": []
401
+ },
402
+ {
403
+ "id": "lists-create",
404
+ "method": "POST",
405
+ "path": "/lists",
406
+ "title": "Create a list",
407
+ "description": "Create a new saved lead list.",
408
+ "tier": "pro+",
409
+ "credits": "Free.",
410
+ "noAuth": false,
411
+ "billable": false,
412
+ "inMcp": true,
413
+ "pathParams": [],
414
+ "params": [
415
+ {
416
+ "name": "name",
417
+ "type": "string",
418
+ "required": true,
419
+ "desc": "List name"
420
+ },
421
+ {
422
+ "name": "description",
423
+ "type": "string",
424
+ "required": false,
425
+ "desc": "Optional description"
426
+ },
427
+ {
428
+ "name": "kind",
429
+ "type": "string",
430
+ "required": false,
431
+ "desc": "List kind: lead (B2B), business (local), podcast, youtube, or instagram (default: lead)"
432
+ }
433
+ ]
434
+ },
435
+ {
436
+ "id": "lists-add-leads",
437
+ "method": "POST",
438
+ "path": "/lists/{id}/add-leads",
439
+ "title": "Add leads to a list",
440
+ "description": "Add members to a saved list by email (B2B leads) or business ID (local leads). Duplicates are ignored. The payload must match the list's kind: send emails to a kind=\"lead\" list and businessIds to a kind=\"business\" list. A mismatch on a list that already has members is rejected with 400 LIST_KIND_MISMATCH and nothing is written; an empty list takes the kind of its first payload. Create the list with the matching kind first. Send only one of the two arrays per call.",
441
+ "tier": "pro+",
442
+ "credits": "B2B email saves are free. Business IDs cost 1 lead credit per newly unlocked business with usable email data. IDs already unlocked by your account, including successful paid local searches, cost 0 additional credits. Duplicate IDs and businesses without email data do not cost credits.",
443
+ "noAuth": false,
444
+ "billable": true,
445
+ "inMcp": true,
446
+ "pathParams": [
447
+ "id"
448
+ ],
449
+ "params": [
450
+ {
451
+ "name": "emails",
452
+ "type": "string[]",
453
+ "required": false,
454
+ "desc": "Array of B2B lead emails. Requires a list with kind=\"lead\""
455
+ },
456
+ {
457
+ "name": "businessIds",
458
+ "type": "number[]",
459
+ "required": false,
460
+ "desc": "Up to 50,000 local business IDs. Requires a list with kind=\"business\". Unpurchased IDs can consume lead credits."
461
+ }
462
+ ]
463
+ }
464
+ ]
465
+ }
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { homedir } from "node:os";
4
+ import { packageVersion, run } from "./cli.js";
5
+ function readStdin() {
6
+ return new Promise((resolve, reject) => {
7
+ let data = "";
8
+ process.stdin.setEncoding("utf8");
9
+ process.stdin.on("data", (chunk) => (data += chunk));
10
+ process.stdin.on("end", () => resolve(data));
11
+ process.stdin.on("error", reject);
12
+ });
13
+ }
14
+ /** Reads a line from the terminal with echo off. */
15
+ function readSecret(prompt) {
16
+ return new Promise((resolve, reject) => {
17
+ const stdin = process.stdin;
18
+ process.stderr.write(prompt);
19
+ stdin.setRawMode(true);
20
+ stdin.resume();
21
+ stdin.setEncoding("utf8");
22
+ let value = "";
23
+ const finish = (err) => {
24
+ stdin.setRawMode(false);
25
+ stdin.pause();
26
+ stdin.removeListener("data", onData);
27
+ process.stderr.write("\n");
28
+ if (err)
29
+ reject(err);
30
+ else
31
+ resolve(value);
32
+ };
33
+ const onData = (chunk) => {
34
+ for (const ch of chunk) {
35
+ if (ch === "\r" || ch === "\n" || ch === "\u0004")
36
+ return finish();
37
+ if (ch === "\u0003")
38
+ return finish(new Error("Cancelled."));
39
+ if (ch === "\u007f" || ch === "\b")
40
+ value = value.slice(0, -1);
41
+ else
42
+ value += ch;
43
+ }
44
+ };
45
+ stdin.on("data", onData);
46
+ });
47
+ }
48
+ function openUrl(url) {
49
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : null;
50
+ if (!cmd)
51
+ return;
52
+ try {
53
+ const child = spawn(cmd, [url], { stdio: "ignore", detached: true });
54
+ child.on("error", () => { });
55
+ child.unref();
56
+ }
57
+ catch {
58
+ // Best effort: the URL is already printed.
59
+ }
60
+ }
61
+ // `consulti ... | head -1` closes the pipe early: that is not an error.
62
+ process.stdout.on("error", (e) => {
63
+ if (e.code === "EPIPE")
64
+ process.exit(0);
65
+ throw e;
66
+ });
67
+ const io = {
68
+ out: (text) => void process.stdout.write(text),
69
+ err: (text) => void process.stderr.write(text),
70
+ outIsTTY: process.stdout.isTTY === true,
71
+ inIsTTY: process.stdin.isTTY === true,
72
+ readStdin,
73
+ readSecret,
74
+ openUrl,
75
+ };
76
+ const ctx = { env: process.env, io, fetch, version: packageVersion(), homedir: homedir() };
77
+ process.exitCode = await run(process.argv.slice(2), ctx);