@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.
@@ -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.1",
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.1",
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
+ };
@@ -0,0 +1,10 @@
1
+ export default {
2
+ cleanObject(o) {
3
+ for (var k in o || {}) {
4
+ if (typeof o[k] === "undefined") {
5
+ delete o[k];
6
+ }
7
+ }
8
+ return o;
9
+ },
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/sharepoint",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Pipedream Microsoft Sharepoint Online Components",
5
5
  "main": "sharepoint.app.mjs",
6
6
  "keywords": [
@@ -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
  }) {
@@ -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.1",
8
+ version: "0.0.2",
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.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {