Checkpoint: Historique des imports enrichi avec le compte, la source, le déclencheur, les résultats, les erreurs et les informations du fichier source. Les administrateurs peuvent déclencher une lecture e-mail ponctuelle pour une boîte configurée, avec confirmation explicite, sans activer ni créer de planification. Migration importTrigger appliquée en sandbox ; TypeScript, 48 tests, build et rendus bureau/mobile validés.
This commit is contained in:
@@ -40,13 +40,16 @@ import {
|
||||
isInvoiceBlacklisted,
|
||||
getAllInvoices,
|
||||
getAllImportLogs,
|
||||
getAllImportLogsWithDetails,
|
||||
getAllBapHistory,
|
||||
createImportLog,
|
||||
getImportLogsByUser,
|
||||
getImportLogsWithDetailsByUser,
|
||||
deleteAllImportLogs,
|
||||
getLlmLogsBySourceFile,
|
||||
getLlmLogsByInvoice,
|
||||
getImportSettingsByUser,
|
||||
getEmailImportAccounts,
|
||||
upsertImportSettings,
|
||||
getDepartmentsByUser,
|
||||
createDepartment,
|
||||
@@ -94,7 +97,7 @@ import { calculateFileSha256 } from "./fileFingerprint";
|
||||
import { localStoragePut, generateStorageKey } from "./localStorage";
|
||||
import { testSftpConnection, exportInvoiceToSftp, getUserSftpConfig } from "./sftpExport";
|
||||
import { drawBapCartouche } from "./bapCartouche";
|
||||
import { startEmailImportService, stopEmailImportService, isEmailImportServiceRunning, triggerEmailCheck, testImapConnection } from "./emailImportService";
|
||||
import { startEmailImportService, stopEmailImportService, isEmailImportServiceRunning, triggerEmailCheck, triggerManualEmailCheck, testImapConnection } from "./emailImportService";
|
||||
import { startFolderImportService, stopFolderImportService, isFolderImportServiceRunning } from "./folderImportService";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { processFreeproExcel } from "./freeproService";
|
||||
@@ -409,6 +412,7 @@ export const appRouter = router({
|
||||
duplicateDetails: JSON.stringify(duplicateDetails),
|
||||
errorDetails: JSON.stringify(errorDetails),
|
||||
importSource: "file",
|
||||
importTrigger: "manual",
|
||||
});
|
||||
|
||||
} catch (error: any) {
|
||||
@@ -1646,9 +1650,9 @@ export const appRouter = router({
|
||||
getByUser: protectedProcedure.query(async ({ ctx }) => {
|
||||
// Les admins voient tous les logs d'import
|
||||
if (ctx.user.role === 'admin') {
|
||||
return getAllImportLogs();
|
||||
return getAllImportLogsWithDetails();
|
||||
}
|
||||
return getImportLogsByUser(ctx.user.id);
|
||||
return getImportLogsWithDetailsByUser(ctx.user.id);
|
||||
}),
|
||||
|
||||
deleteAll: protectedProcedure.mutation(async ({ ctx }) => {
|
||||
@@ -1715,6 +1719,18 @@ export const appRouter = router({
|
||||
const result = await triggerEmailCheck(ctx.user.id);
|
||||
return result;
|
||||
}),
|
||||
|
||||
/** Liste sans secrets les boîtes IMAP disponibles pour une action manuelle d’administrateur. */
|
||||
getConfiguredAccounts: adminProcedure.query(async () => {
|
||||
return getEmailImportAccounts();
|
||||
}),
|
||||
|
||||
/** Déclenche une seule lecture IMAP sans activer ni planifier le service automatique. */
|
||||
checkAccountNow: adminProcedure
|
||||
.input(z.object({ userId: z.number().int().positive() }))
|
||||
.mutation(async ({ input }) => {
|
||||
return triggerManualEmailCheck(input.userId);
|
||||
}),
|
||||
}),
|
||||
|
||||
// ============= IMPORT SETTINGS ROUTES =============
|
||||
|
||||
Reference in New Issue
Block a user