@pipedream/google_drive 1.0.3 → 1.0.5

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.
Files changed (38) hide show
  1. package/actions/add-file-sharing-preference/add-file-sharing-preference.mjs +1 -1
  2. package/actions/copy-file/copy-file.mjs +1 -1
  3. package/actions/create-file-from-template/create-file-from-template.mjs +1 -1
  4. package/actions/create-file-from-text/create-file-from-text.mjs +1 -1
  5. package/actions/create-folder/create-folder.mjs +3 -3
  6. package/actions/create-shared-drive/create-shared-drive.mjs +1 -1
  7. package/actions/delete-file/delete-file.mjs +1 -1
  8. package/actions/delete-shared-drive/delete-shared-drive.mjs +1 -1
  9. package/actions/download-file/download-file.mjs +3 -3
  10. package/actions/find-file/find-file.mjs +3 -3
  11. package/actions/find-folder/find-folder.mjs +2 -2
  12. package/actions/find-forms/find-forms.mjs +3 -3
  13. package/actions/find-spreadsheets/find-spreadsheets.mjs +3 -3
  14. package/actions/get-file-by-id/get-file-by-id.mjs +1 -1
  15. package/actions/get-folder-id-for-path/get-folder-id-for-path.mjs +1 -1
  16. package/actions/get-shared-drive/get-shared-drive.mjs +1 -1
  17. package/actions/list-access-proposals/list-access-proposals.mjs +1 -1
  18. package/actions/list-files/list-files.mjs +2 -2
  19. package/actions/move-file/move-file.mjs +1 -1
  20. package/actions/move-file-to-trash/move-file-to-trash.mjs +2 -2
  21. package/actions/resolve-access-proposal/resolve-access-proposal.mjs +2 -2
  22. package/actions/search-shared-drives/search-shared-drives.mjs +1 -1
  23. package/actions/update-file/update-file.mjs +3 -3
  24. package/actions/update-shared-drive/update-shared-drive.mjs +1 -1
  25. package/actions/upload-file/upload-file.mjs +7 -6
  26. package/common/utils.mjs +10 -4
  27. package/google_drive.app.mjs +31 -23
  28. package/package.json +1 -1
  29. package/sources/changes-to-specific-files/changes-to-specific-files.mjs +2 -2
  30. package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +2 -2
  31. package/sources/new-access-proposal/new-access-proposal.mjs +2 -2
  32. package/sources/new-files-instant/new-files-instant.mjs +3 -3
  33. package/sources/new-files-shared-drive/new-files-shared-drive.mjs +2 -2
  34. package/sources/new-or-modified-comments/new-or-modified-comments.mjs +2 -2
  35. package/sources/new-or-modified-files/new-or-modified-files.mjs +3 -3
  36. package/sources/new-or-modified-folders/new-or-modified-folders.mjs +68 -8
  37. package/sources/new-shared-drive/new-shared-drive.mjs +2 -2
  38. package/sources/new-spreadsheet/new-spreadsheet.mjs +1 -1
@@ -20,7 +20,7 @@ export default {
20
20
  name: "Share File or Folder",
21
21
  description:
22
22
  "Add a [sharing permission](https://support.google.com/drive/answer/7166529) to the sharing preferences of a file or folder and provide a sharing URL. [See the documentation](https://developers.google.com/drive/api/v3/reference/permissions/create)",
23
- version: "0.2.2",
23
+ version: "0.2.4",
24
24
  type: "action",
25
25
  props: {
26
26
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-copy-file",
5
5
  name: "Copy File",
6
6
  description: "Create a copy of the specified file. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/copy) for more information",
7
- version: "0.1.9",
7
+ version: "0.1.11",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -8,7 +8,7 @@ export default {
8
8
  key: "google_drive-create-file-from-template",
9
9
  name: "Create New File From Template",
10
10
  description: "Create a new Google Docs file from a template. Optionally include placeholders in the template document that will get replaced from this action. [See documentation](https://www.npmjs.com/package/google-docs-mustaches)",
11
- version: "0.1.9",
11
+ version: "0.1.11",
12
12
  type: "action",
13
13
  props: {
14
14
  googleDrive,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "google_drive-create-file-from-text",
6
6
  name: "Create New File From Text",
7
7
  description: "Create a new file from plain text. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
8
- version: "0.2.2",
8
+ version: "0.2.4",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -1,19 +1,19 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import {
3
2
  getListFilesOpts,
4
3
  toSingleLineString,
5
4
  } from "../../common/utils.mjs";
5
+ import googleDrive from "../../google_drive.app.mjs";
6
6
 
7
7
  import {
8
- MY_DRIVE_VALUE,
9
8
  GOOGLE_DRIVE_FOLDER_MIME_TYPE,
9
+ MY_DRIVE_VALUE,
10
10
  } from "../../common/constants.mjs";
11
11
 
12
12
  export default {
13
13
  key: "google_drive-create-folder",
14
14
  name: "Create Folder",
15
15
  description: "Create a new empty folder. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
16
- version: "0.1.10",
16
+ version: "0.1.12",
17
17
  type: "action",
18
18
  props: {
19
19
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-create-shared-drive",
5
5
  name: "Create Shared Drive",
6
6
  description: "Create a new shared drive. [See the documentation](https://developers.google.com/drive/api/v3/reference/drives/create) for more information",
7
- version: "0.1.10",
7
+ version: "0.1.12",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Delete File",
6
6
  description:
7
7
  "Permanently delete a file or folder without moving it to the trash. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/delete) for more information",
8
- version: "0.1.10",
8
+ version: "0.1.12",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-delete-shared-drive",
5
5
  name: "Delete Shared Drive",
6
6
  description: "Delete a shared drive without any content. [See the documentation](https://developers.google.com/drive/api/v3/reference/drives/delete) for more information",
7
- version: "0.1.9",
7
+ version: "0.1.11",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,10 +1,10 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import fs from "fs";
3
2
  import stream from "stream";
4
3
  import { promisify } from "util";
5
4
  import { GOOGLE_DRIVE_MIME_TYPE_PREFIX } from "../../common/constants.mjs";
6
- import googleWorkspaceExportFormats from "../common/google-workspace-export-formats.mjs";
7
5
  import { toSingleLineString } from "../../common/utils.mjs";
6
+ import googleDrive from "../../google_drive.app.mjs";
7
+ import googleWorkspaceExportFormats from "../common/google-workspace-export-formats.mjs";
8
8
 
9
9
  /**
10
10
  * Uses Google Drive API to download files to a `filePath` in the /tmp
@@ -18,7 +18,7 @@ export default {
18
18
  key: "google_drive-download-file",
19
19
  name: "Download File",
20
20
  description: "Download a file. [See the documentation](https://developers.google.com/drive/api/v3/manage-downloads) for more information",
21
- version: "0.1.12",
21
+ version: "0.1.14",
22
22
  type: "action",
23
23
  props: {
24
24
  googleDrive,
@@ -1,12 +1,12 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
- import { getListFilesOpts } from "../../common/utils.mjs";
3
1
  import commonSearchQuery from "../../common/commonSearchQuery.mjs";
2
+ import { getListFilesOpts } from "../../common/utils.mjs";
3
+ import googleDrive from "../../google_drive.app.mjs";
4
4
 
5
5
  export default {
6
6
  key: "google_drive-find-file",
7
7
  name: "Find File",
8
8
  description: "Search for a specific file by name. [See the documentation](https://developers.google.com/drive/api/v3/search-files) for more information",
9
- version: "0.1.9",
9
+ version: "0.1.11",
10
10
  type: "action",
11
11
  props: {
12
12
  googleDrive,
@@ -1,5 +1,5 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import { getListFilesOpts } from "../../common/utils.mjs";
2
+ import googleDrive from "../../google_drive.app.mjs";
3
3
 
4
4
  import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../common/constants.mjs";
5
5
 
@@ -7,7 +7,7 @@ export default {
7
7
  key: "google_drive-find-folder",
8
8
  name: "Find Folder",
9
9
  description: "Search for a specific folder by name. [See the documentation](https://developers.google.com/drive/api/v3/search-files) for more information",
10
- version: "0.1.9",
10
+ version: "0.1.11",
11
11
  type: "action",
12
12
  props: {
13
13
  googleDrive,
@@ -1,12 +1,12 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
- import { getListFilesOpts } from "../../common/utils.mjs";
3
1
  import commonSearchQuery from "../../common/commonSearchQuery.mjs";
2
+ import { getListFilesOpts } from "../../common/utils.mjs";
3
+ import googleDrive from "../../google_drive.app.mjs";
4
4
 
5
5
  export default {
6
6
  key: "google_drive-find-forms",
7
7
  name: "Find Forms",
8
8
  description: "List Google Form documents or search for a Form by name. [See the documentation](https://developers.google.com/drive/api/v3/search-files) for more information",
9
- version: "0.0.10",
9
+ version: "0.0.12",
10
10
  type: "action",
11
11
  props: {
12
12
  googleDrive,
@@ -1,12 +1,12 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
- import { getListFilesOpts } from "../../common/utils.mjs";
3
1
  import commonSearchQuery from "../../common/commonSearchQuery.mjs";
2
+ import { getListFilesOpts } from "../../common/utils.mjs";
3
+ import googleDrive from "../../google_drive.app.mjs";
4
4
 
5
5
  export default {
6
6
  key: "google_drive-find-spreadsheets",
7
7
  name: "Find Spreadsheets",
8
8
  description: "Search for a specific spreadsheet by name. [See the documentation](https://developers.google.com/drive/api/v3/search-files) for more information",
9
- version: "0.1.9",
9
+ version: "0.1.11",
10
10
  type: "action",
11
11
  props: {
12
12
  googleDrive,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "google_drive-get-file-by-id",
6
6
  name: "Get File By ID",
7
7
  description: "Get info on a specific file. [See the documentation](https://developers.google.com/drive/api/reference/rest/v3/files/get) for more information",
8
- version: "0.0.6",
8
+ version: "0.0.8",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -12,7 +12,7 @@ export default {
12
12
  key: "google_drive-get-folder-id-for-path",
13
13
  name: "Get Folder ID for a Path",
14
14
  description: "Retrieve a folderId for a path. [See the documentation](https://developers.google.com/drive/api/v3/search-files) for more information",
15
- version: "0.1.11",
15
+ version: "0.1.13",
16
16
  type: "action",
17
17
  props: {
18
18
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-get-shared-drive",
5
5
  name: "Get Shared Drive",
6
6
  description: "Get metadata for one or all shared drives. [See the documentation](https://developers.google.com/drive/api/v3/reference/drives/get) for more information",
7
- version: "0.1.9",
7
+ version: "0.1.11",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-list-access-proposals",
5
5
  name: "List Access Proposals",
6
6
  description: "List access proposals for a file or folder. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/accessproposals/list)",
7
- version: "0.0.2",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,11 +1,11 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import { getListFilesOpts } from "../../common/utils.mjs";
2
+ import googleDrive from "../../google_drive.app.mjs";
3
3
 
4
4
  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 documentation](https://developers.google.com/drive/api/v3/reference/files/list) for more information",
8
- version: "0.1.13",
8
+ version: "0.1.15",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-move-file",
5
5
  name: "Move File",
6
6
  description: "Move a file from one folder to another. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
7
- version: "0.1.9",
7
+ version: "0.1.11",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,11 +1,11 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../common/constants.mjs";
2
+ import googleDrive from "../../google_drive.app.mjs";
3
3
 
4
4
  export default {
5
5
  key: "google_drive-move-file-to-trash",
6
6
  name: "Move File to Trash",
7
7
  description: "Move a file or folder to trash. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
8
- version: "0.1.9",
8
+ version: "0.1.11",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -1,11 +1,11 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import { ConfigurationError } from "@pipedream/platform";
2
+ import googleDrive from "../../google_drive.app.mjs";
3
3
 
4
4
  export default {
5
5
  key: "google_drive-resolve-access-proposal",
6
6
  name: "Resolve Access Proposals",
7
7
  description: "Accept or deny a request for access to a file or folder in Google Drive. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/accessproposals/resolve)",
8
- version: "0.0.2",
8
+ version: "0.0.4",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-search-shared-drives",
5
5
  name: "Search for Shared Drives",
6
6
  description: "Search for shared drives with query options. [See the documentation](https://developers.google.com/drive/api/v3/search-shareddrives) for more information",
7
- version: "0.1.10",
7
+ version: "0.1.12",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,12 +1,12 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
- import { toSingleLineString } from "../../common/utils.mjs";
3
1
  import { getFileStream } from "@pipedream/platform";
2
+ import { toSingleLineString } from "../../common/utils.mjs";
3
+ import googleDrive from "../../google_drive.app.mjs";
4
4
 
5
5
  export default {
6
6
  key: "google_drive-update-file",
7
7
  name: "Update File",
8
8
  description: "Update a file's metadata and/or content. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
9
- version: "2.0.1",
9
+ version: "2.0.3",
10
10
  type: "action",
11
11
  props: {
12
12
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-update-shared-drive",
5
5
  name: "Update Shared Drive",
6
6
  description: "Update an existing shared drive. [See the documentation](https://developers.google.com/drive/api/v3/reference/drives/update) for more information",
7
- version: "0.1.9",
7
+ version: "0.1.11",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,18 +1,19 @@
1
- import googleDrive from "../../google_drive.app.mjs";
1
+ import {
2
+ ConfigurationError,
3
+ getFileStreamAndMetadata,
4
+ } from "@pipedream/platform";
5
+ import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs";
2
6
  import {
3
7
  omitEmptyStringValues,
4
8
  parseObjectEntries,
5
9
  } from "../../common/utils.mjs";
6
- import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs";
7
- import {
8
- getFileStreamAndMetadata, ConfigurationError,
9
- } from "@pipedream/platform";
10
+ import googleDrive from "../../google_drive.app.mjs";
10
11
 
11
12
  export default {
12
13
  key: "google_drive-upload-file",
13
14
  name: "Upload File",
14
15
  description: "Upload a file to Google Drive. [See the documentation](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
15
- version: "2.0.2",
16
+ version: "2.0.4",
16
17
  type: "action",
17
18
  props: {
18
19
  googleDrive,
package/common/utils.mjs CHANGED
@@ -104,7 +104,9 @@ function truncatePath(pathArr) {
104
104
  */
105
105
  function buildFilePaths(files = [], folders = []) {
106
106
  const folderIdToFolder = folders.reduce((acc, cur) => {
107
- acc[cur.id] = cur;
107
+ if (cur?.id) {
108
+ acc[cur.id] = cur;
109
+ }
108
110
  return acc;
109
111
  }, {});
110
112
  const paths = {};
@@ -112,7 +114,7 @@ function buildFilePaths(files = [], folders = []) {
112
114
  // requisite parent folders are available (in `file.parents`) to the requesting user, or an array
113
115
  // containing the file ID otherwise
114
116
  const pathToFile = (file) => {
115
- if (!file) {
117
+ if (!file?.id) {
116
118
  // unretrieved folder or root folder
117
119
  return [];
118
120
  }
@@ -139,7 +141,9 @@ function buildFilePaths(files = [], folders = []) {
139
141
  ];
140
142
  };
141
143
  files.forEach((file) => {
142
- paths[file.id] = pathToFile(file);
144
+ if (file?.id) {
145
+ paths[file.id] = pathToFile(file);
146
+ }
143
147
  });
144
148
  return paths;
145
149
  }
@@ -154,7 +158,9 @@ function buildFilePaths(files = [], folders = []) {
154
158
  */
155
159
  function buildFileNamePaths(files = [], folders = []) {
156
160
  const fileIdToFile = files.concat(folders).reduce((acc, cur) => {
157
- acc[cur.id] = cur;
161
+ if (cur?.id) {
162
+ acc[cur.id] = cur;
163
+ }
158
164
  return acc;
159
165
  }, {});
160
166
  const fileIdToPath = buildFilePaths(files, folders);
@@ -127,16 +127,18 @@ export default {
127
127
  return [];
128
128
  }
129
129
  let parentFolders = await Promise.all(
130
- file.parents.map((parentId) => this.getFile(parentId, {
130
+ (file.parents || []).map((parentId) => this.getFile(parentId, {
131
131
  fields: "id,name",
132
132
  })),
133
133
  );
134
- return parentFolders.map(({
135
- id, name,
136
- }) => ({
137
- value: id,
138
- label: name,
139
- }));
134
+ return parentFolders
135
+ .filter((folder) => folder?.id)
136
+ .map(({
137
+ id, name,
138
+ }) => ({
139
+ value: id,
140
+ label: name,
141
+ }));
140
142
  },
141
143
  },
142
144
  updateTypes: {
@@ -475,7 +477,7 @@ export default {
475
477
  },
476
478
  async _listDriveOptions(pageToken, myDrive = true) {
477
479
  const {
478
- drives,
480
+ drives = [],
479
481
  nextPageToken,
480
482
  } = await this.listDrivesInPage(pageToken);
481
483
 
@@ -493,10 +495,12 @@ export default {
493
495
  ]
494
496
  : [];
495
497
  for (const d of drives) {
496
- options.push({
497
- label: d.name,
498
- value: d.id,
499
- });
498
+ if (d?.id) {
499
+ options.push({
500
+ label: d.name,
501
+ value: d.id,
502
+ });
503
+ }
500
504
  }
501
505
  return {
502
506
  options,
@@ -546,16 +550,18 @@ export default {
546
550
  */
547
551
  async listFilesOptions(pageToken, extraOpts = {}) {
548
552
  const {
549
- files,
553
+ files = [],
550
554
  nextPageToken,
551
555
  } = await this.listFilesInPage(
552
556
  pageToken,
553
557
  extraOpts,
554
558
  );
555
- const options = files.map((file) => ({
556
- label: file.name,
557
- value: file.id,
558
- }));
559
+ const options = files
560
+ .filter((file) => file?.id)
561
+ .map((file) => ({
562
+ label: file.name,
563
+ value: file.id,
564
+ }));
559
565
  return {
560
566
  options,
561
567
  context: {
@@ -611,19 +617,21 @@ export default {
611
617
  opts,
612
618
  );
613
619
  const [
614
- { files: folders },
620
+ { files: folders = [] },
615
621
  {
616
- files, nextPageToken,
622
+ files = [], nextPageToken,
617
623
  },
618
624
  ] = await Promise.all([
619
625
  foldersPromise,
620
626
  filesPromise,
621
627
  ]);
622
628
  const filePaths = this.getFilePaths(files, folders);
623
- const options = files.map((file) => ({
624
- label: filePaths[file.id],
625
- value: file.id,
626
- }));
629
+ const options = files
630
+ .filter((file) => file?.id)
631
+ .map((file) => ({
632
+ label: filePaths[file.id],
633
+ value: file.id,
634
+ }));
627
635
  return {
628
636
  options,
629
637
  context: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -1,9 +1,9 @@
1
1
  import cronParser from "cron-parser";
2
- import sampleEmit from "./test-event.mjs";
3
2
  import includes from "lodash/includes.js";
4
3
  import { v4 as uuid } from "uuid";
5
4
  import { MY_DRIVE_VALUE } from "../../common/constants.mjs";
6
5
  import changesToSpecificFiles from "../changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs";
6
+ import sampleEmit from "./test-event.mjs";
7
7
 
8
8
  /**
9
9
  * This source uses the Google Drive API's
@@ -15,7 +15,7 @@ export default {
15
15
  key: "google_drive-changes-to-specific-files",
16
16
  name: "Changes to Specific Files",
17
17
  description: "Watches for changes to specific files, emitting an event when 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.",
18
- version: "0.2.6",
18
+ version: "0.2.8",
19
19
  type: "source",
20
20
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
21
21
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -11,8 +11,8 @@ import common from "../common-webhook.mjs";
11
11
  import sampleEmit from "./test-event.mjs";
12
12
 
13
13
  import {
14
- GOOGLE_DRIVE_NOTIFICATION_CHANGE,
15
14
  GOOGLE_DRIVE_NOTIFICATION_ADD,
15
+ GOOGLE_DRIVE_NOTIFICATION_CHANGE,
16
16
  GOOGLE_DRIVE_NOTIFICATION_UPDATE,
17
17
  } from "../../common/constants.mjs";
18
18
  import commonDedupeChanges from "../common-dedupe-changes.mjs";
@@ -27,7 +27,7 @@ export default {
27
27
  key: "google_drive-changes-to-specific-files-shared-drive",
28
28
  name: "Changes to Specific Files (Shared Drive)",
29
29
  description: "Watches for changes to specific files in a shared drive, emitting an event when a change is made to one of those files",
30
- version: "0.2.6",
30
+ version: "0.2.8",
31
31
  type: "source",
32
32
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
33
33
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -1,12 +1,12 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
2
+ import googleDrive from "../../google_drive.app.mjs";
3
3
  import sampleEmit from "./test-event.mjs";
4
4
 
5
5
  export default {
6
6
  key: "google_drive-new-access-proposal",
7
7
  name: "New Access Proposal",
8
8
  description: "Emit new event when a new access proposal is requested in Google Drive",
9
- version: "0.0.2",
9
+ version: "0.0.4",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  props: {
@@ -1,16 +1,16 @@
1
- import common from "../common-webhook.mjs";
2
- import sampleEmit from "./test-event.mjs";
3
1
  import {
4
2
  GOOGLE_DRIVE_NOTIFICATION_ADD,
5
3
  GOOGLE_DRIVE_NOTIFICATION_CHANGE,
6
4
  } from "../../common/constants.mjs";
5
+ import common from "../common-webhook.mjs";
6
+ import sampleEmit from "./test-event.mjs";
7
7
 
8
8
  export default {
9
9
  ...common,
10
10
  key: "google_drive-new-files-instant",
11
11
  name: "New Files (Instant)",
12
12
  description: "Emit new event when a new file is added in your linked Google Drive",
13
- version: "0.1.14",
13
+ version: "0.1.16",
14
14
  type: "source",
15
15
  dedupe: "unique",
16
16
  props: {
@@ -1,13 +1,13 @@
1
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
1
2
  import googleDrive from "../../google_drive.app.mjs";
2
3
  import sourceComponent from "../new-files-instant/new-files-instant.mjs";
3
4
  import sampleEmit from "../new-files-instant/test-event.mjs";
4
- import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
5
5
 
6
6
  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.0.3",
10
+ version: "0.0.5",
11
11
  type: "source",
12
12
  dedupe: "unique",
13
13
  props: {
@@ -8,8 +8,8 @@
8
8
  // 1) The HTTP requests tied to changes in the user's Google Drive
9
9
  // 2) A timer that runs on regular intervals, renewing the notification channel as needed
10
10
 
11
- import common from "../common-webhook.mjs";
12
11
  import { GOOGLE_DRIVE_NOTIFICATION_CHANGE } from "../../common/constants.mjs";
12
+ import common from "../common-webhook.mjs";
13
13
 
14
14
  export default {
15
15
  ...common,
@@ -17,7 +17,7 @@ export default {
17
17
  name: "New or Modified Comments (Instant)",
18
18
  description:
19
19
  "Emit new event when a comment is created or modified in the selected file",
20
- version: "1.0.5",
20
+ version: "1.0.7",
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
@@ -8,14 +8,14 @@
8
8
  // 1) The HTTP requests tied to changes in the user's Google Drive
9
9
  // 2) A timer that runs on regular intervals, renewing the notification channel as needed
10
10
 
11
- import common from "../common-webhook.mjs";
12
- import sampleEmit from "./test-event.mjs";
13
11
  import {
14
12
  GOOGLE_DRIVE_NOTIFICATION_ADD,
15
13
  GOOGLE_DRIVE_NOTIFICATION_CHANGE,
16
14
  GOOGLE_DRIVE_NOTIFICATION_UPDATE,
17
15
  } from "../../common/constants.mjs";
18
16
  import commonDedupeChanges from "../common-dedupe-changes.mjs";
17
+ import common from "../common-webhook.mjs";
18
+ import sampleEmit from "./test-event.mjs";
19
19
 
20
20
  const { googleDrive } = common.props;
21
21
 
@@ -24,7 +24,7 @@ export default {
24
24
  key: "google_drive-new-or-modified-files",
25
25
  name: "New or Modified Files (Instant)",
26
26
  description: "Emit new event when a file in the selected Drive is created, modified or trashed.",
27
- version: "0.3.6",
27
+ version: "0.3.8",
28
28
  type: "source",
29
29
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
30
30
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -8,23 +8,44 @@
8
8
  // 1) The HTTP requests tied to changes in the user's Google Drive
9
9
  // 2) A timer that runs on regular intervals, renewing the notification channel as needed
10
10
 
11
- import common from "../common-webhook.mjs";
12
11
  import {
13
12
  GOOGLE_DRIVE_NOTIFICATION_ADD,
14
13
  GOOGLE_DRIVE_NOTIFICATION_CHANGE,
15
14
  GOOGLE_DRIVE_NOTIFICATION_UPDATE,
16
15
  } from "../../common/constants.mjs";
16
+ import common from "../common-webhook.mjs";
17
17
 
18
18
  export default {
19
19
  ...common,
20
20
  key: "google_drive-new-or-modified-folders",
21
21
  name: "New or Modified Folders (Instant)",
22
22
  description: "Emit new event when a folder is created or modified in the selected Drive",
23
- version: "0.1.11",
23
+ version: "0.2.0",
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
27
27
  dedupe: "unique",
28
+ props: {
29
+ ...common.props,
30
+ folderId: {
31
+ propDefinition: [
32
+ common.props.googleDrive,
33
+ "folderId",
34
+ (c) => ({
35
+ drive: c.drive,
36
+ }),
37
+ ],
38
+ label: "Parent Folder",
39
+ description: "The ID of the parent folder which contains the folders. If not specified, it will watch all folders from the drive's top-level folder.",
40
+ optional: true,
41
+ },
42
+ includeSubfolders: {
43
+ type: "boolean",
44
+ label: "Include Subfolders",
45
+ description: "Whether to include subfolders of the parent folder in the changes.",
46
+ optional: true,
47
+ },
48
+ },
28
49
  hooks: {
29
50
  async deploy() {
30
51
  const daysAgo = new Date();
@@ -34,12 +55,11 @@ export default {
34
55
  const args = this.getListFilesOpts({
35
56
  q: `mimeType = "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
36
57
  fields: "files(id, mimeType)",
37
- pageSize: 5,
38
58
  });
39
59
 
40
60
  const { files } = await this.googleDrive.listFilesInPage(null, args);
41
61
 
42
- await this.processChanges(files);
62
+ await this.processChanges(files, null, 5);
43
63
  },
44
64
  ...common.hooks,
45
65
  },
@@ -58,6 +78,24 @@ export default {
58
78
  GOOGLE_DRIVE_NOTIFICATION_UPDATE,
59
79
  ];
60
80
  },
81
+ async getAllParents(folderId) {
82
+ const allParents = [];
83
+ let currentId = folderId;
84
+
85
+ while (currentId) {
86
+ const folder = await this.googleDrive.getFile(currentId, {
87
+ fields: "parents",
88
+ });
89
+ const parents = folder.parents;
90
+
91
+ if (parents && parents.length > 0) {
92
+ allParents.push(parents[0]);
93
+ }
94
+ currentId = parents?.[0];
95
+ }
96
+
97
+ return allParents;
98
+ },
61
99
  generateMeta(data, ts) {
62
100
  const {
63
101
  id: fileId,
@@ -86,29 +124,51 @@ export default {
86
124
  },
87
125
  };
88
126
  },
89
- async processChanges(changedFiles, headers) {
127
+ async processChanges(changedFiles, headers, maxResults) {
90
128
  const files = changedFiles.filter(
91
129
  // API docs that define Google Drive folders:
92
130
  // https://developers.google.com/drive/api/v3/folder
93
131
  (file) => file.mimeType === "application/vnd.google-apps.folder",
94
132
  );
95
133
 
134
+ const filteredFiles = [];
96
135
  for (const file of files) {
97
136
  // The changelog is updated each time a folder is opened. Check the
98
137
  // folder's `modifiedTime` to see if the folder has been modified.
99
138
  const fileInfo = await this.googleDrive.getFile(file.id);
139
+ const root = await this.googleDrive.getFile(this.drive === "My Drive"
140
+ ? "root"
141
+ : this.drive);
142
+
143
+ const allParents = [];
144
+ if (this.includeSubfolders) {
145
+ allParents.push(...(await this.getAllParents(file.id)));
146
+ } else {
147
+ allParents.push(fileInfo.parents[0]);
148
+ }
149
+
150
+ if (!allParents.includes(this.folderId || root.id)) {
151
+ continue;
152
+ }
100
153
 
154
+ filteredFiles.push(fileInfo);
155
+ }
156
+
157
+ if (maxResults && filteredFiles.length >= maxResults) {
158
+ filteredFiles.length = maxResults;
159
+ }
160
+ for (const file of filteredFiles) {
101
161
  const lastModifiedTimeForFile = this._getLastModifiedTimeForFile(file.id);
102
- const modifiedTime = Date.parse(fileInfo.modifiedTime);
162
+ const modifiedTime = Date.parse(file.modifiedTime);
103
163
  if (lastModifiedTimeForFile == modifiedTime) continue;
104
164
 
105
165
  const changes = await this.getChanges(headers);
106
166
 
107
167
  const eventToEmit = {
108
- file: fileInfo,
168
+ file,
109
169
  ...changes,
110
170
  };
111
- const meta = this.generateMeta(fileInfo, modifiedTime);
171
+ const meta = this.generateMeta(file, modifiedTime);
112
172
 
113
173
  this.$emit(eventToEmit, meta);
114
174
 
@@ -1,11 +1,11 @@
1
- import googleDrive from "../../google_drive.app.mjs";
2
1
  import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
2
+ import googleDrive from "../../google_drive.app.mjs";
3
3
 
4
4
  export default {
5
5
  key: "google_drive-new-shared-drive",
6
6
  name: "New Shared Drive",
7
7
  description: "Emits a new event any time a shared drive is created.",
8
- version: "0.1.9",
8
+ version: "0.1.11",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -6,7 +6,7 @@ export default {
6
6
  type: "source",
7
7
  name: "New Spreadsheet (Instant)",
8
8
  description: "Emit new event when a new spreadsheet is created in a drive.",
9
- version: "0.1.11",
9
+ version: "0.1.13",
10
10
  props: {
11
11
  googleDrive: newFilesInstant.props.googleDrive,
12
12
  db: newFilesInstant.props.db,