Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import app from "../../bluecart_api.app.mjs";

export default {
key: "bluecart_api-get-autocomplete",
name: "Get Autocomplete",
description: "Get autocomplete suggestions for the specified search term. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/autocomplete)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
type: "action",
props: {
app,
walmartDomain: {
propDefinition: [
app,
"walmartDomain",
],
},
searchTerm: {
propDefinition: [
app,
"searchTerm",
],
description: "The search term to get autocomplete suggestions for",
},
},
Comment on lines +14 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Unused prop: walmartDomain is defined but never passed to the API.

The walmartDomain prop is defined (lines 16-21) but is not included in the API call parameters (lines 33-36). This suggests either:

  1. The prop should be removed if not needed for autocomplete
  2. The prop should be passed as walmart_domain in params (similar to get-product action)

Compare with get-product action which correctly passes walmart_domain: this.walmartDomain.

Please verify the BlueCart API autocomplete endpoint requirements and either:

  • Remove the unused walmartDomain prop if not needed
  • Add walmart_domain: this.walmartDomain to the params object

🌐 Web query:

Does the BlueCart API autocomplete endpoint require a walmart_domain parameter?

💡 Result:

I can't find BlueCart's autocomplete endpoint documentation online. Could you paste the exact endpoint URL or the docs page you’re using (or a sample request/response)? I’ll check and confirm whether walmart_domain is required.


I'll investigate the codebase to verify this concern.


---

🏁 Script executed:

```shell
#!/bin/bash
# Examine the get-autocomplete.mjs file to see full implementation
cat components/bluecart_api/actions/get-autocomplete/get-autocomplete.mjs

Length of output: 1074


🏁 Script executed:

#!/bin/bash
# Find and examine the get-product.mjs for comparison
find . -name "get-product.mjs" -type f | head -5

Length of output: 309


🏁 Script executed:

#!/bin/bash
# Search for BlueCart API documentation or config
find . -path ./node_modules -prune -o -type f \( -name "*bluecart*" -o -name "*api*" \) -print | grep -i bluecart | head -20

Length of output: 46


🏁 Script executed:

#!/bin/bash
# Look for API endpoint definitions or documentation
find . -path ./node_modules -prune -o -type f -name "*.md" -print | xargs grep -l "autocomplete\|walmart_domain" 2>/dev/null | head -10

Length of output: 158



---

🏁 Script executed:

```shell
#!/bin/bash
# Examine the BlueCart get-product action
cat components/bluecart_api/actions/get-product/get-product.mjs

Length of output: 1080


🏁 Script executed:

#!/bin/bash
# Examine the BlueCart app configuration and API methods
cat components/bluecart_api/bluecart_api.app.mjs

Length of output: 1647


Add walmart_domain parameter to the autocomplete API call or remove the unused prop.

The walmartDomain prop is defined (lines 16-21) but not passed to the API call (lines 33-36). The get-product action uses the same endpoint (/request) and correctly passes walmart_domain: this.walmartDomain. For consistency and to match the API pattern, either add the parameter to the params object in get-autocomplete, or remove the unused prop definition.

params: {
  searchTerm: this.searchTerm,
  walmart_domain: this.walmartDomain,
  type: "autocomplete",
},
🤖 Prompt for AI Agents
In components/bluecart_api/actions/get-autocomplete/get-autocomplete.mjs around
lines 14-29 (prop definition) and the API call around lines 33-36, the
walmartDomain prop is defined but not used; update the params passed to the
/request endpoint to include walmart_domain: this.walmartDomain so the
autocomplete call matches the get-product pattern (params should contain
searchTerm, walmart_domain, and type: "autocomplete"), or alternatively remove
the unused walmartDomain prop definition if the domain is intentionally not
needed.

async run({ $ }) {
const response = await this.app.getAutocomplete({
$,
params: {
searchTerm: this.searchTerm,
type: "autocomplete",
},
});
$.export("$summary", "Successfully retrieved " + response.autocomplete_results.length + " suggestions");
return response;
},
Comment on lines +30 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix parameter naming inconsistency and add null check.

Two issues:

  1. Parameter naming inconsistency: This action uses searchTerm (camelCase) while get-categories uses search_term (snake_case). APIs typically expect consistent parameter naming. Verify which format the BlueCart API expects.

  2. Missing null check: Line 38 directly accesses response.autocomplete_results.length without verifying the property exists, risking a runtime exception if the API returns an unexpected response.

Apply this diff:

   async run({ $ }) {
     const response = await this.app.getAutocomplete({
       $,
       params: {
-        searchTerm: this.searchTerm,
+        search_term: this.searchTerm,
         type: "autocomplete",
       },
     });
-    $.export("$summary", "Successfully retrieved " + response.autocomplete_results.length + " suggestions");
+    if (!response?.autocomplete_results) {
+      throw new Error("Invalid API response: autocomplete_results not found");
+    }
+    $.export("$summary", `Successfully retrieved ${response.autocomplete_results.length} suggestions`);
     return response;
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async run({ $ }) {
const response = await this.app.getAutocomplete({
$,
params: {
searchTerm: this.searchTerm,
type: "autocomplete",
},
});
$.export("$summary", "Successfully retrieved " + response.autocomplete_results.length + " suggestions");
return response;
},
async run({ $ }) {
const response = await this.app.getAutocomplete({
$,
params: {
search_term: this.searchTerm,
type: "autocomplete",
},
});
if (!response?.autocomplete_results) {
throw new Error("Invalid API response: autocomplete_results not found");
}
$.export("$summary", `Successfully retrieved ${response.autocomplete_results.length} suggestions`);
return response;
},
🤖 Prompt for AI Agents
In components/bluecart_api/actions/get-autocomplete/get-autocomplete.mjs around
lines 30 to 40, fix the parameter naming inconsistency and add a null-safe
check: confirm the BlueCart API expects snake_case (search_term) and change the
sent params key from searchTerm to search_term (or keep camelCase only if API
docs require it), and before using response.autocomplete_results.length ensure
autocomplete_results exists (use an explicit null/undefined check or optional
chaining with a default of 0) so the exported summary never throws when the API
returns an unexpected shape.

};
34 changes: 34 additions & 0 deletions components/bluecart_api/actions/get-categories/get-categories.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import app from "../../bluecart_api.app.mjs";

export default {
key: "bluecart_api-get-categories",
name: "Get Categories",
description: "Get a list of categories related to the provided search term. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/category)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
type: "action",
props: {
app,
searchTerm: {
propDefinition: [
app,
"searchTerm",
],
description: "The term used to search for categories",
},
},
async run({ $ }) {
const response = await this.app.getCategories({
$,
params: {
search_term: this.searchTerm,
},
});
$.export("$summary", "Successfully retrieved " + response.categories.length + " categories");
return response;
},
Comment on lines +24 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add defensive null check for the API response.

Line 31 directly accesses response.categories.length without verifying that response.categories exists. If the API returns an unexpected structure or error response, this will cause a runtime exception.

Apply this diff:

   async run({ $ }) {
     const response = await this.app.getCategories({
       $,
       params: {
         search_term: this.searchTerm,
       },
     });
-    $.export("$summary", "Successfully retrieved " + response.categories.length + " categories");
+    if (!response?.categories) {
+      throw new Error("Invalid API response: categories not found");
+    }
+    $.export("$summary", `Successfully retrieved ${response.categories.length} categories`);
     return response;
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async run({ $ }) {
const response = await this.app.getCategories({
$,
params: {
search_term: this.searchTerm,
},
});
$.export("$summary", "Successfully retrieved " + response.categories.length + " categories");
return response;
},
async run({ $ }) {
const response = await this.app.getCategories({
$,
params: {
search_term: this.searchTerm,
},
});
if (!response?.categories) {
throw new Error("Invalid API response: categories not found");
}
$.export("$summary", `Successfully retrieved ${response.categories.length} categories`);
return response;
},
🤖 Prompt for AI Agents
In components/bluecart_api/actions/get-categories/get-categories.mjs around
lines 24-33, the code accesses response.categories.length without null checks;
update the run method to defensively handle missing or malformed responses by
first verifying response and Array.isArray(response.categories) (or at least
response.categories) before reading .length, compute a safe count (e.g., 0 if
absent), and use that value in the $.export("$summary", ...) call; if response
is null/undefined, consider returning a sensible error object or the original
response after exporting the safe summary.

};
50 changes: 50 additions & 0 deletions components/bluecart_api/actions/get-product/get-product.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../bluecart_api.app.mjs";

export default {
key: "bluecart_api-get-product",
name: "Get product",
description: "Get product data from Walmart. [See the documentation](https://docs.trajectdata.com/bluecartapi/walmart-product-data-api/parameters/product)",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
type: "action",
props: {
app,
walmartDomain: {
propDefinition: [
app,
"walmartDomain",
],
},
url: {
propDefinition: [
app,
"url",
],
},
itemId: {
propDefinition: [
app,
"itemId",
],
},
},

async run({ $ }) {
const response = await this.app.searchItem({
$,
params: {
walmart_domain: this.walmartDomain,
type: "product",
item_id: this.itemId,
url: this.url,
},
});

$.export("$summary", "Successfully retrieved data for the product with id: " + response.product.item_id);
return response;
},
Comment on lines +36 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add defensive null checks for the API response.

The code directly accesses response.product.item_id without verifying that response.product exists. If the API returns an unexpected structure or an error response, this will cause a runtime exception.

Apply this diff to add error handling:

   async run({ $ }) {
     const response = await this.app.searchItem({
       $,
       params: {
         walmart_domain: this.walmartDomain,
         type: "product",
         item_id: this.itemId,
         url: this.url,
       },
     });
 
-    $.export("$summary", "Successfully retrieved data for the product with id: " + response.product.item_id);
+    if (!response?.product?.item_id) {
+      throw new Error("Invalid API response: product data not found");
+    }
+    $.export("$summary", `Successfully retrieved data for the product with id: ${response.product.item_id}`);
     return response;
   },
🤖 Prompt for AI Agents
In components/bluecart_api/actions/get-product/get-product.mjs around lines 36
to 49, the code assumes response.product exists and accesses
response.product.item_id directly; add defensive null checks: verify response
and response.product before reading item_id, and if missing set a safe summary
(e.g., "Product data not found for requested id" or include response
status/message) and return or throw a clear error; ensure $.export("$summary",
...) uses a ternary or conditional to read item_id only when present to avoid
runtime exceptions.

};
70 changes: 65 additions & 5 deletions components/bluecart_api/bluecart_api.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "bluecart_api",
propDefinitions: {},
propDefinitions: {
walmartDomain: {
type: "string",
label: "Walmart Domain",
description: "The Walmart domain to target",
options: constants.DOMAIN_OPTIONS,
},
url: {
type: "string",
label: "URL",
description: "The Walmart product page URL to retrieve results from",
optional: true,
},
searchTerm: {
type: "string",
label: "Search Term",
description: "A search term used to find Walmart items",
},
itemId: {
type: "string",
label: "Item ID",
description: "The Walmart Item ID to retrieve product details for. Not used if a URL is provided",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.bluecartapi.com";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
params,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
params: {
api_key: `${this.$auth.api_key}`,
...params,
},
});
},
async getCategories(args = {}) {
return this._makeRequest({
path: "/categories",
...args,
});
},
async searchItem(args = {}) {
return this._makeRequest({
path: "/request",
...args,
});
},
async getAutocomplete(args = {}) {
return this._makeRequest({
path: "/request",
...args,
});
},
},
};
};
6 changes: 6 additions & 0 deletions components/bluecart_api/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
DOMAIN_OPTIONS: [
"walmart.com",
"walmart.ca",
],
};
5 changes: 4 additions & 1 deletion components/bluecart_api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/bluecart_api",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream BlueCart API Components",
"main": "bluecart_api.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.1"
}
}
Loading
Loading