@pipedream/google_drive 0.6.13 → 0.6.15
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/upload-file/upload-file.mjs +11 -24
- package/package.json +3 -1
- 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 +5 -5
- package/sources/common-webhook.mjs +4 -12
- package/sources/new-files-instant/new-files-instant.mjs +11 -7
- package/sources/new-or-modified-comments/new-or-modified-comments.mjs +4 -5
- package/sources/new-or-modified-files/new-or-modified-files.mjs +5 -3
- package/sources/new-or-modified-folders/new-or-modified-folders.mjs +5 -3
- package/sources/new-spreadsheet/new-spreadsheet.mjs +1 -1
@@ -10,7 +10,7 @@ export default {
|
|
10
10
|
key: "google_drive-upload-file",
|
11
11
|
name: "Upload File",
|
12
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.
|
13
|
+
version: "0.1.3",
|
14
14
|
type: "action",
|
15
15
|
props: {
|
16
16
|
googleDrive,
|
@@ -69,26 +69,14 @@ export default {
|
|
69
69
|
default: GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART,
|
70
70
|
optional: true,
|
71
71
|
},
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
fileId: {
|
73
|
+
propDefinition: [
|
74
|
+
googleDrive,
|
75
|
+
"fileId",
|
76
|
+
],
|
77
|
+
label: "File to replace",
|
78
|
+
description: "Id of the file to replace. Leave it empty to upload a new file.",
|
76
79
|
optional: true,
|
77
|
-
default: false,
|
78
|
-
},
|
79
|
-
},
|
80
|
-
methods: {
|
81
|
-
async getFileIdForReplace(filename, parentId) {
|
82
|
-
if (this.replaceFile) {
|
83
|
-
const { files } = await this.googleDrive.listFilesInPage(null, {
|
84
|
-
q: `name = '${filename}' and '${parentId || "root"}' in parents and trashed = false`,
|
85
|
-
fields: "files/id,files/name,files/parents",
|
86
|
-
});
|
87
|
-
if (files.length) {
|
88
|
-
return files[0].id;
|
89
|
-
}
|
90
|
-
}
|
91
|
-
return null;
|
92
80
|
},
|
93
81
|
},
|
94
82
|
async run({ $ }) {
|
@@ -106,7 +94,6 @@ export default {
|
|
106
94
|
const driveId = this.googleDrive.getDriveId(this.drive);
|
107
95
|
|
108
96
|
const filename = name || path.basename(fileUrl || filePath);
|
109
|
-
const fileId = await this.getFileIdForReplace(filename, parentId);
|
110
97
|
|
111
98
|
const file = await getFileStream({
|
112
99
|
$,
|
@@ -116,12 +103,12 @@ export default {
|
|
116
103
|
console.log(`Upload type: ${uploadType}.`);
|
117
104
|
|
118
105
|
let result = null;
|
119
|
-
if (fileId) {
|
120
|
-
await this.googleDrive.updateFileMedia(fileId, file, omitEmptyStringValues({
|
106
|
+
if (this.fileId) {
|
107
|
+
await this.googleDrive.updateFileMedia(this.fileId, file, omitEmptyStringValues({
|
121
108
|
mimeType,
|
122
109
|
uploadType,
|
123
110
|
}));
|
124
|
-
result = await this.googleDrive.updateFile(fileId, omitEmptyStringValues({
|
111
|
+
result = await this.googleDrive.updateFile(this.fileId, omitEmptyStringValues({
|
125
112
|
name: filename,
|
126
113
|
mimeType,
|
127
114
|
uploadType,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pipedream/google_drive",
|
3
|
-
"version": "0.6.
|
3
|
+
"version": "0.6.15",
|
4
4
|
"description": "Pipedream Google_drive Components",
|
5
5
|
"main": "google_drive.app.mjs",
|
6
6
|
"keywords": [
|
@@ -12,6 +12,8 @@
|
|
12
12
|
"dependencies": {
|
13
13
|
"@googleapis/drive": "^2.3.0",
|
14
14
|
"@pipedream/platform": "^1.4.0",
|
15
|
+
"cron-parser": "^4.9.0",
|
16
|
+
"lodash": "^4.17.21",
|
15
17
|
"mime-db": "^1.51.0",
|
16
18
|
"uuid": "^8.3.2"
|
17
19
|
},
|
@@ -17,7 +17,7 @@ export default {
|
|
17
17
|
key: "google_drive-changes-to-specific-files",
|
18
18
|
name: "Changes to Specific Files",
|
19
19
|
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.",
|
20
|
-
version: "0.1.
|
20
|
+
version: "0.1.3",
|
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
|
package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs
CHANGED
@@ -26,7 +26,7 @@ export default {
|
|
26
26
|
key: "google_drive-changes-to-specific-files-shared-drive",
|
27
27
|
name: "Changes to Specific Files (Shared Drive)",
|
28
28
|
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",
|
29
|
-
version: "0.1.
|
29
|
+
version: "0.1.3",
|
30
30
|
type: "source",
|
31
31
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
32
32
|
// https://developers.google.com/drive/api/v3/push#making-watch-requests
|
@@ -41,7 +41,7 @@ export default {
|
|
41
41
|
default: [],
|
42
42
|
options({ prevContext }) {
|
43
43
|
const { nextPageToken } = prevContext;
|
44
|
-
return this.googleDrive.listFilesOptions(nextPageToken, this.
|
44
|
+
return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
|
45
45
|
},
|
46
46
|
},
|
47
47
|
},
|
@@ -51,14 +51,14 @@ export default {
|
|
51
51
|
daysAgo.setDate(daysAgo.getDate() - 30);
|
52
52
|
const timeString = daysAgo.toISOString();
|
53
53
|
|
54
|
-
const args = this.
|
54
|
+
const args = this.getListFilesOpts({
|
55
55
|
q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
|
56
56
|
fields: "files",
|
57
57
|
});
|
58
58
|
|
59
|
-
const {
|
59
|
+
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
60
60
|
|
61
|
-
this.processChanges(
|
61
|
+
this.processChanges(files);
|
62
62
|
},
|
63
63
|
...common.hooks,
|
64
64
|
},
|
@@ -3,6 +3,7 @@ import { v4 as uuid } from "uuid";
|
|
3
3
|
|
4
4
|
import googleDrive from "../google_drive.app.mjs";
|
5
5
|
import { WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS } from "../constants.mjs";
|
6
|
+
import { getListFilesOpts } from "../common/utils.mjs";
|
6
7
|
|
7
8
|
export default {
|
8
9
|
props: {
|
@@ -96,20 +97,11 @@ export default {
|
|
96
97
|
getDriveId(drive = this.drive) {
|
97
98
|
return googleDrive.methods.getDriveId(drive);
|
98
99
|
},
|
99
|
-
|
100
|
-
|
100
|
+
getListFilesOpts(args = {}) {
|
101
|
+
return getListFilesOpts(this.drive, {
|
101
102
|
q: "mimeType != 'application/vnd.google-apps.folder' and trashed = false",
|
102
103
|
...args,
|
103
|
-
};
|
104
|
-
return this.isMyDrive()
|
105
|
-
? opts
|
106
|
-
: {
|
107
|
-
...opts,
|
108
|
-
corpora: "drive",
|
109
|
-
driveId: this.getDriveId(),
|
110
|
-
includeItemsFromAllDrives: true,
|
111
|
-
supportsAllDrives: true,
|
112
|
-
};
|
104
|
+
});
|
113
105
|
},
|
114
106
|
/**
|
115
107
|
* This method returns the types of updates/events from Google Drive that
|
@@ -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 any time a new file is added in your linked Google Drive",
|
13
|
-
version: "0.1.
|
13
|
+
version: "0.1.4",
|
14
14
|
type: "source",
|
15
15
|
dedupe: "unique",
|
16
16
|
props: {
|
@@ -46,14 +46,16 @@ export default {
|
|
46
46
|
daysAgo.setDate(daysAgo.getDate() - 30);
|
47
47
|
const timeString = daysAgo.toISOString();
|
48
48
|
|
49
|
-
const
|
49
|
+
const args = this.getListFilesOpts({
|
50
50
|
q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`,
|
51
51
|
orderBy: "createdTime desc",
|
52
52
|
fields: "*",
|
53
53
|
pageSize: 25,
|
54
54
|
});
|
55
55
|
|
56
|
-
this.
|
56
|
+
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
57
|
+
|
58
|
+
this.emitFiles(files);
|
57
59
|
},
|
58
60
|
...common.hooks,
|
59
61
|
async activate() {
|
@@ -98,19 +100,21 @@ export default {
|
|
98
100
|
const lastFileCreatedTime = this._getLastFileCreatedTime();
|
99
101
|
const timeString = new Date(lastFileCreatedTime).toISOString();
|
100
102
|
|
101
|
-
const
|
103
|
+
const args = this.getListFilesOpts({
|
102
104
|
q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`,
|
103
105
|
orderBy: "createdTime desc",
|
104
106
|
fields: "*",
|
105
107
|
});
|
106
108
|
|
107
|
-
|
109
|
+
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
110
|
+
|
111
|
+
if (!files?.length) {
|
108
112
|
return;
|
109
113
|
}
|
110
114
|
|
111
|
-
this.emitFiles(
|
115
|
+
this.emitFiles(files);
|
112
116
|
|
113
|
-
this._setLastFileCreatedTime(Date.parse(
|
117
|
+
this._setLastFileCreatedTime(Date.parse(files[0].createdTime));
|
114
118
|
},
|
115
119
|
},
|
116
120
|
sampleEmit,
|
@@ -17,8 +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
|
-
|
21
|
-
version: "0.1.3",
|
20
|
+
version: "0.1.4",
|
22
21
|
type: "source",
|
23
22
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
24
23
|
// https://developers.google.com/drive/api/v3/push#making-watch-requests
|
@@ -29,14 +28,14 @@ export default {
|
|
29
28
|
daysAgo.setDate(daysAgo.getDate() - 30);
|
30
29
|
const timeString = daysAgo.toISOString();
|
31
30
|
|
32
|
-
const args = this.
|
31
|
+
const args = this.getListFilesOpts({
|
33
32
|
q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
|
34
33
|
fields: "files",
|
35
34
|
});
|
36
35
|
|
37
|
-
const {
|
36
|
+
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
38
37
|
|
39
|
-
await this.processChanges(
|
38
|
+
await this.processChanges(files);
|
40
39
|
},
|
41
40
|
async activate() {
|
42
41
|
await common.hooks.activate.bind(this)();
|
@@ -21,7 +21,7 @@ export default {
|
|
21
21
|
key: "google_drive-new-or-modified-files",
|
22
22
|
name: "New or Modified Files",
|
23
23
|
description: "Emit new event any time any file in your linked Google Drive is added, modified, or deleted",
|
24
|
-
version: "0.1.
|
24
|
+
version: "0.1.3",
|
25
25
|
type: "source",
|
26
26
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
27
27
|
// https://developers.google.com/drive/api/v3/push#making-watch-requests
|
@@ -32,12 +32,14 @@ export default {
|
|
32
32
|
daysAgo.setDate(daysAgo.getDate() - 30);
|
33
33
|
const timeString = daysAgo.toISOString();
|
34
34
|
|
35
|
-
const
|
35
|
+
const args = this.getListFilesOpts({
|
36
36
|
q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
|
37
37
|
fields: "files",
|
38
38
|
});
|
39
39
|
|
40
|
-
await this.
|
40
|
+
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
41
|
+
|
42
|
+
await this.processChanges(files);
|
41
43
|
},
|
42
44
|
...common.hooks,
|
43
45
|
},
|
@@ -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.1.
|
23
|
+
version: "0.1.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
|
@@ -31,12 +31,14 @@ export default {
|
|
31
31
|
daysAgo.setDate(daysAgo.getDate() - 30);
|
32
32
|
const timeString = daysAgo.toISOString();
|
33
33
|
|
34
|
-
const
|
34
|
+
const args = this.getListFilesOpts({
|
35
35
|
q: `mimeType = "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
|
36
36
|
fields: "files(id, mimeType)",
|
37
37
|
});
|
38
38
|
|
39
|
-
await this.
|
39
|
+
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
40
|
+
|
41
|
+
await this.processChanges(files);
|
40
42
|
},
|
41
43
|
...common.hooks,
|
42
44
|
},
|
@@ -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.1.
|
9
|
+
version: "0.1.2",
|
10
10
|
props: {
|
11
11
|
googleDrive: newFilesInstant.props.googleDrive,
|
12
12
|
db: newFilesInstant.props.db,
|