@pipedream/google_drive 0.6.15 → 0.6.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "0.6.15",
3
+ "version": "0.6.16",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -21,11 +21,38 @@ export default {
21
21
  key: "google_drive-new-or-modified-files",
22
22
  name: "New or Modified Files",
23
23
  description: "Emit new event any time any file in your linked Google Drive is added, modified, or deleted",
24
- version: "0.1.3",
24
+ version: "0.2.0",
25
25
  type: "source",
26
26
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
27
27
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
28
28
  dedupe: "unique",
29
+ props: {
30
+ ...common.props,
31
+ folders: {
32
+ type: "string[]",
33
+ label: "Folders",
34
+ description:
35
+ "(Optional) The folders you want to watch for changes. Leave blank to watch for any new file in the Drive.",
36
+ optional: true,
37
+ default: [],
38
+ options({ prevContext }) {
39
+ const { nextPageToken } = prevContext;
40
+ const baseOpts = {
41
+ q: "mimeType = 'application/vnd.google-apps.folder' and trashed = false",
42
+ };
43
+ const opts = this.isMyDrive()
44
+ ? baseOpts
45
+ : {
46
+ ...baseOpts,
47
+ corpora: "drive",
48
+ driveId: this.getDriveId(),
49
+ includeItemsFromAllDrives: true,
50
+ supportsAllDrives: true,
51
+ };
52
+ return this.googleDrive.listFilesOptions(nextPageToken, opts);
53
+ },
54
+ },
55
+ },
29
56
  hooks: {
30
57
  async deploy() {
31
58
  const daysAgo = new Date();
@@ -45,6 +72,15 @@ export default {
45
72
  },
46
73
  methods: {
47
74
  ...common.methods,
75
+ shouldProcess(file) {
76
+ if (file.mimeType !== "application/vnd.google-apps.folder") {
77
+ const watchedFolders = new Set(this.folders);
78
+ return (
79
+ watchedFolders.size == 0 ||
80
+ (file.parents && file.parents.some((p) => watchedFolders.has(p)))
81
+ );
82
+ }
83
+ },
48
84
  getUpdateTypes() {
49
85
  return [
50
86
  GOOGLE_DRIVE_NOTIFICATION_ADD,
@@ -86,6 +122,17 @@ export default {
86
122
  const changes = await this.getChanges(headers);
87
123
 
88
124
  for (const file of changedFiles) {
125
+ file.parents = (await this.googleDrive.getFile(file.id, {
126
+ fields: "parents",
127
+ })).parents;
128
+
129
+ console.log(file); // see what file was processed
130
+
131
+ if (!this.shouldProcess(file)) {
132
+ console.log(`Skipping file ${file.name}`);
133
+ continue;
134
+ }
135
+
89
136
  const eventToEmit = {
90
137
  file,
91
138
  ...changes,