Feature/Add teams, gmail, outlook tools (#4577)

* add teams, gmail, outlook tools

* update docs link

* update credentials for oauth2

* add jira tool

* add google drive, google calendar, google sheets tools, powerpoint, excel, word doc loader

* update jira logo

* Refactor Gmail and Outlook tools to remove maxOutputLength parameter and enhance request handling. Update response formatting to include parameters in the output. Adjust Google Drive tools to simplify success messages by removing unnecessary parameter details.
This commit is contained in:
Henry Heng
2025-06-06 19:52:04 +01:00
committed by GitHub
parent 6dcb65cedb
commit 30c4180d97
62 changed files with 16832 additions and 144 deletions
@@ -0,0 +1,424 @@
import { convertMultiOptionsToStringArray, getCredentialData, getCredentialParam, refreshOAuth2Token } from '../../../src/utils'
import { createGoogleSheetsTools } from './core'
import type { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
class GoogleSheets_Tools implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'Google Sheets'
this.name = 'googleSheetsTool'
this.version = 1.0
this.type = 'GoogleSheets'
this.icon = 'google-sheets.svg'
this.category = 'Tools'
this.description = 'Perform Google Sheets operations such as managing spreadsheets, reading and writing values'
this.baseClasses = ['Tool']
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['googleSheetsOAuth2']
}
this.inputs = [
{
label: 'Type',
name: 'sheetsType',
type: 'options',
description: 'Type of Google Sheets operation',
options: [
{
label: 'Spreadsheet',
name: 'spreadsheet'
},
{
label: 'Values',
name: 'values'
}
]
},
// Spreadsheet Actions
{
label: 'Spreadsheet Actions',
name: 'spreadsheetActions',
type: 'multiOptions',
description: 'Actions to perform on spreadsheets',
options: [
{
label: 'Create Spreadsheet',
name: 'createSpreadsheet'
},
{
label: 'Get Spreadsheet',
name: 'getSpreadsheet'
},
{
label: 'Update Spreadsheet',
name: 'updateSpreadsheet'
}
],
show: {
sheetsType: ['spreadsheet']
}
},
// Values Actions
{
label: 'Values Actions',
name: 'valuesActions',
type: 'multiOptions',
description: 'Actions to perform on sheet values',
options: [
{
label: 'Get Values',
name: 'getValues'
},
{
label: 'Update Values',
name: 'updateValues'
},
{
label: 'Append Values',
name: 'appendValues'
},
{
label: 'Clear Values',
name: 'clearValues'
},
{
label: 'Batch Get Values',
name: 'batchGetValues'
},
{
label: 'Batch Update Values',
name: 'batchUpdateValues'
},
{
label: 'Batch Clear Values',
name: 'batchClearValues'
}
],
show: {
sheetsType: ['values']
}
},
// Spreadsheet Parameters
{
label: 'Spreadsheet ID',
name: 'spreadsheetId',
type: 'string',
description: 'The ID of the spreadsheet',
show: {
sheetsType: ['spreadsheet', 'values']
},
additionalParams: true,
optional: true
},
{
label: 'Title',
name: 'title',
type: 'string',
description: 'The title of the spreadsheet',
show: {
spreadsheetActions: ['createSpreadsheet', 'updateSpreadsheet']
},
additionalParams: true,
optional: true
},
{
label: 'Sheet Count',
name: 'sheetCount',
type: 'number',
description: 'Number of sheets to create',
default: 1,
show: {
spreadsheetActions: ['createSpreadsheet']
},
additionalParams: true,
optional: true
},
// Values Parameters
{
label: 'Range',
name: 'range',
type: 'string',
description: 'The range to read/write (e.g., A1:B2, Sheet1!A1:C10)',
show: {
valuesActions: ['getValues', 'updateValues', 'clearValues']
},
additionalParams: true,
optional: true
},
{
label: 'Ranges',
name: 'ranges',
type: 'string',
description: 'Comma-separated list of ranges for batch operations',
show: {
valuesActions: ['batchGetValues', 'batchClearValues']
},
additionalParams: true,
optional: true
},
{
label: 'Values',
name: 'values',
type: 'string',
description: 'JSON array of values to write (e.g., [["A1", "B1"], ["A2", "B2"]])',
show: {
valuesActions: ['updateValues', 'appendValues', 'batchUpdateValues']
},
additionalParams: true,
optional: true
},
{
label: 'Value Input Option',
name: 'valueInputOption',
type: 'options',
description: 'How input data should be interpreted',
options: [
{
label: 'Raw',
name: 'RAW'
},
{
label: 'User Entered',
name: 'USER_ENTERED'
}
],
default: 'USER_ENTERED',
show: {
valuesActions: ['updateValues', 'appendValues', 'batchUpdateValues']
},
additionalParams: true,
optional: true
},
{
label: 'Value Render Option',
name: 'valueRenderOption',
type: 'options',
description: 'How values should be represented in the output',
options: [
{
label: 'Formatted Value',
name: 'FORMATTED_VALUE'
},
{
label: 'Unformatted Value',
name: 'UNFORMATTED_VALUE'
},
{
label: 'Formula',
name: 'FORMULA'
}
],
default: 'FORMATTED_VALUE',
show: {
valuesActions: ['getValues', 'batchGetValues']
},
additionalParams: true,
optional: true
},
{
label: 'Date Time Render Option',
name: 'dateTimeRenderOption',
type: 'options',
description: 'How dates, times, and durations should be represented',
options: [
{
label: 'Serial Number',
name: 'SERIAL_NUMBER'
},
{
label: 'Formatted String',
name: 'FORMATTED_STRING'
}
],
default: 'FORMATTED_STRING',
show: {
valuesActions: ['getValues', 'batchGetValues']
},
additionalParams: true,
optional: true
},
{
label: 'Insert Data Option',
name: 'insertDataOption',
type: 'options',
description: 'How data should be inserted',
options: [
{
label: 'Overwrite',
name: 'OVERWRITE'
},
{
label: 'Insert Rows',
name: 'INSERT_ROWS'
}
],
default: 'OVERWRITE',
show: {
valuesActions: ['appendValues']
},
additionalParams: true,
optional: true
},
{
label: 'Include Grid Data',
name: 'includeGridData',
type: 'boolean',
description: 'True if grid data should be returned',
default: false,
show: {
spreadsheetActions: ['getSpreadsheet']
},
additionalParams: true,
optional: true
},
{
label: 'Major Dimension',
name: 'majorDimension',
type: 'options',
description: 'The major dimension that results should use',
options: [
{
label: 'Rows',
name: 'ROWS'
},
{
label: 'Columns',
name: 'COLUMNS'
}
],
default: 'ROWS',
show: {
valuesActions: ['getValues', 'updateValues', 'appendValues', 'batchGetValues', 'batchUpdateValues']
},
additionalParams: true,
optional: true
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const sheetsType = nodeData.inputs?.sheetsType as string
let credentialData = await getCredentialData(nodeData.credential ?? '', options)
credentialData = await refreshOAuth2Token(nodeData.credential ?? '', credentialData, options)
const accessToken = getCredentialParam('access_token', credentialData, nodeData)
if (!accessToken) {
throw new Error('No access token found in credential')
}
// Get all actions based on type
let actions: string[] = []
if (sheetsType === 'spreadsheet') {
actions = convertMultiOptionsToStringArray(nodeData.inputs?.spreadsheetActions)
} else if (sheetsType === 'values') {
actions = convertMultiOptionsToStringArray(nodeData.inputs?.valuesActions)
}
// Create default params object based on inputs
const defaultParams: any = {}
// Spreadsheet-specific default params
if (sheetsType === 'spreadsheet') {
actions.forEach((action) => {
const params: any = {}
// Common spreadsheet parameters
if (nodeData.inputs?.spreadsheetId) params.spreadsheetId = nodeData.inputs.spreadsheetId
if (action === 'createSpreadsheet') {
if (nodeData.inputs?.title) params.title = nodeData.inputs.title
if (nodeData.inputs?.sheetCount) params.sheetCount = nodeData.inputs.sheetCount
}
if (action === 'getSpreadsheet') {
if (nodeData.inputs?.ranges) params.ranges = nodeData.inputs.ranges
if (nodeData.inputs?.includeGridData !== undefined) params.includeGridData = nodeData.inputs.includeGridData
}
if (action === 'updateSpreadsheet') {
if (nodeData.inputs?.title) params.title = nodeData.inputs.title
}
defaultParams[action] = params
})
}
// Values-specific default params
if (sheetsType === 'values') {
actions.forEach((action) => {
const params: any = {}
// Common values parameters
if (nodeData.inputs?.spreadsheetId) params.spreadsheetId = nodeData.inputs.spreadsheetId
if (action === 'getValues') {
if (nodeData.inputs?.range) params.range = nodeData.inputs.range
if (nodeData.inputs?.valueRenderOption) params.valueRenderOption = nodeData.inputs.valueRenderOption
if (nodeData.inputs?.dateTimeRenderOption) params.dateTimeRenderOption = nodeData.inputs.dateTimeRenderOption
if (nodeData.inputs?.majorDimension) params.majorDimension = nodeData.inputs.majorDimension
}
if (action === 'updateValues') {
if (nodeData.inputs?.range) params.range = nodeData.inputs.range
if (nodeData.inputs?.values) params.values = nodeData.inputs.values
if (nodeData.inputs?.valueInputOption) params.valueInputOption = nodeData.inputs.valueInputOption
if (nodeData.inputs?.majorDimension) params.majorDimension = nodeData.inputs.majorDimension
}
if (action === 'appendValues') {
if (nodeData.inputs?.range) params.range = nodeData.inputs.range
if (nodeData.inputs?.values) params.values = nodeData.inputs.values
if (nodeData.inputs?.valueInputOption) params.valueInputOption = nodeData.inputs.valueInputOption
if (nodeData.inputs?.insertDataOption) params.insertDataOption = nodeData.inputs.insertDataOption
if (nodeData.inputs?.majorDimension) params.majorDimension = nodeData.inputs.majorDimension
}
if (action === 'clearValues') {
if (nodeData.inputs?.range) params.range = nodeData.inputs.range
}
if (action === 'batchGetValues') {
if (nodeData.inputs?.ranges) params.ranges = nodeData.inputs.ranges
if (nodeData.inputs?.valueRenderOption) params.valueRenderOption = nodeData.inputs.valueRenderOption
if (nodeData.inputs?.dateTimeRenderOption) params.dateTimeRenderOption = nodeData.inputs.dateTimeRenderOption
if (nodeData.inputs?.majorDimension) params.majorDimension = nodeData.inputs.majorDimension
}
if (action === 'batchUpdateValues') {
if (nodeData.inputs?.values) params.values = nodeData.inputs.values
if (nodeData.inputs?.valueInputOption) params.valueInputOption = nodeData.inputs.valueInputOption
}
if (action === 'batchClearValues') {
if (nodeData.inputs?.ranges) params.ranges = nodeData.inputs.ranges
}
defaultParams[action] = params
})
}
const tools = createGoogleSheetsTools({
accessToken,
actions,
defaultParams
})
return tools
}
}
module.exports = { nodeClass: GoogleSheets_Tools }