@leadsetsai/sdk 0.1.1 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@ All notable changes to this package are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.2.1] - 2026-11-22
8
+
9
+ ### Changed
10
+
11
+ - Published from GitHub Actions with npm trusted publishing (OIDC) and provenance, without a
12
+ long-lived npm token. No changes to the package itself.
13
+
14
+ ## [0.2.0] - 2026-11-19
15
+
16
+ ### Added
17
+
18
+ - `companies.search`: `keywords` and `exclude_keywords`, matched as whole words in the company's
19
+ name, description and specialties. Companies carry `specialties` and `email_domain`.
20
+ - `people.search`: `company_keywords` and `exclude_company_keywords` (what the person's company does),
21
+ `match_headline` (title words also match the LinkedIn headline) and `priorities` with
22
+ `company_linkedin_url`: the best contacts at one company, in your order of preference, each
23
+ tagged with `priority`. People carry `headline`; the response carries `company` with `priorities`.
24
+ - `people.count` and `companies.count`: how many records match (`count`, `count_capped`), using no
25
+ records.
26
+ - `Usage.limits` and `Usage.resets_at`: the limits behind the remaining counts, and when each window
27
+ resets.
28
+
7
29
  ## [0.1.1] - 2026-11-11
8
30
 
9
31
  ### Changed
@@ -25,4 +47,7 @@ All notable changes to this package are documented here. The format follows
25
47
  - Parsed rate-limit headers on `lastResponse.rateLimit`.
26
48
  - ESM and CommonJS builds with type declarations; no runtime dependencies.
27
49
 
50
+ [0.2.1]: https://github.com/leadsets/sdk/releases/tag/v0.2.1
51
+ [0.2.0]: https://github.com/leadsets/sdk/releases/tag/v0.2.0
52
+ [0.1.1]: https://github.com/leadsets/sdk/releases/tag/v0.1.1
28
53
  [0.1.0]: https://github.com/leadsets/sdk/releases/tag/v0.1.0
package/README.md CHANGED
@@ -99,7 +99,26 @@ Every method takes an optional last argument with [request options](#per-request
99
99
 
100
100
  ### People search
101
101
 
102
- Filters: `title`, `seniority` (`c_level`, `vp`, `head`, `director`, `manager`, `ic`), `function` (`revenue`, `marketing`, `engineering`, `product`, `ops`, `finance`, `hr`), `company_domain`, `employees` (`"50-200"`, `"1000+"`, `"<50"`), `industry` (slugs such as `"saas"`), `country` (ISO 3166-1 alpha-2), `has_verified_email`, `max_age_days`, `exclude_stale`, `limit` (1–100, default 25) and `cursor`. A string or an array works wherever a list is accepted.
102
+ Filters: `title` (add `match_headline: true` to also match the LinkedIn headline), `seniority` (`c_level`, `vp`, `head`, `director`, `manager`, `ic`), `function` (`revenue`, `marketing`, `engineering`, `product`, `ops`, `finance`, `hr`), `company_domain`, `company_keywords` / `exclude_company_keywords` (what their company does), `employees` (`"50-200"`, `"1000+"`, `"<50"`), `industry` (slugs such as `"saas"`), `country` (ISO 3166-1 alpha-2), `has_verified_email`, `max_age_days`, `exclude_stale`, `limit` (1–100, default 25) and `cursor`. A string or an array works wherever a list is accepted.
103
+
104
+ Count before you pull, for free, and find the best contacts at one company in your order of preference:
105
+
106
+ ```ts
107
+ const { count } = await ls.companies.count({
108
+ keywords: ['clay', 'gtm engineering'],
109
+ exclude_keywords: ['pottery'],
110
+ country: 'US',
111
+ })
112
+
113
+ const res = await ls.people.search({
114
+ company_domain: 'northwind.io',
115
+ priorities: [{ title: ['founder', 'ceo'], match_headline: true }, { title: ['head of growth', 'vp sales'] }],
116
+ limit: 3,
117
+ })
118
+ for (const p of res.items) console.log(p.priority, p.full_name, p.email?.address)
119
+ ```
120
+
121
+ `companies.search` also takes `keywords` and `exclude_keywords`: whole words in the company's name, description and specialties.
103
122
 
104
123
  ```ts
105
124
  const res = await ls.people.search({
package/dist/index.cjs CHANGED
@@ -102,7 +102,7 @@ function parseRetryAfter(v, now = Date.now()) {
102
102
  }
103
103
 
104
104
  // src/version.ts
105
- var VERSION = "0.1.1";
105
+ var VERSION = "0.2.1";
106
106
 
107
107
  // src/core.ts
108
108
  var DEFAULT_BASE_URL = "https://api.leadsets.ai";
@@ -342,6 +342,16 @@ var Companies = class {
342
342
  search(params = {}, options) {
343
343
  return this.http.request({ method: "POST", path: "/companies/search", body: params, idempotent: true }, options);
344
344
  }
345
+ /**
346
+ * POST /v1/companies/search with `count_only`: how many companies match, without returning them.
347
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
348
+ */
349
+ count(params = {}, options) {
350
+ return this.http.request(
351
+ { method: "POST", path: "/companies/search", body: { ...params, count_only: true }, idempotent: true },
352
+ options
353
+ );
354
+ }
345
355
  /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */
346
356
  searchAll(params = {}, options) {
347
357
  return items(this.searchPages(params, options));
@@ -392,6 +402,16 @@ var People = class {
392
402
  search(params = {}, options) {
393
403
  return this.http.request({ method: "POST", path: "/people/search", body: params, idempotent: true }, options);
394
404
  }
405
+ /**
406
+ * POST /v1/people/search with `count_only`: how many people match, without returning them.
407
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
408
+ */
409
+ count(params = {}, options) {
410
+ return this.http.request(
411
+ { method: "POST", path: "/people/search", body: { ...params, count_only: true }, idempotent: true },
412
+ options
413
+ );
414
+ }
395
415
  /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */
396
416
  searchAll(params = {}, options) {
397
417
  return items(this.searchPages(params, options));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/version.ts","../src/core.ts","../src/pagination.ts","../src/resources/companies.ts","../src/resources/emails.ts","../src/resources/jobs.ts","../src/resources/people.ts","../src/resources/scrape.ts","../src/resources/usage.ts","../src/client.ts"],"names":[],"mappings":";;;AA+BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAIvC,WAAA,CAAY,OAAA,EAAiB,SAAA,GAA2B,IAAA,EAAM,OAAA,EAA+B;AAC3F,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,I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,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,IAAI,OAAA,EAAkD;AACpD,IAAA,OAAO,IAAA,CAAK,KAAK,OAAA,CAAQ,EAAE,QAAQ,KAAA,EAAO,IAAA,EAAM,QAAA,EAAS,EAAG,OAAO,CAAA;AAAA,EACrE;AACF,CAAA;;;ACMO,IAAM,WAAN,MAAe;AAAA,EAUpB,WAAA,CAAY,MAAA,EAAiC,OAAA,GAAyB,EAAC,EAAG;AACxE,IAAA,MAAM,IAAA,GACJ,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,KAAW,IAAA,GAAO,MAAA,GAAS,EAAE,GAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,IAAU,QAAQ,MAAA,EAAO;AAC1G,IAAA,MAAM,IAAA,GAAO,IAAI,UAAA,CAAW,IAAI,CAAA;AAChC,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,MAAA,CAAO,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,SAAA,CAAU,IAAI,CAAA;AACnC,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,MAAA,CAAO,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,MAAA,CAAO,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,IAAA,CAAK,IAAI,CAAA;AACzB,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAI,CAAA;AAAA,EACrC;AACF","file":"index.cjs","sourcesContent":["/**\n * Error hierarchy.\n *\n * LeadsetsError\n * ├── APIError the API answered with an error status\n * │ ├── InvalidRequestError 400 invalid_request\n * │ ├── AuthenticationError 401 unauthorized\n * │ ├── PaymentRequiredError 402\n * │ │ ├── FreeRecordsExhaustedError free_records_exhausted\n * │ │ └── ScrapeUnitsExhaustedError scrape_units_exhausted\n * │ ├── PermissionDeniedError 403 forbidden (upgradeUrl)\n * │ ├── NotFoundError 404 not_found\n * │ ├── IdempotencyConflictError 409 idempotency_conflict\n * │ ├── RateLimitError 429 window_full, weekly_limit, too_many_concurrent\n * │ └── InternalServerError 5xx internal_error\n * │ └── ServiceUnavailableError 503 unavailable\n * └── APIConnectionError the request never got an answer\n * └── APITimeoutError ...because it timed out\n */\n\nexport interface ErrorBody {\n type?: string\n message?: string\n param?: string\n meter?: string\n resets_at?: string\n upgrade_url?: string\n charged?: number\n [key: string]: unknown\n}\n\nexport class LeadsetsError extends Error {\n /** The request_id of the failed call, when the API returned one. */\n readonly requestId: string | null\n\n constructor(message: string, requestId: string | null = null, options?: { cause?: unknown }) {\n super(message, options)\n this.name = new.target.name\n this.requestId = requestId\n }\n}\n\nexport interface APIErrorInit {\n status: number\n error: ErrorBody | undefined\n requestId: string | null\n headers: Headers\n body: unknown\n}\n\nexport class APIError extends LeadsetsError {\n /** HTTP status. */\n readonly status: number\n /** Machine-readable `error.type`, e.g. \"window_full\". */\n readonly type: string | null\n /** The field a 400 refers to. */\n readonly param: string | null\n /** The meter that ran out, e.g. \"search_records_5h\". */\n readonly meter: string | null\n /** When the meter's window frees up (ISO 8601). */\n readonly resetsAt: string | null\n /** Seconds to wait, from the `Retry-After` header. */\n readonly retryAfter: number | null\n /** Always 0: errors never count records. */\n readonly charged: number | null\n /** The `error` object of the response. */\n readonly error: ErrorBody | undefined\n readonly headers: Headers\n /** The full parsed response body. */\n readonly body: unknown\n\n constructor(init: APIErrorInit) {\n const msg = init.error?.message ?? `Request failed with status ${init.status}`\n super(msg, init.requestId)\n this.status = init.status\n this.error = init.error\n this.type = str(init.error?.type)\n this.param = str(init.error?.param)\n this.meter = str(init.error?.meter)\n this.resetsAt = str(init.error?.resets_at)\n this.charged = typeof init.error?.charged === 'number' ? init.error.charged : null\n this.retryAfter = parseRetryAfter(init.headers.get('retry-after'))\n this.headers = init.headers\n this.body = init.body\n }\n\n /** Builds the most specific error class for a response. */\n static from(init: APIErrorInit): APIError {\n const Cls = (init.error?.type && BY_TYPE[init.error.type]) || byStatus(init.status)\n return new Cls(init)\n }\n}\n\nexport class InvalidRequestError extends APIError {}\nexport class AuthenticationError extends APIError {}\nexport class PaymentRequiredError extends APIError {}\nexport class FreeRecordsExhaustedError extends PaymentRequiredError {}\nexport class ScrapeUnitsExhaustedError extends PaymentRequiredError {}\n\nexport class PermissionDeniedError extends APIError {\n /** Where to upgrade, when a plan change would allow the call. */\n readonly upgradeUrl: string | null\n constructor(init: APIErrorInit) {\n super(init)\n this.upgradeUrl = str(init.error?.upgrade_url)\n }\n}\n\nexport class NotFoundError extends APIError {}\nexport class IdempotencyConflictError extends APIError {}\nexport class RateLimitError extends APIError {}\nexport class InternalServerError extends APIError {}\nexport class ServiceUnavailableError extends InternalServerError {}\n\nexport class APIConnectionError extends LeadsetsError {\n constructor(message = 'Could not reach the Leadsets API.', options?: { cause?: unknown }) {\n super(message, null, options)\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(message = 'The request to the Leadsets API timed out.', options?: { cause?: unknown }) {\n super(message, options)\n }\n}\n\n/** Aliases. */\nexport { APIConnectionError as ConnectionError, APITimeoutError as TimeoutError }\n\ntype ErrorClass = new (init: APIErrorInit) => APIError\n\nconst BY_TYPE: Record<string, ErrorClass> = {\n invalid_request: InvalidRequestError,\n unauthorized: AuthenticationError,\n free_records_exhausted: FreeRecordsExhaustedError,\n scrape_units_exhausted: ScrapeUnitsExhaustedError,\n forbidden: PermissionDeniedError,\n not_found: NotFoundError,\n idempotency_conflict: IdempotencyConflictError,\n window_full: RateLimitError,\n weekly_limit: RateLimitError,\n too_many_concurrent: RateLimitError,\n internal_error: InternalServerError,\n unavailable: ServiceUnavailableError,\n}\n\nfunction byStatus(status: number): ErrorClass {\n if (status === 400 || status === 413 || status === 422) return InvalidRequestError\n if (status === 401) return AuthenticationError\n if (status === 402) return PaymentRequiredError\n if (status === 403) return PermissionDeniedError\n if (status === 404) return NotFoundError\n if (status === 409) return IdempotencyConflictError\n if (status === 429) return RateLimitError\n if (status === 503) return ServiceUnavailableError\n if (status >= 500) return InternalServerError\n return APIError\n}\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\n/** `Retry-After` as seconds: a number of seconds or an HTTP date. */\nexport function parseRetryAfter(v: string | null, now: number = Date.now()): number | null {\n if (v == null || v.trim() === '') return null\n const n = Number(v)\n if (Number.isFinite(n)) return Math.max(0, n)\n const t = Date.parse(v)\n if (Number.isNaN(t)) return null\n return Math.max(0, Math.ceil((t - now) / 1000))\n}\n","export const VERSION = '0.1.1'\n","import { APIConnectionError, APIError, APITimeoutError, LeadsetsError, parseRetryAfter } from './errors.js'\nimport type { RateLimitInfo, ResponseMeta } from './types.js'\nimport { VERSION } from './version.js'\n\nexport const DEFAULT_BASE_URL = 'https://api.leadsets.ai'\nexport const DEFAULT_TIMEOUT_MS = 120_000\nexport const DEFAULT_MAX_RETRIES = 2\nexport const DEFAULT_MAX_RETRY_DELAY_MS = 60_000\n\ntype Fetch = (input: string, init: RequestInit) => Promise<Response>\n\nexport interface ClientOptions {\n /** Your API key (`ls_live_…`). Defaults to the LEADSETS_API_KEY or LEADSETS_KEY environment variable. */\n apiKey?: string | undefined\n /** Defaults to https://api.leadsets.ai (or the LEADSETS_BASE_URL environment variable). */\n baseURL?: string | undefined\n /** Retries on 429, 5xx, timeouts and network errors. Default 2. */\n maxRetries?: number | undefined\n /** Per-attempt timeout in milliseconds. Default 120000. */\n timeout?: number | undefined\n /**\n * The longest `Retry-After` the SDK will wait for before retrying, in milliseconds.\n * A 429 asking for a longer wait (a weekly limit, say) is thrown at once. Default 60000.\n */\n maxRetryDelay?: number | undefined\n /** A custom fetch implementation. Defaults to the global fetch. */\n fetch?: Fetch | undefined\n /** Headers sent with every request. */\n defaultHeaders?: Record<string, string> | undefined\n}\n\nexport interface RequestOptions {\n /**\n * Idempotency-Key for this call. The SDK generates one for every paid call when you don't,\n * and reuses it on retries, so a retry never counts records twice. Keys last 24 hours.\n */\n idempotencyKey?: string | undefined\n maxRetries?: number | undefined\n timeout?: number | undefined\n signal?: AbortSignal | undefined\n headers?: Record<string, string> | undefined\n}\n\ninterface ApiRequest {\n method: 'GET' | 'POST'\n path: string\n body?: unknown\n /** Paid POSTs: send an Idempotency-Key. */\n idempotent?: boolean\n}\n\nexport class HttpClient {\n readonly apiKey: string\n readonly baseURL: string\n readonly maxRetries: number\n readonly timeout: number\n readonly maxRetryDelay: number\n private readonly fetchImpl: Fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(opts: ClientOptions = {}) {\n const apiKey = opts.apiKey ?? env('LEADSETS_API_KEY') ?? env('LEADSETS_KEY')\n if (!apiKey) {\n throw new LeadsetsError(\n 'No API key. Pass one to new Leadsets(apiKey) or set the LEADSETS_API_KEY environment variable. Get a free key at https://www.leadsets.ai/signup.',\n )\n }\n this.apiKey = apiKey\n this.baseURL = (opts.baseURL ?? env('LEADSETS_BASE_URL') ?? DEFAULT_BASE_URL).replace(/\\/+$/, '')\n this.maxRetries = nonNegative(opts.maxRetries, DEFAULT_MAX_RETRIES)\n this.timeout = nonNegative(opts.timeout, DEFAULT_TIMEOUT_MS)\n this.maxRetryDelay = nonNegative(opts.maxRetryDelay, DEFAULT_MAX_RETRY_DELAY_MS)\n const f = opts.fetch ?? (globalThis.fetch as Fetch | undefined)\n if (!f) throw new LeadsetsError('No fetch implementation found. Use Node 18+ or pass `fetch` in the options.')\n this.fetchImpl = opts.fetch ?? ((input, init) => globalThis.fetch(input, init))\n this.defaultHeaders = opts.defaultHeaders ?? {}\n }\n\n async request<T extends object>(req: ApiRequest, opts: RequestOptions = {}): Promise<T> {\n const maxRetries = nonNegative(opts.maxRetries, this.maxRetries)\n const timeout = nonNegative(opts.timeout, this.timeout)\n const idempotencyKey = req.idempotent ? (opts.idempotencyKey ?? newIdempotencyKey()) : (opts.idempotencyKey ?? null)\n const url = `${this.baseURL}/v1${req.path}`\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'User-Agent': `leadsets-sdk-js/${VERSION}`,\n ...this.defaultHeaders,\n ...opts.headers,\n Authorization: `Bearer ${this.apiKey}`,\n }\n if (req.body !== undefined) headers['Content-Type'] = 'application/json'\n if (idempotencyKey) headers['Idempotency-Key'] = idempotencyKey\n const body = req.body !== undefined ? JSON.stringify(req.body) : undefined\n\n for (let attempt = 0; ; attempt++) {\n let res: Response\n const timer = timeoutSignal(timeout, opts.signal)\n try {\n res = await this.fetchImpl(url, { method: req.method, headers, body, signal: timer.signal })\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError(undefined, { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n\n let text: string\n try {\n text = await res.text()\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError('The connection closed before the response was read.', { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n timer.clear()\n const parsed = parseJson(text)\n\n if (res.ok) {\n const data = (parsed && typeof parsed === 'object' ? parsed : {}) as T\n const meta = responseMeta(res, data, idempotencyKey, attempt + 1)\n Object.defineProperty(data, 'lastResponse', {\n value: meta,\n enumerable: false,\n writable: false,\n configurable: true,\n })\n return data\n }\n\n const obj = (parsed && typeof parsed === 'object' ? parsed : {}) as { error?: unknown; request_id?: unknown }\n const error = obj.error && typeof obj.error === 'object' ? (obj.error as Record<string, unknown>) : undefined\n const apiErr = APIError.from({\n status: res.status,\n error: error ?? (text && !parsed ? { message: text.slice(0, 500) } : undefined),\n requestId: typeof obj.request_id === 'string' ? obj.request_id : null,\n headers: res.headers,\n body: parsed ?? text,\n })\n const delay = this.retryDelay(apiErr, attempt)\n if (attempt < maxRetries && delay !== null) {\n await sleep(delay, opts.signal)\n continue\n }\n throw apiErr\n }\n }\n\n /** Milliseconds to wait before retrying, or null to not retry. */\n private retryDelay(err: APIError, attempt: number): number | null {\n const retryable = err.status === 408 || err.status === 429 || err.status >= 500\n if (!retryable) return null\n if (err.retryAfter !== null) {\n const ms = err.retryAfter * 1000\n if (ms > this.maxRetryDelay) return null\n // A little jitter so parallel workers don't all retry at the same instant.\n return ms + Math.random() * 250\n }\n return backoff(attempt)\n }\n}\n\n/** Exponential backoff with jitter: ~0.5 s, 1 s, 2 s … capped at 8 s. */\nexport function backoff(attempt: number): number {\n const base = Math.min(8_000, 500 * 2 ** attempt)\n return base * (0.75 + Math.random() * 0.25)\n}\n\nfunction responseMeta(res: Response, data: object, idempotencyKey: string | null, attempts: number): ResponseMeta {\n const h = res.headers\n const rid = (data as { request_id?: unknown }).request_id\n return {\n status: res.status,\n headers: h,\n requestId: typeof rid === 'string' ? rid : null,\n idempotencyKey,\n idempotentReplayed: h.get('idempotent-replayed') === 'true',\n rateLimit: rateLimitInfo(h),\n attempts,\n }\n}\n\nexport function rateLimitInfo(h: Headers): RateLimitInfo {\n return {\n recordsRemaining: num(h.get('x-leadsets-records-remaining')),\n requestsRemaining: num(h.get('x-leadsets-requests-remaining')),\n weeklyRemaining: num(h.get('x-leadsets-weekly-remaining')),\n freeRemaining: num(h.get('x-leadsets-free-remaining')),\n retryAfter: parseRetryAfter(h.get('retry-after')),\n }\n}\n\nconst num = (v: string | null): number | null => {\n if (v == null || v === '') return null\n const n = Number(v)\n return Number.isFinite(n) ? n : null\n}\n\nfunction parseJson(text: string): unknown {\n if (!text) return null\n try {\n return JSON.parse(text)\n } catch {\n return null\n }\n}\n\nfunction nonNegative(v: number | undefined, fallback: number): number {\n return typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : fallback\n}\n\nfunction env(name: string): string | undefined {\n try {\n const p = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n const v = p?.env?.[name]\n return v?.trim() ? v.trim() : undefined\n } catch {\n return undefined\n }\n}\n\n/** A random UUID v4, from Web Crypto when available. */\nexport function newIdempotencyKey(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n if (c?.randomUUID) return c.randomUUID()\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/** An AbortSignal that fires on timeout or when the caller's signal aborts. */\nfunction timeoutSignal(ms: number, outer?: AbortSignal) {\n const ctrl = new AbortController()\n let timedOut = false\n const timer =\n ms > 0\n ? setTimeout(() => {\n timedOut = true\n ctrl.abort()\n }, ms)\n : undefined\n const onAbort = () => ctrl.abort(outer?.reason)\n if (outer) {\n if (outer.aborted) ctrl.abort(outer.reason)\n else outer.addEventListener('abort', onAbort, { once: true })\n }\n return {\n signal: ctrl.signal,\n timedOut: () => timedOut,\n clear: () => {\n if (timer) clearTimeout(timer)\n outer?.removeEventListener('abort', onAbort)\n },\n }\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n const t = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort)\n resolve()\n }, ms)\n const onAbort = () => {\n clearTimeout(t)\n reject(signal?.reason)\n }\n signal?.addEventListener('abort', onAbort, { once: true })\n })\n}\n","import type { RequestOptions } from './core.js'\n\nexport interface PaginationOptions extends RequestOptions {\n /** Stop after this many items (the last page asks only for what's left, so you pay for no more). */\n maxItems?: number | undefined\n /** Stop after this many pages. */\n maxPages?: number | undefined\n}\n\ninterface Page<T> {\n items: T[]\n next_cursor: string | null\n}\n\ntype Params = { limit?: number | undefined; cursor?: string | undefined }\n\n/**\n * Fetches pages by following `next_cursor`. When the caller passes an idempotencyKey, each\n * page gets its own key derived from it (`<key>-p2`, `<key>-p3` …), because each page has a\n * different body.\n */\nexport async function* paginate<P extends Params, R extends Page<unknown>>(\n fetchPage: (params: P, opts: RequestOptions) => Promise<R>,\n params: P,\n opts: PaginationOptions = {},\n): AsyncGenerator<R, void, undefined> {\n const { maxItems, maxPages, ...reqOpts } = opts\n let cursor = params.cursor\n let seen = 0\n for (let page = 1; ; page++) {\n if (maxPages !== undefined && page > maxPages) return\n let limit = params.limit\n if (maxItems !== undefined) {\n const left = maxItems - seen\n if (left <= 0) return\n limit = Math.min(limit ?? 25, left)\n }\n const pageParams = { ...params, ...(limit !== undefined ? { limit } : {}), ...(cursor ? { cursor } : {}) } as P\n const key = reqOpts.idempotencyKey\n const res = await fetchPage(pageParams, { ...reqOpts, idempotencyKey: key && page > 1 ? `${key}-p${page}` : key })\n seen += res.items.length\n yield res\n if (!res.next_cursor || res.items.length === 0) return\n cursor = res.next_cursor\n }\n}\n\nexport async function* items<T, R extends Page<T>>(pages: AsyncIterable<R>): AsyncGenerator<T, void, undefined> {\n for await (const p of pages) yield* p.items\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n CompaniesSearchParams,\n CompaniesSearchResponse,\n Company,\n CompanyEnrichParams,\n CompanyEnrichResponse,\n} from '../types.js'\n\nexport class Companies {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/companies/search. 1 search record per record returned; empty results use none. */\n search(params: CompaniesSearchParams = {}, options?: RequestOptions): Promise<CompaniesSearchResponse> {\n return this.http.request({ method: 'POST', path: '/companies/search', body: params, idempotent: true }, options)\n }\n\n /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: CompaniesSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Company, void, undefined> {\n return items<Company, CompaniesSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results. */\n searchPages(\n params: CompaniesSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<CompaniesSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/companies/enrich. 1 enrichment record when found; 404 uses none. */\n enrich(params: CompanyEnrichParams, options?: RequestOptions): Promise<CompanyEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/companies/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { EmailVerifyParams, EmailVerifyResponse } from '../types.js'\n\nexport class Emails {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * POST /v1/emails/verify. One email (`email`) or up to 100 (`emails`), or pass a string or\n * an array directly. 1 enrichment record per email checked.\n */\n verify(params: EmailVerifyParams | string | string[], options?: RequestOptions): Promise<EmailVerifyResponse> {\n const body = typeof params === 'string' ? { email: params } : Array.isArray(params) ? { emails: params } : params\n return this.http.request({ method: 'POST', path: '/emails/verify', body, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { AsyncJob } from '../types.js'\n\nexport class Jobs {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/jobs/{id}: status of an async job. */\n get(id: string, options?: RequestOptions): Promise<AsyncJob> {\n if (!id) throw new TypeError('jobs.get: id is required')\n return this.http.request({ method: 'GET', path: `/jobs/${encodeURIComponent(id)}` }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n PeopleSearchParams,\n PeopleSearchResponse,\n Person,\n PersonEnrichParams,\n PersonEnrichResponse,\n} from '../types.js'\n\nexport class People {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/people/search. 1 search record per record returned; empty results use none. */\n search(params: PeopleSearchParams = {}, options?: RequestOptions): Promise<PeopleSearchResponse> {\n return this.http.request({ method: 'POST', path: '/people/search', body: params, idempotent: true }, options)\n }\n\n /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: PeopleSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Person, void, undefined> {\n return items<Person, PeopleSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results (with `usage` and `lastResponse` per page). */\n searchPages(\n params: PeopleSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<PeopleSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/people/enrich. 1 enrichment record when found (+1 for a personal email); 404 uses none. */\n enrich(params: PersonEnrichParams, options?: RequestOptions): Promise<PersonEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/people/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { ScrapeCompanyResponse, ScrapeJobsResponse, ScrapeParams } from '../types.js'\n\nexport class Scrape {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/scrape/company. 1 scrape unit per page read (default 1 page). Paid plans with scrape units. */\n company(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeCompanyResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/company', body: params, idempotent: true }, options)\n }\n\n /** POST /v1/scrape/jobs. 1 scrape unit per page read (default up to 3). Paid plans with scrape units. */\n jobs(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeJobsResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/jobs', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { UsageResponse } from '../types.js'\n\nexport class UsageResource {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/usage: what's left in every meter and when each window resets. Free to call. */\n get(options?: RequestOptions): Promise<UsageResponse> {\n return this.http.request({ method: 'GET', path: '/usage' }, options)\n }\n}\n","import { type ClientOptions, HttpClient } from './core.js'\nimport { Companies } from './resources/companies.js'\nimport { Emails } from './resources/emails.js'\nimport { Jobs } from './resources/jobs.js'\nimport { People } from './resources/people.js'\nimport { Scrape } from './resources/scrape.js'\nimport { UsageResource } from './resources/usage.js'\n\n/**\n * The Leadsets API client.\n *\n * ```ts\n * const ls = new Leadsets(process.env.LEADSETS_KEY)\n * const res = await ls.people.search({ function: ['revenue'], country: 'US', limit: 10 })\n * ```\n */\nexport class Leadsets {\n readonly people: People\n readonly companies: Companies\n readonly emails: Emails\n readonly scrape: Scrape\n readonly jobs: Jobs\n readonly usage: UsageResource\n /** The base URL requests go to. */\n readonly baseURL: string\n\n constructor(apiKey?: string | ClientOptions, options: ClientOptions = {}) {\n const opts: ClientOptions =\n typeof apiKey === 'object' && apiKey !== null ? apiKey : { ...options, apiKey: apiKey ?? options.apiKey }\n const http = new HttpClient(opts)\n this.baseURL = http.baseURL\n this.people = new People(http)\n this.companies = new Companies(http)\n this.emails = new Emails(http)\n this.scrape = new Scrape(http)\n this.jobs = new Jobs(http)\n this.usage = new UsageResource(http)\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/version.ts","../src/core.ts","../src/pagination.ts","../src/resources/companies.ts","../src/resources/emails.ts","../src/resources/jobs.ts","../src/resources/people.ts","../src/resources/scrape.ts","../src/resources/usage.ts","../src/client.ts"],"names":[],"mappings":";;;AA+BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAIvC,WAAA,CAAY,OAAA,EAAiB,SAAA,GAA2B,IAAA,EAAM,OAAA,EAA+B;AAC3F,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AAAA,EACnB;AACF;AAUO,IAAM,QAAA,GAAN,cAAuB,aAAA,CAAc;AAAA,EAqB1C,YAAY,IAAA,EAAoB;AAC9B,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA,EAAO,OAAA,IAAW,CAAA,2BAAA,EAA8B,KAAK,MAAM,CAAA,CAAA;AAC5E,IAAA,KAAA,CAAM,GAAA,EAAK,KAAK,SAAS,CAAA;AACzB,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AACnB,IAA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AA;AACzB,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAI,CAAA;AAAA,EACrC;AACF","file":"index.cjs","sourcesContent":["/**\n * Error hierarchy.\n *\n * LeadsetsError\n * ├── APIError the API answered with an error status\n * │ ├── InvalidRequestError 400 invalid_request\n * │ ├── AuthenticationError 401 unauthorized\n * │ ├── PaymentRequiredError 402\n * │ │ ├── FreeRecordsExhaustedError free_records_exhausted\n * │ │ └── ScrapeUnitsExhaustedError scrape_units_exhausted\n * │ ├── PermissionDeniedError 403 forbidden (upgradeUrl)\n * │ ├── NotFoundError 404 not_found\n * │ ├── IdempotencyConflictError 409 idempotency_conflict\n * │ ├── RateLimitError 429 window_full, weekly_limit, too_many_concurrent\n * │ └── InternalServerError 5xx internal_error\n * │ └── ServiceUnavailableError 503 unavailable\n * └── APIConnectionError the request never got an answer\n * └── APITimeoutError ...because it timed out\n */\n\nexport interface ErrorBody {\n type?: string\n message?: string\n param?: string\n meter?: string\n resets_at?: string\n upgrade_url?: string\n charged?: number\n [key: string]: unknown\n}\n\nexport class LeadsetsError extends Error {\n /** The request_id of the failed call, when the API returned one. */\n readonly requestId: string | null\n\n constructor(message: string, requestId: string | null = null, options?: { cause?: unknown }) {\n super(message, options)\n this.name = new.target.name\n this.requestId = requestId\n }\n}\n\nexport interface APIErrorInit {\n status: number\n error: ErrorBody | undefined\n requestId: string | null\n headers: Headers\n body: unknown\n}\n\nexport class APIError extends LeadsetsError {\n /** HTTP status. */\n readonly status: number\n /** Machine-readable `error.type`, e.g. \"window_full\". */\n readonly type: string | null\n /** The field a 400 refers to. */\n readonly param: string | null\n /** The meter that ran out, e.g. \"search_records_5h\". */\n readonly meter: string | null\n /** When the meter's window frees up (ISO 8601). */\n readonly resetsAt: string | null\n /** Seconds to wait, from the `Retry-After` header. */\n readonly retryAfter: number | null\n /** Always 0: errors never count records. */\n readonly charged: number | null\n /** The `error` object of the response. */\n readonly error: ErrorBody | undefined\n readonly headers: Headers\n /** The full parsed response body. */\n readonly body: unknown\n\n constructor(init: APIErrorInit) {\n const msg = init.error?.message ?? `Request failed with status ${init.status}`\n super(msg, init.requestId)\n this.status = init.status\n this.error = init.error\n this.type = str(init.error?.type)\n this.param = str(init.error?.param)\n this.meter = str(init.error?.meter)\n this.resetsAt = str(init.error?.resets_at)\n this.charged = typeof init.error?.charged === 'number' ? init.error.charged : null\n this.retryAfter = parseRetryAfter(init.headers.get('retry-after'))\n this.headers = init.headers\n this.body = init.body\n }\n\n /** Builds the most specific error class for a response. */\n static from(init: APIErrorInit): APIError {\n const Cls = (init.error?.type && BY_TYPE[init.error.type]) || byStatus(init.status)\n return new Cls(init)\n }\n}\n\nexport class InvalidRequestError extends APIError {}\nexport class AuthenticationError extends APIError {}\nexport class PaymentRequiredError extends APIError {}\nexport class FreeRecordsExhaustedError extends PaymentRequiredError {}\nexport class ScrapeUnitsExhaustedError extends PaymentRequiredError {}\n\nexport class PermissionDeniedError extends APIError {\n /** Where to upgrade, when a plan change would allow the call. */\n readonly upgradeUrl: string | null\n constructor(init: APIErrorInit) {\n super(init)\n this.upgradeUrl = str(init.error?.upgrade_url)\n }\n}\n\nexport class NotFoundError extends APIError {}\nexport class IdempotencyConflictError extends APIError {}\nexport class RateLimitError extends APIError {}\nexport class InternalServerError extends APIError {}\nexport class ServiceUnavailableError extends InternalServerError {}\n\nexport class APIConnectionError extends LeadsetsError {\n constructor(message = 'Could not reach the Leadsets API.', options?: { cause?: unknown }) {\n super(message, null, options)\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(message = 'The request to the Leadsets API timed out.', options?: { cause?: unknown }) {\n super(message, options)\n }\n}\n\n/** Aliases. */\nexport { APIConnectionError as ConnectionError, APITimeoutError as TimeoutError }\n\ntype ErrorClass = new (init: APIErrorInit) => APIError\n\nconst BY_TYPE: Record<string, ErrorClass> = {\n invalid_request: InvalidRequestError,\n unauthorized: AuthenticationError,\n free_records_exhausted: FreeRecordsExhaustedError,\n scrape_units_exhausted: ScrapeUnitsExhaustedError,\n forbidden: PermissionDeniedError,\n not_found: NotFoundError,\n idempotency_conflict: IdempotencyConflictError,\n window_full: RateLimitError,\n weekly_limit: RateLimitError,\n too_many_concurrent: RateLimitError,\n internal_error: InternalServerError,\n unavailable: ServiceUnavailableError,\n}\n\nfunction byStatus(status: number): ErrorClass {\n if (status === 400 || status === 413 || status === 422) return InvalidRequestError\n if (status === 401) return AuthenticationError\n if (status === 402) return PaymentRequiredError\n if (status === 403) return PermissionDeniedError\n if (status === 404) return NotFoundError\n if (status === 409) return IdempotencyConflictError\n if (status === 429) return RateLimitError\n if (status === 503) return ServiceUnavailableError\n if (status >= 500) return InternalServerError\n return APIError\n}\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\n/** `Retry-After` as seconds: a number of seconds or an HTTP date. */\nexport function parseRetryAfter(v: string | null, now: number = Date.now()): number | null {\n if (v == null || v.trim() === '') return null\n const n = Number(v)\n if (Number.isFinite(n)) return Math.max(0, n)\n const t = Date.parse(v)\n if (Number.isNaN(t)) return null\n return Math.max(0, Math.ceil((t - now) / 1000))\n}\n","export const VERSION = '0.2.1'\n","import { APIConnectionError, APIError, APITimeoutError, LeadsetsError, parseRetryAfter } from './errors.js'\nimport type { RateLimitInfo, ResponseMeta } from './types.js'\nimport { VERSION } from './version.js'\n\nexport const DEFAULT_BASE_URL = 'https://api.leadsets.ai'\nexport const DEFAULT_TIMEOUT_MS = 120_000\nexport const DEFAULT_MAX_RETRIES = 2\nexport const DEFAULT_MAX_RETRY_DELAY_MS = 60_000\n\ntype Fetch = (input: string, init: RequestInit) => Promise<Response>\n\nexport interface ClientOptions {\n /** Your API key (`ls_live_…`). Defaults to the LEADSETS_API_KEY or LEADSETS_KEY environment variable. */\n apiKey?: string | undefined\n /** Defaults to https://api.leadsets.ai (or the LEADSETS_BASE_URL environment variable). */\n baseURL?: string | undefined\n /** Retries on 429, 5xx, timeouts and network errors. Default 2. */\n maxRetries?: number | undefined\n /** Per-attempt timeout in milliseconds. Default 120000. */\n timeout?: number | undefined\n /**\n * The longest `Retry-After` the SDK will wait for before retrying, in milliseconds.\n * A 429 asking for a longer wait (a weekly limit, say) is thrown at once. Default 60000.\n */\n maxRetryDelay?: number | undefined\n /** A custom fetch implementation. Defaults to the global fetch. */\n fetch?: Fetch | undefined\n /** Headers sent with every request. */\n defaultHeaders?: Record<string, string> | undefined\n}\n\nexport interface RequestOptions {\n /**\n * Idempotency-Key for this call. The SDK generates one for every paid call when you don't,\n * and reuses it on retries, so a retry never counts records twice. Keys last 24 hours.\n */\n idempotencyKey?: string | undefined\n maxRetries?: number | undefined\n timeout?: number | undefined\n signal?: AbortSignal | undefined\n headers?: Record<string, string> | undefined\n}\n\ninterface ApiRequest {\n method: 'GET' | 'POST'\n path: string\n body?: unknown\n /** Paid POSTs: send an Idempotency-Key. */\n idempotent?: boolean\n}\n\nexport class HttpClient {\n readonly apiKey: string\n readonly baseURL: string\n readonly maxRetries: number\n readonly timeout: number\n readonly maxRetryDelay: number\n private readonly fetchImpl: Fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(opts: ClientOptions = {}) {\n const apiKey = opts.apiKey ?? env('LEADSETS_API_KEY') ?? env('LEADSETS_KEY')\n if (!apiKey) {\n throw new LeadsetsError(\n 'No API key. Pass one to new Leadsets(apiKey) or set the LEADSETS_API_KEY environment variable. Get a free key at https://www.leadsets.ai/signup.',\n )\n }\n this.apiKey = apiKey\n this.baseURL = (opts.baseURL ?? env('LEADSETS_BASE_URL') ?? DEFAULT_BASE_URL).replace(/\\/+$/, '')\n this.maxRetries = nonNegative(opts.maxRetries, DEFAULT_MAX_RETRIES)\n this.timeout = nonNegative(opts.timeout, DEFAULT_TIMEOUT_MS)\n this.maxRetryDelay = nonNegative(opts.maxRetryDelay, DEFAULT_MAX_RETRY_DELAY_MS)\n const f = opts.fetch ?? (globalThis.fetch as Fetch | undefined)\n if (!f) throw new LeadsetsError('No fetch implementation found. Use Node 18+ or pass `fetch` in the options.')\n this.fetchImpl = opts.fetch ?? ((input, init) => globalThis.fetch(input, init))\n this.defaultHeaders = opts.defaultHeaders ?? {}\n }\n\n async request<T extends object>(req: ApiRequest, opts: RequestOptions = {}): Promise<T> {\n const maxRetries = nonNegative(opts.maxRetries, this.maxRetries)\n const timeout = nonNegative(opts.timeout, this.timeout)\n const idempotencyKey = req.idempotent ? (opts.idempotencyKey ?? newIdempotencyKey()) : (opts.idempotencyKey ?? null)\n const url = `${this.baseURL}/v1${req.path}`\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'User-Agent': `leadsets-sdk-js/${VERSION}`,\n ...this.defaultHeaders,\n ...opts.headers,\n Authorization: `Bearer ${this.apiKey}`,\n }\n if (req.body !== undefined) headers['Content-Type'] = 'application/json'\n if (idempotencyKey) headers['Idempotency-Key'] = idempotencyKey\n const body = req.body !== undefined ? JSON.stringify(req.body) : undefined\n\n for (let attempt = 0; ; attempt++) {\n let res: Response\n const timer = timeoutSignal(timeout, opts.signal)\n try {\n res = await this.fetchImpl(url, { method: req.method, headers, body, signal: timer.signal })\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError(undefined, { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n\n let text: string\n try {\n text = await res.text()\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError('The connection closed before the response was read.', { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n timer.clear()\n const parsed = parseJson(text)\n\n if (res.ok) {\n const data = (parsed && typeof parsed === 'object' ? parsed : {}) as T\n const meta = responseMeta(res, data, idempotencyKey, attempt + 1)\n Object.defineProperty(data, 'lastResponse', {\n value: meta,\n enumerable: false,\n writable: false,\n configurable: true,\n })\n return data\n }\n\n const obj = (parsed && typeof parsed === 'object' ? parsed : {}) as { error?: unknown; request_id?: unknown }\n const error = obj.error && typeof obj.error === 'object' ? (obj.error as Record<string, unknown>) : undefined\n const apiErr = APIError.from({\n status: res.status,\n error: error ?? (text && !parsed ? { message: text.slice(0, 500) } : undefined),\n requestId: typeof obj.request_id === 'string' ? obj.request_id : null,\n headers: res.headers,\n body: parsed ?? text,\n })\n const delay = this.retryDelay(apiErr, attempt)\n if (attempt < maxRetries && delay !== null) {\n await sleep(delay, opts.signal)\n continue\n }\n throw apiErr\n }\n }\n\n /** Milliseconds to wait before retrying, or null to not retry. */\n private retryDelay(err: APIError, attempt: number): number | null {\n const retryable = err.status === 408 || err.status === 429 || err.status >= 500\n if (!retryable) return null\n if (err.retryAfter !== null) {\n const ms = err.retryAfter * 1000\n if (ms > this.maxRetryDelay) return null\n // A little jitter so parallel workers don't all retry at the same instant.\n return ms + Math.random() * 250\n }\n return backoff(attempt)\n }\n}\n\n/** Exponential backoff with jitter: ~0.5 s, 1 s, 2 s … capped at 8 s. */\nexport function backoff(attempt: number): number {\n const base = Math.min(8_000, 500 * 2 ** attempt)\n return base * (0.75 + Math.random() * 0.25)\n}\n\nfunction responseMeta(res: Response, data: object, idempotencyKey: string | null, attempts: number): ResponseMeta {\n const h = res.headers\n const rid = (data as { request_id?: unknown }).request_id\n return {\n status: res.status,\n headers: h,\n requestId: typeof rid === 'string' ? rid : null,\n idempotencyKey,\n idempotentReplayed: h.get('idempotent-replayed') === 'true',\n rateLimit: rateLimitInfo(h),\n attempts,\n }\n}\n\nexport function rateLimitInfo(h: Headers): RateLimitInfo {\n return {\n recordsRemaining: num(h.get('x-leadsets-records-remaining')),\n requestsRemaining: num(h.get('x-leadsets-requests-remaining')),\n weeklyRemaining: num(h.get('x-leadsets-weekly-remaining')),\n freeRemaining: num(h.get('x-leadsets-free-remaining')),\n retryAfter: parseRetryAfter(h.get('retry-after')),\n }\n}\n\nconst num = (v: string | null): number | null => {\n if (v == null || v === '') return null\n const n = Number(v)\n return Number.isFinite(n) ? n : null\n}\n\nfunction parseJson(text: string): unknown {\n if (!text) return null\n try {\n return JSON.parse(text)\n } catch {\n return null\n }\n}\n\nfunction nonNegative(v: number | undefined, fallback: number): number {\n return typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : fallback\n}\n\nfunction env(name: string): string | undefined {\n try {\n const p = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n const v = p?.env?.[name]\n return v?.trim() ? v.trim() : undefined\n } catch {\n return undefined\n }\n}\n\n/** A random UUID v4, from Web Crypto when available. */\nexport function newIdempotencyKey(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n if (c?.randomUUID) return c.randomUUID()\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/** An AbortSignal that fires on timeout or when the caller's signal aborts. */\nfunction timeoutSignal(ms: number, outer?: AbortSignal) {\n const ctrl = new AbortController()\n let timedOut = false\n const timer =\n ms > 0\n ? setTimeout(() => {\n timedOut = true\n ctrl.abort()\n }, ms)\n : undefined\n const onAbort = () => ctrl.abort(outer?.reason)\n if (outer) {\n if (outer.aborted) ctrl.abort(outer.reason)\n else outer.addEventListener('abort', onAbort, { once: true })\n }\n return {\n signal: ctrl.signal,\n timedOut: () => timedOut,\n clear: () => {\n if (timer) clearTimeout(timer)\n outer?.removeEventListener('abort', onAbort)\n },\n }\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n const t = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort)\n resolve()\n }, ms)\n const onAbort = () => {\n clearTimeout(t)\n reject(signal?.reason)\n }\n signal?.addEventListener('abort', onAbort, { once: true })\n })\n}\n","import type { RequestOptions } from './core.js'\n\nexport interface PaginationOptions extends RequestOptions {\n /** Stop after this many items (the last page asks only for what's left, so you pay for no more). */\n maxItems?: number | undefined\n /** Stop after this many pages. */\n maxPages?: number | undefined\n}\n\ninterface Page<T> {\n items: T[]\n next_cursor: string | null\n}\n\ntype Params = { limit?: number | undefined; cursor?: string | undefined }\n\n/**\n * Fetches pages by following `next_cursor`. When the caller passes an idempotencyKey, each\n * page gets its own key derived from it (`<key>-p2`, `<key>-p3` …), because each page has a\n * different body.\n */\nexport async function* paginate<P extends Params, R extends Page<unknown>>(\n fetchPage: (params: P, opts: RequestOptions) => Promise<R>,\n params: P,\n opts: PaginationOptions = {},\n): AsyncGenerator<R, void, undefined> {\n const { maxItems, maxPages, ...reqOpts } = opts\n let cursor = params.cursor\n let seen = 0\n for (let page = 1; ; page++) {\n if (maxPages !== undefined && page > maxPages) return\n let limit = params.limit\n if (maxItems !== undefined) {\n const left = maxItems - seen\n if (left <= 0) return\n limit = Math.min(limit ?? 25, left)\n }\n const pageParams = { ...params, ...(limit !== undefined ? { limit } : {}), ...(cursor ? { cursor } : {}) } as P\n const key = reqOpts.idempotencyKey\n const res = await fetchPage(pageParams, { ...reqOpts, idempotencyKey: key && page > 1 ? `${key}-p${page}` : key })\n seen += res.items.length\n yield res\n if (!res.next_cursor || res.items.length === 0) return\n cursor = res.next_cursor\n }\n}\n\nexport async function* items<T, R extends Page<T>>(pages: AsyncIterable<R>): AsyncGenerator<T, void, undefined> {\n for await (const p of pages) yield* p.items\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n CompaniesSearchParams,\n CompaniesSearchResponse,\n Company,\n CompanyEnrichParams,\n CompanyEnrichResponse,\n CountResponse,\n} from '../types.js'\n\nexport class Companies {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/companies/search. 1 search record per record returned; empty results use none. */\n search(params: CompaniesSearchParams = {}, options?: RequestOptions): Promise<CompaniesSearchResponse> {\n return this.http.request({ method: 'POST', path: '/companies/search', body: params, idempotent: true }, options)\n }\n\n /**\n * POST /v1/companies/search with `count_only`: how many companies match, without returning them.\n * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).\n */\n count(\n params: Omit<CompaniesSearchParams, 'limit' | 'cursor'> = {},\n options?: RequestOptions,\n ): Promise<CountResponse> {\n return this.http.request(\n { method: 'POST', path: '/companies/search', body: { ...params, count_only: true }, idempotent: true },\n options,\n )\n }\n\n /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: CompaniesSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Company, void, undefined> {\n return items<Company, CompaniesSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results. */\n searchPages(\n params: CompaniesSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<CompaniesSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/companies/enrich. 1 enrichment record when found; 404 uses none. */\n enrich(params: CompanyEnrichParams, options?: RequestOptions): Promise<CompanyEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/companies/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { EmailVerifyParams, EmailVerifyResponse } from '../types.js'\n\nexport class Emails {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * POST /v1/emails/verify. One email (`email`) or up to 100 (`emails`), or pass a string or\n * an array directly. 1 enrichment record per email checked.\n */\n verify(params: EmailVerifyParams | string | string[], options?: RequestOptions): Promise<EmailVerifyResponse> {\n const body = typeof params === 'string' ? { email: params } : Array.isArray(params) ? { emails: params } : params\n return this.http.request({ method: 'POST', path: '/emails/verify', body, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { AsyncJob } from '../types.js'\n\nexport class Jobs {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/jobs/{id}: status of an async job. */\n get(id: string, options?: RequestOptions): Promise<AsyncJob> {\n if (!id) throw new TypeError('jobs.get: id is required')\n return this.http.request({ method: 'GET', path: `/jobs/${encodeURIComponent(id)}` }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n CountResponse,\n PeopleSearchParams,\n PeopleSearchResponse,\n Person,\n PersonEnrichParams,\n PersonEnrichResponse,\n} from '../types.js'\n\nexport class People {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/people/search. 1 search record per record returned; empty results use none. */\n search(params: PeopleSearchParams = {}, options?: RequestOptions): Promise<PeopleSearchResponse> {\n return this.http.request({ method: 'POST', path: '/people/search', body: params, idempotent: true }, options)\n }\n\n /**\n * POST /v1/people/search with `count_only`: how many people match, without returning them.\n * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).\n */\n count(\n params: Omit<PeopleSearchParams, 'limit' | 'cursor' | 'priorities'> = {},\n options?: RequestOptions,\n ): Promise<CountResponse> {\n return this.http.request(\n { method: 'POST', path: '/people/search', body: { ...params, count_only: true }, idempotent: true },\n options,\n )\n }\n\n /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: PeopleSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Person, void, undefined> {\n return items<Person, PeopleSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results (with `usage` and `lastResponse` per page). */\n searchPages(\n params: PeopleSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<PeopleSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/people/enrich. 1 enrichment record when found (+1 for a personal email); 404 uses none. */\n enrich(params: PersonEnrichParams, options?: RequestOptions): Promise<PersonEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/people/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { ScrapeCompanyResponse, ScrapeJobsResponse, ScrapeParams } from '../types.js'\n\nexport class Scrape {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/scrape/company. 1 scrape unit per page read (default 1 page). Paid plans with scrape units. */\n company(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeCompanyResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/company', body: params, idempotent: true }, options)\n }\n\n /** POST /v1/scrape/jobs. 1 scrape unit per page read (default up to 3). Paid plans with scrape units. */\n jobs(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeJobsResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/jobs', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { UsageResponse } from '../types.js'\n\nexport class UsageResource {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/usage: what's left in every meter and when each window resets. Free to call. */\n get(options?: RequestOptions): Promise<UsageResponse> {\n return this.http.request({ method: 'GET', path: '/usage' }, options)\n }\n}\n","import { type ClientOptions, HttpClient } from './core.js'\nimport { Companies } from './resources/companies.js'\nimport { Emails } from './resources/emails.js'\nimport { Jobs } from './resources/jobs.js'\nimport { People } from './resources/people.js'\nimport { Scrape } from './resources/scrape.js'\nimport { UsageResource } from './resources/usage.js'\n\n/**\n * The Leadsets API client.\n *\n * ```ts\n * const ls = new Leadsets(process.env.LEADSETS_KEY)\n * const res = await ls.people.search({ function: ['revenue'], country: 'US', limit: 10 })\n * ```\n */\nexport class Leadsets {\n readonly people: People\n readonly companies: Companies\n readonly emails: Emails\n readonly scrape: Scrape\n readonly jobs: Jobs\n readonly usage: UsageResource\n /** The base URL requests go to. */\n readonly baseURL: string\n\n constructor(apiKey?: string | ClientOptions, options: ClientOptions = {}) {\n const opts: ClientOptions =\n typeof apiKey === 'object' && apiKey !== null ? apiKey : { ...options, apiKey: apiKey ?? options.apiKey }\n const http = new HttpClient(opts)\n this.baseURL = http.baseURL\n this.people = new People(http)\n this.companies = new Companies(http)\n this.emails = new Emails(http)\n this.scrape = new Scrape(http)\n this.jobs = new Jobs(http)\n this.usage = new UsageResource(http)\n }\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -44,7 +44,11 @@ interface Usage {
44
44
  scrape_units_left?: number;
45
45
  /** True when limits could not be checked for this call. */
46
46
  degraded?: boolean;
47
- [key: string]: number | boolean | undefined;
47
+ /** Paid plans: the limits behind the `*_left_*` numbers, e.g. `search_records_5h`, `concurrent_searches`. */
48
+ limits?: Record<string, number>;
49
+ /** Paid plans: when the oldest usage leaves each window (ISO 8601), e.g. `search_5h`, `search_week`. */
50
+ resets_at?: Record<string, string | null>;
51
+ [key: string]: number | boolean | Record<string, number> | Record<string, string | null> | undefined;
48
52
  }
49
53
  /** Rate-limit headers of a response, parsed. `null` when the header was absent. */
50
54
  interface RateLimitInfo {
@@ -91,6 +95,8 @@ interface PersonCompany {
91
95
  company_id: string | null;
92
96
  name: string | null;
93
97
  domain: string | null;
98
+ /** The domain the company's work emails use, when known. */
99
+ email_domain?: string | null;
94
100
  industry: string | null;
95
101
  employees: number | null;
96
102
  employee_range: string | null;
@@ -101,6 +107,8 @@ interface Person {
101
107
  first_name: string | null;
102
108
  last_name: string | null;
103
109
  title: string | null;
110
+ /** LinkedIn headline, when known. */
111
+ headline?: string | null;
104
112
  seniority: Seniority | null;
105
113
  /** Finer-grained seniority, e.g. "founder" or "senior". */
106
114
  seniority_detail: string | null;
@@ -115,6 +123,8 @@ interface Person {
115
123
  personal_email?: Email | null;
116
124
  /** Which filters this record matched (search results only). */
117
125
  match_reasons?: string[];
126
+ /** With `priorities`: which priority found this person (1 for the first group). */
127
+ priority?: number;
118
128
  refreshed_at: string | null;
119
129
  confirmed_at: string | null;
120
130
  stale_after_at: string | null;
@@ -122,13 +132,42 @@ interface Person {
122
132
  /** Source, last-seen date and confidence for every field that has a value. */
123
133
  sources: Record<string, FieldSource>;
124
134
  }
135
+ /** One group of titles for `PeopleSearchParams.priorities`, best first. */
136
+ interface PeoplePriority {
137
+ /** Titles for this priority, fuzzy-matched like `title`. */
138
+ title: OneOrMany<string>;
139
+ /** Titles that rule a person out of this priority, e.g. ["assistant", "intern"]. */
140
+ exclude_title?: OneOrMany<string>;
141
+ /** Replaces the top-level `seniority` for this priority. */
142
+ seniority?: OneOrMany<Seniority>;
143
+ /** Replaces the top-level `function` for this priority. */
144
+ function?: OneOrMany<PersonFunction>;
145
+ /** Replaces the top-level `country` for this priority. */
146
+ country?: OneOrMany<string>;
147
+ /** Also match these titles against the LinkedIn headline. */
148
+ match_headline?: boolean;
149
+ }
125
150
  interface PeopleSearchParams {
126
151
  /** Job titles. Fuzzy-matched: "VP Sales" also finds "Vice President, Sales". */
127
152
  title?: OneOrMany<string>;
153
+ /** Also match title words against the LinkedIn headline. */
154
+ match_headline?: boolean;
128
155
  seniority?: OneOrMany<Seniority>;
129
156
  function?: OneOrMany<PersonFunction>;
130
157
  /** Only people at these companies (domains). */
131
158
  company_domain?: OneOrMany<string>;
159
+ /** With `priorities`: the company by its LinkedIn page, instead of `company_domain`. */
160
+ company_linkedin_url?: string;
161
+ /** What their company does, e.g. ["clay", "gtm engineering"]: whole words in its name, description and specialties. */
162
+ company_keywords?: OneOrMany<string>;
163
+ /** Leave out people whose company mentions any of these. */
164
+ exclude_company_keywords?: OneOrMany<string>;
165
+ /**
166
+ * Best contacts at ONE company (one `company_domain` or `company_linkedin_url`): 1–10 groups of
167
+ * titles, best first. Results fill from the first group, never repeat a person and carry
168
+ * `priority`. `limit` 1–25 (default 5); no cursor, no top-level `title`.
169
+ */
170
+ priorities?: PeoplePriority[];
132
171
  /** Company headcount range, e.g. "50-200", "1000+" or "<50". */
133
172
  employees?: string;
134
173
  /** Leadsets industry slugs, e.g. "saas". */
@@ -151,6 +190,22 @@ interface PeopleSearchParams {
151
190
  interface PeopleSearchResponse extends APIResponse {
152
191
  items: Person[];
153
192
  next_cursor: string | null;
193
+ /** With `priorities`: the company that was matched, or null when none is on file. */
194
+ company?: {
195
+ company_id: string | null;
196
+ name: string | null;
197
+ domain: string | null;
198
+ email_domain: string | null;
199
+ linkedin_url: string | null;
200
+ } | null;
201
+ /** With `priorities`, when no company is on file for the LinkedIn page. */
202
+ note?: string;
203
+ }
204
+ /** `people.count` / `companies.count`: how many records match. Uses no records. */
205
+ interface CountResponse extends APIResponse {
206
+ count: number;
207
+ /** True when counting stopped at 10,000: there are at least `count` matches. */
208
+ count_capped: boolean;
154
209
  }
155
210
  interface PersonEnrichParams {
156
211
  /** LinkedIn profile URL (strongest identifier). */
@@ -177,6 +232,8 @@ interface Company {
177
232
  company_id: string;
178
233
  name: string | null;
179
234
  domain: string | null;
235
+ /** The domain its work emails use, when known (may differ from `domain`). */
236
+ email_domain?: string | null;
180
237
  linkedin_url: string | null;
181
238
  industry: string | null;
182
239
  naics: string | null;
@@ -187,6 +244,8 @@ interface Company {
187
244
  founded_year: number | null;
188
245
  description: string | null;
189
246
  technologies: string[];
247
+ /** What the company says it does (LinkedIn specialties). */
248
+ specialties?: string[];
190
249
  match_reasons?: string[];
191
250
  refreshed_at: string | null;
192
251
  confirmed_at: string | null;
@@ -195,13 +254,17 @@ interface Company {
195
254
  sources: Record<string, FieldSource>;
196
255
  }
197
256
  interface CompaniesSearchParams {
257
+ /** What the company does, e.g. ["lead generation", "appointment setting"]: whole words in its name, description and specialties; any matches. */
258
+ keywords?: OneOrMany<string>;
259
+ /** Leave out companies that mention any of these, e.g. ["pottery"]. */
260
+ exclude_keywords?: OneOrMany<string>;
198
261
  industry?: OneOrMany<string>;
199
262
  /** Headcount range, e.g. "50-200" or "1000+". */
200
263
  employees?: string;
201
264
  country?: OneOrMany<string>;
202
265
  /** Technologies the company uses, e.g. "hubspot". Matches any. */
203
266
  technology?: OneOrMany<string>;
204
- /** Only these domains. */
267
+ /** Only these domains (website or email domain). */
205
268
  domain?: OneOrMany<string>;
206
269
  max_age_days?: number;
207
270
  exclude_stale?: boolean;
@@ -403,6 +466,11 @@ declare class Companies {
403
466
  constructor(http: HttpClient);
404
467
  /** POST /v1/companies/search. 1 search record per record returned; empty results use none. */
405
468
  search(params?: CompaniesSearchParams, options?: RequestOptions): Promise<CompaniesSearchResponse>;
469
+ /**
470
+ * POST /v1/companies/search with `count_only`: how many companies match, without returning them.
471
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
472
+ */
473
+ count(params?: Omit<CompaniesSearchParams, 'limit' | 'cursor'>, options?: RequestOptions): Promise<CountResponse>;
406
474
  /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */
407
475
  searchAll(params?: CompaniesSearchParams, options?: PaginationOptions): AsyncGenerator<Company, void, undefined>;
408
476
  /** Every page of results. */
@@ -433,6 +501,11 @@ declare class People {
433
501
  constructor(http: HttpClient);
434
502
  /** POST /v1/people/search. 1 search record per record returned; empty results use none. */
435
503
  search(params?: PeopleSearchParams, options?: RequestOptions): Promise<PeopleSearchResponse>;
504
+ /**
505
+ * POST /v1/people/search with `count_only`: how many people match, without returning them.
506
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
507
+ */
508
+ count(params?: Omit<PeopleSearchParams, 'limit' | 'cursor' | 'priorities'>, options?: RequestOptions): Promise<CountResponse>;
436
509
  /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */
437
510
  searchAll(params?: PeopleSearchParams, options?: PaginationOptions): AsyncGenerator<Person, void, undefined>;
438
511
  /** Every page of results (with `usage` and `lastResponse` per page). */
@@ -583,6 +656,6 @@ declare class APITimeoutError extends APIConnectionError {
583
656
  /** `Retry-After` as seconds: a number of seconds or an HTTP date. */
584
657
  declare function parseRetryAfter(v: string | null, now?: number): number | null;
585
658
 
586
- declare const VERSION = "0.1.1";
659
+ declare const VERSION = "0.2.1";
587
660
 
588
- export { APIConnectionError, APIError, type APIErrorInit, type APIResponse, APITimeoutError, type AsyncJob, AuthenticationError, type ClientOptions, type CompaniesSearchParams, type CompaniesSearchResponse, type Company, type CompanyEnrichParams, type CompanyEnrichResponse, APIConnectionError as ConnectionError, DEFAULT_BASE_URL, type Email, type EmailStatus, type EmailVerification, type EmailVerifyParams, type EmailVerifyResponse, type EmailVerifySummary, type ErrorBody, type FieldSource, type FreeMeters, FreeRecordsExhaustedError, IdempotencyConflictError, InternalServerError, InvalidRequestError, type Job, Leadsets, LeadsetsError, type Location, type Meter, NotFoundError, type OneOrMany, type PaginationOptions, PaymentRequiredError, type PeopleSearchParams, type PeopleSearchResponse, PermissionDeniedError, type Person, type PersonCompany, type PersonEnrichParams, type PersonEnrichResponse, type PersonFunction, type Plan, RateLimitError, type RateLimitInfo, type RequestOptions, type ResponseMeta, type ScrapeCompanyResponse, type ScrapeJobsResponse, type ScrapeParams, ScrapeUnitsExhaustedError, type ScrapedPage, type Seniority, ServiceUnavailableError, APITimeoutError as TimeoutError, type Unavailable, type Usage, type UsageResponse, VERSION, type VerificationStatus, type WindowMeters, parseRetryAfter };
661
+ export { APIConnectionError, APIError, type APIErrorInit, type APIResponse, APITimeoutError, type AsyncJob, AuthenticationError, type ClientOptions, type CompaniesSearchParams, type CompaniesSearchResponse, type Company, type CompanyEnrichParams, type CompanyEnrichResponse, APIConnectionError as ConnectionError, type CountResponse, DEFAULT_BASE_URL, type Email, type EmailStatus, type EmailVerification, type EmailVerifyParams, type EmailVerifyResponse, type EmailVerifySummary, type ErrorBody, type FieldSource, type FreeMeters, FreeRecordsExhaustedError, IdempotencyConflictError, InternalServerError, InvalidRequestError, type Job, Leadsets, LeadsetsError, type Location, type Meter, NotFoundError, type OneOrMany, type PaginationOptions, PaymentRequiredError, type PeoplePriority, type PeopleSearchParams, type PeopleSearchResponse, PermissionDeniedError, type Person, type PersonCompany, type PersonEnrichParams, type PersonEnrichResponse, type PersonFunction, type Plan, RateLimitError, type RateLimitInfo, type RequestOptions, type ResponseMeta, type ScrapeCompanyResponse, type ScrapeJobsResponse, type ScrapeParams, ScrapeUnitsExhaustedError, type ScrapedPage, type Seniority, ServiceUnavailableError, APITimeoutError as TimeoutError, type Unavailable, type Usage, type UsageResponse, VERSION, type VerificationStatus, type WindowMeters, parseRetryAfter };
package/dist/index.d.ts CHANGED
@@ -44,7 +44,11 @@ interface Usage {
44
44
  scrape_units_left?: number;
45
45
  /** True when limits could not be checked for this call. */
46
46
  degraded?: boolean;
47
- [key: string]: number | boolean | undefined;
47
+ /** Paid plans: the limits behind the `*_left_*` numbers, e.g. `search_records_5h`, `concurrent_searches`. */
48
+ limits?: Record<string, number>;
49
+ /** Paid plans: when the oldest usage leaves each window (ISO 8601), e.g. `search_5h`, `search_week`. */
50
+ resets_at?: Record<string, string | null>;
51
+ [key: string]: number | boolean | Record<string, number> | Record<string, string | null> | undefined;
48
52
  }
49
53
  /** Rate-limit headers of a response, parsed. `null` when the header was absent. */
50
54
  interface RateLimitInfo {
@@ -91,6 +95,8 @@ interface PersonCompany {
91
95
  company_id: string | null;
92
96
  name: string | null;
93
97
  domain: string | null;
98
+ /** The domain the company's work emails use, when known. */
99
+ email_domain?: string | null;
94
100
  industry: string | null;
95
101
  employees: number | null;
96
102
  employee_range: string | null;
@@ -101,6 +107,8 @@ interface Person {
101
107
  first_name: string | null;
102
108
  last_name: string | null;
103
109
  title: string | null;
110
+ /** LinkedIn headline, when known. */
111
+ headline?: string | null;
104
112
  seniority: Seniority | null;
105
113
  /** Finer-grained seniority, e.g. "founder" or "senior". */
106
114
  seniority_detail: string | null;
@@ -115,6 +123,8 @@ interface Person {
115
123
  personal_email?: Email | null;
116
124
  /** Which filters this record matched (search results only). */
117
125
  match_reasons?: string[];
126
+ /** With `priorities`: which priority found this person (1 for the first group). */
127
+ priority?: number;
118
128
  refreshed_at: string | null;
119
129
  confirmed_at: string | null;
120
130
  stale_after_at: string | null;
@@ -122,13 +132,42 @@ interface Person {
122
132
  /** Source, last-seen date and confidence for every field that has a value. */
123
133
  sources: Record<string, FieldSource>;
124
134
  }
135
+ /** One group of titles for `PeopleSearchParams.priorities`, best first. */
136
+ interface PeoplePriority {
137
+ /** Titles for this priority, fuzzy-matched like `title`. */
138
+ title: OneOrMany<string>;
139
+ /** Titles that rule a person out of this priority, e.g. ["assistant", "intern"]. */
140
+ exclude_title?: OneOrMany<string>;
141
+ /** Replaces the top-level `seniority` for this priority. */
142
+ seniority?: OneOrMany<Seniority>;
143
+ /** Replaces the top-level `function` for this priority. */
144
+ function?: OneOrMany<PersonFunction>;
145
+ /** Replaces the top-level `country` for this priority. */
146
+ country?: OneOrMany<string>;
147
+ /** Also match these titles against the LinkedIn headline. */
148
+ match_headline?: boolean;
149
+ }
125
150
  interface PeopleSearchParams {
126
151
  /** Job titles. Fuzzy-matched: "VP Sales" also finds "Vice President, Sales". */
127
152
  title?: OneOrMany<string>;
153
+ /** Also match title words against the LinkedIn headline. */
154
+ match_headline?: boolean;
128
155
  seniority?: OneOrMany<Seniority>;
129
156
  function?: OneOrMany<PersonFunction>;
130
157
  /** Only people at these companies (domains). */
131
158
  company_domain?: OneOrMany<string>;
159
+ /** With `priorities`: the company by its LinkedIn page, instead of `company_domain`. */
160
+ company_linkedin_url?: string;
161
+ /** What their company does, e.g. ["clay", "gtm engineering"]: whole words in its name, description and specialties. */
162
+ company_keywords?: OneOrMany<string>;
163
+ /** Leave out people whose company mentions any of these. */
164
+ exclude_company_keywords?: OneOrMany<string>;
165
+ /**
166
+ * Best contacts at ONE company (one `company_domain` or `company_linkedin_url`): 1–10 groups of
167
+ * titles, best first. Results fill from the first group, never repeat a person and carry
168
+ * `priority`. `limit` 1–25 (default 5); no cursor, no top-level `title`.
169
+ */
170
+ priorities?: PeoplePriority[];
132
171
  /** Company headcount range, e.g. "50-200", "1000+" or "<50". */
133
172
  employees?: string;
134
173
  /** Leadsets industry slugs, e.g. "saas". */
@@ -151,6 +190,22 @@ interface PeopleSearchParams {
151
190
  interface PeopleSearchResponse extends APIResponse {
152
191
  items: Person[];
153
192
  next_cursor: string | null;
193
+ /** With `priorities`: the company that was matched, or null when none is on file. */
194
+ company?: {
195
+ company_id: string | null;
196
+ name: string | null;
197
+ domain: string | null;
198
+ email_domain: string | null;
199
+ linkedin_url: string | null;
200
+ } | null;
201
+ /** With `priorities`, when no company is on file for the LinkedIn page. */
202
+ note?: string;
203
+ }
204
+ /** `people.count` / `companies.count`: how many records match. Uses no records. */
205
+ interface CountResponse extends APIResponse {
206
+ count: number;
207
+ /** True when counting stopped at 10,000: there are at least `count` matches. */
208
+ count_capped: boolean;
154
209
  }
155
210
  interface PersonEnrichParams {
156
211
  /** LinkedIn profile URL (strongest identifier). */
@@ -177,6 +232,8 @@ interface Company {
177
232
  company_id: string;
178
233
  name: string | null;
179
234
  domain: string | null;
235
+ /** The domain its work emails use, when known (may differ from `domain`). */
236
+ email_domain?: string | null;
180
237
  linkedin_url: string | null;
181
238
  industry: string | null;
182
239
  naics: string | null;
@@ -187,6 +244,8 @@ interface Company {
187
244
  founded_year: number | null;
188
245
  description: string | null;
189
246
  technologies: string[];
247
+ /** What the company says it does (LinkedIn specialties). */
248
+ specialties?: string[];
190
249
  match_reasons?: string[];
191
250
  refreshed_at: string | null;
192
251
  confirmed_at: string | null;
@@ -195,13 +254,17 @@ interface Company {
195
254
  sources: Record<string, FieldSource>;
196
255
  }
197
256
  interface CompaniesSearchParams {
257
+ /** What the company does, e.g. ["lead generation", "appointment setting"]: whole words in its name, description and specialties; any matches. */
258
+ keywords?: OneOrMany<string>;
259
+ /** Leave out companies that mention any of these, e.g. ["pottery"]. */
260
+ exclude_keywords?: OneOrMany<string>;
198
261
  industry?: OneOrMany<string>;
199
262
  /** Headcount range, e.g. "50-200" or "1000+". */
200
263
  employees?: string;
201
264
  country?: OneOrMany<string>;
202
265
  /** Technologies the company uses, e.g. "hubspot". Matches any. */
203
266
  technology?: OneOrMany<string>;
204
- /** Only these domains. */
267
+ /** Only these domains (website or email domain). */
205
268
  domain?: OneOrMany<string>;
206
269
  max_age_days?: number;
207
270
  exclude_stale?: boolean;
@@ -403,6 +466,11 @@ declare class Companies {
403
466
  constructor(http: HttpClient);
404
467
  /** POST /v1/companies/search. 1 search record per record returned; empty results use none. */
405
468
  search(params?: CompaniesSearchParams, options?: RequestOptions): Promise<CompaniesSearchResponse>;
469
+ /**
470
+ * POST /v1/companies/search with `count_only`: how many companies match, without returning them.
471
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
472
+ */
473
+ count(params?: Omit<CompaniesSearchParams, 'limit' | 'cursor'>, options?: RequestOptions): Promise<CountResponse>;
406
474
  /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */
407
475
  searchAll(params?: CompaniesSearchParams, options?: PaginationOptions): AsyncGenerator<Company, void, undefined>;
408
476
  /** Every page of results. */
@@ -433,6 +501,11 @@ declare class People {
433
501
  constructor(http: HttpClient);
434
502
  /** POST /v1/people/search. 1 search record per record returned; empty results use none. */
435
503
  search(params?: PeopleSearchParams, options?: RequestOptions): Promise<PeopleSearchResponse>;
504
+ /**
505
+ * POST /v1/people/search with `count_only`: how many people match, without returning them.
506
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
507
+ */
508
+ count(params?: Omit<PeopleSearchParams, 'limit' | 'cursor' | 'priorities'>, options?: RequestOptions): Promise<CountResponse>;
436
509
  /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */
437
510
  searchAll(params?: PeopleSearchParams, options?: PaginationOptions): AsyncGenerator<Person, void, undefined>;
438
511
  /** Every page of results (with `usage` and `lastResponse` per page). */
@@ -583,6 +656,6 @@ declare class APITimeoutError extends APIConnectionError {
583
656
  /** `Retry-After` as seconds: a number of seconds or an HTTP date. */
584
657
  declare function parseRetryAfter(v: string | null, now?: number): number | null;
585
658
 
586
- declare const VERSION = "0.1.1";
659
+ declare const VERSION = "0.2.1";
587
660
 
588
- export { APIConnectionError, APIError, type APIErrorInit, type APIResponse, APITimeoutError, type AsyncJob, AuthenticationError, type ClientOptions, type CompaniesSearchParams, type CompaniesSearchResponse, type Company, type CompanyEnrichParams, type CompanyEnrichResponse, APIConnectionError as ConnectionError, DEFAULT_BASE_URL, type Email, type EmailStatus, type EmailVerification, type EmailVerifyParams, type EmailVerifyResponse, type EmailVerifySummary, type ErrorBody, type FieldSource, type FreeMeters, FreeRecordsExhaustedError, IdempotencyConflictError, InternalServerError, InvalidRequestError, type Job, Leadsets, LeadsetsError, type Location, type Meter, NotFoundError, type OneOrMany, type PaginationOptions, PaymentRequiredError, type PeopleSearchParams, type PeopleSearchResponse, PermissionDeniedError, type Person, type PersonCompany, type PersonEnrichParams, type PersonEnrichResponse, type PersonFunction, type Plan, RateLimitError, type RateLimitInfo, type RequestOptions, type ResponseMeta, type ScrapeCompanyResponse, type ScrapeJobsResponse, type ScrapeParams, ScrapeUnitsExhaustedError, type ScrapedPage, type Seniority, ServiceUnavailableError, APITimeoutError as TimeoutError, type Unavailable, type Usage, type UsageResponse, VERSION, type VerificationStatus, type WindowMeters, parseRetryAfter };
661
+ export { APIConnectionError, APIError, type APIErrorInit, type APIResponse, APITimeoutError, type AsyncJob, AuthenticationError, type ClientOptions, type CompaniesSearchParams, type CompaniesSearchResponse, type Company, type CompanyEnrichParams, type CompanyEnrichResponse, APIConnectionError as ConnectionError, type CountResponse, DEFAULT_BASE_URL, type Email, type EmailStatus, type EmailVerification, type EmailVerifyParams, type EmailVerifyResponse, type EmailVerifySummary, type ErrorBody, type FieldSource, type FreeMeters, FreeRecordsExhaustedError, IdempotencyConflictError, InternalServerError, InvalidRequestError, type Job, Leadsets, LeadsetsError, type Location, type Meter, NotFoundError, type OneOrMany, type PaginationOptions, PaymentRequiredError, type PeoplePriority, type PeopleSearchParams, type PeopleSearchResponse, PermissionDeniedError, type Person, type PersonCompany, type PersonEnrichParams, type PersonEnrichResponse, type PersonFunction, type Plan, RateLimitError, type RateLimitInfo, type RequestOptions, type ResponseMeta, type ScrapeCompanyResponse, type ScrapeJobsResponse, type ScrapeParams, ScrapeUnitsExhaustedError, type ScrapedPage, type Seniority, ServiceUnavailableError, APITimeoutError as TimeoutError, type Unavailable, type Usage, type UsageResponse, VERSION, type VerificationStatus, type WindowMeters, parseRetryAfter };
package/dist/index.js CHANGED
@@ -100,7 +100,7 @@ function parseRetryAfter(v, now = Date.now()) {
100
100
  }
101
101
 
102
102
  // src/version.ts
103
- var VERSION = "0.1.1";
103
+ var VERSION = "0.2.1";
104
104
 
105
105
  // src/core.ts
106
106
  var DEFAULT_BASE_URL = "https://api.leadsets.ai";
@@ -340,6 +340,16 @@ var Companies = class {
340
340
  search(params = {}, options) {
341
341
  return this.http.request({ method: "POST", path: "/companies/search", body: params, idempotent: true }, options);
342
342
  }
343
+ /**
344
+ * POST /v1/companies/search with `count_only`: how many companies match, without returning them.
345
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
346
+ */
347
+ count(params = {}, options) {
348
+ return this.http.request(
349
+ { method: "POST", path: "/companies/search", body: { ...params, count_only: true }, idempotent: true },
350
+ options
351
+ );
352
+ }
343
353
  /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */
344
354
  searchAll(params = {}, options) {
345
355
  return items(this.searchPages(params, options));
@@ -390,6 +400,16 @@ var People = class {
390
400
  search(params = {}, options) {
391
401
  return this.http.request({ method: "POST", path: "/people/search", body: params, idempotent: true }, options);
392
402
  }
403
+ /**
404
+ * POST /v1/people/search with `count_only`: how many people match, without returning them.
405
+ * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).
406
+ */
407
+ count(params = {}, options) {
408
+ return this.http.request(
409
+ { method: "POST", path: "/people/search", body: { ...params, count_only: true }, idempotent: true },
410
+ options
411
+ );
412
+ }
393
413
  /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */
394
414
  searchAll(params = {}, options) {
395
415
  return items(this.searchPages(params, options));
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/version.ts","../src/core.ts","../src/pagination.ts","../src/resources/companies.ts","../src/resources/emails.ts","../src/resources/jobs.ts","../src/resources/people.ts","../src/resources/scrape.ts","../src/resources/usage.ts","../src/client.ts"],"names":[],"mappings":";AA+BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAIvC,WAAA,CAAY,OAAA,EAAiB,SAAA,GAA2B,IAAA,EAAM,OAAA,EAA+B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AQ,UAAA,EAAY,IAAA,IAAQ,OAAO,CAAA;AAAA,EAC5G;AACF,CAAA;;;ACZO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,IAAA,EAAkB;AAAlB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAAmB;AAAA;AAAA,EAGhD,IAAI,OAAA,EAAkD;AACpD,IAAA,OAAO,IAAA,CAAK,KAAK,OAAA,CAAQ,EAAE,QAAQ,KAAA,EAAO,IAAA,EAAM,QAAA,EAAS,EAAG,OAAO,CAAA;AAAA,EACrE;AACF,CAAA;;;ACMO,IAAM,WAAN,MAAe;AAAA,EAUpB,WAAA,CAAY,MAAA,EAAiC,OAAA,GAAyB,EAAC,EAAG;AACxE,IAAA,MAAM,IAAA,GACJ,OAAO,MAAA,KAAW,QAAA,IAAY,MAAA,KAAW,IAAA,GAAO,MAAA,GAAS,EAAE,GAAG,OAAA,EAAS,MAAA,EAAQ,MAAA,IAAU,QAAQ,MAAA,EAAO;AAC1G,IAAA,MAAM,IAAA,GAAO,IAAI,UAAA,CAAW,IAAI,CAAA;AAChC,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,MAAA,CAAO,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,SAAA,CAAU,IAAI,CAAA;AACnC,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,MAAA,CAAO,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,MAAA,CAAO,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,IAAA,CAAK,IAAI,CAAA;AACzB,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAI,CAAA;AAAA,EACrC;AACF","file":"index.js","sourcesContent":["/**\n * Error hierarchy.\n *\n * LeadsetsError\n * ├── APIError the API answered with an error status\n * │ ├── InvalidRequestError 400 invalid_request\n * │ ├── AuthenticationError 401 unauthorized\n * │ ├── PaymentRequiredError 402\n * │ │ ├── FreeRecordsExhaustedError free_records_exhausted\n * │ │ └── ScrapeUnitsExhaustedError scrape_units_exhausted\n * │ ├── PermissionDeniedError 403 forbidden (upgradeUrl)\n * │ ├── NotFoundError 404 not_found\n * │ ├── IdempotencyConflictError 409 idempotency_conflict\n * │ ├── RateLimitError 429 window_full, weekly_limit, too_many_concurrent\n * │ └── InternalServerError 5xx internal_error\n * │ └── ServiceUnavailableError 503 unavailable\n * └── APIConnectionError the request never got an answer\n * └── APITimeoutError ...because it timed out\n */\n\nexport interface ErrorBody {\n type?: string\n message?: string\n param?: string\n meter?: string\n resets_at?: string\n upgrade_url?: string\n charged?: number\n [key: string]: unknown\n}\n\nexport class LeadsetsError extends Error {\n /** The request_id of the failed call, when the API returned one. */\n readonly requestId: string | null\n\n constructor(message: string, requestId: string | null = null, options?: { cause?: unknown }) {\n super(message, options)\n this.name = new.target.name\n this.requestId = requestId\n }\n}\n\nexport interface APIErrorInit {\n status: number\n error: ErrorBody | undefined\n requestId: string | null\n headers: Headers\n body: unknown\n}\n\nexport class APIError extends LeadsetsError {\n /** HTTP status. */\n readonly status: number\n /** Machine-readable `error.type`, e.g. \"window_full\". */\n readonly type: string | null\n /** The field a 400 refers to. */\n readonly param: string | null\n /** The meter that ran out, e.g. \"search_records_5h\". */\n readonly meter: string | null\n /** When the meter's window frees up (ISO 8601). */\n readonly resetsAt: string | null\n /** Seconds to wait, from the `Retry-After` header. */\n readonly retryAfter: number | null\n /** Always 0: errors never count records. */\n readonly charged: number | null\n /** The `error` object of the response. */\n readonly error: ErrorBody | undefined\n readonly headers: Headers\n /** The full parsed response body. */\n readonly body: unknown\n\n constructor(init: APIErrorInit) {\n const msg = init.error?.message ?? `Request failed with status ${init.status}`\n super(msg, init.requestId)\n this.status = init.status\n this.error = init.error\n this.type = str(init.error?.type)\n this.param = str(init.error?.param)\n this.meter = str(init.error?.meter)\n this.resetsAt = str(init.error?.resets_at)\n this.charged = typeof init.error?.charged === 'number' ? init.error.charged : null\n this.retryAfter = parseRetryAfter(init.headers.get('retry-after'))\n this.headers = init.headers\n this.body = init.body\n }\n\n /** Builds the most specific error class for a response. */\n static from(init: APIErrorInit): APIError {\n const Cls = (init.error?.type && BY_TYPE[init.error.type]) || byStatus(init.status)\n return new Cls(init)\n }\n}\n\nexport class InvalidRequestError extends APIError {}\nexport class AuthenticationError extends APIError {}\nexport class PaymentRequiredError extends APIError {}\nexport class FreeRecordsExhaustedError extends PaymentRequiredError {}\nexport class ScrapeUnitsExhaustedError extends PaymentRequiredError {}\n\nexport class PermissionDeniedError extends APIError {\n /** Where to upgrade, when a plan change would allow the call. */\n readonly upgradeUrl: string | null\n constructor(init: APIErrorInit) {\n super(init)\n this.upgradeUrl = str(init.error?.upgrade_url)\n }\n}\n\nexport class NotFoundError extends APIError {}\nexport class IdempotencyConflictError extends APIError {}\nexport class RateLimitError extends APIError {}\nexport class InternalServerError extends APIError {}\nexport class ServiceUnavailableError extends InternalServerError {}\n\nexport class APIConnectionError extends LeadsetsError {\n constructor(message = 'Could not reach the Leadsets API.', options?: { cause?: unknown }) {\n super(message, null, options)\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(message = 'The request to the Leadsets API timed out.', options?: { cause?: unknown }) {\n super(message, options)\n }\n}\n\n/** Aliases. */\nexport { APIConnectionError as ConnectionError, APITimeoutError as TimeoutError }\n\ntype ErrorClass = new (init: APIErrorInit) => APIError\n\nconst BY_TYPE: Record<string, ErrorClass> = {\n invalid_request: InvalidRequestError,\n unauthorized: AuthenticationError,\n free_records_exhausted: FreeRecordsExhaustedError,\n scrape_units_exhausted: ScrapeUnitsExhaustedError,\n forbidden: PermissionDeniedError,\n not_found: NotFoundError,\n idempotency_conflict: IdempotencyConflictError,\n window_full: RateLimitError,\n weekly_limit: RateLimitError,\n too_many_concurrent: RateLimitError,\n internal_error: InternalServerError,\n unavailable: ServiceUnavailableError,\n}\n\nfunction byStatus(status: number): ErrorClass {\n if (status === 400 || status === 413 || status === 422) return InvalidRequestError\n if (status === 401) return AuthenticationError\n if (status === 402) return PaymentRequiredError\n if (status === 403) return PermissionDeniedError\n if (status === 404) return NotFoundError\n if (status === 409) return IdempotencyConflictError\n if (status === 429) return RateLimitError\n if (status === 503) return ServiceUnavailableError\n if (status >= 500) return InternalServerError\n return APIError\n}\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\n/** `Retry-After` as seconds: a number of seconds or an HTTP date. */\nexport function parseRetryAfter(v: string | null, now: number = Date.now()): number | null {\n if (v == null || v.trim() === '') return null\n const n = Number(v)\n if (Number.isFinite(n)) return Math.max(0, n)\n const t = Date.parse(v)\n if (Number.isNaN(t)) return null\n return Math.max(0, Math.ceil((t - now) / 1000))\n}\n","export const VERSION = '0.1.1'\n","import { APIConnectionError, APIError, APITimeoutError, LeadsetsError, parseRetryAfter } from './errors.js'\nimport type { RateLimitInfo, ResponseMeta } from './types.js'\nimport { VERSION } from './version.js'\n\nexport const DEFAULT_BASE_URL = 'https://api.leadsets.ai'\nexport const DEFAULT_TIMEOUT_MS = 120_000\nexport const DEFAULT_MAX_RETRIES = 2\nexport const DEFAULT_MAX_RETRY_DELAY_MS = 60_000\n\ntype Fetch = (input: string, init: RequestInit) => Promise<Response>\n\nexport interface ClientOptions {\n /** Your API key (`ls_live_…`). Defaults to the LEADSETS_API_KEY or LEADSETS_KEY environment variable. */\n apiKey?: string | undefined\n /** Defaults to https://api.leadsets.ai (or the LEADSETS_BASE_URL environment variable). */\n baseURL?: string | undefined\n /** Retries on 429, 5xx, timeouts and network errors. Default 2. */\n maxRetries?: number | undefined\n /** Per-attempt timeout in milliseconds. Default 120000. */\n timeout?: number | undefined\n /**\n * The longest `Retry-After` the SDK will wait for before retrying, in milliseconds.\n * A 429 asking for a longer wait (a weekly limit, say) is thrown at once. Default 60000.\n */\n maxRetryDelay?: number | undefined\n /** A custom fetch implementation. Defaults to the global fetch. */\n fetch?: Fetch | undefined\n /** Headers sent with every request. */\n defaultHeaders?: Record<string, string> | undefined\n}\n\nexport interface RequestOptions {\n /**\n * Idempotency-Key for this call. The SDK generates one for every paid call when you don't,\n * and reuses it on retries, so a retry never counts records twice. Keys last 24 hours.\n */\n idempotencyKey?: string | undefined\n maxRetries?: number | undefined\n timeout?: number | undefined\n signal?: AbortSignal | undefined\n headers?: Record<string, string> | undefined\n}\n\ninterface ApiRequest {\n method: 'GET' | 'POST'\n path: string\n body?: unknown\n /** Paid POSTs: send an Idempotency-Key. */\n idempotent?: boolean\n}\n\nexport class HttpClient {\n readonly apiKey: string\n readonly baseURL: string\n readonly maxRetries: number\n readonly timeout: number\n readonly maxRetryDelay: number\n private readonly fetchImpl: Fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(opts: ClientOptions = {}) {\n const apiKey = opts.apiKey ?? env('LEADSETS_API_KEY') ?? env('LEADSETS_KEY')\n if (!apiKey) {\n throw new LeadsetsError(\n 'No API key. Pass one to new Leadsets(apiKey) or set the LEADSETS_API_KEY environment variable. Get a free key at https://www.leadsets.ai/signup.',\n )\n }\n this.apiKey = apiKey\n this.baseURL = (opts.baseURL ?? env('LEADSETS_BASE_URL') ?? DEFAULT_BASE_URL).replace(/\\/+$/, '')\n this.maxRetries = nonNegative(opts.maxRetries, DEFAULT_MAX_RETRIES)\n this.timeout = nonNegative(opts.timeout, DEFAULT_TIMEOUT_MS)\n this.maxRetryDelay = nonNegative(opts.maxRetryDelay, DEFAULT_MAX_RETRY_DELAY_MS)\n const f = opts.fetch ?? (globalThis.fetch as Fetch | undefined)\n if (!f) throw new LeadsetsError('No fetch implementation found. Use Node 18+ or pass `fetch` in the options.')\n this.fetchImpl = opts.fetch ?? ((input, init) => globalThis.fetch(input, init))\n this.defaultHeaders = opts.defaultHeaders ?? {}\n }\n\n async request<T extends object>(req: ApiRequest, opts: RequestOptions = {}): Promise<T> {\n const maxRetries = nonNegative(opts.maxRetries, this.maxRetries)\n const timeout = nonNegative(opts.timeout, this.timeout)\n const idempotencyKey = req.idempotent ? (opts.idempotencyKey ?? newIdempotencyKey()) : (opts.idempotencyKey ?? null)\n const url = `${this.baseURL}/v1${req.path}`\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'User-Agent': `leadsets-sdk-js/${VERSION}`,\n ...this.defaultHeaders,\n ...opts.headers,\n Authorization: `Bearer ${this.apiKey}`,\n }\n if (req.body !== undefined) headers['Content-Type'] = 'application/json'\n if (idempotencyKey) headers['Idempotency-Key'] = idempotencyKey\n const body = req.body !== undefined ? JSON.stringify(req.body) : undefined\n\n for (let attempt = 0; ; attempt++) {\n let res: Response\n const timer = timeoutSignal(timeout, opts.signal)\n try {\n res = await this.fetchImpl(url, { method: req.method, headers, body, signal: timer.signal })\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError(undefined, { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n\n let text: string\n try {\n text = await res.text()\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError('The connection closed before the response was read.', { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n timer.clear()\n const parsed = parseJson(text)\n\n if (res.ok) {\n const data = (parsed && typeof parsed === 'object' ? parsed : {}) as T\n const meta = responseMeta(res, data, idempotencyKey, attempt + 1)\n Object.defineProperty(data, 'lastResponse', {\n value: meta,\n enumerable: false,\n writable: false,\n configurable: true,\n })\n return data\n }\n\n const obj = (parsed && typeof parsed === 'object' ? parsed : {}) as { error?: unknown; request_id?: unknown }\n const error = obj.error && typeof obj.error === 'object' ? (obj.error as Record<string, unknown>) : undefined\n const apiErr = APIError.from({\n status: res.status,\n error: error ?? (text && !parsed ? { message: text.slice(0, 500) } : undefined),\n requestId: typeof obj.request_id === 'string' ? obj.request_id : null,\n headers: res.headers,\n body: parsed ?? text,\n })\n const delay = this.retryDelay(apiErr, attempt)\n if (attempt < maxRetries && delay !== null) {\n await sleep(delay, opts.signal)\n continue\n }\n throw apiErr\n }\n }\n\n /** Milliseconds to wait before retrying, or null to not retry. */\n private retryDelay(err: APIError, attempt: number): number | null {\n const retryable = err.status === 408 || err.status === 429 || err.status >= 500\n if (!retryable) return null\n if (err.retryAfter !== null) {\n const ms = err.retryAfter * 1000\n if (ms > this.maxRetryDelay) return null\n // A little jitter so parallel workers don't all retry at the same instant.\n return ms + Math.random() * 250\n }\n return backoff(attempt)\n }\n}\n\n/** Exponential backoff with jitter: ~0.5 s, 1 s, 2 s … capped at 8 s. */\nexport function backoff(attempt: number): number {\n const base = Math.min(8_000, 500 * 2 ** attempt)\n return base * (0.75 + Math.random() * 0.25)\n}\n\nfunction responseMeta(res: Response, data: object, idempotencyKey: string | null, attempts: number): ResponseMeta {\n const h = res.headers\n const rid = (data as { request_id?: unknown }).request_id\n return {\n status: res.status,\n headers: h,\n requestId: typeof rid === 'string' ? rid : null,\n idempotencyKey,\n idempotentReplayed: h.get('idempotent-replayed') === 'true',\n rateLimit: rateLimitInfo(h),\n attempts,\n }\n}\n\nexport function rateLimitInfo(h: Headers): RateLimitInfo {\n return {\n recordsRemaining: num(h.get('x-leadsets-records-remaining')),\n requestsRemaining: num(h.get('x-leadsets-requests-remaining')),\n weeklyRemaining: num(h.get('x-leadsets-weekly-remaining')),\n freeRemaining: num(h.get('x-leadsets-free-remaining')),\n retryAfter: parseRetryAfter(h.get('retry-after')),\n }\n}\n\nconst num = (v: string | null): number | null => {\n if (v == null || v === '') return null\n const n = Number(v)\n return Number.isFinite(n) ? n : null\n}\n\nfunction parseJson(text: string): unknown {\n if (!text) return null\n try {\n return JSON.parse(text)\n } catch {\n return null\n }\n}\n\nfunction nonNegative(v: number | undefined, fallback: number): number {\n return typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : fallback\n}\n\nfunction env(name: string): string | undefined {\n try {\n const p = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n const v = p?.env?.[name]\n return v?.trim() ? v.trim() : undefined\n } catch {\n return undefined\n }\n}\n\n/** A random UUID v4, from Web Crypto when available. */\nexport function newIdempotencyKey(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n if (c?.randomUUID) return c.randomUUID()\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/** An AbortSignal that fires on timeout or when the caller's signal aborts. */\nfunction timeoutSignal(ms: number, outer?: AbortSignal) {\n const ctrl = new AbortController()\n let timedOut = false\n const timer =\n ms > 0\n ? setTimeout(() => {\n timedOut = true\n ctrl.abort()\n }, ms)\n : undefined\n const onAbort = () => ctrl.abort(outer?.reason)\n if (outer) {\n if (outer.aborted) ctrl.abort(outer.reason)\n else outer.addEventListener('abort', onAbort, { once: true })\n }\n return {\n signal: ctrl.signal,\n timedOut: () => timedOut,\n clear: () => {\n if (timer) clearTimeout(timer)\n outer?.removeEventListener('abort', onAbort)\n },\n }\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n const t = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort)\n resolve()\n }, ms)\n const onAbort = () => {\n clearTimeout(t)\n reject(signal?.reason)\n }\n signal?.addEventListener('abort', onAbort, { once: true })\n })\n}\n","import type { RequestOptions } from './core.js'\n\nexport interface PaginationOptions extends RequestOptions {\n /** Stop after this many items (the last page asks only for what's left, so you pay for no more). */\n maxItems?: number | undefined\n /** Stop after this many pages. */\n maxPages?: number | undefined\n}\n\ninterface Page<T> {\n items: T[]\n next_cursor: string | null\n}\n\ntype Params = { limit?: number | undefined; cursor?: string | undefined }\n\n/**\n * Fetches pages by following `next_cursor`. When the caller passes an idempotencyKey, each\n * page gets its own key derived from it (`<key>-p2`, `<key>-p3` …), because each page has a\n * different body.\n */\nexport async function* paginate<P extends Params, R extends Page<unknown>>(\n fetchPage: (params: P, opts: RequestOptions) => Promise<R>,\n params: P,\n opts: PaginationOptions = {},\n): AsyncGenerator<R, void, undefined> {\n const { maxItems, maxPages, ...reqOpts } = opts\n let cursor = params.cursor\n let seen = 0\n for (let page = 1; ; page++) {\n if (maxPages !== undefined && page > maxPages) return\n let limit = params.limit\n if (maxItems !== undefined) {\n const left = maxItems - seen\n if (left <= 0) return\n limit = Math.min(limit ?? 25, left)\n }\n const pageParams = { ...params, ...(limit !== undefined ? { limit } : {}), ...(cursor ? { cursor } : {}) } as P\n const key = reqOpts.idempotencyKey\n const res = await fetchPage(pageParams, { ...reqOpts, idempotencyKey: key && page > 1 ? `${key}-p${page}` : key })\n seen += res.items.length\n yield res\n if (!res.next_cursor || res.items.length === 0) return\n cursor = res.next_cursor\n }\n}\n\nexport async function* items<T, R extends Page<T>>(pages: AsyncIterable<R>): AsyncGenerator<T, void, undefined> {\n for await (const p of pages) yield* p.items\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n CompaniesSearchParams,\n CompaniesSearchResponse,\n Company,\n CompanyEnrichParams,\n CompanyEnrichResponse,\n} from '../types.js'\n\nexport class Companies {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/companies/search. 1 search record per record returned; empty results use none. */\n search(params: CompaniesSearchParams = {}, options?: RequestOptions): Promise<CompaniesSearchResponse> {\n return this.http.request({ method: 'POST', path: '/companies/search', body: params, idempotent: true }, options)\n }\n\n /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: CompaniesSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Company, void, undefined> {\n return items<Company, CompaniesSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results. */\n searchPages(\n params: CompaniesSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<CompaniesSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/companies/enrich. 1 enrichment record when found; 404 uses none. */\n enrich(params: CompanyEnrichParams, options?: RequestOptions): Promise<CompanyEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/companies/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { EmailVerifyParams, EmailVerifyResponse } from '../types.js'\n\nexport class Emails {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * POST /v1/emails/verify. One email (`email`) or up to 100 (`emails`), or pass a string or\n * an array directly. 1 enrichment record per email checked.\n */\n verify(params: EmailVerifyParams | string | string[], options?: RequestOptions): Promise<EmailVerifyResponse> {\n const body = typeof params === 'string' ? { email: params } : Array.isArray(params) ? { emails: params } : params\n return this.http.request({ method: 'POST', path: '/emails/verify', body, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { AsyncJob } from '../types.js'\n\nexport class Jobs {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/jobs/{id}: status of an async job. */\n get(id: string, options?: RequestOptions): Promise<AsyncJob> {\n if (!id) throw new TypeError('jobs.get: id is required')\n return this.http.request({ method: 'GET', path: `/jobs/${encodeURIComponent(id)}` }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n PeopleSearchParams,\n PeopleSearchResponse,\n Person,\n PersonEnrichParams,\n PersonEnrichResponse,\n} from '../types.js'\n\nexport class People {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/people/search. 1 search record per record returned; empty results use none. */\n search(params: PeopleSearchParams = {}, options?: RequestOptions): Promise<PeopleSearchResponse> {\n return this.http.request({ method: 'POST', path: '/people/search', body: params, idempotent: true }, options)\n }\n\n /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: PeopleSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Person, void, undefined> {\n return items<Person, PeopleSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results (with `usage` and `lastResponse` per page). */\n searchPages(\n params: PeopleSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<PeopleSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/people/enrich. 1 enrichment record when found (+1 for a personal email); 404 uses none. */\n enrich(params: PersonEnrichParams, options?: RequestOptions): Promise<PersonEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/people/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { ScrapeCompanyResponse, ScrapeJobsResponse, ScrapeParams } from '../types.js'\n\nexport class Scrape {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/scrape/company. 1 scrape unit per page read (default 1 page). Paid plans with scrape units. */\n company(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeCompanyResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/company', body: params, idempotent: true }, options)\n }\n\n /** POST /v1/scrape/jobs. 1 scrape unit per page read (default up to 3). Paid plans with scrape units. */\n jobs(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeJobsResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/jobs', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { UsageResponse } from '../types.js'\n\nexport class UsageResource {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/usage: what's left in every meter and when each window resets. Free to call. */\n get(options?: RequestOptions): Promise<UsageResponse> {\n return this.http.request({ method: 'GET', path: '/usage' }, options)\n }\n}\n","import { type ClientOptions, HttpClient } from './core.js'\nimport { Companies } from './resources/companies.js'\nimport { Emails } from './resources/emails.js'\nimport { Jobs } from './resources/jobs.js'\nimport { People } from './resources/people.js'\nimport { Scrape } from './resources/scrape.js'\nimport { UsageResource } from './resources/usage.js'\n\n/**\n * The Leadsets API client.\n *\n * ```ts\n * const ls = new Leadsets(process.env.LEADSETS_KEY)\n * const res = await ls.people.search({ function: ['revenue'], country: 'US', limit: 10 })\n * ```\n */\nexport class Leadsets {\n readonly people: People\n readonly companies: Companies\n readonly emails: Emails\n readonly scrape: Scrape\n readonly jobs: Jobs\n readonly usage: UsageResource\n /** The base URL requests go to. */\n readonly baseURL: string\n\n constructor(apiKey?: string | ClientOptions, options: ClientOptions = {}) {\n const opts: ClientOptions =\n typeof apiKey === 'object' && apiKey !== null ? apiKey : { ...options, apiKey: apiKey ?? options.apiKey }\n const http = new HttpClient(opts)\n this.baseURL = http.baseURL\n this.people = new People(http)\n this.companies = new Companies(http)\n this.emails = new Emails(http)\n this.scrape = new Scrape(http)\n this.jobs = new Jobs(http)\n this.usage = new UsageResource(http)\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/version.ts","../src/core.ts","../src/pagination.ts","../src/resources/companies.ts","../src/resources/emails.ts","../src/resources/jobs.ts","../src/resources/people.ts","../src/resources/scrape.ts","../src/resources/usage.ts","../src/client.ts"],"names":[],"mappings":";AA+BO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAIvC,WAAA,CAAY,OAAA,EAAiB,SAAA,GAA2B,IAAA,EAAM,OAAA,EAA+B;AAC3F,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AAAA,EACnB;AACF;AAUO,IAAM,QAAA,GAAN,cAAuB,aAAA,CAAc;AAAA,EAqB1C,YAAY,IAAA,EAAoB;AAC9B,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA,EAAO,OAAA,IAAW,CAAA,2BAAA,EAA8B,KAAK,MAAM,CAAA,CAAA;AAC5E,IAAA,KAAA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,IAAI,MAAA,CAAO,IAAI,CAAA;AAC7B,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,IAAA,CAAK,IAAI,CAAA;AACzB,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAI,CAAA;AAAA,EACrC;AACF","file":"index.js","sourcesContent":["/**\n * Error hierarchy.\n *\n * LeadsetsError\n * ├── APIError the API answered with an error status\n * │ ├── InvalidRequestError 400 invalid_request\n * │ ├── AuthenticationError 401 unauthorized\n * │ ├── PaymentRequiredError 402\n * │ │ ├── FreeRecordsExhaustedError free_records_exhausted\n * │ │ └── ScrapeUnitsExhaustedError scrape_units_exhausted\n * │ ├── PermissionDeniedError 403 forbidden (upgradeUrl)\n * │ ├── NotFoundError 404 not_found\n * │ ├── IdempotencyConflictError 409 idempotency_conflict\n * │ ├── RateLimitError 429 window_full, weekly_limit, too_many_concurrent\n * │ └── InternalServerError 5xx internal_error\n * │ └── ServiceUnavailableError 503 unavailable\n * └── APIConnectionError the request never got an answer\n * └── APITimeoutError ...because it timed out\n */\n\nexport interface ErrorBody {\n type?: string\n message?: string\n param?: string\n meter?: string\n resets_at?: string\n upgrade_url?: string\n charged?: number\n [key: string]: unknown\n}\n\nexport class LeadsetsError extends Error {\n /** The request_id of the failed call, when the API returned one. */\n readonly requestId: string | null\n\n constructor(message: string, requestId: string | null = null, options?: { cause?: unknown }) {\n super(message, options)\n this.name = new.target.name\n this.requestId = requestId\n }\n}\n\nexport interface APIErrorInit {\n status: number\n error: ErrorBody | undefined\n requestId: string | null\n headers: Headers\n body: unknown\n}\n\nexport class APIError extends LeadsetsError {\n /** HTTP status. */\n readonly status: number\n /** Machine-readable `error.type`, e.g. \"window_full\". */\n readonly type: string | null\n /** The field a 400 refers to. */\n readonly param: string | null\n /** The meter that ran out, e.g. \"search_records_5h\". */\n readonly meter: string | null\n /** When the meter's window frees up (ISO 8601). */\n readonly resetsAt: string | null\n /** Seconds to wait, from the `Retry-After` header. */\n readonly retryAfter: number | null\n /** Always 0: errors never count records. */\n readonly charged: number | null\n /** The `error` object of the response. */\n readonly error: ErrorBody | undefined\n readonly headers: Headers\n /** The full parsed response body. */\n readonly body: unknown\n\n constructor(init: APIErrorInit) {\n const msg = init.error?.message ?? `Request failed with status ${init.status}`\n super(msg, init.requestId)\n this.status = init.status\n this.error = init.error\n this.type = str(init.error?.type)\n this.param = str(init.error?.param)\n this.meter = str(init.error?.meter)\n this.resetsAt = str(init.error?.resets_at)\n this.charged = typeof init.error?.charged === 'number' ? init.error.charged : null\n this.retryAfter = parseRetryAfter(init.headers.get('retry-after'))\n this.headers = init.headers\n this.body = init.body\n }\n\n /** Builds the most specific error class for a response. */\n static from(init: APIErrorInit): APIError {\n const Cls = (init.error?.type && BY_TYPE[init.error.type]) || byStatus(init.status)\n return new Cls(init)\n }\n}\n\nexport class InvalidRequestError extends APIError {}\nexport class AuthenticationError extends APIError {}\nexport class PaymentRequiredError extends APIError {}\nexport class FreeRecordsExhaustedError extends PaymentRequiredError {}\nexport class ScrapeUnitsExhaustedError extends PaymentRequiredError {}\n\nexport class PermissionDeniedError extends APIError {\n /** Where to upgrade, when a plan change would allow the call. */\n readonly upgradeUrl: string | null\n constructor(init: APIErrorInit) {\n super(init)\n this.upgradeUrl = str(init.error?.upgrade_url)\n }\n}\n\nexport class NotFoundError extends APIError {}\nexport class IdempotencyConflictError extends APIError {}\nexport class RateLimitError extends APIError {}\nexport class InternalServerError extends APIError {}\nexport class ServiceUnavailableError extends InternalServerError {}\n\nexport class APIConnectionError extends LeadsetsError {\n constructor(message = 'Could not reach the Leadsets API.', options?: { cause?: unknown }) {\n super(message, null, options)\n }\n}\n\nexport class APITimeoutError extends APIConnectionError {\n constructor(message = 'The request to the Leadsets API timed out.', options?: { cause?: unknown }) {\n super(message, options)\n }\n}\n\n/** Aliases. */\nexport { APIConnectionError as ConnectionError, APITimeoutError as TimeoutError }\n\ntype ErrorClass = new (init: APIErrorInit) => APIError\n\nconst BY_TYPE: Record<string, ErrorClass> = {\n invalid_request: InvalidRequestError,\n unauthorized: AuthenticationError,\n free_records_exhausted: FreeRecordsExhaustedError,\n scrape_units_exhausted: ScrapeUnitsExhaustedError,\n forbidden: PermissionDeniedError,\n not_found: NotFoundError,\n idempotency_conflict: IdempotencyConflictError,\n window_full: RateLimitError,\n weekly_limit: RateLimitError,\n too_many_concurrent: RateLimitError,\n internal_error: InternalServerError,\n unavailable: ServiceUnavailableError,\n}\n\nfunction byStatus(status: number): ErrorClass {\n if (status === 400 || status === 413 || status === 422) return InvalidRequestError\n if (status === 401) return AuthenticationError\n if (status === 402) return PaymentRequiredError\n if (status === 403) return PermissionDeniedError\n if (status === 404) return NotFoundError\n if (status === 409) return IdempotencyConflictError\n if (status === 429) return RateLimitError\n if (status === 503) return ServiceUnavailableError\n if (status >= 500) return InternalServerError\n return APIError\n}\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\n/** `Retry-After` as seconds: a number of seconds or an HTTP date. */\nexport function parseRetryAfter(v: string | null, now: number = Date.now()): number | null {\n if (v == null || v.trim() === '') return null\n const n = Number(v)\n if (Number.isFinite(n)) return Math.max(0, n)\n const t = Date.parse(v)\n if (Number.isNaN(t)) return null\n return Math.max(0, Math.ceil((t - now) / 1000))\n}\n","export const VERSION = '0.2.1'\n","import { APIConnectionError, APIError, APITimeoutError, LeadsetsError, parseRetryAfter } from './errors.js'\nimport type { RateLimitInfo, ResponseMeta } from './types.js'\nimport { VERSION } from './version.js'\n\nexport const DEFAULT_BASE_URL = 'https://api.leadsets.ai'\nexport const DEFAULT_TIMEOUT_MS = 120_000\nexport const DEFAULT_MAX_RETRIES = 2\nexport const DEFAULT_MAX_RETRY_DELAY_MS = 60_000\n\ntype Fetch = (input: string, init: RequestInit) => Promise<Response>\n\nexport interface ClientOptions {\n /** Your API key (`ls_live_…`). Defaults to the LEADSETS_API_KEY or LEADSETS_KEY environment variable. */\n apiKey?: string | undefined\n /** Defaults to https://api.leadsets.ai (or the LEADSETS_BASE_URL environment variable). */\n baseURL?: string | undefined\n /** Retries on 429, 5xx, timeouts and network errors. Default 2. */\n maxRetries?: number | undefined\n /** Per-attempt timeout in milliseconds. Default 120000. */\n timeout?: number | undefined\n /**\n * The longest `Retry-After` the SDK will wait for before retrying, in milliseconds.\n * A 429 asking for a longer wait (a weekly limit, say) is thrown at once. Default 60000.\n */\n maxRetryDelay?: number | undefined\n /** A custom fetch implementation. Defaults to the global fetch. */\n fetch?: Fetch | undefined\n /** Headers sent with every request. */\n defaultHeaders?: Record<string, string> | undefined\n}\n\nexport interface RequestOptions {\n /**\n * Idempotency-Key for this call. The SDK generates one for every paid call when you don't,\n * and reuses it on retries, so a retry never counts records twice. Keys last 24 hours.\n */\n idempotencyKey?: string | undefined\n maxRetries?: number | undefined\n timeout?: number | undefined\n signal?: AbortSignal | undefined\n headers?: Record<string, string> | undefined\n}\n\ninterface ApiRequest {\n method: 'GET' | 'POST'\n path: string\n body?: unknown\n /** Paid POSTs: send an Idempotency-Key. */\n idempotent?: boolean\n}\n\nexport class HttpClient {\n readonly apiKey: string\n readonly baseURL: string\n readonly maxRetries: number\n readonly timeout: number\n readonly maxRetryDelay: number\n private readonly fetchImpl: Fetch\n private readonly defaultHeaders: Record<string, string>\n\n constructor(opts: ClientOptions = {}) {\n const apiKey = opts.apiKey ?? env('LEADSETS_API_KEY') ?? env('LEADSETS_KEY')\n if (!apiKey) {\n throw new LeadsetsError(\n 'No API key. Pass one to new Leadsets(apiKey) or set the LEADSETS_API_KEY environment variable. Get a free key at https://www.leadsets.ai/signup.',\n )\n }\n this.apiKey = apiKey\n this.baseURL = (opts.baseURL ?? env('LEADSETS_BASE_URL') ?? DEFAULT_BASE_URL).replace(/\\/+$/, '')\n this.maxRetries = nonNegative(opts.maxRetries, DEFAULT_MAX_RETRIES)\n this.timeout = nonNegative(opts.timeout, DEFAULT_TIMEOUT_MS)\n this.maxRetryDelay = nonNegative(opts.maxRetryDelay, DEFAULT_MAX_RETRY_DELAY_MS)\n const f = opts.fetch ?? (globalThis.fetch as Fetch | undefined)\n if (!f) throw new LeadsetsError('No fetch implementation found. Use Node 18+ or pass `fetch` in the options.')\n this.fetchImpl = opts.fetch ?? ((input, init) => globalThis.fetch(input, init))\n this.defaultHeaders = opts.defaultHeaders ?? {}\n }\n\n async request<T extends object>(req: ApiRequest, opts: RequestOptions = {}): Promise<T> {\n const maxRetries = nonNegative(opts.maxRetries, this.maxRetries)\n const timeout = nonNegative(opts.timeout, this.timeout)\n const idempotencyKey = req.idempotent ? (opts.idempotencyKey ?? newIdempotencyKey()) : (opts.idempotencyKey ?? null)\n const url = `${this.baseURL}/v1${req.path}`\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'User-Agent': `leadsets-sdk-js/${VERSION}`,\n ...this.defaultHeaders,\n ...opts.headers,\n Authorization: `Bearer ${this.apiKey}`,\n }\n if (req.body !== undefined) headers['Content-Type'] = 'application/json'\n if (idempotencyKey) headers['Idempotency-Key'] = idempotencyKey\n const body = req.body !== undefined ? JSON.stringify(req.body) : undefined\n\n for (let attempt = 0; ; attempt++) {\n let res: Response\n const timer = timeoutSignal(timeout, opts.signal)\n try {\n res = await this.fetchImpl(url, { method: req.method, headers, body, signal: timer.signal })\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError(undefined, { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n\n let text: string\n try {\n text = await res.text()\n } catch (err) {\n timer.clear()\n if (opts.signal?.aborted) throw err\n const e = timer.timedOut()\n ? new APITimeoutError(undefined, { cause: err })\n : new APIConnectionError('The connection closed before the response was read.', { cause: err })\n if (attempt < maxRetries) {\n await sleep(backoff(attempt), opts.signal)\n continue\n }\n throw e\n }\n timer.clear()\n const parsed = parseJson(text)\n\n if (res.ok) {\n const data = (parsed && typeof parsed === 'object' ? parsed : {}) as T\n const meta = responseMeta(res, data, idempotencyKey, attempt + 1)\n Object.defineProperty(data, 'lastResponse', {\n value: meta,\n enumerable: false,\n writable: false,\n configurable: true,\n })\n return data\n }\n\n const obj = (parsed && typeof parsed === 'object' ? parsed : {}) as { error?: unknown; request_id?: unknown }\n const error = obj.error && typeof obj.error === 'object' ? (obj.error as Record<string, unknown>) : undefined\n const apiErr = APIError.from({\n status: res.status,\n error: error ?? (text && !parsed ? { message: text.slice(0, 500) } : undefined),\n requestId: typeof obj.request_id === 'string' ? obj.request_id : null,\n headers: res.headers,\n body: parsed ?? text,\n })\n const delay = this.retryDelay(apiErr, attempt)\n if (attempt < maxRetries && delay !== null) {\n await sleep(delay, opts.signal)\n continue\n }\n throw apiErr\n }\n }\n\n /** Milliseconds to wait before retrying, or null to not retry. */\n private retryDelay(err: APIError, attempt: number): number | null {\n const retryable = err.status === 408 || err.status === 429 || err.status >= 500\n if (!retryable) return null\n if (err.retryAfter !== null) {\n const ms = err.retryAfter * 1000\n if (ms > this.maxRetryDelay) return null\n // A little jitter so parallel workers don't all retry at the same instant.\n return ms + Math.random() * 250\n }\n return backoff(attempt)\n }\n}\n\n/** Exponential backoff with jitter: ~0.5 s, 1 s, 2 s … capped at 8 s. */\nexport function backoff(attempt: number): number {\n const base = Math.min(8_000, 500 * 2 ** attempt)\n return base * (0.75 + Math.random() * 0.25)\n}\n\nfunction responseMeta(res: Response, data: object, idempotencyKey: string | null, attempts: number): ResponseMeta {\n const h = res.headers\n const rid = (data as { request_id?: unknown }).request_id\n return {\n status: res.status,\n headers: h,\n requestId: typeof rid === 'string' ? rid : null,\n idempotencyKey,\n idempotentReplayed: h.get('idempotent-replayed') === 'true',\n rateLimit: rateLimitInfo(h),\n attempts,\n }\n}\n\nexport function rateLimitInfo(h: Headers): RateLimitInfo {\n return {\n recordsRemaining: num(h.get('x-leadsets-records-remaining')),\n requestsRemaining: num(h.get('x-leadsets-requests-remaining')),\n weeklyRemaining: num(h.get('x-leadsets-weekly-remaining')),\n freeRemaining: num(h.get('x-leadsets-free-remaining')),\n retryAfter: parseRetryAfter(h.get('retry-after')),\n }\n}\n\nconst num = (v: string | null): number | null => {\n if (v == null || v === '') return null\n const n = Number(v)\n return Number.isFinite(n) ? n : null\n}\n\nfunction parseJson(text: string): unknown {\n if (!text) return null\n try {\n return JSON.parse(text)\n } catch {\n return null\n }\n}\n\nfunction nonNegative(v: number | undefined, fallback: number): number {\n return typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : fallback\n}\n\nfunction env(name: string): string | undefined {\n try {\n const p = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process\n const v = p?.env?.[name]\n return v?.trim() ? v.trim() : undefined\n } catch {\n return undefined\n }\n}\n\n/** A random UUID v4, from Web Crypto when available. */\nexport function newIdempotencyKey(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n if (c?.randomUUID) return c.randomUUID()\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n/** An AbortSignal that fires on timeout or when the caller's signal aborts. */\nfunction timeoutSignal(ms: number, outer?: AbortSignal) {\n const ctrl = new AbortController()\n let timedOut = false\n const timer =\n ms > 0\n ? setTimeout(() => {\n timedOut = true\n ctrl.abort()\n }, ms)\n : undefined\n const onAbort = () => ctrl.abort(outer?.reason)\n if (outer) {\n if (outer.aborted) ctrl.abort(outer.reason)\n else outer.addEventListener('abort', onAbort, { once: true })\n }\n return {\n signal: ctrl.signal,\n timedOut: () => timedOut,\n clear: () => {\n if (timer) clearTimeout(timer)\n outer?.removeEventListener('abort', onAbort)\n },\n }\n}\n\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(signal.reason)\n const t = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort)\n resolve()\n }, ms)\n const onAbort = () => {\n clearTimeout(t)\n reject(signal?.reason)\n }\n signal?.addEventListener('abort', onAbort, { once: true })\n })\n}\n","import type { RequestOptions } from './core.js'\n\nexport interface PaginationOptions extends RequestOptions {\n /** Stop after this many items (the last page asks only for what's left, so you pay for no more). */\n maxItems?: number | undefined\n /** Stop after this many pages. */\n maxPages?: number | undefined\n}\n\ninterface Page<T> {\n items: T[]\n next_cursor: string | null\n}\n\ntype Params = { limit?: number | undefined; cursor?: string | undefined }\n\n/**\n * Fetches pages by following `next_cursor`. When the caller passes an idempotencyKey, each\n * page gets its own key derived from it (`<key>-p2`, `<key>-p3` …), because each page has a\n * different body.\n */\nexport async function* paginate<P extends Params, R extends Page<unknown>>(\n fetchPage: (params: P, opts: RequestOptions) => Promise<R>,\n params: P,\n opts: PaginationOptions = {},\n): AsyncGenerator<R, void, undefined> {\n const { maxItems, maxPages, ...reqOpts } = opts\n let cursor = params.cursor\n let seen = 0\n for (let page = 1; ; page++) {\n if (maxPages !== undefined && page > maxPages) return\n let limit = params.limit\n if (maxItems !== undefined) {\n const left = maxItems - seen\n if (left <= 0) return\n limit = Math.min(limit ?? 25, left)\n }\n const pageParams = { ...params, ...(limit !== undefined ? { limit } : {}), ...(cursor ? { cursor } : {}) } as P\n const key = reqOpts.idempotencyKey\n const res = await fetchPage(pageParams, { ...reqOpts, idempotencyKey: key && page > 1 ? `${key}-p${page}` : key })\n seen += res.items.length\n yield res\n if (!res.next_cursor || res.items.length === 0) return\n cursor = res.next_cursor\n }\n}\n\nexport async function* items<T, R extends Page<T>>(pages: AsyncIterable<R>): AsyncGenerator<T, void, undefined> {\n for await (const p of pages) yield* p.items\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n CompaniesSearchParams,\n CompaniesSearchResponse,\n Company,\n CompanyEnrichParams,\n CompanyEnrichResponse,\n CountResponse,\n} from '../types.js'\n\nexport class Companies {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/companies/search. 1 search record per record returned; empty results use none. */\n search(params: CompaniesSearchParams = {}, options?: RequestOptions): Promise<CompaniesSearchResponse> {\n return this.http.request({ method: 'POST', path: '/companies/search', body: params, idempotent: true }, options)\n }\n\n /**\n * POST /v1/companies/search with `count_only`: how many companies match, without returning them.\n * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).\n */\n count(\n params: Omit<CompaniesSearchParams, 'limit' | 'cursor'> = {},\n options?: RequestOptions,\n ): Promise<CountResponse> {\n return this.http.request(\n { method: 'POST', path: '/companies/search', body: { ...params, count_only: true }, idempotent: true },\n options,\n )\n }\n\n /** Every matching company, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: CompaniesSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Company, void, undefined> {\n return items<Company, CompaniesSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results. */\n searchPages(\n params: CompaniesSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<CompaniesSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/companies/enrich. 1 enrichment record when found; 404 uses none. */\n enrich(params: CompanyEnrichParams, options?: RequestOptions): Promise<CompanyEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/companies/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { EmailVerifyParams, EmailVerifyResponse } from '../types.js'\n\nexport class Emails {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * POST /v1/emails/verify. One email (`email`) or up to 100 (`emails`), or pass a string or\n * an array directly. 1 enrichment record per email checked.\n */\n verify(params: EmailVerifyParams | string | string[], options?: RequestOptions): Promise<EmailVerifyResponse> {\n const body = typeof params === 'string' ? { email: params } : Array.isArray(params) ? { emails: params } : params\n return this.http.request({ method: 'POST', path: '/emails/verify', body, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { AsyncJob } from '../types.js'\n\nexport class Jobs {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/jobs/{id}: status of an async job. */\n get(id: string, options?: RequestOptions): Promise<AsyncJob> {\n if (!id) throw new TypeError('jobs.get: id is required')\n return this.http.request({ method: 'GET', path: `/jobs/${encodeURIComponent(id)}` }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport { items, type PaginationOptions, paginate } from '../pagination.js'\nimport type {\n CountResponse,\n PeopleSearchParams,\n PeopleSearchResponse,\n Person,\n PersonEnrichParams,\n PersonEnrichResponse,\n} from '../types.js'\n\nexport class People {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/people/search. 1 search record per record returned; empty results use none. */\n search(params: PeopleSearchParams = {}, options?: RequestOptions): Promise<PeopleSearchResponse> {\n return this.http.request({ method: 'POST', path: '/people/search', body: params, idempotent: true }, options)\n }\n\n /**\n * POST /v1/people/search with `count_only`: how many people match, without returning them.\n * Uses no records; counts as one request. Counting stops at 10,000 (`count_capped`).\n */\n count(\n params: Omit<PeopleSearchParams, 'limit' | 'cursor' | 'priorities'> = {},\n options?: RequestOptions,\n ): Promise<CountResponse> {\n return this.http.request(\n { method: 'POST', path: '/people/search', body: { ...params, count_only: true }, idempotent: true },\n options,\n )\n }\n\n /** Every matching person, page after page. Use `maxItems` to cap what you pay for. */\n searchAll(params: PeopleSearchParams = {}, options?: PaginationOptions): AsyncGenerator<Person, void, undefined> {\n return items<Person, PeopleSearchResponse>(this.searchPages(params, options))\n }\n\n /** Every page of results (with `usage` and `lastResponse` per page). */\n searchPages(\n params: PeopleSearchParams = {},\n options?: PaginationOptions,\n ): AsyncGenerator<PeopleSearchResponse, void, undefined> {\n return paginate((p, o) => this.search(p, o), params, options)\n }\n\n /** POST /v1/people/enrich. 1 enrichment record when found (+1 for a personal email); 404 uses none. */\n enrich(params: PersonEnrichParams, options?: RequestOptions): Promise<PersonEnrichResponse> {\n return this.http.request({ method: 'POST', path: '/people/enrich', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { ScrapeCompanyResponse, ScrapeJobsResponse, ScrapeParams } from '../types.js'\n\nexport class Scrape {\n constructor(private readonly http: HttpClient) {}\n\n /** POST /v1/scrape/company. 1 scrape unit per page read (default 1 page). Paid plans with scrape units. */\n company(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeCompanyResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/company', body: params, idempotent: true }, options)\n }\n\n /** POST /v1/scrape/jobs. 1 scrape unit per page read (default up to 3). Paid plans with scrape units. */\n jobs(params: ScrapeParams, options?: RequestOptions): Promise<ScrapeJobsResponse> {\n return this.http.request({ method: 'POST', path: '/scrape/jobs', body: params, idempotent: true }, options)\n }\n}\n","import type { HttpClient, RequestOptions } from '../core.js'\nimport type { UsageResponse } from '../types.js'\n\nexport class UsageResource {\n constructor(private readonly http: HttpClient) {}\n\n /** GET /v1/usage: what's left in every meter and when each window resets. Free to call. */\n get(options?: RequestOptions): Promise<UsageResponse> {\n return this.http.request({ method: 'GET', path: '/usage' }, options)\n }\n}\n","import { type ClientOptions, HttpClient } from './core.js'\nimport { Companies } from './resources/companies.js'\nimport { Emails } from './resources/emails.js'\nimport { Jobs } from './resources/jobs.js'\nimport { People } from './resources/people.js'\nimport { Scrape } from './resources/scrape.js'\nimport { UsageResource } from './resources/usage.js'\n\n/**\n * The Leadsets API client.\n *\n * ```ts\n * const ls = new Leadsets(process.env.LEADSETS_KEY)\n * const res = await ls.people.search({ function: ['revenue'], country: 'US', limit: 10 })\n * ```\n */\nexport class Leadsets {\n readonly people: People\n readonly companies: Companies\n readonly emails: Emails\n readonly scrape: Scrape\n readonly jobs: Jobs\n readonly usage: UsageResource\n /** The base URL requests go to. */\n readonly baseURL: string\n\n constructor(apiKey?: string | ClientOptions, options: ClientOptions = {}) {\n const opts: ClientOptions =\n typeof apiKey === 'object' && apiKey !== null ? apiKey : { ...options, apiKey: apiKey ?? options.apiKey }\n const http = new HttpClient(opts)\n this.baseURL = http.baseURL\n this.people = new People(http)\n this.companies = new Companies(http)\n this.emails = new Emails(http)\n this.scrape = new Scrape(http)\n this.jobs = new Jobs(http)\n this.usage = new UsageResource(http)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leadsetsai/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Official TypeScript and JavaScript SDK for the Leadsets B2B data API: people and company search, enrichment, email verification and web scraping.",
5
5
  "license": "MIT",
6
6
  "author": "Leadsets",