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
74 changes: 74 additions & 0 deletions components/sharepoint/actions/create-folder/create-folder.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import sharepoint from "../../sharepoint.app.mjs";

export default {
key: "sharepoint-create-folder",
name: "Create Folder",
description: "Create a new folder in SharePoint. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
sharepoint,
siteId: {
propDefinition: [
sharepoint,
"siteId",
],
},
driveId: {
propDefinition: [
sharepoint,
"driveId",
(c) => ({
siteId: c.siteId,
}),
],
},
folderId: {
propDefinition: [
sharepoint,
"folderId",
(c) => ({
siteId: c.siteId,
driveId: c.driveId,
}),
],
label: "Parent Folder ID",
description: "The ID of the folder in which the the new folder should be created. You can either search for the folder here or provide a custom *Folder ID*.",
},
folderName: {
type: "string",
label: "Folder Name",
description: "The name of the new folder to be created. e.g. `New Folder`",
},
},
async run({ $ }) {
const data = {
name: this.folderName,
folder: {},
};
const response = this.folderId
? await this.sharepoint.createDriveItemInFolder({
$,
siteId: this.siteId,
folderId: this.folderId,
data,
})
: await this.sharepoint.createDriveItem({
$,
siteId: this.siteId,
driveId: this.driveId,
data,
});

if (response?.id) {
$.export("$summary", `Successfully created folder with ID ${response.id}.`);
}

return response;
},
};
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.6",
version: "0.0.7",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
74 changes: 74 additions & 0 deletions components/sharepoint/actions/create-link/create-link.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import sharepoint from "../../sharepoint.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "sharepoint-create-link",
name: "Create Link",
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)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
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,
excludeFolders: false,
}),
],
},
type: {
type: "string",
label: "Type",
description: "The type of sharing link to create. Either `view`, `edit`, or `embed`.",
options: constants.SHARING_LINK_TYPE_OPTIONS,
},
scope: {
type: "string",
label: "Scope",
description: "The scope of link to create. Either `anonymous` or `organization`.",
options: constants.SHARING_LINK_SCOPE_OPTIONS,
optional: true,
},
},
async run({ $ }) {
const response = await this.sharepoint.createLink({
$,
siteId: this.siteId,
fileId: this.fileId,
data: {
type: this.type,
scope: this.scope,
},
});

if (response?.id) {
$.export("$summary", `Successfully created a sharing link with ID \`${response.id}\`.`);
}

return response;
},
};
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.6",
version: "0.0.7",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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.5",
version: "0.0.6",
annotations: {
destructiveHint: false,
openWorldHint: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import sharepoint from "../../sharepoint.app.mjs";

export default {
key: "sharepoint-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",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
sharepoint,
siteId: {
propDefinition: [
sharepoint,
"siteId",
],
},
name: {
type: "string",
label: "File Name",
description: "The name of the file or folder to search for",
},
excludeFolders: {
propDefinition: [
sharepoint,
"excludeFolders",
],
},
},
async run({ $ }) {
const response = await this.sharepoint.searchDriveItems({
$,
siteId: this.siteId,
query: this.name,
});
let values = response.value.filter(
({ name }) => name.toLowerCase().includes(this.name.toLowerCase()),
);
if (this.excludeFolders) {
values = values.filter(({ folder }) => !folder);
}

$.export("$summary", `Found ${values.length} matching file${values.length === 1
? ""
: "s"}`);
return values;
},
};
84 changes: 84 additions & 0 deletions components/sharepoint/actions/get-excel-table/get-excel-table.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import sharepoint from "../../sharepoint.app.mjs";

export default {
key: "sharepoint-get-excel-table",
name: "Get Excel Table",
description: "Retrieve a table from an Excel spreadsheet stored in Sharepoint [See the documentation](https://learn.microsoft.com/en-us/graph/api/table-range?view=graph-rest-1.0&tabs=http)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
props: {
sharepoint,
alert: {

Check warning on line 16 in components/sharepoint/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 16 in components/sharepoint/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.
\nSee Microsoft's documentation on how to [Create and Format a Table](https://support.microsoft.com/en-us/office/create-and-format-tables-e81aa349-b006-4f8a-9806-5af9df0ac664)
`,
},
siteId: {
propDefinition: [
sharepoint,
"siteId",
],
},
itemId: {
propDefinition: [
sharepoint,
"excelFileId",
(c) => ({
siteId: c.siteId,
}),
],
},
tableName: {
propDefinition: [
sharepoint,
"tableName",
(c) => ({
siteId: c.siteId,
itemId: c.itemId,
}),
],
},
removeHeaders: {
type: "boolean",
label: "Remove headers?",
optional: true,
description: "By default, The headers are included as the first row.",
default: false,
},
numberOfRows: {
type: "integer",
optional: true,
default: 0,
min: 0,
label: "Number of rows to return",
description: "Leave blank to return all rows.",
},
},
async run({ $ }) {
const range = await this.sharepoint.getExcelTable({
$,
siteId: this.siteId,
itemId: this.itemId,
tableName: this.tableName,
});

const response = this.removeHeaders
? this.numberOfRows <= 0
? range.text.slice(1)
: range.text.slice(1, this.numberOfRows + 1)
: this.numberOfRows <= 0
? range.text
: range.text.slice(0, this.numberOfRows + 1);

$.export("$summary", "Successfully retrieved excel table.");

return response;
},
};
52 changes: 52 additions & 0 deletions components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import sharepoint from "../../sharepoint.app.mjs";

export default {
key: "sharepoint-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",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
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,
}),
],
description: "The file to retrieve. You can either search for the file here or provide a custom *File ID*.",
},
},
async run({ $ }) {
const response = await this.sharepoint.getDriveItem({
$,
siteId: this.siteId,
fileId: this.fileId,
});
$.export("$summary", `Successfully retrieved file with ID: ${this.fileId}`);
return response;
},
};
Loading
Loading