Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion components/sharepoint/actions/create-item/create-item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "sharepoint-create-item",
name: "Create Item",
description: "Create a new item in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/listitem-create?view=graph-rest-1.0&tabs=http)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
sharepoint,
Expand Down
2 changes: 1 addition & 1 deletion components/sharepoint/actions/create-list/create-list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "sharepoint-create-list",
name: "Create List",
description: "Create a new list in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/list-create?view=graph-rest-1.0&tabs=http)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
sharepoint,
Expand Down
61 changes: 61 additions & 0 deletions components/sharepoint/actions/download-file/download-file.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import sharepoint from "../../sharepoint.app.mjs";
import fs from "fs";

export default {
key: "sharepoint-download-file",
name: "Download File",
description: "Download a Microsoft Sharepoint file to the /tmp directory. [See the documentation](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http)",
version: "0.0.1",
type: "action",
props: {
sharepoint,
siteId: {
propDefinition: [
sharepoint,
"siteId",
],
},
driveId: {
propDefinition: [
sharepoint,
"driveId",
(c) => ({
siteId: c.siteId,
}),
],
},
fileId: {
propDefinition: [
sharepoint,
"fileId",
(c) => ({
siteId: c.siteId,
driveId: c.driveId,
}),
],
},
filename: {
type: "string",
label: "Filename",
description: "The filename to save the downloaded file as in the `/tmp` directory",
},
},
async run({ $ }) {
const response = await this.sharepoint.getFile({
$,
siteId: this.siteId,
fileId: this.fileId,
responseType: "arraybuffer",
});

const rawcontent = response.toString("base64");
const buffer = Buffer.from(rawcontent, "base64");
const downloadedFilepath = `/tmp/${this.filename}`;
fs.writeFileSync(downloadedFilepath, buffer);

return {
filename: this.filename,
downloadedFilepath,
};
},
};
2 changes: 1 addition & 1 deletion components/sharepoint/actions/update-item/update-item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sharepoint-update-item",
name: "Update Item",
description: "Updates an existing item in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/listitem-update?view=graph-rest-1.0&tabs=http)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
sharepoint,
Expand Down
4 changes: 2 additions & 2 deletions components/sharepoint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/sharepoint",
"version": "0.2.0",
"version": "0.3.0",
"description": "Pipedream Microsoft Sharepoint Online Components",
"main": "sharepoint.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
"@pipedream/platform": "^3.0.3"
}
}
93 changes: 93 additions & 0 deletions components/sharepoint/sharepoint.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,67 @@ export default {
};
},
},
driveId: {
type: "string",
label: "Drive ID",
description: "Identifier of a drive within a site",
async options({
prevContext, siteId,
}) {
if (!siteId) {
return [];
}
const args = {
siteId,
};
if (prevContext?.nextLink) {
args.url = prevContext.nextLink;
}
const response = await this.listSiteDrives(args);
const options = response.value?.map(({
id: value, name: label,
}) => ({
value,
label,
})) || [];
return {
options,
context: {
nextLink: response["@odata.nextLink"],
},
};
},
},
fileId: {
type: "string",
label: "File ID",
description: "The file to download. You can either search for the file here, provide a custom *File ID*.",
useQuery: true,
async options({
query, siteId, driveId,
}) {
const response = query
? await this.searchDriveItems({
siteId,
query,
params: {
select: "folder,name,id",
},
})
: await this.listDriveItems({
siteId,
driveId,
});
const values = response.value.filter(({ folder }) => !folder);
return values
.map(({
name, id,
}) => ({
label: name,
value: id,
}));
},
},
},
methods: {
_baseUrl() {
Expand Down Expand Up @@ -168,6 +229,38 @@ export default {
...args,
});
},
listSiteDrives({
siteId, ...args
}) {
return this._makeRequest({
path: `/sites/${siteId}/drives`,
...args,
});
},
listDriveItems({
siteId, driveId, ...args
}) {
return this._makeRequest({
path: `/sites/${siteId}/drives/${driveId}/items/root/children`,
...args,
});
},
searchDriveItems({
siteId, query, ...args
}) {
return this._makeRequest({
path: `/sites/${siteId}/drive/root/search(q='${query}')`,
...args,
});
},
getFile({
siteId, fileId, ...args
}) {
return this._makeRequest({
path: `/sites/${siteId}/drive/items/${fileId}/content`,
...args,
});
},
createList({
siteId, ...args
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "sharepoint-new-list-item",
name: "New List Item",
description: "Emit new event when a new list is created in Microsoft Sharepoint.",
version: "0.0.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
export default {
...common,
key: "sharepoint-updated-list-item",
name: "Updated List Item",

Check warning on line 6 in components/sharepoint/sources/updated-list-item/updated-list-item.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a list is updated in Microsoft Sharepoint.",
version: "0.0.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
props: {
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

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

Loading