@divyacon/piece-google-drive 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +155 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/action/add-permission.action.d.ts +11 -0
- package/dist/lib/action/add-permission.action.d.ts.map +1 -0
- package/dist/lib/action/add-permission.action.js +83 -0
- package/dist/lib/action/add-permission.action.js.map +1 -0
- package/dist/lib/action/create-new-folder.d.ts +12 -0
- package/dist/lib/action/create-new-folder.d.ts.map +1 -0
- package/dist/lib/action/create-new-folder.js +43 -0
- package/dist/lib/action/create-new-folder.js.map +1 -0
- package/dist/lib/action/create-new-text-file.d.ts +14 -0
- package/dist/lib/action/create-new-text-file.d.ts.map +1 -0
- package/dist/lib/action/create-new-text-file.js +81 -0
- package/dist/lib/action/create-new-text-file.js.map +1 -0
- package/dist/lib/action/delete-file.d.ts +8 -0
- package/dist/lib/action/delete-file.d.ts.map +1 -0
- package/dist/lib/action/delete-file.js +38 -0
- package/dist/lib/action/delete-file.js.map +1 -0
- package/dist/lib/action/delete-permission.action.d.ts +9 -0
- package/dist/lib/action/delete-permission.action.d.ts.map +1 -0
- package/dist/lib/action/delete-permission.action.js +84 -0
- package/dist/lib/action/delete-permission.action.js.map +1 -0
- package/dist/lib/action/drive-copy-file.d.ts +10 -0
- package/dist/lib/action/drive-copy-file.d.ts.map +1 -0
- package/dist/lib/action/drive-copy-file.js +84 -0
- package/dist/lib/action/drive-copy-file.js.map +1 -0
- package/dist/lib/action/drive-create-comment.d.ts +8 -0
- package/dist/lib/action/drive-create-comment.d.ts.map +1 -0
- package/dist/lib/action/drive-create-comment.js +60 -0
- package/dist/lib/action/drive-create-comment.js.map +1 -0
- package/dist/lib/action/drive-create-file-from-text.d.ts +10 -0
- package/dist/lib/action/drive-create-file-from-text.d.ts.map +1 -0
- package/dist/lib/action/drive-create-file-from-text.js +91 -0
- package/dist/lib/action/drive-create-file-from-text.js.map +1 -0
- package/dist/lib/action/drive-create-folder.d.ts +8 -0
- package/dist/lib/action/drive-create-folder.d.ts.map +1 -0
- package/dist/lib/action/drive-create-folder.js +48 -0
- package/dist/lib/action/drive-create-folder.js.map +1 -0
- package/dist/lib/action/drive-create-reply.d.ts +10 -0
- package/dist/lib/action/drive-create-reply.d.ts.map +1 -0
- package/dist/lib/action/drive-create-reply.js +81 -0
- package/dist/lib/action/drive-create-reply.js.map +1 -0
- package/dist/lib/action/drive-create-shared-drive.d.ts +7 -0
- package/dist/lib/action/drive-create-shared-drive.d.ts.map +1 -0
- package/dist/lib/action/drive-create-shared-drive.js +53 -0
- package/dist/lib/action/drive-create-shared-drive.js.map +1 -0
- package/dist/lib/action/drive-delete-file.d.ts +7 -0
- package/dist/lib/action/drive-delete-file.d.ts.map +1 -0
- package/dist/lib/action/drive-delete-file.js +39 -0
- package/dist/lib/action/drive-delete-file.js.map +1 -0
- package/dist/lib/action/drive-delete-reply.d.ts +9 -0
- package/dist/lib/action/drive-delete-reply.d.ts.map +1 -0
- package/dist/lib/action/drive-delete-reply.js +64 -0
- package/dist/lib/action/drive-delete-reply.js.map +1 -0
- package/dist/lib/action/drive-delete-shared-drive.d.ts +7 -0
- package/dist/lib/action/drive-delete-shared-drive.d.ts.map +1 -0
- package/dist/lib/action/drive-delete-shared-drive.js +55 -0
- package/dist/lib/action/drive-delete-shared-drive.js.map +1 -0
- package/dist/lib/action/drive-download-file.d.ts +8 -0
- package/dist/lib/action/drive-download-file.d.ts.map +1 -0
- package/dist/lib/action/drive-download-file.js +37 -0
- package/dist/lib/action/drive-download-file.js.map +1 -0
- package/dist/lib/action/drive-empty-trash.d.ts +7 -0
- package/dist/lib/action/drive-empty-trash.d.ts.map +1 -0
- package/dist/lib/action/drive-empty-trash.js +47 -0
- package/dist/lib/action/drive-empty-trash.js.map +1 -0
- package/dist/lib/action/drive-export-workspace-file.d.ts +8 -0
- package/dist/lib/action/drive-export-workspace-file.d.ts.map +1 -0
- package/dist/lib/action/drive-export-workspace-file.js +116 -0
- package/dist/lib/action/drive-export-workspace-file.js.map +1 -0
- package/dist/lib/action/drive-get-about.d.ts +5 -0
- package/dist/lib/action/drive-get-about.d.ts.map +1 -0
- package/dist/lib/action/drive-get-about.js +43 -0
- package/dist/lib/action/drive-get-about.js.map +1 -0
- package/dist/lib/action/drive-get-file.d.ts +7 -0
- package/dist/lib/action/drive-get-file.d.ts.map +1 -0
- package/dist/lib/action/drive-get-file.js +46 -0
- package/dist/lib/action/drive-get-file.js.map +1 -0
- package/dist/lib/action/drive-get-reply.d.ts +9 -0
- package/dist/lib/action/drive-get-reply.d.ts.map +1 -0
- package/dist/lib/action/drive-get-reply.js +66 -0
- package/dist/lib/action/drive-get-reply.js.map +1 -0
- package/dist/lib/action/drive-get-shared-drive.d.ts +7 -0
- package/dist/lib/action/drive-get-shared-drive.d.ts.map +1 -0
- package/dist/lib/action/drive-get-shared-drive.js +52 -0
- package/dist/lib/action/drive-get-shared-drive.js.map +1 -0
- package/dist/lib/action/drive-list-comments.d.ts +7 -0
- package/dist/lib/action/drive-list-comments.d.ts.map +1 -0
- package/dist/lib/action/drive-list-comments.js +60 -0
- package/dist/lib/action/drive-list-comments.js.map +1 -0
- package/dist/lib/action/drive-list-files.d.ts +11 -0
- package/dist/lib/action/drive-list-files.d.ts.map +1 -0
- package/dist/lib/action/drive-list-files.js +174 -0
- package/dist/lib/action/drive-list-files.js.map +1 -0
- package/dist/lib/action/drive-list-permissions.d.ts +7 -0
- package/dist/lib/action/drive-list-permissions.d.ts.map +1 -0
- package/dist/lib/action/drive-list-permissions.js +59 -0
- package/dist/lib/action/drive-list-permissions.js.map +1 -0
- package/dist/lib/action/drive-list-replies.d.ts +8 -0
- package/dist/lib/action/drive-list-replies.d.ts.map +1 -0
- package/dist/lib/action/drive-list-replies.js +65 -0
- package/dist/lib/action/drive-list-replies.js.map +1 -0
- package/dist/lib/action/drive-list-shared-drives.d.ts +8 -0
- package/dist/lib/action/drive-list-shared-drives.d.ts.map +1 -0
- package/dist/lib/action/drive-list-shared-drives.js +60 -0
- package/dist/lib/action/drive-list-shared-drives.js.map +1 -0
- package/dist/lib/action/drive-move-file.d.ts +8 -0
- package/dist/lib/action/drive-move-file.d.ts.map +1 -0
- package/dist/lib/action/drive-move-file.js +57 -0
- package/dist/lib/action/drive-move-file.js.map +1 -0
- package/dist/lib/action/drive-remove-permission.d.ts +9 -0
- package/dist/lib/action/drive-remove-permission.d.ts.map +1 -0
- package/dist/lib/action/drive-remove-permission.js +75 -0
- package/dist/lib/action/drive-remove-permission.js.map +1 -0
- package/dist/lib/action/drive-replace-file-content.d.ts +9 -0
- package/dist/lib/action/drive-replace-file-content.d.ts.map +1 -0
- package/dist/lib/action/drive-replace-file-content.js +67 -0
- package/dist/lib/action/drive-replace-file-content.js.map +1 -0
- package/dist/lib/action/drive-save-file-as-pdf.d.ts +9 -0
- package/dist/lib/action/drive-save-file-as-pdf.d.ts.map +1 -0
- package/dist/lib/action/drive-save-file-as-pdf.js +73 -0
- package/dist/lib/action/drive-save-file-as-pdf.js.map +1 -0
- package/dist/lib/action/drive-search-files.d.ts +12 -0
- package/dist/lib/action/drive-search-files.d.ts.map +1 -0
- package/dist/lib/action/drive-search-files.js +130 -0
- package/dist/lib/action/drive-search-files.js.map +1 -0
- package/dist/lib/action/drive-set-public-access.d.ts +8 -0
- package/dist/lib/action/drive-set-public-access.d.ts.map +1 -0
- package/dist/lib/action/drive-set-public-access.js +71 -0
- package/dist/lib/action/drive-set-public-access.js.map +1 -0
- package/dist/lib/action/drive-share-file.d.ts +10 -0
- package/dist/lib/action/drive-share-file.d.ts.map +1 -0
- package/dist/lib/action/drive-share-file.js +69 -0
- package/dist/lib/action/drive-share-file.js.map +1 -0
- package/dist/lib/action/drive-trash-file.d.ts +7 -0
- package/dist/lib/action/drive-trash-file.d.ts.map +1 -0
- package/dist/lib/action/drive-trash-file.js +45 -0
- package/dist/lib/action/drive-trash-file.js.map +1 -0
- package/dist/lib/action/drive-untrash-file.d.ts +7 -0
- package/dist/lib/action/drive-untrash-file.d.ts.map +1 -0
- package/dist/lib/action/drive-untrash-file.js +54 -0
- package/dist/lib/action/drive-untrash-file.js.map +1 -0
- package/dist/lib/action/drive-update-file-metadata.d.ts +10 -0
- package/dist/lib/action/drive-update-file-metadata.d.ts.map +1 -0
- package/dist/lib/action/drive-update-file-metadata.js +79 -0
- package/dist/lib/action/drive-update-file-metadata.js.map +1 -0
- package/dist/lib/action/drive-update-permission.d.ts +9 -0
- package/dist/lib/action/drive-update-permission.d.ts.map +1 -0
- package/dist/lib/action/drive-update-permission.js +93 -0
- package/dist/lib/action/drive-update-permission.js.map +1 -0
- package/dist/lib/action/drive-update-reply.d.ts +10 -0
- package/dist/lib/action/drive-update-reply.d.ts.map +1 -0
- package/dist/lib/action/drive-update-reply.js +72 -0
- package/dist/lib/action/drive-update-reply.js.map +1 -0
- package/dist/lib/action/drive-update-shared-drive.d.ts +8 -0
- package/dist/lib/action/drive-update-shared-drive.d.ts.map +1 -0
- package/dist/lib/action/drive-update-shared-drive.js +62 -0
- package/dist/lib/action/drive-update-shared-drive.js.map +1 -0
- package/dist/lib/action/drive-upload-file.d.ts +9 -0
- package/dist/lib/action/drive-upload-file.d.ts.map +1 -0
- package/dist/lib/action/drive-upload-file.js +71 -0
- package/dist/lib/action/drive-upload-file.js.map +1 -0
- package/dist/lib/action/drive-upload-from-url.d.ts +10 -0
- package/dist/lib/action/drive-upload-from-url.d.ts.map +1 -0
- package/dist/lib/action/drive-upload-from-url.js +90 -0
- package/dist/lib/action/drive-upload-from-url.js.map +1 -0
- package/dist/lib/action/duplicate-file.action.d.ts +11 -0
- package/dist/lib/action/duplicate-file.action.d.ts.map +1 -0
- package/dist/lib/action/duplicate-file.action.js +83 -0
- package/dist/lib/action/duplicate-file.action.js.map +1 -0
- package/dist/lib/action/get-file-by-id.d.ts +8 -0
- package/dist/lib/action/get-file-by-id.d.ts.map +1 -0
- package/dist/lib/action/get-file-by-id.js +45 -0
- package/dist/lib/action/get-file-by-id.js.map +1 -0
- package/dist/lib/action/list-files.action.d.ts +11 -0
- package/dist/lib/action/list-files.action.d.ts.map +1 -0
- package/dist/lib/action/list-files.action.js +165 -0
- package/dist/lib/action/list-files.action.js.map +1 -0
- package/dist/lib/action/move-file.d.ts +12 -0
- package/dist/lib/action/move-file.d.ts.map +1 -0
- package/dist/lib/action/move-file.js +52 -0
- package/dist/lib/action/move-file.js.map +1 -0
- package/dist/lib/action/read-file.d.ts +8 -0
- package/dist/lib/action/read-file.d.ts.map +1 -0
- package/dist/lib/action/read-file.js +34 -0
- package/dist/lib/action/read-file.js.map +1 -0
- package/dist/lib/action/save-file-as-pdf.action.d.ts +10 -0
- package/dist/lib/action/save-file-as-pdf.action.d.ts.map +1 -0
- package/dist/lib/action/save-file-as-pdf.action.js +72 -0
- package/dist/lib/action/save-file-as-pdf.action.js.map +1 -0
- package/dist/lib/action/search-folder-or-file.action.d.ts +15 -0
- package/dist/lib/action/search-folder-or-file.action.d.ts.map +1 -0
- package/dist/lib/action/search-folder-or-file.action.js +119 -0
- package/dist/lib/action/search-folder-or-file.action.js.map +1 -0
- package/dist/lib/action/send-to-trash.d.ts +8 -0
- package/dist/lib/action/send-to-trash.d.ts.map +1 -0
- package/dist/lib/action/send-to-trash.js +44 -0
- package/dist/lib/action/send-to-trash.js.map +1 -0
- package/dist/lib/action/set-public-access.d.ts +8 -0
- package/dist/lib/action/set-public-access.d.ts.map +1 -0
- package/dist/lib/action/set-public-access.js +66 -0
- package/dist/lib/action/set-public-access.js.map +1 -0
- package/dist/lib/action/upload-file.d.ts +13 -0
- package/dist/lib/action/upload-file.d.ts.map +1 -0
- package/dist/lib/action/upload-file.js +58 -0
- package/dist/lib/action/upload-file.js.map +1 -0
- package/dist/lib/auth.d.ts +11 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +87 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/common/get-file-content.d.ts +4 -0
- package/dist/lib/common/get-file-content.d.ts.map +1 -0
- package/dist/lib/common/get-file-content.js +69 -0
- package/dist/lib/common/get-file-content.js.map +1 -0
- package/dist/lib/common/index.d.ts +23 -0
- package/dist/lib/common/index.d.ts.map +1 -0
- package/dist/lib/common/index.js +152 -0
- package/dist/lib/common/index.js.map +1 -0
- package/dist/lib/output-schemas.d.ts +53 -0
- package/dist/lib/output-schemas.d.ts.map +1 -0
- package/dist/lib/output-schemas.js +2022 -0
- package/dist/lib/output-schemas.js.map +1 -0
- package/dist/lib/triggers/new-file.d.ts +43 -0
- package/dist/lib/triggers/new-file.d.ts.map +1 -0
- package/dist/lib/triggers/new-file.js +107 -0
- package/dist/lib/triggers/new-file.js.map +1 -0
- package/dist/lib/triggers/new-folder.d.ts +39 -0
- package/dist/lib/triggers/new-folder.d.ts.map +1 -0
- package/dist/lib/triggers/new-folder.js +71 -0
- package/dist/lib/triggers/new-folder.js.map +1 -0
- package/package.json +50 -4
- package/src/index.ts +149 -0
- package/src/lib/action/add-permission.action.ts +82 -0
- package/src/lib/action/create-new-folder.ts +42 -0
- package/src/lib/action/create-new-text-file.ts +80 -0
- package/src/lib/action/delete-file.ts +33 -0
- package/src/lib/action/delete-permission.action.ts +84 -0
- package/src/lib/action/drive-copy-file.ts +86 -0
- package/src/lib/action/drive-create-comment.ts +61 -0
- package/src/lib/action/drive-create-file-from-text.ts +99 -0
- package/src/lib/action/drive-create-folder.ts +49 -0
- package/src/lib/action/drive-create-reply.ts +84 -0
- package/src/lib/action/drive-create-shared-drive.ts +52 -0
- package/src/lib/action/drive-delete-file.ts +36 -0
- package/src/lib/action/drive-delete-reply.ts +65 -0
- package/src/lib/action/drive-delete-shared-drive.ts +57 -0
- package/src/lib/action/drive-download-file.ts +38 -0
- package/src/lib/action/drive-empty-trash.ts +47 -0
- package/src/lib/action/drive-export-workspace-file.ts +129 -0
- package/src/lib/action/drive-get-about.ts +40 -0
- package/src/lib/action/drive-get-file.ts +40 -0
- package/src/lib/action/drive-get-reply.ts +67 -0
- package/src/lib/action/drive-get-shared-drive.ts +52 -0
- package/src/lib/action/drive-list-comments.ts +61 -0
- package/src/lib/action/drive-list-files.ts +238 -0
- package/src/lib/action/drive-list-permissions.ts +60 -0
- package/src/lib/action/drive-list-replies.ts +66 -0
- package/src/lib/action/drive-list-shared-drives.ts +59 -0
- package/src/lib/action/drive-move-file.ts +56 -0
- package/src/lib/action/drive-remove-permission.ts +75 -0
- package/src/lib/action/drive-replace-file-content.ts +71 -0
- package/src/lib/action/drive-save-file-as-pdf.ts +80 -0
- package/src/lib/action/drive-search-files.ts +127 -0
- package/src/lib/action/drive-set-public-access.ts +75 -0
- package/src/lib/action/drive-share-file.ts +69 -0
- package/src/lib/action/drive-trash-file.ts +41 -0
- package/src/lib/action/drive-untrash-file.ts +54 -0
- package/src/lib/action/drive-update-file-metadata.ts +82 -0
- package/src/lib/action/drive-update-permission.ts +100 -0
- package/src/lib/action/drive-update-reply.ts +73 -0
- package/src/lib/action/drive-update-shared-drive.ts +63 -0
- package/src/lib/action/drive-upload-file.ts +80 -0
- package/src/lib/action/drive-upload-from-url.ts +107 -0
- package/src/lib/action/duplicate-file.action.ts +82 -0
- package/src/lib/action/get-file-by-id.ts +37 -0
- package/src/lib/action/list-files.action.ts +214 -0
- package/src/lib/action/move-file.ts +48 -0
- package/src/lib/action/read-file.ts +28 -0
- package/src/lib/action/save-file-as-pdf.action.ts +76 -0
- package/src/lib/action/search-folder-or-file.action.ts +112 -0
- package/src/lib/action/send-to-trash.ts +38 -0
- package/src/lib/action/set-public-access.ts +68 -0
- package/src/lib/action/upload-file.ts +55 -0
- package/src/lib/auth.ts +79 -0
- package/src/lib/common/get-file-content.ts +109 -0
- package/src/lib/common/index.ts +182 -0
- package/src/lib/output-schemas.ts +2070 -0
- package/src/lib/triggers/new-file.ts +119 -0
- package/src/lib/triggers/new-folder.ts +78 -0
- package/README.md +0 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
|
|
5
|
+
export const driveDeleteFile = createAction({
|
|
6
|
+
auth: googleDriveAuth,
|
|
7
|
+
name: 'drive_delete_file',
|
|
8
|
+
displayName: 'Delete File Permanently',
|
|
9
|
+
description: 'Permanently delete a Drive file by ID, bypassing the trash.',
|
|
10
|
+
audience: 'ai',
|
|
11
|
+
aiMetadata: {
|
|
12
|
+
description:
|
|
13
|
+
'Permanently deletes a file by ID, bypassing the trash — unrecoverable. Use only when permanent removal is intended; for reversible deletion prefer drive_trash_file. A repeat call fails because the file no longer exists.',
|
|
14
|
+
idempotent: false,
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
file_id: Property.ShortText({
|
|
18
|
+
displayName: 'File ID',
|
|
19
|
+
description:
|
|
20
|
+
'The ID of the file to permanently delete. Resolve it via drive_search_files or drive_get_file.',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
async run(context) {
|
|
25
|
+
const authClient = await createGoogleClient(context.auth);
|
|
26
|
+
|
|
27
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
28
|
+
|
|
29
|
+
const response = await drive.files.delete({
|
|
30
|
+
fileId: context.propsValue.file_id,
|
|
31
|
+
supportsAllDrives: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return response.data;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveDeleteReplyOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveDeleteReply = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_delete_reply',
|
|
9
|
+
displayName: 'Delete Reply',
|
|
10
|
+
description: 'Permanently delete a reply on a Drive comment by ID.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Permanently deletes a reply by ID (resolve via drive_list_replies). Use to remove a reply you control; to edit it instead use drive_update_reply. A repeat call fails because the reply is already gone, so it is not safe to retry blindly.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveDeleteReplyOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
file_id: Property.ShortText({
|
|
20
|
+
displayName: 'File ID',
|
|
21
|
+
description:
|
|
22
|
+
'The ID of the file the comment belongs to. Resolve it via drive_search_files or drive_get_file.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
comment_id: Property.ShortText({
|
|
26
|
+
displayName: 'Comment ID',
|
|
27
|
+
description: 'The ID of the parent comment. Resolve it via drive_list_comments.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
reply_id: Property.ShortText({
|
|
31
|
+
displayName: 'Reply ID',
|
|
32
|
+
description: 'The ID of the reply to delete. Resolve it via drive_list_replies.',
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
async run(context) {
|
|
37
|
+
const { file_id, comment_id, reply_id } = context.propsValue;
|
|
38
|
+
|
|
39
|
+
const authClient = await createGoogleClient(context.auth);
|
|
40
|
+
|
|
41
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await drive.replies.delete({
|
|
45
|
+
fileId: file_id,
|
|
46
|
+
commentId: comment_id,
|
|
47
|
+
replyId: reply_id,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return { success: true, reply_id };
|
|
51
|
+
} catch (error: any) {
|
|
52
|
+
if (error.code === 404) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`File, comment, or reply not found (file ID: ${file_id}, comment ID: ${comment_id}, reply ID: ${reply_id}). It may already be deleted. Resolve the reply ID via drive_list_replies.`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
if (error.code === 403) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Permission denied deleting reply ${reply_id} on file ${file_id}. You can only delete your own replies.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveDeleteSharedDriveOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveDeleteSharedDrive = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_delete_shared_drive',
|
|
9
|
+
displayName: 'Delete Shared Drive',
|
|
10
|
+
description: 'Permanently delete a shared drive by ID.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Permanently deletes a shared drive by ID (it must already be empty). Irreversible. Use only to remove a no-longer-needed shared drive. A repeat call fails because the drive no longer exists.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveDeleteSharedDriveOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
drive_id: Property.ShortText({
|
|
20
|
+
displayName: 'Shared Drive ID',
|
|
21
|
+
description: 'The ID of the shared drive to delete. Resolve it via drive_list_shared_drives.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
async run(context) {
|
|
26
|
+
const { drive_id } = context.propsValue;
|
|
27
|
+
|
|
28
|
+
const authClient = await createGoogleClient(context.auth);
|
|
29
|
+
|
|
30
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await drive.drives.delete({
|
|
34
|
+
driveId: drive_id,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return { deleted: true, driveId: drive_id };
|
|
38
|
+
} catch (error: any) {
|
|
39
|
+
if (error.code === 404) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Shared drive not found (ID: ${drive_id}). It may have already been deleted. Resolve a valid ID via drive_list_shared_drives.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (error.code === 400) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Cannot delete shared drive ${drive_id}: it must be empty before deletion. Remove or trash all of its files first.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (error.code === 403) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Permission denied deleting shared drive ${drive_id}. You must be an organizer of this drive.`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { googleDriveAuth } from '../auth';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { downloadFileFromDrive } from '../common/get-file-content';
|
|
4
|
+
import { driveDownloadFileOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveDownloadFile = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_download_file',
|
|
9
|
+
displayName: 'Download File Content',
|
|
10
|
+
description: 'Read a selected file from google drive file',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
"Downloads a Drive file's bytes by ID and returns a file reference; native Google files (Docs/Sheets/Slides) are auto-exported to their default Office format. Use to retrieve content of a file you have the ID for (obtain it from `drive_search_files` or `drive_get_file`). Read-only.",
|
|
15
|
+
idempotent: true,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveDownloadFileOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
file_id: Property.ShortText({
|
|
20
|
+
displayName: 'File ID',
|
|
21
|
+
description:
|
|
22
|
+
'The ID of the file to download. Resolve it via `drive_search_files` or `drive_get_file`.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
destination_file_name: Property.ShortText({
|
|
26
|
+
displayName: 'Destination File name',
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
run: async ({ auth, propsValue, files }) => {
|
|
31
|
+
return downloadFileFromDrive(
|
|
32
|
+
auth,
|
|
33
|
+
files,
|
|
34
|
+
propsValue.file_id,
|
|
35
|
+
propsValue.destination_file_name
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveEmptyTrashOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveEmptyTrash = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_empty_trash',
|
|
9
|
+
displayName: 'Empty Trash',
|
|
10
|
+
description: 'Permanently delete ALL files in the trash (irreversible, account-wide).',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'DESTRUCTIVE: permanently deletes EVERY file currently in the trash — this is an irreversible, account-wide purge (not a single file), or scoped to one shared drive if `drive_id` is given. The entire trash is emptied, so any file the user trashed is gone for good. Use only as a deliberate cleanup step; to remove a single file reversibly use `drive_trash_file`, and to permanently remove one specific file use `drive_delete_file`. Not safe to retry casually — it purges whatever is in the trash at call time.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveEmptyTrashOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
drive_id: Property.ShortText({
|
|
20
|
+
displayName: 'Shared Drive ID',
|
|
21
|
+
description:
|
|
22
|
+
'Optional. Restrict the purge to a single shared drive\'s trash (resolve via drive_list_shared_drives). Leave empty to empty the entire My Drive trash for the connected account.',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
async run(context) {
|
|
27
|
+
const { drive_id } = context.propsValue;
|
|
28
|
+
|
|
29
|
+
const authClient = await createGoogleClient(context.auth);
|
|
30
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await drive.files.emptyTrash({
|
|
34
|
+
...(drive_id ? { driveId: drive_id } : {}),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return { success: true, driveId: drive_id ?? null };
|
|
38
|
+
} catch (error: any) {
|
|
39
|
+
if (error.code === 403) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'Permission denied emptying the trash. You may lack permission to empty this trash.'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { extension } from 'mime-types';
|
|
5
|
+
import { driveExportWorkspaceFileOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const driveExportWorkspaceFile = createAction({
|
|
8
|
+
auth: googleDriveAuth,
|
|
9
|
+
name: 'drive_export_workspace_file',
|
|
10
|
+
displayName: 'Export Google Doc/Sheet/Slides',
|
|
11
|
+
description:
|
|
12
|
+
'Export a native Google Workspace file (Doc/Sheet/Slides) to a chosen format.',
|
|
13
|
+
audience: 'ai',
|
|
14
|
+
aiMetadata: {
|
|
15
|
+
description:
|
|
16
|
+
'Exports a native Google Workspace file (Doc/Sheet/Slides) to a caller-chosen format and returns the bytes. Use when you need a specific format such as PDF, HTML, CSV, or Markdown; for the default rendition or for ordinary binary files use `drive_download_file`. The chosen format must match the source type (Doc formats for a Doc, Sheet formats for a Sheet, etc.). Read-only. Export size is capped at ~10 MB by Drive.',
|
|
17
|
+
idempotent: true,
|
|
18
|
+
},
|
|
19
|
+
outputSchema: driveExportWorkspaceFileOutputSchema,
|
|
20
|
+
props: {
|
|
21
|
+
file_id: Property.ShortText({
|
|
22
|
+
displayName: 'File ID',
|
|
23
|
+
description:
|
|
24
|
+
'The ID of the native Google Workspace file to export. Resolve it via `drive_search_files` or `drive_get_file`.',
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
27
|
+
mime_type: Property.StaticDropdown({
|
|
28
|
+
displayName: 'Export Format',
|
|
29
|
+
description:
|
|
30
|
+
'The target format. It must match the source type: Doc formats for a Google Doc, Sheet formats for a Google Sheet, Slides formats for Google Slides. An incompatible pairing returns an error.',
|
|
31
|
+
required: true,
|
|
32
|
+
options: {
|
|
33
|
+
options: [
|
|
34
|
+
// Google Docs
|
|
35
|
+
{
|
|
36
|
+
label: 'Word (DOCX) — Docs',
|
|
37
|
+
value:
|
|
38
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
39
|
+
},
|
|
40
|
+
{ label: 'PDF — Docs/Sheets/Slides', value: 'application/pdf' },
|
|
41
|
+
{ label: 'HTML — Docs', value: 'text/html' },
|
|
42
|
+
{ label: 'Plain Text (TXT) — Docs', value: 'text/plain' },
|
|
43
|
+
{ label: 'Rich Text (RTF) — Docs', value: 'application/rtf' },
|
|
44
|
+
{
|
|
45
|
+
label: 'OpenDocument Text (ODT) — Docs',
|
|
46
|
+
value: 'application/vnd.oasis.opendocument.text',
|
|
47
|
+
},
|
|
48
|
+
{ label: 'EPUB — Docs', value: 'application/epub+zip' },
|
|
49
|
+
{ label: 'Markdown (MD) — Docs', value: 'text/markdown' },
|
|
50
|
+
// Google Sheets
|
|
51
|
+
{
|
|
52
|
+
label: 'Excel (XLSX) — Sheets',
|
|
53
|
+
value:
|
|
54
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
55
|
+
},
|
|
56
|
+
{ label: 'CSV — Sheets', value: 'text/csv' },
|
|
57
|
+
{ label: 'TSV — Sheets', value: 'text/tab-separated-values' },
|
|
58
|
+
{
|
|
59
|
+
label: 'OpenDocument Spreadsheet (ODS) — Sheets',
|
|
60
|
+
value: 'application/vnd.oasis.opendocument.spreadsheet',
|
|
61
|
+
},
|
|
62
|
+
// Google Slides
|
|
63
|
+
{
|
|
64
|
+
label: 'PowerPoint (PPTX) — Slides',
|
|
65
|
+
value:
|
|
66
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: 'OpenDocument Presentation (ODP) — Slides',
|
|
70
|
+
value: 'application/vnd.oasis.opendocument.presentation',
|
|
71
|
+
},
|
|
72
|
+
{ label: 'PNG — Slides', value: 'image/png' },
|
|
73
|
+
{ label: 'SVG — Slides', value: 'image/svg+xml' },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
async run(context) {
|
|
79
|
+
const { file_id, mime_type } = context.propsValue;
|
|
80
|
+
|
|
81
|
+
const authClient = await createGoogleClient(context.auth);
|
|
82
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const result = await drive.files.export(
|
|
86
|
+
{
|
|
87
|
+
fileId: file_id,
|
|
88
|
+
mimeType: mime_type,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
responseType: 'arraybuffer',
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const extensionResult = extension(mime_type);
|
|
96
|
+
const fileExtension = extensionResult ? '.' + extensionResult : '';
|
|
97
|
+
|
|
98
|
+
return context.files.write({
|
|
99
|
+
fileName: file_id + fileExtension,
|
|
100
|
+
data: Buffer.from(result.data as any),
|
|
101
|
+
});
|
|
102
|
+
} catch (error: any) {
|
|
103
|
+
// exportSizeLimitExceeded is a 403 but distinct from a permission denial.
|
|
104
|
+
const reason =
|
|
105
|
+
error?.errors?.[0]?.reason ?? error?.response?.data?.error?.errors?.[0]?.reason;
|
|
106
|
+
if (reason === 'exportSizeLimitExceeded') {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Export failed: the file exceeds Drive's ~10 MB export size limit (file ID: ${file_id}). Use drive_download_file to fetch the source directly instead.`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (error.code === 403) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`Permission denied exporting file ${file_id}. You may lack access to this file.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (error.code === 400) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`Invalid export for file ${file_id}: the chosen format does not match the source type, or this is not a native Google Workspace file. Use drive_download_file for ordinary binary files.`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
if (error.code === 404) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`File not found (ID: ${file_id}). Resolve a valid ID via drive_search_files or drive_get_file.`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveGetAboutOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveGetAbout = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_get_about',
|
|
9
|
+
displayName: 'Get Account & Storage Info',
|
|
10
|
+
description: 'Get the authenticated Drive account, storage quota, and supported formats.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Returns the authenticated user\'s Drive info: account identity, storage quota and usage, and supported import/export formats. Use to check available space before a large upload, confirm which account is connected, or look up valid export MIME types. Read-only.',
|
|
15
|
+
idempotent: true,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveGetAboutOutputSchema,
|
|
18
|
+
props: {},
|
|
19
|
+
async run(context) {
|
|
20
|
+
const authClient = await createGoogleClient(context.auth);
|
|
21
|
+
|
|
22
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
// about.get requires a fields parameter or the API returns 400.
|
|
26
|
+
const response = await drive.about.get({
|
|
27
|
+
fields: 'user,storageQuota,maxImportSizes,exportFormats',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return response.data;
|
|
31
|
+
} catch (error: any) {
|
|
32
|
+
if (error.code === 403) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
'Permission denied fetching Drive account info. The connection may lack the required Drive scope.'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
2
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveGetFileOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveGetFile = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_get_file',
|
|
9
|
+
displayName: 'Get File or Folder',
|
|
10
|
+
description: 'Get a file folder for files/sub-folders',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Fetches metadata for a single file or folder by its exact ID (name, MIME type, parents, owners, links). Use when you already have an ID (e.g. from a trigger or `drive_search_files`) and need its details, including its parent folder IDs. Read-only and safe to retry.',
|
|
15
|
+
idempotent: true,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveGetFileOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
file_id: Property.ShortText({
|
|
20
|
+
displayName: 'File / Folder ID',
|
|
21
|
+
description:
|
|
22
|
+
'The ID of the file/folder to fetch. Resolve it via `drive_search_files` or `drive_list_files`.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
async run(context) {
|
|
27
|
+
const authClient = await createGoogleClient(context.auth);
|
|
28
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
29
|
+
const response = await drive.files.get({
|
|
30
|
+
fileId: context.propsValue.file_id,
|
|
31
|
+
supportsAllDrives: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (response.data) {
|
|
35
|
+
return response.data;
|
|
36
|
+
} else {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveGetReplyOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveGetReply = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_get_reply',
|
|
9
|
+
displayName: 'Get Reply',
|
|
10
|
+
description: 'Fetch a single reply on a Drive comment by ID.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Fetches a single reply by ID, including its author, content, and action. Use when you already have a replyId (resolve it via drive_list_replies) and need that one reply\'s details. Read-only.',
|
|
15
|
+
idempotent: true,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveGetReplyOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
file_id: Property.ShortText({
|
|
20
|
+
displayName: 'File ID',
|
|
21
|
+
description:
|
|
22
|
+
'The ID of the file the comment belongs to. Resolve it via drive_search_files or drive_get_file.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
comment_id: Property.ShortText({
|
|
26
|
+
displayName: 'Comment ID',
|
|
27
|
+
description: 'The ID of the parent comment. Resolve it via drive_list_comments.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
reply_id: Property.ShortText({
|
|
31
|
+
displayName: 'Reply ID',
|
|
32
|
+
description: 'The ID of the reply to fetch. Resolve it via drive_list_replies.',
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
async run(context) {
|
|
37
|
+
const { file_id, comment_id, reply_id } = context.propsValue;
|
|
38
|
+
|
|
39
|
+
const authClient = await createGoogleClient(context.auth);
|
|
40
|
+
|
|
41
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
// The Drive replies endpoints require a fields parameter or the API returns 400.
|
|
45
|
+
const response = await drive.replies.get({
|
|
46
|
+
fileId: file_id,
|
|
47
|
+
commentId: comment_id,
|
|
48
|
+
replyId: reply_id,
|
|
49
|
+
fields: '*',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return response.data;
|
|
53
|
+
} catch (error: any) {
|
|
54
|
+
if (error.code === 404) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`File, comment, or reply not found (file ID: ${file_id}, comment ID: ${comment_id}, reply ID: ${reply_id}). Resolve the reply ID via drive_list_replies.`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (error.code === 403) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Permission denied fetching reply ${reply_id} on file ${file_id}. You may lack access to this file.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveGetSharedDriveOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveGetSharedDrive = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_get_shared_drive',
|
|
9
|
+
displayName: 'Get Shared Drive',
|
|
10
|
+
description: 'Fetch metadata for one shared drive by ID.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Fetches metadata and capabilities for one shared drive by ID (resolve the ID via drive_list_shared_drives). Use to inspect a shared drive\'s settings before modifying it. Read-only.',
|
|
15
|
+
idempotent: true,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveGetSharedDriveOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
drive_id: Property.ShortText({
|
|
20
|
+
displayName: 'Shared Drive ID',
|
|
21
|
+
description: 'The ID of the shared drive. Resolve it via drive_list_shared_drives.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
async run(context) {
|
|
26
|
+
const { drive_id } = context.propsValue;
|
|
27
|
+
|
|
28
|
+
const authClient = await createGoogleClient(context.auth);
|
|
29
|
+
|
|
30
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const response = await drive.drives.get({
|
|
34
|
+
driveId: drive_id,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return response.data;
|
|
38
|
+
} catch (error: any) {
|
|
39
|
+
if (error.code === 404) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Shared drive not found (ID: ${drive_id}). Resolve a valid ID via drive_list_shared_drives.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (error.code === 403) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Permission denied accessing shared drive ${drive_id}. You may not be a member of this drive.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveListCommentsOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveListComments = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_list_comments',
|
|
9
|
+
displayName: 'List Comments',
|
|
10
|
+
description: 'List the comments on a Drive file.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Lists the comments on a file with each comment\'s id, author, content, and resolved state. Use to read discussion on a file or to resolve a commentId before replying (drive_create_reply) or listing its replies (drive_list_replies). Read-only.',
|
|
15
|
+
idempotent: true,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveListCommentsOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
file_id: Property.ShortText({
|
|
20
|
+
displayName: 'File ID',
|
|
21
|
+
description:
|
|
22
|
+
'The ID of the file whose comments to list. Resolve it via drive_search_files or drive_get_file.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
async run(context) {
|
|
27
|
+
const { file_id } = context.propsValue;
|
|
28
|
+
|
|
29
|
+
const authClient = await createGoogleClient(context.auth);
|
|
30
|
+
|
|
31
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
// The Drive comments endpoints require a fields parameter or the API returns 400.
|
|
35
|
+
const response = await drive.comments.list({
|
|
36
|
+
fileId: file_id,
|
|
37
|
+
fields: '*',
|
|
38
|
+
includeDeleted: false,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const comments = response.data.comments ?? [];
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
comments,
|
|
45
|
+
count: comments.length,
|
|
46
|
+
};
|
|
47
|
+
} catch (error: any) {
|
|
48
|
+
if (error.code === 404) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`File not found (ID: ${file_id}). Resolve a valid ID via drive_search_files or drive_get_file.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (error.code === 403) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Permission denied listing comments for file ${file_id}. You may lack access to this file.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|