Skip to content

New Component - sharepoint #16489

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 3 commits into from
May 2, 2025
Merged

New Component - sharepoint #16489

merged 3 commits into from
May 2, 2025

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 30, 2025

Resolves #16465

Summary by CodeRabbit

  • New Features
    • Introduced a new action to download files from SharePoint sites and drives.
    • Added support for selecting drives and files within SharePoint, enabling enhanced file management capabilities.
  • Chores
    • Updated version numbers for several actions and sources.
    • Upgraded package and dependency versions for improved compatibility.

Copy link

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

Copy link
Contributor

coderabbitai bot commented Apr 30, 2025

Walkthrough

This update introduces a new "Download File" action for Microsoft SharePoint, enabling users to download files from a specified SharePoint site and drive to a local directory. Supporting this feature, the SharePoint app module is extended with new property definitions and methods for selecting drives and files, listing drives and drive items, searching drive items, and fetching file contents. Additionally, several existing action and source modules receive version number increments, and the package manifest is updated to reflect a new version and dependency update.

Changes

File(s) Change Summary
components/sharepoint/actions/create-item/create-item.mjs
components/sharepoint/actions/create-list/create-list.mjs
components/sharepoint/actions/update-item/update-item.mjs
components/sharepoint/sources/new-list-item/new-list-item.mjs
components/sharepoint/sources/updated-list-item/updated-list-item.mjs
Incremented version numbers in metadata only; no logic or functionality changes.
components/sharepoint/actions/download-file/download-file.mjs Added new "Download File" action for SharePoint, enabling file download to local /tmp directory.
components/sharepoint/sharepoint.app.mjs Added driveId and fileId property definitions and four new methods for listing drives, listing/searching drive items, and fetching file content.
components/sharepoint/package.json Updated package version to 0.3.0 and upgraded @pipedream/platform dependency version.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DownloadFileAction
    participant SharePointApp
    participant MicrosoftGraphAPI
    participant FileSystem

    User->>DownloadFileAction: Provide siteId, driveId, fileId, filename
    DownloadFileAction->>SharePointApp: getFile({siteId, fileId})
    SharePointApp->>MicrosoftGraphAPI: Request file content
    MicrosoftGraphAPI-->>SharePointApp: Return file content (array buffer)
    SharePointApp-->>DownloadFileAction: File content (array buffer)
    DownloadFileAction->>FileSystem: Write file to /tmp/filename
    DownloadFileAction-->>User: Return filename and path
Loading

Assessment against linked issues

Objective Addressed Explanation
Enable SharePoint as a knowledgebase by allowing file retrieval and download (#16465)
Add sources and actions for retrieving files from SharePoint (#16465)

Suggested labels

action

Poem

A SharePoint hop, a file to drop,
Now rabbits download without a stop!
Drives and files, all easy to find,
With version bumps and code aligned.
In /tmp they land, with a digital cheer—
Hoppy updates bring new features here! 🐇✨

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/sharepoint/sharepoint.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)


📜 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 6fcdc0d and c890c52.

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

🔭 Outside diff range comments (1)
components/sharepoint/actions/download-file/download-file.mjs (1)

1-62: 🛠️ Refactor suggestion

New component implementation looks solid, with some improvement opportunities.

The new SharePoint Download File action provides a useful capability to download files from SharePoint to the local /tmp directory.

Consider adding the following improvements:

  1. Add error handling for file operations and API calls:
  async run({ $ }) {
-    const response = await this.sharepoint.getFile({
-      $,
-      siteId: this.siteId,
-      fileId: this.fileId,
-      responseType: "arraybuffer",
-    });
+    try {
+      const response = await this.sharepoint.getFile({
+        $,
+        siteId: this.siteId,
+        fileId: this.fileId,
+        responseType: "arraybuffer",
+      });
+
+      const downloadedFilepath = `/tmp/${this.filename}`;
+      fs.writeFileSync(downloadedFilepath, response);
+
+      $.export("$summary", `Successfully downloaded file to ${downloadedFilepath}`);
+
+      return {
+        filename: this.filename,
+        downloadedFilepath,
+      };
+    } catch (error) {
+      $.export("$summary", `Failed to download file: ${error.message}`);
+      throw error;
+    }
  },
  1. Simplify the buffer handling - the arraybuffer from the API can be written directly without base64 conversion:
-    const rawcontent = response.toString("base64");
-    const buffer = Buffer.from(rawcontent, "base64");
-    const downloadedFilepath = `/tmp/${this.filename}`;
-    fs.writeFileSync(downloadedFilepath, buffer);
+    const downloadedFilepath = `/tmp/${this.filename}`;
+    fs.writeFileSync(downloadedFilepath, response);
  1. Add basic filename sanitization to prevent path traversal issues:
+    // Sanitize filename to prevent path traversal
+    const sanitizedFilename = this.filename.replace(/[/\\?%*:|"<>]/g, '-');
-    const downloadedFilepath = `/tmp/${this.filename}`;
+    const downloadedFilepath = `/tmp/${sanitizedFilename}`;
🧹 Nitpick comments (2)
components/sharepoint/sharepoint.app.mjs (1)

152-154: Typo in property description

The description for the fileId property contains a grammatical error: "You can either search for the file here, provide a custom File ID." This sentence is incomplete or incorrectly structured.

-  description: "The file to download. You can either search for the file here, provide a custom *File ID*.",
+  description: "The file to download. You can either search for the file here or provide a custom *File ID*.",
components/sharepoint/actions/download-file/download-file.mjs (1)

43-59: Add success summary message for better user feedback.

Consider adding a summary message to indicate successful download and file location.

  fs.writeFileSync(downloadedFilepath, buffer);

+  $.export("$summary", `Successfully downloaded file to ${downloadedFilepath}`);
+
  return {
    filename: this.filename,
    downloadedFilepath,
  };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 98e0ee8 and 6fcdc0d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • components/sharepoint/actions/create-item/create-item.mjs (1 hunks)
  • components/sharepoint/actions/create-list/create-list.mjs (1 hunks)
  • components/sharepoint/actions/download-file/download-file.mjs (1 hunks)
  • components/sharepoint/actions/update-item/update-item.mjs (1 hunks)
  • components/sharepoint/package.json (2 hunks)
  • components/sharepoint/sharepoint.app.mjs (2 hunks)
  • components/sharepoint/sources/new-list-item/new-list-item.mjs (1 hunks)
  • components/sharepoint/sources/updated-list-item/updated-list-item.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 (10)
components/sharepoint/sharepoint.app.mjs (3)

159-171: Efficiently structured file search and listing options

The implementation elegantly handles both searching and listing scenarios for files, with conditional logic that determines which API to call based on whether a query is provided.


120-180: Well-implemented property definitions with pagination support

Both the driveId and fileId property definitions are well-implemented with proper pagination support, consistent with the existing property definitions in the file.


232-263: Well-structured API methods following established patterns

The new methods for working with SharePoint drives and files follow the same consistent patterns as the existing methods, reusing the _makeRequest helper appropriately.

components/sharepoint/actions/create-list/create-list.mjs (1)

7-7: Version bump is appropriate

The version increment from "0.0.2" to "0.0.3" is appropriate as part of this larger update to the SharePoint components.

components/sharepoint/actions/update-item/update-item.mjs (1)

8-8: Version bump is appropriate

The version increment from "0.0.1" to "0.0.2" is appropriate as part of this larger update to the SharePoint components.

components/sharepoint/package.json (2)

3-3: Appropriate package version increment

The package version increment from 0.2.0 to 0.3.0 appropriately reflects the addition of new functionality (drive and file operations) to the SharePoint components.


16-16:

❓ Verification inconclusive

Significant platform dependency update

This update involves a major version change to the @pipedream/platform dependency (from ^1.5.1 to ^3.0.3). Ensure that this change is intentional and that all components remain compatible with the updated platform version.


🏁 Script executed:

#!/bin/bash
# Check if other SharePoint components use features from the new platform version

# Find import statements to see what's being used from the platform
rg -A 2 "import.*from.*@pipedream/platform" --type js --type mjs components/sharepoint/

Length of output: 117


🏁 Script executed:

#!/bin/bash
# Search for all import and require usages of @pipedream/platform in sharepoint components
rg -A2 "import .* from ['\"]@pipedream/platform['\"]" -g "*.[jt]s" -g "*.mjs" components/sharepoint/
rg -A2 "require\(['\"]@pipedream/platform['\"]\)" -g "*.[jt]s" -g "*.mjs" components/sharepoint/

Length of output: 637


Major @pipedream/platform version bump – verify API compatibility

You’ve upgraded @pipedream/platform from ^1.5.1 to ^3.0.3, which is a breaking change. We’ve confirmed that the SharePoint package imports platform APIs in two places:

  • components/sharepoint/sharepoint.app.mjs
    import { axios } from "@pipedream/platform";
  • components/sharepoint/sources/common/common.mjs
    import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";

Please ensure that both axios and DEFAULT_POLLING_SOURCE_TIMER_INTERVAL are still exported and behave as expected in v3.x. Update usages as needed and run your integration tests to catch any regressions.

components/sharepoint/sources/updated-list-item/updated-list-item.mjs (1)

8-8: Version increment looks good.

The version bump from "0.0.2" to "0.0.3" is consistent with the other SharePoint component updates in this PR. This coordinated version increment aligns with the addition of new SharePoint functionality for handling drives and files.

components/sharepoint/actions/create-item/create-item.mjs (1)

7-7: Version increment looks good.

The version bump from "0.0.2" to "0.0.3" is consistent with the other SharePoint component updates in this PR, maintaining version alignment across the component library.

components/sharepoint/sources/new-list-item/new-list-item.mjs (1)

8-8: Version increment looks good.

The version bump from "0.0.2" to "0.0.3" is consistent with the other SharePoint component updates in this PR, maintaining version alignment across related components.

Copy link
Collaborator

@GTFalcao GTFalcao 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 to me, just made one minor grammar suggestion!

Co-authored-by: Guilherme Falcão <48412907+GTFalcao@users.noreply.github.com>
@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit fd5f05f into master May 2, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-16465 branch May 2, 2025 16:04
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.

Sharepoint
2 participants