From 2c599100dfc26cb96bb1c6b11750886299d83622 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 3 Oct 2025 11:11:42 -0400 Subject: [PATCH 1/6] watch drive instead of file --- components/google_sheets/package.json | 2 +- .../google_sheets/sources/common/http-based/sheet.mjs | 6 ++++-- .../google_sheets/sources/new-comment/new-comment.mjs | 2 +- .../google_sheets/sources/new-row-added/new-row-added.mjs | 2 +- .../google_sheets/sources/new-updates/new-updates.mjs | 2 +- .../google_sheets/sources/new-worksheet/new-worksheet.mjs | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/google_sheets/package.json b/components/google_sheets/package.json index ae17a3c4cb99c..042a8c51d6c42 100644 --- a/components/google_sheets/package.json +++ b/components/google_sheets/package.json @@ -11,7 +11,7 @@ "author": "Pipedream (https://pipedream.com/)", "dependencies": { "@googleapis/sheets": "^0.3.0", - "@pipedream/google_drive": "^1.1.0", + "@pipedream/google_drive": "^1.1.1", "@pipedream/platform": "^3.1.0", "lodash": "^4.17.21", "uuidv4": "^6.2.6", diff --git a/components/google_sheets/sources/common/http-based/sheet.mjs b/components/google_sheets/sources/common/http-based/sheet.mjs index 0b1c5ac37dbac..85a32e26fd97b 100644 --- a/components/google_sheets/sources/common/http-based/sheet.mjs +++ b/components/google_sheets/sources/common/http-based/sheet.mjs @@ -5,6 +5,7 @@ import { v4 as uuid } from "uuid"; import base from "./base.mjs"; +import drive from "./drive.mjs"; /** * This source watches for changes to a specific spreadsheet in the user's Google Drive. @@ -12,12 +13,13 @@ import base from "./base.mjs"; export default { ...base, methods: { + ...drive.methods, ...base.methods, async activateHook(channelID) { - return this.googleSheets.activateFileHook( + return this.googleSheets.activateHook( channelID, this.http.endpoint, - this.getSheetId(), + this.googleSheets.getDriveId(this.watchedDrive), ); }, async getAllWorksheetIds(sheetID) { diff --git a/components/google_sheets/sources/new-comment/new-comment.mjs b/components/google_sheets/sources/new-comment/new-comment.mjs index f02d5c80d683a..1b587baaa0f48 100644 --- a/components/google_sheets/sources/new-comment/new-comment.mjs +++ b/components/google_sheets/sources/new-comment/new-comment.mjs @@ -6,7 +6,7 @@ export default { key: "google_sheets-new-comment", name: "New Comment (Instant)", description: "Emit new event each time a comment is added to a spreadsheet.", - version: "0.1.1", + version: "0.1.2", dedupe: "unique", type: "source", methods: { diff --git a/components/google_sheets/sources/new-row-added/new-row-added.mjs b/components/google_sheets/sources/new-row-added/new-row-added.mjs index 9abda1dd75782..8909266273a07 100644 --- a/components/google_sheets/sources/new-row-added/new-row-added.mjs +++ b/components/google_sheets/sources/new-row-added/new-row-added.mjs @@ -8,7 +8,7 @@ export default { key: "google_sheets-new-row-added", name: "New Row Added (Instant)", description: "Emit new event each time a row or rows are added to the bottom of a spreadsheet.", - version: "0.2.1", + version: "0.2.2", dedupe: "unique", type: "source", props: { diff --git a/components/google_sheets/sources/new-updates/new-updates.mjs b/components/google_sheets/sources/new-updates/new-updates.mjs index 9ad4b0a4831e2..1ac14eb9fa186 100644 --- a/components/google_sheets/sources/new-updates/new-updates.mjs +++ b/components/google_sheets/sources/new-updates/new-updates.mjs @@ -9,7 +9,7 @@ export default { type: "source", name: "New Updates (Instant)", description: "Emit new event each time a row or cell is updated in a spreadsheet.", - version: "0.3.1", + version: "0.3.2", dedupe: "unique", props: { ...httpBase.props, diff --git a/components/google_sheets/sources/new-worksheet/new-worksheet.mjs b/components/google_sheets/sources/new-worksheet/new-worksheet.mjs index 07ad0c133c292..0b7b7cc09f3b0 100644 --- a/components/google_sheets/sources/new-worksheet/new-worksheet.mjs +++ b/components/google_sheets/sources/new-worksheet/new-worksheet.mjs @@ -9,7 +9,7 @@ export default { type: "source", name: "New Worksheet (Instant)", description: "Emit new event each time a new worksheet is created in a spreadsheet.", - version: "0.2.1", + version: "0.2.2", dedupe: "unique", hooks: { ...httpBase.hooks, From 6a57ab74f4431582936890b8b658ec58f3e5468a Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 3 Oct 2025 11:12:30 -0400 Subject: [PATCH 2/6] pnpm-lock.yaml --- pnpm-lock.yaml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2c769c778b047..a6771924b6351 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -623,8 +623,7 @@ importers: specifier: ^2.30.1 version: 2.30.1 - components/airtop: - specifiers: {} + components/airtop: {} components/aitable_ai: dependencies: @@ -6099,8 +6098,8 @@ importers: specifier: ^0.3.0 version: 0.3.0 '@pipedream/google_drive': - specifier: ^1.1.0 - version: 1.1.0 + specifier: ^1.1.1 + version: 1.1.1 '@pipedream/platform': specifier: ^3.1.0 version: 3.1.0 @@ -7684,8 +7683,7 @@ importers: specifier: ^3.1.0 version: 3.1.0 - components/kudosity: - specifiers: {} + components/kudosity: {} components/kustomer: dependencies: @@ -13287,8 +13285,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/sinch: - specifiers: {} + components/sinch: {} components/sinch_messagemedia: {} @@ -20415,8 +20412,8 @@ packages: '@pipedream/google_drive@1.0.3': resolution: {integrity: sha512-E7MF0E3f/RRyL5PsLaoL51IZtdoyWKNpUIT7RIpQDJ2wh00H0hrISfgugfKAVdv7Tl//BvJezu1FecSLTxhroQ==} - '@pipedream/google_drive@1.1.0': - resolution: {integrity: sha512-ZiLlhIrJc7iUK7jLaQaRj4sf/9VUi6ZyZAGhYd2CfoZ8J7ys1KA9Rxi7oUFZvdKsH0AyJIHTIokCZbcuubS0Pw==} + '@pipedream/google_drive@1.1.1': + resolution: {integrity: sha512-amUo+NYuBMnXlJoIAIjw8vuVhGF4AB8LuLn5G2oq4lgU1Xt0Fqot8WGIh1Ahwx16q1RqKq+4DDdV9jROjm9rSA==} '@pipedream/helper_functions@0.3.13': resolution: {integrity: sha512-67zXT5rMccSYEeQCEKjO0g/U2Wnc3q1ErRWt0sivqJEF/KYqAb3tWmznDYGACbC8L6ML0WWSWRy7nEGt5Vyuaw==} @@ -39129,7 +39126,7 @@ snapshots: - encoding - supports-color - '@pipedream/google_drive@1.1.0': + '@pipedream/google_drive@1.1.1': dependencies: '@googleapis/drive': 2.4.0 '@pipedream/platform': 3.1.0 From d275fd7eaab0b8cb884f056c4c7556476a20813c Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 3 Oct 2025 11:17:55 -0400 Subject: [PATCH 3/6] package.json version --- components/google_sheets/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/google_sheets/package.json b/components/google_sheets/package.json index 042a8c51d6c42..c9352fe50c4d4 100644 --- a/components/google_sheets/package.json +++ b/components/google_sheets/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/google_sheets", - "version": "0.9.0", + "version": "0.9.1", "description": "Pipedream Google_sheets Components", "main": "google_sheets.app.mjs", "keywords": [ From 0afd8aca7b9391c8b2213a268731e5a1853eae45 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 3 Oct 2025 17:59:10 -0400 Subject: [PATCH 4/6] add optional watchDrive prop, updates --- .../sources/common/http-based/base.mjs | 5 +- .../sources/common/http-based/drive.mjs | 4 + .../sources/common/http-based/sheet.mjs | 75 ++++++++++++++++++- 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/components/google_sheets/sources/common/http-based/base.mjs b/components/google_sheets/sources/common/http-based/base.mjs index 984ffb1572b08..267a5132b7c1c 100644 --- a/components/google_sheets/sources/common/http-based/base.mjs +++ b/components/google_sheets/sources/common/http-based/base.mjs @@ -31,7 +31,10 @@ export default { props: { googleSheets, db: "$.service.db", - http: "$.interface.http", + http: { + type: "$.interface.http", + customResponse: true, + }, timer: { label: "Push notification renewal schedule", description: diff --git a/components/google_sheets/sources/common/http-based/drive.mjs b/components/google_sheets/sources/common/http-based/drive.mjs index e6c7e9957a8d1..81b31d5a1ad27 100644 --- a/components/google_sheets/sources/common/http-based/drive.mjs +++ b/components/google_sheets/sources/common/http-based/drive.mjs @@ -135,6 +135,10 @@ export default { return; } + this.http.respond({ + status: 200, + }); + const spreadsheet = await this.getSpreadsheetToProcess(event); if (!spreadsheet) { diff --git a/components/google_sheets/sources/common/http-based/sheet.mjs b/components/google_sheets/sources/common/http-based/sheet.mjs index 85a32e26fd97b..c571680f177c4 100644 --- a/components/google_sheets/sources/common/http-based/sheet.mjs +++ b/components/google_sheets/sources/common/http-based/sheet.mjs @@ -12,14 +12,36 @@ import drive from "./drive.mjs"; */ export default { ...base, + props: { + ...base.props, + watchDrive: { + type: "boolean", + label: "Watch Drive", + description: "Set to `true` to watch the drive for changes. May reduce rate limiting.", + optional: true, + }, + }, methods: { ...drive.methods, ...base.methods, + _getChangeToken() { + return this.db.get("changeToken"); + }, + _setChangeToken(changeToken) { + this.db.set("changeToken", changeToken); + }, async activateHook(channelID) { - return this.googleSheets.activateHook( + if (this.watchDrive) { + return this.googleSheets.activateHook( + channelID, + this.http.endpoint, + this.googleSheets.getDriveId(this.watchedDrive), + ); + } + return this.googleSheets.activateFileHook( channelID, this.http.endpoint, - this.googleSheets.getDriveId(this.watchedDrive), + this.getSheetId(), ); }, async getAllWorksheetIds(sheetID) { @@ -29,6 +51,19 @@ export default { .filter(({ sheetType }) => sheetType === "GRID") .map(({ sheetId }) => (sheetId.toString())); }, + async isSheetRelevant() { + const pageToken = this._getChangeToken() || this._getPageToken(); + const drive = this.googleSheets.drive(); + const { data } = await drive.changes.list({ + pageToken, + driveId: this.googleSheets.getDriveId(this.watchedDrive), + }); + const { + changes, newStartPageToken, + } = data; + this._setChangeToken(newStartPageToken); + return changes.some((change) => change.file.id === this.getSheetId()); + }, async renewSubscription() { // Assume subscription & channelID may all be undefined at // this point Handle their absence appropriately. @@ -53,10 +88,37 @@ export default { }); this._setChannelID(newChannelID); }, + async renewDriveSubscription() { + const subscription = this._getSubscription(); + const channelID = this._getChannelID() || uuid(); + + const { + expiration, + resourceId, + newChannelID, + newPageToken, + } = await this.googleSheets.renewSubscription( + this.watchedDrive, + subscription, + this.http.endpoint, + channelID, + this._getPageToken(), + ); + + this._setSubscription({ + expiration, + resourceId, + }); + this._setChannelID(newChannelID); + this._setPageToken(newPageToken); + }, }, async run(event) { if (event.timestamp) { // Component was invoked by timer + if (this.watchDrive) { + return this.renewDriveSubscription(); + } return this.renewSubscription(); } @@ -65,6 +127,15 @@ export default { return; } + this.http.respond({ + status: 200, + }); + + if (this.watchDrive && !(await this.isSheetRelevant(event))) { + console.log("Change to unwatched file, exiting early"); + return; + } + const spreadsheet = await this.googleSheets.getSpreadsheet(this.sheetID); return this.processSpreadsheet(spreadsheet); From 28f4310a46449e82d2fc2f86fba7cd84e3e325e3 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 3 Oct 2025 18:03:13 -0400 Subject: [PATCH 5/6] version --- .../sources/new-row-added-polling/new-row-added-polling.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/google_sheets/sources/new-row-added-polling/new-row-added-polling.mjs b/components/google_sheets/sources/new-row-added-polling/new-row-added-polling.mjs index c4bd18cb86377..d583f22c6a833 100644 --- a/components/google_sheets/sources/new-row-added-polling/new-row-added-polling.mjs +++ b/components/google_sheets/sources/new-row-added-polling/new-row-added-polling.mjs @@ -8,7 +8,7 @@ export default { key: "google_sheets-new-row-added-polling", name: "New Row Added", description: "Emit new event each time a row or rows are added to the bottom of a spreadsheet.", - version: "0.1.1", + version: "0.1.2", dedupe: "unique", type: "source", props: { From 685508d9d15d820f9940968dcb371e9654a477f7 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 3 Oct 2025 18:15:10 -0400 Subject: [PATCH 6/6] update for shared drives --- .../sources/common/http-based/sheet.mjs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/google_sheets/sources/common/http-based/sheet.mjs b/components/google_sheets/sources/common/http-based/sheet.mjs index c571680f177c4..4592543425443 100644 --- a/components/google_sheets/sources/common/http-based/sheet.mjs +++ b/components/google_sheets/sources/common/http-based/sheet.mjs @@ -54,10 +54,19 @@ export default { async isSheetRelevant() { const pageToken = this._getChangeToken() || this._getPageToken(); const drive = this.googleSheets.drive(); - const { data } = await drive.changes.list({ + const params = { pageToken, - driveId: this.googleSheets.getDriveId(this.watchedDrive), - }); + }; + const driveId = this.getDriveId(this.watchedDrive); + if (driveId) { + Object.assign(params, { + driveId, + supportsAllDrives: true, + includeItemsFromAllDrives: true, + corpora: "drive", + }); + } + const { data } = await drive.changes.list(params); const { changes, newStartPageToken, } = data;