| 150 | } |
| 151 | |
| 152 | function parseBatchInfos(files: HFFileEntry[]): BatchInfo[] { |
| 153 | return files |
| 154 | .filter(f => f.type === 'file' && f.path.endsWith('.jsonl')) |
| 155 | .map(f => { |
| 156 | const category = f.path.startsWith('metadata/') ? 'metadata' as const : 'dataset' as const |
| 157 | // Filename format: batch_<timestamp>_<seq>.jsonl |
| 158 | const match = f.path.match(/batch_(.+?)_(\d+)\.jsonl$/) |
| 159 | return { |
| 160 | path: f.path, |
| 161 | category, |
| 162 | size: f.size, |
| 163 | timestamp: match ? match[1].replace(/-/g, (m, offset: number) => { |
| 164 | // Restore ISO timestamp separators: first 2 dashes are date, then T, then colons, then dot |
| 165 | return m |
| 166 | }) : null, |
| 167 | sequence: match ? match[2] : null, |
| 168 | } |
| 169 | }) |
| 170 | .sort((a, b) => (a.path > b.path ? -1 : 1)) // newest first |
| 171 | } |
| 172 | |
| 173 | // ── Core: Read a Batch File ────────────────────────────────────────── |
| 174 | |