-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Expand file tree
/
Copy pathcreate-link.mjs
More file actions
74 lines (71 loc) · 1.75 KB
/
create-link.mjs
File metadata and controls
74 lines (71 loc) · 1.75 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 constants from "../../common/constants.mjs";
import sharepoint from "../../sharepoint.app.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.4",
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;
},
};