diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index c671283f69dd3..6517ef75fe5cd 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -992,7 +992,7 @@ class App { ); } - return { results: [] }; + throw new ResponseError('Parameter methodName is required.', undefined, 400); }, ), ); diff --git a/packages/nodes-base/nodes/Airtable/Airtable.node.ts b/packages/nodes-base/nodes/Airtable/Airtable.node.ts index 0dc96e74ca167..5536870d55cd7 100644 --- a/packages/nodes-base/nodes/Airtable/Airtable.node.ts +++ b/packages/nodes-base/nodes/Airtable/Airtable.node.ts @@ -2,7 +2,9 @@ import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, + ILoadOptionsFunctions, INodeExecutionData, + INodeListSearchResult, INodeType, INodeTypeDescription, NodeOperationError, @@ -10,13 +12,25 @@ import { import { apiRequest, apiRequestAllItems, downloadRecordAttachments } from './GenericFunctions'; +interface AirtableBase { + id: string; + name: string; +} + +interface AirtableTable { + id: string; + name: string; + description: string; +} + export class Airtable implements INodeType { description: INodeTypeDescription = { displayName: 'Airtable', name: 'airtable', icon: 'file:airtable.svg', group: ['input'], - version: 1, + version: [1, 2], + defaultVersion: 2, description: 'Read, update, write and delete data from Airtable', defaults: { name: 'Airtable', @@ -80,6 +94,11 @@ export class Airtable implements INodeType { default: '', required: true, description: 'The ID of the base to access', + displayOptions: { + show: { + '@version': [1], + }, + }, }, { displayName: 'Table ID', @@ -89,6 +108,121 @@ export class Airtable implements INodeType { placeholder: 'Stories', required: true, description: 'The ID of the table to access', + displayOptions: { + show: { + '@version': [1], + }, + }, + }, + + { + displayName: 'Base ID', + name: 'applicationRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + displayOptions: { + show: { + '@version': [2], + }, + }, + description: 'The ID of the base to access', + modes: [ + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter base Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'appD3dfaeidke', + url: '=https://airtable.com/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter base URL', + placeholder: 'https://airtable.com/app12DiScdfes/tblAAAAAAAAAAAAA/viwHdfasdfeieg5p', + validation: [ + { + type: 'regex', + properties: { + regex: 'https://airtable.com/([a-zA-Z0-9]+)/[a-zA-Z0-9/]+', + errorMessage: + 'URL has to be in the format: https://airtable.com///', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://airtable.com/([a-zA-Z0-9]+)', + }, + }, + ], + }, + { + displayName: 'Table ID', + name: 'tableRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + displayOptions: { + show: { + '@version': [2], + }, + }, + description: 'The ID of the table', + modes: [ + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter table Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'tbl3dirwqeidke', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter table URL', + placeholder: 'https://airtable.com/app12DiScdfes/tblAAAAAAAAAAAAA/viwHdfasdfeieg5p', + validation: [ + { + type: 'regex', + properties: { + regex: 'https://airtable.com/[a-zA-Z0-9]+/([a-zA-Z0-9]+)', + errorMessage: + 'URL has to be in the format: https://airtable.com//
/', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://airtable.com/[a-zA-Z0-9]+/([a-zA-Z0-9]+)', + }, + }, + ], }, // ---------------------------------- @@ -421,10 +555,27 @@ export class Airtable implements INodeType { const returnData: INodeExecutionData[] = []; let responseData; + const version = this.getNode().typeVersion; + const operation = this.getNodeParameter('operation', 0) as string; - const application = this.getNodeParameter('application', 0) as string; - const table = encodeURI(this.getNodeParameter('table', 0) as string); + let application: string; + if (version === 2) { + application = this.getNodeParameter('applicationRLC', 0, undefined, { + extractValue: true, + }) as string; + } else { + application = this.getNodeParameter('application', 0) as string; + } + + let table: string; + if (version === 2) { + table = this.getNodeParameter('tableRLC', 0, undefined, { + extractValue: true, + }) as string; + } else { + table = this.getNodeParameter('table', 0) as string; + } let returnAll = false; let endpoint = ''; @@ -493,7 +644,7 @@ export class Airtable implements INodeType { } } catch (error) { if (this.continueOnFail()) { - returnData.push({json: { error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; @@ -538,7 +689,7 @@ export class Airtable implements INodeType { } } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; @@ -589,14 +740,13 @@ export class Airtable implements INodeType { // We can return from here return [ - this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(returnData), - { itemData: { item: 0 } }, - ), + this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(returnData), { + itemData: { item: 0 }, + }), ]; } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); } else { throw error; } @@ -631,7 +781,7 @@ export class Airtable implements INodeType { returnData.push(...executionData); } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; @@ -718,7 +868,7 @@ export class Airtable implements INodeType { } } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; diff --git a/packages/nodes-base/nodes/Trello/v1/AttachmentDescription.ts b/packages/nodes-base/nodes/Trello/AttachmentDescription.ts similarity index 72% rename from packages/nodes-base/nodes/Trello/v1/AttachmentDescription.ts rename to packages/nodes-base/nodes/Trello/AttachmentDescription.ts index 75aee8d37689f..535c95b323061 100644 --- a/packages/nodes-base/nodes/Trello/v1/AttachmentDescription.ts +++ b/packages/nodes-base/nodes/Trello/AttachmentDescription.ts @@ -45,6 +45,76 @@ export const attachmentOperations: INodeProperties[] = [ ]; export const attachmentFields: INodeProperties[] = [ + { + displayName: 'Card ID', + name: 'cardIdAttachmentRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + modes: [ + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'From List', + name: 'list', + type: 'list', + hint: 'Select a card from the list', + placeholder: 'Choose...', + typeOptions: { + searchListMethod: 'searchCards', + searchFilterRequired: true, + searchable: true, + }, + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter Card Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'wiIaGwqE', + url: '=https://trello.com/c/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter Card URL', + placeholder: 'https://trello.com/c/e123456/card-name', + validation: [ + { + type: 'regex', + properties: { + regex: 'http(s)?://trello.com/c/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', + errorMessage: + 'URL has to be in the format: http(s)://trello.com/c//', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://trello.com/c/([a-zA-Z0-9]+)', + }, + }, + ], + displayOptions: { + show: { + operation: ['delete', 'create', 'get', 'getAll'], + resource: ['attachment'], + '@version': [2], + }, + }, + description: 'The ID of the card', + }, // ---------------------------------- // attachment:create // ---------------------------------- @@ -58,6 +128,7 @@ export const attachmentFields: INodeProperties[] = [ show: { operation: ['create'], resource: ['attachment'], + '@version': [1], }, }, description: 'The ID of the card to add attachment to', @@ -120,6 +191,7 @@ export const attachmentFields: INodeProperties[] = [ show: { operation: ['delete'], resource: ['attachment'], + '@version': [1], }, }, description: 'The ID of the card that attachment belongs to', @@ -152,6 +224,7 @@ export const attachmentFields: INodeProperties[] = [ show: { operation: ['getAll'], resource: ['attachment'], + '@version': [1], }, }, description: 'The ID of the card to get attachments', @@ -192,6 +265,7 @@ export const attachmentFields: INodeProperties[] = [ show: { operation: ['get'], resource: ['attachment'], + '@version': [1], }, }, description: 'The ID of the card to get attachment', diff --git a/packages/nodes-base/nodes/Trello/v1/BoardDescription.ts b/packages/nodes-base/nodes/Trello/BoardDescription.ts similarity index 82% rename from packages/nodes-base/nodes/Trello/v1/BoardDescription.ts rename to packages/nodes-base/nodes/Trello/BoardDescription.ts index ccd0f1a60a477..8a5054be2e94f 100644 --- a/packages/nodes-base/nodes/Trello/v1/BoardDescription.ts +++ b/packages/nodes-base/nodes/Trello/BoardDescription.ts @@ -294,6 +294,79 @@ export const boardFields: INodeProperties[] = [ ], }, + { + displayName: 'Board', + name: 'boardIdRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + displayOptions: { + show: { + operation: ['get', 'delete', 'update'], + resource: ['board'], + '@version': [2], + }, + }, + description: 'The ID of the board', + modes: [ + // TODO: This rule should only apply for direct node properties, not their children + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'From List', + name: 'list', + type: 'list', + hint: 'Select a board from the list', + placeholder: 'Choose...', + initType: 'board', + typeOptions: { + searchListMethod: 'searchBoards', + searchFilterRequired: true, + searchable: true, + }, + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter Board Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'KdEAAdde', + url: '=https://trello.com/b/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter board URL', + placeholder: 'https://trello.com/b/e123456/board-name', + validation: [ + { + type: 'regex', + properties: { + regex: 'http(s)?://trello.com/b/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', + errorMessage: + 'URL has to be in the format: http(s)://trello.com/b//', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://trello.com/b/([a-zA-Z0-9]+)', + }, + }, + ], + }, + // ---------------------------------- // board:delete // ---------------------------------- @@ -307,6 +380,7 @@ export const boardFields: INodeProperties[] = [ show: { operation: ['delete'], resource: ['board'], + '@version': [1], }, }, description: 'The ID of the board to delete', @@ -325,6 +399,7 @@ export const boardFields: INodeProperties[] = [ show: { operation: ['get'], resource: ['board'], + '@version': [1], }, }, description: 'The ID of the board to get', @@ -373,6 +448,7 @@ export const boardFields: INodeProperties[] = [ show: { operation: ['update'], resource: ['board'], + '@version': [1], }, }, description: 'The ID of the board to update', diff --git a/packages/nodes-base/nodes/Trello/v1/BoardMemberDescription.ts b/packages/nodes-base/nodes/Trello/BoardMemberDescription.ts similarity index 100% rename from packages/nodes-base/nodes/Trello/v1/BoardMemberDescription.ts rename to packages/nodes-base/nodes/Trello/BoardMemberDescription.ts diff --git a/packages/nodes-base/nodes/Trello/v1/CardCommentDescription.ts b/packages/nodes-base/nodes/Trello/CardCommentDescription.ts similarity index 61% rename from packages/nodes-base/nodes/Trello/v1/CardCommentDescription.ts rename to packages/nodes-base/nodes/Trello/CardCommentDescription.ts index b3a733077328e..0652a526f4589 100644 --- a/packages/nodes-base/nodes/Trello/v1/CardCommentDescription.ts +++ b/packages/nodes-base/nodes/Trello/CardCommentDescription.ts @@ -36,6 +36,77 @@ export const cardCommentOperations: INodeProperties[] = [ ]; export const cardCommentFields: INodeProperties[] = [ + { + displayName: 'Card ID', + name: 'cardIdCommentRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + modes: [ + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'From List', + name: 'list', + type: 'list', + hint: 'Select a card from the list', + placeholder: 'Choose...', + typeOptions: { + searchListMethod: 'searchCards', + searchFilterRequired: true, + searchable: true, + }, + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter Card Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'wiIaGwqE', + url: '=https://trello.com/c/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter Card URL', + placeholder: 'https://trello.com/c/e123456/card-name', + validation: [ + { + type: 'regex', + properties: { + regex: 'http(s)?://trello.com/c/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', + errorMessage: + 'URL has to be in the format: http(s)://trello.com/c//', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://trello.com/c/([a-zA-Z0-9]+)', + }, + }, + ], + displayOptions: { + show: { + operation: ['update', 'delete', 'create'], + resource: ['cardComment'], + '@version': [2], + }, + }, + description: 'The ID of the card', + }, + // ---------------------------------- // cardComment:create // ---------------------------------- @@ -49,6 +120,7 @@ export const cardCommentFields: INodeProperties[] = [ show: { operation: ['create'], resource: ['cardComment'], + '@version': [1], }, }, description: 'The ID of the card', @@ -81,6 +153,7 @@ export const cardCommentFields: INodeProperties[] = [ show: { operation: ['delete'], resource: ['cardComment'], + '@version': [1], }, }, description: 'The ID of the card', @@ -113,6 +186,7 @@ export const cardCommentFields: INodeProperties[] = [ show: { operation: ['update'], resource: ['cardComment'], + '@version': [1], }, }, description: 'The ID of the card to update', diff --git a/packages/nodes-base/nodes/Trello/v1/CardDescription.ts b/packages/nodes-base/nodes/Trello/CardDescription.ts similarity index 83% rename from packages/nodes-base/nodes/Trello/v1/CardDescription.ts rename to packages/nodes-base/nodes/Trello/CardDescription.ts index 2acd2ede0ec8b..15749acbb018a 100644 --- a/packages/nodes-base/nodes/Trello/v1/CardDescription.ts +++ b/packages/nodes-base/nodes/Trello/CardDescription.ts @@ -163,6 +163,77 @@ export const cardFields: INodeProperties[] = [ ], }, + { + displayName: 'Card ID', + name: 'cardIdRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + modes: [ + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'From List', + name: 'list', + type: 'list', + hint: 'Select a card from the list', + placeholder: 'Choose...', + typeOptions: { + searchListMethod: 'searchCards', + searchFilterRequired: true, + searchable: true, + }, + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter Card Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'wiIaGwqE', + url: '=https://trello.com/c/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter Card URL', + placeholder: 'https://trello.com/c/e123456/card-name', + validation: [ + { + type: 'regex', + properties: { + regex: 'http(s)?://trello.com/c/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', + errorMessage: + 'URL has to be in the format: http(s)://trello.com/c//', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://trello.com/c/([a-zA-Z0-9]+)', + }, + }, + ], + displayOptions: { + show: { + operation: ['get', 'delete', 'update'], + resource: ['card'], + '@version': [2], + }, + }, + description: 'The ID of the card', + }, + // ---------------------------------- // card:delete // ---------------------------------- @@ -176,6 +247,7 @@ export const cardFields: INodeProperties[] = [ show: { operation: ['delete'], resource: ['card'], + '@version': [1], }, }, description: 'The ID of the card to delete', @@ -194,6 +266,7 @@ export const cardFields: INodeProperties[] = [ show: { operation: ['get'], resource: ['card'], + '@version': [1], }, }, description: 'The ID of the card to get', @@ -295,6 +368,7 @@ export const cardFields: INodeProperties[] = [ show: { operation: ['update'], resource: ['card'], + '@version': [1], }, }, description: 'The ID of the card to update', diff --git a/packages/nodes-base/nodes/Trello/v1/ChecklistDescription.ts b/packages/nodes-base/nodes/Trello/ChecklistDescription.ts similarity index 85% rename from packages/nodes-base/nodes/Trello/v1/ChecklistDescription.ts rename to packages/nodes-base/nodes/Trello/ChecklistDescription.ts index 83ff9ed98866d..9ffe499161fae 100644 --- a/packages/nodes-base/nodes/Trello/v1/ChecklistDescription.ts +++ b/packages/nodes-base/nodes/Trello/ChecklistDescription.ts @@ -75,6 +75,77 @@ export const checklistOperations: INodeProperties[] = [ ]; export const checklistFields: INodeProperties[] = [ + { + displayName: 'Card ID', + name: 'cardIdChecklistRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + modes: [ + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'From List', + name: 'list', + type: 'list', + hint: 'Select a card from the list', + placeholder: 'Choose...', + typeOptions: { + searchListMethod: 'searchCards', + searchFilterRequired: true, + searchable: true, + }, + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter Card Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'wiIaGwqE', + url: '=https://trello.com/c/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter Card URL', + placeholder: 'https://trello.com/c/e123456/card-name', + validation: [ + { + type: 'regex', + properties: { + regex: 'http(s)?://trello.com/c/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', + errorMessage: + 'URL has to be in the format: http(s)://trello.com/c//', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://trello.com/c/([a-zA-Z0-9]+)', + }, + }, + ], + displayOptions: { + show: { + operation: ['delete', 'create', 'getAll', 'deleteCheckItem', 'getCheckItem', 'updateCheckItem', 'completeCheckItems'], + resource: ['checklist'], + '@version': [2], + }, + }, + description: 'The ID of the card', + }, + // ---------------------------------- // checklist:create // ---------------------------------- @@ -88,6 +159,7 @@ export const checklistFields: INodeProperties[] = [ show: { operation: ['create'], resource: ['checklist'], + '@version': [1], }, }, description: 'The ID of the card to add checklist to', @@ -150,6 +222,7 @@ export const checklistFields: INodeProperties[] = [ show: { operation: ['delete'], resource: ['checklist'], + '@version': [1], }, }, description: 'The ID of the card that checklist belongs to', @@ -182,6 +255,7 @@ export const checklistFields: INodeProperties[] = [ show: { operation: ['getAll'], resource: ['checklist'], + '@version': [1], }, }, description: 'The ID of the card to get checklists', @@ -324,6 +398,7 @@ export const checklistFields: INodeProperties[] = [ show: { operation: ['deleteCheckItem'], resource: ['checklist'], + '@version': [1], }, }, description: 'The ID of the card that checklist belongs to', @@ -356,6 +431,7 @@ export const checklistFields: INodeProperties[] = [ show: { operation: ['getCheckItem'], resource: ['checklist'], + '@version': [1], }, }, description: 'The ID of the card that checklist belongs to', @@ -410,6 +486,7 @@ export const checklistFields: INodeProperties[] = [ show: { operation: ['updateCheckItem'], resource: ['checklist'], + '@version': [1], }, }, description: 'The ID of the card that checklist belongs to', @@ -495,6 +572,7 @@ export const checklistFields: INodeProperties[] = [ show: { operation: ['completedCheckItems'], resource: ['checklist'], + '@version': [1], }, }, description: 'The ID of the card for checkItems', diff --git a/packages/nodes-base/nodes/Trello/v1/LabelDescription.ts b/packages/nodes-base/nodes/Trello/LabelDescription.ts similarity index 67% rename from packages/nodes-base/nodes/Trello/v1/LabelDescription.ts rename to packages/nodes-base/nodes/Trello/LabelDescription.ts index 2bb7e4e0c99e0..7a995ab9157b7 100644 --- a/packages/nodes-base/nodes/Trello/v1/LabelDescription.ts +++ b/packages/nodes-base/nodes/Trello/LabelDescription.ts @@ -63,6 +63,80 @@ export const labelOperations: INodeProperties[] = [ ]; export const labelFields: INodeProperties[] = [ + { + displayName: 'Board', + name: 'boardIdLabelRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + displayOptions: { + show: { + operation: ['create', 'getAll'], + resource: ['label'], + '@version': [2], + }, + }, + description: 'The ID of the board', + modes: [ + // TODO: This rule should only apply for direct node properties, not their children + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'From List', + name: 'list', + type: 'list', + hint: 'Select a board from the list', + placeholder: 'Choose...', + initType: 'board', + typeOptions: { + searchListMethod: 'searchBoards', + searchFilterRequired: true, + searchable: true, + }, + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter Board Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'KdEAAdde', + url: '=https://trello.com/b/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter board URL', + placeholder: 'https://trello.com/b/e123456/board-name', + validation: [ + { + type: 'regex', + properties: { + regex: 'http(s)?://trello.com/b/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', + errorMessage: + 'URL has to be in the format: http(s)://trello.com/b//', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://trello.com/b/([a-zA-Z0-9]+)', + }, + }, + ], + }, + + // ---------------------------------- // label:create // ---------------------------------- @@ -76,6 +150,7 @@ export const labelFields: INodeProperties[] = [ show: { operation: ['create'], resource: ['label'], + '@version': [1], }, }, description: 'The ID of the board to create the label on', @@ -186,6 +261,7 @@ export const labelFields: INodeProperties[] = [ show: { operation: ['getAll'], resource: ['label'], + '@version': [1], }, }, description: 'The ID of the board to get label', @@ -253,6 +329,77 @@ export const labelFields: INodeProperties[] = [ ], }, + { + displayName: 'Card ID', + name: 'cardIdLabelRLC', + type: 'resourceLocator', + default: { mode: 'list', value: '' }, + required: true, + modes: [ + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'From List', + name: 'list', + type: 'list', + hint: 'Select a card from the list', + placeholder: 'Choose...', + typeOptions: { + searchListMethod: 'searchCards', + searchFilterRequired: true, + searchable: true, + }, + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'ID', + name: 'id', + type: 'string', + hint: 'Enter Card Id', + validation: [ + { + type: 'regex', + properties: { + regex: '[a-zA-Z0-9]+', + errorMessage: 'ID value cannot be empty', + }, + }, + ], + placeholder: 'wiIaGwqE', + url: '=https://trello.com/c/{{$value}}', + }, + // eslint-disable-next-line n8n-nodes-base/node-param-default-missing + { + displayName: 'By URL', + name: 'url', + type: 'string', + hint: 'Enter Card URL', + placeholder: 'https://trello.com/c/e123456/card-name', + validation: [ + { + type: 'regex', + properties: { + regex: 'http(s)?://trello.com/c/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', + errorMessage: + 'URL has to be in the format: http(s)://trello.com/c//', + }, + }, + ], + extractValue: { + type: 'regex', + regex: 'https://trello.com/c/([a-zA-Z0-9]+)', + }, + }, + ], + displayOptions: { + show: { + operation: ['addLabel', 'removeLabel'], + resource: ['label'], + '@version': [2], + }, + }, + description: 'The ID of the card', + }, + // ---------------------------------- // label:addLabel // ---------------------------------- @@ -266,6 +413,7 @@ export const labelFields: INodeProperties[] = [ show: { operation: ['addLabel'], resource: ['label'], + '@version': [1], }, }, description: 'The ID of the card to get label', diff --git a/packages/nodes-base/nodes/Trello/v1/ListDescription.ts b/packages/nodes-base/nodes/Trello/ListDescription.ts similarity index 100% rename from packages/nodes-base/nodes/Trello/v1/ListDescription.ts rename to packages/nodes-base/nodes/Trello/ListDescription.ts diff --git a/packages/nodes-base/nodes/Trello/Trello.node.ts b/packages/nodes-base/nodes/Trello/Trello.node.ts index b9a5b6d48ded8..1db1db9d37e87 100644 --- a/packages/nodes-base/nodes/Trello/Trello.node.ts +++ b/packages/nodes-base/nodes/Trello/Trello.node.ts @@ -1,28 +1,1066 @@ -import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { TrelloV1 } from './v1/TrelloV1.node'; +import { + IDataObject, + INodeExecutionData, + INodeListSearchResult, + INodeType, + INodeTypeDescription, + NodeOperationError, +} from 'n8n-workflow'; -import { TrelloV2 } from './v2/TrelloV2.node'; +import { apiRequest, apiRequestAllItems } from './GenericFunctions'; -import { NodeVersionedType } from '../../src/NodeVersionedType'; +import { attachmentFields, attachmentOperations } from './AttachmentDescription'; -export class Trello extends NodeVersionedType { - constructor() { - const baseDescription: INodeTypeBaseDescription = { - displayName: 'Trello', - name: 'trello', - icon: 'file:trello.svg', - group: ['transform'], - subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Create, change and delete boards and cards', - defaultVersion: 2, - }; +import { boardFields, boardOperations } from './BoardDescription'; - const nodeVersions: INodeVersionedType['nodeVersions'] = { - 1: new TrelloV1(baseDescription), - 2: new TrelloV2(baseDescription), - }; +import { boardMemberFields, boardMemberOperations } from './BoardMemberDescription'; - super(nodeVersions, baseDescription); +import { cardFields, cardOperations } from './CardDescription'; + +import { cardCommentFields, cardCommentOperations } from './CardCommentDescription'; + +import { checklistFields, checklistOperations } from './ChecklistDescription'; + +import { labelFields, labelOperations } from './LabelDescription'; + +import { listFields, listOperations } from './ListDescription'; + +interface TrelloBoardType { + id: string; + name: string; + url: string; + desc: string; +} + +// We retrieve the same fields. This is just to make it clear it's not actually +// getting boards back. +type TrelloCardType = TrelloBoardType; + +export class Trello implements INodeType { + description: INodeTypeDescription = { + displayName: 'Trello', + name: 'trello', + icon: 'file:trello.svg', + group: ['transform'], + version: [1, 2], + subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', + description: 'Create, change and delete boards and cards', + defaults: { + name: 'Trello', + }, + inputs: ['main'], + outputs: ['main'], + credentials: [ + { + name: 'trelloApi', + required: true, + }, + ], + properties: [ + { + displayName: 'Resource', + name: 'resource', + type: 'options', + noDataExpression: true, + options: [ + { + name: 'Attachment', + value: 'attachment', + }, + { + name: 'Board', + value: 'board', + }, + { + name: 'Board Member', + value: 'boardMember', + }, + { + name: 'Card', + value: 'card', + }, + { + name: 'Card Comment', + value: 'cardComment', + }, + { + name: 'Checklist', + value: 'checklist', + }, + { + name: 'Label', + value: 'label', + }, + { + name: 'List', + value: 'list', + }, + ], + default: 'card', + }, + + // ---------------------------------- + // operations + // ---------------------------------- + ...attachmentOperations, + ...boardOperations, + ...boardMemberOperations, + ...cardOperations, + ...cardCommentOperations, + ...checklistOperations, + ...labelOperations, + ...listOperations, + + // ---------------------------------- + // fields + // ---------------------------------- + ...attachmentFields, + ...boardFields, + ...boardMemberFields, + ...cardFields, + ...cardCommentFields, + ...checklistFields, + ...labelFields, + ...listFields, + ], + }; + + methods = { + listSearch: { + async searchBoards( + this: ILoadOptionsFunctions, + query?: string, + ): Promise { + if (!query) { + throw new NodeOperationError(this.getNode(), 'Query required for Trello search'); + } + const searchResults = await apiRequest.call( + this, + 'GET', + 'search', + {}, + { + query, + modelTypes: 'boards', + board_fields: 'name,url,desc', + // Enables partial word searching, only for the start of words though + partial: true, + // Seems like a good number since it isn't paginated. Default is 10. + boards_limit: 50, + }, + ); + return { + results: searchResults.boards.map((b: TrelloBoardType) => ({ + name: b.name, + value: b.id, + url: b.url, + description: b.desc, + })), + }; + }, + async searchCards( + this: ILoadOptionsFunctions, + query?: string, + ): Promise { + if (!query) { + throw new NodeOperationError(this.getNode(), 'Query required for Trello search'); + } + const searchResults = await apiRequest.call( + this, + 'GET', + 'search', + {}, + { + query, + modelTypes: 'cards', + board_fields: 'name,url,desc', + // Enables partial word searching, only for the start of words though + partial: true, + // Seems like a good number since it isn't paginated. Default is 10. + cards_limit: 50, + }, + ); + return { + results: searchResults.cards.map((b: TrelloBoardType) => ({ + name: b.name, + value: b.id, + url: b.url, + description: b.desc, + })), + }; + }, + }, + }; + + async execute(this: IExecuteFunctions): Promise { + const items = this.getInputData(); + const returnData: INodeExecutionData[] = []; + + const operation = this.getNodeParameter('operation', 0) as string; + const resource = this.getNodeParameter('resource', 0) as string; + const version = this.getNode().typeVersion; + + // For Post + let body: IDataObject; + // For Query string + let qs: IDataObject; + + let requestMethod: string; + let endpoint: string; + let returnAll = false; + let responseData; + + for (let i = 0; i < items.length; i++) { + try { + requestMethod = 'GET'; + endpoint = ''; + body = {}; + qs = {}; + + if (resource === 'board') { + if (operation === 'create') { + // ---------------------------------- + // create + // ---------------------------------- + + requestMethod = 'POST'; + endpoint = 'boards'; + + qs.name = this.getNodeParameter('name', i) as string; + qs.desc = this.getNodeParameter('description', i) as string; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + let id: string; + + if (version === 2) { + id = this.getNodeParameter('boardIdRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + id = this.getNodeParameter('id', i) as string; + } + + endpoint = `boards/${id}`; + } else if (operation === 'get') { + // ---------------------------------- + // get + // ---------------------------------- + + requestMethod = 'GET'; + + let id: string; + + if (version === 2) { + id = this.getNodeParameter('boardIdRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + id = this.getNodeParameter('id', i) as string; + } + + endpoint = `boards/${id}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'update') { + // ---------------------------------- + // update + // ---------------------------------- + + requestMethod = 'PUT'; + + let id: string; + + if (version === 2) { + id = this.getNodeParameter('boardIdRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + id = this.getNodeParameter('id', i) as string; + } + + endpoint = `boards/${id}`; + + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + Object.assign(qs, updateFields); + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else if (resource === 'boardMember') { + if (operation === 'getAll') { + // ---------------------------------- + // getAll + // ---------------------------------- + + requestMethod = 'GET'; + + const id = this.getNodeParameter('id', i) as string; + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + endpoint = `boards/${id}/members`; + } else if (operation === 'add') { + // ---------------------------------- + // add + // ---------------------------------- + + requestMethod = 'PUT'; + + const id = this.getNodeParameter('id', i) as string; + const idMember = this.getNodeParameter('idMember', i) as string; + + endpoint = `boards/${id}/members/${idMember}`; + + qs.type = this.getNodeParameter('type', i) as string; + qs.allowBillableGuest = this.getNodeParameter( + 'additionalFields.allowBillableGuest', + i, + false, + ) as boolean; + } else if (operation === 'invite') { + // ---------------------------------- + // invite + // ---------------------------------- + + requestMethod = 'PUT'; + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `boards/${id}/members`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + + qs.email = this.getNodeParameter('email', i) as string; + qs.type = additionalFields.type as string; + body.fullName = additionalFields.fullName as string; + } else if (operation === 'remove') { + // ---------------------------------- + // remove + // ---------------------------------- + + requestMethod = 'DELETE'; + + const id = this.getNodeParameter('id', i) as string; + const idMember = this.getNodeParameter('idMember', i) as string; + + endpoint = `boards/${id}/members/${idMember}`; + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else if (resource === 'card') { + if (operation === 'create') { + // ---------------------------------- + // create + // ---------------------------------- + + requestMethod = 'POST'; + endpoint = 'cards'; + + qs.idList = this.getNodeParameter('listId', i) as string; + + qs.name = this.getNodeParameter('name', i) as string; + qs.desc = this.getNodeParameter('description', i) as string; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + let id: string; + + if (version === 2) { + id = this.getNodeParameter('cardIdRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + id = this.getNodeParameter('id', i) as string; + } + + endpoint = `cards/${id}`; + } else if (operation === 'get') { + // ---------------------------------- + // get + // ---------------------------------- + + requestMethod = 'GET'; + + let id: string; + + if (version === 2) { + id = this.getNodeParameter('cardIdRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + id = this.getNodeParameter('id', i) as string; + } + + endpoint = `cards/${id}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'update') { + // ---------------------------------- + // update + // ---------------------------------- + + requestMethod = 'PUT'; + + let id: string; + + if (version === 2) { + id = this.getNodeParameter('cardIdRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + id = this.getNodeParameter('id', i) as string; + } + + endpoint = `cards/${id}`; + + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + Object.assign(qs, updateFields); + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else if (resource === 'cardComment') { + if (operation === 'create') { + // ---------------------------------- + // create + // ---------------------------------- + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdCommentRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + qs.text = this.getNodeParameter('text', i) as string; + + requestMethod = 'POST'; + + endpoint = `cards/${cardId}/actions/comments`; + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdCommentRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const commentId = this.getNodeParameter('commentId', i) as string; + + endpoint = `/cards/${cardId}/actions/${commentId}/comments`; + } else if (operation === 'update') { + // ---------------------------------- + // update + // ---------------------------------- + + requestMethod = 'PUT'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdCommentRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const commentId = this.getNodeParameter('commentId', i) as string; + + qs.text = this.getNodeParameter('text', i) as string; + + endpoint = `cards/${cardId}/actions/${commentId}/comments`; + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else if (resource === 'list') { + if (operation === 'archive') { + // ---------------------------------- + // archive + // ---------------------------------- + + requestMethod = 'PUT'; + + const id = this.getNodeParameter('id', i) as string; + qs.value = this.getNodeParameter('archive', i) as boolean; + + endpoint = `lists/${id}/closed`; + } else if (operation === 'create') { + // ---------------------------------- + // create + // ---------------------------------- + + requestMethod = 'POST'; + endpoint = 'lists'; + + qs.idBoard = this.getNodeParameter('idBoard', i) as string; + + qs.name = this.getNodeParameter('name', i) as string; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'get') { + // ---------------------------------- + // get + // ---------------------------------- + + requestMethod = 'GET'; + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `lists/${id}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'getAll') { + // ---------------------------------- + // getAll + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `boards/${id}/lists`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'getCards') { + // ---------------------------------- + // getCards + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `lists/${id}/cards`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'update') { + // ---------------------------------- + // update + // ---------------------------------- + + requestMethod = 'PUT'; + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `lists/${id}`; + + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + Object.assign(qs, updateFields); + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else if (resource === 'attachment') { + if (operation === 'create') { + // ---------------------------------- + // create + // ---------------------------------- + + requestMethod = 'POST'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdAttachmentRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const url = this.getNodeParameter('url', i) as string; + + Object.assign(qs, { + url, + }); + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + + endpoint = `cards/${cardId}/attachments`; + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdAttachmentRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `cards/${cardId}/attachments/${id}`; + } else if (operation === 'get') { + // ---------------------------------- + // get + // ---------------------------------- + + requestMethod = 'GET'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdAttachmentRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `cards/${cardId}/attachments/${id}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'getAll') { + // ---------------------------------- + // getAll + // ---------------------------------- + + requestMethod = 'GET'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdAttachmentRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + endpoint = `cards/${cardId}/attachments`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else if (resource === 'checklist') { + if (operation === 'create') { + // ---------------------------------- + // create + // ---------------------------------- + + requestMethod = 'POST'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdChecklistRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const name = this.getNodeParameter('name', i) as string; + + Object.assign(qs, { name }); + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + + endpoint = `cards/${cardId}/checklists`; + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdChecklistRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `cards/${cardId}/checklists/${id}`; + } else if (operation === 'get') { + // ---------------------------------- + // get + // ---------------------------------- + + requestMethod = 'GET'; + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `checklists/${id}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'getAll') { + // ---------------------------------- + // getAll + // ---------------------------------- + + requestMethod = 'GET'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdChecklistRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + endpoint = `cards/${cardId}/checklists`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'getCheckItem') { + // ---------------------------------- + // getCheckItem + // ---------------------------------- + + requestMethod = 'GET'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdChecklistRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + + const checkItemId = this.getNodeParameter('checkItemId', i) as string; + + endpoint = `cards/${cardId}/checkItem/${checkItemId}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'createCheckItem') { + // ---------------------------------- + // createCheckItem + // ---------------------------------- + + requestMethod = 'POST'; + + const checklistId = this.getNodeParameter('checklistId', i) as string; + + endpoint = `checklists/${checklistId}/checkItems`; + + const name = this.getNodeParameter('name', i) as string; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, { name, ...additionalFields }); + } else if (operation === 'deleteCheckItem') { + // ---------------------------------- + // deleteCheckItem + // ---------------------------------- + + requestMethod = 'DELETE'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdChecklistRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const checkItemId = this.getNodeParameter('checkItemId', i) as string; + + endpoint = `cards/${cardId}/checkItem/${checkItemId}`; + } else if (operation === 'updateCheckItem') { + // ---------------------------------- + // updateCheckItem + // ---------------------------------- + + requestMethod = 'PUT'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdChecklistRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + + const checkItemId = this.getNodeParameter('checkItemId', i) as string; + + endpoint = `cards/${cardId}/checkItem/${checkItemId}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'completedCheckItems') { + // ---------------------------------- + // completedCheckItems + // ---------------------------------- + + requestMethod = 'GET'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdChecklistRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + endpoint = `cards/${cardId}/checkItemStates`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else if (resource === 'label') { + if (operation === 'create') { + // ---------------------------------- + // create + // ---------------------------------- + + requestMethod = 'POST'; + + let idBoard: string; + if (version === 2) { + idBoard = this.getNodeParameter('boardIdLabelRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + idBoard = this.getNodeParameter('boardId', i) as string; + } + + const name = this.getNodeParameter('name', i) as string; + const color = this.getNodeParameter('color', i) as string; + + Object.assign(qs, { + idBoard, + name, + color, + }); + + endpoint = 'labels'; + } else if (operation === 'delete') { + // ---------------------------------- + // delete + // ---------------------------------- + + requestMethod = 'DELETE'; + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `labels/${id}`; + } else if (operation === 'get') { + // ---------------------------------- + // get + // ---------------------------------- + + requestMethod = 'GET'; + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `labels/${id}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'getAll') { + // ---------------------------------- + // getAll + // ---------------------------------- + + requestMethod = 'GET'; + + let idBoard: string; + if (version === 2) { + idBoard = this.getNodeParameter('boardIdLabelRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + idBoard = this.getNodeParameter('boardId', i) as string; + } + + endpoint = `board/${idBoard}/labels`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + + Object.assign(qs, additionalFields); + } else if (operation === 'update') { + // ---------------------------------- + // update + // ---------------------------------- + + requestMethod = 'PUT'; + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `labels/${id}`; + + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + Object.assign(qs, updateFields); + } else if (operation === 'addLabel') { + // ---------------------------------- + // addLabel + // ---------------------------------- + + requestMethod = 'POST'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdLabelRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const id = this.getNodeParameter('id', i) as string; + + qs.value = id; + + endpoint = `/cards/${cardId}/idLabels`; + } else if (operation === 'removeLabel') { + // ---------------------------------- + // removeLabel + // ---------------------------------- + + requestMethod = 'DELETE'; + + let cardId: string; + if (version === 2) { + cardId = this.getNodeParameter('cardIdLabelRLC', i, undefined, { + extractValue: true, + }) as string; + } else { + cardId = this.getNodeParameter('cardId', i) as string; + } + + const id = this.getNodeParameter('id', i) as string; + + endpoint = `/cards/${cardId}/idLabels/${id}`; + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); + } + } else { + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); + } + + // resources listed here do not support pagination so + // paginate them 'manually' + const skipPagination = ['list:getAll']; + + if (returnAll === true && !skipPagination.includes(`${resource}:${operation}`)) { + responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs); + } else { + responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); + if (returnAll === false && qs.limit) { + responseData = responseData.splice(0, qs.limit); + } + } + + const executionData = this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(responseData), + { itemData: { item: i } }, + ); + returnData.push(...executionData); + } catch (error) { + if (this.continueOnFail()) { + const executionData = this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray({ error: error.message }), + { itemData: { item: i } }, + ); + returnData.push(...executionData); + continue; + } + throw error; + } + } + + return this.prepareOutputData(returnData); } } diff --git a/packages/nodes-base/nodes/Trello/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Trello/v1/GenericFunctions.ts deleted file mode 100644 index daee29cb49082..0000000000000 --- a/packages/nodes-base/nodes/Trello/v1/GenericFunctions.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; - -import { - OptionsWithUri, -} from 'request'; - -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; - -/** - * Make an API request to Trello - * - * @param {IHookFunctions} this - * @param {string} method - * @param {string} url - * @param {object} body - * @returns {Promise} - */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise { // tslint:disable-line:no-any - query = query || {}; - - const options: OptionsWithUri = { - method, - body, - qs: query, - uri: `https://api.trello.com/1/${endpoint}`, - json: true, - }; - - try { - return await this.helpers.requestWithAuthentication.call(this, 'trelloApi', options); - } catch(error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } -} - -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - - query.limit = 30; - - query.sort = '-id'; - - const returnData: IDataObject[] = []; - - let responseData; - - do { - responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData); - if (responseData.length !== 0) { - query.before = responseData[responseData.length - 1].id; - } - } while ( - query.limit <= responseData.length - ); - - return returnData; -} diff --git a/packages/nodes-base/nodes/Trello/v1/TrelloV1.node.ts b/packages/nodes-base/nodes/Trello/v1/TrelloV1.node.ts deleted file mode 100644 index 69f46cddf8a0d..0000000000000 --- a/packages/nodes-base/nodes/Trello/v1/TrelloV1.node.ts +++ /dev/null @@ -1,706 +0,0 @@ -import { IExecuteFunctions } from 'n8n-core'; - -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeBaseDescription, - INodeTypeDescription, - NodeOperationError, -} from 'n8n-workflow'; - -import { apiRequest, apiRequestAllItems } from '../GenericFunctions'; - -import { versionDescription } from './VersionDescription'; - -export class TrelloV1 implements INodeType { - description: INodeTypeDescription; - - constructor(baseDescription: INodeTypeBaseDescription) { - this.description = { - ...baseDescription, - ...versionDescription, - }; - } - - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); - const returnData: INodeExecutionData[] = []; - - const operation = this.getNodeParameter('operation', 0) as string; - const resource = this.getNodeParameter('resource', 0) as string; - - // For Post - let body: IDataObject; - // For Query string - let qs: IDataObject; - - let requestMethod: string; - let endpoint: string; - let returnAll = false; - let responseData; - - for (let i = 0; i < items.length; i++) { - try { - requestMethod = 'GET'; - endpoint = ''; - body = {}; - qs = {}; - - if (resource === 'board') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - endpoint = 'boards'; - - qs.name = this.getNodeParameter('name', i) as string; - qs.desc = this.getNodeParameter('description', i) as string; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `boards/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `boards/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `boards/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'boardMember') { - if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - returnAll = this.getNodeParameter('returnAll', i) as boolean; - if (returnAll === false) { - qs.limit = this.getNodeParameter('limit', i) as number; - } - - endpoint = `boards/${id}/members`; - } else if (operation === 'add') { - // ---------------------------------- - // add - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - const idMember = this.getNodeParameter('idMember', i) as string; - - endpoint = `boards/${id}/members/${idMember}`; - - qs.type = this.getNodeParameter('type', i) as string; - qs.allowBillableGuest = this.getNodeParameter( - 'additionalFields.allowBillableGuest', - i, - false, - ) as boolean; - } else if (operation === 'invite') { - // ---------------------------------- - // invite - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `boards/${id}/members`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - - qs.email = this.getNodeParameter('email', i) as string; - qs.type = additionalFields.type as string; - body.fullName = additionalFields.fullName as string; - } else if (operation === 'remove') { - // ---------------------------------- - // remove - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('id', i) as string; - const idMember = this.getNodeParameter('idMember', i) as string; - - endpoint = `boards/${id}/members/${idMember}`; - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'card') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - endpoint = 'cards'; - - qs.idList = this.getNodeParameter('listId', i) as string; - - qs.name = this.getNodeParameter('name', i) as string; - qs.desc = this.getNodeParameter('description', i) as string; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'cardComment') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - const cardId = this.getNodeParameter('cardId', i) as string; - - qs.text = this.getNodeParameter('text', i) as string; - - requestMethod = 'POST'; - - endpoint = `cards/${cardId}/actions/comments`; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - const commentId = this.getNodeParameter('commentId', i) as string; - - endpoint = `/cards/${cardId}/actions/${commentId}/comments`; - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - const commentId = this.getNodeParameter('commentId', i) as string; - - qs.text = this.getNodeParameter('text', i) as string; - - endpoint = `cards/${cardId}/actions/${commentId}/comments`; - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'list') { - if (operation === 'archive') { - // ---------------------------------- - // archive - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - qs.value = this.getNodeParameter('archive', i) as boolean; - - endpoint = `lists/${id}/closed`; - } else if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - endpoint = 'lists'; - - qs.idBoard = this.getNodeParameter('idBoard', i) as string; - - qs.name = this.getNodeParameter('name', i) as string; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `lists/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - returnAll = this.getNodeParameter('returnAll', i) as boolean; - - if (returnAll === false) { - qs.limit = this.getNodeParameter('limit', i) as number; - } - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `boards/${id}/lists`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getCards') { - // ---------------------------------- - // getCards - // ---------------------------------- - - requestMethod = 'GET'; - - returnAll = this.getNodeParameter('returnAll', i) as boolean; - - if (returnAll === false) { - qs.limit = this.getNodeParameter('limit', i) as number; - } - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `lists/${id}/cards`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `lists/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'attachment') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const url = this.getNodeParameter('url', i) as string; - - Object.assign(qs, { - url, - }); - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - - endpoint = `cards/${cardId}/attachments`; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${cardId}/attachments/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${cardId}/attachments/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - endpoint = `cards/${cardId}/attachments`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'checklist') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const name = this.getNodeParameter('name', i) as string; - - Object.assign(qs, { name }); - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - - endpoint = `cards/${cardId}/checklists`; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${cardId}/checklists/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `checklists/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - endpoint = `cards/${cardId}/checklists`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getCheckItem') { - // ---------------------------------- - // getCheckItem - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const checkItemId = this.getNodeParameter('checkItemId', i) as string; - - endpoint = `cards/${cardId}/checkItem/${checkItemId}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'createCheckItem') { - // ---------------------------------- - // createCheckItem - // ---------------------------------- - - requestMethod = 'POST'; - - const checklistId = this.getNodeParameter('checklistId', i) as string; - - endpoint = `checklists/${checklistId}/checkItems`; - - const name = this.getNodeParameter('name', i) as string; - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, { name, ...additionalFields }); - } else if (operation === 'deleteCheckItem') { - // ---------------------------------- - // deleteCheckItem - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const checkItemId = this.getNodeParameter('checkItemId', i) as string; - - endpoint = `cards/${cardId}/checkItem/${checkItemId}`; - } else if (operation === 'updateCheckItem') { - // ---------------------------------- - // updateCheckItem - // ---------------------------------- - - requestMethod = 'PUT'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const checkItemId = this.getNodeParameter('checkItemId', i) as string; - - endpoint = `cards/${cardId}/checkItem/${checkItemId}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'completedCheckItems') { - // ---------------------------------- - // completedCheckItems - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - endpoint = `cards/${cardId}/checkItemStates`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'label') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - - const idBoard = this.getNodeParameter('boardId', i) as string; - const name = this.getNodeParameter('name', i) as string; - const color = this.getNodeParameter('color', i) as string; - - Object.assign(qs, { - idBoard, - name, - color, - }); - - endpoint = 'labels'; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `labels/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `labels/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const idBoard = this.getNodeParameter('boardId', i) as string; - - endpoint = `board/${idBoard}/labels`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `labels/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else if (operation === 'addLabel') { - // ---------------------------------- - // addLabel - // ---------------------------------- - - requestMethod = 'POST'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - qs.value = id; - - endpoint = `/cards/${cardId}/idLabels`; - } else if (operation === 'removeLabel') { - // ---------------------------------- - // removeLabel - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `/cards/${cardId}/idLabels/${id}`; - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { - itemIndex: i, - }); - } - - // resources listed here do not support pagination so - // paginate them 'manually' - const skipPagination = ['list:getAll']; - - if (returnAll === true && !skipPagination.includes(`${resource}:${operation}`)) { - responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs); - } else { - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - if (returnAll === false && qs.limit) { - responseData = responseData.splice(0, qs.limit); - } - } - - const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), - { itemData: { item: i } }, - ); - returnData.push(...executionData); - } catch (error) { - if (this.continueOnFail()) { - const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray({ error: error.message }), - { itemData: { item: i } }, - ); - returnData.push(...executionData); - continue; - } - throw error; - } - } - - return this.prepareOutputData(returnData); - } -} diff --git a/packages/nodes-base/nodes/Trello/v1/VersionDescription.ts b/packages/nodes-base/nodes/Trello/v1/VersionDescription.ts deleted file mode 100644 index 3e00901e75a8c..0000000000000 --- a/packages/nodes-base/nodes/Trello/v1/VersionDescription.ts +++ /dev/null @@ -1,133 +0,0 @@ -/* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import type { - INodeTypeDescription -} from 'n8n-workflow'; - -import { - attachmentFields, - attachmentOperations, -} from './AttachmentDescription'; - -import { - boardFields, - boardOperations, -} from './BoardDescription'; - -import { - boardMemberFields, - boardMemberOperations, -} from './BoardMemberDescription'; - -import { - cardFields, - cardOperations, -} from './CardDescription'; - -import { - cardCommentFields, - cardCommentOperations, -} from './CardCommentDescription'; - -import { - checklistFields, - checklistOperations, -} from './ChecklistDescription'; - -import { - labelFields, - labelOperations, -} from './LabelDescription'; - -import { - listFields, - listOperations, -} from './ListDescription'; - -export const versionDescription: INodeTypeDescription = { - displayName: 'Trello', - name: 'trello', - icon: 'file:trello.svg', - group: ['transform'], - version: 1, - subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Create, change and delete boards and cards', - defaults: { - name: 'Trello', - }, - inputs: ['main'], - outputs: ['main'], - credentials: [ - { - name: 'trelloApi', - required: true, - }, - ], - properties: [ - { - displayName: 'Resource', - name: 'resource', - type: 'options', - noDataExpression: true, - options: [ - { - name: 'Attachment', - value: 'attachment', - }, - { - name: 'Board', - value: 'board', - }, - { - name: 'Board Member', - value: 'boardMember', - }, - { - name: 'Card', - value: 'card', - }, - { - name: 'Card Comment', - value: 'cardComment', - }, - { - name: 'Checklist', - value: 'checklist', - }, - { - name: 'Label', - value: 'label', - }, - { - name: 'List', - value: 'list', - }, - ], - default: 'card', - }, - - // ---------------------------------- - // operations - // ---------------------------------- - ...attachmentOperations, - ...boardOperations, - ...boardMemberOperations, - ...cardOperations, - ...cardCommentOperations, - ...checklistOperations, - ...labelOperations, - ...listOperations, - - // ---------------------------------- - // fields - // ---------------------------------- - ...attachmentFields, - ...boardFields, - ...boardMemberFields, - ...cardFields, - ...cardCommentFields, - ...checklistFields, - ...labelFields, - ...listFields, - - ], -}; diff --git a/packages/nodes-base/nodes/Trello/v2/AttachmentDescription.ts b/packages/nodes-base/nodes/Trello/v2/AttachmentDescription.ts deleted file mode 100644 index 08b6d36cea5d8..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/AttachmentDescription.ts +++ /dev/null @@ -1,282 +0,0 @@ -import { - INodeProperties, -} from 'n8n-workflow'; - -export const attachmentOperations: INodeProperties[] = [ - // ---------------------------------- - // attachment - // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'attachment', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a new attachment for a card', - action: 'Create an attachment', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete an attachment', - action: 'Delete an attachment', - }, - { - name: 'Get', - value: 'get', - description: 'Get the data of an attachment', - action: 'Get an attachment', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Returns all attachments for the card', - action: 'Get all attachments', - }, - ], - default: 'getAll', - }, - -]; - -export const attachmentFields: INodeProperties[] = [ - - // ---------------------------------- - // attachment:create - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'attachment', - ], - }, - }, - description: 'The ID of the card to add attachment to', - }, - { - displayName: 'Source URL', - name: 'url', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'attachment', - ], - }, - }, - description: 'The URL of the attachment to add', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'attachment', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'MIME Type', - name: 'mimeType', - type: 'string', - default: '', - placeholder: 'image/png', - description: 'The MIME type of the attachment to add', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The name of the attachment to add', - }, - ], - }, - - // ---------------------------------- - // attachment:delete - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'attachment', - ], - }, - }, - description: 'The ID of the card that attachment belongs to', - }, - { - displayName: 'Attachment ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'attachment', - ], - }, - }, - description: 'The ID of the attachment to delete', - }, - - // ---------------------------------- - // attachment:getAll - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'attachment', - ], - }, - }, - description: 'The ID of the card to get attachments', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'attachment', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // attachment:get - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'attachment', - ], - }, - }, - description: 'The ID of the card to get attachment', - }, - { - displayName: 'Attachment ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'attachment', - ], - }, - }, - description: 'The ID of the attachment to get', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'attachment', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - -]; diff --git a/packages/nodes-base/nodes/Trello/v2/BoardDescription.ts b/packages/nodes-base/nodes/Trello/v2/BoardDescription.ts deleted file mode 100644 index 91feabcae32cb..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/BoardDescription.ts +++ /dev/null @@ -1,595 +0,0 @@ -import { - IExecuteSingleFunctions, - INodeProperties, -} from 'n8n-workflow'; - -export const boardOperations: INodeProperties[] = [ - // ---------------------------------- - // board - // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'board', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a new board', - action: 'Create a board', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a board', - action: 'Delete a board', - }, - { - name: 'Get', - value: 'get', - description: 'Get the data of a board', - action: 'Get a board', - }, - { - name: 'Update', - value: 'update', - description: 'Update a board', - action: 'Update a board', - }, - ], - default: 'create', - }, -]; - -export const boardFields: INodeProperties[] = [ - - // ---------------------------------- - // board:create - // ---------------------------------- - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - placeholder: 'My board', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], - }, - }, - description: 'The name of the board', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], - }, - }, - description: 'The description of the board', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Aging', - name: 'prefs_cardAging', - type: 'options', - options: [ - { - name: 'Pirate', - value: 'pirate', - }, - { - name: 'Regular', - value: 'regular', - }, - ], - default: 'regular', - description: 'Determines the type of card aging that should take place on the board if card aging is enabled', - }, - { - displayName: 'Background', - name: 'prefs_background', - type: 'string', - default: 'blue', - description: 'The ID of a custom background or one of: blue, orange, green, red, purple, pink, lime, sky, grey', - }, - { - displayName: 'Comments', - name: 'prefs_comments', - type: 'options', - options: [ - { - name: 'Disabled', - value: 'disabled', - }, - { - name: 'Members', - value: 'members', - }, - { - name: 'Observers', - value: 'observers', - }, - { - name: 'Organization', - value: 'org', - }, - { - name: 'Public', - value: 'public', - }, - ], - default: 'members', - description: 'Who can comment on cards on this board', - }, - { - displayName: 'Covers', - name: 'prefs_cardCovers', - type: 'boolean', - default: true, - description: 'Whether card covers are enabled', - }, - { - displayName: 'Invitations', - name: 'prefs_invitations', - type: 'options', - options: [ - { - name: 'Admins', - value: 'admins', - }, - { - name: 'Members', - value: 'members', - }, - ], - default: 'members', - description: 'Determines what types of members can invite users to join', - }, - { - displayName: 'Keep From Source', - name: 'keepFromSource', - type: 'string', - default: 'none', - description: 'To keep cards from the original board pass in the value cards', - }, - { - displayName: 'Labels', - name: 'defaultLabels', - type: 'boolean', - default: true, - description: 'Whether to use the default set of labels', - }, - { - displayName: 'Lists', - name: 'defaultLists', - type: 'boolean', - default: true, - description: 'Whether to add the default set of lists to a board(To Do, Doing, Done).It is ignored if idBoardSource is provided', - }, - { - displayName: 'Organization ID', - name: 'idOrganization', - type: 'string', - default: '', - description: 'The ID or name of the team the board should belong to', - }, - { - displayName: 'Permission Level', - name: 'prefs_permissionLevel', - type: 'options', - options: [ - { - name: 'Organization', - value: 'org', - }, - { - name: 'Private', - value: 'private', - }, - { - name: 'Public', - value: 'public', - }, - ], - default: 'private', - description: 'The permissions level of the board', - }, - { - displayName: 'Power Ups', - name: 'powerUps', - type: 'options', - options: [ - { - name: 'All', - value: 'all', - }, - { - name: 'Calendar', - value: 'calendar', - }, - { - name: 'Card Aging', - value: 'cardAging', - }, - { - name: 'Recap', - value: 'recap', - }, - { - name: 'Voting', - value: 'voting', - }, - ], - default: 'all', - description: 'The Power-Ups that should be enabled on the new board', - }, - { - displayName: 'Self Join', - name: 'prefs_selfJoin', - type: 'boolean', - default: true, - description: 'Whether users can join the boards themselves or whether they have to be invited', - }, - { - displayName: 'Source IDs', - name: 'idBoardSource', - type: 'string', - default: '', - description: 'The ID of a board to copy into the new board', - }, - { - displayName: 'Voting', - name: 'prefs_voting', - type: 'options', - options: [ - { - name: 'Disabled', - value: 'disabled', - }, - { - name: 'Members', - value: 'members', - }, - { - name: 'Observers', - value: 'observers', - }, - { - name: 'Organization', - value: 'org', - }, - { - name: 'Public', - value: 'public', - }, - ], - default: 'disabled', - description: 'Who can vote on this board', - }, - ], - }, - - { - displayName: 'Board', - name: 'boardId', - type: 'resourceLocator', - default: { mode: 'list', value: '' }, - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'board', - ], - }, - }, - description: 'The ID of the board', - modes: [ - // TODO: This rule should only apply for direct node properties, not their children - // eslint-disable-next-line n8n-nodes-base/node-param-default-missing - { - displayName: "From List", - name: "list", - type: "list", - hint: "Select a board from the list", - placeholder: "Choose...", - initType: "board", - entryTypes: { - board: { - selectable: true, - queryable: true, - data: { - request: { - baseURL: "https://api.trello.com/1", - url: "/members/me/boards", - method: "GET", - }, - }, - }, - }, - search: { - send: { - paginate: true, - }, - request: { - baseURL: "https://api.trello.com/1", - url: "/search", - qs: { - query: "={{$value}}", // TODO: See what goes here - modelTypes: "=boards", // Search only boards - idBoards: "=mine", // That belong to current user - }, - }, - }, - }, - // eslint-disable-next-line n8n-nodes-base/node-param-default-missing - { - displayName: 'ID', - name: 'id', - type: 'string', - hint: 'Enter Board Id', - validation: [ - { - type: 'regex', - properties: { - regex: '[a-zA-Z0-9]+', - errorMessage: 'ID value cannot be empty', - }, - }, - ], - placeholder: '45g950pa5n24054o43t453fe5', - url: '=https://api.trello.com/1/boards/{{$value}}', - }, - // eslint-disable-next-line n8n-nodes-base/node-param-default-missing - { - displayName: 'By URL', - name: 'url', - type: 'string', - hint: 'Enter board URL', - placeholder: 'https://trello.com/b/e123456/board-name', - validation: [ - { - type: 'regex', - properties: { - regex: 'http(s)?:\/\/trello.com\/b\/([a-zA-Z0-9]+)/[a-zA-Z0-9]+', - errorMessage: 'URL has to be in the format: http(s)://trello.com/b//', - }, - }, - ], - extractValue: { - type: 'regex', - regex: 'https:\/\/trello\.com\/b\/([a-zA-Z0-9]+)', - }, - }, - ], - }, - - { - displayName: 'Board', - name: 'boardIdDelete', - type: 'resourceLocator', - default: { mode: 'id', value: '' }, - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'board', - ], - }, - }, - description: 'The ID of the board', - modes: [ - // TODO: This rule should only apply for direct node properties, not their children - // eslint-disable-next-line n8n-nodes-base/node-param-default-missing - { - displayName: 'ID', - name: 'id', - type: 'string', - hint: 'Enter Board Id', - validation: [ - { - type: 'regex', - properties: { - regex: '[a-zA-Z0-9]+', - errorMessage: 'ID value cannot be empty', - }, - }, - ], - placeholder: '45g950pa5n24054o43t453fe5', - url: '=https://api.trello.com/1/boards/{{$value}}', - }, - ], - }, - - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'board', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list: closed, dateLastActivity, dateLastView, desc, descData, idOrganization, invitations, invited, labelNames, memberships, name, pinned, powerUps, prefs, shortLink, shortUrl, starred, subscribed, URL.', - }, - { - displayName: 'Plugin Data', - name: 'pluginData', - type: 'boolean', - default: false, - description: 'Whether to include pluginData on the card with the response', - }, - ], - }, - - // ---------------------------------- - // board:update - // ---------------------------------- - { - displayName: 'Board ID', - name: 'boardIdUpdate', - type: 'resourceLocator', - default: { mode: 'list', value: '' }, - required: true, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'board', - ], - }, - }, - description: 'The ID of the board to update', - modes: [ - // eslint-disable-next-line n8n-nodes-base/node-param-default-missing - { - displayName: "From List", - name: "list", - type: "list", - hint: "Select a board from the list", - placeholder: "Choose...", - initType: "board", - entryTypes: { - board: { - selectable: true, - queryable: true, - data: { - request: { - baseURL: "https://api.trello.com/1", - url: "/members/me/boards", - method: "GET", - }, - }, - }, - }, - search: { - send: { - paginate: true, - }, - request: { - baseURL: "https://api.trello.com/1", - url: "/search", - qs: { - query: "={{$value}}", // TODO: See what goes here - modelTypes: "=boards", // Search only boards - idBoards: "=mine", // That belong to current user - }, - }, - }, - }, - ], - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'board', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Closed', - name: 'closed', - type: 'boolean', - default: false, - description: 'Whether the board is closed', - }, - { - displayName: 'Description', - name: 'desc', - type: 'string', - default: '', - description: 'New description of the board', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'New name of the board', - }, - { - displayName: 'Organization ID', - name: 'idOrganization', - type: 'string', - default: '', - description: 'The ID of the team the board should be moved to', - }, - { - displayName: 'Subscribed', - name: 'subscribed', - type: 'boolean', - default: false, - description: 'Whether the acting user is subscribed to the board', - }, - ], - }, -]; diff --git a/packages/nodes-base/nodes/Trello/v2/BoardMemberDescription.ts b/packages/nodes-base/nodes/Trello/v2/BoardMemberDescription.ts deleted file mode 100644 index 54a720b2d349b..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/BoardMemberDescription.ts +++ /dev/null @@ -1,345 +0,0 @@ -import { - INodeProperties, -} from 'n8n-workflow'; - -export const boardMemberOperations: INodeProperties[] = [ - // ---------------------------------- - // boardMember - // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'boardMember', - ], - }, - }, - options: [ - { - name: 'Add', - value: 'add', - description: 'Add member to board using member ID', - action: 'Add a board member', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get all members of a board', - action: 'Get all board members', - }, - { - name: 'Invite', - value: 'invite', - description: 'Invite a new member to a board via email', - action: 'Invite a board member', - }, - { - name: 'Remove', - value: 'remove', - description: 'Remove member from board using member ID', - action: 'Remove a board member', - }, - ], - default: 'add', - }, -]; - -export const boardMemberFields: INodeProperties[] = [ - // ---------------------------------- - // boardMember:getAll - // ---------------------------------- - { - displayName: 'Board ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'boardMember', - ], - }, - }, - description: 'The ID of the board to get members from', - }, - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'boardMember', - ], - }, - }, - default: false, - description: 'Whether to return all results or only up to a given limit', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - typeOptions: { - minValue: 1, - }, - description: 'Max number of results to return', - default: 20, - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'boardMember', - ], - returnAll: [ - false, - ], - }, - }, - }, - - // ---------------------------------- - // boardMember:add - // ---------------------------------- - { - displayName: 'Board ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], - }, - }, - description: 'The ID of the board to add member to', - }, - { - displayName: 'Member ID', - name: 'idMember', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], - }, - }, - description: 'The ID of the member to add to the board', - }, - { - displayName: 'Type', - name: 'type', - type: 'options', - required: true, - default: 'normal', - displayOptions: { - show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], - }, - }, - options: [ - { - name: 'Normal', - value: 'normal', - description: 'Invite as normal member', - }, - { - name: 'Admin', - value: 'admin', - description: 'Invite as admin', - }, - { - name: 'Observer', - value: 'observer', - description: 'Invite as observer (Trello premium feature)', - }, - ], - description: 'Determines the type of membership the user being added should have', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - default: {}, - displayOptions: { - show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], - }, - }, - options: [ - { - displayName: 'Allow Billable Guest', - name: 'allowBillableGuest', - type: 'boolean', - default: false, - description: 'Whether to allow organization admins to add multi-board guests onto a board', - }, - ], - }, - - // ---------------------------------- - // boardMember:invite - // ---------------------------------- - { - displayName: 'Board ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'invite', - ], - resource: [ - 'boardMember', - ], - }, - }, - description: 'The ID of the board to invite member to', - }, - { - displayName: 'Email', - name: 'email', - type: 'string', - placeholder: 'name@email.com', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'invite', - ], - resource: [ - 'boardMember', - ], - }, - }, - description: 'The ID of the board to update', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'invite', - ], - resource: [ - 'boardMember', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Type', - name: 'type', - type: 'options', - default: 'normal', - options: [ - { - name: 'Normal', - value: 'normal', - description: 'Invite as normal member', - }, - { - name: 'Admin', - value: 'admin', - description: 'Invite as admin', - }, - { - name: 'Observer', - value: 'observer', - description: 'Invite as observer (Trello premium feature)', - }, - ], - description: 'Determines the type of membership the user being added should have', - }, - { - displayName: 'Full Name', - name: 'fullName', - type: 'string', - default: '', - description: 'The full name of the user to add as a member of the board. Must have a length of at least 1 and cannot begin nor end with a space.', - }, - ], - }, - - // ---------------------------------- - // boardMember:remove - // ---------------------------------- - { - displayName: 'Board ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'remove', - ], - resource: [ - 'boardMember', - ], - }, - }, - description: 'The ID of the board to remove member from', - }, - { - displayName: 'Member ID', - name: 'idMember', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'remove', - ], - resource: [ - 'boardMember', - ], - }, - }, - description: 'The ID of the member to remove from the board', - }, -]; diff --git a/packages/nodes-base/nodes/Trello/v2/CardCommentDescription.ts b/packages/nodes-base/nodes/Trello/v2/CardCommentDescription.ts deleted file mode 100644 index 5a482232e605f..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/CardCommentDescription.ts +++ /dev/null @@ -1,180 +0,0 @@ -import { - INodeProperties, -} from 'n8n-workflow'; - -export const cardCommentOperations: INodeProperties[] = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'cardComment', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a comment on a card', - action: 'Create a card comment', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a comment from a card', - action: 'Delete a card comment', - }, - { - name: 'Update', - value: 'update', - description: 'Update a comment on a card', - action: 'Update a card comment', - }, - ], - default: 'create', - }, -]; - -export const cardCommentFields: INodeProperties[] = [ - // ---------------------------------- - // cardComment:create - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], - }, - }, - description: 'The ID of the card', - }, - { - displayName: 'Text', - name: 'text', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], - }, - }, - description: 'Text of the comment', - }, - - // ---------------------------------- - // cardComment:remove - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], - }, - }, - description: 'The ID of the card', - }, - { - displayName: 'Comment ID', - name: 'commentId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], - }, - }, - description: 'The ID of the comment to delete', - }, - - // ---------------------------------- - // cardComment:update - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'cardComment', - ], - }, - }, - description: 'The ID of the card to update', - }, - { - displayName: 'Comment ID', - name: 'commentId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'cardComment', - ], - }, - }, - description: 'The ID of the comment to delete', - }, - { - displayName: 'Text', - name: 'text', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'cardComment', - ], - }, - }, - description: 'Text of the comment', - }, -]; diff --git a/packages/nodes-base/nodes/Trello/v2/CardDescription.ts b/packages/nodes-base/nodes/Trello/v2/CardDescription.ts deleted file mode 100644 index 2caec8ca28337..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/CardDescription.ts +++ /dev/null @@ -1,437 +0,0 @@ -import { - INodeProperties, -} from 'n8n-workflow'; - -export const cardOperations: INodeProperties[] = [ - // ---------------------------------- - // card - // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'card', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a new card', - action: 'Create a card', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a card', - action: 'Delete a card', - }, - { - name: 'Get', - value: 'get', - description: 'Get the data of a card', - action: 'Get a card', - }, - { - name: 'Update', - value: 'update', - description: 'Update a card', - action: 'Update a card', - }, - ], - default: 'create', - }, -]; - -export const cardFields: INodeProperties[] = [ - // ---------------------------------- - // card:create - // ---------------------------------- - { - displayName: 'List ID', - name: 'listId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], - }, - }, - description: 'The ID of the list to create card in', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - placeholder: 'My card', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], - }, - }, - description: 'The name of the card', - }, - { - displayName: 'Description', - name: 'description', - type: 'string', - default: '', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], - }, - }, - description: 'The description of the card', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Due Date', - name: 'due', - type: 'dateTime', - default: '', - description: 'A due date for the card', - }, - { - displayName: 'Due Complete', - name: 'dueComplete', - type: 'boolean', - default: false, - description: 'Whether the card is completed', - }, - { - displayName: 'Position', - name: 'pos', - type: 'string', - default: 'bottom', - description: 'The position of the new card. top, bottom, or a positive float.', - }, - { - displayName: 'Member IDs', - name: 'idMembers', - type: 'string', - default: '', - description: 'Comma-separated list of member IDs to add to the card', - }, - { - displayName: 'Label IDs', - name: 'idLabels', - type: 'string', - default: '', - description: 'Comma-separated list of label IDs to add to the card', - }, - { - displayName: 'URL Source', - name: 'urlSource', - type: 'string', - default: '', - description: 'A source URL to attach to card', - }, - { - displayName: 'Source ID', - name: 'idCardSource', - type: 'string', - default: '', - description: 'The ID of a card to copy into the new card', - }, - { - displayName: 'Keep From Source', - name: 'keepFromSource', - type: 'string', - default: 'all', - description: 'If using idCardSource you can specify which properties to copy over. all or comma-separated list of: attachments, checklists, comments, due, labels, members, stickers.', - }, - ], - }, - - // ---------------------------------- - // card:delete - // ---------------------------------- - { - displayName: 'Card ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'card', - ], - }, - }, - description: 'The ID of the card to delete', - }, - - // ---------------------------------- - // card:get - // ---------------------------------- - { - displayName: 'Card ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'card', - ], - }, - }, - description: 'The ID of the card to get', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'card', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Fields to return. Either "all" or a comma-separated list: badges, checkItemStates, closed, dateLastActivity, desc, descData, due, email, idBoard, idChecklists, idLabels, idList, idMembers, idShort, idAttachmentCover, manualCoverAttachment, labels, name, pos, shortUrl, url.', - }, - { - displayName: 'Board', - name: 'board', - type: 'boolean', - default: false, - description: 'Whether to return the board object the card is on', - }, - { - displayName: 'Board Fields', - name: 'board_fields', - type: 'string', - default: 'all', - // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Fields to return. Either "all" or a comma-separated list: name, desc, descData, closed, idOrganization, pinned, url, prefs.', - }, - { - displayName: 'Custom Field Items', - name: 'customFieldItems', - type: 'boolean', - default: false, - description: 'Whether to include the customFieldItems', - }, - { - displayName: 'Members', - name: 'members', - type: 'boolean', - default: false, - description: 'Whether to return member objects for members on the card', - }, - { - displayName: 'Member Fields', - name: 'member_fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list: avatarHash, fullName, initials, username.', - }, - { - displayName: 'Plugin Data', - name: 'pluginData', - type: 'boolean', - default: false, - description: 'Whether to include pluginData on the card with the response', - }, - { - displayName: 'Stickers', - name: 'stickers', - type: 'boolean', - default: false, - description: 'Whether to include sticker models with the response', - }, - { - displayName: 'Sticker Fields', - name: 'sticker_fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of sticker fields.', - }, - ], - }, - - // ---------------------------------- - // card:update - // ---------------------------------- - { - displayName: 'Card ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], - }, - }, - description: 'The ID of the card to update', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Attachment Cover', - name: 'idAttachmentCover', - type: 'string', - default: '', - description: 'The ID of the image attachment the card should use as its cover, or null for none', - }, - { - displayName: 'Board ID', - name: 'idBoard', - type: 'string', - default: '', - description: 'The ID of the board the card should be on', - }, - { - displayName: 'Closed', - name: 'closed', - type: 'boolean', - default: false, - description: 'Whether the board is closed', - }, - { - displayName: 'Description', - name: 'desc', - type: 'string', - default: '', - description: 'New description of the board', - }, - { - displayName: 'Due Date', - name: 'due', - type: 'dateTime', - default: '', - description: 'A due date for the card', - }, - { - displayName: 'Due Complete', - name: 'dueComplete', - type: 'boolean', - default: false, - description: 'Whether the card is completed', - }, - { - displayName: 'Label IDs', - name: 'idLabels', - type: 'string', - default: '', - description: 'Comma-separated list of label IDs to set on card', - }, - { - displayName: 'List ID', - name: 'idList', - type: 'string', - default: '', - description: 'The ID of the list the card should be in', - }, - { - displayName: 'Member IDs', - name: 'idMembers', - type: 'string', - default: '', - description: 'Comma-separated list of member IDs to set on card', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'New name of the board', - }, - { - displayName: 'Position', - name: 'pos', - type: 'string', - default: 'bottom', - description: 'The position of the card. top, bottom, or a positive float.', - }, - { - displayName: 'Subscribed', - name: 'subscribed', - type: 'boolean', - default: false, - description: 'Whether the acting user is subscribed to the board', - }, - ], - }, -]; diff --git a/packages/nodes-base/nodes/Trello/v2/ChecklistDescription.ts b/packages/nodes-base/nodes/Trello/v2/ChecklistDescription.ts deleted file mode 100644 index e8a1ace9e5a86..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/ChecklistDescription.ts +++ /dev/null @@ -1,616 +0,0 @@ -import { - INodeProperties, -} from 'n8n-workflow'; - -export const checklistOperations: INodeProperties[] = [ - // ---------------------------------- - // checklist - // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'checklist', - ], - }, - }, - options: [ - { - name: 'Create', - value: 'create', - description: 'Create a new checklist', - action: 'Create a checklist', - }, - { - name: 'Create Checklist Item', - value: 'createCheckItem', - description: 'Create a checklist item', - action: 'Create checklist item', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a checklist', - action: 'Delete a checklist', - }, - { - name: 'Delete Checklist Item', - value: 'deleteCheckItem', - description: 'Delete a checklist item', - action: 'Delete a checklist item', - }, - { - name: 'Get', - value: 'get', - description: 'Get the data of a checklist', - action: 'Get a checklist', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Returns all checklists for the card', - action: 'Get all checklists', - }, - { - name: 'Get Checklist Items', - value: 'getCheckItem', - description: 'Get a specific checklist on a card', - action: 'Get checklist items', - }, - { - name: 'Get Completed Checklist Items', - value: 'completedCheckItems', - description: 'Get the completed checklist items on a card', - action: 'Get completed checklist items', - }, - { - name: 'Update Checklist Item', - value: 'updateCheckItem', - description: 'Update an item in a checklist on a card', - action: 'Update a checklist item', - }, - ], - default: 'getAll', - }, - -]; - -export const checklistFields: INodeProperties[] = [ - // ---------------------------------- - // checklist:create - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the card to add checklist to', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The URL of the checklist to add', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'ID Of Checklist Source', - name: 'idChecklistSource', - type: 'string', - default: '', - description: 'The ID of a source checklist to copy into the new one', - }, - { - displayName: 'Position', - name: 'pos', - type: 'string', - default: '', - description: 'The position of the checklist on the card. One of: top, bottom, or a positive number.', - }, - ], - }, - - // ---------------------------------- - // checklist:delete - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the card that checklist belongs to', - }, - { - displayName: 'Checklist ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the checklist to delete', - }, - - - // ---------------------------------- - // checklist:getAll - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the card to get checklists', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // checklist:get - // ---------------------------------- - { - displayName: 'Checklist ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the checklist to get', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // checklist:createCheckItem - // ---------------------------------- - { - displayName: 'Checklist ID', - name: 'checklistId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'createCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the checklist to update', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'createCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The name of the new check item on the checklist', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'createCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Checked', - name: 'checked', - type: 'boolean', - default: false, - description: 'Whether the check item is already checked when created', - }, - { - displayName: 'Position', - name: 'pos', - type: 'string', - default: '', - description: 'The position of the checklist on the card. One of: top, bottom, or a positive number.', - }, - ], - }, - - // ---------------------------------- - // checklist:deleteCheckItem - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'deleteCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the card that checklist belongs to', - }, - { - displayName: 'CheckItem ID', - name: 'checkItemId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'deleteCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the checklist item to delete', - }, - - // ---------------------------------- - // checklist:getCheckItem - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the card that checklist belongs to', - }, - { - displayName: 'CheckItem ID', - name: 'checkItemId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the checklist item to get', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'getCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // checklist:updateCheckItem - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'updateCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the card that checklist belongs to', - }, - { - displayName: 'CheckItem ID', - name: 'checkItemId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'updateCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the checklist item to update', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'updateCheckItem', - ], - resource: [ - 'checklist', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'The new name for the checklist item', - }, - { - displayName: 'State', - name: 'state', - type: 'options', - options: [ - { - name: 'Complete', - value: 'complete', - }, - { - name: 'Incomplete', - value: 'incomplete', - }, - ], - default: 'complete', - }, - { - displayName: 'Checklist ID', - name: 'checklistId', - type: 'string', - default: '', - description: 'The ID of the checklist this item is in', - }, - { - displayName: 'Position', - name: 'pos', - type: 'string', - default: '', - description: 'The position of the checklist on the card. One of: top, bottom, or a positive number.', - }, - ], - }, - - // ---------------------------------- - // checklist:completedCheckItems - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'completedCheckItems', - ], - resource: [ - 'checklist', - ], - }, - }, - description: 'The ID of the card for checkItems', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'completedCheckItems', - ], - resource: [ - 'checklist', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of: "idCheckItem", "state".', - }, - ], - }, - -]; diff --git a/packages/nodes-base/nodes/Trello/v2/GenericFunctions.ts b/packages/nodes-base/nodes/Trello/v2/GenericFunctions.ts deleted file mode 100644 index daee29cb49082..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/GenericFunctions.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; - -import { - OptionsWithUri, -} from 'request'; - -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; - -/** - * Make an API request to Trello - * - * @param {IHookFunctions} this - * @param {string} method - * @param {string} url - * @param {object} body - * @returns {Promise} - */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise { // tslint:disable-line:no-any - query = query || {}; - - const options: OptionsWithUri = { - method, - body, - qs: query, - uri: `https://api.trello.com/1/${endpoint}`, - json: true, - }; - - try { - return await this.helpers.requestWithAuthentication.call(this, 'trelloApi', options); - } catch(error) { - throw new NodeApiError(this.getNode(), error as JsonObject); - } -} - -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - - query.limit = 30; - - query.sort = '-id'; - - const returnData: IDataObject[] = []; - - let responseData; - - do { - responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData); - if (responseData.length !== 0) { - query.before = responseData[responseData.length - 1].id; - } - } while ( - query.limit <= responseData.length - ); - - return returnData; -} diff --git a/packages/nodes-base/nodes/Trello/v2/LabelDescription.ts b/packages/nodes-base/nodes/Trello/v2/LabelDescription.ts deleted file mode 100644 index 68de293905fb4..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/LabelDescription.ts +++ /dev/null @@ -1,476 +0,0 @@ -import { - INodeProperties, -} from 'n8n-workflow'; - -export const labelOperations: INodeProperties[] = [ - // ---------------------------------- - // label - // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'label', - ], - }, - }, - options: [ - { - name: 'Add to Card', - value: 'addLabel', - description: 'Add a label to a card', - action: 'Add a label to a card', - }, - { - name: 'Create', - value: 'create', - description: 'Create a new label', - action: 'Create a label', - }, - { - name: 'Delete', - value: 'delete', - description: 'Delete a label', - action: 'Delete a label', - }, - { - name: 'Get', - value: 'get', - description: 'Get the data of a label', - action: 'Get a label', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Returns all labels for the board', - action: 'Get all labels', - }, - { - name: 'Remove From Card', - value: 'removeLabel', - description: 'Remove a label from a card', - action: 'Remove a label from a card', - }, - { - name: 'Update', - value: 'update', - description: 'Update a label', - action: 'Update a label', - }, - - ], - default: 'getAll', - }, - -]; - -export const labelFields: INodeProperties[] = [ - // ---------------------------------- - // label:create - // ---------------------------------- - { - displayName: 'Board ID', - name: 'labelBoardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the board to create the label on', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'label', - ], - }, - }, - description: 'Name for the label', - }, - { - displayName: 'Color', - name: 'color', - type: 'options', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'label', - ], - }, - }, - options: [ - { - name: 'Black', - value: 'black', - }, - { - name: 'Blue', - value: 'blue', - }, - { - name: 'Green', - value: 'green', - }, - { - name: 'Lime', - value: 'lime', - }, - { - name: 'Null', - value: 'null', - }, - { - name: 'Orange', - value: 'orange', - }, - { - name: 'Pink', - value: 'pink', - }, - { - name: 'Purple', - value: 'purple', - }, - { - name: 'Red', - value: 'red', - }, - { - name: 'Sky', - value: 'sky', - }, - { - name: 'Yellow', - value: 'yellow', - }, - ], - default: 'null', - description: 'The color for the label', - }, - - - // ---------------------------------- - // label:delete - // ---------------------------------- - { - displayName: 'Label ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'delete', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the label to delete', - }, - - // ---------------------------------- - // label:getAll - // ---------------------------------- - { - displayName: 'Board ID', - name: 'labelBoardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the board to get label', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'label', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // label:get - // ---------------------------------- - { - displayName: 'Label ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'label', - ], - }, - }, - description: 'Get information about a label by ID', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'label', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // label:addLabel - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'addLabel', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the card to get label', - }, - { - displayName: 'Label ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'addLabel', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the label to add', - }, - - // ---------------------------------- - // label:removeLabel - // ---------------------------------- - { - displayName: 'Card ID', - name: 'cardId', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'removeLabel', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the card to remove label from', - }, - { - displayName: 'Label ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'removeLabel', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the label to remove', - }, - - // ---------------------------------- - // label:update - // ---------------------------------- - { - displayName: 'Label ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'label', - ], - }, - }, - description: 'The ID of the label to update', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'label', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'Name of the label', - }, - { - displayName: 'Color', - name: 'color', - type: 'options', - options: [ - { - name: 'Black', - value: 'black', - }, - { - name: 'Blue', - value: 'blue', - }, - { - name: 'Green', - value: 'green', - }, - { - name: 'Lime', - value: 'lime', - }, - { - name: 'Null', - value: 'null', - }, - { - name: 'Orange', - value: 'orange', - }, - { - name: 'Pink', - value: 'pink', - }, - { - name: 'Purple', - value: 'purple', - }, - { - name: 'Red', - value: 'red', - }, - { - name: 'Sky', - value: 'sky', - }, - { - name: 'Yellow', - value: 'yellow', - }, - ], - default: 'null', - description: 'The color for the label', - }, - ], - }, - -]; diff --git a/packages/nodes-base/nodes/Trello/v2/ListDescription.ts b/packages/nodes-base/nodes/Trello/v2/ListDescription.ts deleted file mode 100644 index f7e8be365feba..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/ListDescription.ts +++ /dev/null @@ -1,477 +0,0 @@ -import { - INodeProperties, -} from 'n8n-workflow'; - -export const listOperations: INodeProperties[] = [ - // ---------------------------------- - // list - // ---------------------------------- - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: { - resource: [ - 'list', - ], - }, - }, - options: [ - { - name: 'Archive', - value: 'archive', - description: 'Archive/Unarchive a list', - action: 'Archive/unarchive a list', - }, - { - name: 'Create', - value: 'create', - description: 'Create a new list', - action: 'Create a list', - }, - { - name: 'Get', - value: 'get', - description: 'Get the data of a list', - action: 'Get a list', - }, - { - name: 'Get All', - value: 'getAll', - description: 'Get all the lists', - action: 'Get all lists', - }, - { - name: 'Get Cards', - value: 'getCards', - description: 'Get all the cards in a list', - action: 'Get all cards in a list', - }, - { - name: 'Update', - value: 'update', - description: 'Update a list', - action: 'Update a list', - }, - ], - default: 'create', - }, -]; - -export const listFields: INodeProperties[] = [ - // ---------------------------------- - // list:archive - // ---------------------------------- - { - displayName: 'List ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'archive', - ], - resource: [ - 'list', - ], - }, - }, - description: 'The ID of the list to archive or unarchive', - }, - { - displayName: 'Archive', - name: 'archive', - type: 'boolean', - default: false, - displayOptions: { - show: { - operation: [ - 'archive', - ], - resource: [ - 'list', - ], - }, - }, - description: 'Whether the list should be archived or unarchived', - }, - - // ---------------------------------- - // list:create - // ---------------------------------- - { - displayName: 'Board ID', - name: 'idBoard', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], - }, - }, - description: 'The ID of the board the list should be created in', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - placeholder: 'My list', - required: true, - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], - }, - }, - description: 'The name of the list', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'List Source', - name: 'idListSource', - type: 'string', - default: '', - description: 'ID of the list to copy into the new list', - }, - { - displayName: 'Position', - name: 'pos', - type: 'string', - default: 'bottom', - description: - 'The position of the new list. top, bottom, or a positive float.', - }, - ], - }, - - // ---------------------------------- - // list:getCards - // ---------------------------------- - { - displayName: 'List ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getCards', - ], - resource: [ - 'list', - ], - }, - }, - description: 'The ID of the list to get cards', - }, - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - resource: [ - 'list', - ], - operation: [ - 'getCards', - ], - }, - }, - default: false, - description: 'Whether to return all results or only up to a given limit', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - typeOptions: { - minValue: 1, - }, - description: 'Max number of results to return', - default: 20, - displayOptions: { - show: { - resource: [ - 'list', - ], - operation: [ - 'getCards', - ], - returnAll: [ - false, - ], - }, - }, - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'getCards', - ], - resource: [ - 'list', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - // ---------------------------------- - // list:get - // ---------------------------------- - { - displayName: 'List ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], - }, - }, - description: 'The ID of the list to get', - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // list:getAll - // ---------------------------------- - { - displayName: 'Board ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], - }, - }, - description: 'The ID of the board', - }, - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], - }, - }, - default: false, - description: 'Whether to return all results or only up to a given limit', - }, - { - displayName: 'Limit', - name: 'limit', - type: 'number', - typeOptions: { - minValue: 1, - }, - description: 'Max number of results to return', - default: 20, - displayOptions: { - show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], - }, - }, - }, - { - displayName: 'Additional Fields', - name: 'additionalFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Fields', - name: 'fields', - type: 'string', - default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of fields.', - }, - ], - }, - - // ---------------------------------- - // list:update - // ---------------------------------- - { - displayName: 'List ID', - name: 'id', - type: 'string', - default: '', - required: true, - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], - }, - }, - description: 'The ID of the list to update', - }, - { - displayName: 'Update Fields', - name: 'updateFields', - type: 'collection', - placeholder: 'Add Field', - displayOptions: { - show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], - }, - }, - default: {}, - options: [ - { - displayName: 'Board ID', - name: 'idBoard', - type: 'string', - default: '', - description: 'ID of a board the list should be moved to', - }, - { - displayName: 'Closed', - name: 'closed', - type: 'boolean', - default: false, - description: 'Whether the list is closed', - }, - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - description: 'New name of the list', - }, - { - displayName: 'Position', - name: 'pos', - type: 'string', - default: 'bottom', - description: - 'The position of the list. top, bottom, or a positive float.', - }, - { - displayName: 'Subscribed', - name: 'subscribed', - type: 'boolean', - default: false, - description: 'Whether the acting user is subscribed to the list', - }, - ], - }, -]; diff --git a/packages/nodes-base/nodes/Trello/v2/TrelloV2.node.ts b/packages/nodes-base/nodes/Trello/v2/TrelloV2.node.ts deleted file mode 100644 index 76a725c856925..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/TrelloV2.node.ts +++ /dev/null @@ -1,712 +0,0 @@ -import { IExecuteFunctions } from 'n8n-core'; - -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeBaseDescription, - INodeTypeDescription, - NodeOperationError, -} from 'n8n-workflow'; - -import { apiRequest, apiRequestAllItems } from '../GenericFunctions'; - -import { versionDescription } from './VersionDescription'; - -export class TrelloV2 implements INodeType { - description: INodeTypeDescription; - - constructor(baseDescription: INodeTypeBaseDescription) { - this.description = { - ...baseDescription, - ...versionDescription, - }; - } - - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); - const returnData: INodeExecutionData[] = []; - - const operation = this.getNodeParameter('operation', 0) as string; - const resource = this.getNodeParameter('resource', 0) as string; - - // For Post - let body: IDataObject; - // For Query string - let qs: IDataObject; - - let requestMethod: string; - let endpoint: string; - let returnAll = false; - let responseData; - - for (let i = 0; i < items.length; i++) { - try { - requestMethod = 'GET'; - endpoint = ''; - body = {}; - qs = {}; - - if (resource === 'board') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - endpoint = 'boards'; - - qs.name = this.getNodeParameter('name', i) as string; - qs.desc = this.getNodeParameter('description', i) as string; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('boardIdDelete', i, undefined, { - extractValue: true, - }) as string; - - endpoint = `boards/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('boardId', i, undefined, { - extractValue: true, - }) as string; - - endpoint = `boards/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('boardIdUpdate', i, undefined, { - extractValue: true, - }) as string; - - endpoint = `boards/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'boardMember') { - if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - returnAll = this.getNodeParameter('returnAll', i) as boolean; - if (returnAll === false) { - qs.limit = this.getNodeParameter('limit', i) as number; - } - - endpoint = `boards/${id}/members`; - } else if (operation === 'add') { - // ---------------------------------- - // add - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - const idMember = this.getNodeParameter('idMember', i) as string; - - endpoint = `boards/${id}/members/${idMember}`; - - qs.type = this.getNodeParameter('type', i) as string; - qs.allowBillableGuest = this.getNodeParameter( - 'additionalFields.allowBillableGuest', - i, - false, - ) as boolean; - } else if (operation === 'invite') { - // ---------------------------------- - // invite - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `boards/${id}/members`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - - qs.email = this.getNodeParameter('email', i) as string; - qs.type = additionalFields.type as string; - body.fullName = additionalFields.fullName as string; - } else if (operation === 'remove') { - // ---------------------------------- - // remove - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('id', i) as string; - const idMember = this.getNodeParameter('idMember', i) as string; - - endpoint = `boards/${id}/members/${idMember}`; - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'card') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - endpoint = 'cards'; - - qs.idList = this.getNodeParameter('listId', i) as string; - - qs.name = this.getNodeParameter('name', i) as string; - qs.desc = this.getNodeParameter('description', i) as string; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'cardComment') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - const cardId = this.getNodeParameter('cardId', i) as string; - - qs.text = this.getNodeParameter('text', i) as string; - - requestMethod = 'POST'; - - endpoint = `cards/${cardId}/actions/comments`; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - const commentId = this.getNodeParameter('commentId', i) as string; - - endpoint = `/cards/${cardId}/actions/${commentId}/comments`; - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - const commentId = this.getNodeParameter('commentId', i) as string; - - qs.text = this.getNodeParameter('text', i) as string; - - endpoint = `cards/${cardId}/actions/${commentId}/comments`; - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'list') { - if (operation === 'archive') { - // ---------------------------------- - // archive - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - qs.value = this.getNodeParameter('archive', i) as boolean; - - endpoint = `lists/${id}/closed`; - } else if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - endpoint = 'lists'; - - qs.idBoard = this.getNodeParameter('idBoard', i) as string; - - qs.name = this.getNodeParameter('name', i) as string; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `lists/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - returnAll = this.getNodeParameter('returnAll', i) as boolean; - - if (returnAll === false) { - qs.limit = this.getNodeParameter('limit', i) as number; - } - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `boards/${id}/lists`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getCards') { - // ---------------------------------- - // getCards - // ---------------------------------- - - requestMethod = 'GET'; - - returnAll = this.getNodeParameter('returnAll', i) as boolean; - - if (returnAll === false) { - qs.limit = this.getNodeParameter('limit', i) as number; - } - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `lists/${id}/cards`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `lists/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'attachment') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const url = this.getNodeParameter('url', i) as string; - - Object.assign(qs, { - url, - }); - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - - endpoint = `cards/${cardId}/attachments`; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${cardId}/attachments/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${cardId}/attachments/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - endpoint = `cards/${cardId}/attachments`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'checklist') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const name = this.getNodeParameter('name', i) as string; - - Object.assign(qs, { name }); - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - - endpoint = `cards/${cardId}/checklists`; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `cards/${cardId}/checklists/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `checklists/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - endpoint = `cards/${cardId}/checklists`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getCheckItem') { - // ---------------------------------- - // getCheckItem - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const checkItemId = this.getNodeParameter('checkItemId', i) as string; - - endpoint = `cards/${cardId}/checkItem/${checkItemId}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'createCheckItem') { - // ---------------------------------- - // createCheckItem - // ---------------------------------- - - requestMethod = 'POST'; - - const checklistId = this.getNodeParameter('checklistId', i) as string; - - endpoint = `checklists/${checklistId}/checkItems`; - - const name = this.getNodeParameter('name', i) as string; - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, { name, ...additionalFields }); - } else if (operation === 'deleteCheckItem') { - // ---------------------------------- - // deleteCheckItem - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const checkItemId = this.getNodeParameter('checkItemId', i) as string; - - endpoint = `cards/${cardId}/checkItem/${checkItemId}`; - } else if (operation === 'updateCheckItem') { - // ---------------------------------- - // updateCheckItem - // ---------------------------------- - - requestMethod = 'PUT'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const checkItemId = this.getNodeParameter('checkItemId', i) as string; - - endpoint = `cards/${cardId}/checkItem/${checkItemId}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'completedCheckItems') { - // ---------------------------------- - // completedCheckItems - // ---------------------------------- - - requestMethod = 'GET'; - - const cardId = this.getNodeParameter('cardId', i) as string; - - endpoint = `cards/${cardId}/checkItemStates`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else if (resource === 'label') { - if (operation === 'create') { - // ---------------------------------- - // create - // ---------------------------------- - - requestMethod = 'POST'; - - const idBoard = this.getNodeParameter('labelBoardId', i) as string; - const name = this.getNodeParameter('name', i) as string; - const color = this.getNodeParameter('color', i) as string; - - Object.assign(qs, { - idBoard, - name, - color, - }); - - endpoint = 'labels'; - } else if (operation === 'delete') { - // ---------------------------------- - // delete - // ---------------------------------- - - requestMethod = 'DELETE'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `labels/${id}`; - } else if (operation === 'get') { - // ---------------------------------- - // get - // ---------------------------------- - - requestMethod = 'GET'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `labels/${id}`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { - // ---------------------------------- - // getAll - // ---------------------------------- - - requestMethod = 'GET'; - - const idBoard = this.getNodeParameter('labelBoardId', i) as string; - - endpoint = `board/${idBoard}/labels`; - - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - - Object.assign(qs, additionalFields); - } else if (operation === 'update') { - // ---------------------------------- - // update - // ---------------------------------- - - requestMethod = 'PUT'; - - const id = this.getNodeParameter('id', i) as string; - - endpoint = `labels/${id}`; - - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - Object.assign(qs, updateFields); - } else if (operation === 'addLabel') { - // ---------------------------------- - // addLabel - // ---------------------------------- - - requestMethod = 'POST'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - qs.value = id; - - endpoint = `/cards/${cardId}/idLabels`; - } else if (operation === 'removeLabel') { - // ---------------------------------- - // removeLabel - // ---------------------------------- - - requestMethod = 'DELETE'; - - const cardId = this.getNodeParameter('cardId', i) as string; - const id = this.getNodeParameter('id', i) as string; - - endpoint = `/cards/${cardId}/idLabels/${id}`; - } else { - throw new NodeOperationError( - this.getNode(), - `The operation "${operation}" is not known!`, - { itemIndex: i }, - ); - } - } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { - itemIndex: i, - }); - } - - // resources listed here do not support pagination so - // paginate them 'manually' - const skipPagination = ['list:getAll']; - - if (returnAll === true && !skipPagination.includes(`${resource}:${operation}`)) { - responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs); - } else { - responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - if (returnAll === false && qs.limit) { - responseData = responseData.splice(0, qs.limit); - } - } - - const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), - { itemData: { item: i } }, - ); - returnData.push(...executionData); - } catch (error) { - if (this.continueOnFail()) { - const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray({ error: error.message }), - { itemData: { item: i } }, - ); - returnData.push(...executionData); - continue; - } - throw error; - } - } - - return this.prepareOutputData(returnData); - } -} diff --git a/packages/nodes-base/nodes/Trello/v2/VersionDescription.ts b/packages/nodes-base/nodes/Trello/v2/VersionDescription.ts deleted file mode 100644 index a2e6081526f90..0000000000000 --- a/packages/nodes-base/nodes/Trello/v2/VersionDescription.ts +++ /dev/null @@ -1,133 +0,0 @@ -/* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import type { - INodeTypeDescription, -} from 'n8n-workflow'; - -import { - attachmentFields, - attachmentOperations, -} from './AttachmentDescription'; - -import { - boardFields, - boardOperations, -} from './BoardDescription'; - -import { - boardMemberFields, - boardMemberOperations, -} from './BoardMemberDescription'; - -import { - cardFields, - cardOperations, -} from './CardDescription'; - -import { - cardCommentFields, - cardCommentOperations, -} from './CardCommentDescription'; - -import { - checklistFields, - checklistOperations, -} from './ChecklistDescription'; - -import { - labelFields, - labelOperations, -} from './LabelDescription'; - -import { - listFields, - listOperations, -} from './ListDescription'; - -export const versionDescription: INodeTypeDescription = { - displayName: 'Trello', - name: 'trello', - icon: 'file:trello.svg', - group: ['transform'], - version: 2, - subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Create, change and delete boards and cards', - defaults: { - name: 'Trello', - }, - inputs: ['main'], - outputs: ['main'], - credentials: [ - { - name: 'trelloApi', - required: true, - }, - ], - properties: [ - { - displayName: 'Resource', - name: 'resource', - type: 'options', - noDataExpression: true, - options: [ - { - name: 'Attachment', - value: 'attachment', - }, - { - name: 'Board', - value: 'board', - }, - { - name: 'Board Member', - value: 'boardMember', - }, - { - name: 'Card', - value: 'card', - }, - { - name: 'Card Comment', - value: 'cardComment', - }, - { - name: 'Checklist', - value: 'checklist', - }, - { - name: 'Label', - value: 'label', - }, - { - name: 'List', - value: 'list', - }, - ], - default: 'card', - }, - - // ---------------------------------- - // operations - // ---------------------------------- - ...attachmentOperations, - ...boardOperations, - ...boardMemberOperations, - ...cardOperations, - ...cardCommentOperations, - ...checklistOperations, - ...labelOperations, - ...listOperations, - - // ---------------------------------- - // fields - // ---------------------------------- - ...attachmentFields, - ...boardFields, - ...boardMemberFields, - ...cardFields, - ...cardCommentFields, - ...checklistFields, - ...labelFields, - ...listFields, - - ], -};