import type { SourceControlledFile } from '@n8n/api-types';
import { Logger } from '@n8n/backend-common';
import type { TagEntity, User, Variables } from '@n8n/db';
import { CredentialsRepository, FolderRepository, ProjectRelationRepository, ProjectRepository, SharedCredentialsRepository, SharedWorkflowRepository, TagRepository, UserRepository, VariablesRepository, WorkflowRepository, WorkflowTagMapping, WorkflowTagMappingRepository } from '@n8n/db';
import { ErrorReporter, InstanceSettings } from 'n8n-core';
import type { AutoPublishMode } from 'n8n-workflow';
import { CredentialsService } from '../../credentials/credentials.service';
import { DataTableColumnRepository } from '../../modules/data-table/data-table-column.repository';
import { DataTableDDLService } from '../../modules/data-table/data-table-ddl.service';
import { DataTableRepository } from '../../modules/data-table/data-table.repository';
import { TagService } from '../../services/tag.service';
import { WorkflowHistoryService } from '../../workflows/workflow-history/workflow-history.service';
import { WorkflowService } from '../../workflows/workflow.service';
import { SourceControlContextFactory } from './source-control-context.factory';
import { SourceControlScopedService } from './source-control-scoped.service';
import type { StatusExportableCredential } from './types/exportable-credential';
import type { ExportableDataTable, StatusExportableDataTable } from './types/exportable-data-table';
import type { ExportableFolder } from './types/exportable-folders';
import type { ExportableProjectWithFileName } from './types/exportable-project';
import type { ExportableTags } from './types/exportable-tags';
import { ExportableVariable } from './types/exportable-variable';
import { SourceControlContext } from './types/source-control-context';
import type { SourceControlWorkflowVersionId } from './types/source-control-workflow-version-id';
import { VariablesService } from '../../environments.ee/variables/variables.service.ee';
export declare class SourceControlImportService {
    private readonly logger;
    private readonly errorReporter;
    private readonly variablesService;
    private readonly credentialsRepository;
    private readonly projectRepository;
    private readonly projectRelationRepository;
    private readonly tagRepository;
    private readonly sharedWorkflowRepository;
    private readonly sharedCredentialsRepository;
    private readonly userRepository;
    private readonly variablesRepository;
    private readonly workflowRepository;
    private readonly workflowTagMappingRepository;
    private readonly workflowService;
    private readonly credentialsService;
    private readonly tagService;
    private readonly folderRepository;
    private readonly sourceControlContextFactory;
    private readonly sourceControlScopedService;
    private readonly workflowHistoryService;
    private readonly dataTableRepository;
    private readonly dataTableColumnRepository;
    private readonly dataTableDDLService;
    private gitFolder;
    private workflowExportFolder;
    private credentialExportFolder;
    private projectExportFolder;
    private dataTableExportFolder;
    constructor(logger: Logger, errorReporter: ErrorReporter, variablesService: VariablesService, credentialsRepository: CredentialsRepository, projectRepository: ProjectRepository, projectRelationRepository: ProjectRelationRepository, tagRepository: TagRepository, sharedWorkflowRepository: SharedWorkflowRepository, sharedCredentialsRepository: SharedCredentialsRepository, userRepository: UserRepository, variablesRepository: VariablesRepository, workflowRepository: WorkflowRepository, workflowTagMappingRepository: WorkflowTagMappingRepository, workflowService: WorkflowService, credentialsService: CredentialsService, tagService: TagService, folderRepository: FolderRepository, instanceSettings: InstanceSettings, sourceControlContextFactory: SourceControlContextFactory, sourceControlScopedService: SourceControlScopedService, workflowHistoryService: WorkflowHistoryService, dataTableRepository: DataTableRepository, dataTableColumnRepository: DataTableColumnRepository, dataTableDDLService: DataTableDDLService);
    getRemoteVersionIdsFromFiles(context: SourceControlContext): Promise<SourceControlWorkflowVersionId[]>;
    getAllLocalVersionIdsFromDb(): Promise<SourceControlWorkflowVersionId[]>;
    getLocalVersionIdsFromDb(context: SourceControlContext): Promise<SourceControlWorkflowVersionId[]>;
    getRemoteCredentialsFromFiles(context: SourceControlContext): Promise<StatusExportableCredential[]>;
    getLocalCredentialsFromDb(context: SourceControlContext): Promise<StatusExportableCredential[]>;
    getRemoteVariablesFromFile(): Promise<ExportableVariable[]>;
    getLocalGlobalVariablesFromDb(): Promise<Variables[]>;
    getRemoteDataTablesFromFiles(): Promise<ExportableDataTable[]>;
    getLocalDataTablesFromDb(): Promise<StatusExportableDataTable[]>;
    getRemoteFoldersAndMappingsFromFile(context: SourceControlContext): Promise<{
        folders: ExportableFolder[];
    }>;
    getLocalFoldersAndMappingsFromDb(context: SourceControlContext): Promise<{
        folders: ExportableFolder[];
    }>;
    getRemoteTagsAndMappingsFromFile(context: SourceControlContext): Promise<ExportableTags>;
    getLocalTagsAndMappingsFromDb(context: SourceControlContext): Promise<ExportableTags>;
    getRemoteProjectsFromFiles(context: SourceControlContext): Promise<ExportableProjectWithFileName[]>;
    getLocalTeamProjectsFromDb(context?: SourceControlContext): Promise<ExportableProjectWithFileName[]>;
    private mapProjectEntityToExportableProjectWithFileName;
    importWorkflowFromWorkFolder(candidates: SourceControlledFile[], userId: string, autoPublish?: AutoPublishMode): Promise<{
        id: string;
        name: string;
        publishingError: string | undefined;
    }[]>;
    private importSingleWorkflowFromFile;
    private parseWorkflowFromFile;
    private shouldAutoPublishWorkflow;
    private mustUnpublishLocalWorkflow;
    private unpublishWorkflow;
    private publishWorkflow;
    importCredentialsFromWorkFolder(candidates: SourceControlledFile[], userId: string): Promise<{
        id: string;
        name: string;
        type: string;
    }[]>;
    importTagsFromWorkFolder(candidate: SourceControlledFile, user: User): Promise<{
        tags: TagEntity[];
        mappings: WorkflowTagMapping[];
    } | undefined>;
    importFoldersFromWorkFolder(user: User, candidate: SourceControlledFile): Promise<{
        folders: ExportableFolder[];
    } | undefined>;
    importVariables(variables: ExportableVariable[], valueOverrides?: {
        [key: string]: string;
    }): Promise<{
        imported: string[];
    }>;
    importVariablesFromWorkFolder(candidate: SourceControlledFile, valueOverrides?: {
        [key: string]: string;
    }): Promise<{
        imported: string[];
    } | undefined>;
    importDataTablesFromWorkFolder(candidates: SourceControlledFile[], userId: string): Promise<{
        imported: string[];
    } | undefined>;
    importTeamProjectsFromWorkFolder(candidates: SourceControlledFile[], pullingUserId: string): Promise<{
        id: string;
        name: string;
    }[]>;
    deleteWorkflowsNotInWorkfolder(user: User, candidates: SourceControlledFile[]): Promise<void>;
    deleteCredentialsNotInWorkfolder(user: User, candidates: SourceControlledFile[]): Promise<void>;
    deleteVariablesNotInWorkfolder(candidates: SourceControlledFile[]): Promise<void>;
    deleteDataTablesNotInWorkFolder(candidates: SourceControlledFile[]): Promise<void>;
    deleteTagsNotInWorkfolder(candidates: SourceControlledFile[]): Promise<void>;
    deleteFoldersNotInWorkfolder(candidates: SourceControlledFile[]): Promise<void>;
    deleteTeamProjectsNotInWorkfolder(candidates: SourceControlledFile[]): Promise<void>;
    private syncResourceOwnership;
    private findOwnerProjectInLocalDb;
    private createTeamProject;
    private saveOrUpdateWorkflowHistory;
    private preparePublishStateForImport;
    private resolvePublishedStatus;
}
