fix(bulk-import): skip __MACOSX folder when processing zip imports

Build errors fixed:
- Fixed session field access (session.sub instead of session.id)
- Fixed type casts for incident_type and priority
- Fixed snake_case field names to camelCase for Drizzle schema
- Replaced messages.create with chat.completions.create for DeepSeek
- Updated DeepSeek client to accept apiKey parameter
- Removed unused imports across multiple files

Route now accessible at /bulk-import. Redirects unauthenticated users to
/login?redirect=%2Fbulk-import.

Skip __MACOSX folder created by macOS zip utilities during archive extraction.
This commit is contained in:
2026-08-19 18:45:34 +08:00
parent 1bb8e4d856
commit 1422d3df47
8 changed files with 439 additions and 55 deletions
+4 -4
View File
@@ -4,8 +4,8 @@ import { NextRequest, NextResponse } from 'next/server'
export async function POST(request: NextRequest) {
const { session } = await requireAdmin()
if (!session?.id) return new NextResponse('Unauthorized', { status: 401 })
const userId = session.id
if (!session?.sub) return new NextResponse('Unauthorized', { status: 401 })
const userId = session.sub
try {
const body = await request.json()
@@ -25,8 +25,8 @@ export async function POST(request: NextRequest) {
description: f.description,
date: f.date,
location: f.location,
incident_type: f.incident_type as any,
priority: f.priority as any
incident_type: f.incident_type as 'env' | 'asset' | 'security' | 'fire' | undefined,
priority: f.priority as 'low' | 'med' | 'high' | undefined
}))
// Create incidents with user ID