@pipedream/sharepoint 0.3.3 → 0.5.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 +74 -0
- package/actions/create-item/create-item.mjs +6 -1
- package/actions/create-link/create-link.mjs +74 -0
- package/actions/create-list/create-list.mjs +6 -1
- package/actions/download-file/download-file.mjs +6 -1
- package/actions/find-file-by-name/find-file-by-name.mjs +52 -0
- package/actions/get-excel-table/get-excel-table.mjs +84 -0
- package/actions/get-file-by-id/get-file-by-id.mjs +52 -0
- package/actions/list-files-in-folder/list-files-in-folder.mjs +67 -0
- package/actions/select-files/select-files.mjs +201 -0
- package/actions/update-item/update-item.mjs +6 -1
- package/actions/upload-file/upload-file.mjs +86 -0
- package/common/constants.mjs +30 -0
- package/package.json +2 -2
- package/sharepoint.app.mjs +213 -4
- package/sources/common/common.mjs +13 -1
- package/sources/new-file-created/new-file-created.mjs +73 -0
- package/sources/new-folder-created/new-folder-created.mjs +73 -0
- package/sources/new-list-item/new-list-item.mjs +2 -2
- package/sources/updated-list-item/updated-list-item.mjs +2 -2
|
@@ -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.2",
|
|
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.
|
|
7
|
+
version: "0.0.8",
|
|
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.2",
|
|
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.
|
|
7
|
+
version: "0.0.8",
|
|
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.
|
|
8
|
+
version: "0.0.7",
|
|
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.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
|
+
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.2",
|
|
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.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
|
+
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.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
|
+
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
|
+
driveId: this.driveId,
|
|
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
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "sharepoint-select-files",
|
|
5
|
+
name: "Select Files",
|
|
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.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
|
+
withLabel: true,
|
|
22
|
+
reloadProps: true,
|
|
23
|
+
},
|
|
24
|
+
driveId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
sharepoint,
|
|
27
|
+
"driveId",
|
|
28
|
+
(c) => ({
|
|
29
|
+
siteId: c.siteId?.__lv?.value || c.siteId,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
withLabel: true,
|
|
33
|
+
reloadProps: true,
|
|
34
|
+
},
|
|
35
|
+
folderId: {
|
|
36
|
+
propDefinition: [
|
|
37
|
+
sharepoint,
|
|
38
|
+
"folderId",
|
|
39
|
+
(c) => ({
|
|
40
|
+
siteId: c.siteId?.__lv?.value || c.siteId,
|
|
41
|
+
driveId: c.driveId?.__lv?.value || c.driveId,
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
label: "Folder",
|
|
45
|
+
description: "The folder to browse. Leave empty to browse the root of the drive.",
|
|
46
|
+
optional: true,
|
|
47
|
+
withLabel: true,
|
|
48
|
+
reloadProps: true,
|
|
49
|
+
},
|
|
50
|
+
fileOrFolderIds: {
|
|
51
|
+
propDefinition: [
|
|
52
|
+
sharepoint,
|
|
53
|
+
"fileOrFolderId",
|
|
54
|
+
(c) => ({
|
|
55
|
+
siteId: c.siteId?.__lv?.value || c.siteId,
|
|
56
|
+
driveId: c.driveId?.__lv?.value || c.driveId,
|
|
57
|
+
folderId: c.folderId?.__lv?.value || c.folderId,
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
type: "string[]",
|
|
61
|
+
label: "Files or Folders",
|
|
62
|
+
description: "Select one or more files, or select a folder and click 'Refresh Fields' to browse into it",
|
|
63
|
+
withLabel: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
resolveValue(prop) {
|
|
68
|
+
if (!prop) return null;
|
|
69
|
+
if (typeof prop === "object" && prop.__lv) {
|
|
70
|
+
return prop.__lv.value;
|
|
71
|
+
}
|
|
72
|
+
return prop;
|
|
73
|
+
},
|
|
74
|
+
parseFileOrFolder(value) {
|
|
75
|
+
if (!value) return null;
|
|
76
|
+
const resolved = this.resolveValue(value);
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(resolved);
|
|
79
|
+
} catch {
|
|
80
|
+
return {
|
|
81
|
+
id: resolved,
|
|
82
|
+
isFolder: false,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
parseFileOrFolderList(values) {
|
|
87
|
+
if (!values) return [];
|
|
88
|
+
const list = Array.isArray(values)
|
|
89
|
+
? values
|
|
90
|
+
: [
|
|
91
|
+
values,
|
|
92
|
+
];
|
|
93
|
+
return list.map((v) => this.parseFileOrFolder(v)).filter(Boolean);
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
async run({ $ }) {
|
|
97
|
+
const selections = this.parseFileOrFolderList(this.fileOrFolderIds);
|
|
98
|
+
|
|
99
|
+
if (selections.length === 0) {
|
|
100
|
+
throw new Error("Please select at least one file or folder");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const siteId = this.resolveValue(this.siteId);
|
|
104
|
+
const driveId = this.resolveValue(this.driveId);
|
|
105
|
+
|
|
106
|
+
// Separate files and folders
|
|
107
|
+
const folders = selections.filter((s) => s.isFolder);
|
|
108
|
+
const files = selections.filter((s) => !s.isFolder);
|
|
109
|
+
|
|
110
|
+
// If only folders selected, return folder info
|
|
111
|
+
if (files.length === 0 && folders.length > 0) {
|
|
112
|
+
const folderNames = folders.map((f) => f.name).join(", ");
|
|
113
|
+
$.export("$summary", `Selected ${folders.length} folder(s): ${folderNames}. Set one as the Folder ID and refresh to browse its contents.`);
|
|
114
|
+
return {
|
|
115
|
+
type: "folders",
|
|
116
|
+
folders: folders.map((f) => ({
|
|
117
|
+
id: f.id,
|
|
118
|
+
name: f.name,
|
|
119
|
+
})),
|
|
120
|
+
message: "To browse a folder, set it as the folderId and reload props",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Fetch metadata for all selected files in parallel, handling individual failures
|
|
125
|
+
const settledResults = await Promise.allSettled(
|
|
126
|
+
files.map(async (selected) => {
|
|
127
|
+
const file = await this.sharepoint.getDriveItem({
|
|
128
|
+
$,
|
|
129
|
+
siteId,
|
|
130
|
+
driveId,
|
|
131
|
+
fileId: selected.id,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const downloadUrl = file["@microsoft.graph.downloadUrl"];
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
...file,
|
|
138
|
+
downloadUrl,
|
|
139
|
+
_meta: {
|
|
140
|
+
siteId,
|
|
141
|
+
driveId,
|
|
142
|
+
fileId: selected.id,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}),
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// Separate successful and failed results
|
|
149
|
+
const fileResults = [];
|
|
150
|
+
const errors = [];
|
|
151
|
+
|
|
152
|
+
settledResults.forEach((result, index) => {
|
|
153
|
+
if (result.status === "fulfilled") {
|
|
154
|
+
fileResults.push(result.value);
|
|
155
|
+
} else {
|
|
156
|
+
const selected = files[index];
|
|
157
|
+
const errorMessage = result.reason?.message || String(result.reason);
|
|
158
|
+
console.error(`Failed to fetch file ${selected.id} (${selected.name}): ${errorMessage}`);
|
|
159
|
+
errors.push({
|
|
160
|
+
fileId: selected.id,
|
|
161
|
+
fileName: selected.name,
|
|
162
|
+
error: errorMessage,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// If all files failed, throw an error
|
|
168
|
+
if (fileResults.length === 0 && errors.length > 0) {
|
|
169
|
+
throw new Error(`Failed to fetch all selected files: ${errors.map((e) => e.fileName).join(", ")}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// If single file, return it directly for backwards compatibility
|
|
173
|
+
if (fileResults.length === 1 && folders.length === 0 && errors.length === 0) {
|
|
174
|
+
$.export("$summary", `Selected file: ${fileResults[0].name}`);
|
|
175
|
+
return fileResults[0];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Multiple files: return as array
|
|
179
|
+
const fileNames = fileResults.map((f) => f.name).join(", ");
|
|
180
|
+
const summaryParts = [
|
|
181
|
+
`Selected ${fileResults.length} file(s): ${fileNames}`,
|
|
182
|
+
];
|
|
183
|
+
if (errors.length > 0) {
|
|
184
|
+
summaryParts.push(`Failed to fetch ${errors.length} file(s): ${errors.map((e) => e.fileName).join(", ")}`);
|
|
185
|
+
}
|
|
186
|
+
$.export("$summary", summaryParts.join(". "));
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
files: fileResults,
|
|
190
|
+
...(errors.length > 0 && {
|
|
191
|
+
errors,
|
|
192
|
+
}),
|
|
193
|
+
...(folders.length > 0 && {
|
|
194
|
+
folders: folders.map((f) => ({
|
|
195
|
+
id: f.id,
|
|
196
|
+
name: f.name,
|
|
197
|
+
})),
|
|
198
|
+
}),
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
};
|
|
@@ -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.
|
|
8
|
+
version: "0.0.7",
|
|
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.2",
|
|
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
|
+
"version": "0.5.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.1.
|
|
16
|
+
"@pipedream/platform": "^3.1.1"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/sharepoint.app.mjs
CHANGED
|
@@ -148,13 +148,52 @@ 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
|
+
// Handle both raw values and __lv wrapped values
|
|
161
|
+
const resolvedSiteId = this.resolveWrappedValue(siteId);
|
|
162
|
+
const resolvedDriveId = this.resolveWrappedValue(driveId);
|
|
163
|
+
|
|
164
|
+
if (!resolvedSiteId || !resolvedDriveId) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const response = query
|
|
169
|
+
? await this.searchDriveItems({
|
|
170
|
+
siteId: resolvedSiteId,
|
|
171
|
+
query,
|
|
172
|
+
params: {
|
|
173
|
+
select: "folder,name,id",
|
|
174
|
+
},
|
|
175
|
+
})
|
|
176
|
+
: await this.listDriveItems({
|
|
177
|
+
siteId: resolvedSiteId,
|
|
178
|
+
driveId: resolvedDriveId,
|
|
179
|
+
});
|
|
180
|
+
const values = response.value.filter(({ folder }) => folder);
|
|
181
|
+
return values
|
|
182
|
+
.map(({
|
|
183
|
+
name, id,
|
|
184
|
+
}) => ({
|
|
185
|
+
label: name,
|
|
186
|
+
value: id,
|
|
187
|
+
}));
|
|
188
|
+
},
|
|
189
|
+
},
|
|
151
190
|
fileId: {
|
|
152
191
|
type: "string",
|
|
153
192
|
label: "File ID",
|
|
154
193
|
description: "The file to download. You can either search for the file here or provide a custom *File ID*.",
|
|
155
194
|
useQuery: true,
|
|
156
195
|
async options({
|
|
157
|
-
query, siteId, driveId,
|
|
196
|
+
query, siteId, driveId, excludeFolders = true,
|
|
158
197
|
}) {
|
|
159
198
|
const response = query
|
|
160
199
|
? await this.searchDriveItems({
|
|
@@ -168,7 +207,9 @@ export default {
|
|
|
168
207
|
siteId,
|
|
169
208
|
driveId,
|
|
170
209
|
});
|
|
171
|
-
const values =
|
|
210
|
+
const values = excludeFolders
|
|
211
|
+
? response.value.filter(({ folder }) => !folder)
|
|
212
|
+
: response.value;
|
|
172
213
|
return values
|
|
173
214
|
.map(({
|
|
174
215
|
name, id,
|
|
@@ -178,24 +219,115 @@ export default {
|
|
|
178
219
|
}));
|
|
179
220
|
},
|
|
180
221
|
},
|
|
222
|
+
excelFileId: {
|
|
223
|
+
type: "string",
|
|
224
|
+
label: "Spreadsheet",
|
|
225
|
+
description: "**Search for the file by name.** Only xlsx files are supported.",
|
|
226
|
+
useQuery: true,
|
|
227
|
+
async options({
|
|
228
|
+
siteId, query,
|
|
229
|
+
}) {
|
|
230
|
+
const response = await this.searchDriveItems({
|
|
231
|
+
siteId,
|
|
232
|
+
query,
|
|
233
|
+
params: {
|
|
234
|
+
select: "name,id",
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
return response.value.filter(({ name }) => name.endsWith(".xlsx"))
|
|
238
|
+
.map(({
|
|
239
|
+
name, id,
|
|
240
|
+
}) => ({
|
|
241
|
+
label: name,
|
|
242
|
+
value: id,
|
|
243
|
+
}));
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
tableName: {
|
|
247
|
+
type: "string",
|
|
248
|
+
label: "Table Name",
|
|
249
|
+
description: "This is set in the **Table Design** tab of the ribbon",
|
|
250
|
+
async options({
|
|
251
|
+
siteId, itemId,
|
|
252
|
+
}) {
|
|
253
|
+
const response = await this.listExcelTables({
|
|
254
|
+
siteId,
|
|
255
|
+
itemId,
|
|
256
|
+
params: {
|
|
257
|
+
select: "name",
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
return response.value.map(({ name }) => name);
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
excludeFolders: {
|
|
264
|
+
type: "boolean",
|
|
265
|
+
label: "Exclude Folders?",
|
|
266
|
+
description: "Set to `true` to return only files in the response. Defaults to `false`",
|
|
267
|
+
optional: true,
|
|
268
|
+
},
|
|
269
|
+
fileOrFolderId: {
|
|
270
|
+
type: "string",
|
|
271
|
+
label: "File or Folder",
|
|
272
|
+
description: "Select a file or folder to browse",
|
|
273
|
+
async options({
|
|
274
|
+
siteId, driveId, folderId,
|
|
275
|
+
}) {
|
|
276
|
+
// Handle both raw values and __lv wrapped values
|
|
277
|
+
const resolvedSiteId = this.resolveWrappedValue(siteId);
|
|
278
|
+
const resolvedDriveId = this.resolveWrappedValue(driveId);
|
|
279
|
+
const resolvedFolderId = this.resolveWrappedValue(folderId);
|
|
280
|
+
|
|
281
|
+
if (!resolvedSiteId || !resolvedDriveId) {
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
284
|
+
const response = resolvedFolderId
|
|
285
|
+
? await this.listDriveItemsInFolder({
|
|
286
|
+
driveId: resolvedDriveId,
|
|
287
|
+
folderId: resolvedFolderId,
|
|
288
|
+
})
|
|
289
|
+
: await this.listDriveItems({
|
|
290
|
+
siteId: resolvedSiteId,
|
|
291
|
+
driveId: resolvedDriveId,
|
|
292
|
+
});
|
|
293
|
+
return response.value?.map(({
|
|
294
|
+
id, name, folder, size,
|
|
295
|
+
}) => ({
|
|
296
|
+
value: JSON.stringify({
|
|
297
|
+
id,
|
|
298
|
+
name,
|
|
299
|
+
isFolder: !!folder,
|
|
300
|
+
size,
|
|
301
|
+
}),
|
|
302
|
+
label: folder
|
|
303
|
+
? `📁 ${name}`
|
|
304
|
+
: `📄 ${name}`,
|
|
305
|
+
})) || [];
|
|
306
|
+
},
|
|
307
|
+
},
|
|
181
308
|
},
|
|
182
309
|
methods: {
|
|
310
|
+
resolveWrappedValue(value) {
|
|
311
|
+
return value?.__lv?.value || value;
|
|
312
|
+
},
|
|
183
313
|
_baseUrl() {
|
|
184
314
|
return "https://graph.microsoft.com/v1.0";
|
|
185
315
|
},
|
|
186
|
-
_headers() {
|
|
316
|
+
_headers(headers) {
|
|
187
317
|
return {
|
|
188
318
|
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
|
|
319
|
+
...headers,
|
|
189
320
|
};
|
|
190
321
|
},
|
|
191
322
|
_makeRequest({
|
|
192
323
|
$ = this,
|
|
193
324
|
path,
|
|
325
|
+
headers,
|
|
194
326
|
...args
|
|
195
327
|
}) {
|
|
196
328
|
return axios($, {
|
|
197
329
|
url: `${this._baseUrl()}${path}`,
|
|
198
|
-
headers: this._headers(),
|
|
330
|
+
headers: this._headers(headers),
|
|
199
331
|
...args,
|
|
200
332
|
});
|
|
201
333
|
},
|
|
@@ -251,6 +383,83 @@ export default {
|
|
|
251
383
|
...args,
|
|
252
384
|
});
|
|
253
385
|
},
|
|
386
|
+
listDriveItemsInFolder({
|
|
387
|
+
driveId, folderId, ...args
|
|
388
|
+
}) {
|
|
389
|
+
return this._makeRequest({
|
|
390
|
+
path: `/drives/${driveId}/items/${folderId}/children`,
|
|
391
|
+
...args,
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
createDriveItem({
|
|
395
|
+
siteId, driveId, ...args
|
|
396
|
+
}) {
|
|
397
|
+
return this._makeRequest({
|
|
398
|
+
path: `/sites/${siteId}/drives/${driveId}/items/root/children`,
|
|
399
|
+
method: "POST",
|
|
400
|
+
...args,
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
createDriveItemInFolder({
|
|
404
|
+
siteId, folderId, ...args
|
|
405
|
+
}) {
|
|
406
|
+
return this._makeRequest({
|
|
407
|
+
path: `/sites/${siteId}/drive/items/${folderId}/children`,
|
|
408
|
+
method: "POST",
|
|
409
|
+
...args,
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
createLink({
|
|
413
|
+
siteId, fileId, ...args
|
|
414
|
+
}) {
|
|
415
|
+
return this._makeRequest({
|
|
416
|
+
path: `/sites/${siteId}/drive/items/${fileId}/createLink`,
|
|
417
|
+
method: "POST",
|
|
418
|
+
...args,
|
|
419
|
+
});
|
|
420
|
+
},
|
|
421
|
+
listExcelTables({
|
|
422
|
+
siteId, itemId, ...args
|
|
423
|
+
}) {
|
|
424
|
+
return this._makeRequest({
|
|
425
|
+
path: `/sites/${siteId}/drive/items/${itemId}/workbook/tables`,
|
|
426
|
+
...args,
|
|
427
|
+
});
|
|
428
|
+
},
|
|
429
|
+
getExcelTable({
|
|
430
|
+
siteId, itemId, tableName, ...args
|
|
431
|
+
}) {
|
|
432
|
+
return this._makeRequest({
|
|
433
|
+
path: `/sites/${siteId}/drive/items/${itemId}/workbook/tables/${tableName}/range`,
|
|
434
|
+
...args,
|
|
435
|
+
});
|
|
436
|
+
},
|
|
437
|
+
uploadFile({
|
|
438
|
+
siteId, driveId, uploadFolderId, name, ...args
|
|
439
|
+
}) {
|
|
440
|
+
return this._makeRequest({
|
|
441
|
+
path: uploadFolderId
|
|
442
|
+
? `/sites/${siteId}/drives/${driveId}/items/${uploadFolderId}:/${encodeURI(name)}:/content`
|
|
443
|
+
: `/sites/${siteId}/drives/${driveId}/root:/${encodeURI(name)}:/content`,
|
|
444
|
+
method: "PUT",
|
|
445
|
+
headers: {
|
|
446
|
+
"Content-Type": "application/octet-stream",
|
|
447
|
+
},
|
|
448
|
+
...args,
|
|
449
|
+
});
|
|
450
|
+
},
|
|
451
|
+
getDriveItem({
|
|
452
|
+
siteId, driveId, fileId, ...args
|
|
453
|
+
}) {
|
|
454
|
+
// Use driveId if provided, otherwise fall back to site's default drive
|
|
455
|
+
const path = driveId
|
|
456
|
+
? `/drives/${driveId}/items/${fileId}`
|
|
457
|
+
: `/sites/${siteId}/drive/items/${fileId}`;
|
|
458
|
+
return this._makeRequest({
|
|
459
|
+
path,
|
|
460
|
+
...args,
|
|
461
|
+
});
|
|
462
|
+
},
|
|
254
463
|
searchDriveItems({
|
|
255
464
|
siteId, query, ...args
|
|
256
465
|
}) {
|
|
@@ -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.
|
|
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.2",
|
|
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.2",
|
|
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.
|
|
7
|
+
description: "Emit new event when a new list item is created in Microsoft Sharepoint.",
|
|
8
|
+
version: "0.0.7",
|
|
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.
|
|
7
|
+
description: "Emit new event when a list item is updated in Microsoft Sharepoint.",
|
|
8
|
+
version: "0.0.7",
|
|
9
9
|
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
11
11
|
props: {
|