@pipedream/sharepoint 0.1.0 → 0.3.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/README.md +11 -0
- package/actions/create-item/create-item.mjs +1 -1
- package/actions/create-list/create-list.mjs +1 -1
- package/actions/download-file/download-file.mjs +61 -0
- package/actions/update-item/update-item.mjs +80 -0
- package/common/utils.mjs +10 -0
- package/package.json +2 -2
- package/sharepoint.app.mjs +132 -0
- package/sources/new-list-item/new-list-item.mjs +1 -1
- package/sources/updated-list-item/updated-list-item.mjs +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
The Microsoft SharePoint Online API opens up a world of possibilities for integrating your SharePoint content with other services and automating tasks. With Pipedream, you can harness this API to create powerful workflows that trigger on events in SharePoint, manipulate data, and connect with countless other apps. Create custom automations for document management, team notifications, content moderation, and more, without the need to manage infrastructure.
|
|
4
|
+
|
|
5
|
+
# Example Use Cases
|
|
6
|
+
|
|
7
|
+
- **Automate Document Approval Workflows**: Trigger a workflow in Pipedream whenever a new document is uploaded to a SharePoint library. Use the API to send approval requests via email using an app like SendGrid. Once approved, update the document's metadata in SharePoint to reflect the change.
|
|
8
|
+
|
|
9
|
+
- **Sync SharePoint Lists with External Databases**: Keep a SharePoint list in sync with an external database, such as MySQL or PostgreSQL. Use scheduled Pipedream workflows to fetch records from the database and update the corresponding SharePoint list items, or vice versa.
|
|
10
|
+
|
|
11
|
+
- **Aggregate SharePoint Analytics**: Collect and aggregate analytics from SharePoint, like page views or document downloads. Send this data to a service like Google Sheets or Data Studio for advanced reporting and visualization.
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
sharepoint,
|
|
@@ -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.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
sharepoint,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "sharepoint-download-file",
|
|
6
|
+
name: "Download File",
|
|
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.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
sharepoint,
|
|
12
|
+
siteId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
sharepoint,
|
|
15
|
+
"siteId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
driveId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
sharepoint,
|
|
21
|
+
"driveId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
siteId: c.siteId,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
fileId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
sharepoint,
|
|
30
|
+
"fileId",
|
|
31
|
+
(c) => ({
|
|
32
|
+
siteId: c.siteId,
|
|
33
|
+
driveId: c.driveId,
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
filename: {
|
|
38
|
+
type: "string",
|
|
39
|
+
label: "Filename",
|
|
40
|
+
description: "The filename to save the downloaded file as in the `/tmp` directory",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
async run({ $ }) {
|
|
44
|
+
const response = await this.sharepoint.getFile({
|
|
45
|
+
$,
|
|
46
|
+
siteId: this.siteId,
|
|
47
|
+
fileId: this.fileId,
|
|
48
|
+
responseType: "arraybuffer",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const rawcontent = response.toString("base64");
|
|
52
|
+
const buffer = Buffer.from(rawcontent, "base64");
|
|
53
|
+
const downloadedFilepath = `/tmp/${this.filename}`;
|
|
54
|
+
fs.writeFileSync(downloadedFilepath, buffer);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
filename: this.filename,
|
|
58
|
+
downloadedFilepath,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "sharepoint-update-item",
|
|
6
|
+
name: "Update Item",
|
|
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.2",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
sharepoint,
|
|
12
|
+
siteId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
sharepoint,
|
|
15
|
+
"siteId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
listId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
sharepoint,
|
|
21
|
+
"listId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
siteId: c.siteId,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
reloadProps: true,
|
|
27
|
+
},
|
|
28
|
+
itemId: {
|
|
29
|
+
propDefinition: [
|
|
30
|
+
sharepoint,
|
|
31
|
+
"itemId",
|
|
32
|
+
(c) => ({
|
|
33
|
+
siteId: c.siteId,
|
|
34
|
+
listId: c.listId,
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
async additionalProps() {
|
|
40
|
+
const props = {};
|
|
41
|
+
const { value: columns } = await this.sharepoint.listColumns({
|
|
42
|
+
siteId: this.siteId,
|
|
43
|
+
listId: this.listId,
|
|
44
|
+
});
|
|
45
|
+
const editableColumns = columns?.filter(({ readOnly }) => !readOnly) || [];
|
|
46
|
+
for (const column of editableColumns) {
|
|
47
|
+
props[column.name] = {
|
|
48
|
+
type: "string",
|
|
49
|
+
label: column.name,
|
|
50
|
+
optional: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return props;
|
|
54
|
+
},
|
|
55
|
+
async run({ $ }) {
|
|
56
|
+
const {
|
|
57
|
+
sharepoint,
|
|
58
|
+
siteId,
|
|
59
|
+
listId,
|
|
60
|
+
itemId,
|
|
61
|
+
...otherProps
|
|
62
|
+
} = this;
|
|
63
|
+
|
|
64
|
+
const data = utils.cleanObject(otherProps);
|
|
65
|
+
|
|
66
|
+
const response = await sharepoint.updateItem({
|
|
67
|
+
siteId,
|
|
68
|
+
listId,
|
|
69
|
+
itemId,
|
|
70
|
+
data,
|
|
71
|
+
$,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (response?.id) {
|
|
75
|
+
$.export("$summary", `Successfully updated item with ID ${response.id}.`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return response;
|
|
79
|
+
},
|
|
80
|
+
};
|
package/common/utils.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/sharepoint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Pipedream Microsoft Sharepoint Online Components",
|
|
5
5
|
"main": "sharepoint.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pipedream/platform": "^
|
|
16
|
+
"@pipedream/platform": "^3.0.3"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/sharepoint.app.mjs
CHANGED
|
@@ -87,6 +87,97 @@ export default {
|
|
|
87
87
|
};
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
|
+
itemId: {
|
|
91
|
+
type: "string",
|
|
92
|
+
label: "Item",
|
|
93
|
+
description: "Identifier of an item",
|
|
94
|
+
async options({
|
|
95
|
+
prevContext, siteId, listId,
|
|
96
|
+
}) {
|
|
97
|
+
if (!siteId) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const args = {
|
|
101
|
+
siteId,
|
|
102
|
+
listId,
|
|
103
|
+
};
|
|
104
|
+
if (prevContext?.nextLink) {
|
|
105
|
+
args.url = prevContext.nextLink;
|
|
106
|
+
}
|
|
107
|
+
const response = await this.listItems(args);
|
|
108
|
+
const options = response.value?.map(({ id: value }) => ({
|
|
109
|
+
value,
|
|
110
|
+
label: `Item ${value}`,
|
|
111
|
+
})) || [];
|
|
112
|
+
return {
|
|
113
|
+
options,
|
|
114
|
+
context: {
|
|
115
|
+
nextLink: response["@odata.nextLink"],
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
driveId: {
|
|
121
|
+
type: "string",
|
|
122
|
+
label: "Drive ID",
|
|
123
|
+
description: "Identifier of a drive within a site",
|
|
124
|
+
async options({
|
|
125
|
+
prevContext, siteId,
|
|
126
|
+
}) {
|
|
127
|
+
if (!siteId) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
const args = {
|
|
131
|
+
siteId,
|
|
132
|
+
};
|
|
133
|
+
if (prevContext?.nextLink) {
|
|
134
|
+
args.url = prevContext.nextLink;
|
|
135
|
+
}
|
|
136
|
+
const response = await this.listSiteDrives(args);
|
|
137
|
+
const options = response.value?.map(({
|
|
138
|
+
id: value, name: label,
|
|
139
|
+
}) => ({
|
|
140
|
+
value,
|
|
141
|
+
label,
|
|
142
|
+
})) || [];
|
|
143
|
+
return {
|
|
144
|
+
options,
|
|
145
|
+
context: {
|
|
146
|
+
nextLink: response["@odata.nextLink"],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
fileId: {
|
|
152
|
+
type: "string",
|
|
153
|
+
label: "File ID",
|
|
154
|
+
description: "The file to download. You can either search for the file here or provide a custom *File ID*.",
|
|
155
|
+
useQuery: true,
|
|
156
|
+
async options({
|
|
157
|
+
query, siteId, driveId,
|
|
158
|
+
}) {
|
|
159
|
+
const response = query
|
|
160
|
+
? await this.searchDriveItems({
|
|
161
|
+
siteId,
|
|
162
|
+
query,
|
|
163
|
+
params: {
|
|
164
|
+
select: "folder,name,id",
|
|
165
|
+
},
|
|
166
|
+
})
|
|
167
|
+
: await this.listDriveItems({
|
|
168
|
+
siteId,
|
|
169
|
+
driveId,
|
|
170
|
+
});
|
|
171
|
+
const values = response.value.filter(({ folder }) => !folder);
|
|
172
|
+
return values
|
|
173
|
+
.map(({
|
|
174
|
+
name, id,
|
|
175
|
+
}) => ({
|
|
176
|
+
label: name,
|
|
177
|
+
value: id,
|
|
178
|
+
}));
|
|
179
|
+
},
|
|
180
|
+
},
|
|
90
181
|
},
|
|
91
182
|
methods: {
|
|
92
183
|
_baseUrl() {
|
|
@@ -138,6 +229,38 @@ export default {
|
|
|
138
229
|
...args,
|
|
139
230
|
});
|
|
140
231
|
},
|
|
232
|
+
listSiteDrives({
|
|
233
|
+
siteId, ...args
|
|
234
|
+
}) {
|
|
235
|
+
return this._makeRequest({
|
|
236
|
+
path: `/sites/${siteId}/drives`,
|
|
237
|
+
...args,
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
listDriveItems({
|
|
241
|
+
siteId, driveId, ...args
|
|
242
|
+
}) {
|
|
243
|
+
return this._makeRequest({
|
|
244
|
+
path: `/sites/${siteId}/drives/${driveId}/items/root/children`,
|
|
245
|
+
...args,
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
searchDriveItems({
|
|
249
|
+
siteId, query, ...args
|
|
250
|
+
}) {
|
|
251
|
+
return this._makeRequest({
|
|
252
|
+
path: `/sites/${siteId}/drive/root/search(q='${query}')`,
|
|
253
|
+
...args,
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
getFile({
|
|
257
|
+
siteId, fileId, ...args
|
|
258
|
+
}) {
|
|
259
|
+
return this._makeRequest({
|
|
260
|
+
path: `/sites/${siteId}/drive/items/${fileId}/content`,
|
|
261
|
+
...args,
|
|
262
|
+
});
|
|
263
|
+
},
|
|
141
264
|
createList({
|
|
142
265
|
siteId, ...args
|
|
143
266
|
}) {
|
|
@@ -156,6 +279,15 @@ export default {
|
|
|
156
279
|
...args,
|
|
157
280
|
});
|
|
158
281
|
},
|
|
282
|
+
updateItem({
|
|
283
|
+
siteId, listId, itemId, ...args
|
|
284
|
+
}) {
|
|
285
|
+
return this._makeRequest({
|
|
286
|
+
path: `/sites/${siteId}/lists/${listId}/items/${itemId}/fields`,
|
|
287
|
+
method: "PATCH",
|
|
288
|
+
...args,
|
|
289
|
+
});
|
|
290
|
+
},
|
|
159
291
|
async *paginate({
|
|
160
292
|
fn, args,
|
|
161
293
|
}) {
|