SurfSense/surfsense_web/features/artifacts/model.ts
Anish Sarkar 54a0029a33 feat(artifacts): enhance artifact metadata handling and introduce format icons
- Added `document_id` to artifact listing for improved metadata association.
- Introduced `ArtifactFormatIcon` and `ArtifactFormatLabel` components for better visual representation of artifact formats.
- Updated various components to utilize new format handling, ensuring consistent display across the application.
- Refactored artifact-related schemas and hooks to accommodate new format data.
- Enhanced unit tests to cover new functionality and ensure robustness.
2026-08-14 01:34:50 +05:30

48 lines
1.3 KiB
TypeScript

import { z } from "zod";
export const ArtifactFileSchema = z.object({
file_id: z.number(),
role: z.enum(["primary", "preview"]),
filename: z.string(),
mime_type: z.string(),
size_bytes: z.number(),
content_url: z.string(),
});
const ArtifactLegacySchema = z
.object({
kind: z.string(),
id: z.number().int().positive(),
})
.optional();
export const ArtifactManifestSchema = z.object({
artifact_id: z.number(),
document_id: z.number(),
title: z.string(),
format: z.string(),
generation: z.number().int().positive(),
markdown_representation: z.string(),
files: z.array(ArtifactFileSchema),
updated_at: z.string().nullable(),
legacy: ArtifactLegacySchema,
});
export const ArtifactListItemSchema = z.object({
artifact_id: z.number(),
document_id: z.number(),
title: z.string(),
format: z.string(),
generation: z.number().int().positive(),
indexing_status: z.enum(["ready", "pending", "processing", "failed", "deleting"]),
thread_id: z.number().nullable(),
created_at: z.string(),
updated_at: z.string().nullable(),
legacy: ArtifactLegacySchema,
});
export const ArtifactListSchema = z.array(ArtifactListItemSchema);
export type ArtifactFile = z.infer<typeof ArtifactFileSchema>;
export type ArtifactManifest = z.infer<typeof ArtifactManifestSchema>;
export type ArtifactListItem = z.infer<typeof ArtifactListItemSchema>;