Skip to content

Commit 86b6e15

Browse files
authored
Merging pull request #17758
1 parent fe69b0d commit 86b6e15

File tree

14 files changed

+147
-53
lines changed

14 files changed

+147
-53
lines changed

components/microsoft_onedrive/actions/create-folder/create-folder.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Create Folder",
66
description: "Create a new folder in a drive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online)",
77
key: "microsoft_onedrive-create-folder",
8-
version: "0.1.1",
8+
version: "0.1.2",
99
type: "action",
1010
props: {
1111
onedrive,

components/microsoft_onedrive/actions/create-link/create-link.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import constants from "../../common/constants.mjs";
33

44
export default {
55
name: "Create Link",
6-
version: "0.0.2",
6+
version: "0.0.3",
77
key: "microsoft_onedrive-create-link",
88
type: "action",
99
description: "Create a sharing link for a DriveItem. [See the documentation](https://docs.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http)",

components/microsoft_onedrive/actions/download-file/download-file.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
name: "Download File",
1010
description: "Download a file stored in OneDrive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get_content?view=odsp-graph-online)",
1111
key: "microsoft_onedrive-download-file",
12-
version: "0.0.7",
12+
version: "0.0.8",
1313
type: "action",
1414
props: {
1515
onedrive,

components/microsoft_onedrive/actions/find-file-by-name/find-file-by-name.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "microsoft_onedrive-find-file-by-name",
66
name: "Find File by Name",
77
description: "Search for a file or folder by name. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_search)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
onedrive,

components/microsoft_onedrive/actions/get-excel-table/get-excel-table.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
name: "Get Table",
55
description: "Retrieve a table from an Excel spreadsheet stored in OneDrive [See the documentation](https://learn.microsoft.com/en-us/graph/api/table-range?view=graph-rest-1.0&tabs=http)",
66
key: "microsoft_onedrive-get-excel-table",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
onedrive,

components/microsoft_onedrive/actions/get-file-by-id/get-file-by-id.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_onedrive-get-file-by-id",
55
name: "Get File by ID",
66
description: "Retrieves a file by ID. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
onedrive,

components/microsoft_onedrive/actions/list-files-in-folder/list-files-in-folder.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "microsoft_onedrive-list-files-in-folder",
66
name: "List Files in Folder",
77
description: "Retrieves a list of the files and/or folders directly within a folder. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
onedrive,

components/microsoft_onedrive/actions/upload-file/upload-file.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "Upload File",
99
description: "Upload a file to OneDrive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online)",
1010
key: "microsoft_onedrive-upload-file",
11-
version: "0.2.1",
11+
version: "0.2.2",
1212
type: "action",
1313
props: {
1414
onedrive,

components/microsoft_onedrive/microsoft_onedrive.app.mjs

Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,46 @@ export default {
2727
const firstLink = drivePath + driveItemPath + "/children";
2828
const url = get(prevContext, "nextLink", firstLink);
2929

30-
const response = await this.client()
31-
.api(url)
32-
.select(
33-
"folder",
34-
"id",
35-
"name",
36-
)
37-
.orderby("name")
38-
.get();
30+
try {
31+
const response = await this.client()
32+
.api(url)
33+
.select(
34+
"folder",
35+
"id",
36+
"name",
37+
)
38+
.orderby("name")
39+
.get();
3940

40-
const {
41-
"@odata.nextLink": nextLink,
42-
"value": children,
43-
} = response;
41+
const {
42+
"@odata.nextLink": nextLink,
43+
"value": children,
44+
} = response;
4445

45-
const folders = children.filter((child) => !!child.folder);
46+
const folders = children.filter((child) => !!child.folder);
4647

47-
const options = folders.map((folder) => ({
48-
value: folder.id,
49-
label: (label
50-
? `${label} > `
51-
: "") + folder.name,
52-
}));
48+
const options = folders.map((folder) => ({
49+
value: folder.id,
50+
label: (label
51+
? `${label} > `
52+
: "") + folder.name,
53+
}));
5354

54-
return {
55-
options,
56-
context: {
57-
nextLink,
55+
return {
5856
options,
59-
},
60-
};
57+
context: {
58+
nextLink,
59+
options,
60+
},
61+
};
62+
63+
} catch (error) {
64+
console.error("Error listing folders:", error);
65+
return {
66+
options: [],
67+
context: {},
68+
};
69+
}
6170
}));
6271

6372
return {
@@ -151,6 +160,49 @@ export default {
151160
description: "Set to `true` to return only files in the response. Defaults to `false`",
152161
optional: true,
153162
},
163+
drive: {
164+
type: "string",
165+
label: "Drive",
166+
description: "Select a drive to monitor. Defaults to the personal OneDrive if not specified.",
167+
optional: true,
168+
async options() {
169+
let options = [];
170+
171+
try {
172+
const { value: drives } = await this.listDrives();
173+
174+
options = drives
175+
.filter((drive) => drive.owner?.user?.email)
176+
.map(({
177+
id, description, name, driveType,
178+
}) => ({
179+
label: `${description || name} (${driveType})`,
180+
value: id,
181+
}));
182+
} catch (error) {
183+
console.error("Error listing drives:", error);
184+
}
185+
186+
try {
187+
const { value: sharedFiles } = await this.listSharedFiles();
188+
189+
const sharedDriveOptions = sharedFiles
190+
.map(({ remoteItem }) => ({
191+
label: `${remoteItem.parentReference.driveId} (${remoteItem.parentReference.driveType})`,
192+
value: remoteItem.parentReference.driveId,
193+
}));
194+
195+
options = [
196+
...options,
197+
...sharedDriveOptions,
198+
];
199+
} catch (error) {
200+
console.error("Error listing shared files:", error);
201+
}
202+
203+
return options;
204+
},
205+
},
154206
},
155207
methods: {
156208
httpRequest,
@@ -421,5 +473,19 @@ export default {
421473
.api("/me/drive/root/children")
422474
.get(args);
423475
},
476+
listDrives() {
477+
const client = this.client();
478+
return client
479+
.api("/drives")
480+
.select("id", "description", "name", "driveType", "owner")
481+
.get();
482+
},
483+
listSharedFiles() {
484+
const client = this.client();
485+
return client
486+
.api("/me/drive/sharedWithMe")
487+
.select("name", "remoteItem", "folder")
488+
.get();
489+
},
424490
},
425491
};

components/microsoft_onedrive/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/microsoft_onedrive",
3-
"version": "1.7.1",
3+
"version": "1.7.2",
44
"description": "Pipedream Microsoft OneDrive components",
55
"main": "microsoft_onedrive.app.mjs",
66
"homepage": "https://pipedream.com/apps/microsoft-onedrive",

0 commit comments

Comments
 (0)