@pipedream/google_drive 0.7.3 → 0.8.0

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 (37) hide show
  1. package/actions/add-file-sharing-preference/add-file-sharing-preference.mjs +30 -8
  2. package/actions/copy-file/copy-file.mjs +2 -2
  3. package/actions/create-file-from-template/create-file-from-template.mjs +3 -3
  4. package/actions/create-file-from-text/create-file-from-text.mjs +3 -2
  5. package/actions/create-folder/create-folder.mjs +3 -2
  6. package/actions/create-shared-drive/create-shared-drive.mjs +1 -2
  7. package/actions/delete-file/delete-file.mjs +10 -3
  8. package/actions/delete-shared-drive/delete-shared-drive.mjs +7 -5
  9. package/actions/download-file/download-file.mjs +11 -6
  10. package/actions/find-file/find-file.mjs +8 -10
  11. package/actions/find-folder/find-folder.mjs +2 -2
  12. package/actions/find-forms/find-forms.mjs +22 -18
  13. package/actions/find-spreadsheets/find-spreadsheets.mjs +21 -18
  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 +8 -8
  17. package/actions/list-files/list-files.mjs +3 -3
  18. package/actions/move-file/move-file.mjs +2 -2
  19. package/actions/move-file-to-trash/move-file-to-trash.mjs +7 -2
  20. package/actions/search-shared-drives/search-shared-drives.mjs +1 -1
  21. package/actions/update-file/update-file.mjs +9 -7
  22. package/actions/update-shared-drive/update-shared-drive.mjs +11 -11
  23. package/actions/upload-file/upload-file.mjs +12 -4
  24. package/common/commonSearchQuery.mjs +48 -0
  25. package/common/constants.mjs +27 -22
  26. package/google_drive.app.mjs +41 -16
  27. package/package.json +1 -1
  28. package/sources/changes-to-specific-files/changes-to-specific-files.mjs +2 -3
  29. package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +1 -1
  30. package/sources/new-files-instant/new-files-instant.mjs +1 -1
  31. package/sources/new-or-modified-comments/new-or-modified-comments.mjs +1 -1
  32. package/sources/new-or-modified-files/new-or-modified-files.mjs +1 -1
  33. package/sources/new-or-modified-folders/new-or-modified-folders.mjs +1 -1
  34. package/sources/new-shared-drive/new-shared-drive.mjs +1 -1
  35. package/sources/new-spreadsheet/new-spreadsheet.mjs +1 -1
  36. package/actions/create-file/create-file.mjs +0 -242
  37. package/actions/replace-file/replace-file.mjs +0 -134
@@ -7,17 +7,21 @@ import {
7
7
  export default {
8
8
  key: "google_drive-update-file",
9
9
  name: "Update File",
10
- description: "Update a file's metadata and/or content. [See the docs](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
11
- version: "0.1.4",
10
+ 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",
11
+ version: "0.1.5",
12
12
  type: "action",
13
13
  props: {
14
14
  googleDrive,
15
+ requiredPropsAlert: {
16
+ type: "alert",
17
+ alertType: "info",
18
+ content: "Either `File URL` and `File Path` should be specified.",
19
+ },
15
20
  drive: {
16
21
  propDefinition: [
17
22
  googleDrive,
18
23
  "watchedDrive",
19
24
  ],
20
-
21
25
  optional: true,
22
26
  },
23
27
  fileId: {
@@ -104,12 +108,10 @@ export default {
104
108
  },
105
109
  advanced: {
106
110
  type: "object",
107
- label: "Advanced Options",
111
+ label: "Additional Options",
108
112
  optional: true,
109
113
  description: toSingleLineString(`
110
- Specify less-common properties that you want to use. See [Files: update]
111
- (https://developers.google.com/drive/api/v3/reference/files/update#request-body) for a list
112
- of supported properties.
114
+ Any additional parameters to pass in the request. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update#request-body) for all available parameters.
113
115
  `),
114
116
  },
115
117
  },
@@ -3,8 +3,8 @@ import googleDrive from "../../google_drive.app.mjs";
3
3
  export default {
4
4
  key: "google_drive-update-shared-drive",
5
5
  name: "Update Shared Drive",
6
- description: "Update an existing shared drive. [See the docs](https://developers.google.com/drive/api/v3/reference/drives/update) for more information",
7
- version: "0.1.4",
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.5",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -16,6 +16,7 @@ export default {
16
16
  description:
17
17
  "Select a [shared drive](https://support.google.com/a/users/answer/9310351) to update",
18
18
  default: "",
19
+ optional: false,
19
20
  },
20
21
  useDomainAdminAccess: {
21
22
  propDefinition: [
@@ -23,25 +24,24 @@ export default {
23
24
  "useDomainAdminAccess",
24
25
  ],
25
26
  },
27
+ themeId: {
28
+ propDefinition: [
29
+ googleDrive,
30
+ "themeId",
31
+ ],
32
+ },
26
33
  backgroundImageLink: {
27
34
  type: "string",
28
35
  label: "Background Image Link",
29
36
  description:
30
- "A link to the new background image for the shared drive. Cannot be set if `Theme ID` is set in the same request.",
37
+ "A link to the new background image for the shared drive. Cannot be set if `Theme ID` is used (it already sets the background image).",
31
38
  optional: true,
32
39
  },
33
40
  colorRgb: {
34
41
  type: "string",
35
42
  label: "Color",
36
43
  description:
37
- "The new color of this shared drive as an RGB hex string. Cannot be set if `Theme ID` is set in the same request.",
38
- optional: true,
39
- },
40
- themeId: {
41
- type: "string",
42
- label: "Theme ID",
43
- description:
44
- "The ID of the theme from which the background image and color will be set. Cannot be set if `Color` or `Background Image Link` is set in the same request.",
44
+ "The new color of this shared drive as an RGB hex string. Cannot be set if `Theme ID` is used (it already sets the color).",
45
45
  optional: true,
46
46
  },
47
47
  restrictions: {
@@ -5,15 +5,21 @@ import {
5
5
  omitEmptyStringValues,
6
6
  } from "../../common/utils.mjs";
7
7
  import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs";
8
+ import { ConfigurationError } from "@pipedream/platform";
8
9
 
9
10
  export default {
10
11
  key: "google_drive-upload-file",
11
12
  name: "Upload File",
12
- description: "Copy an existing file to Google Drive. [See the docs](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
13
- version: "0.1.6",
13
+ description: "Upload a file to Google Drive. [See the documentation](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
14
+ version: "0.1.7",
14
15
  type: "action",
15
16
  props: {
16
17
  googleDrive,
18
+ infoAlert: {
19
+ type: "alert",
20
+ alertType: "info",
21
+ content: "Either `File URL` and `File Path` should be specified.",
22
+ },
17
23
  drive: {
18
24
  propDefinition: [
19
25
  googleDrive,
@@ -89,7 +95,7 @@ export default {
89
95
  } = this;
90
96
  let { uploadType } = this;
91
97
  if (!fileUrl && !filePath) {
92
- throw new Error("One of File URL and File Path is required.");
98
+ throw new ConfigurationError("Either `File URL` and `File Path` should be specified.");
93
99
  }
94
100
  const driveId = this.googleDrive.getDriveId(this.drive);
95
101
 
@@ -98,7 +104,9 @@ export default {
98
104
  const file = await getFileStream({
99
105
  $,
100
106
  fileUrl,
101
- filePath,
107
+ filePath: filePath.includes("tmp/")
108
+ ? filePath
109
+ : `/tmp/${filePath}`,
102
110
  });
103
111
  console.log(`Upload type: ${uploadType}.`);
104
112
 
@@ -0,0 +1,48 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
2
+ import googleDrive from "../google_drive.app.mjs";
3
+
4
+ export default {
5
+ methods: {
6
+ getQuery(type, folderId) {
7
+ const {
8
+ searchQuery, nameSearchTerm,
9
+ } = this;
10
+ if (!searchQuery && !nameSearchTerm && !type) {
11
+ throw new ConfigurationError("You must specify a search query or name.");
12
+ }
13
+ let q = type
14
+ ? `mimeType = 'application/vnd.google-apps.${type}'`
15
+ : "";
16
+ if (searchQuery) {
17
+ q = (!q || searchQuery.includes(q))
18
+ ? searchQuery
19
+ : `${q} and ${searchQuery}`;
20
+ } else {
21
+ if (nameSearchTerm) {
22
+ const nameQuery = `name contains '${nameSearchTerm}'`;
23
+ q = q
24
+ ? `${q} and ${nameQuery}`
25
+ : nameQuery;
26
+ }
27
+ if (folderId) {
28
+ q = `${q} and "${folderId}" in parents`;
29
+ }
30
+ }
31
+ return q.trim();
32
+ },
33
+ },
34
+ props: {
35
+ nameSearchTerm: {
36
+ propDefinition: [
37
+ googleDrive,
38
+ "fileNameSearchTerm",
39
+ ],
40
+ },
41
+ searchQuery: {
42
+ propDefinition: [
43
+ googleDrive,
44
+ "searchQuery",
45
+ ],
46
+ },
47
+ },
48
+ };
@@ -163,14 +163,6 @@ const GOOGLE_DRIVE_ROLE_READER = "reader";
163
163
  * All of the available Google Drive roles granted by a permission as defined by the [Google
164
164
  * Drive API docs](https://developers.google.com/drive/api/v3/reference/permissions)
165
165
  */
166
- const GOOGLE_DRIVE_ROLES = [
167
- GOOGLE_DRIVE_ROLE_OWNER,
168
- GOOGLE_DRIVE_ROLE_ORGANIZER,
169
- GOOGLE_DRIVE_ROLE_FILEORGANIZER,
170
- GOOGLE_DRIVE_ROLE_WRITER,
171
- GOOGLE_DRIVE_ROLE_COMMENTER,
172
- GOOGLE_DRIVE_ROLE_READER,
173
- ];
174
166
 
175
167
  const GOOGLE_DRIVE_ROLE_OPTIONS = [
176
168
  {
@@ -182,23 +174,20 @@ const GOOGLE_DRIVE_ROLE_OPTIONS = [
182
174
  value: GOOGLE_DRIVE_ROLE_COMMENTER,
183
175
  },
184
176
  {
185
- label: "Reader - Can access, but can't change or share the file with others.",
177
+ label: "Viewer - Can access, but can't change or share the file with others.",
186
178
  value: GOOGLE_DRIVE_ROLE_READER,
187
179
  },
188
- {
189
- label: "(Advanced) File Owner - this will transfer ownership of the file.",
190
- value: GOOGLE_DRIVE_ROLE_OWNER,
191
- },
192
- {
193
- label: "(Advanced) File Organizar",
194
- value: GOOGLE_DRIVE_ROLE_FILEORGANIZER,
195
- },
196
- {
197
- label: "(Advanced) Organizar",
198
- value: GOOGLE_DRIVE_ROLE_ORGANIZER,
199
- },
200
180
  ];
201
181
 
182
+ const GOOGLE_DRIVE_ROLE_OPTION_FILEORGANIZER = {
183
+ label: "(Advanced) Content Manager - add, edit, move, delete and share content",
184
+ value: GOOGLE_DRIVE_ROLE_FILEORGANIZER,
185
+ };
186
+ const GOOGLE_DRIVE_ROLE_OPTION_OWNER = {
187
+ label: "(Advanced) File Owner - this will transfer ownership of the file.",
188
+ value: GOOGLE_DRIVE_ROLE_OWNER,
189
+ };
190
+
202
191
  const GOOGLE_DRIVE_GRANTEE_USER = "user";
203
192
  const GOOGLE_DRIVE_GRANTEE_GROUP = "group";
204
193
  const GOOGLE_DRIVE_GRANTEE_DOMAIN = "domain";
@@ -222,6 +211,20 @@ const GOOGLE_DRIVE_UPLOAD_TYPES = [
222
211
  GOOGLE_DRIVE_UPLOAD_TYPE_RESUMABLE,
223
212
  GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART,
224
213
  ];
214
+ const GOOGLE_DRIVE_UPLOAD_TYPE_OPTIONS = [
215
+ {
216
+ label: "Simple upload. Upload the media only, without any metadata.",
217
+ value: GOOGLE_DRIVE_UPLOAD_TYPE_MEDIA,
218
+ },
219
+ {
220
+ label: "Resumable upload. Upload the file in a resumable fashion, using a series of at least two requests where the first request includes the metadata.",
221
+ value: GOOGLE_DRIVE_UPLOAD_TYPE_RESUMABLE,
222
+ },
223
+ {
224
+ label: "Multipart upload. Upload both the media and its metadata, in a single request.",
225
+ value: GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART,
226
+ },
227
+ ];
225
228
 
226
229
  export {
227
230
  GOOGLE_DRIVE_NOTIFICATION_SYNC,
@@ -241,6 +244,7 @@ export {
241
244
  GOOGLE_DRIVE_MIME_TYPE_PREFIX,
242
245
  GOOGLE_DRIVE_FOLDER_MIME_TYPE,
243
246
  GOOGLE_DRIVE_UPLOAD_TYPES,
247
+ GOOGLE_DRIVE_UPLOAD_TYPE_OPTIONS,
244
248
  // Google Drive Roles
245
249
  GOOGLE_DRIVE_ROLE_OWNER,
246
250
  GOOGLE_DRIVE_ROLE_ORGANIZER,
@@ -248,8 +252,9 @@ export {
248
252
  GOOGLE_DRIVE_ROLE_WRITER,
249
253
  GOOGLE_DRIVE_ROLE_COMMENTER,
250
254
  GOOGLE_DRIVE_ROLE_READER,
251
- GOOGLE_DRIVE_ROLES,
252
255
  GOOGLE_DRIVE_ROLE_OPTIONS,
256
+ GOOGLE_DRIVE_ROLE_OPTION_FILEORGANIZER,
257
+ GOOGLE_DRIVE_ROLE_OPTION_OWNER,
253
258
  // Google Drive Grantee Types
254
259
  GOOGLE_DRIVE_GRANTEE_USER,
255
260
  GOOGLE_DRIVE_GRANTEE_GROUP,
@@ -11,7 +11,7 @@ import {
11
11
  WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS,
12
12
  GOOGLE_DRIVE_FOLDER_MIME_TYPE,
13
13
  GOOGLE_DRIVE_GRANTEE_TYPES,
14
- GOOGLE_DRIVE_UPLOAD_TYPES,
14
+ GOOGLE_DRIVE_UPLOAD_TYPE_OPTIONS,
15
15
  GOOGLE_DRIVE_UPDATE_TYPE_OPTIONS,
16
16
  } from "./common/constants.mjs";
17
17
  import googleMimeTypes from "./actions/google-mime-types.mjs";
@@ -40,6 +40,31 @@ export default {
40
40
  return this._listDriveOptions(nextPageToken);
41
41
  },
42
42
  },
43
+ sharedDrive: {
44
+ type: "string",
45
+ label: "Shared Drive",
46
+ description: "Select a [Shared Drive](https://support.google.com/a/users/answer/9310351) or leave blank to retrieve all available shared drives.",
47
+ optional: true,
48
+ async options({ prevContext }) {
49
+ const { nextPageToken } = prevContext;
50
+ return this._listDriveOptions(nextPageToken, false);
51
+ },
52
+ },
53
+ themeId: {
54
+ type: "string",
55
+ label: "Theme ID",
56
+ description: "The theme from which the background image and color will be set. Cannot be set if `Color` or `Background Image Link` are used.",
57
+ optional: true,
58
+ async options() {
59
+ const { driveThemes } = await this.getAbout("driveThemes");
60
+ return driveThemes?.map(({
61
+ id, colorRgb,
62
+ }) => ({
63
+ label: `${id} (${colorRgb})`,
64
+ value: id,
65
+ }));
66
+ },
67
+ },
43
68
  folderId: {
44
69
  type: "string",
45
70
  label: "Folder",
@@ -155,7 +180,13 @@ export default {
155
180
  fileNameSearchTerm: {
156
181
  type: "string",
157
182
  label: "Search Name",
158
- description: "Enter the name of a file to search for.",
183
+ description: "Search for a file by name (equivalent to the query `name contains [value]`).",
184
+ optional: true,
185
+ },
186
+ searchQuery: {
187
+ type: "string",
188
+ label: "Search Query",
189
+ description: "Search for a file with a query. [See the documentation](https://developers.google.com/drive/api/guides/ref-search-terms) for more information. If specified, `Search Name` will be ignored.",
159
190
  optional: true,
160
191
  },
161
192
  mimeType: {
@@ -179,14 +210,8 @@ export default {
179
210
  uploadType: {
180
211
  type: "string",
181
212
  label: "Upload Type",
182
- description: `The type of upload request to the /upload URI. If you are uploading data
183
- (using an /upload URI), this field is required. If you are creating a metadata-only file,
184
- this field is not required.
185
- media - Simple upload. Upload the media only, without any metadata.
186
- multipart - Multipart upload. Upload both the media and its metadata, in a single request.
187
- resumable - Resumable upload. Upload the file in a resumable fashion, using a series of
188
- at least two requests where the first request includes the metadata.`,
189
- options: GOOGLE_DRIVE_UPLOAD_TYPES,
213
+ description: "The type of upload request to the /upload URI. Required if you are uploading data, but not if are creating a metadata-only file. [See the documentation](https://developers.google.com/drive/api/reference/rest/v2/files/update#path-parameters) for more information.",
214
+ options: GOOGLE_DRIVE_UPLOAD_TYPE_OPTIONS,
190
215
  },
191
216
  useDomainAdminAccess: {
192
217
  type: "boolean",
@@ -429,7 +454,7 @@ export default {
429
454
  pageToken = nextPageToken;
430
455
  }
431
456
  },
432
- async _listDriveOptions(pageToken) {
457
+ async _listDriveOptions(pageToken, myDrive = true) {
433
458
  const {
434
459
  drives,
435
460
  nextPageToken,
@@ -440,14 +465,14 @@ export default {
440
465
  // only do this during the first page of options (i.e. when `pageToken` is
441
466
  // undefined).
442
467
  const options =
443
- pageToken !== undefined
444
- ? []
445
- : [
468
+ myDrive && pageToken === undefined
469
+ ? [
446
470
  {
447
471
  label: "My Drive",
448
472
  value: MY_DRIVE_VALUE,
449
473
  },
450
- ];
474
+ ]
475
+ : [];
451
476
  for (const d of drives) {
452
477
  options.push({
453
478
  label: d.name,
@@ -1239,7 +1264,7 @@ export default {
1239
1264
  */
1240
1265
  async createPermission(fileId, opts = {}) {
1241
1266
  const {
1242
- role = "reader",
1267
+ role,
1243
1268
  type,
1244
1269
  domain,
1245
1270
  emailAddress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "0.7.3",
3
+ "version": "0.8.0",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -2,9 +2,8 @@ import cronParser from "cron-parser";
2
2
  import sampleEmit from "./test-event.mjs";
3
3
  import includes from "lodash/includes.js";
4
4
  import { v4 as uuid } from "uuid";
5
-
6
- import changesToSpecificFiles from "../changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs";
7
5
  import { MY_DRIVE_VALUE } from "../../common/constants.mjs";
6
+ import changesToSpecificFiles from "../changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs";
8
7
 
9
8
  /**
10
9
  * This source uses the Google Drive API's
@@ -16,7 +15,7 @@ export default {
16
15
  key: "google_drive-changes-to-specific-files",
17
16
  name: "Changes to Specific Files",
18
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.",
19
- version: "0.2.0",
18
+ version: "0.2.1",
20
19
  type: "source",
21
20
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
22
21
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -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.0",
30
+ version: "0.2.1",
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
@@ -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 when a new file is added in your linked Google Drive",
13
- version: "0.1.7",
13
+ version: "0.1.8",
14
14
  type: "source",
15
15
  dedupe: "unique",
16
16
  props: {
@@ -17,7 +17,7 @@ export default {
17
17
  name: "New or Modified Comments (Instant)",
18
18
  description:
19
19
  "Emit new event when a file comment is created or modified in the selected Drive",
20
- version: "0.1.7",
20
+ version: "0.1.8",
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
@@ -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.0",
27
+ version: "0.3.1",
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
@@ -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.1.5",
23
+ version: "0.1.6",
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.4",
8
+ version: "0.1.5",
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.5",
9
+ version: "0.1.6",
10
10
  props: {
11
11
  googleDrive: newFilesInstant.props.googleDrive,
12
12
  db: newFilesInstant.props.db,