/** * DOCX Module - Relationship Manager * * Manages OPC relationships for the DOCX package. * Generates .rels files for package-level and part-level relationships. * * Provides both an object-oriented RelationshipsState interface and * backward-compatible free functions (addRelationship, renderRelationships, etc.). */ import type { XmlSink } from "../../xml/types.js"; /** A single OPC relationship. */ export interface Relationship { readonly id: string; readonly type: string; readonly target: string; /** * OPC TargetMode. Standard values are `"External"` and `"Internal"` * (with `"Internal"` typically omitted on the wire). Internally we accept * any string so that round-tripped relationships preserve non-standard * values verbatim; new relationships emitted by the writer's own helpers * still pass `"External"` or `undefined`. */ readonly targetMode?: string; } /** Rich relationship set with validation and dedup capabilities. */ export interface RelationshipsState { readonly rels: readonly Relationship[]; /** Add a relationship. If a matching (type, target, targetMode) already exists, returns its ID. */ add(type: string, target: string, targetMode?: string): string; /** Add with a specific ID. Throws if ID already exists. */ addWithId(id: string, type: string, target: string, targetMode?: string): void; /** Find existing relationship by type and target. */ findByTypeAndTarget(type: string, target: string): Relationship | undefined; /** Check if an rId is already used. */ hasId(id: string): boolean; /** Get count. */ count(): number; /** Validate all relationships. Returns error messages (empty = valid). */ validate(): string[]; /** Render to XML. */ render(sink: XmlSink): void; } /** Create a new empty RelationshipsState. */ export declare function createRelationships(): RelationshipsState; /** Add a relationship and return its assigned rId (free function alias). */ export declare function addRelationship(state: RelationshipsState, type: string, target: string, targetMode?: string): string; /** Add a relationship with a specific ID (free function alias). */ export declare function addRelationshipWithId(state: RelationshipsState, id: string, type: string, target: string, targetMode?: string): void; /** Get the number of relationships (free function alias). */ export declare function getRelationshipCount(state: RelationshipsState): number; /** Render the relationships XML to a sink (free function alias). */ export declare function renderRelationships(state: RelationshipsState, xml: XmlSink): void;