Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Create Folder",
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)",
key: "microsoft_onedrive-create-folder",
version: "0.1.1",
version: "0.1.2",
type: "action",
props: {
onedrive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import constants from "../../common/constants.mjs";

export default {
name: "Create Link",
version: "0.0.2",
version: "0.0.3",
key: "microsoft_onedrive-create-link",
type: "action",
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)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
name: "Download File",
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)",
key: "microsoft_onedrive-download-file",
version: "0.0.7",
version: "0.0.8",
type: "action",
props: {
onedrive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "microsoft_onedrive-find-file-by-name",
name: "Find File by Name",
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)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
onedrive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
name: "Get Table",
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)",
key: "microsoft_onedrive-get-excel-table",
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
onedrive,
alert: {

Check warning on line 11 in components/microsoft_onedrive/actions/get-excel-table/get-excel-table.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 11 in components/microsoft_onedrive/actions/get-excel-table/get-excel-table.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: `Note: The table must exist within the Excel spreadsheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "microsoft_onedrive-get-file-by-id",
name: "Get File by ID",
description: "Retrieves a file by ID. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
onedrive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "microsoft_onedrive-list-files-in-folder",
name: "List Files in Folder",
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)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
onedrive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "Upload File",
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)",
key: "microsoft_onedrive-upload-file",
version: "0.2.1",
version: "0.2.2",
type: "action",
props: {
onedrive,
Expand Down
118 changes: 92 additions & 26 deletions components/microsoft_onedrive/microsoft_onedrive.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,46 @@ export default {
const firstLink = drivePath + driveItemPath + "/children";
const url = get(prevContext, "nextLink", firstLink);

const response = await this.client()
.api(url)
.select(
"folder",
"id",
"name",
)
.orderby("name")
.get();
try {
const response = await this.client()
.api(url)
.select(
"folder",
"id",
"name",
)
.orderby("name")
.get();

const {
"@odata.nextLink": nextLink,
"value": children,
} = response;
const {
"@odata.nextLink": nextLink,
"value": children,
} = response;

const folders = children.filter((child) => !!child.folder);
const folders = children.filter((child) => !!child.folder);

const options = folders.map((folder) => ({
value: folder.id,
label: (label
? `${label} > `
: "") + folder.name,
}));
const options = folders.map((folder) => ({
value: folder.id,
label: (label
? `${label} > `
: "") + folder.name,
}));

return {
options,
context: {
nextLink,
return {
options,
},
};
context: {
nextLink,
options,
},
};

} catch (error) {
console.error("Error listing folders:", error);
return {
options: [],
context: {},
};
}
}));

return {
Expand Down Expand Up @@ -151,6 +160,49 @@ export default {
description: "Set to `true` to return only files in the response. Defaults to `false`",
optional: true,
},
drive: {
type: "string",
label: "Drive",
description: "Select a drive to monitor. Defaults to the personal OneDrive if not specified.",
optional: true,
async options() {
let options = [];

try {
const { value: drives } = await this.listDrives();

options = drives
.filter((drive) => drive.owner?.user?.email)
.map(({
id, description, name, driveType,
}) => ({
label: `${description || name} (${driveType})`,
value: id,
}));
} catch (error) {
console.error("Error listing drives:", error);
}

try {
const { value: sharedFiles } = await this.listSharedFiles();

const sharedDriveOptions = sharedFiles
.map(({ remoteItem }) => ({
label: `${remoteItem.parentReference.driveId} (${remoteItem.parentReference.driveType})`,
value: remoteItem.parentReference.driveId,
}));

options = [
...options,
...sharedDriveOptions,
];
} catch (error) {
console.error("Error listing shared files:", error);
}

return options;
},
},
},
methods: {
httpRequest,
Expand Down Expand Up @@ -421,5 +473,19 @@ export default {
.api("/me/drive/root/children")
.get(args);
},
listDrives() {
const client = this.client();
return client
.api("/drives")
.select("id", "description", "name", "driveType", "owner")
.get();
},
listSharedFiles() {
const client = this.client();
return client
.api("/me/drive/sharedWithMe")
.select("name", "remoteItem", "folder")
.get();
},
},
};
2 changes: 1 addition & 1 deletion components/microsoft_onedrive/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/microsoft_onedrive",
"version": "1.7.1",
"version": "1.7.2",
"description": "Pipedream Microsoft OneDrive components",
"main": "microsoft_onedrive.app.mjs",
"homepage": "https://pipedream.com/apps/microsoft-onedrive",
Expand Down
2 changes: 2 additions & 0 deletions components/microsoft_onedrive/sources/common/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ const methods = {
return new Date(nowTimestamp + expirationTimestampDelta);
},
async _createNewSubscription() {
const deltaLinkParams = this.getDeltaLinkParams();
const hookOpts = {
expirationDateTime: this._getNextExpirationDateTime(),
driveId: deltaLinkParams.driveId,
};
const hookId = await this.onedrive.createHook(this.http.endpoint, hookOpts);
this._setHookId(hookId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@ export default {
key: "microsoft_onedrive-new-file-created",
name: "New File Created (Instant)",
description: "Emit new event when a new file is created in a OneDrive drive",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
props: {
...base.props,
drive: {
propDefinition: [
onedrive,
"drive",
],
description: "The drive to monitor for new files. If not specified, the personal OneDrive will be monitored.",
optional: true,
},
folder: {
propDefinition: [
onedrive,
"folder",
({ drive }) => ({
driveId: drive,
}),
],
description: "The OneDrive folder to watch for new files (leave empty to watch the entire drive). Use the \"Load More\" button to load subfolders.",
optional: true,
Expand All @@ -30,11 +41,14 @@ export default {
methods: {
...base.methods,
getDeltaLinkParams() {
return this.folder
? {
folderId: this.folder,
}
: {};
const params = {};
if (this.drive) {
params.driveId = this.drive;
}
if (this.folder) {
params.folderId = this.folder;
}
return params;
},
isItemTypeRelevant(driveItem) {
const fileType = driveItem?.file?.mimeType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,40 @@ export default {
key: "microsoft_onedrive-new-folder-created",
name: "New Folder Created (Instant)",
description: "Emit new event when a new folder is created in a OneDrive drive",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
props: {
...base.props,
drive: {
propDefinition: [
onedrive,
"drive",
],
description: "The drive to monitor for new folders. If not specified, the personal OneDrive will be monitored.",
optional: true,
},
folder: {
propDefinition: [
onedrive,
"folder",
({ drive }) => ({
driveId: drive,
}),
],
optional: true,
},
},
methods: {
...base.methods,
getDeltaLinkParams() {
return this.folder
? {
folderId: this.folder,
}
: {};
const params = {};
if (this.drive) {
params.driveId = this.drive;
}
if (this.folder) {
params.folderId = this.folder;
}
return params;
},
isItemRelevant(driveItem) {
return !!(driveItem.folder);
Expand Down
10 changes: 4 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading