0a9588abb7
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { PDFStatus } from '../types';
|
|
import { apiClient } from './apiClient';
|
|
|
|
export const pdfPreviewService = {
|
|
|
|
async getPDFUrl(fileId: string): Promise<{ url: string }> {
|
|
const { data } = await apiClient.get<{ url: string }>(`/knowledge-bases/${fileId}/pdf-url`);
|
|
return data;
|
|
},
|
|
|
|
|
|
async getPDFStatus(fileId: string): Promise<PDFStatus> {
|
|
const { data } = await apiClient.get<PDFStatus>(`/knowledge-bases/${fileId}/pdf-status`);
|
|
return data;
|
|
},
|
|
|
|
|
|
async preloadPDF(fileId: string, force: boolean = false): Promise<void> {
|
|
try {
|
|
const url = `/knowledge-bases/${fileId}/pdf-url` + (force ? '?force=true' : '');
|
|
const response = await apiClient.request(url, {
|
|
method: 'GET',
|
|
signal: AbortSignal.timeout(30000), // Increase timeout for conversion
|
|
});
|
|
|
|
if (response.ok) {
|
|
console.log('PDF already exists or conversion completed');
|
|
}
|
|
} catch (error: any) {
|
|
console.log('PDF conversion triggered:', error.message);
|
|
}
|
|
},
|
|
}; |