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

Function collectBlockData

apps/sim/executor/utils/block-data.ts:60–102  ·  view source on GitHub ↗
(
  ctx: ExecutionContext,
  currentNodeId?: string
)

Source from the content-addressed store, hash-verified

58}
59
60export function collectBlockData(
61 ctx: ExecutionContext,
62 currentNodeId?: string
63): BlockDataCollection {
64 const blockData: Record<string, unknown> = {}
65 const blockNameMapping: Record<string, string> = {}
66 const blockOutputSchemas: Record<string, OutputSchema> = {}
67
68 const branchIndex =
69 currentNodeId && isBranchNodeId(currentNodeId) ? extractBranchIndex(currentNodeId) : null
70
71 for (const [id, state] of ctx.blockStates.entries()) {
72 if (state.output !== undefined) {
73 blockData[id] = state.output
74
75 if (branchIndex !== null && isBranchNodeId(id)) {
76 const stateBranchIndex = extractBranchIndex(id)
77 if (stateBranchIndex === branchIndex) {
78 const baseId = extractBaseBlockId(id)
79 if (blockData[baseId] === undefined) {
80 blockData[baseId] = state.output
81 }
82 }
83 }
84 }
85 }
86
87 const workflowBlocks = ctx.workflow?.blocks ?? []
88 for (const block of workflowBlocks) {
89 const id = block.id
90
91 if (block.metadata?.name) {
92 blockNameMapping[normalizeName(block.metadata.name)] = id
93 }
94
95 const schema = getBlockSchema(block)
96 if (schema && Object.keys(schema).length > 0) {
97 blockOutputSchemas[id] = schema
98 }
99 }
100
101 return { blockData, blockNameMapping, blockOutputSchemas }
102}

Callers 5

executeMethod · 0.90
buildProviderRequestMethod · 0.90

Calls 5

isBranchNodeIdFunction · 0.90
extractBranchIndexFunction · 0.90
extractBaseBlockIdFunction · 0.90
normalizeNameFunction · 0.90
getBlockSchemaFunction · 0.85

Tested by

no test coverage detected