Skip to content
Merged
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
18 changes: 9 additions & 9 deletions apps/docs/content/docs/integrations/notion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down
55 changes: 55 additions & 0 deletions apps/sim/blocks/blocks.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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<string, string>()
for (const option of options) {
try {
toolByOperation.set(option.id, selectTool({ operation: option.id }))
} catch {}
}
const operationsByTool = new Map<string, number>()
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([])
})
})
})
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/microsoft_excel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 10 additions & 4 deletions apps/sim/blocks/blocks/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
9 changes: 7 additions & 2 deletions apps/sim/blocks/blocks/ses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
15 changes: 15 additions & 0 deletions apps/sim/blocks/blocks/spotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
],
},
},
Expand All @@ -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',
],
},
},
Expand Down
27 changes: 21 additions & 6 deletions apps/sim/blocks/blocks/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
Loading