import { Injectable } from '@nestjs/common';
import { ProcessSharedService } from '../process-shared/process-shared.service';
import { ProcessImportCommitDto, ProcessListQuery } from '../process-shared/process-shared.dto';
import { ProcessRecordWriteDto } from '../process-shared/process-shared.types';

@Injectable()
export class HolderProcessService {
  constructor(private readonly processSharedService: ProcessSharedService) {}

  list(query: ProcessListQuery) {
    return this.processSharedService.list('holder', query);
  }

  detail(id: string) {
    return this.processSharedService.detail('holder', id);
  }

  create(dto: ProcessRecordWriteDto) {
    return this.processSharedService.create('holder', dto);
  }

  update(id: string, dto: ProcessRecordWriteDto) {
    return this.processSharedService.update('holder', id, dto);
  }

  delete(id: string) {
    return this.processSharedService.delete('holder', id);
  }

  options() {
    return this.processSharedService.options('holder');
  }

  calculate(dto: ProcessRecordWriteDto) {
    return this.processSharedService.calculate('holder', dto);
  }

  previewImport(fileName: string, buffer: Buffer) {
    return this.processSharedService.previewImport('holder', fileName, buffer);
  }

  importFile(fileName: string, buffer: Buffer, mode: 'validOnly' | 'allOrNothing') {
    return this.processSharedService.importFile('holder', fileName, buffer, mode);
  }

  commitImport(dto: ProcessImportCommitDto) {
    return this.processSharedService.commitImport('holder', dto);
  }

  export(query: ProcessListQuery & { format?: string }) {
    return this.processSharedService.export('holder', query);
  }

  sample(format = 'xlsx') {
    return this.processSharedService.sample('holder', format);
  }
}
