mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-04 20:05:16 +02:00
feat(web): add document files contract and api method
This commit is contained in:
parent
a4f3af7ed8
commit
637affecb8
2 changed files with 30 additions and 0 deletions
|
|
@ -281,6 +281,23 @@ export const deleteDocumentResponse = z.object({
|
||||||
message: z.literal("Document deleted successfully"),
|
message: z.literal("Document deleted successfully"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Document files (stored originals / derived artifacts)
|
||||||
|
*/
|
||||||
|
export const documentFileKindEnum = z.enum(["ORIGINAL", "REDACTED", "FILLED_FORM"]);
|
||||||
|
|
||||||
|
export const documentFileRead = z.object({
|
||||||
|
id: z.number(),
|
||||||
|
document_id: z.number(),
|
||||||
|
kind: documentFileKindEnum,
|
||||||
|
original_filename: z.string(),
|
||||||
|
mime_type: z.string().nullable().optional(),
|
||||||
|
size_bytes: z.number(),
|
||||||
|
created_at: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const getDocumentFilesResponse = z.array(documentFileRead);
|
||||||
|
|
||||||
export type Document = z.infer<typeof document>;
|
export type Document = z.infer<typeof document>;
|
||||||
export type DocumentTitleRead = z.infer<typeof documentTitleRead>;
|
export type DocumentTitleRead = z.infer<typeof documentTitleRead>;
|
||||||
export type GetDocumentsRequest = z.infer<typeof getDocumentsRequest>;
|
export type GetDocumentsRequest = z.infer<typeof getDocumentsRequest>;
|
||||||
|
|
@ -314,3 +331,6 @@ export type GetDocumentChunksRequest = z.infer<typeof getDocumentChunksRequest>;
|
||||||
export type GetDocumentChunksResponse = z.infer<typeof getDocumentChunksResponse>;
|
export type GetDocumentChunksResponse = z.infer<typeof getDocumentChunksResponse>;
|
||||||
export type ChunkRead = z.infer<typeof chunkRead>;
|
export type ChunkRead = z.infer<typeof chunkRead>;
|
||||||
export type ProcessingMode = z.infer<typeof processingModeEnum>;
|
export type ProcessingMode = z.infer<typeof processingModeEnum>;
|
||||||
|
export type DocumentFileKind = z.infer<typeof documentFileKindEnum>;
|
||||||
|
export type DocumentFileRead = z.infer<typeof documentFileRead>;
|
||||||
|
export type GetDocumentFilesResponse = z.infer<typeof getDocumentFilesResponse>;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ import {
|
||||||
searchDocumentsResponse,
|
searchDocumentsResponse,
|
||||||
searchDocumentTitlesRequest,
|
searchDocumentTitlesRequest,
|
||||||
searchDocumentTitlesResponse,
|
searchDocumentTitlesResponse,
|
||||||
|
type DocumentFileRead,
|
||||||
|
getDocumentFilesResponse,
|
||||||
type UpdateDocumentRequest,
|
type UpdateDocumentRequest,
|
||||||
type UploadDocumentRequest,
|
type UploadDocumentRequest,
|
||||||
updateDocumentRequest,
|
updateDocumentRequest,
|
||||||
|
|
@ -381,6 +383,14 @@ class DocumentsApiService {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List the stored files for a document (e.g. its original upload).
|
||||||
|
* Used to gate the "Download original" affordance.
|
||||||
|
*/
|
||||||
|
getDocumentFiles = async (documentId: number): Promise<DocumentFileRead[]> => {
|
||||||
|
return baseApiService.get(`/api/v1/documents/${documentId}/files`, getDocumentFilesResponse);
|
||||||
|
};
|
||||||
|
|
||||||
listDocumentVersions = async (documentId: number) => {
|
listDocumentVersions = async (documentId: number) => {
|
||||||
return baseApiService.get(`/api/v1/documents/${documentId}/versions`);
|
return baseApiService.get(`/api/v1/documents/${documentId}/versions`);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue