-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Sharepoint - new components #18845
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
Sharepoint - new components #18845
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughAdds multiple SharePoint features: seven new action modules (folder/file/upload/share/search/excel), two new event sources (new file/folder created), shared constants, enhancements to the SharePoint app (new prop definitions and API helper methods), common source tweaks, and several version bumps. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Action as Action Module
participant SharePoint as SharePoint App
participant API as Microsoft Graph API
User->>Action: Invoke action (e.g., Create Folder / Upload / Create Link)
Action->>Action: Read props (siteId, driveId, folderId, fileId, etc.)
alt Action targets folder
Action->>SharePoint: createDriveItemInFolder(siteId, folderId, payload)
else Action targets drive root or file
Action->>SharePoint: createDriveItem / uploadFile / createLink / getExcelTable(...)
end
SharePoint->>API: HTTP request (Graph API)
API-->>SharePoint: Response (includes item id/data)
SharePoint-->>Action: Return response
Action->>Action: Export $summary if id present
Action-->>User: Return response
sequenceDiagram
participant Poller as Source (Poll)
participant SharePoint as SharePoint App
participant API as Microsoft Graph API
participant Pipeline as Event Pipeline
loop Polling
Poller->>SharePoint: getResourceFn() -> listDriveItems...({ params: orderby lastModifiedDateTime desc })
SharePoint->>API: GET items
API-->>SharePoint: Items (sorted)
SharePoint-->>Poller: Items
Poller->>Poller: Filter by isRelevant(item)
Poller->>Poller: Keep items with ts > lastTs, max 10
loop For each item
Poller->>Poller: generateMeta(item)
Poller->>Pipeline: Emit event (id, summary, ts)
end
Poller->>Poller: Update lastTs
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Multiple new modules follow consistent patterns but require per-file verification (props wiring, API helper correctness, header handling) and testing of new app helper methods and sources. Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 11
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
components/sharepoint/sharepoint.app.mjs (2)
409-416: Encode search query to avoid breaking path and potential injection issuesInterpolate with
encodeURIComponent.- path: `/sites/${siteId}/drive/root/search(q='${query}')`, + path: `/sites/${siteId}/drive/root/search(q='${encodeURIComponent(query)}')`,
97-104: Guard: require bothsiteIdandlistIdwhen listing itemsPrevents requests like
/lists/undefined/items.- if (!siteId) { + if (!siteId || !listId) { return []; }
🧹 Nitpick comments (9)
components/sharepoint/sharepoint.app.mjs (3)
383-385: EncodetableNamein pathTable names can contain spaces or special chars.
- path: `/sites/${siteId}/drive/items/${itemId}/workbook/tables/${tableName}/range`, + path: `/sites/${siteId}/drive/items/${itemId}/workbook/tables/${encodeURIComponent(tableName)}/range`,
391-394: PreferencodeURIComponentfor file namesSafer for special characters.
- ? `/sites/${siteId}/drives/${driveId}/items/${uploadFolderId}:/${encodeURI(name)}:/content` - : `/sites/${siteId}/drives/${driveId}/root:/${encodeURI(name)}:/content`, + ? `/sites/${siteId}/drives/${driveId}/items/${uploadFolderId}:/${encodeURIComponent(name)}:/content` + : `/sites/${siteId}/drives/${driveId}/root:/${encodeURIComponent(name)}:/content`,
255-260: Align description and behavior: set explicit default forexcludeFoldersDescription says default is false; make it explicit.
excludeFolders: { type: "boolean", label: "Exclude Folders?", description: "Set to `true` to return only files in the response. Defaults to `false`", optional: true, + default: false, },components/sharepoint/actions/create-item/create-item.mjs (1)
64-70: Pass$to app method for consistent logging/error contextKeeps Axios scoped to the step context, matching other actions.
- const response = await this.sharepoint.createItem({ - siteId: this.siteId, - listId: this.listId, - data: { - fields, - }, - }); + const response = await this.sharepoint.createItem({ + $, + siteId: this.siteId, + listId: this.listId, + data: { fields }, + });components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs (1)
48-66: Optional: add pagination supportCurrent implementation returns only the first page. Consider using
sharepoint.paginateto stream all items or expose atoplimit.components/sharepoint/actions/get-excel-table/get-excel-table.mjs (1)
72-83: Defensive: fall back tovalueswhentextis absent and keep row semanticsSome workbooks may not populate
text. This keeps behavior consistent.- const response = this.removeHeaders - ? this.numberOfRows <= 0 - ? range.text.slice(1) - : range.text.slice(1, this.numberOfRows + 1) - : this.numberOfRows <= 0 - ? range.text - : range.text.slice(0, this.numberOfRows + 1); + const rows = Array.isArray(range?.text) ? range.text + : Array.isArray(range?.values) ? range.values + : []; + const response = this.removeHeaders + ? (this.numberOfRows <= 0 + ? rows.slice(1) + : rows.slice(1, this.numberOfRows + 1)) + : (this.numberOfRows <= 0 + ? rows + : rows.slice(0, this.numberOfRows + 1));components/sharepoint/sources/new-folder-created/new-folder-created.mjs (1)
7-7: Nit: brand casing.“SharePoint” (capital P).
- description: "Emit new event when a new folder is created in Microsoft Sharepoint.", + description: "Emit new event when a new folder is created in Microsoft SharePoint.",components/sharepoint/common/constants.mjs (1)
1-14: Gate “embed” when not OneDrive personal; consider “users” scope.Expose
embedonly when target is personal OneDrive; SharePoint/ODB will reject it. Optionally addusersscope in the future for specific people links.If you keep
embed, please add a runtime guard in the action to fail fast when the drive isn’t personal. Also confirm the desired scope surface (onlyanonymous/organization).Also applies to: 16-25, 27-30
components/sharepoint/actions/upload-file/upload-file.mjs (1)
7-8: Clarify scope in description.It uploads to SharePoint/OneDrive.
- description: "Upload a file to OneDrive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online)", + description: "Upload a file to SharePoint / OneDrive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online)",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
components/sharepoint/actions/create-folder/create-folder.mjs(1 hunks)components/sharepoint/actions/create-item/create-item.mjs(1 hunks)components/sharepoint/actions/create-link/create-link.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/find-file-by-name/find-file-by-name.mjs(1 hunks)components/sharepoint/actions/get-excel-table/get-excel-table.mjs(1 hunks)components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs(1 hunks)components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs(1 hunks)components/sharepoint/actions/update-item/update-item.mjs(1 hunks)components/sharepoint/actions/upload-file/upload-file.mjs(1 hunks)components/sharepoint/common/constants.mjs(1 hunks)components/sharepoint/package.json(1 hunks)components/sharepoint/sharepoint.app.mjs(4 hunks)components/sharepoint/sources/common/common.mjs(2 hunks)components/sharepoint/sources/new-file-created/new-file-created.mjs(1 hunks)components/sharepoint/sources/new-folder-created/new-folder-created.mjs(1 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)
🧰 Additional context used
🧬 Code graph analysis (7)
components/sharepoint/sources/common/common.mjs (1)
components/sharepoint/sources/updated-list-item/updated-list-item.mjs (1)
ts(47-47)
components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs (2)
components/sharepoint/actions/create-folder/create-folder.mjs (1)
response(54-64)components/sharepoint/sharepoint.app.mjs (8)
response(17-17)response(48-48)response(80-80)response(107-107)response(136-136)response(160-171)values(172-172)values(202-204)
components/sharepoint/actions/create-folder/create-folder.mjs (2)
components/sharepoint/actions/create-item/create-item.mjs (1)
response(64-70)components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs (1)
response(49-59)
components/sharepoint/actions/upload-file/upload-file.mjs (3)
components/sharepoint/actions/create-folder/create-folder.mjs (1)
response(54-64)components/sharepoint/actions/download-file/download-file.mjs (1)
response(54-59)components/sharepoint/sharepoint.app.mjs (6)
response(17-17)response(48-48)response(80-80)response(107-107)response(136-136)response(160-171)
components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs (1)
components/sharepoint/actions/download-file/download-file.mjs (1)
response(54-59)
components/sharepoint/actions/find-file-by-name/find-file-by-name.mjs (2)
components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs (2)
response(49-59)values(60-62)components/sharepoint/sharepoint.app.mjs (8)
response(17-17)response(48-48)response(80-80)response(107-107)response(136-136)response(160-171)values(172-172)values(202-204)
components/sharepoint/sharepoint.app.mjs (9)
components/sharepoint/actions/create-folder/create-folder.mjs (1)
response(54-64)components/sharepoint/actions/create-link/create-link.mjs (1)
response(58-66)components/sharepoint/actions/download-file/download-file.mjs (1)
response(54-59)components/sharepoint/actions/find-file-by-name/find-file-by-name.mjs (2)
response(35-39)values(40-42)components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs (1)
response(44-48)components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs (2)
response(49-59)values(60-62)components/sharepoint/actions/upload-file/upload-file.mjs (2)
response(71-78)name(69-69)components/microsoft_outlook/sources/common/common-new-email.mjs (1)
folder(45-45)components/sharepoint/sources/common/common.mjs (1)
args(50-50)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: pnpm publish
- GitHub Check: Lint Code Base
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (14)
components/sharepoint/actions/download-file/download-file.mjs (1)
8-8: LGTM! Routine version bump.Version bump aligns with the broader SharePoint component expansion in this PR.
components/sharepoint/actions/create-list/create-list.mjs (1)
7-7: LGTM! Routine version bump.Version increment is consistent with the PR's updates to the SharePoint integration.
components/sharepoint/package.json (1)
3-3: LGTM! Appropriate minor version bump.The bump from 0.3.3 to 0.4.0 correctly signals the addition of new SharePoint actions and sources in this PR.
components/sharepoint/actions/update-item/update-item.mjs (1)
8-8: LGTM! Routine version bump.Version increment aligns with the PR's component updates.
components/sharepoint/sources/updated-list-item/updated-list-item.mjs (1)
7-8: LGTM! Clarified description.The description now correctly indicates the source emits events for list item updates rather than list updates, improving clarity.
components/sharepoint/sources/common/common.mjs (2)
26-31: LGTM! Extension points for derived sources.These methods provide customization hooks for sources to control sorting order and item relevance filtering.
56-69: LGTM! Enhanced emission logic with first-run protection.The changes add:
- First-run protection: limits to 10 items when
lastTsis falsy- Filtering: respects
isRelevant()for item selection- Early exit: breaks when items are sorted descending and timestamp threshold is reached
This prevents overwhelming users with historical data on initial runs while maintaining flexibility for derived sources.
components/sharepoint/sources/new-list-item/new-list-item.mjs (1)
7-8: LGTM! Clarified description.The description now correctly indicates the source emits events for new list items rather than new lists, improving accuracy and consistency with the updated-list-item source.
components/sharepoint/actions/create-item/create-item.mjs (1)
7-7: Version bump notedNo issues with the metadata change.
components/sharepoint/actions/find-file-by-name/find-file-by-name.mjs (1)
35-42: Guard empty name, add select params to trim payload; confirm single-page results are acceptable.
searchDriveItemsdoes not auto-paginate—it returns a single response. For "find-file-by-name," verify that single-page results are sufficient or implement pagination handling if needed.Apply:
async run({ $ }) { + const query = (this.name || "").trim(); + if (!query) throw new Error("File Name is required."); const response = await this.sharepoint.searchDriveItems({ $, siteId: this.siteId, - query: this.name, + query, + params: { select: "id,name,folder" }, }); let values = response.value.filter( - ({ name }) => name.toLowerCase().includes(this.name.toLowerCase()), + ({ name }) => name?.toLowerCase().includes(query.toLowerCase()), );components/sharepoint/actions/create-link/create-link.mjs (1)
57-70: Add validation guard for unsupportedembedtype; include URL in summary.The
embedsharing link type is only supported on personal OneDrive files per the Microsoft Graph API. This SharePoint action usessiteId(not personal OneDrive), soembedwill fail at the API level. Adding early validation improves UX. Additionally, the API response includeslink.webUrl, which should be exported in the summary.Note:
driveIdis used for dynamic filtering but is not required bycreateLink()—the method uses the site-based path/sites/{siteId}/drive/items/{fileId}/createLink.async run({ $ }) { + if (this.type === "embed") { + throw new Error("Embed links are only supported for personal OneDrive files."); + } const response = await this.sharepoint.createLink({ $, siteId: this.siteId, fileId: this.fileId, data: { type: this.type, scope: this.scope, }, }); if (response?.id) { - $.export("$summary", `Successfully created a sharing link with ID \`${response.id}\`.`); + const url = response?.link?.webUrl; + $.export("$summary", `Created sharing link ${response.id}${url ? ` → ${url}` : ""}.`); }components/sharepoint/sources/new-file-created/new-file-created.mjs (3)
3-10: LGTM! Metadata is well-defined.The component metadata follows standard patterns with appropriate dedupe strategy and clear naming.
11-38: LGTM! Props are correctly configured.The prop definitions properly chain dependencies (driveId → siteId, folderId → siteId + driveId) and reference the SharePoint app propDefinitions correctly.
62-63: LGTM! File filtering logic is correct.The
isRelevantmethod correctly filters to only items with afileproperty, excluding folders.
Resolves #18792
Summary by CodeRabbit
New Features
Improvements