@pipedream/google_drive 0.4.12 → 0.4.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.
Files changed (33) 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/create-file.mjs +2 -2
  4. package/actions/create-file-from-template/create-file-from-template.mjs +20 -9
  5. package/actions/create-file-from-text/create-file-from-text.mjs +1 -1
  6. package/actions/create-folder/create-folder.mjs +2 -2
  7. package/actions/create-shared-drive/create-shared-drive.mjs +1 -1
  8. package/actions/delete-file/delete-file.mjs +1 -1
  9. package/actions/delete-shared-drive/delete-shared-drive.mjs +1 -1
  10. package/actions/download-file/download-file.mjs +2 -2
  11. package/actions/find-file/find-file.mjs +2 -2
  12. package/actions/find-folder/find-folder.mjs +2 -2
  13. package/actions/get-folder-id-for-path/get-folder-id-for-path.mjs +1 -1
  14. package/actions/get-shared-drive/get-shared-drive.mjs +1 -1
  15. package/actions/list-files/list-files.mjs +2 -2
  16. package/actions/move-file/move-file.mjs +1 -1
  17. package/actions/move-file-to-trash/move-file-to-trash.mjs +1 -1
  18. package/actions/replace-file/replace-file.mjs +3 -3
  19. package/actions/search-shared-drives/search-shared-drives.mjs +1 -1
  20. package/actions/update-file/update-file.mjs +5 -3
  21. package/actions/update-shared-drive/update-shared-drive.mjs +1 -1
  22. package/actions/upload-file/upload-file.mjs +5 -3
  23. package/{utils.mjs → common/utils.mjs} +15 -10
  24. package/google_drive.app.mjs +3 -2
  25. package/package.json +1 -1
  26. package/sources/changes-to-specific-files/changes-to-specific-files.mjs +1 -1
  27. package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +1 -1
  28. package/sources/new-files-instant/new-files-instant.mjs +1 -1
  29. package/sources/new-or-modified-comments/new-or-modified-comments.mjs +1 -1
  30. package/sources/new-or-modified-files/new-or-modified-files.mjs +1 -1
  31. package/sources/new-or-modified-folders/new-or-modified-folders.mjs +1 -1
  32. package/sources/new-shared-drive/new-shared-drive.mjs +1 -1
  33. package/sources/new-spreadsheet/new-spreadsheet.mjs +1 -1
@@ -11,7 +11,7 @@ export default {
11
11
  name: "Add File Sharing Preference",
12
12
  description:
13
13
  "Add a [sharing](https://support.google.com/drive/answer/7166529) permission to the sharing preferences of a file and provide a sharing URL. [See the docs](https://developers.google.com/drive/api/v3/reference/permissions/create) for more information",
14
- version: "0.0.4",
14
+ version: "0.0.5",
15
15
  type: "action",
16
16
  props: {
17
17
  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 docs](https://developers.google.com/drive/api/v3/reference/files/copy) for more information",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,13 +1,13 @@
1
1
  import googleDrive from "../../google_drive.app.mjs";
2
2
  import fs from "fs";
3
3
  import got from "got";
4
- import { toSingleLineString } from "../../utils.mjs";
4
+ import { toSingleLineString } from "../../common/utils.mjs";
5
5
 
6
6
  export default {
7
7
  key: "google_drive-create-file",
8
8
  name: "Create a New File",
9
9
  description: "Create a new file from a URL or /tmp/filepath. [See the docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
10
- version: "0.0.8",
10
+ version: "0.0.9",
11
11
  type: "action",
12
12
  props: {
13
13
  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.0.3",
11
+ version: "0.0.5",
12
12
  type: "action",
13
13
  props: {
14
14
  googleDrive,
@@ -18,7 +18,7 @@ export default {
18
18
  "fileId",
19
19
  ],
20
20
  description:
21
- "Select the document you'd like to use as the template, or use a custom expression to reference a document ID from a previous step.",
21
+ "Select the template document you'd like to use as the template, or use a custom expression to reference a document ID from a previous step. Template documents should contain placeholders in the format {{xyz}}.",
22
22
  },
23
23
  folderId: {
24
24
  propDefinition: [
@@ -50,7 +50,6 @@ export default {
50
50
  type: "object",
51
51
  label: "Replace text placeholders",
52
52
  description: "Replace text placeholders in the document. Use the format {{xyz}} in the document but exclude the curly braces in the key. (eg. `{{myPlaceholder}}` in the document will be replaced by the value of the key `myPlaceholder` in the action.",
53
- optional: true,
54
53
  },
55
54
  },
56
55
  async run({ $ }) {
@@ -66,12 +65,24 @@ export default {
66
65
 
67
66
  /* CREATE THE GOOGLE DOC */
68
67
 
69
- const googleDocId = await client.interpolate({
70
- source: this.templateId,
71
- destination: this.folderId,
72
- name: this.name,
73
- data: this.replaceValues,
74
- });
68
+ let googleDocId;
69
+ try {
70
+ googleDocId = await client.interpolate({
71
+ source: this.templateId,
72
+ destination: this.folderId,
73
+ name: this.name,
74
+ data: this.replaceValues,
75
+ });
76
+ } catch (e) {
77
+ const {
78
+ code, message,
79
+ } = e.error.error;
80
+ let errorMessage = `Status: ${code}, ${message} `;
81
+ if (code == 404 || code == 400) {
82
+ errorMessage += "Make sure that the template file selected contains placeholders in the format {{xyz}}.";
83
+ }
84
+ throw new Error(errorMessage);
85
+ }
75
86
  result["googleDocId"] = googleDocId;
76
87
 
77
88
  /* CREATE THE PDF */
@@ -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 docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
8
- version: "0.0.4",
8
+ version: "0.0.5",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -2,7 +2,7 @@ import googleDrive from "../../google_drive.app.mjs";
2
2
  import {
3
3
  getListFilesOpts,
4
4
  toSingleLineString,
5
- } from "../../utils.mjs";
5
+ } from "../../common/utils.mjs";
6
6
 
7
7
  import {
8
8
  MY_DRIVE_VALUE,
@@ -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 docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
16
- version: "0.0.7",
16
+ version: "0.0.8",
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 docs](https://developers.google.com/drive/api/v3/reference/drives/create) for more information",
7
- version: "0.0.3",
7
+ version: "0.0.4",
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 docs](https://developers.google.com/drive/api/v3/reference/files/delete) for more information",
8
- version: "0.0.4",
8
+ version: "0.0.5",
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 docs](https://developers.google.com/drive/api/v3/reference/drives/delete) for more information",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -4,7 +4,7 @@ import stream from "stream";
4
4
  import { promisify } from "util";
5
5
  import { GOOGLE_DRIVE_MIME_TYPE_PREFIX } from "../../constants.mjs";
6
6
  import googleWorkspaceExportFormats from "../google-workspace-export-formats.mjs";
7
- import { toSingleLineString } from "../../utils.mjs";
7
+ import { toSingleLineString } from "../../common/utils.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 docs](https://developers.google.com/drive/api/v3/manage-downloads) for more information",
21
- version: "0.0.3",
21
+ version: "0.0.4",
22
22
  type: "action",
23
23
  props: {
24
24
  googleDrive,
@@ -1,11 +1,11 @@
1
1
  import googleDrive from "../../google_drive.app.mjs";
2
- import { getListFilesOpts } from "../../utils.mjs";
2
+ import { getListFilesOpts } from "../../common/utils.mjs";
3
3
 
4
4
  export default {
5
5
  key: "google_drive-find-file",
6
6
  name: "Find File",
7
7
  description: "Search for a specific file by name. [See the docs](https://developers.google.com/drive/api/v3/search-files) for more information",
8
- version: "0.0.3",
8
+ version: "0.0.4",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -1,5 +1,5 @@
1
1
  import googleDrive from "../../google_drive.app.mjs";
2
- import { getListFilesOpts } from "../../utils.mjs";
2
+ import { getListFilesOpts } from "../../common/utils.mjs";
3
3
 
4
4
  import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../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 docs](https://developers.google.com/drive/api/v3/search-files) for more information",
10
- version: "0.0.5",
10
+ version: "0.0.6",
11
11
  type: "action",
12
12
  props: {
13
13
  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 docs](https://developers.google.com/drive/api/v3/search-files) for more information",
15
- version: "0.0.3",
15
+ version: "0.0.4",
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 a shared drive's metadata by ID. [See the docs](https://developers.google.com/drive/api/v3/reference/drives/get) for more information",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,11 +1,11 @@
1
1
  import googleDrive from "../../google_drive.app.mjs";
2
- import { getListFilesOpts } from "../../utils.mjs";
2
+ import { getListFilesOpts } from "../../common/utils.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 docs](https://developers.google.com/drive/api/v3/reference/files/list) for more information",
8
- version: "0.0.2",
8
+ version: "0.0.3",
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 docs](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
7
- version: "0.0.4",
7
+ version: "0.0.5",
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 docs](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
8
- version: "0.0.4",
8
+ version: "0.0.5",
9
9
  type: "action",
10
10
  props: {
11
11
  googleDrive,
@@ -1,11 +1,11 @@
1
1
  import path from "path";
2
2
  import googleDrive from "../../google_drive.app.mjs";
3
- import { omitEmptyStringValues } from "../../utils.mjs";
4
3
  import {
4
+ omitEmptyStringValues,
5
5
  getFileStream,
6
6
  streamToBuffer,
7
7
  byteToMB,
8
- } from "../../utils.mjs";
8
+ } from "../../common/utils.mjs";
9
9
  import {
10
10
  GOOGLE_DRIVE_UPLOAD_TYPE_MEDIA,
11
11
  GOOGLE_DRIVE_UPLOAD_TYPE_RESUMABLE,
@@ -15,7 +15,7 @@ export default {
15
15
  key: "google_drive-replace-file",
16
16
  name: "Replace File",
17
17
  description: "Upload a file that replaces an existing file. [See the docs](https://developers.google.com/drive/api/v3/reference/files/update) for more information",
18
- version: "0.0.5",
18
+ version: "0.0.6",
19
19
  type: "action",
20
20
  props: {
21
21
  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 docs](https://developers.google.com/drive/api/v3/search-shareddrives) for more information",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,12 +1,14 @@
1
1
  import googleDrive from "../../google_drive.app.mjs";
2
- import { toSingleLineString } from "../../utils.mjs";
3
- import { getFileStream } from "../../utils.mjs";
2
+ import {
3
+ toSingleLineString,
4
+ getFileStream,
5
+ } from "../../common/utils.mjs";
4
6
 
5
7
  export default {
6
8
  key: "google_drive-update-file",
7
9
  name: "Update File",
8
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",
9
- version: "0.0.4",
11
+ version: "0.0.5",
10
12
  type: "action",
11
13
  props: {
12
14
  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 docs](https://developers.google.com/drive/api/v3/reference/drives/update) for more information",
7
- version: "0.0.4",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  googleDrive,
@@ -1,14 +1,16 @@
1
1
  import googleDrive from "../../google_drive.app.mjs";
2
2
  import path from "path";
3
- import { getFileStream } from "../../utils.mjs";
4
- import { omitEmptyStringValues } from "../../utils.mjs";
3
+ import {
4
+ getFileStream,
5
+ omitEmptyStringValues,
6
+ } from "../../common/utils.mjs";
5
7
  import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../constants.mjs";
6
8
 
7
9
  export default {
8
10
  key: "google_drive-upload-file",
9
11
  name: "Upload File",
10
12
  description: "Copy an existing file to Google Drive. [See the docs](https://developers.google.com/drive/api/v3/manage-uploads) for more information",
11
- version: "0.0.7",
13
+ version: "0.0.8",
12
14
  type: "action",
13
15
  props: {
14
16
  googleDrive,
@@ -1,10 +1,10 @@
1
1
  import fs from "fs";
2
- import { axios } from "@pipedream/platform";
2
+ import axios from "axios";
3
3
  import {
4
4
  MY_DRIVE_VALUE,
5
5
  LEGACY_MY_DRIVE_VALUE,
6
6
  MAX_FILE_OPTION_PATH_SEGMENTS,
7
- } from "./constants.mjs";
7
+ } from "../constants.mjs";
8
8
 
9
9
  /**
10
10
  * Returns whether the specified drive ID corresponds to the authenticated
@@ -70,15 +70,20 @@ function getListFilesOpts(drive, baseOpts = {}) {
70
70
  * @returns {stream.Readable} a Readable stream from the file URL or file path
71
71
  */
72
72
  async function getFileStream({
73
- $, fileUrl, filePath,
73
+ fileUrl, filePath,
74
74
  }) {
75
- return fileUrl
76
- ? (await axios($ ?? this, {
77
- url: fileUrl,
78
- method: "GET",
79
- responseType: "stream",
80
- }))
81
- : fs.createReadStream(filePath);
75
+ if (fileUrl) {
76
+ try {
77
+ return (await axios({
78
+ url: fileUrl,
79
+ method: "GET",
80
+ responseType: "stream",
81
+ })).data;
82
+ } catch (e) {
83
+ throw new Error(`Status ${e.response.status} ${e.response.statusText}. ${e.message}`);
84
+ }
85
+ }
86
+ return fs.createReadStream(filePath);
82
87
  }
83
88
 
84
89
  function streamToBuffer(stream) {
@@ -25,7 +25,7 @@ import {
25
25
  omitEmptyStringValues,
26
26
  toSingleLineString,
27
27
  getFilePaths,
28
- } from "./utils.mjs";
28
+ } from "./common/utils.mjs";
29
29
 
30
30
  export default {
31
31
  type: "app",
@@ -267,8 +267,9 @@ export default {
267
267
  auth.setCredentials({
268
268
  access_token: this.$auth.oauth_access_token,
269
269
  });
270
+ const version = "v3";
270
271
  return drive.drive({
271
- version: "v3",
272
+ version,
272
273
  auth,
273
274
  });
274
275
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_drive",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
4
4
  "description": "Pipedream Google_drive Components",
5
5
  "main": "google_drive.app.mjs",
6
6
  "keywords": [
@@ -16,7 +16,7 @@ export default {
16
16
  key: "google_drive-changes-to-specific-files",
17
17
  name: "Changes to Specific Files",
18
18
  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.",
19
- version: "0.0.19",
19
+ version: "0.0.20",
20
20
  type: "source",
21
21
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
22
22
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -25,7 +25,7 @@ export default {
25
25
  key: "google_drive-changes-to-specific-files-shared-drive",
26
26
  name: "Changes to Specific Files (Shared Drive)",
27
27
  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",
28
- version: "0.0.1",
28
+ version: "0.0.2",
29
29
  type: "source",
30
30
  // Dedupe events based on the "x-goog-message-number" header for the target channel:
31
31
  // https://developers.google.com/drive/api/v3/push#making-watch-requests
@@ -9,7 +9,7 @@ export default {
9
9
  key: "google_drive-new-files-instant",
10
10
  name: "New Files (Instant)",
11
11
  description: "Emit new event any time a new file is added in your linked Google Drive",
12
- version: "0.0.15",
12
+ version: "0.0.16",
13
13
  type: "source",
14
14
  dedupe: "unique",
15
15
  props: {
@@ -17,7 +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.0.9",
20
+ version: "0.0.10",
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
@@ -20,7 +20,7 @@ export default {
20
20
  key: "google_drive-new-or-modified-files",
21
21
  name: "New or Modified Files",
22
22
  description: "Emit new event any time any file in your linked Google Drive is added, modified, or deleted",
23
- version: "0.0.21",
23
+ version: "0.0.22",
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
@@ -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.0.10",
23
+ version: "0.0.11",
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.0.11",
8
+ version: "0.0.12",
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 each time a new spreadsheet is created in a drive.",
9
- version: "0.0.1",
9
+ version: "0.0.2",
10
10
  props: {
11
11
  googleDrive: newFilesInstant.props.googleDrive,
12
12
  db: newFilesInstant.props.db,