@blickwerk/n8n-nodes-microsoft-planner 1.0.0 → 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.
|
@@ -2,3 +2,7 @@ import { IDataObject, IExecuteFunctions, IHookFunctions, IHttpRequestMethods, IL
|
|
|
2
2
|
export declare function microsoftApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, resource: string, body?: IDataObject, qs?: IDataObject, uri?: string, headers?: IDataObject): Promise<any>;
|
|
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
|
+
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;
|
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.microsoftApiRequest = microsoftApiRequest;
|
|
4
4
|
exports.microsoftApiRequestAllItems = microsoftApiRequestAllItems;
|
|
5
5
|
exports.cleanETag = cleanETag;
|
|
6
|
+
exports.formatDateTime = formatDateTime;
|
|
7
|
+
exports.getUserIdByEmail = getUserIdByEmail;
|
|
8
|
+
exports.parseAssignments = parseAssignments;
|
|
9
|
+
exports.createAssignmentsObject = createAssignmentsObject;
|
|
6
10
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
11
|
async function microsoftApiRequest(method, resource, body = {}, qs = {}, uri, headers = {}) {
|
|
8
12
|
const options = {
|
|
@@ -45,3 +49,46 @@ function cleanETag(eTag) {
|
|
|
45
49
|
}
|
|
46
50
|
return eTag;
|
|
47
51
|
}
|
|
52
|
+
function formatDateTime(dateTime) {
|
|
53
|
+
if (!dateTime) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
// If already in ISO format with timezone, return as is
|
|
57
|
+
if (dateTime.includes('T') && (dateTime.endsWith('Z') || dateTime.includes('+'))) {
|
|
58
|
+
return dateTime;
|
|
59
|
+
}
|
|
60
|
+
// Convert to ISO 8601 format with UTC timezone
|
|
61
|
+
const date = new Date(dateTime);
|
|
62
|
+
if (isNaN(date.getTime())) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
return date.toISOString();
|
|
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
|
+
}
|
|
@@ -69,14 +69,28 @@ class MicrosoftPlanner {
|
|
|
69
69
|
body.priority = additionalFields.priority;
|
|
70
70
|
}
|
|
71
71
|
if (additionalFields.dueDateTime) {
|
|
72
|
-
body.dueDateTime = additionalFields.dueDateTime;
|
|
72
|
+
body.dueDateTime = (0, GenericFunctions_1.formatDateTime)(additionalFields.dueDateTime);
|
|
73
73
|
}
|
|
74
74
|
if (additionalFields.startDateTime) {
|
|
75
|
-
body.startDateTime = additionalFields.startDateTime;
|
|
75
|
+
body.startDateTime = (0, GenericFunctions_1.formatDateTime)(additionalFields.startDateTime);
|
|
76
76
|
}
|
|
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) {
|
|
@@ -149,10 +163,10 @@ class MicrosoftPlanner {
|
|
|
149
163
|
body.priority = updateFields.priority;
|
|
150
164
|
}
|
|
151
165
|
if (updateFields.dueDateTime) {
|
|
152
|
-
body.dueDateTime = updateFields.dueDateTime;
|
|
166
|
+
body.dueDateTime = (0, GenericFunctions_1.formatDateTime)(updateFields.dueDateTime);
|
|
153
167
|
}
|
|
154
168
|
if (updateFields.startDateTime) {
|
|
155
|
-
body.startDateTime = updateFields.startDateTime;
|
|
169
|
+
body.startDateTime = (0, GenericFunctions_1.formatDateTime)(updateFields.startDateTime);
|
|
156
170
|
}
|
|
157
171
|
if (updateFields.percentComplete !== undefined) {
|
|
158
172
|
body.percentComplete = updateFields.percentComplete;
|
|
@@ -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: '
|
|
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
|
|
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: '
|
|
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
|
|
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',
|