@memberjunction/metadata-sync 2.120.0 → 2.122.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"sync-engine.js","sourceRoot":"","sources":["../../src/lib/sync-engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;AAEH,gDAAwB;AACxB,wDAA0B;AAC1B,oDAA4B;AAC5B,kDAA0B;AAC1B,+CAAyG;AAEzG,2DAAuD;AACvD,sEAMwC;AA8BxC;;;;;;;;;;;GAWG;AACH,MAAa,UAAU;IACb,QAAQ,CAAW;IACnB,WAAW,CAAW;IAE9B;;;OAGG;IACH,YAAY,WAAqB;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU;QACd,qEAAqE;QACrE,gEAAgE;IAClE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,KAAK,CAAC,iBAAiB,CAAC,KAAU,EAAE,OAAe,EAAE,YAAgC,EAAE,UAA8B,EAAE,QAAgB,CAAC,EAAE,YAAsC;QAC9K,8BAA8B;QAC9B,MAAM,mBAAmB,GAAG,EAAE,CAAC;QAC/B,IAAI,KAAK,GAAG,mBAAmB,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,4BAA4B,mBAAmB,4CAA4C,KAAK,EAAE,CAAC,CAAC;QACtH,CAAC;QACD,wEAAwE;QACxE,4FAA4F;QAC5F,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAChD,8DAA8D;YAC9D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;gBACzD,qFAAqF;gBACrF,MA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AM,CAAC;oBACN,8BAA8B;oBAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,gCAAgC;QAChC,OAAO,GAAG,CAAC;IACb,CAAC;CAEF;AA71BD,gCA61BC","sourcesContent":["/**\n * @fileoverview Core synchronization engine for MemberJunction metadata\n * @module sync-engine\n * \n * This module provides the core functionality for synchronizing metadata between\n * the MemberJunction database and local file system representations. It handles\n * special reference types (@file, @url, @lookup, @env, @parent, @root, @template),\n * manages entity operations, and provides utilities for data transformation.\n */\n\nimport path from 'path';\nimport fs from 'fs-extra';\nimport crypto from 'crypto';\nimport axios from 'axios';\nimport { EntityInfo, Metadata, RunView, BaseEntity, CompositeKey, UserInfo } from '@memberjunction/core';\nimport { EntityConfig, FolderConfig } from '../config';\nimport { JsonPreprocessor } from './json-preprocessor';\nimport {\n METADATA_KEYWORDS,\n METADATA_KEYWORD_PREFIXES,\n isMetadataKeyword,\n isNonKeywordAtSymbol,\n extractKeywordValue\n} from '../constants/metadata-keywords';\n\n/**\n * Represents the structure of a metadata record with optional sync tracking\n */\nexport interface RecordData {\n /** Primary key field(s) and their values */\n primaryKey?: Record<string, any>;\n /** Entity field names and their values */\n fields: Record<string, any>;\n /** Related entities organized by entity name */\n relatedEntities?: Record<string, RecordData[]>;\n /** Synchronization metadata for change tracking */\n sync?: {\n /** ISO timestamp of last modification */\n lastModified: string;\n /** SHA256 checksum of the fields object */\n checksum: string;\n };\n /** Delete record directive for removing records from the database */\n deleteRecord?: {\n /** Flag to indicate this record should be deleted */\n delete: boolean;\n /** ISO timestamp of when the deletion was performed */\n deletedAt?: string;\n /** Flag to indicate the record was not found when attempting deletion */\n notFound?: boolean;\n };\n}\n\n/**\n * Core engine for synchronizing MemberJunction metadata between database and files\n * \n * @class SyncEngine\n * @example\n * ```typescript\n * const syncEngine = new SyncEngine(systemUser);\n * \n * // Process a field value with special references\n * const value = await syncEngine.processFieldValue('@lookup:Users.Email=admin@example.com', '/path/to/base');\n * ```\n */\nexport class SyncEngine {\n private metadata: Metadata;\n private contextUser: UserInfo;\n\n /**\n * Creates a new SyncEngine instance\n * @param contextUser - The user context for database operations\n */\n constructor(contextUser: UserInfo) {\n this.metadata = new Metadata();\n this.contextUser = contextUser;\n }\n \n /**\n * Initializes the sync engine by refreshing metadata cache\n * @returns Promise that resolves when initialization is complete\n */\n async initialize(): Promise<void> {\n // Currently no initialization needed as metadata is managed globally\n // Keeping this method for backward compatibility and future use\n }\n \n /**\n * Process special references in field values and handle complex objects\n * \n * Automatically handles:\n * - Arrays and objects are converted to JSON strings\n * - Scalars (strings, numbers, booleans, null) pass through unchanged\n * \n * Handles the following reference types for string values:\n * - `@parent:fieldName` - References a field from the parent record\n * - `@root:fieldName` - References a field from the root record\n * - `@file:path` - Reads content from an external file\n * - `@url:address` - Fetches content from a URL\n * - `@lookup:Entity.Field=Value` - Looks up an entity ID by field value\n * - `@env:VARIABLE` - Reads an environment variable\n * \n * @param value - The field value to process\n * @param baseDir - Base directory for resolving relative file paths\n * @param parentRecord - Optional parent entity for @parent references\n * @param rootRecord - Optional root entity for @root references\n * @returns The processed value with all references resolved\n * @throws Error if a reference cannot be resolved\n * \n * @example\n * ```typescript\n * // File reference\n * const content = await processFieldValue('@file:template.md', '/path/to/dir');\n * \n * // Lookup with auto-create\n * const userId = await processFieldValue('@lookup:Users.Email=john@example.com?create', '/path');\n * \n * // Complex object - automatically stringified\n * const jsonStr = await processFieldValue({items: [{id: 1}, {id: 2}]}, '/path');\n * // Returns: '{\\n \"items\": [\\n {\\n \"id\": 1\\n },\\n {\\n \"id\": 2\\n }\\n ]\\n}'\n * ```\n */\n async processFieldValue(value: any, baseDir: string, parentRecord?: BaseEntity | null, rootRecord?: BaseEntity | null, depth: number = 0, batchContext?: Map<string, BaseEntity>): Promise<any> {\n // Check recursion depth limit\n const MAX_RECURSION_DEPTH = 50;\n if (depth > MAX_RECURSION_DEPTH) {\n throw new Error(`Maximum recursion depth (${MAX_RECURSION_DEPTH}) exceeded while processing field value: ${value}`);\n }\n // Handle arrays and objects that are directly defined in metadata files\n // Note: Objects loaded from @file references are returned as-is to preserve proper escaping\n if (value !== null && typeof value === 'object') {\n // Check if it's an array or a plain object (not a Date, etc.)\n if (Array.isArray(value) || value.constructor === Object) {\n // First recursively process any @lookup, @file, @parent references inside the object\n const processedValue = await this.processJsonFieldValues(value, baseDir, parentRecord, rootRecord, depth, batchContext);\n // Then convert to pretty-printed JSON string for inline metadata objects\n // Objects from @file references will be handled by BaseEntity during save\n return JSON.stringify(processedValue, null, 2);\n }\n }\n \n // If not a string, return as-is (numbers, booleans, null, etc.)\n if (typeof value !== 'string') {\n return value;\n }\n \n // If string starts with @ but isn't one of our known reference types, return as-is\n // This handles cases like npm package names (@mui/material, @angular/core, etc.)\n if (isNonKeywordAtSymbol(value)) {\n return value; // Not a MetadataSync reference, just a string that happens to start with @\n }\n \n // Check for @parent: reference\n if (value.startsWith(METADATA_KEYWORDS.PARENT)) {\n if (!parentRecord) {\n throw new Error(`@parent reference used but no parent record available: ${value}`);\n }\n const fieldName = extractKeywordValue(value) || '';\n return parentRecord.Get(fieldName);\n }\n\n // Check for @root: reference\n if (value.startsWith(METADATA_KEYWORDS.ROOT)) {\n if (!rootRecord) {\n throw new Error(`@root reference used but no root record available: ${value}`);\n }\n const fieldName = extractKeywordValue(value) || '';\n return rootRecord.Get(fieldName);\n }\n\n // Check for @file: reference\n if (value.startsWith(METADATA_KEYWORDS.FILE)) {\n const filePath = extractKeywordValue(value) as string;\n const fullPath = path.resolve(baseDir, filePath);\n \n if (await fs.pathExists(fullPath)) {\n // Check if this is a JSON file that might contain @include directives\n if (fullPath.endsWith('.json')) {\n try {\n // Parse as JSON and check for @include directives\n const jsonContent = await fs.readJson(fullPath);\n \n // Check if the JSON contains any @include directives\n const jsonString = JSON.stringify(jsonContent);\n const hasIncludes = jsonString.includes('\"@include') || jsonString.includes('\"@include.');\n \n let processedJson: any;\n if (hasIncludes) {\n // Process @include directives with a fresh preprocessor instance\n const preprocessor = new JsonPreprocessor();\n processedJson = await preprocessor.processFile(fullPath);\n } else {\n processedJson = jsonContent;\n }\n \n // Now recursively process any @file references within the JSON\n const fileDir = path.dirname(fullPath);\n processedJson = await this.processJsonFieldValues(processedJson, fileDir, parentRecord, rootRecord, depth + 1, batchContext);\n \n // Return the processed JSON object directly without stringifying\n // Let BaseEntity handle serialization when saving to database\n // This ensures proper escaping of embedded code/scripts\n return processedJson;\n } catch (jsonError) {\n // Not valid JSON or error processing, fall back to text file handling\n const fileContent = await fs.readFile(fullPath, 'utf-8');\n // Process the file content for {@include} references in text files\n return await this.processFileContentWithIncludes(fileContent, fullPath);\n }\n } else {\n // Not a JSON file, process as text with {@include} support\n const fileContent = await fs.readFile(fullPath, 'utf-8');\n // Process the file content for {@include} references\n return await this.processFileContentWithIncludes(fileContent, fullPath);\n }\n } else {\n throw new Error(`File not found: ${fullPath}`);\n }\n }\n \n // Check for @url: reference\n if (value.startsWith(METADATA_KEYWORDS.URL)) {\n const url = extractKeywordValue(value) as string;\n \n try {\n const response = await axios.get(url);\n return response.data;\n } catch (error) {\n throw new Error(`Failed to fetch URL: ${url} - ${error}`);\n }\n }\n \n // Check for @lookup: reference\n if (value.startsWith(METADATA_KEYWORDS.LOOKUP)) {\n const lookupStr = extractKeywordValue(value) as string;\n \n // Parse lookup with optional create syntax\n // Format: EntityName.Field1=Value1&Field2=Value2?create&OtherField=Value\n const entityMatch = lookupStr.match(/^([^.]+)\\./);\n if (!entityMatch) {\n throw new Error(`Invalid lookup format: ${value}`);\n }\n \n const entityName = entityMatch[1];\n const remaining = lookupStr.substring(entityName.length + 1);\n \n // Check if this has ?create syntax\n const hasCreate = remaining.includes('?create');\n const lookupPart = hasCreate ? remaining.split('?')[0] : remaining;\n \n // Parse all lookup fields (can be multiple with &)\n const lookupFields: Array<{fieldName: string, fieldValue: string}> = [];\n const lookupPairs = lookupPart.split('&');\n \n for (const pair of lookupPairs) {\n const fieldMatch = pair.match(/^(.+?)=(.+)$/);\n if (!fieldMatch) {\n throw new Error(`Invalid lookup field format: ${pair} in ${value}`);\n }\n const [, fieldName, fieldValue] = fieldMatch;\n \n // Recursively process the field value to resolve any nested @ commands\n const processedValue = await this.processFieldValue(\n fieldValue.trim(), \n baseDir, \n parentRecord, \n rootRecord,\n depth + 1,\n batchContext\n );\n \n lookupFields.push({ fieldName: fieldName.trim(), fieldValue: processedValue });\n }\n \n if (lookupFields.length === 0) {\n throw new Error(`No lookup fields specified: ${value}`);\n }\n \n // Parse additional fields for creation if ?create is present\n let createFields: Record<string, any> = {};\n if (hasCreate && remaining.includes('?create&')) {\n const createPart = remaining.split('?create&')[1];\n const pairs = createPart.split('&');\n for (const pair of pairs) {\n const [key, val] = pair.split('=');\n if (key && val) {\n const decodedVal = decodeURIComponent(val);\n // Recursively process the field value to resolve any nested @ commands\n createFields[key] = await this.processFieldValue(\n decodedVal, \n baseDir, \n parentRecord, \n rootRecord,\n depth + 1,\n batchContext\n );\n }\n }\n }\n \n return await this.resolveLookup(entityName, lookupFields, hasCreate, createFields, batchContext);\n }\n \n // Check for @env: reference\n if (value.startsWith(METADATA_KEYWORDS.ENV)) {\n const envVar = extractKeywordValue(value) as string;\n const envValue = process.env[envVar];\n \n if (envValue === undefined) {\n throw new Error(`Environment variable not found: ${envVar}`);\n }\n \n return envValue;\n }\n \n return value;\n }\n \n /**\n * Resolve a lookup reference to an ID, optionally creating the record if it doesn't exist\n * \n * @param entityName - Name of the entity to search in\n * @param fieldName - Field to match against\n * @param fieldValue - Value to search for\n * @param autoCreate - Whether to create the record if not found\n * @param createFields - Additional fields to set when creating\n * @returns The ID of the found or created record\n * @throws Error if lookup fails and autoCreate is false\n * \n * @example\n * ```typescript\n * // Simple lookup\n * const categoryId = await resolveLookup('Categories', 'Name', 'Technology');\n * \n * // Lookup with auto-create\n * const tagId = await resolveLookup('Tags', 'Name', 'New Tag', true, {\n * Description: 'Auto-created tag',\n * Status: 'Active'\n * });\n * ```\n */\n async resolveLookup(\n entityName: string, \n lookupFields: Array<{fieldName: string, fieldValue: string}>,\n autoCreate: boolean = false,\n createFields: Record<string, any> = {},\n batchContext?: Map<string, BaseEntity>\n ): Promise<string> {\n // First check batch context for in-memory entities\n if (batchContext) {\n // Try to find the entity in batch context\n for (const [, entity] of batchContext) {\n // Check if this is the right entity type\n if (entity.EntityInfo?.Name === entityName) {\n // Check if all lookup fields match\n let allMatch = true;\n for (const {fieldName, fieldValue} of lookupFields) {\n const entityValue = entity.Get(fieldName);\n const normalizedEntityValue = entityValue?.toString() || '';\n const normalizedLookupValue = fieldValue?.toString() || '';\n \n if (normalizedEntityValue !== normalizedLookupValue) {\n allMatch = false;\n break;\n }\n }\n \n if (allMatch) {\n // Found in batch context, return primary key\n const entityInfo = this.metadata.EntityByName(entityName);\n if (entityInfo && entityInfo.PrimaryKeys.length > 0) {\n const pkeyField = entityInfo.PrimaryKeys[0].Name;\n return entity.Get(pkeyField);\n }\n }\n }\n }\n }\n \n // Not found in batch context, check database\n const rv = new RunView();\n const entityInfo = this.metadata.EntityByName(entityName);\n if (!entityInfo) {\n throw new Error(`Entity not found: ${entityName}`);\n }\n \n // Build compound filter for all lookup fields\n const filterParts: string[] = [];\n for (const {fieldName, fieldValue} of lookupFields) {\n const field = entityInfo.Fields.find(f => f.Name.trim().toLowerCase() === fieldName.trim().toLowerCase());\n if (!field) {\n throw new Error(`Field '${fieldName}' not found in entity '${entityName}'`);\n }\n \n // Handle null values properly\n if (fieldValue.trim().toLowerCase() === 'null') {\n filterParts.push(`${fieldName} IS NULL`);\n } else {\n const quotes = field.NeedsQuotes ? \"'\" : '';\n filterParts.push(`${fieldName} = ${quotes}${fieldValue.replace(/'/g, \"''\")}${quotes}`);\n }\n }\n \n const extraFilter = filterParts.join(' AND ');\n const result = await rv.RunView({\n EntityName: entityName,\n ExtraFilter: extraFilter,\n MaxRows: 1\n }, this.contextUser);\n \n if (result.Success && result.Results.length > 0) {\n if (entityInfo.PrimaryKeys.length > 0) {\n const pkeyField = entityInfo.PrimaryKeys[0].Name;\n const id = result.Results[0][pkeyField];\n return id;\n }\n }\n \n // If not found and auto-create is enabled, create the record\n if (autoCreate) {\n \n const newEntity = await this.metadata.GetEntityObject(entityName, this.contextUser);\n if (!newEntity) {\n throw new Error(`Failed to create entity object for: ${entityName}`);\n }\n \n newEntity.NewRecord();\n \n // UUID generation now happens automatically in BaseEntity.NewRecord()\n \n // Set all lookup fields\n for (const {fieldName, fieldValue} of lookupFields) {\n if (fieldName in newEntity) {\n // Handle null values properly\n if (fieldValue.toLowerCase() === 'null') {\n (newEntity as any)[fieldName] = null;\n } else {\n (newEntity as any)[fieldName] = fieldValue;\n }\n }\n }\n \n // Set any additional fields provided\n for (const [key, value] of Object.entries(createFields)) {\n if (key in newEntity) {\n (newEntity as any)[key] = value;\n }\n }\n \n // Save the new record (new records are always dirty)\n const filterDesc = lookupFields.map(({fieldName, fieldValue}) => `${fieldName}='${fieldValue}'`).join(' AND ');\n console.log(`📝 Auto-creating ${entityName} record where ${filterDesc}`);\n const saved = await newEntity.Save();\n if (!saved) {\n const message = newEntity.LatestResult?.Message;\n if (message) {\n throw new Error(`Failed to auto-create ${entityName}: ${message}`);\n }\n \n const errors = newEntity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || 'Unknown error';\n throw new Error(`Failed to auto-create ${entityName}: ${errors}`);\n }\n \n // Return the new ID\n if (entityInfo.PrimaryKeys.length > 0) {\n const pkeyField = entityInfo.PrimaryKeys[0].Name;\n const newId = newEntity.Get(pkeyField);\n return newId;\n }\n }\n \n const filterDesc = lookupFields.map(({fieldName, fieldValue}) => `${fieldName}='${fieldValue}'`).join(' AND ');\n throw new Error(`Lookup failed: No record found in '${entityName}' where ${filterDesc}`);\n }\n \n /**\n * Build cascading defaults for a file path and process field values\n * \n * Walks up the directory tree from the file location, collecting defaults from\n * entity config and folder configs, with deeper folders overriding parent values.\n * All default values are processed for special references.\n * \n * @param filePath - Path to the file being processed\n * @param entityConfig - Entity configuration containing base defaults\n * @returns Processed defaults with all references resolved\n * @throws Error if any default value processing fails\n */\n async buildDefaults(filePath: string, entityConfig: EntityConfig): Promise<Record<string, any>> {\n const parts = path.dirname(filePath).split(path.sep);\n let defaults: Record<string, any> = { ...entityConfig.defaults };\n \n // Walk up the directory tree building defaults\n let currentPath = '';\n for (const part of parts) {\n currentPath = path.join(currentPath, part);\n const folderConfig = await this.loadFolderConfig(currentPath);\n \n if (folderConfig?.defaults) {\n defaults = { ...defaults, ...folderConfig.defaults };\n }\n }\n \n // Process all default values (lookups, file references, etc.)\n const processedDefaults: Record<string, any> = {};\n const baseDir = path.dirname(filePath);\n \n for (const [field, value] of Object.entries(defaults)) {\n try {\n processedDefaults[field] = await this.processFieldValue(value, baseDir, null, null, 0);\n } catch (error) {\n throw new Error(`Failed to process default for field '${field}': ${error}`);\n }\n }\n \n return processedDefaults;\n }\n \n /**\n * Load folder configuration from .mj-folder.json file\n * \n * @param dir - Directory to check for configuration\n * @returns Folder configuration or null if not found/invalid\n * @private\n */\n private async loadFolderConfig(dir: string): Promise<FolderConfig | null> {\n const configPath = path.join(dir, '.mj-folder.json');\n \n if (await fs.pathExists(configPath)) {\n try {\n return await fs.readJson(configPath);\n } catch (error) {\n console.error(`Error loading folder config at ${configPath}:`, error);\n return null;\n }\n }\n \n return null;\n }\n \n /**\n * Calculate SHA256 checksum for data\n * \n * Generates a deterministic hash of the provided data by converting it to\n * formatted JSON and calculating a SHA256 digest. Used for change detection\n * in sync operations.\n * \n * @param data - Any data structure to calculate checksum for\n * @returns Hexadecimal string representation of the SHA256 hash\n * \n * @example\n * ```typescript\n * const checksum = syncEngine.calculateChecksum({\n * name: 'Test Record',\n * value: 42,\n * tags: ['a', 'b']\n * });\n * // Returns consistent hash for same data structure\n * ```\n */\n calculateChecksum(data: any): string {\n const hash = crypto.createHash('sha256');\n hash.update(JSON.stringify(data, null, 2));\n return hash.digest('hex');\n }\n\n /**\n * Calculate checksum including resolved file content\n * \n * Enhanced checksum calculation that resolves @file references and includes\n * the actual file content (with @include directives processed) in the checksum.\n * This ensures that changes to referenced files are detected.\n * \n * @param data - Fields object that may contain @file references\n * @param entityDir - Directory for resolving relative file paths\n * @returns Promise resolving to checksum string\n */\n async calculateChecksumWithFileContent(data: any, entityDir: string): Promise<string> {\n const processedData = await this.resolveFileReferencesForChecksum(data, entityDir);\n return this.calculateChecksum(processedData);\n }\n\n /**\n * Resolve @file references for checksum calculation\n * \n * Recursively processes an object and replaces @file references with their\n * actual content (including resolved @include directives). This ensures the\n * checksum reflects the actual content, not just the reference.\n * \n * @param obj - Object to process\n * @param entityDir - Directory for resolving relative paths\n * @returns Promise resolving to processed object\n * @private\n */\n private async resolveFileReferencesForChecksum(obj: any, entityDir: string): Promise<any> {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return Promise.all(obj.map(item => this.resolveFileReferencesForChecksum(item, entityDir)));\n }\n\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === 'string' && value.startsWith(METADATA_KEYWORDS.FILE)) {\n // Process @file reference and include actual content\n try {\n const filePath = extractKeywordValue(value) as string;\n const fullPath = path.isAbsolute(filePath) ? filePath : path.join(entityDir, filePath);\n \n if (await fs.pathExists(fullPath)) {\n let processedContent: string;\n \n // Check if this is a JSON file that might contain @include directives\n if (fullPath.endsWith('.json')) {\n try {\n const jsonContent = await fs.readJson(fullPath);\n const jsonString = JSON.stringify(jsonContent);\n const hasIncludes = jsonString.includes('\"@include') || jsonString.includes('\"@include.');\n \n if (hasIncludes) {\n // Process @include directives\n const preprocessor = new JsonPreprocessor();\n const processedJson = await preprocessor.processFile(fullPath);\n processedContent = JSON.stringify(processedJson, null, 2);\n } else {\n processedContent = JSON.stringify(jsonContent, null, 2);\n }\n } catch {\n // Not valid JSON, process as text\n const content = await fs.readFile(fullPath, 'utf-8');\n processedContent = await this.processFileContentWithIncludes(content, fullPath);\n }\n } else {\n // Text file - process {@include} references\n const content = await fs.readFile(fullPath, 'utf-8');\n processedContent = await this.processFileContentWithIncludes(content, fullPath);\n }\n \n result[key] = {\n _checksumType: 'file',\n _reference: value,\n _content: processedContent\n };\n } else {\n // File doesn't exist, keep the reference\n result[key] = value;\n }\n } catch (error) {\n // Error reading file, keep the reference\n result[key] = value;\n }\n } else if (typeof value === 'object') {\n result[key] = await this.resolveFileReferencesForChecksum(value, entityDir);\n } else {\n result[key] = value;\n }\n }\n return result;\n }\n \n /**\n * Get entity metadata information by name\n * \n * Retrieves the EntityInfo object containing schema metadata for the specified entity.\n * Returns null if the entity is not found in the metadata cache.\n * \n * @param entityName - Name of the entity to look up\n * @returns EntityInfo object with schema details or null if not found\n * \n * @example\n * ```typescript\n * const entityInfo = syncEngine.getEntityInfo('AI Prompts');\n * if (entityInfo) {\n * console.log(`Primary keys: ${entityInfo.PrimaryKeys.map(pk => pk.Name).join(', ')}`);\n * }\n * ```\n */\n getEntityInfo(entityName: string): EntityInfo | null {\n return this.metadata.EntityByName(entityName);\n }\n \n /**\n * Create a new entity object instance\n * \n * Uses the MemberJunction metadata system to properly instantiate an entity object.\n * This ensures correct class registration and respects any custom entity subclasses.\n * \n * @param entityName - Name of the entity to create\n * @returns Promise resolving to the new BaseEntity instance\n * @throws Error if entity creation fails\n * \n * @example\n * ```typescript\n * const entity = await syncEngine.createEntityObject('AI Prompts');\n * entity.NewRecord();\n * entity.Set('Name', 'My Prompt');\n * await entity.Save();\n * ```\n */\n async createEntityObject(entityName: string): Promise<BaseEntity> {\n const entity = await this.metadata.GetEntityObject(entityName, this.contextUser);\n if (!entity) {\n throw new Error(`Failed to create entity object for: ${entityName}`);\n }\n return entity;\n }\n \n /**\n * Load an entity record by primary key\n * \n * Retrieves an existing entity record from the database using its primary key values.\n * Supports both single and composite primary keys. Returns null if the record is not found.\n * \n * @param entityName - Name of the entity to load\n * @param primaryKey - Object containing primary key field names and values\n * @returns Promise resolving to the loaded entity or null if not found\n * @throws Error if entity metadata is not found\n * \n * @example\n * ```typescript\n * // Single primary key\n * const entity = await syncEngine.loadEntity('Users', { ID: '123-456' });\n * \n * // Composite primary key\n * const entity = await syncEngine.loadEntity('UserRoles', { \n * UserID: '123-456',\n * RoleID: '789-012'\n * });\n * ```\n */\n async loadEntity(entityName: string, primaryKey: Record<string, any>): Promise<BaseEntity | null> {\n const entityInfo = this.getEntityInfo(entityName);\n \n if (!entityInfo) {\n throw new Error(`Entity not found: ${entityName}`);\n }\n \n // First, check if the record exists using RunView to avoid \"Error in BaseEntity.Load\" messages\n // when records don't exist (which is a normal scenario during sync operations)\n const rv = new RunView();\n \n // Build filter for primary key(s)\n const filters: string[] = [];\n for (const pk of entityInfo.PrimaryKeys) {\n const value = primaryKey[pk.Name];\n if (value === undefined || value === null) {\n throw new Error(`Missing primary key value for ${pk.Name} in entity ${entityName}`);\n }\n \n // Check if field needs quotes\n const field = entityInfo.Fields.find(f => f.Name === pk.Name);\n const quotes = field?.NeedsQuotes ? \"'\" : '';\n const escapedValue = field?.NeedsQuotes && typeof value === 'string' ? value.replace(/'/g, \"''\") : value;\n filters.push(`${pk.Name} = ${quotes}${escapedValue}${quotes}`);\n }\n \n const result = await rv.RunView({\n EntityName: entityName,\n ExtraFilter: filters.join(' AND '),\n MaxRows: 1\n }, this.contextUser);\n \n // If no record found, return null without attempting to load\n if (!result.Success || result.Results.length === 0) {\n return null;\n }\n \n // Record exists, now load it properly through the entity\n const entity = await this.createEntityObject(entityName);\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromSimpleObject(primaryKey);\n const loaded = await entity.InnerLoad(compositeKey);\n \n return loaded ? entity : null;\n }\n \n /**\n * Process file content with {@include} references\n * \n * Recursively processes a file's content to resolve `{@include path}` references.\n * Include references use JSDoc-style syntax and support:\n * - Relative paths resolved from the containing file's directory\n * - Recursive includes (includes within included files)\n * - Circular reference detection to prevent infinite loops\n * - Seamless content substitution maintaining surrounding text\n * \n * @param content - The file content to process\n * @param filePath - Path to the file being processed\n * @param visitedPaths - Set of already visited file paths for circular reference detection\n * @returns Promise resolving to the content with all includes resolved\n * @throws Error if circular reference detected or included file not found\n * \n * @example\n * ```typescript\n * // Content with include reference\n * const content = 'This is a {@include ./shared/header.md} example';\n * \n * // Resolves to:\n * const result = await processFileContentWithIncludes('/path/to/file.md', content);\n * // 'This is a [contents of header.md] example'\n * ```\n */\n private async processFileContentWithIncludes(\n content: string,\n filePath: string, \n visitedPaths: Set<string> = new Set()\n ): Promise<string> {\n // Add current file to visited set\n const absolutePath = path.resolve(filePath);\n if (visitedPaths.has(absolutePath)) {\n throw new Error(`Circular reference detected: ${absolutePath} is already being processed`);\n }\n visitedPaths.add(absolutePath);\n \n // Pattern to match {@include path} references\n // Supports whitespace around the path for flexibility\n const includePattern = /\\{@include\\s+([^\\}]+)\\s*\\}/g;\n \n let processedContent = content;\n let match: RegExpExecArray | null;\n \n // Process all {@include} references\n while ((match = includePattern.exec(content)) !== null) {\n const [fullMatch, includePath] = match;\n const trimmedPath = includePath.trim();\n \n // Resolve the include path relative to the current file's directory\n const currentDir = path.dirname(filePath);\n const resolvedPath = path.resolve(currentDir, trimmedPath);\n \n try {\n // Check if the included file exists\n if (!await fs.pathExists(resolvedPath)) {\n throw new Error(`Included file not found: ${resolvedPath}`);\n }\n \n // Read the included file\n const includedContent = await fs.readFile(resolvedPath, 'utf-8');\n \n // Recursively process the included content for nested includes\n const processedInclude = await this.processFileContentWithIncludes(\n includedContent,\n resolvedPath, \n new Set(visitedPaths) // Pass a copy to allow the same file in different branches\n );\n \n // Replace the {@include} reference with the processed content\n processedContent = processedContent.replace(fullMatch, processedInclude);\n } catch (error) {\n // Enhance error message with context\n throw new Error(`Failed to process {@include ${trimmedPath}} in ${filePath}: ${error}`);\n }\n }\n \n return processedContent;\n }\n\n /**\n * Recursively process field values in a JSON object\n * \n * Processes all string values in a JSON object through processFieldValue,\n * which handles @file, @lookup, @parent, @root references. This ensures\n * that nested @file references within JSON files are properly resolved.\n * \n * @param obj - JSON object to process\n * @param baseDir - Base directory for resolving relative file paths\n * @param parentRecord - Parent entity record for @parent references\n * @param rootRecord - Root entity record for @root references\n * @param depth - Current recursion depth\n * @param batchContext - Batch processing context\n * @returns Promise resolving to processed JSON object\n * @private\n */\n private async processJsonFieldValues(\n obj: any,\n baseDir: string,\n parentRecord?: BaseEntity | null,\n rootRecord?: BaseEntity | null,\n depth: number = 0,\n batchContext?: Map<string, BaseEntity>\n ): Promise<any> {\n // Handle null and undefined\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return Promise.all(\n obj.map(item => \n this.processJsonFieldValues(item, baseDir, parentRecord, rootRecord, depth, batchContext)\n )\n );\n }\n\n // Handle objects\n if (typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n // Process string values that might contain references\n if (typeof value === 'string') {\n // Check if this looks like a reference that needs processing\n // Only process known reference types, ignore other @ strings (like npm packages)\n if (isMetadataKeyword(value)) {\n result[key] = await this.processFieldValue(value, baseDir, parentRecord, rootRecord, depth, batchContext);\n } else {\n result[key] = value;\n }\n } else if (typeof value === 'object') {\n // Recursively process nested objects\n result[key] = await this.processJsonFieldValues(value, baseDir, parentRecord, rootRecord, depth, batchContext);\n } else {\n // Keep primitive values as-is\n result[key] = value;\n }\n }\n return result;\n }\n\n // Return primitive values as-is\n return obj;\n }\n \n}"]}
1
+ {"version":3,"file":"sync-engine.js","sourceRoot":"","sources":["../../src/lib/sync-engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;AAEH,gDAAwB;AACxB,wDAA0B;AAC1B,oDAA4B;AAC5B,kDAA0B;AAC1B,+CAAyG;AAEzG,2DAAuD;AACvD,sEAMwC;AAExC;;;;GAIG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,sCAAsC;IACtB,UAAU,CAAS;IACnC,+CAA+C;IAC/B,YAAY,CAAiD;IAC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**\n * @fileoverview Core synchronization engine for MemberJunction metadata\n * @module sync-engine\n * \n * This module provides the core functionality for synchronizing metadata between\n * the MemberJunction database and local file system representations. It handles\n * special reference types (@file, @url, @lookup, @env, @parent, @root, @template),\n * manages entity operations, and provides utilities for data transformation.\n */\n\nimport path from 'path';\nimport fs from 'fs-extra';\nimport crypto from 'crypto';\nimport axios from 'axios';\nimport { EntityInfo, Metadata, RunView, BaseEntity, CompositeKey, UserInfo } from '@memberjunction/core';\nimport { EntityConfig, FolderConfig } from '../config';\nimport { JsonPreprocessor } from './json-preprocessor';\nimport {\n METADATA_KEYWORDS,\n METADATA_KEYWORD_PREFIXES,\n isMetadataKeyword,\n isNonKeywordAtSymbol,\n extractKeywordValue\n} from '../constants/metadata-keywords';\n\n/**\n * Custom error class for lookup failures that can be deferred.\n * When a lookup with `?allowDefer` flag fails, this error is thrown instead of a regular Error.\n * The calling code can catch this specific error type and queue the lookup for later retry.\n */\nexport class DeferrableLookupError extends Error {\n /** The entity name being looked up */\n public readonly entityName: string;\n /** The lookup fields and values that failed */\n public readonly lookupFields: Array<{fieldName: string, fieldValue: string}>;\n /** The original lookup string value */\n public readonly originalValue: string;\n /** The field name where this lookup was used */\n public readonly targetFieldName?: string;\n\n constructor(\n message: string,\n entityName: string,\n lookupFields: Array<{fieldName: string, fieldValue: string}>,\n originalValue: string,\n targetFieldName?: string\n ) {\n super(message);\n this.name = 'DeferrableLookupError';\n this.entityName = entityName;\n this.lookupFields = lookupFields;\n this.originalValue = originalValue;\n this.targetFieldName = targetFieldName;\n\n // Maintains proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, DeferrableLookupError.prototype);\n }\n}\n\n/**\n * Represents the structure of a metadata record with optional sync tracking\n */\nexport interface RecordData {\n /** Primary key field(s) and their values */\n primaryKey?: Record<string, any>;\n /** Entity field names and their values */\n fields: Record<string, any>;\n /** Related entities organized by entity name */\n relatedEntities?: Record<string, RecordData[]>;\n /** Synchronization metadata for change tracking */\n sync?: {\n /** ISO timestamp of last modification */\n lastModified: string;\n /** SHA256 checksum of the fields object */\n checksum: string;\n };\n /** Delete record directive for removing records from the database */\n deleteRecord?: {\n /** Flag to indicate this record should be deleted */\n delete: boolean;\n /** ISO timestamp of when the deletion was performed */\n deletedAt?: string;\n /** Flag to indicate the record was not found when attempting deletion */\n notFound?: boolean;\n };\n}\n\n/**\n * Core engine for synchronizing MemberJunction metadata between database and files\n * \n * @class SyncEngine\n * @example\n * ```typescript\n * const syncEngine = new SyncEngine(systemUser);\n * \n * // Process a field value with special references\n * const value = await syncEngine.processFieldValue('@lookup:Users.Email=admin@example.com', '/path/to/base');\n * ```\n */\nexport class SyncEngine {\n private metadata: Metadata;\n private contextUser: UserInfo;\n\n /**\n * Creates a new SyncEngine instance\n * @param contextUser - The user context for database operations\n */\n constructor(contextUser: UserInfo) {\n this.metadata = new Metadata();\n this.contextUser = contextUser;\n }\n \n /**\n * Initializes the sync engine by refreshing metadata cache\n * @returns Promise that resolves when initialization is complete\n */\n async initialize(): Promise<void> {\n // Currently no initialization needed as metadata is managed globally\n // Keeping this method for backward compatibility and future use\n }\n \n /**\n * Process special references in field values and handle complex objects\n * \n * Automatically handles:\n * - Arrays and objects are converted to JSON strings\n * - Scalars (strings, numbers, booleans, null) pass through unchanged\n * \n * Handles the following reference types for string values:\n * - `@parent:fieldName` - References a field from the parent record\n * - `@root:fieldName` - References a field from the root record\n * - `@file:path` - Reads content from an external file\n * - `@url:address` - Fetches content from a URL\n * - `@lookup:Entity.Field=Value` - Looks up an entity ID by field value\n * - `@env:VARIABLE` - Reads an environment variable\n * \n * @param value - The field value to process\n * @param baseDir - Base directory for resolving relative file paths\n * @param parentRecord - Optional parent entity for @parent references\n * @param rootRecord - Optional root entity for @root references\n * @returns The processed value with all references resolved\n * @throws Error if a reference cannot be resolved\n * \n * @example\n * ```typescript\n * // File reference\n * const content = await processFieldValue('@file:template.md', '/path/to/dir');\n * \n * // Lookup with auto-create\n * const userId = await processFieldValue('@lookup:Users.Email=john@example.com?create', '/path');\n * \n * // Complex object - automatically stringified\n * const jsonStr = await processFieldValue({items: [{id: 1}, {id: 2}]}, '/path');\n * // Returns: '{\\n \"items\": [\\n {\\n \"id\": 1\\n },\\n {\\n \"id\": 2\\n }\\n ]\\n}'\n * ```\n */\n async processFieldValue(value: any, baseDir: string, parentRecord?: BaseEntity | null, rootRecord?: BaseEntity | null, depth: number = 0, batchContext?: Map<string, BaseEntity>): Promise<any> {\n // Check recursion depth limit\n const MAX_RECURSION_DEPTH = 50;\n if (depth > MAX_RECURSION_DEPTH) {\n throw new Error(`Maximum recursion depth (${MAX_RECURSION_DEPTH}) exceeded while processing field value: ${value}`);\n }\n // Handle arrays and objects that are directly defined in metadata files\n // Note: Objects loaded from @file references are returned as-is to preserve proper escaping\n if (value !== null && typeof value === 'object') {\n // Check if it's an array or a plain object (not a Date, etc.)\n if (Array.isArray(value) || value.constructor === Object) {\n // First recursively process any @lookup, @file, @parent references inside the object\n const processedValue = await this.processJsonFieldValues(value, baseDir, parentRecord, rootRecord, depth, batchContext);\n // Then convert to pretty-printed JSON string for inline metadata objects\n // Objects from @file references will be handled by BaseEntity during save\n return JSON.stringify(processedValue, null, 2);\n }\n }\n \n // If not a string, return as-is (numbers, booleans, null, etc.)\n if (typeof value !== 'string') {\n return value;\n }\n \n // If string starts with @ but isn't one of our known reference types, return as-is\n // This handles cases like npm package names (@mui/material, @angular/core, etc.)\n if (isNonKeywordAtSymbol(value)) {\n return value; // Not a MetadataSync reference, just a string that happens to start with @\n }\n \n // Check for @parent: reference\n if (value.startsWith(METADATA_KEYWORDS.PARENT)) {\n if (!parentRecord) {\n throw new Error(`@parent reference used but no parent record available: ${value}`);\n }\n const fieldName = extractKeywordValue(value) || '';\n return parentRecord.Get(fieldName);\n }\n\n // Check for @root: reference\n if (value.startsWith(METADATA_KEYWORDS.ROOT)) {\n if (!rootRecord) {\n throw new Error(`@root reference used but no root record available: ${value}`);\n }\n const fieldName = extractKeywordValue(value) || '';\n return rootRecord.Get(fieldName);\n }\n\n // Check for @file: reference\n if (value.startsWith(METADATA_KEYWORDS.FILE)) {\n const filePath = extractKeywordValue(value) as string;\n const fullPath = path.resolve(baseDir, filePath);\n \n if (await fs.pathExists(fullPath)) {\n // Check if this is a JSON file that might contain @include directives\n if (fullPath.endsWith('.json')) {\n try {\n // Parse as JSON and check for @include directives\n const jsonContent = await fs.readJson(fullPath);\n \n // Check if the JSON contains any @include directives\n const jsonString = JSON.stringify(jsonContent);\n const hasIncludes = jsonString.includes('\"@include') || jsonString.includes('\"@include.');\n \n let processedJson: any;\n if (hasIncludes) {\n // Process @include directives with a fresh preprocessor instance\n const preprocessor = new JsonPreprocessor();\n processedJson = await preprocessor.processFile(fullPath);\n } else {\n processedJson = jsonContent;\n }\n \n // Now recursively process any @file references within the JSON\n const fileDir = path.dirname(fullPath);\n processedJson = await this.processJsonFieldValues(processedJson, fileDir, parentRecord, rootRecord, depth + 1, batchContext);\n \n // Return the processed JSON object directly without stringifying\n // Let BaseEntity handle serialization when saving to database\n // This ensures proper escaping of embedded code/scripts\n return processedJson;\n } catch (jsonError) {\n // Not valid JSON or error processing, fall back to text file handling\n const fileContent = await fs.readFile(fullPath, 'utf-8');\n // Process the file content for {@include} references in text files\n return await this.processFileContentWithIncludes(fileContent, fullPath);\n }\n } else {\n // Not a JSON file, process as text with {@include} support\n const fileContent = await fs.readFile(fullPath, 'utf-8');\n // Process the file content for {@include} references\n return await this.processFileContentWithIncludes(fileContent, fullPath);\n }\n } else {\n throw new Error(`File not found: ${fullPath}`);\n }\n }\n \n // Check for @url: reference\n if (value.startsWith(METADATA_KEYWORDS.URL)) {\n const url = extractKeywordValue(value) as string;\n \n try {\n const response = await axios.get(url);\n return response.data;\n } catch (error) {\n throw new Error(`Failed to fetch URL: ${url} - ${error}`);\n }\n }\n \n // Check for @lookup: reference\n if (value.startsWith(METADATA_KEYWORDS.LOOKUP)) {\n const lookupStr = extractKeywordValue(value) as string;\n\n // Parse lookup with optional flags: ?create, ?allowDefer\n // Format: EntityName.Field1=Value1&Field2=Value2?create&allowDefer&OtherField=Value\n const entityMatch = lookupStr.match(/^([^.]+)\\./);\n if (!entityMatch) {\n throw new Error(`Invalid lookup format: ${value}`);\n }\n\n const entityName = entityMatch[1];\n const remaining = lookupStr.substring(entityName.length + 1);\n\n // Split into lookup part and flags part\n const questionMarkIndex = remaining.indexOf('?');\n const lookupPart = questionMarkIndex >= 0 ? remaining.substring(0, questionMarkIndex) : remaining;\n const flagsPart = questionMarkIndex >= 0 ? remaining.substring(questionMarkIndex + 1) : '';\n\n // Parse flags from the query string portion\n const flags = new Set(flagsPart.split('&').map(f => f.split('=')[0].toLowerCase()));\n const hasCreate = flags.has('create');\n const allowDefer = flags.has('allowdefer');\n\n // Parse all lookup fields (can be multiple with &)\n const lookupFields: Array<{fieldName: string, fieldValue: string}> = [];\n const lookupPairs = lookupPart.split('&');\n\n for (const pair of lookupPairs) {\n const fieldMatch = pair.match(/^(.+?)=(.+)$/);\n if (!fieldMatch) {\n throw new Error(`Invalid lookup field format: ${pair} in ${value}`);\n }\n const [, fieldName, fieldValue] = fieldMatch;\n\n // Recursively process the field value to resolve any nested @ commands\n const processedValue = await this.processFieldValue(\n fieldValue.trim(),\n baseDir,\n parentRecord,\n rootRecord,\n depth + 1,\n batchContext\n );\n\n lookupFields.push({ fieldName: fieldName.trim(), fieldValue: processedValue });\n }\n\n if (lookupFields.length === 0) {\n throw new Error(`No lookup fields specified: ${value}`);\n }\n\n // Parse additional fields for creation if ?create is present\n // These are key=value pairs after the flags (e.g., ?create&Description=Some%20Value)\n let createFields: Record<string, any> = {};\n if (hasCreate && flagsPart) {\n const flagPairs = flagsPart.split('&');\n for (const pair of flagPairs) {\n // Skip known flags\n if (pair.toLowerCase() === 'create' || pair.toLowerCase() === 'allowdefer') {\n continue;\n }\n const [key, val] = pair.split('=');\n if (key && val) {\n const decodedVal = decodeURIComponent(val);\n // Recursively process the field value to resolve any nested @ commands\n createFields[key] = await this.processFieldValue(\n decodedVal,\n baseDir,\n parentRecord,\n rootRecord,\n depth + 1,\n batchContext\n );\n }\n }\n }\n\n return await this.resolveLookup(entityName, lookupFields, hasCreate, createFields, batchContext, allowDefer, value);\n }\n \n // Check for @env: reference\n if (value.startsWith(METADATA_KEYWORDS.ENV)) {\n const envVar = extractKeywordValue(value) as string;\n const envValue = process.env[envVar];\n \n if (envValue === undefined) {\n throw new Error(`Environment variable not found: ${envVar}`);\n }\n \n return envValue;\n }\n \n return value;\n }\n \n /**\n * Resolve a lookup reference to an ID, optionally creating the record if it doesn't exist\n * \n * @param entityName - Name of the entity to search in\n * @param fieldName - Field to match against\n * @param fieldValue - Value to search for\n * @param autoCreate - Whether to create the record if not found\n * @param createFields - Additional fields to set when creating\n * @param batchContext - Optional batch context for in-memory entity resolution\n * @param allowDefer - If true, throws DeferrableLookupError on failure instead of regular Error\n * @param originalValue - Original lookup string (for error context in deferred lookups)\n * @returns The ID of the found or created record\n * @throws Error if lookup fails and autoCreate is false and allowDefer is false\n * @throws DeferrableLookupError if lookup fails and allowDefer is true\n *\n * @example\n * ```typescript\n * // Simple lookup\n * const categoryId = await resolveLookup('Categories', [{ fieldName: 'Name', fieldValue: 'Technology' }]);\n *\n * // Lookup with auto-create\n * const tagId = await resolveLookup('Tags', [{ fieldName: 'Name', fieldValue: 'New Tag' }], true, {\n * Description: 'Auto-created tag',\n * Status: 'Active'\n * });\n *\n * // Lookup with allowDefer - will throw DeferrableLookupError on failure\n * try {\n * const id = await resolveLookup('Dashboards', [{ fieldName: 'Name', fieldValue: 'My Dashboard' }],\n * false, {}, batchContext, true, '@lookup:Dashboards.Name=My Dashboard?allowDefer');\n * } catch (e) {\n * if (e instanceof DeferrableLookupError) {\n * // Queue for later retry\n * }\n * }\n * ```\n */\n async resolveLookup(\n entityName: string,\n lookupFields: Array<{fieldName: string, fieldValue: string}>,\n autoCreate: boolean = false,\n createFields: Record<string, any> = {},\n batchContext?: Map<string, BaseEntity>,\n allowDefer: boolean = false,\n originalValue?: string\n ): Promise<string> {\n // First check batch context for in-memory entities\n if (batchContext) {\n // Try to find the entity in batch context\n for (const [, entity] of batchContext) {\n // Check if this is the right entity type\n if (entity.EntityInfo?.Name === entityName) {\n // Check if all lookup fields match\n let allMatch = true;\n for (const {fieldName, fieldValue} of lookupFields) {\n const entityValue = entity.Get(fieldName);\n const normalizedEntityValue = entityValue?.toString() || '';\n const normalizedLookupValue = fieldValue?.toString() || '';\n \n if (normalizedEntityValue !== normalizedLookupValue) {\n allMatch = false;\n break;\n }\n }\n \n if (allMatch) {\n // Found in batch context, return primary key\n const entityInfo = this.metadata.EntityByName(entityName);\n if (entityInfo && entityInfo.PrimaryKeys.length > 0) {\n const pkeyField = entityInfo.PrimaryKeys[0].Name;\n return entity.Get(pkeyField);\n }\n }\n }\n }\n }\n \n // Not found in batch context, check database\n const rv = new RunView();\n const entityInfo = this.metadata.EntityByName(entityName);\n if (!entityInfo) {\n throw new Error(`Entity not found: ${entityName}`);\n }\n \n // Build compound filter for all lookup fields\n const filterParts: string[] = [];\n for (const {fieldName, fieldValue} of lookupFields) {\n const field = entityInfo.Fields.find(f => f.Name.trim().toLowerCase() === fieldName.trim().toLowerCase());\n if (!field) {\n throw new Error(`Field '${fieldName}' not found in entity '${entityName}'`);\n }\n \n // Handle null values properly\n if (fieldValue.trim().toLowerCase() === 'null') {\n filterParts.push(`${fieldName} IS NULL`);\n } else {\n const quotes = field.NeedsQuotes ? \"'\" : '';\n filterParts.push(`${fieldName} = ${quotes}${fieldValue.replace(/'/g, \"''\")}${quotes}`);\n }\n }\n \n const extraFilter = filterParts.join(' AND ');\n const result = await rv.RunView({\n EntityName: entityName,\n ExtraFilter: extraFilter,\n MaxRows: 1\n }, this.contextUser);\n \n if (result.Success && result.Results.length > 0) {\n if (entityInfo.PrimaryKeys.length > 0) {\n const pkeyField = entityInfo.PrimaryKeys[0].Name;\n const id = result.Results[0][pkeyField];\n return id;\n }\n }\n \n // If not found and auto-create is enabled, create the record\n if (autoCreate) {\n \n const newEntity = await this.metadata.GetEntityObject(entityName, this.contextUser);\n if (!newEntity) {\n throw new Error(`Failed to create entity object for: ${entityName}`);\n }\n \n newEntity.NewRecord();\n \n // UUID generation now happens automatically in BaseEntity.NewRecord()\n \n // Set all lookup fields\n for (const {fieldName, fieldValue} of lookupFields) {\n if (fieldName in newEntity) {\n // Handle null values properly\n if (fieldValue.toLowerCase() === 'null') {\n (newEntity as any)[fieldName] = null;\n } else {\n (newEntity as any)[fieldName] = fieldValue;\n }\n }\n }\n \n // Set any additional fields provided\n for (const [key, value] of Object.entries(createFields)) {\n if (key in newEntity) {\n (newEntity as any)[key] = value;\n }\n }\n \n // Save the new record (new records are always dirty)\n const filterDesc = lookupFields.map(({fieldName, fieldValue}) => `${fieldName}='${fieldValue}'`).join(' AND ');\n console.log(`📝 Auto-creating ${entityName} record where ${filterDesc}`);\n const saved = await newEntity.Save();\n if (!saved) {\n const message = newEntity.LatestResult?.Message;\n if (message) {\n throw new Error(`Failed to auto-create ${entityName}: ${message}`);\n }\n \n const errors = newEntity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || 'Unknown error';\n throw new Error(`Failed to auto-create ${entityName}: ${errors}`);\n }\n \n // Return the new ID\n if (entityInfo.PrimaryKeys.length > 0) {\n const pkeyField = entityInfo.PrimaryKeys[0].Name;\n const newId = newEntity.Get(pkeyField);\n return newId;\n }\n }\n \n const filterDesc = lookupFields.map(({fieldName, fieldValue}) => `${fieldName}='${fieldValue}'`).join(' AND ');\n const errorMessage = `Lookup failed: No record found in '${entityName}' where ${filterDesc}`;\n\n // If allowDefer is true, throw DeferrableLookupError so caller can queue for retry\n if (allowDefer) {\n throw new DeferrableLookupError(\n errorMessage,\n entityName,\n lookupFields,\n originalValue || `@lookup:${entityName}.${filterDesc}`\n );\n }\n\n throw new Error(errorMessage);\n }\n\n /**\n * Build cascading defaults for a file path and process field values\n * \n * Walks up the directory tree from the file location, collecting defaults from\n * entity config and folder configs, with deeper folders overriding parent values.\n * All default values are processed for special references.\n * \n * @param filePath - Path to the file being processed\n * @param entityConfig - Entity configuration containing base defaults\n * @returns Processed defaults with all references resolved\n * @throws Error if any default value processing fails\n */\n async buildDefaults(filePath: string, entityConfig: EntityConfig): Promise<Record<string, any>> {\n const parts = path.dirname(filePath).split(path.sep);\n let defaults: Record<string, any> = { ...entityConfig.defaults };\n \n // Walk up the directory tree building defaults\n let currentPath = '';\n for (const part of parts) {\n currentPath = path.join(currentPath, part);\n const folderConfig = await this.loadFolderConfig(currentPath);\n \n if (folderConfig?.defaults) {\n defaults = { ...defaults, ...folderConfig.defaults };\n }\n }\n \n // Process all default values (lookups, file references, etc.)\n const processedDefaults: Record<string, any> = {};\n const baseDir = path.dirname(filePath);\n \n for (const [field, value] of Object.entries(defaults)) {\n try {\n processedDefaults[field] = await this.processFieldValue(value, baseDir, null, null, 0);\n } catch (error) {\n throw new Error(`Failed to process default for field '${field}': ${error}`);\n }\n }\n \n return processedDefaults;\n }\n \n /**\n * Load folder configuration from .mj-folder.json file\n * \n * @param dir - Directory to check for configuration\n * @returns Folder configuration or null if not found/invalid\n * @private\n */\n private async loadFolderConfig(dir: string): Promise<FolderConfig | null> {\n const configPath = path.join(dir, '.mj-folder.json');\n \n if (await fs.pathExists(configPath)) {\n try {\n return await fs.readJson(configPath);\n } catch (error) {\n console.error(`Error loading folder config at ${configPath}:`, error);\n return null;\n }\n }\n \n return null;\n }\n \n /**\n * Calculate SHA256 checksum for data\n * \n * Generates a deterministic hash of the provided data by converting it to\n * formatted JSON and calculating a SHA256 digest. Used for change detection\n * in sync operations.\n * \n * @param data - Any data structure to calculate checksum for\n * @returns Hexadecimal string representation of the SHA256 hash\n * \n * @example\n * ```typescript\n * const checksum = syncEngine.calculateChecksum({\n * name: 'Test Record',\n * value: 42,\n * tags: ['a', 'b']\n * });\n * // Returns consistent hash for same data structure\n * ```\n */\n calculateChecksum(data: any): string {\n const hash = crypto.createHash('sha256');\n hash.update(JSON.stringify(data, null, 2));\n return hash.digest('hex');\n }\n\n /**\n * Calculate checksum including resolved file content\n * \n * Enhanced checksum calculation that resolves @file references and includes\n * the actual file content (with @include directives processed) in the checksum.\n * This ensures that changes to referenced files are detected.\n * \n * @param data - Fields object that may contain @file references\n * @param entityDir - Directory for resolving relative file paths\n * @returns Promise resolving to checksum string\n */\n async calculateChecksumWithFileContent(data: any, entityDir: string): Promise<string> {\n const processedData = await this.resolveFileReferencesForChecksum(data, entityDir);\n return this.calculateChecksum(processedData);\n }\n\n /**\n * Resolve @file references for checksum calculation\n * \n * Recursively processes an object and replaces @file references with their\n * actual content (including resolved @include directives). This ensures the\n * checksum reflects the actual content, not just the reference.\n * \n * @param obj - Object to process\n * @param entityDir - Directory for resolving relative paths\n * @returns Promise resolving to processed object\n * @private\n */\n private async resolveFileReferencesForChecksum(obj: any, entityDir: string): Promise<any> {\n if (!obj || typeof obj !== 'object') {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return Promise.all(obj.map(item => this.resolveFileReferencesForChecksum(item, entityDir)));\n }\n\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === 'string' && value.startsWith(METADATA_KEYWORDS.FILE)) {\n // Process @file reference and include actual content\n try {\n const filePath = extractKeywordValue(value) as string;\n const fullPath = path.isAbsolute(filePath) ? filePath : path.join(entityDir, filePath);\n \n if (await fs.pathExists(fullPath)) {\n let processedContent: string;\n \n // Check if this is a JSON file that might contain @include directives\n if (fullPath.endsWith('.json')) {\n try {\n const jsonContent = await fs.readJson(fullPath);\n const jsonString = JSON.stringify(jsonContent);\n const hasIncludes = jsonString.includes('\"@include') || jsonString.includes('\"@include.');\n \n if (hasIncludes) {\n // Process @include directives\n const preprocessor = new JsonPreprocessor();\n const processedJson = await preprocessor.processFile(fullPath);\n processedContent = JSON.stringify(processedJson, null, 2);\n } else {\n processedContent = JSON.stringify(jsonContent, null, 2);\n }\n } catch {\n // Not valid JSON, process as text\n const content = await fs.readFile(fullPath, 'utf-8');\n processedContent = await this.processFileContentWithIncludes(content, fullPath);\n }\n } else {\n // Text file - process {@include} references\n const content = await fs.readFile(fullPath, 'utf-8');\n processedContent = await this.processFileContentWithIncludes(content, fullPath);\n }\n \n result[key] = {\n _checksumType: 'file',\n _reference: value,\n _content: processedContent\n };\n } else {\n // File doesn't exist, keep the reference\n result[key] = value;\n }\n } catch (error) {\n // Error reading file, keep the reference\n result[key] = value;\n }\n } else if (typeof value === 'object') {\n result[key] = await this.resolveFileReferencesForChecksum(value, entityDir);\n } else {\n result[key] = value;\n }\n }\n return result;\n }\n \n /**\n * Get entity metadata information by name\n * \n * Retrieves the EntityInfo object containing schema metadata for the specified entity.\n * Returns null if the entity is not found in the metadata cache.\n * \n * @param entityName - Name of the entity to look up\n * @returns EntityInfo object with schema details or null if not found\n * \n * @example\n * ```typescript\n * const entityInfo = syncEngine.getEntityInfo('AI Prompts');\n * if (entityInfo) {\n * console.log(`Primary keys: ${entityInfo.PrimaryKeys.map(pk => pk.Name).join(', ')}`);\n * }\n * ```\n */\n getEntityInfo(entityName: string): EntityInfo | null {\n return this.metadata.EntityByName(entityName);\n }\n \n /**\n * Create a new entity object instance\n * \n * Uses the MemberJunction metadata system to properly instantiate an entity object.\n * This ensures correct class registration and respects any custom entity subclasses.\n * \n * @param entityName - Name of the entity to create\n * @returns Promise resolving to the new BaseEntity instance\n * @throws Error if entity creation fails\n * \n * @example\n * ```typescript\n * const entity = await syncEngine.createEntityObject('AI Prompts');\n * entity.NewRecord();\n * entity.Set('Name', 'My Prompt');\n * await entity.Save();\n * ```\n */\n async createEntityObject(entityName: string): Promise<BaseEntity> {\n const entity = await this.metadata.GetEntityObject(entityName, this.contextUser);\n if (!entity) {\n throw new Error(`Failed to create entity object for: ${entityName}`);\n }\n return entity;\n }\n \n /**\n * Load an entity record by primary key\n * \n * Retrieves an existing entity record from the database using its primary key values.\n * Supports both single and composite primary keys. Returns null if the record is not found.\n * \n * @param entityName - Name of the entity to load\n * @param primaryKey - Object containing primary key field names and values\n * @returns Promise resolving to the loaded entity or null if not found\n * @throws Error if entity metadata is not found\n * \n * @example\n * ```typescript\n * // Single primary key\n * const entity = await syncEngine.loadEntity('Users', { ID: '123-456' });\n * \n * // Composite primary key\n * const entity = await syncEngine.loadEntity('UserRoles', { \n * UserID: '123-456',\n * RoleID: '789-012'\n * });\n * ```\n */\n async loadEntity(entityName: string, primaryKey: Record<string, any>): Promise<BaseEntity | null> {\n const entityInfo = this.getEntityInfo(entityName);\n \n if (!entityInfo) {\n throw new Error(`Entity not found: ${entityName}`);\n }\n \n // First, check if the record exists using RunView to avoid \"Error in BaseEntity.Load\" messages\n // when records don't exist (which is a normal scenario during sync operations)\n const rv = new RunView();\n \n // Build filter for primary key(s)\n const filters: string[] = [];\n for (const pk of entityInfo.PrimaryKeys) {\n const value = primaryKey[pk.Name];\n if (value === undefined || value === null) {\n throw new Error(`Missing primary key value for ${pk.Name} in entity ${entityName}`);\n }\n \n // Check if field needs quotes\n const field = entityInfo.Fields.find(f => f.Name === pk.Name);\n const quotes = field?.NeedsQuotes ? \"'\" : '';\n const escapedValue = field?.NeedsQuotes && typeof value === 'string' ? value.replace(/'/g, \"''\") : value;\n filters.push(`${pk.Name} = ${quotes}${escapedValue}${quotes}`);\n }\n \n const result = await rv.RunView({\n EntityName: entityName,\n ExtraFilter: filters.join(' AND '),\n MaxRows: 1\n }, this.contextUser);\n \n // If no record found, return null without attempting to load\n if (!result.Success || result.Results.length === 0) {\n return null;\n }\n \n // Record exists, now load it properly through the entity\n const entity = await this.createEntityObject(entityName);\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromSimpleObject(primaryKey);\n const loaded = await entity.InnerLoad(compositeKey);\n \n return loaded ? entity : null;\n }\n \n /**\n * Process file content with {@include} references\n * \n * Recursively processes a file's content to resolve `{@include path}` references.\n * Include references use JSDoc-style syntax and support:\n * - Relative paths resolved from the containing file's directory\n * - Recursive includes (includes within included files)\n * - Circular reference detection to prevent infinite loops\n * - Seamless content substitution maintaining surrounding text\n * \n * @param content - The file content to process\n * @param filePath - Path to the file being processed\n * @param visitedPaths - Set of already visited file paths for circular reference detection\n * @returns Promise resolving to the content with all includes resolved\n * @throws Error if circular reference detected or included file not found\n * \n * @example\n * ```typescript\n * // Content with include reference\n * const content = 'This is a {@include ./shared/header.md} example';\n * \n * // Resolves to:\n * const result = await processFileContentWithIncludes('/path/to/file.md', content);\n * // 'This is a [contents of header.md] example'\n * ```\n */\n private async processFileContentWithIncludes(\n content: string,\n filePath: string, \n visitedPaths: Set<string> = new Set()\n ): Promise<string> {\n // Add current file to visited set\n const absolutePath = path.resolve(filePath);\n if (visitedPaths.has(absolutePath)) {\n throw new Error(`Circular reference detected: ${absolutePath} is already being processed`);\n }\n visitedPaths.add(absolutePath);\n \n // Pattern to match {@include path} references\n // Supports whitespace around the path for flexibility\n const includePattern = /\\{@include\\s+([^\\}]+)\\s*\\}/g;\n \n let processedContent = content;\n let match: RegExpExecArray | null;\n \n // Process all {@include} references\n while ((match = includePattern.exec(content)) !== null) {\n const [fullMatch, includePath] = match;\n const trimmedPath = includePath.trim();\n \n // Resolve the include path relative to the current file's directory\n const currentDir = path.dirname(filePath);\n const resolvedPath = path.resolve(currentDir, trimmedPath);\n \n try {\n // Check if the included file exists\n if (!await fs.pathExists(resolvedPath)) {\n throw new Error(`Included file not found: ${resolvedPath}`);\n }\n \n // Read the included file\n const includedContent = await fs.readFile(resolvedPath, 'utf-8');\n \n // Recursively process the included content for nested includes\n const processedInclude = await this.processFileContentWithIncludes(\n includedContent,\n resolvedPath, \n new Set(visitedPaths) // Pass a copy to allow the same file in different branches\n );\n \n // Replace the {@include} reference with the processed content\n processedContent = processedContent.replace(fullMatch, processedInclude);\n } catch (error) {\n // Enhance error message with context\n throw new Error(`Failed to process {@include ${trimmedPath}} in ${filePath}: ${error}`);\n }\n }\n \n return processedContent;\n }\n\n /**\n * Recursively process field values in a JSON object\n * \n * Processes all string values in a JSON object through processFieldValue,\n * which handles @file, @lookup, @parent, @root references. This ensures\n * that nested @file references within JSON files are properly resolved.\n * \n * @param obj - JSON object to process\n * @param baseDir - Base directory for resolving relative file paths\n * @param parentRecord - Parent entity record for @parent references\n * @param rootRecord - Root entity record for @root references\n * @param depth - Current recursion depth\n * @param batchContext - Batch processing context\n * @returns Promise resolving to processed JSON object\n * @private\n */\n private async processJsonFieldValues(\n obj: any,\n baseDir: string,\n parentRecord?: BaseEntity | null,\n rootRecord?: BaseEntity | null,\n depth: number = 0,\n batchContext?: Map<string, BaseEntity>\n ): Promise<any> {\n // Handle null and undefined\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return Promise.all(\n obj.map(item => \n this.processJsonFieldValues(item, baseDir, parentRecord, rootRecord, depth, batchContext)\n )\n );\n }\n\n // Handle objects\n if (typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n // Process string values that might contain references\n if (typeof value === 'string') {\n // Check if this looks like a reference that needs processing\n // Only process known reference types, ignore other @ strings (like npm packages)\n if (isMetadataKeyword(value)) {\n result[key] = await this.processFieldValue(value, baseDir, parentRecord, rootRecord, depth, batchContext);\n } else {\n result[key] = value;\n }\n } else if (typeof value === 'object') {\n // Recursively process nested objects\n result[key] = await this.processJsonFieldValues(value, baseDir, parentRecord, rootRecord, depth, batchContext);\n } else {\n // Keep primitive values as-is\n result[key] = value;\n }\n }\n return result;\n }\n\n // Return primitive values as-is\n return obj;\n }\n \n}"]}
@@ -20,6 +20,7 @@ export declare class FormattingService {
20
20
  errors: number;
21
21
  duration: number;
22
22
  unchanged?: number;
23
+ deferred?: number;
23
24
  }): string;
24
25
  private formatHeader;
25
26
  private formatSectionHeader;
@@ -118,6 +118,9 @@ class FormattingService {
118
118
  }
119
119
  lines.push(` ${chalk_1.default.red(this.symbols.error)} Deleted: ${chalk_1.default.red(stats.deleted)}`);
120
120
  lines.push(` ${chalk_1.default.gray('-')} Skipped: ${chalk_1.default.gray(stats.skipped)}`);
121
+ if (stats.deferred !== undefined && stats.deferred > 0) {
122
+ lines.push(` ${chalk_1.default.yellow('⏳')} Deferred: ${chalk_1.default.yellow(stats.deferred)}`);
123
+ }
121
124
  lines.push('');
122
125
  lines.push(` Total Records: ${chalk_1.default.bold(total)}`);
123
126
  lines.push(` Duration: ${chalk_1.default.cyan(this.formatDuration(stats.duration))}`);
@@ -1 +1 @@
1
- {"version":3,"file":"FormattingService.js","sourceRoot":"","sources":["../../src/services/FormattingService.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,MAAa,iBAAiB;IAC1B;;OAEG;IACI,4BAA4B,CAAC,MAAwB;QACxD,MAAM,MAAM,GAAG;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE;gBACL,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU;gBACrC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;gBAC3C,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;gBACvC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;gBAC3C,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC;gBACjD,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC;aAC1D;YACD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5B,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,UAAU,EAAE,CAAC,CAAC,UAAU;aAC3B,CAAC,CAAC;YACH,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACh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;QACpD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAErB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACJ;AA/oBD,8CA+oBC","sourcesContent":["import chalk from 'chalk';\nimport { ValidationResult, ValidationError, ValidationWarning, FileValidationResult } from '../types/validation';\n\nexport class FormattingService {\n /**\n * Format validation result as JSON\n */\n public formatValidationResultAsJson(result: ValidationResult): string {\n const output = {\n isValid: result.isValid,\n summary: {\n totalFiles: result.summary.totalFiles,\n totalEntities: result.summary.totalEntities,\n totalErrors: result.summary.totalErrors,\n totalWarnings: result.summary.totalWarnings,\n errorsByType: this.getErrorsByType(result.errors),\n warningsByType: this.getWarningsByType(result.warnings)\n },\n errors: result.errors.map(e => ({\n type: e.type,\n entity: e.entity,\n field: e.field,\n file: e.file,\n message: e.message,\n suggestion: e.suggestion\n })),\n warnings: result.warnings.map(w => ({\n type: w.type,\n entity: w.entity,\n field: w.field,\n file: w.file,\n message: w.message,\n suggestion: w.suggestion\n }))\n };\n \n return JSON.stringify(output, null, 2);\n }\n private readonly symbols = {\n success: '✓',\n error: '✗',\n warning: '⚠',\n info: 'ℹ',\n arrow: '→',\n bullet: '•',\n box: {\n topLeft: '┌',\n topRight: '┐',\n bottomLeft: '└',\n bottomRight: '┘',\n horizontal: '─',\n vertical: '│',\n cross: '┼'\n }\n };\n\n /**\n * Format validation result for terminal output\n */\n public formatValidationResult(result: ValidationResult, verbose: boolean = false): string {\n const lines: string[] = [];\n \n // Header\n lines.push(this.formatHeader('Validation Report'));\n lines.push('');\n\n // Summary box\n lines.push(this.formatSummaryBox(result));\n lines.push('');\n\n // File results\n if (result.summary.fileResults.size > 0) {\n lines.push(this.formatSectionHeader('File Results'));\n lines.push('');\n \n for (const [file, fileResult] of result.summary.fileResults) {\n const hasIssues = fileResult.errors.length > 0 || fileResult.warnings.length > 0;\n if (!verbose && !hasIssues) continue;\n \n lines.push(this.formatFileResult(file, fileResult, verbose));\n }\n }\n\n // Detailed errors\n if (result.errors.length > 0) {\n lines.push('');\n lines.push(this.formatSectionHeader('Errors'));\n lines.push('');\n result.errors.forEach((error, index) => {\n lines.push(this.formatError(error, index + 1));\n });\n }\n\n // Detailed warnings\n if (result.warnings.length > 0) {\n lines.push('');\n lines.push(this.formatSectionHeader('Warnings'));\n lines.push('');\n result.warnings.forEach((warning, index) => {\n lines.push(this.formatWarning(warning, index + 1));\n });\n }\n\n // Footer\n lines.push('');\n lines.push(this.formatFooter(result));\n\n return lines.join('\\n');\n }\n\n /**\n * Format push/pull summary report\n */\n public formatSyncSummary(\n operation: 'push' | 'pull',\n stats: {\n created: number;\n updated: number;\n deleted: number;\n skipped: number;\n errors: number;\n duration: number;\n unchanged?: number;\n }\n ): string {\n const lines: string[] = [];\n \n lines.push(this.formatHeader(`${operation.charAt(0).toUpperCase() + operation.slice(1)} Summary`));\n lines.push('');\n \n const total = stats.created + stats.updated + stats.deleted + stats.skipped + (stats.unchanged || 0);\n \n lines.push(chalk.bold('Operation Statistics:'));\n lines.push('');\n lines.push(` ${chalk.green(this.symbols.success)} Created: ${chalk.green(stats.created)}`);\n lines.push(` ${chalk.blue(this.symbols.info)} Updated: ${chalk.blue(stats.updated)}`);\n if (stats.unchanged !== undefined) {\n lines.push(` ${chalk.gray('-')} Unchanged: ${chalk.gray(stats.unchanged)}`);\n }\n lines.push(` ${chalk.red(this.symbols.error)} Deleted: ${chalk.red(stats.deleted)}`);\n lines.push(` ${chalk.gray('-')} Skipped: ${chalk.gray(stats.skipped)}`);\n lines.push('');\n lines.push(` Total Records: ${chalk.bold(total)}`);\n lines.push(` Duration: ${chalk.cyan(this.formatDuration(stats.duration))}`);\n \n if (stats.errors > 0) {\n lines.push('');\n lines.push(chalk.red(` ${this.symbols.error} Errors: ${stats.errors}`));\n }\n \n return lines.join('\\n');\n }\n\n private formatHeader(title: string): string {\n const width = 60;\n const line = '═'.repeat(width);\n \n // MemberJunction branding\n const brandingText = 'MemberJunction Metadata Sync';\n const brandingPadding = Math.floor((width - brandingText.length - 2) / 2);\n \n // Title\n const titlePadding = Math.floor((width - title.length - 2) / 2);\n \n return chalk.blue([\n line,\n '║' + ' '.repeat(brandingPadding) + brandingText + ' '.repeat(width - brandingPadding - brandingText.length - 2) + '║',\n '║' + ' '.repeat(titlePadding) + title + ' '.repeat(width - titlePadding - title.length - 2) + '║',\n line\n ].join('\\n'));\n }\n\n private formatSectionHeader(title: string): string {\n return chalk.bold.underline(title);\n }\n\n private formatSummaryBox(result: ValidationResult): string {\n const lines: string[] = [];\n const width = 50;\n \n lines.push(chalk.gray('┌' + '─'.repeat(width - 2) + '┐'));\n \n // Basic stats\n const items = [\n ['Files:', result.summary.totalFiles],\n ['Entities:', result.summary.totalEntities],\n ['Errors:', result.summary.totalErrors],\n ['Warnings:', result.summary.totalWarnings]\n ];\n \n items.forEach(([label, value]) => {\n const numValue = Number(value);\n const color = label === 'Errors:' && numValue > 0 ? chalk.red :\n label === 'Warnings:' && numValue > 0 ? chalk.yellow :\n chalk.white;\n const line = `${String(label).padEnd(15)} ${color(String(value))}`;\n lines.push(chalk.gray('│ ') + line.padEnd(width - 4) + chalk.gray(' │'));\n });\n \n // Add separator\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push(chalk.gray('├' + '─'.repeat(width - 2) + '┤'));\n }\n \n // Error breakdown by type\n if (result.errors.length > 0) {\n lines.push(chalk.gray('│ ') + chalk.bold('Errors by Type:').padEnd(width - 4) + chalk.gray(' │'));\n const errorsByType = this.getErrorsByType(result.errors);\n for (const [type, count] of Object.entries(errorsByType)) {\n const typeText = ` ${type}:`;\n const countText = chalk.red(count.toString());\n const spaceBetween = width - 4 - typeText.length - count.toString().length;\n const line = typeText + ' '.repeat(spaceBetween) + countText;\n lines.push(chalk.gray('│ ') + line + chalk.gray(' │'));\n }\n }\n \n // Warning breakdown by type\n if (result.warnings.length > 0) {\n if (result.errors.length > 0) {\n lines.push(chalk.gray('├' + '─'.repeat(width - 2) + '┤'));\n }\n lines.push(chalk.gray('│ ') + chalk.bold('Warnings by Type:').padEnd(width - 4) + chalk.gray(' │'));\n const warningsByType = this.getWarningsByType(result.warnings);\n for (const [type, count] of Object.entries(warningsByType)) {\n const typeText = ` ${type}:`;\n const countText = chalk.yellow(count.toString());\n const spaceBetween = width - 4 - typeText.length - count.toString().length;\n const line = typeText + ' '.repeat(spaceBetween) + countText;\n lines.push(chalk.gray('│ ') + line + chalk.gray(' │'));\n }\n }\n \n lines.push(chalk.gray('└' + '─'.repeat(width - 2) + '┘'));\n \n return lines.join('\\n');\n }\n\n private formatFileResult(file: string, result: FileValidationResult, verbose: boolean): string {\n const lines: string[] = [];\n const hasErrors = result.errors.length > 0;\n const hasWarnings = result.warnings.length > 0;\n \n const icon = hasErrors ? chalk.red(this.symbols.error) :\n hasWarnings ? chalk.yellow(this.symbols.warning) :\n chalk.green(this.symbols.success);\n \n const shortPath = this.shortenPath(file);\n lines.push(`${icon} ${chalk.bold(shortPath)}`);\n \n if (verbose || hasErrors || hasWarnings) {\n lines.push(` ${chalk.gray(`Entities: ${result.entityCount}`)}`);\n \n if (hasErrors) {\n lines.push(` ${chalk.red(`Errors: ${result.errors.length}`)}`);\n }\n \n if (hasWarnings) {\n lines.push(` ${chalk.yellow(`Warnings: ${result.warnings.length}`)}`);\n }\n }\n \n lines.push('');\n return lines.join('\\n');\n }\n\n private formatError(error: ValidationError, index: number): string {\n const lines: string[] = [];\n \n lines.push(chalk.red(`${index}. ${error.message}`));\n \n if (error.entity) {\n lines.push(chalk.gray(` Entity: ${error.entity}`));\n }\n if (error.field) {\n lines.push(chalk.gray(` Field: ${error.field}`));\n }\n lines.push(chalk.gray(` File: ${this.shortenPath(error.file)}`));\n \n if (error.suggestion) {\n lines.push(chalk.cyan(` ${this.symbols.arrow} Suggestion: ${error.suggestion}`));\n }\n \n lines.push('');\n return lines.join('\\n');\n }\n\n private formatWarning(warning: ValidationWarning, index: number): string {\n const lines: string[] = [];\n \n lines.push(chalk.yellow(`${index}. ${warning.message}`));\n \n if (warning.entity) {\n lines.push(chalk.gray(` Entity: ${warning.entity}`));\n }\n if (warning.field) {\n lines.push(chalk.gray(` Field: ${warning.field}`));\n }\n lines.push(chalk.gray(` File: ${this.shortenPath(warning.file)}`));\n \n if (warning.suggestion) {\n lines.push(chalk.cyan(` ${this.symbols.arrow} Suggestion: ${warning.suggestion}`));\n }\n \n lines.push('');\n return lines.join('\\n');\n }\n\n private formatFooter(result: ValidationResult): string {\n const lines: string[] = [];\n \n if (result.isValid) {\n lines.push(chalk.green.bold(`${this.symbols.success} Validation passed!`));\n } else {\n lines.push(chalk.red.bold(`${this.symbols.error} Validation failed with ${result.errors.length} error(s)`));\n }\n \n // Add documentation link if there are any issues\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push('');\n lines.push(chalk.gray('For help resolving issues, see:'));\n lines.push(chalk.cyan('https://github.com/MemberJunction/MJ/tree/next/packages/MetadataSync'));\n }\n \n return lines.join('\\n');\n }\n\n private shortenPath(filePath: string): string {\n const cwd = process.cwd();\n if (filePath.startsWith(cwd)) {\n return '.' + filePath.slice(cwd.length);\n }\n return filePath;\n }\n\n private formatDuration(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;\n return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;\n }\n \n /**\n * Get count of errors by type\n */\n private getErrorsByType(errors: ValidationError[]): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const error of errors) {\n counts[error.type] = (counts[error.type] || 0) + 1;\n }\n return counts;\n }\n \n /**\n * Get count of warnings by type\n */\n private getWarningsByType(warnings: ValidationWarning[]): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const warning of warnings) {\n counts[warning.type] = (counts[warning.type] || 0) + 1;\n }\n return counts;\n }\n \n /**\n * Format validation result as markdown\n */\n public formatValidationResultAsMarkdown(result: ValidationResult): string {\n const lines: string[] = [];\n const timestamp = new Date();\n const dateStr = timestamp.toLocaleDateString('en-US', { \n weekday: 'long', \n year: 'numeric', \n month: 'long', \n day: 'numeric' \n });\n const timeStr = timestamp.toLocaleTimeString('en-US', { \n hour: '2-digit', \n minute: '2-digit', \n second: '2-digit' \n });\n \n // Header with branding\n lines.push('# 🚀 MemberJunction Metadata Sync');\n lines.push('## Validation Report');\n lines.push('');\n lines.push(`📅 **Date:** ${dateStr} `);\n lines.push(`🕐 **Time:** ${timeStr} `);\n lines.push(`📍 **Directory:** \\`${process.cwd()}\\` `);\n lines.push('');\n \n // Table of Contents\n lines.push('## 📑 Table of Contents');\n lines.push('');\n lines.push('- [Executive Summary](#executive-summary)');\n lines.push('- [Validation Results](#validation-results)');\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push('- [Issue Analysis](#issue-analysis)');\n }\n lines.push('- [File-by-File Breakdown](#file-by-file-breakdown)');\n if (result.errors.length > 0) {\n lines.push('- [Error Details](#error-details)');\n }\n if (result.warnings.length > 0) {\n lines.push('- [Warning Details](#warning-details)');\n }\n lines.push('- [Next Steps](#next-steps)');\n lines.push('- [Resources](#resources)');\n lines.push('');\n \n // Executive Summary\n lines.push('## 📊 Executive Summary');\n lines.push('');\n \n const statusEmoji = result.isValid ? '✅' : '❌';\n const statusText = result.isValid ? 'PASSED' : 'FAILED';\n const statusColor = result.isValid ? 'green' : 'red';\n \n lines.push(`### Overall Status: ${statusEmoji} **${statusText}**`);\n lines.push('');\n \n if (result.isValid) {\n lines.push('> 🎉 **Congratulations!** Your metadata validation passed with no errors.');\n } else {\n lines.push(`> ⚠️ **Action Required:** ${result.errors.length} error(s) need to be resolved before proceeding.`);\n }\n lines.push('');\n \n // Quick Stats\n lines.push('### 📈 Quick Statistics');\n lines.push('');\n lines.push(`**📁 Files Validated:** ${result.summary.totalFiles} `);\n lines.push(`**📦 Entities Processed:** ${result.summary.totalEntities} `);\n lines.push(`**❌ Errors Found:** ${result.summary.totalErrors} `);\n lines.push(`**⚠️ Warnings Found:** ${result.summary.totalWarnings} `);\n lines.push('');\n \n // Validation Results\n lines.push('## 🔍 Validation Results');\n lines.push('');\n \n // Issue Analysis\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push('## 📊 Issue Analysis');\n lines.push('');\n \n if (result.errors.length > 0) {\n lines.push('### ❌ Error Distribution');\n lines.push('');\n const errorsByType = this.getErrorsByType(result.errors);\n \n lines.push('<details>');\n lines.push('<summary>Click to expand error breakdown</summary>');\n lines.push('');\n \n for (const [type, count] of Object.entries(errorsByType)) {\n const percentage = ((count / result.errors.length) * 100).toFixed(1);\n lines.push(`- **${type}**: ${count} errors (${percentage}%)`);\n }\n lines.push('');\n lines.push('</details>');\n lines.push('');\n }\n \n if (result.warnings.length > 0) {\n lines.push('### ⚠️ Warning Distribution');\n lines.push('');\n const warningsByType = this.getWarningsByType(result.warnings);\n \n lines.push('<details>');\n lines.push('<summary>Click to expand warning breakdown</summary>');\n lines.push('');\n \n for (const [type, count] of Object.entries(warningsByType)) {\n const percentage = ((count / result.warnings.length) * 100).toFixed(1);\n lines.push(`- **${type}**: ${count} warnings (${percentage}%)`);\n }\n lines.push('');\n lines.push('</details>');\n lines.push('');\n }\n }\n \n // File Results\n lines.push('## 📁 File-by-File Breakdown');\n lines.push('');\n \n const sortedFiles = Array.from(result.summary.fileResults.entries())\n .sort(([a], [b]) => {\n // Sort by error count (descending), then warning count, then name\n const aResult = result.summary.fileResults.get(a)!;\n const bResult = result.summary.fileResults.get(b)!;\n \n if (aResult.errors.length !== bResult.errors.length) {\n return bResult.errors.length - aResult.errors.length;\n }\n if (aResult.warnings.length !== bResult.warnings.length) {\n return bResult.warnings.length - aResult.warnings.length;\n }\n return a.localeCompare(b);\n });\n \n for (const [file, fileResult] of sortedFiles) {\n const shortPath = this.shortenPath(file);\n const hasErrors = fileResult.errors.length > 0;\n const hasWarnings = fileResult.warnings.length > 0;\n const icon = hasErrors ? '❌' : hasWarnings ? '⚠️' : '✅';\n const status = hasErrors ? 'Has Errors' : hasWarnings ? 'Has Warnings' : 'Clean';\n \n lines.push(`<details>`);\n lines.push(`<summary>${icon} <strong>${shortPath}</strong> - ${status}</summary>`);\n lines.push('');\n lines.push('#### File Statistics');\n lines.push(`- **Entities:** ${fileResult.entityCount}`);\n lines.push(`- **Errors:** ${fileResult.errors.length}`);\n lines.push(`- **Warnings:** ${fileResult.warnings.length}`);\n \n if (hasErrors) {\n lines.push('');\n lines.push('#### Errors in this file:');\n fileResult.errors.forEach((error, idx) => {\n lines.push(`${idx + 1}. ${error.message}`);\n });\n }\n \n if (hasWarnings) {\n lines.push('');\n lines.push('#### Warnings in this file:');\n fileResult.warnings.forEach((warning, idx) => {\n lines.push(`${idx + 1}. ${warning.message}`);\n });\n }\n \n lines.push('');\n lines.push('</details>');\n lines.push('');\n }\n \n // Detailed Errors\n if (result.errors.length > 0) {\n lines.push('## ❌ Error Details');\n lines.push('');\n lines.push(`> Found ${result.errors.length} error(s) that must be fixed.`);\n lines.push('');\n \n result.errors.forEach((error, index) => {\n lines.push(`### Error ${index + 1}: ${error.message}`);\n lines.push('');\n \n lines.push(`**Type:** \\`${error.type}\\` `);\n if (error.entity) lines.push(`**Entity:** ${error.entity} `);\n if (error.field) lines.push(`**Field:** \\`${error.field}\\` `);\n lines.push(`**File:** \\`${this.shortenPath(error.file)}\\` `);\n lines.push(`**Severity:** ${error.severity} `);\n \n if (error.suggestion) {\n lines.push('');\n lines.push('> 💡 **Suggestion:** ' + error.suggestion);\n }\n \n lines.push('');\n lines.push('---');\n lines.push('');\n });\n }\n \n // Detailed Warnings\n if (result.warnings.length > 0) {\n lines.push('## ⚠️ Warning Details');\n lines.push('');\n lines.push(`> Found ${result.warnings.length} warning(s) for your review.`);\n lines.push('');\n \n // Group warnings by type for better organization\n const warningsByType = new Map<string, ValidationWarning[]>();\n result.warnings.forEach(warning => {\n if (!warningsByType.has(warning.type)) {\n warningsByType.set(warning.type, []);\n }\n warningsByType.get(warning.type)!.push(warning);\n });\n \n for (const [type, warnings] of warningsByType) {\n lines.push(`### Warning Type: \\`${type}\\``);\n lines.push('');\n \n warnings.forEach((warning, index) => {\n lines.push(`#### ${index + 1}. ${warning.message}`);\n lines.push('');\n \n if (warning.entity) lines.push(`**Entity:** ${warning.entity} `);\n if (warning.field) lines.push(`**Field:** \\`${warning.field}\\` `);\n lines.push(`**File:** \\`${this.shortenPath(warning.file)}\\` `);\n \n if (warning.suggestion) {\n lines.push('');\n lines.push('> 💡 **Suggestion:** ' + warning.suggestion);\n }\n \n lines.push('');\n });\n }\n }\n \n // Next Steps\n lines.push('## 🚀 Next Steps');\n lines.push('');\n \n if (result.errors.length > 0) {\n lines.push('### To fix errors:');\n lines.push('');\n lines.push('1. Review each error in the [Error Details](#error-details) section');\n lines.push('2. Follow the suggestions provided for each error');\n lines.push('3. Run validation again after making changes');\n lines.push('4. Repeat until all errors are resolved');\n lines.push('');\n }\n \n if (result.warnings.length > 0) {\n lines.push('### To address warnings:');\n lines.push('');\n lines.push('1. Review warnings in the [Warning Details](#warning-details) section');\n lines.push('2. Determine which warnings are relevant to your use case');\n lines.push('3. Apply suggested fixes where appropriate');\n lines.push('');\n }\n \n if (result.isValid) {\n lines.push('Your metadata is valid and ready to sync! 🎉');\n lines.push('');\n lines.push('```bash');\n lines.push('# Push your metadata to the database');\n lines.push('mj-sync push');\n lines.push('```');\n }\n \n // Resources\n lines.push('');\n lines.push('## 📚 Resources');\n lines.push('');\n lines.push('- 📖 [MetadataSync Documentation](https://github.com/MemberJunction/MJ/tree/next/packages/MetadataSync)');\n lines.push('- 🐛 [Report Issues](https://github.com/MemberJunction/MJ/issues)');\n lines.push('- 💬 [MemberJunction Community](https://memberjunction.org)');\n lines.push('- 📝 [Validation Rules Guide](https://github.com/MemberJunction/MJ/tree/next/packages/MetadataSync#validation-features)');\n lines.push('');\n \n // Footer\n lines.push('---');\n lines.push('');\n lines.push('<div align=\"center\">');\n lines.push('');\n lines.push('**Generated by [MemberJunction](https://memberjunction.org) Metadata Sync**');\n lines.push('');\n lines.push(`<sub>${timestamp.toISOString()}</sub>`);\n lines.push('');\n lines.push('</div>');\n \n return lines.join('\\n');\n }\n}"]}
1
+ {"version":3,"file":"FormattingService.js","sourceRoot":"","sources":["../../src/services/FormattingService.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAG1B,MAAa,iBAAiB;IAC1B;;OAEG;IACI,4BAA4B,CAAC,MAAwB;QACxD,MAAM,MAAM,GAAG;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE;gBACL,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU;gBACrC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;gBAC3C,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;gBACvC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;gBAC3C,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC;gBACjD,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC;aAC1D;YACD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5B,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,UAAU,EAAE,CAAC,CAAC,UAAU;aAC3B,CAAC,CAAC;YACH,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAChC,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,KAAK,EAAE,CAAC,CAAC,KAA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6E,CAAC,CAAC;QAC1F,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,QAAQ,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACpD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAErB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACJ;AAnpBD,8CAmpBC","sourcesContent":["import chalk from 'chalk';\nimport { ValidationResult, ValidationError, ValidationWarning, FileValidationResult } from '../types/validation';\n\nexport class FormattingService {\n /**\n * Format validation result as JSON\n */\n public formatValidationResultAsJson(result: ValidationResult): string {\n const output = {\n isValid: result.isValid,\n summary: {\n totalFiles: result.summary.totalFiles,\n totalEntities: result.summary.totalEntities,\n totalErrors: result.summary.totalErrors,\n totalWarnings: result.summary.totalWarnings,\n errorsByType: this.getErrorsByType(result.errors),\n warningsByType: this.getWarningsByType(result.warnings)\n },\n errors: result.errors.map(e => ({\n type: e.type,\n entity: e.entity,\n field: e.field,\n file: e.file,\n message: e.message,\n suggestion: e.suggestion\n })),\n warnings: result.warnings.map(w => ({\n type: w.type,\n entity: w.entity,\n field: w.field,\n file: w.file,\n message: w.message,\n suggestion: w.suggestion\n }))\n };\n \n return JSON.stringify(output, null, 2);\n }\n private readonly symbols = {\n success: '✓',\n error: '✗',\n warning: '⚠',\n info: 'ℹ',\n arrow: '→',\n bullet: '•',\n box: {\n topLeft: '┌',\n topRight: '┐',\n bottomLeft: '└',\n bottomRight: '┘',\n horizontal: '─',\n vertical: '│',\n cross: '┼'\n }\n };\n\n /**\n * Format validation result for terminal output\n */\n public formatValidationResult(result: ValidationResult, verbose: boolean = false): string {\n const lines: string[] = [];\n \n // Header\n lines.push(this.formatHeader('Validation Report'));\n lines.push('');\n\n // Summary box\n lines.push(this.formatSummaryBox(result));\n lines.push('');\n\n // File results\n if (result.summary.fileResults.size > 0) {\n lines.push(this.formatSectionHeader('File Results'));\n lines.push('');\n \n for (const [file, fileResult] of result.summary.fileResults) {\n const hasIssues = fileResult.errors.length > 0 || fileResult.warnings.length > 0;\n if (!verbose && !hasIssues) continue;\n \n lines.push(this.formatFileResult(file, fileResult, verbose));\n }\n }\n\n // Detailed errors\n if (result.errors.length > 0) {\n lines.push('');\n lines.push(this.formatSectionHeader('Errors'));\n lines.push('');\n result.errors.forEach((error, index) => {\n lines.push(this.formatError(error, index + 1));\n });\n }\n\n // Detailed warnings\n if (result.warnings.length > 0) {\n lines.push('');\n lines.push(this.formatSectionHeader('Warnings'));\n lines.push('');\n result.warnings.forEach((warning, index) => {\n lines.push(this.formatWarning(warning, index + 1));\n });\n }\n\n // Footer\n lines.push('');\n lines.push(this.formatFooter(result));\n\n return lines.join('\\n');\n }\n\n /**\n * Format push/pull summary report\n */\n public formatSyncSummary(\n operation: 'push' | 'pull',\n stats: {\n created: number;\n updated: number;\n deleted: number;\n skipped: number;\n errors: number;\n duration: number;\n unchanged?: number;\n deferred?: number;\n }\n ): string {\n const lines: string[] = [];\n\n lines.push(this.formatHeader(`${operation.charAt(0).toUpperCase() + operation.slice(1)} Summary`));\n lines.push('');\n\n const total = stats.created + stats.updated + stats.deleted + stats.skipped + (stats.unchanged || 0);\n\n lines.push(chalk.bold('Operation Statistics:'));\n lines.push('');\n lines.push(` ${chalk.green(this.symbols.success)} Created: ${chalk.green(stats.created)}`);\n lines.push(` ${chalk.blue(this.symbols.info)} Updated: ${chalk.blue(stats.updated)}`);\n if (stats.unchanged !== undefined) {\n lines.push(` ${chalk.gray('-')} Unchanged: ${chalk.gray(stats.unchanged)}`);\n }\n lines.push(` ${chalk.red(this.symbols.error)} Deleted: ${chalk.red(stats.deleted)}`);\n lines.push(` ${chalk.gray('-')} Skipped: ${chalk.gray(stats.skipped)}`);\n if (stats.deferred !== undefined && stats.deferred > 0) {\n lines.push(` ${chalk.yellow('⏳')} Deferred: ${chalk.yellow(stats.deferred)}`);\n }\n lines.push('');\n lines.push(` Total Records: ${chalk.bold(total)}`);\n lines.push(` Duration: ${chalk.cyan(this.formatDuration(stats.duration))}`);\n\n if (stats.errors > 0) {\n lines.push('');\n lines.push(chalk.red(` ${this.symbols.error} Errors: ${stats.errors}`));\n }\n\n return lines.join('\\n');\n }\n\n private formatHeader(title: string): string {\n const width = 60;\n const line = '═'.repeat(width);\n \n // MemberJunction branding\n const brandingText = 'MemberJunction Metadata Sync';\n const brandingPadding = Math.floor((width - brandingText.length - 2) / 2);\n \n // Title\n const titlePadding = Math.floor((width - title.length - 2) / 2);\n \n return chalk.blue([\n line,\n '║' + ' '.repeat(brandingPadding) + brandingText + ' '.repeat(width - brandingPadding - brandingText.length - 2) + '║',\n '║' + ' '.repeat(titlePadding) + title + ' '.repeat(width - titlePadding - title.length - 2) + '║',\n line\n ].join('\\n'));\n }\n\n private formatSectionHeader(title: string): string {\n return chalk.bold.underline(title);\n }\n\n private formatSummaryBox(result: ValidationResult): string {\n const lines: string[] = [];\n const width = 50;\n \n lines.push(chalk.gray('┌' + '─'.repeat(width - 2) + '┐'));\n \n // Basic stats\n const items = [\n ['Files:', result.summary.totalFiles],\n ['Entities:', result.summary.totalEntities],\n ['Errors:', result.summary.totalErrors],\n ['Warnings:', result.summary.totalWarnings]\n ];\n \n items.forEach(([label, value]) => {\n const numValue = Number(value);\n const color = label === 'Errors:' && numValue > 0 ? chalk.red :\n label === 'Warnings:' && numValue > 0 ? chalk.yellow :\n chalk.white;\n const line = `${String(label).padEnd(15)} ${color(String(value))}`;\n lines.push(chalk.gray('│ ') + line.padEnd(width - 4) + chalk.gray(' │'));\n });\n \n // Add separator\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push(chalk.gray('├' + '─'.repeat(width - 2) + '┤'));\n }\n \n // Error breakdown by type\n if (result.errors.length > 0) {\n lines.push(chalk.gray('│ ') + chalk.bold('Errors by Type:').padEnd(width - 4) + chalk.gray(' │'));\n const errorsByType = this.getErrorsByType(result.errors);\n for (const [type, count] of Object.entries(errorsByType)) {\n const typeText = ` ${type}:`;\n const countText = chalk.red(count.toString());\n const spaceBetween = width - 4 - typeText.length - count.toString().length;\n const line = typeText + ' '.repeat(spaceBetween) + countText;\n lines.push(chalk.gray('│ ') + line + chalk.gray(' │'));\n }\n }\n \n // Warning breakdown by type\n if (result.warnings.length > 0) {\n if (result.errors.length > 0) {\n lines.push(chalk.gray('├' + '─'.repeat(width - 2) + '┤'));\n }\n lines.push(chalk.gray('│ ') + chalk.bold('Warnings by Type:').padEnd(width - 4) + chalk.gray(' │'));\n const warningsByType = this.getWarningsByType(result.warnings);\n for (const [type, count] of Object.entries(warningsByType)) {\n const typeText = ` ${type}:`;\n const countText = chalk.yellow(count.toString());\n const spaceBetween = width - 4 - typeText.length - count.toString().length;\n const line = typeText + ' '.repeat(spaceBetween) + countText;\n lines.push(chalk.gray('│ ') + line + chalk.gray(' │'));\n }\n }\n \n lines.push(chalk.gray('└' + '─'.repeat(width - 2) + '┘'));\n \n return lines.join('\\n');\n }\n\n private formatFileResult(file: string, result: FileValidationResult, verbose: boolean): string {\n const lines: string[] = [];\n const hasErrors = result.errors.length > 0;\n const hasWarnings = result.warnings.length > 0;\n \n const icon = hasErrors ? chalk.red(this.symbols.error) :\n hasWarnings ? chalk.yellow(this.symbols.warning) :\n chalk.green(this.symbols.success);\n \n const shortPath = this.shortenPath(file);\n lines.push(`${icon} ${chalk.bold(shortPath)}`);\n \n if (verbose || hasErrors || hasWarnings) {\n lines.push(` ${chalk.gray(`Entities: ${result.entityCount}`)}`);\n \n if (hasErrors) {\n lines.push(` ${chalk.red(`Errors: ${result.errors.length}`)}`);\n }\n \n if (hasWarnings) {\n lines.push(` ${chalk.yellow(`Warnings: ${result.warnings.length}`)}`);\n }\n }\n \n lines.push('');\n return lines.join('\\n');\n }\n\n private formatError(error: ValidationError, index: number): string {\n const lines: string[] = [];\n \n lines.push(chalk.red(`${index}. ${error.message}`));\n \n if (error.entity) {\n lines.push(chalk.gray(` Entity: ${error.entity}`));\n }\n if (error.field) {\n lines.push(chalk.gray(` Field: ${error.field}`));\n }\n lines.push(chalk.gray(` File: ${this.shortenPath(error.file)}`));\n \n if (error.suggestion) {\n lines.push(chalk.cyan(` ${this.symbols.arrow} Suggestion: ${error.suggestion}`));\n }\n \n lines.push('');\n return lines.join('\\n');\n }\n\n private formatWarning(warning: ValidationWarning, index: number): string {\n const lines: string[] = [];\n \n lines.push(chalk.yellow(`${index}. ${warning.message}`));\n \n if (warning.entity) {\n lines.push(chalk.gray(` Entity: ${warning.entity}`));\n }\n if (warning.field) {\n lines.push(chalk.gray(` Field: ${warning.field}`));\n }\n lines.push(chalk.gray(` File: ${this.shortenPath(warning.file)}`));\n \n if (warning.suggestion) {\n lines.push(chalk.cyan(` ${this.symbols.arrow} Suggestion: ${warning.suggestion}`));\n }\n \n lines.push('');\n return lines.join('\\n');\n }\n\n private formatFooter(result: ValidationResult): string {\n const lines: string[] = [];\n \n if (result.isValid) {\n lines.push(chalk.green.bold(`${this.symbols.success} Validation passed!`));\n } else {\n lines.push(chalk.red.bold(`${this.symbols.error} Validation failed with ${result.errors.length} error(s)`));\n }\n \n // Add documentation link if there are any issues\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push('');\n lines.push(chalk.gray('For help resolving issues, see:'));\n lines.push(chalk.cyan('https://github.com/MemberJunction/MJ/tree/next/packages/MetadataSync'));\n }\n \n return lines.join('\\n');\n }\n\n private shortenPath(filePath: string): string {\n const cwd = process.cwd();\n if (filePath.startsWith(cwd)) {\n return '.' + filePath.slice(cwd.length);\n }\n return filePath;\n }\n\n private formatDuration(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;\n return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;\n }\n \n /**\n * Get count of errors by type\n */\n private getErrorsByType(errors: ValidationError[]): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const error of errors) {\n counts[error.type] = (counts[error.type] || 0) + 1;\n }\n return counts;\n }\n \n /**\n * Get count of warnings by type\n */\n private getWarningsByType(warnings: ValidationWarning[]): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const warning of warnings) {\n counts[warning.type] = (counts[warning.type] || 0) + 1;\n }\n return counts;\n }\n \n /**\n * Format validation result as markdown\n */\n public formatValidationResultAsMarkdown(result: ValidationResult): string {\n const lines: string[] = [];\n const timestamp = new Date();\n const dateStr = timestamp.toLocaleDateString('en-US', { \n weekday: 'long', \n year: 'numeric', \n month: 'long', \n day: 'numeric' \n });\n const timeStr = timestamp.toLocaleTimeString('en-US', { \n hour: '2-digit', \n minute: '2-digit', \n second: '2-digit' \n });\n \n // Header with branding\n lines.push('# 🚀 MemberJunction Metadata Sync');\n lines.push('## Validation Report');\n lines.push('');\n lines.push(`📅 **Date:** ${dateStr} `);\n lines.push(`🕐 **Time:** ${timeStr} `);\n lines.push(`📍 **Directory:** \\`${process.cwd()}\\` `);\n lines.push('');\n \n // Table of Contents\n lines.push('## 📑 Table of Contents');\n lines.push('');\n lines.push('- [Executive Summary](#executive-summary)');\n lines.push('- [Validation Results](#validation-results)');\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push('- [Issue Analysis](#issue-analysis)');\n }\n lines.push('- [File-by-File Breakdown](#file-by-file-breakdown)');\n if (result.errors.length > 0) {\n lines.push('- [Error Details](#error-details)');\n }\n if (result.warnings.length > 0) {\n lines.push('- [Warning Details](#warning-details)');\n }\n lines.push('- [Next Steps](#next-steps)');\n lines.push('- [Resources](#resources)');\n lines.push('');\n \n // Executive Summary\n lines.push('## 📊 Executive Summary');\n lines.push('');\n \n const statusEmoji = result.isValid ? '✅' : '❌';\n const statusText = result.isValid ? 'PASSED' : 'FAILED';\n const statusColor = result.isValid ? 'green' : 'red';\n \n lines.push(`### Overall Status: ${statusEmoji} **${statusText}**`);\n lines.push('');\n \n if (result.isValid) {\n lines.push('> 🎉 **Congratulations!** Your metadata validation passed with no errors.');\n } else {\n lines.push(`> ⚠️ **Action Required:** ${result.errors.length} error(s) need to be resolved before proceeding.`);\n }\n lines.push('');\n \n // Quick Stats\n lines.push('### 📈 Quick Statistics');\n lines.push('');\n lines.push(`**📁 Files Validated:** ${result.summary.totalFiles} `);\n lines.push(`**📦 Entities Processed:** ${result.summary.totalEntities} `);\n lines.push(`**❌ Errors Found:** ${result.summary.totalErrors} `);\n lines.push(`**⚠️ Warnings Found:** ${result.summary.totalWarnings} `);\n lines.push('');\n \n // Validation Results\n lines.push('## 🔍 Validation Results');\n lines.push('');\n \n // Issue Analysis\n if (result.errors.length > 0 || result.warnings.length > 0) {\n lines.push('## 📊 Issue Analysis');\n lines.push('');\n \n if (result.errors.length > 0) {\n lines.push('### ❌ Error Distribution');\n lines.push('');\n const errorsByType = this.getErrorsByType(result.errors);\n \n lines.push('<details>');\n lines.push('<summary>Click to expand error breakdown</summary>');\n lines.push('');\n \n for (const [type, count] of Object.entries(errorsByType)) {\n const percentage = ((count / result.errors.length) * 100).toFixed(1);\n lines.push(`- **${type}**: ${count} errors (${percentage}%)`);\n }\n lines.push('');\n lines.push('</details>');\n lines.push('');\n }\n \n if (result.warnings.length > 0) {\n lines.push('### ⚠️ Warning Distribution');\n lines.push('');\n const warningsByType = this.getWarningsByType(result.warnings);\n \n lines.push('<details>');\n lines.push('<summary>Click to expand warning breakdown</summary>');\n lines.push('');\n \n for (const [type, count] of Object.entries(warningsByType)) {\n const percentage = ((count / result.warnings.length) * 100).toFixed(1);\n lines.push(`- **${type}**: ${count} warnings (${percentage}%)`);\n }\n lines.push('');\n lines.push('</details>');\n lines.push('');\n }\n }\n \n // File Results\n lines.push('## 📁 File-by-File Breakdown');\n lines.push('');\n \n const sortedFiles = Array.from(result.summary.fileResults.entries())\n .sort(([a], [b]) => {\n // Sort by error count (descending), then warning count, then name\n const aResult = result.summary.fileResults.get(a)!;\n const bResult = result.summary.fileResults.get(b)!;\n \n if (aResult.errors.length !== bResult.errors.length) {\n return bResult.errors.length - aResult.errors.length;\n }\n if (aResult.warnings.length !== bResult.warnings.length) {\n return bResult.warnings.length - aResult.warnings.length;\n }\n return a.localeCompare(b);\n });\n \n for (const [file, fileResult] of sortedFiles) {\n const shortPath = this.shortenPath(file);\n const hasErrors = fileResult.errors.length > 0;\n const hasWarnings = fileResult.warnings.length > 0;\n const icon = hasErrors ? '❌' : hasWarnings ? '⚠️' : '✅';\n const status = hasErrors ? 'Has Errors' : hasWarnings ? 'Has Warnings' : 'Clean';\n \n lines.push(`<details>`);\n lines.push(`<summary>${icon} <strong>${shortPath}</strong> - ${status}</summary>`);\n lines.push('');\n lines.push('#### File Statistics');\n lines.push(`- **Entities:** ${fileResult.entityCount}`);\n lines.push(`- **Errors:** ${fileResult.errors.length}`);\n lines.push(`- **Warnings:** ${fileResult.warnings.length}`);\n \n if (hasErrors) {\n lines.push('');\n lines.push('#### Errors in this file:');\n fileResult.errors.forEach((error, idx) => {\n lines.push(`${idx + 1}. ${error.message}`);\n });\n }\n \n if (hasWarnings) {\n lines.push('');\n lines.push('#### Warnings in this file:');\n fileResult.warnings.forEach((warning, idx) => {\n lines.push(`${idx + 1}. ${warning.message}`);\n });\n }\n \n lines.push('');\n lines.push('</details>');\n lines.push('');\n }\n \n // Detailed Errors\n if (result.errors.length > 0) {\n lines.push('## ❌ Error Details');\n lines.push('');\n lines.push(`> Found ${result.errors.length} error(s) that must be fixed.`);\n lines.push('');\n \n result.errors.forEach((error, index) => {\n lines.push(`### Error ${index + 1}: ${error.message}`);\n lines.push('');\n \n lines.push(`**Type:** \\`${error.type}\\` `);\n if (error.entity) lines.push(`**Entity:** ${error.entity} `);\n if (error.field) lines.push(`**Field:** \\`${error.field}\\` `);\n lines.push(`**File:** \\`${this.shortenPath(error.file)}\\` `);\n lines.push(`**Severity:** ${error.severity} `);\n \n if (error.suggestion) {\n lines.push('');\n lines.push('> 💡 **Suggestion:** ' + error.suggestion);\n }\n \n lines.push('');\n lines.push('---');\n lines.push('');\n });\n }\n \n // Detailed Warnings\n if (result.warnings.length > 0) {\n lines.push('## ⚠️ Warning Details');\n lines.push('');\n lines.push(`> Found ${result.warnings.length} warning(s) for your review.`);\n lines.push('');\n \n // Group warnings by type for better organization\n const warningsByType = new Map<string, ValidationWarning[]>();\n result.warnings.forEach(warning => {\n if (!warningsByType.has(warning.type)) {\n warningsByType.set(warning.type, []);\n }\n warningsByType.get(warning.type)!.push(warning);\n });\n \n for (const [type, warnings] of warningsByType) {\n lines.push(`### Warning Type: \\`${type}\\``);\n lines.push('');\n \n warnings.forEach((warning, index) => {\n lines.push(`#### ${index + 1}. ${warning.message}`);\n lines.push('');\n \n if (warning.entity) lines.push(`**Entity:** ${warning.entity} `);\n if (warning.field) lines.push(`**Field:** \\`${warning.field}\\` `);\n lines.push(`**File:** \\`${this.shortenPath(warning.file)}\\` `);\n \n if (warning.suggestion) {\n lines.push('');\n lines.push('> 💡 **Suggestion:** ' + warning.suggestion);\n }\n \n lines.push('');\n });\n }\n }\n \n // Next Steps\n lines.push('## 🚀 Next Steps');\n lines.push('');\n \n if (result.errors.length > 0) {\n lines.push('### To fix errors:');\n lines.push('');\n lines.push('1. Review each error in the [Error Details](#error-details) section');\n lines.push('2. Follow the suggestions provided for each error');\n lines.push('3. Run validation again after making changes');\n lines.push('4. Repeat until all errors are resolved');\n lines.push('');\n }\n \n if (result.warnings.length > 0) {\n lines.push('### To address warnings:');\n lines.push('');\n lines.push('1. Review warnings in the [Warning Details](#warning-details) section');\n lines.push('2. Determine which warnings are relevant to your use case');\n lines.push('3. Apply suggested fixes where appropriate');\n lines.push('');\n }\n \n if (result.isValid) {\n lines.push('Your metadata is valid and ready to sync! 🎉');\n lines.push('');\n lines.push('```bash');\n lines.push('# Push your metadata to the database');\n lines.push('mj-sync push');\n lines.push('```');\n }\n \n // Resources\n lines.push('');\n lines.push('## 📚 Resources');\n lines.push('');\n lines.push('- 📖 [MetadataSync Documentation](https://github.com/MemberJunction/MJ/tree/next/packages/MetadataSync)');\n lines.push('- 🐛 [Report Issues](https://github.com/MemberJunction/MJ/issues)');\n lines.push('- 💬 [MemberJunction Community](https://memberjunction.org)');\n lines.push('- 📝 [Validation Rules Guide](https://github.com/MemberJunction/MJ/tree/next/packages/MetadataSync#validation-features)');\n lines.push('');\n \n // Footer\n lines.push('---');\n lines.push('');\n lines.push('<div align=\"center\">');\n lines.push('');\n lines.push('**Generated by [MemberJunction](https://memberjunction.org) Metadata Sync**');\n lines.push('');\n lines.push(`<sub>${timestamp.toISOString()}</sub>`);\n lines.push('');\n lines.push('</div>');\n \n return lines.join('\\n');\n }\n}"]}