MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / getInputVariables

Function getInputVariables

packages/components/src/utils.ts:239–268  ·  view source on GitHub ↗
(paramValue: string)

Source from the content-addressed store, hash-verified

237 * @returns {boolean}
238 */
239export const getInputVariables = (paramValue: string): string[] => {
240 if (typeof paramValue !== 'string') return []
241 const returnVal = paramValue
242 const variableStack = []
243 const inputVariables = []
244 let startIdx = 0
245 const endIdx = returnVal.length
246 while (startIdx < endIdx) {
247 const substr = returnVal.substring(startIdx, startIdx + 1)
248 // Check for escaped curly brackets
249 if (substr === '\\' && (returnVal[startIdx + 1] === '{' || returnVal[startIdx + 1] === '}')) {
250 startIdx += 2 // Skip the escaped bracket
251 continue
252 }
253 // Store the opening double curly bracket
254 if (substr === '{') {
255 variableStack.push({ substr, startIdx: startIdx + 1 })
256 }
257 // Found the complete variable
258 if (substr === '}' && variableStack.length > 0 && variableStack[variableStack.length - 1].substr === '{') {
259 const variableStartIdx = variableStack[variableStack.length - 1].startIdx
260 const variableEndIdx = startIdx
261 const variableFullPath = returnVal.substring(variableStartIdx, variableEndIdx)
262 if (!variableFullPath.includes(':')) inputVariables.push(variableFullPath)
263 variableStack.pop()
264 }
265 startIdx += 1
266 }
267 return inputVariables
268}
269
270/**
271 * Transform single curly braces into double curly braces if the content includes a colon.

Callers 9

initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
getSQLDBChainFunction · 0.90
initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
initMethod · 0.90
isStartNodeDependOnInputFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected