@pipedream/google_drive 0.6.6 → 0.6.8

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/README.md CHANGED
@@ -8,3 +8,9 @@ Using the Google Drive API, you can build applications that:
8
8
  - Search for files
9
9
  - Track changes to files
10
10
  - And much more!
11
+
12
+ ## Troubleshooting
13
+
14
+ [Google Advanced Protection Program](https://support.google.com/accounts/answer/7539956?hl=en) must be disabled in order to use the Google Drive app on Pipedream.
15
+
16
+ If you encounter the error "Google cannot give this app access to your account data because Advanced Protection is turned on for your Google Account", you will need to disable this setting as it blocks third-party apps from accessing Google Drive.
@@ -5,7 +5,7 @@ export default {
5
5
  key: "google_drive-list-files",
6
6
  name: "List Files",
7
7
  description: "List files from a specific folder. [See the docs](https://developers.google.com/drive/api/v3/reference/files/list) for more information",
8
- version: "0.1.1",
8
+ version: "0.1.2",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -40,6 +40,12 @@ export default {
40
40
  type: "string",
41
41
  optional: true,
42
42
  },
43
+ trashed: {
44
+ label: "Trashed",
45
+ type: "boolean",
46
+ description: "List trashed files or non-trashed files. Keep it empty to include both.",
47
+ optional: true,
48
+ }
43
49
  },
44
50
  async run({ $ }) {
45
51
  const opts = getListFilesOpts(this.drive, {
@@ -53,6 +59,11 @@ export default {
53
59
  ? " AND "
54
60
  : ""}name contains '${this.filterText}'`;
55
61
  }
62
+ if (typeof this.trashed !== "undefined") {
63
+ opts.q += `${opts.q
64
+ ? " AND "
65
+ : ""}trashed=${this.trashed}`;
66
+ }
56
67
  if (this.fields) {
57
68
  opts.fields = this.fields;
58
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -10,7 +10,7 @@ export default {
10
10
  key: "google_drive-new-files-instant",
11
11
  name: "New Files (Instant)",
12
12
  description: "Emit new event any time a new file is added in your linked Google Drive",
13
- version: "0.1.2",
13
+ version: "0.1.3",
14
14
  type: "source",
15
15
  dedupe: "unique",
16
16
  props: {
@@ -47,11 +47,13 @@ export default {
47
47
  const timeString = daysAgo.toISOString();
48
48
 
49
49
  const { data } = await this.googleDrive.drive().files.list({
50
- q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
51
- fields: "files(id)",
50
+ q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`,
51
+ orderBy: "createdTime desc",
52
+ fields: "*",
53
+ pageSize: 25,
52
54
  });
53
55
 
54
- await this.processChanges(data.files);
56
+ this.emitFiles(data.files);
55
57
  },
56
58
  ...common.hooks,
57
59
  async activate() {
@@ -80,29 +82,35 @@ export default {
80
82
  GOOGLE_DRIVE_NOTIFICATION_CHANGE,
81
83
  ];
82
84
  },
83
- async processChanges(changedFiles) {
84
- const lastFileCreatedTime = this._getLastFileCreatedTime();
85
- let maxCreatedTime = lastFileCreatedTime;
86
-
87
- for (const file of changedFiles) {
88
- const fileInfo = await this.googleDrive.getFile(file.id);
89
- const createdTime = Date.parse(fileInfo.createdTime);
90
- if (
91
- !this.shouldProcess(fileInfo) ||
92
- createdTime < lastFileCreatedTime
93
- ) {
85
+ emitFiles(files) {
86
+ for (const file of files) {
87
+ if (!this.shouldProcess(file)) {
94
88
  continue;
95
89
  }
96
-
97
- this.$emit(fileInfo, {
98
- summary: `New File: ${fileInfo.name}`,
90
+ this.$emit(file, {
91
+ summary: `New File: ${file.name}`,
99
92
  id: file.id,
100
- ts: createdTime,
93
+ ts: Date.parse(file.createdTime),
101
94
  });
95
+ }
96
+ },
97
+ async processChanges() {
98
+ const lastFileCreatedTime = this._getLastFileCreatedTime();
99
+ const timeString = new Date(lastFileCreatedTime).toISOString();
102
100
 
103
- maxCreatedTime = Math.max(createdTime, maxCreatedTime);
104
- this._setLastFileCreatedTime(maxCreatedTime);
101
+ const { data } = await this.googleDrive.drive().files.list({
102
+ q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`,
103
+ orderBy: "createdTime desc",
104
+ fields: "*",
105
+ });
106
+
107
+ if (!data.files?.length) {
108
+ return;
105
109
  }
110
+
111
+ this.emitFiles(data.files);
112
+
113
+ this._setLastFileCreatedTime(Date.parse(data.files[0].createdTime));
106
114
  },
107
115
  },
108
116
  sampleEmit,