Spaces:
Build error
Build error
File size: 658 Bytes
d9494a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import { isObject, isString } from '@sniptt/guards';
import { CAPTURE_ALL_VARIABLE_TAG_INNER_REGEX } from '@/workflow/constants/CaptureAllVariableTagInnerRegex';
function* resolveVariables(value: unknown): Generator<string> {
if (isString(value)) {
for (const [, variablePath] of value.matchAll(
CAPTURE_ALL_VARIABLE_TAG_INNER_REGEX,
)) {
yield variablePath;
}
return;
}
if (isObject(value)) {
for (const nestedValue of Object.values(value)) {
yield* resolveVariables(nestedValue);
}
}
}
export const extractVariablesFromInput = (input: unknown): string[] => {
return [...resolveVariables(input)];
};
|