@pipedream/sharepoint 0.5.0 → 0.5.1

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.
@@ -1,11 +1,11 @@
1
- import sharepoint from "../../sharepoint.app.mjs";
2
1
  import constants from "../../common/constants.mjs";
2
+ import sharepoint from "../../sharepoint.app.mjs";
3
3
 
4
4
  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.2",
8
+ version: "0.0.3",
9
9
  type: "action",
10
10
  annotations: {
11
11
  destructiveHint: false,
@@ -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.7",
8
+ version: "0.0.8",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -60,7 +60,10 @@ export default {
60
60
 
61
61
  const rawcontent = response.toString("base64");
62
62
  const buffer = Buffer.from(rawcontent, "base64");
63
- const downloadedFilepath = `/tmp/${this.filename}`;
63
+ // Since the filepath is not returned as one of the standard keys (filePath
64
+ // or path), save the file to STASH_DIR, if defined, so it is synced at the
65
+ // end of execution.
66
+ const downloadedFilepath = `${process.env.STASH_DIR || "/tmp"}/${this.filename}`;
64
67
  fs.writeFileSync(downloadedFilepath, buffer);
65
68
 
66
69
  return {
@@ -1,10 +1,12 @@
1
+ import constants from "../../common/constants.mjs";
2
+ import utils from "../../common/utils.mjs";
1
3
  import sharepoint from "../../sharepoint.app.mjs";
2
4
 
3
5
  export default {
4
6
  key: "sharepoint-find-file-by-name",
5
7
  name: "Find File by Name",
6
8
  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",
9
+ version: "0.1.0",
8
10
  type: "action",
9
11
  annotations: {
10
12
  destructiveHint: false,
@@ -24,29 +26,54 @@ export default {
24
26
  label: "File Name",
25
27
  description: "The name of the file or folder to search for",
26
28
  },
27
- excludeFolders: {
28
- propDefinition: [
29
- sharepoint,
30
- "excludeFolders",
31
- ],
29
+ returnContentType: {
30
+ type: "string",
31
+ label: "Return Content Type",
32
+ description: "The content type to return",
33
+ options: constants.RETURN_CONTENT_TYPE_OPTIONS,
34
+ default: "all",
35
+ },
36
+ select: {
37
+ type: "string[]",
38
+ label: "Select",
39
+ description: "Use Select to choose only the properties your app needs, as this can lead to performance improvements. E.g. `[\"name\", \"id\", \"createdDateTime\"]`",
40
+ optional: true,
32
41
  },
33
42
  },
34
43
  async run({ $ }) {
35
- const response = await this.sharepoint.searchDriveItems({
44
+ const params = {};
45
+
46
+ if (this.select) {
47
+ params.select = utils.parseObject(this.select)?.join();
48
+ }
49
+
50
+ let { value } = await this.sharepoint.searchDriveItems({
36
51
  $,
37
52
  siteId: this.siteId,
38
53
  query: this.name,
54
+ params,
39
55
  });
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);
56
+
57
+ if (this.returnContentType === "files") {
58
+ value = value.filter(({ file }) => file);
59
+ } else if (this.returnContentType === "folders") {
60
+ value = value.filter(({ folder }) => folder);
45
61
  }
46
62
 
47
- $.export("$summary", `Found ${values.length} matching file${values.length === 1
63
+ value = value.map((item) => {
64
+ return {
65
+ contentType: item.folder
66
+ ? "folder"
67
+ : "file",
68
+ ...item,
69
+ };
70
+ });
71
+
72
+ $.export("$summary", `Found ${value.length} matching ${this.returnContentType === "files"
73
+ ? "file"
74
+ : "folder"}${value.length === 1
48
75
  ? ""
49
76
  : "s"}`);
50
- return values;
77
+ return value;
51
78
  },
52
79
  };
@@ -1,11 +1,11 @@
1
- import sharepoint from "../../sharepoint.app.mjs";
2
1
  import utils from "../../common/utils.mjs";
2
+ import sharepoint from "../../sharepoint.app.mjs";
3
3
 
4
4
  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.7",
8
+ version: "0.0.8",
9
9
  annotations: {
10
10
  destructiveHint: true,
11
11
  openWorldHint: true,
@@ -24,7 +24,23 @@ const SHARING_LINK_SCOPE_OPTIONS = [
24
24
  },
25
25
  ];
26
26
 
27
+ const RETURN_CONTENT_TYPE_OPTIONS = [
28
+ {
29
+ label: "Only Files",
30
+ value: "files",
31
+ },
32
+ {
33
+ label: "Only Folders",
34
+ value: "folders",
35
+ },
36
+ {
37
+ label: "Both Files and Folders",
38
+ value: "all",
39
+ },
40
+ ];
41
+
27
42
  export default {
28
43
  SHARING_LINK_TYPE_OPTIONS,
29
44
  SHARING_LINK_SCOPE_OPTIONS,
45
+ RETURN_CONTENT_TYPE_OPTIONS,
30
46
  };
package/common/utils.mjs CHANGED
@@ -7,4 +7,28 @@ export default {
7
7
  }
8
8
  return o;
9
9
  },
10
+ parseObject(obj) {
11
+ if (!obj) return undefined;
12
+
13
+ if (Array.isArray(obj)) {
14
+ return obj.map((item) => {
15
+ if (typeof item === "string") {
16
+ try {
17
+ return JSON.parse(item);
18
+ } catch (e) {
19
+ return item;
20
+ }
21
+ }
22
+ return item;
23
+ });
24
+ }
25
+ if (typeof obj === "string") {
26
+ try {
27
+ return JSON.parse(obj);
28
+ } catch (e) {
29
+ return obj;
30
+ }
31
+ }
32
+ return obj;
33
+ },
10
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/sharepoint",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Pipedream Microsoft Sharepoint Online Components",
5
5
  "main": "sharepoint.app.mjs",
6
6
  "keywords": [