@pipedream/sharepoint 0.3.2 → 0.4.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.
@@ -0,0 +1,74 @@
1
+ import sharepoint from "../../sharepoint.app.mjs";
2
+
3
+ export default {
4
+ key: "sharepoint-create-folder",
5
+ name: "Create Folder",
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.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: false,
13
+ },
14
+ props: {
15
+ sharepoint,
16
+ siteId: {
17
+ propDefinition: [
18
+ sharepoint,
19
+ "siteId",
20
+ ],
21
+ },
22
+ driveId: {
23
+ propDefinition: [
24
+ sharepoint,
25
+ "driveId",
26
+ (c) => ({
27
+ siteId: c.siteId,
28
+ }),
29
+ ],
30
+ },
31
+ folderId: {
32
+ propDefinition: [
33
+ sharepoint,
34
+ "folderId",
35
+ (c) => ({
36
+ siteId: c.siteId,
37
+ driveId: c.driveId,
38
+ }),
39
+ ],
40
+ label: "Parent Folder ID",
41
+ 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*.",
42
+ },
43
+ folderName: {
44
+ type: "string",
45
+ label: "Folder Name",
46
+ description: "The name of the new folder to be created. e.g. `New Folder`",
47
+ },
48
+ },
49
+ async run({ $ }) {
50
+ const data = {
51
+ name: this.folderName,
52
+ folder: {},
53
+ };
54
+ const response = this.folderId
55
+ ? await this.sharepoint.createDriveItemInFolder({
56
+ $,
57
+ siteId: this.siteId,
58
+ folderId: this.folderId,
59
+ data,
60
+ })
61
+ : await this.sharepoint.createDriveItem({
62
+ $,
63
+ siteId: this.siteId,
64
+ driveId: this.driveId,
65
+ data,
66
+ });
67
+
68
+ if (response?.id) {
69
+ $.export("$summary", `Successfully created folder with ID ${response.id}.`);
70
+ }
71
+
72
+ return response;
73
+ },
74
+ };
@@ -4,7 +4,12 @@ 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.4",
7
+ version: "0.0.7",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
8
13
  type: "action",
9
14
  props: {
10
15
  sharepoint,
@@ -0,0 +1,74 @@
1
+ import sharepoint from "../../sharepoint.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ key: "sharepoint-create-link",
6
+ name: "Create Link",
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.1",
9
+ type: "action",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: false,
14
+ },
15
+ props: {
16
+ sharepoint,
17
+ siteId: {
18
+ propDefinition: [
19
+ sharepoint,
20
+ "siteId",
21
+ ],
22
+ },
23
+ driveId: {
24
+ propDefinition: [
25
+ sharepoint,
26
+ "driveId",
27
+ (c) => ({
28
+ siteId: c.siteId,
29
+ }),
30
+ ],
31
+ },
32
+ fileId: {
33
+ propDefinition: [
34
+ sharepoint,
35
+ "fileId",
36
+ (c) => ({
37
+ siteId: c.siteId,
38
+ driveId: c.driveId,
39
+ excludeFolders: false,
40
+ }),
41
+ ],
42
+ },
43
+ type: {
44
+ type: "string",
45
+ label: "Type",
46
+ description: "The type of sharing link to create. Either `view`, `edit`, or `embed`.",
47
+ options: constants.SHARING_LINK_TYPE_OPTIONS,
48
+ },
49
+ scope: {
50
+ type: "string",
51
+ label: "Scope",
52
+ description: "The scope of link to create. Either `anonymous` or `organization`.",
53
+ options: constants.SHARING_LINK_SCOPE_OPTIONS,
54
+ optional: true,
55
+ },
56
+ },
57
+ async run({ $ }) {
58
+ const response = await this.sharepoint.createLink({
59
+ $,
60
+ siteId: this.siteId,
61
+ fileId: this.fileId,
62
+ data: {
63
+ type: this.type,
64
+ scope: this.scope,
65
+ },
66
+ });
67
+
68
+ if (response?.id) {
69
+ $.export("$summary", `Successfully created a sharing link with ID \`${response.id}\`.`);
70
+ }
71
+
72
+ return response;
73
+ },
74
+ };
@@ -4,7 +4,12 @@ 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.4",
7
+ version: "0.0.7",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
8
13
  type: "action",
9
14
  props: {
10
15
  sharepoint,
@@ -5,7 +5,12 @@ 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.3",
8
+ version: "0.0.6",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
9
14
  type: "action",
10
15
  props: {
11
16
  sharepoint,
@@ -0,0 +1,52 @@
1
+ import sharepoint from "../../sharepoint.app.mjs";
2
+
3
+ export default {
4
+ key: "sharepoint-find-file-by-name",
5
+ name: "Find File by Name",
6
+ 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)",
7
+ version: "0.0.1",
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
+ name: {
23
+ type: "string",
24
+ label: "File Name",
25
+ description: "The name of the file or folder to search for",
26
+ },
27
+ excludeFolders: {
28
+ propDefinition: [
29
+ sharepoint,
30
+ "excludeFolders",
31
+ ],
32
+ },
33
+ },
34
+ async run({ $ }) {
35
+ const response = await this.sharepoint.searchDriveItems({
36
+ $,
37
+ siteId: this.siteId,
38
+ query: this.name,
39
+ });
40
+ let values = response.value.filter(
41
+ ({ name }) => name.toLowerCase().includes(this.name.toLowerCase()),
42
+ );
43
+ if (this.excludeFolders) {
44
+ values = values.filter(({ folder }) => !folder);
45
+ }
46
+
47
+ $.export("$summary", `Found ${values.length} matching file${values.length === 1
48
+ ? ""
49
+ : "s"}`);
50
+ return values;
51
+ },
52
+ };
@@ -0,0 +1,84 @@
1
+ import sharepoint from "../../sharepoint.app.mjs";
2
+
3
+ export default {
4
+ key: "sharepoint-get-excel-table",
5
+ name: "Get Excel Table",
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.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ sharepoint,
16
+ alert: {
17
+ type: "alert",
18
+ alertType: "info",
19
+ content: `Note: The table must exist within the Excel spreadsheet.
20
+ \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
+ `,
22
+ },
23
+ siteId: {
24
+ propDefinition: [
25
+ sharepoint,
26
+ "siteId",
27
+ ],
28
+ },
29
+ itemId: {
30
+ propDefinition: [
31
+ sharepoint,
32
+ "excelFileId",
33
+ (c) => ({
34
+ siteId: c.siteId,
35
+ }),
36
+ ],
37
+ },
38
+ tableName: {
39
+ propDefinition: [
40
+ sharepoint,
41
+ "tableName",
42
+ (c) => ({
43
+ siteId: c.siteId,
44
+ itemId: c.itemId,
45
+ }),
46
+ ],
47
+ },
48
+ removeHeaders: {
49
+ type: "boolean",
50
+ label: "Remove headers?",
51
+ optional: true,
52
+ description: "By default, The headers are included as the first row.",
53
+ default: false,
54
+ },
55
+ numberOfRows: {
56
+ type: "integer",
57
+ optional: true,
58
+ default: 0,
59
+ min: 0,
60
+ label: "Number of rows to return",
61
+ description: "Leave blank to return all rows.",
62
+ },
63
+ },
64
+ async run({ $ }) {
65
+ const range = await this.sharepoint.getExcelTable({
66
+ $,
67
+ siteId: this.siteId,
68
+ itemId: this.itemId,
69
+ tableName: this.tableName,
70
+ });
71
+
72
+ const response = this.removeHeaders
73
+ ? this.numberOfRows <= 0
74
+ ? range.text.slice(1)
75
+ : range.text.slice(1, this.numberOfRows + 1)
76
+ : this.numberOfRows <= 0
77
+ ? range.text
78
+ : range.text.slice(0, this.numberOfRows + 1);
79
+
80
+ $.export("$summary", "Successfully retrieved excel table.");
81
+
82
+ return response;
83
+ },
84
+ };
@@ -0,0 +1,52 @@
1
+ import sharepoint from "../../sharepoint.app.mjs";
2
+
3
+ export default {
4
+ key: "sharepoint-get-file-by-id",
5
+ name: "Get File by ID",
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.1",
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
+ driveId: {
23
+ propDefinition: [
24
+ sharepoint,
25
+ "driveId",
26
+ (c) => ({
27
+ siteId: c.siteId,
28
+ }),
29
+ ],
30
+ },
31
+ fileId: {
32
+ propDefinition: [
33
+ sharepoint,
34
+ "fileId",
35
+ (c) => ({
36
+ siteId: c.siteId,
37
+ driveId: c.driveId,
38
+ }),
39
+ ],
40
+ description: "The file to retrieve. You can either search for the file here or provide a custom *File ID*.",
41
+ },
42
+ },
43
+ async run({ $ }) {
44
+ const response = await this.sharepoint.getDriveItem({
45
+ $,
46
+ siteId: this.siteId,
47
+ fileId: this.fileId,
48
+ });
49
+ $.export("$summary", `Successfully retrieved file with ID: ${this.fileId}`);
50
+ return response;
51
+ },
52
+ };
@@ -0,0 +1,67 @@
1
+ import sharepoint from "../../sharepoint.app.mjs";
2
+
3
+ export default {
4
+ key: "sharepoint-list-files-in-folder",
5
+ name: "List Files in Folder",
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.1",
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
+ driveId: {
23
+ propDefinition: [
24
+ sharepoint,
25
+ "driveId",
26
+ (c) => ({
27
+ siteId: c.siteId,
28
+ }),
29
+ ],
30
+ },
31
+ folderId: {
32
+ propDefinition: [
33
+ sharepoint,
34
+ "folderId",
35
+ (c) => ({
36
+ siteId: c.siteId,
37
+ driveId: c.driveId,
38
+ }),
39
+ ],
40
+ },
41
+ excludeFolders: {
42
+ propDefinition: [
43
+ sharepoint,
44
+ "excludeFolders",
45
+ ],
46
+ },
47
+ },
48
+ async run({ $ }) {
49
+ const response = this.folderId
50
+ ? await this.sharepoint.listDriveItemsInFolder({
51
+ $,
52
+ siteId: this.siteId,
53
+ folderId: this.folderId,
54
+ })
55
+ : await this.sharepoint.listDriveItems({
56
+ $,
57
+ siteId: this.siteId,
58
+ driveId: this.driveId,
59
+ });
60
+ const values = this.excludeFolders
61
+ ? response.value.filter(({ folder }) => !folder)
62
+ : response.value;
63
+
64
+ $.export("$summary", `Found ${values.length} file(s) and/or folder(s)`);
65
+ return values;
66
+ },
67
+ };
@@ -5,7 +5,12 @@ 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.3",
8
+ version: "0.0.6",
9
+ annotations: {
10
+ destructiveHint: true,
11
+ openWorldHint: true,
12
+ readOnlyHint: false,
13
+ },
9
14
  type: "action",
10
15
  props: {
11
16
  sharepoint,
@@ -0,0 +1,86 @@
1
+ import sharepoint from "../../sharepoint.app.mjs";
2
+ import { getFileStreamAndMetadata } from "@pipedream/platform";
3
+
4
+ export default {
5
+ key: "sharepoint-upload-file",
6
+ name: "Upload File",
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.1",
9
+ type: "action",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: false,
14
+ },
15
+ props: {
16
+ sharepoint,
17
+ siteId: {
18
+ propDefinition: [
19
+ sharepoint,
20
+ "siteId",
21
+ ],
22
+ },
23
+ driveId: {
24
+ propDefinition: [
25
+ sharepoint,
26
+ "driveId",
27
+ (c) => ({
28
+ siteId: c.siteId,
29
+ }),
30
+ ],
31
+ },
32
+ uploadFolderId: {
33
+ propDefinition: [
34
+ sharepoint,
35
+ "folderId",
36
+ (c) => ({
37
+ siteId: c.siteId,
38
+ driveId: c.driveId,
39
+ }),
40
+ ],
41
+ label: "Upload Folder ID",
42
+ description: "The ID of the folder where you want to upload the file. You can either search for the folder here or provide a custom *Folder ID*.",
43
+ },
44
+ filePath: {
45
+ type: "string",
46
+ label: "File Path or URL",
47
+ description: "The file to upload. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.txt`)",
48
+ },
49
+ filename: {
50
+ type: "string",
51
+ label: "Name",
52
+ description: "Name of the new uploaded file",
53
+ },
54
+ syncDir: {
55
+ type: "dir",
56
+ accessMode: "read",
57
+ sync: true,
58
+ optional: true,
59
+ },
60
+ },
61
+ async run({ $ }) {
62
+ const {
63
+ siteId, driveId, uploadFolderId, filePath, filename,
64
+ } = this;
65
+
66
+ const {
67
+ stream, metadata,
68
+ } = await getFileStreamAndMetadata(filePath);
69
+ const name = filename || metadata.name;
70
+
71
+ const response = await this.sharepoint.uploadFile({
72
+ siteId,
73
+ driveId,
74
+ uploadFolderId,
75
+ name,
76
+ data: stream,
77
+ $,
78
+ });
79
+
80
+ if (response?.id) {
81
+ $.export("$summary", `Successfully uploaded file with ID ${response.id}.`);
82
+ }
83
+
84
+ return response;
85
+ },
86
+ };
@@ -0,0 +1,30 @@
1
+ const SHARING_LINK_TYPE_OPTIONS = [
2
+ {
3
+ label: "Create a read-only link to the DriveItem",
4
+ value: "view",
5
+ },
6
+ {
7
+ label: "Create a read-write link to the DriveItem",
8
+ value: "edit",
9
+ },
10
+ {
11
+ label: "Create an embeddable link to the DriveItem. Only available for files in OneDrive personal.",
12
+ value: "embed",
13
+ },
14
+ ];
15
+
16
+ const SHARING_LINK_SCOPE_OPTIONS = [
17
+ {
18
+ label: "Anyone with the link has access, without needing to sign in",
19
+ value: "anonymous",
20
+ },
21
+ {
22
+ label: "Anyone signed into your organization can use the link. Only available in OneDrive for Business and SharePoint.",
23
+ value: "organization",
24
+ },
25
+ ];
26
+
27
+ export default {
28
+ SHARING_LINK_TYPE_OPTIONS,
29
+ SHARING_LINK_SCOPE_OPTIONS,
30
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/sharepoint",
3
- "version": "0.3.2",
3
+ "version": "0.4.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": "^3.0.3"
16
+ "@pipedream/platform": "^3.1.0"
17
17
  }
18
18
  }
@@ -14,7 +14,7 @@ export default {
14
14
  url: prevContext.nextLink,
15
15
  }
16
16
  : {};
17
- const response = await this.listSites(args);
17
+ const response = await this.listAllSites(args);
18
18
  const options = response.value?.map(({
19
19
  id: value, displayName: label,
20
20
  }) => ({
@@ -148,13 +148,44 @@ export default {
148
148
  };
149
149
  },
150
150
  },
151
+ folderId: {
152
+ type: "string",
153
+ label: "Folder ID",
154
+ description: "The folder to list files in. You can either search for the folder here or provide a custom *Folder ID*.",
155
+ optional: true,
156
+ useQuery: true,
157
+ async options({
158
+ query, siteId, driveId,
159
+ }) {
160
+ const response = query
161
+ ? await this.searchDriveItems({
162
+ siteId,
163
+ query,
164
+ params: {
165
+ select: "folder,name,id",
166
+ },
167
+ })
168
+ : await this.listDriveItems({
169
+ siteId,
170
+ driveId,
171
+ });
172
+ const values = response.value.filter(({ folder }) => folder);
173
+ return values
174
+ .map(({
175
+ name, id,
176
+ }) => ({
177
+ label: name,
178
+ value: id,
179
+ }));
180
+ },
181
+ },
151
182
  fileId: {
152
183
  type: "string",
153
184
  label: "File ID",
154
185
  description: "The file to download. You can either search for the file here or provide a custom *File ID*.",
155
186
  useQuery: true,
156
187
  async options({
157
- query, siteId, driveId,
188
+ query, siteId, driveId, excludeFolders = true,
158
189
  }) {
159
190
  const response = query
160
191
  ? await this.searchDriveItems({
@@ -168,7 +199,9 @@ export default {
168
199
  siteId,
169
200
  driveId,
170
201
  });
171
- const values = response.value.filter(({ folder }) => !folder);
202
+ const values = excludeFolders
203
+ ? response.value.filter(({ folder }) => !folder)
204
+ : response.value;
172
205
  return values
173
206
  .map(({
174
207
  name, id,
@@ -178,24 +211,73 @@ export default {
178
211
  }));
179
212
  },
180
213
  },
214
+ excelFileId: {
215
+ type: "string",
216
+ label: "Spreadsheet",
217
+ description: "**Search for the file by name.** Only xlsx files are supported.",
218
+ useQuery: true,
219
+ async options({
220
+ siteId, query,
221
+ }) {
222
+ const response = await this.searchDriveItems({
223
+ siteId,
224
+ query,
225
+ params: {
226
+ select: "name,id",
227
+ },
228
+ });
229
+ return response.value.filter(({ name }) => name.endsWith(".xlsx"))
230
+ .map(({
231
+ name, id,
232
+ }) => ({
233
+ label: name,
234
+ value: id,
235
+ }));
236
+ },
237
+ },
238
+ tableName: {
239
+ type: "string",
240
+ label: "Table Name",
241
+ description: "This is set in the **Table Design** tab of the ribbon",
242
+ async options({
243
+ siteId, itemId,
244
+ }) {
245
+ const response = await this.listExcelTables({
246
+ siteId,
247
+ itemId,
248
+ params: {
249
+ select: "name",
250
+ },
251
+ });
252
+ return response.value.map(({ name }) => name);
253
+ },
254
+ },
255
+ excludeFolders: {
256
+ type: "boolean",
257
+ label: "Exclude Folders?",
258
+ description: "Set to `true` to return only files in the response. Defaults to `false`",
259
+ optional: true,
260
+ },
181
261
  },
182
262
  methods: {
183
263
  _baseUrl() {
184
264
  return "https://graph.microsoft.com/v1.0";
185
265
  },
186
- _headers() {
266
+ _headers(headers) {
187
267
  return {
188
268
  Authorization: `Bearer ${this.$auth.oauth_access_token}`,
269
+ ...headers,
189
270
  };
190
271
  },
191
272
  _makeRequest({
192
273
  $ = this,
193
274
  path,
275
+ headers,
194
276
  ...args
195
277
  }) {
196
278
  return axios($, {
197
279
  url: `${this._baseUrl()}${path}`,
198
- headers: this._headers(),
280
+ headers: this._headers(headers),
199
281
  ...args,
200
282
  });
201
283
  },
@@ -205,6 +287,12 @@ export default {
205
287
  ...args,
206
288
  });
207
289
  },
290
+ listAllSites(args = {}) {
291
+ return this._makeRequest({
292
+ path: "/sites?search=*",
293
+ ...args,
294
+ });
295
+ },
208
296
  listLists({
209
297
  siteId, ...args
210
298
  }) {
@@ -245,6 +333,79 @@ export default {
245
333
  ...args,
246
334
  });
247
335
  },
336
+ listDriveItemsInFolder({
337
+ siteId, folderId, ...args
338
+ }) {
339
+ return this._makeRequest({
340
+ path: `/sites/${siteId}/drive/items/${folderId}/children`,
341
+ ...args,
342
+ });
343
+ },
344
+ createDriveItem({
345
+ siteId, driveId, ...args
346
+ }) {
347
+ return this._makeRequest({
348
+ path: `/sites/${siteId}/drives/${driveId}/items/root/children`,
349
+ method: "POST",
350
+ ...args,
351
+ });
352
+ },
353
+ createDriveItemInFolder({
354
+ siteId, folderId, ...args
355
+ }) {
356
+ return this._makeRequest({
357
+ path: `/sites/${siteId}/drive/items/${folderId}/children`,
358
+ method: "POST",
359
+ ...args,
360
+ });
361
+ },
362
+ createLink({
363
+ siteId, fileId, ...args
364
+ }) {
365
+ return this._makeRequest({
366
+ path: `/sites/${siteId}/drive/items/${fileId}/createLink`,
367
+ method: "POST",
368
+ ...args,
369
+ });
370
+ },
371
+ listExcelTables({
372
+ siteId, itemId, ...args
373
+ }) {
374
+ return this._makeRequest({
375
+ path: `/sites/${siteId}/drive/items/${itemId}/workbook/tables`,
376
+ ...args,
377
+ });
378
+ },
379
+ getExcelTable({
380
+ siteId, itemId, tableName, ...args
381
+ }) {
382
+ return this._makeRequest({
383
+ path: `/sites/${siteId}/drive/items/${itemId}/workbook/tables/${tableName}/range`,
384
+ ...args,
385
+ });
386
+ },
387
+ uploadFile({
388
+ siteId, driveId, uploadFolderId, name, ...args
389
+ }) {
390
+ return this._makeRequest({
391
+ path: uploadFolderId
392
+ ? `/sites/${siteId}/drives/${driveId}/items/${uploadFolderId}:/${encodeURI(name)}:/content`
393
+ : `/sites/${siteId}/drives/${driveId}/root:/${encodeURI(name)}:/content`,
394
+ method: "PUT",
395
+ headers: {
396
+ "Content-Type": "application/octet-stream",
397
+ },
398
+ ...args,
399
+ });
400
+ },
401
+ getDriveItem({
402
+ siteId, fileId, ...args
403
+ }) {
404
+ return this._makeRequest({
405
+ path: `/sites/${siteId}/drive/items/${fileId}`,
406
+ ...args,
407
+ });
408
+ },
248
409
  searchDriveItems({
249
410
  siteId, query, ...args
250
411
  }) {
@@ -23,6 +23,12 @@ export default {
23
23
  const meta = this.generateMeta(item);
24
24
  this.$emit(item, meta);
25
25
  },
26
+ isSortedDesc() {
27
+ return false;
28
+ },
29
+ isRelevant() {
30
+ return true;
31
+ },
26
32
  getResourceFn() {
27
33
  throw new Error("getResourceFn is not implemented");
28
34
  },
@@ -47,13 +53,19 @@ export default {
47
53
  args,
48
54
  });
49
55
 
56
+ let count = 0;
50
57
  for await (const item of items) {
51
58
  const ts = Date.parse(item[this.getTsField()]);
52
59
  if (ts > lastTs) {
53
- this.emitEvent(item);
60
+ if (this.isRelevant(item) && (lastTs || count < 10)) {
61
+ this.emitEvent(item);
62
+ count++;
63
+ }
54
64
  if (ts > maxTs) {
55
65
  maxTs = ts;
56
66
  }
67
+ } else if (this.isSortedDesc()) {
68
+ break;
57
69
  }
58
70
  }
59
71
 
@@ -0,0 +1,73 @@
1
+ import common from "../common/common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "sharepoint-new-file-created",
6
+ name: "New File Created",
7
+ description: "Emit new event when a new file is created in Microsoft Sharepoint.",
8
+ version: "0.0.1",
9
+ type: "source",
10
+ dedupe: "unique",
11
+ props: {
12
+ ...common.props,
13
+ siteId: {
14
+ propDefinition: [
15
+ common.props.sharepoint,
16
+ "siteId",
17
+ ],
18
+ },
19
+ driveId: {
20
+ propDefinition: [
21
+ common.props.sharepoint,
22
+ "driveId",
23
+ (c) => ({
24
+ siteId: c.siteId,
25
+ }),
26
+ ],
27
+ },
28
+ folderId: {
29
+ propDefinition: [
30
+ common.props.sharepoint,
31
+ "folderId",
32
+ (c) => ({
33
+ siteId: c.siteId,
34
+ driveId: c.driveId,
35
+ }),
36
+ ],
37
+ },
38
+ },
39
+ methods: {
40
+ ...common.methods,
41
+ getResourceFn() {
42
+ return this.folderId
43
+ ? this.sharepoint.listDriveItemsInFolder
44
+ : this.sharepoint.listDriveItems;
45
+ },
46
+ getArgs() {
47
+ return {
48
+ siteId: this.siteId,
49
+ driveId: this.driveId,
50
+ folderId: this.folderId,
51
+ params: {
52
+ orderby: "lastModifiedDateTime desc",
53
+ },
54
+ };
55
+ },
56
+ getTsField() {
57
+ return "lastModifiedDateTime";
58
+ },
59
+ isSortedDesc() {
60
+ return true;
61
+ },
62
+ isRelevant(item) {
63
+ return !!item.file;
64
+ },
65
+ generateMeta(item) {
66
+ return {
67
+ id: item.id,
68
+ summary: `New File: ${item.name}`,
69
+ ts: Date.parse(item.createdDateTime),
70
+ };
71
+ },
72
+ },
73
+ };
@@ -0,0 +1,73 @@
1
+ import common from "../common/common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "sharepoint-new-folder-created",
6
+ name: "New Folder Created",
7
+ description: "Emit new event when a new folder is created in Microsoft Sharepoint.",
8
+ version: "0.0.1",
9
+ type: "source",
10
+ dedupe: "unique",
11
+ props: {
12
+ ...common.props,
13
+ siteId: {
14
+ propDefinition: [
15
+ common.props.sharepoint,
16
+ "siteId",
17
+ ],
18
+ },
19
+ driveId: {
20
+ propDefinition: [
21
+ common.props.sharepoint,
22
+ "driveId",
23
+ (c) => ({
24
+ siteId: c.siteId,
25
+ }),
26
+ ],
27
+ },
28
+ folderId: {
29
+ propDefinition: [
30
+ common.props.sharepoint,
31
+ "folderId",
32
+ (c) => ({
33
+ siteId: c.siteId,
34
+ driveId: c.driveId,
35
+ }),
36
+ ],
37
+ },
38
+ },
39
+ methods: {
40
+ ...common.methods,
41
+ getResourceFn() {
42
+ return this.folderId
43
+ ? this.sharepoint.listDriveItemsInFolder
44
+ : this.sharepoint.listDriveItems;
45
+ },
46
+ getArgs() {
47
+ return {
48
+ siteId: this.siteId,
49
+ driveId: this.driveId,
50
+ folderId: this.folderId,
51
+ params: {
52
+ orderby: "lastModifiedDateTime desc",
53
+ },
54
+ };
55
+ },
56
+ getTsField() {
57
+ return "lastModifiedDateTime";
58
+ },
59
+ isSortedDesc() {
60
+ return true;
61
+ },
62
+ isRelevant(item) {
63
+ return !!item.folder;
64
+ },
65
+ generateMeta(item) {
66
+ return {
67
+ id: item.id,
68
+ summary: `New Folder: ${item.name}`,
69
+ ts: Date.parse(item.createdDateTime),
70
+ };
71
+ },
72
+ },
73
+ };
@@ -4,8 +4,8 @@ export default {
4
4
  ...common,
5
5
  key: "sharepoint-new-list-item",
6
6
  name: "New List Item",
7
- description: "Emit new event when a new list is created in Microsoft Sharepoint.",
8
- version: "0.0.4",
7
+ description: "Emit new event when a new list item is created in Microsoft Sharepoint.",
8
+ version: "0.0.6",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -4,8 +4,8 @@ export default {
4
4
  ...common,
5
5
  key: "sharepoint-updated-list-item",
6
6
  name: "Updated List Item",
7
- description: "Emit new event when a list is updated in Microsoft Sharepoint.",
8
- version: "0.0.4",
7
+ description: "Emit new event when a list item is updated in Microsoft Sharepoint.",
8
+ version: "0.0.6",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {