-
Couldn't load subscription status.
- Fork 5.5k
New Components - what_are_those #15207
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
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c9fdcc0
what_are_those init
luancazarine 33b1b2d
[Components] what_are_those #15195
luancazarine 2141862
pnpm update
luancazarine 8e5f010
some adjusts
luancazarine 0420e57
Update components/what_are_those/common/utils.mjs
luancazarine 330bac3
Merge branch 'master' into issue-15195
luancazarine 9819152
pnpm update
luancazarine 2f14587
add timeout config
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
31 changes: 31 additions & 0 deletions
31
components/what_are_those/actions/find-sneakers-by-sku/find-sneakers-by-sku.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,31 @@ | ||
| import fs from "fs"; | ||
| import { checkTmp } from "../../common/utils.mjs"; | ||
| import app from "../../what_are_those.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "what_are_those-find-sneakers-by-sku", | ||
| name: "Find Sneakers by SKU", | ||
| description: "Identifies sneakers from a size tag photo and returns sneaker name and details. [See the documentation](https://documenter.getpostman.com/view/3847098/2sAY4rDQDs#4f6a49f9-3393-42cd-8474-3856a79888af)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| sizeTagImage: { | ||
| type: "string", | ||
| label: "Size Tag Image", | ||
| description: "The path to the size tag image 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).", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const data = fs.readFileSync(checkTmp(this.sizeTagImage)); | ||
| const base64Image = Buffer.from(data, "binary").toString("base64"); | ||
|
|
||
| const response = await this.app.identifySneakersFromSizeTag({ | ||
| $, | ||
| data: base64Image, | ||
| }); | ||
|
|
||
| $.export("$summary", `Identified sneaker: ${response}`); | ||
| return response; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
77 changes: 77 additions & 0 deletions
77
components/what_are_those/actions/grade-sneakers-condition/grade-sneakers-condition.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,77 @@ | ||
| import FormData from "form-data"; | ||
| import fs from "fs"; | ||
| import { checkTmp } from "../../common/utils.mjs"; | ||
| import app from "../../what_are_those.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "what_are_those-grade-sneakers-condition", | ||
| name: "Grade and Authenticate Sneakers", | ||
| description: "Grades and authenticates sneakers using provided images. [See the documentation](https://documenter.getpostman.com/view/3847098/2sAY4rDQDs#13d527e8-5d8f-4511-857c-b40b8dd921b8)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| frontImage: { | ||
| type: "string", | ||
| label: "Front Image", | ||
| description: "Base64 encoded or multipart form data image of the front.", | ||
| }, | ||
| leftImage: { | ||
| type: "string", | ||
| label: "Left Image", | ||
| description: "Base64 encoded or multipart form data image of the left side.", | ||
| }, | ||
| rightImage: { | ||
| type: "string", | ||
| label: "Right Image", | ||
| description: "Base64 encoded or multipart form data image of the right side.", | ||
| }, | ||
| soleImage: { | ||
| type: "string", | ||
| label: "Sole Image", | ||
| description: "Base64 encoded or multipart form data image of the sole.", | ||
| }, | ||
| insoleImage: { | ||
| type: "string", | ||
| label: "Insole Image", | ||
| description: "Base64 encoded or multipart form data image of the insole.", | ||
| }, | ||
| sizeTagImage: { | ||
| type: "string", | ||
| label: "Size Tag Image", | ||
| description: "Base64 encoded or multipart form data image of the size tag.", | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Use Type", | ||
| description: "the type parameter to see specific types of data.", | ||
| options: [ | ||
| "grading", | ||
| "authentication", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async run({ $ }) { | ||
| const data = new FormData(); | ||
| data.append("image1", fs.createReadStream(checkTmp(this.frontImage))); | ||
| data.append("image2", fs.createReadStream(checkTmp(this.leftImage))); | ||
| data.append("image3", fs.createReadStream(checkTmp(this.rightImage))); | ||
| data.append("image4", fs.createReadStream(checkTmp(this.soleImage))); | ||
| data.append("image5", fs.createReadStream(checkTmp(this.insoleImage))); | ||
| data.append("image6", fs.createReadStream(checkTmp(this.sizeTagImage))); | ||
|
|
||
| const response = await this.app.gradeAuthenticateSneakers({ | ||
| headers: { | ||
| ...data.getHeaders(), | ||
| }, | ||
| data: data, | ||
| maxBodyLength: Infinity, | ||
| params: { | ||
| type: this.type, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully graded and authenticated sneakers."); | ||
| return response; | ||
| }, | ||
| }; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
34 changes: 34 additions & 0 deletions
34
...ents/what_are_those/actions/identify-sneakers-from-photo/identify-sneakers-from-photo.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,34 @@ | ||
| import FormData from "form-data"; | ||
| import fs from "fs"; | ||
| import { checkTmp } from "../../common/utils.mjs"; | ||
| import app from "../../what_are_those.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "what_are_those-identify-sneakers-from-photo", | ||
| name: "Identify Sneakers from Photo", | ||
| description: "Identifies sneakers from an uploaded image and returns details such as name, links, images, prices, and confidence scores. [See the documentation](https://documenter.getpostman.com/view/3847098/2sAY4rDQDs#957c900c-501f-4c8f-9b8b-71655a8cfb5d).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| image: { | ||
| type: "string", | ||
| label: "Image", | ||
| description: "The path to the size tag image 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).", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const data = new FormData(); | ||
| data.append("image1", fs.createReadStream(checkTmp(this.image))); | ||
|
|
||
| const response = await this.app.identifySneakers({ | ||
| headers: { | ||
| ...data.getHeaders(), | ||
| }, | ||
| data: data, | ||
| }); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| $.export("$summary", `Identified ${response.names} sneakers successfully`); | ||
| return response; | ||
| }, | ||
| }; | ||
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,6 @@ | ||
| export const checkTmp = (filename) => { | ||
| if (!filename.startsWith("/tmp")) { | ||
| return "/tmp/filename"; | ||
| } | ||
| return filename; | ||
| }; | ||
luancazarine 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/what_are_those", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream What Are Those Components", | ||
| "main": "what_are_those.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
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,43 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "what_are_those", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _headers(headers = {}) { | ||
| return { | ||
| "x-api-key": this.$auth.api_key, | ||
| ...headers, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, headers, ...opts | ||
| }) { | ||
| return axios($, { | ||
| headers: this._headers(headers), | ||
| ...opts, | ||
| }); | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| identifySneakers(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| url: "https://ayq6s37rv6.execute-api.us-east-1.amazonaws.com/Prod/rec?data_type=multi", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| gradeAuthenticateSneakers(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| url: "https://6mdt6kw7ig.execute-api.us-east-1.amazonaws.com/Prod/list?data_type=multi", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| identifySneakersFromSizeTag(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| url: "https://0blrzg7ahc.execute-api.us-east-1.amazonaws.com/Prod/sku", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.