@memberjunction/metadata-sync 2.112.0 → 2.113.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.
Files changed (42) hide show
  1. package/README.md +136 -61
  2. package/dist/constants/metadata-keywords.d.ts +282 -0
  3. package/dist/constants/metadata-keywords.js +364 -0
  4. package/dist/constants/metadata-keywords.js.map +1 -0
  5. package/dist/lib/EntityPropertyExtractor.d.ts +1 -1
  6. package/dist/lib/EntityPropertyExtractor.js +4 -18
  7. package/dist/lib/EntityPropertyExtractor.js.map +1 -1
  8. package/dist/lib/FieldExternalizer.d.ts +1 -1
  9. package/dist/lib/FieldExternalizer.js +6 -5
  10. package/dist/lib/FieldExternalizer.js.map +1 -1
  11. package/dist/lib/RecordProcessor.d.ts +1 -1
  12. package/dist/lib/RecordProcessor.js +14 -12
  13. package/dist/lib/RecordProcessor.js.map +1 -1
  14. package/dist/lib/RelatedEntityHandler.d.ts +1 -1
  15. package/dist/lib/RelatedEntityHandler.js +5 -5
  16. package/dist/lib/RelatedEntityHandler.js.map +1 -1
  17. package/dist/lib/json-preprocessor.js +7 -6
  18. package/dist/lib/json-preprocessor.js.map +1 -1
  19. package/dist/lib/provider-utils.d.ts +1 -1
  20. package/dist/lib/provider-utils.js +19 -16
  21. package/dist/lib/provider-utils.js.map +1 -1
  22. package/dist/lib/record-dependency-analyzer.js +44 -37
  23. package/dist/lib/record-dependency-analyzer.js.map +1 -1
  24. package/dist/lib/singleton-manager.d.ts +1 -1
  25. package/dist/lib/singleton-manager.js.map +1 -1
  26. package/dist/lib/sync-engine.d.ts +1 -1
  27. package/dist/lib/sync-engine.js +36 -44
  28. package/dist/lib/sync-engine.js.map +1 -1
  29. package/dist/services/PullService.d.ts +1 -1
  30. package/dist/services/PullService.js +18 -22
  31. package/dist/services/PullService.js.map +1 -1
  32. package/dist/services/PushService.d.ts +1 -1
  33. package/dist/services/PushService.js +21 -15
  34. package/dist/services/PushService.js.map +1 -1
  35. package/dist/services/ValidationService.js +32 -44
  36. package/dist/services/ValidationService.js.map +1 -1
  37. package/dist/services/WatchService.d.ts +1 -1
  38. package/dist/services/WatchService.js +14 -13
  39. package/dist/services/WatchService.js.map +1 -1
  40. package/dist/types/validation.d.ts +6 -1
  41. package/dist/types/validation.js.map +1 -1
  42. package/package.json +7 -6
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationService.js","sourceRoot":"","sources":["../../src/services/ValidationService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwF;AACxF,uCAAyB;AACzB,2CAA6B;AAY7B,0DAAsD;AAMtD,MAAa,iBAAiB;IACpB,QAAQ,CAAW;IACnB,MAAM,GAAsB,EAAE,CAAC;IAC/B,QAAQ,GAAwB,EAAE,CAAC;IACnC,kBAAkB,GAAkC,IAAI,GAAG,EAAE,CAAC;IAC9D,iBAAiB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC3C,OAAO,CAAoB;IAC3B,aAAa,GAA0B,IAAI,GAAG,EAAE,CAAC;IAEzD,YAAY,UAAsC,EAAE;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG;YACb,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,OAAO;YACrB,eAAe,EAAE,EAAE;YACnB,kBAAkB,EAAE,IAAI;YACxB,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,iBAAiB,CAAC,GAAW;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,OAAO;gBACjB,IAAI,EA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E,UAAU,EAAE,GAAG,CAAC,CAAC;wBACzF,CAAC;oBACH,CAAC;yBAAM,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACtC,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;wBAC1C,IAAI,MAAM,EAAE,CAAC;4BACX,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;wBACvF,CAAC;oBACH,CAAC;yBAAM,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;wBACrC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;wBAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;4BACzB,IAAI,CAAC,UAAU,CAAC;gCACd,IAAI,EAAE,YAAY;gCAClB,QAAQ,EAAE,SAAS;gCACnB,MAAM,EAAE,UAAU;gCAClB,KAAK,EAAE,GAAG;gCACV,IAAI,EAAE,UAAU;gCAChB,OAAO,EAAE,yBAAyB,MAAM,wBAAwB;gCAChE,UAAU,EAAE,4DAA4D;6BACzE,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;qBAAM,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAC9C,qCAAqC;oBACrC,MAAM,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;gBAChG,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAt4CD,8CAs4CC","sourcesContent":["import { EntityFieldInfo, EntityInfo, Metadata, RunView } from '@memberjunction/global';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n ValidationResult,\n ValidationError,\n ValidationWarning,\n ValidationOptions,\n FileValidationResult,\n EntityDependency,\n ParsedReference,\n ReferenceType,\n} from '../types/validation';\nimport { RecordData } from '../lib/sync-engine';\nimport { getSystemUser } from '../lib/provider-utils';\n\n// Type aliases for clarity\ntype EntityData = RecordData;\ntype EntitySyncConfig = any;\n\nexport class ValidationService {\n private metadata: Metadata;\n private errors: ValidationError[] = [];\n private warnings: ValidationWarning[] = [];\n private entityDependencies: Map<string, EntityDependency> = new Map();\n private processedEntities: Set<string> = new Set();\n private options: ValidationOptions;\n private userRoleCache: Map<string, string[]> = new Map();\n\n constructor(options: Partial<ValidationOptions> = {}) {\n this.metadata = new Metadata();\n this.options = {\n verbose: false,\n outputFormat: 'human',\n maxNestingDepth: 10,\n checkBestPractices: true,\n ...options,\n };\n }\n\n /**\n * Validates all metadata files in the specified directory\n */\n public async validateDirectory(dir: string): Promise<ValidationResult> {\n this.reset();\n\n const configPath = path.join(dir, '.mj-sync.json');\n if (!fs.existsSync(configPath)) {\n this.addError({\n type: 'entity',\n severity: 'error',\n file: dir,\n message: 'No .mj-sync.json configuration file found in directory',\n });\n return this.getResult();\n }\n\n const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n\n // Load user role configuration and cache if enabled\n if (config.userRoleValidation?.enabled) {\n await this.loadUserRoles();\n }\n\n const directories = await this.getDirectoriesInOrder(dir, config);\n\n let totalFiles = 0;\n let totalEntities = 0;\n const fileResults = new Map<string, FileValidationResult>();\n\n for (const subDir of directories) {\n const subDirPath = path.join(dir, subDir);\n const result = await this.validateEntityDirectory(subDirPath);\n if (result) {\n totalFiles += result.files;\n totalEntities += result.entities;\n for (const [file, fileResult] of result.fileResults) {\n fileResults.set(file, fileResult);\n }\n }\n }\n\n // Validate dependency order\n await this.validateDependencyOrder(directories);\n\n return {\n isValid: this.errors.length === 0,\n errors: this.errors,\n warnings: this.warnings,\n summary: {\n totalFiles,\n totalEntities,\n totalErrors: this.errors.length,\n totalWarnings: this.warnings.length,\n fileResults,\n },\n };\n }\n\n /**\n * Validates a single entity directory\n */\n private async validateEntityDirectory(\n dir: string\n ): Promise<{ files: number; entities: number; fileResults: Map<string, FileValidationResult> } | null> {\n // Check for .mj-folder.json first (new format)\n let configPath = path.join(dir, '.mj-folder.json');\n let config: any;\n\n if (fs.existsSync(configPath)) {\n config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n // .mj-folder.json uses entityName field\n if (!config.entityName) {\n this.addError({\n type: 'validation',\n severity: 'error',\n file: configPath,\n message: 'Missing entityName field in .mj-folder.json',\n });\n return null;\n }\n config.entity = config.entityName; // Normalize to entity field\n } else {\n // Fall back to .mj-sync.json (legacy format)\n configPath = path.join(dir, '.mj-sync.json');\n if (!fs.existsSync(configPath)) {\n return null;\n }\n config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n }\n\n // Validate entity name exists\n if (!config.entity || config.entity.trim() === '') {\n this.addError({\n type: 'validation',\n severity: 'error',\n file: configPath,\n message: 'Entity name is empty or missing',\n });\n return null;\n }\n\n const entityInfo = this.metadata.EntityByName(config.entity);\n\n if (!entityInfo) {\n this.addError({\n type: 'entity',\n severity: 'error',\n file: configPath,\n message: `Entity \"${config.entity}\" not found in metadata`,\n });\n return null;\n }\n\n const files = await this.getMatchingFiles(dir, config.filePattern);\n let totalEntities = 0;\n const fileResults = new Map<string, FileValidationResult>();\n\n for (const file of files) {\n const filePath = path.join(dir, file);\n const result = await this.validateFile(filePath, entityInfo, config);\n totalEntities += result.entityCount;\n fileResults.set(filePath, result);\n }\n\n return { files: files.length, entities: totalEntities, fileResults };\n }\n\n /**\n * Validates a single metadata file\n */\n private async validateFile(filePath: string, entityInfo: any, config: EntitySyncConfig): Promise<FileValidationResult> {\n const fileErrors: ValidationError[] = [];\n let entityCount = 0;\n\n try {\n const content = fs.readFileSync(filePath, 'utf8');\n const data = JSON.parse(content);\n const entities = Array.isArray(data) ? data : [data];\n entityCount = entities.length;\n\n for (const entityData of entities) {\n await this.validateEntityData(entityData, entityInfo, filePath, config);\n }\n } catch (error) {\n fileErrors.push({\n type: 'entity',\n severity: 'error',\n file: filePath,\n message: `Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Collect errors and warnings for this file\n const currentFileErrors = this.errors.filter((e) => e.file === filePath);\n const currentFileWarnings = this.warnings.filter((w) => w.file === filePath);\n\n return {\n file: filePath,\n entityCount,\n errors: currentFileErrors,\n warnings: currentFileWarnings,\n };\n }\n\n /**\n * Validates a single entity data object\n */\n private async validateEntityData(\n entityData: EntityData,\n entityInfo: any,\n filePath: string,\n config: EntitySyncConfig,\n parentContext?: { entity: string; field: string },\n depth: number = 0\n ): Promise<void> {\n // Check nesting depth\n if (depth > this.options.maxNestingDepth) {\n this.addWarning({\n type: 'nesting',\n severity: 'warning',\n entity: entityInfo.Name,\n file: filePath,\n message: `Nesting depth ${depth} exceeds recommended maximum of ${this.options.maxNestingDepth}`,\n suggestion: 'Consider flattening the data structure or increasing maxNestingDepth',\n });\n }\n\n // Validate fields\n if (entityData.fields) {\n await this.validateFields(entityData.fields, entityInfo, filePath, parentContext);\n }\n\n // Track dependencies\n this.trackEntityDependencies(entityData, entityInfo.Name, filePath);\n\n // Validate related entities\n if (entityData.relatedEntities) {\n for (const [relatedEntityName, relatedData] of Object.entries(entityData.relatedEntities)) {\n const relatedEntityInfo = this.metadata.EntityByName(relatedEntityName);\n if (!relatedEntityInfo) {\n this.addError({\n type: 'entity',\n severity: 'error',\n entity: entityInfo.Name,\n file: filePath,\n message: `Related entity \"${relatedEntityName}\" not found in metadata`,\n });\n continue;\n }\n\n const relatedEntities = Array.isArray(relatedData) ? relatedData : [relatedData];\n for (const relatedEntity of relatedEntities) {\n await this.validateEntityData(\n relatedEntity,\n relatedEntityInfo,\n filePath,\n config,\n { entity: entityInfo.Name, field: relatedEntityName },\n depth + 1\n );\n }\n }\n }\n }\n\n /**\n * Validates entity fields\n */\n private async validateFields(\n fields: Record<string, any>,\n entityInfo: EntityInfo,\n filePath: string,\n parentContext?: { entity: string; field: string }\n ): Promise<void> {\n const entityFields = entityInfo.Fields;\n const fieldMap = new Map(entityFields.map((f) => [f.Name, f]));\n\n for (const [fieldName, fieldValue] of Object.entries(fields)) {\n const fieldInfo = fieldMap.get(fieldName);\n\n if (!fieldInfo) {\n // Check if this might be a virtual property (getter/setter)\n try {\n const entityInstance = await this.metadata.GetEntityObject(entityInfo.Name);\n // we use this approach instead of checking Entity Fields because\n // some sub-classes implement setter properties that allow you to set\n // values that are not physically in the database but are resolved by the sub-class\n // a good example is the sub-class for AI Prompts that has a property called TemplateText\n // that is automatically resolved into a separate record in the Templates/Template Contents entity\n const hasProperty = fieldName in entityInstance;\n\n if (!hasProperty) {\n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldName,\n file: filePath,\n message: `Field \"${fieldName}\" does not exist on entity \"${entityInfo.Name}\"`,\n });\n continue;\n }\n\n continue;\n } catch (error) {\n // If we can't create an entity instance, fall back to error\n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldName,\n file: filePath,\n message: `Field \"${fieldName}\" does not exist on entity \"${entityInfo.Name}\"`,\n });\n continue;\n }\n }\n\n // Check if field is settable (not system field)\n if (fieldInfo.ReadOnly || fieldName.startsWith('__mj_')) {\n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldName,\n file: filePath,\n message: `Field \"${fieldName}\" is a read-only or system field and cannot be set`,\n suggestion: 'Remove this field from your metadata file',\n });\n continue;\n }\n\n // Validate field value and references\n await this.validateFieldValue(fieldValue, fieldInfo, entityInfo, filePath, parentContext);\n }\n\n // Check for required fields\n if (this.options.checkBestPractices) {\n for (const field of entityFields) {\n // Skip if field allows null or has a value already\n if (field.AllowsNull || fields[field.Name]) {\n continue;\n }\n\n // Skip if field has a default value\n if (field.DefaultValue !== null && field.DefaultValue !== undefined) {\n continue;\n }\n\n // Skip virtual/computed fields (foreign key reference fields)\n // These are typically named without 'ID' suffix but have a corresponding FK field\n const relatedEntityField = field.RelatedEntity;\n const correspondingFKField = entityFields.find((f: any) => f.Name === field.Name + 'ID' && f.IsForeignKey);\n if (relatedEntityField && correspondingFKField) {\n continue;\n }\n\n // Skip fields that are marked as AutoUpdateOnly or ReadOnly\n if (field.AutoIncrement || field.ReadOnly) {\n continue;\n }\n\n // Skip if this is a parent context and the field can be inherited\n if (parentContext && (field.Name === parentContext.field || field.Name === parentContext.field + 'ID')) {\n continue;\n }\n\n // Special case: Skip TemplateID if TemplateText is provided (virtual property)\n if (field.Name === 'TemplateID' && fields['TemplateText']) {\n continue;\n }\n\n // Skip Template field if TemplateText is provided\n if (field.Name === 'Template' && fields['TemplateText']) {\n continue;\n }\n\n this.addWarning({\n type: 'bestpractice',\n severity: 'warning',\n entity: entityInfo.Name,\n field: field.Name,\n file: filePath,\n message: `Required field \"${field.Name}\" is missing`,\n suggestion: `Add \"${field.Name}\" to the fields object`,\n });\n }\n }\n }\n\n /**\n * Validates field values and references\n */\n private async validateFieldValue(\n value: any,\n fieldInfo: EntityFieldInfo,\n entityInfo: EntityInfo,\n filePath: string,\n parentContext?: { entity: string; field: string }\n ): Promise<void> {\n if (typeof value === 'string' && this.isValidReference(value)) {\n await this.validateReference(value, fieldInfo, entityInfo, filePath, parentContext);\n // Skip further validation for references as they will be resolved later\n return;\n }\n\n // Validate field value against value list if applicable\n await this.validateFieldValueList(value, fieldInfo, entityInfo, filePath);\n\n // Validate UserID fields against allowed roles\n if (fieldInfo.Name === 'UserID' && typeof value === 'string' && value.length > 0) {\n // Get the sync config from the file's directory\n const dir = path.dirname(filePath);\n\n // Walk up to find the root sync config with userRoleValidation\n let currentDir = dir;\n let config = null;\n while (currentDir && currentDir !== path.parse(currentDir).root) {\n const currentConfigPath = path.join(currentDir, '.mj-sync.json');\n if (fs.existsSync(currentConfigPath)) {\n try {\n const currentConfig = JSON.parse(fs.readFileSync(currentConfigPath, 'utf8'));\n if (currentConfig.userRoleValidation) {\n config = currentConfig;\n break;\n }\n } catch {\n // Ignore parse errors\n }\n }\n currentDir = path.dirname(currentDir);\n }\n\n if (config?.userRoleValidation?.enabled) {\n await this.validateUserRole(value, entityInfo.Name, fieldInfo.Name, filePath, config);\n }\n }\n\n // Add other type validation here if needed\n }\n\n /**\n * Validates field value against the field's value list if applicable\n */\n private async validateFieldValueList(value: any, fieldInfo: EntityFieldInfo, entityInfo: EntityInfo, filePath: string): Promise<void> {\n // Skip validation if value is null/undefined (handled by required field check)\n if (value === null || value === undefined || value === '') {\n return;\n }\n\n // Check if this field has a value list constraint\n if (fieldInfo.ValueListType !== 'List') {\n return;\n }\n\n // Get the allowed values from EntityFieldValues\n const entityFieldValues = fieldInfo.EntityFieldValues;\n if (!entityFieldValues || !Array.isArray(entityFieldValues) || entityFieldValues.length === 0) {\n // No values defined, skip validation\n return;\n }\n\n // Extract the allowed values\n const allowedValues = entityFieldValues.map((efv: any) => efv.Value);\n\n // Convert value to string for comparison (in case it's a number or boolean)\n const stringValue = String(value);\n\n // Check if the value is in the allowed list\n if (!allowedValues.includes(stringValue)) {\n // Check case-insensitive match as a warning\n const caseInsensitiveMatch = allowedValues.find((av: string) => av.toLowerCase() === stringValue.toLowerCase());\n\n if (caseInsensitiveMatch) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n entity: entityInfo.Name,\n field: fieldInfo.Name,\n file: filePath,\n message: `Field \"${fieldInfo.Name}\" has value \"${stringValue}\" which differs in case from allowed value \"${caseInsensitiveMatch}\"`,\n suggestion: `Use \"${caseInsensitiveMatch}\" for consistency`,\n });\n } else {\n // Format the allowed values list for display\n const allowedValuesList =\n allowedValues.length <= 10\n ? allowedValues.join(', ')\n : allowedValues.slice(0, 10).join(', ') + `, ... (${allowedValues.length - 10} more)`;\n\n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldInfo.Name,\n file: filePath,\n message: `Field \"${fieldInfo.Name}\" has invalid value \"${stringValue}\"`,\n suggestion: `Allowed values are: ${allowedValuesList}`,\n });\n }\n }\n }\n\n /**\n * Check if a string is actually a MetadataSync reference (not just any @ string)\n */\n private isValidReference(value: string): boolean {\n if (typeof value !== 'string' || !value.startsWith('@')) {\n return false;\n }\n\n // List of valid reference prefixes\n const validPrefixes = [\n '@file:',\n '@lookup:',\n '@template:',\n '@parent:',\n '@root:',\n '@env:',\n '@include', // Can be @include or @include.\n ];\n\n return validPrefixes.some((prefix) => value.startsWith(prefix));\n }\n\n /**\n * Validates special references (@file:, @lookup:, etc.)\n */\n private async validateReference(\n reference: string,\n fieldInfo: EntityFieldInfo,\n entityInfo: EntityInfo,\n filePath: string,\n parentContext?: { entity: string; field: string }\n ): Promise<void> {\n const parsed = this.parseReference(reference);\n if (!parsed) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldInfo.Name,\n file: filePath,\n message: `Invalid reference format: \"${reference}\"`,\n });\n return;\n }\n\n switch (parsed.type) {\n case '@file:':\n await this.validateFileReference(parsed.value, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case '@lookup:':\n await this.validateLookupReference(parsed, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case '@template:':\n await this.validateTemplateReference(parsed.value, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case '@parent:':\n this.validateParentReference(parsed.value, parentContext, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case '@root:':\n this.validateRootReference(parsed.value, parentContext, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n }\n }\n\n /**\n * Parses a reference string\n */\n private parseReference(reference: string): ParsedReference | null {\n const patterns: [ReferenceType, RegExp][] = [\n ['@file:', /^@file:(.+)$/],\n ['@lookup:', /^@lookup:([^.]+)\\.(.+)$/],\n ['@template:', /^@template:(.+)$/],\n ['@parent:', /^@parent:(.+)$/],\n ['@root:', /^@root:(.+)$/],\n ['@env:', /^@env:(.+)$/],\n ];\n\n for (const [type, pattern] of patterns) {\n const match = reference.match(pattern);\n if (match) {\n if (type === '@lookup:') {\n const [, entity, remaining] = match;\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 lookupPairs = lookupPart.split('&');\n const fields: Array<{ field: string; value: string }> = [];\n\n for (const pair of lookupPairs) {\n const fieldMatch = pair.match(/^(.+?)=(.+)$/);\n if (fieldMatch) {\n const [, field, value] = fieldMatch;\n fields.push({ field: field.trim(), value: value.trim() });\n }\n }\n\n // For backward compatibility, use the first field as primary\n const primaryField = fields.length > 0 ? fields[0] : { field: '', value: '' };\n\n // Parse additional fields for creation if ?create is present\n const additionalFields: 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 additionalFields[key] = decodeURIComponent(val);\n }\n }\n }\n\n return {\n type,\n value: primaryField.value,\n entity,\n field: primaryField.field,\n fields, // Include all fields for validation\n createIfMissing: hasCreate,\n additionalFields,\n };\n }\n return { type, value: match[1] };\n }\n }\n\n return null;\n }\n\n /**\n * Validates @file: references\n */\n private async validateFileReference(\n filePath: string,\n sourceFile: string,\n entityName: string,\n fieldName: string,\n visitedFiles?: Set<string>\n ): Promise<void> {\n const dir = path.dirname(sourceFile);\n const resolvedPath = path.resolve(dir, filePath);\n\n // Initialize visited files set if not provided (for circular reference detection)\n const visited = visitedFiles || new Set<string>();\n\n // Check for circular references\n if (visited.has(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Circular @file reference detected: \"${filePath}\"`,\n details: `Path ${resolvedPath} is already being processed`,\n suggestion: 'Restructure your file references to avoid circular dependencies',\n });\n return;\n }\n\n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `File reference not found: \"${filePath}\"`,\n suggestion: `Create file at: ${resolvedPath}`,\n });\n return;\n }\n\n // Add to visited set\n visited.add(resolvedPath);\n\n // Read the file and check for references\n try {\n const content = fs.readFileSync(resolvedPath, 'utf-8');\n\n // Check for {@include} references in all file types\n await this.validateIncludeReferences(content, resolvedPath, new Set([resolvedPath]));\n\n // If it's a JSON file, parse and validate nested @ references\n if (resolvedPath.endsWith('.json')) {\n try {\n const jsonContent = JSON.parse(content);\n\n // Check if JSON contains @include directives that need preprocessing\n const jsonString = JSON.stringify(jsonContent);\n const hasIncludes = jsonString.includes('\"@include\"') || jsonString.includes('\"@include.');\n\n if (hasIncludes) {\n await this.validateJsonIncludes(jsonContent, resolvedPath);\n }\n\n // Recursively validate all @ references in the JSON structure\n await this.validateJsonReferences(jsonContent, resolvedPath, entityName, visited);\n } catch (parseError) {\n // Not valid JSON or error parsing, treat as text file (already validated {@include} above)\n if (this.options.verbose) {\n console.log(`File ${resolvedPath} is not valid JSON, treating as text file`);\n }\n }\n }\n } catch (error) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Failed to read file reference: \"${filePath}\"`,\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Validates @lookup: references\n */\n private async validateLookupReference(parsed: ParsedReference, sourceFile: string, entityName: string, fieldName: string): Promise<void> {\n const lookupEntity = this.metadata.EntityByName(parsed.entity!);\n\n if (!lookupEntity) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Lookup entity \"${parsed.entity}\" not found`,\n suggestion: 'Check entity name spelling and case',\n });\n return;\n }\n\n // For multi-field lookups, validate all fields\n if (parsed.fields && parsed.fields.length > 0) {\n for (const { field } of parsed.fields) {\n const lookupField = lookupEntity.Fields.find((f: any) => f.Name === field);\n if (!lookupField) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Lookup field \"${field}\" not found on entity \"${parsed.entity}\"`,\n suggestion: `Available fields: ${lookupEntity.Fields.map((f: any) => f.Name).join(', ')}`,\n });\n }\n }\n } else if (parsed.field) {\n // Fallback for single field lookup (backward compatibility)\n const lookupField = lookupEntity.Fields.find((f: any) => f.Name === parsed.field);\n if (!lookupField) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Lookup field \"${parsed.field}\" not found on entity \"${parsed.entity}\"`,\n suggestion: `Available fields: ${lookupEntity.Fields.map((f: any) => f.Name).join(', ')}`,\n });\n }\n }\n\n // Track dependency\n this.addEntityDependency(entityName, parsed.entity!);\n }\n\n /**\n * Validates @template: references\n */\n private async validateTemplateReference(templatePath: string, sourceFile: string, entityName: string, fieldName: string): Promise<void> {\n const dir = path.dirname(sourceFile);\n const resolvedPath = path.resolve(dir, templatePath);\n\n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Template file not found: \"${templatePath}\"`,\n suggestion: `Create template at: ${resolvedPath}`,\n });\n return;\n }\n\n // Validate template is valid JSON\n try {\n JSON.parse(fs.readFileSync(resolvedPath, 'utf8'));\n } catch (error) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Template file is not valid JSON: \"${templatePath}\"`,\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Validates @parent: references\n */\n private validateParentReference(\n _fieldName: string,\n parentContext: { entity: string; field: string } | undefined,\n sourceFile: string,\n entityName: string,\n currentFieldName: string\n ): void {\n if (!parentContext) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: currentFieldName,\n file: sourceFile,\n message: `@parent: reference used but no parent context exists`,\n suggestion: '@parent: can only be used in nested/related entities',\n });\n }\n }\n\n /**\n * Validates @root: references\n */\n private validateRootReference(\n _fieldName: string,\n parentContext: { entity: string; field: string } | undefined,\n sourceFile: string,\n entityName: string,\n currentFieldName: string\n ): void {\n if (!parentContext) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: currentFieldName,\n file: sourceFile,\n message: `@root: reference used but no root context exists`,\n suggestion: '@root: can only be used in nested/related entities',\n });\n }\n }\n\n /**\n * Track entity dependencies\n */\n private trackEntityDependencies(entityData: EntityData, entityName: string, filePath: string): void {\n if (!this.entityDependencies.has(entityName)) {\n this.entityDependencies.set(entityName, {\n entityName,\n dependsOn: new Set(),\n file: filePath,\n });\n }\n\n // Track dependencies from lookups in fields\n if (entityData.fields) {\n for (const value of Object.values(entityData.fields)) {\n if (typeof value === 'string' && value.startsWith('@lookup:')) {\n const parsed = this.parseReference(value);\n if (parsed?.entity) {\n this.addEntityDependency(entityName, parsed.entity);\n }\n }\n }\n }\n }\n\n /**\n * Add an entity dependency\n */\n private addEntityDependency(from: string, to: string): void {\n // Don't add self-references as dependencies (e.g., ParentID in hierarchical structures)\n if (from === to) {\n return;\n }\n\n if (!this.entityDependencies.has(from)) {\n this.entityDependencies.set(from, {\n entityName: from,\n dependsOn: new Set(),\n file: '',\n });\n }\n this.entityDependencies.get(from)!.dependsOn.add(to);\n }\n\n /**\n * Validates dependency order\n */\n private async validateDependencyOrder(directoryOrder: string[]): Promise<void> {\n // Build a map of entity to directory\n const entityToDirectory = new Map<string, string>();\n\n for (const dir of directoryOrder) {\n // This is simplified - in reality we'd need to read the .mj-sync.json\n // to get the actual entity name\n entityToDirectory.set(dir, dir);\n }\n\n // Check for circular dependencies\n const visited = new Set<string>();\n const recursionStack = new Set<string>();\n\n for (const [entity] of this.entityDependencies) {\n if (!visited.has(entity)) {\n this.checkCircularDependency(entity, visited, recursionStack);\n }\n }\n\n // Check if current order satisfies dependencies\n const orderViolations = this.checkDependencyOrder(directoryOrder);\n if (orderViolations.length > 0) {\n // Suggest a corrected order\n const suggestedOrder = this.topologicalSort();\n\n for (const violation of orderViolations) {\n this.addError({\n type: 'dependency',\n severity: 'error',\n entity: violation.entity,\n file: violation.file,\n message: `Entity '${violation.entity}' depends on '${violation.dependency}' but is processed before it`,\n suggestion: `Reorder directories to: [${suggestedOrder.join(', ')}]`,\n });\n }\n }\n }\n\n /**\n * Check for circular dependencies\n */\n private checkCircularDependency(entity: string, visited: Set<string>, recursionStack: Set<string>, path: string[] = []): boolean {\n visited.add(entity);\n recursionStack.add(entity);\n path.push(entity);\n\n const deps = this.entityDependencies.get(entity);\n if (deps) {\n for (const dep of deps.dependsOn) {\n if (!visited.has(dep)) {\n if (this.checkCircularDependency(dep, visited, recursionStack, [...path])) {\n return true;\n }\n } else if (recursionStack.has(dep)) {\n // Found circular dependency\n const cycle = [...path, dep];\n const cycleStart = cycle.indexOf(dep);\n const cyclePath = cycle.slice(cycleStart).join(' → ');\n\n this.addError({\n type: 'circular',\n severity: 'error',\n entity: entity,\n file: deps.file,\n message: `Circular dependency detected: ${cyclePath}`,\n suggestion: 'Restructure your entities to avoid circular references',\n });\n return true;\n }\n }\n }\n\n recursionStack.delete(entity);\n return false;\n }\n\n /**\n * Get directories in order based on config\n */\n private async getDirectoriesInOrder(rootDir: string, config: any): Promise<string[]> {\n const allDirs = fs\n .readdirSync(rootDir)\n .filter((f) => fs.statSync(path.join(rootDir, f)).isDirectory())\n .filter((d) => !d.startsWith('.'));\n\n if (config.directoryOrder && Array.isArray(config.directoryOrder)) {\n const ordered = config.directoryOrder.filter((d: string) => allDirs.includes(d));\n const remaining = allDirs.filter((d) => !ordered.includes(d)).sort();\n return [...ordered, ...remaining];\n }\n\n return allDirs.sort();\n }\n\n /**\n * Get files matching pattern\n */\n private async getMatchingFiles(dir: string, pattern: string): Promise<string[]> {\n const files = fs.readdirSync(dir).filter((f) => fs.statSync(path.join(dir, f)).isFile());\n\n // Simple glob pattern matching\n if (pattern === '*.json') {\n return files.filter((f) => f.endsWith('.json') && !f.startsWith('.mj-'));\n } else if (pattern === '.*.json') {\n return files.filter((f) => f.startsWith('.') && f.endsWith('.json') && !f.startsWith('.mj-'));\n }\n\n return files;\n }\n\n /**\n * Add an error\n */\n private addError(error: ValidationError): void {\n this.errors.push(error);\n }\n\n /**\n * Add a warning\n */\n private addWarning(warning: ValidationWarning): void {\n this.warnings.push(warning);\n }\n\n /**\n * Check if current directory order satisfies dependencies\n */\n private checkDependencyOrder(directoryOrder: string[]): Array<{ entity: string; dependency: string; file: string }> {\n const violations: Array<{ entity: string; dependency: string; file: string }> = [];\n const processedEntities = new Set<string>();\n\n for (const dir of directoryOrder) {\n // In real implementation, we'd read .mj-sync.json to get entity name\n const entityName = dir; // Simplified for now\n\n const deps = this.entityDependencies.get(entityName);\n if (deps) {\n for (const dep of deps.dependsOn) {\n if (!processedEntities.has(dep) && directoryOrder.includes(dep)) {\n violations.push({\n entity: entityName,\n dependency: dep,\n file: deps.file,\n });\n }\n }\n }\n\n processedEntities.add(entityName);\n }\n\n return violations;\n }\n\n /**\n * Perform topological sort on entity dependencies\n */\n private topologicalSort(): string[] {\n const result: string[] = [];\n const visited = new Set<string>();\n const tempStack = new Set<string>();\n\n const visit = (entity: string): boolean => {\n if (tempStack.has(entity)) {\n // Circular dependency, already handled by checkCircularDependency\n return false;\n }\n\n if (visited.has(entity)) {\n return true;\n }\n\n tempStack.add(entity);\n\n const deps = this.entityDependencies.get(entity);\n if (deps) {\n for (const dep of deps.dependsOn) {\n if (!visit(dep)) {\n return false;\n }\n }\n }\n\n tempStack.delete(entity);\n visited.add(entity);\n result.push(entity);\n\n return true;\n };\n\n // Visit all entities\n for (const entity of this.entityDependencies.keys()) {\n if (!visited.has(entity)) {\n visit(entity);\n }\n }\n\n return result;\n }\n\n /**\n * Reset validation state\n */\n private reset(): void {\n this.errors = [];\n this.warnings = [];\n this.entityDependencies.clear();\n this.processedEntities.clear();\n this.userRoleCache.clear();\n }\n\n /**\n * Get validation result\n */\n private getResult(): ValidationResult {\n return {\n isValid: this.errors.length === 0,\n errors: this.errors,\n warnings: this.warnings,\n summary: {\n totalFiles: 0,\n totalEntities: 0,\n totalErrors: this.errors.length,\n totalWarnings: this.warnings.length,\n fileResults: new Map(),\n },\n };\n }\n\n /**\n * Load user roles from the database into cache\n */\n private async loadUserRoles(): Promise<void> {\n try {\n const rv = new RunView();\n const systemUser = getSystemUser();\n\n // Load all user roles with role names\n const result = await rv.RunView(\n {\n EntityName: 'User Roles',\n ExtraFilter: '',\n OrderBy: 'UserID',\n MaxRows: 10000,\n },\n systemUser\n );\n\n if (!result.Success) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n file: 'system',\n message: 'Failed to load user roles for validation',\n details: result.ErrorMessage,\n });\n return;\n }\n\n // Group roles by UserID\n for (const userRole of result.Results || []) {\n const userId = userRole.UserID;\n const roleName = userRole.Role;\n\n if (!this.userRoleCache.has(userId)) {\n this.userRoleCache.set(userId, []);\n }\n this.userRoleCache.get(userId)!.push(roleName);\n }\n\n if (this.options.verbose) {\n console.log(`Loaded roles for ${this.userRoleCache.size} users`);\n }\n } catch (error) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n file: 'system',\n message: 'Error loading user roles for validation',\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Validate a UserID field value against allowed roles\n */\n private async validateUserRole(userId: string, entityName: string, fieldName: string, filePath: string, config: any): Promise<void> {\n // Skip if user role validation is not enabled\n if (!config.userRoleValidation?.enabled) {\n return;\n }\n\n const userRoles = this.userRoleCache.get(userId);\n const allowedRoles = config.userRoleValidation.allowedRoles || [];\n const allowUsersWithoutRoles = config.userRoleValidation.allowUsersWithoutRoles || false;\n\n if (!userRoles || userRoles.length === 0) {\n if (!allowUsersWithoutRoles) {\n this.addError({\n type: 'validation',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: filePath,\n message: `UserID '${userId}' does not have any assigned roles`,\n suggestion:\n allowedRoles.length > 0\n ? `User must have one of these roles: ${allowedRoles.join(', ')}`\n : 'Assign appropriate roles to this user or set allowUsersWithoutRoles: true',\n });\n }\n return;\n }\n\n // Check if user has at least one allowed role\n if (allowedRoles.length > 0) {\n const hasAllowedRole = userRoles.some((role) => allowedRoles.includes(role));\n if (!hasAllowedRole) {\n this.addError({\n type: 'validation',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: filePath,\n message: `UserID '${userId}' has roles [${userRoles.join(', ')}] but none are in allowed list`,\n suggestion: `Allowed roles: ${allowedRoles.join(', ')}`,\n });\n }\n }\n }\n\n /**\n * Validates {@include} references within file content\n *\n * Recursively checks all {@include path} references in file content to ensure:\n * - Referenced files exist\n * - No circular references occur\n * - Include paths are valid\n *\n * @param content - The file content to validate\n * @param filePath - Path of the file being validated\n * @param visitedPaths - Set of already visited paths for circular reference detection\n */\n private async validateIncludeReferences(content: string, filePath: string, visitedPaths: Set<string>): Promise<void> {\n // Pattern to match {@include path} references\n const includePattern = /\\{@include\\s+([^\\}]+)\\s*\\}/g;\n let match: RegExpExecArray | null;\n\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 // Check for circular reference\n if (visitedPaths.has(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: filePath,\n message: `Circular {@include} reference detected: \"${trimmedPath}\"`,\n details: `Path ${resolvedPath} is already being processed`,\n suggestion: 'Restructure your includes to avoid circular references',\n });\n continue;\n }\n\n // Check if the included file exists\n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: filePath,\n message: `{@include} file not found: \"${trimmedPath}\"`,\n suggestion: `Create file at: ${resolvedPath}`,\n });\n continue;\n }\n\n // Recursively validate the included file\n try {\n const includedContent = fs.readFileSync(resolvedPath, 'utf-8');\n const newVisitedPaths = new Set(visitedPaths);\n newVisitedPaths.add(resolvedPath);\n await this.validateIncludeReferences(includedContent, resolvedPath, newVisitedPaths);\n } catch (error) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: filePath,\n message: `Failed to read {@include} file: \"${trimmedPath}\"`,\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n /**\n * Validates @include directives in JSON files\n */\n private async validateJsonIncludes(jsonContent: any, sourceFile: string): Promise<void> {\n // Process based on data type\n if (Array.isArray(jsonContent)) {\n for (const item of jsonContent) {\n if (typeof item === 'string' && item.startsWith('@include:')) {\n const includePath = item.substring(9).trim();\n await this.validateIncludeFile(includePath, sourceFile);\n } else if (item && typeof item === 'object') {\n await this.validateJsonIncludes(item, sourceFile);\n }\n }\n } else if (jsonContent && typeof jsonContent === 'object') {\n for (const [key, value] of Object.entries(jsonContent)) {\n if (key === '@include' || key.startsWith('@include.')) {\n let includeFile: string;\n if (typeof value === 'string') {\n includeFile = value;\n } else if (value && typeof value === 'object' && 'file' in value) {\n includeFile = (value as any).file;\n } else {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: sourceFile,\n message: `Invalid @include directive format for key \"${key}\"`,\n suggestion: 'Use either a string path or an object with a \"file\" property',\n });\n continue;\n }\n await this.validateIncludeFile(includeFile, sourceFile);\n } else if (value && typeof value === 'object') {\n await this.validateJsonIncludes(value, sourceFile);\n }\n }\n }\n }\n\n /**\n * Validates a single include file path\n */\n private async validateIncludeFile(includePath: string, sourceFile: string): Promise<void> {\n const dir = path.dirname(sourceFile);\n const resolvedPath = path.resolve(dir, includePath);\n\n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: sourceFile,\n message: `@include file not found: \"${includePath}\"`,\n suggestion: `Create file at: ${resolvedPath}`,\n });\n }\n }\n\n /**\n * Recursively validates all @ references in a JSON structure\n */\n private async validateJsonReferences(\n obj: any,\n sourceFile: string,\n entityName: string,\n visitedFiles: Set<string>,\n parentContext?: { entity: string; field: string }\n ): Promise<void> {\n if (obj === null || obj === undefined) {\n return;\n }\n\n if (Array.isArray(obj)) {\n for (const item of obj) {\n await this.validateJsonReferences(item, sourceFile, entityName, visitedFiles, parentContext);\n }\n } else if (typeof obj === 'object') {\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === 'string' && this.isValidReference(value)) {\n // Process different reference types\n if (value.startsWith('@file:')) {\n const filePath = value.substring(6);\n // Recursively validate the file reference (with circular detection)\n await this.validateFileReference(filePath, sourceFile, entityName, key, visitedFiles);\n } else if (value.startsWith('@lookup:')) {\n // Parse and validate lookup reference\n const parsed = this.parseReference(value);\n if (parsed) {\n await this.validateLookupReference(parsed, sourceFile, entityName, key);\n }\n } else if (value.startsWith('@template:')) {\n const templatePath = value.substring(10);\n await this.validateTemplateReference(templatePath, sourceFile, entityName, key);\n } else if (value.startsWith('@parent:')) {\n const parsed = this.parseReference(value);\n if (parsed) {\n this.validateParentReference(parsed.value, parentContext, sourceFile, entityName, key);\n }\n } else if (value.startsWith('@root:')) {\n const parsed = this.parseReference(value);\n if (parsed) {\n this.validateRootReference(parsed.value, parentContext, sourceFile, entityName, key);\n }\n } else if (value.startsWith('@env:')) {\n const envVar = value.substring(5);\n if (!process.env[envVar]) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n entity: entityName,\n field: key,\n file: sourceFile,\n message: `Environment variable \"${envVar}\" is not currently set`,\n suggestion: `Ensure this variable is set before running push operations`,\n });\n }\n }\n } else if (value && typeof value === 'object') {\n // Recursively process nested objects\n await this.validateJsonReferences(value, sourceFile, entityName, visitedFiles, parentContext);\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ValidationService.js","sourceRoot":"","sources":["../../src/services/ValidationService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsF;AACtF,uCAAyB;AACzB,2CAA6B;AAY7B,0DAAsD;AACtD,sEAMwC;AAMxC,MAAa,iBAAiB;IACpB,QAAQ,CAAW;IACnB,MAAM,GAAsB,EAAE,CAAC;IAC/B,QAAQ,GAAwB,EAAE,CAAC;IACnC,kBAAkB,GAAkC,IAAI,GAAG,EAAE,CAAC;IAC9D,iBAAiB,GAAgB,IAAI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,CAAC;gCACd,IAAI,EAAE,YAAY;gCAClB,QAAQ,EAAE,SAAS;gCACnB,MAAM,EAAE,UAAU;gCAClB,KAAK,EAAE,GAAG;gCACV,IAAI,EAAE,UAAU;gCAChB,OAAO,EAAE,yBAAyB,MAAM,wBAAwB;gCAChE,UAAU,EAAE,4DAA4D;6BACzE,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;qBAAM,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAC9C,qCAAqC;oBACrC,MAAM,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;gBAChG,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA92CD,8CA82CC","sourcesContent":["import { EntityFieldInfo, EntityInfo, Metadata, RunView } from '@memberjunction/core';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n ValidationResult,\n ValidationError,\n ValidationWarning,\n ValidationOptions,\n FileValidationResult,\n EntityDependency,\n ParsedReference,\n ReferenceType,\n} from '../types/validation';\nimport { RecordData } from '../lib/sync-engine';\nimport { getSystemUser } from '../lib/provider-utils';\nimport {\n METADATA_KEYWORDS,\n METADATA_KEYWORD_PREFIXES,\n isMetadataKeyword,\n getMetadataKeywordType,\n extractKeywordValue\n} from '../constants/metadata-keywords';\n\n// Type aliases for clarity\ntype EntityData = RecordData;\ntype EntitySyncConfig = any;\n\nexport class ValidationService {\n private metadata: Metadata;\n private errors: ValidationError[] = [];\n private warnings: ValidationWarning[] = [];\n private entityDependencies: Map<string, EntityDependency> = new Map();\n private processedEntities: Set<string> = new Set();\n private options: ValidationOptions;\n private userRoleCache: Map<string, string[]> = new Map();\n\n constructor(options: Partial<ValidationOptions> = {}) {\n this.metadata = new Metadata();\n this.options = {\n verbose: false,\n outputFormat: 'human',\n maxNestingDepth: 10,\n checkBestPractices: true,\n ...options,\n };\n }\n\n /**\n * Validates all metadata files in the specified directory\n */\n public async validateDirectory(dir: string): Promise<ValidationResult> {\n this.reset();\n\n const configPath = path.join(dir, '.mj-sync.json');\n if (!fs.existsSync(configPath)) {\n this.addError({\n type: 'entity',\n severity: 'error',\n file: dir,\n message: 'No .mj-sync.json configuration file found in directory',\n });\n return this.getResult();\n }\n\n const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n\n // Load user role configuration and cache if enabled\n if (config.userRoleValidation?.enabled) {\n await this.loadUserRoles();\n }\n\n const directories = await this.getDirectoriesInOrder(dir, config);\n\n let totalFiles = 0;\n let totalEntities = 0;\n const fileResults = new Map<string, FileValidationResult>();\n\n for (const subDir of directories) {\n const subDirPath = path.join(dir, subDir);\n const result = await this.validateEntityDirectory(subDirPath);\n if (result) {\n totalFiles += result.files;\n totalEntities += result.entities;\n for (const [file, fileResult] of result.fileResults) {\n fileResults.set(file, fileResult);\n }\n }\n }\n\n // Validate dependency order\n await this.validateDependencyOrder(directories);\n\n return {\n isValid: this.errors.length === 0,\n errors: this.errors,\n warnings: this.warnings,\n summary: {\n totalFiles,\n totalEntities,\n totalErrors: this.errors.length,\n totalWarnings: this.warnings.length,\n fileResults,\n },\n };\n }\n\n /**\n * Validates a single entity directory\n */\n private async validateEntityDirectory(dir: string): Promise<{ files: number; entities: number; fileResults: Map<string, FileValidationResult> } | null> {\n // Check for .mj-folder.json first (new format)\n let configPath = path.join(dir, '.mj-folder.json');\n let config: any;\n \n if (fs.existsSync(configPath)) {\n config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n // .mj-folder.json uses entityName field\n if (!config.entityName) {\n this.addError({\n type: 'validation',\n severity: 'error',\n file: configPath,\n message: 'Missing entityName field in .mj-folder.json',\n });\n return null;\n }\n config.entity = config.entityName; // Normalize to entity field\n } else {\n // Fall back to .mj-sync.json (legacy format)\n configPath = path.join(dir, '.mj-sync.json');\n if (!fs.existsSync(configPath)) {\n return null;\n }\n config = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n }\n\n // Validate entity name exists\n if (!config.entity || config.entity.trim() === '') {\n this.addError({\n type: 'validation',\n severity: 'error',\n file: configPath,\n message: 'Entity name is empty or missing',\n });\n return null;\n }\n\n const entityInfo = this.metadata.EntityByName(config.entity);\n\n if (!entityInfo) {\n this.addError({\n type: 'entity',\n severity: 'error',\n file: configPath,\n message: `Entity \"${config.entity}\" not found in metadata`,\n });\n return null;\n }\n\n const files = await this.getMatchingFiles(dir, config.filePattern);\n let totalEntities = 0;\n const fileResults = new Map<string, FileValidationResult>();\n\n for (const file of files) {\n const filePath = path.join(dir, file);\n const result = await this.validateFile(filePath, entityInfo, config);\n totalEntities += result.entityCount;\n fileResults.set(filePath, result);\n }\n\n return { files: files.length, entities: totalEntities, fileResults };\n }\n\n /**\n * Validates a single metadata file\n */\n private async validateFile(filePath: string, entityInfo: any, config: EntitySyncConfig): Promise<FileValidationResult> {\n const fileErrors: ValidationError[] = [];\n let entityCount = 0;\n\n try {\n const content = fs.readFileSync(filePath, 'utf8');\n const data = JSON.parse(content);\n const entities = Array.isArray(data) ? data : [data];\n entityCount = entities.length;\n\n for (const entityData of entities) {\n await this.validateEntityData(entityData, entityInfo, filePath, config);\n }\n } catch (error) {\n fileErrors.push({\n type: 'entity',\n severity: 'error',\n file: filePath,\n message: `Failed to parse JSON: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Collect errors and warnings for this file\n const currentFileErrors = this.errors.filter((e) => e.file === filePath);\n const currentFileWarnings = this.warnings.filter((w) => w.file === filePath);\n\n return {\n file: filePath,\n entityCount,\n errors: currentFileErrors,\n warnings: currentFileWarnings,\n };\n }\n\n /**\n * Validates a single entity data object\n */\n private async validateEntityData(\n entityData: EntityData,\n entityInfo: any,\n filePath: string,\n config: EntitySyncConfig,\n parentContext?: { entity: string; field: string },\n depth: number = 0,\n ): Promise<void> {\n // Check nesting depth\n if (depth > this.options.maxNestingDepth) {\n this.addWarning({\n type: 'nesting',\n severity: 'warning',\n entity: entityInfo.Name,\n file: filePath,\n message: `Nesting depth ${depth} exceeds recommended maximum of ${this.options.maxNestingDepth}`,\n suggestion: 'Consider flattening the data structure or increasing maxNestingDepth',\n });\n }\n\n // Validate fields\n if (entityData.fields) {\n await this.validateFields(entityData.fields, entityInfo, filePath, parentContext);\n }\n\n // Track dependencies\n this.trackEntityDependencies(entityData, entityInfo.Name, filePath);\n\n // Validate related entities\n if (entityData.relatedEntities) {\n for (const [relatedEntityName, relatedData] of Object.entries(entityData.relatedEntities)) {\n const relatedEntityInfo = this.metadata.EntityByName(relatedEntityName);\n if (!relatedEntityInfo) {\n this.addError({\n type: 'entity',\n severity: 'error',\n entity: entityInfo.Name,\n file: filePath,\n message: `Related entity \"${relatedEntityName}\" not found in metadata`,\n });\n continue;\n }\n\n const relatedEntities = Array.isArray(relatedData) ? relatedData : [relatedData];\n for (const relatedEntity of relatedEntities) {\n await this.validateEntityData(relatedEntity, relatedEntityInfo, filePath, config, { entity: entityInfo.Name, field: relatedEntityName }, depth + 1);\n }\n }\n }\n }\n\n /**\n * Validates entity fields\n */\n private async validateFields(\n fields: Record<string, any>,\n entityInfo: EntityInfo,\n filePath: string,\n parentContext?: { entity: string; field: string },\n ): Promise<void> {\n const entityFields = entityInfo.Fields;\n const fieldMap = new Map(entityFields.map((f) => [f.Name, f]));\n\n for (const [fieldName, fieldValue] of Object.entries(fields)) {\n const fieldInfo = fieldMap.get(fieldName);\n\n if (!fieldInfo) {\n // Check if this might be a virtual property (getter/setter)\n try {\n const entityInstance = await this.metadata.GetEntityObject(entityInfo.Name);\n // we use this approach instead of checking Entity Fields because\n // some sub-classes implement setter properties that allow you to set\n // values that are not physically in the database but are resolved by the sub-class\n // a good example is the sub-class for AI Prompts that has a property called TemplateText\n // that is automatically resolved into a separate record in the Templates/Template Contents entity\n const hasProperty = fieldName in entityInstance;\n\n if (!hasProperty) {\n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldName,\n file: filePath,\n message: `Field \"${fieldName}\" does not exist on entity \"${entityInfo.Name}\"`,\n });\n continue;\n }\n\n continue;\n } catch (error) {\n // If we can't create an entity instance, fall back to error\n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldName,\n file: filePath,\n message: `Field \"${fieldName}\" does not exist on entity \"${entityInfo.Name}\"`,\n });\n continue;\n }\n }\n\n // Check if field is settable (not system field)\n if (fieldInfo.ReadOnly || fieldName.startsWith('__mj_')) {\n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldName,\n file: filePath,\n message: `Field \"${fieldName}\" is a read-only or system field and cannot be set`,\n suggestion: 'Remove this field from your metadata file',\n });\n continue;\n }\n\n // Validate field value and references\n await this.validateFieldValue(fieldValue, fieldInfo, entityInfo, filePath, parentContext);\n }\n\n // Check for required fields\n if (this.options.checkBestPractices) {\n for (const field of entityFields) {\n // Skip if field allows null or has a value already\n if (field.AllowsNull || fields[field.Name]) {\n continue;\n }\n\n // Skip if field has a default value\n if (field.DefaultValue !== null && field.DefaultValue !== undefined) {\n continue;\n }\n\n // Skip virtual/computed fields (foreign key reference fields)\n // These are typically named without 'ID' suffix but have a corresponding FK field\n const relatedEntityField = field.RelatedEntity;\n const correspondingFKField = entityFields.find((f: any) => f.Name === field.Name + 'ID' && f.IsForeignKey);\n if (relatedEntityField && correspondingFKField) {\n continue;\n }\n\n // Skip fields that are marked as AutoUpdateOnly or ReadOnly\n if (field.AutoIncrement || field.ReadOnly) {\n continue;\n }\n\n // Skip if this is a parent context and the field can be inherited\n if (parentContext && (field.Name === parentContext.field || field.Name === parentContext.field + 'ID')) {\n continue;\n }\n\n // Special case: Skip TemplateID if TemplateText is provided (virtual property)\n if (field.Name === 'TemplateID' && fields['TemplateText']) {\n continue;\n }\n\n // Skip Template field if TemplateText is provided\n if (field.Name === 'Template' && fields['TemplateText']) {\n continue;\n }\n\n this.addWarning({\n type: 'bestpractice',\n severity: 'warning',\n entity: entityInfo.Name,\n field: field.Name,\n file: filePath,\n message: `Required field \"${field.Name}\" is missing`,\n suggestion: `Add \"${field.Name}\" to the fields object`,\n });\n }\n }\n }\n\n /**\n * Validates field values and references\n */\n private async validateFieldValue(\n value: any,\n fieldInfo: EntityFieldInfo,\n entityInfo: EntityInfo,\n filePath: string,\n parentContext?: { entity: string; field: string },\n ): Promise<void> {\n if (typeof value === 'string' && this.isValidReference(value)) {\n await this.validateReference(value, fieldInfo, entityInfo, filePath, parentContext);\n // Skip further validation for references as they will be resolved later\n return;\n }\n\n // Validate field value against value list if applicable\n await this.validateFieldValueList(value, fieldInfo, entityInfo, filePath);\n\n // Validate UserID fields against allowed roles\n if (fieldInfo.Name === 'UserID' && typeof value === 'string' && value.length > 0) {\n // Get the sync config from the file's directory\n const dir = path.dirname(filePath);\n\n // Walk up to find the root sync config with userRoleValidation\n let currentDir = dir;\n let config = null;\n while (currentDir && currentDir !== path.parse(currentDir).root) {\n const currentConfigPath = path.join(currentDir, '.mj-sync.json');\n if (fs.existsSync(currentConfigPath)) {\n try {\n const currentConfig = JSON.parse(fs.readFileSync(currentConfigPath, 'utf8'));\n if (currentConfig.userRoleValidation) {\n config = currentConfig;\n break;\n }\n } catch {\n // Ignore parse errors\n }\n }\n currentDir = path.dirname(currentDir);\n }\n\n if (config?.userRoleValidation?.enabled) {\n await this.validateUserRole(value, entityInfo.Name, fieldInfo.Name, filePath, config);\n }\n }\n\n // Add other type validation here if needed\n }\n\n /**\n * Validates field value against the field's value list if applicable\n */\n private async validateFieldValueList(\n value: any,\n fieldInfo: EntityFieldInfo,\n entityInfo: EntityInfo,\n filePath: string\n ): Promise<void> {\n // Skip validation if value is null/undefined (handled by required field check)\n if (value === null || value === undefined || value === '') {\n return;\n }\n\n // Check if this field has a value list constraint\n if (fieldInfo.ValueListType !== 'List') {\n return;\n }\n\n // Get the allowed values from EntityFieldValues\n const entityFieldValues = fieldInfo.EntityFieldValues;\n if (!entityFieldValues || !Array.isArray(entityFieldValues) || entityFieldValues.length === 0) {\n // No values defined, skip validation\n return;\n }\n\n // Extract the allowed values\n const allowedValues = entityFieldValues.map((efv: any) => efv.Value);\n \n // Convert value to string for comparison (in case it's a number or boolean)\n const stringValue = String(value);\n \n // Check if the value is in the allowed list\n if (!allowedValues.includes(stringValue)) {\n // Check case-insensitive match as a warning\n const caseInsensitiveMatch = allowedValues.find((av: string) => \n av.toLowerCase() === stringValue.toLowerCase()\n );\n \n if (caseInsensitiveMatch) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n entity: entityInfo.Name,\n field: fieldInfo.Name,\n file: filePath,\n message: `Field \"${fieldInfo.Name}\" has value \"${stringValue}\" which differs in case from allowed value \"${caseInsensitiveMatch}\"`,\n suggestion: `Use \"${caseInsensitiveMatch}\" for consistency`,\n });\n } else {\n // Format the allowed values list for display\n const allowedValuesList = allowedValues.length <= 10 \n ? allowedValues.join(', ')\n : allowedValues.slice(0, 10).join(', ') + `, ... (${allowedValues.length - 10} more)`;\n \n this.addError({\n type: 'field',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldInfo.Name,\n file: filePath,\n message: `Field \"${fieldInfo.Name}\" has invalid value \"${stringValue}\"`,\n suggestion: `Allowed values are: ${allowedValuesList}`,\n });\n }\n }\n }\n\n /**\n * Check if a string is actually a MetadataSync reference (not just any @ string)\n */\n private isValidReference(value: string): boolean {\n return isMetadataKeyword(value);\n }\n\n /**\n * Validates special references (@file:, @lookup:, etc.)\n */\n private async validateReference(\n reference: string,\n fieldInfo: EntityFieldInfo,\n entityInfo: EntityInfo,\n filePath: string,\n parentContext?: { entity: string; field: string },\n ): Promise<void> {\n const parsed = this.parseReference(reference);\n if (!parsed) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityInfo.Name,\n field: fieldInfo.Name,\n file: filePath,\n message: `Invalid reference format: \"${reference}\"`,\n });\n return;\n }\n\n switch (parsed.type) {\n case METADATA_KEYWORDS.FILE:\n await this.validateFileReference(parsed.value, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case METADATA_KEYWORDS.LOOKUP:\n await this.validateLookupReference(parsed, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case METADATA_KEYWORDS.TEMPLATE:\n await this.validateTemplateReference(parsed.value, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case METADATA_KEYWORDS.PARENT:\n this.validateParentReference(parsed.value, parentContext, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n case METADATA_KEYWORDS.ROOT:\n this.validateRootReference(parsed.value, parentContext, filePath, entityInfo.Name, fieldInfo.Name);\n break;\n }\n }\n\n /**\n * Parses a reference string\n */\n private parseReference(reference: string): ParsedReference | null {\n const patterns: [ReferenceType, RegExp][] = [\n [METADATA_KEYWORDS.FILE, /^@file:(.+)$/],\n [METADATA_KEYWORDS.LOOKUP, /^@lookup:([^.]+)\\.(.+)$/],\n [METADATA_KEYWORDS.TEMPLATE, /^@template:(.+)$/],\n [METADATA_KEYWORDS.PARENT, /^@parent:(.+)$/],\n [METADATA_KEYWORDS.ROOT, /^@root:(.+)$/],\n [METADATA_KEYWORDS.ENV, /^@env:(.+)$/],\n ];\n\n for (const [type, pattern] of patterns) {\n const match = reference.match(pattern);\n if (match) {\n if (type === METADATA_KEYWORDS.LOOKUP) {\n const [, entity, remaining] = match;\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 lookupPairs = lookupPart.split('&');\n const fields: Array<{field: string, value: string}> = [];\n \n for (const pair of lookupPairs) {\n const fieldMatch = pair.match(/^(.+?)=(.+)$/);\n if (fieldMatch) {\n const [, field, value] = fieldMatch;\n fields.push({ field: field.trim(), value: value.trim() });\n }\n }\n \n // For backward compatibility, use the first field as primary\n const primaryField = fields.length > 0 ? fields[0] : { field: '', value: '' };\n \n // Parse additional fields for creation if ?create is present\n const additionalFields: 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 additionalFields[key] = decodeURIComponent(val);\n }\n }\n }\n\n return { \n type, \n value: primaryField.value, \n entity, \n field: primaryField.field,\n fields, // Include all fields for validation\n createIfMissing: hasCreate, \n additionalFields \n };\n }\n return { type, value: match[1] };\n }\n }\n\n return null;\n }\n\n /**\n * Validates @file: references\n */\n private async validateFileReference(filePath: string, sourceFile: string, entityName: string, fieldName: string, visitedFiles?: Set<string>): Promise<void> {\n const dir = path.dirname(sourceFile);\n const resolvedPath = path.resolve(dir, filePath);\n\n // Initialize visited files set if not provided (for circular reference detection)\n const visited = visitedFiles || new Set<string>();\n \n // Check for circular references\n if (visited.has(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Circular @file reference detected: \"${filePath}\"`,\n details: `Path ${resolvedPath} is already being processed`,\n suggestion: 'Restructure your file references to avoid circular dependencies',\n });\n return;\n }\n\n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `File reference not found: \"${filePath}\"`,\n suggestion: `Create file at: ${resolvedPath}`,\n });\n return;\n }\n\n // Add to visited set\n visited.add(resolvedPath);\n\n // Read the file and check for references\n try {\n const content = fs.readFileSync(resolvedPath, 'utf-8');\n \n // Check for {@include} references in all file types\n await this.validateIncludeReferences(content, resolvedPath, new Set([resolvedPath]));\n \n // If it's a JSON file, parse and validate nested @ references\n if (resolvedPath.endsWith('.json')) {\n try {\n const jsonContent = JSON.parse(content);\n \n // Check if JSON contains @include directives that need preprocessing\n const jsonString = JSON.stringify(jsonContent);\n const hasIncludes = jsonString.includes('\"@include\"') || jsonString.includes('\"@include.');\n \n if (hasIncludes) {\n await this.validateJsonIncludes(jsonContent, resolvedPath);\n }\n \n // Recursively validate all @ references in the JSON structure\n await this.validateJsonReferences(jsonContent, resolvedPath, entityName, visited);\n } catch (parseError) {\n // Not valid JSON or error parsing, treat as text file (already validated {@include} above)\n if (this.options.verbose) {\n console.log(`File ${resolvedPath} is not valid JSON, treating as text file`);\n }\n }\n }\n } catch (error) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Failed to read file reference: \"${filePath}\"`,\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Validates @lookup: references\n */\n private async validateLookupReference(parsed: ParsedReference, sourceFile: string, entityName: string, fieldName: string): Promise<void> {\n const lookupEntity = this.metadata.EntityByName(parsed.entity!);\n\n if (!lookupEntity) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Lookup entity \"${parsed.entity}\" not found`,\n suggestion: 'Check entity name spelling and case',\n });\n return;\n }\n\n // For multi-field lookups, validate all fields\n if (parsed.fields && parsed.fields.length > 0) {\n for (const {field} of parsed.fields) {\n const lookupField = lookupEntity.Fields.find((f: any) => f.Name === field);\n if (!lookupField) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Lookup field \"${field}\" not found on entity \"${parsed.entity}\"`,\n suggestion: `Available fields: ${lookupEntity.Fields.map((f: any) => f.Name).join(', ')}`,\n });\n }\n }\n } else if (parsed.field) {\n // Fallback for single field lookup (backward compatibility)\n const lookupField = lookupEntity.Fields.find((f: any) => f.Name === parsed.field);\n if (!lookupField) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Lookup field \"${parsed.field}\" not found on entity \"${parsed.entity}\"`,\n suggestion: `Available fields: ${lookupEntity.Fields.map((f: any) => f.Name).join(', ')}`,\n });\n }\n }\n\n // Track dependency\n this.addEntityDependency(entityName, parsed.entity!);\n }\n\n /**\n * Validates @template: references\n */\n private async validateTemplateReference(templatePath: string, sourceFile: string, entityName: string, fieldName: string): Promise<void> {\n const dir = path.dirname(sourceFile);\n const resolvedPath = path.resolve(dir, templatePath);\n\n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Template file not found: \"${templatePath}\"`,\n suggestion: `Create template at: ${resolvedPath}`,\n });\n return;\n }\n\n // Validate template is valid JSON\n try {\n JSON.parse(fs.readFileSync(resolvedPath, 'utf8'));\n } catch (error) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: sourceFile,\n message: `Template file is not valid JSON: \"${templatePath}\"`,\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Validates @parent: references\n */\n private validateParentReference(\n _fieldName: string,\n parentContext: { entity: string; field: string } | undefined,\n sourceFile: string,\n entityName: string,\n currentFieldName: string,\n ): void {\n if (!parentContext) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: currentFieldName,\n file: sourceFile,\n message: `@parent: reference used but no parent context exists`,\n suggestion: '@parent: can only be used in nested/related entities',\n });\n }\n }\n\n /**\n * Validates @root: references\n */\n private validateRootReference(\n _fieldName: string,\n parentContext: { entity: string; field: string } | undefined,\n sourceFile: string,\n entityName: string,\n currentFieldName: string,\n ): void {\n if (!parentContext) {\n this.addError({\n type: 'reference',\n severity: 'error',\n entity: entityName,\n field: currentFieldName,\n file: sourceFile,\n message: `@root: reference used but no root context exists`,\n suggestion: '@root: can only be used in nested/related entities',\n });\n }\n }\n\n /**\n * Track entity dependencies\n */\n private trackEntityDependencies(entityData: EntityData, entityName: string, filePath: string): void {\n if (!this.entityDependencies.has(entityName)) {\n this.entityDependencies.set(entityName, {\n entityName,\n dependsOn: new Set(),\n file: filePath,\n });\n }\n\n // Track dependencies from lookups in fields\n if (entityData.fields) {\n for (const value of Object.values(entityData.fields)) {\n if (typeof value === 'string' && value.startsWith(METADATA_KEYWORDS.LOOKUP)) {\n const parsed = this.parseReference(value);\n if (parsed?.entity) {\n this.addEntityDependency(entityName, parsed.entity);\n }\n }\n }\n }\n }\n\n /**\n * Add an entity dependency\n */\n private addEntityDependency(from: string, to: string): void {\n // Don't add self-references as dependencies (e.g., ParentID in hierarchical structures)\n if (from === to) {\n return;\n }\n \n if (!this.entityDependencies.has(from)) {\n this.entityDependencies.set(from, {\n entityName: from,\n dependsOn: new Set(),\n file: '',\n });\n }\n this.entityDependencies.get(from)!.dependsOn.add(to);\n }\n\n /**\n * Validates dependency order\n */\n private async validateDependencyOrder(directoryOrder: string[]): Promise<void> {\n // Build a map of entity to directory\n const entityToDirectory = new Map<string, string>();\n\n for (const dir of directoryOrder) {\n // This is simplified - in reality we'd need to read the .mj-sync.json\n // to get the actual entity name\n entityToDirectory.set(dir, dir);\n }\n\n // Check for circular dependencies\n const visited = new Set<string>();\n const recursionStack = new Set<string>();\n\n for (const [entity] of this.entityDependencies) {\n if (!visited.has(entity)) {\n this.checkCircularDependency(entity, visited, recursionStack);\n }\n }\n\n // Check if current order satisfies dependencies\n const orderViolations = this.checkDependencyOrder(directoryOrder);\n if (orderViolations.length > 0) {\n // Suggest a corrected order\n const suggestedOrder = this.topologicalSort();\n\n for (const violation of orderViolations) {\n this.addError({\n type: 'dependency',\n severity: 'error',\n entity: violation.entity,\n file: violation.file,\n message: `Entity '${violation.entity}' depends on '${violation.dependency}' but is processed before it`,\n suggestion: `Reorder directories to: [${suggestedOrder.join(', ')}]`,\n });\n }\n }\n }\n\n /**\n * Check for circular dependencies\n */\n private checkCircularDependency(entity: string, visited: Set<string>, recursionStack: Set<string>, path: string[] = []): boolean {\n visited.add(entity);\n recursionStack.add(entity);\n path.push(entity);\n\n const deps = this.entityDependencies.get(entity);\n if (deps) {\n for (const dep of deps.dependsOn) {\n if (!visited.has(dep)) {\n if (this.checkCircularDependency(dep, visited, recursionStack, [...path])) {\n return true;\n }\n } else if (recursionStack.has(dep)) {\n // Found circular dependency\n const cycle = [...path, dep];\n const cycleStart = cycle.indexOf(dep);\n const cyclePath = cycle.slice(cycleStart).join(' → ');\n\n this.addError({\n type: 'circular',\n severity: 'error',\n entity: entity,\n file: deps.file,\n message: `Circular dependency detected: ${cyclePath}`,\n suggestion: 'Restructure your entities to avoid circular references',\n });\n return true;\n }\n }\n }\n\n recursionStack.delete(entity);\n return false;\n }\n\n /**\n * Get directories in order based on config\n */\n private async getDirectoriesInOrder(rootDir: string, config: any): Promise<string[]> {\n const allDirs = fs\n .readdirSync(rootDir)\n .filter((f) => fs.statSync(path.join(rootDir, f)).isDirectory())\n .filter((d) => !d.startsWith('.'));\n\n if (config.directoryOrder && Array.isArray(config.directoryOrder)) {\n const ordered = config.directoryOrder.filter((d: string) => allDirs.includes(d));\n const remaining = allDirs.filter((d) => !ordered.includes(d)).sort();\n return [...ordered, ...remaining];\n }\n\n return allDirs.sort();\n }\n\n /**\n * Get files matching pattern\n */\n private async getMatchingFiles(dir: string, pattern: string): Promise<string[]> {\n const files = fs.readdirSync(dir).filter((f) => fs.statSync(path.join(dir, f)).isFile());\n\n // Simple glob pattern matching\n if (pattern === '*.json') {\n return files.filter((f) => f.endsWith('.json') && !f.startsWith('.mj-'));\n } else if (pattern === '.*.json') {\n return files.filter((f) => f.startsWith('.') && f.endsWith('.json') && !f.startsWith('.mj-'));\n }\n\n return files;\n }\n\n /**\n * Add an error\n */\n private addError(error: ValidationError): void {\n this.errors.push(error);\n }\n\n /**\n * Add a warning\n */\n private addWarning(warning: ValidationWarning): void {\n this.warnings.push(warning);\n }\n\n /**\n * Check if current directory order satisfies dependencies\n */\n private checkDependencyOrder(directoryOrder: string[]): Array<{ entity: string; dependency: string; file: string }> {\n const violations: Array<{ entity: string; dependency: string; file: string }> = [];\n const processedEntities = new Set<string>();\n\n for (const dir of directoryOrder) {\n // In real implementation, we'd read .mj-sync.json to get entity name\n const entityName = dir; // Simplified for now\n\n const deps = this.entityDependencies.get(entityName);\n if (deps) {\n for (const dep of deps.dependsOn) {\n if (!processedEntities.has(dep) && directoryOrder.includes(dep)) {\n violations.push({\n entity: entityName,\n dependency: dep,\n file: deps.file,\n });\n }\n }\n }\n\n processedEntities.add(entityName);\n }\n\n return violations;\n }\n\n /**\n * Perform topological sort on entity dependencies\n */\n private topologicalSort(): string[] {\n const result: string[] = [];\n const visited = new Set<string>();\n const tempStack = new Set<string>();\n\n const visit = (entity: string): boolean => {\n if (tempStack.has(entity)) {\n // Circular dependency, already handled by checkCircularDependency\n return false;\n }\n\n if (visited.has(entity)) {\n return true;\n }\n\n tempStack.add(entity);\n\n const deps = this.entityDependencies.get(entity);\n if (deps) {\n for (const dep of deps.dependsOn) {\n if (!visit(dep)) {\n return false;\n }\n }\n }\n\n tempStack.delete(entity);\n visited.add(entity);\n result.push(entity);\n\n return true;\n };\n\n // Visit all entities\n for (const entity of this.entityDependencies.keys()) {\n if (!visited.has(entity)) {\n visit(entity);\n }\n }\n\n return result;\n }\n\n /**\n * Reset validation state\n */\n private reset(): void {\n this.errors = [];\n this.warnings = [];\n this.entityDependencies.clear();\n this.processedEntities.clear();\n this.userRoleCache.clear();\n }\n\n /**\n * Get validation result\n */\n private getResult(): ValidationResult {\n return {\n isValid: this.errors.length === 0,\n errors: this.errors,\n warnings: this.warnings,\n summary: {\n totalFiles: 0,\n totalEntities: 0,\n totalErrors: this.errors.length,\n totalWarnings: this.warnings.length,\n fileResults: new Map(),\n },\n };\n }\n\n /**\n * Load user roles from the database into cache\n */\n private async loadUserRoles(): Promise<void> {\n try {\n const rv = new RunView();\n const systemUser = getSystemUser();\n\n // Load all user roles with role names\n const result = await rv.RunView(\n {\n EntityName: 'User Roles',\n ExtraFilter: '',\n OrderBy: 'UserID',\n MaxRows: 10000,\n },\n systemUser,\n );\n\n if (!result.Success) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n file: 'system',\n message: 'Failed to load user roles for validation',\n details: result.ErrorMessage,\n });\n return;\n }\n\n // Group roles by UserID\n for (const userRole of result.Results || []) {\n const userId = userRole.UserID;\n const roleName = userRole.Role;\n\n if (!this.userRoleCache.has(userId)) {\n this.userRoleCache.set(userId, []);\n }\n this.userRoleCache.get(userId)!.push(roleName);\n }\n\n if (this.options.verbose) {\n console.log(`Loaded roles for ${this.userRoleCache.size} users`);\n }\n } catch (error) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n file: 'system',\n message: 'Error loading user roles for validation',\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n /**\n * Validate a UserID field value against allowed roles\n */\n private async validateUserRole(userId: string, entityName: string, fieldName: string, filePath: string, config: any): Promise<void> {\n // Skip if user role validation is not enabled\n if (!config.userRoleValidation?.enabled) {\n return;\n }\n\n const userRoles = this.userRoleCache.get(userId);\n const allowedRoles = config.userRoleValidation.allowedRoles || [];\n const allowUsersWithoutRoles = config.userRoleValidation.allowUsersWithoutRoles || false;\n\n if (!userRoles || userRoles.length === 0) {\n if (!allowUsersWithoutRoles) {\n this.addError({\n type: 'validation',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: filePath,\n message: `UserID '${userId}' does not have any assigned roles`,\n suggestion:\n allowedRoles.length > 0\n ? `User must have one of these roles: ${allowedRoles.join(', ')}`\n : 'Assign appropriate roles to this user or set allowUsersWithoutRoles: true',\n });\n }\n return;\n }\n\n // Check if user has at least one allowed role\n if (allowedRoles.length > 0) {\n const hasAllowedRole = userRoles.some((role) => allowedRoles.includes(role));\n if (!hasAllowedRole) {\n this.addError({\n type: 'validation',\n severity: 'error',\n entity: entityName,\n field: fieldName,\n file: filePath,\n message: `UserID '${userId}' has roles [${userRoles.join(', ')}] but none are in allowed list`,\n suggestion: `Allowed roles: ${allowedRoles.join(', ')}`,\n });\n }\n }\n }\n\n /**\n * Validates {@include} references within file content\n * \n * Recursively checks all {@include path} references in file content to ensure:\n * - Referenced files exist\n * - No circular references occur\n * - Include paths are valid\n * \n * @param content - The file content to validate\n * @param filePath - Path of the file being validated\n * @param visitedPaths - Set of already visited paths for circular reference detection\n */\n private async validateIncludeReferences(content: string, filePath: string, visitedPaths: Set<string>): Promise<void> {\n // Pattern to match {@include path} references\n const includePattern = /\\{@include\\s+([^\\}]+)\\s*\\}/g;\n let match: RegExpExecArray | null;\n \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 // Check for circular reference\n if (visitedPaths.has(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: filePath,\n message: `Circular {@include} reference detected: \"${trimmedPath}\"`,\n details: `Path ${resolvedPath} is already being processed`,\n suggestion: 'Restructure your includes to avoid circular references',\n });\n continue;\n }\n \n // Check if the included file exists\n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: filePath,\n message: `{@include} file not found: \"${trimmedPath}\"`,\n suggestion: `Create file at: ${resolvedPath}`,\n });\n continue;\n }\n \n // Recursively validate the included file\n try {\n const includedContent = fs.readFileSync(resolvedPath, 'utf-8');\n const newVisitedPaths = new Set(visitedPaths);\n newVisitedPaths.add(resolvedPath);\n await this.validateIncludeReferences(includedContent, resolvedPath, newVisitedPaths);\n } catch (error) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: filePath,\n message: `Failed to read {@include} file: \"${trimmedPath}\"`,\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n /**\n * Validates @include directives in JSON files\n */\n private async validateJsonIncludes(jsonContent: any, sourceFile: string): Promise<void> {\n // Process based on data type\n if (Array.isArray(jsonContent)) {\n for (const item of jsonContent) {\n if (typeof item === 'string' && item.startsWith(`${METADATA_KEYWORDS.INCLUDE}:`)) {\n const includePath = extractKeywordValue(item) as string;\n await this.validateIncludeFile(includePath.trim(), sourceFile);\n } else if (item && typeof item === 'object') {\n await this.validateJsonIncludes(item, sourceFile);\n }\n }\n } else if (jsonContent && typeof jsonContent === 'object') {\n for (const [key, value] of Object.entries(jsonContent)) {\n if (key === METADATA_KEYWORDS.INCLUDE || key.startsWith(`${METADATA_KEYWORDS.INCLUDE}.`)) {\n let includeFile: string;\n if (typeof value === 'string') {\n includeFile = value;\n } else if (value && typeof value === 'object' && 'file' in value) {\n includeFile = (value as any).file;\n } else {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: sourceFile,\n message: `Invalid @include directive format for key \"${key}\"`,\n suggestion: 'Use either a string path or an object with a \"file\" property',\n });\n continue;\n }\n await this.validateIncludeFile(includeFile, sourceFile);\n } else if (value && typeof value === 'object') {\n await this.validateJsonIncludes(value, sourceFile);\n }\n }\n }\n }\n\n /**\n * Validates a single include file path\n */\n private async validateIncludeFile(includePath: string, sourceFile: string): Promise<void> {\n const dir = path.dirname(sourceFile);\n const resolvedPath = path.resolve(dir, includePath);\n \n if (!fs.existsSync(resolvedPath)) {\n this.addError({\n type: 'reference',\n severity: 'error',\n file: sourceFile,\n message: `@include file not found: \"${includePath}\"`,\n suggestion: `Create file at: ${resolvedPath}`,\n });\n }\n }\n\n /**\n * Recursively validates all @ references in a JSON structure\n */\n private async validateJsonReferences(\n obj: any,\n sourceFile: string,\n entityName: string,\n visitedFiles: Set<string>,\n parentContext?: { entity: string; field: string }\n ): Promise<void> {\n if (obj === null || obj === undefined) {\n return;\n }\n\n if (Array.isArray(obj)) {\n for (const item of obj) {\n await this.validateJsonReferences(item, sourceFile, entityName, visitedFiles, parentContext);\n }\n } else if (typeof obj === 'object') {\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === 'string' && this.isValidReference(value)) {\n // Process different reference types\n if (value.startsWith(METADATA_KEYWORDS.FILE)) {\n const filePath = extractKeywordValue(value) as string;\n // Recursively validate the file reference (with circular detection)\n await this.validateFileReference(filePath, sourceFile, entityName, key, visitedFiles);\n } else if (value.startsWith(METADATA_KEYWORDS.LOOKUP)) {\n // Parse and validate lookup reference\n const parsed = this.parseReference(value);\n if (parsed) {\n await this.validateLookupReference(parsed, sourceFile, entityName, key);\n }\n } else if (value.startsWith(METADATA_KEYWORDS.TEMPLATE)) {\n const templatePath = extractKeywordValue(value) as string;\n await this.validateTemplateReference(templatePath, sourceFile, entityName, key);\n } else if (value.startsWith(METADATA_KEYWORDS.PARENT)) {\n const parsed = this.parseReference(value);\n if (parsed) {\n this.validateParentReference(parsed.value, parentContext, sourceFile, entityName, key);\n }\n } else if (value.startsWith(METADATA_KEYWORDS.ROOT)) {\n const parsed = this.parseReference(value);\n if (parsed) {\n this.validateRootReference(parsed.value, parentContext, sourceFile, entityName, key);\n }\n } else if (value.startsWith(METADATA_KEYWORDS.ENV)) {\n const envVar = extractKeywordValue(value) as string;\n if (!process.env[envVar]) {\n this.addWarning({\n type: 'validation',\n severity: 'warning',\n entity: entityName,\n field: key,\n file: sourceFile,\n message: `Environment variable \"${envVar}\" is not currently set`,\n suggestion: `Ensure this variable is set before running push operations`,\n });\n }\n }\n } else if (value && typeof value === 'object') {\n // Recursively process nested objects\n await this.validateJsonReferences(value, sourceFile, entityName, visitedFiles, parentContext);\n }\n }\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import chokidar from 'chokidar';
2
- import { BaseEntity } from '@memberjunction/global';
2
+ import { BaseEntity } from '@memberjunction/core';
3
3
  import { SyncEngine } from '../lib/sync-engine';
4
4
  export interface WatchOptions {
5
5
  dir?: string;
@@ -7,7 +7,7 @@ exports.WatchService = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const chokidar_1 = __importDefault(require("chokidar"));
10
- const global_1 = require("@memberjunction/global");
10
+ const core_1 = require("@memberjunction/core");
11
11
  const config_1 = require("../config");
12
12
  const provider_utils_1 = require("../lib/provider-utils");
13
13
  const config_manager_1 = require("../lib/config-manager");
@@ -43,7 +43,7 @@ class WatchService {
43
43
  path_1.default.join(entityDir, '**/*.txt'),
44
44
  path_1.default.join(entityDir, '**/*.html'),
45
45
  path_1.default.join(entityDir, '**/*.liquid'),
46
- path_1.default.join(entityDir, '**/*.sql'),
46
+ path_1.default.join(entityDir, '**/*.sql')
47
47
  ];
48
48
  const ignored = [
49
49
  '**/node_modules/**',
@@ -51,12 +51,12 @@ class WatchService {
51
51
  '**/.mj-sync.json',
52
52
  '**/.mj-folder.json',
53
53
  '**/*.backup',
54
- ...(options.ignorePatterns || []),
54
+ ...(options.ignorePatterns || [])
55
55
  ];
56
56
  const watcher = chokidar_1.default.watch(patterns, {
57
57
  ignored,
58
58
  persistent: true,
59
- ignoreInitial: true,
59
+ ignoreInitial: true
60
60
  });
61
61
  watcher
62
62
  .on('add', (filePath) => {
@@ -82,7 +82,7 @@ class WatchService {
82
82
  }
83
83
  this.debounceTimers.clear();
84
84
  // Close all watchers
85
- await Promise.all(watchers.map((w) => w.close()));
85
+ await Promise.all(watchers.map(w => w.close()));
86
86
  // Dispose SQL logging session
87
87
  if (this.sqlLoggingSession) {
88
88
  try {
@@ -94,7 +94,7 @@ class WatchService {
94
94
  callbacks?.onWarn?.(`Failed to close SQL logging session: ${error}`);
95
95
  }
96
96
  }
97
- },
97
+ }
98
98
  };
99
99
  }
100
100
  handleFileChange(filePath, event, entityDir, entityConfig, options, callbacks) {
@@ -207,8 +207,7 @@ class WatchService {
207
207
  if (message) {
208
208
  throw new Error(`Failed to save record: ${message}`);
209
209
  }
210
- const errors = entity.LatestResult?.Errors?.map((err) => (typeof err === 'string' ? err : err?.message || JSON.stringify(err)))?.join(', ') ||
211
- 'Unknown error';
210
+ const errors = entity.LatestResult?.Errors?.map(err => typeof err === 'string' ? err : (err?.message || JSON.stringify(err)))?.join(', ') || 'Unknown error';
212
211
  throw new Error(`Failed to save record: ${errors}`);
213
212
  }
214
213
  if (wasActuallyUpdated) {
@@ -233,7 +232,7 @@ class WatchService {
233
232
  // Always update sync metadata when the record was updated - use original fields for checksum
234
233
  recordData.sync = {
235
234
  lastModified: new Date().toISOString(),
236
- checksum: await this.syncEngine.calculateChecksumWithFileContent(originalFields, path_1.default.dirname(filePath)),
235
+ checksum: await this.syncEngine.calculateChecksumWithFileContent(originalFields, path_1.default.dirname(filePath))
237
236
  };
238
237
  // Restore original field values to preserve @ references
239
238
  recordData.fields = originalFields;
@@ -256,7 +255,7 @@ class WatchService {
256
255
  const recordData = await fs_extra_1.default.readJson(jsonFilePath);
257
256
  recordData.sync = {
258
257
  lastModified: new Date().toISOString(),
259
- checksum: recordData.sync?.checksum || '',
258
+ checksum: recordData.sync?.checksum || ''
260
259
  };
261
260
  await json_write_helper_1.JsonWriteHelper.writeOrderedRecordData(jsonFilePath, recordData);
262
261
  callbacks?.onLog?.(`Updated sync metadata for ${jsonFileName} due to external file change`);
@@ -268,11 +267,13 @@ class WatchService {
268
267
  // Load sync config for SQL logging settings
269
268
  const syncConfig = await (0, config_1.loadSyncConfig)(config_manager_1.configManager.getOriginalCwd());
270
269
  if (syncConfig?.sqlLogging?.enabled) {
271
- const provider = global_1.Metadata.Provider; // SQLServerDataProvider
270
+ const provider = core_1.Metadata.Provider; // SQLServerDataProvider
272
271
  if (provider && typeof provider.CreateSqlLogger === 'function') {
273
272
  // Generate filename with timestamp
274
273
  const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
275
- const filename = syncConfig.sqlLogging?.formatAsMigration ? `MetadataSync_Watch_${timestamp}.sql` : `watch_${timestamp}.sql`;
274
+ const filename = syncConfig.sqlLogging?.formatAsMigration
275
+ ? `MetadataSync_Watch_${timestamp}.sql`
276
+ : `watch_${timestamp}.sql`;
276
277
  // Use .sql-log-watch directory in the working directory
277
278
  const outputDir = path_1.default.join(config_manager_1.configManager.getOriginalCwd(), '.sql-log-watch');
278
279
  const filepath = path_1.default.join(outputDir, filename);
@@ -282,7 +283,7 @@ class WatchService {
282
283
  this.sqlLoggingSession = await provider.CreateSqlLogger(filepath, {
283
284
  formatAsMigration: syncConfig.sqlLogging?.formatAsMigration || false,
284
285
  description: 'MetadataSync watch operation',
285
- logRecordChangeMetadata: true,
286
+ logRecordChangeMetadata: true
286
287
  });
287
288
  callbacks?.onLog?.(`📝 SQL logging enabled: ${filepath}`);
288
289
  }