File size: 1,144 Bytes
cd8bd0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { BatchRecord } from "@/lib/db/batches";
import { FileRecord } from "@/lib/db/files";

export function mapBatchApiToRecord(b: any): BatchRecord {
  return {
    id: b.id,
    endpoint: b.endpoint,
    completionWindow: b.completion_window,
    status: b.status,
    inputFileId: b.input_file_id,
    outputFileId: b.output_file_id,
    errorFileId: b.error_file_id,
    createdAt: b.created_at,
    inProgressAt: b.in_progress_at,
    expiresAt: b.expires_at,
    finalizingAt: b.finalizing_at,
    completedAt: b.completed_at,
    failedAt: b.failed_at,
    expiredAt: b.expired_at,
    cancellingAt: b.cancelling_at,
    cancelledAt: b.cancelled_at,
    requestCountsTotal: b.request_counts?.total ?? 0,
    requestCountsCompleted: b.request_counts?.completed ?? 0,
    requestCountsFailed: b.request_counts?.failed ?? 0,
    metadata: b.metadata,
    errors: b.errors,
    model: b.model,
    usage: b.usage,
  };
}

export function mapFileApiToRecord(f: any): FileRecord {
  return {
    id: f.id,
    filename: f.filename,
    bytes: f.bytes,
    purpose: f.purpose,
    createdAt: f.created_at,
    expiresAt: f.expires_at,
  };
}