@pipedream/sharepoint 0.4.0 → 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 +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/get-excel-table/get-excel-table.mjs +1 -1
- package/actions/get-file-by-id/get-file-by-id.mjs +1 -1
- package/actions/list-files-in-folder/list-files-in-folder.mjs +2 -2
- package/actions/select-files/select-files.mjs +201 -0
- package/actions/update-item/update-item.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +1 -1
- package/package.json +2 -2
- package/sharepoint.app.mjs +61 -7
- 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.2",
|
|
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.8",
|
|
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.2",
|
|
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.8",
|
|
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.7",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-find-file-by-name",
|
|
5
5
|
name: "Find File by Name",
|
|
6
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.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -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.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -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.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -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.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -49,7 +49,7 @@ export default {
|
|
|
49
49
|
const response = this.folderId
|
|
50
50
|
? await this.sharepoint.listDriveItemsInFolder({
|
|
51
51
|
$,
|
|
52
|
-
|
|
52
|
+
driveId: this.driveId,
|
|
53
53
|
folderId: this.folderId,
|
|
54
54
|
})
|
|
55
55
|
: await this.sharepoint.listDriveItems({
|
|
@@ -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,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.7",
|
|
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.2",
|
|
9
9
|
type: "action",
|
|
10
10
|
annotations: {
|
|
11
11
|
destructiveHint: false,
|
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
|
@@ -157,17 +157,25 @@ export default {
|
|
|
157
157
|
async options({
|
|
158
158
|
query, siteId, driveId,
|
|
159
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
|
+
|
|
160
168
|
const response = query
|
|
161
169
|
? await this.searchDriveItems({
|
|
162
|
-
siteId,
|
|
170
|
+
siteId: resolvedSiteId,
|
|
163
171
|
query,
|
|
164
172
|
params: {
|
|
165
173
|
select: "folder,name,id",
|
|
166
174
|
},
|
|
167
175
|
})
|
|
168
176
|
: await this.listDriveItems({
|
|
169
|
-
siteId,
|
|
170
|
-
driveId,
|
|
177
|
+
siteId: resolvedSiteId,
|
|
178
|
+
driveId: resolvedDriveId,
|
|
171
179
|
});
|
|
172
180
|
const values = response.value.filter(({ folder }) => folder);
|
|
173
181
|
return values
|
|
@@ -258,8 +266,50 @@ export default {
|
|
|
258
266
|
description: "Set to `true` to return only files in the response. Defaults to `false`",
|
|
259
267
|
optional: true,
|
|
260
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
|
+
},
|
|
261
308
|
},
|
|
262
309
|
methods: {
|
|
310
|
+
resolveWrappedValue(value) {
|
|
311
|
+
return value?.__lv?.value || value;
|
|
312
|
+
},
|
|
263
313
|
_baseUrl() {
|
|
264
314
|
return "https://graph.microsoft.com/v1.0";
|
|
265
315
|
},
|
|
@@ -334,10 +384,10 @@ export default {
|
|
|
334
384
|
});
|
|
335
385
|
},
|
|
336
386
|
listDriveItemsInFolder({
|
|
337
|
-
|
|
387
|
+
driveId, folderId, ...args
|
|
338
388
|
}) {
|
|
339
389
|
return this._makeRequest({
|
|
340
|
-
path: `/
|
|
390
|
+
path: `/drives/${driveId}/items/${folderId}/children`,
|
|
341
391
|
...args,
|
|
342
392
|
});
|
|
343
393
|
},
|
|
@@ -399,10 +449,14 @@ export default {
|
|
|
399
449
|
});
|
|
400
450
|
},
|
|
401
451
|
getDriveItem({
|
|
402
|
-
siteId, fileId, ...args
|
|
452
|
+
siteId, driveId, fileId, ...args
|
|
403
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}`;
|
|
404
458
|
return this._makeRequest({
|
|
405
|
-
path
|
|
459
|
+
path,
|
|
406
460
|
...args,
|
|
407
461
|
});
|
|
408
462
|
},
|