MCPcopy Index your code
hub / github.com/simstudioai/sim / getBlockOutputs

Function getBlockOutputs

apps/sim/lib/workflows/blocks/block-outputs.ts:255–320  ·  view source on GitHub ↗
(
  blockType: string,
  subBlocks?: Record<string, SubBlockWithValue>,
  triggerMode?: boolean,
  options?: { includeHidden?: boolean }
)

Source from the content-addressed store, hash-verified

253}
254
255export function getBlockOutputs(
256 blockType: string,
257 subBlocks?: Record<string, SubBlockWithValue>,
258 triggerMode?: boolean,
259 options?: { includeHidden?: boolean }
260): OutputDefinition {
261 const includeHidden = options?.includeHidden ?? false
262 const blockConfig = getBlock(blockType)
263 if (!blockConfig) return {}
264
265 if (triggerMode && blockConfig.triggers?.enabled) {
266 const triggerId = getTriggerId(subBlocks, blockConfig)
267 if (triggerId && isTriggerValid(triggerId)) {
268 const trigger = getTrigger(triggerId)
269 if (trigger.outputs) {
270 // TriggerOutput is compatible with OutputFieldDefinition at runtime.
271 // Conditions narrow outputs to the selected trigger configuration
272 // (e.g. the Sim trigger only surfaces execution fields for
273 // execution-backed event types).
274 return filterOutputsByCondition(
275 trigger.outputs as OutputDefinition,
276 subBlocks,
277 includeHidden
278 )
279 }
280 }
281 }
282
283 const startPath = classifyStartBlockType(blockType)
284
285 if (startPath === StartBlockPath.UNIFIED) {
286 return getUnifiedStartOutputs(subBlocks)
287 }
288
289 if (blockType === 'human_in_the_loop') {
290 // Start with block config outputs (respects hiddenFromDisplay via filterOutputsByCondition)
291 const baseOutputs = filterOutputsByCondition(
292 { ...(blockConfig.outputs || {}) } as OutputDefinition,
293 subBlocks,
294 includeHidden
295 )
296
297 // Add inputFormat fields (resume form fields)
298 const normalizedInputFormat = normalizeInputFormatValue(subBlocks?.inputFormat?.value)
299
300 for (const field of normalizedInputFormat) {
301 const fieldName = field?.name?.trim()
302 if (!fieldName) continue
303
304 baseOutputs[fieldName] = {
305 type: (field?.type || 'any') as any,
306 description: field?.description || `Field from resume form`,
307 }
308 }
309
310 return baseOutputs
311 }
312

Callers 1

getEffectiveBlockOutputsFunction · 0.85

Calls 10

getBlockFunction · 0.90
isTriggerValidFunction · 0.90
getTriggerFunction · 0.90
classifyStartBlockTypeFunction · 0.90
getTriggerIdFunction · 0.85
filterOutputsByConditionFunction · 0.85
getUnifiedStartOutputsFunction · 0.85
getLegacyStarterOutputsFunction · 0.85

Tested by

no test coverage detected