@memberjunction/metadata-sync 2.46.0 → 2.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/pull/index.ts"],"names":[],"mappings":";;;;;AAAA,sCAA6C;AAC7C,wDAA0B;AAC1B,gDAAwB;AACxB,+CAA2C;AAC3C,8DAA8B;AAC9B,yCAAmF;AACnF,uDAA+D;AAC/D,+CAA+C;AAC/C,6DAA8F;AAE9F,MAAqB,IAAK,SAAQ,cAAO;IACvC,MAAM,CAAC,WAAW,GAAG,4CAA4C,CAAC;IAElE,MAAM,CAAC,QAAQ,GAAG;QAChB,2DAA2D;QAC3D,uGAAuG;KACxG,CAAC;IAEF,MAAM,CAAC,KAAK,GAAG;QACb,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC5E,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;QACvF,SAAS,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC;KAChG,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,IAAA,qBAAG,GAAE,CAAC;QAEtB,IAAI,CAAC;YACH,iBAAiB;YACjB,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACvC,MAAM,QAAQ,GAAG,IAAA,qBAAY,GAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,IAAI,CAAC,KAAK,CAAC,mEAAmE,CAAC,CAAC;YAClF,CAAC;YAED,2BAA2B;YAC3B,MAAM,QAAQ,GAAG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O,eAAe,CAAC,YAAiB,EAAE,KAAU;QACnD,qDAAqD;QACrD,+CAA+C;QAC/C,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACnE,IAAI,UAAU,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3D,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;;AAzXH,uBA0XC","sourcesContent":["import { Command, Flags } from '@oclif/core';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { select } from '@inquirer/prompts';\nimport ora from 'ora-classic';\nimport { loadMJConfig, loadEntityConfig, RelatedEntityConfig } from '../../config';\nimport { SyncEngine, RecordData } from '../../lib/sync-engine';\nimport { RunView } from '@memberjunction/core';\nimport { getSystemUser, initializeProvider, cleanupProvider } from '../../lib/provider-utils';\n\nexport default class Pull extends Command {\n static description = 'Pull metadata from database to local files';\n \n static examples = [\n `<%= config.bin %> <%= command.id %> --entity=\"AI Prompts\"`,\n `<%= config.bin %> <%= command.id %> --entity=\"AI Prompts\" --filter=\"CategoryID='customer-service-id'\"`,\n ];\n \n static flags = {\n entity: Flags.string({ description: 'Entity name to pull', required: true }),\n filter: Flags.string({ description: 'Additional filter for pulling specific records' }),\n 'dry-run': Flags.boolean({ description: 'Show what would be pulled without actually pulling' }),\n };\n \n async run(): Promise<void> {\n const { flags } = await this.parse(Pull);\n const spinner = ora();\n \n try {\n // Load MJ config\n spinner.start('Loading configuration');\n const mjConfig = loadMJConfig();\n if (!mjConfig) {\n this.error('No mj.config.cjs found in current directory or parent directories');\n }\n \n // Initialize data provider\n const provider = await initializeProvider(mjConfig);\n \n // Initialize sync engine\n const syncEngine = new SyncEngine(getSystemUser());\n await syncEngine.initialize();\n spinner.succeed('Configuration loaded');\n \n // Find entity directory\n const entityDirs = await this.findEntityDirectories(flags.entity);\n \n if (entityDirs.length === 0) {\n this.error(`No directory found for entity \"${flags.entity}\". Run \"mj-sync init\" first.`);\n }\n \n let targetDir: string;\n if (entityDirs.length === 1) {\n targetDir = entityDirs[0];\n } else {\n // Multiple directories found, ask user\n targetDir = await select({\n message: `Multiple directories found for entity \"${flags.entity}\". Which one to use?`,\n choices: entityDirs.map(dir => ({ name: dir, value: dir }))\n });\n }\n \n const entityConfig = await loadEntityConfig(targetDir);\n if (!entityConfig) {\n this.error(`Invalid entity configuration in ${targetDir}`);\n }\n \n // Pull records\n spinner.start(`Pulling ${flags.entity} records`);\n const rv = new RunView();\n \n let filter = '';\n if (flags.filter) {\n filter = flags.filter;\n } else if (entityConfig.pull?.filter) {\n filter = entityConfig.pull.filter;\n }\n \n const result = await rv.RunView({\n EntityName: flags.entity,\n ExtraFilter: filter\n }, getSystemUser());\n \n if (!result.Success) {\n this.error(`Failed to pull records: ${result.ErrorMessage}`);\n }\n \n spinner.succeed(`Found ${result.Results.length} records`);\n \n if (flags['dry-run']) {\n this.log(`\\nDry run mode - would pull ${result.Results.length} records to ${targetDir}`);\n return;\n }\n \n // Process each record\n const entityInfo = syncEngine.getEntityInfo(flags.entity);\n if (!entityInfo) {\n this.error(`Entity information not found for: ${flags.entity}`);\n }\n \n spinner.start('Processing records');\n let processed = 0;\n \n for (const record of result.Results) {\n try {\n // Build primary key\n const primaryKey: Record<string, any> = {};\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKey[pk.Name] = record[pk.Name];\n }\n \n // Process record\n await this.processRecord(record, primaryKey, targetDir, entityConfig, syncEngine);\n processed++;\n \n spinner.text = `Processing records (${processed}/${result.Results.length})`;\n } catch (error) {\n this.warn(`Failed to process record: ${(error as any).message || error}`);\n }\n }\n \n spinner.succeed(`Pulled ${processed} records to ${targetDir}`);\n \n } catch (error) {\n spinner.fail('Pull failed');\n this.error(error as Error);\n } finally {\n // Clean up database connection\n await cleanupProvider();\n }\n }\n \n private async findEntityDirectories(entityName: string): Promise<string[]> {\n const dirs: string[] = [];\n \n // Search for directories with matching entity config\n const searchDirs = async (dir: string) => {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (entry.isDirectory()) {\n const fullPath = path.join(dir, entry.name);\n const config = await loadEntityConfig(fullPath);\n \n if (config && config.entity === entityName) {\n dirs.push(fullPath);\n } else {\n // Recurse\n await searchDirs(fullPath);\n }\n }\n }\n };\n \n await searchDirs(process.cwd());\n return dirs;\n }\n \n private async processRecord(\n record: any, \n primaryKey: Record<string, any>,\n targetDir: string, \n entityConfig: any,\n syncEngine: SyncEngine\n ): Promise<void> {\n // Build record data\n const recordData: RecordData = {\n primaryKey: primaryKey,\n fields: {},\n sync: {\n lastModified: new Date().toISOString(),\n checksum: ''\n }\n };\n \n // Process fields\n for (const [fieldName, fieldValue] of Object.entries(record)) {\n // Skip primary key fields\n if (primaryKey[fieldName] !== undefined) {\n continue;\n }\n \n // Skip internal fields\n if (fieldName.startsWith('__mj_')) {\n continue;\n }\n \n // Check if this is an external file field\n if (await this.shouldExternalizeField(fieldName, fieldValue, entityConfig)) {\n const fileName = await this.createExternalFile(\n targetDir,\n primaryKey,\n fieldName,\n String(fieldValue)\n );\n recordData.fields[fieldName] = `@file:${fileName}`;\n } else {\n recordData.fields[fieldName] = fieldValue;\n }\n }\n \n // Pull related entities if configured\n if (entityConfig.pull?.relatedEntities) {\n recordData.relatedEntities = await this.pullRelatedEntities(\n record,\n entityConfig.pull.relatedEntities,\n syncEngine\n );\n }\n \n // Calculate checksum\n recordData.sync!.checksum = syncEngine.calculateChecksum(recordData.fields);\n \n // Determine file path\n const fileName = this.buildFileName(primaryKey, entityConfig);\n const filePath = path.join(targetDir, fileName);\n \n // Write JSON file\n await fs.writeJson(filePath, recordData, { spaces: 2 });\n }\n \n private async shouldExternalizeField(\n fieldName: string, \n fieldValue: any,\n entityConfig: any\n ): Promise<boolean> {\n // Only externalize string fields with significant content\n if (typeof fieldValue !== 'string') {\n return false;\n }\n \n // Check if it's a known large text field\n const largeTextFields = ['Prompt', 'Template', 'Notes', 'Description', \n 'Content', 'Body', 'Text', 'HTML', 'SQL'];\n \n if (largeTextFields.some(f => fieldName.toLowerCase().includes(f.toLowerCase()))) {\n // Only externalize if content is substantial (more than 100 chars or has newlines)\n return fieldValue.length > 100 || fieldValue.includes('\\n');\n }\n \n return false;\n }\n \n private async createExternalFile(\n targetDir: string,\n primaryKey: Record<string, any>,\n fieldName: string,\n content: string\n ): Promise<string> {\n // Determine file extension based on field name and content\n let extension = '.txt';\n \n if (fieldName.toLowerCase().includes('prompt')) {\n extension = '.md';\n } else if (fieldName.toLowerCase().includes('template')) {\n if (content.includes('<html') || content.includes('<!DOCTYPE')) {\n extension = '.html';\n } else if (content.includes('{{') || content.includes('{%')) {\n extension = '.liquid';\n }\n } else if (fieldName.toLowerCase().includes('sql')) {\n extension = '.sql';\n } else if (fieldName.toLowerCase().includes('notes') || fieldName.toLowerCase().includes('description')) {\n extension = '.md';\n }\n \n const baseFileName = this.buildFileName(primaryKey, null).replace('.json', '');\n const fileName = `${baseFileName}.${fieldName.toLowerCase()}${extension}`;\n const filePath = path.join(targetDir, fileName);\n \n await fs.writeFile(filePath, content, 'utf-8');\n \n return fileName;\n }\n \n private buildFileName(primaryKey: Record<string, any>, entityConfig: any): string {\n // Use primary key values to build filename\n const keys = Object.values(primaryKey);\n \n if (keys.length === 1 && typeof keys[0] === 'string') {\n // Single string key - use as base if it's a guid\n const key = keys[0];\n if (key.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)) {\n // It's a GUID, use first 8 chars\n return `${key.substring(0, 8)}.json`;\n }\n // Use the whole key if not too long\n if (key.length <= 50) {\n return `${key.replace(/[^a-zA-Z0-9-_]/g, '_')}.json`;\n }\n }\n \n // Multiple keys or numeric - create composite name\n return keys.map(k => String(k).replace(/[^a-zA-Z0-9-_]/g, '_')).join('-') + '.json';\n }\n \n private async pullRelatedEntities(\n parentRecord: any,\n relatedConfig: Record<string, RelatedEntityConfig>,\n syncEngine: SyncEngine\n ): Promise<Record<string, RecordData[]>> {\n const relatedEntities: Record<string, RecordData[]> = {};\n \n for (const [key, config] of Object.entries(relatedConfig)) {\n try {\n // Get the parent's primary key value\n const parentKeyValue = parentRecord[config.foreignKey];\n if (!parentKeyValue) {\n continue; // Skip if parent doesn't have the foreign key field\n }\n \n // Build filter for related records\n let filter = `${config.foreignKey} = '${String(parentKeyValue).replace(/'/g, \"''\")}'`;\n if (config.filter) {\n filter += ` AND (${config.filter})`;\n }\n \n // Pull related records\n const rv = new RunView();\n const result = await rv.RunView({\n EntityName: config.entity,\n ExtraFilter: filter\n }, getSystemUser());\n \n if (!result.Success) {\n this.warn(`Failed to pull related ${config.entity}: ${result.ErrorMessage}`);\n continue;\n }\n \n // Process each related record\n const relatedRecords: RecordData[] = [];\n for (const relatedRecord of result.Results) {\n const recordData: RecordData = {\n fields: {}\n };\n \n // Process fields, omitting the foreign key since it will be set via @parent\n for (const [fieldName, fieldValue] of Object.entries(relatedRecord)) {\n // Skip internal fields\n if (fieldName.startsWith('__mj_')) {\n continue;\n }\n \n // Convert foreign key reference to @parent\n if (fieldName === config.foreignKey) {\n const parentFieldName = this.findParentField(parentRecord, parentKeyValue);\n if (parentFieldName) {\n recordData.fields[fieldName] = `@parent:${parentFieldName}`;\n }\n continue;\n }\n \n recordData.fields[fieldName] = fieldValue;\n }\n \n // Pull nested related entities if configured\n if (config.relatedEntities) {\n recordData.relatedEntities = await this.pullRelatedEntities(\n relatedRecord,\n config.relatedEntities,\n syncEngine\n );\n }\n \n relatedRecords.push(recordData);\n }\n \n if (relatedRecords.length > 0) {\n relatedEntities[key] = relatedRecords;\n }\n } catch (error) {\n this.warn(`Error pulling related ${key}: ${error}`);\n }\n }\n \n return relatedEntities;\n }\n \n private findParentField(parentRecord: any, value: any): string | null {\n // Find which field in the parent contains this value\n // Typically this will be the primary key field\n for (const [fieldName, fieldValue] of Object.entries(parentRecord)) {\n if (fieldValue === value && !fieldName.startsWith('__mj_')) {\n return fieldName;\n }\n }\n return null;\n }\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/pull/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;AAEH,sCAA6C;AAC7C,wDAA0B;AAC1B,gDAAwB;AACxB,+CAA2C;AAC3C,8DAA8B;AAC9B,yCAAmF;AAEnF,+CAAqE;AACrE,6DAA8F;AAC9F,6DAAyD;AACzD,mEAA6E;AAE7E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAqB,IAAK,SAAQ,cAAO;IACvC,MAAM,CAAC,WAAW,GAAG,4CAA4C,CAAC;IAElE,MAAM,CAAC,QAAQ,GAAG;QAChB,2DAA2D;QAC3D,uGAAuG;KACxG,CAAC;IAEF,MAAM,CAAC,KAAK,GAAG;QACb,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC5E,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;QACvF,SAAS,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC;QAC/F,YAAY,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;QAC5G,OAAO,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;KAC3E,CAAC;IAEF,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,IAAA,qBAAG,GAAE,CAAC;QAEtB,IAAI,CAAC;YACH,mDAAmD;YACnD,OAAO,CAAC,KAA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AAE,aAAsB;QACjE,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,IAAI,UAAU,CAAC,CAAC;QAE9D,iCAAiC;QACjC,MAAM,kBAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAE9B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACjE,oEAAoE;QACpE,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,SAAS,SAAS,CAAC,CAAC;QAC3E,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAExD,IAAI,CAAC;YACH,MAAM,kBAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,8BAA8B,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;;AA58CH,uBA68CC","sourcesContent":["/**\n * @fileoverview Pull command implementation for MetadataSync\n * @module commands/pull\n * \n * This module implements the pull command which retrieves metadata records from\n * the MemberJunction database and saves them as local JSON files. It supports:\n * - Filtering records with SQL expressions\n * - Pulling related entities with foreign key relationships\n * - Externalizing large text fields to separate files\n * - Creating multi-record JSON files\n * - Recursive directory search for entity configurations\n */\n\nimport { Command, Flags } from '@oclif/core';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { select } from '@inquirer/prompts';\nimport ora from 'ora-classic';\nimport { loadMJConfig, loadEntityConfig, RelatedEntityConfig } from '../../config';\nimport { SyncEngine, RecordData } from '../../lib/sync-engine';\nimport { RunView, Metadata, EntityInfo } from '@memberjunction/core';\nimport { getSystemUser, initializeProvider, cleanupProvider } from '../../lib/provider-utils';\nimport { configManager } from '../../lib/config-manager';\nimport { getSyncEngine, resetSyncEngine } from '../../lib/singleton-manager';\n\n/**\n * Pull metadata records from database to local files\n * \n * @class Pull\n * @extends Command\n * \n * @example\n * ```bash\n * # Pull all records for an entity\n * mj-sync pull --entity=\"AI Prompts\"\n * \n * # Pull with filter\n * mj-sync pull --entity=\"AI Prompts\" --filter=\"CategoryID='123'\"\n * \n * # Pull to multi-record file\n * mj-sync pull --entity=\"AI Prompts\" --multi-file=\"all-prompts.json\"\n * ```\n */\nexport default class Pull extends Command {\n static description = 'Pull metadata from database to local files';\n \n static examples = [\n `<%= config.bin %> <%= command.id %> --entity=\"AI Prompts\"`,\n `<%= config.bin %> <%= command.id %> --entity=\"AI Prompts\" --filter=\"CategoryID='customer-service-id'\"`,\n ];\n \n static flags = {\n entity: Flags.string({ description: 'Entity name to pull', required: true }),\n filter: Flags.string({ description: 'Additional filter for pulling specific records' }),\n 'dry-run': Flags.boolean({ description: 'Show what would be pulled without actually pulling' }),\n 'multi-file': Flags.string({ description: 'Create a single file with multiple records (provide filename)' }),\n verbose: Flags.boolean({ char: 'v', description: 'Show detailed output' }),\n };\n \n async run(): Promise<void> {\n const { flags } = await this.parse(Pull);\n const spinner = ora();\n \n try {\n // Load MJ config first (before changing directory)\n spinner.start('Loading configuration');\n const mjConfig = loadMJConfig();\n if (!mjConfig) {\n this.error('No mj.config.cjs found in current directory or parent directories');\n }\n \n // Stop spinner before provider initialization (which logs to console)\n spinner.stop();\n \n // Initialize data provider\n const provider = await initializeProvider(mjConfig);\n \n // Get singleton sync engine\n const syncEngine = await getSyncEngine(getSystemUser());\n \n // Show success after all initialization is complete\n spinner.succeed('Configuration and metadata loaded');\n \n let targetDir: string;\n let entityConfig: any;\n \n // Check if we should use a specific target directory\n const envTargetDir = process.env.METADATA_SYNC_TARGET_DIR;\n if (envTargetDir) {\n if (flags.verbose) {\n console.log(`Using specified target directory: ${envTargetDir}`);\n }\n process.chdir(envTargetDir);\n targetDir = process.cwd();\n \n // Load entity config from the current directory\n entityConfig = await loadEntityConfig(targetDir);\n if (!entityConfig) {\n this.error(`No .mj-sync.json found in ${targetDir}`);\n }\n if (entityConfig.entity !== flags.entity) {\n this.error(`Directory ${targetDir} is configured for entity \"${entityConfig.entity}\", not \"${flags.entity}\"`);\n }\n } else {\n // Original behavior - find entity directory\n const entityDirs = await this.findEntityDirectories(flags.entity);\n \n if (entityDirs.length === 0) {\n this.error(`No directory found for entity \"${flags.entity}\". Run \"mj-sync init\" first.`);\n }\n \n if (entityDirs.length === 1) {\n targetDir = entityDirs[0];\n } else {\n // Multiple directories found, ask user\n targetDir = await select({\n message: `Multiple directories found for entity \"${flags.entity}\". Which one to use?`,\n choices: entityDirs.map(dir => ({ name: dir, value: dir }))\n });\n }\n \n entityConfig = await loadEntityConfig(targetDir);\n if (!entityConfig) {\n this.error(`Invalid entity configuration in ${targetDir}`);\n }\n }\n \n // Show configuration notice only if relevant\n if (entityConfig.pull?.appendRecordsToExistingFile && entityConfig.pull?.newFileName) {\n const targetFile = path.join(targetDir, entityConfig.pull.newFileName.endsWith('.json') \n ? entityConfig.pull.newFileName \n : `${entityConfig.pull.newFileName}.json`);\n \n if (await fs.pathExists(targetFile)) {\n // File exists - inform about append behavior\n this.log(`\\n📝 Configuration: New records will be appended to existing file '${path.basename(targetFile)}'`);\n }\n // If file doesn't exist, no need to mention anything special - we're just creating it\n }\n \n // Pull records\n spinner.start(`Pulling ${flags.entity} records`);\n const rv = new RunView();\n \n let filter = '';\n if (flags.filter) {\n filter = flags.filter;\n } else if (entityConfig.pull?.filter) {\n filter = entityConfig.pull.filter;\n }\n \n const result = await rv.RunView({\n EntityName: flags.entity,\n ExtraFilter: filter,\n ResultType: 'entity_object'\n }, getSystemUser());\n \n if (!result.Success) {\n this.error(`Failed to pull records: ${result.ErrorMessage}`);\n }\n \n spinner.succeed(`Found ${result.Results.length} records`);\n \n if (flags['dry-run']) {\n this.log(`\\nDry run mode - would pull ${result.Results.length} records to ${targetDir}`);\n return;\n }\n \n // Check if we need to wait for async property loading\n if (entityConfig.pull?.externalizeFields && result.Results.length > 0) {\n const metadata = new Metadata();\n const entityInfo = metadata.EntityByName(flags.entity);\n if (entityInfo) {\n const externalizeConfig = entityConfig.pull.externalizeFields;\n let fieldsToExternalize: string[] = [];\n \n if (Array.isArray(externalizeConfig)) {\n if (externalizeConfig.length > 0 && typeof externalizeConfig[0] === 'string') {\n // Simple string array\n fieldsToExternalize = externalizeConfig as string[];\n } else {\n // New pattern format\n fieldsToExternalize = (externalizeConfig as Array<{field: string; pattern: string}>)\n .map(item => item.field);\n }\n } else {\n // Object format\n fieldsToExternalize = Object.keys(externalizeConfig);\n }\n \n // Get all field names from entity metadata\n const metadataFieldNames = entityInfo.Fields.map(f => f.Name);\n \n // Check if any externalized fields are NOT in metadata (likely computed properties)\n const computedFields = fieldsToExternalize.filter(f => !metadataFieldNames.includes(f));\n \n if (computedFields.length > 0) {\n spinner.start(`Waiting 5 seconds for async property loading in ${flags.entity} (${computedFields.join(', ')})...`);\n await new Promise(resolve => setTimeout(resolve, 5000));\n spinner.succeed('Async property loading wait complete');\n }\n }\n }\n \n // Process each record\n const entityInfo = syncEngine.getEntityInfo(flags.entity);\n if (!entityInfo) {\n this.error(`Entity information not found for: ${flags.entity}`);\n }\n \n spinner.start('Processing records');\n let processed = 0;\n let updated = 0;\n let created = 0;\n let skipped = 0;\n \n // If multi-file flag is set, collect all records\n if (flags['multi-file']) {\n const allRecords: RecordData[] = [];\n \n for (const record of result.Results) {\n try {\n // Build primary key\n const primaryKey: Record<string, any> = {};\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKey[pk.Name] = record[pk.Name];\n }\n \n // Process record for multi-file\n const recordData = await this.processRecordData(record, primaryKey, targetDir, entityConfig, syncEngine, flags, true);\n allRecords.push(recordData);\n processed++;\n \n if (flags.verbose) {\n spinner.text = `Processing records (${processed}/${result.Results.length})`;\n }\n } catch (error) {\n this.warn(`Failed to process record: ${(error as any).message || error}`);\n }\n }\n \n // Write all records to single file\n if (allRecords.length > 0) {\n const fileName = flags['multi-file'].endsWith('.json') ? flags['multi-file'] : `${flags['multi-file']}.json`;\n const filePath = path.join(targetDir, fileName);\n await fs.writeJson(filePath, allRecords, { spaces: 2 });\n spinner.succeed(`Pulled ${processed} records to ${filePath}`);\n }\n } else {\n // Smart update logic for single-file-per-record\n spinner.text = 'Scanning for existing files...';\n \n // Find existing files\n const filePattern = entityConfig.pull?.filePattern || entityConfig.filePattern || '*.json';\n const existingFiles = await this.findExistingFiles(targetDir, filePattern);\n \n if (flags.verbose) {\n this.log(`Found ${existingFiles.length} existing files matching pattern '${filePattern}'`);\n existingFiles.forEach(f => this.log(` - ${path.basename(f)}`));\n }\n \n // Load existing records and build lookup map\n const existingRecordsMap = await this.loadExistingRecords(existingFiles, entityInfo);\n \n if (flags.verbose) {\n this.log(`Loaded ${existingRecordsMap.size} existing records from files`);\n }\n \n // Separate records into new and existing\n const newRecords: Array<{ record: any; primaryKey: Record<string, any> }> = [];\n const existingRecordsToUpdate: Array<{ record: any; primaryKey: Record<string, any>; filePath: string }> = [];\n \n for (const record of result.Results) {\n // Build primary key\n const primaryKey: Record<string, any> = {};\n for (const pk of entityInfo.PrimaryKeys) {\n primaryKey[pk.Name] = record[pk.Name];\n }\n \n // Create lookup key\n const lookupKey = this.createPrimaryKeyLookup(primaryKey);\n const existingFileInfo = existingRecordsMap.get(lookupKey);\n \n if (existingFileInfo) {\n // Record exists locally\n if (entityConfig.pull?.updateExistingRecords !== false) {\n existingRecordsToUpdate.push({ record, primaryKey, filePath: existingFileInfo.filePath });\n } else {\n skipped++;\n if (flags.verbose) {\n this.log(`Skipping existing record: ${lookupKey}`);\n }\n }\n } else {\n // Record doesn't exist locally\n if (entityConfig.pull?.createNewFileIfNotFound !== false) {\n newRecords.push({ record, primaryKey });\n } else {\n skipped++;\n if (flags.verbose) {\n this.log(`Skipping new record (createNewFileIfNotFound=false): ${lookupKey}`);\n }\n }\n }\n }\n \n // Track which files have been backed up to avoid duplicates\n const backedUpFiles = new Set<string>();\n \n // Process existing records updates\n for (const { record, primaryKey, filePath } of existingRecordsToUpdate) {\n try {\n spinner.text = `Updating existing records (${updated + 1}/${existingRecordsToUpdate.length})`;\n \n // Create backup if configured (only once per file)\n if (entityConfig.pull?.backupBeforeUpdate && !backedUpFiles.has(filePath)) {\n await this.createBackup(filePath, entityConfig.pull?.backupDirectory);\n backedUpFiles.add(filePath);\n }\n \n // Load existing file data\n const existingData = await fs.readJson(filePath);\n \n // Find the specific existing record that matches this primary key\n let existingRecordData: RecordData;\n if (Array.isArray(existingData)) {\n // Find the matching record in the array\n const matchingRecord = existingData.find(r => \n this.createPrimaryKeyLookup(r.primaryKey || {}) === this.createPrimaryKeyLookup(primaryKey)\n );\n existingRecordData = matchingRecord || existingData[0]; // Fallback to first if not found\n } else {\n existingRecordData = existingData;\n }\n \n // Process the new record data (isNewRecord = false for updates)\n const newRecordData = await this.processRecordData(record, primaryKey, targetDir, entityConfig, syncEngine, flags, false, existingRecordData);\n \n // Apply merge strategy\n const mergedData = await this.mergeRecords(\n existingRecordData,\n newRecordData,\n entityConfig.pull?.mergeStrategy || 'merge',\n entityConfig.pull?.preserveFields || []\n );\n \n // Write updated data\n if (Array.isArray(existingData)) {\n // Update the record in the array\n const index = existingData.findIndex(r => \n this.createPrimaryKeyLookup(r.primaryKey || {}) === this.createPrimaryKeyLookup(primaryKey)\n );\n if (index >= 0) {\n existingData[index] = mergedData;\n await fs.writeJson(filePath, existingData, { spaces: 2 });\n }\n } else {\n await fs.writeJson(filePath, mergedData, { spaces: 2 });\n }\n \n updated++;\n processed++;\n \n if (flags.verbose) {\n this.log(`Updated: ${filePath}`);\n }\n } catch (error) {\n this.warn(`Failed to update record: ${(error as any).message || error}`);\n }\n }\n \n // Process new records\n if (newRecords.length > 0) {\n spinner.text = `Creating new records (0/${newRecords.length})`;\n \n if (entityConfig.pull?.appendRecordsToExistingFile && entityConfig.pull?.newFileName) {\n // Append all new records to a single file\n const fileName = entityConfig.pull.newFileName.endsWith('.json') \n ? entityConfig.pull.newFileName \n : `${entityConfig.pull.newFileName}.json`;\n const filePath = path.join(targetDir, fileName);\n \n // Load existing file if it exists\n let existingData: RecordData[] = [];\n if (await fs.pathExists(filePath)) {\n const fileData = await fs.readJson(filePath);\n existingData = Array.isArray(fileData) ? fileData : [fileData];\n }\n \n // Process and append all new records\n for (const { record, primaryKey } of newRecords) {\n try {\n // For new records, pass isNewRecord = true (default)\n const recordData = await this.processRecordData(record, primaryKey, targetDir, entityConfig, syncEngine, flags, true);\n existingData.push(recordData);\n created++;\n processed++;\n \n if (flags.verbose) {\n spinner.text = `Creating new records (${created}/${newRecords.length})`;\n }\n } catch (error) {\n this.warn(`Failed to process new record: ${(error as any).message || error}`);\n }\n }\n \n // Write the combined data\n await fs.writeJson(filePath, existingData, { spaces: 2 });\n \n if (flags.verbose) {\n this.log(`Appended ${created} new records to: ${filePath}`);\n }\n } else {\n // Create individual files for each new record\n for (const { record, primaryKey } of newRecords) {\n try {\n await this.processRecord(record, primaryKey, targetDir, entityConfig, syncEngine, flags);\n created++;\n processed++;\n \n if (flags.verbose) {\n spinner.text = `Creating new records (${created}/${newRecords.length})`;\n }\n } catch (error) {\n this.warn(`Failed to process new record: ${(error as any).message || error}`);\n }\n }\n }\n }\n \n // Final status\n const statusParts = [`Processed ${processed} records`];\n if (updated > 0) statusParts.push(`updated ${updated}`);\n if (created > 0) statusParts.push(`created ${created}`);\n if (skipped > 0) statusParts.push(`skipped ${skipped}`);\n \n spinner.succeed(statusParts.join(', '));\n }\n \n } catch (error) {\n spinner.fail('Pull failed');\n this.error(error as Error);\n } finally {\n // Clean up database connection and reset singletons\n await cleanupProvider();\n resetSyncEngine();\n \n // Exit process to prevent background MJ tasks from throwing errors\n process.exit(0);\n }\n }\n \n /**\n * Find directories containing configuration for the specified entity\n * \n * Recursively searches the current working directory for .mj-sync.json files\n * that specify the given entity name. Returns all matching directories to\n * allow user selection when multiple locations exist.\n * \n * @param entityName - Name of the entity to search for\n * @returns Promise resolving to array of directory paths\n * @private\n */\n private async findEntityDirectories(entityName: string): Promise<string[]> {\n const dirs: string[] = [];\n \n // Search for directories with matching entity config\n const searchDirs = async (dir: string) => {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (entry.isDirectory()) {\n const fullPath = path.join(dir, entry.name);\n const config = await loadEntityConfig(fullPath);\n \n if (config && config.entity === entityName) {\n dirs.push(fullPath);\n } else {\n // Recurse\n await searchDirs(fullPath);\n }\n }\n }\n };\n \n await searchDirs(configManager.getOriginalCwd());\n return dirs;\n }\n \n /**\n * Process a single record and save to file\n * \n * Converts a database record into the file format and writes it to disk.\n * This is a wrapper around processRecordData that handles file writing.\n * \n * @param record - Raw database record\n * @param primaryKey - Primary key fields and values\n * @param targetDir - Directory to save the file\n * @param entityConfig - Entity configuration with pull settings\n * @param syncEngine - Sync engine instance\n * @returns Promise that resolves when file is written\n * @private\n */\n private async processRecord(\n record: any, \n primaryKey: Record<string, any>,\n targetDir: string, \n entityConfig: any,\n syncEngine: SyncEngine,\n flags: any\n ): Promise<void> {\n const recordData = await this.processRecordData(record, primaryKey, targetDir, entityConfig, syncEngine, flags, true);\n \n // Determine file path\n const fileName = this.buildFileName(primaryKey, entityConfig);\n const filePath = path.join(targetDir, fileName);\n \n // Write JSON file\n await fs.writeJson(filePath, recordData, { spaces: 2 });\n }\n \n /**\n * Process record data for storage\n * \n * Transforms a raw database record into the RecordData format used for file storage.\n * Handles field externalization, related entity pulling, and checksum calculation.\n * \n * @param record - Raw database record\n * @param primaryKey - Primary key fields and values \n * @param targetDir - Directory where files will be saved\n * @param entityConfig - Entity configuration with defaults and settings\n * @param syncEngine - Sync engine for checksum calculation\n * @param flags - Command flags\n * @param isNewRecord - Whether this is a new record\n * @param existingRecordData - Existing record data to preserve field selection\n * @returns Promise resolving to formatted RecordData\n * @private\n */\n private async processRecordData(\n record: any, \n primaryKey: Record<string, any>,\n targetDir: string, \n entityConfig: any,\n syncEngine: SyncEngine,\n flags?: any,\n isNewRecord: boolean = true,\n existingRecordData?: RecordData\n ): Promise<RecordData> {\n // Build record data - we'll restructure at the end for proper ordering\n const fields: Record<string, any> = {};\n const relatedEntities: Record<string, RecordData[]> = {};\n \n // Debug: Log all fields in first record (only in verbose mode)\n if (flags?.verbose) {\n const recordKeys = Object.keys(record);\n console.log('\\n=== DEBUG: Processing record ===');\n console.log('Entity:', entityConfig.entity);\n console.log('Total fields:', recordKeys.length);\n console.log('Field names:', recordKeys.filter(k => !k.startsWith('__mj_')).join(', '));\n console.log('Has TemplateText?:', recordKeys.includes('TemplateText'));\n console.log('externalizeFields config:', entityConfig.pull?.externalizeFields);\n }\n \n // Get the underlying data from the entity object\n // If it's an entity object, it will have a GetAll() method\n let dataToProcess = record;\n if (typeof record.GetAll === 'function') {\n // It's an entity object, get the underlying data\n dataToProcess = record.GetAll();\n }\n \n // Get externalize configuration for pattern lookup\n const externalizeConfig = entityConfig.pull?.externalizeFields;\n let externalizeMap = new Map<string, string | undefined>();\n \n if (externalizeConfig) {\n if (Array.isArray(externalizeConfig)) {\n if (externalizeConfig.length > 0 && typeof externalizeConfig[0] === 'string') {\n // Simple string array\n (externalizeConfig as string[]).forEach(f => externalizeMap.set(f, undefined));\n } else {\n // New pattern format\n (externalizeConfig as Array<{field: string; pattern: string}>).forEach(item => \n externalizeMap.set(item.field, item.pattern)\n );\n }\n } else {\n // Object format\n Object.keys(externalizeConfig).forEach(f => externalizeMap.set(f, undefined));\n }\n }\n \n // Process regular fields from the underlying data\n for (const [fieldName, fieldValue] of Object.entries(dataToProcess)) {\n // Skip primary key fields\n if (primaryKey[fieldName] !== undefined) {\n continue;\n }\n \n // Skip internal fields\n if (fieldName.startsWith('__mj_')) {\n continue;\n }\n \n // Skip excluded fields\n if (entityConfig.pull?.excludeFields?.includes(fieldName)) {\n continue;\n }\n \n // Skip fields already externalized\n if (fields[fieldName]) {\n continue;\n }\n \n // Skip virtual/computed fields - check entity metadata\n const metadata = new Metadata();\n const entityInfo = metadata.EntityByName(entityConfig.entity);\n \n \n if (entityInfo) {\n const fieldInfo = entityInfo.Fields.find(f => f.Name === fieldName);\n if (fieldInfo && !fieldInfo.IsVirtual) {\n // Field exists in metadata and is not virtual, keep it\n } else if (fieldInfo && fieldInfo.IsVirtual) {\n // Skip virtual fields\n continue;\n } else if (!fieldInfo) {\n // Field not in metadata at all\n // Check if it's explicitly configured for externalization, lookup, or exclusion\n const isConfiguredField = \n entityConfig.pull?.externalizeFields?.includes(fieldName) ||\n entityConfig.pull?.lookupFields?.[fieldName] ||\n entityConfig.pull?.excludeFields?.includes(fieldName);\n \n \n if (!isConfiguredField) {\n // Skip fields not in metadata and not explicitly configured\n continue;\n }\n // Otherwise, allow the field to be processed since it's explicitly configured\n }\n }\n \n // Check if this field should be converted to a lookup\n const lookupConfig = entityConfig.pull?.lookupFields?.[fieldName];\n if (lookupConfig && fieldValue) {\n // Convert foreign key to @lookup reference\n const lookupValue = await this.convertToLookup(\n fieldValue,\n lookupConfig.entity,\n lookupConfig.field,\n syncEngine\n );\n if (lookupValue) {\n fields[fieldName] = lookupValue;\n continue;\n }\n }\n \n // Check if this is an external file field\n if (await this.shouldExternalizeField(fieldName, fieldValue, entityConfig)) {\n // Check if this field is preserved and already has a @file: reference\n const isPreservedField = entityConfig.pull?.preserveFields?.includes(fieldName);\n const existingFieldValue = existingRecordData?.fields?.[fieldName];\n \n if (isPreservedField && existingFieldValue && typeof existingFieldValue === 'string' && existingFieldValue.startsWith('@file:')) {\n // Field is preserved and has existing @file: reference - update the existing file\n const existingFilePath = existingFieldValue.replace('@file:', '');\n const fullPath = path.join(targetDir, existingFilePath);\n \n // Ensure directory exists\n await fs.ensureDir(path.dirname(fullPath));\n \n // Write the content to the existing file path\n await fs.writeFile(fullPath, String(fieldValue), 'utf-8');\n \n // Keep the existing @file: reference\n fields[fieldName] = existingFieldValue;\n } else {\n // Normal externalization - create new file\n const pattern = externalizeMap.get(fieldName);\n const fileName = await this.createExternalFile(\n targetDir,\n record,\n primaryKey,\n fieldName,\n String(fieldValue),\n entityConfig,\n pattern\n );\n fields[fieldName] = fileName; // fileName already includes @file: prefix if pattern-based\n }\n } else {\n fields[fieldName] = fieldValue;\n }\n }\n \n // Now check for externalized fields that might be computed properties\n // We process ALL externalized fields, including those not in the data\n if (entityConfig.pull?.externalizeFields && typeof record.GetAll === 'function') {\n const externalizeConfig = entityConfig.pull.externalizeFields;\n \n // Normalize configuration to array format\n let externalizeItems: Array<{field: string; pattern?: string}> = [];\n if (Array.isArray(externalizeConfig)) {\n if (externalizeConfig.length > 0 && typeof externalizeConfig[0] === 'string') {\n // Simple string array\n externalizeItems = (externalizeConfig as string[]).map(f => ({field: f}));\n } else {\n // Already in the new format\n externalizeItems = externalizeConfig as Array<{field: string; pattern: string}>;\n }\n } else {\n // Object format\n externalizeItems = Object.entries(externalizeConfig).map(([field, config]) => ({\n field,\n pattern: undefined // Will use default pattern\n }));\n }\n \n // Get the keys from the underlying data to identify computed properties\n const dataKeys = Object.keys(dataToProcess);\n \n for (const externalItem of externalizeItems) {\n const externalField = externalItem.field;\n \n // Only process fields that are NOT in the underlying data\n // (these are likely computed properties)\n if (dataKeys.includes(externalField)) {\n continue; // This was already processed in the main loop\n }\n \n try {\n // Use bracket notation to access properties (including getters)\n const fieldValue = record[externalField];\n if (fieldValue !== undefined && fieldValue !== null && fieldValue !== '') {\n if (await this.shouldExternalizeField(externalField, fieldValue, entityConfig)) {\n // Check if this field is preserved and already has a @file: reference\n const isPreservedField = entityConfig.pull?.preserveFields?.includes(externalField);\n const existingFieldValue = existingRecordData?.fields?.[externalField];\n \n if (isPreservedField && existingFieldValue && typeof existingFieldValue === 'string' && existingFieldValue.startsWith('@file:')) {\n // Field is preserved and has existing @file: reference - update the existing file\n const existingFilePath = existingFieldValue.replace('@file:', '');\n const fullPath = path.join(targetDir, existingFilePath);\n \n // Ensure directory exists\n await fs.ensureDir(path.dirname(fullPath));\n \n // Write the content to the existing file path\n await fs.writeFile(fullPath, String(fieldValue), 'utf-8');\n \n // Keep the existing @file: reference\n fields[externalField] = existingFieldValue;\n } else {\n // Normal externalization - create new file\n const fileName = await this.createExternalFile(\n targetDir,\n record,\n primaryKey,\n externalField,\n String(fieldValue),\n entityConfig,\n externalItem.pattern\n );\n fields[externalField] = fileName; // fileName already includes @file: prefix if pattern-based\n }\n } else {\n // Include the field value if not externalized\n fields[externalField] = fieldValue;\n }\n }\n } catch (error) {\n // Property might not exist, that's okay\n if (flags?.verbose) {\n console.log(`Could not get property ${externalField}: ${error}`);\n }\n }\n }\n }\n \n // Pull related entities if configured\n if (entityConfig.pull?.relatedEntities) {\n const related = await this.pullRelatedEntities(\n record,\n entityConfig.pull.relatedEntities,\n syncEngine,\n entityConfig,\n flags\n );\n Object.assign(relatedEntities, related);\n }\n \n // Get entity metadata to check defaults\n const metadata = new Metadata();\n const entityInfo = metadata.EntityByName(entityConfig.entity);\n \n // Filter out null values and fields matching their defaults\n const cleanedFields: Record<string, any> = {};\n \n // Get the set of fields that existed in the original record (if updating)\n const existingFieldNames = existingRecordData?.fields ? new Set(Object.keys(existingRecordData.fields)) : new Set<string>();\n \n for (const [fieldName, fieldValue] of Object.entries(fields)) {\n let includeField = false;\n \n if (!isNewRecord && existingFieldNames.has(fieldName)) {\n // For updates: Always preserve fields that existed in the original record\n includeField = true;\n } else {\n // For new records or new fields in existing records:\n // Skip null/undefined/empty string values\n if (fieldValue === null || fieldValue === undefined || fieldValue === '') {\n includeField = false;\n } else if (entityInfo) {\n // Check if value matches the field's default\n const fieldInfo = entityInfo.Fields.find(f => f.Name === fieldName);\n if (fieldInfo && fieldInfo.DefaultValue !== null && fieldInfo.DefaultValue !== undefined) {\n // Compare with default value\n if (fieldValue === fieldInfo.DefaultValue) {\n includeField = false;\n }\n // Special handling for boolean defaults (might be stored as strings)\n else if (typeof fieldValue === 'boolean' && \n (fieldInfo.DefaultValue === (fieldValue ? '1' : '0') || \n fieldInfo.DefaultValue === (fieldValue ? 'true' : 'false'))) {\n includeField = false;\n }\n // Special handling for numeric defaults that might be strings\n else if (typeof fieldValue === 'number' && String(fieldValue) === String(fieldInfo.DefaultValue)) {\n includeField = false;\n } else {\n includeField = true;\n }\n } else {\n // No default value defined, include if not null/empty\n includeField = true;\n }\n } else {\n // No entity info, include if not null/empty\n includeField = true;\n }\n }\n \n if (includeField) {\n cleanedFields[fieldName] = fieldValue;\n }\n }\n \n // Calculate checksum on cleaned fields\n const checksum = syncEngine.calculateChecksum(cleanedFields);\n \n // Build the final record data with proper ordering\n // Use a new object to ensure property order\n const recordData: RecordData = {} as RecordData;\n \n // 1. User fields first\n recordData.fields = cleanedFields;\n \n // 2. Related entities (if any)\n if (Object.keys(relatedEntities).length > 0) {\n recordData.relatedEntities = relatedEntities;\n }\n \n // 3. Primary key (system field)\n recordData.primaryKey = primaryKey;\n \n // 4. Sync metadata (system field)\n recordData.sync = {\n lastModified: new Date().toISOString(),\n checksum: checksum\n };\n \n return recordData;\n }\n \n /**\n * Convert a foreign key value to a @lookup reference\n * \n * Looks up the related record and creates a @lookup string that can be\n * resolved during push operations.\n * \n * @param foreignKeyValue - The foreign key value (ID)\n * @param targetEntity - Name of the target entity\n * @param targetField - Field in target entity to use for lookup\n * @param syncEngine - Sync engine instance\n * @returns @lookup string or null if lookup fails\n * @private\n */\n private async convertToLookup(\n foreignKeyValue: any,\n targetEntity: string,\n targetField: string,\n syncEngine: SyncEngine\n ): Promise<string | null> {\n try {\n // Get the related record\n const metadata = new Metadata();\n const targetEntityInfo = metadata.EntityByName(targetEntity);\n if (!targetEntityInfo) {\n this.warn(`Could not find entity ${targetEntity} for lookup`);\n return null;\n }\n \n // Load the related record\n const primaryKeyField = targetEntityInfo.PrimaryKeys?.[0]?.Name || 'ID';\n const rv = new RunView();\n const result = await rv.RunView({\n EntityName: targetEntity,\n ExtraFilter: `${primaryKeyField} = '${String(foreignKeyValue).replace(/'/g, \"''\")}'`,\n ResultType: 'entity_object'\n }, getSystemUser());\n \n if (!result.Success || result.Results.length === 0) {\n this.warn(`Could not find ${targetEntity} with ${primaryKeyField} = ${foreignKeyValue}`);\n return null;\n }\n \n const relatedRecord = result.Results[0];\n const lookupValue = relatedRecord[targetField];\n \n if (!lookupValue) {\n this.warn(`${targetEntity} record missing ${targetField} field`);\n return null;\n }\n \n // Return the @lookup reference\n return `@lookup:${targetEntity}.${targetField}=${lookupValue}`;\n } catch (error) {\n this.warn(`Failed to create lookup for ${targetEntity}: ${error}`);\n return null;\n }\n }\n \n /**\n * Determine if a field should be saved to an external file\n * \n * Checks if a field is configured for externalization or contains substantial\n * text content that would be better stored in a separate file.\n * \n * @param fieldName - Name of the field to check\n * @param fieldValue - Value of the field\n * @param entityConfig - Entity configuration with externalization settings\n * @returns Promise resolving to true if field should be externalized\n * @private\n */\n private async shouldExternalizeField(\n fieldName: string, \n fieldValue: any,\n entityConfig: any\n ): Promise<boolean> {\n \n // Only externalize string fields\n if (typeof fieldValue !== 'string') {\n return false;\n }\n \n // Check if field is configured for externalization\n const externalizeConfig = entityConfig.pull?.externalizeFields;\n if (!externalizeConfig) {\n return false;\n }\n \n if (Array.isArray(externalizeConfig)) {\n if (externalizeConfig.length > 0 && typeof externalizeConfig[0] === 'string') {\n // Simple string array\n return (externalizeConfig as string[]).includes(fieldName);\n } else {\n // New pattern format\n return (externalizeConfig as Array<{field: string; pattern: string}>)\n .some(item => item.field === fieldName);\n }\n } else {\n // Object format\n return fieldName in externalizeConfig;\n }\n }\n \n /**\n * Create an external file for a field value\n * \n * Saves large text content to a separate file and returns the filename.\n * Automatically determines appropriate file extension based on field name\n * and content type (e.g., .md for prompts, .html for templates).\n * Uses the entity's name field for the filename if available.\n * \n * @param targetDir - Directory to save the file\n * @param record - Full record to extract name field from\n * @param primaryKey - Primary key for filename generation fallback\n * @param fieldName - Name of the field being externalized\n * @param content - Content to write to the file\n * @param entityConfig - Entity configuration\n * @returns Promise resolving to the created filename\n * @private\n */\n private async createExternalFile(\n targetDir: string,\n record: any,\n primaryKey: Record<string, any>,\n fieldName: string,\n content: string,\n entityConfig: any,\n pattern?: string\n ): Promise<string> {\n // If pattern is provided, use it to generate the full path\n if (pattern) {\n // Replace placeholders in the pattern\n let resolvedPattern = pattern;\n \n // Get entity metadata for field lookups\n const metadata = new Metadata();\n const entityInfo = metadata.EntityByName(entityConfig.entity);\n \n // Replace {Name} with the entity's name field value\n if (entityInfo) {\n const nameField = entityInfo.Fields.find(f => f.IsNameField);\n if (nameField && record[nameField.Name]) {\n const nameValue = String(record[nameField.Name])\n .replace(/[^a-zA-Z0-9\\-_ ]/g, '') // Remove disallowed characters\n .replace(/\\s+/g, '-') // Replace spaces with -\n .toLowerCase(); // Make lowercase\n resolvedPattern = resolvedPattern.replace(/{Name}/g, nameValue);\n }\n }\n \n // Replace {ID} with the primary key\n const idValue = primaryKey.ID || Object.values(primaryKey)[0];\n if (idValue) {\n resolvedPattern = resolvedPattern.replace(/{ID}/g, String(idValue).toLowerCase());\n }\n \n // Replace {FieldName} with the current field name\n resolvedPattern = resolvedPattern.replace(/{FieldName}/g, fieldName.toLowerCase());\n \n // Replace any other {field} placeholders with field values from the record\n const placeholderRegex = /{(\\w+)}/g;\n resolvedPattern = resolvedPattern.replace(placeholderRegex, (match, fieldName) => {\n const value = record[fieldName];\n if (value !== undefined && value !== null) {\n return String(value)\n .replace(/[^a-zA-Z0-9\\-_ ]/g, '')\n .replace(/\\s+/g, '-')\n .toLowerCase();\n }\n return match; // Keep placeholder if field not found\n });\n \n // Extract the file path from the pattern\n const filePath = path.join(targetDir, resolvedPattern.replace('@file:', ''));\n \n // Ensure directory exists\n await fs.ensureDir(path.dirname(filePath));\n \n // Write the file\n await fs.writeFile(filePath, content, 'utf-8');\n \n // Return the pattern as-is (it includes @file: prefix)\n return resolvedPattern;\n }\n \n // Original logic for non-pattern based externalization\n let extension = '.md'; // default to markdown\n \n const externalizeConfig = entityConfig.pull?.externalizeFields;\n if (externalizeConfig && !Array.isArray(externalizeConfig) && externalizeConfig[fieldName]?.extension) {\n extension = externalizeConfig[fieldName].extension;\n // Ensure extension starts with a dot\n if (!extension.startsWith('.')) {\n extension = '.' + extension;\n }\n }\n \n // Try to use the entity's name field for the filename\n let baseFileName: string;\n \n // Get entity metadata to find the name field\n const metadata = new Metadata();\n const entityInfo = metadata.EntityByName(entityConfig.entity);\n \n if (entityInfo) {\n // Find the name field\n const nameField = entityInfo.Fields.find(f => f.IsNameField);\n if (nameField && record[nameField.Name]) {\n // Use the name field value, sanitized for filesystem\n const nameValue = String(record[nameField.Name]);\n // Remove disallowed characters (don't replace with _), replace spaces with -, and lowercase\n baseFileName = nameValue\n .replace(/[^a-zA-Z0-9\\-_ ]/g, '') // Remove disallowed characters\n .replace(/\\s+/g, '-') // Replace spaces with -\n .toLowerCase(); // Make lowercase\n } else {\n // Fallback to primary key\n baseFileName = this.buildFileName(primaryKey, null).replace('.json', '');\n }\n } else {\n // Fallback to primary key\n baseFileName = this.buildFileName(primaryKey, null).replace('.json', '');\n }\n \n // Remove dot prefix from baseFileName if it exists (it will be a dot-prefixed name from buildFileName)\n const cleanBaseFileName = baseFileName.startsWith('.') ? baseFileName.substring(1) : baseFileName;\n const fileName = `.${cleanBaseFileName}.${fieldName.toLowerCase()}${extension}`;\n const filePath = path.join(targetDir, fileName);\n \n await fs.writeFile(filePath, content, 'utf-8');\n \n return fileName;\n }\n \n /**\n * Build a filename from primary key values\n * \n * Creates a safe filename based on the entity's primary key values.\n * Handles GUIDs by using first 8 characters, sanitizes special characters,\n * and creates composite names for multi-field keys.\n * Files are prefixed with a dot to follow the metadata file convention.\n * \n * @param primaryKey - Primary key fields and values\n * @param entityConfig - Entity configuration (for future extension)\n * @returns Filename with .json extension\n * @private\n */\n private buildFileName(primaryKey: Record<string, any>, entityConfig: any): string {\n // Use primary key values to build filename\n const keys = Object.values(primaryKey);\n \n if (keys.length === 1 && typeof keys[0] === 'string') {\n // Single string key - use as base if it's a guid\n const key = keys[0];\n if (key.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)) {\n // It's a GUID, use first 8 chars, prefixed with dot, lowercase\n return `.${key.substring(0, 8).toLowerCase()}.json`;\n }\n // Use the whole key if not too long, prefixed with dot\n if (key.length <= 50) {\n return `.${key.replace(/[^a-zA-Z0-9\\-_]/g, '').toLowerCase()}.json`;\n }\n }\n \n // Multiple keys or numeric - create composite name, prefixed with dot\n return '.' + keys.map(k => String(k).replace(/[^a-zA-Z0-9\\-_]/g, '').toLowerCase()).join('-') + '.json';\n }\n \n /**\n * Pull related entities for a parent record\n * \n * Retrieves child records that have foreign key relationships to the parent.\n * Converts foreign key values to @parent references and supports nested\n * related entities for deep object graphs.\n * \n * @param parentRecord - Parent entity record\n * @param relatedConfig - Configuration for related entities to pull\n * @param syncEngine - Sync engine instance\n * @returns Promise resolving to map of entity names to related records\n * @private\n */\n private async pullRelatedEntities(\n parentRecord: any,\n relatedConfig: Record<string, RelatedEntityConfig>,\n syncEngine: SyncEngine,\n entityConfig: any,\n flags?: any\n ): Promise<Record<string, RecordData[]>> {\n const relatedEntities: Record<string, RecordData[]> = {};\n \n for (const [key, config] of Object.entries(relatedConfig)) {\n try {\n // Get entity metadata to find primary key\n const metadata = new Metadata();\n const parentEntity = metadata.EntityByName(entityConfig.entity);\n if (!parentEntity) {\n this.warn(`Could not find entity metadata for ${entityConfig.entity}`);\n continue;\n }\n \n // Get the parent's primary key value (usually ID)\n const primaryKeyField = parentEntity.PrimaryKeys?.[0]?.Name || 'ID';\n const parentKeyValue = parentRecord[primaryKeyField];\n if (!parentKeyValue) {\n this.warn(`Parent record missing primary key field ${primaryKeyField}`);\n continue;\n }\n \n // Build filter for related records\n // The foreignKey is the field in the CHILD entity that points to this parent\n let filter = `${config.foreignKey} = '${String(parentKeyValue).replace(/'/g, \"''\")}'`;\n if (config.filter) {\n filter += ` AND (${config.filter})`;\n }\n \n \n // Pull related records\n const rv = new RunView();\n const result = await rv.RunView({\n EntityName: config.entity,\n ExtraFilter: filter,\n ResultType: 'entity_object'\n }, getSystemUser());\n \n if (!result.Success) {\n this.warn(`Failed to pull related ${config.entity}: ${result.ErrorMessage}`);\n continue;\n }\n \n // Get child entity metadata\n const childEntity = metadata.EntityByName(config.entity);\n if (!childEntity) {\n this.warn(`Could not find entity metadata for ${config.entity}`);\n continue;\n }\n \n // Check if we need to wait for async property loading for related entities\n if (config.externalizeFields && result.Results.length > 0) {\n let fieldsToExternalize: string[] = [];\n \n if (Array.isArray(config.externalizeFields)) {\n if (config.externalizeFields.length > 0 && typeof config.externalizeFields[0] === 'string') {\n // Simple string array\n fieldsToExternalize = config.externalizeFields as string[];\n } else {\n // New pattern format\n fieldsToExternalize = (config.externalizeFields as Array<{field: string; pattern: string}>)\n .map(item => item.field);\n }\n } else {\n // Object format\n fieldsToExternalize = Object.keys(config.externalizeFields);\n }\n \n // Get all field names from entity metadata\n const metadataFieldNames = childEntity.Fields.map(f => f.Name);\n \n // Check if any externalized fields are NOT in metadata (likely computed properties)\n const computedFields = fieldsToExternalize.filter(f => !metadataFieldNames.includes(f));\n \n if (computedFields.length > 0) {\n console.log(`Waiting 5 seconds for async property loading in related entity ${config.entity} (${computedFields.join(', ')})...`);\n await new Promise(resolve => setTimeout(resolve, 5000));\n }\n }\n \n // Process each related record\n const relatedRecords: RecordData[] = [];\n for (const relatedRecord of result.Results) {\n // Build primary key for the related record\n const relatedPrimaryKey: Record<string, any> = {};\n for (const pk of childEntity.PrimaryKeys) {\n relatedPrimaryKey[pk.Name] = relatedRecord[pk.Name];\n }\n \n // Process the related record using the same logic as parent records\n const relatedData = await this.processRecordData(\n relatedRecord,\n relatedPrimaryKey,\n '', // Not used for related entities since we don't externalize their fields\n { \n entity: config.entity,\n pull: {\n excludeFields: config.excludeFields || entityConfig.pull?.excludeFields,\n lookupFields: config.lookupFields || entityConfig.pull?.lookupFields,\n externalizeFields: config.externalizeFields,\n relatedEntities: config.relatedEntities\n }\n },\n syncEngine,\n flags,\n true\n );\n \n // Convert foreign key reference to @parent\n if (relatedData.fields[config.foreignKey]) {\n relatedData.fields[config.foreignKey] = `@parent:${primaryKeyField}`;\n }\n \n // The processRecordData method already filters nulls and defaults\n // No need to do it again here\n \n relatedRecords.push(relatedData);\n }\n \n if (relatedRecords.length > 0) {\n relatedEntities[key] = relatedRecords;\n }\n } catch (error) {\n this.warn(`Error pulling related ${key}: ${error}`);\n }\n }\n \n return relatedEntities;\n }\n \n /**\n * Find which field in the parent record contains a specific value\n * \n * Used to convert foreign key references to @parent references by finding\n * the parent field that contains the foreign key value. Typically finds\n * the primary key field but can match any field.\n * \n * @param parentRecord - Parent record to search\n * @param value - Value to search for\n * @returns Field name containing the value, or null if not found\n * @private\n */\n private findParentField(parentRecord: any, value: any): string | null {\n // Find which field in the parent contains this value\n // Typically this will be the primary key field\n for (const [fieldName, fieldValue] of Object.entries(parentRecord)) {\n if (fieldValue === value && !fieldName.startsWith('__mj_')) {\n return fieldName;\n }\n }\n return null;\n }\n \n /**\n * Find existing files in a directory matching a pattern\n * \n * Searches for files that match the configured file pattern, used to identify\n * which records already exist locally for smart update functionality.\n * \n * @param dir - Directory to search in\n * @param pattern - Glob pattern to match files (e.g., \"*.json\")\n * @returns Promise resolving to array of file paths\n * @private\n */\n private async findExistingFiles(dir: string, pattern: string): Promise<string[]> {\n const files: string[] = [];\n \n try {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n \n for (const entry of entries) {\n if (entry.isFile()) {\n const fileName = entry.name;\n \n // Simple pattern matching - could be enhanced with proper glob support\n if (pattern === '*.json' && fileName.endsWith('.json')) {\n files.push(path.join(dir, fileName));\n } else if (pattern === '.*.json' && fileName.startsWith('.') && fileName.endsWith('.json')) {\n // Handle dot-prefixed JSON files\n files.push(path.join(dir, fileName));\n } else if (pattern === fileName) {\n files.push(path.join(dir, fileName));\n }\n // TODO: Add more sophisticated glob pattern matching if needed\n }\n }\n } catch (error) {\n // Directory might not exist yet\n if ((error as any).code !== 'ENOENT') {\n throw error;\n }\n }\n \n return files;\n }\n \n /**\n * Load existing records from files and build a lookup map\n * \n * Reads all existing files and creates a map from primary key to file location,\n * enabling efficient lookup during the update process.\n * \n * @param files - Array of file paths to load\n * @param entityInfo - Entity metadata for primary key information\n * @returns Map from primary key string to file info\n * @private\n */\n private async loadExistingRecords(\n files: string[], \n entityInfo: EntityInfo\n ): Promise<Map<string, { filePath: string; recordData: RecordData }>> {\n const recordsMap = new Map<string, { filePath: string; recordData: RecordData }>();\n \n for (const filePath of files) {\n try {\n const fileData = await fs.readJson(filePath);\n const records = Array.isArray(fileData) ? fileData : [fileData];\n \n for (const record of records) {\n if (record.primaryKey) {\n const lookupKey = this.createPrimaryKeyLookup(record.primaryKey);\n recordsMap.set(lookupKey, { filePath, recordData: record });\n }\n }\n } catch (error) {\n // Skip files that can't be parsed\n this.warn(`Could not load file ${filePath}: ${error}`);\n }\n }\n \n return recordsMap;\n }\n \n /**\n * Create a string lookup key from primary key values\n * \n * Generates a consistent string representation of primary key values\n * for use in maps and comparisons.\n * \n * @param primaryKey - Primary key field names and values\n * @returns String representation of the primary key\n * @private\n */\n private createPrimaryKeyLookup(primaryKey: Record<string, any>): string {\n const keys = Object.keys(primaryKey).sort();\n return keys.map(k => `${k}:${primaryKey[k]}`).join('|');\n }\n \n /**\n * Merge two record data objects based on configured strategy\n * \n * Combines existing and new record data according to the merge strategy:\n * - 'overwrite': Replace all fields with new values\n * - 'merge': Combine fields, with new values taking precedence\n * - 'skip': Keep existing record unchanged\n * \n * @param existing - Existing record data\n * @param newData - New record data from database\n * @param strategy - Merge strategy to apply\n * @param preserveFields - Field names that should never be overwritten\n * @returns Merged record data\n * @private\n */\n private async mergeRecords(\n existing: RecordData,\n newData: RecordData,\n strategy: 'overwrite' | 'merge' | 'skip',\n preserveFields: string[]\n ): Promise<RecordData> {\n if (strategy === 'skip') {\n return existing;\n }\n \n if (strategy === 'overwrite') {\n // Build with proper ordering\n const result: RecordData = {} as RecordData;\n \n // 1. Fields first\n result.fields = { ...newData.fields };\n \n // Restore preserved fields from existing\n if (preserveFields.length > 0 && existing.fields) {\n for (const field of preserveFields) {\n if (field in existing.fields) {\n result.fields[field] = existing.fields[field];\n }\n }\n }\n \n // 2. Related entities (if any)\n if (newData.relatedEntities) {\n result.relatedEntities = newData.relatedEntities;\n }\n \n // 3. Primary key\n result.primaryKey = newData.primaryKey;\n \n // 4. Sync metadata\n result.sync = newData.sync;\n \n return result;\n }\n \n // Default 'merge' strategy\n // Build with proper ordering\n const result: RecordData = {} as RecordData;\n \n // 1. Fields first\n result.fields = { ...existing.fields, ...newData.fields };\n \n // Restore preserved fields\n if (preserveFields.length > 0 && existing.fields) {\n for (const field of preserveFields) {\n if (field in existing.fields) {\n result.fields[field] = existing.fields[field];\n }\n }\n }\n \n // 2. Related entities (if any)\n if (existing.relatedEntities || newData.relatedEntities) {\n result.relatedEntities = {\n ...existing.relatedEntities,\n ...newData.relatedEntities\n };\n }\n \n // 3. Primary key\n result.primaryKey = newData.primaryKey || existing.primaryKey;\n \n // 4. Sync metadata\n result.sync = newData.sync;\n \n return result;\n }\n \n /**\n * Create a backup of a file before updating\n * \n * Creates a timestamped backup copy of the file in a backup directory\n * with the original filename, timestamp suffix, and .backup extension.\n * The backup directory defaults to .backups but can be configured.\n * \n * @param filePath - Path to the file to backup\n * @param backupDirName - Name of the backup directory (optional)\n * @returns Promise that resolves when backup is created\n * @private\n */\n private async createBackup(filePath: string, backupDirName?: string): Promise<void> {\n const dir = path.dirname(filePath);\n const fileName = path.basename(filePath);\n const backupDir = path.join(dir, backupDirName || '.backups');\n \n // Ensure backup directory exists\n await fs.ensureDir(backupDir);\n \n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n // Remove .json extension, add timestamp, then add .backup extension\n const backupFileName = fileName.replace(/\\.json$/, `.${timestamp}.backup`);\n const backupPath = path.join(backupDir, backupFileName);\n \n try {\n await fs.copy(filePath, backupPath);\n } catch (error) {\n this.warn(`Could not create backup of ${filePath}: ${error}`);\n }\n }\n}"]}
@@ -10,6 +10,7 @@ export default class Push extends Command {
10
10
  };
11
11
  run(): Promise<void>;
12
12
  private processEntityDirectory;
13
+ private processJsonFiles;
13
14
  private pushRecord;
14
15
  private processRelatedEntities;
15
16
  }
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const core_1 = require("@oclif/core");
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const prompts_1 = require("@inquirer/prompts");
10
9
  const ora_classic_1 = __importDefault(require("ora-classic"));
11
10
  const fast_glob_1 = __importDefault(require("fast-glob"));
12
11
  const config_1 = require("../../config");
13
- const sync_engine_1 = require("../../lib/sync-engine");
14
12
  const provider_utils_1 = require("../../lib/provider-utils");
15
13
  const provider_utils_2 = require("../../lib/provider-utils");
14
+ const config_manager_1 = require("../../lib/config-manager");
15
+ const singleton_manager_1 = require("../../lib/singleton-manager");
16
16
  class Push extends core_1.Command {
17
17
  static description = 'Push local file changes to the database';
18
18
  static examples = [
@@ -37,15 +37,17 @@ class Push extends core_1.Command {
37
37
  if (!mjConfig) {
38
38
  this.error('No mj.config.cjs found in current directory or parent directories');
39
39
  }
40
- const syncConfig = await (0, config_1.loadSyncConfig)(process.cwd());
40
+ const syncConfig = await (0, config_1.loadSyncConfig)(config_manager_1.configManager.getOriginalCwd());
41
+ // Stop spinner before provider initialization (which logs to console)
42
+ spinner.stop();
41
43
  // Initialize data provider
42
44
  await (0, provider_utils_1.initializeProvider)(mjConfig);
43
- // Initialize sync engine
44
- const syncEngine = new sync_engine_1.SyncEngine((0, provider_utils_1.getSystemUser)());
45
- await syncEngine.initialize();
46
- spinner.succeed('Configuration loaded');
45
+ // Initialize sync engine using singleton pattern
46
+ const syncEngine = await (0, singleton_manager_1.getSyncEngine)((0, provider_utils_1.getSystemUser)());
47
+ // Show success after all initialization is complete
48
+ spinner.succeed('Configuration and metadata loaded');
47
49
  // Find entity directories to process
48
- const entityDirs = (0, provider_utils_1.findEntityDirectories)(process.cwd(), flags.dir);
50
+ const entityDirs = (0, provider_utils_1.findEntityDirectories)(config_manager_1.configManager.getOriginalCwd(), flags.dir);
49
51
  if (entityDirs.length === 0) {
50
52
  this.error('No entity directories found');
51
53
  }
@@ -80,52 +82,98 @@ class Push extends core_1.Command {
80
82
  this.error(error);
81
83
  }
82
84
  finally {
85
+ // Reset sync engine singleton
86
+ (0, singleton_manager_1.resetSyncEngine)();
83
87
  // Clean up database connection
84
88
  await (0, provider_utils_2.cleanupProvider)();
89
+ // Exit process to prevent background MJ tasks from throwing errors
90
+ process.exit(0);
85
91
  }
86
92
  }
87
93
  async processEntityDirectory(entityDir, entityConfig, syncEngine, flags, syncConfig) {
88
94
  const result = { created: 0, updated: 0, errors: 0 };
89
- // Find all JSON files
95
+ // Find files matching the configured pattern
90
96
  const pattern = entityConfig.filePattern || '*.json';
91
97
  const jsonFiles = await (0, fast_glob_1.default)(pattern, {
92
98
  cwd: entityDir,
93
- ignore: ['.mj-sync.json', '.mj-folder.json']
99
+ ignore: ['.mj-sync.json', '.mj-folder.json', '**/*.backup'],
100
+ dot: true, // Include dotfiles (files starting with .)
101
+ onlyFiles: true
94
102
  });
95
- this.log(`Found ${jsonFiles.length} records to process`);
96
- if (jsonFiles.length === 0) {
97
- return result;
98
- }
99
- // Confirm if needed
100
- if (!flags['dry-run'] && !flags.ci && syncConfig?.push?.requireConfirmation) {
101
- const proceed = await (0, prompts_1.confirm)({
102
- message: `Push ${jsonFiles.length} ${entityConfig.entity} records to database?`
103
- });
104
- if (!proceed) {
105
- this.log('Push cancelled');
106
- return result;
103
+ this.log(`Processing ${jsonFiles.length} records in ${path_1.default.relative(process.cwd(), entityDir) || '.'}`);
104
+ // First, process all JSON files in this directory
105
+ await this.processJsonFiles(jsonFiles, entityDir, entityConfig, syncEngine, flags, result);
106
+ // Then, recursively process subdirectories
107
+ const entries = await fs_extra_1.default.readdir(entityDir, { withFileTypes: true });
108
+ for (const entry of entries) {
109
+ if (entry.isDirectory() && !entry.name.startsWith('.')) {
110
+ const subDir = path_1.default.join(entityDir, entry.name);
111
+ // Load subdirectory config and merge with parent config
112
+ let subEntityConfig = { ...entityConfig };
113
+ const subDirConfig = await (0, config_1.loadEntityConfig)(subDir);
114
+ if (subDirConfig) {
115
+ // Check if this is a new entity type (has different entity name)
116
+ if (subDirConfig.entity && subDirConfig.entity !== entityConfig.entity) {
117
+ // This is a different entity type, skip it (will be processed separately)
118
+ continue;
119
+ }
120
+ // Merge defaults: parent defaults + subdirectory overrides
121
+ subEntityConfig = {
122
+ ...entityConfig,
123
+ ...subDirConfig,
124
+ defaults: {
125
+ ...entityConfig.defaults,
126
+ ...(subDirConfig.defaults || {})
127
+ }
128
+ };
129
+ }
130
+ // Process subdirectory with merged config
131
+ const subResult = await this.processEntityDirectory(subDir, subEntityConfig, syncEngine, flags, syncConfig);
132
+ result.created += subResult.created;
133
+ result.updated += subResult.updated;
134
+ result.errors += subResult.errors;
107
135
  }
108
136
  }
109
- // Process each file
137
+ return result;
138
+ }
139
+ async processJsonFiles(jsonFiles, entityDir, entityConfig, syncEngine, flags, result) {
140
+ if (jsonFiles.length === 0) {
141
+ return;
142
+ }
110
143
  const spinner = (0, ora_classic_1.default)();
111
144
  spinner.start('Processing records');
145
+ let totalRecords = 0;
112
146
  for (const file of jsonFiles) {
113
147
  try {
114
148
  const filePath = path_1.default.join(entityDir, file);
115
- const recordData = await fs_extra_1.default.readJson(filePath);
149
+ const fileContent = await fs_extra_1.default.readJson(filePath);
150
+ // Process templates in the loaded content
151
+ const processedContent = await syncEngine.processTemplates(fileContent, entityDir);
152
+ // Check if the file contains a single record or an array of records
153
+ const isArray = Array.isArray(processedContent);
154
+ const records = isArray ? processedContent : [processedContent];
155
+ totalRecords += records.length;
116
156
  // Build and process defaults (including lookups)
117
157
  const defaults = await syncEngine.buildDefaults(filePath, entityConfig);
118
- // Process the record
119
- const isNew = await this.pushRecord(recordData, entityConfig.entity, path_1.default.dirname(filePath), file, defaults, syncEngine, flags['dry-run'], flags.verbose);
120
- if (!flags['dry-run']) {
121
- if (isNew) {
122
- result.created++;
123
- }
124
- else {
125
- result.updated++;
158
+ // Process each record in the file
159
+ for (let i = 0; i < records.length; i++) {
160
+ const recordData = records[i];
161
+ // Process the record
162
+ const isNew = await this.pushRecord(recordData, entityConfig.entity, path_1.default.dirname(filePath), file, defaults, syncEngine, flags['dry-run'], flags.verbose, isArray ? i : undefined);
163
+ if (!flags['dry-run']) {
164
+ if (isNew) {
165
+ result.created++;
166
+ }
167
+ else {
168
+ result.updated++;
169
+ }
126
170
  }
171
+ spinner.text = `Processing records (${result.created + result.updated + result.errors}/${totalRecords})`;
172
+ }
173
+ // Write back the entire file if it's an array
174
+ if (isArray && !flags['dry-run']) {
175
+ await fs_extra_1.default.writeJson(filePath, records, { spaces: 2 });
127
176
  }
128
- spinner.text = `Processing records (${result.created + result.updated + result.errors}/${jsonFiles.length})`;
129
177
  }
130
178
  catch (error) {
131
179
  result.errors++;
@@ -133,10 +181,9 @@ class Push extends core_1.Command {
133
181
  this.error(`Failed to process ${file}: ${errorMessage}`, { exit: false });
134
182
  }
135
183
  }
136
- spinner.succeed(`Processed ${jsonFiles.length} records`);
137
- return result;
184
+ spinner.succeed(`Processed ${totalRecords} records from ${jsonFiles.length} files`);
138
185
  }
139
- async pushRecord(recordData, entityName, baseDir, fileName, defaults, syncEngine, dryRun, verbose = false) {
186
+ async pushRecord(recordData, entityName, baseDir, fileName, defaults, syncEngine, dryRun, verbose = false, arrayIndex) {
140
187
  // Load or create entity
141
188
  let entity = null;
142
189
  let isNew = false;
@@ -199,15 +246,18 @@ class Push extends core_1.Command {
199
246
  recordData.primaryKey = newPrimaryKey;
200
247
  }
201
248
  }
202
- // Always update sync metadata and write back to file
249
+ // Always update sync metadata
203
250
  // This ensures related entities are persisted with their metadata
204
251
  recordData.sync = {
205
252
  lastModified: new Date().toISOString(),
206
253
  checksum: syncEngine.calculateChecksum(recordData.fields)
207
254
  };
208
- // Write back to file
209
- const filePath = path_1.default.join(baseDir, fileName);
210
- await fs_extra_1.default.writeJson(filePath, recordData, { spaces: 2 });
255
+ // Write back to file only if it's a single record (not part of an array)
256
+ // Array records are written back in bulk after all records are processed
257
+ if (arrayIndex === undefined) {
258
+ const filePath = path_1.default.join(baseDir, fileName);
259
+ await fs_extra_1.default.writeJson(filePath, recordData, { spaces: 2 });
260
+ }
211
261
  return isNew;
212
262
  }
213
263
  async processRelatedEntities(relatedEntities, parentEntity, rootEntity, baseDir, syncEngine, verbose = false, indentLevel = 1) {