@pipedream/google_drive 1.11.0 → 1.12.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/create-text-file/create-text-file.mjs +102 -0
- package/actions/get-file/get-file.mjs +48 -0
- package/actions/get-user-details/get-user-details.mjs +34 -0
- package/actions/list-permissions/list-permissions.mjs +46 -0
- package/actions/list-shared-drives/list-shared-drives.mjs +52 -0
- package/actions/remove-sharing/remove-sharing.mjs +50 -0
- package/actions/search-files/search-files.mjs +82 -0
- package/actions/share-file/share-file.mjs +86 -0
- package/actions/trash-file/trash-file.mjs +41 -0
- package/package.json +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Readable } from "stream";
|
|
2
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "google_drive-create-text-file",
|
|
6
|
+
name: "Create Text File",
|
|
7
|
+
description:
|
|
8
|
+
"Create a new Google Doc from text content in Google Drive."
|
|
9
|
+
+ " The file is created as a Google Docs document, which can be viewed and edited in the browser."
|
|
10
|
+
+ " Use this when the user asks to create a document, write a file, or save text to Drive."
|
|
11
|
+
+ " To place the file in a specific folder, pass the `parentId` — use **Search Files** with"
|
|
12
|
+
+ " `mimeType = 'application/vnd.google-apps.folder'` to find the folder ID first."
|
|
13
|
+
+ " Supported content formats: plain text, Markdown, HTML, Rich Text, CSV."
|
|
14
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/files/create)",
|
|
15
|
+
version: "0.0.1",
|
|
16
|
+
type: "action",
|
|
17
|
+
annotations: {
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
openWorldHint: true,
|
|
20
|
+
readOnlyHint: false,
|
|
21
|
+
},
|
|
22
|
+
props: {
|
|
23
|
+
googleDrive,
|
|
24
|
+
name: {
|
|
25
|
+
type: "string",
|
|
26
|
+
label: "File Name",
|
|
27
|
+
description: "The name of the new file (e.g., 'Meeting Notes', 'Project Plan').",
|
|
28
|
+
},
|
|
29
|
+
content: {
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Content",
|
|
32
|
+
description: "The text content of the file.",
|
|
33
|
+
optional: true,
|
|
34
|
+
default: "",
|
|
35
|
+
},
|
|
36
|
+
mimeType: {
|
|
37
|
+
type: "string",
|
|
38
|
+
label: "Content Format",
|
|
39
|
+
description:
|
|
40
|
+
"The format of the content being provided. Defaults to plain text.",
|
|
41
|
+
optional: true,
|
|
42
|
+
default: "text/plain",
|
|
43
|
+
options: [
|
|
44
|
+
{
|
|
45
|
+
value: "text/plain",
|
|
46
|
+
label: "Plain Text",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
value: "text/markdown",
|
|
50
|
+
label: "Markdown",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: "text/html",
|
|
54
|
+
label: "HTML",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: "application/rtf",
|
|
58
|
+
label: "Rich Text",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: "text/csv",
|
|
62
|
+
label: "CSV",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
parentId: {
|
|
67
|
+
type: "string",
|
|
68
|
+
label: "Parent Folder ID",
|
|
69
|
+
description:
|
|
70
|
+
"The ID of the folder to create the file in."
|
|
71
|
+
+ " Use **Search Files** with `mimeType = 'application/vnd.google-apps.folder'` to find folder IDs."
|
|
72
|
+
+ " Omit to create in the root of My Drive.",
|
|
73
|
+
optional: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
async run({ $ }) {
|
|
77
|
+
const file = Readable.from([
|
|
78
|
+
this.content,
|
|
79
|
+
]);
|
|
80
|
+
const drive = this.googleDrive.drive();
|
|
81
|
+
|
|
82
|
+
const { data: resp } = await drive.files.create({
|
|
83
|
+
supportsAllDrives: true,
|
|
84
|
+
media: {
|
|
85
|
+
mimeType: this.mimeType,
|
|
86
|
+
body: file,
|
|
87
|
+
},
|
|
88
|
+
requestBody: {
|
|
89
|
+
name: this.name,
|
|
90
|
+
mimeType: "application/vnd.google-apps.document",
|
|
91
|
+
parents: this.parentId
|
|
92
|
+
? [
|
|
93
|
+
this.parentId,
|
|
94
|
+
]
|
|
95
|
+
: undefined,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
$.export("$summary", `Created file: ${resp.name} (${resp.id})`);
|
|
100
|
+
return resp;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-get-file",
|
|
5
|
+
name: "Get File",
|
|
6
|
+
description:
|
|
7
|
+
"Get full metadata for a file or folder by its ID."
|
|
8
|
+
+ " Returns name, MIME type, size, parent folders, sharing permissions, web links, creation/modification dates, and more."
|
|
9
|
+
+ " Use **Search Files** first to find the file ID if you only have the file name."
|
|
10
|
+
+ " By default returns all fields. Pass specific field names to `fields` to reduce the response size."
|
|
11
|
+
+ "\n\nCommon fields: `id`, `name`, `mimeType`, `size`, `parents`, `webViewLink`, `webContentLink`,"
|
|
12
|
+
+ " `createdTime`, `modifiedTime`, `owners`, `permissions`, `description`, `trashed`."
|
|
13
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/files/get)",
|
|
14
|
+
version: "0.0.1",
|
|
15
|
+
type: "action",
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
openWorldHint: true,
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
},
|
|
21
|
+
props: {
|
|
22
|
+
googleDrive,
|
|
23
|
+
fileId: {
|
|
24
|
+
type: "string",
|
|
25
|
+
label: "File ID",
|
|
26
|
+
description:
|
|
27
|
+
"The ID of the file or folder to retrieve."
|
|
28
|
+
+ " Use **Search Files** to find the file ID by name.",
|
|
29
|
+
},
|
|
30
|
+
fields: {
|
|
31
|
+
type: "string",
|
|
32
|
+
label: "Fields",
|
|
33
|
+
description:
|
|
34
|
+
"Comma-separated list of fields to include in the response."
|
|
35
|
+
+ " Example: `id,name,mimeType,webViewLink,parents,permissions`."
|
|
36
|
+
+ " Omit to return all fields.",
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
async run({ $ }) {
|
|
41
|
+
const response = await this.googleDrive.getFile(this.fileId, {
|
|
42
|
+
fields: this.fields || "*",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
$.export("$summary", `Retrieved file: ${response.name}`);
|
|
46
|
+
return response;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-get-user-details",
|
|
5
|
+
name: "Get User Details",
|
|
6
|
+
description:
|
|
7
|
+
"Retrieve the authenticated user's Google Drive identity and storage quota."
|
|
8
|
+
+ " Returns display name, email address, permission ID, and storage usage/limits."
|
|
9
|
+
+ " Use this tool when the user asks 'who am I?' or needs their identity for owner-based queries."
|
|
10
|
+
+ " When the user says 'my files' or 'my documents', call this first to get the owner email,"
|
|
11
|
+
+ " then pass it to **Search Files** with a query like `'user@example.com' in owners`."
|
|
12
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/about/get)",
|
|
13
|
+
version: "0.0.1",
|
|
14
|
+
type: "action",
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: false,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
googleDrive,
|
|
22
|
+
},
|
|
23
|
+
async run({ $ }) {
|
|
24
|
+
const about = await this.googleDrive.getAbout("user,storageQuota");
|
|
25
|
+
|
|
26
|
+
const name =
|
|
27
|
+
about?.user?.displayName
|
|
28
|
+
|| about?.user?.emailAddress
|
|
29
|
+
|| about?.user?.permissionId;
|
|
30
|
+
$.export("$summary", `Retrieved Google Drive user: ${name}`);
|
|
31
|
+
|
|
32
|
+
return about;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-list-permissions",
|
|
5
|
+
name: "List Permissions",
|
|
6
|
+
description:
|
|
7
|
+
"List sharing permissions on a file or folder in Google Drive."
|
|
8
|
+
+ " Returns each permission's ID, type (user/group/domain/anyone), role (owner/writer/commenter/reader), and email address."
|
|
9
|
+
+ " Use **Search Files** first to find the file ID by name."
|
|
10
|
+
+ " Use this tool when the user asks 'who has access to this file?' or needs to audit sharing."
|
|
11
|
+
+ " Pass permission IDs from this response to **Remove Sharing** to revoke access."
|
|
12
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/permissions/list)",
|
|
13
|
+
version: "0.0.1",
|
|
14
|
+
type: "action",
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: false,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
googleDrive,
|
|
22
|
+
fileId: {
|
|
23
|
+
type: "string",
|
|
24
|
+
label: "File ID",
|
|
25
|
+
description:
|
|
26
|
+
"The ID of the file or folder to list permissions for."
|
|
27
|
+
+ " Use **Search Files** to find the file ID by name.",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async run({ $ }) {
|
|
31
|
+
const allPermissions = [];
|
|
32
|
+
let pageToken;
|
|
33
|
+
do {
|
|
34
|
+
const {
|
|
35
|
+
permissions = [], nextPageToken,
|
|
36
|
+
} = await this.googleDrive.listPermissions(pageToken, this.fileId);
|
|
37
|
+
allPermissions.push(...permissions);
|
|
38
|
+
pageToken = nextPageToken;
|
|
39
|
+
} while (pageToken);
|
|
40
|
+
|
|
41
|
+
$.export("$summary", `Found ${allPermissions.length} permission${allPermissions.length === 1
|
|
42
|
+
? ""
|
|
43
|
+
: "s"}`);
|
|
44
|
+
return allPermissions;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-list-shared-drives",
|
|
5
|
+
name: "List Shared Drives",
|
|
6
|
+
description:
|
|
7
|
+
"List shared drives accessible to the authenticated user."
|
|
8
|
+
+ " Returns drive IDs, names, and metadata for each shared drive."
|
|
9
|
+
+ " Use this when the user asks about their shared drives or needs to scope a search to a specific drive."
|
|
10
|
+
+ " Pass a drive ID to **Search Files** `driveId` parameter to search within a specific shared drive."
|
|
11
|
+
+ " Optionally filter by name using the `query` parameter (e.g., `name contains 'Engineering'`)."
|
|
12
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/drives/list)",
|
|
13
|
+
version: "0.0.1",
|
|
14
|
+
type: "action",
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: false,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
googleDrive,
|
|
22
|
+
query: {
|
|
23
|
+
type: "string",
|
|
24
|
+
label: "Query",
|
|
25
|
+
description:
|
|
26
|
+
"Optional. Filter shared drives by name."
|
|
27
|
+
+ " Example: `name contains 'Marketing'`."
|
|
28
|
+
+ " Omit to list all shared drives.",
|
|
29
|
+
optional: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const allDrives = [];
|
|
34
|
+
let pageToken;
|
|
35
|
+
do {
|
|
36
|
+
const {
|
|
37
|
+
drives = [], nextPageToken,
|
|
38
|
+
} = await this.googleDrive.searchDrives({
|
|
39
|
+
q: this.query,
|
|
40
|
+
pageToken,
|
|
41
|
+
pageSize: 100,
|
|
42
|
+
});
|
|
43
|
+
allDrives.push(...drives);
|
|
44
|
+
pageToken = nextPageToken;
|
|
45
|
+
} while (pageToken);
|
|
46
|
+
|
|
47
|
+
$.export("$summary", `Found ${allDrives.length} shared drive${allDrives.length === 1
|
|
48
|
+
? ""
|
|
49
|
+
: "s"}`);
|
|
50
|
+
return allDrives;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-remove-sharing",
|
|
5
|
+
name: "Remove Sharing",
|
|
6
|
+
description:
|
|
7
|
+
"Remove a sharing permission from a file or folder in Google Drive."
|
|
8
|
+
+ " This revokes access for the specified permission."
|
|
9
|
+
+ " Use **List Permissions** first to find the permission ID to remove."
|
|
10
|
+
+ " The owner permission cannot be removed."
|
|
11
|
+
+ " Use **Search Files** to find the file ID by name if needed."
|
|
12
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/permissions/delete)",
|
|
13
|
+
version: "0.0.1",
|
|
14
|
+
type: "action",
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: true,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
readOnlyHint: false,
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
googleDrive,
|
|
22
|
+
fileId: {
|
|
23
|
+
type: "string",
|
|
24
|
+
label: "File ID",
|
|
25
|
+
description:
|
|
26
|
+
"The ID of the file or folder to remove the sharing permission from."
|
|
27
|
+
+ " Use **Search Files** to find the file ID by name.",
|
|
28
|
+
},
|
|
29
|
+
permissionId: {
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Permission ID",
|
|
32
|
+
description:
|
|
33
|
+
"The ID of the permission to remove."
|
|
34
|
+
+ " Use **List Permissions** to find the permission ID.",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
async run({ $ }) {
|
|
38
|
+
await this.googleDrive.deletePermission({
|
|
39
|
+
fileId: this.fileId,
|
|
40
|
+
permissionId: this.permissionId,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
$.export("$summary", `Removed permission ${this.permissionId} from file ${this.fileId}`);
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
fileId: this.fileId,
|
|
47
|
+
permissionId: this.permissionId,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getListFilesOpts } from "../../common/utils.mjs";
|
|
2
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "google_drive-search-files",
|
|
6
|
+
name: "Search Files",
|
|
7
|
+
description:
|
|
8
|
+
"Search for files and folders in Google Drive using the Drive query language."
|
|
9
|
+
+ " This is the primary tool for finding files, folders, spreadsheets, forms, and any other Drive item."
|
|
10
|
+
+ " Returns matching files with their IDs, names, MIME types, and parent folder IDs."
|
|
11
|
+
+ "\n\n**Query syntax** — pass a Drive search query string. Examples:"
|
|
12
|
+
+ "\n- Find by name: `name contains 'Budget'`"
|
|
13
|
+
+ "\n- Exact name match: `name = 'Q4 Report'`"
|
|
14
|
+
+ "\n- Folders only: `mimeType = 'application/vnd.google-apps.folder'`"
|
|
15
|
+
+ "\n- Google Docs: `mimeType = 'application/vnd.google-apps.document'`"
|
|
16
|
+
+ "\n- Spreadsheets: `mimeType = 'application/vnd.google-apps.spreadsheet'`"
|
|
17
|
+
+ "\n- Files in a folder: `'FOLDER_ID' in parents`"
|
|
18
|
+
+ "\n- Not trashed: `trashed = false`"
|
|
19
|
+
+ "\n- Modified after date: `modifiedTime > '2024-01-01T00:00:00'`"
|
|
20
|
+
+ "\n- Combine with AND: `name contains 'Report' and mimeType = 'application/vnd.google-apps.document'`"
|
|
21
|
+
+ "\n- Owner filter: `'user@example.com' in owners`"
|
|
22
|
+
+ "\n\nWhen the user says 'my files', use **Get User Details** first to get the owner email."
|
|
23
|
+
+ " To scope to a shared drive, pass the `driveId` from **List Shared Drives**."
|
|
24
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/search-files)",
|
|
25
|
+
version: "0.0.1",
|
|
26
|
+
type: "action",
|
|
27
|
+
annotations: {
|
|
28
|
+
destructiveHint: false,
|
|
29
|
+
openWorldHint: true,
|
|
30
|
+
readOnlyHint: true,
|
|
31
|
+
},
|
|
32
|
+
props: {
|
|
33
|
+
googleDrive,
|
|
34
|
+
query: {
|
|
35
|
+
type: "string",
|
|
36
|
+
label: "Query",
|
|
37
|
+
description:
|
|
38
|
+
"A Drive search query string. See the tool description for syntax examples."
|
|
39
|
+
+ " Common queries: `name contains 'keyword'`, `mimeType = 'application/vnd.google-apps.folder'`,"
|
|
40
|
+
+ " `'FOLDER_ID' in parents`, `trashed = false`.",
|
|
41
|
+
},
|
|
42
|
+
driveId: {
|
|
43
|
+
type: "string",
|
|
44
|
+
label: "Drive ID",
|
|
45
|
+
description:
|
|
46
|
+
"Optional. Scope the search to a specific shared drive."
|
|
47
|
+
+ " Use **List Shared Drives** to find available drive IDs."
|
|
48
|
+
+ " Omit to search My Drive.",
|
|
49
|
+
optional: true,
|
|
50
|
+
},
|
|
51
|
+
includeItemsFromAllDrives: {
|
|
52
|
+
type: "boolean",
|
|
53
|
+
label: "Include Items From All Drives",
|
|
54
|
+
description:
|
|
55
|
+
"If true, include results from all drives (My Drive and shared drives)."
|
|
56
|
+
+ " Defaults to false.",
|
|
57
|
+
optional: true,
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
async run({ $ }) {
|
|
62
|
+
const opts = getListFilesOpts(this.driveId, {
|
|
63
|
+
q: this.query,
|
|
64
|
+
includeItemsFromAllDrives: this.includeItemsFromAllDrives,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const allFiles = [];
|
|
68
|
+
let pageToken;
|
|
69
|
+
do {
|
|
70
|
+
const {
|
|
71
|
+
files, nextPageToken,
|
|
72
|
+
} = await this.googleDrive.listFilesInPage(pageToken, opts);
|
|
73
|
+
allFiles.push(...files);
|
|
74
|
+
pageToken = nextPageToken;
|
|
75
|
+
} while (pageToken);
|
|
76
|
+
|
|
77
|
+
$.export("$summary", `Found ${allFiles.length} file${allFiles.length === 1
|
|
78
|
+
? ""
|
|
79
|
+
: "s"} matching query "${this.query}"`);
|
|
80
|
+
return allFiles;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-share-file",
|
|
5
|
+
name: "Share File",
|
|
6
|
+
description:
|
|
7
|
+
"Share a file or folder in Google Drive by creating a sharing permission."
|
|
8
|
+
+ " Supports sharing with a specific user, a group, an entire domain, or anyone with the link."
|
|
9
|
+
+ " Use **Search Files** first to find the file ID by name."
|
|
10
|
+
+ "\n\n**Sharing types:**"
|
|
11
|
+
+ "\n- `user` — share with a specific person (requires `emailAddress`)"
|
|
12
|
+
+ "\n- `group` — share with a Google Group (requires `emailAddress`)"
|
|
13
|
+
+ "\n- `domain` — share with everyone in a Google Workspace domain (requires `domain`)"
|
|
14
|
+
+ "\n- `anyone` — share with anyone who has the link (no email/domain needed)"
|
|
15
|
+
+ "\n\n**Roles:** `reader` (view only), `commenter` (can comment), `writer` (can edit)."
|
|
16
|
+
+ " Use **List Permissions** to see existing sharing on a file."
|
|
17
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/permissions/create)",
|
|
18
|
+
version: "0.0.1",
|
|
19
|
+
type: "action",
|
|
20
|
+
annotations: {
|
|
21
|
+
destructiveHint: false,
|
|
22
|
+
openWorldHint: true,
|
|
23
|
+
readOnlyHint: false,
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
googleDrive,
|
|
27
|
+
fileId: {
|
|
28
|
+
type: "string",
|
|
29
|
+
label: "File ID",
|
|
30
|
+
description:
|
|
31
|
+
"The ID of the file or folder to share."
|
|
32
|
+
+ " Use **Search Files** to find the file ID by name.",
|
|
33
|
+
},
|
|
34
|
+
type: {
|
|
35
|
+
type: "string",
|
|
36
|
+
label: "Type",
|
|
37
|
+
description:
|
|
38
|
+
"The type of grantee: `user`, `group`, `domain`, or `anyone`.",
|
|
39
|
+
options: [
|
|
40
|
+
"user",
|
|
41
|
+
"group",
|
|
42
|
+
"domain",
|
|
43
|
+
"anyone",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
role: {
|
|
47
|
+
type: "string",
|
|
48
|
+
label: "Role",
|
|
49
|
+
description:
|
|
50
|
+
"The access level to grant: `reader` (view), `commenter` (comment), or `writer` (edit).",
|
|
51
|
+
options: [
|
|
52
|
+
"reader",
|
|
53
|
+
"commenter",
|
|
54
|
+
"writer",
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
emailAddress: {
|
|
58
|
+
type: "string",
|
|
59
|
+
label: "Email Address",
|
|
60
|
+
description:
|
|
61
|
+
"The email address of the user or group to share with."
|
|
62
|
+
+ " Required when type is `user` or `group`. Ignored for `domain` and `anyone`.",
|
|
63
|
+
optional: true,
|
|
64
|
+
},
|
|
65
|
+
domain: {
|
|
66
|
+
type: "string",
|
|
67
|
+
label: "Domain",
|
|
68
|
+
description:
|
|
69
|
+
"The Google Workspace domain to share with (e.g., `example.com`)."
|
|
70
|
+
+ " Required when type is `domain`. Ignored for other types.",
|
|
71
|
+
optional: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
async run({ $ }) {
|
|
75
|
+
const resp = await this.googleDrive.createPermission(this.fileId, {
|
|
76
|
+
role: this.role,
|
|
77
|
+
type: this.type,
|
|
78
|
+
emailAddress: this.emailAddress,
|
|
79
|
+
domain: this.domain,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const target = this.emailAddress || this.domain || this.type;
|
|
83
|
+
$.export("$summary", `Shared file with ${target} as ${this.role}`);
|
|
84
|
+
return resp;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import googleDrive from "../../google_drive.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "google_drive-trash-file",
|
|
5
|
+
name: "Trash File",
|
|
6
|
+
description:
|
|
7
|
+
"Move a file or folder to the trash in Google Drive."
|
|
8
|
+
+ " This is a reversible operation — the file can be restored from trash within 30 days."
|
|
9
|
+
+ " Use **Search Files** first to find the file ID by name."
|
|
10
|
+
+ " Use this instead of permanent deletion as the safer default."
|
|
11
|
+
+ " To find trashed files, use **Search Files** with `trashed = true`."
|
|
12
|
+
+ " [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update)",
|
|
13
|
+
version: "0.0.1",
|
|
14
|
+
type: "action",
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: true,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
readOnlyHint: false,
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
googleDrive,
|
|
22
|
+
fileId: {
|
|
23
|
+
type: "string",
|
|
24
|
+
label: "File ID",
|
|
25
|
+
description:
|
|
26
|
+
"The ID of the file or folder to move to trash."
|
|
27
|
+
+ " Use **Search Files** to find the file ID by name.",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
async run({ $ }) {
|
|
31
|
+
const resp = await this.googleDrive.updateFile(this.fileId, {
|
|
32
|
+
requestBody: {
|
|
33
|
+
trashed: true,
|
|
34
|
+
},
|
|
35
|
+
fields: "*",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
$.export("$summary", `Moved to trash: ${resp.name} (${resp.id})`);
|
|
39
|
+
return resp;
|
|
40
|
+
},
|
|
41
|
+
};
|