UNPKG

legal-markdown-js

Version:

Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version

69 lines 2.66 kB
/** * Phase 1: Processing Context Builder * * This module implements Phase 1 of the 3-phase pipeline architecture. * It handles document parsing, force-commands resolution, and creates * a unified processing context for subsequent phases. * * Key responsibilities: * - Parse YAML frontmatter * - Resolve force-commands templates (using remark-based processor) * - Merge CLI options, force-commands, and metadata * - Create ProcessingContext for Phase 2 * * @module core/pipeline/context-builder */ import type { ProcessingContext, ProcessingOptions } from '../../types/pipeline.js'; import type { YamlValue } from '../../types/index.js'; /** * Build a processing context from raw content and options * * This is the entry point for Phase 1. It: * 1. Parses YAML frontmatter to extract metadata * 2. Extracts and resolves force-commands (if present) * 3. Merges all options (CLI + force-commands + defaults) * 4. Creates a unified ProcessingContext for Phase 2 * * @param rawContent - Raw markdown content with optional YAML frontmatter * @param cliOptions - Options from CLI or API call * @param basePath - Base path for file resolution * @returns ProcessingContext ready for Phase 2 processing * * @example * ```typescript * const context = await buildProcessingContext( * fileContent, * { pdf: true, highlight: true }, * '/path/to/input/dir' * ); * // context.options contains merged CLI + force-commands options * // context.metadata contains parsed YAML + additional metadata * ``` */ export declare function buildProcessingContext(rawContent: string, cliOptions?: Partial<ProcessingOptions>, basePath?: string): Promise<ProcessingContext>; /** * Merge multiple metadata objects with proper handling of nested objects * * This function is used when combining metadata from multiple sources: * - Document YAML frontmatter * - Imported file metadata * - Additional metadata from API/CLI * * @param target - Target metadata object to merge into * @param source - Source metadata to merge from * @returns Merged metadata object * @internal */ export declare function mergeMetadata(target: Record<string, YamlValue>, source: Record<string, YamlValue>): Record<string, YamlValue>; /** * Validate processing context for Phase 2 * * Ensures that the context has all required fields and valid values. * This helps catch configuration errors early in the pipeline. * * @param context - Processing context to validate * @throws Error if context is invalid * @internal */ export declare function validateProcessingContext(context: ProcessingContext): void; //# sourceMappingURL=context-builder.d.ts.map