feat(mail-ingest): read forwarded booking mails and add what passes the checks to its trip

Addresses per person and per trip (random base32 token, stored hashed and
encrypted), an intake every transport shares, and a job that reads each
mail once under a lease: filters without AI, machine-readable data always,
one AI request with the person's trips, the server's checks G1 to G9, then
one transaction per mail that adds what passed, keeps the rest in the inbox
with a reason, and notifies the forwarder and co-travellers. Undo within
7 days, manual apply, filing as documents, a prefilled form and a nightly
retention complete it; on a managed install the operator's switch decides.
This commit is contained in:
Maurice
2026-11-13 16:04:26 +01:00
parent 340454cfc7
commit de7de4b8de
36 changed files with 4038 additions and 54 deletions
@@ -1,3 +1,4 @@
import { logError } from '../audit/audit-log.logger';
import type { KiReservation } from '../booking-import/kitinerary.types';
import { capImage, renderPdfPages } from './image-input';
import { createLlmClient } from './llm-client.factory';
@@ -96,7 +97,7 @@ export class MailReadService {
} catch (err) {
// The provider and the error only: the mail's content stays out of the log.
const reason = err instanceof Error ? err.message : String(err);
console.error(`[llm-parse] Mail read failed (provider=${config.provider}): ${reason}`);
logError(`[llm-parse] Mail read failed (provider=${config.provider}): ${reason}`);
return nothing(failureOutcome(err));
}
}
@@ -53,7 +53,10 @@ export function normalizeNode(node: Record<string, unknown>): Record<string, unk
* is dropped: an empty currency lets the cost form pick one, a made up one
* (`EURials`, #2477) is saved and cannot be converted.
*/
export function normalizeCurrency(node: Record<string, unknown>, documentText: string | undefined): Record<string, unknown> {
export function normalizeCurrency(
node: Record<string, unknown>,
documentText: string | undefined,
): Record<string, unknown> {
const hasPrice = node.price != null && node.price !== '';
if (node.priceCurrency == null && !hasPrice) return node;
const code =