@pipedream/sharepoint 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/create-folder/create-folder.mjs +1 -1
- package/actions/create-item/create-item.mjs +1 -1
- package/actions/create-link/create-link.mjs +1 -1
- package/actions/create-list/create-list.mjs +1 -1
- package/actions/download-file/download-file.mjs +1 -1
- package/actions/find-file-by-name/find-file-by-name.mjs +1 -1
- package/actions/find-files-with-metadata/find-files-with-metadata.mjs +132 -0
- package/actions/get-excel-table/get-excel-table.mjs +3 -1
- package/actions/get-file-by-id/get-file-by-id.mjs +10 -1
- package/actions/get-site/get-site.mjs +40 -0
- package/actions/list-files-in-folder/list-files-in-folder.mjs +20 -1
- package/actions/list-sites/list-sites.mjs +57 -0
- package/actions/search-and-filter-files/search-and-filter-files.mjs +155 -0
- package/actions/search-files/search-files.mjs +84 -0
- package/actions/search-sites/search-sites.mjs +63 -0
- package/actions/select-files/select-files.mjs +9 -12
- package/actions/update-item/update-item.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +1 -1
- package/package.json +1 -1
- package/sharepoint.app.mjs +76 -13
- package/sources/new-file-created/new-file-created.mjs +1 -1
- package/sources/new-folder-created/new-folder-created.mjs +1 -1
- package/sources/new-list-item/new-list-item.mjs +1 -1
- package/sources/updated-list-item/updated-list-item.mjs +1 -1
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-create-folder",
|
|
5
5
|
name: "Create Folder",
|
|
6
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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-create-item",
|
|
5
5
|
name: "Create Item",
|
|
6
6
|
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.
|
|
7
|
+
version: "0.0.10",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "sharepoint-create-link",
|
|
6
6
|
name: "Create Link",
|
|
7
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.
|
|
8
|
+
version: "0.0.5",
|
|
9
9
|
type: "action",
|
|
10
10
|
annotations: {
|
|
11
11
|
destructiveHint: false,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-create-list",
|
|
5
5
|
name: "Create List",
|
|
6
6
|
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.
|
|
7
|
+
version: "0.0.10",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "sharepoint-download-file",
|
|
6
6
|
name: "Download File",
|
|
7
7
|
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.
|
|
8
|
+
version: "0.0.10",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "sharepoint-find-file-by-name",
|
|
7
7
|
name: "Find File by Name",
|
|
8
8
|
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)",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.2",
|
|
10
10
|
type: "action",
|
|
11
11
|
annotations: {
|
|
12
12
|
destructiveHint: false,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "sharepoint-find-files-with-metadata",
|
|
5
|
+
name: "Find Files in List with Metadata",
|
|
6
|
+
description:
|
|
7
|
+
"Search and filter items in a SharePoint list based on metadata and custom columns. [See docs here](https://learn.microsoft.com/en-us/graph/api/listitem-list)",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: true,
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
sharepoint,
|
|
17
|
+
siteId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
sharepoint,
|
|
20
|
+
"siteId",
|
|
21
|
+
],
|
|
22
|
+
description: "Select the SharePoint site.",
|
|
23
|
+
},
|
|
24
|
+
listId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
sharepoint,
|
|
27
|
+
"listId",
|
|
28
|
+
(c) => ({
|
|
29
|
+
siteId: c.siteId,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
description: "Select the list or document library to search within.",
|
|
33
|
+
},
|
|
34
|
+
returnFields: {
|
|
35
|
+
propDefinition: [
|
|
36
|
+
sharepoint,
|
|
37
|
+
"columnNames",
|
|
38
|
+
(c) => ({
|
|
39
|
+
siteId: c.siteId,
|
|
40
|
+
listId: c.listId,
|
|
41
|
+
mapper: ({
|
|
42
|
+
name, displayName,
|
|
43
|
+
}) => ({
|
|
44
|
+
label: displayName,
|
|
45
|
+
value: name,
|
|
46
|
+
}),
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
label: "Fields to Return",
|
|
50
|
+
description:
|
|
51
|
+
"Select which custom fields to return. If left empty, all custom fields are returned.",
|
|
52
|
+
optional: true,
|
|
53
|
+
},
|
|
54
|
+
filter: {
|
|
55
|
+
type: "string",
|
|
56
|
+
label: "Filter Query",
|
|
57
|
+
description:
|
|
58
|
+
"OData filter query. To filter by a custom column, use the format `fields/InternalName eq 'Value'`. The field picker for 'Fields to Return' shows the `InternalName` in parentheses.",
|
|
59
|
+
optional: true,
|
|
60
|
+
},
|
|
61
|
+
orderby: {
|
|
62
|
+
type: "string",
|
|
63
|
+
label: "Order By",
|
|
64
|
+
description:
|
|
65
|
+
"OData order by query (e.g., `lastModifiedDateTime desc`). To sort by a custom field, use `fields/InternalName asc`.",
|
|
66
|
+
optional: true,
|
|
67
|
+
},
|
|
68
|
+
select: {
|
|
69
|
+
type: "string[]",
|
|
70
|
+
label: "Top-level Properties",
|
|
71
|
+
description:
|
|
72
|
+
"Select which top-level item properties to return. If not specified, a default set is returned. `id` and `webUrl` are always returned.",
|
|
73
|
+
optional: true,
|
|
74
|
+
options: [
|
|
75
|
+
"id",
|
|
76
|
+
"name",
|
|
77
|
+
"createdDateTime",
|
|
78
|
+
"lastModifiedDateTime",
|
|
79
|
+
"webUrl",
|
|
80
|
+
"size",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
async run({ $ }) {
|
|
85
|
+
const {
|
|
86
|
+
siteId, listId, returnFields, filter, orderby, select,
|
|
87
|
+
} = this;
|
|
88
|
+
|
|
89
|
+
const params = {
|
|
90
|
+
$filter: filter,
|
|
91
|
+
$orderby: orderby,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
let expandValue = "fields";
|
|
95
|
+
if (returnFields?.length > 0) {
|
|
96
|
+
expandValue = `fields($select=${returnFields.join(",")})`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (select?.length > 0) {
|
|
100
|
+
const selectSet = new Set(select);
|
|
101
|
+
selectSet.add("id");
|
|
102
|
+
selectSet.add("webUrl");
|
|
103
|
+
params.$select = Array.from(selectSet).join(",");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
params.$expand = expandValue;
|
|
107
|
+
|
|
108
|
+
const results = [];
|
|
109
|
+
const iterator = this.sharepoint.paginate({
|
|
110
|
+
fn: this.sharepoint.listItems,
|
|
111
|
+
args: {
|
|
112
|
+
siteId,
|
|
113
|
+
listId,
|
|
114
|
+
params,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
for await (const item of iterator) {
|
|
119
|
+
results.push(item);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
$.export(
|
|
123
|
+
"$summary",
|
|
124
|
+
`Successfully found ${results.length} item${
|
|
125
|
+
results.length === 1
|
|
126
|
+
? ""
|
|
127
|
+
: "s"
|
|
128
|
+
}.`,
|
|
129
|
+
);
|
|
130
|
+
return results;
|
|
131
|
+
},
|
|
132
|
+
};
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-get-excel-table",
|
|
5
5
|
name: "Get Excel Table",
|
|
6
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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -16,6 +16,8 @@ export default {
|
|
|
16
16
|
alert: {
|
|
17
17
|
type: "alert",
|
|
18
18
|
alertType: "info",
|
|
19
|
+
label: "Excel Table Information",
|
|
20
|
+
description: "Information about selecting Excel tables",
|
|
19
21
|
content: `Note: The table must exist within the Excel spreadsheet.
|
|
20
22
|
\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
23
|
`,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-get-file-by-id",
|
|
5
5
|
name: "Get File by ID",
|
|
6
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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -39,12 +39,21 @@ export default {
|
|
|
39
39
|
],
|
|
40
40
|
description: "The file to retrieve. You can either search for the file here or provide a custom *File ID*.",
|
|
41
41
|
},
|
|
42
|
+
select: {
|
|
43
|
+
propDefinition: [
|
|
44
|
+
sharepoint,
|
|
45
|
+
"select",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
42
48
|
},
|
|
43
49
|
async run({ $ }) {
|
|
44
50
|
const response = await this.sharepoint.getDriveItem({
|
|
45
51
|
$,
|
|
46
52
|
siteId: this.siteId,
|
|
47
53
|
fileId: this.fileId,
|
|
54
|
+
params: {
|
|
55
|
+
select: this.select,
|
|
56
|
+
},
|
|
48
57
|
});
|
|
49
58
|
$.export("$summary", `Successfully retrieved file with ID: ${this.fileId}`);
|
|
50
59
|
return response;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "sharepoint-get-site",
|
|
5
|
+
name: "Get Site",
|
|
6
|
+
description: "Get a site in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/site-get?view=graph-rest-1.0&tabs=http)",
|
|
7
|
+
version: "0.0.2",
|
|
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
|
+
select: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
sharepoint,
|
|
25
|
+
"select",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async run({ $ }) {
|
|
30
|
+
const response = await this.sharepoint.getSite({
|
|
31
|
+
$,
|
|
32
|
+
siteId: this.siteId,
|
|
33
|
+
params: {
|
|
34
|
+
select: this.select,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
$.export("$summary", `Successfully retrieved site with ID: ${this.siteId}`);
|
|
38
|
+
return response;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-list-files-in-folder",
|
|
5
5
|
name: "List Files in Folder",
|
|
6
6
|
description: "Retrieves a list of the files and/or folders directly within a folder. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -44,18 +44,37 @@ export default {
|
|
|
44
44
|
"excludeFolders",
|
|
45
45
|
],
|
|
46
46
|
},
|
|
47
|
+
select: {
|
|
48
|
+
propDefinition: [
|
|
49
|
+
sharepoint,
|
|
50
|
+
"select",
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
orderBy: {
|
|
54
|
+
type: "string",
|
|
55
|
+
label: "Order By",
|
|
56
|
+
description: "The field to order the results by",
|
|
57
|
+
default: "lastModifiedDateTime",
|
|
58
|
+
optional: true,
|
|
59
|
+
},
|
|
47
60
|
},
|
|
48
61
|
async run({ $ }) {
|
|
62
|
+
const params = {
|
|
63
|
+
select: this.select,
|
|
64
|
+
orderby: this.orderBy,
|
|
65
|
+
};
|
|
49
66
|
const response = this.folderId
|
|
50
67
|
? await this.sharepoint.listDriveItemsInFolder({
|
|
51
68
|
$,
|
|
52
69
|
driveId: this.driveId,
|
|
53
70
|
folderId: this.folderId,
|
|
71
|
+
params,
|
|
54
72
|
})
|
|
55
73
|
: await this.sharepoint.listDriveItems({
|
|
56
74
|
$,
|
|
57
75
|
siteId: this.siteId,
|
|
58
76
|
driveId: this.driveId,
|
|
77
|
+
params,
|
|
59
78
|
});
|
|
60
79
|
const values = this.excludeFolders
|
|
61
80
|
? response.value.filter(({ folder }) => !folder)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "sharepoint-list-sites",
|
|
5
|
+
name: "List Sites",
|
|
6
|
+
description: "List all sites in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/site-list?view=graph-rest-1.0&tabs=http)",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
sharepoint,
|
|
16
|
+
select: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
sharepoint,
|
|
19
|
+
"select",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
maxResults: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
sharepoint,
|
|
25
|
+
"maxResults",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async run({ $ }) {
|
|
30
|
+
const sites = [];
|
|
31
|
+
let count = 0;
|
|
32
|
+
|
|
33
|
+
const results = this.sharepoint.paginate({
|
|
34
|
+
fn: this.sharepoint.listAllSites,
|
|
35
|
+
args: {
|
|
36
|
+
$,
|
|
37
|
+
params: {
|
|
38
|
+
select: this.select,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
for await (const site of results) {
|
|
44
|
+
sites.push(site);
|
|
45
|
+
count++;
|
|
46
|
+
if (this.maxResults && count >= this.maxResults) {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
$.export("$summary", `Successfully listed ${count} site${count === 1
|
|
52
|
+
? ""
|
|
53
|
+
: "s"}`);
|
|
54
|
+
|
|
55
|
+
return sites;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "sharepoint-search-and-filter-files",
|
|
6
|
+
name: "Search and Filter Files",
|
|
7
|
+
description:
|
|
8
|
+
"Search and filter SharePoint files based on metadata and custom columns. This action allows you to query files using SharePoint's custom properties, managed metadata, and other column values. [See the documentation](https://learn.microsoft.com/en-us/graph/api/listitem-list)",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "action",
|
|
11
|
+
annotations: {
|
|
12
|
+
destructiveHint: false,
|
|
13
|
+
openWorldHint: true,
|
|
14
|
+
readOnlyHint: true,
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
sharepoint,
|
|
18
|
+
siteId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
sharepoint,
|
|
21
|
+
"siteId",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
listId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
sharepoint,
|
|
27
|
+
"listId",
|
|
28
|
+
(c) => ({
|
|
29
|
+
siteId: c.siteId,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
label: "List / Document Library",
|
|
33
|
+
description: "Select the document library or list to search in",
|
|
34
|
+
},
|
|
35
|
+
filter: {
|
|
36
|
+
type: "string",
|
|
37
|
+
label: "Filter",
|
|
38
|
+
description:
|
|
39
|
+
"Filter items using OData syntax. To filter by custom columns, use `fields/ColumnInternalName`. Example: `fields/Title eq 'My File'` or `fields/Status eq 'Approved'`. [See OData filter documentation](https://learn.microsoft.com/en-us/graph/query-parameters#filter-parameter)",
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
42
|
+
select: {
|
|
43
|
+
propDefinition: [
|
|
44
|
+
sharepoint,
|
|
45
|
+
"columnNames",
|
|
46
|
+
(c) => ({
|
|
47
|
+
siteId: c.siteId,
|
|
48
|
+
listId: c.listId,
|
|
49
|
+
mapper: ({
|
|
50
|
+
name, displayName,
|
|
51
|
+
}) => ({
|
|
52
|
+
label: displayName,
|
|
53
|
+
value: name,
|
|
54
|
+
}),
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
label: "Select Fields",
|
|
58
|
+
description:
|
|
59
|
+
"Select the specific metadata fields to return in the response. If none are selected, all fields will be returned.",
|
|
60
|
+
optional: true,
|
|
61
|
+
},
|
|
62
|
+
orderBy: {
|
|
63
|
+
type: "string",
|
|
64
|
+
label: "Order By",
|
|
65
|
+
description:
|
|
66
|
+
"Specify the sort order of the results using OData syntax. Example: `fields/Created desc` or `fields/Title asc`.",
|
|
67
|
+
optional: true,
|
|
68
|
+
},
|
|
69
|
+
expandFields: {
|
|
70
|
+
type: "boolean",
|
|
71
|
+
label: "Expand Fields?",
|
|
72
|
+
description:
|
|
73
|
+
"Set to `true` to retrieve custom metadata and column values. Defaults to `true`.",
|
|
74
|
+
optional: true,
|
|
75
|
+
default: true,
|
|
76
|
+
},
|
|
77
|
+
maxResults: {
|
|
78
|
+
type: "integer",
|
|
79
|
+
label: "Max Results",
|
|
80
|
+
description: "The maximum number of results to return. Defaults to 100.",
|
|
81
|
+
optional: true,
|
|
82
|
+
default: 100,
|
|
83
|
+
min: 1,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
async run({ $ }) {
|
|
87
|
+
const {
|
|
88
|
+
siteId,
|
|
89
|
+
listId,
|
|
90
|
+
filter,
|
|
91
|
+
select,
|
|
92
|
+
orderBy,
|
|
93
|
+
expandFields,
|
|
94
|
+
maxResults,
|
|
95
|
+
} = this;
|
|
96
|
+
|
|
97
|
+
const expand = expandFields
|
|
98
|
+
? "fields"
|
|
99
|
+
: undefined;
|
|
100
|
+
|
|
101
|
+
// Construct select parameter
|
|
102
|
+
// If fields are selected, we need to select them within the expanded fields
|
|
103
|
+
// Graph API supports $expand=fields($select=Title,Color)
|
|
104
|
+
let expandParam = expand;
|
|
105
|
+
if (expandFields && select?.length > 0) {
|
|
106
|
+
expandParam = `fields($select=${select.join(",")})`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const params = utils.cleanObject({
|
|
110
|
+
$filter: filter,
|
|
111
|
+
$expand: expandParam,
|
|
112
|
+
$orderby: orderBy,
|
|
113
|
+
$top: Math.max(1, maxResults),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const items = [];
|
|
117
|
+
const iterator = this.sharepoint.paginate({
|
|
118
|
+
fn: this.sharepoint.listItems,
|
|
119
|
+
args: {
|
|
120
|
+
$,
|
|
121
|
+
siteId,
|
|
122
|
+
listId,
|
|
123
|
+
params,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
for await (const item of iterator) {
|
|
128
|
+
items.push({
|
|
129
|
+
id: item.id,
|
|
130
|
+
name:
|
|
131
|
+
item.fields?.FileLeafRef ||
|
|
132
|
+
item.fields?.Title ||
|
|
133
|
+
item.name ||
|
|
134
|
+
item.displayName,
|
|
135
|
+
fileType: item.fields?.File_x0020_Type,
|
|
136
|
+
createdDateTime: item.createdDateTime,
|
|
137
|
+
lastModifiedDateTime: item.lastModifiedDateTime,
|
|
138
|
+
webUrl: item.webUrl,
|
|
139
|
+
fields: item.fields,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (items.length >= maxResults) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
$.export(
|
|
148
|
+
"$summary",
|
|
149
|
+
`Found ${items.length} matching item${items.length === 1
|
|
150
|
+
? ""
|
|
151
|
+
: "s"}`,
|
|
152
|
+
);
|
|
153
|
+
return items;
|
|
154
|
+
},
|
|
155
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "sharepoint-search-files",
|
|
5
|
+
name: "Search Files",
|
|
6
|
+
description: "Search for files in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&tabs=http)",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
sharepoint,
|
|
16
|
+
queryString: {
|
|
17
|
+
type: "string",
|
|
18
|
+
label: "Query String",
|
|
19
|
+
description: "The search query containing the search terms",
|
|
20
|
+
},
|
|
21
|
+
queryTemplate: {
|
|
22
|
+
type: "string",
|
|
23
|
+
label: "Query Template",
|
|
24
|
+
description: "Provides a way to decorate the query string. Supports both KQL and query variables. Example: `({searchTerms}) AuthorOWSUSER:Adventure` [See the documentation](https://learn.microsoft.com/en-us/graph/search-concept-query-template) for more information.",
|
|
25
|
+
optional: true,
|
|
26
|
+
},
|
|
27
|
+
select: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
sharepoint,
|
|
30
|
+
"select",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
propDefinition: [
|
|
35
|
+
sharepoint,
|
|
36
|
+
"maxResults",
|
|
37
|
+
],
|
|
38
|
+
max: 500,
|
|
39
|
+
},
|
|
40
|
+
sortField: {
|
|
41
|
+
type: "string",
|
|
42
|
+
label: "Sort Field",
|
|
43
|
+
description: "The field to sort the results by",
|
|
44
|
+
default: "lastModifiedDateTime",
|
|
45
|
+
optional: true,
|
|
46
|
+
},
|
|
47
|
+
descending: {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
label: "Descending",
|
|
50
|
+
description: "Whether to sort the results in descending order",
|
|
51
|
+
optional: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
async run({ $ }) {
|
|
55
|
+
const response = await this.sharepoint.searchQuery({
|
|
56
|
+
$,
|
|
57
|
+
data: {
|
|
58
|
+
requests: [
|
|
59
|
+
{
|
|
60
|
+
entityTypes: [
|
|
61
|
+
"driveItem",
|
|
62
|
+
],
|
|
63
|
+
query: {
|
|
64
|
+
queryString: this.queryString,
|
|
65
|
+
queryTemplate: this.queryTemplate,
|
|
66
|
+
},
|
|
67
|
+
fields: this.select
|
|
68
|
+
? this.select.split(",").map((f) => f.trim())
|
|
69
|
+
: undefined,
|
|
70
|
+
size: this.size,
|
|
71
|
+
sortProperties: [
|
|
72
|
+
{
|
|
73
|
+
name: this.sortField,
|
|
74
|
+
isDescending: this.descending,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
$.export("$summary", `Successfully searched for ${this.queryString}`);
|
|
82
|
+
return response;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "sharepoint-search-sites",
|
|
5
|
+
name: "Search Sites",
|
|
6
|
+
description: "Search for sites in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/site-search?view=graph-rest-1.0&tabs=http)",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
sharepoint,
|
|
16
|
+
query: {
|
|
17
|
+
type: "string",
|
|
18
|
+
label: "Query",
|
|
19
|
+
description: "The query to search for",
|
|
20
|
+
},
|
|
21
|
+
select: {
|
|
22
|
+
propDefinition: [
|
|
23
|
+
sharepoint,
|
|
24
|
+
"select",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
maxResults: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
sharepoint,
|
|
30
|
+
"maxResults",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
async run({ $ }) {
|
|
35
|
+
const sites = [];
|
|
36
|
+
let count = 0;
|
|
37
|
+
|
|
38
|
+
const results = this.sharepoint.paginate({
|
|
39
|
+
fn: this.sharepoint.listAllSites,
|
|
40
|
+
args: {
|
|
41
|
+
$,
|
|
42
|
+
params: {
|
|
43
|
+
search: this.query,
|
|
44
|
+
select: this.select,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
for await (const site of results) {
|
|
50
|
+
sites.push(site);
|
|
51
|
+
count++;
|
|
52
|
+
if (this.maxResults && count >= this.maxResults) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
$.export("$summary", `Successfully listed ${count} site${count === 1
|
|
58
|
+
? ""
|
|
59
|
+
: "s"}`);
|
|
60
|
+
|
|
61
|
+
return sites;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-select-files",
|
|
5
5
|
name: "Select Files",
|
|
6
6
|
description: "A file picker action that allows browsing and selecting one or more files from SharePoint. Returns the selected files' metadata including pre-authenticated download URLs. [See the documentation](https://learn.microsoft.com/en-us/graph/api/driveitem-get)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -19,42 +19,39 @@ export default {
|
|
|
19
19
|
"siteId",
|
|
20
20
|
],
|
|
21
21
|
withLabel: true,
|
|
22
|
-
reloadProps: true,
|
|
23
22
|
},
|
|
24
23
|
driveId: {
|
|
25
24
|
propDefinition: [
|
|
26
25
|
sharepoint,
|
|
27
26
|
"driveId",
|
|
28
27
|
(c) => ({
|
|
29
|
-
siteId: c.siteId?.
|
|
28
|
+
siteId: c.siteId?.value || c.siteId,
|
|
30
29
|
}),
|
|
31
30
|
],
|
|
32
31
|
withLabel: true,
|
|
33
|
-
reloadProps: true,
|
|
34
32
|
},
|
|
35
33
|
folderId: {
|
|
36
34
|
propDefinition: [
|
|
37
35
|
sharepoint,
|
|
38
36
|
"folderId",
|
|
39
37
|
(c) => ({
|
|
40
|
-
siteId: c.siteId?.
|
|
41
|
-
driveId: c.driveId?.
|
|
38
|
+
siteId: c.siteId?.value || c.siteId,
|
|
39
|
+
driveId: c.driveId?.value || c.driveId,
|
|
42
40
|
}),
|
|
43
41
|
],
|
|
44
42
|
label: "Folder",
|
|
45
43
|
description: "The folder to browse. Leave empty to browse the root of the drive.",
|
|
46
44
|
optional: true,
|
|
47
45
|
withLabel: true,
|
|
48
|
-
reloadProps: true,
|
|
49
46
|
},
|
|
50
47
|
fileOrFolderIds: {
|
|
51
48
|
propDefinition: [
|
|
52
49
|
sharepoint,
|
|
53
50
|
"fileOrFolderId",
|
|
54
51
|
(c) => ({
|
|
55
|
-
siteId: c.siteId?.
|
|
56
|
-
driveId: c.driveId?.
|
|
57
|
-
folderId: c.folderId?.
|
|
52
|
+
siteId: c.siteId?.value || c.siteId,
|
|
53
|
+
driveId: c.driveId?.value || c.driveId,
|
|
54
|
+
folderId: c.folderId?.value || c.folderId,
|
|
58
55
|
}),
|
|
59
56
|
],
|
|
60
57
|
type: "string[]",
|
|
@@ -66,8 +63,8 @@ export default {
|
|
|
66
63
|
methods: {
|
|
67
64
|
resolveValue(prop) {
|
|
68
65
|
if (!prop) return null;
|
|
69
|
-
if (typeof prop === "object" && prop
|
|
70
|
-
return prop.
|
|
66
|
+
if (typeof prop === "object" && prop?.value) {
|
|
67
|
+
return prop.value;
|
|
71
68
|
}
|
|
72
69
|
return prop;
|
|
73
70
|
},
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "sharepoint-update-item",
|
|
6
6
|
name: "Update Item",
|
|
7
7
|
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)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.10",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: true,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "sharepoint-upload-file",
|
|
6
6
|
name: "Upload File",
|
|
7
7
|
description: "Upload a file to OneDrive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
annotations: {
|
|
11
11
|
destructiveHint: false,
|
package/package.json
CHANGED
package/sharepoint.app.mjs
CHANGED
|
@@ -8,12 +8,20 @@ export default {
|
|
|
8
8
|
type: "string",
|
|
9
9
|
label: "Site",
|
|
10
10
|
description: "Identifier of a site",
|
|
11
|
-
|
|
11
|
+
useQuery: true,
|
|
12
|
+
async options({
|
|
13
|
+
prevContext, query,
|
|
14
|
+
}) {
|
|
12
15
|
const args = prevContext?.nextLink
|
|
13
16
|
? {
|
|
14
17
|
url: prevContext.nextLink,
|
|
15
18
|
}
|
|
16
19
|
: {};
|
|
20
|
+
if (query) {
|
|
21
|
+
args.params = {
|
|
22
|
+
search: query,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
17
25
|
const response = await this.listAllSites(args);
|
|
18
26
|
const options = response.value?.map(({
|
|
19
27
|
id: value, displayName: label,
|
|
@@ -66,6 +74,7 @@ export default {
|
|
|
66
74
|
description: "Array of column names",
|
|
67
75
|
async options({
|
|
68
76
|
prevContext, siteId, listId,
|
|
77
|
+
mapper = ({ name }) => name,
|
|
69
78
|
}) {
|
|
70
79
|
if (!siteId || !listId) {
|
|
71
80
|
return [];
|
|
@@ -78,7 +87,7 @@ export default {
|
|
|
78
87
|
args.url = prevContext.nextLink;
|
|
79
88
|
}
|
|
80
89
|
const response = await this.listColumns(args);
|
|
81
|
-
const options = response.value?.map(
|
|
90
|
+
const options = response.value?.map(mapper) || [];
|
|
82
91
|
return {
|
|
83
92
|
options,
|
|
84
93
|
context: {
|
|
@@ -94,7 +103,7 @@ export default {
|
|
|
94
103
|
async options({
|
|
95
104
|
prevContext, siteId, listId,
|
|
96
105
|
}) {
|
|
97
|
-
if (!siteId) {
|
|
106
|
+
if (!siteId || !listId) {
|
|
98
107
|
return [];
|
|
99
108
|
}
|
|
100
109
|
const args = {
|
|
@@ -195,17 +204,24 @@ export default {
|
|
|
195
204
|
async options({
|
|
196
205
|
query, siteId, driveId, excludeFolders = true,
|
|
197
206
|
}) {
|
|
207
|
+
const resolvedSiteId = this.resolveWrappedValue(siteId);
|
|
208
|
+
const resolvedDriveId = this.resolveWrappedValue(driveId);
|
|
209
|
+
|
|
210
|
+
if (!resolvedSiteId || !resolvedDriveId) {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
|
|
198
214
|
const response = query
|
|
199
215
|
? await this.searchDriveItems({
|
|
200
|
-
siteId,
|
|
216
|
+
siteId: resolvedSiteId,
|
|
201
217
|
query,
|
|
202
218
|
params: {
|
|
203
219
|
select: "folder,name,id",
|
|
204
220
|
},
|
|
205
221
|
})
|
|
206
222
|
: await this.listDriveItems({
|
|
207
|
-
siteId,
|
|
208
|
-
driveId,
|
|
223
|
+
siteId: resolvedSiteId,
|
|
224
|
+
driveId: resolvedDriveId,
|
|
209
225
|
});
|
|
210
226
|
const values = excludeFolders
|
|
211
227
|
? response.value.filter(({ folder }) => !folder)
|
|
@@ -266,6 +282,19 @@ export default {
|
|
|
266
282
|
description: "Set to `true` to return only files in the response. Defaults to `false`",
|
|
267
283
|
optional: true,
|
|
268
284
|
},
|
|
285
|
+
select: {
|
|
286
|
+
type: "string",
|
|
287
|
+
label: "Select",
|
|
288
|
+
description: "A comma-separated list of properties to return in the response",
|
|
289
|
+
optional: true,
|
|
290
|
+
},
|
|
291
|
+
maxResults: {
|
|
292
|
+
type: "integer",
|
|
293
|
+
label: "Max Results",
|
|
294
|
+
description: "The maximum number of results to return",
|
|
295
|
+
optional: true,
|
|
296
|
+
default: 100,
|
|
297
|
+
},
|
|
269
298
|
fileOrFolderId: {
|
|
270
299
|
type: "string",
|
|
271
300
|
label: "File or Folder",
|
|
@@ -310,12 +339,15 @@ export default {
|
|
|
310
339
|
resolveWrappedValue(value) {
|
|
311
340
|
return value?.__lv?.value || value;
|
|
312
341
|
},
|
|
342
|
+
_getAccessToken() {
|
|
343
|
+
return this.$auth.oauth_access_token;
|
|
344
|
+
},
|
|
313
345
|
_baseUrl() {
|
|
314
346
|
return "https://graph.microsoft.com/v1.0";
|
|
315
347
|
},
|
|
316
348
|
_headers(headers) {
|
|
317
349
|
return {
|
|
318
|
-
Authorization: `Bearer ${this
|
|
350
|
+
Authorization: `Bearer ${this._getAccessToken()}`,
|
|
319
351
|
...headers,
|
|
320
352
|
};
|
|
321
353
|
},
|
|
@@ -331,15 +363,29 @@ export default {
|
|
|
331
363
|
...args,
|
|
332
364
|
});
|
|
333
365
|
},
|
|
366
|
+
getSite({
|
|
367
|
+
siteId, ...args
|
|
368
|
+
}) {
|
|
369
|
+
return this._makeRequest({
|
|
370
|
+
path: `/sites/${siteId}`,
|
|
371
|
+
...args,
|
|
372
|
+
});
|
|
373
|
+
},
|
|
334
374
|
listSites(args = {}) {
|
|
335
375
|
return this._makeRequest({
|
|
336
376
|
path: "/me/followedSites",
|
|
337
377
|
...args,
|
|
338
378
|
});
|
|
339
379
|
},
|
|
340
|
-
listAllSites(
|
|
380
|
+
listAllSites({
|
|
381
|
+
params = {}, ...args
|
|
382
|
+
} = {}) {
|
|
383
|
+
if (!params.search) {
|
|
384
|
+
params.search = "*";
|
|
385
|
+
}
|
|
341
386
|
return this._makeRequest({
|
|
342
|
-
path: "/sites
|
|
387
|
+
path: "/sites",
|
|
388
|
+
params,
|
|
343
389
|
...args,
|
|
344
390
|
});
|
|
345
391
|
},
|
|
@@ -367,6 +413,14 @@ export default {
|
|
|
367
413
|
...args,
|
|
368
414
|
});
|
|
369
415
|
},
|
|
416
|
+
getListItem({
|
|
417
|
+
siteId, listId, itemId, ...args
|
|
418
|
+
}) {
|
|
419
|
+
return this._makeRequest({
|
|
420
|
+
path: `/sites/${siteId}/lists/${listId}/items/${itemId}`,
|
|
421
|
+
...args,
|
|
422
|
+
});
|
|
423
|
+
},
|
|
370
424
|
listSiteDrives({
|
|
371
425
|
siteId, ...args
|
|
372
426
|
}) {
|
|
@@ -379,7 +433,7 @@ export default {
|
|
|
379
433
|
siteId, driveId, ...args
|
|
380
434
|
}) {
|
|
381
435
|
return this._makeRequest({
|
|
382
|
-
path: `/sites/${siteId}/drives/${driveId}/
|
|
436
|
+
path: `/sites/${siteId}/drives/${driveId}/root/children`,
|
|
383
437
|
...args,
|
|
384
438
|
});
|
|
385
439
|
},
|
|
@@ -395,7 +449,7 @@ export default {
|
|
|
395
449
|
siteId, driveId, ...args
|
|
396
450
|
}) {
|
|
397
451
|
return this._makeRequest({
|
|
398
|
-
path: `/sites/${siteId}/drives/${driveId}/
|
|
452
|
+
path: `/sites/${siteId}/drives/${driveId}/root/children`,
|
|
399
453
|
method: "POST",
|
|
400
454
|
...args,
|
|
401
455
|
});
|
|
@@ -443,7 +497,7 @@ export default {
|
|
|
443
497
|
: `/sites/${siteId}/drives/${driveId}/root:/${encodeURI(name)}:/content`,
|
|
444
498
|
method: "PUT",
|
|
445
499
|
headers: {
|
|
446
|
-
"
|
|
500
|
+
"Authorization": `Bearer ${this._getAccessToken()}`,
|
|
447
501
|
},
|
|
448
502
|
...args,
|
|
449
503
|
});
|
|
@@ -464,7 +518,9 @@ export default {
|
|
|
464
518
|
siteId, query, ...args
|
|
465
519
|
}) {
|
|
466
520
|
return this._makeRequest({
|
|
467
|
-
path: `/sites/${siteId}/drive/root/search(q='${
|
|
521
|
+
path: `/sites/${siteId}/drive/root/search(q='${encodeURIComponent(
|
|
522
|
+
query,
|
|
523
|
+
)}')`,
|
|
468
524
|
...args,
|
|
469
525
|
});
|
|
470
526
|
},
|
|
@@ -503,6 +559,13 @@ export default {
|
|
|
503
559
|
...args,
|
|
504
560
|
});
|
|
505
561
|
},
|
|
562
|
+
searchQuery(args = {}) {
|
|
563
|
+
return this._makeRequest({
|
|
564
|
+
method: "POST",
|
|
565
|
+
path: "/search/query",
|
|
566
|
+
...args,
|
|
567
|
+
});
|
|
568
|
+
},
|
|
506
569
|
async *paginate({
|
|
507
570
|
fn, args,
|
|
508
571
|
}) {
|