import { EntityAliasOrString } from '@typedorm/common' ; import { regexInterpolatedWord } from './constants' ; import { isKeyOfTypeAliasSchema } from './is-key-of-type-alias-schema' ; export function getInterpolatedKeys ( key ) { if ( isKeyOfTypeAliasSchema ( key ) ) { return [ key . alias as string ] ; } const matchIterator = key . matchAll ( regexInterpolatedWord ) ; const interpolatedKeys = [ ] as string [ ] ; recursiveFindInterpolatedKeys ( key , matchIterator , interpolatedKeys ) ; return [ ... new Set ( interpolatedKeys ) ] ; } function recursiveFindInterpolatedKeys ( key , iterator , interpolatedKeys ) { const next = iterator . next ( ) ; if ( next . done ) { return ; } const variable = next . value [ 1 ] ; interpolatedKeys . push ( variable ) ; recursiveFindInterpolatedKeys ( key , iterator , interpolatedKeys ) ; }