Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/lusha/actions/company-enrich/company-enrich.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "lusha-company-enrich",
name: "Enrich Companies",
description: "Enriches company information based on provided company IDs. [See the documentation](https://docs.lusha.com/apis/openapi/company-search-and-enrich/enrichprospectingcompanies)",
version: "0.0.4",
version: "0.0.5",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
108 changes: 71 additions & 37 deletions components/lusha/actions/company-search/company-search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "lusha-company-search",
name: "Search Companies",
description: "Search for companies using various filters. [See the documentation](https://docs.lusha.com/apis/openapi/company-search-and-enrich/searchprospectingcompanies)",
version: "0.0.3",
version: "0.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -56,49 +56,83 @@ export default {
"naicsCodes",
],
},
limit: {
propDefinition: [
lusha,
"limit",
],
},
},
async run({ $ }) {
try {
const include = {};
const {
lusha,
names,
domains,
locations,
sizes,
revenues,
sicCodes,
naicsCodes,
} = this;

if (this.names) include.names = parseObject(this.names);
if (this.domains) include.domains = parseObject(this.domains);
if (this.locations) include.locations = parseObject(this.locations);
if (this.sizes) include.sizes = parseObject(this.sizes);
if (this.revenues) include.revenues = parseObject(this.revenues);
if (this.sicCodes) include.sicCodes = parseObject(this.sicCodes);
if (this.naicsCodes) include.naicsCodes = parseObject(this.naicsCodes);
const include = {
...(names
? {
names: parseObject(names),
}
: undefined
),
...(domains
? {
domains: parseObject(domains),
}
: undefined
),
...(locations
? {
locations: parseObject(locations).map((country) => ({
country,
})),
}
: undefined
),
...(sizes
? {
sizes: parseObject(sizes),
}
: undefined
),
...(revenues
? {
revenues: parseObject(revenues),
}
: undefined
),
...(sicCodes
? {
sicCodes: parseObject(sicCodes),
}
: undefined
),
...(naicsCodes
? {
naicsCodes: parseObject(naicsCodes),
}
: undefined
),
};

const response = this.lusha.paginate({
$,
maxResults: this.limit,
fn: this.lusha.searchCompanies,
data: {
filters: {
companies: {
include,
},
if (Object.keys(include).length === 0) {
throw new Error("At least one company filter must be provided");
}

const response = await lusha.searchCompanies({
$,
data: {
filters: {
companies: {
include,
},
},
});
},
});

const responseArray = [];
$.export("$summary", "Successfully searched for companies");

for await (const item of response) {
responseArray.push(item);
}

$.export("$summary", `Successfully retrieved ${responseArray.length} companies`);
return responseArray;
} catch (error) {
$.export("$summary", "Failed to search companies");
throw error;
}
return response;
},
};
2 changes: 1 addition & 1 deletion components/lusha/actions/contact-enrich/contact-enrich.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "lusha-contact-enrich",
name: "Enrich Contacts",
description: "Enriches contacts based on provided IDs. [See the documentation](https://docs.lusha.com/apis/openapi/contact-search-and-enrich/enrichprospectingcontacts)",
version: "0.0.3",
version: "0.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
4 changes: 2 additions & 2 deletions components/lusha/actions/contact-search/contact-search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "lusha-contact-search",
name: "Search Contacts",
description: "Search for contacts using various filters. [See the documentation](https://docs.lusha.com/apis/openapi/contact-search-and-enrich/searchprospectingcontacts)",
version: "0.0.3",
version: "0.0.4",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -82,7 +82,7 @@ export default {
if (this.seniority) include.seniority = parseObject(this.seniority);
if (this.departments) include.departments = parseObject(this.departments);
if (this.existingDataPoints) include.existingDataPoints = parseObject(this.existingDataPoints);
if (this.location) include.location = parseObject(this.location);
if (this.location) include.locations = parseObject(this.location);

const response = this.lusha.paginate({
$,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "lusha-search-and-enrich-companies",
name: "Search and Enrich Companies",
description: "Search for companies and enrich them. [See the documentation](https://docs.lusha.com/apis/openapi/company-search-and-enrich)",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -64,23 +64,75 @@ export default {
},
},
async run({ $ }) {
const include = {};
const {
lusha,
names,
domains,
locations,
sizes,
revenues,
sicCodes,
naicsCodes,
} = this;

if (this.names) include.names = parseObject(this.names);
if (this.domains) include.domains = parseObject(this.domains);
if (this.locations) include.locations = parseObject(this.locations);
if (this.sizes) include.sizes = parseObject(this.sizes);
if (this.revenues) include.revenues = parseObject(this.revenues);
if (this.sicCodes) include.sicCodes = parseObject(this.sicCodes);
if (this.naicsCodes) include.naicsCodes = parseObject(this.naicsCodes);
const include = {
...(names
? {
names: parseObject(names),
}
: undefined
),
...(domains
? {
domains: parseObject(domains),
}
: undefined
),
...(locations
? {
locations: parseObject(locations).map((country) => ({
country,
})),
}
: undefined
),
...(sizes
? {
sizes: parseObject(sizes),
}
: undefined
),
...(revenues
? {
revenues: parseObject(revenues),
}
: undefined
),
...(sicCodes
? {
sicCodes: parseObject(sicCodes),
}
: undefined
),
...(naicsCodes
? {
naicsCodes: parseObject(naicsCodes),
}
: undefined
),
};

if (Object.keys(include).length === 0) {
throw new Error("At least one company filter must be provided");
}

const companies = [];
let hasMore, count = 0, page = 0;

do {
const {
requestId, data = [],
} = await this.lusha.searchCompanies({
} = await lusha.searchCompanies({
$,
params: {
pages: {
Expand All @@ -97,10 +149,10 @@ export default {
},
});
hasMore = data.length;
const companyIds = [];
const companiesIds = [];

for (const d of data) {
companyIds.push(d.id);
companiesIds.push(d.id);
if (++count >= this.limit) {
hasMore = false;
break;
Expand All @@ -111,7 +163,7 @@ export default {
$,
data: {
requestId,
companyIds,
companiesIds,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "lusha-search-and-enrich-contacts",
name: "Search and Enrich Contacts",
description: "Search for contacts and enrich them. [See the documentation](https://docs.lusha.com/apis/openapi/contact-search-and-enrich)",
version: "0.0.2",
version: "0.0.3",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down Expand Up @@ -82,7 +82,7 @@ export default {
if (this.seniority) include.seniority = parseObject(this.seniority);
if (this.departments) include.departments = parseObject(this.departments);
if (this.existingDataPoints) include.existingDataPoints = parseObject(this.existingDataPoints);
if (this.location) include.location = parseObject(this.location);
if (this.location) include.locations = parseObject(this.location);

const contacts = [];
let hasMore, count = 0, page = 0;
Expand Down
36 changes: 28 additions & 8 deletions components/lusha/lusha.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
locations: {
type: "string[]",
label: "Company Locations",
description: "Location filters for companies to search",
description: "Location country filters for companies to search. Eg. `United States`, `Canada`, `United Kingdom`, etc.",
optional: true,
},
sizes: {
Expand Down Expand Up @@ -141,7 +141,26 @@ export default {
location: {
type: "string[]",
label: "Contact Locations",
description: "Location filters for contacts to search (JSON strings)",
description: `Location filters for contacts to search. Each entry should be a JSON object with the following optional fields:

**Available Fields:**
- \`continent\` - The continent name (e.g., "North America")
- \`country\` - The country name (e.g., "United States")
- \`country_grouping\` - Country grouping code (e.g., "na" for North America)
- \`state\` - The state or region name (e.g., "New York")
- \`city\` - The city name (e.g., "New York")

**Example JSON:**
\`\`\`json
[
{
"continent": "North America",
"country": "United States",
"state": "New York",
"city": "New York"
}
]
\`\`\``,
optional: true,
},
requestId: {
Expand Down Expand Up @@ -261,30 +280,31 @@ export default {
});
},
async *paginate({
fn, params = {}, maxResults = null, ...opts
fn, data = {}, maxResults = null, ...opts
}) {
let hasMore = false;
let count = 0;
let page = -1;

do {
params.pages = {
data.pages = {
page: ++page,
size: 50,
};
const { data } = await fn({
params,
const response = await fn({
data,
...opts,
});
for (const d of data) {
const results = response.data || [];
for (const d of results) {
yield d;

if (maxResults && ++count === maxResults) {
return count;
}
}

hasMore = data.length;
hasMore = results.length;

Comment on lines +290 to 308
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix paginator page size (Lusha rejects 50).

The helper now hardcodes pages.size = 50, but Lusha’s API only accepts 10–40. Any request through this paginator will 400, which regresses every action that relies on it. Please drop this to 40 (or enforce the documented bounds dynamically) before the release. (lusha.com)

🤖 Prompt for AI Agents
In components/lusha/lusha.app.mjs around lines 290 to 308, the paginator sets
pages.size = 50 which Lusha's API rejects (valid range 10–40); change the
hardcoded value to 40 or enforce bounds dynamically (e.g., clamp requested size
to between 10 and 40 before assigning pages.size) so requests use an accepted
page size and avoid 400 errors.

} while (hasMore);
},
Expand Down
2 changes: 1 addition & 1 deletion components/lusha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/lusha",
"version": "0.2.0",
"version": "0.2.1",
"description": "Pipedream Lusha Components",
"main": "lusha.app.mjs",
"keywords": [
Expand Down
Loading