@pipedream/google_drive 0.6.19 → 0.7.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-file-sharing-preference/add-file-sharing-preference.mjs +60 -27
- package/actions/copy-file/copy-file.mjs +1 -1
- package/actions/create-file/create-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 +2 -2
- 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 +2 -2
- package/actions/find-file/find-file.mjs +1 -1
- package/actions/find-folder/find-folder.mjs +2 -2
- package/actions/find-forms/find-forms.mjs +1 -1
- package/actions/find-spreadsheets/find-spreadsheets.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-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 +2 -2
- package/actions/replace-file/replace-file.mjs +2 -2
- 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 +2 -2
- package/{constants.mjs → common/constants.mjs} +59 -0
- package/common/utils.mjs +1 -1
- package/google_drive.app.mjs +7 -34
- package/package.json +1 -1
- package/sources/changes-to-specific-files/changes-to-specific-files.mjs +11 -5
- package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs +12 -7
- package/sources/common-dedupe-changes.mjs +53 -0
- package/sources/common-webhook.mjs +3 -7
- package/sources/new-files-instant/new-files-instant.mjs +5 -5
- package/sources/new-or-modified-comments/new-or-modified-comments.mjs +8 -5
- package/sources/new-or-modified-files/new-or-modified-files.mjs +23 -8
- package/sources/new-or-modified-folders/new-or-modified-folders.mjs +8 -5
- package/sources/new-shared-drive/new-shared-drive.mjs +1 -1
- package/sources/new-spreadsheet/new-spreadsheet.mjs +8 -4
@@ -1,3 +1,9 @@
|
|
1
|
+
import {
|
2
|
+
GOOGLE_DRIVE_GRANTEE_DOMAIN,
|
3
|
+
GOOGLE_DRIVE_GRANTEE_GROUP,
|
4
|
+
GOOGLE_DRIVE_GRANTEE_USER,
|
5
|
+
GOOGLE_DRIVE_ROLE_OPTIONS,
|
6
|
+
} from "../../common/constants.mjs";
|
1
7
|
import googleDrive from "../../google_drive.app.mjs";
|
2
8
|
|
3
9
|
/**
|
@@ -8,10 +14,10 @@ import googleDrive from "../../google_drive.app.mjs";
|
|
8
14
|
*/
|
9
15
|
export default {
|
10
16
|
key: "google_drive-add-file-sharing-preference",
|
11
|
-
name: "
|
17
|
+
name: "Share File",
|
12
18
|
description:
|
13
|
-
"Add a [sharing](https://support.google.com/drive/answer/7166529)
|
14
|
-
version: "0.1.
|
19
|
+
"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)",
|
20
|
+
version: "0.1.5",
|
15
21
|
type: "action",
|
16
22
|
props: {
|
17
23
|
googleDrive,
|
@@ -33,38 +39,60 @@ export default {
|
|
33
39
|
optional: false,
|
34
40
|
description: "The file or folder to share",
|
35
41
|
},
|
36
|
-
role: {
|
37
|
-
propDefinition: [
|
38
|
-
googleDrive,
|
39
|
-
"role",
|
40
|
-
],
|
41
|
-
},
|
42
42
|
type: {
|
43
43
|
propDefinition: [
|
44
44
|
googleDrive,
|
45
45
|
"type",
|
46
46
|
],
|
47
|
+
reloadProps: true,
|
47
48
|
},
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
},
|
50
|
+
additionalProps() {
|
51
|
+
const obj = {};
|
52
|
+
const emailAddress = {
|
53
|
+
type: "string",
|
54
|
+
label: "Email Address",
|
55
|
+
description:
|
56
|
+
"Enter the email address of the user that you'd like to share the file or folder with (e.g. `alex@altostrat.com`).",
|
57
|
+
};
|
58
|
+
|
59
|
+
switch (this.type) {
|
60
|
+
case GOOGLE_DRIVE_GRANTEE_DOMAIN:
|
61
|
+
obj.domain = {
|
62
|
+
type: "string",
|
63
|
+
label: "Domain",
|
64
|
+
description:
|
65
|
+
"Enter the domain of the G Suite organization that you'd like to share the file or folder with (e.g. `altostrat.com`). All G Suite organization users under this domain will have access to the file you share.",
|
66
|
+
};
|
67
|
+
break;
|
68
|
+
case GOOGLE_DRIVE_GRANTEE_GROUP:
|
69
|
+
obj.emailAddress = {
|
70
|
+
...emailAddress,
|
71
|
+
description:
|
72
|
+
"Enter the email address of the group that you'd like to share the file or folder with (e.g. `hiking-club@altostrat.com`)",
|
73
|
+
};
|
74
|
+
break;
|
75
|
+
case GOOGLE_DRIVE_GRANTEE_USER:
|
76
|
+
obj.emailAddress = emailAddress;
|
77
|
+
break;
|
78
|
+
|
79
|
+
default:
|
80
|
+
break;
|
81
|
+
}
|
82
|
+
|
83
|
+
return {
|
84
|
+
...obj,
|
85
|
+
role: {
|
86
|
+
type: "string",
|
87
|
+
label: "Role",
|
88
|
+
description: "The role granted by this permission",
|
89
|
+
options: GOOGLE_DRIVE_ROLE_OPTIONS,
|
90
|
+
},
|
91
|
+
};
|
60
92
|
},
|
61
93
|
async run({ $ }) {
|
62
94
|
const {
|
63
|
-
fileOrFolderId,
|
64
|
-
role,
|
65
|
-
type,
|
66
|
-
domain,
|
67
|
-
emailAddress,
|
95
|
+
fileOrFolderId, role, type, domain, emailAddress,
|
68
96
|
} = this;
|
69
97
|
// Create the permission for the file
|
70
98
|
await this.googleDrive.createPermission(fileOrFolderId, {
|
@@ -77,7 +105,12 @@ export default {
|
|
77
105
|
// Get the file to get the `webViewLink` sharing URL
|
78
106
|
const resp = await this.googleDrive.getFile(this.fileOrFolderId);
|
79
107
|
const webViewLink = resp.webViewLink;
|
80
|
-
$.export(
|
108
|
+
$.export(
|
109
|
+
"$summary",
|
110
|
+
`Successfully shared file "${resp.name}" with ${this.type} "${
|
111
|
+
this.emailAddress ?? this.domain ?? ""
|
112
|
+
}"`,
|
113
|
+
);
|
81
114
|
return webViewLink;
|
82
115
|
},
|
83
116
|
};
|
@@ -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.1.
|
7
|
+
version: "0.1.4",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
googleDrive,
|
@@ -7,7 +7,7 @@ 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.1.
|
10
|
+
version: "0.1.6",
|
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.1.
|
11
|
+
version: "0.1.4",
|
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 docs](https://developers.google.com/drive/api/v3/reference/files/create) for more information",
|
8
|
-
version: "0.1.
|
8
|
+
version: "0.1.4",
|
9
9
|
type: "action",
|
10
10
|
props: {
|
11
11
|
googleDrive,
|
@@ -7,13 +7,13 @@ import {
|
|
7
7
|
import {
|
8
8
|
MY_DRIVE_VALUE,
|
9
9
|
GOOGLE_DRIVE_FOLDER_MIME_TYPE,
|
10
|
-
} from "../../constants.mjs";
|
10
|
+
} from "../../common/constants.mjs";
|
11
11
|
|
12
12
|
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.1.
|
16
|
+
version: "0.1.4",
|
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.1.
|
7
|
+
version: "0.1.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.1.
|
8
|
+
version: "0.1.4",
|
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.1.
|
7
|
+
version: "0.1.4",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
googleDrive,
|
@@ -2,7 +2,7 @@ import googleDrive from "../../google_drive.app.mjs";
|
|
2
2
|
import fs from "fs";
|
3
3
|
import stream from "stream";
|
4
4
|
import { promisify } from "util";
|
5
|
-
import { GOOGLE_DRIVE_MIME_TYPE_PREFIX } from "../../constants.mjs";
|
5
|
+
import { GOOGLE_DRIVE_MIME_TYPE_PREFIX } from "../../common/constants.mjs";
|
6
6
|
import googleWorkspaceExportFormats from "../google-workspace-export-formats.mjs";
|
7
7
|
import { toSingleLineString } from "../../common/utils.mjs";
|
8
8
|
|
@@ -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.1.
|
21
|
+
version: "0.1.4",
|
22
22
|
type: "action",
|
23
23
|
props: {
|
24
24
|
googleDrive,
|
@@ -5,7 +5,7 @@ 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.1.
|
8
|
+
version: "0.1.4",
|
9
9
|
type: "action",
|
10
10
|
props: {
|
11
11
|
googleDrive,
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import googleDrive from "../../google_drive.app.mjs";
|
2
2
|
import { getListFilesOpts } from "../../common/utils.mjs";
|
3
3
|
|
4
|
-
import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../constants.mjs";
|
4
|
+
import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../common/constants.mjs";
|
5
5
|
|
6
6
|
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.1.
|
10
|
+
version: "0.1.4",
|
11
11
|
type: "action",
|
12
12
|
props: {
|
13
13
|
googleDrive,
|
@@ -5,7 +5,7 @@ export default {
|
|
5
5
|
key: "google_drive-find-forms",
|
6
6
|
name: "Find Forms",
|
7
7
|
description: "List Google Form documents or search for a Form by name. [See the docs](https://developers.google.com/drive/api/v3/search-files) for more information",
|
8
|
-
version: "0.0.
|
8
|
+
version: "0.0.5",
|
9
9
|
type: "action",
|
10
10
|
props: {
|
11
11
|
googleDrive,
|
@@ -5,7 +5,7 @@ export default {
|
|
5
5
|
key: "google_drive-find-spreadsheets",
|
6
6
|
name: "Find Spreadsheets",
|
7
7
|
description: "Search for a specific spreadsheet by name. [See the docs](https://developers.google.com/drive/api/v3/search-files) for more information",
|
8
|
-
version: "0.1.
|
8
|
+
version: "0.1.4",
|
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 docs](https://developers.google.com/drive/api/v3/search-files) for more information",
|
15
|
-
version: "0.1.
|
15
|
+
version: "0.1.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.1.
|
7
|
+
version: "0.1.4",
|
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.8",
|
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.1.
|
7
|
+
version: "0.1.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 { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../constants.mjs";
|
2
|
+
import { GOOGLE_DRIVE_FOLDER_MIME_TYPE } from "../../common/constants.mjs";
|
3
3
|
|
4
4
|
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.1.
|
8
|
+
version: "0.1.4",
|
9
9
|
type: "action",
|
10
10
|
props: {
|
11
11
|
googleDrive,
|
@@ -9,13 +9,13 @@ import {
|
|
9
9
|
import {
|
10
10
|
GOOGLE_DRIVE_UPLOAD_TYPE_MEDIA,
|
11
11
|
GOOGLE_DRIVE_UPLOAD_TYPE_RESUMABLE,
|
12
|
-
} from "../../constants.mjs";
|
12
|
+
} from "../../common/constants.mjs";
|
13
13
|
|
14
14
|
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.1.
|
18
|
+
version: "0.1.4",
|
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.1.
|
7
|
+
version: "0.1.4",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
googleDrive,
|
@@ -8,7 +8,7 @@ export default {
|
|
8
8
|
key: "google_drive-update-file",
|
9
9
|
name: "Update File",
|
10
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.
|
11
|
+
version: "0.1.4",
|
12
12
|
type: "action",
|
13
13
|
props: {
|
14
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.1.
|
7
|
+
version: "0.1.4",
|
8
8
|
type: "action",
|
9
9
|
props: {
|
10
10
|
googleDrive,
|
@@ -4,13 +4,13 @@ import {
|
|
4
4
|
getFileStream,
|
5
5
|
omitEmptyStringValues,
|
6
6
|
} from "../../common/utils.mjs";
|
7
|
-
import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../constants.mjs";
|
7
|
+
import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs";
|
8
8
|
|
9
9
|
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.6",
|
14
14
|
type: "action",
|
15
15
|
props: {
|
16
16
|
googleDrive,
|
@@ -66,6 +66,36 @@ const GOOGLE_DRIVE_UPDATE_TYPES = [
|
|
66
66
|
GOOGLE_DRIVE_NOTIFICATION_UNTRASH,
|
67
67
|
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
68
68
|
];
|
69
|
+
const GOOGLE_DRIVE_UPDATE_TYPE_OPTIONS = [
|
70
|
+
{
|
71
|
+
label: `'${GOOGLE_DRIVE_NOTIFICATION_SYNC}' - A channel was successfully created. You can expect to start receiving notifications for it.`,
|
72
|
+
value: GOOGLE_DRIVE_NOTIFICATION_SYNC,
|
73
|
+
},
|
74
|
+
{
|
75
|
+
label: `'${GOOGLE_DRIVE_NOTIFICATION_ADD}' - A resource was created or shared.`,
|
76
|
+
value: GOOGLE_DRIVE_NOTIFICATION_ADD,
|
77
|
+
},
|
78
|
+
{
|
79
|
+
label: `'${GOOGLE_DRIVE_NOTIFICATION_REMOVE}' - An existing resource was deleted or unshared.`,
|
80
|
+
value: GOOGLE_DRIVE_NOTIFICATION_REMOVE,
|
81
|
+
},
|
82
|
+
{
|
83
|
+
label: `'${GOOGLE_DRIVE_NOTIFICATION_UPDATE}' - One or more properties (metadata) of a resource have been updated.`,
|
84
|
+
value: GOOGLE_DRIVE_NOTIFICATION_UPDATE,
|
85
|
+
},
|
86
|
+
{
|
87
|
+
label: `'${GOOGLE_DRIVE_NOTIFICATION_TRASH}' - A resource has been moved to the trash.`,
|
88
|
+
value: GOOGLE_DRIVE_NOTIFICATION_TRASH,
|
89
|
+
},
|
90
|
+
{
|
91
|
+
label: `'${GOOGLE_DRIVE_NOTIFICATION_UNTRASH}' - A resource has been removed from the trash.`,
|
92
|
+
value: GOOGLE_DRIVE_NOTIFICATION_UNTRASH,
|
93
|
+
},
|
94
|
+
{
|
95
|
+
label: `'${GOOGLE_DRIVE_NOTIFICATION_CHANGE}' - One or more changelog items have been added.`,
|
96
|
+
value: GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
97
|
+
},
|
98
|
+
];
|
69
99
|
|
70
100
|
/**
|
71
101
|
* This is a custom string value to represent the 'My Drive' Google Drive, which
|
@@ -142,6 +172,33 @@ const GOOGLE_DRIVE_ROLES = [
|
|
142
172
|
GOOGLE_DRIVE_ROLE_READER,
|
143
173
|
];
|
144
174
|
|
175
|
+
const GOOGLE_DRIVE_ROLE_OPTIONS = [
|
176
|
+
{
|
177
|
+
label: "Writer - Can make changes, accept or reject suggestions, and share the file with others.",
|
178
|
+
value: GOOGLE_DRIVE_ROLE_WRITER,
|
179
|
+
},
|
180
|
+
{
|
181
|
+
label: "Commenter - Can make comments and suggestions, but can't change or share the file with others.",
|
182
|
+
value: GOOGLE_DRIVE_ROLE_COMMENTER,
|
183
|
+
},
|
184
|
+
{
|
185
|
+
label: "Reader - Can access, but can't change or share the file with others.",
|
186
|
+
value: GOOGLE_DRIVE_ROLE_READER,
|
187
|
+
},
|
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
|
+
];
|
201
|
+
|
145
202
|
const GOOGLE_DRIVE_GRANTEE_USER = "user";
|
146
203
|
const GOOGLE_DRIVE_GRANTEE_GROUP = "group";
|
147
204
|
const GOOGLE_DRIVE_GRANTEE_DOMAIN = "domain";
|
@@ -175,6 +232,7 @@ export {
|
|
175
232
|
GOOGLE_DRIVE_NOTIFICATION_UNTRASH,
|
176
233
|
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
177
234
|
GOOGLE_DRIVE_UPDATE_TYPES,
|
235
|
+
GOOGLE_DRIVE_UPDATE_TYPE_OPTIONS,
|
178
236
|
MY_DRIVE_VALUE,
|
179
237
|
LEGACY_MY_DRIVE_VALUE,
|
180
238
|
WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS,
|
@@ -191,6 +249,7 @@ export {
|
|
191
249
|
GOOGLE_DRIVE_ROLE_COMMENTER,
|
192
250
|
GOOGLE_DRIVE_ROLE_READER,
|
193
251
|
GOOGLE_DRIVE_ROLES,
|
252
|
+
GOOGLE_DRIVE_ROLE_OPTIONS,
|
194
253
|
// Google Drive Grantee Types
|
195
254
|
GOOGLE_DRIVE_GRANTEE_USER,
|
196
255
|
GOOGLE_DRIVE_GRANTEE_GROUP,
|
package/common/utils.mjs
CHANGED
package/google_drive.app.mjs
CHANGED
@@ -10,12 +10,10 @@ import {
|
|
10
10
|
MY_DRIVE_VALUE,
|
11
11
|
WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS,
|
12
12
|
GOOGLE_DRIVE_FOLDER_MIME_TYPE,
|
13
|
-
GOOGLE_DRIVE_ROLES,
|
14
13
|
GOOGLE_DRIVE_GRANTEE_TYPES,
|
15
|
-
GOOGLE_DRIVE_GRANTEE_ANYONE,
|
16
|
-
GOOGLE_DRIVE_ROLE_READER,
|
17
14
|
GOOGLE_DRIVE_UPLOAD_TYPES,
|
18
|
-
|
15
|
+
GOOGLE_DRIVE_UPDATE_TYPE_OPTIONS,
|
16
|
+
} from "./common/constants.mjs";
|
19
17
|
import googleMimeTypes from "./actions/google-mime-types.mjs";
|
20
18
|
|
21
19
|
import {
|
@@ -117,16 +115,15 @@ export default {
|
|
117
115
|
type: "string[]",
|
118
116
|
label: "Types of updates",
|
119
117
|
description: `The types of updates you want to watch for on these files.
|
120
|
-
[See Google's docs]
|
121
|
-
(https://developers.google.com/drive/api/v3/push#understanding-drive-api-notification-events).`,
|
118
|
+
[See Google's docs](https://developers.google.com/drive/api/v3/push#understanding-drive-api-notification-events).`,
|
122
119
|
default: GOOGLE_DRIVE_UPDATE_TYPES,
|
123
|
-
options:
|
120
|
+
options: GOOGLE_DRIVE_UPDATE_TYPE_OPTIONS,
|
124
121
|
},
|
125
122
|
watchForPropertiesChanges: {
|
126
123
|
type: "boolean",
|
127
124
|
label: "Watch for changes to file properties",
|
128
|
-
description: `Watch for changes to [file properties](https://developers.google.com/drive/api/v3/properties)
|
129
|
-
in addition to changes to content. **Defaults to \`false\`, watching for
|
125
|
+
description: `Watch for changes to [custom file properties](https://developers.google.com/drive/api/v3/properties)
|
126
|
+
in addition to changes to content. **Defaults to \`false\`, watching only for changes to content**.`,
|
130
127
|
optional: true,
|
131
128
|
default: false,
|
132
129
|
},
|
@@ -198,37 +195,13 @@ export default {
|
|
198
195
|
optional: true,
|
199
196
|
default: false,
|
200
197
|
},
|
201
|
-
role: {
|
202
|
-
type: "string",
|
203
|
-
label: "Role",
|
204
|
-
description: "The role granted by this permission",
|
205
|
-
optional: true,
|
206
|
-
default: GOOGLE_DRIVE_ROLE_READER,
|
207
|
-
options: GOOGLE_DRIVE_ROLES,
|
208
|
-
},
|
209
198
|
type: {
|
210
199
|
type: "string",
|
211
200
|
label: "Type",
|
212
201
|
description:
|
213
|
-
"The type of the grantee.
|
214
|
-
optional: true,
|
215
|
-
default: GOOGLE_DRIVE_GRANTEE_ANYONE,
|
202
|
+
"The type of the grantee. Sharing with a domain is only valid for G Suite users.",
|
216
203
|
options: GOOGLE_DRIVE_GRANTEE_TYPES,
|
217
204
|
},
|
218
|
-
domain: {
|
219
|
-
type: "string",
|
220
|
-
label: "Domain",
|
221
|
-
description:
|
222
|
-
"The domain of the G Suite organization to which this permission refers if **Type** is `domain` (e.g., `yourcomapany.com`)",
|
223
|
-
optional: true,
|
224
|
-
},
|
225
|
-
emailAddress: {
|
226
|
-
type: "string",
|
227
|
-
label: "Email Address",
|
228
|
-
description:
|
229
|
-
"The email address of the user or group to which this permission refers if **Type** is `user` or `group`",
|
230
|
-
optional: true,
|
231
|
-
},
|
232
205
|
ocrLanguage: {
|
233
206
|
type: "string",
|
234
207
|
label: "OCR Language",
|
package/package.json
CHANGED
@@ -3,9 +3,8 @@ import sampleEmit from "./test-event.mjs";
|
|
3
3
|
import includes from "lodash/includes.js";
|
4
4
|
import { v4 as uuid } from "uuid";
|
5
5
|
|
6
|
-
import { MY_DRIVE_VALUE } from "../../constants.mjs";
|
7
|
-
|
8
6
|
import changesToSpecificFiles from "../changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs";
|
7
|
+
import { MY_DRIVE_VALUE } from "../../common/constants.mjs";
|
9
8
|
|
10
9
|
/**
|
11
10
|
* This source uses the Google Drive API's
|
@@ -16,8 +15,8 @@ export default {
|
|
16
15
|
...changesToSpecificFiles,
|
17
16
|
key: "google_drive-changes-to-specific-files",
|
18
17
|
name: "Changes to Specific Files",
|
19
|
-
description: "Watches for changes to specific files, emitting an event
|
20
|
-
version: "0.
|
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.2.0",
|
21
20
|
type: "source",
|
22
21
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
23
22
|
// https://developers.google.com/drive/api/v3/push#making-watch-requests
|
@@ -222,7 +221,14 @@ export default {
|
|
222
221
|
return;
|
223
222
|
}
|
224
223
|
|
225
|
-
|
224
|
+
const [
|
225
|
+
checkedFile,
|
226
|
+
] = this.checkMinimumInterval([
|
227
|
+
file,
|
228
|
+
]);
|
229
|
+
if (checkedFile) {
|
230
|
+
this.processChange(file, headers);
|
231
|
+
}
|
226
232
|
},
|
227
233
|
sampleEmit,
|
228
234
|
};
|
package/sources/changes-to-specific-files-shared-drive/changes-to-specific-files-shared-drive.mjs
CHANGED
@@ -14,7 +14,8 @@ import {
|
|
14
14
|
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
15
15
|
GOOGLE_DRIVE_NOTIFICATION_ADD,
|
16
16
|
GOOGLE_DRIVE_NOTIFICATION_UPDATE,
|
17
|
-
} from "../../constants.mjs";
|
17
|
+
} from "../../common/constants.mjs";
|
18
|
+
import commonDedupeChanges from "../common-dedupe-changes.mjs";
|
18
19
|
|
19
20
|
/**
|
20
21
|
* This source uses the Google Drive API's
|
@@ -25,8 +26,8 @@ export default {
|
|
25
26
|
...common,
|
26
27
|
key: "google_drive-changes-to-specific-files-shared-drive",
|
27
28
|
name: "Changes to Specific Files (Shared Drive)",
|
28
|
-
description: "Watches for changes to specific files in a shared drive, emitting an event
|
29
|
-
version: "0.
|
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
31
|
type: "source",
|
31
32
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
32
33
|
// https://developers.google.com/drive/api/v3/push#making-watch-requests
|
@@ -37,13 +38,12 @@ export default {
|
|
37
38
|
type: "string[]",
|
38
39
|
label: "Files",
|
39
40
|
description: "The files you want to watch for changes.",
|
40
|
-
optional: true,
|
41
|
-
default: [],
|
42
41
|
options({ prevContext }) {
|
43
42
|
const { nextPageToken } = prevContext;
|
44
43
|
return this.googleDrive.listFilesOptions(nextPageToken, this.getListFilesOpts());
|
45
44
|
},
|
46
45
|
},
|
46
|
+
...commonDedupeChanges.props,
|
47
47
|
},
|
48
48
|
hooks: {
|
49
49
|
async deploy() {
|
@@ -54,6 +54,7 @@ export default {
|
|
54
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
|
+
pageSize: 5,
|
57
58
|
});
|
58
59
|
|
59
60
|
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
@@ -96,7 +97,9 @@ export default {
|
|
96
97
|
},
|
97
98
|
getChanges(headers) {
|
98
99
|
if (!headers) {
|
99
|
-
return
|
100
|
+
return {
|
101
|
+
change: { },
|
102
|
+
};
|
100
103
|
}
|
101
104
|
return {
|
102
105
|
change: {
|
@@ -119,7 +122,9 @@ export default {
|
|
119
122
|
console.log(`Processing ${changedFiles.length} changed files`);
|
120
123
|
console.log(`Changed files: ${JSON.stringify(changedFiles, null, 2)}!!!`);
|
121
124
|
console.log(`Files: ${this.files}!!!`);
|
122
|
-
|
125
|
+
|
126
|
+
const filteredFiles = this.checkMinimumInterval(changedFiles);
|
127
|
+
for (const file of filteredFiles) {
|
123
128
|
if (!this.isFileRelevant(file)) {
|
124
129
|
console.log(`Skipping event for irrelevant file ${file.id}`);
|
125
130
|
continue;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
export default {
|
2
|
+
props: {
|
3
|
+
intervalAlert: {
|
4
|
+
type: "alert",
|
5
|
+
alertType: "info",
|
6
|
+
content: `This source can emit many events in quick succession while a file is being edited. By default, it will not emit another event for the same file for at least 1 minute.
|
7
|
+
\\
|
8
|
+
You can change or disable this minimum interval using the prop \`Minimum Interval Per File\`.`,
|
9
|
+
},
|
10
|
+
perFileInterval: {
|
11
|
+
type: "integer",
|
12
|
+
label: "Minimum Interval Per File",
|
13
|
+
description: "How many minutes to wait until the same file can emit another event.\n\nIf set to `0`, this interval is disabled and all events will be emitted.",
|
14
|
+
min: 0,
|
15
|
+
max: 60,
|
16
|
+
default: 1,
|
17
|
+
optional: true,
|
18
|
+
},
|
19
|
+
},
|
20
|
+
methods: {
|
21
|
+
_getFileIntervals() {
|
22
|
+
return this.db.get("fileIntervals") ?? {};
|
23
|
+
},
|
24
|
+
_setFileIntervals(value) {
|
25
|
+
this.db.set("fileIntervals", value);
|
26
|
+
},
|
27
|
+
checkMinimumInterval(files) {
|
28
|
+
const interval = this.perFileInterval;
|
29
|
+
if (!interval) return files;
|
30
|
+
|
31
|
+
const now = Date.now();
|
32
|
+
const minTimestamp = now - (interval * 1000 * 60);
|
33
|
+
|
34
|
+
const savedData = this._getFileIntervals();
|
35
|
+
Object.entries(savedData).forEach(([
|
36
|
+
key,
|
37
|
+
value,
|
38
|
+
]) => {
|
39
|
+
if (value < minTimestamp) delete savedData[key];
|
40
|
+
});
|
41
|
+
|
42
|
+
const filteredFiles = files.filter(({ id }) => {
|
43
|
+
const exists = !!savedData[id];
|
44
|
+
if (!exists) {
|
45
|
+
savedData[id] = now;
|
46
|
+
}
|
47
|
+
return !exists;
|
48
|
+
});
|
49
|
+
this._setFileIntervals(savedData);
|
50
|
+
return filteredFiles;
|
51
|
+
},
|
52
|
+
},
|
53
|
+
};
|
@@ -2,8 +2,9 @@ import includes from "lodash/includes.js";
|
|
2
2
|
import { v4 as uuid } from "uuid";
|
3
3
|
|
4
4
|
import googleDrive from "../google_drive.app.mjs";
|
5
|
-
import { WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS } from "../constants.mjs";
|
5
|
+
import { WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS } from "../common/constants.mjs";
|
6
6
|
import { getListFilesOpts } from "../common/utils.mjs";
|
7
|
+
import commonDedupeChanges from "./common-dedupe-changes.mjs";
|
7
8
|
|
8
9
|
export default {
|
9
10
|
props: {
|
@@ -18,12 +19,6 @@ export default {
|
|
18
19
|
description: "Defaults to My Drive. To select a [Shared Drive](https://support.google.com/a/users/answer/9310351) instead, select it from this list.",
|
19
20
|
optional: false,
|
20
21
|
},
|
21
|
-
watchForPropertiesChanges: {
|
22
|
-
propDefinition: [
|
23
|
-
googleDrive,
|
24
|
-
"watchForPropertiesChanges",
|
25
|
-
],
|
26
|
-
},
|
27
22
|
timer: {
|
28
23
|
label: "Push notification renewal schedule",
|
29
24
|
description:
|
@@ -73,6 +68,7 @@ export default {
|
|
73
68
|
},
|
74
69
|
},
|
75
70
|
methods: {
|
71
|
+
...commonDedupeChanges.methods,
|
76
72
|
_getSubscription() {
|
77
73
|
return this.db.get("subscription");
|
78
74
|
},
|
@@ -3,14 +3,14 @@ import sampleEmit from "./test-event.mjs";
|
|
3
3
|
import {
|
4
4
|
GOOGLE_DRIVE_NOTIFICATION_ADD,
|
5
5
|
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
6
|
-
} from "../../constants.mjs";
|
6
|
+
} from "../../common/constants.mjs";
|
7
7
|
|
8
8
|
export default {
|
9
9
|
...common,
|
10
10
|
key: "google_drive-new-files-instant",
|
11
11
|
name: "New Files (Instant)",
|
12
|
-
description: "Emit new event
|
13
|
-
version: "0.1.
|
12
|
+
description: "Emit new event when a new file is added in your linked Google Drive",
|
13
|
+
version: "0.1.7",
|
14
14
|
type: "source",
|
15
15
|
dedupe: "unique",
|
16
16
|
props: {
|
@@ -19,7 +19,7 @@ export default {
|
|
19
19
|
type: "string[]",
|
20
20
|
label: "Folders",
|
21
21
|
description:
|
22
|
-
"(Optional) The folders you want to watch
|
22
|
+
"(Optional) The folders you want to watch. Leave blank to watch for any new file in the Drive.",
|
23
23
|
optional: true,
|
24
24
|
default: [],
|
25
25
|
options({ prevContext }) {
|
@@ -50,7 +50,7 @@ export default {
|
|
50
50
|
q: `mimeType != "application/vnd.google-apps.folder" and createdTime > "${timeString}" and trashed = false`,
|
51
51
|
orderBy: "createdTime desc",
|
52
52
|
fields: "*",
|
53
|
-
pageSize:
|
53
|
+
pageSize: 5,
|
54
54
|
});
|
55
55
|
|
56
56
|
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
@@ -9,15 +9,15 @@
|
|
9
9
|
// 2) A timer that runs on regular intervals, renewing the notification channel as needed
|
10
10
|
|
11
11
|
import common from "../common-webhook.mjs";
|
12
|
-
import { GOOGLE_DRIVE_NOTIFICATION_CHANGE } from "../../constants.mjs";
|
12
|
+
import { GOOGLE_DRIVE_NOTIFICATION_CHANGE } from "../../common/constants.mjs";
|
13
13
|
|
14
14
|
export default {
|
15
15
|
...common,
|
16
16
|
key: "google_drive-new-or-modified-comments",
|
17
|
-
name: "New or Modified Comments",
|
17
|
+
name: "New or Modified Comments (Instant)",
|
18
18
|
description:
|
19
|
-
"
|
20
|
-
version: "0.1.
|
19
|
+
"Emit new event when a file comment is created or modified in the selected Drive",
|
20
|
+
version: "0.1.7",
|
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
|
@@ -31,6 +31,7 @@ export default {
|
|
31
31
|
const args = this.getListFilesOpts({
|
32
32
|
q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
|
33
33
|
fields: "files",
|
34
|
+
pageSize: 5,
|
34
35
|
});
|
35
36
|
|
36
37
|
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
@@ -82,7 +83,9 @@ export default {
|
|
82
83
|
},
|
83
84
|
getChanges(headers) {
|
84
85
|
if (!headers) {
|
85
|
-
return
|
86
|
+
return {
|
87
|
+
change: { },
|
88
|
+
};
|
86
89
|
}
|
87
90
|
return {
|
88
91
|
change: {
|
@@ -14,14 +14,17 @@ import {
|
|
14
14
|
GOOGLE_DRIVE_NOTIFICATION_ADD,
|
15
15
|
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
16
16
|
GOOGLE_DRIVE_NOTIFICATION_UPDATE,
|
17
|
-
} from "../../constants.mjs";
|
17
|
+
} from "../../common/constants.mjs";
|
18
|
+
import commonDedupeChanges from "../common-dedupe-changes.mjs";
|
19
|
+
|
20
|
+
const { googleDrive } = common.props;
|
18
21
|
|
19
22
|
export default {
|
20
23
|
...common,
|
21
24
|
key: "google_drive-new-or-modified-files",
|
22
|
-
name: "New or Modified Files",
|
23
|
-
description: "Emit new event
|
24
|
-
version: "0.
|
25
|
+
name: "New or Modified Files (Instant)",
|
26
|
+
description: "Emit new event when a file in the selected Drive is created, modified or trashed.",
|
27
|
+
version: "0.3.0",
|
25
28
|
type: "source",
|
26
29
|
// Dedupe events based on the "x-goog-message-number" header for the target channel:
|
27
30
|
// https://developers.google.com/drive/api/v3/push#making-watch-requests
|
@@ -30,9 +33,9 @@ export default {
|
|
30
33
|
...common.props,
|
31
34
|
folders: {
|
32
35
|
type: "string[]",
|
33
|
-
label: "
|
36
|
+
label: "Folder(s)",
|
34
37
|
description:
|
35
|
-
"(
|
38
|
+
"The folder(s) to watch for changes. Leave blank to watch for any new or modified file in the Drive.",
|
36
39
|
optional: true,
|
37
40
|
default: [],
|
38
41
|
options({ prevContext }) {
|
@@ -52,6 +55,13 @@ export default {
|
|
52
55
|
return this.googleDrive.listFilesOptions(nextPageToken, opts);
|
53
56
|
},
|
54
57
|
},
|
58
|
+
watchForPropertiesChanges: {
|
59
|
+
propDefinition: [
|
60
|
+
googleDrive,
|
61
|
+
"watchForPropertiesChanges",
|
62
|
+
],
|
63
|
+
},
|
64
|
+
...commonDedupeChanges.props,
|
55
65
|
},
|
56
66
|
hooks: {
|
57
67
|
async deploy() {
|
@@ -62,6 +72,7 @@ export default {
|
|
62
72
|
const args = this.getListFilesOpts({
|
63
73
|
q: `mimeType != "application/vnd.google-apps.folder" and modifiedTime > "${timeString}" and trashed = false`,
|
64
74
|
fields: "files",
|
75
|
+
pageSize: 5,
|
65
76
|
});
|
66
77
|
|
67
78
|
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
@@ -105,7 +116,9 @@ export default {
|
|
105
116
|
},
|
106
117
|
async getChanges(headers) {
|
107
118
|
if (!headers) {
|
108
|
-
return
|
119
|
+
return {
|
120
|
+
change: { },
|
121
|
+
};
|
109
122
|
}
|
110
123
|
const resourceUri = headers["x-goog-resource-uri"];
|
111
124
|
const metadata = await this.googleDrive.getFileMetadata(`${resourceUri}&fields=*`);
|
@@ -121,7 +134,9 @@ export default {
|
|
121
134
|
async processChanges(changedFiles, headers) {
|
122
135
|
const changes = await this.getChanges(headers);
|
123
136
|
|
124
|
-
|
137
|
+
const filteredFiles = this.checkMinimumInterval(changedFiles);
|
138
|
+
|
139
|
+
for (const file of filteredFiles) {
|
125
140
|
file.parents = (await this.googleDrive.getFile(file.id, {
|
126
141
|
fields: "parents",
|
127
142
|
})).parents;
|
@@ -13,14 +13,14 @@ import {
|
|
13
13
|
GOOGLE_DRIVE_NOTIFICATION_ADD,
|
14
14
|
GOOGLE_DRIVE_NOTIFICATION_CHANGE,
|
15
15
|
GOOGLE_DRIVE_NOTIFICATION_UPDATE,
|
16
|
-
} from "../../constants.mjs";
|
16
|
+
} from "../../common/constants.mjs";
|
17
17
|
|
18
18
|
export default {
|
19
19
|
...common,
|
20
20
|
key: "google_drive-new-or-modified-folders",
|
21
|
-
name: "New or Modified Folders",
|
22
|
-
description: "Emit new event
|
23
|
-
version: "0.1.
|
21
|
+
name: "New or Modified Folders (Instant)",
|
22
|
+
description: "Emit new event when a folder is created or modified in the selected Drive",
|
23
|
+
version: "0.1.5",
|
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
|
@@ -34,6 +34,7 @@ export default {
|
|
34
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
|
+
pageSize: 5,
|
37
38
|
});
|
38
39
|
|
39
40
|
const { files } = await this.googleDrive.listFilesInPage(null, args);
|
@@ -70,7 +71,9 @@ export default {
|
|
70
71
|
},
|
71
72
|
async getChanges(headers) {
|
72
73
|
if (!headers) {
|
73
|
-
return
|
74
|
+
return {
|
75
|
+
change: { },
|
76
|
+
};
|
74
77
|
}
|
75
78
|
const resourceUri = headers["x-goog-resource-uri"];
|
76
79
|
const metadata = await this.googleDrive.getFileMetadata(`${resourceUri}&fields=*`);
|
@@ -5,21 +5,25 @@ export default {
|
|
5
5
|
key: "google_drive-new-spreadsheet",
|
6
6
|
type: "source",
|
7
7
|
name: "New Spreadsheet (Instant)",
|
8
|
-
description: "Emit new event
|
9
|
-
version: "0.1.
|
8
|
+
description: "Emit new event when a new spreadsheet is created in a drive.",
|
9
|
+
version: "0.1.5",
|
10
10
|
props: {
|
11
11
|
googleDrive: newFilesInstant.props.googleDrive,
|
12
12
|
db: newFilesInstant.props.db,
|
13
13
|
http: newFilesInstant.props.http,
|
14
14
|
drive: newFilesInstant.props.drive,
|
15
15
|
timer: newFilesInstant.props.timer,
|
16
|
-
folders:
|
16
|
+
folders: {
|
17
|
+
...newFilesInstant.props.folders,
|
18
|
+
description:
|
19
|
+
"(Optional) The folders you want to watch. Leave blank to watch for any new spreadsheet in the Drive.",
|
20
|
+
},
|
17
21
|
},
|
18
22
|
hooks: {
|
19
23
|
...newFilesInstant.hooks,
|
20
24
|
async deploy() {
|
21
25
|
// Emit sample records on the first run
|
22
|
-
const spreadsheets = await this.getSpreadsheets(
|
26
|
+
const spreadsheets = await this.getSpreadsheets(5);
|
23
27
|
for (const fileInfo of spreadsheets) {
|
24
28
|
const createdTime = Date.parse(fileInfo.createdTime);
|
25
29
|
this.$emit(fileInfo, {
|