@pipedream/google_drive 0.6.12 → 0.6.14

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.
@@ -4,8 +4,8 @@ import { getListFilesOpts } from "../../common/utils.mjs";
4
4
  export default {
5
5
  key: "google_drive-list-files",
6
6
  name: "List Files",
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.3",
7
+ description: "List files from a specific folder. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/list) for more information",
8
+ version: "0.1.4",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -67,8 +67,16 @@ export default {
67
67
  if (this.fields) {
68
68
  opts.fields = this.fields;
69
69
  }
70
- const files = (await this.googleDrive.listFilesInPage(null, opts)).files;
71
- $.export("$summary", `Successfully found ${files.length} file(s).`);
72
- return files;
70
+ const allFiles = [];
71
+ let pageToken;
72
+ do {
73
+ const {
74
+ files, nextPageToken,
75
+ } = await this.googleDrive.listFilesInPage(pageToken, opts);
76
+ allFiles.push(...files);
77
+ pageToken = nextPageToken;
78
+ } while (pageToken);
79
+ $.export("$summary", `Successfully found ${allFiles.length} file(s).`);
80
+ return allFiles;
73
81
  },
74
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "0.6.12",
3
+ "version": "0.6.14",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -12,6 +12,8 @@
12
12
  "dependencies": {
13
13
  "@googleapis/drive": "^2.3.0",
14
14
  "@pipedream/platform": "^1.4.0",
15
+ "cron-parser": "^4.9.0",
16
+ "lodash": "^4.17.21",
15
17
  "mime-db": "^1.51.0",
16
18
  "uuid": "^8.3.2"
17
19
  },
@@ -17,7 +17,7 @@ export default {
17
17
  key: "google_drive-changes-to-specific-files",
18
18
  name: "Changes to Specific Files",
19
19
  description: "Watches for changes to specific files, emitting an event any time a change is made to one of those files. To watch for changes to [shared drive](https://support.google.com/a/users/answer/9310351) files, use the **Changes to Specific Files (Shared Drive)** source instead.",
20
- version: "0.1.2",
20
+ version: "0.1.3",
21
21
  type: "source",
22
22
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
23
23
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -26,7 +26,7 @@ export default {
26
26
  key: "google_drive-changes-to-specific-files-shared-drive",
27
27
  name: "Changes to Specific Files (Shared Drive)",
28
28
  description: "Watches for changes to specific files in a shared drive, emitting an event any time a change is made to one of those files",
29
- version: "0.1.2",
29
+ version: "0.1.3",
30
30
  type: "source",
31
31
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
32
32
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -41,7 +41,7 @@ export default {
41
41
  default: [],
42
42
  options({ prevContext }) {
43
43
  const { nextPageToken } = prevContext;
44
- return this.googleDrive.listFilesOptions(nextPageToken, this.getFilesOpts());
44
+ return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
45
45
  },
46
46
  },
47
47
  },
@@ -51,14 +51,14 @@ export default {
51
51
  daysAgo.setDate(daysAgo.getDate() - 30);
52
52
  const timeString = daysAgo.toISOString();
53
53
 
54
- const args = this.getFilesOpts({
54
+ const args = this.getListFilesOpts({
55
55
  q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
56
56
  fields: "files",
57
57
  });
58
58
 
59
- const { data } = await this.googleDrive.drive().files.list(args);
59
+ const { files } = await this.googleDrive.listFilesInPage(null, args);
60
60
 
61
- this.processChanges(data.files);
61
+ this.processChanges(files);
62
62
  },
63
63
  ...common.hooks,
64
64
  },
@@ -3,6 +3,7 @@ import { v4 as uuid } from "uuid";
3
3
 
4
4
  import googleDrive from "../google_drive.app.mjs";
5
5
  import { WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS } from "../constants.mjs";
6
+ import { getListFilesOpts } from "../common/utils.mjs";
6
7
 
7
8
  export default {
8
9
  props: {
@@ -96,20 +97,11 @@ export default {
96
97
  getDriveId(drive = this.drive) {
97
98
  return googleDrive.methods.getDriveId(drive);
98
99
  },
99
- getFilesOpts(args = {}) {
100
- const opts = {
100
+ getListFilesOpts(args = {}) {
101
+ return getListFilesOpts(this.drive, {
101
102
  q: "mimeType != 'application/vnd.google-apps.folder' and trashed = false",
102
103
  ...args,
103
- };
104
- return this.isMyDrive()
105
- ? opts
106
- : {
107
- ...opts,
108
- corpora: "drive",
109
- driveId: this.getDriveId(),
110
- includeItemsFromAllDrives: true,
111
- supportsAllDrives: true,
112
- };
104
+ });
113
105
  },
114
106
  /**
115
107
  * This method returns the types of updates/events from Google Drive that
@@ -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.3",
13
+ version: "0.1.4",
14
14
  type: "source",
15
15
  dedupe: "unique",
16
16
  props: {
@@ -46,14 +46,16 @@ export default {
46
46
  daysAgo.setDate(daysAgo.getDate() - 30);
47
47
  const timeString = daysAgo.toISOString();
48
48
 
49
- const { data } = await this.googleDrive.drive().files.list({
49
+ const args = this.getListFilesOpts({
50
50
  q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`,
51
51
  orderBy: "createdTime desc",
52
52
  fields: "*",
53
53
  pageSize: 25,
54
54
  });
55
55
 
56
- this.emitFiles(data.files);
56
+ const { files } = await this.googleDrive.listFilesInPage(null, args);
57
+
58
+ this.emitFiles(files);
57
59
  },
58
60
  ...common.hooks,
59
61
  async activate() {
@@ -98,19 +100,21 @@ export default {
98
100
  const lastFileCreatedTime = this._getLastFileCreatedTime();
99
101
  const timeString = new Date(lastFileCreatedTime).toISOString();
100
102
 
101
- const { data } = await this.googleDrive.drive().files.list({
103
+ const args = this.getListFilesOpts({
102
104
  q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`,
103
105
  orderBy: "createdTime desc",
104
106
  fields: "*",
105
107
  });
106
108
 
107
- if (!data.files?.length) {
109
+ const { files } = await this.googleDrive.listFilesInPage(null, args);
110
+
111
+ if (!files?.length) {
108
112
  return;
109
113
  }
110
114
 
111
- this.emitFiles(data.files);
115
+ this.emitFiles(files);
112
116
 
113
- this._setLastFileCreatedTime(Date.parse(data.files[0].createdTime));
117
+ this._setLastFileCreatedTime(Date.parse(files[0].createdTime));
114
118
  },
115
119
  },
116
120
  sampleEmit,
@@ -17,8 +17,7 @@ export default {
17
17
  name: "New or Modified Comments",
18
18
  description:
19
19
  "Emits a new event any time a file comment is added, modified, or deleted in your linked Google Drive",
20
- // version: "0.1.1",
21
- version: "0.1.3",
20
+ version: "0.1.4",
22
21
  type: "source",
23
22
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
24
23
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -29,14 +28,14 @@ export default {
29
28
  daysAgo.setDate(daysAgo.getDate() - 30);
30
29
  const timeString = daysAgo.toISOString();
31
30
 
32
- const args = this.getFilesOpts({
31
+ const args = this.getListFilesOpts({
33
32
  q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
34
33
  fields: "files",
35
34
  });
36
35
 
37
- const { data } = await this.googleDrive.drive().files.list(args);
36
+ const { files } = await this.googleDrive.listFilesInPage(null, args);
38
37
 
39
- await this.processChanges(data.files);
38
+ await this.processChanges(files);
40
39
  },
41
40
  async activate() {
42
41
  await common.hooks.activate.bind(this)();
@@ -21,7 +21,7 @@ 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.2",
24
+ version: "0.1.3",
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
@@ -32,12 +32,14 @@ export default {
32
32
  daysAgo.setDate(daysAgo.getDate() - 30);
33
33
  const timeString = daysAgo.toISOString();
34
34
 
35
- const { data } = await this.googleDrive.drive().files.list({
35
+ const args = this.getListFilesOpts({
36
36
  q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
37
37
  fields: "files",
38
38
  });
39
39
 
40
- await this.processChanges(data.files);
40
+ const { files } = await this.googleDrive.listFilesInPage(null, args);
41
+
42
+ await this.processChanges(files);
41
43
  },
42
44
  ...common.hooks,
43
45
  },
@@ -20,7 +20,7 @@ export default {
20
20
  key: "google_drive-new-or-modified-folders",
21
21
  name: "New or Modified Folders",
22
22
  description: "Emit new event any time any folder in your linked Google Drive is added, modified, or deleted",
23
- version: "0.1.1",
23
+ version: "0.1.2",
24
24
  type: "source",
25
25
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
26
26
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -31,12 +31,14 @@ export default {
31
31
  daysAgo.setDate(daysAgo.getDate() - 30);
32
32
  const timeString = daysAgo.toISOString();
33
33
 
34
- const { data } = await this.googleDrive.drive().files.list({
34
+ const args = this.getListFilesOpts({
35
35
  q: `mimeType = "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
36
36
  fields: "files(id, mimeType)",
37
37
  });
38
38
 
39
- await this.processChanges(data.files);
39
+ const { files } = await this.googleDrive.listFilesInPage(null, args);
40
+
41
+ await this.processChanges(files);
40
42
  },
41
43
  ...common.hooks,
42
44
  },
@@ -6,7 +6,7 @@ export default {
6
6
  type: "source",
7
7
  name: "New Spreadsheet (Instant)",
8
8
  description: "Emit new event each time a new spreadsheet is created in a drive.",
9
- version: "0.1.1",
9
+ version: "0.1.2",
10
10
  props: {
11
11
  googleDrive: newFilesInstant.props.googleDrive,
12
12
  db: newFilesInstant.props.db,