mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
|
import { apiRequest } from '../../transport';
|
|
import type { GoogleSheet } from '../../helpers/GoogleSheet';
|
|
import { wrapData } from '../../../../../../utils/utilities';
|
|
|
|
export async function execute(
|
|
this: IExecuteFunctions,
|
|
sheet: GoogleSheet,
|
|
sheetName: string,
|
|
): Promise<INodeExecutionData[]> {
|
|
const returnData: INodeExecutionData[] = [];
|
|
const items = this.getInputData();
|
|
for (let i = 0; i < items.length; i++) {
|
|
const [spreadsheetId, sheetWithinDocument] = sheetName.split('||');
|
|
const requests = [
|
|
{
|
|
deleteSheet: {
|
|
sheetId: sheetWithinDocument,
|
|
},
|
|
},
|
|
];
|
|
|
|
const responseData = await apiRequest.call(
|
|
this,
|
|
'POST',
|
|
`/v4/spreadsheets/${spreadsheetId}:batchUpdate`,
|
|
{ requests },
|
|
);
|
|
delete responseData.replies;
|
|
|
|
const executionData = this.helpers.constructExecutionMetaData(
|
|
wrapData(responseData as IDataObject[]),
|
|
{ itemData: { item: i } },
|
|
);
|
|
|
|
returnData.push(...executionData);
|
|
}
|
|
|
|
return returnData;
|
|
}
|