@pipedream/google_drive 1.5.0 → 1.5.1

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": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -11,7 +11,7 @@ export default {
11
11
  key: "google_drive-new-files-instant",
12
12
  name: "New Files (Instant)",
13
13
  description: "Emit new event when a new file is added in your linked Google Drive",
14
- version: "0.2.3",
14
+ version: "0.2.4",
15
15
  type: "source",
16
16
  dedupe: "unique",
17
17
  props: {
@@ -54,6 +54,13 @@ export default {
54
54
  default: false,
55
55
  optional: true,
56
56
  },
57
+ includeSubfolders: {
58
+ type: "boolean",
59
+ label: "Include Subfolders",
60
+ description: "Whether to watch for new files in subfolders of the parent folder",
61
+ default: false,
62
+ optional: true,
63
+ },
57
64
  dir: {
58
65
  type: "dir",
59
66
  accessMode: "write",
@@ -91,12 +98,32 @@ export default {
91
98
  _setLastFileCreatedTime(lastFileCreatedTime) {
92
99
  this.db.set("lastFileCreatedTime", lastFileCreatedTime);
93
100
  },
94
- shouldProcess(file) {
101
+ async hasAncestor(file, targetFolderIds) {
102
+ const MAX_DEPTH = 50;
103
+ let currentId = file.parents?.[0];
104
+ if (!currentId) return false;
105
+
106
+ for (let i = 0; i < MAX_DEPTH; i++) {
107
+ if (targetFolderIds.includes(currentId)) return true;
108
+
109
+ const data = await this.googleDrive.getFile(currentId, {
110
+ fields: "parents",
111
+ });
112
+
113
+ if (!data.parents?.length) return false;
114
+ currentId = data.parents[0];
115
+ }
116
+ return false;
117
+ },
118
+ async shouldProcess(file) {
95
119
  const watchedFolders = new Set(this.folders);
96
- return (
97
- watchedFolders.size == 0 ||
98
- (file.parents && file.parents.some((p) => watchedFolders.has(p)))
99
- );
120
+ if (watchedFolders.size == 0 || !file.parents) {
121
+ return true;
122
+ }
123
+ if (this.includeSubfolders) {
124
+ return await this.hasAncestor(file, Array.from(watchedFolders));
125
+ }
126
+ return file.parents.some((p) => watchedFolders.has(p));
100
127
  },
101
128
  getUpdateTypes() {
102
129
  return [
@@ -106,7 +133,7 @@ export default {
106
133
  },
107
134
  async emitFiles(files) {
108
135
  for (const file of files) {
109
- if (!this.shouldProcess(file)) {
136
+ if (!(await this.shouldProcess(file))) {
110
137
  continue;
111
138
  }
112
139
  if (this.includeLink) {
@@ -7,7 +7,7 @@ export default {
7
7
  key: "google_drive-new-files-shared-drive",
8
8
  name: "New Files (Shared Drive)",
9
9
  description: "Emit new event when a new file is added in your shared Google Drive",
10
- version: "0.1.3",
10
+ version: "0.1.4",
11
11
  type: "source",
12
12
  dedupe: "unique",
13
13
  props: {
@@ -37,6 +37,13 @@ export default {
37
37
  default: false,
38
38
  optional: true,
39
39
  },
40
+ includeSubfolders: {
41
+ type: "boolean",
42
+ label: "Enable Subfolders",
43
+ description: "Whether to watch for new files in subfolders of the parent folder",
44
+ default: false,
45
+ optional: true,
46
+ },
40
47
  dir: {
41
48
  type: "dir",
42
49
  accessMode: "write",