Skip to content

Commit e874d14

Browse files
authored
Merging pull request #18845
* new components * updates * updates
1 parent 43fae74 commit e874d14

File tree

19 files changed

+846
-14
lines changed

19 files changed

+846
-14
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import sharepoint from "../../sharepoint.app.mjs";
2+
3+
export default {
4+
key: "sharepoint-create-folder",
5+
name: "Create Folder",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
sharepoint,
16+
siteId: {
17+
propDefinition: [
18+
sharepoint,
19+
"siteId",
20+
],
21+
},
22+
driveId: {
23+
propDefinition: [
24+
sharepoint,
25+
"driveId",
26+
(c) => ({
27+
siteId: c.siteId,
28+
}),
29+
],
30+
},
31+
folderId: {
32+
propDefinition: [
33+
sharepoint,
34+
"folderId",
35+
(c) => ({
36+
siteId: c.siteId,
37+
driveId: c.driveId,
38+
}),
39+
],
40+
label: "Parent Folder ID",
41+
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*.",
42+
},
43+
folderName: {
44+
type: "string",
45+
label: "Folder Name",
46+
description: "The name of the new folder to be created. e.g. `New Folder`",
47+
},
48+
},
49+
async run({ $ }) {
50+
const data = {
51+
name: this.folderName,
52+
folder: {},
53+
};
54+
const response = this.folderId
55+
? await this.sharepoint.createDriveItemInFolder({
56+
$,
57+
siteId: this.siteId,
58+
folderId: this.folderId,
59+
data,
60+
})
61+
: await this.sharepoint.createDriveItem({
62+
$,
63+
siteId: this.siteId,
64+
driveId: this.driveId,
65+
data,
66+
});
67+
68+
if (response?.id) {
69+
$.export("$summary", `Successfully created folder with ID ${response.id}.`);
70+
}
71+
72+
return response;
73+
},
74+
};

components/sharepoint/actions/create-item/create-item.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "sharepoint-create-item",
55
name: "Create Item",
66
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)",
7-
version: "0.0.6",
7+
version: "0.0.7",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import sharepoint from "../../sharepoint.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "sharepoint-create-link",
6+
name: "Create Link",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: false,
14+
},
15+
props: {
16+
sharepoint,
17+
siteId: {
18+
propDefinition: [
19+
sharepoint,
20+
"siteId",
21+
],
22+
},
23+
driveId: {
24+
propDefinition: [
25+
sharepoint,
26+
"driveId",
27+
(c) => ({
28+
siteId: c.siteId,
29+
}),
30+
],
31+
},
32+
fileId: {
33+
propDefinition: [
34+
sharepoint,
35+
"fileId",
36+
(c) => ({
37+
siteId: c.siteId,
38+
driveId: c.driveId,
39+
excludeFolders: false,
40+
}),
41+
],
42+
},
43+
type: {
44+
type: "string",
45+
label: "Type",
46+
description: "The type of sharing link to create. Either `view`, `edit`, or `embed`.",
47+
options: constants.SHARING_LINK_TYPE_OPTIONS,
48+
},
49+
scope: {
50+
type: "string",
51+
label: "Scope",
52+
description: "The scope of link to create. Either `anonymous` or `organization`.",
53+
options: constants.SHARING_LINK_SCOPE_OPTIONS,
54+
optional: true,
55+
},
56+
},
57+
async run({ $ }) {
58+
const response = await this.sharepoint.createLink({
59+
$,
60+
siteId: this.siteId,
61+
fileId: this.fileId,
62+
data: {
63+
type: this.type,
64+
scope: this.scope,
65+
},
66+
});
67+
68+
if (response?.id) {
69+
$.export("$summary", `Successfully created a sharing link with ID \`${response.id}\`.`);
70+
}
71+
72+
return response;
73+
},
74+
};

components/sharepoint/actions/create-list/create-list.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "sharepoint-create-list",
55
name: "Create List",
66
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)",
7-
version: "0.0.6",
7+
version: "0.0.7",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "sharepoint-download-file",
66
name: "Download File",
77
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)",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import sharepoint from "../../sharepoint.app.mjs";
2+
3+
export default {
4+
key: "sharepoint-find-file-by-name",
5+
name: "Find File by Name",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
sharepoint,
16+
siteId: {
17+
propDefinition: [
18+
sharepoint,
19+
"siteId",
20+
],
21+
},
22+
name: {
23+
type: "string",
24+
label: "File Name",
25+
description: "The name of the file or folder to search for",
26+
},
27+
excludeFolders: {
28+
propDefinition: [
29+
sharepoint,
30+
"excludeFolders",
31+
],
32+
},
33+
},
34+
async run({ $ }) {
35+
const response = await this.sharepoint.searchDriveItems({
36+
$,
37+
siteId: this.siteId,
38+
query: this.name,
39+
});
40+
let values = response.value.filter(
41+
({ name }) => name.toLowerCase().includes(this.name.toLowerCase()),
42+
);
43+
if (this.excludeFolders) {
44+
values = values.filter(({ folder }) => !folder);
45+
}
46+
47+
$.export("$summary", `Found ${values.length} matching file${values.length === 1
48+
? ""
49+
: "s"}`);
50+
return values;
51+
},
52+
};
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import sharepoint from "../../sharepoint.app.mjs";
2+
3+
export default {
4+
key: "sharepoint-get-excel-table",
5+
name: "Get Excel Table",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
sharepoint,
16+
alert: {
17+
type: "alert",
18+
alertType: "info",
19+
content: `Note: The table must exist within the Excel spreadsheet.
20+
\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)
21+
`,
22+
},
23+
siteId: {
24+
propDefinition: [
25+
sharepoint,
26+
"siteId",
27+
],
28+
},
29+
itemId: {
30+
propDefinition: [
31+
sharepoint,
32+
"excelFileId",
33+
(c) => ({
34+
siteId: c.siteId,
35+
}),
36+
],
37+
},
38+
tableName: {
39+
propDefinition: [
40+
sharepoint,
41+
"tableName",
42+
(c) => ({
43+
siteId: c.siteId,
44+
itemId: c.itemId,
45+
}),
46+
],
47+
},
48+
removeHeaders: {
49+
type: "boolean",
50+
label: "Remove headers?",
51+
optional: true,
52+
description: "By default, The headers are included as the first row.",
53+
default: false,
54+
},
55+
numberOfRows: {
56+
type: "integer",
57+
optional: true,
58+
default: 0,
59+
min: 0,
60+
label: "Number of rows to return",
61+
description: "Leave blank to return all rows.",
62+
},
63+
},
64+
async run({ $ }) {
65+
const range = await this.sharepoint.getExcelTable({
66+
$,
67+
siteId: this.siteId,
68+
itemId: this.itemId,
69+
tableName: this.tableName,
70+
});
71+
72+
const response = this.removeHeaders
73+
? this.numberOfRows <= 0
74+
? range.text.slice(1)
75+
: range.text.slice(1, this.numberOfRows + 1)
76+
: this.numberOfRows <= 0
77+
? range.text
78+
: range.text.slice(0, this.numberOfRows + 1);
79+
80+
$.export("$summary", "Successfully retrieved excel table.");
81+
82+
return response;
83+
},
84+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import sharepoint from "../../sharepoint.app.mjs";
2+
3+
export default {
4+
key: "sharepoint-get-file-by-id",
5+
name: "Get File by ID",
6+
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",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
sharepoint,
16+
siteId: {
17+
propDefinition: [
18+
sharepoint,
19+
"siteId",
20+
],
21+
},
22+
driveId: {
23+
propDefinition: [
24+
sharepoint,
25+
"driveId",
26+
(c) => ({
27+
siteId: c.siteId,
28+
}),
29+
],
30+
},
31+
fileId: {
32+
propDefinition: [
33+
sharepoint,
34+
"fileId",
35+
(c) => ({
36+
siteId: c.siteId,
37+
driveId: c.driveId,
38+
}),
39+
],
40+
description: "The file to retrieve. You can either search for the file here or provide a custom *File ID*.",
41+
},
42+
},
43+
async run({ $ }) {
44+
const response = await this.sharepoint.getDriveItem({
45+
$,
46+
siteId: this.siteId,
47+
fileId: this.fileId,
48+
});
49+
$.export("$summary", `Successfully retrieved file with ID: ${this.fileId}`);
50+
return response;
51+
},
52+
};

0 commit comments

Comments
 (0)