11import { AuditAction , AuditResourceType , recordAudit } from '@sim/audit'
22import { type Principal , resolvePrincipalAuditAttribution } from '@sim/auth/principal'
33import { db } from '@sim/db'
4- import { workspaceFiles } from '@sim/db/schema'
4+ import { type WorkspaceFileRow , workspaceFileColumns , workspaceFiles } from '@sim/db/schema'
55import { generateId } from '@sim/utils/id'
66import { eq , sql } from 'drizzle-orm'
77import type { V2File } from '@/lib/api/contracts/v2/files'
@@ -80,7 +80,7 @@ interface FinalizedMetadataInput {
8080 size : number
8181}
8282
83- type FileMetadataRecord = typeof workspaceFiles . $inferSelect
83+ type FileMetadataRecord = WorkspaceFileRow
8484
8585/**
8686 * Finalizes the domain resource represented by a verified upload object.
@@ -371,7 +371,7 @@ async function insertOrLoadFileMetadata(
371371 contentUpdatedAt : now ,
372372 } )
373373 . onConflictDoNothing ( )
374- . returning ( )
374+ . returning ( workspaceFileColumns )
375375
376376 if ( inserted ) return { file : inserted , created : true }
377377
@@ -386,7 +386,7 @@ async function insertOrLoadFileMetadata(
386386
387387async function findFileMetadataByKey ( key : string ) : Promise < FileMetadataRecord | undefined > {
388388 const [ file ] = await db
389- . select ( )
389+ . select ( workspaceFileColumns )
390390 . from ( workspaceFiles )
391391 . where ( eq ( workspaceFiles . key , key ) )
392392 . orderBy ( sql `${ workspaceFiles . deletedAt } IS NULL DESC` )
0 commit comments