'use server';
import { resolve } from '../../lib/server-container.js';
export async function exportWorkItemsCsv(input) {
    try {
        const useCase = resolve('ExportWorkItemsCsvUseCase');
        const result = await useCase.execute(input);
        if (!result.ok)
            return { error: result.error };
        return { csv: result.csv, itemCount: result.itemCount };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to export work items';
        return { error: message };
    }
}
export async function importWorkItemsCsv(input) {
    try {
        const useCase = resolve('ImportWorkItemsCsvUseCase');
        const result = await useCase.execute({
            ...input,
            fieldMapping: input.fieldMapping,
        });
        if (!result.ok)
            return { error: result.error };
        return { createdCount: result.createdCount, errors: result.errors };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to import work items';
        return { error: message };
    }
}
