@blickwerk/n8n-nodes-microsoft-planner 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,3 +3,6 @@ export declare function microsoftApiRequest(this: IHookFunctions | IExecuteFunct
3
3
  export declare function microsoftApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: IHttpRequestMethods, endpoint: string, body?: IDataObject, query?: IDataObject): Promise<any>;
4
4
  export declare function cleanETag(eTag: string): string;
5
5
  export declare function formatDateTime(dateTime: string | undefined): string | undefined;
6
+ export declare function getUserIdByEmail(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, email: string): Promise<string | null>;
7
+ export declare function parseAssignments(assignmentsString: string): string[];
8
+ export declare function createAssignmentsObject(userIds: string[]): IDataObject;
@@ -4,6 +4,9 @@ exports.microsoftApiRequest = microsoftApiRequest;
4
4
  exports.microsoftApiRequestAllItems = microsoftApiRequestAllItems;
5
5
  exports.cleanETag = cleanETag;
6
6
  exports.formatDateTime = formatDateTime;
7
+ exports.getUserIdByEmail = getUserIdByEmail;
8
+ exports.parseAssignments = parseAssignments;
9
+ exports.createAssignmentsObject = createAssignmentsObject;
7
10
  const n8n_workflow_1 = require("n8n-workflow");
8
11
  async function microsoftApiRequest(method, resource, body = {}, qs = {}, uri, headers = {}) {
9
12
  const options = {
@@ -61,3 +64,31 @@ function formatDateTime(dateTime) {
61
64
  }
62
65
  return date.toISOString();
63
66
  }
67
+ async function getUserIdByEmail(email) {
68
+ try {
69
+ const response = await microsoftApiRequest.call(this, 'GET', `/users/${encodeURIComponent(email)}`);
70
+ return response.id;
71
+ }
72
+ catch (error) {
73
+ return null;
74
+ }
75
+ }
76
+ function parseAssignments(assignmentsString) {
77
+ if (!assignmentsString || assignmentsString.trim() === '') {
78
+ return [];
79
+ }
80
+ return assignmentsString
81
+ .split(',')
82
+ .map((email) => email.trim())
83
+ .filter((email) => email.length > 0);
84
+ }
85
+ function createAssignmentsObject(userIds) {
86
+ const assignments = {};
87
+ for (const userId of userIds) {
88
+ assignments[userId] = {
89
+ '@odata.type': '#microsoft.graph.plannerAssignment',
90
+ orderHint: ' !',
91
+ };
92
+ }
93
+ return assignments;
94
+ }
@@ -77,6 +77,20 @@ class MicrosoftPlanner {
77
77
  if (additionalFields.percentComplete !== undefined) {
78
78
  body.percentComplete = additionalFields.percentComplete;
79
79
  }
80
+ // Handle assignments
81
+ if (additionalFields.assignments) {
82
+ const emails = (0, GenericFunctions_1.parseAssignments)(additionalFields.assignments);
83
+ const userIds = [];
84
+ for (const email of emails) {
85
+ const userId = await GenericFunctions_1.getUserIdByEmail.call(this, email);
86
+ if (userId) {
87
+ userIds.push(userId);
88
+ }
89
+ }
90
+ if (userIds.length > 0) {
91
+ body.assignments = (0, GenericFunctions_1.createAssignmentsObject)(userIds);
92
+ }
93
+ }
80
94
  const responseData = await GenericFunctions_1.microsoftApiRequest.call(this, 'POST', '/planner/tasks', body);
81
95
  // Add description if provided
82
96
  if (additionalFields.description) {
@@ -160,6 +174,20 @@ class MicrosoftPlanner {
160
174
  if (updateFields.bucketId) {
161
175
  body.bucketId = updateFields.bucketId;
162
176
  }
177
+ // Handle assignments
178
+ if (updateFields.assignments) {
179
+ const emails = (0, GenericFunctions_1.parseAssignments)(updateFields.assignments);
180
+ const userIds = [];
181
+ for (const email of emails) {
182
+ const userId = await GenericFunctions_1.getUserIdByEmail.call(this, email);
183
+ if (userId) {
184
+ userIds.push(userId);
185
+ }
186
+ }
187
+ if (userIds.length > 0) {
188
+ body.assignments = (0, GenericFunctions_1.createAssignmentsObject)(userIds);
189
+ }
190
+ }
163
191
  const responseData = await GenericFunctions_1.microsoftApiRequest.call(this, 'PATCH', `/planner/tasks/${taskId}`, body, {}, undefined, {
164
192
  'If-Match': eTag,
165
193
  });
@@ -119,9 +119,35 @@ exports.taskFields = [
119
119
  {
120
120
  displayName: 'Priority',
121
121
  name: 'priority',
122
- type: 'number',
122
+ type: 'options',
123
+ options: [
124
+ {
125
+ name: 'Urgent',
126
+ value: 0,
127
+ },
128
+ {
129
+ name: 'Important',
130
+ value: 1,
131
+ },
132
+ {
133
+ name: 'Medium',
134
+ value: 5,
135
+ },
136
+ {
137
+ name: 'Low',
138
+ value: 9,
139
+ },
140
+ ],
123
141
  default: 5,
124
- description: 'Priority of the task (0-10, where 0 is most urgent)',
142
+ description: 'Priority of the task',
143
+ },
144
+ {
145
+ displayName: 'Assigned To (User IDs)',
146
+ name: 'assignments',
147
+ type: 'string',
148
+ default: '',
149
+ placeholder: 'user1@domain.com, user2@domain.com',
150
+ description: 'Comma-separated list of user emails or IDs to assign the task to',
125
151
  },
126
152
  {
127
153
  displayName: 'Due Date Time',
@@ -284,9 +310,35 @@ exports.taskFields = [
284
310
  {
285
311
  displayName: 'Priority',
286
312
  name: 'priority',
287
- type: 'number',
313
+ type: 'options',
314
+ options: [
315
+ {
316
+ name: 'Urgent',
317
+ value: 0,
318
+ },
319
+ {
320
+ name: 'Important',
321
+ value: 1,
322
+ },
323
+ {
324
+ name: 'Medium',
325
+ value: 5,
326
+ },
327
+ {
328
+ name: 'Low',
329
+ value: 9,
330
+ },
331
+ ],
288
332
  default: 5,
289
- description: 'Priority of the task (0-10, where 0 is most urgent)',
333
+ description: 'Priority of the task',
334
+ },
335
+ {
336
+ displayName: 'Assigned To (User IDs)',
337
+ name: 'assignments',
338
+ type: 'string',
339
+ default: '',
340
+ placeholder: 'user1@domain.com, user2@domain.com',
341
+ description: 'Comma-separated list of user emails or IDs to assign the task to',
290
342
  },
291
343
  {
292
344
  displayName: 'Due Date Time',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blickwerk/n8n-nodes-microsoft-planner",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "n8n node for Microsoft Planner - Create and retrieve tasks",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",