Skip to content

Commit 3bb327f

Browse files
waleedlatif1claude
andcommitted
chore(uploads): align metadata.ts with global standards
Replace dynamic uuid import with generateId() per @sim/utils/id convention, narrow the error catch off `any`, and convert the inline comment to TSDoc. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 0d9a14e commit 3bb327f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

apps/sim/lib/uploads/server/metadata.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { db } from '@sim/db'
22
import { workspaceFiles } from '@sim/db/schema'
33
import { createLogger } from '@sim/logger'
4+
import { generateId } from '@sim/utils/id'
45
import { and, eq, isNull } from 'drizzle-orm'
56
import type { StorageContext } from '../shared/types'
67

@@ -16,7 +17,8 @@ export interface FileMetadataInsertOptions {
1617
originalName: string
1718
contentType: string
1819
size: number
19-
id?: string // Optional - will generate UUID if not provided
20+
/** Optional — a UUID is generated when omitted. */
21+
id?: string
2022
}
2123

2224
export interface FileMetadataQueryOptions {
@@ -71,7 +73,7 @@ export async function insertFileMetadata(
7173
return existing[0]
7274
}
7375

74-
const fileId = id || (await import('uuid')).v4()
76+
const fileId = id || generateId()
7577

7678
try {
7779
const [inserted] = await db
@@ -92,10 +94,8 @@ export async function insertFileMetadata(
9294

9395
return inserted
9496
} catch (error) {
95-
if (
96-
(error as any)?.code === '23505' ||
97-
(error instanceof Error && error.message.includes('unique'))
98-
) {
97+
const code = (error as { code?: string } | null)?.code
98+
if (code === '23505' || (error instanceof Error && error.message.includes('unique'))) {
9999
const existingAfterError = await db
100100
.select()
101101
.from(workspaceFiles)

0 commit comments

Comments
 (0)