Skip to content

Commit 8b4c746

Browse files
New Components - what_are_those (#15207)
* what_are_those init * [Components] what_are_those #15195 Actions - Identify Sneakers From Photo - Grade Sneakers Condition - Find Sneakers By SKU * pnpm update * some adjusts * Update components/what_are_those/common/utils.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * pnpm update * add timeout config --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent ef01229 commit 8b4c746

File tree

7 files changed

+195
-7
lines changed

7 files changed

+195
-7
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from "fs";
2+
import { checkTmp } from "../../common/utils.mjs";
3+
import app from "../../what_are_those.app.mjs";
4+
5+
export default {
6+
key: "what_are_those-find-sneakers-by-sku",
7+
name: "Find Sneakers by SKU",
8+
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)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
app,
13+
sizeTagImage: {
14+
type: "string",
15+
label: "Size Tag Image",
16+
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).",
17+
},
18+
},
19+
async run({ $ }) {
20+
const data = fs.readFileSync(checkTmp(this.sizeTagImage));
21+
const base64Image = Buffer.from(data, "binary").toString("base64");
22+
23+
const response = await this.app.identifySneakersFromSizeTag({
24+
$,
25+
data: base64Image,
26+
});
27+
28+
$.export("$summary", `Identified sneaker: ${response}`);
29+
return response;
30+
},
31+
};
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import FormData from "form-data";
2+
import fs from "fs";
3+
import { checkTmp } from "../../common/utils.mjs";
4+
import app from "../../what_are_those.app.mjs";
5+
6+
export default {
7+
key: "what_are_those-grade-sneakers-condition",
8+
name: "Grade and Authenticate Sneakers",
9+
description: "Grades and authenticates sneakers using provided images. [See the documentation](https://documenter.getpostman.com/view/3847098/2sAY4rDQDs#13d527e8-5d8f-4511-857c-b40b8dd921b8)",
10+
version: "0.0.1",
11+
type: "action",
12+
props: {
13+
app,
14+
frontImage: {
15+
type: "string",
16+
label: "Front Image",
17+
description: "The path to the front image 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).",
18+
},
19+
leftImage: {
20+
type: "string",
21+
label: "Left Image",
22+
description: "The path to the left image 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).",
23+
},
24+
rightImage: {
25+
type: "string",
26+
label: "Right Image",
27+
description: "The path to the right image 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).",
28+
},
29+
soleImage: {
30+
type: "string",
31+
label: "Sole Image",
32+
description: "The path to the sole image 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).",
33+
},
34+
insoleImage: {
35+
type: "string",
36+
label: "Insole Image",
37+
description: "The path to the insole image 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).",
38+
},
39+
sizeTagImage: {
40+
type: "string",
41+
label: "Size Tag Image",
42+
description: "The path to the sizeTag image 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).",
43+
},
44+
type: {
45+
type: "string",
46+
label: "Use Type",
47+
description: "the type parameter to see specific types of data.",
48+
options: [
49+
"grading",
50+
"authentication",
51+
],
52+
optional: true,
53+
},
54+
},
55+
async run({ $ }) {
56+
const data = new FormData();
57+
data.append("image1", fs.createReadStream(checkTmp(this.frontImage)));
58+
data.append("image2", fs.createReadStream(checkTmp(this.leftImage)));
59+
data.append("image3", fs.createReadStream(checkTmp(this.rightImage)));
60+
data.append("image4", fs.createReadStream(checkTmp(this.soleImage)));
61+
data.append("image5", fs.createReadStream(checkTmp(this.insoleImage)));
62+
data.append("image6", fs.createReadStream(checkTmp(this.sizeTagImage)));
63+
64+
const response = await this.app.gradeAuthenticateSneakers({
65+
headers: {
66+
...data.getHeaders(),
67+
},
68+
data: data,
69+
maxBodyLength: Infinity,
70+
params: {
71+
type: this.type,
72+
},
73+
timeout: 120000,
74+
});
75+
$.export("$summary", "Successfully graded and authenticated sneakers.");
76+
return response;
77+
},
78+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import FormData from "form-data";
2+
import fs from "fs";
3+
import { checkTmp } from "../../common/utils.mjs";
4+
import app from "../../what_are_those.app.mjs";
5+
6+
export default {
7+
key: "what_are_those-identify-sneakers-from-photo",
8+
name: "Identify Sneakers from Photo",
9+
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).",
10+
version: "0.0.1",
11+
type: "action",
12+
props: {
13+
app,
14+
image: {
15+
type: "string",
16+
label: "Image",
17+
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).",
18+
},
19+
},
20+
async run({ $ }) {
21+
const data = new FormData();
22+
data.append("image1", fs.createReadStream(checkTmp(this.image)));
23+
24+
const response = await this.app.identifySneakers({
25+
headers: {
26+
...data.getHeaders(),
27+
},
28+
data: data,
29+
});
30+
31+
$.export("$summary", `Identified ${response.names} sneakers successfully`);
32+
return response;
33+
},
34+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const checkTmp = (filename) => {
2+
if (!filename.startsWith("/tmp")) {
3+
return `/tmp/${filename}`;
4+
}
5+
return filename;
6+
};

components/what_are_those/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/what_are_those",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream What Are Those Components",
55
"main": "what_are_those.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}
Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "what_are_those",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
_headers(headers = {}) {
8+
return {
9+
"x-api-key": this.$auth.api_key,
10+
...headers,
11+
};
12+
},
13+
_makeRequest({
14+
$ = this, headers, ...opts
15+
}) {
16+
return axios($, {
17+
headers: this._headers(headers),
18+
...opts,
19+
});
20+
},
21+
identifySneakers(opts = {}) {
22+
return this._makeRequest({
23+
method: "POST",
24+
url: "https://ayq6s37rv6.execute-api.us-east-1.amazonaws.com/Prod/rec?data_type=multi",
25+
...opts,
26+
});
27+
},
28+
gradeAuthenticateSneakers(opts = {}) {
29+
return this._makeRequest({
30+
method: "POST",
31+
url: "https://6mdt6kw7ig.execute-api.us-east-1.amazonaws.com/Prod/list?data_type=multi",
32+
...opts,
33+
});
34+
},
35+
identifySneakersFromSizeTag(opts = {}) {
36+
return this._makeRequest({
37+
method: "POST",
38+
url: "https://0blrzg7ahc.execute-api.us-east-1.amazonaws.com/Prod/sku",
39+
...opts,
40+
});
941
},
1042
},
1143
};

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)