@pipedream/google_drive 0.9.2 → 0.10.1
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.
- package/actions/add-file-sharing-preference/add-file-sharing-preference.mjs +1 -1
- package/actions/{google-workspace-export-formats.mjs → common/google-workspace-export-formats.mjs} +24 -0
- package/actions/copy-file/copy-file.mjs +1 -1
- package/actions/create-file-from-template/create-file-from-template.mjs +1 -1
- package/actions/create-file-from-text/create-file-from-text.mjs +1 -1
- package/actions/create-folder/create-folder.mjs +1 -1
- package/actions/create-shared-drive/create-shared-drive.mjs +1 -1
- package/actions/delete-file/delete-file.mjs +1 -1
- package/actions/delete-shared-drive/delete-shared-drive.mjs +1 -1
- package/actions/download-file/download-file.mjs +6 -3
- package/actions/find-file/find-file.mjs +1 -1
- package/actions/find-forms/find-forms.mjs +1 -1
- package/actions/find-spreadsheets/find-spreadsheets.mjs +1 -1
- package/actions/get-file-by-id/get-file-by-id.mjs +1 -1
- package/actions/get-folder-id-for-path/get-folder-id-for-path.mjs +1 -1
- package/actions/get-shared-drive/get-shared-drive.mjs +1 -1
- package/actions/list-access-proposals/list-access-proposals.mjs +1 -1
- package/actions/list-files/list-files.mjs +1 -1
- package/actions/move-file/move-file.mjs +1 -1
- package/actions/move-file-to-trash/move-file-to-trash.mjs +1 -1
- package/actions/resolve-access-proposal/resolve-access-proposal.mjs +1 -1
- package/actions/search-shared-drives/search-shared-drives.mjs +1 -1
- package/actions/update-file/update-file.mjs +1 -1
- package/actions/update-shared-drive/update-shared-drive.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +27 -32
- package/common/utils.mjs +34 -1
- package/google_drive.app.mjs +37 -10
- package/package.json +2 -2
- package/sources/changes-to-specific-files/changes-to-specific-files.mjs +1 -1
- package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +1 -1
- package/sources/new-access-proposal/new-access-proposal.mjs +1 -1
- package/sources/new-files-instant/new-files-instant.mjs +1 -1
- package/sources/new-files-shared-drive/new-files-shared-drive.mjs +1 -1
- package/sources/new-or-modified-comments/new-or-modified-comments.mjs +1 -1
- package/sources/new-or-modified-files/new-or-modified-files.mjs +1 -1
- package/sources/new-or-modified-folders/new-or-modified-folders.mjs +1 -1
- package/sources/new-shared-drive/new-shared-drive.mjs +1 -1
- 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.
|
23
|
+
version: "0.2.2",
|
24
24
|
type: "action",
|
25
25
|
props: {
|
26
26
|
googleDrive,
|
package/actions/{google-workspace-export-formats.mjs → common/google-workspace-export-formats.mjs}
RENAMED
@@ -39,6 +39,22 @@ export default [
|
|
39
39
|
value: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
40
40
|
label: "MS Word document",
|
41
41
|
},
|
42
|
+
{
|
43
|
+
value: "application/vnd.oasis.opendocument.text",
|
44
|
+
label: "OpenDocument Text",
|
45
|
+
},
|
46
|
+
{
|
47
|
+
value: "application/vnd.oasis.opendocument.spreadsheet",
|
48
|
+
label: "OpenDocument Spreadsheet",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
value: "application/vnd.oasis.opendocument.presentation",
|
52
|
+
label: "OpenDocument Presentation",
|
53
|
+
},
|
54
|
+
{
|
55
|
+
value: "application/vnd.google-apps.vid",
|
56
|
+
label: "MP4",
|
57
|
+
},
|
42
58
|
{
|
43
59
|
value: "application/zip",
|
44
60
|
label: "HTML (zipped)",
|
@@ -71,4 +87,12 @@ export default [
|
|
71
87
|
value: "text/tab-separated-values",
|
72
88
|
label: "TSV (sheet only)",
|
73
89
|
},
|
90
|
+
{
|
91
|
+
value: "text/markdown",
|
92
|
+
label: "Markdown",
|
93
|
+
},
|
94
|
+
{
|
95
|
+
value: "text/x-markdown",
|
96
|
+
label: "Markdown (Deprecated)",
|
97
|
+
},
|
74
98
|
];
|
@@ -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.
|
7
|
+
version: "0.1.9",
|
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.
|
11
|
+
version: "0.1.9",
|
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.
|
8
|
+
version: "0.2.2",
|
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.
|
16
|
+
version: "0.1.10",
|
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.
|
7
|
+
version: "0.1.10",
|
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.
|
8
|
+
version: "0.1.10",
|
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.
|
7
|
+
version: "0.1.9",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
googleDrive,
|
@@ -3,7 +3,7 @@ import fs from "fs";
|
|
3
3
|
import stream from "stream";
|
4
4
|
import { promisify } from "util";
|
5
5
|
import { GOOGLE_DRIVE_MIME_TYPE_PREFIX } from "../../common/constants.mjs";
|
6
|
-
import googleWorkspaceExportFormats from "../google-workspace-export-formats.mjs";
|
6
|
+
import googleWorkspaceExportFormats from "../common/google-workspace-export-formats.mjs";
|
7
7
|
import { toSingleLineString } from "../../common/utils.mjs";
|
8
8
|
|
9
9
|
/**
|
@@ -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.
|
21
|
+
version: "0.1.10",
|
22
22
|
type: "action",
|
23
23
|
props: {
|
24
24
|
googleDrive,
|
@@ -82,7 +82,10 @@ export default {
|
|
82
82
|
return exportFormats[file.mimeType].map((f) =>
|
83
83
|
googleWorkspaceExportFormats.find(
|
84
84
|
(format) => format.value === f,
|
85
|
-
) ??
|
85
|
+
) ?? {
|
86
|
+
value: f,
|
87
|
+
label: f,
|
88
|
+
});
|
86
89
|
},
|
87
90
|
},
|
88
91
|
},
|
@@ -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.
|
9
|
+
version: "0.1.9",
|
10
10
|
type: "action",
|
11
11
|
props: {
|
12
12
|
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.
|
9
|
+
version: "0.0.10",
|
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.
|
9
|
+
version: "0.1.9",
|
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.
|
8
|
+
version: "0.0.6",
|
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.
|
15
|
+
version: "0.1.11",
|
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.
|
7
|
+
version: "0.1.9",
|
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.
|
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.
|
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-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.
|
7
|
+
version: "0.1.9",
|
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.
|
8
|
+
version: "0.1.9",
|
9
9
|
type: "action",
|
10
10
|
props: {
|
11
11
|
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.
|
8
|
+
version: "0.0.2",
|
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.
|
7
|
+
version: "0.1.10",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
googleDrive,
|
@@ -9,7 +9,7 @@ export default {
|
|
9
9
|
key: "google_drive-update-file",
|
10
10
|
name: "Update File",
|
11
11
|
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",
|
12
|
-
version: "1.0.
|
12
|
+
version: "1.0.2",
|
13
13
|
type: "action",
|
14
14
|
additionalProps,
|
15
15
|
props: {
|
@@ -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.
|
7
|
+
version: "0.1.9",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
googleDrive,
|
@@ -1,24 +1,22 @@
|
|
1
1
|
import googleDrive from "../../google_drive.app.mjs";
|
2
2
|
import path from "path";
|
3
3
|
import {
|
4
|
-
getFileStream,
|
5
4
|
omitEmptyStringValues,
|
5
|
+
parseObjectEntries,
|
6
6
|
} from "../../common/utils.mjs";
|
7
7
|
import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs";
|
8
8
|
import {
|
9
|
-
|
10
|
-
} from "
|
9
|
+
getFileStream, ConfigurationError,
|
10
|
+
} from "@pipedream/platform";
|
11
11
|
|
12
12
|
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: "1.0
|
16
|
+
version: "1.1.0",
|
17
17
|
type: "action",
|
18
|
-
additionalProps,
|
19
18
|
props: {
|
20
19
|
googleDrive,
|
21
|
-
updateType,
|
22
20
|
drive: {
|
23
21
|
propDefinition: [
|
24
22
|
googleDrive,
|
@@ -38,21 +36,10 @@ export default {
|
|
38
36
|
"The folder you want to upload the file to. If not specified, the file will be placed directly in the drive's top-level folder.",
|
39
37
|
optional: true,
|
40
38
|
},
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
],
|
46
|
-
optional: true,
|
47
|
-
hidden: true,
|
48
|
-
},
|
49
|
-
filePath: {
|
50
|
-
propDefinition: [
|
51
|
-
googleDrive,
|
52
|
-
"filePath",
|
53
|
-
],
|
54
|
-
optional: true,
|
55
|
-
hidden: true,
|
39
|
+
file: {
|
40
|
+
type: "string",
|
41
|
+
label: "File",
|
42
|
+
description: "Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFlie.pdf).",
|
56
43
|
},
|
57
44
|
name: {
|
58
45
|
propDefinition: [
|
@@ -84,32 +71,38 @@ export default {
|
|
84
71
|
"fileId",
|
85
72
|
],
|
86
73
|
label: "File to replace",
|
87
|
-
description: "
|
74
|
+
description: "ID of the file to replace. Leave it empty to upload a new file.",
|
75
|
+
optional: true,
|
76
|
+
},
|
77
|
+
metadata: {
|
78
|
+
type: "object",
|
79
|
+
label: "Metadata",
|
80
|
+
description: "Additional metadata to supply in the upload. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/files) for information on available fields. Values will be parsed as JSON where applicable. Example: `{ \"description\": \"my file description\" }`",
|
88
81
|
optional: true,
|
89
82
|
},
|
90
83
|
},
|
91
84
|
async run({ $ }) {
|
92
85
|
const {
|
93
86
|
parentId,
|
94
|
-
fileUrl,
|
95
|
-
filePath,
|
96
87
|
name,
|
97
88
|
mimeType,
|
98
89
|
} = this;
|
99
90
|
let { uploadType } = this;
|
100
91
|
const driveId = this.googleDrive.getDriveId(this.drive);
|
101
92
|
|
102
|
-
const filename = name || path.basename(
|
93
|
+
const filename = name || path.basename(this.file);
|
103
94
|
|
104
|
-
const file = await getFileStream(
|
105
|
-
$,
|
106
|
-
fileUrl,
|
107
|
-
filePath: filePath?.startsWith("/tmp/")
|
108
|
-
? filePath
|
109
|
-
: `/tmp/${filePath}`,
|
110
|
-
});
|
95
|
+
const file = await getFileStream(this.file);
|
111
96
|
console.log(`Upload type: ${uploadType}.`);
|
112
97
|
|
98
|
+
const metadata = this.metadata
|
99
|
+
? parseObjectEntries(this.metadata)
|
100
|
+
: undefined;
|
101
|
+
|
102
|
+
if (metadata?.mimeType && !mimeType) {
|
103
|
+
throw new ConfigurationError(`Please include the file's original MIME type in the \`Mime Type\` prop. File will be converted to \`${metadata.mimeType}\`.`);
|
104
|
+
}
|
105
|
+
|
113
106
|
let result = null;
|
114
107
|
if (this.fileId) {
|
115
108
|
await this.googleDrive.updateFileMedia(this.fileId, file, omitEmptyStringValues({
|
@@ -120,6 +113,7 @@ export default {
|
|
120
113
|
name: filename,
|
121
114
|
mimeType,
|
122
115
|
uploadType,
|
116
|
+
requestBody: metadata,
|
123
117
|
}));
|
124
118
|
$.export("$summary", `Successfully updated file, "${result.name}"`);
|
125
119
|
} else {
|
@@ -130,6 +124,7 @@ export default {
|
|
130
124
|
parentId,
|
131
125
|
driveId,
|
132
126
|
uploadType,
|
127
|
+
requestBody: metadata,
|
133
128
|
}));
|
134
129
|
$.export("$summary", `Successfully uploaded a new file, "${result.name}"`);
|
135
130
|
}
|
package/common/utils.mjs
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import fs from "fs";
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
axios, ConfigurationError,
|
4
|
+
} from "@pipedream/platform";
|
3
5
|
import {
|
4
6
|
MY_DRIVE_VALUE,
|
5
7
|
LEGACY_MY_DRIVE_VALUE,
|
@@ -257,6 +259,36 @@ function toSingleLineString(multiLineString) {
|
|
257
259
|
.replace(/\s{2,}/g, " ");
|
258
260
|
}
|
259
261
|
|
262
|
+
function optionalParseAsJSON(value) {
|
263
|
+
try {
|
264
|
+
return JSON.parse(value);
|
265
|
+
} catch (e) {
|
266
|
+
return value;
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
function parseObjectEntries(value = {}) {
|
271
|
+
let obj;
|
272
|
+
if (typeof value === "string") {
|
273
|
+
try {
|
274
|
+
obj = JSON.parse(value);
|
275
|
+
} catch (e) {
|
276
|
+
throw new ConfigurationError(`Invalid JSON string provided: ${e.message}`);
|
277
|
+
}
|
278
|
+
} else {
|
279
|
+
obj = value;
|
280
|
+
}
|
281
|
+
return Object.fromEntries(
|
282
|
+
Object.entries(obj).map(([
|
283
|
+
key,
|
284
|
+
value,
|
285
|
+
]) => [
|
286
|
+
key,
|
287
|
+
optionalParseAsJSON(value),
|
288
|
+
]),
|
289
|
+
);
|
290
|
+
}
|
291
|
+
|
260
292
|
export {
|
261
293
|
MY_DRIVE_VALUE,
|
262
294
|
isMyDrive,
|
@@ -269,4 +301,5 @@ export {
|
|
269
301
|
getFilePaths,
|
270
302
|
streamToBuffer,
|
271
303
|
byteToMB,
|
304
|
+
parseObjectEntries,
|
272
305
|
};
|
package/google_drive.app.mjs
CHANGED
@@ -729,12 +729,12 @@ export default {
|
|
729
729
|
// When watching for changes to an entire account, we must pass a pageToken,
|
730
730
|
// which points to the moment in time we want to start watching for changes:
|
731
731
|
// https://developers.google.com/drive/api/v3/manage-changes
|
732
|
+
const fn = () => drive.changes.watch(watchRequest);
|
733
|
+
const { data } = await this.retryWithExponentialBackoff(fn);
|
732
734
|
const {
|
733
735
|
expiration,
|
734
736
|
resourceId,
|
735
|
-
} =
|
736
|
-
await drive.changes.watch(watchRequest)
|
737
|
-
).data;
|
737
|
+
} = data;
|
738
738
|
console.log(`Watch request for drive successful, expiry: ${expiration}`);
|
739
739
|
return {
|
740
740
|
expiration: parseInt(expiration),
|
@@ -744,16 +744,16 @@ export default {
|
|
744
744
|
async watchFile(id, address, fileId) {
|
745
745
|
const drive = this.drive();
|
746
746
|
const requestBody = this._makeWatchRequestBody(id, address);
|
747
|
+
const fn = () => drive.files.watch({
|
748
|
+
fileId,
|
749
|
+
requestBody,
|
750
|
+
supportsAllDrives: true,
|
751
|
+
});
|
752
|
+
const { data } = await this.retryWithExponentialBackoff(fn);
|
747
753
|
const {
|
748
754
|
expiration,
|
749
755
|
resourceId,
|
750
|
-
} =
|
751
|
-
await drive.files.watch({
|
752
|
-
fileId,
|
753
|
-
requestBody,
|
754
|
-
supportsAllDrives: true,
|
755
|
-
})
|
756
|
-
).data;
|
756
|
+
} = data;
|
757
757
|
console.log(
|
758
758
|
`Watch request for file ${fileId} successful, expiry: ${expiration}`,
|
759
759
|
);
|
@@ -1475,5 +1475,32 @@ export default {
|
|
1475
1475
|
const drive = this.drive();
|
1476
1476
|
return (await drive.accessproposals.resolve(opts)).data;
|
1477
1477
|
},
|
1478
|
+
retryWithExponentialBackoff(func, maxAttempts = 3, baseDelayS = 2) {
|
1479
|
+
let attempt = 0;
|
1480
|
+
|
1481
|
+
const execute = async () => {
|
1482
|
+
try {
|
1483
|
+
return await func();
|
1484
|
+
} catch (error) {
|
1485
|
+
// retry for error status 422
|
1486
|
+
const statusCode = error.status || error.response?.status;
|
1487
|
+
if (attempt >= maxAttempts || statusCode !== 422) {
|
1488
|
+
throw error;
|
1489
|
+
}
|
1490
|
+
|
1491
|
+
// display error message for 422 status
|
1492
|
+
const errorMessage = error.message || error.response?.data?.message || error.response?.statusText || "Unknown error";
|
1493
|
+
console.log(`Received 422 error: ${errorMessage}. Retrying attempt ${attempt + 1}/${maxAttempts}...`);
|
1494
|
+
|
1495
|
+
const delayMs = Math.pow(baseDelayS, attempt) * 1000;
|
1496
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
1497
|
+
|
1498
|
+
attempt++;
|
1499
|
+
return execute();
|
1500
|
+
}
|
1501
|
+
};
|
1502
|
+
|
1503
|
+
return execute();
|
1504
|
+
},
|
1478
1505
|
},
|
1479
1506
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pipedream/google_drive",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.10.1",
|
4
4
|
"description": "Pipedream Google_drive Components",
|
5
5
|
"main": "google_drive.app.mjs",
|
6
6
|
"keywords": [
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
12
12
|
"dependencies": {
|
13
13
|
"@googleapis/drive": "^2.3.0",
|
14
|
-
"@pipedream/platform": "^3.0
|
14
|
+
"@pipedream/platform": "^3.1.0",
|
15
15
|
"cron-parser": "^4.9.0",
|
16
16
|
"google-docs-mustaches": "^1.2.2",
|
17
17
|
"got": "13.0.0",
|
@@ -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.
|
18
|
+
version: "0.2.6",
|
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
|
package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs
CHANGED
@@ -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.
|
30
|
+
version: "0.2.6",
|
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
|
@@ -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.
|
9
|
+
version: "0.0.2",
|
10
10
|
type: "source",
|
11
11
|
dedupe: "unique",
|
12
12
|
props: {
|
@@ -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.
|
13
|
+
version: "0.1.14",
|
14
14
|
type: "source",
|
15
15
|
dedupe: "unique",
|
16
16
|
props: {
|
@@ -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.
|
10
|
+
version: "0.0.3",
|
11
11
|
type: "source",
|
12
12
|
dedupe: "unique",
|
13
13
|
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 comment is created or modified in the selected file",
|
20
|
-
version: "1.0.
|
20
|
+
version: "1.0.5",
|
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.
|
27
|
+
version: "0.3.6",
|
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.
|
23
|
+
version: "0.1.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
|
@@ -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.
|
9
|
+
version: "0.1.11",
|
10
10
|
props: {
|
11
11
|
googleDrive: newFilesInstant.props.googleDrive,
|
12
12
|
db: newFilesInstant.props.db,
|