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

Method resolveInternal

apps/sim/executor/variables/resolvers/loop.ts:75–200  ·  view source on GitHub ↗
(
    reference: string,
    context: ResolutionContext,
    useAsyncPath: boolean
  )

Source from the content-addressed store, hash-verified

73 ): Promise<any>
74 private resolveInternal(reference: string, context: ResolutionContext, useAsyncPath: false): any
75 private resolveInternal(
76 reference: string,
77 context: ResolutionContext,
78 useAsyncPath: boolean
79 ): any | Promise<any> {
80 const parts = parseReferencePath(reference)
81 if (parts.length === 0) {
82 logger.warn('Invalid loop reference', { reference })
83 return undefined
84 }
85
86 const [firstPart, ...rest] = parts
87 const isGenericRef = firstPart === REFERENCE.PREFIX.LOOP
88
89 let targetLoopId: string | undefined
90
91 if (isGenericRef) {
92 targetLoopId = this.findInnermostLoopForBlock(context.currentNodeId)
93 if (!targetLoopId && !context.loopScope) {
94 return undefined
95 }
96 } else {
97 targetLoopId = this.loopNameToId.get(firstPart)
98 if (!targetLoopId) {
99 return undefined
100 }
101 }
102
103 // Resolve the effective (possibly cloned) loop ID for scope/output lookups
104 if (targetLoopId && context.executionContext.loopExecutions) {
105 const mappedBranchIndex =
106 (isGenericRef
107 ? extractInnermostOuterBranchIndex(context.currentNodeId)
108 : extractOuterBranchIndex(context.currentNodeId)) ??
109 context.executionContext.parallelBlockMapping?.get(context.currentNodeId)?.iterationIndex
110 targetLoopId = findEffectiveContainerId(
111 targetLoopId,
112 context.currentNodeId,
113 context.executionContext.loopExecutions,
114 mappedBranchIndex
115 )
116 }
117
118 if (rest.length > 0) {
119 const { property, pathParts: bracketPathParts } = splitLeadingBracketPath(rest[0])
120
121 if (LoopResolver.OUTPUT_PROPERTIES.has(property)) {
122 if (!targetLoopId) {
123 return undefined
124 }
125 return useAsyncPath
126 ? this.resolveOutputAsync(targetLoopId, [...bracketPathParts, ...rest.slice(1)], context)
127 : this.resolveOutput(targetLoopId, [...bracketPathParts, ...rest.slice(1)], context)
128 }
129
130 const isContextual =
131 isGenericRef ||
132 (targetLoopId !== undefined &&

Callers 2

resolveMethod · 0.95
resolveAsyncMethod · 0.95

Calls 13

resolveOutputAsyncMethod · 0.95
resolveOutputMethod · 0.95
getAvailableFieldsMethod · 0.95
parseReferencePathFunction · 0.90
extractOuterBranchIndexFunction · 0.90
findEffectiveContainerIdFunction · 0.90
splitLeadingBracketPathFunction · 0.90
navigatePathFunction · 0.90
warnMethod · 0.65

Tested by

no test coverage detected