diff --git a/apps/sim/blocks/blocks/google_drive.ts b/apps/sim/blocks/blocks/google_drive.ts index d109a85501..dff09b34e3 100644 --- a/apps/sim/blocks/blocks/google_drive.ts +++ b/apps/sim/blocks/blocks/google_drive.ts @@ -20,6 +20,7 @@ export const GoogleDriveBlock: BlockConfig = { title: 'Operation', type: 'dropdown', options: [ + { label: 'Get File', id: 'get_content' }, { label: 'Create Folder', id: 'create_folder' }, { label: 'Create File', id: 'create_file' }, { label: 'Upload File', id: 'upload' }, @@ -126,43 +127,48 @@ export const GoogleDriveBlock: BlockConfig = { condition: { field: 'operation', value: ['create_file', 'upload'] }, }, // Get Content Fields - // { - // id: 'fileId', - // title: 'Select File', - // type: 'file-selector', - // provider: 'google-drive', - // serviceId: 'google-drive', - // requiredScopes: [], - // placeholder: 'Select a file', - // condition: { field: 'operation', value: 'get_content' }, - // }, - // // Manual File ID input (shown only when no file is selected) - // { - // id: 'fileId', - // title: 'Or Enter File ID Manually', - // type: 'short-input', - // placeholder: 'ID of the file to get content from', - // condition: { - // field: 'operation', - // value: 'get_content', - // and: { - // field: 'fileId', - // value: '', - // }, - // }, - // }, + // Get Content Fields - File Selector (basic mode) + { + id: 'fileSelector', + title: 'Select File', + type: 'file-selector', + canonicalParamId: 'fileId', + provider: 'google-drive', + serviceId: 'google-drive', + requiredScopes: [ + 'https://www.googleapis.com/auth/drive.readonly', + 'https://www.googleapis.com/auth/drive.file', + ], + placeholder: 'Select a file to get content from', + mode: 'basic', + dependsOn: ['credential'], + condition: { field: 'operation', value: 'get_content' }, + required: true, + }, + // Manual File ID input (advanced mode) + { + id: 'manualFileId', + title: 'File ID', + type: 'short-input', + canonicalParamId: 'fileId', + placeholder: 'Enter file ID manually', + mode: 'advanced', + condition: { field: 'operation', value: 'get_content' }, + }, // Export format for Google Workspace files - // { - // id: 'mimeType', - // title: 'Export Format', - // type: 'dropdown', - // options: [ - // { label: 'Plain Text', id: 'text/plain' }, - // { label: 'HTML', id: 'text/html' }, - // ], - // placeholder: 'Optional: Choose export format for Google Workspace files', - // condition: { field: 'operation', value: 'get_content' }, - // }, + { + id: 'mimeType', + title: 'Export Format', + type: 'dropdown', + options: [ + { label: 'Plain Text', id: 'text/plain' }, + { label: 'HTML', id: 'text/html' }, + { label: 'PDF', id: 'application/pdf' }, + { label: 'Microsoft Word', id: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }, + ], + placeholder: 'Optional: Choose export format for Google Workspace files', + condition: { field: 'operation', value: 'get_content' }, + }, // Create Folder Fields { id: 'fileName', @@ -305,6 +311,7 @@ export const GoogleDriveBlock: BlockConfig = { ], tools: { access: [ + 'google_drive_get_content', 'google_drive_upload', 'google_drive_create_folder', 'google_drive_download', @@ -313,6 +320,8 @@ export const GoogleDriveBlock: BlockConfig = { config: { tool: (params) => { switch (params.operation) { + case 'get_content': + return 'google_drive_get_content' case 'create_file': case 'upload': return 'google_drive_upload' @@ -357,6 +366,7 @@ export const GoogleDriveBlock: BlockConfig = { inputs: { operation: { type: 'string', description: 'Operation to perform' }, credential: { type: 'string', description: 'Google Drive access token' }, + fileId: { type: 'string', description: 'File identifier for get_content operation' }, // Upload and Create Folder operation inputs fileName: { type: 'string', description: 'File or folder name' }, file: { type: 'json', description: 'File to upload (UserFile object)' }, diff --git a/apps/sim/blocks/blocks/notion.ts b/apps/sim/blocks/blocks/notion.ts index e7a7281c57..1286854276 100644 --- a/apps/sim/blocks/blocks/notion.ts +++ b/apps/sim/blocks/blocks/notion.ts @@ -23,6 +23,7 @@ export const NotionBlock: BlockConfig = { { label: 'Read Page', id: 'notion_read' }, { label: 'Read Database', id: 'notion_read_database' }, { label: 'Create Page', id: 'notion_create_page' }, + { label: 'Create Page in Database', id: 'notion_create_page_in_database' }, { label: 'Create Database', id: 'notion_create_database' }, { label: 'Append Content', id: 'notion_write' }, { label: 'Query Database', id: 'notion_query_database' }, @@ -116,6 +117,36 @@ export const NotionBlock: BlockConfig = { }, required: true, }, + // Create Page in Database Fields + { + id: 'databaseId', + title: 'Database ID', + type: 'short-input', + placeholder: 'Enter Notion database ID', + condition: { field: 'operation', value: 'notion_create_page_in_database' }, + required: true, + }, + { + id: 'title', + title: 'Page Title', + type: 'short-input', + placeholder: 'Title for the new page', + condition: { + field: 'operation', + value: 'notion_create_page_in_database', + }, + required: true, + }, + { + id: 'content', + title: 'Content', + type: 'long-input', + placeholder: 'Enter content to add to the page', + condition: { + field: 'operation', + value: 'notion_create_page_in_database', + }, + }, // Query Database Fields { id: 'databaseId', @@ -212,6 +243,8 @@ export const NotionBlock: BlockConfig = { return 'notion_write' case 'notion_create_page': return 'notion_create_page' + case 'notion_create_page_in_database': + return 'notion_create_page' case 'notion_query_database': return 'notion_query_database' case 'notion_search': @@ -223,12 +256,24 @@ export const NotionBlock: BlockConfig = { } }, params: (params) => { - const { credential, operation, properties, filter, sorts, ...rest } = params + const { credential, operation, properties, filter, sorts, databaseId, ...rest } = params + + // Handle different parent types for page creation + let parentId: string | undefined + let parentType: 'page_id' | 'database_id' | undefined + + if (operation === 'notion_create_page_in_database') { + parentId = databaseId + parentType = 'database_id' + } else if (operation === 'notion_create_page') { + parentId = rest.parentId + parentType = 'page_id' + } // Parse properties from JSON string for create operations let parsedProperties if ( - (operation === 'notion_create_page' || operation === 'notion_create_database') && + (operation === 'notion_create_page' || operation === 'notion_create_page_in_database' || operation === 'notion_create_database') && properties ) { try { @@ -267,6 +312,8 @@ export const NotionBlock: BlockConfig = { return { ...rest, credential, + ...(parentId ? { parentId } : {}), + ...(parentType ? { parentType } : {}), ...(parsedProperties ? { properties: parsedProperties } : {}), ...(parsedFilter ? { filter: JSON.stringify(parsedFilter) } : {}), ...(parsedSorts ? { sorts: JSON.stringify(parsedSorts) } : {}), diff --git a/apps/sim/tools/notion/create_page.ts b/apps/sim/tools/notion/create_page.ts index 0f8baf5d13..1d5df9cd11 100644 --- a/apps/sim/tools/notion/create_page.ts +++ b/apps/sim/tools/notion/create_page.ts @@ -23,7 +23,13 @@ export const notionCreatePageTool: ToolConfig