import { flatten } from "flat" export function flattenInput( input: unknown ): Record | undefined { if (typeof input !== "object" || input === null) { return undefined } const onlyPrimitives = Object.entries(input).reduce( (acc, [key, value]) => { if ( typeof value === "string" || typeof value === "number" || typeof value === "boolean" ) { acc[key] = value } return acc }, {} as Record ) if (onlyPrimitives && Object.keys(onlyPrimitives).length === 0) { return undefined } return flatten({ input: onlyPrimitives }) }