diff --git a/components/autodesk/autodesk.app.mjs b/components/autodesk/autodesk.app.mjs index dd899e5bb04ff..67dc994768ffb 100644 --- a/components/autodesk/autodesk.app.mjs +++ b/components/autodesk/autodesk.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/motive/motive.app.mjs b/components/motive/motive.app.mjs index 1a0959808ceca..185cde19a37f5 100644 --- a/components/motive/motive.app.mjs +++ b/components/motive/motive.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/traffit/traffit.app.mjs b/components/traffit/traffit.app.mjs index e803c934f2871..58ed416ccfc25 100644 --- a/components/traffit/traffit.app.mjs +++ b/components/traffit/traffit.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/what_are_those/actions/find-sneakers-by-sku/find-sneakers-by-sku.mjs b/components/what_are_those/actions/find-sneakers-by-sku/find-sneakers-by-sku.mjs new file mode 100644 index 0000000000000..61f1296aca567 --- /dev/null +++ b/components/what_are_those/actions/find-sneakers-by-sku/find-sneakers-by-sku.mjs @@ -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; + }, +}; diff --git a/components/what_are_those/actions/grade-sneakers-condition/grade-sneakers-condition.mjs b/components/what_are_those/actions/grade-sneakers-condition/grade-sneakers-condition.mjs new file mode 100644 index 0000000000000..2382e7e4e40dd --- /dev/null +++ b/components/what_are_those/actions/grade-sneakers-condition/grade-sneakers-condition.mjs @@ -0,0 +1,78 @@ +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: "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).", + }, + leftImage: { + type: "string", + label: "Left Image", + 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).", + }, + rightImage: { + type: "string", + label: "Right Image", + 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).", + }, + soleImage: { + type: "string", + label: "Sole Image", + 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).", + }, + insoleImage: { + type: "string", + label: "Insole Image", + 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).", + }, + sizeTagImage: { + type: "string", + label: "Size Tag Image", + 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).", + }, + type: { + type: "string", + label: "Use Type", + description: "the type parameter to see specific types of data.", + options: [ + "grading", + "authentication", + ], + optional: true, + }, + }, + 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, + }, + timeout: 120000, + }); + $.export("$summary", "Successfully graded and authenticated sneakers."); + return response; + }, +}; diff --git a/components/what_are_those/actions/identify-sneakers-from-photo/identify-sneakers-from-photo.mjs b/components/what_are_those/actions/identify-sneakers-from-photo/identify-sneakers-from-photo.mjs new file mode 100644 index 0000000000000..1ff6a6585f5c2 --- /dev/null +++ b/components/what_are_those/actions/identify-sneakers-from-photo/identify-sneakers-from-photo.mjs @@ -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, + }); + + $.export("$summary", `Identified ${response.names} sneakers successfully`); + return response; + }, +}; diff --git a/components/what_are_those/common/utils.mjs b/components/what_are_those/common/utils.mjs new file mode 100644 index 0000000000000..1a5e36f32a603 --- /dev/null +++ b/components/what_are_those/common/utils.mjs @@ -0,0 +1,6 @@ +export const checkTmp = (filename) => { + if (!filename.startsWith("/tmp")) { + return `/tmp/${filename}`; + } + return filename; +}; diff --git a/components/what_are_those/package.json b/components/what_are_those/package.json index 53583a683a064..16b409180cf3b 100644 --- a/components/what_are_those/package.json +++ b/components/what_are_those/package.json @@ -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 (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/what_are_those/what_are_those.app.mjs b/components/what_are_those/what_are_those.app.mjs index 2a92abacf67a2..b578d247d61eb 100644 --- a/components/what_are_those/what_are_those.app.mjs +++ b/components/what_are_those/what_are_those.app.mjs @@ -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, + }); + }, + 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, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c6798a293942..14eb5f2dfd221 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6641,8 +6641,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/motive: - specifiers: {} + components/motive: {} components/moxie: dependencies: @@ -10825,8 +10824,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/traffit: - specifiers: {} + components/traffit: {} components/trainual: {} @@ -11599,7 +11597,11 @@ importers: components/weworkbook: {} - components/what_are_those: {} + components/what_are_those: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/whatconverts: {} @@ -24714,22 +24716,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==}