import { DdbUpdateItem, DetailKey, DynamoDbService, ICommandOptions, IInvoke, S3Service, SnsService, StepFunctionService } from '@mbc-cqrs-serverless/core'; import { ConfigService } from '@nestjs/config'; import { CreateCsvImportDto } from './dto/create-csv-import.dto'; import { CreateImportDto } from './dto/create-import.dto'; import { CreateZipImportDto } from './dto/create-zip-import.dto'; import { ImportEntity } from './entity'; import { ImportQueueEvent } from './event'; import { IImportStrategy } from './interface'; export declare class ImportService { private readonly dynamoDbService; private readonly snsService; private readonly s3Service; private readonly importStrategyMap; private readonly configService; private readonly sfnService; private readonly logger; private readonly tableName; private readonly alarmTopicArn; constructor(dynamoDbService: DynamoDbService, snsService: SnsService, s3Service: S3Service, importStrategyMap: Map>, configService: ConfigService, sfnService: StepFunctionService); /** * Handles a single import request from the API. * It uses the appropriate ImportStrategy to transform and validate the data * before creating a record in the temporary import table. */ createWithApi(dto: CreateImportDto, options: ICommandOptions): Promise; /** * Main router for handling CSV imports. It delegates to the correct * processing method based on the specified execution strategy. */ handleCsvImport(dto: CreateCsvImportDto, options: ICommandOptions): Promise; /** * Creates a master job record for a CSV import that will be orchestrated * by a Step Function. */ createCsvJob(dto: CreateCsvImportDto, options: { invokeContext: IInvoke; }): Promise; createZipJob(dto: CreateZipImportDto, options: { invokeContext: IInvoke; }): Promise; private streamToBuffer; /** * Creates a import job record for a single json import */ createImport(dto: CreateImportDto, options: ICommandOptions): Promise; /** * Creates a CSV master job that is part of a larger ZIP orchestration. * It stores the SFN Task Token needed to signal completion back to the orchestrator. * @param dto The details of the CSV file to process. * @param taskToken The task token from the waiting Step Function. * @param sourceId The key of the parent ZIP_MASTER_JOB. * @returns The created ImportEntity. */ createCsvJobWithTaskToken(dto: CreateCsvImportDto, taskToken: string, sourceId: DetailKey): Promise; /** * Handles the 'DIRECT' execution strategy by fetching the CSV from S3 * and processing its stream immediately. */ private _processCsvDirectly; /** * Centralized logic to process a CSV stream. It reads each row, uses the * appropriate ImportStrategy to transform and validate, and creates a * temporary import record for each valid row. */ private _processCsvStream; updateStatus(key: DetailKey, status: string, payload?: { result?: any; error?: any; }, attributes?: { result?: any; error?: any; }, notifyId?: string): Promise; /** * Atomically increments the progress counters for a parent CSV job. * After incrementing, it checks if the job is complete and updates the * final status if necessary. * @param parentKey The key of the master CSV job entity. * @param childSucceeded True if the child job was successful, false otherwise. */ incrementParentJobCounters(parentKey: DetailKey, childSucceeded: boolean): Promise; /** * A private helper to build a valid DynamoDB UpdateExpression for atomic counters. * @param counters A map of attribute names to the amount they should be incremented by. * @returns An object with the UpdateExpression and its necessary parameter maps. */ private _buildAtomicCounterUpdateExpression; updateImportJob(key: DetailKey, payload: DdbUpdateItem): Promise; publishAlarm(event: ImportQueueEvent, errorDetails: any): Promise; /** * Loads a single import record from DynamoDB by primary key. * * @returns The import entity when the item exists, or `null` when no row matches * the key */ getImportByKey(key: DetailKey): Promise; }