-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - jigsawstack #13929
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 - jigsawstack #13929
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
73 changes: 73 additions & 0 deletions
73
components/jigsawstack/actions/object-detection/object-detection.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,73 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import fs from "fs"; | ||
| import mime from "mime"; | ||
| import { | ||
| checkTmp, | ||
| throwError, | ||
| } from "../../common/utils.mjs"; | ||
| import jigsawstack from "../../jigsawstack.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "jigsawstack-object-detection", | ||
| name: "Object Detection", | ||
| description: "Recognize objects within a provided image and retrieve it with great accuracy. [See the documentation](https://docs.jigsawstack.com/api-reference/ai/object-detection)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| jigsawstack, | ||
| url: { | ||
| type: "string", | ||
| label: "Image URL", | ||
| description: "The URL of the image to process.", | ||
| optional: true, | ||
| }, | ||
| fileStoreKey: { | ||
| type: "string", | ||
| label: "File Store Key", | ||
| description: "The key used to store the image on Jigsawstack file [Storage](https://docs.jigsawstack.com/api-reference/store/file/add).", | ||
| optional: true, | ||
| }, | ||
| imageFile: { | ||
| type: "string", | ||
| label: "Image File", | ||
| description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| jigsawstack, | ||
| ...data | ||
| } = this; | ||
|
|
||
| if (Object.keys(data).length > 1) { | ||
| throw new ConfigurationError("You must provide only one option, either the **Image URL**, the **Image File**, or the **File Storage Key**."); | ||
| } | ||
|
|
||
| if (data.fileStoreKey) data.file_store_key = data.fileStoreKey; | ||
|
|
||
| if (data.imageFile) { | ||
| const filePath = checkTmp(data.imageFile); | ||
| const file = fs.readFileSync(filePath); | ||
| const { key } = await jigsawstack.uploadFile({ | ||
| headers: { | ||
| "Content-Type": mime.getType(filePath), | ||
| }, | ||
| data: file, | ||
| }); | ||
| data.file_store_key = key; | ||
| } | ||
|
|
||
| try { | ||
| const response = await jigsawstack.detectObjectsInImage({ | ||
| $, | ||
| data, | ||
| }); | ||
| $.export("$summary", "Successfully detected objects in the image"); | ||
| return response; | ||
|
|
||
| } catch (e) { | ||
| return throwError(e); | ||
| } | ||
| }, | ||
| }; |
33 changes: 33 additions & 0 deletions
33
components/jigsawstack/actions/sentiment-analysis/sentiment-analysis.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,33 @@ | ||
| import { throwError } from "../../common/utils.mjs"; | ||
| import jigsawstack from "../../jigsawstack.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "jigsawstack-sentiment-analysis", | ||
| name: "Sentiment Analysis", | ||
| description: "Assess sentiment of a provided text. Vibes can be positive, negative, or neutral. [See the documentation](https://docs.jigsawstack.com/api-reference/ai/sentiment)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| jigsawstack, | ||
| text: { | ||
| type: "string", | ||
| label: "Text", | ||
| description: "The text to analyze for sentiment.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| try { | ||
| const response = await this.jigsawstack.analyzeSentiment({ | ||
| $, | ||
| data: { | ||
| text: this.text, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully analyzed sentiment with emotion: ${response.sentiment.emotion} and sentiment: ${response.sentiment.sentiment}`); | ||
| return response; | ||
| } catch (e) { | ||
| return throwError(e); | ||
| } | ||
| }, | ||
| }; |
33 changes: 33 additions & 0 deletions
33
components/jigsawstack/actions/verify-email/verify-email.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,33 @@ | ||
| import { throwError } from "../../common/utils.mjs"; | ||
| import jigsawstack from "../../jigsawstack.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "jigsawstack-verify-email", | ||
| name: "Verify Email", | ||
| description: "Validate any email address and determine deliverability as well as disposable status. [See the documentation](https://docs.jigsawstack.com/api-reference/validate/email)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| jigsawstack, | ||
| email: { | ||
| type: "string", | ||
| label: "Email Address", | ||
| description: "The email address to validate.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| try { | ||
| const response = await this.jigsawstack.validateEmail({ | ||
| $, | ||
| params: { | ||
| email: this.email, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully validated email: ${this.email}`); | ||
| return response; | ||
| } catch (e) { | ||
| return throwError(e); | ||
| } | ||
| }, | ||
| }; |
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,13 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export const throwError = ({ message }) => { | ||
| const errorMessage = JSON.parse(message).message; | ||
| throw new ConfigurationError(errorMessage); | ||
| }; | ||
|
|
||
| export const checkTmp = (filename) => { | ||
| if (!filename.startsWith("/tmp")) { | ||
| return `/tmp/${filename}`; | ||
| } | ||
| return filename; | ||
| }; | ||
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 |
|---|---|---|
| @@ -1,11 +1,54 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "jigsawstack", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.jigsawstack.com/v1"; | ||
| }, | ||
| _headers(headers = {}) { | ||
| return { | ||
| "x-api-key": this.$auth.api_key, | ||
| ...headers, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, headers, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: this._baseUrl() + path, | ||
| headers: this._headers(headers), | ||
| ...opts, | ||
| }); | ||
| }, | ||
| validateEmail(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "GET", | ||
| path: "/validate/email", | ||
| ...opts, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| detectObjectsInImage(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/ai/object_detection", | ||
| ...opts, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| analyzeSentiment(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/ai/sentiment", | ||
| ...opts, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| uploadFile(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/store/file", | ||
| ...opts, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
| }; | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.