Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 6, 2025

Resolves #16527

Summary by CodeRabbit

  • New Features

    • Added actions to create render jobs, get render status, and list templates for the Plainly integration.
    • Introduced event sources to emit events when a render job completes, fails, or when a new video is created in Plainly.
    • Enhanced Plainly integration with dynamic dropdowns and full API access for projects, renders, brands, articles, and videos.
  • Chores

    • Updated package version and added a new dependency for improved platform compatibility.

@vercel
Copy link

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 6, 2025

Walkthrough

This update introduces a full integration for the Plainly video automation platform, adding new actions, event sources, utility functions, and dynamic property definitions. The changes enable creating and monitoring render jobs, listing templates, and tracking new video creations or render outcomes, with robust API interactions and configurable event emission.

Changes

File(s) Change Summary
components/plainly/actions/create-render-job/create-render-job.mjs Added new action to create a render job with extensive configuration options, dynamic property visibility, and input validation.
components/plainly/actions/get-render-status/get-render-status.mjs Added new action to retrieve the status of a render job by render ID.
components/plainly/actions/list-templates/list-templates.mjs Added new action to list video templates available in a specified project.
components/plainly/common/utils.mjs Introduced utility functions for parsing JSON and object entries, supporting flexible input handling for actions.
components/plainly/package.json Updated version to 0.1.0 and added a dependency on "@pipedream/platform".
components/plainly/plainly.app.mjs Implemented dynamic property definitions and comprehensive API methods for interacting with Plainly, including CRUD operations and dropdown population.
components/plainly/sources/common/base.mjs Added a base class for polling sources, supporting pagination, stateful event emission, and requiring subclasses to define resource access and metadata generation.
components/plainly/sources/new-render-completed/new-render-completed.mjs Added new source to emit events when a render job completes successfully, with project and template scoping.
components/plainly/sources/new-render-failed/new-render-failed.mjs Added new source to emit events when a render job fails, with optional project and template filtering.
components/plainly/sources/new-video-created/new-video-created.mjs Added new source to emit events when a new video is created or uploaded, supporting brand and article scoping.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant PlainlyAPI

    User->>Action: Trigger Create Render Job
    Action->>PlainlyAPI: POST /renders (with config)
    PlainlyAPI-->>Action: Render Job Created (ID)
    Action-->>User: Output summary with Render Job ID

    User->>Action: Trigger Get Render Status
    Action->>PlainlyAPI: GET /renders/{renderId}
    PlainlyAPI-->>Action: Render Status
    Action-->>User: Output summary with status

    User->>Action: Trigger List Templates
    Action->>PlainlyAPI: GET /projects/{projectId}
    PlainlyAPI-->>Action: Project Data (templates)
    Action-->>User: Output templates list

    Note over Sources: For event sources (e.g., new-render-completed):<br>Polling periodically, fetching new items, emitting events.
Loading

Assessment against linked issues

Objective Addressed Explanation
Add polling source: new-video-created (emit on video creation/upload) (#16527)
Add polling source: new-render-completed (emit on render completion, project scoping) (#16527)
Add polling source: new-render-failed (emit on render failure, project scoping) (#16527)
Add actions: create-render-job, get-render-status, list-templates (#16527)

Suggested labels

ai-assisted

Suggested reviewers

  • GTFalcao

Poem

In the land of Plainly, new features hop in—
Actions and sources, let automations begin!
Renders are tracked, templates in view,
With polling and parsing, there’s nothing we can’t do.
🐇✨
A carrot for progress, and a hop for each win!

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/plainly/actions/get-render-status/get-render-status.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)

components/plainly/actions/create-render-job/create-render-job.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)

components/plainly/plainly.app.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)

  • 6 others
✨ 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.

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: 4

🧹 Nitpick comments (13)
components/plainly/actions/get-render-status/get-render-status.mjs (1)

18-25: Fix space in template string for summary.

There's an extra space before the closing curly brace in the template string that may cause unexpected formatting in the output summary.

-    $.export("$summary", `Retrieved status ${render.state } for render ${this.renderId}`);
+    $.export("$summary", `Retrieved status ${render.state} for render ${this.renderId}`);
components/plainly/plainly.app.mjs (2)

81-98: Consider adding error handling to API requests

The _makeRequest method should include error handling to provide more informative error messages when API requests fail. This would improve debugging and user experience.

_makeRequest({
  $ = this,
  path,
  ...otherOpts
}) {
-  return axios($, {
+  return axios($, {
    url: `${this._baseUrl()}${path}`,
    auth: {
      username: this.$auth.api_key,
      password: "",
    },
    ...otherOpts,
+  }).catch((error) => {
+    const status = error.response?.status;
+    const message = error.response?.data?.message || error.message;
+    throw new Error(`Plainly API error (${status}): ${message}`);
  });
}

121-126: Consider implementing standardized pagination handling

The listRenders method accepts pagination parameters, but there's no standardized approach to handle pagination across all listing methods. Consider implementing a consistent pagination strategy, especially for methods that might return large result sets.

components/plainly/actions/list-templates/list-templates.mjs (1)

18-29: Consider adding error handling

The run method should include try/catch error handling to provide more informative error messages when the API request fails.

async run({ $ }) {
+  try {
    const { templates } = await this.plainly.getProject({
      $,
      projectId: this.projectId,
    });

    if (templates?.length) {
      $.export("$summary", `Fetched ${templates.length} template${templates.length === 1
        ? ""
        : "s"}`);
    }
    return templates;
+  } catch (error) {
+    $.error(`Error fetching templates: ${error.message}`);
+    throw error;
+  }
},
components/plainly/sources/new-video-created/new-video-created.mjs (1)

43-49: Ensure date parsing is reliable

The generateMeta method uses Date.parse(item.createdDate) which assumes the API consistently returns dates in a format that JavaScript can parse. Consider using a more robust date parsing approach or adding validation.

generateMeta(item) {
+  // Ensure we have a valid timestamp, fallback to current time if parsing fails
+  const timestamp = item.createdDate ? Date.parse(item.createdDate) : null;
  return {
    id: item.id,
    summary: `New Video Created with ID: ${item.id}`,
-    ts: Date.parse(item.createdDate),
+    ts: timestamp || Date.now(),
  };
},
components/plainly/sources/new-render-completed/new-render-completed.mjs (1)

48-54: Ensure date parsing is reliable

Similar to the previous source component, the generateMeta method uses Date.parse(item.lastModified) which assumes the API consistently returns dates in a format that JavaScript can parse. Consider using a more robust date parsing approach or adding validation.

generateMeta(item) {
+  // Ensure we have a valid timestamp, fallback to current time if parsing fails
+  const timestamp = item.lastModified ? Date.parse(item.lastModified) : null;
  return {
    id: item.id,
    summary: `New Completed Render with ID: ${item.id}`,
-    ts: Date.parse(item.lastModified),
+    ts: timestamp || Date.now(),
  };
},
components/plainly/sources/common/base.mjs (3)

56-56: Consider a more robust timestamp parsing approach

Using Date.parse() directly can be problematic for certain date formats. Some APIs might return dates in formats that aren't properly parsed by Date.parse().

You might want to consider a more robust approach:

- const ts = Date.parse(item[tsField]);
+ const ts = new Date(item[tsField]).getTime();

Or using a date handling library like date-fns if dealing with complex date formats.


16-21: Missing validation in state management

The timestamp state management methods don't validate the timestamp values. Consider adding validation to ensure the timestamp is a valid number.

_getLastTs() {
-  return this.db.get("lastTs") || 0;
+  const lastTs = this.db.get("lastTs");
+  return typeof lastTs === "number" ? lastTs : 0;
},
_setLastTs(lastTs) {
+  if (typeof lastTs !== "number" || isNaN(lastTs)) {
+    throw new Error("Invalid timestamp value");
+  }
  this.db.set("lastTs", lastTs);
},

71-74: Potential improvement for handling large result sets

When limiting results with max, you truncate the array after collecting all results. For large datasets, this could lead to unnecessary memory usage.

Consider limiting results as they're collected:

- if (max && results.length > max) {
-   results.length = max;
- }

do {
  const items = await fn(args);
  for (const item of items) {
    const ts = Date.parse(item[tsField]);
    if (ts > lastTs) {
      results.push(item);
      maxTs = Math.max(ts, maxTs);
+     if (max && results.length >= max) {
+       break;
+     }
    }
  }
  total = items?.length;
  if (args.params) {
    args.params.page++;
  }
+  if (max && results.length >= max) {
+    break;
+  }
} while (paginate && total === args.params.size);
components/plainly/actions/create-render-job/create-render-job.mjs (4)

128-128: Fix typo in label

There's a typo in the label for the watermarkEncodingParamsLine property.

- label: "Watermark Encodeing Params Line",
+ label: "Watermark Encoding Params Line",

274-301: Make nested object handling consistent

Some nested objects like captions and watermark are conditionally set based on their required properties, but others like integration, projectFiles, and thumbnails are always included even if all their properties are undefined.

Consider making the handling consistent by conditionally setting all nested objects:

options: {
  captions: this.srtFileUrl
    ? {
      captionsPosition: this.captionsPosition,
      captionsStyle: this.captionsStyle,
      srtFileUrl: this.srtFileUrl,
    }
    : undefined,
-  integration: {
-    passthrough: this.passthrough,
-    skipAll: this.skipAll,
-  },
+  integration: (this.passthrough || this.skipAll)
+    ? {
+      passthrough: this.passthrough,
+      skipAll: this.skipAll,
+    }
+    : undefined,
-  projectFiles: {
-    uploadEnabled: this.uploadEnabled,
-  },
+  projectFiles: this.uploadEnabled
+    ? {
+      uploadEnabled: this.uploadEnabled,
+    }
+    : undefined,
-  thumbnails: {
-    atSeconds: this.thumbnailAtSeconds,
-    format: this.thumbnailFormat,
-    frequencySeconds: this.thumbnailFrequencySeconds,
-    fromEncodedVideo: this.thumbnailFromEncodedVideo,
-  },
+  thumbnails: (this.thumbnailAtSeconds || this.thumbnailFormat || 
+              this.thumbnailFrequencySeconds || this.thumbnailFromEncodedVideo)
+    ? {
+      atSeconds: this.thumbnailAtSeconds,
+      format: this.thumbnailFormat,
+      frequencySeconds: this.thumbnailFrequencySeconds,
+      fromEncodedVideo: this.thumbnailFromEncodedVideo,
+    }
+    : undefined,
  watermark: this.watermarkUrl
    ? {
      encodingParamsLine: this.watermarkEncodingParamsLine,
      url: this.watermarkUrl,
    }
    : undefined,
},

302-307: Consider conditionally setting outputFormat

Similar to the other nested objects, consider conditionally setting the outputFormat object only if at least one of its properties is defined.

- outputFormat: {
-   attachment: this.attachment,
-   attachmentFileName: this.attachmentFileName,
-   outputModule: this.outputModule,
-   settingsTemplate: this.settingsTemplate,
- },
+ outputFormat: (this.attachment || this.attachmentFileName || 
+               this.outputModule || this.settingsTemplate)
+   ? {
+     attachment: this.attachment,
+     attachmentFileName: this.attachmentFileName,
+     outputModule: this.outputModule,
+     settingsTemplate: this.settingsTemplate,
+   }
+   : undefined,

216-219: Add URL validation for webhook URL

The action accepts a webhook URL but doesn't validate it. Consider adding validation to ensure it's a valid HTTP/HTTPS URL.

Add a validation function to the run method:

async run({ $ }) {
  if ((this.captionsPosition || this.captionsStyle) && !this.srtFileUrl) {
    throw new ConfigurationError("SRT File URL is required if setting Captions Position or Style");
  }

  if (this.watermarkEncodingParamsLine && !this.watermarkUrl) {
    throw new ConfigurationError("Must specify Watermark URL if specifying Watermark Encoding Params Line");
  }

+  if (this.webhookUrl && !this.webhookUrl.match(/^https?:\/\/.+/)) {
+    throw new ConfigurationError("Webhook URL must be a valid HTTP/HTTPS URL");
+  }
+
+  if (this.srtFileUrl && !this.srtFileUrl.match(/^https?:\/\/.+/)) {
+    throw new ConfigurationError("SRT File URL must be a valid HTTP/HTTPS URL");
+  }
+
+  if (this.watermarkUrl && !this.watermarkUrl.match(/^https?:\/\/.+/)) {
+    throw new ConfigurationError("Watermark URL must be a valid HTTP/HTTPS URL");
+  }

  // Rest of the run method...
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 771e840 and 632c5ad.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components/plainly/actions/create-render-job/create-render-job.mjs (1 hunks)
  • components/plainly/actions/get-render-status/get-render-status.mjs (1 hunks)
  • components/plainly/actions/list-templates/list-templates.mjs (1 hunks)
  • components/plainly/common/utils.mjs (1 hunks)
  • components/plainly/package.json (2 hunks)
  • components/plainly/plainly.app.mjs (1 hunks)
  • components/plainly/sources/common/base.mjs (1 hunks)
  • components/plainly/sources/new-render-completed/new-render-completed.mjs (1 hunks)
  • components/plainly/sources/new-render-failed/new-render-failed.mjs (1 hunks)
  • components/plainly/sources/new-video-created/new-video-created.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (17)
components/plainly/package.json (2)

3-3: Version increment looks appropriate.

The version bump from 0.0.1 to 0.1.0 follows semantic versioning principles and appropriately reflects the addition of new features in this integration.


14-17: Dependencies look correct.

The addition of @pipedream/platform dependency is appropriate for a Pipedream integration component. The version constraint (^3.0.3) allows for compatible updates.

components/plainly/common/utils.mjs (1)

1-7: Helper function implementation looks good.

The optionalParseAsJSON function properly handles JSON parsing with a fallback to the original value if parsing fails, which is a robust approach.

components/plainly/sources/new-render-failed/new-render-failed.mjs (4)

3-11: Well-structured component definition.

The component metadata is clear and follows best practices for Pipedream integrations.


11-30: Props configuration looks good.

The props are properly configured with optional flags and dependencies between templateId and projectId.


31-48: Method implementations follow expected patterns.

The methods override the base source implementation as expected, with clear resource function, arguments, and timestamp field definitions.


48-54: Verify timestamp handling for different date formats.

The generateMeta method uses Date.parse() which can be inconsistent across browsers for some date formats. Consider using a more robust date parsing approach or ensuring the API returns dates in a consistent ISO format.

Can you confirm that the lastModified field from the Plainly API always returns a standard ISO format that will be consistently parsed by Date.parse()?

components/plainly/actions/get-render-status/get-render-status.mjs (2)

3-9: Component metadata looks good.

The action component has appropriate key, name, description, version, and type definitions.


9-17: Props configuration is appropriate.

The props definition is correct with the required renderId input.

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

1-157: Well-structured API implementation with comprehensive endpoints

The Plainly app implementation provides a complete set of API methods and dynamic property definitions, making it easy to interact with the Plainly platform. The authentication mechanism and request handling are properly implemented.

components/plainly/actions/list-templates/list-templates.mjs (1)

1-31: Well-implemented template listing action

The implementation correctly fetches templates from a specified project and returns them with a descriptive summary. The handling of singular/plural in the summary message is a nice touch.

components/plainly/sources/new-video-created/new-video-created.mjs (1)

1-51: Well-structured source component extending common base

The implementation correctly extends the common base source and customizes it for new video events. The component properly defines required properties and overrides necessary methods.

components/plainly/sources/new-render-completed/new-render-completed.mjs (1)

1-56: Well-structured source component for completed renders

The implementation correctly extends the common base source and customizes it for completed render events. The component properly defines optional properties with dependencies and overrides necessary methods.

components/plainly/sources/common/base.mjs (1)

4-98: Well-structured component with good separation of concerns

The base component is well-designed with clear separation of concerns, making it easy to extend for specific use cases. The approach of providing abstract methods (getResourceFn and generateMeta) that must be implemented by subclasses is a good design pattern.

components/plainly/actions/create-render-job/create-render-job.mjs (3)

259-265: Good validation for dependent fields

The validation checks ensure that required dependencies are properly configured, preventing potential errors when using the Plainly API.


317-318: Good user feedback with $summary

The action provides clear feedback to the user about the successful creation of the render job, which is a good practice.


1-320: Well-structured component with comprehensive configuration options

The action provides a comprehensive set of configuration options for creating render jobs with Plainly, with good organization of related properties and appropriate validation. The dynamic property visibility based on configuration flags is a nice touch for improving the user experience.

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 @michelle0927 lgtm! Ready for QA!

@michelle0927 michelle0927 merged commit d1bbe8b into master May 7, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-16527 branch May 7, 2025 14:49
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] plainly

3 participants