Skip to content

Commit 16ecff3

Browse files
committed
improvement(logs): align fileSchema with shared UserFile type
- contracts/logs.ts: replace local fileSchema with mediaUserFileSchema (the established UserFile boundary schema with .passthrough()) - file-download.tsx: drop local FileData interface, use UserFile from @/executor/types
1 parent 8c53a45 commit 16ecff3

2 files changed

Lines changed: 6 additions & 30 deletions

File tree

  • apps/sim
    • app/workspace/[workspaceId]/logs/components/log-details/components/file-download
    • lib/api/contracts

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/components/file-download/file-download.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,18 @@ import { useRouter } from 'next/navigation'
77
import { Button, Loader } from '@/components/emcn'
88
import { cn } from '@/lib/core/utils/cn'
99
import { extractWorkspaceIdFromExecutionKey, getViewerUrl } from '@/lib/uploads/utils/file-utils'
10+
import type { UserFile } from '@/executor/types'
1011

1112
const logger = createLogger('FileCards')
1213

13-
interface FileData {
14-
id?: string
15-
name: string
16-
size: number
17-
type: string
18-
key: string
19-
url: string
20-
uploadedAt?: string
21-
expiresAt?: string
22-
storageProvider?: 's3' | 'blob' | 'local'
23-
bucketName?: string
24-
}
25-
2614
interface FileCardsProps {
27-
files: FileData[]
15+
files: UserFile[]
2816
isExecutionFile?: boolean
2917
workspaceId?: string
3018
}
3119

3220
interface FileCardProps {
33-
file: FileData
21+
file: UserFile
3422
isExecutionFile?: boolean
3523
workspaceId?: string
3624
}
@@ -158,7 +146,7 @@ export function FileDownload({
158146
className,
159147
workspaceId,
160148
}: {
161-
file: FileData
149+
file: UserFile
162150
isExecutionFile?: boolean
163151
className?: string
164152
workspaceId?: string

apps/sim/lib/api/contracts/logs.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { z } from 'zod'
2+
import { mediaUserFileSchema } from '@/lib/api/contracts/tools/media/shared'
23
import { defineRouteContract } from '@/lib/api/contracts/types'
34

45
const comparisonOperatorSchema = z.enum(['=', '>', '<', '>=', '<=', '!='])
@@ -66,19 +67,6 @@ const workflowSummarySchema = z
6667
})
6768
.partial()
6869

69-
const fileSchema = z.object({
70-
id: z.string(),
71-
name: z.string(),
72-
size: z.number(),
73-
type: z.string(),
74-
url: z.string(),
75-
key: z.string(),
76-
uploadedAt: z.string().optional(),
77-
expiresAt: z.string().optional(),
78-
storageProvider: z.enum(['s3', 'blob', 'local']).optional(),
79-
bucketName: z.string().optional(),
80-
})
81-
8270
const tokenBreakdownSchema = z
8371
.object({
8472
total: z.number().optional(),
@@ -237,7 +225,7 @@ export const workflowLogSummarySchema = z.object({
237225

238226
export const workflowLogDetailSchema = workflowLogSummarySchema.extend({
239227
executionData: executionDataDetailSchema,
240-
files: z.array(fileSchema).nullable(),
228+
files: z.array(mediaUserFileSchema).nullable(),
241229
})
242230

243231
export type WorkflowLogSummary = z.output<typeof workflowLogSummarySchema>

0 commit comments

Comments
 (0)