-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Google Drive - allow format selection for text #15299
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
Google Drive - allow format selection for text #15299
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request modifies the Google Drive file creation action to support more flexible file format uploads. The changes introduce a new optional Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 1
🧹 Nitpick comments (2)
components/google_drive/actions/create-file-from-text/create-file-from-text.mjs (2)
47-76: Update the documentation link in the description.The current link points to export formats documentation, which isn't directly relevant for file creation. Consider linking to the supported MIME types documentation instead.
- "The [format](https://developers.google.com/drive/api/v3/ref-export-formats) in which the text is presented", + "The [format](https://developers.google.com/drive/api/guides/mime-types) in which the text is presented",
90-90: Consider making the parent folder logic more explicit.The current implementation silently falls back to the drive ID when no parent folder is specified. Consider adding a comment or updating the variable name to make this behavior more obvious.
- const parent = parentId ?? driveId; + // Fall back to drive's root if no parent folder specified + const parentFolderId = parentId ?? driveId;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/google_drive/actions/create-file-from-text/create-file-from-text.mjs(2 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 (2)
components/google_drive/actions/create-file-from-text/create-file-from-text.mjs (2)
8-8: LGTM! Version bump is appropriate.The minor version increment (0.1.7 → 0.2.0) correctly reflects the addition of new functionality (format selection) without breaking changes.
88-104: Verify the impact on existing workflows.Let's check how this component is being used in existing workflows to ensure the changes don't affect them unexpectedly.
✅ Verification successful
Changes are isolated and consistent with core implementation
The component is self-contained and follows the same pattern as the core Google Drive implementation. No workflows or other components are affected by these changes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for workflows using this component rg -l "google_drive-create-file-from-text" -g '*.{json,yaml,yml}' # Check for any custom implementations that might be affected rg "drive\.files\.create" -g '*.{js,mjs,ts}'Length of output: 326
Script:
#!/bin/bash # Get context of drive.files.create in google_drive.app.mjs rg "drive\.files\.create" components/google_drive/google_drive.app.mjs -B 5 -A 5 # Search for any imports or references to this component rg "create-file-from-text" -g '*.{js,mjs,ts}'Length of output: 527
| const { data: resp } = await drive.files.create({ | ||
| supportsAllDrives: true, | ||
| media: { | ||
| mimeType, | ||
| body: file, | ||
| }, | ||
| requestBody: { | ||
| name, | ||
| mimeType: "application/vnd.google-apps.document", | ||
| parents: [ | ||
| parent, | ||
| ], | ||
| }, |
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.
Fix conflicting MIME type configuration.
There's a potential issue with specifying two different MIME types:
- The user-selected format in
media.mimeType - A hardcoded Google Docs format in
requestBody.mimeType
This might cause unexpected conversion behavior. Consider one of these approaches:
Option 1 (Recommended) - Keep the original format:
const { data: resp } = await drive.files.create({
supportsAllDrives: true,
media: {
mimeType,
body: file,
},
requestBody: {
name,
- mimeType: "application/vnd.google-apps.document",
+ mimeType, // Use the same format as the media object
parents: [
- parent,
+ parentFolderId,
],
},
});Option 2 - Add a separate property for conversion:
+ conversionFormat: {
+ type: "boolean",
+ label: "Convert to Google Docs",
+ description: "Whether to convert the file to Google Docs format",
+ optional: true,
+ default: false,
+ },Then in the code:
const { data: resp } = await drive.files.create({
supportsAllDrives: true,
media: {
mimeType,
body: file,
},
requestBody: {
name,
- mimeType: "application/vnd.google-apps.document",
+ mimeType: this.conversionFormat
+ ? "application/vnd.google-apps.document"
+ : mimeType,
parents: [
- parent,
+ parentFolderId,
],
},
});Committable suggestion skipped: line range outside the PR's diff.
WHY
Summary by CodeRabbit
New Features
Improvements
Version Update