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

Method getBlockOutput

apps/sim/executor/execution/state.ts:68–113  ·  view source on GitHub ↗
(blockId: string, currentNodeId?: string)

Source from the content-addressed store, hash-verified

66 }
67
68 getBlockOutput(blockId: string, currentNodeId?: string): NormalizedBlockOutput | undefined {
69 const normalizedId = normalizeLookupId(blockId)
70 if (normalizedId !== blockId) {
71 return this.blockStates.get(blockId)?.output
72 }
73
74 if (currentNodeId) {
75 const scopedOutput = this.getScopedBlockOutput(blockId, currentNodeId)
76 if (scopedOutput !== undefined) {
77 return scopedOutput
78 }
79
80 if (extractOuterBranchIndex(currentNodeId) !== undefined) {
81 return undefined
82 }
83 }
84
85 const direct = this.blockStates.get(blockId)?.output
86 if (direct !== undefined) {
87 return direct
88 }
89
90 if (currentNodeId && extractBranchSuffix(currentNodeId) === '') {
91 const stableBranchZeroOutput = this.blockStates.get(
92 buildOuterBranchScopedId(blockId, 0)
93 )?.output
94 if (stableBranchZeroOutput !== undefined) {
95 return stableBranchZeroOutput
96 }
97
98 const branchZeroOutput = this.blockStates.get(
99 `${blockId}₍0₎${extractLoopSuffix(currentNodeId)}`
100 )?.output
101 if (branchZeroOutput !== undefined) {
102 return branchZeroOutput
103 }
104 }
105
106 for (const [storedId, state] of this.blockStates.entries()) {
107 if (normalizeLookupId(storedId) === blockId) {
108 return state.output
109 }
110 }
111
112 return undefined
113 }
114
115 private getScopedBlockOutput(
116 blockId: string,

Callers

nothing calls this directly

Calls 7

getScopedBlockOutputMethod · 0.95
extractOuterBranchIndexFunction · 0.90
buildOuterBranchScopedIdFunction · 0.90
normalizeLookupIdFunction · 0.70
extractBranchSuffixFunction · 0.70
extractLoopSuffixFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected