Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4626 from activepieces/feat/zerobounce
feat(zerobounce): validate email action
- Loading branch information
Showing
12 changed files
with
207 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "@activepieces/piece-apollo", | ||
"version": "0.0.2" | ||
"version": "0.0.3" | ||
} |
This file contains 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
This file contains 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
This file contains 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,33 @@ | ||
{ | ||
"extends": [ | ||
"../../../../.eslintrc.base.json" | ||
], | ||
"ignorePatterns": [ | ||
"!**/*" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx", | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains 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,7 @@ | ||
# pieces-zerobounce | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build pieces-zerobounce` to build the library. |
This file contains 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,4 @@ | ||
{ | ||
"name": "@activepieces/piece-zerobounce", | ||
"version": "0.0.1" | ||
} |
This file contains 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,38 @@ | ||
{ | ||
"name": "pieces-zerobounce", | ||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/pieces/community/zerobounce/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": [ | ||
"{options.outputPath}" | ||
], | ||
"options": { | ||
"outputPath": "dist/packages/pieces/community/zerobounce", | ||
"tsConfig": "packages/pieces/community/zerobounce/tsconfig.lib.json", | ||
"packageJson": "packages/pieces/community/zerobounce/package.json", | ||
"main": "packages/pieces/community/zerobounce/src/index.ts", | ||
"assets": [ | ||
"packages/pieces/community/zerobounce/*.md" | ||
], | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"updateBuildableProjectDepsInPackageJson": true | ||
} | ||
}, | ||
"publish": { | ||
"command": "node tools/scripts/publish.mjs pieces-zerobounce {args.ver} {args.tag}", | ||
"dependsOn": [ | ||
"build" | ||
] | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": [ | ||
"{options.outputFile}" | ||
] | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains 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,19 @@ | ||
|
||
import { createPiece, PieceAuth } from "@activepieces/pieces-framework"; | ||
import { validateEmail } from "./lib/actions/validate-email"; | ||
|
||
export const zerobounceAuth = PieceAuth.SecretText({ | ||
displayName: 'API Key', | ||
required: true, | ||
}); | ||
|
||
export const zerobounce = createPiece({ | ||
displayName: "ZeroBounce", | ||
auth: zerobounceAuth, | ||
description: "ZeroBounce is an email validation service that helps you reduce bounces, improve email deliverability and increase email marketing ROI.", | ||
minimumSupportedRelease: '0.20.0', | ||
logoUrl: "https://cdn.activepieces.com/pieces/zerobounce.png", | ||
authors: ["abuaboud"], | ||
actions: [validateEmail], | ||
triggers: [], | ||
}); |
40 changes: 40 additions & 0 deletions
40
packages/pieces/community/zerobounce/src/lib/actions/validate-email.ts
This file contains 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,40 @@ | ||
import { zerobounceAuth } from '../..'; | ||
import { createAction, Property, StoreScope } from '@activepieces/pieces-framework'; | ||
import { httpClient, HttpMethod } from '@activepieces/pieces-common'; | ||
import { isNil } from '@activepieces/shared'; | ||
|
||
export const validateEmail = createAction({ | ||
name: 'validateEmail', | ||
displayName: 'Validate Email', | ||
description: '', | ||
props: { | ||
email: Property.ShortText({ | ||
displayName: 'Email', | ||
required: true, | ||
}), | ||
cacheResponse: Property.Checkbox({ | ||
displayName: 'Cache Response', | ||
description: 'Store the response in the project store for future use.', | ||
required: false, | ||
defaultValue: true, | ||
}), | ||
}, | ||
auth: zerobounceAuth, | ||
async run({ store, propsValue, auth }) { | ||
const key = `_zerobounce_${propsValue.email}`; | ||
if (propsValue.cacheResponse) { | ||
const cachedResponse = await store.get(key, StoreScope.PROJECT); | ||
if (!isNil(cachedResponse)) { | ||
return cachedResponse | ||
} | ||
} | ||
const res = await httpClient.sendRequest<string[]>({ | ||
method: HttpMethod.GET, | ||
url: `https://api.zerobounce.net/v2/validate?email=${propsValue.email}&api_key=${auth}`, | ||
}); | ||
if (propsValue.cacheResponse) { | ||
await store.put(key, res.body, StoreScope.PROJECT); | ||
} | ||
return res.body; | ||
}, | ||
}); |
This file contains 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,19 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
} | ||
] | ||
} |
This file contains 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,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], | ||
"include": ["src/**/*.ts"] | ||
} |
This file contains 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