- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
Google Drive - new files shared drive polling trigger #15997
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import googleDrive from "../../google_drive.app.mjs"; | ||
| import sourceComponent from "../new-files-instant/new-files-instant.mjs"; | ||
| import sampleEmit from "../new-files-instant/test-event.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|  | ||
| export default { | ||
| key: "google_drive-new-files-shared-drive", | ||
| name: "New Files (Shared Drive)", | ||
| description: "Emit new event when a new file is added in your shared Google Drive", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| googleDrive, | ||
| db: "$.service.db", | ||
| timer: { | ||
| label: "Polling interval", | ||
| description: "Interval to poll the Google Drive API for new files", | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| drive: { | ||
| propDefinition: [ | ||
| googleDrive, | ||
| "sharedDrive", | ||
| ], | ||
| description: "Select a [Shared Drive](https://support.google.com/a/users/answer/9310351) from this list", | ||
| optional: false, | ||
| }, | ||
| folders: sourceComponent.props.folders, | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify method compatibility. While reusing methods and props from the instant source is efficient, ensure that all methods required by this component are properly defined in the sourceComponent. Also applies to: 45-45 🏁 Script executed: #!/bin/bash
# Check for required methods in the sourceComponent
# Look for methods referenced in this file
echo "Methods referenced in new-files-shared-drive.mjs:"
methods=$(grep -o '_[a-zA-Z]*' components/google_drive/sources/new-files-shared-drive/new-files-shared-drive.mjs | sort | uniq)
echo "$methods"
# Check if these methods exist in the source component
echo -e "\nVerifying methods exist in source component:"
for method in $methods; do
  echo -n "$method: "
  if grep -q "$method" components/google_drive/sources/new-files-instant/new-files-instant.mjs; then
    echo "Found"
  else
    echo "NOT FOUND - This might be a problem"
  fi
done
# Check for getDriveId method which is used but might be from googleDrive
echo -e "\nChecking for getDriveId method:"
if grep -q "getDriveId" components/google_drive/sources/new-files-instant/new-files-instant.mjs; then
  echo "getDriveId: Found in source component"
else
  echo "getDriveId: Not found in source component, checking if it exists in app file"
  if grep -q "getDriveId" components/google_drive/google_drive.app.mjs; then
    echo "getDriveId: Found in google_drive.app.mjs"
  else
    echo "getDriveId: NOT FOUND - This might be a problem"
  fi
fiLength of output: 2671 Action: Verify and Fix Missing Method Definitions The verification indicates that several methods referenced in the new shared drive component from the instant source—specifically  
 | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| // Get initial page token for change tracking | ||
| const startPageToken = await this.googleDrive.getPageToken(this.getDriveId()); | ||
| this._setPageToken(startPageToken); | ||
| this._setLastFileCreatedTime(Date.now()); | ||
|  | ||
| // Emit the most recent files | ||
| await sourceComponent.hooks.deploy.bind(this)(); | ||
| }, | ||
| }, | ||
| methods: sourceComponent.methods, | ||
| async run() { | ||
| const pageToken = this._getPageToken(); | ||
|  | ||
| const driveId = this.getDriveId(); | ||
| const changedFilesStream = this.googleDrive.listChanges(pageToken, driveId); | ||
| for await (const changedFilesPage of changedFilesStream) { | ||
| const { nextPageToken } = changedFilesPage; | ||
|  | ||
| // Process all the changed files retrieved from the current page | ||
| await this.processChanges(); | ||
|  | ||
| // After successfully processing the changed files, we store the page | ||
| // token of the next page | ||
| this._setPageToken(nextPageToken); | ||
| } | ||
| }, | ||
| sampleEmit, | ||
| }; | ||
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.
Add missing label and description for the alert prop.
The alert prop is missing the required label and description properties according to component guidelines.
alert: { type: "alert", + label: "Shared Drive Notice", + description: "Important information about using this trigger with shared drives", content: "For shared drives, prefer to use [New Files (Shared Drive)](https://pipedream.com/apps/google-drive/triggers/new-files-shared-drive) instead. \ It provides a more reliable way to track changes using polling. \ Shared drive notifications may be delayed or incomplete, as they don't immediately reflect all changes made by other users. \ For more details, see [Google's documentation](https://developers.google.com/drive/api/guides/about-changes#track_shared_drives).", },📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: Lint Code Base
[warning] 18-18:
Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
[warning] 18-18:
Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props