Skip to content

Commit e30409a

Browse files
Google Sheets new source + drive improvement (#19111)
* Adjusting files and folders to propDefinitions * Adding 'new worksheet (polling)' source * Name adjustment * Update components/google_sheets/sources/new-worksheet-polling/new-worksheet-polling.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com> --------- Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
1 parent 5f26519 commit e30409a

File tree

4 files changed

+85
-25
lines changed

4 files changed

+85
-25
lines changed

components/google_drive/sources/new-or-modified-files-polling/new-or-modified-files-polling.mjs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "google_drive-new-or-modified-files-polling",
99
name: "New or Modified Files (Polling)",
1010
description: "Emit new event when a file in the selected Drive is created, modified or trashed. [See the documentation](https://developers.google.com/drive/api/v3/reference/changes/list)",
11-
version: "0.0.1",
11+
version: "0.0.2",
1212
type: "source",
1313
dedupe: "unique",
1414
props: {
@@ -29,39 +29,34 @@ export default {
2929
optional: false,
3030
},
3131
files: {
32+
propDefinition: [
33+
googleDrive,
34+
"fileId",
35+
({ drive }) => ({
36+
drive,
37+
}),
38+
],
3239
type: "string[]",
3340
label: "Files",
34-
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)",
41+
description: "The specific file(s) 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)",
3542
optional: true,
3643
default: [],
37-
options({ prevContext }) {
38-
const { nextPageToken } = prevContext;
39-
return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
40-
},
4144
},
4245
folders: {
46+
propDefinition: [
47+
googleDrive,
48+
"folderId",
49+
({ drive }) => ({
50+
drive,
51+
baseOpts: {
52+
q: `mimeType = '${GOOGLE_DRIVE_FOLDER_MIME_TYPE}' and trashed = false`,
53+
},
54+
}),
55+
],
4356
type: "string[]",
4457
label: "Folders",
4558
description: "The specific folder(s) to watch for changes. Leave blank to watch all folders in the Drive.",
4659
optional: true,
47-
default: [],
48-
options({ prevContext }) {
49-
const { nextPageToken } = prevContext;
50-
const baseOpts = {
51-
q: "mimeType = 'application/vnd.google-apps.folder' and trashed = false",
52-
};
53-
const isMyDrive = this.googleDrive.isMyDrive(this.drive);
54-
const opts = isMyDrive
55-
? baseOpts
56-
: {
57-
...baseOpts,
58-
corpora: "drive",
59-
driveId: this.getDriveId(),
60-
includeItemsFromAllDrives: true,
61-
supportsAllDrives: true,
62-
};
63-
return this.googleDrive.listFilesOptions(nextPageToken, opts);
64-
},
6560
},
6661
newFilesOnly: {
6762
type: "boolean",

components/google_sheets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_sheets",
3-
"version": "0.11.0",
3+
"version": "0.12.0",
44
"description": "Pipedream Google_sheets Components",
55
"main": "google_sheets.app.mjs",
66
"keywords": [
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import googleSheets from "../../google_sheets.app.mjs";
2+
import common from "../common/new-worksheet.mjs";
3+
import base from "../common/http-based/base.mjs";
4+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
5+
import sampleEmit from "./test-event.mjs";
6+
7+
export default {
8+
...common,
9+
key: "google_sheets-new-worksheet-polling",
10+
name: "New Worksheet (Polling)",
11+
description: "Emit new event each time a new worksheet is created in a spreadsheet.",
12+
version: "0.0.1",
13+
dedupe: "unique",
14+
type: "source",
15+
hooks: {
16+
...common.hooks,
17+
},
18+
props: {
19+
googleSheets,
20+
db: "$.service.db",
21+
timer: {
22+
type: "$.interface.timer",
23+
default: {
24+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
25+
},
26+
},
27+
watchedDrive: {
28+
propDefinition: [
29+
googleSheets,
30+
"watchedDrive",
31+
],
32+
},
33+
sheetID: {
34+
propDefinition: [
35+
googleSheets,
36+
"sheetID",
37+
(c) => ({
38+
driveId: googleSheets.methods.getDriveId(c.watchedDrive),
39+
}),
40+
],
41+
},
42+
},
43+
methods: {
44+
...base.methods,
45+
...common.methods,
46+
},
47+
async run() {
48+
await this.processSpreadsheet({
49+
spreadsheetId: this.sheetID,
50+
});
51+
},
52+
sampleEmit,
53+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default {
2+
"properties": {
3+
"sheetId": 0,
4+
"title": "Sheet1",
5+
"index": 0,
6+
"sheetType": "GRID",
7+
"gridProperties": {
8+
"rowCount": 1007,
9+
"columnCount": 28
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)