{"version":3,"sources":["../src/cli/commands/dataset/list.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport ora from \"ora\";\nimport { checkApiKey } from \"../../utils/apiKey\";\nimport { formatTable, formatRelativeTime } from \"../../utils/formatting\";\nimport { createDatasetService } from \"./service-factory\";\nimport { handleDatasetCommandError } from \"./error-handler\";\n\n/**\n * Lists all datasets for the current project.\n * Displays a table with name, slug, record count, and last updated.\n */\nexport const listCommand = async (options?: { format?: string }): Promise<void> => {\n  checkApiKey();\n\n  const service = createDatasetService();\n  const spinner = ora(\"Fetching datasets...\").start();\n\n  try {\n    const result = await service.listDatasets();\n    const { data: datasets, pagination } = result;\n\n    spinner.succeed(\n      `Found ${pagination.total} dataset${pagination.total !== 1 ? \"s\" : \"\"}`,\n    );\n\n    if (options?.format === \"json\") {\n      console.log(JSON.stringify({ data: datasets, pagination }, null, 2));\n      return;\n    }\n\n    if (datasets.length === 0) {\n      console.log();\n      console.log(chalk.gray(\"No datasets found.\"));\n      console.log(chalk.gray(\"Create your first dataset with:\"));\n      console.log(\n        chalk.cyan('  langwatch dataset create \"My Dataset\" --columns input:string,output:string'),\n      );\n      return;\n    }\n\n    console.log();\n\n    const tableData = datasets.map((ds) => ({\n      Name: ds.name,\n      Slug: ds.slug,\n      Records: String(ds.recordCount),\n      Updated: ds.updatedAt ? formatRelativeTime(ds.updatedAt) : \"N/A\",\n    }));\n\n    formatTable({\n      data: tableData,\n      headers: [\"Name\", \"Slug\", \"Records\", \"Updated\"],\n      colorMap: { Name: chalk.cyan },\n    });\n\n    if (pagination.totalPages > 1) {\n      console.log();\n      console.log(\n        chalk.gray(\n          `Showing page ${pagination.page} of ${pagination.totalPages} (${pagination.total} total)`,\n        ),\n      );\n    }\n  } catch (error) {\n    handleDatasetCommandError({ spinner, error, context: \"list datasets\" });\n  }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAClB,OAAO,SAAS;AAUT,IAAM,cAAc,OAAO,YAAiD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