import type { NodeVar } from '@/types/var'

export type AllowedListInputType =
	| 'array[string]'
	| 'array[number]'
	| 'array[boolean]'
	| 'array[file]'
	| 'array[object]'

export const ALLOWED_INPUT_TYPES: AllowedListInputType[] = [
	'array[string]',
	'array[number]',
	'array[boolean]',
	'array[file]',
	'array[object]'
]

export const filterArrayVariables = (list: NodeVar[]) => {
	return list
		.map((group) => ({
			...group,
			variableList: group.variableList.filter((item) =>
				ALLOWED_INPUT_TYPES.includes(item.type as AllowedListInputType)
			)
		}))
		.filter((group) => group.variableList.length)
}
