Skip to content

Commit be6e7ea

Browse files
authored
Merging pull request #18453
* wip * updates * pnpm-lock.yaml
1 parent bbe6b5b commit be6e7ea

File tree

9 files changed

+416
-45
lines changed

9 files changed

+416
-45
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import lusha from "../../lusha.app.mjs";
33
export default {
44
key: "lusha-company-enrich",
55
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.2",
6+
description: "Enriches company information based on provided company IDs. [See the documentation](https://docs.lusha.com/apis/openapi/company-search-and-enrich/enrichprospectingcompanies)",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
lusha,
@@ -14,7 +14,7 @@ export default {
1414
"requestId",
1515
],
1616
label: "Company Request ID",
17-
description: "The request ID generated from the company search response.",
17+
description: "The request ID generated from the company search response",
1818
},
1919
companiesIds: {
2020
propDefinition: [

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import lusha from "../../lusha.app.mjs";
44
export default {
55
key: "lusha-company-search",
66
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",
7+
description: "Search for companies using various filters. [See the documentation](https://docs.lusha.com/apis/openapi/company-search-and-enrich/searchprospectingcompanies)",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
lusha,
@@ -14,54 +14,48 @@ export default {
1414
lusha,
1515
"companyNames",
1616
],
17-
optional: true,
1817
},
1918
domains: {
2019
propDefinition: [
2120
lusha,
2221
"domains",
2322
],
24-
optional: true,
2523
},
2624
locations: {
2725
propDefinition: [
2826
lusha,
2927
"locations",
3028
],
31-
optional: true,
3229
},
3330
sizes: {
3431
propDefinition: [
3532
lusha,
3633
"sizes",
3734
],
38-
optional: true,
3935
},
4036
revenues: {
4137
propDefinition: [
4238
lusha,
4339
"revenues",
4440
],
45-
optional: true,
4641
},
4742
sicCodes: {
4843
propDefinition: [
4944
lusha,
5045
"sicCodes",
5146
],
52-
optional: true,
5347
},
5448
naicsCodes: {
5549
propDefinition: [
5650
lusha,
5751
"naicsCodes",
5852
],
59-
optional: true,
6053
},
6154
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.**",
55+
propDefinition: [
56+
lusha,
57+
"limit",
58+
],
6559
},
6660
},
6761
async run({ $ }) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import lusha from "../../lusha.app.mjs";
33
export default {
44
key: "lusha-contact-enrich",
55
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",
6+
description: "Enriches contacts based on provided IDs. [See the documentation](https://docs.lusha.com/apis/openapi/contact-search-and-enrich/enrichprospectingcontacts)",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
lusha,
@@ -14,7 +14,7 @@ export default {
1414
"requestId",
1515
],
1616
label: "Contact Request ID",
17-
description: "The request ID generated from the contact search response.",
17+
description: "The request ID generated from the contact search response",
1818
},
1919
contactIds: {
2020
propDefinition: [

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import lusha from "../../lusha.app.mjs";
44
export default {
55
key: "lusha-contact-search",
66
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",
7+
description: "Search for contacts using various filters. [See the documentation](https://docs.lusha.com/apis/openapi/contact-search-and-enrich/searchprospectingcontacts)",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
lusha,
@@ -15,7 +15,7 @@ export default {
1515
"contactNames",
1616
],
1717
label: "Contact Names",
18-
description: "Names of contacts to search.",
18+
description: "Names of contacts to search",
1919
},
2020
jobTitles: {
2121
propDefinition: [
@@ -59,6 +59,12 @@ export default {
5959
"location",
6060
],
6161
},
62+
limit: {
63+
propDefinition: [
64+
lusha,
65+
"limit",
66+
],
67+
},
6268
},
6369
async run({ $ }) {
6470
const include = {};
@@ -93,6 +99,6 @@ export default {
9399
}
94100

95101
$.export("$summary", `Found ${responseArray.length} contacts`);
96-
return response;
102+
return responseArray;
97103
},
98104
};
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import lusha from "../../lusha.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "lusha-search-and-enrich-companies",
6+
name: "Search and Enrich Companies",
7+
description: "Search for companies and enrich them. [See the documentation](https://docs.lusha.com/apis/openapi/company-search-and-enrich)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
lusha,
12+
names: {
13+
propDefinition: [
14+
lusha,
15+
"companyNames",
16+
],
17+
},
18+
domains: {
19+
propDefinition: [
20+
lusha,
21+
"domains",
22+
],
23+
},
24+
locations: {
25+
propDefinition: [
26+
lusha,
27+
"locations",
28+
],
29+
},
30+
sizes: {
31+
propDefinition: [
32+
lusha,
33+
"sizes",
34+
],
35+
},
36+
revenues: {
37+
propDefinition: [
38+
lusha,
39+
"revenues",
40+
],
41+
},
42+
sicCodes: {
43+
propDefinition: [
44+
lusha,
45+
"sicCodes",
46+
],
47+
},
48+
naicsCodes: {
49+
propDefinition: [
50+
lusha,
51+
"naicsCodes",
52+
],
53+
},
54+
limit: {
55+
propDefinition: [
56+
lusha,
57+
"limit",
58+
],
59+
},
60+
},
61+
async run({ $ }) {
62+
const include = {};
63+
64+
if (this.names) include.names = parseObject(this.names);
65+
if (this.domains) include.domains = parseObject(this.domains);
66+
if (this.locations) include.locations = parseObject(this.locations);
67+
if (this.sizes) include.sizes = parseObject(this.sizes);
68+
if (this.revenues) include.revenues = parseObject(this.revenues);
69+
if (this.sicCodes) include.sicCodes = parseObject(this.sicCodes);
70+
if (this.naicsCodes) include.naicsCodes = parseObject(this.naicsCodes);
71+
72+
const companies = [];
73+
let hasMore, count = 0, page = 0;
74+
75+
do {
76+
const {
77+
requestId, data = [],
78+
} = await this.lusha.searchCompanies({
79+
$,
80+
params: {
81+
pages: {
82+
page,
83+
size: 50,
84+
},
85+
},
86+
data: {
87+
filters: {
88+
companies: {
89+
include,
90+
},
91+
},
92+
},
93+
});
94+
hasMore = data.length;
95+
const companyIds = [];
96+
97+
for (const d of data) {
98+
companyIds.push(d.id);
99+
if (++count >= this.limit) {
100+
hasMore = false;
101+
break;
102+
}
103+
}
104+
105+
const enrichedCompanies = await this.lusha.enrichCompanies({
106+
$,
107+
data: {
108+
requestId,
109+
companyIds,
110+
},
111+
});
112+
113+
companies.push(...enrichedCompanies.companies);
114+
page++;
115+
} while (hasMore);
116+
117+
$.export("$summary", `Found and enriched ${companies.length} companies`);
118+
return companies;
119+
},
120+
};

0 commit comments

Comments
 (0)