Skip to content

refactor(microsoft-excel): export GRAPH_ID_PATTERN and deduplicate validation#4174

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/excel-sharepoint-drive-v2
Apr 15, 2026
Merged

refactor(microsoft-excel): export GRAPH_ID_PATTERN and deduplicate validation#4174
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/excel-sharepoint-drive-v2

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented Apr 15, 2026

Summary

Test plan

  • Verify bun run build passes with no type errors
  • Confirm existing OneDrive Excel workflows are unaffected
  • Confirm SharePoint drive selection still works end-to-end

…outes

Export the shared regex pattern from utils.ts and import it in files/route.ts
and drives/route.ts instead of duplicating the inline pattern. Also reorders
the TSDoc comment to sit above getItemBasePath where it belongs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 15, 2026 4:30am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 15, 2026

PR Summary

Low Risk
Low risk refactor that centralizes a shared ID validation regex; behavior should be unchanged aside from ensuring all Graph driveId checks use the same pattern.

Overview
Deduplicates Microsoft Graph ID validation by exporting GRAPH_ID_PATTERN from microsoft_excel/utils.ts and reusing it in the Microsoft OAuth files API and the SharePoint drives API instead of inline regexes.

Also moves the ID-pattern TSDoc to sit directly above getItemBasePath for clarity.

Reviewed by Cursor Bugbot for commit 71382cc. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 15, 2026

Greptile Summary

This PR exports GRAPH_ID_PATTERN from tools/microsoft_excel/utils.ts and replaces two duplicate inline regex definitions in files/route.ts and drives/route.ts with the shared import. The TSDoc comment for getItemBasePath is also repositioned to sit directly above the function. This is a clean deduplication with no behavioral changes.

Confidence Score: 5/5

Safe to merge — pure deduplication with no logic changes.

All three files make identical behavioral use of the pattern; no new logic is introduced. Import ordering follows the project conventions. No P0 or P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/tools/microsoft_excel/utils.ts Exports GRAPH_ID_PATTERN and repositions the TSDoc comment for getItemBasePath directly above the function — clean and correct.
apps/sim/app/api/auth/oauth/microsoft/files/route.ts Replaces the inline duplicate driveId regex with the shared GRAPH_ID_PATTERN import; logic and import order are correct.
apps/sim/app/api/tools/microsoft_excel/drives/route.ts Replaces the inline duplicate driveId regex with the shared GRAPH_ID_PATTERN import; no logic changes, consistent with files/route.ts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["GRAPH_ID_PATTERN\ntools/microsoft_excel/utils.ts"] --> B["getItemBasePath\nvalidates spreadsheetId and driveId"]
    A --> C["files/route.ts\nvalidates driveId query param"]
    A --> D["drives/route.ts\nvalidates driveId body param"]

    C -->|"driveId valid"| E["Search drive: drives/{driveId}/root"]
    C -->|"no driveId"| F["Search personal: me/drive/root"]
    D -->|"driveId provided"| G["Fetch single drive\nsites/{siteId}/drives/{driveId}"]
    D -->|"no driveId"| H["List all drives\nsites/{siteId}/drives"]
    B -->|"driveId provided"| I["/drives/{driveId}/items/{itemId}"]
    B -->|"no driveId"| J["/me/drive/items/{itemId}"]
Loading

Reviews (1): Last reviewed commit: "lint" | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit 22d4639 into staging Apr 15, 2026
13 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/excel-sharepoint-drive-v2 branch April 15, 2026 04:34
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.

1 participant