@divyacon/piece-google-drive 0.0.0-stage → 0.1.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/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 +49 -3
- 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,42 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { common } from '../common';
|
|
4
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
5
|
+
import { createNewGdriveFolderActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const googleDriveCreateNewFolder = createAction({
|
|
8
|
+
auth: googleDriveAuth,
|
|
9
|
+
name: 'create_new_gdrive_folder',
|
|
10
|
+
description: 'Create a new empty folder in your Google Drive',
|
|
11
|
+
audience: 'human',
|
|
12
|
+
aiMetadata: { description: 'Creates a new empty folder in Google Drive, optionally nested under a parent folder. Use to set up a destination before uploading or moving files. Not idempotent: each call creates a distinct folder even with the same name (Drive permits duplicate folder names).', idempotent: false },
|
|
13
|
+
displayName: 'Create new folder',
|
|
14
|
+
props: {
|
|
15
|
+
folderName: Property.ShortText({
|
|
16
|
+
displayName: 'Folder name',
|
|
17
|
+
description: 'The name of the new folder',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
parentFolder: common.properties.parentFolder,
|
|
21
|
+
include_team_drives: common.properties.include_team_drives,
|
|
22
|
+
},
|
|
23
|
+
outputSchema: createNewGdriveFolderActionOutputSchema,
|
|
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.create({
|
|
30
|
+
requestBody: {
|
|
31
|
+
mimeType: 'application/vnd.google-apps.folder',
|
|
32
|
+
name: context.propsValue.folderName,
|
|
33
|
+
...(context.propsValue.parentFolder
|
|
34
|
+
? { parents: [context.propsValue.parentFolder] }
|
|
35
|
+
: {}),
|
|
36
|
+
},
|
|
37
|
+
supportsAllDrives: context.propsValue.include_team_drives,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return response.data;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
3
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
4
|
+
import { common } from '../common';
|
|
5
|
+
import { createNewGdriveFileActionOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const googleDriveCreateNewTextFile = createAction({
|
|
8
|
+
auth: googleDriveAuth,
|
|
9
|
+
name: 'create_new_gdrive_file',
|
|
10
|
+
description: 'Create a new text file in your Google Drive from text',
|
|
11
|
+
audience: 'human',
|
|
12
|
+
aiMetadata: { description: 'Creates a new file in Google Drive from inline text content as plain text, CSV, or XML, optionally inside a parent folder. Use when an agent has generated text it needs to persist as a Drive file. Not idempotent: each call creates a new file.', idempotent: false },
|
|
13
|
+
displayName: 'Create new file',
|
|
14
|
+
props: {
|
|
15
|
+
fileName: Property.ShortText({
|
|
16
|
+
displayName: 'File name',
|
|
17
|
+
description: 'The name of the new text file',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
text: Property.LongText({
|
|
21
|
+
displayName: 'Text',
|
|
22
|
+
description: 'The text content to add to file',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
fileType: Property.StaticDropdown({
|
|
26
|
+
displayName: 'Content type',
|
|
27
|
+
description: 'Select file type',
|
|
28
|
+
required: true,
|
|
29
|
+
defaultValue: 'text/plain',
|
|
30
|
+
options: {
|
|
31
|
+
options: [
|
|
32
|
+
{
|
|
33
|
+
label: 'Text',
|
|
34
|
+
value: 'text/plain',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'CSV',
|
|
38
|
+
value: 'text/csv',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'XML',
|
|
42
|
+
value: 'text/xml',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
parentFolder: common.properties.parentFolder,
|
|
48
|
+
include_team_drives: common.properties.include_team_drives,
|
|
49
|
+
},
|
|
50
|
+
outputSchema: createNewGdriveFileActionOutputSchema,
|
|
51
|
+
async run(context) {
|
|
52
|
+
const authClient = await createGoogleClient(context.auth);
|
|
53
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
54
|
+
|
|
55
|
+
// Normalize the legacy 'plain/text' value saved by existing flows to the
|
|
56
|
+
// valid 'text/plain' MIME type Google Drive expects.
|
|
57
|
+
const mimeType =
|
|
58
|
+
context.propsValue.fileType === 'plain/text'
|
|
59
|
+
? 'text/plain'
|
|
60
|
+
: context.propsValue.fileType;
|
|
61
|
+
|
|
62
|
+
const response = await drive.files.create({
|
|
63
|
+
requestBody: {
|
|
64
|
+
name: context.propsValue.fileName,
|
|
65
|
+
mimeType,
|
|
66
|
+
...(context.propsValue.parentFolder
|
|
67
|
+
? { parents: [context.propsValue.parentFolder] }
|
|
68
|
+
: {}),
|
|
69
|
+
},
|
|
70
|
+
media: {
|
|
71
|
+
mimeType,
|
|
72
|
+
body: context.propsValue.text,
|
|
73
|
+
},
|
|
74
|
+
supportsAllDrives: context.propsValue.include_team_drives ?? false,
|
|
75
|
+
fields: 'id, name, mimeType, kind',
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return response.data;
|
|
79
|
+
},
|
|
80
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { common } from '../common';
|
|
4
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
5
|
+
|
|
6
|
+
export const googleDriveDeleteFile = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'delete_gdrive_file',
|
|
9
|
+
description: 'Delete permanently a file from your Google Drive',
|
|
10
|
+
audience: 'human',
|
|
11
|
+
aiMetadata: { description: 'Permanently deletes a file from Google Drive by its ID, bypassing the trash and making it unrecoverable. Use only when permanent removal is intended; prefer Trash file for reversible deletion. Requires the file ID. Not idempotent: a repeat call fails because the file no longer exists.', idempotent: false },
|
|
12
|
+
displayName: 'Delete file',
|
|
13
|
+
props: {
|
|
14
|
+
fileId: Property.ShortText({
|
|
15
|
+
displayName: 'File ID',
|
|
16
|
+
description: 'The ID of the file to delete',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
include_team_drives: common.properties.include_team_drives,
|
|
20
|
+
},
|
|
21
|
+
async run(context) {
|
|
22
|
+
const authClient = await createGoogleClient(context.auth);
|
|
23
|
+
|
|
24
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
25
|
+
|
|
26
|
+
const response = await drive.files.delete({
|
|
27
|
+
fileId: context.propsValue.fileId,
|
|
28
|
+
supportsAllDrives: context.propsValue.include_team_drives,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return response.data;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Property, createAction } from "@agnocon/pieces-framework";
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { deletePermissionsActionOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const deletePermission = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'delete_permissions',
|
|
9
|
+
description: 'Removes a role from an user for a file or folder',
|
|
10
|
+
audience: 'human',
|
|
11
|
+
aiMetadata: { description: 'Revokes a specific role from a user (matched by email and role) on a Drive file or folder. Use to unshare or downgrade access for someone. Requires the file/folder ID, the user email, and the role to remove. Idempotent: if no matching permission exists, the call is a no-op.', idempotent: true },
|
|
12
|
+
displayName: 'Delete permissions',
|
|
13
|
+
props: {
|
|
14
|
+
fileId: Property.ShortText({
|
|
15
|
+
displayName: 'File or Folder ID',
|
|
16
|
+
description: 'The ID of the file or folder to update permissions for',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
user_email: Property.ShortText({
|
|
20
|
+
displayName: 'User email',
|
|
21
|
+
description: 'The email address of the user to update permissions for',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
permission_name : Property.StaticDropdown({
|
|
25
|
+
displayName: 'Role',
|
|
26
|
+
description: 'The role to remove from user.',
|
|
27
|
+
required: true,
|
|
28
|
+
options: {
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
label: 'Organizer',
|
|
32
|
+
value: 'organizer',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: 'File Organizer',
|
|
36
|
+
value: 'fileOrganizer',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: 'Writer',
|
|
40
|
+
value: 'writer',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: 'Commenter',
|
|
44
|
+
value: 'commenter',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: 'Reader',
|
|
48
|
+
value: 'reader',
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
outputSchema: deletePermissionsActionOutputSchema,
|
|
56
|
+
async run (context) {
|
|
57
|
+
const [fileId, user_email] = [context.propsValue.fileId, context.propsValue.user_email];
|
|
58
|
+
const authClient = await createGoogleClient(context.auth);
|
|
59
|
+
|
|
60
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
61
|
+
|
|
62
|
+
const response_permissions_list = await drive.permissions.list({
|
|
63
|
+
fileId: fileId,
|
|
64
|
+
fields: 'permissions(id, emailAddress, role)',
|
|
65
|
+
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
if (response_permissions_list.data.permissions) {
|
|
69
|
+
|
|
70
|
+
for (const permission of response_permissions_list.data.permissions) {
|
|
71
|
+
if (permission.emailAddress === user_email && permission.role === context.propsValue.permission_name) {
|
|
72
|
+
await drive.permissions.delete({
|
|
73
|
+
fileId: fileId,
|
|
74
|
+
permissionId: permission.id ? permission.id : '',
|
|
75
|
+
});
|
|
76
|
+
return {removed: true, message: 'Permission removed'};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {removed: false, message: 'Permission not found'};
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
3
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
4
|
+
import { driveCopyFileOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveCopyFile = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_copy_file',
|
|
9
|
+
displayName: 'Copy File',
|
|
10
|
+
description: 'Duplicate a file from Google Drive. Returns the new file ID.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Copies an existing Drive file into a target folder under a new name, optionally converting it to a Google Sheet or Doc. Use to clone a file or make an editable Google-format copy; to relocate the original instead of copying use `drive_move_file`. Requires source file ID and destination folder ID. Each call creates a new copy.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveCopyFileOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
file_id: Property.ShortText({
|
|
20
|
+
displayName: 'File ID',
|
|
21
|
+
description:
|
|
22
|
+
'The ID of the file to duplicate. Resolve it via `drive_search_files`.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
name: Property.ShortText({
|
|
26
|
+
displayName: 'Name',
|
|
27
|
+
description: 'The name of the new file',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
folder_id: Property.ShortText({
|
|
31
|
+
displayName: 'Folder ID',
|
|
32
|
+
description:
|
|
33
|
+
'The ID of the folder where the file will be duplicated. Resolve it via `drive_search_files`.',
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
convert_to: Property.StaticDropdown({
|
|
37
|
+
displayName: 'Duplicate as',
|
|
38
|
+
description: 'If left unselected the file will be duplicated as it is',
|
|
39
|
+
required: false,
|
|
40
|
+
options: {
|
|
41
|
+
options: [
|
|
42
|
+
{
|
|
43
|
+
label: 'Google Sheets',
|
|
44
|
+
value: 'application/vnd.google-apps.spreadsheet',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: 'Google Docs',
|
|
48
|
+
value: 'application/vnd.google-apps.document',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
async run(context) {
|
|
55
|
+
const authClient = await createGoogleClient(context.auth);
|
|
56
|
+
|
|
57
|
+
const fileId = context.propsValue.file_id;
|
|
58
|
+
const nameForNewFile = context.propsValue.name;
|
|
59
|
+
const parentFolderId = context.propsValue.folder_id;
|
|
60
|
+
const mimeType = context.propsValue.convert_to;
|
|
61
|
+
|
|
62
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
63
|
+
|
|
64
|
+
const requestBody: any = {
|
|
65
|
+
name: nameForNewFile,
|
|
66
|
+
parents: [parentFolderId],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (mimeType) {
|
|
70
|
+
requestBody.mimeType = mimeType;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const response = await drive.files.copy({
|
|
74
|
+
fileId,
|
|
75
|
+
auth: authClient,
|
|
76
|
+
requestBody,
|
|
77
|
+
supportsAllDrives: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (response.status !== 200) {
|
|
81
|
+
throw new Error('Error duplicating file');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return response.data;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
@@ -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 { driveCreateCommentOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveCreateComment = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_create_comment',
|
|
9
|
+
displayName: 'Create Comment',
|
|
10
|
+
description: 'Add a new comment to a Drive file.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Adds a new top-level comment to a file. Use to leave feedback or a note on a file (resolve the file ID via drive_search_files); to respond to an existing comment use drive_create_reply instead. Each call creates a new comment, so retries duplicate.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveCreateCommentOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
file_id: Property.ShortText({
|
|
20
|
+
displayName: 'File ID',
|
|
21
|
+
description:
|
|
22
|
+
'The ID of the file to comment on. Resolve it via drive_search_files or drive_get_file.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
content: Property.LongText({
|
|
26
|
+
displayName: 'Content',
|
|
27
|
+
description: 'The plain-text content of the comment.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
async run(context) {
|
|
32
|
+
const { file_id, content } = context.propsValue;
|
|
33
|
+
|
|
34
|
+
const authClient = await createGoogleClient(context.auth);
|
|
35
|
+
|
|
36
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
// The Drive comments endpoints require a fields parameter or the API returns 400.
|
|
40
|
+
const response = await drive.comments.create({
|
|
41
|
+
fileId: file_id,
|
|
42
|
+
fields: '*',
|
|
43
|
+
requestBody: { content },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return response.data;
|
|
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 commenting on file ${file_id}. You may lack comment access to this file.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import {
|
|
3
|
+
httpClient,
|
|
4
|
+
HttpMethod,
|
|
5
|
+
AuthenticationType,
|
|
6
|
+
} from '@agnocon/pieces-common';
|
|
7
|
+
import FormData from 'form-data';
|
|
8
|
+
import { googleDriveAuth, getAccessToken } from '../auth';
|
|
9
|
+
import { driveCreateFileFromTextOutputSchema } from '../output-schemas';
|
|
10
|
+
|
|
11
|
+
export const driveCreateFileFromText = createAction({
|
|
12
|
+
auth: googleDriveAuth,
|
|
13
|
+
name: 'drive_create_file_from_text',
|
|
14
|
+
displayName: 'Create File from Text',
|
|
15
|
+
description: 'Create a new text file in your Google Drive from text',
|
|
16
|
+
audience: 'ai',
|
|
17
|
+
aiMetadata: {
|
|
18
|
+
description:
|
|
19
|
+
'Creates a new Drive file from inline text content as plain text, CSV, or XML. Use when an agent has generated text it needs to persist as a Drive file; for binary or existing files use `drive_upload_file` instead. Each call creates a new file.',
|
|
20
|
+
idempotent: false,
|
|
21
|
+
},
|
|
22
|
+
outputSchema: driveCreateFileFromTextOutputSchema,
|
|
23
|
+
props: {
|
|
24
|
+
file_name: Property.ShortText({
|
|
25
|
+
displayName: 'File name',
|
|
26
|
+
description: 'The name of the new text file',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
text: Property.LongText({
|
|
30
|
+
displayName: 'Text',
|
|
31
|
+
description: 'The text content to add to file',
|
|
32
|
+
required: true,
|
|
33
|
+
}),
|
|
34
|
+
content_type: Property.StaticDropdown({
|
|
35
|
+
displayName: 'Content type',
|
|
36
|
+
description: 'Select file type',
|
|
37
|
+
required: true,
|
|
38
|
+
defaultValue: 'plain/text',
|
|
39
|
+
options: {
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
label: 'Text',
|
|
43
|
+
value: 'plain/text',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: 'CSV',
|
|
47
|
+
value: 'text/csv',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'XML',
|
|
51
|
+
value: 'text/xml',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
parent_folder_id: Property.ShortText({
|
|
57
|
+
displayName: 'Parent Folder ID',
|
|
58
|
+
description:
|
|
59
|
+
'The ID of the folder to create the file inside. Leave empty to create it in the root of My Drive. Resolve a folder ID with `drive_search_files`.',
|
|
60
|
+
required: false,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
async run(context) {
|
|
64
|
+
const meta = {
|
|
65
|
+
mimeType: context.propsValue.content_type,
|
|
66
|
+
name: context.propsValue.file_name,
|
|
67
|
+
...(context.propsValue.parent_folder_id
|
|
68
|
+
? { parents: [context.propsValue.parent_folder_id] }
|
|
69
|
+
: {}),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const metaBuffer = Buffer.from(JSON.stringify(meta), 'utf-8');
|
|
73
|
+
const textBuffer = Buffer.from(context.propsValue.text!, 'utf-8');
|
|
74
|
+
|
|
75
|
+
const form = new FormData();
|
|
76
|
+
form.append('Metadata', metaBuffer, { contentType: 'application/json' });
|
|
77
|
+
form.append('Media', textBuffer, {
|
|
78
|
+
contentType: context.propsValue.content_type,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const result = await httpClient.sendRequest({
|
|
82
|
+
method: HttpMethod.POST,
|
|
83
|
+
url: `https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart`,
|
|
84
|
+
body: form,
|
|
85
|
+
headers: {
|
|
86
|
+
...form.getHeaders(),
|
|
87
|
+
},
|
|
88
|
+
queryParams: {
|
|
89
|
+
supportsAllDrives: 'true',
|
|
90
|
+
},
|
|
91
|
+
authentication: {
|
|
92
|
+
type: AuthenticationType.BEARER_TOKEN,
|
|
93
|
+
token: await getAccessToken(context.auth),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return result.body;
|
|
98
|
+
},
|
|
99
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveCreateFolderOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveCreateFolder = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_create_folder',
|
|
9
|
+
displayName: 'Create Folder',
|
|
10
|
+
description: 'Create a new empty folder in your Google Drive',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Creates a new empty folder in Google Drive, optionally nested under a parent folder (resolve the parent ID via `drive_search_files`). Use to set up a destination before uploading or moving files. Each call creates a distinct folder even with the same name, so retries duplicate.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveCreateFolderOutputSchema,
|
|
18
|
+
props: {
|
|
19
|
+
folder_name: Property.ShortText({
|
|
20
|
+
displayName: 'Folder name',
|
|
21
|
+
description: 'The name of the new folder',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
parent_folder_id: Property.ShortText({
|
|
25
|
+
displayName: 'Parent Folder ID',
|
|
26
|
+
description:
|
|
27
|
+
'The ID of the folder to create the new folder inside. Leave empty to create it in the root of My Drive. Resolve a folder ID with `drive_search_files`.',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
async run(context) {
|
|
32
|
+
const authClient = await createGoogleClient(context.auth);
|
|
33
|
+
|
|
34
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
35
|
+
|
|
36
|
+
const response = await drive.files.create({
|
|
37
|
+
requestBody: {
|
|
38
|
+
mimeType: 'application/vnd.google-apps.folder',
|
|
39
|
+
name: context.propsValue.folder_name,
|
|
40
|
+
...(context.propsValue.parent_folder_id
|
|
41
|
+
? { parents: [context.propsValue.parent_folder_id] }
|
|
42
|
+
: {}),
|
|
43
|
+
},
|
|
44
|
+
supportsAllDrives: true,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return response.data;
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
3
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
4
|
+
import { driveCreateReplyOutputSchema } from '../output-schemas';
|
|
5
|
+
|
|
6
|
+
export const driveCreateReply = createAction({
|
|
7
|
+
auth: googleDriveAuth,
|
|
8
|
+
name: 'drive_create_reply',
|
|
9
|
+
displayName: 'Reply to Comment',
|
|
10
|
+
description: 'Add a reply to an existing comment on a Drive file.',
|
|
11
|
+
audience: 'ai',
|
|
12
|
+
aiMetadata: {
|
|
13
|
+
description:
|
|
14
|
+
'Adds a reply to an existing comment, optionally resolving or reopening the comment via the action field. Use to respond to a comment (resolve the commentId via drive_list_comments); to start a new top-level comment use drive_create_comment instead. Each call creates a new reply, so retries duplicate.',
|
|
15
|
+
idempotent: false,
|
|
16
|
+
},
|
|
17
|
+
outputSchema: driveCreateReplyOutputSchema,
|
|
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 comment to reply to. Resolve it via drive_list_comments.',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
content: Property.LongText({
|
|
31
|
+
displayName: 'Content',
|
|
32
|
+
description: 'The plain-text content of the reply.',
|
|
33
|
+
required: true,
|
|
34
|
+
}),
|
|
35
|
+
action: Property.StaticDropdown({
|
|
36
|
+
displayName: 'Action',
|
|
37
|
+
description:
|
|
38
|
+
'Optionally change the parent comment\'s state: resolve (mark resolved) or reopen.',
|
|
39
|
+
required: false,
|
|
40
|
+
options: {
|
|
41
|
+
options: [
|
|
42
|
+
{ label: 'Resolve', value: 'resolve' },
|
|
43
|
+
{ label: 'Reopen', value: 'reopen' },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
async run(context) {
|
|
49
|
+
const { file_id, comment_id, content, action } = context.propsValue;
|
|
50
|
+
|
|
51
|
+
const authClient = await createGoogleClient(context.auth);
|
|
52
|
+
|
|
53
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
54
|
+
|
|
55
|
+
const requestBody: { content: string; action?: string } = { content };
|
|
56
|
+
if (action) {
|
|
57
|
+
requestBody.action = action;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
// The Drive replies endpoints require a fields parameter or the API returns 400.
|
|
62
|
+
const response = await drive.replies.create({
|
|
63
|
+
fileId: file_id,
|
|
64
|
+
commentId: comment_id,
|
|
65
|
+
fields: '*',
|
|
66
|
+
requestBody,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return response.data;
|
|
70
|
+
} catch (error: any) {
|
|
71
|
+
if (error.code === 404) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`File or comment not found (file ID: ${file_id}, comment ID: ${comment_id}). Resolve the comment ID via drive_list_comments.`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (error.code === 403) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Permission denied replying to comment ${comment_id} on file ${file_id}. You may lack comment access to this file.`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Property, createAction } from '@agnocon/pieces-framework';
|
|
2
|
+
import { randomUUID } from 'crypto';
|
|
3
|
+
import { googleDriveAuth, createGoogleClient } from '../auth';
|
|
4
|
+
import { drive as googleDrive } from '@googleapis/drive';
|
|
5
|
+
import { driveCreateSharedDriveOutputSchema } from '../output-schemas';
|
|
6
|
+
|
|
7
|
+
export const driveCreateSharedDrive = createAction({
|
|
8
|
+
auth: googleDriveAuth,
|
|
9
|
+
name: 'drive_create_shared_drive',
|
|
10
|
+
displayName: 'Create Shared Drive',
|
|
11
|
+
description: 'Create a new shared drive (Team Drive).',
|
|
12
|
+
audience: 'ai',
|
|
13
|
+
aiMetadata: {
|
|
14
|
+
description:
|
|
15
|
+
'Creates a new shared drive (Team Drive) with the given name; the action supplies the required idempotency requestId internally. Use to set up a shared workspace. Each call creates a distinct shared drive. Your Workspace admin must have shared-drive creation enabled (a 403 here is an admin-policy issue, not a scope issue).',
|
|
16
|
+
idempotent: false,
|
|
17
|
+
},
|
|
18
|
+
outputSchema: driveCreateSharedDriveOutputSchema,
|
|
19
|
+
props: {
|
|
20
|
+
name: Property.ShortText({
|
|
21
|
+
displayName: 'Name',
|
|
22
|
+
description: 'The name of the new shared drive.',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
async run(context) {
|
|
27
|
+
const { name } = context.propsValue;
|
|
28
|
+
|
|
29
|
+
const authClient = await createGoogleClient(context.auth);
|
|
30
|
+
|
|
31
|
+
const drive = googleDrive({ version: 'v3', auth: authClient });
|
|
32
|
+
|
|
33
|
+
// drives.create requires a requestId (idempotency key); omitting it returns a 400.
|
|
34
|
+
const requestId = randomUUID();
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const response = await drive.drives.create({
|
|
38
|
+
requestId,
|
|
39
|
+
requestBody: { name },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return response.data;
|
|
43
|
+
} catch (error: any) {
|
|
44
|
+
if (error.code === 403) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
'Permission denied creating a shared drive. Your Google Workspace admin may have disabled shared-drive creation for your account.'
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|