-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - lusha #14994
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
Merged
Merged
New Components - lusha #14994
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5ac9a44
lusha init
luancazarine a4d7535
[ACTION] Lusha: Prospecting APIs #14992
luancazarine 0a2c2ee
pnpm update
luancazarine 9f2cfe7
Merge branch 'master' into issue-14992
luancazarine 204d8af
new release
luancazarine d84ba76
remove node modules
luancazarine 2933934
some adjusts
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
components/lusha/actions/company-enrich/company-enrich.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ | ||
$, | ||
data: { | ||
requestId: this.requestId, | ||
companiesIds: this.companiesIds, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully enriched ${this.companiesIds.length} companies`); | ||
return response; | ||
}, | ||
}; |
105 changes: 105 additions & 0 deletions
105
components/lusha/actions/company-search/company-search.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.**", | ||
}, | ||
}, | ||
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
37
components/lusha/actions/contact-enrich/contact-enrich.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "Contact Request ID", | ||
description: "The request ID generated from the contact search response.", | ||
}, | ||
contactIds: { | ||
propDefinition: [ | ||
lusha, | ||
"contactIds", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.lusha.enrichContacts({ | ||
$, | ||
data: { | ||
requestId: this.requestId, | ||
contactIds: this.contactIds, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully enriched ${this.contactIds.length} contacts`); | ||
return response; | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
98 changes: 98 additions & 0 deletions
98
components/lusha/actions/contact-search/contact-search.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.