( filePath: string, deps: StreamImportDeps, formatOptions?: Record<string, unknown>, externalSessionId?: string )
| 95 | * with batched transactions. Supports format auto-detection with fallback. |
| 96 | */ |
| 97 | export async function streamingImport( |
| 98 | filePath: string, |
| 99 | deps: StreamImportDeps, |
| 100 | formatOptions?: Record<string, unknown>, |
| 101 | externalSessionId?: string |
| 102 | ): Promise<StreamImportResult> { |
| 103 | if (formatOptions?.formatId) { |
| 104 | const formatId = formatOptions.formatId as string |
| 105 | const feature = getFormatFeatureById(formatId) |
| 106 | if (!feature) { |
| 107 | return { success: false, error: 'error.unknown_format_id' } |
| 108 | } |
| 109 | return streamImportSingle(filePath, deps, feature, formatOptions, externalSessionId) |
| 110 | } |
| 111 | |
| 112 | const candidates = detectAllFormats(filePath) |
| 113 | if (candidates.length === 0) { |
| 114 | return { success: false, error: 'error.unrecognized_format' } |
| 115 | } |
| 116 | |
| 117 | if (candidates.length > 1) { |
| 118 | return streamImportWithFallback(filePath, deps, candidates, formatOptions, externalSessionId) |
| 119 | } |
| 120 | |
| 121 | return streamImportSingle(filePath, deps, candidates[0], formatOptions, externalSessionId) |
| 122 | } |
| 123 | |
| 124 | async function streamImportWithFallback( |
| 125 | filePath: string, |
no test coverage detected