UNPKG

legal-markdown-js

Version:

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

156 lines 4.88 kB
/** * Field Tracking System for Legal Markdown Processing * * This module provides comprehensive field tracking functionality for Legal Markdown * documents, including field status monitoring, highlighting support, and reporting * capabilities. It tracks field processing state and applies appropriate CSS classes * for visual feedback during document review. * * Features: * - Field status tracking (filled, empty, logic) * - CSS class application for field highlighting * - Field processing state management * - Mixin usage tracking for complex field logic * - Reporting and analytics for field usage * - Singleton pattern for consistent tracking across the application * * @example * ```typescript * import { fieldTracker, FieldStatus } from './field-tracker'; * * // Track a field during processing * fieldTracker.trackField('client.name', { * value: 'Acme Corporation', * status: FieldStatus.FILLED * }); * * // Apply field tracking to content * const highlightedContent = fieldTracker.applyFieldTracking(processedContent); * * // Generate field report * const report = fieldTracker.generateReport(); * console.log(`${report.filled} fields filled, ${report.empty} fields empty`); * ``` */ import { FieldStatus } from '../../core/tracking/field-state'; import type { TrackedField } from '../../core/tracking/field-state'; export { FieldStatus }; export type { TrackedField }; /** * Field tracking system for Legal Markdown processing * * Manages field tracking throughout the document processing lifecycle, * including status monitoring, highlighting, and reporting capabilities. * * @class FieldTracker * @example * ```typescript * import { FieldTracker, FieldStatus } from './field-tracker'; * * const tracker = new FieldTracker(); * * // Track field processing * tracker.trackField('client.name', { * value: 'Acme Corp', * originalValue: '{{client.name}}', * hasLogic: false * }); * * // Apply tracking to content * const highlighted = tracker.applyFieldTracking(content); * * // Generate report * const report = tracker.generateReport(); * ``` */ export declare class FieldTracker { private fields; private processedContent; private totalOccurrences; /** * Creates a new FieldTracker instance */ constructor(); /** * Track a field that has been processed * * Registers a field with the tracking system, determining its status based on * the provided options and storing relevant metadata for later use. * * @param {string} fieldName - The name/identifier of the field to track * @param {Object} options - Options for field tracking * @param {any} [options.value] - The processed value of the field * @param {any} [options.originalValue] - The original unprocessed value * @param {boolean} [options.hasLogic=false] - Whether the field contains logical operations * @param {string} [options.mixinUsed] - Name of mixin used for processing * @returns {void} * @example * ```typescript * // Track a filled field * tracker.trackField('client.name', { * value: 'Acme Corporation', * originalValue: '{{client.name}}' * }); * * // Track an empty field * tracker.trackField('client.address', { * value: '', * originalValue: '{{client.address}}' * }); * * // Track a field with logic * tracker.trackField('warranty.clause', { * value: 'Standard warranty applies', * originalValue: '{{#if warranty.enabled}}{{warranty.text}}{{/if}}', * hasLogic: true, * mixinUsed: 'warranty-mixin' * }); * ``` */ trackField(fieldName: string, options: { value?: any; originalValue?: any; hasLogic?: boolean; mixinUsed?: string; }): void; /** * Apply field tracking to processed content by wrapping fields with appropriate CSS classes */ applyFieldTracking(content: string): string; /** * Get CSS class for field based on its status */ private getFieldCssClass; /** * Escape special regex characters in a string */ private escapeRegex; /** * Get all tracked fields */ getFields(): Map<string, TrackedField>; /** * Get total number of field occurrences tracked */ getTotalOccurrences(): number; /** * Get fields by status */ getFieldsByStatus(status: FieldStatus): TrackedField[]; /** * Generate a summary report of tracked fields */ generateReport(): { total: number; filled: number; empty: number; logic: number; fields: TrackedField[]; }; /** * Clear all tracked fields */ clear(): void; } export declare const fieldTracker: FieldTracker; //# sourceMappingURL=field-tracker.d.ts.map