From eb9b3508ec38982025c33901e70587359d356cf6 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 8 Oct 2025 12:11:22 -0300 Subject: [PATCH 1/3] Added actions --- .../batch-barcode-lookup.mjs | 2 +- .../get-product-by-barcode.mjs | 2 +- .../actions/get-products/get-products.mjs | 82 ++++++++++++++ .../get-rate-limits/get-rate-limits.mjs | 24 ++++ .../search-products-by-parameters.mjs | 2 +- .../barcode_lookup/barcode_lookup.app.mjs | 107 +++++++++++------- components/barcode_lookup/package.json | 2 +- 7 files changed, 179 insertions(+), 42 deletions(-) create mode 100644 components/barcode_lookup/actions/get-products/get-products.mjs create mode 100644 components/barcode_lookup/actions/get-rate-limits/get-rate-limits.mjs diff --git a/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs b/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs index 805b67cced699..719da5846ab9a 100644 --- a/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs +++ b/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs @@ -5,7 +5,7 @@ export default { key: "barcode_lookup-batch-barcode-lookup", name: "Batch Barcode Lookup", description: "Get multiple products by barcode. [See the documentation](https://www.barcodelookup.com/api-documentation)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs b/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs index 111c87875faae..8f7d213f9eae7 100644 --- a/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs +++ b/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs @@ -4,7 +4,7 @@ export default { key: "barcode_lookup-get-product-by-barcode", name: "Get Product by Barcode", description: "Get a product by barcode. [See the documentation](https://www.barcodelookup.com/api-documentation)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/barcode_lookup/actions/get-products/get-products.mjs b/components/barcode_lookup/actions/get-products/get-products.mjs new file mode 100644 index 0000000000000..9d33dbf0860cf --- /dev/null +++ b/components/barcode_lookup/actions/get-products/get-products.mjs @@ -0,0 +1,82 @@ +import app from "../../barcode_lookup.app.mjs"; + +export default { + key: "barcode_lookup-get-products", + name: "Get Products", + description: "Retrieve products details by barcode, MPN, ASIN, or search terms. [See the documentation](https://www.barcodelookup.com/api-documentation#endpoints)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + barcode: { + propDefinition: [ + app, + "barcode", + ], + }, + mpn: { + propDefinition: [ + app, + "mpn", + ], + }, + asin: { + propDefinition: [ + app, + "asin", + ], + }, + title: { + propDefinition: [ + app, + "title", + ], + }, + category: { + propDefinition: [ + app, + "category", + ], + }, + manufacturer: { + propDefinition: [ + app, + "manufacturer", + ], + }, + brand: { + propDefinition: [ + app, + "brand", + ], + }, + search: { + propDefinition: [ + app, + "search", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getProducts({ + $, + params: { + barcode: this.barcode, + mpn: this.mpn, + asin: this.asin, + title: this.title, + category: this.category, + manufacturer: this.manufacturer, + brand: this.brand, + search: this.search, + }, + }); + $.export("$summary", "Successfully retrieved " + response.products.length + " products"); + return response; + }, +}; diff --git a/components/barcode_lookup/actions/get-rate-limits/get-rate-limits.mjs b/components/barcode_lookup/actions/get-rate-limits/get-rate-limits.mjs new file mode 100644 index 0000000000000..f27ead99c23e4 --- /dev/null +++ b/components/barcode_lookup/actions/get-rate-limits/get-rate-limits.mjs @@ -0,0 +1,24 @@ +import app from "../../barcode_lookup.app.mjs"; + +export default { + key: "barcode_lookup-get-rate-limits", + name: "Get Rate Limits", + description: "Retrieve the current API rate limits for your account. [See the documentation](https://www.barcodelookup.com/api-documentation#endpoints)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.getRateLimits({ + $, + }); + $.export("$summary", "Successfully retrieved the account rate limits"); + return response; + }, +}; diff --git a/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs b/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs index 3f44af0dca496..87884ff308d0a 100644 --- a/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs +++ b/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs @@ -4,7 +4,7 @@ export default { key: "barcode_lookup-search-products-by-parameters", name: "Search Products by Parameters", description: "Search for products by parameters. [See the documentation](https://www.barcodelookup.com/api-documentation)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/barcode_lookup/barcode_lookup.app.mjs b/components/barcode_lookup/barcode_lookup.app.mjs index 24d686ad8386e..23f86e49bada9 100644 --- a/components/barcode_lookup/barcode_lookup.app.mjs +++ b/components/barcode_lookup/barcode_lookup.app.mjs @@ -3,56 +3,87 @@ import { axios } from "@pipedream/platform"; export default { type: "app", app: "barcode_lookup", - propDefinitions: {}, + propDefinitions: { + barcode: { + type: "string", + label: "Barcode", + description: "Barcode to search, must be 7, 8, 10, 11, 12, 13 or 14 digits long, i.e.: `865694301167`", + optional: true, + }, + mpn: { + type: "string", + label: "MPN", + description: "Manufacturer Part Number of the product, i.e: `LXCF9407`", + optional: true, + }, + asin: { + type: "string", + label: "ASIN", + description: "Amazon Standard Identification Number of the product, i.e.: `B079L4WR4T`", + optional: true, + }, + title: { + type: "string", + label: "Title", + description: "Product title or name, i.e.: `Red Running Shoes`", + optional: true, + }, + category: { + type: "string", + label: "Category", + description: "Category or type of the product, i.e.: `Home & Garden > Decor`", + optional: true, + }, + manufacturer: { + type: "string", + label: "Manufacturer", + description: "Name of the product manufacturer, i.e.: `Samsung`", + optional: true, + }, + brand: { + type: "string", + label: "Brand", + description: "Brand associated with the product, i.e.: `Calvin Klein`", + optional: true, + }, + search: { + type: "string", + label: "Search", + description: "General search term for products, i.e.: `Air Jordan Red Shoes Size 40`", + optional: true, + }, + }, methods: { _baseUrl() { return "https://api.barcodelookup.com/v3"; }, - _params(params = {}) { - return { - ...params, - key: `${this.$auth.api_key}`, - }; - }, - _makeRequest({ - $ = this, params, path, ...opts - }) { + async _makeRequest(opts = {}) { + const { + $ = this, + path, + params, + ...otherOpts + } = opts; return axios($, { + ...otherOpts, url: this._baseUrl() + path, - params: this._params(params), - ...opts, + params: { + key: `${this.$auth.api_key}`, + ...params, + }, }); }, - searchProducts(opts = {}) { + async getProducts(args = {}) { return this._makeRequest({ path: "/products", - ...opts, + ...args, }); }, - async *paginate({ - fn, params = {}, maxResults = null, ...opts - }) { - let hasMore = false; - let count = 0; - let page = 0; - - do { - params.page = ++page; - const { products: data } = await fn({ - params, - ...opts, - }); - for (const d of data) { - yield d; - - if (maxResults && ++count === maxResults) { - return count; - } - } - - hasMore = data?.length; - - } while (hasMore); + async getRateLimits(args = {}) { + return this._makeRequest({ + path: "/rate-limits", + ...args, + }); }, }, }; diff --git a/components/barcode_lookup/package.json b/components/barcode_lookup/package.json index 7679b14de04b4..f6cd910ff7ef3 100644 --- a/components/barcode_lookup/package.json +++ b/components/barcode_lookup/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/barcode_lookup", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Barcode Lookup Components", "main": "barcode_lookup.app.mjs", "keywords": [ From d36ab54c4ff2c8ac9115631c785dd917f75189df Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 15 Oct 2025 11:23:43 -0300 Subject: [PATCH 2/3] Added actions --- components/barcode_lookup/barcode_lookup.app.mjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/barcode_lookup/barcode_lookup.app.mjs b/components/barcode_lookup/barcode_lookup.app.mjs index 23f86e49bada9..9083c248aae3c 100644 --- a/components/barcode_lookup/barcode_lookup.app.mjs +++ b/components/barcode_lookup/barcode_lookup.app.mjs @@ -7,7 +7,7 @@ export default { barcode: { type: "string", label: "Barcode", - description: "Barcode to search, must be 7, 8, 10, 11, 12, 13 or 14 digits long, i.e.: `865694301167`", + description: "Barcode to search, must be 7, 8, 10, 11, 12, 13 or 14 digits long, e.g. `865694301167`", optional: true, }, mpn: { @@ -19,37 +19,37 @@ export default { asin: { type: "string", label: "ASIN", - description: "Amazon Standard Identification Number of the product, i.e.: `B079L4WR4T`", + description: "Amazon Standard Identification Number of the product, e.g. `B079L4WR4T`", optional: true, }, title: { type: "string", label: "Title", - description: "Product title or name, i.e.: `Red Running Shoes`", + description: "Product title or name, e.g. `Red Running Shoes`", optional: true, }, category: { type: "string", label: "Category", - description: "Category or type of the product, i.e.: `Home & Garden > Decor`", + description: "Category or type of the product, e.g. `Home & Garden > Decor`", optional: true, }, manufacturer: { type: "string", label: "Manufacturer", - description: "Name of the product manufacturer, i.e.: `Samsung`", + description: "Name of the product manufacturer, e.g. `Samsung`", optional: true, }, brand: { type: "string", label: "Brand", - description: "Brand associated with the product, i.e.: `Calvin Klein`", + description: "Brand associated with the product, e.g. `Calvin Klein`", optional: true, }, search: { type: "string", label: "Search", - description: "General search term for products, i.e.: `Air Jordan Red Shoes Size 40`", + description: "General search term for products, e.g. `Air Jordan Red Shoes Size 40`", optional: true, }, }, From 533f39c05fccc9528e805264787f3eceda6396c9 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Wed, 15 Oct 2025 11:26:27 -0300 Subject: [PATCH 3/3] Added actions --- .../actions/batch-barcode-lookup/batch-barcode-lookup.mjs | 2 +- .../actions/get-product-by-barcode/get-product-by-barcode.mjs | 2 +- .../search-products-by-parameters.mjs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs b/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs index 719da5846ab9a..169c98ad60192 100644 --- a/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs +++ b/components/barcode_lookup/actions/batch-barcode-lookup/batch-barcode-lookup.mjs @@ -21,7 +21,7 @@ export default { }, }, async run({ $ }) { - const response = await this.app.searchProducts({ + const response = await this.app.getProducts({ $, params: { barcode: parseObject(this.barcodes)?.join(","), diff --git a/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs b/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs index 8f7d213f9eae7..7e577562a565f 100644 --- a/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs +++ b/components/barcode_lookup/actions/get-product-by-barcode/get-product-by-barcode.mjs @@ -20,7 +20,7 @@ export default { }, }, async run({ $ }) { - const response = await this.app.searchProducts({ + const response = await this.app.getProducts({ $, params: { barcode: this.barcode, diff --git a/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs b/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs index 87884ff308d0a..a0a47cc37138b 100644 --- a/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs +++ b/components/barcode_lookup/actions/search-products-by-parameters/search-products-by-parameters.mjs @@ -78,7 +78,7 @@ export default { try { const response = await this.app.paginate({ $, - fn: this.app.searchProducts, + fn: this.app.getProducts, maxResults: this.maxResults, params: { mpn: this.mpn,