mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-29 06:29:42 -08:00
Merge branch 'master' of github.com:n8n-io/n8n into n8n-2349-connectors
This commit is contained in:
commit
9755c712e1
|
@ -39,7 +39,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
(credentials) => credentials.name === name && credentials.type === type,
|
(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;
|
credentialsUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
(credentials) => credentials.name === name && credentials.type === type,
|
(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;
|
credentialsUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
(credentials) => credentials.name === name && credentials.type === type,
|
(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;
|
credentialsUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,8 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac
|
||||||
for (const [type, creds] of allNodeCredentials) {
|
for (const [type, creds] of allNodeCredentials) {
|
||||||
if (typeof creds === 'object') {
|
if (typeof creds === 'object') {
|
||||||
const matchingCredentials = credentialsEntities.find(
|
const matchingCredentials = credentialsEntities.find(
|
||||||
// @ts-ignore
|
// @ts-ignore double-equals because creds.id can be string or number
|
||||||
(credentials) => credentials.id === creds.id && credentials.type === type,
|
(credentials) => credentials.id == creds.id && credentials.type === type,
|
||||||
);
|
);
|
||||||
if (matchingCredentials) {
|
if (matchingCredentials) {
|
||||||
node.credentials[type] = matchingCredentials.name;
|
node.credentials[type] = matchingCredentials.name;
|
||||||
|
@ -226,8 +226,8 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac
|
||||||
for (const [type, creds] of allNodeCredentials) {
|
for (const [type, creds] of allNodeCredentials) {
|
||||||
if (typeof creds === 'object') {
|
if (typeof creds === 'object') {
|
||||||
const matchingCredentials = credentialsEntities.find(
|
const matchingCredentials = credentialsEntities.find(
|
||||||
// @ts-ignore
|
// @ts-ignore double-equals because creds.id can be string or number
|
||||||
(credentials) => credentials.id === creds.id && credentials.type === type,
|
(credentials) => credentials.id == creds.id && credentials.type === type,
|
||||||
);
|
);
|
||||||
if (matchingCredentials) {
|
if (matchingCredentials) {
|
||||||
node.credentials[type] = matchingCredentials.name;
|
node.credentials[type] = matchingCredentials.name;
|
||||||
|
@ -276,8 +276,8 @@ export class UpdateWorkflowCredentials1630330987096 implements MigrationInterfac
|
||||||
for (const [type, creds] of allNodeCredentials) {
|
for (const [type, creds] of allNodeCredentials) {
|
||||||
if (typeof creds === 'object') {
|
if (typeof creds === 'object') {
|
||||||
const matchingCredentials = credentialsEntities.find(
|
const matchingCredentials = credentialsEntities.find(
|
||||||
// @ts-ignore
|
// @ts-ignore double-equals because creds.id can be string or number
|
||||||
(credentials) => credentials.id === creds.id && credentials.type === type,
|
(credentials) => credentials.id == creds.id && credentials.type === type,
|
||||||
);
|
);
|
||||||
if (matchingCredentials) {
|
if (matchingCredentials) {
|
||||||
node.credentials[type] = matchingCredentials.name;
|
node.credentials[type] = matchingCredentials.name;
|
||||||
|
|
|
@ -1971,10 +1971,13 @@ export default mixins(
|
||||||
|
|
||||||
if (nodeCredentials.id) {
|
if (nodeCredentials.id) {
|
||||||
// Check whether the id is matching with a credential
|
// 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) {
|
||||||
if (credentialsForId.name !== nodeCredentials.name) {
|
if (credentialsForId.name !== nodeCredentials.name || typeof nodeCredentials.id === 'number') {
|
||||||
node.credentials![nodeCredentialType].name = credentialsForId.name;
|
node.credentials![nodeCredentialType] = { id: credentialsForId.id, name: credentialsForId.name };
|
||||||
this.credentialsUpdated = true;
|
this.credentialsUpdated = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -44,7 +44,6 @@ export async function todoistApiRequest(
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
options.headers['Authorization'] = `Bearer ${credentials.apiKey}`;
|
options.headers['Authorization'] = `Bearer ${credentials.apiKey}`;
|
||||||
|
|
||||||
return this.helpers.request!(options);
|
return this.helpers.request!(options);
|
||||||
} else {
|
} else {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
interface IBodyCreateTask {
|
interface IBodyCreateTask {
|
||||||
content: string;
|
content?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
project_id?: number;
|
project_id?: number;
|
||||||
section_id?: number;
|
section_id?: number;
|
||||||
|
@ -146,6 +146,11 @@ export class Todoist implements INodeType {
|
||||||
value: 'reopen',
|
value: 'reopen',
|
||||||
description: 'Reopen a task',
|
description: 'Reopen a task',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Update',
|
||||||
|
value: 'update',
|
||||||
|
description: 'Update a task',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
|
@ -228,6 +233,7 @@ export class Todoist implements INodeType {
|
||||||
'close',
|
'close',
|
||||||
'get',
|
'get',
|
||||||
'reopen',
|
'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).',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -573,6 +649,43 @@ export class Todoist implements INodeType {
|
||||||
|
|
||||||
responseData = { success: true };
|
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)) {
|
if (Array.isArray(responseData)) {
|
||||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||||
|
|
Loading…
Reference in a new issue