Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 46 additions & 36 deletions apps/sim/blocks/blocks/google_drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
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' },
Expand Down Expand Up @@ -126,43 +127,48 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
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',
Expand Down Expand Up @@ -305,6 +311,7 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
],
tools: {
access: [
'google_drive_get_content',
'google_drive_upload',
'google_drive_create_folder',
'google_drive_download',
Expand All @@ -313,6 +320,8 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
config: {
tool: (params) => {
switch (params.operation) {
case 'get_content':
return 'google_drive_get_content'
case 'create_file':
case 'upload':
return 'google_drive_upload'
Expand Down Expand Up @@ -357,6 +366,7 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
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)' },
Expand Down
51 changes: 49 additions & 2 deletions apps/sim/blocks/blocks/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const NotionBlock: BlockConfig<NotionResponse> = {
{ 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' },
Expand Down Expand Up @@ -116,6 +117,36 @@ export const NotionBlock: BlockConfig<NotionResponse> = {
},
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',
Expand Down Expand Up @@ -212,6 +243,8 @@ export const NotionBlock: BlockConfig<NotionResponse> = {
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':
Expand All @@ -223,12 +256,24 @@ export const NotionBlock: BlockConfig<NotionResponse> = {
}
},
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 {
Expand Down Expand Up @@ -267,6 +312,8 @@ export const NotionBlock: BlockConfig<NotionResponse> = {
return {
...rest,
credential,
...(parentId ? { parentId } : {}),
...(parentType ? { parentType } : {}),
...(parsedProperties ? { properties: parsedProperties } : {}),
...(parsedFilter ? { filter: JSON.stringify(parsedFilter) } : {}),
...(parsedSorts ? { sorts: JSON.stringify(parsedSorts) } : {}),
Expand Down
12 changes: 9 additions & 3 deletions apps/sim/tools/notion/create_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ export const notionCreatePageTool: ToolConfig<NotionCreatePageParams, NotionResp
type: 'string',
required: true,
visibility: 'user-only',
description: 'ID of the parent page',
description: 'ID of the parent page or database',
},
parentType: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Type of parent: "page_id" or "database_id"',
},
title: {
type: 'string',
Expand Down Expand Up @@ -63,8 +69,8 @@ export const notionCreatePageTool: ToolConfig<NotionCreatePageParams, NotionResp
// Prepare the body for page parent
const body: any = {
parent: {
type: 'page_id',
page_id: formattedParentId,
type: params.parentType,
[params.parentType]: formattedParentId,
},
}

Expand Down
1 change: 1 addition & 0 deletions apps/sim/tools/notion/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface NotionWriteParams {

export interface NotionCreatePageParams {
parentId: string
parentType: 'page_id' | 'database_id'
title?: string
content?: string
accessToken: string
Expand Down