mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-27 13:39:44 -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
|
||||
(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;
|
||||
|
|
|
@ -1971,10 +1971,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;
|
||||
|
|
|
@ -44,7 +44,6 @@ export async function todoistApiRequest(
|
|||
|
||||
//@ts-ignore
|
||||
options.headers['Authorization'] = `Bearer ${credentials.apiKey}`;
|
||||
|
||||
return this.helpers.request!(options);
|
||||
} else {
|
||||
//@ts-ignore
|
||||
|
|
|
@ -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[]);
|
||||
|
|
Loading…
Reference in a new issue