@memberjunction/metadata-sync 2.121.0 ā 2.122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/json-preprocessor.js +4 -2
- package/dist/lib/json-preprocessor.js.map +1 -1
- package/dist/lib/sync-engine.d.ts +40 -4
- package/dist/lib/sync-engine.js +70 -16
- package/dist/lib/sync-engine.js.map +1 -1
- package/dist/services/FormattingService.d.ts +1 -0
- package/dist/services/FormattingService.js +3 -0
- package/dist/services/FormattingService.js.map +1 -1
- package/dist/services/PushService.d.ts +17 -0
- package/dist/services/PushService.js +162 -18
- package/dist/services/PushService.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,+CAAyF;AAEzF,sCAA6D;AAC7D,oEAA+D;AAC/D,0DAAsD;AACtD,kDAA8C;AAC9C,oEAAgE;AAChE,gEAA2D;AAC3D,kFAA8F;AAC9F,gEAA4D;AAC5D,0DAA8D;AAC9D,8DAAyE;AACzE,gFAA2E;AAG3E,wCAAwC;AACxC,MAAM,mBAAmB,GAAG,CAAC,CAAC,CAAC,oEAAoE;AAmDnG,MAAa,WAAW;IACd,UAAU,CAAa;IACvB,WAAW,CAAW;IACtB,QAAQ,GAAa,EAAE,CAAC;IACxB,UAAU,CAAM;IAChB,kBAAkB,GAAmC,IAAI,GAAG,EAAE,CAAC;IAEvE,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,S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MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC/D,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,oDAAoD;YACpD,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC1D,KAAK,MAAM,KAAK,IAAI,iBAAiB,EAAE,CAAC;gBACtC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF;AAl/CD,kCAk/CC","sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport fastGlob from 'fast-glob';\nimport { BaseEntity, Metadata, UserInfo, EntitySaveOptions } 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 { JsonWriteHelper } from '../lib/json-write-helper';\nimport { RecordDependencyAnalyzer, FlattenedRecord } from '../lib/record-dependency-analyzer';\nimport { JsonPreprocessor } from '../lib/json-preprocessor';\nimport { findEntityDirectories } from '../lib/provider-utils';\nimport { DeletionAuditor, DeletionAudit } from '../lib/deletion-auditor';\nimport { DeletionReportGenerator } from '../lib/deletion-report-generator';\nimport type { SqlLoggingSession, SQLServerDataProvider } from '@memberjunction/sqlserver-dataprovider';\n\n// Configuration for parallel processing\nconst PARALLEL_BATCH_SIZE = 1; // Number of records to process in parallel at each dependency level\n/// TEMPORARILY DISABLED PARALLEL BY SETTING TO 1 as we were having some issues\n\nexport interface PushOptions {\n dir?: string;\n dryRun?: boolean;\n verbose?: boolean;\n noValidate?: boolean;\n parallelBatchSize?: number; // Number of records to process in parallel (default: 10)\n include?: string[]; // Only process these directories (whitelist, supports patterns)\n exclude?: string[]; // Skip these directories (blacklist, supports patterns)\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 deleted: number;\n skipped: 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 deleted: number;\n skipped: number;\n errors: number;\n}\n\n/**\n * Tracks files that need to be written back after deletions complete\n */\ninterface DeferredFileWrite {\n filePath: string;\n records: RecordData[];\n isArray: boolean;\n}\n\nexport class PushService {\n private syncEngine: SyncEngine;\n private contextUser: UserInfo;\n private warnings: string[] = [];\n private syncConfig: any;\n private deferredFileWrites: Map<string, DeferredFileWrite> = new Map();\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\n // Validate that include and exclude are not used together\n if (options.include && options.exclude) {\n throw new Error('Cannot specify both --include and --exclude options. Please use one or the other.');\n }\n\n this.deferredFileWrites.clear(); // Reset deferred writes for this push operation\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 // Display warnings for special flags that are enabled\n if (this.syncConfig?.push?.alwaysPush && !options.dryRun) {\n callbacks?.onWarn?.('\\nā” WARNING: alwaysPush is enabled - ALL records will be saved to database regardless of changes\\n');\n }\n if (this.syncConfig?.push?.autoCreateMissingRecords && !options.dryRun) {\n callbacks?.onWarn?.('\\nš§ WARNING: autoCreateMissingRecords is enabled - Missing records with primaryKey will be created\\n');\n }\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 filterPatterns: this.syncConfig.sqlLogging?.filterPatterns,\n filterType: this.syncConfig.sqlLogging?.filterType,\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 // Note: If options.dir is specified, configDir already points to that directory\n // So we don't need to pass it as specificDir\n const entityDirs = findEntityDirectories(\n configDir,\n undefined,\n this.syncConfig?.directoryOrder,\n this.syncConfig?.ignoreDirectories,\n options.include,\n options.exclude\n );\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 totalDeleted = 0;\n let totalSkipped = 0;\n let totalErrors = 0;\n \n // PHASE 0: Audit all deletions across all entities (if any exist)\n let deletionAudit: DeletionAudit | null = null;\n try {\n deletionAudit = await this.auditAllDeletions(entityDirs, options, callbacks);\n } catch (auditError) {\n // Audit failed, cannot proceed\n throw auditError;\n }\n\n // CONFIRMATION PROMPT: Ask user to confirm only if deletions will occur\n if (!options.dryRun && deletionAudit) {\n const shouldProceed = await this.promptForConfirmation(deletionAudit, callbacks);\n if (!shouldProceed) {\n callbacks?.onLog?.('\\nā Push operation cancelled by user.\\n');\n\n // Clean up SQL logging session and file if it was created\n if (sqlLoggingSession) {\n const sqlLogPath = sqlLoggingSession.filePath;\n try {\n await sqlLoggingSession.dispose();\n // Delete the empty SQL log file since no operations occurred\n if (await fs.pathExists(sqlLogPath)) {\n await fs.remove(sqlLogPath);\n if (options.verbose) {\n callbacks?.onLog?.(`šļø Removed empty SQL log file: ${sqlLogPath}`);\n }\n }\n } catch (cleanupError) {\n callbacks?.onWarn?.(`Failed to clean up SQL logging session: ${cleanupError}`);\n }\n }\n\n return {\n created: 0,\n updated: 0,\n unchanged: 0,\n deleted: 0,\n skipped: 0,\n errors: 0,\n warnings: this.warnings\n };\n }\n }\n\n // Begin transaction if not in dry-run mode\n if (!options.dryRun) {\n await transactionManager.beginTransaction();\n }\n\n try {\n // PHASE 1: Process creates/updates for all entities\n callbacks?.onLog?.('š Processing creates and updates...\\n');\n\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 totalSkipped++; // Count skipped directories\n continue;\n }\n\n // Show folder with spinner at start\n const dirName = path.relative(process.cwd(), entityDir) || '.';\n callbacks?.onLog?.(`\\nš ${dirName}:`);\n\n // Use onProgress for animated spinner if available\n if (callbacks?.onProgress) {\n callbacks.onProgress(`Processing ${dirName}...`);\n } else {\n callbacks?.onLog?.(` ā³ Processing...`);\n }\n \n if (options.verbose && callbacks?.onLog) {\n callbacks.onLog(`Processing ${entityConfig.entity} in ${entityDir}`);\n }\n \n const result = await this.processEntityDirectory(\n entityDir,\n entityConfig,\n options,\n fileBackupManager,\n callbacks\n );\n \n // Stop the spinner if we were using onProgress\n if (callbacks?.onProgress && callbacks?.onSuccess) {\n callbacks.onSuccess(`Processed ${dirName}`);\n }\n \n // Show per-directory summary\n const dirTotal = result.created + result.updated + result.unchanged + result.deleted + result.skipped;\n if (dirTotal > 0 || result.errors > 0) {\n callbacks?.onLog?.(` Total processed: ${dirTotal} 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.deleted > 0) {\n callbacks?.onLog?.(` ā Deleted: ${result.deleted}`);\n }\n if (result.unchanged > 0) {\n callbacks?.onLog?.(` - Unchanged: ${result.unchanged}`);\n }\n if (result.skipped > 0) {\n callbacks?.onLog?.(` - Skipped: ${result.skipped}`);\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 totalDeleted += result.deleted;\n totalSkipped += result.skipped;\n totalErrors += result.errors;\n }\n\n // PHASE 2: Process deletions in reverse dependency order (if any exist)\n if (deletionAudit && totalErrors === 0) {\n const deletionResult = await this.processDeletionsFromAudit(deletionAudit, options, callbacks);\n totalDeleted += deletionResult.deleted;\n totalErrors += deletionResult.errors;\n }\n\n // Commit transaction if successful\n if (!options.dryRun && totalErrors === 0) {\n await transactionManager.commitTransaction();\n }\n\n // PHASE 3: Write deferred files with updated deletion timestamps\n if (!options.dryRun && totalErrors === 0 && this.deferredFileWrites.size > 0) {\n await this.writeDeferredFiles(options, callbacks);\n }\n } catch (error) {\n // Rollback transaction on error\n if (!options.dryRun) {\n callbacks?.onLog?.('\\nā ļø Rolling back database transaction due to error...');\n await transactionManager.rollbackTransaction();\n callbacks?.onLog?.('ā Database transaction rolled back successfully\\n');\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 deleted: totalDeleted,\n skipped: totalSkipped,\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 ): Promise<EntityPushResult> {\n let created = 0;\n let updated = 0;\n let unchanged = 0;\n let deleted = 0;\n let skipped = 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 // Read the raw file data first\n const rawFileData = await fs.readJson(filePath);\n \n // Only preprocess if there are @include directives\n let fileData = rawFileData;\n const jsonString = JSON.stringify(rawFileData);\n const hasIncludes = jsonString.includes('\"@include\"') || jsonString.includes('\"@include.');\n \n if (hasIncludes) {\n // Preprocess the JSON file to handle @include directives\n // Create a new preprocessor instance for each file to ensure clean state\n const jsonPreprocessor = new JsonPreprocessor();\n fileData = await jsonPreprocessor.processFile(filePath);\n }\n \n const records = Array.isArray(fileData) ? fileData : [fileData];\n const isArray = Array.isArray(fileData);\n \n // Analyze dependencies and get sorted records\n const analyzer = new RecordDependencyAnalyzer();\n const analysisResult = await analyzer.analyzeFileRecords(records, entityConfig.entity);\n \n if (analysisResult.circularDependencies.length > 0) {\n callbacks?.onWarn?.(`ā ļø Circular dependencies detected in ${filePath}`);\n for (const cycle of analysisResult.circularDependencies) {\n callbacks?.onWarn?.(` Cycle: ${cycle.join(' ā ')}`);\n }\n }\n \n if (options.verbose) {\n callbacks?.onLog?.(` Analyzed ${analysisResult.sortedRecords.length} records (including nested)`);\n }\n \n // Create batch context for in-memory entity resolution\n // Note: While JavaScript is single-threaded, async operations can interleave.\n // Map operations themselves are atomic, but we ensure records are added to\n // the context AFTER successful save to maintain consistency.\n const batchContext = new Map<string, BaseEntity>();\n \n // Process records using dependency levels for parallel processing\n if (analysisResult.dependencyLevels && analysisResult.dependencyLevels.length > 0) {\n // Use parallel processing with dependency levels\n for (let levelIndex = 0; levelIndex < analysisResult.dependencyLevels.length; levelIndex++) {\n const level = analysisResult.dependencyLevels[levelIndex];\n \n if (options.verbose && level.length > 1) {\n callbacks?.onLog?.(` Processing dependency level ${levelIndex} with ${level.length} records in parallel...`);\n }\n \n // Process records in this level in parallel batches\n const batchSize = options.parallelBatchSize || PARALLEL_BATCH_SIZE;\n for (let i = 0; i < level.length; i += batchSize) {\n const batch = level.slice(i, Math.min(i + batchSize, level.length));\n \n // Process batch in parallel\n const batchResults = await Promise.all(\n batch.map(async (flattenedRecord) => {\n try {\n const result = await this.processFlattenedRecord(\n flattenedRecord,\n entityDir,\n options,\n batchContext,\n callbacks,\n entityConfig\n );\n return { success: true, result };\n } catch (error) {\n // Return error instead of throwing to handle after Promise.all\n return { success: false, error, record: flattenedRecord };\n }\n })\n );\n \n // Process results and check for errors\n for (const batchResult of batchResults) {\n if (!batchResult.success) {\n // Fail fast on first error with detailed logging\n const err = batchResult.error as Error;\n const rec = batchResult.record as FlattenedRecord;\n\n // Log concise summary - detailed error was already logged by processFlattenedRecord\n callbacks?.onLog?.(`\\nā Processing failed for ${rec.entityName} at ${rec.path}`);\n callbacks?.onLog?.(` ${err.message}\\n`);\n\n // Throw concise error to trigger rollback\n throw err;\n }\n \n // Update stats for successful results\n const result = batchResult.result!;\n // Don't count deletion records - they're counted in Phase 2\n if (result.isDeletedRecord) {\n continue; // Skip entirely\n } else if (result.isDuplicate) {\n skipped++; // Count duplicates as skipped\n } else {\n if (result.status === 'created') created++;\n else if (result.status === 'updated') updated++;\n else if (result.status === 'unchanged') unchanged++;\n else if (result.status === 'deleted') deleted++;\n else if (result.status === 'skipped') skipped++;\n else if (result.status === 'error') errors++;\n }\n }\n }\n }\n } else {\n // Fallback to sequential processing if no dependency levels available\n for (const flattenedRecord of analysisResult.sortedRecords) {\n try {\n const result = await this.processFlattenedRecord(\n flattenedRecord,\n entityDir,\n options,\n batchContext,\n callbacks,\n entityConfig\n );\n \n // Update stats\n // Don't count deletion records - they're counted in Phase 2\n if (!result.isDeletedRecord) {\n if (result.isDuplicate) {\n skipped++; // Count duplicates as skipped\n } else {\n if (result.status === 'created') created++;\n else if (result.status === 'updated') updated++;\n else if (result.status === 'unchanged') unchanged++;\n else if (result.status === 'deleted') deleted++;\n else if (result.status === 'skipped') skipped++;\n else if (result.status === 'error') errors++;\n }\n }\n } catch (recordError) {\n const errorMsg = `Error processing ${flattenedRecord.entityName} record at ${flattenedRecord.path}: ${recordError}`;\n callbacks?.onError?.(errorMsg);\n errors++;\n }\n }\n }\n \n // Check if this file has any deletion records (including nested relatedEntities)\n const hasDeletions = this.hasAnyDeletions(records);\n\n // Write back to file (handles both single records and arrays)\n // Defer writing if file contains deletions - they'll be written after Phase 2\n if (!options.dryRun) {\n if (hasDeletions) {\n // Store for later writing after deletions complete\n this.deferredFileWrites.set(filePath, {\n filePath,\n records,\n isArray\n });\n } else {\n // Write immediately for files without deletions\n if (isArray) {\n await JsonWriteHelper.writeOrderedRecordData(filePath, records);\n } else {\n await JsonWriteHelper.writeOrderedRecordData(filePath, records[0]);\n }\n }\n }\n } catch (fileError) {\n // Error details already logged by lower-level handlers, just re-throw\n throw fileError;\n }\n }\n \n return { created, updated, unchanged, deleted, skipped, errors };\n }\n \n private async processFlattenedRecord(\n flattenedRecord: FlattenedRecord,\n entityDir: string,\n options: PushOptions,\n batchContext: Map<string, BaseEntity>,\n callbacks?: PushCallbacks,\n entityConfig?: any\n ): Promise<{ status: 'created' | 'updated' | 'unchanged' | 'error' | 'deleted' | 'skipped'; isDuplicate?: boolean; isDeletedRecord?: boolean }> {\n const metadata = new Metadata();\n const { record, entityName, parentContext, id: recordId } = flattenedRecord;\n\n // Skip deletion records - they're handled in Phase 2\n // File writing is deferred for files containing deletions\n // Mark with special flag so they don't count in Phase 1 stats at all\n if (record.deleteRecord && record.deleteRecord.delete === true) {\n return { status: 'unchanged', isDuplicate: false, isDeletedRecord: true };\n }\n \n // Use the unique record ID from the flattened record for batch context\n // This ensures we can properly find parent entities even when they're new\n const lookupKey = recordId;\n \n // Check if already in batch context\n let entity = batchContext.get(lookupKey);\n if (entity) {\n // Already processed\n return { status: 'unchanged', isDuplicate: true };\n }\n \n // Get or create entity instance\n entity = await metadata.GetEntityObject(entityName, this.contextUser);\n if (!entity) {\n throw new Error(`Failed to create entity object for ${entityName}`);\n }\n \n // Check if record exists\n const primaryKey = record.primaryKey;\n let exists = false;\n let isNew = false;\n \n if (primaryKey && Object.keys(primaryKey).length > 0) {\n // First check if the record exists using the sync engine's loadEntity method\n // This avoids the \"Error in BaseEntity.Load\" message for missing records\n const existingEntity = await this.syncEngine.loadEntity(entityName, primaryKey);\n \n if (existingEntity) {\n // Record exists, use the loaded entity\n entity = existingEntity;\n exists = true;\n } else {\n // Record doesn't exist in database\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: ${entityName} 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 { status: 'error', isDuplicate: false }; // This will be counted as error, not skipped\n } else {\n // Log that we're creating the missing record\n if (options.verbose) {\n callbacks?.onLog?.(`š Creating missing ${entityName} record with primaryKey {${pkDisplay}}`);\n }\n }\n }\n }\n \n if (!exists) {\n entity.NewRecord();\n isNew = true;\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 // Apply defaults if entityConfig is provided\n if (entityConfig) {\n const defaults = await this.syncEngine.buildDefaults(flattenedRecord.path, entityConfig);\n\n // Apply defaults only to fields not explicitly set in record.fields\n for (const [field, value] of Object.entries(defaults)) {\n if (!(field in record.fields) && field in entity) {\n entity.Set(field, value);\n }\n }\n }\n\n // Store original field values to preserve @ references\n const originalFields = { ...record.fields };\n \n // Get parent entity from context if available\n let parentEntity: BaseEntity | null = null;\n if (parentContext) {\n // Find the parent's flattened record ID\n // The parent record was flattened before this child, so it should have a lower ID number\n const parentRecordId = flattenedRecord.dependencies.values().next().value;\n if (parentRecordId) {\n parentEntity = batchContext.get(parentRecordId) || null;\n }\n \n if (!parentEntity) {\n // Parent should have been processed before child due to dependency ordering\n throw new Error(`Parent entity not found in batch context for ${entityName}. Parent dependencies: ${Array.from(flattenedRecord.dependencies).join(', ')}`);\n }\n }\n \n // Process field values with parent context and batch context\n // Process each field with better error reporting\n for (const [fieldName, fieldValue] of Object.entries(record.fields)) {\n try {\n const processedValue = await this.syncEngine.processFieldValue(\n fieldValue,\n entityDir,\n parentEntity,\n null, // rootRecord\n 0,\n batchContext // Pass batch context for lookups\n );\n entity.Set(fieldName, processedValue);\n } catch (fieldError: any) {\n // Enhanced error reporting for field processing failures\n const primaryKeyInfo = record.primaryKey ? JSON.stringify(record.primaryKey) : 'NEW';\n\n // Helper to log to both console and callbacks\n const logError = (msg: string) => {\n console.error(msg);\n callbacks?.onLog?.(msg);\n };\n\n // Check if this is a lookup failure\n if (fieldError.message?.includes('Lookup failed:')) {\n logError(`\\nā LOOKUP FAILURE in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${fieldError.message}`);\n logError(` Tip: Check if the referenced record exists in the target entity\\n`);\n } else if (fieldError.message?.includes('Entity not found:')) {\n logError(`\\nā ENTITY NOT FOUND in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${fieldError.message}`);\n logError(` Tip: Check if the entity name is spelled correctly\\n`);\n } else if (fieldError.message?.includes('Field') && fieldError.message?.includes('not found')) {\n logError(`\\nā FIELD NOT FOUND in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${fieldError.message}`);\n logError(` Tip: Check if the field name exists in the target entity\\n`);\n } else if (fieldError.message?.includes('File not found:')) {\n logError(`\\nā FILE NOT FOUND in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${fieldError.message}`);\n logError(` Tip: Check if the file path is correct relative to ${entityDir}\\n`);\n } else {\n logError(`\\nā FIELD PROCESSING ERROR in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${fieldError.message}\\n`);\n }\n\n // Re-throw with enhanced context\n throw new Error(`Failed to process field '${fieldName}' in ${entityName}: ${fieldError.message}`);\n }\n }\n \n // Check if the record is actually dirty before considering it changed\n let isDirty = entity.Dirty;\n \n // Force dirty state if alwaysPush is enabled\n const alwaysPush = this.syncConfig?.push?.alwaysPush ?? false;\n if (alwaysPush && !isNew) {\n isDirty = true;\n }\n \n // Also check if file content has changed (for @file references)\n if (!isDirty && !isNew && record.sync) {\n const currentChecksum = await this.syncEngine.calculateChecksumWithFileContent(originalFields, entityDir);\n if (currentChecksum !== record.sync.checksum) {\n isDirty = true;\n if (options.verbose) {\n callbacks?.onLog?.(`š File content changed for ${entityName} record (checksum mismatch)`);\n }\n }\n }\n \n if (options.dryRun) {\n if (exists) {\n callbacks?.onLog?.(`[DRY RUN] Would update ${entityName} record`);\n return { status: 'updated' };\n } else {\n callbacks?.onLog?.(`[DRY RUN] Would create ${entityName} record`);\n return { status: 'created' };\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(entityName);\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 ${entityName} 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 with detailed error logging\n const recordName = entity.Get('Name');\n const entityRecordId = entity.Get('ID');\n \n let saveResult;\n try {\n // Pass IgnoreDirtyState option when alwaysPush is enabled\n const saveOptions = alwaysPush ? { IgnoreDirtyState: true } : undefined;\n saveResult = await entity.Save(saveOptions);\n } catch (saveError: any) {\n // Helper to log to both console and callbacks\n const logError = (msg: string) => {\n console.error(msg);\n callbacks?.onLog?.(msg);\n };\n\n logError(`\\nā SAVE EXCEPTION for ${entityName}`);\n logError(` Record ID: ${entityRecordId || 'NEW'}`);\n logError(` Record Name: ${recordName || 'N/A'}`);\n logError(` File Path: ${flattenedRecord.path}`);\n logError(` Error: ${saveError.message || saveError}`);\n\n // Check for specific error patterns\n if (saveError.message?.includes('Cannot insert the value NULL')) {\n logError(` Tip: A required field is NULL. Check the entity's required fields.`);\n } else if (saveError.message?.includes('FOREIGN KEY constraint')) {\n logError(` Tip: Foreign key constraint violation. Check that referenced records exist.`);\n } else if (saveError.message?.includes('duplicate key')) {\n logError(` Tip: Duplicate key violation. A record with these values already exists.`);\n } else if (saveError.message?.includes('Incorrect syntax')) {\n logError(` Tip: SQL syntax error. Check for special characters in field values.`);\n }\n\n // Log problematic field values for debugging\n logError(`\\n Failed entity field values:`);\n for (const field of entity.Fields) {\n const value = entity.Get(field.Name);\n if (value !== null && value !== undefined) {\n const displayValue = typeof value === 'string' && value.length > 100\n ? value.substring(0, 100) + '...'\n : value;\n logError(` ${field.Name}: ${displayValue}`);\n }\n }\n logError(''); // Empty line for readability\n throw saveError;\n }\n \n if (!saveResult) {\n // Helper to log to both console and callbacks\n const logError = (msg: string) => {\n console.error(msg);\n callbacks?.onLog?.(msg);\n };\n\n logError(`\\nā SAVE RETURNED FALSE for ${entityName}`);\n logError(` Record ID: ${entityRecordId || 'NEW'}`);\n logError(` Record Name: ${recordName || 'N/A'}`);\n logError(` File Path: ${flattenedRecord.path}`);\n\n // Log the LatestResult for debugging\n if (entity.LatestResult) {\n if (entity.LatestResult.Message) {\n logError(` Database Message: ${entity.LatestResult.Message}`);\n }\n if (entity.LatestResult.Errors && entity.LatestResult.Errors.length > 0) {\n logError(` Errors:`);\n entity.LatestResult.Errors.forEach((err: any, idx: number) => {\n const errorMsg = typeof err === 'string' ? err : (err?.message || JSON.stringify(err));\n logError(` ${idx + 1}. ${errorMsg}`);\n });\n }\n if ((entity.LatestResult as any).SQL) {\n // Don't log the full SQL as it might be huge, just indicate it's available\n logError(` SQL Statement: [Available - check entity.LatestResult.SQL if needed]`);\n }\n }\n\n // Log field values that might be problematic\n logError(`\\n Entity field values:`);\n for (const field of entity.Fields) {\n const value = entity.Get(field.Name);\n if (value !== null && value !== undefined) {\n const displayValue = typeof value === 'string' && value.length > 100\n ? value.substring(0, 100) + '...'\n : value;\n logError(` ${field.Name}: ${displayValue}`);\n }\n }\n logError(''); // Empty line for readability\n // Build detailed error information\n const entityInfo = this.syncEngine.getEntityInfo(entityName);\n const primaryKeyInfo: string[] = [];\n const fieldInfo: string[] = [];\n \n // Collect primary key information\n if (entityInfo) {\n for (const pk of entityInfo.PrimaryKeys) {\n const pkValue = entity.Get(pk.Name);\n primaryKeyInfo.push(`${pk.Name}=${this.formatFieldValue(pkValue)}`);\n }\n }\n \n // Collect field values that were being saved\n for (const [fieldName, fieldValue] of Object.entries(record.fields)) {\n const processedValue = entity.Get(fieldName);\n fieldInfo.push(`${fieldName}=${this.formatFieldValue(processedValue)}`);\n }\n \n // Get the actual error details from the entity\n const errorMessage = entity.LatestResult?.Message || 'Unknown error';\n const errorDetails = entity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || '';\n \n // Log detailed error information\n callbacks?.onError?.(`\\nā FATAL ERROR: Failed to save ${entityName} record`);\n callbacks?.onError?.(` Entity: ${entityName}`);\n if (primaryKeyInfo.length > 0) {\n callbacks?.onError?.(` Primary Key: {${primaryKeyInfo.join(', ')}}`);\n }\n callbacks?.onError?.(` Record Path: ${flattenedRecord.path}`);\n callbacks?.onError?.(` Is New Record: ${isNew}`);\n callbacks?.onError?.(` Field Values Being Saved:`);\n for (const field of fieldInfo) {\n callbacks?.onError?.(` - ${field}`);\n }\n callbacks?.onError?.(` SQL Error: ${errorMessage}`);\n if (errorDetails) {\n callbacks?.onError?.(` Additional Details: ${errorDetails}`);\n }\n \n // Check for common issues\n if (errorMessage.includes('conversion failed') || errorMessage.includes('GUID')) {\n callbacks?.onError?.(` ā ļø This appears to be a GUID/UUID format error. Check that all ID fields contain valid GUIDs.`);\n }\n if (errorMessage.includes('transaction')) {\n callbacks?.onError?.(` ā ļø Transaction error detected. The database transaction may be corrupted.`);\n }\n \n // Throw error to trigger rollback and stop processing\n throw new Error(`Failed to save ${entityName} record at ${flattenedRecord.path}: ${errorMessage}`);\n }\n \n // Add to batch context AFTER save so it has an ID for child @parent:ID references\n // Use the recordId (lookupKey) as the key so child records can find this parent\n batchContext.set(lookupKey, entity);\n \n // Update primaryKey for new records\n if (isNew) {\n const entityInfo = this.syncEngine.getEntityInfo(entityName);\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 record.primaryKey = newPrimaryKey;\n }\n }\n \n // Only update sync metadata if the record was actually dirty (changed)\n if (isNew || isDirty) {\n record.sync = {\n lastModified: new Date().toISOString(),\n checksum: await this.syncEngine.calculateChecksumWithFileContent(originalFields, entityDir)\n };\n if (options.verbose) {\n callbacks?.onLog?.(` ā Updated sync metadata (record was ${isNew ? 'new' : 'changed'})`);\n }\n } else if (options.verbose) {\n callbacks?.onLog?.(` - Skipped sync metadata update (no changes detected)`);\n }\n \n // Restore original field values to preserve @ references\n record.fields = originalFields;\n \n return { \n status: isNew ? 'created' : (isDirty ? 'updated' : 'unchanged'),\n isDuplicate: false\n };\n }\n \n private formatFieldValue(value: any): string {\n if (value === null || value === undefined) return 'null';\n if (typeof value === 'string') {\n // Truncate long strings and show quotes\n if (value.length > 50) {\n return `\"${value.substring(0, 47)}...\"`;\n }\n return `\"${value}\"`;\n }\n if (typeof value === 'object') {\n const str = JSON.stringify(value);\n return str.length > 50 ? `\"${str.substring(0, 47)}...\"` : `\"${str}\"`;\n }\n return String(value);\n }\n \n private async processDeleteRecord(\n flattenedRecord: FlattenedRecord,\n _entityDir: string,\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<{ status: 'deleted' | 'skipped' | 'unchanged'; isDuplicate?: boolean }> {\n const { record, entityName } = flattenedRecord;\n \n // Validate that we have a primary key for deletion\n if (!record.primaryKey || Object.keys(record.primaryKey).length === 0) {\n throw new Error(`Cannot delete ${entityName} record without primaryKey. Please specify primaryKey fields.`);\n }\n \n // Load the entity to check if it exists in the target database\n const existingEntity = await this.syncEngine.loadEntity(entityName, record.primaryKey);\n\n // Check if the deletion has already been processed\n if (record.deleteRecord?.deletedAt) {\n // Verify if record still exists in THIS database\n if (!existingEntity) {\n if (options.verbose) {\n callbacks?.onLog?.(` ā¹ļø Record already deleted on ${record.deleteRecord.deletedAt} and confirmed absent from database`);\n }\n return { status: 'unchanged', isDuplicate: false };\n }\n\n // Record has deletedAt timestamp but still exists in this database\n // This can happen when syncing to a different database\n if (options.verbose) {\n callbacks?.onLog?.(` ā¹ļø Record marked as deleted on ${record.deleteRecord.deletedAt}, but still exists in this database. Re-deleting...`);\n }\n // Fall through to deletion logic\n }\n \n if (!existingEntity) {\n const pkDisplay = Object.entries(record.primaryKey)\n .map(([key, value]) => `${key}=${value}`)\n .join(', ');\n \n const warning = `Record not found for deletion: ${entityName} with primaryKey {${pkDisplay}}`;\n this.warnings.push(warning);\n callbacks?.onWarn?.(warning);\n \n // Mark as deleted anyway since it doesn't exist\n if (!record.deleteRecord) {\n record.deleteRecord = { delete: true };\n }\n record.deleteRecord.deletedAt = undefined; // Indicate it was not found\n record.deleteRecord.notFound = true;\n \n return { status: 'skipped', isDuplicate: false };\n }\n \n // Log the deletion\n const entityInfo = this.syncEngine.getEntityInfo(entityName);\n const primaryKeyDisplay: string[] = [];\n if (entityInfo) {\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKeyDisplay.push(`${pk.Name}: ${existingEntity.Get(pk.Name)}`);\n }\n }\n \n callbacks?.onLog?.(`šļø Deleting ${entityName} record:`);\n if (primaryKeyDisplay.length > 0) {\n callbacks?.onLog?.(` Primary Key: ${primaryKeyDisplay.join(', ')}`);\n }\n \n // Additional info if available\n const recordName = existingEntity.Get('Name');\n if (recordName) {\n callbacks?.onLog?.(` Name: ${recordName}`);\n }\n \n if (options.dryRun) {\n callbacks?.onLog?.(`[DRY RUN] Would delete ${entityName} record`);\n return { status: 'deleted', isDuplicate: false };\n }\n \n // Delete the record\n try {\n const deleteResult = await existingEntity.Delete();\n \n if (!deleteResult) {\n // Check the LatestResult for error details\n const errorMessage = existingEntity.LatestResult?.Message || 'Unknown error';\n const errorDetails = existingEntity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || '';\n \n callbacks?.onError?.(`\\nā Failed to delete ${entityName} record`);\n callbacks?.onError?.(` Primary Key: {${primaryKeyDisplay.join(', ')}}`);\n callbacks?.onError?.(` Error: ${errorMessage}`);\n if (errorDetails) {\n callbacks?.onError?.(` Details: ${errorDetails}`);\n }\n \n throw new Error(`Failed to delete ${entityName} record: ${errorMessage}`);\n }\n \n // Set deletedAt timestamp after successful deletion\n if (!record.deleteRecord) {\n record.deleteRecord = { delete: true };\n }\n record.deleteRecord.deletedAt = new Date().toISOString();\n\n // Update the corresponding record in deferred file writes\n this.updateDeferredFileRecord(flattenedRecord);\n\n if (options.verbose) {\n callbacks?.onLog?.(` ā Successfully deleted ${entityName} record`);\n }\n\n return { status: 'deleted', isDuplicate: false };\n \n } catch (deleteError: any) {\n console.error(`\\nā DELETE EXCEPTION for ${entityName}`);\n console.error(` Primary Key: {${primaryKeyDisplay.join(', ')}}`);\n console.error(` Error: ${deleteError.message || deleteError}`);\n \n // Check for specific error patterns\n if (deleteError.message?.includes('FOREIGN KEY constraint')) {\n console.error(` Tip: This record is referenced by other records and cannot be deleted.`);\n console.error(` Consider deleting dependent records first.`);\n } else if (deleteError.message?.includes('permission')) {\n console.error(` Tip: You may not have permission to delete this record.`);\n }\n \n throw deleteError;\n }\n }\n \n /**\n * Prompt user for confirmation before proceeding with push operation\n * This happens after deletion audit but before any database operations\n */\n private async promptForConfirmation(\n deletionAudit: DeletionAudit | null,\n callbacks?: PushCallbacks\n ): Promise<boolean> {\n // Build confirmation message\n const messages: string[] = [];\n messages.push('\\n' + 'ā'.repeat(80));\n messages.push('CONFIRMATION REQUIRED');\n messages.push('ā'.repeat(80));\n messages.push('');\n messages.push('This operation will:');\n messages.push(' ⢠Create new records');\n messages.push(' ⢠Update existing records');\n\n if (deletionAudit) {\n const totalDeletes = deletionAudit.explicitDeletes.size + deletionAudit.implicitDeletes.size;\n messages.push(` ⢠Delete ${totalDeletes} record${totalDeletes > 1 ? 's' : ''} (${deletionAudit.explicitDeletes.size} explicit, ${deletionAudit.implicitDeletes.size} implicit)`);\n\n if (deletionAudit.orphanedReferences.length > 0) {\n messages.push(` ā ļø ${deletionAudit.orphanedReferences.length} database-only reference${deletionAudit.orphanedReferences.length > 1 ? 's' : ''} detected (may cause FK errors)`);\n }\n } else {\n messages.push(' ⢠No deletions');\n }\n\n messages.push('');\n messages.push('All operations will occur within a transaction and can be rolled back on error.');\n messages.push('');\n messages.push('ā'.repeat(80));\n messages.push('');\n\n // Display messages\n for (const msg of messages) {\n callbacks?.onLog?.(msg);\n }\n\n // Use onConfirm callback if available, otherwise throw error\n if (callbacks?.onConfirm) {\n const confirmed = await callbacks.onConfirm('Do you want to proceed? (yes/no)');\n return confirmed;\n } else {\n // No confirmation callback provided - this shouldn't happen in interactive mode\n callbacks?.onWarn?.('ā ļø No confirmation callback provided. Proceeding automatically.');\n callbacks?.onWarn?.(' To enable confirmation prompts, provide an onConfirm callback.\\n');\n return true;\n }\n }\n\n /**\n * Audit all deletions across all metadata files\n * This pre-processes all records to identify deletion dependencies and order\n */\n private async auditAllDeletions(\n entityDirs: string[],\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<DeletionAudit | null> {\n // OPTIMIZATION: Quick scan to check if ANY deletions exist before doing expensive loading\n let hasAnyDeletions = false;\n\n for (const entityDir of entityDirs) {\n if (hasAnyDeletions) break; // Early exit once we find any deletion\n\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n continue;\n }\n\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 // Quick scan for delete directives without full processing\n for (const filePath of files) {\n try {\n const content = await fs.readFile(filePath, 'utf-8');\n // Fast string check for delete directives\n if (content.includes('\"delete\"') && content.includes('true')) {\n // More precise check - parse JSON to confirm\n const data = JSON.parse(content);\n const records = Array.isArray(data) ? data : [data];\n\n const hasDelete = records.some((r: RecordData) => r.deleteRecord?.delete === true);\n if (hasDelete) {\n hasAnyDeletions = true;\n break;\n }\n }\n } catch (error) {\n // Ignore errors in quick scan\n }\n }\n }\n\n // If no deletions found, skip all processing\n if (!hasAnyDeletions) {\n if (options.verbose) {\n callbacks?.onLog?.('No deletion operations found - skipping deletion audit.\\n');\n }\n return null;\n }\n\n // Deletions exist - proceed with full audit\n callbacks?.onLog?.('\\nš Analyzing deletion operations...\\n');\n\n // Load all records from all entity directories\n const allRecords: FlattenedRecord[] = [];\n const analyzer = new RecordDependencyAnalyzer();\n\n for (const entityDir of entityDirs) {\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n continue;\n }\n\n // Find all JSON files\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 // Load and flatten records from each file\n for (const filePath of files) {\n try {\n const rawFileData = await fs.readJson(filePath);\n\n // Handle @include directives if present\n let fileData = rawFileData;\n const jsonString = JSON.stringify(rawFileData);\n const hasIncludes = jsonString.includes('\"@include\"') || jsonString.includes('\"@include.');\n\n if (hasIncludes) {\n const jsonPreprocessor = new JsonPreprocessor();\n fileData = await jsonPreprocessor.processFile(filePath);\n }\n\n const records = Array.isArray(fileData) ? fileData : [fileData];\n\n // Analyze and flatten records\n const analysisResult = await analyzer.analyzeFileRecords(records, entityConfig.entity);\n allRecords.push(...analysisResult.sortedRecords);\n } catch (error) {\n if (options.verbose) {\n callbacks?.onLog?.(`Warning: Could not load ${filePath}: ${error}`);\n }\n }\n }\n }\n\n // Perform comprehensive deletion audit\n const md = new Metadata();\n const auditor = new DeletionAuditor(\n md,\n this.contextUser\n );\n\n const audit = await auditor.auditDeletions(allRecords);\n\n // Check if any records actually need deletion\n const totalMarkedForDeletion = audit.explicitDeletes.size + audit.implicitDeletes.size;\n const needDeletion = audit.deletionLevels.flat().length; // Only records that exist in DB\n\n if (needDeletion === 0) {\n // All records marked for deletion are already deleted\n if (options.verbose && totalMarkedForDeletion > 0) {\n callbacks?.onLog?.(`ā¹ļø All ${totalMarkedForDeletion} record${totalMarkedForDeletion > 1 ? 's' : ''} marked for deletion are already deleted from the database.`);\n callbacks?.onLog?.(' No deletion operations needed.\\n');\n }\n return null; // Signal that no deletion audit is needed\n }\n\n // Generate and display report (only if records need deletion)\n const report = DeletionReportGenerator.generateReport(audit, options.verbose);\n callbacks?.onLog?.(report);\n callbacks?.onLog?.('');\n\n // Check for blocking issues (only circular dependencies block execution)\n if (audit.circularDependencies.length > 0) {\n const error = `Cannot proceed: ${audit.circularDependencies.length} circular ${audit.circularDependencies.length > 1 ? 'dependencies' : 'dependency'} detected.\\n` +\n `Please resolve the circular dependencies before attempting deletion.`;\n callbacks?.onError?.(error);\n throw new Error(error);\n }\n\n // Warn about database-only references (non-blocking)\n // These may be handled by cascade delete rules at the database level\n if (audit.orphanedReferences.length > 0) {\n callbacks?.onWarn?.(`ā ļø WARNING: ${audit.orphanedReferences.length} database-only reference${audit.orphanedReferences.length > 1 ? 's' : ''} found.`);\n callbacks?.onWarn?.(` These records exist in the database but not in metadata.`);\n callbacks?.onWarn?.(` If your database has cascade delete rules, these will be handled automatically.`);\n callbacks?.onWarn?.(` Otherwise, deletion may fail with FK constraint errors.\\n`);\n }\n\n // Warn about implicit deletes\n if (audit.implicitDeletes.size > 0) {\n callbacks?.onWarn?.('ā ļø WARNING: Implicit deletions will occur.');\n callbacks?.onWarn?.(` ${audit.implicitDeletes.size} record${audit.implicitDeletes.size > 1 ? 's' : ''} will be deleted due to FK constraints.`);\n callbacks?.onWarn?.(' Review the deletion audit report above.\\n');\n }\n\n return audit;\n }\n\n /**\n * Process deletions in reverse dependency order\n */\n private async processDeletionsFromAudit(\n audit: DeletionAudit,\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<{ deleted: number; errors: number }> {\n let deleted = 0;\n let errors = 0;\n\n callbacks?.onLog?.('šļø Processing deletions in reverse dependency order...\\n');\n\n // Process deletion levels in order (highest dependency level first)\n for (let i = 0; i < audit.deletionLevels.length; i++) {\n const level = audit.deletionLevels[i];\n const levelNumber = audit.deletionLevels.length - i; // Reverse numbering for clarity\n\n callbacks?.onLog?.(` Level ${levelNumber}: Deleting ${level.length} record${level.length > 1 ? 's' : ''}...`);\n\n // Process records within same level (can be done in parallel in the future)\n for (const record of level) {\n try {\n const result = await this.processDeleteRecord(record, '', options, callbacks);\n\n if (result.status === 'deleted') {\n deleted++;\n } else if (result.status === 'skipped') {\n // Record not found, already handled in processDeleteRecord\n }\n } catch (error) {\n callbacks?.onError?.(` Failed to delete ${record.entityName}: ${error}`);\n errors++;\n throw error; // Fail fast on first deletion error\n }\n }\n }\n\n if (deleted > 0) {\n callbacks?.onLog?.(` ā Successfully deleted ${deleted} record${deleted > 1 ? 's' : ''}\\n`);\n }\n\n return { deleted, errors };\n }\n\n /**\n * Recursively check if any records in an array (including nested relatedEntities) have deletions\n */\n private hasAnyDeletions(records: RecordData[]): boolean {\n for (const record of records) {\n // Check this record\n if (record.deleteRecord?.delete === true) {\n return true;\n }\n\n // Check nested related entities recursively\n if (record.relatedEntities) {\n for (const relatedRecords of Object.values(record.relatedEntities)) {\n if (Array.isArray(relatedRecords)) {\n if (this.hasAnyDeletions(relatedRecords)) {\n return true;\n }\n }\n }\n }\n }\n\n return false;\n }\n\n /**\n * Write all deferred files with updated deletion timestamps\n * Called in Phase 3 after all deletions complete successfully\n */\n private async writeDeferredFiles(options: PushOptions, callbacks?: PushCallbacks): Promise<void> {\n if (this.deferredFileWrites.size === 0) {\n return;\n }\n\n if (options.verbose) {\n callbacks?.onLog?.(`\\nš Writing ${this.deferredFileWrites.size} file${this.deferredFileWrites.size > 1 ? 's' : ''} with deletion timestamps...`);\n }\n\n for (const deferredWrite of this.deferredFileWrites.values()) {\n try {\n if (deferredWrite.isArray) {\n await JsonWriteHelper.writeOrderedRecordData(deferredWrite.filePath, deferredWrite.records);\n } else {\n await JsonWriteHelper.writeOrderedRecordData(deferredWrite.filePath, deferredWrite.records[0]);\n }\n } catch (error) {\n callbacks?.onWarn?.(` ā ļø Failed to write ${deferredWrite.filePath}: ${error}`);\n }\n }\n\n if (options.verbose) {\n callbacks?.onLog?.(` ā Completed writing deferred files\\n`);\n }\n }\n\n /**\n * Update a record in deferred file writes after successful deletion\n * Finds the matching RecordData by primary key and updates its deleteRecord section\n * Searches recursively through nested relatedEntities\n */\n private updateDeferredFileRecord(flattenedRecord: FlattenedRecord): void {\n const { record } = flattenedRecord;\n\n // Search through all deferred files to find the matching record\n for (const deferredWrite of this.deferredFileWrites.values()) {\n for (const fileRecord of deferredWrite.records) {\n // Search this record and all nested related entities recursively\n if (this.findAndUpdateRecord(fileRecord, record, flattenedRecord.entityName)) {\n return; // Found and updated\n }\n }\n }\n }\n\n /**\n * Recursively search a RecordData and its relatedEntities for a matching record\n * Updates the matching record's deleteRecord timestamp\n */\n private findAndUpdateRecord(\n searchIn: RecordData,\n targetRecord: RecordData,\n targetEntityName: string\n ): boolean {\n // Check if this is the matching record\n if (this.recordsMatch(searchIn, targetRecord, targetEntityName)) {\n // Update the deleteRecord section with the timestamp\n if (!searchIn.deleteRecord) {\n searchIn.deleteRecord = { delete: true };\n }\n searchIn.deleteRecord.deletedAt = targetRecord.deleteRecord!.deletedAt;\n return true; // Found and updated\n }\n\n // Search through related entities recursively\n if (searchIn.relatedEntities) {\n for (const relatedRecords of Object.values(searchIn.relatedEntities)) {\n if (Array.isArray(relatedRecords)) {\n for (const relatedRecord of relatedRecords) {\n if (this.findAndUpdateRecord(relatedRecord, targetRecord, targetEntityName)) {\n return true; // Found in nested record\n }\n }\n }\n }\n }\n\n return false; // Not found in this branch\n }\n\n /**\n * Check if two RecordData objects represent the same record\n * Compares primary keys and entity context\n */\n private recordsMatch(record1: RecordData, record2: RecordData, entityName: string): boolean {\n // Must both have primary keys\n if (!record1.primaryKey || !record2.primaryKey) {\n return false;\n }\n\n // Must have same primary key fields\n const pk1Keys = Object.keys(record1.primaryKey);\n const pk2Keys = Object.keys(record2.primaryKey);\n\n if (pk1Keys.length !== pk2Keys.length) {\n return false;\n }\n\n // All primary key values must match\n return pk1Keys.every(key =>\n record1.primaryKey![key] === record2.primaryKey![key]\n );\n }\n\n private _buildBatchContextKey(entityName: string, record: RecordData): string {\n // Build a unique key for the batch context based on entity name and identifying fields\n const keyParts = [entityName];\n\n // Use primary key if available\n if (record.primaryKey) {\n for (const [field, value] of Object.entries(record.primaryKey)) {\n keyParts.push(`${field}=${value}`);\n }\n } else {\n // Use a combination of important fields as fallback\n const identifyingFields = ['Name', 'ID', 'Code', 'Email'];\n for (const field of identifyingFields) {\n if (record.fields[field]) {\n keyParts.push(`${field}=${record.fields[field]}`);\n }\n }\n }\n\n return keyParts.join('|');\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"PushService.js","sourceRoot":"","sources":["../../src/services/PushService.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AACxB,0DAAiC;AACjC,+CAAyF;AACzF,oDAAmF;AACnF,sCAA2E;AAC3E,oEAA+D;AAC/D,0DAAsD;AACtD,kDAA8C;AAC9C,oEAAgE;AAChE,gEAA2D;AAC3D,kFAA8F;AAC9F,gEAA4D;AAC5D,0DAA8D;AAC9D,8DAAyE;AACzE,g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C,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF;AAtqDD,kCAsqDC","sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport fastGlob from 'fast-glob';\nimport { BaseEntity, Metadata, UserInfo, EntitySaveOptions } from '@memberjunction/core';\nimport { SyncEngine, RecordData, DeferrableLookupError } from '../lib/sync-engine';\nimport { loadEntityConfig, loadSyncConfig, EntityConfig } 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 { JsonWriteHelper } from '../lib/json-write-helper';\nimport { RecordDependencyAnalyzer, FlattenedRecord } from '../lib/record-dependency-analyzer';\nimport { JsonPreprocessor } from '../lib/json-preprocessor';\nimport { findEntityDirectories } from '../lib/provider-utils';\nimport { DeletionAuditor, DeletionAudit } from '../lib/deletion-auditor';\nimport { DeletionReportGenerator } from '../lib/deletion-report-generator';\nimport type { SqlLoggingSession, SQLServerDataProvider } from '@memberjunction/sqlserver-dataprovider';\n\n// Configuration for parallel processing\nconst PARALLEL_BATCH_SIZE = 1; // Number of records to process in parallel at each dependency level\n/// TEMPORARILY DISABLED PARALLEL BY SETTING TO 1 as we were having some issues\n\nexport interface PushOptions {\n dir?: string;\n dryRun?: boolean;\n verbose?: boolean;\n noValidate?: boolean;\n parallelBatchSize?: number; // Number of records to process in parallel (default: 10)\n include?: string[]; // Only process these directories (whitelist, supports patterns)\n exclude?: string[]; // Skip these directories (blacklist, supports patterns)\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 deleted: number;\n skipped: number;\n deferred: 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 deleted: number;\n skipped: number;\n deferred: number;\n errors: number;\n}\n\n/**\n * Tracks files that need to be written back after deletions complete\n */\ninterface DeferredFileWrite {\n filePath: string;\n records: RecordData[];\n isArray: boolean;\n}\n\n/**\n * Tracks records that had deferred lookups and need to be re-processed.\n * Used with `?allowDefer` flag in @lookup syntax for handling circular dependencies.\n * Stores the full context needed to re-run processFlattenedRecord identically.\n */\ninterface DeferredRecord {\n /** The full flattened record to re-process */\n flattenedRecord: FlattenedRecord;\n /** The entity directory for resolving paths */\n entityDir: string;\n /** The entity configuration */\n entityConfig: EntityConfig;\n}\n\nexport class PushService {\n private syncEngine: SyncEngine;\n private contextUser: UserInfo;\n private warnings: string[] = [];\n private syncConfig: any;\n private deferredFileWrites: Map<string, DeferredFileWrite> = new Map();\n private deferredRecords: DeferredRecord[] = [];\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\n // Validate that include and exclude are not used together\n if (options.include && options.exclude) {\n throw new Error('Cannot specify both --include and --exclude options. Please use one or the other.');\n }\n\n // Reset deferred tracking for this push operation\n this.deferredFileWrites.clear();\n this.deferredRecords = [];\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 // Display warnings for special flags that are enabled\n if (this.syncConfig?.push?.alwaysPush && !options.dryRun) {\n callbacks?.onWarn?.('\\nā” WARNING: alwaysPush is enabled - ALL records will be saved to database regardless of changes\\n');\n }\n if (this.syncConfig?.push?.autoCreateMissingRecords && !options.dryRun) {\n callbacks?.onWarn?.('\\nš§ WARNING: autoCreateMissingRecords is enabled - Missing records with primaryKey will be created\\n');\n }\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 filterPatterns: this.syncConfig.sqlLogging?.filterPatterns,\n filterType: this.syncConfig.sqlLogging?.filterType,\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 // Note: If options.dir is specified, configDir already points to that directory\n // So we don't need to pass it as specificDir\n const entityDirs = findEntityDirectories(\n configDir,\n undefined,\n this.syncConfig?.directoryOrder,\n this.syncConfig?.ignoreDirectories,\n options.include,\n options.exclude\n );\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 totalDeleted = 0;\n let totalSkipped = 0;\n let totalDeferred = 0;\n let totalErrors = 0;\n \n // PHASE 0: Audit all deletions across all entities (if any exist)\n let deletionAudit: DeletionAudit | null = null;\n try {\n deletionAudit = await this.auditAllDeletions(entityDirs, options, callbacks);\n } catch (auditError) {\n // Audit failed, cannot proceed\n throw auditError;\n }\n\n // CONFIRMATION PROMPT: Ask user to confirm only if deletions will occur\n if (!options.dryRun && deletionAudit) {\n const shouldProceed = await this.promptForConfirmation(deletionAudit, callbacks);\n if (!shouldProceed) {\n callbacks?.onLog?.('\\nā Push operation cancelled by user.\\n');\n\n // Clean up SQL logging session and file if it was created\n if (sqlLoggingSession) {\n const sqlLogPath = sqlLoggingSession.filePath;\n try {\n await sqlLoggingSession.dispose();\n // Delete the empty SQL log file since no operations occurred\n if (await fs.pathExists(sqlLogPath)) {\n await fs.remove(sqlLogPath);\n if (options.verbose) {\n callbacks?.onLog?.(`šļø Removed empty SQL log file: ${sqlLogPath}`);\n }\n }\n } catch (cleanupError) {\n callbacks?.onWarn?.(`Failed to clean up SQL logging session: ${cleanupError}`);\n }\n }\n\n return {\n created: 0,\n updated: 0,\n unchanged: 0,\n deleted: 0,\n skipped: 0,\n deferred: 0,\n errors: 0,\n warnings: this.warnings\n };\n }\n }\n\n // Begin transaction if not in dry-run mode\n if (!options.dryRun) {\n await transactionManager.beginTransaction();\n }\n\n try {\n // PHASE 1: Process creates/updates for all entities\n callbacks?.onLog?.('š Processing creates and updates...\\n');\n\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 totalSkipped++; // Count skipped directories\n continue;\n }\n\n // Show folder with spinner at start\n const dirName = path.relative(process.cwd(), entityDir) || '.';\n callbacks?.onLog?.(`\\nš ${dirName}:`);\n\n // Use onProgress for animated spinner if available\n if (callbacks?.onProgress) {\n callbacks.onProgress(`Processing ${dirName}...`);\n } else {\n callbacks?.onLog?.(` ā³ Processing...`);\n }\n \n if (options.verbose && callbacks?.onLog) {\n callbacks.onLog(`Processing ${entityConfig.entity} in ${entityDir}`);\n }\n \n const result = await this.processEntityDirectory(\n entityDir,\n entityConfig,\n options,\n fileBackupManager,\n callbacks\n );\n \n // Stop the spinner if we were using onProgress\n if (callbacks?.onProgress && callbacks?.onSuccess) {\n callbacks.onSuccess(`Processed ${dirName}`);\n }\n \n // Show per-directory summary\n const dirTotal = result.created + result.updated + result.unchanged + result.deleted + result.skipped;\n if (dirTotal > 0 || result.errors > 0) {\n callbacks?.onLog?.(` Total processed: ${dirTotal} 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.deleted > 0) {\n callbacks?.onLog?.(` ā Deleted: ${result.deleted}`);\n }\n if (result.deferred > 0) {\n callbacks?.onLog?.(` ā³ Deferred: ${result.deferred}`);\n }\n if (result.unchanged > 0) {\n callbacks?.onLog?.(` - Unchanged: ${result.unchanged}`);\n }\n if (result.skipped > 0) {\n callbacks?.onLog?.(` - Skipped: ${result.skipped}`);\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 totalDeleted += result.deleted;\n totalSkipped += result.skipped;\n totalDeferred += result.deferred;\n totalErrors += result.errors;\n }\n\n // PHASE 2: Process deletions in reverse dependency order (if any exist)\n if (deletionAudit && totalErrors === 0) {\n const deletionResult = await this.processDeletionsFromAudit(deletionAudit, options, callbacks);\n totalDeleted += deletionResult.deleted;\n totalErrors += deletionResult.errors;\n }\n\n // PHASE 2.5: Process deferred records (for circular dependencies)\n if (this.deferredRecords.length > 0 && totalErrors === 0) {\n const deferredResult = await this.processDeferredRecords(options, callbacks);\n totalCreated += deferredResult.created;\n totalUpdated += deferredResult.updated;\n totalErrors += deferredResult.errors;\n }\n\n // Commit transaction if successful\n if (!options.dryRun && totalErrors === 0) {\n await transactionManager.commitTransaction();\n }\n\n // PHASE 3: Write deferred files with updated deletion timestamps\n if (!options.dryRun && totalErrors === 0 && this.deferredFileWrites.size > 0) {\n await this.writeDeferredFiles(options, callbacks);\n }\n } catch (error) {\n // Rollback transaction on error\n if (!options.dryRun) {\n callbacks?.onLog?.('\\nā ļø Rolling back database transaction due to error...');\n await transactionManager.rollbackTransaction();\n callbacks?.onLog?.('ā Database transaction rolled back successfully\\n');\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 deleted: totalDeleted,\n skipped: totalSkipped,\n deferred: totalDeferred,\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 ): Promise<EntityPushResult> {\n let created = 0;\n let updated = 0;\n let unchanged = 0;\n let deleted = 0;\n let skipped = 0;\n let deferred = 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 // Read the raw file data first\n const rawFileData = await fs.readJson(filePath);\n\n // Keep unprocessed data to write back (preserves @file: references)\n const unprocessedRecords = Array.isArray(rawFileData) ? rawFileData : [rawFileData];\n const isArray = Array.isArray(rawFileData);\n\n // Only preprocess if there are @include directives\n let fileData = rawFileData;\n const jsonString = JSON.stringify(rawFileData);\n const hasIncludes = jsonString.includes('\"@include\"') || jsonString.includes('\"@include.');\n\n if (hasIncludes) {\n // Preprocess the JSON file to handle @include directives\n // Create a new preprocessor instance for each file to ensure clean state\n const jsonPreprocessor = new JsonPreprocessor();\n fileData = await jsonPreprocessor.processFile(filePath);\n }\n\n const records = Array.isArray(fileData) ? fileData : [fileData];\n \n // Analyze dependencies and get sorted records\n const analyzer = new RecordDependencyAnalyzer();\n const analysisResult = await analyzer.analyzeFileRecords(records, entityConfig.entity);\n \n if (analysisResult.circularDependencies.length > 0) {\n callbacks?.onWarn?.(`ā ļø Circular dependencies detected in ${filePath}`);\n for (const cycle of analysisResult.circularDependencies) {\n callbacks?.onWarn?.(` Cycle: ${cycle.join(' ā ')}`);\n }\n }\n \n if (options.verbose) {\n callbacks?.onLog?.(` Analyzed ${analysisResult.sortedRecords.length} records (including nested)`);\n }\n \n // Create batch context for in-memory entity resolution\n // Note: While JavaScript is single-threaded, async operations can interleave.\n // Map operations themselves are atomic, but we ensure records are added to\n // the context AFTER successful save to maintain consistency.\n const batchContext = new Map<string, BaseEntity>();\n \n // Process records using dependency levels for parallel processing\n if (analysisResult.dependencyLevels && analysisResult.dependencyLevels.length > 0) {\n // Use parallel processing with dependency levels\n for (let levelIndex = 0; levelIndex < analysisResult.dependencyLevels.length; levelIndex++) {\n const level = analysisResult.dependencyLevels[levelIndex];\n \n if (options.verbose && level.length > 1) {\n callbacks?.onLog?.(` Processing dependency level ${levelIndex} with ${level.length} records in parallel...`);\n }\n \n // Process records in this level in parallel batches\n const batchSize = options.parallelBatchSize || PARALLEL_BATCH_SIZE;\n for (let i = 0; i < level.length; i += batchSize) {\n const batch = level.slice(i, Math.min(i + batchSize, level.length));\n \n // Process batch in parallel\n const batchResults = await Promise.all(\n batch.map(async (flattenedRecord) => {\n try {\n const result = await this.processFlattenedRecord(\n flattenedRecord,\n entityDir,\n options,\n batchContext,\n callbacks,\n entityConfig\n );\n return { success: true, result };\n } catch (error) {\n // Return error instead of throwing to handle after Promise.all\n return { success: false, error, record: flattenedRecord };\n }\n })\n );\n \n // Process results and check for errors\n for (const batchResult of batchResults) {\n if (!batchResult.success) {\n // Fail fast on first error with detailed logging\n const err = batchResult.error as Error;\n const rec = batchResult.record as FlattenedRecord;\n\n // Log concise summary - detailed error was already logged by processFlattenedRecord\n callbacks?.onLog?.(`\\nā Processing failed for ${rec.entityName} at ${rec.path}`);\n callbacks?.onLog?.(` ${err.message}\\n`);\n\n // Throw concise error to trigger rollback\n throw err;\n }\n \n // Update stats for successful results\n const result = batchResult.result!;\n // Don't count deletion records - they're counted in Phase 2\n if (result.isDeletedRecord) {\n continue; // Skip entirely\n } else if (result.isDuplicate) {\n skipped++; // Count duplicates as skipped\n } else {\n if (result.status === 'created') created++;\n else if (result.status === 'updated') updated++;\n else if (result.status === 'unchanged') unchanged++;\n else if (result.status === 'deleted') deleted++;\n else if (result.status === 'skipped') skipped++;\n else if (result.status === 'error') errors++;\n else if (result.status === 'deferred') {\n created++; // Deferred records were saved (count as created)\n deferred++; // Also track separately for reporting\n }\n }\n }\n }\n }\n } else {\n // Fallback to sequential processing if no dependency levels available\n for (const flattenedRecord of analysisResult.sortedRecords) {\n try {\n const result = await this.processFlattenedRecord(\n flattenedRecord,\n entityDir,\n options,\n batchContext,\n callbacks,\n entityConfig\n );\n \n // Update stats\n // Don't count deletion records - they're counted in Phase 2\n if (!result.isDeletedRecord) {\n if (result.isDuplicate) {\n skipped++; // Count duplicates as skipped\n } else {\n if (result.status === 'created') created++;\n else if (result.status === 'updated') updated++;\n else if (result.status === 'unchanged') unchanged++;\n else if (result.status === 'deleted') deleted++;\n else if (result.status === 'skipped') skipped++;\n else if (result.status === 'error') errors++;\n else if (result.status === 'deferred') {\n created++; // Deferred records were saved (count as created)\n deferred++; // Also track separately for reporting\n }\n }\n }\n } catch (recordError) {\n const errorMsg = `Error processing ${flattenedRecord.entityName} record at ${flattenedRecord.path}: ${recordError}`;\n callbacks?.onError?.(errorMsg);\n errors++;\n }\n }\n }\n \n // Check if this file has any deletion records (including nested relatedEntities)\n const hasDeletions = this.hasAnyDeletions(records);\n\n // Write back to file (handles both single records and arrays)\n // Use unprocessedRecords to preserve @file: references\n // Defer writing if file contains deletions - they'll be written after Phase 2\n if (!options.dryRun) {\n if (hasDeletions) {\n // Store for later writing after deletions complete\n this.deferredFileWrites.set(filePath, {\n filePath,\n records: unprocessedRecords,\n isArray\n });\n } else {\n // Write immediately for files without deletions\n if (isArray) {\n await JsonWriteHelper.writeOrderedRecordData(filePath, unprocessedRecords);\n } else {\n await JsonWriteHelper.writeOrderedRecordData(filePath, unprocessedRecords[0]);\n }\n }\n }\n } catch (fileError) {\n // Error details already logged by lower-level handlers, just re-throw\n throw fileError;\n }\n }\n \n return { created, updated, unchanged, deleted, skipped, deferred, errors };\n }\n\n private async processFlattenedRecord(\n flattenedRecord: FlattenedRecord,\n entityDir: string,\n options: PushOptions,\n batchContext: Map<string, BaseEntity>,\n callbacks?: PushCallbacks,\n entityConfig?: EntityConfig,\n allowDefer: boolean = true\n ): Promise<{ status: 'created' | 'updated' | 'unchanged' | 'error' | 'deleted' | 'skipped' | 'deferred'; isDuplicate?: boolean; isDeletedRecord?: boolean }> {\n const metadata = new Metadata();\n const { record, entityName, parentContext, id: recordId } = flattenedRecord;\n\n // Skip deletion records - they're handled in Phase 2\n // File writing is deferred for files containing deletions\n // Mark with special flag so they don't count in Phase 1 stats at all\n if (record.deleteRecord && record.deleteRecord.delete === true) {\n return { status: 'unchanged', isDuplicate: false, isDeletedRecord: true };\n }\n \n // Use the unique record ID from the flattened record for batch context\n // This ensures we can properly find parent entities even when they're new\n const lookupKey = recordId;\n \n // Check if already in batch context\n let entity = batchContext.get(lookupKey);\n if (entity) {\n // Already processed\n return { status: 'unchanged', isDuplicate: true };\n }\n \n // Get or create entity instance\n entity = await metadata.GetEntityObject(entityName, this.contextUser);\n if (!entity) {\n throw new Error(`Failed to create entity object for ${entityName}`);\n }\n \n // Check if record exists\n const primaryKey = record.primaryKey;\n let exists = false;\n let isNew = false;\n \n if (primaryKey && Object.keys(primaryKey).length > 0) {\n // First check if the record exists using the sync engine's loadEntity method\n // This avoids the \"Error in BaseEntity.Load\" message for missing records\n const existingEntity = await this.syncEngine.loadEntity(entityName, primaryKey);\n \n if (existingEntity) {\n // Record exists, use the loaded entity\n entity = existingEntity;\n exists = true;\n } else {\n // Record doesn't exist in database\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: ${entityName} 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 { status: 'error', isDuplicate: false }; // This will be counted as error, not skipped\n } else {\n // Log that we're creating the missing record\n if (options.verbose) {\n callbacks?.onLog?.(`š Creating missing ${entityName} record with primaryKey {${pkDisplay}}`);\n }\n }\n }\n }\n \n if (!exists) {\n entity.NewRecord();\n isNew = true;\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 // Apply defaults if entityConfig is provided\n if (entityConfig) {\n const defaults = await this.syncEngine.buildDefaults(flattenedRecord.path, entityConfig);\n\n // Apply defaults only to fields not explicitly set in record.fields\n for (const [field, value] of Object.entries(defaults)) {\n if (!(field in record.fields) && field in entity) {\n entity.Set(field, value);\n }\n }\n }\n\n // Store original field values to preserve @ references\n const originalFields = { ...record.fields };\n \n // Get parent entity from context if available\n let parentEntity: BaseEntity | null = null;\n if (parentContext) {\n // Find the parent's flattened record ID\n // The parent record was flattened before this child, so it should have a lower ID number\n const parentRecordId = flattenedRecord.dependencies.values().next().value;\n if (parentRecordId) {\n parentEntity = batchContext.get(parentRecordId) || null;\n }\n \n if (!parentEntity) {\n // Parent should have been processed before child due to dependency ordering\n throw new Error(`Parent entity not found in batch context for ${entityName}. Parent dependencies: ${Array.from(flattenedRecord.dependencies).join(', ')}`);\n }\n }\n \n // Process field values with parent context and batch context\n // Process each field with better error reporting\n // Track if we hit any deferrable lookup errors\n let hasDeferrableLookupError = false;\n\n for (const [fieldName, fieldValue] of Object.entries(record.fields)) {\n try {\n const processedValue = await this.syncEngine.processFieldValue(\n fieldValue,\n entityDir,\n parentEntity,\n null, // rootRecord\n 0,\n batchContext // Pass batch context for lookups\n );\n entity.Set(fieldName, processedValue);\n } catch (fieldError: unknown) {\n // Check if this is a deferrable lookup error first\n if (fieldError instanceof DeferrableLookupError) {\n // If allowDefer is false, we're in deferred processing mode - can't defer again\n if (!allowDefer) {\n const err = fieldError as DeferrableLookupError;\n throw new Error(`Deferred lookup still failed: ${err.message}`);\n }\n\n // Mark that we need to defer this entire record\n hasDeferrableLookupError = true;\n\n // Log that we're deferring this lookup\n if (options.verbose) {\n callbacks?.onLog?.(` ā³ Deferring lookup for ${entityName}.${fieldName} -> ${fieldError.entityName}`);\n }\n // Don't set this field - continue to try other fields\n // We'll re-process the entire record later\n continue;\n }\n\n // For other errors, use enhanced error reporting\n const err = fieldError as Error;\n const primaryKeyInfo = record.primaryKey ? JSON.stringify(record.primaryKey) : 'NEW';\n\n // Helper to log to both console and callbacks\n const logError = (msg: string) => {\n console.error(msg);\n callbacks?.onLog?.(msg);\n };\n\n // Check if this is a lookup failure\n if (err.message?.includes('Lookup failed:')) {\n logError(`\\nā LOOKUP FAILURE in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${err.message}`);\n logError(` Tip: Check if the referenced record exists in the target entity\\n`);\n } else if (err.message?.includes('Entity not found:')) {\n logError(`\\nā ENTITY NOT FOUND in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${err.message}`);\n logError(` Tip: Check if the entity name is spelled correctly\\n`);\n } else if (err.message?.includes('Field') && err.message?.includes('not found')) {\n logError(`\\nā FIELD NOT FOUND in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${err.message}`);\n logError(` Tip: Check if the field name exists in the target entity\\n`);\n } else if (err.message?.includes('File not found:')) {\n logError(`\\nā FILE NOT FOUND in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${err.message}`);\n logError(` Tip: Check if the file path is correct relative to ${entityDir}\\n`);\n } else {\n logError(`\\nā FIELD PROCESSING ERROR in ${entityName} (${primaryKeyInfo})`);\n logError(` Field: ${fieldName}`);\n logError(` Value: ${fieldValue}`);\n logError(` Error: ${err.message}\\n`);\n }\n\n // Re-throw with enhanced context\n throw new Error(`Failed to process field '${fieldName}' in ${entityName}: ${err.message}`);\n }\n }\n\n // Note: If we had deferred fields, we still continue to save the record\n // The deferred fields are not set, but other fields are. We'll queue for\n // re-processing after save succeeds.\n\n // Check if the record is actually dirty before considering it changed\n let isDirty = entity.Dirty;\n \n // Force dirty state if alwaysPush is enabled\n const alwaysPush = this.syncConfig?.push?.alwaysPush ?? false;\n if (alwaysPush && !isNew) {\n isDirty = true;\n }\n \n // Also check if file content has changed (for @file references)\n if (!isDirty && !isNew && record.sync) {\n const currentChecksum = await this.syncEngine.calculateChecksumWithFileContent(originalFields, entityDir);\n if (currentChecksum !== record.sync.checksum) {\n isDirty = true;\n if (options.verbose) {\n callbacks?.onLog?.(`š File content changed for ${entityName} record (checksum mismatch)`);\n }\n }\n }\n \n if (options.dryRun) {\n if (exists) {\n callbacks?.onLog?.(`[DRY RUN] Would update ${entityName} record`);\n return { status: 'updated' };\n } else {\n callbacks?.onLog?.(`[DRY RUN] Would create ${entityName} record`);\n return { status: 'created' };\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(entityName);\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 ${entityName} 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 with detailed error logging\n const recordName = entity.Get('Name');\n const entityRecordId = entity.Get('ID');\n \n let saveResult;\n try {\n // Pass IgnoreDirtyState option when alwaysPush is enabled\n const saveOptions = alwaysPush ? { IgnoreDirtyState: true } : undefined;\n saveResult = await entity.Save(saveOptions);\n } catch (saveError: any) {\n // Helper to log to both console and callbacks\n const logError = (msg: string) => {\n console.error(msg);\n callbacks?.onLog?.(msg);\n };\n\n logError(`\\nā SAVE EXCEPTION for ${entityName}`);\n logError(` Record ID: ${entityRecordId || 'NEW'}`);\n logError(` Record Name: ${recordName || 'N/A'}`);\n logError(` File Path: ${flattenedRecord.path}`);\n logError(` Error: ${saveError.message || saveError}`);\n\n // Check for specific error patterns\n if (saveError.message?.includes('Cannot insert the value NULL')) {\n logError(` Tip: A required field is NULL. Check the entity's required fields.`);\n } else if (saveError.message?.includes('FOREIGN KEY constraint')) {\n logError(` Tip: Foreign key constraint violation. Check that referenced records exist.`);\n } else if (saveError.message?.includes('duplicate key')) {\n logError(` Tip: Duplicate key violation. A record with these values already exists.`);\n } else if (saveError.message?.includes('Incorrect syntax')) {\n logError(` Tip: SQL syntax error. Check for special characters in field values.`);\n }\n\n // Log problematic field values for debugging\n logError(`\\n Failed entity field values:`);\n for (const field of entity.Fields) {\n const value = entity.Get(field.Name);\n if (value !== null && value !== undefined) {\n const displayValue = typeof value === 'string' && value.length > 100\n ? value.substring(0, 100) + '...'\n : value;\n logError(` ${field.Name}: ${displayValue}`);\n }\n }\n logError(''); // Empty line for readability\n throw saveError;\n }\n \n if (!saveResult) {\n // Helper to log to both console and callbacks\n const logError = (msg: string) => {\n console.error(msg);\n callbacks?.onLog?.(msg);\n };\n\n logError(`\\nā SAVE RETURNED FALSE for ${entityName}`);\n logError(` Record ID: ${entityRecordId || 'NEW'}`);\n logError(` Record Name: ${recordName || 'N/A'}`);\n logError(` File Path: ${flattenedRecord.path}`);\n\n // Log the LatestResult for debugging\n if (entity.LatestResult) {\n if (entity.LatestResult.Message) {\n logError(` Database Message: ${entity.LatestResult.Message}`);\n }\n if (entity.LatestResult.Errors && entity.LatestResult.Errors.length > 0) {\n logError(` Errors:`);\n entity.LatestResult.Errors.forEach((err: any, idx: number) => {\n const errorMsg = typeof err === 'string' ? err : (err?.message || JSON.stringify(err));\n logError(` ${idx + 1}. ${errorMsg}`);\n });\n }\n if ((entity.LatestResult as any).SQL) {\n // Don't log the full SQL as it might be huge, just indicate it's available\n logError(` SQL Statement: [Available - check entity.LatestResult.SQL if needed]`);\n }\n }\n\n // Log field values that might be problematic\n logError(`\\n Entity field values:`);\n for (const field of entity.Fields) {\n const value = entity.Get(field.Name);\n if (value !== null && value !== undefined) {\n const displayValue = typeof value === 'string' && value.length > 100\n ? value.substring(0, 100) + '...'\n : value;\n logError(` ${field.Name}: ${displayValue}`);\n }\n }\n logError(''); // Empty line for readability\n // Build detailed error information\n const entityInfo = this.syncEngine.getEntityInfo(entityName);\n const primaryKeyInfo: string[] = [];\n const fieldInfo: string[] = [];\n \n // Collect primary key information\n if (entityInfo) {\n for (const pk of entityInfo.PrimaryKeys) {\n const pkValue = entity.Get(pk.Name);\n primaryKeyInfo.push(`${pk.Name}=${this.formatFieldValue(pkValue)}`);\n }\n }\n \n // Collect field values that were being saved\n for (const [fieldName, fieldValue] of Object.entries(record.fields)) {\n const processedValue = entity.Get(fieldName);\n fieldInfo.push(`${fieldName}=${this.formatFieldValue(processedValue)}`);\n }\n \n // Get the actual error details from the entity\n const errorMessage = entity.LatestResult?.Message || 'Unknown error';\n const errorDetails = entity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || '';\n \n // Log detailed error information\n callbacks?.onError?.(`\\nā FATAL ERROR: Failed to save ${entityName} record`);\n callbacks?.onError?.(` Entity: ${entityName}`);\n if (primaryKeyInfo.length > 0) {\n callbacks?.onError?.(` Primary Key: {${primaryKeyInfo.join(', ')}}`);\n }\n callbacks?.onError?.(` Record Path: ${flattenedRecord.path}`);\n callbacks?.onError?.(` Is New Record: ${isNew}`);\n callbacks?.onError?.(` Field Values Being Saved:`);\n for (const field of fieldInfo) {\n callbacks?.onError?.(` - ${field}`);\n }\n callbacks?.onError?.(` SQL Error: ${errorMessage}`);\n if (errorDetails) {\n callbacks?.onError?.(` Additional Details: ${errorDetails}`);\n }\n \n // Check for common issues\n if (errorMessage.includes('conversion failed') || errorMessage.includes('GUID')) {\n callbacks?.onError?.(` ā ļø This appears to be a GUID/UUID format error. Check that all ID fields contain valid GUIDs.`);\n }\n if (errorMessage.includes('transaction')) {\n callbacks?.onError?.(` ā ļø Transaction error detected. The database transaction may be corrupted.`);\n }\n \n // Throw error to trigger rollback and stop processing\n throw new Error(`Failed to save ${entityName} record at ${flattenedRecord.path}: ${errorMessage}`);\n }\n \n // Add to batch context AFTER save so it has an ID for child @parent:ID references\n // Use the recordId (lookupKey) as the key so child records can find this parent\n batchContext.set(lookupKey, entity);\n\n // If we had deferred lookup errors, queue the entire record for re-processing\n // The record has been saved (without the deferred fields), so it exists in the DB.\n // In Phase 2.5, we'll re-run processFlattenedRecord with allowDefer=false to fill in the gaps.\n if (hasDeferrableLookupError && allowDefer && entityConfig) {\n this.deferredRecords.push({\n flattenedRecord,\n entityDir,\n entityConfig\n });\n\n if (options.verbose) {\n callbacks?.onLog?.(` š Queued ${entityName} for deferred processing (record saved, some fields pending)`);\n }\n\n // Return 'deferred' status - it's saved but incomplete\n // We don't return early here because we still want to update primaryKey and sync metadata\n }\n\n // Update primaryKey for new records\n if (isNew) {\n const entityInfo = this.syncEngine.getEntityInfo(entityName);\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 record.primaryKey = newPrimaryKey;\n }\n }\n \n // Only update sync metadata if the record was actually dirty (changed)\n if (isNew || isDirty) {\n record.sync = {\n lastModified: new Date().toISOString(),\n checksum: await this.syncEngine.calculateChecksumWithFileContent(originalFields, entityDir)\n };\n if (options.verbose) {\n callbacks?.onLog?.(` ā Updated sync metadata (record was ${isNew ? 'new' : 'changed'})`);\n }\n } else if (options.verbose) {\n callbacks?.onLog?.(` - Skipped sync metadata update (no changes detected)`);\n }\n \n // Restore original field values to preserve @ references\n record.fields = originalFields;\n\n // Return appropriate status\n // If we had deferred lookups, return 'deferred' to indicate partial save\n // The record is saved but will be re-processed in Phase 2.5\n if (hasDeferrableLookupError && allowDefer) {\n return {\n status: 'deferred',\n isDuplicate: false\n };\n }\n\n return {\n status: isNew ? 'created' : (isDirty ? 'updated' : 'unchanged'),\n isDuplicate: false\n };\n }\n\n private formatFieldValue(value: any): string {\n if (value === null || value === undefined) return 'null';\n if (typeof value === 'string') {\n // Truncate long strings and show quotes\n if (value.length > 50) {\n return `\"${value.substring(0, 47)}...\"`;\n }\n return `\"${value}\"`;\n }\n if (typeof value === 'object') {\n const str = JSON.stringify(value);\n return str.length > 50 ? `\"${str.substring(0, 47)}...\"` : `\"${str}\"`;\n }\n return String(value);\n }\n \n private async processDeleteRecord(\n flattenedRecord: FlattenedRecord,\n _entityDir: string,\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<{ status: 'deleted' | 'skipped' | 'unchanged'; isDuplicate?: boolean }> {\n const { record, entityName } = flattenedRecord;\n \n // Validate that we have a primary key for deletion\n if (!record.primaryKey || Object.keys(record.primaryKey).length === 0) {\n throw new Error(`Cannot delete ${entityName} record without primaryKey. Please specify primaryKey fields.`);\n }\n \n // Load the entity to check if it exists in the target database\n const existingEntity = await this.syncEngine.loadEntity(entityName, record.primaryKey);\n\n // Check if the deletion has already been processed\n if (record.deleteRecord?.deletedAt) {\n // Verify if record still exists in THIS database\n if (!existingEntity) {\n if (options.verbose) {\n callbacks?.onLog?.(` ā¹ļø Record already deleted on ${record.deleteRecord.deletedAt} and confirmed absent from database`);\n }\n return { status: 'unchanged', isDuplicate: false };\n }\n\n // Record has deletedAt timestamp but still exists in this database\n // This can happen when syncing to a different database\n if (options.verbose) {\n callbacks?.onLog?.(` ā¹ļø Record marked as deleted on ${record.deleteRecord.deletedAt}, but still exists in this database. Re-deleting...`);\n }\n // Fall through to deletion logic\n }\n \n if (!existingEntity) {\n const pkDisplay = Object.entries(record.primaryKey)\n .map(([key, value]) => `${key}=${value}`)\n .join(', ');\n \n const warning = `Record not found for deletion: ${entityName} with primaryKey {${pkDisplay}}`;\n this.warnings.push(warning);\n callbacks?.onWarn?.(warning);\n \n // Mark as deleted anyway since it doesn't exist\n if (!record.deleteRecord) {\n record.deleteRecord = { delete: true };\n }\n record.deleteRecord.deletedAt = undefined; // Indicate it was not found\n record.deleteRecord.notFound = true;\n \n return { status: 'skipped', isDuplicate: false };\n }\n \n // Log the deletion\n const entityInfo = this.syncEngine.getEntityInfo(entityName);\n const primaryKeyDisplay: string[] = [];\n if (entityInfo) {\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKeyDisplay.push(`${pk.Name}: ${existingEntity.Get(pk.Name)}`);\n }\n }\n \n callbacks?.onLog?.(`šļø Deleting ${entityName} record:`);\n if (primaryKeyDisplay.length > 0) {\n callbacks?.onLog?.(` Primary Key: ${primaryKeyDisplay.join(', ')}`);\n }\n \n // Additional info if available\n const recordName = existingEntity.Get('Name');\n if (recordName) {\n callbacks?.onLog?.(` Name: ${recordName}`);\n }\n \n if (options.dryRun) {\n callbacks?.onLog?.(`[DRY RUN] Would delete ${entityName} record`);\n return { status: 'deleted', isDuplicate: false };\n }\n \n // Delete the record\n try {\n const deleteResult = await existingEntity.Delete();\n \n if (!deleteResult) {\n // Check the LatestResult for error details\n const errorMessage = existingEntity.LatestResult?.Message || 'Unknown error';\n const errorDetails = existingEntity.LatestResult?.Errors?.map(err => \n typeof err === 'string' ? err : (err?.message || JSON.stringify(err))\n )?.join(', ') || '';\n \n callbacks?.onError?.(`\\nā Failed to delete ${entityName} record`);\n callbacks?.onError?.(` Primary Key: {${primaryKeyDisplay.join(', ')}}`);\n callbacks?.onError?.(` Error: ${errorMessage}`);\n if (errorDetails) {\n callbacks?.onError?.(` Details: ${errorDetails}`);\n }\n \n throw new Error(`Failed to delete ${entityName} record: ${errorMessage}`);\n }\n \n // Set deletedAt timestamp after successful deletion\n if (!record.deleteRecord) {\n record.deleteRecord = { delete: true };\n }\n record.deleteRecord.deletedAt = new Date().toISOString();\n\n // Update the corresponding record in deferred file writes\n this.updateDeferredFileRecord(flattenedRecord);\n\n if (options.verbose) {\n callbacks?.onLog?.(` ā Successfully deleted ${entityName} record`);\n }\n\n return { status: 'deleted', isDuplicate: false };\n \n } catch (deleteError: any) {\n console.error(`\\nā DELETE EXCEPTION for ${entityName}`);\n console.error(` Primary Key: {${primaryKeyDisplay.join(', ')}}`);\n console.error(` Error: ${deleteError.message || deleteError}`);\n \n // Check for specific error patterns\n if (deleteError.message?.includes('FOREIGN KEY constraint')) {\n console.error(` Tip: This record is referenced by other records and cannot be deleted.`);\n console.error(` Consider deleting dependent records first.`);\n } else if (deleteError.message?.includes('permission')) {\n console.error(` Tip: You may not have permission to delete this record.`);\n }\n \n throw deleteError;\n }\n }\n \n /**\n * Prompt user for confirmation before proceeding with push operation\n * This happens after deletion audit but before any database operations\n */\n private async promptForConfirmation(\n deletionAudit: DeletionAudit | null,\n callbacks?: PushCallbacks\n ): Promise<boolean> {\n // Build confirmation message\n const messages: string[] = [];\n messages.push('\\n' + 'ā'.repeat(80));\n messages.push('CONFIRMATION REQUIRED');\n messages.push('ā'.repeat(80));\n messages.push('');\n messages.push('This operation will:');\n messages.push(' ⢠Create new records');\n messages.push(' ⢠Update existing records');\n\n if (deletionAudit) {\n const totalDeletes = deletionAudit.explicitDeletes.size + deletionAudit.implicitDeletes.size;\n messages.push(` ⢠Delete ${totalDeletes} record${totalDeletes > 1 ? 's' : ''} (${deletionAudit.explicitDeletes.size} explicit, ${deletionAudit.implicitDeletes.size} implicit)`);\n\n if (deletionAudit.orphanedReferences.length > 0) {\n messages.push(` ā ļø ${deletionAudit.orphanedReferences.length} database-only reference${deletionAudit.orphanedReferences.length > 1 ? 's' : ''} detected (may cause FK errors)`);\n }\n } else {\n messages.push(' ⢠No deletions');\n }\n\n messages.push('');\n messages.push('All operations will occur within a transaction and can be rolled back on error.');\n messages.push('');\n messages.push('ā'.repeat(80));\n messages.push('');\n\n // Display messages\n for (const msg of messages) {\n callbacks?.onLog?.(msg);\n }\n\n // Use onConfirm callback if available, otherwise throw error\n if (callbacks?.onConfirm) {\n const confirmed = await callbacks.onConfirm('Do you want to proceed? (yes/no)');\n return confirmed;\n } else {\n // No confirmation callback provided - this shouldn't happen in interactive mode\n callbacks?.onWarn?.('ā ļø No confirmation callback provided. Proceeding automatically.');\n callbacks?.onWarn?.(' To enable confirmation prompts, provide an onConfirm callback.\\n');\n return true;\n }\n }\n\n /**\n * Audit all deletions across all metadata files\n * This pre-processes all records to identify deletion dependencies and order\n */\n private async auditAllDeletions(\n entityDirs: string[],\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<DeletionAudit | null> {\n // OPTIMIZATION: Quick scan to check if ANY deletions exist before doing expensive loading\n let hasAnyDeletions = false;\n\n for (const entityDir of entityDirs) {\n if (hasAnyDeletions) break; // Early exit once we find any deletion\n\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n continue;\n }\n\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 // Quick scan for delete directives without full processing\n for (const filePath of files) {\n try {\n const content = await fs.readFile(filePath, 'utf-8');\n // Fast string check for delete directives\n if (content.includes('\"delete\"') && content.includes('true')) {\n // More precise check - parse JSON to confirm\n const data = JSON.parse(content);\n const records = Array.isArray(data) ? data : [data];\n\n const hasDelete = records.some((r: RecordData) => r.deleteRecord?.delete === true);\n if (hasDelete) {\n hasAnyDeletions = true;\n break;\n }\n }\n } catch (error) {\n // Ignore errors in quick scan\n }\n }\n }\n\n // If no deletions found, skip all processing\n if (!hasAnyDeletions) {\n if (options.verbose) {\n callbacks?.onLog?.('No deletion operations found - skipping deletion audit.\\n');\n }\n return null;\n }\n\n // Deletions exist - proceed with full audit\n callbacks?.onLog?.('\\nš Analyzing deletion operations...\\n');\n\n // Load all records from all entity directories\n const allRecords: FlattenedRecord[] = [];\n const analyzer = new RecordDependencyAnalyzer();\n\n for (const entityDir of entityDirs) {\n const entityConfig = await loadEntityConfig(entityDir);\n if (!entityConfig) {\n continue;\n }\n\n // Find all JSON files\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 // Load and flatten records from each file\n for (const filePath of files) {\n try {\n const rawFileData = await fs.readJson(filePath);\n\n // Handle @include directives if present\n let fileData = rawFileData;\n const jsonString = JSON.stringify(rawFileData);\n const hasIncludes = jsonString.includes('\"@include\"') || jsonString.includes('\"@include.');\n\n if (hasIncludes) {\n const jsonPreprocessor = new JsonPreprocessor();\n fileData = await jsonPreprocessor.processFile(filePath);\n }\n\n const records = Array.isArray(fileData) ? fileData : [fileData];\n\n // Analyze and flatten records\n const analysisResult = await analyzer.analyzeFileRecords(records, entityConfig.entity);\n allRecords.push(...analysisResult.sortedRecords);\n } catch (error) {\n if (options.verbose) {\n callbacks?.onLog?.(`Warning: Could not load ${filePath}: ${error}`);\n }\n }\n }\n }\n\n // Perform comprehensive deletion audit\n const md = new Metadata();\n const auditor = new DeletionAuditor(\n md,\n this.contextUser\n );\n\n const audit = await auditor.auditDeletions(allRecords);\n\n // Check if any records actually need deletion\n const totalMarkedForDeletion = audit.explicitDeletes.size + audit.implicitDeletes.size;\n const needDeletion = audit.deletionLevels.flat().length; // Only records that exist in DB\n\n if (needDeletion === 0) {\n // All records marked for deletion are already deleted\n if (options.verbose && totalMarkedForDeletion > 0) {\n callbacks?.onLog?.(`ā¹ļø All ${totalMarkedForDeletion} record${totalMarkedForDeletion > 1 ? 's' : ''} marked for deletion are already deleted from the database.`);\n callbacks?.onLog?.(' No deletion operations needed.\\n');\n }\n return null; // Signal that no deletion audit is needed\n }\n\n // Generate and display report (only if records need deletion)\n const report = DeletionReportGenerator.generateReport(audit, options.verbose);\n callbacks?.onLog?.(report);\n callbacks?.onLog?.('');\n\n // Check for blocking issues (only circular dependencies block execution)\n if (audit.circularDependencies.length > 0) {\n const error = `Cannot proceed: ${audit.circularDependencies.length} circular ${audit.circularDependencies.length > 1 ? 'dependencies' : 'dependency'} detected.\\n` +\n `Please resolve the circular dependencies before attempting deletion.`;\n callbacks?.onError?.(error);\n throw new Error(error);\n }\n\n // Warn about database-only references (non-blocking)\n // These may be handled by cascade delete rules at the database level\n if (audit.orphanedReferences.length > 0) {\n callbacks?.onWarn?.(`ā ļø WARNING: ${audit.orphanedReferences.length} database-only reference${audit.orphanedReferences.length > 1 ? 's' : ''} found.`);\n callbacks?.onWarn?.(` These records exist in the database but not in metadata.`);\n callbacks?.onWarn?.(` If your database has cascade delete rules, these will be handled automatically.`);\n callbacks?.onWarn?.(` Otherwise, deletion may fail with FK constraint errors.\\n`);\n }\n\n // Warn about implicit deletes\n if (audit.implicitDeletes.size > 0) {\n callbacks?.onWarn?.('ā ļø WARNING: Implicit deletions will occur.');\n callbacks?.onWarn?.(` ${audit.implicitDeletes.size} record${audit.implicitDeletes.size > 1 ? 's' : ''} will be deleted due to FK constraints.`);\n callbacks?.onWarn?.(' Review the deletion audit report above.\\n');\n }\n\n return audit;\n }\n\n /**\n * Process deletions in reverse dependency order\n */\n private async processDeletionsFromAudit(\n audit: DeletionAudit,\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<{ deleted: number; errors: number }> {\n let deleted = 0;\n let errors = 0;\n\n callbacks?.onLog?.('šļø Processing deletions in reverse dependency order...\\n');\n\n // Process deletion levels in order (highest dependency level first)\n for (let i = 0; i < audit.deletionLevels.length; i++) {\n const level = audit.deletionLevels[i];\n const levelNumber = audit.deletionLevels.length - i; // Reverse numbering for clarity\n\n callbacks?.onLog?.(` Level ${levelNumber}: Deleting ${level.length} record${level.length > 1 ? 's' : ''}...`);\n\n // Process records within same level (can be done in parallel in the future)\n for (const record of level) {\n try {\n const result = await this.processDeleteRecord(record, '', options, callbacks);\n\n if (result.status === 'deleted') {\n deleted++;\n } else if (result.status === 'skipped') {\n // Record not found, already handled in processDeleteRecord\n }\n } catch (error) {\n callbacks?.onError?.(` Failed to delete ${record.entityName}: ${error}`);\n errors++;\n throw error; // Fail fast on first deletion error\n }\n }\n }\n\n if (deleted > 0) {\n callbacks?.onLog?.(` ā Successfully deleted ${deleted} record${deleted > 1 ? 's' : ''}\\n`);\n }\n\n return { deleted, errors };\n }\n\n /**\n * Recursively check if any records in an array (including nested relatedEntities) have deletions\n */\n private hasAnyDeletions(records: RecordData[]): boolean {\n for (const record of records) {\n // Check this record\n if (record.deleteRecord?.delete === true) {\n return true;\n }\n\n // Check nested related entities recursively\n if (record.relatedEntities) {\n for (const relatedRecords of Object.values(record.relatedEntities)) {\n if (Array.isArray(relatedRecords)) {\n if (this.hasAnyDeletions(relatedRecords)) {\n return true;\n }\n }\n }\n }\n }\n\n return false;\n }\n\n /**\n * Process deferred records that had lookup failures during initial processing.\n * Called in Phase 2.5 after all records are created/updated but before commit.\n * This handles circular dependencies where records reference each other.\n *\n * Re-runs processFlattenedRecord with allowDefer=false, which processes the\n * entire record exactly as in the initial pass. Now that all records exist,\n * the lookups should succeed.\n *\n * @param options - Push options\n * @param callbacks - Callbacks for progress/error reporting\n * @returns Object with created, updated, and errors counts\n */\n private async processDeferredRecords(\n options: PushOptions,\n callbacks?: PushCallbacks\n ): Promise<{ created: number; updated: number; errors: number }> {\n if (this.deferredRecords.length === 0) {\n return { created: 0, updated: 0, errors: 0 };\n }\n\n callbacks?.onLog?.(`\\nā³ Processing ${this.deferredRecords.length} deferred record${this.deferredRecords.length > 1 ? 's' : ''}...`);\n\n let created = 0;\n let updated = 0;\n let errors = 0;\n\n // Create a fresh batch context for deferred processing\n // Records are in DB now, so this is mainly for tracking within this phase\n const batchContext = new Map<string, BaseEntity>();\n\n for (const deferred of this.deferredRecords) {\n const { flattenedRecord, entityDir, entityConfig } = deferred;\n const entityName = flattenedRecord.entityName;\n const recordId = flattenedRecord.record.primaryKey\n ? Object.entries(flattenedRecord.record.primaryKey).map(([k, v]) => `${k}=${v}`).join(', ')\n : (flattenedRecord.record.fields.Name || 'NEW');\n\n try {\n // Re-run processFlattenedRecord with allowDefer=false\n // This ensures we use the exact same processing logic\n const result = await this.processFlattenedRecord(\n flattenedRecord,\n entityDir,\n options,\n batchContext,\n callbacks,\n entityConfig,\n false // allowDefer=false - must succeed or fail, no re-deferring\n );\n\n if (result.status === 'created') {\n created++;\n callbacks?.onLog?.(` ā ${entityName} (${recordId}) - created`);\n } else if (result.status === 'updated') {\n updated++;\n callbacks?.onLog?.(` ā ${entityName} (${recordId}) - updated`);\n } else if (result.status === 'unchanged') {\n callbacks?.onLog?.(` - ${entityName} (${recordId}) - unchanged`);\n }\n\n } catch (error) {\n const err = error as Error;\n\n callbacks?.onError?.(\n ` ā Failed to process deferred record: ${entityName} (${recordId})`\n );\n callbacks?.onError?.(\n ` Error: ${err.message}`\n );\n callbacks?.onError?.(\n ` Tip: Ensure all referenced records exist or remove the ?allowDefer flag`\n );\n\n errors++;\n }\n }\n\n // Summary\n callbacks?.onLog?.('');\n const total = created + updated;\n if (total > 0) {\n callbacks?.onLog?.(` ā Resolved ${total} deferred record${total > 1 ? 's' : ''} (${created} created, ${updated} updated)`);\n }\n if (errors > 0) {\n callbacks?.onLog?.(` ā Failed to resolve ${errors} deferred record${errors > 1 ? 's' : ''}`);\n }\n callbacks?.onLog?.('');\n\n return { created, updated, errors };\n }\n\n /**\n * Write all deferred files with updated deletion timestamps\n * Called in Phase 3 after all deletions complete successfully\n */\n private async writeDeferredFiles(options: PushOptions, callbacks?: PushCallbacks): Promise<void> {\n if (this.deferredFileWrites.size === 0) {\n return;\n }\n\n if (options.verbose) {\n callbacks?.onLog?.(`\\nš Writing ${this.deferredFileWrites.size} file${this.deferredFileWrites.size > 1 ? 's' : ''} with deletion timestamps...`);\n }\n\n for (const deferredWrite of this.deferredFileWrites.values()) {\n try {\n if (deferredWrite.isArray) {\n await JsonWriteHelper.writeOrderedRecordData(deferredWrite.filePath, deferredWrite.records);\n } else {\n await JsonWriteHelper.writeOrderedRecordData(deferredWrite.filePath, deferredWrite.records[0]);\n }\n } catch (error) {\n callbacks?.onWarn?.(` ā ļø Failed to write ${deferredWrite.filePath}: ${error}`);\n }\n }\n\n if (options.verbose) {\n callbacks?.onLog?.(` ā Completed writing deferred files\\n`);\n }\n }\n\n /**\n * Update a record in deferred file writes after successful deletion\n * Finds the matching RecordData by primary key and updates its deleteRecord section\n * Searches recursively through nested relatedEntities\n */\n private updateDeferredFileRecord(flattenedRecord: FlattenedRecord): void {\n const { record } = flattenedRecord;\n\n // Search through all deferred files to find the matching record\n for (const deferredWrite of this.deferredFileWrites.values()) {\n for (const fileRecord of deferredWrite.records) {\n // Search this record and all nested related entities recursively\n if (this.findAndUpdateRecord(fileRecord, record, flattenedRecord.entityName)) {\n return; // Found and updated\n }\n }\n }\n }\n\n /**\n * Recursively search a RecordData and its relatedEntities for a matching record\n * Updates the matching record's deleteRecord timestamp\n */\n private findAndUpdateRecord(\n searchIn: RecordData,\n targetRecord: RecordData,\n targetEntityName: string\n ): boolean {\n // Check if this is the matching record\n if (this.recordsMatch(searchIn, targetRecord, targetEntityName)) {\n // Update the deleteRecord section with the timestamp\n if (!searchIn.deleteRecord) {\n searchIn.deleteRecord = { delete: true };\n }\n searchIn.deleteRecord.deletedAt = targetRecord.deleteRecord!.deletedAt;\n return true; // Found and updated\n }\n\n // Search through related entities recursively\n if (searchIn.relatedEntities) {\n for (const relatedRecords of Object.values(searchIn.relatedEntities)) {\n if (Array.isArray(relatedRecords)) {\n for (const relatedRecord of relatedRecords) {\n if (this.findAndUpdateRecord(relatedRecord, targetRecord, targetEntityName)) {\n return true; // Found in nested record\n }\n }\n }\n }\n }\n\n return false; // Not found in this branch\n }\n\n /**\n * Check if two RecordData objects represent the same record\n * Compares primary keys and entity context\n */\n private recordsMatch(record1: RecordData, record2: RecordData, entityName: string): boolean {\n // Must both have primary keys\n if (!record1.primaryKey || !record2.primaryKey) {\n return false;\n }\n\n // Must have same primary key fields\n const pk1Keys = Object.keys(record1.primaryKey);\n const pk2Keys = Object.keys(record2.primaryKey);\n\n if (pk1Keys.length !== pk2Keys.length) {\n return false;\n }\n\n // All primary key values must match\n return pk1Keys.every(key =>\n record1.primaryKey![key] === record2.primaryKey![key]\n );\n }\n\n private _buildBatchContextKey(entityName: string, record: RecordData): string {\n // Build a unique key for the batch context based on entity name and identifying fields\n const keyParts = [entityName];\n\n // Use primary key if available\n if (record.primaryKey) {\n for (const [field, value] of Object.entries(record.primaryKey)) {\n keyParts.push(`${field}=${value}`);\n }\n } else {\n // Use a combination of important fields as fallback\n const identifyingFields = ['Name', 'ID', 'Code', 'Email'];\n for (const field of identifyingFields) {\n if (record.fields[field]) {\n keyParts.push(`${field}=${record.fields[field]}`);\n }\n }\n }\n\n return keyParts.join('|');\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/metadata-sync",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.122.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.122.0",
|
|
30
|
+
"@memberjunction/core-entities": "2.122.0",
|
|
31
|
+
"@memberjunction/core-entities-server": "2.122.0",
|
|
32
|
+
"@memberjunction/global": "2.122.0",
|
|
33
|
+
"@memberjunction/sqlserver-dataprovider": "2.122.0",
|
|
34
|
+
"@memberjunction/graphql-dataprovider": "2.122.0",
|
|
35
35
|
"chokidar": "^3.6.0",
|
|
36
36
|
"cosmiconfig": "9.0.0",
|
|
37
37
|
"dotenv": "16.4.5",
|