@absolutejs/engagement-apollo 0.0.2 → 0.0.4

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // @bun
2
2
  // src/index.ts
3
+ import { RateLimitError } from "@absolutejs/engagement";
3
4
  var APOLLO_BASE_URL = "https://api.apollo.io";
4
5
  var DEFAULT_ACTIVITY_LIMIT = 50;
5
6
  var DEFAULT_SEARCH_LIMIT = 6;
@@ -24,6 +25,8 @@ var apolloSource = (options) => {
24
25
  headers,
25
26
  method: "POST"
26
27
  });
28
+ if (res.status === 429)
29
+ throw new RateLimitError("apollo");
27
30
  if (!res.ok)
28
31
  return null;
29
32
  const json = await res.json();
@@ -31,6 +34,8 @@ var apolloSource = (options) => {
31
34
  };
32
35
  const get = async (path) => {
33
36
  const res = await doFetch(`${baseUrl}${path}`, { headers, method: "GET" });
37
+ if (res.status === 429)
38
+ throw new RateLimitError("apollo");
34
39
  if (!res.ok)
35
40
  return null;
36
41
  const json = await res.json();
@@ -38,11 +43,13 @@ var apolloSource = (options) => {
38
43
  };
39
44
  const normalizePerson = (person) => {
40
45
  const org = isRecord(person.organization) ? person.organization : null;
41
- const email = str(person.email);
46
+ const contact = isRecord(person.contact) ? person.contact : null;
47
+ const personalEmails = Array.isArray(person.personal_emails) ? person.personal_emails.map(str) : [];
48
+ const emails = Array.from(new Set([str(person.email), contact ? str(contact.email) : null, ...personalEmails].filter((value) => value !== null).filter((value) => !LOCKED_EMAIL.test(value))));
42
49
  return {
43
50
  company: org ? str(org.name) : null,
44
51
  companyDomain: org ? str(org.primary_domain) : null,
45
- email: email && !LOCKED_EMAIL.test(email) ? email : null,
52
+ emails,
46
53
  firstName: str(person.first_name),
47
54
  lastName: str(person.last_name),
48
55
  linkedinUrl: str(person.linkedin_url),
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Alex Kahn",
3
3
  "description": "Apollo.io EngagementSource adapter for @absolutejs/engagement — person/company enrichment and outreach activity (emails sent/opened/replied) from the Apollo API.",
4
4
  "devDependencies": {
5
- "@absolutejs/engagement": "^0.0.2",
5
+ "@absolutejs/engagement": "0.0.4",
6
6
  "@types/bun": "latest",
7
7
  "typescript": "5.8.3"
8
8
  },
@@ -39,5 +39,5 @@
39
39
  },
40
40
  "type": "module",
41
41
  "types": "./dist/index.d.ts",
42
- "version": "0.0.2"
42
+ "version": "0.0.4"
43
43
  }