feat(integrations): add Microsoft Word - #7069
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryAdds a Microsoft Word integration that constructs and edits DOCX packages locally while using Microsoft Graph for file storage and PDF conversion.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/microsoft-word/document.server.ts | Implements DOCX generation, extraction, append, and text-replacement behavior with archive validation for mutation paths. |
| apps/sim/lib/microsoft-word/graph.server.ts | Centralizes Microsoft Graph document downloads, uploads, conversion, metadata mapping, and content-tag conflict handling. |
| apps/sim/app/api/tools/microsoft_word/append/route.ts | Implements guarded read-modify-write append behavior with conflict responses for detectable concurrent changes. |
| apps/sim/app/api/tools/microsoft_word/replace-text/route.ts | Implements guarded in-place text replacement while preserving the surrounding DOCX package. |
| apps/sim/app/api/tools/microsoft_word/update/route.ts | Implements the documented full-content replacement operation by generating and uploading a new DOCX package. |
| apps/sim/blocks/blocks/microsoft_word.ts | Defines the workflow-facing Microsoft Word block, operations, parameters, and output mappings. |
Sequence Diagram
sequenceDiagram
participant Workflow
participant Sim as Sim Word Tool
participant Graph as Microsoft Graph
Workflow->>Sim: Invoke Word operation
alt Create or Replace Content
Sim->>Sim: Build DOCX package
Sim->>Graph: Upload document content
else Append or Find and Replace
Sim->>Graph: Fetch metadata and content tag
Sim->>Graph: Download DOCX package
Sim->>Sim: Edit package in memory
Sim->>Graph: Re-check content tag
Sim->>Graph: Upload edited package
else Export PDF
Sim->>Graph: "Request content?format=pdf"
Graph-->>Sim: Redirect to converted file
Sim-->>Workflow: Return PDF file
end
Reviews (6): Last reviewed commit: "fix(microsoft-word): fail closed when a ..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 43 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Collaborator
Author
…, and tighten input bounds
Collaborator
Author
Collaborator
Author
…d-integration # Conflicts: # apps/sim/tools/generated/tool-ids.ts # apps/sim/tools/generated/tool-metadata.ts # apps/sim/tools/generated/tool-outputs.ts
Collaborator
Author
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.docxpackage itself and talks to Graph only through documentedcontentendpointsDetails
.docxfrom text with a small documented Markdown subset (#/##/###,-bullets,**bold**/*italic*); unsupported syntax stays as visible text rather than being droppedcopyaction is deliberately unused: it is async and only returns a monitor URL, which would force a poll before the copy could be filledword/document.xmlin place via JSZip, so styles, numbering, images, headers, and footers survive. Append inserts before the body-level<w:sectPr>and emits no style references, since a user-owned document may not defineHeading1content?format=pdfand follows Graph's redirect to the preauthenticated URL with the bearer token stripped cross-originmicrosoft.wordfile selector and fixes it to forwarddriveId(it was ignoring it, unlikemicrosoft.excel, so the picker would list personal OneDrive documents even when a SharePoint drive was set)onedrive.foldersselector;Files.Read/Files.ReadWriteget Word-specific labels on the consent screen instead of the OneDrive-only wordingType of Change
Testing
$, and case sensitivity<w:sectPr>insertion, the$-escaping, and the in-place-replacement branch each turns a specific test redbun run check:audits33/33,bun run type-checkclean,bun run lintcleanChecklist