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

Function extractInputFormatFromBlock

apps/sim/lib/execution/files.ts:121–140  ·  view source on GitHub ↗
(block: SerializedBlock)

Source from the content-addressed store, hash-verified

119type ValidatedInputFormatField = Required<Pick<InputFormatField, 'name' | 'type'>>
120
121function extractInputFormatFromBlock(block: SerializedBlock): ValidatedInputFormatField[] {
122 const metadata = block.metadata as { subBlocks?: Record<string, { value?: unknown }> } | undefined
123 const subBlocksValue = metadata?.subBlocks?.inputFormat?.value
124 const legacyValue = block.config?.params?.inputFormat
125 const inputFormatValue = subBlocksValue ?? legacyValue
126
127 if (!Array.isArray(inputFormatValue) || inputFormatValue.length === 0) {
128 return []
129 }
130
131 return inputFormatValue.filter(
132 (field): field is ValidatedInputFormatField =>
133 field &&
134 typeof field === 'object' &&
135 'name' in field &&
136 'type' in field &&
137 typeof field.name === 'string' &&
138 typeof field.type === 'string'
139 )
140}
141
142/**
143 * Process file fields in workflow input based on the start block's inputFormat

Callers 1

processInputFileFieldsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected