Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\DataExchange\Application\Service;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Core\DataExchange\Domain\Model\ImportMappingConfig;
12use App\Core\DataExchange\Domain\Model\ImportResultDto;
13use App\Core\Engine\Domain\Model\PermissionContext;
14
15/**
16 * Service contract orchestrating multi-step tabular data imports.
17 *
18 * @package App\Core\DataExchange\Application\Service
19 */
20interface DataImportServiceInterface
21{
22    /**
23     * Analyzes an uploaded file, extracts header metadata, sample rows, and suggests field mappings.
24     *
25     * @param string $filePath   Absolute path to uploaded spreadsheet file.
26     * @param string $moduleName Target module machine name.
27     * @return array{
28     *     file_headers: list<string>,
29     *     sample_rows: list<array<string, string>>,
30     *     module_fields: list<array{key: string, label: string, uitype: string, is_mandatory: bool, is_unique: bool}>,
31     *     suggested_mapping: array<string, string>
32     * }
33     */
34    public function analyzeFile(string $filePath, string $moduleName): array;
35
36    /**
37     * Executes data import streaming with strict UiType validation and deduplication strategies.
38     *
39     * @param string                         $moduleName  Target module machine name.
40     * @param string                         $filePath    Path to source tabular file.
41     * @param ImportMappingConfig            $config      Import configuration and column mapping rules.
42     * @param PermissionContext              $context     User security context.
43     * @param (callable(int, int):void)|null $onProgress  Optional progress callback ($processed, $totalEstimate).
44     * @return ImportResultDto Summary metrics and row error details.
45     */
46    public function executeImport(
47        string $moduleName,
48        string $filePath,
49        ImportMappingConfig $config,
50        PermissionContext $context,
51        ?callable $onProgress = null
52    ): ImportResultDto;
53}