@memberjunction/metadata-sync 2.56.0 ā 2.57.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.
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/provider-utils.d.ts +2 -2
- package/dist/lib/provider-utils.js.map +1 -1
- package/dist/lib/sql-logger.js +3 -3
- package/dist/lib/sql-logger.js.map +1 -1
- package/dist/lib/sync-engine.d.ts +25 -0
- package/dist/lib/sync-engine.js +70 -0
- package/dist/lib/sync-engine.js.map +1 -1
- package/dist/lib/transaction-manager.d.ts +0 -1
- package/dist/lib/transaction-manager.js +4 -21
- package/dist/lib/transaction-manager.js.map +1 -1
- package/dist/services/FileResetService.js +1 -0
- package/dist/services/FileResetService.js.map +1 -1
- package/dist/services/PushService.d.ts +2 -0
- package/dist/services/PushService.js +238 -74
- package/dist/services/PushService.js.map +1 -1
- package/dist/services/WatchService.d.ts +2 -0
- package/dist/services/WatchService.js +63 -9
- package/dist/services/WatchService.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PushService.js","sourceRoot":"","sources":["../../src/services/PushService.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,0DAAiC;AACjC,+CAA+F;AAE/F,sCAA6D;AAC7D,oEAA+D;AAC/D,0DAAsD;AACtD,kDAA8C;AAC9C,oEAAgE;AAkChE,MAAa,WAAW;IACd,UAAU,CAAa;IACvB,WAAW,CAAW;IACtB,QAAQ,GAAa,EAAE,CAAC;IACxB,gBAAgB,GAAgF,IAAI,GAAG,EAAE,CAAC;IAC1G,UAAU,CAAM;IAExB,YAAY,UAAsB,EAAE,WAAqB;QACvD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAoB,EAAE,SAAyB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AAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;gCAC3C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oCAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gCACtB,CAAC;4BACH,CAAC;4BAAC,MAAM,CAAC;gCACP,4BAA4B;4BAC9B,CAAC;wBACH,CAAC;6BAAM,CAAC;4BACN,8BAA8B;4BAC9B,UAAU,CAAC,QAAQ,CAAC,CAAC;wBACvB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;YAEF,UAAU,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtdD,kCAsdC","sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport fastGlob from 'fast-glob';\nimport { BaseEntity, LogStatus, Metadata, UserInfo, CompositeKey } from '@memberjunction/core';\nimport { SyncEngine, RecordData } from '../lib/sync-engine';\nimport { loadEntityConfig, loadSyncConfig } from '../config';\nimport { FileBackupManager } from '../lib/file-backup-manager';\nimport { configManager } from '../lib/config-manager';\nimport { SQLLogger } from '../lib/sql-logger';\nimport { TransactionManager } from '../lib/transaction-manager';\n\nexport interface PushOptions {\n dir?: string;\n dryRun?: boolean;\n verbose?: boolean;\n noValidate?: boolean;\n}\n\nexport interface PushCallbacks {\n onProgress?: (message: string) => void;\n onSuccess?: (message: string) => void;\n onError?: (message: string) => void;\n onWarn?: (message: string) => void;\n onLog?: (message: string) => void;\n onConfirm?: (message: string) => Promise<boolean>;\n}\n\nexport interface PushResult {\n created: number;\n updated: number;\n unchanged: number;\n errors: number;\n warnings: string[];\n sqlLogPath?: string;\n}\n\nexport interface EntityPushResult {\n created: number;\n updated: number;\n unchanged: number;\n errors: number;\n}\n\nexport class PushService {\n private syncEngine: SyncEngine;\n private contextUser: UserInfo;\n private warnings: string[] = [];\n private processedRecords: Map<string, { filePath: string; arrayIndex?: number; lineNumber?: number }> = new Map();\n private syncConfig: any;\n \n constructor(syncEngine: SyncEngine, contextUser: UserInfo) {\n this.syncEngine = syncEngine;\n this.contextUser = contextUser;\n }\n \n async push(options: PushOptions, callbacks?: PushCallbacks): Promise<PushResult> {\n this.warnings = [];\n this.processedRecords.clear();\n \n const fileBackupManager = new FileBackupManager();\n \n // Load sync config for SQL logging settings and autoCreateMissingRecords flag\n this.syncConfig = await loadSyncConfig(configManager.getOriginalCwd());\n const sqlLogger = new SQLLogger(this.syncConfig);\n const transactionManager = new TransactionManager(sqlLogger);\n \n try {\n // Initialize SQL logger if enabled\n if (sqlLogger.enabled && !options.dryRun) {\n await sqlLogger.initialize();\n if (options.verbose) {\n callbacks?.onLog?.('š SQL logging enabled');\n }\n }\n \n // Find entity directories to process\n const entityDirs = this.findEntityDirectories(configManager.getOriginalCwd(), options.dir);\n \n if (entityDirs.length === 0) {\n throw new Error('No entity directories found');\n }\n \n if (options.verbose) {\n callbacks?.onLog?.(`Found ${entityDirs.length} entity ${entityDirs.length === 1 ? 'directory' : 'directories'} to process`);\n }\n \n // Initialize file backup manager (unless in dry-run mode)\n if (!options.dryRun) {\n await fileBackupManager.initialize();\n if (options.verbose) {\n callbacks?.onLog?.('š File backup manager initialized');\n }\n }\n \n // Process each entity directory\n let totalCreated = 0;\n let totalUpdated = 0;\n let totalUnchanged = 0;\n let totalErrors = 0;\n \n // Begin transaction if not in dry-run mode\n if (!options.dryRun) {\n await transactionManager.beginTransaction();\n }\n \n try {\n for (const entityDir of entityDirs) {\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n const warning = `Skipping ${entityDir} - no valid entity configuration`;\n this.warnings.push(warning);\n callbacks?.onWarn?.(warning);\n continue;\n }\n \n if (options.verbose) {\n callbacks?.onLog?.(`\\nProcessing ${entityConfig.entity} in ${entityDir}`);\n }\n \n const result = await this.processEntityDirectory(\n entityDir,\n entityConfig,\n options,\n fileBackupManager,\n callbacks,\n sqlLogger\n );\n \n // Show per-directory summary\n const dirName = path.relative(process.cwd(), entityDir) || '.';\n const dirTotal = result.created + result.updated + result.unchanged;\n if (dirTotal > 0 || result.errors > 0) {\n callbacks?.onLog?.(`\\nš ${dirName}:`);\n callbacks?.onLog?.(` Total processed: ${dirTotal} unique records`);\n if (result.created > 0) {\n callbacks?.onLog?.(` ā Created: ${result.created}`);\n }\n if (result.updated > 0) {\n callbacks?.onLog?.(` ā Updated: ${result.updated}`);\n }\n if (result.unchanged > 0) {\n callbacks?.onLog?.(` - Unchanged: ${result.unchanged}`);\n }\n if (result.errors > 0) {\n callbacks?.onLog?.(` ā Errors: ${result.errors}`);\n }\n }\n \n totalCreated += result.created;\n totalUpdated += result.updated;\n totalUnchanged += result.unchanged;\n totalErrors += result.errors;\n }\n \n // Commit transaction if successful\n if (!options.dryRun && totalErrors === 0) {\n await transactionManager.commitTransaction();\n }\n } catch (error) {\n // Rollback transaction on error\n if (!options.dryRun) {\n await transactionManager.rollbackTransaction();\n }\n throw error;\n }\n \n // Commit file backups if successful and not in dry-run mode\n if (!options.dryRun && totalErrors === 0) {\n await fileBackupManager.cleanup();\n if (options.verbose) {\n callbacks?.onLog?.('ā
File backups committed');\n }\n }\n \n // Write SQL log if enabled\n let sqlLogPath: string | undefined;\n if (sqlLogger.enabled && !options.dryRun) {\n sqlLogPath = await sqlLogger.writeLog();\n if (sqlLogPath && options.verbose) {\n callbacks?.onLog?.(`š SQL log written to: ${sqlLogPath}`);\n }\n }\n \n return {\n created: totalCreated,\n updated: totalUpdated,\n unchanged: totalUnchanged,\n errors: totalErrors,\n warnings: this.warnings,\n sqlLogPath\n };\n \n } catch (error) {\n // Rollback file backups on error\n if (!options.dryRun) {\n try {\n await fileBackupManager.rollback();\n callbacks?.onWarn?.('File backups rolled back due to error');\n } catch (rollbackError) {\n callbacks?.onWarn?.(`Failed to rollback file backups: ${rollbackError}`);\n }\n }\n throw error;\n }\n }\n \n private async processEntityDirectory(\n entityDir: string,\n entityConfig: any,\n options: PushOptions,\n fileBackupManager: FileBackupManager,\n callbacks?: PushCallbacks,\n sqlLogger?: SQLLogger\n ): Promise<EntityPushResult> {\n let created = 0;\n let updated = 0;\n let unchanged = 0;\n let errors = 0;\n \n // Find all JSON files in the directory\n const pattern = entityConfig.filePattern || '*.json';\n const files = await fastGlob(pattern, {\n cwd: entityDir,\n absolute: true,\n onlyFiles: true,\n ignore: ['**/node_modules/**', '**/.mj-*.json']\n });\n \n if (options.verbose) {\n callbacks?.onLog?.(`Found ${files.length} files to process`);\n }\n \n // Process each file\n for (const filePath of files) {\n try {\n const fileData = await fs.readJson(filePath);\n const records = Array.isArray(fileData) ? fileData : [fileData];\n \n for (let i = 0; i < records.length; i++) {\n const recordData = records[i];\n \n if (!this.isValidRecordData(recordData)) {\n callbacks?.onWarn?.(`Invalid record format in ${filePath}${Array.isArray(fileData) ? ` at index ${i}` : ''}`);\n errors++;\n continue;\n }\n \n try {\n const result = await this.processRecord(\n recordData,\n entityConfig,\n entityDir,\n options,\n callbacks\n );\n \n if (result === 'created') created++;\n else if (result === 'updated') updated++;\n else if (result === 'unchanged') unchanged++;\n \n // Track processed record\n const recordKey = this.getRecordKey(recordData, entityConfig.entity);\n this.processedRecords.set(recordKey, {\n filePath,\n arrayIndex: Array.isArray(fileData) ? i : undefined,\n lineNumber: i + 1 // Simple line number approximation\n });\n \n } catch (recordError) {\n const errorMsg = `Error processing record in ${filePath}${Array.isArray(fileData) ? ` at index ${i}` : ''}: ${recordError}`;\n callbacks?.onError?.(errorMsg);\n errors++;\n }\n }\n } catch (fileError) {\n const errorMsg = `Error reading file ${filePath}: ${fileError}`;\n callbacks?.onError?.(errorMsg);\n errors++;\n }\n }\n \n return { created, updated, unchanged, errors };\n }\n \n private async processRecord(\n recordData: RecordData,\n entityConfig: any,\n entityDir: string,\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<'created' | 'updated' | 'unchanged' | 'error'> {\n const metadata = new Metadata();\n const entityInfo = metadata.EntityByName(entityConfig.entity);\n \n if (!entityInfo) {\n throw new Error(`Entity ${entityConfig.entity} not found in metadata`);\n }\n \n // Get or create entity instance\n let entity = await metadata.GetEntityObject(entityConfig.entity, this.contextUser);\n if (!entity) {\n throw new Error(`Failed to create entity object for ${entityConfig.entity}`);\n }\n \n // Apply defaults from configuration\n const defaults = { ...entityConfig.defaults };\n \n // Build full record data\n const fullData = {\n ...defaults,\n ...recordData.fields\n };\n \n // Process field values\n const processedData: Record<string, any> = {};\n for (const [fieldName, fieldValue] of Object.entries(fullData)) {\n const processedValue = await this.syncEngine.processFieldValue(\n fieldValue,\n entityDir,\n null, // parentRecord\n null // rootRecord\n );\n processedData[fieldName] = processedValue;\n }\n \n // Check if record exists\n const primaryKey = recordData.primaryKey;\n let exists = false;\n let existingEntity: BaseEntity | null = null;\n \n if (primaryKey && Object.keys(primaryKey).length > 0) {\n // Try to load existing record\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromSimpleObject(primaryKey);\n existingEntity = await metadata.GetEntityObject(entityConfig.entity, this.contextUser);\n if (existingEntity) {\n exists = await existingEntity.InnerLoad(compositeKey);\n \n // Check autoCreateMissingRecords flag if record not found\n if (!exists) {\n const autoCreate = this.syncConfig?.push?.autoCreateMissingRecords ?? false;\n const pkDisplay = Object.entries(primaryKey)\n .map(([key, value]) => `${key}=${value}`)\n .join(', ');\n \n if (!autoCreate) {\n const warning = `Record not found: ${entityConfig.entity} with primaryKey {${pkDisplay}}. To auto-create missing records, set push.autoCreateMissingRecords=true in .mj-sync.json`;\n this.warnings.push(warning);\n callbacks?.onWarn?.(warning);\n return 'error';\n } else if (options.verbose) {\n callbacks?.onLog?.(`Auto-creating missing ${entityConfig.entity} record with primaryKey {${pkDisplay}}`);\n }\n }\n }\n }\n \n if (options.dryRun) {\n if (exists) {\n callbacks?.onLog?.(`[DRY RUN] Would update ${entityConfig.entity} record`);\n return 'updated';\n } else {\n callbacks?.onLog?.(`[DRY RUN] Would create ${entityConfig.entity} record`);\n return 'created';\n }\n }\n \n // Use existing entity if found, otherwise create new one\n if (!exists) {\n entity = existingEntity || entity;\n entity.NewRecord();\n \n // Set primary key values for new records if provided\n if (primaryKey) {\n for (const [pkField, pkValue] of Object.entries(primaryKey)) {\n entity.Set(pkField, pkValue);\n }\n }\n }\n \n // Set field values\n for (const [fieldName, fieldValue] of Object.entries(processedData)) {\n entity.Set(fieldName, fieldValue);\n }\n \n // Handle related entities\n if (recordData.relatedEntities) {\n // Store related entities to process after parent save\n (entity as any).__pendingRelatedEntities = recordData.relatedEntities;\n }\n \n // Save the record\n // TODO: Hook into BaseEntity SQL execution for SQL logging\n // Currently SQL logging requires deeper integration with MJ core\n const saveResult = await entity.Save();\n \n if (!saveResult) {\n throw new Error(`Failed to save ${entityConfig.entity} record: ${entity.LatestResult?.Message || 'Unknown error'}`);\n }\n \n // Process related entities after parent save\n if (recordData.relatedEntities) {\n await this.processRelatedEntities(\n entity,\n recordData.relatedEntities,\n entityDir,\n options,\n callbacks\n );\n }\n \n return exists ? 'updated' : 'created';\n }\n \n private async processRelatedEntities(\n parentEntity: BaseEntity,\n relatedEntities: Record<string, RecordData[]>,\n entityDir: string,\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<void> {\n // TODO: Complete implementation for processing related entities\n // This is a simplified version - full implementation would:\n // 1. Create entity objects for each related entity type\n // 2. Apply field values with proper parent/root references\n // 3. Save related entities with proper error handling\n // 4. Support nested related entities recursively\n for (const [key, records] of Object.entries(relatedEntities)) {\n for (const relatedRecord of records) {\n // Process @parent references\n const processedFields: Record<string, any> = {};\n for (const [fieldName, fieldValue] of Object.entries(relatedRecord.fields)) {\n if (typeof fieldValue === 'string' && fieldValue.startsWith('@parent:')) {\n const parentField = fieldValue.substring(8);\n processedFields[fieldName] = parentEntity.Get(parentField);\n } else {\n processedFields[fieldName] = await this.syncEngine.processFieldValue(\n fieldValue,\n entityDir,\n parentEntity,\n null\n );\n }\n }\n \n // Save related entity (simplified - full implementation needed)\n relatedRecord.fields = processedFields;\n }\n }\n }\n \n private isValidRecordData(data: any): data is RecordData {\n return data && \n typeof data === 'object' && \n 'fields' in data &&\n typeof data.fields === 'object';\n }\n \n private getRecordKey(recordData: RecordData, entityName: string): string {\n if (recordData.primaryKey) {\n const keys = Object.entries(recordData.primaryKey)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join('|');\n return `${entityName}|${keys}`;\n }\n \n // Generate a key from fields if no primary key\n const fieldKeys = Object.keys(recordData.fields).sort().join(',');\n return `${entityName}|fields:${fieldKeys}`;\n }\n \n private findEntityDirectories(baseDir: string, specificDir?: string): string[] {\n const dirs: string[] = [];\n \n if (specificDir) {\n // Process specific directory\n const fullPath = path.resolve(baseDir, specificDir);\n if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {\n dirs.push(fullPath);\n }\n } else {\n // Find all entity directories\n const searchDirs = (dir: string) => {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {\n const fullPath = path.join(dir, entry.name);\n const configPath = path.join(fullPath, '.mj-sync.json');\n \n if (fs.existsSync(configPath)) {\n try {\n const config = fs.readJsonSync(configPath);\n if (config.entity) {\n dirs.push(fullPath);\n }\n } catch {\n // Skip invalid config files\n }\n } else {\n // Recurse into subdirectories\n searchDirs(fullPath);\n }\n }\n }\n };\n \n searchDirs(baseDir);\n }\n \n return dirs;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"PushService.js","sourceRoot":"","sources":["../../src/services/PushService.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,0DAAiC;AACjC,+CAA+F;AAE/F,sCAA6D;AAC7D,oEAA+D;AAC/D,0DAAsD;AACtD,kDAA8C;AAC9C,oEAAgE;AAmChE,MAAa,WAAW;IACd,UAAU,CAAa;IACvB,WAAW,CAAW;IACtB,QAAQ,GAAa,EAAE,CAAC;IACxB,gBAAgB,GAAgF,IAAI,GAAG,EAAE,CAAC;IAC1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AC,UAAU,CAAC,CAAC;wBAC3C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;4BAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;wBACtB,CAAC;oBACH,CAAC;oBAAC,MAAM,CAAC;wBACP,4BAA4B;oBAC9B,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,8BAA8B;oBAC9B,IAAI,CAAC,8BAA8B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACtD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAjpBD,kCAipBC","sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport fastGlob from 'fast-glob';\nimport { BaseEntity, LogStatus, Metadata, UserInfo, CompositeKey } from '@memberjunction/core';\nimport { SyncEngine, RecordData } from '../lib/sync-engine';\nimport { loadEntityConfig, loadSyncConfig } from '../config';\nimport { FileBackupManager } from '../lib/file-backup-manager';\nimport { configManager } from '../lib/config-manager';\nimport { SQLLogger } from '../lib/sql-logger';\nimport { TransactionManager } from '../lib/transaction-manager';\nimport type { SqlLoggingSession, SQLServerDataProvider } from '@memberjunction/sqlserver-dataprovider';\n\nexport interface PushOptions {\n dir?: string;\n dryRun?: boolean;\n verbose?: boolean;\n noValidate?: boolean;\n}\n\nexport interface PushCallbacks {\n onProgress?: (message: string) => void;\n onSuccess?: (message: string) => void;\n onError?: (message: string) => void;\n onWarn?: (message: string) => void;\n onLog?: (message: string) => void;\n onConfirm?: (message: string) => Promise<boolean>;\n}\n\nexport interface PushResult {\n created: number;\n updated: number;\n unchanged: number;\n errors: number;\n warnings: string[];\n sqlLogPath?: string;\n}\n\nexport interface EntityPushResult {\n created: number;\n updated: number;\n unchanged: number;\n errors: number;\n}\n\nexport class PushService {\n private syncEngine: SyncEngine;\n private contextUser: UserInfo;\n private warnings: string[] = [];\n private processedRecords: Map<string, { filePath: string; arrayIndex?: number; lineNumber?: number }> = new Map();\n private syncConfig: any;\n \n constructor(syncEngine: SyncEngine, contextUser: UserInfo) {\n this.syncEngine = syncEngine;\n this.contextUser = contextUser;\n }\n \n async push(options: PushOptions, callbacks?: PushCallbacks): Promise<PushResult> {\n this.warnings = [];\n this.processedRecords.clear();\n \n const fileBackupManager = new FileBackupManager();\n \n // Load sync config for SQL logging settings and autoCreateMissingRecords flag\n // If dir option is specified, load from that directory, otherwise use original CWD\n const configDir = options.dir ? path.resolve(configManager.getOriginalCwd(), options.dir) : configManager.getOriginalCwd();\n this.syncConfig = await loadSyncConfig(configDir);\n \n if (options.verbose) {\n callbacks?.onLog?.(`Original working directory: ${configManager.getOriginalCwd()}`);\n callbacks?.onLog?.(`Config directory (with dir option): ${configDir}`);\n callbacks?.onLog?.(`Config file path: ${path.join(configDir, '.mj-sync.json')}`);\n callbacks?.onLog?.(`Full sync config loaded: ${JSON.stringify(this.syncConfig, null, 2)}`);\n callbacks?.onLog?.(`SQL logging config: ${JSON.stringify(this.syncConfig?.sqlLogging)}`);\n }\n \n const sqlLogger = new SQLLogger(this.syncConfig);\n const transactionManager = new TransactionManager(sqlLogger);\n \n if (options.verbose) {\n callbacks?.onLog?.(`SQLLogger enabled status: ${sqlLogger.enabled}`);\n }\n \n // Setup SQL logging session with the provider if enabled\n let sqlLoggingSession: SqlLoggingSession | null = null;\n \n try {\n // Initialize SQL logger if enabled and not dry-run\n if (sqlLogger.enabled && !options.dryRun) {\n const provider = Metadata.Provider as SQLServerDataProvider;\n \n if (options.verbose) {\n callbacks?.onLog?.(`SQL logging enabled: ${sqlLogger.enabled}`);\n callbacks?.onLog?.(`Provider type: ${provider?.constructor?.name || 'Unknown'}`);\n callbacks?.onLog?.(`Has CreateSqlLogger: ${typeof provider?.CreateSqlLogger === 'function'}`);\n }\n \n if (provider && typeof provider.CreateSqlLogger === 'function') {\n // Generate filename with timestamp\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n const filename = this.syncConfig.sqlLogging?.formatAsMigration \n ? `MetadataSync_Push_${timestamp}.sql`\n : `push_${timestamp}.sql`;\n \n // Use .sql-log-push directory in the config directory (where sync was initiated)\n const outputDir = path.join(configDir, this.syncConfig?.sqlLogging?.outputDirectory || './sql-log-push');\n const filepath = path.join(outputDir, filename);\n \n // Ensure the directory exists\n await fs.ensureDir(path.dirname(filepath));\n \n // Create the SQL logging session\n sqlLoggingSession = await provider.CreateSqlLogger(filepath, {\n formatAsMigration: this.syncConfig.sqlLogging?.formatAsMigration || false,\n description: 'MetadataSync push operation',\n statementTypes: \"mutations\",\n prettyPrint: true, \n });\n \n if (options.verbose) {\n callbacks?.onLog?.(`š SQL logging enabled: ${filepath}`);\n }\n } else {\n if (options.verbose) {\n callbacks?.onWarn?.('SQL logging requested but provider does not support it');\n }\n }\n }\n \n // Find entity directories to process\n const entityDirs = this.findEntityDirectories(configDir);\n \n if (entityDirs.length === 0) {\n throw new Error('No entity directories found');\n }\n \n if (options.verbose) {\n callbacks?.onLog?.(`Found ${entityDirs.length} entity ${entityDirs.length === 1 ? 'directory' : 'directories'} to process`);\n }\n \n // Initialize file backup manager (unless in dry-run mode)\n if (!options.dryRun) {\n await fileBackupManager.initialize();\n if (options.verbose) {\n callbacks?.onLog?.('š File backup manager initialized');\n }\n }\n \n // Process each entity directory\n let totalCreated = 0;\n let totalUpdated = 0;\n let totalUnchanged = 0;\n let totalErrors = 0;\n \n // Begin transaction if not in dry-run mode\n if (!options.dryRun) {\n await transactionManager.beginTransaction();\n }\n \n try {\n for (const entityDir of entityDirs) {\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n const warning = `Skipping ${entityDir} - no valid entity configuration`;\n this.warnings.push(warning);\n callbacks?.onWarn?.(warning);\n continue;\n }\n \n if (options.verbose) {\n callbacks?.onLog?.(`\\nProcessing ${entityConfig.entity} in ${entityDir}`);\n }\n \n const result = await this.processEntityDirectory(\n entityDir,\n entityConfig,\n options,\n fileBackupManager,\n callbacks,\n sqlLogger\n );\n \n // Show per-directory summary\n const dirName = path.relative(process.cwd(), entityDir) || '.';\n const dirTotal = result.created + result.updated + result.unchanged;\n if (dirTotal > 0 || result.errors > 0) {\n callbacks?.onLog?.(`\\nš ${dirName}:`);\n callbacks?.onLog?.(` Total processed: ${dirTotal} unique records`);\n if (result.created > 0) {\n callbacks?.onLog?.(` ā Created: ${result.created}`);\n }\n if (result.updated > 0) {\n callbacks?.onLog?.(` ā Updated: ${result.updated}`);\n }\n if (result.unchanged > 0) {\n callbacks?.onLog?.(` - Unchanged: ${result.unchanged}`);\n }\n if (result.errors > 0) {\n callbacks?.onLog?.(` ā Errors: ${result.errors}`);\n }\n }\n \n totalCreated += result.created;\n totalUpdated += result.updated;\n totalUnchanged += result.unchanged;\n totalErrors += result.errors;\n }\n \n // Commit transaction if successful\n if (!options.dryRun && totalErrors === 0) {\n await transactionManager.commitTransaction();\n }\n } catch (error) {\n // Rollback transaction on error\n if (!options.dryRun) {\n await transactionManager.rollbackTransaction();\n }\n throw error;\n }\n \n // Commit file backups if successful and not in dry-run mode\n if (!options.dryRun && totalErrors === 0) {\n await fileBackupManager.cleanup();\n if (options.verbose) {\n callbacks?.onLog?.('ā
File backups committed');\n }\n }\n \n // Close SQL logging session if it was created\n let sqlLogPath: string | undefined;\n if (sqlLoggingSession) {\n sqlLogPath = sqlLoggingSession.filePath;\n await sqlLoggingSession.dispose();\n if (options.verbose) {\n callbacks?.onLog?.(`š SQL log written to: ${sqlLogPath}`);\n }\n }\n \n return {\n created: totalCreated,\n updated: totalUpdated,\n unchanged: totalUnchanged,\n errors: totalErrors,\n warnings: this.warnings,\n sqlLogPath\n };\n \n } catch (error) {\n // Rollback file backups on error\n if (!options.dryRun) {\n try {\n await fileBackupManager.rollback();\n callbacks?.onWarn?.('File backups rolled back due to error');\n } catch (rollbackError) {\n callbacks?.onWarn?.(`Failed to rollback file backups: ${rollbackError}`);\n }\n }\n \n // Close SQL logging session on error\n if (sqlLoggingSession) {\n try {\n await sqlLoggingSession.dispose();\n } catch (disposeError) {\n callbacks?.onWarn?.(`Failed to close SQL logging session: ${disposeError}`);\n }\n }\n \n throw error;\n }\n }\n \n private async processEntityDirectory(\n entityDir: string,\n entityConfig: any,\n options: PushOptions,\n fileBackupManager: FileBackupManager,\n callbacks?: PushCallbacks,\n sqlLogger?: SQLLogger\n ): Promise<EntityPushResult> {\n let created = 0;\n let updated = 0;\n let unchanged = 0;\n let errors = 0;\n \n // Find all JSON files in the directory\n const pattern = entityConfig.filePattern || '*.json';\n const files = await fastGlob(pattern, {\n cwd: entityDir,\n absolute: true,\n onlyFiles: true,\n dot: true,\n ignore: ['**/node_modules/**', '**/.mj-*.json']\n });\n \n if (options.verbose) {\n callbacks?.onLog?.(`Found ${files.length} files to process`);\n }\n \n // Process each file\n for (const filePath of files) {\n try {\n // Backup the file before any modifications (unless dry-run)\n if (!options.dryRun) {\n await fileBackupManager.backupFile(filePath);\n }\n \n const fileData = await fs.readJson(filePath);\n const records = Array.isArray(fileData) ? fileData : [fileData];\n const isArray = Array.isArray(fileData);\n \n for (let i = 0; i < records.length; i++) {\n const recordData = records[i];\n \n if (!this.isValidRecordData(recordData)) {\n callbacks?.onWarn?.(`Invalid record format in ${filePath}${isArray ? ` at index ${i}` : ''}`);\n errors++;\n continue;\n }\n \n try {\n // For arrays, work with a deep copy to avoid modifying the original\n const recordToProcess = isArray ? JSON.parse(JSON.stringify(recordData)) : recordData;\n \n const result = await this.processRecord(\n recordToProcess,\n entityConfig,\n entityDir,\n options,\n callbacks,\n filePath,\n isArray ? i : undefined\n );\n \n if (result === 'created') created++;\n else if (result === 'updated') updated++;\n else if (result === 'unchanged') unchanged++;\n \n // For arrays, update the original record's primaryKey and sync only\n if (isArray) {\n // Update primaryKey if it exists (for new records)\n if (recordToProcess.primaryKey) {\n records[i].primaryKey = recordToProcess.primaryKey;\n }\n // Update sync metadata only if it was updated (dirty records only)\n if (recordToProcess.sync) {\n records[i].sync = recordToProcess.sync;\n }\n }\n \n // Track processed record\n const recordKey = this.getRecordKey(recordData, entityConfig.entity);\n this.processedRecords.set(recordKey, {\n filePath,\n arrayIndex: isArray ? i : undefined,\n lineNumber: i + 1 // Simple line number approximation\n });\n \n } catch (recordError) {\n const errorMsg = `Error processing record in ${filePath}${isArray ? ` at index ${i}` : ''}: ${recordError}`;\n callbacks?.onError?.(errorMsg);\n errors++;\n }\n }\n \n // Write back the entire file if it's an array (after processing all records)\n if (isArray && !options.dryRun) {\n await fs.writeJson(filePath, records, { spaces: 2 });\n }\n } catch (fileError) {\n const errorMsg = `Error reading file ${filePath}: ${fileError}`;\n callbacks?.onError?.(errorMsg);\n errors++;\n }\n }\n \n return { created, updated, unchanged, errors };\n }\n \n private async processRecord(\n recordData: RecordData,\n entityConfig: any,\n entityDir: string,\n options: PushOptions,\n callbacks?: PushCallbacks,\n filePath?: string,\n arrayIndex?: number\n ): Promise<'created' | 'updated' | 'unchanged' | 'error'> {\n const metadata = new Metadata();\n \n // Get or create entity instance\n let entity = await metadata.GetEntityObject(entityConfig.entity, this.contextUser);\n if (!entity) {\n throw new Error(`Failed to create entity object for ${entityConfig.entity}`);\n }\n \n // Apply defaults from configuration\n const defaults = { ...entityConfig.defaults };\n \n // Build full record data - keep original values for file writing\n const originalFields = { ...recordData.fields };\n const fullData = {\n ...defaults,\n ...recordData.fields\n };\n \n // Process field values for database operations\n const processedData: Record<string, any> = {};\n for (const [fieldName, fieldValue] of Object.entries(fullData)) {\n const processedValue = await this.syncEngine.processFieldValue(\n fieldValue,\n entityDir,\n null, // parentRecord\n null // rootRecord\n );\n processedData[fieldName] = processedValue;\n }\n \n // Check if record exists\n const primaryKey = recordData.primaryKey;\n let exists = false;\n let isNew = false;\n \n if (primaryKey && Object.keys(primaryKey).length > 0) {\n // Try to load existing record\n const compositeKey = new CompositeKey();\n compositeKey.LoadFromSimpleObject(primaryKey);\n exists = await entity.InnerLoad(compositeKey);\n \n // Check autoCreateMissingRecords flag if record not found\n if (!exists) {\n const autoCreate = this.syncConfig?.push?.autoCreateMissingRecords ?? false;\n const pkDisplay = Object.entries(primaryKey)\n .map(([key, value]) => `${key}=${value}`)\n .join(', ');\n \n if (!autoCreate) {\n const warning = `Record not found: ${entityConfig.entity} with primaryKey {${pkDisplay}}. To auto-create missing records, set push.autoCreateMissingRecords=true in .mj-sync.json`;\n this.warnings.push(warning);\n callbacks?.onWarn?.(warning);\n return 'error';\n } else if (options.verbose) {\n callbacks?.onLog?.(`Auto-creating missing ${entityConfig.entity} record with primaryKey {${pkDisplay}}`);\n }\n }\n }\n \n if (options.dryRun) {\n if (exists) {\n callbacks?.onLog?.(`[DRY RUN] Would update ${entityConfig.entity} record`);\n return 'updated';\n } else {\n callbacks?.onLog?.(`[DRY RUN] Would create ${entityConfig.entity} record`);\n return 'created';\n }\n }\n \n if (!exists) {\n entity.NewRecord(); // make sure our record starts out fresh\n isNew = true;\n // Set primary key values for new records if provided, this is important for the auto-create logic\n if (primaryKey) {\n for (const [pkField, pkValue] of Object.entries(primaryKey)) {\n entity.Set(pkField, pkValue);\n }\n }\n }\n \n // Set field values\n for (const [fieldName, fieldValue] of Object.entries(processedData)) {\n entity.Set(fieldName, fieldValue);\n }\n\n // Handle related entities\n if (recordData.relatedEntities) {\n // Store related entities to process after parent save\n (entity as any).__pendingRelatedEntities = recordData.relatedEntities;\n }\n \n // Check if the record is actually dirty before considering it changed\n let isDirty = entity.Dirty;\n \n // Also check if file content has changed (for @file references)\n if (!isDirty && !isNew && recordData.sync) {\n const currentChecksum = await this.syncEngine.calculateChecksumWithFileContent(originalFields, entityDir);\n if (currentChecksum !== recordData.sync.checksum) {\n isDirty = true;\n if (options.verbose) {\n callbacks?.onLog?.(`š File content changed for ${entityConfig.entity} record (checksum mismatch)`);\n }\n }\n }\n \n // If updating an existing record that's dirty, show what changed\n if (!isNew && isDirty) {\n const changes = entity.GetChangesSinceLastSave();\n const changeKeys = Object.keys(changes);\n if (changeKeys.length > 0) {\n // Get primary key info for display\n const entityInfo = this.syncEngine.getEntityInfo(entityConfig.entity);\n const primaryKeyDisplay: string[] = [];\n if (entityInfo) {\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKeyDisplay.push(`${pk.Name}: ${entity.Get(pk.Name)}`);\n }\n }\n \n callbacks?.onLog?.(`š Updating ${entityConfig.entity} record:`);\n if (primaryKeyDisplay.length > 0) {\n callbacks?.onLog?.(` Primary Key: ${primaryKeyDisplay.join(', ')}`);\n }\n callbacks?.onLog?.(` Changes:`);\n for (const fieldName of changeKeys) {\n const field = entity.GetFieldByName(fieldName);\n const oldValue = field ? field.OldValue : undefined;\n const newValue = (changes as any)[fieldName];\n callbacks?.onLog?.(` ${fieldName}: ${this.formatFieldValue(oldValue)} ā ${this.formatFieldValue(newValue)}`);\n }\n }\n }\n \n // Save the record (always call Save, but track if it was actually dirty)\n const saveResult = await entity.Save();\n \n if (!saveResult) {\n throw new Error(`Failed to save ${entityConfig.entity} record: ${entity.LatestResult?.Message || 'Unknown error'}`);\n }\n \n // Update primaryKey for new records\n if (isNew) {\n const entityInfo = this.syncEngine.getEntityInfo(entityConfig.entity);\n if (entityInfo) {\n const newPrimaryKey: Record<string, any> = {};\n for (const pk of entityInfo.PrimaryKeys) {\n newPrimaryKey[pk.Name] = entity.Get(pk.Name);\n }\n recordData.primaryKey = newPrimaryKey;\n }\n }\n \n // Only update sync metadata if the record was actually dirty (changed)\n if (isNew || isDirty) {\n recordData.sync = {\n lastModified: new Date().toISOString(),\n checksum: await this.syncEngine.calculateChecksumWithFileContent(originalFields, entityDir)\n };\n }\n \n // Restore original field values to preserve @ references\n recordData.fields = originalFields;\n \n // Write back to file only if it's a single record (not part of an array)\n if (filePath && arrayIndex === undefined && !options.dryRun) {\n await fs.writeJson(filePath, recordData, { spaces: 2 });\n }\n \n // Process related entities after parent save\n if (recordData.relatedEntities) {\n await this.processRelatedEntities(\n entity,\n recordData.relatedEntities,\n entityDir,\n options,\n callbacks\n );\n }\n \n // Return the actual status based on whether the record was dirty\n if (isNew) {\n return 'created';\n } else if (isDirty) {\n return 'updated';\n } else {\n return 'unchanged';\n }\n }\n \n private async processRelatedEntities(\n parentEntity: BaseEntity,\n relatedEntities: Record<string, RecordData[]>,\n entityDir: string,\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<void> {\n // TODO: Complete implementation for processing related entities\n // This is a simplified version - full implementation would:\n // 1. Create entity objects for each related entity type\n // 2. Apply field values with proper parent/root references\n // 3. Save related entities with proper error handling\n // 4. Support nested related entities recursively\n for (const [key, records] of Object.entries(relatedEntities)) {\n for (const relatedRecord of records) {\n // Process @parent references but DON'T modify the original fields\n const processedFields: Record<string, any> = {};\n for (const [fieldName, fieldValue] of Object.entries(relatedRecord.fields)) {\n if (typeof fieldValue === 'string' && fieldValue.startsWith('@parent:')) {\n const parentField = fieldValue.substring(8);\n processedFields[fieldName] = parentEntity.Get(parentField);\n } else {\n processedFields[fieldName] = await this.syncEngine.processFieldValue(\n fieldValue,\n entityDir,\n parentEntity,\n null\n );\n }\n }\n \n // TODO: Actually save the related entity with processedFields\n // For now, we're just processing the values but not saving\n // This needs to be implemented to actually create/update the related entities\n }\n }\n }\n \n private isValidRecordData(data: any): data is RecordData {\n return data && \n typeof data === 'object' && \n 'fields' in data &&\n typeof data.fields === 'object';\n }\n \n private getRecordKey(recordData: RecordData, entityName: string): string {\n if (recordData.primaryKey) {\n const keys = Object.entries(recordData.primaryKey)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join('|');\n return `${entityName}|${keys}`;\n }\n \n // Generate a key from fields if no primary key\n const fieldKeys = Object.keys(recordData.fields).sort().join(',');\n return `${entityName}|fields:${fieldKeys}`;\n }\n \n private formatFieldValue(value: any, maxLength: number = 50): string {\n let strValue = JSON.stringify(value);\n strValue = strValue.trim();\n\n if (strValue.length > maxLength) {\n return strValue.substring(0, maxLength) + '...';\n }\n\n return strValue;\n }\n \n private findEntityDirectories(baseDir: string, specificDir?: string): string[] {\n const dirs: string[] = [];\n \n if (specificDir) {\n // Process specific directory\n const fullPath = path.resolve(baseDir, specificDir);\n if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {\n // Check if this directory has an entity configuration\n const configPath = path.join(fullPath, '.mj-sync.json');\n if (fs.existsSync(configPath)) {\n try {\n const config = fs.readJsonSync(configPath);\n if (config.entity) {\n // It's an entity directory, add it\n dirs.push(fullPath);\n } else {\n // It's a container directory, search its subdirectories\n this.findEntityDirectoriesRecursive(fullPath, dirs);\n }\n } catch {\n // Invalid config, skip\n }\n }\n }\n } else {\n // Find all entity directories\n this.findEntityDirectoriesRecursive(baseDir, dirs);\n }\n \n return dirs;\n }\n\n private findEntityDirectoriesRecursive(dir: string, dirs: string[]): void {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {\n const fullPath = path.join(dir, entry.name);\n const configPath = path.join(fullPath, '.mj-sync.json');\n \n if (fs.existsSync(configPath)) {\n try {\n const config = fs.readJsonSync(configPath);\n if (config.entity) {\n dirs.push(fullPath);\n }\n } catch {\n // Skip invalid config files\n }\n } else {\n // Recurse into subdirectories\n this.findEntityDirectoriesRecursive(fullPath, dirs);\n }\n }\n }\n }\n}"]}
|
|
@@ -24,9 +24,11 @@ export interface WatchResult {
|
|
|
24
24
|
export declare class WatchService {
|
|
25
25
|
private syncEngine;
|
|
26
26
|
private debounceTimers;
|
|
27
|
+
private sqlLoggingSession;
|
|
27
28
|
constructor(syncEngine: SyncEngine);
|
|
28
29
|
watch(options?: WatchOptions, callbacks?: WatchCallbacks): Promise<WatchResult>;
|
|
29
30
|
private handleFileChange;
|
|
30
31
|
private syncJsonFile;
|
|
31
32
|
private syncExternalFile;
|
|
33
|
+
private setupSqlLogging;
|
|
32
34
|
}
|
|
@@ -7,11 +7,14 @@ 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 core_1 = require("@memberjunction/core");
|
|
10
11
|
const config_1 = require("../config");
|
|
11
12
|
const provider_utils_1 = require("../lib/provider-utils");
|
|
13
|
+
const config_manager_1 = require("../lib/config-manager");
|
|
12
14
|
class WatchService {
|
|
13
15
|
syncEngine;
|
|
14
16
|
debounceTimers = new Map();
|
|
17
|
+
sqlLoggingSession = null;
|
|
15
18
|
constructor(syncEngine) {
|
|
16
19
|
this.syncEngine = syncEngine;
|
|
17
20
|
}
|
|
@@ -21,6 +24,8 @@ class WatchService {
|
|
|
21
24
|
throw new Error('No entity directories found');
|
|
22
25
|
}
|
|
23
26
|
callbacks?.onLog?.(`Watching ${entityDirs.length} entity ${entityDirs.length === 1 ? 'directory' : 'directories'} for changes`);
|
|
27
|
+
// Setup SQL logging session
|
|
28
|
+
await this.setupSqlLogging(callbacks);
|
|
24
29
|
// Set up watchers
|
|
25
30
|
const watchers = [];
|
|
26
31
|
for (const entityDir of entityDirs) {
|
|
@@ -77,6 +82,17 @@ class WatchService {
|
|
|
77
82
|
this.debounceTimers.clear();
|
|
78
83
|
// Close all watchers
|
|
79
84
|
await Promise.all(watchers.map(w => w.close()));
|
|
85
|
+
// Dispose SQL logging session
|
|
86
|
+
if (this.sqlLoggingSession) {
|
|
87
|
+
try {
|
|
88
|
+
callbacks?.onLog?.(`š SQL log written to: ${this.sqlLoggingSession.filePath}`);
|
|
89
|
+
await this.sqlLoggingSession.dispose();
|
|
90
|
+
this.sqlLoggingSession = null;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
callbacks?.onWarn?.(`Failed to close SQL logging session: ${error}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
80
96
|
}
|
|
81
97
|
};
|
|
82
98
|
}
|
|
@@ -118,6 +134,8 @@ class WatchService {
|
|
|
118
134
|
}
|
|
119
135
|
async syncJsonFile(filePath, entityDir, entityConfig, callbacks) {
|
|
120
136
|
const recordData = await fs_extra_1.default.readJson(filePath);
|
|
137
|
+
// Keep original fields for file writing
|
|
138
|
+
const originalFields = { ...recordData.fields };
|
|
121
139
|
// Build defaults
|
|
122
140
|
const defaults = await this.syncEngine.buildDefaults(filePath, entityConfig);
|
|
123
141
|
// Load or create entity
|
|
@@ -138,7 +156,7 @@ class WatchService {
|
|
|
138
156
|
entity[field] = value;
|
|
139
157
|
}
|
|
140
158
|
}
|
|
141
|
-
// Apply record fields
|
|
159
|
+
// Apply record fields with processed values for database operations
|
|
142
160
|
for (const [field, value] of Object.entries(recordData.fields)) {
|
|
143
161
|
if (field in entity) {
|
|
144
162
|
const processedValue = await this.syncEngine.processFieldValue(value, path_1.default.dirname(filePath));
|
|
@@ -197,20 +215,25 @@ class WatchService {
|
|
|
197
215
|
else {
|
|
198
216
|
callbacks?.onLog?.(`No changes detected for ${entityConfig.entity} record - skipped update`);
|
|
199
217
|
}
|
|
200
|
-
// Update the local file with
|
|
201
|
-
if (
|
|
218
|
+
// Update the local file with primary key and sync metadata
|
|
219
|
+
if (wasActuallyUpdated) {
|
|
202
220
|
const entityInfo = this.syncEngine.getEntityInfo(entityConfig.entity);
|
|
203
221
|
if (entityInfo) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
newPrimaryKey
|
|
222
|
+
// Update primary key for new records
|
|
223
|
+
if (isNew) {
|
|
224
|
+
const newPrimaryKey = {};
|
|
225
|
+
for (const pk of entityInfo.PrimaryKeys) {
|
|
226
|
+
newPrimaryKey[pk.Name] = entity.Get(pk.Name);
|
|
227
|
+
}
|
|
228
|
+
recordData.primaryKey = newPrimaryKey;
|
|
207
229
|
}
|
|
208
|
-
|
|
209
|
-
// Update sync metadata
|
|
230
|
+
// Always update sync metadata when the record was updated - use original fields for checksum
|
|
210
231
|
recordData.sync = {
|
|
211
232
|
lastModified: new Date().toISOString(),
|
|
212
|
-
checksum: this.syncEngine.
|
|
233
|
+
checksum: await this.syncEngine.calculateChecksumWithFileContent(originalFields, path_1.default.dirname(filePath))
|
|
213
234
|
};
|
|
235
|
+
// Restore original field values to preserve @ references
|
|
236
|
+
recordData.fields = originalFields;
|
|
214
237
|
// Write back to file
|
|
215
238
|
await fs_extra_1.default.writeJson(filePath, recordData, { spaces: 2 });
|
|
216
239
|
}
|
|
@@ -237,6 +260,37 @@ class WatchService {
|
|
|
237
260
|
}
|
|
238
261
|
}
|
|
239
262
|
}
|
|
263
|
+
async setupSqlLogging(callbacks) {
|
|
264
|
+
try {
|
|
265
|
+
// Load sync config for SQL logging settings
|
|
266
|
+
const syncConfig = await (0, config_1.loadSyncConfig)(config_manager_1.configManager.getOriginalCwd());
|
|
267
|
+
if (syncConfig?.sqlLogging?.enabled) {
|
|
268
|
+
const provider = core_1.Metadata.Provider; // SQLServerDataProvider
|
|
269
|
+
if (provider && typeof provider.CreateSqlLogger === 'function') {
|
|
270
|
+
// Generate filename with timestamp
|
|
271
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
272
|
+
const filename = syncConfig.sqlLogging?.formatAsMigration
|
|
273
|
+
? `MetadataSync_Watch_${timestamp}.sql`
|
|
274
|
+
: `watch_${timestamp}.sql`;
|
|
275
|
+
// Use .sql-log-watch directory in the working directory
|
|
276
|
+
const outputDir = path_1.default.join(config_manager_1.configManager.getOriginalCwd(), '.sql-log-watch');
|
|
277
|
+
const filepath = path_1.default.join(outputDir, filename);
|
|
278
|
+
// Ensure the directory exists
|
|
279
|
+
await fs_extra_1.default.ensureDir(outputDir);
|
|
280
|
+
// Create the SQL logging session
|
|
281
|
+
this.sqlLoggingSession = await provider.CreateSqlLogger(filepath, {
|
|
282
|
+
formatAsMigration: syncConfig.sqlLogging?.formatAsMigration || false,
|
|
283
|
+
description: 'MetadataSync watch operation',
|
|
284
|
+
logRecordChangeMetadata: true
|
|
285
|
+
});
|
|
286
|
+
callbacks?.onLog?.(`š SQL logging enabled: ${filepath}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
callbacks?.onWarn?.(`Failed to setup SQL logging: ${error}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
240
294
|
}
|
|
241
295
|
exports.WatchService = WatchService;
|
|
242
296
|
//# sourceMappingURL=WatchService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WatchService.js","sourceRoot":"","sources":["../../src/services/WatchService.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,wDAAgC;AAGhC,sCAA6C;AAC7C,0DAA8D;AAyB9D,MAAa,YAAY;IACf,UAAU,CAAa;IACvB,cAAc,GAAgC,IAAI,GAAG,EAAE,CAAC;IAEhE,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,UAAwB,EAAE,EAAE,SAA0B;QAChE,MAAM,UAAU,GAAG,IAAA,sCAAqB,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAErE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,SAAS,EAAE,KAAK,EAAE,CAAC,YAAY,UAAU,CAAC,MAAM,WAAW,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,cAAc,CAAC,CAAC;QAEhI,kBAAkB;QAClB,MAAM,QAAQ,GAAyB,EAAE,CAAC;QAE1C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,MAAM,IAAA,yBAAgB,EAAC,SAAS,CAAC,CAAC;YACvD,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,SAAS,EAAE,MAAM,EAAE,CAAC,YAAY,SAAS,kCAAkC,CAAC,CAAC;gBAC7E,SAAS;YACX,CAAC;YAED,SAAS,EAAE,KAAK,EAAE,CAAC,YAA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,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YACtB,6BAA6B;YAC7B,MAAM,YAAY,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;YACxC,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3B,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;YAErE,IAAI,MAAM,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtC,yDAAyD;gBACzD,MAAM,UAAU,GAAe,MAAM,kBAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;gBAC/D,UAAU,CAAC,IAAI,GAAG;oBAChB,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;oBACtC,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE;iBAC1C,CAAC;gBACF,MAAM,kBAAE,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;gBAE5D,SAAS,EAAE,KAAK,EAAE,CAAC,6BAA6B,YAAY,8BAA8B,CAAC,CAAC;YAC9F,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3RD,oCA2RC","sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport chokidar from 'chokidar';\nimport { BaseEntity } from '@memberjunction/core';\nimport { SyncEngine, RecordData } from '../lib/sync-engine';\nimport { loadEntityConfig } from '../config';\nimport { findEntityDirectories } from '../lib/provider-utils';\n\nexport interface WatchOptions {\n dir?: string;\n debounceMs?: number;\n ignorePatterns?: string[];\n}\n\nexport interface WatchCallbacks {\n onFileAdd?: (filePath: string, entityDir: string, entityConfig: any) => void;\n onFileChange?: (filePath: string, entityDir: string, entityConfig: any) => void;\n onFileDelete?: (filePath: string, entityDir: string, entityConfig: any) => void;\n onLog?: (message: string) => void;\n onWarn?: (message: string) => void;\n onError?: (error: Error) => void;\n onRecordCreated?: (entity: BaseEntity, entityConfig: any) => void;\n onRecordUpdated?: (entity: BaseEntity, changes: any, entityConfig: any) => void;\n onRecordSaved?: (entity: BaseEntity, isNew: boolean, entityConfig: any) => void;\n}\n\nexport interface WatchResult {\n watchers: chokidar.FSWatcher[];\n stop: () => Promise<void>;\n}\n\nexport class WatchService {\n private syncEngine: SyncEngine;\n private debounceTimers: Map<string, NodeJS.Timeout> = new Map();\n \n constructor(syncEngine: SyncEngine) {\n this.syncEngine = syncEngine;\n }\n \n async watch(options: WatchOptions = {}, callbacks?: WatchCallbacks): Promise<WatchResult> {\n const entityDirs = findEntityDirectories(process.cwd(), options.dir);\n \n if (entityDirs.length === 0) {\n throw new Error('No entity directories found');\n }\n \n callbacks?.onLog?.(`Watching ${entityDirs.length} entity ${entityDirs.length === 1 ? 'directory' : 'directories'} for changes`);\n \n // Set up watchers\n const watchers: chokidar.FSWatcher[] = [];\n \n for (const entityDir of entityDirs) {\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n callbacks?.onWarn?.(`Skipping ${entityDir} - no valid entity configuration`);\n continue;\n }\n \n callbacks?.onLog?.(`Watching ${entityConfig.entity} in ${entityDir}`);\n \n // Watch for JSON files and external files\n const patterns = [\n path.join(entityDir, entityConfig.filePattern || '**/*.json'),\n path.join(entityDir, '**/*.md'),\n path.join(entityDir, '**/*.txt'),\n path.join(entityDir, '**/*.html'),\n path.join(entityDir, '**/*.liquid'),\n path.join(entityDir, '**/*.sql')\n ];\n \n const ignored = [\n '**/node_modules/**',\n '**/.git/**',\n '**/.mj-sync.json',\n '**/.mj-folder.json',\n '**/*.backup',\n ...(options.ignorePatterns || [])\n ];\n \n const watcher = chokidar.watch(patterns, {\n ignored,\n persistent: true,\n ignoreInitial: true\n });\n \n watcher\n .on('add', (filePath) => {\n callbacks?.onFileAdd?.(filePath, entityDir, entityConfig);\n this.handleFileChange(filePath, 'added', entityDir, entityConfig, options, callbacks);\n })\n .on('change', (filePath) => {\n callbacks?.onFileChange?.(filePath, entityDir, entityConfig);\n this.handleFileChange(filePath, 'changed', entityDir, entityConfig, options, callbacks);\n })\n .on('unlink', (filePath) => {\n callbacks?.onFileDelete?.(filePath, entityDir, entityConfig);\n this.handleFileChange(filePath, 'deleted', entityDir, entityConfig, options, callbacks);\n });\n \n watchers.push(watcher);\n }\n \n return {\n watchers,\n stop: async () => {\n // Clear all debounce timers\n for (const timer of this.debounceTimers.values()) {\n clearTimeout(timer);\n }\n this.debounceTimers.clear();\n \n // Close all watchers\n await Promise.all(watchers.map(w => w.close()));\n }\n };\n }\n \n private handleFileChange(\n filePath: string,\n event: string,\n entityDir: string,\n entityConfig: any,\n options: WatchOptions,\n callbacks?: WatchCallbacks\n ): void {\n // Clear existing debounce timer\n const existingTimer = this.debounceTimers.get(filePath);\n if (existingTimer) {\n clearTimeout(existingTimer);\n }\n \n // Set new debounce timer\n const debounceMs = options.debounceMs || 1000;\n const timer = setTimeout(async () => {\n this.debounceTimers.delete(filePath);\n \n try {\n const relativePath = path.relative(entityDir, filePath);\n callbacks?.onLog?.(`File ${event}: ${relativePath}`);\n \n if (event === 'deleted') {\n // Handle deletion\n callbacks?.onLog?.('File deletion detected - manual database cleanup may be required');\n } else if (filePath.endsWith('.json')) {\n // Handle JSON file change\n await this.syncJsonFile(filePath, entityDir, entityConfig, callbacks);\n } else {\n // Handle external file change\n await this.syncExternalFile(filePath, entityDir, entityConfig, callbacks);\n }\n } catch (error) {\n const errorMessage = `Failed to sync ${filePath}: ${(error as any).message || error}`;\n callbacks?.onWarn?.(errorMessage);\n if (error instanceof Error) {\n callbacks?.onError?.(error);\n }\n }\n }, debounceMs);\n \n this.debounceTimers.set(filePath, timer);\n }\n \n private async syncJsonFile(\n filePath: string,\n entityDir: string,\n entityConfig: any,\n callbacks?: WatchCallbacks\n ): Promise<void> {\n const recordData: RecordData = await fs.readJson(filePath);\n \n // Build defaults\n const defaults = await this.syncEngine.buildDefaults(filePath, entityConfig);\n \n // Load or create entity\n let entity: BaseEntity | null = null;\n let isNew = false;\n \n if (recordData.primaryKey) {\n entity = await this.syncEngine.loadEntity(entityConfig.entity, recordData.primaryKey);\n }\n \n if (!entity) {\n // New record\n entity = await this.syncEngine.createEntityObject(entityConfig.entity);\n entity.NewRecord();\n isNew = true;\n }\n \n // Apply defaults first\n for (const [field, value] of Object.entries(defaults)) {\n if (field in entity) {\n (entity as any)[field] = value;\n }\n }\n \n // Apply record fields\n for (const [field, value] of Object.entries(recordData.fields)) {\n if (field in entity) {\n const processedValue = await this.syncEngine.processFieldValue(value, path.dirname(filePath));\n (entity as any)[field] = processedValue;\n }\n }\n \n // Check if the record is dirty before saving\n let wasActuallyUpdated = false;\n let changes: any = null;\n \n if (!isNew && entity.Dirty) {\n // Record is dirty, get the changes\n changes = (entity as any).GetChangesSinceLastSave();\n const changeKeys = Object.keys(changes);\n if (changeKeys.length > 0) {\n wasActuallyUpdated = true;\n \n // Get primary key info for display\n const entityInfo = this.syncEngine.getEntityInfo(entityConfig.entity);\n const primaryKeyDisplay: string[] = [];\n if (entityInfo) {\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKeyDisplay.push(`${pk.Name}: ${entity.Get(pk.Name)}`);\n }\n }\n \n callbacks?.onLog?.(`š Updating ${entityConfig.entity} record:`);\n if (primaryKeyDisplay.length > 0) {\n callbacks?.onLog?.(` Primary Key: ${primaryKeyDisplay.join(', ')}`);\n }\n callbacks?.onLog?.(` Changes:`);\n for (const fieldName of changeKeys) {\n const field = entity.GetFieldByName(fieldName);\n const oldValue = field ? field.OldValue : undefined;\n const newValue = (changes as any)[fieldName];\n callbacks?.onLog?.(` ${fieldName}: ${oldValue} ā ${newValue}`);\n }\n \n callbacks?.onRecordUpdated?.(entity, changes, entityConfig);\n }\n } else if (isNew) {\n wasActuallyUpdated = true;\n callbacks?.onRecordCreated?.(entity, entityConfig);\n }\n \n // Save the record\n const saved = await entity.Save();\n if (!saved) {\n const message = entity.LatestResult?.Message;\n if (message) {\n throw new Error(`Failed to save record: ${message}`);\n }\n \n const errors = entity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || 'Unknown error';\n throw new Error(`Failed to save record: ${errors}`);\n }\n \n if (wasActuallyUpdated) {\n callbacks?.onLog?.(`Successfully ${isNew ? 'created' : 'updated'} ${entityConfig.entity} record`);\n callbacks?.onRecordSaved?.(entity, isNew, entityConfig);\n } else {\n callbacks?.onLog?.(`No changes detected for ${entityConfig.entity} record - skipped update`);\n }\n \n // Update the local file with new primary key if created\n if (isNew) {\n const entityInfo = this.syncEngine.getEntityInfo(entityConfig.entity);\n if (entityInfo) {\n const newPrimaryKey: Record<string, any> = {};\n for (const pk of entityInfo.PrimaryKeys) {\n newPrimaryKey[pk.Name] = entity.Get(pk.Name);\n }\n recordData.primaryKey = newPrimaryKey;\n \n // Update sync metadata\n recordData.sync = {\n lastModified: new Date().toISOString(),\n checksum: this.syncEngine.calculateChecksum(recordData.fields)\n };\n \n // Write back to file\n await fs.writeJson(filePath, recordData, { spaces: 2 });\n }\n }\n }\n \n private async syncExternalFile(\n filePath: string,\n entityDir: string,\n entityConfig: any,\n callbacks?: WatchCallbacks\n ): Promise<void> {\n // Find the corresponding JSON file\n const fileName = path.basename(filePath);\n const parts = fileName.split('.');\n \n if (parts.length >= 3) {\n // Format: uuid.fieldname.ext\n const jsonFileName = `${parts[0]}.json`;\n const fieldName = parts[1];\n const jsonFilePath = path.join(path.dirname(filePath), jsonFileName);\n \n if (await fs.pathExists(jsonFilePath)) {\n // Update the JSON file's sync metadata to trigger a sync\n const recordData: RecordData = await fs.readJson(jsonFilePath);\n recordData.sync = {\n lastModified: new Date().toISOString(),\n checksum: recordData.sync?.checksum || ''\n };\n await fs.writeJson(jsonFilePath, recordData, { spaces: 2 });\n \n callbacks?.onLog?.(`Updated sync metadata for ${jsonFileName} due to external file change`);\n }\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"WatchService.js","sourceRoot":"","sources":["../../src/services/WatchService.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,wDAAgC;AAChC,+CAA4D;AAE5D,sCAA6D;AAC7D,0DAA8D;AAC9D,0DAAsD;AA0BtD,MAAa,YAAY;IACf,UAAU,CAAa;IACvB,cAAc,GAAgC,IAAI,GAAG,EAAE,CAAC;IACxD,iBAAiB,GAA6B,IAAI,CAAC;IAE3D,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,UAAwB,EAAE,EAAE,SAA0B;QAChE,MAAM,UAAU,GAAG,IAAA,sCAAqB,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAErE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,SAAS,EAAE,KAAK,EAAE,CAAC,YAAY,UAAU,CAAC,MAAM,WAAW,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,cAAc,CAAC,CAAC;QAEhI,4BAA4B;QAC5B,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAEtC,kBAAkB;QAClB,MAAM,QAAQ,GAAyB,EAAE,CAAC;QAE1C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,YAAY,GAAG,MAAM,IAAA,yBAAgB,EAAC,SAAS,CAAC,CAAC;YACvD,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,SAAS,EAAE,MAAM,EAAE,CAAC,YAAY,SAAS,kCAAkC,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AEhD,8BAA8B;oBAC9B,MAAM,kBAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;oBAE9B,iCAAiC;oBACjC,IAAI,CAAC,iBAAiB,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE;wBAChE,iBAAiB,EAAE,UAAU,CAAC,UAAU,EAAE,iBAAiB,IAAI,KAAK;wBACpE,WAAW,EAAE,8BAA8B;wBAC3C,uBAAuB,EAAE,IAAI;qBAC9B,CAAC,CAAC;oBAEH,SAAS,EAAE,KAAK,EAAE,CAAC,2BAA2B,QAAQ,EAAE,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,EAAE,MAAM,EAAE,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF;AAxVD,oCAwVC","sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport chokidar from 'chokidar';\nimport { BaseEntity, Metadata } from '@memberjunction/core';\nimport { SyncEngine, RecordData } from '../lib/sync-engine';\nimport { loadEntityConfig, loadSyncConfig } from '../config';\nimport { findEntityDirectories } from '../lib/provider-utils';\nimport { configManager } from '../lib/config-manager';\nimport type { SqlLoggingSession } from '@memberjunction/sqlserver-dataprovider';\n\nexport interface WatchOptions {\n dir?: string;\n debounceMs?: number;\n ignorePatterns?: string[];\n}\n\nexport interface WatchCallbacks {\n onFileAdd?: (filePath: string, entityDir: string, entityConfig: any) => void;\n onFileChange?: (filePath: string, entityDir: string, entityConfig: any) => void;\n onFileDelete?: (filePath: string, entityDir: string, entityConfig: any) => void;\n onLog?: (message: string) => void;\n onWarn?: (message: string) => void;\n onError?: (error: Error) => void;\n onRecordCreated?: (entity: BaseEntity, entityConfig: any) => void;\n onRecordUpdated?: (entity: BaseEntity, changes: any, entityConfig: any) => void;\n onRecordSaved?: (entity: BaseEntity, isNew: boolean, entityConfig: any) => void;\n}\n\nexport interface WatchResult {\n watchers: chokidar.FSWatcher[];\n stop: () => Promise<void>;\n}\n\nexport class WatchService {\n private syncEngine: SyncEngine;\n private debounceTimers: Map<string, NodeJS.Timeout> = new Map();\n private sqlLoggingSession: SqlLoggingSession | null = null;\n \n constructor(syncEngine: SyncEngine) {\n this.syncEngine = syncEngine;\n }\n \n async watch(options: WatchOptions = {}, callbacks?: WatchCallbacks): Promise<WatchResult> {\n const entityDirs = findEntityDirectories(process.cwd(), options.dir);\n \n if (entityDirs.length === 0) {\n throw new Error('No entity directories found');\n }\n \n callbacks?.onLog?.(`Watching ${entityDirs.length} entity ${entityDirs.length === 1 ? 'directory' : 'directories'} for changes`);\n \n // Setup SQL logging session\n await this.setupSqlLogging(callbacks);\n \n // Set up watchers\n const watchers: chokidar.FSWatcher[] = [];\n \n for (const entityDir of entityDirs) {\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n callbacks?.onWarn?.(`Skipping ${entityDir} - no valid entity configuration`);\n continue;\n }\n \n callbacks?.onLog?.(`Watching ${entityConfig.entity} in ${entityDir}`);\n \n // Watch for JSON files and external files\n const patterns = [\n path.join(entityDir, entityConfig.filePattern || '**/*.json'),\n path.join(entityDir, '**/*.md'),\n path.join(entityDir, '**/*.txt'),\n path.join(entityDir, '**/*.html'),\n path.join(entityDir, '**/*.liquid'),\n path.join(entityDir, '**/*.sql')\n ];\n \n const ignored = [\n '**/node_modules/**',\n '**/.git/**',\n '**/.mj-sync.json',\n '**/.mj-folder.json',\n '**/*.backup',\n ...(options.ignorePatterns || [])\n ];\n \n const watcher = chokidar.watch(patterns, {\n ignored,\n persistent: true,\n ignoreInitial: true\n });\n \n watcher\n .on('add', (filePath) => {\n callbacks?.onFileAdd?.(filePath, entityDir, entityConfig);\n this.handleFileChange(filePath, 'added', entityDir, entityConfig, options, callbacks);\n })\n .on('change', (filePath) => {\n callbacks?.onFileChange?.(filePath, entityDir, entityConfig);\n this.handleFileChange(filePath, 'changed', entityDir, entityConfig, options, callbacks);\n })\n .on('unlink', (filePath) => {\n callbacks?.onFileDelete?.(filePath, entityDir, entityConfig);\n this.handleFileChange(filePath, 'deleted', entityDir, entityConfig, options, callbacks);\n });\n \n watchers.push(watcher);\n }\n \n return {\n watchers,\n stop: async () => {\n // Clear all debounce timers\n for (const timer of this.debounceTimers.values()) {\n clearTimeout(timer);\n }\n this.debounceTimers.clear();\n \n // Close all watchers\n await Promise.all(watchers.map(w => w.close()));\n \n // Dispose SQL logging session\n if (this.sqlLoggingSession) {\n try {\n callbacks?.onLog?.(`š SQL log written to: ${this.sqlLoggingSession.filePath}`);\n await this.sqlLoggingSession.dispose();\n this.sqlLoggingSession = null;\n } catch (error) {\n callbacks?.onWarn?.(`Failed to close SQL logging session: ${error}`);\n }\n }\n }\n };\n }\n \n private handleFileChange(\n filePath: string,\n event: string,\n entityDir: string,\n entityConfig: any,\n options: WatchOptions,\n callbacks?: WatchCallbacks\n ): void {\n // Clear existing debounce timer\n const existingTimer = this.debounceTimers.get(filePath);\n if (existingTimer) {\n clearTimeout(existingTimer);\n }\n \n // Set new debounce timer\n const debounceMs = options.debounceMs || 1000;\n const timer = setTimeout(async () => {\n this.debounceTimers.delete(filePath);\n \n try {\n const relativePath = path.relative(entityDir, filePath);\n callbacks?.onLog?.(`File ${event}: ${relativePath}`);\n \n if (event === 'deleted') {\n // Handle deletion\n callbacks?.onLog?.('File deletion detected - manual database cleanup may be required');\n } else if (filePath.endsWith('.json')) {\n // Handle JSON file change\n await this.syncJsonFile(filePath, entityDir, entityConfig, callbacks);\n } else {\n // Handle external file change\n await this.syncExternalFile(filePath, entityDir, entityConfig, callbacks);\n }\n } catch (error) {\n const errorMessage = `Failed to sync ${filePath}: ${(error as any).message || error}`;\n callbacks?.onWarn?.(errorMessage);\n if (error instanceof Error) {\n callbacks?.onError?.(error);\n }\n }\n }, debounceMs);\n \n this.debounceTimers.set(filePath, timer);\n }\n \n private async syncJsonFile(\n filePath: string,\n entityDir: string,\n entityConfig: any,\n callbacks?: WatchCallbacks\n ): Promise<void> {\n const recordData: RecordData = await fs.readJson(filePath);\n \n // Keep original fields for file writing\n const originalFields = { ...recordData.fields };\n \n // Build defaults\n const defaults = await this.syncEngine.buildDefaults(filePath, entityConfig);\n \n // Load or create entity\n let entity: BaseEntity | null = null;\n let isNew = false;\n \n if (recordData.primaryKey) {\n entity = await this.syncEngine.loadEntity(entityConfig.entity, recordData.primaryKey);\n }\n \n if (!entity) {\n // New record\n entity = await this.syncEngine.createEntityObject(entityConfig.entity);\n entity.NewRecord();\n isNew = true;\n }\n \n // Apply defaults first\n for (const [field, value] of Object.entries(defaults)) {\n if (field in entity) {\n (entity as any)[field] = value;\n }\n }\n \n // Apply record fields with processed values for database operations\n for (const [field, value] of Object.entries(recordData.fields)) {\n if (field in entity) {\n const processedValue = await this.syncEngine.processFieldValue(value, path.dirname(filePath));\n (entity as any)[field] = processedValue;\n }\n }\n \n // Check if the record is dirty before saving\n let wasActuallyUpdated = false;\n let changes: any = null;\n \n if (!isNew && entity.Dirty) {\n // Record is dirty, get the changes\n changes = entity.GetChangesSinceLastSave();\n const changeKeys = Object.keys(changes);\n if (changeKeys.length > 0) {\n wasActuallyUpdated = true;\n \n // Get primary key info for display\n const entityInfo = this.syncEngine.getEntityInfo(entityConfig.entity);\n const primaryKeyDisplay: string[] = [];\n if (entityInfo) {\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKeyDisplay.push(`${pk.Name}: ${entity.Get(pk.Name)}`);\n }\n }\n \n callbacks?.onLog?.(`š Updating ${entityConfig.entity} record:`);\n if (primaryKeyDisplay.length > 0) {\n callbacks?.onLog?.(` Primary Key: ${primaryKeyDisplay.join(', ')}`);\n }\n callbacks?.onLog?.(` Changes:`);\n for (const fieldName of changeKeys) {\n const field = entity.GetFieldByName(fieldName);\n const oldValue = field ? field.OldValue : undefined;\n const newValue = (changes as any)[fieldName];\n callbacks?.onLog?.(` ${fieldName}: ${oldValue} ā ${newValue}`);\n }\n \n callbacks?.onRecordUpdated?.(entity, changes, entityConfig);\n }\n } else if (isNew) {\n wasActuallyUpdated = true;\n callbacks?.onRecordCreated?.(entity, entityConfig);\n }\n \n // Save the record\n const saved = await entity.Save();\n if (!saved) {\n const message = entity.LatestResult?.Message;\n if (message) {\n throw new Error(`Failed to save record: ${message}`);\n }\n \n const errors = entity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || 'Unknown error';\n throw new Error(`Failed to save record: ${errors}`);\n }\n \n if (wasActuallyUpdated) {\n callbacks?.onLog?.(`Successfully ${isNew ? 'created' : 'updated'} ${entityConfig.entity} record`);\n callbacks?.onRecordSaved?.(entity, isNew, entityConfig);\n } else {\n callbacks?.onLog?.(`No changes detected for ${entityConfig.entity} record - skipped update`);\n }\n \n // Update the local file with primary key and sync metadata\n if (wasActuallyUpdated) {\n const entityInfo = this.syncEngine.getEntityInfo(entityConfig.entity);\n if (entityInfo) {\n // Update primary key for new records\n if (isNew) {\n const newPrimaryKey: Record<string, any> = {};\n for (const pk of entityInfo.PrimaryKeys) {\n newPrimaryKey[pk.Name] = entity.Get(pk.Name);\n }\n recordData.primaryKey = newPrimaryKey;\n }\n \n // Always update sync metadata when the record was updated - use original fields for checksum\n recordData.sync = {\n lastModified: new Date().toISOString(),\n checksum: await this.syncEngine.calculateChecksumWithFileContent(originalFields, path.dirname(filePath))\n };\n \n // Restore original field values to preserve @ references\n recordData.fields = originalFields;\n \n // Write back to file\n await fs.writeJson(filePath, recordData, { spaces: 2 });\n }\n }\n }\n \n private async syncExternalFile(\n filePath: string,\n entityDir: string,\n entityConfig: any,\n callbacks?: WatchCallbacks\n ): Promise<void> {\n // Find the corresponding JSON file\n const fileName = path.basename(filePath);\n const parts = fileName.split('.');\n \n if (parts.length >= 3) {\n // Format: uuid.fieldname.ext\n const jsonFileName = `${parts[0]}.json`;\n const fieldName = parts[1];\n const jsonFilePath = path.join(path.dirname(filePath), jsonFileName);\n \n if (await fs.pathExists(jsonFilePath)) {\n // Update the JSON file's sync metadata to trigger a sync\n const recordData: RecordData = await fs.readJson(jsonFilePath);\n recordData.sync = {\n lastModified: new Date().toISOString(),\n checksum: recordData.sync?.checksum || ''\n };\n await fs.writeJson(jsonFilePath, recordData, { spaces: 2 });\n \n callbacks?.onLog?.(`Updated sync metadata for ${jsonFileName} due to external file change`);\n }\n }\n }\n \n private async setupSqlLogging(callbacks?: WatchCallbacks): Promise<void> {\n try {\n // Load sync config for SQL logging settings\n const syncConfig = await loadSyncConfig(configManager.getOriginalCwd());\n \n if (syncConfig?.sqlLogging?.enabled) {\n const provider = Metadata.Provider as any; // SQLServerDataProvider\n \n if (provider && typeof provider.CreateSqlLogger === 'function') {\n // Generate filename with timestamp\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n const filename = syncConfig.sqlLogging?.formatAsMigration \n ? `MetadataSync_Watch_${timestamp}.sql`\n : `watch_${timestamp}.sql`;\n \n // Use .sql-log-watch directory in the working directory\n const outputDir = path.join(configManager.getOriginalCwd(), '.sql-log-watch');\n const filepath = path.join(outputDir, filename);\n \n // Ensure the directory exists\n await fs.ensureDir(outputDir);\n \n // Create the SQL logging session\n this.sqlLoggingSession = await provider.CreateSqlLogger(filepath, {\n formatAsMigration: syncConfig.sqlLogging?.formatAsMigration || false,\n description: 'MetadataSync watch operation',\n logRecordChangeMetadata: true\n });\n \n callbacks?.onLog?.(`š SQL logging enabled: ${filepath}`);\n }\n }\n } catch (error) {\n callbacks?.onWarn?.(`Failed to setup SQL logging: ${error}`);\n }\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/metadata-sync",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.57.0",
|
|
4
4
|
"description": "MemberJunction metadata synchronization CLI tool",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"metadata",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"build": "tsc -b"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@memberjunction/core": "2.
|
|
30
|
-
"@memberjunction/core-entities": "2.
|
|
31
|
-
"@memberjunction/core-entities-server": "2.
|
|
32
|
-
"@memberjunction/global": "2.
|
|
33
|
-
"@memberjunction/sqlserver-dataprovider": "2.
|
|
34
|
-
"@memberjunction/graphql-dataprovider": "2.
|
|
29
|
+
"@memberjunction/core": "2.57.0",
|
|
30
|
+
"@memberjunction/core-entities": "2.57.0",
|
|
31
|
+
"@memberjunction/core-entities-server": "2.57.0",
|
|
32
|
+
"@memberjunction/global": "2.57.0",
|
|
33
|
+
"@memberjunction/sqlserver-dataprovider": "2.57.0",
|
|
34
|
+
"@memberjunction/graphql-dataprovider": "2.57.0",
|
|
35
35
|
"chokidar": "^3.6.0",
|
|
36
36
|
"cosmiconfig": "9.0.0",
|
|
37
37
|
"dotenv": "16.4.5",
|