Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(google-drive): make actions and triggers easier to configure (#15685)

Talal Jaber57e31211c41c
diff --git a/bun.lock b/bun.lock
index 1f058068c03..a1b5c651dda 100644
--- a/bun.lock
+++ b/bun.lock
@@ -3830,7 +3830,7 @@
},
"packages/pieces/community/google-drive": {
"name": "@activepieces/piece-google-drive",
- "version": "0.10.0",
+ "version": "0.11.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/google-drive/package.json b/packages/pieces/community/google-drive/package.json
index efb3b053687..fc4ec7a22f4 100644
--- a/packages/pieces/community/google-drive/package.json
+++ b/packages/pieces/community/google-drive/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-google-drive",
- "version": "0.10.0",
+ "version": "0.11.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/google-drive/src/index.ts b/packages/pieces/community/google-drive/src/index.ts
index cd09d386eba..960c97af248 100644
--- a/packages/pieces/community/google-drive/src/index.ts
+++ b/packages/pieces/community/google-drive/src/index.ts
@@ -66,7 +66,7 @@ import { driveGetAbout } from './lib/action/drive-get-about';
export { googleDriveAuth, getAccessToken, GoogleDriveAuthValue, createGoogleClient } from './lib/auth';
export const googleDrive = createPiece({
- minimumSupportedRelease: '0.86.4',
+ minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/google-drive.png',
categories: [PieceCategory.CONTENT_AND_FILES],
displayName: 'Google Drive',
diff --git a/packages/pieces/community/google-drive/src/lib/action/add-permission.action.ts b/packages/pieces/community/google-drive/src/lib/action/add-permission.action.ts
index ccd89e523ea..ce4c9980931 100644
--- a/packages/pieces/community/google-drive/src/lib/action/add-permission.action.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/add-permission.action.ts
@@ -8,37 +8,39 @@ export const addPermission = createAction({
auth: googleDriveAuth,
name: 'update_permissions',
classification: 'WRITE',
- description: 'Update permissions for a file or folder',
+ description: 'Give a person a role on a file or folder by email.',
audience: 'human',
aiMetadata: { description: 'Grants a specified role (reader, commenter, writer, fileOrganizer, or organizer) on a Drive file or folder to a user identified by email, optionally sending a notification email. Use to share a resource with a person. Requires the file/folder ID and target email. Not idempotent: each call creates a new permission grant.', idempotent: false },
- displayName: 'Update permissions',
+ displayName: 'Share File or Folder',
props: {
fileId: Property.ShortText({
displayName: 'File or Folder ID',
- description: 'The ID of the file or folder to update permissions for',
+ description: "The ID from the item's Drive URL or an earlier step.",
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
user_email: Property.ShortText({
- displayName: 'User email',
- description: 'The email address of the user to update permissions for',
+ displayName: 'User Email',
+ description: 'The person who receives the access.',
required: true,
+ placeholder: '[email protected]',
}),
permission_name : Property.StaticDropdown({
displayName: 'Role',
- description: 'The role to grant to user. See more at: https://developers.google.com/drive/api/guides/ref-roles',
+ description: 'What the person can do. Manager roles apply to shared drives only.',
required: true,
options: {
options: [
{
- label: 'Organizer',
+ label: 'Manager',
value: 'organizer',
},
{
- label: 'File Organizer',
+ label: 'Content Manager',
value: 'fileOrganizer',
},
{
- label: 'Writer',
+ label: 'Editor',
value: 'writer',
},
{
@@ -46,19 +48,19 @@ export const addPermission = createAction({
value: 'commenter',
},
{
- label: 'Reader',
+ label: 'Viewer',
value: 'reader',
},
]
}
}),
- include_team_drives: common.properties.include_team_drives,
send_invitation_email: Property.Checkbox({
- displayName: 'Send invitation email',
- description: 'Send an email to the user to notify them of the new permissions',
+ displayName: 'Send Invitation Email',
+ description: 'Email the person that they now have access.',
required: true,
}),
+ include_team_drives: common.properties.include_team_drives,
},
outputSchema: updatePermissionsActionOutputSchema,
diff --git a/packages/pieces/community/google-drive/src/lib/action/create-new-folder.ts b/packages/pieces/community/google-drive/src/lib/action/create-new-folder.ts
index b37563e3a1e..56b973646f9 100644
--- a/packages/pieces/community/google-drive/src/lib/action/create-new-folder.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/create-new-folder.ts
@@ -8,15 +8,15 @@ export const googleDriveCreateNewFolder = createAction({
auth: googleDriveAuth,
name: 'create_new_gdrive_folder',
classification: 'WRITE',
- description: 'Create a new empty folder in your Google Drive',
+ description: 'Create an empty folder in Google Drive.',
audience: 'human',
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 },
- displayName: 'Create new folder',
+ displayName: 'Create Folder',
props: {
folderName: Property.ShortText({
- displayName: 'Folder name',
- description: 'The name of the new folder',
+ displayName: 'Folder Name',
required: true,
+ placeholder: 'Invoices 2026',
}),
parentFolder: common.properties.parentFolder,
include_team_drives: common.properties.include_team_drives,
diff --git a/packages/pieces/community/google-drive/src/lib/action/create-new-text-file.ts b/packages/pieces/community/google-drive/src/lib/action/create-new-text-file.ts
index df8d577a4a2..e1ef9d2d76c 100644
--- a/packages/pieces/community/google-drive/src/lib/action/create-new-text-file.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/create-new-text-file.ts
@@ -8,30 +8,31 @@ export const googleDriveCreateNewTextFile = createAction({
auth: googleDriveAuth,
name: 'create_new_gdrive_file',
classification: 'WRITE',
- description: 'Create a new text file in your Google Drive from text',
+ description: 'Create a text, CSV or XML file from text you enter.',
audience: 'human',
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 },
- displayName: 'Create new file',
+ displayName: 'Create File from Text',
props: {
fileName: Property.ShortText({
- displayName: 'File name',
- description: 'The name of the new text file',
+ displayName: 'File Name',
+ description: 'Include the extension, for example report.csv.',
required: true,
+ placeholder: 'report.txt',
}),
text: Property.LongText({
- displayName: 'Text',
- description: 'The text content to add to file',
+ displayName: 'Content',
+ description: 'The text written into the file.',
required: true,
}),
fileType: Property.StaticDropdown({
- displayName: 'Content type',
- description: 'Select file type',
+ displayName: 'File Type',
+ description: 'Plain text, CSV or XML. Match the extension in the file name.',
required: true,
defaultValue: 'text/plain',
options: {
options: [
{
- label: 'Text',
+ label: 'Plain Text (TXT)',
value: 'text/plain',
},
{
diff --git a/packages/pieces/community/google-drive/src/lib/action/delete-file.ts b/packages/pieces/community/google-drive/src/lib/action/delete-file.ts
index d069c2158c2..7c381478b6e 100644
--- a/packages/pieces/community/google-drive/src/lib/action/delete-file.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/delete-file.ts
@@ -7,15 +7,16 @@ export const googleDriveDeleteFile = createAction({
auth: googleDriveAuth,
name: 'delete_gdrive_file',
classification: 'DESTRUCTIVE',
- description: 'Delete permanently a file from your Google Drive',
+ description: 'Permanently delete a file, skipping the bin.',
audience: 'human',
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 },
- displayName: 'Delete file',
+ displayName: 'Delete File',
props: {
fileId: Property.ShortText({
displayName: 'File ID',
- description: 'The ID of the file to delete',
+ description: 'The ID of the file to delete. This cannot be undone.',
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
include_team_drives: common.properties.include_team_drives,
},
diff --git a/packages/pieces/community/google-drive/src/lib/action/delete-permission.action.ts b/packages/pieces/community/google-drive/src/lib/action/delete-permission.action.ts
index 2d452904c78..b4e3304d9df 100644
--- a/packages/pieces/community/google-drive/src/lib/action/delete-permission.action.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/delete-permission.action.ts
@@ -7,37 +7,39 @@ export const deletePermission = createAction({
auth: googleDriveAuth,
name: 'delete_permissions',
classification: 'DESTRUCTIVE',
- description: 'Removes a role from an user for a file or folder',
+ description: "Remove a person's role from a file or folder.",
audience: 'human',
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 },
- displayName: 'Delete permissions',
+ displayName: 'Remove Access',
props: {
fileId: Property.ShortText({
displayName: 'File or Folder ID',
- description: 'The ID of the file or folder to update permissions for',
+ description: "The ID from the item's Drive URL or an earlier step.",
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
user_email: Property.ShortText({
- displayName: 'User email',
- description: 'The email address of the user to update permissions for',
+ displayName: 'User Email',
+ description: 'The person whose access is removed.',
required: true,
- }),
+ placeholder: '[email protected]',
+ }),
permission_name : Property.StaticDropdown({
displayName: 'Role',
- description: 'The role to remove from user.',
+ description: 'The role to remove. Other roles the person has stay.',
required: true,
options: {
options: [
{
- label: 'Organizer',
+ label: 'Manager',
value: 'organizer',
},
{
- label: 'File Organizer',
+ label: 'Content Manager',
value: 'fileOrganizer',
},
{
- label: 'Writer',
+ label: 'Editor',
value: 'writer',
},
{
@@ -45,10 +47,10 @@ export const deletePermission = createAction({
value: 'commenter',
},
{
- label: 'Reader',
+ label: 'Viewer',
value: 'reader',
},
-
+
]
}
}),
@@ -63,7 +65,7 @@ export const deletePermission = createAction({
const response_permissions_list = await drive.permissions.list({
fileId: fileId,
fields: 'permissions(id, emailAddress, role)',
-
+ supportsAllDrives: true,
});
if (response_permissions_list.data.permissions) {
@@ -73,6 +75,7 @@ export const deletePermission = createAction({
await drive.permissions.delete({
fileId: fileId,
permissionId: permission.id ? permission.id : '',
+ supportsAllDrives: true,
});
return {removed: true, message: 'Permission removed'};
}
diff --git a/packages/pieces/community/google-drive/src/lib/action/drive-export-folder-as-zip.ts b/packages/pieces/community/google-drive/src/lib/action/drive-export-folder-as-zip.ts
index 0b351a9c6f1..c609964365f 100644
--- a/packages/pieces/community/google-drive/src/lib/action/drive-export-folder-as-zip.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/drive-export-folder-as-zip.ts
@@ -71,11 +71,6 @@ const NATIVE_TYPES: Record<string, NativeTypeConfig> = {
},
};
-const encryptionMethodDescription = `
-- ZipCrypto: Legacy encryption method with wide compatibility (not recommended for sensitive data)
-- AES-256: Modern encryption with strong security (may not be supported by older zip clients)
-`;
-
interface ZipFolderEntry {
relativePath: string;
fileId: string;
@@ -457,7 +452,7 @@ export const driveExportFolderAsZip = createAction({
classification: 'READ',
displayName: 'Export Folder as Zip',
description:
- 'Recursively export a Google Drive folder (with all subfolders) as a single zip file.',
+ 'Download a folder and all its subfolders as one zip file.',
audience: 'human',
aiMetadata: {
description:
@@ -465,14 +460,10 @@ export const driveExportFolderAsZip = createAction({
idempotent: true,
},
props: {
- duplicatePathWarning: Property.MarkDown({
- value:
- 'Zip paths mirror the Drive folder exactly, with no renaming. The action fails before downloading anything if: a file and a folder share a name in the same Drive folder, two items share a name, or a Google Doc/Sheet/Slides export lands on a name that already exists (e.g. a Sheet named "Report" exported as PDF alongside an existing "Report.pdf"); or an included item\'s name contains "/" or "\\", or is exactly "." or ".." (not usable as a zip path segment). Rename the conflicting or unsafe item in Drive and re-run.',
- variant: MarkdownVariant.WARNING,
- }),
folderId: Property.Dropdown({
displayName: 'Folder',
- description: 'The Drive folder to export (including all subfolders).',
+ description:
+ 'Everything inside it, including subfolders, goes into the zip.',
required: true,
auth: googleDriveAuth,
refreshers: ['includeTeamDrives'],
@@ -486,62 +477,72 @@ export const driveExportFolderAsZip = createAction({
}),
includeTeamDrives: Property.Checkbox({
displayName: 'Include Team Drives',
+ description: 'Also include shared drives, not only My Drive.',
required: false,
defaultValue: false,
}),
googleDocsFormat: Property.StaticDropdown({
- displayName: 'Google Docs',
- description: 'How to include native Google Docs found in the folder.',
+ displayName: 'Google Docs As',
+ description: 'Convert Docs to Word or PDF, or leave them out.',
required: true,
defaultValue: 'docx',
options: {
options: [
{ label: 'Word (DOCX)', value: 'docx' },
{ label: 'PDF', value: 'pdf' },
- { label: 'Skip', value: 'skip' },
+ { label: 'Leave Out', value: 'skip' },
],
},
}),
googleSheetsFormat: Property.StaticDropdown({
- displayName: 'Google Sheets',
- description: 'How to include native Google Sheets found in the folder.',
+ displayName: 'Google Sheets As',
+ description: 'Convert Sheets to Excel or PDF, or leave them out.',
required: true,
defaultValue: 'xlsx',
options: {
options: [
{ label: 'Excel (XLSX)', value: 'xlsx' },
{ label: 'PDF', value: 'pdf' },
- { label: 'Skip', value: 'skip' },
+ { label: 'Leave Out', value: 'skip' },
],
},
}),
googleSlidesFormat: Property.StaticDropdown({
- displayName: 'Google Slides',
- description: 'How to include native Google Slides found in the folder.',
+ displayName: 'Google Slides As',
+ description: 'Convert Slides to PowerPoint or PDF, or leave them out.',
required: true,
defaultValue: 'pptx',
options: {
options: [
{ label: 'PowerPoint (PPTX)', value: 'pptx' },
{ label: 'PDF', value: 'pdf' },
- { label: 'Skip', value: 'skip' },
+ { label: 'Leave Out', value: 'skip' },
],
},
}),
+ duplicatePathWarning: Property.MarkDown({
+ value:
+ 'Zip paths copy the Drive names. The export stops before downloading anything if two items in one folder would share a path, for example a Sheet named "Report" exported as PDF next to an existing Report.pdf, or if a name contains / or \\ or is "." or "..". Rename the item in Drive and run again.',
+ variant: MarkdownVariant.WARNING,
+ }),
outputFileName: Property.ShortText({
- displayName: 'Output Zip File Name',
+ displayName: 'Zip File Name',
+ description: 'Include the .zip extension.',
required: true,
defaultValue: 'export.zip',
+ placeholder: 'export.zip',
}),
usePassword: Property.Checkbox({
- displayName: 'Use password',
- description: 'Enable password protection for the zip file',
+ displayName: 'Use Password',
+ description: 'Encrypt the zip so a password is needed to open it.',
required: false,
defaultValue: false,
+ advanced: true,
}),
passwordOptions: Property.DynamicProperties({
- displayName: 'Password options',
+ displayName: 'Password Options',
required: false,
+ advanced: true,
auth: PieceAuth.None(),
refreshers: ['usePassword'],
props: async ({ usePassword }) => {
@@ -552,18 +553,20 @@ export const driveExportFolderAsZip = createAction({
const fields = {
password: Property.ShortText({
displayName: 'Password',
+ description: 'Needed to open the zip.',
required: true,
}),
encryptionMethod: Property.StaticDropdown({
displayName: 'Encryption Method',
- description: encryptionMethodDescription,
+ description:
+ 'ZipCrypto opens everywhere; AES-256 is stronger but needs a modern unzip app.',
required: true,
defaultValue: 'zipcrypto',
options: {
disabled: false,
options: [
- { label: 'ZipCrypto (Most Compatible)', value: 'zipcrypto' },
- { label: 'AES-256 (Stronger Security)', value: 'aes-256' },
+ { label: 'ZipCrypto', value: 'zipcrypto' },
+ { label: 'AES-256', value: 'aes-256' },
],
},
}),
diff --git a/packages/pieces/community/google-drive/src/lib/action/duplicate-file.action.ts b/packages/pieces/community/google-drive/src/lib/action/duplicate-file.action.ts
index 3efd8f65d13..fc8c516146a 100644
--- a/packages/pieces/community/google-drive/src/lib/action/duplicate-file.action.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/duplicate-file.action.ts
@@ -9,29 +9,32 @@ export const duplicateFileAction = createAction({
auth: googleDriveAuth,
name: 'duplicate_file',
classification: 'WRITE',
- description: 'Duplicate a file from Google Drive. Returns the new file ID.',
+ description: 'Copy a file into a folder, optionally as a Google Doc or Sheet.',
audience: 'human',
aiMetadata: { description: 'Copies an existing Drive file into a target folder under a new name, optionally converting it to a Google Sheet or Google Doc. Use to clone a file or create an editable Google-format copy. Requires the source file ID and destination folder ID. Not idempotent: each call creates a new copy.', idempotent: false },
props: {
fileId: Property.ShortText({
displayName: 'File ID',
- description: 'The ID of the file to duplicate',
+ description: 'The ID of the file to copy.',
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
name: Property.ShortText({
- displayName: 'Name',
- description: 'The name of the new file',
+ displayName: 'New File Name',
+ description: 'Name of the copy.',
required: true,
+ placeholder: 'Report (copy)',
}),
folderId: Property.ShortText({
- displayName: 'Folder ID',
- description: 'The ID of the folder where the file will be duplicated',
+ displayName: 'Destination Folder ID',
+ description: 'The ID of the folder that receives the copy.',
required: true,
}),
mimeType: Property.StaticDropdown({
- displayName: 'Duplicate as',
- description: 'If left unselected the file will be duplicated as it is',
+ displayName: 'Convert To',
+ description: 'Empty keeps the original format.',
required: false,
+ advanced: true,
options: {
options: [
{
diff --git a/packages/pieces/community/google-drive/src/lib/action/get-file-by-id.ts b/packages/pieces/community/google-drive/src/lib/action/get-file-by-id.ts
index bff02b5c914..8f5b4e02590 100644
--- a/packages/pieces/community/google-drive/src/lib/action/get-file-by-id.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/get-file-by-id.ts
@@ -9,14 +9,15 @@ export const googleDriveGetResourceById = createAction({
name: 'get-file-or-folder-by-id',
classification: 'READ',
displayName: 'Get File Information',
- description: 'Get a file folder for files/sub-folders',
+ description: 'Get the details of a file or folder by its ID.',
audience: 'human',
aiMetadata: { description: 'Fetches metadata for a single file or folder in Google Drive by its exact ID (name, MIME type, parents, etc.). Use when an agent already has a file/folder ID and needs its details. Read-only and idempotent. Requires the resource ID, not a name or path.', idempotent: true },
props: {
id: Property.ShortText({
- displayName: 'File / Folder Id',
- description: 'The Id of the file/folder to search for.',
+ displayName: 'File or Folder ID',
+ description: "The ID from the item's Drive URL or an earlier step.",
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
include_team_drives: common.properties.include_team_drives,
},
diff --git a/packages/pieces/community/google-drive/src/lib/action/list-files.action.ts b/packages/pieces/community/google-drive/src/lib/action/list-files.action.ts
index b46d73800c3..ca5008e0aff 100644
--- a/packages/pieces/community/google-drive/src/lib/action/list-files.action.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/list-files.action.ts
@@ -17,38 +17,41 @@ export const googleDriveListFiles = createAction({
auth: googleDriveAuth,
name: 'list-files',
classification: 'SEARCH',
- displayName: 'List files',
- description: 'List files from a Google Drive folder',
+ displayName: 'List Files',
+ description: 'List the files and folders inside a folder.',
audience: 'human',
aiMetadata: { description: 'Lists files and subfolders inside a given Drive folder, with optional recursion to a chosen depth and optional download of each file\'s content. Use to enumerate the contents of a known folder ID. Read-only and idempotent. Requires the folder ID, not a name.', idempotent: true },
props: {
folderId: Property.ShortText({
displayName: 'Folder ID',
- description: 'Folder ID coming from | New Folder -> id | (or any other source)',
+ description: 'The ID after /folders/ in the folder URL, or from an earlier step.',
required: true,
- }),
- include_team_drives: common.properties.include_team_drives,
-
- includeTrashed: Property.Checkbox({
- displayName: 'Include Trashed',
- description: 'Include new files that have been trashed.',
- required: false,
- defaultValue: false
+ placeholder: '1aMEtTqIYn5651wdK7WLxaK_SDim4mvXW',
}),
depthLevel: Property.Number({
- displayName: 'Depth Level',
- description: 'How many levels deep to search for files. 1 = current folder only, 2 = current + next level, etc.',
+ displayName: 'Folder Depth',
+ description: '1 lists only this folder; 2 adds its subfolders, and so on.',
required: false,
defaultValue: 1
}),
downloadFiles: Property.Checkbox({
displayName: 'Download Files',
- description: 'Download all file contents in a list',
+ description: 'Also download every file. Slow for large folders.',
required: false,
defaultValue: false
}),
+
+ include_team_drives: common.properties.include_team_drives,
+
+ includeTrashed: Property.Checkbox({
+ displayName: 'Include Trashed',
+ description: 'Also list files that are in the bin.',
+ required: false,
+ defaultValue: false,
+ advanced: true
+ }),
},
outputSchema: listFilesActionOutputSchema,
async run(context) {
diff --git a/packages/pieces/community/google-drive/src/lib/action/move-file.ts b/packages/pieces/community/google-drive/src/lib/action/move-file.ts
index 6eeb49a97e4..daeb8757c67 100644
--- a/packages/pieces/community/google-drive/src/lib/action/move-file.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/move-file.ts
@@ -9,17 +9,21 @@ export const moveFileAction = createAction({
name: 'google-drive-move-file',
classification: 'WRITE',
displayName: 'Move File',
- description: 'Moves a file from one folder to another.',
+ description: 'Move a file into another folder.',
audience: 'human',
aiMetadata: { description: 'Relocates a Drive file to a target folder, detaching it from its current parents and attaching it to the new one. Use to reorganize a file once you know its ID and the destination folder ID. Idempotent: repeating with the same destination leaves the file in the same folder.', idempotent: true },
props: {
fileId: Property.ShortText({
displayName: 'File ID',
- description: 'You can use **Search Folder/File** action to retrieve ID.',
+ description: 'Use the ID from a trigger or the Find File or Folder action.',
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
+ }),
+ folderId: common.parentFolderDropdown({
+ displayName: 'Destination Folder',
+ description: 'The folder to move the file into. Type to search by folder name.',
}),
include_team_drives: common.properties.include_team_drives,
- folderId: common.properties.parentFolder,
},
outputSchema: googleDriveMoveFileActionOutputSchema,
async run(context) {
diff --git a/packages/pieces/community/google-drive/src/lib/action/read-file.ts b/packages/pieces/community/google-drive/src/lib/action/read-file.ts
index 7f68dff3646..e19a66612ca 100644
--- a/packages/pieces/community/google-drive/src/lib/action/read-file.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/read-file.ts
@@ -7,19 +7,22 @@ export const readFile = createAction({
auth: googleDriveAuth,
name: 'read-file',
classification: 'READ',
- displayName: 'Read File Content',
- description: 'Read a selected file from google drive file',
+ displayName: 'Download File',
+ description: 'Download a file. Google Docs, Sheets and Slides become Office files.',
audience: 'human',
aiMetadata: { description: 'Downloads the content of a Drive file by its file ID and returns it as a usable file reference. Use to retrieve a file an agent already knows the ID of (e.g. from a trigger or search). Read-only and idempotent. Requires the exact file ID, not a name.', idempotent: true },
props: {
fileId: Property.ShortText({
displayName: 'File ID',
- description: 'File ID coming from | New File -> id |',
+ description: 'Use the ID from a trigger or the Find File or Folder action.',
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
fileName: Property.ShortText({
- displayName: 'Destination File name',
+ displayName: 'File Name',
+ description: 'Name for the saved file. Empty uses the file ID plus its extension.',
required: false,
+ placeholder: 'report.pdf',
}),
},
outputSchema: readFileActionOutputSchema,
diff --git a/packages/pieces/community/google-drive/src/lib/action/save-file-as-pdf.action.ts b/packages/pieces/community/google-drive/src/lib/action/save-file-as-pdf.action.ts
index 21a55bb1cbc..a6889c948ce 100644
--- a/packages/pieces/community/google-drive/src/lib/action/save-file-as-pdf.action.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/save-file-as-pdf.action.ts
@@ -12,24 +12,26 @@ export const saveFileAsPdf = createAction({
auth: googleDriveAuth,
name: 'save_file_as_pdf',
classification: 'WRITE',
- description: 'Save a document as PDF in a Google Drive folder',
+ description: 'Export a Google Doc, Sheet or Slides as a PDF into a folder.',
audience: 'human',
aiMetadata: { description: 'Exports a Google document to PDF and saves it as a new file in a target Drive folder. Use to produce a PDF rendition of a Google Doc/Sheet/Slides for sharing or archival. Requires the source document ID and destination folder ID. Not idempotent: each call creates a new PDF file.', idempotent: false },
props: {
documentId: Property.ShortText({
displayName: 'Document ID',
- description: 'The ID of the document to export',
+ description: 'The ID of the Google Doc, Sheet or Slides to export.',
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
folderId: Property.ShortText({
- displayName: 'Folder ID',
- description: 'The ID of the folder where the file will be exported',
+ displayName: 'Destination Folder ID',
+ description: 'The ID of the folder that receives the PDF.',
required: true,
}),
name: Property.ShortText({
- displayName: 'Name',
- description: 'The name of the new file (do not include the extension)',
+ displayName: 'File Name',
+ description: 'Without the extension; .pdf is added.',
required: true,
+ placeholder: 'Quarterly report',
}),
include_team_drives: common.properties.include_team_drives,
},
diff --git a/packages/pieces/community/google-drive/src/lib/action/search-folder-or-file.action.ts b/packages/pieces/community/google-drive/src/lib/action/search-folder-or-file.action.ts
index db4b0489c26..a6c41990906 100644
--- a/packages/pieces/community/google-drive/src/lib/action/search-folder-or-file.action.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/search-folder-or-file.action.ts
@@ -2,33 +2,34 @@ import { googleDriveAuth, createGoogleClient } from '../auth';
import { Property, createAction } from '@activepieces/pieces-framework';
import { drive as googleDrive } from '@googleapis/drive';
import { common } from '../common';
+import { buildDriveSearchQuery } from '../common/search-query';
import { searchFolderActionOutputSchema } from '../output-schemas';
export const googleDriveSearchFolder = createAction({
auth: googleDriveAuth,
name: 'search-folder',
classification: 'SEARCH',
- displayName: 'Search',
- description: 'Search a Google Drive folder for files/sub-folders',
+ displayName: 'Find File or Folder',
+ description: 'Find files or folders by name, content or type.',
audience: 'human',
aiMetadata: { description: 'Searches Google Drive for files or folders matching a name, full-text, or MIME-type query, optionally scoped to a parent folder and filtered to files or folders only. Use to resolve a file/folder ID from a human-readable name before acting on it. Read-only and idempotent.', idempotent: true },
props: {
queryTerm: Property.StaticDropdown({
- displayName: 'Query Term',
- description: 'The Query term or field of file/folder to search upon.',
+ displayName: 'Search By',
+ description: 'Match the file name, the text inside it, or its type.',
defaultValue: 'name',
options: {
options: [
- { label: 'File name', value: 'name' },
- { label: 'Full text search', value: 'fullText' },
- { label: 'Content type', value: 'mimeType' },
+ { label: 'File Name', value: 'name' },
+ { label: 'Text Inside the File', value: 'fullText' },
+ { label: 'File Type', value: 'mimeType' },
],
},
required: true,
}),
operator: Property.StaticDropdown({
- displayName: 'Operator',
- description: 'The operator to create criteria.',
+ displayName: 'Match',
+ description: 'Contains finds partial matches; Equals needs the exact value.',
required: true,
options: {
options: [
@@ -39,24 +40,28 @@ export const googleDriveSearchFolder = createAction({
defaultValue: 'contains',
}),
query: Property.ShortText({
- displayName: 'Value',
- description: 'Value of the field of file/folder to search for.',
+ displayName: 'Search Text',
+ description: 'The name, text or type to look for.',
required: true,
+ placeholder: 'Quarterly report',
}),
type: Property.StaticDropdown({
- displayName: 'File Type',
- description: '(Optional) Choose between files and folders.',
+ displayName: 'Show',
+ description: 'Return everything, only files or only folders.',
required: false,
options: {
options: [
- { label: 'All', value: 'all' },
- { label: 'Files', value: 'file' },
- { label: 'Folders', value: 'folder' },
+ { label: 'Files and Folders', value: 'all' },
+ { label: 'Files Only', value: 'file' },
+ { label: 'Folders Only', value: 'folder' },
],
},
defaultValue: 'all',
}),
- parentFolder: common.properties.parentFolder,
+ parentFolder: common.parentFolderDropdown({
+ displayName: 'Search in Folder',
+ description: 'Leave empty to search all of Drive. Type to search by folder name.',
+ }),
include_team_drives: common.properties.include_team_drives,
},
outputSchema: searchFolderActionOutputSchema,
@@ -64,24 +69,13 @@ export const googleDriveSearchFolder = createAction({
const authClient = await createGoogleClient(context.auth);
const drive = googleDrive({ version: 'v3', auth: authClient });
- const operator = context.propsValue.operator ?? 'contains';
- const queryTerm = context.propsValue.queryTerm ?? 'name';
- let finalQuery = `${queryTerm} ${operator} '${context.propsValue.query}'`;
- if (context.propsValue.parentFolder) {
- finalQuery = `${finalQuery} and '${context.propsValue.parentFolder}' in parents`;
- }
-
- const type = context.propsValue.type ?? 'all';
- switch (type) {
- case 'file':
- finalQuery = `${finalQuery} and mimeType!='application/vnd.google-apps.folder'`;
- break;
- case 'folder':
- finalQuery = `${finalQuery} and mimeType='application/vnd.google-apps.folder'`;
- break;
- default:
- break;
- }
+ const finalQuery = buildDriveSearchQuery({
+ queryTerm: context.propsValue.queryTerm ?? 'name',
+ operator: context.propsValue.operator ?? 'contains',
+ query: context.propsValue.query,
+ parentFolder: context.propsValue.parentFolder,
+ type: context.propsValue.type ?? 'all',
+ });
const allFiles: any[] = [];
let pageToken: string | undefined = undefined;
diff --git a/packages/pieces/community/google-drive/src/lib/action/send-to-trash.ts b/packages/pieces/community/google-drive/src/lib/action/send-to-trash.ts
index ee69bdab151..1865a656d9a 100644
--- a/packages/pieces/community/google-drive/src/lib/action/send-to-trash.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/send-to-trash.ts
@@ -8,15 +8,16 @@ export const googleDriveTrashFile = createAction({
auth: googleDriveAuth,
name: 'trash_gdrive_file',
classification: 'DESTRUCTIVE',
- description: 'Move a file to the trash in your Google Drive',
+ description: 'Move a file to the bin, where it can be restored.',
audience: 'human',
aiMetadata: { description: 'Moves a Drive file to the trash by its ID, a reversible deletion that can be restored from Drive. Use for safe removal instead of permanent deletion. Requires the file ID. Idempotent: re-trashing an already-trashed file leaves it in the same state.', idempotent: true },
- displayName: 'Trash file',
+ displayName: 'Move File to Trash',
props: {
fileId: Property.ShortText({
displayName: 'File ID',
- description: 'The ID of the file to trash',
+ description: 'The ID of the file to trash.',
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
include_team_drives: common.properties.include_team_drives,
},
diff --git a/packages/pieces/community/google-drive/src/lib/action/set-public-access.ts b/packages/pieces/community/google-drive/src/lib/action/set-public-access.ts
index e3acbf3fc1c..818b8d5977d 100644
--- a/packages/pieces/community/google-drive/src/lib/action/set-public-access.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/set-public-access.ts
@@ -8,22 +8,23 @@ export const setPublicAccess = createAction({
auth: googleDriveAuth,
name: 'set_public_access',
classification: 'WRITE',
- description: 'Set public access for a file or folder',
+ description: 'Let anyone with the link open a file or folder.',
audience: 'human',
aiMetadata: { description: 'Makes a Drive file or folder accessible to anyone with the link at the chosen role (reader, commenter, or writer) and returns its shareable view/download URL. Use to publish a resource publicly. Requires the file/folder ID. Not idempotent: each call adds a new anyone-with-link permission.', idempotent: false },
- displayName: 'Set public access',
+ displayName: 'Set Public Access',
props: {
fileId: Property.ShortText({
displayName: 'File or Folder ID',
- description: 'The ID of the file or folder to update permissions for',
+ description: "The ID from the item's Drive URL or an earlier step.",
required: true,
+ placeholder: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
}),
role: Property.StaticDropdown({
displayName: 'Role',
- description: 'The role to assign for public access',
+ description: 'What anyone with the link can do.',
options: {
options: [
- { label: 'Reader', value: 'reader' },
+ { label: 'Viewer', value: 'reader' },
{ label: 'Commenter', value: 'commenter' },
{ label: 'Editor', value: 'writer' },
],
@@ -47,11 +48,13 @@ export const setPublicAccess = createAction({
const res = await drive.permissions.create({
fileId: fileId,
requestBody: permission,
+ supportsAllDrives: true,
});
const file = await drive.files.get({
fileId: fileId,
fields: 'name,mimeType,webContentLink,webViewLink',
+ supportsAllDrives: true,
});
if (file.data.mimeType === 'application/vnd.google-apps.folder') {
diff --git a/packages/pieces/community/google-drive/src/lib/action/upload-file.ts b/packages/pieces/community/google-drive/src/lib/action/upload-file.ts
index 3d105c75b03..b7d92daf4e8 100644
--- a/packages/pieces/community/google-drive/src/lib/action/upload-file.ts
+++ b/packages/pieces/community/google-drive/src/lib/action/upload-file.ts
@@ -10,19 +10,20 @@ export const googleDriveUploadFile = createAction({
auth: googleDriveAuth,
name: 'upload_gdrive_file',
classification: 'WRITE',
- description: 'Upload a file in your Google Drive',
+ description: 'Upload a file to Google Drive.',
audience: 'human',
aiMetadata: { description: 'Uploads a binary file (from a URL or base64 input) into Google Drive, optionally inside a parent folder. Use to store an existing file or attachment in Drive; the MIME type is inferred from the file extension. Not idempotent: each call creates a new file.', idempotent: false },
- displayName: 'Upload file',
+ displayName: 'Upload File',
props: {
fileName: Property.ShortText({
- displayName: 'File name',
- description: 'The name of the file',
+ displayName: 'File Name',
+ description: 'Name shown in Drive, including the extension.',
required: true,
+ placeholder: 'photo.png',
}),
file: Property.File({
displayName: 'File',
- description: 'The file URL or base64 to upload',
+ description: 'The file to upload, from an earlier step or a URL.',
required: true,
streaming: true,
}),
diff --git a/packages/pieces/community/google-drive/src/lib/common/index.ts b/packages/pieces/community/google-drive/src/lib/common/index.ts
index aa86287eee6..4720e402d97 100644
--- a/packages/pieces/community/google-drive/src/lib/common/index.ts
+++ b/packages/pieces/community/google-drive/src/lib/common/index.ts
@@ -27,7 +27,7 @@ async function fetchFolderDropdownOptions({
return {
disabled: true,
options: [],
- placeholder: 'Please authenticate first',
+ placeholder: 'Connect your Google account first',
};
}
const accessToken = await getAccessToken(auth);
@@ -71,7 +71,7 @@ async function fetchFolderDropdownOptions({
return {
disabled: false,
placeholder: truncated
- ? `Showing first ${folders.length} matches — type to narrow the list, or switch to Dynamic value to paste an ID.`
+ ? `Showing the first ${folders.length} matches. Type to narrow the list, or paste an ID with Dynamic value.`
: undefined,
options: folders.map((folder: { id: string; name: string }) => {
return {
@@ -82,32 +82,46 @@ async function fetchFolderDropdownOptions({
};
}
+function parentFolderDropdown({
+ displayName,
+ description,
+}: {
+ displayName: string;
+ description: string;
+}) {
+ return Property.Dropdown({
+ displayName,
+ description,
+ required: false,
+ auth: googleDriveAuth,
+ refreshers: ['include_team_drives'],
+ refreshOnSearch: true,
+ options: async ({ auth, include_team_drives }, ctx) =>
+ fetchFolderDropdownOptions({
+ auth: auth as GoogleDriveAuthValue | undefined,
+ searchValue: ctx?.searchValue,
+ includeTeamDrives: include_team_drives as boolean | undefined,
+ }),
+ });
+}
+
export const common = {
properties: {
- parentFolder: Property.Dropdown({
+ parentFolder: parentFolderDropdown({
displayName: 'Parent Folder',
description:
- "The Drive folder to target. Leave empty to use the root of My Drive. Type in the box to search your Drive by folder name. If the folder still isn't listed, switch this field to 'Dynamic value' (the toggle next to the field) and paste the folder ID — you can copy it from the folder's URL in Drive, after /folders/ (e.g. https://drive.google.com/drive/folders/<FOLDER_ID>).",
- required: false,
- auth: googleDriveAuth,
- refreshers: ['include_team_drives'],
- refreshOnSearch: true,
- options: async ({ auth, include_team_drives }, ctx) =>
- fetchFolderDropdownOptions({
- auth: auth as GoogleDriveAuthValue | undefined,
- searchValue: ctx?.searchValue,
- includeTeamDrives: include_team_drives as boolean | undefined,
- }),
+ 'Leave empty for the root of My Drive. Type to search by folder name.',
}),
include_team_drives: Property.Checkbox({
displayName: 'Include Team Drives',
- description:
- 'Determines if folders from Team Drives should be included in the results.',
+ description: 'Also include shared drives, not only My Drive.',
defaultValue: false,
required: false,
}),
},
+ parentFolderDropdown,
+ escapeDriveQueryLiteral,
fetchFolderDropdownOptions,
async getFiles(
diff --git a/packages/pieces/community/google-drive/src/lib/common/search-query.ts b/packages/pieces/community/google-drive/src/lib/common/search-query.ts
new file mode 100644
index 00000000000..c2246bb2f6b
--- /dev/null
+++ b/packages/pieces/community/google-drive/src/lib/common/search-query.ts
@@ -0,0 +1,33 @@
+import { common } from './index';
+
+const FOLDER_MIME_TYPE = 'application/vnd.google-apps.folder';
+
+export function buildDriveSearchQuery({
+ queryTerm,
+ operator,
+ query,
+ parentFolder,
+ type,
+}: {
+ queryTerm: string;
+ operator: string;
+ query: string;
+ parentFolder: string | undefined;
+ type: string;
+}): string {
+ const clauses = [
+ `${queryTerm} ${operator} '${common.escapeDriveQueryLiteral(query)}'`,
+ ];
+ if (parentFolder) {
+ clauses.push(
+ `'${common.escapeDriveQueryLiteral(parentFolder)}' in parents`
+ );
+ }
+ if (type === 'file') {
+ clauses.push(`mimeType!='${FOLDER_MIME_TYPE}'`);
+ }
+ if (type === 'folder') {
+ clauses.push(`mimeType='${FOLDER_MIME_TYPE}'`);
+ }
+ return clauses.join(' and ');
+}
diff --git a/packages/pieces/community/google-drive/src/lib/triggers/new-file.ts b/packages/pieces/community/google-drive/src/lib/triggers/new-file.ts
index 0ed25f13bcd..52b2843423d 100644
--- a/packages/pieces/community/google-drive/src/lib/triggers/new-file.ts
+++ b/packages/pieces/community/google-drive/src/lib/triggers/new-file.ts
@@ -41,16 +41,22 @@ export const newFile = createTrigger({
name: 'new_file',
classification: 'READ',
displayName: 'New File',
- description: 'Trigger when a new file is uploaded.',
+ description:
+ 'Triggers when a new file is added to Drive or the chosen folder.',
aiMetadata: {
description: 'Fires when a new file appears in Google Drive, optionally scoped to a specific parent folder. Each event represents one newly created file and its metadata, with optional inclusion of the file content.',
},
props: {
- parentFolder: common.properties.parentFolder,
+ parentFolder: common.parentFolderDropdown({
+ displayName: 'Folder',
+ description:
+ 'Leave empty to watch all of My Drive. Type to search by folder name.',
+ }),
include_team_drives: common.properties.include_team_drives,
include_file_content: Property.Checkbox({
displayName: 'Include File Content',
- description: 'Include the file content in the output. This will increase the time taken to fetch the files and might cause issues with large files.',
+ description:
+ 'Also download each file. Slower, and very large files may fail.',
required: false,
defaultValue: false
}),
@@ -97,7 +103,10 @@ export const newFile = createTrigger({
mimeType: 'image/png',
id: '1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5',
name: 'google-drive.png',
- link: 'https://cdn.activepieces.com/pieces/google-drive.png'
+ webViewLink:
+ 'https://drive.google.com/file/d/1dpv4-sKJfKRwI9qx1vWqQhEGEn3EpbI5/view?usp=drivesdk',
+ createdTime: '2026-08-20T09:12:44.000Z',
+ modifiedTime: '2026-08-20T09:12:44.000Z',
},
});
diff --git a/packages/pieces/community/google-drive/src/lib/triggers/new-folder.ts b/packages/pieces/community/google-drive/src/lib/triggers/new-folder.ts
index 7a7b9b2131c..765ee39d773 100644
--- a/packages/pieces/community/google-drive/src/lib/triggers/new-folder.ts
+++ b/packages/pieces/community/google-drive/src/lib/triggers/new-folder.ts
@@ -39,12 +39,17 @@ export const newFolder = createTrigger({
name: 'new_folder',
classification: 'READ',
displayName: 'New Folder',
- description: 'Trigger when a new folder is created or uploaded.',
+ description:
+ 'Triggers when a new folder is created in Drive or the chosen folder.',
aiMetadata: {
description: 'Fires when a new folder is created in Google Drive, optionally scoped to a specific parent folder. Each event represents one newly created folder and its metadata.',
},
props: {
- parentFolder: common.properties.parentFolder,
+ parentFolder: common.parentFolderDropdown({
+ displayName: 'Folder',
+ description:
+ 'Leave empty to watch all of My Drive. Type to search by folder name.',
+ }),
include_team_drives: common.properties.include_team_drives,
},
outputSchema: newFolderTriggerOutputSchema,
@@ -74,6 +79,7 @@ export const newFolder = createTrigger({
kind: 'drive#file',
mimeType: 'application/vnd.google-apps.folder',
id: '1aMEtTqIYn5651wdK7WLxaK_SDim4mvXW',
- name: 'New Folder WOOOO',
+ name: 'Invoices 2026',
+ createdTime: '2026-08-20T09:12:44.000Z',
},
});
diff --git a/packages/pieces/community/google-drive/src/lib/triggers/new-or-updated-file.ts b/packages/pieces/community/google-drive/src/lib/triggers/new-or-updated-file.ts
index 448f9467e7d..6bdca96dc1e 100644
--- a/packages/pieces/community/google-drive/src/lib/triggers/new-or-updated-file.ts
+++ b/packages/pieces/community/google-drive/src/lib/triggers/new-or-updated-file.ts
@@ -1,6 +1,7 @@
import {
AppConnectionValueForAuthProperty,
FilesService,
+ MarkdownVariant,
Property,
TriggerStrategy,
createTrigger,
@@ -56,18 +57,27 @@ export const newOrUpdatedFile = createTrigger({
classification: 'READ',
displayName: 'New or Updated File',
description:
- 'Trigger when a file is created or updated, checked on a schedule. Each event carries a Change Type of created or updated, and several edits between two checks arrive as a single event. Renaming a file counts as an update. Trashing a file is not an event, and neither is restoring one from the bin nor moving an existing file into the watched folder. Selecting a parent folder watches its direct children only, not sub-folders.',
+ 'Triggers when a file is created or edited. A rename counts; trashing or moving does not.',
aiMetadata: {
description:
'Fires when a file is created or modified in Google Drive, based on its creation and last-modified times (polling), optionally scoped to a parent folder and to specific file types. Each event represents one file and its metadata, carries a changeType of created or updated, and can include the file content, falling back to a contentError field when a download fails. Choose this over New File when edits to files that already exist should also trigger the flow.',
},
props: {
- parentFolder: common.properties.parentFolder,
+ behaviourNote: Property.MarkDown({
+ value:
+ 'Each event carries a Change Type of created or updated. Several edits between two checks arrive as one event. A chosen folder is watched one level deep, not its subfolders.',
+ variant: MarkdownVariant.INFO,
+ }),
+ parentFolder: common.parentFolderDropdown({
+ displayName: 'Folder',
+ description:
+ 'Leave empty to watch all of My Drive. Type to search by folder name.',
+ }),
include_team_drives: common.properties.include_team_drives,
file_types: Property.StaticMultiSelectDropdown({
displayName: 'File Types',
description:
- "Only fire for files of these types. Leave empty to watch every type. If the type you need is not listed, switch this field to 'Dynamic value' (the toggle next to the field) and provide a list of MIME types.",
+ 'Empty watches every type. Use Dynamic value to add other MIME types.',
required: false,
options: {
options: [
@@ -99,7 +109,7 @@ export const newOrUpdatedFile = createTrigger({
include_file_content: Property.Checkbox({
displayName: 'Include File Content',
description:
- 'Include the file content in the output. This will increase the time taken to fetch the files and might cause issues with large files. If a download fails the event still arrives, carrying a File Content Error instead of the content.',
+ 'Also download each file. A failed download adds an error instead.',
required: false,
defaultValue: false,
}),
diff --git a/packages/pieces/community/google-drive/test/search-query.test.ts b/packages/pieces/community/google-drive/test/search-query.test.ts
new file mode 100644
index 00000000000..65f02c96a6c
--- /dev/null
+++ b/packages/pieces/community/google-drive/test/search-query.test.ts
@@ -0,0 +1,66 @@
+/// <reference types="vitest/globals" />
+
+import { buildDriveSearchQuery } from '../src/lib/common/search-query';
+
+const base = {
+ queryTerm: 'name',
+ operator: 'contains',
+ query: 'Quarterly report',
+ parentFolder: undefined,
+ type: 'all',
+};
+
+describe('buildDriveSearchQuery', () => {
+ it('builds a plain name search', () => {
+ expect(buildDriveSearchQuery(base)).toBe("name contains 'Quarterly report'");
+ });
+
+ it('escapes apostrophes in the search text', () => {
+ expect(buildDriveSearchQuery({ ...base, query: "Tom's notes" })).toBe(
+ "name contains 'Tom\\'s notes'"
+ );
+ });
+
+ it('escapes backslashes before apostrophes in the search text', () => {
+ expect(buildDriveSearchQuery({ ...base, query: "a\\'b" })).toBe(
+ "name contains 'a\\\\\\'b'"
+ );
+ });
+
+ it('keeps an injected clause inside the literal', () => {
+ const query = buildDriveSearchQuery({
+ ...base,
+ query: "x' or trashed=true and name contains 'y",
+ });
+ expect(query).toBe(
+ "name contains 'x\\' or trashed=true and name contains \\'y'"
+ );
+ });
+
+ it('escapes the parent folder id', () => {
+ expect(
+ buildDriveSearchQuery({ ...base, parentFolder: "id' or '1'='1" })
+ ).toBe("name contains 'Quarterly report' and 'id\\' or \\'1\\'=\\'1' in parents");
+ });
+
+ it('omits the parents clause when no folder is chosen', () => {
+ expect(buildDriveSearchQuery({ ...base, parentFolder: '' })).not.toContain(
+ 'in parents'
+ );
+ });
+
+ it('narrows to files or folders', () => {
+ expect(buildDriveSearchQuery({ ...base, type: 'file' })).toBe(
+ "name contains 'Quarterly report' and mimeType!='application/vnd.google-apps.folder'"
+ );
+ expect(buildDriveSearchQuery({ ...base, type: 'folder' })).toBe(
+ "name contains 'Quarterly report' and mimeType='application/vnd.google-apps.folder'"
+ );
+ });
+
+ it('uses the chosen term and operator', () => {
+ expect(
+ buildDriveSearchQuery({ ...base, queryTerm: 'mimeType', operator: '=', query: 'text/csv' })
+ ).toBe("mimeType = 'text/csv'");
+ });
+});