@pipedream/sharepoint 0.1.0 → 0.2.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-item/create-item.mjs +1 -1
- package/actions/create-list/create-list.mjs +1 -1
- package/actions/update-item/update-item.mjs +80 -0
- package/common/utils.mjs +10 -0
- package/package.json +1 -1
- package/sharepoint.app.mjs +39 -0
- 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-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.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
sharepoint,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "sharepoint-create-list",
|
|
5
5
|
name: "Create List",
|
|
6
6
|
description: "Create a new list in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/list-create?view=graph-rest-1.0&tabs=http)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
sharepoint,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import sharepoint from "../../sharepoint.app.mjs";
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "sharepoint-update-item",
|
|
6
|
+
name: "Update Item",
|
|
7
|
+
description: "Updates an existing item in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/listitem-update?view=graph-rest-1.0&tabs=http)",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
sharepoint,
|
|
12
|
+
siteId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
sharepoint,
|
|
15
|
+
"siteId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
listId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
sharepoint,
|
|
21
|
+
"listId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
siteId: c.siteId,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
reloadProps: true,
|
|
27
|
+
},
|
|
28
|
+
itemId: {
|
|
29
|
+
propDefinition: [
|
|
30
|
+
sharepoint,
|
|
31
|
+
"itemId",
|
|
32
|
+
(c) => ({
|
|
33
|
+
siteId: c.siteId,
|
|
34
|
+
listId: c.listId,
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
async additionalProps() {
|
|
40
|
+
const props = {};
|
|
41
|
+
const { value: columns } = await this.sharepoint.listColumns({
|
|
42
|
+
siteId: this.siteId,
|
|
43
|
+
listId: this.listId,
|
|
44
|
+
});
|
|
45
|
+
const editableColumns = columns?.filter(({ readOnly }) => !readOnly) || [];
|
|
46
|
+
for (const column of editableColumns) {
|
|
47
|
+
props[column.name] = {
|
|
48
|
+
type: "string",
|
|
49
|
+
label: column.name,
|
|
50
|
+
optional: true,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return props;
|
|
54
|
+
},
|
|
55
|
+
async run({ $ }) {
|
|
56
|
+
const {
|
|
57
|
+
sharepoint,
|
|
58
|
+
siteId,
|
|
59
|
+
listId,
|
|
60
|
+
itemId,
|
|
61
|
+
...otherProps
|
|
62
|
+
} = this;
|
|
63
|
+
|
|
64
|
+
const data = utils.cleanObject(otherProps);
|
|
65
|
+
|
|
66
|
+
const response = await sharepoint.updateItem({
|
|
67
|
+
siteId,
|
|
68
|
+
listId,
|
|
69
|
+
itemId,
|
|
70
|
+
data,
|
|
71
|
+
$,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (response?.id) {
|
|
75
|
+
$.export("$summary", `Successfully updated item with ID ${response.id}.`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return response;
|
|
79
|
+
},
|
|
80
|
+
};
|
package/common/utils.mjs
ADDED
package/package.json
CHANGED
package/sharepoint.app.mjs
CHANGED
|
@@ -87,6 +87,36 @@ export default {
|
|
|
87
87
|
};
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
|
+
itemId: {
|
|
91
|
+
type: "string",
|
|
92
|
+
label: "Item",
|
|
93
|
+
description: "Identifier of an item",
|
|
94
|
+
async options({
|
|
95
|
+
prevContext, siteId, listId,
|
|
96
|
+
}) {
|
|
97
|
+
if (!siteId) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const args = {
|
|
101
|
+
siteId,
|
|
102
|
+
listId,
|
|
103
|
+
};
|
|
104
|
+
if (prevContext?.nextLink) {
|
|
105
|
+
args.url = prevContext.nextLink;
|
|
106
|
+
}
|
|
107
|
+
const response = await this.listItems(args);
|
|
108
|
+
const options = response.value?.map(({ id: value }) => ({
|
|
109
|
+
value,
|
|
110
|
+
label: `Item ${value}`,
|
|
111
|
+
})) || [];
|
|
112
|
+
return {
|
|
113
|
+
options,
|
|
114
|
+
context: {
|
|
115
|
+
nextLink: response["@odata.nextLink"],
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
},
|
|
90
120
|
},
|
|
91
121
|
methods: {
|
|
92
122
|
_baseUrl() {
|
|
@@ -156,6 +186,15 @@ export default {
|
|
|
156
186
|
...args,
|
|
157
187
|
});
|
|
158
188
|
},
|
|
189
|
+
updateItem({
|
|
190
|
+
siteId, listId, itemId, ...args
|
|
191
|
+
}) {
|
|
192
|
+
return this._makeRequest({
|
|
193
|
+
path: `/sites/${siteId}/lists/${listId}/items/${itemId}/fields`,
|
|
194
|
+
method: "PATCH",
|
|
195
|
+
...args,
|
|
196
|
+
});
|
|
197
|
+
},
|
|
159
198
|
async *paginate({
|
|
160
199
|
fn, args,
|
|
161
200
|
}) {
|