O módulo usa a identidade Supabase, isola cada workspace e registra storage, TTL, runner e biblioteca XLSX como decisões ainda abertas. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
845 B
TypeScript
29 lines
845 B
TypeScript
import { PREVIEW_ROWS } from "./limits";
|
|
import { transformRows } from "./transform";
|
|
import type { ColumnSchema, MappingInput } from "./types";
|
|
|
|
export type PreviewContract = {
|
|
preview: true;
|
|
columns: { name: string; required: boolean }[];
|
|
rows: string[][];
|
|
rowCount: number;
|
|
truncated: boolean;
|
|
};
|
|
|
|
export function buildPreview(
|
|
modelColumns: ColumnSchema[],
|
|
sourceHeaders: string[],
|
|
dataRows: string[][],
|
|
mappings: MappingInput[],
|
|
): PreviewContract {
|
|
const ordered = modelColumns.map((column) => column.name);
|
|
const all = transformRows(ordered, sourceHeaders, dataRows, mappings);
|
|
return {
|
|
preview: true,
|
|
columns: modelColumns.map((column) => ({ name: column.name, required: column.required })),
|
|
rows: all.slice(0, PREVIEW_ROWS),
|
|
rowCount: all.length,
|
|
truncated: all.length > PREVIEW_ROWS,
|
|
};
|
|
}
|