n8n-nodes-onedrive-business-sp 1.1.0 → 1.1.1

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.
@@ -242,8 +242,9 @@ class MicrosoftOneDriveBusinessTrigger {
242
242
  });
243
243
  actualDriveId = driveResponse.id;
244
244
  }
245
- const watchPath = watchFolderId === 'root' ? 'root' : `items/${watchFolderId}`;
246
- const resource = `/drives/${actualDriveId}/${watchPath}`;
245
+ // Microsoft Graph only supports subscriptions at drive root level
246
+ // We'll filter by folder in the webhook handler
247
+ const resource = `/drives/${actualDriveId}/root`;
247
248
  // Create subscription
248
249
  const expirationDateTime = new Date();
249
250
  expirationDateTime.setHours(expirationDateTime.getHours() + 72); // 72 hours max
@@ -263,6 +264,7 @@ class MicrosoftOneDriveBusinessTrigger {
263
264
  });
264
265
  webhookData.subscriptionId = responseData.id;
265
266
  webhookData.driveId = actualDriveId;
267
+ webhookData.watchFolderId = watchFolderId;
266
268
  webhookData.deltaLink = null;
267
269
  }
268
270
  catch (error) {
@@ -321,11 +323,11 @@ class MicrosoftOneDriveBusinessTrigger {
321
323
  watchFolderId = watchFolder.value || 'root';
322
324
  }
323
325
  const driveId = webhookData.driveId;
324
- // Use delta query to get changes
326
+ const storedWatchFolderId = webhookData.watchFolderId || 'root';
327
+ // Always use root delta query (Microsoft Graph requirement)
325
328
  let deltaUrl = webhookData.deltaLink;
326
329
  if (!deltaUrl) {
327
- const watchPath = watchFolderId === 'root' ? 'root' : `items/${watchFolderId}`;
328
- deltaUrl = `https://graph.microsoft.com/v1.0/drives/${driveId}/${watchPath}/delta`;
330
+ deltaUrl = `https://graph.microsoft.com/v1.0/drives/${driveId}/root/delta`;
329
331
  }
330
332
  try {
331
333
  const deltaResponse = await this.helpers.requestOAuth2.call(this, 'microsoftOneDriveBusinessOAuth2Api', {
@@ -336,12 +338,37 @@ class MicrosoftOneDriveBusinessTrigger {
336
338
  // Store the new delta link
337
339
  webhookData.deltaLink = deltaResponse['@odata.deltaLink'];
338
340
  const changes = deltaResponse.value;
341
+ // Get folder path if watching specific folder
342
+ let watchFolderPath = null;
343
+ if (storedWatchFolderId !== 'root') {
344
+ try {
345
+ const folderInfo = await this.helpers.requestOAuth2.call(this, 'microsoftOneDriveBusinessOAuth2Api', {
346
+ method: 'GET',
347
+ url: `https://graph.microsoft.com/v1.0/drives/${driveId}/items/${storedWatchFolderId}`,
348
+ qs: { $select: 'id,name,parentReference' },
349
+ json: true,
350
+ });
351
+ const parentRef = folderInfo.parentReference;
352
+ watchFolderPath = (parentRef?.path || '') + '/' + folderInfo.name;
353
+ }
354
+ catch (error) {
355
+ // If can't get folder path, don't filter
356
+ }
357
+ }
339
358
  const filteredChanges = changes.filter((change) => {
340
359
  const isFile = change.file !== undefined;
341
360
  const isFolder = change.folder !== undefined;
342
361
  const isDeleted = change.deleted !== undefined;
343
362
  if (isDeleted)
344
363
  return false;
364
+ // Filter by folder path if watching specific folder
365
+ if (watchFolderPath && change.parentReference) {
366
+ const parentRef = change.parentReference;
367
+ const itemPath = parentRef.path || '';
368
+ if (!itemPath.includes(watchFolderPath)) {
369
+ return false;
370
+ }
371
+ }
345
372
  if (event === 'fileCreated' && isFile) {
346
373
  return change.createdDateTime === change.lastModifiedDateTime;
347
374
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-onedrive-business-sp",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "n8n node for Microsoft OneDrive for Business (SharePoint)",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",