Skip to content

New Components - transloadit #16579

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 6 commits into from
May 9, 2025
Merged

New Components - transloadit #16579

merged 6 commits into from
May 9, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented May 7, 2025

Resolves #16556.

Summary by CodeRabbit

  • New Features
    • Added actions to create, cancel, and fetch status of Transloadit assemblies.
    • Introduced event sources that emit notifications on assembly completion and failure.
    • Enabled dynamic selection of templates and assemblies with paginated option loaders.
  • Improvements
    • Added utility for robust JSON parsing and a constant to limit API results.
    • Enhanced event handling with sample events for improved testing and simulation.
  • Chores
    • Updated package dependencies and bumped version to 0.1.0.

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

vercel bot commented May 7, 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 May 8, 2025 7:38pm
pipedream-docs ⬜️ Ignored (Inspect) May 8, 2025 7:38pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 8, 2025 7:38pm

Copy link
Contributor

coderabbitai bot commented May 7, 2025

Walkthrough

This update introduces a comprehensive Transloadit integration, adding new actions for creating, canceling, and checking the status of assemblies, as well as polling sources for completed and failed assemblies. Supporting utilities, constants, and app-level methods are implemented to handle API interactions, option loading, and event emission.

Changes

File(s) Change Summary
components/transloadit/actions/cancel-assembly/cancel-assembly.mjs New action: Cancel Assembly. Allows canceling a running assembly by ID.
components/transloadit/actions/create-assembly/create-assembly.mjs New action: Create Assembly. Enables creation of assemblies with templates or steps and handles input validation.
components/transloadit/actions/get-assembly-status/get-assembly-status.mjs New action: Get Assembly Status. Retrieves status/results of a specified assembly.
components/transloadit/common/constants.mjs Adds and exports a numeric constant LIMIT = 5000.
components/transloadit/common/utils.mjs Adds and exports a utility function parseObject for robust JSON parsing.
components/transloadit/package.json Updates version to 0.1.0 and adds dependencies for "@pipedream/platform" and "transloadit".
components/transloadit/sources/common/base.mjs Adds a base source module for polling and emitting assembly events, with pagination and event deduplication logic.
components/transloadit/sources/new-assembly-completed/new-assembly-completed.mjs New source: emits events for completed assemblies, extending the common base.
components/transloadit/sources/new-assembly-completed/test-event.mjs Adds a sample completed assembly event for testing.
components/transloadit/sources/new-assembly-error/new-assembly-error.mjs New source: emits events for failed assemblies, extending the common base.
components/transloadit/sources/new-assembly-error/test-event.mjs Adds a sample failed assembly event for testing.
components/transloadit/transloadit.app.mjs Implements the Transloadit app: property definitions, API methods, pagination, and client setup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant TransloaditApp
    participant TransloaditAPI

    User->>Action: Trigger Create Assembly
    Action->>TransloaditApp: createAssembly(opts)
    TransloaditApp->>TransloaditAPI: POST /assemblies
    TransloaditAPI-->>TransloaditApp: Assembly response
    TransloaditApp-->>Action: Assembly result
    Action-->>User: Summary and result

    User->>Action: Trigger Cancel Assembly
    Action->>TransloaditApp: cancelAssembly(assemblyId)
    TransloaditApp->>TransloaditAPI: DELETE /assemblies/{id}
    TransloaditAPI-->>TransloaditApp: Cancel response
    TransloaditApp-->>Action: Cancel result
    Action-->>User: Summary and result

    User->>Action: Get Assembly Status
    Action->>TransloaditApp: getAssemblyStatus(assemblyId)
    TransloaditApp->>TransloaditAPI: GET /assemblies/{id}
    TransloaditAPI-->>TransloaditApp: Status response
    TransloaditApp-->>Action: Status result
    Action-->>User: Summary and result
Loading
sequenceDiagram
    participant Source
    participant TransloaditApp
    participant TransloaditAPI
    participant EventStream

    loop Polling Interval
        Source->>TransloaditApp: listAssemblies(status)
        TransloaditApp->>TransloaditAPI: GET /assemblies?status={type}
        TransloaditAPI-->>TransloaditApp: Assemblies list
        TransloaditApp-->>Source: Assembly events
        Source->>EventStream: Emit new event(s)
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement "new-assembly-completed" polling source to emit events on assembly completion (#16556)
Implement "new-assembly-error" polling source to emit events on assembly failure (#16556)
Add "create-assembly" action supporting templates, steps, and validation (#16556)
Add "cancel-assembly" action to abort assemblies by ID (#16556)
Add "get-assembly-status" action to retrieve assembly status by ID (#16556)

Suggested reviewers

  • michelle0927

Poem

In fields of code where rabbits hop,
Assemblies start, assemble, and stop.
With actions new and sources bright,
We poll for errors, cheer success in sight.
JSON parsed, events emitted,
🐇 Transloadit’s magic, fully committed!
— A rabbit with a coder’s delight

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 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 6296ed0 and 6530978.

📒 Files selected for processing (1)
  • components/transloadit/transloadit.app.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/transloadit/transloadit.app.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

Sources
 - New Assembly Completed
 - New Assembly Error

Actions
 - Create Assembly
 - Cancel Assembly
 - Get Assembly Status
@michelle0927 michelle0927 marked this pull request as ready for review May 8, 2025 14:58
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: 6

🧹 Nitpick comments (4)
components/transloadit/sources/common/base.mjs (1)

40-43: Ensure responseArray is not empty before accessing index 0.

While you do check if responseArray.length is truthy before setting the last date, it would be more explicit to check if the length is greater than 0.

- if (responseArray.length) {
+ if (responseArray.length > 0) {
    this._setLastDate(responseArray[0].created);
  }
components/transloadit/sources/new-assembly-error/new-assembly-error.mjs (1)

8-9: Grammar + clarity in description

"Emit new event when a failed occurs during assembly processing" reads awkwardly (“a failed” → “a failure”). A small wording fix will make the component description clearer and more professional.

-  description: "Emit new event when a failed occurs during assembly processing. [See the documentation](https://transloadit.com/docs/api/assemblies-get/)",
+  description: "Emit an event when a failure occurs during assembly processing. [See the documentation](https://transloadit.com/docs/api/assemblies-get/)",
components/transloadit/actions/create-assembly/create-assembly.mjs (2)

13-17: Missing label / description fields on the info prop

The linter warnings point out that every prop (even alert props) needs a label and description per the Pipedream guidelines.

     info: {
       type: "alert",
+      label: "Information",
+      description: "Guidance on using the *Steps* and *Template ID* fields",
       alertType: "info",
🧰 Tools
🪛 GitHub Check: Lint Code Base

[warning] 13-13:
Component prop info must have a label. See https://pipedream.com/docs/components/guidelines/#props


[warning] 13-13:
Component prop info must have a description. See https://pipedream.com/docs/components/guidelines/#props


78-82: Constructing error message – prefer err.message & snake-vs-camel case

  1. err is interpolated directly, which leads to [object Object] for non-string errors.
  2. The Transloadit SDK returns assembly_id, not assemblyId.
-      let message = `Unable to process Assembly. ${err}`;
+      let message = `Unable to process Assembly. ${err?.message ?? err}`;
-      if (err.assemblyId) {
-        message += `More info: https://transloadit.com/assemblies/${err.assemblyId}`;
+      if (err.assembly_id) {
+        message += ` More info: https://transloadit.com/assemblies/${err.assembly_id}`;
       }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b9f6a17 and da937be.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • common/constants.mjs (1 hunks)
  • components/transloadit/actions/cancel-assembly/cancel-assembly.mjs (1 hunks)
  • components/transloadit/actions/create-assembly/create-assembly.mjs (1 hunks)
  • components/transloadit/actions/get-assembly-status/get-assembly-status.mjs (1 hunks)
  • components/transloadit/common/utils.mjs (1 hunks)
  • components/transloadit/package.json (2 hunks)
  • components/transloadit/sources/common/base.mjs (1 hunks)
  • components/transloadit/sources/new-assembly-completed/new-assembly-completed.mjs (1 hunks)
  • components/transloadit/sources/new-assembly-completed/test-event.mjs (1 hunks)
  • components/transloadit/sources/new-assembly-error/new-assembly-error.mjs (1 hunks)
  • components/transloadit/sources/new-assembly-error/test-event.mjs (1 hunks)
  • components/transloadit/transloadit.app.mjs (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint Code Base
components/transloadit/actions/create-assembly/create-assembly.mjs

[warning] 13-13:
Component prop info must have a label. See https://pipedream.com/docs/components/guidelines/#props


[warning] 13-13:
Component prop info must have a description. See https://pipedream.com/docs/components/guidelines/#props

🔇 Additional comments (12)
common/constants.mjs (1)

1-1: Introduce a pagination limit constant
Defining LIMIT in a single place avoids magic numbers and improves maintainability when handling paginated requests.

components/transloadit/package.json (3)

3-3: Bump package version
Updating the version to 0.1.0 correctly reflects the new Transloadit integration release.


14-14: Publish configuration
The publishConfig.access: "public" setting is correctly placed for scoped public packages.


15-18: Declare necessary dependencies
Adding @pipedream/platform and transloadit aligns with the new components' requirements. Ensure these versions are compatible with the rest of the monorepo.

components/transloadit/common/utils.mjs (2)

4-15: Array handling logic is sound
The mapping and JSON parsing of string elements with graceful fallback is implemented correctly.


16-22: String parsing fallback
The try/catch around JSON.parse for string inputs ensures invalid JSON doesn't break the flow. Good error handling here.

components/transloadit/sources/new-assembly-error/test-event.mjs (1)

1-21: Provide representative failure event payload
The default export JSON mirrors the Transloadit failure event schema and will facilitate accurate testing of the error source component.

components/transloadit/sources/new-assembly-completed/test-event.mjs (1)

1-19: Provide representative success event payload
The default export JSON matches the Transloadit completion event schema and supports testing of the completed-source component.

components/transloadit/actions/cancel-assembly/cancel-assembly.mjs (1)

1-24: Well-implemented action component for canceling Transloadit assemblies.

The action is correctly structured with appropriate metadata and follows Pipedream component patterns. Good job including the documentation link in the description to help users understand the underlying API.

components/transloadit/actions/get-assembly-status/get-assembly-status.mjs (1)

1-23: Clean implementation of the assembly status retrieval action.

The component is well-structured and follows the established patterns for Pipedream actions. Good inclusion of the documentation link and a clear summary message for user feedback.

components/transloadit/sources/new-assembly-completed/new-assembly-completed.mjs (1)

1-22: Well-structured source component extending the base implementation.

The component correctly extends the common base functionality and provides specific implementations for event type filtering and summary formatting. Good use of the spread operator to inherit base methods while adding custom ones.

components/transloadit/transloadit.app.mjs (1)

15-16: Pagination maths may skip pages

page * LIMIT mixes “page number” with “offset”.
Pipedream’s page argument starts at 0; Transloadit expects a page index (1-based). Multiplying by LIMIT will jump by huge increments (e.g. page 2 → 60 instead of 3). Use page + 1 for the requested page index.

-            page: page * LIMIT,
+            page: page + 1,

@michelle0927
Copy link
Collaborator

@luancazarine This is failing one of the PR checks. Make sure to run eslint on all files before pushing changes.

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

Oops, I had assumed pageSize was correct since you used it twice and pagesize once, but looks like it's the other way around.

@luancazarine luancazarine requested a review from michelle0927 May 8, 2025 19:38
Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

@luancazarine luancazarine merged commit 0c5ad79 into master May 9, 2025
11 checks passed
@luancazarine luancazarine deleted the issue-16556 branch May 9, 2025 12:52
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] transloadit
2 participants