first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,97 @@
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
JsonObject,
IHttpRequestMethods,
IRequestOptions,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
export async function microsoftApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
resource: string,
body: IDataObject = {},
qs: IDataObject = {},
uri?: string,
_headers: IDataObject = {},
option: IDataObject = { json: true },
) {
const credentials = await this.getCredentials('microsoftToDoOAuth2Api');
const baseUrl = (
typeof credentials.graphApiBaseUrl === 'string' && credentials.graphApiBaseUrl !== ''
? credentials.graphApiBaseUrl
: 'https://graph.microsoft.com'
).replace(/\/+$/, '');
const options: IRequestOptions = {
headers: {
'Content-Type': 'application/json',
},
method,
body,
qs,
uri: uri || `${baseUrl}/v1.0/me${resource}`,
};
try {
Object.assign(options, option);
if (Object.keys(qs).length === 0) {
delete options.qs;
}
if (Object.keys(body).length === 0) {
delete options.body;
}
return await this.helpers.requestOAuth2.call(this, 'microsoftToDoOAuth2Api', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export async function microsoftApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions,
propertyName: string,
method: IHttpRequestMethods,
endpoint: string,
body: IDataObject = {},
query: IDataObject = {},
) {
const returnData: IDataObject[] = [];
let responseData;
let uri: string | undefined;
query.$top = 100;
do {
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
uri = responseData['@odata.nextLink'];
if (uri?.includes('$top')) {
delete query.$top;
}
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
} while (responseData['@odata.nextLink'] !== undefined);
return returnData;
}
export async function microsoftApiRequestAllItemsSkip(
this: IExecuteFunctions,
propertyName: string,
method: IHttpRequestMethods,
endpoint: string,
body: IDataObject = {},
query: IDataObject = {},
) {
const returnData: IDataObject[] = [];
let responseData;
query.$top = 100;
query.$skip = 0;
do {
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query);
query.$skip += query.$top;
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
} while (responseData.value.length !== 0);
return returnData;
}
@@ -0,0 +1,241 @@
import type { INodeProperties } from 'n8n-workflow';
export const linkedResourceOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['linkedResource'],
},
},
options: [
{
name: 'Create',
value: 'create',
action: 'Create a linked resource',
},
{
name: 'Delete',
value: 'delete',
action: 'Delete a linked resource',
},
{
name: 'Get',
value: 'get',
action: 'Get a linked resource',
},
{
name: 'Get Many',
value: 'getAll',
action: 'Get many linked resources',
},
{
name: 'Update',
value: 'update',
action: 'Update a linked resource',
},
],
default: 'get',
},
];
export const linkedResourceFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* linkedResource:ALL */
/* -------------------------------------------------------------------------- */
{
displayName: 'Task List Name or ID',
name: 'taskListId',
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getTaskLists',
},
displayOptions: {
show: {
operation: ['create', 'delete', 'get', 'getAll', 'update'],
resource: ['linkedResource'],
},
},
required: true,
default: '',
},
{
displayName: 'Task ID',
name: 'taskId',
type: 'string',
displayOptions: {
show: {
operation: ['create', 'delete', 'get', 'getAll', 'update'],
resource: ['linkedResource'],
},
},
required: true,
default: '',
},
/* -------------------------------------------------------------------------- */
/* linkedResource:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Name',
name: 'displayName',
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['create'],
resource: ['linkedResource'],
},
},
description: 'Field indicating title of the linked entity',
},
{
displayName: 'Application Name',
name: 'applicationName',
type: 'string',
displayOptions: {
show: {
operation: ['create'],
resource: ['linkedResource'],
},
},
required: true,
default: '',
description: 'App name of the source that is sending the linked entity',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['linkedResource'],
operation: ['create'],
},
},
options: [
{
displayName: 'External ID',
name: 'externalId',
type: 'string',
default: '',
description:
'ID of the object that is associated with this task on the third-party/partner system',
},
{
displayName: 'Web URL',
name: 'webUrl',
type: 'string',
default: '',
description: 'Deeplink to the linked entity',
},
],
},
/* -------------------------------------------------------------------------- */
/* linkedResource:get/delete/update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Linked Resource ID',
name: 'linkedResourceId',
type: 'string',
displayOptions: {
show: {
resource: ['linkedResource'],
operation: ['delete', 'get', 'update'],
},
},
default: '',
required: true,
},
/* -------------------------------------------------------------------------- */
/* linkedResource:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['linkedResource'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['linkedResource'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
/* -------------------------------------------------------------------------- */
/* linkedResource:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['linkedResource'],
operation: ['update'],
},
},
options: [
{
displayName: 'Application Name',
name: 'applicationName',
type: 'string',
default: '',
description: 'App name of the source that is sending the linked entity',
},
{
displayName: 'Name',
name: 'displayName',
type: 'string',
default: '',
description: 'Field indicating title of the linked entity',
},
{
displayName: 'External ID',
name: 'externalId',
type: 'string',
default: '',
description:
'ID of the object that is associated with this task on the third-party/partner system',
},
{
displayName: 'Web URL',
name: 'webUrl',
type: 'string',
default: '',
description: 'Deeplink to the linked entity',
},
],
},
];
@@ -0,0 +1,134 @@
import type { INodeProperties } from 'n8n-workflow';
export const listOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['list'],
},
},
options: [
{
name: 'Create',
value: 'create',
action: 'Create a list',
},
{
name: 'Delete',
value: 'delete',
action: 'Delete a list',
},
{
name: 'Get',
value: 'get',
action: 'Get a list',
},
{
name: 'Get Many',
value: 'getAll',
action: 'Get many lists',
},
{
name: 'Update',
value: 'update',
action: 'Update a list',
},
],
default: 'get',
},
];
export const listFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* list:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'List Name',
name: 'displayName',
type: 'string',
displayOptions: {
show: {
operation: ['create'],
resource: ['list'],
},
},
required: true,
default: '',
description: 'List display name',
},
/* -------------------------------------------------------------------------- */
/* list:get/delete/update */
/* -------------------------------------------------------------------------- */
{
displayName: 'List ID',
name: 'listId',
type: 'string',
displayOptions: {
show: {
operation: ['delete', 'get', 'update'],
resource: ['list'],
},
},
required: true,
default: '',
description: "The identifier of the list, unique in the user's mailbox",
},
/* -------------------------------------------------------------------------- */
/* list:getAll */
/* -------------------------------------------------------------------------- */
{
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',
displayOptions: {
show: {
resource: ['list'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
/* -------------------------------------------------------------------------- */
/* list:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'New List Name',
name: 'displayName',
type: 'string',
displayOptions: {
show: {
operation: ['update'],
resource: ['list'],
},
},
required: true,
default: '',
description: 'List display name',
},
];
@@ -0,0 +1,18 @@
{
"node": "n8n-nodes-base.microsoftToDo",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Productivity"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/microsoft/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.microsofttodo/"
}
]
}
}
@@ -0,0 +1,436 @@
import moment from 'moment-timezone';
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import { microsoftApiRequest, microsoftApiRequestAllItems } from './GenericFunctions';
import { linkedResourceFields, linkedResourceOperations } from './LinkedResourceDescription';
import { listFields, listOperations } from './ListDescription';
import { taskFields, taskOperations } from './TaskDescription';
export class MicrosoftToDo implements INodeType {
description: INodeTypeDescription = {
displayName: 'Microsoft To Do',
name: 'microsoftToDo',
icon: 'file:todo.svg',
group: ['input'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume Microsoft To Do API.',
schemaPath: 'Microsoft/ToDo',
defaults: {
name: 'Microsoft To Do',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'microsoftToDoOAuth2Api',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Linked Resource',
value: 'linkedResource',
},
{
name: 'List',
value: 'list',
},
{
name: 'Task',
value: 'task',
},
],
default: 'task',
},
...linkedResourceOperations,
...linkedResourceFields,
...taskOperations,
...taskFields,
...listOperations,
...listFields,
],
};
methods = {
loadOptions: {
// Get all the team's channels to display them to user so that they can
// select them easily
async getTaskLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const lists = await microsoftApiRequestAllItems.call(this, 'value', 'GET', '/todo/lists');
for (const list of lists) {
returnData.push({
name: list.displayName as string,
value: list.id as string,
});
}
return returnData;
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
const timezone = this.getTimezone();
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < length; i++) {
try {
if (resource === 'linkedResource') {
// https://docs.microsoft.com/en-us/graph/api/todotask-post-linkedresources?view=graph-rest-1.0&tabs=http
if (operation === 'create') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
const body: IDataObject = {
applicationName: this.getNodeParameter('applicationName', i) as string,
displayName: this.getNodeParameter('displayName', i) as string,
...this.getNodeParameter('additionalFields', i),
};
responseData = await microsoftApiRequest.call(
this,
'POST',
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`,
body,
qs,
);
// https://docs.microsoft.com/en-us/graph/api/linkedresource-delete?view=graph-rest-1.0&tabs=http
} else if (operation === 'delete') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string;
responseData = await microsoftApiRequest.call(
this,
'DELETE',
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`,
undefined,
qs,
);
responseData = { success: true };
// https://docs.microsoft.com/en-us/graph/api/linkedresource-get?view=graph-rest-1.0&tabs=http
} else if (operation === 'get') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string;
responseData = await microsoftApiRequest.call(
this,
'GET',
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`,
undefined,
qs,
);
// https://docs.microsoft.com/en-us/graph/api/todotask-list-linkedresources?view=graph-rest-1.0&tabs=http
} else if (operation === 'getAll') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
const returnAll = this.getNodeParameter('returnAll', i);
if (returnAll) {
responseData = await microsoftApiRequestAllItems.call(
this,
'value',
'GET',
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`,
undefined,
qs,
);
} else {
qs.$top = this.getNodeParameter('limit', i);
responseData = await microsoftApiRequest.call(
this,
'GET',
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`,
undefined,
qs,
);
responseData = responseData.value;
}
// https://docs.microsoft.com/en-us/graph/api/linkedresource-update?view=graph-rest-1.0&tabs=http
} else if (operation === 'update') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string;
const body: IDataObject = {
...this.getNodeParameter('updateFields', i),
};
responseData = await microsoftApiRequest.call(
this,
'PATCH',
`/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`,
body,
qs,
);
} else {
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
{ itemIndex: i },
);
}
} else if (resource === 'task') {
// https://docs.microsoft.com/en-us/graph/api/todotasklist-post-tasks?view=graph-rest-1.0&tabs=http
if (operation === 'create') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const body: IDataObject = {
title: this.getNodeParameter('title', i) as string,
...this.getNodeParameter('additionalFields', i),
};
if (body.content) {
body.body = {
content: body.content,
contentType: 'html',
};
}
if (body.dueDateTime) {
body.dueDateTime = {
dateTime: moment.tz(body.dueDateTime, timezone).format(),
timeZone: timezone,
};
}
if (body.reminderDateTime) {
body.reminderDateTime = {
dateTime: moment.tz(body.reminderDateTime, timezone).format(),
timeZone: timezone,
};
body.isReminderOn = true;
}
responseData = await microsoftApiRequest.call(
this,
'POST',
`/todo/lists/${taskListId}/tasks`,
body,
qs,
);
// https://docs.microsoft.com/en-us/graph/api/todotask-delete?view=graph-rest-1.0&tabs=http
} else if (operation === 'delete') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
responseData = await microsoftApiRequest.call(
this,
'DELETE',
`/todo/lists/${taskListId}/tasks/${taskId}`,
undefined,
qs,
);
responseData = { success: true };
// https://docs.microsoft.com/en-us/graph/api/todotask-get?view=graph-rest-1.0&tabs=http
} else if (operation === 'get') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
responseData = await microsoftApiRequest.call(
this,
'GET',
`/todo/lists/${taskListId}/tasks/${taskId}`,
undefined,
qs,
);
// https://docs.microsoft.com/en-us/graph/api/todotasklist-list-tasks?view=graph-rest-1.0&tabs=http
} else if (operation === 'getAll') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const returnAll = this.getNodeParameter('returnAll', i);
if (returnAll) {
responseData = await microsoftApiRequestAllItems.call(
this,
'value',
'GET',
`/todo/lists/${taskListId}/tasks/`,
undefined,
qs,
);
} else {
qs.$top = this.getNodeParameter('limit', i);
responseData = await microsoftApiRequest.call(
this,
'GET',
`/todo/lists/${taskListId}/tasks/`,
undefined,
qs,
);
responseData = responseData.value;
}
// https://docs.microsoft.com/en-us/graph/api/todotask-update?view=graph-rest-1.0&tabs=http
} else if (operation === 'update') {
const taskListId = this.getNodeParameter('taskListId', i) as string;
const taskId = this.getNodeParameter('taskId', i) as string;
const body: IDataObject = {
...this.getNodeParameter('updateFields', i),
};
if (body.content) {
body.body = {
content: body.content,
contentType: 'html',
};
}
if (body.dueDateTime) {
body.dueDateTime = {
dateTime: moment.tz(body.dueDateTime, timezone).format(),
timeZone: timezone,
};
}
if (body.reminderDateTime) {
body.reminderDateTime = {
dateTime: moment.tz(body.reminderDateTime, timezone).format(),
timeZone: timezone,
};
body.isReminderOn = true;
} else {
body.isReminderOn = false;
}
responseData = await microsoftApiRequest.call(
this,
'PATCH',
`/todo/lists/${taskListId}/tasks/${taskId}`,
body,
qs,
);
} else {
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
{ itemIndex: i },
);
}
} else if (resource === 'list') {
// https://docs.microsoft.com/en-us/graph/api/todo-post-lists?view=graph-rest-1.0&tabs=http
if (operation === 'create') {
const body = {
displayName: this.getNodeParameter('displayName', i) as string,
};
responseData = await microsoftApiRequest.call(this, 'POST', '/todo/lists/', body, qs);
// https://docs.microsoft.com/en-us/graph/api/todotasklist-delete?view=graph-rest-1.0&tabs=http
} else if (operation === 'delete') {
const listId = this.getNodeParameter('listId', i) as string;
responseData = await microsoftApiRequest.call(
this,
'DELETE',
`/todo/lists/${listId}`,
undefined,
qs,
);
responseData = { success: true };
//https://docs.microsoft.com/en-us/graph/api/todotasklist-get?view=graph-rest-1.0&tabs=http
} else if (operation === 'get') {
const listId = this.getNodeParameter('listId', i) as string;
responseData = await microsoftApiRequest.call(
this,
'GET',
`/todo/lists/${listId}`,
undefined,
qs,
);
// https://docs.microsoft.com/en-us/graph/api/todo-list-lists?view=graph-rest-1.0&tabs=http
} else if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
if (returnAll) {
responseData = await microsoftApiRequestAllItems.call(
this,
'value',
'GET',
'/todo/lists',
undefined,
qs,
);
} else {
qs.$top = this.getNodeParameter('limit', i);
responseData = await microsoftApiRequest.call(
this,
'GET',
'/todo/lists',
undefined,
qs,
);
responseData = responseData.value;
}
// https://docs.microsoft.com/en-us/graph/api/todotasklist-update?view=graph-rest-1.0&tabs=http
} else if (operation === 'update') {
const listId = this.getNodeParameter('listId', i) as string;
const body = {
displayName: this.getNodeParameter('displayName', i) as string,
};
responseData = await microsoftApiRequest.call(
this,
'PATCH',
`/todo/lists/${listId}`,
body,
qs,
);
} else {
throw new NodeOperationError(
this.getNode(),
`The operation "${operation}" is not supported!`,
{ itemIndex: i },
);
}
}
} catch (error) {
if (this.continueOnFail()) {
const executionErrorData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionErrorData);
continue;
}
throw error;
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
return [returnData];
}
}
@@ -0,0 +1,336 @@
import type { INodeProperties } from 'n8n-workflow';
export const taskOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['task'],
},
},
options: [
{
name: 'Create',
value: 'create',
action: 'Create a task',
},
{
name: 'Delete',
value: 'delete',
action: 'Delete a task',
},
{
name: 'Get',
value: 'get',
action: 'Get a task',
},
{
name: 'Get Many',
value: 'getAll',
action: 'Get many tasks',
},
{
name: 'Update',
value: 'update',
action: 'Update a task',
},
],
default: 'get',
},
];
export const taskFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* task:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'List Name or ID',
name: 'taskListId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTaskLists',
},
displayOptions: {
show: {
operation: ['create'],
resource: ['task'],
},
},
required: true,
default: '',
description:
'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Subject',
name: 'title',
type: 'string',
displayOptions: {
show: {
operation: ['create'],
resource: ['task'],
},
},
required: true,
default: '',
description: 'A brief description of the task',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['task'],
operation: ['create'],
},
},
options: [
{
displayName: 'Content',
name: 'content',
type: 'string',
default: '',
description: 'The content of the task',
},
{
displayName: 'Due',
name: 'dueDateTime',
type: 'dateTime',
default: '',
description: 'The date in the specified time zone that the task is to be finished',
},
{
displayName: 'Reminder',
name: 'reminderDateTime',
type: 'dateTime',
default: '',
description: 'The date in the specified time zone that the task is to be reminded',
},
{
displayName: 'Importance',
name: 'importance',
type: 'options',
options: [
{
name: 'Low',
value: 'low',
},
{
name: 'Normal',
value: 'normal',
},
{
name: 'High',
value: 'high',
},
],
default: 'normal',
description: 'The importance of the task',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
options: [
{
name: 'Not Started',
value: 'notStarted',
},
{
name: 'In Progress',
value: 'inProgress',
},
{
name: 'Completed',
value: 'completed',
},
{
name: 'Waiting On Others',
value: 'waitingOnOthers',
},
{
name: 'Deferred',
value: 'deferred',
},
],
default: 'notStarted',
description: 'Indicates the state or progress of the task',
},
],
},
/* -------------------------------------------------------------------------- */
/* task:get/delete/update/getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'List Name or ID',
name: 'taskListId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getTaskLists',
},
displayOptions: {
show: {
operation: ['delete', 'get', 'getAll', 'update'],
resource: ['task'],
},
},
required: true,
default: '',
description:
'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Task ID',
name: 'taskId',
type: 'string',
displayOptions: {
show: {
operation: ['delete', 'get', 'update'],
resource: ['task'],
},
},
required: true,
default: '',
},
/* -------------------------------------------------------------------------- */
/* task:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['task'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: ['task'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'Max number of results to return',
},
/* -------------------------------------------------------------------------- */
/* task:update */
/* -------------------------------------------------------------------------- */
{
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: 'The content of the task',
},
{
displayName: 'Due Date Time',
name: 'dueDateTime',
type: 'dateTime',
default: '',
description: 'The date in the specified time zone that the task is to be finished',
},
{
displayName: 'Reminder',
name: 'reminderDateTime',
type: 'dateTime',
default: '',
description: 'The date in the specified time zone that the task is to be reminded',
},
{
displayName: 'Importance',
name: 'importance',
type: 'options',
options: [
{
name: 'Low',
value: 'low',
},
{
name: 'Normal',
value: 'normal',
},
{
name: 'High',
value: 'high',
},
],
default: 'normal',
description: 'The importance of the task',
},
{
displayName: 'Status',
name: 'status',
type: 'options',
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
options: [
{
name: 'Not Started',
value: 'notStarted',
},
{
name: 'In Progress',
value: 'inProgress',
},
{
name: 'Completed',
value: 'completed',
},
{
name: 'Waiting On Others',
value: 'waitingOnOthers',
},
{
name: 'Deferred',
value: 'deferred',
},
],
default: 'notStarted',
description: 'Indicates the state or progress of the task',
},
{
displayName: 'Subject',
name: 'title',
type: 'string',
default: '',
description: 'A brief description of the task',
},
],
},
];
@@ -0,0 +1,27 @@
{
"type": "object",
"properties": {
"@odata.context": {
"type": "string"
},
"@odata.etag": {
"type": "string"
},
"displayName": {
"type": "string"
},
"id": {
"type": "string"
},
"isOwner": {
"type": "boolean"
},
"isShared": {
"type": "boolean"
},
"wellknownListName": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,27 @@
{
"type": "object",
"properties": {
"@odata.context": {
"type": "string"
},
"@odata.etag": {
"type": "string"
},
"displayName": {
"type": "string"
},
"id": {
"type": "string"
},
"isOwner": {
"type": "boolean"
},
"isShared": {
"type": "boolean"
},
"wellknownListName": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,24 @@
{
"type": "object",
"properties": {
"@odata.etag": {
"type": "string"
},
"displayName": {
"type": "string"
},
"id": {
"type": "string"
},
"isOwner": {
"type": "boolean"
},
"isShared": {
"type": "boolean"
},
"wellknownListName": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,47 @@
{
"type": "object",
"properties": {
"@odata.context": {
"type": "string"
},
"@odata.etag": {
"type": "string"
},
"body": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"contentType": {
"type": "string"
}
}
},
"createdDateTime": {
"type": "string"
},
"hasAttachments": {
"type": "boolean"
},
"id": {
"type": "string"
},
"importance": {
"type": "string"
},
"isReminderOn": {
"type": "boolean"
},
"lastModifiedDateTime": {
"type": "string"
},
"status": {
"type": "string"
},
"title": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,61 @@
{
"type": "object",
"properties": {
"@odata.etag": {
"type": "string"
},
"body": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"contentType": {
"type": "string"
}
}
},
"categories": {
"type": "array",
"items": {
"type": "string"
}
},
"createdDateTime": {
"type": "string"
},
"dueDateTime": {
"type": "object",
"properties": {
"dateTime": {
"type": "string"
},
"timeZone": {
"type": "string"
}
}
},
"hasAttachments": {
"type": "boolean"
},
"id": {
"type": "string"
},
"importance": {
"type": "string"
},
"isReminderOn": {
"type": "boolean"
},
"lastModifiedDateTime": {
"type": "string"
},
"status": {
"type": "string"
},
"title": {
"type": "string"
}
},
"version": 7
}
@@ -0,0 +1,47 @@
{
"type": "object",
"properties": {
"@odata.context": {
"type": "string"
},
"@odata.etag": {
"type": "string"
},
"body": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"contentType": {
"type": "string"
}
}
},
"createdDateTime": {
"type": "string"
},
"hasAttachments": {
"type": "boolean"
},
"id": {
"type": "string"
},
"importance": {
"type": "string"
},
"isReminderOn": {
"type": "boolean"
},
"lastModifiedDateTime": {
"type": "string"
},
"status": {
"type": "string"
},
"title": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,210 @@
import { mockDeep } from 'jest-mock-extended';
import type { IExecuteFunctions, INode } from 'n8n-workflow';
import { microsoftApiRequest } from '../GenericFunctions';
describe('Microsoft ToDo GenericFunctions', () => {
let mockExecuteFunctions: jest.Mocked<IExecuteFunctions>;
let mockNode: INode;
let mockRequestOAuth2: jest.Mock;
beforeEach(() => {
mockExecuteFunctions = mockDeep<IExecuteFunctions>();
mockRequestOAuth2 = jest.fn();
mockExecuteFunctions.helpers.requestOAuth2 = mockRequestOAuth2;
mockNode = {
id: 'test-node',
name: 'Test ToDo Node',
type: 'n8n-nodes-base.microsoftToDo',
typeVersion: 1,
position: [0, 0],
parameters: {},
};
mockExecuteFunctions.getNode.mockReturnValue(mockNode);
jest.clearAllMocks();
});
afterEach(() => {
jest.resetAllMocks();
});
describe('microsoftApiRequest', () => {
describe('graphApiBaseUrl from credentials', () => {
it('should use base URL from credentials', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
graphApiBaseUrl: 'https://graph.microsoft.us',
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://graph.microsoft.us/v1.0/me/todo/lists',
json: true,
}),
);
});
it('should fall back to default when credentials.graphApiBaseUrl is empty', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
graphApiBaseUrl: '',
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://graph.microsoft.com/v1.0/me/todo/lists',
json: true,
}),
);
});
it('should fall back to default when credentials.graphApiBaseUrl is undefined', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://graph.microsoft.com/v1.0/me/todo/lists',
json: true,
}),
);
});
it('should strip trailing slashes from base URL using regex', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
graphApiBaseUrl: 'https://graph.microsoft.com/',
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://graph.microsoft.com/v1.0/me/todo/lists',
json: true,
}),
);
});
it('should strip multiple trailing slashes from base URL', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
graphApiBaseUrl: 'https://graph.microsoft.com///',
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://graph.microsoft.com/v1.0/me/todo/lists',
json: true,
}),
);
});
it('should use US Government cloud endpoint', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
graphApiBaseUrl: 'https://graph.microsoft.us',
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://graph.microsoft.us/v1.0/me/todo/lists',
json: true,
}),
);
});
it('should use US Government DOD cloud endpoint', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
graphApiBaseUrl: 'https://dod-graph.microsoft.us',
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://dod-graph.microsoft.us/v1.0/me/todo/lists',
json: true,
}),
);
});
it('should use China cloud endpoint', async () => {
const mockResponse = { data: 'test' };
mockRequestOAuth2.mockResolvedValue(mockResponse);
mockExecuteFunctions.getCredentials.mockResolvedValue({
oauthTokenData: {
access_token: 'test-access-token',
},
graphApiBaseUrl: 'https://microsoftgraph.chinacloudapi.cn',
});
await microsoftApiRequest.call(mockExecuteFunctions, 'GET', '/todo/lists');
expect(mockRequestOAuth2).toHaveBeenCalledWith(
'microsoftToDoOAuth2Api',
expect.objectContaining({
method: 'GET',
uri: 'https://microsoftgraph.chinacloudapi.cn/v1.0/me/todo/lists',
json: true,
}),
);
});
});
});
});
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#185abd" d="M3.713 7.854.394 11.172a1.17 1.17 0 0 0 0 1.655L5.367 17.8l4.974-4.974-4.974-4.972a1.17 1.17 0 0 0-1.654 0"/><path fill="#41a5ee" d="m23.606 6.2-3.318-3.32a1.17 1.17 0 0 0-1.655 0l-4.146 4.146L9.513 12l-4.146 4.146a1.17 1.17 0 0 0 0 1.655l3.319 3.318a1.17 1.17 0 0 0 1.655 0l4.146-4.146L19.46 12l4.146-4.146a1.17 1.17 0 0 0 0-1.654"/><path fill="none" d="M0 0h24v24H0z"/></svg>

After

Width:  |  Height:  |  Size: 461 B