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

Function resolveBlockReference

apps/sim/executor/utils/block-reference.ts:209–249  ·  view source on GitHub ↗
(
  blockName: string,
  pathParts: string[],
  context: BlockReferenceContext,
  options: {
    allowLargeValueRefs?: boolean
    executionContext?: ResolutionContext['executionContext']
  } = {}
)

Source from the content-addressed store, hash-verified

207}
208
209export function resolveBlockReference(
210 blockName: string,
211 pathParts: string[],
212 context: BlockReferenceContext,
213 options: {
214 allowLargeValueRefs?: boolean
215 executionContext?: ResolutionContext['executionContext']
216 } = {}
217): BlockReferenceResult | undefined {
218 const normalizedName = normalizeName(blockName)
219 const blockId = context.blockNameMapping[normalizedName]
220
221 if (!blockId) {
222 return undefined
223 }
224
225 const blockOutput = context.blockData[blockId]
226
227 // When the block has not produced any output (e.g. it lives on a branched
228 // path that wasn't taken), resolve the reference to undefined without
229 // validating against the declared schema. Callers map this to an empty
230 // value so that references to skipped blocks don't fail the workflow.
231 if (blockOutput === undefined) {
232 return { value: undefined, blockId }
233 }
234
235 if (pathParts.length === 0) {
236 return { value: blockOutput, blockId }
237 }
238
239 const value = navigatePath(blockOutput, pathParts, options)
240
241 const schema = context.blockOutputSchemas?.[blockId]
242 if (value === undefined && schema) {
243 if (!isPathInSchema(schema, pathParts)) {
244 throw new InvalidFieldError(blockName, pathParts.join('.'), getSchemaFieldNames(schema))
245 }
246 }
247
248 return { value, blockId }
249}
250
251export async function resolveBlockReferenceAsync(
252 blockName: string,

Callers 3

resolveTagVariablesFunction · 0.90
resolveMethod · 0.90

Calls 5

normalizeNameFunction · 0.90
navigatePathFunction · 0.90
isPathInSchemaFunction · 0.85
getSchemaFieldNamesFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected