@pipedream/google_drive 1.1.2 → 1.3.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.
- package/actions/add-comment/add-comment.mjs +11 -2
- package/actions/add-file-sharing-preference/add-file-sharing-preference.mjs +1 -1
- 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-comment/delete-comment.mjs +1 -1
- package/actions/delete-file/delete-file.mjs +1 -1
- package/actions/delete-reply/delete-reply.mjs +69 -0
- package/actions/delete-shared-drive/delete-shared-drive.mjs +1 -1
- package/actions/download-file/download-file.mjs +1 -1
- package/actions/find-file/find-file.mjs +1 -1
- package/actions/find-folder/find-folder.mjs +1 -1
- package/actions/find-forms/find-forms.mjs +1 -1
- package/actions/find-spreadsheets/find-spreadsheets.mjs +1 -1
- package/actions/get-comment/get-comment.mjs +65 -0
- package/actions/get-current-user/get-current-user.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-reply/get-reply.mjs +66 -0
- 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-comments/list-comments.mjs +1 -1
- package/actions/list-files/list-files.mjs +1 -1
- package/actions/list-replies/list-replies.mjs +74 -0
- package/actions/move-file/move-file.mjs +1 -1
- package/actions/move-file-to-trash/move-file-to-trash.mjs +1 -1
- package/actions/reply-to-comment/reply-to-comment.mjs +1 -1
- package/actions/resolve-access-proposal/resolve-access-proposal.mjs +1 -1
- package/actions/resolve-comment/resolve-comment.mjs +1 -1
- package/actions/search-shared-drives/search-shared-drives.mjs +1 -1
- package/actions/update-comment/update-comment.mjs +66 -0
- package/actions/update-file/update-file.mjs +1 -1
- package/actions/update-reply/update-reply.mjs +90 -0
- package/actions/update-shared-drive/update-shared-drive.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +1 -1
- package/google_drive.app.mjs +76 -6
- package/package.json +2 -2
- package/sources/changes-to-files-in-drive/changes-to-files-in-drive.mjs +1 -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 +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-files-polling/new-or-modified-files-polling.mjs +220 -0
- package/sources/new-or-modified-files-polling/test-event.mjs +111 -0
- 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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-update-reply",
|
|
5
|
+
name: "Update Reply",
|
|
6
|
+
description: "Update a reply on a specific comment. [See the documentation](https://developers.google.com/workspace/drive/api/reference/rest/v3/replies/update) for more information",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
googleDrive,
|
|
16
|
+
drive: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
googleDrive,
|
|
19
|
+
"watchedDrive",
|
|
20
|
+
],
|
|
21
|
+
optional: true,
|
|
22
|
+
},
|
|
23
|
+
fileIdTip: {
|
|
24
|
+
type: "alert",
|
|
25
|
+
alertType: "info",
|
|
26
|
+
content: "You can use actions such as **Find File** or **List Files** to obtain a file ID, and use its value here.",
|
|
27
|
+
},
|
|
28
|
+
fileId: {
|
|
29
|
+
propDefinition: [
|
|
30
|
+
googleDrive,
|
|
31
|
+
"fileId",
|
|
32
|
+
(c) => ({
|
|
33
|
+
drive: c.drive,
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
description: "The file to obtain info for. You can select a file or use a file ID from a previous step.",
|
|
37
|
+
},
|
|
38
|
+
commentId: {
|
|
39
|
+
propDefinition: [
|
|
40
|
+
googleDrive,
|
|
41
|
+
"commentId",
|
|
42
|
+
(c) => ({
|
|
43
|
+
fileId: c.fileId,
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
description: "The comment to get info for. You can select a comment or use a comment ID from a previous step.",
|
|
47
|
+
},
|
|
48
|
+
replyId: {
|
|
49
|
+
propDefinition: [
|
|
50
|
+
googleDrive,
|
|
51
|
+
"replyId",
|
|
52
|
+
(c) => ({
|
|
53
|
+
fileId: c.fileId,
|
|
54
|
+
commentId: c.commentId,
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
description: "The reply to get info for. You can select a reply or use a reply ID from a previous step.",
|
|
58
|
+
},
|
|
59
|
+
action: {
|
|
60
|
+
type: "string",
|
|
61
|
+
label: "Action",
|
|
62
|
+
description: "The action the reply performed to the parent comment.",
|
|
63
|
+
options: [
|
|
64
|
+
"resolve",
|
|
65
|
+
"reopen",
|
|
66
|
+
],
|
|
67
|
+
optional: true,
|
|
68
|
+
},
|
|
69
|
+
content: {
|
|
70
|
+
type: "string",
|
|
71
|
+
label: "Content",
|
|
72
|
+
description: "The plain text content of the reply.",
|
|
73
|
+
optional: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
async run({ $ }) {
|
|
77
|
+
const response = await this.googleDrive.updateReply({
|
|
78
|
+
replyId: this.replyId,
|
|
79
|
+
fileId: this.fileId,
|
|
80
|
+
commentId: this.commentId,
|
|
81
|
+
requestBody: {
|
|
82
|
+
action: this.action,
|
|
83
|
+
content: this.content,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
$.export("$summary", `Successfully updated reply with ID ${this.replyId}`);
|
|
88
|
+
return response;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -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.15",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -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.
|
|
16
|
+
version: "2.0.8",
|
|
17
17
|
annotations: {
|
|
18
18
|
destructiveHint: false,
|
|
19
19
|
openWorldHint: true,
|
package/google_drive.app.mjs
CHANGED
|
@@ -306,6 +306,37 @@ export default {
|
|
|
306
306
|
};
|
|
307
307
|
},
|
|
308
308
|
},
|
|
309
|
+
replyId: {
|
|
310
|
+
type: "string",
|
|
311
|
+
label: "Reply ID",
|
|
312
|
+
description: "The ID of the reply to get info for.",
|
|
313
|
+
async options({
|
|
314
|
+
fileId, commentId, prevContext,
|
|
315
|
+
}) {
|
|
316
|
+
const { pageToken } = prevContext;
|
|
317
|
+
const {
|
|
318
|
+
replies, nextPageToken,
|
|
319
|
+
} = await this.listReplies(
|
|
320
|
+
pageToken,
|
|
321
|
+
{
|
|
322
|
+
fileId,
|
|
323
|
+
commentId,
|
|
324
|
+
},
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
return {
|
|
328
|
+
options: replies?.map(({
|
|
329
|
+
id, content,
|
|
330
|
+
}) => ({
|
|
331
|
+
label: content,
|
|
332
|
+
value: id,
|
|
333
|
+
})) || [],
|
|
334
|
+
context: {
|
|
335
|
+
pageToken: nextPageToken,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
},
|
|
309
340
|
},
|
|
310
341
|
methods: {
|
|
311
342
|
// Static methods
|
|
@@ -731,13 +762,20 @@ export default {
|
|
|
731
762
|
...args,
|
|
732
763
|
});
|
|
733
764
|
},
|
|
734
|
-
|
|
765
|
+
getComment(fileId, commentId, includeDeleted) {
|
|
766
|
+
const drive = this.drive();
|
|
767
|
+
return drive.comments.get({
|
|
768
|
+
commentId,
|
|
769
|
+
fileId,
|
|
770
|
+
includeDeleted,
|
|
771
|
+
fields: "*",
|
|
772
|
+
});
|
|
773
|
+
},
|
|
774
|
+
createComment(fileId, requestBody) {
|
|
735
775
|
const drive = this.drive();
|
|
736
776
|
return drive.comments.create({
|
|
737
777
|
fileId,
|
|
738
|
-
requestBody
|
|
739
|
-
content,
|
|
740
|
-
},
|
|
778
|
+
requestBody,
|
|
741
779
|
fields: "*",
|
|
742
780
|
});
|
|
743
781
|
},
|
|
@@ -758,12 +796,44 @@ export default {
|
|
|
758
796
|
fields: "*",
|
|
759
797
|
});
|
|
760
798
|
},
|
|
761
|
-
|
|
799
|
+
async listReplies(pageToken, opts = {}) {
|
|
800
|
+
const drive = this.drive();
|
|
801
|
+
const { data } = await drive.replies.list({
|
|
802
|
+
pageToken,
|
|
803
|
+
...opts,
|
|
804
|
+
fields: "*",
|
|
805
|
+
});
|
|
806
|
+
return data;
|
|
807
|
+
},
|
|
808
|
+
getReply(replyId, fileId, commentId) {
|
|
809
|
+
const drive = this.drive();
|
|
810
|
+
return drive.replies.get({
|
|
811
|
+
replyId,
|
|
812
|
+
fileId,
|
|
813
|
+
commentId,
|
|
814
|
+
fields: "*",
|
|
815
|
+
});
|
|
816
|
+
},
|
|
817
|
+
updateReply(args = {}) {
|
|
818
|
+
const drive = this.drive();
|
|
819
|
+
return drive.replies.update({
|
|
820
|
+
...args,
|
|
821
|
+
fields: "*",
|
|
822
|
+
});
|
|
823
|
+
},
|
|
824
|
+
deleteReply(args = {}) {
|
|
825
|
+
const drive = this.drive();
|
|
826
|
+
return drive.replies.delete({
|
|
827
|
+
...args,
|
|
828
|
+
fields: "*",
|
|
829
|
+
});
|
|
830
|
+
},
|
|
831
|
+
updateComment(commentId, fileId, requestBody) {
|
|
762
832
|
const drive = this.drive();
|
|
763
833
|
return drive.comments.update({
|
|
764
834
|
fileId,
|
|
765
835
|
commentId,
|
|
766
|
-
requestBody
|
|
836
|
+
requestBody,
|
|
767
837
|
fields: "*",
|
|
768
838
|
});
|
|
769
839
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/google_drive",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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.1.
|
|
14
|
+
"@pipedream/platform": "^3.1.1",
|
|
15
15
|
"cron-parser": "^4.9.0",
|
|
16
16
|
"google-docs-mustaches": "^1.2.2",
|
|
17
17
|
"got": "13.0.0",
|
|
@@ -13,7 +13,7 @@ export default {
|
|
|
13
13
|
key: "google_drive-changes-to-files-in-drive",
|
|
14
14
|
name: "Changes to Files in Drive",
|
|
15
15
|
description: "Emit new event when a change is made to one of the specified files. [See the documentation](https://developers.google.com/drive/api/v3/reference/changes/watch)",
|
|
16
|
-
version: "0.0.
|
|
16
|
+
version: "0.0.2",
|
|
17
17
|
type: "source",
|
|
18
18
|
dedupe: "unique",
|
|
19
19
|
props: {
|
|
@@ -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 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.3.
|
|
19
|
+
version: "0.3.2",
|
|
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
|
package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs
CHANGED
|
@@ -28,7 +28,7 @@ export default {
|
|
|
28
28
|
key: "google_drive-changes-to-specific-files-shared-drive",
|
|
29
29
|
name: "Changes to Specific Files (Shared Drive)",
|
|
30
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",
|
|
31
|
-
version: "0.3.
|
|
31
|
+
version: "0.3.2",
|
|
32
32
|
type: "source",
|
|
33
33
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
|
34
34
|
// 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.7",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
props: {
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
key: "google_drive-new-files-instant",
|
|
12
12
|
name: "New Files (Instant)",
|
|
13
13
|
description: "Emit new event when a new file is added in your linked Google Drive",
|
|
14
|
-
version: "0.2.
|
|
14
|
+
version: "0.2.2",
|
|
15
15
|
type: "source",
|
|
16
16
|
dedupe: "unique",
|
|
17
17
|
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.1.
|
|
10
|
+
version: "0.1.2",
|
|
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.11",
|
|
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
|
|
@@ -25,7 +25,7 @@ export default {
|
|
|
25
25
|
key: "google_drive-new-or-modified-files",
|
|
26
26
|
name: "New or Modified Files (Instant)",
|
|
27
27
|
description: "Emit new event when a file in the selected Drive is created, modified or trashed.",
|
|
28
|
-
version: "0.4.
|
|
28
|
+
version: "0.4.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
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
2
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
3
|
+
import { getListFilesOpts } from "../../common/utils.mjs";
|
|
4
|
+
import sampleEmit from "./test-event.mjs";
|
|
5
|
+
import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../common/constants.mjs";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
key: "google_drive-new-or-modified-files-polling",
|
|
9
|
+
name: "New or Modified Files (Polling)",
|
|
10
|
+
description: "Emit new event when a file in the selected Drive is created, modified or trashed. [See the documentation](https://developers.google.com/drive/api/v3/reference/changes/list)",
|
|
11
|
+
version: "0.0.1",
|
|
12
|
+
type: "source",
|
|
13
|
+
dedupe: "unique",
|
|
14
|
+
props: {
|
|
15
|
+
googleDrive,
|
|
16
|
+
db: "$.service.db",
|
|
17
|
+
timer: {
|
|
18
|
+
type: "$.interface.timer",
|
|
19
|
+
default: {
|
|
20
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
drive: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
googleDrive,
|
|
26
|
+
"watchedDrive",
|
|
27
|
+
],
|
|
28
|
+
description: "Defaults to My Drive. To select a [Shared Drive](https://support.google.com/a/users/answer/9310351) instead, select it from this list.",
|
|
29
|
+
optional: false,
|
|
30
|
+
},
|
|
31
|
+
files: {
|
|
32
|
+
type: "string[]",
|
|
33
|
+
label: "Files",
|
|
34
|
+
description: "The specific file(s) you want to watch for changes. Leave blank to watch all files in the Drive. Note that events will only be emitted for files directly in these folders (not in their subfolders, unless also selected here)",
|
|
35
|
+
optional: true,
|
|
36
|
+
default: [],
|
|
37
|
+
options({ prevContext }) {
|
|
38
|
+
const { nextPageToken } = prevContext;
|
|
39
|
+
return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
folders: {
|
|
43
|
+
type: "string[]",
|
|
44
|
+
label: "Folders",
|
|
45
|
+
description: "The specific folder(s) to watch for changes. Leave blank to watch all folders in the Drive.",
|
|
46
|
+
optional: true,
|
|
47
|
+
default: [],
|
|
48
|
+
options({ prevContext }) {
|
|
49
|
+
const { nextPageToken } = prevContext;
|
|
50
|
+
const baseOpts = {
|
|
51
|
+
q: "mimeType = 'application/vnd.google-apps.folder' and trashed = false",
|
|
52
|
+
};
|
|
53
|
+
const isMyDrive = this.googleDrive.isMyDrive(this.drive);
|
|
54
|
+
const opts = isMyDrive
|
|
55
|
+
? baseOpts
|
|
56
|
+
: {
|
|
57
|
+
...baseOpts,
|
|
58
|
+
corpora: "drive",
|
|
59
|
+
driveId: this.getDriveId(),
|
|
60
|
+
includeItemsFromAllDrives: true,
|
|
61
|
+
supportsAllDrives: true,
|
|
62
|
+
};
|
|
63
|
+
return this.googleDrive.listFilesOptions(nextPageToken, opts);
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
newFilesOnly: {
|
|
67
|
+
type: "boolean",
|
|
68
|
+
label: "New Files Only",
|
|
69
|
+
description: "If enabled, only emit events for newly created files (based on `createdTime`)",
|
|
70
|
+
default: false,
|
|
71
|
+
optional: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
hooks: {
|
|
75
|
+
async deploy() {
|
|
76
|
+
// Get initial page token for change tracking
|
|
77
|
+
const driveId = this.getDriveId();
|
|
78
|
+
const startPageToken = await this.googleDrive.getPageToken(driveId);
|
|
79
|
+
this._setPageToken(startPageToken);
|
|
80
|
+
|
|
81
|
+
this._setLastRunTimestamp(Date.now());
|
|
82
|
+
|
|
83
|
+
// Emit sample events from the last 30 days
|
|
84
|
+
const daysAgo = new Date();
|
|
85
|
+
daysAgo.setDate(daysAgo.getDate() - 30);
|
|
86
|
+
const timeString = daysAgo.toISOString();
|
|
87
|
+
|
|
88
|
+
const args = this.getListFilesOpts({
|
|
89
|
+
q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
|
|
90
|
+
orderBy: "modifiedTime desc",
|
|
91
|
+
fields: "*",
|
|
92
|
+
pageSize: 5,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
|
96
|
+
|
|
97
|
+
for (const file of files) {
|
|
98
|
+
if (this.shouldProcess(file)) {
|
|
99
|
+
await this.emitFile(file);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
methods: {
|
|
105
|
+
_getPageToken() {
|
|
106
|
+
return this.db.get("pageToken");
|
|
107
|
+
},
|
|
108
|
+
_setPageToken(pageToken) {
|
|
109
|
+
this.db.set("pageToken", pageToken);
|
|
110
|
+
},
|
|
111
|
+
_getLastRunTimestamp() {
|
|
112
|
+
return this.db.get("lastRunTimestamp");
|
|
113
|
+
},
|
|
114
|
+
_setLastRunTimestamp(timestamp) {
|
|
115
|
+
this.db.set("lastRunTimestamp", timestamp);
|
|
116
|
+
},
|
|
117
|
+
getDriveId(drive = this.drive) {
|
|
118
|
+
return this.googleDrive.getDriveId(drive);
|
|
119
|
+
},
|
|
120
|
+
getListFilesOpts(args = {}) {
|
|
121
|
+
return getListFilesOpts(this.drive, {
|
|
122
|
+
q: "mimeType != 'application/vnd.google-apps.folder' and trashed = false",
|
|
123
|
+
...args,
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
shouldProcess(file, lastRunTimestamp) {
|
|
127
|
+
// Skip folders
|
|
128
|
+
if (file.mimeType === GOOGLE_DRIVE_FOLDER_MIME_TYPE) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Check if "new files only" mode is enabled
|
|
133
|
+
if (this.newFilesOnly) {
|
|
134
|
+
const fileCreatedTime = Date.parse(file.createdTime);
|
|
135
|
+
// Only process files created after the last run
|
|
136
|
+
if (fileCreatedTime <= lastRunTimestamp) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Check if specific files are being watched
|
|
142
|
+
if (this.files?.length > 0) {
|
|
143
|
+
if (!this.files.includes(file.id)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Check if specific folders are being watched
|
|
149
|
+
if (this.folders?.length > 0) {
|
|
150
|
+
const watchedFolders = new Set(this.folders);
|
|
151
|
+
if (!file.parents || !file.parents.some((p) => watchedFolders.has(p))) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return true;
|
|
157
|
+
},
|
|
158
|
+
generateMeta(file) {
|
|
159
|
+
const {
|
|
160
|
+
id: fileId,
|
|
161
|
+
name: summary,
|
|
162
|
+
modifiedTime: tsString,
|
|
163
|
+
} = file;
|
|
164
|
+
const ts = Date.parse(tsString);
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
id: `${fileId}-${ts}`,
|
|
168
|
+
summary,
|
|
169
|
+
ts,
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
async emitFile(file) {
|
|
173
|
+
const meta = this.generateMeta(file);
|
|
174
|
+
this.$emit(file, meta);
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
async run() {
|
|
178
|
+
// Store the current run timestamp at the start
|
|
179
|
+
const currentRunTimestamp = Date.now();
|
|
180
|
+
const lastRunTimestamp = this._getLastRunTimestamp();
|
|
181
|
+
|
|
182
|
+
const pageToken = this._getPageToken();
|
|
183
|
+
const driveId = this.getDriveId();
|
|
184
|
+
|
|
185
|
+
const changedFilesStream = this.googleDrive.listChanges(pageToken, driveId);
|
|
186
|
+
|
|
187
|
+
for await (const changedFilesPage of changedFilesStream) {
|
|
188
|
+
console.log("Changed files page:", changedFilesPage);
|
|
189
|
+
const {
|
|
190
|
+
changedFiles,
|
|
191
|
+
nextPageToken,
|
|
192
|
+
} = changedFilesPage;
|
|
193
|
+
|
|
194
|
+
console.log(changedFiles.length
|
|
195
|
+
? `Processing ${changedFiles.length} changed files`
|
|
196
|
+
: "No changed files since last run");
|
|
197
|
+
|
|
198
|
+
for (const file of changedFiles) {
|
|
199
|
+
// Get full file metadata including parents
|
|
200
|
+
const fullFile = await this.googleDrive.getFile(file.id, {
|
|
201
|
+
fields: "*",
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (!this.shouldProcess(fullFile, lastRunTimestamp)) {
|
|
205
|
+
console.log(`Skipping file ${fullFile.name || fullFile.id}`);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
await this.emitFile(fullFile);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Save the next page token after successfully processing
|
|
213
|
+
this._setPageToken(nextPageToken);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Update the last run timestamp after processing all changes
|
|
217
|
+
this._setLastRunTimestamp(currentRunTimestamp);
|
|
218
|
+
},
|
|
219
|
+
sampleEmit,
|
|
220
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"kind": "drive#file",
|
|
3
|
+
"copyRequiresWriterPermission": false,
|
|
4
|
+
"writersCanShare": true,
|
|
5
|
+
"viewedByMe": true,
|
|
6
|
+
"mimeType": "application/vnd.google-apps.spreadsheet",
|
|
7
|
+
"exportLinks": {
|
|
8
|
+
"application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmw4&exportFormat=ods",
|
|
9
|
+
"text/tab-separated-values": "https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXnViTOo&exportFormat=tsv",
|
|
10
|
+
"application/pdf": "https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaBViTOo&exportFormat=pdf",
|
|
11
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbOo&exportFormat=xlsx",
|
|
12
|
+
"text/csv": "https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbBViTOo&exportFormat=csv",
|
|
13
|
+
"application/zip": "https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-VbTmw4Pt2BViTOo&exportFormat=zip",
|
|
14
|
+
"application/vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbViTOo&exportFormat=ods"
|
|
15
|
+
},
|
|
16
|
+
"parents": [
|
|
17
|
+
"0ANs73yKKVA"
|
|
18
|
+
],
|
|
19
|
+
"thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmw4&v=12&s=AMedNnoAAAAAZKWjrEqscucFpYCyRCJqnd0wtBiDtXYh&sz=s220",
|
|
20
|
+
"iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet",
|
|
21
|
+
"shared": false,
|
|
22
|
+
"lastModifyingUser": {
|
|
23
|
+
"displayName": "John Doe",
|
|
24
|
+
"kind": "drive#user",
|
|
25
|
+
"me": true,
|
|
26
|
+
"permissionId": "077423361841532483",
|
|
27
|
+
"emailAddress": "john@doe.com",
|
|
28
|
+
"photoLink": "https://lh3.googleusercontent.com/a/default-user=s64"
|
|
29
|
+
},
|
|
30
|
+
"owners": [
|
|
31
|
+
{
|
|
32
|
+
"displayName": "John Doe",
|
|
33
|
+
"kind": "drive#user",
|
|
34
|
+
"me": true,
|
|
35
|
+
"permissionId": "07742336189483",
|
|
36
|
+
"emailAddress": "john@doe.com",
|
|
37
|
+
"photoLink": "https://lh3.googleusercontent.com/a/default-user=s64"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"webViewLink": "https://docs.google.com/spreadsheets/d/1LmXTIQ0wqKP7T3-l9r127MaTXn3pVbTmwTOo/edit?usp=drivesdk",
|
|
41
|
+
"size": "1024",
|
|
42
|
+
"viewersCanCopyContent": true,
|
|
43
|
+
"permissions": [
|
|
44
|
+
{
|
|
45
|
+
"id": "07742336184153259483",
|
|
46
|
+
"displayName": "John Doe",
|
|
47
|
+
"type": "user",
|
|
48
|
+
"kind": "drive#permission",
|
|
49
|
+
"photoLink": "https://lh3.googleusercontent.com/a/default-user=s64",
|
|
50
|
+
"emailAddress": "john@doe.com",
|
|
51
|
+
"role": "owner",
|
|
52
|
+
"deleted": false,
|
|
53
|
+
"pendingOwner": false
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"hasThumbnail": true,
|
|
57
|
+
"spaces": [
|
|
58
|
+
"drive"
|
|
59
|
+
],
|
|
60
|
+
"id": "1LmXTIQ0wqKP7T3-l9r127Maw4Pt2BViTOo",
|
|
61
|
+
"name": "Pipedream 2213",
|
|
62
|
+
"starred": false,
|
|
63
|
+
"trashed": false,
|
|
64
|
+
"explicitlyTrashed": false,
|
|
65
|
+
"createdTime": "2023-02-06T15:13:33.023Z",
|
|
66
|
+
"modifiedTime": "2023-06-28T12:52:54.570Z",
|
|
67
|
+
"modifiedByMeTime": "2023-06-28T12:52:54.570Z",
|
|
68
|
+
"viewedByMeTime": "2023-06-29T06:30:58.441Z",
|
|
69
|
+
"quotaBytesUsed": "1024",
|
|
70
|
+
"version": "53",
|
|
71
|
+
"ownedByMe": true,
|
|
72
|
+
"isAppAuthorized": false,
|
|
73
|
+
"capabilities": {
|
|
74
|
+
"canChangeViewersCanCopyContent": true,
|
|
75
|
+
"canEdit": true,
|
|
76
|
+
"canCopy": true,
|
|
77
|
+
"canComment": true,
|
|
78
|
+
"canAddChildren": false,
|
|
79
|
+
"canDelete": true,
|
|
80
|
+
"canDownload": true,
|
|
81
|
+
"canListChildren": false,
|
|
82
|
+
"canRemoveChildren": false,
|
|
83
|
+
"canRename": true,
|
|
84
|
+
"canTrash": true,
|
|
85
|
+
"canReadRevisions": true,
|
|
86
|
+
"canChangeCopyRequiresWriterPermission": true,
|
|
87
|
+
"canMoveItemIntoTeamDrive": true,
|
|
88
|
+
"canUntrash": true,
|
|
89
|
+
"canModifyContent": true,
|
|
90
|
+
"canMoveItemOutOfDrive": true,
|
|
91
|
+
"canAddMyDriveParent": false,
|
|
92
|
+
"canRemoveMyDriveParent": true,
|
|
93
|
+
"canMoveItemWithinDrive": true,
|
|
94
|
+
"canShare": true,
|
|
95
|
+
"canMoveChildrenWithinDrive": false,
|
|
96
|
+
"canModifyContentRestriction": true,
|
|
97
|
+
"canChangeSecurityUpdateEnabled": false,
|
|
98
|
+
"canAcceptOwnership": false,
|
|
99
|
+
"canReadLabels": true,
|
|
100
|
+
"canModifyLabels": true
|
|
101
|
+
},
|
|
102
|
+
"thumbnailVersion": "12",
|
|
103
|
+
"modifiedByMe": true,
|
|
104
|
+
"permissionIds": [
|
|
105
|
+
"07742336184153259483"
|
|
106
|
+
],
|
|
107
|
+
"linkShareMetadata": {
|
|
108
|
+
"securityUpdateEligible": false,
|
|
109
|
+
"securityUpdateEnabled": true
|
|
110
|
+
}
|
|
111
|
+
};
|
|
@@ -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.
|
|
23
|
+
version: "0.2.4",
|
|
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.17",
|
|
10
10
|
props: {
|
|
11
11
|
googleDrive: newFilesInstant.props.googleDrive,
|
|
12
12
|
db: newFilesInstant.props.db,
|