@absolutejs/engagement-apollo 0.0.13 → 0.0.15
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/index.d.ts +5 -5
- package/dist/index.js +25 -13
- package/dist/manifest.d.ts +8 -25
- package/dist/manifest.json +84 -71
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EngagementSource } from "@absolutejs/engagement";
|
|
2
2
|
export type ApolloOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** Override for testing or a proxy. Defaults to https://api.apollo.io. */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Inject a fetch (tests, instrumentation). Defaults to global fetch. */
|
|
7
|
+
fetchImpl?: typeof fetch;
|
|
8
8
|
};
|
|
9
9
|
export declare const apolloSource: (options: ApolloOptions) => EngagementSource;
|
package/dist/index.js
CHANGED
|
@@ -60,14 +60,17 @@ var apolloSource = (options) => {
|
|
|
60
60
|
const res = await doFetch(`${baseUrl}${path}`, {
|
|
61
61
|
body: JSON.stringify(body),
|
|
62
62
|
headers,
|
|
63
|
-
method: "POST"
|
|
63
|
+
method: "POST",
|
|
64
|
+
signal: AbortSignal.timeout(30000)
|
|
64
65
|
});
|
|
65
66
|
if (res.status === 429)
|
|
66
67
|
throw new RateLimitError("apollo");
|
|
67
68
|
if (!res.ok)
|
|
68
|
-
|
|
69
|
-
const json = await res.json();
|
|
70
|
-
|
|
69
|
+
throw new EngagementProviderError("apollo", res.status, path);
|
|
70
|
+
const json = await res.json().catch(() => null);
|
|
71
|
+
if (!isRecord(json))
|
|
72
|
+
throw new EngagementProviderError("apollo", 502, `invalid ${path} response`);
|
|
73
|
+
return json;
|
|
71
74
|
};
|
|
72
75
|
const normalizePerson = (person) => {
|
|
73
76
|
const org = isRecord(person.organization) ? person.organization : null;
|
|
@@ -80,7 +83,7 @@ var apolloSource = (options) => {
|
|
|
80
83
|
].filter((value) => value !== null).filter((value) => !LOCKED_EMAIL.test(value))));
|
|
81
84
|
return {
|
|
82
85
|
company: org ? str(org.name) : null,
|
|
83
|
-
companyDomain: org ?
|
|
86
|
+
companyDomain: org ? companyDomain(org) : null,
|
|
84
87
|
emails,
|
|
85
88
|
facebookUrl: str(person.facebook_url),
|
|
86
89
|
firstName: str(person.first_name),
|
|
@@ -100,33 +103,42 @@ var apolloSource = (options) => {
|
|
|
100
103
|
};
|
|
101
104
|
};
|
|
102
105
|
const matchById = async (id) => {
|
|
103
|
-
const json = await post("/v1/people/match", { id });
|
|
104
|
-
|
|
106
|
+
const json = await post("/api/v1/people/match", { id });
|
|
107
|
+
if (json.person !== null && !isRecord(json.person))
|
|
108
|
+
throw new EngagementProviderError("apollo", 502, "invalid person enrichment response");
|
|
109
|
+
const person = isRecord(json.person) ? json.person : null;
|
|
105
110
|
return person ? normalizePerson(person) : null;
|
|
106
111
|
};
|
|
107
112
|
const enrichPerson = async (query) => {
|
|
108
|
-
const json = await post("/v1/people/match", {
|
|
113
|
+
const json = await post("/api/v1/people/match", {
|
|
109
114
|
domain: query.domain,
|
|
110
115
|
email: query.email,
|
|
111
116
|
linkedin_url: query.linkedinUrl,
|
|
112
117
|
name: query.name,
|
|
113
118
|
organization_name: query.company
|
|
114
119
|
});
|
|
115
|
-
|
|
120
|
+
if (json.person !== null && !isRecord(json.person))
|
|
121
|
+
throw new EngagementProviderError("apollo", 502, "invalid person enrichment response");
|
|
122
|
+
const person = isRecord(json.person) ? json.person : null;
|
|
116
123
|
return person ? normalizePerson(person) : null;
|
|
117
124
|
};
|
|
118
125
|
const searchPeople = async (query) => {
|
|
119
126
|
const limit = query.limit ?? DEFAULT_SEARCH_LIMIT;
|
|
120
|
-
|
|
127
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100)
|
|
128
|
+
throw new RangeError("Apollo people limit must be an integer from 1 to 100");
|
|
129
|
+
const search = await post("/api/v1/mixed_people/api_search", {
|
|
121
130
|
page: 1,
|
|
122
131
|
per_page: limit,
|
|
123
132
|
...query.titles && query.titles.length > 0 ? { person_titles: query.titles } : {},
|
|
124
133
|
...query.domain ? { q_organization_domains_list: [query.domain] } : {},
|
|
125
134
|
...!query.domain && query.company ? { q_keywords: query.company } : {}
|
|
126
135
|
});
|
|
127
|
-
const searchRequests =
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
const searchRequests = 1;
|
|
137
|
+
if (!Array.isArray(search.people))
|
|
138
|
+
throw new EngagementProviderError("apollo", 502, "invalid people search response");
|
|
139
|
+
const ids = [
|
|
140
|
+
...new Set(search.people.map((person) => isRecord(person) ? str(person.id) : null).filter((id) => id !== null))
|
|
141
|
+
].slice(0, limit);
|
|
130
142
|
if (ids.length === 0) {
|
|
131
143
|
return { people: [], revealsAttempted: 0, searchRequests };
|
|
132
144
|
}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
import type { ApolloOptions } from "./index";
|
|
2
|
-
export declare const manifest: Omit<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
|
8
|
-
|
|
9
|
-
tools?:
|
|
10
|
-
| Record<
|
|
11
|
-
string,
|
|
12
|
-
import("@absolutejs/manifest").LegacyManifestTool<never>
|
|
13
|
-
>
|
|
14
|
-
| undefined;
|
|
15
|
-
}
|
|
16
|
-
| {
|
|
17
|
-
contract: 2;
|
|
18
|
-
tools?:
|
|
19
|
-
| Record<
|
|
20
|
-
string,
|
|
21
|
-
import("@absolutejs/manifest").AuthorizedManifestTool<never>
|
|
22
|
-
>
|
|
23
|
-
| undefined;
|
|
24
|
-
}
|
|
25
|
-
) & {
|
|
2
|
+
export declare const manifest: Omit<import("@absolutejs/manifest").PackageManifest<ApolloOptions, never>, "contract" | "settings" | "tools"> & (({
|
|
3
|
+
contract: 1;
|
|
4
|
+
tools?: Record<string, import("@absolutejs/manifest").LegacyManifestTool<never>> | undefined;
|
|
5
|
+
} | {
|
|
6
|
+
contract: 2;
|
|
7
|
+
tools?: Record<string, import("@absolutejs/manifest").AuthorizedManifestTool<never>> | undefined;
|
|
8
|
+
}) & {
|
|
26
9
|
settings: import("@sinclair/typebox").TObject<{}>;
|
|
27
|
-
|
|
10
|
+
});
|
package/dist/manifest.json
CHANGED
|
@@ -1,73 +1,86 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
2
|
+
"contract": 2,
|
|
3
|
+
"discovery": {
|
|
4
|
+
"audiences": [
|
|
5
|
+
"agent-hosts",
|
|
6
|
+
"application-developers"
|
|
7
|
+
],
|
|
8
|
+
"intents": [
|
|
9
|
+
"enrich a person with Apollo",
|
|
10
|
+
"enrich a company with Apollo",
|
|
11
|
+
"search people by role",
|
|
12
|
+
"research company revenue and ownership",
|
|
13
|
+
"read Apollo outreach activity"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"apollo",
|
|
17
|
+
"engagement",
|
|
18
|
+
"enrichment",
|
|
19
|
+
"outreach",
|
|
20
|
+
"sales"
|
|
21
|
+
],
|
|
22
|
+
"protocols": [
|
|
23
|
+
"HTTPS"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"identity": {
|
|
27
|
+
"accent": "#5c4cff",
|
|
28
|
+
"category": "sales",
|
|
29
|
+
"description": "Apollo-backed EngagementSource for person and company enrichment, role-based people search, and outreach activity with explicit provider-credit accounting.",
|
|
30
|
+
"docsUrl": "https://github.com/absolutejs/engagement-adapters/tree/main/apollo",
|
|
31
|
+
"name": "@absolutejs/engagement-apollo",
|
|
32
|
+
"tagline": "Connect Apollo enrichment and outreach to your site."
|
|
33
|
+
},
|
|
34
|
+
"implements": [
|
|
35
|
+
{
|
|
36
|
+
"contract": "engagement/source",
|
|
37
|
+
"factory": "apolloSource",
|
|
38
|
+
"from": "@absolutejs/engagement-apollo",
|
|
39
|
+
"requires": {
|
|
40
|
+
"env": [
|
|
41
|
+
{
|
|
42
|
+
"description": "Apollo API key",
|
|
43
|
+
"docsUrl": "https://developer.apollo.io/keys/",
|
|
44
|
+
"key": "APOLLO_API_KEY",
|
|
45
|
+
"secret": true
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"peers": [
|
|
49
|
+
{
|
|
50
|
+
"name": "@absolutejs/engagement",
|
|
51
|
+
"range": ">=0.0.10 <0.1",
|
|
52
|
+
"reason": "Shared engagement contracts and rate-limit identity"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"settings": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"properties": {
|
|
59
|
+
"baseUrl": {
|
|
60
|
+
"description": "Apollo-compatible API origin. Leave empty for the official Apollo API.",
|
|
61
|
+
"format": "uri",
|
|
62
|
+
"title": "API origin",
|
|
63
|
+
"type": "string"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"title": "Apollo",
|
|
68
|
+
"wiring": {
|
|
69
|
+
"code": "apolloSource({ apiKey: ${env.APOLLO_API_KEY}, ...${settings} })",
|
|
70
|
+
"imports": [
|
|
71
|
+
{
|
|
72
|
+
"from": "@absolutejs/engagement-apollo",
|
|
73
|
+
"names": [
|
|
74
|
+
"apolloSource"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"settings": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"properties": {}
|
|
84
|
+
},
|
|
85
|
+
"wiring": []
|
|
73
86
|
}
|