Compare commits
13 Commits
main
...
feature/OA
| Author | SHA1 | Date |
|---|---|---|
|
|
94187b2b0c | |
|
|
2b5a6e4317 | |
|
|
ea3191b6b9 | |
|
|
a8ba0956fa | |
|
|
c1ea6462c8 | |
|
|
0d0b294e5f | |
|
|
848074589e | |
|
|
bece1dc62b | |
|
|
ad2f68dad4 | |
|
|
6a4277017c | |
|
|
3a39ff54e1 | |
|
|
4efc7fd0e2 | |
|
|
80e405a897 |
|
|
@ -0,0 +1,62 @@
|
|||
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||
const scopes = [
|
||||
'https://www.googleapis.com/auth/documents',
|
||||
'https://www.googleapis.com/auth/drive',
|
||||
'https://www.googleapis.com/auth/drive.file'
|
||||
]
|
||||
|
||||
class GoogleDocsOAuth2 implements INodeCredential {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
inputs: INodeParams[]
|
||||
description: string
|
||||
|
||||
constructor() {
|
||||
this.label = 'Google Docs OAuth2'
|
||||
this.name = 'googleDocsOAuth2'
|
||||
this.version = 1.0
|
||||
this.description =
|
||||
'You can find the setup instructions <a target="_blank" href="https://docs.flowiseai.com/integrations/langchain/tools/google-sheets">here</a>'
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Authorization URL',
|
||||
name: 'authorizationUrl',
|
||||
type: 'string',
|
||||
default: 'https://accounts.google.com/o/oauth2/v2/auth'
|
||||
},
|
||||
{
|
||||
label: 'Access Token URL',
|
||||
name: 'accessTokenUrl',
|
||||
type: 'string',
|
||||
default: 'https://oauth2.googleapis.com/token'
|
||||
},
|
||||
{
|
||||
label: 'Client ID',
|
||||
name: 'clientId',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
label: 'Client Secret',
|
||||
name: 'clientSecret',
|
||||
type: 'password'
|
||||
},
|
||||
{
|
||||
label: 'Additional Parameters',
|
||||
name: 'additionalParameters',
|
||||
type: 'string',
|
||||
default: 'access_type=offline&prompt=consent',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
label: 'Scope',
|
||||
name: 'scope',
|
||||
type: 'string',
|
||||
hidden: true,
|
||||
default: scopes.join(' ')
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { credClass: GoogleDocsOAuth2 }
|
||||
|
|
@ -226,6 +226,16 @@ class Tool_Agentflow implements INode {
|
|||
const toolInstance = (await newToolNodeInstance.init(newNodeData, '', options)) as Tool | Tool[]
|
||||
|
||||
let toolCallArgs: Record<string, any> = {}
|
||||
|
||||
if (newToolNodeInstance.transformNodeInputsToToolArgs) {
|
||||
const defaultParams = newToolNodeInstance.transformNodeInputsToToolArgs(newNodeData)
|
||||
|
||||
toolCallArgs = {
|
||||
...defaultParams,
|
||||
...toolCallArgs
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of toolInputArgs) {
|
||||
const variableName = item.inputArgName
|
||||
const variableValue = item.inputArgValue
|
||||
|
|
|
|||
|
|
@ -571,118 +571,7 @@ class Gmail_Tools implements INode {
|
|||
actions = convertMultiOptionsToStringArray(nodeData.inputs?.threadActions)
|
||||
}
|
||||
|
||||
// Prepare default parameters for each action
|
||||
const defaultParams: ICommonObject = {}
|
||||
|
||||
// Draft parameters
|
||||
const draftMaxResults = nodeData.inputs?.draftMaxResults
|
||||
const draftTo = nodeData.inputs?.draftTo
|
||||
const draftSubject = nodeData.inputs?.draftSubject
|
||||
const draftBody = nodeData.inputs?.draftBody
|
||||
const draftCc = nodeData.inputs?.draftCc
|
||||
const draftBcc = nodeData.inputs?.draftBcc
|
||||
const draftId = nodeData.inputs?.draftId
|
||||
const draftUpdateTo = nodeData.inputs?.draftUpdateTo
|
||||
const draftUpdateSubject = nodeData.inputs?.draftUpdateSubject
|
||||
const draftUpdateBody = nodeData.inputs?.draftUpdateBody
|
||||
|
||||
// Message parameters
|
||||
const messageMaxResults = nodeData.inputs?.messageMaxResults
|
||||
const messageQuery = nodeData.inputs?.messageQuery
|
||||
const messageTo = nodeData.inputs?.messageTo
|
||||
const messageSubject = nodeData.inputs?.messageSubject
|
||||
const messageBody = nodeData.inputs?.messageBody
|
||||
const messageCc = nodeData.inputs?.messageCc
|
||||
const messageBcc = nodeData.inputs?.messageBcc
|
||||
const messageId = nodeData.inputs?.messageId
|
||||
const messageAddLabelIds = nodeData.inputs?.messageAddLabelIds
|
||||
const messageRemoveLabelIds = nodeData.inputs?.messageRemoveLabelIds
|
||||
|
||||
// Label parameters
|
||||
const labelName = nodeData.inputs?.labelName
|
||||
const labelColor = nodeData.inputs?.labelColor
|
||||
const labelId = nodeData.inputs?.labelId
|
||||
|
||||
// Thread parameters
|
||||
const threadMaxResults = nodeData.inputs?.threadMaxResults
|
||||
const threadQuery = nodeData.inputs?.threadQuery
|
||||
const threadId = nodeData.inputs?.threadId
|
||||
const threadAddLabelIds = nodeData.inputs?.threadAddLabelIds
|
||||
const threadRemoveLabelIds = nodeData.inputs?.threadRemoveLabelIds
|
||||
|
||||
// Set default parameters based on actions
|
||||
actions.forEach((action) => {
|
||||
const params: ICommonObject = {}
|
||||
|
||||
// Draft action parameters
|
||||
if (action.startsWith('list') && draftMaxResults) params.maxResults = draftMaxResults
|
||||
if (action === 'createDraft') {
|
||||
if (draftTo) params.to = draftTo
|
||||
if (draftSubject) params.subject = draftSubject
|
||||
if (draftBody) params.body = draftBody
|
||||
if (draftCc) params.cc = draftCc
|
||||
if (draftBcc) params.bcc = draftBcc
|
||||
}
|
||||
if (action === 'updateDraft') {
|
||||
if (draftId) params.draftId = draftId
|
||||
if (draftUpdateTo) params.to = draftUpdateTo
|
||||
if (draftUpdateSubject) params.subject = draftUpdateSubject
|
||||
if (draftUpdateBody) params.body = draftUpdateBody
|
||||
}
|
||||
if (['getDraft', 'sendDraft', 'deleteDraft'].includes(action) && draftId) {
|
||||
params.draftId = draftId
|
||||
}
|
||||
|
||||
// Message action parameters
|
||||
if (action === 'listMessages') {
|
||||
if (messageMaxResults) params.maxResults = messageMaxResults
|
||||
if (messageQuery) params.query = messageQuery
|
||||
}
|
||||
if (action === 'sendMessage') {
|
||||
if (messageTo) params.to = messageTo
|
||||
if (messageSubject) params.subject = messageSubject
|
||||
if (messageBody) params.body = messageBody
|
||||
if (messageCc) params.cc = messageCc
|
||||
if (messageBcc) params.bcc = messageBcc
|
||||
}
|
||||
if (['getMessage', 'trashMessage', 'untrashMessage', 'deleteMessage'].includes(action) && messageId) {
|
||||
params.messageId = messageId
|
||||
}
|
||||
if (action === 'modifyMessage') {
|
||||
if (messageId) params.messageId = messageId
|
||||
if (messageAddLabelIds) params.addLabelIds = messageAddLabelIds.split(',').map((id: string) => id.trim())
|
||||
if (messageRemoveLabelIds) params.removeLabelIds = messageRemoveLabelIds.split(',').map((id: string) => id.trim())
|
||||
}
|
||||
|
||||
// Label action parameters
|
||||
if (action === 'createLabel') {
|
||||
if (labelName) params.labelName = labelName
|
||||
if (labelColor) params.labelColor = labelColor
|
||||
}
|
||||
if (['getLabel', 'updateLabel', 'deleteLabel'].includes(action) && labelId) {
|
||||
params.labelId = labelId
|
||||
}
|
||||
if (action === 'updateLabel') {
|
||||
if (labelName) params.labelName = labelName
|
||||
if (labelColor) params.labelColor = labelColor
|
||||
}
|
||||
|
||||
// Thread action parameters
|
||||
if (action === 'listThreads') {
|
||||
if (threadMaxResults) params.maxResults = threadMaxResults
|
||||
if (threadQuery) params.query = threadQuery
|
||||
}
|
||||
if (['getThread', 'trashThread', 'untrashThread', 'deleteThread'].includes(action) && threadId) {
|
||||
params.threadId = threadId
|
||||
}
|
||||
if (action === 'modifyThread') {
|
||||
if (threadId) params.threadId = threadId
|
||||
if (threadAddLabelIds) params.addLabelIds = threadAddLabelIds.split(',').map((id: string) => id.trim())
|
||||
if (threadRemoveLabelIds) params.removeLabelIds = threadRemoveLabelIds.split(',').map((id: string) => id.trim())
|
||||
}
|
||||
|
||||
defaultParams[action] = params
|
||||
})
|
||||
const defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
// Create and return tools based on selected actions
|
||||
const tools = createGmailTools({
|
||||
|
|
@ -693,6 +582,49 @@ class Gmail_Tools implements INode {
|
|||
|
||||
return tools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
// Collect default parameters from inputs
|
||||
const defaultParams: Record<string, any> = {}
|
||||
|
||||
// Draft parameters
|
||||
if (nodeData.inputs?.draftMaxResults) defaultParams.draftMaxResults = nodeData.inputs.draftMaxResults
|
||||
if (nodeData.inputs?.draftTo) defaultParams.draftTo = nodeData.inputs.draftTo
|
||||
if (nodeData.inputs?.draftSubject) defaultParams.draftSubject = nodeData.inputs.draftSubject
|
||||
if (nodeData.inputs?.draftBody) defaultParams.draftBody = nodeData.inputs.draftBody
|
||||
if (nodeData.inputs?.draftCc) defaultParams.draftCc = nodeData.inputs.draftCc
|
||||
if (nodeData.inputs?.draftBcc) defaultParams.draftBcc = nodeData.inputs.draftBcc
|
||||
if (nodeData.inputs?.draftId) defaultParams.draftId = nodeData.inputs.draftId
|
||||
if (nodeData.inputs?.draftUpdateTo) defaultParams.draftUpdateTo = nodeData.inputs.draftUpdateTo
|
||||
if (nodeData.inputs?.draftUpdateSubject) defaultParams.draftUpdateSubject = nodeData.inputs.draftUpdateSubject
|
||||
if (nodeData.inputs?.draftUpdateBody) defaultParams.draftUpdateBody = nodeData.inputs.draftUpdateBody
|
||||
|
||||
// Message parameters
|
||||
if (nodeData.inputs?.messageMaxResults) defaultParams.messageMaxResults = nodeData.inputs.messageMaxResults
|
||||
if (nodeData.inputs?.messageQuery) defaultParams.messageQuery = nodeData.inputs.messageQuery
|
||||
if (nodeData.inputs?.messageTo) defaultParams.messageTo = nodeData.inputs.messageTo
|
||||
if (nodeData.inputs?.messageSubject) defaultParams.messageSubject = nodeData.inputs.messageSubject
|
||||
if (nodeData.inputs?.messageBody) defaultParams.messageBody = nodeData.inputs.messageBody
|
||||
if (nodeData.inputs?.messageCc) defaultParams.messageCc = nodeData.inputs.messageCc
|
||||
if (nodeData.inputs?.messageBcc) defaultParams.messageBcc = nodeData.inputs.messageBcc
|
||||
if (nodeData.inputs?.messageId) defaultParams.messageId = nodeData.inputs.messageId
|
||||
if (nodeData.inputs?.messageAddLabelIds) defaultParams.messageAddLabelIds = nodeData.inputs.messageAddLabelIds
|
||||
if (nodeData.inputs?.messageRemoveLabelIds) defaultParams.messageRemoveLabelIds = nodeData.inputs.messageRemoveLabelIds
|
||||
|
||||
// Label parameters
|
||||
if (nodeData.inputs?.labelName) defaultParams.labelName = nodeData.inputs.labelName
|
||||
if (nodeData.inputs?.labelColor) defaultParams.labelColor = nodeData.inputs.labelColor
|
||||
if (nodeData.inputs?.labelId) defaultParams.labelId = nodeData.inputs.labelId
|
||||
|
||||
// Thread parameters
|
||||
if (nodeData.inputs?.threadMaxResults) defaultParams.threadMaxResults = nodeData.inputs.threadMaxResults
|
||||
if (nodeData.inputs?.threadQuery) defaultParams.threadQuery = nodeData.inputs.threadQuery
|
||||
if (nodeData.inputs?.threadId) defaultParams.threadId = nodeData.inputs.threadId
|
||||
if (nodeData.inputs?.threadAddLabelIds) defaultParams.threadAddLabelIds = nodeData.inputs.threadAddLabelIds
|
||||
if (nodeData.inputs?.threadRemoveLabelIds) defaultParams.threadRemoveLabelIds = nodeData.inputs.threadRemoveLabelIds
|
||||
|
||||
return defaultParams
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: Gmail_Tools }
|
||||
|
|
|
|||
|
|
@ -559,88 +559,7 @@ class GoogleCalendar_Tools implements INode {
|
|||
actions = convertMultiOptionsToStringArray(nodeData.inputs?.freebusyActions)
|
||||
}
|
||||
|
||||
// Create default params object based on inputs
|
||||
const defaultParams: any = {}
|
||||
|
||||
// Event-specific default params
|
||||
if (calendarType === 'event') {
|
||||
actions.forEach((action) => {
|
||||
const params: any = {}
|
||||
|
||||
if (nodeData.inputs?.calendarId) params.calendarId = nodeData.inputs.calendarId
|
||||
if (action === 'getEvent' || action === 'updateEvent' || action === 'deleteEvent') {
|
||||
if (nodeData.inputs?.eventId) params.eventId = nodeData.inputs.eventId
|
||||
}
|
||||
if (action === 'createEvent' || action === 'updateEvent') {
|
||||
if (nodeData.inputs?.summary) params.summary = nodeData.inputs.summary
|
||||
if (nodeData.inputs?.description) params.description = nodeData.inputs.description
|
||||
if (nodeData.inputs?.location) params.location = nodeData.inputs.location
|
||||
if (nodeData.inputs?.startDateTime) params.startDateTime = nodeData.inputs.startDateTime
|
||||
if (nodeData.inputs?.endDateTime) params.endDateTime = nodeData.inputs.endDateTime
|
||||
if (nodeData.inputs?.timeZone) params.timeZone = nodeData.inputs.timeZone
|
||||
if (nodeData.inputs?.allDay !== undefined) params.allDay = nodeData.inputs.allDay
|
||||
if (nodeData.inputs?.startDate) params.startDate = nodeData.inputs.startDate
|
||||
if (nodeData.inputs?.endDate) params.endDate = nodeData.inputs.endDate
|
||||
if (nodeData.inputs?.attendees) params.attendees = nodeData.inputs.attendees
|
||||
if (nodeData.inputs?.recurrence) params.recurrence = nodeData.inputs.recurrence
|
||||
if (nodeData.inputs?.reminderMinutes) params.reminderMinutes = nodeData.inputs.reminderMinutes
|
||||
if (nodeData.inputs?.visibility) params.visibility = nodeData.inputs.visibility
|
||||
}
|
||||
if (action === 'quickAddEvent') {
|
||||
if (nodeData.inputs?.quickAddText) params.quickAddText = nodeData.inputs.quickAddText
|
||||
}
|
||||
if (action === 'listEvents') {
|
||||
if (nodeData.inputs?.timeMin) params.timeMin = nodeData.inputs.timeMin
|
||||
if (nodeData.inputs?.timeMax) params.timeMax = nodeData.inputs.timeMax
|
||||
if (nodeData.inputs?.maxResults) params.maxResults = nodeData.inputs.maxResults
|
||||
if (nodeData.inputs?.singleEvents !== undefined) params.singleEvents = nodeData.inputs.singleEvents
|
||||
if (nodeData.inputs?.orderBy) params.orderBy = nodeData.inputs.orderBy
|
||||
if (nodeData.inputs?.query) params.query = nodeData.inputs.query
|
||||
}
|
||||
|
||||
defaultParams[action] = params
|
||||
})
|
||||
}
|
||||
|
||||
// Calendar-specific default params
|
||||
if (calendarType === 'calendar') {
|
||||
actions.forEach((action) => {
|
||||
const params: any = {}
|
||||
|
||||
if (['getCalendar', 'updateCalendar', 'deleteCalendar', 'clearCalendar'].includes(action)) {
|
||||
if (nodeData.inputs?.calendarIdForCalendar) params.calendarId = nodeData.inputs.calendarIdForCalendar
|
||||
}
|
||||
if (action === 'createCalendar' || action === 'updateCalendar') {
|
||||
if (nodeData.inputs?.calendarSummary) params.summary = nodeData.inputs.calendarSummary
|
||||
if (nodeData.inputs?.calendarDescription) params.description = nodeData.inputs.calendarDescription
|
||||
if (nodeData.inputs?.calendarLocation) params.location = nodeData.inputs.calendarLocation
|
||||
if (nodeData.inputs?.calendarTimeZone) params.timeZone = nodeData.inputs.calendarTimeZone
|
||||
}
|
||||
if (action === 'listCalendars') {
|
||||
if (nodeData.inputs?.showHidden !== undefined) params.showHidden = nodeData.inputs.showHidden
|
||||
if (nodeData.inputs?.minAccessRole) params.minAccessRole = nodeData.inputs.minAccessRole
|
||||
}
|
||||
|
||||
defaultParams[action] = params
|
||||
})
|
||||
}
|
||||
|
||||
// Freebusy-specific default params
|
||||
if (calendarType === 'freebusy') {
|
||||
actions.forEach((action) => {
|
||||
const params: any = {}
|
||||
|
||||
if (action === 'queryFreebusy') {
|
||||
if (nodeData.inputs?.freebusyTimeMin) params.timeMin = nodeData.inputs.freebusyTimeMin
|
||||
if (nodeData.inputs?.freebusyTimeMax) params.timeMax = nodeData.inputs.freebusyTimeMax
|
||||
if (nodeData.inputs?.calendarIds) params.calendarIds = nodeData.inputs.calendarIds
|
||||
if (nodeData.inputs?.groupExpansionMax) params.groupExpansionMax = nodeData.inputs.groupExpansionMax
|
||||
if (nodeData.inputs?.calendarExpansionMax) params.calendarExpansionMax = nodeData.inputs.calendarExpansionMax
|
||||
}
|
||||
|
||||
defaultParams[action] = params
|
||||
})
|
||||
}
|
||||
const defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
const tools = createGoogleCalendarTools({
|
||||
accessToken,
|
||||
|
|
@ -650,6 +569,53 @@ class GoogleCalendar_Tools implements INode {
|
|||
|
||||
return tools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
// Collect default parameters from inputs
|
||||
const defaultParams: Record<string, any> = {}
|
||||
|
||||
// Event parameters
|
||||
if (nodeData.inputs?.calendarId) defaultParams.calendarId = nodeData.inputs.calendarId
|
||||
if (nodeData.inputs?.eventId) defaultParams.eventId = nodeData.inputs.eventId
|
||||
if (nodeData.inputs?.summary) defaultParams.summary = nodeData.inputs.summary
|
||||
if (nodeData.inputs?.description) defaultParams.description = nodeData.inputs.description
|
||||
if (nodeData.inputs?.location) defaultParams.location = nodeData.inputs.location
|
||||
if (nodeData.inputs?.startDateTime) defaultParams.startDateTime = nodeData.inputs.startDateTime
|
||||
if (nodeData.inputs?.endDateTime) defaultParams.endDateTime = nodeData.inputs.endDateTime
|
||||
if (nodeData.inputs?.timeZone) defaultParams.timeZone = nodeData.inputs.timeZone
|
||||
if (nodeData.inputs?.allDay !== undefined) defaultParams.allDay = nodeData.inputs.allDay
|
||||
if (nodeData.inputs?.startDate) defaultParams.startDate = nodeData.inputs.startDate
|
||||
if (nodeData.inputs?.endDate) defaultParams.endDate = nodeData.inputs.endDate
|
||||
if (nodeData.inputs?.attendees) defaultParams.attendees = nodeData.inputs.attendees
|
||||
if (nodeData.inputs?.recurrence) defaultParams.recurrence = nodeData.inputs.recurrence
|
||||
if (nodeData.inputs?.reminderMinutes) defaultParams.reminderMinutes = nodeData.inputs.reminderMinutes
|
||||
if (nodeData.inputs?.visibility) defaultParams.visibility = nodeData.inputs.visibility
|
||||
if (nodeData.inputs?.quickAddText) defaultParams.quickAddText = nodeData.inputs.quickAddText
|
||||
if (nodeData.inputs?.timeMin) defaultParams.timeMin = nodeData.inputs.timeMin
|
||||
if (nodeData.inputs?.timeMax) defaultParams.timeMax = nodeData.inputs.timeMax
|
||||
if (nodeData.inputs?.maxResults) defaultParams.maxResults = nodeData.inputs.maxResults
|
||||
if (nodeData.inputs?.singleEvents !== undefined) defaultParams.singleEvents = nodeData.inputs.singleEvents
|
||||
if (nodeData.inputs?.orderBy) defaultParams.orderBy = nodeData.inputs.orderBy
|
||||
if (nodeData.inputs?.query) defaultParams.query = nodeData.inputs.query
|
||||
|
||||
// Calendar parameters
|
||||
if (nodeData.inputs?.calendarIdForCalendar) defaultParams.calendarIdForCalendar = nodeData.inputs.calendarIdForCalendar
|
||||
if (nodeData.inputs?.calendarSummary) defaultParams.calendarSummary = nodeData.inputs.calendarSummary
|
||||
if (nodeData.inputs?.calendarDescription) defaultParams.calendarDescription = nodeData.inputs.calendarDescription
|
||||
if (nodeData.inputs?.calendarLocation) defaultParams.calendarLocation = nodeData.inputs.calendarLocation
|
||||
if (nodeData.inputs?.calendarTimeZone) defaultParams.calendarTimeZone = nodeData.inputs.calendarTimeZone
|
||||
if (nodeData.inputs?.showHidden !== undefined) defaultParams.showHidden = nodeData.inputs.showHidden
|
||||
if (nodeData.inputs?.minAccessRole) defaultParams.minAccessRole = nodeData.inputs.minAccessRole
|
||||
|
||||
// Freebusy parameters
|
||||
if (nodeData.inputs?.freebusyTimeMin) defaultParams.freebusyTimeMin = nodeData.inputs.freebusyTimeMin
|
||||
if (nodeData.inputs?.freebusyTimeMax) defaultParams.freebusyTimeMax = nodeData.inputs.freebusyTimeMax
|
||||
if (nodeData.inputs?.calendarIds) defaultParams.calendarIds = nodeData.inputs.calendarIds
|
||||
if (nodeData.inputs?.groupExpansionMax) defaultParams.groupExpansionMax = nodeData.inputs.groupExpansionMax
|
||||
if (nodeData.inputs?.calendarExpansionMax) defaultParams.calendarExpansionMax = nodeData.inputs.calendarExpansionMax
|
||||
|
||||
return defaultParams
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: GoogleCalendar_Tools }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,253 @@
|
|||
import { convertMultiOptionsToStringArray, getCredentialData, getCredentialParam, refreshOAuth2Token } from '../../../src/utils'
|
||||
import { createGoogleDocsTools } from './core'
|
||||
import type { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
|
||||
class GoogleDocs_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 Docs'
|
||||
this.name = 'googleDocsTool'
|
||||
this.version = 1.0
|
||||
this.type = 'GoogleDocs'
|
||||
this.icon = 'google-docs.svg'
|
||||
this.category = 'Tools'
|
||||
this.description =
|
||||
'Perform Google Docs operations such as creating, reading, updating, and deleting documents, as well as text manipulation'
|
||||
this.baseClasses = ['Tool']
|
||||
this.credential = {
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
credentialNames: ['googleDocsOAuth2']
|
||||
}
|
||||
this.inputs = [
|
||||
// Document Actions
|
||||
{
|
||||
label: 'Actions',
|
||||
name: 'actions',
|
||||
type: 'multiOptions',
|
||||
description: 'Actions to perform',
|
||||
options: [
|
||||
{
|
||||
label: 'Create Document',
|
||||
name: 'createDocument'
|
||||
},
|
||||
{
|
||||
label: 'Get Document',
|
||||
name: 'getDocument'
|
||||
},
|
||||
{
|
||||
label: 'Update Document',
|
||||
name: 'updateDocument'
|
||||
},
|
||||
{
|
||||
label: 'Insert Text',
|
||||
name: 'insertText'
|
||||
},
|
||||
{
|
||||
label: 'Replace Text',
|
||||
name: 'replaceText'
|
||||
},
|
||||
{
|
||||
label: 'Append Text',
|
||||
name: 'appendText'
|
||||
},
|
||||
{
|
||||
label: 'Get Text Content',
|
||||
name: 'getTextContent'
|
||||
},
|
||||
{
|
||||
label: 'Insert Image',
|
||||
name: 'insertImage'
|
||||
},
|
||||
{
|
||||
label: 'Create Table',
|
||||
name: 'createTable'
|
||||
}
|
||||
]
|
||||
},
|
||||
// Document Parameters
|
||||
{
|
||||
label: 'Document ID',
|
||||
name: 'documentId',
|
||||
type: 'string',
|
||||
description: 'Document ID for operations on specific documents',
|
||||
show: {
|
||||
actions: [
|
||||
'getDocument',
|
||||
'updateDocument',
|
||||
'insertText',
|
||||
'replaceText',
|
||||
'appendText',
|
||||
'getTextContent',
|
||||
'insertImage',
|
||||
'createTable'
|
||||
]
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
description: 'Document title',
|
||||
show: {
|
||||
actions: ['createDocument']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
// Text Parameters
|
||||
{
|
||||
label: 'Text',
|
||||
name: 'text',
|
||||
type: 'string',
|
||||
description: 'Text content to insert or append',
|
||||
show: {
|
||||
actions: ['createDocument', 'updateDocument', 'insertText', 'appendText']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Index',
|
||||
name: 'index',
|
||||
type: 'number',
|
||||
description: 'Index where to insert text or media (1-based, default: 1 for beginning)',
|
||||
default: 1,
|
||||
show: {
|
||||
actions: ['createDocument', 'updateDocument', 'insertText', 'insertImage', 'createTable']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Replace Text',
|
||||
name: 'replaceText',
|
||||
type: 'string',
|
||||
description: 'Text to replace',
|
||||
show: {
|
||||
actions: ['updateDocument', 'replaceText']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'New Text',
|
||||
name: 'newText',
|
||||
type: 'string',
|
||||
description: 'New text to replace with',
|
||||
show: {
|
||||
actions: ['updateDocument', 'replaceText']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Match Case',
|
||||
name: 'matchCase',
|
||||
type: 'boolean',
|
||||
description: 'Whether the search should be case-sensitive',
|
||||
default: false,
|
||||
show: {
|
||||
actions: ['updateDocument', 'replaceText']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
|
||||
// Media Parameters
|
||||
{
|
||||
label: 'Image URL',
|
||||
name: 'imageUrl',
|
||||
type: 'string',
|
||||
description: 'URL of the image to insert',
|
||||
show: {
|
||||
actions: ['createDocument', 'updateDocument', 'insertImage']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Table Rows',
|
||||
name: 'rows',
|
||||
type: 'number',
|
||||
description: 'Number of rows in the table',
|
||||
show: {
|
||||
actions: ['createDocument', 'updateDocument', 'createTable']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Table Columns',
|
||||
name: 'columns',
|
||||
type: 'number',
|
||||
description: 'Number of columns in the table',
|
||||
show: {
|
||||
actions: ['createDocument', 'updateDocument', 'createTable']
|
||||
},
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
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
|
||||
const actions = convertMultiOptionsToStringArray(nodeData.inputs?.actions)
|
||||
|
||||
const defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
const tools = createGoogleDocsTools({
|
||||
accessToken,
|
||||
actions,
|
||||
defaultParams
|
||||
})
|
||||
|
||||
return tools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
const nodeInputs: Record<string, any> = {}
|
||||
|
||||
// Document parameters
|
||||
if (nodeData.inputs?.documentId) nodeInputs.documentId = nodeData.inputs.documentId
|
||||
if (nodeData.inputs?.title) nodeInputs.title = nodeData.inputs.title
|
||||
|
||||
// Text parameters
|
||||
if (nodeData.inputs?.text) nodeInputs.text = nodeData.inputs.text
|
||||
if (nodeData.inputs?.index) nodeInputs.index = nodeData.inputs.index
|
||||
if (nodeData.inputs?.replaceText) nodeInputs.replaceText = nodeData.inputs.replaceText
|
||||
if (nodeData.inputs?.newText) nodeInputs.newText = nodeData.inputs.newText
|
||||
if (nodeData.inputs?.matchCase !== undefined) nodeInputs.matchCase = nodeData.inputs.matchCase
|
||||
|
||||
// Media parameters
|
||||
if (nodeData.inputs?.imageUrl) nodeInputs.imageUrl = nodeData.inputs.imageUrl
|
||||
if (nodeData.inputs?.rows) nodeInputs.rows = nodeData.inputs.rows
|
||||
if (nodeData.inputs?.columns) nodeInputs.columns = nodeData.inputs.columns
|
||||
|
||||
return nodeInputs
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: GoogleDocs_Tools }
|
||||
|
|
@ -0,0 +1,729 @@
|
|||
import { z } from 'zod'
|
||||
import fetch from 'node-fetch'
|
||||
import { DynamicStructuredTool } from '../OpenAPIToolkit/core'
|
||||
import { TOOL_ARGS_PREFIX } from '../../../src/agents'
|
||||
|
||||
export const desc = `Use this when you want to access Google Docs API for managing documents`
|
||||
|
||||
export interface Headers {
|
||||
[key: string]: string
|
||||
}
|
||||
|
||||
export interface Body {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface RequestParameters {
|
||||
headers?: Headers
|
||||
body?: Body
|
||||
url?: string
|
||||
description?: string
|
||||
name?: string
|
||||
actions?: string[]
|
||||
accessToken?: string
|
||||
defaultParams?: any
|
||||
}
|
||||
|
||||
// Define schemas for different Google Docs operations
|
||||
|
||||
// Document Schemas
|
||||
const CreateDocumentSchema = z.object({
|
||||
title: z.string().describe('Document title'),
|
||||
text: z.string().optional().describe('Text content to insert after creating document'),
|
||||
index: z.number().optional().default(1).describe('Index where to insert text or media (1-based, default: 1 for beginning)'),
|
||||
imageUrl: z.string().optional().describe('URL of the image to insert after creating document'),
|
||||
rows: z.number().optional().describe('Number of rows in the table to create'),
|
||||
columns: z.number().optional().describe('Number of columns in the table to create')
|
||||
})
|
||||
|
||||
const GetDocumentSchema = z.object({
|
||||
documentId: z.string().describe('Document ID to retrieve')
|
||||
})
|
||||
|
||||
const UpdateDocumentSchema = z.object({
|
||||
documentId: z.string().describe('Document ID to update'),
|
||||
text: z.string().optional().describe('Text content to insert'),
|
||||
index: z.number().optional().default(1).describe('Index where to insert text or media (1-based, default: 1 for beginning)'),
|
||||
replaceText: z.string().optional().describe('Text to replace'),
|
||||
newText: z.string().optional().describe('New text to replace with'),
|
||||
matchCase: z.boolean().optional().default(false).describe('Whether the search should be case-sensitive'),
|
||||
imageUrl: z.string().optional().describe('URL of the image to insert'),
|
||||
rows: z.number().optional().describe('Number of rows in the table to create'),
|
||||
columns: z.number().optional().describe('Number of columns in the table to create')
|
||||
})
|
||||
|
||||
const InsertTextSchema = z.object({
|
||||
documentId: z.string().describe('Document ID'),
|
||||
text: z.string().describe('Text to insert'),
|
||||
index: z.number().optional().default(1).describe('Index where to insert text (1-based, default: 1 for beginning)')
|
||||
})
|
||||
|
||||
const ReplaceTextSchema = z.object({
|
||||
documentId: z.string().describe('Document ID'),
|
||||
replaceText: z.string().describe('Text to replace'),
|
||||
newText: z.string().describe('New text to replace with'),
|
||||
matchCase: z.boolean().optional().default(false).describe('Whether the search should be case-sensitive')
|
||||
})
|
||||
|
||||
const AppendTextSchema = z.object({
|
||||
documentId: z.string().describe('Document ID'),
|
||||
text: z.string().describe('Text to append to the document')
|
||||
})
|
||||
|
||||
const GetTextContentSchema = z.object({
|
||||
documentId: z.string().describe('Document ID to get text content from')
|
||||
})
|
||||
|
||||
const InsertImageSchema = z.object({
|
||||
documentId: z.string().describe('Document ID'),
|
||||
imageUrl: z.string().describe('URL of the image to insert'),
|
||||
index: z.number().optional().default(1).describe('Index where to insert image (1-based)')
|
||||
})
|
||||
|
||||
const CreateTableSchema = z.object({
|
||||
documentId: z.string().describe('Document ID'),
|
||||
rows: z.number().describe('Number of rows in the table'),
|
||||
columns: z.number().describe('Number of columns in the table'),
|
||||
index: z.number().optional().default(1).describe('Index where to insert table (1-based)')
|
||||
})
|
||||
|
||||
class BaseGoogleDocsTool extends DynamicStructuredTool {
|
||||
protected accessToken: string = ''
|
||||
|
||||
constructor(args: any) {
|
||||
super(args)
|
||||
this.accessToken = args.accessToken ?? ''
|
||||
}
|
||||
|
||||
async makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method = 'GET',
|
||||
body,
|
||||
params
|
||||
}: {
|
||||
endpoint: string
|
||||
method?: string
|
||||
body?: any
|
||||
params?: any
|
||||
}): Promise<string> {
|
||||
const url = `https://docs.googleapis.com/v1/${endpoint}`
|
||||
|
||||
const headers = {
|
||||
Authorization: `Bearer ${this.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
...this.headers
|
||||
}
|
||||
|
||||
const response = await fetch(url, {
|
||||
method,
|
||||
headers,
|
||||
body: body ? JSON.stringify(body) : undefined
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text()
|
||||
throw new Error(`Google Docs API Error ${response.status}: ${response.statusText} - ${errorText}`)
|
||||
}
|
||||
|
||||
const data = await response.text()
|
||||
return data + TOOL_ARGS_PREFIX + JSON.stringify(params)
|
||||
}
|
||||
|
||||
async makeDriveRequest({
|
||||
endpoint,
|
||||
method = 'GET',
|
||||
body,
|
||||
params
|
||||
}: {
|
||||
endpoint: string
|
||||
method?: string
|
||||
body?: any
|
||||
params?: any
|
||||
}): Promise<string> {
|
||||
const url = `https://www.googleapis.com/drive/v3/${endpoint}`
|
||||
|
||||
const headers = {
|
||||
Authorization: `Bearer ${this.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
...this.headers
|
||||
}
|
||||
|
||||
const response = await fetch(url, {
|
||||
method,
|
||||
headers,
|
||||
body: body ? JSON.stringify(body) : undefined
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text()
|
||||
throw new Error(`Google Drive API Error ${response.status}: ${response.statusText} - ${errorText}`)
|
||||
}
|
||||
|
||||
const data = await response.text()
|
||||
return data + TOOL_ARGS_PREFIX + JSON.stringify(params)
|
||||
}
|
||||
}
|
||||
|
||||
// Document Tools
|
||||
class CreateDocumentTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'create_document',
|
||||
description: 'Create a new Google Docs document',
|
||||
schema: CreateDocumentSchema,
|
||||
baseUrl: '',
|
||||
method: 'POST',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const documentData = {
|
||||
title: params.title
|
||||
}
|
||||
|
||||
const endpoint = 'documents'
|
||||
const createResponse = await this.makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method: 'POST',
|
||||
body: documentData,
|
||||
params
|
||||
})
|
||||
|
||||
// Get the document ID from the response
|
||||
const documentResponse = JSON.parse(createResponse.split(TOOL_ARGS_PREFIX)[0])
|
||||
const documentId = documentResponse.documentId
|
||||
|
||||
// Now add content if provided
|
||||
const requests = []
|
||||
|
||||
if (params.text) {
|
||||
requests.push({
|
||||
insertText: {
|
||||
location: {
|
||||
index: params.index || 1
|
||||
},
|
||||
text: params.text
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (params.imageUrl) {
|
||||
requests.push({
|
||||
insertInlineImage: {
|
||||
location: {
|
||||
index: params.index || 1
|
||||
},
|
||||
uri: params.imageUrl
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (params.rows && params.columns) {
|
||||
requests.push({
|
||||
insertTable: {
|
||||
location: {
|
||||
index: params.index || 1
|
||||
},
|
||||
rows: params.rows,
|
||||
columns: params.columns
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// If we have content to add, make a batch update
|
||||
if (requests.length > 0) {
|
||||
const updateEndpoint = `documents/${encodeURIComponent(documentId)}:batchUpdate`
|
||||
await this.makeGoogleDocsRequest({
|
||||
endpoint: updateEndpoint,
|
||||
method: 'POST',
|
||||
body: { requests },
|
||||
params: {}
|
||||
})
|
||||
}
|
||||
|
||||
return createResponse
|
||||
} catch (error) {
|
||||
return `Error creating document: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GetDocumentTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'get_document',
|
||||
description: 'Get a Google Docs document by ID',
|
||||
schema: GetDocumentSchema,
|
||||
baseUrl: '',
|
||||
method: 'GET',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}`
|
||||
const response = await this.makeGoogleDocsRequest({ endpoint, params })
|
||||
return response
|
||||
} catch (error) {
|
||||
return `Error getting document: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class UpdateDocumentTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'update_document',
|
||||
description: 'Update a Google Docs document with batch requests',
|
||||
schema: UpdateDocumentSchema,
|
||||
baseUrl: '',
|
||||
method: 'POST',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const requests = []
|
||||
|
||||
// Insert text
|
||||
if (params.text) {
|
||||
requests.push({
|
||||
insertText: {
|
||||
location: {
|
||||
index: params.index || 1
|
||||
},
|
||||
text: params.text
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Replace text
|
||||
if (params.replaceText && params.newText) {
|
||||
requests.push({
|
||||
replaceAllText: {
|
||||
containsText: {
|
||||
text: params.replaceText,
|
||||
matchCase: params.matchCase || false
|
||||
},
|
||||
replaceText: params.newText
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Insert image
|
||||
if (params.imageUrl) {
|
||||
requests.push({
|
||||
insertInlineImage: {
|
||||
location: {
|
||||
index: params.index || 1
|
||||
},
|
||||
uri: params.imageUrl
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Create table
|
||||
if (params.rows && params.columns) {
|
||||
requests.push({
|
||||
insertTable: {
|
||||
location: {
|
||||
index: params.index || 1
|
||||
},
|
||||
rows: params.rows,
|
||||
columns: params.columns
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (requests.length > 0) {
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}:batchUpdate`
|
||||
const response = await this.makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method: 'POST',
|
||||
body: { requests },
|
||||
params
|
||||
})
|
||||
return response
|
||||
} else {
|
||||
return `No updates specified` + TOOL_ARGS_PREFIX + JSON.stringify(params)
|
||||
}
|
||||
} catch (error) {
|
||||
return `Error updating document: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class InsertTextTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'insert_text',
|
||||
description: 'Insert text into a Google Docs document',
|
||||
schema: InsertTextSchema,
|
||||
baseUrl: '',
|
||||
method: 'POST',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const requests = [
|
||||
{
|
||||
insertText: {
|
||||
location: {
|
||||
index: params.index
|
||||
},
|
||||
text: params.text
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}:batchUpdate`
|
||||
const response = await this.makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method: 'POST',
|
||||
body: { requests },
|
||||
params
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
return `Error inserting text: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ReplaceTextTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'replace_text',
|
||||
description: 'Replace text in a Google Docs document',
|
||||
schema: ReplaceTextSchema,
|
||||
baseUrl: '',
|
||||
method: 'POST',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const requests = [
|
||||
{
|
||||
replaceAllText: {
|
||||
containsText: {
|
||||
text: params.replaceText,
|
||||
matchCase: params.matchCase
|
||||
},
|
||||
replaceText: params.newText
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}:batchUpdate`
|
||||
const response = await this.makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method: 'POST',
|
||||
body: { requests },
|
||||
params
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
return `Error replacing text: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AppendTextTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'append_text',
|
||||
description: 'Append text to the end of a Google Docs document',
|
||||
schema: AppendTextSchema,
|
||||
baseUrl: '',
|
||||
method: 'POST',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
// First get the document to find the end index
|
||||
const getEndpoint = `documents/${encodeURIComponent(params.documentId)}`
|
||||
const docResponse = await this.makeGoogleDocsRequest({ endpoint: getEndpoint, params: {} })
|
||||
const docData = JSON.parse(docResponse.split(TOOL_ARGS_PREFIX)[0])
|
||||
|
||||
// Get the end index of the document body
|
||||
const endIndex = docData.body.content[docData.body.content.length - 1].endIndex - 1
|
||||
|
||||
const requests = [
|
||||
{
|
||||
insertText: {
|
||||
location: {
|
||||
index: endIndex
|
||||
},
|
||||
text: params.text
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}:batchUpdate`
|
||||
const response = await this.makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method: 'POST',
|
||||
body: { requests },
|
||||
params
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
return `Error appending text: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GetTextContentTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'get_text_content',
|
||||
description: 'Get the text content from a Google Docs document',
|
||||
schema: GetTextContentSchema,
|
||||
baseUrl: '',
|
||||
method: 'GET',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}`
|
||||
const response = await this.makeGoogleDocsRequest({ endpoint, params })
|
||||
|
||||
// Extract and return just the text content
|
||||
const docData = JSON.parse(response.split(TOOL_ARGS_PREFIX)[0])
|
||||
let textContent = ''
|
||||
|
||||
const extractText = (element: any) => {
|
||||
if (element.paragraph) {
|
||||
element.paragraph.elements?.forEach((elem: any) => {
|
||||
if (elem.textRun) {
|
||||
textContent += elem.textRun.content
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
docData.body.content?.forEach(extractText)
|
||||
|
||||
return JSON.stringify({ textContent }) + TOOL_ARGS_PREFIX + JSON.stringify(params)
|
||||
} catch (error) {
|
||||
return `Error getting text content: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class InsertImageTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'insert_image',
|
||||
description: 'Insert an image into a Google Docs document',
|
||||
schema: InsertImageSchema,
|
||||
baseUrl: '',
|
||||
method: 'POST',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const requests = [
|
||||
{
|
||||
insertInlineImage: {
|
||||
location: {
|
||||
index: params.index
|
||||
},
|
||||
uri: params.imageUrl
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}:batchUpdate`
|
||||
const response = await this.makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method: 'POST',
|
||||
body: { requests },
|
||||
params
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
return `Error inserting image: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CreateTableTool extends BaseGoogleDocsTool {
|
||||
defaultParams: any
|
||||
|
||||
constructor(args: any) {
|
||||
const toolInput = {
|
||||
name: 'create_table',
|
||||
description: 'Create a table in a Google Docs document',
|
||||
schema: CreateTableSchema,
|
||||
baseUrl: '',
|
||||
method: 'POST',
|
||||
headers: {}
|
||||
}
|
||||
super({
|
||||
...toolInput,
|
||||
accessToken: args.accessToken
|
||||
})
|
||||
this.defaultParams = args.defaultParams || {}
|
||||
}
|
||||
|
||||
async _call(arg: any): Promise<string> {
|
||||
const params = { ...arg, ...this.defaultParams }
|
||||
|
||||
try {
|
||||
const requests = [
|
||||
{
|
||||
insertTable: {
|
||||
location: {
|
||||
index: params.index
|
||||
},
|
||||
rows: params.rows,
|
||||
columns: params.columns
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const endpoint = `documents/${encodeURIComponent(params.documentId)}:batchUpdate`
|
||||
const response = await this.makeGoogleDocsRequest({
|
||||
endpoint,
|
||||
method: 'POST',
|
||||
body: { requests },
|
||||
params
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
return `Error creating table: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const createGoogleDocsTools = (args?: RequestParameters): DynamicStructuredTool[] => {
|
||||
const actions = args?.actions || []
|
||||
const tools: DynamicStructuredTool[] = []
|
||||
|
||||
if (actions.includes('createDocument') || actions.length === 0) {
|
||||
tools.push(new CreateDocumentTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('getDocument') || actions.length === 0) {
|
||||
tools.push(new GetDocumentTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('updateDocument') || actions.length === 0) {
|
||||
tools.push(new UpdateDocumentTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('insertText') || actions.length === 0) {
|
||||
tools.push(new InsertTextTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('replaceText') || actions.length === 0) {
|
||||
tools.push(new ReplaceTextTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('appendText') || actions.length === 0) {
|
||||
tools.push(new AppendTextTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('getTextContent') || actions.length === 0) {
|
||||
tools.push(new GetTextContentTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('insertImage') || actions.length === 0) {
|
||||
tools.push(new InsertImageTool(args))
|
||||
}
|
||||
|
||||
if (actions.includes('createTable') || actions.length === 0) {
|
||||
tools.push(new CreateTableTool(args))
|
||||
}
|
||||
|
||||
return tools
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="96px" height="96px" fill-rule="evenodd" clip-rule="evenodd" baseProfile="basic"><linearGradient id="pg10I3OeSC0NOv22QZ6aWa" x1="-209.942" x2="-179.36" y1="-3.055" y2="27.526" gradientTransform="translate(208.979 6.006)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#55adfd"/><stop offset="1" stop-color="#438ffd"/></linearGradient><path fill="url(#pg10I3OeSC0NOv22QZ6aWa)" d="M39.001,13.999v27c0,1.105-0.896,2-2,2h-26 c-1.105,0-2-0.895-2-2v-34c0-1.104,0.895-2,2-2h19l2,7L39.001,13.999z"/><path fill="#fff" fill-rule="evenodd" d="M15.999,18.001v2.999 h17.002v-2.999H15.999z" clip-rule="evenodd"/><path fill="#fff" fill-rule="evenodd" d="M16.001,24.001v2.999 h17.002v-2.999H16.001z" clip-rule="evenodd"/><path fill="#fff" fill-rule="evenodd" d="M15.999,30.001v2.999 h12.001v-2.999H15.999z" clip-rule="evenodd"/><linearGradient id="pg10I3OeSC0NOv22QZ6aWb" x1="-197.862" x2="-203.384" y1="-4.632" y2=".89" gradientTransform="translate(234.385 12.109)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#427fdb"/><stop offset="1" stop-color="#0c52bb"/></linearGradient><path fill="url(#pg10I3OeSC0NOv22QZ6aWb)" d="M30.001,13.999l0.001-9l8.999,8.999L30.001,13.999z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
|
@ -616,8 +616,20 @@ class GoogleDrive_Tools implements INode {
|
|||
actions = shareActions
|
||||
}
|
||||
|
||||
const defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
const tools = createGoogleDriveTools({
|
||||
accessToken,
|
||||
actions,
|
||||
defaultParams
|
||||
})
|
||||
|
||||
return tools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
// Collect default parameters from inputs
|
||||
const defaultParams: any = {}
|
||||
const defaultParams: Record<string, any> = {}
|
||||
|
||||
// Add parameters based on the inputs provided
|
||||
if (nodeData.inputs?.fileId) defaultParams.fileId = nodeData.inputs.fileId
|
||||
|
|
@ -644,13 +656,7 @@ class GoogleDrive_Tools implements INode {
|
|||
if (nodeData.inputs?.fields) defaultParams.fields = nodeData.inputs.fields
|
||||
if (nodeData.inputs?.acknowledgeAbuse !== undefined) defaultParams.acknowledgeAbuse = nodeData.inputs.acknowledgeAbuse
|
||||
|
||||
const tools = createGoogleDriveTools({
|
||||
accessToken,
|
||||
actions,
|
||||
defaultParams
|
||||
})
|
||||
|
||||
return tools
|
||||
return defaultParams
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -328,88 +328,7 @@ class GoogleSheets_Tools implements INode {
|
|||
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 defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
const tools = createGoogleSheetsTools({
|
||||
accessToken,
|
||||
|
|
@ -419,6 +338,31 @@ class GoogleSheets_Tools implements INode {
|
|||
|
||||
return tools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
// Collect default parameters from inputs
|
||||
const defaultParams: Record<string, any> = {}
|
||||
|
||||
// Common parameters
|
||||
if (nodeData.inputs?.spreadsheetId) defaultParams.spreadsheetId = nodeData.inputs.spreadsheetId
|
||||
|
||||
// Spreadsheet parameters
|
||||
if (nodeData.inputs?.title) defaultParams.title = nodeData.inputs.title
|
||||
if (nodeData.inputs?.sheetCount) defaultParams.sheetCount = nodeData.inputs.sheetCount
|
||||
if (nodeData.inputs?.includeGridData !== undefined) defaultParams.includeGridData = nodeData.inputs.includeGridData
|
||||
|
||||
// Values parameters
|
||||
if (nodeData.inputs?.range) defaultParams.range = nodeData.inputs.range
|
||||
if (nodeData.inputs?.ranges) defaultParams.ranges = nodeData.inputs.ranges
|
||||
if (nodeData.inputs?.values) defaultParams.values = nodeData.inputs.values
|
||||
if (nodeData.inputs?.valueInputOption) defaultParams.valueInputOption = nodeData.inputs.valueInputOption
|
||||
if (nodeData.inputs?.valueRenderOption) defaultParams.valueRenderOption = nodeData.inputs.valueRenderOption
|
||||
if (nodeData.inputs?.dateTimeRenderOption) defaultParams.dateTimeRenderOption = nodeData.inputs.dateTimeRenderOption
|
||||
if (nodeData.inputs?.insertDataOption) defaultParams.insertDataOption = nodeData.inputs.insertDataOption
|
||||
if (nodeData.inputs?.majorDimension) defaultParams.majorDimension = nodeData.inputs.majorDimension
|
||||
|
||||
return defaultParams
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: GoogleSheets_Tools }
|
||||
|
|
|
|||
|
|
@ -400,93 +400,7 @@ class Jira_Tools implements INode {
|
|||
actions = convertMultiOptionsToStringArray(nodeData.inputs?.userActions)
|
||||
}
|
||||
|
||||
// Prepare default parameters for each action
|
||||
const defaultParams: ICommonObject = {}
|
||||
|
||||
// Issue parameters
|
||||
const projectKey = nodeData.inputs?.projectKey
|
||||
const issueType = nodeData.inputs?.issueType
|
||||
const issueSummary = nodeData.inputs?.issueSummary
|
||||
const issueDescription = nodeData.inputs?.issueDescription
|
||||
const issuePriority = nodeData.inputs?.issuePriority
|
||||
const issueKey = nodeData.inputs?.issueKey
|
||||
const assigneeAccountId = nodeData.inputs?.assigneeAccountId
|
||||
const transitionId = nodeData.inputs?.transitionId
|
||||
const jqlQuery = nodeData.inputs?.jqlQuery
|
||||
const issueMaxResults = nodeData.inputs?.issueMaxResults
|
||||
|
||||
// Comment parameters
|
||||
const commentIssueKey = nodeData.inputs?.commentIssueKey
|
||||
const commentText = nodeData.inputs?.commentText
|
||||
const commentId = nodeData.inputs?.commentId
|
||||
|
||||
// User parameters
|
||||
const userQuery = nodeData.inputs?.userQuery
|
||||
const userAccountId = nodeData.inputs?.userAccountId
|
||||
const userEmail = nodeData.inputs?.userEmail
|
||||
const userDisplayName = nodeData.inputs?.userDisplayName
|
||||
const userMaxResults = nodeData.inputs?.userMaxResults
|
||||
|
||||
// Set default parameters based on actions
|
||||
actions.forEach((action) => {
|
||||
const params: ICommonObject = {}
|
||||
|
||||
// Issue action parameters
|
||||
if (action === 'listIssues') {
|
||||
if (projectKey) params.projectKey = projectKey
|
||||
if (jqlQuery) params.jql = jqlQuery
|
||||
if (issueMaxResults) params.maxResults = issueMaxResults
|
||||
}
|
||||
if (action === 'createIssue') {
|
||||
if (projectKey) params.projectKey = projectKey
|
||||
if (issueType) params.issueType = issueType
|
||||
if (issueSummary) params.summary = issueSummary
|
||||
if (issueDescription) params.description = issueDescription
|
||||
if (issuePriority) params.priority = issuePriority
|
||||
if (assigneeAccountId) params.assigneeAccountId = assigneeAccountId
|
||||
}
|
||||
if (['getIssue', 'updateIssue', 'deleteIssue', 'assignIssue', 'transitionIssue'].includes(action)) {
|
||||
if (issueKey) params.issueKey = issueKey
|
||||
}
|
||||
if (action === 'updateIssue') {
|
||||
if (issueSummary) params.summary = issueSummary
|
||||
if (issueDescription) params.description = issueDescription
|
||||
if (issuePriority) params.priority = issuePriority
|
||||
if (assigneeAccountId) params.assigneeAccountId = assigneeAccountId
|
||||
}
|
||||
if (action === 'assignIssue') {
|
||||
if (assigneeAccountId) params.assigneeAccountId = assigneeAccountId
|
||||
}
|
||||
if (action === 'transitionIssue') {
|
||||
if (transitionId) params.transitionId = transitionId
|
||||
}
|
||||
|
||||
// Comment action parameters
|
||||
if (['listComments', 'createComment'].includes(action) && commentIssueKey) {
|
||||
params.issueKey = commentIssueKey
|
||||
}
|
||||
if (['createComment', 'updateComment'].includes(action) && commentText) {
|
||||
params.text = commentText
|
||||
}
|
||||
if (['getComment', 'updateComment', 'deleteComment'].includes(action) && commentId) {
|
||||
params.commentId = commentId
|
||||
}
|
||||
|
||||
// User action parameters
|
||||
if (action === 'searchUsers') {
|
||||
if (userQuery) params.query = userQuery
|
||||
if (userMaxResults) params.maxResults = userMaxResults
|
||||
}
|
||||
if (['getUser', 'updateUser', 'deleteUser'].includes(action) && userAccountId) {
|
||||
params.accountId = userAccountId
|
||||
}
|
||||
if (['createUser', 'updateUser'].includes(action)) {
|
||||
if (userEmail) params.emailAddress = userEmail
|
||||
if (userDisplayName) params.displayName = userDisplayName
|
||||
}
|
||||
|
||||
defaultParams[action] = params
|
||||
})
|
||||
const defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
// Create and return tools based on selected actions
|
||||
const tools = createJiraTools({
|
||||
|
|
@ -499,6 +413,37 @@ class Jira_Tools implements INode {
|
|||
|
||||
return tools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
// Collect default parameters from inputs
|
||||
const defaultParams: Record<string, any> = {}
|
||||
|
||||
// Issue parameters
|
||||
if (nodeData.inputs?.projectKey) defaultParams.projectKey = nodeData.inputs.projectKey
|
||||
if (nodeData.inputs?.issueType) defaultParams.issueType = nodeData.inputs.issueType
|
||||
if (nodeData.inputs?.issueSummary) defaultParams.issueSummary = nodeData.inputs.issueSummary
|
||||
if (nodeData.inputs?.issueDescription) defaultParams.issueDescription = nodeData.inputs.issueDescription
|
||||
if (nodeData.inputs?.issuePriority) defaultParams.issuePriority = nodeData.inputs.issuePriority
|
||||
if (nodeData.inputs?.issueKey) defaultParams.issueKey = nodeData.inputs.issueKey
|
||||
if (nodeData.inputs?.assigneeAccountId) defaultParams.assigneeAccountId = nodeData.inputs.assigneeAccountId
|
||||
if (nodeData.inputs?.transitionId) defaultParams.transitionId = nodeData.inputs.transitionId
|
||||
if (nodeData.inputs?.jqlQuery) defaultParams.jqlQuery = nodeData.inputs.jqlQuery
|
||||
if (nodeData.inputs?.issueMaxResults) defaultParams.issueMaxResults = nodeData.inputs.issueMaxResults
|
||||
|
||||
// Comment parameters
|
||||
if (nodeData.inputs?.commentIssueKey) defaultParams.commentIssueKey = nodeData.inputs.commentIssueKey
|
||||
if (nodeData.inputs?.commentText) defaultParams.commentText = nodeData.inputs.commentText
|
||||
if (nodeData.inputs?.commentId) defaultParams.commentId = nodeData.inputs.commentId
|
||||
|
||||
// User parameters
|
||||
if (nodeData.inputs?.userQuery) defaultParams.userQuery = nodeData.inputs.userQuery
|
||||
if (nodeData.inputs?.userAccountId) defaultParams.userAccountId = nodeData.inputs.userAccountId
|
||||
if (nodeData.inputs?.userEmail) defaultParams.userEmail = nodeData.inputs.userEmail
|
||||
if (nodeData.inputs?.userDisplayName) defaultParams.userDisplayName = nodeData.inputs.userDisplayName
|
||||
if (nodeData.inputs?.userMaxResults) defaultParams.userMaxResults = nodeData.inputs.userMaxResults
|
||||
|
||||
return defaultParams
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: Jira_Tools }
|
||||
|
|
|
|||
|
|
@ -747,216 +747,7 @@ class MicrosoftOutlook_Tools implements INode {
|
|||
actions = convertMultiOptionsToStringArray(messageActions)
|
||||
}
|
||||
|
||||
// Prepare default parameters for each action based on type
|
||||
const defaultParams: ICommonObject = {}
|
||||
|
||||
if (outlookType === 'calendar') {
|
||||
// Map calendar actions to their parameters
|
||||
actions.forEach((action) => {
|
||||
defaultParams[action] = {}
|
||||
|
||||
switch (action) {
|
||||
case 'listCalendars':
|
||||
if (nodeData.inputs?.maxResultsListCalendars) {
|
||||
defaultParams[action].maxResults = nodeData.inputs.maxResultsListCalendars
|
||||
}
|
||||
break
|
||||
|
||||
case 'getCalendar':
|
||||
if (nodeData.inputs?.calendarIdGetCalendar) {
|
||||
defaultParams[action].calendarId = nodeData.inputs.calendarIdGetCalendar
|
||||
}
|
||||
break
|
||||
|
||||
case 'createCalendar':
|
||||
if (nodeData.inputs?.calendarNameCreateCalendar) {
|
||||
defaultParams[action].calendarName = nodeData.inputs.calendarNameCreateCalendar
|
||||
}
|
||||
break
|
||||
|
||||
case 'updateCalendar':
|
||||
if (nodeData.inputs?.calendarIdUpdateCalendar) {
|
||||
defaultParams[action].calendarId = nodeData.inputs.calendarIdUpdateCalendar
|
||||
}
|
||||
if (nodeData.inputs?.calendarNameUpdateCalendar) {
|
||||
defaultParams[action].calendarName = nodeData.inputs.calendarNameUpdateCalendar
|
||||
}
|
||||
break
|
||||
|
||||
case 'deleteCalendar':
|
||||
if (nodeData.inputs?.calendarIdDeleteCalendar) {
|
||||
defaultParams[action].calendarId = nodeData.inputs.calendarIdDeleteCalendar
|
||||
}
|
||||
break
|
||||
|
||||
case 'listEvents':
|
||||
if (nodeData.inputs?.calendarIdListEvents) {
|
||||
defaultParams[action].calendarId = nodeData.inputs.calendarIdListEvents
|
||||
}
|
||||
if (nodeData.inputs?.maxResultsListEvents) {
|
||||
defaultParams[action].maxResults = nodeData.inputs.maxResultsListEvents
|
||||
}
|
||||
if (nodeData.inputs?.startDateTimeListEvents) {
|
||||
defaultParams[action].startDateTime = nodeData.inputs.startDateTimeListEvents
|
||||
}
|
||||
if (nodeData.inputs?.endDateTimeListEvents) {
|
||||
defaultParams[action].endDateTime = nodeData.inputs.endDateTimeListEvents
|
||||
}
|
||||
break
|
||||
|
||||
case 'getEvent':
|
||||
if (nodeData.inputs?.eventIdGetEvent) {
|
||||
defaultParams[action].eventId = nodeData.inputs.eventIdGetEvent
|
||||
}
|
||||
break
|
||||
|
||||
case 'createEvent':
|
||||
if (nodeData.inputs?.subjectCreateEvent) {
|
||||
defaultParams[action].subject = nodeData.inputs.subjectCreateEvent
|
||||
}
|
||||
if (nodeData.inputs?.bodyCreateEvent) {
|
||||
defaultParams[action].body = nodeData.inputs.bodyCreateEvent
|
||||
}
|
||||
if (nodeData.inputs?.startDateTimeCreateEvent) {
|
||||
defaultParams[action].startDateTime = nodeData.inputs.startDateTimeCreateEvent
|
||||
}
|
||||
if (nodeData.inputs?.endDateTimeCreateEvent) {
|
||||
defaultParams[action].endDateTime = nodeData.inputs.endDateTimeCreateEvent
|
||||
}
|
||||
if (nodeData.inputs?.timeZoneCreateEvent) {
|
||||
defaultParams[action].timeZone = nodeData.inputs.timeZoneCreateEvent
|
||||
}
|
||||
if (nodeData.inputs?.locationCreateEvent) {
|
||||
defaultParams[action].location = nodeData.inputs.locationCreateEvent
|
||||
}
|
||||
if (nodeData.inputs?.attendeesCreateEvent) {
|
||||
defaultParams[action].attendees = nodeData.inputs.attendeesCreateEvent
|
||||
}
|
||||
break
|
||||
|
||||
case 'updateEvent':
|
||||
if (nodeData.inputs?.eventIdUpdateEvent) {
|
||||
defaultParams[action].eventId = nodeData.inputs.eventIdUpdateEvent
|
||||
}
|
||||
if (nodeData.inputs?.subjectUpdateEvent) {
|
||||
defaultParams[action].subject = nodeData.inputs.subjectUpdateEvent
|
||||
}
|
||||
break
|
||||
|
||||
case 'deleteEvent':
|
||||
if (nodeData.inputs?.eventIdDeleteEvent) {
|
||||
defaultParams[action].eventId = nodeData.inputs.eventIdDeleteEvent
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
} else if (outlookType === 'message') {
|
||||
// Map message actions to their parameters
|
||||
actions.forEach((action) => {
|
||||
defaultParams[action] = {}
|
||||
|
||||
switch (action) {
|
||||
case 'listMessages':
|
||||
if (nodeData.inputs?.maxResultsListMessages) {
|
||||
defaultParams[action].maxResults = nodeData.inputs.maxResultsListMessages
|
||||
}
|
||||
if (nodeData.inputs?.filterListMessages) {
|
||||
defaultParams[action].filter = nodeData.inputs.filterListMessages
|
||||
}
|
||||
break
|
||||
|
||||
case 'getMessage':
|
||||
if (nodeData.inputs?.messageIdGetMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdGetMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'createDraftMessage':
|
||||
if (nodeData.inputs?.toCreateDraftMessage) {
|
||||
defaultParams[action].to = nodeData.inputs.toCreateDraftMessage
|
||||
}
|
||||
if (nodeData.inputs?.subjectCreateDraftMessage) {
|
||||
defaultParams[action].subject = nodeData.inputs.subjectCreateDraftMessage
|
||||
}
|
||||
if (nodeData.inputs?.bodyCreateDraftMessage) {
|
||||
defaultParams[action].body = nodeData.inputs.bodyCreateDraftMessage
|
||||
}
|
||||
if (nodeData.inputs?.ccCreateDraftMessage) {
|
||||
defaultParams[action].cc = nodeData.inputs.ccCreateDraftMessage
|
||||
}
|
||||
if (nodeData.inputs?.bccCreateDraftMessage) {
|
||||
defaultParams[action].bcc = nodeData.inputs.bccCreateDraftMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'sendMessage':
|
||||
if (nodeData.inputs?.toSendMessage) {
|
||||
defaultParams[action].to = nodeData.inputs.toSendMessage
|
||||
}
|
||||
if (nodeData.inputs?.subjectSendMessage) {
|
||||
defaultParams[action].subject = nodeData.inputs.subjectSendMessage
|
||||
}
|
||||
if (nodeData.inputs?.bodySendMessage) {
|
||||
defaultParams[action].body = nodeData.inputs.bodySendMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'updateMessage':
|
||||
if (nodeData.inputs?.messageIdUpdateMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdUpdateMessage
|
||||
}
|
||||
if (nodeData.inputs?.isReadUpdateMessage !== undefined) {
|
||||
defaultParams[action].isRead = nodeData.inputs.isReadUpdateMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'deleteMessage':
|
||||
if (nodeData.inputs?.messageIdDeleteMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdDeleteMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'copyMessage':
|
||||
if (nodeData.inputs?.messageIdCopyMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdCopyMessage
|
||||
}
|
||||
if (nodeData.inputs?.destinationFolderIdCopyMessage) {
|
||||
defaultParams[action].destinationFolderId = nodeData.inputs.destinationFolderIdCopyMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'moveMessage':
|
||||
if (nodeData.inputs?.messageIdMoveMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdMoveMessage
|
||||
}
|
||||
if (nodeData.inputs?.destinationFolderIdMoveMessage) {
|
||||
defaultParams[action].destinationFolderId = nodeData.inputs.destinationFolderIdMoveMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'replyMessage':
|
||||
if (nodeData.inputs?.messageIdReplyMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdReplyMessage
|
||||
}
|
||||
if (nodeData.inputs?.replyBodyReplyMessage) {
|
||||
defaultParams[action].replyBody = nodeData.inputs.replyBodyReplyMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'forwardMessage':
|
||||
if (nodeData.inputs?.messageIdForwardMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdForwardMessage
|
||||
}
|
||||
if (nodeData.inputs?.forwardToForwardMessage) {
|
||||
defaultParams[action].forwardTo = nodeData.inputs.forwardToForwardMessage
|
||||
}
|
||||
if (nodeData.inputs?.forwardCommentForwardMessage) {
|
||||
defaultParams[action].forwardComment = nodeData.inputs.forwardCommentForwardMessage
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
const defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
const outlookTools = createOutlookTools({
|
||||
accessToken,
|
||||
|
|
@ -966,6 +757,66 @@ class MicrosoftOutlook_Tools implements INode {
|
|||
|
||||
return outlookTools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
// Collect default parameters from inputs
|
||||
const defaultParams: Record<string, any> = {}
|
||||
|
||||
// Calendar parameters
|
||||
if (nodeData.inputs?.maxResultsListCalendars) defaultParams.maxResultsListCalendars = nodeData.inputs.maxResultsListCalendars
|
||||
if (nodeData.inputs?.calendarIdGetCalendar) defaultParams.calendarIdGetCalendar = nodeData.inputs.calendarIdGetCalendar
|
||||
if (nodeData.inputs?.calendarNameCreateCalendar)
|
||||
defaultParams.calendarNameCreateCalendar = nodeData.inputs.calendarNameCreateCalendar
|
||||
if (nodeData.inputs?.calendarIdUpdateCalendar) defaultParams.calendarIdUpdateCalendar = nodeData.inputs.calendarIdUpdateCalendar
|
||||
if (nodeData.inputs?.calendarNameUpdateCalendar)
|
||||
defaultParams.calendarNameUpdateCalendar = nodeData.inputs.calendarNameUpdateCalendar
|
||||
if (nodeData.inputs?.calendarIdDeleteCalendar) defaultParams.calendarIdDeleteCalendar = nodeData.inputs.calendarIdDeleteCalendar
|
||||
if (nodeData.inputs?.calendarIdListEvents) defaultParams.calendarIdListEvents = nodeData.inputs.calendarIdListEvents
|
||||
if (nodeData.inputs?.maxResultsListEvents) defaultParams.maxResultsListEvents = nodeData.inputs.maxResultsListEvents
|
||||
if (nodeData.inputs?.startDateTimeListEvents) defaultParams.startDateTimeListEvents = nodeData.inputs.startDateTimeListEvents
|
||||
if (nodeData.inputs?.endDateTimeListEvents) defaultParams.endDateTimeListEvents = nodeData.inputs.endDateTimeListEvents
|
||||
if (nodeData.inputs?.eventIdGetEvent) defaultParams.eventIdGetEvent = nodeData.inputs.eventIdGetEvent
|
||||
if (nodeData.inputs?.subjectCreateEvent) defaultParams.subjectCreateEvent = nodeData.inputs.subjectCreateEvent
|
||||
if (nodeData.inputs?.bodyCreateEvent) defaultParams.bodyCreateEvent = nodeData.inputs.bodyCreateEvent
|
||||
if (nodeData.inputs?.startDateTimeCreateEvent) defaultParams.startDateTimeCreateEvent = nodeData.inputs.startDateTimeCreateEvent
|
||||
if (nodeData.inputs?.endDateTimeCreateEvent) defaultParams.endDateTimeCreateEvent = nodeData.inputs.endDateTimeCreateEvent
|
||||
if (nodeData.inputs?.timeZoneCreateEvent) defaultParams.timeZoneCreateEvent = nodeData.inputs.timeZoneCreateEvent
|
||||
if (nodeData.inputs?.locationCreateEvent) defaultParams.locationCreateEvent = nodeData.inputs.locationCreateEvent
|
||||
if (nodeData.inputs?.attendeesCreateEvent) defaultParams.attendeesCreateEvent = nodeData.inputs.attendeesCreateEvent
|
||||
if (nodeData.inputs?.eventIdUpdateEvent) defaultParams.eventIdUpdateEvent = nodeData.inputs.eventIdUpdateEvent
|
||||
if (nodeData.inputs?.subjectUpdateEvent) defaultParams.subjectUpdateEvent = nodeData.inputs.subjectUpdateEvent
|
||||
if (nodeData.inputs?.eventIdDeleteEvent) defaultParams.eventIdDeleteEvent = nodeData.inputs.eventIdDeleteEvent
|
||||
|
||||
// Message parameters
|
||||
if (nodeData.inputs?.maxResultsListMessages) defaultParams.maxResultsListMessages = nodeData.inputs.maxResultsListMessages
|
||||
if (nodeData.inputs?.filterListMessages) defaultParams.filterListMessages = nodeData.inputs.filterListMessages
|
||||
if (nodeData.inputs?.messageIdGetMessage) defaultParams.messageIdGetMessage = nodeData.inputs.messageIdGetMessage
|
||||
if (nodeData.inputs?.toCreateDraftMessage) defaultParams.toCreateDraftMessage = nodeData.inputs.toCreateDraftMessage
|
||||
if (nodeData.inputs?.subjectCreateDraftMessage) defaultParams.subjectCreateDraftMessage = nodeData.inputs.subjectCreateDraftMessage
|
||||
if (nodeData.inputs?.bodyCreateDraftMessage) defaultParams.bodyCreateDraftMessage = nodeData.inputs.bodyCreateDraftMessage
|
||||
if (nodeData.inputs?.ccCreateDraftMessage) defaultParams.ccCreateDraftMessage = nodeData.inputs.ccCreateDraftMessage
|
||||
if (nodeData.inputs?.bccCreateDraftMessage) defaultParams.bccCreateDraftMessage = nodeData.inputs.bccCreateDraftMessage
|
||||
if (nodeData.inputs?.toSendMessage) defaultParams.toSendMessage = nodeData.inputs.toSendMessage
|
||||
if (nodeData.inputs?.subjectSendMessage) defaultParams.subjectSendMessage = nodeData.inputs.subjectSendMessage
|
||||
if (nodeData.inputs?.bodySendMessage) defaultParams.bodySendMessage = nodeData.inputs.bodySendMessage
|
||||
if (nodeData.inputs?.messageIdUpdateMessage) defaultParams.messageIdUpdateMessage = nodeData.inputs.messageIdUpdateMessage
|
||||
if (nodeData.inputs?.isReadUpdateMessage !== undefined) defaultParams.isReadUpdateMessage = nodeData.inputs.isReadUpdateMessage
|
||||
if (nodeData.inputs?.messageIdDeleteMessage) defaultParams.messageIdDeleteMessage = nodeData.inputs.messageIdDeleteMessage
|
||||
if (nodeData.inputs?.messageIdCopyMessage) defaultParams.messageIdCopyMessage = nodeData.inputs.messageIdCopyMessage
|
||||
if (nodeData.inputs?.destinationFolderIdCopyMessage)
|
||||
defaultParams.destinationFolderIdCopyMessage = nodeData.inputs.destinationFolderIdCopyMessage
|
||||
if (nodeData.inputs?.messageIdMoveMessage) defaultParams.messageIdMoveMessage = nodeData.inputs.messageIdMoveMessage
|
||||
if (nodeData.inputs?.destinationFolderIdMoveMessage)
|
||||
defaultParams.destinationFolderIdMoveMessage = nodeData.inputs.destinationFolderIdMoveMessage
|
||||
if (nodeData.inputs?.messageIdReplyMessage) defaultParams.messageIdReplyMessage = nodeData.inputs.messageIdReplyMessage
|
||||
if (nodeData.inputs?.replyBodyReplyMessage) defaultParams.replyBodyReplyMessage = nodeData.inputs.replyBodyReplyMessage
|
||||
if (nodeData.inputs?.messageIdForwardMessage) defaultParams.messageIdForwardMessage = nodeData.inputs.messageIdForwardMessage
|
||||
if (nodeData.inputs?.forwardToForwardMessage) defaultParams.forwardToForwardMessage = nodeData.inputs.forwardToForwardMessage
|
||||
if (nodeData.inputs?.forwardCommentForwardMessage)
|
||||
defaultParams.forwardCommentForwardMessage = nodeData.inputs.forwardCommentForwardMessage
|
||||
|
||||
return defaultParams
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MicrosoftOutlook_Tools }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { convertMultiOptionsToStringArray, getCredentialData, getCredentialParam, refreshOAuth2Token } from '../../../src/utils'
|
||||
import { createTeamsTools } from './core'
|
||||
|
||||
|
|
@ -928,289 +928,7 @@ class MicrosoftTeams_Tools implements INode {
|
|||
throw new Error('No access token found in credential')
|
||||
}
|
||||
|
||||
// Prepare default parameters for each action based on type
|
||||
const defaultParams: ICommonObject = {}
|
||||
|
||||
if (teamsType === 'channel') {
|
||||
// Map channel actions to their parameters
|
||||
actions.forEach((action) => {
|
||||
defaultParams[action] = {}
|
||||
|
||||
switch (action) {
|
||||
case 'listChannels':
|
||||
if (nodeData.inputs?.teamIdListChannels) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdListChannels
|
||||
}
|
||||
if (nodeData.inputs?.maxResultsListChannels) {
|
||||
defaultParams[action].maxResults = nodeData.inputs.maxResultsListChannels
|
||||
}
|
||||
break
|
||||
|
||||
case 'getChannel':
|
||||
if (nodeData.inputs?.teamIdGetChannel) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdGetChannel
|
||||
}
|
||||
if (nodeData.inputs?.channelIdGetChannel) {
|
||||
defaultParams[action].channelId = nodeData.inputs.channelIdGetChannel
|
||||
}
|
||||
break
|
||||
|
||||
case 'createChannel':
|
||||
if (nodeData.inputs?.teamIdCreateChannel) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdCreateChannel
|
||||
}
|
||||
if (nodeData.inputs?.displayNameCreateChannel) {
|
||||
defaultParams[action].displayName = nodeData.inputs.displayNameCreateChannel
|
||||
}
|
||||
if (nodeData.inputs?.descriptionCreateChannel) {
|
||||
defaultParams[action].description = nodeData.inputs.descriptionCreateChannel
|
||||
}
|
||||
if (nodeData.inputs?.membershipTypeCreateChannel) {
|
||||
defaultParams[action].membershipType = nodeData.inputs.membershipTypeCreateChannel
|
||||
}
|
||||
break
|
||||
|
||||
case 'updateChannel':
|
||||
if (nodeData.inputs?.teamIdUpdateChannel) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdUpdateChannel
|
||||
}
|
||||
if (nodeData.inputs?.channelIdUpdateChannel) {
|
||||
defaultParams[action].channelId = nodeData.inputs.channelIdUpdateChannel
|
||||
}
|
||||
if (nodeData.inputs?.displayNameUpdateChannel) {
|
||||
defaultParams[action].displayName = nodeData.inputs.displayNameUpdateChannel
|
||||
}
|
||||
break
|
||||
|
||||
case 'deleteChannel':
|
||||
case 'archiveChannel':
|
||||
case 'unarchiveChannel':
|
||||
if (nodeData.inputs?.teamIdDeleteChannel) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdDeleteChannel
|
||||
}
|
||||
if (nodeData.inputs?.channelIdDeleteChannel) {
|
||||
defaultParams[action].channelId = nodeData.inputs.channelIdDeleteChannel
|
||||
}
|
||||
break
|
||||
|
||||
case 'listChannelMembers':
|
||||
if (nodeData.inputs?.teamIdChannelMembers) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdChannelMembers
|
||||
}
|
||||
if (nodeData.inputs?.channelIdChannelMembers) {
|
||||
defaultParams[action].channelId = nodeData.inputs.channelIdChannelMembers
|
||||
}
|
||||
break
|
||||
|
||||
case 'addChannelMember':
|
||||
case 'removeChannelMember':
|
||||
if (nodeData.inputs?.teamIdChannelMembers) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdChannelMembers
|
||||
}
|
||||
if (nodeData.inputs?.channelIdChannelMembers) {
|
||||
defaultParams[action].channelId = nodeData.inputs.channelIdChannelMembers
|
||||
}
|
||||
if (nodeData.inputs?.userIdChannelMember) {
|
||||
defaultParams[action].userId = nodeData.inputs.userIdChannelMember
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
} else if (teamsType === 'chat') {
|
||||
// Map chat actions to their parameters
|
||||
actions.forEach((action) => {
|
||||
defaultParams[action] = {}
|
||||
|
||||
switch (action) {
|
||||
case 'listChats':
|
||||
if (nodeData.inputs?.maxResultsListChats) {
|
||||
defaultParams[action].maxResults = nodeData.inputs.maxResultsListChats
|
||||
}
|
||||
break
|
||||
|
||||
case 'getChat':
|
||||
if (nodeData.inputs?.chatIdGetChat) {
|
||||
defaultParams[action].chatId = nodeData.inputs.chatIdGetChat
|
||||
}
|
||||
break
|
||||
|
||||
case 'createChat':
|
||||
if (nodeData.inputs?.chatTypeCreateChat) {
|
||||
defaultParams[action].chatType = nodeData.inputs.chatTypeCreateChat
|
||||
}
|
||||
if (nodeData.inputs?.topicCreateChat) {
|
||||
defaultParams[action].topic = nodeData.inputs.topicCreateChat
|
||||
}
|
||||
if (nodeData.inputs?.membersCreateChat) {
|
||||
defaultParams[action].members = nodeData.inputs.membersCreateChat
|
||||
}
|
||||
break
|
||||
|
||||
case 'updateChat':
|
||||
if (nodeData.inputs?.chatIdUpdateChat) {
|
||||
defaultParams[action].chatId = nodeData.inputs.chatIdUpdateChat
|
||||
}
|
||||
if (nodeData.inputs?.topicUpdateChat) {
|
||||
defaultParams[action].topic = nodeData.inputs.topicUpdateChat
|
||||
}
|
||||
break
|
||||
|
||||
case 'deleteChat':
|
||||
if (nodeData.inputs?.chatIdDeleteChat) {
|
||||
defaultParams[action].chatId = nodeData.inputs.chatIdDeleteChat
|
||||
}
|
||||
break
|
||||
|
||||
case 'listChatMembers':
|
||||
if (nodeData.inputs?.chatIdChatMembers) {
|
||||
defaultParams[action].chatId = nodeData.inputs.chatIdChatMembers
|
||||
}
|
||||
break
|
||||
|
||||
case 'addChatMember':
|
||||
case 'removeChatMember':
|
||||
if (nodeData.inputs?.chatIdChatMembers) {
|
||||
defaultParams[action].chatId = nodeData.inputs.chatIdChatMembers
|
||||
}
|
||||
if (nodeData.inputs?.userIdChatMember) {
|
||||
defaultParams[action].userId = nodeData.inputs.userIdChatMember
|
||||
}
|
||||
break
|
||||
|
||||
case 'pinMessage':
|
||||
case 'unpinMessage':
|
||||
if (nodeData.inputs?.chatIdPinMessage) {
|
||||
defaultParams[action].chatId = nodeData.inputs.chatIdPinMessage
|
||||
}
|
||||
if (nodeData.inputs?.messageIdPinMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdPinMessage
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
} else if (teamsType === 'chatMessage') {
|
||||
// Map chat message actions to their parameters
|
||||
actions.forEach((action) => {
|
||||
defaultParams[action] = {}
|
||||
|
||||
switch (action) {
|
||||
case 'listMessages':
|
||||
if (nodeData.inputs?.chatChannelIdListMessages) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdListMessages
|
||||
}
|
||||
if (nodeData.inputs?.teamIdListMessages) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdListMessages
|
||||
}
|
||||
if (nodeData.inputs?.maxResultsListMessages) {
|
||||
defaultParams[action].maxResults = nodeData.inputs.maxResultsListMessages
|
||||
}
|
||||
break
|
||||
|
||||
case 'getMessage':
|
||||
if (nodeData.inputs?.chatChannelIdGetMessage) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdGetMessage
|
||||
}
|
||||
if (nodeData.inputs?.teamIdGetMessage) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdGetMessage
|
||||
}
|
||||
if (nodeData.inputs?.messageIdGetMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdGetMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'sendMessage':
|
||||
if (nodeData.inputs?.chatChannelIdSendMessage) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdSendMessage
|
||||
}
|
||||
if (nodeData.inputs?.teamIdSendMessage) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdSendMessage
|
||||
}
|
||||
if (nodeData.inputs?.messageBodySendMessage) {
|
||||
defaultParams[action].messageBody = nodeData.inputs.messageBodySendMessage
|
||||
}
|
||||
if (nodeData.inputs?.contentTypeSendMessage) {
|
||||
defaultParams[action].contentType = nodeData.inputs.contentTypeSendMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'updateMessage':
|
||||
if (nodeData.inputs?.chatChannelIdUpdateMessage) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdUpdateMessage
|
||||
}
|
||||
if (nodeData.inputs?.teamIdUpdateMessage) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdUpdateMessage
|
||||
}
|
||||
if (nodeData.inputs?.messageIdUpdateMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdUpdateMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'deleteMessage':
|
||||
if (nodeData.inputs?.chatChannelIdDeleteMessage) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdDeleteMessage
|
||||
}
|
||||
if (nodeData.inputs?.teamIdDeleteMessage) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdDeleteMessage
|
||||
}
|
||||
if (nodeData.inputs?.messageIdDeleteMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdDeleteMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'replyToMessage':
|
||||
if (nodeData.inputs?.chatChannelIdReplyMessage) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdReplyMessage
|
||||
}
|
||||
if (nodeData.inputs?.teamIdReplyMessage) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdReplyMessage
|
||||
}
|
||||
if (nodeData.inputs?.messageIdReplyMessage) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdReplyMessage
|
||||
}
|
||||
if (nodeData.inputs?.replyBodyReplyMessage) {
|
||||
defaultParams[action].replyBody = nodeData.inputs.replyBodyReplyMessage
|
||||
}
|
||||
break
|
||||
|
||||
case 'setReaction':
|
||||
if (nodeData.inputs?.chatChannelIdReaction) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdReaction
|
||||
}
|
||||
if (nodeData.inputs?.teamIdReaction) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdReaction
|
||||
}
|
||||
if (nodeData.inputs?.messageIdReaction) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdReaction
|
||||
}
|
||||
if (nodeData.inputs?.reactionTypeSetReaction) {
|
||||
defaultParams[action].reactionType = nodeData.inputs.reactionTypeSetReaction
|
||||
}
|
||||
break
|
||||
|
||||
case 'unsetReaction':
|
||||
if (nodeData.inputs?.chatChannelIdReaction) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdReaction
|
||||
}
|
||||
if (nodeData.inputs?.teamIdReaction) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdReaction
|
||||
}
|
||||
if (nodeData.inputs?.messageIdReaction) {
|
||||
defaultParams[action].messageId = nodeData.inputs.messageIdReaction
|
||||
}
|
||||
break
|
||||
|
||||
case 'getAllMessages':
|
||||
// getAllMessages might use similar params to listMessages
|
||||
if (nodeData.inputs?.chatChannelIdListMessages) {
|
||||
defaultParams[action].chatChannelId = nodeData.inputs.chatChannelIdListMessages
|
||||
}
|
||||
if (nodeData.inputs?.teamIdListMessages) {
|
||||
defaultParams[action].teamId = nodeData.inputs.teamIdListMessages
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
const defaultParams = this.transformNodeInputsToToolArgs(nodeData)
|
||||
|
||||
const teamsTools = createTeamsTools({
|
||||
accessToken,
|
||||
|
|
@ -1221,6 +939,74 @@ class MicrosoftTeams_Tools implements INode {
|
|||
|
||||
return teamsTools
|
||||
}
|
||||
|
||||
transformNodeInputsToToolArgs(nodeData: INodeData): Record<string, any> {
|
||||
// Collect default parameters from inputs
|
||||
const defaultParams: Record<string, any> = {}
|
||||
|
||||
// Channel parameters
|
||||
if (nodeData.inputs?.teamIdListChannels) defaultParams.teamIdListChannels = nodeData.inputs.teamIdListChannels
|
||||
if (nodeData.inputs?.maxResultsListChannels) defaultParams.maxResultsListChannels = nodeData.inputs.maxResultsListChannels
|
||||
if (nodeData.inputs?.teamIdGetChannel) defaultParams.teamIdGetChannel = nodeData.inputs.teamIdGetChannel
|
||||
if (nodeData.inputs?.channelIdGetChannel) defaultParams.channelIdGetChannel = nodeData.inputs.channelIdGetChannel
|
||||
if (nodeData.inputs?.teamIdCreateChannel) defaultParams.teamIdCreateChannel = nodeData.inputs.teamIdCreateChannel
|
||||
if (nodeData.inputs?.displayNameCreateChannel) defaultParams.displayNameCreateChannel = nodeData.inputs.displayNameCreateChannel
|
||||
if (nodeData.inputs?.descriptionCreateChannel) defaultParams.descriptionCreateChannel = nodeData.inputs.descriptionCreateChannel
|
||||
if (nodeData.inputs?.membershipTypeCreateChannel)
|
||||
defaultParams.membershipTypeCreateChannel = nodeData.inputs.membershipTypeCreateChannel
|
||||
if (nodeData.inputs?.teamIdUpdateChannel) defaultParams.teamIdUpdateChannel = nodeData.inputs.teamIdUpdateChannel
|
||||
if (nodeData.inputs?.channelIdUpdateChannel) defaultParams.channelIdUpdateChannel = nodeData.inputs.channelIdUpdateChannel
|
||||
if (nodeData.inputs?.displayNameUpdateChannel) defaultParams.displayNameUpdateChannel = nodeData.inputs.displayNameUpdateChannel
|
||||
if (nodeData.inputs?.teamIdDeleteChannel) defaultParams.teamIdDeleteChannel = nodeData.inputs.teamIdDeleteChannel
|
||||
if (nodeData.inputs?.channelIdDeleteChannel) defaultParams.channelIdDeleteChannel = nodeData.inputs.channelIdDeleteChannel
|
||||
if (nodeData.inputs?.teamIdChannelMembers) defaultParams.teamIdChannelMembers = nodeData.inputs.teamIdChannelMembers
|
||||
if (nodeData.inputs?.channelIdChannelMembers) defaultParams.channelIdChannelMembers = nodeData.inputs.channelIdChannelMembers
|
||||
if (nodeData.inputs?.userIdChannelMember) defaultParams.userIdChannelMember = nodeData.inputs.userIdChannelMember
|
||||
|
||||
// Chat parameters
|
||||
if (nodeData.inputs?.maxResultsListChats) defaultParams.maxResultsListChats = nodeData.inputs.maxResultsListChats
|
||||
if (nodeData.inputs?.chatIdGetChat) defaultParams.chatIdGetChat = nodeData.inputs.chatIdGetChat
|
||||
if (nodeData.inputs?.chatTypeCreateChat) defaultParams.chatTypeCreateChat = nodeData.inputs.chatTypeCreateChat
|
||||
if (nodeData.inputs?.topicCreateChat) defaultParams.topicCreateChat = nodeData.inputs.topicCreateChat
|
||||
if (nodeData.inputs?.membersCreateChat) defaultParams.membersCreateChat = nodeData.inputs.membersCreateChat
|
||||
if (nodeData.inputs?.chatIdUpdateChat) defaultParams.chatIdUpdateChat = nodeData.inputs.chatIdUpdateChat
|
||||
if (nodeData.inputs?.topicUpdateChat) defaultParams.topicUpdateChat = nodeData.inputs.topicUpdateChat
|
||||
if (nodeData.inputs?.chatIdDeleteChat) defaultParams.chatIdDeleteChat = nodeData.inputs.chatIdDeleteChat
|
||||
if (nodeData.inputs?.chatIdChatMembers) defaultParams.chatIdChatMembers = nodeData.inputs.chatIdChatMembers
|
||||
if (nodeData.inputs?.userIdChatMember) defaultParams.userIdChatMember = nodeData.inputs.userIdChatMember
|
||||
if (nodeData.inputs?.chatIdPinMessage) defaultParams.chatIdPinMessage = nodeData.inputs.chatIdPinMessage
|
||||
if (nodeData.inputs?.messageIdPinMessage) defaultParams.messageIdPinMessage = nodeData.inputs.messageIdPinMessage
|
||||
|
||||
// Chat Message parameters
|
||||
if (nodeData.inputs?.chatChannelIdListMessages) defaultParams.chatChannelIdListMessages = nodeData.inputs.chatChannelIdListMessages
|
||||
if (nodeData.inputs?.teamIdListMessages) defaultParams.teamIdListMessages = nodeData.inputs.teamIdListMessages
|
||||
if (nodeData.inputs?.maxResultsListMessages) defaultParams.maxResultsListMessages = nodeData.inputs.maxResultsListMessages
|
||||
if (nodeData.inputs?.chatChannelIdGetMessage) defaultParams.chatChannelIdGetMessage = nodeData.inputs.chatChannelIdGetMessage
|
||||
if (nodeData.inputs?.teamIdGetMessage) defaultParams.teamIdGetMessage = nodeData.inputs.teamIdGetMessage
|
||||
if (nodeData.inputs?.messageIdGetMessage) defaultParams.messageIdGetMessage = nodeData.inputs.messageIdGetMessage
|
||||
if (nodeData.inputs?.chatChannelIdSendMessage) defaultParams.chatChannelIdSendMessage = nodeData.inputs.chatChannelIdSendMessage
|
||||
if (nodeData.inputs?.teamIdSendMessage) defaultParams.teamIdSendMessage = nodeData.inputs.teamIdSendMessage
|
||||
if (nodeData.inputs?.messageBodySendMessage) defaultParams.messageBodySendMessage = nodeData.inputs.messageBodySendMessage
|
||||
if (nodeData.inputs?.contentTypeSendMessage) defaultParams.contentTypeSendMessage = nodeData.inputs.contentTypeSendMessage
|
||||
if (nodeData.inputs?.chatChannelIdUpdateMessage)
|
||||
defaultParams.chatChannelIdUpdateMessage = nodeData.inputs.chatChannelIdUpdateMessage
|
||||
if (nodeData.inputs?.teamIdUpdateMessage) defaultParams.teamIdUpdateMessage = nodeData.inputs.teamIdUpdateMessage
|
||||
if (nodeData.inputs?.messageIdUpdateMessage) defaultParams.messageIdUpdateMessage = nodeData.inputs.messageIdUpdateMessage
|
||||
if (nodeData.inputs?.chatChannelIdDeleteMessage)
|
||||
defaultParams.chatChannelIdDeleteMessage = nodeData.inputs.chatChannelIdDeleteMessage
|
||||
if (nodeData.inputs?.teamIdDeleteMessage) defaultParams.teamIdDeleteMessage = nodeData.inputs.teamIdDeleteMessage
|
||||
if (nodeData.inputs?.messageIdDeleteMessage) defaultParams.messageIdDeleteMessage = nodeData.inputs.messageIdDeleteMessage
|
||||
if (nodeData.inputs?.chatChannelIdReplyMessage) defaultParams.chatChannelIdReplyMessage = nodeData.inputs.chatChannelIdReplyMessage
|
||||
if (nodeData.inputs?.teamIdReplyMessage) defaultParams.teamIdReplyMessage = nodeData.inputs.teamIdReplyMessage
|
||||
if (nodeData.inputs?.messageIdReplyMessage) defaultParams.messageIdReplyMessage = nodeData.inputs.messageIdReplyMessage
|
||||
if (nodeData.inputs?.replyBodyReplyMessage) defaultParams.replyBodyReplyMessage = nodeData.inputs.replyBodyReplyMessage
|
||||
if (nodeData.inputs?.chatChannelIdReaction) defaultParams.chatChannelIdReaction = nodeData.inputs.chatChannelIdReaction
|
||||
if (nodeData.inputs?.teamIdReaction) defaultParams.teamIdReaction = nodeData.inputs.teamIdReaction
|
||||
if (nodeData.inputs?.messageIdReaction) defaultParams.messageIdReaction = nodeData.inputs.messageIdReaction
|
||||
if (nodeData.inputs?.reactionTypeSetReaction) defaultParams.reactionTypeSetReaction = nodeData.inputs.reactionTypeSetReaction
|
||||
|
||||
return defaultParams
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MicrosoftTeams_Tools }
|
||||
|
|
|
|||
Loading…
Reference in New Issue