import { INormalizedName, normalizeName, } from '../../../helpers/profileGeneratorHelper'; import inquirer from 'inquirer'; export async function getTaskDataFromCustom( normalizedTaskName: INormalizedName, ): Promise<{ connection: { name: string }; puller: null; pusher: null; table: { columns: string[] }; }> { const { connectionName } = await inquirer.prompt([ { type: 'input', name: 'connectionName', message: 'Please provide the connection name for this task:', validate: (input) => input.trim() !== '' || 'Connection name cannot be empty.', }, ]); if (!connectionName.trim()) { throw new Error('Connection name is required for the custom option.'); } const { columns } = await inquirer.prompt([ { type: 'input', name: 'columns', message: 'Please provide table columns (comma-separated):', validate: (input) => input.trim() !== '' || 'Table columns cannot be empty.', }, ]); const columnsArray = columns .split(',') .map((col) => col.trim()) .filter((col) => col); if (columnsArray.length === 0) { throw new Error( 'At least one column must be provided for the custom table.', ); } console.log(`Custom table columns: ${columnsArray.join(', ')}`); return { connection: { name: normalizeName(connectionName).camelCaseName }, puller: null, pusher: null, table: { columns: columnsArray }, }; }