-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] emaillistverify #12332 #14065
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import app from "../../emaillistverify.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "emaillistverify-find-email", | ||
| name: "Find Email", | ||
| description: "Generate a series of potential email addresses by synthesizing first names, last names, and company domains. [See the documentation](https://emaillistverify.com/docs/#tag/Email-Validation-API/operation/find-contact)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| firstName: { | ||
| propDefinition: [ | ||
| app, | ||
| "firstName", | ||
| ], | ||
| }, | ||
| lastName: { | ||
| propDefinition: [ | ||
| app, | ||
| "lastName", | ||
| ], | ||
| }, | ||
| domain: { | ||
| propDefinition: [ | ||
| app, | ||
| "domain", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.app.findEmail({ | ||
| $, | ||
| data: { | ||
| first_name: this.firstName, | ||
| last_name: this.lastName, | ||
| domain: this.domain, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully generated ${response.length} email addresses`); | ||
|
|
||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import app from "../../emaillistverify.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "emaillistverify-verify-email", | ||
| name: "Verify Email", | ||
| description: "Verify an email. [See the documentation](https://emaillistverify.com/docs/#tag/Email-Validation-API/operation/verifyEmail)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| email: { | ||
| propDefinition: [ | ||
| app, | ||
| "email", | ||
| ], | ||
| }, | ||
| }, | ||
|
Comment on lines
+9
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Props look good. Consider adding email validation. The props are correctly defined, and using Consider adding some basic validation for the email prop to ensure it's in a valid format before sending it to the API. You could use a regular expression or a built-in email validation function if available in your framework. For example: email: {
propDefinition: [
app,
"email",
],
description: "The email address to verify",
validate: (value) => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(value)) {
throw new Error("Invalid email format");
}
},
}, |
||
| async run({ $ }) { | ||
| const response = await this.app.verifyEmail({ | ||
| params: { | ||
| email: this.email, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully verified the email. Result: '${response}'`); | ||
|
|
||
| return response; | ||
| }, | ||
|
Comment on lines
+18
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run method looks good. Consider adding error handling. The run method correctly uses the app's verifyEmail method and provides a useful summary export. Consider adding error handling to gracefully manage potential API failures or network issues. Here's an example of how you could improve the run method: async run({ $ }) {
try {
const response = await this.app.verifyEmail({
params: {
email: this.email,
},
});
$.export("$summary", `Successfully verified the email. Result: '${response}'`);
return response;
} catch (error) {
$.export("$summary", `Failed to verify email: ${error.message}`);
throw error;
}
},This change will provide more informative error messages and ensure that the action fails properly when an error occurs. |
||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,62 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { axios } from "@pipedream/platform"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "app", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app: "emaillistverify", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinitions: {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinitions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| email: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Email", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Email to be verified", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| firstName: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "First Name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The first name of the contact", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lastName: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Last Name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The last name of the contact", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| domain: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Email domain", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The domain to use for generating email addresses, i.e.: `gmail.com`", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| methods: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // this.$auth contains connected account data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| authKeys() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(Object.keys(this.$auth)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _baseUrl() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "https://apps.emaillistverify.com/api"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async _makeRequest(opts = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $ = this, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...otherOpts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return axios($, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...otherOpts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: this._baseUrl() + path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| secret: `${this.$auth.api_key}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+32
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure API key is not logged The The API key is included in the request parameters, which might be logged by default in some environments. To enhance security, consider:
- params: {
- ...params,
- secret: `${this.$auth.api_key}`,
- },
+ headers: {
+ ...otherOpts.headers,
+ "Authorization": `Bearer ${this.$auth.api_key}`,
+ },
+ params,
These changes will help prevent accidental exposure of the API key in logs or error messages. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async verifyEmail(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/verifyEmail", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add input validation and error handling to verifyEmail method The Consider adding input validation and error handling: async verifyEmail(args = {}) {
const { email } = args.params || {};
if (!email) {
throw new Error("Email is required for verification");
}
try {
return await this._makeRequest({
path: "/verifyEmail",
...args,
});
} catch (error) {
console.error("Error verifying email:", error);
throw error;
}
}This change ensures that an email is provided and handles potential errors, improving the robustness of the method. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async findEmail(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "post", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/find-contact", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add input validation and error handling to findEmail method The Consider enhancing the method as follows: async findEmail(args = {}) {
const { firstName, lastName, domain } = args.data || {};
if (!firstName || !lastName || !domain) {
throw new Error("First name, last name, and domain are required for finding an email");
}
try {
return await this._makeRequest({
method: "post",
path: "/find-contact",
...args,
});
} catch (error) {
console.error("Error finding email:", error);
throw error;
}
}This change ensures that all required fields are provided and handles potential errors, improving the method's reliability. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/emaillistverify", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream EmailListVerify Components", | ||
| "main": "emaillistverify.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Consider adding error handling.
The run method is well-structured and follows best practices for async operations. The use of destructuring for $ and the summary export are good for clarity and user feedback.
Consider adding error handling to improve robustness:
async run({ $ }) { - const response = await this.app.findEmail({ - $, - data: { - first_name: this.firstName, - last_name: this.lastName, - domain: this.domain, - }, - }); + try { + const response = await this.app.findEmail({ + $, + data: { + first_name: this.firstName, + last_name: this.lastName, + domain: this.domain, + }, + }); - $.export("$summary", `Successfully generated ${response.length} email addresses`); + $.export("$summary", `Successfully generated ${response.length} email addresses`); - return response; + return response; + } catch (error) { + $.export("$summary", "Failed to generate email addresses"); + throw error; + } },This change will provide better error reporting and ensure that the action fails properly if an error occurs.
Committable suggestion