Skip to content

Microsoft Outlook - add pagination to props and actions #16255

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 15, 2025

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 10, 2025

Resolves #16233

Summary by CodeRabbit

  • New Features
    • Introduced pagination support with configurable result limits (maxResults) for retrieving contacts, emails, and folders, enhancing efficiency.
  • Documentation
    • Updated text for clearer references to the official documentation.
  • Chores
    • Incremented version numbers across various modules and updated the package version for overall consistency.

Copy link

vercel bot commented Apr 10, 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 14, 2025 3:08pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 14, 2025 3:08pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 14, 2025 3:08pm

Copy link
Contributor

coderabbitai bot commented Apr 10, 2025

Walkthrough

This pull request updates multiple Microsoft Outlook actions and source modules by incrementing version numbers across the board. Several files receive minor documentation improvements, and a few actions now introduce or update the maxResults property along with pagination logic in their asynchronous run methods. Additionally, the main app file now includes a new constant (DEFAULT_LIMIT), updated options methods to support pagination, and a new paginate helper method.

Changes

Files Change Summary
components/microsoft_outlook/actions/(add-label-to-email, approve-workflow, list-labels, move-email-to-folder, remove-label-from-email, reply-to-email, send-email, update-contact).mjs,
components/microsoft_outlook/sources/(new-contact, new-email).mjs,
components/microsoft_outlook/package.json
Version bump updates only; no functional changes.
components/microsoft_outlook/actions/(create-contact, create-draft-email).mjs Version bump with description text updates (changing “docs” to “documentation”).
components/microsoft_outlook/actions/(find-contacts, find-email, list-contacts, list-folders).mjs Version increment; added/updated maxResults property and revised run methods to incorporate asynchronous pagination.
components/microsoft_outlook/microsoft_outlook.app.mjs Introduced DEFAULT_LIMIT constant; added a new maxResults property; updated options methods to accept a page parameter; and added a new paginate helper for standardized pagination.

Sequence Diagram(s)

sequenceDiagram
    participant Action as Action Module
    participant App as microsoft_outlook.app
    participant API as Microsoft Outlook API
    Action->>App: Invoke run method (e.g., find-email)
    App->>App: Call paginate({fn, args, maxResults})
    loop Pagination Loop
        App->>API: Request batch (listMessages, listContacts, etc.)
        API-->>App: Return batch of items
        App-->>Action: Yield each item from batch
    end
    Action->>Action: Process retrieved items until maxResults reached
Loading

Assessment against linked issues

Objective Addressed Explanation
[ACTION] Paginate MS Outlook actions to return all results (#16233)

Suggested labels

ai-assisted

Suggested reviewers

  • GTFalcao

Poem

I'm a little rabbit with a digital hop,
Skipping through code, I just can't stop.
Versions bump and paginate with grace,
Nibbling on changes at a swift, happy pace.
CodeRabbit cheers as we race through bytes—hooray!
🐇✨

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/microsoft_outlook/actions/find-contacts/find-contacts.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)

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 1

🔭 Outside diff range comments (1)
components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs (1)

34-36: ⚠️ Potential issue

Handle Potential Undefined Categories Array
The code retrieves message?.categories and then immediately calls indexOf on it. If message.categories is undefined, this will result in a runtime error. Consider defaulting to an empty array to avoid this issue. For example:

-    let labels = message?.categories;
+    let labels = message?.categories || [];

This change will ensure that subsequent operations on labels are safe even when no categories are present.

🧹 Nitpick comments (1)
components/microsoft_outlook/sources/new-email/new-email.mjs (1)

29-31: Consider Making Page Size Configurable
The sample events are fetched with a hard-coded page size of 25. In light of the pagination enhancements, consider exposing the page size as a configurable property, which would empower users to control the number of items per page.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef0e890 and 4a85e4f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs (1 hunks)
  • components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs (1 hunks)
  • components/microsoft_outlook/actions/create-contact/create-contact.mjs (1 hunks)
  • components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs (1 hunks)
  • components/microsoft_outlook/actions/find-contacts/find-contacts.mjs (1 hunks)
  • components/microsoft_outlook/actions/find-email/find-email.mjs (2 hunks)
  • components/microsoft_outlook/actions/list-contacts/list-contacts.mjs (1 hunks)
  • components/microsoft_outlook/actions/list-folders/list-folders.mjs (1 hunks)
  • components/microsoft_outlook/actions/list-labels/list-labels.mjs (1 hunks)
  • components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs (1 hunks)
  • components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs (1 hunks)
  • components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs (1 hunks)
  • components/microsoft_outlook/actions/send-email/send-email.mjs (1 hunks)
  • components/microsoft_outlook/actions/update-contact/update-contact.mjs (1 hunks)
  • components/microsoft_outlook/microsoft_outlook.app.mjs (7 hunks)
  • components/microsoft_outlook/package.json (1 hunks)
  • components/microsoft_outlook/sources/new-contact/new-contact.mjs (1 hunks)
  • components/microsoft_outlook/sources/new-email/new-email.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (41)
components/microsoft_outlook/sources/new-email/new-email.mjs (1)

10-10: Version Bump Updated
The version has been updated from "0.0.15" to "0.0.16" to reflect the new changes. This is consistent with our versioning strategy across the Outlook components.

components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs (1)

7-7: Version Bump Updated for Move Email to Folder Action
The version has been incremented from "0.0.2" to "0.0.3". There are no functional changes here, and the update is consistent with similar version bumps in related modules.

components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs (1)

7-7: Version Bump Updated for Remove Label from Email Action
The version has been updated from "0.0.4" to "0.0.5", keeping it in line with our consistent versioning approach across the Microsoft Outlook actions.

components/microsoft_outlook/actions/list-labels/list-labels.mjs (1)

7-7: Version Bump Updated for List Labels Action
The version has been updated from "0.0.4" to "0.0.5". The changes are limited to the version update with no impact on functionality.

components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs (1)

7-7: Version Bump Updated for Reply to Email Action
The module’s version has been incremented from "0.0.1" to "0.0.2". There are no other functional changes in this file.

components/microsoft_outlook/package.json (1)

3-3: Version Update in package.json

The version number has been correctly updated from "1.4.0" to "1.4.1", which is consistent with the coordinated version bump across the Microsoft Outlook integration components.

components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs (1)

8-8: Version Bump for Add Label to Email Action

The version has been updated from "0.0.4" to "0.0.5" with no changes to the underlying functionality. This version bump maintains consistency with similar updates across the integration.

components/microsoft_outlook/actions/send-email/send-email.mjs (1)

6-6: Version Update for Send Email Action

The action’s version is now "0.0.13", which aligns with the overall versioning strategy. No functional changes were made in this update.

components/microsoft_outlook/sources/new-contact/new-contact.mjs (1)

8-8: Version Bump for New Contact Source

The exported module’s version has been updated from "0.0.12" to "0.0.13". This is a straightforward version increment; please ensure that any pagination functionality introduced elsewhere (e.g., in the app file) remains consistent with these updates.

components/microsoft_outlook/actions/update-contact/update-contact.mjs (1)

6-6: Update Contact Action Version Increment

The version has been bumped from "0.0.11" to "0.0.12". The changes here are limited to versioning, with no modifications to business logic or the action’s properties.

components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs (1)

7-7: Version increment looks good.

The version bump from "0.0.2" to "0.0.3" is consistent with the versioning strategy across other files in this PR.

components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs (2)

6-6: Version increment looks good.

The version bump from "0.0.11" to "0.0.12" is appropriate and maintains consistency with other files in the PR.


8-8: Documentation improvement is good.

Changing "docs" to "documentation" improves clarity and readability of the action description.

components/microsoft_outlook/actions/create-contact/create-contact.mjs (2)

6-6: Version increment looks good.

The version bump from "0.0.11" to "0.0.12" aligns with the consistent versioning strategy across components.


8-8: Documentation improvement is good.

Changing "docs" to "documentation" improves clarity and readability in the action description.

components/microsoft_outlook/actions/list-folders/list-folders.mjs (5)

7-7: Version increment looks good.

The version bump from "0.0.2" to "0.0.3" is appropriate for the pagination functionality being added.


11-16: New maxResults property looks good.

Adding the maxResults property allows users to control the number of results returned, which is essential for pagination functionality.


27-30: Results collection looks good.

Correctly collects all paginated results using a for-await loop for async iteration through the paginated items.


32-35: Summary and return statement updates look good.

The summary message and return statement have been appropriately updated to reflect the new pagination implementation.


19-25:

✅ Verification successful

Pagination implementation looks good.

The implementation now uses a paginate helper method instead of directly calling listFolders, which is a good abstraction for handling pagination logic across multiple actions.


🏁 Script executed:

#!/bin/bash
# Check the implementation of the paginate method in the app file
cat components/microsoft_outlook/microsoft_outlook.app.mjs | grep -A 25 "paginate("

Length of output: 668


Pagination implementation verified and approved.

The paginate helper method in components/microsoft_outlook/microsoft_outlook.app.mjs correctly handles the pagination logic by merging the necessary parameters, iterating through results, and updating the query with calculated skip values. This abstraction effectively replaces direct calls to listFolders and improves code maintainability across actions.

components/microsoft_outlook/actions/find-contacts/find-contacts.mjs (5)

6-8: Version increment and documentation improvements look good.

The version update from 0.0.11 to 0.0.12 and added documentation link improve the component.


16-21: Good addition of the maxResults property.

Adding the maxResults property allows users to limit the number of results returned, which is particularly useful with the new pagination implementation.


24-29: Improved implementation with pagination.

The change from direct API call to using the paginate helper method is a significant improvement for handling larger datasets.


31-46: Filtering logic with maxResults limiting works correctly.

The implementation correctly filters contacts based on search criteria and respects the maxResults limit. The approach of filtering after fetching contacts is appropriate since the Microsoft Graph API doesn't support complex filtering on these fields.


49-49: Summary message update is appropriate.

The updated summary message correctly reflects that matching contacts were found rather than filtered.

components/microsoft_outlook/actions/list-contacts/list-contacts.mjs (5)

6-8: Version increment and documentation improvements look good.

The version update from 0.0.11 to 0.0.12 and improved documentation link are good changes.


12-12: Fixed typo in property label.

Correcting "Email adress" to "Email Address" improves the UI accuracy.


17-22: Good addition of the maxResults property.

Adding the maxResults property ensures consistency with other actions and provides control over result volume.


25-32: Improved implementation with pagination.

The change from direct API call to using the paginate helper method with max parameter is a good improvement for handling large datasets.


34-41: Collection and return of results is well-implemented.

The approach of collecting paginated results into an array and providing an appropriate summary message is clean and effective.

components/microsoft_outlook/microsoft_outlook.app.mjs (7)

6-6: Good addition of DEFAULT_LIMIT constant.

Adding a constant for the default limit promotes code consistency and makes future changes easier.


66-78: Contact options method updated for pagination.

The options method now properly handles pagination using the DEFAULT_LIMIT constant.


136-151: Message options method updated for pagination.

The implementation for paginating message options is consistent with the contact options approach.


157-171: Folder options method updated for pagination.

The implementation for paginating folder options is consistent with the other options methods.


173-179: Well-defined maxResults property.

The maxResults property is defined with appropriate defaults and description, making it reusable across components.


327-332: Simplified parameter handling in listContacts.

The method now directly modifies args.params rather than using a separate paramsContainer, which is more consistent with other methods.


406-430: Well-implemented paginate generator method.

The paginate method is a well-designed generator function that handles iteration through paginated results efficiently. It correctly:

  1. Uses DEFAULT_LIMIT for consistency
  2. Manages skip/top parameters for pagination
  3. Respects the max parameter to limit results
  4. Terminates when no more results are available
components/microsoft_outlook/actions/find-email/find-email.mjs (4)

7-7: Version increment looks good.

The version update from 0.0.2 to 0.0.3 reflects the functional changes appropriately.


18-21: Good update to use shared maxResults property definition.

Updating the maxResults property to use the propDefinition from microsoftOutlook ensures consistency across components.


25-34: Improved implementation with pagination.

The change from direct API call to using the paginate helper method is a good improvement for handling large datasets.


36-44: Collection and return of results is well-implemented.

The approach of collecting paginated results into an array and providing an appropriate summary message is clean and effective.

luancazarine
luancazarine previously approved these changes Apr 11, 2025
Copy link
Collaborator

@luancazarine luancazarine 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!

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

🧹 Nitpick comments (1)
components/microsoft_outlook/actions/find-contacts/find-contacts.mjs (1)

23-50: Consider adding error handling

While the implementation is functionally correct, consider adding try/catch blocks around the pagination logic to handle potential errors gracefully.

  async run({ $ }) {
+   try {
      const contacts = this.microsoftOutlook.paginate({
        fn: this.microsoftOutlook.listContacts,
        args: {
          $,
        },
      });

      const relatedContacts = [];
      for await (const contact of contacts) {
        if (
          contact?.displayName?.includes(this.searchString) ||
          contact?.givenName?.includes(this.searchString) ||
          contact?.surname?.includes(this.searchString) ||
          contact?.emailAddresses?.find(
            (e) => e?.address == this.searchString || e?.name?.includes(this.searchString),
          )
        ) {
          relatedContacts.push(contact);
          if (this.maxResults && relatedContacts.length >= this.maxResults) {
            break;
          }
        }
      }

      // eslint-disable-next-line multiline-ternary
      $.export("$summary", `${relatedContacts.length} matching contact${relatedContacts.length != 1 ? "s" : ""} found`);
      return relatedContacts;
+   } catch (error) {
+     $.export("$summary", "Failed to find contacts");
+     throw error;
+   }
  },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b1249e and 413b20b.

📒 Files selected for processing (1)
  • components/microsoft_outlook/actions/find-contacts/find-contacts.mjs (1 hunks)
⏰ 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 (5)
components/microsoft_outlook/actions/find-contacts/find-contacts.mjs (5)

6-6: Documentation and versioning updates look good

Appropriate version bump and improved description with documentation link provides better reference for developers.

Also applies to: 8-8


16-21: Good addition of maxResults property

The new maxResults property allows users to limit the number of results returned, which is an important feature for pagination. The implementation correctly uses the propDefinition from the parent app.


24-29: Pagination implementation looks good

The change from direct API call to using the pagination helper method is a significant improvement for handling large result sets. This approach is more memory-efficient and aligned with the PR's pagination objectives.


31-46: Efficient contact filtering with early termination

The implementation correctly:

  1. Processes contacts as they're returned from the paginator
  2. Applies the same filtering criteria as before
  3. Breaks the loop when reaching the maxResults limit

This improves performance by avoiding unnecessary processing when the desired number of results is reached.


49-49: Improved summary message

The updated summary message more accurately describes the action result by indicating that matching contacts were found rather than filtered.

@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit cd04a13 into master Apr 15, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-16233 branch April 15, 2025 14:47
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.

[ACTION] Make sure MS Outlook actions are paginating / returning all results
2 participants