@pipedream/google_drive 1.0.6 → 1.0.7

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 (43) hide show
  1. package/actions/add-comment/add-comment.mjs +1 -1
  2. package/actions/add-file-sharing-preference/add-file-sharing-preference.mjs +1 -1
  3. package/actions/copy-file/copy-file.mjs +1 -1
  4. package/actions/create-file-from-template/create-file-from-template.mjs +1 -1
  5. package/actions/create-file-from-text/create-file-from-text.mjs +1 -1
  6. package/actions/create-folder/create-folder.mjs +1 -1
  7. package/actions/create-shared-drive/create-shared-drive.mjs +1 -1
  8. package/actions/delete-comment/delete-comment.mjs +1 -1
  9. package/actions/delete-file/delete-file.mjs +1 -1
  10. package/actions/delete-shared-drive/delete-shared-drive.mjs +1 -1
  11. package/actions/download-file/download-file.mjs +1 -1
  12. package/actions/find-file/find-file.mjs +1 -1
  13. package/actions/find-folder/find-folder.mjs +1 -1
  14. package/actions/find-forms/find-forms.mjs +1 -1
  15. package/actions/find-spreadsheets/find-spreadsheets.mjs +1 -1
  16. package/actions/get-file-by-id/get-file-by-id.mjs +1 -1
  17. package/actions/get-folder-id-for-path/get-folder-id-for-path.mjs +1 -1
  18. package/actions/get-shared-drive/get-shared-drive.mjs +1 -1
  19. package/actions/list-access-proposals/list-access-proposals.mjs +1 -1
  20. package/actions/list-comments/list-comments.mjs +1 -1
  21. package/actions/list-files/list-files.mjs +1 -1
  22. package/actions/move-file/move-file.mjs +1 -1
  23. package/actions/move-file-to-trash/move-file-to-trash.mjs +1 -1
  24. package/actions/reply-to-comment/reply-to-comment.mjs +1 -1
  25. package/actions/resolve-access-proposal/resolve-access-proposal.mjs +1 -1
  26. package/actions/resolve-comment/resolve-comment.mjs +1 -1
  27. package/actions/search-shared-drives/search-shared-drives.mjs +1 -1
  28. package/actions/update-file/update-file.mjs +1 -1
  29. package/actions/update-shared-drive/update-shared-drive.mjs +1 -1
  30. package/actions/upload-file/upload-file.mjs +1 -1
  31. package/common/utils.mjs +40 -0
  32. package/package.json +1 -1
  33. package/sources/changes-to-specific-files/changes-to-specific-files.mjs +14 -2
  34. package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +21 -5
  35. package/sources/new-access-proposal/new-access-proposal.mjs +1 -1
  36. package/sources/new-files-instant/new-files-instant.mjs +20 -4
  37. package/sources/new-files-shared-drive/new-files-shared-drive.mjs +13 -1
  38. package/sources/new-or-modified-comments/new-or-modified-comments.mjs +1 -1
  39. package/sources/new-or-modified-files/new-or-modified-files.mjs +17 -1
  40. package/sources/new-or-modified-files/test-event.mjs +1 -1
  41. package/sources/new-or-modified-folders/new-or-modified-folders.mjs +1 -1
  42. package/sources/new-shared-drive/new-shared-drive.mjs +1 -1
  43. package/sources/new-spreadsheet/new-spreadsheet.mjs +1 -1
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-add-comment",
5
5
  name: "Add Comment",
6
6
  description: "Add an unanchored comment to a Google Doc (general feedback, no text highlighting). [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/comments/create)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -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.5",
23
+ version: "0.2.6",
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.12",
7
+ version: "0.1.13",
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.12",
11
+ version: "0.1.13",
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.5",
8
+ version: "0.2.6",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -13,7 +13,7 @@ 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.13",
16
+ version: "0.1.14",
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.13",
7
+ version: "0.1.14",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-delete-comment",
5
5
  name: "Delete Comment",
6
6
  description: "Delete a specific comment (Requires ownership or permissions). [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/comments/delete)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
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.13",
8
+ version: "0.1.14",
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.12",
7
+ version: "0.1.13",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -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.15",
21
+ version: "0.1.16",
22
22
  type: "action",
23
23
  props: {
24
24
  googleDrive,
@@ -6,7 +6,7 @@ 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.12",
9
+ version: "0.1.13",
10
10
  type: "action",
11
11
  props: {
12
12
  googleDrive,
@@ -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.12",
10
+ version: "0.1.13",
11
11
  type: "action",
12
12
  props: {
13
13
  googleDrive,
@@ -6,7 +6,7 @@ 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.13",
9
+ version: "0.0.14",
10
10
  type: "action",
11
11
  props: {
12
12
  googleDrive,
@@ -6,7 +6,7 @@ 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.12",
9
+ version: "0.1.13",
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.9",
8
+ version: "0.0.10",
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.14",
15
+ version: "0.1.15",
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.12",
7
+ version: "0.1.13",
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.5",
7
+ version: "0.0.6",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-list-comments",
5
5
  name: "List Comments",
6
6
  description: "List all comments on a file. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/comments/list)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -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 documentation](https://developers.google.com/drive/api/v3/reference/files/list) for more information",
8
- version: "0.1.16",
8
+ version: "0.1.17",
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.12",
7
+ version: "0.1.13",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -5,7 +5,7 @@ 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.12",
8
+ version: "0.1.13",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-reply-to-comment",
5
5
  name: "Reply to Comment",
6
6
  description: "Add a reply to an existing comment. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/replies/create)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -5,7 +5,7 @@ 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.5",
8
+ version: "0.0.6",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "google_drive-resolve-comment",
5
5
  name: "Resolve Comment",
6
6
  description: "Mark a comment as resolved. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/comments/update)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  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.13",
7
+ version: "0.1.14",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -6,7 +6,7 @@ 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.4",
9
+ version: "2.0.5",
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.12",
7
+ version: "0.1.13",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -13,7 +13,7 @@ export default {
13
13
  key: "google_drive-upload-file",
14
14
  name: "Upload File",
15
15
  description: "Upload a file to Google Drive. [See the documentation](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
16
- version: "2.0.5",
16
+ version: "2.0.6",
17
17
  type: "action",
18
18
  props: {
19
19
  googleDrive,
package/common/utils.mjs CHANGED
@@ -3,7 +3,9 @@ import {
3
3
  MY_DRIVE_VALUE,
4
4
  LEGACY_MY_DRIVE_VALUE,
5
5
  MAX_FILE_OPTION_PATH_SEGMENTS,
6
+ GOOGLE_DRIVE_MIME_TYPE_PREFIX,
6
7
  } from "../common/constants.mjs";
8
+ import { Readable } from "stream";
7
9
 
8
10
  /**
9
11
  * Returns whether the specified drive ID corresponds to the authenticated
@@ -264,6 +266,43 @@ function parseObjectEntries(value = {}) {
264
266
  );
265
267
  }
266
268
 
269
+ async function stashFile(item, googleDrive, dir) {
270
+ const fileMetadata = await googleDrive.getFile(item.id, {
271
+ fields: "name,mimeType",
272
+ });
273
+ let mimeType = fileMetadata.mimeType;
274
+ const isWorkspaceDocument = mimeType.includes(GOOGLE_DRIVE_MIME_TYPE_PREFIX);
275
+ if (isWorkspaceDocument) {
276
+ mimeType = "application/pdf";
277
+ }
278
+ const response = isWorkspaceDocument
279
+ ? await googleDrive.downloadWorkspaceFile(item.id, {
280
+ mimeType,
281
+ })
282
+ : await googleDrive.getFile(item.id, {
283
+ alt: "media",
284
+ });
285
+ // Convert stream to buffer
286
+ const chunks = [];
287
+ for await (const chunk of response) {
288
+ chunks.push(chunk);
289
+ }
290
+ const buffer = Buffer.concat(chunks);
291
+ // Construct a file path unique to this attachment to avoid overwriting
292
+ // files with the same name.
293
+ const filepath = `${item.id}/${item.name}`;
294
+ // Upload the attachment to the configured directory (File Stash) so it
295
+ // can be accessed later.
296
+ const file = await dir.open(filepath).fromReadableStream(
297
+ Readable.from(buffer),
298
+ mimeType,
299
+ buffer.length,
300
+ );
301
+ // Return file details and temporary download link:
302
+ // { path, get_url, s3Key, type }
303
+ return await file.withoutPutUrl().withGetUrl();
304
+ }
305
+
267
306
  export {
268
307
  MY_DRIVE_VALUE,
269
308
  isMyDrive,
@@ -276,4 +315,5 @@ export {
276
315
  streamToBuffer,
277
316
  byteToMB,
278
317
  parseObjectEntries,
318
+ stashFile,
279
319
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -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.9",
18
+ version: "0.3.0",
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
@@ -35,6 +35,18 @@ export default {
35
35
  "updateTypes",
36
36
  ],
37
37
  },
38
+ includeLink: {
39
+ label: "Include Link",
40
+ type: "boolean",
41
+ description: "Upload file to your File Stash and emit temporary download link to the file. Google Workspace documents will be converted to PDF. See [the docs](https://pipedream.com/docs/connect/components/files) to learn more about working with files in Pipedream.",
42
+ default: false,
43
+ optional: true,
44
+ },
45
+ dir: {
46
+ type: "dir",
47
+ accessMode: "write",
48
+ optional: true,
49
+ },
38
50
  },
39
51
  hooks: {
40
52
  ...changesToSpecificFiles.hooks,
@@ -226,7 +238,7 @@ export default {
226
238
  file,
227
239
  ]);
228
240
  if (checkedFile) {
229
- this.processChange(file, headers);
241
+ await this.processChange(file, headers);
230
242
  }
231
243
  },
232
244
  sampleEmit,
@@ -16,6 +16,7 @@ import {
16
16
  GOOGLE_DRIVE_NOTIFICATION_UPDATE,
17
17
  } from "../../common/constants.mjs";
18
18
  import commonDedupeChanges from "../common-dedupe-changes.mjs";
19
+ import { stashFile } from "../../common/utils.mjs";
19
20
 
20
21
  /**
21
22
  * This source uses the Google Drive API's
@@ -27,7 +28,7 @@ export default {
27
28
  key: "google_drive-changes-to-specific-files-shared-drive",
28
29
  name: "Changes to Specific Files (Shared Drive)",
29
30
  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.9",
31
+ version: "0.3.0",
31
32
  type: "source",
32
33
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
33
34
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -43,6 +44,18 @@ export default {
43
44
  return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
44
45
  },
45
46
  },
47
+ includeLink: {
48
+ label: "Include Link",
49
+ type: "boolean",
50
+ description: "Upload file to your File Stash and emit temporary download link to the file. Google Workspace documents will be converted to PDF. See [the docs](https://pipedream.com/docs/connect/components/files) to learn more about working with files in Pipedream.",
51
+ default: false,
52
+ optional: true,
53
+ },
54
+ dir: {
55
+ type: "dir",
56
+ accessMode: "write",
57
+ optional: true,
58
+ },
46
59
  ...commonDedupeChanges.props,
47
60
  },
48
61
  hooks: {
@@ -59,7 +72,7 @@ export default {
59
72
 
60
73
  const { files } = await this.googleDrive.listFilesInPage(null, args);
61
74
 
62
- this.processChanges(files);
75
+ await this.processChanges(files);
63
76
  },
64
77
  ...common.hooks,
65
78
  },
@@ -109,8 +122,11 @@ export default {
109
122
  },
110
123
  };
111
124
  },
112
- processChange(file, headers) {
125
+ async processChange(file, headers) {
113
126
  const changes = this.getChanges(headers);
127
+ if (this.includeLink) {
128
+ file.file = await stashFile(file, this.googleDrive, this.dir);
129
+ }
114
130
  const eventToEmit = {
115
131
  file,
116
132
  ...changes,
@@ -118,7 +134,7 @@ export default {
118
134
  const meta = this.generateMeta(file, headers);
119
135
  this.$emit(eventToEmit, meta);
120
136
  },
121
- processChanges(changedFiles, headers) {
137
+ async processChanges(changedFiles, headers) {
122
138
  console.log(`Processing ${changedFiles.length} changed files`);
123
139
  console.log(`Changed files: ${JSON.stringify(changedFiles, null, 2)}!!!`);
124
140
  console.log(`Files: ${this.files}!!!`);
@@ -129,7 +145,7 @@ export default {
129
145
  console.log(`Skipping event for irrelevant file ${file.id}`);
130
146
  continue;
131
147
  }
132
- this.processChange(file, headers);
148
+ await this.processChange(file, headers);
133
149
  }
134
150
  },
135
151
  },
@@ -6,7 +6,7 @@ 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.5",
9
+ version: "0.0.6",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  props: {
@@ -3,6 +3,7 @@ import {
3
3
  GOOGLE_DRIVE_NOTIFICATION_CHANGE,
4
4
  } from "../../common/constants.mjs";
5
5
  import common from "../common-webhook.mjs";
6
+ import { stashFile } from "../../common/utils.mjs";
6
7
  import sampleEmit from "./test-event.mjs";
7
8
 
8
9
  export default {
@@ -10,7 +11,7 @@ export default {
10
11
  key: "google_drive-new-files-instant",
11
12
  name: "New Files (Instant)",
12
13
  description: "Emit new event when a new file is added in your linked Google Drive",
13
- version: "0.1.17",
14
+ version: "0.2.0",
14
15
  type: "source",
15
16
  dedupe: "unique",
16
17
  props: {
@@ -46,6 +47,18 @@ export default {
46
47
  return this.googleDrive.listFilesOptions(nextPageToken, opts);
47
48
  },
48
49
  },
50
+ includeLink: {
51
+ label: "Include Link",
52
+ type: "boolean",
53
+ description: "Upload file to your File Stash and emit temporary download link to the file. Google Workspace documents will be converted to PDF. See [the docs](https://pipedream.com/docs/connect/components/files) to learn more about working with files in Pipedream.",
54
+ default: false,
55
+ optional: true,
56
+ },
57
+ dir: {
58
+ type: "dir",
59
+ accessMode: "write",
60
+ optional: true,
61
+ },
49
62
  },
50
63
  hooks: {
51
64
  async deploy() {
@@ -62,7 +75,7 @@ export default {
62
75
 
63
76
  const { files } = await this.googleDrive.listFilesInPage(null, args);
64
77
 
65
- this.emitFiles(files);
78
+ await this.emitFiles(files);
66
79
  },
67
80
  ...common.hooks,
68
81
  async activate() {
@@ -91,11 +104,14 @@ export default {
91
104
  GOOGLE_DRIVE_NOTIFICATION_CHANGE,
92
105
  ];
93
106
  },
94
- emitFiles(files) {
107
+ async emitFiles(files) {
95
108
  for (const file of files) {
96
109
  if (!this.shouldProcess(file)) {
97
110
  continue;
98
111
  }
112
+ if (this.includeLink) {
113
+ file.file = await stashFile(file, this.googleDrive, this.dir);
114
+ }
99
115
  this.$emit(file, {
100
116
  summary: `New File: ${file.name}`,
101
117
  id: file.id,
@@ -119,7 +135,7 @@ export default {
119
135
  return;
120
136
  }
121
137
 
122
- this.emitFiles(files);
138
+ await this.emitFiles(files);
123
139
 
124
140
  this._setLastFileCreatedTime(Date.parse(files[0].createdTime));
125
141
  },
@@ -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.0.6",
10
+ version: "0.1.0",
11
11
  type: "source",
12
12
  dedupe: "unique",
13
13
  props: {
@@ -30,6 +30,18 @@ export default {
30
30
  optional: false,
31
31
  },
32
32
  folders: sourceComponent.props.folders,
33
+ includeLink: {
34
+ label: "Include Link",
35
+ type: "boolean",
36
+ description: "Upload file to your File Stash and emit temporary download link to the file. Google Workspace documents will be converted to PDF. See [the docs](https://pipedream.com/docs/connect/components/files) to learn more about working with files in Pipedream.",
37
+ default: false,
38
+ optional: true,
39
+ },
40
+ dir: {
41
+ type: "dir",
42
+ accessMode: "write",
43
+ optional: true,
44
+ },
33
45
  },
34
46
  hooks: {
35
47
  async deploy() {
@@ -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.8",
20
+ version: "1.0.9",
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
@@ -15,6 +15,7 @@ import {
15
15
  } from "../../common/constants.mjs";
16
16
  import commonDedupeChanges from "../common-dedupe-changes.mjs";
17
17
  import common from "../common-webhook.mjs";
18
+ import { stashFile } from "../../common/utils.mjs";
18
19
  import sampleEmit from "./test-event.mjs";
19
20
 
20
21
  const { googleDrive } = common.props;
@@ -24,7 +25,7 @@ export default {
24
25
  key: "google_drive-new-or-modified-files",
25
26
  name: "New or Modified Files (Instant)",
26
27
  description: "Emit new event when a file in the selected Drive is created, modified or trashed.",
27
- version: "0.3.9",
28
+ version: "0.4.0",
28
29
  type: "source",
29
30
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
30
31
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -61,6 +62,18 @@ export default {
61
62
  "watchForPropertiesChanges",
62
63
  ],
63
64
  },
65
+ includeLink: {
66
+ label: "Include Link",
67
+ type: "boolean",
68
+ description: "Upload file to your File Stash and emit temporary download link to the file. Google Workspace documents will be converted to PDF. See [the docs](https://pipedream.com/docs/connect/components/files) to learn more about working with files in Pipedream.",
69
+ default: false,
70
+ optional: true,
71
+ },
72
+ dir: {
73
+ type: "dir",
74
+ accessMode: "write",
75
+ optional: true,
76
+ },
64
77
  ...commonDedupeChanges.props,
65
78
  },
66
79
  hooks: {
@@ -152,6 +165,9 @@ export default {
152
165
  file,
153
166
  ...changes,
154
167
  };
168
+ if (this.includeLink) {
169
+ eventToEmit.fileURL = await stashFile(file, this.googleDrive, this.dir);
170
+ }
155
171
  const meta = this.generateMeta(file, headers);
156
172
  this.$emit(eventToEmit, meta);
157
173
  }
@@ -1 +1 @@
1
- export default JSON.parse("{\n \"file\": {\n \"kind\": \"drive#file\",\n \"copyRequiresWriterPermission\": false,\n \"writersCanShare\": true,\n \"viewedByMe\": true,\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\",\n \"exportLinks\": {\n \"application/x-vnd.oasis.opendocument.spreadsheet\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmw4&exportFormat=ods\",\n \"text/tab-separated-values\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXnViTOo&exportFormat=tsv\",\n \"application/pdf\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaBViTOo&exportFormat=pdf\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbOo&exportFormat=xlsx\",\n \"text/csv\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbBViTOo&exportFormat=csv\",\n \"application/zip\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-VbTmw4Pt2BViTOo&exportFormat=zip\",\n \"application/vnd.oasis.opendocument.spreadsheet\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbViTOo&exportFormat=ods\"\n },\n \"parents\": [\n \"0ANs73yKKVA\"\n ],\n \"thumbnailLink\": \"https://docs.google.com/feeds/vt?gd=true&id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmw4&v=12&s=AMedNnoAAAAAZKWjrEqscucFpYCyRCJqnd0wtBiDtXYh&sz=s220\",\n \"iconLink\": \"https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet\",\n \"shared\": false,\n \"lastModifyingUser\": {\n \"displayName\": \"John Doe\",\n \"kind\": \"drive#user\",\n \"me\": true,\n \"permissionId\": \"077423361841532483\",\n \"emailAddress\": \"john@doe.com\",\n \"photoLink\": \"https://lh3.googleusercontent.com/a/default-user=s64\"\n },\n \"owners\": [\n {\n \"displayName\": \"John Doe\",\n \"kind\": \"drive#user\",\n \"me\": true,\n \"permissionId\": \"07742336189483\",\n \"emailAddress\": \"john@doe.com\",\n \"photoLink\": \"https://lh3.googleusercontent.com/a/default-user=s64\"\n }\n ],\n \"webViewLink\": \"https://docs.google.com/spreadsheets/d/1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmwTOo/edit?usp=drivesdk\",\n \"size\": \"1024\",\n \"viewersCanCopyContent\": true,\n \"permissions\": [\n {\n \"id\": \"07742336184153259483\",\n \"displayName\": \"John Doe\",\n \"type\": \"user\",\n \"kind\": \"drive#permission\",\n \"photoLink\": \"https://lh3.googleusercontent.com/a/default-user=s64\",\n \"emailAddress\": \"john@doe.com\",\n \"role\": \"owner\",\n \"deleted\": false,\n \"pendingOwner\": false\n }\n ],\n \"hasThumbnail\": true,\n \"spaces\": [\n \"drive\"\n ],\n \"id\": \"1LmXTIQ0wqKP7T3-l9r127Maw4Pt2BViTOo\",\n \"name\": \"Pipedream 2213\",\n \"starred\": false,\n \"trashed\": false,\n \"explicitlyTrashed\": false,\n \"createdTime\": \"2023-02-06T15:13:33.023Z\",\n \"modifiedTime\": \"2023-06-28T12:52:54.570Z\",\n \"modifiedByMeTime\": \"2023-06-28T12:52:54.570Z\",\n \"viewedByMeTime\": \"2023-06-29T06:30:58.441Z\",\n \"quotaBytesUsed\": \"1024\",\n \"version\": \"53\",\n \"ownedByMe\": true,\n \"isAppAuthorized\": false,\n \"capabilities\": {\n \"canChangeViewersCanCopyContent\": true,\n \"canEdit\": true,\n \"canCopy\": true,\n \"canComment\": true,\n \"canAddChildren\": false,\n \"canDelete\": true,\n \"canDownload\": true,\n \"canListChildren\": false,\n \"canRemoveChildren\": false,\n \"canRename\": true,\n \"canTrash\": true,\n \"canReadRevisions\": true,\n \"canChangeCopyRequiresWriterPermission\": true,\n \"canMoveItemIntoTeamDrive\": true,\n \"canUntrash\": true,\n \"canModifyContent\": true,\n \"canMoveItemOutOfDrive\": true,\n \"canAddMyDriveParent\": false,\n \"canRemoveMyDriveParent\": true,\n \"canMoveItemWithinDrive\": true,\n \"canShare\": true,\n \"canMoveChildrenWithinDrive\": false,\n \"canModifyContentRestriction\": true,\n \"canChangeSecurityUpdateEnabled\": false,\n \"canAcceptOwnership\": false,\n \"canReadLabels\": true,\n \"canModifyLabels\": true\n },\n \"thumbnailVersion\": \"12\",\n \"modifiedByMe\": true,\n \"permissionIds\": [\n \"07742336184153259483\"\n ],\n \"linkShareMetadata\": {\n \"securityUpdateEligible\": false,\n \"securityUpdateEnabled\": true\n }\n }\n}")
1
+ export default JSON.parse("{\n \"file\": {\n \"kind\": \"drive#file\",\n \"copyRequiresWriterPermission\": false,\n \"writersCanShare\": true,\n \"viewedByMe\": true,\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\",\n \"exportLinks\": {\n \"application/x-vnd.oasis.opendocument.spreadsheet\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmw4&exportFormat=ods\",\n \"text/tab-separated-values\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXnViTOo&exportFormat=tsv\",\n \"application/pdf\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaBViTOo&exportFormat=pdf\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbOo&exportFormat=xlsx\",\n \"text/csv\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbBViTOo&exportFormat=csv\",\n \"application/zip\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-VbTmw4Pt2BViTOo&exportFormat=zip\",\n \"application/vnd.oasis.opendocument.spreadsheet\": \"https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbViTOo&exportFormat=ods\"\n },\n \"parents\": [\n \"0ANs73yKKVA\"\n ],\n \"thumbnailLink\": \"https://docs.google.com/feeds/vt?gd=true&id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmw4&v=12&s=AMedNnoAAAAAZKWjrEqscucFpYCyRCJqnd0wtBiDtXYh&sz=s220\",\n \"iconLink\": \"https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet\",\n \"shared\": false,\n \"lastModifyingUser\": {\n \"displayName\": \"John Doe\",\n \"kind\": \"drive#user\",\n \"me\": true,\n \"permissionId\": \"077423361841532483\",\n \"emailAddress\": \"john@doe.com\",\n \"photoLink\": \"https://lh3.googleusercontent.com/a/default-user=s64\"\n },\n \"owners\": [\n {\n \"displayName\": \"John Doe\",\n \"kind\": \"drive#user\",\n \"me\": true,\n \"permissionId\": \"07742336189483\",\n \"emailAddress\": \"john@doe.com\",\n \"photoLink\": \"https://lh3.googleusercontent.com/a/default-user=s64\"\n }\n ],\n \"webViewLink\": \"https://docs.google.com/spreadsheets/d/1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmwTOo/edit?usp=drivesdk\",\n \"size\": \"1024\",\n \"viewersCanCopyContent\": true,\n \"permissions\": [\n {\n \"id\": \"07742336184153259483\",\n \"displayName\": \"John Doe\",\n \"type\": \"user\",\n \"kind\": \"drive#permission\",\n \"photoLink\": \"https://lh3.googleusercontent.com/a/default-user=s64\",\n \"emailAddress\": \"john@doe.com\",\n \"role\": \"owner\",\n \"deleted\": false,\n \"pendingOwner\": false\n }\n ],\n \"hasThumbnail\": true,\n \"spaces\": [\n \"drive\"\n ],\n \"id\": \"1LmXTIQ0wqKP7T3-l9r127Maw4Pt2BViTOo\",\n \"name\": \"Pipedream 2213\",\n \"starred\": false,\n \"trashed\": false,\n \"explicitlyTrashed\": false,\n \"createdTime\": \"2023-02-06T15:13:33.023Z\",\n \"modifiedTime\": \"2023-06-28T12:52:54.570Z\",\n \"modifiedByMeTime\": \"2023-06-28T12:52:54.570Z\",\n \"viewedByMeTime\": \"2023-06-29T06:30:58.441Z\",\n \"quotaBytesUsed\": \"1024\",\n \"version\": \"53\",\n \"ownedByMe\": true,\n \"isAppAuthorized\": false,\n \"capabilities\": {\n \"canChangeViewersCanCopyContent\": true,\n \"canEdit\": true,\n \"canCopy\": true,\n \"canComment\": true,\n \"canAddChildren\": false,\n \"canDelete\": true,\n \"canDownload\": true,\n \"canListChildren\": false,\n \"canRemoveChildren\": false,\n \"canRename\": true,\n \"canTrash\": true,\n \"canReadRevisions\": true,\n \"canChangeCopyRequiresWriterPermission\": true,\n \"canMoveItemIntoTeamDrive\": true,\n \"canUntrash\": true,\n \"canModifyContent\": true,\n \"canMoveItemOutOfDrive\": true,\n \"canAddMyDriveParent\": false,\n \"canRemoveMyDriveParent\": true,\n \"canMoveItemWithinDrive\": true,\n \"canShare\": true,\n \"canMoveChildrenWithinDrive\": false,\n \"canModifyContentRestriction\": true,\n \"canChangeSecurityUpdateEnabled\": false,\n \"canAcceptOwnership\": false,\n \"canReadLabels\": true,\n \"canModifyLabels\": true\n },\n \"thumbnailVersion\": \"12\",\n \"modifiedByMe\": true,\n \"permissionIds\": [\n \"07742336184153259483\"\n ],\n \"linkShareMetadata\": {\n \"securityUpdateEligible\": false,\n \"securityUpdateEnabled\": true\n }\n }\n}");
@@ -20,7 +20,7 @@ export default {
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.2.1",
23
+ version: "0.2.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
@@ -5,7 +5,7 @@ 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.12",
8
+ version: "0.1.13",
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.14",
9
+ version: "0.1.15",
10
10
  props: {
11
11
  googleDrive: newFilesInstant.props.googleDrive,
12
12
  db: newFilesInstant.props.db,