mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
✨ Add delete operation to GoogleSheets-Node
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import { google } from 'googleapis';
|
||||
import { google, sheets_v4 } from 'googleapis';
|
||||
import { JWT } from 'google-auth-library';
|
||||
import { getAuthenticationClient } from './GoogleApi';
|
||||
|
||||
@@ -24,6 +24,18 @@ export interface ILookupValues {
|
||||
lookupValue: string;
|
||||
}
|
||||
|
||||
export interface IToDeleteRange {
|
||||
amount: number;
|
||||
startIndex: number;
|
||||
sheetId: number;
|
||||
}
|
||||
|
||||
export interface IToDelete {
|
||||
[key: string]: IToDeleteRange[] | undefined;
|
||||
columns?: IToDeleteRange[];
|
||||
rows?: IToDeleteRange[];
|
||||
}
|
||||
|
||||
export type ValueInputOption = 'RAW' | 'USER_ENTERED';
|
||||
|
||||
export type ValueRenderOption = 'FORMATTED_VALUE' | 'FORMULA' | 'UNFORMATTED_VALUE';
|
||||
@@ -85,6 +97,44 @@ export class GoogleSheet {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the sheets in a Spreadsheet
|
||||
*/
|
||||
async spreadsheetGetSheets() {
|
||||
const client = await this.getAuthenticationClient();
|
||||
|
||||
const response = await Sheets.spreadsheets.get(
|
||||
{
|
||||
auth: client,
|
||||
spreadsheetId: this.id,
|
||||
fields: 'sheets.properties'
|
||||
}
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets values in one or more ranges of a spreadsheet.
|
||||
*/
|
||||
async spreadsheetBatchUpdate(requests: sheets_v4.Schema$Request[]) { // tslint:disable-line:no-any
|
||||
const client = await this.getAuthenticationClient();
|
||||
|
||||
const response = await Sheets.spreadsheets.batchUpdate(
|
||||
{
|
||||
auth: client,
|
||||
spreadsheetId: this.id,
|
||||
requestBody: {
|
||||
requests,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the cell values
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user