From f6dae26532a37a8762f2870722412838363da21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 4 Nov 2021 20:59:53 +0100 Subject: [PATCH 1/3] :zap: Add .npmrc to fix build issues (#2243) --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..e9ee3cb4d0 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +legacy-peer-deps=true \ No newline at end of file From e84846dcf915387382094acc174aaf65adfa2f90 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Thu, 4 Nov 2021 22:21:35 -0400 Subject: [PATCH 2/3] :zap: Add task:update - Todoist (#2409) * :zap: Add task:update * :zap: Minor improvements Co-authored-by: Jan Oberhauser --- .../nodes/Todoist/GenericFunctions.ts | 1 - .../nodes-base/nodes/Todoist/Todoist.node.ts | 129 ++++++++++++++++-- 2 files changed, 121 insertions(+), 9 deletions(-) diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts index 97665c3c4c..bd09118dae 100644 --- a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -44,7 +44,6 @@ export async function todoistApiRequest( //@ts-ignore options.headers['Authorization'] = `Bearer ${credentials.apiKey}`; - return this.helpers.request!(options); } else { //@ts-ignore diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts index 4aeca39d81..a4ebc6fe2d 100644 --- a/packages/nodes-base/nodes/Todoist/Todoist.node.ts +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -16,7 +16,7 @@ import { } from './GenericFunctions'; interface IBodyCreateTask { - content: string; + content?: string; description?: string; project_id?: number; section_id?: number; @@ -146,6 +146,11 @@ export class Todoist implements INodeType { value: 'reopen', description: 'Reopen a task', }, + { + name: 'Update', + value: 'update', + description: 'Update a task', + }, ], default: 'create', description: 'The operation to perform.', @@ -228,6 +233,7 @@ export class Todoist implements INodeType { 'close', 'get', 'reopen', + 'update', ], }, }, @@ -398,6 +404,76 @@ export class Todoist implements INodeType { }, ], }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'task', + ], + operation: [ + 'update', + ], + }, + }, + options: [ + { + displayName: 'Content', + name: 'content', + type: 'string', + default: '', + description: 'Task content', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'A description for the task.', + }, + { + displayName: 'Due Date Time', + name: 'dueDateTime', + type: 'dateTime', + default: '', + description: 'Specific date and time in RFC3339 format in UTC.', + }, + { + displayName: 'Due String', + name: 'dueString', + type: 'string', + default: '', + description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', + }, + { + displayName: 'Labels', + name: 'labels', + type: 'multiOptions', + typeOptions: { + loadOptionsMethod: 'getLabels', + }, + default: [], + required: false, + description: 'Labels', + }, + { + displayName: 'Priority', + name: 'priority', + type: 'number', + typeOptions: { + numberStepSize: 1, + maxValue: 4, + minValue: 1, + }, + default: 1, + description: 'Task priority from 1 (normal) to 4 (urgent).', + }, + ], + }, ], }; @@ -485,33 +561,33 @@ export class Todoist implements INodeType { const projectId = this.getNodeParameter('project', i) as number; const labels = this.getNodeParameter('labels', i) as number[]; const options = this.getNodeParameter('options', i) as IDataObject; - + const body: IBodyCreateTask = { content, project_id: projectId, priority: (options.priority!) ? parseInt(options.priority as string, 10) : 1, }; - + if (options.description) { body.description = options.description as string; } - + if (options.dueDateTime) { body.due_datetime = options.dueDateTime as string; } - + if (options.dueString) { body.due_string = options.dueString as string; } - + if (labels !== undefined && labels.length !== 0) { body.label_ids = labels; } - + if (options.section) { body.section_id = options.section as number; } - + responseData = await todoistApiRequest.call(this, 'POST', '/tasks', body); } if (operation === 'close') { @@ -573,6 +649,43 @@ export class Todoist implements INodeType { responseData = { success: true }; } + + if (operation === 'update') { + //https://developer.todoist.com/rest/v1/#update-a-task + const id = this.getNodeParameter('taskId', i) as string; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + + const body: IBodyCreateTask = {}; + + if (updateFields.content) { + body.content = updateFields.content as string; + } + + if (updateFields.priority) { + body.priority = parseInt(updateFields.priority as string, 10); + } + + if (updateFields.description) { + body.description = updateFields.description as string; + } + + if (updateFields.dueDateTime) { + body.due_datetime = updateFields.dueDateTime as string; + } + + if (updateFields.dueString) { + body.due_string = updateFields.dueString as string; + } + + if (updateFields.labels !== undefined && + Array.isArray(updateFields.labels) && + updateFields.labels.length !== 0) { + body.label_ids = updateFields.labels as number[]; + } + + await todoistApiRequest.call(this, 'POST', `/tasks/${id}`, body); + responseData = { success: true }; + } } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); From a46c7f827d94b73326c64e7d45199d0d27498949 Mon Sep 17 00:00:00 2001 From: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Date: Fri, 5 Nov 2021 03:23:10 +0100 Subject: [PATCH 3/3] :bug: Fix saving credentials id as string (#2410) --- .../1630330987096-UpdateWorkflowCredentials.ts | 18 +++++++++--------- packages/editor-ui/src/views/NodeView.vue | 9 ++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/databases/sqlite/migrations/1630330987096-UpdateWorkflowCredentials.ts b/packages/cli/src/databases/sqlite/migrations/1630330987096-UpdateWorkflowCredentials.ts index 147e5e49b2..273f644e4e 100644 --- a/packages/cli/src/databases/sqlite/migrations/1630330987096-UpdateWorkflowCredentials.ts +++ b/packages/cli/src/databases/sqlite/migrations/1630330987096-UpdateWorkflowCredentials.ts @@ -39,7 +39,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac // @ts-ignore (credentials) => credentials.name === name && credentials.type === type, ); - node.credentials[type] = { id: matchingCredentials?.id || null, name }; + node.credentials[type] = { id: matchingCredentials?.id.toString() || null, name }; credentialsUpdated = true; } } @@ -82,7 +82,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac // @ts-ignore (credentials) => credentials.name === name && credentials.type === type, ); - node.credentials[type] = { id: matchingCredentials?.id || null, name }; + node.credentials[type] = { id: matchingCredentials?.id.toString() || null, name }; credentialsUpdated = true; } } @@ -126,7 +126,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac // @ts-ignore (credentials) => credentials.name === name && credentials.type === type, ); - node.credentials[type] = { id: matchingCredentials?.id || null, name }; + node.credentials[type] = { id: matchingCredentials?.id.toString() || null, name }; credentialsUpdated = true; } } @@ -176,8 +176,8 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac for (const [type, creds] of allNodeCredentials) { if (typeof creds === 'object') { const matchingCredentials = credentialsEntities.find( - // @ts-ignore - (credentials) => credentials.id === creds.id && credentials.type === type, + // @ts-ignore double-equals because creds.id can be string or number + (credentials) => credentials.id == creds.id && credentials.type === type, ); if (matchingCredentials) { node.credentials[type] = matchingCredentials.name; @@ -226,8 +226,8 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac for (const [type, creds] of allNodeCredentials) { if (typeof creds === 'object') { const matchingCredentials = credentialsEntities.find( - // @ts-ignore - (credentials) => credentials.id === creds.id && credentials.type === type, + // @ts-ignore double-equals because creds.id can be string or number + (credentials) => credentials.id == creds.id && credentials.type === type, ); if (matchingCredentials) { node.credentials[type] = matchingCredentials.name; @@ -276,8 +276,8 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac for (const [type, creds] of allNodeCredentials) { if (typeof creds === 'object') { const matchingCredentials = credentialsEntities.find( - // @ts-ignore - (credentials) => credentials.id === creds.id && credentials.type === type, + // @ts-ignore double-equals because creds.id can be string or number + (credentials) => credentials.id == creds.id && credentials.type === type, ); if (matchingCredentials) { node.credentials[type] = matchingCredentials.name; diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 82c8cf1d95..3e6abff170 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -1917,10 +1917,13 @@ export default mixins( if (nodeCredentials.id) { // Check whether the id is matching with a credential - const credentialsForId = credentialOptions.find((optionData: ICredentialsResponse) => optionData.id === nodeCredentials.id); + const credentialsId = nodeCredentials.id.toString(); // due to a fixed bug in the migration UpdateWorkflowCredentials (just sqlite) we have to cast to string and check later if it has been a number + const credentialsForId = credentialOptions.find((optionData: ICredentialsResponse) => + optionData.id === credentialsId, + ); if (credentialsForId) { - if (credentialsForId.name !== nodeCredentials.name) { - node.credentials![nodeCredentialType].name = credentialsForId.name; + if (credentialsForId.name !== nodeCredentials.name || typeof nodeCredentials.id === 'number') { + node.credentials![nodeCredentialType] = { id: credentialsForId.id, name: credentialsForId.name }; this.credentialsUpdated = true; } return;