Skip to content

[Components] modelry #12525 #16350

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

[Components] modelry #12525 #16350

wants to merge 2 commits into from

Conversation

lcaresia
Copy link
Collaborator

@lcaresia lcaresia commented Apr 17, 2025

WHY

Summary by CodeRabbit

  • New Features

    • Introduced actions to create, retrieve, and delete products via the Modelry API.
    • Added support for managing product details, including SKU, title, batch ID, description, tags, dimensions, and external URL.
  • Chores

    • Updated package version to 0.1.0 and added a new platform dependency.

@lcaresia lcaresia self-assigned this Apr 17, 2025
Copy link

vercel bot commented Apr 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2025 11:52am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
pipedream-docs ⬜️ Ignored (Inspect) Apr 22, 2025 11:52am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 22, 2025 11:52am

Copy link
Contributor

coderabbitai bot commented Apr 17, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update introduces a set of new action modules for product management within the Modelry integration, including creating, retrieving, and deleting products via API calls. The Modelry app component is extensively implemented with property definitions and methods for CRUD operations, leveraging axios for HTTP requests and supporting dynamic product selection. The package metadata is updated to version 0.1.0, and a new dependency on "@pipedream/platform" is added.

Changes

File(s) Change Summary
components/modelry/actions/create-product/create-product.mjs Introduced a new "Create Product" action module. Defines properties for product creation, metadata, and an async run method that calls the app's createProduct method and returns a summary and response.
components/modelry/actions/delete-product/delete-product.mjs Added a "Delete Product" action module. Accepts a product ID, defines metadata, and implements an async run method that deletes a product via the app's deleteProduct method, returning a summary and response.
components/modelry/actions/get-product/get-product.mjs Added a "Get Product" action module. Accepts a product ID, defines metadata, and implements an async run method that retrieves product details via the app's getProduct method, returning a summary and response.
components/modelry/modelry.app.mjs Fully implemented the Modelry app component. Added property definitions for product fields, dynamic product ID selection, and methods for product CRUD operations using axios. Removed placeholder methods and provided a complete API interface.
components/modelry/package.json Updated the package version to 0.1.0 and added a dependency on "@pipedream/platform" version ^3.0.3. No changes to exported or public code entities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActionModule
    participant ModelryApp
    participant ModelryAPI

    User->>ActionModule: Trigger action (Create/Get/Delete Product)
    ActionModule->>ModelryApp: Call respective method (createProduct/getProduct/deleteProduct)
    ModelryApp->>ModelryAPI: Send HTTP request via axios
    ModelryAPI-->>ModelryApp: Return API response
    ModelryApp-->>ActionModule: Return result
    ActionModule-->>User: Output summary and data
Loading

Suggested labels

ai-assisted

Suggested reviewers

  • jcortes

Poem

A hop, a leap, new actions appear,
Products to create, fetch, or clear.
Modelry now dances with code so bright,
CRUD ops in place, all working right!
With version bumped and platform in tow,
This rabbit’s proud to see the features grow.
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lcaresia lcaresia linked an issue Apr 17, 2025 that may be closed by this pull request
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (7)
components/modelry/modelry.app.mjs (3)

94-98: Inconsistent trailing slash in API endpoints.

The endpoints in getProduct and deleteProduct include a trailing slash (/products/${productId}/) while other endpoints like /products in createProduct and getProducts do not. Consider making this consistent across all endpoints.

- path: `/products/${productId}/`,
+ path: `/products/${productId}`,

Also applies to: 102-107


108-113: Consider adding pagination support for getProducts.

The getProducts method doesn't handle API pagination. If the Modelry API supports pagination and there are many products, this method might not fetch all of them.

async getProducts(args = {}) {
  return this._makeRequest({
    path: "/products",
    ...args,
  });
}

You could enhance this to automatically handle pagination if needed:

async getProducts(args = {}) {
  // This is a simplified example - adjust based on the actual API pagination implementation
  const allProducts = [];
  let page = 1;
  let hasMore = true;
  
  while (hasMore) {
    const response = await this._makeRequest({
      path: "/products",
      params: { page },
      ...args,
    });
    
    allProducts.push(...response.data);
    
    // Check if there are more pages - this logic depends on the API's pagination scheme
    hasMore = response.meta?.nextPage || false;
    page++;
  }
  
  return { data: allProducts };
}

67-83: Consider adding basic error handling in _makeRequest.

The _makeRequest method doesn't have any error handling. While errors will propagate to the caller, catching and transforming API errors can provide more helpful error messages.

async _makeRequest(opts = {}) {
  const {
    $ = this,
    path,
    headers,
    ...otherOpts
  } = opts;
-  return axios($, {
-    ...otherOpts,
-    url: this._baseUrl() + path,
-    headers: {
-      ...headers,
-      "Content-Type": "application/json",
-      "Authorization": `${this.$auth.api_token}`,
-    },
-  });
+  try {
+    return await axios($, {
+      ...otherOpts,
+      url: this._baseUrl() + path,
+      headers: {
+        ...headers,
+        "Content-Type": "application/json",
+        "Authorization": `${this.$auth.api_token}`,
+      },
+    });
+  } catch (error) {
+    const statusCode = error.response?.status;
+    const statusText = error.response?.statusText;
+    const errorMsg = error.response?.data?.error || error.message;
+    throw new Error(`Modelry API error (${statusCode} ${statusText}): ${errorMsg}`);
+  }
}
components/modelry/actions/create-product/create-product.mjs (1)

54-71: Consider handling empty arrays and null values.

The current implementation doesn't handle special cases for array or optional fields. If this.tags is undefined, it will be sent as-is to the API. Some APIs expect empty arrays instead of null/undefined values.

async run({ $ }) {
  const response = await this.app.createProduct({
    $,
    data: {
      product: {
        sku: this.sku,
        title: this.title,
        batch_id: this.batchId,
        description: this.description,
-       tags: this.tags,
+       tags: this.tags || [],
        dimensions: this.dimensions,
        external_url: this.externalUrl,
      },
    },
  });
  $.export("$summary", "Successfully created the product");
  return response;
}
components/modelry/actions/delete-product/delete-product.mjs (1)

4-8: Version consistency with package.json.

The action version is set to 0.0.1, while the package.json version was updated to 0.1.0. Consider aligning these versions for consistency.

- version: "0.0.1",
+ version: "0.1.0",
components/modelry/actions/get-product/get-product.mjs (2)

18-25: Consider adding error handling.

While the implementation is functionally correct, it would be more robust with explicit error handling for API failures.

  async run({ $ }) {
-   const response = await this.app.getProduct({
-     $,
-     productId: this.productId,
-   });
-   $.export("$summary", "Successfully retrieved the product details");
-   return response;
+   try {
+     const response = await this.app.getProduct({
+       $,
+       productId: this.productId,
+     });
+     $.export("$summary", "Successfully retrieved the product details");
+     return response;
+   } catch (error) {
+     $.export("$summary", `Failed to retrieve product: ${error.message}`);
+     throw error;
+   }
  },

1-26: Consider adding input validation.

Though the propDefinition likely handles basic validation, consider adding additional validation for the productId in the run method to ensure it's in the expected format before making the API call.

  async run({ $ }) {
+   if (!this.productId || typeof this.productId !== 'string') {
+     throw new Error('A valid product ID is required');
+   }
    const response = await this.app.getProduct({
      $,
      productId: this.productId,
    });
    $.export("$summary", "Successfully retrieved the product details");
    return response;
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0dc0ec4 and 482f877.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • components/modelry/actions/create-product/create-product.mjs (1 hunks)
  • components/modelry/actions/delete-product/delete-product.mjs (1 hunks)
  • components/modelry/actions/get-product/get-product.mjs (1 hunks)
  • components/modelry/modelry.app.mjs (1 hunks)
  • components/modelry/package.json (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (10)
components/modelry/modelry.app.mjs (3)

64-66: Good implementation of the base URL method.

The _baseUrl method correctly provides the API base URL for Modelry. This separation makes it easy to change the base URL if needed in the future.


67-83: Authorization header might be missing a token type prefix.

The Authorization header is currently set as just the raw token value. Most REST APIs expect a token type prefix like "Bearer" before the token.

- "Authorization": `${this.$auth.api_token}`,
+ "Authorization": `Bearer ${this.$auth.api_token}`,

Please check the Modelry API documentation to confirm the correct authorization header format.


51-60: Good implementation of dynamic product options.

The options method for the productId prop correctly fetches and maps products into a format suitable for dropdown selection, providing a good user experience.

components/modelry/package.json (2)

3-3: Version bump is appropriate for feature additions.

The version increase from 0.0.1 to 0.1.0 follows semantic versioning principles for adding new features.


15-16: Correct dependency for platform functionality.

Adding the @pipedream/platform dependency is necessary for using axios from the platform in the app file.

components/modelry/actions/create-product/create-product.mjs (1)

6-7:

✅ Verification successful

Documentation link needs verification.

The documentation link in the description points to https://files.cgtarsenal.com/api/doc/index.html, which seems like it might be a private URL. Consider using a more accessible public documentation URL if available.


🏁 Script executed:

#!/bin/bash
# Check if the documentation URL is publicly accessible
response=$(curl -s -o /dev/null -w "%{http_code}" https://files.cgtarsenal.com/api/doc/index.html)
echo "HTTP Status Code: $response"
if [[ $response == 200 ]]; then
  echo "The documentation URL is publicly accessible"
else
  echo "The documentation URL might not be publicly accessible"
fi

Length of output: 275


Documentation Link Verified

The URL https://files.cgtarsenal.com/api/doc/index.html#api-Products-CreateProduct returns HTTP 200 and is publicly accessible, so no changes are needed.

components/modelry/actions/delete-product/delete-product.mjs (1)

6-7:

✅ Verification successful

Documentation link consistency with other actions.

This action uses the same documentation link as the create-product action. Ensure that this link points to the relevant section for deleting products, not just the general API documentation.


🏁 Script executed:

#!/bin/bash
# Check if the documentation URL is publicly accessible
response=$(curl -s -o /dev/null -w "%{http_code}" https://files.cgtarsenal.com/api/doc/index.html)
echo "HTTP Status Code: $response"
if [[ $response == 200 ]]; then
  echo "The documentation URL is publicly accessible"
else
  echo "The documentation URL might not be publicly accessible"
fi

Length of output: 275


It looks like the Delete Product action’s link already includes the specific “#api-Products-DeleteProduct” anchor and differs from Create Product’s “#api-Products-CreateProduct” anchor, so no change is required here.

components/modelry/actions/get-product/get-product.mjs (3)

1-2: Clean and appropriate import.

The import statement correctly references the parent app module, following good module organization practices.


3-8: Component metadata looks good.

The component is well-defined with a unique key, clear name, descriptive text with documentation link, version, and proper type specification.


9-17: Props structure follows best practices.

Good job reusing the app's property definition for productId. This promotes consistency and reduces duplication across components.

Comment on lines +69 to +70
$.export("$summary", "Successfully created the product");
return response;
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 17, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add response validation before reporting success.

The action currently reports successful product creation regardless of the API response. Consider checking the response status or structure before declaring success.

- $.export("$summary", "Successfully created the product");
- return response;
+ const { data } = response;
+ $.export("$summary", `Successfully created product "${data.product.title}" with ID: ${data.product.id}`);
+ return data;

This assumes the response includes the created product details. Adjust according to the actual API response structure.

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lcaresia if the response includes an ID, I'd apply this suggestion from CodeRabbit, since that is the standard we adopt for summaries

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

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

I suggest including the ID of the selected product (or the response) in all the summaries.

Moving it to QA though since this does not impact functionality

Comment on lines +69 to +70
$.export("$summary", "Successfully created the product");
return response;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lcaresia if the response includes an ID, I'd apply this suggestion from CodeRabbit, since that is the standard we adopt for summaries

@lcaresia
Copy link
Collaborator Author

/approve

@GTFalcao
Copy link
Collaborator

@lcaresia not sure if you read the previous comment, let me know if you agree with the suggestion or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Components] modelry
2 participants