-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Google Drive "New or Modified Files" polling source #19070
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughVersion 1.3.0 of the Google Drive component adds a new polling source that monitors Google Drive for new or modified files. The source includes configuration for drive selection, optional file and folder filters, deployment-time state initialization with sample events, and a polling loop that streams changes and updates persistent state. Changes
Sequence Diagram(s)sequenceDiagram
participant Deploy as Deployment
participant Source as Polling Source
participant Drive as Google Drive API
participant DB as State Storage
participant Emit as Event Emitter
rect rgba(100, 150, 255, 0.3)
Note over Deploy,Emit: Deploy Phase (Bootstrap)
Deploy->>Source: Initialize source
Source->>DB: Set initial pageToken and lastRunTimestamp
Source->>Drive: List recent modified files (last 30 days)
Drive-->>Source: File metadata (up to 5 non-folders)
Source->>Emit: Emit sample events
end
rect rgba(100, 200, 100, 0.3)
Note over Deploy,Emit: Polling Loop (Recurring)
loop Each poll interval
Source->>DB: Retrieve pageToken, driveId, lastRunTimestamp
Source->>Drive: listChanges(pageToken, driveId)
Drive-->>Source: Changed files page
Source->>Source: shouldProcess: filter folders,<br/>apply newFilesOnly,<br/>match file/folder IDs
Source->>Emit: Emit qualified events with metadata
Source->>DB: Update pageToken
end
Source->>DB: Update lastRunTimestamp after all pages
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
components/google_drive/package.json(1 hunks)components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs(1 hunks)components/google_drive/sources/new-or-modified-files-polling/test-event.mjs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs (1)
components/google_drive/google_drive.app.mjs (1)
changedFiles(424-426)
⏰ 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 (2)
components/google_drive/package.json (1)
3-3: Version bump looks appropriateThe version update to
1.3.0is consistent with adding a new source and has no functional risk by itself.components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs (1)
177-218: ConfirmlistChangestoken semantics to avoid reprocessing or 4xx errorsThe
runloop is structured well, but its correctness depends on howgoogleDrive.listChangeshandles tokens:const changedFilesStream = this.googleDrive.listChanges(pageToken, driveId); for await (const changedFilesPage of changedFilesStream) { const { changedFiles, nextPageToken } = changedFilesPage; ... this._setPageToken(nextPageToken); } ... this._setLastRunTimestamp(currentRunTimestamp);Please verify that:
nextPageTokenis always the correct token to resume from on the next run (e.g., it already accounts fornewStartPageTokenfrom the Drive API), and- It’s safe to persist
nextPageTokeneven on the last page (i.e., it does not end upundefinedin a way that breaks subsequent calls or causes reprocessing).If
listChangesalready normalizes this, great; if not, you may want to guard the_setPageTokencall or explicitly handle a finalnewStartPageToken.
components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-or-modified-files-polling/test-event.mjs
Show resolved
Hide resolved
michelle0927
left a 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.
Looks good. Left a couple comments. I'll leave it up to you, but I wonder if it would be simpler to just have one of either files or folders.
| files: { | ||
| type: "string[]", | ||
| label: "Files", | ||
| description: "The specific file(s) you want to watch for changes. Leave blank to watch all files in the Drive. Note that events will only be emitted for files directly in these folders (not in their subfolders, unless also selected here)", | ||
| optional: true, | ||
| default: [], | ||
| options({ prevContext }) { | ||
| const { nextPageToken } = prevContext; | ||
| return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts()); | ||
| }, | ||
| }, | ||
| folders: { | ||
| type: "string[]", | ||
| label: "Folders", | ||
| description: "The specific folder(s) to watch for changes. Leave blank to watch all folders in the Drive.", | ||
| optional: true, | ||
| default: [], | ||
| options({ prevContext }) { |
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.
Is there any reason not to use the fileId & folderId propDefinitions from the app file?
| // Check if specific files are being watched | ||
| if (this.files?.length > 0) { | ||
| if (!this.files.includes(file.id)) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| // Check if specific folders are being watched | ||
| if (this.folders?.length > 0) { | ||
| const watchedFolders = new Set(this.folders); | ||
| if (!file.parents || !file.parents.some((p) => watchedFolders.has(p))) { | ||
| return false; | ||
| } | ||
| } |
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.
The user can specify both files and folders. But if the changed file is in a watched folder, but isn't one of the selected files, it will return early.
For Integration QA: |
|
Hi everyone, all test cases are passed! Ready for release! Test reports
|
Created as an alternative to existing webhook-based sources
Supports shared drives, and provides optional filters for specific files, specific folders, and "new files only".
Summary by CodeRabbit
New Features
Chores