Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Components - lusha #14994

Merged
merged 7 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
37 changes: 37 additions & 0 deletions components/lusha/actions/company-enrich/company-enrich.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import lusha from "../../lusha.app.mjs";

export default {
key: "lusha-company-enrich",
name: "Enrich Companies",
description: "Enriches company information based on provided company IDs. [See the documentation](https://www.lusha.com/docs/#company-enrich)",
version: "0.0.1",
type: "action",
props: {
lusha,
requestId: {
propDefinition: [
lusha,
"requestId",
],
label: "Company Request ID",
description: "The request ID generated from the company search response.",
},
companiesIds: {
propDefinition: [
lusha,
"companiesIds",
],
},
},
async run({ $ }) {
const response = await this.lusha.enrichCompanies({
$,
params: {
requestId: this.requestId,
companiesIds: this.companiesIds,
},
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
});
$.export("$summary", `Successfully enriched ${this.companiesIds.length} companies`);
return response;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
};
105 changes: 105 additions & 0 deletions components/lusha/actions/company-search/company-search.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { parseObject } from "../../common/utils.mjs";
import lusha from "../../lusha.app.mjs";

export default {
key: "lusha-company-search",
name: "Search Companies",
description: "Search for companies using various filters. [See the documentation](https://www.lusha.com/docs/#contactcompany-search)",
version: "0.0.1",
type: "action",
props: {
lusha,
names: {
propDefinition: [
lusha,
"companyNames",
],
optional: true,
},
domains: {
propDefinition: [
lusha,
"domains",
],
optional: true,
},
locations: {
propDefinition: [
lusha,
"locations",
],
optional: true,
},
sizes: {
propDefinition: [
lusha,
"sizes",
],
optional: true,
},
revenues: {
propDefinition: [
lusha,
"revenues",
],
optional: true,
},
sicCodes: {
propDefinition: [
lusha,
"sicCodes",
],
optional: true,
},
naicsCodes: {
propDefinition: [
lusha,
"naicsCodes",
],
optional: true,
},
limit: {
type: "string",
label: "Limit",
description: "The maximum number of results to return. **This feature is used to avoid timeouts due to very long returns.**",
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
},
async run({ $ }) {
try {
const include = {};

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 response = this.lusha.paginate({
$,
maxResults: this.limit,
fn: this.lusha.searchCompanies,
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
data: {
filters: {
companies: {
include,
},
},
},
});

const responseArray = [];

for await (const item of response) {
responseArray.push(item);
}
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved

$.export("$summary", `Successfully retrieved ${responseArray.length} companies`);
return responseArray;
} catch (error) {
$.export("$summary", "Failed to search companies");
throw error;
}
},
};
37 changes: 37 additions & 0 deletions components/lusha/actions/contact-enrich/contact-enrich.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import lusha from "../../lusha.app.mjs";

export default {
key: "lusha-contact-enrich",
name: "Enrich Contacts",
description: "Enriches contacts based on provided IDs. [See the documentation](https://www.lusha.com/docs/#contact-enrich)",
version: "0.0.1",
type: "action",
props: {
lusha,
requestId: {
propDefinition: [
lusha,
"requestId",
],
label: "Company Request ID",
description: "The request ID generated from the company search response.",
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
},
contactIds: {
propDefinition: [
lusha,
"contactIds",
],
},
},
async run({ $ }) {
const response = await this.lusha.enrichContacts({
$,
params: {
requestId: this.requestId,
contactIds: this.contactIds,
},
luancazarine marked this conversation as resolved.
Show resolved Hide resolved
});
$.export("$summary", `Successfully enriched ${this.contactIds.length} contacts`);
return response;
},
};
98 changes: 98 additions & 0 deletions components/lusha/actions/contact-search/contact-search.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { parseObject } from "../../common/utils.mjs";
import lusha from "../../lusha.app.mjs";

export default {
key: "lusha-contact-search",
name: "Search Contacts",
description: "Search for contacts using various filters. [See the documentation](https://www.lusha.com/docs/#contactcompany-search)",
version: "0.0.1",
type: "action",
props: {
lusha,
names: {
propDefinition: [
lusha,
"contactNames",
],
label: "Contact Names",
description: "Names of contacts to search.",
},
jobTitles: {
propDefinition: [
lusha,
"jobTitles",
],
},
jobTitlesExactMatch: {
propDefinition: [
lusha,
"jobTitlesExactMatch",
],
},
countries: {
propDefinition: [
lusha,
"countries",
],
},
seniority: {
propDefinition: [
lusha,
"seniority",
],
},
departments: {
propDefinition: [
lusha,
"departments",
],
},
existingDataPoints: {
propDefinition: [
lusha,
"existingDataPoints",
],
},
location: {
propDefinition: [
lusha,
"location",
],
},
},
async run({ $ }) {
const include = {};

michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
if (this.names) include.names = parseObject(this.names);
if (this.jobTitles) include.jobTitles = parseObject(this.jobTitles);
if (this.jobTitlesExactMatch)
include.jobTitlesExactMatch = parseObject(this.jobTitlesExactMatch);
if (this.countries) include.countries = parseObject(this.countries);
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);

const response = this.lusha.paginate({
$,
maxResults: this.limit,
fn: this.lusha.searchContacts,
data: {
filters: {
contacts: {
include,
},
},
},
});

const responseArray = [];

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

$.export("$summary", `Found ${responseArray.length} contacts`);
return response;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
};
29 changes: 0 additions & 29 deletions components/lusha/actions/find-company/find-company.mjs

This file was deleted.

41 changes: 0 additions & 41 deletions components/lusha/actions/find-contact/find-contact.mjs

This file was deleted.

24 changes: 24 additions & 0 deletions components/lusha/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
Loading
Loading