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

Method resolve

apps/sim/executor/variables/resolvers/block.ts:84–149  ·  view source on GitHub ↗
(reference: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

82 }
83
84 resolve(reference: string, context: ResolutionContext): any {
85 const parts = parseReferencePath(reference)
86 if (parts.length === 0) {
87 return undefined
88 }
89 const [blockName, ...pathParts] = parts
90
91 const blockId = this.findBlockIdByName(blockName)
92 if (!blockId) {
93 return undefined
94 }
95
96 const block = this.blockById.get(blockId)!
97 const output = this.getBlockOutput(blockId, context)
98
99 const blockData: Record<string, unknown> = {}
100 const blockOutputSchemas: Record<string, OutputSchema> = {}
101
102 if (output !== undefined) {
103 blockData[blockId] = output
104 }
105
106 const outputSchema = getBlockSchema(block)
107
108 if (outputSchema && Object.keys(outputSchema).length > 0) {
109 blockOutputSchemas[blockId] = outputSchema
110 }
111
112 try {
113 const result = resolveBlockReference(
114 blockName,
115 pathParts,
116 {
117 blockNameMapping: Object.fromEntries(this.nameToBlockId),
118 blockData,
119 blockOutputSchemas,
120 },
121 {
122 allowLargeValueRefs: context.allowLargeValueRefs,
123 executionContext: context.executionContext,
124 }
125 )!
126
127 if (result.value !== undefined) {
128 if (!context.allowLargeValueRefs) {
129 assertNoLargeValueRefs(result.value)
130 }
131 return result.value
132 }
133
134 const backwardsCompat = this.handleBackwardsCompatSync(block, output, pathParts)
135 if (backwardsCompat !== undefined) {
136 return backwardsCompat
137 }
138
139 return RESOLVED_EMPTY
140 } catch (error) {
141 if (error instanceof InvalidFieldError) {

Callers 1

resolveAsyncMethod · 0.95

Calls 8

findBlockIdByNameMethod · 0.95
getBlockOutputMethod · 0.95
parseReferencePathFunction · 0.90
getBlockSchemaFunction · 0.90
resolveBlockReferenceFunction · 0.90
assertNoLargeValueRefsFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected