import type { User } from '@n8n/db'; import type { Readable } from 'node:stream'; import type { DataTableResolutionFailure } from './entities/data-table/data-table.types'; import type { VariableResolutionFailure } from './entities/variable/variable.types'; import type { WorkflowIdConflict } from './entities/workflow/workflow-import-match.service'; import type { WorkflowConflict, WorkflowFolderConflict } from './entities/workflow/workflow-import.types'; import type { WorkflowPublishingOutcome, WorkflowPublishingPolicy } from './entities/workflow/workflow-publishing-policy.types'; export type { CredentialResolution } from './entities/credential/credential.types'; export { WorkflowPublishingPolicy } from './entities/workflow/workflow-publishing-policy.types'; export type { WorkflowPublishingOutcome } from './entities/workflow/workflow-publishing-policy.types'; export type CredentialMatchingMode = 'id-only' | 'name-and-type' | 'type-only'; export type CredentialMissingMode = 'must-preexist' | 'create-stub'; export type PackageFailureReason = 'access-denied' | 'entity-not-found' | 'blocked' | 'validation'; export declare const WorkflowConflictPolicy: { readonly NewVersion: 'new-version'; readonly Fail: 'fail'; readonly Skip: 'skip'; }; export declare const WorkflowIdPolicy: { readonly New: 'new'; readonly Source: 'source'; }; export declare const FolderConflictPolicy: { readonly Merge: 'merge'; readonly Fail: 'fail'; }; export declare const MissingNodeTypeMode: { readonly Fail: 'fail'; readonly ImportAnyway: 'import-anyway'; }; export declare const MissingWorkflowDependencyPolicy: { readonly Fail: 'fail'; readonly ReferenceOnly: 'reference-only'; readonly IncludeInPackage: 'include-in-package'; }; export declare const DataTableMatchingMode: { readonly ById: 'by-id'; }; export declare const DataTableMissingMode: { readonly Create: 'create'; readonly MustPreexist: 'must-preexist'; readonly DoNothing: 'do-nothing'; }; export declare const DataTableSchemaConflictPolicy: { readonly KeepExisting: 'keep-existing'; readonly Fail: 'fail'; }; export declare const VariableMissingMode: { readonly DoNothing: 'do-nothing'; readonly MustPreexist: 'must-preexist'; }; export type WorkflowConflictPolicy = (typeof WorkflowConflictPolicy)[keyof typeof WorkflowConflictPolicy]; export type WorkflowIdPolicy = (typeof WorkflowIdPolicy)[keyof typeof WorkflowIdPolicy]; export type FolderConflictPolicy = (typeof FolderConflictPolicy)[keyof typeof FolderConflictPolicy]; export type MissingNodeTypeMode = (typeof MissingNodeTypeMode)[keyof typeof MissingNodeTypeMode]; export type MissingWorkflowDependencyPolicy = (typeof MissingWorkflowDependencyPolicy)[keyof typeof MissingWorkflowDependencyPolicy]; export type DataTableMatchingMode = (typeof DataTableMatchingMode)[keyof typeof DataTableMatchingMode]; export type DataTableMissingMode = (typeof DataTableMissingMode)[keyof typeof DataTableMissingMode]; export type DataTableSchemaConflictPolicy = (typeof DataTableSchemaConflictPolicy)[keyof typeof DataTableSchemaConflictPolicy]; export type VariableMissingMode = (typeof VariableMissingMode)[keyof typeof VariableMissingMode]; export interface ExportPackageRequest { user: User; workflowIds?: string[]; folderIds?: string[]; projectIds?: string[]; includeVariableValues?: boolean; canExportVariableValues?: boolean; missingWorkflowDependencyPolicy?: MissingWorkflowDependencyPolicy; } export type ImportPackageRequest = { user: User; projectId?: string; folderId?: string; packageBuffer: Buffer; bindings?: Partial; apiKeyScopes?: string[]; } & ImportCredentialProperties & ImportWorkflowProperties & ImportFolderProperties & ImportDataTableProperties & ImportVariableProperties; export type ImportCredentialProperties = { credentialMatchingMode: CredentialMatchingMode; credentialMissingMode: CredentialMissingMode; }; export type ImportWorkflowProperties = { workflowConflictPolicy: WorkflowConflictPolicy; workflowPublishingPolicy: WorkflowPublishingPolicy; workflowIdPolicy: WorkflowIdPolicy; missingNodeTypeMode: MissingNodeTypeMode; }; export type ImportFolderProperties = { folderConflictPolicy: FolderConflictPolicy; }; export type ImportDataTableProperties = { dataTableMatchingMode: DataTableMatchingMode; dataTableMissingMode: DataTableMissingMode; dataTableSchemaConflictPolicy: DataTableSchemaConflictPolicy; }; export type ImportVariableProperties = { variableMissingMode: VariableMissingMode; }; export interface ImportContext { user: User; projectId: string; folderId: string | null; } export type ImportPackageEventOptions = ImportCredentialProperties & ImportWorkflowProperties & ImportDataTableProperties & ImportVariableProperties; export type ImportAuditCredentialIds = { matched: string[]; created: string[]; updated: string[]; }; export type ImportPackageEventCounts = { workflows: { created: number; updated: number; skipped: number; }; credentials: { matched: number; created: number; requirements: number; }; dataTables: { matched: number; created: number; requirements: number; }; variables: { matched: number; missing: number; requirements: number; }; }; export type ExportPackageEventCounts = { workflows: number; folders: number; credentials: number; dataTables: number; variables: number; }; export interface ExportPackageResult { stream: Readable; counts: ExportPackageEventCounts; } export interface ImportedWorkflowSummary { sourceWorkflowId: string; localId: string; name: string; projectId: string; parentFolderId: string | null; activeVersionId: string | null; publishing: WorkflowPublishingOutcome; status: 'created' | 'updated' | 'skipped'; } export interface ImportedFolderSummary { sourceFolderId: string; localId: string; name: string; parentFolderId: string | null; status: 'created' | 'skipped'; } export interface ImportedProjectSummary { sourceProjectId: string; localId: string; name: string; status: 'created' | 'updated'; } export type BlockingIssue = ({ type: 'workflow-conflict'; } & WorkflowConflict) | ({ type: 'workflow-id-conflict'; } & WorkflowIdConflict) | ({ type: 'workflow-folder-conflict'; } & WorkflowFolderConflict) | { type: 'credential-unresolved'; kind: 'not_found' | 'unknown_type' | 'source_not_found' | 'type_mismatch'; sourceId: string; targetId?: string; expectedType?: string; actualType?: string; usedByWorkflows: string[]; } | ({ type: 'folder-conflict'; } & FolderConflict) | ({ type: 'data-table-unresolved'; } & DataTableResolutionFailure) | ({ type: 'variable-unresolved'; } & VariableResolutionFailure) | { type: 'missing-node-type'; nodeType: string; typeVersion: number; usedByWorkflows: string[]; }; export interface FolderConflict { kind: 'parent-mismatch' | 'id-in-other-project' | 'fail-policy'; sourceFolderId: string; name: string; existingParentFolderId?: string | null; expectedParentFolderId?: string | null; existingProjectId?: string | null; } export type ImportBindingMap = Map; export interface PackageImportBindings { workflows: ImportBindingMap; credentials: ImportBindingMap; } export declare function createBindings(seed?: Partial): PackageImportBindings; export declare function mergeBindings(...bindings: PackageImportBindings[]): PackageImportBindings; export type SerializedBindings = Record>; export declare function serializeBindings(bindings: PackageImportBindings): SerializedBindings; export interface ImportPackageSummary { sourceN8nVersion: string; sourceId: string; exportedAt: string; } export interface ImportCredentialSummary { matched: string[]; stubbed: string[]; } export interface ImportVariableSummary { matched: string[]; missing: string[]; } export interface ImportResult { package: ImportPackageSummary; workflows: ImportedWorkflowSummary[]; folders: ImportedFolderSummary[]; projects: ImportedProjectSummary[]; bindings: SerializedBindings; credentials: ImportCredentialSummary; variables: ImportVariableSummary; }