fix: harden upload resilience and contracts

This commit is contained in:
Tom Boullay
2026-05-12 23:49:30 +02:00
parent 101af23418
commit 606df93b69
19 changed files with 479 additions and 159 deletions
+6 -3
View File
@@ -6,22 +6,25 @@ import type { TextureFile } from '@/lib/client-types'
const SUPPORT_FILE_EXT_ARRAY = [...TEXTURE_EXTENSIONS, ...ASSET_EXTENSIONS]
interface GltfBufferReference {
uri?: unknown
uri?: string
}
interface GltfJson {
buffers?: GltfBufferReference[]
}
/** Discriminated union: either valid (with model) or invalid (with errors). */
type ValidationResult =
| { ok: true; model: File; textures: TextureFile[]; warnings: string[] }
| { ok: false; errors: string[] }
function isGltfBufferReference(value: unknown): value is GltfBufferReference {
return isRecord(value) && (value.uri === undefined || typeof value.uri === 'string')
}
function isGltfJson(value: unknown): value is GltfJson {
if (!isRecord(value)) return false
if (value.buffers === undefined) return true
return Array.isArray(value.buffers) && value.buffers.every(isRecord)
return Array.isArray(value.buffers) && value.buffers.every(isGltfBufferReference)
}
function getReferencedBufferNames(gltf: GltfJson) {