-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
base: master
Are you sure you want to change the base?
New Components - convertapi #16425
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis 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 Changes
Sequence Diagram(s)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
Poem
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
components/convertapi/actions/convert-base64-encoded-file/convert-base64-encoded-file.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/convertapi/actions/convert-file/convert-file.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/convertapi/actions/convert-web-url/convert-web-url.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Actions - Convert Base64 Encoded File - Convert File - Convert Web URL
There was a problem hiding this 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 nameThere's a typo in the constant name
CSS_MEDIA_TYTPE_OPTIONS
- it should beCSS_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 methodsConsider 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 unnecessaryif
block
Array.prototype.filter
expects a boolean return value. The extraif
wrapper is redundant and slightly harder to read. A terser arrow-function improves clarity and removes the risk of accidentally returningundefined
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
⛔ 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 normalizationThe
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 listThe
FORMAT_OPTIONS
array provides a comprehensive list of supported file formats that users can select from.
80-83
: LGTM - Page orientation optionsThe page orientation options are appropriate and complete.
85-162
: LGTM - Comprehensive page size optionsThe page size options are well-defined with descriptive labels including dimensions in both metric and imperial units.
164-181
: LGTM - Fixed elements optionsThe 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, expandFORMAT_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.0Appropriate version bump to 0.1.0 for a significant component update.
5-5
: LGTM - Updated main entry pointMain entry point correctly updated to point to the new JavaScript implementation.
components/convertapi/convertapi.app.mjs (2)
1-3
: LGTM - Proper importsThe imports for axios and the format constants are appropriate.
4-19
: LGTM - Good app structure and property definitionsThe app structure follows Pipedream conventions, and the property definitions are well described with appropriate types and labels.
components/convertapi/actions/convert-base64-encoded-file/convert-base64-encoded-file.mjs
Show resolved
Hide resolved
There was a problem hiding this 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!
await saveFile(Files); | ||
|
||
$.export("$summary", `Successfully converted base64 encoded file to ${this.formatTo} and saved in /tmp directory as **${Files[0].FileName}**.`); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion here is if you are creating files in /tmp
let's return also the path in the step something like
return; | |
return { | |
filePath, | |
}; |
and the same suggestion goes for the other action components
Resolves #13324.
Summary by CodeRabbit
New Features
Enhancements
Chores