Skip to content

New Components - mailosaur #16666

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 8 commits into from
May 20, 2025
Merged

New Components - mailosaur #16666

merged 8 commits into from
May 20, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented May 14, 2025

Resolves #16655.

Summary by CodeRabbit

  • New Features

    • Introduced actions to create and send emails, delete emails, and search for emails using Mailosaur.
    • Added sources to emit events for new messages and for messages matching specific criteria in a Mailosaur inbox.
    • Enhanced Mailosaur integration with dynamic property selection, filtering options, and paginated data retrieval.
  • Chores

    • Updated package version and added a dependency on @pipedream/platform.

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

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

Copy link
Contributor

coderabbitai bot commented May 14, 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 comprehensive Mailosaur integration, adding new polling sources for incoming emails, actions to create, search, and delete emails, and supporting utilities. The Mailosaur app component is refactored to include structured API methods, dynamic property loading, and pagination. Test event fixtures and common constants are also provided.

Changes

File(s) Change Summary
components/mailosaur/actions/create-email/create-email.mjs New action: Create and send email via Mailosaur with validation for required fields and API interaction.
components/mailosaur/actions/delete-email/delete-email.mjs New action: Delete an email from Mailosaur by email ID.
components/mailosaur/actions/search-email/search-email.mjs New action: Search for emails in Mailosaur with multiple filter options.
components/mailosaur/common/constants.mjs New module: Exports LIMIT and MATCH_OPTIONS constants for use in filtering and pagination.
components/mailosaur/mailosaur.app.mjs Major refactor: Adds API methods, authentication, pagination, and dynamic property definitions for Mailosaur integration.
components/mailosaur/package.json Version bump to 0.1.0 and adds dependency on @pipedream/platform.
components/mailosaur/sources/common/base.mjs New base source: Implements polling, state management, and event emission for Mailosaur sources.
components/mailosaur/sources/new-email-matching-criteria/new-email-matching-criteria.mjs New source: Emits events for emails matching specific criteria.
components/mailosaur/sources/new-email-matching-criteria/test-event.mjs New test event: Provides a sample email event for matching criteria source.
components/mailosaur/sources/new-message/new-message.mjs New source: Emits events for new messages received in a Mailosaur inbox.
components/mailosaur/sources/new-message/test-event.mjs New test event: Provides a sample email message for the new-message source.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CreateEmailAction
    participant MailosaurApp
    participant MailosaurAPI

    User->>CreateEmailAction: Trigger create-email
    CreateEmailAction->>MailosaurApp: sendEmail({ serverId, to, ... })
    MailosaurApp->>MailosaurAPI: POST /messages
    MailosaurAPI-->>MailosaurApp: Email creation response
    MailosaurApp-->>CreateEmailAction: Response
    CreateEmailAction-->>User: Summary and result
Loading
sequenceDiagram
    participant Source
    participant MailosaurApp
    participant MailosaurAPI
    participant EventStream

    Source->>MailosaurApp: listMessages/searchMessages({ serverId, ... })
    MailosaurApp->>MailosaurAPI: GET /messages or /messages/search
    MailosaurAPI-->>MailosaurApp: List of messages
    MailosaurApp-->>Source: Messages
    Source->>EventStream: Emit new events for each message
Loading

Assessment against linked issues

Objective Addressed Explanation
Add polling source: new-message (emit on new message in specified inbox) (#16655)
Add polling source: new-email-matching-criteria (emit on email matching sentFrom, sentTo, subject, body) (#16655)
Add action: create-email (send email, required: server ID, to, subject; optional: from, html, text, send, attachments) (#16655) Attachments property is not implemented in the create-email action.
Add action: search-email (search by server ID, receiveAfter, page, itemsPerPage, dir) (#16655)
Add action: delete-email (delete email by email ID) (#16655)

Poem

(
(
(
((\
( -.-) "Mailosaur hops in, with emails to send,
o_(")(") New messages, searches, and deletes to the end!
With code so neat and sources that poll,
This bunny delivers emails—on a roll!"
"""


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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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 Message
 - New Message Macthing Criteira

Actions
 - Create Email
 - Search Message
 - Delete Message
@luancazarine luancazarine marked this pull request as ready for review May 15, 2025 20:20
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: 3

🧹 Nitpick comments (9)
components/mailosaur/sources/new-message/test-event.mjs (1)

1-16: Well-structured test event for new message detection.

This test event provides appropriate mock data for the new message source. Note that this test fixture is identical to the one in new-email-matching-criteria/test-event.mjs.

Consider creating a shared test fixture that both source components could import if they'll always use identical test data. This would reduce duplication and make future updates more maintainable.

components/mailosaur/actions/create-email/create-email.mjs (3)

24-28: Fix spacing in the email example

There's an extra space in the email example that should be removed.

-      description: "Optionally overrides of the message's `from` address. This **must** be an address ending with `YOUR_SERVER.mailosaur.net`, such as `my-emails @a1bcdef2.mailosaur.net`.",
+      description: "Optionally overrides of the message's `from` address. This **must** be an address ending with `YOUR_SERVER.mailosaur.net`, such as `[email protected]`.",

34-45: Consider enhancing documentation for HTML and text objects

The props for HTML and text are defined as objects with limited description of their expected structure. Consider providing more details or examples to help users understand the expected format.


53-55: Simplify validation logic

The validation logic can be simplified slightly.

-    if ((!!this.send) && (!this.html && !this.text)) {
+    if (this.send && !this.html && !this.text) {
      throw new ConfigurationError("Please provide either HTML or plain text content.");
    }
components/mailosaur/mailosaur.app.mjs (3)

23-27: Label/description typo for emailId property

Both the label and description still read “Server ID”, which is misleading for an e-mail selector and will confuse users in the UI.

-  label: "Server ID",
-  description: "The identifier of the server from which the email should be sent.",
+  label: "Email ID",
+  description: "The identifier of the email to operate on.",

53-61: Risk of leaking component context via default $ parameter

_makeRequest({ $ = this, … }) passes the whole component instance by default to axios, which may inadvertently expose internal props (e.g. secrets) to request/response interceptors. Instead, forward only the $ that Pipedream explicitly injects (this).

-_makeRequest({ $ = this, path, ...opts }) {
-  return axios($, {
+_makeRequest({ $, path, ...opts }) {
+  // default to the app instance when a `$` context
+  // isn’t supplied by the caller
+  const context = $ || this;
+  return axios(context, {

44-46: Consider extracting base URL & limit to constants

Hard-coding "https://mailosaur.com/api" here makes future upgrades painful (e.g., v2 endpoint or regional hosts). You already import LIMIT from ./common/constants.mjs; doing the same for the base URL will improve maintainability.

components/mailosaur/sources/common/base.mjs (2)

50-54: _setLastDate assumes API is sorted newest-first

If the API ever returns results oldest-first, responseArray[0] will point to the oldest message, causing duplicates on the next run. Safer to compute Math.max(...receivedTimestamps) or rely on the first element after sorting.


65-73: Missing abstract getFunction / getSummary contracts

emitEvent calls this.getFunction() and this.getSummary(item) but the base class does not enforce or document these. AddingrequiredMethods checks or JSDoc will prevent accidental runtime errors in extending sources.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 02b76b8 and 7ddb44c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • components/mailosaur/actions/create-email/create-email.mjs (1 hunks)
  • components/mailosaur/actions/delete-email/delete-email.mjs (1 hunks)
  • components/mailosaur/actions/search-email/search-email.mjs (1 hunks)
  • components/mailosaur/common/constants.mjs (1 hunks)
  • components/mailosaur/mailosaur.app.mjs (1 hunks)
  • components/mailosaur/package.json (2 hunks)
  • components/mailosaur/sources/common/base.mjs (1 hunks)
  • components/mailosaur/sources/new-email-matching-criteria/new-email-matching-criteria.mjs (1 hunks)
  • components/mailosaur/sources/new-email-matching-criteria/test-event.mjs (1 hunks)
  • components/mailosaur/sources/new-message/new-message.mjs (1 hunks)
  • components/mailosaur/sources/new-message/test-event.mjs (1 hunks)
🔇 Additional comments (10)
components/mailosaur/package.json (1)

3-3: Package version and dependencies correctly updated.

The version bump to 0.1.0 is appropriate for the introduction of new Mailosaur integration components. The added dependency on @pipedream/platform is standard for Pipedream components and properly uses semantic versioning.

Also applies to: 14-16

components/mailosaur/sources/new-email-matching-criteria/test-event.mjs (1)

1-16: Well-structured test event for email matching criteria.

This test event provides a comprehensive mock email object with all the expected fields (id, timestamp, subject, sender/recipient details) that would be needed to test matching criteria functionality. The structure follows Mailosaur's API response format.

components/mailosaur/common/constants.mjs (1)

1-12: Well-organized constants module.

Centralizing the limit value and match options in a common constants file is a good practice. The match options are properly structured with descriptive labels and values for dropdown selection, and the 1000 item limit is a reasonable default for pagination.

components/mailosaur/actions/delete-email/delete-email.mjs (1)

1-37: Well-structured delete email action with appropriate props and error handling.

This action properly imports the Mailosaur app, defines the necessary properties with correct dependencies (emailId depends on serverId), and includes appropriate error handling through the Pipedream context. The success message is clear, and returning the deleted emailId allows for chaining with other actions if needed.

components/mailosaur/sources/new-message/new-message.mjs (1)

1-22: Implementation looks clean and well-structured!

This source component is well implemented with clear naming, proper documentation links, and good separation of concerns. The extension of a common base component promotes code reuse, and the methods are concise and focused.

components/mailosaur/actions/create-email/create-email.mjs (1)

52-73: Implementation looks good!

The validation, error handling, and API interaction are well implemented. The export summary provides clear feedback to the user.

components/mailosaur/actions/search-email/search-email.mjs (1)

1-101: Component is well-structured with comprehensive search parameters

The search email action provides a comprehensive set of search parameters with clear descriptions and appropriate separation between query parameters and body data in the API call. The export summary is informative.

components/mailosaur/sources/new-email-matching-criteria/new-email-matching-criteria.mjs (2)

1-66: Component effectively extends base functionality with filtering criteria

This component nicely extends the common base module with additional filtering capabilities. The implementation is clean and follows consistent patterns with the other Mailosaur components.


15-26:

✅ Verification successful

Check description references to phone numbers

The property descriptions reference "phone number" which seems unusual for an email service. Verify if Mailosaur supports both email and SMS messaging, and adjust the descriptions if necessary.


🌐 Web query:

Does Mailosaur support SMS or phone number messaging in addition to email?

💡 Result:

Yes, Mailosaur fully supports SMS messaging alongside email testing. Mailosaur's platform allows you to test and automate SMS communications with features similar to their email testing capabilities.

SMS Testing Capabilities

Mailosaur provides dedicated test phone numbers that you can use for SMS testing. These numbers are assigned to your servers, allowing you to send SMS messages to them and then retrieve and analyze those messages using the Mailosaur API[3][4]. This enables end-to-end testing of SMS functionality in your applications.

Key SMS Features:

  • Dedicated phone numbers for testing that are assigned to your account[9]
  • Support for international mobile numbers[4]
  • Ability to verify SMS delivery timing[4]
  • Testing of identity/account verification codes and one-time passwords (OTPs)[4]
  • Validation of promotional text messages[4]
  • Automated SMS testing with various frameworks like Cypress, Playwright, Selenium, and Robot Framework[3][6]
  • Reply functionality to simulate user responses to SMS messages[5]

How SMS Testing Works

The process for testing SMS messages with Mailosaur is straightforward:

  1. Request and assign a phone number to one of your Mailosaur servers
  2. Send SMS messages to that number as you normally would
  3. Use the Mailosaur API to retrieve and test the content of those messages[3]

The code for retrieving and testing SMS messages is very similar to the approach used for email testing, making it easy to implement if you're already using Mailosaur for email tests[6][7].

Phone Number Availability

Mailosaur offers phone numbers in various countries:

  • US, UK, and Canadian numbers are included in standard pricing
  • Numbers for other countries (such as France, Germany, and Australia) are available with additional charges
  • The Business plan includes 1 number, while the Professional plan includes 5 numbers as standard
  • Additional numbers can be added starting from $1 per number per month[9]

This combined approach of handling both email and SMS testing through a single platform is considered one of Mailosaur's key advantages according to user reviews[10].

Citations:


No changes needed for phone number references

Mailosaur supports both email and SMS testing, so keeping “email address or phone number” in these field descriptions is correct.

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

45-47: Date comparison may skip newer items on equal timestamps

break triggers when received <= lastDate, so if two messages share the same received value the second one is never emitted. Consider continue for equality or store millisecond precision to guarantee monotonicity.

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.

Looks good, just a couple minor things.

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

♻️ Duplicate comments (1)
components/mailosaur/actions/search-email/search-email.mjs (1)

68-74: Match options implementation looks correct.

The use of imported MATCH_OPTIONS for the options property is appropriate. This addresses the previous review comment asking if it should be "options: constants.MATCH_OPTIONS".

🧹 Nitpick comments (2)
components/mailosaur/actions/search-email/search-email.mjs (2)

95-97: Consider enhancing the summary message with more details.

The summary message only includes the count of emails retrieved. Consider enhancing it to include some details about the search criteria when filters are applied.

-    $.export("$summary", `Successfully retrieved ${response.items.length} email(s) from server.`);
+    const filters = [
+      this.sentFrom && `from: ${this.sentFrom}`,
+      this.sentTo && `to: ${this.sentTo}`,
+      this.subject && `subject: "${this.subject}"`,
+    ].filter(Boolean).join(", ");
+    
+    $.export("$summary", `Successfully retrieved ${response.items.length} email(s)${filters ? ` matching ${filters}` : ""} from server.`);

76-97: Consider adding basic error handling.

While the framework likely provides some error handling, consider adding specific error handling for common API failures to provide more helpful error messages to users.

   async run({ $ }) {
-    const response = await this.mailosaur.searchMessages({
-      $,
-      params: {
-        server: this.serverId,
-        receiveAfter: this.receiveAfter,
-        page: this.page,
-        itemsPerPage: this.itemsPerPage,
-        dir: this.dir,
-      },
-      data: {
-        sentFrom: this.sentFrom,
-        sentTo: this.sentTo,
-        subject: this.subject,
-        body: this.body,
-        match: this.match,
-      },
-    });
+    try {
+      const response = await this.mailosaur.searchMessages({
+        $,
+        params: {
+          server: this.serverId,
+          receiveAfter: this.receiveAfter,
+          page: this.page,
+          itemsPerPage: this.itemsPerPage,
+          dir: this.dir,
+        },
+        data: {
+          sentFrom: this.sentFrom,
+          sentTo: this.sentTo,
+          subject: this.subject,
+          body: this.body,
+          match: this.match,
+        },
+      });
+      
+      $.export("$summary", `Successfully retrieved ${response.items.length} email(s) from server.`);
+      return response;
+    } catch (error) {
+      throw new Error(`Failed to search emails: ${error.message}`);
+    }
-
-    $.export("$summary", `Successfully retrieved ${response.items.length} email(s) from server.`);
-    return response;
   },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between e5df4c0 and 9cd2cb1.

📒 Files selected for processing (2)
  • components/mailosaur/actions/search-email/search-email.mjs (1 hunks)
  • components/mailosaur/sources/common/base.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/mailosaur/sources/common/base.mjs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (4)
components/mailosaur/actions/search-email/search-email.mjs (4)

1-3: Imports look well-structured.

The imports are clean and appropriate, bringing in just what's needed from the constants file and the main Mailosaur app.


4-9: Component metadata is clear and well-documented.

The component definition includes a descriptive name, appropriate description with documentation link, and follows Pipedream's component structure guidelines.


10-75: Props are well-defined with clear descriptions.

All properties have appropriate types, labels, and helpful descriptions. The optional flags are properly set for non-required fields, and the pagination parameters are well documented.


76-94: API call is well-structured.

The implementation correctly separates parameters between query params and request body data, which is good practice for REST API calls. The parameters are properly passed from the component props.

michelle0927
michelle0927 previously approved these changes May 16, 2025
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
Copy link
Collaborator Author

/approve

@luancazarine luancazarine merged commit 7ac38a8 into master May 20, 2025
11 checks passed
@luancazarine luancazarine deleted the issue-16655 branch May 20, 2025 17:53
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] mailosaur
2 participants