Skip to content

Commit 08012e9

Browse files
committed
fix(blocks): output conditions match what each operation's tool returns
1 parent 579c7cc commit 08012e9

7 files changed

Lines changed: 119 additions & 23 deletions

File tree

‎apps/docs/content/docs/integrations/notion.mdx‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ Append new block children (content) to a Notion page or block
351351
| `total_results` | number | Number of results returned |
352352
| `properties` | json | Database properties schema |
353353
| `appended` | boolean | Whether content was successfully appended |
354-
| `type` | string | Block type |
354+
| `type` | string | Block type, or user type \(person or bot\) |
355355
| `block` | json | The full Notion block object |
356356
| `has_children` | boolean | Whether the block has nested blocks |
357357
| `archived` | boolean | Whether the block is archived |
@@ -391,7 +391,7 @@ Retrieve a single Notion block by its UUID, including its type-specific content
391391
| `total_results` | number | Number of results returned |
392392
| `properties` | json | Database properties schema |
393393
| `appended` | boolean | Whether content was successfully appended |
394-
| `type` | string | Block type |
394+
| `type` | string | Block type, or user type \(person or bot\) |
395395
| `block` | json | The full Notion block object |
396396
| `has_children` | boolean | Whether the block has nested blocks |
397397
| `archived` | boolean | Whether the block is archived |
@@ -433,7 +433,7 @@ Retrieve the block children (content) of a Notion page or block
433433
| `total_results` | number | Number of results returned |
434434
| `properties` | json | Database properties schema |
435435
| `appended` | boolean | Whether content was successfully appended |
436-
| `type` | string | Block type |
436+
| `type` | string | Block type, or user type \(person or bot\) |
437437
| `block` | json | The full Notion block object |
438438
| `has_children` | boolean | Whether the block has nested blocks |
439439
| `archived` | boolean | Whether the block is archived |
@@ -475,7 +475,7 @@ Update the content or archived state of a single Notion block
475475
| `total_results` | number | Number of results returned |
476476
| `properties` | json | Database properties schema |
477477
| `appended` | boolean | Whether content was successfully appended |
478-
| `type` | string | Block type |
478+
| `type` | string | Block type, or user type \(person or bot\) |
479479
| `block` | json | The full Notion block object |
480480
| `has_children` | boolean | Whether the block has nested blocks |
481481
| `archived` | boolean | Whether the block is archived |
@@ -515,7 +515,7 @@ Delete (move to trash) a single Notion block
515515
| `total_results` | number | Number of results returned |
516516
| `properties` | json | Database properties schema |
517517
| `appended` | boolean | Whether content was successfully appended |
518-
| `type` | string | Block type |
518+
| `type` | string | Block type, or user type \(person or bot\) |
519519
| `block` | json | The full Notion block object |
520520
| `has_children` | boolean | Whether the block has nested blocks |
521521
| `archived` | boolean | Whether the block is archived |
@@ -557,7 +557,7 @@ Create a comment on a Notion page or within an existing discussion thread
557557
| `total_results` | number | Number of results returned |
558558
| `properties` | json | Database properties schema |
559559
| `appended` | boolean | Whether content was successfully appended |
560-
| `type` | string | Block type |
560+
| `type` | string | Block type, or user type \(person or bot\) |
561561
| `block` | json | The full Notion block object |
562562
| `has_children` | boolean | Whether the block has nested blocks |
563563
| `archived` | boolean | Whether the block is archived |
@@ -599,7 +599,7 @@ List unresolved comments on a Notion page or block
599599
| `total_results` | number | Number of results returned |
600600
| `properties` | json | Database properties schema |
601601
| `appended` | boolean | Whether content was successfully appended |
602-
| `type` | string | Block type |
602+
| `type` | string | Block type, or user type \(person or bot\) |
603603
| `block` | json | The full Notion block object |
604604
| `has_children` | boolean | Whether the block has nested blocks |
605605
| `archived` | boolean | Whether the block is archived |
@@ -640,7 +640,7 @@ List all users (members and bots) in the Notion workspace
640640
| `total_results` | number | Number of results returned |
641641
| `properties` | json | Database properties schema |
642642
| `appended` | boolean | Whether content was successfully appended |
643-
| `type` | string | Block type |
643+
| `type` | string | Block type, or user type \(person or bot\) |
644644
| `block` | json | The full Notion block object |
645645
| `has_children` | boolean | Whether the block has nested blocks |
646646
| `archived` | boolean | Whether the block is archived |
@@ -680,7 +680,7 @@ Retrieve a single Notion user by their UUID
680680
| `total_results` | number | Number of results returned |
681681
| `properties` | json | Database properties schema |
682682
| `appended` | boolean | Whether content was successfully appended |
683-
| `type` | string | Block type |
683+
| `type` | string | Block type, or user type \(person or bot\) |
684684
| `block` | json | The full Notion block object |
685685
| `has_children` | boolean | Whether the block has nested blocks |
686686
| `archived` | boolean | Whether the block is archived |

‎apps/sim/blocks/blocks.test.ts‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import { describe, expect, it, vi } from 'vitest'
22

33
vi.unmock('@/blocks/registry')
4+
vi.unmock('@/tools/metadata-outputs')
45

56
import { evaluateSubBlockCondition } from '@sim/workflow-code/catalog/canonical-index'
67
import { getAllBlocks, getBlock } from '@/blocks/registry'
8+
import type { OutputCondition } from '@/blocks/types'
9+
import { getToolOutputsMetadata } from '@/tools/metadata-outputs'
10+
11+
/** Whether an output condition's own clause on `operation` admits `operation`. */
12+
function operationClauseAdmits(condition: OutputCondition, operation: string): boolean {
13+
const matches = Array.isArray(condition.value)
14+
? condition.value.includes(operation)
15+
: condition.value === operation
16+
return condition.not ? !matches : matches
17+
}
718

819
describe.concurrent('Blocks Module', () => {
920
describe('Agent block', () => {
@@ -484,4 +495,48 @@ describe.concurrent('Blocks Module', () => {
484495
}
485496
})
486497
})
498+
499+
describe('Output conditions', () => {
500+
it('keeps every output an operation tool returns selectable for that operation', () => {
501+
const errors: string[] = []
502+
503+
for (const block of getAllBlocks()) {
504+
const operationSubBlock = block.subBlocks.find(
505+
(subBlock) => subBlock.id === 'operation' && subBlock.type === 'dropdown'
506+
)
507+
const options = operationSubBlock?.options
508+
const selectTool = block.tools.config?.tool
509+
if (!Array.isArray(options) || !selectTool || !block.outputs) continue
510+
511+
const toolByOperation = new Map<string, string>()
512+
for (const option of options) {
513+
try {
514+
toolByOperation.set(option.id, selectTool({ operation: option.id }))
515+
} catch {}
516+
}
517+
const operationsByTool = new Map<string, number>()
518+
for (const toolId of toolByOperation.values()) {
519+
operationsByTool.set(toolId, (operationsByTool.get(toolId) ?? 0) + 1)
520+
}
521+
522+
for (const [operation, toolId] of toolByOperation) {
523+
// A tool shared by several operations declares the union of their outputs.
524+
if (operationsByTool.get(toolId) !== 1) continue
525+
const toolOutputs = getToolOutputsMetadata(toolId)
526+
if (!toolOutputs) continue
527+
528+
for (const [name, output] of Object.entries(block.outputs)) {
529+
if (!output || typeof output !== 'object' || !('condition' in output)) continue
530+
const condition = output.condition
531+
if (condition?.field !== 'operation' || !Object.hasOwn(toolOutputs, name)) continue
532+
if (!operationClauseAdmits(condition, operation)) {
533+
errors.push(`${block.type}.${name} hidden for ${operation} (${toolId} returns it)`)
534+
}
535+
}
536+
}
537+
}
538+
539+
expect(errors).toEqual([])
540+
})
541+
})
487542
})

‎apps/sim/blocks/blocks/microsoft_excel.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,8 +2192,8 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`,
21922192
},
21932193
range: {
21942194
type: 'string',
2195-
description: 'Range that was read',
2196-
condition: { field: 'operation', value: 'read' },
2195+
description: 'Range that was read, cleared, or formatted',
2196+
condition: { field: 'operation', value: ['read', 'clear_range', 'format_range'] },
21972197
},
21982198
values: {
21992199
type: 'json',

‎apps/sim/blocks/blocks/notion.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,11 @@ export const NotionBlock: BlockConfig = {
882882
},
883883
type: {
884884
type: 'string',
885-
description: 'Block type',
886-
condition: { field: 'operation', value: ['notion_retrieve_block', 'notion_update_block'] },
885+
description: 'Block type, or user type (person or bot)',
886+
condition: {
887+
field: 'operation',
888+
value: ['notion_retrieve_block', 'notion_update_block', 'notion_retrieve_user'],
889+
},
887890
},
888891
block: {
889892
type: 'json',
@@ -1165,8 +1168,11 @@ export const NotionV2Block: BlockConfig = {
11651168
// Block retrieve/update/delete outputs
11661169
type: {
11671170
type: 'string',
1168-
description: 'Block type',
1169-
condition: { field: 'operation', value: ['notion_retrieve_block', 'notion_update_block'] },
1171+
description: 'Block type, or user type (person or bot)',
1172+
condition: {
1173+
field: 'operation',
1174+
value: ['notion_retrieve_block', 'notion_update_block', 'notion_retrieve_user'],
1175+
},
11701176
},
11711177
block: {
11721178
type: 'json',

‎apps/sim/blocks/blocks/ses.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,10 +899,15 @@ export const SESBlock: BlockConfig = {
899899
messageId: {
900900
type: 'string',
901901
description:
902-
'SES message ID (send_email, send_templated_email, send_custom_verification_email)',
902+
'SES message ID (send_email, send_templated_email, send_custom_verification_email), or the message behind a suppression (get_suppressed_destination)',
903903
condition: {
904904
field: 'operation',
905-
value: ['send_email', 'send_templated_email', 'send_custom_verification_email'],
905+
value: [
906+
'send_email',
907+
'send_templated_email',
908+
'send_custom_verification_email',
909+
'get_suppressed_destination',
910+
],
906911
},
907912
},
908913
results: {

‎apps/sim/blocks/blocks/spotify.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ export const SpotifyBlock: BlockConfig = {
10761076
field: 'operation',
10771077
value: [
10781078
'spotify_search',
1079+
'spotify_get_album',
10791080
'spotify_get_tracks',
10801081
'spotify_get_album_tracks',
10811082
'spotify_get_playlist_tracks',
@@ -1092,6 +1093,8 @@ export const SpotifyBlock: BlockConfig = {
10921093
field: 'operation',
10931094
value: [
10941095
'spotify_search',
1096+
'spotify_get_album',
1097+
'spotify_get_track',
10951098
'spotify_get_artists',
10961099
'spotify_get_top_artists',
10971100
'spotify_get_followed_artists',
@@ -1518,6 +1521,12 @@ export const SpotifyBlock: BlockConfig = {
15181521
'spotify_get_top_artists',
15191522
'spotify_get_new_releases',
15201523
'spotify_get_categories',
1524+
'spotify_get_followed_artists',
1525+
'spotify_get_show_episodes',
1526+
'spotify_get_saved_shows',
1527+
'spotify_get_saved_episodes',
1528+
'spotify_get_audiobook_chapters',
1529+
'spotify_get_saved_audiobooks',
15211530
],
15221531
},
15231532
},
@@ -1537,6 +1546,12 @@ export const SpotifyBlock: BlockConfig = {
15371546
'spotify_get_top_artists',
15381547
'spotify_get_recently_played',
15391548
'spotify_get_new_releases',
1549+
'spotify_get_followed_artists',
1550+
'spotify_get_show_episodes',
1551+
'spotify_get_saved_shows',
1552+
'spotify_get_saved_episodes',
1553+
'spotify_get_audiobook_chapters',
1554+
'spotify_get_saved_audiobooks',
15401555
],
15411556
},
15421557
},

‎apps/sim/blocks/blocks/vercel.ts‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,8 +2181,11 @@ export const VercelBlock: BlockConfig = {
21812181
},
21822182
events: {
21832183
type: 'array',
2184-
description: 'Deployment build log events',
2185-
condition: { field: 'operation', value: 'get_deployment_events' },
2184+
description: 'Deployment build log events, or the events a webhook subscribes to',
2185+
condition: {
2186+
field: 'operation',
2187+
value: ['get_deployment_events', 'create_webhook', 'get_webhook'],
2188+
},
21862189
},
21872190
files: {
21882191
type: 'array',
@@ -2209,10 +2212,16 @@ export const VercelBlock: BlockConfig = {
22092212
},
22102213
url: {
22112214
type: 'string',
2212-
description: 'Deployment URL',
2215+
description: 'Deployment or webhook URL',
22132216
condition: {
22142217
field: 'operation',
2215-
value: ['get_deployment', 'create_deployment', 'cancel_deployment'],
2218+
value: [
2219+
'get_deployment',
2220+
'create_deployment',
2221+
'cancel_deployment',
2222+
'create_webhook',
2223+
'get_webhook',
2224+
],
22162225
},
22172226
},
22182227
state: {
@@ -2243,10 +2252,16 @@ export const VercelBlock: BlockConfig = {
22432252
},
22442253
verified: {
22452254
type: 'boolean',
2246-
description: 'Whether the project domain is verified',
2255+
description: 'Whether the domain is verified',
22472256
condition: {
22482257
field: 'operation',
2249-
value: ['add_project_domain', 'update_project_domain', 'verify_project_domain'],
2258+
value: [
2259+
'add_domain',
2260+
'get_domain',
2261+
'add_project_domain',
2262+
'update_project_domain',
2263+
'verify_project_domain',
2264+
],
22502265
},
22512266
},
22522267
promoted: {

0 commit comments

Comments
 (0)