fix(Google Sheets Node): RMC should correctly map columns if data location set in options (#13116)

Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
This commit is contained in:
Michael Kret
2025-02-10 11:30:33 +02:00
committed by GitHub
parent da837feb26
commit 5d05f7f436
4 changed files with 157 additions and 5 deletions

View File

@@ -105,11 +105,11 @@ export function addRowNumber(data: SheetRangeData, headerRow: number) {
export function trimToFirstEmptyRow(data: SheetRangeData, includesRowNumber = true) {
const baseLength = includesRowNumber ? 1 : 0;
const emtyRowIndex = data.findIndex((row) => row.slice(baseLength).every((cell) => cell === ''));
if (emtyRowIndex === -1) {
const emptyRowIndex = data.findIndex((row) => row.slice(baseLength).every((cell) => cell === ''));
if (emptyRowIndex === -1) {
return data;
}
return data.slice(0, emtyRowIndex);
return data.slice(0, emptyRowIndex);
}
export function removeEmptyRows(data: SheetRangeData, includesRowNumber = true) {
@@ -343,8 +343,10 @@ export function checkForSchemaChanges(
schema: ResourceMapperField[],
) {
const updatedColumnNames: Array<{ oldName: string; newName: string }> = [];
// RMC filters out empty columns so do the same here
columnNames = columnNames.filter((col) => col !== '');
//if sheet does not contain ROW_NUMBER ignore it as data come from read rows operation
// if sheet does not contain ROW_NUMBER ignore it as data come from read rows operation
const schemaColumns = columnNames.includes(ROW_NUMBER)
? schema.map((s) => s.id)
: schema.filter((s) => s.id !== ROW_NUMBER).map((s) => s.id);