/** * Which parts of a MIME tree hold the message body. * * This used to be four lines: walk the flat part list, keep the longest `text/plain` and the * longest `text/html`. That is wrong in a way that loses content silently. In * `multipart/mixed(P, P)` the two children are not two renderings of one thing, they are two * pieces of the message, and picking the longer one deleted the shorter. A three line authored * reply followed by a long gateway disclaimer came out as the disclaimer alone, with no warning. * * MIME structure carries the meaning that length does not: * * - `multipart/alternative` holds alternative renderings of the same content. At most one text and * one HTML representation come out of one group. * - `multipart/mixed` holds ordered sibling content, all of which may belong to the visible message. * Each body-bearing child is an independent section. * - `multipart/related` holds one root body plus inline resources. The root is named by the * container's `start` parameter or is simply the first child. * - `message/rfc822` is embedded content, not the container's own body. * - An attachment disposition excludes a part. The *absence* of one does not make sibling parts * alternatives, which is the assumption the old code made. * * Length survives only as a tie breaker inside one structurally equivalent group. Document order * decides everything else. */ import { type MimePart, type ParsedMessage } from './model'; /** Where a section sits in the message. The first body-bearing section is the primary one. */ export type SectionRole = 'primary' | 'appended'; /** One structurally independent piece of the body, in whichever representations it has. */ export interface PlannedSection { text: MimePart | null; html: MimePart | null; role: SectionRole; } /** Why an eligible looking text part is not in the plan. Machine readable, never free text. */ export type ExclusionReason = /** Another member of the same `multipart/alternative` group represents this content. */ 'alternative_not_preferred' /** An inline resource of a `multipart/related`, not its root. */ | 'related_resource' /** Inside a `message/rfc822`. Embedded messages are content for the caller to render, not body. */ | 'embedded_message' /** Carried an attachment disposition. */ | 'attachment' /** Nesting deeper than the walk is willing to follow. */ | 'max_depth_exceeded'; export interface ExcludedPart { partId: string; reason: ExclusionReason; } export interface BodyPlan { /** Body-bearing sections in document order. Empty when the message has no body. */ sections: PlannedSection[]; excluded: ExcludedPart[]; } /** * Build the ordered body plan for a parsed message. * * The first body-bearing section is `primary`; everything after it is `appended`. Appended sections * are ordinary content until a rule says otherwise: gateways append substantive text as often as * they append disclaimers, so position is evidence, not a label. */ export declare function planBody(message: ParsedMessage): BodyPlan; /** * Exclusions a caller should be told about. * * An unused `multipart/alternative` member, an attachment and an embedded message are all excluded * by a written rule and are not losses. A text part dropped because it was not the related root, or * because the tree nested past the walk's limit, is content that exists and is not represented. */ export declare function reportableExclusions(plan: BodyPlan): ExcludedPart[]; //# sourceMappingURL=select.d.ts.map