web / app/api/import/preview-schema/helpers
app/api/import/preview-schema/helpers
Shared helpers for preview-schema endpoints (upload and URL).
Contains file parsing, field detection, URL validation, and metadata persistence logic used by both the upload and URL preview routes.
Variables
ALLOWED_MIME_TYPES
constALLOWED_MIME_TYPES:string[]
MAX_FILE_SIZE
constMAX_FILE_SIZE:number
SAMPLE_ROW_COUNT
constSAMPLE_ROW_COUNT:5=5
FILE_EXTENSION_REGEX
constFILE_EXTENSION_REGEX:RegExp
SUPPORTED_EXTENSIONS
constSUPPORTED_EXTENSIONS:string[]
Functions
detectSuggestedMappings()
detectSuggestedMappings(
headers,sampleData):SuggestedMappings
Detect suggested field mappings for a sheet
Parameters
headers
string[]
sampleData
Record<string, unknown>[]
Returns
getPreviewDir()
getPreviewDir():
string
Returns
string
parseCSVPreview()
parseCSVPreview(
filePath):SheetInfo[]
Parameters
filePath
string
Returns
parseExcelPreview()
parseExcelPreview(
filePath):SheetInfo[]
Parameters
filePath
string
Returns
parseFileSheets()
parseFileSheets(
filePath,fileExtension):SheetInfo[]
Parse file sheets based on file extension.
Parameters
filePath
string
fileExtension
string
Returns
savePreviewMetadata()
savePreviewMetadata(
opts):void
Save preview metadata to disk. Intentionally omits authConfig to avoid persisting secrets to disk.
Parameters
opts
previewId
string
userId
number
originalName
string
filePath
string
mimeType
string
fileSize
number
sourceUrl?
string
Returns
void
References
AuthConfig
Re-exports AuthConfig
SheetInfo
Re-exports SheetInfo
SuggestedMappings
Re-exports SuggestedMappings
validateUrl
Renames and re-exports validateExternalHttpUrl