@pipedream/dropbox 0.3.14 → 0.3.16

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,12 +1,10 @@
1
1
  import dropbox from "../../dropbox.app.mjs";
2
- import common from "../common/common.mjs";
3
2
 
4
3
  export default {
5
- ...common,
6
4
  name: "Create a Text File",
7
5
  description: "Creates a brand new text file from plain text content you specify. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
8
6
  key: "dropbox-create-a-text-file",
9
- version: "0.0.6",
7
+ version: "0.0.7",
10
8
  type: "action",
11
9
  props: {
12
10
  dropbox,
@@ -37,7 +35,7 @@ export default {
37
35
 
38
36
  const res = await this.dropbox.uploadFile({
39
37
  contents: Buffer.from(content),
40
- path: this.getNormalizedPath(path, true) + name,
38
+ path: this.dropbox.getNormalizedPath(path, true) + name,
41
39
  autorename: true,
42
40
  });
43
41
 
@@ -1,12 +1,10 @@
1
1
  import dropbox from "../../dropbox.app.mjs";
2
- import common from "../common/common.mjs";
3
2
 
4
3
  export default {
5
- ...common,
6
4
  name: "Create folder",
7
5
  description: "Create a folder. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)",
8
6
  key: "dropbox-create-folder",
9
- version: "0.0.6",
7
+ version: "0.0.7",
10
8
  type: "action",
11
9
  props: {
12
10
  dropbox,
@@ -39,7 +37,7 @@ export default {
39
37
 
40
38
  const res = await this.dropbox.createFolder({
41
39
  autorename,
42
- path: this.getNormalizedPath(path, true) + name,
40
+ path: this.dropbox.getNormalizedPath(path, true) + name,
43
41
  });
44
42
  $.export("$summary", `Folder successfully created: \`${res.result.metadata.name}\``);
45
43
  return res;
@@ -1,11 +1,10 @@
1
1
  import dropbox from "../../dropbox.app.mjs";
2
- import common from "../common/common.mjs";
3
2
 
4
3
  export default {
5
4
  name: "Create or Append to a Text File",
6
5
  description: "Adds a new line to an existing text file, or creates a file if it doesn't exist. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
7
6
  key: "dropbox-create-or-append-to-a-text-file",
8
- version: "0.0.6",
7
+ version: "0.0.7",
9
8
  type: "action",
10
9
  props: {
11
10
  dropbox,
@@ -29,7 +28,6 @@ export default {
29
28
  },
30
29
  },
31
30
  methods: {
32
- ...common.methods,
33
31
  async getFileInfo(path, content) {
34
32
  let file;
35
33
  try {
@@ -67,7 +65,7 @@ export default {
67
65
  path,
68
66
  } = this;
69
67
 
70
- const normalizedPath = this.getNormalizedPath(path, true) + name;
68
+ const normalizedPath = this.dropbox.getNormalizedPath(path, true) + name;
71
69
  const {
72
70
  fileExists,
73
71
  content: normalizedContent,
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Create/Update a Share Link",
6
6
  description: "Creates or updates a public share link to the file or folder (It allows to share the file or folder with anyone). [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingCreateSharedLinkWithSettings__anchor)",
7
7
  key: "dropbox-create-update-share-link",
8
- version: "0.0.6",
8
+ version: "0.0.7",
9
9
  type: "action",
10
10
  props: {
11
11
  dropbox,
@@ -13,6 +13,9 @@ export default {
13
13
  propDefinition: [
14
14
  dropbox,
15
15
  "pathFileFolder",
16
+ () => ({
17
+ omitRootFolder: true,
18
+ }),
16
19
  ],
17
20
  description: "The path to be shared by the shared link.",
18
21
  },
@@ -28,6 +31,11 @@ export default {
28
31
  description: "If `require_password` is `true`, this is needed to specify the password to access the link.",
29
32
  optional: true,
30
33
  },
34
+ allowDownload: {
35
+ type: "boolean",
36
+ label: "Allow downloads",
37
+ description: "Boolean flag to allow or not allow capabilities for shared links.",
38
+ },
31
39
  expires: {
32
40
  type: "string",
33
41
  label: "Expires",
@@ -48,12 +56,6 @@ export default {
48
56
  optional: true,
49
57
  options: consts.CREATE_SHARED_LINK_ACCESS_OPTIONS,
50
58
  },
51
- allowDownload: {
52
- type: "boolean",
53
- label: "Allow downloads",
54
- description: "Boolean flag to allow or not allow capabilities for shared links.",
55
- optional: true,
56
- },
57
59
  },
58
60
  async run({ $ }) {
59
61
  const {
@@ -73,7 +75,7 @@ export default {
73
75
  }
74
76
 
75
77
  const res = await this.dropbox.createSharedLink({
76
- path: path?.value || path,
78
+ path: this.dropbox.getPath(path),
77
79
  settings: {
78
80
  require_password: requirePassword,
79
81
  link_password: linkPassword,
@@ -4,7 +4,7 @@ export default {
4
4
  name: "Delete a File/Folder",
5
5
  description: "Permanently removes a file/folder from the server. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDeleteV2__anchor)",
6
6
  key: "dropbox-delete-file-folder",
7
- version: "0.0.6",
7
+ version: "0.0.7",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -12,6 +12,9 @@ export default {
12
12
  propDefinition: [
13
13
  dropbox,
14
14
  "pathFileFolder",
15
+ () => ({
16
+ omitRootFolder: true,
17
+ }),
15
18
  ],
16
19
  description: "Path in the user's Dropbox to delete.",
17
20
  },
@@ -19,7 +22,7 @@ export default {
19
22
  async run({ $ }) {
20
23
  const { path } = this;
21
24
  const res = await this.dropbox.deleteFileFolder({
22
- path: path?.value || path,
25
+ path: this.dropbox.getPath(path),
23
26
  });
24
27
  $.export("$summary", `"${path?.label || path}" successfully deleted`);
25
28
  return res;
@@ -1,14 +1,12 @@
1
1
  import dropbox from "../../dropbox.app.mjs";
2
- import common from "../common/common.mjs";
3
2
  import fs from "fs";
4
3
  import { file } from "tmp-promise";
5
4
 
6
5
  export default {
7
- ...common,
8
6
  name: "Download File to TMP",
9
7
  description: "Download a specific file to the temporary directory. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor).",
10
8
  key: "dropbox-download-file-to-tmp",
11
- version: "0.0.2",
9
+ version: "0.0.3",
12
10
  type: "action",
13
11
  props: {
14
12
  dropbox,
@@ -28,7 +26,7 @@ export default {
28
26
  },
29
27
  async run({ $ }) {
30
28
  const { result } = await this.dropbox.downloadFile({
31
- path: this.getNormalizedPath(this.path, false),
29
+ path: this.dropbox.getNormalizedPath(this.path, false),
32
30
  });
33
31
 
34
32
  const {
@@ -4,7 +4,7 @@ export default {
4
4
  name: "List All Files/Subfolders in a Folder",
5
5
  description: "Retrieves a list of files or subfolders in a specified folder [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor)",
6
6
  key: "dropbox-list-file-folders-in-a-folder",
7
- version: "0.0.6",
7
+ version: "0.0.7",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -63,7 +63,7 @@ export default {
63
63
  includeNonDownloadableFiles,
64
64
  } = this;
65
65
  const res = await this.dropbox.listFilesFolders({
66
- path: path?.value || path,
66
+ path: this.dropbox.getPath(path),
67
67
  recursive,
68
68
  include_deleted: includeDeleted,
69
69
  include_has_explicit_shared_members: includeHasExplicitSharedMembers,
@@ -5,7 +5,7 @@ export default {
5
5
  name: "List File Revisions",
6
6
  description: "Retrieves a list of file revisions needed to recover previous content. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListRevisions__anchor)",
7
7
  key: "dropbox-list-file-revisions",
8
- version: "0.0.6",
8
+ version: "0.0.7",
9
9
  type: "action",
10
10
  props: {
11
11
  dropbox,
@@ -39,7 +39,7 @@ export default {
39
39
  limit,
40
40
  } = this;
41
41
  const res = await this.dropbox.listFileRevisions({
42
- path: path?.value || path,
42
+ path: this.dropbox.getPath(path),
43
43
  mode: mode
44
44
  ? {
45
45
  ".tag": mode,
@@ -4,7 +4,7 @@ export default {
4
4
  name: "Move a File/Folder",
5
5
  description: "Moves a file or folder to a different location in the user's Dropbox [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
6
6
  key: "dropbox-move-file-folder",
7
- version: "0.0.6",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -12,6 +12,9 @@ export default {
12
12
  propDefinition: [
13
13
  dropbox,
14
14
  "pathFileFolder",
15
+ () => ({
16
+ omitRootFolder: true,
17
+ }),
15
18
  ],
16
19
  label: "Path from",
17
20
  description: "The file/folder that you want to move.",
@@ -45,18 +48,16 @@ export default {
45
48
  pathTo,
46
49
  } = this;
47
50
 
48
- let normalizedPathTo = pathTo?.value || pathTo;
49
- const normalizedPathFrom = pathFrom?.value || pathFrom;
51
+ let normalizedPathTo = this.dropbox.getPath(pathTo);
52
+ const normalizedPathFrom = this.dropbox.getPath(pathFrom);
50
53
 
51
- // If path is a file, we need to move it as a file
52
- if (pathFrom?.type == "file" && pathFrom.value) {
53
- const splited = normalizedPathFrom.split("/");
54
- const fileName = splited[splited.length - 1];
55
- normalizedPathTo = `${pathTo?.value || pathTo}/${fileName}`;
56
- }
54
+ // Add file/folder name to end of pathTo
55
+ const splited = normalizedPathFrom.split("/");
56
+ const fileName = splited[splited.length - 1];
57
+ normalizedPathTo += `/${fileName}`;
57
58
 
58
59
  const res = await this.dropbox.filesMove({
59
- from_path: pathFrom.value,
60
+ from_path: normalizedPathFrom,
60
61
  to_path: normalizedPathTo,
61
62
  autorename,
62
63
  allow_ownership_transfer: allowOwnershipTransfer,
@@ -4,7 +4,7 @@ export default {
4
4
  name: "Rename a File/Folder",
5
5
  description: "Renames a file or folder in the user's Dropbox [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
6
6
  key: "dropbox-rename-file-folder",
7
- version: "0.0.6",
7
+ version: "0.0.7",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -12,6 +12,9 @@ export default {
12
12
  propDefinition: [
13
13
  dropbox,
14
14
  "pathFileFolder",
15
+ () => ({
16
+ omitRootFolder: true,
17
+ }),
15
18
  ],
16
19
  label: "Path From",
17
20
  description: "The file that you want to rename.",
@@ -42,7 +45,7 @@ export default {
42
45
  allowOwnershipTransfer,
43
46
  } = this;
44
47
 
45
- const normalizedPathFrom = pathFrom?.value || pathFrom;
48
+ const normalizedPathFrom = this.dropbox.getPath(pathFrom);
46
49
  const splitedPath = normalizedPathFrom.split("/");
47
50
  splitedPath[splitedPath.length - 1] = newName;
48
51
  const res = await this.dropbox.filesMove({
@@ -4,7 +4,7 @@ export default {
4
4
  name: "Restore a File",
5
5
  description: "Restores a previous file version. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesRestore__anchor)",
6
6
  key: "dropbox-restore-a-file",
7
- version: "0.0.6",
7
+ version: "0.0.7",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -12,6 +12,9 @@ export default {
12
12
  propDefinition: [
13
13
  dropbox,
14
14
  "pathFile",
15
+ () => ({
16
+ omitRootFolder: true,
17
+ }),
15
18
  ],
16
19
  description: "The path to save the restored file.",
17
20
  },
@@ -33,7 +36,7 @@ export default {
33
36
  } = this;
34
37
 
35
38
  const res = await this.dropbox.restoreFile({
36
- path: path?.value || path,
39
+ path: this.dropbox.getPath(path),
37
40
  rev: rev?.value || rev,
38
41
  });
39
42
  $.export("$summary", `"${path?.label || path}" successfully restored to "${rev?.label || rev}" revision`);
@@ -1,13 +1,12 @@
1
1
  import dropbox from "../../dropbox.app.mjs";
2
2
  import isNil from "lodash/isNil.js";
3
- import get from "lodash/get.js";
4
3
  import consts from "../../common/consts.mjs";
5
4
 
6
5
  export default {
7
6
  name: "Search files and folders",
8
7
  description: "Searches for files and folders by name. [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesSearchV2__anchor)",
9
8
  key: "dropbox-search-files-folders",
10
- version: "0.0.6",
9
+ version: "0.0.7",
11
10
  type: "action",
12
11
  props: {
13
12
  dropbox,
@@ -91,7 +90,7 @@ export default {
91
90
  include_highlights: includeHighlights,
92
91
  },
93
92
  options: {
94
- path: get(path, "value", path) || "",
93
+ path: this.dropbox.getPath(path),
95
94
  order_by: orderBy
96
95
  ? {
97
96
  ".tag": orderBy,
@@ -2,14 +2,12 @@ import dropbox from "../../dropbox.app.mjs";
2
2
  import consts from "../../common/consts.mjs";
3
3
  import fs from "fs";
4
4
  import got from "got@12.4.1";
5
- import common from "../common/common.mjs";
6
5
 
7
6
  export default {
8
- ...common,
9
7
  name: "Upload a File",
10
8
  description: "Uploads a file to a selected folder. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
11
9
  key: "dropbox-upload-file",
12
- version: "0.0.8",
10
+ version: "0.0.9",
13
11
  type: "action",
14
12
  props: {
15
13
  dropbox,
@@ -80,7 +78,7 @@ export default {
80
78
  ? await got.stream(fileUrl)
81
79
  : fs.createReadStream(filePath);
82
80
 
83
- let normalizedPath = this.getNormalizedPath(path, true);
81
+ let normalizedPath = this.dropbox.getNormalizedPath(path, true);
84
82
 
85
83
  const res = await this.dropbox.uploadFile({
86
84
  contents,
package/dropbox.app.mjs CHANGED
@@ -4,6 +4,7 @@ import get from "lodash/get.js";
4
4
  import config from "./common/config.mjs";
5
5
  import isString from "lodash/isString.js";
6
6
  import isEmpty from "lodash/isEmpty.js";
7
+ import isNil from "lodash/isNil.js";
7
8
 
8
9
  const Dropbox = dropbox.Dropbox;
9
10
 
@@ -21,6 +22,7 @@ export default {
21
22
  prevContext,
22
23
  query,
23
24
  returnSimpleString,
25
+ omitRootFolder,
24
26
  }) {
25
27
  if (prevContext?.reachedLastPage) {
26
28
  return [];
@@ -31,6 +33,7 @@ export default {
31
33
  {
32
34
  omitFiles: true,
33
35
  returnSimpleString,
36
+ omitRootFolder,
34
37
  },
35
38
  );
36
39
  },
@@ -45,6 +48,7 @@ export default {
45
48
  prevContext,
46
49
  query,
47
50
  returnSimpleString,
51
+ omitRootFolder,
48
52
  }) {
49
53
  if (prevContext?.reachedLastPage) {
50
54
  return [];
@@ -55,6 +59,7 @@ export default {
55
59
  {
56
60
  omitFolders: true,
57
61
  returnSimpleString,
62
+ omitRootFolder,
58
63
  },
59
64
  );
60
65
  },
@@ -69,6 +74,7 @@ export default {
69
74
  prevContext,
70
75
  query,
71
76
  returnSimpleString,
77
+ omitRootFolder,
72
78
  }) {
73
79
  if (prevContext?.reachedLastPage) {
74
80
  return [];
@@ -78,6 +84,7 @@ export default {
78
84
  prevContext?.cursor,
79
85
  {
80
86
  returnSimpleString,
87
+ omitRootFolder,
81
88
  },
82
89
  );
83
90
  },
@@ -111,6 +118,25 @@ export default {
111
118
  },
112
119
  },
113
120
  methods: {
121
+ getPath(path) {
122
+ return Object.prototype.hasOwnProperty.call(path, "value")
123
+ ? path.value
124
+ : path;
125
+ },
126
+ getNormalizedPath(path, appendFinalBar) {
127
+ let normalizedPath = this.getPath(path);
128
+
129
+ // Check for empties path
130
+ if (isNil(normalizedPath) || isEmpty(normalizedPath)) {
131
+ normalizedPath = "/";
132
+ }
133
+
134
+ if (appendFinalBar && normalizedPath[normalizedPath.length - 1] !== "/") {
135
+ normalizedPath += "/";
136
+ }
137
+
138
+ return normalizedPath;
139
+ },
114
140
  async sdk() {
115
141
  const baseClientOpts = {
116
142
  accessToken: this.$auth.oauth_access_token,
@@ -171,6 +197,7 @@ export default {
171
197
  const {
172
198
  omitFolders,
173
199
  omitFiles,
200
+ omitRootFolder,
174
201
  } = opts;
175
202
 
176
203
  let data = [];
@@ -237,7 +264,20 @@ export default {
237
264
  data = data.filter((item) => item.type !== "folder");
238
265
  }
239
266
 
240
- data = data.map((item) => (item.path));
267
+ data = data.map((item) => ({
268
+ label: item.path,
269
+ value: item.path,
270
+ }));
271
+
272
+ if (path === "" && !omitFolders && !omitRootFolder) {
273
+ data = [
274
+ {
275
+ label: "Root Folder",
276
+ value: "",
277
+ },
278
+ ...data,
279
+ ];
280
+ }
241
281
 
242
282
  data.sort((a, b) => {
243
283
  return a > b ?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/dropbox",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "description": "Pipedream Dropbox Components",
5
5
  "main": "dropbox.app.mjs",
6
6
  "keywords": [
@@ -13,7 +13,8 @@
13
13
  "dropbox": "^10.34.0",
14
14
  "tmp-promise": "^3.0.3",
15
15
  "isomorphic-fetch": "^3.0.0",
16
- "lodash": "^4.17.21"
16
+ "lodash": "^4.17.21",
17
+ "@types/node-fetch": "^2.5.7"
17
18
  },
18
19
  "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
19
20
  "publishConfig": {
@@ -6,7 +6,7 @@ export default {
6
6
  type: "source",
7
7
  key: "dropbox-all-updates",
8
8
  name: "New or Modified File or Folder",
9
- version: "0.0.13",
9
+ version: "0.0.14",
10
10
  description: "Emit new event when a file or folder is added or modified. Make sure the number of files/folders in the watched folder does not exceed 4000.",
11
11
  props: {
12
12
  ...common.props,
@@ -31,7 +31,7 @@ export default {
31
31
  },
32
32
  async getHistoricalEvents(fileTypes = []) {
33
33
  const files = await this.dropbox.listFilesFolders({
34
- path: this.path?.value || this.path,
34
+ path: this.dropbox.getPath(this.path),
35
35
  recursive: this.recursive,
36
36
  include_media_info: this.includeMediaInfo,
37
37
  });
@@ -7,7 +7,7 @@ export default {
7
7
  type: "source",
8
8
  key: "dropbox-new-file",
9
9
  name: "New File",
10
- version: "0.0.14",
10
+ version: "0.0.15",
11
11
  description: "Emit new event when a new file is added to your account or a specific folder. Make sure the number of files/folders in the watched folder does not exceed 4000.",
12
12
  props: {
13
13
  ...common.props,
@@ -6,7 +6,7 @@ export default {
6
6
  type: "source",
7
7
  key: "dropbox-new-folder",
8
8
  name: "New Folder",
9
- version: "0.0.13",
9
+ version: "0.0.14",
10
10
  description: "Emit new event when a new folder is created. Make sure the number of files/folders in the watched folder does not exceed 4000.",
11
11
  hooks: {
12
12
  async activate() {
@@ -1,21 +0,0 @@
1
- import isEmpty from "lodash/isEmpty.js";
2
- import isNil from "lodash/isNil.js";
3
-
4
- export default {
5
- methods: {
6
- getNormalizedPath: (path, appendFinalBar) => {
7
- let normalizedPath = path?.value || path;
8
-
9
- // Check for empties path
10
- if (isNil(normalizedPath) || isEmpty(normalizedPath)) {
11
- normalizedPath = "/";
12
- }
13
-
14
- if (appendFinalBar && normalizedPath[normalizedPath.length - 1] !== "/") {
15
- normalizedPath += "/";
16
- }
17
-
18
- return normalizedPath;
19
- },
20
- },
21
- };