Skip to content

New Components - convertapi #16425

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

Merged
merged 5 commits into from
Apr 30, 2025
Merged

New Components - convertapi #16425

merged 5 commits into from
Apr 30, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Apr 24, 2025

Resolves #13324.

Summary by CodeRabbit

  • New Features

    • Introduced actions to convert files, base64-encoded files, and website URLs to various formats using ConvertAPI.
    • Added support for extensive conversion parameters, including output format selection, image/PDF options, and web content handling.
    • Provided dynamic fetching of allowed target formats based on source format.
  • Enhancements

    • Added standardized option lists for formats, page sizes, and conversion settings.
    • Introduced utility functions for file handling and saving converted files.
  • Chores

    • Updated package dependencies and configuration.
    • Removed obsolete files and improved app structure.

@luancazarine luancazarine added the ai-assisted Content generated by AI, with human refinement and modification label Apr 24, 2025
Copy link

vercel bot commented Apr 24, 2025

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Apr 30, 2025 3:23pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 30, 2025 3:23pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 30, 2025 3:23pm

Copy link
Contributor

coderabbitai bot commented Apr 24, 2025

"""

Walkthrough

This update introduces a new ConvertAPI integration component with three primary actions: converting a base64-encoded file, converting a file from disk, and converting a web URL to a specified format. The new implementation provides dynamic property options based on available formats, comprehensive parameter support for web conversions, and utility functions for file handling. Supporting constants and utilities are modularized, and the package metadata is updated to reflect these changes. The previous TypeScript app and its .gitignore are removed in favor of the new JavaScript-based structure.

Changes

File(s) Change Summary
components/convertapi/actions/convert-base64-encoded-file/convert-base64-encoded-file.mjs Added new action to convert a base64-encoded file to a user-specified format using ConvertAPI, with dynamic output format options and file-saving logic.
components/convertapi/actions/convert-file/convert-file.mjs Added new action to convert a file from disk to another format using ConvertAPI, including dynamic output format selection and error handling.
components/convertapi/actions/convert-web-url/convert-web-url.mjs Added new action to convert a web URL to a specified format, supporting extensive configuration options and dynamic property visibility.
components/convertapi/convertapi.app.mjs Introduced new ConvertAPI app definition with authentication, prop definitions, and methods for format fetching and file/web conversions.
components/convertapi/common/constants.mjs Added constants for format options, media types, page orientations, page sizes, fixed element handling, and output formats.
components/convertapi/common/utils.mjs Added utility functions for ensuring file paths are in /tmp and for saving base64-encoded files to disk.
components/convertapi/package.json Updated package version, entry point, dependencies, and removed "files" field.
components/convertapi/app/convertapi.app.ts Deleted previous TypeScript-based app definition for ConvertAPI.
components/convertapi/.gitignore Deleted .gitignore that excluded .js, .mjs, and dist directory from version control.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant User
    participant Action
    participant ConvertAPI App
    participant ConvertAPI Service
    participant Utils

    User->>Action: Provide input (base64/file/url, format, etc.)
    Action->>ConvertAPI App: Request allowed output formats (if needed)
    ConvertAPI App->>ConvertAPI Service: Fetch allowed formats
    ConvertAPI Service-->>ConvertAPI App: Return allowed formats
    ConvertAPI App-->>Action: Return allowed formats
    User->>Action: Select output format
    Action->>ConvertAPI App: Submit conversion request with parameters
    ConvertAPI App->>ConvertAPI Service: Perform conversion API call
    ConvertAPI Service-->>ConvertAPI App: Return converted file(s)
    ConvertAPI App-->>Action: Return file(s)
    Action->>Utils: Save file(s) to /tmp
    Utils-->>Action: File saved
    Action-->>User: Export summary with file location

Assessment against linked issues

Objective Addressed Explanation
Implement convert-base64-encoded-file action as described in #13324
Implement convert-file action as described in #13324
Implement convert-web-url action as described in #13324
Use dynamic format selection and proper API integration per ConvertAPI documentation (#13324)

Suggested reviewers

  • lcaresia

Poem

A bunny hopped in code’s domain,
And brought new actions—clear, not arcane!
Convert files, URLs, and base64 with glee,
Saving them snugly in /tmp, you see.
Constants and helpers, all neat in their place,
This rabbit’s release is a swift, clever race!
🐇✨
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/convertapi/actions/convert-web-url/convert-web-url.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74f4664 and f62e4a5.

📒 Files selected for processing (1)
  • components/convertapi/actions/convert-web-url/convert-web-url.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/convertapi/actions/convert-web-url/convert-web-url.mjs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
✨ Finishing Touches
  • 📝 Generate Docstrings

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

Sorry, something went wrong.

Actions
 - Convert Base64 Encoded File
 - Convert File
 - Convert Web URL
@luancazarine luancazarine marked this pull request as ready for review April 28, 2025 19:33
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: 10

🧹 Nitpick comments (3)
components/convertapi/common/constants.mjs (1)

75-78: Fix typo in constant name

There's a typo in the constant name CSS_MEDIA_TYTPE_OPTIONS - it should be CSS_MEDIA_TYPE_OPTIONS.

-export const CSS_MEDIA_TYTPE_OPTIONS = [
+export const CSS_MEDIA_TYPE_OPTIONS = [
  "print",
  "screen",
];
components/convertapi/convertapi.app.mjs (1)

20-62: Add JSDoc comments to methods

Consider adding JSDoc comments to describe the methods, their parameters, and return values. This improves code documentation and IDE support.

Example for one method:

+  /**
+   * Get allowed output formats for a given input format
+   * @param {Object} params - Parameters
+   * @param {string} params.formatFrom - Input format
+   * @returns {Promise<Object>} - API response with allowed formats
+   */
  getAllowedFormats({ formatFrom }) {
    return this._makeRequest({
      path: `/info/openapi/${formatFrom}/to/*`,
    });
  },
components/convertapi/actions/convert-file/convert-file.mjs (1)

38-43: Simplify the filter callback to avoid an unnecessary if block

Array.prototype.filter expects a boolean return value. The extra if wrapper is redundant and slightly harder to read. A terser arrow-function improves clarity and removes the risk of accidentally returning undefined for non-matched items (which is still falsy, but not explicit).

-const allowedFormats = Object.keys(paths).filter((format) => {
-  if (format.startsWith(str)) {
-    return true;
-  }
-})
-  .map((format) => format.slice(str.length));
+const allowedFormats = Object.keys(paths)
+  .filter((format) => format.startsWith(str))
+  .map((format) => format.slice(str.length));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ea8d185 and d8be3d9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • components/convertapi/.gitignore (0 hunks)
  • components/convertapi/actions/convert-base64-encoded-file/convert-base64-encoded-file.mjs (1 hunks)
  • components/convertapi/actions/convert-file/convert-file.mjs (1 hunks)
  • components/convertapi/actions/convert-web-url/convert-web-url.mjs (1 hunks)
  • components/convertapi/app/convertapi.app.ts (0 hunks)
  • components/convertapi/common/constants.mjs (1 hunks)
  • components/convertapi/common/utils.mjs (1 hunks)
  • components/convertapi/convertapi.app.mjs (1 hunks)
  • components/convertapi/package.json (1 hunks)
💤 Files with no reviewable changes (2)
  • components/convertapi/.gitignore
  • components/convertapi/app/convertapi.app.ts
🔇 Additional comments (10)
components/convertapi/common/utils.mjs (1)

3-8: LGTM - Utility function for path normalization

The checkTmp function properly ensures filenames are prefixed with "/tmp", which is good practice for serverless environments like Pipedream where temporary file storage is restricted to the /tmp directory.

components/convertapi/common/constants.mjs (5)

1-73: LGTM - Comprehensive format options list

The FORMAT_OPTIONS array provides a comprehensive list of supported file formats that users can select from.


80-83: LGTM - Page orientation options

The page orientation options are appropriate and complete.


85-162: LGTM - Comprehensive page size options

The page size options are well-defined with descriptive labels including dimensions in both metric and imperial units.


164-181: LGTM - Fixed elements options

The fixed elements options provide clear labels and corresponding values.


183-186:

❓ Verification inconclusive

Verify if FORMAT_TO_OPTIONS is intentionally limited

The FORMAT_TO_OPTIONS array only includes "jpg" and "pdf". Is this intentionally limited? If the API supports more output formats, consider expanding this list or adding a comment explaining why it's restricted.

Run the following script to check what formats are actually supported:


🏁 Script executed:

#!/bin/bash
# Check the supported formats from the ConvertAPI documentation or API
curl -s "https://v2.convertapi.com/info/formats" | jq '.'

Length of output: 55


Confirm API-supported output formats or document the restriction

The call to https://v2.convertapi.com/info/formats returned no data (likely due to missing authentication or a changed endpoint). Please manually verify which output formats the API actually supports. If it truly only supports "jpg" and "pdf", add a comment to that effect; otherwise, expand FORMAT_TO_OPTIONS accordingly.

• File: components/convertapi/common/constants.mjs
• Lines: 183–186

-export const FORMAT_TO_OPTIONS = [
-  "jpg",
-  "pdf",
-];
+// TODO: Verify supported output formats. If only "jpg" & "pdf" are supported by ConvertAPI, this restriction is intentional.
+export const FORMAT_TO_OPTIONS = [
+  "jpg",
+  "pdf",
+];
components/convertapi/package.json (2)

3-3: LGTM - Version bump to 0.1.0

Appropriate version bump to 0.1.0 for a significant component update.


5-5: LGTM - Updated main entry point

Main entry point correctly updated to point to the new JavaScript implementation.

components/convertapi/convertapi.app.mjs (2)

1-3: LGTM - Proper imports

The imports for axios and the format constants are appropriate.


4-19: LGTM - Good app structure and property definitions

The app structure follows Pipedream conventions, and the property definitions are well described with appropriate types and labels.

Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @luancazarine I've just added a minor suggestion. It's optional so lgtm! Ready for QA!

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

♻️ Duplicate comments (4)
components/convertapi/actions/convert-web-url/convert-web-url.mjs (4)

370-370: 🛠️ Refactor suggestion

Return the mutated props object, not an empty literal

Returning {} discards all runtime visibility changes and repeats a problem flagged in a previous review. Return props instead.

-    return {};
+    return props;

392-402: 🛠️ Refactor suggestion

imageQuality not sent in payload

Even if the control becomes visible, its value is never appended, so JPG quality is stuck at ConvertAPI default.

-        if (this.zoom) data.append("Zoom", this.zoom);
+        if (this.zoom) data.append("Zoom", this.zoom);
+        if (this.imageQuality) data.append("ImageQuality", this.imageQuality);

335-346: ⚠️ Potential issue

type prop referenced but never declared – will throw TypeError

additionalProps toggles props.type.hidden, yet no type property exists in the props block. Accessing hidden on undefined crashes the Pipedream UI.

Either add the property definition or remove these three lines:

-    props.type.hidden = !isJpg;

335-346: 🛠️ Refactor suggestion

Forgot to toggle imageQuality visibility

imageQuality is JPG-specific but its hidden flag is never flipped, so the control is permanently invisible.

+    props.imageQuality.hidden = !isJpg;
🧹 Nitpick comments (2)
components/convertapi/actions/convert-web-url/convert-web-url.mjs (2)

70-78: Spelling nit in description string

Exaple:Example: helps users copy/paste cookie syntax correctly.

-      description: "Set additional cookies for the page request. Exaple: cookiename1=cookievalue1; cookiename2=cookievalue2; cookiename3=cookievalue3",
+      description: "Set additional cookies for the page request. Example: cookiename1=cookievalue1; cookiename2=cookievalue2; cookiename3=cookievalue3",

300-303: Minor UI label typo

ShowElements is missing a space – for consistency with other labels use “Show Elements”.

-      label: "ShowElements",
+      label: "Show Elements",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d8be3d9 and 74f4664.

📒 Files selected for processing (3)
  • components/convertapi/actions/convert-base64-encoded-file/convert-base64-encoded-file.mjs (1 hunks)
  • components/convertapi/actions/convert-file/convert-file.mjs (1 hunks)
  • components/convertapi/actions/convert-web-url/convert-web-url.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/convertapi/actions/convert-base64-encoded-file/convert-base64-encoded-file.mjs
  • components/convertapi/actions/convert-file/convert-file.mjs
⏰ 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 (1)
components/convertapi/actions/convert-web-url/convert-web-url.mjs (1)

3-8:

❌ Incorrect review comment

Possible typo in imported constant breaks runtime

CSS_MEDIA_TYTPE_OPTIONS appears to be miss-spelled (TYTPE). If the constant is exported as CSS_MEDIA_TYPE_OPTIONS (or similar) in ../../common/constants.mjs, this import will be undefined, which causes the options list to be empty and may crash the component render.

-  CSS_MEDIA_TYTPE_OPTIONS,
+  CSS_MEDIA_TYPE_OPTIONS,

Please verify the constant name in constants.mjs.


🏁 Script executed:

#!/bin/bash
# Search for CSS_MEDIA_* constants in the codebase
rg "CSS_MEDIA_" -n .

Length of output: 318


Review comment incorrect: constant spelling is consistent across declaration and usage

The constant CSS_MEDIA_TYTPE_OPTIONS is declared in components/convertapi/common/constants.mjs and imported with the identical name. There is no missing export or runtime break caused by a mismatch.

Likely an incorrect or invalid review comment.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@luancazarine
Copy link
Collaborator Author

/approve

@luancazarine luancazarine merged commit 159d440 into master Apr 30, 2025
10 of 11 checks passed
@luancazarine luancazarine deleted the issue-13324 branch April 30, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai-assisted Content generated by AI, with human refinement and modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Components] convertapi
2 participants