-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[ACTION] Google Drive - Polling-based components as an alternative to webhook-based ones #19126
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
base: master
Are you sure you want to change the base?
[ACTION] Google Drive - Polling-based components as an alternative to webhook-based ones #19126
Conversation
… webhook-based ones
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughThis PR introduces four new polling-based sources for Google Drive—new files, new/modified comments, new/modified folders, and new spreadsheets—each with associated test-event fixtures. The package version is bumped to 1.4.0. These sources offer alternatives to webhook-based triggers by using page tokens and timestamps for state tracking across runs. Changes
Sequence Diagram(s)sequenceDiagram
participant Deploy as Deploy Hook
participant Run as Run Loop
participant DB as State (DB)
participant GDrive as Google Drive API
participant Emit as Event Emission
Deploy->>DB: Initialize pageToken & timestamp
Deploy->>GDrive: Fetch recent items (last 30 days)
Deploy->>Emit: Emit up to 5 sample events
loop Every trigger interval
Run->>DB: Get pageToken & lastRunTimestamp
Run->>GDrive: listChanges(pageToken)
GDrive-->>Run: Return change pages
loop For each change
Run->>Run: Filter by type (file/folder/comment)
Run->>Run: Apply folder/visibility rules
Run->>Run: Check timestamp > lastRunTimestamp
alt Passes filter
Run->>GDrive: Fetch full metadata
Run->>Emit: Emit event with meta
end
end
Run->>DB: Update pageToken
Run->>DB: Update lastRunTimestamp
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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: 12
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (9)
components/google_drive/package.json(1 hunks)components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs(1 hunks)components/google_drive/sources/new-files-instant-polling/test-event.mjs(1 hunks)components/google_drive/sources/new-or-modified-comments-polling/new-or-modified-comments-polling.mjs(1 hunks)components/google_drive/sources/new-or-modified-comments-polling/test-event.mjs(1 hunks)components/google_drive/sources/new-or-modified-folders-polling/new-or-modified-folders-polling.mjs(1 hunks)components/google_drive/sources/new-or-modified-folders-polling/test-event.mjs(1 hunks)components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.mjs(1 hunks)components/google_drive/sources/new-spreadsheet-polling/test-event.mjs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
components/google_drive/sources/new-or-modified-folders-polling/new-or-modified-folders-polling.mjs (3)
components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs (15)
driveId(52-52)driveId(141-141)startPageToken(53-53)daysAgo(59-59)timeString(61-61)args(63-68)args(70-70)pageToken(140-140)fileId(118-122)ts(123-123)meta(132-132)currentRunTimestamp(137-137)changedFilesStream(143-143)changedFilesPage(147-150)fullFile(163-165)components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.mjs (15)
driveId(51-51)driveId(139-139)startPageToken(52-52)daysAgo(58-58)timeString(60-60)args(62-67)args(69-69)pageToken(138-138)fileId(116-120)ts(121-121)meta(130-130)currentRunTimestamp(135-135)changedFilesStream(141-141)changedFilesPage(145-148)fullFile(161-163)components/google_drive/google_drive.app.mjs (1)
changedFiles(424-426)
components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.mjs (1)
components/google_drive/google_drive.app.mjs (1)
changedFiles(424-426)
components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs (1)
components/google_drive/google_drive.app.mjs (1)
changedFiles(424-426)
components/google_drive/sources/new-or-modified-comments-polling/new-or-modified-comments-polling.mjs (3)
components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs (2)
ts(123-123)meta(132-132)components/google_drive/sources/new-or-modified-folders-polling/new-or-modified-folders-polling.mjs (2)
ts(154-154)meta(163-163)components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.mjs (2)
ts(121-121)meta(130-130)
⏰ 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: Verify TypeScript components
- GitHub Check: Publish TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (8)
components/google_drive/sources/new-or-modified-folders-polling/test-event.mjs (1)
1-51: LGTM! Test fixture is well-structured.The test event fixture correctly represents a Google Drive folder resource with appropriate fields and sample data for testing the polling source.
components/google_drive/sources/new-or-modified-folders-polling/new-or-modified-folders-polling.mjs (1)
167-222: Run method logic is sound.The polling logic correctly:
- Tracks state with page tokens and timestamps
- Fetches full metadata for changed folders
- Optimizes by skipping unmodified folders (lines 197-204)
- Applies filtering with
shouldProcess- Persists state after each page for resumability
This follows the same solid pattern as other polling sources in this PR.
components/google_drive/package.json (1)
3-3: Version bump looks consistent with new sourcesUpdating the package version to
1.4.0to ship the new polling sources is appropriate; no issues here.components/google_drive/sources/new-files-instant-polling/test-event.mjs (1)
1-99: Fixture shape is appropriate for sample file eventsThe exported object provides realistic Drive file metadata (id, name, parents, mimeType, timestamps, permissions) and matches what the polling source expects for
sampleEmit. No issues spotted.components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs (1)
136-188: Run loop and state updates look logically soundThe run loop correctly:
- Streams changes via
listChanges(pageToken, driveId)- Filters out folders and then fetches full metadata
- Uses
createdTimevslastRunTimestampto detect truly new files- Applies
shouldProcess(folder filter) and emits viaemitFile- Updates
pageTokenon each page andlastRunTimestampat the endThe overall polling behavior and deduplication logic look consistent with the intended “new files since last run” semantics.
components/google_drive/sources/new-spreadsheet-polling/test-event.mjs (1)
1-111: Spreadsheet test fixture is well‑formedThe exported spreadsheet payload includes the expected fields (id, name, mimeType, parents, timestamps, permissions, capabilities, exportLinks) and matches what the polling source will emit as a sample. No issues found.
components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.mjs (1)
134-186: Spreadsheet run loop aligns with desired polling behaviorThe
run()implementation:
- Streams changes from Drive using
listChanges- Filters to spreadsheet mime types, fetches full metadata, and skips already‑created spreadsheets based on
createdTimevslastRunTimestamp- Applies folder filters via
shouldProcessand emits viaemitSpreadsheet- Updates
pageTokenper page andlastRunTimestampat the endThe logic is consistent with the “new spreadsheet since last run” requirement and mirrors the new‑files implementation appropriately.
components/google_drive/sources/new-or-modified-comments-polling/test-event.mjs (1)
1-35: Fixture shape and data look appropriateThe sample payload is a realistic Drive comment (with a single reply), matches the fields this source uses (
id,content,modifiedTime,author,replies), and uses safe placeholder identities. No issues from a testing or privacy perspective.
components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-files-instant-polling/new-files-instant-polling.mjs
Show resolved
Hide resolved
...s/google_drive/sources/new-or-modified-comments-polling/new-or-modified-comments-polling.mjs
Show resolved
Hide resolved
...s/google_drive/sources/new-or-modified-comments-polling/new-or-modified-comments-polling.mjs
Show resolved
Hide resolved
...nts/google_drive/sources/new-or-modified-folders-polling/new-or-modified-folders-polling.mjs
Show resolved
Hide resolved
...nts/google_drive/sources/new-or-modified-folders-polling/new-or-modified-folders-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.mjs
Show resolved
Hide resolved
components/google_drive/sources/new-spreadsheet-polling/new-spreadsheet-polling.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.
LGTM! Ready for QA!
For Integration QA: |
WHY
Resolves #19118
Summary by CodeRabbit