Checkpoint: Automatismes séparé en onglets Import et Export. Les règles d’export ciblent un destinataire ou une ventilation, avec destination locale, Teams ou SharePoint et ouverture navigateur optionnelle. La validation BAP unique ou en masse applique la première règle active par priorité puis conserve le paramétrage historique comme repli. Paramètres d’export déplacés vers Automatismes et page renommée Paramètres. Migration additive, tests, TypeScript, build et contrôles visuels validés.

This commit is contained in:
Manus
2026-09-02 12:13:23 +00:00
parent da19629ee0
commit 582ca77f28
15 changed files with 2978 additions and 23 deletions

View File

@@ -30,6 +30,9 @@ import {
automationRules,
InsertAutomationRule,
AutomationRule,
exportAutomationRules,
InsertExportAutomationRule,
ExportAutomationRule,
llmFieldsConfig,
InsertLlmFieldConfig,
LlmFieldConfig,
@@ -747,6 +750,47 @@ export async function deleteAutomationRule(id: number): Promise<void> {
await db.delete(automationRules).where(eq(automationRules.id, id));
}
// ============= EXPORT AUTOMATION RULES OPERATIONS =============
export async function getExportAutomationRulesByUser(userId: number): Promise<ExportAutomationRule[]> {
const db = await getDb();
if (!db) return [];
return db.select().from(exportAutomationRules)
.where(eq(exportAutomationRules.userId, userId))
.orderBy(exportAutomationRules.priority, exportAutomationRules.id);
}
export async function getExportAutomationRuleById(id: number): Promise<ExportAutomationRule | null> {
const db = await getDb();
if (!db) return null;
const [rule] = await db.select().from(exportAutomationRules).where(eq(exportAutomationRules.id, id));
return rule || null;
}
export async function createExportAutomationRule(data: InsertExportAutomationRule): Promise<ExportAutomationRule> {
const db = await getDb();
if (!db) throw new Error("Database not available");
const result = await db.insert(exportAutomationRules).values(data);
const rule = await getExportAutomationRuleById(result[0].insertId);
if (!rule) throw new Error("Export automation rule could not be created");
return rule;
}
export async function updateExportAutomationRule(id: number, data: Partial<InsertExportAutomationRule>): Promise<ExportAutomationRule> {
const db = await getDb();
if (!db) throw new Error("Database not available");
await db.update(exportAutomationRules).set(data).where(eq(exportAutomationRules.id, id));
const rule = await getExportAutomationRuleById(id);
if (!rule) throw new Error("Export automation rule not found");
return rule;
}
export async function deleteExportAutomationRule(id: number): Promise<void> {
const db = await getDb();
if (!db) throw new Error("Database not available");
await db.delete(exportAutomationRules).where(eq(exportAutomationRules.id, id));
}
// ============= INITIALIZE DEFAULT VALUES =============
export async function initializeDefaultLists(userId: number): Promise<void> {