@pipedream/sharepoint 0.2.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 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.2",
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.2",
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
+ };
@@ -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.1",
8
+ version: "0.0.2",
9
9
  type: "action",
10
10
  props: {
11
11
  sharepoint,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/sharepoint",
3
- "version": "0.2.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": "^1.5.1"
16
+ "@pipedream/platform": "^3.0.3"
17
17
  }
18
18
  }
@@ -117,6 +117,67 @@ export default {
117
117
  };
118
118
  },
119
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
+ },
120
181
  },
121
182
  methods: {
122
183
  _baseUrl() {
@@ -168,6 +229,38 @@ export default {
168
229
  ...args,
169
230
  });
170
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
+ },
171
264
  createList({
172
265
  siteId, ...args
173
266
  }) {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "sharepoint-new-list-item",
6
6
  name: "New List Item",
7
7
  description: "Emit new event when a new list is created in Microsoft Sharepoint.",
8
- version: "0.0.2",
8
+ version: "0.0.3",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "sharepoint-updated-list-item",
6
6
  name: "Updated List Item",
7
7
  description: "Emit new event when a list is updated in Microsoft Sharepoint.",
8
- version: "0.0.2",
8
+ version: "0.0.3",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {