Skip to content

Commit 30a9f2c

Browse files
authored
New Components - lusha (#14994)
* lusha init * [ACTION] Lusha: Prospecting APIs #14992 Actions - Contact Search - Company Search - Contact Enrich - Company Enrich * pnpm update * new release * remove node modules * some adjusts
1 parent 5797912 commit 30a9f2c

File tree

10 files changed

+464
-101
lines changed

10 files changed

+464
-101
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import lusha from "../../lusha.app.mjs";
2+
3+
export default {
4+
key: "lusha-company-enrich",
5+
name: "Enrich Companies",
6+
description: "Enriches company information based on provided company IDs. [See the documentation](https://www.lusha.com/docs/#company-enrich)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
lusha,
11+
requestId: {
12+
propDefinition: [
13+
lusha,
14+
"requestId",
15+
],
16+
label: "Company Request ID",
17+
description: "The request ID generated from the company search response.",
18+
},
19+
companiesIds: {
20+
propDefinition: [
21+
lusha,
22+
"companiesIds",
23+
],
24+
},
25+
},
26+
async run({ $ }) {
27+
const response = await this.lusha.enrichCompanies({
28+
$,
29+
data: {
30+
requestId: this.requestId,
31+
companiesIds: this.companiesIds,
32+
},
33+
});
34+
$.export("$summary", `Successfully enriched ${this.companiesIds.length} companies`);
35+
return response;
36+
},
37+
};
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import lusha from "../../lusha.app.mjs";
3+
4+
export default {
5+
key: "lusha-company-search",
6+
name: "Search Companies",
7+
description: "Search for companies using various filters. [See the documentation](https://www.lusha.com/docs/#contactcompany-search)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
lusha,
12+
names: {
13+
propDefinition: [
14+
lusha,
15+
"companyNames",
16+
],
17+
optional: true,
18+
},
19+
domains: {
20+
propDefinition: [
21+
lusha,
22+
"domains",
23+
],
24+
optional: true,
25+
},
26+
locations: {
27+
propDefinition: [
28+
lusha,
29+
"locations",
30+
],
31+
optional: true,
32+
},
33+
sizes: {
34+
propDefinition: [
35+
lusha,
36+
"sizes",
37+
],
38+
optional: true,
39+
},
40+
revenues: {
41+
propDefinition: [
42+
lusha,
43+
"revenues",
44+
],
45+
optional: true,
46+
},
47+
sicCodes: {
48+
propDefinition: [
49+
lusha,
50+
"sicCodes",
51+
],
52+
optional: true,
53+
},
54+
naicsCodes: {
55+
propDefinition: [
56+
lusha,
57+
"naicsCodes",
58+
],
59+
optional: true,
60+
},
61+
limit: {
62+
type: "string",
63+
label: "Limit",
64+
description: "The maximum number of results to return. **This feature is used to avoid timeouts due to very long returns.**",
65+
},
66+
},
67+
async run({ $ }) {
68+
try {
69+
const include = {};
70+
71+
if (this.names) include.names = parseObject(this.names);
72+
if (this.domains) include.domains = parseObject(this.domains);
73+
if (this.locations) include.locations = parseObject(this.locations);
74+
if (this.sizes) include.sizes = parseObject(this.sizes);
75+
if (this.revenues) include.revenues = parseObject(this.revenues);
76+
if (this.sicCodes) include.sicCodes = parseObject(this.sicCodes);
77+
if (this.naicsCodes) include.naicsCodes = parseObject(this.naicsCodes);
78+
79+
const response = this.lusha.paginate({
80+
$,
81+
maxResults: this.limit,
82+
fn: this.lusha.searchCompanies,
83+
data: {
84+
filters: {
85+
companies: {
86+
include,
87+
},
88+
},
89+
},
90+
});
91+
92+
const responseArray = [];
93+
94+
for await (const item of response) {
95+
responseArray.push(item);
96+
}
97+
98+
$.export("$summary", `Successfully retrieved ${responseArray.length} companies`);
99+
return responseArray;
100+
} catch (error) {
101+
$.export("$summary", "Failed to search companies");
102+
throw error;
103+
}
104+
},
105+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import lusha from "../../lusha.app.mjs";
2+
3+
export default {
4+
key: "lusha-contact-enrich",
5+
name: "Enrich Contacts",
6+
description: "Enriches contacts based on provided IDs. [See the documentation](https://www.lusha.com/docs/#contact-enrich)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
lusha,
11+
requestId: {
12+
propDefinition: [
13+
lusha,
14+
"requestId",
15+
],
16+
label: "Contact Request ID",
17+
description: "The request ID generated from the contact search response.",
18+
},
19+
contactIds: {
20+
propDefinition: [
21+
lusha,
22+
"contactIds",
23+
],
24+
},
25+
},
26+
async run({ $ }) {
27+
const response = await this.lusha.enrichContacts({
28+
$,
29+
data: {
30+
requestId: this.requestId,
31+
contactIds: this.contactIds,
32+
},
33+
});
34+
$.export("$summary", `Successfully enriched ${this.contactIds.length} contacts`);
35+
return response;
36+
},
37+
};
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import lusha from "../../lusha.app.mjs";
3+
4+
export default {
5+
key: "lusha-contact-search",
6+
name: "Search Contacts",
7+
description: "Search for contacts using various filters. [See the documentation](https://www.lusha.com/docs/#contactcompany-search)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
lusha,
12+
names: {
13+
propDefinition: [
14+
lusha,
15+
"contactNames",
16+
],
17+
label: "Contact Names",
18+
description: "Names of contacts to search.",
19+
},
20+
jobTitles: {
21+
propDefinition: [
22+
lusha,
23+
"jobTitles",
24+
],
25+
},
26+
jobTitlesExactMatch: {
27+
propDefinition: [
28+
lusha,
29+
"jobTitlesExactMatch",
30+
],
31+
},
32+
countries: {
33+
propDefinition: [
34+
lusha,
35+
"countries",
36+
],
37+
},
38+
seniority: {
39+
propDefinition: [
40+
lusha,
41+
"seniority",
42+
],
43+
},
44+
departments: {
45+
propDefinition: [
46+
lusha,
47+
"departments",
48+
],
49+
},
50+
existingDataPoints: {
51+
propDefinition: [
52+
lusha,
53+
"existingDataPoints",
54+
],
55+
},
56+
location: {
57+
propDefinition: [
58+
lusha,
59+
"location",
60+
],
61+
},
62+
},
63+
async run({ $ }) {
64+
const include = {};
65+
66+
if (this.names) include.names = parseObject(this.names);
67+
if (this.jobTitles) include.jobTitles = parseObject(this.jobTitles);
68+
if (this.jobTitlesExactMatch)
69+
include.jobTitlesExactMatch = parseObject(this.jobTitlesExactMatch);
70+
if (this.countries) include.countries = parseObject(this.countries);
71+
if (this.seniority) include.seniority = parseObject(this.seniority);
72+
if (this.departments) include.departments = parseObject(this.departments);
73+
if (this.existingDataPoints) include.existingDataPoints = parseObject(this.existingDataPoints);
74+
if (this.location) include.location = parseObject(this.location);
75+
76+
const response = this.lusha.paginate({
77+
$,
78+
maxResults: this.limit,
79+
fn: this.lusha.searchContacts,
80+
data: {
81+
filters: {
82+
contacts: {
83+
include,
84+
},
85+
},
86+
},
87+
});
88+
89+
const responseArray = [];
90+
91+
for await (const item of response) {
92+
responseArray.push(item);
93+
}
94+
95+
$.export("$summary", `Found ${responseArray.length} contacts`);
96+
return response;
97+
},
98+
};

components/lusha/actions/find-company/find-company.mjs

Lines changed: 0 additions & 29 deletions
This file was deleted.

components/lusha/actions/find-contact/find-contact.mjs

Lines changed: 0 additions & 41 deletions
This file was deleted.

components/lusha/common/utils.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

0 commit comments

Comments
 (0)