diff --git a/apps/docs/content/docs/integrations/notion.mdx b/apps/docs/content/docs/integrations/notion.mdx index 6800b3a8b51..094f59e48d1 100644 --- a/apps/docs/content/docs/integrations/notion.mdx +++ b/apps/docs/content/docs/integrations/notion.mdx @@ -351,7 +351,7 @@ Append new block children (content) to a Notion page or block | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -391,7 +391,7 @@ Retrieve a single Notion block by its UUID, including its type-specific content | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -433,7 +433,7 @@ Retrieve the block children (content) of a Notion page or block | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -475,7 +475,7 @@ Update the content or archived state of a single Notion block | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -515,7 +515,7 @@ Delete (move to trash) a single Notion block | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -557,7 +557,7 @@ Create a comment on a Notion page or within an existing discussion thread | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -599,7 +599,7 @@ List unresolved comments on a Notion page or block | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -640,7 +640,7 @@ List all users (members and bots) in the Notion workspace | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | @@ -680,7 +680,7 @@ Retrieve a single Notion user by their UUID | `total_results` | number | Number of results returned | | `properties` | json | Database properties schema | | `appended` | boolean | Whether content was successfully appended | -| `type` | string | Block type | +| `type` | string | Block type, or user type \(person or bot\) | | `block` | json | The full Notion block object | | `has_children` | boolean | Whether the block has nested blocks | | `archived` | boolean | Whether the block is archived | diff --git a/apps/sim/blocks/blocks.test.ts b/apps/sim/blocks/blocks.test.ts index 9a0bddad5e4..08ac2caf784 100644 --- a/apps/sim/blocks/blocks.test.ts +++ b/apps/sim/blocks/blocks.test.ts @@ -1,9 +1,20 @@ import { describe, expect, it, vi } from 'vitest' vi.unmock('@/blocks/registry') +vi.unmock('@/tools/metadata-outputs') import { evaluateSubBlockCondition } from '@sim/workflow-code/catalog/canonical-index' import { getAllBlocks, getBlock } from '@/blocks/registry' +import type { OutputCondition } from '@/blocks/types' +import { getToolOutputsMetadata } from '@/tools/metadata-outputs' + +/** Whether an output condition's own clause on `operation` admits `operation`. */ +function operationClauseAdmits(condition: OutputCondition, operation: string): boolean { + const matches = Array.isArray(condition.value) + ? condition.value.includes(operation) + : condition.value === operation + return condition.not ? !matches : matches +} describe.concurrent('Blocks Module', () => { describe('Agent block', () => { @@ -484,4 +495,48 @@ describe.concurrent('Blocks Module', () => { } }) }) + + describe('Output conditions', () => { + it('keeps every output an operation tool returns selectable for that operation', () => { + const errors: string[] = [] + + for (const block of getAllBlocks()) { + const operationSubBlock = block.subBlocks.find( + (subBlock) => subBlock.id === 'operation' && subBlock.type === 'dropdown' + ) + const options = operationSubBlock?.options + const selectTool = block.tools.config?.tool + if (!Array.isArray(options) || !selectTool || !block.outputs) continue + + const toolByOperation = new Map() + for (const option of options) { + try { + toolByOperation.set(option.id, selectTool({ operation: option.id })) + } catch {} + } + const operationsByTool = new Map() + for (const toolId of toolByOperation.values()) { + operationsByTool.set(toolId, (operationsByTool.get(toolId) ?? 0) + 1) + } + + for (const [operation, toolId] of toolByOperation) { + // A tool shared by several operations declares the union of their outputs. + if (operationsByTool.get(toolId) !== 1) continue + const toolOutputs = getToolOutputsMetadata(toolId) + if (!toolOutputs) continue + + for (const [name, output] of Object.entries(block.outputs)) { + if (!output || typeof output !== 'object' || !('condition' in output)) continue + const condition = output.condition + if (condition?.field !== 'operation' || !Object.hasOwn(toolOutputs, name)) continue + if (!operationClauseAdmits(condition, operation)) { + errors.push(`${block.type}.${name} hidden for ${operation} (${toolId} returns it)`) + } + } + } + } + + expect(errors).toEqual([]) + }) + }) }) diff --git a/apps/sim/blocks/blocks/microsoft_excel.ts b/apps/sim/blocks/blocks/microsoft_excel.ts index 0168fc10ee8..7458594316a 100644 --- a/apps/sim/blocks/blocks/microsoft_excel.ts +++ b/apps/sim/blocks/blocks/microsoft_excel.ts @@ -2192,8 +2192,8 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`, }, range: { type: 'string', - description: 'Range that was read', - condition: { field: 'operation', value: 'read' }, + description: 'Range that was read, cleared, or formatted', + condition: { field: 'operation', value: ['read', 'clear_range', 'format_range'] }, }, values: { type: 'json', diff --git a/apps/sim/blocks/blocks/notion.ts b/apps/sim/blocks/blocks/notion.ts index d9f45810388..c80b6937efc 100644 --- a/apps/sim/blocks/blocks/notion.ts +++ b/apps/sim/blocks/blocks/notion.ts @@ -882,8 +882,11 @@ export const NotionBlock: BlockConfig = { }, type: { type: 'string', - description: 'Block type', - condition: { field: 'operation', value: ['notion_retrieve_block', 'notion_update_block'] }, + description: 'Block type, or user type (person or bot)', + condition: { + field: 'operation', + value: ['notion_retrieve_block', 'notion_update_block', 'notion_retrieve_user'], + }, }, block: { type: 'json', @@ -1165,8 +1168,11 @@ export const NotionV2Block: BlockConfig = { // Block retrieve/update/delete outputs type: { type: 'string', - description: 'Block type', - condition: { field: 'operation', value: ['notion_retrieve_block', 'notion_update_block'] }, + description: 'Block type, or user type (person or bot)', + condition: { + field: 'operation', + value: ['notion_retrieve_block', 'notion_update_block', 'notion_retrieve_user'], + }, }, block: { type: 'json', diff --git a/apps/sim/blocks/blocks/ses.ts b/apps/sim/blocks/blocks/ses.ts index ed0821fa9cc..dca849e0e92 100644 --- a/apps/sim/blocks/blocks/ses.ts +++ b/apps/sim/blocks/blocks/ses.ts @@ -899,10 +899,15 @@ export const SESBlock: BlockConfig = { messageId: { type: 'string', description: - 'SES message ID (send_email, send_templated_email, send_custom_verification_email)', + 'SES message ID (send_email, send_templated_email, send_custom_verification_email), or the message behind a suppression (get_suppressed_destination)', condition: { field: 'operation', - value: ['send_email', 'send_templated_email', 'send_custom_verification_email'], + value: [ + 'send_email', + 'send_templated_email', + 'send_custom_verification_email', + 'get_suppressed_destination', + ], }, }, results: { diff --git a/apps/sim/blocks/blocks/spotify.ts b/apps/sim/blocks/blocks/spotify.ts index 5301a8cc17b..05d51ecfbe4 100644 --- a/apps/sim/blocks/blocks/spotify.ts +++ b/apps/sim/blocks/blocks/spotify.ts @@ -1076,6 +1076,7 @@ export const SpotifyBlock: BlockConfig = { field: 'operation', value: [ 'spotify_search', + 'spotify_get_album', 'spotify_get_tracks', 'spotify_get_album_tracks', 'spotify_get_playlist_tracks', @@ -1092,6 +1093,8 @@ export const SpotifyBlock: BlockConfig = { field: 'operation', value: [ 'spotify_search', + 'spotify_get_album', + 'spotify_get_track', 'spotify_get_artists', 'spotify_get_top_artists', 'spotify_get_followed_artists', @@ -1518,6 +1521,12 @@ export const SpotifyBlock: BlockConfig = { 'spotify_get_top_artists', 'spotify_get_new_releases', 'spotify_get_categories', + 'spotify_get_followed_artists', + 'spotify_get_show_episodes', + 'spotify_get_saved_shows', + 'spotify_get_saved_episodes', + 'spotify_get_audiobook_chapters', + 'spotify_get_saved_audiobooks', ], }, }, @@ -1537,6 +1546,12 @@ export const SpotifyBlock: BlockConfig = { 'spotify_get_top_artists', 'spotify_get_recently_played', 'spotify_get_new_releases', + 'spotify_get_followed_artists', + 'spotify_get_show_episodes', + 'spotify_get_saved_shows', + 'spotify_get_saved_episodes', + 'spotify_get_audiobook_chapters', + 'spotify_get_saved_audiobooks', ], }, }, diff --git a/apps/sim/blocks/blocks/vercel.ts b/apps/sim/blocks/blocks/vercel.ts index 3081a91bb16..5723257e1e1 100644 --- a/apps/sim/blocks/blocks/vercel.ts +++ b/apps/sim/blocks/blocks/vercel.ts @@ -2181,8 +2181,11 @@ export const VercelBlock: BlockConfig = { }, events: { type: 'array', - description: 'Deployment build log events', - condition: { field: 'operation', value: 'get_deployment_events' }, + description: 'Deployment build log events, or the events a webhook subscribes to', + condition: { + field: 'operation', + value: ['get_deployment_events', 'create_webhook', 'get_webhook'], + }, }, files: { type: 'array', @@ -2209,10 +2212,16 @@ export const VercelBlock: BlockConfig = { }, url: { type: 'string', - description: 'Deployment URL', + description: 'Deployment or webhook URL', condition: { field: 'operation', - value: ['get_deployment', 'create_deployment', 'cancel_deployment'], + value: [ + 'get_deployment', + 'create_deployment', + 'cancel_deployment', + 'create_webhook', + 'get_webhook', + ], }, }, state: { @@ -2243,10 +2252,16 @@ export const VercelBlock: BlockConfig = { }, verified: { type: 'boolean', - description: 'Whether the project domain is verified', + description: 'Whether the domain is verified', condition: { field: 'operation', - value: ['add_project_domain', 'update_project_domain', 'verify_project_domain'], + value: [ + 'add_domain', + 'get_domain', + 'add_project_domain', + 'update_project_domain', + 'verify_project_domain', + ], }, }, promoted: {