From 47e3b7c7f0c6f72c03f30933d4637c7d1d3fa821 Mon Sep 17 00:00:00 2001 From: aadamgough Date: Fri, 9 Jan 2026 14:42:34 -0800 Subject: [PATCH 1/9] expanded metadata fields for google drive --- apps/sim/tools/google_drive/download.ts | 157 +++++++++++- apps/sim/tools/google_drive/get_content.ts | 180 +++++++++++--- apps/sim/tools/google_drive/list.ts | 100 ++++++-- apps/sim/tools/google_drive/types.ts | 273 ++++++++++++++++++++- apps/sim/tools/google_drive/upload.ts | 109 ++++++-- 5 files changed, 751 insertions(+), 68 deletions(-) diff --git a/apps/sim/tools/google_drive/download.ts b/apps/sim/tools/google_drive/download.ts index c01d1a0475..a0ecd08f57 100644 --- a/apps/sim/tools/google_drive/download.ts +++ b/apps/sim/tools/google_drive/download.ts @@ -1,14 +1,115 @@ import { createLogger } from '@sim/logger' -import type { GoogleDriveDownloadResponse, GoogleDriveToolParams } from '@/tools/google_drive/types' +import type { + GoogleDriveDownloadResponse, + GoogleDriveFile, + GoogleDriveRevision, + GoogleDriveToolParams, +} from '@/tools/google_drive/types' import { DEFAULT_EXPORT_FORMATS, GOOGLE_WORKSPACE_MIME_TYPES } from '@/tools/google_drive/utils' import type { ToolConfig } from '@/tools/types' const logger = createLogger('GoogleDriveDownloadTool') +// All available file metadata fields from Google Drive API v3 +const ALL_FILE_FIELDS = [ + // Basic Info + 'id', + 'name', + 'mimeType', + 'kind', + 'description', + 'originalFilename', + 'fullFileExtension', + 'fileExtension', + // Ownership & Sharing + 'owners', + 'permissions', + 'permissionIds', + 'shared', + 'ownedByMe', + 'writersCanShare', + 'viewersCanCopyContent', + 'copyRequiresWriterPermission', + 'sharingUser', + // Labels/Tags + 'starred', + 'trashed', + 'explicitlyTrashed', + 'properties', + 'appProperties', + 'folderColorRgb', + // Timestamps + 'createdTime', + 'modifiedTime', + 'modifiedByMeTime', + 'viewedByMeTime', + 'sharedWithMeTime', + 'trashedTime', + // User Info + 'lastModifyingUser', + 'trashingUser', + 'viewedByMe', + 'modifiedByMe', + // Links + 'webViewLink', + 'webContentLink', + 'iconLink', + 'thumbnailLink', + 'exportLinks', + // Size & Storage + 'size', + 'quotaBytesUsed', + // Checksums + 'md5Checksum', + 'sha1Checksum', + 'sha256Checksum', + // Hierarchy & Location + 'parents', + 'spaces', + 'driveId', + 'teamDriveId', + // Capabilities + 'capabilities', + // Versions + 'version', + 'headRevisionId', + // Media Metadata + 'hasThumbnail', + 'thumbnailVersion', + 'imageMediaMetadata', + 'videoMediaMetadata', + 'contentHints', + // Other + 'isAppAuthorized', + 'contentRestrictions', + 'resourceKey', + 'shortcutDetails', + 'linkShareMetadata', +].join(',') + +// All revision fields +const ALL_REVISION_FIELDS = [ + 'id', + 'mimeType', + 'modifiedTime', + 'keepForever', + 'published', + 'publishAuto', + 'publishedLink', + 'publishedOutsideDomain', + 'lastModifyingUser', + 'originalFilename', + 'md5Checksum', + 'size', + 'exportLinks', + 'kind', +].join(',') + export const downloadTool: ToolConfig = { id: 'google_drive_download', name: 'Download File from Google Drive', - description: 'Download a file from Google Drive (exports Google Workspace files automatically)', + description: + 'Download a file from Google Drive with complete metadata (exports Google Workspace files automatically)', version: '1.0', oauth: { @@ -41,11 +142,17 @@ export const downloadTool: ToolConfig - `https://www.googleapis.com/drive/v3/files/${params.fileId}?fields=id,name,mimeType&supportsAllDrives=true`, + `https://www.googleapis.com/drive/v3/files/${params.fileId}?fields=${ALL_FILE_FIELDS}&supportsAllDrives=true`, method: 'GET', headers: (params) => ({ Authorization: `Bearer ${params.accessToken}`, @@ -64,7 +171,7 @@ export const downloadTool: ToolConfig = { id: 'google_drive_get_content', name: 'Get Content from Google Drive', description: - 'Get content from a file in Google Drive (exports Google Workspace files automatically)', + 'Get content from a file in Google Drive with complete metadata (exports Google Workspace files automatically)', version: '1.0', oauth: { @@ -39,11 +136,17 @@ export const getContentTool: ToolConfig - `https://www.googleapis.com/drive/v3/files/${params.fileId}?fields=id,name,mimeType&supportsAllDrives=true`, + `https://www.googleapis.com/drive/v3/files/${params.fileId}?fields=${ALL_FILE_FIELDS}&supportsAllDrives=true`, method: 'GET', headers: (params) => ({ Authorization: `Bearer ${params.accessToken}`, @@ -61,7 +164,7 @@ export const getContentTool: ToolConfig = { id: 'google_drive_list', name: 'List Google Drive Files', - description: 'List files and folders in Google Drive', + description: 'List files and folders in Google Drive with complete metadata', version: '1.0', oauth: { @@ -55,10 +133,7 @@ export const listTool: ToolConfig { const url = new URL('https://www.googleapis.com/drive/v3/files') - url.searchParams.append( - 'fields', - 'files(id,name,mimeType,webViewLink,webContentLink,size,createdTime,modifiedTime,parents),nextPageToken' - ) + url.searchParams.append('fields', `files(${ALL_FILE_FIELDS}),nextPageToken`) // Ensure shared drives support - corpora=allDrives is critical for searching across shared drives url.searchParams.append('corpora', 'allDrives') url.searchParams.append('supportsAllDrives', 'true') @@ -104,17 +179,7 @@ export const listTool: ToolConfig ({ - id: file.id, - name: file.name, - mimeType: file.mimeType, - webViewLink: file.webViewLink, - webContentLink: file.webContentLink, - size: file.size, - createdTime: file.createdTime, - modifiedTime: file.modifiedTime, - parents: file.parents, - })), + files: data.files, nextPageToken: data.nextPageToken, }, } @@ -123,7 +188,8 @@ export const listTool: ToolConfig +} + +// Label/tag information +export interface GoogleDriveLabel { + id?: string + revisionId?: string + kind?: string + fields?: Record< + string, + { + kind?: string + id?: string + valueType?: string + dateString?: string[] + integer?: string[] + selection?: string[] + text?: string[] + user?: GoogleDriveUser[] + } + > +} + +// Content hints for indexing +export interface GoogleDriveContentHints { + indexableText?: string + thumbnail?: { + image?: string + mimeType?: string + } +} + +// Image-specific metadata +export interface GoogleDriveImageMediaMetadata { + width?: number + height?: number + rotation?: number + time?: string + cameraMake?: string + cameraModel?: string + exposureTime?: number + aperture?: number + flashUsed?: boolean + focalLength?: number + isoSpeed?: number + meteringMode?: string + sensor?: string + exposureMode?: string + colorSpace?: string + whiteBalance?: string + exposureBias?: number + maxApertureValue?: number + subjectDistance?: number + lens?: string + location?: { + latitude?: number + longitude?: number + altitude?: number + } +} + +// Video-specific metadata +export interface GoogleDriveVideoMediaMetadata { + width?: number + height?: number + durationMillis?: string +} + +// Shortcut details +export interface GoogleDriveShortcutDetails { + targetId?: string + targetMimeType?: string + targetResourceKey?: string +} + +// Content restrictions +export interface GoogleDriveContentRestriction { + readOnly?: boolean + reason?: string + type?: string + restrictingUser?: GoogleDriveUser + restrictionTime?: string + ownerRestricted?: boolean + systemRestricted?: boolean +} + +// Link share metadata +export interface GoogleDriveLinkShareMetadata { + securityUpdateEligible?: boolean + securityUpdateEnabled?: boolean +} + +// Capabilities - what the current user can do with the file +export interface GoogleDriveCapabilities { + canAcceptOwnership?: boolean + canAddChildren?: boolean + canAddFolderFromAnotherDrive?: boolean + canAddMyDriveParent?: boolean + canChangeCopyRequiresWriterPermission?: boolean + canChangeSecurityUpdateEnabled?: boolean + canChangeViewersCanCopyContent?: boolean + canComment?: boolean + canCopy?: boolean + canDelete?: boolean + canDeleteChildren?: boolean + canDownload?: boolean + canEdit?: boolean + canListChildren?: boolean + canModifyContent?: boolean + canModifyContentRestriction?: boolean + canModifyEditorContentRestriction?: boolean + canModifyLabels?: boolean + canModifyOwnerContentRestriction?: boolean + canMoveChildrenOutOfDrive?: boolean + canMoveChildrenOutOfTeamDrive?: boolean + canMoveChildrenWithinDrive?: boolean + canMoveChildrenWithinTeamDrive?: boolean + canMoveItemIntoTeamDrive?: boolean + canMoveItemOutOfDrive?: boolean + canMoveItemOutOfTeamDrive?: boolean + canMoveItemWithinDrive?: boolean + canMoveItemWithinTeamDrive?: boolean + canMoveTeamDriveItem?: boolean + canReadDrive?: boolean + canReadLabels?: boolean + canReadRevisions?: boolean + canReadTeamDrive?: boolean + canRemoveChildren?: boolean + canRemoveContentRestriction?: boolean + canRemoveMyDriveParent?: boolean + canRename?: boolean + canShare?: boolean + canTrash?: boolean + canTrashChildren?: boolean + canUntrash?: boolean +} + +// Revision information +export interface GoogleDriveRevision { + id?: string + mimeType?: string + modifiedTime?: string + keepForever?: boolean + published?: boolean + publishAuto?: boolean + publishedLink?: string + publishedOutsideDomain?: boolean + lastModifyingUser?: GoogleDriveUser + originalFilename?: string + md5Checksum?: string + size?: string + exportLinks?: Record + kind?: string +} + +// Complete file metadata - all 50+ fields from Google Drive API v3 export interface GoogleDriveFile { + // Basic Info id: string name: string mimeType: string + kind?: string + description?: string + originalFilename?: string + fullFileExtension?: string + fileExtension?: string + + // Ownership & Sharing + owners?: GoogleDriveUser[] + permissions?: GoogleDrivePermission[] + permissionIds?: string[] + shared?: boolean + ownedByMe?: boolean + writersCanShare?: boolean + viewersCanCopyContent?: boolean + copyRequiresWriterPermission?: boolean + sharingUser?: GoogleDriveUser + + // Labels/Tags + labels?: GoogleDriveLabel[] + labelInfo?: { + labels?: GoogleDriveLabel[] + } + starred?: boolean + trashed?: boolean + explicitlyTrashed?: boolean + properties?: Record + appProperties?: Record + folderColorRgb?: string + + // Timestamps + createdTime?: string + modifiedTime?: string + modifiedByMeTime?: string + viewedByMeTime?: string + sharedWithMeTime?: string + trashedTime?: string + + // User Info + lastModifyingUser?: GoogleDriveUser + trashingUser?: GoogleDriveUser + viewedByMe?: boolean + modifiedByMe?: boolean + + // Links webViewLink?: string webContentLink?: string + iconLink?: string + thumbnailLink?: string + exportLinks?: Record + + // Size & Storage size?: string - createdTime?: string - modifiedTime?: string + quotaBytesUsed?: string + + // Checksums + md5Checksum?: string + sha1Checksum?: string + sha256Checksum?: string + + // Hierarchy & Location parents?: string[] + spaces?: string[] + driveId?: string + teamDriveId?: string + + // Capabilities + capabilities?: GoogleDriveCapabilities + + // Versions + version?: string + headRevisionId?: string + + // Media Metadata + hasThumbnail?: boolean + thumbnailVersion?: string + imageMediaMetadata?: GoogleDriveImageMediaMetadata + videoMediaMetadata?: GoogleDriveVideoMediaMetadata + contentHints?: GoogleDriveContentHints + + // Other + isAppAuthorized?: boolean + contentRestrictions?: GoogleDriveContentRestriction[] + resourceKey?: string + shortcutDetails?: GoogleDriveShortcutDetails + linkShareMetadata?: GoogleDriveLinkShareMetadata + + // Revisions (fetched separately but included in response) + revisions?: GoogleDriveRevision[] } export interface GoogleDriveListResponse extends ToolResponse { @@ -40,6 +307,7 @@ export interface GoogleDriveDownloadResponse extends ToolResponse { data: Buffer size: number } + metadata: GoogleDriveFile } } @@ -56,6 +324,7 @@ export interface GoogleDriveToolParams { pageSize?: number pageToken?: string exportMimeType?: string + includeRevisions?: boolean } export type GoogleDriveResponse = diff --git a/apps/sim/tools/google_drive/upload.ts b/apps/sim/tools/google_drive/upload.ts index 5d8f0c6747..41d80b2f44 100644 --- a/apps/sim/tools/google_drive/upload.ts +++ b/apps/sim/tools/google_drive/upload.ts @@ -9,10 +9,87 @@ import type { ToolConfig } from '@/tools/types' const logger = createLogger('GoogleDriveUploadTool') +// All available file metadata fields from Google Drive API v3 +const ALL_FILE_FIELDS = [ + // Basic Info + 'id', + 'name', + 'mimeType', + 'kind', + 'description', + 'originalFilename', + 'fullFileExtension', + 'fileExtension', + // Ownership & Sharing + 'owners', + 'permissions', + 'permissionIds', + 'shared', + 'ownedByMe', + 'writersCanShare', + 'viewersCanCopyContent', + 'copyRequiresWriterPermission', + 'sharingUser', + // Labels/Tags + 'starred', + 'trashed', + 'explicitlyTrashed', + 'properties', + 'appProperties', + 'folderColorRgb', + // Timestamps + 'createdTime', + 'modifiedTime', + 'modifiedByMeTime', + 'viewedByMeTime', + 'sharedWithMeTime', + 'trashedTime', + // User Info + 'lastModifyingUser', + 'trashingUser', + 'viewedByMe', + 'modifiedByMe', + // Links + 'webViewLink', + 'webContentLink', + 'iconLink', + 'thumbnailLink', + 'exportLinks', + // Size & Storage + 'size', + 'quotaBytesUsed', + // Checksums + 'md5Checksum', + 'sha1Checksum', + 'sha256Checksum', + // Hierarchy & Location + 'parents', + 'spaces', + 'driveId', + 'teamDriveId', + // Capabilities + 'capabilities', + // Versions + 'version', + 'headRevisionId', + // Media Metadata + 'hasThumbnail', + 'thumbnailVersion', + 'imageMediaMetadata', + 'videoMediaMetadata', + 'contentHints', + // Other + 'isAppAuthorized', + 'contentRestrictions', + 'resourceKey', + 'shortcutDetails', + 'linkShareMetadata', +].join(',') + export const uploadTool: ToolConfig = { id: 'google_drive_upload', name: 'Upload to Google Drive', - description: 'Upload a file to Google Drive', + description: 'Upload a file to Google Drive with complete metadata returned', version: '1.0', oauth: { @@ -228,8 +305,9 @@ export const uploadTool: ToolConfig Date: Fri, 9 Jan 2026 14:53:04 -0800 Subject: [PATCH 2/9] added tag dropdown support --- apps/sim/tools/google_drive/create_folder.ts | 15 +++- apps/sim/tools/google_drive/download.ts | 92 +++++++++++++++++++- apps/sim/tools/google_drive/get_content.ts | 78 ++++++++++++++++- apps/sim/tools/google_drive/list.ts | 82 ++++++++++++++++- apps/sim/tools/google_drive/upload.ts | 76 +++++++++++++++- 5 files changed, 328 insertions(+), 15 deletions(-) diff --git a/apps/sim/tools/google_drive/create_folder.ts b/apps/sim/tools/google_drive/create_folder.ts index 6fb03f4b4f..c543a2ea41 100644 --- a/apps/sim/tools/google_drive/create_folder.ts +++ b/apps/sim/tools/google_drive/create_folder.ts @@ -93,8 +93,19 @@ export const createFolderTool: ToolConfig Date: Fri, 9 Jan 2026 15:28:44 -0800 Subject: [PATCH 3/9] fixed greptile --- apps/sim/tools/google_drive/create_folder.ts | 190 +++++++++++++++++-- apps/sim/tools/google_drive/list.ts | 1 + 2 files changed, 173 insertions(+), 18 deletions(-) diff --git a/apps/sim/tools/google_drive/create_folder.ts b/apps/sim/tools/google_drive/create_folder.ts index c543a2ea41..e58ec8035b 100644 --- a/apps/sim/tools/google_drive/create_folder.ts +++ b/apps/sim/tools/google_drive/create_folder.ts @@ -1,10 +1,90 @@ +import { createLogger } from '@sim/logger' import type { GoogleDriveToolParams, GoogleDriveUploadResponse } from '@/tools/google_drive/types' import type { ToolConfig } from '@/tools/types' +const logger = createLogger('GoogleDriveCreateFolderTool') + +// All available file metadata fields from Google Drive API v3 +const ALL_FILE_FIELDS = [ + // Basic Info + 'id', + 'name', + 'mimeType', + 'kind', + 'description', + 'originalFilename', + 'fullFileExtension', + 'fileExtension', + // Ownership & Sharing + 'owners', + 'permissions', + 'permissionIds', + 'shared', + 'ownedByMe', + 'writersCanShare', + 'viewersCanCopyContent', + 'copyRequiresWriterPermission', + 'sharingUser', + // Labels/Tags + 'starred', + 'trashed', + 'explicitlyTrashed', + 'properties', + 'appProperties', + 'folderColorRgb', + // Timestamps + 'createdTime', + 'modifiedTime', + 'modifiedByMeTime', + 'viewedByMeTime', + 'sharedWithMeTime', + 'trashedTime', + // User Info + 'lastModifyingUser', + 'trashingUser', + 'viewedByMe', + 'modifiedByMe', + // Links + 'webViewLink', + 'webContentLink', + 'iconLink', + 'thumbnailLink', + 'exportLinks', + // Size & Storage + 'size', + 'quotaBytesUsed', + // Checksums + 'md5Checksum', + 'sha1Checksum', + 'sha256Checksum', + // Hierarchy & Location + 'parents', + 'spaces', + 'driveId', + 'teamDriveId', + // Capabilities + 'capabilities', + // Versions + 'version', + 'headRevisionId', + // Media Metadata + 'hasThumbnail', + 'thumbnailVersion', + 'imageMediaMetadata', + 'videoMediaMetadata', + 'contentHints', + // Other + 'isAppAuthorized', + 'contentRestrictions', + 'resourceKey', + 'shortcutDetails', + 'linkShareMetadata', +].join(',') + export const createFolderTool: ToolConfig = { id: 'google_drive_create_folder', name: 'Create Folder in Google Drive', - description: 'Create a new folder in Google Drive', + description: 'Create a new folder in Google Drive with complete metadata returned', version: '1.0', oauth: { @@ -66,27 +146,59 @@ export const createFolderTool: ToolConfig { + transformResponse: async (response: Response, params?: GoogleDriveToolParams) => { if (!response.ok) { const data = await response.json().catch(() => ({})) + logger.error('Failed to create folder in Google Drive', { + status: response.status, + statusText: response.statusText, + error: data, + }) throw new Error(data.error?.message || 'Failed to create folder in Google Drive') } + const data = await response.json() + const folderId = data.id + const authHeader = `Bearer ${params?.accessToken || ''}` + + // Fetch complete folder metadata with all fields + const metadataResponse = await fetch( + `https://www.googleapis.com/drive/v3/files/${folderId}?supportsAllDrives=true&fields=${ALL_FILE_FIELDS}`, + { + headers: { + Authorization: authHeader, + }, + } + ) + + if (!metadataResponse.ok) { + logger.warn('Failed to fetch complete metadata, returning basic response', { + status: metadataResponse.status, + statusText: metadataResponse.statusText, + }) + // Return basic response if metadata fetch fails + return { + success: true, + output: { + file: data, + }, + } + } + + const fullMetadata = await metadataResponse.json() + + logger.info('Folder created successfully', { + folderId: fullMetadata.id, + name: fullMetadata.name, + mimeType: fullMetadata.mimeType, + hasOwners: !!fullMetadata.owners?.length, + hasPermissions: !!fullMetadata.permissions?.length, + }) return { success: true, output: { - file: { - id: data.id, - name: data.name, - mimeType: data.mimeType, - webViewLink: data.webViewLink, - webContentLink: data.webContentLink, - size: data.size, - createdTime: data.createdTime, - modifiedTime: data.modifiedTime, - parents: data.parents, - }, + file: fullMetadata, }, } }, @@ -94,17 +206,59 @@ export const createFolderTool: ToolConfig Date: Fri, 9 Jan 2026 15:32:55 -0800 Subject: [PATCH 4/9] added utils func --- apps/sim/tools/google_drive/create_folder.ts | 78 +------------- apps/sim/tools/google_drive/download.ts | 102 ++----------------- apps/sim/tools/google_drive/get_content.ts | 102 ++----------------- apps/sim/tools/google_drive/list.ts | 79 +------------- apps/sim/tools/google_drive/upload.ts | 78 +------------- apps/sim/tools/google_drive/utils.ts | 95 +++++++++++++++++ 6 files changed, 110 insertions(+), 424 deletions(-) diff --git a/apps/sim/tools/google_drive/create_folder.ts b/apps/sim/tools/google_drive/create_folder.ts index e58ec8035b..6e04de4804 100644 --- a/apps/sim/tools/google_drive/create_folder.ts +++ b/apps/sim/tools/google_drive/create_folder.ts @@ -1,86 +1,10 @@ import { createLogger } from '@sim/logger' import type { GoogleDriveToolParams, GoogleDriveUploadResponse } from '@/tools/google_drive/types' +import { ALL_FILE_FIELDS } from '@/tools/google_drive/utils' import type { ToolConfig } from '@/tools/types' const logger = createLogger('GoogleDriveCreateFolderTool') -// All available file metadata fields from Google Drive API v3 -const ALL_FILE_FIELDS = [ - // Basic Info - 'id', - 'name', - 'mimeType', - 'kind', - 'description', - 'originalFilename', - 'fullFileExtension', - 'fileExtension', - // Ownership & Sharing - 'owners', - 'permissions', - 'permissionIds', - 'shared', - 'ownedByMe', - 'writersCanShare', - 'viewersCanCopyContent', - 'copyRequiresWriterPermission', - 'sharingUser', - // Labels/Tags - 'starred', - 'trashed', - 'explicitlyTrashed', - 'properties', - 'appProperties', - 'folderColorRgb', - // Timestamps - 'createdTime', - 'modifiedTime', - 'modifiedByMeTime', - 'viewedByMeTime', - 'sharedWithMeTime', - 'trashedTime', - // User Info - 'lastModifyingUser', - 'trashingUser', - 'viewedByMe', - 'modifiedByMe', - // Links - 'webViewLink', - 'webContentLink', - 'iconLink', - 'thumbnailLink', - 'exportLinks', - // Size & Storage - 'size', - 'quotaBytesUsed', - // Checksums - 'md5Checksum', - 'sha1Checksum', - 'sha256Checksum', - // Hierarchy & Location - 'parents', - 'spaces', - 'driveId', - 'teamDriveId', - // Capabilities - 'capabilities', - // Versions - 'version', - 'headRevisionId', - // Media Metadata - 'hasThumbnail', - 'thumbnailVersion', - 'imageMediaMetadata', - 'videoMediaMetadata', - 'contentHints', - // Other - 'isAppAuthorized', - 'contentRestrictions', - 'resourceKey', - 'shortcutDetails', - 'linkShareMetadata', -].join(',') - export const createFolderTool: ToolConfig = { id: 'google_drive_create_folder', name: 'Create Folder in Google Drive', diff --git a/apps/sim/tools/google_drive/download.ts b/apps/sim/tools/google_drive/download.ts index ac78f5c9e7..6c6c73c060 100644 --- a/apps/sim/tools/google_drive/download.ts +++ b/apps/sim/tools/google_drive/download.ts @@ -5,106 +5,16 @@ import type { GoogleDriveRevision, GoogleDriveToolParams, } from '@/tools/google_drive/types' -import { DEFAULT_EXPORT_FORMATS, GOOGLE_WORKSPACE_MIME_TYPES } from '@/tools/google_drive/utils' +import { + ALL_FILE_FIELDS, + ALL_REVISION_FIELDS, + DEFAULT_EXPORT_FORMATS, + GOOGLE_WORKSPACE_MIME_TYPES, +} from '@/tools/google_drive/utils' import type { ToolConfig } from '@/tools/types' const logger = createLogger('GoogleDriveDownloadTool') -// All available file metadata fields from Google Drive API v3 -const ALL_FILE_FIELDS = [ - // Basic Info - 'id', - 'name', - 'mimeType', - 'kind', - 'description', - 'originalFilename', - 'fullFileExtension', - 'fileExtension', - // Ownership & Sharing - 'owners', - 'permissions', - 'permissionIds', - 'shared', - 'ownedByMe', - 'writersCanShare', - 'viewersCanCopyContent', - 'copyRequiresWriterPermission', - 'sharingUser', - // Labels/Tags - 'starred', - 'trashed', - 'explicitlyTrashed', - 'properties', - 'appProperties', - 'folderColorRgb', - // Timestamps - 'createdTime', - 'modifiedTime', - 'modifiedByMeTime', - 'viewedByMeTime', - 'sharedWithMeTime', - 'trashedTime', - // User Info - 'lastModifyingUser', - 'trashingUser', - 'viewedByMe', - 'modifiedByMe', - // Links - 'webViewLink', - 'webContentLink', - 'iconLink', - 'thumbnailLink', - 'exportLinks', - // Size & Storage - 'size', - 'quotaBytesUsed', - // Checksums - 'md5Checksum', - 'sha1Checksum', - 'sha256Checksum', - // Hierarchy & Location - 'parents', - 'spaces', - 'driveId', - 'teamDriveId', - // Capabilities - 'capabilities', - // Versions - 'version', - 'headRevisionId', - // Media Metadata - 'hasThumbnail', - 'thumbnailVersion', - 'imageMediaMetadata', - 'videoMediaMetadata', - 'contentHints', - // Other - 'isAppAuthorized', - 'contentRestrictions', - 'resourceKey', - 'shortcutDetails', - 'linkShareMetadata', -].join(',') - -// All revision fields -const ALL_REVISION_FIELDS = [ - 'id', - 'mimeType', - 'modifiedTime', - 'keepForever', - 'published', - 'publishAuto', - 'publishedLink', - 'publishedOutsideDomain', - 'lastModifyingUser', - 'originalFilename', - 'md5Checksum', - 'size', - 'exportLinks', - 'kind', -].join(',') - export const downloadTool: ToolConfig = { id: 'google_drive_download', name: 'Download File from Google Drive', diff --git a/apps/sim/tools/google_drive/get_content.ts b/apps/sim/tools/google_drive/get_content.ts index 17e46912a5..94e217bbf4 100644 --- a/apps/sim/tools/google_drive/get_content.ts +++ b/apps/sim/tools/google_drive/get_content.ts @@ -5,106 +5,16 @@ import type { GoogleDriveRevision, GoogleDriveToolParams, } from '@/tools/google_drive/types' -import { DEFAULT_EXPORT_FORMATS, GOOGLE_WORKSPACE_MIME_TYPES } from '@/tools/google_drive/utils' +import { + ALL_FILE_FIELDS, + ALL_REVISION_FIELDS, + DEFAULT_EXPORT_FORMATS, + GOOGLE_WORKSPACE_MIME_TYPES, +} from '@/tools/google_drive/utils' import type { ToolConfig } from '@/tools/types' const logger = createLogger('GoogleDriveGetContentTool') -// All available file metadata fields from Google Drive API v3 -const ALL_FILE_FIELDS = [ - // Basic Info - 'id', - 'name', - 'mimeType', - 'kind', - 'description', - 'originalFilename', - 'fullFileExtension', - 'fileExtension', - // Ownership & Sharing - 'owners', - 'permissions', - 'permissionIds', - 'shared', - 'ownedByMe', - 'writersCanShare', - 'viewersCanCopyContent', - 'copyRequiresWriterPermission', - 'sharingUser', - // Labels/Tags - 'starred', - 'trashed', - 'explicitlyTrashed', - 'properties', - 'appProperties', - 'folderColorRgb', - // Timestamps - 'createdTime', - 'modifiedTime', - 'modifiedByMeTime', - 'viewedByMeTime', - 'sharedWithMeTime', - 'trashedTime', - // User Info - 'lastModifyingUser', - 'trashingUser', - 'viewedByMe', - 'modifiedByMe', - // Links - 'webViewLink', - 'webContentLink', - 'iconLink', - 'thumbnailLink', - 'exportLinks', - // Size & Storage - 'size', - 'quotaBytesUsed', - // Checksums - 'md5Checksum', - 'sha1Checksum', - 'sha256Checksum', - // Hierarchy & Location - 'parents', - 'spaces', - 'driveId', - 'teamDriveId', - // Capabilities - 'capabilities', - // Versions - 'version', - 'headRevisionId', - // Media Metadata - 'hasThumbnail', - 'thumbnailVersion', - 'imageMediaMetadata', - 'videoMediaMetadata', - 'contentHints', - // Other - 'isAppAuthorized', - 'contentRestrictions', - 'resourceKey', - 'shortcutDetails', - 'linkShareMetadata', -].join(',') - -// All revision fields -const ALL_REVISION_FIELDS = [ - 'id', - 'mimeType', - 'modifiedTime', - 'keepForever', - 'published', - 'publishAuto', - 'publishedLink', - 'publishedOutsideDomain', - 'lastModifyingUser', - 'originalFilename', - 'md5Checksum', - 'size', - 'exportLinks', - 'kind', -].join(',') - export const getContentTool: ToolConfig = { id: 'google_drive_get_content', name: 'Get Content from Google Drive', diff --git a/apps/sim/tools/google_drive/list.ts b/apps/sim/tools/google_drive/list.ts index 397f16e466..fba15491c6 100644 --- a/apps/sim/tools/google_drive/list.ts +++ b/apps/sim/tools/google_drive/list.ts @@ -1,84 +1,7 @@ import type { GoogleDriveListResponse, GoogleDriveToolParams } from '@/tools/google_drive/types' +import { ALL_FILE_FIELDS } from '@/tools/google_drive/utils' import type { ToolConfig } from '@/tools/types' -// All available file metadata fields from Google Drive API v3 -// Note: For list operations, some nested fields may not be available depending on permissions -const ALL_FILE_FIELDS = [ - // Basic Info - 'id', - 'name', - 'mimeType', - 'kind', - 'description', - 'originalFilename', - 'fullFileExtension', - 'fileExtension', - // Ownership & Sharing - 'owners', - 'permissions', - 'permissionIds', - 'shared', - 'ownedByMe', - 'writersCanShare', - 'viewersCanCopyContent', - 'copyRequiresWriterPermission', - 'sharingUser', - // Labels/Tags - 'starred', - 'trashed', - 'explicitlyTrashed', - 'properties', - 'appProperties', - 'folderColorRgb', - // Timestamps - 'createdTime', - 'modifiedTime', - 'modifiedByMeTime', - 'viewedByMeTime', - 'sharedWithMeTime', - 'trashedTime', - // User Info - 'lastModifyingUser', - 'trashingUser', - 'viewedByMe', - 'modifiedByMe', - // Links - 'webViewLink', - 'webContentLink', - 'iconLink', - 'thumbnailLink', - 'exportLinks', - // Size & Storage - 'size', - 'quotaBytesUsed', - // Checksums - 'md5Checksum', - 'sha1Checksum', - 'sha256Checksum', - // Hierarchy & Location - 'parents', - 'spaces', - 'driveId', - 'teamDriveId', - // Capabilities - 'capabilities', - // Versions - 'version', - 'headRevisionId', - // Media Metadata - 'hasThumbnail', - 'thumbnailVersion', - 'imageMediaMetadata', - 'videoMediaMetadata', - 'contentHints', - // Other - 'isAppAuthorized', - 'contentRestrictions', - 'resourceKey', - 'shortcutDetails', - 'linkShareMetadata', -].join(',') - export const listTool: ToolConfig = { id: 'google_drive_list', name: 'List Google Drive Files', diff --git a/apps/sim/tools/google_drive/upload.ts b/apps/sim/tools/google_drive/upload.ts index dd9a982df9..4dbc6d62f3 100644 --- a/apps/sim/tools/google_drive/upload.ts +++ b/apps/sim/tools/google_drive/upload.ts @@ -1,6 +1,7 @@ import { createLogger } from '@sim/logger' import type { GoogleDriveToolParams, GoogleDriveUploadResponse } from '@/tools/google_drive/types' import { + ALL_FILE_FIELDS, GOOGLE_WORKSPACE_MIME_TYPES, handleSheetsFormat, SOURCE_MIME_TYPES, @@ -9,83 +10,6 @@ import type { ToolConfig } from '@/tools/types' const logger = createLogger('GoogleDriveUploadTool') -// All available file metadata fields from Google Drive API v3 -const ALL_FILE_FIELDS = [ - // Basic Info - 'id', - 'name', - 'mimeType', - 'kind', - 'description', - 'originalFilename', - 'fullFileExtension', - 'fileExtension', - // Ownership & Sharing - 'owners', - 'permissions', - 'permissionIds', - 'shared', - 'ownedByMe', - 'writersCanShare', - 'viewersCanCopyContent', - 'copyRequiresWriterPermission', - 'sharingUser', - // Labels/Tags - 'starred', - 'trashed', - 'explicitlyTrashed', - 'properties', - 'appProperties', - 'folderColorRgb', - // Timestamps - 'createdTime', - 'modifiedTime', - 'modifiedByMeTime', - 'viewedByMeTime', - 'sharedWithMeTime', - 'trashedTime', - // User Info - 'lastModifyingUser', - 'trashingUser', - 'viewedByMe', - 'modifiedByMe', - // Links - 'webViewLink', - 'webContentLink', - 'iconLink', - 'thumbnailLink', - 'exportLinks', - // Size & Storage - 'size', - 'quotaBytesUsed', - // Checksums - 'md5Checksum', - 'sha1Checksum', - 'sha256Checksum', - // Hierarchy & Location - 'parents', - 'spaces', - 'driveId', - 'teamDriveId', - // Capabilities - 'capabilities', - // Versions - 'version', - 'headRevisionId', - // Media Metadata - 'hasThumbnail', - 'thumbnailVersion', - 'imageMediaMetadata', - 'videoMediaMetadata', - 'contentHints', - // Other - 'isAppAuthorized', - 'contentRestrictions', - 'resourceKey', - 'shortcutDetails', - 'linkShareMetadata', -].join(',') - export const uploadTool: ToolConfig = { id: 'google_drive_upload', name: 'Upload to Google Drive', diff --git a/apps/sim/tools/google_drive/utils.ts b/apps/sim/tools/google_drive/utils.ts index 98f9c66027..15abfc35a4 100644 --- a/apps/sim/tools/google_drive/utils.ts +++ b/apps/sim/tools/google_drive/utils.ts @@ -1,3 +1,98 @@ +// All available file metadata fields from Google Drive API v3 +export const ALL_FILE_FIELDS = [ + // Basic Info + 'id', + 'name', + 'mimeType', + 'kind', + 'description', + 'originalFilename', + 'fullFileExtension', + 'fileExtension', + // Ownership & Sharing + 'owners', + 'permissions', + 'permissionIds', + 'shared', + 'ownedByMe', + 'writersCanShare', + 'viewersCanCopyContent', + 'copyRequiresWriterPermission', + 'sharingUser', + // Labels/Tags + 'starred', + 'trashed', + 'explicitlyTrashed', + 'properties', + 'appProperties', + 'folderColorRgb', + // Timestamps + 'createdTime', + 'modifiedTime', + 'modifiedByMeTime', + 'viewedByMeTime', + 'sharedWithMeTime', + 'trashedTime', + // User Info + 'lastModifyingUser', + 'trashingUser', + 'viewedByMe', + 'modifiedByMe', + // Links + 'webViewLink', + 'webContentLink', + 'iconLink', + 'thumbnailLink', + 'exportLinks', + // Size & Storage + 'size', + 'quotaBytesUsed', + // Checksums + 'md5Checksum', + 'sha1Checksum', + 'sha256Checksum', + // Hierarchy & Location + 'parents', + 'spaces', + 'driveId', + 'teamDriveId', + // Capabilities + 'capabilities', + // Versions + 'version', + 'headRevisionId', + // Media Metadata + 'hasThumbnail', + 'thumbnailVersion', + 'imageMediaMetadata', + 'videoMediaMetadata', + 'contentHints', + // Other + 'isAppAuthorized', + 'contentRestrictions', + 'resourceKey', + 'shortcutDetails', + 'linkShareMetadata', +].join(',') + +// All revision fields from Google Drive API v3 +export const ALL_REVISION_FIELDS = [ + 'id', + 'mimeType', + 'modifiedTime', + 'keepForever', + 'published', + 'publishAuto', + 'publishedLink', + 'publishedOutsideDomain', + 'lastModifyingUser', + 'originalFilename', + 'md5Checksum', + 'size', + 'exportLinks', + 'kind', +].join(',') + export const GOOGLE_WORKSPACE_MIME_TYPES = [ 'application/vnd.google-apps.document', // Google Docs 'application/vnd.google-apps.spreadsheet', // Google Sheets From ac008f6bac2a4868f378e88d919a396af2b113e4 Mon Sep 17 00:00:00 2001 From: aadamgough Date: Fri, 9 Jan 2026 15:36:04 -0800 Subject: [PATCH 5/9] removed comments --- apps/sim/tools/google_drive/download.ts | 1 - apps/sim/tools/google_drive/get_content.ts | 1 - apps/sim/tools/google_drive/upload.ts | 9 --------- 3 files changed, 11 deletions(-) diff --git a/apps/sim/tools/google_drive/download.ts b/apps/sim/tools/google_drive/download.ts index 6c6c73c060..092a0528b7 100644 --- a/apps/sim/tools/google_drive/download.ts +++ b/apps/sim/tools/google_drive/download.ts @@ -149,7 +149,6 @@ export const downloadTool: ToolConfig Date: Fri, 9 Jan 2026 15:41:25 -0800 Subject: [PATCH 6/9] updated docs --- .../docs/content/docs/en/tools/google_drive.mdx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/docs/content/docs/en/tools/google_drive.mdx b/apps/docs/content/docs/en/tools/google_drive.mdx index 27de721e6e..54b3ed3bc3 100644 --- a/apps/docs/content/docs/en/tools/google_drive.mdx +++ b/apps/docs/content/docs/en/tools/google_drive.mdx @@ -48,7 +48,7 @@ Integrate Google Drive into the workflow. Can create, upload, and list files. ### `google_drive_upload` -Upload a file to Google Drive +Upload a file to Google Drive with complete metadata returned #### Input @@ -65,11 +65,11 @@ Upload a file to Google Drive | Parameter | Type | Description | | --------- | ---- | ----------- | -| `file` | json | Uploaded file metadata including ID, name, and links | +| `file` | object | Complete uploaded file metadata from Google Drive | ### `google_drive_create_folder` -Create a new folder in Google Drive +Create a new folder in Google Drive with complete metadata returned #### Input @@ -83,11 +83,11 @@ Create a new folder in Google Drive | Parameter | Type | Description | | --------- | ---- | ----------- | -| `file` | json | Created folder metadata including ID, name, and parent information | +| `file` | object | Complete created folder metadata from Google Drive | ### `google_drive_download` -Download a file from Google Drive (exports Google Workspace files automatically) +Download a file from Google Drive with complete metadata (exports Google Workspace files automatically) #### Input @@ -96,16 +96,17 @@ Download a file from Google Drive (exports Google Workspace files automatically) | `fileId` | string | Yes | The ID of the file to download | | `mimeType` | string | No | The MIME type to export Google Workspace files to \(optional\) | | `fileName` | string | No | Optional filename override | +| `includeRevisions` | boolean | No | Whether to include revision history in the metadata \(default: true\) | #### Output | Parameter | Type | Description | | --------- | ---- | ----------- | -| `file` | file | Downloaded file stored in execution files | +| `file` | object | Downloaded file stored in execution files | ### `google_drive_list` -List files and folders in Google Drive +List files and folders in Google Drive with complete metadata #### Input @@ -121,7 +122,7 @@ List files and folders in Google Drive | Parameter | Type | Description | | --------- | ---- | ----------- | -| `files` | json | Array of file metadata objects from the specified folder | +| `files` | array | Array of file metadata objects from Google Drive | From 2ca6f6e78c545632a162bd66bd7bbaff6fa0f8f5 Mon Sep 17 00:00:00 2001 From: aadamgough Date: Fri, 9 Jan 2026 16:24:25 -0800 Subject: [PATCH 7/9] greptile comments --- apps/sim/tools/google_drive/download.ts | 7 ++++++- apps/sim/tools/google_drive/get_content.ts | 7 ++++++- apps/sim/tools/google_drive/list.ts | 10 ++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apps/sim/tools/google_drive/download.ts b/apps/sim/tools/google_drive/download.ts index 092a0528b7..91b61cfd67 100644 --- a/apps/sim/tools/google_drive/download.ts +++ b/apps/sim/tools/google_drive/download.ts @@ -150,7 +150,8 @@ export const downloadTool: ToolConfig + value.replace(/\\/g, '\\\\').replace(/'/g, "\\'") + // Build the query conditions const conditions = ['trashed = false'] // Always exclude trashed files const folderId = params.folderId || params.folderSelector if (folderId) { - conditions.push(`'${folderId}' in parents`) + const escapedFolderId = escapeQueryValue(folderId) + conditions.push(`'${escapedFolderId}' in parents`) } // Combine all conditions with AND @@ -74,7 +79,8 @@ export const listTool: ToolConfig Date: Fri, 9 Jan 2026 16:43:16 -0800 Subject: [PATCH 8/9] fixed output schema --- apps/sim/tools/google_drive/download.ts | 17 +++++++++-------- apps/sim/tools/google_drive/get_content.ts | 8 ++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/sim/tools/google_drive/download.ts b/apps/sim/tools/google_drive/download.ts index 91b61cfd67..3fbb0d379e 100644 --- a/apps/sim/tools/google_drive/download.ts +++ b/apps/sim/tools/google_drive/download.ts @@ -56,7 +56,8 @@ export const downloadTool: ToolConfig Date: Fri, 9 Jan 2026 16:51:12 -0800 Subject: [PATCH 9/9] reverted back to bas64 string --- apps/sim/tools/google_drive/download.ts | 6 ++++-- apps/sim/tools/google_drive/types.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/sim/tools/google_drive/download.ts b/apps/sim/tools/google_drive/download.ts index 3fbb0d379e..db58ac3d88 100644 --- a/apps/sim/tools/google_drive/download.ts +++ b/apps/sim/tools/google_drive/download.ts @@ -199,13 +199,15 @@ export const downloadTool: ToolConfig