-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Expand file tree
/
Copy pathcreate-folder.mjs
More file actions
74 lines (71 loc) · 1.8 KB
/
create-folder.mjs
File metadata and controls
74 lines (71 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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.3",
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;
},
};