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
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:
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.microsoftTeams",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Communication", "HITL"],
|
||||
"subcategories": {
|
||||
"HITL": ["Human in the Loop"]
|
||||
},
|
||||
"alias": ["human", "form", "wait", "hitl", "approval"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/microsoft/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.microsoftteams/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { INodeTypeBaseDescription, IVersionedNodeType } from 'n8n-workflow';
|
||||
import { VersionedNodeType } from 'n8n-workflow';
|
||||
|
||||
import { MicrosoftTeamsV1 } from './v1/MicrosoftTeamsV1.node';
|
||||
import { MicrosoftTeamsV2 } from './v2/MicrosoftTeamsV2.node';
|
||||
|
||||
export class MicrosoftTeams extends VersionedNodeType {
|
||||
constructor() {
|
||||
const baseDescription: INodeTypeBaseDescription = {
|
||||
displayName: 'Microsoft Teams',
|
||||
name: 'microsoftTeams',
|
||||
icon: 'file:teams.svg',
|
||||
group: ['input'],
|
||||
description: 'Consume Microsoft Teams API',
|
||||
defaultVersion: 2,
|
||||
schemaPath: 'Microsoft/Teams',
|
||||
};
|
||||
|
||||
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
|
||||
1: new MicrosoftTeamsV1(baseDescription),
|
||||
1.1: new MicrosoftTeamsV1(baseDescription),
|
||||
2: new MicrosoftTeamsV2(baseDescription),
|
||||
};
|
||||
|
||||
super(nodeVersions, baseDescription);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.microsoftTeamsTrigger",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Communication"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/microsoft/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.microsoftteamstrigger/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
IWebhookResponseData,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
JsonObject,
|
||||
INodeExecutionData,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError, NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import type { WebhookNotification, SubscriptionResponse } from './v2/helpers/types';
|
||||
import { createSubscription, getResourcePath } from './v2/helpers/utils-trigger';
|
||||
import { listSearch } from './v2/methods';
|
||||
import { microsoftApiRequest, microsoftApiRequestAllItems } from './v2/transport';
|
||||
|
||||
export class MicrosoftTeamsTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Microsoft Teams Trigger',
|
||||
name: 'microsoftTeamsTrigger',
|
||||
icon: 'file:teams.svg',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
description:
|
||||
'Triggers workflows in n8n based on events from Microsoft Teams, such as new messages or team updates, using specified configurations.',
|
||||
subtitle: 'Microsoft Teams Trigger',
|
||||
defaults: {
|
||||
name: 'Microsoft Teams Trigger',
|
||||
},
|
||||
credentials: [
|
||||
{
|
||||
name: 'microsoftTeamsOAuth2Api',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
inputs: [],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
responseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Trigger On',
|
||||
name: 'event',
|
||||
type: 'options',
|
||||
default: 'newChannelMessage',
|
||||
options: [
|
||||
{
|
||||
name: 'New Channel',
|
||||
value: 'newChannel',
|
||||
description: 'A new channel is created',
|
||||
},
|
||||
{
|
||||
name: 'New Channel Message',
|
||||
value: 'newChannelMessage',
|
||||
description: 'A message is posted to a channel',
|
||||
},
|
||||
{
|
||||
name: 'New Chat',
|
||||
value: 'newChat',
|
||||
description: 'A new chat is created',
|
||||
},
|
||||
{
|
||||
name: 'New Chat Message',
|
||||
value: 'newChatMessage',
|
||||
description: 'A message is posted to a chat',
|
||||
},
|
||||
{
|
||||
name: 'New Team Member',
|
||||
value: 'newTeamMember',
|
||||
description: 'A new member is added to a team',
|
||||
},
|
||||
],
|
||||
description: 'Select the event to trigger the workflow',
|
||||
},
|
||||
{
|
||||
displayName: 'Watch All Teams',
|
||||
name: 'watchAllTeams',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to watch for the event in all the available teams',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['newChannel', 'newChannelMessage', 'newTeamMember'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Team',
|
||||
name: 'teamId',
|
||||
type: 'resourceLocator',
|
||||
default: {
|
||||
mode: 'list',
|
||||
value: '',
|
||||
},
|
||||
required: true,
|
||||
description: 'Select a team from the list, enter an ID or a URL',
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a team...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getTeams',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: 'e.g., 61165b04-e4cc-4026-b43f-926b4e2a7182',
|
||||
},
|
||||
{
|
||||
displayName: 'By URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
placeholder:
|
||||
'e.g., https://teams.microsoft.com/l/team/19%3A...groupId=your-team-id&tenantId=...',
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: /groupId=([0-9a-fA-F-]{36})/,
|
||||
},
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['newChannel', 'newChannelMessage', 'newTeamMember'],
|
||||
watchAllTeams: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Watch All Channels',
|
||||
name: 'watchAllChannels',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to watch for the event in all the available channels',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['newChannelMessage'],
|
||||
watchAllTeams: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Channel',
|
||||
name: 'channelId',
|
||||
type: 'resourceLocator',
|
||||
default: {
|
||||
mode: 'list',
|
||||
value: '',
|
||||
},
|
||||
required: true,
|
||||
description: 'Select a channel from the list, enter an ID or a URL',
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a channel...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getChannels',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: 'e.g., 19:-xlxyqXNSCxpI1SDzgQ_L9ZvzSR26pgphq1BJ9y7QJE1@thread.tacv2',
|
||||
},
|
||||
{
|
||||
displayName: 'By URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
placeholder: 'e.g., https://teams.microsoft.com/l/channel/19%3A...@thread.tacv2/...',
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: /channel\/([^\/?]+)/,
|
||||
},
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['newChannelMessage'],
|
||||
watchAllTeams: [false],
|
||||
watchAllChannels: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Watch All Chats',
|
||||
name: 'watchAllChats',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to watch for the event in all the available chats',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['newChatMessage'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Chat',
|
||||
name: 'chatId',
|
||||
type: 'resourceLocator',
|
||||
default: {
|
||||
mode: 'list',
|
||||
value: '',
|
||||
},
|
||||
required: true,
|
||||
description: 'Select a chat from the list, enter an ID or a URL',
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a chat...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getChats',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: '19:7e2f1174-e8ee-4859-b8b1-a8d1cc63d276@unq.gbl.spaces',
|
||||
},
|
||||
{
|
||||
displayName: 'By URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
placeholder: 'https://teams.microsoft.com/_#/conversations/CHAT_ID',
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: /conversations\/([^\/?]+)/i,
|
||||
},
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: ['newChatMessage'],
|
||||
watchAllChats: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
listSearch,
|
||||
};
|
||||
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const event = this.getNodeParameter('event', 0) as string;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
|
||||
try {
|
||||
const subscriptions = (await microsoftApiRequestAllItems.call(
|
||||
this as unknown as ILoadOptionsFunctions,
|
||||
'value',
|
||||
'GET',
|
||||
'/v1.0/subscriptions',
|
||||
)) as SubscriptionResponse[];
|
||||
|
||||
const matchingSubscriptions = subscriptions.filter(
|
||||
(subscription) => subscription.notificationUrl === webhookUrl,
|
||||
);
|
||||
|
||||
const now = new Date();
|
||||
const thresholdMs = 5 * 60 * 1000;
|
||||
const validSubscriptions = matchingSubscriptions.filter((subscription) => {
|
||||
const expiration = new Date(subscription.expirationDateTime);
|
||||
return expiration.getTime() - now.getTime() > thresholdMs;
|
||||
});
|
||||
|
||||
const resourcePaths = await getResourcePath.call(this, event);
|
||||
const requiredResources = Array.isArray(resourcePaths) ? resourcePaths : [resourcePaths];
|
||||
|
||||
const subscribedResources = validSubscriptions.map((sub) => sub.resource);
|
||||
const allResourcesSubscribed = requiredResources.every((resource) =>
|
||||
subscribedResources.includes(resource),
|
||||
);
|
||||
|
||||
if (allResourcesSubscribed) {
|
||||
webhookData.subscriptionIds = validSubscriptions.map((sub) => sub.id);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const event = this.getNodeParameter('event', 0) as string;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
|
||||
if (!webhookUrl?.startsWith('https://')) {
|
||||
throw new NodeApiError(this.getNode(), {
|
||||
message: 'Invalid Notification URL',
|
||||
description: `The webhook URL "${webhookUrl}" is invalid. Microsoft Graph requires an HTTPS URL.`,
|
||||
});
|
||||
}
|
||||
|
||||
const resourcePaths = await getResourcePath.call(this, event);
|
||||
const subscriptionIds: string[] = [];
|
||||
|
||||
if (Array.isArray(resourcePaths)) {
|
||||
await Promise.all(
|
||||
resourcePaths.map(async (resource) => {
|
||||
const subscription = await createSubscription.call(this, webhookUrl, resource);
|
||||
subscriptionIds.push(subscription.id);
|
||||
return subscription;
|
||||
}),
|
||||
);
|
||||
|
||||
webhookData.subscriptionIds = subscriptionIds;
|
||||
} else {
|
||||
const subscription = await createSubscription.call(this, webhookUrl, resourcePaths);
|
||||
webhookData.subscriptionIds = [subscription.id];
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const storedIds = webhookData.subscriptionIds as string[] | undefined;
|
||||
|
||||
if (!Array.isArray(storedIds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(
|
||||
storedIds.map(async (subscriptionId) => {
|
||||
try {
|
||||
await microsoftApiRequest.call(
|
||||
this as unknown as IExecuteFunctions,
|
||||
'DELETE',
|
||||
`/v1.0/subscriptions/${subscriptionId}`,
|
||||
);
|
||||
} catch (error) {
|
||||
if ((error as JsonObject).httpStatusCode !== 404) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
delete webhookData.subscriptionIds;
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
const res = this.getResponseObject();
|
||||
|
||||
// Handle Microsoft Graph validation request
|
||||
if (req.query.validationToken) {
|
||||
res.status(200).send(req.query.validationToken);
|
||||
return { noWebhookResponse: true };
|
||||
}
|
||||
|
||||
const eventNotifications = req.body.value as WebhookNotification[];
|
||||
const response: IWebhookResponseData = {
|
||||
workflowData: eventNotifications.map((event) => [
|
||||
{
|
||||
json: (event.resourceData as IDataObject) ?? event,
|
||||
} as INodeExecutionData,
|
||||
]),
|
||||
};
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.context": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"isArchived": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"membershipType": {
|
||||
"type": "string"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.context": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"isArchived": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"membershipType": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"isArchived": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"membershipType": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 3
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.context": {
|
||||
"type": "string"
|
||||
},
|
||||
"body": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"channelIdentity": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"channelId": {
|
||||
"type": "string"
|
||||
},
|
||||
"teamId": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"chatId": {
|
||||
"type": "null"
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"deletedDateTime": {
|
||||
"type": "null"
|
||||
},
|
||||
"etag": {
|
||||
"type": "string"
|
||||
},
|
||||
"eventDetail": {
|
||||
"type": "null"
|
||||
},
|
||||
"from": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "null"
|
||||
},
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"importance": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastEditedDateTime": {
|
||||
"type": "null"
|
||||
},
|
||||
"lastModifiedDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"locale": {
|
||||
"type": "string"
|
||||
},
|
||||
"messageType": {
|
||||
"type": "string"
|
||||
},
|
||||
"onBehalfOf": {
|
||||
"type": "null"
|
||||
},
|
||||
"policyViolation": {
|
||||
"type": "null"
|
||||
},
|
||||
"subject": {
|
||||
"type": "null"
|
||||
},
|
||||
"summary": {
|
||||
"type": "null"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"attachments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"teamsAppId": {
|
||||
"type": "null"
|
||||
},
|
||||
"thumbnailUrl": {
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"channelIdentity": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"channelId": {
|
||||
"type": "string"
|
||||
},
|
||||
"teamId": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"chatId": {
|
||||
"type": "null"
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"etag": {
|
||||
"type": "string"
|
||||
},
|
||||
"from": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"importance": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastModifiedDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"locale": {
|
||||
"type": "string"
|
||||
},
|
||||
"mentions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"mentioned": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "null"
|
||||
},
|
||||
"conversation": {
|
||||
"type": "null"
|
||||
},
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"tag": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mentionText": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"messageType": {
|
||||
"type": "string"
|
||||
},
|
||||
"policyViolation": {
|
||||
"type": "null"
|
||||
},
|
||||
"reactions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"reactionContentUrl": {
|
||||
"type": "null"
|
||||
},
|
||||
"reactionType": {
|
||||
"type": "string"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "null"
|
||||
},
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"replyToId": {
|
||||
"type": "null"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.context": {
|
||||
"type": "string"
|
||||
},
|
||||
"body": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"channelIdentity": {
|
||||
"type": "null"
|
||||
},
|
||||
"chatId": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"deletedDateTime": {
|
||||
"type": "null"
|
||||
},
|
||||
"etag": {
|
||||
"type": "string"
|
||||
},
|
||||
"eventDetail": {
|
||||
"type": "null"
|
||||
},
|
||||
"from": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "null"
|
||||
},
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"importance": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastEditedDateTime": {
|
||||
"type": "null"
|
||||
},
|
||||
"lastModifiedDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"locale": {
|
||||
"type": "string"
|
||||
},
|
||||
"messageType": {
|
||||
"type": "string"
|
||||
},
|
||||
"policyViolation": {
|
||||
"type": "null"
|
||||
},
|
||||
"replyToId": {
|
||||
"type": "null"
|
||||
},
|
||||
"subject": {
|
||||
"type": "null"
|
||||
},
|
||||
"summary": {
|
||||
"type": "null"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "null"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
+215
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.context": {
|
||||
"type": "string"
|
||||
},
|
||||
"attachments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentUrl": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "null"
|
||||
},
|
||||
"teamsAppId": {
|
||||
"type": "null"
|
||||
},
|
||||
"thumbnailUrl": {
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"channelIdentity": {
|
||||
"type": "null"
|
||||
},
|
||||
"chatId": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"etag": {
|
||||
"type": "string"
|
||||
},
|
||||
"from": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"importance": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastEditedDateTime": {
|
||||
"type": "null"
|
||||
},
|
||||
"lastModifiedDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"locale": {
|
||||
"type": "string"
|
||||
},
|
||||
"mentions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"mentioned": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"applicationIdentityType": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"conversation": {
|
||||
"type": "null"
|
||||
},
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"tag": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mentionText": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"messageType": {
|
||||
"type": "string"
|
||||
},
|
||||
"policyViolation": {
|
||||
"type": "null"
|
||||
},
|
||||
"reactions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"reactionContentUrl": {
|
||||
"type": "null"
|
||||
},
|
||||
"reactionType": {
|
||||
"type": "string"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "null"
|
||||
},
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"replyToId": {
|
||||
"type": "null"
|
||||
},
|
||||
"summary": {
|
||||
"type": "null"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "null"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"attachments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"teamsAppId": {
|
||||
"type": "null"
|
||||
},
|
||||
"thumbnailUrl": {
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"contentType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"channelIdentity": {
|
||||
"type": "null"
|
||||
},
|
||||
"chatId": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"etag": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"importance": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastModifiedDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"locale": {
|
||||
"type": "string"
|
||||
},
|
||||
"mentions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"mentioned": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"tag": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mentionText": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"messageType": {
|
||||
"type": "string"
|
||||
},
|
||||
"policyViolation": {
|
||||
"type": "null"
|
||||
},
|
||||
"reactions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "string"
|
||||
},
|
||||
"reactionContentUrl": {
|
||||
"type": "null"
|
||||
},
|
||||
"reactionType": {
|
||||
"type": "string"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "null"
|
||||
},
|
||||
"device": {
|
||||
"type": "null"
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.type": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayName": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "string"
|
||||
},
|
||||
"userIdentityType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"replyToId": {
|
||||
"type": "null"
|
||||
},
|
||||
"webUrl": {
|
||||
"type": "null"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"approved": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": 2
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.context": {
|
||||
"type": "string"
|
||||
},
|
||||
"@odata.etag": {
|
||||
"type": "string"
|
||||
},
|
||||
"activeChecklistItemCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"assigneePriority": {
|
||||
"type": "string"
|
||||
},
|
||||
"bucketId": {
|
||||
"type": "string"
|
||||
},
|
||||
"checklistItemCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"completedBy": {
|
||||
"type": "null"
|
||||
},
|
||||
"completedDateTime": {
|
||||
"type": "null"
|
||||
},
|
||||
"conversationThreadId": {
|
||||
"type": "null"
|
||||
},
|
||||
"createdBy": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"displayName": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"displayName": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasDescription": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"orderHint": {
|
||||
"type": "string"
|
||||
},
|
||||
"percentComplete": {
|
||||
"type": "integer"
|
||||
},
|
||||
"planId": {
|
||||
"type": "string"
|
||||
},
|
||||
"previewType": {
|
||||
"type": "string"
|
||||
},
|
||||
"priority": {
|
||||
"type": "integer"
|
||||
},
|
||||
"referenceCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"startDateTime": {
|
||||
"type": "null"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@odata.etag": {
|
||||
"type": "string"
|
||||
},
|
||||
"activeChecklistItemCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"assigneePriority": {
|
||||
"type": "string"
|
||||
},
|
||||
"checklistItemCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"createdBy": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"displayName": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"user": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"displayName": {
|
||||
"type": "null"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"createdDateTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"hasDescription": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"orderHint": {
|
||||
"type": "string"
|
||||
},
|
||||
"percentComplete": {
|
||||
"type": "integer"
|
||||
},
|
||||
"planId": {
|
||||
"type": "string"
|
||||
},
|
||||
"previewType": {
|
||||
"type": "string"
|
||||
},
|
||||
"priority": {
|
||||
"type": "integer"
|
||||
},
|
||||
"referenceCount": {
|
||||
"type": "integer"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2381.4 2354.5"><path fill="#5558af" d="M2015.6 899.2c19.5 19.5 42.5 35 67.9 45.8 53 22.2 112.7 22.2 165.8 0 51.2-21.8 92-62.5 113.7-113.7 22.2-53 22.2-112.7 0-165.8-21.8-51.2-62.5-92-113.7-113.7-53-22.2-112.7-22.2-165.8 0-51.2 21.8-92 62.5-113.7 113.7-22.2 53-22.2 112.7 0 165.8 10.8 25.3 26.4 48.4 45.8 67.9m-62.4 197.8v642.1h107c36.8-.2 73.4-3.6 109.5-10.4 36.3-6.4 71.3-18.6 103.7-36.2 30.6-16.6 57-40 77.3-68.2 21.3-31.3 32-68.6 30.5-106.5V1097zm-346.8-269.2c28.4.2 56.6-5.5 82.8-16.7 51.2-21.8 91.9-62.5 113.6-113.7 22.2-53 22.2-112.7-.1-165.8-21.8-51.2-62.5-92-113.7-113.7-26.2-11.2-54.4-16.9-82.9-16.7-28.3-.2-56.3 5.5-82.3 16.7-19.4 8.3-25.5 19.1-52.2 32.1v329c26.8 13.1 32.8 23.8 52.2 32.1 26.1 11.3 54.2 16.9 82.6 16.7m-134.8 1081.1c26.8 5.8 36.4 10.3 55.4 12.9 20.8 3 41.8 4.5 62.8 4.6 32.4-.2 64.8-3.6 96.5-10.4 32.3-6.5 63.3-18.6 91.5-35.7 27.7-17 51-40.2 68.2-67.7 19-32.1 28.3-69.1 26.9-106.4v-743h-401.3zM0 2113.7l1391.3 240.8V0L0 240.8z"/><path fill="#fff" d="m1016.7 722.4-642.1 39.1v148.1l240.8-9.7v686.7l160.5 9.4V893.6l240.8-10.7z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,8 @@
|
||||
export const credentials = {
|
||||
microsoftTeamsOAuth2Api: {
|
||||
scope: 'openid',
|
||||
oauthTokenData: {
|
||||
access_token: 'token',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,232 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { MicrosoftTeamsTrigger } from '../../MicrosoftTeamsTrigger.node';
|
||||
import { microsoftApiRequest, microsoftApiRequestAllItems } from '../../v2/transport';
|
||||
|
||||
jest.mock('../../v2/transport', () => ({
|
||||
microsoftApiRequest: {
|
||||
call: jest.fn(),
|
||||
},
|
||||
microsoftApiRequestAllItems: {
|
||||
call: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('Microsoft Teams Trigger Node', () => {
|
||||
let mockWebhookFunctions: any;
|
||||
|
||||
beforeEach(() => {
|
||||
mockWebhookFunctions = mock();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('webhookMethods', () => {
|
||||
describe('checkExists', () => {
|
||||
it('should return true if the subscription exists', async () => {
|
||||
(microsoftApiRequestAllItems.call as jest.Mock).mockResolvedValue([
|
||||
{
|
||||
id: 'sub1',
|
||||
notificationUrl: 'https://webhook.url',
|
||||
resource: '/me/chats',
|
||||
expirationDateTime: new Date(Date.now() + 3600000).toISOString(),
|
||||
},
|
||||
]);
|
||||
|
||||
mockWebhookFunctions.getNodeWebhookUrl.mockReturnValue('https://webhook.url');
|
||||
mockWebhookFunctions.getWorkflowStaticData.mockReturnValue({
|
||||
node: {
|
||||
subscriptionIds: ['sub1'],
|
||||
},
|
||||
});
|
||||
|
||||
mockWebhookFunctions.getNodeParameter.mockImplementation((paramName: string) => {
|
||||
if (paramName === 'event') return 'newChat';
|
||||
return false;
|
||||
});
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhookMethods.default.checkExists.call(
|
||||
mockWebhookFunctions,
|
||||
);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
it('should return false if the subscription does not exist', async () => {
|
||||
(microsoftApiRequestAllItems.call as jest.Mock).mockResolvedValue([]);
|
||||
|
||||
mockWebhookFunctions.getNodeWebhookUrl.mockReturnValue('https://webhook.url');
|
||||
|
||||
mockWebhookFunctions.getWorkflowStaticData.mockReturnValue({
|
||||
node: {},
|
||||
});
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhookMethods.default.checkExists.call(
|
||||
mockWebhookFunctions,
|
||||
);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should throw an error if the API request fails', async () => {
|
||||
(microsoftApiRequestAllItems.call as jest.Mock).mockRejectedValue(
|
||||
new Error('API request failed'),
|
||||
);
|
||||
|
||||
mockWebhookFunctions.getNodeWebhookUrl.mockReturnValue('https://webhook.url');
|
||||
mockWebhookFunctions.getWorkflowStaticData.mockReturnValue({
|
||||
node: {},
|
||||
});
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhookMethods.default.checkExists.call(
|
||||
mockWebhookFunctions,
|
||||
);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('create', () => {
|
||||
it('should create a subscription successfully', async () => {
|
||||
(microsoftApiRequest.call as jest.Mock).mockResolvedValue({ id: 'subscription123' });
|
||||
|
||||
mockWebhookFunctions.getNodeWebhookUrl.mockReturnValue('https://webhook.url');
|
||||
mockWebhookFunctions.getNodeParameter.mockReturnValue('newChat');
|
||||
mockWebhookFunctions.getWorkflowStaticData.mockReturnValue({
|
||||
node: {
|
||||
subscriptionIds: [],
|
||||
},
|
||||
});
|
||||
|
||||
(microsoftApiRequest.call as jest.Mock).mockResolvedValue({
|
||||
value: [{ id: 'team1', displayName: 'Team 1' }],
|
||||
});
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhookMethods.default.create.call(
|
||||
mockWebhookFunctions,
|
||||
);
|
||||
|
||||
expect(result).toBe(true);
|
||||
expect(microsoftApiRequest.call).toHaveBeenCalledWith(
|
||||
mockWebhookFunctions,
|
||||
'POST',
|
||||
'/v1.0/subscriptions',
|
||||
expect.objectContaining({
|
||||
changeType: 'created',
|
||||
notificationUrl: 'https://webhook.url',
|
||||
resource: '/me/chats',
|
||||
expirationDateTime: expect.any(String),
|
||||
latestSupportedTlsVersion: 'v1_2',
|
||||
lifecycleNotificationUrl: 'https://webhook.url',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error if the URL is invalid', async () => {
|
||||
mockWebhookFunctions.getNodeWebhookUrl.mockReturnValue('invalid-url');
|
||||
await expect(
|
||||
new MicrosoftTeamsTrigger().webhookMethods.default.create.call(mockWebhookFunctions),
|
||||
).rejects.toThrow('Invalid Notification URL');
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
it('should delete subscriptions using stored IDs and clean static data', async () => {
|
||||
const mockWebhookData = {
|
||||
subscriptionIds: ['subscription123'],
|
||||
};
|
||||
|
||||
mockWebhookFunctions.getWorkflowStaticData.mockReturnValue(mockWebhookData);
|
||||
|
||||
(microsoftApiRequest.call as jest.Mock).mockResolvedValue({});
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhookMethods.default.delete.call(
|
||||
mockWebhookFunctions,
|
||||
);
|
||||
expect(result).toBe(true);
|
||||
expect(microsoftApiRequest.call).toHaveBeenCalledWith(
|
||||
mockWebhookFunctions,
|
||||
'DELETE',
|
||||
'/v1.0/subscriptions/subscription123',
|
||||
);
|
||||
expect(mockWebhookData.subscriptionIds).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return false if no subscription matches', async () => {
|
||||
(microsoftApiRequestAllItems.call as jest.Mock).mockResolvedValue([]);
|
||||
mockWebhookFunctions.getNodeWebhookUrl.mockReturnValue('https://webhook.url');
|
||||
mockWebhookFunctions.getWorkflowStaticData.mockReturnValue({
|
||||
node: {
|
||||
subscriptionIds: [],
|
||||
},
|
||||
});
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhookMethods.default.delete.call(
|
||||
mockWebhookFunctions,
|
||||
);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should throw an error if the API request fails', async () => {
|
||||
(microsoftApiRequestAllItems.call as jest.Mock).mockResolvedValue([
|
||||
{ id: 'subscription123', notificationUrl: 'https://webhook.url' },
|
||||
]);
|
||||
(microsoftApiRequest.call as jest.Mock).mockRejectedValue(new Error('API request failed'));
|
||||
mockWebhookFunctions.getNodeWebhookUrl.mockReturnValue('https://webhook.url');
|
||||
mockWebhookFunctions.getWorkflowStaticData.mockReturnValue({
|
||||
node: {
|
||||
subscriptionIds: ['subscription123'],
|
||||
},
|
||||
});
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhookMethods.default.delete.call(
|
||||
mockWebhookFunctions,
|
||||
);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('webhook', () => {
|
||||
it('should handle Microsoft Graph validation request correctly', async () => {
|
||||
const mockRequest = {
|
||||
query: {
|
||||
validationToken: 'validation-token',
|
||||
},
|
||||
};
|
||||
const mockResponse = {
|
||||
status: jest.fn().mockReturnThis(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
|
||||
mockWebhookFunctions.getRequestObject.mockReturnValue(mockRequest);
|
||||
mockWebhookFunctions.getResponseObject.mockReturnValue(mockResponse);
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhook.call(mockWebhookFunctions);
|
||||
expect(mockResponse.status).toHaveBeenCalledWith(200);
|
||||
expect(mockResponse.send).toHaveBeenCalledWith('validation-token');
|
||||
expect(result.noWebhookResponse).toBe(true);
|
||||
});
|
||||
|
||||
it('should process incoming event notifications', async () => {
|
||||
const mockRequest = {
|
||||
body: {
|
||||
value: [{ resourceData: { message: 'test message' } }],
|
||||
},
|
||||
query: {},
|
||||
};
|
||||
const mockResponse = {
|
||||
status: jest.fn().mockReturnThis(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
|
||||
mockWebhookFunctions.getRequestObject.mockReturnValue(mockRequest);
|
||||
mockWebhookFunctions.getResponseObject.mockReturnValue(mockResponse);
|
||||
|
||||
const result = await new MicrosoftTeamsTrigger().webhook.call(mockWebhookFunctions);
|
||||
|
||||
expect(result.workflowData).toEqual([
|
||||
[
|
||||
{
|
||||
json: { message: 'test message' },
|
||||
},
|
||||
],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,209 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
fetchAllTeams,
|
||||
fetchAllChannels,
|
||||
createSubscription,
|
||||
getResourcePath,
|
||||
} from '../../v2/helpers/utils-trigger';
|
||||
import { microsoftApiRequest } from '../../v2/transport';
|
||||
|
||||
jest.mock('../../v2/transport', () => ({
|
||||
microsoftApiRequest: {
|
||||
call: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('Microsoft Teams Helpers Functions', () => {
|
||||
let mockLoadOptionsFunctions: any;
|
||||
let mockHookFunctions: any;
|
||||
|
||||
beforeEach(() => {
|
||||
mockLoadOptionsFunctions = mock();
|
||||
mockHookFunctions = mock();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('fetchAllTeams', () => {
|
||||
it('should fetch all teams and map them correctly', async () => {
|
||||
(microsoftApiRequest.call as jest.Mock).mockResolvedValue({
|
||||
value: [
|
||||
{ id: 'team1', displayName: 'Team 1' },
|
||||
{ id: 'team2', displayName: 'Team 2' },
|
||||
],
|
||||
});
|
||||
|
||||
const result = await fetchAllTeams.call(mockLoadOptionsFunctions);
|
||||
|
||||
expect(result).toEqual([
|
||||
{ id: 'team1', displayName: 'Team 1' },
|
||||
{ id: 'team2', displayName: 'Team 2' },
|
||||
]);
|
||||
expect(microsoftApiRequest.call).toHaveBeenCalledWith(
|
||||
mockLoadOptionsFunctions,
|
||||
'GET',
|
||||
'/v1.0/me/joinedTeams',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error if getTeams fails', async () => {
|
||||
(microsoftApiRequest.call as jest.Mock).mockRejectedValue(new Error('Failed to fetch teams'));
|
||||
|
||||
await expect(fetchAllTeams.call(mockLoadOptionsFunctions)).rejects.toThrow(
|
||||
'Failed to fetch teams',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetchAllChannels', () => {
|
||||
it('should fetch all channels for a team and map them correctly', async () => {
|
||||
(microsoftApiRequest.call as jest.Mock).mockResolvedValue({
|
||||
value: [
|
||||
{ id: 'channel1', displayName: 'Channel 1' },
|
||||
{ id: 'channel2', displayName: 'Channel 2' },
|
||||
],
|
||||
});
|
||||
|
||||
const result = await fetchAllChannels.call(mockLoadOptionsFunctions, 'team1');
|
||||
|
||||
expect(result).toEqual([
|
||||
{ id: 'channel1', displayName: 'Channel 1' },
|
||||
{ id: 'channel2', displayName: 'Channel 2' },
|
||||
]);
|
||||
expect(microsoftApiRequest.call).toHaveBeenCalledWith(
|
||||
mockLoadOptionsFunctions,
|
||||
'GET',
|
||||
'/v1.0/teams/team1/channels',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error if getChannels fails', async () => {
|
||||
(microsoftApiRequest.call as jest.Mock).mockRejectedValue(
|
||||
new Error('Failed to fetch channels'),
|
||||
);
|
||||
|
||||
await expect(fetchAllChannels.call(mockLoadOptionsFunctions, 'team1')).rejects.toThrow(
|
||||
'Failed to fetch channels',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createSubscription', () => {
|
||||
it('should create a subscription and return the subscription ID', async () => {
|
||||
(microsoftApiRequest.call as jest.Mock).mockResolvedValue({
|
||||
id: 'subscription123',
|
||||
resource: '/resource/path',
|
||||
notificationUrl: 'https://webhook.url',
|
||||
expirationDateTime: '2024-01-01T00:00:00Z',
|
||||
});
|
||||
|
||||
const result = await createSubscription.call(
|
||||
mockHookFunctions,
|
||||
'https://webhook.url',
|
||||
'/resource/path',
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
id: 'subscription123',
|
||||
resource: '/resource/path',
|
||||
notificationUrl: 'https://webhook.url',
|
||||
expirationDateTime: '2024-01-01T00:00:00Z',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw a NodeApiError if the API request fails', async () => {
|
||||
const error = new NodeApiError(mockHookFunctions.getNode(), {
|
||||
message: 'API request failed',
|
||||
httpCode: '400',
|
||||
});
|
||||
(microsoftApiRequest.call as jest.Mock).mockRejectedValue(error);
|
||||
|
||||
await expect(
|
||||
createSubscription.call(mockHookFunctions, 'https://webhook.url', '/resource/path'),
|
||||
).rejects.toThrow(NodeApiError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getResourcePath', () => {
|
||||
it('should return the correct resource path for newChat event', async () => {
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newChat');
|
||||
expect(result).toBe('/me/chats');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newChatMessage event with watchAllChats', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(true);
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newChatMessage');
|
||||
expect(result).toBe('/me/chats/getAllMessages');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newChatMessage event with chatId', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(false).mockReturnValueOnce('chat123');
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newChatMessage');
|
||||
expect(result).toBe('/chats/chat123/messages');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newChatMessage event with chatId missing', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(false);
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(undefined);
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newChatMessage');
|
||||
expect(result).toBe('/chats/undefined/messages');
|
||||
});
|
||||
it('should return the correct resource path for newChannel event', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(false);
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce('team123');
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newChannel');
|
||||
expect(result).toBe('/teams/team123/channels');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newChannel event with teamId missing', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(undefined);
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newChannel');
|
||||
expect(result).toBe('/teams/undefined/channels');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newChannelMessage event with a specific team and channel', async () => {
|
||||
mockHookFunctions.getNodeParameter
|
||||
.mockReturnValueOnce(false)
|
||||
.mockReturnValueOnce('team123')
|
||||
.mockReturnValueOnce(false)
|
||||
.mockReturnValueOnce('channel123');
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newChannelMessage');
|
||||
expect(result).toBe('/teams/team123/channels/channel123/messages');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newTeamMember event', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(false);
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce('team123');
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newTeamMember');
|
||||
expect(result).toBe('/teams/team123/members');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newTeamMember event with teamId missing', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(undefined);
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newTeamMember');
|
||||
expect(result).toBe('/teams/undefined/members');
|
||||
});
|
||||
|
||||
it('should return the correct resource path for newTeamMember event with watchAllTeams', async () => {
|
||||
mockHookFunctions.getNodeParameter.mockReturnValueOnce(true);
|
||||
|
||||
(microsoftApiRequest.call as jest.Mock).mockResolvedValueOnce({
|
||||
value: [
|
||||
{ id: 'team1', displayName: 'Team 1' },
|
||||
{ id: 'team2', displayName: 'Team 2' },
|
||||
],
|
||||
});
|
||||
|
||||
const result = await getResourcePath.call(mockHookFunctions, 'newTeamMember');
|
||||
expect(result).toEqual(['/teams/team1/members', '/teams/team2/members']);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, channel => create', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.post('/v1.0/teams/1644e7fe-547e-4223-a24f-922395865343/channels')
|
||||
.reply(200, {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/v1.0/$metadata#teams('1644e7fe-547e-4223-a24f-922395865343')/channels/$entity",
|
||||
id: '19:16259efabba44a66916d91dd91862a6f@thread.tacv2',
|
||||
createdDateTime: '2023-10-26T05:37:43.4798824Z',
|
||||
displayName: 'New Channel',
|
||||
description: 'new channel description',
|
||||
isFavoriteByDefault: null,
|
||||
email: '',
|
||||
webUrl:
|
||||
'https://teams.microsoft.com/l/channel/19%3a16259efabba44a66916d91dd91862a6f%40thread.tacv2/New+Channel?groupId=1644e7fe-547e-4223-a24f-922395865343&tenantId=tenantId-111-222-333',
|
||||
membershipType: 'private',
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['create.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"teamId": {
|
||||
"__rl": true,
|
||||
"value": "1644e7fe-547e-4223-a24f-922395865343",
|
||||
"mode": "list",
|
||||
"cachedResultName": "5w1hb7"
|
||||
},
|
||||
"name": "New Channel",
|
||||
"options": {
|
||||
"description": "new channel description",
|
||||
"type": "private"
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('1644e7fe-547e-4223-a24f-922395865343')/channels/$entity",
|
||||
"id": "19:16259efabba44a66916d91dd91862a6f@thread.tacv2",
|
||||
"createdDateTime": "2023-10-26T05:37:43.4798824Z",
|
||||
"displayName": "New Channel",
|
||||
"description": "new channel description",
|
||||
"isFavoriteByDefault": null,
|
||||
"email": "",
|
||||
"webUrl": "https://teams.microsoft.com/l/channel/19%3a16259efabba44a66916d91dd91862a6f%40thread.tacv2/New+Channel?groupId=1644e7fe-547e-4223-a24f-922395865343&tenantId=tenantId-111-222-333",
|
||||
"membershipType": "private"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "ec0b4e3d-2fd7-4fac-90e5-f18ecd620a8f",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, channel => deleteChannel', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.delete(
|
||||
'/v1.0/teams/1644e7fe-547e-4223-a24f-922395865343/channels/19:16259efabba44a66916d91dd91862a6f@thread.tacv2',
|
||||
)
|
||||
.reply(200, {});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['deleteChannel.workflow.json'],
|
||||
});
|
||||
});
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "deleteChannel",
|
||||
"teamId": {
|
||||
"__rl": true,
|
||||
"value": "1644e7fe-547e-4223-a24f-922395865343",
|
||||
"mode": "list",
|
||||
"cachedResultName": "5w1hb7"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "19:16259efabba44a66916d91dd91862a6f@thread.tacv2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "New Channel",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/channel/19%3A16259efabba44a66916d91dd91862a6f%40thread.tacv2/New%20Channel?groupId=1644e7fe-547e-4223-a24f-922395865343&tenantId=tenantId-111-222-333&allowXTenantAccess=False"
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "fb9028a2-b502-45f1-b907-825e8d754991",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, channel => get', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get(
|
||||
'/v1.0/teams/e25bae35-7bcc-4fb7-b4f2-0d5caef251fd/channels/19:dff84a49e5124cc89dff0192c621ea0f@thread.tacv2',
|
||||
)
|
||||
.reply(200, {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/v1.0/$metadata#teams('e25bae35-7bcc-4fb7-b4f2-0d5caef251fd')/channels/$entity",
|
||||
id: '19:dff84a49e5124cc89dff0192c621ea0f@thread.tacv2',
|
||||
createdDateTime: '2022-03-26T17:16:51Z',
|
||||
displayName: 'General',
|
||||
description: 'Description of Retail',
|
||||
isFavoriteByDefault: null,
|
||||
email: 'Retail@5w1hb7.onmicrosoft.com',
|
||||
tenantId: 'tenantId-111-222-333',
|
||||
webUrl:
|
||||
'https://teams.microsoft.com/l/channel/19%3Adff84a49e5124cc89dff0192c621ea0f%40thread.tacv2/General?groupId=e25bae35-7bcc-4fb7-b4f2-0d5caef251fd&tenantId=tenantId-111-222-333&allowXTenantAccess=True',
|
||||
membershipType: 'standard',
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['get.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "get",
|
||||
"teamId": {
|
||||
"__rl": true,
|
||||
"value": "e25bae35-7bcc-4fb7-b4f2-0d5caef251fd",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Retail"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "19:dff84a49e5124cc89dff0192c621ea0f@thread.tacv2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "General",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/channel/19%3Adff84a49e5124cc89dff0192c621ea0f%40thread.tacv2/Retail?groupId=e25bae35-7bcc-4fb7-b4f2-0d5caef251fd&tenantId=tenantId-111-222-333&allowXTenantAccess=False"
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('e25bae35-7bcc-4fb7-b4f2-0d5caef251fd')/channels/$entity",
|
||||
"id": "19:dff84a49e5124cc89dff0192c621ea0f@thread.tacv2",
|
||||
"createdDateTime": "2022-03-26T17:16:51Z",
|
||||
"displayName": "General",
|
||||
"description": "Description of Retail",
|
||||
"isFavoriteByDefault": null,
|
||||
"email": "Retail@5w1hb7.onmicrosoft.com",
|
||||
"tenantId": "tenantId-111-222-333",
|
||||
"webUrl": "https://teams.microsoft.com/l/channel/19%3Adff84a49e5124cc89dff0192c621ea0f%40thread.tacv2/General?groupId=e25bae35-7bcc-4fb7-b4f2-0d5caef251fd&tenantId=tenantId-111-222-333&allowXTenantAccess=True",
|
||||
"membershipType": "standard"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "021e8e46-fd28-4dfb-bd94-b288a8541940",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, channel => getAll', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/v1.0/teams/1111-2222-3333/channels')
|
||||
.reply(200, {
|
||||
value: [
|
||||
{
|
||||
id: '42:aaabbbccc.tacv2',
|
||||
createdDateTime: '2022-03-26T17:18:33Z',
|
||||
displayName: 'Sales West',
|
||||
description: 'Description of Sales West',
|
||||
isFavoriteByDefault: null,
|
||||
email: null,
|
||||
tenantId: 'tenantId-111-222-333',
|
||||
webUrl:
|
||||
'https://teams.microsoft.com/l/channel/threadId/Sales%20West?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False',
|
||||
membershipType: 'standard',
|
||||
},
|
||||
{
|
||||
id: '19:8662cdf2d8ff49eabdcf6364bc0fe3a2@thread.tacv2',
|
||||
createdDateTime: '2022-03-26T17:18:30Z',
|
||||
displayName: 'Sales East',
|
||||
description: 'Description of Sales West',
|
||||
isFavoriteByDefault: null,
|
||||
email: null,
|
||||
tenantId: 'tenantId-111-222-333',
|
||||
webUrl:
|
||||
'https://teams.microsoft.com/l/channel/19%3A8662cdf2d8ff49eabdcf6364bc0fe3a2%40thread.tacv2/Sales%20East?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False',
|
||||
membershipType: 'standard',
|
||||
},
|
||||
{
|
||||
id: '19:a95209ede91f4d5595ac944aeb172124@thread.tacv2',
|
||||
createdDateTime: '2022-03-26T17:18:16Z',
|
||||
displayName: 'General',
|
||||
description: 'Description of U.S. Sales',
|
||||
isFavoriteByDefault: null,
|
||||
email: 'U.S.Sales@5w1hb7.onmicrosoft.com',
|
||||
tenantId: 'tenantId-111-222-333',
|
||||
webUrl:
|
||||
'https://teams.microsoft.com/l/channel/19%3Aa95209ede91f4d5595ac944aeb172124%40thread.tacv2/U.S.%20Sales?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False',
|
||||
membershipType: 'standard',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "getAll",
|
||||
"teamId": {
|
||||
"__rl": true,
|
||||
"value": "1111-2222-3333",
|
||||
"mode": "list",
|
||||
"cachedResultName": "U.S. Sales"
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "42:aaabbbccc.tacv2",
|
||||
"createdDateTime": "2022-03-26T17:18:33Z",
|
||||
"displayName": "Sales West",
|
||||
"description": "Description of Sales West",
|
||||
"isFavoriteByDefault": null,
|
||||
"email": null,
|
||||
"tenantId": "tenantId-111-222-333",
|
||||
"webUrl": "https://teams.microsoft.com/l/channel/threadId/Sales%20West?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False",
|
||||
"membershipType": "standard"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "19:8662cdf2d8ff49eabdcf6364bc0fe3a2@thread.tacv2",
|
||||
"createdDateTime": "2022-03-26T17:18:30Z",
|
||||
"displayName": "Sales East",
|
||||
"description": "Description of Sales West",
|
||||
"isFavoriteByDefault": null,
|
||||
"email": null,
|
||||
"tenantId": "tenantId-111-222-333",
|
||||
"webUrl": "https://teams.microsoft.com/l/channel/19%3A8662cdf2d8ff49eabdcf6364bc0fe3a2%40thread.tacv2/Sales%20East?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False",
|
||||
"membershipType": "standard"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "19:a95209ede91f4d5595ac944aeb172124@thread.tacv2",
|
||||
"createdDateTime": "2022-03-26T17:18:16Z",
|
||||
"displayName": "General",
|
||||
"description": "Description of U.S. Sales",
|
||||
"isFavoriteByDefault": null,
|
||||
"email": "U.S.Sales@5w1hb7.onmicrosoft.com",
|
||||
"tenantId": "tenantId-111-222-333",
|
||||
"webUrl": "https://teams.microsoft.com/l/channel/19%3Aa95209ede91f4d5595ac944aeb172124%40thread.tacv2/U.S.%20Sales?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False",
|
||||
"membershipType": "standard"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "08f365b7-a03d-4d38-979e-edca8194d045",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, channel => update', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.patch(
|
||||
'/v1.0/teams/e25bae35-7bcc-4fb7-b4f2-0d5caef251fd/channels/19:b9daa3647ff8450bacaf39490d3e05e2@thread.tacv2',
|
||||
{ description: 'new channel description', displayName: 'New Deals' },
|
||||
)
|
||||
.reply(200, {});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['update.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "update",
|
||||
"teamId": {
|
||||
"__rl": true,
|
||||
"value": "e25bae35-7bcc-4fb7-b4f2-0d5caef251fd",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Retail"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "19:b9daa3647ff8450bacaf39490d3e05e2@thread.tacv2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Deals",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/channel/19%3Ab9daa3647ff8450bacaf39490d3e05e2%40thread.tacv2/Deals?groupId=e25bae35-7bcc-4fb7-b4f2-0d5caef251fd&tenantId=tenantId-111-222-333&allowXTenantAccess=False"
|
||||
},
|
||||
"name": "New Deals",
|
||||
"options": {
|
||||
"description": "new channel description"
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "75151dab-2cd1-42ee-9a01-e61cf6a1245e",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, channelMessage => create', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.post('/beta/teams/1111-2222-3333/channels/42:aaabbbccc.tacv2/messages', {
|
||||
body: { content: 'new sale', contentType: 'html' },
|
||||
})
|
||||
.reply(200, {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/beta/$metadata#teams('1111-2222-3333')/channels('threadId')/messages/$entity",
|
||||
id: '1698324478896',
|
||||
replyToId: null,
|
||||
etag: '1698324478896',
|
||||
messageType: 'message',
|
||||
createdDateTime: '2023-10-26T12:47:58.896Z',
|
||||
lastModifiedDateTime: '2023-10-26T12:47:58.896Z',
|
||||
lastEditedDateTime: null,
|
||||
deletedDateTime: null,
|
||||
subject: null,
|
||||
summary: null,
|
||||
chatId: null,
|
||||
importance: 'normal',
|
||||
locale: 'en-us',
|
||||
webUrl:
|
||||
'https://teams.microsoft.com/l/message/threadId/1698324478896?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&createdTime=1698324478896&parentMessageId=1698324478896',
|
||||
onBehalfOf: null,
|
||||
policyViolation: null,
|
||||
eventDetail: null,
|
||||
from: {
|
||||
application: null,
|
||||
device: null,
|
||||
user: {
|
||||
'@odata.type': '#microsoft.graph.teamworkUserIdentity',
|
||||
id: '11111-2222-3333',
|
||||
displayName: 'My Name',
|
||||
userIdentityType: 'aadUser',
|
||||
},
|
||||
},
|
||||
body: {
|
||||
contentType: 'html',
|
||||
content: 'new sale',
|
||||
},
|
||||
channelIdentity: {
|
||||
teamId: '1111-2222-3333',
|
||||
channelId: '42:aaabbbccc.tacv2',
|
||||
},
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
reactions: [],
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['create.workflow.json'],
|
||||
});
|
||||
});
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "channelMessage",
|
||||
"teamId": {
|
||||
"__rl": true,
|
||||
"value": "1111-2222-3333",
|
||||
"mode": "list",
|
||||
"cachedResultName": "U.S. Sales"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "42:aaabbbccc.tacv2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sales West",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/channel/threadId/Sales%20West?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False"
|
||||
},
|
||||
"contentType": "html",
|
||||
"message": "new sale",
|
||||
"options": {
|
||||
"includeLinkToWorkflow": false
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/beta/$metadata#teams('1111-2222-3333')/channels('threadId')/messages/$entity",
|
||||
"id": "1698324478896",
|
||||
"replyToId": null,
|
||||
"etag": "1698324478896",
|
||||
"messageType": "message",
|
||||
"createdDateTime": "2023-10-26T12:47:58.896Z",
|
||||
"lastModifiedDateTime": "2023-10-26T12:47:58.896Z",
|
||||
"lastEditedDateTime": null,
|
||||
"deletedDateTime": null,
|
||||
"subject": null,
|
||||
"summary": null,
|
||||
"chatId": null,
|
||||
"importance": "normal",
|
||||
"locale": "en-us",
|
||||
"webUrl": "https://teams.microsoft.com/l/message/threadId/1698324478896?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&createdTime=1698324478896&parentMessageId=1698324478896",
|
||||
"onBehalfOf": null,
|
||||
"policyViolation": null,
|
||||
"eventDetail": null,
|
||||
"from": {
|
||||
"application": null,
|
||||
"device": null,
|
||||
"user": {
|
||||
"@odata.type": "#microsoft.graph.teamworkUserIdentity",
|
||||
"id": "11111-2222-3333",
|
||||
"displayName": "My Name",
|
||||
"userIdentityType": "aadUser"
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"contentType": "html",
|
||||
"content": "new sale"
|
||||
},
|
||||
"channelIdentity": {
|
||||
"teamId": "1111-2222-3333",
|
||||
"channelId": "42:aaabbbccc.tacv2"
|
||||
},
|
||||
"attachments": [],
|
||||
"mentions": [],
|
||||
"reactions": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "30cec397-a737-41b8-8da2-dff4d293ce70",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, channelMessage => getAll', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/beta/teams/1111-2222-3333/channels/42:aaabbbccc.tacv2/messages')
|
||||
.reply(200, {
|
||||
value: [
|
||||
{
|
||||
id: '1698130964682',
|
||||
replyToId: null,
|
||||
etag: '1698130964682',
|
||||
messageType: 'message',
|
||||
createdDateTime: '2023-10-24T07:02:44.682Z',
|
||||
lastModifiedDateTime: '2023-10-24T07:02:44.682Z',
|
||||
lastEditedDateTime: null,
|
||||
deletedDateTime: null,
|
||||
subject: '',
|
||||
summary: null,
|
||||
chatId: null,
|
||||
importance: 'normal',
|
||||
locale: 'en-us',
|
||||
webUrl:
|
||||
'https://teams.microsoft.com/l/message/threadId/1698130964682?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&createdTime=1698130964682&parentMessageId=1698130964682',
|
||||
onBehalfOf: null,
|
||||
policyViolation: null,
|
||||
eventDetail: null,
|
||||
from: {
|
||||
application: null,
|
||||
device: null,
|
||||
user: {
|
||||
'@odata.type': '#microsoft.graph.teamworkUserIdentity',
|
||||
id: '11111-2222-3333',
|
||||
displayName: 'My Name',
|
||||
userIdentityType: 'aadUser',
|
||||
tenantId: 'tenantId-111-222-333',
|
||||
},
|
||||
},
|
||||
body: {
|
||||
contentType: 'html',
|
||||
content:
|
||||
'<div>I added a tab at the top of this channel. Check it out!</div><attachment id="tab::f22a0494-6f7c-4512-85c5-e4ce72ce142a"></attachment>',
|
||||
},
|
||||
channelIdentity: {
|
||||
teamId: '1111-2222-3333',
|
||||
channelId: '42:aaabbbccc.tacv2',
|
||||
},
|
||||
attachments: [
|
||||
{
|
||||
id: 'tab::f22a0494-6f7c-4512-85c5-e4ce72ce142a',
|
||||
contentType: 'tabReference',
|
||||
contentUrl: null,
|
||||
content: null,
|
||||
name: 'Tasks',
|
||||
thumbnailUrl: null,
|
||||
teamsAppId: null,
|
||||
},
|
||||
],
|
||||
mentions: [],
|
||||
reactions: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
});
|
||||
});
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "channelMessage",
|
||||
"operation": "getAll",
|
||||
"teamId": {
|
||||
"__rl": true,
|
||||
"value": "1111-2222-3333",
|
||||
"mode": "list",
|
||||
"cachedResultName": "U.S. Sales"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "42:aaabbbccc.tacv2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sales West",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/channel/threadId/Sales%20West?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&allowXTenantAccess=False"
|
||||
},
|
||||
"returnAll": true
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1698130964682",
|
||||
"replyToId": null,
|
||||
"etag": "1698130964682",
|
||||
"messageType": "message",
|
||||
"createdDateTime": "2023-10-24T07:02:44.682Z",
|
||||
"lastModifiedDateTime": "2023-10-24T07:02:44.682Z",
|
||||
"lastEditedDateTime": null,
|
||||
"deletedDateTime": null,
|
||||
"subject": "",
|
||||
"summary": null,
|
||||
"chatId": null,
|
||||
"importance": "normal",
|
||||
"locale": "en-us",
|
||||
"webUrl": "https://teams.microsoft.com/l/message/threadId/1698130964682?groupId=1111-2222-3333&tenantId=tenantId-111-222-333&createdTime=1698130964682&parentMessageId=1698130964682",
|
||||
"onBehalfOf": null,
|
||||
"policyViolation": null,
|
||||
"eventDetail": null,
|
||||
"from": {
|
||||
"application": null,
|
||||
"device": null,
|
||||
"user": {
|
||||
"@odata.type": "#microsoft.graph.teamworkUserIdentity",
|
||||
"id": "11111-2222-3333",
|
||||
"displayName": "My Name",
|
||||
"userIdentityType": "aadUser",
|
||||
"tenantId": "tenantId-111-222-333"
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"contentType": "html",
|
||||
"content": "<div>I added a tab at the top of this channel. Check it out!</div><attachment id=\"tab::f22a0494-6f7c-4512-85c5-e4ce72ce142a\"></attachment>"
|
||||
},
|
||||
"channelIdentity": {
|
||||
"teamId": "1111-2222-3333",
|
||||
"channelId": "42:aaabbbccc.tacv2"
|
||||
},
|
||||
"attachments": [
|
||||
{
|
||||
"id": "tab::f22a0494-6f7c-4512-85c5-e4ce72ce142a",
|
||||
"contentType": "tabReference",
|
||||
"contentUrl": null,
|
||||
"content": null,
|
||||
"name": "Tasks",
|
||||
"thumbnailUrl": null,
|
||||
"teamsAppId": null
|
||||
}
|
||||
],
|
||||
"mentions": [],
|
||||
"reactions": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "d89de79a-1819-4d29-b781-a1f3f00b4a2e",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, chatMessage => create', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.post('/v1.0/chats/19:ebed9ad42c904d6c83adf0db360053ec@thread.v2/messages')
|
||||
.reply(200, {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/v1.0/$metadata#chats('19%3Aebed9ad42c904d6c83adf0db360053ec%40thread.v2')/messages/$entity",
|
||||
id: '1698378560692',
|
||||
replyToId: null,
|
||||
etag: '1698378560692',
|
||||
messageType: 'message',
|
||||
createdDateTime: '2023-10-27T03:49:20.692Z',
|
||||
lastModifiedDateTime: '2023-10-27T03:49:20.692Z',
|
||||
lastEditedDateTime: null,
|
||||
deletedDateTime: null,
|
||||
subject: null,
|
||||
summary: null,
|
||||
chatId: '19:ebed9ad42c904d6c83adf0db360053ec@thread.v2',
|
||||
importance: 'normal',
|
||||
locale: 'en-us',
|
||||
webUrl: null,
|
||||
channelIdentity: null,
|
||||
policyViolation: null,
|
||||
eventDetail: null,
|
||||
from: {
|
||||
application: null,
|
||||
device: null,
|
||||
user: {
|
||||
'@odata.type': '#microsoft.graph.teamworkUserIdentity',
|
||||
id: '11111-2222-3333',
|
||||
displayName: 'Michael Kret',
|
||||
userIdentityType: 'aadUser',
|
||||
},
|
||||
},
|
||||
body: {
|
||||
contentType: 'html',
|
||||
content:
|
||||
'Hello!<br>\n<br>\n<em> Powered by <a href="http://localhost:5678/workflow/i3NYGF0LXV4qDFV9?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363">this n8n workflow</a> </em>',
|
||||
},
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
reactions: [],
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['create.workflow.json'],
|
||||
});
|
||||
});
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "chatMessage",
|
||||
"chatId": {
|
||||
"__rl": true,
|
||||
"value": "19:ebed9ad42c904d6c83adf0db360053ec@thread.v2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Grady Archie, Adele Vance, Henrietta Mueller, Patti Fernandez, Diego Siciliani, Michael Kret (group)",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/chat/19%3Aebed9ad42c904d6c83adf0db360053ec%40thread.v2/0?tenantId=23786ca6-7ff2-4672-87d0-5c649ee0a337"
|
||||
},
|
||||
"message": "Hello!",
|
||||
"options": {
|
||||
"includeLinkToWorkflow": true
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#chats('19%3Aebed9ad42c904d6c83adf0db360053ec%40thread.v2')/messages/$entity",
|
||||
"id": "1698378560692",
|
||||
"replyToId": null,
|
||||
"etag": "1698378560692",
|
||||
"messageType": "message",
|
||||
"createdDateTime": "2023-10-27T03:49:20.692Z",
|
||||
"lastModifiedDateTime": "2023-10-27T03:49:20.692Z",
|
||||
"lastEditedDateTime": null,
|
||||
"deletedDateTime": null,
|
||||
"subject": null,
|
||||
"summary": null,
|
||||
"chatId": "19:ebed9ad42c904d6c83adf0db360053ec@thread.v2",
|
||||
"importance": "normal",
|
||||
"locale": "en-us",
|
||||
"webUrl": null,
|
||||
"channelIdentity": null,
|
||||
"policyViolation": null,
|
||||
"eventDetail": null,
|
||||
"from": {
|
||||
"application": null,
|
||||
"device": null,
|
||||
"user": {
|
||||
"@odata.type": "#microsoft.graph.teamworkUserIdentity",
|
||||
"id": "11111-2222-3333",
|
||||
"displayName": "Michael Kret",
|
||||
"userIdentityType": "aadUser"
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"contentType": "html",
|
||||
"content": "Hello!<br>\n<br>\n<em> Powered by <a href=\"http://localhost:5678/workflow/i3NYGF0LXV4qDFV9?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363\">this n8n workflow</a> </em>"
|
||||
},
|
||||
"attachments": [],
|
||||
"mentions": [],
|
||||
"reactions": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "4b3813fc-dee5-4560-becc-9e2c7fe881d6",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, chatMessage => get', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/v1.0/chats/19:ebed9ad42c904d6c83adf0db360053ec@thread.v2/messages/1698378560692')
|
||||
.reply(200, {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/v1.0/$metadata#chats('19%3Aebed9ad42c904d6c83adf0db360053ec%40thread.v2')/messages/$entity",
|
||||
id: '1698378560692',
|
||||
replyToId: null,
|
||||
etag: '1698378560692',
|
||||
messageType: 'message',
|
||||
createdDateTime: '2023-10-27T03:49:20.692Z',
|
||||
lastModifiedDateTime: '2023-10-27T03:49:20.692Z',
|
||||
lastEditedDateTime: null,
|
||||
deletedDateTime: null,
|
||||
subject: null,
|
||||
summary: null,
|
||||
chatId: '19:ebed9ad42c904d6c83adf0db360053ec@thread.v2',
|
||||
importance: 'normal',
|
||||
locale: 'en-us',
|
||||
webUrl: null,
|
||||
channelIdentity: null,
|
||||
policyViolation: null,
|
||||
eventDetail: null,
|
||||
from: {
|
||||
application: null,
|
||||
device: null,
|
||||
user: {
|
||||
'@odata.type': '#microsoft.graph.teamworkUserIdentity',
|
||||
id: '11111-2222-3333',
|
||||
displayName: 'Michael Kret',
|
||||
userIdentityType: 'aadUser',
|
||||
tenantId: '23786ca6-7ff2-4672-87d0-5c649ee0a337',
|
||||
},
|
||||
},
|
||||
body: {
|
||||
contentType: 'html',
|
||||
content:
|
||||
'Hello!<br>\n<br>\n<em> Powered by <a href="http://localhost:5678/workflow/i3NYGF0LXV4qDFV9?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363">this n8n workflow</a> </em>',
|
||||
},
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
reactions: [],
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['get.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "chatMessage",
|
||||
"operation": "get",
|
||||
"chatId": {
|
||||
"__rl": true,
|
||||
"value": "19:ebed9ad42c904d6c83adf0db360053ec@thread.v2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Grady Archie, Adele Vance, Henrietta Mueller, Patti Fernandez, Diego Siciliani, Michael Kret (group)",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/chat/19%3Aebed9ad42c904d6c83adf0db360053ec%40thread.v2/0?tenantId=23786ca6-7ff2-4672-87d0-5c649ee0a337"
|
||||
},
|
||||
"messageId": "1698378560692"
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#chats('19%3Aebed9ad42c904d6c83adf0db360053ec%40thread.v2')/messages/$entity",
|
||||
"id": "1698378560692",
|
||||
"replyToId": null,
|
||||
"etag": "1698378560692",
|
||||
"messageType": "message",
|
||||
"createdDateTime": "2023-10-27T03:49:20.692Z",
|
||||
"lastModifiedDateTime": "2023-10-27T03:49:20.692Z",
|
||||
"lastEditedDateTime": null,
|
||||
"deletedDateTime": null,
|
||||
"subject": null,
|
||||
"summary": null,
|
||||
"chatId": "19:ebed9ad42c904d6c83adf0db360053ec@thread.v2",
|
||||
"importance": "normal",
|
||||
"locale": "en-us",
|
||||
"webUrl": null,
|
||||
"channelIdentity": null,
|
||||
"policyViolation": null,
|
||||
"eventDetail": null,
|
||||
"from": {
|
||||
"application": null,
|
||||
"device": null,
|
||||
"user": {
|
||||
"@odata.type": "#microsoft.graph.teamworkUserIdentity",
|
||||
"id": "11111-2222-3333",
|
||||
"displayName": "Michael Kret",
|
||||
"userIdentityType": "aadUser",
|
||||
"tenantId": "23786ca6-7ff2-4672-87d0-5c649ee0a337"
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"contentType": "html",
|
||||
"content": "Hello!<br>\n<br>\n<em> Powered by <a href=\"http://localhost:5678/workflow/i3NYGF0LXV4qDFV9?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363\">this n8n workflow</a> </em>"
|
||||
},
|
||||
"attachments": [],
|
||||
"mentions": [],
|
||||
"reactions": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "4de0815e-b1b7-463a-a627-c55ac71b70e4",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, chatMessage => getAll', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/v1.0/chats/19:ebed9ad42c904d6c83adf0db360053ec@thread.v2/messages')
|
||||
.reply(200, {
|
||||
value: [
|
||||
{
|
||||
id: '1698378560692',
|
||||
replyToId: null,
|
||||
etag: '1698378560692',
|
||||
messageType: 'message',
|
||||
createdDateTime: '2023-10-27T03:49:20.692Z',
|
||||
lastModifiedDateTime: '2023-10-27T03:49:20.692Z',
|
||||
lastEditedDateTime: null,
|
||||
deletedDateTime: null,
|
||||
subject: null,
|
||||
summary: null,
|
||||
chatId: '19:ebed9ad42c904d6c83adf0db360053ec@thread.v2',
|
||||
importance: 'normal',
|
||||
locale: 'en-us',
|
||||
webUrl: null,
|
||||
channelIdentity: null,
|
||||
policyViolation: null,
|
||||
eventDetail: null,
|
||||
from: {
|
||||
application: null,
|
||||
device: null,
|
||||
user: {
|
||||
'@odata.type': '#microsoft.graph.teamworkUserIdentity',
|
||||
id: '11111-2222-3333',
|
||||
displayName: 'Michael Kret',
|
||||
userIdentityType: 'aadUser',
|
||||
tenantId: '23786ca6-7ff2-4672-87d0-5c649ee0a337',
|
||||
},
|
||||
},
|
||||
body: {
|
||||
contentType: 'html',
|
||||
content:
|
||||
'Hello!<br>\n<br>\n<em> Powered by <a href="http://localhost:5678/workflow/i3NYGF0LXV4qDFV9?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363">this n8n workflow</a> </em>',
|
||||
},
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
reactions: [],
|
||||
},
|
||||
{
|
||||
id: '1698129297101',
|
||||
replyToId: null,
|
||||
etag: '1698129297101',
|
||||
messageType: 'message',
|
||||
createdDateTime: '2023-10-24T06:34:57.101Z',
|
||||
lastModifiedDateTime: '2023-10-24T06:34:57.101Z',
|
||||
lastEditedDateTime: null,
|
||||
deletedDateTime: null,
|
||||
subject: null,
|
||||
summary: null,
|
||||
chatId: '19:ebed9ad42c904d6c83adf0db360053ec@thread.v2',
|
||||
importance: 'normal',
|
||||
locale: 'en-us',
|
||||
webUrl: null,
|
||||
channelIdentity: null,
|
||||
policyViolation: null,
|
||||
eventDetail: null,
|
||||
from: {
|
||||
application: null,
|
||||
device: null,
|
||||
user: {
|
||||
'@odata.type': '#microsoft.graph.teamworkUserIdentity',
|
||||
id: '11111-2222-3333',
|
||||
displayName: 'Michael Kret',
|
||||
userIdentityType: 'aadUser',
|
||||
tenantId: '23786ca6-7ff2-4672-87d0-5c649ee0a337',
|
||||
},
|
||||
},
|
||||
body: {
|
||||
contentType: 'html',
|
||||
content:
|
||||
'tada<br>\n<br>\n<em> Powered by <a href="http://localhost:5678/workflow/5sTm8tp3j3niFewr?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363">this n8n workflow</a> </em>',
|
||||
},
|
||||
attachments: [],
|
||||
mentions: [],
|
||||
reactions: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
});
|
||||
});
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "chatMessage",
|
||||
"operation": "getAll",
|
||||
"chatId": {
|
||||
"__rl": true,
|
||||
"value": "19:ebed9ad42c904d6c83adf0db360053ec@thread.v2",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Grady Archie, Adele Vance, Henrietta Mueller, Patti Fernandez, Diego Siciliani, Michael Kret (group)",
|
||||
"cachedResultUrl": "https://teams.microsoft.com/l/chat/19%3Aebed9ad42c904d6c83adf0db360053ec%40thread.v2/0?tenantId=23786ca6-7ff2-4672-87d0-5c649ee0a337"
|
||||
},
|
||||
"limit": 2
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1698378560692",
|
||||
"replyToId": null,
|
||||
"etag": "1698378560692",
|
||||
"messageType": "message",
|
||||
"createdDateTime": "2023-10-27T03:49:20.692Z",
|
||||
"lastModifiedDateTime": "2023-10-27T03:49:20.692Z",
|
||||
"lastEditedDateTime": null,
|
||||
"deletedDateTime": null,
|
||||
"subject": null,
|
||||
"summary": null,
|
||||
"chatId": "19:ebed9ad42c904d6c83adf0db360053ec@thread.v2",
|
||||
"importance": "normal",
|
||||
"locale": "en-us",
|
||||
"webUrl": null,
|
||||
"channelIdentity": null,
|
||||
"policyViolation": null,
|
||||
"eventDetail": null,
|
||||
"from": {
|
||||
"application": null,
|
||||
"device": null,
|
||||
"user": {
|
||||
"@odata.type": "#microsoft.graph.teamworkUserIdentity",
|
||||
"id": "11111-2222-3333",
|
||||
"displayName": "Michael Kret",
|
||||
"userIdentityType": "aadUser",
|
||||
"tenantId": "23786ca6-7ff2-4672-87d0-5c649ee0a337"
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"contentType": "html",
|
||||
"content": "Hello!<br>\n<br>\n<em> Powered by <a href=\"http://localhost:5678/workflow/i3NYGF0LXV4qDFV9?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363\">this n8n workflow</a> </em>"
|
||||
},
|
||||
"attachments": [],
|
||||
"mentions": [],
|
||||
"reactions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "1698129297101",
|
||||
"replyToId": null,
|
||||
"etag": "1698129297101",
|
||||
"messageType": "message",
|
||||
"createdDateTime": "2023-10-24T06:34:57.101Z",
|
||||
"lastModifiedDateTime": "2023-10-24T06:34:57.101Z",
|
||||
"lastEditedDateTime": null,
|
||||
"deletedDateTime": null,
|
||||
"subject": null,
|
||||
"summary": null,
|
||||
"chatId": "19:ebed9ad42c904d6c83adf0db360053ec@thread.v2",
|
||||
"importance": "normal",
|
||||
"locale": "en-us",
|
||||
"webUrl": null,
|
||||
"channelIdentity": null,
|
||||
"policyViolation": null,
|
||||
"eventDetail": null,
|
||||
"from": {
|
||||
"application": null,
|
||||
"device": null,
|
||||
"user": {
|
||||
"@odata.type": "#microsoft.graph.teamworkUserIdentity",
|
||||
"id": "11111-2222-3333",
|
||||
"displayName": "Michael Kret",
|
||||
"userIdentityType": "aadUser",
|
||||
"tenantId": "23786ca6-7ff2-4672-87d0-5c649ee0a337"
|
||||
}
|
||||
},
|
||||
"body": {
|
||||
"contentType": "html",
|
||||
"content": "tada<br>\n<br>\n<em> Powered by <a href=\"http://localhost:5678/workflow/5sTm8tp3j3niFewr?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363\">this n8n workflow</a> </em>"
|
||||
},
|
||||
"attachments": [],
|
||||
"mentions": [],
|
||||
"reactions": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "324b8a88-47a1-453e-906f-79f9be836e17",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { SEND_AND_WAIT_OPERATION, type IExecuteFunctions, type INode } from 'n8n-workflow';
|
||||
|
||||
import { versionDescription } from '../../../../v2/actions/versionDescription';
|
||||
import { MicrosoftTeamsV2 } from '../../../../v2/MicrosoftTeamsV2.node';
|
||||
import * as transport from '../../../../v2/transport';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftTeamsV2, chatMessage => sendAndWait', () => {
|
||||
let microsoftTeamsV2: MicrosoftTeamsV2;
|
||||
let mockExecuteFunctions: MockProxy<IExecuteFunctions>;
|
||||
|
||||
beforeEach(() => {
|
||||
microsoftTeamsV2 = new MicrosoftTeamsV2(versionDescription);
|
||||
mockExecuteFunctions = mock<IExecuteFunctions>();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should send message and put execution to wait', async () => {
|
||||
const items = [{ json: { data: 'test' } }];
|
||||
mockExecuteFunctions.getNodeParameter.mockImplementation((key: string) => {
|
||||
if (key === 'operation') return SEND_AND_WAIT_OPERATION;
|
||||
if (key === 'resource') return 'chatMessage';
|
||||
if (key === 'chatId') return 'chatID';
|
||||
if (key === 'message') return 'my message';
|
||||
if (key === 'subject') return '';
|
||||
if (key === 'approvalOptions.values') return {};
|
||||
if (key === 'responseType') return 'approval';
|
||||
if (key === 'options.limitWaitTime.values') return {};
|
||||
});
|
||||
|
||||
mockExecuteFunctions.putExecutionToWait.mockImplementation();
|
||||
mockExecuteFunctions.getInputData.mockReturnValue(items);
|
||||
mockExecuteFunctions.getInstanceId.mockReturnValue('instanceId');
|
||||
mockExecuteFunctions.getNode.mockReturnValue(mock<INode>({ typeVersion: 2 }));
|
||||
|
||||
mockExecuteFunctions.getSignedResumeUrl.mockReturnValue(
|
||||
'http://localhost/waiting-webhook/nodeID?approved=true&signature=abc',
|
||||
);
|
||||
|
||||
const result = await microsoftTeamsV2.execute.call(mockExecuteFunctions);
|
||||
|
||||
expect(result).toEqual([items]);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledTimes(1);
|
||||
expect(mockExecuteFunctions.putExecutionToWait).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/v1.0/chats/chatID/messages',
|
||||
{
|
||||
body: {
|
||||
content:
|
||||
'my message<br><br><a href="http://localhost/waiting-webhook/nodeID?approved=true&signature=abc">Approve</a><br><br><em>This message was sent automatically with <a href="https://n8n.io/?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.microsoftTeams_instanceId">n8n</a></em>',
|
||||
contentType: 'html',
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, task => create', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.post('/v1.0/planner/tasks', {
|
||||
assignments: {
|
||||
'ba4a422e-bdce-4795-b4b6-579287363f0e': {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
},
|
||||
bucketId: 'CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m',
|
||||
dueDateTime: '2023-10-30T22:00:00.000Z',
|
||||
percentComplete: 25,
|
||||
planId: 'THwgIivuyU26ki8qS7ufcJgAB6zf',
|
||||
title: 'do this',
|
||||
})
|
||||
.reply(200, {
|
||||
'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#planner/tasks/$entity',
|
||||
'@odata.etag': 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="',
|
||||
planId: 'THwgIivuyU26ki8qS7ufcJgAB6zf',
|
||||
bucketId: 'CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m',
|
||||
title: 'do this',
|
||||
orderHint: '8584964728139267910',
|
||||
assigneePriority: '',
|
||||
percentComplete: 25,
|
||||
startDateTime: null,
|
||||
createdDateTime: '2024-01-13T08:21:11.5507897Z',
|
||||
dueDateTime: '2023-10-30T22:00:00Z',
|
||||
hasDescription: false,
|
||||
previewType: 'automatic',
|
||||
completedDateTime: null,
|
||||
completedBy: null,
|
||||
referenceCount: 0,
|
||||
checklistItemCount: 0,
|
||||
activeChecklistItemCount: 0,
|
||||
conversationThreadId: null,
|
||||
priority: 5,
|
||||
id: 'mYxTKaD9VkqWaBCJE5v4E5gAHcPB',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: 'b834447b-6848-4af9-8390-d2259ce46b74',
|
||||
},
|
||||
application: {
|
||||
displayName: null,
|
||||
id: '66bdd989-4a29-465d-86fb-d94ed8fd86ed',
|
||||
},
|
||||
},
|
||||
appliedCategories: {},
|
||||
assignments: {
|
||||
'ba4a422e-bdce-4795-b4b6-579287363f0e': {
|
||||
'@odata.type': '#microsoft.graph.plannerAssignment',
|
||||
assignedDateTime: '2024-01-13T08:21:11.5507897Z',
|
||||
orderHint: '8584964728740986700PZ',
|
||||
assignedBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: 'b834447b-6848-4af9-8390-d2259ce46b74',
|
||||
},
|
||||
application: {
|
||||
displayName: null,
|
||||
id: '66bdd989-4a29-465d-86fb-d94ed8fd86ed',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['create.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,167 @@
|
||||
{
|
||||
"name": "My workflow 69",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "28f1f78e-0d50-4bfe-aa16-1a53f0832793",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
520,
|
||||
300
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "task",
|
||||
"groupId": {
|
||||
"__rl": true,
|
||||
"value": "1644e7fe-547e-4223-a24f-922395865343",
|
||||
"mode": "list",
|
||||
"cachedResultName": "5w1hb7"
|
||||
},
|
||||
"planId": {
|
||||
"__rl": true,
|
||||
"value": "THwgIivuyU26ki8qS7ufcJgAB6zf",
|
||||
"mode": "list",
|
||||
"cachedResultName": "my best plan"
|
||||
},
|
||||
"bucketId": {
|
||||
"__rl": true,
|
||||
"value": "CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m",
|
||||
"mode": "list",
|
||||
"cachedResultName": "To do"
|
||||
},
|
||||
"title": "do this",
|
||||
"options": {
|
||||
"assignedTo": {
|
||||
"__rl": true,
|
||||
"value": "ba4a422e-bdce-4795-b4b6-579287363f0e",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Henrietta Mueller"
|
||||
},
|
||||
"dueDateTime": "2023-10-30T22:00:00.000Z",
|
||||
"percentComplete": 25
|
||||
}
|
||||
},
|
||||
"id": "e1c2eafd-4a1e-48aa-bc0e-d5a03644fedc",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
740,
|
||||
300
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "a05a3079-3431-44b8-a317-79e5d8babe25",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1040,
|
||||
300
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#planner/tasks/$entity",
|
||||
"@odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc=\"",
|
||||
"planId": "THwgIivuyU26ki8qS7ufcJgAB6zf",
|
||||
"bucketId": "CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m",
|
||||
"title": "do this",
|
||||
"orderHint": "8584964728139267910",
|
||||
"assigneePriority": "",
|
||||
"percentComplete": 25,
|
||||
"startDateTime": null,
|
||||
"createdDateTime": "2024-01-13T08:21:11.5507897Z",
|
||||
"dueDateTime": "2023-10-30T22:00:00Z",
|
||||
"hasDescription": false,
|
||||
"previewType": "automatic",
|
||||
"completedDateTime": null,
|
||||
"completedBy": null,
|
||||
"referenceCount": 0,
|
||||
"checklistItemCount": 0,
|
||||
"activeChecklistItemCount": 0,
|
||||
"conversationThreadId": null,
|
||||
"priority": 5,
|
||||
"id": "mYxTKaD9VkqWaBCJE5v4E5gAHcPB",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "b834447b-6848-4af9-8390-d2259ce46b74"
|
||||
},
|
||||
"application": {
|
||||
"displayName": null,
|
||||
"id": "66bdd989-4a29-465d-86fb-d94ed8fd86ed"
|
||||
}
|
||||
},
|
||||
"appliedCategories": {},
|
||||
"assignments": {
|
||||
"ba4a422e-bdce-4795-b4b6-579287363f0e": {
|
||||
"@odata.type": "#microsoft.graph.plannerAssignment",
|
||||
"assignedDateTime": "2024-01-13T08:21:11.5507897Z",
|
||||
"orderHint": "8584964728740986700PZ",
|
||||
"assignedBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "b834447b-6848-4af9-8390-d2259ce46b74"
|
||||
},
|
||||
"application": {
|
||||
"displayName": null,
|
||||
"id": "66bdd989-4a29-465d-86fb-d94ed8fd86ed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "8cb42e14-a12c-4c24-8374-4105664065c3",
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true,
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"id": "73ZPNCHsvTvFBx1V",
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, task => deleteTask', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD')
|
||||
.reply(200, { '@odata.etag': 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="' })
|
||||
.delete('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD')
|
||||
.matchHeader('If-Match', 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="')
|
||||
.reply(200, {});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['deleteTask.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "task",
|
||||
"operation": "deleteTask",
|
||||
"taskId": "lDrRJ7N_-06p_26iKBtJ6ZgAKffD"
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "ae5ed0d2-4513-457a-80a4-262126523553",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, task => get', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD')
|
||||
.reply(200, {
|
||||
'@odata.context': 'https://graph.microsoft.com/v1.0/$metadata#planner/tasks/$entity',
|
||||
'@odata.etag': 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="',
|
||||
planId: 'THwgIivuyU26ki8qS7ufcJgAB6zf',
|
||||
bucketId: 'CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m',
|
||||
title: 'do this',
|
||||
orderHint: '8585032308935758184',
|
||||
assigneePriority: '',
|
||||
percentComplete: 25,
|
||||
startDateTime: null,
|
||||
createdDateTime: '2023-10-27T03:06:31.9017623Z',
|
||||
dueDateTime: '2023-10-30T22:00:00Z',
|
||||
hasDescription: false,
|
||||
previewType: 'automatic',
|
||||
completedDateTime: null,
|
||||
completedBy: null,
|
||||
referenceCount: 0,
|
||||
checklistItemCount: 0,
|
||||
activeChecklistItemCount: 0,
|
||||
conversationThreadId: null,
|
||||
priority: 5,
|
||||
id: 'lDrRJ7N_-06p_26iKBtJ6ZgAKffD',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
application: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333-44444',
|
||||
},
|
||||
},
|
||||
appliedCategories: {},
|
||||
assignments: {
|
||||
'ba4a422e-bdce-4795-b4b6-579287363f0e': {
|
||||
'@odata.type': '#microsoft.graph.plannerAssignment',
|
||||
assignedDateTime: '2023-10-27T03:06:31.9017623Z',
|
||||
orderHint: '8585032309536070726PE',
|
||||
assignedBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
application: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333-44444',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['get.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "task",
|
||||
"operation": "get",
|
||||
"taskId": "lDrRJ7N_-06p_26iKBtJ6ZgAKffD"
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#planner/tasks/$entity",
|
||||
"@odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc=\"",
|
||||
"planId": "THwgIivuyU26ki8qS7ufcJgAB6zf",
|
||||
"bucketId": "CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m",
|
||||
"title": "do this",
|
||||
"orderHint": "8585032308935758184",
|
||||
"assigneePriority": "",
|
||||
"percentComplete": 25,
|
||||
"startDateTime": null,
|
||||
"createdDateTime": "2023-10-27T03:06:31.9017623Z",
|
||||
"dueDateTime": "2023-10-30T22:00:00Z",
|
||||
"hasDescription": false,
|
||||
"previewType": "automatic",
|
||||
"completedDateTime": null,
|
||||
"completedBy": null,
|
||||
"referenceCount": 0,
|
||||
"checklistItemCount": 0,
|
||||
"activeChecklistItemCount": 0,
|
||||
"conversationThreadId": null,
|
||||
"priority": 5,
|
||||
"id": "lDrRJ7N_-06p_26iKBtJ6ZgAKffD",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
},
|
||||
"application": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333-44444"
|
||||
}
|
||||
},
|
||||
"appliedCategories": {},
|
||||
"assignments": {
|
||||
"ba4a422e-bdce-4795-b4b6-579287363f0e": {
|
||||
"@odata.type": "#microsoft.graph.plannerAssignment",
|
||||
"assignedDateTime": "2023-10-27T03:06:31.9017623Z",
|
||||
"orderHint": "8585032309536070726PE",
|
||||
"assignedBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
},
|
||||
"application": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333-44444"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "8147cd45-b1e6-44b3-abd2-232b44102660",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, task => getAll', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/v1.0/me')
|
||||
.reply(200, { id: '123456789' })
|
||||
.get('/v1.0/users/123456789/planner/tasks')
|
||||
.reply(200, {
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAZCc="',
|
||||
planId: 'coJdCqzqNUKULQtTRWDa6pgACTln',
|
||||
bucketId: null,
|
||||
title: 'tada',
|
||||
orderHint: '8585516884147534440',
|
||||
assigneePriority: '8585516882706975451',
|
||||
percentComplete: 10,
|
||||
startDateTime: null,
|
||||
createdDateTime: '2022-04-14T06:41:10.7241367Z',
|
||||
dueDateTime: '2022-04-24T21:00:00Z',
|
||||
hasDescription: false,
|
||||
previewType: 'automatic',
|
||||
completedDateTime: null,
|
||||
completedBy: null,
|
||||
referenceCount: 0,
|
||||
checklistItemCount: 0,
|
||||
activeChecklistItemCount: 0,
|
||||
conversationThreadId: null,
|
||||
priority: 5,
|
||||
id: '1KgwUqOmbU2C9mZWiqxiv5gAPp8Q',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
},
|
||||
appliedCategories: {},
|
||||
assignments: {
|
||||
'11111-2222-3333': {
|
||||
'@odata.type': '#microsoft.graph.plannerAssignment',
|
||||
assignedDateTime: '2022-04-14T06:43:34.7800356Z',
|
||||
orderHint: '8585516882406130277PO',
|
||||
assignedBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'@odata.etag': 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc="',
|
||||
planId: 'coJdCqzqNUKULQtTRWDa6pgACTln',
|
||||
bucketId: '2avE1BwPmEKp7Lxh0E-EmZgALF72',
|
||||
title: '1',
|
||||
orderHint: '8585516897613076919P1',
|
||||
assigneePriority: '8585516890164965803',
|
||||
percentComplete: 0,
|
||||
startDateTime: null,
|
||||
createdDateTime: '2022-04-14T06:19:44.2011467Z',
|
||||
dueDateTime: null,
|
||||
hasDescription: false,
|
||||
previewType: 'automatic',
|
||||
completedDateTime: null,
|
||||
completedBy: null,
|
||||
referenceCount: 0,
|
||||
checklistItemCount: 0,
|
||||
activeChecklistItemCount: 0,
|
||||
conversationThreadId: null,
|
||||
priority: 5,
|
||||
id: 'J3MLUgtmJ06YJgenyujiYpgANMF1',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
},
|
||||
appliedCategories: {},
|
||||
assignments: {
|
||||
'11111-2222-3333': {
|
||||
'@odata.type': '#microsoft.graph.plannerAssignment',
|
||||
assignedDateTime: '2022-04-14T06:31:08.9810004Z',
|
||||
orderHint: '8585516890765590890Pw',
|
||||
assignedBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'@odata.etag': 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAVCc="',
|
||||
planId: 'THwgIivuyU26ki8qS7ufcJgAB6zf',
|
||||
bucketId: 'CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m',
|
||||
title: 'td 54',
|
||||
orderHint: '8585034751365009589',
|
||||
assigneePriority: '8585034751365009589',
|
||||
percentComplete: 0,
|
||||
startDateTime: null,
|
||||
createdDateTime: '2023-10-24T07:15:48.9766218Z',
|
||||
dueDateTime: null,
|
||||
hasDescription: true,
|
||||
previewType: 'automatic',
|
||||
completedDateTime: null,
|
||||
completedBy: null,
|
||||
referenceCount: 0,
|
||||
checklistItemCount: 0,
|
||||
activeChecklistItemCount: 0,
|
||||
conversationThreadId: null,
|
||||
priority: 5,
|
||||
id: 'silreUDQskqFYfrO4EObD5gAKt_G',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
application: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333-44444',
|
||||
},
|
||||
},
|
||||
appliedCategories: {},
|
||||
assignments: {
|
||||
'11111-2222-3333': {
|
||||
'@odata.type': '#microsoft.graph.plannerAssignment',
|
||||
assignedDateTime: '2023-10-24T07:15:48.9766218Z',
|
||||
orderHint: '8585034751965947109Pc',
|
||||
assignedBy: {
|
||||
user: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333',
|
||||
},
|
||||
application: {
|
||||
displayName: null,
|
||||
id: '11111-2222-3333-44444',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,232 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "task",
|
||||
"operation": "getAll",
|
||||
"groupId": {
|
||||
"__rl": true,
|
||||
"value": "1644e7fe-547e-4223-a24f-922395865343",
|
||||
"mode": "list",
|
||||
"cachedResultName": "5w1hb7"
|
||||
},
|
||||
"returnAll": true
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAZCc=\"",
|
||||
"planId": "coJdCqzqNUKULQtTRWDa6pgACTln",
|
||||
"bucketId": null,
|
||||
"title": "tada",
|
||||
"orderHint": "8585516884147534440",
|
||||
"assigneePriority": "8585516882706975451",
|
||||
"percentComplete": 10,
|
||||
"startDateTime": null,
|
||||
"createdDateTime": "2022-04-14T06:41:10.7241367Z",
|
||||
"dueDateTime": "2022-04-24T21:00:00Z",
|
||||
"hasDescription": false,
|
||||
"previewType": "automatic",
|
||||
"completedDateTime": null,
|
||||
"completedBy": null,
|
||||
"referenceCount": 0,
|
||||
"checklistItemCount": 0,
|
||||
"activeChecklistItemCount": 0,
|
||||
"conversationThreadId": null,
|
||||
"priority": 5,
|
||||
"id": "1KgwUqOmbU2C9mZWiqxiv5gAPp8Q",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
}
|
||||
},
|
||||
"appliedCategories": {},
|
||||
"assignments": {
|
||||
"11111-2222-3333": {
|
||||
"@odata.type": "#microsoft.graph.plannerAssignment",
|
||||
"assignedDateTime": "2022-04-14T06:43:34.7800356Z",
|
||||
"orderHint": "8585516882406130277PO",
|
||||
"assignedBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"@odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\"",
|
||||
"planId": "coJdCqzqNUKULQtTRWDa6pgACTln",
|
||||
"bucketId": "2avE1BwPmEKp7Lxh0E-EmZgALF72",
|
||||
"title": "1",
|
||||
"orderHint": "8585516897613076919P1",
|
||||
"assigneePriority": "8585516890164965803",
|
||||
"percentComplete": 0,
|
||||
"startDateTime": null,
|
||||
"createdDateTime": "2022-04-14T06:19:44.2011467Z",
|
||||
"dueDateTime": null,
|
||||
"hasDescription": false,
|
||||
"previewType": "automatic",
|
||||
"completedDateTime": null,
|
||||
"completedBy": null,
|
||||
"referenceCount": 0,
|
||||
"checklistItemCount": 0,
|
||||
"activeChecklistItemCount": 0,
|
||||
"conversationThreadId": null,
|
||||
"priority": 5,
|
||||
"id": "J3MLUgtmJ06YJgenyujiYpgANMF1",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
}
|
||||
},
|
||||
"appliedCategories": {},
|
||||
"assignments": {
|
||||
"11111-2222-3333": {
|
||||
"@odata.type": "#microsoft.graph.plannerAssignment",
|
||||
"assignedDateTime": "2022-04-14T06:31:08.9810004Z",
|
||||
"orderHint": "8585516890765590890Pw",
|
||||
"assignedBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"@odata.etag": "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAVCc=\"",
|
||||
"planId": "THwgIivuyU26ki8qS7ufcJgAB6zf",
|
||||
"bucketId": "CO-ZsX1s4kO7FtO6ZHZdDpgAFL1m",
|
||||
"title": "td 54",
|
||||
"orderHint": "8585034751365009589",
|
||||
"assigneePriority": "8585034751365009589",
|
||||
"percentComplete": 0,
|
||||
"startDateTime": null,
|
||||
"createdDateTime": "2023-10-24T07:15:48.9766218Z",
|
||||
"dueDateTime": null,
|
||||
"hasDescription": true,
|
||||
"previewType": "automatic",
|
||||
"completedDateTime": null,
|
||||
"completedBy": null,
|
||||
"referenceCount": 0,
|
||||
"checklistItemCount": 0,
|
||||
"activeChecklistItemCount": 0,
|
||||
"conversationThreadId": null,
|
||||
"priority": 5,
|
||||
"id": "silreUDQskqFYfrO4EObD5gAKt_G",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
},
|
||||
"application": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333-44444"
|
||||
}
|
||||
},
|
||||
"appliedCategories": {},
|
||||
"assignments": {
|
||||
"11111-2222-3333": {
|
||||
"@odata.type": "#microsoft.graph.plannerAssignment",
|
||||
"assignedDateTime": "2023-10-24T07:15:48.9766218Z",
|
||||
"orderHint": "8585034751965947109Pc",
|
||||
"assignedBy": {
|
||||
"user": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333"
|
||||
},
|
||||
"application": {
|
||||
"displayName": null,
|
||||
"id": "11111-2222-3333-44444"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "34bcdc66-9dad-4c93-8456-4019f94c2f88",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../../../credentials';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, task => update', () => {
|
||||
nock('https://graph.microsoft.com')
|
||||
.get('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD')
|
||||
.reply(200, { '@odata.etag': 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="' })
|
||||
.patch('/v1.0/planner/tasks/lDrRJ7N_-06p_26iKBtJ6ZgAKffD', {
|
||||
dueDateTime: '2023-10-24T21:00:00.000Z',
|
||||
percentComplete: 78,
|
||||
title: 'do that',
|
||||
})
|
||||
.matchHeader('If-Match', 'W/"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBARCc="')
|
||||
.reply(200);
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['update.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"name": "My workflow 35",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "6666-9999-77777",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
380
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "task",
|
||||
"operation": "update",
|
||||
"taskId": "lDrRJ7N_-06p_26iKBtJ6ZgAKffD",
|
||||
"updateFields": {
|
||||
"dueDateTime": "2023-10-24T21:00:00.000Z",
|
||||
"percentComplete": 78,
|
||||
"title": "do that"
|
||||
}
|
||||
},
|
||||
"id": "6666-5555-77777",
|
||||
"name": "Microsoft Teams",
|
||||
"type": "n8n-nodes-base.microsoftTeams",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1100,
|
||||
380
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftTeamsOAuth2Api": {
|
||||
"id": "6isd5ytvA0qV78eK",
|
||||
"name": "Microsoft Teams account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1400,
|
||||
380
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Teams",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Microsoft Teams": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "74d2873c-c1e1-4628-b398-e2a72c6eed9c",
|
||||
"id": "i3NYGF0LXV4qDFV9",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { filterSortSearchListItems } from '../../v2/helpers/utils';
|
||||
|
||||
describe('Test MicrosoftTeamsV2, filterSortSearchListItems', () => {
|
||||
it('should filter, sort and search list items', () => {
|
||||
const items = [
|
||||
{
|
||||
name: 'Test1',
|
||||
value: 'test1',
|
||||
},
|
||||
{
|
||||
name: 'Test2',
|
||||
value: 'test2',
|
||||
},
|
||||
];
|
||||
|
||||
const result = filterSortSearchListItems(items, 'test1');
|
||||
|
||||
expect(result).toEqual([
|
||||
{
|
||||
name: 'Test1',
|
||||
value: 'test1',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,327 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const channelOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a channel',
|
||||
action: 'Create a channel',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a channel',
|
||||
action: 'Delete a channel',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a channel',
|
||||
action: 'Get a channel',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many channels',
|
||||
action: 'Get many channels',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a channel',
|
||||
action: 'Update a channel',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const channelFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channel:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
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: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Channel name as it will appear to the user in Microsoft Teams',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: "Channel's description",
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Private',
|
||||
value: 'private',
|
||||
},
|
||||
{
|
||||
name: 'Standard',
|
||||
value: 'standard',
|
||||
},
|
||||
],
|
||||
default: 'standard',
|
||||
description: 'The type of the channel',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channel:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
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: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['delete'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
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: 'getChannels',
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['delete'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channel:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
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: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
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: 'getChannels',
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channel:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
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: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['channel'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channel:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
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: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['update'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
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: 'getChannels',
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['update'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['update'],
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Channel name as it will appear to the user in Microsoft Teams',
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: "Channel's description",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,210 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const channelMessageOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a message',
|
||||
action: 'Create a message in a channel',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many messages',
|
||||
action: 'Get many messages in a channel',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const channelMessageFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channelMessage:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
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: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
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: 'getChannels',
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Message Type',
|
||||
name: 'messageType',
|
||||
required: true,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'html',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: 'text',
|
||||
description: 'The type of the content',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The content of the item',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include Link to Workflow',
|
||||
name: 'includeLinkToWorkflow',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to append a link to this workflow at the end of the message. This is helpful if you have many workflows sending messages.',
|
||||
},
|
||||
{
|
||||
displayName: 'Make Reply',
|
||||
name: 'makeReply',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'An optional ID of the message you want to reply to',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* channelMessage:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
required: true,
|
||||
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: 'getTeams',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Channel Name or ID',
|
||||
name: 'channelId',
|
||||
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: 'getChannels',
|
||||
loadOptionsDependsOn: ['teamId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['channelMessage'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,191 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const chatMessageOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a message',
|
||||
action: 'Create a chat message',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a message',
|
||||
action: 'Get a chat message',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many messages',
|
||||
action: 'Get many chat messages',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const chatMessageFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* chatMessage:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Chat Name or ID',
|
||||
name: 'chatId',
|
||||
required: true,
|
||||
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: 'getChats',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create', 'get'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Message Type',
|
||||
name: 'messageType',
|
||||
required: true,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'html',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: 'text',
|
||||
description: 'The type of the content',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The content of the item',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
description: 'Other options to set',
|
||||
placeholder: 'Add option',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include Link to Workflow',
|
||||
name: 'includeLinkToWorkflow',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to append a link to this workflow at the end of the message. This is helpful if you have many workflows sending messages.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* chatMessage:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Message ID',
|
||||
name: 'messageId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* chatMessage:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Chat Name or ID',
|
||||
name: 'chatId',
|
||||
required: true,
|
||||
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: 'getChats',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['chatMessage'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,114 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IDataObject,
|
||||
JsonObject,
|
||||
IHttpRequestMethods,
|
||||
IRequestOptions,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
body,
|
||||
qs,
|
||||
uri: uri || `https://graph.microsoft.com${resource}`,
|
||||
json: true,
|
||||
};
|
||||
try {
|
||||
if (Object.keys(headers).length !== 0) {
|
||||
options.headers = Object.assign({}, options.headers, headers);
|
||||
}
|
||||
return await this.helpers.requestOAuth2.call(this, 'microsoftTeamsOAuth2Api', 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: any = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
let uri: string | undefined;
|
||||
|
||||
do {
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = responseData['@odata.nextLink'];
|
||||
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
|
||||
const limit = query.limit as number | undefined;
|
||||
if (limit && limit <= returnData.length) {
|
||||
return returnData;
|
||||
}
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
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;
|
||||
}
|
||||
|
||||
export function prepareMessage(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
message: string,
|
||||
messageType: string,
|
||||
includeLinkToWorkflow: boolean,
|
||||
instanceId?: string,
|
||||
) {
|
||||
if (includeLinkToWorkflow) {
|
||||
const { id } = this.getWorkflow();
|
||||
const link = `${this.getInstanceBaseUrl()}workflow/${id}?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=${encodeURIComponent(
|
||||
'n8n-nodes-base.microsoftTeams',
|
||||
)}${instanceId ? '_' + instanceId : ''}`;
|
||||
messageType = 'html';
|
||||
message = `${message}<br><br><em> Powered by <a href="${link}">this n8n workflow</a> </em>`;
|
||||
}
|
||||
|
||||
return {
|
||||
body: {
|
||||
contentType: messageType,
|
||||
content: message,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,679 @@
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type IDataObject,
|
||||
type ILoadOptionsFunctions,
|
||||
type INodeExecutionData,
|
||||
type INodePropertyOptions,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type INodeTypeBaseDescription,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { channelFields, channelOperations } from './ChannelDescription';
|
||||
import { channelMessageFields, channelMessageOperations } from './ChannelMessageDescription';
|
||||
import { chatMessageFields, chatMessageOperations } from './ChatMessageDescription';
|
||||
import {
|
||||
microsoftApiRequest,
|
||||
microsoftApiRequestAllItems,
|
||||
prepareMessage,
|
||||
} from './GenericFunctions';
|
||||
import { taskFields, taskOperations } from './TaskDescription';
|
||||
import { oldVersionNotice } from '../../../../utils/descriptions';
|
||||
|
||||
const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'Microsoft Teams',
|
||||
name: 'microsoftTeams',
|
||||
icon: 'file:teams.svg',
|
||||
group: ['input'],
|
||||
version: [1, 1.1],
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Microsoft Teams API',
|
||||
defaults: {
|
||||
name: 'Microsoft Teams',
|
||||
},
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'microsoftTeamsOAuth2Api',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
oldVersionNotice,
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Channel',
|
||||
value: 'channel',
|
||||
},
|
||||
{
|
||||
name: 'Channel Message (Beta)',
|
||||
value: 'channelMessage',
|
||||
},
|
||||
{
|
||||
name: 'Chat Message',
|
||||
value: 'chatMessage',
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
],
|
||||
default: 'channel',
|
||||
},
|
||||
// CHANNEL
|
||||
...channelOperations,
|
||||
...channelFields,
|
||||
/// MESSAGE
|
||||
...channelMessageOperations,
|
||||
...channelMessageFields,
|
||||
...chatMessageOperations,
|
||||
...chatMessageFields,
|
||||
///TASK
|
||||
...taskOperations,
|
||||
...taskFields,
|
||||
],
|
||||
};
|
||||
|
||||
export class MicrosoftTeamsV1 implements INodeType {
|
||||
description: INodeTypeDescription;
|
||||
|
||||
constructor(baseDescription: INodeTypeBaseDescription) {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
...versionDescription,
|
||||
};
|
||||
}
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the team's channels to display them to user so that they can
|
||||
// select them easily
|
||||
async getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const teamId = this.getCurrentNodeParameter('teamId') as string;
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
);
|
||||
for (const channel of value) {
|
||||
const channelName = channel.displayName;
|
||||
const channelId = channel.id;
|
||||
returnData.push({
|
||||
name: channelName,
|
||||
value: channelId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the teams to display them to user so that they can
|
||||
// select them easily
|
||||
async getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', '/v1.0/me/joinedTeams');
|
||||
for (const team of value) {
|
||||
const teamName = team.displayName;
|
||||
const teamId = team.id;
|
||||
returnData.push({
|
||||
name: teamName,
|
||||
value: teamId,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the groups to display them to user so that they can
|
||||
// select them easily
|
||||
async getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const groupSource = this.getCurrentNodeParameter('groupSource') as string;
|
||||
let requestUrl = '/v1.0/groups' as string;
|
||||
if (groupSource === 'mine') {
|
||||
requestUrl = '/v1.0/me/transitiveMemberOf';
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', requestUrl);
|
||||
for (const group of value) {
|
||||
returnData.push({
|
||||
name: group.displayName || group.mail || group.id,
|
||||
value: group.id,
|
||||
description: group.mail,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the plans to display them to user so that they can
|
||||
// select them easily
|
||||
async getPlans(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
let groupId = this.getCurrentNodeParameter('groupId') as string;
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
if (operation === 'update' && (groupId === undefined || groupId === null)) {
|
||||
// groupId not found at base, check updateFields for the groupId
|
||||
groupId = this.getCurrentNodeParameter('updateFields.groupId') as string;
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/groups/${groupId}/planner/plans`,
|
||||
);
|
||||
for (const plan of value) {
|
||||
returnData.push({
|
||||
name: plan.title,
|
||||
value: plan.id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the plans to display them to user so that they can
|
||||
// select them easily
|
||||
async getBuckets(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
let planId = this.getCurrentNodeParameter('planId') as string;
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
if (operation === 'update' && (planId === undefined || planId === null)) {
|
||||
// planId not found at base, check updateFields for the planId
|
||||
planId = this.getCurrentNodeParameter('updateFields.planId') as string;
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/buckets`,
|
||||
);
|
||||
for (const bucket of value) {
|
||||
returnData.push({
|
||||
name: bucket.name,
|
||||
value: bucket.id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the plans to display them to user so that they can
|
||||
// select them easily
|
||||
async getMembers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
let groupId = this.getCurrentNodeParameter('groupId') as string;
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
if (operation === 'update' && (groupId === undefined || groupId === null)) {
|
||||
// groupId not found at base, check updateFields for the groupId
|
||||
groupId = this.getCurrentNodeParameter('updateFields.groupId') as string;
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/groups/${groupId}/members`,
|
||||
);
|
||||
for (const member of value) {
|
||||
returnData.push({
|
||||
name: member.displayName,
|
||||
value: member.id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the labels to display them to user so that they can
|
||||
// select them easily
|
||||
async getLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
let planId = this.getCurrentNodeParameter('planId') as string;
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
if (operation === 'update' && (planId === undefined || planId === null)) {
|
||||
// planId not found at base, check updateFields for the planId
|
||||
planId = this.getCurrentNodeParameter('updateFields.planId') as string;
|
||||
}
|
||||
const { categoryDescriptions } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/details`,
|
||||
);
|
||||
for (const key of Object.keys(categoryDescriptions as IDataObject)) {
|
||||
if (categoryDescriptions[key] !== null) {
|
||||
returnData.push({
|
||||
name: categoryDescriptions[key],
|
||||
value: key,
|
||||
});
|
||||
}
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
// Get all the chats to display them to user so that they can
|
||||
// select them easily
|
||||
async getChats(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const qs: IDataObject = {
|
||||
$expand: 'members',
|
||||
};
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', '/v1.0/chats', {}, qs);
|
||||
for (const chat of value) {
|
||||
if (!chat.topic) {
|
||||
chat.topic = chat.members
|
||||
.filter((member: IDataObject) => member.displayName)
|
||||
.map((member: IDataObject) => member.displayName)
|
||||
.join(', ');
|
||||
}
|
||||
const chatName = `${chat.topic || '(no title) - ' + (chat.id as string)} (${
|
||||
chat.chatType
|
||||
})`;
|
||||
const chatId = chat.id;
|
||||
returnData.push({
|
||||
name: chatName,
|
||||
value: chatId,
|
||||
});
|
||||
}
|
||||
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 resource = this.getNodeParameter('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
const instanceId = this.getInstanceId();
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
if (resource === 'channel') {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'create') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
const body: IDataObject = {
|
||||
displayName: name,
|
||||
};
|
||||
if (options.description) {
|
||||
body.description = options.description as string;
|
||||
}
|
||||
if (options.type) {
|
||||
body.membershipType = options.type as string;
|
||||
}
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-delete?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'delete') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-get?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'get') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'getAll') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-patch?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'update') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDataObject = {};
|
||||
if (updateFields.name) {
|
||||
body.displayName = updateFields.name as string;
|
||||
}
|
||||
if (updateFields.description) {
|
||||
body.description = updateFields.description as string;
|
||||
}
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
body,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
if (resource === 'channelMessage') {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=http
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'create') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
const messageType = this.getNodeParameter('messageType', i) as string;
|
||||
const message = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
let includeLinkToWorkflow = options.includeLinkToWorkflow;
|
||||
if (includeLinkToWorkflow === undefined) {
|
||||
includeLinkToWorkflow = nodeVersion >= 1.1;
|
||||
}
|
||||
|
||||
const body: IDataObject = prepareMessage.call(
|
||||
this,
|
||||
message,
|
||||
messageType,
|
||||
includeLinkToWorkflow as boolean,
|
||||
instanceId,
|
||||
);
|
||||
|
||||
if (options.makeReply) {
|
||||
const replyToId = options.makeReply as string;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`,
|
||||
body,
|
||||
);
|
||||
} else {
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-beta&tabs=http
|
||||
if (operation === 'getAll') {
|
||||
const teamId = this.getNodeParameter('teamId', i) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'chatMessage') {
|
||||
// https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'create') {
|
||||
const chatId = this.getNodeParameter('chatId', i) as string;
|
||||
const messageType = this.getNodeParameter('messageType', i) as string;
|
||||
const message = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i, {});
|
||||
|
||||
const includeLinkToWorkflow =
|
||||
options.includeLinkToWorkflow !== false && nodeVersion >= 1.1;
|
||||
|
||||
const body: IDataObject = prepareMessage.call(
|
||||
this,
|
||||
message,
|
||||
messageType,
|
||||
includeLinkToWorkflow,
|
||||
instanceId,
|
||||
);
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'get') {
|
||||
const chatId = this.getNodeParameter('chatId', i) as string;
|
||||
const messageId = this.getNodeParameter('messageId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages/${messageId}`,
|
||||
);
|
||||
}
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'getAll') {
|
||||
const chatId = this.getNodeParameter('chatId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'task') {
|
||||
//https://docs.microsoft.com/en-us/graph/api/planner-post-tasks?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'create') {
|
||||
const planId = this.getNodeParameter('planId', i) as string;
|
||||
const bucketId = this.getNodeParameter('bucketId', i) as string;
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const body: IDataObject = {
|
||||
planId,
|
||||
bucketId,
|
||||
title,
|
||||
};
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
if (body.assignedTo) {
|
||||
body.assignments = {
|
||||
[body.assignedTo as string]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete body.assignedTo;
|
||||
}
|
||||
|
||||
if (Array.isArray(body.labels)) {
|
||||
body.appliedCategories = (body.labels as string[]).map((label) => ({
|
||||
[label]: true,
|
||||
}));
|
||||
}
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/v1.0/planner/tasks',
|
||||
body,
|
||||
);
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-delete?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'delete') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const task = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
);
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
{},
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-get?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'get') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
);
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const tasksFor = this.getNodeParameter('tasksFor', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
if (tasksFor === 'member') {
|
||||
//https://docs.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const memberId = this.getNodeParameter('memberId', i) as string;
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
} else {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannerplan-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const planId = this.getNodeParameter('planId', i) as string;
|
||||
if (returnAll) {
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
{},
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-update?view=graph-rest-1.0&tabs=http
|
||||
if (operation === 'update') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
const body: IDataObject = {};
|
||||
Object.assign(body, updateFields);
|
||||
|
||||
if (body.assignedTo) {
|
||||
body.assignments = {
|
||||
[body.assignedTo as string]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete body.assignedTo;
|
||||
}
|
||||
|
||||
if (body.groupId) {
|
||||
// tasks are assigned to a plan and bucket, group is used for filtering
|
||||
delete body.groupId;
|
||||
}
|
||||
|
||||
if (Array.isArray(body.labels)) {
|
||||
body.appliedCategories = (body.labels as string[]).map((label) => ({
|
||||
[label]: true,
|
||||
}));
|
||||
}
|
||||
|
||||
const task = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
);
|
||||
|
||||
responseData = await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
body,
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,483 @@
|
||||
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',
|
||||
description: 'Create a task',
|
||||
action: 'Create a task',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a task',
|
||||
action: 'Delete a task',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a task',
|
||||
action: 'Get a task',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many tasks',
|
||||
action: 'Get many tasks',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a task',
|
||||
action: 'Update a task',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const taskFields: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Group Source',
|
||||
name: 'groupSource',
|
||||
required: true,
|
||||
type: 'options',
|
||||
default: 'all',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll', 'create', 'update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'All Groups',
|
||||
value: 'all',
|
||||
description: 'From all groups',
|
||||
},
|
||||
{
|
||||
name: 'My Groups',
|
||||
value: 'mine',
|
||||
description: 'Only load groups that account is member of',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Group Name or ID',
|
||||
name: 'groupId',
|
||||
required: true,
|
||||
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: 'getGroups',
|
||||
loadOptionsDependsOn: ['groupSource'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Plan Name or ID',
|
||||
name: 'planId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getPlans',
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'The plan for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Bucket Name or ID',
|
||||
name: 'bucketId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getBuckets',
|
||||
loadOptionsDependsOn: ['planId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'The bucket for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Title of the task',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assigned To Name or ID',
|
||||
name: 'assignedTo',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getMembers',
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'Who the task should be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Label Names or IDs',
|
||||
name: 'labels',
|
||||
type: 'multiOptions',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getLabels',
|
||||
loadOptionsDependsOn: ['planId'],
|
||||
},
|
||||
default: [],
|
||||
description:
|
||||
'Labels to assign to the task. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
name: 'percentComplete',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['delete'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
{
|
||||
displayName: 'Tasks For',
|
||||
name: 'tasksFor',
|
||||
default: 'member',
|
||||
required: true,
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Group Member',
|
||||
value: 'member',
|
||||
description: 'Tasks assigned to group member',
|
||||
},
|
||||
{
|
||||
name: 'Plan',
|
||||
value: 'plan',
|
||||
description: 'Tasks in group plan',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Group Name or ID',
|
||||
name: 'groupId',
|
||||
required: true,
|
||||
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: 'getGroups',
|
||||
loadOptionsDependsOn: ['groupSource'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Member Name or ID',
|
||||
name: 'memberId',
|
||||
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: 'getMembers',
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
tasksFor: ['member'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Plan Name or ID',
|
||||
name: 'planId',
|
||||
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: 'getPlans',
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
tasksFor: ['plan'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['task'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The ID of the Task',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['update'],
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Assigned To Name or ID',
|
||||
name: 'assignedTo',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getMembers',
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'Who the task should be assigned to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Bucket Name or ID',
|
||||
name: 'bucketId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getBuckets',
|
||||
loadOptionsDependsOn: ['updateFields.planId'],
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'The bucket for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Group Name or ID',
|
||||
name: 'groupId',
|
||||
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: 'getGroups',
|
||||
loadOptionsDependsOn: ['groupSource'],
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Label Names or IDs',
|
||||
name: 'labels',
|
||||
type: 'multiOptions',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getLabels',
|
||||
loadOptionsDependsOn: ['updateFields.planId'],
|
||||
},
|
||||
default: [],
|
||||
description:
|
||||
'Labels to assign to the task. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
name: 'percentComplete',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
{
|
||||
displayName: 'Plan Name or ID',
|
||||
name: 'planId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getPlans',
|
||||
loadOptionsDependsOn: ['groupId'],
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'The plan for the task to belong to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Title of the task',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,31 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
INodeTypeBaseDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { router } from './actions/router';
|
||||
import { versionDescription } from './actions/versionDescription';
|
||||
import { listSearch } from './methods';
|
||||
import { sendAndWaitWebhook } from '../../../../utils/sendAndWait/utils';
|
||||
|
||||
export class MicrosoftTeamsV2 implements INodeType {
|
||||
description: INodeTypeDescription;
|
||||
|
||||
constructor(baseDescription: INodeTypeBaseDescription) {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
...versionDescription,
|
||||
usableAsTool: true,
|
||||
};
|
||||
}
|
||||
|
||||
methods = { listSearch };
|
||||
|
||||
webhook = sendAndWaitWebhook;
|
||||
|
||||
async execute(this: IExecuteFunctions) {
|
||||
return await router.call(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { teamRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
teamRLC,
|
||||
{
|
||||
displayName: 'New Channel Name',
|
||||
name: 'name',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. My New Channel',
|
||||
description: 'The name of the new channel you want to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add option',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The description of the channel',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Private',
|
||||
value: 'private',
|
||||
},
|
||||
{
|
||||
name: 'Standard',
|
||||
value: 'standard',
|
||||
},
|
||||
],
|
||||
default: 'standard',
|
||||
description:
|
||||
'Standard: Accessible to everyone on the team. Private: Accessible only to a specific group of people within the team.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post?view=graph-rest-beta&tabs=http
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
displayName: name,
|
||||
};
|
||||
if (options.description) {
|
||||
body.description = options.description as string;
|
||||
}
|
||||
if (options.type) {
|
||||
body.membershipType = options.type as string;
|
||||
}
|
||||
return await microsoftApiRequest.call(this, 'POST', `/v1.0/teams/${teamId}/channels`, body);
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
import { type INodeProperties, type IExecuteFunctions, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, channelRLC];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['deleteChannel'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-delete?view=graph-rest-beta&tabs=http
|
||||
|
||||
try {
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
|
||||
await microsoftApiRequest.call(this, 'DELETE', `/v1.0/teams/${teamId}/channels/${channelId}`);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"The channel you are trying to delete doesn't exist",
|
||||
{
|
||||
description: "Check that the 'Channel' parameter is correctly set",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { type INodeProperties, type IExecuteFunctions, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, channelRLC];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['get'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-get?view=graph-rest-beta&tabs=http
|
||||
|
||||
try {
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"The channel you are trying to get doesn't exist",
|
||||
{
|
||||
description: "Check that the 'Channel' parameter is correctly set",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { teamRLC } from '../../descriptions';
|
||||
import { microsoftApiRequestAllItems } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, ...returnAllOrLimit];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as deleteChannel from './deleteChannel.operation';
|
||||
import * as get from './get.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
import * as update from './update.operation';
|
||||
|
||||
export { create, deleteChannel, get, getAll, update };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a channel',
|
||||
action: 'Create channel',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'deleteChannel',
|
||||
description: 'Delete a channel',
|
||||
action: 'Delete channel',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a channel',
|
||||
action: 'Get channel',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many channels',
|
||||
action: 'Get many channels',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a channel',
|
||||
action: 'Update channel',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...deleteChannel.description,
|
||||
...get.description,
|
||||
...getAll.description,
|
||||
...update.description,
|
||||
];
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
teamRLC,
|
||||
channelRLC,
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. My New Channel name',
|
||||
description: 'The name of the channel',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add option',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Description',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The description of the channel',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channel'],
|
||||
operation: ['update'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-patch?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
const newName = this.getNodeParameter('name', i) as string;
|
||||
const newDescription = this.getNodeParameter('options.description', i, '') as string;
|
||||
|
||||
const body: IDataObject = {};
|
||||
if (newName) {
|
||||
body.displayName = newName;
|
||||
}
|
||||
if (newDescription) {
|
||||
body.description = newDescription;
|
||||
}
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/teams/${teamId}/channels/${channelId}`,
|
||||
body,
|
||||
);
|
||||
return { success: true };
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
import { prepareMessage } from '../../helpers/utils';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
teamRLC,
|
||||
channelRLC,
|
||||
{
|
||||
displayName: 'Content Type',
|
||||
name: 'contentType',
|
||||
required: true,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'html',
|
||||
},
|
||||
],
|
||||
default: 'text',
|
||||
description: 'Whether the message is plain text or HTML',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The content of the message to be sent',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include Link to Workflow',
|
||||
name: 'includeLinkToWorkflow',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to append a link to this workflow at the end of the message. This is helpful if you have many workflows sending messages.',
|
||||
},
|
||||
{
|
||||
displayName: 'Reply to ID',
|
||||
name: 'makeReply',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. 1673348720590',
|
||||
description:
|
||||
'An optional ID of the message you want to reply to. The message ID is the number before "?tenantId" in the message URL.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
i: number,
|
||||
nodeVersion: number,
|
||||
instanceId: string,
|
||||
) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=http
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
const contentType = this.getNodeParameter('contentType', i) as string;
|
||||
const message = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
let includeLinkToWorkflow = options.includeLinkToWorkflow;
|
||||
if (includeLinkToWorkflow === undefined) {
|
||||
includeLinkToWorkflow = nodeVersion >= 1.1;
|
||||
}
|
||||
|
||||
const body: IDataObject = prepareMessage.call(
|
||||
this,
|
||||
message,
|
||||
contentType,
|
||||
includeLinkToWorkflow as boolean,
|
||||
instanceId,
|
||||
);
|
||||
|
||||
if (options.makeReply) {
|
||||
const replyToId = options.makeReply as string;
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`,
|
||||
body,
|
||||
);
|
||||
} else {
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { channelRLC, teamRLC } from '../../descriptions';
|
||||
import { microsoftApiRequestAllItems } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [teamRLC, channelRLC, ...returnAllOrLimit];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-beta&tabs=http
|
||||
|
||||
const teamId = this.getNodeParameter('teamId', i, '', { extractValue: true }) as string;
|
||||
const channelId = this.getNodeParameter('channelId', i, '', { extractValue: true }) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/beta/teams/${teamId}/channels/${channelId}/messages`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
|
||||
export { create, getAll };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['channelMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a message in a channel',
|
||||
action: 'Create message',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many messages from a channel',
|
||||
action: 'Get many messages',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...getAll.description,
|
||||
];
|
||||
@@ -0,0 +1,88 @@
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { chatRLC } from '../../descriptions';
|
||||
import { prepareMessage } from '../../helpers/utils';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
chatRLC,
|
||||
{
|
||||
displayName: 'Content Type',
|
||||
name: 'contentType',
|
||||
required: true,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'html',
|
||||
},
|
||||
],
|
||||
default: 'text',
|
||||
description: 'Whether the message is plain text or HTML',
|
||||
},
|
||||
{
|
||||
displayName: 'Message',
|
||||
name: 'message',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The content of the message to be sent',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
description: 'Other options to set',
|
||||
placeholder: 'Add option',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Include Link to Workflow',
|
||||
name: 'includeLinkToWorkflow',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to append a link to this workflow at the end of the message. This is helpful if you have many workflows sending messages.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number, instanceId: string) {
|
||||
// https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
|
||||
const contentType = this.getNodeParameter('contentType', i) as string;
|
||||
const message = this.getNodeParameter('message', i) as string;
|
||||
const options = this.getNodeParameter('options', i, {});
|
||||
|
||||
const includeLinkToWorkflow = options.includeLinkToWorkflow !== false;
|
||||
|
||||
const body: IDataObject = prepareMessage.call(
|
||||
this,
|
||||
message,
|
||||
contentType,
|
||||
includeLinkToWorkflow,
|
||||
instanceId,
|
||||
);
|
||||
|
||||
return await microsoftApiRequest.call(this, 'POST', `/v1.0/chats/${chatId}/messages`, body);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { type INodeProperties, type IExecuteFunctions, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { chatRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
chatRLC,
|
||||
{
|
||||
displayName: 'Message ID',
|
||||
name: 'messageId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. 1673355049064',
|
||||
description: 'The ID of the message to retrieve',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
operation: ['get'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
|
||||
try {
|
||||
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
|
||||
const messageId = this.getNodeParameter('messageId', i) as string;
|
||||
|
||||
return await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages/${messageId}`,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"The message you are trying to get doesn't exist",
|
||||
{
|
||||
description: "Check that the 'Message ID' parameter is correctly set",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { chatRLC } from '../../descriptions';
|
||||
import { microsoftApiRequestAllItems } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [chatRLC, ...returnAllOrLimit];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
// https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/chats/${chatId}/messages`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { SEND_AND_WAIT_OPERATION, type INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as get from './get.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
import * as sendAndWait from './sendAndWait.operation';
|
||||
|
||||
export { create, get, getAll, sendAndWait };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['chatMessage'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a message in a chat',
|
||||
action: 'Create chat message',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a message from a chat',
|
||||
action: 'Get chat message',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many messages from a chat',
|
||||
action: 'Get many chat messages',
|
||||
},
|
||||
{
|
||||
name: 'Send and Wait for Response',
|
||||
value: SEND_AND_WAIT_OPERATION,
|
||||
description: 'Send a message and wait for response',
|
||||
action: 'Send message and wait for response',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...get.description,
|
||||
...getAll.description,
|
||||
...sendAndWait.description,
|
||||
];
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
getSendAndWaitConfig,
|
||||
getSendAndWaitProperties,
|
||||
} from '../../../../../../utils/sendAndWait/utils';
|
||||
import { createUtmCampaignLink } from '../../../../../../utils/utilities';
|
||||
import { chatRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
export const description: INodeProperties[] = getSendAndWaitProperties(
|
||||
[chatRLC],
|
||||
'chatMessage',
|
||||
undefined,
|
||||
{
|
||||
noButtonStyle: true,
|
||||
defaultApproveLabel: '✓ Approve',
|
||||
defaultDisapproveLabel: '✗ Decline',
|
||||
},
|
||||
).filter((p) => p.name !== 'subject');
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number, instanceId: string) {
|
||||
const chatId = this.getNodeParameter('chatId', i, '', { extractValue: true }) as string;
|
||||
const config = getSendAndWaitConfig(this);
|
||||
|
||||
const buttons = config.options.map((option) => `<a href="${option.url}">${option.label}</a>`);
|
||||
|
||||
let content = `${config.message}<br><br>${buttons.join(' ')}`;
|
||||
|
||||
if (config.appendAttribution !== false) {
|
||||
const attributionText = 'This message was sent automatically with';
|
||||
const link = createUtmCampaignLink('n8n-nodes-base.microsoftTeams', instanceId);
|
||||
const attribution = `<em>${attributionText} <a href="${link}">n8n</a></em>`;
|
||||
content += `<br><br>${attribution}`;
|
||||
}
|
||||
|
||||
const body = {
|
||||
body: {
|
||||
contentType: 'html',
|
||||
content,
|
||||
},
|
||||
};
|
||||
|
||||
return await microsoftApiRequest.call(this, 'POST', `/v1.0/chats/${chatId}/messages`, body);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { AllEntities } from 'n8n-workflow';
|
||||
|
||||
type NodeMap = {
|
||||
channel: 'create' | 'deleteChannel' | 'get' | 'getAll' | 'update';
|
||||
channelMessage: 'create' | 'getAll';
|
||||
chatMessage: 'create' | 'get' | 'getAll' | 'sendAndWait';
|
||||
task: 'create' | 'deleteTask' | 'get' | 'getAll' | 'update';
|
||||
};
|
||||
|
||||
export type MicrosoftTeamsType = AllEntities<NodeMap>;
|
||||
@@ -0,0 +1,94 @@
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type IDataObject,
|
||||
type INodeExecutionData,
|
||||
NodeOperationError,
|
||||
SEND_AND_WAIT_OPERATION,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import * as channel from './channel';
|
||||
import * as channelMessage from './channelMessage';
|
||||
import * as chatMessage from './chatMessage';
|
||||
import type { MicrosoftTeamsType } from './node.type';
|
||||
import * as task from './task';
|
||||
import { configureWaitTillDate } from '../../../../../utils/sendAndWait/configureWaitTillDate.util';
|
||||
|
||||
export async function router(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
let responseData;
|
||||
|
||||
const resource = this.getNodeParameter<MicrosoftTeamsType>('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
const instanceId = this.getInstanceId();
|
||||
|
||||
const microsoftTeamsTypeData = {
|
||||
resource,
|
||||
operation,
|
||||
} as MicrosoftTeamsType;
|
||||
|
||||
if (
|
||||
microsoftTeamsTypeData.resource === 'chatMessage' &&
|
||||
microsoftTeamsTypeData.operation === SEND_AND_WAIT_OPERATION
|
||||
) {
|
||||
await chatMessage[microsoftTeamsTypeData.operation].execute.call(this, 0, instanceId);
|
||||
|
||||
const waitTill = configureWaitTillDate(this);
|
||||
|
||||
await this.putExecutionToWait(waitTill);
|
||||
return [items];
|
||||
}
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
switch (microsoftTeamsTypeData.resource) {
|
||||
case 'channel':
|
||||
responseData = await channel[microsoftTeamsTypeData.operation].execute.call(this, i);
|
||||
break;
|
||||
case 'channelMessage':
|
||||
responseData = await channelMessage[microsoftTeamsTypeData.operation].execute.call(
|
||||
this,
|
||||
i,
|
||||
nodeVersion,
|
||||
instanceId,
|
||||
);
|
||||
break;
|
||||
case 'chatMessage':
|
||||
responseData = await chatMessage[microsoftTeamsTypeData.operation].execute.call(
|
||||
this,
|
||||
i,
|
||||
instanceId,
|
||||
);
|
||||
break;
|
||||
case 'task':
|
||||
responseData = await task[microsoftTeamsTypeData.operation].execute.call(this, i);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
return [returnData];
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { bucketRLC, groupRLC, memberRLC, planRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
groupRLC,
|
||||
planRLC,
|
||||
bucketRLC,
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. new task',
|
||||
description: 'Title of the task',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add option',
|
||||
options: [
|
||||
{
|
||||
...memberRLC,
|
||||
displayName: 'Assigned To',
|
||||
name: 'assignedTo',
|
||||
description: 'Who the task should be assigned to',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['groupId.balue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'string',
|
||||
validateType: 'dateTime',
|
||||
default: '',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
name: 'percentComplete',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
placeholder: 'e.g. 75',
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/planner-post-tasks?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const planId = this.getNodeParameter('planId', i, '', { extractValue: true }) as string;
|
||||
const bucketId = this.getNodeParameter('bucketId', i, '', { extractValue: true }) as string;
|
||||
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
planId,
|
||||
bucketId,
|
||||
title,
|
||||
};
|
||||
|
||||
if (options.assignedTo) {
|
||||
options.assignedTo = this.getNodeParameter('options.assignedTo', i, '', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
}
|
||||
|
||||
if (options.dueDateTime && options.dueDateTime instanceof DateTime) {
|
||||
options.dueDateTime = options.dueDateTime.toISO();
|
||||
}
|
||||
|
||||
Object.assign(body, options);
|
||||
|
||||
if (body.assignedTo) {
|
||||
body.assignments = {
|
||||
[body.assignedTo as string]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete body.assignedTo;
|
||||
}
|
||||
|
||||
return await microsoftApiRequest.call(this, 'POST', '/v1.0/planner/tasks', body);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
placeholder: 'e.g. h3ufgLvXPkSRzYm-zO5cY5gANtBQ',
|
||||
description: 'The ID of the task to delete',
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['deleteTask'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-delete?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
{},
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
return { success: true };
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
description: 'The ID of the task to retrieve',
|
||||
placeholder: 'e.g. h3ufgLvXPkSRzYm-zO5cY5gANtBQ',
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['get'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-get?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
return await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import type { INodeProperties, IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { returnAllOrLimit } from '@utils/descriptions';
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { groupRLC, planRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest, microsoftApiRequestAllItems } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Tasks For',
|
||||
name: 'tasksFor',
|
||||
default: 'member',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Whether to retrieve the tasks for a user or for a plan',
|
||||
options: [
|
||||
{
|
||||
name: 'Group Member',
|
||||
value: 'member',
|
||||
description: 'Tasks assigned to group member',
|
||||
},
|
||||
{
|
||||
name: 'Plan',
|
||||
value: 'plan',
|
||||
description: 'Tasks in group plan',
|
||||
},
|
||||
],
|
||||
},
|
||||
groupRLC,
|
||||
{
|
||||
...planRLC,
|
||||
displayOptions: {
|
||||
show: {
|
||||
tasksFor: ['plan'],
|
||||
},
|
||||
},
|
||||
},
|
||||
...returnAllOrLimit,
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
const tasksFor = this.getNodeParameter('tasksFor', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (tasksFor === 'member') {
|
||||
//https://docs.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const memberId = ((await microsoftApiRequest.call(this, 'GET', '/v1.0/me')) as { id: string })
|
||||
.id;
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/users/${memberId}/planner/tasks`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
} else {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannerplan-list-tasks?view=graph-rest-1.0&tabs=http
|
||||
const planId = this.getNodeParameter('planId', i, '', { extractValue: true }) as string;
|
||||
if (returnAll) {
|
||||
return await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
const responseData = await microsoftApiRequestAllItems.call(
|
||||
this,
|
||||
'value',
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/tasks`,
|
||||
{},
|
||||
);
|
||||
return responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as deleteTask from './deleteTask.operation';
|
||||
import * as get from './get.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
import * as update from './update.operation';
|
||||
|
||||
export { create, deleteTask, get, getAll, update };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a task',
|
||||
action: 'Create task',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'deleteTask',
|
||||
description: 'Delete a task',
|
||||
action: 'Delete task',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a task',
|
||||
action: 'Get task',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many tasks',
|
||||
action: 'Get many tasks',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a task',
|
||||
action: 'Update task',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...deleteTask.description,
|
||||
...get.description,
|
||||
...getAll.description,
|
||||
...update.description,
|
||||
];
|
||||
@@ -0,0 +1,157 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { bucketRLC, groupRLC, memberRLC, planRLC } from '../../descriptions';
|
||||
import { microsoftApiRequest } from '../../transport';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Task ID',
|
||||
name: 'taskId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. h3ufgLvXPkSRzYm-zO5cY5gANtBQ',
|
||||
description: 'The ID of the task to update',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
options: [
|
||||
{
|
||||
...memberRLC,
|
||||
displayName: 'Assigned To',
|
||||
name: 'assignedTo',
|
||||
description: 'Who the task should be assigned to',
|
||||
hint: "Select 'Team' from options first",
|
||||
required: false,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['updateFields.groupId.value'],
|
||||
},
|
||||
},
|
||||
{
|
||||
...bucketRLC,
|
||||
required: false,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['updateFields.planId.value'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date Time',
|
||||
name: 'dueDateTime',
|
||||
type: 'string',
|
||||
validateType: 'dateTime',
|
||||
default: '',
|
||||
description:
|
||||
'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.',
|
||||
},
|
||||
{
|
||||
...groupRLC,
|
||||
required: false,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['/groupSource'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Percent Complete',
|
||||
name: 'percentComplete',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 0,
|
||||
placeholder: 'e.g. 75',
|
||||
description:
|
||||
'Percentage of task completion. When set to 100, the task is considered completed.',
|
||||
},
|
||||
{
|
||||
...planRLC,
|
||||
required: false,
|
||||
hint: "Select 'Team' from options first",
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['updateFields.groupId.value'],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g. my task',
|
||||
description: 'Title of the task',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['task'],
|
||||
operation: ['update'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number) {
|
||||
//https://docs.microsoft.com/en-us/graph/api/plannertask-update?view=graph-rest-1.0&tabs=http
|
||||
|
||||
const taskId = this.getNodeParameter('taskId', i, '', { extractValue: true }) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
|
||||
for (const key of Object.keys(updateFields)) {
|
||||
if (key === 'groupId') {
|
||||
// tasks are assigned to a plan and bucket, group is used for filtering
|
||||
delete updateFields.groupId;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key === 'assignedTo') {
|
||||
const assignedTo = this.getNodeParameter('updateFields.assignedTo', i, '', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
updateFields.assignments = {
|
||||
[assignedTo]: {
|
||||
'@odata.type': 'microsoft.graph.plannerAssignment',
|
||||
orderHint: ' !',
|
||||
},
|
||||
};
|
||||
delete updateFields.assignedTo;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (['bucketId', 'planId'].includes(key)) {
|
||||
updateFields[key] = this.getNodeParameter(`updateFields.${key}`, i, '', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
}
|
||||
|
||||
if (key === 'dueDateTime' && updateFields.dueDateTime instanceof DateTime) {
|
||||
updateFields.dueDateTime = updateFields.dueDateTime.toISO();
|
||||
}
|
||||
}
|
||||
|
||||
const body: IDataObject = {};
|
||||
Object.assign(body, updateFields);
|
||||
|
||||
const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`);
|
||||
|
||||
await microsoftApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/v1.0/planner/tasks/${taskId}`,
|
||||
body,
|
||||
{},
|
||||
undefined,
|
||||
{ 'If-Match': task['@odata.etag'] },
|
||||
);
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
|
||||
import { NodeConnectionTypes, type INodeTypeDescription } from 'n8n-workflow';
|
||||
|
||||
import * as channel from './channel';
|
||||
import * as channelMessage from './channelMessage';
|
||||
import * as chatMessage from './chatMessage';
|
||||
import * as task from './task';
|
||||
import { sendAndWaitWebhooksDescription } from '../../../../../utils/sendAndWait/descriptions';
|
||||
import { SEND_AND_WAIT_WAITING_TOOLTIP } from '../../../../../utils/sendAndWait/utils';
|
||||
|
||||
export const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'Microsoft Teams',
|
||||
name: 'microsoftTeams',
|
||||
icon: 'file:teams.svg',
|
||||
group: ['input'],
|
||||
version: 2,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Microsoft Teams API',
|
||||
defaults: {
|
||||
name: 'Microsoft Teams',
|
||||
},
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'microsoftTeamsOAuth2Api',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
waitingNodeTooltip: SEND_AND_WAIT_WAITING_TOOLTIP,
|
||||
webhooks: sendAndWaitWebhooksDescription,
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Channel',
|
||||
value: 'channel',
|
||||
},
|
||||
{
|
||||
name: 'Channel Message',
|
||||
value: 'channelMessage',
|
||||
},
|
||||
{
|
||||
name: 'Chat Message',
|
||||
value: 'chatMessage',
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
],
|
||||
default: 'channel',
|
||||
},
|
||||
|
||||
...channel.description,
|
||||
...channelMessage.description,
|
||||
...chatMessage.description,
|
||||
...task.description,
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const groupSourceOptions: INodeProperties = {
|
||||
displayName: 'Group Source',
|
||||
name: 'groupSource',
|
||||
required: true,
|
||||
type: 'options',
|
||||
default: 'all',
|
||||
description: 'From where to select groups and teams',
|
||||
options: [
|
||||
{
|
||||
name: 'All Groups',
|
||||
value: 'all',
|
||||
description: 'From all groups',
|
||||
},
|
||||
{
|
||||
name: 'My Groups',
|
||||
value: 'mine',
|
||||
description: 'Only load groups that account is member of',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './rlc.description';
|
||||
export * from './common.description';
|
||||
@@ -0,0 +1,269 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const teamRLC: INodeProperties = {
|
||||
displayName: 'Team',
|
||||
name: 'teamId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
description:
|
||||
'Select the team from the list, by URL, or by ID (the ID is the "groupId" parameter in the URL you get from "Get a link to the team")',
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'e.g. My Team',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getTeams',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'From URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
placeholder: 'e.g. https://teams.microsoft.com/l/team/19%3AP8l9gXd6oqlgq…',
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: 'groupId=([a-f0-9-]+)\\&',
|
||||
},
|
||||
validation: [
|
||||
{
|
||||
type: 'regex',
|
||||
properties: {
|
||||
regex: 'https:\\/\\/teams.microsoft.com\\/.*groupId=[a-f0-9-]+\\&.*',
|
||||
errorMessage: 'Not a valid Microsoft Teams URL',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: 'e.g. 61165b04-e4cc-4026-b43f-926b4e2a7182',
|
||||
validation: [
|
||||
{
|
||||
type: 'regex',
|
||||
properties: {
|
||||
regex: '^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})[ \t]*',
|
||||
errorMessage: 'Not a valid Microsoft Teams Team ID',
|
||||
},
|
||||
},
|
||||
],
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: '^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const channelRLC: INodeProperties = {
|
||||
displayName: 'Channel',
|
||||
name: 'channelId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
description:
|
||||
'Select the channel from the list, by URL, or by ID (the ID is the "threadId" in the URL)',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['teamId.value'],
|
||||
},
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a Channel...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getChannels',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: '19:-xlxyqXNSCxpI1SDzgQ_L9ZvzSR26pgphq1BJ9y7QJE1@thread.tacv2',
|
||||
// validation missing because no documentation found how these unique ids look like.
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const chatRLC: INodeProperties = {
|
||||
displayName: 'Chat',
|
||||
name: 'chatId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
description:
|
||||
'Select the chat from the list, by URL, or by ID (find the chat ID after "conversations/" in the URL)',
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a Chat...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getChats',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder:
|
||||
'19:7e2f1174-e8ee-4859-b8b1-a8d1cc63d276_0c5cfdbb-596f-4d39-b557-5d9516c94107@unq.gbl.spaces',
|
||||
// validation missing because no documentation found how these unique chat ids look like.
|
||||
url: '=https://teams.microsoft.com/l/chat/{{encodeURIComponent($value)}}/0',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const groupRLC: INodeProperties = {
|
||||
displayName: 'Team',
|
||||
name: 'groupId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['groupSource'],
|
||||
},
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a Team...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getGroups',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: '12f0ca7d-b77f-4c4e-93d2-5cbdb4f464c6',
|
||||
validation: [
|
||||
{
|
||||
type: 'regex',
|
||||
properties: {
|
||||
regex: '^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})[ \t]*',
|
||||
errorMessage: 'Not a valid Microsoft Teams Team ID',
|
||||
},
|
||||
},
|
||||
],
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: '^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const planRLC: INodeProperties = {
|
||||
displayName: 'Plan',
|
||||
name: 'planId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['groupId.value'],
|
||||
},
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a Plan...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getPlans',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: 'rl1HYb0cUEiHPc7zgB_KWWUAA7Of',
|
||||
// validation missing because no documentation found how these unique ids look like.
|
||||
},
|
||||
],
|
||||
description: 'The plan for the task to belong to',
|
||||
};
|
||||
|
||||
export const bucketRLC: INodeProperties = {
|
||||
displayName: 'Bucket',
|
||||
name: 'bucketId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['planId.value'],
|
||||
},
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a Bucket...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getBuckets',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: 'rl1HYb0cUEiHPc7zgB_KWWUAA7Of',
|
||||
// validation missing because no documentation found how these unique ids look like.
|
||||
},
|
||||
],
|
||||
description: 'The bucket for the task to belong to',
|
||||
};
|
||||
|
||||
export const memberRLC: INodeProperties = {
|
||||
displayName: 'Member',
|
||||
name: 'memberId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: ['groupId.value'],
|
||||
},
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
placeholder: 'Select a Member...',
|
||||
typeOptions: {
|
||||
searchListMethod: 'getMembers',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
placeholder: '7e2f1174-e8ee-4859-b8b1-a8d1cc63d276',
|
||||
validation: [
|
||||
{
|
||||
type: 'regex',
|
||||
properties: {
|
||||
regex: '^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})[ \t]*',
|
||||
errorMessage: 'Not a valid Microsoft Teams Team ID',
|
||||
},
|
||||
},
|
||||
],
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: '^([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
export interface TeamResponse {
|
||||
id: string;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export interface ChannelResponse {
|
||||
id: string;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export interface WebhookNotification {
|
||||
subscriptionId: string;
|
||||
resource: string;
|
||||
resourceData: ResourceData;
|
||||
tenantId: string;
|
||||
subscriptionExpirationDateTime: string;
|
||||
}
|
||||
|
||||
export interface ResourceData {
|
||||
id: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface SubscriptionResponse {
|
||||
id: string;
|
||||
expirationDateTime: string;
|
||||
notificationUrl: string;
|
||||
resource: string;
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import type { IHookFunctions, IDataObject } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import type { TeamResponse, ChannelResponse, SubscriptionResponse } from './types';
|
||||
import { microsoftApiRequest } from '../transport';
|
||||
|
||||
export async function fetchAllTeams(this: IHookFunctions): Promise<TeamResponse[]> {
|
||||
const { value: teams } = (await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/v1.0/me/joinedTeams',
|
||||
)) as { value: TeamResponse[] };
|
||||
return teams;
|
||||
}
|
||||
|
||||
export async function fetchAllChannels(
|
||||
this: IHookFunctions,
|
||||
teamId: string,
|
||||
): Promise<ChannelResponse[]> {
|
||||
const { value: channels } = (await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/teams/${teamId}/channels`,
|
||||
)) as { value: ChannelResponse[] };
|
||||
return channels;
|
||||
}
|
||||
|
||||
export async function createSubscription(
|
||||
this: IHookFunctions,
|
||||
webhookUrl: string,
|
||||
resourcePath: string,
|
||||
): Promise<SubscriptionResponse> {
|
||||
const expirationTime = new Date(Date.now() + 4318 * 60 * 1000).toISOString();
|
||||
const body: IDataObject = {
|
||||
changeType: 'created',
|
||||
notificationUrl: webhookUrl,
|
||||
resource: resourcePath,
|
||||
expirationDateTime: expirationTime,
|
||||
latestSupportedTlsVersion: 'v1_2',
|
||||
lifecycleNotificationUrl: webhookUrl,
|
||||
};
|
||||
|
||||
const response = (await microsoftApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'/v1.0/subscriptions',
|
||||
body,
|
||||
)) as SubscriptionResponse;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getResourcePath(
|
||||
this: IHookFunctions,
|
||||
event: string,
|
||||
): Promise<string | string[]> {
|
||||
switch (event) {
|
||||
case 'newChat': {
|
||||
return '/me/chats';
|
||||
}
|
||||
|
||||
case 'newChatMessage': {
|
||||
const watchAllChats = this.getNodeParameter('watchAllChats', false, {
|
||||
extractValue: true,
|
||||
}) as boolean;
|
||||
|
||||
if (watchAllChats) {
|
||||
return '/me/chats/getAllMessages';
|
||||
} else {
|
||||
const chatId = this.getNodeParameter('chatId', undefined, { extractValue: true }) as string;
|
||||
return `/chats/${decodeURIComponent(chatId)}/messages`;
|
||||
}
|
||||
}
|
||||
|
||||
case 'newChannel': {
|
||||
const watchAllTeams = this.getNodeParameter('watchAllTeams', false, {
|
||||
extractValue: true,
|
||||
}) as boolean;
|
||||
|
||||
if (watchAllTeams) {
|
||||
const teams = await fetchAllTeams.call(this);
|
||||
return teams.map((team) => `/teams/${team.id}/channels`);
|
||||
} else {
|
||||
const teamId = this.getNodeParameter('teamId', undefined, { extractValue: true }) as string;
|
||||
return `/teams/${teamId}/channels`;
|
||||
}
|
||||
}
|
||||
|
||||
case 'newChannelMessage': {
|
||||
const watchAllTeams = this.getNodeParameter('watchAllTeams', false, {
|
||||
extractValue: true,
|
||||
}) as boolean;
|
||||
|
||||
if (watchAllTeams) {
|
||||
const teams = await fetchAllTeams.call(this);
|
||||
const teamChannels = await Promise.all(
|
||||
teams.map(async (team) => {
|
||||
const channels = await fetchAllChannels.call(this, team.id);
|
||||
return channels.map((channel) => `/teams/${team.id}/channels/${channel.id}/messages`);
|
||||
}),
|
||||
);
|
||||
return teamChannels.flat();
|
||||
} else {
|
||||
const teamId = this.getNodeParameter('teamId', undefined, { extractValue: true }) as string;
|
||||
const watchAllChannels = this.getNodeParameter('watchAllChannels', false, {
|
||||
extractValue: true,
|
||||
}) as boolean;
|
||||
|
||||
if (watchAllChannels) {
|
||||
const channels = await fetchAllChannels.call(this, teamId);
|
||||
return channels.map((channel) => `/teams/${teamId}/channels/${channel.id}/messages`);
|
||||
} else {
|
||||
const channelId = this.getNodeParameter('channelId', undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
return `/teams/${teamId}/channels/${decodeURIComponent(channelId)}/messages`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case 'newTeamMember': {
|
||||
const watchAllTeams = this.getNodeParameter('watchAllTeams', false, {
|
||||
extractValue: true,
|
||||
}) as boolean;
|
||||
|
||||
if (watchAllTeams) {
|
||||
const teams = await fetchAllTeams.call(this);
|
||||
return teams.map((team) => `/teams/${team.id}/members`);
|
||||
} else {
|
||||
const teamId = this.getNodeParameter('teamId', undefined, { extractValue: true }) as string;
|
||||
return `/teams/${teamId}/members`;
|
||||
}
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new NodeOperationError(this.getNode(), {
|
||||
message: `Invalid event: ${event}`,
|
||||
description: `The selected event "${event}" is not recognized.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { IExecuteFunctions, ILoadOptionsFunctions, INodeListSearchItems } from 'n8n-workflow';
|
||||
|
||||
export function prepareMessage(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
message: string,
|
||||
contentType: string,
|
||||
includeLinkToWorkflow: boolean,
|
||||
instanceId?: string,
|
||||
) {
|
||||
if (includeLinkToWorkflow) {
|
||||
const { id } = this.getWorkflow();
|
||||
const link = `${this.getInstanceBaseUrl()}workflow/${id}?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=${encodeURIComponent(
|
||||
'n8n-nodes-base.microsoftTeams',
|
||||
)}${instanceId ? '_' + instanceId : ''}`;
|
||||
contentType = 'html';
|
||||
message = `${message}<br><br><em> Powered by <a href="${link}">this n8n workflow</a> </em>`;
|
||||
}
|
||||
|
||||
return {
|
||||
body: {
|
||||
contentType,
|
||||
content: message,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function filterSortSearchListItems(items: INodeListSearchItems[], filter?: string) {
|
||||
return items
|
||||
.filter(
|
||||
(item) =>
|
||||
!filter ||
|
||||
item.name.toLowerCase().includes(filter.toLowerCase()) ||
|
||||
item.value.toString().toLowerCase().includes(filter.toLowerCase()),
|
||||
)
|
||||
.sort((a, b) => {
|
||||
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * as listSearch from './listSearch';
|
||||
@@ -0,0 +1,280 @@
|
||||
import {
|
||||
NodeOperationError,
|
||||
type IDataObject,
|
||||
type ILoadOptionsFunctions,
|
||||
type INodeListSearchItems,
|
||||
type INodeListSearchResult,
|
||||
sleep,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { filterSortSearchListItems } from '../helpers/utils';
|
||||
import { microsoftApiRequest } from '../transport';
|
||||
|
||||
export async function getChats(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const returnData: INodeListSearchItems[] = [];
|
||||
const qs: IDataObject = {
|
||||
$expand: 'members',
|
||||
};
|
||||
|
||||
let value: IDataObject[] = [];
|
||||
let attempts = 5;
|
||||
do {
|
||||
try {
|
||||
value = ((await microsoftApiRequest.call(this, 'GET', '/v1.0/chats', {}, qs)) as IDataObject)
|
||||
.value as IDataObject[];
|
||||
break;
|
||||
} catch (error) {
|
||||
if (attempts > 0) {
|
||||
await sleep(1000);
|
||||
attempts--;
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
} while (attempts > 0);
|
||||
|
||||
for (const chat of value) {
|
||||
if (!chat.topic) {
|
||||
chat.topic = (chat.members as IDataObject[])
|
||||
.filter((member: IDataObject) => member.displayName)
|
||||
.map((member: IDataObject) => member.displayName)
|
||||
.join(', ');
|
||||
}
|
||||
const chatName = `${chat.topic || '(no title) - ' + chat.id} (${chat.chatType})`;
|
||||
const chatId = chat.id;
|
||||
const url = chat.webUrl as string;
|
||||
returnData.push({
|
||||
name: chatName,
|
||||
value: chatId as string,
|
||||
url,
|
||||
});
|
||||
}
|
||||
|
||||
const results = returnData
|
||||
.filter(
|
||||
(item) =>
|
||||
!filter ||
|
||||
item.name.toLowerCase().includes(filter.toLowerCase()) ||
|
||||
item.value.toString().toLowerCase().includes(filter.toLowerCase()),
|
||||
)
|
||||
.sort((a, b) => {
|
||||
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return { results };
|
||||
}
|
||||
|
||||
export async function getTeams(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const returnData: INodeListSearchItems[] = [];
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', '/v1.0/me/joinedTeams');
|
||||
|
||||
for (const team of value) {
|
||||
const teamName = team.displayName;
|
||||
const teamId = team.id;
|
||||
// let channelId: string = '';
|
||||
|
||||
// try {
|
||||
// const channels = await microsoftApiRequestAllItems.call(
|
||||
// this,
|
||||
// 'value',
|
||||
// 'GET',
|
||||
// `/v1.0/teams/${teamId}/channels`,
|
||||
// {},
|
||||
// );
|
||||
|
||||
// if (channels.length > 0) {
|
||||
// channelId = channels.find((channel: IDataObject) => channel.displayName === 'General').id;
|
||||
// if (!channelId) {
|
||||
// channelId = channels[0].id;
|
||||
// }
|
||||
// }
|
||||
// } catch (error) {}
|
||||
|
||||
returnData.push({
|
||||
name: teamName,
|
||||
value: teamId,
|
||||
// url: channelId
|
||||
// ? `https://teams.microsoft.com/l/team/${channelId}/conversations?groupId=${teamId}&tenantId=${team.tenantId}`
|
||||
// : undefined,
|
||||
});
|
||||
}
|
||||
const results = filterSortSearchListItems(returnData, filter);
|
||||
|
||||
return { results };
|
||||
}
|
||||
|
||||
export async function getChannels(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const returnData: INodeListSearchItems[] = [];
|
||||
const teamId = this.getCurrentNodeParameter('teamId', { extractValue: true }) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
|
||||
const excludeGeneralChannel = ['deleteChannel'];
|
||||
|
||||
if (resource === 'channel') excludeGeneralChannel.push('update');
|
||||
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/teams/${teamId}/channels`);
|
||||
|
||||
for (const channel of value) {
|
||||
if (channel.displayName === 'General' && excludeGeneralChannel.includes(operation)) {
|
||||
continue;
|
||||
}
|
||||
const channelName = channel.displayName;
|
||||
const channelId = channel.id;
|
||||
const url = channel.webUrl;
|
||||
returnData.push({
|
||||
name: channelName,
|
||||
value: channelId,
|
||||
url,
|
||||
});
|
||||
}
|
||||
|
||||
const results = filterSortSearchListItems(returnData, filter);
|
||||
return { results };
|
||||
}
|
||||
|
||||
export async function getGroups(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const returnData: INodeListSearchItems[] = [];
|
||||
// const groupSource = this.getCurrentNodeParameter('groupSource') as string;
|
||||
const requestUrl = '/v1.0/groups' as string;
|
||||
|
||||
// if (groupSource === 'mine') {
|
||||
// requestUrl = '/v1.0/me/transitiveMemberOf';
|
||||
// }
|
||||
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', requestUrl);
|
||||
|
||||
for (const group of value) {
|
||||
if (group.displayName === 'All Company') continue;
|
||||
|
||||
const name = group.displayName || group.mail;
|
||||
|
||||
if (name === undefined) continue;
|
||||
|
||||
returnData.push({
|
||||
name,
|
||||
value: group.id,
|
||||
});
|
||||
}
|
||||
|
||||
const results = filterSortSearchListItems(returnData, filter);
|
||||
return { results };
|
||||
}
|
||||
|
||||
export async function getPlans(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const returnData: INodeListSearchItems[] = [];
|
||||
|
||||
let groupId = '';
|
||||
|
||||
try {
|
||||
groupId = this.getCurrentNodeParameter('groupId', { extractValue: true }) as string;
|
||||
} catch (error) {}
|
||||
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
if (operation === 'update' && !groupId) {
|
||||
groupId = this.getCurrentNodeParameter('updateFields.groupId', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
}
|
||||
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/groups/${groupId}/planner/plans`,
|
||||
);
|
||||
for (const plan of value) {
|
||||
returnData.push({
|
||||
name: plan.title,
|
||||
value: plan.id,
|
||||
});
|
||||
}
|
||||
const results = filterSortSearchListItems(returnData, filter);
|
||||
return { results };
|
||||
}
|
||||
|
||||
export async function getBuckets(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const returnData: INodeListSearchItems[] = [];
|
||||
let planId = '';
|
||||
|
||||
try {
|
||||
planId = this.getCurrentNodeParameter('planId', { extractValue: true }) as string;
|
||||
} catch (error) {}
|
||||
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
if (operation === 'update' && !planId) {
|
||||
planId = this.getCurrentNodeParameter('updateFields.planId', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
}
|
||||
|
||||
const { value } = await microsoftApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/v1.0/planner/plans/${planId}/buckets`,
|
||||
);
|
||||
for (const bucket of value) {
|
||||
returnData.push({
|
||||
name: bucket.name,
|
||||
value: bucket.id,
|
||||
});
|
||||
}
|
||||
const results = filterSortSearchListItems(returnData, filter);
|
||||
return { results };
|
||||
}
|
||||
|
||||
export async function getMembers(
|
||||
this: ILoadOptionsFunctions,
|
||||
filter?: string,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const returnData: INodeListSearchItems[] = [];
|
||||
let groupId = '';
|
||||
|
||||
try {
|
||||
groupId = this.getCurrentNodeParameter('groupId', { extractValue: true }) as string;
|
||||
} catch (error) {}
|
||||
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
if (operation === 'update' && !groupId) {
|
||||
groupId = this.getCurrentNodeParameter('updateFields.groupId', {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
}
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/groups/${groupId}/members`);
|
||||
|
||||
for (const member of value) {
|
||||
returnData.push({
|
||||
name: member.displayName,
|
||||
value: member.id,
|
||||
});
|
||||
}
|
||||
|
||||
const results = filterSortSearchListItems(returnData, filter);
|
||||
return { results };
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
import { mockDeep } from 'jest-mock-extended';
|
||||
import type { IExecuteFunctions, INode } from 'n8n-workflow';
|
||||
|
||||
import { microsoftApiRequest } from '../../transport/index';
|
||||
|
||||
describe('Microsoft Teams Transport', () => {
|
||||
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 Teams Node',
|
||||
type: 'n8n-nodes-base.microsoftTeams',
|
||||
typeVersion: 2,
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://graph.microsoft.us/teams',
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://graph.microsoft.com/teams',
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://graph.microsoft.com/teams',
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://graph.microsoft.com/teams',
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://graph.microsoft.com/teams',
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://graph.microsoft.us/teams',
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://dod-graph.microsoft.us/teams',
|
||||
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', '/teams');
|
||||
|
||||
expect(mockRequestOAuth2).toHaveBeenCalledWith(
|
||||
'microsoftTeamsOAuth2Api',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
uri: 'https://microsoftgraph.chinacloudapi.cn/teams',
|
||||
json: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,108 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IDataObject,
|
||||
JsonObject,
|
||||
IHttpRequestMethods,
|
||||
IRequestOptions,
|
||||
IHookFunctions,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import { capitalize } from '../../../../../utils/utilities';
|
||||
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('microsoftTeamsOAuth2Api');
|
||||
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}${resource}`,
|
||||
json: true,
|
||||
};
|
||||
try {
|
||||
if (Object.keys(headers).length !== 0) {
|
||||
options.headers = Object.assign({}, options.headers, headers);
|
||||
}
|
||||
return await this.helpers.requestOAuth2.call(this, 'microsoftTeamsOAuth2Api', options);
|
||||
} catch (error) {
|
||||
const errorOptions: IDataObject = {};
|
||||
if (error.error?.error) {
|
||||
const httpCode = error.statusCode;
|
||||
error = error.error.error;
|
||||
error.statusCode = httpCode;
|
||||
errorOptions.message = error.message;
|
||||
|
||||
if (error.code === 'NotFound' && error.message === 'Resource not found') {
|
||||
const nodeResource = capitalize(this.getNodeParameter('resource', 0) as string);
|
||||
errorOptions.message = `${nodeResource} not found`;
|
||||
}
|
||||
}
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject, errorOptions);
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
let uri: string | undefined;
|
||||
|
||||
do {
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = responseData['@odata.nextLink'];
|
||||
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
|
||||
const limit = query.limit as number | undefined;
|
||||
if (limit && limit <= returnData.length) {
|
||||
return returnData;
|
||||
}
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user