import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { MigrationExport } from '../../entities/migration-export.entity'; @Injectable() export class MigrationService { constructor( @InjectRepository(MigrationExport) private readonly exportRepo: Repository, ) {} async exportConfig(licenseId: string, userId: string, exportType: string = 'full'): Promise { const expiresAt = new Date(); expiresAt.setDate(expiresAt.getDate() + 7); // 7 days expiry const exportRecord = this.exportRepo.create({ license_id: licenseId, export_type: exportType, storage_path: `/exports/${licenseId}/${Date.now()}.json`, file_size_bytes: 0, // Stub - would calculate after actual export created_by: userId, expires_at: expiresAt, }); return this.exportRepo.save(exportRecord); } async getExports(licenseId: string): Promise { return this.exportRepo.find({ where: { license_id: licenseId }, order: { created_at: 'DESC' }, }); } async importConfig(licenseId: string, data: any): Promise<{ message: string }> { // Stub implementation - would validate and import data in production return { message: 'Import complete' }; } }