leadmeteor 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  export type ClientOptions = {
2
2
  apiKey: string;
3
3
  baseUrl?: string;
4
+ maxRetries?: number;
4
5
  };
5
6
  export declare class Client {
6
7
  private readonly apiKey;
7
8
  private readonly baseUrl;
9
+ private readonly maxRetries;
8
10
  constructor(options: ClientOptions);
9
11
  request<T>(method: string, path: string, params?: Record<string, string>): Promise<T>;
12
+ private getRetryDelay;
13
+ private sleep;
10
14
  }
package/dist/client.js CHANGED
@@ -5,32 +5,67 @@ const error_1 = require("./error");
5
5
  class Client {
6
6
  apiKey;
7
7
  baseUrl;
8
+ maxRetries;
8
9
  constructor(options) {
9
10
  if (!options.apiKey) {
10
11
  throw new error_1.LeadmeteorError("API key is required", 0);
11
12
  }
12
13
  this.apiKey = options.apiKey;
13
14
  this.baseUrl = (options.baseUrl ?? "https://api.leadmeteor.com").replace(/\/+$/, "");
15
+ this.maxRetries = options.maxRetries ?? 2;
14
16
  }
15
17
  async request(method, path, params) {
16
18
  let url = `${this.baseUrl}${path}`;
17
- if (params) {
19
+ const isGet = method.toUpperCase() === "GET";
20
+ if (params && isGet) {
18
21
  const query = new URLSearchParams(params).toString();
19
22
  url += `?${query}`;
20
23
  }
21
- const response = await fetch(url, {
22
- method,
23
- headers: {
24
- Authorization: `Bearer ${this.apiKey}`,
25
- "Content-Type": "application/json",
26
- },
27
- });
28
- const body = (await response.json());
29
- if (!response.ok || !body.success) {
30
- const error = !body.success ? body.error : `Request failed with status ${response.status}`;
31
- throw new error_1.LeadmeteorError(error, response.status);
24
+ let lastError;
25
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
26
+ if (attempt > 0) {
27
+ await this.sleep(this.getRetryDelay(attempt));
28
+ }
29
+ let response;
30
+ try {
31
+ response = await fetch(url, {
32
+ method,
33
+ headers: {
34
+ Authorization: `Bearer ${this.apiKey}`,
35
+ "Content-Type": "application/json",
36
+ },
37
+ ...(params && !isGet ? { body: JSON.stringify(params) } : {}),
38
+ });
39
+ }
40
+ catch (error) {
41
+ lastError = error;
42
+ continue;
43
+ }
44
+ if (response.status >= 500) {
45
+ const body = await response.json().catch(() => null);
46
+ const message = body?.error?.message ?? `Request failed with status ${response.status}`;
47
+ lastError = new error_1.LeadmeteorError(message, response.status);
48
+ continue;
49
+ }
50
+ if (!response.ok) {
51
+ const body = await response.json().catch(() => null);
52
+ const message = body?.error?.message ?? `Request failed with status ${response.status}`;
53
+ throw new error_1.LeadmeteorError(message, response.status);
54
+ }
55
+ return (await response.json());
32
56
  }
33
- return body.data;
57
+ if (lastError instanceof error_1.LeadmeteorError) {
58
+ throw lastError;
59
+ }
60
+ throw new error_1.LeadmeteorError(lastError instanceof Error ? lastError.message : "Request failed after retries", 0);
61
+ }
62
+ getRetryDelay(attempt) {
63
+ const baseDelay = Math.min(0.5 * Math.pow(2, attempt - 1), 5);
64
+ const jitter = 0.5 * (1 + Math.random());
65
+ return Math.max(0.5, baseDelay * jitter) * 1000;
66
+ }
67
+ sleep(ms) {
68
+ return new Promise((resolve) => setTimeout(resolve, ms));
34
69
  }
35
70
  }
36
71
  exports.Client = Client;
package/dist/index.d.ts CHANGED
@@ -1,27 +1,14 @@
1
1
  import { type ClientOptions } from "./client";
2
- import { People } from "./resources/people";
3
- import { Companies } from "./resources/companies";
4
- import * as _EmailsModule from "./types/emails";
5
- import * as _DomainsModule from "./types/domains";
2
+ import { EmailsResource } from "./resources/emails";
3
+ import { DomainsResource } from "./resources/domains";
4
+ import { CompaniesResource } from "./resources/companies";
5
+ import { PeopleResource } from "./resources/people";
6
6
  declare class Leadmeteor {
7
- readonly emails: Leadmeteor.Emails;
8
- readonly people: People;
9
- readonly companies: Companies;
10
- readonly domains: Leadmeteor.Domains;
7
+ readonly emails: EmailsResource;
8
+ readonly domains: DomainsResource;
9
+ readonly companies: CompaniesResource;
10
+ readonly people: PeopleResource;
11
11
  constructor(apiKey: string, options?: Omit<ClientOptions, "apiKey">);
12
12
  }
13
- declare namespace Leadmeteor {
14
- export import Emails = _EmailsModule.Emails;
15
- interface Emails {
16
- verify(params: Emails.EmailVerificationParams): Promise<Emails.EmailVerification>;
17
- lookup(params: Emails.LookupParams): Promise<unknown>;
18
- search(params: Emails.SearchParams): Promise<unknown>;
19
- }
20
- export import Domains = _DomainsModule.Domains;
21
- interface Domains {
22
- lookup(params: Domains.DomainLookupParams): Promise<Domains.DomainLookup>;
23
- }
24
- }
13
+ export { Leadmeteor } from "./types";
25
14
  export default Leadmeteor;
26
- export { Leadmeteor };
27
- export { LeadmeteorError } from "./error";
package/dist/index.js CHANGED
@@ -1,27 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LeadmeteorError = exports.Leadmeteor = void 0;
4
3
  const client_1 = require("./client");
5
4
  const emails_1 = require("./resources/emails");
6
- const people_1 = require("./resources/people");
7
- const companies_1 = require("./resources/companies");
8
5
  const domains_1 = require("./resources/domains");
6
+ const companies_1 = require("./resources/companies");
7
+ const people_1 = require("./resources/people");
9
8
  class Leadmeteor {
10
9
  emails;
11
- people;
12
- companies;
13
10
  domains;
11
+ companies;
12
+ people;
14
13
  constructor(apiKey, options) {
15
14
  const client = new client_1.Client({ apiKey, ...options });
16
15
  this.emails = new emails_1.EmailsResource(client);
17
- this.people = new people_1.People(client);
18
- this.companies = new companies_1.Companies(client);
16
+ this.people = new people_1.PeopleResource(client);
17
+ this.companies = new companies_1.CompaniesResource(client);
19
18
  this.domains = new domains_1.DomainsResource(client);
20
19
  }
21
20
  }
22
- exports.Leadmeteor = Leadmeteor;
23
- (function (Leadmeteor) {
24
- })(Leadmeteor || (exports.Leadmeteor = Leadmeteor = {}));
21
+ // Exports
22
+ module.exports = Leadmeteor;
25
23
  exports.default = Leadmeteor;
26
- var error_1 = require("./error");
27
- Object.defineProperty(exports, "LeadmeteorError", { enumerable: true, get: function () { return error_1.LeadmeteorError; } });
@@ -1,5 +1,5 @@
1
1
  import type { Client } from "../client";
2
- export declare class Companies {
2
+ export declare class CompaniesResource {
3
3
  private readonly client;
4
4
  constructor(client: Client);
5
5
  lookup(params: Record<string, string>): Promise<unknown>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Companies = void 0;
4
- class Companies {
3
+ exports.CompaniesResource = void 0;
4
+ class CompaniesResource {
5
5
  client;
6
6
  constructor(client) {
7
7
  this.client = client;
@@ -13,4 +13,4 @@ class Companies {
13
13
  return this.client.request("GET", "/v1/companies/search", params);
14
14
  }
15
15
  }
16
- exports.Companies = Companies;
16
+ exports.CompaniesResource = CompaniesResource;
@@ -1,7 +1,7 @@
1
1
  import type { Client } from "../client";
2
- import type { Domains } from "../types/domains";
2
+ import type { Leadmeteor } from "../types";
3
3
  export declare class DomainsResource {
4
4
  private readonly client;
5
5
  constructor(client: Client);
6
- lookup(params: Domains.DomainLookupParams): Promise<Domains.DomainLookup>;
6
+ lookup(params: Leadmeteor.Domains.DomainLookupParams): Promise<Leadmeteor.Domains.DomainLookup>;
7
7
  }
@@ -1,9 +1,9 @@
1
1
  import type { Client } from "../client";
2
- import type { Emails } from "../types/emails";
2
+ import type { Leadmeteor } from "../types";
3
3
  export declare class EmailsResource {
4
4
  private readonly client;
5
5
  constructor(client: Client);
6
- verify(params: Emails.EmailVerificationParams): Promise<Emails.EmailVerification>;
7
- lookup(params: Emails.LookupParams): Promise<unknown>;
8
- search(params: Emails.SearchParams): Promise<unknown>;
6
+ verify(params: Leadmeteor.Emails.EmailVerificationParams): Promise<Leadmeteor.Emails.EmailVerification>;
7
+ lookup(params: Leadmeteor.Emails.LookupParams): Promise<unknown>;
8
+ search(params: Leadmeteor.Emails.SearchParams): Promise<unknown>;
9
9
  }
@@ -7,7 +7,7 @@ class EmailsResource {
7
7
  this.client = client;
8
8
  }
9
9
  async verify(params) {
10
- return this.client.request("GET", "/v1/emails/verify", {
10
+ return this.client.request("POST", "/v1/emails/verify", {
11
11
  email: params.email,
12
12
  });
13
13
  }
@@ -1,5 +1,5 @@
1
1
  import type { Client } from "../client";
2
- export declare class People {
2
+ export declare class PeopleResource {
3
3
  private readonly client;
4
4
  constructor(client: Client);
5
5
  lookup(params: Record<string, string>): Promise<unknown>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.People = void 0;
4
- class People {
3
+ exports.PeopleResource = void 0;
4
+ class PeopleResource {
5
5
  client;
6
6
  constructor(client) {
7
7
  this.client = client;
@@ -13,4 +13,4 @@ class People {
13
13
  return this.client.request("GET", "/v1/people/search", params);
14
14
  }
15
15
  }
16
- exports.People = People;
16
+ exports.PeopleResource = PeopleResource;
@@ -3,8 +3,36 @@ export declare namespace Emails {
3
3
  email: string;
4
4
  };
5
5
  type EmailVerification = {
6
- status: Status;
7
- checks: Checks;
6
+ email: string;
7
+ status: string;
8
+ checks: {
9
+ format: {
10
+ status: string;
11
+ passed: boolean;
12
+ reason?: string;
13
+ };
14
+ dns: {
15
+ status: string;
16
+ passed: boolean;
17
+ reason?: string;
18
+ };
19
+ mx: {
20
+ status: string;
21
+ passed: boolean;
22
+ reason?: string;
23
+ };
24
+ smtp: {
25
+ status: string;
26
+ passed: boolean;
27
+ reason?: string;
28
+ };
29
+ };
30
+ is_disposable: boolean;
31
+ is_free_provider: boolean;
32
+ is_role_based: boolean;
33
+ id: string;
34
+ object: string;
35
+ created_at: number;
8
36
  };
9
37
  type LookupParams = EmailVerificationParams | {
10
38
  name: string;
@@ -16,18 +44,4 @@ export declare namespace Emails {
16
44
  domain: string;
17
45
  email?: string;
18
46
  };
19
- type CheckStatus = Status;
20
- type Status = "valid" | "skipped" | "invalid" | "unknown" | "risky";
21
- type CheckResult = {
22
- status: Status;
23
- passed: boolean;
24
- reason?: string;
25
- };
26
- type Checks = {
27
- format: CheckResult;
28
- disposable: CheckResult;
29
- dns: CheckResult;
30
- mx: CheckResult;
31
- smtp: CheckResult;
32
- };
33
47
  }
@@ -1,2 +1,60 @@
1
- export * from "./emails";
2
- //# sourceMappingURL=index.d.ts.map
1
+ export declare namespace Leadmeteor {
2
+ namespace Emails {
3
+ type EmailVerificationParams = {
4
+ email: string;
5
+ };
6
+ type EmailVerification = {
7
+ email: string;
8
+ status: string;
9
+ checks: {
10
+ format: {
11
+ status: string;
12
+ passed: boolean;
13
+ reason?: string;
14
+ };
15
+ dns: {
16
+ status: string;
17
+ passed: boolean;
18
+ reason?: string;
19
+ };
20
+ mx: {
21
+ status: string;
22
+ passed: boolean;
23
+ reason?: string;
24
+ };
25
+ smtp: {
26
+ status: string;
27
+ passed: boolean;
28
+ reason?: string;
29
+ };
30
+ };
31
+ is_disposable: boolean;
32
+ is_free_provider: boolean;
33
+ is_role_based: boolean;
34
+ id: string;
35
+ object: string;
36
+ created_at: number;
37
+ };
38
+ type LookupParams = EmailVerificationParams | {
39
+ name: string;
40
+ company: string;
41
+ } | {
42
+ linkedin_url: string;
43
+ };
44
+ type SearchParams = {
45
+ domain: string;
46
+ email?: string;
47
+ };
48
+ }
49
+ namespace Domains {
50
+ type DomainLookupParams = {
51
+ domain: string;
52
+ };
53
+ type DomainLookup = {
54
+ domain: string;
55
+ expires_at?: string;
56
+ registered_at?: string;
57
+ registrar?: string;
58
+ };
59
+ }
60
+ }
@@ -1,19 +1,3 @@
1
1
  "use strict";
2
2
  // Auto-generated from our API
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
3
  Object.defineProperty(exports, "__esModule", { value: true });
18
- __exportStar(require("./emails"), exports);
19
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leadmeteor",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Official Leadmeteor SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,9 +12,16 @@
12
12
  "build": "tsc",
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
- "keywords": ["leadmeteor", "email-verification", "sdk"],
15
+ "keywords": [
16
+ "leadmeteor",
17
+ "email verification",
18
+ "bulk emails checker",
19
+ "leads verifier"
20
+ ],
16
21
  "license": "MIT",
22
+ "dependencies": {},
17
23
  "devDependencies": {
24
+ "@types/node": "^25.5.0",
18
25
  "typescript": "^5.9.3"
19
26
  }
20
27
  }